@cortexkit/opencode-magic-context 0.46.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-search-worker.js +115 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/live-run-config.d.ts.map +1 -1
- package/dist/config/migrate-config-location.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +15 -7
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-7fj2b9jw.js → conflict-warning-hook-z44ynfz7.js} +5 -4
- package/dist/{context-8dkpszy5.js → context-wq4ffwyb.js} +164 -37
- package/dist/{derive-budgets-7nj7r1rv.js → derive-budgets-ke12jnnh.js} +1 -1
- package/dist/embedding-worker.js +2 -2
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +2 -0
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +7 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +2 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/session-project-storage.d.ts +8 -2
- package/dist/features/magic-context/session-project-storage.d.ts.map +1 -1
- package/dist/features/magic-context/storage-historian-runs.d.ts +2 -5
- package/dist/features/magic-context/storage-historian-runs.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +12 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +7 -2
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +1 -0
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts +3 -1
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/hooks/magic-context/active-anthropic-turn.d.ts +8 -0
- package/dist/hooks/magic-context/active-anthropic-turn.d.ts.map +1 -0
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-blocking.fixture.d.ts +2 -0
- package/dist/hooks/magic-context/auto-search-blocking.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-deadline.d.ts +7 -0
- package/dist/hooks/magic-context/auto-search-deadline.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-host-review.fixture.d.ts +3 -0
- package/dist/hooks/magic-context/auto-search-host-review.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-lock-review.fixture.d.ts +2 -0
- package/dist/hooks/magic-context/auto-search-lock-review.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-long-lock-review.fixture.d.ts +2 -0
- package/dist/hooks/magic-context/auto-search-long-lock-review.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-omp-host-review.fixture.d.ts +4 -0
- package/dist/hooks/magic-context/auto-search-omp-host-review.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-omp-loader.fixture.d.ts +3 -0
- package/dist/hooks/magic-context/auto-search-omp-loader.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-runner.d.ts +1 -1
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-snapshot.fixture.d.ts +4 -0
- package/dist/hooks/magic-context/auto-search-snapshot.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts +69 -0
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-worker.d.ts +2 -0
- package/dist/hooks/magic-context/auto-search-worker.d.ts.map +1 -0
- package/dist/hooks/magic-context/caveman-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +3 -5
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts +2 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts +3 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
- package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +2 -0
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-drain-gate.d.ts +11 -0
- package/dist/hooks/magic-context/historian-drain-gate.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook.d.ts +2 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/latest-assistant-turn.d.ts +25 -0
- package/dist/hooks/magic-context/latest-assistant-turn.d.ts.map +1 -0
- package/dist/hooks/magic-context/latest-thinking-recovery.d.ts +61 -0
- package/dist/hooks/magic-context/latest-thinking-recovery.d.ts.map +1 -0
- package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
- package/dist/hooks/magic-context/opencode-proven-floor.d.ts +6 -0
- package/dist/hooks/magic-context/opencode-proven-floor.d.ts.map +1 -0
- package/dist/hooks/magic-context/pass-outcome.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/reasoning-budget-status.d.ts +15 -0
- package/dist/hooks/magic-context/reasoning-budget-status.d.ts.map +1 -0
- package/dist/hooks/magic-context/reasoning-budget.d.ts +40 -0
- package/dist/hooks/magic-context/reasoning-budget.d.ts.map +1 -0
- package/dist/hooks/magic-context/reasoning-removal.d.ts +6 -6
- package/dist/hooks/magic-context/reasoning-removal.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/sentinel.d.ts +4 -0
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
- package/dist/hooks/magic-context/strip-content.d.ts +7 -3
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +13 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts +5 -0
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +3 -28
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +28 -6
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +3 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-0d3g3461.js → index-0c82743p.js} +2 -1
- package/dist/{index-e2dtv0ra.js → index-5a2r0p9f.js} +3 -3
- package/dist/{index-p821bjdb.js → index-6d9e1m08.js} +4726 -11050
- package/dist/{index-majxda46.js → index-6wkcswft.js} +1 -1
- package/dist/index-92bp57hg.js +2063 -0
- package/dist/{index-sfnj6h8h.js → index-9pk9exrb.js} +3 -3
- package/dist/{index-7qw742ev.js → index-adwfkpex.js} +5 -24
- package/dist/{index-3h0ybwah.js → index-bb36vgr3.js} +80 -12
- package/dist/{index-k4404na5.js → index-cwf6s3ay.js} +1072 -2422
- package/dist/index-fnn5pjtt.js +6554 -0
- package/dist/{index-j7fvnjye.js → index-gg8j07zz.js} +1 -1
- package/dist/{index-yasgb8ej.js → index-m5fe6jch.js} +9 -3
- package/dist/{v2/server-g0fjrkta.js → index-rrbbspwh.js} +42 -27
- package/dist/index-rrrsepyw.js +3464 -0
- package/dist/{index-qr6r7akd.js → index-w2t4ah5j.js} +950 -502
- package/dist/{v2/server-fg34g6a5.js → index-wx8a6bw3.js} +48 -8
- package/dist/{index-r5hmbx3t.js → index-x3kwrmqk.js} +146 -3571
- package/dist/index-yr3zj7e7.js +23 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +624 -65
- package/dist/{message-time-backfill-68gj6t3e.js → message-time-backfill-r5epkzj3.js} +1 -1
- package/dist/migration-worker.js +7 -5
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +2 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/host-stall-profiler-report.d.ts +67 -0
- package/dist/plugin/host-stall-profiler-report.d.ts.map +1 -0
- package/dist/plugin/host-stall-profiler.d.ts +96 -0
- package/dist/plugin/host-stall-profiler.d.ts.map +1 -0
- package/dist/plugin/messages-transform.d.ts +21 -6
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/{read-session-chunk-egz7r68d.js → read-session-chunk-4jey7hpt.js} +4 -4
- package/dist/{recomp-orchestrator-ejq7ex5d.js → recomp-orchestrator-rervg6q4.js} +13 -10
- package/dist/{send-session-notification-dyw42dtr.js → send-session-notification-0m68ms3n.js} +4 -3
- package/dist/shared/auto-search-lifecycle.d.ts +7 -0
- package/dist/shared/auto-search-lifecycle.d.ts.map +1 -0
- package/dist/shared/historian-tool-expansions.d.ts +1 -1
- package/dist/shared/historian-tool-expansions.d.ts.map +1 -1
- package/dist/shared/historian-tool-template.d.ts +2 -2
- package/dist/shared/historian-tool-template.d.ts.map +1 -1
- package/dist/shared/sqlite.d.ts +16 -1
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/status-view.d.ts.map +1 -1
- package/dist/shared/window-geometry.d.ts +4 -0
- package/dist/shared/window-geometry.d.ts.map +1 -1
- package/dist/tools/ctx-expand/render.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-tz3pat2p.js → transform-postprocess-phase-z5hzpsxv.js} +13 -10
- package/dist/v2/auto-search-worker.js +115 -0
- package/dist/v2/{context-8vgtb6sz.js → context-14v1hr8b.js} +4918 -5760
- package/dist/v2/{derive-budgets-kdgp4s3r.js → derive-budgets-nc9avxz8.js} +2 -2
- package/dist/v2/embedding-worker.js +3 -3
- package/dist/v2/hidden-child-native.d.ts +7 -0
- package/dist/v2/hidden-child-native.d.ts.map +1 -1
- package/dist/v2/hidden-child-record.d.ts +8 -0
- package/dist/v2/hidden-child-record.d.ts.map +1 -1
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/dream-trigger.d.ts +15 -1
- package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +54 -3
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/types.d.ts +12 -1
- package/dist/v2/hooks/types.d.ts.map +1 -1
- package/dist/v2/{message-time-backfill-r6qkem1x.js → message-time-backfill-1f9tzvcs.js} +1 -1
- package/dist/v2/migration-worker.js +7 -5
- package/dist/v2/{read-session-chunk-8vjp6581.js → read-session-chunk-gyyv7w2r.js} +4 -4
- package/dist/v2/{recomp-orchestrator-5xj0yzyk.js → recomp-orchestrator-42vjba7p.js} +17 -14
- package/dist/v2/{send-session-notification-qs0j78v6.js → send-session-notification-c0wtscea.js} +5 -4
- package/dist/v2/server-3trjk1hx.js +6360 -0
- package/dist/v2/{server-xtp687da.js → server-50hvkg3v.js} +9 -3
- package/dist/v2/{server-y8maxeft.js → server-cpepxy2q.js} +2 -1
- package/dist/v2/server-d0sraw7m.js +3403 -0
- package/dist/v2/server-e0c1b7a7.js +2063 -0
- package/dist/v2/{server-mcfawjgc.js → server-efhwzx05.js} +5 -24
- package/dist/v2/{server-3n4q9xme.js → server-fcdehk1s.js} +1 -1
- package/dist/{index-q4yp4b52.js → v2/server-fq7kq32k.js} +42 -27
- package/dist/v2/{server-vnh7r35f.js → server-nf82q6pt.js} +2459 -8603
- package/dist/v2/{server-frbm99q5.js → server-njt3np1k.js} +99 -3465
- package/dist/v2/{server-qp5hx1ad.js → server-nm9n3aqq.js} +107 -12
- package/dist/v2/{server-p2en78c8.js → server-rz514f14.js} +7 -2
- package/dist/v2/{server-wvjvfhck.js → server-vd4e7174.js} +1 -1
- package/dist/{index-fg34g6a5.js → v2/server-wx8a6bw3.js} +48 -8
- package/dist/v2/{server-4663ejam.js → server-y10vbq6y.js} +1 -1
- package/dist/v2/server-yr3zj7e7.js +23 -0
- package/dist/v2/server.js +5 -5
- package/dist/v2/{wrapup-orchestrator-r5t1pyj8.js → wrapup-orchestrator-nbz854vc.js} +16 -13
- package/dist/wrapup-orchestrator-b2dztrar.js +29 -0
- package/package.json +6 -5
- package/src/config/index.ts +6 -0
- package/src/config/live-run-config.test.ts +37 -1
- package/src/config/live-run-config.ts +28 -0
- package/src/config/migrate-config-location.ts +10 -3
- package/src/config/schema/magic-context.test.ts +4 -3
- package/src/config/schema/magic-context.ts +23 -6
- package/src/shared/auto-search-lifecycle.ts +27 -0
- package/src/shared/historian-tool-defaults.json +6 -6
- package/src/shared/historian-tool-expansions.ts +65 -8
- package/src/shared/historian-tool-preview-defaults.json +13 -0
- package/src/shared/historian-tool-template.ts +48 -14
- package/src/shared/sqlite-640-review-r2.test.ts +136 -0
- package/src/shared/sqlite-640-review.test.ts +183 -0
- package/src/shared/sqlite-acquisition-routing.test.ts +18 -0
- package/src/shared/sqlite.ts +84 -14
- package/src/shared/status-view.test.ts +6 -1
- package/src/shared/status-view.ts +15 -1
- package/src/shared/tag-transcript.ts +6 -0
- package/src/shared/window-geometry.ts +10 -0
- package/dist/wrapup-orchestrator-kw3x3myw.js +0 -26
- /package/dist/{index-en1k8h8m.js → index-5prbx026.js} +0 -0
- /package/dist/v2/{index-en1k8h8m.js → index-5prbx026.js} +0 -0
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
SynapseEmbeddingProvider,
|
|
25
25
|
computeNormalizedHash,
|
|
26
26
|
getLocalEmbeddingNativeMemoryStats
|
|
27
|
-
} from "./index-
|
|
27
|
+
} from "./index-m5fe6jch.js";
|
|
28
28
|
import {
|
|
29
29
|
getHarness,
|
|
30
30
|
harnessOwnsOpenCodeStore,
|
|
@@ -63,11 +63,8 @@ import {
|
|
|
63
63
|
isTransientSqliteError,
|
|
64
64
|
SqliteAcquisitionBusyError,
|
|
65
65
|
withAsyncPrivilegedWriter
|
|
66
|
-
} from "./index-
|
|
66
|
+
} from "./index-wx8a6bw3.js";
|
|
67
67
|
import {
|
|
68
|
-
isFailClosedBlockingError,
|
|
69
|
-
shouldBypassFailClosedBlock,
|
|
70
|
-
resolveAgentNameFromMessages,
|
|
71
68
|
canonicalProjectDirectory,
|
|
72
69
|
shouldSkipHomeProjectMemory,
|
|
73
70
|
ProjectIdentityError,
|
|
@@ -82,12 +79,6 @@ import {
|
|
|
82
79
|
storedPathBelongsToIdentity,
|
|
83
80
|
beginBootQuietPeriod,
|
|
84
81
|
scheduleAfterBootQuiet,
|
|
85
|
-
registerOwnRpcServerInstance,
|
|
86
|
-
rpcPortDir,
|
|
87
|
-
rpcPortFilePath,
|
|
88
|
-
parseRpcPortFile,
|
|
89
|
-
inspectProcessesAsync,
|
|
90
|
-
configureContextDatabasePragmas,
|
|
91
82
|
layoutLkgPrefix,
|
|
92
83
|
assembleLkgPrefix,
|
|
93
84
|
V2_MEMORY_CATEGORIES,
|
|
@@ -98,7 +89,238 @@ import {
|
|
|
98
89
|
expandWorkspaceIdentitySetWithAliases,
|
|
99
90
|
resolveStoredPathWorkspaceIdentity,
|
|
100
91
|
storedPathBelongsToWorkspace,
|
|
101
|
-
computeWorkspaceEpochFingerprint
|
|
92
|
+
computeWorkspaceEpochFingerprint
|
|
93
|
+
} from "./index-x3kwrmqk.js";
|
|
94
|
+
import {
|
|
95
|
+
recordSessionProjectIdentity,
|
|
96
|
+
hasRecordedSessionProjectIdentity,
|
|
97
|
+
getMessageIndexSourceIdentity,
|
|
98
|
+
isMessageIndexSourceCurrent,
|
|
99
|
+
getLastIndexedOrdinal,
|
|
100
|
+
getMessageIndexReconciliationStartOrdinal,
|
|
101
|
+
isMessageIndexReconciledThrough,
|
|
102
|
+
clearIndexedMessages,
|
|
103
|
+
indexSingleMessage,
|
|
104
|
+
indexMessagesAfterOrdinal,
|
|
105
|
+
sweepOrphanedOpenCodeMessageIndexes,
|
|
106
|
+
SESSION_NOTE_CONDITION_ERROR,
|
|
107
|
+
getNoteByIdInScope,
|
|
108
|
+
getNotes,
|
|
109
|
+
addNote,
|
|
110
|
+
getSessionNotes,
|
|
111
|
+
getPendingSmartNotes,
|
|
112
|
+
getReadySmartNotes,
|
|
113
|
+
updateNote,
|
|
114
|
+
dismissNotes,
|
|
115
|
+
dismissNote,
|
|
116
|
+
markNoteReady,
|
|
117
|
+
markNoteChecked,
|
|
118
|
+
PRIMER_CANDIDATE_TTL_MS,
|
|
119
|
+
PRIMER_CANDIDATE_MAX_AGE_MS,
|
|
120
|
+
primerOccurrenceKey,
|
|
121
|
+
primerOccurrenceUtcDay,
|
|
122
|
+
updatePrimerCandidateEmbedding,
|
|
123
|
+
getPrimerCandidatesByIds,
|
|
124
|
+
getPrimerCandidatesForPromotion,
|
|
125
|
+
countPrimerCandidatesForProject,
|
|
126
|
+
getActivePrimers,
|
|
127
|
+
createPrimer,
|
|
128
|
+
updatePrimerSupport,
|
|
129
|
+
updatePrimerAnswer,
|
|
130
|
+
cosineSimilarity,
|
|
131
|
+
drainBackgroundBatches,
|
|
132
|
+
GIT_SWEEP_LEASE_RENEWAL_MS,
|
|
133
|
+
acquireGitSweepLease,
|
|
134
|
+
renewGitSweepLease,
|
|
135
|
+
markGitSweepSuccessAndRelease,
|
|
136
|
+
parkGitSweepNonIndexable,
|
|
137
|
+
releaseGitSweepLease,
|
|
138
|
+
saveEmbeddingIfHashMatches,
|
|
139
|
+
invalidateProject,
|
|
140
|
+
invalidateMemory,
|
|
141
|
+
describeShadowBackfillWriteRefusal,
|
|
142
|
+
markProjectLoadUntrusted,
|
|
143
|
+
drainProjectEmbeddingIdentityMaintenance,
|
|
144
|
+
drainStaleEmbeddingIdentitiesForProject,
|
|
145
|
+
registerProjectEmbedding,
|
|
146
|
+
registerProjectShadowEmbedding,
|
|
147
|
+
enqueueShadowEmbeddingItems,
|
|
148
|
+
registerProjectInObservationMode,
|
|
149
|
+
unregisterProjectShadowEmbedding,
|
|
150
|
+
getProjectEmbeddingSnapshot,
|
|
151
|
+
embedTextForProject,
|
|
152
|
+
embedBatchForProject,
|
|
153
|
+
embedUnembeddedMemoriesForProject,
|
|
154
|
+
embedUnembeddedMemoriesForProjectOutcome,
|
|
155
|
+
drainCommitBacklogForProject,
|
|
156
|
+
embedSessionCompartmentChunks,
|
|
157
|
+
getEmbeddingCoverageStatus,
|
|
158
|
+
computeCueContentHash,
|
|
159
|
+
hasMuralCueColumns,
|
|
160
|
+
getMuralCueState,
|
|
161
|
+
memoryNeedsCue,
|
|
162
|
+
setMuralCue,
|
|
163
|
+
recordMuralCueRejection,
|
|
164
|
+
hasMemoryShareableColumn,
|
|
165
|
+
hasMemoryClassifiedAtColumn,
|
|
166
|
+
getUnclassifiedMemoryIds,
|
|
167
|
+
insertMemory,
|
|
168
|
+
insertMemoryIdempotent,
|
|
169
|
+
getMemoryByHash,
|
|
170
|
+
getMemoriesByProject,
|
|
171
|
+
getMemoriesForList,
|
|
172
|
+
getMaxMemoryIdForProjects,
|
|
173
|
+
getMemoryById,
|
|
174
|
+
getMemoriesByIds,
|
|
175
|
+
updateMemorySeenCount,
|
|
176
|
+
setMemoryClassification,
|
|
177
|
+
supersededMemory,
|
|
178
|
+
mergeMemoryStats,
|
|
179
|
+
archiveMemory,
|
|
180
|
+
getMemoryCountsByStatus,
|
|
181
|
+
recordMemoryMapping,
|
|
182
|
+
recordMemoryVerifications,
|
|
183
|
+
getUnmappedMemoryIds,
|
|
184
|
+
clearMemoryVerifications,
|
|
185
|
+
getMemoryVerifications,
|
|
186
|
+
resolveGitTopLevel,
|
|
187
|
+
readGitHead,
|
|
188
|
+
readGitChangedFilesSince,
|
|
189
|
+
readGitFileChangeTimesSince,
|
|
190
|
+
verificationFileExists,
|
|
191
|
+
normalizeVerificationFiles
|
|
192
|
+
} from "./index-fnn5pjtt.js";
|
|
193
|
+
import {
|
|
194
|
+
hasTrustedAbsoluteWall,
|
|
195
|
+
applyProvenInputFloor,
|
|
196
|
+
formatWindowDerivationLine,
|
|
197
|
+
isSaneLimit,
|
|
198
|
+
getSdkWindowGeometry,
|
|
199
|
+
getSdkContextLimit,
|
|
200
|
+
getSdkOutputLimit,
|
|
201
|
+
deriveTriggerBudget2,
|
|
202
|
+
resolveKnownHistorianContextLimit2,
|
|
203
|
+
resolveHistorianProducerLimits2
|
|
204
|
+
} from "./index-0c82743p.js";
|
|
205
|
+
import {
|
|
206
|
+
resolveModelCalibration,
|
|
207
|
+
calibrateBuckets,
|
|
208
|
+
resolveDecisionCalibration
|
|
209
|
+
} from "./index-1zx87sdm.js";
|
|
210
|
+
import {
|
|
211
|
+
hasMeaningfulUserText2,
|
|
212
|
+
extractTexts2,
|
|
213
|
+
extractToolCallSummaries,
|
|
214
|
+
getTokenizerNativeMemoryStats,
|
|
215
|
+
estimateTokens,
|
|
216
|
+
estimateFixedPromptTokens,
|
|
217
|
+
normalizeText
|
|
218
|
+
} from "./index-5eqk6z3s.js";
|
|
219
|
+
import {
|
|
220
|
+
protectedToolTagNumbers,
|
|
221
|
+
protectedToolTokenCount,
|
|
222
|
+
peelLeadingMcTagNotation,
|
|
223
|
+
isRecord,
|
|
224
|
+
contentTagOwnerMessageId,
|
|
225
|
+
normalizeTodoStateJson,
|
|
226
|
+
computeSyntheticCallId,
|
|
227
|
+
CHANNEL1_SENTINEL,
|
|
228
|
+
toolOutputTokens,
|
|
229
|
+
decideChannel1,
|
|
230
|
+
evaluateChannel2,
|
|
231
|
+
formatChannel1Evaluation,
|
|
232
|
+
formatChannel2Evaluation,
|
|
233
|
+
reclaimableToolOutputCount,
|
|
234
|
+
buildChannel2Reminder,
|
|
235
|
+
buildChannel1Reminder,
|
|
236
|
+
queuePendingOp,
|
|
237
|
+
getPendingOps,
|
|
238
|
+
hasPendingDropOps,
|
|
239
|
+
clearPendingOps,
|
|
240
|
+
removePendingOp,
|
|
241
|
+
getTriggerTagTokenUpperBound,
|
|
242
|
+
getActiveTagTokenTotalsByMessage,
|
|
243
|
+
getReasoningTokenEstimatesByMessage,
|
|
244
|
+
updateTagStatus,
|
|
245
|
+
getInertWhitespaceAssistantTags,
|
|
246
|
+
deriveTagLoadFloor,
|
|
247
|
+
getTagsBySession,
|
|
248
|
+
getActiveTagsBySession,
|
|
249
|
+
getDroppedTagsBySession,
|
|
250
|
+
getTagsByNumbers,
|
|
251
|
+
getDroppedTagsByNumbers,
|
|
252
|
+
getMaxDroppedTagNumber,
|
|
253
|
+
getTagById,
|
|
254
|
+
expandToolPart,
|
|
255
|
+
isRawCompactionSummaryInfo,
|
|
256
|
+
extractInMemoryMessageViews,
|
|
257
|
+
buildInMemoryTailRawMessages,
|
|
258
|
+
estimateTrueRawMessageTokens,
|
|
259
|
+
toolPartHasUserAnswer,
|
|
260
|
+
DreamTokenBudgetExceeded,
|
|
261
|
+
isEditTool,
|
|
262
|
+
describeFinalWireTail,
|
|
263
|
+
estimateMessageTokens,
|
|
264
|
+
wireContentBytes,
|
|
265
|
+
createFinalWireUsageTracker,
|
|
266
|
+
estimateFinalWireInputTokens,
|
|
267
|
+
estimateAppendedWireTokens,
|
|
268
|
+
detectLatestTurnThinkingMismatch,
|
|
269
|
+
isPrefixBoundThinkingModel,
|
|
270
|
+
detectOverflow,
|
|
271
|
+
modelAcceptsEmptyContent,
|
|
272
|
+
isAnthropicFamilyRoute,
|
|
273
|
+
variantChangeBustsProviderCache,
|
|
274
|
+
setRawMessageProvider2,
|
|
275
|
+
cleanUserText2,
|
|
276
|
+
withRawSessionMessageCache2,
|
|
277
|
+
readRawSessionMessages2,
|
|
278
|
+
visitRawSessionMessages2,
|
|
279
|
+
primeTailRawMessageCache2,
|
|
280
|
+
primeInMemoryTailRawMessageCache2,
|
|
281
|
+
readRawSessionMessageOrdinalPage2,
|
|
282
|
+
getRawSessionStoredMessageCount2,
|
|
283
|
+
readRawSessionMessageIdOrdinalsForRange2,
|
|
284
|
+
readRawSessionMessagePartsById2,
|
|
285
|
+
readRawSessionMessageById2,
|
|
286
|
+
readSessionChunk2,
|
|
287
|
+
readRawSessionSeedTail2
|
|
288
|
+
} from "./index-bb36vgr3.js";
|
|
289
|
+
import {
|
|
290
|
+
observeTemporalDecisions,
|
|
291
|
+
getMeasuredToolDefinitionTokens
|
|
292
|
+
} from "./index-5gq3b2ya.js";
|
|
293
|
+
import {
|
|
294
|
+
openCodeDbExists,
|
|
295
|
+
withReadOnlySessionDb,
|
|
296
|
+
assistantAwaitingTools,
|
|
297
|
+
latestPersistedMessageForRecovery,
|
|
298
|
+
findLastAssistantModelFromOpenCodeDb
|
|
299
|
+
} from "./index-6wkcswft.js";
|
|
300
|
+
import {
|
|
301
|
+
CANONICAL_DREAM_TASKS,
|
|
302
|
+
DREAM_TASK_CAPABILITIES,
|
|
303
|
+
toolLoopDreamTasks,
|
|
304
|
+
formatDreamTaskBacklogs,
|
|
305
|
+
formatDreamTaskFailures,
|
|
306
|
+
processedDreamTaskItems,
|
|
307
|
+
leaseKindFor,
|
|
308
|
+
leaseKeyFor,
|
|
309
|
+
isCanonicalDreamTask,
|
|
310
|
+
compareTaskOrder,
|
|
311
|
+
buildDreamTaskRuntimeConfigs2,
|
|
312
|
+
userMemoryCollectionEnabled2
|
|
313
|
+
} from "./index-mc22ayvf.js";
|
|
314
|
+
import {
|
|
315
|
+
isFailClosedBlockingError,
|
|
316
|
+
shouldBypassFailClosedBlock,
|
|
317
|
+
resolveAgentNameFromMessages,
|
|
318
|
+
registerOwnRpcServerInstance,
|
|
319
|
+
rpcPortDir,
|
|
320
|
+
rpcPortFilePath,
|
|
321
|
+
parseRpcPortFile,
|
|
322
|
+
inspectProcessesAsync,
|
|
323
|
+
configureContextDatabasePragmas,
|
|
102
324
|
getUnconfirmedMigrationHolders,
|
|
103
325
|
getSchemaFenceRejection,
|
|
104
326
|
getMigrationOnOpenRefusal,
|
|
@@ -108,7 +330,7 @@ import {
|
|
|
108
330
|
runSqliteOptimize,
|
|
109
331
|
openDatabase,
|
|
110
332
|
openCurrentDatabase
|
|
111
|
-
} from "./index-
|
|
333
|
+
} from "./index-rrrsepyw.js";
|
|
112
334
|
import {
|
|
113
335
|
getMagicContextBuiltinCommands,
|
|
114
336
|
formatConfigParseStatusLine,
|
|
@@ -129,8 +351,6 @@ import {
|
|
|
129
351
|
renderDreamFailure,
|
|
130
352
|
dreamFailureCode,
|
|
131
353
|
renderEmbeddingFailure,
|
|
132
|
-
recordSessionProjectIdentity,
|
|
133
|
-
hasRecordedSessionProjectIdentity,
|
|
134
354
|
clampProducerAtomChars,
|
|
135
355
|
producerInputTokenLimit,
|
|
136
356
|
historianProducerReserve,
|
|
@@ -146,20 +366,13 @@ import {
|
|
|
146
366
|
embedRunStateBySession,
|
|
147
367
|
invalidateAutoEmbedSession,
|
|
148
368
|
getEmbedDrainUiStatus,
|
|
369
|
+
ensureSessionMetaRow,
|
|
149
370
|
getCompartments,
|
|
150
371
|
getLastCompartmentEndMessage,
|
|
151
372
|
getLastCompartmentEndMessageId,
|
|
152
|
-
getMessageIndexSourceIdentity,
|
|
153
|
-
isMessageIndexSourceCurrent,
|
|
154
|
-
getLastIndexedOrdinal,
|
|
155
|
-
getMessageIndexReconciliationStartOrdinal,
|
|
156
|
-
isMessageIndexReconciledThrough,
|
|
157
|
-
clearIndexedMessages,
|
|
158
|
-
indexSingleMessage,
|
|
159
|
-
indexMessagesAfterOrdinal,
|
|
160
|
-
sweepOrphanedOpenCodeMessageIndexes,
|
|
161
373
|
MAX_EXECUTE_THRESHOLD,
|
|
162
374
|
escalationBands,
|
|
375
|
+
decodeMergedReasoningParts,
|
|
163
376
|
sessionDecisionCalibration,
|
|
164
377
|
getProtectionWindowForSession,
|
|
165
378
|
isRustMarkerAdmissionFenced,
|
|
@@ -176,6 +389,7 @@ import {
|
|
|
176
389
|
resolveCompactionModeRecord,
|
|
177
390
|
getCompactionModeRecord,
|
|
178
391
|
setCompactionModeRecord,
|
|
392
|
+
getProtectedTailDrainBudgetSkip,
|
|
179
393
|
clearPersistedReasoningWatermark,
|
|
180
394
|
getEmergencyInputSample,
|
|
181
395
|
clearEmergencyDropSample,
|
|
@@ -209,7 +423,10 @@ import {
|
|
|
209
423
|
getPersistedCompactionMarkerState,
|
|
210
424
|
setPersistedCompactionMarkerState,
|
|
211
425
|
getStrippedPlaceholderIds,
|
|
426
|
+
getThinkingBindingRecoveryTarget,
|
|
427
|
+
armThinkingBindingRecovery,
|
|
212
428
|
clearThinkingBindingRecoveryIf,
|
|
429
|
+
getMergedReasoningStrippedIds,
|
|
213
430
|
getStaleReduceStrippedIds,
|
|
214
431
|
getProcessedImageStrippedIds,
|
|
215
432
|
getPendingCompactionMarkerState,
|
|
@@ -218,6 +435,7 @@ import {
|
|
|
218
435
|
setSessionWorkMetrics,
|
|
219
436
|
getObservedEpochFloor,
|
|
220
437
|
resolveEpochFloorForPass,
|
|
438
|
+
providerResponseFailed,
|
|
221
439
|
claimLkgRequestIdentity,
|
|
222
440
|
noteCapturedLkgRequest,
|
|
223
441
|
measuredLkgPrefix,
|
|
@@ -240,6 +458,7 @@ import {
|
|
|
240
458
|
dropSlot,
|
|
241
459
|
noteEntry,
|
|
242
460
|
getLkgSlotHeapStats,
|
|
461
|
+
TOOL_SWEEP_SCOPED_MARKER,
|
|
243
462
|
useScopedToolSweep,
|
|
244
463
|
createPreAdoptionToolSweepResolver,
|
|
245
464
|
queueMemoryMutation,
|
|
@@ -248,117 +467,31 @@ import {
|
|
|
248
467
|
updateSessionMeta,
|
|
249
468
|
retryPendingSessionCleanups,
|
|
250
469
|
retryPendingRustSessionCleanupsForProject,
|
|
251
|
-
SESSION_NOTE_CONDITION_ERROR,
|
|
252
|
-
getNoteByIdInScope,
|
|
253
|
-
getNotes,
|
|
254
|
-
addNote,
|
|
255
|
-
getSessionNotes,
|
|
256
|
-
getPendingSmartNotes,
|
|
257
|
-
getReadySmartNotes,
|
|
258
|
-
updateNote,
|
|
259
|
-
dismissNotes,
|
|
260
|
-
dismissNote,
|
|
261
|
-
markNoteReady,
|
|
262
|
-
markNoteChecked,
|
|
263
|
-
PRIMER_CANDIDATE_TTL_MS,
|
|
264
|
-
PRIMER_CANDIDATE_MAX_AGE_MS,
|
|
265
|
-
primerOccurrenceKey,
|
|
266
|
-
primerOccurrenceUtcDay,
|
|
267
|
-
updatePrimerCandidateEmbedding,
|
|
268
|
-
getPrimerCandidatesByIds,
|
|
269
|
-
getPrimerCandidatesForPromotion,
|
|
270
|
-
countPrimerCandidatesForProject,
|
|
271
|
-
getActivePrimers,
|
|
272
|
-
createPrimer,
|
|
273
|
-
updatePrimerSupport,
|
|
274
|
-
updatePrimerAnswer,
|
|
275
470
|
GLOBAL_USER_PROFILE_PROJECT_PATH,
|
|
276
471
|
getProjectState,
|
|
277
472
|
bumpProjectUserProfileVersion,
|
|
278
|
-
createChildSessionWithFence,
|
|
279
|
-
HiddenCompletionRefusal,
|
|
280
|
-
DreamerProviderOutputFailureError,
|
|
281
|
-
withDreamerModelCooldown,
|
|
282
|
-
providerOutputFailureFromInvalidManifest,
|
|
283
|
-
extractLatestAssistantText,
|
|
284
|
-
hasLengthCappedOutput,
|
|
285
|
-
parseProviderModel,
|
|
286
|
-
modelBodyField,
|
|
287
|
-
toModelEntry,
|
|
288
|
-
isPromptTimeoutError,
|
|
289
|
-
getPromptFailureDetail,
|
|
290
|
-
promptSyncWithValidatedOutputRetry,
|
|
291
|
-
normalizeSDKResponse,
|
|
292
|
-
failedInvocationStatus,
|
|
293
|
-
recordChildInvocation,
|
|
294
|
-
createPromptAsyncTransport,
|
|
295
|
-
promptSurfaceHashMaterial,
|
|
296
|
-
createPromptSurfaceRuntime,
|
|
297
|
-
createPromptSurfaceGuidanceEpochCache,
|
|
298
|
-
teardownChildSession,
|
|
299
|
-
getCompartmentEvents,
|
|
300
|
-
cosineSimilarity,
|
|
301
|
-
drainBackgroundBatches,
|
|
302
|
-
GIT_SWEEP_LEASE_RENEWAL_MS,
|
|
303
|
-
acquireGitSweepLease,
|
|
304
|
-
renewGitSweepLease,
|
|
305
|
-
markGitSweepSuccessAndRelease,
|
|
306
|
-
parkGitSweepNonIndexable,
|
|
307
|
-
releaseGitSweepLease,
|
|
308
|
-
saveEmbeddingIfHashMatches,
|
|
309
|
-
invalidateProject,
|
|
310
|
-
invalidateMemory,
|
|
311
|
-
describeShadowBackfillWriteRefusal,
|
|
312
|
-
markProjectLoadUntrusted,
|
|
313
|
-
drainProjectEmbeddingIdentityMaintenance,
|
|
314
|
-
drainStaleEmbeddingIdentitiesForProject,
|
|
315
|
-
registerProjectEmbedding,
|
|
316
|
-
registerProjectShadowEmbedding,
|
|
317
|
-
enqueueShadowEmbeddingItems,
|
|
318
|
-
registerProjectInObservationMode,
|
|
319
|
-
unregisterProjectShadowEmbedding,
|
|
320
|
-
getProjectEmbeddingSnapshot,
|
|
321
|
-
embedTextForProject,
|
|
322
|
-
embedBatchForProject,
|
|
323
|
-
embedUnembeddedMemoriesForProject,
|
|
324
|
-
embedUnembeddedMemoriesForProjectOutcome,
|
|
325
|
-
drainCommitBacklogForProject,
|
|
326
|
-
embedSessionCompartmentChunks,
|
|
327
|
-
getEmbeddingCoverageStatus,
|
|
328
|
-
computeCueContentHash,
|
|
329
|
-
hasMuralCueColumns,
|
|
330
|
-
getMuralCueState,
|
|
331
|
-
memoryNeedsCue,
|
|
332
|
-
setMuralCue,
|
|
333
|
-
recordMuralCueRejection,
|
|
334
|
-
hasMemoryShareableColumn,
|
|
335
|
-
hasMemoryClassifiedAtColumn,
|
|
336
|
-
getUnclassifiedMemoryIds,
|
|
337
|
-
insertMemory,
|
|
338
|
-
insertMemoryIdempotent,
|
|
339
|
-
getMemoryByHash,
|
|
340
|
-
getMemoriesByProject,
|
|
341
|
-
getMemoriesForList,
|
|
342
|
-
getMaxMemoryIdForProjects,
|
|
343
|
-
getMemoryById,
|
|
344
|
-
getMemoriesByIds,
|
|
345
|
-
updateMemorySeenCount,
|
|
346
|
-
setMemoryClassification,
|
|
347
|
-
supersededMemory,
|
|
348
|
-
mergeMemoryStats,
|
|
349
|
-
archiveMemory,
|
|
350
|
-
getMemoryCountsByStatus,
|
|
351
|
-
recordMemoryMapping,
|
|
352
|
-
recordMemoryVerifications,
|
|
353
|
-
getUnmappedMemoryIds,
|
|
354
|
-
clearMemoryVerifications,
|
|
355
|
-
getMemoryVerifications,
|
|
356
|
-
resolveGitTopLevel,
|
|
357
|
-
readGitHead,
|
|
358
|
-
readGitChangedFilesSince,
|
|
359
|
-
readGitFileChangeTimesSince,
|
|
360
|
-
verificationFileExists,
|
|
361
|
-
normalizeVerificationFiles,
|
|
473
|
+
createChildSessionWithFence,
|
|
474
|
+
HiddenCompletionRefusal,
|
|
475
|
+
DreamerProviderOutputFailureError,
|
|
476
|
+
withDreamerModelCooldown,
|
|
477
|
+
providerOutputFailureFromInvalidManifest,
|
|
478
|
+
extractLatestAssistantText,
|
|
479
|
+
hasLengthCappedOutput,
|
|
480
|
+
parseProviderModel,
|
|
481
|
+
modelBodyField,
|
|
482
|
+
toModelEntry,
|
|
483
|
+
isPromptTimeoutError,
|
|
484
|
+
getPromptFailureDetail,
|
|
485
|
+
promptSyncWithValidatedOutputRetry,
|
|
486
|
+
normalizeSDKResponse,
|
|
487
|
+
failedInvocationStatus,
|
|
488
|
+
recordChildInvocation,
|
|
489
|
+
createPromptAsyncTransport,
|
|
490
|
+
promptSurfaceHashMaterial,
|
|
491
|
+
createPromptSurfaceRuntime,
|
|
492
|
+
createPromptSurfaceGuidanceEpochCache,
|
|
493
|
+
teardownChildSession,
|
|
494
|
+
getCompartmentEvents,
|
|
362
495
|
runTokenLog,
|
|
363
496
|
formatRunTokenLog,
|
|
364
497
|
resolveHiddenCompletionExecutor,
|
|
@@ -407,6 +540,8 @@ import {
|
|
|
407
540
|
clearNoteNudgeTriggerAndCooldown,
|
|
408
541
|
resetNoteNudgeCooldownOnly,
|
|
409
542
|
RECOVERY_NO_HEAD_LIMIT,
|
|
543
|
+
deriveProtectedTailTokenTarget,
|
|
544
|
+
selectPerRunCap,
|
|
410
545
|
resolveOpenCodeProtectedTailBoundary,
|
|
411
546
|
getRawHistoryEligibility,
|
|
412
547
|
hasRunnableCompartmentWindow,
|
|
@@ -414,126 +549,7 @@ import {
|
|
|
414
549
|
snapRangeToCompartments,
|
|
415
550
|
getActiveCompartmentRun,
|
|
416
551
|
startCompartmentAgent
|
|
417
|
-
} from "./index-
|
|
418
|
-
import {
|
|
419
|
-
hasTrustedAbsoluteWall,
|
|
420
|
-
applyProvenInputFloor,
|
|
421
|
-
formatWindowDerivationLine,
|
|
422
|
-
isSaneLimit,
|
|
423
|
-
getSdkWindowGeometry,
|
|
424
|
-
getSdkContextLimit,
|
|
425
|
-
getSdkOutputLimit,
|
|
426
|
-
deriveTriggerBudget2,
|
|
427
|
-
resolveKnownHistorianContextLimit2,
|
|
428
|
-
resolveHistorianProducerLimits2
|
|
429
|
-
} from "./index-0d3g3461.js";
|
|
430
|
-
import {
|
|
431
|
-
resolveModelCalibration,
|
|
432
|
-
calibrateBuckets,
|
|
433
|
-
resolveDecisionCalibration
|
|
434
|
-
} from "./index-1zx87sdm.js";
|
|
435
|
-
import {
|
|
436
|
-
hasMeaningfulUserText2,
|
|
437
|
-
extractTexts2,
|
|
438
|
-
extractToolCallSummaries,
|
|
439
|
-
getTokenizerNativeMemoryStats,
|
|
440
|
-
estimateTokens,
|
|
441
|
-
estimateFixedPromptTokens,
|
|
442
|
-
normalizeText
|
|
443
|
-
} from "./index-5eqk6z3s.js";
|
|
444
|
-
import {
|
|
445
|
-
protectedToolTagNumbers,
|
|
446
|
-
protectedToolTokenCount,
|
|
447
|
-
peelLeadingMcTagNotation,
|
|
448
|
-
isRecord,
|
|
449
|
-
contentTagOwnerMessageId,
|
|
450
|
-
normalizeTodoStateJson,
|
|
451
|
-
computeSyntheticCallId,
|
|
452
|
-
CHANNEL1_SENTINEL,
|
|
453
|
-
toolOutputTokens,
|
|
454
|
-
decideChannel1,
|
|
455
|
-
evaluateChannel2,
|
|
456
|
-
formatChannel1Evaluation,
|
|
457
|
-
formatChannel2Evaluation,
|
|
458
|
-
reclaimableToolOutputCount,
|
|
459
|
-
buildChannel2Reminder,
|
|
460
|
-
buildChannel1Reminder,
|
|
461
|
-
queuePendingOp,
|
|
462
|
-
getPendingOps,
|
|
463
|
-
hasPendingDropOps,
|
|
464
|
-
clearPendingOps,
|
|
465
|
-
removePendingOp,
|
|
466
|
-
getTriggerTagTokenUpperBound,
|
|
467
|
-
getActiveTagTokenTotalsByMessage,
|
|
468
|
-
updateTagStatus,
|
|
469
|
-
getInertWhitespaceAssistantTags,
|
|
470
|
-
deriveTagLoadFloor,
|
|
471
|
-
getTagsBySession,
|
|
472
|
-
getActiveTagsBySession,
|
|
473
|
-
getDroppedTagsBySession,
|
|
474
|
-
getTagsByNumbers,
|
|
475
|
-
getDroppedTagsByNumbers,
|
|
476
|
-
getMaxDroppedTagNumber,
|
|
477
|
-
getTagById,
|
|
478
|
-
expandToolPart,
|
|
479
|
-
isRawCompactionSummaryInfo,
|
|
480
|
-
extractInMemoryMessageViews,
|
|
481
|
-
buildInMemoryTailRawMessages,
|
|
482
|
-
estimateTrueRawMessageTokens,
|
|
483
|
-
toolPartHasUserAnswer,
|
|
484
|
-
DreamTokenBudgetExceeded,
|
|
485
|
-
isEditTool,
|
|
486
|
-
describeFinalWireTail,
|
|
487
|
-
estimateMessageTokens,
|
|
488
|
-
wireContentBytes,
|
|
489
|
-
createFinalWireUsageTracker,
|
|
490
|
-
estimateFinalWireInputTokens,
|
|
491
|
-
estimateAppendedWireTokens,
|
|
492
|
-
isPrefixBoundThinkingModel,
|
|
493
|
-
detectOverflow,
|
|
494
|
-
modelAcceptsEmptyContent,
|
|
495
|
-
isAnthropicFamilyRoute,
|
|
496
|
-
variantChangeBustsProviderCache,
|
|
497
|
-
setRawMessageProvider2,
|
|
498
|
-
cleanUserText2,
|
|
499
|
-
withRawSessionMessageCache2,
|
|
500
|
-
readRawSessionMessages2,
|
|
501
|
-
visitRawSessionMessages2,
|
|
502
|
-
primeTailRawMessageCache2,
|
|
503
|
-
primeInMemoryTailRawMessageCache2,
|
|
504
|
-
readRawSessionMessageOrdinalPage2,
|
|
505
|
-
getRawSessionStoredMessageCount2,
|
|
506
|
-
readRawSessionMessageIdOrdinalsForRange2,
|
|
507
|
-
readRawSessionMessagePartsById2,
|
|
508
|
-
readRawSessionMessageById2,
|
|
509
|
-
readSessionChunk2,
|
|
510
|
-
readRawSessionSeedTail2
|
|
511
|
-
} from "./index-3h0ybwah.js";
|
|
512
|
-
import {
|
|
513
|
-
observeTemporalDecisions,
|
|
514
|
-
getMeasuredToolDefinitionTokens
|
|
515
|
-
} from "./index-5gq3b2ya.js";
|
|
516
|
-
import {
|
|
517
|
-
openCodeDbExists,
|
|
518
|
-
withReadOnlySessionDb,
|
|
519
|
-
assistantAwaitingTools,
|
|
520
|
-
latestPersistedMessageForRecovery,
|
|
521
|
-
findLastAssistantModelFromOpenCodeDb
|
|
522
|
-
} from "./index-majxda46.js";
|
|
523
|
-
import {
|
|
524
|
-
CANONICAL_DREAM_TASKS,
|
|
525
|
-
DREAM_TASK_CAPABILITIES,
|
|
526
|
-
toolLoopDreamTasks,
|
|
527
|
-
formatDreamTaskBacklogs,
|
|
528
|
-
formatDreamTaskFailures,
|
|
529
|
-
processedDreamTaskItems,
|
|
530
|
-
leaseKindFor,
|
|
531
|
-
leaseKeyFor,
|
|
532
|
-
isCanonicalDreamTask,
|
|
533
|
-
compareTaskOrder,
|
|
534
|
-
buildDreamTaskRuntimeConfigs2,
|
|
535
|
-
userMemoryCollectionEnabled2
|
|
536
|
-
} from "./index-mc22ayvf.js";
|
|
552
|
+
} from "./index-6d9e1m08.js";
|
|
537
553
|
import {
|
|
538
554
|
registerNotificationSink2,
|
|
539
555
|
pushNotification2,
|
|
@@ -541,12 +557,6 @@ import {
|
|
|
541
557
|
drainNotifications2,
|
|
542
558
|
isTuiConnected2
|
|
543
559
|
} from "./index-x8a7jmkh.js";
|
|
544
|
-
import {
|
|
545
|
-
flushIgnoredMessages2,
|
|
546
|
-
clearIgnoredMessages2,
|
|
547
|
-
observeIgnoredNotificationEvent2,
|
|
548
|
-
sendStatusNotification2
|
|
549
|
-
} from "./index-7qw742ev.js";
|
|
550
560
|
import {
|
|
551
561
|
indexCommitsForProject,
|
|
552
562
|
embedUnembeddedCommits,
|
|
@@ -554,7 +564,9 @@ import {
|
|
|
554
564
|
parseIdShapedQuery,
|
|
555
565
|
resolveMemoriesByIdsForSearch,
|
|
556
566
|
unifiedSearch,
|
|
557
|
-
formatSearchResults
|
|
567
|
+
formatSearchResults
|
|
568
|
+
} from "./index-92bp57hg.js";
|
|
569
|
+
import {
|
|
558
570
|
findSessionId,
|
|
559
571
|
findLastUserMessageId,
|
|
560
572
|
clearAutoSearchForSession,
|
|
@@ -571,18 +583,26 @@ import {
|
|
|
571
583
|
canConsumeDeferredOnThisPass,
|
|
572
584
|
hasReclaimRide,
|
|
573
585
|
reclaimRideLabel,
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
586
|
+
replayClearedReasoning,
|
|
587
|
+
replayStrippedInlineThinking,
|
|
588
|
+
stripClearedReasoning,
|
|
589
|
+
snapshotTrailingBlankSourceDecisions,
|
|
590
|
+
projectOpencodeReasoningBudgetCutoff,
|
|
591
|
+
resolveKeepReasoningTokens,
|
|
592
|
+
reasoningBudgetCutoff,
|
|
593
|
+
captureOpencodeReasoningBudgetStatus,
|
|
594
|
+
reasoningBudgetStatusLine,
|
|
577
595
|
ENGINE_RECONNECTING_USER_MESSAGE,
|
|
578
596
|
contextRefusalError,
|
|
579
597
|
protectedToolRefusal,
|
|
580
598
|
outgoingContextRefusal,
|
|
581
599
|
EmergencyFailClosedError,
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
600
|
+
latestAssistantTurnStart,
|
|
601
|
+
latestAssistantTurnMessages,
|
|
602
|
+
hasActiveAnthropicThinkingTurn,
|
|
603
|
+
replayCavemanCompression,
|
|
604
|
+
DegradedPassRefusalError,
|
|
605
|
+
degradedPassError,
|
|
586
606
|
applyFlushedStatuses,
|
|
587
607
|
stripStructuralNoise,
|
|
588
608
|
logTransformTiming,
|
|
@@ -596,11 +616,17 @@ import {
|
|
|
596
616
|
abortSessionFailClosed2,
|
|
597
617
|
evaluateEmergencyFailClosed2,
|
|
598
618
|
runPostTransformPhase2
|
|
599
|
-
} from "./index-
|
|
619
|
+
} from "./index-cwf6s3ay.js";
|
|
620
|
+
import {
|
|
621
|
+
flushIgnoredMessages2,
|
|
622
|
+
clearIgnoredMessages2,
|
|
623
|
+
observeIgnoredNotificationEvent2,
|
|
624
|
+
sendStatusNotification2
|
|
625
|
+
} from "./index-adwfkpex.js";
|
|
600
626
|
import {
|
|
601
627
|
setRecompStarting2,
|
|
602
628
|
setRecompTerminal2
|
|
603
|
-
} from "./index-
|
|
629
|
+
} from "./index-gg8j07zz.js";
|
|
604
630
|
import {
|
|
605
631
|
ANNOUNCEMENT_VERSION2,
|
|
606
632
|
ANNOUNCEMENT_FEATURES2,
|
|
@@ -5927,7 +5953,7 @@ function getAsyncModule() {
|
|
|
5927
5953
|
await beforeModuleLoad();
|
|
5928
5954
|
const [{ default: singlefileAsyncifyVariant }, { newQuickJSAsyncWASMModuleFromVariant }] = await importPluginModule(() => Promise.all([
|
|
5929
5955
|
import("./index-e7vx3byk.js").then((m)=>__toESM(m.default,1)),
|
|
5930
|
-
import("./index-
|
|
5956
|
+
import("./index-5prbx026.js")
|
|
5931
5957
|
]));
|
|
5932
5958
|
const module = await newQuickJSAsyncWASMModuleFromVariant(singlefileAsyncifyVariant);
|
|
5933
5959
|
return module;
|
|
@@ -8875,9 +8901,11 @@ function countCompartmentsSince(db, projectPath, since) {
|
|
|
8875
8901
|
}
|
|
8876
8902
|
function countProjectSessionsSince(db, projectPath, since) {
|
|
8877
8903
|
const row = since === null ? db.prepare("SELECT COUNT(*) AS cnt FROM session_projects WHERE project_path = ?").get(projectPath) : db.prepare(`SELECT COUNT(*) AS cnt FROM session_projects sp
|
|
8878
|
-
JOIN schema_migrations_meta activity
|
|
8904
|
+
LEFT JOIN schema_migrations_meta activity
|
|
8879
8905
|
ON activity.key = 'retrospective_activity:' || sp.session_id
|
|
8880
|
-
|
|
8906
|
+
LEFT JOIN message_history_index history ON history.session_id = sp.session_id
|
|
8907
|
+
WHERE sp.project_path = ?
|
|
8908
|
+
AND COALESCE(CAST(activity.value AS INTEGER), history.updated_at) > ?`).get(projectPath, since);
|
|
8881
8909
|
return row?.cnt ?? 0;
|
|
8882
8910
|
}
|
|
8883
8911
|
function countMappedMemories(db, projectPath) {
|
|
@@ -8952,10 +8980,11 @@ function hasActiveMemories(db, projectPath) {
|
|
|
8952
8980
|
return db.prepare("SELECT 1 AS one FROM memories WHERE project_path = ? AND status IN ('active','permanent') LIMIT 1").get(projectPath) != null;
|
|
8953
8981
|
}
|
|
8954
8982
|
var RECENT_PROJECT_SESSIONS_SQL = `SELECT sp.session_id FROM session_projects sp
|
|
8955
|
-
|
|
8956
|
-
|
|
8983
|
+
LEFT JOIN schema_migrations_meta activity
|
|
8984
|
+
ON activity.key = 'retrospective_activity:' || sp.session_id
|
|
8985
|
+
LEFT JOIN message_history_index history ON history.session_id = sp.session_id
|
|
8957
8986
|
WHERE sp.project_path = ?
|
|
8958
|
-
AND (sp.updated_at > ? OR CAST(activity.value AS INTEGER) > ?)`;
|
|
8987
|
+
AND (sp.updated_at > ? OR COALESCE(CAST(activity.value AS INTEGER), history.updated_at) > ?)`;
|
|
8959
8988
|
function hasRecentProjectSession(db, projectPath, since) {
|
|
8960
8989
|
return db.prepare(`${RECENT_PROJECT_SESSIONS_SQL} LIMIT 1`).get(projectPath, since, since) != null;
|
|
8961
8990
|
}
|
|
@@ -12289,7 +12318,9 @@ function scheduleInitialProjectRun(reg, db) {
|
|
|
12289
12318
|
startupTimers.set(reg.directory, timer);
|
|
12290
12319
|
}
|
|
12291
12320
|
async function runProjectMaintenance(reg, origin, db) {
|
|
12292
|
-
const
|
|
12321
|
+
const sampled = reg.sampleDreamRun?.();
|
|
12322
|
+
const current = sampled ? { ...reg, ...sampled } : reg;
|
|
12323
|
+
const projectMaintenanceEnabled = Boolean(current.dreamerConfig && current.dreamerConfig.disable !== true) || reg.memoryEnabled === true || reg.gitCommitIndexing?.enabled === true || reg.historianChildSweep !== undefined;
|
|
12293
12324
|
if (!projectMaintenanceEnabled)
|
|
12294
12325
|
return;
|
|
12295
12326
|
await reg.ensureRegistered(reg.directory, db);
|
|
@@ -12300,8 +12331,7 @@ async function runProjectMaintenance(reg, origin, db) {
|
|
|
12300
12331
|
log(`[magic-context] proactively embedded ${embeddedCount} ${embeddedCount === 1 ? "memory" : "memories"} for project ${reg.projectIdentity}`);
|
|
12301
12332
|
}
|
|
12302
12333
|
}
|
|
12303
|
-
|
|
12304
|
-
await sweepProject(sampled ? { ...reg, ...sampled } : reg, origin, db);
|
|
12334
|
+
await sweepProject(current, origin, db);
|
|
12305
12335
|
}
|
|
12306
12336
|
async function sweepProject(reg, origin, db, gitCommitEnabled) {
|
|
12307
12337
|
if (!directoryStillExists(reg.directory)) {
|
|
@@ -12847,12 +12877,68 @@ function resolveModelCacheTtl(config, modelKey, configuredExplicitly = typeof co
|
|
|
12847
12877
|
};
|
|
12848
12878
|
}
|
|
12849
12879
|
|
|
12880
|
+
// src/hooks/magic-context/opencode-proven-floor.ts
|
|
12881
|
+
var KEY = "opencodeProvenInputFloor";
|
|
12882
|
+
function recordOpenCodeProvenInputFloor(db, sessionId, modelKey, tokens) {
|
|
12883
|
+
db.prepare(`UPDATE session_meta SET deferred_execute_state = json_set(
|
|
12884
|
+
CASE WHEN json_valid(deferred_execute_state) AND json_type(deferred_execute_state) = 'object'
|
|
12885
|
+
THEN deferred_execute_state ELSE '{}' END, '$.${KEY}', json(?)) WHERE session_id = ?`).run(JSON.stringify({ modelKey, tokens, basis: "provider_usage_v1" }), sessionId);
|
|
12886
|
+
}
|
|
12887
|
+
function largestAcceptedInput(sessionId, modelKey) {
|
|
12888
|
+
return withReadOnlySessionDb((db) => {
|
|
12889
|
+
const rows = db.prepare(`SELECT
|
|
12890
|
+
COALESCE(json_extract(data, '$.providerID'), json_extract(data, '$.model.providerID')) AS provider,
|
|
12891
|
+
COALESCE(json_extract(data, '$.modelID'), json_extract(data, '$.model.id')) AS model,
|
|
12892
|
+
json_extract(data, '$.finish') AS finish, json_extract(data, '$.error') AS error,
|
|
12893
|
+
json_extract(data, '$.tokens.input') AS input,
|
|
12894
|
+
json_extract(data, '$.tokens.cache.read') AS cacheRead,
|
|
12895
|
+
json_extract(data, '$.tokens.cache.write') AS cacheWrite
|
|
12896
|
+
FROM message WHERE session_id = ? AND json_valid(data)
|
|
12897
|
+
AND json_extract(data, '$.role') = 'assistant'`).all(sessionId);
|
|
12898
|
+
let largest = 0;
|
|
12899
|
+
for (const row of rows) {
|
|
12900
|
+
if (!row.provider || !row.model || piModelRefToCanonical(`${row.provider}/${row.model}`) !== piModelRefToCanonical(modelKey) || providerResponseFailed(row))
|
|
12901
|
+
continue;
|
|
12902
|
+
const components = [row.input ?? 0, row.cacheRead ?? 0, row.cacheWrite ?? 0];
|
|
12903
|
+
if (components.every((n) => typeof n === "number" && Number.isFinite(n) && n >= 0)) {
|
|
12904
|
+
largest = Math.max(largest, components.reduce((sum, n) => sum + n, 0));
|
|
12905
|
+
}
|
|
12906
|
+
}
|
|
12907
|
+
return largest;
|
|
12908
|
+
});
|
|
12909
|
+
}
|
|
12910
|
+
function resolveOpenCodeProvenInputFloor(db, sessionId, modelKey) {
|
|
12911
|
+
const row = db.prepare("SELECT observed_safe_input_tokens, last_observed_model_key, deferred_execute_state FROM session_meta WHERE session_id = ?").get(sessionId);
|
|
12912
|
+
const stored = row?.observed_safe_input_tokens ?? 0;
|
|
12913
|
+
if (!modelKey || piModelRefToCanonical(row?.last_observed_model_key ?? "") !== piModelRefToCanonical(modelKey) || !Number.isFinite(stored) || stored <= 0)
|
|
12914
|
+
return 0;
|
|
12915
|
+
try {
|
|
12916
|
+
const record = JSON.parse(row?.deferred_execute_state ?? "{}")[KEY];
|
|
12917
|
+
if (record?.basis === "provider_usage_v1" && record.modelKey === modelKey && record.tokens === stored)
|
|
12918
|
+
return stored;
|
|
12919
|
+
} catch {}
|
|
12920
|
+
let measured = 0;
|
|
12921
|
+
try {
|
|
12922
|
+
measured = largestAcceptedInput(sessionId, modelKey);
|
|
12923
|
+
} catch {}
|
|
12924
|
+
const repaired = Math.min(stored, measured);
|
|
12925
|
+
updateSessionMeta(db, sessionId, {
|
|
12926
|
+
observedSafeInputTokens: repaired,
|
|
12927
|
+
cacheAlertSent: false,
|
|
12928
|
+
lastUsageContextLimit: 0
|
|
12929
|
+
});
|
|
12930
|
+
recordOpenCodeProvenInputFloor(db, sessionId, modelKey, repaired);
|
|
12931
|
+
sessionLog(sessionId, `legacy proven input floor ${stored} clamped to accepted provider usage: ${repaired}`);
|
|
12932
|
+
return repaired;
|
|
12933
|
+
}
|
|
12934
|
+
|
|
12850
12935
|
// src/hooks/magic-context/event-resolvers.ts
|
|
12851
12936
|
var DEFAULT_CONTEXT_LIMIT = 200000;
|
|
12852
12937
|
function modelMatchedPersistedUsage(db, sessionID, modelKey) {
|
|
12853
12938
|
if (!db || !sessionID || !modelKey)
|
|
12854
12939
|
return;
|
|
12855
12940
|
try {
|
|
12941
|
+
resolveOpenCodeProvenInputFloor(db, sessionID, modelKey);
|
|
12856
12942
|
const persisted = loadPersistedUsage(db, sessionID);
|
|
12857
12943
|
if (persisted !== null && piModelRefToCanonical(persisted.lastObservedModelKey ?? "") === piModelRefToCanonical(modelKey)) {
|
|
12858
12944
|
return persisted;
|
|
@@ -13964,6 +14050,29 @@ function formatThresholdClampNote(opts) {
|
|
|
13964
14050
|
// src/shared/rust-mode-status.ts
|
|
13965
14051
|
var RUST_MODE_HOST_PATHS_LINE = "Host backends → MODULE: ctx_memory, ctx_note; historian: module-side";
|
|
13966
14052
|
|
|
14053
|
+
// src/hooks/magic-context/historian-drain-gate.ts
|
|
14054
|
+
var loggedWindows = new WeakMap;
|
|
14055
|
+
function isHistorianDrainBudgetSpent(args) {
|
|
14056
|
+
const target = deriveProtectedTailTokenTarget(args);
|
|
14057
|
+
const state = getProtectedTailDrainBudgetSkip({
|
|
14058
|
+
...args,
|
|
14059
|
+
usable: target.usable,
|
|
14060
|
+
perRunCap: selectPerRunCap({ ...args, N: target.N })
|
|
14061
|
+
});
|
|
14062
|
+
if (!state)
|
|
14063
|
+
return false;
|
|
14064
|
+
let windows = loggedWindows.get(args.db);
|
|
14065
|
+
if (!windows) {
|
|
14066
|
+
windows = new Map;
|
|
14067
|
+
loggedWindows.set(args.db, windows);
|
|
14068
|
+
}
|
|
14069
|
+
if (windows.get(args.sessionId) !== state.resetsAt) {
|
|
14070
|
+
windows.set(args.sessionId, state.resetsAt);
|
|
14071
|
+
sessionLog(args.sessionId, `historian skip: internal drain budget spent (${state.spentTokens}/${state.limitTokens} tokens); next eligible at ${new Date(state.nextEligibleAt).toISOString()}`);
|
|
14072
|
+
}
|
|
14073
|
+
return true;
|
|
14074
|
+
}
|
|
14075
|
+
|
|
13967
14076
|
// src/hooks/magic-context/compartment-trigger.ts
|
|
13968
14077
|
var PROACTIVE_TRIGGER_OFFSET_PERCENTAGE = 2;
|
|
13969
14078
|
var POST_DROP_TARGET_RATIO = 0.75;
|
|
@@ -14024,7 +14133,7 @@ function buildTriggerInMemoryTail(db, sessionId, messages) {
|
|
|
14024
14133
|
function getProactiveCompartmentTriggerPercentage(executeThresholdPercentage) {
|
|
14025
14134
|
return Math.max(0, executeThresholdPercentage - PROACTIVE_TRIGGER_OFFSET_PERCENTAGE);
|
|
14026
14135
|
}
|
|
14027
|
-
function estimateProjectedPostDropPercentage(db, sessionId, usage, activeTags,
|
|
14136
|
+
function estimateProjectedPostDropPercentage(db, sessionId, usage, activeTags, keepReasoningTokens, clearedReasoningThroughTag, canClearReasoning, liveBudgetCutoff) {
|
|
14028
14137
|
const totalActiveBytes = activeTags.reduce((sum, tag) => sum + tag.byteSize + tag.reasoningByteSize, 0);
|
|
14029
14138
|
if (totalActiveBytes === 0)
|
|
14030
14139
|
return null;
|
|
@@ -14034,9 +14143,25 @@ function estimateProjectedPostDropPercentage(db, sessionId, usage, activeTags, c
|
|
|
14034
14143
|
if (pendingDrops.length > 0) {
|
|
14035
14144
|
droppableBytes += activeTags.filter((tag) => pendingDropTagIds.has(tag.tagNumber)).reduce((sum, tag) => sum + tag.byteSize + tag.reasoningByteSize, 0);
|
|
14036
14145
|
}
|
|
14037
|
-
|
|
14038
|
-
|
|
14039
|
-
const
|
|
14146
|
+
if (canClearReasoning && keepReasoningTokens !== undefined && clearedReasoningThroughTag !== undefined) {
|
|
14147
|
+
const estimates = getReasoningTokenEstimatesByMessage(db, sessionId, sessionDecisionCalibration(db, sessionId).proseRatio);
|
|
14148
|
+
const groups = new Map;
|
|
14149
|
+
for (const tag of activeTags) {
|
|
14150
|
+
const id = tag.type === "tool" ? tag.toolOwnerMessageId : tag.messageId;
|
|
14151
|
+
if (!id)
|
|
14152
|
+
continue;
|
|
14153
|
+
const group = groups.get(id) ?? { tag: 0, cost: estimates.get(id) ?? 0 };
|
|
14154
|
+
if (!estimates.has(id))
|
|
14155
|
+
group.cost += tag.reasoningByteSize / 4;
|
|
14156
|
+
group.tag = Math.max(group.tag, tag.tagNumber);
|
|
14157
|
+
groups.set(id, group);
|
|
14158
|
+
}
|
|
14159
|
+
const steps = [...groups.values()].sort((a, b) => a.tag - b.tag);
|
|
14160
|
+
const reasoningAgeCutoff = liveBudgetCutoff ?? reasoningBudgetCutoff(steps.map((step, index) => ({
|
|
14161
|
+
...step,
|
|
14162
|
+
exempt: index === steps.length - 1,
|
|
14163
|
+
alreadyRemoved: step.tag <= clearedReasoningThroughTag
|
|
14164
|
+
})), keepReasoningTokens);
|
|
14040
14165
|
for (const tag of activeTags) {
|
|
14041
14166
|
if (tag.type !== "message")
|
|
14042
14167
|
continue;
|
|
@@ -14106,7 +14231,7 @@ function getUnsummarizedTailInfo(db, sessionId, triggerBudget, usage, executeThr
|
|
|
14106
14231
|
usageSource: "live",
|
|
14107
14232
|
taggerFloor
|
|
14108
14233
|
});
|
|
14109
|
-
const hasProtectedEligibleHead = boundary.offset < boundary.protectedTailStart;
|
|
14234
|
+
const hasProtectedEligibleHead = boundary.offset < Math.min(boundary.protectedTailStart, boundary.eligibleEndOrdinal);
|
|
14110
14235
|
if (!hasProtectedEligibleHead) {
|
|
14111
14236
|
return {
|
|
14112
14237
|
...TAIL_INFO_DEFAULTS,
|
|
@@ -14118,7 +14243,7 @@ function getUnsummarizedTailInfo(db, sessionId, triggerBudget, usage, executeThr
|
|
|
14118
14243
|
const seed = sessionDecisionCalibration(db, sessionId);
|
|
14119
14244
|
const sourceRatio = Math.max(seed.proseRatio, seed.toolsRatio);
|
|
14120
14245
|
const scanBudget = Math.floor(Math.max(MIN_PROACTIVE_TAIL_TOKEN_ESTIMATE, triggerBudget * TAIL_SIZE_TRIGGER_MULTIPLIER) / sourceRatio);
|
|
14121
|
-
const chunk = readSessionChunk2(sessionId, scanBudget, rawEligibility.offset, boundary.
|
|
14246
|
+
const chunk = readSessionChunk2(sessionId, scanBudget, rawEligibility.offset, boundary.eligibleEndOrdinal);
|
|
14122
14247
|
const isMeaningful = chunk.hasMore || boundary.trueRawEligibleTokens >= MIN_PROACTIVE_TAIL_TOKEN_ESTIMATE || Math.ceil(chunk.tokenEstimate * sourceRatio) >= MIN_PROACTIVE_TAIL_TOKEN_ESTIMATE || chunk.messageCount >= MIN_PROACTIVE_TAIL_MESSAGE_COUNT;
|
|
14123
14248
|
return {
|
|
14124
14249
|
nextStartOrdinal: rawEligibility.offset,
|
|
@@ -14140,11 +14265,19 @@ function getUnsummarizedTailInfo(db, sessionId, triggerBudget, usage, executeThr
|
|
|
14140
14265
|
function formatProjectedPostDropPercentage(value) {
|
|
14141
14266
|
return value === null ? "none" : `${value.toFixed(1)}%`;
|
|
14142
14267
|
}
|
|
14143
|
-
function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPercentage, executeThresholdPercentage, triggerBudget,
|
|
14268
|
+
function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPercentage, executeThresholdPercentage, triggerBudget, keepReasoningTokens, commitClusterTrigger, preloadedActiveTags, contextLimit, inMemoryTail, taggerFloorOverride, reasoningProjection, reclaimRide) {
|
|
14144
14269
|
if (sessionMeta.compartmentInProgress) {
|
|
14145
14270
|
sessionLog(sessionId, `compartment trigger: skipped — historian already in progress (usage=${usage.percentage.toFixed(1)}%)`);
|
|
14146
14271
|
return { shouldFire: false };
|
|
14147
14272
|
}
|
|
14273
|
+
if (isHistorianDrainBudgetSpent({
|
|
14274
|
+
db,
|
|
14275
|
+
sessionId,
|
|
14276
|
+
usagePercentage: usage.percentage,
|
|
14277
|
+
contextLimit: resolveBoundaryContextLimit(usage, contextLimit),
|
|
14278
|
+
executeThresholdPercentage
|
|
14279
|
+
}))
|
|
14280
|
+
return { shouldFire: false };
|
|
14148
14281
|
const lazyInMemoryTail = typeof inMemoryTail === "function" ? inMemoryTail : undefined;
|
|
14149
14282
|
let resolvedInMemoryTail = typeof inMemoryTail === "function" ? undefined : inMemoryTail;
|
|
14150
14283
|
if (resolvedInMemoryTail) {
|
|
@@ -14196,7 +14329,7 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
|
|
|
14196
14329
|
return { shouldFire: false };
|
|
14197
14330
|
}
|
|
14198
14331
|
const canClearReasoning = reasoningProjection?.canClearReasoning ?? modelAcceptsEmptyContent(reasoningProjection?.providerID);
|
|
14199
|
-
const projectedPostDropPercentage = estimateProjectedPostDropPercentage(db, sessionId, usage, preloadedActiveTags ?? getActiveTagsBySession(db, sessionId),
|
|
14332
|
+
const projectedPostDropPercentage = estimateProjectedPostDropPercentage(db, sessionId, usage, preloadedActiveTags ?? getActiveTagsBySession(db, sessionId), keepReasoningTokens, sessionMeta.clearedReasoningThroughTag, canClearReasoning, reasoningProjection?.budgetCutoff);
|
|
14200
14333
|
const relativePostDropTarget = executeThresholdPercentage * POST_DROP_TARGET_RATIO;
|
|
14201
14334
|
const rideLabel = reclaimRide ? reclaimRideLabel(reclaimRide) : "ride=none";
|
|
14202
14335
|
const dropsCanLand = reclaimRide !== undefined && hasReclaimRide(reclaimRide);
|
|
@@ -14348,7 +14481,9 @@ function executeStatus(db, sessionId, executeThresholdPercentageConfig = DEFAULT
|
|
|
14348
14481
|
const displayPercentage = contextUsage?.percentage ?? meta.lastContextPercentage;
|
|
14349
14482
|
const displayContextLimit = contextLimit && contextLimit > 0 ? contextLimit : displayPercentage > 0 ? Math.round(displayInputTokens / (displayPercentage / 100)) : 0;
|
|
14350
14483
|
const parseFailureLines = (display?.configParseFailures ?? []).map(formatConfigParseStatusLine);
|
|
14484
|
+
const reasoningLine = reasoningBudgetStatusLine(sessionId);
|
|
14351
14485
|
const lines = [
|
|
14486
|
+
...reasoningLine ? [reasoningLine, ""] : [],
|
|
14352
14487
|
...openCodeDbStatusLine ? [openCodeDbStatusLine, ""] : [],
|
|
14353
14488
|
...parseFailureLines,
|
|
14354
14489
|
...parseFailureLines.length > 0 ? [""] : [],
|
|
@@ -16661,7 +16796,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16661
16796
|
return { count: buildCompartmentCount(db, sessionId, moduleStatus) };
|
|
16662
16797
|
});
|
|
16663
16798
|
const buildManagedCtx = async (db) => {
|
|
16664
|
-
const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await importPluginModule(() => import("./derive-budgets-
|
|
16799
|
+
const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await importPluginModule(() => import("./derive-budgets-ke12jnnh.js"));
|
|
16665
16800
|
const { resolveHistorianModel } = await importPluginModule(() => import("./model-resolution-xhfmyyvy.js"));
|
|
16666
16801
|
const { userMemoryCollectionEnabled } = await importPluginModule(() => import("./task-config-v81k8jvk.js"));
|
|
16667
16802
|
const DEFAULT_HISTORIAN_TIMEOUT_MS = 10 * 60 * 1000;
|
|
@@ -16697,8 +16832,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16697
16832
|
const db = readDatabase();
|
|
16698
16833
|
if (!db)
|
|
16699
16834
|
return { ok: false, error: "db unavailable" };
|
|
16700
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
16701
|
-
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-
|
|
16835
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-rervg6q4.js"));
|
|
16836
|
+
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-0m68ms3n.js"));
|
|
16702
16837
|
log(`[rpc] recomp requested for session ${sessionId}`);
|
|
16703
16838
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
16704
16839
|
return {
|
|
@@ -16767,7 +16902,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16767
16902
|
const db = readDatabase();
|
|
16768
16903
|
if (!db)
|
|
16769
16904
|
return { ok: false, error: "db unavailable" };
|
|
16770
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
16905
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-b2dztrar.js"));
|
|
16771
16906
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
16772
16907
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
16773
16908
|
const ctx = {
|
|
@@ -16827,18 +16962,225 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16827
16962
|
return { show: false };
|
|
16828
16963
|
}
|
|
16829
16964
|
return {
|
|
16830
|
-
show: true,
|
|
16831
|
-
version: ANNOUNCEMENT_VERSION2,
|
|
16832
|
-
features: [...ANNOUNCEMENT_FEATURES2],
|
|
16833
|
-
footer: ANNOUNCEMENT_FOOTER2
|
|
16965
|
+
show: true,
|
|
16966
|
+
version: ANNOUNCEMENT_VERSION2,
|
|
16967
|
+
features: [...ANNOUNCEMENT_FEATURES2],
|
|
16968
|
+
footer: ANNOUNCEMENT_FOOTER2
|
|
16969
|
+
};
|
|
16970
|
+
});
|
|
16971
|
+
rpcServer.handle("mark-announced", async () => {
|
|
16972
|
+
if (ANNOUNCEMENT_VERSION2) {
|
|
16973
|
+
markAnnouncementSeen2(ANNOUNCEMENT_VERSION2);
|
|
16974
|
+
}
|
|
16975
|
+
return { ok: true };
|
|
16976
|
+
});
|
|
16977
|
+
}
|
|
16978
|
+
|
|
16979
|
+
// src/hooks/magic-context/latest-thinking-recovery.ts
|
|
16980
|
+
var LATEST_THINKING_RESTORE = "latest_thinking_original";
|
|
16981
|
+
var knownRejectedSessions = new Set;
|
|
16982
|
+
var lastPassTurnAnchor = new Map;
|
|
16983
|
+
var ACTIVE = `${LATEST_THINKING_RESTORE}:`;
|
|
16984
|
+
var ARMED = `${LATEST_THINKING_RESTORE}_armed:`;
|
|
16985
|
+
var UNRECOVERABLE = `${LATEST_THINKING_RESTORE}_unavailable`;
|
|
16986
|
+
var LATEST_THINKING_UNSAFE = "ANTHROPIC_LATEST_TURN_EDIT_UNSAFE: The provider rejected edits to this thinking turn and its original context cannot be safely replayed. Send a new user message or /clear to continue.";
|
|
16987
|
+
function armLatestThinkingRecovery(db, sessionId) {
|
|
16988
|
+
knownRejectedSessions.add(sessionId);
|
|
16989
|
+
ensureSessionMetaRow(db, sessionId);
|
|
16990
|
+
const current = getThinkingBindingRecoveryTarget(db, sessionId);
|
|
16991
|
+
const anchor = lastPassTurnAnchor.get(sessionId);
|
|
16992
|
+
const next = current?.startsWith(ACTIVE) ? UNRECOVERABLE + ":" + current.slice(ACTIVE.length) : current?.startsWith(UNRECOVERABLE) || current?.startsWith(ARMED) ? current : anchor !== undefined ? ARMED + anchor : LATEST_THINKING_RESTORE;
|
|
16993
|
+
db.prepare("UPDATE session_meta SET thinking_binding_recovery_target = ? WHERE session_id = ?").run(next, sessionId);
|
|
16994
|
+
}
|
|
16995
|
+
function clone(value) {
|
|
16996
|
+
if (Array.isArray(value))
|
|
16997
|
+
return value.map(clone);
|
|
16998
|
+
if (!isRecord(value))
|
|
16999
|
+
return value;
|
|
17000
|
+
const proto = Object.getPrototypeOf(value);
|
|
17001
|
+
if (proto !== Object.prototype && proto !== null)
|
|
17002
|
+
return value;
|
|
17003
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, clone(item)]));
|
|
17004
|
+
}
|
|
17005
|
+
function isThinkingPart(part) {
|
|
17006
|
+
return isRecord(part) && ["thinking", "reasoning", "redacted_thinking"].includes(String(part.type));
|
|
17007
|
+
}
|
|
17008
|
+
function replayableOriginal(part) {
|
|
17009
|
+
if (!isThinkingPart(part) || !isRecord(part))
|
|
17010
|
+
return false;
|
|
17011
|
+
const metadata = isRecord(part.metadata) && isRecord(part.metadata.anthropic) ? part.metadata.anthropic : {};
|
|
17012
|
+
const signature = part.signature ?? part.thinkingSignature ?? metadata.signature ?? part.data ?? metadata.redactedData;
|
|
17013
|
+
return typeof signature === "string" && signature.length > 0 && part.text !== "[cleared]" && part.thinking !== "[cleared]";
|
|
17014
|
+
}
|
|
17015
|
+
function prepareLatestThinkingRecovery(args) {
|
|
17016
|
+
const start = latestAssistantTurnStart(args.messages);
|
|
17017
|
+
const anchor = start > 0 ? args.id(args.messages[start - 1], start - 1) : undefined;
|
|
17018
|
+
if (anchor === undefined)
|
|
17019
|
+
lastPassTurnAnchor.delete(args.sessionId);
|
|
17020
|
+
else
|
|
17021
|
+
lastPassTurnAnchor.set(args.sessionId, anchor);
|
|
17022
|
+
let target;
|
|
17023
|
+
try {
|
|
17024
|
+
target = getThinkingBindingRecoveryTarget(args.db, args.sessionId);
|
|
17025
|
+
} catch (error) {
|
|
17026
|
+
if (knownRejectedSessions.has(args.sessionId))
|
|
17027
|
+
throw contextRefusalError(LATEST_THINKING_UNSAFE);
|
|
17028
|
+
return { restore: false, ended: false };
|
|
17029
|
+
}
|
|
17030
|
+
if (!target || !target.startsWith(LATEST_THINKING_RESTORE)) {
|
|
17031
|
+
knownRejectedSessions.delete(args.sessionId);
|
|
17032
|
+
return { restore: false, ended: false };
|
|
17033
|
+
}
|
|
17034
|
+
const armedAnchor = target.startsWith(ARMED) ? target.slice(ARMED.length) : undefined;
|
|
17035
|
+
if (target === LATEST_THINKING_RESTORE || armedAnchor !== undefined && armedAnchor !== anchor) {
|
|
17036
|
+
args.db.prepare("UPDATE session_meta SET thinking_binding_recovery_target = '' WHERE session_id = ? AND thinking_binding_recovery_target = ?").run(args.sessionId, target);
|
|
17037
|
+
knownRejectedSessions.delete(args.sessionId);
|
|
17038
|
+
return { restore: false, ended: false };
|
|
17039
|
+
}
|
|
17040
|
+
knownRejectedSessions.add(args.sessionId);
|
|
17041
|
+
const savedAnchor = target.startsWith(ACTIVE) ? target.slice(ACTIVE.length) : target.startsWith(UNRECOVERABLE + ":") ? target.slice(UNRECOVERABLE.length + 1) : undefined;
|
|
17042
|
+
if (savedAnchor !== undefined && savedAnchor !== anchor) {
|
|
17043
|
+
args.db.prepare("UPDATE session_meta SET thinking_binding_recovery_target = '' WHERE session_id = ? AND thinking_binding_recovery_target = ?").run(args.sessionId, target);
|
|
17044
|
+
knownRejectedSessions.delete(args.sessionId);
|
|
17045
|
+
return { restore: false, ended: true };
|
|
17046
|
+
}
|
|
17047
|
+
if (target.startsWith(UNRECOVERABLE) || !anchor)
|
|
17048
|
+
throw contextRefusalError(LATEST_THINKING_UNSAFE);
|
|
17049
|
+
if (armedAnchor !== undefined) {
|
|
17050
|
+
args.db.prepare("UPDATE session_meta SET thinking_binding_recovery_target = ? WHERE session_id = ? AND thinking_binding_recovery_target = ?").run(ACTIVE + anchor, args.sessionId, target);
|
|
17051
|
+
}
|
|
17052
|
+
const active = args.messages.slice(start);
|
|
17053
|
+
if (!active.some((message) => args.parts(message).some(replayableOriginal)))
|
|
17054
|
+
throw contextRefusalError(LATEST_THINKING_UNSAFE + " [missing-thinking-original]");
|
|
17055
|
+
const ids = new Map(args.messages.map((message, index) => [args.id(message, index), index]));
|
|
17056
|
+
for (const decision of getMergedReasoningStrippedIds(args.db, args.sessionId)) {
|
|
17057
|
+
if (decision === "binding_mismatch_order:end" || decision === TOOL_SWEEP_SCOPED_MARKER)
|
|
17058
|
+
continue;
|
|
17059
|
+
const id = decodeMergedReasoningParts(decision)?.[0] ?? (decision.startsWith("binding_mismatch:") ? decision.slice("binding_mismatch:".length) : decision);
|
|
17060
|
+
const index = ids.get(id);
|
|
17061
|
+
if (index === undefined || index >= start && !args.parts(args.messages[index]).some(replayableOriginal))
|
|
17062
|
+
throw contextRefusalError(LATEST_THINKING_UNSAFE + ` [missing-original:${id}]`);
|
|
17063
|
+
}
|
|
17064
|
+
return { restore: true, ended: false };
|
|
17065
|
+
}
|
|
17066
|
+
function captureOriginalTurn(messages, parts, setParts) {
|
|
17067
|
+
const start = Math.max(0, latestAssistantTurnStart(messages) - 1);
|
|
17068
|
+
const originals = messages.slice(start).map((message) => ({ message, parts: clone(parts(message)) }));
|
|
17069
|
+
const before = messages.slice(0, start);
|
|
17070
|
+
return (target = messages) => {
|
|
17071
|
+
const first = target.findIndex((message) => originals.some((original) => original.message === message || isRecord(message) && isRecord(original.message) && (isRecord(message.info) && isRecord(original.message.info) && message.info.id === original.message.info.id || message.role === original.message.role && message.timestamp !== undefined && message.timestamp === original.message.timestamp)));
|
|
17072
|
+
const prefix = first >= 0 ? target.slice(0, first) : target === messages ? before : target.slice();
|
|
17073
|
+
for (const original of originals) {
|
|
17074
|
+
setParts(original.message, clone(original.parts));
|
|
17075
|
+
}
|
|
17076
|
+
target.length = 0;
|
|
17077
|
+
target.push(...prefix, ...originals.map((original) => original.message));
|
|
17078
|
+
};
|
|
17079
|
+
}
|
|
17080
|
+
function captureLatestTurnOriginals(messages) {
|
|
17081
|
+
return captureOriginalTurn(messages, (message) => message.parts, (message, parts) => {
|
|
17082
|
+
message.parts = parts;
|
|
17083
|
+
});
|
|
17084
|
+
}
|
|
17085
|
+
function armBindingRecoverySafely(db, sessionId) {
|
|
17086
|
+
if (getThinkingBindingRecoveryTarget(db, sessionId)?.startsWith(LATEST_THINKING_RESTORE))
|
|
17087
|
+
armLatestThinkingRecovery(db, sessionId);
|
|
17088
|
+
else
|
|
17089
|
+
armThinkingBindingRecovery(db, sessionId);
|
|
17090
|
+
}
|
|
17091
|
+
function armLatestThinkingRecoveryFromError(args) {
|
|
17092
|
+
if (!detectLatestTurnThinkingMismatch(args.error))
|
|
17093
|
+
return false;
|
|
17094
|
+
if (!isAnthropicFamilyRoute(args.providerID, args.modelID))
|
|
17095
|
+
return true;
|
|
17096
|
+
armLatestThinkingRecovery(args.db, args.sessionId);
|
|
17097
|
+
dropSlot(args.sessionId, "latest-thinking-recovery-arm");
|
|
17098
|
+
return true;
|
|
17099
|
+
}
|
|
17100
|
+
|
|
17101
|
+
// src/hooks/magic-context/lkg-replay-fit.ts
|
|
17102
|
+
var RAW_FALLBACK_BYTES_PER_CONTEXT_TOKEN = 4;
|
|
17103
|
+
function lkgReplayLimit(args) {
|
|
17104
|
+
const { db, sessionId, model } = args;
|
|
17105
|
+
const trusted = model ? resolveTrustedContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : undefined;
|
|
17106
|
+
if (trusted !== undefined && trusted > 0)
|
|
17107
|
+
return trusted;
|
|
17108
|
+
const detected = getOverflowState(db, sessionId, args.modelKey).detectedContextLimit;
|
|
17109
|
+
return detected > 0 ? detected : undefined;
|
|
17110
|
+
}
|
|
17111
|
+
function measureLkgReplay(args) {
|
|
17112
|
+
const baseline = args.measuredInputTokens ?? 0;
|
|
17113
|
+
const tailLimit = Math.max(0, args.limit - baseline);
|
|
17114
|
+
const proxy = wireContentBytes(args.messages, tailLimit * RAW_FALLBACK_BYTES_PER_CONTEXT_TOKEN, RAW_FALLBACK_BYTES_PER_CONTEXT_TOKEN);
|
|
17115
|
+
const skipped = { proxy, estimatorRan: false, trusted: false };
|
|
17116
|
+
if (proxy === null)
|
|
17117
|
+
return { fit: "unproven", tokens: null, ...skipped };
|
|
17118
|
+
const proxyTokens = baseline + Math.ceil(proxy.bytes / RAW_FALLBACK_BYTES_PER_CONTEXT_TOKEN);
|
|
17119
|
+
if (proxy.aborted || proxyTokens > args.limit) {
|
|
17120
|
+
return { fit: "over", tokens: null, proxyTokens, ...skipped };
|
|
17121
|
+
}
|
|
17122
|
+
let estimate;
|
|
17123
|
+
try {
|
|
17124
|
+
estimate = args.estimate();
|
|
17125
|
+
} catch {
|
|
17126
|
+
return { fit: "unproven", tokens: null, ...skipped };
|
|
17127
|
+
}
|
|
17128
|
+
const seen = { proxy, estimatorRan: true, trusted: estimate.trusted };
|
|
17129
|
+
const tokens = baseline + estimate.tokens;
|
|
17130
|
+
if (!estimate.trusted || !Number.isFinite(tokens) || tokens <= 0 || estimate.tokens < 0) {
|
|
17131
|
+
return {
|
|
17132
|
+
fit: "unproven",
|
|
17133
|
+
tokens: Number.isFinite(estimate.tokens) ? estimate.tokens : null,
|
|
17134
|
+
...seen
|
|
16834
17135
|
};
|
|
17136
|
+
}
|
|
17137
|
+
return tokens > args.limit ? { fit: "over", tokens, proxyTokens, ...seen } : { fit: "under", tokens, ...seen };
|
|
17138
|
+
}
|
|
17139
|
+
function measureLkgReplayRequest(args) {
|
|
17140
|
+
let measured;
|
|
17141
|
+
try {
|
|
17142
|
+
measured = args.model ? measuredLkgPrefix({
|
|
17143
|
+
...args,
|
|
17144
|
+
slot: getSlot(args.sessionId),
|
|
17145
|
+
modelKey: `${args.model.providerID}/${args.model.modelID}`
|
|
17146
|
+
}) : undefined;
|
|
17147
|
+
} catch {
|
|
17148
|
+
measured = undefined;
|
|
17149
|
+
}
|
|
17150
|
+
const estimator = args.estimator ?? estimateFinalWireInputTokens;
|
|
17151
|
+
return measureLkgReplay({
|
|
17152
|
+
messages: measured?.appendedMessages ?? args.messages,
|
|
17153
|
+
limit: args.limit,
|
|
17154
|
+
measuredInputTokens: measured?.inputTokens,
|
|
17155
|
+
estimate: () => measured ? estimateAppendedWireTokens({
|
|
17156
|
+
messages: measured.appendedMessages,
|
|
17157
|
+
providerID: args.model?.providerID,
|
|
17158
|
+
modelID: args.model?.modelID
|
|
17159
|
+
}) : estimator({
|
|
17160
|
+
messages: args.messages,
|
|
17161
|
+
systemPromptTokens: args.systemPromptTokens,
|
|
17162
|
+
providerID: args.model?.providerID,
|
|
17163
|
+
modelID: args.model?.modelID,
|
|
17164
|
+
agentName: args.agentName
|
|
17165
|
+
})
|
|
16835
17166
|
});
|
|
16836
|
-
|
|
16837
|
-
|
|
16838
|
-
|
|
16839
|
-
|
|
16840
|
-
|
|
16841
|
-
}
|
|
17167
|
+
}
|
|
17168
|
+
function lkgReplayFits(args) {
|
|
17169
|
+
let limit;
|
|
17170
|
+
try {
|
|
17171
|
+
limit = lkgReplayLimit(args);
|
|
17172
|
+
} catch {
|
|
17173
|
+
return { fits: false, detail: null };
|
|
17174
|
+
}
|
|
17175
|
+
if (limit === undefined)
|
|
17176
|
+
return { fits: false, detail: null };
|
|
17177
|
+
const measure = measureLkgReplayRequest({ ...args, limit });
|
|
17178
|
+
if (measure.fit === "under")
|
|
17179
|
+
return { fits: true };
|
|
17180
|
+
return {
|
|
17181
|
+
fits: false,
|
|
17182
|
+
detail: measure.fit === "over" ? `lkg_over_context_limit estimated=${measure.tokens ?? "skipped"} proxy_tokens=${measure.proxyTokens ?? "unavailable"} limit=${limit}` : `lkg_fit_untrusted estimated=${measure.tokens ?? "unavailable"} limit=${limit}`
|
|
17183
|
+
};
|
|
16842
17184
|
}
|
|
16843
17185
|
|
|
16844
17186
|
// src/hooks/magic-context/storage-busy-refusal.ts
|
|
@@ -17967,10 +18309,10 @@ function createPassOutcome() {
|
|
|
17967
18309
|
finalized = true;
|
|
17968
18310
|
},
|
|
17969
18311
|
get captureEligible() {
|
|
17970
|
-
return finalized && degradations.
|
|
18312
|
+
return finalized && degradations.every((item) => item.kind !== "fatal" && item.site === "auto-search-timeout");
|
|
17971
18313
|
},
|
|
17972
18314
|
isCaptureEligible() {
|
|
17973
|
-
return finalized && degradations.
|
|
18315
|
+
return finalized && degradations.every((item) => item.kind !== "fatal" && item.site === "auto-search-timeout");
|
|
17974
18316
|
}
|
|
17975
18317
|
};
|
|
17976
18318
|
}
|
|
@@ -18559,91 +18901,6 @@ function createHistorianHostRunner(args) {
|
|
|
18559
18901
|
});
|
|
18560
18902
|
}
|
|
18561
18903
|
|
|
18562
|
-
// src/hooks/magic-context/lkg-replay-fit.ts
|
|
18563
|
-
var RAW_FALLBACK_BYTES_PER_CONTEXT_TOKEN = 4;
|
|
18564
|
-
function lkgReplayLimit(args) {
|
|
18565
|
-
const { db, sessionId, model } = args;
|
|
18566
|
-
const trusted = model ? resolveTrustedContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : undefined;
|
|
18567
|
-
if (trusted !== undefined && trusted > 0)
|
|
18568
|
-
return trusted;
|
|
18569
|
-
const detected = getOverflowState(db, sessionId, args.modelKey).detectedContextLimit;
|
|
18570
|
-
return detected > 0 ? detected : undefined;
|
|
18571
|
-
}
|
|
18572
|
-
function measureLkgReplay(args) {
|
|
18573
|
-
const baseline = args.measuredInputTokens ?? 0;
|
|
18574
|
-
const tailLimit = Math.max(0, args.limit - baseline);
|
|
18575
|
-
const proxy = wireContentBytes(args.messages, tailLimit * RAW_FALLBACK_BYTES_PER_CONTEXT_TOKEN, RAW_FALLBACK_BYTES_PER_CONTEXT_TOKEN);
|
|
18576
|
-
const skipped = { proxy, estimatorRan: false, trusted: false };
|
|
18577
|
-
if (proxy === null)
|
|
18578
|
-
return { fit: "unproven", tokens: null, ...skipped };
|
|
18579
|
-
const proxyTokens = baseline + Math.ceil(proxy.bytes / RAW_FALLBACK_BYTES_PER_CONTEXT_TOKEN);
|
|
18580
|
-
if (proxy.aborted || proxyTokens > args.limit) {
|
|
18581
|
-
return { fit: "over", tokens: null, proxyTokens, ...skipped };
|
|
18582
|
-
}
|
|
18583
|
-
let estimate;
|
|
18584
|
-
try {
|
|
18585
|
-
estimate = args.estimate();
|
|
18586
|
-
} catch {
|
|
18587
|
-
return { fit: "unproven", tokens: null, ...skipped };
|
|
18588
|
-
}
|
|
18589
|
-
const seen = { proxy, estimatorRan: true, trusted: estimate.trusted };
|
|
18590
|
-
const tokens = baseline + estimate.tokens;
|
|
18591
|
-
if (!estimate.trusted || !Number.isFinite(tokens) || tokens <= 0 || estimate.tokens < 0) {
|
|
18592
|
-
return {
|
|
18593
|
-
fit: "unproven",
|
|
18594
|
-
tokens: Number.isFinite(estimate.tokens) ? estimate.tokens : null,
|
|
18595
|
-
...seen
|
|
18596
|
-
};
|
|
18597
|
-
}
|
|
18598
|
-
return tokens > args.limit ? { fit: "over", tokens, proxyTokens, ...seen } : { fit: "under", tokens, ...seen };
|
|
18599
|
-
}
|
|
18600
|
-
function measureLkgReplayRequest(args) {
|
|
18601
|
-
let measured;
|
|
18602
|
-
try {
|
|
18603
|
-
measured = args.model ? measuredLkgPrefix({
|
|
18604
|
-
...args,
|
|
18605
|
-
slot: getSlot(args.sessionId),
|
|
18606
|
-
modelKey: `${args.model.providerID}/${args.model.modelID}`
|
|
18607
|
-
}) : undefined;
|
|
18608
|
-
} catch {
|
|
18609
|
-
measured = undefined;
|
|
18610
|
-
}
|
|
18611
|
-
const estimator = args.estimator ?? estimateFinalWireInputTokens;
|
|
18612
|
-
return measureLkgReplay({
|
|
18613
|
-
messages: measured?.appendedMessages ?? args.messages,
|
|
18614
|
-
limit: args.limit,
|
|
18615
|
-
measuredInputTokens: measured?.inputTokens,
|
|
18616
|
-
estimate: () => measured ? estimateAppendedWireTokens({
|
|
18617
|
-
messages: measured.appendedMessages,
|
|
18618
|
-
providerID: args.model?.providerID,
|
|
18619
|
-
modelID: args.model?.modelID
|
|
18620
|
-
}) : estimator({
|
|
18621
|
-
messages: args.messages,
|
|
18622
|
-
systemPromptTokens: args.systemPromptTokens,
|
|
18623
|
-
providerID: args.model?.providerID,
|
|
18624
|
-
modelID: args.model?.modelID,
|
|
18625
|
-
agentName: args.agentName
|
|
18626
|
-
})
|
|
18627
|
-
});
|
|
18628
|
-
}
|
|
18629
|
-
function lkgReplayFits(args) {
|
|
18630
|
-
let limit;
|
|
18631
|
-
try {
|
|
18632
|
-
limit = lkgReplayLimit(args);
|
|
18633
|
-
} catch {
|
|
18634
|
-
return { fits: false, detail: null };
|
|
18635
|
-
}
|
|
18636
|
-
if (limit === undefined)
|
|
18637
|
-
return { fits: false, detail: null };
|
|
18638
|
-
const measure = measureLkgReplayRequest({ ...args, limit });
|
|
18639
|
-
if (measure.fit === "under")
|
|
18640
|
-
return { fits: true };
|
|
18641
|
-
return {
|
|
18642
|
-
fits: false,
|
|
18643
|
-
detail: measure.fit === "over" ? `lkg_over_context_limit estimated=${measure.tokens ?? "skipped"} proxy_tokens=${measure.proxyTokens ?? "unavailable"} limit=${limit}` : `lkg_fit_untrusted estimated=${measure.tokens ?? "unavailable"} limit=${limit}`
|
|
18644
|
-
};
|
|
18645
|
-
}
|
|
18646
|
-
|
|
18647
18904
|
// src/hooks/magic-context/module-state-sync.ts
|
|
18648
18905
|
import { createHmac, randomUUID as randomUUID4 } from "node:crypto";
|
|
18649
18906
|
|
|
@@ -19275,6 +19532,73 @@ function moduleRawBlockMappings(message) {
|
|
|
19275
19532
|
}
|
|
19276
19533
|
return mappings;
|
|
19277
19534
|
}
|
|
19535
|
+
function moduleToolOutput(part, state, text) {
|
|
19536
|
+
const attachments = state.attachments ?? part.attachments;
|
|
19537
|
+
const error = state.status === "error";
|
|
19538
|
+
if (!Array.isArray(attachments) || attachments.length === 0) {
|
|
19539
|
+
return { kind: { type: error ? "error_text" : "text", text } };
|
|
19540
|
+
}
|
|
19541
|
+
const blocks = [{ kind: { type: "text", text } }];
|
|
19542
|
+
for (const attachment of attachments) {
|
|
19543
|
+
const child = attachment !== null && typeof attachment === "object" ? attachment : {};
|
|
19544
|
+
const string = (key) => typeof child[key] === "string" ? child[key] : undefined;
|
|
19545
|
+
const mime = string("mime") ?? string("mimeType");
|
|
19546
|
+
const data = string("data");
|
|
19547
|
+
const url = string("url");
|
|
19548
|
+
let kind;
|
|
19549
|
+
if (child.type === "text" && typeof child.text === "string") {
|
|
19550
|
+
kind = { type: "text", text: child.text };
|
|
19551
|
+
} else if (mime !== undefined && (data !== undefined || url !== undefined)) {
|
|
19552
|
+
const prefix = `data:${mime};base64,`;
|
|
19553
|
+
const nativeUrl = url ?? "";
|
|
19554
|
+
const source = data !== undefined ? { type: "data_base64", data } : nativeUrl.startsWith(prefix) ? { type: "data_base64", data: nativeUrl.slice(prefix.length) } : { type: "url", url };
|
|
19555
|
+
const filename = string("filename") ?? string("name");
|
|
19556
|
+
kind = {
|
|
19557
|
+
type: "media",
|
|
19558
|
+
media: {
|
|
19559
|
+
kind: mime.startsWith("image/") ? "image" : mime.startsWith("audio/") ? "audio" : mime.startsWith("video/") ? "video" : mime === "application/pdf" ? "document" : "file",
|
|
19560
|
+
media_type: mime,
|
|
19561
|
+
...filename !== undefined ? { filename } : {},
|
|
19562
|
+
source
|
|
19563
|
+
}
|
|
19564
|
+
};
|
|
19565
|
+
} else {
|
|
19566
|
+
kind = {
|
|
19567
|
+
type: "opaque",
|
|
19568
|
+
opaque: {
|
|
19569
|
+
source: { type: "harness", harness: "opencode" },
|
|
19570
|
+
kind: string("type") ?? "attachment",
|
|
19571
|
+
raw: attachment
|
|
19572
|
+
}
|
|
19573
|
+
};
|
|
19574
|
+
}
|
|
19575
|
+
const rawAttachment = { ...child };
|
|
19576
|
+
const sourceFields = [];
|
|
19577
|
+
if (kind.type === "media") {
|
|
19578
|
+
const media = kind.media;
|
|
19579
|
+
const derivedUrl = media.source.type === "data_base64" ? `data:${mime};base64,${media.source.data}` : media.source.url;
|
|
19580
|
+
for (const [field, derived] of [
|
|
19581
|
+
["url", derivedUrl],
|
|
19582
|
+
["data", media.source.data]
|
|
19583
|
+
]) {
|
|
19584
|
+
if (child[field] !== undefined && child[field] === derived) {
|
|
19585
|
+
delete rawAttachment[field];
|
|
19586
|
+
sourceFields.push(field);
|
|
19587
|
+
}
|
|
19588
|
+
}
|
|
19589
|
+
}
|
|
19590
|
+
blocks.push(kind.type === "opaque" ? { kind } : {
|
|
19591
|
+
kind,
|
|
19592
|
+
provider_extras: {
|
|
19593
|
+
opencode: {
|
|
19594
|
+
rawAttachment,
|
|
19595
|
+
...sourceFields.length ? { rawAttachmentSourceFields: sourceFields } : {}
|
|
19596
|
+
}
|
|
19597
|
+
}
|
|
19598
|
+
});
|
|
19599
|
+
}
|
|
19600
|
+
return { kind: { type: error ? "error_content" : "content", blocks } };
|
|
19601
|
+
}
|
|
19278
19602
|
function encodeOpenCodeMessagesToCk(messages) {
|
|
19279
19603
|
return messages.map((message, index) => {
|
|
19280
19604
|
const raw = message !== null && typeof message === "object" ? message : {};
|
|
@@ -19345,12 +19669,7 @@ function encodeOpenCodeMessagesToCk(messages) {
|
|
|
19345
19669
|
type: "tool_result",
|
|
19346
19670
|
id: callId,
|
|
19347
19671
|
tool_name: toolName,
|
|
19348
|
-
output:
|
|
19349
|
-
kind: {
|
|
19350
|
-
type: state.status === "error" ? "error_text" : "text",
|
|
19351
|
-
text: output
|
|
19352
|
-
}
|
|
19353
|
-
}
|
|
19672
|
+
output: moduleToolOutput(part, state, output)
|
|
19354
19673
|
}
|
|
19355
19674
|
});
|
|
19356
19675
|
}
|
|
@@ -21231,7 +21550,7 @@ function buildTransformBody(args) {
|
|
|
21231
21550
|
historian_model_limits: args.passInputs.historian_model_limits,
|
|
21232
21551
|
historian_model_variants: args.passInputs.historian_model_variants,
|
|
21233
21552
|
historian_timeout_ms: args.passInputs.historian_timeout_ms,
|
|
21234
|
-
|
|
21553
|
+
keep_reasoning_tokens_effective: args.passInputs.keep_reasoning_tokens_effective,
|
|
21235
21554
|
caveman_enabled: args.passInputs.caveman_enabled === true,
|
|
21236
21555
|
caveman_min_chars: args.passInputs.caveman_min_chars ?? 500,
|
|
21237
21556
|
cache_ttl: args.passInputs.cache_ttl,
|
|
@@ -21751,6 +22070,15 @@ function createRustModeTransform(deps, options) {
|
|
|
21751
22070
|
sessionLog(sessionId, "RUST LOOP BREAKER: suppressing host directives after three consecutive synthetic turns until a real user message arrives");
|
|
21752
22071
|
}
|
|
21753
22072
|
const inputCount = messages.length;
|
|
22073
|
+
const inputHasActiveThinking = hasActiveAnthropicThinkingTurn(messages, "anthropic");
|
|
22074
|
+
const thinkingRecovery = prepareLatestThinkingRecovery({
|
|
22075
|
+
db: deps.db,
|
|
22076
|
+
sessionId,
|
|
22077
|
+
messages,
|
|
22078
|
+
id: (message) => message?.info.id,
|
|
22079
|
+
parts: (message) => message?.parts ?? []
|
|
22080
|
+
});
|
|
22081
|
+
const restoreLatestTurnOriginals = thinkingRecovery.restore ? captureLatestTurnOriginals(messages) : undefined;
|
|
21754
22082
|
let requestInputTokens = 0;
|
|
21755
22083
|
let decision = "error";
|
|
21756
22084
|
let materializeReason = "none";
|
|
@@ -22176,7 +22504,7 @@ function createRustModeTransform(deps, options) {
|
|
|
22176
22504
|
historian_model_chain: historianChain,
|
|
22177
22505
|
historian_model_variants: resolvedHistorianModelVariants(historianModels),
|
|
22178
22506
|
historian_timeout_ms: historianRun?.timeoutMs ?? deps.historianTimeoutMs ?? DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
22179
|
-
|
|
22507
|
+
keep_reasoning_tokens_effective: resolveKeepReasoningTokens(deps.keepReasoningTokens, modelKey ?? undefined),
|
|
22180
22508
|
caveman_enabled: !sessionMeta.isSubagent && deps.cavemanTextCompression?.enabled === true,
|
|
22181
22509
|
caveman_min_chars: deps.cavemanTextCompression?.minChars ?? 500,
|
|
22182
22510
|
cache_ttl: sessionMeta.cacheTtl,
|
|
@@ -22829,7 +23157,12 @@ function createRustModeTransform(deps, options) {
|
|
|
22829
23157
|
throw error;
|
|
22830
23158
|
}
|
|
22831
23159
|
}
|
|
23160
|
+
const protectedThinkingMessages = latestAssistantTurnMessages(appliedMessages);
|
|
23161
|
+
const activeThinkingTurn = inputHasActiveThinking && isAnthropicFamilyRoute(model?.providerID, model?.modelID);
|
|
22832
23162
|
const postprocess = runRustModePostprocess2({
|
|
23163
|
+
activeThinkingTurn,
|
|
23164
|
+
protectedThinkingMessages: thinkingRecovery.restore ? protectedThinkingMessages : undefined,
|
|
23165
|
+
restoreLatestTurnOriginals: () => restoreLatestTurnOriginals?.(appliedMessages),
|
|
22833
23166
|
db: deps.db,
|
|
22834
23167
|
sessionId,
|
|
22835
23168
|
messages: appliedMessages,
|
|
@@ -23089,6 +23422,7 @@ function createRustModeTransform(deps, options) {
|
|
|
23089
23422
|
agentName: deps.getNotificationParams?.(sessionId)?.agent,
|
|
23090
23423
|
systemPromptHash: sessionMeta.systemPromptHash
|
|
23091
23424
|
});
|
|
23425
|
+
captureOpencodeReasoningBudgetStatus(sessionId, output.messages, resolveKeepReasoningTokens(deps.keepReasoningTokens, modelKey ?? undefined), isPrefixBoundThinkingModel(model?.providerID, model?.modelID));
|
|
23092
23426
|
finishPass(true);
|
|
23093
23427
|
if (state.markerAdmissionFenced) {
|
|
23094
23428
|
setRustMarkerAdmissionFence(deps.db, sessionId, false);
|
|
@@ -23371,8 +23705,24 @@ function historianJoinFailClosedMessage(input) {
|
|
|
23371
23705
|
return `historian did not complete within ${seconds} s: ${reason}`;
|
|
23372
23706
|
}
|
|
23373
23707
|
function runCompartmentPhase(args) {
|
|
23708
|
+
if (args.historianRunnable !== false && !args.compactionOff && args.canRunCompartments && !getActiveCompartmentRun(args.sessionId) && (args.sessionMeta.compartmentInProgress || args.contextUsage.percentage >= BLOCK_UNTIL_DONE_PERCENTAGE) && isHistorianDrainBudgetSpent({
|
|
23709
|
+
db: args.db,
|
|
23710
|
+
sessionId: args.sessionId,
|
|
23711
|
+
contextLimit: args.boundaryContextLimit,
|
|
23712
|
+
executeThresholdPercentage: args.boundaryExecuteThresholdPercentage,
|
|
23713
|
+
usagePercentage: args.boundaryUsage.percentage
|
|
23714
|
+
})) {
|
|
23715
|
+
if (args.sessionMeta.compartmentInProgress) {
|
|
23716
|
+
updateSessionMeta(args.db, args.sessionId, { compartmentInProgress: false });
|
|
23717
|
+
}
|
|
23718
|
+
return runCompartmentPhaseImpl({
|
|
23719
|
+
...args,
|
|
23720
|
+
canRunCompartments: false,
|
|
23721
|
+
sessionMeta: { compartmentInProgress: false }
|
|
23722
|
+
});
|
|
23723
|
+
}
|
|
23374
23724
|
const historianRunnable = args.historianRunnable !== false;
|
|
23375
|
-
const willReadRawHistory = historianRunnable && !args.compactionOff && args.canRunCompartments && getActiveCompartmentRun(args.sessionId) === undefined &&
|
|
23725
|
+
const willReadRawHistory = historianRunnable && !args.compactionOff && args.canRunCompartments && getActiveCompartmentRun(args.sessionId) === undefined && args.contextUsage.percentage >= BLOCK_UNTIL_DONE_PERCENTAGE;
|
|
23376
23726
|
if (!willReadRawHistory) {
|
|
23377
23727
|
return runCompartmentPhaseImpl(args);
|
|
23378
23728
|
}
|
|
@@ -23498,7 +23848,7 @@ async function runCompartmentPhaseImpl(args) {
|
|
|
23498
23848
|
compartmentInProgress = false;
|
|
23499
23849
|
}
|
|
23500
23850
|
if (historianRunnable && args.canRunCompartments && args.sessionMeta.compartmentInProgress && !getActiveCompartmentRun(args.sessionId)) {
|
|
23501
|
-
if (!hasEligibleHistoryForCompartment()) {
|
|
23851
|
+
if (args.contextUsage.percentage >= BLOCK_UNTIL_DONE_PERCENTAGE && !hasEligibleHistoryForCompartment()) {
|
|
23502
23852
|
sessionLog(args.sessionId, `transform: skipping compartment start, no eligible history before protected tail (beyond ${lastObservedCompartmentEnd})`);
|
|
23503
23853
|
updateSessionMeta(args.db, args.sessionId, { compartmentInProgress: false });
|
|
23504
23854
|
compartmentInProgress = false;
|
|
@@ -23515,7 +23865,7 @@ async function runCompartmentPhaseImpl(args) {
|
|
|
23515
23865
|
db: args.db,
|
|
23516
23866
|
sessionId: args.sessionId,
|
|
23517
23867
|
historianChunkTokens: args.historianChunkTokens,
|
|
23518
|
-
boundarySnapshot:
|
|
23868
|
+
boundarySnapshot: args.preResolvedBoundarySnapshot,
|
|
23519
23869
|
currentContextLimit: args.boundaryContextLimit,
|
|
23520
23870
|
historyBudgetTokens: args.historyBudgetTokens,
|
|
23521
23871
|
historianTimeoutMs: args.historianTimeoutMs,
|
|
@@ -23534,6 +23884,12 @@ async function runCompartmentPhaseImpl(args) {
|
|
|
23534
23884
|
autoPromote: args.autoPromote,
|
|
23535
23885
|
onCompartmentStatePublished: args.onCompartmentStatePublished,
|
|
23536
23886
|
preserveInjectionCacheUntilConsumed: true
|
|
23887
|
+
}, undefined, () => {
|
|
23888
|
+
const snapshot = getBoundarySnapshotForCompartment();
|
|
23889
|
+
if (snapshot && hasRunnableCompartmentWindow(snapshot))
|
|
23890
|
+
return snapshot;
|
|
23891
|
+
sessionLog(args.sessionId, `transform: skipping compartment start, no eligible history before protected tail (beyond ${lastObservedCompartmentEnd})`);
|
|
23892
|
+
return null;
|
|
23537
23893
|
});
|
|
23538
23894
|
compartmentInProgress = true;
|
|
23539
23895
|
}
|
|
@@ -23888,7 +24244,19 @@ function createTransform(deps) {
|
|
|
23888
24244
|
sessionDirectoryFellBack = true;
|
|
23889
24245
|
}
|
|
23890
24246
|
}
|
|
23891
|
-
const
|
|
24247
|
+
const activeThinkingModel = findLastAssistantModel(messages) ?? deps.liveModelBySession?.get(sessionId);
|
|
24248
|
+
const thinkingRecovery = prepareLatestThinkingRecovery({
|
|
24249
|
+
db,
|
|
24250
|
+
sessionId,
|
|
24251
|
+
messages,
|
|
24252
|
+
id: (message) => message?.info.id,
|
|
24253
|
+
parts: (message) => message?.parts ?? []
|
|
24254
|
+
});
|
|
24255
|
+
if (thinkingRecovery.ended)
|
|
24256
|
+
deps.pendingMaterializationSessions?.add(sessionId);
|
|
24257
|
+
let restoreLatestTurnOriginals;
|
|
24258
|
+
let activeThinkingTurn = hasActiveAnthropicThinkingTurn(messages, activeThinkingModel?.providerID, activeThinkingModel?.modelID);
|
|
24259
|
+
let freezeM0M1 = activeThinkingTurn && isPrefixBoundThinkingModel(activeThinkingModel?.providerID, activeThinkingModel?.modelID) || sessionDirectoryFellBack && sessionMeta.cachedM0Bytes != null && sessionMeta.cachedM1Bytes != null && (() => {
|
|
23892
24260
|
try {
|
|
23893
24261
|
return hasRecordedSessionProjectIdentity(db, sessionId);
|
|
23894
24262
|
} catch {
|
|
@@ -24018,7 +24386,10 @@ function createTransform(deps) {
|
|
|
24018
24386
|
}
|
|
24019
24387
|
}
|
|
24020
24388
|
const resolvedProviderID = modelForBudget?.providerID;
|
|
24389
|
+
activeThinkingTurn ||= hasActiveAnthropicThinkingTurn(messages, resolvedProviderID, modelForBudget?.modelID);
|
|
24390
|
+
freezeM0M1 ||= activeThinkingTurn && isPrefixBoundThinkingModel(resolvedProviderID, modelForBudget?.modelID);
|
|
24021
24391
|
const canUseEmptySentinels = modelAcceptsEmptyContent(resolvedProviderID);
|
|
24392
|
+
const protectedThinkingMessages = activeThinkingTurn || isAnthropicFamilyRoute(resolvedProviderID, modelForBudget?.modelID) ? latestAssistantTurnMessages(messages) : new Set;
|
|
24022
24393
|
const resolvedContextLimit = modelForBudget ? resolveTrustedContextLimit(modelForBudget.providerID, modelForBudget.modelID, {
|
|
24023
24394
|
db,
|
|
24024
24395
|
sessionID: sessionId
|
|
@@ -24128,19 +24499,33 @@ function createTransform(deps) {
|
|
|
24128
24499
|
if (false) {}
|
|
24129
24500
|
return false;
|
|
24130
24501
|
};
|
|
24131
|
-
const startRecoveryRun = () => {
|
|
24132
|
-
|
|
24133
|
-
|
|
24134
|
-
|
|
24135
|
-
|
|
24136
|
-
|
|
24137
|
-
|
|
24138
|
-
|
|
24502
|
+
const startRecoveryRun = (onReady) => {
|
|
24503
|
+
if (isHistorianDrainBudgetSpent({
|
|
24504
|
+
db,
|
|
24505
|
+
sessionId,
|
|
24506
|
+
contextLimit: boundaryContextLimit,
|
|
24507
|
+
executeThresholdPercentage: boundaryExecuteThreshold,
|
|
24508
|
+
usagePercentage: boundaryUsageForProtectedTail.percentage
|
|
24509
|
+
}))
|
|
24139
24510
|
return false;
|
|
24140
|
-
|
|
24141
|
-
|
|
24511
|
+
if (!canRunCompartments || !deps.client && !deps.hiddenCompletionExecutor || getActiveCompartmentRun(sessionId))
|
|
24512
|
+
return false;
|
|
24513
|
+
const prepareRecoveryBoundary = () => {
|
|
24514
|
+
const scale = emergencyUsagePercentageEarly >= 95 ? 0.25 : 0.5;
|
|
24515
|
+
let boundarySnapshot = getRunnableBoundaryForCompartment();
|
|
24516
|
+
if (!boundarySnapshot || !hasRunnableCompartmentWindow(boundarySnapshot)) {
|
|
24517
|
+
boundarySnapshot = getRunnableBoundaryForCompartment(scale);
|
|
24518
|
+
}
|
|
24519
|
+
if (false) {}
|
|
24520
|
+
if (!boundarySnapshot || !hasRunnableCompartmentWindow(boundarySnapshot))
|
|
24521
|
+
return null;
|
|
24522
|
+
onReady?.();
|
|
24523
|
+
return boundarySnapshot;
|
|
24524
|
+
};
|
|
24525
|
+
const urgent = emergencyUsagePercentageEarly >= 95;
|
|
24526
|
+
const boundarySnapshot = urgent ? prepareRecoveryBoundary() : undefined;
|
|
24527
|
+
if (urgent && !boundarySnapshot)
|
|
24142
24528
|
return false;
|
|
24143
|
-
}
|
|
24144
24529
|
updateSessionMeta(db, sessionId, { compartmentInProgress: true });
|
|
24145
24530
|
startCompartmentAgent({
|
|
24146
24531
|
client: deps.client,
|
|
@@ -24149,7 +24534,7 @@ function createTransform(deps) {
|
|
|
24149
24534
|
db,
|
|
24150
24535
|
sessionId,
|
|
24151
24536
|
historianChunkTokens: historianRun?.chunkTokens ?? deps.getHistorianChunkTokens?.() ?? 20000,
|
|
24152
|
-
boundarySnapshot,
|
|
24537
|
+
boundarySnapshot: boundarySnapshot ?? undefined,
|
|
24153
24538
|
currentContextLimit: boundaryContextLimit,
|
|
24154
24539
|
historyBudgetTokens,
|
|
24155
24540
|
historianTimeoutMs: historianRun?.timeoutMs ?? deps.historianTimeoutMs,
|
|
@@ -24170,7 +24555,7 @@ function createTransform(deps) {
|
|
|
24170
24555
|
deferredHistoryRefreshSessions.add(sid);
|
|
24171
24556
|
deferredMaterializationSessions.add(sid);
|
|
24172
24557
|
}
|
|
24173
|
-
});
|
|
24558
|
+
}, undefined, urgent ? undefined : prepareRecoveryBoundary);
|
|
24174
24559
|
return true;
|
|
24175
24560
|
};
|
|
24176
24561
|
if (fullFeatureMode && !compactionOff && historianFailureState.failureCount > 0 && emergencyUsagePercentageEarly >= 95 && !recoveryNoHeadEscapeActive) {
|
|
@@ -24184,13 +24569,15 @@ function createTransform(deps) {
|
|
|
24184
24569
|
sessionLog(sessionId, "transform: emergency recovery remains armed — no complete eligible head before protected tail");
|
|
24185
24570
|
}
|
|
24186
24571
|
sessionLog(sessionId, `EMERGENCY: historian recovery requested at ${emergencyPercentage}%, failures: ${historianFailureState.failureCount}`);
|
|
24187
|
-
} else if (fullFeatureMode && !compactionOff && isFirstTransformPassForSession && historianFailureState.failureCount > 0
|
|
24188
|
-
|
|
24189
|
-
|
|
24190
|
-
|
|
24572
|
+
} else if (fullFeatureMode && !compactionOff && isFirstTransformPassForSession && historianFailureState.failureCount > 0) {
|
|
24573
|
+
startRecoveryRun(() => {
|
|
24574
|
+
sessionLog(sessionId, `transform: historian recovery triggered on session load after ${historianFailureState.failureCount} failure(s)`);
|
|
24575
|
+
if (deps.client) {
|
|
24576
|
+
withoutSqliteTransformPass(() => sendStatusNotification2(deps.client, sessionId, `## Historian recovery
|
|
24191
24577
|
|
|
24192
24578
|
Historian previously failed ${historianFailureState.failureCount} time(s), so Magic Context is retrying history comparting immediately after restart.`, notificationParams));
|
|
24193
|
-
|
|
24579
|
+
}
|
|
24580
|
+
});
|
|
24194
24581
|
}
|
|
24195
24582
|
logTransformTiming(sessionId, "emergencyRecoveryBlock", tFirstPass);
|
|
24196
24583
|
const memoryProjectDirectory = compartmentDirectory || process.cwd();
|
|
@@ -24218,7 +24605,10 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24218
24605
|
const tTrigger = performance.now();
|
|
24219
24606
|
try {
|
|
24220
24607
|
const inMemoryTail = buildTriggerInMemoryTail(db, sessionId, extractInMemoryMessageViews(messages));
|
|
24221
|
-
const triggerResult = checkCompartmentTrigger(db, sessionId, sessionMeta, boundaryUsageForProtectedTail, sessionMeta.lastContextPercentage, boundaryExecuteThreshold, deriveTriggerBudget2(boundaryContextLimit, boundaryExecuteThreshold), deps.
|
|
24608
|
+
const triggerResult = checkCompartmentTrigger(db, sessionId, sessionMeta, boundaryUsageForProtectedTail, sessionMeta.lastContextPercentage, boundaryExecuteThreshold, deriveTriggerBudget2(boundaryContextLimit, boundaryExecuteThreshold), resolveKeepReasoningTokens(deps.keepReasoningTokens, currentModelKeyForBoundary), historianRun?.commitClusterTrigger ?? deps.commitClusterTrigger, undefined, boundaryContextLimit, inMemoryTail, taggerFloor, {
|
|
24609
|
+
providerID: resolvedProviderID,
|
|
24610
|
+
budgetCutoff: projectOpencodeReasoningBudgetCutoff(db, sessionId, messages, resolveKeepReasoningTokens(deps.keepReasoningTokens, currentModelKeyForBoundary), sessionMeta.clearedReasoningThroughTag, sessionDecisionCalibration(db, sessionId).proseRatio)
|
|
24611
|
+
}, {
|
|
24222
24612
|
hardFold: false,
|
|
24223
24613
|
force: contextUsageEarly.percentage >= forceMaterializationPercentage && (contextUsageEarly.percentage >= 95 || getEmergencyInputSample(db, sessionId) === 0),
|
|
24224
24614
|
explicitFlush: deps.pendingMaterializationSessions.has(sessionId),
|
|
@@ -24289,6 +24679,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24289
24679
|
servedMessages: messages
|
|
24290
24680
|
});
|
|
24291
24681
|
targets = result.targets;
|
|
24682
|
+
if (thinkingRecovery.restore)
|
|
24683
|
+
restoreLatestTurnOriginals = captureLatestTurnOriginals(messages);
|
|
24292
24684
|
reasoningByMessage = result.reasoningByMessage;
|
|
24293
24685
|
messageTagNumbers = result.messageTagNumbers;
|
|
24294
24686
|
batch = result.batch;
|
|
@@ -24549,7 +24941,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24549
24941
|
deferredHistoryRefreshSessions,
|
|
24550
24942
|
deferredMaterializationSessions,
|
|
24551
24943
|
lastHeuristicsTurnId: deps.lastHeuristicsTurnId,
|
|
24552
|
-
|
|
24944
|
+
keepReasoningTokens: resolveKeepReasoningTokens(deps.keepReasoningTokens, currentModelKeyForBoundary),
|
|
24553
24945
|
protectedTagIds,
|
|
24554
24946
|
protectedTagNumbers,
|
|
24555
24947
|
protectedCutoff,
|
|
@@ -24570,6 +24962,11 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24570
24962
|
smartDrops: deps.smartDrops === true,
|
|
24571
24963
|
protectedTools: deps.protectedTools,
|
|
24572
24964
|
resolvedProviderID,
|
|
24965
|
+
activeThinkingTurn,
|
|
24966
|
+
protectedThinkingMessages: thinkingRecovery.restore ? protectedThinkingMessages : undefined,
|
|
24967
|
+
restoreThinkingMessageIds: thinkingRecovery.restore ? new Set([...protectedThinkingMessages].flatMap((message) => typeof message.info.id === "string" ? [message.info.id] : [])) : undefined,
|
|
24968
|
+
restoreLatestTurnOriginals,
|
|
24969
|
+
resolvedModelID: modelForBudget?.modelID,
|
|
24573
24970
|
thinkingBindingRecoveryEnabledForModel: isPrefixBoundThinkingModel(modelForBudget?.providerID, modelForBudget?.modelID),
|
|
24574
24971
|
trailingBlankSourceDecisions,
|
|
24575
24972
|
passOutcome,
|
|
@@ -25225,6 +25622,102 @@ function preserveUserTerminatedTail(messages, inputMessages) {
|
|
|
25225
25622
|
}
|
|
25226
25623
|
moveUserToTail(messages, userIndex >= 0 ? messages[userIndex] : inputTail, userIndex);
|
|
25227
25624
|
}
|
|
25625
|
+
|
|
25626
|
+
class LkgAdmissionReplay extends Error {
|
|
25627
|
+
}
|
|
25628
|
+
function tryMessagesTransformLkgReplay(args) {
|
|
25629
|
+
const { output, sessionId, error, agent } = args;
|
|
25630
|
+
const slotAtEntry = getSlot(sessionId);
|
|
25631
|
+
let entry = args.entry;
|
|
25632
|
+
if (entry === undefined && slotAtEntry) {
|
|
25633
|
+
try {
|
|
25634
|
+
entry = noteEntry(sessionId, output.messages);
|
|
25635
|
+
} catch {
|
|
25636
|
+
entry = null;
|
|
25637
|
+
}
|
|
25638
|
+
}
|
|
25639
|
+
if (sessionId && slotAtEntry && !entry) {
|
|
25640
|
+
dropSlot(sessionId, "lkg_invalidated_reshape");
|
|
25641
|
+
sessionLog(sessionId, "lkg_invalidated_reshape");
|
|
25642
|
+
} else if (sessionId && entry) {
|
|
25643
|
+
let replayBlocked = false;
|
|
25644
|
+
try {
|
|
25645
|
+
const db = openDatabase();
|
|
25646
|
+
const rust = args.rust;
|
|
25647
|
+
if (error instanceof StorageBusyRefusalError && error.stage === "rust-mode-emergency" || rust?.emergencyFailClosed(sessionId, output.messages)) {
|
|
25648
|
+
replayBlocked = true;
|
|
25649
|
+
sessionLog(sessionId, "lkg_emergency_band_refused");
|
|
25650
|
+
} else if (!db || isEmergencyRecoveryArmed(sessionId) || getOverflowState(db, sessionId).needsEmergencyRecovery) {
|
|
25651
|
+
replayBlocked = true;
|
|
25652
|
+
sessionLog(sessionId, "lkg_emergency_armed");
|
|
25653
|
+
} else {
|
|
25654
|
+
const inputMessages = output.messages;
|
|
25655
|
+
const inputCount = inputMessages.length;
|
|
25656
|
+
const keys = resolveLkgModelKeys(inputMessages);
|
|
25657
|
+
const replay = replayLkg({
|
|
25658
|
+
sessionId,
|
|
25659
|
+
messages: inputMessages,
|
|
25660
|
+
modelKey: keys.modelKey,
|
|
25661
|
+
providerKey: keys.providerKey,
|
|
25662
|
+
entry,
|
|
25663
|
+
prepareReplay: (messages) => rust ? rust.stripPersistedReasoning(sessionId, messages, inputMessages) : replayRustModeBindingMismatchStrips2({
|
|
25664
|
+
db,
|
|
25665
|
+
sessionId,
|
|
25666
|
+
messages,
|
|
25667
|
+
resolvedProviderID: keys.providerKey ?? undefined
|
|
25668
|
+
})
|
|
25669
|
+
});
|
|
25670
|
+
let tsFit = true;
|
|
25671
|
+
if (replay.ok && !rust && keys.providerKey && keys.modelKey) {
|
|
25672
|
+
const model = {
|
|
25673
|
+
providerID: keys.providerKey,
|
|
25674
|
+
modelID: keys.modelKey.slice(keys.providerKey.length + 1)
|
|
25675
|
+
};
|
|
25676
|
+
if (lkgReplayLimit({
|
|
25677
|
+
db,
|
|
25678
|
+
sessionId,
|
|
25679
|
+
model,
|
|
25680
|
+
modelKey: keys.modelKey
|
|
25681
|
+
}) !== undefined) {
|
|
25682
|
+
const fit = lkgReplayFits({
|
|
25683
|
+
db,
|
|
25684
|
+
sessionId,
|
|
25685
|
+
messages: replay.messages,
|
|
25686
|
+
model,
|
|
25687
|
+
modelKey: keys.modelKey,
|
|
25688
|
+
systemPromptTokens: getOrCreateSessionMeta(db, sessionId).systemPromptTokens,
|
|
25689
|
+
agentName: agent
|
|
25690
|
+
});
|
|
25691
|
+
tsFit = fit.fits;
|
|
25692
|
+
if (!fit.fits && fit.detail)
|
|
25693
|
+
sessionLog(sessionId, fit.detail);
|
|
25694
|
+
}
|
|
25695
|
+
}
|
|
25696
|
+
if (replay.ok && (!tsFit || args.replayFits?.(replay.messages) === false || rust && !rust.replayFits(sessionId, replay.messages, inputMessages))) {
|
|
25697
|
+
replayBlocked = true;
|
|
25698
|
+
sessionLog(sessionId, "lkg_replay_does_not_fit");
|
|
25699
|
+
} else if (replay.ok) {
|
|
25700
|
+
args.onLkgReplay?.();
|
|
25701
|
+
replaceMessagesInPlace2(output, replay.messages);
|
|
25702
|
+
noteExternalLkgReplay(rust, sessionId, inputCount);
|
|
25703
|
+
sessionLog(sessionId, "lkg_replay_served");
|
|
25704
|
+
return true;
|
|
25705
|
+
} else {
|
|
25706
|
+
sessionLog(sessionId, replay.reason);
|
|
25707
|
+
}
|
|
25708
|
+
}
|
|
25709
|
+
} catch (replayError) {
|
|
25710
|
+
replayBlocked = true;
|
|
25711
|
+
sessionLog(sessionId, "lkg_replay_unavailable", replayError);
|
|
25712
|
+
}
|
|
25713
|
+
if (replayBlocked) {
|
|
25714
|
+
sessionLog(sessionId, "lkg_replay_declined");
|
|
25715
|
+
}
|
|
25716
|
+
} else if (sessionId) {
|
|
25717
|
+
sessionLog(sessionId, "lkg_miss");
|
|
25718
|
+
}
|
|
25719
|
+
return false;
|
|
25720
|
+
}
|
|
25228
25721
|
function createMessagesTransformHandler(args) {
|
|
25229
25722
|
const resolveRust = (sessionId) => args.rustReplayParticipant ? args.rustReplayParticipant() ?? undefined : resolveRustLkgReplayParticipant(sessionId);
|
|
25230
25723
|
const run = async (input, output) => {
|
|
@@ -25270,15 +25763,18 @@ function createMessagesTransformHandler(args) {
|
|
|
25270
25763
|
}
|
|
25271
25764
|
}
|
|
25272
25765
|
const magicContext = args.getMagicContext ? args.getMagicContext() : args.magicContext;
|
|
25273
|
-
const
|
|
25274
|
-
|
|
25766
|
+
const captureEntry = () => {
|
|
25767
|
+
if (!sessionId || !getSlot(sessionId))
|
|
25768
|
+
return null;
|
|
25275
25769
|
try {
|
|
25276
25770
|
return noteEntry(sessionId, output.messages);
|
|
25277
25771
|
} catch (error) {
|
|
25278
25772
|
sessionLog(sessionId, "lkg entry snapshot failed; replay unavailable", error);
|
|
25279
25773
|
return null;
|
|
25280
25774
|
}
|
|
25281
|
-
}
|
|
25775
|
+
};
|
|
25776
|
+
let entry = captureEntry();
|
|
25777
|
+
let admissionRetried = false;
|
|
25282
25778
|
try {
|
|
25283
25779
|
if (magicContext) {
|
|
25284
25780
|
const admissionDb = openDatabase();
|
|
@@ -25286,6 +25782,22 @@ function createMessagesTransformHandler(args) {
|
|
|
25286
25782
|
if (!args.compactionOff) {
|
|
25287
25783
|
await withAsyncPrivilegedWriter(admissionDb, () => {
|
|
25288
25784
|
return;
|
|
25785
|
+
}, {
|
|
25786
|
+
beforeRetry: (error) => {
|
|
25787
|
+
admissionRetried = true;
|
|
25788
|
+
entry = captureEntry();
|
|
25789
|
+
if (sessionId && tryMessagesTransformLkgReplay({
|
|
25790
|
+
output,
|
|
25791
|
+
sessionId,
|
|
25792
|
+
error,
|
|
25793
|
+
entry,
|
|
25794
|
+
rust: resolveRust(sessionId),
|
|
25795
|
+
agent,
|
|
25796
|
+
replayFits: args.replayFits,
|
|
25797
|
+
onLkgReplay: args.onLkgReplay
|
|
25798
|
+
}))
|
|
25799
|
+
throw new LkgAdmissionReplay;
|
|
25800
|
+
}
|
|
25289
25801
|
});
|
|
25290
25802
|
}
|
|
25291
25803
|
} else {
|
|
@@ -25311,9 +25823,13 @@ function createMessagesTransformHandler(args) {
|
|
|
25311
25823
|
}
|
|
25312
25824
|
}
|
|
25313
25825
|
}
|
|
25826
|
+
if (admissionRetried)
|
|
25827
|
+
entry = captureEntry();
|
|
25314
25828
|
await magicContext?.["experimental.chat.messages.transform"]?.(input, output);
|
|
25315
25829
|
return output.messages;
|
|
25316
25830
|
} catch (error) {
|
|
25831
|
+
if (error instanceof LkgAdmissionReplay)
|
|
25832
|
+
return output.messages;
|
|
25317
25833
|
if (error instanceof RawFallbackContextLimitError || error instanceof AssistantTerminalRetryError) {
|
|
25318
25834
|
throw error;
|
|
25319
25835
|
}
|
|
@@ -25329,85 +25845,17 @@ function createMessagesTransformHandler(args) {
|
|
|
25329
25845
|
}
|
|
25330
25846
|
if (args.compactionOff) {
|
|
25331
25847
|
restoreCompactionOffInput();
|
|
25332
|
-
} else if (sessionId &&
|
|
25333
|
-
|
|
25334
|
-
|
|
25335
|
-
|
|
25336
|
-
|
|
25337
|
-
|
|
25338
|
-
|
|
25339
|
-
|
|
25340
|
-
|
|
25341
|
-
|
|
25342
|
-
|
|
25343
|
-
} else if (!db || isEmergencyRecoveryArmed(sessionId) || getOverflowState(db, sessionId).needsEmergencyRecovery) {
|
|
25344
|
-
replayBlocked = true;
|
|
25345
|
-
sessionLog(sessionId, "lkg_emergency_armed");
|
|
25346
|
-
} else {
|
|
25347
|
-
const inputMessages = output.messages;
|
|
25348
|
-
const inputCount = inputMessages.length;
|
|
25349
|
-
const keys = resolveLkgModelKeys(inputMessages);
|
|
25350
|
-
const replay = replayLkg({
|
|
25351
|
-
sessionId,
|
|
25352
|
-
messages: inputMessages,
|
|
25353
|
-
modelKey: keys.modelKey,
|
|
25354
|
-
providerKey: keys.providerKey,
|
|
25355
|
-
entry,
|
|
25356
|
-
prepareReplay: (messages) => rust ? rust.stripPersistedReasoning(sessionId, messages, inputMessages) : replayRustModeBindingMismatchStrips2({
|
|
25357
|
-
db,
|
|
25358
|
-
sessionId,
|
|
25359
|
-
messages,
|
|
25360
|
-
resolvedProviderID: keys.providerKey ?? undefined
|
|
25361
|
-
})
|
|
25362
|
-
});
|
|
25363
|
-
let tsFit = true;
|
|
25364
|
-
if (replay.ok && !rust && keys.providerKey && keys.modelKey) {
|
|
25365
|
-
const model = {
|
|
25366
|
-
providerID: keys.providerKey,
|
|
25367
|
-
modelID: keys.modelKey.slice(keys.providerKey.length + 1)
|
|
25368
|
-
};
|
|
25369
|
-
if (lkgReplayLimit({
|
|
25370
|
-
db,
|
|
25371
|
-
sessionId,
|
|
25372
|
-
model,
|
|
25373
|
-
modelKey: keys.modelKey
|
|
25374
|
-
}) !== undefined) {
|
|
25375
|
-
const fit = lkgReplayFits({
|
|
25376
|
-
db,
|
|
25377
|
-
sessionId,
|
|
25378
|
-
messages: replay.messages,
|
|
25379
|
-
model,
|
|
25380
|
-
modelKey: keys.modelKey,
|
|
25381
|
-
systemPromptTokens: getOrCreateSessionMeta(db, sessionId).systemPromptTokens,
|
|
25382
|
-
agentName: agent
|
|
25383
|
-
});
|
|
25384
|
-
tsFit = fit.fits;
|
|
25385
|
-
if (!fit.fits && fit.detail)
|
|
25386
|
-
sessionLog(sessionId, fit.detail);
|
|
25387
|
-
}
|
|
25388
|
-
}
|
|
25389
|
-
if (replay.ok && (!tsFit || rust && !rust.replayFits(sessionId, replay.messages, inputMessages))) {
|
|
25390
|
-
replayBlocked = true;
|
|
25391
|
-
sessionLog(sessionId, "lkg_replay_does_not_fit");
|
|
25392
|
-
} else if (replay.ok) {
|
|
25393
|
-
args.onLkgReplay?.();
|
|
25394
|
-
replaceMessagesInPlace2(output, replay.messages);
|
|
25395
|
-
noteExternalLkgReplay(rust, sessionId, inputCount);
|
|
25396
|
-
sessionLog(sessionId, "lkg_replay_served");
|
|
25397
|
-
return output.messages;
|
|
25398
|
-
} else {
|
|
25399
|
-
sessionLog(sessionId, replay.reason);
|
|
25400
|
-
}
|
|
25401
|
-
}
|
|
25402
|
-
} catch (replayError) {
|
|
25403
|
-
replayBlocked = true;
|
|
25404
|
-
sessionLog(sessionId, "lkg_replay_unavailable", replayError);
|
|
25405
|
-
}
|
|
25406
|
-
if (replayBlocked) {
|
|
25407
|
-
sessionLog(sessionId, "lkg_replay_declined");
|
|
25408
|
-
}
|
|
25409
|
-
} else if (sessionId) {
|
|
25410
|
-
sessionLog(sessionId, "lkg_miss");
|
|
25848
|
+
} else if (sessionId && tryMessagesTransformLkgReplay({
|
|
25849
|
+
output,
|
|
25850
|
+
sessionId,
|
|
25851
|
+
error,
|
|
25852
|
+
entry,
|
|
25853
|
+
rust: resolveRust(sessionId),
|
|
25854
|
+
agent,
|
|
25855
|
+
replayFits: args.replayFits,
|
|
25856
|
+
onLkgReplay: args.onLkgReplay
|
|
25857
|
+
})) {
|
|
25858
|
+
return output.messages;
|
|
25411
25859
|
}
|
|
25412
25860
|
if (!args.compactionOff && (error instanceof UnresolvedHistoryBoundaryError || error instanceof UnmanagedOverWindowError || error instanceof DegradedPassRefusalError)) {
|
|
25413
25861
|
throw error;
|
|
@@ -27083,7 +27531,7 @@ function reasoningOf(part) {
|
|
|
27083
27531
|
function renderPartPreview(part, expandTools) {
|
|
27084
27532
|
if (!isRecord6(part))
|
|
27085
27533
|
return null;
|
|
27086
|
-
const expansion = expandToolPart(part, expandTools);
|
|
27534
|
+
const expansion = expandToolPart(part, expandTools, true);
|
|
27087
27535
|
if (expansion !== null)
|
|
27088
27536
|
return ` • tool ${part.tool}: ${expansion}`;
|
|
27089
27537
|
const text = textOf(part);
|
|
@@ -28502,4 +28950,4 @@ function createCtxSearchTools(deps) {
|
|
|
28502
28950
|
[CTX_SEARCH_TOOL_NAME]: createCtxSearchTool(deps)
|
|
28503
28951
|
};
|
|
28504
28952
|
}
|
|
28505
|
-
export { createSubcCheckoutClaimGate, openCodeEventSessionId, openOpenCodeDb, DREAMER_SYSTEM_PROMPT, runSessionProjectBackfill, SMART_NOTE_COMPILER_SYSTEM_PROMPT, createLiveSessionState, getDefaultSubcConnectionFile, SubcModuleTransport, RETROSPECTIVE_MAX_USER_MESSAGE_CHARS, RETROSPECTIVE_MESSAGE_TRUNCATION_MARKER, OpenCodeRetrospectiveRawProvider, createDreamTaskExecutor, runManualDream, runDueTasksForProject, createDbLkgPersistence, startDreamScheduleTimer, ensureProjectRegisteredFromOpenCodeDirectory, resolveContextWindowGeometry, resolveContextLimit, resolveExecuteThresholdDetail, resolveModelKey, resolveSessionId, createScheduler, describeStorageUnavailability, scheduleClearAndReindex, resolveSessionCacheTtl, runEmbedHistoryDrain, pauseEmbedHistoryDrain, formatEmbedStatusText, getSessionProperties, getSessionCreatedInfo, getMessageUpdatedAssistantInfo, getMessageUpdatedInfo, getSessionErrorInfo, getMessageRemovedInfo, summarizeManualDream, createMagicContextCommandHandler, getLiveNotificationParams, createChatMessageHook, createEventHook, createCommandExecuteBeforeHook, createToolExecuteAfterHook, recordHiddenVariantWarning, buildStatusDetail, isDebugRpcEnabled, registerRpcHandlers, clearTransformDecisionSession, scheduleOpenCodeTransformDecisionWrite, maybeDeliverChannel2, STORAGE_BUSY_MESSAGE, StorageBusyRefusalError, UnmanagedOverWindowError, UnresolvedHistoryBoundaryError, clearMessageTokensCache, createTransform, createSubcModuleClient, createModuleToolBackends, createRustRefusalRecovery, createSystemPromptHashHandler, createMessagesTransformHandler, primaryOnlyToolIds, subagentToolRefusal, guardSubagentTools, hideSubagentTools, createCtxExpandTools, CTX_MEMORY_LIST_TOOL_NAME, CTX_MEMORY_ACTIONS, createCtxMemoryTools, createCtxMemoryListTools, createCtxNoteTools, createCtxReduceTools, createCtxSearchTools, parameterDescriptionsFor, applyJsonSchemaParameterDescriptions, MagicContextRpcServer };
|
|
28953
|
+
export { createSubcCheckoutClaimGate, openCodeEventSessionId, openOpenCodeDb, DREAMER_SYSTEM_PROMPT, runSessionProjectBackfill, SMART_NOTE_COMPILER_SYSTEM_PROMPT, createLiveSessionState, getDefaultSubcConnectionFile, SubcModuleTransport, RETROSPECTIVE_MAX_USER_MESSAGE_CHARS, RETROSPECTIVE_MESSAGE_TRUNCATION_MARKER, OpenCodeRetrospectiveRawProvider, createDreamTaskExecutor, runManualDream, runDueTasksForProject, createDbLkgPersistence, startDreamScheduleTimer, ensureProjectRegisteredFromOpenCodeDirectory, recordOpenCodeProvenInputFloor, resolveOpenCodeProvenInputFloor, resolveContextWindowGeometry, resolveContextLimit, resolveExecuteThresholdDetail, resolveModelKey, resolveSessionId, createScheduler, describeStorageUnavailability, scheduleClearAndReindex, resolveSessionCacheTtl, runEmbedHistoryDrain, pauseEmbedHistoryDrain, formatEmbedStatusText, getSessionProperties, getSessionCreatedInfo, getMessageUpdatedAssistantInfo, getMessageUpdatedInfo, getSessionErrorInfo, getMessageRemovedInfo, summarizeManualDream, createMagicContextCommandHandler, getLiveNotificationParams, createChatMessageHook, createEventHook, createCommandExecuteBeforeHook, createToolExecuteAfterHook, recordHiddenVariantWarning, buildStatusDetail, isDebugRpcEnabled, registerRpcHandlers, clearTransformDecisionSession, scheduleOpenCodeTransformDecisionWrite, maybeDeliverChannel2, armLatestThinkingRecovery, armBindingRecoverySafely, armLatestThinkingRecoveryFromError, lkgReplayLimit, measureLkgReplay, STORAGE_BUSY_MESSAGE, StorageBusyRefusalError, UnmanagedOverWindowError, UnresolvedHistoryBoundaryError, clearMessageTokensCache, createTransform, createSubcModuleClient, createModuleToolBackends, createRustRefusalRecovery, createSystemPromptHashHandler, tryMessagesTransformLkgReplay, createMessagesTransformHandler, primaryOnlyToolIds, subagentToolRefusal, guardSubagentTools, hideSubagentTools, createCtxExpandTools, CTX_MEMORY_LIST_TOOL_NAME, CTX_MEMORY_ACTIONS, createCtxMemoryTools, createCtxMemoryListTools, createCtxNoteTools, createCtxReduceTools, createCtxSearchTools, parameterDescriptionsFor, applyJsonSchemaParameterDescriptions, MagicContextRpcServer };
|