@cortexkit/opencode-magic-context 0.49.28 → 0.49.29

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.
Files changed (114) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/chunk-embedding-write-worker.js +1 -1
  3. package/dist/config/commit-retention-recovery.d.ts +9 -0
  4. package/dist/config/commit-retention-recovery.d.ts.map +1 -0
  5. package/dist/config/index.d.ts +2 -1
  6. package/dist/config/index.d.ts.map +1 -1
  7. package/dist/config/live-child-output-cap.d.ts.map +1 -1
  8. package/dist/config/live-run-config.d.ts.map +1 -1
  9. package/dist/config/project-security.d.ts +1 -0
  10. package/dist/config/project-security.d.ts.map +1 -1
  11. package/dist/{conflict-warning-hook-tgnw019g.js → conflict-warning-hook-xgskea1v.js} +3 -3
  12. package/dist/{context-dxfztzsd.js → context-836j3vte.js} +63 -27
  13. package/dist/{embedding-backfill-cwnyr4fj.js → embedding-backfill-mms9nb0h.js} +2 -2
  14. package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
  15. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  16. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  17. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  18. package/dist/features/magic-context/dreamer/verify-diff.d.ts.map +1 -1
  19. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  20. package/dist/features/magic-context/git-commits/indexer.d.ts +2 -0
  21. package/dist/features/magic-context/git-commits/indexer.d.ts.map +1 -1
  22. package/dist/features/magic-context/project-embedding-registry.d.ts +3 -1
  23. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  24. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  25. package/dist/features/magic-context/work-metrics.d.ts +5 -3
  26. package/dist/features/magic-context/work-metrics.d.ts.map +1 -1
  27. package/dist/hooks/magic-context/apply-operations.d.ts +2 -0
  28. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  29. package/dist/hooks/magic-context/compartment-runner-types.d.ts +5 -1
  30. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  31. package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts +3 -1
  32. package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts.map +1 -1
  33. package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
  34. package/dist/hooks/magic-context/lkg-slot.d.ts +7 -0
  35. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  37. package/dist/hooks/magic-context/read-session-db.d.ts +3 -2
  38. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  39. package/dist/hooks/magic-context/replay-committed-drops.d.ts.map +1 -1
  40. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  41. package/dist/{index-n8qmmd7f.js → index-093c4g1c.js} +3 -3
  42. package/dist/{index-89k1w6x2.js → index-a1h316s9.js} +2 -2
  43. package/dist/{index-fq2p158w.js → index-bps8vn9r.js} +13 -7
  44. package/dist/{index-tvzvjggy.js → index-gkee6p4g.js} +1 -1
  45. package/dist/{index-a2fz9hpa.js → index-gxkhzmjq.js} +4 -2
  46. package/dist/{index-4cpc59jv.js → index-h4s5jk7f.js} +1 -1
  47. package/dist/{index-t3rbb8wr.js → index-pe6b4bhs.js} +1 -1
  48. package/dist/{index-dcqk0y27.js → index-q9zvphbq.js} +104 -24
  49. package/dist/{index-7gbcg8xv.js → index-tx68g9nc.js} +1 -1
  50. package/dist/{index-4ypqzvhf.js → index-vnn5405n.js} +1 -1
  51. package/dist/{index-077ht5cq.js → index-waktfbjy.js} +1 -1
  52. package/dist/{index-k9jx7ma9.js → index-wpcdk76y.js} +325 -249
  53. package/dist/{index-dzfevacx.js → index-wvffze8y.js} +10 -6
  54. package/dist/{index-31y1mznz.js → index-wyt5m81v.js} +4 -4
  55. package/dist/{index-v0dhhxsq.js → index-y1qwzvxn.js} +5 -5
  56. package/dist/{index-yzjhx10y.js → index-zhgqgxtt.js} +5 -1
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +26 -30
  59. package/dist/{message-index-bounded-7ayzb2ah.js → message-index-bounded-7qsn4fd3.js} +3 -3
  60. package/dist/migration-worker.js +1 -1
  61. package/dist/plugin/dream-timer.d.ts.map +1 -1
  62. package/dist/plugin/embedding-bootstrap-helpers.d.ts +5 -1
  63. package/dist/plugin/embedding-bootstrap-helpers.d.ts.map +1 -1
  64. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  65. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  66. package/dist/{project-embedding-registry-94nncs5g.js → project-embedding-registry-cg281d9j.js} +1 -1
  67. package/dist/raw-ordinal-warmup-worker.js +2 -2
  68. package/dist/{read-session-chunk-jzb6w9w5.js → read-session-chunk-a5d0q3m0.js} +2 -2
  69. package/dist/{recomp-orchestrator-02sa2ngr.js → recomp-orchestrator-na34m4c5.js} +10 -10
  70. package/dist/{search-spq6nfyf.js → search-0cd6hx7a.js} +7 -7
  71. package/dist/{search-archive-q1vw7zg4.js → search-archive-66pm17gm.js} +3 -3
  72. package/dist/{send-session-notification-afzzqy5b.js → send-session-notification-vz86nt79.js} +2 -2
  73. package/dist/{transform-postprocess-phase-6menyyxc.js → transform-postprocess-phase-27we33af.js} +10 -10
  74. package/dist/v2/auto-search-worker.js +3 -3
  75. package/dist/v2/chunk-embedding-write-worker.js +1 -1
  76. package/dist/v2/{context-0qhz1nnj.js → context-g4ptae4x.js} +197 -80
  77. package/dist/v2/{embedding-backfill-rh5dgsva.js → embedding-backfill-35k6czrr.js} +2 -2
  78. package/dist/v2/hidden-completion.d.ts.map +1 -1
  79. package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
  80. package/dist/v2/hooks/store.d.ts.map +1 -1
  81. package/dist/v2/{message-index-bounded-n09b74vr.js → message-index-bounded-7363502m.js} +3 -3
  82. package/dist/v2/migration-worker.js +1 -1
  83. package/dist/v2/{project-embedding-registry-6pak822h.js → project-embedding-registry-p1p10ks7.js} +1 -1
  84. package/dist/v2/raw-ordinal-warmup-worker.js +2 -2
  85. package/dist/v2/{read-session-chunk-vpt69tw9.js → read-session-chunk-kkppfhft.js} +2 -2
  86. package/dist/v2/{recomp-orchestrator-txsmbnvw.js → recomp-orchestrator-f1df1gb8.js} +10 -10
  87. package/dist/v2/{search-dcy9b6gd.js → search-2v3xyzse.js} +7 -7
  88. package/dist/v2/{search-archive-t9bcz4ht.js → search-archive-v07jpw25.js} +3 -3
  89. package/dist/v2/{send-session-notification-vdsgnf4c.js → send-session-notification-x5nzy34v.js} +2 -2
  90. package/dist/v2/{server-e3hc93wk.js → server-77gznpmf.js} +1 -1
  91. package/dist/v2/{server-94wk1ey3.js → server-835q39kd.js} +45 -5
  92. package/dist/v2/{server-txbc3czn.js → server-976dxaxh.js} +10 -6
  93. package/dist/v2/{server-3vhxy2k5.js → server-a7x00tw8.js} +5 -5
  94. package/dist/v2/{server-z2n2xaeh.js → server-k9je35ev.js} +1 -1
  95. package/dist/v2/{server-xkvxss5g.js → server-mxzj3r0y.js} +5 -1
  96. package/dist/v2/{server-6avtp9jp.js → server-p0snacz3.js} +1 -1
  97. package/dist/v2/{server-z3mk9jdc.js → server-ph300d6m.js} +1 -1
  98. package/dist/v2/{server-jj9qye8y.js → server-q50ttc2g.js} +62 -21
  99. package/dist/v2/{server-6v3cdzsx.js → server-qc915kw2.js} +1 -1
  100. package/dist/v2/{server-zmcrvpm3.js → server-w79f8ejn.js} +2 -2
  101. package/dist/v2/{server-yqek3s4k.js → server-zh3esb0z.js} +4 -2
  102. package/dist/v2/server.js +3 -3
  103. package/dist/v2/{wrapup-orchestrator-gjkszser.js → wrapup-orchestrator-jq33fda8.js} +10 -10
  104. package/dist/{wrapup-orchestrator-n5h5sr1x.js → wrapup-orchestrator-f0xr7pft.js} +11 -11
  105. package/package.json +1 -1
  106. package/src/config/commit-retention-recovery.ts +34 -0
  107. package/src/config/index.ts +22 -2
  108. package/src/config/live-child-output-cap.test.ts +28 -0
  109. package/src/config/live-child-output-cap.ts +2 -0
  110. package/src/config/live-run-config.test.ts +44 -1
  111. package/src/config/live-run-config.ts +8 -1
  112. package/src/config/project-config-trust-boundary.test.ts +57 -0
  113. package/src/config/project-security.ts +6 -2
  114. package/src/shared/windows-hidden-spawns.test.ts +133 -23
