hiveagents-runtime 0.0.0-stage → 0.1.0-beta.3
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.
- package/LICENSE +202 -0
- package/README.md +89 -2
- package/dist/adapter-kit.d.ts +37 -0
- package/dist/adapter-kit.js +34 -0
- package/dist/adapter-kit.js.map +1 -0
- package/dist/agent-Bj5YPrO7.d.ts +169 -0
- package/dist/agent-D6OXR7UF.js +24 -0
- package/dist/agent-D6OXR7UF.js.map +1 -0
- package/dist/agent-readiness-KSGNKTGK.js +19 -0
- package/dist/agent-readiness-KSGNKTGK.js.map +1 -0
- package/dist/capture-runtime-GP6NZ2ee.d.ts +54 -0
- package/dist/chunk-2RK74GCA.js +2397 -0
- package/dist/chunk-2RK74GCA.js.map +1 -0
- package/dist/chunk-3TIYA3K5.js +55 -0
- package/dist/chunk-3TIYA3K5.js.map +1 -0
- package/dist/chunk-6FIXXWNM.js +1 -0
- package/dist/chunk-6FIXXWNM.js.map +1 -0
- package/dist/chunk-6XIJW65Q.js +52 -0
- package/dist/chunk-6XIJW65Q.js.map +1 -0
- package/dist/chunk-7LDQKJKI.js +248 -0
- package/dist/chunk-7LDQKJKI.js.map +1 -0
- package/dist/chunk-CPN4DOXH.js +115 -0
- package/dist/chunk-CPN4DOXH.js.map +1 -0
- package/dist/chunk-DAXPAV2L.js +810 -0
- package/dist/chunk-DAXPAV2L.js.map +1 -0
- package/dist/chunk-DQEMIGKC.js +291 -0
- package/dist/chunk-DQEMIGKC.js.map +1 -0
- package/dist/chunk-DZFFGUIA.js +81 -0
- package/dist/chunk-DZFFGUIA.js.map +1 -0
- package/dist/chunk-EEUYQFCP.js +106 -0
- package/dist/chunk-EEUYQFCP.js.map +1 -0
- package/dist/chunk-G6JV7WV6.js +521 -0
- package/dist/chunk-G6JV7WV6.js.map +1 -0
- package/dist/chunk-GFVYNPLS.js +118 -0
- package/dist/chunk-GFVYNPLS.js.map +1 -0
- package/dist/chunk-GS5U3KUN.js +201 -0
- package/dist/chunk-GS5U3KUN.js.map +1 -0
- package/dist/chunk-HB7FBSH2.js +960 -0
- package/dist/chunk-HB7FBSH2.js.map +1 -0
- package/dist/chunk-HZFZX5A3.js +21 -0
- package/dist/chunk-HZFZX5A3.js.map +1 -0
- package/dist/chunk-J7VAYJKM.js +595 -0
- package/dist/chunk-J7VAYJKM.js.map +1 -0
- package/dist/chunk-NCNSHOF7.js +52 -0
- package/dist/chunk-NCNSHOF7.js.map +1 -0
- package/dist/chunk-RH5A5U7G.js +202 -0
- package/dist/chunk-RH5A5U7G.js.map +1 -0
- package/dist/chunk-RX3XZENU.js +385 -0
- package/dist/chunk-RX3XZENU.js.map +1 -0
- package/dist/chunk-RXU2Q2HF.js +49 -0
- package/dist/chunk-RXU2Q2HF.js.map +1 -0
- package/dist/chunk-TG7NTMTR.js +208 -0
- package/dist/chunk-TG7NTMTR.js.map +1 -0
- package/dist/chunk-TWGEYWMO.js +1217 -0
- package/dist/chunk-TWGEYWMO.js.map +1 -0
- package/dist/chunk-UZPDDQVJ.js +2910 -0
- package/dist/chunk-UZPDDQVJ.js.map +1 -0
- package/dist/chunk-WMKO5XOE.js +601 -0
- package/dist/chunk-WMKO5XOE.js.map +1 -0
- package/dist/chunk-WOQBVJH5.js +175 -0
- package/dist/chunk-WOQBVJH5.js.map +1 -0
- package/dist/chunk-WVT5SEKC.js +581 -0
- package/dist/chunk-WVT5SEKC.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +26 -0
- package/dist/cli.js.map +1 -0
- package/dist/errors-BNHvvjn9.d.ts +98 -0
- package/dist/execution-halt-B8G0fOKS.d.ts +12 -0
- package/dist/execution-types-ClYYqPQP.d.ts +239 -0
- package/dist/host-ledger-VPRWVVOS.js +25 -0
- package/dist/host-ledger-VPRWVVOS.js.map +1 -0
- package/dist/hosted-runtime.d.ts +168 -0
- package/dist/hosted-runtime.js +858 -0
- package/dist/hosted-runtime.js.map +1 -0
- package/dist/index-B86C6VAD.d.ts +41 -0
- package/dist/index.d.ts +344 -0
- package/dist/index.js +8825 -0
- package/dist/index.js.map +1 -0
- package/dist/memory-items-BSTC0_R0.d.ts +28 -0
- package/dist/memory-tools.d.ts +222 -0
- package/dist/memory-tools.js +923 -0
- package/dist/memory-tools.js.map +1 -0
- package/dist/orchestration/dynamic.d.ts +854 -0
- package/dist/orchestration/dynamic.js +3150 -0
- package/dist/orchestration/dynamic.js.map +1 -0
- package/dist/orchestration/graph.d.ts +11 -0
- package/dist/orchestration/graph.js +9 -0
- package/dist/orchestration/graph.js.map +1 -0
- package/dist/orchestration/index.d.ts +2385 -0
- package/dist/orchestration/index.js +6409 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/log.d.ts +301 -0
- package/dist/orchestration/log.js +3058 -0
- package/dist/orchestration/log.js.map +1 -0
- package/dist/orchestration/memory.d.ts +711 -0
- package/dist/orchestration/memory.js +27 -0
- package/dist/orchestration/memory.js.map +1 -0
- package/dist/provider-DX5Mf0uq.d.ts +151 -0
- package/dist/routing/index.d.ts +29 -0
- package/dist/routing/index.js +386 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/learning/index.d.ts +433 -0
- package/dist/routing/learning/index.js +2502 -0
- package/dist/routing/learning/index.js.map +1 -0
- package/dist/runtime-BSjrnxeF.d.ts +283 -0
- package/dist/runtime-OISPXS4I.js +19 -0
- package/dist/runtime-OISPXS4I.js.map +1 -0
- package/dist/store-types-2YdceOMy.d.ts +78 -0
- package/dist/types-BB7KqceP.d.ts +52 -0
- package/dist/types-CIqkKXix.d.ts +86 -0
- package/dist/types-DTFc1qO6.d.ts +1065 -0
- package/dist/types-DYex3p7_.d.ts +88 -0
- package/docs/licenses/ruflo-memory-MIT.txt +21 -0
- package/docs/releases/0.1.0-beta.3.md +13 -0
- package/package.json +114 -4
|
@@ -0,0 +1,1065 @@
|
|
|
1
|
+
/** Application-owned authority. A tool declaration never grants permissions. */
|
|
2
|
+
interface ApplicationToolScope {
|
|
3
|
+
readonly provider: ProviderId;
|
|
4
|
+
readonly transport: TransportKind;
|
|
5
|
+
readonly cwd: string;
|
|
6
|
+
readonly sessionId: string;
|
|
7
|
+
readonly turnId?: string;
|
|
8
|
+
readonly callId?: string;
|
|
9
|
+
readonly authorityEpoch: string;
|
|
10
|
+
}
|
|
11
|
+
interface ApplicationToolContext {
|
|
12
|
+
readonly signal: AbortSignal;
|
|
13
|
+
/** Effective tool/turn deadline, as epoch milliseconds. */
|
|
14
|
+
readonly deadline: number;
|
|
15
|
+
readonly scope: Readonly<ApplicationToolScope>;
|
|
16
|
+
}
|
|
17
|
+
interface ApplicationTool {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
inputSchema: Record<string, unknown>;
|
|
21
|
+
timeoutMs: number;
|
|
22
|
+
maxOutputBytes: number;
|
|
23
|
+
authorize(input: unknown, context: ApplicationToolContext): boolean | Promise<boolean>;
|
|
24
|
+
execute(input: unknown, context: ApplicationToolContext): unknown | Promise<unknown>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface LaunchTarget {
|
|
28
|
+
command: string;
|
|
29
|
+
argsPrefix: string[];
|
|
30
|
+
}
|
|
31
|
+
declare function resolveBinary(name: string, options?: {
|
|
32
|
+
platform?: NodeJS.Platform;
|
|
33
|
+
env?: NodeJS.ProcessEnv;
|
|
34
|
+
}): LaunchTarget | undefined;
|
|
35
|
+
/** Ordered, canonical, unique executables. A stale shim must not hide a healthy install later on PATH. */
|
|
36
|
+
declare function resolveBinaryCandidates(name: string, options?: {
|
|
37
|
+
platform?: NodeJS.Platform;
|
|
38
|
+
env?: NodeJS.ProcessEnv;
|
|
39
|
+
}): LaunchTarget[];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Per-agent memory: the public contract.
|
|
43
|
+
*
|
|
44
|
+
* Memory is an application resource. The SDK never stores, embeds or ranks
|
|
45
|
+
* anything itself here: it asks the application's provider for a few recalled
|
|
46
|
+
* items before a turn, carries them to the model as reference data (never as
|
|
47
|
+
* instructions), and, only when asked, hands the completed turn back to the
|
|
48
|
+
* provider afterwards. Every step is opt-in and fail-open: a provider that
|
|
49
|
+
* fails or is slow never fails the turn, and the turn records what happened.
|
|
50
|
+
*
|
|
51
|
+
* The scope is chosen by the application and is never derived from anything
|
|
52
|
+
* the model wrote. It has the same shape as the orchestration memory ports'
|
|
53
|
+
* `MemoryScope`, so a port implementation can serve it directly.
|
|
54
|
+
*/
|
|
55
|
+
interface AgentMemoryScope {
|
|
56
|
+
readonly tenant: string;
|
|
57
|
+
readonly namespace: string;
|
|
58
|
+
readonly subject?: string;
|
|
59
|
+
}
|
|
60
|
+
/** What the provider is asked before one turn. */
|
|
61
|
+
interface MemoryRecallRequest {
|
|
62
|
+
readonly scope: AgentMemoryScope;
|
|
63
|
+
/** The turn's user text (text items joined); never includes earlier recalled blocks. */
|
|
64
|
+
readonly text: string;
|
|
65
|
+
readonly provider: ProviderId;
|
|
66
|
+
readonly transport: TransportKind;
|
|
67
|
+
readonly cwd: string;
|
|
68
|
+
/** Upper bound the SDK will carry; a provider may return fewer, never needs to return more. */
|
|
69
|
+
readonly limit: number;
|
|
70
|
+
/** Aborted when the recall deadline passes or the turn is cancelled. */
|
|
71
|
+
readonly signal: AbortSignal;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* One recalled item. Its text is data the model may read, not an instruction it must follow.
|
|
75
|
+
* The SDK drops (and counts in `omitted`) an item whose `id` or `source` is empty, longer than
|
|
76
|
+
* 256 characters, or contains a line break, a control character or an invisible format
|
|
77
|
+
* character (zero-width, bidi override, tag), and an `id` or `source` with any opening or closing
|
|
78
|
+
* punctuation after NFKC normalization (Unicode `Ps`/`Pe`: square brackets and their fullwidth or
|
|
79
|
+
* other look-alikes, parentheses, braces, and the square-bracket pieces U+23A1-U+23A6, U+23B4-U+23B5), since they sit between brackets on the SDK-owned item
|
|
80
|
+
* header; whose `observedAt` is longer than 64 characters or is not a strict ISO-8601 date and
|
|
81
|
+
* time with an offset (`YYYY-MM-DDTHH:MM[:SS[.fraction]]` then `Z` or `±HH:MM`); whose `text` is
|
|
82
|
+
* empty, contains NUL or is only tag characters; or whose id repeats an earlier item's. A
|
|
83
|
+
* `title` that breaks the `id` rules is left out and the item kept. Tag characters are removed
|
|
84
|
+
* from the text, and `observedAt` is carried as `Date.prototype.toISOString()` gives it. The
|
|
85
|
+
* exported `recallableMemory` applies exactly these rules.
|
|
86
|
+
*/
|
|
87
|
+
interface RecalledMemory {
|
|
88
|
+
readonly id: string;
|
|
89
|
+
readonly text: string;
|
|
90
|
+
readonly title?: string;
|
|
91
|
+
/** Provenance label shown to the model and recorded on the turn, e.g. `sqlite-system-memory`. */
|
|
92
|
+
readonly source: string;
|
|
93
|
+
/** Strict ISO-8601 time the remembered fact was observed, when the provider knows it; carried in UTC. */
|
|
94
|
+
readonly observedAt?: string;
|
|
95
|
+
}
|
|
96
|
+
/** What the provider receives after a completed turn, only when `MemoryOption.capture` is true. */
|
|
97
|
+
interface MemoryCaptureRequest {
|
|
98
|
+
readonly scope: AgentMemoryScope;
|
|
99
|
+
/** The user text of the turn, without the recalled block the SDK prepended. */
|
|
100
|
+
readonly input: string;
|
|
101
|
+
readonly turn: Turn;
|
|
102
|
+
/** ISO-8601 time the SDK delivered the completed turn; stable for a retried capture of the same request. */
|
|
103
|
+
readonly completedAt: string;
|
|
104
|
+
/** Aborted after `MEMORY_CAPTURE_TIMEOUT_MS`. */
|
|
105
|
+
readonly signal: AbortSignal;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* An application's memory backend for agents. Every method is optional: a
|
|
109
|
+
* read-only memory implements `recall`, a recorder implements `capture`.
|
|
110
|
+
* `AgentOptions.memory` needs `recall`, `capture` or `profile` (a provider with
|
|
111
|
+
* only `propose` is a TypeError there: it serves only the memory tools).
|
|
112
|
+
* Implementations must be safe to share between agents and sessions; per-call
|
|
113
|
+
* identity arrives in the request, never in the provider instance.
|
|
114
|
+
*/
|
|
115
|
+
interface AgentMemoryProvider {
|
|
116
|
+
/**
|
|
117
|
+
* Stable label recorded on every turn note, e.g. `sqlite-system-memory` or `agentdb`. It is the
|
|
118
|
+
* source on the `### Profile [source: <id>]` header, so `AgentOptions.memory` refuses an id that
|
|
119
|
+
* breaks the item id rules (see `RecalledMemory`), brackets and other opening or closing punctuation included.
|
|
120
|
+
*/
|
|
121
|
+
readonly id: string;
|
|
122
|
+
recall?(request: MemoryRecallRequest): Promise<readonly RecalledMemory[]>;
|
|
123
|
+
capture?(request: MemoryCaptureRequest): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* The scope's fixed profile: a short text the application maintains (who the user is, the
|
|
126
|
+
* project's conventions). Carried on every turn before the recalled items, under its own
|
|
127
|
+
* budget. Only the application writes it; nothing an agent does reaches it. Asked in parallel
|
|
128
|
+
* with `recall`, under the same deadline and signal, and just as fail-open; undefined means the
|
|
129
|
+
* scope has no profile. The exported `profileText` applies the SDK's rules to the text.
|
|
130
|
+
*/
|
|
131
|
+
profile?(request: MemoryProfileRequest): Promise<string | undefined>;
|
|
132
|
+
/**
|
|
133
|
+
* Stores something the agent proposes to remember, through a memory tool. A proposal is a
|
|
134
|
+
* candidate, never recallable until the application promotes it; the result names it. Throw a
|
|
135
|
+
* `TypeError` to refuse a proposal as written (e.g. over the store's size bound): the tool
|
|
136
|
+
* reports `INVALID_INPUT` with the SDK's own message; any other error is `PROVIDER_FAILED`.
|
|
137
|
+
*/
|
|
138
|
+
propose?(request: MemoryProposeRequest): Promise<{
|
|
139
|
+
readonly id: string;
|
|
140
|
+
}>;
|
|
141
|
+
}
|
|
142
|
+
/** What the provider is asked for the scope's profile, once per turn. */
|
|
143
|
+
interface MemoryProfileRequest {
|
|
144
|
+
readonly scope: AgentMemoryScope;
|
|
145
|
+
readonly provider: ProviderId;
|
|
146
|
+
readonly transport: TransportKind;
|
|
147
|
+
readonly cwd: string;
|
|
148
|
+
readonly signal: AbortSignal;
|
|
149
|
+
}
|
|
150
|
+
/** A memory the agent proposes through a memory tool; untrusted model output. */
|
|
151
|
+
interface MemoryProposeRequest {
|
|
152
|
+
readonly scope: AgentMemoryScope;
|
|
153
|
+
readonly text: string;
|
|
154
|
+
readonly title?: string;
|
|
155
|
+
/** Where the proposal came from, e.g. `memory-tool` or `mcp:<server name>`. */
|
|
156
|
+
readonly origin: string;
|
|
157
|
+
readonly signal: AbortSignal;
|
|
158
|
+
}
|
|
159
|
+
/** Defaults and ceilings of the memory option. */
|
|
160
|
+
declare const MEMORY_DEFAULT_MAX_ITEMS = 2;
|
|
161
|
+
declare const MEMORY_MAX_ITEMS_CEILING = 8;
|
|
162
|
+
declare const MEMORY_DEFAULT_MAX_BYTES: number;
|
|
163
|
+
declare const MEMORY_MAX_BYTES_CEILING: number;
|
|
164
|
+
declare const MEMORY_DEFAULT_RECALL_TIMEOUT_MS = 2000;
|
|
165
|
+
/** Profile budget: UTF-8 bytes of the profile section as rendered (see `MemoryOption.maxProfileBytes`). */
|
|
166
|
+
declare const MEMORY_DEFAULT_MAX_PROFILE_BYTES: number;
|
|
167
|
+
declare const MEMORY_MAX_PROFILE_BYTES_CEILING: number;
|
|
168
|
+
/** Bound on one background capture, and on how long `close()` waits for pending captures. */
|
|
169
|
+
declare const MEMORY_CAPTURE_TIMEOUT_MS = 10000;
|
|
170
|
+
/**
|
|
171
|
+
* Opt-in per-agent memory, set on `AgentOptions.memory` (or as a Runtime
|
|
172
|
+
* default). Its absence changes nothing.
|
|
173
|
+
*/
|
|
174
|
+
interface MemoryOption {
|
|
175
|
+
readonly provider: AgentMemoryProvider;
|
|
176
|
+
readonly scope: AgentMemoryScope;
|
|
177
|
+
/** Recalled items carried per turn: default 2, at most 8. */
|
|
178
|
+
readonly maxItems?: number;
|
|
179
|
+
/**
|
|
180
|
+
* UTF-8 bytes of the recalled items carried per turn, as rendered: every kept item's header,
|
|
181
|
+
* title line and indented text lines count, datamarked (each whitespace run inside a line is
|
|
182
|
+
* U+02C6, 2 bytes); only the block's fixed heading, preamble and end
|
|
183
|
+
* marker do not. Default 8 KiB, at least 256, at most 32 KiB. Items are whole or left out.
|
|
184
|
+
*/
|
|
185
|
+
readonly maxBytes?: number;
|
|
186
|
+
/**
|
|
187
|
+
* Recall deadline; on expiry the turn runs without memory. Default 2000 ms. A turn with its own
|
|
188
|
+
* `timeoutMs` gives recall at most a quarter of it, and keeps the rest for itself.
|
|
189
|
+
*/
|
|
190
|
+
readonly recallTimeoutMs?: number;
|
|
191
|
+
/**
|
|
192
|
+
* UTF-8 bytes of the profile carried per turn (only read when the provider implements `profile`),
|
|
193
|
+
* as rendered: its `### Profile [source: <provider id>]` header, every indented line and the
|
|
194
|
+
* blank line after them. Default 2 KiB (`MEMORY_DEFAULT_MAX_PROFILE_BYTES`), at least 64, at most
|
|
195
|
+
* 8 KiB (`MEMORY_MAX_PROFILE_BYTES_CEILING`). It is a budget of its own: the profile never takes
|
|
196
|
+
* room from `maxBytes`. A profile that does not fit is left out whole, never truncated (a cut
|
|
197
|
+
* could keep half a rule). To carry no profile, use a provider without `profile`.
|
|
198
|
+
*/
|
|
199
|
+
readonly maxProfileBytes?: number;
|
|
200
|
+
/**
|
|
201
|
+
* Hand each completed turn to `provider.capture`, in the background, after the result is
|
|
202
|
+
* delivered. Default false: recall-only; true needs a provider with `capture` (a TypeError
|
|
203
|
+
* otherwise). `Session.close()` and `Agent.close()` wait for pending captures, each bounded by
|
|
204
|
+
* `MEMORY_CAPTURE_TIMEOUT_MS`; an exec fork's first-turn capture belongs to the child session.
|
|
205
|
+
*/
|
|
206
|
+
readonly capture?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Receives capture failures, which never fail the turn. Without it a failure is a process
|
|
209
|
+
* warning (code `OAR_MEMORY_CAPTURE_FAILED`), at most one a minute per Agent memory. Recall
|
|
210
|
+
* failures are on the turn itself.
|
|
211
|
+
*/
|
|
212
|
+
readonly onCaptureError?: (error: unknown) => void;
|
|
213
|
+
}
|
|
214
|
+
/** What a Runtime-wide default needs to pick a stable scope for each Agent it builds. */
|
|
215
|
+
interface MemoryScopeContext {
|
|
216
|
+
readonly model: ModelInfo;
|
|
217
|
+
/** The cwd the Agent was given, before readiness resolves it; undefined means process.cwd(). */
|
|
218
|
+
readonly cwd?: string;
|
|
219
|
+
}
|
|
220
|
+
/** Runtime-wide default: every Agent of the Runtime gets memory unless it sets `memory: false`. */
|
|
221
|
+
interface RuntimeMemoryDefault extends Omit<MemoryOption, 'scope'> {
|
|
222
|
+
readonly scope: (context: MemoryScopeContext) => AgentMemoryScope;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* What happened to the scope's profile on one turn; on the turn note only when the provider
|
|
226
|
+
* implements `profile`. `carried`: in the block, `bytes` as rendered (never more than
|
|
227
|
+
* `maxProfileBytes`). `absent`: the provider returned undefined. `omitted`: usable but over
|
|
228
|
+
* `maxProfileBytes`, left out whole. `failed`: it threw, timed out (it shares the recall deadline
|
|
229
|
+
* and signal) or returned something that is not a usable text: not a string, empty or only
|
|
230
|
+
* whitespace once tag characters are removed, or containing NUL. `omitted` and `failed` also add
|
|
231
|
+
* a `MEMORY_PROFILE_UNAVAILABLE` warning; neither changes what recall does or how it is recorded.
|
|
232
|
+
*/
|
|
233
|
+
type MemoryProfileNote = {
|
|
234
|
+
status: 'carried';
|
|
235
|
+
bytes: number;
|
|
236
|
+
} | {
|
|
237
|
+
status: 'absent';
|
|
238
|
+
} | {
|
|
239
|
+
status: 'omitted';
|
|
240
|
+
reason: string;
|
|
241
|
+
bytes?: number;
|
|
242
|
+
} | {
|
|
243
|
+
status: 'failed';
|
|
244
|
+
reason: string;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* What one turn did with memory; found in `Turn.providerMetadata.memory`, recorded before a
|
|
248
|
+
* required log capture sees the turn, so the logged and the returned turn are the same. The
|
|
249
|
+
* `profile` field is there only when the provider implements `profile`; when the profile is
|
|
250
|
+
* carried the block exists even if no item was recalled.
|
|
251
|
+
*/
|
|
252
|
+
type MemoryTurnNote = {
|
|
253
|
+
status: 'recalled';
|
|
254
|
+
provider: string;
|
|
255
|
+
/** The carried items; `bytes` is each one as rendered (header, title and indented text). */
|
|
256
|
+
items: ReadonlyArray<{
|
|
257
|
+
id: string;
|
|
258
|
+
source: string;
|
|
259
|
+
bytes: number;
|
|
260
|
+
}>;
|
|
261
|
+
/** Items the provider returned that were malformed, repeated, or did not fit the item or byte budget. */
|
|
262
|
+
omitted: number;
|
|
263
|
+
/** The items' rendered bytes together: never more than `maxBytes`. The profile is not counted here. */
|
|
264
|
+
bytes: number;
|
|
265
|
+
capture: boolean;
|
|
266
|
+
profile?: MemoryProfileNote;
|
|
267
|
+
}
|
|
268
|
+
/** The provider returned no items, or has no `recall`. */
|
|
269
|
+
| {
|
|
270
|
+
status: 'empty';
|
|
271
|
+
provider: string;
|
|
272
|
+
capture: boolean;
|
|
273
|
+
profile?: MemoryProfileNote;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The turn ran without recalled items: the recall threw, timed out or returned something that
|
|
277
|
+
* is not a list, or every returned item was malformed or over budget. Also a `MEMORY_UNAVAILABLE`
|
|
278
|
+
* warning. A carried profile still reaches the turn. A turn cancelled while recall ran does not
|
|
279
|
+
* run at all, so it has no note.
|
|
280
|
+
*/
|
|
281
|
+
| {
|
|
282
|
+
status: 'failed';
|
|
283
|
+
provider: string;
|
|
284
|
+
reason: string;
|
|
285
|
+
capture: boolean;
|
|
286
|
+
profile?: MemoryProfileNote;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
/** A constraint the owner pinned. It reaches the model on every turn, outside the conversation. */
|
|
290
|
+
interface PinnedConstraint {
|
|
291
|
+
/** Who it applies to, for example `host` or `system:grow`. */
|
|
292
|
+
scope: string;
|
|
293
|
+
id: string;
|
|
294
|
+
/** Starts at 1 and grows by one with every change, including a revocation. */
|
|
295
|
+
version: number;
|
|
296
|
+
text: string;
|
|
297
|
+
/** Who set this version, as named by the holder of the authority. */
|
|
298
|
+
setBy: string;
|
|
299
|
+
/** Epoch milliseconds. */
|
|
300
|
+
setAt: number;
|
|
301
|
+
}
|
|
302
|
+
/** Names one exact version of one constraint. */
|
|
303
|
+
interface ConstraintRef {
|
|
304
|
+
scope: string;
|
|
305
|
+
id: string;
|
|
306
|
+
version: number;
|
|
307
|
+
}
|
|
308
|
+
/** One entry of a constraint's append-only history. */
|
|
309
|
+
interface ConstraintVersion extends PinnedConstraint {
|
|
310
|
+
status: 'active' | 'revoked';
|
|
311
|
+
/** Present on a revocation. */
|
|
312
|
+
reason?: string;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* What a caller knows a constraint had reached. A store that shows less was rolled back:
|
|
316
|
+
* its newest rows were removed, or an older copy of the file was put in its place.
|
|
317
|
+
*/
|
|
318
|
+
interface ConstraintExpectation {
|
|
319
|
+
scope: string;
|
|
320
|
+
id: string;
|
|
321
|
+
/** The store must hold this version or a later one. */
|
|
322
|
+
minVersion: number;
|
|
323
|
+
/** The status the caller saw at exactly `minVersion`. A later version may have any status. */
|
|
324
|
+
status?: 'active' | 'revoked';
|
|
325
|
+
}
|
|
326
|
+
interface ConstraintWrite {
|
|
327
|
+
scope: string;
|
|
328
|
+
id: string;
|
|
329
|
+
text: string;
|
|
330
|
+
setBy: string;
|
|
331
|
+
/** The version the writer last saw; 0 when the constraint must not exist yet. */
|
|
332
|
+
expectedVersion: number;
|
|
333
|
+
}
|
|
334
|
+
interface ConstraintRevocation {
|
|
335
|
+
scope: string;
|
|
336
|
+
id: string;
|
|
337
|
+
setBy: string;
|
|
338
|
+
reason: string;
|
|
339
|
+
/** The version the writer last saw. */
|
|
340
|
+
expectedVersion: number;
|
|
341
|
+
}
|
|
342
|
+
/** Opens an existing store. Opening never creates anything. */
|
|
343
|
+
interface ConstraintStoreOptions {
|
|
344
|
+
/** Absolute path of the SQLite file. It must already be a store made by `ConstraintStore.create`. */
|
|
345
|
+
databasePath: string;
|
|
346
|
+
/** Public half of the owner's authority. Every row read is verified against it. */
|
|
347
|
+
publicKey: string;
|
|
348
|
+
/** The `id` of the store the caller expects at this path. A file with another id is refused. */
|
|
349
|
+
storeId?: string;
|
|
350
|
+
busyTimeoutMs?: number;
|
|
351
|
+
/** Clock used for `setAt`. */
|
|
352
|
+
now?: () => number;
|
|
353
|
+
}
|
|
354
|
+
interface ConstraintStoreCreateOptions {
|
|
355
|
+
/** Absolute path of the SQLite file to make. Nothing may exist there; missing directories are made. */
|
|
356
|
+
databasePath: string;
|
|
357
|
+
busyTimeoutMs?: number;
|
|
358
|
+
/** Clock used for `setAt`. */
|
|
359
|
+
now?: () => number;
|
|
360
|
+
}
|
|
361
|
+
/** Material for one task. None of it can change a constraint, whatever it says. */
|
|
362
|
+
interface TaskMaterial {
|
|
363
|
+
instructions: string;
|
|
364
|
+
/** Oldest first. The compiler keeps the most recent entries that fit. */
|
|
365
|
+
history?: readonly HistoryEntry[];
|
|
366
|
+
/** In priority order. A reference is carried whole or left out. */
|
|
367
|
+
references?: readonly ContextReference[];
|
|
368
|
+
}
|
|
369
|
+
interface HistoryEntry {
|
|
370
|
+
id: string;
|
|
371
|
+
role: 'user' | 'agent' | 'tool';
|
|
372
|
+
text: string;
|
|
373
|
+
}
|
|
374
|
+
interface ContextReference {
|
|
375
|
+
id: string;
|
|
376
|
+
title: string;
|
|
377
|
+
text: string;
|
|
378
|
+
}
|
|
379
|
+
interface ContextBudget {
|
|
380
|
+
/** UTF-8 bytes for the pinned channel plus the task prompt. */
|
|
381
|
+
maxBytes: number;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* The constraints of one call, ready for the provider's instruction channel.
|
|
385
|
+
* Only `compileContext` makes one, and only from verified rows of a `ConstraintStore`.
|
|
386
|
+
*/
|
|
387
|
+
interface PinnedChannel {
|
|
388
|
+
/** Empty when no constraint is active in the requested scopes. */
|
|
389
|
+
readonly text: string;
|
|
390
|
+
/** Every constraint version in `text`, with its provenance. */
|
|
391
|
+
readonly carried: readonly Omit<PinnedConstraint, 'text'>[];
|
|
392
|
+
/** SHA-256 of `text`. */
|
|
393
|
+
readonly digest: string;
|
|
394
|
+
}
|
|
395
|
+
interface CompiledContext {
|
|
396
|
+
/** Never trimmed and never part of `prompt`. */
|
|
397
|
+
readonly pinned: PinnedChannel;
|
|
398
|
+
/**
|
|
399
|
+
* The newest version of every constraint in the requested scopes, revoked ones included.
|
|
400
|
+
* Keep it where agents cannot write and pass it as `require` on the next call.
|
|
401
|
+
*/
|
|
402
|
+
readonly seen: readonly Required<ConstraintExpectation>[];
|
|
403
|
+
/** Task instructions, references and selected history. */
|
|
404
|
+
readonly prompt: string;
|
|
405
|
+
readonly included: {
|
|
406
|
+
readonly history: readonly string[];
|
|
407
|
+
readonly references: readonly string[];
|
|
408
|
+
};
|
|
409
|
+
readonly omitted: {
|
|
410
|
+
readonly history: readonly string[];
|
|
411
|
+
readonly references: readonly string[];
|
|
412
|
+
};
|
|
413
|
+
readonly bytes: {
|
|
414
|
+
readonly pinned: number;
|
|
415
|
+
readonly prompt: number;
|
|
416
|
+
readonly budget: number;
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
/** The writer does not hold the authority of this store. */
|
|
420
|
+
declare class ConstraintAuthorityError extends Error {
|
|
421
|
+
readonly name = "ConstraintAuthorityError";
|
|
422
|
+
}
|
|
423
|
+
/** The constraint changed since the writer last read it, or a file already exists where a store was to be made. */
|
|
424
|
+
declare class ConstraintConflictError extends Error {
|
|
425
|
+
readonly name = "ConstraintConflictError";
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* The store cannot be trusted for this call: a row does not verify against the owner's public
|
|
429
|
+
* key, the file is missing or is another store, or it holds less than the caller had seen.
|
|
430
|
+
* Do not run the turn.
|
|
431
|
+
*/
|
|
432
|
+
declare class ConstraintIntegrityError extends Error {
|
|
433
|
+
readonly name = "ConstraintIntegrityError";
|
|
434
|
+
}
|
|
435
|
+
/** The pinned constraints and the task instructions do not fit; neither is ever trimmed. */
|
|
436
|
+
declare class ContextBudgetError extends Error {
|
|
437
|
+
readonly name = "ContextBudgetError";
|
|
438
|
+
}
|
|
439
|
+
/** The provider has no verified channel for pinned constraints in this kind of turn. */
|
|
440
|
+
declare class UnverifiedPinnedChannelError extends Error {
|
|
441
|
+
readonly name = "UnverifiedPinnedChannelError";
|
|
442
|
+
}
|
|
443
|
+
/** No constraint was active for the turn and the caller did not say that is expected. */
|
|
444
|
+
declare class NothingPinnedError extends Error {
|
|
445
|
+
readonly name = "NothingPinnedError";
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* The owner's right to write constraints. Only an object returned by `create` or
|
|
450
|
+
* `fromPrivateKey` can write; text, JSON and look-alike objects cannot become one.
|
|
451
|
+
* Keep it on the host side and never hand it to code that runs agent output.
|
|
452
|
+
*/
|
|
453
|
+
declare class ConstraintAuthority {
|
|
454
|
+
/** Safe to share: readers verify every stored constraint against it. */
|
|
455
|
+
readonly publicKey: string;
|
|
456
|
+
private constructor();
|
|
457
|
+
/** A new authority with a fresh Ed25519 key. */
|
|
458
|
+
static create(): ConstraintAuthority;
|
|
459
|
+
/** Restores the authority from the PEM the owner kept from `exportPrivateKey`. */
|
|
460
|
+
static fromPrivateKey(pem: string): ConstraintAuthority;
|
|
461
|
+
/** The secret, for the owner's own protected storage. Whoever holds it can write constraints. */
|
|
462
|
+
exportPrivateKey(): string;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Durable, append-only constraints for one owner.
|
|
467
|
+
*
|
|
468
|
+
* The owner makes the file once with `ConstraintStore.create`, which needs the
|
|
469
|
+
* `ConstraintAuthority`. `new ConstraintStore` only opens a file that is already a store of
|
|
470
|
+
* that owner: a missing, empty or foreign file throws `ConstraintIntegrityError`, and nothing
|
|
471
|
+
* is created. Never fall back to `create` when opening fails; that would replace the owner's
|
|
472
|
+
* constraints with an empty set.
|
|
473
|
+
*
|
|
474
|
+
* Reading needs only the owner's public key. Writing needs the authority object: there is no
|
|
475
|
+
* method that turns text into a constraint without it. Every version is signed together with
|
|
476
|
+
* the id of its store, and every read verifies the signature, so a row rewritten, inserted or
|
|
477
|
+
* copied from another store by any other path makes the read throw `ConstraintIntegrityError`.
|
|
478
|
+
*
|
|
479
|
+
* Not covered by the store alone: removing the newest versions of a constraint, removing a
|
|
480
|
+
* constraint whole, or putting back an older copy of the file. What is left is a valid signed
|
|
481
|
+
* history. A caller detects that by stating what it last saw (`require` in `compileContext`).
|
|
482
|
+
*/
|
|
483
|
+
declare class ConstraintStore {
|
|
484
|
+
#private;
|
|
485
|
+
/** Opens an existing store. It never creates the file, its directory or the schema. */
|
|
486
|
+
constructor(options: ConstraintStoreOptions);
|
|
487
|
+
/**
|
|
488
|
+
* Makes a new, empty store for the holder of `authority` and opens it. Refuses a path where
|
|
489
|
+
* any file already exists, so it can never stand in for a store that was lost.
|
|
490
|
+
*/
|
|
491
|
+
static create(authority: ConstraintAuthority, options: ConstraintStoreCreateOptions): ConstraintStore;
|
|
492
|
+
/**
|
|
493
|
+
* Identifies this file among the stores of one owner. Keep it next to the public key and pass
|
|
494
|
+
* it as `storeId` when opening, so another store's file cannot be put in its place.
|
|
495
|
+
*/
|
|
496
|
+
get id(): string;
|
|
497
|
+
/** True only for a real store: not a subclass stand-in, a look-alike object or a proxy. */
|
|
498
|
+
static is(value: unknown): value is ConstraintStore;
|
|
499
|
+
/** Sets a constraint or replaces its text. The new version is `expectedVersion + 1`. */
|
|
500
|
+
pin(authority: ConstraintAuthority, write: ConstraintWrite): PinnedConstraint;
|
|
501
|
+
/** Ends a constraint. The revocation is a signed version like any other. */
|
|
502
|
+
revoke(authority: ConstraintAuthority, revocation: ConstraintRevocation): ConstraintRef;
|
|
503
|
+
/** Verified active constraints, in the order of `scopes`, then by id. */
|
|
504
|
+
active(scopes: readonly string[]): readonly PinnedConstraint[];
|
|
505
|
+
/**
|
|
506
|
+
* The verified newest version of every constraint in `scopes`, revoked ones included, in the
|
|
507
|
+
* order of `scopes`, then by id. This is what a caller remembers to detect a rollback later.
|
|
508
|
+
*/
|
|
509
|
+
latest(scopes: readonly string[]): readonly ConstraintVersion[];
|
|
510
|
+
/** Every version of one constraint, oldest first, each verified. */
|
|
511
|
+
history(scope: string, id: string): readonly ConstraintVersion[];
|
|
512
|
+
/** Safe to call more than once. */
|
|
513
|
+
close(): void;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Opt-in: the owner's pinned constraints reach every turn of this Agent, outside the
|
|
518
|
+
* conversation. Each turn reads the store, verifies it and delivers the current versions on the
|
|
519
|
+
* provider's verified channel (Claude exec: `--append-system-prompt`; Codex: a new `exec`
|
|
520
|
+
* only). Where there is no verified channel the turn is refused with
|
|
521
|
+
* `PinnedGuaranteeUnavailableError` before the CLI runs, unless `allowUnpinned` is set.
|
|
522
|
+
*
|
|
523
|
+
* With this option and no explicit transport the Agent uses `exec`, the only transport whose
|
|
524
|
+
* delivery was examined. Nothing an agent writes can reach this option or its store.
|
|
525
|
+
*/
|
|
526
|
+
interface PinnedOption {
|
|
527
|
+
/** A reader: open it with `openSystemConstraintStore`. It is never written through here. */
|
|
528
|
+
constraints: ConstraintStore;
|
|
529
|
+
/** Which scopes apply to this Agent, for example `['host', 'system:grow']`. */
|
|
530
|
+
scopes: readonly string[];
|
|
531
|
+
/**
|
|
532
|
+
* Versions the host knows the store must hold (its manifest). Later turns also require
|
|
533
|
+
* whatever earlier turns of this Agent saw, so a store that loses versions stops the turn.
|
|
534
|
+
*/
|
|
535
|
+
require?: readonly ConstraintExpectation[];
|
|
536
|
+
/** The system really has no constraint yet; running with an empty store is not an error. */
|
|
537
|
+
allowEmpty?: boolean;
|
|
538
|
+
/**
|
|
539
|
+
* Run turns that have no verified channel (Codex resume, control transport, other
|
|
540
|
+
* providers) without the guarantee. Each such turn says so in `warnings` and in
|
|
541
|
+
* `providerMetadata.pinned`.
|
|
542
|
+
*/
|
|
543
|
+
allowUnpinned?: boolean;
|
|
544
|
+
}
|
|
545
|
+
/** What one turn did with the pinned option; found in `Turn.providerMetadata.pinned`. */
|
|
546
|
+
type PinnedTurnNote = {
|
|
547
|
+
status: 'pinned';
|
|
548
|
+
provider: ProviderId;
|
|
549
|
+
channel: 'claude-append-system-prompt' | 'codex-developer-instructions';
|
|
550
|
+
digest: string;
|
|
551
|
+
carried: ReadonlyArray<{
|
|
552
|
+
scope: string;
|
|
553
|
+
id: string;
|
|
554
|
+
version: number;
|
|
555
|
+
}>;
|
|
556
|
+
} | {
|
|
557
|
+
status: 'nothing-pinned';
|
|
558
|
+
provider: ProviderId;
|
|
559
|
+
} | {
|
|
560
|
+
status: 'unpinned';
|
|
561
|
+
provider: ProviderId;
|
|
562
|
+
reason: string;
|
|
563
|
+
digest: string;
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
type BuiltinProviderId = 'claude' | 'codex';
|
|
567
|
+
type ProviderId = BuiltinProviderId | (string & {});
|
|
568
|
+
type TransportKind = 'exec' | 'control';
|
|
569
|
+
type TransportPreference = 'auto' | TransportKind;
|
|
570
|
+
type SessionPersistence = 'provider' | 'process';
|
|
571
|
+
type SessionState = 'opening' | 'idle' | 'running' | 'interrupted' | 'unknown' | 'failed' | 'closing' | 'closed';
|
|
572
|
+
interface ContextPolicy {
|
|
573
|
+
profile?: 'native' | 'project' | 'clean';
|
|
574
|
+
memory?: 'inherit' | 'off' | 'read-only';
|
|
575
|
+
}
|
|
576
|
+
interface PermissionIntent {
|
|
577
|
+
/** respond: Claude exec only, clean context, explicit non-coding prompt and no filesystem tools. */
|
|
578
|
+
mode: 'analyze' | 'respond' | 'edit' | 'unrestricted';
|
|
579
|
+
network?: 'deny' | 'allow';
|
|
580
|
+
additionalDirectories?: string[];
|
|
581
|
+
minimumEnforcement?: 'harness' | 'sandbox' | 'external';
|
|
582
|
+
strict?: boolean;
|
|
583
|
+
}
|
|
584
|
+
interface EnvironmentPolicy {
|
|
585
|
+
mode: 'inherit' | 'minimal' | 'explicit';
|
|
586
|
+
variables?: Record<string, string>;
|
|
587
|
+
passthrough?: string[];
|
|
588
|
+
}
|
|
589
|
+
type CapabilityRequirement = boolean | 'required' | 'preferred';
|
|
590
|
+
interface CapabilityRequirements {
|
|
591
|
+
interactiveApprovals?: CapabilityRequirement;
|
|
592
|
+
userInputDuringTurn?: CapabilityRequirement;
|
|
593
|
+
steering?: CapabilityRequirement;
|
|
594
|
+
inProcessTools?: CapabilityRequirement;
|
|
595
|
+
processPersistence?: CapabilityRequirement;
|
|
596
|
+
messageDeltas?: CapabilityRequirement;
|
|
597
|
+
/** @deprecated Use messageDeltas; provider chunks are not token boundaries. */
|
|
598
|
+
tokenDeltas?: CapabilityRequirement;
|
|
599
|
+
dynamicPermissions?: CapabilityRequirement;
|
|
600
|
+
sessionInspection?: CapabilityRequirement;
|
|
601
|
+
checkpointOrRollback?: CapabilityRequirement;
|
|
602
|
+
subagentLifecycle?: CapabilityRequirement;
|
|
603
|
+
subagentMessages?: CapabilityRequirement;
|
|
604
|
+
subagentDeltas?: CapabilityRequirement;
|
|
605
|
+
refusalDetection?: CapabilityRequirement;
|
|
606
|
+
/** Fork nativo confirmando el hijo con un primer turn; ambos exec CLIs lo soportan. */
|
|
607
|
+
forkWithPrompt?: CapabilityRequirement;
|
|
608
|
+
/** Fork sin prompt: sólo control transports; ningún exec CLI lo soporta. */
|
|
609
|
+
forkWithoutPrompt?: CapabilityRequirement;
|
|
610
|
+
images?: CapabilityRequirement;
|
|
611
|
+
files?: CapabilityRequirement;
|
|
612
|
+
}
|
|
613
|
+
type CapabilitySupport = 'supported' | 'partial' | 'unsupported' | 'unverified';
|
|
614
|
+
type SupportLevel = 'full' | 'partial' | 'none' | 'unknown';
|
|
615
|
+
type CapabilityEvidenceSource = 'live-handshake' | 'generated-schema' | 'sdk-capability' | 'compatibility-manifest';
|
|
616
|
+
interface CapabilityStatus {
|
|
617
|
+
support: SupportLevel;
|
|
618
|
+
detail?: string;
|
|
619
|
+
evidence: Array<{
|
|
620
|
+
source: CapabilityEvidenceSource;
|
|
621
|
+
fingerprint: string;
|
|
622
|
+
}>;
|
|
623
|
+
}
|
|
624
|
+
type PermissionModeCeiling = 'plan' | 'default' | 'acceptEdits' | 'bypassPermissions';
|
|
625
|
+
interface SafetyEnvelope {
|
|
626
|
+
authorityEpoch: string;
|
|
627
|
+
filesystem: {
|
|
628
|
+
readonlyRoots: string[];
|
|
629
|
+
writableRoots: string[];
|
|
630
|
+
};
|
|
631
|
+
network: Array<{
|
|
632
|
+
protocol: 'http' | 'https' | 'tcp';
|
|
633
|
+
host: string;
|
|
634
|
+
ports?: number[];
|
|
635
|
+
}>;
|
|
636
|
+
tools: string[];
|
|
637
|
+
executables: string[];
|
|
638
|
+
mcpServers: string[];
|
|
639
|
+
environmentVariables: string[];
|
|
640
|
+
settingsPersistence: 'none' | 'session' | 'durable';
|
|
641
|
+
enforcedBy: Array<'harness' | 'sandbox' | 'external'>;
|
|
642
|
+
/** Highest permission mode a session may adopt; absent means unrestricted. */
|
|
643
|
+
permissionModeCeiling?: PermissionModeCeiling;
|
|
644
|
+
/** Models a session may switch to; absent means unrestricted, empty denies all. */
|
|
645
|
+
modelAllowlist?: string[];
|
|
646
|
+
}
|
|
647
|
+
interface NegotiatedPlan {
|
|
648
|
+
provider: ProviderId;
|
|
649
|
+
transport: TransportKind;
|
|
650
|
+
fingerprint: {
|
|
651
|
+
adapterVersion: string;
|
|
652
|
+
cliVersion: string;
|
|
653
|
+
executableRealpath: string;
|
|
654
|
+
executableDigest?: string;
|
|
655
|
+
launchIdentityDigest?: string;
|
|
656
|
+
protocolVersion?: string;
|
|
657
|
+
sdkVersion?: string;
|
|
658
|
+
};
|
|
659
|
+
capabilities: Record<string, CapabilityStatus>;
|
|
660
|
+
envelope: SafetyEnvelope;
|
|
661
|
+
warnings: RuntimeWarning[];
|
|
662
|
+
}
|
|
663
|
+
interface CapabilityReport {
|
|
664
|
+
provider: ProviderId;
|
|
665
|
+
transport: TransportKind;
|
|
666
|
+
features: Record<string, CapabilitySupport>;
|
|
667
|
+
unsupported: string[];
|
|
668
|
+
warnings: RuntimeWarning[];
|
|
669
|
+
contextSources: ContextSourceReport;
|
|
670
|
+
enforcement?: EnforcementReport;
|
|
671
|
+
}
|
|
672
|
+
interface ContextSourceReport {
|
|
673
|
+
profile: 'native' | 'project' | 'clean';
|
|
674
|
+
memory: 'inherit' | 'off' | 'read-only';
|
|
675
|
+
active: string[];
|
|
676
|
+
inactive: string[];
|
|
677
|
+
unavoidable: string[];
|
|
678
|
+
unknown: string[];
|
|
679
|
+
}
|
|
680
|
+
interface EnforcementReport {
|
|
681
|
+
requested: PermissionIntent;
|
|
682
|
+
effective: {
|
|
683
|
+
filesystem: string;
|
|
684
|
+
network: string;
|
|
685
|
+
approvals: string;
|
|
686
|
+
enforcedBy: Array<'harness' | 'sandbox' | 'external'>;
|
|
687
|
+
};
|
|
688
|
+
unsupported: string[];
|
|
689
|
+
warnings: string[];
|
|
690
|
+
}
|
|
691
|
+
interface ProviderOptions {
|
|
692
|
+
external?: Record<string, Record<string, unknown>>;
|
|
693
|
+
claude?: {
|
|
694
|
+
/** Replace the CLI coding persona for non-coding workflows; append preserves it. */
|
|
695
|
+
systemPromptMode?: 'append' | 'replace';
|
|
696
|
+
settings?: string | Record<string, unknown>;
|
|
697
|
+
mcpConfigs?: string[];
|
|
698
|
+
/** Exec transport only: built-in tool names. [] emits --tools ""; MCP is governed separately. */
|
|
699
|
+
tools?: string[];
|
|
700
|
+
/** Exec transport only: restrict MCP to mcpConfigs; an empty server map disables MCP. */
|
|
701
|
+
strictMcpConfig?: boolean;
|
|
702
|
+
};
|
|
703
|
+
codex?: {
|
|
704
|
+
config?: Record<string, unknown>;
|
|
705
|
+
skipGitRepoCheck?: boolean;
|
|
706
|
+
/** Exec transport only: `--ignore-user-config`, the owner's `$CODEX_HOME/config.toml` is not loaded (auth still is). */
|
|
707
|
+
ignoreUserConfig?: boolean;
|
|
708
|
+
/** Exec transport only: `--ignore-rules`, no execpolicy `.rules` file is loaded. */
|
|
709
|
+
ignoreRules?: boolean;
|
|
710
|
+
/** Exec transport only: `--ephemeral`, no session files are written, so the session cannot be resumed. */
|
|
711
|
+
ephemeral?: boolean;
|
|
712
|
+
};
|
|
713
|
+
/** Opt-in gate for control transports; never implied by experimentalApi. */
|
|
714
|
+
experimentalControl?: boolean;
|
|
715
|
+
/** Opt-in gate for dynamic tools; never implied by experimentalControl. */
|
|
716
|
+
experimentalApi?: boolean;
|
|
717
|
+
}
|
|
718
|
+
interface AgentOptions {
|
|
719
|
+
/** Host callbacks require explicit control transport gates. */
|
|
720
|
+
tools?: readonly ApplicationTool[];
|
|
721
|
+
model: string;
|
|
722
|
+
cwd?: string;
|
|
723
|
+
instructions?: string;
|
|
724
|
+
effort?: string;
|
|
725
|
+
transport?: TransportPreference;
|
|
726
|
+
context?: ContextPolicy;
|
|
727
|
+
permissions?: PermissionIntent;
|
|
728
|
+
environment?: EnvironmentPolicy;
|
|
729
|
+
capabilities?: CapabilityRequirements;
|
|
730
|
+
providerOptions?: ProviderOptions;
|
|
731
|
+
requireAuth?: 'any' | 'subscription';
|
|
732
|
+
/** Opt-in pinned constraints on every turn. See `PinnedOption`. */
|
|
733
|
+
pinned?: PinnedOption;
|
|
734
|
+
/**
|
|
735
|
+
* Opt-in per-agent memory: recalled items reach each turn as reference data, never as
|
|
736
|
+
* instructions. Absent, the Runtime's default applies; `false` opts out of it. See `MemoryOption`.
|
|
737
|
+
*/
|
|
738
|
+
memory?: MemoryOption | false;
|
|
739
|
+
}
|
|
740
|
+
interface SessionOptions {
|
|
741
|
+
persistence?: SessionPersistence;
|
|
742
|
+
resume?: SessionRef;
|
|
743
|
+
name?: string;
|
|
744
|
+
}
|
|
745
|
+
interface SessionRef {
|
|
746
|
+
schemaVersion: 1;
|
|
747
|
+
provider: ProviderId;
|
|
748
|
+
id: string;
|
|
749
|
+
model?: string;
|
|
750
|
+
cwd: string;
|
|
751
|
+
transport: TransportKind;
|
|
752
|
+
persistence: SessionPersistence;
|
|
753
|
+
/** @deprecated Legacy refs may omit the transport epoch. */
|
|
754
|
+
transportEpoch?: string;
|
|
755
|
+
cliVersion?: string;
|
|
756
|
+
createdAt: string;
|
|
757
|
+
}
|
|
758
|
+
interface SessionIdentity extends SessionRef {
|
|
759
|
+
transportEpoch: string;
|
|
760
|
+
sessionId?: string;
|
|
761
|
+
forkedFromId?: string;
|
|
762
|
+
parentSessionId?: string;
|
|
763
|
+
}
|
|
764
|
+
interface PersistedSessionRef extends SessionIdentity {
|
|
765
|
+
persistence: 'provider';
|
|
766
|
+
}
|
|
767
|
+
type AgentInput = string | Array<{
|
|
768
|
+
type: 'text';
|
|
769
|
+
text: string;
|
|
770
|
+
} | {
|
|
771
|
+
type: 'image';
|
|
772
|
+
path: string;
|
|
773
|
+
} | {
|
|
774
|
+
type: 'file';
|
|
775
|
+
path: string;
|
|
776
|
+
}>;
|
|
777
|
+
interface InteractionBinding {
|
|
778
|
+
interactionId: string;
|
|
779
|
+
provider: ProviderId;
|
|
780
|
+
transportEpoch: string;
|
|
781
|
+
providerRequestId?: string | number;
|
|
782
|
+
method: string;
|
|
783
|
+
sessionId: string;
|
|
784
|
+
turnId?: string;
|
|
785
|
+
itemId?: string;
|
|
786
|
+
payloadDigest: string;
|
|
787
|
+
expiresAt?: string;
|
|
788
|
+
}
|
|
789
|
+
interface InteractionBase {
|
|
790
|
+
binding: InteractionBinding;
|
|
791
|
+
availableDecisions: readonly string[];
|
|
792
|
+
signal: AbortSignal;
|
|
793
|
+
}
|
|
794
|
+
interface UserQuestion {
|
|
795
|
+
id: string;
|
|
796
|
+
header?: string;
|
|
797
|
+
question: string;
|
|
798
|
+
secret?: boolean;
|
|
799
|
+
allowOther?: boolean;
|
|
800
|
+
multiple?: boolean;
|
|
801
|
+
options?: Array<{
|
|
802
|
+
id: string;
|
|
803
|
+
label: string;
|
|
804
|
+
description?: string;
|
|
805
|
+
}>;
|
|
806
|
+
}
|
|
807
|
+
type InteractionRequest = (InteractionBase & {
|
|
808
|
+
kind: 'command-approval';
|
|
809
|
+
command?: unknown;
|
|
810
|
+
cwd?: unknown;
|
|
811
|
+
}) | (InteractionBase & {
|
|
812
|
+
kind: 'file-change-approval';
|
|
813
|
+
paths?: unknown;
|
|
814
|
+
}) | (InteractionBase & {
|
|
815
|
+
kind: 'network-approval';
|
|
816
|
+
destination?: unknown;
|
|
817
|
+
}) | (InteractionBase & {
|
|
818
|
+
kind: 'tool-approval';
|
|
819
|
+
toolName: string;
|
|
820
|
+
input?: unknown;
|
|
821
|
+
}) | (InteractionBase & {
|
|
822
|
+
kind: 'permission';
|
|
823
|
+
requested: unknown;
|
|
824
|
+
}) | (InteractionBase & {
|
|
825
|
+
kind: 'user-input';
|
|
826
|
+
questions: UserQuestion[];
|
|
827
|
+
}) | (InteractionBase & {
|
|
828
|
+
kind: 'elicitation';
|
|
829
|
+
serverName: string;
|
|
830
|
+
schema?: object;
|
|
831
|
+
}) | (InteractionBase & {
|
|
832
|
+
kind: 'dynamic-tool';
|
|
833
|
+
toolName: string;
|
|
834
|
+
arguments: unknown;
|
|
835
|
+
});
|
|
836
|
+
type InteractionResponse = {
|
|
837
|
+
kind: 'approval';
|
|
838
|
+
decision: string;
|
|
839
|
+
reason?: string;
|
|
840
|
+
} | {
|
|
841
|
+
kind: 'user-input';
|
|
842
|
+
answers: Record<string, string[]>;
|
|
843
|
+
} | {
|
|
844
|
+
kind: 'permission';
|
|
845
|
+
decision: string;
|
|
846
|
+
granted?: unknown;
|
|
847
|
+
} | {
|
|
848
|
+
kind: 'elicitation';
|
|
849
|
+
action: 'accept' | 'decline' | 'cancel';
|
|
850
|
+
content?: unknown;
|
|
851
|
+
} | {
|
|
852
|
+
kind: 'dynamic-tool';
|
|
853
|
+
success: boolean;
|
|
854
|
+
content?: unknown;
|
|
855
|
+
error?: string;
|
|
856
|
+
};
|
|
857
|
+
interface TurnOptions {
|
|
858
|
+
signal?: AbortSignal;
|
|
859
|
+
signalBehavior?: 'interrupt' | 'detach';
|
|
860
|
+
/** Exec only: retain the operation until actual adapter work and cleanup settle after abort.
|
|
861
|
+
* Defaults to false (bounded cleanup). Noncooperative work can keep it pending indefinitely.
|
|
862
|
+
* Control turns reject true before dispatch. */
|
|
863
|
+
awaitSettlement?: boolean;
|
|
864
|
+
/**
|
|
865
|
+
* Turn deadline in milliseconds: an integer in 1..2^31-1 (Node timers clamp
|
|
866
|
+
* anything else to 1 ms). Defaults to 600 000. Out of range throws a
|
|
867
|
+
* RangeError before the turn starts, on the exec and control paths alike.
|
|
868
|
+
*/
|
|
869
|
+
timeoutMs?: number;
|
|
870
|
+
outputSchema?: Record<string, unknown>;
|
|
871
|
+
onInteraction?: (request: InteractionRequest) => Promise<InteractionResponse>;
|
|
872
|
+
}
|
|
873
|
+
interface TurnToken {
|
|
874
|
+
readonly value: string;
|
|
875
|
+
}
|
|
876
|
+
interface InterruptReceipt {
|
|
877
|
+
requested: boolean;
|
|
878
|
+
terminal: 'interrupted' | 'completed' | 'failed' | 'unknown';
|
|
879
|
+
}
|
|
880
|
+
interface SteerReceipt {
|
|
881
|
+
accepted: boolean;
|
|
882
|
+
turnId?: string;
|
|
883
|
+
}
|
|
884
|
+
interface TurnHandle {
|
|
885
|
+
readonly token: TurnToken;
|
|
886
|
+
readonly turnId: Promise<string | undefined>;
|
|
887
|
+
/** Live single-consumer events; a lag beyond 4096 events/64 MiB fails this observer with OUTPUT_LIMIT without cancelling result. */
|
|
888
|
+
readonly events: AsyncIterable<AgentEvent>;
|
|
889
|
+
readonly result: Promise<Turn>;
|
|
890
|
+
interrupt(reason?: string): Promise<InterruptReceipt>;
|
|
891
|
+
detach(): void;
|
|
892
|
+
respond(interactionId: string, response: InteractionResponse): Promise<void>;
|
|
893
|
+
/**
|
|
894
|
+
* Present only when the negotiated capabilities include steering. Its
|
|
895
|
+
* absence is the capability answer: no probing, no throwing stub.
|
|
896
|
+
*/
|
|
897
|
+
steer?(input: AgentInput): Promise<SteerReceipt>;
|
|
898
|
+
}
|
|
899
|
+
interface OneShotOptions extends TurnOptions {
|
|
900
|
+
context?: ContextPolicy;
|
|
901
|
+
}
|
|
902
|
+
interface ForkOptions extends TurnOptions {
|
|
903
|
+
model?: string;
|
|
904
|
+
name?: string;
|
|
905
|
+
}
|
|
906
|
+
interface RuntimeWarning {
|
|
907
|
+
code: string;
|
|
908
|
+
message: string;
|
|
909
|
+
providerMetadata?: unknown;
|
|
910
|
+
}
|
|
911
|
+
interface ModelUsage {
|
|
912
|
+
inputTokens?: number;
|
|
913
|
+
outputTokens?: number;
|
|
914
|
+
cachedInputTokens?: number;
|
|
915
|
+
cacheCreationTokens?: number;
|
|
916
|
+
reportedCostUsd?: number;
|
|
917
|
+
}
|
|
918
|
+
interface Usage {
|
|
919
|
+
inputTokens?: number;
|
|
920
|
+
outputTokens?: number;
|
|
921
|
+
cachedInputTokens?: number;
|
|
922
|
+
cacheCreationTokens?: number;
|
|
923
|
+
perModel?: Record<string, ModelUsage>;
|
|
924
|
+
reportedCostUsd?: number;
|
|
925
|
+
costMeaning: 'provider-reported' | 'api-equivalent' | 'estimate' | 'unavailable';
|
|
926
|
+
}
|
|
927
|
+
interface Turn {
|
|
928
|
+
id?: string;
|
|
929
|
+
session: SessionIdentity;
|
|
930
|
+
/**
|
|
931
|
+
* 'refused' comes only from a native provider refusal signal, never inferred from text. No built-in
|
|
932
|
+
* transport nor the Gemini/Antigravity adapters has an evidenced signal today, so none returns it;
|
|
933
|
+
* their `refusalDetection` capability says 'unsupported' or 'none'.
|
|
934
|
+
*/
|
|
935
|
+
status: 'completed' | 'failed' | 'interrupted' | 'refused';
|
|
936
|
+
text: string;
|
|
937
|
+
output?: unknown;
|
|
938
|
+
usage?: Usage;
|
|
939
|
+
events: AgentEvent[];
|
|
940
|
+
warnings: RuntimeWarning[];
|
|
941
|
+
providerMetadata: unknown;
|
|
942
|
+
}
|
|
943
|
+
type AgentEvent = {
|
|
944
|
+
type: 'session.started';
|
|
945
|
+
session: SessionRef;
|
|
946
|
+
} | {
|
|
947
|
+
type: 'turn.started';
|
|
948
|
+
turnId?: string;
|
|
949
|
+
} | {
|
|
950
|
+
type: 'message.delta';
|
|
951
|
+
text: string;
|
|
952
|
+
} | {
|
|
953
|
+
type: 'message.completed';
|
|
954
|
+
text: string;
|
|
955
|
+
} | {
|
|
956
|
+
type: 'tool.started';
|
|
957
|
+
id: string;
|
|
958
|
+
name: string;
|
|
959
|
+
input?: unknown;
|
|
960
|
+
} | {
|
|
961
|
+
type: 'tool.updated';
|
|
962
|
+
id: string;
|
|
963
|
+
update: unknown;
|
|
964
|
+
} | {
|
|
965
|
+
type: 'tool.completed';
|
|
966
|
+
id: string;
|
|
967
|
+
output?: unknown;
|
|
968
|
+
error?: unknown;
|
|
969
|
+
} | {
|
|
970
|
+
type: 'interaction.requested';
|
|
971
|
+
request: InteractionRequest;
|
|
972
|
+
} | {
|
|
973
|
+
type: 'subagent.started';
|
|
974
|
+
id: string;
|
|
975
|
+
metadata?: unknown;
|
|
976
|
+
} | {
|
|
977
|
+
type: 'subagent.completed';
|
|
978
|
+
id: string;
|
|
979
|
+
metadata?: unknown;
|
|
980
|
+
} | {
|
|
981
|
+
type: 'context.compacted';
|
|
982
|
+
metadata?: unknown;
|
|
983
|
+
} | {
|
|
984
|
+
type: 'turn.completed';
|
|
985
|
+
turn: Turn;
|
|
986
|
+
} | {
|
|
987
|
+
type: 'provider.event';
|
|
988
|
+
provider: ProviderId;
|
|
989
|
+
event: unknown;
|
|
990
|
+
};
|
|
991
|
+
interface AuthStatus {
|
|
992
|
+
authenticated: boolean;
|
|
993
|
+
source: 'subscription' | 'api-key' | 'cloud-provider' | 'oauth' | 'oss' | 'unknown';
|
|
994
|
+
state?: 'authenticated' | 'not-authenticated' | 'unknown';
|
|
995
|
+
evidence?: 'provider-status' | 'local-configuration' | 'turn-result';
|
|
996
|
+
account?: {
|
|
997
|
+
plan?: string;
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
interface ProviderInstallation {
|
|
1001
|
+
launchTarget?: LaunchTarget;
|
|
1002
|
+
identityFiles?: string[];
|
|
1003
|
+
installed: boolean;
|
|
1004
|
+
path?: string;
|
|
1005
|
+
realpath?: string;
|
|
1006
|
+
version?: string;
|
|
1007
|
+
}
|
|
1008
|
+
interface ModelInfo {
|
|
1009
|
+
id: string;
|
|
1010
|
+
provider: ProviderId;
|
|
1011
|
+
aliases: string[];
|
|
1012
|
+
source: 'agent-sdk' | 'app-server' | 'compatibility-catalog' | 'explicit';
|
|
1013
|
+
availability: 'available' | 'unavailable' | 'unverified';
|
|
1014
|
+
displayName?: string;
|
|
1015
|
+
contextWindow?: number;
|
|
1016
|
+
maxOutputTokens?: number;
|
|
1017
|
+
supportedEffort?: string[];
|
|
1018
|
+
}
|
|
1019
|
+
interface ModelCatalog {
|
|
1020
|
+
provider: ProviderId;
|
|
1021
|
+
source: ModelInfo['source'];
|
|
1022
|
+
models: ModelInfo[];
|
|
1023
|
+
fetchedAt: string;
|
|
1024
|
+
}
|
|
1025
|
+
interface AgentReadinessOptions {
|
|
1026
|
+
signal?: AbortSignal;
|
|
1027
|
+
/** Fresh preparation budget in milliseconds; defaults to 600000. */
|
|
1028
|
+
timeoutMs?: number;
|
|
1029
|
+
/** Wait for actual pending probe settlement after cancellation or timeout. */
|
|
1030
|
+
awaitSettlement?: boolean;
|
|
1031
|
+
}
|
|
1032
|
+
interface AgentReadiness {
|
|
1033
|
+
ready: boolean;
|
|
1034
|
+
provider: ProviderId;
|
|
1035
|
+
model: ModelInfo;
|
|
1036
|
+
installation: ProviderInstallation;
|
|
1037
|
+
auth: AuthStatus;
|
|
1038
|
+
capabilities: CapabilityReport;
|
|
1039
|
+
plan: NegotiatedPlan;
|
|
1040
|
+
}
|
|
1041
|
+
interface ProviderDoctorReport {
|
|
1042
|
+
provider: ProviderId;
|
|
1043
|
+
installation: ProviderInstallation;
|
|
1044
|
+
auth: AuthStatus;
|
|
1045
|
+
transports: Array<{
|
|
1046
|
+
kind: TransportKind;
|
|
1047
|
+
available: boolean;
|
|
1048
|
+
detail?: string;
|
|
1049
|
+
}>;
|
|
1050
|
+
models: ModelCatalog;
|
|
1051
|
+
memory: 'active' | 'inactive' | 'unknown';
|
|
1052
|
+
instructionSources: string[];
|
|
1053
|
+
warnings: RuntimeWarning[];
|
|
1054
|
+
fingerprint?: NegotiatedPlan['fingerprint'];
|
|
1055
|
+
capabilityEvidence?: Record<string, {
|
|
1056
|
+
support: SupportLevel;
|
|
1057
|
+
sources: CapabilityEvidenceSource[];
|
|
1058
|
+
}>;
|
|
1059
|
+
}
|
|
1060
|
+
interface DoctorReport {
|
|
1061
|
+
generatedAt: string;
|
|
1062
|
+
providers: ProviderDoctorReport[];
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
export { type EnvironmentPolicy as $, type AgentEvent as A, type AgentReadiness as B, type CapabilitySupport as C, type CapabilityReport as D, type SessionOptions as E, type ForkOptions as F, type ContextSourceReport as G, type ContextPolicy as H, type EnforcementReport as I, type PermissionIntent as J, type SafetyEnvelope as K, type LaunchTarget as L, type ModelInfo as M, type InteractionRequest as N, type OneShotOptions as O, type ProviderId as P, type InteractionResponse as Q, type RecalledMemory as R, type SessionRef as S, type TurnOptions as T, type Usage as U, type InterruptReceipt as V, type SteerReceipt as W, type SupportLevel as X, type CapabilityEvidenceSource as Y, type BuiltinProviderId as Z, type RuntimeMemoryDefault as _, type Turn as a, type DoctorReport as a0, type TransportPreference as a1, type CapabilityRequirements as a2, type PermissionModeCeiling as a3, type CapabilityRequirement as a4, type InteractionBase as a5, type InteractionBinding as a6, MEMORY_CAPTURE_TIMEOUT_MS as a7, MEMORY_DEFAULT_MAX_BYTES as a8, MEMORY_DEFAULT_MAX_ITEMS as a9, ConstraintIntegrityError as aA, type ConstraintRef as aB, type ConstraintRevocation as aC, type ConstraintStoreCreateOptions as aD, type ConstraintStoreOptions as aE, type ConstraintVersion as aF, type ConstraintWrite as aG, ContextBudgetError as aH, type ContextReference as aI, type HistoryEntry as aJ, NothingPinnedError as aK, type PinnedConstraint as aL, UnverifiedPinnedChannelError as aM, MEMORY_DEFAULT_MAX_PROFILE_BYTES as aa, MEMORY_DEFAULT_RECALL_TIMEOUT_MS as ab, MEMORY_MAX_BYTES_CEILING as ac, MEMORY_MAX_ITEMS_CEILING as ad, MEMORY_MAX_PROFILE_BYTES_CEILING as ae, type MemoryCaptureRequest as af, type MemoryProfileNote as ag, type MemoryProfileRequest as ah, type MemoryScopeContext as ai, type ModelCatalog as aj, type ModelUsage as ak, type NegotiatedPlan as al, type ProviderDoctorReport as am, type ProviderOptions as an, type TurnToken as ao, type UserQuestion as ap, resolveBinary as aq, ConstraintStore as ar, type TaskMaterial as as, type ContextBudget as at, type ConstraintExpectation as au, type CompiledContext as av, type PinnedChannel as aw, ConstraintAuthority as ax, ConstraintAuthorityError as ay, ConstraintConflictError as az, type TransportKind as b, type AuthStatus as c, type AgentOptions as d, type ProviderInstallation as e, type SessionIdentity as f, type AgentMemoryProvider as g, type AgentMemoryScope as h, type ApplicationToolScope as i, type ApplicationTool as j, type ApplicationToolContext as k, type MemoryProposeRequest as l, type MemoryRecallRequest as m, type PinnedOption as n, type PinnedTurnNote as o, type MemoryOption as p, type AgentInput as q, resolveBinaryCandidates as r, type MemoryTurnNote as s, type SessionPersistence as t, type RuntimeWarning as u, type CapabilityStatus as v, type SessionState as w, type PersistedSessionRef as x, type TurnHandle as y, type AgentReadinessOptions as z };
|