@cubicecho/agent-core 4.0.0 → 4.2.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 (73) hide show
  1. package/README.md +50 -2
  2. package/dist/{compaction.d.ts → context/compaction.d.ts} +3 -3
  3. package/dist/{compaction.js → context/compaction.js} +6 -6
  4. package/dist/{ledger.d.ts → context/ledger.d.ts} +2 -2
  5. package/dist/{ledger.js → context/ledger.js} +3 -3
  6. package/dist/{calibration.js → endpoint/calibration.js} +4 -4
  7. package/dist/{capabilities.d.ts → endpoint/capabilities.d.ts} +2 -2
  8. package/dist/{capabilities.js → endpoint/capabilities.js} +3 -3
  9. package/dist/{client.d.ts → endpoint/client.d.ts} +27 -11
  10. package/dist/{client.js → endpoint/client.js} +85 -26
  11. package/dist/{schema-compat.js → endpoint/schema-compat.js} +2 -2
  12. package/dist/{hooks.js → hooks/hooks.js} +6 -6
  13. package/dist/index.d.ts +30 -30
  14. package/dist/index.js +29 -29
  15. package/dist/{agent-loop.d.ts → run/agent-loop.d.ts} +25 -16
  16. package/dist/{agent-loop.js → run/agent-loop.js} +34 -25
  17. package/dist/{events.d.ts → run/events.d.ts} +3 -3
  18. package/dist/{events.js → run/events.js} +6 -6
  19. package/dist/{request-body.d.ts → run/request-body.d.ts} +3 -3
  20. package/dist/{request-body.js → run/request-body.js} +4 -4
  21. package/dist/{run-calls.d.ts → run/run-calls.d.ts} +3 -3
  22. package/dist/{run-calls.js → run/run-calls.js} +4 -4
  23. package/dist/{reset.js → runtime/reset.js} +6 -6
  24. package/dist/{runtime.d.ts → runtime/runtime.d.ts} +11 -11
  25. package/dist/{runtime.js → runtime/runtime.js} +12 -12
  26. package/dist/{snapshot.js → runtime/snapshot.js} +4 -4
  27. package/dist/{spec.d.ts → spec/spec.d.ts} +44 -4
  28. package/dist/{spec.js → spec/spec.js} +164 -5
  29. package/dist/{preselect.d.ts → tools/preselect.d.ts} +5 -4
  30. package/dist/{preselect.js → tools/preselect.js} +6 -5
  31. package/dist/{tool-loading.js → tools/tool-loading.js} +3 -3
  32. package/dist/{continuation.d.ts → turn/continuation.d.ts} +2 -2
  33. package/dist/{continuation.js → turn/continuation.js} +5 -5
  34. package/dist/{run-turn.d.ts → turn/run-turn.d.ts} +2 -2
  35. package/dist/{run-turn.js → turn/run-turn.js} +7 -7
  36. package/dist/{side-task.d.ts → turn/side-task.d.ts} +2 -2
  37. package/dist/{side-task.js → turn/side-task.js} +9 -9
  38. package/dist/{errors.d.ts → wire/errors.d.ts} +4 -0
  39. package/dist/{errors.js → wire/errors.js} +4 -0
  40. package/dist/{retry.js → wire/retry.js} +1 -1
  41. package/dist/{stream.js → wire/stream.js} +1 -1
  42. package/dist/{tool-calls.js → wire/tool-calls.js} +1 -1
  43. package/llms.txt +180 -175
  44. package/package.json +3 -3
  45. /package/dist/{config.d.ts → core/config.d.ts} +0 -0
  46. /package/dist/{config.js → core/config.js} +0 -0
  47. /package/dist/{digest.d.ts → core/digest.d.ts} +0 -0
  48. /package/dist/{digest.js → core/digest.js} +0 -0
  49. /package/dist/{guards.d.ts → core/guards.d.ts} +0 -0
  50. /package/dist/{guards.js → core/guards.js} +0 -0
  51. /package/dist/{platform.d.ts → core/platform.d.ts} +0 -0
  52. /package/dist/{platform.js → core/platform.js} +0 -0
  53. /package/dist/{scope.d.ts → core/scope.d.ts} +0 -0
  54. /package/dist/{scope.js → core/scope.js} +0 -0
  55. /package/dist/{calibration.d.ts → endpoint/calibration.d.ts} +0 -0
  56. /package/dist/{schema-compat.d.ts → endpoint/schema-compat.d.ts} +0 -0
  57. /package/dist/{hook-events.d.ts → hooks/hook-events.d.ts} +0 -0
  58. /package/dist/{hook-events.js → hooks/hook-events.js} +0 -0
  59. /package/dist/{hooks.d.ts → hooks/hooks.d.ts} +0 -0
  60. /package/dist/{reset.d.ts → runtime/reset.d.ts} +0 -0
  61. /package/dist/{snapshot.d.ts → runtime/snapshot.d.ts} +0 -0
  62. /package/dist/{catalog.d.ts → tools/catalog.d.ts} +0 -0
  63. /package/dist/{catalog.js → tools/catalog.js} +0 -0
  64. /package/dist/{tool-loading.d.ts → tools/tool-loading.d.ts} +0 -0
  65. /package/dist/{retry.d.ts → wire/retry.d.ts} +0 -0
  66. /package/dist/{stream.d.ts → wire/stream.d.ts} +0 -0
  67. /package/dist/{thinking.d.ts → wire/thinking.d.ts} +0 -0
  68. /package/dist/{thinking.js → wire/thinking.js} +0 -0
  69. /package/dist/{tokens.d.ts → wire/tokens.d.ts} +0 -0
  70. /package/dist/{tokens.js → wire/tokens.js} +0 -0
  71. /package/dist/{tool-calls.d.ts → wire/tool-calls.d.ts} +0 -0
  72. /package/dist/{wire.d.ts → wire/wire.d.ts} +0 -0
  73. /package/dist/{wire.js → wire/wire.js} +0 -0
