@cubicecho/agent-core 2.25.1 → 4.0.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 +5 -4
- package/dist/calibration.d.ts +2 -2
- package/dist/calibration.js +2 -2
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/compaction.d.ts +4 -4
- package/dist/compaction.js +3 -3
- package/dist/config.d.ts +1 -1
- package/dist/continuation.d.ts +2 -2
- package/dist/continuation.js +2 -2
- package/dist/guards.d.ts +2 -3
- package/dist/guards.js +1 -2
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -7
- package/dist/preselect.d.ts +4 -27
- package/dist/preselect.js +2 -2
- package/dist/retry.d.ts +1 -1
- package/dist/retry.js +1 -1
- package/dist/run-turn.d.ts +2 -2
- package/dist/scope.d.ts +3 -3
- package/dist/tokens.d.ts +6 -6
- package/dist/tokens.js +6 -6
- package/llms.txt +1 -13
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -316,7 +316,7 @@ and wrong for what a tool-using run is made of — JSON schemas and tool results
|
|
|
316
316
|
three characters a token — so a request the guard let through was refused anyway. The divisor is
|
|
317
317
|
learned instead. Every turn `runTurn` answers comes back with the endpoint's exact prompt count for a
|
|
318
318
|
body whose characters were already counted, and `calibrate` keeps that ratio per endpoint and model;
|
|
319
|
-
the next request to the same model is sized by `charsPerTokenFor`, which is
|
|
319
|
+
the next request to the same model is sized by `charsPerTokenFor`, which is four
|
|
320
320
|
until a turn has reported one. It is the highest of the model's last four readings, which is the
|
|
321
321
|
lowest token count: a count that comes out high refuses a run that would have fit, and one that
|
|
322
322
|
comes out low only costs the round trip the guard was saving. A reading from a request carrying an
|
|
@@ -349,7 +349,7 @@ large for gpt-4o ... on tokens per min"); that is ruled out and waited through a
|
|
|
349
349
|
A server still loading the model is waited for on its own clock. llama.cpp answers 503 `Loading
|
|
350
350
|
model` (type `unavailable_error`) until the weights are mapped, thirty to ninety seconds for a large
|
|
351
351
|
model from a cold cache, and a router build says the same while it swaps models; `backoffMs` would
|
|
352
|
-
give up inside fifteen. `isModelLoading` recognises it, and `runTurn` polls every
|
|
352
|
+
give up inside fifteen. `isModelLoading` recognises it, and `runTurn` polls every three seconds
|
|
353
353
|
for up to `loadingTimeoutMs` (two minutes by default, zero to turn it off) without spending
|
|
354
354
|
`maxRetries`, with one notice at the start. `runAgentLoop` reads it as `loadingTimeoutSeconds` off
|
|
355
355
|
the config. A 503 that says nothing about loading stays on the ordinary backoff.
|
|
@@ -985,7 +985,7 @@ not turn the backlog off. `resetEvents` (and `resetAll`) puts the defaults back,
|
|
|
985
985
|
is not the next one's.
|
|
986
986
|
|
|
987
987
|
`expandNames`, `carryOver`, `preselection`, `preselectInput` and `preselectSystem` take their caps
|
|
988
|
-
the same way — as a last argument
|
|
988
|
+
the same way — as a last argument, which is 12 tools a load and 16 carried unless given. A resolution
|
|
989
989
|
carries the cap it was held to, so `loadResult` tells the model the number it was actually
|
|
990
990
|
measured against rather than the module's own.
|
|
991
991
|
|
|
@@ -1245,7 +1245,8 @@ cannot drift. `endpointKey` holds the key in the clear; `endpointId`, its SHA-25
|
|
|
1245
1245
|
that is safe to write down.
|
|
1246
1246
|
|
|
1247
1247
|
`resetAll` drops all five, and `reset.ts` names each seam separately for a test that wants one —
|
|
1248
|
-
`resetCalibration` for the measured ratios
|
|
1248
|
+
`resetCalibration` for the measured ratios, `resetHints` for the models that refused the
|
|
1249
|
+
no-thinking hints.
|
|
1249
1250
|
|
|
1250
1251
|
The latches can outlive the process as well, because otherwise every restart spends one refused
|
|
1251
1252
|
request per endpoint and model learning the same facts again. `exportCapabilities` returns every
|
package/dist/calibration.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type OpenAI from 'openai';
|
|
2
2
|
import type { Capabilities } from './capabilities.ts';
|
|
3
3
|
/**
|
|
4
|
-
* The characters per token to size a request to this model with,
|
|
4
|
+
* The characters per token to size a request to this model with, four until a turn
|
|
5
5
|
* has reported one.
|
|
6
6
|
*
|
|
7
7
|
* @param supports - The endpoint, as `capabilitiesFor` hands it over.
|
|
8
8
|
* @param model - The name the endpoint knows the model as, as it goes in the body.
|
|
9
9
|
* @returns The highest of the readings held for the model in the current runtime, or
|
|
10
|
-
*
|
|
10
|
+
* four where it holds none.
|
|
11
11
|
*
|
|
12
12
|
* @remarks
|
|
13
13
|
* The highest of the model's last few readings rather than their mean. The estimate guards a
|
package/dist/calibration.js
CHANGED
|
@@ -32,13 +32,13 @@ const PLAUSIBLE = { least: 1, most: 8 };
|
|
|
32
32
|
*/
|
|
33
33
|
const readings = scoped(() => new WeakMap());
|
|
34
34
|
/**
|
|
35
|
-
* The characters per token to size a request to this model with,
|
|
35
|
+
* The characters per token to size a request to this model with, four until a turn
|
|
36
36
|
* has reported one.
|
|
37
37
|
*
|
|
38
38
|
* @param supports - The endpoint, as `capabilitiesFor` hands it over.
|
|
39
39
|
* @param model - The name the endpoint knows the model as, as it goes in the body.
|
|
40
40
|
* @returns The highest of the readings held for the model in the current runtime, or
|
|
41
|
-
*
|
|
41
|
+
* four where it holds none.
|
|
42
42
|
*
|
|
43
43
|
* @remarks
|
|
44
44
|
* The highest of the model's last few readings rather than their mean. The estimate guards a
|
package/dist/client.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export declare const FIRST_TOKEN_FACTOR = 5;
|
|
|
66
66
|
*
|
|
67
67
|
* @param config - Read for `firstTokenSeconds`, and `requestTimeoutSeconds` where that is absent.
|
|
68
68
|
* @returns Milliseconds. `firstTokenSeconds` where it is given, zero or less being no limit;
|
|
69
|
-
* otherwise
|
|
69
|
+
* otherwise five request timeouts, and no limit where the request has none.
|
|
70
70
|
*/
|
|
71
71
|
export declare const firstTokenMs: (config: Pick<Endpoint, 'requestTimeoutSeconds' | 'firstTokenSeconds'>) => number | undefined;
|
|
72
72
|
/**
|
package/dist/client.js
CHANGED
|
@@ -127,7 +127,7 @@ export const FIRST_TOKEN_FACTOR = 5;
|
|
|
127
127
|
*
|
|
128
128
|
* @param config - Read for `firstTokenSeconds`, and `requestTimeoutSeconds` where that is absent.
|
|
129
129
|
* @returns Milliseconds. `firstTokenSeconds` where it is given, zero or less being no limit;
|
|
130
|
-
* otherwise
|
|
130
|
+
* otherwise five request timeouts, and no limit where the request has none.
|
|
131
131
|
*/
|
|
132
132
|
export const firstTokenMs = (config) => {
|
|
133
133
|
if (config.firstTokenSeconds === undefined) {
|
package/dist/compaction.d.ts
CHANGED
|
@@ -107,7 +107,7 @@ export interface CompactionOptions {
|
|
|
107
107
|
* The divisor the default `estimate` uses — `charsPerTokenFor` the model, for a transcript
|
|
108
108
|
* weighed the way `runTurn` sizes its requests. Ignored beside an `estimate` of the caller's own.
|
|
109
109
|
*
|
|
110
|
-
* @defaultValue `
|
|
110
|
+
* @defaultValue `4`
|
|
111
111
|
*/
|
|
112
112
|
charsPerToken?: number;
|
|
113
113
|
/**
|
|
@@ -186,7 +186,7 @@ export declare function summaryInput(plan: CompactionPlan): string;
|
|
|
186
186
|
* @param model - The model to write it, which may be a smaller one than the run's.
|
|
187
187
|
* @param [options] - Cancellation and notices, and the instruction and ceiling the summary is
|
|
188
188
|
* written under.
|
|
189
|
-
* @returns A function from
|
|
189
|
+
* @returns A function from the text of what is being folded to the summary. It rejects as `ask` does, and
|
|
190
190
|
* resolves with an empty string where the model wrote nothing.
|
|
191
191
|
*/
|
|
192
192
|
export declare const summariser: (config: Endpoint, model: string, { system, maxTokens, ...options }?: SideTaskOptions & {
|
|
@@ -233,7 +233,7 @@ export interface CompactionRunOptions {
|
|
|
233
233
|
*
|
|
234
234
|
* @param messages - The transcript the plan was made for. Read only, and only for the hooks.
|
|
235
235
|
* @param plan - What `planCompaction` returned for it.
|
|
236
|
-
* @param summarise - Writes the summary from
|
|
236
|
+
* @param summarise - Writes the summary from the text it is handed. See `summariser`. Not called
|
|
237
237
|
* when a hook vetoes.
|
|
238
238
|
* @param [options] - Hooks to tell and whether the window is already past. See `CompactionRunOptions`.
|
|
239
239
|
* @returns `undefined` when nothing was folded — a hook vetoed, or the summary came back empty —
|
|
@@ -292,7 +292,7 @@ export declare const requestIndex: (index: number, record?: Pick<CompactionRecor
|
|
|
292
292
|
*
|
|
293
293
|
* @param messages - The transcript the plan was made for. Not written to.
|
|
294
294
|
* @param plan - What `planCompaction` returned for it.
|
|
295
|
-
* @param summarise - Writes the summary from
|
|
295
|
+
* @param summarise - Writes the summary from the text it is handed. See `summariser`. Not called
|
|
296
296
|
* when a hook vetoes.
|
|
297
297
|
* @param [options] - Hooks to tell and whether the window is already past. See
|
|
298
298
|
* `CompactionRunOptions`.
|
package/dist/compaction.js
CHANGED
|
@@ -252,7 +252,7 @@ export function summaryInput(plan) {
|
|
|
252
252
|
* @param model - The model to write it, which may be a smaller one than the run's.
|
|
253
253
|
* @param [options] - Cancellation and notices, and the instruction and ceiling the summary is
|
|
254
254
|
* written under.
|
|
255
|
-
* @returns A function from
|
|
255
|
+
* @returns A function from the text of what is being folded to the summary. It rejects as `ask` does, and
|
|
256
256
|
* resolves with an empty string where the model wrote nothing.
|
|
257
257
|
*/
|
|
258
258
|
export const summariser = (config, model, { system = SUMMARY_PROMPT, maxTokens = SUMMARY_TOKENS, ...options } = {}) => (text) => ask(config, model, system, text, { maxTokens, ...options });
|
|
@@ -261,7 +261,7 @@ export const summariser = (config, model, { system = SUMMARY_PROMPT, maxTokens =
|
|
|
261
261
|
*
|
|
262
262
|
* @param messages - The transcript the plan was made for. Read only, and only for the hooks.
|
|
263
263
|
* @param plan - What `planCompaction` returned for it.
|
|
264
|
-
* @param summarise - Writes the summary from
|
|
264
|
+
* @param summarise - Writes the summary from the text it is handed. See `summariser`. Not called
|
|
265
265
|
* when a hook vetoes.
|
|
266
266
|
* @param [options] - Hooks to tell and whether the window is already past. See `CompactionRunOptions`.
|
|
267
267
|
* @returns `undefined` when nothing was folded — a hook vetoed, or the summary came back empty —
|
|
@@ -357,7 +357,7 @@ export const requestIndex = (index, record, head = 0) => {
|
|
|
357
357
|
*
|
|
358
358
|
* @param messages - The transcript the plan was made for. Not written to.
|
|
359
359
|
* @param plan - What `planCompaction` returned for it.
|
|
360
|
-
* @param summarise - Writes the summary from
|
|
360
|
+
* @param summarise - Writes the summary from the text it is handed. See `summariser`. Not called
|
|
361
361
|
* when a hook vetoes.
|
|
362
362
|
* @param [options] - Hooks to tell and whether the window is already past. See
|
|
363
363
|
* `CompactionRunOptions`.
|
package/dist/config.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface Endpoint {
|
|
|
36
36
|
/**
|
|
37
37
|
* How long a streamed turn may wait for its first chunk. Zero or less is no limit.
|
|
38
38
|
*
|
|
39
|
-
* @defaultValue
|
|
39
|
+
* @defaultValue Five times `requestTimeoutSeconds`
|
|
40
40
|
*
|
|
41
41
|
* @remarks
|
|
42
42
|
* Its own number because the first wait is prefill, and on a local server prefill of a long
|
package/dist/continuation.d.ts
CHANGED
|
@@ -50,8 +50,8 @@ export declare const isContinuable: (turn: Turn) => boolean;
|
|
|
50
50
|
* continuation's `finishReason` and tool calls.
|
|
51
51
|
*
|
|
52
52
|
* @remarks
|
|
53
|
-
* Only a turn
|
|
54
|
-
* reasoning are joined in order, the tool calls a continuation makes are kept, and usage is summed
|
|
53
|
+
* Only a turn cut off at the ceiling, with an answer begun and no tool call in it, is continued;
|
|
54
|
+
* any other comes back as it was. Content and reasoning are joined in order, the tool calls a continuation makes are kept, and usage is summed
|
|
55
55
|
* across the requests with `continuations` counting them. The continuation is read as starting in
|
|
56
56
|
* the answer, whatever `startInReasoning` says: a template that opens a fence for a fresh reply
|
|
57
57
|
* does not open one for a prefill. Its tokens reach `onOutput` as they arrive, so a watcher sees
|
package/dist/continuation.js
CHANGED
|
@@ -112,8 +112,8 @@ function joinUsage(first, next) {
|
|
|
112
112
|
* continuation's `finishReason` and tool calls.
|
|
113
113
|
*
|
|
114
114
|
* @remarks
|
|
115
|
-
* Only a turn
|
|
116
|
-
* reasoning are joined in order, the tool calls a continuation makes are kept, and usage is summed
|
|
115
|
+
* Only a turn cut off at the ceiling, with an answer begun and no tool call in it, is continued;
|
|
116
|
+
* any other comes back as it was. Content and reasoning are joined in order, the tool calls a continuation makes are kept, and usage is summed
|
|
117
117
|
* across the requests with `continuations` counting them. The continuation is read as starting in
|
|
118
118
|
* the answer, whatever `startInReasoning` says: a template that opens a fence for a fresh reply
|
|
119
119
|
* does not open one for a prefill. Its tokens reach `onOutput` as they arrive, so a watcher sees
|
package/dist/guards.d.ts
CHANGED
|
@@ -37,12 +37,11 @@ interface Lookup<K, V> {
|
|
|
37
37
|
*
|
|
38
38
|
* @param map - Where to look. Gains an entry on a miss, which is the point of calling this.
|
|
39
39
|
* @param key - What to look under.
|
|
40
|
-
* @param create - Builds the value on a miss, and is not called on a hit.
|
|
41
|
-
* reads as a miss, so one that returns it is called every time.
|
|
40
|
+
* @param create - Builds the value on a miss, and is not called on a hit.
|
|
42
41
|
* @returns What the map holds under the key afterwards: the held value itself on a hit, what
|
|
43
42
|
* `create` returned on a miss.
|
|
44
43
|
*/
|
|
45
|
-
export declare function getOrCreate<K, V>(map: Lookup<K, V>, key: K, create: () => V): V;
|
|
44
|
+
export declare function getOrCreate<K, V extends {}>(map: Lookup<K, V>, key: K, create: () => V): V;
|
|
46
45
|
/**
|
|
47
46
|
* A count and its noun, plural unless the count is one: `1 tool`, `3 tools`.
|
|
48
47
|
*
|
package/dist/guards.js
CHANGED
|
@@ -32,8 +32,7 @@ export const isPositive = (value) => typeof value === 'number' && value > 0;
|
|
|
32
32
|
*
|
|
33
33
|
* @param map - Where to look. Gains an entry on a miss, which is the point of calling this.
|
|
34
34
|
* @param key - What to look under.
|
|
35
|
-
* @param create - Builds the value on a miss, and is not called on a hit.
|
|
36
|
-
* reads as a miss, so one that returns it is called every time.
|
|
35
|
+
* @param create - Builds the value on a miss, and is not called on a hit.
|
|
37
36
|
* @returns What the map holds under the key afterwards: the held value itself on a hit, what
|
|
38
37
|
* `create` returned on a miss.
|
|
39
38
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -13,19 +13,19 @@ export { type AgentLoopHooks, type AgentLoopOptions, type AgentLoopRequest, type
|
|
|
13
13
|
export { calibrate, charsPerTokenFor, resetCalibration } from './calibration.ts';
|
|
14
14
|
export { type Capabilities, capabilitiesFor, EFFORT_LADDER, EFFORT_NONE, EFFORT_OFF, effortFor, expireCapabilities, type ModelCapabilities, modelCapabilitiesFor, type NegotiateOptions, negotiate, resetCapabilities, } from './capabilities.ts';
|
|
15
15
|
export type { CatalogServer } from './catalog.ts';
|
|
16
|
-
export { type ClientPoolOptions, configureClients, contextLimitFor, endpointId, endpointKey,
|
|
17
|
-
export { applyCompaction, COMPACT_AT, type CompactionOptions, type CompactionPlan, type CompactionRecord, type CompactionRunOptions, compactTranscript, KEEP_RATIO, type PruneOptions, planCompaction, pruneToolResults, requestIndex, runCompaction, SUMMARY_LEAD, SUMMARY_PROMPT, summariser,
|
|
16
|
+
export { type ClientPoolOptions, configureClients, contextLimitFor, endpointId, endpointKey, firstTokenMs, getClient, listModels, type ModelInfo, NO_KEY, resetClients, resolveApiKey, servedWindow, timeoutMs, } from './client.ts';
|
|
17
|
+
export { applyCompaction, COMPACT_AT, type CompactionOptions, type CompactionPlan, type CompactionRecord, type CompactionRunOptions, compactTranscript, KEEP_RATIO, type PruneOptions, planCompaction, pruneToolResults, requestIndex, runCompaction, SUMMARY_LEAD, SUMMARY_PROMPT, summariser, } from './compaction.ts';
|
|
18
18
|
export { type AgentConfig, type Endpoint, type ModelParams, type RetryPolicy, ToolDiscovery, type ToolPolicy, } from './config.ts';
|
|
19
|
-
export { type ContinueTurnOptions, continueTurn,
|
|
19
|
+
export { type ContinueTurnOptions, continueTurn, } from './continuation.ts';
|
|
20
20
|
export { AgentLoopError, type AgentLoopFailure, AgentLoopOverflow, errorMessage, failedRun, ToolIterationLimit, } from './errors.ts';
|
|
21
21
|
export { configureEvents, type EventBusOptions, emit, endRun, fold, history, type RunEvent, type RunEventInput, RunEventKind, type RunMetrics, type RunMetricsOptions, RunOutcome, type RunUsage, resetEvents, runMetrics, type TurnReport, watch, } from './events.ts';
|
|
22
22
|
export { HOOK_EVENTS, HookEvent, INJECT_EVENTS } from './hook-events.ts';
|
|
23
23
|
export { assembleContext, configureHooks, consult, type Gathered, gather, HOOK_CONTEXT_TOKENS, HOOK_PREFACE, type HookContext, type HookMessage, type HookNote, type HookOptions, type HookOutcome, type HookRunner, notify, resetHooks, turnIndex, turnMessages, UNTRUSTED_PREFACE, untrusted, withContext, } from './hooks.ts';
|
|
24
24
|
export { estimateFrom, type LedgerEntry, type LedgerEstimateOptions, type LedgerRequest, rebaseLedger, recordRequest, type TokenLedger, tokensBetween, } from './ledger.ts';
|
|
25
|
-
export {
|
|
25
|
+
export { type KeywordPreselection, type KeywordPreselectOptions, PRESELECT_SCHEMA, PRESELECT_SYSTEM, preselect, preselectByKeywords, preselectInput, preselection, preselectSystem, type ToolMatch, } from './preselect.ts';
|
|
26
26
|
export { buildBody } from './request-body.ts';
|
|
27
27
|
export { resetAll } from './reset.ts';
|
|
28
|
-
export { backoffMs, ContextOverflow, EndpointSilent, isModelLoading, isOverflow, isTransient,
|
|
28
|
+
export { backoffMs, ContextOverflow, EndpointSilent, isModelLoading, isOverflow, isTransient, SMALLEST_LIKELY_WINDOW, } from './retry.ts';
|
|
29
29
|
export { preview } from './run-calls.ts';
|
|
30
30
|
export { type RunTurnOptions, runTurn } from './run-turn.ts';
|
|
31
31
|
export { createRuntime, defaultRuntime, type Runtime, type RuntimeOptions } from './runtime.ts';
|
|
@@ -35,7 +35,7 @@ export { CAPABILITY_SNAPSHOT_VERSION, type CapabilitySnapshot, type EndpointSnap
|
|
|
35
35
|
export { AGENT_SPEC, AGENT_SPEC_VERSION, AGENT_TASKS, type AgentHook, type AgentSpec, type EndpointSpec, type ExportSpecOptions, exportSpec, type ModelSpec, type ParsedSpec, type ParseSpecOptions, type PromptPart, parseSpec, REF_FILE, REF_URL, RESOLVED_DEFAULTS, type ResolvedAgent, type ResolvedTask, type RetrySpec, resolveAgentSpec, SPEC_EVENTS, type SpecBundle, type SpecServer, type TaskSpec, type ToolsSpec, } from './spec.ts';
|
|
36
36
|
export { CacheBreakReason, type Produced, type StreamTurnOptions, streamTurn, type Turn, type TurnUsage, } from './stream.ts';
|
|
37
37
|
export { ALL_FENCES, DEFAULT_FENCES, type Fence, FenceSplitter, type FenceSplitterOptions, SPLIT_OUTPUT, SPLIT_REASONING, type Split, stripThinking, THINK_FENCE, } from './thinking.ts';
|
|
38
|
-
export {
|
|
38
|
+
export { type ContextBreakdown, type ContextBreakdownOptions, compact, contextChars, contextTokens, estimateTokens, messageTokens, requestChars, requestTokens, type TokenEstimateOptions, } from './tokens.ts';
|
|
39
39
|
export { ARGUMENTS_MALFORMED, ARGUMENTS_TRUNCATED, parseToolArguments, recoverToolCalls, ToolArgumentsError, type ToolCall, type ToolCallOutcome, type ToolCallRequest, type ToolCallResult, } from './tool-calls.ts';
|
|
40
|
-
export { CALL_TOOL, carryOver, catalogList, catalogPrompt, expandNames, holdsDefinitions, inCatalog, LOAD_TOOLS, LOAD_TOOLS_DEFINITION, loadedTools, loadResult,
|
|
40
|
+
export { CALL_TOOL, carryOver, catalogList, catalogPrompt, expandNames, holdsDefinitions, inCatalog, LOAD_TOOLS, LOAD_TOOLS_DEFINITION, loadedTools, loadResult, orderTools, PROXY_TOOLS, proxiedCall, proxyCatalogPrompt, proxyLoadResult, requestedNames, shownCall, type ToolOrder, } from './tool-loading.ts';
|
|
41
41
|
export { FinishReason, FUNCTION_TOOL, JSON_SCHEMA_FORMAT, PartType, Role, SchemaType } from './wire.ts';
|
package/dist/index.js
CHANGED
|
@@ -12,19 +12,19 @@
|
|
|
12
12
|
export { PRESELECT_APPEND, PRESELECT_EXCLUSIVE, runAgentLoop, } from './agent-loop.js';
|
|
13
13
|
export { calibrate, charsPerTokenFor, resetCalibration } from './calibration.js';
|
|
14
14
|
export { capabilitiesFor, EFFORT_LADDER, EFFORT_NONE, EFFORT_OFF, effortFor, expireCapabilities, modelCapabilitiesFor, negotiate, resetCapabilities, } from './capabilities.js';
|
|
15
|
-
export { configureClients, contextLimitFor, endpointId, endpointKey,
|
|
16
|
-
export { applyCompaction, COMPACT_AT, compactTranscript, KEEP_RATIO, planCompaction, pruneToolResults, requestIndex, runCompaction, SUMMARY_LEAD, SUMMARY_PROMPT, summariser,
|
|
15
|
+
export { configureClients, contextLimitFor, endpointId, endpointKey, firstTokenMs, getClient, listModels, NO_KEY, resetClients, resolveApiKey, servedWindow, timeoutMs, } from './client.js';
|
|
16
|
+
export { applyCompaction, COMPACT_AT, compactTranscript, KEEP_RATIO, planCompaction, pruneToolResults, requestIndex, runCompaction, SUMMARY_LEAD, SUMMARY_PROMPT, summariser, } from './compaction.js';
|
|
17
17
|
export { ToolDiscovery, } from './config.js';
|
|
18
|
-
export { continueTurn,
|
|
18
|
+
export { continueTurn, } from './continuation.js';
|
|
19
19
|
export { AgentLoopError, AgentLoopOverflow, errorMessage, failedRun, ToolIterationLimit, } from './errors.js';
|
|
20
20
|
export { configureEvents, emit, endRun, fold, history, RunEventKind, RunOutcome, resetEvents, runMetrics, watch, } from './events.js';
|
|
21
21
|
export { HOOK_EVENTS, HookEvent, INJECT_EVENTS } from './hook-events.js';
|
|
22
22
|
export { assembleContext, configureHooks, consult, gather, HOOK_CONTEXT_TOKENS, HOOK_PREFACE, notify, resetHooks, turnIndex, turnMessages, UNTRUSTED_PREFACE, untrusted, withContext, } from './hooks.js';
|
|
23
23
|
export { estimateFrom, rebaseLedger, recordRequest, tokensBetween, } from './ledger.js';
|
|
24
|
-
export {
|
|
24
|
+
export { PRESELECT_SCHEMA, PRESELECT_SYSTEM, preselect, preselectByKeywords, preselectInput, preselection, preselectSystem, } from './preselect.js';
|
|
25
25
|
export { buildBody } from './request-body.js';
|
|
26
26
|
export { resetAll } from './reset.js';
|
|
27
|
-
export { backoffMs, ContextOverflow, EndpointSilent, isModelLoading, isOverflow, isTransient,
|
|
27
|
+
export { backoffMs, ContextOverflow, EndpointSilent, isModelLoading, isOverflow, isTransient, SMALLEST_LIKELY_WINDOW, } from './retry.js';
|
|
28
28
|
export { preview } from './run-calls.js';
|
|
29
29
|
export { runTurn } from './run-turn.js';
|
|
30
30
|
export { createRuntime, defaultRuntime } from './runtime.js';
|
|
@@ -34,7 +34,7 @@ export { CAPABILITY_SNAPSHOT_VERSION, exportCapabilities, importCapabilities, }
|
|
|
34
34
|
export { AGENT_SPEC, AGENT_SPEC_VERSION, AGENT_TASKS, exportSpec, parseSpec, REF_FILE, REF_URL, RESOLVED_DEFAULTS, resolveAgentSpec, SPEC_EVENTS, } from './spec.js';
|
|
35
35
|
export { CacheBreakReason, streamTurn, } from './stream.js';
|
|
36
36
|
export { ALL_FENCES, DEFAULT_FENCES, FenceSplitter, SPLIT_OUTPUT, SPLIT_REASONING, stripThinking, THINK_FENCE, } from './thinking.js';
|
|
37
|
-
export {
|
|
37
|
+
export { compact, contextChars, contextTokens, estimateTokens, messageTokens, requestChars, requestTokens, } from './tokens.js';
|
|
38
38
|
export { ARGUMENTS_MALFORMED, ARGUMENTS_TRUNCATED, parseToolArguments, recoverToolCalls, ToolArgumentsError, } from './tool-calls.js';
|
|
39
|
-
export { CALL_TOOL, carryOver, catalogList, catalogPrompt, expandNames, holdsDefinitions, inCatalog, LOAD_TOOLS, LOAD_TOOLS_DEFINITION, loadedTools, loadResult,
|
|
39
|
+
export { CALL_TOOL, carryOver, catalogList, catalogPrompt, expandNames, holdsDefinitions, inCatalog, LOAD_TOOLS, LOAD_TOOLS_DEFINITION, loadedTools, loadResult, orderTools, PROXY_TOOLS, proxiedCall, proxyCatalogPrompt, proxyLoadResult, requestedNames, shownCall, } from './tool-loading.js';
|
|
40
40
|
export { FinishReason, FUNCTION_TOOL, JSON_SCHEMA_FORMAT, PartType, Role, SchemaType } from './wire.js';
|
package/dist/preselect.d.ts
CHANGED
|
@@ -66,29 +66,6 @@ export declare const preselectInput: (catalog: CatalogServer[], prompt: string,
|
|
|
66
66
|
* more than `maxPerLoad`. Empty where nothing resolved.
|
|
67
67
|
*/
|
|
68
68
|
export declare function preselection(names: unknown, catalog: CatalogServer[], maxPerLoad?: number): string[];
|
|
69
|
-
/**
|
|
70
|
-
* The least a best match may score and still be acted on without a model.
|
|
71
|
-
*
|
|
72
|
-
* @remarks
|
|
73
|
-
* A BM25 score, so it is read against the shape of the corpus rather than as a percentage: a
|
|
74
|
-
* query term carried by half the catalogue is worth about 0.7, and one carried by a single tool
|
|
75
|
-
* about 3. One at this floor is therefore "something more distinctive than a word every other
|
|
76
|
-
* tool uses", which is the weakest evidence worth skipping a round trip on.
|
|
77
|
-
*
|
|
78
|
-
* A term is distinctive only against other terms, so a catalogue of three or four tools rarely
|
|
79
|
-
* clears it. That is the right answer rather than a gap: a catalogue that small is not costing
|
|
80
|
-
* enough tokens to be worth choosing from in the first place.
|
|
81
|
-
*/
|
|
82
|
-
export declare const KEYWORD_MIN_SCORE = 1;
|
|
83
|
-
/**
|
|
84
|
-
* How far the best unpicked tool must fall below the last picked one for the cut to count clean.
|
|
85
|
-
*
|
|
86
|
-
* @remarks
|
|
87
|
-
* Half. The cap is the only reason a hit is dropped, so a hit just underneath it scoring nearly
|
|
88
|
-
* as much as one just above means the ranking chose arbitrarily, which is exactly the case a
|
|
89
|
-
* model should be spent on.
|
|
90
|
-
*/
|
|
91
|
-
export declare const KEYWORD_DROPOFF = 0.5;
|
|
92
69
|
/** One tool's score against a request. */
|
|
93
70
|
export interface ToolMatch {
|
|
94
71
|
name: string;
|
|
@@ -109,19 +86,19 @@ export interface KeywordPreselectOptions {
|
|
|
109
86
|
/**
|
|
110
87
|
* The most to pick. The same cap the model is held to.
|
|
111
88
|
*
|
|
112
|
-
* @defaultValue `
|
|
89
|
+
* @defaultValue `12`
|
|
113
90
|
*/
|
|
114
91
|
maxPerLoad?: number;
|
|
115
92
|
/**
|
|
116
93
|
* The floor under a confident best match.
|
|
117
94
|
*
|
|
118
|
-
* @defaultValue `
|
|
95
|
+
* @defaultValue `1`
|
|
119
96
|
*/
|
|
120
97
|
minScore?: number;
|
|
121
98
|
/**
|
|
122
99
|
* The gap a confident cut needs.
|
|
123
100
|
*
|
|
124
|
-
* @defaultValue `
|
|
101
|
+
* @defaultValue `0.5`
|
|
125
102
|
*/
|
|
126
103
|
dropoff?: number;
|
|
127
104
|
/**
|
|
@@ -184,7 +161,7 @@ export interface PreselectOptions {
|
|
|
184
161
|
/**
|
|
185
162
|
* The most tools the choice may name.
|
|
186
163
|
*
|
|
187
|
-
* @defaultValue `
|
|
164
|
+
* @defaultValue `12`
|
|
188
165
|
*/
|
|
189
166
|
maxPerLoad?: number;
|
|
190
167
|
/**
|
package/dist/preselect.js
CHANGED
|
@@ -112,7 +112,7 @@ const IDF_SMOOTHING = 0.5;
|
|
|
112
112
|
* clears it. That is the right answer rather than a gap: a catalogue that small is not costing
|
|
113
113
|
* enough tokens to be worth choosing from in the first place.
|
|
114
114
|
*/
|
|
115
|
-
|
|
115
|
+
const KEYWORD_MIN_SCORE = 1;
|
|
116
116
|
/**
|
|
117
117
|
* How far the best unpicked tool must fall below the last picked one for the cut to count clean.
|
|
118
118
|
*
|
|
@@ -121,7 +121,7 @@ export const KEYWORD_MIN_SCORE = 1;
|
|
|
121
121
|
* as much as one just above means the ranking chose arbitrarily, which is exactly the case a
|
|
122
122
|
* model should be spent on.
|
|
123
123
|
*/
|
|
124
|
-
|
|
124
|
+
const KEYWORD_DROPOFF = 0.5;
|
|
125
125
|
/** The longest word `terms` leaves its trailing `s` on: `bus` and `was` are not plurals. */
|
|
126
126
|
const SHORTEST_PLURAL = 3;
|
|
127
127
|
/** What the preselector's reply schema is called on the wire. */
|
package/dist/retry.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ export declare const refusesRequest: (error: unknown) => boolean;
|
|
|
91
91
|
*
|
|
92
92
|
* @remarks
|
|
93
93
|
* An abort reaches a catch in two shapes. The SDK raises its own class when a request in flight is
|
|
94
|
-
* cancelled, and
|
|
94
|
+
* cancelled, and the wait between attempts rejects with the signal's reason when the cancel lands there.
|
|
95
95
|
* A catch that knew only the first reported the second as a failure. A signal aborted with a
|
|
96
96
|
* reason of the caller's own making is not recognised, since only the error is looked at: a
|
|
97
97
|
* catch that holds the signal asks it as well, as `tryAsk` does.
|
package/dist/retry.js
CHANGED
|
@@ -135,7 +135,7 @@ export const refusesRequest = (error) => error instanceof OpenAI.APIError &&
|
|
|
135
135
|
*
|
|
136
136
|
* @remarks
|
|
137
137
|
* An abort reaches a catch in two shapes. The SDK raises its own class when a request in flight is
|
|
138
|
-
* cancelled, and
|
|
138
|
+
* cancelled, and the wait between attempts rejects with the signal's reason when the cancel lands there.
|
|
139
139
|
* A catch that knew only the first reported the second as a failure. A signal aborted with a
|
|
140
140
|
* reason of the caller's own making is not recognised, since only the error is looked at: a
|
|
141
141
|
* catch that holds the signal asks it as well, as `tryAsk` does.
|
package/dist/run-turn.d.ts
CHANGED
|
@@ -75,10 +75,10 @@ export interface RunTurnOptions extends Omit<StreamTurnOptions, 'produced'> {
|
|
|
75
75
|
* How long to wait on a server answering that the model is still loading; zero gives up on the
|
|
76
76
|
* first such answer like any other 503.
|
|
77
77
|
*
|
|
78
|
-
* @defaultValue `
|
|
78
|
+
* @defaultValue `120000`
|
|
79
79
|
*
|
|
80
80
|
* @remarks
|
|
81
|
-
* Polled every
|
|
81
|
+
* Polled every three seconds without spending `maxRetries`, and announced once rather than
|
|
82
82
|
* per poll. A consumer that starts alongside its llama.cpp, or asks a router for a model it
|
|
83
83
|
* has to swap in, meets this on its first request every time.
|
|
84
84
|
*/
|
package/dist/scope.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* A map rather than a record of named caches, so a module that grows a cache declares it where
|
|
6
6
|
* it is used and `runtime.ts` does not have to hear about it.
|
|
7
7
|
*/
|
|
8
|
-
export type Scope = Map<symbol, unknown
|
|
8
|
+
export type Scope = Map<symbol, NonNullable<unknown>>;
|
|
9
9
|
/** The default runtime's scope: what the top-level functions use when no runtime is running. */
|
|
10
10
|
export declare const rootScope: Scope;
|
|
11
11
|
/**
|
|
@@ -23,7 +23,7 @@ export declare const currentScope: () => Scope;
|
|
|
23
23
|
*/
|
|
24
24
|
export declare const inScope: <T>(scope: Scope, fn: () => T) => T;
|
|
25
25
|
/** One module's state, read from whichever scope is current. See `scoped`. */
|
|
26
|
-
export interface Scoped<T> {
|
|
26
|
+
export interface Scoped<T extends {}> {
|
|
27
27
|
/** The current scope's copy, made on first use. */
|
|
28
28
|
(): T;
|
|
29
29
|
/** Drops the current scope's copy, so the next read makes a fresh one. */
|
|
@@ -41,7 +41,7 @@ export interface Scoped<T> {
|
|
|
41
41
|
* and each use reads `cache()`. The copy is made lazily, so a runtime pays only for the modules
|
|
42
42
|
* it touches.
|
|
43
43
|
*/
|
|
44
|
-
export declare function scoped<T>(create: () => T): Scoped<T>;
|
|
44
|
+
export declare function scoped<T extends {}>(create: () => T): Scoped<T>;
|
|
45
45
|
/**
|
|
46
46
|
* Writes what a caller gave onto the settings in force, field by field, skipping what is unusable.
|
|
47
47
|
*
|
package/dist/tokens.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare const CHARS_PER_TOKEN = 4;
|
|
|
13
13
|
* vocabulary either.
|
|
14
14
|
*
|
|
15
15
|
* @param text - Prose or serialised JSON — both counted the same way, which is why JSON reads low.
|
|
16
|
-
* @returns The length over
|
|
16
|
+
* @returns The length over four, rounded up: zero for an empty string, and one for
|
|
17
17
|
* anything shorter than a token.
|
|
18
18
|
*
|
|
19
19
|
* @remarks
|
|
@@ -46,7 +46,7 @@ export interface TokenEstimateOptions {
|
|
|
46
46
|
* The divisor — `charsPerTokenFor` for a model whose reported usage has calibrated it. A value
|
|
47
47
|
* that is not a number above zero is ignored.
|
|
48
48
|
*
|
|
49
|
-
* @defaultValue `
|
|
49
|
+
* @defaultValue `4`
|
|
50
50
|
*/
|
|
51
51
|
charsPerToken?: number;
|
|
52
52
|
}
|
|
@@ -72,7 +72,7 @@ export declare function toolsChars(tools: OpenAI.ChatCompletionTool[]): number;
|
|
|
72
72
|
*
|
|
73
73
|
* @param body - The request as it was sent, tools included.
|
|
74
74
|
* @returns The sum of `messageChars` over the messages. The tools are not in it, whether or not
|
|
75
|
-
* the body carries them; `
|
|
75
|
+
* the body carries them; `contextChars` counts those, under `tools`.
|
|
76
76
|
*
|
|
77
77
|
* @remarks
|
|
78
78
|
* What calibration reads a reported prompt count against, since a ratio is only as good as the
|
|
@@ -83,7 +83,7 @@ export declare function requestChars(body: OpenAI.ChatCompletionCreateParamsStre
|
|
|
83
83
|
* What this request will cost the window, in tokens, near enough.
|
|
84
84
|
*
|
|
85
85
|
* @param body - The request as it will be sent, tools included.
|
|
86
|
-
* @param [options] - The divisor,
|
|
86
|
+
* @param [options] - The divisor, four when none is given.
|
|
87
87
|
* @returns Whole tokens: the messages' and the tools', each rounded up on its own and added.
|
|
88
88
|
*
|
|
89
89
|
* @remarks
|
|
@@ -132,7 +132,7 @@ export interface ContextBreakdown {
|
|
|
132
132
|
* that is neither that nor a `tool` message as `history`.
|
|
133
133
|
*
|
|
134
134
|
* @remarks
|
|
135
|
-
* Exact and additive: the parts sum to `total`, which is `requestChars` plus
|
|
135
|
+
* Exact and additive: the parts sum to `total`, which is `requestChars` plus the characters of the tools. The
|
|
136
136
|
* conversion to tokens is `contextTokens`' business, because that is where an estimate and a
|
|
137
137
|
* reported count have to be told apart.
|
|
138
138
|
*/
|
|
@@ -172,7 +172,7 @@ export declare function contextTokens(body: OpenAI.ChatCompletionCreateParamsStr
|
|
|
172
172
|
* One message's estimated tokens, by the same count `requestTokens` sums for a whole request.
|
|
173
173
|
*
|
|
174
174
|
* @param message - The message as it will be sent.
|
|
175
|
-
* @param [options] - The divisor,
|
|
175
|
+
* @param [options] - The divisor, four when none is given.
|
|
176
176
|
* @returns `messageChars` over the divisor, rounded up per message, where `requestTokens` rounds
|
|
177
177
|
* once over them all.
|
|
178
178
|
*
|
package/dist/tokens.js
CHANGED
|
@@ -13,7 +13,7 @@ export const CHARS_PER_TOKEN = 4;
|
|
|
13
13
|
* vocabulary either.
|
|
14
14
|
*
|
|
15
15
|
* @param text - Prose or serialised JSON — both counted the same way, which is why JSON reads low.
|
|
16
|
-
* @returns The length over
|
|
16
|
+
* @returns The length over four, rounded up: zero for an empty string, and one for
|
|
17
17
|
* anything shorter than a token.
|
|
18
18
|
*
|
|
19
19
|
* @remarks
|
|
@@ -80,7 +80,7 @@ const REASONING_ALT_KEY = 15;
|
|
|
80
80
|
* The divisor an option asked for, or the fallback when it asked for nothing usable.
|
|
81
81
|
*
|
|
82
82
|
* @param charsPerToken - What the caller gave. Absent, zero, negative or `NaN` is nothing usable.
|
|
83
|
-
* @returns `charsPerToken` when it is above zero, otherwise
|
|
83
|
+
* @returns `charsPerToken` when it is above zero, otherwise four.
|
|
84
84
|
*/
|
|
85
85
|
const divisor = (charsPerToken) => charsPerToken !== undefined && charsPerToken > 0 ? charsPerToken : CHARS_PER_TOKEN;
|
|
86
86
|
/**
|
|
@@ -180,7 +180,7 @@ export function toolsChars(tools) {
|
|
|
180
180
|
*
|
|
181
181
|
* @param body - The request as it was sent, tools included.
|
|
182
182
|
* @returns The sum of `messageChars` over the messages. The tools are not in it, whether or not
|
|
183
|
-
* the body carries them; `
|
|
183
|
+
* the body carries them; `contextChars` counts those, under `tools`.
|
|
184
184
|
*
|
|
185
185
|
* @remarks
|
|
186
186
|
* What calibration reads a reported prompt count against, since a ratio is only as good as the
|
|
@@ -197,7 +197,7 @@ export function requestChars(body) {
|
|
|
197
197
|
* What this request will cost the window, in tokens, near enough.
|
|
198
198
|
*
|
|
199
199
|
* @param body - The request as it will be sent, tools included.
|
|
200
|
-
* @param [options] - The divisor,
|
|
200
|
+
* @param [options] - The divisor, four when none is given.
|
|
201
201
|
* @returns Whole tokens: the messages' and the tools', each rounded up on its own and added.
|
|
202
202
|
*
|
|
203
203
|
* @remarks
|
|
@@ -232,7 +232,7 @@ const PARTS = ['system', 'tools', 'history', 'toolResults'];
|
|
|
232
232
|
* that is neither that nor a `tool` message as `history`.
|
|
233
233
|
*
|
|
234
234
|
* @remarks
|
|
235
|
-
* Exact and additive: the parts sum to `total`, which is `requestChars` plus
|
|
235
|
+
* Exact and additive: the parts sum to `total`, which is `requestChars` plus the characters of the tools. The
|
|
236
236
|
* conversion to tokens is `contextTokens`' business, because that is where an estimate and a
|
|
237
237
|
* reported count have to be told apart.
|
|
238
238
|
*/
|
|
@@ -327,7 +327,7 @@ export function contextTokens(body, { charsPerToken, promptTokens } = {}) {
|
|
|
327
327
|
* One message's estimated tokens, by the same count `requestTokens` sums for a whole request.
|
|
328
328
|
*
|
|
329
329
|
* @param message - The message as it will be sent.
|
|
330
|
-
* @param [options] - The divisor,
|
|
330
|
+
* @param [options] - The divisor, four when none is given.
|
|
331
331
|
* @returns `messageChars` over the divisor, rounded up per message, where `requestTokens` rounds
|
|
332
332
|
* once over them all.
|
|
333
333
|
*
|
package/llms.txt
CHANGED
|
@@ -27,7 +27,7 @@ The loop above a turn: send, run the tools the model asked for, send again, unti
|
|
|
27
27
|
How many characters a token is worth on one model, learned from what its endpoint reports.
|
|
28
28
|
|
|
29
29
|
- `calibrate` — Takes one reading from a request that was answered, so the next one to this model is sized by it.
|
|
30
|
-
- `charsPerTokenFor` — The characters per token to size a request to this model with,
|
|
30
|
+
- `charsPerTokenFor` — The characters per token to size a request to this model with, four until a turn has reported one.
|
|
31
31
|
- `resetCalibration` — Forgets every reading, so the next request is sized at `CHARS_PER_TOKEN` again.
|
|
32
32
|
|
|
33
33
|
### capabilities
|
|
@@ -60,7 +60,6 @@ The contract between whatever holds the tools and the loop that offers them to a
|
|
|
60
60
|
- `contextLimitFor` — How much a model will read, in tokens.
|
|
61
61
|
- `endpointId` — `endpointKey` hashed, for the remembered facts that can leave the process.
|
|
62
62
|
- `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
|
-
- `FIRST_TOKEN_FACTOR` — How many idle windows the first chunk gets when `firstTokenSeconds` is not given.
|
|
64
63
|
- `firstTokenMs` — The wait for a streamed turn's first chunk, in the SDK's spelling: `undefined` is no limit.
|
|
65
64
|
- `getClient` — The client for an endpoint, built once and kept.
|
|
66
65
|
- `listModels` — Asks an endpoint what it serves, and remembers the answer.
|
|
@@ -91,7 +90,6 @@ Keeping a long run inside its window: stale tool results cleared, and the oldest
|
|
|
91
90
|
- `SUMMARY_LEAD` — How a summary message opens, which is also how `planCompaction` knows one from a system prompt.
|
|
92
91
|
- `SUMMARY_PROMPT` — The summariser's instruction when the caller gives none.
|
|
93
92
|
- `summariser` — A summariser that asks `model` with `SUMMARY_PROMPT`, for `compactTranscript`.
|
|
94
|
-
- `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.
|
|
95
93
|
|
|
96
94
|
### config
|
|
97
95
|
|
|
@@ -110,7 +108,6 @@ Picking up an answer the token ceiling cut off, instead of keeping half of it.
|
|
|
110
108
|
|
|
111
109
|
- `ContinueTurnOptions` (type) — What `continueTurn` takes besides what `runTurn` does.
|
|
112
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.
|
|
113
|
-
- `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.
|
|
114
111
|
|
|
115
112
|
### errors
|
|
116
113
|
|
|
@@ -193,8 +190,6 @@ What stretches of a transcript cost, read off the prompt counts the server alrea
|
|
|
193
190
|
|
|
194
191
|
Choosing a run's tools before it starts, from the request and the catalogue's names.
|
|
195
192
|
|
|
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
193
|
- `KeywordPreselection` (type) — What `preselectByKeywords` found.
|
|
199
194
|
- `KeywordPreselectOptions` (type) — What `preselectByKeywords` takes besides the catalogue and the request.
|
|
200
195
|
- `PRESELECT_SCHEMA` — The shape a preselector's answer is held to where the server takes a schema: `{ tools: [...] }`.
|
|
@@ -224,10 +219,7 @@ Everything about a request failing that is not about what the request said.
|
|
|
224
219
|
- `isModelLoading` — Whether a failure is a local server still loading the model, rather than one failing to serve.
|
|
225
220
|
- `isOverflow` — Whether a refusal means the request was too big, rather than merely refused.
|
|
226
221
|
- `isTransient` — Whether a failed request is worth trying again.
|
|
227
|
-
- `LOADING_POLL_MS` — How long to wait between asking a loading server again.
|
|
228
|
-
- `LOADING_TIMEOUT_MS` — How long `runTurn` waits for a model to load unless told otherwise.
|
|
229
222
|
- `SMALLEST_LIKELY_WINDOW` — The smallest window worth believing in, and the floor under `runTurn`'s guard.
|
|
230
|
-
- `sleep` — A delay an abort cuts short, rejecting rather than resolving early.
|
|
231
223
|
|
|
232
224
|
### run-calls
|
|
233
225
|
|
|
@@ -345,7 +337,6 @@ Telling a model's scratchpad from its answer when both arrive in `content`.
|
|
|
345
337
|
|
|
346
338
|
### tokens
|
|
347
339
|
|
|
348
|
-
- `CHARS_PER_TOKEN` — The characters one token is taken to be, where nothing has measured it.
|
|
349
340
|
- `ContextBreakdown` (type) — What a request is made of, by the part of it a consumer can actually do something about.
|
|
350
341
|
- `ContextBreakdownOptions` (type) — What `contextTokens` takes besides the request.
|
|
351
342
|
- `compact` — A token count as a message shows it: 1234 → "1.2k".
|
|
@@ -356,7 +347,6 @@ Telling a model's scratchpad from its answer when both arrive in `content`.
|
|
|
356
347
|
- `requestChars` — How many characters a request is worth: the walk `requestTokens` divides, without the division.
|
|
357
348
|
- `requestTokens` — What this request will cost the window, in tokens, near enough.
|
|
358
349
|
- `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.
|
|
360
350
|
|
|
361
351
|
### tool-calls
|
|
362
352
|
|
|
@@ -385,8 +375,6 @@ Reading what a model meant by a tool call when it did not write one cleanly.
|
|
|
385
375
|
- `LOAD_TOOLS_DEFINITION` — One object for the life of the process — the agent loop asks for it on every iteration.
|
|
386
376
|
- `loadedTools` — A tool array with newly loaded definitions appended, in the order they were loaded.
|
|
387
377
|
- `loadResult` — What `load_tools` reports back: the descriptions, now that they are worth their tokens.
|
|
388
|
-
- `MAX_CARRIED` — The most a conversation carries between turns.
|
|
389
|
-
- `MAX_PER_LOAD` — The most a single `load_tools` call may pull in.
|
|
390
378
|
- `orderTools` — The tool array in a stable order, so the same set of tools renders the same way twice.
|
|
391
379
|
- `PROXY_TOOLS` — The whole tool array of a proxied run, `load_tools` then `call_tool`, frozen because it is shared.
|
|
392
380
|
- `proxiedCall` — The tool a `call_tool` names and the arguments to run it with, or a throw the model can read.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cubicecho/agent-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.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",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsc -p tsconfig.build.json && node scripts/llms-txt.mjs",
|
|
49
|
-
"
|
|
49
|
+
"prepack": "npm run build",
|
|
50
50
|
"check": "npm run check:biome && npm run check:types",
|
|
51
51
|
"check:biome": "biome check --write .",
|
|
52
|
-
"check:types": "tsc
|
|
52
|
+
"check:types": "tsc --noEmit",
|
|
53
53
|
"test": "vitest run",
|
|
54
54
|
"test:watch": "vitest",
|
|
55
55
|
"llms": "node scripts/llms-txt.mjs",
|