@yolk-sdk/agent 0.1.0-canary.115 → 0.1.0-canary.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -5
- package/dist/client/state.d.mts +82 -82
- package/dist/client/state.d.mts.map +1 -1
- package/dist/protocol/content.d.mts +7 -1
- package/dist/protocol/content.d.mts.map +1 -1
- package/dist/protocol/content.mjs +13 -6
- package/dist/protocol/content.mjs.map +1 -1
- package/dist/protocol/event.d.mts +6 -0
- package/dist/protocol/event.d.mts.map +1 -1
- package/dist/protocol/event.mjs +6 -0
- package/dist/protocol/event.mjs.map +1 -1
- package/dist/protocol/index.d.mts +2 -2
- package/dist/protocol/index.d.mts.map +1 -1
- package/dist/protocol/index.mjs +2 -2
- package/dist/providers/anthropic/conformance/claude-usage-cases.d.mts.map +1 -1
- package/dist/providers/anthropic/conformance/claude-usage-cases.mjs +30 -5
- package/dist/providers/anthropic/conformance/claude-usage-cases.mjs.map +1 -1
- package/dist/providers/anthropic/conformance/claude-usage-snapshot.d.mts +2 -1
- package/dist/providers/anthropic/conformance/claude-usage-snapshot.d.mts.map +1 -1
- package/dist/providers/anthropic/conformance/claude-usage-snapshot.mjs +3 -2
- package/dist/providers/anthropic/conformance/claude-usage-snapshot.mjs.map +1 -1
- package/dist/providers/anthropic/usage.d.mts +3 -1
- package/dist/providers/anthropic/usage.d.mts.map +1 -1
- package/dist/providers/anthropic/usage.mjs +70 -16
- package/dist/providers/anthropic/usage.mjs.map +1 -1
- package/dist/providers/anthropic-provider-internal.d.mts.map +1 -1
- package/dist/providers/anthropic-provider-internal.mjs +8 -1
- package/dist/providers/anthropic-provider-internal.mjs.map +1 -1
- package/dist/providers/openai/conformance/codex-usage-cases.mjs +1 -1
- package/dist/providers/openai/conformance/subscription-usage-cases-internal.d.mts +7 -1
- package/dist/providers/openai/conformance/subscription-usage-cases-internal.d.mts.map +1 -1
- package/dist/providers/openai/conformance/subscription-usage-cases-internal.mjs +8 -5
- package/dist/providers/openai/conformance/subscription-usage-cases-internal.mjs.map +1 -1
- package/dist/providers/openai-responses-provider-internal.d.mts.map +1 -1
- package/dist/providers/openai-responses-provider-internal.mjs +15 -2
- package/dist/providers/openai-responses-provider-internal.mjs.map +1 -1
- package/dist/providers/opencode/usage.d.mts.map +1 -1
- package/dist/providers/opencode/usage.mjs +13 -4
- package/dist/providers/opencode/usage.mjs.map +1 -1
- package/dist/providers/provider-error.d.mts +3 -1
- package/dist/providers/provider-error.d.mts.map +1 -1
- package/dist/providers/provider-error.mjs +2 -0
- package/dist/providers/provider-error.mjs.map +1 -1
- package/dist/providers/quota-reset-internal.d.mts +29 -0
- package/dist/providers/quota-reset-internal.d.mts.map +1 -0
- package/dist/providers/quota-reset-internal.mjs +98 -0
- package/dist/providers/quota-reset-internal.mjs.map +1 -0
- package/dist/providers/subscription-usage.d.mts +5 -0
- package/dist/providers/subscription-usage.d.mts.map +1 -1
- package/dist/providers/subscription-usage.mjs +6 -1
- package/dist/providers/subscription-usage.mjs.map +1 -1
- package/dist/react/chat-actions.d.mts +20 -20
- package/dist/react/chat-actions.d.mts.map +1 -1
- package/dist/react/chat-items.d.mts +97 -97
- package/dist/react/chat-items.d.mts.map +1 -1
- package/dist/react/chat-messages.d.mts +133 -133
- package/dist/react/chat-messages.d.mts.map +1 -1
- package/dist/skillset/merge.d.mts +1 -1
- package/dist/tools/files.d.mts.map +1 -1
- package/dist/tools/files.mjs +2 -2
- package/dist/tools/files.mjs.map +1 -1
- package/package.json +3 -3
- package/src/protocol/content.ts +16 -6
- package/src/protocol/event.ts +6 -0
- package/src/protocol/index.ts +1 -0
- package/src/providers/anthropic/conformance/claude-usage-cases.ts +60 -5
- package/src/providers/anthropic/conformance/claude-usage-snapshot.ts +3 -2
- package/src/providers/anthropic/usage.ts +122 -27
- package/src/providers/anthropic-provider-internal.ts +13 -1
- package/src/providers/openai/conformance/subscription-usage-cases-internal.ts +32 -6
- package/src/providers/openai-responses-provider-internal.ts +23 -4
- package/src/providers/opencode/usage.ts +19 -5
- package/src/providers/provider-error.ts +12 -0
- package/src/providers/quota-reset-internal.ts +227 -0
- package/src/providers/subscription-usage.ts +6 -1
- package/src/tools/files.ts +2 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Root export is intentionally empty. Import feature APIs from explicit subpaths.
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
pnpm add @yolk-sdk/agent@canary effect@4.0.
|
|
10
|
+
pnpm add @yolk-sdk/agent@canary effect@4.0.5
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Add `react` if you use `@yolk-sdk/agent/react` or `@yolk-sdk/agent/voice/react`.
|
|
@@ -15,7 +15,7 @@ Add `react` if you use `@yolk-sdk/agent/react` or `@yolk-sdk/agent/voice/react`.
|
|
|
15
15
|
Running the experimental `@yolk-sdk/agent/providers/*/conformance` cases? Also add `@yolk-sdk/conformance@canary` (usually as a dev dependency); the cases run through `@yolk-sdk/conformance/runner`.
|
|
16
16
|
|
|
17
17
|
Canary APIs are unstable. Keep all `@yolk-sdk/*` packages on the same version.
|
|
18
|
-
Use the SDK's matching Effect version (`4.0.
|
|
18
|
+
Use the SDK's matching Effect version (`4.0.5`) in host code.
|
|
19
19
|
Published package metadata requires Node.js 22+.
|
|
20
20
|
|
|
21
21
|
## Subpaths
|
|
@@ -443,7 +443,9 @@ Provider adapters classify safe failure metadata at the boundary. The loop owns
|
|
|
443
443
|
policy and emits protocol-visible retry/error state:
|
|
444
444
|
|
|
445
445
|
- `ProviderErrorInfo` carries safe provider id, failure kind, HTTP status, provider code, optional
|
|
446
|
-
`retryAfterMs`,
|
|
446
|
+
`retryAfterMs`, optional `quotaResetsAtMs` (epoch milliseconds when a spent account-wide
|
|
447
|
+
subscription quota resets; on `rate_limit` only, when Claude or a Responses provider such as
|
|
448
|
+
ChatGPT Codex reports a trusted reset), and optional `stream` diagnostics (`ProviderStreamDiagnostics`) on chat
|
|
447
449
|
`unexpected_content_type` / `incomplete_stream` failures. Diagnostics contain counters and
|
|
448
450
|
milestones, never transcript content, raw headers, or body fragments. See the
|
|
449
451
|
[stream diagnostics guide](https://github.com/magoz/yolk-sdk/blob/main/apps/docs/content/docs/troubleshooting.mdx#diagnose-chat-stream-failures-with-stream-diagnostics).
|
|
@@ -471,7 +473,8 @@ typed retry/error state.
|
|
|
471
473
|
## Subscription allowance snapshots
|
|
472
474
|
|
|
473
475
|
The Claude, Codex, and Grok usage adapters read best-effort consumer subscription allowance
|
|
474
|
-
percentages and reset windows. Claude normalizes its aggregate five-hour and seven-day windows
|
|
476
|
+
percentages and reset windows. Claude normalizes its aggregate five-hour and seven-day windows plus model-scoped weekly limits
|
|
477
|
+
(`seven-day-<model>`);
|
|
475
478
|
Codex normalizes primary and secondary rate-limit windows; Grok normalizes its aggregate shared
|
|
476
479
|
credit allowance. Additional provider-specific buckets are ignored. These private provider
|
|
477
480
|
endpoints may change without notice. Pass a fresh host-owned `OAuthAccessToken` and provide an
|
|
@@ -497,7 +500,9 @@ adapter sends it with `x-grok-client-mode: headless` and never claims an officia
|
|
|
497
500
|
version.
|
|
498
501
|
|
|
499
502
|
Provider adapters return an immutable Effect `Chunk` of semantic window ids, percentages, and
|
|
500
|
-
optional reset/duration fields
|
|
503
|
+
optional reset/duration fields. A model-scoped window (Claude's `seven-day-<model>`) carries
|
|
504
|
+
`models`, the lowercase model id substrings it limits; absent means every model of the account.
|
|
505
|
+
Hosts own labels, polling, persistence, stale-data policy, alert
|
|
501
506
|
thresholds, billing interpretation, and UI. Configure `requestTimeoutMs` at the server integration
|
|
502
507
|
boundary. Each fetcher defaults to its exported URL constant; the optional `url` override is only
|
|
503
508
|
for a trusted proxy or local emulator, because the credential is sent to it. `FetchHttpClient.layer` is configured for manual
|
package/dist/client/state.d.mts
CHANGED
|
@@ -79,26 +79,6 @@ type AgentToolRun = {
|
|
|
79
79
|
readonly result: ToolResult;
|
|
80
80
|
};
|
|
81
81
|
declare const AgentToolRun: {
|
|
82
|
-
readonly InputStreaming: Data.TaggedEnum.ConstructorFrom<{
|
|
83
|
-
readonly _tag: "InputStreaming";
|
|
84
|
-
readonly id: string;
|
|
85
|
-
readonly name?: string;
|
|
86
|
-
readonly input: string;
|
|
87
|
-
}, "_tag">;
|
|
88
|
-
readonly InputReady: Data.TaggedEnum.ConstructorFrom<{
|
|
89
|
-
readonly _tag: "InputReady";
|
|
90
|
-
readonly call: ToolCall;
|
|
91
|
-
}, "_tag">;
|
|
92
|
-
readonly ApprovalRequested: Data.TaggedEnum.ConstructorFrom<{
|
|
93
|
-
readonly _tag: "ApprovalRequested";
|
|
94
|
-
readonly call: ToolCall;
|
|
95
|
-
readonly request?: ToolApprovalRequest;
|
|
96
|
-
}, "_tag">;
|
|
97
|
-
readonly Denied: Data.TaggedEnum.ConstructorFrom<{
|
|
98
|
-
readonly _tag: "Denied";
|
|
99
|
-
readonly toolCallId: string;
|
|
100
|
-
readonly reason: string;
|
|
101
|
-
}, "_tag">;
|
|
102
82
|
readonly QuestionRequested: Data.TaggedEnum.ConstructorFrom<{
|
|
103
83
|
readonly _tag: "QuestionRequested";
|
|
104
84
|
readonly request: QuestionRequest;
|
|
@@ -141,21 +121,31 @@ declare const AgentToolRun: {
|
|
|
141
121
|
readonly response: InteractionResponse;
|
|
142
122
|
readonly request?: InteractionRequest;
|
|
143
123
|
}, "_tag">;
|
|
144
|
-
readonly
|
|
145
|
-
readonly _tag: "
|
|
124
|
+
readonly Denied: Data.TaggedEnum.ConstructorFrom<{
|
|
125
|
+
readonly _tag: "Denied";
|
|
126
|
+
readonly toolCallId: string;
|
|
127
|
+
readonly reason: string;
|
|
128
|
+
}, "_tag">;
|
|
129
|
+
readonly InputStreaming: Data.TaggedEnum.ConstructorFrom<{
|
|
130
|
+
readonly _tag: "InputStreaming";
|
|
131
|
+
readonly id: string;
|
|
132
|
+
readonly name?: string;
|
|
133
|
+
readonly input: string;
|
|
134
|
+
}, "_tag">;
|
|
135
|
+
readonly ApprovalRequested: Data.TaggedEnum.ConstructorFrom<{
|
|
136
|
+
readonly _tag: "ApprovalRequested";
|
|
146
137
|
readonly call: ToolCall;
|
|
147
|
-
readonly
|
|
148
|
-
readonly interaction?: true;
|
|
138
|
+
readonly request?: ToolApprovalRequest;
|
|
149
139
|
}, "_tag">;
|
|
150
|
-
readonly
|
|
151
|
-
readonly _tag: "
|
|
140
|
+
readonly Accepted: Data.TaggedEnum.ConstructorFrom<{
|
|
141
|
+
readonly _tag: "Accepted";
|
|
152
142
|
readonly call: ToolCall;
|
|
153
143
|
readonly result: ToolResult;
|
|
154
144
|
readonly startedAtMs: number;
|
|
155
145
|
readonly endedAtMs: number;
|
|
156
146
|
}, "_tag">;
|
|
157
|
-
readonly
|
|
158
|
-
readonly _tag: "
|
|
147
|
+
readonly Completed: Data.TaggedEnum.ConstructorFrom<{
|
|
148
|
+
readonly _tag: "Completed";
|
|
159
149
|
readonly call: ToolCall;
|
|
160
150
|
readonly result: ToolResult;
|
|
161
151
|
readonly startedAtMs: number;
|
|
@@ -172,7 +162,17 @@ declare const AgentToolRun: {
|
|
|
172
162
|
readonly call: ToolCall;
|
|
173
163
|
readonly result: ToolResult;
|
|
174
164
|
}, "_tag">;
|
|
175
|
-
readonly
|
|
165
|
+
readonly InputReady: Data.TaggedEnum.ConstructorFrom<{
|
|
166
|
+
readonly _tag: "InputReady";
|
|
167
|
+
readonly call: ToolCall;
|
|
168
|
+
}, "_tag">;
|
|
169
|
+
readonly Executing: Data.TaggedEnum.ConstructorFrom<{
|
|
170
|
+
readonly _tag: "Executing";
|
|
171
|
+
readonly call: ToolCall;
|
|
172
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
173
|
+
readonly interaction?: true;
|
|
174
|
+
}, "_tag">;
|
|
175
|
+
readonly $is: <Tag extends "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Denied" | "InputStreaming" | "ApprovalRequested" | "Accepted" | "Completed" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
176
176
|
readonly _tag: "InputStreaming";
|
|
177
177
|
readonly id: string;
|
|
178
178
|
readonly name?: string;
|
|
@@ -286,26 +286,6 @@ declare const AgentToolRun: {
|
|
|
286
286
|
}>;
|
|
287
287
|
readonly $match: {
|
|
288
288
|
<Cases extends {
|
|
289
|
-
readonly InputStreaming: (args: {
|
|
290
|
-
readonly _tag: "InputStreaming";
|
|
291
|
-
readonly id: string;
|
|
292
|
-
readonly name?: string;
|
|
293
|
-
readonly input: string;
|
|
294
|
-
}) => any;
|
|
295
|
-
readonly InputReady: (args: {
|
|
296
|
-
readonly _tag: "InputReady";
|
|
297
|
-
readonly call: ToolCall;
|
|
298
|
-
}) => any;
|
|
299
|
-
readonly ApprovalRequested: (args: {
|
|
300
|
-
readonly _tag: "ApprovalRequested";
|
|
301
|
-
readonly call: ToolCall;
|
|
302
|
-
readonly request?: ToolApprovalRequest;
|
|
303
|
-
}) => any;
|
|
304
|
-
readonly Denied: (args: {
|
|
305
|
-
readonly _tag: "Denied";
|
|
306
|
-
readonly toolCallId: string;
|
|
307
|
-
readonly reason: string;
|
|
308
|
-
}) => any;
|
|
309
289
|
readonly QuestionRequested: (args: {
|
|
310
290
|
readonly _tag: "QuestionRequested";
|
|
311
291
|
readonly request: QuestionRequest;
|
|
@@ -348,21 +328,31 @@ declare const AgentToolRun: {
|
|
|
348
328
|
readonly response: InteractionResponse;
|
|
349
329
|
readonly request?: InteractionRequest;
|
|
350
330
|
}) => any;
|
|
351
|
-
readonly
|
|
352
|
-
readonly _tag: "
|
|
331
|
+
readonly Denied: (args: {
|
|
332
|
+
readonly _tag: "Denied";
|
|
333
|
+
readonly toolCallId: string;
|
|
334
|
+
readonly reason: string;
|
|
335
|
+
}) => any;
|
|
336
|
+
readonly InputStreaming: (args: {
|
|
337
|
+
readonly _tag: "InputStreaming";
|
|
338
|
+
readonly id: string;
|
|
339
|
+
readonly name?: string;
|
|
340
|
+
readonly input: string;
|
|
341
|
+
}) => any;
|
|
342
|
+
readonly ApprovalRequested: (args: {
|
|
343
|
+
readonly _tag: "ApprovalRequested";
|
|
353
344
|
readonly call: ToolCall;
|
|
354
|
-
readonly
|
|
355
|
-
readonly interaction?: true;
|
|
345
|
+
readonly request?: ToolApprovalRequest;
|
|
356
346
|
}) => any;
|
|
357
|
-
readonly
|
|
358
|
-
readonly _tag: "
|
|
347
|
+
readonly Accepted: (args: {
|
|
348
|
+
readonly _tag: "Accepted";
|
|
359
349
|
readonly call: ToolCall;
|
|
360
350
|
readonly result: ToolResult;
|
|
361
351
|
readonly startedAtMs: number;
|
|
362
352
|
readonly endedAtMs: number;
|
|
363
353
|
}) => any;
|
|
364
|
-
readonly
|
|
365
|
-
readonly _tag: "
|
|
354
|
+
readonly Completed: (args: {
|
|
355
|
+
readonly _tag: "Completed";
|
|
366
356
|
readonly call: ToolCall;
|
|
367
357
|
readonly result: ToolResult;
|
|
368
358
|
readonly startedAtMs: number;
|
|
@@ -379,28 +369,18 @@ declare const AgentToolRun: {
|
|
|
379
369
|
readonly call: ToolCall;
|
|
380
370
|
readonly result: ToolResult;
|
|
381
371
|
}) => any;
|
|
382
|
-
}>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
|
|
383
|
-
<Cases extends {
|
|
384
|
-
readonly InputStreaming: (args: {
|
|
385
|
-
readonly _tag: "InputStreaming";
|
|
386
|
-
readonly id: string;
|
|
387
|
-
readonly name?: string;
|
|
388
|
-
readonly input: string;
|
|
389
|
-
}) => any;
|
|
390
372
|
readonly InputReady: (args: {
|
|
391
373
|
readonly _tag: "InputReady";
|
|
392
374
|
readonly call: ToolCall;
|
|
393
375
|
}) => any;
|
|
394
|
-
readonly
|
|
395
|
-
readonly _tag: "
|
|
376
|
+
readonly Executing: (args: {
|
|
377
|
+
readonly _tag: "Executing";
|
|
396
378
|
readonly call: ToolCall;
|
|
397
|
-
readonly
|
|
398
|
-
|
|
399
|
-
readonly Denied: (args: {
|
|
400
|
-
readonly _tag: "Denied";
|
|
401
|
-
readonly toolCallId: string;
|
|
402
|
-
readonly reason: string;
|
|
379
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
380
|
+
readonly interaction?: true;
|
|
403
381
|
}) => any;
|
|
382
|
+
}>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Denied" | "InputStreaming" | "ApprovalRequested" | "Accepted" | "Completed" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing"]>>;
|
|
383
|
+
<Cases extends {
|
|
404
384
|
readonly QuestionRequested: (args: {
|
|
405
385
|
readonly _tag: "QuestionRequested";
|
|
406
386
|
readonly request: QuestionRequest;
|
|
@@ -443,21 +423,31 @@ declare const AgentToolRun: {
|
|
|
443
423
|
readonly response: InteractionResponse;
|
|
444
424
|
readonly request?: InteractionRequest;
|
|
445
425
|
}) => any;
|
|
446
|
-
readonly
|
|
447
|
-
readonly _tag: "
|
|
426
|
+
readonly Denied: (args: {
|
|
427
|
+
readonly _tag: "Denied";
|
|
428
|
+
readonly toolCallId: string;
|
|
429
|
+
readonly reason: string;
|
|
430
|
+
}) => any;
|
|
431
|
+
readonly InputStreaming: (args: {
|
|
432
|
+
readonly _tag: "InputStreaming";
|
|
433
|
+
readonly id: string;
|
|
434
|
+
readonly name?: string;
|
|
435
|
+
readonly input: string;
|
|
436
|
+
}) => any;
|
|
437
|
+
readonly ApprovalRequested: (args: {
|
|
438
|
+
readonly _tag: "ApprovalRequested";
|
|
448
439
|
readonly call: ToolCall;
|
|
449
|
-
readonly
|
|
450
|
-
readonly interaction?: true;
|
|
440
|
+
readonly request?: ToolApprovalRequest;
|
|
451
441
|
}) => any;
|
|
452
|
-
readonly
|
|
453
|
-
readonly _tag: "
|
|
442
|
+
readonly Accepted: (args: {
|
|
443
|
+
readonly _tag: "Accepted";
|
|
454
444
|
readonly call: ToolCall;
|
|
455
445
|
readonly result: ToolResult;
|
|
456
446
|
readonly startedAtMs: number;
|
|
457
447
|
readonly endedAtMs: number;
|
|
458
448
|
}) => any;
|
|
459
|
-
readonly
|
|
460
|
-
readonly _tag: "
|
|
449
|
+
readonly Completed: (args: {
|
|
450
|
+
readonly _tag: "Completed";
|
|
461
451
|
readonly call: ToolCall;
|
|
462
452
|
readonly result: ToolResult;
|
|
463
453
|
readonly startedAtMs: number;
|
|
@@ -474,7 +464,17 @@ declare const AgentToolRun: {
|
|
|
474
464
|
readonly call: ToolCall;
|
|
475
465
|
readonly result: ToolResult;
|
|
476
466
|
}) => any;
|
|
477
|
-
|
|
467
|
+
readonly InputReady: (args: {
|
|
468
|
+
readonly _tag: "InputReady";
|
|
469
|
+
readonly call: ToolCall;
|
|
470
|
+
}) => any;
|
|
471
|
+
readonly Executing: (args: {
|
|
472
|
+
readonly _tag: "Executing";
|
|
473
|
+
readonly call: ToolCall;
|
|
474
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
475
|
+
readonly interaction?: true;
|
|
476
|
+
}) => any;
|
|
477
|
+
}>(value: AgentToolRun, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Denied" | "InputStreaming" | "ApprovalRequested" | "Accepted" | "Completed" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing"]>>;
|
|
478
478
|
};
|
|
479
479
|
};
|
|
480
480
|
type AgentClientState = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.mts","names":[],"sources":["../../src/client/state.ts"],"mappings":";;;;KA0BY,YAAA;EAAA,SAEG,IAAA;EAAA,SACA,EAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA;AAAA;EAAA,SAEA,IAAA;EAAA,SAA6B,IAAA,EAAM,QAAA;AAAA;EAAA,SAEnC,IAAA;EAAA,SACA,IAAA,EAAM,QAAA;EAAA,SACN,OAAA,GAAU,mBAAA;AAAA;EAAA,SAEV,IAAA;EAAA,SAAyB,UAAA;EAAA,SAA6B,MAAA;AAAA;EAAA,SACtD,IAAA;EAAA,SAAoC,OAAA,EAAS,eAAA;AAAA;EAAA,SAE7C,IAAA;EAAA,SACA,QAAA,EAAU,gBAAA;EAAA,SACV,OAAA,GAAU,eAAA;AAAA;EAAA,SAGV,IAAA;EAAA,SACA,QAAA,EAAU,gBAAA;EAAA,SACV,OAAA,GAAU,eAAA;AAAA;EAAA,SAEV,IAAA;EAAA,SAAiC,OAAA,EAAS,YAAA;AAAA;EAAA,SAE1C,IAAA;EAAA,SACA,QAAA,EAAU,aAAA;EAAA,SACV,OAAA,GAAU,YAAA;AAAA;EAAA,SAGV,IAAA;EAAA,SACA,QAAA,EAAU,aAAA;EAAA,SACV,OAAA,GAAU,YAAA;AAAA;EAAA,SAEV,IAAA;EAAA,SAAuC,OAAA,EAAS,kBAAA;AAAA;EAAA,SAEhD,IAAA;EAAA,SACA,QAAA,EAAU,mBAAA;EAAA,SACV,OAAA,GAAU,kBAAA;AAAA;EAAA,SAGV,IAAA;EAAA,SACA,QAAA,EAAU,mBAAA;EAAA,SACV,OAAA,GAAU,kBAAA;AAAA;EAAA,SAGV,IAAA;EAAA,SACA,IAAA,EAAM,QAAA;EAAA,SACN,WA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: string) => RefAttachmentSource;
|
|
|
93
93
|
declare const inlineBase64Source: (data: string) => InlineBase64AttachmentSource;
|
|
94
94
|
/** Standard base64 of `bytes`, chunked so large files do not exceed argument limits. */
|
|
95
95
|
declare const bytesToBase64: (bytes: Uint8Array) => string;
|
|
96
|
+
/**
|
|
97
|
+
* Bytes of standard base64 (throws on invalid input, like `atob`). Copies into one preallocated
|
|
98
|
+
* array: `Uint8Array.from(binary, mapFn)` first collects every character into a list, which
|
|
99
|
+
* costs tens of bytes per decoded byte (~0.7 GB for 20 MiB).
|
|
100
|
+
*/
|
|
101
|
+
declare const base64ToBytes: (data: string) => Uint8Array<ArrayBuffer>;
|
|
96
102
|
/** A `FilePart` carrying `bytes` inline, for tools that yield files (ADR 0009). */
|
|
97
103
|
declare const filePartFromBytes: (input: {
|
|
98
104
|
readonly bytes: Uint8Array;
|
|
@@ -118,5 +124,5 @@ declare const documentPartFromText: (input: {
|
|
|
118
124
|
declare const attachmentSourceText: (source: AttachmentSource) => Effect.Effect<Option.Option<string>, unknown, never>;
|
|
119
125
|
declare const attachmentSourceBase64: (source: AttachmentSource) => Option.Option<string>;
|
|
120
126
|
//#endregion
|
|
121
|
-
export { AttachmentContentPart, AttachmentSource, AttachmentSourceResolver, AudioPart, Content, ContentPart, DocumentPart, FilePart, ImagePart, InlineBase64AttachmentSource, RefAttachmentSource, TextPart, UrlAttachmentSource, appendTextToContent, attachmentSourceBase64, attachmentSourceDataUrl, attachmentSourcePreview, attachmentSourceText, attachmentSourceUrl, bytesToBase64, contentPartPreview, contentPartText, contentParts, contentPreview, contentText, documentPartFromText, filePartFromBytes, filePartText, inferTextDocumentMimeType, inlineBase64AttachmentSource, inlineBase64Source, isContentEmpty, isTextDocumentMimeType, refAttachmentSource, replaceLoneSurrogates, replaceLoneSurrogatesDeep, resolveContentAttachmentSources, textDocumentMimeTypeFromFilename, textToBase64Utf8, urlAttachmentSource };
|
|
127
|
+
export { AttachmentContentPart, AttachmentSource, AttachmentSourceResolver, AudioPart, Content, ContentPart, DocumentPart, FilePart, ImagePart, InlineBase64AttachmentSource, RefAttachmentSource, TextPart, UrlAttachmentSource, appendTextToContent, attachmentSourceBase64, attachmentSourceDataUrl, attachmentSourcePreview, attachmentSourceText, attachmentSourceUrl, base64ToBytes, bytesToBase64, contentPartPreview, contentPartText, contentParts, contentPreview, contentText, documentPartFromText, filePartFromBytes, filePartText, inferTextDocumentMimeType, inlineBase64AttachmentSource, inlineBase64Source, isContentEmpty, isTextDocumentMimeType, refAttachmentSource, replaceLoneSurrogates, replaceLoneSurrogatesDeep, resolveContentAttachmentSources, textDocumentMimeTypeFromFilename, textToBase64Utf8, urlAttachmentSource };
|
|
122
128
|
//# sourceMappingURL=content.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.mts","names":[],"sources":["../../src/protocol/content.ts"],"mappings":";;;;cACuC,aAAA;;;cAG1B,QAAA,SAAiB,aAE5B;AAAA,cAAG,iCAAA;;;cAEQ,4BAAA,SAAqC,iCAKjD;AAAA,cAAG,wBAAA;;;cAES,mBAAA,SAA4B,wBAEvC;AAAA,cAAG,wBAAA;;;cAEQ,mBAAA,SAA4B,wBAEvC;AAAA,cAEW,gBAAA,EAAgB,QAAA,CAAA,KAAA,kBAAA,4BAAA,SAAA,mBAAA,SAAA,mBAAA;AAAA,KAMjB,gBAAA,UAA0B,gBAAA,CAAiB,IAAI;AAAA,cAAA,cAAA;;;;;;;;cAE9C,SAAA,SAAkB,cAO7B;AAAA,cAAG,iBAAA;;;;;;cAEQ,YAAA,SAAqB,iBAKhC;AAAA,cAAG,cAAA;;;;;;cAEQ,SAAA,SAAkB,cAK7B;AAAA,cAAG,aAAA;;;;;;;;;;;cAOQ,QAAA,SAAiB,aAK5B;AAAA,cAEW,WAAA,EAAW,QAAA,CAAA,KAAA,kBAAA,QAAA,SAAA,SAAA,SAAA,YAAA,SAAA,SAAA,SAAA,QAAA;AAAA,KAEZ,WAAA,UAAqB,WAAA,CAAY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A,CAAA,MAAA;AAAA,cAsCjE,sBAAA,GAA0B,QAAgB;AAAA,cAyB1C,gCAAA,GAAoC,QAAgB;AAAA,cAUpD,yBAAA,GAA6B,KAAA;EAAA,SAC/B,QAAA;EAAA,SACA,QAAA;AAAA;AAAA,cAWE,gBAAA,GAAoB,IAAY;AAAA,cAWhC,oBAAA,GAAwB,KAAA;EAAA,SAC1B,IAAA;EAAA,SACA,QAAA;EAAA,SACA,QAAA;EAAA,SACA,KAAA;AAAA,MACV,YAAA;AAAA,cAyBY,oBAAA,GAAwB,MAAA,EAAQ,gBAAA,KAAgB,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA;AAAA,cAYhD,sBAAA,GAA0B,MAAA,EAAQ,gBAAA,KAAgB,MAAA,CAAA,MAAA"}
|
|
@@ -134,6 +134,17 @@ const bytesToBase64 = (bytes) => {
|
|
|
134
134
|
for (let offset = 0; offset < bytes.length; offset += base64ChunkBytes) binary += String.fromCharCode(...bytes.subarray(offset, offset + base64ChunkBytes));
|
|
135
135
|
return globalThis.btoa(binary);
|
|
136
136
|
};
|
|
137
|
+
/**
|
|
138
|
+
* Bytes of standard base64 (throws on invalid input, like `atob`). Copies into one preallocated
|
|
139
|
+
* array: `Uint8Array.from(binary, mapFn)` first collects every character into a list, which
|
|
140
|
+
* costs tens of bytes per decoded byte (~0.7 GB for 20 MiB).
|
|
141
|
+
*/
|
|
142
|
+
const base64ToBytes = (data) => {
|
|
143
|
+
const binary = globalThis.atob(data);
|
|
144
|
+
const bytes = new Uint8Array(binary.length);
|
|
145
|
+
for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);
|
|
146
|
+
return bytes;
|
|
147
|
+
};
|
|
137
148
|
/** A `FilePart` carrying `bytes` inline, for tools that yield files (ADR 0009). */
|
|
138
149
|
const filePartFromBytes = (input) => input.filename === void 0 ? FilePart.make({
|
|
139
150
|
source: inlineBase64AttachmentSource(bytesToBase64(input.bytes)),
|
|
@@ -208,17 +219,13 @@ const documentPartFromText = (input) => {
|
|
|
208
219
|
title: input.title
|
|
209
220
|
});
|
|
210
221
|
};
|
|
211
|
-
const decodeBase64Utf8 = (data) => {
|
|
212
|
-
const binary = globalThis.atob(data);
|
|
213
|
-
const bytes = Uint8Array.from(binary, (character) => character.charCodeAt(0));
|
|
214
|
-
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
215
|
-
};
|
|
222
|
+
const decodeBase64Utf8 = (data) => new TextDecoder("utf-8", { fatal: true }).decode(base64ToBytes(data));
|
|
216
223
|
const attachmentSourceText = (source) => Match.value(source).pipe(Match.tag("InlineBase64", (current) => Effect.try({
|
|
217
224
|
try: () => Option.some(decodeBase64Utf8(current.data)),
|
|
218
225
|
catch: (error) => error
|
|
219
226
|
})), Match.tag("Url", "Ref", () => Effect.succeed(Option.none())), Match.exhaustive);
|
|
220
227
|
const attachmentSourceBase64 = (source) => Match.value(source).pipe(Match.tag("InlineBase64", (current) => Option.some(current.data)), Match.tag("Url", "Ref", () => Option.none()), Match.exhaustive);
|
|
221
228
|
//#endregion
|
|
222
|
-
export { AttachmentSource, AudioPart, Content, ContentPart, DocumentPart, FilePart, ImagePart, InlineBase64AttachmentSource, RefAttachmentSource, TextPart, UrlAttachmentSource, appendTextToContent, attachmentSourceBase64, attachmentSourceDataUrl, attachmentSourcePreview, attachmentSourceText, attachmentSourceUrl, bytesToBase64, contentPartPreview, contentPartText, contentParts, contentPreview, contentText, documentPartFromText, filePartFromBytes, filePartText, inferTextDocumentMimeType, inlineBase64AttachmentSource, inlineBase64Source, isContentEmpty, isTextDocumentMimeType, refAttachmentSource, replaceLoneSurrogates, replaceLoneSurrogatesDeep, resolveContentAttachmentSources, textDocumentMimeTypeFromFilename, textToBase64Utf8, urlAttachmentSource };
|
|
229
|
+
export { AttachmentSource, AudioPart, Content, ContentPart, DocumentPart, FilePart, ImagePart, InlineBase64AttachmentSource, RefAttachmentSource, TextPart, UrlAttachmentSource, appendTextToContent, attachmentSourceBase64, attachmentSourceDataUrl, attachmentSourcePreview, attachmentSourceText, attachmentSourceUrl, base64ToBytes, bytesToBase64, contentPartPreview, contentPartText, contentParts, contentPreview, contentText, documentPartFromText, filePartFromBytes, filePartText, inferTextDocumentMimeType, inlineBase64AttachmentSource, inlineBase64Source, isContentEmpty, isTextDocumentMimeType, refAttachmentSource, replaceLoneSurrogates, replaceLoneSurrogatesDeep, resolveContentAttachmentSources, textDocumentMimeTypeFromFilename, textToBase64Utf8, urlAttachmentSource };
|
|
223
230
|
|
|
224
231
|
//# sourceMappingURL=content.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.mjs","names":["Schema","Arr"],"sources":["../../src/protocol/content.ts"],"sourcesContent":["import { Array as Arr, Effect, Match, Option, Predicate } from 'effect'\nimport * as Schema from 'effect/Schema'\nimport { fileLabel, fileNotCapturedLabel, isFileId } from './file.ts'\n\nexport class TextPart extends Schema.TaggedClass<TextPart>()('Text', {\n text: Schema.String\n}) {}\n\nexport class InlineBase64AttachmentSource extends Schema.TaggedClass<InlineBase64AttachmentSource>()(\n 'InlineBase64',\n {\n data: Schema.String\n }\n) {}\n\nexport class UrlAttachmentSource extends Schema.TaggedClass<UrlAttachmentSource>()('Url', {\n url: Schema.String\n}) {}\n\nexport class RefAttachmentSource extends Schema.TaggedClass<RefAttachmentSource>()('Ref', {\n id: Schema.String\n}) {}\n\nexport const AttachmentSource = Schema.Union([\n InlineBase64AttachmentSource,\n UrlAttachmentSource,\n RefAttachmentSource\n])\n\nexport type AttachmentSource = typeof AttachmentSource.Type\n\nexport class ImagePart extends Schema.TaggedClass<ImagePart>()('Image', {\n source: AttachmentSource,\n mimeType: Schema.String,\n filename: Schema.optional(Schema.String),\n title: Schema.optional(Schema.String),\n width: Schema.optional(Schema.Number),\n height: Schema.optional(Schema.Number)\n}) {}\n\nexport class DocumentPart extends Schema.TaggedClass<DocumentPart>()('Document', {\n source: AttachmentSource,\n mimeType: Schema.String,\n filename: Schema.String,\n title: Schema.optional(Schema.String)\n}) {}\n\nexport class AudioPart extends Schema.TaggedClass<AudioPart>()('Audio', {\n source: AttachmentSource,\n mimeType: Schema.String,\n filename: Schema.optional(Schema.String),\n durationMs: Schema.optional(Schema.Number)\n}) {}\n\n/**\n * Bytes the agent can move between tools, not content for the model to view (ADR 0009). Producers\n * emit an `InlineBase64` source; tool resolution captures it into the host file store and rewrites\n * it to `Ref { id: fileId }`. Providers lower it to its text label only, never as an attachment.\n */\nexport class FilePart extends Schema.TaggedClass<FilePart>()('File', {\n source: AttachmentSource,\n mimeType: Schema.String,\n filename: Schema.optional(Schema.String),\n size: Schema.optional(Schema.Number)\n}) {}\n\nexport const ContentPart = Schema.Union([TextPart, ImagePart, DocumentPart, AudioPart, FilePart])\n\nexport type ContentPart = typeof ContentPart.Type\n\nexport const Content = Schema.Union([Schema.String, Schema.Array(ContentPart)])\n\nexport type Content = typeof Content.Type\n\nexport type AttachmentContentPart = ImagePart | DocumentPart | AudioPart\n\nexport type AttachmentSourceResolver<E = never, R = never> = (\n part: AttachmentContentPart\n) => Effect.Effect<AttachmentSource, E, R>\n\nconst resolveContentPartAttachmentSource = <E, R>(\n part: ContentPart,\n resolver: AttachmentSourceResolver<E, R>\n): Effect.Effect<ContentPart, E, R> =>\n Match.value(part).pipe(\n Match.tag('Text', current => Effect.succeed(current)),\n Match.tag('Image', current =>\n resolver(current).pipe(\n Effect.map(source =>\n ImagePart.make({\n source,\n mimeType: current.mimeType,\n filename: current.filename,\n title: current.title,\n width: current.width,\n height: current.height\n })\n )\n )\n ),\n Match.tag('Document', current =>\n resolver(current).pipe(\n Effect.map(source =>\n DocumentPart.make({\n source,\n mimeType: current.mimeType,\n filename: current.filename,\n title: current.title\n })\n )\n )\n ),\n Match.tag('Audio', current =>\n resolver(current).pipe(\n Effect.map(source =>\n AudioPart.make({\n source,\n mimeType: current.mimeType,\n filename: current.filename,\n durationMs: current.durationMs\n })\n )\n )\n ),\n // Files are never provider attachments: they lower to their label, so nothing to resolve.\n Match.tag('File', current => Effect.succeed(current)),\n Match.exhaustive\n )\n\nexport const resolveContentAttachmentSources = <E, R>(\n content: Content,\n resolver: AttachmentSourceResolver<E, R>\n): Effect.Effect<Content, E, R> =>\n Predicate.isString(content)\n ? Effect.succeed(content)\n : Effect.forEach(content, part => resolveContentPartAttachmentSource(part, resolver))\n\n/**\n * The model-visible text of a file part: its label when captured (`Ref` to a file id), otherwise a\n * \"not captured\" line. Inline bytes are never rendered.\n */\nexport const filePartText = (part: FilePart) => {\n const name = part.filename ?? 'file'\n\n if (Predicate.isTagged(part.source, 'Ref') && isFileId(part.source.id)) {\n return part.size === undefined\n ? fileLabel({ fileId: part.source.id, name, mimeType: part.mimeType })\n : fileLabel({ fileId: part.source.id, name, mimeType: part.mimeType, size: part.size })\n }\n\n return fileNotCapturedLabel({ name, mimeType: part.mimeType, reason: 'no file store' })\n}\n\nexport const contentPartText = (part: ContentPart) =>\n Match.value(part).pipe(\n Match.tag('Text', current => current.text),\n Match.tag('Image', 'Document', 'Audio', () => ''),\n Match.tag('File', filePartText),\n Match.exhaustive\n )\n\nexport const contentPartPreview = (part: ContentPart) =>\n Match.value(part).pipe(\n Match.tag('Text', current => current.text),\n Match.tag('Image', () => 'Image'),\n Match.tag('Document', current => `Document: ${current.title ?? current.filename}`),\n Match.tag('Audio', () => 'Audio'),\n Match.tag('File', current => `File: ${current.filename ?? current.mimeType}`),\n Match.exhaustive\n )\n\nconst loneSurrogates = /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/g\n\n/**\n * Replace lone UTF-16 surrogates with U+FFFD. Models emit them in transcripts\n * and tool arguments; they are valid JS strings but unencodable as UTF-8, so\n * provider APIs and storage backends can reject payloads containing them.\n */\nexport const replaceLoneSurrogates = (text: string) => text.replace(loneSurrogates, '\\uFFFD')\n\n/**\n * Deep-apply `replaceLoneSurrogates` to every string (keys included) in a\n * JSON-shaped value. Providers harden lowered request bodies with this before\n * serialization so junk in replayed transcripts cannot poison model calls;\n * hosts may also use it when persisting model-produced JSON.\n */\nexport const replaceLoneSurrogatesDeep = (value: unknown): unknown => {\n if (Predicate.isString(value)) return replaceLoneSurrogates(value)\n\n if (Array.isArray(value)) return value.map(replaceLoneSurrogatesDeep)\n\n if (Predicate.isObjectOrArray(value)) {\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => [\n replaceLoneSurrogates(key),\n replaceLoneSurrogatesDeep(entry)\n ])\n )\n }\n\n return value\n}\n\nexport const contentText = (content: Content) =>\n Predicate.isString(content) ? content : Arr.map(content, contentPartText).join('')\n\nexport const contentPreview = (content: Content) =>\n Predicate.isString(content) ? content : Arr.map(content, contentPartPreview).join(', ')\n\nexport const contentParts = (content: Content): ReadonlyArray<ContentPart> =>\n Predicate.isString(content) ? [TextPart.make({ text: content })] : content\n\nexport const isContentEmpty = (content: Content) =>\n Predicate.isString(content)\n ? content.length === 0\n : content.length === 0 ||\n Arr.every(content, part => Predicate.isTagged(part, 'Text') && part.text.length === 0)\n\nexport const appendTextToContent = (content: Content, text: string): Content => {\n if (Predicate.isString(content)) {\n return `${content}${text}`\n }\n\n return Option.match(Arr.last(content), {\n onNone: () => [TextPart.make({ text })],\n onSome: last =>\n !Predicate.isTagged(last, 'Text')\n ? [...content, TextPart.make({ text })]\n : Arr.map(content, (part, index) =>\n index === content.length - 1 && Predicate.isTagged(part, 'Text')\n ? TextPart.make({ text: `${part.text}${text}` })\n : part\n )\n })\n}\n\nexport const inlineBase64AttachmentSource = (data: string) =>\n InlineBase64AttachmentSource.make({ data })\n\nexport const urlAttachmentSource = (url: string) => UrlAttachmentSource.make({ url })\n\nexport const refAttachmentSource = (id: string) => RefAttachmentSource.make({ id })\n\nexport const inlineBase64Source = inlineBase64AttachmentSource\n\nconst base64ChunkBytes = 0x8000\n\n/** Standard base64 of `bytes`, chunked so large files do not exceed argument limits. */\nexport const bytesToBase64 = (bytes: Uint8Array) => {\n let binary = ''\n\n for (let offset = 0; offset < bytes.length; offset += base64ChunkBytes) {\n binary += String.fromCharCode(...bytes.subarray(offset, offset + base64ChunkBytes))\n }\n\n return globalThis.btoa(binary)\n}\n\n/** A `FilePart` carrying `bytes` inline, for tools that yield files (ADR 0009). */\nexport const filePartFromBytes = (input: {\n readonly bytes: Uint8Array\n readonly mimeType: string\n readonly filename?: string\n}) =>\n input.filename === undefined\n ? FilePart.make({\n source: inlineBase64AttachmentSource(bytesToBase64(input.bytes)),\n mimeType: input.mimeType,\n size: input.bytes.byteLength\n })\n : FilePart.make({\n source: inlineBase64AttachmentSource(bytesToBase64(input.bytes)),\n mimeType: input.mimeType,\n filename: input.filename,\n size: input.bytes.byteLength\n })\n\nexport const attachmentSourcePreview = (source: AttachmentSource) =>\n Match.value(source).pipe(\n Match.tag('InlineBase64', () => 'inline'),\n Match.tag('Url', current => current.url),\n Match.tag('Ref', current => current.id),\n Match.exhaustive\n )\n\nexport const attachmentSourceDataUrl = (source: AttachmentSource, mimeType: string) =>\n Match.value(source).pipe(\n Match.tag('InlineBase64', current => Option.some(`data:${mimeType};base64,${current.data}`)),\n Match.tag('Url', 'Ref', () => Option.none<string>()),\n Match.exhaustive\n )\n\nexport const attachmentSourceUrl = (source: AttachmentSource, mimeType: string) =>\n Match.value(source).pipe(\n Match.tag('InlineBase64', current => Option.some(`data:${mimeType};base64,${current.data}`)),\n Match.tag('Url', current => Option.some(current.url)),\n Match.tag('Ref', () => Option.none<string>()),\n Match.exhaustive\n )\n\nconst normalizeMimeType = (mimeType: string) =>\n mimeType.split(';', 1)[0]?.trim().toLowerCase() ?? ''\n\nconst textDocumentMimeTypeByExtension = {\n '.csv': 'text/csv',\n '.css': 'text/css',\n '.gql': 'application/graphql',\n '.graphql': 'application/graphql',\n '.html': 'text/html',\n '.js': 'application/javascript',\n '.jsx': 'application/javascript',\n '.json': 'application/json',\n '.jsonl': 'application/x-ndjson',\n '.md': 'text/markdown',\n '.markdown': 'text/markdown',\n '.sql': 'application/sql',\n '.toml': 'application/toml',\n '.ts': 'application/typescript',\n '.tsx': 'application/typescript',\n '.txt': 'text/plain',\n '.xml': 'application/xml',\n '.yaml': 'application/yaml',\n '.yml': 'application/yaml'\n}\n\nconst isUnknownDocumentMimeType = (mimeType: string) =>\n mimeType.length === 0 ||\n mimeType === 'application/octet-stream' ||\n mimeType === 'binary/octet-stream'\n\nexport const isTextDocumentMimeType = (mimeType: string) => {\n const normalized = normalizeMimeType(mimeType)\n\n return (\n normalized.startsWith('text/') ||\n normalized === 'application/json' ||\n normalized === 'application/ld+json' ||\n normalized === 'application/jsonl' ||\n normalized === 'application/x-ndjson' ||\n normalized === 'application/javascript' ||\n normalized === 'application/x-javascript' ||\n normalized === 'application/typescript' ||\n normalized === 'application/x-typescript' ||\n normalized === 'application/xml' ||\n normalized === 'application/yaml' ||\n normalized === 'application/x-yaml' ||\n normalized === 'application/toml' ||\n normalized === 'application/markdown' ||\n normalized === 'application/sql' ||\n normalized === 'application/graphql' ||\n normalized.endsWith('+json') ||\n normalized.endsWith('+xml')\n )\n}\n\nexport const textDocumentMimeTypeFromFilename = (filename: string) => {\n const normalized = filename.trim().toLowerCase()\n\n const entry = Object.entries(textDocumentMimeTypeByExtension).find(([extension]) =>\n normalized.endsWith(extension)\n )\n\n return entry?.[1]\n}\n\nexport const inferTextDocumentMimeType = (input: {\n readonly filename: string\n readonly mimeType: string\n}) => {\n const normalized = normalizeMimeType(input.mimeType)\n\n if (isTextDocumentMimeType(normalized)) return normalized\n\n if (!isUnknownDocumentMimeType(normalized)) return undefined\n\n return textDocumentMimeTypeFromFilename(input.filename)\n}\n\nexport const textToBase64Utf8 = (text: string) => {\n const bytes = new TextEncoder().encode(text)\n let binary = ''\n\n for (const byte of bytes) {\n binary += String.fromCharCode(byte)\n }\n\n return globalThis.btoa(binary)\n}\n\nexport const documentPartFromText = (input: {\n readonly text: string\n readonly filename: string\n readonly mimeType: string\n readonly title?: string\n}) => {\n const normalized = normalizeMimeType(input.mimeType)\n\n const mimeType =\n inferTextDocumentMimeType({\n filename: input.filename,\n mimeType: input.mimeType\n }) ?? (isUnknownDocumentMimeType(normalized) ? 'text/plain' : undefined)\n\n if (mimeType === undefined) return undefined\n\n const base = {\n source: inlineBase64AttachmentSource(textToBase64Utf8(input.text)),\n mimeType,\n filename: input.filename\n }\n\n return input.title === undefined\n ? DocumentPart.make(base)\n : DocumentPart.make({ ...base, title: input.title })\n}\n\nconst decodeBase64Utf8 = (data: string) => {\n const binary = globalThis.atob(data)\n const bytes = Uint8Array.from(binary, character => character.charCodeAt(0))\n\n return new TextDecoder('utf-8', { fatal: true }).decode(bytes)\n}\n\nexport const attachmentSourceText = (source: AttachmentSource) =>\n Match.value(source).pipe(\n Match.tag('InlineBase64', current =>\n Effect.try({\n try: () => Option.some(decodeBase64Utf8(current.data)),\n catch: error => error\n })\n ),\n Match.tag('Url', 'Ref', () => Effect.succeed(Option.none<string>())),\n Match.exhaustive\n )\n\nexport const attachmentSourceBase64 = (source: AttachmentSource) =>\n Match.value(source).pipe(\n Match.tag('InlineBase64', current => Option.some(current.data)),\n Match.tag('Url', 'Ref', () => Option.none<string>()),\n Match.exhaustive\n )\n"],"mappings":";;;;AAIA,IAAa,WAAb,cAA8BA,SAAO,YAAsB,EAAE,QAAQ,EACnE,MAAMA,SAAO,OACf,CAAC,EAAE,CAAC;AAEJ,IAAa,+BAAb,cAAkDA,SAAO,YAA0C,EACjG,gBACA,EACE,MAAMA,SAAO,OACf,CACF,EAAE,CAAC;AAEH,IAAa,sBAAb,cAAyCA,SAAO,YAAiC,EAAE,OAAO,EACxF,KAAKA,SAAO,OACd,CAAC,EAAE,CAAC;AAEJ,IAAa,sBAAb,cAAyCA,SAAO,YAAiC,EAAE,OAAO,EACxF,IAAIA,SAAO,OACb,CAAC,EAAE,CAAC;AAEJ,MAAa,mBAAmBA,SAAO,MAAM;CAC3C;CACA;CACA;AACF,CAAC;AAID,IAAa,YAAb,cAA+BA,SAAO,YAAuB,EAAE,SAAS;CACtE,QAAQ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wB,WACnC,MAAM,MAAM,MAAM,EAAE,KAClB,MAAM,IAAI,iBAAgB,YACxB,OAAO,IAAI;CACT,WAAW,OAAO,KAAK,iBAAiB,QAAQ,IAAI,CAAC;CACrD,QAAO,UAAS;AAClB,CAAC,CACH,GACA,MAAM,IAAI,OAAO,aAAa,OAAO,QAAQ,OAAO,KAAa,CAAC,CAAC,GACnE,MAAM,UACR;AAEF,MAAa,0BAA0B,WACrC,MAAM,MAAM,MAAM,EAAE,KAClB,MAAM,IAAI,iBAAgB,YAAW,OAAO,KAAK,QAAQ,IAAI,CAAC,GAC9D,MAAM,IAAI,OAAO,aAAa,OAAO,KAAa,CAAC,GACnD,MAAM,UACR"}
|
|
1
|
+
{"version":3,"file":"content.mjs","names":["Schema","Arr"],"sources":["../../src/protocol/content.ts"],"sourcesContent":["import { Array as Arr, Effect, Match, Option, Predicate } from 'effect'\nimport * as Schema from 'effect/Schema'\nimport { fileLabel, fileNotCapturedLabel, isFileId } from './file.ts'\n\nexport class TextPart extends Schema.TaggedClass<TextPart>()('Text', {\n text: Schema.String\n}) {}\n\nexport class InlineBase64AttachmentSource extends Schema.TaggedClass<InlineBase64AttachmentSource>()(\n 'InlineBase64',\n {\n data: Schema.String\n }\n) {}\n\nexport class UrlAttachmentSource extends Schema.TaggedClass<UrlAttachmentSource>()('Url', {\n url: Schema.String\n}) {}\n\nexport class RefAttachmentSource extends Schema.TaggedClass<RefAttachmentSource>()('Ref', {\n id: Schema.String\n}) {}\n\nexport const AttachmentSource = Schema.Union([\n InlineBase64AttachmentSource,\n UrlAttachmentSource,\n RefAttachmentSource\n])\n\nexport type AttachmentSource = typeof AttachmentSource.Type\n\nexport class ImagePart extends Schema.TaggedClass<ImagePart>()('Image', {\n source: AttachmentSource,\n mimeType: Schema.String,\n filename: Schema.optional(Schema.String),\n title: Schema.optional(Schema.String),\n width: Schema.optional(Schema.Number),\n height: Schema.optional(Schema.Number)\n}) {}\n\nexport class DocumentPart extends Schema.TaggedClass<DocumentPart>()('Document', {\n source: AttachmentSource,\n mimeType: Schema.String,\n filename: Schema.String,\n title: Schema.optional(Schema.String)\n}) {}\n\nexport class AudioPart extends Schema.TaggedClass<AudioPart>()('Audio', {\n source: AttachmentSource,\n mimeType: Schema.String,\n filename: Schema.optional(Schema.String),\n durationMs: Schema.optional(Schema.Number)\n}) {}\n\n/**\n * Bytes the agent can move between tools, not content for the model to view (ADR 0009). Producers\n * emit an `InlineBase64` source; tool resolution captures it into the host file store and rewrites\n * it to `Ref { id: fileId }`. Providers lower it to its text label only, never as an attachment.\n */\nexport class FilePart extends Schema.TaggedClass<FilePart>()('File', {\n source: AttachmentSource,\n mimeType: Schema.String,\n filename: Schema.optional(Schema.String),\n size: Schema.optional(Schema.Number)\n}) {}\n\nexport const ContentPart = Schema.Union([TextPart, ImagePart, DocumentPart, AudioPart, FilePart])\n\nexport type ContentPart = typeof ContentPart.Type\n\nexport const Content = Schema.Union([Schema.String, Schema.Array(ContentPart)])\n\nexport type Content = typeof Content.Type\n\nexport type AttachmentContentPart = ImagePart | DocumentPart | AudioPart\n\nexport type AttachmentSourceResolver<E = never, R = never> = (\n part: AttachmentContentPart\n) => Effect.Effect<AttachmentSource, E, R>\n\nconst resolveContentPartAttachmentSource = <E, R>(\n part: ContentPart,\n resolver: AttachmentSourceResolver<E, R>\n): Effect.Effect<ContentPart, E, R> =>\n Match.value(part).pipe(\n Match.tag('Text', current => Effect.succeed(current)),\n Match.tag('Image', current =>\n resolver(current).pipe(\n Effect.map(source =>\n ImagePart.make({\n source,\n mimeType: current.mimeType,\n filename: current.filename,\n title: current.title,\n width: current.width,\n height: current.height\n })\n )\n )\n ),\n Match.tag('Document', current =>\n resolver(current).pipe(\n Effect.map(source =>\n DocumentPart.make({\n source,\n mimeType: current.mimeType,\n filename: current.filename,\n title: current.title\n })\n )\n )\n ),\n Match.tag('Audio', current =>\n resolver(current).pipe(\n Effect.map(source =>\n AudioPart.make({\n source,\n mimeType: current.mimeType,\n filename: current.filename,\n durationMs: current.durationMs\n })\n )\n )\n ),\n // Files are never provider attachments: they lower to their label, so nothing to resolve.\n Match.tag('File', current => Effect.succeed(current)),\n Match.exhaustive\n )\n\nexport const resolveContentAttachmentSources = <E, R>(\n content: Content,\n resolver: AttachmentSourceResolver<E, R>\n): Effect.Effect<Content, E, R> =>\n Predicate.isString(content)\n ? Effect.succeed(content)\n : Effect.forEach(content, part => resolveContentPartAttachmentSource(part, resolver))\n\n/**\n * The model-visible text of a file part: its label when captured (`Ref` to a file id), otherwise a\n * \"not captured\" line. Inline bytes are never rendered.\n */\nexport const filePartText = (part: FilePart) => {\n const name = part.filename ?? 'file'\n\n if (Predicate.isTagged(part.source, 'Ref') && isFileId(part.source.id)) {\n return part.size === undefined\n ? fileLabel({ fileId: part.source.id, name, mimeType: part.mimeType })\n : fileLabel({ fileId: part.source.id, name, mimeType: part.mimeType, size: part.size })\n }\n\n return fileNotCapturedLabel({ name, mimeType: part.mimeType, reason: 'no file store' })\n}\n\nexport const contentPartText = (part: ContentPart) =>\n Match.value(part).pipe(\n Match.tag('Text', current => current.text),\n Match.tag('Image', 'Document', 'Audio', () => ''),\n Match.tag('File', filePartText),\n Match.exhaustive\n )\n\nexport const contentPartPreview = (part: ContentPart) =>\n Match.value(part).pipe(\n Match.tag('Text', current => current.text),\n Match.tag('Image', () => 'Image'),\n Match.tag('Document', current => `Document: ${current.title ?? current.filename}`),\n Match.tag('Audio', () => 'Audio'),\n Match.tag('File', current => `File: ${current.filename ?? current.mimeType}`),\n Match.exhaustive\n )\n\nconst loneSurrogates = /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/g\n\n/**\n * Replace lone UTF-16 surrogates with U+FFFD. Models emit them in transcripts\n * and tool arguments; they are valid JS strings but unencodable as UTF-8, so\n * provider APIs and storage backends can reject payloads containing them.\n */\nexport const replaceLoneSurrogates = (text: string) => text.replace(loneSurrogates, '\\uFFFD')\n\n/**\n * Deep-apply `replaceLoneSurrogates` to every string (keys included) in a\n * JSON-shaped value. Providers harden lowered request bodies with this before\n * serialization so junk in replayed transcripts cannot poison model calls;\n * hosts may also use it when persisting model-produced JSON.\n */\nexport const replaceLoneSurrogatesDeep = (value: unknown): unknown => {\n if (Predicate.isString(value)) return replaceLoneSurrogates(value)\n\n if (Array.isArray(value)) return value.map(replaceLoneSurrogatesDeep)\n\n if (Predicate.isObjectOrArray(value)) {\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => [\n replaceLoneSurrogates(key),\n replaceLoneSurrogatesDeep(entry)\n ])\n )\n }\n\n return value\n}\n\nexport const contentText = (content: Content) =>\n Predicate.isString(content) ? content : Arr.map(content, contentPartText).join('')\n\nexport const contentPreview = (content: Content) =>\n Predicate.isString(content) ? content : Arr.map(content, contentPartPreview).join(', ')\n\nexport const contentParts = (content: Content): ReadonlyArray<ContentPart> =>\n Predicate.isString(content) ? [TextPart.make({ text: content })] : content\n\nexport const isContentEmpty = (content: Content) =>\n Predicate.isString(content)\n ? content.length === 0\n : content.length === 0 ||\n Arr.every(content, part => Predicate.isTagged(part, 'Text') && part.text.length === 0)\n\nexport const appendTextToContent = (content: Content, text: string): Content => {\n if (Predicate.isString(content)) {\n return `${content}${text}`\n }\n\n return Option.match(Arr.last(content), {\n onNone: () => [TextPart.make({ text })],\n onSome: last =>\n !Predicate.isTagged(last, 'Text')\n ? [...content, TextPart.make({ text })]\n : Arr.map(content, (part, index) =>\n index === content.length - 1 && Predicate.isTagged(part, 'Text')\n ? TextPart.make({ text: `${part.text}${text}` })\n : part\n )\n })\n}\n\nexport const inlineBase64AttachmentSource = (data: string) =>\n InlineBase64AttachmentSource.make({ data })\n\nexport const urlAttachmentSource = (url: string) => UrlAttachmentSource.make({ url })\n\nexport const refAttachmentSource = (id: string) => RefAttachmentSource.make({ id })\n\nexport const inlineBase64Source = inlineBase64AttachmentSource\n\nconst base64ChunkBytes = 0x8000\n\n/** Standard base64 of `bytes`, chunked so large files do not exceed argument limits. */\nexport const bytesToBase64 = (bytes: Uint8Array) => {\n let binary = ''\n\n for (let offset = 0; offset < bytes.length; offset += base64ChunkBytes) {\n binary += String.fromCharCode(...bytes.subarray(offset, offset + base64ChunkBytes))\n }\n\n return globalThis.btoa(binary)\n}\n\n/**\n * Bytes of standard base64 (throws on invalid input, like `atob`). Copies into one preallocated\n * array: `Uint8Array.from(binary, mapFn)` first collects every character into a list, which\n * costs tens of bytes per decoded byte (~0.7 GB for 20 MiB).\n */\nexport const base64ToBytes = (data: string) => {\n const binary = globalThis.atob(data)\n const bytes = new Uint8Array(binary.length)\n\n for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index)\n\n return bytes\n}\n\n/** A `FilePart` carrying `bytes` inline, for tools that yield files (ADR 0009). */\nexport const filePartFromBytes = (input: {\n readonly bytes: Uint8Array\n readonly mimeType: string\n readonly filename?: string\n}) =>\n input.filename === undefined\n ? FilePart.make({\n source: inlineBase64AttachmentSource(bytesToBase64(input.bytes)),\n mimeType: input.mimeType,\n size: input.bytes.byteLength\n })\n : FilePart.make({\n source: inlineBase64AttachmentSource(bytesToBase64(input.bytes)),\n mimeType: input.mimeType,\n filename: input.filename,\n size: input.bytes.byteLength\n })\n\nexport const attachmentSourcePreview = (source: AttachmentSource) =>\n Match.value(source).pipe(\n Match.tag('InlineBase64', () => 'inline'),\n Match.tag('Url', current => current.url),\n Match.tag('Ref', current => current.id),\n Match.exhaustive\n )\n\nexport const attachmentSourceDataUrl = (source: AttachmentSource, mimeType: string) =>\n Match.value(source).pipe(\n Match.tag('InlineBase64', current => Option.some(`data:${mimeType};base64,${current.data}`)),\n Match.tag('Url', 'Ref', () => Option.none<string>()),\n Match.exhaustive\n )\n\nexport const attachmentSourceUrl = (source: AttachmentSource, mimeType: string) =>\n Match.value(source).pipe(\n Match.tag('InlineBase64', current => Option.some(`data:${mimeType};base64,${current.data}`)),\n Match.tag('Url', current => Option.some(current.url)),\n Match.tag('Ref', () => Option.none<string>()),\n Match.exhaustive\n )\n\nconst normalizeMimeType = (mimeType: string) =>\n mimeType.split(';', 1)[0]?.trim().toLowerCase() ?? ''\n\nconst textDocumentMimeTypeByExtension = {\n '.csv': 'text/csv',\n '.css': 'text/css',\n '.gql': 'application/graphql',\n '.graphql': 'application/graphql',\n '.html': 'text/html',\n '.js': 'application/javascript',\n '.jsx': 'application/javascript',\n '.json': 'application/json',\n '.jsonl': 'application/x-ndjson',\n '.md': 'text/markdown',\n '.markdown': 'text/markdown',\n '.sql': 'application/sql',\n '.toml': 'application/toml',\n '.ts': 'application/typescript',\n '.tsx': 'application/typescript',\n '.txt': 'text/plain',\n '.xml': 'application/xml',\n '.yaml': 'application/yaml',\n '.yml': 'application/yaml'\n}\n\nconst isUnknownDocumentMimeType = (mimeType: string) =>\n mimeType.length === 0 ||\n mimeType === 'application/octet-stream' ||\n mimeType === 'binary/octet-stream'\n\nexport const isTextDocumentMimeType = (mimeType: string) => {\n const normalized = normalizeMimeType(mimeType)\n\n return (\n normalized.startsWith('text/') ||\n normalized === 'application/json' ||\n normalized === 'application/ld+json' ||\n normalized === 'application/jsonl' ||\n normalized === 'application/x-ndjson' ||\n normalized === 'application/javascript' ||\n normalized === 'application/x-javascript' ||\n normalized === 'application/typescript' ||\n normalized === 'application/x-typescript' ||\n normalized === 'application/xml' ||\n normalized === 'application/yaml' ||\n normalized === 'application/x-yaml' ||\n normalized === 'application/toml' ||\n normalized === 'application/markdown' ||\n normalized === 'application/sql' ||\n normalized === 'application/graphql' ||\n normalized.endsWith('+json') ||\n normalized.endsWith('+xml')\n )\n}\n\nexport const textDocumentMimeTypeFromFilename = (filename: string) => {\n const normalized = filename.trim().toLowerCase()\n\n const entry = Object.entries(textDocumentMimeTypeByExtension).find(([extension]) =>\n normalized.endsWith(extension)\n )\n\n return entry?.[1]\n}\n\nexport const inferTextDocumentMimeType = (input: {\n readonly filename: string\n readonly mimeType: string\n}) => {\n const normalized = normalizeMimeType(input.mimeType)\n\n if (isTextDocumentMimeType(normalized)) return normalized\n\n if (!isUnknownDocumentMimeType(normalized)) return undefined\n\n return textDocumentMimeTypeFromFilename(input.filename)\n}\n\nexport const textToBase64Utf8 = (text: string) => {\n const bytes = new TextEncoder().encode(text)\n let binary = ''\n\n for (const byte of bytes) {\n binary += String.fromCharCode(byte)\n }\n\n return globalThis.btoa(binary)\n}\n\nexport const documentPartFromText = (input: {\n readonly text: string\n readonly filename: string\n readonly mimeType: string\n readonly title?: string\n}) => {\n const normalized = normalizeMimeType(input.mimeType)\n\n const mimeType =\n inferTextDocumentMimeType({\n filename: input.filename,\n mimeType: input.mimeType\n }) ?? (isUnknownDocumentMimeType(normalized) ? 'text/plain' : undefined)\n\n if (mimeType === undefined) return undefined\n\n const base = {\n source: inlineBase64AttachmentSource(textToBase64Utf8(input.text)),\n mimeType,\n filename: input.filename\n }\n\n return input.title === undefined\n ? DocumentPart.make(base)\n : DocumentPart.make({ ...base, title: input.title })\n}\n\nconst decodeBase64Utf8 = (data: string) =>\n new TextDecoder('utf-8', { fatal: true }).decode(base64ToBytes(data))\n\nexport const attachmentSourceText = (source: AttachmentSource) =>\n Match.value(source).pipe(\n Match.tag('InlineBase64', current =>\n Effect.try({\n try: () => Option.some(decodeBase64Utf8(current.data)),\n catch: error => error\n })\n ),\n Match.tag('Url', 'Ref', () => Effect.succeed(Option.none<string>())),\n Match.exhaustive\n )\n\nexport const attachmentSourceBase64 = (source: AttachmentSource) =>\n Match.value(source).pipe(\n Match.tag('InlineBase64', current => Option.some(current.data)),\n Match.tag('Url', 'Ref', () => Option.none<string>()),\n Match.exhaustive\n )\n"],"mappings":";;;;AAIA,IAAa,WAAb,cAA8BA,SAAO,YAAsB,EAAE,QAAQ,EACnE,MAAMA,SAAO,OACf,CAAC,EAAE,CAAC;AAEJ,IAAa,+BAAb,cAAkDA,SAAO,YAA0C,EACjG,gBACA,EACE,MAAMA,SAAO,OACf,CACF,EAAE,CAAC;AAEH,IAAa,sBAAb,cAAyCA,SAAO,YAAiC,EAAE,O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,KAAA;CAEhE,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;CAEnC,MAAM,OAAO;EACX,QAAQ,6BAA6B,iBAAiB,MAAM,IAAI,CAAC;EACjE;EACA,UAAU,MAAM;CAClB;CAEA,OAAO,MAAM,UAAU,KAAA,IACnB,aAAa,KAAK,IAAI,IACtB,aAAa,KAAK;EAAE,GAAG;EAAM,OAAO,MAAM;CAAM,CAAC;AACvD;AAEA,MAAM,oBAAoB,SACxB,IAAI,YAAY,SAAS,EAAE,OAAO,KAAK,CAAC,EAAE,OAAO,cAAc,IAAI,CAAC;AAEtE,MAAa,wBAAwB,WACnC,MAAM,MAAM,MAAM,EAAE,KAClB,MAAM,IAAI,iBAAgB,YACxB,OAAO,IAAI;CACT,WAAW,OAAO,KAAK,iBAAiB,QAAQ,IAAI,CAAC;CACrD,QAAO,UAAS;AAClB,CAAC,CACH,GACA,MAAM,IAAI,OAAO,aAAa,OAAO,QAAQ,OAAO,KAAa,CAAC,CAAC,GACnE,MAAM,UACR;AAEF,MAAa,0BAA0B,WACrC,MAAM,MAAM,MAAM,EAAE,KAClB,MAAM,IAAI,iBAAgB,YAAW,OAAO,KAAK,QAAQ,IAAI,CAAC,GAC9D,MAAM,IAAI,OAAO,aAAa,OAAO,KAAa,CAAC,GACnD,MAAM,UACR"}
|
|
@@ -34,6 +34,12 @@ declare const ProviderErrorInfo_base: Schema.Class<ProviderErrorInfo, Schema.Str
|
|
|
34
34
|
readonly status: Schema.optional<Schema.Number>;
|
|
35
35
|
readonly providerCode: Schema.optional<Schema.String>;
|
|
36
36
|
readonly retryAfterMs: Schema.optional<Schema.Number>;
|
|
37
|
+
/**
|
|
38
|
+
* When an exhausted subscription quota resets (epoch milliseconds), read from the provider's
|
|
39
|
+
* quota signal (Claude unified rate-limit headers, Codex `usage_limit_reached`). Present only on
|
|
40
|
+
* quota exhaustion, never on transient rate limits; account pools cool the account down until it.
|
|
41
|
+
*/
|
|
42
|
+
readonly quotaResetsAtMs: Schema.optional<Schema.Number>;
|
|
37
43
|
readonly stream: Schema.optional<typeof ProviderStreamDiagnostics>;
|
|
38
44
|
}>, {}>;
|
|
39
45
|
declare class ProviderErrorInfo extends ProviderErrorInfo_base {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.mts","names":[],"sources":["../../src/protocol/event.ts"],"mappings":";;;;;;cAgCa,cAAA,EAAc,MAAA,CAAA,QAAA;AAAA,KAEf,cAAA,UAAwB,cAAA,CAAe,IAAI;AAAA,cAE1C,cAAA,EAAc,MAAA,CAAA,QAAA;AAAA,KAiBf,cAAA,UAAwB,cAAA,CAAe,IAAI;;cAG1C,gBAAA,EAAgB,MAAA,CAAA,QAAA;AAAA,KAEjB,gBAAA,UAA0B,gBAAA,CAAiB,IAAI;AAAA,cAE9C,mBAAA,EAAmB,MAAA,CAAA,QAAA;AAAA,KAYpB,mBAAA,UAA6B,mBAAA,CAAoB,IAAI;AAAA,cAEpD,sBAAA,EAAsB,MAAA,CAAA,QAAA;AAAA,KAEvB,sBAAA,UAAgC,sBAAA,CAAuB,IAAI;AA1ChB;AAAA,cA6C1C,4BAAA,EAA4B,MAAA,CAAA,QAAA;AAAA,KAE7B,4BAAA,UAAsC,4BAAA,CAA6B,IAAI;AAAA,cAAA,8BAAA;;0FA5BvE;EAAA;0CAA2C;EAAA,wCAGyB;EAAA;;AAAnD;AAAA,cA4BhB,yBAAA,SAAkC,8BAa7C;AAAA,cAAG,sBAAA
|
|
1
|
+
{"version":3,"file":"event.d.mts","names":[],"sources":["../../src/protocol/event.ts"],"mappings":";;;;;;cAgCa,cAAA,EAAc,MAAA,CAAA,QAAA;AAAA,KAEf,cAAA,UAAwB,cAAA,CAAe,IAAI;AAAA,cAE1C,cAAA,EAAc,MAAA,CAAA,QAAA;AAAA,KAiBf,cAAA,UAAwB,cAAA,CAAe,IAAI;;cAG1C,gBAAA,EAAgB,MAAA,CAAA,QAAA;AAAA,KAEjB,gBAAA,UAA0B,gBAAA,CAAiB,I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79
79
|
providerCode: Schema$1.optional(Schema$1.String),
|
|
80
80
|
retryAfterMs: Schema$1.optional(Schema$1.Number),
|
|
81
|
+
/**
|
|
82
|
+
* When an exhausted subscription quota resets (epoch milliseconds), read from the provider's
|
|
83
|
+
* quota signal (Claude unified rate-limit headers, Codex `usage_limit_reached`). Present only on
|
|
84
|
+
* quota exhaustion, never on transient rate limits; account pools cool the account down until it.
|
|
85
|
+
*/
|
|
86
|
+
quotaResetsAtMs: Schema$1.optional(Schema$1.Number),
|
|
81
87
|
stream: Schema$1.optional(ProviderStreamDiagnostics)
|
|
82
88
|
}) {};
|
|
83
89
|
var AgentStart = class extends Schema$1.TaggedClass()("AgentStart", { ...EventIdentity }) {};
|