package/llms.txt CHANGED
@@ -9,18 +9,50 @@ Full prose, worked examples and the reasoning behind each seam are in README.md;
9
9
 
10
10
  ## Exports
11
11
 
12
- ### agent-loop
12
+ ### compaction
13
13
 
14
- The loop above a turn: send, run the tools the model asked for, send again, until it stops asking.
14
+ Keeping a long run inside its window: stale tool results cleared, and the oldest stretch folded into a summary the model writes itself.
15
15
 
16
- - `AgentLoopHooks` (type) — The hooks a loop runs around one question.
17
- - `AgentLoopOptions` (type) — What `runAgentLoop` takes.
18
- - `AgentLoopRequest` (type) — One step's request as `onRequest` is handed it: what the model is about to read.
19
- - `AgentLoopResult` (type) — What a finished loop hands back.
20
- - `PRESELECT_APPEND` — The `preselectRouting` that loads the shortlist after what was carried, and sends the first step like any other.
21
- - `PRESELECT_EXCLUSIVE` — The `preselectRouting` that sends the first step the shortlist alone.
22
- - `runAgentLoop` — Runs a question to its answer: one `runTurn` per step, the tools it asks for between them, until a turn asks for none.
23
- - `StepWindow` (type) — How full the window is as a step is about to be sent, as `beforeStep` is told it.
16
+ - `applyCompaction` — The transcript as the server should see it: the folded head replaced by its summary.
17
+ - `COMPACT_AT` — The fraction of the window in use before a summary is worth its own round trip.
18
+ - `CompactionOptions` (type) — What `planCompaction` takes.
19
+ - `CompactionPlan` (type) — Where to cut, as `compactTranscript` takes it.
20
+ - `CompactionRecord` (type) — One fold, as a host that keeps its transcript append-only stores it.
21
+ - `CompactionRunOptions` (type) — What `runCompaction` and `compactTranscript` take beside the plan.
22
+ - `compactTranscript` — The transcript with the plan's stretch replaced by one system message holding its summary.
23
+ - `KEEP_RATIO` — The fraction of the window the kept tail may fill, leaving room for the run to grow again.
24
+ - `PruneOptions` (type) — What `pruneToolResults` takes.
25
+ - `planCompaction` — Where to fold a transcript that has grown into its window, or `undefined` when it should not be.
26
+ - `pruneToolResults` — The transcript with every tool result but the latest few replaced by a one-line stub.
27
+ - `requestIndex` — Where a stored index sits in the request `applyCompaction` builds, once a fold has shifted everything after it.
28
+ - `runCompaction` — The hooks and the summariser for a plan, as a record to store rather than a transcript to send.
29
+ - `SUMMARY_LEAD` — How a summary message opens, which is also how `planCompaction` knows one from a system prompt.
30
+ - `SUMMARY_PROMPT` — The summariser's instruction when the caller gives none.
31
+ - `summariser` — A summariser that asks `model` with `SUMMARY_PROMPT`, for `compactTranscript`.
32
+
33
+ ### ledger
34
+
35
+ What stretches of a transcript cost, read off the prompt counts the server already reported.
36
+
37
+ - `estimateFrom` — A per-message cost for `planCompaction`'s `estimate`: the measured share where the ledger covers the message, the calibrated estimate where it does not.
38
+ - `LedgerEntry` (type) — One request's reported prompt, and how far into the transcript that request reached.
39
+ - `LedgerEstimateOptions` (type) — What `tokensBetween` and `estimateFrom` take besides the ledger and the transcript.
40
+ - `LedgerRequest` (type) — What `recordRequest` needs to know of one request.
41
+ - `rebaseLedger` — The ledger for a transcript that has been rewritten, keeping the boundaries the rewrite left standing.
42
+ - `recordRequest` — The ledger with one more request on it, in the epoch the request before it says it belongs to.
43
+ - `TokenLedger` (type) — A transcript's entries in the order their requests were sent, which is also by `through`.
44
+ - `tokensBetween` — What the messages from `from` up to, not including, `to` cost the window, measured where the ledger can say and estimated where it cannot.
45
+
46
+ ### config
47
+
48
+ What this package needs to know about a caller's configuration.
49
+
50
+ - `AgentConfig` (type) — A whole agent configuration — every part, plus the two fields that belong to no group.
51
+ - `Endpoint` (type) — Where to send a request and how long to wait.
52
+ - `ModelParams` (type) — What to ask the model for.
53
+ - `RetryPolicy` (type) — How many times a lost or refused request is worth sending again.
54
+ - `ToolDiscovery` — Any one of the modes in `ToolDiscovery`.
55
+ - `ToolPolicy` (type) — How tools reach the model, and how long it may keep calling them.
24
56
 
