Add include/hyperkitty.hrl
Browse files- include/hyperkitty.hrl +121 -0
include/hyperkitty.hrl
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%%%-------------------------------------------------------------------
|
| 2 |
+
%%% HyperKitty Chromium :: shared entity schemas (data_model).
|
| 3 |
+
%%%
|
| 4 |
+
%%% These records are the canonical in-memory shape of every entity
|
| 5 |
+
%%% named in the specification's <data_model>. Each has a matching
|
| 6 |
+
%%% `to_map/1' clause in hk_schema.erl for JSON transport. Records
|
| 7 |
+
%%% (not maps) are used for these because entity shape is meant to
|
| 8 |
+
%%% be closed and compiler-checked at the points that construct
|
| 9 |
+
%%% them (agent runtime, browser controller, search harness); the
|
| 10 |
+
%%% *wire* representation is a map/JSON, produced only at the
|
| 11 |
+
%%% boundary, in hk_schema.
|
| 12 |
+
%%% -------------------------------------------------------------------
|
| 13 |
+
|
| 14 |
+
%% ---- Agent ---------------------------------------------------------
|
| 15 |
+
%% Mirrors HK-AGENT's <agent_state> enumeration exactly.
|
| 16 |
+
-record(agent, {
|
| 17 |
+
agent_id :: binary(),
|
| 18 |
+
objective :: #{} | undefined, % #agent_objective{}
|
| 19 |
+
state :: created | ready | planning | executing
|
| 20 |
+
| waiting | completed | failed | terminated,
|
| 21 |
+
capabilities :: [atom()], % explicitly granted tool names
|
| 22 |
+
action_count = 0 :: non_neg_integer(),
|
| 23 |
+
started_at_ms :: integer(),
|
| 24 |
+
updated_at_ms :: integer(),
|
| 25 |
+
limits :: map(), % see hk_agent_fsm limits map
|
| 26 |
+
result :: term() | undefined,
|
| 27 |
+
failure_reason :: term() | undefined
|
| 28 |
+
}).
|
| 29 |
+
|
| 30 |
+
-record(agent_objective, {
|
| 31 |
+
objective_id :: binary(),
|
| 32 |
+
agent_id :: binary(),
|
| 33 |
+
description :: binary(), % what the agent was asked to do
|
| 34 |
+
success_criteria :: binary() | undefined,
|
| 35 |
+
created_at_ms :: integer()
|
| 36 |
+
}).
|
| 37 |
+
|
| 38 |
+
%% ---- Browser --------------------------------------------------------
|
| 39 |
+
-record(browser_session, {
|
| 40 |
+
session_id :: binary(),
|
| 41 |
+
owner_agent_id :: binary() | undefined, % undefined = system/manual session
|
| 42 |
+
profile :: binary(), % profile name, isolates cookies/storage
|
| 43 |
+
pid :: pid() | undefined,
|
| 44 |
+
status :: starting | ready | busy | closing | closed | crashed,
|
| 45 |
+
tabs :: [binary()], % tab_ids
|
| 46 |
+
created_at_ms :: integer(),
|
| 47 |
+
updated_at_ms :: integer()
|
| 48 |
+
}).
|
| 49 |
+
|
| 50 |
+
-record(browser_tab, {
|
| 51 |
+
tab_id :: binary(),
|
| 52 |
+
session_id :: binary(),
|
| 53 |
+
url :: binary() | undefined,
|
| 54 |
+
title :: binary() | undefined,
|
| 55 |
+
status :: opening | loading | idle | closed,
|
| 56 |
+
created_at_ms :: integer(),
|
| 57 |
+
updated_at_ms :: integer()
|
| 58 |
+
}).
|
| 59 |
+
|
| 60 |
+
%% ---- Search -----------------------------------------------------------
|
| 61 |
+
-record(search_job, {
|
| 62 |
+
job_id :: binary(),
|
| 63 |
+
owner_agent_id :: binary() | undefined,
|
| 64 |
+
query :: binary(),
|
| 65 |
+
stage :: user_query | query_normalization | search_planner
|
| 66 |
+
| search_provider | result_normalization | url_deduplication
|
| 67 |
+
| content_retrieval | content_extraction | source_ranking
|
| 68 |
+
| result_synthesis | frontend_visibility | done | failed,
|
| 69 |
+
max_iterations :: pos_integer(),
|
| 70 |
+
iteration :: non_neg_integer(),
|
| 71 |
+
results :: [binary()], % result_ids
|
| 72 |
+
created_at_ms :: integer(),
|
| 73 |
+
updated_at_ms :: integer()
|
| 74 |
+
}).
|
| 75 |
+
|
| 76 |
+
-record(search_result, {
|
| 77 |
+
result_id :: binary(),
|
| 78 |
+
job_id :: binary(),
|
| 79 |
+
url :: binary(),
|
| 80 |
+
normalized_url:: binary(),
|
| 81 |
+
title :: binary() | undefined,
|
| 82 |
+
snippet :: binary() | undefined,
|
| 83 |
+
rank :: number() | undefined,
|
| 84 |
+
source_document_id :: binary() | undefined,
|
| 85 |
+
created_at_ms :: integer()
|
| 86 |
+
}).
|
| 87 |
+
|
| 88 |
+
-record(source_document, {
|
| 89 |
+
document_id :: binary(),
|
| 90 |
+
url :: binary(),
|
| 91 |
+
fetched_at_ms :: integer(),
|
| 92 |
+
content_type :: binary() | undefined,
|
| 93 |
+
extracted_text :: binary() | undefined,
|
| 94 |
+
citation_map :: map() % passage/anchor -> location within extracted_text
|
| 95 |
+
}).
|
| 96 |
+
|
| 97 |
+
%% ---- Messaging --------------------------------------------------------
|
| 98 |
+
-record(message, {
|
| 99 |
+
message_id :: binary(),
|
| 100 |
+
sender :: binary(),
|
| 101 |
+
recipient :: binary(),
|
| 102 |
+
timestamp :: integer(),
|
| 103 |
+
conversation_id :: binary(),
|
| 104 |
+
message_type :: user_to_agent | agent_to_user | agent_to_agent | system,
|
| 105 |
+
payload :: map(),
|
| 106 |
+
status :: queued | delivered | read | failed
|
| 107 |
+
}).
|
| 108 |
+
|
| 109 |
+
%% ---- Operation ----------------------------------------------------------
|
| 110 |
+
%% Every mutating API call returns an #operation{}; see api spec
|
| 111 |
+
%% ("Every mutating operation should return an operation identifier").
|
| 112 |
+
-record(operation, {
|
| 113 |
+
operation_id :: binary(),
|
| 114 |
+
request_id :: binary(),
|
| 115 |
+
kind :: atom(), % e.g. agent_create, browser_navigate, search_start
|
| 116 |
+
status :: accepted | in_progress | succeeded | failed,
|
| 117 |
+
subject :: {atom(), binary()} | undefined,
|
| 118 |
+
error :: map() | undefined,
|
| 119 |
+
created_at_ms :: integer(),
|
| 120 |
+
updated_at_ms :: integer()
|
| 121 |
+
}).
|