prefix-safe-json 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -3
- package/dist/coordinator/coordinator.d.ts +1 -0
- package/dist/coordinator/coordinator.d.ts.map +1 -1
- package/dist/coordinator/coordinator.js +56 -5
- package/dist/coordinator/coordinator.js.map +1 -1
- package/dist/coordinator/diagnostic-codes.d.ts +26 -0
- package/dist/coordinator/diagnostic-codes.d.ts.map +1 -1
- package/dist/coordinator/diagnostic-codes.js +26 -0
- package/dist/coordinator/diagnostic-codes.js.map +1 -1
- package/dist/coordinator/protocol.d.ts +2 -1
- package/dist/coordinator/protocol.d.ts.map +1 -1
- package/dist/coordinator/types.d.ts +1 -1
- package/dist/coordinator/types.d.ts.map +1 -1
- package/dist/gate/decide.d.ts.map +1 -1
- package/dist/gate/decide.js +49 -8
- package/dist/gate/decide.js.map +1 -1
- package/dist/gate/types.d.ts +1 -1
- package/dist/gate/types.d.ts.map +1 -1
- package/dist/guard/ai-sdk-execution-lock.d.ts +19 -0
- package/dist/guard/ai-sdk-execution-lock.d.ts.map +1 -0
- package/dist/guard/ai-sdk-execution-lock.js +78 -0
- package/dist/guard/ai-sdk-execution-lock.js.map +1 -0
- package/dist/index.d.ts +76 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +82 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/ai-sdk.d.ts +6 -1
- package/dist/providers/ai-sdk.d.ts.map +1 -1
- package/dist/providers/ai-sdk.js +32 -4
- package/dist/providers/ai-sdk.js.map +1 -1
- package/package.json +16 -4
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
**Don't execute incomplete AI tool calls.**
|
|
6
6
|
|
|
7
|
-
`prefix-safe-json` is a fail-closed integrity layer for streamed
|
|
8
|
-
calls. It distinguishes complete, unfabricated arguments from truncated
|
|
7
|
+
`prefix-safe-json` is a fail-closed execution-integrity layer for streamed
|
|
8
|
+
LLM tool calls. It distinguishes complete, unfabricated arguments from truncated
|
|
9
9
|
ones — including ones a syntax-level JSON repairer can make *look* complete
|
|
10
10
|
— before they reach a tool with real side effects (writing a file, running a
|
|
11
11
|
command, sending a request).
|
|
@@ -94,12 +94,100 @@ provider, or framework hands it the data. See
|
|
|
94
94
|
`test/guard/ai-sdk-compatibility.test.ts` for the cross-version test
|
|
95
95
|
evidence.
|
|
96
96
|
|
|
97
|
+
**Execution ownership: what must never also happen**
|
|
98
|
+
|
|
99
|
+
The guard's decisions only mean something if it's the sole thing deciding
|
|
100
|
+
whether your tool function runs. The pattern above works because it never
|
|
101
|
+
gives the AI SDK's own tool-calling loop a chance to run your tool itself —
|
|
102
|
+
in order from strongest guarantee to weakest:
|
|
103
|
+
|
|
104
|
+
- **Strongest — `createAiSdkExecutionLock()`** — wrap your tool definitions
|
|
105
|
+
with it before passing them to `streamText()`/`generateText()`. It removes
|
|
106
|
+
every AI SDK-invoked callback capable of running your code before this
|
|
107
|
+
library's decision — not just `execute`, but also `onInputStart`,
|
|
108
|
+
`onInputDelta`, and `onInputAvailable` (verified directly against
|
|
109
|
+
`ai@5`/`ai@6`/`ai@7`'s own real source: all three fire unconditionally,
|
|
110
|
+
independent of `needsApproval`/approval status — `needsApproval: true`
|
|
111
|
+
alone does **not** stop them, which is exactly the gap this function
|
|
112
|
+
closes). It also forces `needsApproval: true`, which still closes the
|
|
113
|
+
`execute` gap specifically on `ai@6`+ via the SDK's own approval
|
|
114
|
+
mechanism. It also rejects a **function-valued `description`**
|
|
115
|
+
(`ai@7`+ invokes it during tool preparation, before the model call even
|
|
116
|
+
begins — arbitrary caller code on the same pre-decision timeline as the
|
|
117
|
+
callback trio; a string `description` is unaffected on every major), and
|
|
118
|
+
any **provider tool shape whose real execution location it cannot
|
|
119
|
+
verify**: `isProviderExecuted: true` (real operation runs entirely on the
|
|
120
|
+
model provider's remote infrastructure), `ai@6`'s discriminator-less
|
|
121
|
+
`{ type: "provider" }`, and `ai@5`'s discriminator-less
|
|
122
|
+
`{ type: "provider-defined" }` are all rejected rather than silently
|
|
123
|
+
accepted; `ai@7`'s `{ type: "provider", isProviderExecuted: false }` is
|
|
124
|
+
accepted (verified to have no `execute` field at all on that shape, so the
|
|
125
|
+
SDK can never auto-run it). The guarantee is precisely about **this
|
|
126
|
+
function's own output, unchanged, on a supported local tool definition**:
|
|
127
|
+
it says nothing about a tool that bypasses this function, one
|
|
128
|
+
mutated/reconstructed after this function returns it, or a rejected
|
|
129
|
+
shape. Still dispatch manually from
|
|
130
|
+
`guard.finish().decisions`, exactly as shown above; this only closes the
|
|
131
|
+
door on the SDK (or your own callbacks) doing it *for* you. See
|
|
132
|
+
[`docs/EXECUTION_GATE.md`](docs/EXECUTION_GATE.md#execution-ownership-tool-resulttool-error-as-evidence).
|
|
133
|
+
- **Safe, supported pattern (all majors, including `ai@5`)** — define your
|
|
134
|
+
tools *without* an AI SDK-native `execute` callback at all. Not even a
|
|
135
|
+
no-op one: the guard treats any `tool-result`/`tool-error` it observes as
|
|
136
|
+
proof the SDK's tool loop already invoked that call, and a no-op callback
|
|
137
|
+
still produces one — omitting `execute` entirely is what keeps the SDK
|
|
138
|
+
from running the tool itself in the first place. Consume `fullStream`
|
|
139
|
+
yourself, and dispatch manually — only for `action === "execute"` — after
|
|
140
|
+
`guard.finish()`, exactly as shown above. `createAiSdkExecutionLock()`
|
|
141
|
+
above gets you this same shape automatically (it drops `execute` too) plus
|
|
142
|
+
the SDK-enforced backstop where that backstop exists.
|
|
143
|
+
- **Unprotected / misuse pattern** — attach the real, irreversible operation
|
|
144
|
+
(or any side-effecting code at all) directly as `execute`, `onInputStart`,
|
|
145
|
+
`onInputDelta`, or `onInputAvailable` on a tool definition that bypasses
|
|
146
|
+
`createAiSdkExecutionLock()` entirely, *and* separately run the guard on
|
|
147
|
+
the same stream. All four are callbacks the SDK invokes on its own
|
|
148
|
+
schedule, independent of and often before this guard ever reaches a
|
|
149
|
+
decision — `onInputStart`/`onInputDelta`/`onInputAvailable` in particular
|
|
150
|
+
run regardless of finish reason, schema validity, or approval status, on
|
|
151
|
+
every major including `ai@5`. If that happens, the side effect has
|
|
152
|
+
already run — `prefix-safe-json` cannot retroactively undo it, and on
|
|
153
|
+
`ai@5` specifically nothing in this library can prevent any of these four
|
|
154
|
+
callbacks from firing at all (verified directly, not assumed — see
|
|
155
|
+
`test/integration/ai-sdk-lifecycle/ai-v5.real.test.ts`).
|
|
156
|
+
|
|
157
|
+
The guard does defend against the second pattern in one specific way, and
|
|
158
|
+
only for `execute` specifically: a `tool-result` or `tool-error` part on
|
|
159
|
+
`fullStream` is direct evidence the SDK's own loop already invoked *some*
|
|
160
|
+
call's `execute`. When it names a specific call (a real `toolCallId`), only
|
|
161
|
+
that call is disqualified; when it doesn't, the guard cannot tell which
|
|
162
|
+
in-flight call was affected and fails closed for **every** call in that
|
|
163
|
+
stream rather than guess. Either way the guard never again reports
|
|
164
|
+
`action: "execute"` for the affected call(s)
|
|
165
|
+
(`reason: "sdk_execution_observed"`, which takes priority over every other
|
|
166
|
+
rejection reason), so a caller who also runs the documented manual-dispatch
|
|
167
|
+
loop will not invoke the tool function a *second* time. There is no
|
|
168
|
+
equivalent detection for a bypassed `onInputStart`/`onInputDelta`/
|
|
169
|
+
`onInputAvailable` — those callbacks produce no observable `fullStream`
|
|
170
|
+
evidence of having run at all, so a misuse of any of the three is invisible
|
|
171
|
+
to the guard entirely; the only defense is calling
|
|
172
|
+
`createAiSdkExecutionLock()` in the first place. It does not undo
|
|
173
|
+
whatever the SDK's own callback already did. See
|
|
174
|
+
[`docs/EXECUTION_GATE.md`](docs/EXECUTION_GATE.md#execution-ownership-tool-resulttool-error-as-evidence)
|
|
175
|
+
for the full behavior and test matrix.
|
|
176
|
+
|
|
97
177
|
**Supported providers**: OpenAI (legacy `function_call` and Responses API),
|
|
98
178
|
Anthropic, Gemini, OpenRouter, generic OpenAI-compatible endpoints, and the
|
|
99
179
|
Vercel AI SDK. High-level guards currently ship for the AI SDK; every
|
|
100
180
|
provider has a public low-level adapter (see below) that composes with
|
|
101
181
|
`createToolCallExecutionGate()` the same way.
|
|
102
182
|
|
|
183
|
+
`AiSdkStreamAdapter`/`createAiSdkExecutionGuard()` target the public
|
|
184
|
+
`streamText()`/`generateText()` `fullStream` surface, whose `finishReason`
|
|
185
|
+
is a plain unified string (`"stop"`, `"length"`, ...). They are not
|
|
186
|
+
currently an adapter for the lower-level `@ai-sdk/provider` `doStream()`
|
|
187
|
+
boundary (`LanguageModelV3`/`V4`), where finish reason is
|
|
188
|
+
`{ unified, raw }`-object-shaped — building your own provider against that
|
|
189
|
+
interface directly needs different handling of that field.
|
|
190
|
+
|
|
103
191
|
Full semantics, the decision table, provider finish-reason mapping, and the
|
|
104
192
|
high-level guard API: [`docs/EXECUTION_GATE.md`](docs/EXECUTION_GATE.md).
|
|
105
193
|
|
|
@@ -120,6 +208,8 @@ This library parses each chunk incrementally and provides:
|
|
|
120
208
|
|
|
121
209
|
> The parser never fabricates missing data. It clearly distinguishes what is definite, what is pending, what was deterministically repaired, and what is lost.
|
|
122
210
|
|
|
211
|
+
> **Valid JSON is not safe generation completion. Safe generation completion is not permission to execute a side effect.** Structural validity, confirmed completeness, and execution authority are three separate questions — the gate layer (below) answers all three before ever returning `execute`, not just the first. See [`docs/THREAT_MODEL.md`](docs/THREAT_MODEL.md) for the full guarantee/non-guarantee list.
|
|
212
|
+
|
|
123
213
|
## Why not a general "partial JSON" parser?
|
|
124
214
|
|
|
125
215
|
Most streaming JSON helpers (including ones already used in the wild for
|
|
@@ -210,7 +300,9 @@ It does **not**:
|
|
|
210
300
|
with complete, schema-valid arguments is still reported `execute`)
|
|
211
301
|
|
|
212
302
|
See [`docs/EXECUTION_GATE.md`](docs/EXECUTION_GATE.md#limitations---what-this-does-not-protect-against)
|
|
213
|
-
for the full list, including known internal limitations
|
|
303
|
+
for the full list, including known internal limitations, and
|
|
304
|
+
[`docs/THREAT_MODEL.md`](docs/THREAT_MODEL.md) for the complete security
|
|
305
|
+
objective, trust boundaries, and guarantee/non-guarantee list.
|
|
214
306
|
|
|
215
307
|
## Current Status
|
|
216
308
|
|
|
@@ -229,6 +321,7 @@ for the full list, including known internal limitations.
|
|
|
229
321
|
- Optional per-tool JSON Schema validation on the coordinator (see below) — a value can be structurally complete and still not match what a tool declared it needs
|
|
230
322
|
- `createToolCallExecutionGate()` — a fail-closed `execute` / `retry` / `reject` decision per tool call, built on top of the coordinator (see [`docs/EXECUTION_GATE.md`](docs/EXECUTION_GATE.md))
|
|
231
323
|
- `createAiSdkExecutionGuard()` — a drop-in high-level guard for the Vercel AI SDK's `fullStream`, composing a provider adapter with the execution gate; every `ExecutionDecision` also carries an `evidence` object explaining why (see [`docs/EXECUTION_GATE.md`](docs/EXECUTION_GATE.md#high-level-guards))
|
|
324
|
+
- SDK execution-ownership detection — direct evidence that the AI SDK's own tool loop already invoked a call (attributed or, when it can't be, stream-wide) permanently blocks this library from also authorizing it, with the highest rejection-reason priority of any disqualifier (see [`docs/EXECUTION_GATE.md`](docs/EXECUTION_GATE.md#execution-ownership-tool-resulttool-error-as-evidence))
|
|
232
325
|
|
|
233
326
|
### Not Yet Implemented
|
|
234
327
|
|
|
@@ -271,6 +364,13 @@ A schema mismatch also surfaces as a coordinator diagnostic (`E_SCHEMA_VALIDATIO
|
|
|
271
364
|
npm install prefix-safe-json
|
|
272
365
|
```
|
|
273
366
|
|
|
367
|
+
ESM only — `import`, not `require`. There is currently no CommonJS build.
|
|
368
|
+
Node `>=22.0.0` (Active LTS lines only — Node 18/20 are end-of-life and no
|
|
369
|
+
longer receive security patches). See
|
|
370
|
+
[`docs/COMPATIBILITY.md`](docs/COMPATIBILITY.md) for the full
|
|
371
|
+
ESM/Node/SemVer/Stable-vs-Experimental policy and the per-provider
|
|
372
|
+
compatibility matrix.
|
|
373
|
+
|
|
274
374
|
## Low-level API: Quick Start
|
|
275
375
|
|
|
276
376
|
The AI SDK guard (above) covers the common case. For other providers, or
|
|
@@ -13,6 +13,7 @@ export declare class DefaultToolCallStreamCoordinator implements ToolCallStreamC
|
|
|
13
13
|
private eventsProcessed;
|
|
14
14
|
private globalSequence;
|
|
15
15
|
private isFinished;
|
|
16
|
+
private finishedReason?;
|
|
16
17
|
/**
|
|
17
18
|
* @param limits Coordinator-level limits (concurrent tool calls, tool name
|
|
18
19
|
* size, etc.) — distinct from `parserOptions`, which configures each
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../src/coordinator/coordinator.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,aAAa,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,yBAAyB,EAAgB,eAAe,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,EACxB,8BAA8B,EAC9B,qBAAqB,EACrB,iBAAiB,EAIjB,cAAc,EACf,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../src/coordinator/coordinator.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,aAAa,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,yBAAyB,EAAgB,eAAe,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,EACxB,8BAA8B,EAC9B,qBAAqB,EACrB,iBAAiB,EAIjB,cAAc,EACf,MAAM,YAAY,CAAC;AAwCpB,qBAAa,gCAAiC,YAAW,yBAAyB;IAChF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;IAC1D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgC;IAC/D,OAAO,CAAC,KAAK,CAAgD;IAC7D,OAAO,CAAC,qBAAqB,CAAkC;IAC/D,OAAO,CAAC,WAAW,CAAK;IACxB,OAA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|
|
4
|
+
import { SDK_EXECUTION_OBSERVED_DIAGNOSTIC_CODE, SDK_EXECUTION_ERROR_DIAGNOSTIC_CODE, } from "./diagnostic-codes.js";
|
|
5
|
+
// A `provider_diagnostic` carrying either code is proof that a provider SDK's
|
|
6
|
+
// own tool loop already invoked this call's `execute` callback (see the two
|
|
7
|
+
// constants' own docs in diagnostic-codes.ts) - success and failure get
|
|
8
|
+
// identical treatment here, since neither proves the absence of a partial
|
|
9
|
+
// irreversible side effect, and this library only needs to know that
|
|
10
|
+
// execution authority already left its hands.
|
|
11
|
+
const SDK_EXECUTION_OBSERVED_CODES = new Set([
|
|
12
|
+
SDK_EXECUTION_OBSERVED_DIAGNOSTIC_CODE,
|
|
13
|
+
SDK_EXECUTION_ERROR_DIAGNOSTIC_CODE,
|
|
14
|
+
]);
|
|
4
15
|
class CoordinatorCallState {
|
|
5
16
|
internalId;
|
|
6
17
|
provider;
|
|
@@ -30,6 +41,7 @@ export class DefaultToolCallStreamCoordinator {
|
|
|
30
41
|
eventsProcessed = 0;
|
|
31
42
|
globalSequence = 0;
|
|
32
43
|
isFinished = false;
|
|
44
|
+
finishedReason;
|
|
33
45
|
/**
|
|
34
46
|
* @param limits Coordinator-level limits (concurrent tool calls, tool name
|
|
35
47
|
* size, etc.) — distinct from `parserOptions`, which configures each
|
|
@@ -59,11 +71,31 @@ export class DefaultToolCallStreamCoordinator {
|
|
|
59
71
|
}
|
|
60
72
|
push(event) {
|
|
61
73
|
if (this.isFinished) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
// A second `provider_stream_end` whose reason contradicts the first
|
|
75
|
+
// one already decided every call's outcome (e.g. "complete" then
|
|
76
|
+
// "abort") is a genuine provider-protocol anomaly, not just a late or
|
|
77
|
+
// duplicate event - it gets its own diagnostic code so a caller can
|
|
78
|
+
// tell the two apart without comparing payloads themselves. Either
|
|
79
|
+
// way this call's decision was already made and locked in by the
|
|
80
|
+
// `isFinished` gate above: nothing here can raise execution
|
|
81
|
+
// confidence after the fact, only report that the contradiction was
|
|
82
|
+
// observed. Rejected/unattributed, same as any other post-finish
|
|
83
|
+
// event - no open call exists left to attribute it to by the time the
|
|
84
|
+
// stream has already ended.
|
|
85
|
+
const isConflictingTerminalReason = event.type === "provider_stream_end" &&
|
|
86
|
+
this.finishedReason !== undefined &&
|
|
87
|
+
event.reason !== this.finishedReason;
|
|
88
|
+
this.addDiagnostic(isConflictingTerminalReason
|
|
89
|
+
? {
|
|
90
|
+
code: "E_TERMINAL_REASON_CONFLICT",
|
|
91
|
+
severity: "fatal",
|
|
92
|
+
message: `Stream already ended with reason "${this.finishedReason}"; a second, conflicting terminal reason "${event.reason}" arrived afterward`,
|
|
93
|
+
}
|
|
94
|
+
: {
|
|
95
|
+
code: "E_EVENT_AFTER_STREAM_END",
|
|
96
|
+
severity: "error",
|
|
97
|
+
message: "Event pushed after stream end",
|
|
98
|
+
});
|
|
67
99
|
return { accepted: false };
|
|
68
100
|
}
|
|
69
101
|
if (this.eventsProcessed >= this.limits.maxNormalizedEvents) {
|
|
@@ -360,9 +392,28 @@ export class DefaultToolCallStreamCoordinator {
|
|
|
360
392
|
message: event.message,
|
|
361
393
|
internalId,
|
|
362
394
|
});
|
|
395
|
+
// Mirrors handleIdentity()'s existing "mutate call.status mid-stream, not
|
|
396
|
+
// only at finishCall() time" pattern for identity conflicts - this is
|
|
397
|
+
// the same kind of call-scoped fact that can be known before the stream
|
|
398
|
+
// ends and must not wait for it. Gated on "collecting" (first write
|
|
399
|
+
// wins, matching finishCall()'s own `if (call.status !== "collecting")
|
|
400
|
+
// return` guard) so this is a one-way transition: once set, no later
|
|
401
|
+
// event of any kind - including a duplicate of this same diagnostic -
|
|
402
|
+
// can move the call off "sdk_execution_observed". An unattributable
|
|
403
|
+
// diagnostic (no callRef, e.g. a malformed provider event with no
|
|
404
|
+
// correlatable ID) intentionally poisons nothing - there is no specific
|
|
405
|
+
// call to hold ineligible, and guessing one would be worse than leaving
|
|
406
|
+
// it to decide normally.
|
|
407
|
+
if (internalId !== undefined && SDK_EXECUTION_OBSERVED_CODES.has(event.code)) {
|
|
408
|
+
const call = this.calls.get(internalId);
|
|
409
|
+
if (call && call.status === "collecting") {
|
|
410
|
+
call.status = "sdk_execution_observed";
|
|
411
|
+
}
|
|
412
|
+
}
|
|
363
413
|
}
|
|
364
414
|
handleStreamEnd(event) {
|
|
365
415
|
this.isFinished = true;
|
|
416
|
+
this.finishedReason = event.reason;
|
|
366
417
|
// Close all open calls
|
|
367
418
|
for (const call of this.calls.values()) {
|
|
368
419
|
if (call.status === "collecting") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../src/coordinator/coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAoB,MAAM,KAAK,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAOL,0BAA0B,EAI3B,MAAM,YAAY,CAAC;AAEpB,MAAM,oBAAoB;IACf,UAAU,CAAS;IACnB,QAAQ,CAAe;IAEhC,UAAU,CAAU;IACpB,SAAS,CAAU;IAEnB,IAAI,CAAU;IACd,YAAY,GAAY,KAAK,CAAC;IAC9B,oBAAoB,GAAY,KAAK,CAAC;IAE7B,MAAM,CAAwB;IAEvC,MAAM,GAA4B,YAAY,CAAC;IAC/C,WAAW,CAAW;IAEtB,YAAY,UAAkB,EAAE,QAAsB,EAAE,MAA6B;QACnF,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,MAAM,OAAO,gCAAgC;IAC1B,MAAM,CAAoB;IAC1B,aAAa,CAA4B;IACzC,cAAc,CAAgC;IACvD,KAAK,GAAsC,IAAI,GAAG,EAAE,CAAC;IACrD,qBAAqB,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AAI,EAAE,cAAc;aACrC,CAAC,CAAC;QACL,CAAC;QACD,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK;SAC7B,CAAC;IACJ,CAAC;CACF;AAED,MAAM,UAAU,+BAA+B,CAC7C,MAAmC,EACnC,aAA6B,EAC7B,WAA4C;IAE5C,OAAO,IAAI,gCAAgC,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -8,4 +8,30 @@
|
|
|
8
8
|
* blindly.
|
|
9
9
|
*/
|
|
10
10
|
export declare const CONTENT_FILTERED_DIAGNOSTIC_CODE = "E_CONTENT_FILTERED";
|
|
11
|
+
/**
|
|
12
|
+
* Emitted (as a `provider_diagnostic` carrying the call's own `callRef`) by
|
|
13
|
+
* the AI SDK adapter when a `tool-result` part is observed: direct proof
|
|
14
|
+
* that the Vercel AI SDK's own tool-calling loop already invoked this call's
|
|
15
|
+
* `execute` callback and it returned successfully - independent of, and
|
|
16
|
+
* almost always before, this library's own decision is ever computed. See
|
|
17
|
+
* `SDK_EXECUTION_ERROR_DIAGNOSTIC_CODE` for the failed-attempt counterpart;
|
|
18
|
+
* the coordinator treats both identically (see `coordinator.ts`'s
|
|
19
|
+
* `handleProviderDiagnostic`), poisoning the call to `status:
|
|
20
|
+
* "sdk_execution_observed"` so the gate can never later report `execute` for
|
|
21
|
+
* it - re-running (or, for the error case, retrying) a call the SDK already
|
|
22
|
+
* attempted would risk a second/duplicate invocation of the same
|
|
23
|
+
* irreversible side effect.
|
|
24
|
+
*/
|
|
25
|
+
export declare const SDK_EXECUTION_OBSERVED_DIAGNOSTIC_CODE = "E_SDK_EXECUTION_OBSERVED";
|
|
26
|
+
/**
|
|
27
|
+
* Emitted (as a `provider_diagnostic` carrying the call's own `callRef`, when
|
|
28
|
+
* a `callRef` could be determined) by the AI SDK adapter when a `tool-error`
|
|
29
|
+
* part is observed: proof that the Vercel AI SDK's own tool-calling loop
|
|
30
|
+
* already invoked this call's `execute` callback and it threw. This does NOT
|
|
31
|
+
* prove no partial irreversible side effect occurred before the throw, so it
|
|
32
|
+
* receives the exact same fail-closed treatment as
|
|
33
|
+
* `SDK_EXECUTION_OBSERVED_DIAGNOSTIC_CODE` - success and failure are not
|
|
34
|
+
* distinguished into safe/unsafe here, both must fail closed.
|
|
35
|
+
*/
|
|
36
|
+
export declare const SDK_EXECUTION_ERROR_DIAGNOSTIC_CODE = "E_PROVIDER_TOOL_ERROR";
|
|
11
37
|
//# sourceMappingURL=diagnostic-codes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic-codes.d.ts","sourceRoot":"","sources":["../../src/coordinator/diagnostic-codes.ts"],"names":[],"mappings":"AAYA;;;;;;;;GAQG;AACH,eAAO,MAAM,gCAAgC,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"diagnostic-codes.d.ts","sourceRoot":"","sources":["../../src/coordinator/diagnostic-codes.ts"],"names":[],"mappings":"AAYA;;;;;;;;GAQG;AACH,eAAO,MAAM,gCAAgC,uBAAuB,CAAC;AAErE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sCAAsC,6BAA6B,CAAC;AAEjF;;;;;;;;;GASG;AACH,eAAO,MAAM,mCAAmC,0BAA0B,CAAC"}
|
|
@@ -19,4 +19,30 @@
|
|
|
19
19
|
* blindly.
|
|
20
20
|
*/
|
|
21
21
|
export const CONTENT_FILTERED_DIAGNOSTIC_CODE = "E_CONTENT_FILTERED";
|
|
22
|
+
/**
|
|
23
|
+
* Emitted (as a `provider_diagnostic` carrying the call's own `callRef`) by
|
|
24
|
+
* the AI SDK adapter when a `tool-result` part is observed: direct proof
|
|
25
|
+
* that the Vercel AI SDK's own tool-calling loop already invoked this call's
|
|
26
|
+
* `execute` callback and it returned successfully - independent of, and
|
|
27
|
+
* almost always before, this library's own decision is ever computed. See
|
|
28
|
+
* `SDK_EXECUTION_ERROR_DIAGNOSTIC_CODE` for the failed-attempt counterpart;
|
|
29
|
+
* the coordinator treats both identically (see `coordinator.ts`'s
|
|
30
|
+
* `handleProviderDiagnostic`), poisoning the call to `status:
|
|
31
|
+
* "sdk_execution_observed"` so the gate can never later report `execute` for
|
|
32
|
+
* it - re-running (or, for the error case, retrying) a call the SDK already
|
|
33
|
+
* attempted would risk a second/duplicate invocation of the same
|
|
34
|
+
* irreversible side effect.
|
|
35
|
+
*/
|
|
36
|
+
export const SDK_EXECUTION_OBSERVED_DIAGNOSTIC_CODE = "E_SDK_EXECUTION_OBSERVED";
|
|
37
|
+
/**
|
|
38
|
+
* Emitted (as a `provider_diagnostic` carrying the call's own `callRef`, when
|
|
39
|
+
* a `callRef` could be determined) by the AI SDK adapter when a `tool-error`
|
|
40
|
+
* part is observed: proof that the Vercel AI SDK's own tool-calling loop
|
|
41
|
+
* already invoked this call's `execute` callback and it threw. This does NOT
|
|
42
|
+
* prove no partial irreversible side effect occurred before the throw, so it
|
|
43
|
+
* receives the exact same fail-closed treatment as
|
|
44
|
+
* `SDK_EXECUTION_OBSERVED_DIAGNOSTIC_CODE` - success and failure are not
|
|
45
|
+
* distinguished into safe/unsafe here, both must fail closed.
|
|
46
|
+
*/
|
|
47
|
+
export const SDK_EXECUTION_ERROR_DIAGNOSTIC_CODE = "E_PROVIDER_TOOL_ERROR";
|
|
22
48
|
//# sourceMappingURL=diagnostic-codes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic-codes.js","sourceRoot":"","sources":["../../src/coordinator/diagnostic-codes.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,mDAAmD;AACnD,EAAE;AACF,sEAAsE;AACtE,2EAA2E;AAC3E,yEAAyE;AACzE,2EAA2E;AAC3E,0EAA0E;AAC1E,wEAAwE;AACxE,8CAA8C;AAC9C,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"diagnostic-codes.js","sourceRoot":"","sources":["../../src/coordinator/diagnostic-codes.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,mDAAmD;AACnD,EAAE;AACF,sEAAsE;AACtE,2EAA2E;AAC3E,yEAAyE;AACzE,2EAA2E;AAC3E,0EAA0E;AAC1E,wEAAwE;AACxE,8CAA8C;AAC9C,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,oBAAoB,CAAC;AAErE;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,0BAA0B,CAAC;AAEjF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,uBAAuB,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { StreamEndReason } from "../types.js";
|
|
2
|
+
export type { StreamEndReason };
|
|
1
3
|
export type ProviderName = "openai" | "anthropic" | "gemini" | "openrouter" | "openai-compatible" | "ai-sdk" | "unknown";
|
|
2
4
|
export interface NormalizedEventBase {
|
|
3
5
|
/**
|
|
@@ -32,7 +34,6 @@ export interface ToolCallArgumentsDeltaEvent extends NormalizedEventBase {
|
|
|
32
34
|
readonly callRef: ProviderCallRef;
|
|
33
35
|
readonly delta: string | Uint8Array;
|
|
34
36
|
}
|
|
35
|
-
export type StreamEndReason = "complete" | "length" | "cancelled" | "provider_error" | "network_error" | "unknown";
|
|
36
37
|
export interface ToolCallEndEvent extends NormalizedEventBase {
|
|
37
38
|
readonly type: "tool_call_end";
|
|
38
39
|
readonly callRef: ProviderCallRef;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/coordinator/protocol.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,YAAY,GACZ,mBAAmB,GACnB,QAAQ,GACR,SAAS,CAAC;AAEd,MAAM,WAAW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name?: string;
|
|
16
16
|
readonly nameComplete: boolean;
|
|
17
17
|
readonly parser: ParserSnapshot;
|
|
18
|
-
readonly status: "collecting" | "complete" | "truncated" | "salvaged" | "invalid" | "cancelled";
|
|
18
|
+
readonly status: "collecting" | "complete" | "truncated" | "salvaged" | "invalid" | "cancelled" | "sdk_execution_observed";
|
|
19
19
|
/**
|
|
20
20
|
* Result of validating `parser.stableValue` against the JSON Schema
|
|
21
21
|
* registered for this call's tool name (see `toolSchemas` on
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/coordinator/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEzF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACtC;AAED,eAAO,MAAM,0BAA0B,EAAE,iBAKxC,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAEhC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAE/B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAEhC,QAAQ,CAAC,MAAM,EACX,YAAY,GACZ,UAAU,GACV,WAAW,GACX,UAAU,GACV,SA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CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;CAC5C,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,0BAA0B,CAAC;IAC1C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;CAClC,CAAC;AAEN,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;IAC1D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,CAAC,KAAK,EAAE,yBAAyB,GAAG,qBAAqB,CAAC;IAC9D,QAAQ,IAAI,2BAA2B,CAAC;IACxC,WAAW,IAAI,SAAS,wBAAwB,EAAE,CAAC;IACnD,MAAM,CAAC,IAAI,CAAC,EAAE;QACZ,MAAM,CAAC,EAAE,eAAe,CAAC;QACzB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GAAG,8BAA8B,CAAC;CACpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decide.d.ts","sourceRoot":"","sources":["../../src/gate/decide.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decide.d.ts","sourceRoot":"","sources":["../../src/gate/decide.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAM7D,OAAO,EAAoB,eAAe,EAAmB,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEvG,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAE1C;;;;;OAKG;IACH,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAE1C;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACxD;AAoBD,wBAAgB,eAAe,CAC7B,IAAI,EAAE,aAAa,EACnB,GAAG,EAAE,eAAe,GACnB,eAAe,GAAG,qBAAqB,CA4JzC"}
|
package/dist/gate/decide.js
CHANGED
|
@@ -6,17 +6,28 @@
|
|
|
6
6
|
// ToolCallState fixtures, without spinning up a full push()/finish()
|
|
7
7
|
// pipeline for every row of the table.
|
|
8
8
|
//
|
|
9
|
-
// Priority order matters and is intentional
|
|
9
|
+
// Priority order matters and is intentional. SDK-execution-ownership
|
|
10
|
+
// evidence (attributed to this call, or stream-wide/unattributable) is
|
|
11
|
+
// checked FIRST, before every other disqualifier - it is a statement that
|
|
12
|
+
// execution authority already left this library's hands, categorically
|
|
13
|
+
// different from every other check below, which are all statements about
|
|
14
|
+
// the ARGUMENTS/STREAM being unusable. A caller's higher-level logic might
|
|
15
|
+
// reasonably retry a whole request on resource_limit/provider_error/
|
|
16
|
+
// content_filtered; retrying is never safe once SDK execution was observed,
|
|
17
|
+
// since a fresh generation could trigger the SDK's own execute() again for
|
|
18
|
+
// whatever already (partially) ran. That distinction would be lost if a
|
|
19
|
+
// data-quality reason could mask it, so it always wins regardless of what
|
|
20
|
+
// else is also true about the call. Every other fail-closed disqualifier
|
|
10
21
|
// (resource limits, provider errors, content-policy terminations, schema
|
|
11
|
-
// mismatches, malformed content, positively-observed truncation) is
|
|
12
|
-
// before the single positive "execute" branch. "execute" is reached
|
|
13
|
-
// once nothing above has disqualified the call - it is the last
|
|
14
|
-
// case, never the first check made, so a future status value that
|
|
15
|
-
// to superficially resemble "complete" still can't skip the checks
|
|
16
|
-
// it.
|
|
22
|
+
// mismatches, malformed content, positively-observed truncation) is then
|
|
23
|
+
// checked before the single positive "execute" branch. "execute" is reached
|
|
24
|
+
// only once nothing above has disqualified the call - it is the last
|
|
25
|
+
// positive case, never the first check made, so a future status value that
|
|
26
|
+
// happens to superficially resemble "complete" still can't skip the checks
|
|
27
|
+
// ahead of it.
|
|
17
28
|
// ---------------------------------------------------------------------------
|
|
18
29
|
import { DiagnosticCode } from "../diagnostics/codes.js";
|
|
19
|
-
import { CONTENT_FILTERED_DIAGNOSTIC_CODE } from "../coordinator/diagnostic-codes.js";
|
|
30
|
+
import { CONTENT_FILTERED_DIAGNOSTIC_CODE, SDK_EXECUTION_OBSERVED_DIAGNOSTIC_CODE, SDK_EXECUTION_ERROR_DIAGNOSTIC_CODE, } from "../coordinator/diagnostic-codes.js";
|
|
20
31
|
const PARSER_RESOURCE_LIMIT_CODES = new Set([
|
|
21
32
|
DiagnosticCode.E_LIMIT_DEPTH,
|
|
22
33
|
DiagnosticCode.E_LIMIT_INPUT_BYTES,
|
|
@@ -28,6 +39,10 @@ const COORDINATOR_RESOURCE_LIMIT_CODES = new Set([
|
|
|
28
39
|
"E_COORDINATOR_LIMIT_EVENTS",
|
|
29
40
|
"E_TOOL_NAME_LIMIT",
|
|
30
41
|
]);
|
|
42
|
+
const SDK_EXECUTION_OBSERVED_CODES = new Set([
|
|
43
|
+
SDK_EXECUTION_OBSERVED_DIAGNOSTIC_CODE,
|
|
44
|
+
SDK_EXECUTION_ERROR_DIAGNOSTIC_CODE,
|
|
45
|
+
]);
|
|
31
46
|
export function decideExecution(call, ctx) {
|
|
32
47
|
const parserDiagnostics = call.parser.diagnostics;
|
|
33
48
|
const callCoordinatorDiagnostics = ctx.diagnostics.filter((d) => d.internalId === call.internalId);
|
|
@@ -62,6 +77,27 @@ export function decideExecution(call, ctx) {
|
|
|
62
77
|
function retry(reason) {
|
|
63
78
|
return { ...common, action: "retry", executable: false, reason };
|
|
64
79
|
}
|
|
80
|
+
// --- SDK execution ownership (highest priority - see file header) -------
|
|
81
|
+
// Two evidence shapes, identical outcome:
|
|
82
|
+
// - attributed: `call.status` was poisoned the moment the coordinator
|
|
83
|
+
// resolved a tool-result/tool-error to this exact call - see
|
|
84
|
+
// DefaultToolCallStreamCoordinator.handleProviderDiagnostic. One-way,
|
|
85
|
+
// call-scoped.
|
|
86
|
+
// - unattributable: a tool-result/tool-error arrived with no resolvable
|
|
87
|
+
// call identity at all, recorded as a stream-wide diagnostic
|
|
88
|
+
// (`internalId: undefined`) instead of guessing which call it meant.
|
|
89
|
+
// With no way to rule any call in this stream out - including one
|
|
90
|
+
// whose `tool_call_start` arrives after this point - as the one the
|
|
91
|
+
// SDK already executed, EVERY call decided against this same
|
|
92
|
+
// `ctx.diagnostics` list must fail closed, not just the one that
|
|
93
|
+
// happens to look safest. `globalCoordinatorDiagnostics` is re-derived
|
|
94
|
+
// fresh from the full, append-only diagnostics list on every call to
|
|
95
|
+
// this function, so this is automatic for calls that exist now and
|
|
96
|
+
// calls the coordinator hasn't created yet.
|
|
97
|
+
if (call.status === "sdk_execution_observed" ||
|
|
98
|
+
globalCoordinatorDiagnostics.some((d) => SDK_EXECUTION_OBSERVED_CODES.has(d.code))) {
|
|
99
|
+
return reject("sdk_execution_observed");
|
|
100
|
+
}
|
|
65
101
|
// --- Universal fail-closed checks ---------------------------------------
|
|
66
102
|
// Evaluated first and unconditionally, regardless of call.status, so a
|
|
67
103
|
// resource limit, a provider-side failure, or a content-policy
|
|
@@ -83,6 +119,11 @@ export function decideExecution(call, ctx) {
|
|
|
83
119
|
// Exhaustive over ToolCallState["status"] with no `default`: if a future
|
|
84
120
|
// coordinator version adds a new status literal without a matching case
|
|
85
121
|
// here, `noImplicitReturns` fails the build - not a silent runtime gap.
|
|
122
|
+
// "sdk_execution_observed" has no case here at all: the check above
|
|
123
|
+
// already returned for it, and TypeScript's own control-flow narrowing
|
|
124
|
+
// has removed that literal from `call.status`'s type by this point - the
|
|
125
|
+
// compiler itself now rejects a case for it as unreachable, a stronger
|
|
126
|
+
// guarantee than a runtime-only "this shouldn't happen" comment could give.
|
|
86
127
|
switch (call.status) {
|
|
87
128
|
case "complete": {
|
|
88
129
|
if (call.schemaValid === false) {
|
package/dist/gate/decide.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decide.js","sourceRoot":"","sources":["../../src/gate/decide.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,mCAAmC;AACnC,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,qEAAqE;AACrE,uCAAuC;AACvC,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"decide.js","sourceRoot":"","sources":["../../src/gate/decide.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,mCAAmC;AACnC,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,qEAAqE;AACrE,uCAAuC;AACvC,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,0EAA0E;AAC1E,uEAAuE;AACvE,yEAAyE;AACzE,2EAA2E;AAC3E,qEAAqE;AACrE,4EAA4E;AAC5E,2EAA2E;AAC3E,wEAAwE;AACxE,0EAA0E;AAC1E,yEAAyE;AACzE,yEAAyE;AACzE,yEAAyE;AACzE,4EAA4E;AAC5E,qEAAqE;AACrE,2EAA2E;AAC3E,2EAA2E;AAC3E,eAAe;AACf,8EAA8E;AAE9E,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGzD,OAAO,EACL,gCAAgC,EAChC,sCAAsC,EACtC,mCAAmC,GACpC,MAAM,oCAAoC,CAAC;AA4B5C,MAAM,2BAA2B,GAAwB,IAAI,GAAG,CAAC;IAC/D,c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GAAoB;oBAChC,GAAG,MAAM;oBACT,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,MAAM,EAAE,SAAS;oBACjB,UAAU,EAAE,IAAI;oBAChB,MAAM,EAAE,UAAU;oBAClB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;iBAC/B,CAAC;gBACF,OAAO,QAAQ,CAAC;YAClB,CAAC;YACD,kEAAkE;YAClE,mEAAmE;YACnE,8DAA8D;YAC9D,OAAO,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACpC,CAAC;QAED,KAAK,WAAW;YACd,qEAAqE;YACrE,kEAAkE;YAClE,kBAAkB;YAClB,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC;QAE5B,KAAK,SAAS;YACZ,iEAAiE;YACjE,qEAAqE;YACrE,SAAS;YACT,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC;QAE7B,KAAK,UAAU;YACb,iEAAiE;YACjE,kEAAkE;YAClE,2DAA2D;YAC3D,OAAO,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAEpC,KAAK,WAAW,CAAC;QACjB,KAAK,YAAY;YACf,OAAO,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
|
package/dist/gate/types.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type ExecutionAction = "execute" | "retry" | "reject";
|
|
|
18
18
|
* Machine-readable classification of *why* an `ExecutionAction` was chosen.
|
|
19
19
|
* See `docs/EXECUTION_GATE.md` for the full decision table.
|
|
20
20
|
*/
|
|
21
|
-
export type ExecutionReason = "complete" | "truncated" | "stream_incomplete" | "schema_invalid" | "malformed" | "resource_limit" | "provider_error" | "content_filtered" | "unknown";
|
|
21
|
+
export type ExecutionReason = "complete" | "truncated" | "stream_incomplete" | "schema_invalid" | "malformed" | "resource_limit" | "provider_error" | "content_filtered" | "sdk_execution_observed" | "unknown";
|
|
22
22
|
/**
|
|
23
23
|
* Why a decision came out the way it did - observability, not a second
|
|
24
24
|
* decision input. Every field here is read-only, derived state already held
|
package/dist/gate/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/gate/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAEtG;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE7D;;;GAGG;AACH,MAAM,MAAM,eAAe,GACvB,UAAU,GACV,WAAW,GACX,mBAAmB,GACnB,gBAAgB,GAChB,WAAW,GACX,gBAAgB,GAChB,gBAAgB,GAChB,kBAAkB,GAClB,SAAS,CAAC;AAEd;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAEhC;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAEjC,4EAA4E;IAC5E,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAE1C;;;;;;;OAOG;IACH,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IAEpC;;;;;;;;OAQG;IACH,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;IAEvC,0FAA0F;IAC1F,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IAEnC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAE/B,mGAAmG;IACnG,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,UAAU,uBAAuB;IAC/B,mFAAmF;IACnF,QAAQ,C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AQ,CAAC,UAAU,EAAE,KAAK,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;CACvD;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,GAAG,eAAe,GAAG,qBAAqB,CAAC;AAExE,MAAM,WAAW,gCAAgC;IAC/C,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAEjD;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACxD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,KAAK,EAAE,yBAAyB,GAAG,qBAAqB,CAAC;IAE9D;;;;;OAKG;IACH,QAAQ,IAAI,SAAS,iBAAiB,EAAE,CAAC;IAEzC,sFAAsF;IACtF,WAAW,IAAI,SAAS,wBAAwB,EAAE,CAAC;IAEnD,MAAM,CAAC,IAAI,CAAC,EAAE;QACZ,MAAM,CAAC,EAAE,eAAe,CAAC;QACzB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GAAG,gCAAgC,CAAC;CACtC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tool definition after {@link createAiSdkExecutionLock} has processed it.
|
|
3
|
+
* `execute` and every SDK-invoked pre-decision input-lifecycle callback
|
|
4
|
+
* (`onInputStart`, `onInputDelta`, `onInputAvailable`) are removed, not
|
|
5
|
+
* merely typed as optional-and-absent - the compiler will reject an attempt
|
|
6
|
+
* to read them off a locked tool. `needsApproval` is narrowed to the literal
|
|
7
|
+
* `true`, reflecting that this function always forces it and never leaves it
|
|
8
|
+
* caller-controlled. Every other field (schema, description, provider
|
|
9
|
+
* metadata, etc.) keeps its original type unchanged.
|
|
10
|
+
*/
|
|
11
|
+
export type LockedAiSdkTool<T> = Omit<T, "execute" | "onInputStart" | "onInputDelta" | "onInputAvailable" | "needsApproval"> & {
|
|
12
|
+
needsApproval: true;
|
|
13
|
+
};
|
|
14
|
+
/** `createAiSdkExecutionLock`'s return type: every tool in the input, individually locked. */
|
|
15
|
+
export type LockedAiSdkTools<TTools extends Record<string, object>> = {
|
|
16
|
+
[K in keyof TTools]: LockedAiSdkTool<TTools[K]>;
|
|
17
|
+
};
|
|
18
|
+
export declare function createAiSdkExecutionLock<TTools extends Record<string, object>>(tools: TTools): LockedAiSdkTools<TTools>;
|
|
19
|
+
//# sourceMappingURL=ai-sdk-execution-lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-sdk-execution-lock.d.ts","sourceRoot":"","sources":["../../src/guard/ai-sdk-execution-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,SAAS,GAAG,cAAc,GAAG,cAAc,GAAG,kBAAkB,GAAG,eAAe,CAAC,GAAG;IAC7H,aAAa,EAAE,IAAI,CAAC;CACrB,CAAC;AAEF,8FAA8F;AAC9F,MAAM,MAAM,gBAAgB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI;KACnE,CAAC,IAAI,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;CAChD,CAAC;AA+NF,wBAAgB,wBAAwB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAwBvH"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rejects tool shapes whose real execution location this function cannot
|
|
3
|
+
* verify from the object alone. See the "Provider-executed and
|
|
4
|
+
* execution-location-ambiguous tools" section of this module's top doc
|
|
5
|
+
* comment for the exact per-major reasoning; this function only encodes the
|
|
6
|
+
* resulting decision table.
|
|
7
|
+
*/
|
|
8
|
+
function rejectUnsupportedProviderShape(name, definition) {
|
|
9
|
+
if (definition.isProviderExecuted === true) {
|
|
10
|
+
throw new Error(`createAiSdkExecutionLock: tool "${name}" is provider-executed (isProviderExecuted: true) - ` +
|
|
11
|
+
"its real operation runs entirely on the model provider's own infrastructure, which this " +
|
|
12
|
+
"function has no visibility into or control over. Wrapping it here would falsely imply a " +
|
|
13
|
+
"guarantee this function cannot make. Do not pass provider-executed tools to this function.");
|
|
14
|
+
}
|
|
15
|
+
if (definition.type === "provider") {
|
|
16
|
+
if (definition.isProviderExecuted === false) {
|
|
17
|
+
// ai@7's locally-executed provider-defined shape - see the doc comment;
|
|
18
|
+
// structurally has no `execute` field, so the SDK's own
|
|
19
|
+
// `isExecutableTool` (`typeof tool.execute === "function"`) never
|
|
20
|
+
// auto-runs it, and it falls through to the normal strip-and-relock
|
|
21
|
+
// path below like any other accepted tool.
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
throw new Error(`createAiSdkExecutionLock: tool "${name}" has type "provider" but no isProviderExecuted flag - ` +
|
|
25
|
+
"this matches ai@6's provider-tool shape, which has no discriminator at all for whether the " +
|
|
26
|
+
"operation runs on the model provider's remote infrastructure or locally in this process " +
|
|
27
|
+
"(ai@7 added isProviderExecuted for exactly this reason). This function cannot safely infer " +
|
|
28
|
+
"which applies from the object shape, so it rejects rather than risk falsely implying a " +
|
|
29
|
+
"guarantee it cannot verify. Do not pass this tool to createAiSdkExecutionLock.");
|
|
30
|
+
}
|
|
31
|
+
if (definition.type === "provider-defined") {
|
|
32
|
+
throw new Error(`createAiSdkExecutionLock: tool "${name}" has type "provider-defined" - this is ai@5's ` +
|
|
33
|
+
"provider-tool shape, which (like ai@6's) has no isProviderExecuted or equivalent " +
|
|
34
|
+
"discriminator: some provider-defined tools execute locally and some execute entirely on " +
|
|
35
|
+
"the provider's remote infrastructure, and nothing in the object shape distinguishes them. " +
|
|
36
|
+
"This function cannot safely infer which execution authority applies, so it rejects rather " +
|
|
37
|
+
"than guess. Do not pass this tool to createAiSdkExecutionLock.");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Rejects a function-valued `description`. On ai@7, `prepareTools()` calls
|
|
42
|
+
* `resolveToolDescription()`, which invokes a function-valued `description`
|
|
43
|
+
* directly - arbitrary caller code running during tool preparation, before
|
|
44
|
+
* `streamText`/`generateText`'s model call begins and therefore necessarily
|
|
45
|
+
* before this library's gate can reach any decision. ai@5/ai@6 only ever
|
|
46
|
+
* typed `description` as `string`, so this rejects nothing for a caller
|
|
47
|
+
* following those majors' own types; it is a shape check, not a version
|
|
48
|
+
* check, and applies identically regardless of which major is installed.
|
|
49
|
+
*/
|
|
50
|
+
function rejectFunctionValuedDescription(name, definition) {
|
|
51
|
+
if (typeof definition.description !== "function")
|
|
52
|
+
return;
|
|
53
|
+
throw new Error(`createAiSdkExecutionLock: tool "${name}" has a function-valued "description" - ` +
|
|
54
|
+
"on ai@7+, the AI SDK's own prepareTools()/resolveToolDescription() calls that function " +
|
|
55
|
+
"during tool preparation, before streamText/generateText's model call begins, which is " +
|
|
56
|
+
"arbitrary caller code running before this library's gate can reach any decision. A string " +
|
|
57
|
+
"description is unaffected and remains supported. Do not pass a function-valued description " +
|
|
58
|
+
"to createAiSdkExecutionLock; resolve it to a string yourself before calling this function.");
|
|
59
|
+
}
|
|
60
|
+
export function createAiSdkExecutionLock(tools) {
|
|
61
|
+
const locked = {};
|
|
62
|
+
for (const [name, definition] of Object.entries(tools)) {
|
|
63
|
+
const probe = definition;
|
|
64
|
+
rejectUnsupportedProviderShape(name, probe);
|
|
65
|
+
if (probe.type !== "provider") {
|
|
66
|
+
// Only the ordinary local-tool code path (type undefined/"function"/"dynamic")
|
|
67
|
+
// ever reaches prepareTools()'s description-invoking branch; an accepted
|
|
68
|
+
// `type: "provider"` tool's description is never read by the SDK at all
|
|
69
|
+
// (see rejectUnsupportedProviderShape's "provider" branch), so checking
|
|
70
|
+
// it there would reject shapes the SDK can never actually exploit.
|
|
71
|
+
rejectFunctionValuedDescription(name, probe);
|
|
72
|
+
}
|
|
73
|
+
const { execute: _droppedExecute, onInputStart: _droppedOnInputStart, onInputDelta: _droppedOnInputDelta, onInputAvailable: _droppedOnInputAvailable, needsApproval: _droppedNeedsApproval, ...rest } = probe;
|
|
74
|
+
locked[name] = { ...rest, needsApproval: true };
|
|
75
|
+
}
|
|
76
|
+
return locked;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=ai-sdk-execution-lock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-sdk-execution-lock.js","sourceRoot":"","sources":["../../src/guard/ai-sdk-execution-lock.ts"],"names":[],"mappings":"AA0KA;;;;;;GAMG;AACH,SAAS,8BAA8B,CAAC,IAAY,EAAE,UAAsB;IAC1E,IAAI,UAAU,CAAC,kBAAkB,KAAK,IAAI,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CACb,mCAAmC,IAAI,sDAAsD;YAC3F,0FAA0F;YAC1F,0FAA0F;YAC1F,4FAA4F,CAC/F,CAAC;IACJ,CAAC;IAED,IAAI,UAAU,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACnC,IAAI,UAAU,CAAC,kBAAkB,KAAK,KAAK,EAAE,CAAC;YAC5C,wEAAwE;YACxE,wDAAwD;YACxD,kEAAkE;YAClE,oEAAoE;YACpE,2CAA2C;YAC3C,OAAO;QACT,CAAC;QACD,MAAM,IAAI,KAAK,CACb,mCAAmC,IAAI,yDAAyD;YAC9F,6FAA6F;YAC7F,0FAA0F;YAC1F,6FAA6F;YAC7F,yFAAyF;YACzF,gFAAgF,CACnF,CAAC;IACJ,CAAC;IAED,IAAI,UAAU,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CACb,mCAAmC,IAAI,iDAAiD;YACtF,mFAAmF;YACnF,0FAA0F;YAC1F,4FAA4F;YAC5F,4FAA4F;YA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onParser, ParserOptions, PushResult, ParserSnapshot, FinalResult, ParserEvent, ValueCommittedEvent, ContainerClosedEvent, RepairAppliedEvent, DiagnosticEvent, DocumentCompleteEvent, StreamFinishedEvent, JsonValue, JsonObject, JsonArray, SyntaxStatus, StreamEndReason, PendingToken, RepairAction, Diagnostic, ParserLimits, } from "./types.js";
|
|
7
|
+
/** @public (Stable) Default resource limits applied when none are supplied to `createParser()`. */
|
|
7
8
|
export { DEFAULT_LIMITS } from "./limits.js";
|
|
9
|
+
/** @public (Stable) Machine-readable parser diagnostic codes (see `Diagnostic.code`). */
|
|
8
10
|
export { DiagnosticCode } from "./diagnostics/codes.js";
|
|
9
11
|
/**
|
|
10
12
|
* @public (Stable)
|
|
@@ -13,6 +15,13 @@ export { DiagnosticCode } from "./diagnostics/codes.js";
|
|
|
13
15
|
export { createToolCallStreamCoordinator } from "./coordinator/coordinator.js";
|
|
14
16
|
export type { ToolCallStreamCoordinator, ToolCallState, JsonSchemaLike, CoordinatorLimits, CoordinatorDiagnostic, } from "./coordinator/types.js";
|
|
15
17
|
export type { NormalizedToolStreamEvent, ProviderName } from "./coordinator/protocol.js";
|
|
18
|
+
/**
|
|
19
|
+
* @public (Stable)
|
|
20
|
+
* Diagnostic code a custom `ProviderStreamAdapter` can emit (as a
|
|
21
|
+
* stream-wide `provider_diagnostic`, no `callRef`) to signal a
|
|
22
|
+
* content-safety/policy termination - the gate matches on this exact code
|
|
23
|
+
* to report `reason: "content_filtered"`. See docs/EXECUTION_GATE.md.
|
|
24
|
+
*/
|
|
16
25
|
export { CONTENT_FILTERED_DIAGNOSTIC_CODE } from "./coordinator/diagnostic-codes.js";
|
|
17
26
|
/**
|
|
18
27
|
* @public (Stable)
|
|
@@ -30,16 +39,81 @@ export type { ToolCallExecutionGate, ToolCallExecutionGateFinalResult, Execution
|
|
|
30
39
|
*/
|
|
31
40
|
export { createAiSdkExecutionGuard } from "./guard/ai-sdk.js";
|
|
32
41
|
export type { ExecutionGuard, AiSdkExecutionGuard, ExecutionGuardOptions } from "./guard/types.js";
|
|
42
|
+
/**
|
|
43
|
+
* @public (Experimental)
|
|
44
|
+
* Removes every AI SDK-invoked callback field capable of running caller code
|
|
45
|
+
* before this library's gate reaches a decision - `execute`,
|
|
46
|
+
* `onInputStart`, `onInputDelta`, and `onInputAvailable` (verified directly
|
|
47
|
+
* against `ai@5`/`ai@6`/`ai@7`'s own real source that all three fire
|
|
48
|
+
* unconditionally, with zero reference to `needsApproval` or approval
|
|
49
|
+
* status - `needsApproval: true` alone does not stop them). Also forces
|
|
50
|
+
* `needsApproval: true`, which still closes the `execute` gap on `ai@6`+ via
|
|
51
|
+
* the SDK's own approval mechanism. Also rejects two other classes of
|
|
52
|
+
* pre-decision caller code this library cannot neutralize by stripping
|
|
53
|
+
* fields: a function-valued `description` (`ai@7`+ invokes it during tool
|
|
54
|
+
* preparation, before the model call begins), and any provider tool shape
|
|
55
|
+
* whose real execution location cannot be verified from the object alone -
|
|
56
|
+
* `isProviderExecuted: true`, `ai@6`'s discriminator-less `{ type:
|
|
57
|
+
* "provider" }`, and `ai@5`'s discriminator-less `{ type: "provider-defined"
|
|
58
|
+
* }` are all rejected; `ai@7`'s `{ type: "provider", isProviderExecuted:
|
|
59
|
+
* false }` (verified to have no `execute` field at all, so the SDK can never
|
|
60
|
+
* auto-run it) is accepted. Real execution stays exactly where it already
|
|
61
|
+
* was: driven manually from `guard.finish().decisions`. See the function's
|
|
62
|
+
* own doc comment for the exact, precisely-scoped guarantee, its real
|
|
63
|
+
* limits, and the explicit non-sandbox threat-model boundary around
|
|
64
|
+
* caller-provided schema/validation code, and
|
|
65
|
+
* `docs/EXECUTION_GATE.md#execution-ownership-tool-resulttool-error-as-evidence`.
|
|
66
|
+
*/
|
|
67
|
+
export { createAiSdkExecutionLock } from "./guard/ai-sdk-execution-lock.js";
|
|
68
|
+
export type { LockedAiSdkTool, LockedAiSdkTools } from "./guard/ai-sdk-execution-lock.js";
|
|
69
|
+
/**
|
|
70
|
+
* @public (Experimental)
|
|
71
|
+
* The contract every provider adapter above implements. Classified
|
|
72
|
+
* Experimental alongside them, not Stable: writing a custom adapter against
|
|
73
|
+
* this interface is exactly as exposed to upstream wire-shape churn as the
|
|
74
|
+
* adapters that already implement it.
|
|
75
|
+
*/
|
|
33
76
|
export type { ProviderStreamAdapter } from "./providers/adapter.js";
|
|
34
77
|
/**
|
|
35
78
|
* @public (Experimental)
|
|
36
|
-
*
|
|
37
|
-
*
|
|
79
|
+
* OpenAI Chat Completions (legacy `function_call`) and Responses API
|
|
80
|
+
* streaming tool-call shape.
|
|
38
81
|
*/
|
|
39
82
|
export { OpenAIStreamAdapter } from "./providers/openai.js";
|
|
83
|
+
/**
|
|
84
|
+
* @public (Experimental)
|
|
85
|
+
* Generic OpenAI-compatible `choices[].delta.tool_calls[]` streaming
|
|
86
|
+
* shape, shared by OpenAI's current API and most compatible endpoints.
|
|
87
|
+
*/
|
|
40
88
|
export { OpenAICompatibleStreamAdapter } from "./providers/openai-compatible.js";
|
|
89
|
+
/**
|
|
90
|
+
* @public (Experimental)
|
|
91
|
+
* Anthropic Messages API streaming tool-call shape
|
|
92
|
+
* (`content_block_delta` / `input_json_delta`).
|
|
93
|
+
*/
|
|
41
94
|
export { AnthropicStreamAdapter } from "./providers/anthropic.js";
|
|
95
|
+
/**
|
|
96
|
+
* @public (Experimental)
|
|
97
|
+
* Gemini's structured `functionCall` shape. Unlike the other adapters,
|
|
98
|
+
* Gemini delivers function-call arguments as an already-parsed object, not
|
|
99
|
+
* incremental raw JSON text - see docs/COMPATIBILITY.md for what that
|
|
100
|
+
* means for this adapter's guarantees.
|
|
101
|
+
*/
|
|
42
102
|
export { GeminiStreamAdapter } from "./providers/gemini.js";
|
|
103
|
+
/**
|
|
104
|
+
* @public (Experimental)
|
|
105
|
+
* OpenRouter's streaming tool-call shape (a thin extension of the
|
|
106
|
+
* OpenAI-compatible shape above).
|
|
107
|
+
*/
|
|
43
108
|
export { OpenRouterStreamAdapter } from "./providers/openrouter.js";
|
|
109
|
+
/**
|
|
110
|
+
* @public (Experimental)
|
|
111
|
+
* Vercel AI SDK's `fullStream` tool-call part shape
|
|
112
|
+
* (`tool-input-start`/`-delta`/`-end`, `tool-call`, `tool-result`,
|
|
113
|
+
* `tool-error`, `finish`, `error`, `abort`). Verified against `ai@5.0.240`,
|
|
114
|
+
* `ai@6.0.259`, `ai@7.0.70` - see docs/COMPATIBILITY.md. Prefer
|
|
115
|
+
* `createAiSdkExecutionGuard()` (Stable, above) for the common case; use
|
|
116
|
+
* this directly only if you need the adapter instance itself.
|
|
117
|
+
*/
|
|
44
118
|
export { AiSdkStreamAdapter } from "./providers/ai-sdk.js";
|
|
45
119
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,YAAY,EAEV,qBAAqB,EACrB,aAAa,EAGb,UAAU,EACV,cAAc,EACd,WAAW,EAGX,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EAGnB,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,mGAAmG;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,yFAAyF;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD;;;GAGG;AACH,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,YAAY,EACV,yBAAyB,EACzB,aAAa,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ED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
// ---------------------------------------------------------------------------
|
|
2
2
|
// Public API — prefix-safe-json
|
|
3
|
+
//
|
|
4
|
+
// Every exported function/class carries its own `@public (Stable)` or
|
|
5
|
+
// `@public (Experimental)` classification directly above its own
|
|
6
|
+
// declaration - never one comment shared across multiple export
|
|
7
|
+
// statements, since a JSDoc/TSDoc comment attaches only to the single
|
|
8
|
+
// declaration immediately following it, not to every statement a reader's
|
|
9
|
+
// eye groups it with visually. Type-only exports grouped under a
|
|
10
|
+
// `// <Section> API` comment inherit the classification of the
|
|
11
|
+
// function/class they are declared alongside in that same section, unless
|
|
12
|
+
// individually annotated otherwise.
|
|
3
13
|
// ---------------------------------------------------------------------------
|
|
4
14
|
/**
|
|
5
15
|
* @public (Stable)
|
|
6
16
|
* Creates a new Incremental JSON Parser instance.
|
|
7
17
|
*/
|
|
8
18
|
export { createParser } from "./parser.js";
|
|
19
|
+
/** @public (Stable) Default resource limits applied when none are supplied to `createParser()`. */
|
|
9
20
|
export { DEFAULT_LIMITS } from "./limits.js";
|
|
21
|
+
/** @public (Stable) Machine-readable parser diagnostic codes (see `Diagnostic.code`). */
|
|
10
22
|
export { DiagnosticCode } from "./diagnostics/codes.js";
|
|
11
23
|
// Coordinator API
|
|
12
24
|
/**
|
|
@@ -14,6 +26,13 @@ export { DiagnosticCode } from "./diagnostics/codes.js";
|
|
|
14
26
|
* Creates a stream coordinator for mapping overlapping multi-tool streams.
|
|
15
27
|
*/
|
|
16
28
|
export { createToolCallStreamCoordinator } from "./coordinator/coordinator.js";
|
|
29
|
+
/**
|
|
30
|
+
* @public (Stable)
|
|
31
|
+
* Diagnostic code a custom `ProviderStreamAdapter` can emit (as a
|
|
32
|
+
* stream-wide `provider_diagnostic`, no `callRef`) to signal a
|
|
33
|
+
* content-safety/policy termination - the gate matches on this exact code
|
|
34
|
+
* to report `reason: "content_filtered"`. See docs/EXECUTION_GATE.md.
|
|
35
|
+
*/
|
|
17
36
|
export { CONTENT_FILTERED_DIAGNOSTIC_CODE } from "./coordinator/diagnostic-codes.js";
|
|
18
37
|
// Execution Safety Gate API
|
|
19
38
|
/**
|
|
@@ -33,13 +52,74 @@ export { createToolCallExecutionGate } from "./gate/gate.js";
|
|
|
33
52
|
export { createAiSdkExecutionGuard } from "./guard/ai-sdk.js";
|
|
34
53
|
/**
|
|
35
54
|
* @public (Experimental)
|
|
36
|
-
*
|
|
37
|
-
*
|
|
55
|
+
* Removes every AI SDK-invoked callback field capable of running caller code
|
|
56
|
+
* before this library's gate reaches a decision - `execute`,
|
|
57
|
+
* `onInputStart`, `onInputDelta`, and `onInputAvailable` (verified directly
|
|
58
|
+
* against `ai@5`/`ai@6`/`ai@7`'s own real source that all three fire
|
|
59
|
+
* unconditionally, with zero reference to `needsApproval` or approval
|
|
60
|
+
* status - `needsApproval: true` alone does not stop them). Also forces
|
|
61
|
+
* `needsApproval: true`, which still closes the `execute` gap on `ai@6`+ via
|
|
62
|
+
* the SDK's own approval mechanism. Also rejects two other classes of
|
|
63
|
+
* pre-decision caller code this library cannot neutralize by stripping
|
|
64
|
+
* fields: a function-valued `description` (`ai@7`+ invokes it during tool
|
|
65
|
+
* preparation, before the model call begins), and any provider tool shape
|
|
66
|
+
* whose real execution location cannot be verified from the object alone -
|
|
67
|
+
* `isProviderExecuted: true`, `ai@6`'s discriminator-less `{ type:
|
|
68
|
+
* "provider" }`, and `ai@5`'s discriminator-less `{ type: "provider-defined"
|
|
69
|
+
* }` are all rejected; `ai@7`'s `{ type: "provider", isProviderExecuted:
|
|
70
|
+
* false }` (verified to have no `execute` field at all, so the SDK can never
|
|
71
|
+
* auto-run it) is accepted. Real execution stays exactly where it already
|
|
72
|
+
* was: driven manually from `guard.finish().decisions`. See the function's
|
|
73
|
+
* own doc comment for the exact, precisely-scoped guarantee, its real
|
|
74
|
+
* limits, and the explicit non-sandbox threat-model boundary around
|
|
75
|
+
* caller-provided schema/validation code, and
|
|
76
|
+
* `docs/EXECUTION_GATE.md#execution-ownership-tool-resulttool-error-as-evidence`.
|
|
77
|
+
*/
|
|
78
|
+
export { createAiSdkExecutionLock } from "./guard/ai-sdk-execution-lock.js";
|
|
79
|
+
// Provider adapters for various LLM network shapes. Each is independently
|
|
80
|
+
// classified below - see docs/COMPATIBILITY.md for what "verified" means
|
|
81
|
+
// per adapter (a specific tested SDK version vs. a documented wire shape).
|
|
82
|
+
// All six may change if the upstream API/SDK shape they target changes.
|
|
83
|
+
/**
|
|
84
|
+
* @public (Experimental)
|
|
85
|
+
* OpenAI Chat Completions (legacy `function_call`) and Responses API
|
|
86
|
+
* streaming tool-call shape.
|
|
38
87
|
*/
|
|
39
88
|
export { OpenAIStreamAdapter } from "./providers/openai.js";
|
|
89
|
+
/**
|
|
90
|
+
* @public (Experimental)
|
|
91
|
+
* Generic OpenAI-compatible `choices[].delta.tool_calls[]` streaming
|
|
92
|
+
* shape, shared by OpenAI's current API and most compatible endpoints.
|
|
93
|
+
*/
|
|
40
94
|
export { OpenAICompatibleStreamAdapter } from "./providers/openai-compatible.js";
|
|
95
|
+
/**
|
|
96
|
+
* @public (Experimental)
|
|
97
|
+
* Anthropic Messages API streaming tool-call shape
|
|
98
|
+
* (`content_block_delta` / `input_json_delta`).
|
|
99
|
+
*/
|
|
41
100
|
export { AnthropicStreamAdapter } from "./providers/anthropic.js";
|
|
101
|
+
/**
|
|
102
|
+
* @public (Experimental)
|
|
103
|
+
* Gemini's structured `functionCall` shape. Unlike the other adapters,
|
|
104
|
+
* Gemini delivers function-call arguments as an already-parsed object, not
|
|
105
|
+
* incremental raw JSON text - see docs/COMPATIBILITY.md for what that
|
|
106
|
+
* means for this adapter's guarantees.
|
|
107
|
+
*/
|
|
42
108
|
export { GeminiStreamAdapter } from "./providers/gemini.js";
|
|
109
|
+
/**
|
|
110
|
+
* @public (Experimental)
|
|
111
|
+
* OpenRouter's streaming tool-call shape (a thin extension of the
|
|
112
|
+
* OpenAI-compatible shape above).
|
|
113
|
+
*/
|
|
43
114
|
export { OpenRouterStreamAdapter } from "./providers/openrouter.js";
|
|
115
|
+
/**
|
|
116
|
+
* @public (Experimental)
|
|
117
|
+
* Vercel AI SDK's `fullStream` tool-call part shape
|
|
118
|
+
* (`tool-input-start`/`-delta`/`-end`, `tool-call`, `tool-result`,
|
|
119
|
+
* `tool-error`, `finish`, `error`, `abort`). Verified against `ai@5.0.240`,
|
|
120
|
+
* `ai@6.0.259`, `ai@7.0.70` - see docs/COMPATIBILITY.md. Prefer
|
|
121
|
+
* `createAiSdkExecutionGuard()` (Stable, above) for the common case; use
|
|
122
|
+
* this directly only if you need the adapter instance itself.
|
|
123
|
+
*/
|
|
44
124
|
export { AiSdkStreamAdapter } from "./providers/ai-sdk.js";
|
|
45
125
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,gCAAgC;AAChC,8EAA8E;AAE9E;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAiC3C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,kBAAkB;AAClB;;;GAGG;AACH,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAS/E,OAAO,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AAErF,4BAA4B;AAC5B;;;;;GAKG;AACH,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAY7D,8BAA8B;AAC9B;;;;;GAKG;AACH,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,gCAAgC;AAChC,EAAE;AACF,sEAAsE;AAC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6 +22,11 @@ interface AiSdkToolCallPart {
|
|
|
22
22
|
toolCallId?: string;
|
|
23
23
|
toolName?: string;
|
|
24
24
|
}
|
|
25
|
+
interface AiSdkToolResultPart {
|
|
26
|
+
type: "tool-result";
|
|
27
|
+
toolCallId?: string;
|
|
28
|
+
toolName?: string;
|
|
29
|
+
}
|
|
25
30
|
interface AiSdkToolErrorPart {
|
|
26
31
|
type: "tool-error";
|
|
27
32
|
toolCallId?: string;
|
|
@@ -40,7 +45,7 @@ interface AiSdkAbortPart {
|
|
|
40
45
|
type: "abort";
|
|
41
46
|
reason?: string;
|
|
42
47
|
}
|
|
43
|
-
export type AiSdkStreamPart = AiSdkToolInputStartPart | AiSdkToolInputDeltaPart | AiSdkToolInputEndPart | AiSdkToolCallPart | AiSdkToolErrorPart | AiSdkFinishPart | AiSdkErrorPart | AiSdkAbortPart | {
|
|
48
|
+
export type AiSdkStreamPart = AiSdkToolInputStartPart | AiSdkToolInputDeltaPart | AiSdkToolInputEndPart | AiSdkToolCallPart | AiSdkToolResultPart | AiSdkToolErrorPart | AiSdkFinishPart | AiSdkErrorPart | AiSdkAbortPart | {
|
|
44
49
|
type: string;
|
|
45
50
|
[key: string]: unknown;
|
|
46
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-sdk.d.ts","sourceRoot":"","sources":["../../src/providers/ai-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACtG,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"ai-sdk.d.ts","sourceRoot":"","sources":["../../src/providers/ai-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACtG,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAqBrD,UAAU,u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mBAAmB,GACnB,kBAAkB,GAClB,eAAe,GACf,cAAc,GACd,cAAc,GACd;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AA4B7C,qBAAa,kBAAmB,YAAW,qBAAqB,CAAC,OAAO,CAAC;IACvE,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAY;IAC3C,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ,CAAS;IAEzB,IAAI,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,yBAAyB,EAAE;IA6M7D,MAAM,CAAC,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,eAAe,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,yBAAyB,EAAE;CAW3G"}
|
package/dist/providers/ai-sdk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CONTENT_FILTERED_DIAGNOSTIC_CODE } from "../coordinator/diagnostic-codes.js";
|
|
1
|
+
import { CONTENT_FILTERED_DIAGNOSTIC_CODE, SDK_EXECUTION_OBSERVED_DIAGNOSTIC_CODE, SDK_EXECUTION_ERROR_DIAGNOSTIC_CODE, } from "../coordinator/diagnostic-codes.js";
|
|
2
2
|
function toolPartId(part) {
|
|
3
3
|
// "tool-input-start"/"tool-input-delta" carry `id`; "tool-input-end" is
|
|
4
4
|
// documented with `toolCallId`. Reading both defensively means this
|
|
@@ -101,13 +101,41 @@ export class AiSdkStreamAdapter {
|
|
|
101
101
|
// verbatim from "tool-input-delta" parts above, byte for byte.
|
|
102
102
|
break;
|
|
103
103
|
}
|
|
104
|
+
case "tool-result": {
|
|
105
|
+
// Direct proof the SDK's own tool loop already invoked and completed
|
|
106
|
+
// this call's `execute` callback - see
|
|
107
|
+
// SDK_EXECUTION_OBSERVED_DIAGNOSTIC_CODE's own docs. This adapter
|
|
108
|
+
// never reads `output`/`result`: the point isn't what the SDK's
|
|
109
|
+
// execution produced, only that execution already happened, which
|
|
110
|
+
// must permanently disqualify this call from an `execute` decision
|
|
111
|
+
// here (DefaultToolCallStreamCoordinator.handleProviderDiagnostic
|
|
112
|
+
// acts on this code). An unattributable result (no id at all) still
|
|
113
|
+
// gets reported - just without a callRef, matching "tool-error"
|
|
114
|
+
// below - rather than silently dropped.
|
|
115
|
+
const id = toolPartId(part);
|
|
116
|
+
events.push({
|
|
117
|
+
type: "provider_diagnostic",
|
|
118
|
+
sequence: ++this.sequence,
|
|
119
|
+
provider: this.provider,
|
|
120
|
+
code: SDK_EXECUTION_OBSERVED_DIAGNOSTIC_CODE,
|
|
121
|
+
severity: "error",
|
|
122
|
+
message: `Tool "${part.toolName ?? "unknown"}" was already executed by the AI SDK's own tool loop before this guard reached a decision`,
|
|
123
|
+
...(id !== undefined ? { callRef: { sourceKey: `tool-input:${id}` } } : {}),
|
|
124
|
+
});
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
104
127
|
case "tool-error": {
|
|
128
|
+
// Also proof the SDK's own tool loop already invoked this call's
|
|
129
|
+
// `execute` callback - it threw, but that does not prove no partial
|
|
130
|
+
// irreversible side effect occurred first. Deliberately the same
|
|
131
|
+
// fail-closed treatment as "tool-result" above: see
|
|
132
|
+
// SDK_EXECUTION_ERROR_DIAGNOSTIC_CODE's own docs.
|
|
105
133
|
const id = toolPartId(part);
|
|
106
134
|
events.push({
|
|
107
135
|
type: "provider_diagnostic",
|
|
108
136
|
sequence: ++this.sequence,
|
|
109
137
|
provider: this.provider,
|
|
110
|
-
code:
|
|
138
|
+
code: SDK_EXECUTION_ERROR_DIAGNOSTIC_CODE,
|
|
111
139
|
severity: "error",
|
|
112
140
|
message: `Tool "${part.toolName ?? "unknown"}" reported an error: ${stringifyError(part.error)}`,
|
|
113
141
|
...(id !== undefined ? { callRef: { sourceKey: `tool-input:${id}` } } : {}),
|
|
@@ -187,8 +215,8 @@ export class AiSdkStreamAdapter {
|
|
|
187
215
|
this.finished = true;
|
|
188
216
|
break;
|
|
189
217
|
}
|
|
190
|
-
// Unrelated part types (text-delta, reasoning-delta,
|
|
191
|
-
// start
|
|
218
|
+
// Unrelated part types (text-delta, reasoning-delta, start,
|
|
219
|
+
// start-step, finish-step, etc.) carry no tool-argument or
|
|
192
220
|
// stream-termination information for our purposes and must not crash
|
|
193
221
|
// the adapter.
|
|
194
222
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-sdk.js","sourceRoot":"","sources":["../../src/providers/ai-sdk.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"ai-sdk.js","sourceRoot":"","sources":["../../src/providers/ai-sdk.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gCAAgC,EAChC,sCAAsC,EACtC,mCAAmC,GACpC,MAAM,oCAAoC,CAAC;AAuF5C,SAAS,UAAU,CAAC,IAA0C;IAC5D,wEAAwE;IACxE,oEAAoE;IACpE,0EAA0E;IAC1E,8DAA8D;IAC9D,OAAO,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC;AACpC,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IACE,KAAK;QACL,OAAO,KAAK,KAAK,QAAQ;QACzB,SAAS,IAAI,KAAK;QAClB,OAAQ,KAA8B,CAAC,OAAO,KAAK,QAAQ,EAC3D,CAAC;QACD,OAAQ,KAA6B,CAAC,OAAO,CAAC;IAChD,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,OAAO,kBAAkB;IACp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|
|
2
2
|
"name": "prefix-safe-json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Fail-closed execution integrity for streamed LLM tool calls — reject truncated or unconfirmed arguments before side effects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"json",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"license": "MIT OR Apache-2.0",
|
|
19
19
|
"type": "module",
|
|
20
|
+
"sideEffects": false,
|
|
20
21
|
"repository": {
|
|
21
22
|
"type": "git",
|
|
22
23
|
"url": "git+https://github.com/canblmz1/prefix-safe-json.git"
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"README.md"
|
|
41
42
|
],
|
|
42
43
|
"engines": {
|
|
43
|
-
"node": ">=
|
|
44
|
+
"node": ">=22.0.0"
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
47
|
"ajv": "^8.20.0"
|
|
@@ -72,7 +73,10 @@
|
|
|
72
73
|
"@stryker-mutator/vitest-runner": "^9.6.1",
|
|
73
74
|
"@types/clarinet": "^0.12.3",
|
|
74
75
|
"@types/node": "^26.1.2",
|
|
75
|
-
"@vitest/coverage-v8": "^2.
|
|
76
|
+
"@vitest/coverage-v8": "^3.2.6",
|
|
77
|
+
"ai-v5": "npm:ai@5.0.244",
|
|
78
|
+
"ai-v6": "npm:ai@6.0.264",
|
|
79
|
+
"ai-v7": "npm:ai@7.0.77",
|
|
76
80
|
"clarinet": "^0.12.6",
|
|
77
81
|
"eslint": "^9.8.0",
|
|
78
82
|
"fast-check": "^4.9.0",
|
|
@@ -82,6 +86,14 @@
|
|
|
82
86
|
"tsx": "^4.16.0",
|
|
83
87
|
"typescript": "^5.5.0",
|
|
84
88
|
"typescript-eslint": "^8.0.0",
|
|
85
|
-
"vitest": "^2.
|
|
89
|
+
"vitest": "^3.2.6"
|
|
90
|
+
},
|
|
91
|
+
"pnpm": {
|
|
92
|
+
"overrides": {
|
|
93
|
+
"qs": "^6.15.2",
|
|
94
|
+
"vite": "^6.4.3",
|
|
95
|
+
"nanoid": "^3.3.18",
|
|
96
|
+
"undici": "^7.28.0"
|
|
97
|
+
}
|
|
86
98
|
}
|
|
87
99
|
}
|