hiveagents-runtime 0.0.0-stage → 0.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +85 -2
  3. package/dist/adapter-kit.d.ts +37 -0
  4. package/dist/adapter-kit.js +33 -0
  5. package/dist/adapter-kit.js.map +1 -0
  6. package/dist/agent-D0HS38G3.d.ts +169 -0
  7. package/dist/agent-OLSXNGNN.js +23 -0
  8. package/dist/agent-OLSXNGNN.js.map +1 -0
  9. package/dist/agent-readiness-V36OJME4.js +19 -0
  10. package/dist/agent-readiness-V36OJME4.js.map +1 -0
  11. package/dist/capture-runtime-GP6NZ2ee.d.ts +54 -0
  12. package/dist/chunk-2RUEC63U.js +1217 -0
  13. package/dist/chunk-2RUEC63U.js.map +1 -0
  14. package/dist/chunk-3B3JW4U3.js +291 -0
  15. package/dist/chunk-3B3JW4U3.js.map +1 -0
  16. package/dist/chunk-3TIYA3K5.js +55 -0
  17. package/dist/chunk-3TIYA3K5.js.map +1 -0
  18. package/dist/chunk-6XIJW65Q.js +52 -0
  19. package/dist/chunk-6XIJW65Q.js.map +1 -0
  20. package/dist/chunk-7LDQKJKI.js +248 -0
  21. package/dist/chunk-7LDQKJKI.js.map +1 -0
  22. package/dist/chunk-ALLOMOUN.js +810 -0
  23. package/dist/chunk-ALLOMOUN.js.map +1 -0
  24. package/dist/chunk-C2DN6KL4.js +853 -0
  25. package/dist/chunk-C2DN6KL4.js.map +1 -0
  26. package/dist/chunk-COKYQUTK.js +581 -0
  27. package/dist/chunk-COKYQUTK.js.map +1 -0
  28. package/dist/chunk-CPN4DOXH.js +115 -0
  29. package/dist/chunk-CPN4DOXH.js.map +1 -0
  30. package/dist/chunk-DBFXFWQZ.js +385 -0
  31. package/dist/chunk-DBFXFWQZ.js.map +1 -0
  32. package/dist/chunk-DZFFGUIA.js +81 -0
  33. package/dist/chunk-DZFFGUIA.js.map +1 -0
  34. package/dist/chunk-EEUYQFCP.js +106 -0
  35. package/dist/chunk-EEUYQFCP.js.map +1 -0
  36. package/dist/chunk-GFVYNPLS.js +118 -0
  37. package/dist/chunk-GFVYNPLS.js.map +1 -0
  38. package/dist/chunk-GJ4FTDBJ.js +2910 -0
  39. package/dist/chunk-GJ4FTDBJ.js.map +1 -0
  40. package/dist/chunk-GS5U3KUN.js +201 -0
  41. package/dist/chunk-GS5U3KUN.js.map +1 -0
  42. package/dist/chunk-HB7FBSH2.js +960 -0
  43. package/dist/chunk-HB7FBSH2.js.map +1 -0
  44. package/dist/chunk-HZFZX5A3.js +21 -0
  45. package/dist/chunk-HZFZX5A3.js.map +1 -0
  46. package/dist/chunk-J7VAYJKM.js +595 -0
  47. package/dist/chunk-J7VAYJKM.js.map +1 -0
  48. package/dist/chunk-NCNSHOF7.js +52 -0
  49. package/dist/chunk-NCNSHOF7.js.map +1 -0
  50. package/dist/chunk-RXU2Q2HF.js +49 -0
  51. package/dist/chunk-RXU2Q2HF.js.map +1 -0
  52. package/dist/chunk-SRJUZJKV.js +521 -0
  53. package/dist/chunk-SRJUZJKV.js.map +1 -0
  54. package/dist/chunk-TG7NTMTR.js +208 -0
  55. package/dist/chunk-TG7NTMTR.js.map +1 -0
  56. package/dist/chunk-TIZKGD4R.js +202 -0
  57. package/dist/chunk-TIZKGD4R.js.map +1 -0
  58. package/dist/chunk-WMKO5XOE.js +601 -0
  59. package/dist/chunk-WMKO5XOE.js.map +1 -0
  60. package/dist/chunk-WOQBVJH5.js +175 -0
  61. package/dist/chunk-WOQBVJH5.js.map +1 -0
  62. package/dist/cli.d.ts +1 -0
  63. package/dist/cli.js +25 -0
  64. package/dist/cli.js.map +1 -0
  65. package/dist/errors-DgehLwqI.d.ts +98 -0
  66. package/dist/execution-halt-CW0Oi9s9.d.ts +12 -0
  67. package/dist/execution-types-UJ6gAF48.d.ts +239 -0
  68. package/dist/host-ledger-VPRWVVOS.js +25 -0
  69. package/dist/host-ledger-VPRWVVOS.js.map +1 -0
  70. package/dist/hosted-runtime.d.ts +168 -0
  71. package/dist/hosted-runtime.js +857 -0
  72. package/dist/hosted-runtime.js.map +1 -0
  73. package/dist/index-B86C6VAD.d.ts +41 -0
  74. package/dist/index.d.ts +327 -0
  75. package/dist/index.js +8818 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/memory-items-BSTC0_R0.d.ts +28 -0
  78. package/dist/memory-tools.d.ts +222 -0
  79. package/dist/memory-tools.js +923 -0
  80. package/dist/memory-tools.js.map +1 -0
  81. package/dist/orchestration/dynamic.d.ts +854 -0
  82. package/dist/orchestration/dynamic.js +3150 -0
  83. package/dist/orchestration/dynamic.js.map +1 -0
  84. package/dist/orchestration/graph.d.ts +11 -0
  85. package/dist/orchestration/graph.js +9 -0
  86. package/dist/orchestration/graph.js.map +1 -0
  87. package/dist/orchestration/index.d.ts +2385 -0
  88. package/dist/orchestration/index.js +6403 -0
  89. package/dist/orchestration/index.js.map +1 -0
  90. package/dist/orchestration/log.d.ts +301 -0
  91. package/dist/orchestration/log.js +3058 -0
  92. package/dist/orchestration/log.js.map +1 -0
  93. package/dist/orchestration/memory.d.ts +711 -0
  94. package/dist/orchestration/memory.js +27 -0
  95. package/dist/orchestration/memory.js.map +1 -0
  96. package/dist/provider-XCpWjJ6a.d.ts +151 -0
  97. package/dist/routing/index.d.ts +29 -0
  98. package/dist/routing/index.js +385 -0
  99. package/dist/routing/index.js.map +1 -0
  100. package/dist/routing/learning/index.d.ts +433 -0
  101. package/dist/routing/learning/index.js +2501 -0
  102. package/dist/routing/learning/index.js.map +1 -0
  103. package/dist/runtime-C6Cu2fvw.d.ts +283 -0
  104. package/dist/runtime-Y72XJFFO.js +18 -0
  105. package/dist/runtime-Y72XJFFO.js.map +1 -0
  106. package/dist/store-types-2YdceOMy.d.ts +78 -0
  107. package/dist/types-BB7KqceP.d.ts +52 -0
  108. package/dist/types-BBRKjIc7.d.ts +86 -0
  109. package/dist/types-DTFc1qO6.d.ts +1065 -0
  110. package/dist/types-DYex3p7_.d.ts +88 -0
  111. package/docs/licenses/ruflo-memory-MIT.txt +21 -0
  112. package/docs/releases/0.1.0-beta.1.md +13 -0
  113. package/package.json +114 -4
