prefix-safe-json 0.4.4 → 0.4.5
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/dist/providers/anthropic.d.ts +1 -0
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +89 -8
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/gemini.d.ts +122 -0
- package/dist/providers/gemini.d.ts.map +1 -1
- package/dist/providers/gemini.js +442 -25
- package/dist/providers/gemini.js.map +1 -1
- package/dist/providers/openai-compatible.d.ts +47 -1
- package/dist/providers/openai-compatible.d.ts.map +1 -1
- package/dist/providers/openai-compatible.js +381 -84
- package/dist/providers/openai-compatible.js.map +1 -1
- package/dist/providers/openai.d.ts +7 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +459 -67
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/openrouter.d.ts.map +1 -1
- package/dist/providers/openrouter.js +14 -2
- package/dist/providers/openrouter.js.map +1 -1
- package/package.json +4 -1
|
@@ -1,11 +1,125 @@
|
|
|
1
|
-
import { DUPLICATE_CHOICE_INDEX_DIAGNOSTIC_CODE, INVALID_CHOICE_INDEX_DIAGNOSTIC_CODE, } from "../coordinator/diagnostic-codes.js";
|
|
1
|
+
import { DUPLICATE_CHOICE_INDEX_DIAGNOSTIC_CODE, INVALID_CHOICE_INDEX_DIAGNOSTIC_CODE, TOOL_ARGUMENTS_AFTER_END_DIAGNOSTIC_CODE, } from "../coordinator/diagnostic-codes.js";
|
|
2
|
+
// Reason values a choice's own finish_reason can map to, ordered most- to
|
|
3
|
+
// least-restrictive. Used by finish()'s reason aggregation: whichever
|
|
4
|
+
// recorded choice reason (plus any caller-supplied `meta.reason`) ranks
|
|
5
|
+
// EARLIEST here wins as the one stream-wide reason - "complete" only when
|
|
6
|
+
// every recorded reason was itself "complete", so a mix like
|
|
7
|
+
// ["complete", "length"] can never launder into an overall "complete".
|
|
8
|
+
// Directly evidenced for `provider_error`'s own top rank: decide.ts checks
|
|
9
|
+
// `ctx.streamEndReason === "provider_error"` explicitly, before any
|
|
10
|
+
// per-call status branching, unconditionally rejecting every call - the
|
|
11
|
+
// single strongest, most stream-wide-authoritative reason in the existing
|
|
12
|
+
// gate. The remaining relative order (unknown > network_error > length >
|
|
13
|
+
// cancelled > complete) is this adapter's own conservative extension of
|
|
14
|
+
// that same fail-closed philosophy: any reason other than "complete" means
|
|
15
|
+
// at least one choice did not finish normally, so it must dominate.
|
|
16
|
+
const REASON_PRIORITY = [
|
|
17
|
+
"provider_error",
|
|
18
|
+
"unknown",
|
|
19
|
+
"network_error",
|
|
20
|
+
"length",
|
|
21
|
+
"cancelled",
|
|
22
|
+
"complete",
|
|
23
|
+
];
|
|
24
|
+
function mapFinishReason(providerReason) {
|
|
25
|
+
if (providerReason === "stop" || providerReason === "tool_calls")
|
|
26
|
+
return "complete";
|
|
27
|
+
if (providerReason === "length")
|
|
28
|
+
return "length";
|
|
29
|
+
if (providerReason === "cancelled")
|
|
30
|
+
return "cancelled";
|
|
31
|
+
return "unknown";
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Chat-Completions-shaped ("OpenAI-compatible") streaming adapter.
|
|
35
|
+
*
|
|
36
|
+
* Lifecycle contract (`@public (Experimental)` - see docs/COMPATIBILITY.md;
|
|
37
|
+
* this is a deliberate, disclosed lifecycle correction, not an accidental
|
|
38
|
+
* behavior change):
|
|
39
|
+
*
|
|
40
|
+
* choice.finish_reason
|
|
41
|
+
* -> closes ONLY the tool calls belonging to that exact choice index
|
|
42
|
+
* (tool_call_end per open call)
|
|
43
|
+
* -> records that choice's own terminal StreamEndReason
|
|
44
|
+
* -> does NOT emit provider_stream_end
|
|
45
|
+
* -> does NOT set this adapter's global `finished` state
|
|
46
|
+
*
|
|
47
|
+
* finish(meta?)
|
|
48
|
+
* -> the ONE provider_stream_end for this adapter's whole lifetime,
|
|
49
|
+
* closing any call whose own choice never reported a finish_reason
|
|
50
|
+
* at all, with a reason aggregated from every choice-local reason
|
|
51
|
+
* recorded so far plus `meta.reason` (see REASON_PRIORITY above) -
|
|
52
|
+
* call this once the caller has drained the raw provider iterator.
|
|
53
|
+
*
|
|
54
|
+
* Why: a single choice's finish_reason is call-local evidence only. For an
|
|
55
|
+
* ordinary single-choice (the overwhelmingly common, n=1) stream this was
|
|
56
|
+
* previously indistinguishable from the whole provider stream ending, so
|
|
57
|
+
* treating it as such was harmless. For a genuine multi-choice (n>1)
|
|
58
|
+
* stream it is not: this adapter has no visibility into the request's own
|
|
59
|
+
* `n`, and no wire-level signal available to `push()` proves no further,
|
|
60
|
+
* unseen choice can still appear - only the caller's own raw-iterator
|
|
61
|
+
* exhaustion (driving an explicit `finish()` call) can. Previously, the
|
|
62
|
+
* first choice to finish was wrongly treated as ending the entire stream:
|
|
63
|
+
* every OTHER choice's still-tracked calls were force-closed by a single,
|
|
64
|
+
* shared `knownSourceKeys` Set and the stream was declared over via a real
|
|
65
|
+
* `provider_stream_end` - which could make a call belonging to a
|
|
66
|
+
* completely different, still-generating choice genuinely, immediately
|
|
67
|
+
* executable (a real, empirically-confirmed `takeDecision()`-able
|
|
68
|
+
* authority window) purely because an unrelated choice finished first, and
|
|
69
|
+
* separately made a second finishing choice's own, entirely real
|
|
70
|
+
* termination look like corrupt/duplicate post-terminal evidence,
|
|
71
|
+
* poisoning every call in the stream via the coordinator's own
|
|
72
|
+
* EVENT_AFTER_STREAM_END/TERMINAL_REASON_CONFLICT protocol.
|
|
73
|
+
*/
|
|
2
74
|
export class OpenAICompatibleStreamAdapter {
|
|
3
75
|
provider = "openai-compatible";
|
|
4
76
|
sequence = 0;
|
|
5
77
|
// Track full provider coordinates, never the tool index alone.
|
|
6
78
|
startedSourceKeys = new Set();
|
|
7
|
-
//
|
|
8
|
-
|
|
79
|
+
// Choice-scoped: which sourceKeys are currently open (started, not yet
|
|
80
|
+
// closed by their OWN choice's finish_reason) under each choice index.
|
|
81
|
+
// Replaces a single, adapter-wide Set - a choice's finish_reason must
|
|
82
|
+
// close exactly its own entries here, never another choice's.
|
|
83
|
+
openSourceKeysByChoice = new Map();
|
|
84
|
+
// Every choice index that has reported its own finish_reason, and the
|
|
85
|
+
// StreamEndReason it mapped to. Never overwritten once set for a given
|
|
86
|
+
// choice - a second/conflicting finish_reason for the same choice is
|
|
87
|
+
// reported as choice-local post-terminal evidence (see push()), not
|
|
88
|
+
// silently applied over the first. Read by finish() to aggregate one
|
|
89
|
+
// stream-wide reason.
|
|
90
|
+
choiceTerminalReasons = new Map();
|
|
91
|
+
// The same choices' own RAW (pre-normalization) finish_reason strings,
|
|
92
|
+
// keyed identically. Kept separate from choiceTerminalReasons rather than
|
|
93
|
+
// folded into it because this is pure observability data (mirrored onto
|
|
94
|
+
// DecisionEvidence.providerReason - see decide.ts's own doc comment:
|
|
95
|
+
// "never consulted by the decision logic itself"), whereas
|
|
96
|
+
// choiceTerminalReasons drives real aggregation logic. Read by finish()
|
|
97
|
+
// alongside it so the one stream-wide provider_stream_end can carry the
|
|
98
|
+
// specific raw string that produced its aggregated reason instead of
|
|
99
|
+
// silently dropping it.
|
|
100
|
+
choiceTerminalProviderReasons = new Map();
|
|
101
|
+
// Every sourceKey EVER started under a choice index, never cleared (unlike
|
|
102
|
+
// openSourceKeysByChoice, which drops entries the moment their choice
|
|
103
|
+
// closes them). Read only when late tool-call evidence arrives for an
|
|
104
|
+
// already-terminal choice (see push()'s choiceAlreadyTerminal branch): a
|
|
105
|
+
// brand-new tool index injected under a finished choice never gets a
|
|
106
|
+
// coordinator call created for it at all, so a diagnostic attached only
|
|
107
|
+
// to ITS OWN (never-resolvable) sourceKey can never disqualify anything -
|
|
108
|
+
// this lets the adapter instead attach the disqualifying diagnostic to
|
|
109
|
+
// every REAL, already-started call the choice actually has, without
|
|
110
|
+
// parsing choice ownership back out of a sourceKey string.
|
|
111
|
+
allSourceKeysByChoice = new Map();
|
|
112
|
+
// Sticky, never reset: set the moment ANY choice reports a second (or
|
|
113
|
+
// conflicting) finish_reason after already recording one. A well-behaved
|
|
114
|
+
// provider never does this at all - once observed, this stream's
|
|
115
|
+
// protocol can no longer be trusted, so finish()'s aggregated reason is
|
|
116
|
+
// unconditionally forced to "provider_error" (see aggregateTermination())
|
|
117
|
+
// regardless of what any individual choice or the caller's own
|
|
118
|
+
// meta.reason claims. Deliberately NOT scoped to the one violating choice
|
|
119
|
+
// - see BLOCKER 2 in this file's own review history for why a stream-wide
|
|
120
|
+
// fail-closed guarantee, not a per-choice diagnostic, is the correct fix
|
|
121
|
+
// for a duplicated/conflicting CHOICE-level terminal specifically.
|
|
122
|
+
choiceTerminalProtocolViolation = false;
|
|
9
123
|
finished = false;
|
|
10
124
|
push(rawEvent) {
|
|
11
125
|
if (this.finished) {
|
|
@@ -81,99 +195,216 @@ export class OpenAICompatibleStreamAdapter {
|
|
|
81
195
|
}
|
|
82
196
|
continue;
|
|
83
197
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
198
|
+
// Choice-local post-terminal evidence: this exact choice already
|
|
199
|
+
// recorded its own finish_reason. Never merge further tool-call
|
|
200
|
+
// evidence for it as normal (would either silently mutate an
|
|
201
|
+
// already-closed call's value with no record of the anomaly, or
|
|
202
|
+
// let a brand-new tool call start and become tracked/executable
|
|
203
|
+
// under a choice the provider itself already said was done) -
|
|
204
|
+
// raise the same authority-disqualifying diagnostic
|
|
205
|
+
// AiSdkStreamAdapter already uses for materially identical
|
|
206
|
+
// semantics ("argument evidence arrived after the call's end
|
|
207
|
+
// part"), attributed to the specific sourceKey when there is
|
|
208
|
+
// one, so the coordinator resolves it to a real call
|
|
209
|
+
// (handleProviderDiagnostic) or holds it pending
|
|
210
|
+
// (pendingProtocolDiagnostics) for a sourceKey that never
|
|
211
|
+
// actually gets a tool_call_start at all - which is exactly the
|
|
212
|
+
// point: a brand-new call is never created under a finished
|
|
213
|
+
// choice in the first place.
|
|
214
|
+
const choiceAlreadyTerminal = this.choiceTerminalReasons.has(choiceIndex);
|
|
215
|
+
if (choice.delta && Array.isArray(choice.delta.tool_calls) && choice.delta.tool_calls.length > 0) {
|
|
216
|
+
if (choiceAlreadyTerminal) {
|
|
217
|
+
// Choice-local revocation: ANY meaningful tool-call evidence
|
|
218
|
+
// for an already-terminal choice invalidates every already-
|
|
219
|
+
// known call in that exact choice - not merely the specific
|
|
220
|
+
// sourceKey this delta happens to reference. A brand-new tool
|
|
221
|
+
// index never gets a coordinator call created for it at all
|
|
222
|
+
// (see the non-terminal branch below), so a diagnostic against
|
|
223
|
+
// ITS OWN sourceKey alone could sit forever unresolved in the
|
|
224
|
+
// coordinator's pendingProtocolDiagnostics and disqualify
|
|
225
|
+
// nothing - attaching to every sourceKey this adapter already
|
|
226
|
+
// knows started under the choice is what actually reaches
|
|
227
|
+
// real, coordinator-tracked calls. Scoped strictly to
|
|
228
|
+
// allSourceKeysByChoice.get(choiceIndex): sibling choices are
|
|
229
|
+
// never touched, and nothing here parses a choice index back
|
|
230
|
+
// out of a sourceKey string.
|
|
231
|
+
const known = this.allSourceKeysByChoice.get(choiceIndex);
|
|
232
|
+
if (known && known.size > 0) {
|
|
233
|
+
for (const sourceKey of known) {
|
|
234
|
+
events.push({
|
|
235
|
+
type: "provider_diagnostic",
|
|
236
|
+
sequence: ++this.sequence,
|
|
237
|
+
provider: this.provider,
|
|
238
|
+
callRef: { sourceKey },
|
|
239
|
+
code: TOOL_ARGUMENTS_AFTER_END_DIAGNOSTIC_CODE,
|
|
240
|
+
severity: "error",
|
|
241
|
+
message: `Tool call evidence for choice ${choiceIndex} arrived after that choice's own finish_reason; call ${sourceKey} is disqualified`,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
110
244
|
}
|
|
111
245
|
else {
|
|
112
|
-
//
|
|
113
|
-
|
|
246
|
+
// No call was ever tracked for this choice at all (e.g. a
|
|
247
|
+
// text-only choice that later receives a spurious tool_calls
|
|
248
|
+
// delta) - nothing exists yet to disqualify, but the attempt
|
|
249
|
+
// itself is still worth a forensic record against its own
|
|
250
|
+
// (never-resolvable) sourceKey.
|
|
251
|
+
for (const tc of choice.delta.tool_calls) {
|
|
252
|
+
if (!Number.isInteger(tc.index) || tc.index < 0)
|
|
253
|
+
continue;
|
|
254
|
+
events.push({
|
|
255
|
+
type: "provider_diagnostic",
|
|
256
|
+
sequence: ++this.sequence,
|
|
257
|
+
provider: this.provider,
|
|
258
|
+
callRef: { sourceKey: `choice:${choiceIndex}/tool-index:${tc.index}` },
|
|
259
|
+
code: TOOL_ARGUMENTS_AFTER_END_DIAGNOSTIC_CODE,
|
|
260
|
+
severity: "error",
|
|
261
|
+
message: `Tool call evidence for choice ${choiceIndex} arrived after that choice's own finish_reason`,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
// Deliberately does not fall through to normal start/delta
|
|
266
|
+
// processing below - a call is never started or mutated under
|
|
267
|
+
// an already-terminal choice.
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
for (const tc of choice.delta.tool_calls) {
|
|
271
|
+
if (!Number.isInteger(tc.index) || tc.index < 0) {
|
|
272
|
+
events.push({
|
|
273
|
+
type: "provider_diagnostic",
|
|
274
|
+
sequence: ++this.sequence,
|
|
275
|
+
provider: this.provider,
|
|
276
|
+
code: "E_PROVIDER_EVENT_MALFORMED",
|
|
277
|
+
severity: "error",
|
|
278
|
+
message: "tool_call index is missing or invalid",
|
|
279
|
+
});
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
const sourceKey = `choice:${choiceIndex}/tool-index:${tc.index}`;
|
|
283
|
+
let openSet = this.openSourceKeysByChoice.get(choiceIndex);
|
|
284
|
+
if (!openSet) {
|
|
285
|
+
openSet = new Set();
|
|
286
|
+
this.openSourceKeysByChoice.set(choiceIndex, openSet);
|
|
287
|
+
}
|
|
288
|
+
openSet.add(sourceKey);
|
|
289
|
+
let knownSet = this.allSourceKeysByChoice.get(choiceIndex);
|
|
290
|
+
if (!knownSet) {
|
|
291
|
+
knownSet = new Set();
|
|
292
|
+
this.allSourceKeysByChoice.set(choiceIndex, knownSet);
|
|
293
|
+
}
|
|
294
|
+
knownSet.add(sourceKey);
|
|
295
|
+
if (!this.startedSourceKeys.has(sourceKey)) {
|
|
296
|
+
this.startedSourceKeys.add(sourceKey);
|
|
114
297
|
events.push({
|
|
115
|
-
type: "
|
|
298
|
+
type: "tool_call_start",
|
|
116
299
|
sequence: ++this.sequence,
|
|
117
300
|
provider: this.provider,
|
|
118
301
|
callRef: { sourceKey },
|
|
119
|
-
toolCallId: tc.id,
|
|
120
302
|
toolIndex: tc.index,
|
|
303
|
+
toolCallId: tc.id,
|
|
304
|
+
name: tc.function?.name,
|
|
121
305
|
});
|
|
122
306
|
}
|
|
123
|
-
|
|
124
|
-
|
|
307
|
+
else {
|
|
308
|
+
// Send identity if ID provided late
|
|
309
|
+
if (tc.id !== undefined) {
|
|
310
|
+
events.push({
|
|
311
|
+
type: "tool_call_identity",
|
|
312
|
+
sequence: ++this.sequence,
|
|
313
|
+
provider: this.provider,
|
|
314
|
+
callRef: { sourceKey },
|
|
315
|
+
toolCallId: tc.id,
|
|
316
|
+
toolIndex: tc.index,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
// Name delta
|
|
320
|
+
if (tc.function?.name) {
|
|
321
|
+
events.push({
|
|
322
|
+
type: "tool_call_name_delta",
|
|
323
|
+
sequence: ++this.sequence,
|
|
324
|
+
provider: this.provider,
|
|
325
|
+
callRef: { sourceKey },
|
|
326
|
+
delta: tc.function.name,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
// Arguments delta
|
|
331
|
+
if (tc.function?.arguments) {
|
|
125
332
|
events.push({
|
|
126
|
-
type: "
|
|
333
|
+
type: "tool_call_arguments_delta",
|
|
127
334
|
sequence: ++this.sequence,
|
|
128
335
|
provider: this.provider,
|
|
129
336
|
callRef: { sourceKey },
|
|
130
|
-
delta: tc.function.
|
|
337
|
+
delta: tc.function.arguments,
|
|
131
338
|
});
|
|
132
339
|
}
|
|
133
340
|
}
|
|
134
|
-
// Arguments delta
|
|
135
|
-
if (tc.function?.arguments) {
|
|
136
|
-
events.push({
|
|
137
|
-
type: "tool_call_arguments_delta",
|
|
138
|
-
sequence: ++this.sequence,
|
|
139
|
-
provider: this.provider,
|
|
140
|
-
callRef: { sourceKey },
|
|
141
|
-
delta: tc.function.arguments,
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
341
|
}
|
|
145
342
|
}
|
|
146
343
|
if (choice.finish_reason != null) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
344
|
+
if (choiceAlreadyTerminal) {
|
|
345
|
+
// A second, duplicate, or conflicting finish_reason for a
|
|
346
|
+
// choice that already recorded one. Deliberately recorded
|
|
347
|
+
// (never silently overwritten - choiceTerminalReasons keeps
|
|
348
|
+
// its first-recorded value - and never silently ignored), but
|
|
349
|
+
// NOT via TOOL_ARGUMENTS_AFTER_END: this is not tool-argument
|
|
350
|
+
// evidence at all, it is a second CHOICE-terminal marker, a
|
|
351
|
+
// materially different condition that code does not describe.
|
|
352
|
+
// No existing coordinator diagnostic code represents "a
|
|
353
|
+
// duplicate/conflicting CHOICE-level terminal" either (they are
|
|
354
|
+
// all either call-scoped - e.g. DUPLICATE_TOOL_END, which is
|
|
355
|
+
// specifically about a repeated end for the SAME CALL, not a
|
|
356
|
+
// choice that may have zero calls - or stream-wide-provider_
|
|
357
|
+
// stream_end-scoped - e.g. TERMINAL_REASON_CONFLICT/
|
|
358
|
+
// EVENT_AFTER_STREAM_END, which describe the coordinator's own
|
|
359
|
+
// handleStreamEnd() mechanic on a second provider_stream_end,
|
|
360
|
+
// an event this adapter deliberately never emits from a single
|
|
361
|
+
// choice). Inventing a new one was deliberately avoided.
|
|
362
|
+
// Instead: record the fact locally (the sticky
|
|
363
|
+
// choiceTerminalProtocolViolation flag, never reset) and let
|
|
364
|
+
// finish()'s aggregation guarantee the fail-closed outcome -
|
|
365
|
+
// see aggregateTermination() below, which forces the ONE
|
|
366
|
+
// stream-wide reason to "provider_error" once this flag is
|
|
367
|
+
// set, regardless of any individual choice's or the caller's
|
|
368
|
+
// own claimed reason. This diagnostic itself is therefore pure
|
|
369
|
+
// observability (not a member of AUTHORITY_PROTOCOL_VIOLATION_
|
|
370
|
+
// CODES, not imported from the shared coordinator/diagnostic-
|
|
371
|
+
// codes.ts registry - mirrors the existing adapter-local
|
|
372
|
+
// "W_EVENT_AFTER_STREAM_END" pattern elsewhere in this file):
|
|
373
|
+
// the actual fail-closed guarantee comes from the aggregate
|
|
374
|
+
// reason, not from this event being specially recognized.
|
|
375
|
+
this.choiceTerminalProtocolViolation = true;
|
|
159
376
|
events.push({
|
|
160
|
-
type: "
|
|
377
|
+
type: "provider_diagnostic",
|
|
161
378
|
sequence: ++this.sequence,
|
|
162
379
|
provider: this.provider,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
380
|
+
code: "E_CHOICE_TERMINAL_PROTOCOL_VIOLATION",
|
|
381
|
+
severity: "error",
|
|
382
|
+
message: `choice ${choiceIndex} reported a second finish_reason ("${choice.finish_reason}") after already terminating with ("${this.choiceTerminalProviderReasons.get(choiceIndex)}") - the whole stream is now fail-closed`,
|
|
166
383
|
});
|
|
167
384
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
385
|
+
else {
|
|
386
|
+
const reason = mapFinishReason(choice.finish_reason);
|
|
387
|
+
this.choiceTerminalReasons.set(choiceIndex, reason);
|
|
388
|
+
this.choiceTerminalProviderReasons.set(choiceIndex, choice.finish_reason);
|
|
389
|
+
const openSet = this.openSourceKeysByChoice.get(choiceIndex);
|
|
390
|
+
if (openSet) {
|
|
391
|
+
for (const sourceKey of openSet.values()) {
|
|
392
|
+
events.push({
|
|
393
|
+
type: "tool_call_end",
|
|
394
|
+
sequence: ++this.sequence,
|
|
395
|
+
provider: this.provider,
|
|
396
|
+
callRef: { sourceKey },
|
|
397
|
+
reason,
|
|
398
|
+
providerReason: choice.finish_reason,
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
openSet.clear();
|
|
402
|
+
}
|
|
403
|
+
// No provider_stream_end here, and `this.finished` stays
|
|
404
|
+
// false: this choice finishing is not, by itself, proof the
|
|
405
|
+
// whole provider stream (which may still have other choices
|
|
406
|
+
// actively generating) has ended. See finish().
|
|
407
|
+
}
|
|
177
408
|
}
|
|
178
409
|
}
|
|
179
410
|
}
|
|
@@ -184,25 +415,91 @@ export class OpenAICompatibleStreamAdapter {
|
|
|
184
415
|
return [];
|
|
185
416
|
this.finished = true;
|
|
186
417
|
const events = [];
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
418
|
+
// Close any call whose own choice never got a chance to report its own
|
|
419
|
+
// finish_reason at all before the caller's raw iterator ended.
|
|
420
|
+
for (const openSet of this.openSourceKeysByChoice.values()) {
|
|
421
|
+
for (const sourceKey of openSet.values()) {
|
|
422
|
+
events.push({
|
|
423
|
+
type: "tool_call_end",
|
|
424
|
+
sequence: ++this.sequence,
|
|
425
|
+
provider: this.provider,
|
|
426
|
+
callRef: { sourceKey },
|
|
427
|
+
reason: meta?.reason ?? "unknown",
|
|
428
|
+
providerReason: meta?.providerReason,
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
openSet.clear();
|
|
196
432
|
}
|
|
197
|
-
this.
|
|
433
|
+
const { reason, providerReason } = this.aggregateTermination(meta?.reason, meta?.providerReason);
|
|
198
434
|
events.push({
|
|
199
435
|
type: "provider_stream_end",
|
|
200
436
|
sequence: ++this.sequence,
|
|
201
437
|
provider: this.provider,
|
|
202
|
-
reason
|
|
203
|
-
providerReason
|
|
438
|
+
reason,
|
|
439
|
+
providerReason,
|
|
204
440
|
});
|
|
205
441
|
return events;
|
|
206
442
|
}
|
|
443
|
+
// One stream-wide StreamEndReason from every choice-local reason
|
|
444
|
+
// recorded so far, plus any caller-supplied override - "complete" only
|
|
445
|
+
// if every single one of them was "complete". See REASON_PRIORITY.
|
|
446
|
+
//
|
|
447
|
+
// Paired with it: the raw providerReason string FROM WHICHEVER candidate
|
|
448
|
+
// actually won that aggregation. The caller's own meta.providerReason is
|
|
449
|
+
// used only when meta.reason is itself STRICTLY worse (a lower
|
|
450
|
+
// REASON_PRIORITY index) than every recorded choice reason - e.g.
|
|
451
|
+
// OpenRouterStreamAdapter's top-level-error shortcut, which calls
|
|
452
|
+
// finish({reason:"provider_error", providerReason:"error"}) with no
|
|
453
|
+
// choice having reported anything yet. A tie, or a less-severe caller
|
|
454
|
+
// reason, keeps the specific choice-level raw string (e.g. "tool_calls")
|
|
455
|
+
// instead of discarding it in favor of nothing - an ordinary
|
|
456
|
+
// finish({reason:"complete"}) call from a drained raw iterator (or the
|
|
457
|
+
// provider-envelopes conformance harness) commonly carries no
|
|
458
|
+
// providerReason of its own at all, and dropping the one real, specific
|
|
459
|
+
// string this adapter actually observed would be a pure loss of already
|
|
460
|
+
//-available diagnostic fidelity, not a safety property: providerReason
|
|
461
|
+
// is observability-only, never consulted by decideExecution() itself
|
|
462
|
+
// (see decide.ts's own doc comment on DecisionEvidence.providerReason).
|
|
463
|
+
aggregateTermination(callerReason, callerProviderReason) {
|
|
464
|
+
// A duplicated/conflicting CHOICE-level terminal was observed at some
|
|
465
|
+
// point during push() (see the choiceAlreadyTerminal branch of
|
|
466
|
+
// choice.finish_reason handling above). Unconditionally wins over
|
|
467
|
+
// every other candidate below, INCLUDING an explicit caller-supplied
|
|
468
|
+
// "complete" - a caller draining a raw iterator that already delivered
|
|
469
|
+
// a protocol-violating duplicate terminal has no way to know that
|
|
470
|
+
// violation occurred and must not be able to launder it away.
|
|
471
|
+
// "provider_error" specifically (not just any low-priority reason)
|
|
472
|
+
// because decide.ts's decision table checks
|
|
473
|
+
// `ctx.streamEndReason === "provider_error"` unconditionally, before
|
|
474
|
+
// any per-call status branching (see decide.ts's own file-header
|
|
475
|
+
// comment) - the one reason value guaranteed to reject every call in
|
|
476
|
+
// this stream regardless of how cleanly any individual call's own
|
|
477
|
+
// evidence otherwise looks.
|
|
478
|
+
if (this.choiceTerminalProtocolViolation) {
|
|
479
|
+
return { reason: "provider_error", providerReason: "choice_terminal_protocol_violation" };
|
|
480
|
+
}
|
|
481
|
+
let worst;
|
|
482
|
+
let worstRank = Infinity;
|
|
483
|
+
let worstProviderReason;
|
|
484
|
+
for (const [choiceIndex, candidate] of this.choiceTerminalReasons.entries()) {
|
|
485
|
+
const rank = REASON_PRIORITY.indexOf(candidate);
|
|
486
|
+
if (rank !== -1 && rank < worstRank) {
|
|
487
|
+
worst = candidate;
|
|
488
|
+
worstRank = rank;
|
|
489
|
+
worstProviderReason = this.choiceTerminalProviderReasons.get(choiceIndex);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
if (callerReason !== undefined) {
|
|
493
|
+
const rank = REASON_PRIORITY.indexOf(callerReason);
|
|
494
|
+
if (rank !== -1 && rank < worstRank) {
|
|
495
|
+
worst = callerReason;
|
|
496
|
+
worstRank = rank;
|
|
497
|
+
worstProviderReason = callerProviderReason;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
if (worst === undefined)
|
|
501
|
+
return { reason: "unknown", providerReason: callerProviderReason };
|
|
502
|
+
return { reason: worst, providerReason: worstProviderReason };
|
|
503
|
+
}
|
|
207
504
|
}
|
|
208
505
|
//# sourceMappingURL=openai-compatible.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-compatible.js","sourceRoot":"","sources":["../../src/providers/openai-compatible.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,sCAAsC,EACtC,oCAAoC,GACrC,MAAM,oCAAoC,CAAC;AAuB5C,MAAM,OAAO,6BAA6B;IAC/B,QAAQ,GAAiB,mBAAmB,CAAC;IAC9C,QAAQ,GAAG,CAAC,CAAC;IAErB,+DAA+D;IACvD,iBAAiB,GAAgB,IAAI,GAAG,EAAE,CAAC;IACnD,iDAAiD;IACzC,eAAe,GAAgB,IAAI,GAAG,EAAE,CAAC;IAEzC,QAAQ,GAAG,KAAK,CAAC;IAEzB,IAAI,CAAC,QAAiB;QACpB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,OAAO,CAAC;oBACN,IAAI,EAAE,qBAAqB;oBAC3B,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ;oBACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,IAAI,EAAE,0BAA0B;oBAChC,QAAQ,EAAE,SAAS;oBACnB,OAAO,EAAE,sCAAsC;iBAChD,CAAC,CAAC;QACL,CAAC;QAED,MAAM,MAAM,GAAgC,EAAE,CAAC;QAE/C,iBAAiB;QACjB,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC9C,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,qBAAqB;gBAC3B,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ;gBACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,IAAI,EAAE,4BAA4B;gBAClC,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,4BAA4B;aACtC,CAAC,CAAC;YACH,OAAO,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CAAC,SAAS,CAAC,CAAC;YAChD,IAAI,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,GAAG,SAAS,EAAE,CAAC;gBACpC,KAAK,GAAG,SAAS,CAAC;gBAClB,SAAS,GAAG,IAAI,CAAC;gBACjB,mBAAmB,GAAG,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YAC5E,CAAC;QACH,CAAC;QAED,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAC/B,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YACnD,IAAI,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,GAAG,SAAS,EAAE,CAAC;gBACpC,KAAK,GAAG,YAAY,CAAC;gBACrB,SAAS,GAAG,IAAI,CAAC;gBACjB,mBAAmB,GAAG,oBAAoB,CAAC;YAC7C,CAAC;QACH,CAAC;QAED,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,oBAAoB,EAAE,CAAC;QAC5F,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAC;IAChE,CAAC;CACF"}
|
|
@@ -5,6 +5,7 @@ interface OpenAIFunctionCallDelta {
|
|
|
5
5
|
arguments?: string;
|
|
6
6
|
}
|
|
7
7
|
interface OpenAIChoice {
|
|
8
|
+
index?: number;
|
|
8
9
|
delta?: {
|
|
9
10
|
function_call?: OpenAIFunctionCallDelta;
|
|
10
11
|
tool_calls?: unknown;
|
|
@@ -40,16 +41,21 @@ export declare class OpenAIStreamAdapter implements ProviderStreamAdapter<unknow
|
|
|
40
41
|
readonly provider: ProviderName;
|
|
41
42
|
private sequence;
|
|
42
43
|
private compatibleAdapter;
|
|
44
|
+
private hasCompatibleToolCalls;
|
|
43
45
|
private hasLegacyFunctionCall;
|
|
44
|
-
private
|
|
46
|
+
private legacyChoiceOpen;
|
|
47
|
+
private legacyChoiceTerminalReasons;
|
|
48
|
+
private legacyChoiceTerminalProviderReasons;
|
|
45
49
|
private accumulatedArguments;
|
|
46
50
|
private receivedDeltas;
|
|
51
|
+
private doneOutputItemIds;
|
|
47
52
|
private finished;
|
|
48
53
|
push(rawEvent: unknown): readonly NormalizedToolStreamEvent[];
|
|
49
54
|
finish(meta?: {
|
|
50
55
|
reason?: StreamEndReason;
|
|
51
56
|
providerReason?: string;
|
|
52
57
|
}): readonly NormalizedToolStreamEvent[];
|
|
58
|
+
private aggregateLegacyTermination;
|
|
53
59
|
}
|
|
54
60
|
export {};
|
|
55
61
|
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.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":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACtG,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAUrD,UAAU,uBAAuB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,YAAY;IAIpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE;QACN,aAAa,CAAC,EAAE,uBAAuB,CAAC;QACxC,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB,CAAC;IACF,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAyBD,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB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