25
57
  ### calibration
26
58
 
@@ -47,12 +79,6 @@ What an endpoint turned out not to support, and answering it when it says so.
47
79
  - `negotiate` — Sends a request, re-sending it each time the answer is this endpoint refusing something the request can do without.
48
80
  - `resetCapabilities` — Forgets what one endpoint refused, or every endpoint's when told none.
49
81
 
50
- ### catalog
51
-
52
- The contract between whatever holds the tools and the loop that offers them to a model.
53
-
54
- - `CatalogServer` (type) — One server's tools, without their JSON schemas — the cheap half of a tool definition.
55
-
56
82
  ### client
57
83
 
58
84
  - `ClientPoolOptions` (type) — What the client pool is held to across a process.
@@ -62,6 +88,7 @@ The contract between whatever holds the tools and the loop that offers them to a
62
88
  - `endpointKey` — What counts as one endpoint, everywhere in this package that has to remember something about one — the model listings, `capabilities`, and the no-thinking hints in `side-task`.
63
89
  - `firstTokenMs` — The wait for a streamed turn's first chunk, in the SDK's spelling: `undefined` is no limit.
64
90
  - `getClient` — The client for an endpoint, built once and kept.
91
+ - `LookupOptions` (type) — What a lookup takes besides the endpoint: `listModels`, `servedWindow` and `contextLimitFor`.
65
92
  - `listModels` — Asks an endpoint what it serves, and remembers the answer.
66
93
  - `ModelInfo` (type) — A model an endpoint offers, and what it says the model will read.
67
94
  - `NO_KEY` — The SDK insists on a non-empty key even where the server will not look at it.
@@ -70,75 +97,15 @@ The contract between whatever holds the tools and the loop that offers them to a
70
97
  - `servedWindow` — The window a local server's own API says it is serving a model in, for the servers whose listing does not say.
71
98
  - `timeoutMs` — An endpoint's request timeout in the SDK's spelling: milliseconds, and `undefined` for no limit.
72
99
 
73
- ### compaction
74
-
75
- Keeping a long run inside its window: stale tool results cleared, and the oldest stretch folded into a summary the model writes itself.
76
-
77
- - `applyCompaction` — The transcript as the server should see it: the folded head replaced by its summary.
78
- - `COMPACT_AT` — The fraction of the window in use before a summary is worth its own round trip.
79
- - `CompactionOptions` (type) — What `planCompaction` takes.
80
- - `CompactionPlan` (type) — Where to cut, as `compactTranscript` takes it.
81
- - `CompactionRecord` (type) — One fold, as a host that keeps its transcript append-only stores it.
82
- - `CompactionRunOptions` (type) — What `runCompaction` and `compactTranscript` take beside the plan.
83
- - `compactTranscript` — The transcript with the plan's stretch replaced by one system message holding its summary.
84
- - `KEEP_RATIO` — The fraction of the window the kept tail may fill, leaving room for the run to grow again.
85
- - `PruneOptions` (type) — What `pruneToolResults` takes.
86
- - `planCompaction` — Where to fold a transcript that has grown into its window, or `undefined` when it should not be.
87
- - `pruneToolResults` — The transcript with every tool result but the latest few replaced by a one-line stub.
88
- - `requestIndex` — Where a stored index sits in the request `applyCompaction` builds, once a fold has shifted everything after it.
89
- - `runCompaction` — The hooks and the summariser for a plan, as a record to store rather than a transcript to send.
90
- - `SUMMARY_LEAD` — How a summary message opens, which is also how `planCompaction` knows one from a system prompt.
91
- - `SUMMARY_PROMPT` — The summariser's instruction when the caller gives none.
92
- - `summariser` — A summariser that asks `model` with `SUMMARY_PROMPT`, for `compactTranscript`.
93
-
94
- ### config
95
-
96
- What this package needs to know about a caller's configuration.
97
-
98
- - `AgentConfig` (type) — A whole agent configuration — every part, plus the two fields that belong to no group.
99
- - `Endpoint` (type) — Where to send a request and how long to wait.
100
- - `ModelParams` (type) — What to ask the model for.
101
- - `RetryPolicy` (type) — How many times a lost or refused request is worth sending again.
102
- - `ToolDiscovery` — Any one of the modes in `ToolDiscovery`.
103
- - `ToolPolicy` (type) — How tools reach the model, and how long it may keep calling them.
104
-
105
- ### continuation
106
-
107
- Picking up an answer the token ceiling cut off, instead of keeping half of it.
108
-
109
- - `ContinueTurnOptions` (type) — What `continueTurn` takes besides what `runTurn` does.
110
- - `continueTurn` — Carries on an answer the token ceiling cut off, by sending the transcript again with the answer so far as a trailing assistant message, and joins the pieces into one turn.
111
-
112
- ### errors
113
-
114
- - `AgentLoopError` — What `runAgentLoop` throws, carrying the run as it stood and what was caught as `cause`.
115
- - `AgentLoopFailure` (type) — A run as it stood when `runAgentLoop` gave up on it.
116
- - `AgentLoopOverflow` — A `ContextOverflow` out of `runAgentLoop`, carrying the run as it stood.
117
- - `errorMessage` — What went wrong, as a string.
118
- - `failedRun` — The run a failed `runAgentLoop` left behind, read off whatever it threw, or nothing.
119
- - `ToolIterationLimit` — `maxToolIterations` was spent with the model still asking for tools.
120
-
121
- ### events
100
+ ### schema-compat
122
101
 
