@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.
Files changed (71) hide show
  1. package/README.md +10 -7
  2. package/dist/agent-loop.d.ts +84 -205
  3. package/dist/agent-loop.js +288 -597
  4. package/dist/calibration.d.ts +14 -10
  5. package/dist/calibration.js +30 -23
  6. package/dist/capabilities.d.ts +111 -42
  7. package/dist/capabilities.js +281 -138
  8. package/dist/client.d.ts +104 -35
  9. package/dist/client.js +205 -74
  10. package/dist/compaction.d.ts +103 -60
  11. package/dist/compaction.js +160 -86
  12. package/dist/config.d.ts +48 -12
  13. package/dist/config.js +20 -1
  14. package/dist/continuation.d.ts +24 -16
  15. package/dist/continuation.js +70 -44
  16. package/dist/digest.d.ts +7 -0
  17. package/dist/digest.js +18 -0
  18. package/dist/errors.d.ts +24 -15
  19. package/dist/errors.js +23 -15
  20. package/dist/events.d.ts +100 -63
  21. package/dist/events.js +250 -120
  22. package/dist/guards.d.ts +35 -4
  23. package/dist/guards.js +38 -5
  24. package/dist/hook-events.d.ts +21 -5
  25. package/dist/hook-events.js +23 -9
  26. package/dist/hooks.d.ts +96 -73
  27. package/dist/hooks.js +202 -116
  28. package/dist/index.d.ts +30 -26
  29. package/dist/index.js +29 -24
  30. package/dist/ledger.d.ts +62 -30
  31. package/dist/ledger.js +163 -56
  32. package/dist/platform.d.ts +13 -0
  33. package/dist/platform.js +13 -0
  34. package/dist/preselect.d.ts +222 -0
  35. package/dist/preselect.js +290 -0
  36. package/dist/request-body.d.ts +32 -0
  37. package/dist/request-body.js +47 -0
  38. package/dist/reset.d.ts +1 -0
  39. package/dist/reset.js +7 -6
  40. package/dist/retry.d.ts +29 -138
  41. package/dist/retry.js +69 -282
  42. package/dist/run-calls.d.ts +123 -0
  43. package/dist/run-calls.js +351 -0
  44. package/dist/run-turn.d.ts +36 -15
  45. package/dist/run-turn.js +74 -37
  46. package/dist/runtime.d.ts +23 -17
  47. package/dist/runtime.js +34 -24
  48. package/dist/schema-compat.d.ts +35 -18
  49. package/dist/schema-compat.js +340 -175
  50. package/dist/scope.d.ts +28 -5
  51. package/dist/scope.js +37 -10
  52. package/dist/side-task.d.ts +123 -40
  53. package/dist/side-task.js +181 -63
  54. package/dist/snapshot.d.ts +10 -5
  55. package/dist/snapshot.js +73 -30
  56. package/dist/spec.d.ts +56 -25
  57. package/dist/spec.js +494 -215
  58. package/dist/stream.d.ts +66 -16
  59. package/dist/stream.js +220 -97
  60. package/dist/thinking.d.ts +23 -8
  61. package/dist/thinking.js +92 -44
  62. package/dist/tokens.d.ts +164 -6
  63. package/dist/tokens.js +319 -6
  64. package/dist/tool-calls.d.ts +82 -17
  65. package/dist/tool-calls.js +198 -83
  66. package/dist/tool-loading.d.ts +101 -189
  67. package/dist/tool-loading.js +277 -371
  68. package/dist/wire.d.ts +81 -0
  69. package/dist/wire.js +73 -0
  70. package/llms.txt +76 -39
  71. package/package.json +4 -4
package/dist/spec.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { AgentConfig, Endpoint } from "./config.ts";
2
- import { type HookEvent } from "./hook-events.ts";
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 ["compaction", "toolSelect", "title", "followups"];
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: "file" | "url";
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?: "eager" | "ondemand" | "proxy";
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
- /** Absent is the side task's own default, 0.3, whatever the agent's temperature is. */
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. Off by default, because a bundled server carries a
258
- * command line and an environment map: loading one is equivalent to running a program, exactly
259
- * as dangerous as pasting somebody's `.mcp.json`, and a host has to make that decision rather
260
- * than inherit it from a default.
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
- /** The events this host actually fires, defaulting to all of them. A hook bound elsewhere warns. */
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. Off by default, mirroring the pool's
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 this removes values rather than keys, and
328
- * nothing outside `bundle` is touched: the format has no credential field at any depth, which is
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;