@buoy-gg/agent-core 7.0.36 → 7.0.38
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 +13 -9
- package/lib/commonjs/catalog/catalog.g.js +93 -6
- package/lib/commonjs/catalog/catalog.g.js.map +1 -1
- package/lib/commonjs/catalog/catalog.source.json +106 -4
- package/lib/commonjs/catalog/catalog.types.g.js +3 -3
- package/lib/commonjs/catalog/catalog.types.g.js.map +1 -1
- package/lib/commonjs/catalog/toProviderTools.js +3 -1
- package/lib/commonjs/catalog/toProviderTools.js.map +1 -1
- package/lib/commonjs/effects/ledger.js +13 -1
- package/lib/commonjs/effects/ledger.js.map +1 -1
- package/lib/commonjs/engine/evidence.js +113 -0
- package/lib/commonjs/engine/evidence.js.map +1 -0
- package/lib/commonjs/engine/historyBudget.js +158 -55
- package/lib/commonjs/engine/historyBudget.js.map +1 -1
- package/lib/commonjs/engine/retrieve.js +214 -0
- package/lib/commonjs/engine/retrieve.js.map +1 -0
- package/lib/commonjs/engine/runAgentTurn.js +364 -94
- package/lib/commonjs/engine/runAgentTurn.js.map +1 -1
- package/lib/commonjs/engine/systemPrompt.js +31 -1
- package/lib/commonjs/engine/systemPrompt.js.map +1 -1
- package/lib/commonjs/engine/tokenCalibration.js +81 -0
- package/lib/commonjs/engine/tokenCalibration.js.map +1 -0
- package/lib/commonjs/engine/verify.js +300 -0
- package/lib/commonjs/engine/verify.js.map +1 -0
- package/lib/commonjs/index.js +16 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/providers/anthropic.js +12 -3
- package/lib/commonjs/providers/anthropic.js.map +1 -1
- package/lib/commonjs/providers/openai.js +11 -3
- package/lib/commonjs/providers/openai.js.map +1 -1
- package/lib/commonjs/providers/problem.js +98 -0
- package/lib/commonjs/providers/problem.js.map +1 -0
- package/lib/commonjs/providers/sse.js +6 -5
- package/lib/commonjs/providers/sse.js.map +1 -1
- package/lib/commonjs/providers/transport.js +20 -4
- package/lib/commonjs/providers/transport.js.map +1 -1
- package/lib/commonjs/providers/xhrStream.js +3 -0
- package/lib/commonjs/providers/xhrStream.js.map +1 -1
- package/lib/commonjs/session.js +32 -5
- package/lib/commonjs/session.js.map +1 -1
- package/lib/module/catalog/catalog.g.js +93 -6
- package/lib/module/catalog/catalog.g.js.map +1 -1
- package/lib/module/catalog/catalog.source.json +106 -4
- package/lib/module/catalog/catalog.types.g.js +3 -3
- package/lib/module/catalog/catalog.types.g.js.map +1 -1
- package/lib/module/catalog/toProviderTools.js +3 -1
- package/lib/module/catalog/toProviderTools.js.map +1 -1
- package/lib/module/effects/ledger.js +13 -1
- package/lib/module/effects/ledger.js.map +1 -1
- package/lib/module/engine/evidence.js +107 -0
- package/lib/module/engine/evidence.js.map +1 -0
- package/lib/module/engine/historyBudget.js +158 -54
- package/lib/module/engine/historyBudget.js.map +1 -1
- package/lib/module/engine/retrieve.js +210 -0
- package/lib/module/engine/retrieve.js.map +1 -0
- package/lib/module/engine/runAgentTurn.js +365 -96
- package/lib/module/engine/runAgentTurn.js.map +1 -1
- package/lib/module/engine/systemPrompt.js +30 -1
- package/lib/module/engine/systemPrompt.js.map +1 -1
- package/lib/module/engine/tokenCalibration.js +75 -0
- package/lib/module/engine/tokenCalibration.js.map +1 -0
- package/lib/module/engine/verify.js +292 -0
- package/lib/module/engine/verify.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/providers/anthropic.js +12 -3
- package/lib/module/providers/anthropic.js.map +1 -1
- package/lib/module/providers/openai.js +11 -3
- package/lib/module/providers/openai.js.map +1 -1
- package/lib/module/providers/problem.js +92 -0
- package/lib/module/providers/problem.js.map +1 -0
- package/lib/module/providers/sse.js +6 -5
- package/lib/module/providers/sse.js.map +1 -1
- package/lib/module/providers/transport.js +20 -4
- package/lib/module/providers/transport.js.map +1 -1
- package/lib/module/providers/xhrStream.js +3 -0
- package/lib/module/providers/xhrStream.js.map +1 -1
- package/lib/module/session.js +33 -6
- package/lib/module/session.js.map +1 -1
- package/lib/typescript/catalog/catalog.g.d.ts +2 -2
- package/lib/typescript/catalog/catalog.g.d.ts.map +1 -1
- package/lib/typescript/catalog/catalog.types.g.d.ts +3 -3
- package/lib/typescript/catalog/catalog.types.g.d.ts.map +1 -1
- package/lib/typescript/catalog/toProviderTools.d.ts.map +1 -1
- package/lib/typescript/effects/ledger.d.ts +18 -0
- package/lib/typescript/effects/ledger.d.ts.map +1 -1
- package/lib/typescript/engine/evidence.d.ts +67 -0
- package/lib/typescript/engine/evidence.d.ts.map +1 -0
- package/lib/typescript/engine/historyBudget.d.ts +31 -8
- package/lib/typescript/engine/historyBudget.d.ts.map +1 -1
- package/lib/typescript/engine/retrieve.d.ts +32 -0
- package/lib/typescript/engine/retrieve.d.ts.map +1 -0
- package/lib/typescript/engine/runAgentTurn.d.ts +96 -2
- package/lib/typescript/engine/runAgentTurn.d.ts.map +1 -1
- package/lib/typescript/engine/systemPrompt.d.ts +39 -0
- package/lib/typescript/engine/systemPrompt.d.ts.map +1 -1
- package/lib/typescript/engine/tokenCalibration.d.ts +46 -0
- package/lib/typescript/engine/tokenCalibration.d.ts.map +1 -0
- package/lib/typescript/engine/verify.d.ts +67 -0
- package/lib/typescript/engine/verify.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +4 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/providers/anthropic.d.ts.map +1 -1
- package/lib/typescript/providers/openai.d.ts.map +1 -1
- package/lib/typescript/providers/problem.d.ts +50 -0
- package/lib/typescript/providers/problem.d.ts.map +1 -0
- package/lib/typescript/providers/sse.d.ts +4 -1
- package/lib/typescript/providers/sse.d.ts.map +1 -1
- package/lib/typescript/providers/transport.d.ts +8 -0
- package/lib/typescript/providers/transport.d.ts.map +1 -1
- package/lib/typescript/providers/types.d.ts +14 -0
- package/lib/typescript/providers/types.d.ts.map +1 -1
- package/lib/typescript/providers/xhrStream.d.ts +2 -0
- package/lib/typescript/providers/xhrStream.d.ts.map +1 -1
- package/lib/typescript/session.d.ts +15 -2
- package/lib/typescript/session.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +6 -0
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/LICENSE +0 -58
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"historyBudget.d.ts","sourceRoot":"","sources":["../../../src/engine/historyBudget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"historyBudget.d.ts","sourceRoot":"","sources":["../../../src/engine/historyBudget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,QAAS,CAAC;AACzC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,SAAU,CAAC;AAC1C,eAAO,MAAM,iBAAiB,QAA+C,CAAC;AAC9E,eAAO,MAAM,iBAAiB,QAA+C,CAAC;AAK9E,wBAAgB,WAAW,CAAC,CAAC,EAAE,YAAY,GAAG,MAAM,CAMnD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,YAAY,UAAO,GAAG,YAAY,EAAE,CAiD9F;AA2ED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,YAAY,EAAE,EACxB,aAAa,GAAE,MAAgC;AAC/C,mGAAmG;AACnG,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAClC;IACD,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,aAAa,EAAE,MAAM,CAAC;CACvB,CAcA;AAED,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAEpE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,YAAY,EAAE,EACxB,OAAO,EAAE,MAAM;AACf;;;;GAIG;AACH,GAAG,GAAE,MAA0B;AAC/B,sEAAsE;AACtE,aAAa,GAAE,MAAgC;AAC/C,mGAAmG;AACnG,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAClC;IAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CA4D5E"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ask-buoy.retrieve` — read part of a kept result back. See evidence.ts.
|
|
3
|
+
*
|
|
4
|
+
* Four ways in, chosen so the model never needs the whole thing again:
|
|
5
|
+
*
|
|
6
|
+
* - nothing but `ref` → the SHAPE: top-level keys with type and size, so the
|
|
7
|
+
* next call can name a path. Handing back the full
|
|
8
|
+
* text would only hit the same cap that cut it.
|
|
9
|
+
* - `path` → the value at a dotted / slash path ("stats.0.base_stat",
|
|
10
|
+
* "/moves/3/move/name"). Arrays index by number.
|
|
11
|
+
* - `slice: [a, b]` → a window: items of an array, characters of a string.
|
|
12
|
+
* Combines with `path`.
|
|
13
|
+
* - `pattern` → a literal, case-insensitive substring search over the
|
|
14
|
+
* pretty-printed text; matching lines with
|
|
15
|
+
* `contextLines` (default 2) around each. Not a regex:
|
|
16
|
+
* a model that means "height" should not have to
|
|
17
|
+
* escape anything, and an executable pattern over a
|
|
18
|
+
* store of app data is a surface nobody asked for.
|
|
19
|
+
*
|
|
20
|
+
* Every result is capped at the same size as any other tool result, and the
|
|
21
|
+
* engine never stashes a retrieve result — a retrieve of a retrieve is a loop.
|
|
22
|
+
*/
|
|
23
|
+
import type { EvidenceStore } from "./evidence";
|
|
24
|
+
export interface RetrieveParams {
|
|
25
|
+
ref: string;
|
|
26
|
+
path?: string;
|
|
27
|
+
slice?: [number, number];
|
|
28
|
+
pattern?: string;
|
|
29
|
+
contextLines?: number;
|
|
30
|
+
}
|
|
31
|
+
export declare function retrieveEvidence(store: EvidenceStore | undefined, params: RetrieveParams): unknown;
|
|
32
|
+
//# sourceMappingURL=retrieve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieve.d.ts","sourceRoot":"","sources":["../../../src/engine/retrieve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAMD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAqDlG"}
|
|
@@ -22,6 +22,10 @@ import { EffectLedger } from "../effects/ledger";
|
|
|
22
22
|
import { type AskBuoyPolicy } from "../policy/policy";
|
|
23
23
|
import { digestOf } from "../effects/digest";
|
|
24
24
|
import { type Block } from "../blocks/types";
|
|
25
|
+
import { TokenCalibration } from "./tokenCalibration";
|
|
26
|
+
import { type EvidenceStore } from "./evidence";
|
|
27
|
+
import { type Verification } from "./verify";
|
|
28
|
+
import type { Procedure } from "./systemPrompt";
|
|
25
29
|
export type TurnEvent = {
|
|
26
30
|
type: "text";
|
|
27
31
|
delta: string;
|
|
@@ -60,6 +64,13 @@ export type TurnEvent = {
|
|
|
60
64
|
| {
|
|
61
65
|
type: "history-trimmed";
|
|
62
66
|
droppedRounds: number;
|
|
67
|
+
/**
|
|
68
|
+
* Of those, rounds that had made a change still applied — dropped only
|
|
69
|
+
* because nothing else was left. The caption should say so: the change
|
|
70
|
+
* is still in the app and still in the changes bar, but the model no
|
|
71
|
+
* longer remembers making it.
|
|
72
|
+
*/
|
|
73
|
+
droppedPinned?: number;
|
|
63
74
|
} | {
|
|
64
75
|
type: "tool-start";
|
|
65
76
|
id: string;
|
|
@@ -95,6 +106,17 @@ export type TurnEvent = {
|
|
|
95
106
|
*/
|
|
96
107
|
result?: string;
|
|
97
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* The outcome check for a write that has one (engine/verify.ts), after its
|
|
111
|
+
* receipt: the row updates in place to "Verified" / "Done · not yet
|
|
112
|
+
* visible" / "Done · check failed". Its own event, not a second tool-end,
|
|
113
|
+
* so a consumer counting ends per call is not fooled.
|
|
114
|
+
*/
|
|
115
|
+
| {
|
|
116
|
+
type: "tool-verified";
|
|
117
|
+
id: string;
|
|
118
|
+
verification: Verification;
|
|
119
|
+
}
|
|
98
120
|
/** A block to render — a receipt from a tool result, or a model-authored block. */
|
|
99
121
|
| {
|
|
100
122
|
type: "block";
|
|
@@ -117,6 +139,18 @@ export type TurnEvent = {
|
|
|
117
139
|
type: "error";
|
|
118
140
|
message: string;
|
|
119
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* The model request failed before producing anything and is being sent
|
|
144
|
+
* again after a wait — see THROTTLE_RETRIES. Yielded so the thinking strip
|
|
145
|
+
* can say "endpoint busy, retrying in 2 s" rather than sit still.
|
|
146
|
+
*/
|
|
147
|
+
| {
|
|
148
|
+
type: "retrying";
|
|
149
|
+
reason: "throttled" | "overflow";
|
|
150
|
+
attempt: number;
|
|
151
|
+
maxAttempts: number;
|
|
152
|
+
inMs: number;
|
|
153
|
+
}
|
|
120
154
|
/**
|
|
121
155
|
* Token usage for one provider request, when the provider reports it.
|
|
122
156
|
* `cacheRead`/`cacheWrite` are the prompt-cache counters (see TokenUsage —
|
|
@@ -133,6 +167,36 @@ export type TurnEvent = {
|
|
|
133
167
|
model?: string;
|
|
134
168
|
} | {
|
|
135
169
|
type: "done";
|
|
170
|
+
stopReason: StopReason;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Why the turn ended — the machine-readable half of the notices. The text in
|
|
174
|
+
* the notice blocks is unchanged (the eval classifier pins it); this is for a
|
|
175
|
+
* host, the bank and the desktop, which used to have to grep the prose.
|
|
176
|
+
*/
|
|
177
|
+
export type StopReason =
|
|
178
|
+
/** The model wrote its answer and stopped calling tools. */
|
|
179
|
+
"answered"
|
|
180
|
+
/** An Ask block (the model's or the gate's) ended the turn; the answer comes as the next user message. */
|
|
181
|
+
| "awaiting-user"
|
|
182
|
+
/** The model→tools→model cap (policy.maxSteps, default 12). */
|
|
183
|
+
| "step-cap"
|
|
184
|
+
/** The wall-clock cap, approval time excluded. */
|
|
185
|
+
| "time-cap"
|
|
186
|
+
/** The user pressed Stop. */
|
|
187
|
+
| "stopped"
|
|
188
|
+
/** `app.reloadApp` ran; the JS realm is about to die and nothing after it can be answered. */
|
|
189
|
+
| "realm-died"
|
|
190
|
+
/** The stream ended without the provider saying it finished, or the model ran out of room — recoverable with Continue. */
|
|
191
|
+
| "incomplete"
|
|
192
|
+
/** A provider error, after any retries. */
|
|
193
|
+
| "error"
|
|
194
|
+
/** The conversation was reset while this turn was getting ready; nothing was sent. */
|
|
195
|
+
| "superseded";
|
|
196
|
+
export type ApprovalAnswer = boolean | {
|
|
197
|
+
approved: boolean;
|
|
198
|
+
reason?: string;
|
|
199
|
+
trust?: boolean;
|
|
136
200
|
};
|
|
137
201
|
export interface RunTurnInput {
|
|
138
202
|
provider: Provider;
|
|
@@ -158,7 +222,12 @@ export interface RunTurnInput {
|
|
|
158
222
|
/** Live tool ids from `listToolActions()`, so absent tools are never offered. */
|
|
159
223
|
availableToolIds?: string[];
|
|
160
224
|
availableActions?: Record<string, string[]>;
|
|
161
|
-
/**
|
|
225
|
+
/**
|
|
226
|
+
* Resolves once the user answers the pending call — a bare boolean, or the
|
|
227
|
+
* richer shape: a note with a decline goes to the model verbatim (one round
|
|
228
|
+
* trip saved), and `trust` on an approval waives the card for that
|
|
229
|
+
* tool.action for the rest of the conversation. See `trusted`.
|
|
230
|
+
*/
|
|
162
231
|
requestApproval?: (input: {
|
|
163
232
|
id: string;
|
|
164
233
|
toolId: string;
|
|
@@ -183,7 +252,19 @@ export interface RunTurnInput {
|
|
|
183
252
|
* answered live never needs it. Absent when the target cannot be read.
|
|
184
253
|
*/
|
|
185
254
|
targetDigest?: string;
|
|
186
|
-
}) => Promise<
|
|
255
|
+
}) => Promise<ApprovalAnswer>;
|
|
256
|
+
/**
|
|
257
|
+
* `toolId.action` keys the user has waived the approval card for in THIS
|
|
258
|
+
* conversation ("Allow for this chat"). Session-owned and mutated here when
|
|
259
|
+
* an answer carries `trust`. It suppresses `needs-approval` only — `deny`,
|
|
260
|
+
* `allow`, `readOnly` and release refusals are the app saying no, not the
|
|
261
|
+
* app asking, and a waiver never widens what the agent can reach. The
|
|
262
|
+
* Strands HITL handler calls the same thing `enableTrust`, and keeps the
|
|
263
|
+
* same rule: a negated tool cannot be trusted.
|
|
264
|
+
*/
|
|
265
|
+
trusted?: Set<string>;
|
|
266
|
+
/** The app's procedures this device can follow — served by `ask-buoy.openProcedure`. See systemPrompt.ts `Procedure`. */
|
|
267
|
+
procedures?: Procedure[];
|
|
187
268
|
signal?: AbortSignal;
|
|
188
269
|
/**
|
|
189
270
|
* Every http(s) URL this CONVERSATION has read out of a tool result. Owned
|
|
@@ -195,6 +276,19 @@ export interface RunTurnInput {
|
|
|
195
276
|
* fresh per-turn set.
|
|
196
277
|
*/
|
|
197
278
|
seenUrls?: Set<string>;
|
|
279
|
+
/**
|
|
280
|
+
* Where every result's full text is kept for `ask-buoy.retrieve` — see
|
|
281
|
+
* engine/evidence.ts. Session-owned, like `seenUrls`; absent (tests,
|
|
282
|
+
* one-shot callers) means results are not retrievable and the markers say
|
|
283
|
+
* so.
|
|
284
|
+
*/
|
|
285
|
+
evidence?: EvidenceStore;
|
|
286
|
+
/**
|
|
287
|
+
* The session's measured chars-per-token (engine/tokenCalibration.ts). Read
|
|
288
|
+
* for every budget and fed after every usage report. Absent means the
|
|
289
|
+
* default ratio, uncorrected.
|
|
290
|
+
*/
|
|
291
|
+
calibration?: TokenCalibration;
|
|
198
292
|
}
|
|
199
293
|
export declare function runAgentTurn(input: RunTurnInput): AsyncGenerator<TurnEvent, AgentMessage[], void>;
|
|
200
294
|
export { digestOf };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runAgentTurn.d.ts","sourceRoot":"","sources":["../../../src/engine/runAgentTurn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAoB,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAOzF,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EAKT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAG5E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"runAgentTurn.d.ts","sourceRoot":"","sources":["../../../src/engine/runAgentTurn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAoB,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAOzF,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EAKT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,kBA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UAAU,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,wCAAwC;IACxC,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,MAAM,MAAM,kBAAkB,GAC1B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC7B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAmEzF"}
|
|
@@ -35,10 +35,47 @@ export interface ContextPack {
|
|
|
35
35
|
digest?: Record<string, unknown>;
|
|
36
36
|
/** Anything else the app wants to say to the model. */
|
|
37
37
|
extra?: string;
|
|
38
|
+
/**
|
|
39
|
+
* App-author procedures the model can open ON DEMAND — see `Procedure`.
|
|
40
|
+
* Only `id — summary` goes in every prompt; the body is loaded by
|
|
41
|
+
* `ask-buoy.openProcedure` when the task matches, so a long playbook costs
|
|
42
|
+
* nothing until it is needed.
|
|
43
|
+
*/
|
|
44
|
+
procedures?: Procedure[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A playbook for this app: how to put it into a state, reproduce a ticket,
|
|
48
|
+
* or read something that is not obvious. Written by the app's developers,
|
|
49
|
+
* loaded when the model decides it applies. Borrowed from Strands' AgentSkills
|
|
50
|
+
* (SKILL.md name + description in the prompt, body on activation) — in-memory
|
|
51
|
+
* objects, no filesystem.
|
|
52
|
+
*
|
|
53
|
+
* A procedure GUIDES tool use; it grants nothing. Every step it names still
|
|
54
|
+
* goes through the same catalog, policy, approval card and ledger as any other
|
|
55
|
+
* call, and the outcome checks (engine/verify.ts) still run.
|
|
56
|
+
*/
|
|
57
|
+
export interface Procedure {
|
|
58
|
+
/** Stable, short, what the model calls it by: "expire-subscription". */
|
|
59
|
+
id: string;
|
|
60
|
+
title: string;
|
|
61
|
+
/** One line, shown in every prompt. Make it say WHEN to open this. */
|
|
62
|
+
summary: string;
|
|
63
|
+
/** The steps, preconditions, data conventions and what "done" looks like. Plain text or markdown. */
|
|
64
|
+
body: string;
|
|
65
|
+
/**
|
|
66
|
+
* Tool ids this procedure needs (`"zustand"`, `"network"`). It is only
|
|
67
|
+
* listed when every one is installed on this device — a procedure that
|
|
68
|
+
* names a tool the app does not have is one the model cannot follow.
|
|
69
|
+
*/
|
|
70
|
+
requires?: string[];
|
|
71
|
+
/** The app/build it was written against, so a stale one can say so. */
|
|
72
|
+
version?: string;
|
|
38
73
|
}
|
|
39
74
|
export interface SystemPromptInput {
|
|
40
75
|
catalog: ToolDescriptor[];
|
|
41
76
|
context?: ContextPack;
|
|
77
|
+
/** Live tool ids, so a procedure that needs a tool this device lacks is not offered. */
|
|
78
|
+
availableToolIds?: string[];
|
|
42
79
|
isRelease: boolean;
|
|
43
80
|
readOnly: boolean;
|
|
44
81
|
/**
|
|
@@ -60,6 +97,8 @@ export interface SystemPromptInput {
|
|
|
60
97
|
platform?: string;
|
|
61
98
|
}
|
|
62
99
|
export declare function buildSystemPrompt(input: SystemPromptInput): string;
|
|
100
|
+
/** The procedures this device can follow: every `requires` tool installed (or no `requires` at all). */
|
|
101
|
+
export declare function listableProcedures(procedures: Procedure[] | undefined, availableToolIds: string[] | undefined): Procedure[];
|
|
63
102
|
/**
|
|
64
103
|
* The per-turn block: what the app is showing at the moment the user typed.
|
|
65
104
|
* Rendered AFTER the cached prompt (see ProviderRequest.systemVolatile), so it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemPrompt.d.ts","sourceRoot":"","sources":["../../../src/engine/systemPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,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EAAE,WAAW,CAAC;IACtB,wFAAwF;IACxF,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAClC,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAsIlE;AAED,wGAAwG;AACxG,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,SAAS,EAAE,CAK3H;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;AACzC;;;;;;;;;;;;GAYG;AACH,OAAO,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,EAAE,GAC7C,MAAM,CAgBR"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many characters make a token — measured, not assumed.
|
|
3
|
+
*
|
|
4
|
+
* Every budget in this engine is kept in characters because that is what a
|
|
5
|
+
* string has, but every LIMIT that matters is in tokens: the provider's
|
|
6
|
+
* context window, the reply room, the cost. The conversion was a constant
|
|
7
|
+
* (4) everywhere. English prose does run near 4; the tool results this agent
|
|
8
|
+
* actually sends are JSON, which tokenizes nearer 3 — so a request the budget
|
|
9
|
+
* called 100k tokens could be 130k, on a gateway whose window is 128k. The
|
|
10
|
+
* proactive budget was optimistic in exactly the sessions it exists for.
|
|
11
|
+
*
|
|
12
|
+
* The provider tells us the truth after every request: its usage report
|
|
13
|
+
* carries the prompt's token count, and the engine knows how many characters
|
|
14
|
+
* it sent. One division gives the ratio for THIS conversation on THIS
|
|
15
|
+
* tokenizer; an exponential average smooths a single odd request (a round
|
|
16
|
+
* that was all prose, or all ids). Strands' design 0008 does the same in
|
|
17
|
+
* reverse — a known token baseline plus an estimate of the delta — and its
|
|
18
|
+
* decision record says why: public limits should be in LLM-native units.
|
|
19
|
+
*
|
|
20
|
+
* Clamped, because a wrong sample must not be able to blow the budget wide
|
|
21
|
+
* open (a gateway that reports nonsense usage) or shrink it to nothing.
|
|
22
|
+
*/
|
|
23
|
+
import type { TokenUsage } from "../providers/types";
|
|
24
|
+
export declare const DEFAULT_CHARS_PER_TOKEN = 4;
|
|
25
|
+
export declare class TokenCalibration {
|
|
26
|
+
private ratio;
|
|
27
|
+
private samples;
|
|
28
|
+
/** Characters per token, as currently believed. */
|
|
29
|
+
get charsPerToken(): number;
|
|
30
|
+
get sampleCount(): number;
|
|
31
|
+
/** Fold in one request: what was sent, and what the provider counted. */
|
|
32
|
+
observe(requestChars: number, promptTokens: number): void;
|
|
33
|
+
/** Characters a token budget allows, at the believed ratio. */
|
|
34
|
+
chars(tokens: number): number;
|
|
35
|
+
reset(): void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The whole prompt's token count from a usage report.
|
|
39
|
+
*
|
|
40
|
+
* Anthropic reports the cached and freshly-written prefix SEPARATELY from
|
|
41
|
+
* `input`; OpenAI-shaped providers fold `cached_tokens` INTO `prompt_tokens`.
|
|
42
|
+
* See TokenUsage. Adding on the wrong protocol double-counts the cache and
|
|
43
|
+
* halves the believed ratio.
|
|
44
|
+
*/
|
|
45
|
+
export declare function promptTokensOf(usage: TokenUsage, protocol: "anthropic" | "openai"): number;
|
|
46
|
+
//# sourceMappingURL=tokenCalibration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenCalibration.d.ts","sourceRoot":"","sources":["../../../src/engine/tokenCalibration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAQzC,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,OAAO,CAAK;IAEpB,mDAAmD;IACnD,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,yEAAyE;IACzE,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAOzD,+DAA+D;IAC/D,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAI7B,KAAK,IAAI,IAAI;CAId;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,MAAM,CAG1F"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outcome verification: after a write lands, check that what the user asked
|
|
3
|
+
* for actually happened — not just that the adapter said ok.
|
|
4
|
+
*
|
|
5
|
+
* "Install override → `{ok:true}`" was reported as done. But installed ≠ a
|
|
6
|
+
* request has used it ≠ the cart shows it, and each step can succeed while
|
|
7
|
+
* the outcome fails: the app had the old response cached, the screen kept
|
|
8
|
+
* saying In Stock, and the reply said "the item is now sold out". Strands'
|
|
9
|
+
* GoalLoop frames this as a completion criterion with bounded correction; the
|
|
10
|
+
* criterion borrowed here is DETERMINISTIC — a read-back the engine performs
|
|
11
|
+
* with the same tools the model has — not a second model judging the reply.
|
|
12
|
+
*
|
|
13
|
+
* Three outcomes, each honest about what it is:
|
|
14
|
+
*
|
|
15
|
+
* - `verified` — the read-back shows the requested state.
|
|
16
|
+
* - `unverified` — the write landed but the read-back cannot yet show the
|
|
17
|
+
* outcome (an override is installed but no request has
|
|
18
|
+
* matched it). Reported as exactly that, never as proof.
|
|
19
|
+
* - `failed` — the read-back contradicts the write. The model is told
|
|
20
|
+
* what was found and asked for ONE correction through the
|
|
21
|
+
* same policy and ledger path; never to repeat the write.
|
|
22
|
+
*
|
|
23
|
+
* Bounded by construction: each verifier makes a few reads, polls for at most
|
|
24
|
+
* `waitMs` (small, per action), and stops on the turn's abort signal. It never
|
|
25
|
+
* dispatches a write, and its reads are not stashed as evidence. Undefined
|
|
26
|
+
* means "no opinion" — nothing is appended, which is what every action
|
|
27
|
+
* without a verifier gets.
|
|
28
|
+
*/
|
|
29
|
+
import type { DispatchFn } from "../types";
|
|
30
|
+
export type VerificationStatus = "verified" | "unverified" | "failed";
|
|
31
|
+
export interface Verification {
|
|
32
|
+
status: VerificationStatus;
|
|
33
|
+
/** One plain sentence for the row and the model. */
|
|
34
|
+
detail: string;
|
|
35
|
+
}
|
|
36
|
+
export interface VerifyInput {
|
|
37
|
+
toolId: string;
|
|
38
|
+
action: string;
|
|
39
|
+
params: Record<string, unknown>;
|
|
40
|
+
result: unknown;
|
|
41
|
+
dispatch: DispatchFn;
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
/**
|
|
44
|
+
* The store / cache read the engine already took after the write for the
|
|
45
|
+
* receipt (`captureStoreState`), so the zustand and query verifiers do not
|
|
46
|
+
* read the same thing twice. Absent → the verifier reads it itself.
|
|
47
|
+
*/
|
|
48
|
+
after?: unknown;
|
|
49
|
+
}
|
|
50
|
+
type Verifier = (input: VerifyInput) => Promise<Verification | undefined>;
|
|
51
|
+
/** Every key in `want` present in `have` with an equal (deep) value. Arrays compare whole. */
|
|
52
|
+
export declare function isSubset(want: unknown, have: unknown): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The adapters' path grammar — dotted keys, `[0]`, and the id-addressed
|
|
55
|
+
* `[field=value]` the prompt recommends for list edits ("lines[lineId=seed-1].qty").
|
|
56
|
+
* A mirror of shared/sync/valuePath.ts, kept here because agent-core imports
|
|
57
|
+
* nothing. The first live run wrote exactly that form and this resolver, then
|
|
58
|
+
* dotted-only, reported a landed edit as "did not take".
|
|
59
|
+
*/
|
|
60
|
+
export declare function atPath(root: unknown, path: string): unknown;
|
|
61
|
+
export declare const VERIFIERS: Readonly<Record<string, Verifier>>;
|
|
62
|
+
/** Run the verifier for this action, if there is one. Never throws: a read that blows up is "no opinion". */
|
|
63
|
+
export declare function verifyOutcome(input: VerifyInput): Promise<Verification | undefined>;
|
|
64
|
+
/** The trailer the model reads. Kept in the `[Buoy] ` trailer form the bench's parser splits on. */
|
|
65
|
+
export declare function verificationTrailer(v: Verification): string;
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/engine/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEtE,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,UAAU,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAAC;AA6B1E,8FAA8F;AAC9F,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAS9D;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAqB3D;AAiFD,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAMxD,CAAC;AAEF,6GAA6G;AAC7G,wBAAsB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAQzF;AAED,oGAAoG;AACpG,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,YAAY,GAAG,MAAM,CAS3D"}
|
|
@@ -17,8 +17,10 @@ export { normalizeParams, aliasNote, hashQueryKey } from "./catalog/normalizePar
|
|
|
17
17
|
export { createAnthropicProvider } from "./providers/anthropic";
|
|
18
18
|
export { createOpenAIProvider } from "./providers/openai";
|
|
19
19
|
export type { AgentMessage, Provider, ProviderConfig, ProviderRequest, StreamEvent, ThinkingBlock, TokenUsage, ToolCall, ToolResult, } from "./providers/types";
|
|
20
|
-
export { runAgentTurn, runGatedAction, readTargetDigest, digestOf, type GatedActionInput, type GatedActionOutcome, type RunTurnInput, type TurnEvent, } from "./engine/runAgentTurn";
|
|
21
|
-
export {
|
|
20
|
+
export { runAgentTurn, runGatedAction, readTargetDigest, digestOf, type GatedActionInput, type GatedActionOutcome, type RunTurnInput, type TurnEvent, type ApprovalAnswer, type StopReason, } from "./engine/runAgentTurn";
|
|
21
|
+
export { EvidenceStore, type EvidenceEntry } from "./engine/evidence";
|
|
22
|
+
export { TokenCalibration } from "./engine/tokenCalibration";
|
|
23
|
+
export { buildLiveBlock, buildSystemPrompt, type ContextPack, type Procedure, type SystemPromptInput, } from "./engine/systemPrompt";
|
|
22
24
|
export { buildContextDigest, buildLiveContext, type BuildContextInput, } from "./context/buildContextPack";
|
|
23
25
|
export { EffectLedger, isReversible, type AppliedEffect, type LedgerEntry, type RevertOutcome, } from "./effects/ledger";
|
|
24
26
|
export { humanise, titleCall, toolTitle } from "./policy/labels";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,UAAU,EACV,cAAc,EACd,QAAQ,GACT,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EACL,eAAe,EACf,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,aAAa,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,sBAAsB,GAC5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,aAAa,EACb,cAAc,EACd,KAAK,gBAAgB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAErF,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,YAAY,EACV,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,eAAe,EACf,WAAW,EACX,aAAa,EACb,UAAU,EACV,QAAQ,EACR,UAAU,GACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,QAAQ,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thropic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,EAEV,QAAQ,EACR,cAAc,EAMf,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,EAEV,QAAQ,EACR,cAAc,EAMf,MAAM,SAAS,CAAC;AA2EjB,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,cAAc,GAAG,QAAQ,CAySxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/providers/openai.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAEV,QAAQ,EACR,cAAc,EAIf,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/providers/openai.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAEV,QAAQ,EACR,cAAc,EAIf,MAAM,SAAS,CAAC;AA8DjB,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,QAAQ,CAkNrE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What kind of failure a provider reported — decided once, from the status,
|
|
3
|
+
* the error type and the message, so the engine can act on the KIND rather
|
|
4
|
+
* than grep a string.
|
|
5
|
+
*
|
|
6
|
+
* Only two kinds are acted on, and both only when nothing has been generated:
|
|
7
|
+
*
|
|
8
|
+
* - `throttled` — 429 / 529 / 503, a `rate_limit_error` or `overloaded_error`
|
|
9
|
+
* frame, or a body that says so. Waiting and asking again is the right move;
|
|
10
|
+
* the request never reached a model.
|
|
11
|
+
* - `overflow` — the provider refused the request as too big. Trimming older
|
|
12
|
+
* history and asking once more is the right move; the proactive budget is
|
|
13
|
+
* an estimate (chars ÷ 4) and JSON tokenizes worse than prose.
|
|
14
|
+
*
|
|
15
|
+
* Everything else — auth, a bad schema, an unknown model, a mid-answer
|
|
16
|
+
* `api_error` — is reported and NOT retried. The phrase lists are the union
|
|
17
|
+
* observed across provider responses by the Strands SDK (harness-sdk
|
|
18
|
+
* `381ab48`, `models/anthropic.ts` + `models/openai/errors.ts`, Apache-2.0),
|
|
19
|
+
* matched case-insensitively on the lowered message.
|
|
20
|
+
*/
|
|
21
|
+
export type ProblemKind = "throttled" | "overflow" | "auth" | "other";
|
|
22
|
+
export interface StreamProblem {
|
|
23
|
+
kind: ProblemKind;
|
|
24
|
+
/** HTTP status, when the failure was an HTTP response. */
|
|
25
|
+
status?: number;
|
|
26
|
+
/** A `Retry-After` the endpoint sent, in ms — honoured over the backoff. */
|
|
27
|
+
retryAfterMs?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ClassifyInput {
|
|
30
|
+
status?: number;
|
|
31
|
+
/** The provider's error `type` (or OpenAI `code`), when the body was parsed. */
|
|
32
|
+
type?: string;
|
|
33
|
+
message: string;
|
|
34
|
+
/** Raw `Retry-After` header value — seconds, or an HTTP date. */
|
|
35
|
+
retryAfter?: string | null;
|
|
36
|
+
}
|
|
37
|
+
export declare function classifyProblem(input: ClassifyInput): StreamProblem;
|
|
38
|
+
/**
|
|
39
|
+
* `Retry-After` is either delay-seconds or an HTTP-date. Anything unparseable
|
|
40
|
+
* or in the past is undefined, so the caller falls back to its own backoff.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseRetryAfter(value: string | null | undefined): number | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Pull the provider's error `type` out of an error body, for the HTTP path
|
|
45
|
+
* where the body is JSON like `{"error":{"type":"overloaded_error",…}}` or
|
|
46
|
+
* `{"error":{"code":"context_length_exceeded",…}}`. Returns undefined for
|
|
47
|
+
* anything that is not that shape; the message phrases still apply.
|
|
48
|
+
*/
|
|
49
|
+
export declare function errorTypeOf(body: string): string | undefined;
|
|
50
|
+
//# sourceMappingURL=problem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"problem.d.ts","sourceRoot":"","sources":["../../../src/providers/problem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AAEtE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AA8BD,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAoBnE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAQpF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAS5D"}
|
|
@@ -78,7 +78,10 @@ export declare function readSse(response: Response, options?: SseReadOptions): A
|
|
|
78
78
|
* only in the failing case.
|
|
79
79
|
*/
|
|
80
80
|
export declare function nonStreamProblem(response: Response): Promise<string | undefined>;
|
|
81
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Body text for a failed response, trimmed to something a user can read.
|
|
83
|
+
* The detail alone — the transport prefixes the status and classifies it.
|
|
84
|
+
*/
|
|
82
85
|
export declare function errorBody(response: Response): Promise<string>;
|
|
83
86
|
/**
|
|
84
87
|
* The message for a stream that stopped before the provider said it was done.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../../src/providers/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B;;;;;;;OAOG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AA6CD;;;;;;;GAOG;AACH,wBAAuB,UAAU,CAC/B,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,EAC7B,OAAO,GAAE,cAAmB,GAC3B,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAUtC;AAED,wBAAuB,OAAO,CAC5B,QAAQ,EAAE,QAAQ,EAClB,OAAO,GAAE,cAAmB,GAC3B,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CA6EtC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAYtF;AAED
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../../src/providers/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B;;;;;;;OAOG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AA6CD;;;;;;;GAOG;AACH,wBAAuB,UAAU,CAC/B,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,EAC7B,OAAO,GAAE,cAAmB,GAC3B,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAUtC;AAED,wBAAuB,OAAO,CAC5B,QAAQ,EAAE,QAAQ,EAClB,OAAO,GAAE,cAAmB,GAC3B,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CA6EtC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAYtF;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAMnE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,CAI3D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ1F"}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import type { ProviderConfig } from "./types";
|
|
20
20
|
import { type SseEvent, type SseReadOptions } from "./sse";
|
|
21
|
+
import { type StreamProblem } from "./problem";
|
|
21
22
|
export type TransportKind = "fetch" | "xhr" | "auto";
|
|
22
23
|
export interface OpenStreamRequest {
|
|
23
24
|
headers: Record<string, string>;
|
|
@@ -27,6 +28,13 @@ export interface OpenStreamRequest {
|
|
|
27
28
|
export interface OpenStreamResult {
|
|
28
29
|
/** A message when the request failed or is not a stream; frames are empty. */
|
|
29
30
|
problem?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The failure, classified — see providers/problem.ts. Present whenever
|
|
33
|
+
* `problem` is an HTTP failure; a not-a-stream body is `other`. The engine
|
|
34
|
+
* retries `throttled` and `overflow` when nothing was generated, and this
|
|
35
|
+
* is the only place the status and `Retry-After` header are still in hand.
|
|
36
|
+
*/
|
|
37
|
+
problemInfo?: StreamProblem;
|
|
30
38
|
frames(options?: SseReadOptions): AsyncGenerator<SseEvent, void, void>;
|
|
31
39
|
}
|
|
32
40
|
export interface Transport {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/providers/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/providers/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAgC,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAE7E,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;CACxE;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACzD;AAID;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAmFjE"}
|
|
@@ -23,6 +23,13 @@ export interface ToolResult {
|
|
|
23
23
|
/** Already JSON-encoded and truncated by the engine. */
|
|
24
24
|
content: string;
|
|
25
25
|
isError?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The evidence-store ref of the FULL result (engine/evidence.ts), when the
|
|
28
|
+
* session keeps one. Session-local: it never goes on the wire and never to
|
|
29
|
+
* disk; history compression reads it to leave a marker the model can act
|
|
30
|
+
* on. Absent on a result rebuilt from a persisted transcript.
|
|
31
|
+
*/
|
|
32
|
+
ref?: string;
|
|
26
33
|
}
|
|
27
34
|
/**
|
|
28
35
|
* An Anthropic thinking block, kept verbatim.
|
|
@@ -77,6 +84,7 @@ export type StreamOutcome =
|
|
|
77
84
|
* Why a stream failed. `provider` is the model or gateway saying so; the other
|
|
78
85
|
* two are this side deciding the response cannot be trusted.
|
|
79
86
|
*/
|
|
87
|
+
import type { StreamProblem } from "./problem";
|
|
80
88
|
export type StreamErrorKind =
|
|
81
89
|
/** The provider reported it: HTTP error, or an `error` event on a 200. */
|
|
82
90
|
"provider"
|
|
@@ -102,6 +110,12 @@ export type StreamEvent = {
|
|
|
102
110
|
type: "error";
|
|
103
111
|
message: string;
|
|
104
112
|
kind: StreamErrorKind;
|
|
113
|
+
/**
|
|
114
|
+
* What kind of provider failure this was (providers/problem.ts). Only
|
|
115
|
+
* `kind: "provider"` errors carry it. The engine retries `throttled` and
|
|
116
|
+
* `overflow` — and only when the stream had produced nothing yet.
|
|
117
|
+
*/
|
|
118
|
+
problem?: StreamProblem;
|
|
105
119
|
}
|
|
106
120
|
/**
|
|
107
121
|
* The stream ended in a state worth acting on. A provider that cannot say
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/providers/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,oEAAoE;AACpE,MAAM,WAAW,QAAQ;IACvB,+DAA+D;IAC/D,EAAE,EAAE,MAAM,CAAC;IACX,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/providers/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,oEAAoE;AACpE,MAAM,WAAW,QAAQ;IACvB,+DAA+D;IAC/D,EAAE,EAAE,MAAM,CAAC;IACX,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;C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C;IAC1B;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IACrC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,QAAQ,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC1C;;;;;OAKG;IACH,IAAI,CAAC,GAAG,EAAE,eAAe,GAAG,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;CACrE"}
|
|
@@ -29,6 +29,8 @@ export interface XhrStreamResponse {
|
|
|
29
29
|
status: number;
|
|
30
30
|
ok: boolean;
|
|
31
31
|
contentType: string;
|
|
32
|
+
/** The `Retry-After` header, raw, when the endpoint sent one. */
|
|
33
|
+
retryAfter: string | null;
|
|
32
34
|
/** Whole body, for the non-2xx and not-a-stream paths. Reads what arrived. */
|
|
33
35
|
text(): Promise<string>;
|
|
34
36
|
frames(options?: SseReadOptions): AsyncGenerator<SseEvent, void, void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xhrStream.d.ts","sourceRoot":"","sources":["../../../src/providers/xhrStream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAc,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAKvE,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IA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