123
- What a run is doing, while it is doing it.
102
+ JSON Schema compatibility for llama.cpp-backed servers.
124
103
 
125
- - `configureEvents` — Changes what the bus keeps, for a process whose runs are not shaped like the ones these defaults were chosen for.
126
- - `EventBusOptions` (type) — What the bus keeps and for how long.
127
- - `emit` — Records one event and hands it to everyone watching that run.
128
- - `endRun` — Forgets a run that will not be emitting `done` — one whose process is tearing down, or whose loop threw where it could not be caught.
129
- - `fold` — A run's events with each stretch of `thinking` or of `output` joined into one block, for a reader that takes a run in snapshots.
130
- - `history` — The backlog alone, for a caller that wants a snapshot rather than a subscription.
131
- - `RunEvent` (type) — One thing that happened in a run, as a watcher receives it.
132
- - `RunEventInput` (type) — What `emit` is given: the run and the sequence are the bus's to assign.
133
- - `RunEventKind` — Any one of the kinds in `RunEventKind`.
134
- - `RunMetrics` (type) — A run summed and derived from its events: what it cost, where the time went, and why.
135
- - `RunMetricsOptions` (type) — What `runMetrics` takes besides the events.
136
- - `RunOutcome` — Any one of the outcomes in `RunOutcome`.
137
- - `RunUsage` (type) — What a run has spent, counted from the start of the run rather than for the turn that carried it: a client draws the latest one it has seen and needs no arithmetic of its own, and one lost to the backlog cap costs nothing because the next supersedes it.
138
- - `resetEvents` — Test seam: forget every run, so one test's events cannot be read by the next.
139
- - `runMetrics` — A run's totals, timings and cache findings, derived from the events it emitted.
140
- - `TurnReport` (type) — One turn's usage and measurements as a `usage` event carries them.
141
- - `watch` — Everything that has happened on a run, then everything that happens next, until it ends.
104
+ - `isGrammarError` — Whether a failure looks like the server could not build a grammar from our tool schemas.
105
+ - `relaxSchema` — One schema without its `pattern` and `format` keywords, for a schema that is not a tool's.
106
+ - `relaxTools` — The tool array with every schema's `pattern` and `format` keywords gone — the shape a turn is retried with.
107
+ - `sanitizeSchema` — One JSON Schema as a strict server will accept it, for a schema that is not a tool's parameters.
108
+ - `sanitizeTools` — Tool definitions a strict server will accept, remembered per definition object.
142
109
 
143
110
  ### hook-events
144
111
 
@@ -173,66 +140,55 @@ Lifecycle hooks, from the host's side: what a session looks like to them, where
173
140
  - `untrusted` — Fences text nobody trusted — a fetched page, an email, a submitted card, a tool result — so the model can see where it starts and ends and read it as data rather than as instructions.
174
141
  - `withContext` — The request, with the hooks' context added to this turn's question.
175
142
 
176
- ### ledger
143
+ ### agent-loop
177
144
 
178
- What stretches of a transcript cost, read off the prompt counts the server already reported.
145
+ The loop above a turn: send, run the tools the model asked for, send again, until it stops asking.
179
146
 
180
- - `estimateFrom` — A per-message cost for `planCompaction`'s `estimate`: the measured share where the ledger covers the message, the calibrated estimate where it does not.
181
- - `LedgerEntry` (type) — One request's reported prompt, and how far into the transcript that request reached.
182
- - `LedgerEstimateOptions` (type) — What `tokensBetween` and `estimateFrom` take besides the ledger and the transcript.
183
- - `LedgerRequest` (type) — What `recordRequest` needs to know of one request.
184
- - `rebaseLedger` — The ledger for a transcript that has been rewritten, keeping the boundaries the rewrite left standing.
185
- - `recordRequest` — The ledger with one more request on it, in the epoch the request before it says it belongs to.
186
- - `TokenLedger` (type) — A transcript's entries in the order their requests were sent, which is also by `through`.
187
- - `tokensBetween` — What the messages from `from` up to, not including, `to` cost the window, measured where the ledger can say and estimated where it cannot.
147
+ - `AgentLoopHooks` (type) — The hooks a loop runs around one question.
148
+ - `AgentLoopOptions` (type) — What `runAgentLoop` takes.
149
+ - `AgentLoopRequest` (type) — One step's request as `onRequest` is handed it: what the model is about to read.
150
+ - `AgentLoopResult` (type) — What a finished loop hands back.
151
+ - `PRESELECT_APPEND` — The `preselectRouting` that loads the shortlist after what was carried, and sends the first step like any other.
152
+ - `PRESELECT_EXCLUSIVE` — The `preselectRouting` that sends the first step the shortlist alone.
153
+ - `PRESELECTED_NOTICE` — What opens the notice naming the loop's own picks, ahead of the names.
154
+ - `runAgentLoop` — Runs a question to its answer: one `runTurn` per step, the tools it asks for between them, until a turn asks for none.
155
+ - `StepWindow` (type) — How full the window is as a step is about to be sent, as `beforeStep` is told it.
188
156
 
