@cortexkit/opencode-magic-context 0.49.98 → 0.49.100
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/auto-search-worker.js +3 -3
- package/dist/chunk-embedding-write-worker.js +1 -1
- package/dist/{context-0ae81pg4.js → context-k2tdh146.js} +293 -32
- package/dist/{embedding-backfill-7terr34j.js → embedding-backfill-79br4kk6.js} +2 -2
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-probe.d.ts +10 -9
- package/dist/features/magic-context/memory/embedding-probe.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-response-slots.d.ts +13 -0
- package/dist/features/magic-context/memory/embedding-response-slots.d.ts.map +1 -0
- package/dist/features/magic-context/overflow-detection.d.ts +7 -0
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/storage-native-replay.d.ts +2 -0
- package/dist/features/magic-context/storage-native-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/emergency-drop.d.ts +8 -1
- package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
- package/dist/hooks/magic-context/execute-flush.d.ts +1 -1
- package/dist/hooks/magic-context/execute-flush.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +4 -0
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts +1 -0
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/image-token-estimate.d.ts +1 -0
- package/dist/hooks/magic-context/image-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/provider-refusal-count.d.ts +84 -0
- package/dist/hooks/magic-context/provider-refusal-count.d.ts.map +1 -0
- package/dist/hooks/magic-context/signed-thinking-hold.d.ts +2 -0
- package/dist/hooks/magic-context/signed-thinking-hold.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +1 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-p52gf8a6.js → index-0eyxarpb.js} +7 -7
- package/dist/{index-a1295271.js → index-0tqhr9zs.js} +5 -5
- package/dist/{index-xw608ytx.js → index-3cgh0ght.js} +1 -1
- package/dist/{index-hmrkgd4v.js → index-634cww4x.js} +7 -7
- package/dist/{index-h1xvt8fw.js → index-63kp05sy.js} +1 -1
- package/dist/{index-k86ec4j2.js → index-6hjbeeth.js} +4 -4
- package/dist/{index-04zhtsb1.js → index-e6s2jpr8.js} +1 -1
- package/dist/{index-db1art1p.js → index-esym6cw4.js} +1 -1
- package/dist/{index-tyjx0dwz.js → index-jjy4shhy.js} +1 -1
- package/dist/{index-8hhmv0ff.js → index-kjhgxkdx.js} +1 -1
- package/dist/{index-z1mj8fv5.js → index-mhdavdd4.js} +22 -17
- package/dist/{index-5wbqmvg8.js → index-n3tebmah.js} +25 -18
- package/dist/{index-0wj3jr8n.js → index-qjcye18f.js} +3 -3
- package/dist/{index-9eqt7755.js → index-rakm1eay.js} +2 -2
- package/dist/{index-w6kcwhhj.js → index-rjxg7a7m.js} +212 -4
- package/dist/{index-vxsxz3sp.js → index-txthzqrm.js} +286 -36
- package/dist/{index-em72jhc0.js → index-z1hc2g06.js} +1 -1
- package/dist/{index-kjdys7e2.js → index-zg5r2syy.js} +1 -1
- package/dist/{index-xbna9akt.js → index-zyb7tndy.js} +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +138 -26
- package/dist/{message-index-bounded-6y7p974x.js → message-index-bounded-289186ah.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/plugin/messages-transform.d.ts +1 -0
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/plugin/provider-refusal-v1.d.ts +15 -0
- package/dist/plugin/provider-refusal-v1.d.ts.map +1 -0
- package/dist/{project-embedding-registry-5rp9w92w.js → project-embedding-registry-xy8dcdys.js} +1 -1
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-9ejnbe07.js → read-session-chunk-frnwxnjg.js} +2 -2
- package/dist/{recomp-orchestrator-kmkf8dm4.js → recomp-orchestrator-e7n124g0.js} +10 -10
- package/dist/{render-9712q3gp.js → render-argap54x.js} +6 -6
- package/dist/{search-archive-5jr011gc.js → search-archive-ads5mh9s.js} +5 -5
- package/dist/{search-kd84wg76.js → search-fxtb4844.js} +9 -9
- package/dist/shared/transcript.d.ts +1 -1
- package/dist/shared/transcript.d.ts.map +1 -1
- package/dist/{storage-tags-vd3sgd4s.js → storage-tags-2d2ba8e9.js} +1 -1
- package/dist/{transform-postprocess-phase-n4q1yd72.js → transform-postprocess-phase-2y0st4gk.js} +11 -11
- package/dist/v2/auto-search-worker.js +3 -3
- package/dist/v2/chunk-embedding-write-worker.js +1 -1
- package/dist/v2/{context-fqeg60th.js → context-v56v40cx.js} +600 -87
- package/dist/v2/{embedding-backfill-dm33f3ce.js → embedding-backfill-nhgp8znm.js} +2 -2
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/http-refusal-count.d.ts +41 -0
- package/dist/v2/hooks/http-refusal-count.d.ts.map +1 -0
- package/dist/v2/hooks/overflow-recovery.d.ts +3 -0
- package/dist/v2/hooks/overflow-recovery.d.ts.map +1 -1
- package/dist/v2/hooks/types.d.ts +5 -0
- package/dist/v2/hooks/types.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-wj5rs9az.js → message-index-bounded-p69v4wpy.js} +3 -3
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/{project-embedding-registry-z9qxkdxm.js → project-embedding-registry-qz9x79kn.js} +1 -1
- package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
- package/dist/v2/{read-session-chunk-89ep8br4.js → read-session-chunk-qzw3vedr.js} +2 -2
- package/dist/v2/{recomp-orchestrator-79362xbm.js → recomp-orchestrator-5gkzamy2.js} +9 -9
- package/dist/v2/{render-bzzypsgy.js → render-atxj9eaf.js} +6 -6
- package/dist/v2/{search-4f6kmq31.js → search-51qr14ed.js} +8 -8
- package/dist/v2/{search-archive-4yr4hw2m.js → search-archive-vgwnvdx2.js} +5 -5
- package/dist/v2/{server-1bks09js.js → server-08jh9wew.js} +3 -3
- package/dist/v2/{server-b38pxt0e.js → server-2ek9exbe.js} +1 -1
- package/dist/v2/{server-8xgs110k.js → server-606mnrv4.js} +212 -4
- package/dist/v2/{server-md1cabvq.js → server-7wpw3wc6.js} +22 -17
- package/dist/v2/{server-zedjjdc5.js → server-8vby30m5.js} +1 -1
- package/dist/v2/{server-7861dnm3.js → server-awth2wsg.js} +1 -1
- package/dist/v2/{server-62t1852h.js → server-b25nvm9c.js} +1 -1
- package/dist/v2/{server-4ccgfzr2.js → server-bhr92yb4.js} +1 -1
- package/dist/v2/{server-6mq43ear.js → server-c1vcbszm.js} +1 -1
- package/dist/v2/{server-70dhx58s.js → server-d2a639dg.js} +6 -6
- package/dist/v2/{server-e8ybwfv8.js → server-p2wxmjc3.js} +2 -2
- package/dist/v2/{server-tk4hpcxq.js → server-rwdp3hw6.js} +7 -7
- package/dist/v2/{server-h95cdc30.js → server-s3m2y97h.js} +1 -1
- package/dist/v2/{server-d0h1gjz2.js → server-wdmcqhv6.js} +3 -3
- package/dist/v2/server.js +2 -2
- package/dist/v2/{storage-tags-8kktww54.js → storage-tags-4t9fb4ch.js} +1 -1
- package/dist/v2/{v2-archive-reader-veyqp15a.js → v2-archive-reader-1wc5wb1a.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-97s5wznb.js → wrapup-orchestrator-ksdn2emb.js} +9 -9
- package/dist/{v2-archive-reader-3s332fn7.js → v2-archive-reader-4pk46nc1.js} +1 -1
- package/dist/{wrapup-orchestrator-bm0x49e5.js → wrapup-orchestrator-sc2fsfct.js} +11 -11
- package/package.json +1 -1
- package/src/shared/tag-transcript.ts +5 -4
- package/src/shared/transcript.ts +1 -1
|
@@ -27,11 +27,11 @@ serveWorkerJobs(async (initial, port) => {
|
|
|
27
27
|
{ Database, registerSqliteDiagnosticSink },
|
|
28
28
|
{ log }
|
|
29
29
|
] = await Promise.all([
|
|
30
|
-
import("./embedding-backfill-
|
|
30
|
+
import("./embedding-backfill-79br4kk6.js"),
|
|
31
31
|
import("./embedding-cache-zn4r1c31.js"),
|
|
32
32
|
import("./storage-memory-hhrvfw0x.js"),
|
|
33
|
-
import("./project-embedding-registry-
|
|
34
|
-
import("./search-
|
|
33
|
+
import("./project-embedding-registry-xy8dcdys.js"),
|
|
34
|
+
import("./search-fxtb4844.js"),
|
|
35
35
|
import("./compartment-chunk-embedding-gnemmf79.js"),
|
|
36
36
|
import("./embedding-activity-g1dhes6g.js"),
|
|
37
37
|
import("./harness-e4avh192.js"),
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
clearNoteNudgeTriggerOnly,
|
|
52
52
|
nonNarrativeStoredGapRanges,
|
|
53
53
|
getActiveCompartmentRun
|
|
54
|
-
} from "./index-
|
|
54
|
+
} from "./index-0eyxarpb.js";
|
|
55
55
|
import"./index-sd3egckz.js";
|
|
56
56
|
import {
|
|
57
57
|
getHarness2
|
|
@@ -111,6 +111,10 @@ import {
|
|
|
111
111
|
PROVIDER_OVERFLOW_NOTICE,
|
|
112
112
|
noteServedRecoveryForOverflowHint,
|
|
113
113
|
holdOverflowResendHint,
|
|
114
|
+
ProviderRefusalCounts,
|
|
115
|
+
snapshotRefusalHistory,
|
|
116
|
+
pushRefusalFields,
|
|
117
|
+
withProviderRefusalPass,
|
|
114
118
|
createM0RenderOptions,
|
|
115
119
|
lkgReplayLimit,
|
|
116
120
|
measureLkgReplay,
|
|
@@ -146,7 +150,7 @@ import {
|
|
|
146
150
|
applyJsonSchemaParameterDescriptions,
|
|
147
151
|
MagicContextRpcServer,
|
|
148
152
|
subagentTemperature
|
|
149
|
-
} from "./index-
|
|
153
|
+
} from "./index-txthzqrm.js";
|
|
150
154
|
import {
|
|
151
155
|
invalidateAutoEmbedSession,
|
|
152
156
|
clearEmbedSessionState
|
|
@@ -212,13 +216,15 @@ import {
|
|
|
212
216
|
getSlot,
|
|
213
217
|
dropSlot,
|
|
214
218
|
copySessionStateForClone
|
|
215
|
-
} from "./index-
|
|
216
|
-
import"./index-
|
|
219
|
+
} from "./index-z1hc2g06.js";
|
|
220
|
+
import"./index-jjy4shhy.js";
|
|
217
221
|
import {
|
|
218
222
|
stripPersistedAssistantText,
|
|
219
223
|
currentReclaimableToolOutputCount,
|
|
220
224
|
isRecord,
|
|
221
225
|
contentTagOwnerMessageId,
|
|
226
|
+
estimateImageTokensFromDataUrl,
|
|
227
|
+
estimateImageTokensFromBase64,
|
|
222
228
|
isDroppedToolOutput,
|
|
223
229
|
evaluateChannel2,
|
|
224
230
|
buildChannel2Reminder,
|
|
@@ -251,14 +257,17 @@ import {
|
|
|
251
257
|
getObservedEpochFloor,
|
|
252
258
|
isPrefixBoundThinkingModel,
|
|
253
259
|
detectOverflow,
|
|
260
|
+
isMeasuredRefusalStatusVeto,
|
|
261
|
+
isProviderSizeRefusal,
|
|
254
262
|
isProviderRateLimit,
|
|
255
263
|
modelAcceptsEmptyContent,
|
|
256
264
|
markServedShapeRepair,
|
|
257
265
|
getEmptyImageParts,
|
|
266
|
+
estimateFrozenRequestInputTokens,
|
|
258
267
|
estimateFinalWireInputTokens,
|
|
259
268
|
getMaxTagNumberBySession2,
|
|
260
269
|
getTagsBySession2
|
|
261
|
-
} from "./index-
|
|
270
|
+
} from "./index-rjxg7a7m.js";
|
|
262
271
|
import {
|
|
263
272
|
BoundedSessionMap,
|
|
264
273
|
getTableColumnNames,
|
|
@@ -301,10 +310,10 @@ import {
|
|
|
301
310
|
cleanUserText2,
|
|
302
311
|
readRawSessionMessageIdOrdinalsForRange2,
|
|
303
312
|
readRawSessionMessageOrdinalById2
|
|
304
|
-
} from "./index-
|
|
313
|
+
} from "./index-kjhgxkdx.js";
|
|
305
314
|
import {
|
|
306
315
|
scheduleClearAndReindex
|
|
307
|
-
} from "./index-
|
|
316
|
+
} from "./index-63kp05sy.js";
|
|
308
317
|
import {
|
|
309
318
|
startBootDeadline,
|
|
310
319
|
getSchemaFenceRejection,
|
|
@@ -314,7 +323,7 @@ import {
|
|
|
314
323
|
openDatabaseAsync,
|
|
315
324
|
isDatabasePersisted,
|
|
316
325
|
getDatabasePersistenceError
|
|
317
|
-
} from "./index-
|
|
326
|
+
} from "./index-3cgh0ght.js";
|
|
318
327
|
import"./index-fr0wbhdn.js";
|
|
319
328
|
import"./index-hyvxmz3e.js";
|
|
320
329
|
import {
|
|
@@ -344,20 +353,20 @@ import {
|
|
|
344
353
|
servedHeadChanged,
|
|
345
354
|
noteHostCheckpointCommit,
|
|
346
355
|
isSyntheticHeadMessage2
|
|
347
|
-
} from "./index-
|
|
356
|
+
} from "./index-n3tebmah.js";
|
|
348
357
|
import"./index-qxzk5s30.js";
|
|
349
358
|
import"./index-qt1qqasc.js";
|
|
350
359
|
import {
|
|
351
360
|
retainProjectEmbedding2
|
|
352
|
-
} from "./index-
|
|
361
|
+
} from "./index-mhdavdd4.js";
|
|
353
362
|
import"./index-fd3hkyk1.js";
|
|
354
363
|
import"./index-qjwpqvnf.js";
|
|
355
364
|
import"./index-nyjztqyj.js";
|
|
356
365
|
import {
|
|
357
366
|
renderUserFacingFailure,
|
|
358
367
|
userFacingFailureCode
|
|
359
|
-
} from "./index-
|
|
360
|
-
import"./index-
|
|
368
|
+
} from "./index-esym6cw4.js";
|
|
369
|
+
import"./index-e6s2jpr8.js";
|
|
361
370
|
import"./index-9emdjcb5.js";
|
|
362
371
|
import {
|
|
363
372
|
pushLiveNotification2,
|
|
@@ -366,8 +375,8 @@ import {
|
|
|
366
375
|
} from "./index-y14pawe1.js";
|
|
367
376
|
import"./index-y5f5yg5a.js";
|
|
368
377
|
import"./index-61a853ky.js";
|
|
369
|
-
import"./index-
|
|
370
|
-
import"./index-
|
|
378
|
+
import"./index-634cww4x.js";
|
|
379
|
+
import"./index-6hjbeeth.js";
|
|
371
380
|
import"./index-cayqdwf9.js";
|
|
372
381
|
import {
|
|
373
382
|
detectConflicts
|
|
@@ -399,10 +408,10 @@ import {
|
|
|
399
408
|
createV2RawMessageProvider2
|
|
400
409
|
} from "./index-mfx7hzyc.js";
|
|
401
410
|
import"./index-fmsr7v69.js";
|
|
402
|
-
import"./index-
|
|
403
|
-
import"./index-
|
|
404
|
-
import"./index-
|
|
405
|
-
import"./index-
|
|
411
|
+
import"./index-rakm1eay.js";
|
|
412
|
+
import"./index-zg5r2syy.js";
|
|
413
|
+
import"./index-zyb7tndy.js";
|
|
414
|
+
import"./index-qjcye18f.js";
|
|
406
415
|
import {
|
|
407
416
|
markHostInstructionRow,
|
|
408
417
|
hostInstructionRow,
|
|
@@ -6549,6 +6558,193 @@ function hiddenTerminalError(event) {
|
|
|
6549
6558
|
return;
|
|
6550
6559
|
}
|
|
6551
6560
|
|
|
6561
|
+
// src/v2/hooks/http-refusal-count.ts
|
|
6562
|
+
class V2HttpRefusalCounts {
|
|
6563
|
+
counts;
|
|
6564
|
+
requests = new WeakMap;
|
|
6565
|
+
associated = new WeakSet;
|
|
6566
|
+
inFlight = new Map;
|
|
6567
|
+
constructor(counts) {
|
|
6568
|
+
this.counts = counts;
|
|
6569
|
+
}
|
|
6570
|
+
capture({ sessionID, model, request }) {
|
|
6571
|
+
const pass = this.counts.latest(sessionID);
|
|
6572
|
+
if (!pass)
|
|
6573
|
+
return;
|
|
6574
|
+
this.release(sessionID);
|
|
6575
|
+
this.associated.add(request);
|
|
6576
|
+
if (request.signal.aborted)
|
|
6577
|
+
return;
|
|
6578
|
+
const attempt = { sessionID, model: `${model.providerID}/${model.id}`, pass };
|
|
6579
|
+
this.requests.set(request, attempt);
|
|
6580
|
+
this.inFlight.set(sessionID, request);
|
|
6581
|
+
const abort = () => this.releaseNonSizeAttempt(request);
|
|
6582
|
+
request.signal.addEventListener("abort", abort, { once: true });
|
|
6583
|
+
attempt.detachAbort = () => request.signal.removeEventListener("abort", abort);
|
|
6584
|
+
try {
|
|
6585
|
+
attempt.body = request.clone();
|
|
6586
|
+
} catch {}
|
|
6587
|
+
}
|
|
6588
|
+
async observe(draft, errorBody) {
|
|
6589
|
+
const attempt = this.detach(draft.request);
|
|
6590
|
+
if (!attempt) {
|
|
6591
|
+
if (draft.response.ok)
|
|
6592
|
+
this.accept(draft.sessionID);
|
|
6593
|
+
return this.associated.has(draft.request);
|
|
6594
|
+
}
|
|
6595
|
+
const model = `${draft.model.providerID}/${draft.model.id}`;
|
|
6596
|
+
if (draft.sessionID !== attempt.sessionID || model !== attempt.model) {
|
|
6597
|
+
cancelBody(attempt);
|
|
6598
|
+
return true;
|
|
6599
|
+
}
|
|
6600
|
+
if (draft.response.ok) {
|
|
6601
|
+
cancelBody(attempt);
|
|
6602
|
+
this.accept(draft.sessionID);
|
|
6603
|
+
return true;
|
|
6604
|
+
}
|
|
6605
|
+
if (!isProviderSizeRefusal({ status: draft.response.status, responseBody: errorBody })) {
|
|
6606
|
+
this.counts.discardPreparation(attempt.sessionID, attempt.pass);
|
|
6607
|
+
cancelBody(attempt);
|
|
6608
|
+
return true;
|
|
6609
|
+
}
|
|
6610
|
+
this.counts.discardDraft(attempt.sessionID, attempt.pass);
|
|
6611
|
+
try {
|
|
6612
|
+
const body = await attempt.body?.json();
|
|
6613
|
+
const tokens = countFullRequest(body);
|
|
6614
|
+
if (tokens !== undefined)
|
|
6615
|
+
this.counts.refusal(attempt.sessionID, attempt.model, attempt.pass, tokens);
|
|
6616
|
+
} catch {} finally {
|
|
6617
|
+
cancelBody(attempt);
|
|
6618
|
+
this.counts.discardPreparation(attempt.sessionID, attempt.pass);
|
|
6619
|
+
}
|
|
6620
|
+
return true;
|
|
6621
|
+
}
|
|
6622
|
+
accept(sessionID) {
|
|
6623
|
+
this.counts.forget(sessionID);
|
|
6624
|
+
this.release(sessionID);
|
|
6625
|
+
}
|
|
6626
|
+
endRun(sessionID) {
|
|
6627
|
+
const request = this.inFlight.get(sessionID);
|
|
6628
|
+
this.counts.endRun(sessionID, () => {
|
|
6629
|
+
if (request)
|
|
6630
|
+
this.discard(request);
|
|
6631
|
+
});
|
|
6632
|
+
}
|
|
6633
|
+
release(sessionID, nonSizeFailure = false) {
|
|
6634
|
+
const request = this.inFlight.get(sessionID);
|
|
6635
|
+
if (!request)
|
|
6636
|
+
return;
|
|
6637
|
+
if (nonSizeFailure)
|
|
6638
|
+
this.releaseNonSizeAttempt(request);
|
|
6639
|
+
else
|
|
6640
|
+
this.discard(request);
|
|
6641
|
+
}
|
|
6642
|
+
dispose() {
|
|
6643
|
+
for (const request of this.inFlight.values())
|
|
6644
|
+
this.discard(request);
|
|
6645
|
+
}
|
|
6646
|
+
detach(request) {
|
|
6647
|
+
const attempt = this.requests.get(request);
|
|
6648
|
+
if (!attempt)
|
|
6649
|
+
return;
|
|
6650
|
+
this.requests.delete(request);
|
|
6651
|
+
if (this.inFlight.get(attempt.sessionID) === request)
|
|
6652
|
+
this.inFlight.delete(attempt.sessionID);
|
|
6653
|
+
attempt.detachAbort?.();
|
|
6654
|
+
return attempt;
|
|
6655
|
+
}
|
|
6656
|
+
discard(request) {
|
|
6657
|
+
const attempt = this.detach(request);
|
|
6658
|
+
if (!attempt)
|
|
6659
|
+
return;
|
|
6660
|
+
cancelBody(attempt);
|
|
6661
|
+
}
|
|
6662
|
+
releaseNonSizeAttempt(request) {
|
|
6663
|
+
const attempt = this.detach(request);
|
|
6664
|
+
if (!attempt)
|
|
6665
|
+
return;
|
|
6666
|
+
this.counts.discardPreparation(attempt.sessionID, attempt.pass);
|
|
6667
|
+
cancelBody(attempt);
|
|
6668
|
+
}
|
|
6669
|
+
}
|
|
6670
|
+
function cancelBody(attempt) {
|
|
6671
|
+
const body = attempt?.body?.body;
|
|
6672
|
+
if (body && !body.locked)
|
|
6673
|
+
body.cancel().catch(() => {});
|
|
6674
|
+
}
|
|
6675
|
+
function readOpenCode2RefusalMessage(message, values) {
|
|
6676
|
+
values.push(message.role);
|
|
6677
|
+
for (const part of message.content) {
|
|
6678
|
+
switch (part.type) {
|
|
6679
|
+
case "text":
|
|
6680
|
+
case "reasoning":
|
|
6681
|
+
values.push(part.type, part.text);
|
|
6682
|
+
break;
|
|
6683
|
+
case "tool-call":
|
|
6684
|
+
values.push("tool-call", part.name, part.input);
|
|
6685
|
+
break;
|
|
6686
|
+
case "tool-result":
|
|
6687
|
+
values.push("tool-result", part.name, part.result);
|
|
6688
|
+
break;
|
|
6689
|
+
case "media": {
|
|
6690
|
+
const media = isRecord(part.media) ? part.media : {};
|
|
6691
|
+
const source = isRecord(media.source) ? media.source : {};
|
|
6692
|
+
values.push("media", source.type, source.mediaType, source.data, source.url);
|
|
6693
|
+
break;
|
|
6694
|
+
}
|
|
6695
|
+
default:
|
|
6696
|
+
pushRefusalFields(part, values);
|
|
6697
|
+
}
|
|
6698
|
+
}
|
|
6699
|
+
}
|
|
6700
|
+
function countFullRequest(body) {
|
|
6701
|
+
if (!body || typeof body !== "object")
|
|
6702
|
+
return;
|
|
6703
|
+
const request = body;
|
|
6704
|
+
if (request.previous_response_id || request.conversation || request.cachedContent)
|
|
6705
|
+
return;
|
|
6706
|
+
const transcript = request.messages ?? request.input ?? request.contents;
|
|
6707
|
+
if (!Array.isArray(transcript))
|
|
6708
|
+
return;
|
|
6709
|
+
if (request.tools !== undefined && !Array.isArray(request.tools))
|
|
6710
|
+
return;
|
|
6711
|
+
let images = 0;
|
|
6712
|
+
const text = JSON.stringify({
|
|
6713
|
+
transcript,
|
|
6714
|
+
system: request.system ?? request.instructions ?? request.systemInstruction,
|
|
6715
|
+
tools: request.tools
|
|
6716
|
+
}, (_key, value) => {
|
|
6717
|
+
if (!isRecord(value))
|
|
6718
|
+
return value;
|
|
6719
|
+
const tokens = httpImageTokens(value);
|
|
6720
|
+
if (tokens === undefined)
|
|
6721
|
+
return value;
|
|
6722
|
+
images += tokens;
|
|
6723
|
+
return null;
|
|
6724
|
+
});
|
|
6725
|
+
return estimateTokens(text) + images;
|
|
6726
|
+
}
|
|
6727
|
+
function httpImageTokens(part) {
|
|
6728
|
+
if (part.type === "image" && isRecord(part.source)) {
|
|
6729
|
+
const source = part.source;
|
|
6730
|
+
if (source.type === "base64" && typeof source.media_type === "string" && typeof source.data === "string")
|
|
6731
|
+
return estimateImageTokensFromBase64(source.media_type, source.data);
|
|
6732
|
+
if (source.type === "url" && typeof source.url === "string")
|
|
6733
|
+
return estimateImageTokensFromDataUrl(source.url);
|
|
6734
|
+
}
|
|
6735
|
+
if (part.type === "image_url" || part.type === "input_image") {
|
|
6736
|
+
const url = isRecord(part.image_url) ? part.image_url.url : part.image_url;
|
|
6737
|
+
if (typeof url === "string")
|
|
6738
|
+
return estimateImageTokensFromDataUrl(url);
|
|
6739
|
+
}
|
|
6740
|
+
const inline = part.inlineData ?? part.inline_data;
|
|
6741
|
+
if (isRecord(inline)) {
|
|
6742
|
+
const mime = inline.mimeType ?? inline.mime_type;
|
|
6743
|
+
if (typeof mime === "string" && mime.startsWith("image/") && typeof inline.data === "string")
|
|
6744
|
+
return estimateImageTokensFromBase64(mime, inline.data);
|
|
6745
|
+
}
|
|
6746
|
+
}
|
|
6747
|
+
|
|
6552
6748
|
// src/v2/hooks/lkg-system.ts
|
|
6553
6749
|
import { createHash as createHash3 } from "node:crypto";
|
|
6554
6750
|
function identity2(slot) {
|
|
@@ -6681,13 +6877,15 @@ class V2OverflowRecovery {
|
|
|
6681
6877
|
if (error === undefined)
|
|
6682
6878
|
return;
|
|
6683
6879
|
const prior = this.requests.get(sessionID);
|
|
6684
|
-
|
|
6880
|
+
const sizeRefusal = isProviderSizeRefusal(error);
|
|
6881
|
+
if (prior?.observed || isProviderRateLimit(error) || !sizeRefusal && !detectOverflow(error).isOverflow)
|
|
6685
6882
|
return;
|
|
6686
6883
|
const messageID = event.data?.assistantMessageID;
|
|
6687
6884
|
const step = readStep(sessionID, messageID);
|
|
6688
6885
|
if (!step)
|
|
6689
6886
|
return;
|
|
6690
|
-
|
|
6887
|
+
const durable = !!messageID || !!step.error && detectOverflow(step.error).isOverflow;
|
|
6888
|
+
if (!durable && !isProviderSizeRefusal(step.error))
|
|
6691
6889
|
return;
|
|
6692
6890
|
if (!prior && step.model)
|
|
6693
6891
|
this.begin({
|
|
@@ -6703,7 +6901,8 @@ class V2OverflowRecovery {
|
|
|
6703
6901
|
sessionID,
|
|
6704
6902
|
error,
|
|
6705
6903
|
model: step?.model ?? request.model,
|
|
6706
|
-
assistantMessageID: messageID ?? step?.id
|
|
6904
|
+
assistantMessageID: messageID ?? step?.id,
|
|
6905
|
+
durable
|
|
6707
6906
|
});
|
|
6708
6907
|
}
|
|
6709
6908
|
observe(input) {
|
|
@@ -6714,13 +6913,22 @@ class V2OverflowRecovery {
|
|
|
6714
6913
|
return;
|
|
6715
6914
|
if (input.status === 429 || isProviderRateLimit(input.error))
|
|
6716
6915
|
return;
|
|
6717
|
-
const
|
|
6916
|
+
const reportedError = typeof input.error === "string" && input.status !== undefined ? {
|
|
6917
|
+
status: input.status,
|
|
6918
|
+
responseBody: input.error,
|
|
6919
|
+
data: { responseBody: input.error }
|
|
6920
|
+
} : input.error;
|
|
6921
|
+
const modelKey = `${input.model.providerID}/${input.model.id}`;
|
|
6922
|
+
if (!this.deps.compactionOff && !input.skipMeasured && isProviderSizeRefusal(reportedError))
|
|
6923
|
+
this.deps.onProviderRefused?.(input.sessionID, modelKey, input.assistantMessageID);
|
|
6924
|
+
if (input.durable === false)
|
|
6925
|
+
return;
|
|
6926
|
+
const detection = detectOverflow(reportedError);
|
|
6718
6927
|
if (!detection.isOverflow)
|
|
6719
6928
|
return;
|
|
6720
6929
|
const db = this.deps.database();
|
|
6721
6930
|
if (!db)
|
|
6722
6931
|
return;
|
|
6723
|
-
const modelKey = `${input.model.providerID}/${input.model.id}`;
|
|
6724
6932
|
const reportedLimit = resolveOpenCodeOverflowLimit(detection, input.model.providerID, input.model.id, { db, sessionID: input.sessionID });
|
|
6725
6933
|
if (this.deps.compactionOff) {
|
|
6726
6934
|
if (reportedLimit)
|
|
@@ -7593,7 +7801,14 @@ function restoreNativeCheckpointInput(messages, incoming, restored, reader, sess
|
|
|
7593
7801
|
const at = messages.indexOf(incoming);
|
|
7594
7802
|
return [...messages.slice(0, at), ...hidden, ...messages.slice(at + 1)];
|
|
7595
7803
|
}
|
|
7596
|
-
function
|
|
7804
|
+
function latestDraftAssistantID(messages) {
|
|
7805
|
+
for (let index = messages.length - 1;index >= 0; index--) {
|
|
7806
|
+
const message = messages[index];
|
|
7807
|
+
if (message?.role === "assistant" && message.id)
|
|
7808
|
+
return message.id;
|
|
7809
|
+
}
|
|
7810
|
+
}
|
|
7811
|
+
function checkpointRequestSizingInput(draft) {
|
|
7597
7812
|
let toolDefinitionTokens = 0;
|
|
7598
7813
|
for (const tool of Object.values(draft.tools)) {
|
|
7599
7814
|
const schema = JSON.stringify(tool.input);
|
|
@@ -7605,7 +7820,7 @@ function estimateCheckpointRequest(draft) {
|
|
|
7605
7820
|
...draft,
|
|
7606
7821
|
messages: draft.messages.map((message) => HEAD_IDS.some((id) => message.id === id) ? { ...message, id: undefined } : message)
|
|
7607
7822
|
};
|
|
7608
|
-
return
|
|
7823
|
+
return {
|
|
7609
7824
|
messages: adaptPayload(estimateDraft).messages,
|
|
7610
7825
|
toolDefinitionTokens,
|
|
7611
7826
|
systemPromptTokens: estimateTokens(JSON.stringify(draft.system)),
|
|
@@ -7613,7 +7828,10 @@ function estimateCheckpointRequest(draft) {
|
|
|
7613
7828
|
modelID: draft.model.id,
|
|
7614
7829
|
agentName: draft.agent,
|
|
7615
7830
|
sessionId: draft.sessionID
|
|
7616
|
-
}
|
|
7831
|
+
};
|
|
7832
|
+
}
|
|
7833
|
+
function estimateCheckpointRequest(draft) {
|
|
7834
|
+
return estimateFinalWireInputTokens(checkpointRequestSizingInput(draft));
|
|
7617
7835
|
}
|
|
7618
7836
|
function estimateCheckpointFraming(draft, checkpoint, submitted) {
|
|
7619
7837
|
const framing = structuredClone(checkpoint);
|
|
@@ -8073,11 +8291,18 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
8073
8291
|
}) : undefined;
|
|
8074
8292
|
const hiddenChildHook = new HiddenChildHook;
|
|
8075
8293
|
const usage = new Map;
|
|
8294
|
+
const refusalCounts = new ProviderRefusalCounts;
|
|
8295
|
+
const httpRefusalCounts = new V2HttpRefusalCounts(refusalCounts);
|
|
8076
8296
|
const overflowRecovery = new V2OverflowRecovery({
|
|
8077
8297
|
database: () => db ?? null,
|
|
8078
8298
|
compactionOff,
|
|
8079
8299
|
isHidden: (sessionID) => hiddenChildHook.owns(sessionID),
|
|
8080
8300
|
onOverflow: (sessionID) => notifyV2ProviderOverflow(sessionID, openStoreReader),
|
|
8301
|
+
onProviderRefused: (sessionID, modelKey, assistantMessageID) => {
|
|
8302
|
+
const pass = refusalCounts.latestForTerminalFailure(sessionID, assistantMessageID);
|
|
8303
|
+
if (pass)
|
|
8304
|
+
refusalCounts.refusal(sessionID, modelKey, pass);
|
|
8305
|
+
},
|
|
8081
8306
|
onInputTokens: (sessionID, inputTokens, limit) => usage.set(sessionID, {
|
|
8082
8307
|
usage: { inputTokens, percentage: limit > 0 ? inputTokens / limit * 100 : 100 },
|
|
8083
8308
|
hasUsageTokens: true,
|
|
@@ -8088,6 +8313,8 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
8088
8313
|
await hiddenChildHook.cacheRequest(draft);
|
|
8089
8314
|
if (draft.kind !== "primary" || hiddenChildHook.owns(draft.sessionID))
|
|
8090
8315
|
return;
|
|
8316
|
+
if (!compactionOff && draft.model)
|
|
8317
|
+
httpRefusalCounts.capture({ ...draft, model: draft.model });
|
|
8091
8318
|
const selectedModel = liveModels.get(draft.sessionID);
|
|
8092
8319
|
if (selectedModel)
|
|
8093
8320
|
overflowRecovery.begin({
|
|
@@ -8100,12 +8327,21 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
8100
8327
|
cleanup.tools = () => tools.dispose();
|
|
8101
8328
|
const generateReplay = new V2GenerateReplay;
|
|
8102
8329
|
await context.session.hook("http.response", async (draft) => {
|
|
8103
|
-
if (!db || draft.kind !== "primary"
|
|
8330
|
+
if (!db || draft.kind !== "primary")
|
|
8104
8331
|
return;
|
|
8332
|
+
if (draft.response.ok) {
|
|
8333
|
+
httpRefusalCounts.accept(draft.sessionID);
|
|
8334
|
+
return;
|
|
8335
|
+
}
|
|
8336
|
+
if (draft.request && isMeasuredRefusalStatusVeto(draft.response.status))
|
|
8337
|
+
httpRefusalCounts.releaseNonSizeAttempt(draft.request);
|
|
8338
|
+
const error = await draft.response.clone().text();
|
|
8339
|
+
const associated = !compactionOff && draft.request !== undefined && await httpRefusalCounts.observe({ ...draft, request: draft.request }, error);
|
|
8105
8340
|
overflowRecovery.observe({
|
|
8106
8341
|
...draft,
|
|
8107
|
-
error
|
|
8108
|
-
status: draft.response.status
|
|
8342
|
+
error,
|
|
8343
|
+
status: draft.response.status,
|
|
8344
|
+
skipMeasured: associated
|
|
8109
8345
|
});
|
|
8110
8346
|
});
|
|
8111
8347
|
await registerHiddenChildAgents(context.agent);
|
|
@@ -8630,7 +8866,10 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
8630
8866
|
}
|
|
8631
8867
|
};
|
|
8632
8868
|
const usageController = new AbortController;
|
|
8633
|
-
cleanup.abortUsage = () =>
|
|
8869
|
+
cleanup.abortUsage = () => {
|
|
8870
|
+
usageController.abort();
|
|
8871
|
+
httpRefusalCounts.dispose();
|
|
8872
|
+
};
|
|
8634
8873
|
const usageDone = (async () => {
|
|
8635
8874
|
let retry = 0;
|
|
8636
8875
|
while (!usageController.signal.aborted) {
|
|
@@ -8652,6 +8891,10 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
8652
8891
|
continue;
|
|
8653
8892
|
const sessionID = event.data.sessionID;
|
|
8654
8893
|
observeSyntheticAdmissionEvent(context, event);
|
|
8894
|
+
if (event.type?.startsWith("session.revert.") || event.type === "session.message.removed" || event.type === "session.message.deleted" || event.type === "session.deleted")
|
|
8895
|
+
httpRefusalCounts.accept(sessionID);
|
|
8896
|
+
if ((event.type === "session.step.failed" || event.type === "session.error") && !isProviderSizeRefusal(event.data.error ?? hiddenTerminalError(event)))
|
|
8897
|
+
httpRefusalCounts.release(sessionID, true);
|
|
8655
8898
|
overflowRecovery.observeTerminal(event, (id, messageID) => {
|
|
8656
8899
|
const reader = openStoreReader();
|
|
8657
8900
|
try {
|
|
@@ -8664,6 +8907,13 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
8664
8907
|
reader.close();
|
|
8665
8908
|
}
|
|
8666
8909
|
});
|
|
8910
|
+
if (event.type === "session.step.ended") {
|
|
8911
|
+
const pass = refusalCounts.latestForTerminalFailure(sessionID, event.data.assistantMessageID);
|
|
8912
|
+
if (pass)
|
|
8913
|
+
refusalCounts.discardPreparation(sessionID, pass);
|
|
8914
|
+
}
|
|
8915
|
+
if (event.type === "session.execution.succeeded" || event.type === "session.execution.failed" || event.type === "session.execution.interrupted")
|
|
8916
|
+
httpRefusalCounts.endRun(sessionID);
|
|
8667
8917
|
if (event.type === "session.revert.staged" && db) {
|
|
8668
8918
|
revertMessageCleanup.captureStageProof(sessionID, event.data.revert?.messageID);
|
|
8669
8919
|
}
|
|
@@ -8864,6 +9114,8 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
8864
9114
|
const running = reader.latestRunningCompaction(draft.sessionID);
|
|
8865
9115
|
const attempt = running && nativeFoldMemory?.admission(draft.sessionID, running.id);
|
|
8866
9116
|
const manual = running?.data.reason === "manual" && !(attempt?.status === "pending" && attempt.owner_token);
|
|
9117
|
+
if (manual)
|
|
9118
|
+
httpRefusalCounts.accept(draft.sessionID);
|
|
8867
9119
|
const moduleBaseline = rustModeModuleClient ? servedModuleM0Text(draft.sessionID) : undefined;
|
|
8868
9120
|
const source = !rustModeModuleClient ? "typescript" : moduleBaseline === null ? "typescript_fallback" : "module";
|
|
8869
9121
|
if (nativeFoldReplay) {
|
|
@@ -9129,7 +9381,7 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
9129
9381
|
onRustEngineReconnectRefusal: (refusal) => rustRefusalRecovery?.arm(refusal),
|
|
9130
9382
|
...createHostSeams(context, readAllForConversion, pagedRead, liveModels)
|
|
9131
9383
|
});
|
|
9132
|
-
const runManagedContext = async (draft, pass, previousRecovery) => {
|
|
9384
|
+
const runManagedContext = async (draft, pass, previousRecovery, refusalPass) => {
|
|
9133
9385
|
rememberHostMedia(draft.messages);
|
|
9134
9386
|
if (hiddenChildHook.apply(draft))
|
|
9135
9387
|
return "skipped";
|
|
@@ -9586,6 +9838,8 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
9586
9838
|
nativeFoldReplay.invalidate(draft.sessionID, true);
|
|
9587
9839
|
}
|
|
9588
9840
|
}
|
|
9841
|
+
if (refusalPass)
|
|
9842
|
+
refusalPass.observeHistory(snapshotRefusalHistory(draft.messages, readOpenCode2RefusalMessage));
|
|
9589
9843
|
const mapped = adaptPayload(draft, syntheticIDs, messageTimes, anchorTimesOnly, instructionRows);
|
|
9590
9844
|
bindSystemDateRequestIdentity(mapped, draft);
|
|
9591
9845
|
checkpointPassPermissions.delete(draft.sessionID);
|
|
@@ -9814,12 +10068,15 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
9814
10068
|
const previousRecovery = recoveredInstructions.peek(draft.sessionID);
|
|
9815
10069
|
recoveredInstructions.delete(draft.sessionID);
|
|
9816
10070
|
const hiddenChild = hiddenChildHook.owns(draft.sessionID);
|
|
10071
|
+
if (!compactionOff && !hiddenChild && !rustModeModuleClient)
|
|
10072
|
+
httpRefusalCounts.release(draft.sessionID);
|
|
10073
|
+
const refusalPass = compactionOff || hiddenChild || rustModeModuleClient ? undefined : refusalCounts.begin(draft.sessionID, undefined, latestDraftAssistantID(draft.messages));
|
|
9817
10074
|
const anchor = compactionOff || hiddenChild ? undefined : generateReplayAnchor(draft.messages);
|
|
9818
10075
|
beginServedRequest(draft.sessionID);
|
|
9819
10076
|
let returned = false;
|
|
9820
10077
|
let outcome;
|
|
9821
10078
|
try {
|
|
9822
|
-
outcome = await runManagedContext(draft, pass, previousRecovery);
|
|
10079
|
+
outcome = refusalPass ? await withProviderRefusalPass(draft.sessionID, refusalPass, () => runManagedContext(draft, pass, previousRecovery, refusalPass)) : await runManagedContext(draft, pass, previousRecovery);
|
|
9823
10080
|
if (!pass.refused && pass.storageNoticeWake && draft.messages.at(-1)?.role === "assistant") {
|
|
9824
10081
|
await refuseBeforeProvider(context.session, draft.sessionID, "storage-notice-turn", "request ends with the previous reply");
|
|
9825
10082
|
}
|
|
@@ -9880,6 +10137,10 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
9880
10137
|
sessionLog2(draft.sessionID, "generate replay capture skipped: compaction-disabled");
|
|
9881
10138
|
else if (!pass.refused && outcome === "managed" && !hiddenChild && !deletedSessions.has(draft.sessionID))
|
|
9882
10139
|
generateReplay.capture(draft, anchor);
|
|
10140
|
+
if (refusalPass && !pass.refused && outcome === "managed" && draft.system.some((part) => part.text)) {
|
|
10141
|
+
const saved = { ...draft };
|
|
10142
|
+
refusalPass.freeze(`${saved.model.providerID}/${saved.model.id}`, () => estimateFrozenRequestInputTokens(checkpointRequestSizingInput(saved)));
|
|
10143
|
+
}
|
|
9883
10144
|
}));
|
|
9884
10145
|
await context.session.hook("generate", async (draft) => {
|
|
9885
10146
|
const managed = !compactionOff && !deletedSessions.has(draft.sessionID);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding-openai.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding-openai.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAyB,MAAM,qBAAqB,CAAC;AAGnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"embedding-openai.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding-openai.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Live verification of an OpenAI-compatible embeddings endpoint.
|
|
3
3
|
*
|
|
4
|
-
* Used by `doctor`
|
|
5
|
-
* `test_embedding_endpoint` command
|
|
6
|
-
* `${endpoint}/embeddings` and classify the response. Keeping the two
|
|
7
|
-
* implementations parallel is intentional: doctor runs in the plugin's Node
|
|
8
|
-
* runtime where `fetch` + `AbortSignal.timeout` are available, while the
|
|
9
|
-
* dashboard uses Rust `reqwest` for reasons of its own async stack.
|
|
4
|
+
* Used by the Node CLI's `doctor` to check a small batch. The dashboard's
|
|
5
|
+
* `test_embedding_endpoint` command uses a separate Rust probe.
|
|
10
6
|
*/
|
|
11
7
|
export type EmbeddingProbeOutcome = {
|
|
12
8
|
kind: "ok";
|
|
13
9
|
status: number;
|
|
14
10
|
dimensions: number | null;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "invalid_envelope";
|
|
13
|
+
status: number;
|
|
14
|
+
message: string;
|
|
15
15
|
} | {
|
|
16
16
|
kind: "dimensions_mismatch";
|
|
17
17
|
status: number;
|
|
@@ -69,9 +69,10 @@ export interface EmbeddingProbeOptions {
|
|
|
69
69
|
/**
|
|
70
70
|
* Probe an embeddings endpoint and classify the outcome.
|
|
71
71
|
*
|
|
72
|
-
* - 2xx with
|
|
73
|
-
* - 2xx
|
|
74
|
-
* - 2xx
|
|
72
|
+
* - 2xx with two placeable embeddings → `ok` with dimension count
|
|
73
|
+
* - 2xx with invalid indexes or the wrong number of items → `invalid_envelope`
|
|
74
|
+
* - 2xx with a vector differing from a requested `dimensions` → `dimensions_mismatch`
|
|
75
|
+
* - 2xx without usable `data[].embedding` arrays → `endpoint_unsupported` (e.g. routers
|
|
75
76
|
* that accept the URL but don't implement the embeddings spec)
|
|
76
77
|
* - 401 / 403 → `auth_failed`
|
|
77
78
|
* - 404 / 405 → `endpoint_unsupported` (route not available at this URL)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding-probe.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding-probe.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"embedding-probe.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding-probe.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,qBAAqB,GAC3B;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACzD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,qBAAqB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACpF;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,sBAAsB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,MAAM,WAAW,qBAAqB;IAClC;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;sEACkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;4EAEwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACxB;AAKD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,sBAAsB,CACxC,OAAO,EAAE,qBAAqB,GAC/B,OAAO,CAAC,qBAAqB,CAAC,CA4HhC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const INVALID_EMBEDDING_INDEX_MESSAGE = "response data[].index values were missing, duplicated or out of range";
|
|
2
|
+
/**
|
|
3
|
+
* Map each embedding to its input, even when the endpoint reorders its reply.
|
|
4
|
+
* When no item has an `index`, use array order. Otherwise, a missing or
|
|
5
|
+
* undefined `index` means 0: Google's OpenAI-compatible endpoint encodes its
|
|
6
|
+
* replies as proto3 JSON, which leaves out fields whose value is zero. Null is
|
|
7
|
+
* not a missing index. Return null if any index is not an integer, is out of
|
|
8
|
+
* range, or is used more than once.
|
|
9
|
+
*/
|
|
10
|
+
export declare function responseSlots(items: readonly {
|
|
11
|
+
index?: unknown;
|
|
12
|
+
}[], inputCount: number): number[] | null;
|
|
13
|
+
//# sourceMappingURL=embedding-response-slots.d.ts.map
|