@buoy-gg/agent-core 7.0.35 → 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 +21 -14
- package/lib/commonjs/blocks/receipts.js +57 -1
- package/lib/commonjs/blocks/receipts.js.map +1 -1
- package/lib/commonjs/blocks/types.js +23 -2
- package/lib/commonjs/blocks/types.js.map +1 -1
- package/lib/commonjs/blocks/uiTool.js +423 -10
- package/lib/commonjs/blocks/uiTool.js.map +1 -1
- package/lib/commonjs/catalog/catalog.g.js +213 -48
- package/lib/commonjs/catalog/catalog.g.js.map +1 -1
- package/lib/commonjs/catalog/catalog.source.json +226 -48
- package/lib/commonjs/catalog/catalog.types.g.js +44 -0
- package/lib/commonjs/catalog/catalog.types.g.js.map +1 -0
- package/lib/commonjs/catalog/normalizeParams.js +333 -0
- package/lib/commonjs/catalog/normalizeParams.js.map +1 -0
- package/lib/commonjs/catalog/signature.js +68 -0
- package/lib/commonjs/catalog/signature.js.map +1 -0
- package/lib/commonjs/catalog/snapshotReads.js +13 -6
- package/lib/commonjs/catalog/snapshotReads.js.map +1 -1
- package/lib/commonjs/catalog/toProviderTools.js +44 -6
- package/lib/commonjs/catalog/toProviderTools.js.map +1 -1
- package/lib/commonjs/context/buildContextPack.js +367 -19
- package/lib/commonjs/context/buildContextPack.js.map +1 -1
- package/lib/commonjs/effects/digest.js +34 -0
- package/lib/commonjs/effects/digest.js.map +1 -0
- package/lib/commonjs/effects/ledger.js +98 -2
- package/lib/commonjs/effects/ledger.js.map +1 -1
- package/lib/commonjs/engine/askGate.js +287 -0
- package/lib/commonjs/engine/askGate.js.map +1 -0
- package/lib/commonjs/engine/effectFor.js +82 -1
- package/lib/commonjs/engine/effectFor.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 +363 -0
- package/lib/commonjs/engine/historyBudget.js.map +1 -0
- package/lib/commonjs/engine/retrieve.js +214 -0
- package/lib/commonjs/engine/retrieve.js.map +1 -0
- package/lib/commonjs/engine/runAgentTurn.js +1231 -120
- package/lib/commonjs/engine/runAgentTurn.js.map +1 -1
- package/lib/commonjs/engine/systemPrompt.js +103 -9
- package/lib/commonjs/engine/systemPrompt.js.map +1 -1
- package/lib/commonjs/engine/textToolCalls.js +276 -0
- package/lib/commonjs/engine/textToolCalls.js.map +1 -0
- 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 +74 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/policy/labels.js +19 -3
- package/lib/commonjs/policy/labels.js.map +1 -1
- package/lib/commonjs/policy/policy.js +6 -1
- package/lib/commonjs/policy/policy.js.map +1 -1
- package/lib/commonjs/policy/redact.js +42 -5
- package/lib/commonjs/policy/redact.js.map +1 -1
- package/lib/commonjs/providers/anthropic.js +340 -208
- package/lib/commonjs/providers/anthropic.js.map +1 -1
- package/lib/commonjs/providers/openai.js +237 -103
- 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 +170 -34
- package/lib/commonjs/providers/sse.js.map +1 -1
- package/lib/commonjs/providers/streamTimer.js +123 -0
- package/lib/commonjs/providers/streamTimer.js.map +1 -0
- package/lib/commonjs/providers/transport.js +123 -0
- package/lib/commonjs/providers/transport.js.map +1 -0
- package/lib/commonjs/providers/xhrStream.js +212 -0
- package/lib/commonjs/providers/xhrStream.js.map +1 -0
- package/lib/commonjs/session.js +242 -58
- package/lib/commonjs/session.js.map +1 -1
- package/lib/module/blocks/receipts.js +57 -1
- package/lib/module/blocks/receipts.js.map +1 -1
- package/lib/module/blocks/types.js +23 -2
- package/lib/module/blocks/types.js.map +1 -1
- package/lib/module/blocks/uiTool.js +421 -10
- package/lib/module/blocks/uiTool.js.map +1 -1
- package/lib/module/catalog/catalog.g.js +213 -48
- package/lib/module/catalog/catalog.g.js.map +1 -1
- package/lib/module/catalog/catalog.source.json +226 -48
- package/lib/module/catalog/catalog.types.g.js +40 -0
- package/lib/module/catalog/catalog.types.g.js.map +1 -0
- package/lib/module/catalog/normalizeParams.js +327 -0
- package/lib/module/catalog/normalizeParams.js.map +1 -0
- package/lib/module/catalog/signature.js +63 -0
- package/lib/module/catalog/signature.js.map +1 -0
- package/lib/module/catalog/snapshotReads.js +13 -6
- package/lib/module/catalog/snapshotReads.js.map +1 -1
- package/lib/module/catalog/toProviderTools.js +44 -6
- package/lib/module/catalog/toProviderTools.js.map +1 -1
- package/lib/module/context/buildContextPack.js +366 -19
- package/lib/module/context/buildContextPack.js.map +1 -1
- package/lib/module/effects/digest.js +29 -0
- package/lib/module/effects/digest.js.map +1 -0
- package/lib/module/effects/ledger.js +98 -2
- package/lib/module/effects/ledger.js.map +1 -1
- package/lib/module/engine/askGate.js +280 -0
- package/lib/module/engine/askGate.js.map +1 -0
- package/lib/module/engine/effectFor.js +83 -1
- package/lib/module/engine/effectFor.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 +355 -0
- package/lib/module/engine/historyBudget.js.map +1 -0
- package/lib/module/engine/retrieve.js +210 -0
- package/lib/module/engine/retrieve.js.map +1 -0
- package/lib/module/engine/runAgentTurn.js +1227 -121
- package/lib/module/engine/runAgentTurn.js.map +1 -1
- package/lib/module/engine/systemPrompt.js +101 -9
- package/lib/module/engine/systemPrompt.js.map +1 -1
- package/lib/module/engine/textToolCalls.js +270 -0
- package/lib/module/engine/textToolCalls.js.map +1 -0
- 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 +7 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/policy/labels.js +19 -3
- package/lib/module/policy/labels.js.map +1 -1
- package/lib/module/policy/policy.js +6 -1
- package/lib/module/policy/policy.js.map +1 -1
- package/lib/module/policy/redact.js +42 -5
- package/lib/module/policy/redact.js.map +1 -1
- package/lib/module/providers/anthropic.js +341 -209
- package/lib/module/providers/anthropic.js.map +1 -1
- package/lib/module/providers/openai.js +238 -104
- 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 +166 -34
- package/lib/module/providers/sse.js.map +1 -1
- package/lib/module/providers/streamTimer.js +118 -0
- package/lib/module/providers/streamTimer.js.map +1 -0
- package/lib/module/providers/transport.js +119 -0
- package/lib/module/providers/transport.js.map +1 -0
- package/lib/module/providers/xhrStream.js +207 -0
- package/lib/module/providers/xhrStream.js.map +1 -0
- package/lib/module/session.js +226 -60
- package/lib/module/session.js.map +1 -1
- package/lib/typescript/blocks/receipts.d.ts +5 -0
- package/lib/typescript/blocks/receipts.d.ts.map +1 -1
- package/lib/typescript/blocks/types.d.ts +23 -2
- package/lib/typescript/blocks/types.d.ts.map +1 -1
- package/lib/typescript/blocks/uiTool.d.ts +11 -2
- package/lib/typescript/blocks/uiTool.d.ts.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 +40 -0
- package/lib/typescript/catalog/catalog.types.g.d.ts.map +1 -0
- package/lib/typescript/catalog/normalizeParams.d.ts +43 -0
- package/lib/typescript/catalog/normalizeParams.d.ts.map +1 -0
- package/lib/typescript/catalog/signature.d.ts +29 -0
- package/lib/typescript/catalog/signature.d.ts.map +1 -0
- package/lib/typescript/catalog/snapshotReads.d.ts.map +1 -1
- package/lib/typescript/catalog/toProviderTools.d.ts +28 -15
- package/lib/typescript/catalog/toProviderTools.d.ts.map +1 -1
- package/lib/typescript/context/buildContextPack.d.ts +24 -2
- package/lib/typescript/context/buildContextPack.d.ts.map +1 -1
- package/lib/typescript/effects/digest.d.ts +10 -0
- package/lib/typescript/effects/digest.d.ts.map +1 -0
- package/lib/typescript/effects/ledger.d.ts +73 -0
- package/lib/typescript/effects/ledger.d.ts.map +1 -1
- package/lib/typescript/engine/askGate.d.ts +29 -0
- package/lib/typescript/engine/askGate.d.ts.map +1 -0
- package/lib/typescript/engine/effectFor.d.ts +6 -1
- package/lib/typescript/engine/effectFor.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 +115 -0
- package/lib/typescript/engine/historyBudget.d.ts.map +1 -0
- 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 +179 -3
- package/lib/typescript/engine/runAgentTurn.d.ts.map +1 -1
- package/lib/typescript/engine/systemPrompt.d.ts +80 -0
- package/lib/typescript/engine/systemPrompt.d.ts.map +1 -1
- package/lib/typescript/engine/textToolCalls.d.ts +58 -0
- package/lib/typescript/engine/textToolCalls.d.ts.map +1 -0
- 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 +7 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/policy/labels.d.ts.map +1 -1
- package/lib/typescript/policy/policy.d.ts.map +1 -1
- package/lib/typescript/policy/redact.d.ts.map +1 -1
- package/lib/typescript/providers/anthropic.d.ts.map +1 -1
- package/lib/typescript/providers/openai.d.ts +0 -16
- 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 +86 -2
- package/lib/typescript/providers/sse.d.ts.map +1 -1
- package/lib/typescript/providers/streamTimer.d.ts +59 -0
- package/lib/typescript/providers/streamTimer.d.ts.map +1 -0
- package/lib/typescript/providers/transport.d.ts +48 -0
- package/lib/typescript/providers/transport.d.ts.map +1 -0
- package/lib/typescript/providers/types.d.ts +105 -3
- package/lib/typescript/providers/types.d.ts.map +1 -1
- package/lib/typescript/providers/xhrStream.d.ts +45 -0
- package/lib/typescript/providers/xhrStream.d.ts.map +1 -0
- package/lib/typescript/session.d.ts +55 -4
- 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 +10 -10
- package/LICENSE +0 -58
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The evidence store: every tool result this conversation produced, kept in
|
|
3
|
+
* full so the model can go back to it.
|
|
4
|
+
*
|
|
5
|
+
* Two markers used to point nowhere. A result over 24 000 characters was cut
|
|
6
|
+
* with "ask for a narrower slice" — and no tool offers one, so the bank has
|
|
7
|
+
* cases tagged `capability` (Pokémon `stats` sit at offset ~180 000 of a
|
|
8
|
+
* 400 000-character detail; unreadable by design). And a result compressed
|
|
9
|
+
* out of memory said "ask again" — a re-dispatch returns the CURRENT value,
|
|
10
|
+
* not what the model saw before it wrote, which is the one it needs when a
|
|
11
|
+
* write is refused and it has to say what it changed FROM.
|
|
12
|
+
*
|
|
13
|
+
* So the full text is kept here, keyed by a short ref the markers carry, and
|
|
14
|
+
* `ask-buoy.retrieve` reads any part of it back: a path, a substring, a
|
|
15
|
+
* window. Borrowed from Strands' ContextOffloader (`retrieve_offloaded_content`
|
|
16
|
+
* with pattern / line_range), minus the storage layer — this is in-memory and
|
|
17
|
+
* per session on purpose: persisted transcripts deliberately carry no tool
|
|
18
|
+
* result payloads (see ask-buoy transcriptPersistence.ts), and this must not
|
|
19
|
+
* quietly change that.
|
|
20
|
+
*
|
|
21
|
+
* What goes in is what the MODEL was given: after `redact` (credential names
|
|
22
|
+
* and value shapes) and `stripSelfTraffic`. Never the raw adapter value.
|
|
23
|
+
*
|
|
24
|
+
* Bounded by bytes and entries, oldest out first; an evicted ref is remembered
|
|
25
|
+
* so the answer is "evicted" rather than "never existed" — the marker still
|
|
26
|
+
* names a real thing, and the honest reply is to call the tool again.
|
|
27
|
+
*/
|
|
28
|
+
export interface EvidenceEntry {
|
|
29
|
+
ref: string;
|
|
30
|
+
toolId: string;
|
|
31
|
+
action: string;
|
|
32
|
+
params: Record<string, unknown>;
|
|
33
|
+
/** Epoch ms when the result came back. */
|
|
34
|
+
capturedAt: number;
|
|
35
|
+
/** The redacted JSON text the model was shown (before any truncation). */
|
|
36
|
+
text: string;
|
|
37
|
+
}
|
|
38
|
+
export interface EvidenceStoreOptions {
|
|
39
|
+
/** Total characters kept across entries. Default 4 000 000 (~4 MB). */
|
|
40
|
+
maxChars?: number;
|
|
41
|
+
/** Entries kept. Default 200. */
|
|
42
|
+
maxEntries?: number;
|
|
43
|
+
}
|
|
44
|
+
export declare class EvidenceStore {
|
|
45
|
+
private readonly entries;
|
|
46
|
+
private readonly evictedRefs;
|
|
47
|
+
private readonly maxChars;
|
|
48
|
+
private readonly maxEntries;
|
|
49
|
+
private chars;
|
|
50
|
+
private seq;
|
|
51
|
+
constructor(opts?: EvidenceStoreOptions);
|
|
52
|
+
/** Keep a result. Returns its ref — `ev_<n>`, counting up for the life of the store. */
|
|
53
|
+
stash(input: Omit<EvidenceEntry, "ref">): string;
|
|
54
|
+
get(ref: string): EvidenceEntry | undefined;
|
|
55
|
+
/** True when the ref was real and has since been dropped for space. */
|
|
56
|
+
wasEvicted(ref: string): boolean;
|
|
57
|
+
get size(): number;
|
|
58
|
+
get totalChars(): number;
|
|
59
|
+
/** New conversation: nothing from the old one is retrievable. */
|
|
60
|
+
clear(): void;
|
|
61
|
+
private evict;
|
|
62
|
+
}
|
|
63
|
+
/** The tail of a result cut at the engine's cap. */
|
|
64
|
+
export declare function truncationMarker(totalChars: number, ref: string | undefined): string;
|
|
65
|
+
/** What a consumed result is replaced with when history is compressed. Keep the `[earlier result` prefix — historyBudget skips on it. */
|
|
66
|
+
export declare function compressedMarker(totalChars: number, ref: string | undefined): string;
|
|
67
|
+
//# sourceMappingURL=evidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence.d.ts","sourceRoot":"","sources":["../../../src/engine/evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAKD,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAC5D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,GAAG,CAAK;gBAEJ,IAAI,GAAE,oBAAyB;IAK3C,wFAAwF;IACxF,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,GAAG,MAAM;IAWhD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAI3C,uEAAuE;IACvE,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIhC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,iEAAiE;IACjE,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,KAAK;CAUd;AAMD,oDAAoD;AACpD,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAIpF;AAED,yIAAyI;AACzI,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAIpF"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How much conversation the model is allowed to be sent, and what gets cut.
|
|
3
|
+
*
|
|
4
|
+
* Lives here, not in `session.ts`, because it is needed in TWO places and used
|
|
5
|
+
* to run in only one. The session trims once per turn, before the loop starts
|
|
6
|
+
* — and a turn is not one request. A twelve-step investigation appends an
|
|
7
|
+
* assistant message and a tool-results message per step, each result capped at
|
|
8
|
+
* 24,000 characters, so a long read chain could add well over a hundred
|
|
9
|
+
* thousand characters AFTER the only check had already happened and walk
|
|
10
|
+
* straight into the provider's context limit. The engine now applies the same
|
|
11
|
+
* budget before every request; the session still applies it when a turn opens.
|
|
12
|
+
*/
|
|
13
|
+
import type { AgentMessage } from "../providers/types";
|
|
14
|
+
/**
|
|
15
|
+
* A long QA session must not die on the provider's context limit with an
|
|
16
|
+
* opaque error, so the history is kept under a budget.
|
|
17
|
+
*
|
|
18
|
+
* TWO STAGES, AND THE ORDER IS THE POINT. Dropping the oldest rounds was the
|
|
19
|
+
* only stage, and in a QA session the oldest round is usually the SETUP — the
|
|
20
|
+
* override that was armed, the store that was written, the user someone is
|
|
21
|
+
* impersonating. Drop it and the model can no longer explain the screen it is
|
|
22
|
+
* looking at, or that a "wrong" response is its own mock. The reply gets worse
|
|
23
|
+
* in exactly the sessions long enough to need trimming.
|
|
24
|
+
*
|
|
25
|
+
* So: COMPRESS first, DROP only if that was not enough.
|
|
26
|
+
*
|
|
27
|
+
* A tool result is "consumed" once the model has produced an assistant message
|
|
28
|
+
* after seeing it — it has already been reasoned over, and what remains is
|
|
29
|
+
* bulk. Replacing it with a marker keeps the round, its decision and its
|
|
30
|
+
* ordering while giving back nearly all the bytes. Three exemptions carry
|
|
31
|
+
* their weight:
|
|
32
|
+
*
|
|
33
|
+
* - Errors are never compressed. A failure is the diagnostic value.
|
|
34
|
+
* - The newest tool-results message is never compressed. The model is about
|
|
35
|
+
* to answer from it.
|
|
36
|
+
* - The last read before a WRITE is never compressed: that is the shape the
|
|
37
|
+
* model matched its edit to, and it is the thing it re-reads when the write
|
|
38
|
+
* is refused and it has to correct itself.
|
|
39
|
+
*
|
|
40
|
+
* Only if the history is still over budget do whole rounds get dropped, as
|
|
41
|
+
* before — a round starts at a user message, so the assistant/tool-result
|
|
42
|
+
* pairing every provider requires stays intact.
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* The limits are in TOKENS — the unit the provider enforces — and turned into
|
|
46
|
+
* characters at the ratio the session has measured (engine/tokenCalibration.ts).
|
|
47
|
+
* The `_CHARS` constants below are those limits at the default 4 chars/token,
|
|
48
|
+
* kept for callers that have no calibration in hand (tests, one-shot use).
|
|
49
|
+
*/
|
|
50
|
+
export declare const MAX_HISTORY_TOKENS = 37500;
|
|
51
|
+
/**
|
|
52
|
+
* The ceiling on a WHOLE request: tools, system prompt, messages and the room
|
|
53
|
+
* reserved for the reply. 100k tokens fits the smallest context Ask Buoy is
|
|
54
|
+
* pointed at in practice (a 128k-token gateway) with headroom, and leaves
|
|
55
|
+
* Anthropic's 200k far from the limit.
|
|
56
|
+
*/
|
|
57
|
+
export declare const MAX_REQUEST_TOKENS = 100000;
|
|
58
|
+
export declare const MAX_HISTORY_CHARS: number;
|
|
59
|
+
export declare const MAX_REQUEST_CHARS: number;
|
|
60
|
+
export declare function messageSize(m: AgentMessage): number;
|
|
61
|
+
/**
|
|
62
|
+
* Replace consumed tool results with a marker. See the note above
|
|
63
|
+
* MAX_HISTORY_CHARS for what "consumed" means and why the exemptions exist.
|
|
64
|
+
*/
|
|
65
|
+
export declare function compressConsumed(messages: AgentMessage[], exemptNewest?: boolean): AgentMessage[];
|
|
66
|
+
/**
|
|
67
|
+
* Trim, and say how many whole rounds were dropped — the number the UI turns
|
|
68
|
+
* into "older messages were trimmed from the agent's memory".
|
|
69
|
+
*
|
|
70
|
+
* A round is a user message and everything up to the next one. Once a drop
|
|
71
|
+
* starts it ALWAYS runs to the next user boundary: the inner loop used to stop
|
|
72
|
+
* at `MIN_KEEP_MESSAGES` as well, so a history could come out starting with an
|
|
73
|
+
* assistant or tool-results message — which every provider rejects. The
|
|
74
|
+
* minimum-keep guard belongs on STARTING a drop, not on finishing one.
|
|
75
|
+
*/
|
|
76
|
+
export declare function trimHistoryReport(messages: AgentMessage[], charsPerToken?: number,
|
|
77
|
+
/** Tool-call ids whose change is still applied — their rounds are dropped last. See dropRounds. */
|
|
78
|
+
pinnedCallIds?: ReadonlySet<string>): {
|
|
79
|
+
messages: AgentMessage[];
|
|
80
|
+
droppedRounds: number;
|
|
81
|
+
/** Of `droppedRounds`, how many still held an applied change. */
|
|
82
|
+
droppedPinned: number;
|
|
83
|
+
};
|
|
84
|
+
/** Exported for the history tests; not part of the package surface. */
|
|
85
|
+
export declare function trimHistory(messages: AgentMessage[]): AgentMessage[];
|
|
86
|
+
/**
|
|
87
|
+
* Trim the working history of a turn that is still running.
|
|
88
|
+
*
|
|
89
|
+
* Differs from `trimHistoryReport` in one way that matters: the CURRENT round
|
|
90
|
+
* is never touched. A turn's own user message and the reads it has taken since
|
|
91
|
+
* are the thing being answered, so compressing or dropping them would make the
|
|
92
|
+
* request cheaper and the answer wrong. Everything before the last user
|
|
93
|
+
* message is fair game, in the same order as always — compress, then drop.
|
|
94
|
+
*
|
|
95
|
+
* `reserve` is what the request costs BEFORE any messages: the tool
|
|
96
|
+
* definitions (~8k tokens for a typical install, ~23k with everything
|
|
97
|
+
* installed), the system prompt, and the reply the model is allowed to write.
|
|
98
|
+
* Budgeting messages alone would leave the biggest fixed cost out of the sum.
|
|
99
|
+
*/
|
|
100
|
+
export declare function budgetForRequest(messages: AgentMessage[], reserve: number,
|
|
101
|
+
/**
|
|
102
|
+
* A tighter ceiling on the messages than MAX_HISTORY_CHARS — set by the
|
|
103
|
+
* engine after the provider refused a request as too big. The proactive
|
|
104
|
+
* budget is an estimate; the provider's refusal is the truth.
|
|
105
|
+
*/
|
|
106
|
+
cap?: number,
|
|
107
|
+
/** The session's measured ratio; scales the whole-request ceiling. */
|
|
108
|
+
charsPerToken?: number,
|
|
109
|
+
/** Tool-call ids whose change is still applied — their rounds are dropped last. See dropRounds. */
|
|
110
|
+
pinnedCallIds?: ReadonlySet<string>): {
|
|
111
|
+
messages: AgentMessage[];
|
|
112
|
+
droppedRounds: number;
|
|
113
|
+
droppedPinned: number;
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=historyBudget.d.ts.map
|
|
@@ -0,0 +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;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"}
|
|
@@ -20,10 +20,26 @@ import type { DispatchFn, SnapshotFn, ToolDescriptor } from "../types";
|
|
|
20
20
|
import type { AgentMessage, Provider } from "../providers/types";
|
|
21
21
|
import { EffectLedger } from "../effects/ledger";
|
|
22
22
|
import { type AskBuoyPolicy } from "../policy/policy";
|
|
23
|
+
import { digestOf } from "../effects/digest";
|
|
23
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";
|
|
24
29
|
export type TurnEvent = {
|
|
25
30
|
type: "text";
|
|
26
31
|
delta: string;
|
|
32
|
+
/**
|
|
33
|
+
* This delta opens a new round of the same answer.
|
|
34
|
+
*
|
|
35
|
+
* One assistant bubble spans every round of a multi-step run, so without
|
|
36
|
+
* a marker the last sentence of one round and the first of the next are
|
|
37
|
+
* concatenated — "…resets every launch.Here's the full picture…". The
|
|
38
|
+
* ENGINE is the only layer that knows where a round ends: the UI sees a
|
|
39
|
+
* flat stream of deltas, and the tool events it used to infer the
|
|
40
|
+
* boundary from are not always there (a declined approval runs no tool).
|
|
41
|
+
*/
|
|
42
|
+
breakBefore?: boolean;
|
|
27
43
|
}
|
|
28
44
|
/**
|
|
29
45
|
* The model's own reasoning for this turn, when the provider reports any.
|
|
@@ -36,6 +52,25 @@ export type TurnEvent = {
|
|
|
36
52
|
| {
|
|
37
53
|
type: "reasoning";
|
|
38
54
|
text: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Whole rounds were dropped from the model's memory before this turn.
|
|
58
|
+
*
|
|
59
|
+
* Yielded by the SESSION (which owns trimming), never by the engine. The
|
|
60
|
+
* screen still shows those rounds, so without this the transcript and the
|
|
61
|
+
* model silently disagree — the user asks "turn off that override" and the
|
|
62
|
+
* model, having lost the round that armed it, asks which one.
|
|
63
|
+
*/
|
|
64
|
+
| {
|
|
65
|
+
type: "history-trimmed";
|
|
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;
|
|
39
74
|
} | {
|
|
40
75
|
type: "tool-start";
|
|
41
76
|
id: string;
|
|
@@ -71,6 +106,17 @@ export type TurnEvent = {
|
|
|
71
106
|
*/
|
|
72
107
|
result?: string;
|
|
73
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
|
+
}
|
|
74
120
|
/** A block to render — a receipt from a tool result, or a model-authored block. */
|
|
75
121
|
| {
|
|
76
122
|
type: "block";
|
|
@@ -93,19 +139,72 @@ export type TurnEvent = {
|
|
|
93
139
|
type: "error";
|
|
94
140
|
message: string;
|
|
95
141
|
}
|
|
96
|
-
/**
|
|
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
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Token usage for one provider request, when the provider reports it.
|
|
156
|
+
* `cacheRead`/`cacheWrite` are the prompt-cache counters (see TokenUsage —
|
|
157
|
+
* without them a cached Claude request looks nearly free) and `model` is
|
|
158
|
+
* the id the provider actually SERVED, which is what a cost table or a
|
|
159
|
+
* benchmark needs when a gateway alias drifts to a new snapshot.
|
|
160
|
+
*/
|
|
97
161
|
| {
|
|
98
162
|
type: "usage";
|
|
99
163
|
input: number;
|
|
100
164
|
output: number;
|
|
165
|
+
cacheRead?: number;
|
|
166
|
+
cacheWrite?: number;
|
|
167
|
+
model?: string;
|
|
101
168
|
} | {
|
|
102
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;
|
|
103
200
|
};
|
|
104
201
|
export interface RunTurnInput {
|
|
105
202
|
provider: Provider;
|
|
106
203
|
catalog: ToolDescriptor[];
|
|
107
204
|
messages: AgentMessage[];
|
|
108
205
|
system: string;
|
|
206
|
+
/** Per-turn "right now" block. See ProviderRequest.systemVolatile. */
|
|
207
|
+
systemVolatile?: string;
|
|
109
208
|
model: string;
|
|
110
209
|
maxTokens: number;
|
|
111
210
|
dispatch: DispatchFn;
|
|
@@ -123,7 +222,12 @@ export interface RunTurnInput {
|
|
|
123
222
|
/** Live tool ids from `listToolActions()`, so absent tools are never offered. */
|
|
124
223
|
availableToolIds?: string[];
|
|
125
224
|
availableActions?: Record<string, string[]>;
|
|
126
|
-
/**
|
|
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
|
+
*/
|
|
127
231
|
requestApproval?: (input: {
|
|
128
232
|
id: string;
|
|
129
233
|
toolId: string;
|
|
@@ -131,10 +235,82 @@ export interface RunTurnInput {
|
|
|
131
235
|
label: string;
|
|
132
236
|
description: string;
|
|
133
237
|
reason: string;
|
|
134
|
-
|
|
238
|
+
/**
|
|
239
|
+
* The exact call being asked about.
|
|
240
|
+
*
|
|
241
|
+
* The UI does not render it — an approval prompt shows the effect, not the
|
|
242
|
+
* payload. It travels so a card that OUTLIVES this turn can still run it:
|
|
243
|
+
* the sheet persists an unanswered approval, and after a reload the
|
|
244
|
+
* generator holding this promise no longer exists, so Allow has to
|
|
245
|
+
* re-dispatch the call itself.
|
|
246
|
+
*/
|
|
247
|
+
params: Record<string, unknown>;
|
|
248
|
+
/**
|
|
249
|
+
* A fingerprint of the value this call is about to overwrite, read at the
|
|
250
|
+
* moment the question was asked — see `readTargetDigest`. A card that comes
|
|
251
|
+
* back after a restart re-reads and compares before it writes; a card
|
|
252
|
+
* answered live never needs it. Absent when the target cannot be read.
|
|
253
|
+
*/
|
|
254
|
+
targetDigest?: string;
|
|
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[];
|
|
135
268
|
signal?: AbortSignal;
|
|
269
|
+
/**
|
|
270
|
+
* Every http(s) URL this CONVERSATION has read out of a tool result. Owned
|
|
271
|
+
* by the session so it outlives one turn: "now show me those as pictures"
|
|
272
|
+
* is a normal second message, and a per-turn set answered it by silently
|
|
273
|
+
* stripping every image — the model then described artwork the user could
|
|
274
|
+
* not see. Provenance is still enforced, just over the whole conversation
|
|
275
|
+
* rather than one turn of it. Omitted (tests, one-shot callers) means a
|
|
276
|
+
* fresh per-turn set.
|
|
277
|
+
*/
|
|
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;
|
|
136
292
|
}
|
|
137
293
|
export declare function runAgentTurn(input: RunTurnInput): AsyncGenerator<TurnEvent, AgentMessage[], void>;
|
|
294
|
+
export { digestOf };
|
|
295
|
+
/**
|
|
296
|
+
* Fingerprint the value a write is about to replace.
|
|
297
|
+
*
|
|
298
|
+
* Built for the approval card that outlives its turn: the app crashed with
|
|
299
|
+
* "Set bag line L-01 qty to 14" still asking, relaunched, and the card came
|
|
300
|
+
* back — and Allow wrote qty 14 against whatever the bag was NOW, maybe a
|
|
301
|
+
* different account, maybe a line that no longer existed. A hash of the
|
|
302
|
+
* params alone would not catch that (same label, same params, different
|
|
303
|
+
* world). So the card carries a digest of the TARGET at ask time, and a
|
|
304
|
+
* restored Allow re-reads and compares before it writes. Undefined when the
|
|
305
|
+
* target cannot be read — then the card can only warn, not check.
|
|
306
|
+
*/
|
|
307
|
+
export declare function readTargetDigest(input: {
|
|
308
|
+
toolId: string;
|
|
309
|
+
action: string;
|
|
310
|
+
params: Record<string, unknown>;
|
|
311
|
+
dispatch: DispatchFn;
|
|
312
|
+
catalog?: ToolDescriptor[];
|
|
313
|
+
}): Promise<string | undefined>;
|
|
138
314
|
export interface GatedActionInput {
|
|
139
315
|
toolId: string;
|
|
140
316
|
action: string;
|
|
@@ -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;
|
|
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,MAA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,CAAC,CAQ9B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,QAAQ,EAAE,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,15 +35,95 @@ 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;
|
|
81
|
+
/**
|
|
82
|
+
* Who turned read-only on. The APP configuring it is a rule the user cannot
|
|
83
|
+
* change; the DEVICE toggle is the person in front of the phone choosing to
|
|
84
|
+
* look without touching — and the model should tell them where to turn it
|
|
85
|
+
* off rather than send them to a developer.
|
|
86
|
+
*/
|
|
87
|
+
readOnlySource?: "app" | "device";
|
|
44
88
|
requireApproval: string[];
|
|
89
|
+
/**
|
|
90
|
+
* The user turned approval cards off on this device. Distinct from an empty
|
|
91
|
+
* `requireApproval`, which is the APP choosing full auto-run: here a gate
|
|
92
|
+
* exists and the person in front of the phone waived it, so the model is
|
|
93
|
+
* told plainly that nothing will stop a destructive call.
|
|
94
|
+
*/
|
|
95
|
+
approvalsBypassed?: boolean;
|
|
45
96
|
appName?: string;
|
|
46
97
|
platform?: string;
|
|
47
98
|
}
|
|
48
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[];
|
|
102
|
+
/**
|
|
103
|
+
* The per-turn block: what the app is showing at the moment the user typed.
|
|
104
|
+
* Rendered AFTER the cached prompt (see ProviderRequest.systemVolatile), so it
|
|
105
|
+
* can change on every message without invalidating anything.
|
|
106
|
+
*
|
|
107
|
+
* Returns undefined when nothing was readable — the prompt then says so, so the
|
|
108
|
+
* model knows to read for itself rather than assume the block was empty
|
|
109
|
+
* because the app is.
|
|
110
|
+
*/
|
|
111
|
+
export declare function buildLiveBlock(live: Record<string, unknown> | undefined,
|
|
112
|
+
/**
|
|
113
|
+
* What this conversation has already changed, newest last.
|
|
114
|
+
*
|
|
115
|
+
* The ledger existed from the start and the model could never see it. Two
|
|
116
|
+
* failures came out of that. Asked "what have you changed?" it answered from
|
|
117
|
+
* memory of its own sentences, which drifts and cannot survive a reload. And
|
|
118
|
+
* reading a value it had itself overwritten three turns earlier, it reported
|
|
119
|
+
* the number as the app's own — the same "never fake the answer" problem as
|
|
120
|
+
* a network override, with the model as the one deceived.
|
|
121
|
+
*
|
|
122
|
+
* Short by construction: tool, action and a label per entry, capped. It is a
|
|
123
|
+
* reminder of what happened, not a replay of it.
|
|
124
|
+
*/
|
|
125
|
+
changes?: {
|
|
126
|
+
label: string;
|
|
127
|
+
undone: boolean;
|
|
128
|
+
}[]): string;
|
|
49
129
|
//# sourceMappingURL=systemPrompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemPrompt.d.ts","sourceRoot":"","sources":["../../../src/engine/systemPrompt.ts"],"names":[],"mapp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E,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,OAAO,CAAC,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,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recovering a tool call a model wrote as TEXT instead of calling.
|
|
3
|
+
*
|
|
4
|
+
* Every provider here is sent real tool definitions, and most models use them.
|
|
5
|
+
* Some don't — under a gateway, after a clarifying question, or just on the
|
|
6
|
+
* wrong roll, a model answers with the call spelled out as JSON:
|
|
7
|
+
*
|
|
8
|
+
* ```json
|
|
9
|
+
* {"calls":[{"tool":"buoy_zustand","action":"setState","params":{…}}],
|
|
10
|
+
* "reply":"Done — I added one Jigglypuff to your bag."}
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Left alone this is the worst outcome the product has: the user said "yes,
|
|
14
|
+
* go ahead", nothing happened, and what they got back was a wall of JSON
|
|
15
|
+
* claiming it did. The same class of problem as the parameter aliases in
|
|
16
|
+
* normalizeParams — models reach for a convention they know, and meeting them
|
|
17
|
+
* costs one parse.
|
|
18
|
+
*
|
|
19
|
+
* Two halves, and the first is why this file exists at all:
|
|
20
|
+
*
|
|
21
|
+
* 1. {@link couldBeToolCallEnvelope} runs on every delta, because the decision
|
|
22
|
+
* has to be made BEFORE the text reaches the screen. Streamed text cannot
|
|
23
|
+
* be taken back. It withholds only what could still be an envelope and
|
|
24
|
+
* releases the moment it can't be.
|
|
25
|
+
* 2. {@link parseTextToolCalls} turns the finished blob into ordinary calls,
|
|
26
|
+
* which then go through validation, the policy, and approval exactly like a
|
|
27
|
+
* native one. Nothing here decides that a call is allowed to run — a
|
|
28
|
+
* recovered destructive call still stops at the same approval sheet.
|
|
29
|
+
*/
|
|
30
|
+
import type { ToolCall } from "../providers/types";
|
|
31
|
+
import type { ToolDescriptor } from "../types";
|
|
32
|
+
/**
|
|
33
|
+
* Could the text so far still turn out to be a tool-call envelope?
|
|
34
|
+
*
|
|
35
|
+
* False the instant it can't be, so an ordinary answer streams exactly as it
|
|
36
|
+
* did before — the window this holds is one opening brace plus a key name.
|
|
37
|
+
*/
|
|
38
|
+
export declare function couldBeToolCallEnvelope(text: string): boolean;
|
|
39
|
+
export interface SalvagedCalls {
|
|
40
|
+
calls: ToolCall[];
|
|
41
|
+
/** The prose the envelope carried, if any. The JSON itself is never shown. */
|
|
42
|
+
reply: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Read a text envelope as tool calls, or nothing if that is not what it is.
|
|
46
|
+
*
|
|
47
|
+
* Deliberately strict about the SHAPE and loose about the spelling: it will
|
|
48
|
+
* not turn arbitrary JSON into calls (a model showing the user a response body
|
|
49
|
+
* must still be shown), but it accepts every naming convention a model might
|
|
50
|
+
* carry over — `tool`/`name`, `params`/`input`/`arguments`, one call or many.
|
|
51
|
+
*/
|
|
52
|
+
export declare function parseTextToolCalls(text: string, catalog: ToolDescriptor[]): SalvagedCalls | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Appended to a recovered call's result, so the model corrects itself for the
|
|
55
|
+
* rest of the conversation instead of writing the next one as text too.
|
|
56
|
+
*/
|
|
57
|
+
export declare const SALVAGE_NOTE = "\n\n[You wrote this call as JSON in your reply instead of calling the tool. It was recovered and run this time. Call tools through the tool interface \u2014 text is shown to the user as-is, and a call written there does not run.]";
|
|
58
|
+
//# sourceMappingURL=textToolCalls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textToolCalls.d.ts","sourceRoot":"","sources":["../../../src/engine/textToolCalls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AA0B/C;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQ7D;AA+JD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,EAAE,GACxB,aAAa,GAAG,SAAS,CA+B3B;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,0OAC2M,CAAC"}
|