189
- ### preselect
157
+ ### events
190
158
 
191
- Choosing a run's tools before it starts, from the request and the catalogue's names.
159
+ What a run is doing, while it is doing it.
192
160
 
193
- - `KeywordPreselection` (type) — What `preselectByKeywords` found.
194
- - `KeywordPreselectOptions` (type) — What `preselectByKeywords` takes besides the catalogue and the request.
195
- - `PRESELECT_SCHEMA` — The shape a preselector's answer is held to where the server takes a schema: `{ tools: [...] }`.
196
- - `PRESELECT_SYSTEM` — The preselection system prompt at the default cap, for a caller that never changes it.
197
- - `preselect` — The tools a request is likely to need, picked by a small model before the run starts, or none.
198
- - `preselectByKeywords` — The tools a request's own words point at, ranked, and whether they point clearly enough.
199
- - `preselectInput` — The user message for a preselection call: the catalogue, then the request.
200
- - `preselection` — Resolves a preselection against the catalogue: unknown names dropped, count capped.
201
- - `preselectSystem` — The system prompt a preselector is given, holding it to the cap its answer will be held to.
202
- - `ToolMatch` (type) — One tool's score against a request.
161
+ - `configureEvents` — Changes what the bus keeps, for a process whose runs are not shaped like the ones these defaults were chosen for.
162
+ - `EventBusOptions` (type) — What the bus keeps and for how long.
163
+ - `emit` — Records one event and hands it to everyone watching that run.
164
+ - `endRun` — Forgets a run that will not be emitting `done` — one whose process is tearing down, or whose loop threw where it could not be caught.
165
+ - `fold` — A run's events with each stretch of `thinking` or of `output` joined into one block, for a reader that takes a run in snapshots.
166
+ - `history` — The backlog alone, for a caller that wants a snapshot rather than a subscription.
167
+ - `RunEvent` (type) — One thing that happened in a run, as a watcher receives it.
168
+ - `RunEventInput` (type) — What `emit` is given: the run and the sequence are the bus's to assign.
169
+ - `RunEventKind` — Any one of the kinds in `RunEventKind`.
170
+ - `RunMetrics` (type) — A run summed and derived from its events: what it cost, where the time went, and why.
171
+ - `RunMetricsOptions` (type) — What `runMetrics` takes besides the events.
172
+ - `RunOutcome` — Any one of the outcomes in `RunOutcome`.
173
+ - `RunUsage` (type) — What a run has spent, counted from the start of the run rather than for the turn that carried it: a client draws the latest one it has seen and needs no arithmetic of its own, and one lost to the backlog cap costs nothing because the next supersedes it.
174
+ - `resetEvents` — Test seam: forget every run, so one test's events cannot be read by the next.
175
+ - `runMetrics` — A run's totals, timings and cache findings, derived from the events it emitted.
176
+ - `TurnReport` (type) — One turn's usage and measurements as a `usage` event carries them.
177
+ - `watch` — Everything that has happened on a run, then everything that happens next, until it ends.
203
178
 
204
179
  ### request-body
205
180
 
206
181
  - `buildBody` — The one place a streamed request's body is decided from a config and what the endpoint and the model have refused.
207
182
 
208
- ### reset
209
-
210
- - `resetAll` — Forgets everything this package remembers between calls.
211
-
212
- ### retry
213
-
214
- Everything about a request failing that is not about what the request said.
215
-
216
- - `backoffMs` — How long to wait before a retry: exponential, with jitter so several tasks failing at once do not return in lockstep.
217
- - `ContextOverflow` — The request was bigger than the model will read.
218
- - `EndpointSilent` — The endpoint stopped answering mid-request.
219
- - `isModelLoading` — Whether a failure is a local server still loading the model, rather than one failing to serve.
220
- - `isOverflow` — Whether a refusal means the request was too big, rather than merely refused.
221
- - `isTransient` — Whether a failed request is worth trying again.
222
- - `SMALLEST_LIKELY_WINDOW` — The smallest window worth believing in, and the floor under `runTurn`'s guard.
223
-
224
183
  ### run-calls
225
184
 
226
185
  The tools between two turns: a step's calls read, run and written into the transcript.
227
186
 
228
187
  - `preview` — A long tool argument or result cut to what a watcher needs, with the full length said.
229
188
 
