@cortexkit/opencode-magic-context 0.49.89 → 0.49.91
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 +4 -4
- package/dist/chunk-embedding-write-worker.js +6 -6
- package/dist/{compartment-chunk-embedding-fey2bsyf.js → compartment-chunk-embedding-rp4asvk0.js} +3 -3
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/migrate-dreamer-v2.d.ts +1 -0
- package/dist/config/migrate-dreamer-v2.d.ts.map +1 -1
- package/dist/{context-grdg1k2k.js → context-6qq5e1ry.js} +716 -216
- package/dist/{embedding-backfill-qjkaee9s.js → embedding-backfill-w0yq71q2.js} +6 -6
- package/dist/embedding-worker.js +3 -3
- package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +2 -2
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/memory/single-store-embedding-drain.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +2 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +2 -2
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-host-runner.d.ts +1 -1
- package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/history-boundary-repair.d.ts +2 -0
- package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-formatting.d.ts +2 -0
- package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
- package/dist/{index-3pdknr07.js → index-0twg41mh.js} +2 -2
- package/dist/{index-2pdgy88n.js → index-3n376ann.js} +19 -7
- package/dist/{index-wmb2mcdw.js → index-3yw525kb.js} +5 -5
- package/dist/{index-mrjat4eq.js → index-5wgdbj2h.js} +3 -3
- package/dist/{index-pxnzyvjc.js → index-6r99v53h.js} +1 -1
- package/dist/{index-9d3qgwq0.js → index-6t7jvp76.js} +3 -3
- package/dist/{index-jzfsnbmm.js → index-7rgnh11t.js} +5 -5
- package/dist/{index-chpzb6xy.js → index-capcna4r.js} +2 -2
- package/dist/{index-1y4y98r1.js → index-czz0w2c4.js} +14 -2
- package/dist/{index-zxhev8ze.js → index-dva352qe.js} +1 -1
- package/dist/{index-dk3hy2a2.js → index-e8my7q6m.js} +10 -10
- package/dist/{index-w51n3576.js → index-f25ha337.js} +1 -1
- package/dist/{index-q7msfgwz.js → index-febyth5n.js} +94 -27
- package/dist/{index-kknjvmpx.js → index-fqth7850.js} +51 -60
- package/dist/{index-60wnwcwz.js → index-gqhebzxx.js} +2 -2
- package/dist/{index-n1ty0vd3.js → index-m6vhxsce.js} +58 -56
- package/dist/{index-m6dnydf8.js → index-mg9s2rc3.js} +1 -1
- package/dist/{index-2qsca7h7.js → index-mq97qmb8.js} +3 -3
- package/dist/{index-78t37mcq.js → index-nmkv8yvs.js} +3 -3
- package/dist/{index-tt0vs4x5.js → index-qna2ra0s.js} +1 -1
- package/dist/{index-qfcjrnpe.js → index-r6r2eh90.js} +4 -4
- package/dist/{index-g0mb2kb4.js → index-ran2b3fn.js} +10 -10
- package/dist/{index-5vsk2cpp.js → index-s7460efs.js} +12 -1
- package/dist/{index-08jfpny9.js → index-sr8dmp7p.js} +1 -1
- package/dist/{index-h9hybzr5.js → index-wfahebsc.js} +5 -5
- package/dist/index-x3rdza40.js +63 -0
- package/dist/{index-60x5d68t.js → index-xn9efn18.js} +1 -1
- package/dist/{index-39rzef89.js → index-ydhymf0b.js} +3 -3
- package/dist/{index-61knrt52.js → index-ywgv1xcb.js} +1 -1
- package/dist/index.js +40 -40
- package/dist/{message-index-bounded-r1qys471.js → message-index-bounded-wvnp6fcp.js} +5 -5
- package/dist/migration-worker.js +4 -4
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/{project-embedding-registry-m3fp1pa4.js → project-embedding-registry-8je0xg18.js} +7 -5
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-xv9f0wgb.js → read-session-chunk-j4hjc1pk.js} +4 -4
- package/dist/{recomp-orchestrator-dgyb394j.js → recomp-orchestrator-ps1c8c5h.js} +19 -18
- package/dist/{render-d014e603.js → render-nfj7280n.js} +13 -13
- package/dist/{search-9gceftb9.js → search-3r8b0jfa.js} +15 -15
- package/dist/{search-archive-gybn6q7s.js → search-archive-1etwnve4.js} +6 -6
- package/dist/shared/model-suggestion-retry.d.ts +18 -0
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/{storage-tags-f1ftvjpw.js → storage-tags-nh2ftqhx.js} +3 -3
- package/dist/{store-n4yz3n66.js → store-019k3ek7.js} +2 -2
- package/dist/{store-reader-nf8z86n9.js → store-reader-a2v34xnh.js} +1 -1
- package/dist/{task-config-qt6n4bxm.js → task-config-vrebjxyy.js} +2 -1
- package/dist/{transform-postprocess-phase-34k1zwsy.js → transform-postprocess-phase-tqp968w4.js} +20 -19
- package/dist/v2/auto-search-worker.js +4 -4
- package/dist/v2/chunk-embedding-write-worker.js +6 -6
- package/dist/v2/{compartment-chunk-embedding-knt2468v.js → compartment-chunk-embedding-w7ht0t9v.js} +3 -3
- package/dist/v2/{context-8bzydxfy.js → context-d57v8c10.js} +753 -253
- package/dist/v2/{embedding-backfill-0ar1bm97.js → embedding-backfill-95m72gxa.js} +6 -6
- package/dist/v2/embedding-worker.js +3 -3
- package/dist/v2/fold/native-replay-v3.d.ts.map +1 -1
- package/dist/v2/fold/native-replay.d.ts +11 -2
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/hidden-child-native.d.ts +1 -1
- package/dist/v2/hidden-child-native.d.ts.map +1 -1
- package/dist/v2/hidden-child-record.d.ts +11 -2
- package/dist/v2/hidden-child-record.d.ts.map +1 -1
- package/dist/v2/hidden-child-sweep.d.ts +3 -0
- package/dist/v2/hidden-child-sweep.d.ts.map +1 -1
- package/dist/v2/hidden-completion.d.ts +4 -0
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hidden-run-holder.d.ts +2 -2
- package/dist/v2/hidden-run-holder.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts +2 -2
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +2 -0
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/revert-message-state.d.ts +19 -1
- package/dist/v2/hooks/revert-message-state.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-b07r9cjv.js → message-index-bounded-2nhbwry6.js} +5 -5
- package/dist/v2/migration-worker.js +4 -4
- package/dist/v2/{project-embedding-registry-gx2waee8.js → project-embedding-registry-fcxf4qht.js} +7 -5
- package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
- package/dist/v2/{read-session-chunk-38wdy8nd.js → read-session-chunk-jrrhwxgx.js} +4 -4
- package/dist/v2/{recomp-orchestrator-wq7gbkqa.js → recomp-orchestrator-n79hdd7n.js} +19 -18
- package/dist/v2/{render-2dan17xc.js → render-7emcjdt1.js} +13 -13
- package/dist/v2/{search-archive-89hdy0a2.js → search-archive-fpjbmxcx.js} +6 -6
- package/dist/v2/{search-nyqykx7q.js → search-vz2cpgr0.js} +14 -14
- package/dist/v2/{server-ytqps2xa.js → server-0h875f56.js} +1 -1
- package/dist/v2/server-3gz9k20t.js +63 -0
- package/dist/v2/{server-ta4h0fch.js → server-3z8rhacq.js} +9 -9
- package/dist/v2/{server-dtcwkdqj.js → server-4axv6kq6.js} +63 -23
- package/dist/v2/{server-c7awk5s2.js → server-4bfk1sky.js} +3 -3
- package/dist/v2/{server-dgjqvpgd.js → server-72k2r3kt.js} +19 -7
- package/dist/v2/{server-pjk9spbf.js → server-7e89a2kf.js} +1 -1
- package/dist/v2/{server-add0j5n3.js → server-8ps3717t.js} +3 -3
- package/dist/v2/{server-a85j3kam.js → server-8r32etq0.js} +1 -1
- package/dist/v2/{server-f7tzvmzs.js → server-b4efn08m.js} +1 -1
- package/dist/v2/{server-y17r5ryz.js → server-barj0mjz.js} +2 -2
- package/dist/v2/{server-yx0nyj1q.js → server-hgfd6c3e.js} +3 -3
- package/dist/v2/{server-qyazxy92.js → server-j9cm1czj.js} +14 -2
- package/dist/v2/{server-9n2qgk29.js → server-kwsqytwj.js} +2 -2
- package/dist/v2/{server-fb5hvvfc.js → server-n431vzn5.js} +3 -3
- package/dist/v2/{server-2kswss3d.js → server-n5wn7d9b.js} +48 -60
- package/dist/v2/{server-x6fn9x8q.js → server-ps6zrzwj.js} +1 -1
- package/dist/v2/{server-pmws7we9.js → server-q104czn6.js} +2 -2
- package/dist/v2/{server-vy0beygw.js → server-q2ap5cty.js} +3 -3
- package/dist/v2/{server-y8xjr8rx.js → server-qb3s0mnc.js} +12 -1
- package/dist/v2/{server-stjy5dxv.js → server-qntmqaca.js} +1 -1
- package/dist/v2/{server-09h2vyvs.js → server-r4816kwv.js} +5 -5
- package/dist/v2/{server-b0a9h3ds.js → server-vfa7byfa.js} +5 -5
- package/dist/v2/{server-tj65pgvg.js → server-vsqmkvxc.js} +32 -5
- package/dist/v2/{server-fn4ky6mn.js → server-xmgvy3cq.js} +1 -1
- package/dist/v2/server.js +4 -3
- package/dist/v2/{storage-tags-pmw33chf.js → storage-tags-t0f9njdp.js} +3 -3
- package/dist/v2/{store-y56y034s.js → store-q3ef5rvz.js} +2 -2
- package/dist/v2/{store-reader-2vhx33n6.js → store-reader-wc01y2rc.js} +1 -1
- package/dist/v2/store-reader.d.ts +2 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{task-config-ex2vajr2.js → task-config-4nqq2s0w.js} +2 -1
- package/dist/v2/{v2-archive-reader-gh1jghf7.js → v2-archive-reader-9p84yzk5.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-2h7ayss9.js → wrapup-orchestrator-acebazx8.js} +19 -18
- package/dist/{v2-archive-reader-8158kyfd.js → v2-archive-reader-w1bbaqe8.js} +1 -1
- package/dist/{wrapup-orchestrator-ct59br0c.js → wrapup-orchestrator-fwbe0mvm.js} +20 -19
- package/package.json +1 -1
- package/src/config/index.test.ts +58 -0
- package/src/config/index.ts +4 -1
- package/src/config/migrate-dreamer-v2.ts +42 -0
- package/src/shared/model-suggestion-retry.test.ts +37 -0
- package/src/shared/model-suggestion-retry.ts +38 -4
- package/src/shared/startup-maintenance-policy.test.ts +11 -6
- package/dist/index-ksdyrrav.js +0 -52
- package/dist/v2/server-0s95v3en.js +0 -49
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
hiddenToolLoop,
|
|
18
18
|
HIDDEN_RUN_DISPOSED_REASON,
|
|
19
19
|
noteChildOfDisposedInstance,
|
|
20
|
+
noteTimedOutHiddenChild,
|
|
20
21
|
hiddenChildPermissions,
|
|
21
22
|
registerHiddenChildAgents,
|
|
22
23
|
hiddenToolCallRefusal,
|
|
@@ -25,8 +26,11 @@ import {
|
|
|
25
26
|
parseProviderModel,
|
|
26
27
|
toModelEntry,
|
|
27
28
|
ModelProducedNoOutputError,
|
|
29
|
+
promptTransportBudget,
|
|
30
|
+
notePromptSetupTimeout,
|
|
28
31
|
noteModelActivityMonitored,
|
|
29
32
|
noteModelOutputReceived,
|
|
33
|
+
isPromptTimeoutError,
|
|
30
34
|
annotateSubagentInvocationError,
|
|
31
35
|
recordChildInvocation,
|
|
32
36
|
CTX_NOTE_LIGHT_DESCRIPTION,
|
|
@@ -44,7 +48,7 @@ import {
|
|
|
44
48
|
resolveOpenCodeProtectedTailBoundary,
|
|
45
49
|
nonNarrativeStoredGapRanges,
|
|
46
50
|
getActiveCompartmentRun
|
|
47
|
-
} from "./index-
|
|
51
|
+
} from "./index-febyth5n.js";
|
|
48
52
|
import"./index-sd3egckz.js";
|
|
49
53
|
import {
|
|
50
54
|
getHarness2
|
|
@@ -69,16 +73,16 @@ import {
|
|
|
69
73
|
resolveKnownHistorianContextLimit2,
|
|
70
74
|
resolveHistorianContextLimit2
|
|
71
75
|
} from "./index-xsqw8kbd.js";
|
|
72
|
-
import"./index-6nqz8hsz.js";
|
|
73
76
|
import {
|
|
77
|
+
isDreamerRunnable,
|
|
78
|
+
isSmartNoteSurfaceAvailable,
|
|
79
|
+
isCompactionEnabled,
|
|
74
80
|
CANONICAL_DREAM_TASKS,
|
|
75
81
|
DREAM_TASK_CAPABILITIES,
|
|
76
82
|
formatUnsupportedDreamTasks,
|
|
77
|
-
isCanonicalDreamTask
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
userObservationsRequested2
|
|
81
|
-
} from "./index-kknjvmpx.js";
|
|
83
|
+
isCanonicalDreamTask
|
|
84
|
+
} from "./index-fqth7850.js";
|
|
85
|
+
import"./index-6nqz8hsz.js";
|
|
82
86
|
import {
|
|
83
87
|
logConfigDependencyNotesOnce,
|
|
84
88
|
runSessionProjectBackfill,
|
|
@@ -136,7 +140,7 @@ import {
|
|
|
136
140
|
applyJsonSchemaParameterDescriptions,
|
|
137
141
|
MagicContextRpcServer,
|
|
138
142
|
subagentTemperature
|
|
139
|
-
} from "./index-
|
|
143
|
+
} from "./index-m6vhxsce.js";
|
|
140
144
|
import {
|
|
141
145
|
invalidateAutoEmbedSession,
|
|
142
146
|
clearEmbedSessionState
|
|
@@ -145,8 +149,8 @@ import {
|
|
|
145
149
|
hasMeaningfulUserText2,
|
|
146
150
|
preloadTokenizer,
|
|
147
151
|
estimateTokens
|
|
148
|
-
} from "./index-
|
|
149
|
-
import"./index-
|
|
152
|
+
} from "./index-s7460efs.js";
|
|
153
|
+
import"./index-6r99v53h.js";
|
|
150
154
|
import {
|
|
151
155
|
inRootAsyncContext2,
|
|
152
156
|
withSqliteTransformPass2,
|
|
@@ -161,7 +165,7 @@ import"./index-q7q6qp1f.js";
|
|
|
161
165
|
import"./index-s32f8y67.js";
|
|
162
166
|
import {
|
|
163
167
|
deleteChunkEmbedBackoffForSession2
|
|
164
|
-
} from "./index-
|
|
168
|
+
} from "./index-0twg41mh.js";
|
|
165
169
|
import {
|
|
166
170
|
advanceSessionActivity,
|
|
167
171
|
backfillSessionActivity,
|
|
@@ -169,6 +173,7 @@ import {
|
|
|
169
173
|
releaseCompartmentLeaseBestEffort,
|
|
170
174
|
isCompartmentLeaseHeld,
|
|
171
175
|
queueM0Mutation,
|
|
176
|
+
getLastCompartmentEndMessageId,
|
|
172
177
|
clearRecompStaging,
|
|
173
178
|
getUncoveredCompartmentEndsThrough,
|
|
174
179
|
readServerFallbackUsage,
|
|
@@ -198,8 +203,8 @@ import {
|
|
|
198
203
|
getSlot,
|
|
199
204
|
dropSlot,
|
|
200
205
|
copySessionStateForClone
|
|
201
|
-
} from "./index-
|
|
202
|
-
import"./index-
|
|
206
|
+
} from "./index-wfahebsc.js";
|
|
207
|
+
import"./index-capcna4r.js";
|
|
203
208
|
import {
|
|
204
209
|
stripPersistedAssistantText,
|
|
205
210
|
currentReclaimableToolOutputCount,
|
|
@@ -241,16 +246,21 @@ import {
|
|
|
241
246
|
estimateFinalWireInputTokens,
|
|
242
247
|
getMaxTagNumberBySession2,
|
|
243
248
|
getTagsBySession2
|
|
244
|
-
} from "./index-
|
|
249
|
+
} from "./index-gqhebzxx.js";
|
|
245
250
|
import {
|
|
246
251
|
BoundedSessionMap,
|
|
247
252
|
getTableColumnNames,
|
|
248
253
|
recordToolDefinitionSet,
|
|
249
254
|
getCurrentToolSetHash
|
|
250
|
-
} from "./index-
|
|
255
|
+
} from "./index-mg9s2rc3.js";
|
|
251
256
|
import {
|
|
252
257
|
resolveHistorianModel2
|
|
253
258
|
} from "./index-5kym00ag.js";
|
|
259
|
+
import {
|
|
260
|
+
buildDreamTaskRuntimeConfigs2,
|
|
261
|
+
userObservationCollectionEnabled2,
|
|
262
|
+
userObservationsRequested2
|
|
263
|
+
} from "./index-x3rdza40.js";
|
|
254
264
|
import {
|
|
255
265
|
formatFailClosedBlockingMessage,
|
|
256
266
|
formatFailClosedBlockingSummary,
|
|
@@ -279,10 +289,10 @@ import {
|
|
|
279
289
|
cleanUserText2,
|
|
280
290
|
readRawSessionMessageIdOrdinalsForRange2,
|
|
281
291
|
readRawSessionMessageOrdinalById2
|
|
282
|
-
} from "./index-
|
|
292
|
+
} from "./index-mq97qmb8.js";
|
|
283
293
|
import {
|
|
284
294
|
scheduleClearAndReindex
|
|
285
|
-
} from "./index-
|
|
295
|
+
} from "./index-dva352qe.js";
|
|
286
296
|
import {
|
|
287
297
|
startBootDeadline,
|
|
288
298
|
getSchemaFenceRejection,
|
|
@@ -292,17 +302,17 @@ import {
|
|
|
292
302
|
openDatabaseAsync,
|
|
293
303
|
isDatabasePersisted,
|
|
294
304
|
getDatabasePersistenceError
|
|
295
|
-
} from "./index-
|
|
305
|
+
} from "./index-5wgdbj2h.js";
|
|
296
306
|
import"./index-fr0wbhdn.js";
|
|
297
|
-
import"./index-
|
|
307
|
+
import"./index-qna2ra0s.js";
|
|
298
308
|
import {
|
|
299
309
|
gaDatabasePath2,
|
|
300
310
|
RAW_MESSAGE_TYPES2,
|
|
301
311
|
V2StoreReaderPool2,
|
|
302
312
|
V2StoreReader2
|
|
303
|
-
} from "./index-
|
|
313
|
+
} from "./index-czz0w2c4.js";
|
|
304
314
|
import"./index-fb3zxn06.js";
|
|
305
|
-
import"./index-
|
|
315
|
+
import"./index-ywgv1xcb.js";
|
|
306
316
|
import {
|
|
307
317
|
resolveContextLimit,
|
|
308
318
|
resolveModelKey,
|
|
@@ -320,20 +330,20 @@ import {
|
|
|
320
330
|
servedHeadChanged,
|
|
321
331
|
noteHostCheckpointCommit,
|
|
322
332
|
isSyntheticHeadMessage2
|
|
323
|
-
} from "./index-
|
|
333
|
+
} from "./index-ran2b3fn.js";
|
|
324
334
|
import"./index-832w615x.js";
|
|
325
335
|
import"./index-qt1qqasc.js";
|
|
326
336
|
import {
|
|
327
337
|
retainProjectEmbedding2
|
|
328
|
-
} from "./index-
|
|
338
|
+
} from "./index-3n376ann.js";
|
|
329
339
|
import"./index-r4y0dczp.js";
|
|
330
340
|
import"./index-qjwpqvnf.js";
|
|
331
|
-
import"./index-
|
|
341
|
+
import"./index-xn9efn18.js";
|
|
332
342
|
import {
|
|
333
343
|
renderUserFacingFailure,
|
|
334
344
|
userFacingFailureCode
|
|
335
|
-
} from "./index-
|
|
336
|
-
import"./index-
|
|
345
|
+
} from "./index-ydhymf0b.js";
|
|
346
|
+
import"./index-f25ha337.js";
|
|
337
347
|
import"./index-9emdjcb5.js";
|
|
338
348
|
import {
|
|
339
349
|
pushLiveNotification2,
|
|
@@ -342,8 +352,8 @@ import {
|
|
|
342
352
|
} from "./index-y14pawe1.js";
|
|
343
353
|
import"./index-e6ncz7a6.js";
|
|
344
354
|
import"./index-6zewd2n5.js";
|
|
345
|
-
import"./index-
|
|
346
|
-
import"./index-
|
|
355
|
+
import"./index-e8my7q6m.js";
|
|
356
|
+
import"./index-r6r2eh90.js";
|
|
347
357
|
import"./index-cr483vx6.js";
|
|
348
358
|
import {
|
|
349
359
|
detectConflicts
|
|
@@ -373,17 +383,12 @@ import {
|
|
|
373
383
|
readV2RawMessagePagesForConversion2,
|
|
374
384
|
createV2RawMessageReader2,
|
|
375
385
|
createV2RawMessageProvider2
|
|
376
|
-
} from "./index-
|
|
386
|
+
} from "./index-sr8dmp7p.js";
|
|
377
387
|
import"./index-fmsr7v69.js";
|
|
378
|
-
import"./index-
|
|
388
|
+
import"./index-nmkv8yvs.js";
|
|
379
389
|
import"./index-52x68mj4.js";
|
|
380
|
-
import"./index-
|
|
381
|
-
import"./index-
|
|
382
|
-
import {
|
|
383
|
-
isDreamerRunnable,
|
|
384
|
-
isSmartNoteSurfaceAvailable,
|
|
385
|
-
isCompactionEnabled
|
|
386
|
-
} from "./index-ksdyrrav.js";
|
|
390
|
+
import"./index-7rgnh11t.js";
|
|
391
|
+
import"./index-6t7jvp76.js";
|
|
387
392
|
import {
|
|
388
393
|
markHostInstructionRow,
|
|
389
394
|
hostInstructionRow,
|
|
@@ -494,6 +499,49 @@ function dropCompartmentsAfter(db, sessionId, anchor, holderId, activeBranch = f
|
|
|
494
499
|
}
|
|
495
500
|
function repairMissingHistoryBoundary(args) {
|
|
496
501
|
const { db, sessionId, isInHostStore, scope = "store" } = args;
|
|
502
|
+
const removed = args.removedByCommittedRevert;
|
|
503
|
+
if (removed) {
|
|
504
|
+
const firstRemoved = removed.values().next().value;
|
|
505
|
+
if (firstRemoved === undefined)
|
|
506
|
+
return { kind: "intact" };
|
|
507
|
+
const busy = {
|
|
508
|
+
kind: "unresolved",
|
|
509
|
+
reason: "busy",
|
|
510
|
+
missingEndMessageId: firstRemoved
|
|
511
|
+
};
|
|
512
|
+
const holderId = crypto.randomUUID();
|
|
513
|
+
if (getActiveCompartmentRun(sessionId) || !acquireCompartmentLease(db, sessionId, holderId))
|
|
514
|
+
return busy;
|
|
515
|
+
try {
|
|
516
|
+
const boundaries = readStoreBoundaries(db, sessionId);
|
|
517
|
+
const first = boundaries.findIndex(({ endMessageId }) => removed.has(endMessageId));
|
|
518
|
+
const affected = boundaries[first];
|
|
519
|
+
if (!affected)
|
|
520
|
+
return { kind: "intact" };
|
|
521
|
+
const previous = boundaries[first - 1];
|
|
522
|
+
let anchor = null;
|
|
523
|
+
if (previous) {
|
|
524
|
+
const row = db.prepare("SELECT end_message AS endMessage FROM compartments WHERE session_id = ? AND sequence = ?").get(sessionId, previous.sequence);
|
|
525
|
+
if (!row)
|
|
526
|
+
return busy;
|
|
527
|
+
anchor = { ...previous, endMessage: row.endMessage };
|
|
528
|
+
}
|
|
529
|
+
const dropped = dropCompartmentsAfter(db, sessionId, anchor, holderId, false, () => args.onRetire?.(boundaries.slice(first), anchor));
|
|
530
|
+
if (dropped === null)
|
|
531
|
+
return busy;
|
|
532
|
+
invalidateAutoEmbedSession(sessionId);
|
|
533
|
+
forgetCachedPrefix(sessionId);
|
|
534
|
+
sessionLog2(sessionId, `committed revert history repair: removed compartments ${dropped.join(",")} and cleared the cached history; removed boundary ${affected.endMessageId}`);
|
|
535
|
+
return {
|
|
536
|
+
kind: "repaired",
|
|
537
|
+
missingEndMessageId: affected.endMessageId,
|
|
538
|
+
anchorEndMessageId: anchor?.endMessageId ?? "",
|
|
539
|
+
droppedSequences: dropped
|
|
540
|
+
};
|
|
541
|
+
} finally {
|
|
542
|
+
releaseCompartmentLeaseBestEffort(db, sessionId, holderId);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
497
545
|
const compartments = scope === "active-branch" ? db.prepare("SELECT sequence, COALESCE(end_message_id, '') AS endMessageId FROM compartments WHERE session_id = ? ORDER BY sequence").all(sessionId) : readStoreBoundaries(db, sessionId);
|
|
498
546
|
let latestIndex = compartments.length - 1;
|
|
499
547
|
while (latestIndex >= 0 && !compartments[latestIndex]?.endMessageId)
|
|
@@ -2115,7 +2163,13 @@ function importedFloor(reader, sessionID, through = reader.latestSequence(sessio
|
|
|
2115
2163
|
let after = -1;
|
|
2116
2164
|
let found;
|
|
2117
2165
|
while (true) {
|
|
2118
|
-
const page = reader.page(sessionID, {
|
|
2166
|
+
const page = reader.page(sessionID, {
|
|
2167
|
+
after,
|
|
2168
|
+
through,
|
|
2169
|
+
type: "compaction",
|
|
2170
|
+
limit: 1000,
|
|
2171
|
+
preferTypeIndex: true
|
|
2172
|
+
});
|
|
2119
2173
|
if (!page.rows.length)
|
|
2120
2174
|
break;
|
|
2121
2175
|
for (const row of page.rows) {
|
|
@@ -2401,15 +2455,33 @@ class NativeFoldReplay {
|
|
|
2401
2455
|
this.options.log?.(sessionID, `v3 host fold: ${reason}`);
|
|
2402
2456
|
} catch {}
|
|
2403
2457
|
}
|
|
2458
|
+
historyCoverage(sessionID, reader) {
|
|
2459
|
+
if (!this.options.rendersHistory?.(sessionID))
|
|
2460
|
+
return;
|
|
2461
|
+
const db = this.storage.db;
|
|
2462
|
+
const cached = db.prepare("SELECT cached_m0_last_baseline_end_message_id AS id, cached_m0_bytes IS NOT NULL AS hasBytes FROM session_meta WHERE session_id=?").get(sessionID);
|
|
2463
|
+
const id = cached?.hasBytes ? cached.id : getLastCompartmentEndMessageId(db, sessionID);
|
|
2464
|
+
const after = id ? reader.sequenceForId(sessionID, id) : (reader.earliestSequence(sessionID) ?? 0) - 1;
|
|
2465
|
+
return after === undefined ? undefined : { id, after };
|
|
2466
|
+
}
|
|
2467
|
+
floorCovered(sessionID, floor, coverage, record) {
|
|
2468
|
+
if (!coverage || floor.kind === "start" || floor.kind === "host-checkpoint" && !record?.withoutRecentContext && this.options.servesHostCheckpoint?.(sessionID, floor.id) || floor.after <= coverage.after)
|
|
2469
|
+
return true;
|
|
2470
|
+
this.options.onUncoveredFloor?.(sessionID, floor, coverage);
|
|
2471
|
+
return false;
|
|
2472
|
+
}
|
|
2404
2473
|
async floorState(sessionID, reader, boundary, served, preferCapture = false) {
|
|
2474
|
+
const coverage = this.historyCoverage(sessionID, reader);
|
|
2405
2475
|
const retained = this.tail(sessionID)?.replay;
|
|
2406
2476
|
const controlsKnown = (replay) => replay.controls.every((control) => !control.after || reader.sequenceForId(sessionID, control.after) !== undefined);
|
|
2407
|
-
const memory = retained && validReplayState(retained) && controlsKnown(retained) && validFloor(reader, sessionID, retained.floor) ? retained : undefined;
|
|
2477
|
+
const memory = retained && validReplayState(retained) && controlsKnown(retained) && validFloor(reader, sessionID, retained.floor) && this.floorCovered(sessionID, retained.floor, coverage, retained) ? retained : undefined;
|
|
2408
2478
|
const cut = reader.latestCompaction(sessionID);
|
|
2409
2479
|
const saved = await this.readV3(sessionID);
|
|
2410
|
-
const durable = saved && saved.proof.sourceDigest === foldDigest(reader.hostIdentity()) && (!cut || saved.proof.admissionID === cut.id) && controlsKnown(saved.replay) && validFloor(reader, sessionID, saved.replay.floor) ? saved.replay : undefined;
|
|
2411
|
-
const
|
|
2412
|
-
const
|
|
2480
|
+
const durable = saved && saved.proof.sourceDigest === foldDigest(reader.hostIdentity()) && (!cut || saved.proof.admissionID === cut.id) && controlsKnown(saved.replay) && validFloor(reader, sessionID, saved.replay.floor) && this.floorCovered(sessionID, saved.replay.floor, coverage, saved.replay) ? saved.replay : undefined;
|
|
2481
|
+
const marker = importedFloor(reader, sessionID, cut?.seq);
|
|
2482
|
+
const imported = marker && this.floorCovered(sessionID, marker, coverage) ? marker : undefined;
|
|
2483
|
+
const capturedRecord = await this.readCapturedReplay(sessionID, reader);
|
|
2484
|
+
const captured = capturedRecord && this.floorCovered(sessionID, capturedRecord.floor, coverage, capturedRecord) ? capturedRecord : undefined;
|
|
2413
2485
|
const existing = preferCapture ? captured ?? memory ?? durable : memory ?? durable ?? captured;
|
|
2414
2486
|
if (preferCapture && !existing && !served)
|
|
2415
2487
|
return;
|
|
@@ -2716,6 +2788,8 @@ ${cached}
|
|
|
2716
2788
|
await this.retainReplay(sessionID, replay, this.tail(sessionID)?.model ?? "", cut.seq - 1);
|
|
2717
2789
|
return false;
|
|
2718
2790
|
}
|
|
2791
|
+
if (!this.floorCovered(sessionID, replay.floor, this.historyCoverage(sessionID, reader), replay))
|
|
2792
|
+
return false;
|
|
2719
2793
|
await this.retainReplay(sessionID, saved.replay, this.tail(sessionID)?.model ?? "", cut.seq - 1);
|
|
2720
2794
|
if (proof.historyDigest !== historyDigest(reader, sessionID, cut.seq - 1, saved.replay.floor.after)) {
|
|
2721
2795
|
this.staleHeads.add(sessionID);
|
|
@@ -2810,7 +2884,7 @@ ${cached}
|
|
|
2810
2884
|
return "legacy";
|
|
2811
2885
|
if (saved.proof.admissionID !== cut.id)
|
|
2812
2886
|
return "legacy";
|
|
2813
|
-
return saved.proof.sourceDigest === foldDigest(reader.hostIdentity()) && saved.proof.summaryDigest === foldDigest(cut.data.summary ?? "") && validFloor(reader, sessionID, saved.replay.floor) && saved.proof.historyDigest === historyDigest(reader, sessionID, cut.seq - 1, saved.replay.floor.after) ? "native" : undefined;
|
|
2887
|
+
return saved.proof.sourceDigest === foldDigest(reader.hostIdentity()) && saved.proof.summaryDigest === foldDigest(cut.data.summary ?? "") && validFloor(reader, sessionID, saved.replay.floor) && this.floorCovered(sessionID, saved.replay.floor, this.historyCoverage(sessionID, reader), saved.replay) && saved.proof.historyDigest === historyDigest(reader, sessionID, cut.seq - 1, saved.replay.floor.after) ? "native" : undefined;
|
|
2814
2888
|
}
|
|
2815
2889
|
if (!isLocalCheckpoint(cut) || cut.session_id !== sessionID)
|
|
2816
2890
|
return;
|
|
@@ -2977,7 +3051,7 @@ ${cached}
|
|
|
2977
3051
|
}
|
|
2978
3052
|
return [...grouped].map(([row, messages]) => this.record(row, messages));
|
|
2979
3053
|
}
|
|
2980
|
-
async capture(draft, native, boundary) {
|
|
3054
|
+
async capture(draft, native, boundary, restoredFirstRow) {
|
|
2981
3055
|
const release = this.storage.hold(draft.sessionID);
|
|
2982
3056
|
let replay;
|
|
2983
3057
|
let sourceSeq = -1;
|
|
@@ -2987,6 +3061,11 @@ ${cached}
|
|
|
2987
3061
|
try {
|
|
2988
3062
|
if (this.options.protocol === 3) {
|
|
2989
3063
|
replay = await this.floorState(draft.sessionID, reader, boundary, draft);
|
|
3064
|
+
if (!replay && restoredFirstRow) {
|
|
3065
|
+
const first = reader.page(draft.sessionID, { limit: 1 }).rows[0];
|
|
3066
|
+
if (first?.id === restoredFirstRow)
|
|
3067
|
+
replay = { floor: floorFor(first, "start"), controls: [] };
|
|
3068
|
+
}
|
|
2990
3069
|
if (!replay)
|
|
2991
3070
|
throw new NativeReplayUnavailable("No usable host replay boundary");
|
|
2992
3071
|
replay = { ...replay, blocked: false };
|
|
@@ -3054,7 +3133,7 @@ ${cached}
|
|
|
3054
3133
|
await this.saveCapturedReplay(draft.sessionID, replay, reader);
|
|
3055
3134
|
const saved = await this.readV3(draft.sessionID);
|
|
3056
3135
|
const cut = reader.latestCompaction(draft.sessionID);
|
|
3057
|
-
if (saved && !this.editedAdmissions.has(draft.sessionID) && cut?.id === saved.proof.admissionID && replay.floor.after > saved.replay.floor.after && boundary && this.servedBaseline(draft) === boundary.summary) {
|
|
3136
|
+
if (saved && !this.editedAdmissions.has(draft.sessionID) && cut?.id === saved.proof.admissionID && (replay.floor.after > saved.replay.floor.after || !this.floorCovered(draft.sessionID, saved.replay.floor, this.historyCoverage(draft.sessionID, reader), saved.replay)) && (boundary && this.servedBaseline(draft) === boundary.summary || replay.floor.kind === "start" && restoredFirstRow === replay.floor.id)) {
|
|
3058
3137
|
const value = {
|
|
3059
3138
|
...saved,
|
|
3060
3139
|
replay: {
|
|
@@ -3305,11 +3384,12 @@ ${cached}
|
|
|
3305
3384
|
}
|
|
3306
3385
|
const through = cut.seq - 1;
|
|
3307
3386
|
let metadata = this.metadata.get(sessionID);
|
|
3308
|
-
if (!metadata || (this.metadataThrough.get(sessionID) ?? -1) < through) {
|
|
3387
|
+
if (!metadata || (this.metadataThrough.get(sessionID) ?? -1) < through || this.options.protocol === 3 && this.options.rendersHistory?.(sessionID) && (this.metadataAfter.get(sessionID) ?? -1) > after) {
|
|
3309
3388
|
reader ??= this.openReader(sessionID);
|
|
3310
3389
|
metadata = reader.rowStampsThrough(sessionID, through, this.options.protocol === 3 ? after : undefined).filter(conversational);
|
|
3311
3390
|
this.metadata.set(sessionID, metadata);
|
|
3312
3391
|
this.metadataThrough.set(sessionID, through);
|
|
3392
|
+
this.metadataAfter.set(sessionID, this.options.protocol === 3 ? after : undefined);
|
|
3313
3393
|
}
|
|
3314
3394
|
const required = metadata.filter((row) => row.seq > after && row.seq <= through);
|
|
3315
3395
|
if (this.dirty.has(sessionID) || !tail || (this.loaded.get(sessionID) ?? -1) < through && !this.storage.admission(sessionID, cut.id) || !this.storage.containsRows(sessionID, required.map((row) => row.id))) {
|
|
@@ -3811,6 +3891,10 @@ var SWEEP_BUDGET_MS = 30000;
|
|
|
3811
3891
|
function recordHiddenChild(db, child) {
|
|
3812
3892
|
db.prepare("INSERT INTO schema_migrations_meta (key, value) VALUES (?, ?)").run(`${PREFIX}${child.id}`, JSON.stringify(child));
|
|
3813
3893
|
}
|
|
3894
|
+
function recordRetiringHiddenChild(db, child) {
|
|
3895
|
+
db.prepare(`INSERT INTO schema_migrations_meta (key, value) VALUES (?, ?)
|
|
3896
|
+
ON CONFLICT(key) DO UPDATE SET value = json_set(value, '$.retiring', json('true'))`).run(`${PREFIX}${child.id}`, JSON.stringify({ ...child, retiring: true }));
|
|
3897
|
+
}
|
|
3814
3898
|
function forgetHiddenChild(db, id) {
|
|
3815
3899
|
db.prepare("DELETE FROM schema_migrations_meta WHERE key = ?").run(`${PREFIX}${id}`);
|
|
3816
3900
|
}
|
|
@@ -3917,6 +4001,20 @@ function isSessionNotFound(error) {
|
|
|
3917
4001
|
function createNativeHiddenChildren(host, removeSession, options) {
|
|
3918
4002
|
const quiet = supportsQuietHiddenChildren(options.hostVersion);
|
|
3919
4003
|
const removing = new Map;
|
|
4004
|
+
const removeBounded = async (id, timeoutMs = options.removalTimeoutMs ?? 5000) => {
|
|
4005
|
+
let timer;
|
|
4006
|
+
try {
|
|
4007
|
+
await Promise.race([
|
|
4008
|
+
removeSession({ sessionID: id }),
|
|
4009
|
+
new Promise((_, reject) => {
|
|
4010
|
+
timer = setTimeout(() => reject(new Error("session.remove timed out")), timeoutMs);
|
|
4011
|
+
})
|
|
4012
|
+
]);
|
|
4013
|
+
} finally {
|
|
4014
|
+
if (timer)
|
|
4015
|
+
clearTimeout(timer);
|
|
4016
|
+
}
|
|
4017
|
+
};
|
|
3920
4018
|
const remove = (child) => {
|
|
3921
4019
|
const inFlight = removing.get(child.id);
|
|
3922
4020
|
if (inFlight)
|
|
@@ -3924,18 +4022,7 @@ function createNativeHiddenChildren(host, removeSession, options) {
|
|
|
3924
4022
|
options.log(`[magic-context] hidden child ${child.id} removing`);
|
|
3925
4023
|
const done = (async () => {
|
|
3926
4024
|
try {
|
|
3927
|
-
|
|
3928
|
-
try {
|
|
3929
|
-
await Promise.race([
|
|
3930
|
-
removeSession({ sessionID: child.id }),
|
|
3931
|
-
new Promise((_, reject) => {
|
|
3932
|
-
timer = setTimeout(() => reject(new Error("session.remove timed out")), options.removalTimeoutMs ?? 5000);
|
|
3933
|
-
})
|
|
3934
|
-
]);
|
|
3935
|
-
} finally {
|
|
3936
|
-
if (timer)
|
|
3937
|
-
clearTimeout(timer);
|
|
3938
|
-
}
|
|
4025
|
+
await removeBounded(child.id);
|
|
3939
4026
|
forgetHiddenChild(options.db, child.id);
|
|
3940
4027
|
options.log(`[magic-context] hidden child ${child.id} removed`);
|
|
3941
4028
|
} catch (error) {
|
|
@@ -3956,18 +4043,52 @@ function createNativeHiddenChildren(host, removeSession, options) {
|
|
|
3956
4043
|
removing.set(child.id, done);
|
|
3957
4044
|
return done;
|
|
3958
4045
|
};
|
|
3959
|
-
const
|
|
4046
|
+
const retireLate = async (id, directory, createdAt, cleanupMs) => {
|
|
4047
|
+
noteTimedOutHiddenChild(id);
|
|
4048
|
+
liveChildren.delete(id);
|
|
4049
|
+
try {
|
|
4050
|
+
recordRetiringHiddenChild(options.db, { id, directory, created_at: createdAt });
|
|
4051
|
+
} catch (error) {
|
|
4052
|
+
const kind = error instanceof Error ? error.constructor.name : typeof error;
|
|
4053
|
+
options.log(`[magic-context] late hidden child ${id} record failed (${kind})`);
|
|
4054
|
+
}
|
|
4055
|
+
try {
|
|
4056
|
+
await removeBounded(id, cleanupMs);
|
|
4057
|
+
} catch (error) {
|
|
4058
|
+
if (!isSessionNotFound(error)) {
|
|
4059
|
+
options.log(`[magic-context] late hidden child ${id} could not be removed`);
|
|
4060
|
+
return;
|
|
4061
|
+
}
|
|
4062
|
+
}
|
|
4063
|
+
try {
|
|
4064
|
+
forgetHiddenChild(options.db, id);
|
|
4065
|
+
} catch {}
|
|
4066
|
+
};
|
|
4067
|
+
const create = async (identity, role, model, budget) => {
|
|
3960
4068
|
const input = childCreateInput(identity, role, model);
|
|
3961
4069
|
const directory = identity.directory;
|
|
3962
4070
|
if (quiet) {
|
|
3963
4071
|
if (!host.createHolder)
|
|
3964
4072
|
throw new Error("OpenCode 2 background holder API is not wired");
|
|
3965
|
-
const placement = await hiddenRunPlacement(host.createHolder, directory);
|
|
4073
|
+
const placement = await hiddenRunPlacement(host.createHolder, directory, budget);
|
|
3966
4074
|
input.id = placement.id;
|
|
3967
4075
|
input.parentID = placement.parentID;
|
|
3968
4076
|
delete input.location;
|
|
3969
4077
|
}
|
|
3970
|
-
|
|
4078
|
+
budget?.setStage("creating the child session");
|
|
4079
|
+
const start = () => host.create(input);
|
|
4080
|
+
const removeLate = ({ id }) => {
|
|
4081
|
+
if (!id || !budget)
|
|
4082
|
+
return;
|
|
4083
|
+
retireLate(id, directory, Date.now(), budget.cleanupMs);
|
|
4084
|
+
};
|
|
4085
|
+
const created = await (budget?.work(start, removeLate) ?? start());
|
|
4086
|
+
try {
|
|
4087
|
+
budget?.check();
|
|
4088
|
+
} catch (error) {
|
|
4089
|
+
removeLate(created);
|
|
4090
|
+
throw error;
|
|
4091
|
+
}
|
|
3971
4092
|
if (!created.id)
|
|
3972
4093
|
throw new Error("OpenCode 2 did not return a child session id");
|
|
3973
4094
|
const createdAt = Date.now();
|
|
@@ -3982,20 +4103,12 @@ function createNativeHiddenChildren(host, removeSession, options) {
|
|
|
3982
4103
|
});
|
|
3983
4104
|
} catch (storeError) {
|
|
3984
4105
|
let removed = false;
|
|
3985
|
-
let timer;
|
|
3986
4106
|
try {
|
|
3987
|
-
await
|
|
3988
|
-
removeSession({ sessionID: created.id }),
|
|
3989
|
-
new Promise((_, reject) => {
|
|
3990
|
-
timer = setTimeout(() => reject(new Error("session.remove timed out")), options.removalTimeoutMs ?? 5000);
|
|
3991
|
-
})
|
|
3992
|
-
]);
|
|
4107
|
+
await removeBounded(created.id);
|
|
3993
4108
|
removed = true;
|
|
3994
4109
|
} catch (error) {
|
|
3995
4110
|
removed = isSessionNotFound(error);
|
|
3996
4111
|
} finally {
|
|
3997
|
-
if (timer)
|
|
3998
|
-
clearTimeout(timer);
|
|
3999
4112
|
liveChildren.delete(created.id);
|
|
4000
4113
|
}
|
|
4001
4114
|
options.log(`[magic-context] hidden child ${created.id} record failed; removed=${removed}: ${errorText(storeError)}`);
|
|
@@ -4023,6 +4136,9 @@ function createNativeHiddenChildren(host, removeSession, options) {
|
|
|
4023
4136
|
return {
|
|
4024
4137
|
open: create,
|
|
4025
4138
|
create,
|
|
4139
|
+
retireLate(child, cleanupMs) {
|
|
4140
|
+
retireLate(child.id, child.directory ?? "", child.created_at, cleanupMs);
|
|
4141
|
+
},
|
|
4026
4142
|
retire(child) {
|
|
4027
4143
|
if (kept(child)) {
|
|
4028
4144
|
liveChildren.delete(child.id);
|
|
@@ -4121,17 +4237,83 @@ async function cleanupLegacyHiddenChildren(db, remove, note, options = {}) {
|
|
|
4121
4237
|
|
|
4122
4238
|
// src/v2/hidden-completion.ts
|
|
4123
4239
|
var DEFAULT_DISPOSE_DRAIN_MS = 2000;
|
|
4240
|
+
|
|
4241
|
+
class HiddenWorkTimeout extends Error {
|
|
4242
|
+
constructor(timeoutMs) {
|
|
4243
|
+
super(`prompt timed out after ${timeoutMs}ms`);
|
|
4244
|
+
}
|
|
4245
|
+
}
|
|
4246
|
+
|
|
4247
|
+
class HiddenSetupTimeout extends HiddenCompletionRefusal {
|
|
4248
|
+
constructor(stage) {
|
|
4249
|
+
super("hidden_setup_timeout", `Hidden completion setup timed out while ${stage}`, true);
|
|
4250
|
+
}
|
|
4251
|
+
}
|
|
4252
|
+
|
|
4253
|
+
class HiddenWorkAborted extends Error {
|
|
4254
|
+
constructor() {
|
|
4255
|
+
super("Hidden completion prompt aborted");
|
|
4256
|
+
}
|
|
4257
|
+
}
|
|
4258
|
+
function setupBudget(deadline, timeout, signal) {
|
|
4259
|
+
let stage = "preparing the attempt";
|
|
4260
|
+
let lost;
|
|
4261
|
+
const check = () => {
|
|
4262
|
+
if (lost)
|
|
4263
|
+
throw lost;
|
|
4264
|
+
if (Date.now() >= deadline)
|
|
4265
|
+
throw lost = timeout(stage);
|
|
4266
|
+
if (signal?.aborted)
|
|
4267
|
+
throw lost = new HiddenWorkAborted;
|
|
4268
|
+
};
|
|
4269
|
+
return {
|
|
4270
|
+
check,
|
|
4271
|
+
setStage: (value) => {
|
|
4272
|
+
stage = value;
|
|
4273
|
+
},
|
|
4274
|
+
get stage() {
|
|
4275
|
+
return stage;
|
|
4276
|
+
},
|
|
4277
|
+
cleanupMs: DEFAULT_DISPOSE_DRAIN_MS,
|
|
4278
|
+
async work(start, onLate) {
|
|
4279
|
+
check();
|
|
4280
|
+
let timer;
|
|
4281
|
+
let abort;
|
|
4282
|
+
try {
|
|
4283
|
+
return await Promise.race([
|
|
4284
|
+
start().then((result) => {
|
|
4285
|
+
try {
|
|
4286
|
+
check();
|
|
4287
|
+
} catch (error) {
|
|
4288
|
+
onLate?.(result);
|
|
4289
|
+
throw error;
|
|
4290
|
+
}
|
|
4291
|
+
return result;
|
|
4292
|
+
}),
|
|
4293
|
+
new Promise((_, reject) => {
|
|
4294
|
+
timer = setTimeout(() => reject(lost ??= timeout(stage)), Math.max(0, deadline - Date.now()));
|
|
4295
|
+
abort = () => reject(lost ??= new HiddenWorkAborted);
|
|
4296
|
+
if (signal?.aborted)
|
|
4297
|
+
abort();
|
|
4298
|
+
else
|
|
4299
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
4300
|
+
})
|
|
4301
|
+
]);
|
|
4302
|
+
} finally {
|
|
4303
|
+
clearTimeout(timer);
|
|
4304
|
+
if (abort)
|
|
4305
|
+
signal?.removeEventListener("abort", abort);
|
|
4306
|
+
}
|
|
4307
|
+
}
|
|
4308
|
+
};
|
|
4309
|
+
}
|
|
4124
4310
|
async function settleWithin(work, ms) {
|
|
4125
4311
|
let timer;
|
|
4126
4312
|
try {
|
|
4127
|
-
await Promise.race([
|
|
4128
|
-
work.then(() =>
|
|
4129
|
-
return;
|
|
4130
|
-
}, () => {
|
|
4131
|
-
return;
|
|
4132
|
-
}),
|
|
4313
|
+
return await Promise.race([
|
|
4314
|
+
work.then(() => true, () => true),
|
|
4133
4315
|
new Promise((resolve) => {
|
|
4134
|
-
timer = setTimeout(resolve, Math.max(0, ms));
|
|
4316
|
+
timer = setTimeout(() => resolve(false), Math.max(0, ms));
|
|
4135
4317
|
})
|
|
4136
4318
|
]);
|
|
4137
4319
|
} finally {
|
|
@@ -4328,8 +4510,9 @@ function isProviderFailure(error) {
|
|
|
4328
4510
|
const type = error.type;
|
|
4329
4511
|
return typeof type === "string" && (type.startsWith("provider.") || type.toLowerCase().includes("provider"));
|
|
4330
4512
|
}
|
|
4331
|
-
async function awaitAssistantRow(openReader, readSessionError, localFailure, childID, afterSeq, deadline, signal) {
|
|
4513
|
+
async function awaitAssistantRow(openReader, readSessionError, localFailure, childID, afterSeq, deadline, signal, checkDeadline) {
|
|
4332
4514
|
for (;; ) {
|
|
4515
|
+
checkDeadline?.();
|
|
4333
4516
|
const refusedBefore = localFailure();
|
|
4334
4517
|
if (refusedBefore)
|
|
4335
4518
|
throw refusedBefore;
|
|
@@ -4385,9 +4568,6 @@ async function awaitAssistantRow(openReader, readSessionError, localFailure, chi
|
|
|
4385
4568
|
return { row: newAssistant };
|
|
4386
4569
|
}
|
|
4387
4570
|
}
|
|
4388
|
-
if (Date.now() >= deadline) {
|
|
4389
|
-
throw new Error("Hidden completion timed out waiting for a persisted assistant row");
|
|
4390
|
-
}
|
|
4391
4571
|
await sleepUntilPoll(signal, deadline);
|
|
4392
4572
|
}
|
|
4393
4573
|
}
|
|
@@ -4452,11 +4632,11 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4452
4632
|
};
|
|
4453
4633
|
};
|
|
4454
4634
|
const warnedVariants = new Set;
|
|
4455
|
-
const validateVariant = async (model) => {
|
|
4635
|
+
const validateVariant = async (model, work) => {
|
|
4456
4636
|
if (!model.variant || !options.modelCatalog)
|
|
4457
4637
|
return model;
|
|
4458
4638
|
try {
|
|
4459
|
-
const listed = await options.modelCatalog
|
|
4639
|
+
const listed = await work(options.modelCatalog);
|
|
4460
4640
|
const rows = Array.isArray(listed) ? listed : listed && typeof listed === "object" && Array.isArray(listed.data) ? listed.data : [];
|
|
4461
4641
|
const entry = rows.find((row) => row && typeof row === "object" && row.providerID === model.providerID && row.id === model.modelID);
|
|
4462
4642
|
if (!entry)
|
|
@@ -4469,18 +4649,21 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4469
4649
|
note(`[magic-context] ${recordHiddenVariantWarning(model.providerID, model.modelID, model.variant)}`);
|
|
4470
4650
|
}
|
|
4471
4651
|
return { providerID: model.providerID, modelID: model.modelID };
|
|
4472
|
-
} catch {
|
|
4652
|
+
} catch (error) {
|
|
4653
|
+
if (error instanceof HiddenSetupTimeout || error instanceof HiddenWorkAborted)
|
|
4654
|
+
throw error;
|
|
4473
4655
|
return model;
|
|
4474
4656
|
}
|
|
4475
4657
|
};
|
|
4476
|
-
const resolveHead = async (identity) => {
|
|
4658
|
+
const resolveHead = async (identity, work) => {
|
|
4477
4659
|
const configured = configuredHead(identity);
|
|
4478
4660
|
if (configured)
|
|
4479
|
-
return validateVariant(configured);
|
|
4480
|
-
|
|
4661
|
+
return validateVariant(configured, work);
|
|
4662
|
+
const parentSessionId = identity.parentSessionId;
|
|
4663
|
+
if (!parentSessionId) {
|
|
4481
4664
|
throw new HiddenCompletionRefusal("hidden_model_unsupported", "Hidden completion requires a configured model or an existing parent session model", true);
|
|
4482
4665
|
}
|
|
4483
|
-
const parent = await host.get({ sessionID:
|
|
4666
|
+
const parent = await work(() => host.get({ sessionID: parentSessionId }));
|
|
4484
4667
|
if (!parent.model) {
|
|
4485
4668
|
throw new HiddenCompletionRefusal("hidden_model_unsupported", "Hidden completion could not resolve the parent session model", true);
|
|
4486
4669
|
}
|
|
@@ -4490,17 +4673,18 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4490
4673
|
...parent.model.variant ? { variant: parent.model.variant } : {}
|
|
4491
4674
|
};
|
|
4492
4675
|
};
|
|
4493
|
-
const switchChildModel = async (run, requested) => {
|
|
4676
|
+
const switchChildModel = async (run, requested, setup) => {
|
|
4494
4677
|
if (sameModel(run.child.model, requested))
|
|
4495
4678
|
return;
|
|
4496
|
-
await host.switchModel({
|
|
4679
|
+
await setup.work(() => host.switchModel({
|
|
4497
4680
|
sessionID: run.child.id,
|
|
4498
4681
|
model: {
|
|
4499
4682
|
providerID: requested.providerID,
|
|
4500
4683
|
id: requested.modelID,
|
|
4501
4684
|
...requested.variant ? { variant: requested.variant } : {}
|
|
4502
4685
|
}
|
|
4503
|
-
});
|
|
4686
|
+
}));
|
|
4687
|
+
setup.check();
|
|
4504
4688
|
run.child = lifecycle.updateModel(run.child, requested);
|
|
4505
4689
|
};
|
|
4506
4690
|
const partialCompletion = (run) => {
|
|
@@ -4532,30 +4716,63 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4532
4716
|
lifecycle.retire(run.child, reason);
|
|
4533
4717
|
run.retired = true;
|
|
4534
4718
|
};
|
|
4535
|
-
const interruptAndRetire =
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4719
|
+
const interruptAndRetire = (run, reason) => {
|
|
4720
|
+
if (run.retired)
|
|
4721
|
+
return run.retirement ?? Promise.resolve();
|
|
4722
|
+
return run.retirement ??= (async () => {
|
|
4723
|
+
const id = run.child.id;
|
|
4724
|
+
const warn = (error) => {
|
|
4725
|
+
const kind = error instanceof Error ? error.constructor.name : typeof error;
|
|
4726
|
+
const message = `[magic-context] hidden child ${id} could not be interrupted (${kind})`;
|
|
4727
|
+
if (options.log)
|
|
4728
|
+
options.log(message);
|
|
4729
|
+
else
|
|
4730
|
+
log2(message);
|
|
4731
|
+
};
|
|
4732
|
+
try {
|
|
4733
|
+
await settleWithin(host.interrupt({ sessionID: id }).catch(warn), DEFAULT_DISPOSE_DRAIN_MS);
|
|
4734
|
+
} catch (error) {
|
|
4735
|
+
warn(error);
|
|
4736
|
+
} finally {
|
|
4737
|
+
retire(run, reason);
|
|
4738
|
+
}
|
|
4739
|
+
})();
|
|
4541
4740
|
};
|
|
4542
4741
|
return {
|
|
4543
4742
|
capabilities: V2_HIDDEN_EXECUTOR_CAPABILITIES,
|
|
4544
4743
|
async open(identity) {
|
|
4545
4744
|
if (disposed)
|
|
4546
4745
|
throw disposed;
|
|
4746
|
+
const roleWait = setupBudget(Date.now() + identity.timeoutMs, (stage) => new HiddenSetupTimeout(stage));
|
|
4747
|
+
roleWait.setStage("waiting for its role");
|
|
4547
4748
|
const role = roleFor(identity);
|
|
4548
4749
|
const releaseStore = options.holdStore?.() ?? (() => {});
|
|
4549
4750
|
let releaseRole;
|
|
4550
4751
|
let openedChild;
|
|
4551
4752
|
let opened;
|
|
4552
4753
|
try {
|
|
4553
|
-
releaseRole = await acquireRole(role);
|
|
4754
|
+
releaseRole = await roleWait.work(() => acquireRole(role), (release) => release());
|
|
4554
4755
|
if (disposed)
|
|
4555
4756
|
throw disposed;
|
|
4556
|
-
|
|
4557
|
-
const
|
|
4558
|
-
const
|
|
4757
|
+
const deadline = Date.now() + identity.timeoutMs;
|
|
4758
|
+
const setup = setupBudget(deadline, (stage) => new HiddenSetupTimeout(stage));
|
|
4759
|
+
const work = setup.work;
|
|
4760
|
+
const ensureAgent = options.ensureAgent;
|
|
4761
|
+
if (ensureAgent) {
|
|
4762
|
+
setup.setStage("reloading the hidden agent");
|
|
4763
|
+
let pending;
|
|
4764
|
+
try {
|
|
4765
|
+
await work(() => pending = ensureAgent.call(options));
|
|
4766
|
+
} catch (error) {
|
|
4767
|
+
if (pending)
|
|
4768
|
+
options.forgetAgent?.(pending);
|
|
4769
|
+
throw error;
|
|
4770
|
+
}
|
|
4771
|
+
}
|
|
4772
|
+
setup.setStage("resolving the hidden model");
|
|
4773
|
+
const head = await resolveHead(identity, work);
|
|
4774
|
+
setup.setStage("creating the child session");
|
|
4775
|
+
const active = await work(() => lifecycle.open(identity, role, head, setup), (child) => lifecycle.retireLate(child, setup.cleanupMs));
|
|
4559
4776
|
openedChild = active;
|
|
4560
4777
|
const configuredModel = toModelEntry(identity.model);
|
|
4561
4778
|
const handle = {
|
|
@@ -4572,6 +4789,7 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4572
4789
|
child: active,
|
|
4573
4790
|
releaseRole,
|
|
4574
4791
|
releaseStore,
|
|
4792
|
+
firstDeadline: deadline,
|
|
4575
4793
|
failed: false,
|
|
4576
4794
|
unsettledFailure: false,
|
|
4577
4795
|
retired: false
|
|
@@ -4581,15 +4799,23 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4581
4799
|
openRuns.add(run);
|
|
4582
4800
|
if (disposed)
|
|
4583
4801
|
noteChildOfDisposedInstance(active.id);
|
|
4584
|
-
|
|
4802
|
+
setup.setStage("switching the child model");
|
|
4803
|
+
await switchChildModel(run, head, setup);
|
|
4804
|
+
setup.check();
|
|
4585
4805
|
return handle;
|
|
4586
4806
|
} catch (error) {
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4807
|
+
try {
|
|
4808
|
+
if (openedChild) {
|
|
4809
|
+
if (error instanceof HiddenSetupTimeout)
|
|
4810
|
+
noteTimedOutHiddenChild(openedChild.id);
|
|
4811
|
+
lifecycle.retire(openedChild, "hidden-run-open-failed");
|
|
4812
|
+
}
|
|
4813
|
+
} finally {
|
|
4814
|
+
if (opened)
|
|
4815
|
+
openRuns.delete(opened);
|
|
4816
|
+
releaseRole?.();
|
|
4817
|
+
releaseStore();
|
|
4818
|
+
}
|
|
4593
4819
|
throw error;
|
|
4594
4820
|
}
|
|
4595
4821
|
},
|
|
@@ -4598,6 +4824,35 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4598
4824
|
const run = runs.get(handle);
|
|
4599
4825
|
if (!run)
|
|
4600
4826
|
throw new Error("Unknown hidden completion run");
|
|
4827
|
+
const timeoutMs = run.identity.timeoutMs;
|
|
4828
|
+
const deadline = run.firstDeadline ?? startedAt + timeoutMs;
|
|
4829
|
+
run.firstDeadline = undefined;
|
|
4830
|
+
let dispatched = false;
|
|
4831
|
+
const setup = setupBudget(deadline, (stage) => dispatched ? new HiddenWorkTimeout(timeoutMs) : new HiddenSetupTimeout(stage), request.signal);
|
|
4832
|
+
const work = setup.work;
|
|
4833
|
+
const sharedBudget = promptTransportBudget(request.signal);
|
|
4834
|
+
const refuseSliver = () => {
|
|
4835
|
+
const now = Date.now();
|
|
4836
|
+
if (deadline - now < timeoutMs * 0.05 || sharedBudget && sharedBudget.deadline - now < sharedBudget.timeoutMs * 0.05)
|
|
4837
|
+
throw new HiddenSetupTimeout("preparing to send the prompt");
|
|
4838
|
+
};
|
|
4839
|
+
const retireFailedSetup = (error) => {
|
|
4840
|
+
if (error instanceof HiddenSetupTimeout) {
|
|
4841
|
+
run.deadlineExpired = true;
|
|
4842
|
+
noteTimedOutHiddenChild(run.child.id);
|
|
4843
|
+
}
|
|
4844
|
+
run.failed = true;
|
|
4845
|
+
run.unsettledFailure = true;
|
|
4846
|
+
if (!run.retirement)
|
|
4847
|
+
retire(run, "hidden-attempt-setup-cancelled");
|
|
4848
|
+
};
|
|
4849
|
+
const stopWithinWork = async (reason) => {
|
|
4850
|
+
const retirement = interruptAndRetire(run, reason);
|
|
4851
|
+
if (Date.now() < deadline)
|
|
4852
|
+
await settleWithin(retirement, deadline - Date.now());
|
|
4853
|
+
if (Date.now() >= deadline)
|
|
4854
|
+
run.deadlineExpired = true;
|
|
4855
|
+
};
|
|
4601
4856
|
const refuseDisposed = () => {
|
|
4602
4857
|
if (!disposed)
|
|
4603
4858
|
return;
|
|
@@ -4608,46 +4863,78 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4608
4863
|
};
|
|
4609
4864
|
refuseDisposed();
|
|
4610
4865
|
if (request.signal?.aborted) {
|
|
4611
|
-
await
|
|
4866
|
+
await stopWithinWork("aborted-before-prompt");
|
|
4612
4867
|
throw new Error("Hidden completion prompt aborted");
|
|
4613
4868
|
}
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4869
|
+
let requested;
|
|
4870
|
+
let requestedRef;
|
|
4871
|
+
notePromptSetupTimeout(request.signal, () => new HiddenSetupTimeout(setup.stage));
|
|
4872
|
+
try {
|
|
4873
|
+
const previousRetirement = run.retirement;
|
|
4874
|
+
setup.setStage("waiting for the previous child to retire");
|
|
4875
|
+
if (previousRetirement)
|
|
4876
|
+
await work(() => previousRetirement);
|
|
4877
|
+
setup.setStage("resolving the hidden model");
|
|
4878
|
+
requested = await validateVariant(requestModel(request, run.child.model), work);
|
|
4879
|
+
requestedRef = modelKey(requested);
|
|
4880
|
+
const configuredModel = [
|
|
4881
|
+
run.identity.model,
|
|
4882
|
+
...run.identity.configuredModels ?? []
|
|
4883
|
+
].map(toModelEntry).find((entry) => entry?.model === requestedRef);
|
|
4884
|
+
handle.attemptedModel = requestedRef;
|
|
4885
|
+
handle.modelConfigKey = configuredModel?.sourceConfigKey ?? handle.modelConfigKey;
|
|
4886
|
+
if (run.identity.kind !== "dreamer-task" && request.body.temperature === undefined) {
|
|
4887
|
+
const configured = options.historianTemperature?.();
|
|
4888
|
+
if (typeof configured === "number" && Number.isFinite(configured))
|
|
4889
|
+
request = {
|
|
4890
|
+
...request,
|
|
4891
|
+
body: { ...request.body, temperature: configured }
|
|
4892
|
+
};
|
|
4893
|
+
}
|
|
4894
|
+
if (typeof request.body.temperature === "number") {
|
|
4895
|
+
let metadata;
|
|
4896
|
+
try {
|
|
4897
|
+
const listed = options.modelCatalog ? await work(options.modelCatalog) : undefined;
|
|
4898
|
+
const rows = Array.isArray(listed) ? listed : listed?.data;
|
|
4899
|
+
metadata = rows?.find((row) => row?.providerID === requested.providerID && (row?.id === requested.modelID || row?.modelID === requested.modelID));
|
|
4900
|
+
} catch (error) {
|
|
4901
|
+
if (error instanceof HiddenSetupTimeout || error instanceof HiddenWorkAborted)
|
|
4902
|
+
throw error;
|
|
4903
|
+
}
|
|
4904
|
+
const temperature = subagentTemperature(modelKey(requested), metadata, request.body.temperature, (message) => note(message));
|
|
4905
|
+
const body = { ...request.body };
|
|
4906
|
+
if (temperature === undefined)
|
|
4907
|
+
delete body.temperature;
|
|
4908
|
+
else
|
|
4909
|
+
body.temperature = temperature;
|
|
4910
|
+
request = { ...request, body };
|
|
4911
|
+
}
|
|
4912
|
+
if (needsBlockedRead(run.identity.agent, run.child.model.providerID) !== needsBlockedRead(run.identity.agent, requested.providerID)) {
|
|
4913
|
+
retire(run, "hidden-run-tool-surface-changed");
|
|
4914
|
+
}
|
|
4915
|
+
if (run.retired) {
|
|
4916
|
+
setup.setStage("creating the replacement child session");
|
|
4917
|
+
run.child = await work(() => lifecycle.create(run.identity, run.role, requested, setup), (child) => lifecycle.retireLate(child, setup.cleanupMs));
|
|
4918
|
+
run.retirement = undefined;
|
|
4919
|
+
run.deadlineExpired = false;
|
|
4920
|
+
run.failed = false;
|
|
4921
|
+
run.unsettledFailure = false;
|
|
4922
|
+
run.retired = false;
|
|
4923
|
+
handle.id = run.child.id;
|
|
4924
|
+
handle.childSessionId = run.child.id;
|
|
4925
|
+
}
|
|
4926
|
+
setup.setStage("switching the child model");
|
|
4927
|
+
await switchChildModel(run, requested, setup);
|
|
4928
|
+
setup.check();
|
|
4929
|
+
setup.setStage("preparing to send the prompt");
|
|
4930
|
+
refuseSliver();
|
|
4931
|
+
} catch (error) {
|
|
4932
|
+
if (error instanceof HiddenSetupTimeout || error instanceof HiddenWorkAborted)
|
|
4933
|
+
retireFailedSetup(error);
|
|
4934
|
+
throw error;
|
|
4935
|
+
} finally {
|
|
4936
|
+
notePromptSetupTimeout(request.signal);
|
|
4649
4937
|
}
|
|
4650
|
-
await switchChildModel(run, requested);
|
|
4651
4938
|
refuseDisposed();
|
|
4652
4939
|
const baseline = withReader(options.openReader, (reader) => reader.latestSequence(run.child.id));
|
|
4653
4940
|
const marker = `mc:hidden:${crypto.randomUUID()}:${crypto.randomUUID()}`;
|
|
@@ -4662,7 +4949,6 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4662
4949
|
run.partialCompletion = undefined;
|
|
4663
4950
|
run.attempt = { child: attempt, baseline };
|
|
4664
4951
|
options.hook.registerAttempt(marker, attempt);
|
|
4665
|
-
const deadline = Date.now() + run.identity.timeoutMs;
|
|
4666
4952
|
lifecycle.extendDeadline(run.child, deadline);
|
|
4667
4953
|
const budget = run.budget;
|
|
4668
4954
|
if (budget?.snapshot().finalizeFired) {
|
|
@@ -4721,6 +5007,8 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4721
5007
|
});
|
|
4722
5008
|
const onAbort = () => {
|
|
4723
5009
|
const reason = request.signal?.reason;
|
|
5010
|
+
if (dispatched)
|
|
5011
|
+
noteTimedOutHiddenChild(run.child.id);
|
|
4724
5012
|
if (reason instanceof ModelProducedNoOutputError && run.identity.kind === "dreamer-task") {
|
|
4725
5013
|
recordChildInvocation({
|
|
4726
5014
|
db: options.db,
|
|
@@ -4738,9 +5026,6 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4738
5026
|
}
|
|
4739
5027
|
interruptAndRetire(run, "prompt-aborted").finally(() => abortReject(new Error("Hidden completion prompt aborted")));
|
|
4740
5028
|
};
|
|
4741
|
-
const deadlineTimer = setTimeout(() => {
|
|
4742
|
-
interruptAndRetire(run, "prompt-timeout").finally(() => abortReject(new Error("Hidden completion prompt timed out")));
|
|
4743
|
-
}, Math.max(0, deadline - Date.now()));
|
|
4744
5029
|
request.signal?.addEventListener("abort", onAbort, { once: true });
|
|
4745
5030
|
let settle;
|
|
4746
5031
|
const entry = {
|
|
@@ -4749,8 +5034,6 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4749
5034
|
noteChildOfDisposedInstance(run.child.id);
|
|
4750
5035
|
try {
|
|
4751
5036
|
await interruptAndRetire(run, "plugin-instance-disposed");
|
|
4752
|
-
} catch (error) {
|
|
4753
|
-
note(`[magic-context] hidden child ${run.child.id} could not be interrupted on dispose: ${errorText(error)}`);
|
|
4754
5037
|
} finally {
|
|
4755
5038
|
abortReject(refusal);
|
|
4756
5039
|
}
|
|
@@ -4769,28 +5052,32 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4769
5052
|
noteModelActivityMonitored(request.signal);
|
|
4770
5053
|
try {
|
|
4771
5054
|
await Promise.race([
|
|
4772
|
-
|
|
5055
|
+
work(() => {
|
|
5056
|
+
refuseSliver();
|
|
5057
|
+
dispatched = true;
|
|
5058
|
+
return host.prompt({ sessionID: run.child.id, text: marker });
|
|
5059
|
+
}),
|
|
4773
5060
|
aborted,
|
|
4774
5061
|
...budget ? [budgetStopped] : []
|
|
4775
5062
|
]);
|
|
4776
5063
|
await Promise.race([
|
|
4777
|
-
host.wait({ sessionID: run.child.id }),
|
|
5064
|
+
work(() => host.wait({ sessionID: run.child.id })),
|
|
4778
5065
|
aborted,
|
|
4779
5066
|
...budget ? [budgetStopped] : []
|
|
4780
5067
|
]);
|
|
4781
5068
|
const { row, outputLimit } = await Promise.race([
|
|
4782
|
-
awaitAssistantRow(options.openReader, async () => {
|
|
5069
|
+
work(() => awaitAssistantRow(options.openReader, async () => {
|
|
4783
5070
|
try {
|
|
4784
|
-
const
|
|
4785
|
-
|
|
4786
|
-
});
|
|
5071
|
+
const id = run.child.id;
|
|
5072
|
+
const terminalError = host.terminalError;
|
|
5073
|
+
const eventError = terminalError ? await work(() => terminalError.call(host, { sessionID: id })) : undefined;
|
|
4787
5074
|
if (eventError !== undefined)
|
|
4788
5075
|
return eventError;
|
|
4789
|
-
return (await host.get({ sessionID:
|
|
5076
|
+
return (await work(() => host.get({ sessionID: id }))).error;
|
|
4790
5077
|
} catch {
|
|
4791
5078
|
return;
|
|
4792
5079
|
}
|
|
4793
|
-
}, () => attempt.refusal ?? attempt.stepLimit, run.child.id, baseline, deadline, request.signal),
|
|
5080
|
+
}, () => attempt.refusal ?? attempt.stepLimit, run.child.id, baseline, deadline, request.signal, setup.check)),
|
|
4794
5081
|
aborted,
|
|
4795
5082
|
...budget ? [budgetStopped] : []
|
|
4796
5083
|
]);
|
|
@@ -4806,15 +5093,17 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4806
5093
|
const steps = attemptRows.filter((step) => step.type === "assistant" && step.seq > baseline && step.seq <= row.seq);
|
|
4807
5094
|
const exceeded = chargeBudgetRows(steps);
|
|
4808
5095
|
if (exceeded) {
|
|
4809
|
-
await
|
|
5096
|
+
await stopWithinWork("token-budget");
|
|
4810
5097
|
throw exceeded;
|
|
4811
5098
|
}
|
|
4812
5099
|
const cappedChainStart = outputLimit ? outputLimitChainStart(attemptRows, row.seq) : row.seq;
|
|
4813
5100
|
const usageRows = cappedChainStart < row.seq ? steps.filter((step) => step.seq < cappedChainStart || step.seq === row.seq) : steps;
|
|
4814
5101
|
const reportedUsage = usageRows.some((step) => tokenNumber(step.data.tokens?.input) !== undefined || tokenNumber(step.data.tokens?.output) !== undefined);
|
|
4815
5102
|
const usage = sumRowUsage(usageRows);
|
|
4816
|
-
if (
|
|
4817
|
-
|
|
5103
|
+
if (Date.now() >= deadline)
|
|
5104
|
+
throw new HiddenWorkTimeout(timeoutMs);
|
|
5105
|
+
if (request.signal?.aborted || run.retired) {
|
|
5106
|
+
await stopWithinWork("prompt-aborted-or-timeout");
|
|
4818
5107
|
throw new Error(request.signal?.aborted ? "Hidden completion prompt aborted" : "Hidden completion prompt timed out");
|
|
4819
5108
|
}
|
|
4820
5109
|
run.completion = {
|
|
@@ -4843,17 +5132,25 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4843
5132
|
if (!(error instanceof HiddenProviderError)) {
|
|
4844
5133
|
run.unsettledFailure = true;
|
|
4845
5134
|
}
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
5135
|
+
const dispatchedTimeout = dispatched && isPromptTimeoutError(error);
|
|
5136
|
+
if (error instanceof HiddenSetupTimeout) {
|
|
5137
|
+
retireFailedSetup(error);
|
|
5138
|
+
} else if (dispatched && (caught instanceof HiddenWorkTimeout || Date.now() >= deadline)) {
|
|
5139
|
+
run.deadlineExpired = true;
|
|
5140
|
+
noteTimedOutHiddenChild(run.child.id);
|
|
5141
|
+
interruptAndRetire(run, "prompt-timeout");
|
|
5142
|
+
} else if (request.signal?.aborted && !run.retired) {
|
|
5143
|
+
await stopWithinWork("prompt-aborted");
|
|
5144
|
+
} else if (!run.retired && (dispatchedTimeout || error instanceof Error && error.message.includes("timed out"))) {
|
|
5145
|
+
if (dispatchedTimeout)
|
|
5146
|
+
noteTimedOutHiddenChild(run.child.id);
|
|
5147
|
+
await stopWithinWork("prompt-timeout");
|
|
4850
5148
|
} else if ((error instanceof HiddenAgentStepLimit || error instanceof HiddenProviderError && error.settled) && !run.retired) {
|
|
4851
|
-
await
|
|
5149
|
+
await stopWithinWork(error instanceof HiddenAgentStepLimit ? "hidden-run-step-limit" : "hidden-run-provider-error");
|
|
4852
5150
|
}
|
|
4853
5151
|
throw error;
|
|
4854
5152
|
} finally {
|
|
4855
5153
|
stopWatching?.();
|
|
4856
|
-
clearTimeout(deadlineTimer);
|
|
4857
5154
|
if (budgetPoll)
|
|
4858
5155
|
clearInterval(budgetPoll);
|
|
4859
5156
|
request.signal?.removeEventListener("abort", onAbort);
|
|
@@ -4880,7 +5177,18 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4880
5177
|
const run = runs.get(handle);
|
|
4881
5178
|
if (!run)
|
|
4882
5179
|
return;
|
|
5180
|
+
if (run.retirement && (!run.retired || run.deadlineExpired)) {
|
|
5181
|
+
runs.delete(handle);
|
|
5182
|
+
run.retirement.finally(() => {
|
|
5183
|
+
openRuns.delete(run);
|
|
5184
|
+
run.releaseRole();
|
|
5185
|
+
run.releaseStore();
|
|
5186
|
+
});
|
|
5187
|
+
return;
|
|
5188
|
+
}
|
|
4883
5189
|
try {
|
|
5190
|
+
if (run.retirement)
|
|
5191
|
+
await run.retirement;
|
|
4884
5192
|
const reusable = !run.retired && run.failed && !run.unsettledFailure;
|
|
4885
5193
|
if (hiddenToolLoop(run.identity)) {
|
|
4886
5194
|
retire(run, settlement.promptSettled ? "tool-loop-settled" : "tool-loop-failed");
|
|
@@ -4893,7 +5201,9 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4893
5201
|
run.releaseRole();
|
|
4894
5202
|
run.releaseStore();
|
|
4895
5203
|
}
|
|
4896
|
-
|
|
5204
|
+
const finished = lifecycle.finish(run.child, run.retired);
|
|
5205
|
+
if (!run.deadlineExpired)
|
|
5206
|
+
await finished;
|
|
4897
5207
|
},
|
|
4898
5208
|
async dispose() {
|
|
4899
5209
|
disposed ??= new HiddenCompletionRefusal("hidden_instance_disposed", HIDDEN_RUN_DISPOSED_REASON, true);
|
|
@@ -6238,6 +6548,7 @@ var MAX_STAGED_SUFFIX_ROWS = 1e4;
|
|
|
6238
6548
|
class V2RevertMessageCleanup {
|
|
6239
6549
|
openStoreReader;
|
|
6240
6550
|
staged = new BoundedSessionMap(MAX_STAGED_REVERTS);
|
|
6551
|
+
pendingHistory = [];
|
|
6241
6552
|
constructor(openStoreReader) {
|
|
6242
6553
|
this.openStoreReader = openStoreReader;
|
|
6243
6554
|
}
|
|
@@ -6266,7 +6577,11 @@ class V2RevertMessageCleanup {
|
|
|
6266
6577
|
discardAllStageProofs() {
|
|
6267
6578
|
this.staged.clear();
|
|
6268
6579
|
}
|
|
6269
|
-
|
|
6580
|
+
forgetSession(sessionID) {
|
|
6581
|
+
this.discardStageProof(sessionID);
|
|
6582
|
+
this.pendingHistory = this.pendingHistory.filter((proof) => proof.sessionID !== sessionID);
|
|
6583
|
+
}
|
|
6584
|
+
pruneOnCommit(db, sessionID, to, retireHistory) {
|
|
6270
6585
|
const staged = this.staged.peek(sessionID);
|
|
6271
6586
|
this.discardStageProof(sessionID);
|
|
6272
6587
|
const noteSkippedCleanup = (reason) => {
|
|
@@ -6296,9 +6611,45 @@ class V2RevertMessageCleanup {
|
|
|
6296
6611
|
return noteSkippedCleanup("retained predecessor is not visible at commit");
|
|
6297
6612
|
if (!removed.size)
|
|
6298
6613
|
return noteSkippedCleanup("all staged rows still exist");
|
|
6614
|
+
if (retireHistory) {
|
|
6615
|
+
if (this.pendingHistory.length === MAX_STAGED_REVERTS)
|
|
6616
|
+
this.pendingHistory.shift();
|
|
6617
|
+
this.pendingHistory.push({ sessionID, host: staged.host, removed });
|
|
6618
|
+
}
|
|
6299
6619
|
pruneMessages(db, sessionID, removed);
|
|
6300
6620
|
return true;
|
|
6301
6621
|
}
|
|
6622
|
+
retireProvenHistory(db, sessionID, reader) {
|
|
6623
|
+
const ownProofs = this.pendingHistory.filter((proof) => proof.sessionID === sessionID);
|
|
6624
|
+
if (ownProofs.length === 0)
|
|
6625
|
+
return;
|
|
6626
|
+
const source = reader ?? this.openStoreReader();
|
|
6627
|
+
try {
|
|
6628
|
+
const host = source.hostIdentity();
|
|
6629
|
+
const current = ownProofs.filter((proof) => proof.host === host);
|
|
6630
|
+
this.pendingHistory = this.pendingHistory.filter((proof) => proof.sessionID !== sessionID || proof.host === host);
|
|
6631
|
+
if (current.length === 0)
|
|
6632
|
+
return;
|
|
6633
|
+
const removed = new Set;
|
|
6634
|
+
for (const proof of current)
|
|
6635
|
+
for (const id of proof.removed)
|
|
6636
|
+
removed.add(id);
|
|
6637
|
+
const result = repairMissingHistoryBoundary({
|
|
6638
|
+
db,
|
|
6639
|
+
sessionId: sessionID,
|
|
6640
|
+
isInHostStore: (id) => source.sequenceForId(sessionID, id) !== undefined,
|
|
6641
|
+
removedByCommittedRevert: removed,
|
|
6642
|
+
onRetire: () => clearRecompStaging(db, sessionID)
|
|
6643
|
+
});
|
|
6644
|
+
if (result.kind !== "unresolved") {
|
|
6645
|
+
this.pendingHistory = this.pendingHistory.filter((proof) => proof.sessionID !== sessionID);
|
|
6646
|
+
}
|
|
6647
|
+
return result.kind === "intact" ? undefined : result;
|
|
6648
|
+
} finally {
|
|
6649
|
+
if (!reader)
|
|
6650
|
+
source.close();
|
|
6651
|
+
}
|
|
6652
|
+
}
|
|
6302
6653
|
}
|
|
6303
6654
|
function pruneMessages(db, sessionID, removed) {
|
|
6304
6655
|
db.transaction(() => {
|
|
@@ -6782,9 +7133,23 @@ function servableCarrier(stored, head) {
|
|
|
6782
7133
|
}
|
|
6783
7134
|
function bindKeptInstructionCoordinates(messages, incoming, reader, sessionID) {
|
|
6784
7135
|
const rows = reader.instructionRowsThrough(sessionID, reader.latestSequence(sessionID));
|
|
7136
|
+
const visible = (message) => message !== incoming && !effortPart(message);
|
|
7137
|
+
const ids = new Set;
|
|
7138
|
+
for (const message of messages) {
|
|
7139
|
+
if (!visible(message))
|
|
7140
|
+
continue;
|
|
7141
|
+
const id = nativeRowID(message);
|
|
7142
|
+
if (id)
|
|
7143
|
+
ids.add(id);
|
|
7144
|
+
}
|
|
7145
|
+
const sequences = reader.sequencesForIds(sessionID, [...ids]);
|
|
6785
7146
|
let previous;
|
|
6786
7147
|
let pending = [];
|
|
6787
7148
|
const matches = (message, row) => message?.role === "system" && message.content.length === 1 && message.content[0]?.type === "text" && message.content[0].text === row?.data.text;
|
|
7149
|
+
const bindRow = (message, row) => {
|
|
7150
|
+
bindNativeRowID(message, row.id, row.seq);
|
|
7151
|
+
sequences.set(row.id, row.seq);
|
|
7152
|
+
};
|
|
6788
7153
|
const bind = (next) => {
|
|
6789
7154
|
if (!pending.length)
|
|
6790
7155
|
return;
|
|
@@ -6794,7 +7159,7 @@ function bindKeptInstructionCoordinates(messages, incoming, reader, sessionID) {
|
|
|
6794
7159
|
selected.forEach((row, index) => {
|
|
6795
7160
|
const message = pending[index];
|
|
6796
7161
|
if (message)
|
|
6797
|
-
|
|
7162
|
+
bindRow(message, row);
|
|
6798
7163
|
});
|
|
6799
7164
|
} else {
|
|
6800
7165
|
const earliest = [];
|
|
@@ -6815,16 +7180,16 @@ function bindKeptInstructionCoordinates(messages, incoming, reader, sessionID) {
|
|
|
6815
7180
|
pending.forEach((message, index) => {
|
|
6816
7181
|
const row = candidates[earliest[index]];
|
|
6817
7182
|
if (row && earliest[index] === latest[index])
|
|
6818
|
-
|
|
7183
|
+
bindRow(message, row);
|
|
6819
7184
|
});
|
|
6820
7185
|
}
|
|
6821
7186
|
pending = [];
|
|
6822
7187
|
};
|
|
6823
7188
|
for (const message of messages) {
|
|
6824
|
-
if (
|
|
7189
|
+
if (!visible(message))
|
|
6825
7190
|
continue;
|
|
6826
7191
|
const id = nativeRowID(message);
|
|
6827
|
-
const seq = id ?
|
|
7192
|
+
const seq = id ? sequences.get(id) : undefined;
|
|
6828
7193
|
if (seq !== undefined) {
|
|
6829
7194
|
bind(seq);
|
|
6830
7195
|
previous = seq;
|
|
@@ -6965,12 +7330,16 @@ function checkHistoryBoundary(db, reader, sessionID) {
|
|
|
6965
7330
|
}
|
|
6966
7331
|
}
|
|
6967
7332
|
function newBaselineStartAfter(db, reader, sessionID, cached, compactionOff) {
|
|
6968
|
-
if (cached?.id != null
|
|
7333
|
+
if (cached?.id != null)
|
|
6969
7334
|
return;
|
|
6970
7335
|
const isSubagent = storedSubagentMode(db, sessionID);
|
|
6971
7336
|
if (isSubagent === undefined || !rendersCompartmentHistory(isSubagent, compactionOff))
|
|
6972
7337
|
return;
|
|
7338
|
+
if (cached?.hasBytes)
|
|
7339
|
+
return reader.earliestSequence(sessionID) === undefined ? undefined : null;
|
|
6973
7340
|
const newest = db.prepare("SELECT end_message_id AS id, rebase_status AS status FROM compartments WHERE session_id = ? ORDER BY sequence DESC LIMIT 1").get(sessionID);
|
|
7341
|
+
if (!newest && reader.earliestSequence(sessionID) !== undefined)
|
|
7342
|
+
return null;
|
|
6974
7343
|
if (newest?.id && newest.status !== "unresolved" && reader.sequenceForId(sessionID, newest.id) !== undefined)
|
|
6975
7344
|
return newest.id;
|
|
6976
7345
|
return;
|
|
@@ -6988,6 +7357,12 @@ async function cacheV2SessionDirectory(session, sessionID, directories) {
|
|
|
6988
7357
|
}
|
|
6989
7358
|
}
|
|
6990
7359
|
var contextPass = new AsyncLocalStorage;
|
|
7360
|
+
function noteCheckpointWithoutTail(sessionID, cut, incoming, messageCount) {
|
|
7361
|
+
const pass = contextPass.getStore();
|
|
7362
|
+
if (pass?.sessionID !== sessionID)
|
|
7363
|
+
return;
|
|
7364
|
+
pass.checkpointWithoutTail = cut && incoming && messageCount === 1 && !isCheckpointNote(cut.data.summary) ? cut.id : undefined;
|
|
7365
|
+
}
|
|
6991
7366
|
function withV2ContextPass(sessionID, run) {
|
|
6992
7367
|
const pass = { sessionID, refused: false };
|
|
6993
7368
|
return withSqliteTransformPass2(() => contextPass.run(pass, () => run(pass)));
|
|
@@ -7163,9 +7538,31 @@ function coveredInstructionRows(reader, sessionID, throughSeq, model, retired =
|
|
|
7163
7538
|
return [];
|
|
7164
7539
|
return reader.instructionRowsThrough(sessionID, throughSeq).filter((row) => !retired(row)).flatMap((row) => restoreRow(row, model)).map((message) => markCoveredInstructionRow(message));
|
|
7165
7540
|
}
|
|
7541
|
+
var contextDisposalOrder = [
|
|
7542
|
+
"sweep",
|
|
7543
|
+
"backfill",
|
|
7544
|
+
"idle",
|
|
7545
|
+
"abortUsage",
|
|
7546
|
+
"hidden",
|
|
7547
|
+
"joinUsage",
|
|
7548
|
+
"rpc",
|
|
7549
|
+
"transform",
|
|
7550
|
+
"tools",
|
|
7551
|
+
"deletedSessions",
|
|
7552
|
+
"dream",
|
|
7553
|
+
"maintenance",
|
|
7554
|
+
"embeddings",
|
|
7555
|
+
"rawProviders",
|
|
7556
|
+
"restoredRows",
|
|
7557
|
+
"readerPool",
|
|
7558
|
+
"synthetic"
|
|
7559
|
+
];
|
|
7166
7560
|
async function registerContext(context) {
|
|
7167
7561
|
const directory = context.location.directory;
|
|
7168
7562
|
const config = loadPluginConfigDetailed(directory).config;
|
|
7563
|
+
for (const warning of new Set(config.configWarnings)) {
|
|
7564
|
+
log2(`[magic-context] config warning: ${warning}`);
|
|
7565
|
+
}
|
|
7169
7566
|
log2(`[magic-context] OpenCode 2 keep_subagents=${config.keep_subagents === true}`);
|
|
7170
7567
|
setHomeProjectPermission(config.allow_home_project);
|
|
7171
7568
|
if (!config.enabled)
|
|
@@ -7191,7 +7588,6 @@ async function registerContext(context) {
|
|
|
7191
7588
|
});
|
|
7192
7589
|
return;
|
|
7193
7590
|
}
|
|
7194
|
-
const liveConfigReader = pluginConfigReader(directory, config);
|
|
7195
7591
|
const compactionOff = !isCompactionEnabled(config);
|
|
7196
7592
|
const conflicts = detectConflicts(directory, {
|
|
7197
7593
|
compactionEnabled: !compactionOff,
|
|
@@ -7201,12 +7597,62 @@ async function registerContext(context) {
|
|
|
7201
7597
|
console.warn(`[magic-context] v2 setup disabled by conflicting context hooks: ${conflicts.reasons.join("; ")}`);
|
|
7202
7598
|
return;
|
|
7203
7599
|
}
|
|
7600
|
+
const cleanup = {};
|
|
7601
|
+
const dispose = async (failedSetup = false) => {
|
|
7602
|
+
for (const resource of contextDisposalOrder) {
|
|
7603
|
+
try {
|
|
7604
|
+
const drain = cleanup[resource]?.(failedSetup);
|
|
7605
|
+
if (drain)
|
|
7606
|
+
await drain;
|
|
7607
|
+
} catch (error) {
|
|
7608
|
+
const kind = error instanceof Error ? error.constructor.name : typeof error;
|
|
7609
|
+
log2(`[magic-context] v2 ${resource} cleanup failed (${kind})`);
|
|
7610
|
+
}
|
|
7611
|
+
}
|
|
7612
|
+
};
|
|
7613
|
+
try {
|
|
7614
|
+
await setupContext(context, config, nativeRemove, compactionOff, cleanup);
|
|
7615
|
+
} catch (error) {
|
|
7616
|
+
await dispose(true);
|
|
7617
|
+
throw error;
|
|
7618
|
+
}
|
|
7619
|
+
return { dispose: () => dispose() };
|
|
7620
|
+
}
|
|
7621
|
+
async function setupContext(context, config, nativeRemove, compactionOff, cleanup) {
|
|
7622
|
+
const directory = context.location.directory;
|
|
7623
|
+
const liveConfigReader = pluginConfigReader(directory, config);
|
|
7204
7624
|
const embeddings = createV2EmbeddingScope(resolveProjectIdentityForSession(directory, config.allow_home_project));
|
|
7625
|
+
cleanup.embeddings = () => embeddings.dispose();
|
|
7205
7626
|
const folds = new FoldOwner(context.storage);
|
|
7206
7627
|
const nativeFoldMemory = compactionOff ? undefined : nativeFoldCache(() => storage.require());
|
|
7628
|
+
const loggedUncoveredCheckpoints = new BoundedSessionMap(1000);
|
|
7207
7629
|
const nativeFoldReplay = nativeFoldMemory ? new NativeFoldReplay(nativeFoldMemory, () => openStoreReader(), context.storage, {
|
|
7208
7630
|
protocol: 3,
|
|
7209
|
-
log: sessionLog2
|
|
7631
|
+
log: sessionLog2,
|
|
7632
|
+
rendersHistory: (sessionID) => {
|
|
7633
|
+
if (rustModeModuleClient)
|
|
7634
|
+
return false;
|
|
7635
|
+
const mode = storedSubagentMode(storage.require(), sessionID);
|
|
7636
|
+
return mode !== undefined && rendersCompartmentHistory(mode, compactionOff);
|
|
7637
|
+
},
|
|
7638
|
+
servesHostCheckpoint: (sessionID, checkpointID) => {
|
|
7639
|
+
const pass = contextPass.getStore();
|
|
7640
|
+
return pass?.sessionID === sessionID && pass.checkpointWithoutTail === checkpointID;
|
|
7641
|
+
},
|
|
7642
|
+
onUncoveredFloor: (sessionID, floor, coverage) => {
|
|
7643
|
+
const pass = contextPass.getStore();
|
|
7644
|
+
if (pass?.sessionID === sessionID && pass.loggedUncoveredFloor)
|
|
7645
|
+
return;
|
|
7646
|
+
if (floor.kind === "checkpoint") {
|
|
7647
|
+
const key = JSON.stringify([sessionID, floor.id]);
|
|
7648
|
+
if (loggedUncoveredCheckpoints.get(key))
|
|
7649
|
+
return;
|
|
7650
|
+
loggedUncoveredCheckpoints.set(key, true);
|
|
7651
|
+
}
|
|
7652
|
+
if (pass?.sessionID === sessionID)
|
|
7653
|
+
pass.loggedUncoveredFloor = true;
|
|
7654
|
+
sessionLog2(sessionID, `v2 restore: ignored ${floor.kind} floor ${floor.id} at seq=${floor.after}; rendered coverage ${coverage.id ?? "none"} ends at seq=${coverage.after}`);
|
|
7655
|
+
}
|
|
7210
7656
|
}) : undefined;
|
|
7211
7657
|
setOutputReserveConfig(config.output_reserve);
|
|
7212
7658
|
const queriedModels = new Set;
|
|
@@ -7244,6 +7690,11 @@ async function registerContext(context) {
|
|
|
7244
7690
|
isLive: isLiveHiddenChild
|
|
7245
7691
|
});
|
|
7246
7692
|
let hiddenChildSweepTimer;
|
|
7693
|
+
cleanup.sweep = () => {
|
|
7694
|
+
if (hiddenChildSweepTimer)
|
|
7695
|
+
clearInterval(hiddenChildSweepTimer);
|
|
7696
|
+
return hiddenChildSweep.dispose();
|
|
7697
|
+
};
|
|
7247
7698
|
const sweepChildren = (database) => {
|
|
7248
7699
|
hiddenChildSweep.start(database);
|
|
7249
7700
|
};
|
|
@@ -7309,6 +7760,8 @@ async function registerContext(context) {
|
|
|
7309
7760
|
});
|
|
7310
7761
|
});
|
|
7311
7762
|
const tools = db && isDatabasePersisted(db) ? await registerTools(context, db, config, moduleToolBackends?.backends, (id) => hiddenChildHook.owns(id), embeddings.ensureRegistered) : undefined;
|
|
7763
|
+
if (tools)
|
|
7764
|
+
cleanup.tools = () => tools.dispose();
|
|
7312
7765
|
const generateReplay = new V2GenerateReplay;
|
|
7313
7766
|
await context.session.hook("http.response", async (draft) => {
|
|
7314
7767
|
if (!db || draft.kind !== "primary" || draft.response.ok)
|
|
@@ -7332,6 +7785,11 @@ async function registerContext(context) {
|
|
|
7332
7785
|
});
|
|
7333
7786
|
let hiddenAgentsReady;
|
|
7334
7787
|
const readerPool = new V2StoreReaderPool2;
|
|
7788
|
+
cleanup.readerPool = async () => {
|
|
7789
|
+
if (!await readerPool.closeWhenIdle(STORE_POOL_DISPOSE_WAIT_MS))
|
|
7790
|
+
log2(`[magic-context] v2 store reader pool still held by ${readerPool.holdCount()} hidden run(s) at dispose; it closes when they finish`);
|
|
7791
|
+
};
|
|
7792
|
+
cleanup.synthetic = () => clearSyntheticCandidates(context);
|
|
7335
7793
|
const messageTimesCache = new V2MessageTimesCache;
|
|
7336
7794
|
const openStoreReader = () => readerPool.open(gaDatabasePath2(getDataDir(), process.env.OPENCODE_CHANNEL ?? "latest"));
|
|
7337
7795
|
const revertMessageCleanup = new V2RevertMessageCleanup(openStoreReader);
|
|
@@ -7402,6 +7860,10 @@ async function registerContext(context) {
|
|
|
7402
7860
|
hostVersion: context.app?.version,
|
|
7403
7861
|
keepSubagents: config.keep_subagents === true,
|
|
7404
7862
|
ensureAgent: () => hiddenAgentsReady ??= context.agent.reload(),
|
|
7863
|
+
forgetAgent: (pending) => {
|
|
7864
|
+
if (hiddenAgentsReady === pending)
|
|
7865
|
+
hiddenAgentsReady = undefined;
|
|
7866
|
+
},
|
|
7405
7867
|
modelCatalog: () => Promise.resolve(context.model.list()),
|
|
7406
7868
|
historianTemperature: () => config.historian?.temperature,
|
|
7407
7869
|
openReader: openStoreReader,
|
|
@@ -7435,9 +7897,12 @@ async function registerContext(context) {
|
|
|
7435
7897
|
return trigger;
|
|
7436
7898
|
};
|
|
7437
7899
|
let hiddenCompletionExecutor = db && isDatabasePersisted(db) && resolveProjectIdentityForSession(directory, config.allow_home_project) ? await createHiddenExecutor(db) : undefined;
|
|
7900
|
+
cleanup.hidden = () => hiddenCompletionExecutor?.dispose();
|
|
7438
7901
|
let dreamTrigger = hiddenCompletionExecutor ? startDreamer(hiddenCompletionExecutor) : undefined;
|
|
7902
|
+
cleanup.dream = () => dreamTrigger?.dispose();
|
|
7439
7903
|
const lateHiddenExecutor = createLateHiddenExecutor(() => hiddenCompletionExecutor);
|
|
7440
7904
|
let maintenanceTimer;
|
|
7905
|
+
cleanup.maintenance = () => maintenanceTimer?.dispose();
|
|
7441
7906
|
const startMaintenance = () => {
|
|
7442
7907
|
const timerProjectIdentity = resolveProjectIdentityForSession(directory, config.allow_home_project);
|
|
7443
7908
|
if (!timerProjectIdentity || maintenanceTimer)
|
|
@@ -7498,6 +7963,12 @@ async function registerContext(context) {
|
|
|
7498
7963
|
const commitSeenLastPass = new Map;
|
|
7499
7964
|
const restoredRows = new RestoredRowCache;
|
|
7500
7965
|
const rawProviders = new Map;
|
|
7966
|
+
cleanup.restoredRows = () => restoredRows.clear();
|
|
7967
|
+
cleanup.rawProviders = () => {
|
|
7968
|
+
for (const release of rawProviders.values())
|
|
7969
|
+
release();
|
|
7970
|
+
rawProviders.clear();
|
|
7971
|
+
};
|
|
7501
7972
|
let passDuties;
|
|
7502
7973
|
let toolDuties;
|
|
7503
7974
|
const droppedInputGuard = createDroppedInputGuard();
|
|
@@ -7536,8 +8007,9 @@ async function registerContext(context) {
|
|
|
7536
8007
|
};
|
|
7537
8008
|
if (db && isDatabasePersisted(db)) {
|
|
7538
8009
|
const backfillDb = db;
|
|
7539
|
-
|
|
7540
|
-
|
|
8010
|
+
let running;
|
|
8011
|
+
const timer = scheduleAfterBootQuiet(() => {
|
|
8012
|
+
running = runV2SessionProjectBackfill(backfillDb, openStoreReader, config.allow_home_project).then(() => backfillSessionActivity(backfillDb, "opencode", (sessionId) => {
|
|
7541
8013
|
const reader = openStoreReader();
|
|
7542
8014
|
try {
|
|
7543
8015
|
return reader.latestMessageTime(sessionId);
|
|
@@ -7546,6 +8018,17 @@ async function registerContext(context) {
|
|
|
7546
8018
|
}
|
|
7547
8019
|
})).catch((error) => log2("[session-project-backfill] OpenCode 2 backfill failed:", error));
|
|
7548
8020
|
});
|
|
8021
|
+
cleanup.backfill = (failedSetup) => {
|
|
8022
|
+
if (!failedSetup)
|
|
8023
|
+
return;
|
|
8024
|
+
clearTimeout(timer);
|
|
8025
|
+
if (!running)
|
|
8026
|
+
return;
|
|
8027
|
+
return settleWithin(running, DEFAULT_DISPOSE_DRAIN_MS).then((joined) => {
|
|
8028
|
+
if (!joined)
|
|
8029
|
+
log2("[magic-context] v2 backfill still running after setup cleanup");
|
|
8030
|
+
});
|
|
8031
|
+
};
|
|
7549
8032
|
}
|
|
7550
8033
|
const readAllForConversion = (sessionID) => readAllV2RawMessagesForConversion2(openStoreReader, sessionID);
|
|
7551
8034
|
const readRowsFrom = (sessionID, messageID) => {
|
|
@@ -7566,10 +8049,12 @@ async function registerContext(context) {
|
|
|
7566
8049
|
}) : undefined;
|
|
7567
8050
|
const lkgSystems = new V2LkgSystemReplay;
|
|
7568
8051
|
let transform;
|
|
8052
|
+
cleanup.transform = () => transform?.disposeRust();
|
|
7569
8053
|
let systemPrompt;
|
|
7570
8054
|
const systemPromptRefreshSessions = new Set;
|
|
7571
8055
|
const tagger = createTagger();
|
|
7572
8056
|
const deletedSessions = new DeletedSessionTombstones;
|
|
8057
|
+
cleanup.deletedSessions = () => deletedSessions.clear();
|
|
7573
8058
|
const forkSeedSettled = new Set;
|
|
7574
8059
|
const inheritForkState = (database, sessionID) => {
|
|
7575
8060
|
if (forkSeedSettled.has(sessionID))
|
|
@@ -7740,6 +8225,12 @@ async function registerContext(context) {
|
|
|
7740
8225
|
log: sessionLog2
|
|
7741
8226
|
}) : undefined;
|
|
7742
8227
|
const hostFoldIdle = hostFolds ? new HostFoldIdle((sessionID, eligible) => hostFolds.idle(sessionID, eligible)) : undefined;
|
|
8228
|
+
cleanup.idle = () => {
|
|
8229
|
+
messageTimesCache.clear();
|
|
8230
|
+
recoveredInstructions.clear();
|
|
8231
|
+
loggedUncoveredCheckpoints.clear();
|
|
8232
|
+
hostFoldIdle?.dispose();
|
|
8233
|
+
};
|
|
7743
8234
|
const armBindingRecoveryFromEvent = (sessionID, error, source) => {
|
|
7744
8235
|
if (error === undefined || !db || compactionOff)
|
|
7745
8236
|
return;
|
|
@@ -7775,6 +8266,7 @@ async function registerContext(context) {
|
|
|
7775
8266
|
}
|
|
7776
8267
|
};
|
|
7777
8268
|
const usageController = new AbortController;
|
|
8269
|
+
cleanup.abortUsage = () => usageController.abort();
|
|
7778
8270
|
const usageDone = (async () => {
|
|
7779
8271
|
let retry = 0;
|
|
7780
8272
|
while (!usageController.signal.aborted) {
|
|
@@ -7811,9 +8303,11 @@ async function registerContext(context) {
|
|
|
7811
8303
|
if (event.type === "session.revert.staged" && db) {
|
|
7812
8304
|
revertMessageCleanup.captureStageProof(sessionID, event.data.revert?.messageID);
|
|
7813
8305
|
}
|
|
7814
|
-
if (event.type === "session.revert.cleared"
|
|
8306
|
+
if (event.type === "session.revert.cleared") {
|
|
7815
8307
|
revertMessageCleanup.discardStageProof(sessionID);
|
|
7816
8308
|
}
|
|
8309
|
+
if (event.type === "session.deleted")
|
|
8310
|
+
revertMessageCleanup.forgetSession(sessionID);
|
|
7817
8311
|
if (event.type === "session.revert.committed") {
|
|
7818
8312
|
dropServedRecord(sessionID, "host_edit");
|
|
7819
8313
|
if (db) {
|
|
@@ -7821,9 +8315,10 @@ async function registerContext(context) {
|
|
|
7821
8315
|
withoutSqliteTransformPass2(() => {
|
|
7822
8316
|
scheduleClearAndReindex(indexDb, sessionID, pagedRead);
|
|
7823
8317
|
try {
|
|
7824
|
-
if (revertMessageCleanup.pruneOnCommit(indexDb, sessionID, event.data?.to)) {
|
|
8318
|
+
if (revertMessageCleanup.pruneOnCommit(indexDb, sessionID, event.data?.to, !compactionOff && !rustModeModuleClient)) {
|
|
7825
8319
|
tagger.cleanup(sessionID);
|
|
7826
8320
|
transform?.invalidateRustWireState(sessionID);
|
|
8321
|
+
revertMessageCleanup.retireProvenHistory(indexDb, sessionID);
|
|
7827
8322
|
}
|
|
7828
8323
|
} catch (error) {
|
|
7829
8324
|
sessionLog2(sessionID, "committed revert message cleanup failed:", error);
|
|
@@ -7951,6 +8446,7 @@ async function registerContext(context) {
|
|
|
7951
8446
|
}
|
|
7952
8447
|
}
|
|
7953
8448
|
})();
|
|
8449
|
+
cleanup.joinUsage = () => usageDone;
|
|
7954
8450
|
const m0RenderOptions = (draft, store, state) => {
|
|
7955
8451
|
const modelKey = `${draft.model.providerID}/${draft.model.id}`;
|
|
7956
8452
|
const contextLimit = resolveContextLimit(draft.model.providerID, draft.model.id, {
|
|
@@ -8121,7 +8617,7 @@ async function registerContext(context) {
|
|
|
8121
8617
|
const nativeFloor = await nativeFoldReplay?.restorationFloor(draft.sessionID, cut, reader, {
|
|
8122
8618
|
allowMissingFloor: newStart !== undefined
|
|
8123
8619
|
});
|
|
8124
|
-
if (newStart && nativeFloor === undefined) {
|
|
8620
|
+
if (newStart !== undefined && nativeFloor === undefined) {
|
|
8125
8621
|
const pass = contextPass.getStore();
|
|
8126
8622
|
if (pass)
|
|
8127
8623
|
pass.recoveredCheckpointID = cut.id;
|
|
@@ -8130,6 +8626,12 @@ async function registerContext(context) {
|
|
|
8130
8626
|
const servedBoundary = boundaryID ? servedBoundaryRow2(reader, draft.sessionID, boundaryID) : null;
|
|
8131
8627
|
const retiredInstructions = await nativeFoldReplay?.instructionRetirement(draft.sessionID, reader) ?? (() => false);
|
|
8132
8628
|
const floor = Math.max(nativeFloor ?? -Infinity, (nativeFoldReplay?.sourceChanged(draft.sessionID) && !rustModeModuleClient ? (reader.earliestSequence(draft.sessionID) ?? 0) - 1 : undefined) ?? (moduleBoundarySeq !== undefined ? moduleBoundarySeq - 1 : undefined) ?? servedBoundary?.seq ?? reader.sequenceForId(draft.sessionID, boundaryID) ?? (reader.earliestSequence(draft.sessionID) ?? 0) - 1);
|
|
8629
|
+
if (nativeFloor === undefined && newStart === null) {
|
|
8630
|
+
const first = reader.page(draft.sessionID, { limit: 1 }).rows[0];
|
|
8631
|
+
if (first?.seq === floor + 1)
|
|
8632
|
+
args.onStartAtFirstRow?.(first.id);
|
|
8633
|
+
sessionLog2(draft.sessionID, `v2 restore: no rendered history boundary; starting at stored row seq=${floor + 1}`);
|
|
8634
|
+
}
|
|
8133
8635
|
const floorRow = !rustModeModuleClient && Number.isFinite(floor) ? reader.range(draft.sessionID, floor - 1, floor).find((row) => row.seq === floor) : undefined;
|
|
8134
8636
|
const boundary = floorRow && hasUnsummarizedBlocks(db, reader, draft.sessionID, floorRow.id) ? floor - 1 : floor;
|
|
8135
8637
|
if (moduleBoundarySeq !== undefined)
|
|
@@ -8358,6 +8860,7 @@ async function registerContext(context) {
|
|
|
8358
8860
|
const incoming = localCut && messages.find((message) => message.id === localCut.id);
|
|
8359
8861
|
if (localCut && !incoming)
|
|
8360
8862
|
return;
|
|
8863
|
+
noteCheckpointWithoutTail(draft.sessionID, localCut, incoming, messages.length);
|
|
8361
8864
|
checkpointAtEntry = incoming || null;
|
|
8362
8865
|
const modeDb = db ?? storage.current();
|
|
8363
8866
|
const subagent = modeDb ? storedSubagentMode(modeDb, draft.sessionID) : undefined;
|
|
@@ -8554,18 +9057,20 @@ async function registerContext(context) {
|
|
|
8554
9057
|
let submitted;
|
|
8555
9058
|
let recordedHead;
|
|
8556
9059
|
let upgradeCheckpointSequence;
|
|
9060
|
+
let restoredFirstRow;
|
|
8557
9061
|
try {
|
|
8558
9062
|
syntheticIDs = await readSyntheticProvenance(reader, draft.messages);
|
|
8559
9063
|
const cut = reader.latestCompaction(draft.sessionID);
|
|
8560
9064
|
if (nativeFoldReplay)
|
|
8561
9065
|
await nativeFoldReplay.observeSource(draft.sessionID, reader);
|
|
8562
|
-
const boundaryRepair = !rustModeModuleClient && db && !compactionOff ? checkHistoryBoundary(db, reader, draft.sessionID) : undefined;
|
|
9066
|
+
const boundaryRepair = !rustModeModuleClient && db && !compactionOff ? revertMessageCleanup.retireProvenHistory(db, draft.sessionID, reader) ?? checkHistoryBoundary(db, reader, draft.sessionID) : undefined;
|
|
8563
9067
|
if (boundaryRepair?.kind === "repaired" || boundaryRepair?.kind === "baseline-reset") {
|
|
8564
9068
|
historyRefreshSessions.add(draft.sessionID);
|
|
8565
9069
|
requestPendingMaterialization(pendingMaterializationSessions, draft.sessionID, "boundary_repair");
|
|
8566
9070
|
}
|
|
8567
9071
|
const localCut = cut && isLocalCheckpoint(cut) ? cut : undefined;
|
|
8568
9072
|
const incoming = localCut && draft.messages.find((message) => message.id === localCut.id);
|
|
9073
|
+
noteCheckpointWithoutTail(draft.sessionID, localCut, incoming, draft.messages.length);
|
|
8569
9074
|
if (!compactionOff && localCut && !incoming)
|
|
8570
9075
|
throw new Error("The host checkpoint disappeared from the context draft");
|
|
8571
9076
|
checkpointAtEntry = incoming || null;
|
|
@@ -8647,7 +9152,10 @@ async function registerContext(context) {
|
|
|
8647
9152
|
messages: draft.messages,
|
|
8648
9153
|
cut: localCut,
|
|
8649
9154
|
incoming,
|
|
8650
|
-
canRebuild: true
|
|
9155
|
+
canRebuild: true,
|
|
9156
|
+
onStartAtFirstRow: (id) => {
|
|
9157
|
+
restoredFirstRow = id;
|
|
9158
|
+
}
|
|
8651
9159
|
}));
|
|
8652
9160
|
}
|
|
8653
9161
|
instructionRows = new Map(bindKeptInstructionCoordinates(draft.messages, incoming || undefined, reader, draft.sessionID).map((row) => [row.id, row]));
|
|
@@ -8701,14 +9209,30 @@ async function registerContext(context) {
|
|
|
8701
9209
|
})({}, mapped);
|
|
8702
9210
|
mapped.commit();
|
|
8703
9211
|
if (replayHead === undefined && (pass.recoveredCheckpointID || previousRecovery && pass.nativeReplayCheckpointID === previousRecovery.checkpointID)) {
|
|
9212
|
+
let coveredAfterRestore;
|
|
9213
|
+
if (pass.recoveredCheckpointID && restoredFirstRow) {
|
|
9214
|
+
try {
|
|
9215
|
+
const end = db.prepare("SELECT cached_m0_last_baseline_end_message_id AS id FROM session_meta WHERE session_id=?").get(draft.sessionID);
|
|
9216
|
+
if (end?.id) {
|
|
9217
|
+
const source = openStoreReader();
|
|
9218
|
+
try {
|
|
9219
|
+
const seq = source.sequenceForId(draft.sessionID, end.id);
|
|
9220
|
+
if (seq !== undefined)
|
|
9221
|
+
coveredAfterRestore = new Set(source.instructionRowsThrough(draft.sessionID, seq).map(({ id }) => id));
|
|
9222
|
+
} finally {
|
|
9223
|
+
source.close();
|
|
9224
|
+
}
|
|
9225
|
+
}
|
|
9226
|
+
} catch {}
|
|
9227
|
+
}
|
|
8704
9228
|
pass.servedInstructionIDs = new Set(mapped.messages.flatMap(({ info, parts }) => {
|
|
8705
|
-
|
|
9229
|
+
const id = hostInstructionRowID(info);
|
|
9230
|
+
if (!id || info.role !== "system" || pass.recoveredCheckpointID && !isCoveredInstructionRow(info) && !coveredAfterRestore?.has(id) || !parts.some((value) => {
|
|
8706
9231
|
const part = value;
|
|
8707
9232
|
return part?.type === "text" && typeof part.text === "string" && part.text.length > 0;
|
|
8708
9233
|
}))
|
|
8709
9234
|
return [];
|
|
8710
|
-
|
|
8711
|
-
return id ? [id] : [];
|
|
9235
|
+
return [id];
|
|
8712
9236
|
}));
|
|
8713
9237
|
}
|
|
8714
9238
|
const checkpointPermission = checkpointPassPermissions.get(draft.sessionID);
|
|
@@ -8756,7 +9280,7 @@ async function registerContext(context) {
|
|
|
8756
9280
|
try {
|
|
8757
9281
|
const state = db && getOrCreateSessionMeta(db, draft.sessionID);
|
|
8758
9282
|
const boundary = db?.prepare("SELECT cached_m0_last_baseline_end_message_id AS id FROM session_meta WHERE session_id=?").get(draft.sessionID);
|
|
8759
|
-
await nativeFoldReplay?.capture(draft, nativeMessages, boundary?.id && state?.cachedM0Bytes ? { id: boundary.id, summary: state.cachedM0Bytes.toString("utf8") } : undefined);
|
|
9283
|
+
await nativeFoldReplay?.capture(draft, nativeMessages, boundary?.id && state?.cachedM0Bytes ? { id: boundary.id, summary: state.cachedM0Bytes.toString("utf8") } : undefined, restoredFirstRow);
|
|
8760
9284
|
} catch (error) {
|
|
8761
9285
|
nativeFoldReplay?.invalidate(draft.sessionID, true);
|
|
8762
9286
|
sessionLog2(draft.sessionID, "v2 host fold: optional capture unavailable", error);
|
|
@@ -8960,6 +9484,10 @@ async function registerContext(context) {
|
|
|
8960
9484
|
const storageDir = getMagicContextStorageDir();
|
|
8961
9485
|
const rpcServer = new MagicContextRpcServer(storageDir, directory);
|
|
8962
9486
|
let rpcStopped = false;
|
|
9487
|
+
cleanup.rpc = () => {
|
|
9488
|
+
rpcStopped = true;
|
|
9489
|
+
rpcServer.stop();
|
|
9490
|
+
};
|
|
8963
9491
|
registerRpcHandlers(rpcServer, {
|
|
8964
9492
|
directory,
|
|
8965
9493
|
config,
|
|
@@ -9066,34 +9594,6 @@ async function registerContext(context) {
|
|
|
9066
9594
|
return;
|
|
9067
9595
|
rpcServer.start().catch((error) => log2("[magic-context] v2 RPC server failed to start", error));
|
|
9068
9596
|
}, 0));
|
|
9069
|
-
return {
|
|
9070
|
-
async dispose() {
|
|
9071
|
-
if (hiddenChildSweepTimer)
|
|
9072
|
-
clearInterval(hiddenChildSweepTimer);
|
|
9073
|
-
await hiddenChildSweep.dispose();
|
|
9074
|
-
messageTimesCache.clear();
|
|
9075
|
-
recoveredInstructions.clear();
|
|
9076
|
-
hostFoldIdle?.dispose();
|
|
9077
|
-
usageController.abort();
|
|
9078
|
-
await hiddenCompletionExecutor?.dispose();
|
|
9079
|
-
await usageDone;
|
|
9080
|
-
rpcStopped = true;
|
|
9081
|
-
rpcServer.stop();
|
|
9082
|
-
transform?.disposeRust();
|
|
9083
|
-
tools?.dispose();
|
|
9084
|
-
deletedSessions.clear();
|
|
9085
|
-
await dreamTrigger?.dispose();
|
|
9086
|
-
await maintenanceTimer?.dispose();
|
|
9087
|
-
await embeddings.dispose();
|
|
9088
|
-
for (const release of rawProviders.values())
|
|
9089
|
-
release();
|
|
9090
|
-
rawProviders.clear();
|
|
9091
|
-
restoredRows.clear();
|
|
9092
|
-
if (!await readerPool.closeWhenIdle(STORE_POOL_DISPOSE_WAIT_MS))
|
|
9093
|
-
log2(`[magic-context] v2 store reader pool still held by ${readerPool.holdCount()} hidden run(s) at dispose; it closes when they finish`);
|
|
9094
|
-
clearSyntheticCandidates(context);
|
|
9095
|
-
}
|
|
9096
|
-
};
|
|
9097
9597
|
}
|
|
9098
9598
|
export {
|
|
9099
9599
|
registerContext
|