@@ -82,6 +82,191 @@ import {
82
82
  parkGitSweepNonIndexable,
83
83
  releaseGitSweepLease
84
84
  } from "./index-kfyb3k6n.js";
85
+ import {
86
+ getMagicContextBuiltinCommands,
87
+ formatConfigParseStatusLine,
88
+ isCommitRetentionPaused,
89
+ cortexKitUserConfigBasePath,
90
+ cortexKitProjectConfigBasePath,
91
+ resolveLegacyConfigSources,
92
+ loadPluginConfigDetailed,
93
+ historianRunConfig,
94
+ currentPluginConfigReader,
95
+ clampProducerAtomChars,
96
+ producerInputTokenLimit,
97
+ historianProducerReserve,
98
+ producerPromptFailureReason,
99
+ DREAMER_AGENT,
100
+ DREAMER_RETROSPECTIVE_AGENT,
101
+ DREAMER_PRIMER_INVESTIGATOR_AGENT,
102
+ DREAMER_MEMORY_MAPPER_AGENT,
103
+ DREAMER_CLASSIFIER_AGENT,
104
+ DREAMER_DOCS_AGENT,
105
+ DREAMER_REVIEWER_AGENT,
106
+ getCompartments,
107
+ getLastCompartmentEndMessage,
108
+ getLastCompartmentEndMessageId,
109
+ providerResponseFailed,
110
+ LkgRecoveryFenceError,
111
+ lkgServedArrayDigest,
112
+ hasCleanLkgRecoveryFence,
113
+ dirtyLkgRecoveryRevision,
114
+ ownsLkgDirtyFence,
115
+ invalidateCleanLkgRecoveryFence,
116
+ prepareLkgCaptureFence,
117
+ certifyCommittedLkgCapture,
118
+ markLkgRecoveryDirty,
119
+ getOrCreateSessionMeta,
120
+ updateSessionMeta,
121
+ retryPendingSessionCleanups,
122
+ retryPendingRustSessionCleanupsForProject,
123
+ requestPendingMaterialization,
124
+ hasPendingMaterializationOrigin,
125
+ clearPendingMaterialization,
126
+ recordSystemPromptForRequest,
127
+ recordHeldHeadForRequest,
128
+ isHeldHeadForRequest,
129
+ deferDeliveredSystemRefresh,
130
+ retirePendingSystemPromptDelivery,
131
+ claimLkgRequestIdentity,
132
+ currentLkgRequestIdentity,
133
+ noteCapturedLkgRequest,
134
+ measuredLkgPrefix,
135
+ saveLkgSlotToDb,
136
+ clearPersistedLkgSlotStrict,
137
+ loadPersistedLkgSlot,
138
+ drainStaleLkgSlots,
139
+ resolveLkgModelKeys,
140
+ createLkgEntryProjector,
141
+ captureLkgSlot,
142
+ validateAnthropicReasoningRuns,
143
+ validateLkgSeam,
144
+ replayLkg,
145
+ coldStartRawServedIndex,
146
+ coldStartUncapturedReplay,
147
+ noteUncertifiedNormalLkg,
148
+ hasProcessLocalLkgProof,
149
+ lkgDirtyRevision,
150
+ rememberLkgDirtyRevision,
151
+ readPersistedLkgUntaggedInputIds,
152
+ persistLkgUntaggedInputIds,
153
+ noteLkgRecoveryPrefix,
154
+ readLkgRecoveryPrefix,
155
+ noteLkgHealthyPrefix,
156
+ lkgRecoveryReplayUnproven,
157
+ lkgRecoveryEntryUnproven,
158
+ lkgInputIdentity,
159
+ beginLkgPass,
160
+ visitMessageContentFields,
161
+ contentSnapshotValue,
162
+ messageContentFields,
163
+ signatureForFields,
164
+ exactReusablePrefix,
165
+ incrementalLkgContentDigests,
166
+ lkgSlotRejection,
167
+ captureSlot,
168
+ getInMemorySlot,
169
+ getSlot,
170
+ forgetInMemorySlot,
171
+ dropSlot,
172
+ noteEntry,
173
+ getLkgSlotHeapStats,
174
+ TOOL_SWEEP_SCOPED_MARKER,
175
+ useScopedToolSweep,
176
+ createPreAdoptionToolSweepResolver,
177
+ queueMemoryMutation,
178
+ getMaxMemoryMutationIdForProjects,
179
+ GLOBAL_USER_PROFILE_PROJECT_PATH,
180
+ getProjectState,
181
+ bumpProjectUserProfileVersion,
182
+ createChildSessionWithFence,
183
+ HiddenCompletionRefusal,
184
+ DreamerProviderOutputFailureError,
185
+ withDreamerModelCooldown,
186
+ providerOutputFailureFromInvalidManifest,
187
+ extractLatestAssistantText,
188
+ hasLengthCappedOutput,
189
+ parseProviderModel,
190
+ modelBodyField,
191
+ toModelEntry,
192
+ isPromptTimeoutError,
193
+ getPromptFailureDetail,
194
+ raceWithSignal,
195
+ promptSyncWithValidatedOutputRetry,
196
+ normalizeSDKResponse,
197
+ annotateSubagentInvocationError,
198
+ failedInvocationStatus,
199
+ emptyTokenTotals,
200
+ sumTokensFromChildMessages,
201
+ recordChildInvocation,
202
+ createPromptAsyncTransport,
203
+ systemPromptFingerprint,
204
+ createPromptSurfaceRuntime,
205
+ createPromptSurfaceGuidanceEpochCache,
206
+ teardownChildSession,
207
+ getCompartmentEvents,
208
+ runTokenLog,
209
+ formatRunTokenLog,
210
+ buildMagicContextSection,
211
+ getMuralIdentity,
212
+ getMural,
213
+ modelKeyAcceptsImages,
214
+ resolveMuralWire,
215
+ USER_MEMORY_CANDIDATE_TTL_MS,
216
+ insertUserMemoryCandidates,
217
+ getUserMemoryCandidates,
218
+ deleteUserMemoryCandidates,
219
+ pruneExpiredUserMemoryCandidates,
220
+ insertUserMemory,
221
+ getActiveUserMemories,
222
+ updateUserMemoryContent,
223
+ dismissUserMemory,
224
+ getOpenCodeDbPath,
225
+ prepareCompactionMarkerCandidates,
226
+ removeMcOwnedCompactionMarkers,
227
+ MARKER_SUMMARY_TEXT,
228
+ markerUpdateDefinitelyDidNotCut,
229
+ extractM0Block,
230
+ formatDate,
231
+ TEMPORAL_MARKER_REPLAY_PATTERN,
232
+ collectTemporalCandidates,
233
+ injectTemporalMarkers,
234
+ getVisibleMemoryIds,
235
+ selectHiddenMessagesAtCompactionSeam,
236
+ prepareCompartmentInjection,
237
+ mustMaterialize,
238
+ trimMemoriesToBudgetV2,
239
+ renderMemoryBlockV2,
240
+ findHostCompactionWindow,
241
+ capturePrefixTrimSourceOrder,
242
+ resolveHiddenCompletionExecutor,
243
+ createV1HiddenCompletionExecutor,
244
+ readCoordinateGeneration,
245
+ readCoordinateRebaseNotice,
246
+ formatCoordinateRebaseNotice,
247
+ rebaseSessionCoordinatesAsync,
248
+ shouldWaitForNewHistorianHistory,
249
+ EMPTY_READ_REPLY,
250
+ noteTouchedAt,
251
+ renderGlance,
252
+ renderNotesById,
253
+ formatWriteReply,
254
+ onNoteTrigger,
255
+ clearNoteNudgeTriggerAndCooldown,
256
+ resetNoteNudgeCooldownOnly,
257
+ omitIncompleteFileTokenTotals,
258
+ RECOVERY_NO_HEAD_LIMIT,
259
+ deriveProtectedTailTokenTarget,
260
+ selectPerRunCap,
261
+ resolveOpenCodeProtectedTailBoundary,
262
+ getRawHistoryEligibility,
263
+ hasRunnableCompartmentWindow,
264
+ recordHighPressureNoEligibleHead,
265
+ noteTransformPassForExactOrdinalReads,
266
+ snapRangeToCompartments,
267
+ getActiveCompartmentRun,
268
+ startCompartmentAgent
269
+ } from "./index-q9zvphbq.js";
85
270
  import {
86
271
  hasTrustedAbsoluteWall,
87
272
  applyProvenInputFloor,
@@ -177,7 +362,7 @@ import {
177
362
  latestPersistedMessageForRecovery,
178
363
  latestRealUserTurnIdFromOpenCodeDb,
179
364
  findLastAssistantModelFromOpenCodeDb
180
- } from "./index-v0dhhxsq.js";
365
+ } from "./index-y1qwzvxn.js";
181
366
  import {
182
367
  expandToolPart,
183
368
  askAnswerLines,
@@ -302,7 +487,7 @@ import {
302
487
  readRawSessionMessageById2,
303
488
  readSessionChunk2,
304
489
  readRawSessionSeedTail2
305
- } from "./index-yzjhx10y.js";
490
+ } from "./index-zhgqgxtt.js";
306
491
  import {
307
492
  BoundedSessionMap,
308
493
  getMeasuredToolDefinitionTokens
@@ -320,7 +505,7 @@ import {
320
505
  runSqliteOptimize,
321
506
  openDatabase,
322
507
  openCurrentDatabase
323
- } from "./index-4cpc59jv.js";
508
+ } from "./index-h4s5jk7f.js";
324
509
  import {
325
510
  registerOwnRpcServerInstance,
326
511
  rpcPortDir,
@@ -344,188 +529,6 @@ import {
344
529
  V2_MEMORY_CATEGORIES,
345
530
  CATEGORY_PRIORITY
346
531
  } from "./index-fr0wbhdn.js";
347
- import {
348
- getMagicContextBuiltinCommands,
349
- formatConfigParseStatusLine,
350
- cortexKitUserConfigBasePath,
351
- cortexKitProjectConfigBasePath,
352
- resolveLegacyConfigSources,
353
- loadPluginConfigDetailed,
354
- historianRunConfig,
355
- currentPluginConfigReader,
356
- clampProducerAtomChars,
357
- producerInputTokenLimit,
358
- historianProducerReserve,
359
- producerPromptFailureReason,
360
- DREAMER_AGENT,
361
- DREAMER_RETROSPECTIVE_AGENT,
362
- DREAMER_PRIMER_INVESTIGATOR_AGENT,
363
- DREAMER_MEMORY_MAPPER_AGENT,
364
- DREAMER_CLASSIFIER_AGENT,
365
- DREAMER_DOCS_AGENT,
366
- DREAMER_REVIEWER_AGENT,
367
- getCompartments,
368
- getLastCompartmentEndMessage,
369
- getLastCompartmentEndMessageId,
370
- providerResponseFailed,
371
- LkgRecoveryFenceError,
372
- lkgServedArrayDigest,
373
- hasCleanLkgRecoveryFence,
374
- dirtyLkgRecoveryRevision,
375
- ownsLkgDirtyFence,
376
- invalidateCleanLkgRecoveryFence,
377
- prepareLkgCaptureFence,
378
- certifyCommittedLkgCapture,
379
- markLkgRecoveryDirty,
380
- getOrCreateSessionMeta,
381
- updateSessionMeta,
382
- retryPendingSessionCleanups,
383
- retryPendingRustSessionCleanupsForProject,
384
- requestPendingMaterialization,
385
- hasPendingMaterializationOrigin,
386
- clearPendingMaterialization,
387
- recordSystemPromptForRequest,
388
- recordHeldHeadForRequest,
389
- isHeldHeadForRequest,
390
- deferDeliveredSystemRefresh,
391
- retirePendingSystemPromptDelivery,
392
- claimLkgRequestIdentity,
393
- currentLkgRequestIdentity,
394
- noteCapturedLkgRequest,
395
- measuredLkgPrefix,
396
- saveLkgSlotToDb,
397
- clearPersistedLkgSlotStrict,
398
- loadPersistedLkgSlot,
399
- drainStaleLkgSlots,
400
- resolveLkgModelKeys,
401
- createLkgEntryProjector,
402
- captureLkgSlot,
403
- validateAnthropicReasoningRuns,
404
- validateLkgSeam,
405
- replayLkg,
406
- coldStartRawServedIndex,
407
- coldStartUncapturedReplay,
408
- noteUncertifiedNormalLkg,
409
- hasProcessLocalLkgProof,
410
- lkgDirtyRevision,
411
- rememberLkgDirtyRevision,
412
- readPersistedLkgUntaggedInputIds,
413
- persistLkgUntaggedInputIds,
414
- noteLkgRecoveryPrefix,
415
- readLkgRecoveryPrefix,
416
- noteLkgHealthyPrefix,
417
- lkgRecoveryReplayUnproven,
418
- lkgRecoveryEntryUnproven,
419
- beginLkgPass,
420
- visitMessageContentFields,
421
- contentSnapshotValue,
422
- messageContentFields,
423
- signatureForFields,
424
- exactReusablePrefix,
425
- incrementalLkgContentDigests,
426
- lkgSlotRejection,
427
- captureSlot,
428
- getInMemorySlot,
429
- getSlot,
430
- forgetInMemorySlot,
431
- dropSlot,
432
- noteEntry,
433
- getLkgSlotHeapStats,
434
- TOOL_SWEEP_SCOPED_MARKER,
435
- useScopedToolSweep,
436
- createPreAdoptionToolSweepResolver,
437
- queueMemoryMutation,
438
- getMaxMemoryMutationIdForProjects,
439
- GLOBAL_USER_PROFILE_PROJECT_PATH,
440
- getProjectState,
441
- bumpProjectUserProfileVersion,
442
- createChildSessionWithFence,
443
- HiddenCompletionRefusal,
444
- DreamerProviderOutputFailureError,
445
- withDreamerModelCooldown,
446
- providerOutputFailureFromInvalidManifest,
447
- extractLatestAssistantText,
448
- hasLengthCappedOutput,
449
- parseProviderModel,
450
- modelBodyField,
451
- toModelEntry,
452
- isPromptTimeoutError,
453
- getPromptFailureDetail,
454
- raceWithSignal,
455
- promptSyncWithValidatedOutputRetry,
456
- normalizeSDKResponse,
457
- annotateSubagentInvocationError,
458
- failedInvocationStatus,
459
- sumTokensFromChildMessages,
460
- recordChildInvocation,
461
- createPromptAsyncTransport,
462
- systemPromptFingerprint,
463
- createPromptSurfaceRuntime,
464
- createPromptSurfaceGuidanceEpochCache,
465
- teardownChildSession,
466
- getCompartmentEvents,
467
- runTokenLog,
468
- formatRunTokenLog,
469
- buildMagicContextSection,
470
- getMuralIdentity,
471
- getMural,
472
- modelKeyAcceptsImages,
473
- resolveMuralWire,
474
- USER_MEMORY_CANDIDATE_TTL_MS,
475
- insertUserMemoryCandidates,
476
- getUserMemoryCandidates,
477
- deleteUserMemoryCandidates,
478
- pruneExpiredUserMemoryCandidates,
479
- insertUserMemory,
480
- getActiveUserMemories,
481
- updateUserMemoryContent,
482
- dismissUserMemory,
483
- getOpenCodeDbPath,
484
- prepareCompactionMarkerCandidates,
485
- removeMcOwnedCompactionMarkers,
486
- MARKER_SUMMARY_TEXT,
487
- markerUpdateDefinitelyDidNotCut,
488
- extractM0Block,
489
- formatDate,
490
- TEMPORAL_MARKER_REPLAY_PATTERN,
491
- collectTemporalCandidates,
492
- injectTemporalMarkers,
493
- getVisibleMemoryIds,
494
- selectHiddenMessagesAtCompactionSeam,
495
- prepareCompartmentInjection,
496
- mustMaterialize,
497
- trimMemoriesToBudgetV2,
498
- renderMemoryBlockV2,
499
- findHostCompactionWindow,
500
- capturePrefixTrimSourceOrder,
501
- resolveHiddenCompletionExecutor,
502
- createV1HiddenCompletionExecutor,
503
- readCoordinateGeneration,
504
- readCoordinateRebaseNotice,
505
- formatCoordinateRebaseNotice,
506
- rebaseSessionCoordinatesAsync,
507
- shouldWaitForNewHistorianHistory,
508
- EMPTY_READ_REPLY,
509
- noteTouchedAt,
510
- renderGlance,
511
- renderNotesById,
512
- formatWriteReply,
513
- onNoteTrigger,
514
- clearNoteNudgeTriggerAndCooldown,
515
- resetNoteNudgeCooldownOnly,
516
- omitIncompleteFileTokenTotals,
517
- RECOVERY_NO_HEAD_LIMIT,
518
- deriveProtectedTailTokenTarget,
519
- selectPerRunCap,
520
- resolveOpenCodeProtectedTailBoundary,
521
- getRawHistoryEligibility,
522
- hasRunnableCompartmentWindow,
523
- recordHighPressureNoEligibleHead,
524
- noteTransformPassForExactOrdinalReads,
525
- snapRangeToCompartments,
526
- getActiveCompartmentRun,
527
- startCompartmentAgent
528
- } from "./index-dcqk0y27.js";
529
532
  import {
530
533
  embedPauseBySession,
531
534
  embedRunStateBySession,
@@ -553,7 +556,7 @@ import {
553
556
  embedSessionCompartmentChunks2,
554
557
  getEmbeddingCoverageStatus2,
555
558
  getAutoEmbeddingSessionCoverage2
556
- } from "./index-a2fz9hpa.js";
559
+ } from "./index-gxkhzmjq.js";
557
560
  import {
558
561
  SubcClient,
559
562
  connectionFileExists,
@@ -571,7 +574,7 @@ import {
571
574
  clearIndexedMessages,
572
575
  indexSingleMessage,
573
576
  indexMessagesAfterOrdinal
574
- } from "./index-7gbcg8xv.js";
577
+ } from "./index-tx68g9nc.js";
575
578
  import {
576
579
  renderUserFacingFailure,
577
580
  userFacingFailureCode,
@@ -615,7 +618,7 @@ import {
615
618
  readGitFileChangeTimesSince,
616
619
  verificationFileExists,
617
620
  normalizeVerificationFiles
618
- } from "./index-t3rbb8wr.js";
621
+ } from "./index-pe6b4bhs.js";
619
622
  import {
620
623
  registerNotificationSink2,
621
624
  pushNotification2,
@@ -635,7 +638,7 @@ import {
635
638
  } from "./index-4dhv7mqz.js";
636
639
  import {
637
640
  cosineSimilarity
638
- } from "./index-4ypqzvhf.js";
641
+ } from "./index-vnn5405n.js";
639
642
  import {
640
643
  computeCueContentHash,
641
644
  hasMuralCueColumns,
@@ -681,17 +684,17 @@ import {
681
684
  resolveMemoriesByIdsForSearch2,
682
685
  unifiedSearch2,
683
686
  formatSearchResults2
684
- } from "./index-dzfevacx.js";
687
+ } from "./index-wvffze8y.js";
685
688
  import {
686
689
  flushIgnoredMessages2,
687
690
  clearIgnoredMessages2,
688
691
  observeIgnoredNotificationEvent2,
689
692
  sendStatusNotification2
690
- } from "./index-077ht5cq.js";
693
+ } from "./index-waktfbjy.js";
691
694
  import {
692
695
  setRecompStarting2,
693
696
  setRecompTerminal2
694
- } from "./index-n8qmmd7f.js";
697
+ } from "./index-093c4g1c.js";
695
698
  import {
696
699
  makeToolCompositeKey,
697
700
  searchMessageHistoryOffThread,
@@ -735,6 +738,7 @@ import {
735
738
  replayCavemanCompression,
736
739
  DegradedPassRefusalError,
737
740
  degradedPassError,
741
+ renderDroppedText,
738
742
  applyFlushedStatuses,
739
743
  prewarmTagOwners,
740
744
  waitForTagOwners,
@@ -753,7 +757,7 @@ import {
753
757
  abortSessionFailClosed2,
754
758
  evaluateEmergencyFailClosed2,
755
759
  runPostTransformPhase2
756
- } from "./index-fq2p158w.js";
760
+ } from "./index-bps8vn9r.js";
757
761
  import {
758
762
  ANNOUNCEMENT_VERSION2,
759
763
  ANNOUNCEMENT_FEATURES2,
@@ -766,7 +770,7 @@ import {
766
770
  } from "./index-fmsr7v69.js";
767
771
  import {
768
772
  renderSearchArchiveOffThread2
769
- } from "./index-89k1w6x2.js";
773
+ } from "./index-a1h316s9.js";
770
774
  import {
771
775
  COMPACTION_ENABLED_PATH,
772
776
  isDreamerRunnable,
@@ -2952,7 +2956,7 @@ async function runHiddenSingleShotPrompt(args) {
2952
2956
  let timer;
2953
2957
  try {
2954
2958
  const completion = await Promise.race([
2955
- args.executor.collect(handle, 200),
2959
+ args.executor.collectPartial?.(handle, 200) ?? args.executor.collect(handle, 200),
2956
2960
  new Promise((resolve) => {
2957
2961
  timer = setTimeout(() => resolve(null), 5000);
2958
2962
  })
@@ -5598,6 +5602,7 @@ Remember: output only the JSON object described by the system prompt.`;
5598
5602
  let childSessionId = null;
5599
5603
  let promptSettled = false;
5600
5604
  let invocationRecorded = false;
5605
+ let completionUsage;
5601
5606
  const recordInvocation = (params) => {
5602
5607
  if (!args.db || !args.parentSessionId || invocationRecorded)
5603
5608
  return;
@@ -5611,6 +5616,7 @@ Remember: output only the JSON object described by the system prompt.`;
5611
5616
  startedAt,
5612
5617
  status: params.status,
5613
5618
  messages: params.messages,
5619
+ tokens: args.hiddenCompletionExecutor?.capabilities.harness === "opencode2" ? completionUsage : undefined,
5614
5620
  attemptedModel: args.model,
5615
5621
  configuredModels: args.fallbackModels,
5616
5622
  error: params.error
@@ -5635,11 +5641,15 @@ Remember: output only the JSON object described by the system prompt.`;
5635
5641
  timeoutMs: remainingMs,
5636
5642
  signal: args.signal,
5637
5643
  metadata: { task: "evaluate-smart-notes" },
5644
+ onFailureOutput: (completion) => {
5645
+ completionUsage = completion.usage;
5646
+ },
5638
5647
  parse: parseCompilerOutput
5639
5648
  });
5640
5649
  promptSettled = true;
5641
5650
  response = carried.validated;
5642
5651
  outputMessages = carried.completion.messages;
5652
+ completionUsage = carried.completion.usage;
5643
5653
  } else {
5644
5654
  const client = args.client;
5645
5655
  if (!client) {
@@ -6599,6 +6609,7 @@ async function confirmReadOnly(args, noteId, content, surfaceCondition, leaseSig
6599
6609
  startedAt,
6600
6610
  status: params.status,
6601
6611
  messages: params.messages,
6612
+ tokens: args.hiddenCompletionExecutor?.capabilities.harness === "opencode2" ? params.tokens : undefined,
6602
6613
  attemptedModel: args.model,
6603
6614
  configuredModels: args.fallbackModels,
6604
6615
  error: params.error
@@ -6626,7 +6637,11 @@ async function confirmReadOnly(args, noteId, content, surfaceCondition, leaseSig
6626
6637
  parse: parseConfirmationVerdict
6627
6638
  });
6628
6639
  promptSettled = true;
6629
- recordInvocation({ status: "completed", messages: run.completion.messages });
6640
+ recordInvocation({
6641
+ status: "completed",
6642
+ messages: run.completion.messages,
6643
+ tokens: run.completion.usage
6644
+ });
6630
6645
  return run.validated;
6631
6646
  } finally {
6632
6647
  promptSignal.cleanup();
@@ -7294,7 +7309,8 @@ async function mapOneBatch(args, batch, sliceMs, signal) {
7294
7309
  });
7295
7310
  recordInvocation2(args, startedAt, {
7296
7311
  status: "completed",
7297
- messages: run.completion.messages ?? []
7312
+ messages: run.completion.messages ?? [],
7313
+ tokens: run.completion.usage
7298
7314
  });
7299
7315
  stage = "apply";
7300
7316
  const outcome = await applyParsedBatchMappings(args, batch, run.validated, budgetFinalized, true);
@@ -7369,7 +7385,8 @@ async function mapOneBatch(args, batch, sliceMs, signal) {
7369
7385
  recordInvocation2(args, startedAt, {
7370
7386
  status: failedInvocationStatus(error),
7371
7387
  error,
7372
- messages
7388
+ messages,
7389
+ tokens: failedCompletion?.usage
7373
7390
  });
7374
7391
  if (error instanceof DreamerModuleFailureError)
7375
7392
  throw error;
@@ -7536,6 +7553,7 @@ function recordInvocation2(args, startedAt, params) {
7536
7553
  startedAt,
7537
7554
  status: params.status,
7538
7555
  messages: params.messages,
7556
+ tokens: args.hiddenCompletionExecutor?.capabilities.harness === "opencode2" ? params.tokens : undefined,
7539
7557
  attemptedModel: args.model,
7540
7558
  configuredModels: args.fallbackModels,
7541
7559
  error: params.error
@@ -8670,7 +8688,8 @@ async function git2(root, args) {
8670
8688
  cwd: root,
8671
8689
  timeout: 1e4,
8672
8690
  maxBuffer: MAX_DIFF_BYTES,
8673
- encoding: "utf8"
8691
+ encoding: "utf8",
8692
+ windowsHide: true
8674
8693
  });
8675
8694
  return stdout;
8676
8695
  }
@@ -9312,7 +9331,8 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
9312
9331
  });
9313
9332
  recordInvocation4(args, startedAt, {
9314
9333
  status: "completed",
9315
- messages: run.completion.messages ?? []
9334
+ messages: run.completion.messages ?? [],
9335
+ tokens: run.completion.usage
9316
9336
  });
9317
9337
  reportUsage(run.completion.messages ?? [], run.childSessionId, run.completion.usage.input + (run.completion.usage.cacheRead ?? 0) + (run.completion.usage.cacheWrite ?? 0));
9318
9338
  return await applyParsedVerifyManifest(args, batch, run.validated, evidence?.head ?? headAtPrompt, budgetFinalized);
@@ -9386,7 +9406,8 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
9386
9406
  recordInvocation4(args, startedAt, {
9387
9407
  status: failedInvocationStatus(error),
9388
9408
  error,
9389
- messages
9409
+ messages,
9410
+ tokens: failedCompletion?.usage
9390
9411
  });
9391
9412
  if (error instanceof DreamerModuleFailureError || signal.aborted)
9392
9413
  throw error;
@@ -9645,6 +9666,7 @@ function recordInvocation4(args, startedAt, params) {
9645
9666
  startedAt,
9646
9667
  status: params.status,
9647
9668
  messages: params.messages,
9669
+ tokens: args.hiddenCompletionExecutor?.capabilities.harness === "opencode2" ? params.tokens : undefined,
9648
9670
  attemptedModel: args.model,
9649
9671
  configuredModels: args.fallbackModels,
9650
9672
  error: params.error
@@ -9714,6 +9736,15 @@ function classifyFailure(error) {
9714
9736
  const transient = explicitTransient || name === "AbortError" || /abort|lease|timeout|timed out|econn|socket|network|rate.?limit|429|503|overloaded|sqlite_busy|database is locked/.test(combined);
9715
9737
  return { transient, brief };
9716
9738
  }
9739
+ function sumCompletionUsages(usages) {
9740
+ return usages.reduce((total, usage) => ({
9741
+ input: total.input + usage.input,
9742
+ output: total.output + usage.output,
9743
+ cacheRead: total.cacheRead + usage.cacheRead,
9744
+ cacheWrite: total.cacheWrite + usage.cacheWrite,
9745
+ ...total.reasoning !== undefined || usage.reasoning !== undefined ? { reasoning: (total.reasoning ?? 0) + (usage.reasoning ?? 0) } : {}
9746
+ }), emptyTokenTotals());
9747
+ }
9717
9748
  function newIds(beforeIds, afterIds) {
9718
9749
  const before = new Set(beforeIds);
9719
9750
  const out = [];
@@ -10521,6 +10552,7 @@ async function runRetrospectiveTask(config, ctx, helpers) {
10521
10552
  }, ctx.leaseAcquisition);
10522
10553
  let childSessionId = null;
10523
10554
  let hiddenHandle = null;
10555
+ const hiddenUsages = [];
10524
10556
  let promptSettled = false;
10525
10557
  let invocationRecorded = false;
10526
10558
  const recordInvocation = (status, messages, error) => {
@@ -10536,6 +10568,7 @@ async function runRetrospectiveTask(config, ctx, helpers) {
10536
10568
  startedAt: helpers.invocationStartedAt,
10537
10569
  status,
10538
10570
  messages,
10571
+ tokens: deps.hiddenCompletionExecutor?.capabilities.harness === "opencode2" && hiddenUsages.length ? sumCompletionUsages(hiddenUsages) : undefined,
10539
10572
  attemptedModel: config.model,
10540
10573
  configuredModels: config.fallbackModels,
10541
10574
  error
@@ -10621,6 +10654,8 @@ async function runRetrospectiveTask(config, ctx, helpers) {
10621
10654
  }
10622
10655
  });
10623
10656
  promptSettled = true;
10657
+ if (hiddenHandle)
10658
+ hiddenUsages.push(run.output.usage);
10624
10659
  const output = hiddenHandle ? run.output.messages ?? [] : run.output;
10625
10660
  return { ...run, output };
10626
10661
  };
@@ -10791,6 +10826,7 @@ async function runAgenticTask(config, ctx, helpers) {
10791
10826
  let childSessionId = null;
10792
10827
  let promptSettled = false;
10793
10828
  let expiredArchived = 0;
10829
+ const hiddenUsages = [];
10794
10830
  let invocationRecorded = false;
10795
10831
  const recordInvocation = (status, messages, error) => {
10796
10832
  if (!parent || !childSessionId || invocationRecorded)
@@ -10805,6 +10841,7 @@ async function runAgenticTask(config, ctx, helpers) {
10805
10841
  startedAt: invocationStartedAt,
10806
10842
  status,
10807
10843
  messages,
10844
+ tokens: deps.hiddenCompletionExecutor?.capabilities.harness === "opencode2" && hiddenUsages.length ? sumCompletionUsages(hiddenUsages) : undefined,
10808
10845
  attemptedModel: config.model,
10809
10846
  configuredModels: config.fallbackModels,
10810
10847
  error
@@ -10922,6 +10959,7 @@ async function runAgenticTask(config, ctx, helpers) {
10922
10959
  }
10923
10960
  });
10924
10961
  childSessionId = hidden.childSessionId;
10962
+ hiddenUsages.push(hidden.completion.usage);
10925
10963
  run = { output: hidden.completion.messages ?? [], validated: hidden.validated };
10926
10964
  promptSettled = true;
10927
10965
  } else {
@@ -11910,7 +11948,8 @@ async function sweepGitCommits(args) {
11910
11948
  try {
11911
11949
  const result = await indexCommitsForProject(db, projectIdentity, directory, {
11912
11950
  sinceDays: gitCommitIndexing.since_days,
11913
- maxCommits: gitCommitIndexing.max_commits
11951
+ maxCommits: gitCommitIndexing.max_commits,
11952
+ skipRetention: isCommitRetentionPaused(gitCommitIndexing)
11914
11953
  });
11915
11954
  if (result.nonIndexable) {
11916
11955
  if (!parkGitSweepNonIndexable(db, projectIdentity, holderId)) {
@@ -11973,28 +12012,28 @@ var EMBEDDING_AFFECTING_KEYS = new Set([
11973
12012
  "embedding.query_instruction",
11974
12013
  "embedding.document_prefix",
11975
12014
  "embedding.fallback_provider",
11976
- "subc",
12015
+ "embedding.local_runtime",
12016
+ "embedding.local_dtype",
11977
12017
  "subc.connection_file",
11978
- "shadow_embedding"
12018
+ "shadow_embedding.enabled",
12019
+ "memory.enabled",
12020
+ "memory.git_commit_indexing.enabled",
12021
+ "allow_home_project"
11979
12022
  ]);
11980
12023
  var LITERAL_CONFIG_TOKEN_RE = /\{(?:env|file):[^}]+\}/;
11981
- function embeddingConfigHasLiteralTokens(embedding) {
11982
- if (!embedding)
11983
- return false;
11984
- for (const value of Object.values(embedding)) {
12024
+ function affectsEmbeddingRegistration(path) {
12025
+ return [...EMBEDDING_AFFECTING_KEYS].some((field) => field === path || field.startsWith(`${path}.`));
12026
+ }
12027
+ function untrustedConfigFieldPaths(detailed) {
12028
+ const paths = (detailed.recoveredFieldPaths ?? detailed.recoveredTopLevelKeys).filter(affectsEmbeddingRegistration);
12029
+ paths.push(...detailed.substitutionFailures.map((failure) => failure.keyPath).filter(affectsEmbeddingRegistration));
12030
+ for (const [key, value] of Object.entries(detailed.config.embedding)) {
11985
12031
  if (typeof value === "string" && LITERAL_CONFIG_TOKEN_RE.test(value)) {
11986
- return true;
12032
+ paths.push(`embedding.${key}`);
11987
12033
  }
11988
12034
  }
11989
- return false;
12035
+ return [...new Set(paths)].sort();
11990
12036
  }
11991
- var EMBEDDING_AFFECTING_TOP_LEVEL_KEYS = new Set([
11992
- "embedding",
11993
- "memory",
11994
- "experimental",
11995
- "subc",
11996
- "shadow_embedding"
11997
- ]);
11998
12037
  var EMBEDDING_WARNING_TERMS = [
11999
12038
  "api_key",
12000
12039
  "endpoint",
@@ -12019,21 +12058,12 @@ function isConfigLoadUntrusted(detailed) {
12019
12058
  return true;
12020
12059
  }
12021
12060
  for (const failure of detailed.substitutionFailures) {
12022
- if (EMBEDDING_AFFECTING_KEYS.has(failure.keyPath)) {
12023
- return true;
12024
- }
12025
12061
  if (failure.keyPath === "<unknown>" && warningLooksEmbeddingRelated(failure.message)) {
12026
12062
  return true;
12027
12063
  }
12028
12064
  }
12029
- for (const recoveredKey of detailed.recoveredTopLevelKeys) {
12030
- if (EMBEDDING_AFFECTING_TOP_LEVEL_KEYS.has(recoveredKey)) {
12031
- return true;
12032
- }
12033
- }
12034
- if (embeddingConfigHasLiteralTokens(detailed.config.embedding)) {
12065
+ if (untrustedConfigFieldPaths(detailed).length > 0)
12035
12066
  return true;
12036
- }
12037
12067
  return false;
12038
12068
  }
12039
12069
  function describeFailure(detailed) {
@@ -12046,8 +12076,9 @@ function describeFailure(detailed) {
12046
12076
  if (detailed.substitutionFailures.length > 0) {
12047
12077
  parts.push(`substitution=${detailed.substitutionFailures.map((failure) => `${failure.source}:${failure.keyPath}`).join(",")}`);
12048
12078
  }
12049
- if (detailed.recoveredTopLevelKeys.length > 0) {
12050
- parts.push(`recovered=${detailed.recoveredTopLevelKeys.join(",")}`);
12079
+ const recovered = detailed.recoveredFieldPaths ?? detailed.recoveredTopLevelKeys;
12080
+ if (recovered.length > 0) {
12081
+ parts.push(`recovered=${recovered.join(",")}`);
12051
12082
  }
12052
12083
  return parts.length > 0 ? parts.join("; ") : detailed.loadOutcome;
12053
12084
  }
@@ -12055,7 +12086,8 @@ function logConfigFailureOnce(projectIdentity, detailed) {
12055
12086
  const signature = sha256Prefix(JSON.stringify({
12056
12087
  outcomes: detailed.sources,
12057
12088
  substitutions: detailed.substitutionFailures.map((failure) => `${failure.source}:${failure.keyPath}:${failure.message}`).sort(),
12058
- recoveredTopLevelKeys: [...detailed.recoveredTopLevelKeys].sort()
12089
+ recoveredTopLevelKeys: [...detailed.recoveredTopLevelKeys].sort(),
12090
+ recoveredFieldPaths: detailed.recoveredFieldPaths?.slice().sort()
12059
12091
  }));
12060
12092
  const existing = loggedFailureSignatures.get(projectIdentity) ?? new Set;
12061
12093
  if (existing.has(signature))
@@ -12071,9 +12103,14 @@ function handleUntrustedLoad(db, projectIdentity, directory, detailed) {
12071
12103
  logConfigFailureOnce(projectIdentity, detailed);
12072
12104
  return true;
12073
12105
  }
12074
- registerProjectInObservationMode2(db, projectIdentity, directory, detailed.config.embedding, describeFailure(detailed));
12106
+ registerProjectInObservationMode2(db, projectIdentity, directory, detailed.config.embedding, describeFailure(detailed), untrustedConfigMemoryMessage(detailed));
12075
12107
  return true;
12076
12108
  }
12109
+ function untrustedConfigMemoryMessage(detailed) {
12110
+ const fields = untrustedConfigFieldPaths(detailed);
12111
+ const cause = fields.length > 0 ? `has invalid embedding or project identity settings: ${fields.join(", ")}` : Object.values(detailed.sources).includes("legacy-config-unmigrated") ? "is awaiting config migration" : Object.values(detailed.sources).some((source) => source === "project-file-parse-error" || source === "project-file-io-error") ? "could not be read or parsed" : "has invalid embedding settings";
12112
+ return `Cross-session memory is off for this project because magic-context.jsonc ${cause}.`;
12113
+ }
12077
12114
 
12078
12115
  // src/plugin/embedding-routing.ts
12079
12116
  var SYNAPSE_PROBE_TTL_MS = 60000;
@@ -13236,8 +13273,23 @@ WHERE session_id = ?
13236
13273
  AND data IS NOT NULL
13237
13274
  AND (time_created > ? OR (time_created = ? AND id > ?))
13238
13275
  ORDER BY time_created, id`;
13239
- function readAssistantUsageRowsAfter(openCodeDb, sessionId, afterTimeCreated, afterId) {
13240
- const rows = openCodeDb.prepare(ASSISTANT_USAGE_ROWS_AFTER_SQL).all(sessionId, afterTimeCreated, afterTimeCreated, afterId);
13276
+ var V2_ASSISTANT_USAGE_ROWS_AFTER_SQL = `
13277
+ SELECT
13278
+ json_extract(data, '$.agent') AS agent,
13279
+ seq AS time_created,
13280
+ id AS id,
13281
+ COALESCE(json_extract(data, '$.tokens.input'), 0)
13282
+ + COALESCE(json_extract(data, '$.tokens.cache.read'), 0)
13283
+ + COALESCE(json_extract(data, '$.tokens.cache.write'), 0) AS prompt,
13284
+ COALESCE(json_extract(data, '$.tokens.output'), 0) AS output
13285
+ FROM session_message
13286
+ WHERE session_id = ?
13287
+ AND type = 'assistant'
13288
+ AND data IS NOT NULL
13289
+ AND (seq > ? OR (seq = ? AND id > ?))
13290
+ ORDER BY seq, id`;
13291
+ function readAssistantUsageRowsAfter(openCodeDb, sessionId, afterTimeCreated, afterId, generation = "v1") {
13292
+ const rows = openCodeDb.prepare(generation === "v2" ? V2_ASSISTANT_USAGE_ROWS_AFTER_SQL : ASSISTANT_USAGE_ROWS_AFTER_SQL).all(sessionId, afterTimeCreated, afterTimeCreated, afterId);
13241
13293
  return rows.map((r) => ({
13242
13294
  agent: r.agent ?? null,
13243
13295
  timeCreated: Number(r.time_created ?? 0),
@@ -13246,8 +13298,8 @@ function readAssistantUsageRowsAfter(openCodeDb, sessionId, afterTimeCreated, af
13246
13298
  output: Number(r.output ?? 0)
13247
13299
  }));
13248
13300
  }
13249
- function computeOpenCodeWorkMetricsIncremental(openCodeDb, sessionId, carry) {
13250
- const rows = readAssistantUsageRowsAfter(openCodeDb, sessionId, carry.lastTimeCreated, carry.lastId);
13301
+ function computeOpenCodeWorkMetricsIncremental(openCodeDb, sessionId, carry, generation = "v1") {
13302
+ const rows = readAssistantUsageRowsAfter(openCodeDb, sessionId, carry.lastTimeCreated, carry.lastId, generation);
13251
13303
  if (rows.length === 0) {
13252
13304
  return { carry, metrics: metricsFromCarry(carry) };
13253
13305
  }
@@ -15562,13 +15614,15 @@ function runnerStatusFromModule(status) {
15562
15614
  }
15563
15615
  var rustStatusInFlight = new Map;
15564
15616
  function resolveSidebarWorkMetrics(db, sessionId, persistedNewWork, persistedTotalInput) {
15565
- if (!openCodeDbExists()) {
15617
+ const generation = getHarness2() === "opencode2" ? "v2" : "v1";
15618
+ if (!openCodeDbExists(generation)) {
15566
15619
  return { newWorkTokens: persistedNewWork, totalInputTokens: persistedTotalInput };
15567
15620
  }
15568
15621
  try {
15569
- const carry = workMetricsCarryBySession.get(sessionId) ?? emptyWorkMetricsCarry();
15570
- const { carry: nextCarry, metrics } = withReadOnlySessionDb((openCodeDb) => computeOpenCodeWorkMetricsIncremental(openCodeDb, sessionId, carry));
15571
- workMetricsCarryBySession.set(sessionId, nextCarry);
15622
+ const carryKey = `${generation}:${sessionId}`;
15623
+ const carry = workMetricsCarryBySession.get(carryKey) ?? emptyWorkMetricsCarry();
15624
+ const { carry: nextCarry, metrics } = withReadOnlySessionDb((openCodeDb) => computeOpenCodeWorkMetricsIncremental(openCodeDb, sessionId, carry, generation), generation);
15625
+ workMetricsCarryBySession.set(carryKey, nextCarry);
15572
15626
  try {
15573
15627
  setSessionWorkMetrics(db, sessionId, metrics.newWorkTokens, metrics.totalInputTokens);
15574
15628
  } catch {}
@@ -16469,8 +16523,8 @@ function registerRpcHandlers(rpcServer, args) {
16469
16523
  const db = readDatabase();
16470
16524
  if (!db)
16471
16525
  return { ok: false, error: "db unavailable" };
16472
- const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-02sa2ngr.js"));
16473
- const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-afzzqy5b.js"));
16526
+ const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-na34m4c5.js"));
16527
+ const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-vz86nt79.js"));
16474
16528
  log2(`[rpc] recomp requested for session ${sessionId}`);
16475
16529
  if (!args.client && !args.hiddenCompletionExecutor) {
16476
16530
  return {
@@ -16554,7 +16608,7 @@ function registerRpcHandlers(rpcServer, args) {
16554
16608
  const db = readDatabase();
16555
16609
  if (!db)
16556
16610
  return { ok: false, error: "db unavailable" };
16557
- const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-n5h5sr1x.js"));
16611
+ const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-f0xr7pft.js"));
16558
16612
  const model = liveSessionState.liveModelBySession.get(sessionId);
16559
16613
  const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
16560
16614
  const ctx = {
@@ -24405,8 +24459,21 @@ function createTransform(deps) {
24405
24459
  const temporalReplayIds = temporalCandidates ? messages.flatMap((message) => message.info.id ? [message.info.id] : []) : undefined;
24406
24460
  logTransformTiming(sessionId, "findSessionId", tSessionId, `messages=${messages.length}`);
24407
24461
  const tLkgEntry = performance.now();
24408
- const lkgInput = deps.transformMode === "rust" ? [] : projectEntry(sessionId, messages);
24462
+ const lkgInput = deps.transformMode === "rust" ? [] : projectEntry(sessionId, entryOrderForThinkingFit);
24409
24463
  const recovery = deps.compactionOff || deps.transformMode === "rust" ? {} : readLkgRecoveryPrefix(sessionId, lkgInput, messages, deps.db);
24464
+ const recoveryTailSources = [];
24465
+ if (recovery.prefix) {
24466
+ const priorIdentities = new Set(recovery.prefix.inputs.map((input) => input.id));
24467
+ lkgInput.forEach((input, index) => {
24468
+ const identity = lkgInputIdentity(input.id, input.role, index);
24469
+ if (!identity || priorIdentities.has(identity))
24470
+ return;
24471
+ recoveryTailSources.push({
24472
+ identity,
24473
+ pristineSystem: input.id === null && input.role === "system" ? structuredClone(entryOrderForThinkingFit[index]) : undefined
24474
+ });
24475
+ });
24476
+ }
24410
24477
  const persistedUntaggedInputIds = deps.compactionOff || deps.transformMode === "rust" ? [] : readPersistedLkgUntaggedInputIds(deps.db, sessionId);
24411
24478
  const untaggedReplayIds = new Set([
24412
24479
  ...recovery.prefix?.untaggedInputIds ?? [],
@@ -25443,9 +25510,15 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
25443
25510
  });
25444
25511
  compactionModeTransitionPending.delete(sessionId);
25445
25512
  if (recovery.prefix && !recoveryNormalized) {
25446
- const priorIds = new Set(recovery.prefix.inputs.map((input) => input.id));
25447
- const newIds = new Set(lkgInput.flatMap((input) => input.id && !priorIds.has(input.id) ? [input.id] : []));
25448
- const suffix = messages.filter((message) => message.info.id && newIds.has(message.info.id));
25513
+ const renderedById = new Map;
25514
+ for (const message of messages) {
25515
+ if (!message.info.id)
25516
+ continue;
25517
+ const group = renderedById.get(message.info.id) ?? [];
25518
+ group.push(message);
25519
+ renderedById.set(message.info.id, group);
25520
+ }
25521
+ const suffix = recoveryTailSources.flatMap(({ identity, pristineSystem }) => pristineSystem ? [pristineSystem] : renderedById.get(identity) ?? []);
25449
25522
  messages.splice(0, messages.length, ...JSON.parse(recovery.prefix.json), ...suffix);
25450
25523
  }
25451
25524
  const recoveryReleaseReason = recovery.rebuildReason ?? (recoveryNormalized ? "recovery_tail_normalized" : undefined);
@@ -26388,6 +26461,8 @@ function replayCommittedDrops(db, sessionId, messages) {
26388
26461
  const toolThinking = new Map;
26389
26462
  const batch = new ToolMutationBatch(messages);
26390
26463
  for (const message of messages) {
26464
+ if (message.info.syntheticHead === true)
26465
+ continue;
26391
26466
  if (message.info.role === "user")
26392
26467
  precedingThinking = [];
26393
26468
  const thinking = message.parts.filter(isThinkingPart);
@@ -26421,9 +26496,10 @@ function replayCommittedDrops(db, sessionId, messages) {
26421
26496
  message,
26422
26497
  setContent(content) {
26423
26498
  if (isTextPart(part)) {
26424
- if (part.text === content)
26499
+ const rendered = renderDroppedText(tag.tagNumber, part.text);
26500
+ if (part.text === rendered)
26425
26501
  return false;
26426
- part.text = content;
26502
+ part.text = rendered;
26427
26503
  } else
26428
26504
  message.parts[p] = { type: "text", text: content };
26429
26505
  return true;
@@ -27740,7 +27816,7 @@ function createCtxMemoryTool(deps) {
27740
27816
  const memoryOwnedByTool = (memory) => visibility.owned(memory);
27741
27817
  const embeddingSnapshot = getProjectEmbeddingSnapshot2(projectPath);
27742
27818
  if (embeddingSnapshot ? !embeddingSnapshot.features.memoryEnabled : deps.memoryEnabled === false) {
27743
- return getDisabledMessage();
27819
+ return embeddingSnapshot?.memoryDisabledReason ?? getDisabledMessage();
27744
27820
  }
27745
27821
  if (args.action === "write") {
27746
27822
  const content = args.content?.trim();