230
- ### run-turn
231
-
232
- One turn, given as many attempts as the caller allows.
189
+ ### reset
233
190
 
234
- - `RunTurnOptions` (type) — A retry is not the same event as a downgrade, but a watcher wants to be told about both.
235
- - `runTurn` — One turn seen through to an answer: negotiated with the endpoint, retried where the failure is transient, and waited for where the model is still loading.
191
+ - `resetAll` — Forgets everything this package remembers between calls.
236
192
 
237
193
  ### runtime
238
194
 
@@ -241,33 +197,6 @@ One turn, given as many attempts as the caller allows.
241
197
  - `Runtime` (type) — One set of the package's caches, with the functions that use them as methods.
242
198
  - `RuntimeOptions` (type) — What a runtime starts out configured with.
243
199
 
244
- ### schema-compat
245
-
246
- JSON Schema compatibility for llama.cpp-backed servers.
247
-
248
- - `isGrammarError` — Whether a failure looks like the server could not build a grammar from our tool schemas.
249
- - `relaxSchema` — One schema without its `pattern` and `format` keywords, for a schema that is not a tool's.
250
- - `relaxTools` — The tool array with every schema's `pattern` and `format` keywords gone — the shape a turn is retried with.
251
- - `sanitizeSchema` — One JSON Schema as a strict server will accept it, for a schema that is not a tool's parameters.
252
- - `sanitizeTools` — Tool definitions a strict server will accept, remembered per definition object.
253
-
254
- ### side-task
255
-
256
- One-shot calls that support a run without being one: picking tools, naming a session, summarising a transcript, proposing follow-ups.
257
-
258
- - `AskJsonOptions` (type) — What `askJson` takes besides a side task's options.
259
- - `ask` — Runs a side task and returns the reply text, thinking stripped.
260
- - `askJson` — A side task whose answer is JSON matching a schema, parsed.
261
- - `clean` — Strips the quoting and list punctuation models decorate short answers with.
262
- - `listLines` — A list-shaped reply, one item per line, cleaned of the bullets and quotes models decorate them with.
263
- - `parseJson` — The first array or object in a model's reply, parsed, whatever prose or fence surrounds it.
264
- - `resetHints` — Test seam, alongside `resetClients` and `resetAll`: forget which models refused the hints.
265
- - `SideTask` (type) — One side task's own settings, as a resolved agent spec carries them under `tasks.<key>`.
266
- - `SideTaskInput` (type) — The input a side task applies its instruction to: text, or the content parts a vision model reads.
267
- - `SideTaskOptions` (type) — What a side task may be given.
268
- - `taskCall` — A side task's settings as the call that honours them: its endpoint, its model, and the options `ask`, `askJson`, `summariser` and `preselect` take last.
269
- - `tryAsk` — Runs a side task and answers `undefined` where it fails, so the work it supports carries on.
270
-
271
200
  ### snapshot
272
201
 
273
202
  What endpoints and models refused, carried across a restart.
@@ -291,6 +220,7 @@ A JSON document that defines an agent, and the rules for reading one.
291
220
  - `EndpointSpec` (type) — Where a model is reached, and how long to wait for it.
292
221
  - `ExportSpecOptions` (type) — What `exportSpec` takes besides the document.
293
222
  - `exportSpec` — A document fit to leave the host: the same agent, with the secrets of its bundled servers gone.
223
+ - `findSpecSecrets` — Where a document's bundled servers may still carry a credential after `exportSpec`.
294
224
  - `ModelSpec` (type) — Which model answers and how, including the request fields this interface cannot spell.
295
225
  - `ParsedSpec` (type) — What `parseSpec` hands back.
296
226
  - `ParseSpecOptions` (type) — What `parseSpec` takes besides the document.
@@ -303,12 +233,109 @@ A JSON document that defines an agent, and the rules for reading one.
303
233
  - `ResolvedTask` (type) — One side task, resolved: a model, and the endpoint it is reached through.
304
234
  - `RetrySpec` (type) — What to do about a request lost before the model produced anything.
305
235
  - `resolveAgentSpec` — Layers documents into the flat object the loop takes, weakest first.
236
+ - `SecretHint` (type) — One place `findSpecSecrets` thinks a credential may be, and never the credential.
237
+ - `SecretSign` — Any one of the reasons in `SecretSign`.
306
238
  - `SPEC_EVENTS` — Every event a hook may be bound to: `HOOK_EVENTS`, under the name a document's reader knows.
307
239
  - `SpecBundle` (type) — What an agent carries so it can travel whole: the definitions of the servers it names.
308
240
  - `SpecServer` (type) — A bundled MCP server, validated only as far as a round trip needs and otherwise passed through.
309
241
  - `TaskSpec` (type) — One side task, which may run on a different model — and a different machine — than the agent.
310
242
  - `ToolsSpec` (type) — How tools reach the model, and which servers this agent may reach at all.
311
243
 
