@cubicecho/agent-core 2.24.0 → 2.25.0
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/README.md +10 -7
- package/dist/agent-loop.d.ts +84 -205
- package/dist/agent-loop.js +288 -597
- package/dist/calibration.d.ts +14 -10
- package/dist/calibration.js +30 -23
- package/dist/capabilities.d.ts +111 -42
- package/dist/capabilities.js +281 -138
- package/dist/client.d.ts +104 -35
- package/dist/client.js +205 -74
- package/dist/compaction.d.ts +103 -60
- package/dist/compaction.js +160 -86
- package/dist/config.d.ts +48 -12
- package/dist/config.js +20 -1
- package/dist/continuation.d.ts +24 -16
- package/dist/continuation.js +70 -44
- package/dist/digest.d.ts +7 -0
- package/dist/digest.js +18 -0
- package/dist/errors.d.ts +24 -15
- package/dist/errors.js +23 -15
- package/dist/events.d.ts +100 -63
- package/dist/events.js +250 -120
- package/dist/guards.d.ts +35 -4
- package/dist/guards.js +38 -5
- package/dist/hook-events.d.ts +21 -5
- package/dist/hook-events.js +23 -9
- package/dist/hooks.d.ts +96 -73
- package/dist/hooks.js +202 -116
- package/dist/index.d.ts +30 -26
- package/dist/index.js +29 -24
- package/dist/ledger.d.ts +62 -30
- package/dist/ledger.js +163 -56
- package/dist/platform.d.ts +13 -0
- package/dist/platform.js +13 -0
- package/dist/preselect.d.ts +222 -0
- package/dist/preselect.js +290 -0
- package/dist/request-body.d.ts +32 -0
- package/dist/request-body.js +47 -0
- package/dist/reset.d.ts +1 -0
- package/dist/reset.js +7 -6
- package/dist/retry.d.ts +29 -138
- package/dist/retry.js +69 -282
- package/dist/run-calls.d.ts +123 -0
- package/dist/run-calls.js +351 -0
- package/dist/run-turn.d.ts +36 -15
- package/dist/run-turn.js +74 -37
- package/dist/runtime.d.ts +23 -17
- package/dist/runtime.js +34 -24
- package/dist/schema-compat.d.ts +35 -18
- package/dist/schema-compat.js +340 -175
- package/dist/scope.d.ts +28 -5
- package/dist/scope.js +37 -10
- package/dist/side-task.d.ts +123 -40
- package/dist/side-task.js +181 -63
- package/dist/snapshot.d.ts +10 -5
- package/dist/snapshot.js +73 -30
- package/dist/spec.d.ts +56 -25
- package/dist/spec.js +494 -215
- package/dist/stream.d.ts +66 -16
- package/dist/stream.js +220 -97
- package/dist/thinking.d.ts +23 -8
- package/dist/thinking.js +92 -44
- package/dist/tokens.d.ts +164 -6
- package/dist/tokens.js +319 -6
- package/dist/tool-calls.d.ts +82 -17
- package/dist/tool-calls.js +198 -83
- package/dist/tool-loading.d.ts +101 -189
- package/dist/tool-loading.js +277 -371
- package/dist/wire.d.ts +81 -0
- package/dist/wire.js +73 -0
- package/llms.txt +76 -39
- package/package.json +4 -4
package/dist/spec.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
1
|
+
import { type AgentConfig, type Endpoint } from './config.ts';
|
|
2
|
+
import { HookEvent } from './hook-events.ts';
|
|
3
3
|
/**
|
|
4
4
|
* A JSON document that defines an agent, and the rules for reading one.
|
|
5
5
|
*
|
|
@@ -25,13 +25,15 @@ export declare const AGENT_SPEC_VERSION = 1;
|
|
|
25
25
|
* The side tasks this package has code for: documentation and a sensible UI order, not a
|
|
26
26
|
* validator.
|
|
27
27
|
*
|
|
28
|
+
* @remarks
|
|
28
29
|
* `tasks` is an open record on purpose — a host may run tasks this package has never heard of,
|
|
29
30
|
* and an unknown key is carried through untouched rather than warned about.
|
|
30
31
|
*/
|
|
31
|
-
export declare const AGENT_TASKS: readonly [
|
|
32
|
+
export declare const AGENT_TASKS: readonly ['compaction', 'toolSelect', 'title', 'followups'];
|
|
32
33
|
/**
|
|
33
34
|
* Every event a hook may be bound to: `HOOK_EVENTS`, under the name a document's reader knows.
|
|
34
35
|
*
|
|
36
|
+
* @remarks
|
|
35
37
|
* The same array, not a copy. It comes from `hook-events.ts` rather than `hooks.ts` because that
|
|
36
38
|
* module's `createHash` would otherwise come with it, into a file whose whole point is that a
|
|
37
39
|
* browser can load it.
|
|
@@ -91,6 +93,10 @@ export interface ModelSpec {
|
|
|
91
93
|
/** Request fields the interface cannot spell. `model`, `messages`, `stream`, `tools` are dropped. */
|
|
92
94
|
extraBody?: Record<string, unknown>;
|
|
93
95
|
}
|
|
96
|
+
/** The `ref.type` of a prompt part whose text is in a file. */
|
|
97
|
+
export declare const REF_FILE: 'file';
|
|
98
|
+
/** The `ref.type` of a prompt part whose text is behind a URL. */
|
|
99
|
+
export declare const REF_URL: 'url';
|
|
94
100
|
/** One layer of system prompt, named so a layer above can stack beside it or replace it. */
|
|
95
101
|
export interface PromptPart {
|
|
96
102
|
/** Names this layer: `project`, `identity`, `role`, `lane`. Merging happens on it. */
|
|
@@ -99,7 +105,7 @@ export interface PromptPart {
|
|
|
99
105
|
text?: string;
|
|
100
106
|
/** Where the text lives instead. The shape is validated; the reference is never resolved. */
|
|
101
107
|
ref?: {
|
|
102
|
-
type:
|
|
108
|
+
type: typeof REF_FILE | typeof REF_URL;
|
|
103
109
|
value: string;
|
|
104
110
|
};
|
|
105
111
|
}
|
|
@@ -109,7 +115,7 @@ export interface ToolsSpec {
|
|
|
109
115
|
* How tool definitions reach the model: all of them on every request, a name-only catalogue
|
|
110
116
|
* the model loads from, or that catalogue behind a fixed `load_tools` and `call_tool`.
|
|
111
117
|
*/
|
|
112
|
-
discovery?:
|
|
118
|
+
discovery?: 'eager' | 'ondemand' | 'proxy';
|
|
113
119
|
/** The hard stop on a tool loop. At least one. */
|
|
114
120
|
maxIterations?: number;
|
|
115
121
|
/**
|
|
@@ -134,7 +140,11 @@ export interface TaskSpec {
|
|
|
134
140
|
endpoint?: EndpointSpec;
|
|
135
141
|
/** The reply's ceiling. Absent is the side task's own default, not the agent's `maxTokens`. */
|
|
136
142
|
maxTokens?: number;
|
|
137
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* Sampling temperature, whatever the agent's own is.
|
|
145
|
+
*
|
|
146
|
+
* @defaultValue `0.3`
|
|
147
|
+
*/
|
|
138
148
|
temperature?: number;
|
|
139
149
|
/**
|
|
140
150
|
* A level has the task deliberate. Absent and `"off"` leave it with the no-thinking hints a
|
|
@@ -175,6 +185,7 @@ export interface SpecBundle {
|
|
|
175
185
|
* Full MCP server definitions. Validated only as far as a round trip needs — an object, a
|
|
176
186
|
* non-empty `id` or `slug`, no duplicate slugs — with every other key passed through untouched.
|
|
177
187
|
*
|
|
188
|
+
* @remarks
|
|
178
189
|
* This package deliberately does not restate the pool's `McpServerConfig`. Restating a union it
|
|
179
190
|
* never reads is a version-skew generator: the pool carries `coerceArguments`, `maxResultChars`
|
|
180
191
|
* and three separate timeouts, and a strict parse here would silently delete a server's
|
|
@@ -186,6 +197,7 @@ export interface SpecBundle {
|
|
|
186
197
|
/**
|
|
187
198
|
* One side task, resolved: a model, and the endpoint it is reached through.
|
|
188
199
|
*
|
|
200
|
+
* @remarks
|
|
189
201
|
* The three settings are present only where a layer stated them, and nothing is filled in from
|
|
190
202
|
* the agent's own model — `taskCall` turns one into a call, and what is absent there is left to
|
|
191
203
|
* the side task's default.
|
|
@@ -202,6 +214,7 @@ export interface ResolvedTask {
|
|
|
202
214
|
* What layered documents resolve to: the flat shape the loop already takes, plus the parts of an
|
|
203
215
|
* agent that are the host's to act on.
|
|
204
216
|
*
|
|
217
|
+
* @remarks
|
|
205
218
|
* `extends AgentConfig` is the whole point — `getClient(resolved)` and
|
|
206
219
|
* `runAgentLoop({ config: resolved })` take this unchanged, and no adapter is needed.
|
|
207
220
|
*/
|
|
@@ -229,6 +242,7 @@ export interface ResolvedAgent extends AgentConfig {
|
|
|
229
242
|
/**
|
|
230
243
|
* What a field falls back to when no layer said anything at all.
|
|
231
244
|
*
|
|
245
|
+
* @remarks
|
|
232
246
|
* Not sentinels, and not invented: `toolDiscovery`, `maxRetries` and `contextLength` are the
|
|
233
247
|
* "absent everywhere" column of the document's own table, and `temperature` and `maxToolIterations`
|
|
234
248
|
* are what all three consumers store as their defaults today. A field left out here is left out of
|
|
@@ -254,13 +268,19 @@ export interface ParsedSpec {
|
|
|
254
268
|
/** What `parseSpec` takes besides the document. */
|
|
255
269
|
export interface ParseSpecOptions {
|
|
256
270
|
/**
|
|
257
|
-
* Parse `bundle` rather than dropping it.
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
271
|
+
* Parse `bundle` rather than dropping it. Opt-in, because a bundled server carries a command
|
|
272
|
+
* line and an environment map: loading one is equivalent to running a program, exactly as
|
|
273
|
+
* dangerous as pasting somebody's `.mcp.json`, and a host has to make that decision rather than
|
|
274
|
+
* inherit it from a default.
|
|
275
|
+
*
|
|
276
|
+
* @defaultValue `false`
|
|
261
277
|
*/
|
|
262
278
|
bundle?: boolean;
|
|
263
|
-
/**
|
|
279
|
+
/**
|
|
280
|
+
* The events this host actually fires. A hook bound elsewhere warns.
|
|
281
|
+
*
|
|
282
|
+
* @defaultValue `SPEC_EVENTS`, which is all of them
|
|
283
|
+
*/
|
|
264
284
|
events?: readonly string[];
|
|
265
285
|
/** The `extensions` keys this host understands. A `requires` entry outside it refuses the load. */
|
|
266
286
|
understands?: readonly string[];
|
|
@@ -268,6 +288,14 @@ export interface ParseSpecOptions {
|
|
|
268
288
|
/**
|
|
269
289
|
* Reads a document, dropping what it cannot use and refusing only what it cannot identify.
|
|
270
290
|
*
|
|
291
|
+
* @param document - Anything at all — this is the front door, and it is given parsed JSON from a
|
|
292
|
+
* form, a file or another host.
|
|
293
|
+
* @param [options] - Whether to parse a bundle, which events this host fires, and which extension
|
|
294
|
+
* keys it understands.
|
|
295
|
+
* @returns The document that survived — a new object, never the one handed in — or `spec: null`
|
|
296
|
+
* where `errors` holds anything. `warnings` is filled either way.
|
|
297
|
+
*
|
|
298
|
+
* @remarks
|
|
271
299
|
* Every problem is reported at once, in the `path: what is wrong` shape `validateHooks` already
|
|
272
300
|
* uses, because a host showing an operator one error at a time makes them fix a document one
|
|
273
301
|
* round trip at a time.
|
|
@@ -283,16 +311,16 @@ export interface ParseSpecOptions {
|
|
|
283
311
|
* version and returns false: degrade where the loss is performance, refuse where the loss is
|
|
284
312
|
* identity. A snapshot of the wrong version costs a few refused requests; an agent of the wrong
|
|
285
313
|
* version is not the agent its author described.
|
|
286
|
-
*
|
|
287
|
-
* @param document Anything at all — this is the front door, and it is given parsed JSON from a
|
|
288
|
-
* form, a file or another host.
|
|
289
|
-
* @param options Whether to parse a bundle, which events this host fires, and which extension
|
|
290
|
-
* keys it understands.
|
|
291
314
|
*/
|
|
292
315
|
export declare function parseSpec(document: unknown, options?: ParseSpecOptions): ParsedSpec;
|
|
293
316
|
/**
|
|
294
317
|
* Layers documents into the flat object the loop takes, weakest first.
|
|
295
318
|
*
|
|
319
|
+
* @param layers - The documents, weakest first: settings, then the agent, then a task, then a step.
|
|
320
|
+
* @returns The resolved agent, built new. Always whole: an empty list gives empty strings and
|
|
321
|
+
* `RESOLVED_DEFAULTS` rather than an error, and `apiKey` is `""` whatever the layers said.
|
|
322
|
+
*
|
|
323
|
+
* @remarks
|
|
296
324
|
* Absent inherits, and nothing else does: `0`, `-1`, `""` and `[]` are values that mean what they
|
|
297
325
|
* say, which is the whole reason the format exists — `maxTokens: 0` means three different things
|
|
298
326
|
* across the three applications this was extracted from, and `temperature: 0` is unsayable in one
|
|
@@ -307,28 +335,31 @@ export declare function parseSpec(document: unknown, options?: ParseSpecOptions)
|
|
|
307
335
|
* empty for the same reason: a document naming somebody else's endpoint must not be able to make
|
|
308
336
|
* this host send its own provider key there. A host that wants inheritance applies `resolveApiKey`
|
|
309
337
|
* afterwards.
|
|
310
|
-
*
|
|
311
|
-
* @param layers The documents, weakest first: settings, then the agent, then a task, then a step.
|
|
312
338
|
*/
|
|
313
339
|
export declare function resolveAgentSpec(layers: readonly AgentSpec[]): ResolvedAgent;
|
|
314
340
|
/** What `exportSpec` takes besides the document. */
|
|
315
341
|
export interface ExportSpecOptions {
|
|
316
342
|
/**
|
|
317
|
-
* Keep the environment and headers of bundled servers.
|
|
343
|
+
* Keep the environment and headers of bundled servers. Opt-in, mirroring the pool's
|
|
318
344
|
* `state({ secrets })`, because those are where a bundled server's credentials live.
|
|
345
|
+
*
|
|
346
|
+
* @defaultValue `false`
|
|
319
347
|
*/
|
|
320
348
|
secrets?: boolean;
|
|
321
349
|
}
|
|
322
350
|
/**
|
|
323
351
|
* A document fit to leave the host: the same agent, with the secrets of its bundled servers gone.
|
|
324
352
|
*
|
|
353
|
+
* @param spec - A document, ordinarily one `parseSpec` returned.
|
|
354
|
+
* @param [options] - Whether to keep the secrets.
|
|
355
|
+
* @returns A copy one level deep, never `spec` itself: what is not redacted is shared with the
|
|
356
|
+
* original.
|
|
357
|
+
*
|
|
358
|
+
* @remarks
|
|
325
359
|
* The property worth keeping is that **a redacted spec is still a valid spec** — it parses, it
|
|
326
360
|
* resolves, and what comes back is the same agent pointed at the same servers, needing only the
|
|
327
|
-
* credentials the importing host supplies itself. So
|
|
328
|
-
* nothing outside `bundle` is touched: the format has no
|
|
329
|
-
* the reason there is nothing else to strip.
|
|
330
|
-
*
|
|
331
|
-
* @param spec A document, ordinarily one `parseSpec` returned.
|
|
332
|
-
* @param options Whether to keep the secrets. The default is not to.
|
|
361
|
+
* credentials the importing host supplies itself. So a bundled server loses its `env` and its
|
|
362
|
+
* `headers` and nothing else, and nothing outside `bundle` is touched: the format has no
|
|
363
|
+
* credential field at any depth, which is the reason there is nothing else to strip.
|
|
333
364
|
*/
|
|
334
365
|
export declare function exportSpec(spec: AgentSpec, { secrets }?: ExportSpecOptions): AgentSpec;
|