@cubicecho/agent-core 3.0.0 → 4.1.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 +34 -3
- package/dist/{compaction.d.ts → context/compaction.d.ts} +6 -6
- package/dist/{compaction.js → context/compaction.js} +9 -9
- package/dist/{ledger.d.ts → context/ledger.d.ts} +2 -2
- package/dist/{ledger.js → context/ledger.js} +3 -3
- package/dist/{guards.d.ts → core/guards.d.ts} +2 -3
- package/dist/{guards.js → core/guards.js} +1 -2
- package/dist/{scope.d.ts → core/scope.d.ts} +3 -3
- package/dist/{calibration.js → endpoint/calibration.js} +4 -4
- package/dist/{capabilities.d.ts → endpoint/capabilities.d.ts} +2 -2
- package/dist/{capabilities.js → endpoint/capabilities.js} +3 -3
- package/dist/{client.d.ts → endpoint/client.d.ts} +27 -11
- package/dist/{client.js → endpoint/client.js} +85 -26
- package/dist/{schema-compat.js → endpoint/schema-compat.js} +2 -2
- package/dist/{hooks.js → hooks/hooks.js} +6 -6
- package/dist/index.d.ts +30 -30
- package/dist/index.js +29 -29
- package/dist/{agent-loop.d.ts → run/agent-loop.d.ts} +25 -16
- package/dist/{agent-loop.js → run/agent-loop.js} +34 -25
- package/dist/{events.d.ts → run/events.d.ts} +3 -3
- package/dist/{events.js → run/events.js} +6 -6
- package/dist/{request-body.d.ts → run/request-body.d.ts} +3 -3
- package/dist/{request-body.js → run/request-body.js} +4 -4
- package/dist/{run-calls.d.ts → run/run-calls.d.ts} +3 -3
- package/dist/{run-calls.js → run/run-calls.js} +4 -4
- package/dist/{reset.js → runtime/reset.js} +6 -6
- package/dist/{runtime.d.ts → runtime/runtime.d.ts} +11 -11
- package/dist/{runtime.js → runtime/runtime.js} +12 -12
- package/dist/{snapshot.js → runtime/snapshot.js} +4 -4
- package/dist/{spec.d.ts → spec/spec.d.ts} +2 -2
- package/dist/{spec.js → spec/spec.js} +3 -3
- package/dist/{preselect.d.ts → tools/preselect.d.ts} +5 -4
- package/dist/{preselect.js → tools/preselect.js} +6 -5
- package/dist/{tool-loading.js → tools/tool-loading.js} +3 -3
- package/dist/{continuation.d.ts → turn/continuation.d.ts} +4 -4
- package/dist/{continuation.js → turn/continuation.js} +7 -7
- package/dist/{run-turn.d.ts → turn/run-turn.d.ts} +2 -2
- package/dist/{run-turn.js → turn/run-turn.js} +7 -7
- package/dist/{side-task.d.ts → turn/side-task.d.ts} +2 -2
- package/dist/{side-task.js → turn/side-task.js} +9 -9
- package/dist/{errors.d.ts → wire/errors.d.ts} +4 -0
- package/dist/{errors.js → wire/errors.js} +4 -0
- package/dist/{retry.d.ts → wire/retry.d.ts} +1 -1
- package/dist/{retry.js → wire/retry.js} +2 -2
- package/dist/{stream.js → wire/stream.js} +1 -1
- package/dist/{tokens.d.ts → wire/tokens.d.ts} +2 -2
- package/dist/{tokens.js → wire/tokens.js} +2 -2
- package/dist/{tool-calls.js → wire/tool-calls.js} +1 -1
- package/llms.txt +177 -179
- package/package.json +3 -3
- /package/dist/{config.d.ts → core/config.d.ts} +0 -0
- /package/dist/{config.js → core/config.js} +0 -0
- /package/dist/{digest.d.ts → core/digest.d.ts} +0 -0
- /package/dist/{digest.js → core/digest.js} +0 -0
- /package/dist/{platform.d.ts → core/platform.d.ts} +0 -0
- /package/dist/{platform.js → core/platform.js} +0 -0
- /package/dist/{scope.js → core/scope.js} +0 -0
- /package/dist/{calibration.d.ts → endpoint/calibration.d.ts} +0 -0
- /package/dist/{schema-compat.d.ts → endpoint/schema-compat.d.ts} +0 -0
- /package/dist/{hook-events.d.ts → hooks/hook-events.d.ts} +0 -0
- /package/dist/{hook-events.js → hooks/hook-events.js} +0 -0
- /package/dist/{hooks.d.ts → hooks/hooks.d.ts} +0 -0
- /package/dist/{reset.d.ts → runtime/reset.d.ts} +0 -0
- /package/dist/{snapshot.d.ts → runtime/snapshot.d.ts} +0 -0
- /package/dist/{catalog.d.ts → tools/catalog.d.ts} +0 -0
- /package/dist/{catalog.js → tools/catalog.js} +0 -0
- /package/dist/{tool-loading.d.ts → tools/tool-loading.d.ts} +0 -0
- /package/dist/{stream.d.ts → wire/stream.d.ts} +0 -0
- /package/dist/{thinking.d.ts → wire/thinking.d.ts} +0 -0
- /package/dist/{thinking.js → wire/thinking.js} +0 -0
- /package/dist/{tool-calls.d.ts → wire/tool-calls.d.ts} +0 -0
- /package/dist/{wire.d.ts → wire/wire.d.ts} +0 -0
- /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
|
-
###
|
|
12
|
+
### compaction
|
|
13
13
|
|
|
14
|
-
|
|
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
|
-
- `
|
|
17
|
-
- `
|
|
18
|
-
- `
|
|
19
|
-
- `
|
|
20
|
-
- `
|
|
21
|
-
- `
|
|
22
|
-
- `
|
|
23
|
-
- `
|
|
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,77 +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
|
-
###
|
|
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
|
-
- `summaryInput` — What the summariser is handed for a plan: the earlier summary if there was one, then each message as its role and at most 4000 characters of its text.
|
|
94
|
-
|
|
95
|
-
### config
|
|
96
|
-
|
|
97
|
-
What this package needs to know about a caller's configuration.
|
|
98
|
-
|
|
99
|
-
- `AgentConfig` (type) — A whole agent configuration — every part, plus the two fields that belong to no group.
|
|
100
|
-
- `Endpoint` (type) — Where to send a request and how long to wait.
|
|
101
|
-
- `ModelParams` (type) — What to ask the model for.
|
|
102
|
-
- `RetryPolicy` (type) — How many times a lost or refused request is worth sending again.
|
|
103
|
-
- `ToolDiscovery` — Any one of the modes in `ToolDiscovery`.
|
|
104
|
-
- `ToolPolicy` (type) — How tools reach the model, and how long it may keep calling them.
|
|
105
|
-
|
|
106
|
-
### continuation
|
|
107
|
-
|
|
108
|
-
Picking up an answer the token ceiling cut off, instead of keeping half of it.
|
|
109
|
-
|
|
110
|
-
- `ContinueTurnOptions` (type) — What `continueTurn` takes besides what `runTurn` does.
|
|
111
|
-
- `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.
|
|
112
|
-
- `isContinuable` — Whether a turn is one a continuation can finish: cut off at the ceiling, with an answer begun and no tool call in it.
|
|
113
|
-
|
|
114
|
-
### errors
|
|
115
|
-
|
|
116
|
-
- `AgentLoopError` — What `runAgentLoop` throws, carrying the run as it stood and what was caught as `cause`.
|
|
117
|
-
- `AgentLoopFailure` (type) — A run as it stood when `runAgentLoop` gave up on it.
|
|
118
|
-
- `AgentLoopOverflow` — A `ContextOverflow` out of `runAgentLoop`, carrying the run as it stood.
|
|
119
|
-
- `errorMessage` — What went wrong, as a string.
|
|
120
|
-
- `failedRun` — The run a failed `runAgentLoop` left behind, read off whatever it threw, or nothing.
|
|
121
|
-
- `ToolIterationLimit` — `maxToolIterations` was spent with the model still asking for tools.
|
|
122
|
-
|
|
123
|
-
### events
|
|
100
|
+
### schema-compat
|
|
124
101
|
|
|
125
|
-
|
|
102
|
+
JSON Schema compatibility for llama.cpp-backed servers.
|
|
126
103
|
|
|
127
|
-
- `
|
|
128
|
-
- `
|
|
129
|
-
- `
|
|
130
|
-
- `
|
|
131
|
-
- `
|
|
132
|
-
- `history` — The backlog alone, for a caller that wants a snapshot rather than a subscription.
|
|
133
|
-
- `RunEvent` (type) — One thing that happened in a run, as a watcher receives it.
|
|
134
|
-
- `RunEventInput` (type) — What `emit` is given: the run and the sequence are the bus's to assign.
|
|
135
|
-
- `RunEventKind` — Any one of the kinds in `RunEventKind`.
|
|
136
|
-
- `RunMetrics` (type) — A run summed and derived from its events: what it cost, where the time went, and why.
|
|
137
|
-
- `RunMetricsOptions` (type) — What `runMetrics` takes besides the events.
|
|
138
|
-
- `RunOutcome` — Any one of the outcomes in `RunOutcome`.
|
|
139
|
-
- `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.
|
|
140
|
-
- `resetEvents` — Test seam: forget every run, so one test's events cannot be read by the next.
|
|
141
|
-
- `runMetrics` — A run's totals, timings and cache findings, derived from the events it emitted.
|
|
142
|
-
- `TurnReport` (type) — One turn's usage and measurements as a `usage` event carries them.
|
|
143
|
-
- `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.
|
|
144
109
|
|
|
145
110
|
### hook-events
|
|
146
111
|
|
|
@@ -175,67 +140,55 @@ Lifecycle hooks, from the host's side: what a session looks like to them, where
|
|
|
175
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.
|
|
176
141
|
- `withContext` — The request, with the hooks' context added to this turn's question.
|
|
177
142
|
|
|
178
|
-
###
|
|
143
|
+
### agent-loop
|
|
179
144
|
|
|
180
|
-
|
|
145
|
+
The loop above a turn: send, run the tools the model asked for, send again, until it stops asking.
|
|
181
146
|
|
|
182
|
-
- `
|
|
183
|
-
- `
|
|
184
|
-
- `
|
|
185
|
-
- `
|
|
186
|
-
- `
|
|
187
|
-
- `
|
|
188
|
-
- `
|
|
189
|
-
- `
|
|
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.
|
|
190
156
|
|
|
191
|
-
###
|
|
157
|
+
### events
|
|
192
158
|
|
|
193
|
-
|
|
159
|
+
What a run is doing, while it is doing it.
|
|
194
160
|
|
|
195
|
-
- `
|
|
196
|
-
- `
|
|
197
|
-
- `
|
|
198
|
-
- `
|
|
199
|
-
- `
|
|
200
|
-
- `
|
|
201
|
-
- `
|
|
202
|
-
- `
|
|
203
|
-
- `
|
|
204
|
-
- `
|
|
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.
|
|
205
178
|
|
|
206
179
|
### request-body
|
|
207
180
|
|
|
208
181
|
- `buildBody` — The one place a streamed request's body is decided from a config and what the endpoint and the model have refused.
|
|
209
182
|
|
|
210
|
-
### reset
|
|
211
|
-
|
|
212
|
-
- `resetAll` — Forgets everything this package remembers between calls.
|
|
213
|
-
|
|
214
|
-
### retry
|
|
215
|
-
|
|
216
|
-
Everything about a request failing that is not about what the request said.
|
|
217
|
-
|
|
218
|
-
- `backoffMs` — How long to wait before a retry: exponential, with jitter so several tasks failing at once do not return in lockstep.
|
|
219
|
-
- `ContextOverflow` — The request was bigger than the model will read.
|
|
220
|
-
- `EndpointSilent` — The endpoint stopped answering mid-request.
|
|
221
|
-
- `isModelLoading` — Whether a failure is a local server still loading the model, rather than one failing to serve.
|
|
222
|
-
- `isOverflow` — Whether a refusal means the request was too big, rather than merely refused.
|
|
223
|
-
- `isTransient` — Whether a failed request is worth trying again.
|
|
224
|
-
- `SMALLEST_LIKELY_WINDOW` — The smallest window worth believing in, and the floor under `runTurn`'s guard.
|
|
225
|
-
- `sleep` — A delay an abort cuts short, rejecting rather than resolving early.
|
|
226
|
-
|
|
227
183
|
### run-calls
|
|
228
184
|
|
|
229
185
|
The tools between two turns: a step's calls read, run and written into the transcript.
|
|
230
186
|
|
|
231
187
|
- `preview` — A long tool argument or result cut to what a watcher needs, with the full length said.
|
|
232
188
|
|
|
233
|
-
###
|
|
234
|
-
|
|
235
|
-
One turn, given as many attempts as the caller allows.
|
|
189
|
+
### reset
|
|
236
190
|
|
|
237
|
-
- `
|
|
238
|
-
- `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.
|
|
239
192
|
|
|
240
193
|
### runtime
|
|
241
194
|
|
|
@@ -244,33 +197,6 @@ One turn, given as many attempts as the caller allows.
|
|
|
244
197
|
- `Runtime` (type) — One set of the package's caches, with the functions that use them as methods.
|
|
245
198
|
- `RuntimeOptions` (type) — What a runtime starts out configured with.
|
|
246
199
|
|
|
247
|
-
### schema-compat
|
|
248
|
-
|
|
249
|
-
JSON Schema compatibility for llama.cpp-backed servers.
|
|
250
|
-
|
|
251
|
-
- `isGrammarError` — Whether a failure looks like the server could not build a grammar from our tool schemas.
|
|
252
|
-
- `relaxSchema` — One schema without its `pattern` and `format` keywords, for a schema that is not a tool's.
|
|
253
|
-
- `relaxTools` — The tool array with every schema's `pattern` and `format` keywords gone — the shape a turn is retried with.
|
|
254
|
-
- `sanitizeSchema` — One JSON Schema as a strict server will accept it, for a schema that is not a tool's parameters.
|
|
255
|
-
- `sanitizeTools` — Tool definitions a strict server will accept, remembered per definition object.
|
|
256
|
-
|
|
257
|
-
### side-task
|
|
258
|
-
|
|
259
|
-
One-shot calls that support a run without being one: picking tools, naming a session, summarising a transcript, proposing follow-ups.
|
|
260
|
-
|
|
261
|
-
- `AskJsonOptions` (type) — What `askJson` takes besides a side task's options.
|
|
262
|
-
- `ask` — Runs a side task and returns the reply text, thinking stripped.
|
|
263
|
-
- `askJson` — A side task whose answer is JSON matching a schema, parsed.
|
|
264
|
-
- `clean` — Strips the quoting and list punctuation models decorate short answers with.
|
|
265
|
-
- `listLines` — A list-shaped reply, one item per line, cleaned of the bullets and quotes models decorate them with.
|
|
266
|
-
- `parseJson` — The first array or object in a model's reply, parsed, whatever prose or fence surrounds it.
|
|
267
|
-
- `resetHints` — Test seam, alongside `resetClients` and `resetAll`: forget which models refused the hints.
|
|
268
|
-
- `SideTask` (type) — One side task's own settings, as a resolved agent spec carries them under `tasks.<key>`.
|
|
269
|
-
- `SideTaskInput` (type) — The input a side task applies its instruction to: text, or the content parts a vision model reads.
|
|
270
|
-
- `SideTaskOptions` (type) — What a side task may be given.
|
|
271
|
-
- `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.
|
|
272
|
-
- `tryAsk` — Runs a side task and answers `undefined` where it fails, so the work it supports carries on.
|
|
273
|
-
|
|
274
200
|
### snapshot
|
|
275
201
|
|
|
276
202
|
What endpoints and models refused, carried across a restart.
|
|
@@ -312,6 +238,101 @@ A JSON document that defines an agent, and the rules for reading one.
|
|
|
312
238
|
- `TaskSpec` (type) — One side task, which may run on a different model — and a different machine — than the agent.
|
|
313
239
|
- `ToolsSpec` (type) — How tools reach the model, and which servers this agent may reach at all.
|
|
314
240
|
|
|
241
|
+
### catalog
|
|
242
|
+
|
|
243
|
+
The contract between whatever holds the tools and the loop that offers them to a model.
|
|
244
|
+
|
|
245
|
+
- `CatalogServer` (type) — One server's tools, without their JSON schemas — the cheap half of a tool definition.
|
|
246
|
+
|
|
247
|
+
### preselect
|
|
248
|
+
|
|
249
|
+
Choosing a run's tools before it starts, from the request and the catalogue's names.
|
|
250
|
+
|
|
251
|
+
- `KeywordPreselection` (type) — What `preselectByKeywords` found.
|
|
252
|
+
- `KeywordPreselectOptions` (type) — What `preselectByKeywords` takes besides the catalogue and the request.
|
|
253
|
+
- `PRESELECT_SCHEMA` — The shape a preselector's answer is held to where the server takes a schema: `{ tools: [...] }`.
|
|
254
|
+
- `PRESELECT_SYSTEM` — The preselection system prompt at the default cap, for a caller that never changes it.
|
|
255
|
+
- `preselect` — The tools a request is likely to need, picked by a small model before the run starts, or none.
|
|
256
|
+
- `preselectByKeywords` — The tools a request's own words point at, ranked, and whether they point clearly enough.
|
|
257
|
+
- `preselectInput` — The user message for a preselection call: the catalogue, then the request.
|
|
258
|
+
- `preselection` — Resolves a preselection against the catalogue: unknown names dropped, count capped.
|
|
259
|
+
- `preselectSystem` — The system prompt a preselector is given, holding it to the cap its answer will be held to.
|
|
260
|
+
- `ToolMatch` (type) — One tool's score against a request.
|
|
261
|
+
|
|
262
|
+
### tool-loading
|
|
263
|
+
|
|
264
|
+
- `CALL_TOOL` — The one tool a proxied run reaches every catalogued tool through.
|
|
265
|
+
- `carryOver` — The tools to start the next turn with: last turn's where they were, then what this turn used.
|
|
266
|
+
- `catalogList` — The catalogue as a plain grouped listing of names, loaded ones marked if asked.
|
|
267
|
+
- `catalogPrompt` — The catalogue block appended to the system prompt.
|
|
268
|
+
- `expandNames` — Resolves requested names against the catalogue, expanding trailing `*` wildcards.
|
|
269
|
+
- `holdsDefinitions` — Whether a tool result is a proxied load carrying definitions, which is the only copy of them the model has.
|
|
270
|
+
- `inCatalog` — Whether the catalogue holds a tool by this name.
|
|
271
|
+
- `LOAD_TOOLS` — On-demand tool loading.
|
|
272
|
+
- `LOAD_TOOLS_DEFINITION` — One object for the life of the process — the agent loop asks for it on every iteration.
|
|
273
|
+
- `loadedTools` — A tool array with newly loaded definitions appended, in the order they were loaded.
|
|
274
|
+
- `loadResult` — What `load_tools` reports back: the descriptions, now that they are worth their tokens.
|
|
275
|
+
- `orderTools` — The tool array in a stable order, so the same set of tools renders the same way twice.
|
|
276
|
+
- `PROXY_TOOLS` — The whole tool array of a proxied run, `load_tools` then `call_tool`, frozen because it is shared.
|
|
277
|
+
- `proxiedCall` — The tool a `call_tool` names and the arguments to run it with, or a throw the model can read.
|
|
278
|
+
- `proxyCatalogPrompt` — The catalogue block for a proxied run's system prompt, worded for `call_tool` rather than for a tool list.
|
|
279
|
+
- `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.
|
|
280
|
+
- `requestedNames` — `load_tools` arguments, defensively — a model may send a bare string or a nested object.
|
|
281
|
+
- `shownCall` — A tool call as a watcher should see it: a `call_tool` as the tool it ran, anything else as it is.
|
|
282
|
+
- `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.
|
|
283
|
+
|
|
284
|
+
### continuation
|
|
285
|
+
|
|
286
|
+
Picking up an answer the token ceiling cut off, instead of keeping half of it.
|
|
287
|
+
|
|
288
|
+
- `ContinueTurnOptions` (type) — What `continueTurn` takes besides what `runTurn` does.
|
|
289
|
+
- `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.
|
|
290
|
+
|
|
291
|
+
### run-turn
|
|
292
|
+
|
|
293
|
+
One turn, given as many attempts as the caller allows.
|
|
294
|
+
|
|
295
|
+
- `RunTurnOptions` (type) — A retry is not the same event as a downgrade, but a watcher wants to be told about both.
|
|
296
|
+
- `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.
|
|
297
|
+
|
|
298
|
+
### side-task
|
|
299
|
+
|
|
300
|
+
One-shot calls that support a run without being one: picking tools, naming a session, summarising a transcript, proposing follow-ups.
|
|
301
|
+
|
|
302
|
+
- `AskJsonOptions` (type) — What `askJson` takes besides a side task's options.
|
|
303
|
+
- `ask` — Runs a side task and returns the reply text, thinking stripped.
|
|
304
|
+
- `askJson` — A side task whose answer is JSON matching a schema, parsed.
|
|
305
|
+
- `clean` — Strips the quoting and list punctuation models decorate short answers with.
|
|
306
|
+
- `listLines` — A list-shaped reply, one item per line, cleaned of the bullets and quotes models decorate them with.
|
|
307
|
+
- `parseJson` — The first array or object in a model's reply, parsed, whatever prose or fence surrounds it.
|
|
308
|
+
- `resetHints` — Test seam, alongside `resetClients` and `resetAll`: forget which models refused the hints.
|
|
309
|
+
- `SideTask` (type) — One side task's own settings, as a resolved agent spec carries them under `tasks.<key>`.
|
|
310
|
+
- `SideTaskInput` (type) — The input a side task applies its instruction to: text, or the content parts a vision model reads.
|
|
311
|
+
- `SideTaskOptions` (type) — What a side task may be given.
|
|
312
|
+
- `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.
|
|
313
|
+
- `tryAsk` — Runs a side task and answers `undefined` where it fails, so the work it supports carries on.
|
|
314
|
+
|
|
315
|
+
### errors
|
|
316
|
+
|
|
317
|
+
- `AgentLoopError` — What `runAgentLoop` throws, carrying the run as it stood and what was caught as `cause`.
|
|
318
|
+
- `AgentLoopFailure` (type) — A run as it stood when `runAgentLoop` gave up on it.
|
|
319
|
+
- `AgentLoopOverflow` — A `ContextOverflow` out of `runAgentLoop`, carrying the run as it stood.
|
|
320
|
+
- `errorMessage` — What went wrong, as a string.
|
|
321
|
+
- `failedRun` — The run a failed `runAgentLoop` left behind, read off whatever it threw, or nothing.
|
|
322
|
+
- `ToolIterationLimit` — `maxToolIterations` was spent with the model still asking for tools.
|
|
323
|
+
|
|
324
|
+
### retry
|
|
325
|
+
|
|
326
|
+
Everything about a request failing that is not about what the request said.
|
|
327
|
+
|
|
328
|
+
- `backoffMs` — How long to wait before a retry: exponential, with jitter so several tasks failing at once do not return in lockstep.
|
|
329
|
+
- `ContextOverflow` — The request was bigger than the model will read.
|
|
330
|
+
- `EndpointSilent` — The endpoint stopped answering mid-request.
|
|
331
|
+
- `isModelLoading` — Whether a failure is a local server still loading the model, rather than one failing to serve.
|
|
332
|
+
- `isOverflow` — Whether a refusal means the request was too big, rather than merely refused.
|
|
333
|
+
- `isTransient` — Whether a failed request is worth trying again.
|
|
334
|
+
- `SMALLEST_LIKELY_WINDOW` — The smallest window worth believing in, and the floor under `runTurn`'s guard.
|
|
335
|
+
|
|
315
336
|
### stream
|
|
316
337
|
|
|
317
338
|
Reading one streamed turn back into a message.
|
|
@@ -350,7 +371,6 @@ Telling a model's scratchpad from its answer when both arrive in `content`.
|
|
|
350
371
|
- `requestChars` — How many characters a request is worth: the walk `requestTokens` divides, without the division.
|
|
351
372
|
- `requestTokens` — What this request will cost the window, in tokens, near enough.
|
|
352
373
|
- `TokenEstimateOptions` (type) — What the two token estimates below take besides what they measure.
|
|
353
|
-
- `toolsChars` — How many characters a tool array is worth, measured once per array.
|
|
354
374
|
|
|
355
375
|
### tool-calls
|
|
356
376
|
|
|
@@ -366,28 +386,6 @@ Reading what a model meant by a tool call when it did not write one cleanly.
|
|
|
366
386
|
- `ToolCallRequest` (type) — One call the model made, as `dispatch` and `onToolCall` are handed it.
|
|
367
387
|
- `ToolCallResult` (type) — One call's whole answer, as `onToolResult` is handed it.
|
|
368
388
|
|
|
369
|
-
### tool-loading
|
|
370
|
-
|
|
371
|
-
- `CALL_TOOL` — The one tool a proxied run reaches every catalogued tool through.
|
|
372
|
-
- `carryOver` — The tools to start the next turn with: last turn's where they were, then what this turn used.
|
|
373
|
-
- `catalogList` — The catalogue as a plain grouped listing of names, loaded ones marked if asked.
|
|
374
|
-
- `catalogPrompt` — The catalogue block appended to the system prompt.
|
|
375
|
-
- `expandNames` — Resolves requested names against the catalogue, expanding trailing `*` wildcards.
|
|
376
|
-
- `holdsDefinitions` — Whether a tool result is a proxied load carrying definitions, which is the only copy of them the model has.
|
|
377
|
-
- `inCatalog` — Whether the catalogue holds a tool by this name.
|
|
378
|
-
- `LOAD_TOOLS` — On-demand tool loading.
|
|
379
|
-
- `LOAD_TOOLS_DEFINITION` — One object for the life of the process — the agent loop asks for it on every iteration.
|
|
380
|
-
- `loadedTools` — A tool array with newly loaded definitions appended, in the order they were loaded.
|
|
381
|
-
- `loadResult` — What `load_tools` reports back: the descriptions, now that they are worth their tokens.
|
|
382
|
-
- `orderTools` — The tool array in a stable order, so the same set of tools renders the same way twice.
|
|
383
|
-
- `PROXY_TOOLS` — The whole tool array of a proxied run, `load_tools` then `call_tool`, frozen because it is shared.
|
|
384
|
-
- `proxiedCall` — The tool a `call_tool` names and the arguments to run it with, or a throw the model can read.
|
|
385
|
-
- `proxyCatalogPrompt` — The catalogue block for a proxied run's system prompt, worded for `call_tool` rather than for a tool list.
|
|
386
|
-
- `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.
|
|
387
|
-
- `requestedNames` — `load_tools` arguments, defensively — a model may send a bare string or a nested object.
|
|
388
|
-
- `shownCall` — A tool call as a watcher should see it: a `call_tool` as the tool it ran, anything else as it is.
|
|
389
|
-
- `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.
|
|
390
|
-
|
|
391
389
|
### wire
|
|
392
390
|
|
|
393
391
|
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": "
|
|
3
|
+
"version": "4.1.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
|