244
+ ### catalog
245
+
246
+ The contract between whatever holds the tools and the loop that offers them to a model.
247
+
248
+ - `CatalogServer` (type) — One server's tools, without their JSON schemas — the cheap half of a tool definition.
249
+
250
+ ### preselect
251
+
252
+ Choosing a run's tools before it starts, from the request and the catalogue's names.
253
+
254
+ - `KeywordPreselection` (type) — What `preselectByKeywords` found.
255
+ - `KeywordPreselectOptions` (type) — What `preselectByKeywords` takes besides the catalogue and the request.
256
+ - `PRESELECT_SCHEMA` — The shape a preselector's answer is held to where the server takes a schema: `{ tools: [...] }`.
257
+ - `PRESELECT_SYSTEM` — The preselection system prompt at the default cap, for a caller that never changes it.
258
+ - `preselect` — The tools a request is likely to need, picked by a small model before the run starts, or none.
259
+ - `preselectByKeywords` — The tools a request's own words point at, ranked, and whether they point clearly enough.
260
+ - `preselectInput` — The user message for a preselection call: the catalogue, then the request.
261
+ - `preselection` — Resolves a preselection against the catalogue: unknown names dropped, count capped.
262
+ - `preselectSystem` — The system prompt a preselector is given, holding it to the cap its answer will be held to.
263
+ - `ToolMatch` (type) — One tool's score against a request.
264
+
265
+ ### tool-loading
266
+
267
+ - `CALL_TOOL` — The one tool a proxied run reaches every catalogued tool through.
268
+ - `carryOver` — The tools to start the next turn with: last turn's where they were, then what this turn used.
269
+ - `catalogList` — The catalogue as a plain grouped listing of names, loaded ones marked if asked.
270
+ - `catalogPrompt` — The catalogue block appended to the system prompt.
271
+ - `expandNames` — Resolves requested names against the catalogue, expanding trailing `*` wildcards.
272
+ - `holdsDefinitions` — Whether a tool result is a proxied load carrying definitions, which is the only copy of them the model has.
273
+ - `inCatalog` — Whether the catalogue holds a tool by this name.
274
+ - `LOAD_TOOLS` — On-demand tool loading.
275
+ - `LOAD_TOOLS_DEFINITION` — One object for the life of the process — the agent loop asks for it on every iteration.
276
+ - `loadedTools` — A tool array with newly loaded definitions appended, in the order they were loaded.
277
+ - `loadResult` — What `load_tools` reports back: the descriptions, now that they are worth their tokens.
278
+ - `orderTools` — The tool array in a stable order, so the same set of tools renders the same way twice.
279
+ - `PROXY_TOOLS` — The whole tool array of a proxied run, `load_tools` then `call_tool`, frozen because it is shared.
280
+ - `proxiedCall` — The tool a `call_tool` names and the arguments to run it with, or a throw the model can read.
281
+ - `proxyCatalogPrompt` — The catalogue block for a proxied run's system prompt, worded for `call_tool` rather than for a tool list.
282
+ - `proxyLoadResult` — What a proxied `load_tools` answers: each new tool's whole definition as a line of JSON, since the result is the only place the model will ever see it.
283
+ - `requestedNames` — `load_tools` arguments, defensively — a model may send a bare string or a nested object.
284
+ - `shownCall` — A tool call as a watcher should see it: a `call_tool` as the tool it ran, anything else as it is.
285
+ - `ToolOrder` (type) — How a tool array is ordered before it is sent: `true` by name, `false` as the caller built it, or a comparator over the two names.
286
+
287
+ ### continuation
288
+
289
+ Picking up an answer the token ceiling cut off, instead of keeping half of it.
290
+
291
+ - `ContinueTurnOptions` (type) — What `continueTurn` takes besides what `runTurn` does.
292
+ - `continueTurn` — Carries on an answer the token ceiling cut off, by sending the transcript again with the answer so far as a trailing assistant message, and joins the pieces into one turn.
293
+
294
+ ### run-turn
295
+
296
+ One turn, given as many attempts as the caller allows.
297
+
298
+ - `RunTurnOptions` (type) — A retry is not the same event as a downgrade, but a watcher wants to be told about both.
299
+ - `runTurn` — One turn seen through to an answer: negotiated with the endpoint, retried where the failure is transient, and waited for where the model is still loading.
300
+
301
+ ### side-task
302
+
303
+ One-shot calls that support a run without being one: picking tools, naming a session, summarising a transcript, proposing follow-ups.
304
+
305
+ - `AskJsonOptions` (type) — What `askJson` takes besides a side task's options.
306
+ - `ask` — Runs a side task and returns the reply text, thinking stripped.
307
+ - `askJson` — A side task whose answer is JSON matching a schema, parsed.
308
+ - `clean` — Strips the quoting and list punctuation models decorate short answers with.
309
+ - `listLines` — A list-shaped reply, one item per line, cleaned of the bullets and quotes models decorate them with.
310
+ - `parseJson` — The first array or object in a model's reply, parsed, whatever prose or fence surrounds it.
311
+ - `resetHints` — Test seam, alongside `resetClients` and `resetAll`: forget which models refused the hints.
312
+ - `SideTask` (type) — One side task's own settings, as a resolved agent spec carries them under `tasks.<key>`.
313
+ - `SideTaskInput` (type) — The input a side task applies its instruction to: text, or the content parts a vision model reads.
314
+ - `SideTaskOptions` (type) — What a side task may be given.
315
+ - `taskCall` — A side task's settings as the call that honours them: its endpoint, its model, and the options `ask`, `askJson`, `summariser` and `preselect` take last.
316
+ - `tryAsk` — Runs a side task and answers `undefined` where it fails, so the work it supports carries on.
317
+
318
+ ### errors
319
+
320
+ - `AgentLoopError` — What `runAgentLoop` throws, carrying the run as it stood and what was caught as `cause`.
321
+ - `AgentLoopFailure` (type) — A run as it stood when `runAgentLoop` gave up on it.
322
+ - `AgentLoopOverflow` — A `ContextOverflow` out of `runAgentLoop`, carrying the run as it stood.
323
+ - `errorMessage` — What went wrong, as a string.
324
+ - `failedRun` — The run a failed `runAgentLoop` left behind, read off whatever it threw, or nothing.
325
+ - `ToolIterationLimit` — `maxToolIterations` was spent with the model still asking for tools.
326
+
327
+ ### retry
328
+
329
+ Everything about a request failing that is not about what the request said.
330
+
331
+ - `backoffMs` — How long to wait before a retry: exponential, with jitter so several tasks failing at once do not return in lockstep.
332
+ - `ContextOverflow` — The request was bigger than the model will read.
333
+ - `EndpointSilent` — The endpoint stopped answering mid-request.
334
+ - `isModelLoading` — Whether a failure is a local server still loading the model, rather than one failing to serve.
335
+ - `isOverflow` — Whether a refusal means the request was too big, rather than merely refused.
336
+ - `isTransient` — Whether a failed request is worth trying again.
337
+ - `SMALLEST_LIKELY_WINDOW` — The smallest window worth believing in, and the floor under `runTurn`'s guard.
338
+
312
339
  ### stream