@@ -0,0 +1,28 @@
1
+ import { R as RecalledMemory } from './types-DTFc1qO6.js';
2
+
3
+ /**
4
+ * The rules a recalled item must meet before the SDK carries it to a model. Pure and
5
+ * dependency-free, so a memory adapter can apply the same rules before it counts an item
6
+ * against its limit, instead of returning something the SDK would then drop.
7
+ */
8
+ /** Longest id, source or title the SDK carries. */
9
+ declare const MEMORY_LABEL_MAX = 256;
10
+ /** Longest `observedAt` the SDK carries. */
11
+ declare const MEMORY_OBSERVED_AT_MAX = 64;
12
+ /** A non-empty single-line label of at most `max` characters with no control or invisible format character. */
13
+ declare function isMemoryLabel(value: unknown, max?: number): value is string;
14
+ /**
15
+ * A scope profile as the SDK will carry it, or undefined when it is unusable: not a string,
16
+ * containing NUL, or empty or only whitespace once tag characters are removed. Tag characters
17
+ * are removed; nothing else changes (every line is indented under the profile header when rendered).
18
+ */
19
+ declare function profileText(value: unknown): string | undefined;
20
+ /**
21
+ * The item as the SDK will carry it, or undefined when it must be dropped. An unusable title is
22
+ * left out rather than dropping the item; an unusable id, source, observedAt or text drops it.
23
+ * Tag characters are removed from the text; the text must still have something visible.
24
+ * `observedAt` is carried normalized to `toISOString()` (UTC, milliseconds).
25
+ */
26
+ declare function recallableMemory(value: unknown): RecalledMemory | undefined;
27
+
28
+ export { MEMORY_LABEL_MAX as M, MEMORY_OBSERVED_AT_MAX as a, isMemoryLabel as i, profileText as p, recallableMemory as r };
@@ -0,0 +1,222 @@
1
+ import { g as AgentMemoryProvider, h as AgentMemoryScope, i as ApplicationToolScope, j as ApplicationTool, P as ProviderId } from './types-DTFc1qO6.js';
2
+ export { k as ApplicationToolContext, l as MemoryProposeRequest, m as MemoryRecallRequest, R as RecalledMemory } from './types-DTFc1qO6.js';
3
+ import { Readable, Writable } from 'node:stream';
4
+
5
+ /**
6
+ * The memory tools an agent calls, shared by the control-transport application tools and the
7
+ * stdio MCP server. The application fixes the provider and the scope when it builds the tool
8
+ * set: no argument a model writes can name, change or widen the scope. Search goes through
9
+ * `provider.recall`, so it returns only what the provider would recall for a turn, under the
10
+ * same item rules and the same byte budget; propose hands the provider a candidate, which the
11
+ * provider contract keeps out of recall until the application promotes it.
12
+ */
13
+ declare const MEMORY_SEARCH_TOOL = "memory_search";
14
+ declare const MEMORY_PROPOSE_TOOL = "memory_propose";
15
+ /** Longest query or proposed text, in Unicode code points (as JSON Schema `maxLength` counts). */
16
+ declare const MEMORY_TOOL_TEXT_MAX = 4096;
17
+ declare const MEMORY_TOOL_DEFAULT_PROPOSALS_PER_MINUTE = 10;
18
+ /** Carried on every search result: the items are the same untrusted data as the prompt's recalled block. */
19
+ declare const MEMORY_TOOL_NOTICE: string;
20
+ /** Carried on every proposal result. */
21
+ declare const MEMORY_PROPOSE_NOTICE = "not recallable until the application promotes it";
22
+ type MemoryToolErrorCode = 'INVALID_INPUT' | 'RATE_LIMITED' | 'TIMEOUT' | 'CANCELLED' | 'PROVIDER_FAILED';
23
+ /**
24
+ * A memory tool failure as the model sees it: a closed code and a short fixed message written by
25
+ * the SDK. A provider's own error text, stack or fields never reach it; they go only to the
26
+ * application's `onError` (or the MCP server's `log`).
27
+ */
28
+ declare class MemoryToolError extends Error {
29
+ readonly name = "MemoryToolError";
30
+ readonly code: MemoryToolErrorCode;
31
+ constructor(code: MemoryToolErrorCode, message: string);
32
+ toJSON(): {
33
+ code: MemoryToolErrorCode;
34
+ message: string;
35
+ };
36
+ }
37
+ /** One item as a search returns it. */
38
+ interface MemorySearchItem {
39
+ readonly id: string;
40
+ readonly source: string;
41
+ readonly title?: string;
42
+ readonly observedAt?: string;
43
+ readonly text: string;
44
+ }
45
+ interface MemorySearchResult {
46
+ readonly notice: string;
47
+ readonly items: readonly MemorySearchItem[];
48
+ /** Items the provider returned that were malformed, repeated, or over the item or byte budget. */
49
+ readonly omitted: number;
50
+ }
51
+ interface MemoryProposeResult {
52
+ readonly id: string;
53
+ readonly status: 'candidate';
54
+ readonly notice: string;
55
+ }
56
+ /** What every memory tool surface accepts. */
57
+ interface MemoryToolsBaseOptions {
58
+ readonly provider: AgentMemoryProvider;
59
+ /** Fixed by the application; never taken from a tool argument. */
60
+ readonly scope: AgentMemoryScope;
61
+ /** Items a search returns at most: default 2, at most 8 (as `AgentOptions.memory`). A call's `limit` can only lower it. */
62
+ readonly maxItems?: number;
63
+ /**
64
+ * UTF-8 bytes of the returned items, each measured as its JSON object: default 8 KiB, at least
65
+ * 256, at most 32 KiB. Items are whole or left out, and counted in `omitted`.
66
+ */
67
+ readonly maxBytes?: number;
68
+ /** Deadline of one provider call (recall or propose): default 2000 ms, at most 60000. */
69
+ readonly timeoutMs?: number;
70
+ /**
71
+ * Offer `memory_propose`. Needs a provider with `propose` (a TypeError otherwise). Default false.
72
+ * `memory_search` is offered when the provider has `recall`; a provider with `propose` and no
73
+ * `recall` (a persistence-only provider) serves `memory_propose` alone. A tool set with neither is a TypeError.
74
+ */
75
+ readonly propose?: boolean;
76
+ /**
77
+ * Proposals per rolling minute by this tool set: default 10, at most 600. A proposal takes its
78
+ * slot when it is admitted (a call already cancelled is not admitted) and gives it back only
79
+ * when the provider refuses it as written (a TypeError, reported as `INVALID_INPUT`). Any other
80
+ * outcome keeps it, because the provider may have stored the proposal: an accepted proposal, an
81
+ * answer without a usable id, another provider error (`PROVIDER_FAILED`), a timeout or a
82
+ * cancellation after the provider was called (the store may still commit it).
83
+ */
84
+ readonly proposalsPerMinute?: number;
85
+ /** Receives provider failures, which the model sees only as a code and a fixed message. */
86
+ readonly onError?: (error: unknown) => void;
87
+ }
88
+
89
+ /** `MemoryProposeRequest.origin` of a proposal made through these application tools. */
90
+ declare const MEMORY_TOOL_ORIGIN = "memory-tool";
91
+ interface MemoryToolsOptions extends MemoryToolsBaseOptions {
92
+ /**
93
+ * The working directory the tools serve. When set, `authorize` admits a call only from a session
94
+ * whose resolved cwd is this one. Without it any session of the Agent the tools are given to is
95
+ * admitted; the memory scope stays the fixed one either way.
96
+ */
97
+ readonly cwd?: string;
98
+ /** An extra application check on each call's trusted scope (session, turn, provider); it must return true. */
99
+ readonly authorize?: (scope: Readonly<ApplicationToolScope>) => boolean | Promise<boolean>;
100
+ }
101
+ /**
102
+ * The memory tools as application tools for a control transport (`AgentOptions.tools`, which needs
103
+ * `providerOptions.experimentalControl` and, for Claude control, `experimentalApi`).
104
+ *
105
+ * - `memory_search` `{ query, limit? }`, when the provider has `recall`, asks it with the fixed scope
106
+ * and returns `{ notice, items: [{ id, source, title?, observedAt?, text }], omitted }`.
107
+ * - `memory_propose` `{ text, title? }`, only with `propose: true`, hands `provider.propose` a candidate
108
+ * with origin `memory-tool` and returns `{ id, status: 'candidate', notice }`. A provider with
109
+ * `propose` and no `recall` gives a tool set of `memory_propose` alone; one that would offer no
110
+ * tool at all is a TypeError.
111
+ *
112
+ * `authorize` admits only control-transport calls whose input has no field beyond the tool's own,
113
+ * from the configured `cwd` when one is set, and passing the application's `authorize` when given.
114
+ * A failure is a JSON result `{ error: { code, message } }` with a closed code and an SDK message.
115
+ */
116
+ declare function memoryTools(options: MemoryToolsOptions): ApplicationTool[];
117
+
118
+ interface MemoryMcpLogEntry {
119
+ readonly level: 'info' | 'warn' | 'error';
120
+ readonly message: string;
121
+ }
122
+ interface MemoryMcpServerOptions extends MemoryToolsBaseOptions {
123
+ /** Newline-delimited JSON-RPC from the client, e.g. `process.stdin`. */
124
+ readonly input: Readable;
125
+ /** Receives protocol messages and nothing else, e.g. `process.stdout`. */
126
+ readonly output: Writable;
127
+ /** `serverInfo.name` and the `mcp:<name>` origin of proposals; default `oar-memory`. */
128
+ readonly name?: string;
129
+ readonly version?: string;
130
+ /** `MemoryRecallRequest.provider` for searches: the CLI that launched this server; default `unknown`. */
131
+ readonly agentProvider?: ProviderId;
132
+ /** `MemoryRecallRequest.cwd` for searches; default `process.cwd()`. */
133
+ readonly cwd?: string;
134
+ /** Longest input line in bytes: default 1 MiB, from 1 KiB to 16 MiB. A longer line is refused unread. */
135
+ readonly maxLineBytes?: number;
136
+ /**
137
+ * Tool calls running at once: default 4, at most 64. Further calls wait: from 16 waiting per slot
138
+ * the server stops reading its input (the rest of a chunk included) until fewer than 8 per slot
139
+ * wait, and a call past 32 waiting per slot, which only a batch can reach, is refused with `-32000`.
140
+ * Input is not read either while `output.write()` reports a full buffer, until `'drain'`.
141
+ */
142
+ readonly maxConcurrency?: number;
143
+ /**
144
+ * Diagnostics; never written to `output`. Messages are fixed SDK text in which an error appears
145
+ * only as its class name: never the client's input, nor a provider's error message or fields
146
+ * (which may quote that input). The error itself goes to `onError`.
147
+ */
148
+ readonly log?: (entry: MemoryMcpLogEntry) => void;
149
+ }
150
+ interface MemoryMcpServerHandle {
151
+ /** Settles once the server has stopped: input ended or closed, output failed, or `close()`. */
152
+ readonly closed: Promise<void>;
153
+ /** Stops reading, cancels running tool calls and resolves `closed`. */
154
+ close(): Promise<void>;
155
+ }
156
+ /**
157
+ * A minimal MCP server over newline-delimited JSON-RPC 2.0 exposing `memory_search` and, with
158
+ * `propose: true`, `memory_propose`, for exec CLIs that take MCP servers (Claude exec through
159
+ * `providerOptions.claude.mcpConfigs`, Codex exec through `mcp_servers`). `memory_search` is offered
160
+ * when the provider has `recall`, so a persistence-only provider with `propose: true` serves
161
+ * `memory_propose` alone. The application writes a
162
+ * small script that builds its provider and calls this with `process.stdin` and `process.stdout`;
163
+ * `memoryMcpRecipe` builds the launch entry for that script. The scope is fixed here: no tool
164
+ * argument can name it. Speaks the legacy `initialize` handshake (2025-11-25, 2025-06-18,
165
+ * 2025-03-26, 2024-11-05) and the stateless 2026-07-28 revision.
166
+ */
167
+ declare function serveMemoryMcp(options: MemoryMcpServerOptions): MemoryMcpServerHandle;
168
+
169
+ /**
170
+ * The slice of the Model Context Protocol the memory server speaks, verified against
171
+ * https://modelcontextprotocol.io/specification (revisions 2026-07-28, 2025-11-25, 2025-06-18,
172
+ * 2025-03-26 and 2024-11-05: base protocol, versioning, lifecycle, ping, stdio and tools pages).
173
+ *
174
+ * - Legacy revisions (2025-11-25 and earlier) open with `initialize`: the server answers with the
175
+ * client's requested version when it supports it, otherwise with its latest legacy version.
176
+ * - The modern revision (2026-07-28) has no handshake: every request carries its version and the
177
+ * client capabilities in `params._meta`, results carry `resultType`, and `server/discover` lists
178
+ * the versions. A request carrying the modern version key is served statelessly; an
179
+ * unsupported version gets `-32022` with the supported list.
180
+ * - `structuredContent` and tool `title` exist from 2025-06-18 on; JSON-RPC batches only in 2025-03-26.
181
+ * - JSON-RPC 2.0 leaves -32000 to -32099 to the server: `SERVER_BUSY` refuses a call past the queue cap.
182
+ */
183
+ declare const MCP_MODERN_VERSIONS: readonly string[];
184
+ /** Newest first: the first one answers an `initialize` that asks for a version not listed here. */
185
+ declare const MCP_LEGACY_VERSIONS: readonly string[];
186
+ declare const MCP_SUPPORTED_VERSIONS: readonly string[];
187
+
188
+ /**
189
+ * The launch entry of an application's memory MCP server script. Pure: it formats data and
190
+ * starts nothing.
191
+ *
192
+ * Structurally the same `McpServerRecipe` that `hiveagents-runtime/orchestration/memory` exports
193
+ * (and that its `claudeMcpConfig` accepts): `{ name, command, args, env }`. The type is repeated
194
+ * here rather than imported because nothing outside `src/orchestration/memory` may import that
195
+ * folder except through its two public entries, and this entry must stay free of it.
196
+ */
197
+ interface MemoryMcpRecipe {
198
+ readonly name: string;
199
+ /** The absolute path given as `executable`. */
200
+ readonly command: string;
201
+ readonly args: readonly string[];
202
+ readonly env: Readonly<Record<string, string>>;
203
+ }
204
+ interface MemoryMcpRecipeOptions {
205
+ /** MCP server name; Claude names the tools `mcp__<name>__memory_search`. Default `oar-memory`. */
206
+ readonly name?: string;
207
+ /** Absolute path of the Node.js binary that runs the script, e.g. `process.execPath`. */
208
+ readonly executable: string;
209
+ /** Absolute path of the application's script that calls `serveMemoryMcp`. */
210
+ readonly script: string;
211
+ /** Environment for the server process, e.g. the path of the memory database. */
212
+ readonly env?: Readonly<Record<string, string>>;
213
+ }
214
+ /**
215
+ * `<executable> <script>` with the given environment. Pass the result to `claudeMcpConfig` for
216
+ * `providerOptions.claude.mcpConfigs` (Claude exec). For Codex exec the same command, args and env
217
+ * go in a `mcp_servers.<name>` entry of `providerOptions.codex.config`; no Codex helper is offered
218
+ * because that entry's layout is not verified against the Codex CLI in this repository.
219
+ */
220
+ declare function memoryMcpRecipe(options: MemoryMcpRecipeOptions): MemoryMcpRecipe;
221
+
222
+ export { AgentMemoryProvider, AgentMemoryScope, ApplicationTool, ApplicationToolScope, MCP_LEGACY_VERSIONS, MCP_MODERN_VERSIONS, MCP_SUPPORTED_VERSIONS, MEMORY_PROPOSE_NOTICE, MEMORY_PROPOSE_TOOL, MEMORY_SEARCH_TOOL, MEMORY_TOOL_DEFAULT_PROPOSALS_PER_MINUTE, MEMORY_TOOL_NOTICE, MEMORY_TOOL_ORIGIN, MEMORY_TOOL_TEXT_MAX, type MemoryMcpLogEntry, type MemoryMcpRecipe, type MemoryMcpRecipeOptions, type MemoryMcpServerHandle, type MemoryMcpServerOptions, type MemoryProposeResult, type MemorySearchItem, type MemorySearchResult, MemoryToolError, type MemoryToolErrorCode, type MemoryToolsBaseOptions, type MemoryToolsOptions, memoryMcpRecipe, memoryTools, serveMemoryMcp };