@cubicecho/agent-core 2.24.0 → 2.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -7
- package/dist/agent-loop.d.ts +84 -205
- package/dist/agent-loop.js +288 -597
- package/dist/calibration.d.ts +14 -10
- package/dist/calibration.js +30 -23
- package/dist/capabilities.d.ts +111 -42
- package/dist/capabilities.js +281 -138
- package/dist/client.d.ts +104 -35
- package/dist/client.js +205 -74
- package/dist/compaction.d.ts +103 -60
- package/dist/compaction.js +160 -86
- package/dist/config.d.ts +48 -12
- package/dist/config.js +20 -1
- package/dist/continuation.d.ts +24 -16
- package/dist/continuation.js +70 -44
- package/dist/digest.d.ts +7 -0
- package/dist/digest.js +18 -0
- package/dist/errors.d.ts +24 -15
- package/dist/errors.js +23 -15
- package/dist/events.d.ts +100 -63
- package/dist/events.js +250 -120
- package/dist/guards.d.ts +49 -4
- package/dist/guards.js +60 -5
- package/dist/hook-events.d.ts +21 -5
- package/dist/hook-events.js +23 -9
- package/dist/hooks.d.ts +96 -73
- package/dist/hooks.js +202 -116
- package/dist/index.d.ts +30 -26
- package/dist/index.js +29 -24
- package/dist/ledger.d.ts +62 -30
- package/dist/ledger.js +163 -56
- package/dist/platform.d.ts +15 -0
- package/dist/platform.js +15 -0
- package/dist/preselect.d.ts +223 -0
- package/dist/preselect.js +291 -0
- package/dist/request-body.d.ts +32 -0
- package/dist/request-body.js +47 -0
- package/dist/reset.d.ts +1 -0
- package/dist/reset.js +7 -6
- package/dist/retry.d.ts +44 -138
- package/dist/retry.js +83 -281
- package/dist/run-calls.d.ts +123 -0
- package/dist/run-calls.js +351 -0
- package/dist/run-turn.d.ts +36 -15
- package/dist/run-turn.js +74 -37
- package/dist/runtime.d.ts +23 -17
- package/dist/runtime.js +34 -24
- package/dist/schema-compat.d.ts +35 -18
- package/dist/schema-compat.js +346 -176
- package/dist/scope.d.ts +28 -5
- package/dist/scope.js +37 -10
- package/dist/side-task.d.ts +124 -40
- package/dist/side-task.js +186 -66
- package/dist/snapshot.d.ts +10 -5
- package/dist/snapshot.js +73 -30
- package/dist/spec.d.ts +56 -25
- package/dist/spec.js +494 -215
- package/dist/stream.d.ts +66 -16
- package/dist/stream.js +220 -97
- package/dist/thinking.d.ts +23 -8
- package/dist/thinking.js +92 -44
- package/dist/tokens.d.ts +164 -6
- package/dist/tokens.js +319 -6
- package/dist/tool-calls.d.ts +90 -17
- package/dist/tool-calls.js +207 -84
- package/dist/tool-loading.d.ts +101 -189
- package/dist/tool-loading.js +257 -371
- package/dist/wire.d.ts +81 -0
- package/dist/wire.js +73 -0
- package/llms.txt +76 -39
- package/package.json +4 -4
package/dist/wire.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words the chat-completions wire is written in, each under a name.
|
|
3
|
+
*
|
|
4
|
+
* A leaf with no imports, because every module that builds a message or reads one needs these and
|
|
5
|
+
* they share nothing else. The `openai` types still say which word a field takes — these are the
|
|
6
|
+
* same literals, so a message built from them is checked exactly as one built from strings — and
|
|
7
|
+
* what the names add is that a role or a finish reason is spelled in one place.
|
|
8
|
+
*/
|
|
9
|
+
/** Who a message is from. */
|
|
10
|
+
export declare const Role: {
|
|
11
|
+
/** The instructions a conversation opens with. */
|
|
12
|
+
readonly System: 'system';
|
|
13
|
+
/** What a reasoning model takes in place of `system`. */
|
|
14
|
+
readonly Developer: 'developer';
|
|
15
|
+
/** The person, or whatever stands in for one. */
|
|
16
|
+
readonly User: 'user';
|
|
17
|
+
/** The model. */
|
|
18
|
+
readonly Assistant: 'assistant';
|
|
19
|
+
/** A tool's result, answering the call whose id it carries. */
|
|
20
|
+
readonly Tool: 'tool';
|
|
21
|
+
};
|
|
22
|
+
/** Any one of the roles in `Role`. */
|
|
23
|
+
export type Role = (typeof Role)[keyof typeof Role];
|
|
24
|
+
/** Why a model stopped writing. */
|
|
25
|
+
export declare const FinishReason: {
|
|
26
|
+
/** It was done. */
|
|
27
|
+
readonly Stop: 'stop';
|
|
28
|
+
/** It ran into the reply ceiling, and what it wrote is cut off. */
|
|
29
|
+
readonly Length: 'length';
|
|
30
|
+
/** It asked for tools. */
|
|
31
|
+
readonly ToolCalls: 'tool_calls';
|
|
32
|
+
/** A filter withheld the reply. */
|
|
33
|
+
readonly ContentFilter: 'content_filter';
|
|
34
|
+
};
|
|
35
|
+
/** Any one of the reasons in `FinishReason`. */
|
|
36
|
+
export type FinishReason = (typeof FinishReason)[keyof typeof FinishReason];
|
|
37
|
+
/** What a part of a message's content is. */
|
|
38
|
+
export declare const PartType: {
|
|
39
|
+
/** Text. */
|
|
40
|
+
readonly Text: 'text';
|
|
41
|
+
/** The model declining, in place of an answer. */
|
|
42
|
+
readonly Refusal: 'refusal';
|
|
43
|
+
/** An image, by URL or inline. */
|
|
44
|
+
readonly ImageUrl: 'image_url';
|
|
45
|
+
/** An attached file. */
|
|
46
|
+
readonly File: 'file';
|
|
47
|
+
};
|
|
48
|
+
/** Any one of the part types in `PartType`. */
|
|
49
|
+
export type PartType = (typeof PartType)[keyof typeof PartType];
|
|
50
|
+
/** The types JSON Schema has, as the `type` keyword spells them. */
|
|
51
|
+
export declare const SchemaType: {
|
|
52
|
+
readonly Object: 'object';
|
|
53
|
+
readonly Array: 'array';
|
|
54
|
+
readonly String: 'string';
|
|
55
|
+
readonly Number: 'number';
|
|
56
|
+
readonly Integer: 'integer';
|
|
57
|
+
readonly Boolean: 'boolean';
|
|
58
|
+
readonly Null: 'null';
|
|
59
|
+
};
|
|
60
|
+
/** Any one of the types in `SchemaType`. */
|
|
61
|
+
export type SchemaType = (typeof SchemaType)[keyof typeof SchemaType];
|
|
62
|
+
/** The one `type` a tool definition or a tool call has on this wire. */
|
|
63
|
+
export declare const FUNCTION_TOOL: 'function';
|
|
64
|
+
/** The `response_format` type that carries a schema the reply has to fit. */
|
|
65
|
+
export declare const JSON_SCHEMA_FORMAT: 'json_schema';
|
|
66
|
+
/** The HTTP statuses this package reads a meaning into. */
|
|
67
|
+
export declare const HttpStatus: {
|
|
68
|
+
readonly Ok: 200;
|
|
69
|
+
readonly BadRequest: 400;
|
|
70
|
+
readonly Unauthorized: 401;
|
|
71
|
+
readonly NotFound: 404;
|
|
72
|
+
readonly MethodNotAllowed: 405;
|
|
73
|
+
readonly RequestTimeout: 408;
|
|
74
|
+
readonly Conflict: 409;
|
|
75
|
+
readonly UnprocessableEntity: 422;
|
|
76
|
+
readonly TooManyRequests: 429;
|
|
77
|
+
/** The first of the 5xx range, and so the floor of "the server's fault". */
|
|
78
|
+
readonly InternalServerError: 500;
|
|
79
|
+
readonly NotImplemented: 501;
|
|
80
|
+
readonly ServiceUnavailable: 503;
|
|
81
|
+
};
|
package/dist/wire.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words the chat-completions wire is written in, each under a name.
|
|
3
|
+
*
|
|
4
|
+
* A leaf with no imports, because every module that builds a message or reads one needs these and
|
|
5
|
+
* they share nothing else. The `openai` types still say which word a field takes — these are the
|
|
6
|
+
* same literals, so a message built from them is checked exactly as one built from strings — and
|
|
7
|
+
* what the names add is that a role or a finish reason is spelled in one place.
|
|
8
|
+
*/
|
|
9
|
+
/** Who a message is from. */
|
|
10
|
+
export const Role = {
|
|
11
|
+
/** The instructions a conversation opens with. */
|
|
12
|
+
System: 'system',
|
|
13
|
+
/** What a reasoning model takes in place of `system`. */
|
|
14
|
+
Developer: 'developer',
|
|
15
|
+
/** The person, or whatever stands in for one. */
|
|
16
|
+
User: 'user',
|
|
17
|
+
/** The model. */
|
|
18
|
+
Assistant: 'assistant',
|
|
19
|
+
/** A tool's result, answering the call whose id it carries. */
|
|
20
|
+
Tool: 'tool',
|
|
21
|
+
};
|
|
22
|
+
/** Why a model stopped writing. */
|
|
23
|
+
export const FinishReason = {
|
|
24
|
+
/** It was done. */
|
|
25
|
+
Stop: 'stop',
|
|
26
|
+
/** It ran into the reply ceiling, and what it wrote is cut off. */
|
|
27
|
+
Length: 'length',
|
|
28
|
+
/** It asked for tools. */
|
|
29
|
+
ToolCalls: 'tool_calls',
|
|
30
|
+
/** A filter withheld the reply. */
|
|
31
|
+
ContentFilter: 'content_filter',
|
|
32
|
+
};
|
|
33
|
+
/** What a part of a message's content is. */
|
|
34
|
+
export const PartType = {
|
|
35
|
+
/** Text. */
|
|
36
|
+
Text: 'text',
|
|
37
|
+
/** The model declining, in place of an answer. */
|
|
38
|
+
Refusal: 'refusal',
|
|
39
|
+
/** An image, by URL or inline. */
|
|
40
|
+
ImageUrl: 'image_url',
|
|
41
|
+
/** An attached file. */
|
|
42
|
+
File: 'file',
|
|
43
|
+
};
|
|
44
|
+
/** The types JSON Schema has, as the `type` keyword spells them. */
|
|
45
|
+
export const SchemaType = {
|
|
46
|
+
Object: 'object',
|
|
47
|
+
Array: 'array',
|
|
48
|
+
String: 'string',
|
|
49
|
+
Number: 'number',
|
|
50
|
+
Integer: 'integer',
|
|
51
|
+
Boolean: 'boolean',
|
|
52
|
+
Null: 'null',
|
|
53
|
+
};
|
|
54
|
+
/** The one `type` a tool definition or a tool call has on this wire. */
|
|
55
|
+
export const FUNCTION_TOOL = 'function';
|
|
56
|
+
/** The `response_format` type that carries a schema the reply has to fit. */
|
|
57
|
+
export const JSON_SCHEMA_FORMAT = 'json_schema';
|
|
58
|
+
/** The HTTP statuses this package reads a meaning into. */
|
|
59
|
+
export const HttpStatus = {
|
|
60
|
+
Ok: 200,
|
|
61
|
+
BadRequest: 400,
|
|
62
|
+
Unauthorized: 401,
|
|
63
|
+
NotFound: 404,
|
|
64
|
+
MethodNotAllowed: 405,
|
|
65
|
+
RequestTimeout: 408,
|
|
66
|
+
Conflict: 409,
|
|
67
|
+
UnprocessableEntity: 422,
|
|
68
|
+
TooManyRequests: 429,
|
|
69
|
+
/** The first of the 5xx range, and so the floor of "the server's fault". */
|
|
70
|
+
InternalServerError: 500,
|
|
71
|
+
NotImplemented: 501,
|
|
72
|
+
ServiceUnavailable: 503,
|
|
73
|
+
};
|
package/llms.txt
CHANGED
|
@@ -17,16 +17,10 @@ The loop above a turn: send, run the tools the model asked for, send again, unti
|
|
|
17
17
|
- `AgentLoopOptions` (type) — What `runAgentLoop` takes.
|
|
18
18
|
- `AgentLoopRequest` (type) — One step's request as `onRequest` is handed it: what the model is about to read.
|
|
19
19
|
- `AgentLoopResult` (type) — What a finished loop hands back.
|
|
20
|
-
- `
|
|
21
|
-
- `
|
|
22
|
-
- `preview` — A long tool argument or result cut to what a watcher needs, with the full length said.
|
|
23
|
-
- `resolveApiKey` — The key to send, where an endpoint may inherit one from the settings it overrides.
|
|
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.
|
|
24
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.
|
|
25
23
|
- `StepWindow` (type) — How full the window is as a step is about to be sent, as `beforeStep` is told it.
|
|
26
|
-
- `ToolCallOutcome` (type) — What one tool call did, in the order the model asked.
|
|
27
|
-
- `ToolCallRequest` (type) — One call the model made, as `dispatch` and `onToolCall` are handed it.
|
|
28
|
-
- `ToolCallResult` (type) — One call's whole answer, as `onToolResult` is handed it.
|
|
29
|
-
- `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.
|
|
30
24
|
|
|
31
25
|
### calibration
|
|
32
26
|
|
|
@@ -43,6 +37,8 @@ What an endpoint turned out not to support, and answering it when it says so.
|
|
|
43
37
|
- `Capabilities` (type) — What one endpoint turned out not to support.
|
|
44
38
|
- `capabilitiesFor` — What this endpoint is known not to support.
|
|
45
39
|
- `EFFORT_LADDER` — The efforts this package can place, cheapest first.
|
|
40
|
+
- `EFFORT_NONE` — The lowest effort the wire has a word for, which is what a side task asks for.
|
|
41
|
+
- `EFFORT_OFF` — The setting that asks for no `reasoning_effort` field at all.
|
|
46
42
|
- `effortFor` — What to actually put in `reasoning_effort` for a model that has refused the value asked for.
|
|
47
43
|
- `expireCapabilities` — Forgets every endpoint whose entry is older than this, so the next request finds out again.
|
|
48
44
|
- `ModelCapabilities` (type) — What one model on that endpoint turned out not to support.
|
|
@@ -71,8 +67,9 @@ The contract between whatever holds the tools and the loop that offers them to a
|
|
|
71
67
|
- `ModelInfo` (type) — A model an endpoint offers, and what it says the model will read.
|
|
72
68
|
- `NO_KEY` — The SDK insists on a non-empty key even where the server will not look at it.
|
|
73
69
|
- `resetClients` — Forgets every cached client and listing, and puts `configureClients` back to the defaults.
|
|
70
|
+
- `resolveApiKey` — The key to send, where an endpoint may inherit one from the settings it overrides.
|
|
74
71
|
- `servedWindow` — The window a local server's own API says it is serving a model in, for the servers whose listing does not say.
|
|
75
|
-
- `timeoutMs` —
|
|
72
|
+
- `timeoutMs` — An endpoint's request timeout in the SDK's spelling: milliseconds, and `undefined` for no limit.
|
|
76
73
|
|
|
77
74
|
### compaction
|
|
78
75
|
|
|
@@ -104,6 +101,7 @@ What this package needs to know about a caller's configuration.
|
|
|
104
101
|
- `Endpoint` (type) — Where to send a request and how long to wait.
|
|
105
102
|
- `ModelParams` (type) — What to ask the model for.
|
|
106
103
|
- `RetryPolicy` (type) — How many times a lost or refused request is worth sending again.
|
|
104
|
+
- `ToolDiscovery` — Any one of the modes in `ToolDiscovery`.
|
|
107
105
|
- `ToolPolicy` (type) — How tools reach the model, and how long it may keep calling them.
|
|
108
106
|
|
|
109
107
|
### continuation
|
|
@@ -131,13 +129,14 @@ What a run is doing, while it is doing it.
|
|
|
131
129
|
- `EventBusOptions` (type) — What the bus keeps and for how long.
|
|
132
130
|
- `emit` — Records one event and hands it to everyone watching that run.
|
|
133
131
|
- `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.
|
|
134
|
-
- `fold` —
|
|
132
|
+
- `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.
|
|
135
133
|
- `history` — The backlog alone, for a caller that wants a snapshot rather than a subscription.
|
|
136
134
|
- `RunEvent` (type) — One thing that happened in a run, as a watcher receives it.
|
|
137
135
|
- `RunEventInput` (type) — What `emit` is given: the run and the sequence are the bus's to assign.
|
|
138
|
-
- `RunEventKind`
|
|
136
|
+
- `RunEventKind` — Any one of the kinds in `RunEventKind`.
|
|
139
137
|
- `RunMetrics` (type) — A run summed and derived from its events: what it cost, where the time went, and why.
|
|
140
138
|
- `RunMetricsOptions` (type) — What `runMetrics` takes besides the events.
|
|
139
|
+
- `RunOutcome` — Any one of the outcomes in `RunOutcome`.
|
|
141
140
|
- `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.
|
|
142
141
|
- `resetEvents` — Test seam: forget every run, so one test's events cannot be read by the next.
|
|
143
142
|
- `runMetrics` — A run's totals, timings and cache findings, derived from the events it emitted.
|
|
@@ -149,7 +148,7 @@ What a run is doing, while it is doing it.
|
|
|
149
148
|
The points in a session a hook can be bound to, apart from everything that runs one.
|
|
150
149
|
|
|
151
150
|
- `HOOK_EVENTS` — Every event a hook can be bound to, in the order a session meets them.
|
|
152
|
-
- `HookEvent`
|
|
151
|
+
- `HookEvent` — Any one of the events in `HookEvent`.
|
|
153
152
|
- `INJECT_EVENTS` — The events whose hooks run before a request, and so the only ones whose output can reach it.
|
|
154
153
|
|
|
155
154
|
### hooks
|
|
@@ -190,6 +189,27 @@ What stretches of a transcript cost, read off the prompt counts the server alrea
|
|
|
190
189
|
- `TokenLedger` (type) — A transcript's entries in the order their requests were sent, which is also by `through`.
|
|
191
190
|
- `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.
|
|
192
191
|
|
|
192
|
+
### preselect
|
|
193
|
+
|
|
194
|
+
Choosing a run's tools before it starts, from the request and the catalogue's names.
|
|
195
|
+
|
|
196
|
+
- `KEYWORD_DROPOFF` — How far the best unpicked tool must fall below the last picked one for the cut to count clean.
|
|
197
|
+
- `KEYWORD_MIN_SCORE` — The least a best match may score and still be acted on without a model.
|
|
198
|
+
- `KeywordPreselection` (type) — What `preselectByKeywords` found.
|
|
199
|
+
- `KeywordPreselectOptions` (type) — What `preselectByKeywords` takes besides the catalogue and the request.
|
|
200
|
+
- `PRESELECT_SCHEMA` — The shape a preselector's answer is held to where the server takes a schema: `{ tools: [...] }`.
|
|
201
|
+
- `PRESELECT_SYSTEM` — The preselection system prompt at the default cap, for a caller that never changes it.
|
|
202
|
+
- `preselect` — The tools a request is likely to need, picked by a small model before the run starts, or none.
|
|
203
|
+
- `preselectByKeywords` — The tools a request's own words point at, ranked, and whether they point clearly enough.
|
|
204
|
+
- `preselectInput` — The user message for a preselection call: the catalogue, then the request.
|
|
205
|
+
- `preselection` — Resolves a preselection against the catalogue: unknown names dropped, count capped.
|
|
206
|
+
- `preselectSystem` — The system prompt a preselector is given, holding it to the cap its answer will be held to.
|
|
207
|
+
- `ToolMatch` (type) — One tool's score against a request.
|
|
208
|
+
|
|
209
|
+
### request-body
|
|
210
|
+
|
|
211
|
+
- `buildBody` — The one place a streamed request's body is decided from a config and what the endpoint and the model have refused.
|
|
212
|
+
|
|
193
213
|
### reset
|
|
194
214
|
|
|
195
215
|
- `resetAll` — Forgets everything this package remembers between calls.
|
|
@@ -198,33 +218,29 @@ What stretches of a transcript cost, read off the prompt counts the server alrea
|
|
|
198
218
|
|
|
199
219
|
Everything about a request failing that is not about what the request said.
|
|
200
220
|
|
|
201
|
-
- `backoffMs` —
|
|
202
|
-
- `ContextBreakdown` (type) — What a request is made of, by the part of it a consumer can actually do something about.
|
|
203
|
-
- `ContextBreakdownOptions` (type) — What `contextTokens` takes besides the request.
|
|
221
|
+
- `backoffMs` — How long to wait before a retry: exponential, with jitter so several tasks failing at once do not return in lockstep.
|
|
204
222
|
- `ContextOverflow` — The request was bigger than the model will read.
|
|
205
|
-
- `compact` — 1234 → "1.2k".
|
|
206
|
-
- `contextChars` — What each part of a request is worth in characters, by the same walk `requestTokens` divides.
|
|
207
|
-
- `contextTokens` — What each part of a request costs the window, in tokens, adding up to the whole.
|
|
208
223
|
- `EndpointSilent` — The endpoint stopped answering mid-request.
|
|
209
224
|
- `isModelLoading` — Whether a failure is a local server still loading the model, rather than one failing to serve.
|
|
210
225
|
- `isOverflow` — Whether a refusal means the request was too big, rather than merely refused.
|
|
211
226
|
- `isTransient` — Whether a failed request is worth trying again.
|
|
212
227
|
- `LOADING_POLL_MS` — How long to wait between asking a loading server again.
|
|
213
228
|
- `LOADING_TIMEOUT_MS` — How long `runTurn` waits for a model to load unless told otherwise.
|
|
214
|
-
- `messageTokens` — One message's estimated tokens, by the same count `requestTokens` sums for a whole request.
|
|
215
|
-
- `requestChars` — How many characters a request is worth: the walk `requestTokens` divides, without the division.
|
|
216
|
-
- `requestTokens` — What this request will cost the window, in tokens, near enough.
|
|
217
229
|
- `SMALLEST_LIKELY_WINDOW` — The smallest window worth believing in, and the floor under `runTurn`'s guard.
|
|
218
230
|
- `sleep` — A delay an abort cuts short, rejecting rather than resolving early.
|
|
219
|
-
|
|
220
|
-
-
|
|
231
|
+
|
|
232
|
+
### run-calls
|
|
233
|
+
|
|
234
|
+
The tools between two turns: a step's calls read, run and written into the transcript.
|
|
235
|
+
|
|
236
|
+
- `preview` — A long tool argument or result cut to what a watcher needs, with the full length said.
|
|
221
237
|
|
|
222
238
|
### run-turn
|
|
223
239
|
|
|
224
240
|
One turn, given as many attempts as the caller allows.
|
|
225
241
|
|
|
226
242
|
- `RunTurnOptions` (type) — A retry is not the same event as a downgrade, but a watcher wants to be told about both.
|
|
227
|
-
- `runTurn` —
|
|
243
|
+
- `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.
|
|
228
244
|
|
|
229
245
|
### runtime
|
|
230
246
|
|
|
@@ -237,9 +253,9 @@ One turn, given as many attempts as the caller allows.
|
|
|
237
253
|
|
|
238
254
|
JSON Schema compatibility for llama.cpp-backed servers.
|
|
239
255
|
|
|
240
|
-
- `isGrammarError` —
|
|
256
|
+
- `isGrammarError` — Whether a failure looks like the server could not build a grammar from our tool schemas.
|
|
241
257
|
- `relaxSchema` — One schema without its `pattern` and `format` keywords, for a schema that is not a tool's.
|
|
242
|
-
- `relaxTools` — The
|
|
258
|
+
- `relaxTools` — The tool array with every schema's `pattern` and `format` keywords gone — the shape a turn is retried with.
|
|
243
259
|
- `sanitizeSchema` — One JSON Schema as a strict server will accept it, for a schema that is not a tool's parameters.
|
|
244
260
|
- `sanitizeTools` — Tool definitions a strict server will accept, remembered per definition object.
|
|
245
261
|
|
|
@@ -252,12 +268,13 @@ One-shot calls that support a run without being one: picking tools, naming a ses
|
|
|
252
268
|
- `askJson` — A side task whose answer is JSON matching a schema, parsed.
|
|
253
269
|
- `clean` — Strips the quoting and list punctuation models decorate short answers with.
|
|
254
270
|
- `listLines` — A list-shaped reply, one item per line, cleaned of the bullets and quotes models decorate them with.
|
|
255
|
-
- `parseJson` —
|
|
271
|
+
- `parseJson` — The first array or object in a model's reply, parsed, whatever prose or fence surrounds it.
|
|
256
272
|
- `resetHints` — Test seam, alongside `resetClients` and `resetAll`: forget which models refused the hints.
|
|
257
273
|
- `SideTask` (type) — One side task's own settings, as a resolved agent spec carries them under `tasks.<key>`.
|
|
258
274
|
- `SideTaskInput` (type) — The input a side task applies its instruction to: text, or the content parts a vision model reads.
|
|
259
275
|
- `SideTaskOptions` (type) — What a side task may be given.
|
|
260
|
-
- `
|
|
276
|
+
- `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.
|
|
277
|
+
- `tryAsk` — Runs a side task and answers `undefined` where it fails, so the work it supports carries on.
|
|
261
278
|
|
|
262
279
|
### snapshot
|
|
263
280
|
|
|
@@ -287,6 +304,8 @@ A JSON document that defines an agent, and the rules for reading one.
|
|
|
287
304
|
- `ParseSpecOptions` (type) — What `parseSpec` takes besides the document.
|
|
288
305
|
- `PromptPart` (type) — One layer of system prompt, named so a layer above can stack beside it or replace it.
|
|
289
306
|
- `parseSpec` — Reads a document, dropping what it cannot use and refusing only what it cannot identify.
|
|
307
|
+
- `REF_FILE` — The `ref.type` of a prompt part whose text is in a file.
|
|
308
|
+
- `REF_URL` — The `ref.type` of a prompt part whose text is behind a URL.
|
|
290
309
|
- `RESOLVED_DEFAULTS` — What a field falls back to when no layer said anything at all.
|
|
291
310
|
- `ResolvedAgent` (type) — What layered documents resolve to: the flat shape the loop already takes, plus the parts of an agent that are the host's to act on.
|
|
292
311
|
- `ResolvedTask` (type) — One side task, resolved: a model, and the endpoint it is reached through.
|
|
@@ -302,6 +321,7 @@ A JSON document that defines an agent, and the rules for reading one.
|
|
|
302
321
|
|
|
303
322
|
Reading one streamed turn back into a message.
|
|
304
323
|
|
|
324
|
+
- `CacheBreakReason` — Any one of the reasons in `CacheBreakReason`.
|
|
305
325
|
- `Produced` (type) — Whether the model has said anything a second attempt would say twice.
|
|
306
326
|
- `StreamTurnOptions` (type) — What `streamTurn` takes besides the request body.
|
|
307
327
|
- `streamTurn` — Runs one turn as a stream, reporting tokens as they arrive and assembling them back into a message.
|
|
@@ -317,6 +337,8 @@ Telling a model's scratchpad from its answer when both arrive in `content`.
|
|
|
317
337
|
- `Fence` (type) — One way a model marks off its scratchpad inside `content`.
|
|
318
338
|
- `FenceSplitter` — A state machine over a stream of `content` that routes fenced text to reasoning.
|
|
319
339
|
- `FenceSplitterOptions` (type) — What `FenceSplitter` takes besides its fences.
|
|
340
|
+
- `SPLIT_OUTPUT` — What a `Split` is called when it was not.
|
|
341
|
+
- `SPLIT_REASONING` — What a `Split` is called when it was inside a fence.
|
|
320
342
|
- `Split` (type) — A piece of `content`, said to be one or the other.
|
|
321
343
|
- `stripThinking` — What is left of a complete reply once every scratchpad is taken out of it.
|
|
322
344
|
- `THINK_FENCE` — DeepSeek, Qwen3, QwQ and most distills.
|
|
@@ -324,16 +346,31 @@ Telling a model's scratchpad from its answer when both arrive in `content`.
|
|
|
324
346
|
### tokens
|
|
325
347
|
|
|
326
348
|
- `CHARS_PER_TOKEN` — The characters one token is taken to be, where nothing has measured it.
|
|
349
|
+
- `ContextBreakdown` (type) — What a request is made of, by the part of it a consumer can actually do something about.
|
|
350
|
+
- `ContextBreakdownOptions` (type) — What `contextTokens` takes besides the request.
|
|
351
|
+
- `compact` — A token count as a message shows it: 1234 → "1.2k".
|
|
352
|
+
- `contextChars` — What each part of a request is worth in characters, by the same walk `requestTokens` divides.
|
|
353
|
+
- `contextTokens` — What each part of a request costs the window, in tokens, adding up to the whole.
|
|
327
354
|
- `estimateTokens` — Rough token count.
|
|
355
|
+
- `messageTokens` — One message's estimated tokens, by the same count `requestTokens` sums for a whole request.
|
|
356
|
+
- `requestChars` — How many characters a request is worth: the walk `requestTokens` divides, without the division.
|
|
357
|
+
- `requestTokens` — What this request will cost the window, in tokens, near enough.
|
|
358
|
+
- `TokenEstimateOptions` (type) — What the two token estimates below take besides what they measure.
|
|
359
|
+
- `toolsChars` — How many characters a tool array is worth, measured once per array.
|
|
328
360
|
|
|
329
361
|
### tool-calls
|
|
330
362
|
|
|
331
363
|
Reading what a model meant by a tool call when it did not write one cleanly.
|
|
332
364
|
|
|
365
|
+
- `ARGUMENTS_MALFORMED` — The `ToolArgumentsError` kind for a call the model wrote wrongly.
|
|
366
|
+
- `ARGUMENTS_TRUNCATED` — The `ToolArgumentsError` kind for a call cut off at the reply ceiling.
|
|
333
367
|
- `parseToolArguments` — A tool call's arguments as the object the tool is handed.
|
|
334
368
|
- `recoverToolCalls` — Tool calls a model wrote into its reply as text, taken out of it and made into calls.
|
|
335
369
|
- `ToolArgumentsError` — Tool arguments that could not be read as an object, with why.
|
|
336
370
|
- `ToolCall` (type) — A tool call as the loop handles it, recovered or streamed.
|
|
371
|
+
- `ToolCallOutcome` (type) — What one tool call did, in the order the model asked.
|
|
372
|
+
- `ToolCallRequest` (type) — One call the model made, as `dispatch` and `onToolCall` are handed it.
|
|
373
|
+
- `ToolCallResult` (type) — One call's whole answer, as `onToolResult` is handed it.
|
|
337
374
|
|
|
338
375
|
### tool-loading
|
|
339
376
|
|
|
@@ -344,10 +381,6 @@ Reading what a model meant by a tool call when it did not write one cleanly.
|
|
|
344
381
|
- `expandNames` — Resolves requested names against the catalogue, expanding trailing `*` wildcards.
|
|
345
382
|
- `holdsDefinitions` — Whether a tool result is a proxied load carrying definitions, which is the only copy of them the model has.
|
|
346
383
|
- `inCatalog` — Whether the catalogue holds a tool by this name.
|
|
347
|
-
- `KEYWORD_DROPOFF` — How far the best unpicked tool must fall below the last picked one for the cut to count clean.
|
|
348
|
-
- `KEYWORD_MIN_SCORE` — The least a best match may score and still be acted on without a model.
|
|
349
|
-
- `KeywordPreselection` (type) — What `preselectByKeywords` found.
|
|
350
|
-
- `KeywordPreselectOptions` (type) — What `preselectByKeywords` takes besides the catalogue and the request.
|
|
351
384
|
- `LOAD_TOOLS` — On-demand tool loading.
|
|
352
385
|
- `LOAD_TOOLS_DEFINITION` — One object for the life of the process — the agent loop asks for it on every iteration.
|
|
353
386
|
- `loadedTools` — A tool array with newly loaded definitions appended, in the order they were loaded.
|
|
@@ -355,17 +388,21 @@ Reading what a model meant by a tool call when it did not write one cleanly.
|
|
|
355
388
|
- `MAX_CARRIED` — The most a conversation carries between turns.
|
|
356
389
|
- `MAX_PER_LOAD` — The most a single `load_tools` call may pull in.
|
|
357
390
|
- `orderTools` — The tool array in a stable order, so the same set of tools renders the same way twice.
|
|
358
|
-
- `PRESELECT_SCHEMA` — The shape a preselector's answer is held to where the server takes a schema: `{ tools: [...] }`.
|
|
359
|
-
- `PRESELECT_SYSTEM` — The preselection system prompt at the default cap, for a caller that never changes it.
|
|
360
391
|
- `PROXY_TOOLS` — The whole tool array of a proxied run, `load_tools` then `call_tool`, frozen because it is shared.
|
|
361
|
-
- `preselectByKeywords` — The tools a request's own words point at, ranked, and whether they point clearly enough.
|
|
362
|
-
- `preselectInput` — The user message for a preselection call: the catalogue, then the request.
|
|
363
|
-
- `preselection` — Resolves a preselection against the catalogue: unknown names dropped, count capped.
|
|
364
|
-
- `preselectSystem` — The system prompt a preselector is given, holding it to the cap its answer will be held to.
|
|
365
392
|
- `proxiedCall` — The tool a `call_tool` names and the arguments to run it with, or a throw the model can read.
|
|
366
393
|
- `proxyCatalogPrompt` — The catalogue block for a proxied run's system prompt, worded for `call_tool` rather than for a tool list.
|
|
367
394
|
- `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.
|
|
368
395
|
- `requestedNames` — `load_tools` arguments, defensively — a model may send a bare string or a nested object.
|
|
369
396
|
- `shownCall` — A tool call as a watcher should see it: a `call_tool` as the tool it ran, anything else as it is.
|
|
370
|
-
- `ToolMatch` (type) — One tool's score against a request.
|
|
371
397
|
- `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.
|
|
398
|
+
|
|
399
|
+
### wire
|
|
400
|
+
|
|
401
|
+
The words the chat-completions wire is written in, each under a name.
|
|
402
|
+
|
|
403
|
+
- `FinishReason` — Any one of the reasons in `FinishReason`.
|
|
404
|
+
- `FUNCTION_TOOL` — The one `type` a tool definition or a tool call has on this wire.
|
|
405
|
+
- `JSON_SCHEMA_FORMAT` — The `response_format` type that carries a schema the reply has to fit.
|
|
406
|
+
- `PartType` — Any one of the part types in `PartType`.
|
|
407
|
+
- `Role` — Any one of the roles in `Role`.
|
|
408
|
+
- `SchemaType` — Any one of the types in `SchemaType`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cubicecho/agent-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.1",
|
|
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",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsc -p tsconfig.build.json && node scripts/llms-txt.mjs",
|
|
49
49
|
"prepare": "npm run build",
|
|
50
|
-
"
|
|
50
|
+
"check": "npm run check:biome && npm run check:types",
|
|
51
|
+
"check:biome": "biome check --write .",
|
|
52
|
+
"check:types": "tsc -p tsconfig.tests.json",
|
|
51
53
|
"test": "vitest run",
|
|
52
54
|
"test:watch": "vitest",
|
|
53
55
|
"llms": "node scripts/llms-txt.mjs",
|
|
54
56
|
"llms:check": "node scripts/llms-txt.mjs --check",
|
|
55
|
-
"lint": "biome check .",
|
|
56
|
-
"format": "biome check --write .",
|
|
57
57
|
"bench": "vitest bench --run",
|
|
58
58
|
"coverage": "vitest run --coverage"
|
|
59
59
|
},
|