313
340
 
314
341
  Reading one streamed turn back into a message.
@@ -362,28 +389,6 @@ Reading what a model meant by a tool call when it did not write one cleanly.
362
389
  - `ToolCallRequest` (type) — One call the model made, as `dispatch` and `onToolCall` are handed it.
363
390
  - `ToolCallResult` (type) — One call's whole answer, as `onToolResult` is handed it.
364
391
 
365
- ### tool-loading
366
-
367
- - `CALL_TOOL` — The one tool a proxied run reaches every catalogued tool through.
368
- - `carryOver` — The tools to start the next turn with: last turn's where they were, then what this turn used.
369
- - `catalogList` — The catalogue as a plain grouped listing of names, loaded ones marked if asked.
370
- - `catalogPrompt` — The catalogue block appended to the system prompt.
371
- - `expandNames` — Resolves requested names against the catalogue, expanding trailing `*` wildcards.
372
- - `holdsDefinitions` — Whether a tool result is a proxied load carrying definitions, which is the only copy of them the model has.
373
- - `inCatalog` — Whether the catalogue holds a tool by this name.
374
- - `LOAD_TOOLS` — On-demand tool loading.
375
- - `LOAD_TOOLS_DEFINITION` — One object for the life of the process — the agent loop asks for it on every iteration.
376
- - `loadedTools` — A tool array with newly loaded definitions appended, in the order they were loaded.
377
- - `loadResult` — What `load_tools` reports back: the descriptions, now that they are worth their tokens.
378
- - `orderTools` — The tool array in a stable order, so the same set of tools renders the same way twice.
379
- - `PROXY_TOOLS` — The whole tool array of a proxied run, `load_tools` then `call_tool`, frozen because it is shared.
380
- - `proxiedCall` — The tool a `call_tool` names and the arguments to run it with, or a throw the model can read.
381
- - `proxyCatalogPrompt` — The catalogue block for a proxied run's system prompt, worded for `call_tool` rather than for a tool list.
382
- - `proxyLoadResult` — What a proxied `load_tools` answers: each new tool's whole definition as a line of JSON, since the result is the only place the model will ever see it.
383
- - `requestedNames` — `load_tools` arguments, defensively — a model may send a bare string or a nested object.
384
- - `shownCall` — A tool call as a watcher should see it: a `call_tool` as the tool it ran, anything else as it is.
385
- - `ToolOrder` (type) — How a tool array is ordered before it is sent: `true` by name, `false` as the caller built it, or a comparator over the two names.
386
-
387
392
  ### wire
388
393
 
389
394
  The words the chat-completions wire is written in, each under a name.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubicecho/agent-core",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "The endpoint-agnostic half of an OpenAI-compatible agent loop: tool-schema compatibility, on-demand tool loading, one-shot side tasks, run events, and a pooled client.",
5
5
  "keywords": [
6
6
  "openai",
@@ -33,8 +33,8 @@
33
33
  "import": "./dist/index.js"
34
34
  },
35
35
  "./spec": {
36
- "types": "./dist/spec.d.ts",
37
- "import": "./dist/spec.js"
36
+ "types": "./dist/spec/spec.d.ts",
37
+ "import": "./dist/spec/spec.js"
38
38
  }
39
39
  },
40
40
  "files": [
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes