@yolk-sdk/agent 0.1.0-canary.97 → 0.1.0-canary.99
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 +24 -1
- package/dist/client/state.d.mts +63 -63
- package/dist/client/state.d.mts.map +1 -1
- package/dist/protocol/bounded-text.d.mts +20 -0
- package/dist/protocol/bounded-text.d.mts.map +1 -0
- package/dist/protocol/bounded-text.mjs +48 -0
- package/dist/protocol/bounded-text.mjs.map +1 -0
- package/dist/protocol/index.d.mts +3 -2
- package/dist/protocol/index.d.mts.map +1 -1
- package/dist/protocol/index.mjs +3 -2
- package/dist/protocol/nested-tool-calls.d.mts +58 -9
- package/dist/protocol/nested-tool-calls.d.mts.map +1 -1
- package/dist/protocol/nested-tool-calls.mjs +83 -58
- package/dist/protocol/nested-tool-calls.mjs.map +1 -1
- package/dist/react/chat-items.d.mts +39 -39
- package/dist/react/chat-items.d.mts.map +1 -1
- package/dist/react/chat-messages.d.mts +39 -39
- package/dist/react/chat-messages.d.mts.map +1 -1
- package/dist/skillset/merge.d.mts +1 -1
- package/dist/skillset/name.d.mts +2 -2
- package/dist/skillset/name.d.mts.map +1 -1
- package/dist/tools/index.d.mts +2 -1
- package/dist/tools/index.mjs +2 -1
- package/dist/tools/ledger.d.mts +452 -0
- package/dist/tools/ledger.d.mts.map +1 -0
- package/dist/tools/ledger.mjs +471 -0
- package/dist/tools/ledger.mjs.map +1 -0
- package/dist/tools/registry.d.mts +23 -6
- package/dist/tools/registry.d.mts.map +1 -1
- package/dist/tools/registry.mjs +55 -33
- package/dist/tools/registry.mjs.map +1 -1
- package/dist/tools/sha256.d.mts +6 -0
- package/dist/tools/sha256.d.mts.map +1 -0
- package/dist/tools/sha256.mjs +138 -0
- package/dist/tools/sha256.mjs.map +1 -0
- package/dist/tools/subagent.d.mts +4 -0
- package/dist/tools/subagent.d.mts.map +1 -1
- package/dist/tools/subagent.mjs +7 -2
- package/dist/tools/subagent.mjs.map +1 -1
- package/package.json +2 -2
- package/src/protocol/bounded-text.ts +78 -0
- package/src/protocol/index.ts +8 -0
- package/src/protocol/nested-tool-calls.ts +114 -83
- package/src/tools/README.md +99 -1
- package/src/tools/index.ts +38 -0
- package/src/tools/ledger.ts +1068 -0
- package/src/tools/registry.ts +101 -19
- package/src/tools/sha256.ts +98 -0
- package/src/tools/subagent.ts +10 -2
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Published package metadata requires Node.js 22+.
|
|
|
29
29
|
| `@yolk-sdk/agent/client` | HTTP/NDJSON transport, HITL resume, retry/error state helpers |
|
|
30
30
|
| `@yolk-sdk/agent/compaction` | Host-owned compaction budgets, checkpoints, formatting, retry |
|
|
31
31
|
| `@yolk-sdk/agent/classification` | Classifier model contract: typed questions, answers, usage, errors |
|
|
32
|
-
| `@yolk-sdk/agent/tools` | Tool registry, typed inputs, interactions, subagents/questions
|
|
32
|
+
| `@yolk-sdk/agent/tools` | Tool registry, typed inputs, interactions, subagents/questions, durable tool ledger |
|
|
33
33
|
| `@yolk-sdk/agent/react` | Headless React chat hook, reducer, selectors, and render model |
|
|
34
34
|
| `@yolk-sdk/agent/oauth` | Provider-neutral OAuth token and broker contracts |
|
|
35
35
|
| `@yolk-sdk/agent/providers/openai` | OpenAI/Codex OAuth and broker helpers |
|
|
@@ -934,6 +934,26 @@ This package declares them; it does not run scripts.
|
|
|
934
934
|
bounded `ToolResult.nestedCalls` record and summed `ToolResult.usage` never reach the model:
|
|
935
935
|
`toolResultMessageFromResult` drops both, and the loop does not add `ToolResult.usage` to run
|
|
936
936
|
usage. Capture them from the `ToolResult` or tool events when you need audit or billing records.
|
|
937
|
+
Size the record with `makeNestedToolCallRecorder({ maxCalls })`; per-status `counts` cover
|
|
938
|
+
every call, dropped ones included.
|
|
939
|
+
|
|
940
|
+
## Durable tool ledger
|
|
941
|
+
|
|
942
|
+
Steps that hosts re-execute (Vercel Workflow's queue is at-least-once) must not repeat writes.
|
|
943
|
+
Pass `resolveTools(modules, context, { ledger: { store } })` with a host-implemented durable
|
|
944
|
+
`ToolLedgerStore` scoped to the run: every ledgered call (by default every non-`read` call plus the
|
|
945
|
+
built-in `subagent` tool, top-level or nested in code mode) runs at most once per ledger key. Add
|
|
946
|
+
custom delegation tools with `isLedgered`. Input and interaction tools are never ledgered; their
|
|
947
|
+
at-most-once guarantee is the host's `InteractionHost` receipts. A different call under the same key (tool name or a
|
|
948
|
+
SHA-256 `argsDigest` of the full arguments, a stable format hosts persist) is a conflict, never a
|
|
949
|
+
replay. Completed calls return their stored result, concurrent duplicates wait, and calls abandoned
|
|
950
|
+
by a crash are never re-run (the model is told to verify). Executors receive a stable
|
|
951
|
+
`idempotencyKey`. Stores get the lease length (`leaseMs`) so they can use database time, and must
|
|
952
|
+
keep their operations interruptible (the ledger's timeouts cannot cut uninterruptible store work).
|
|
953
|
+
`deadline` bounds only waiting for a duplicate; recording an outcome can take about 15 s more.
|
|
954
|
+
`onLedgerDecision` reports each call's decision (`fresh`, `completed`, `in_flight_wait`, ...) for
|
|
955
|
+
logs and metrics. Without the option behavior is unchanged. See
|
|
956
|
+
[the tools README](https://github.com/magoz/yolk-sdk/blob/main/packages/agent/src/tools/README.md#durable-tool-ledger).
|
|
937
957
|
|
|
938
958
|
## Tool failures
|
|
939
959
|
|
|
@@ -965,6 +985,9 @@ aborts, and implementation bugs outside typed tool execution.
|
|
|
965
985
|
- Persist/return one `ToolResultMessage` for every host tool call, including `isError` failures.
|
|
966
986
|
- Persist terminal provider failures and clear active run ids where applicable.
|
|
967
987
|
- Provide tools, approval policy, auth, storage, and observability.
|
|
988
|
+
- When steps can re-execute, implement a durable `ToolLedgerStore` scoped to one run (plus the turn
|
|
989
|
+
or step when call ids can repeat), keep its operations interruptible, and reserve about 15 s of
|
|
990
|
+
the step budget after `deadline` for recording outcomes.
|
|
968
991
|
- If you send `ToolDef`s to providers yourself (outside `run`/`runModelTurn`), filter them with
|
|
969
992
|
protocol `providerToolDefs`; codemode-only tools must never reach providers. Executor decorators
|
|
970
993
|
outside `ResolvedToolSet.execute` do not see nested code mode calls.
|
package/dist/client/state.d.mts
CHANGED
|
@@ -80,26 +80,6 @@ type AgentToolRun = {
|
|
|
80
80
|
readonly result: ToolResult;
|
|
81
81
|
};
|
|
82
82
|
declare const AgentToolRun: {
|
|
83
|
-
readonly InputStreaming: Data.TaggedEnum.ConstructorFrom<{
|
|
84
|
-
readonly _tag: "InputStreaming";
|
|
85
|
-
readonly id: string;
|
|
86
|
-
readonly name?: string;
|
|
87
|
-
readonly input: string;
|
|
88
|
-
}, "_tag">;
|
|
89
|
-
readonly InputReady: Data.TaggedEnum.ConstructorFrom<{
|
|
90
|
-
readonly _tag: "InputReady";
|
|
91
|
-
readonly call: ToolCall;
|
|
92
|
-
}, "_tag">;
|
|
93
|
-
readonly ApprovalRequested: Data.TaggedEnum.ConstructorFrom<{
|
|
94
|
-
readonly _tag: "ApprovalRequested";
|
|
95
|
-
readonly call: ToolCall;
|
|
96
|
-
readonly request?: ToolApprovalRequest;
|
|
97
|
-
}, "_tag">;
|
|
98
|
-
readonly Denied: Data.TaggedEnum.ConstructorFrom<{
|
|
99
|
-
readonly _tag: "Denied";
|
|
100
|
-
readonly toolCallId: string;
|
|
101
|
-
readonly reason: string;
|
|
102
|
-
}, "_tag">;
|
|
103
83
|
readonly QuestionRequested: Data.TaggedEnum.ConstructorFrom<{
|
|
104
84
|
readonly _tag: "QuestionRequested";
|
|
105
85
|
readonly request: QuestionRequest;
|
|
@@ -142,6 +122,26 @@ declare const AgentToolRun: {
|
|
|
142
122
|
readonly response: InteractionResponse;
|
|
143
123
|
readonly request?: InteractionRequest;
|
|
144
124
|
}, "_tag">;
|
|
125
|
+
readonly InputStreaming: Data.TaggedEnum.ConstructorFrom<{
|
|
126
|
+
readonly _tag: "InputStreaming";
|
|
127
|
+
readonly id: string;
|
|
128
|
+
readonly name?: string;
|
|
129
|
+
readonly input: string;
|
|
130
|
+
}, "_tag">;
|
|
131
|
+
readonly InputReady: Data.TaggedEnum.ConstructorFrom<{
|
|
132
|
+
readonly _tag: "InputReady";
|
|
133
|
+
readonly call: ToolCall;
|
|
134
|
+
}, "_tag">;
|
|
135
|
+
readonly ApprovalRequested: Data.TaggedEnum.ConstructorFrom<{
|
|
136
|
+
readonly _tag: "ApprovalRequested";
|
|
137
|
+
readonly call: ToolCall;
|
|
138
|
+
readonly request?: ToolApprovalRequest;
|
|
139
|
+
}, "_tag">;
|
|
140
|
+
readonly Denied: Data.TaggedEnum.ConstructorFrom<{
|
|
141
|
+
readonly _tag: "Denied";
|
|
142
|
+
readonly toolCallId: string;
|
|
143
|
+
readonly reason: string;
|
|
144
|
+
}, "_tag">;
|
|
145
145
|
readonly Executing: Data.TaggedEnum.ConstructorFrom<{
|
|
146
146
|
readonly _tag: "Executing";
|
|
147
147
|
readonly call: ToolCall;
|
|
@@ -173,7 +173,7 @@ declare const AgentToolRun: {
|
|
|
173
173
|
readonly call: ToolCall;
|
|
174
174
|
readonly result: ToolResult;
|
|
175
175
|
}, "_tag">;
|
|
176
|
-
readonly $is: <Tag extends "
|
|
176
|
+
readonly $is: <Tag extends "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
177
177
|
readonly _tag: "InputStreaming";
|
|
178
178
|
readonly id: string;
|
|
179
179
|
readonly name?: string;
|
|
@@ -287,26 +287,6 @@ declare const AgentToolRun: {
|
|
|
287
287
|
}>;
|
|
288
288
|
readonly $match: {
|
|
289
289
|
<Cases extends {
|
|
290
|
-
readonly InputStreaming: (args: {
|
|
291
|
-
readonly _tag: "InputStreaming";
|
|
292
|
-
readonly id: string;
|
|
293
|
-
readonly name?: string;
|
|
294
|
-
readonly input: string;
|
|
295
|
-
}) => any;
|
|
296
|
-
readonly InputReady: (args: {
|
|
297
|
-
readonly _tag: "InputReady";
|
|
298
|
-
readonly call: ToolCall;
|
|
299
|
-
}) => any;
|
|
300
|
-
readonly ApprovalRequested: (args: {
|
|
301
|
-
readonly _tag: "ApprovalRequested";
|
|
302
|
-
readonly call: ToolCall;
|
|
303
|
-
readonly request?: ToolApprovalRequest;
|
|
304
|
-
}) => any;
|
|
305
|
-
readonly Denied: (args: {
|
|
306
|
-
readonly _tag: "Denied";
|
|
307
|
-
readonly toolCallId: string;
|
|
308
|
-
readonly reason: string;
|
|
309
|
-
}) => any;
|
|
310
290
|
readonly QuestionRequested: (args: {
|
|
311
291
|
readonly _tag: "QuestionRequested";
|
|
312
292
|
readonly request: QuestionRequest;
|
|
@@ -349,6 +329,26 @@ declare const AgentToolRun: {
|
|
|
349
329
|
readonly response: InteractionResponse;
|
|
350
330
|
readonly request?: InteractionRequest;
|
|
351
331
|
}) => any;
|
|
332
|
+
readonly InputStreaming: (args: {
|
|
333
|
+
readonly _tag: "InputStreaming";
|
|
334
|
+
readonly id: string;
|
|
335
|
+
readonly name?: string;
|
|
336
|
+
readonly input: string;
|
|
337
|
+
}) => any;
|
|
338
|
+
readonly InputReady: (args: {
|
|
339
|
+
readonly _tag: "InputReady";
|
|
340
|
+
readonly call: ToolCall;
|
|
341
|
+
}) => any;
|
|
342
|
+
readonly ApprovalRequested: (args: {
|
|
343
|
+
readonly _tag: "ApprovalRequested";
|
|
344
|
+
readonly call: ToolCall;
|
|
345
|
+
readonly request?: ToolApprovalRequest;
|
|
346
|
+
}) => any;
|
|
347
|
+
readonly Denied: (args: {
|
|
348
|
+
readonly _tag: "Denied";
|
|
349
|
+
readonly toolCallId: string;
|
|
350
|
+
readonly reason: string;
|
|
351
|
+
}) => any;
|
|
352
352
|
readonly Executing: (args: {
|
|
353
353
|
readonly _tag: "Executing";
|
|
354
354
|
readonly call: ToolCall;
|
|
@@ -380,28 +380,8 @@ declare const AgentToolRun: {
|
|
|
380
380
|
readonly call: ToolCall;
|
|
381
381
|
readonly result: ToolResult;
|
|
382
382
|
}) => any;
|
|
383
|
-
}>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["
|
|
383
|
+
}>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
|
|
384
384
|
<Cases extends {
|
|
385
|
-
readonly InputStreaming: (args: {
|
|
386
|
-
readonly _tag: "InputStreaming";
|
|
387
|
-
readonly id: string;
|
|
388
|
-
readonly name?: string;
|
|
389
|
-
readonly input: string;
|
|
390
|
-
}) => any;
|
|
391
|
-
readonly InputReady: (args: {
|
|
392
|
-
readonly _tag: "InputReady";
|
|
393
|
-
readonly call: ToolCall;
|
|
394
|
-
}) => any;
|
|
395
|
-
readonly ApprovalRequested: (args: {
|
|
396
|
-
readonly _tag: "ApprovalRequested";
|
|
397
|
-
readonly call: ToolCall;
|
|
398
|
-
readonly request?: ToolApprovalRequest;
|
|
399
|
-
}) => any;
|
|
400
|
-
readonly Denied: (args: {
|
|
401
|
-
readonly _tag: "Denied";
|
|
402
|
-
readonly toolCallId: string;
|
|
403
|
-
readonly reason: string;
|
|
404
|
-
}) => any;
|
|
405
385
|
readonly QuestionRequested: (args: {
|
|
406
386
|
readonly _tag: "QuestionRequested";
|
|
407
387
|
readonly request: QuestionRequest;
|
|
@@ -444,6 +424,26 @@ declare const AgentToolRun: {
|
|
|
444
424
|
readonly response: InteractionResponse;
|
|
445
425
|
readonly request?: InteractionRequest;
|
|
446
426
|
}) => any;
|
|
427
|
+
readonly InputStreaming: (args: {
|
|
428
|
+
readonly _tag: "InputStreaming";
|
|
429
|
+
readonly id: string;
|
|
430
|
+
readonly name?: string;
|
|
431
|
+
readonly input: string;
|
|
432
|
+
}) => any;
|
|
433
|
+
readonly InputReady: (args: {
|
|
434
|
+
readonly _tag: "InputReady";
|
|
435
|
+
readonly call: ToolCall;
|
|
436
|
+
}) => any;
|
|
437
|
+
readonly ApprovalRequested: (args: {
|
|
438
|
+
readonly _tag: "ApprovalRequested";
|
|
439
|
+
readonly call: ToolCall;
|
|
440
|
+
readonly request?: ToolApprovalRequest;
|
|
441
|
+
}) => any;
|
|
442
|
+
readonly Denied: (args: {
|
|
443
|
+
readonly _tag: "Denied";
|
|
444
|
+
readonly toolCallId: string;
|
|
445
|
+
readonly reason: string;
|
|
446
|
+
}) => any;
|
|
447
447
|
readonly Executing: (args: {
|
|
448
448
|
readonly _tag: "Executing";
|
|
449
449
|
readonly call: ToolCall;
|
|
@@ -475,7 +475,7 @@ declare const AgentToolRun: {
|
|
|
475
475
|
readonly call: ToolCall;
|
|
476
476
|
readonly result: ToolResult;
|
|
477
477
|
}) => any;
|
|
478
|
-
}>(value: AgentToolRun, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["
|
|
478
|
+
}>(value: AgentToolRun, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
|
|
479
479
|
};
|
|
480
480
|
};
|
|
481
481
|
type AgentClientState = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.mts","names":[],"sources":["../../src/client/state.ts"],"mappings":";;;;KAoBY,cAAA;AAAA,KAEA,YAAA;EAAA,SAEG,IAAA;EAAA,SACA,EAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA;AAAA;EAAA,SAEA,IAAA;EAA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AAA;oBAWH,YAAA;AAAA;EAAA;oBAWM,kBAAA;AAAA;EAAA;qBAGtC,mBAAA;EAAA,mBACA,kBAAA;AAAA;EAAA;iBASJ,QAAA;EAAA;;;cA+HR,iBAAA,GAAqB,IAAA,EAAM,aAAA,CAAc,YAAA;EAAA;iBAxHjC,QAAA;EAAA,iBACE,UAAA;EAAA;;;cAoIV,wBAAA,GACX,QAAA,EAAU,aAAA,CAAc,WAAA,MACvB,aAAA,CAAc,YAAA;AAAA,cAwNJ,kBAAA,GACX,QAAA,EAAU,aAAA,CAAc,YAAA,GACxB,OAAA,EAAS,YAAA,KACR,eAAA;AAAA,cAUU,eAAA,GAAmB,KAAA,EAAO,gBAAA,EAAkB,KAAA,EAAO,UAAA,KAAa,gBAAA;AAAA,cAMhE,0BAAA,GACX,KAAA,EAAO,gBAAA,EACP,KAAA,EAAO,UAAA,EACP,OAAA,GAAS,sBAAA,KACR,gBAAA;AAAA,cA2SU,sBAAA,GACX,KAAA,EAAO,gBAAA,EACP,OAAA,EAAS,WAAA,KACR,gBAAA;AAAA,cAcU,cAAA,GACX,KAAA,EAAO,gBAAA,EACP,OAAA,WACA,SAAA,GAAW,UAAA,YACV,gBAAA;AAAA,cASU,gBAAA,GAAoB,KAAA,EAAO,gBAAA,KAAmB,gBAOzD;AAAA,cAEW,iBAAA,GACX,MAAA,EAAQ,aAAA,CAAc,UAAA,GACtB,YAAA,GAAc,gBAAA,EACd,OAAA,GAAS,sBAAA,KAA2B,gBAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/protocol/bounded-text.d.ts
|
|
2
|
+
/** Marker appended to text cut by `truncateUtf8` and `truncateCodePoints`. */
|
|
3
|
+
declare const truncationMarker = "\u2026";
|
|
4
|
+
/** UTF-8 byte length of `text` (a lone surrogate counts as the 3 bytes of U+FFFD). */
|
|
5
|
+
declare const utf8ByteLength: (text: string) => number;
|
|
6
|
+
/**
|
|
7
|
+
* `text` within `maxBytes` UTF-8 bytes: unchanged when it fits, else cut on a code point boundary
|
|
8
|
+
* (surrogate pairs and multi-byte characters stay whole) with a trailing `…` counted in the
|
|
9
|
+
* budget. A budget smaller than the marker yields `''`, so the result never exceeds `maxBytes`.
|
|
10
|
+
*/
|
|
11
|
+
declare const truncateUtf8: (text: string, maxBytes: number) => string;
|
|
12
|
+
/** `text` within `maxCharacters` code points: cut with a trailing `…` (counted) when longer. */
|
|
13
|
+
declare const truncateCodePoints: (text: string, maxCharacters: number) => string;
|
|
14
|
+
/** Compact JSON of tool call arguments: `null` for `undefined`, `[unserializable arguments]` when
|
|
15
|
+
* `JSON.stringify` throws (cycles, BigInt).
|
|
16
|
+
*/
|
|
17
|
+
declare const compactToolArguments: (args: unknown) => string;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { compactToolArguments, truncateCodePoints, truncateUtf8, truncationMarker, utf8ByteLength };
|
|
20
|
+
//# sourceMappingURL=bounded-text.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounded-text.d.mts","names":[],"sources":["../../src/protocol/bounded-text.ts"],"mappings":";;cAGa,gBAAA;;cAQA,cAAA,GAAkB,IAAY;;AARd;AAQ7B;;;cAea,YAAA,GAAgB,IAAA,UAAc,QAAgB;AAfhB;AAAA,cA4C9B,kBAAA,GAAsB,IAAA,UAAc,aAAqB;;;;cAezD,oBAAA,GAAwB,IAAa"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Predicate, Result } from "effect";
|
|
2
|
+
//#region src/protocol/bounded-text.ts
|
|
3
|
+
/** Marker appended to text cut by `truncateUtf8` and `truncateCodePoints`. */
|
|
4
|
+
const truncationMarker = "…";
|
|
5
|
+
const codePointUtf8Bytes = (codePoint) => codePoint <= 127 ? 1 : codePoint <= 2047 ? 2 : codePoint <= 65535 ? 3 : 4;
|
|
6
|
+
const characterUtf8Bytes = (character) => codePointUtf8Bytes(character.codePointAt(0) ?? 0);
|
|
7
|
+
/** UTF-8 byte length of `text` (a lone surrogate counts as the 3 bytes of U+FFFD). */
|
|
8
|
+
const utf8ByteLength = (text) => {
|
|
9
|
+
let bytes = 0;
|
|
10
|
+
for (const character of text) bytes += characterUtf8Bytes(character);
|
|
11
|
+
return bytes;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* `text` within `maxBytes` UTF-8 bytes: unchanged when it fits, else cut on a code point boundary
|
|
15
|
+
* (surrogate pairs and multi-byte characters stay whole) with a trailing `…` counted in the
|
|
16
|
+
* budget. A budget smaller than the marker yields `''`, so the result never exceeds `maxBytes`.
|
|
17
|
+
*/
|
|
18
|
+
const truncateUtf8 = (text, maxBytes) => {
|
|
19
|
+
if (utf8ByteLength(text) <= maxBytes) return text;
|
|
20
|
+
const budget = maxBytes - utf8ByteLength("…");
|
|
21
|
+
if (budget < 0) return "";
|
|
22
|
+
let bytes = 0;
|
|
23
|
+
let kept = "";
|
|
24
|
+
for (const character of text) {
|
|
25
|
+
const size = characterUtf8Bytes(character);
|
|
26
|
+
if (bytes + size > budget) break;
|
|
27
|
+
kept += character;
|
|
28
|
+
bytes += size;
|
|
29
|
+
}
|
|
30
|
+
return `${kept}…`;
|
|
31
|
+
};
|
|
32
|
+
/** `text` within `maxCharacters` code points: cut with a trailing `…` (counted) when longer. */
|
|
33
|
+
const truncateCodePoints = (text, maxCharacters) => {
|
|
34
|
+
const characters = Array.from(text);
|
|
35
|
+
if (characters.length <= maxCharacters) return text;
|
|
36
|
+
return maxCharacters < 1 ? "" : `${characters.slice(0, maxCharacters - 1).join("")}…`;
|
|
37
|
+
};
|
|
38
|
+
/** Compact JSON of tool call arguments: `null` for `undefined`, `[unserializable arguments]` when
|
|
39
|
+
* `JSON.stringify` throws (cycles, BigInt).
|
|
40
|
+
*/
|
|
41
|
+
const compactToolArguments = (args) => Result.match(Result.try(() => JSON.stringify(args)), {
|
|
42
|
+
onFailure: () => "[unserializable arguments]",
|
|
43
|
+
onSuccess: (encoded) => Predicate.isString(encoded) ? encoded : "null"
|
|
44
|
+
});
|
|
45
|
+
//#endregion
|
|
46
|
+
export { compactToolArguments, truncateCodePoints, truncateUtf8, truncationMarker, utf8ByteLength };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=bounded-text.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounded-text.mjs","names":[],"sources":["../../src/protocol/bounded-text.ts"],"sourcesContent":["import { Predicate, Result } from 'effect'\n\n/** Marker appended to text cut by `truncateUtf8` and `truncateCodePoints`. */\nexport const truncationMarker = '…'\n\nconst codePointUtf8Bytes = (codePoint: number) =>\n codePoint <= 0x7f ? 1 : codePoint <= 0x7ff ? 2 : codePoint <= 0xffff ? 3 : 4\n\nconst characterUtf8Bytes = (character: string) => codePointUtf8Bytes(character.codePointAt(0) ?? 0)\n\n/** UTF-8 byte length of `text` (a lone surrogate counts as the 3 bytes of U+FFFD). */\nexport const utf8ByteLength = (text: string) => {\n let bytes = 0\n\n for (const character of text) {\n bytes += characterUtf8Bytes(character)\n }\n\n return bytes\n}\n\n/**\n * `text` within `maxBytes` UTF-8 bytes: unchanged when it fits, else cut on a code point boundary\n * (surrogate pairs and multi-byte characters stay whole) with a trailing `…` counted in the\n * budget. A budget smaller than the marker yields `''`, so the result never exceeds `maxBytes`.\n */\nexport const truncateUtf8 = (text: string, maxBytes: number): string => {\n if (utf8ByteLength(text) <= maxBytes) {\n return text\n }\n\n const budget = maxBytes - utf8ByteLength(truncationMarker)\n\n if (budget < 0) {\n return ''\n }\n\n let bytes = 0\n let kept = ''\n\n for (const character of text) {\n const size = characterUtf8Bytes(character)\n\n if (bytes + size > budget) {\n break\n }\n\n kept += character\n bytes += size\n }\n\n return `${kept}${truncationMarker}`\n}\n\n/** `text` within `maxCharacters` code points: cut with a trailing `…` (counted) when longer. */\nexport const truncateCodePoints = (text: string, maxCharacters: number): string => {\n const characters = Array.from(text)\n\n if (characters.length <= maxCharacters) {\n return text\n }\n\n return maxCharacters < 1\n ? ''\n : `${characters.slice(0, maxCharacters - 1).join('')}${truncationMarker}`\n}\n\n/** Compact JSON of tool call arguments: `null` for `undefined`, `[unserializable arguments]` when\n * `JSON.stringify` throws (cycles, BigInt).\n */\nexport const compactToolArguments = (args: unknown): string =>\n Result.match(\n Result.try(() => JSON.stringify(args)),\n {\n onFailure: () => '[unserializable arguments]',\n onSuccess: (encoded: string | undefined) => (Predicate.isString(encoded) ? encoded : 'null')\n }\n )\n"],"mappings":";;;AAGA,MAAa,mBAAmB;AAEhC,MAAM,sBAAsB,cAC1B,aAAa,MAAO,IAAI,aAAa,OAAQ,IAAI,aAAa,QAAS,IAAI;AAE7E,MAAM,sBAAsB,cAAsB,mBAAmB,UAAU,YAAY,CAAC,KAAK,CAAC;;AAGlG,MAAa,kBAAkB,SAAiB;CAC9C,IAAI,QAAQ;CAEZ,KAAK,MAAM,aAAa,MACtB,SAAS,mBAAmB,SAAS;CAGvC,OAAO;AACT;;;;;;AAOA,MAAa,gBAAgB,MAAc,aAA6B;CACtE,IAAI,eAAe,IAAI,KAAK,UAC1B,OAAO;CAGT,MAAM,SAAS,WAAW,eAAA,GAA+B;CAEzD,IAAI,SAAS,GACX,OAAO;CAGT,IAAI,QAAQ;CACZ,IAAI,OAAO;CAEX,KAAK,MAAM,aAAa,MAAM;EAC5B,MAAM,OAAO,mBAAmB,SAAS;EAEzC,IAAI,QAAQ,OAAO,QACjB;EAGF,QAAQ;EACR,SAAS;CACX;CAEA,OAAO,GAAG;AACZ;;AAGA,MAAa,sBAAsB,MAAc,kBAAkC;CACjF,MAAM,aAAa,MAAM,KAAK,IAAI;CAElC,IAAI,WAAW,UAAU,eACvB,OAAO;CAGT,OAAO,gBAAgB,IACnB,KACA,GAAG,WAAW,MAAM,GAAG,gBAAgB,CAAC,EAAE,KAAK,EAAE;AACvD;;;;AAKA,MAAa,wBAAwB,SACnC,OAAO,MACL,OAAO,UAAU,KAAK,UAAU,IAAI,CAAC,GACrC;CACE,iBAAiB;CACjB,YAAY,YAAiC,UAAU,SAAS,OAAO,IAAI,UAAU;AACvF,CACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { truncateCodePoints } from "./bounded-text.mjs";
|
|
1
2
|
import { AgentContentCapabilities, AgentModelCapabilities, textImageDocumentModelCapabilities, textImageModelCapabilities, textOnlyModelCapabilities } from "./capability.mjs";
|
|
2
3
|
import { AttachmentContentPart, AttachmentSource, AttachmentSourceResolver, AudioPart, Content, ContentPart, DocumentPart, ImagePart, InlineBase64AttachmentSource, RefAttachmentSource, TextPart, UrlAttachmentSource, appendTextToContent, attachmentSourceBase64, attachmentSourceDataUrl, attachmentSourcePreview, attachmentSourceText, attachmentSourceUrl, contentPartPreview, contentPartText, contentParts, contentPreview, contentText, documentPartFromText, inferTextDocumentMimeType, inlineBase64AttachmentSource, inlineBase64Source, isContentEmpty, isTextDocumentMimeType, refAttachmentSource, replaceLoneSurrogates, replaceLoneSurrogatesDeep, resolveContentAttachmentSources, textDocumentMimeTypeFromFilename, textToBase64Utf8, urlAttachmentSource } from "./content.mjs";
|
|
3
4
|
import { AgentInputUsage, AgentOutputUsage, AgentUsage, addAgentUsage, zeroAgentUsage } from "./usage.mjs";
|
|
4
|
-
import { NestedToolCallInput, NestedToolCallRecord, NestedToolCallRecorder, NestedToolCallResultFields, NestedToolCallStatus, NestedToolCalls, emptyNestedToolCallRecorder, nestedToolCallMaxArgsBytes, nestedToolCallMaxCalls, nestedToolCallMaxErrorChars, nestedToolCallMaxTotalArgsBytes, nestedToolCallResultFields, recordNestedToolCall } from "./nested-tool-calls.mjs";
|
|
5
|
+
import { BoundedNestedToolCallArgs, NestedToolCallCounts, NestedToolCallInput, NestedToolCallRecord, NestedToolCallRecorder, NestedToolCallResultFields, NestedToolCallStatus, NestedToolCalls, boundNestedToolCallArgs, emptyNestedToolCallRecorder, makeNestedToolCallRecorder, nestedToolCallMaxArgsBytes, nestedToolCallMaxCalls, nestedToolCallMaxErrorChars, nestedToolCallMaxRecordedCalls, nestedToolCallMaxTotalArgsBytes, nestedToolCallRecordLimit, nestedToolCallResultFields, recordNestedToolCall } from "./nested-tool-calls.mjs";
|
|
5
6
|
import { BackgroundToolAccepted, BackgroundToolExecution, BackgroundToolInput, ErrorToolResultInput, HitlRequest, HitlResponse, HitlResponseSource, InputContentFormatter, InputDescriptor, InputRequest, InputResponse, InputResponseOutcome, InputResponseStructuredContent, InputResponseValidator, InputToolHandler, InteractionActionDescriptor, InteractionAdmissionError, InteractionBusinessOutcome, InteractionCandidate, InteractionClaim, InteractionDescriptor, InteractionHost, InteractionHostError, InteractionOutcome, InteractionPreflight, InteractionReceipt, InteractionReceiptStatus, InteractionRef, InteractionRequest, InteractionResponse, InteractionResponseOutcome, InteractionResponseStructuredContent, InteractionResponseValidator, InteractionValidationError, PlainHitlResponse, PlainInputResponse, PlainInteractionResponse, PlainQuestionAnswer, PlainQuestionResponse, PlainToolApprovalResponse, QuestionAnswer, QuestionOption, QuestionPrompt, QuestionRequest, QuestionResponse, QuestionResponseOutcome, QuestionResponseStructuredContent, QuestionToolParams, ToolApprovalDecision, ToolApprovalMode, ToolApprovalPolicy, ToolApprovalRequest, ToolApprovalResponse, ToolCall, ToolCallableBy, ToolDef, ToolDiscovery, ToolExposure, ToolJsonSchema, ToolJsonSchemaObject, ToolResult, decodeBackgroundToolInput, decodeToolJsonSchema, decodeToolJsonSchemaObject, formatInputResponseContent, formatInteractionResponseContent, formatQuestionResponseContent, inputRequestId, inputResponseStructuredContent, interactionJsonEquals, interactionRequestId, interactionResponseStructuredContent, interactionUnknownOutcomeNotice, isCodeModeCallable, isCodeModeFailClosed, isProviderToolDef, isToolJsonSchemaObject, makeBackgroundToolAcceptedResult, makeErrorToolResult, makeInteractionToolResult, plainHitlResponse, plainInputResponse, plainInteractionResponse, plainQuestionAnswer, plainQuestionResponse, plainToolApprovalResponse, providerToolDefs, questionResponseStructuredContent, sameInteractionBinding, sameInteractionCall, toolDiscovery, validInteractionReceipt, validateInteractionSubmission } from "./tool.mjs";
|
|
6
7
|
import { AgentMessage, AssistantAgentMessage, AssistantPart, AssistantReasoningPart, AssistantTextPart, DanglingHostToolCall, HostToolCallPart, MessageAnnotations, MessageAuthor, MessageEnvelope, ProviderToolCallPart, ProviderToolResultPart, RepairDanglingHostToolCallsOptions, ToolResultMessage, TranscriptInvariantValidation, UserMessage, assistantContent, assistantHostToolCalls, assistantReasoningText, danglingHostToolCalls, messageContextText, prependMessageContextToContent, repairDanglingHostToolCalls, resolveMessageAttachmentSources, resolveMessagesAttachmentSources, toolResultMessageFromResult, validateNoDanglingHostToolCalls } from "./message.mjs";
|
|
7
8
|
import { AgentAwaitingInput, AgentEnd, AgentError, AgentErrorCode, AgentEvent, AgentRetry, AgentStart, AssistantMessageEvent, CompactionEnd, CompactionStart, InputCancelled, InputRequested, InputSubmitted, InteractionCancelled, InteractionRequested, InteractionSubmitted, LLMReasoningDelta, LLMStreamEnd, LLMStreamStart, LLMTextDelta, ProviderErrorInfo, ProviderFailureKind, ProviderStreamDiagnostics, ProviderStreamProtocol, ProviderStreamResponseFormat, ProviderToolResult, QuestionAnswered, QuestionCancelled, QuestionRequested, SubagentCompleted, SubagentStarted, SubagentStatus, TerminalAgentEvent, ToolApprovalDenied, ToolApprovalGranted, ToolApprovalRequested, ToolExecutionAccepted, ToolExecutionCompleted, ToolExecutionError, ToolExecutionStarted, ToolInputDelta, ToolInputEnd, ToolInputStart, TurnEnd, TurnStart, UsageUpdate, UserMessageEvent, hitlResponseEvent, isTerminalAgentEvent, makeSubagentRunId } from "./event.mjs";
|
|
@@ -11,5 +12,5 @@ import { AgentWebSocketClientMessage, AgentWebSocketServerMessage, InputResponse
|
|
|
11
12
|
//#region src/protocol/index.d.ts
|
|
12
13
|
type MessageId = string;
|
|
13
14
|
//#endregion
|
|
14
|
-
export { AgentAwaitingInput, AgentContentCapabilities, AgentEnd, AgentError, AgentErrorCode, AgentEvent, AgentInputUsage, AgentMessage, AgentModelCapabilities, AgentOutputUsage, AgentReasoningEffort, AgentRetry, AgentStart, AgentUsage, AgentWebSocketClientMessage, AgentWebSocketServerMessage, AssistantAgentMessage, AssistantMessageEvent, AssistantPart, AssistantReasoningPart, AssistantTextPart, type AttachmentContentPart, AttachmentSource, type AttachmentSourceResolver, AudioPart, BackgroundToolAccepted, BackgroundToolExecution, BackgroundToolInput, CompactionEnd, CompactionStart, Content, ContentPart, type DanglingHostToolCall, DocumentPart, type ErrorToolResultInput, HitlRequest, HitlResponse, HitlResponseSource, HostToolCallPart, ImagePart, InlineBase64AttachmentSource, InputCancelled, type InputContentFormatter, InputDescriptor, InputRequest, InputRequested, InputResponse, InputResponseInput, InputResponseOutcome, type InputResponseStructuredContent, type InputResponseValidator, InputSubmitted, type InputToolHandler, InteractionActionDescriptor, InteractionAdmissionError, InteractionBusinessOutcome, InteractionCancelled, InteractionCandidate, InteractionClaim, InteractionDescriptor, type InteractionHost, InteractionHostError, type InteractionOutcome, type InteractionPreflight, InteractionReceipt, InteractionReceiptStatus, type InteractionRef, InteractionRequest, InteractionRequested, InteractionResponse, InteractionResponseInput, InteractionResponseOutcome, type InteractionResponseStructuredContent, type InteractionResponseValidator, InteractionSubmitted, InteractionValidationError, LLMReasoningDelta, LLMStreamEnd, LLMStreamStart, LLMTextDelta, MessageAnnotations, MessageAuthor, type MessageEnvelope, MessageId, type NestedToolCallInput, NestedToolCallRecord, type NestedToolCallRecorder, type NestedToolCallResultFields, NestedToolCallStatus, NestedToolCalls, PlainHitlResponse, type PlainInputResponse, type PlainInteractionResponse, type PlainQuestionAnswer, type PlainQuestionResponse, type PlainToolApprovalResponse, ProviderErrorInfo, ProviderFailureKind, ProviderStreamDiagnostics, ProviderStreamProtocol, ProviderStreamResponseFormat, ProviderToolCallPart, ProviderToolResult, ProviderToolResultPart, QuestionAnswer, QuestionAnswered, QuestionCancelled, QuestionOption, QuestionPrompt, QuestionRequest, QuestionRequested, QuestionResponse, QuestionResponseInput, QuestionResponseOutcome, type QuestionResponseStructuredContent, QuestionToolParams, RefAttachmentSource, type RepairDanglingHostToolCallsOptions, SessionSnapshot, SubagentCompleted, SubagentStarted, SubagentStatus, type TerminalAgentEvent, TextPart, ToolApprovalDecision, ToolApprovalDenied, ToolApprovalGranted, ToolApprovalMode, ToolApprovalPolicy, ToolApprovalRequest, ToolApprovalRequested, ToolApprovalResponse, ToolApprovalResponseInput, ToolCall, ToolCallableBy, ToolDef, ToolDiscovery, ToolExecutionAccepted, ToolExecutionCompleted, ToolExecutionError, ToolExecutionStarted, type ToolExposure, ToolInputDelta, ToolInputEnd, ToolInputStart, ToolJsonSchema, ToolJsonSchemaObject, ToolResult, ToolResultMessage, type TranscriptInvariantValidation, TurnEnd, TurnStart, UrlAttachmentSource, UsageUpdate, UserInput, UserMessage, UserMessageEvent, addAgentUsage, appendTextToContent, assistantContent, assistantHostToolCalls, assistantReasoningText, attachmentSourceBase64, attachmentSourceDataUrl, attachmentSourcePreview, attachmentSourceText, attachmentSourceUrl, contentPartPreview, contentPartText, contentParts, contentPreview, contentText, danglingHostToolCalls, decodeBackgroundToolInput, decodeToolJsonSchema, decodeToolJsonSchemaObject, documentPartFromText, emptyNestedToolCallRecorder, formatInputResponseContent, formatInteractionResponseContent, formatQuestionResponseContent, hitlResponseEvent, inferTextDocumentMimeType, inlineBase64AttachmentSource, inlineBase64Source, inputRequestId, inputResponseStructuredContent, interactionJsonEquals, interactionRequestId, interactionResponseStructuredContent, interactionUnknownOutcomeNotice, isCodeModeCallable, isCodeModeFailClosed, isContentEmpty, isProviderToolDef, isTerminalAgentEvent, isTextDocumentMimeType, isToolJsonSchemaObject, makeBackgroundToolAcceptedResult, makeErrorToolResult, makeInteractionToolResult, makeSubagentRunId, messageContextText, nestedToolCallMaxArgsBytes, nestedToolCallMaxCalls, nestedToolCallMaxErrorChars, nestedToolCallMaxTotalArgsBytes, nestedToolCallResultFields, plainHitlResponse, plainInputResponse, plainInteractionResponse, plainQuestionAnswer, plainQuestionResponse, plainToolApprovalResponse, prependMessageContextToContent, providerToolDefs, questionResponseStructuredContent, recordNestedToolCall, refAttachmentSource, repairDanglingHostToolCalls, replaceLoneSurrogates, replaceLoneSurrogatesDeep, resolveContentAttachmentSources, resolveMessageAttachmentSources, resolveMessagesAttachmentSources, sameInteractionBinding, sameInteractionCall, textDocumentMimeTypeFromFilename, textImageDocumentModelCapabilities, textImageModelCapabilities, textOnlyModelCapabilities, textToBase64Utf8, toolDiscovery, toolResultMessageFromResult, urlAttachmentSource, validInteractionReceipt, validateInteractionSubmission, validateNoDanglingHostToolCalls, zeroAgentUsage };
|
|
15
|
+
export { AgentAwaitingInput, AgentContentCapabilities, AgentEnd, AgentError, AgentErrorCode, AgentEvent, AgentInputUsage, AgentMessage, AgentModelCapabilities, AgentOutputUsage, AgentReasoningEffort, AgentRetry, AgentStart, AgentUsage, AgentWebSocketClientMessage, AgentWebSocketServerMessage, AssistantAgentMessage, AssistantMessageEvent, AssistantPart, AssistantReasoningPart, AssistantTextPart, type AttachmentContentPart, AttachmentSource, type AttachmentSourceResolver, AudioPart, BackgroundToolAccepted, BackgroundToolExecution, BackgroundToolInput, type BoundedNestedToolCallArgs, CompactionEnd, CompactionStart, Content, ContentPart, type DanglingHostToolCall, DocumentPart, type ErrorToolResultInput, HitlRequest, HitlResponse, HitlResponseSource, HostToolCallPart, ImagePart, InlineBase64AttachmentSource, InputCancelled, type InputContentFormatter, InputDescriptor, InputRequest, InputRequested, InputResponse, InputResponseInput, InputResponseOutcome, type InputResponseStructuredContent, type InputResponseValidator, InputSubmitted, type InputToolHandler, InteractionActionDescriptor, InteractionAdmissionError, InteractionBusinessOutcome, InteractionCancelled, InteractionCandidate, InteractionClaim, InteractionDescriptor, type InteractionHost, InteractionHostError, type InteractionOutcome, type InteractionPreflight, InteractionReceipt, InteractionReceiptStatus, type InteractionRef, InteractionRequest, InteractionRequested, InteractionResponse, InteractionResponseInput, InteractionResponseOutcome, type InteractionResponseStructuredContent, type InteractionResponseValidator, InteractionSubmitted, InteractionValidationError, LLMReasoningDelta, LLMStreamEnd, LLMStreamStart, LLMTextDelta, MessageAnnotations, MessageAuthor, type MessageEnvelope, MessageId, NestedToolCallCounts, type NestedToolCallInput, NestedToolCallRecord, type NestedToolCallRecorder, type NestedToolCallResultFields, NestedToolCallStatus, NestedToolCalls, PlainHitlResponse, type PlainInputResponse, type PlainInteractionResponse, type PlainQuestionAnswer, type PlainQuestionResponse, type PlainToolApprovalResponse, ProviderErrorInfo, ProviderFailureKind, ProviderStreamDiagnostics, ProviderStreamProtocol, ProviderStreamResponseFormat, ProviderToolCallPart, ProviderToolResult, ProviderToolResultPart, QuestionAnswer, QuestionAnswered, QuestionCancelled, QuestionOption, QuestionPrompt, QuestionRequest, QuestionRequested, QuestionResponse, QuestionResponseInput, QuestionResponseOutcome, type QuestionResponseStructuredContent, QuestionToolParams, RefAttachmentSource, type RepairDanglingHostToolCallsOptions, SessionSnapshot, SubagentCompleted, SubagentStarted, SubagentStatus, type TerminalAgentEvent, TextPart, ToolApprovalDecision, ToolApprovalDenied, ToolApprovalGranted, ToolApprovalMode, ToolApprovalPolicy, ToolApprovalRequest, ToolApprovalRequested, ToolApprovalResponse, ToolApprovalResponseInput, ToolCall, ToolCallableBy, ToolDef, ToolDiscovery, ToolExecutionAccepted, ToolExecutionCompleted, ToolExecutionError, ToolExecutionStarted, type ToolExposure, ToolInputDelta, ToolInputEnd, ToolInputStart, ToolJsonSchema, ToolJsonSchemaObject, ToolResult, ToolResultMessage, type TranscriptInvariantValidation, TurnEnd, TurnStart, UrlAttachmentSource, UsageUpdate, UserInput, UserMessage, UserMessageEvent, addAgentUsage, appendTextToContent, assistantContent, assistantHostToolCalls, assistantReasoningText, attachmentSourceBase64, attachmentSourceDataUrl, attachmentSourcePreview, attachmentSourceText, attachmentSourceUrl, boundNestedToolCallArgs, contentPartPreview, contentPartText, contentParts, contentPreview, contentText, danglingHostToolCalls, decodeBackgroundToolInput, decodeToolJsonSchema, decodeToolJsonSchemaObject, documentPartFromText, emptyNestedToolCallRecorder, formatInputResponseContent, formatInteractionResponseContent, formatQuestionResponseContent, hitlResponseEvent, inferTextDocumentMimeType, inlineBase64AttachmentSource, inlineBase64Source, inputRequestId, inputResponseStructuredContent, interactionJsonEquals, interactionRequestId, interactionResponseStructuredContent, interactionUnknownOutcomeNotice, isCodeModeCallable, isCodeModeFailClosed, isContentEmpty, isProviderToolDef, isTerminalAgentEvent, isTextDocumentMimeType, isToolJsonSchemaObject, makeBackgroundToolAcceptedResult, makeErrorToolResult, makeInteractionToolResult, makeNestedToolCallRecorder, makeSubagentRunId, messageContextText, nestedToolCallMaxArgsBytes, nestedToolCallMaxCalls, nestedToolCallMaxErrorChars, nestedToolCallMaxRecordedCalls, nestedToolCallMaxTotalArgsBytes, nestedToolCallRecordLimit, nestedToolCallResultFields, plainHitlResponse, plainInputResponse, plainInteractionResponse, plainQuestionAnswer, plainQuestionResponse, plainToolApprovalResponse, prependMessageContextToContent, providerToolDefs, questionResponseStructuredContent, recordNestedToolCall, refAttachmentSource, repairDanglingHostToolCalls, replaceLoneSurrogates, replaceLoneSurrogatesDeep, resolveContentAttachmentSources, resolveMessageAttachmentSources, resolveMessagesAttachmentSources, sameInteractionBinding, sameInteractionCall, textDocumentMimeTypeFromFilename, textImageDocumentModelCapabilities, textImageModelCapabilities, textOnlyModelCapabilities, textToBase64Utf8, toolDiscovery, toolResultMessageFromResult, truncateCodePoints, urlAttachmentSource, validInteractionReceipt, validateInteractionSubmission, validateNoDanglingHostToolCalls, zeroAgentUsage };
|
|
15
16
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/protocol/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/protocol/index.ts"],"mappings":";;;;;;;;;;;;KAwRY,SAAA"}
|
package/dist/protocol/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { AttachmentSource, AudioPart, Content, ContentPart, DocumentPart, ImagePart, InlineBase64AttachmentSource, RefAttachmentSource, TextPart, UrlAttachmentSource, appendTextToContent, attachmentSourceBase64, attachmentSourceDataUrl, attachmentSourcePreview, attachmentSourceText, attachmentSourceUrl, contentPartPreview, contentPartText, contentParts, contentPreview, contentText, documentPartFromText, inferTextDocumentMimeType, inlineBase64AttachmentSource, inlineBase64Source, isContentEmpty, isTextDocumentMimeType, refAttachmentSource, replaceLoneSurrogates, replaceLoneSurrogatesDeep, resolveContentAttachmentSources, textDocumentMimeTypeFromFilename, textToBase64Utf8, urlAttachmentSource } from "./content.mjs";
|
|
2
|
+
import { truncateCodePoints } from "./bounded-text.mjs";
|
|
2
3
|
import { AgentInputUsage, AgentOutputUsage, AgentUsage, addAgentUsage, zeroAgentUsage } from "./usage.mjs";
|
|
3
|
-
import { NestedToolCallRecord, NestedToolCallStatus, NestedToolCalls, emptyNestedToolCallRecorder, nestedToolCallMaxArgsBytes, nestedToolCallMaxCalls, nestedToolCallMaxErrorChars, nestedToolCallMaxTotalArgsBytes, nestedToolCallResultFields, recordNestedToolCall } from "./nested-tool-calls.mjs";
|
|
4
|
+
import { NestedToolCallCounts, NestedToolCallRecord, NestedToolCallStatus, NestedToolCalls, boundNestedToolCallArgs, emptyNestedToolCallRecorder, makeNestedToolCallRecorder, nestedToolCallMaxArgsBytes, nestedToolCallMaxCalls, nestedToolCallMaxErrorChars, nestedToolCallMaxRecordedCalls, nestedToolCallMaxTotalArgsBytes, nestedToolCallRecordLimit, nestedToolCallResultFields, recordNestedToolCall } from "./nested-tool-calls.mjs";
|
|
4
5
|
import { BackgroundToolAccepted, BackgroundToolExecution, BackgroundToolInput, HitlRequest, HitlResponse, HitlResponseSource, InputDescriptor, InputRequest, InputResponse, InputResponseOutcome, InteractionActionDescriptor, InteractionAdmissionError, InteractionBusinessOutcome, InteractionCandidate, InteractionClaim, InteractionDescriptor, InteractionHostError, InteractionReceipt, InteractionReceiptStatus, InteractionRequest, InteractionResponse, InteractionResponseOutcome, InteractionValidationError, PlainHitlResponse, QuestionAnswer, QuestionOption, QuestionPrompt, QuestionRequest, QuestionResponse, QuestionResponseOutcome, QuestionToolParams, ToolApprovalDecision, ToolApprovalMode, ToolApprovalPolicy, ToolApprovalRequest, ToolApprovalResponse, ToolCall, ToolCallableBy, ToolDef, ToolDiscovery, ToolJsonSchema, ToolJsonSchemaObject, ToolResult, decodeBackgroundToolInput, decodeToolJsonSchema, decodeToolJsonSchemaObject, formatInputResponseContent, formatInteractionResponseContent, formatQuestionResponseContent, inputRequestId, inputResponseStructuredContent, interactionJsonEquals, interactionRequestId, interactionResponseStructuredContent, interactionUnknownOutcomeNotice, isCodeModeCallable, isCodeModeFailClosed, isProviderToolDef, isToolJsonSchemaObject, makeBackgroundToolAcceptedResult, makeErrorToolResult, makeInteractionToolResult, plainHitlResponse, plainInputResponse, plainInteractionResponse, plainQuestionAnswer, plainQuestionResponse, plainToolApprovalResponse, providerToolDefs, questionResponseStructuredContent, sameInteractionBinding, sameInteractionCall, toolDiscovery, validInteractionReceipt, validateInteractionSubmission } from "./tool.mjs";
|
|
5
6
|
import { AgentContentCapabilities, AgentModelCapabilities, textImageDocumentModelCapabilities, textImageModelCapabilities, textOnlyModelCapabilities } from "./capability.mjs";
|
|
6
7
|
import { AgentMessage, AssistantAgentMessage, AssistantPart, AssistantReasoningPart, AssistantTextPart, HostToolCallPart, MessageAnnotations, MessageAuthor, ProviderToolCallPart, ProviderToolResultPart, ToolResultMessage, UserMessage, assistantContent, assistantHostToolCalls, assistantReasoningText, danglingHostToolCalls, messageContextText, prependMessageContextToContent, repairDanglingHostToolCalls, resolveMessageAttachmentSources, resolveMessagesAttachmentSources, toolResultMessageFromResult, validateNoDanglingHostToolCalls } from "./message.mjs";
|
|
7
8
|
import { AgentAwaitingInput, AgentEnd, AgentError, AgentErrorCode, AgentEvent, AgentRetry, AgentStart, AssistantMessageEvent, CompactionEnd, CompactionStart, InputCancelled, InputRequested, InputSubmitted, InteractionCancelled, InteractionRequested, InteractionSubmitted, LLMReasoningDelta, LLMStreamEnd, LLMStreamStart, LLMTextDelta, ProviderErrorInfo, ProviderFailureKind, ProviderStreamDiagnostics, ProviderStreamProtocol, ProviderStreamResponseFormat, ProviderToolResult, QuestionAnswered, QuestionCancelled, QuestionRequested, SubagentCompleted, SubagentStarted, SubagentStatus, ToolApprovalDenied, ToolApprovalGranted, ToolApprovalRequested, ToolExecutionAccepted, ToolExecutionCompleted, ToolExecutionError, ToolExecutionStarted, ToolInputDelta, ToolInputEnd, ToolInputStart, TurnEnd, TurnStart, UsageUpdate, UserMessageEvent, hitlResponseEvent, isTerminalAgentEvent, makeSubagentRunId } from "./event.mjs";
|
|
8
9
|
import { AgentReasoningEffort } from "./reasoning.mjs";
|
|
9
10
|
import { AgentWebSocketClientMessage, AgentWebSocketServerMessage, InputResponseInput, InteractionResponseInput, QuestionResponseInput, SessionSnapshot, ToolApprovalResponseInput, UserInput } from "./session.mjs";
|
|
10
|
-
export { AgentAwaitingInput, AgentContentCapabilities, AgentEnd, AgentError, AgentErrorCode, AgentEvent, AgentInputUsage, AgentMessage, AgentModelCapabilities, AgentOutputUsage, AgentReasoningEffort, AgentRetry, AgentStart, AgentUsage, AgentWebSocketClientMessage, AgentWebSocketServerMessage, AssistantAgentMessage, AssistantMessageEvent, AssistantPart, AssistantReasoningPart, AssistantTextPart, AttachmentSource, AudioPart, BackgroundToolAccepted, BackgroundToolExecution, BackgroundToolInput, CompactionEnd, CompactionStart, Content, ContentPart, DocumentPart, HitlRequest, HitlResponse, HitlResponseSource, HostToolCallPart, ImagePart, InlineBase64AttachmentSource, InputCancelled, InputDescriptor, InputRequest, InputRequested, InputResponse, InputResponseInput, InputResponseOutcome, InputSubmitted, InteractionActionDescriptor, InteractionAdmissionError, InteractionBusinessOutcome, InteractionCancelled, InteractionCandidate, InteractionClaim, InteractionDescriptor, InteractionHostError, InteractionReceipt, InteractionReceiptStatus, InteractionRequest, InteractionRequested, InteractionResponse, InteractionResponseInput, InteractionResponseOutcome, InteractionSubmitted, InteractionValidationError, LLMReasoningDelta, LLMStreamEnd, LLMStreamStart, LLMTextDelta, MessageAnnotations, MessageAuthor, NestedToolCallRecord, NestedToolCallStatus, NestedToolCalls, PlainHitlResponse, ProviderErrorInfo, ProviderFailureKind, ProviderStreamDiagnostics, ProviderStreamProtocol, ProviderStreamResponseFormat, ProviderToolCallPart, ProviderToolResult, ProviderToolResultPart, QuestionAnswer, QuestionAnswered, QuestionCancelled, QuestionOption, QuestionPrompt, QuestionRequest, QuestionRequested, QuestionResponse, QuestionResponseInput, QuestionResponseOutcome, QuestionToolParams, RefAttachmentSource, SessionSnapshot, SubagentCompleted, SubagentStarted, SubagentStatus, TextPart, ToolApprovalDecision, ToolApprovalDenied, ToolApprovalGranted, ToolApprovalMode, ToolApprovalPolicy, ToolApprovalRequest, ToolApprovalRequested, ToolApprovalResponse, ToolApprovalResponseInput, ToolCall, ToolCallableBy, ToolDef, ToolDiscovery, ToolExecutionAccepted, ToolExecutionCompleted, ToolExecutionError, ToolExecutionStarted, ToolInputDelta, ToolInputEnd, ToolInputStart, ToolJsonSchema, ToolJsonSchemaObject, ToolResult, ToolResultMessage, TurnEnd, TurnStart, UrlAttachmentSource, UsageUpdate, UserInput, UserMessage, UserMessageEvent, addAgentUsage, appendTextToContent, assistantContent, assistantHostToolCalls, assistantReasoningText, attachmentSourceBase64, attachmentSourceDataUrl, attachmentSourcePreview, attachmentSourceText, attachmentSourceUrl, contentPartPreview, contentPartText, contentParts, contentPreview, contentText, danglingHostToolCalls, decodeBackgroundToolInput, decodeToolJsonSchema, decodeToolJsonSchemaObject, documentPartFromText, emptyNestedToolCallRecorder, formatInputResponseContent, formatInteractionResponseContent, formatQuestionResponseContent, hitlResponseEvent, inferTextDocumentMimeType, inlineBase64AttachmentSource, inlineBase64Source, inputRequestId, inputResponseStructuredContent, interactionJsonEquals, interactionRequestId, interactionResponseStructuredContent, interactionUnknownOutcomeNotice, isCodeModeCallable, isCodeModeFailClosed, isContentEmpty, isProviderToolDef, isTerminalAgentEvent, isTextDocumentMimeType, isToolJsonSchemaObject, makeBackgroundToolAcceptedResult, makeErrorToolResult, makeInteractionToolResult, makeSubagentRunId, messageContextText, nestedToolCallMaxArgsBytes, nestedToolCallMaxCalls, nestedToolCallMaxErrorChars, nestedToolCallMaxTotalArgsBytes, nestedToolCallResultFields, plainHitlResponse, plainInputResponse, plainInteractionResponse, plainQuestionAnswer, plainQuestionResponse, plainToolApprovalResponse, prependMessageContextToContent, providerToolDefs, questionResponseStructuredContent, recordNestedToolCall, refAttachmentSource, repairDanglingHostToolCalls, replaceLoneSurrogates, replaceLoneSurrogatesDeep, resolveContentAttachmentSources, resolveMessageAttachmentSources, resolveMessagesAttachmentSources, sameInteractionBinding, sameInteractionCall, textDocumentMimeTypeFromFilename, textImageDocumentModelCapabilities, textImageModelCapabilities, textOnlyModelCapabilities, textToBase64Utf8, toolDiscovery, toolResultMessageFromResult, urlAttachmentSource, validInteractionReceipt, validateInteractionSubmission, validateNoDanglingHostToolCalls, zeroAgentUsage };
|
|
11
|
+
export { AgentAwaitingInput, AgentContentCapabilities, AgentEnd, AgentError, AgentErrorCode, AgentEvent, AgentInputUsage, AgentMessage, AgentModelCapabilities, AgentOutputUsage, AgentReasoningEffort, AgentRetry, AgentStart, AgentUsage, AgentWebSocketClientMessage, AgentWebSocketServerMessage, AssistantAgentMessage, AssistantMessageEvent, AssistantPart, AssistantReasoningPart, AssistantTextPart, AttachmentSource, AudioPart, BackgroundToolAccepted, BackgroundToolExecution, BackgroundToolInput, CompactionEnd, CompactionStart, Content, ContentPart, DocumentPart, HitlRequest, HitlResponse, HitlResponseSource, HostToolCallPart, ImagePart, InlineBase64AttachmentSource, InputCancelled, InputDescriptor, InputRequest, InputRequested, InputResponse, InputResponseInput, InputResponseOutcome, InputSubmitted, InteractionActionDescriptor, InteractionAdmissionError, InteractionBusinessOutcome, InteractionCancelled, InteractionCandidate, InteractionClaim, InteractionDescriptor, InteractionHostError, InteractionReceipt, InteractionReceiptStatus, InteractionRequest, InteractionRequested, InteractionResponse, InteractionResponseInput, InteractionResponseOutcome, InteractionSubmitted, InteractionValidationError, LLMReasoningDelta, LLMStreamEnd, LLMStreamStart, LLMTextDelta, MessageAnnotations, MessageAuthor, NestedToolCallCounts, NestedToolCallRecord, NestedToolCallStatus, NestedToolCalls, PlainHitlResponse, ProviderErrorInfo, ProviderFailureKind, ProviderStreamDiagnostics, ProviderStreamProtocol, ProviderStreamResponseFormat, ProviderToolCallPart, ProviderToolResult, ProviderToolResultPart, QuestionAnswer, QuestionAnswered, QuestionCancelled, QuestionOption, QuestionPrompt, QuestionRequest, QuestionRequested, QuestionResponse, QuestionResponseInput, QuestionResponseOutcome, QuestionToolParams, RefAttachmentSource, SessionSnapshot, SubagentCompleted, SubagentStarted, SubagentStatus, TextPart, ToolApprovalDecision, ToolApprovalDenied, ToolApprovalGranted, ToolApprovalMode, ToolApprovalPolicy, ToolApprovalRequest, ToolApprovalRequested, ToolApprovalResponse, ToolApprovalResponseInput, ToolCall, ToolCallableBy, ToolDef, ToolDiscovery, ToolExecutionAccepted, ToolExecutionCompleted, ToolExecutionError, ToolExecutionStarted, ToolInputDelta, ToolInputEnd, ToolInputStart, ToolJsonSchema, ToolJsonSchemaObject, ToolResult, ToolResultMessage, TurnEnd, TurnStart, UrlAttachmentSource, UsageUpdate, UserInput, UserMessage, UserMessageEvent, addAgentUsage, appendTextToContent, assistantContent, assistantHostToolCalls, assistantReasoningText, attachmentSourceBase64, attachmentSourceDataUrl, attachmentSourcePreview, attachmentSourceText, attachmentSourceUrl, boundNestedToolCallArgs, contentPartPreview, contentPartText, contentParts, contentPreview, contentText, danglingHostToolCalls, decodeBackgroundToolInput, decodeToolJsonSchema, decodeToolJsonSchemaObject, documentPartFromText, emptyNestedToolCallRecorder, formatInputResponseContent, formatInteractionResponseContent, formatQuestionResponseContent, hitlResponseEvent, inferTextDocumentMimeType, inlineBase64AttachmentSource, inlineBase64Source, inputRequestId, inputResponseStructuredContent, interactionJsonEquals, interactionRequestId, interactionResponseStructuredContent, interactionUnknownOutcomeNotice, isCodeModeCallable, isCodeModeFailClosed, isContentEmpty, isProviderToolDef, isTerminalAgentEvent, isTextDocumentMimeType, isToolJsonSchemaObject, makeBackgroundToolAcceptedResult, makeErrorToolResult, makeInteractionToolResult, makeNestedToolCallRecorder, makeSubagentRunId, messageContextText, nestedToolCallMaxArgsBytes, nestedToolCallMaxCalls, nestedToolCallMaxErrorChars, nestedToolCallMaxRecordedCalls, nestedToolCallMaxTotalArgsBytes, nestedToolCallRecordLimit, nestedToolCallResultFields, plainHitlResponse, plainInputResponse, plainInteractionResponse, plainQuestionAnswer, plainQuestionResponse, plainToolApprovalResponse, prependMessageContextToContent, providerToolDefs, questionResponseStructuredContent, recordNestedToolCall, refAttachmentSource, repairDanglingHostToolCalls, replaceLoneSurrogates, replaceLoneSurrogatesDeep, resolveContentAttachmentSources, resolveMessageAttachmentSources, resolveMessagesAttachmentSources, sameInteractionBinding, sameInteractionCall, textDocumentMimeTypeFromFilename, textImageDocumentModelCapabilities, textImageModelCapabilities, textOnlyModelCapabilities, textToBase64Utf8, toolDiscovery, toolResultMessageFromResult, truncateCodePoints, urlAttachmentSource, validInteractionReceipt, validateInteractionSubmission, validateNoDanglingHostToolCalls, zeroAgentUsage };
|
|
@@ -2,8 +2,17 @@ import { AgentUsage } from "./usage.mjs";
|
|
|
2
2
|
import * as Schema from "effect/Schema";
|
|
3
3
|
|
|
4
4
|
//#region src/protocol/nested-tool-calls.d.ts
|
|
5
|
-
/**
|
|
5
|
+
/** Default number of nested calls a record keeps; later calls are dropped (counted, not listed)
|
|
6
|
+
* and mark the record incomplete. Callers size the record to their own call limit with
|
|
7
|
+
* `makeNestedToolCallRecorder({ maxCalls })` (code mode uses `limits.maxNestedCalls`).
|
|
8
|
+
*/
|
|
6
9
|
declare const nestedToolCallMaxCalls = 256;
|
|
10
|
+
/** Ceiling of any record's `maxCalls`: a larger (or infinite) limit keeps this many calls. */
|
|
11
|
+
declare const nestedToolCallMaxRecordedCalls = 4096;
|
|
12
|
+
/** The number of calls a record keeps for a requested `maxCalls`: whole, within
|
|
13
|
+
* `0..nestedToolCallMaxRecordedCalls`; `NaN` and absent mean `nestedToolCallMaxCalls`.
|
|
14
|
+
*/
|
|
15
|
+
declare const nestedToolCallRecordLimit: (maxCalls: number | undefined) => number;
|
|
7
16
|
/** UTF-8 byte budget for one recorded call's compact JSON arguments. */
|
|
8
17
|
declare const nestedToolCallMaxArgsBytes: number;
|
|
9
18
|
/** UTF-8 byte budget for the compact JSON arguments of all recorded calls together. */
|
|
@@ -26,11 +35,22 @@ declare const NestedToolCallRecord_base: Schema.Class<NestedToolCallRecord, Sche
|
|
|
26
35
|
* `args` is compact JSON, cut to the byte bounds with a trailing `…` (then no longer JSON).
|
|
27
36
|
*/
|
|
28
37
|
declare class NestedToolCallRecord extends NestedToolCallRecord_base {}
|
|
38
|
+
declare const NestedToolCallCounts_base: Schema.Class<NestedToolCallCounts, Schema.Struct<{
|
|
39
|
+
readonly ok: Schema.Number;
|
|
40
|
+
readonly error: Schema.Number;
|
|
41
|
+
readonly cancelled: Schema.Number;
|
|
42
|
+
}>, {}>;
|
|
43
|
+
/** Calls per status over every recorded call, including calls dropped from `calls`. */
|
|
44
|
+
declare class NestedToolCallCounts extends NestedToolCallCounts_base {}
|
|
29
45
|
declare const NestedToolCalls_base: Schema.Class<NestedToolCalls, Schema.Struct<{
|
|
30
46
|
readonly calls: Schema.$Array<typeof NestedToolCallRecord>;
|
|
31
47
|
readonly complete: Schema.Boolean;
|
|
48
|
+
readonly counts: Schema.optional<typeof NestedToolCallCounts>;
|
|
32
49
|
}>, {}>;
|
|
33
|
-
/** Bounded nested-call record. `complete: false` means calls were dropped or arguments cut.
|
|
50
|
+
/** Bounded nested-call record. `complete: false` means calls were dropped or arguments cut.
|
|
51
|
+
* `counts` (absent on records written before it existed) counts every call by status, dropped
|
|
52
|
+
* calls included, so totals stay correct when `calls` is cut.
|
|
53
|
+
*/
|
|
34
54
|
declare class NestedToolCalls extends NestedToolCalls_base {}
|
|
35
55
|
type NestedToolCallInput = {
|
|
36
56
|
/** Caller-assigned id; the convention is `<parentToolCallId>/<seq>`. */readonly id: string;
|
|
@@ -41,27 +61,56 @@ type NestedToolCallInput = {
|
|
|
41
61
|
readonly error?: string;
|
|
42
62
|
readonly usage?: AgentUsage;
|
|
43
63
|
};
|
|
44
|
-
|
|
45
|
-
|
|
64
|
+
type StatusCounts = {
|
|
65
|
+
readonly ok: number;
|
|
66
|
+
readonly error: number;
|
|
67
|
+
readonly cancelled: number;
|
|
68
|
+
};
|
|
69
|
+
/** Immutable recorder state. Fold calls with `recordNestedToolCall`; usage and status counts of
|
|
70
|
+
* dropped calls still count. `maxCalls` defaults to `nestedToolCallMaxCalls`.
|
|
46
71
|
*/
|
|
47
72
|
type NestedToolCallRecorder = {
|
|
48
73
|
readonly calls: ReadonlyArray<NestedToolCallRecord>;
|
|
49
74
|
readonly complete: boolean;
|
|
50
75
|
readonly argsBytes: number;
|
|
51
76
|
readonly usage?: AgentUsage;
|
|
77
|
+
readonly maxCalls?: number;
|
|
78
|
+
readonly counts?: StatusCounts;
|
|
52
79
|
};
|
|
80
|
+
/** An empty recorder keeping at most `maxCalls` calls (default `nestedToolCallMaxCalls`, clamped
|
|
81
|
+
* by `nestedToolCallRecordLimit` to at most `nestedToolCallMaxRecordedCalls`); the argument byte
|
|
82
|
+
* budgets are fixed.
|
|
83
|
+
*/
|
|
84
|
+
declare const makeNestedToolCallRecorder: (options?: {
|
|
85
|
+
readonly maxCalls?: number;
|
|
86
|
+
}) => NestedToolCallRecorder;
|
|
53
87
|
declare const emptyNestedToolCallRecorder: NestedToolCallRecorder;
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
88
|
+
/** One call's arguments cut to the nested-call record budgets (see `boundNestedToolCallArgs`). */
|
|
89
|
+
type BoundedNestedToolCallArgs = {
|
|
90
|
+
/** The kept compact JSON, cut with a trailing `…` when `truncated`. */readonly args: string; /** UTF-8 bytes of `args`. */
|
|
91
|
+
readonly bytes: number;
|
|
92
|
+
readonly truncated: boolean;
|
|
93
|
+
};
|
|
94
|
+
/** One call's compact JSON arguments within the record budgets: at most
|
|
95
|
+
* `nestedToolCallMaxArgsBytes`, and at most what `usedBytes` leaves of
|
|
96
|
+
* `nestedToolCallMaxTotalArgsBytes`. Shared by every bounded nested-call listing (`nestedCalls`,
|
|
97
|
+
* code mode `interruptedCalls`) so the bounds cannot drift.
|
|
98
|
+
*/
|
|
99
|
+
declare const boundNestedToolCallArgs: (args: string, usedBytes: number) => BoundedNestedToolCallArgs;
|
|
100
|
+
/** Pure fold step enforcing the record bounds. Calls past the recorder's `maxCalls` are dropped
|
|
101
|
+
* (still counted by status), arguments past the per-call or total byte budget are cut; either marks
|
|
102
|
+
* the record incomplete. Errors are always cut to `nestedToolCallMaxErrorChars` without affecting
|
|
103
|
+
* completeness.
|
|
57
104
|
*/
|
|
58
105
|
declare const recordNestedToolCall: (recorder: NestedToolCallRecorder, input: NestedToolCallInput) => NestedToolCallRecorder;
|
|
59
106
|
type NestedToolCallResultFields = {
|
|
60
107
|
readonly nestedCalls: NestedToolCalls;
|
|
61
108
|
readonly usage?: AgentUsage;
|
|
62
109
|
};
|
|
63
|
-
/** `ToolResult` fields for a recorder: the bounded record
|
|
110
|
+
/** `ToolResult` fields for a recorder: the bounded record with per-status counts plus summed
|
|
111
|
+
* usage when reported.
|
|
112
|
+
*/
|
|
64
113
|
declare const nestedToolCallResultFields: (recorder: NestedToolCallRecorder) => NestedToolCallResultFields;
|
|
65
114
|
//#endregion
|
|
66
|
-
export { NestedToolCallInput, NestedToolCallRecord, NestedToolCallRecorder, NestedToolCallResultFields, NestedToolCallStatus, NestedToolCalls, emptyNestedToolCallRecorder, nestedToolCallMaxArgsBytes, nestedToolCallMaxCalls, nestedToolCallMaxErrorChars, nestedToolCallMaxTotalArgsBytes, nestedToolCallResultFields, recordNestedToolCall };
|
|
115
|
+
export { BoundedNestedToolCallArgs, NestedToolCallCounts, NestedToolCallInput, NestedToolCallRecord, NestedToolCallRecorder, NestedToolCallResultFields, NestedToolCallStatus, NestedToolCalls, boundNestedToolCallArgs, emptyNestedToolCallRecorder, makeNestedToolCallRecorder, nestedToolCallMaxArgsBytes, nestedToolCallMaxCalls, nestedToolCallMaxErrorChars, nestedToolCallMaxRecordedCalls, nestedToolCallMaxTotalArgsBytes, nestedToolCallRecordLimit, nestedToolCallResultFields, recordNestedToolCall };
|
|
67
116
|
//# sourceMappingURL=nested-tool-calls.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nested-tool-calls.d.mts","names":[],"sources":["../../src/protocol/nested-tool-calls.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"nested-tool-calls.d.mts","names":[],"sources":["../../src/protocol/nested-tool-calls.ts"],"mappings":";;;;;;AAeA;;cAAa,sBAAA;;cAGA,8BAAA;AAAb;;;AAAA,cAKa,yBAAA,GAA6B,QAA4B;AAL3B;AAAA,cAW9B,0BAAA;;cAGA,+BAAA;;cAGA,2BAAA;AAAA,cAEA,oBAAA,EAAoB,MAAA,CAAA,QAAA;AAAA,KAErB,oBAAA,UAA8B,oBAAA,CAAqB,IAAI;AAAA,cAAA,yBAAA;;;;;;;;;;;;AAJ3B;cAU3B,oBAAA,SAA6B,yBAUxC;AAAA,cAAG,yBAAA;;;;;;cAGQ,oBAAA,SAA6B,yBAMxC;AAAA,cAAG,oBAAA;;;;;;;;;cAMQ,eAAA,SAAwB,oBAInC;AAAA,KAEU,mBAAA;mFAED,EAAA;EAAA,SACA,IAAA;WAEA,IAAA;EAAA,SACA,MAAA,EAAQ,oBAAA;EAAA,SACR,UAAA;EAAA,SACA,KAAA;EAAA,SACA,KAAA,GAAQ,UAAU;AAAA;AAAA,KAGxB,YAAA;EAAA,SACM,EAAA;EAAA,SACA,KAAA;EAAA,SACA,SAAA;AAAA;;;;KAQC,sBAAA;EAAA,SACD,KAAA,EAAO,aAAA,CAAc,oBAAA;EAA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