@cortexkit/opencode-magic-context 0.49.35 → 0.49.36
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/README.md +1 -1
- package/dist/auto-search-worker.js +163 -160
- package/dist/chunk-embedding-write-worker.js +58 -56
- package/dist/{compaction-marker-candidates-g0p67ced.js → compaction-marker-candidates-5p1qkve9.js} +3 -1
- package/dist/compaction-marker-candidates-worker.js +24 -23
- package/dist/{compartment-chunk-embedding-y4136are.js → compartment-chunk-embedding-ypktm0tk.js} +5 -4
- package/dist/{conflict-warning-hook-hhw8z5ak.js → conflict-warning-hook-b75jn458.js} +6 -5
- package/dist/{context-fk8e3h9p.js → context-969z683s.js} +485 -91
- package/dist/{embedding-backfill-q6n72sy0.js → embedding-backfill-rma0v2ct.js} +9 -8
- package/dist/embedding-worker.js +2 -2
- package/dist/features/magic-context/compaction-marker-candidates.d.ts.map +1 -1
- package/dist/features/magic-context/compaction-marker.d.ts +5 -3
- 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/dreamer/verify-gate.d.ts +2 -0
- package/dist/features/magic-context/dreamer/verify-gate.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify-state.d.ts +9 -0
- package/dist/features/magic-context/dreamer/verify-state.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/verify.d.ts +2 -1
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/migration-worker-client.d.ts +3 -0
- package/dist/features/magic-context/migration-worker-client.d.ts.map +1 -1
- package/dist/features/magic-context/migration-worker.d.ts +15 -0
- package/dist/features/magic-context/migration-worker.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +2 -2
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/search-rerank.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +1 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +4 -0
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/work-metrics-carry-storage.d.ts +10 -0
- package/dist/features/magic-context/work-metrics-carry-storage.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts +5 -1
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-publication.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/issue-423-fixture.d.ts +1 -1
- package/dist/hooks/magic-context/issue-423-fixture.d.ts.map +1 -1
- package/dist/hooks/magic-context/issue-424-fixture.d.ts +1 -1
- package/dist/hooks/magic-context/issue-424-fixture.d.ts.map +1 -1
- package/dist/hooks/magic-context/project-structural-sentinels.d.ts +25 -0
- package/dist/hooks/magic-context/project-structural-sentinels.d.ts.map +1 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +8 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts +2 -0
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/release-recovery-prefix.d.ts +9 -0
- package/dist/hooks/magic-context/release-recovery-prefix.d.ts.map +1 -0
- package/dist/hooks/magic-context/strip-structural-noise.d.ts +6 -3
- package/dist/hooks/magic-context/strip-structural-noise.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-context-state.d.ts +3 -0
- package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +3 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-cpjk5jd2.js → index-1d042x6w.js} +16 -14
- package/dist/{index-jn0ddrhp.js → index-21fgrfrf.js} +8 -6
- package/dist/{index-pq0dpwrc.js → index-2rs7912w.js} +2 -2
- package/dist/{index-ezv6dz3y.js → index-4ks89h5a.js} +4 -4
- package/dist/{index-vzhhr1ht.js → index-4y35msh5.js} +1 -2
- package/dist/{index-f297z1n8.js → index-72czy45z.js} +5 -5
- package/dist/index-7v05d9b7.js +58 -0
- package/dist/{index-f9b3vtt1.js → index-850vthn3.js} +8 -2
- package/dist/{index-ksv0a31x.js → index-8jjjmhab.js} +12 -1
- package/dist/index-96ztjvkn.js +204 -0
- package/dist/{index-gyaa159j.js → index-9fgmkfaf.js} +6 -3
- package/dist/{index-4bgk5ztz.js → index-9tdvbdv1.js} +187 -90
- package/dist/{index-2v6nvy3k.js → index-ae1ar4v1.js} +1 -1
- package/dist/{index-faxb7mck.js → index-b1ydbp95.js} +1 -1
- package/dist/{index-nxrsns5x.js → index-c5dzns43.js} +75 -75
- package/dist/{index-zhqwda72.js → index-dcjkw41m.js} +1 -1
- package/dist/{index-x2mrq5xv.js → index-dfdg2cgg.js} +179 -49
- package/dist/{index-87ctnzz9.js → index-dz48h1wx.js} +2 -2
- package/dist/{index-b6xz3qbe.js → index-gnmhbyyc.js} +366 -83
- package/dist/{index-qx8j6kds.js → index-j105mf16.js} +2 -2
- package/dist/{index-p56dszfp.js → index-jggt5gf2.js} +1 -1
- package/dist/{index-xwwsbsd3.js → index-pp8vdn01.js} +5 -5
- package/dist/{index-dy7w6wm4.js → index-prw8apnc.js} +5 -5
- package/dist/{index-qncw9hey.js → index-r2epb000.js} +33 -3
- package/dist/{index-brg2w6qc.js → index-tn9drm1a.js} +16 -14
- package/dist/{index-pswsyf1w.js → index-ty4vhe4n.js} +3 -3
- package/dist/{index-pztqab6k.js → index-vd2ywmfe.js} +1 -1
- package/dist/{index-3j9t1v4n.js → index-wcwhhtdh.js} +10 -9
- package/dist/{index-1rhgxqs8.js → index-xd2p95m7.js} +1 -1
- package/dist/{index-0c7p8mq5.js → index-xnm0wq1r.js} +1 -1
- package/dist/{index-3d3872c6.js → index-ys7j6679.js} +4 -4
- package/dist/index.js +38 -37
- package/dist/{message-fts-rowid-map-xg7hr0mk.js → message-fts-rowid-map-t6qsyg9s.js} +4 -3
- package/dist/{message-index-bounded-narw7bnz.js → message-index-bounded-wfk6aqxk.js} +9 -8
- package/dist/migration-worker.js +45 -40
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{project-embedding-registry-tdz7985n.js → project-embedding-registry-3yyegjma.js} +8 -7
- package/dist/raw-ordinal-warmup-worker.js +114 -118
- package/dist/{read-session-chunk-vmg1zjg0.js → read-session-chunk-26yrrhyz.js} +7 -6
- package/dist/{read-session-raw-mncmzbm9.js → read-session-raw-j7c9w57v.js} +3 -2
- package/dist/{recomp-orchestrator-qyyhnc9b.js → recomp-orchestrator-wk509qkp.js} +20 -19
- package/dist/{render-c5p0k846.js → render-h1qarr8a.js} +13 -12
- package/dist/{search-f6hwvcxk.js → search-5h9fydyq.js} +16 -15
- package/dist/{search-archive-0ny7p3bw.js → search-archive-q79hyqxs.js} +9 -8
- package/dist/{send-session-notification-0gwcz3fw.js → send-session-notification-14p3yje4.js} +5 -4
- package/dist/shared/model-suggestion-retry.d.ts +7 -0
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/prompt-async-transport.d.ts.map +1 -1
- package/dist/shared/reusable-worker-entry.d.ts +4 -0
- package/dist/shared/reusable-worker-entry.d.ts.map +1 -0
- package/dist/shared/reusable-worker.d.ts +6 -0
- package/dist/shared/reusable-worker.d.ts.map +1 -0
- package/dist/shared/reusable-worker.fixture.d.ts +2 -0
- package/dist/shared/reusable-worker.fixture.d.ts.map +1 -0
- package/dist/shared/worker-shutdown.d.ts +1 -1
- package/dist/shared/worker-shutdown.d.ts.map +1 -1
- package/dist/{storage-tags-zx1023km.js → storage-tags-vj0yj7ed.js} +1 -1
- package/dist/{store-620rjzt9.js → store-s3eykdjt.js} +1 -1
- package/dist/{transform-postprocess-phase-807ff6t2.js → transform-postprocess-phase-4gj0mtcg.js} +21 -20
- package/dist/v2/auto-search-worker.js +163 -160
- package/dist/v2/chunk-embedding-write-worker.js +59 -57
- package/dist/v2/compaction-marker-candidates-worker.js +24 -23
- package/dist/v2/{compaction-marker-candidates-t1aq6gsj.js → compaction-marker-candidates-yeb2ky46.js} +4 -2
- package/dist/v2/{compartment-chunk-embedding-ncsk0r9e.js → compartment-chunk-embedding-qfk791bd.js} +6 -5
- package/dist/v2/{context-znqfkap4.js → context-bxr039be.js} +1011 -209
- package/dist/v2/{embedding-backfill-11j425e0.js → embedding-backfill-00tw59rx.js} +10 -9
- package/dist/v2/embedding-worker.js +2 -2
- package/dist/v2/fold/code-mode-catalog.d.ts +3 -0
- package/dist/v2/fold/code-mode-catalog.d.ts.map +1 -0
- package/dist/v2/fold/idle.d.ts +1 -0
- package/dist/v2/fold/idle.d.ts.map +1 -1
- package/dist/v2/fold/manual-baseline.d.ts +8 -0
- package/dist/v2/fold/manual-baseline.d.ts.map +1 -0
- package/dist/v2/fold/native-replay-v3.d.ts +7 -0
- package/dist/v2/fold/native-replay-v3.d.ts.map +1 -1
- package/dist/v2/fold/native-replay.d.ts +24 -7
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/fold/restore.d.ts.map +1 -1
- package/dist/v2/fold/summary.d.ts +4 -0
- package/dist/v2/fold/summary.d.ts.map +1 -0
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/channel2.d.ts +6 -0
- package/dist/v2/hooks/channel2.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/restore-rows.d.ts +12 -2
- package/dist/v2/hooks/restore-rows.d.ts.map +1 -1
- package/dist/v2/hooks/synthetic-admission.d.ts +7 -0
- package/dist/v2/hooks/synthetic-admission.d.ts.map +1 -0
- package/dist/v2/hooks/usage-persist.d.ts.map +1 -1
- package/dist/v2/{message-fts-rowid-map-rmk571mb.js → message-fts-rowid-map-z86avy0n.js} +5 -4
- package/dist/v2/{message-index-bounded-620bppw7.js → message-index-bounded-w14496s9.js} +9 -8
- package/dist/v2/migration-worker.js +46 -41
- package/dist/v2/{project-embedding-registry-bm5fe1a8.js → project-embedding-registry-jqq2qeqb.js} +9 -8
- package/dist/v2/raw-ordinal-warmup-worker.js +114 -118
- package/dist/v2/{read-session-chunk-qfwv1k71.js → read-session-chunk-tqnh1ret.js} +7 -6
- package/dist/v2/{read-session-raw-q294t8xs.js → read-session-raw-qpp6x9kg.js} +4 -3
- package/dist/v2/{recomp-orchestrator-fcnjref7.js → recomp-orchestrator-9cjk6aej.js} +19 -18
- package/dist/v2/{render-98a1qv0b.js → render-5dz1knf2.js} +13 -12
- package/dist/v2/{search-z1zqzsmh.js → search-8yfet25y.js} +15 -14
- package/dist/v2/{search-archive-r0y1bafr.js → search-archive-z6z9jqwf.js} +9 -8
- package/dist/v2/{send-session-notification-fst6hkg7.js → send-session-notification-kxp47tsw.js} +4 -3
- package/dist/v2/{server-cpjk5jd2.js → server-1d042x6w.js} +16 -14
- package/dist/v2/{server-fqj6ddpr.js → server-5by3vdzs.js} +186 -89
- package/dist/v2/{server-5jp38p98.js → server-6emy0v9a.js} +1 -2
- package/dist/v2/{server-rktnzs89.js → server-6vzh6wej.js} +1 -1
- package/dist/v2/{server-qa74bj91.js → server-7094pk3w.js} +9 -8
- package/dist/v2/{server-bxpz2dcn.js → server-7acq7815.js} +8 -6
- package/dist/v2/server-7v05d9b7.js +58 -0
- package/dist/v2/{server-24g8r2d0.js → server-7zacmty5.js} +75 -75
- package/dist/v2/server-96ztjvkn.js +204 -0
- package/dist/v2/{server-hnknwaz8.js → server-a9w5f0yw.js} +3 -3
- package/dist/v2/{server-9k0mjef7.js → server-avdveykk.js} +1 -1
- package/dist/v2/{server-hsf0qsn5.js → server-cp1a03vc.js} +1 -1
- package/dist/v2/{server-r3chnxs5.js → server-dfq5vb8j.js} +2 -2
- package/dist/v2/{server-x4m6xcn4.js → server-e51xmr4d.js} +6 -6
- package/dist/v2/{server-7ccxt4nq.js → server-g3gqq4ac.js} +6 -3
- package/dist/v2/{server-kkxzwa6w.js → server-gkse1wyz.js} +3 -3
- package/dist/v2/{server-1xesqm5h.js → server-jd7vzwn4.js} +15 -13
- package/dist/v2/{server-ws5exe6q.js → server-nmyganc8.js} +1 -1
- package/dist/v2/{server-q0z2q2dx.js → server-nq3cb7be.js} +1 -1
- package/dist/v2/{server-55v5hpth.js → server-qjyp27vf.js} +2 -2
- package/dist/v2/{server-xbtw0p9t.js → server-r4430x9m.js} +9 -3
- package/dist/v2/{server-qf2kzsh2.js → server-t8y64xj7.js} +4 -4
- package/dist/v2/{server-s9xgyyj9.js → server-tnzbk64q.js} +34 -4
- package/dist/v2/{server-51779zs2.js → server-v0p37hm2.js} +4 -1
- package/dist/v2/{server-bpvsvtph.js → server-xfjjbrkt.js} +12 -1
- package/dist/v2/server.js +4 -4
- package/dist/v2/{storage-tags-19s0ebf0.js → storage-tags-cw07ky67.js} +1 -1
- package/dist/v2/{store-vdm8v3jd.js → store-z3qe67cg.js} +1 -1
- package/dist/v2/{v2-archive-reader-t2c0eypn.js → v2-archive-reader-z7wr42ry.js} +3 -3
- package/dist/v2/{wrapup-orchestrator-aqpqsveg.js → wrapup-orchestrator-j1v62bkj.js} +19 -18
- package/dist/{v2-archive-reader-tm2eayp2.js → v2-archive-reader-028z6kck.js} +2 -2
- package/dist/{wrapup-orchestrator-k5yp19a6.js → wrapup-orchestrator-xg9avt2p.js} +21 -20
- package/package.json +1 -1
- package/src/shared/model-suggestion-retry.ts +1 -1
- package/src/shared/prompt-async-transport.test.ts +64 -3
- package/src/shared/prompt-async-transport.ts +61 -16
- package/src/shared/reusable-worker-entry.ts +58 -0
- package/src/shared/reusable-worker-reset.test.ts +108 -0
- package/src/shared/reusable-worker.fixture.ts +35 -0
- package/src/shared/reusable-worker.test.ts +253 -0
- package/src/shared/reusable-worker.ts +240 -0
- package/src/shared/worker-shutdown.ts +21 -17
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
cortexKitProjectConfigBasePath,
|
|
21
21
|
resolveLegacyConfigSourcesForHarness,
|
|
22
22
|
loadPluginConfigDetailed
|
|
23
|
-
} from "./server-
|
|
23
|
+
} from "./server-avdveykk.js";
|
|
24
24
|
import {
|
|
25
25
|
catalogOutputReserve,
|
|
26
26
|
getSdkContextLimit,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
resolvePromptSurface,
|
|
34
34
|
DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
35
35
|
LIVE_RELOAD_CONFIG_PATHS
|
|
36
|
-
} from "./server-
|
|
36
|
+
} from "./server-7zacmty5.js";
|
|
37
37
|
import {
|
|
38
38
|
inRootAsyncContext2,
|
|
39
39
|
Database2,
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
RawOrdinalsNotReady2,
|
|
49
49
|
dropRawSessionOrdinalCheckpoints2,
|
|
50
50
|
runSessionWarmupWorker
|
|
51
|
-
} from "./server-
|
|
51
|
+
} from "./server-tnzbk64q.js";
|
|
52
52
|
import {
|
|
53
53
|
providerMass,
|
|
54
54
|
calibrationForModelKey,
|
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
foldShrunkPartTags2,
|
|
65
65
|
getTagNumberByMessageId2,
|
|
66
66
|
getActiveTagsBySession2
|
|
67
|
-
} from "./server-
|
|
67
|
+
} from "./server-xfjjbrkt.js";
|
|
68
68
|
import {
|
|
69
69
|
hasMeaningfulUserText2,
|
|
70
70
|
estimateTokens,
|
|
@@ -152,7 +152,7 @@ import {
|
|
|
152
152
|
getRawSessionTagKeysThrough2,
|
|
153
153
|
getLegacyProtectedTailStartOrdinal2,
|
|
154
154
|
readSessionChunk2
|
|
155
|
-
} from "./server-
|
|
155
|
+
} from "./server-jd7vzwn4.js";
|
|
156
156
|
import {
|
|
157
157
|
BoundedSessionMap
|
|
158
158
|
} from "./server-xy7w7hrd.js";
|
|
@@ -162,7 +162,7 @@ import {
|
|
|
162
162
|
toMessageIndexSource,
|
|
163
163
|
clearIndexedMessagesInTransaction,
|
|
164
164
|
indexSourcesAfterOrdinal
|
|
165
|
-
} from "./server-
|
|
165
|
+
} from "./server-dfq5vb8j.js";
|
|
166
166
|
import {
|
|
167
167
|
COMPARTMENT_LEASE_RENEWAL_MS,
|
|
168
168
|
getCompartmentLeaseBlocker,
|
|
@@ -206,7 +206,7 @@ import {
|
|
|
206
206
|
getProjectState,
|
|
207
207
|
recordSubagentInvocation,
|
|
208
208
|
getLatestHistorianInvocationId
|
|
209
|
-
} from "./server-
|
|
209
|
+
} from "./server-t8y64xj7.js";
|
|
210
210
|
import {
|
|
211
211
|
invalidateAutoEmbedSession
|
|
212
212
|
} from "./server-2amn2s73.js";
|
|
@@ -219,13 +219,13 @@ import {
|
|
|
219
219
|
replaceCompartmentChunkEmbeddings2,
|
|
220
220
|
deleteChunkEmbedBackoffForSession2,
|
|
221
221
|
chunkWindowSourceKey2
|
|
222
|
-
} from "./server-
|
|
222
|
+
} from "./server-cp1a03vc.js";
|
|
223
223
|
import {
|
|
224
224
|
isMarkerCandidateBasisCurrent2,
|
|
225
225
|
invalidateMarkerCandidateBasis2,
|
|
226
226
|
readMarkerCandidateBasis2,
|
|
227
227
|
prepareMarkerCandidateBasis2
|
|
228
|
-
} from "./server-
|
|
228
|
+
} from "./server-r4430x9m.js";
|
|
229
229
|
import {
|
|
230
230
|
shouldSkipHomeProjectMemory,
|
|
231
231
|
resolveProjectIdentity
|
|
@@ -236,7 +236,7 @@ import {
|
|
|
236
236
|
getProjectChunkEmbeddingModelId2,
|
|
237
237
|
getProjectEmbeddingMaxInputTokens2,
|
|
238
238
|
embedItemsForProject2
|
|
239
|
-
} from "./server-
|
|
239
|
+
} from "./server-7acq7815.js";
|
|
240
240
|
import {
|
|
241
241
|
V2_MEMORY_CATEGORIES,
|
|
242
242
|
CATEGORY_PRIORITY,
|
|
@@ -255,13 +255,13 @@ import {
|
|
|
255
255
|
userFacingFailureCode,
|
|
256
256
|
promoteSessionFactsDurable,
|
|
257
257
|
embedPromotedFacts
|
|
258
|
-
} from "./server-
|
|
258
|
+
} from "./server-nq3cb7be.js";
|
|
259
259
|
import {
|
|
260
260
|
getSchemaFenceRejection,
|
|
261
261
|
LATEST_SUPPORTED_VERSION,
|
|
262
262
|
getPersistedSchemaVersion,
|
|
263
263
|
openDatabase
|
|
264
|
-
} from "./server-
|
|
264
|
+
} from "./server-g3gqq4ac.js";
|
|
265
265
|
import {
|
|
266
266
|
parseCompartmentOutput,
|
|
267
267
|
resolveWorkspaceShareCategories,
|
|
@@ -1566,46 +1566,36 @@ function isCompactionMarkerIntentAbsent(marker, targetEndMessageId) {
|
|
|
1566
1566
|
function withCompactionMarkerPublicationLock(operation) {
|
|
1567
1567
|
return runMarkerWriteTransaction(getWritableOpenCodeDb(), "compaction-marker-replace", operation);
|
|
1568
1568
|
}
|
|
1569
|
-
function inspectCompactionMarkerPublication(sessionId, recognized, summaryText) {
|
|
1569
|
+
function inspectCompactionMarkerPublication(sessionId, recognized, summaryText, targetBoundaryMessageId, preferred) {
|
|
1570
1570
|
const db = getWritableOpenCodeDb();
|
|
1571
1571
|
const basis = readMarkerCandidateBasis2(db, sessionId);
|
|
1572
1572
|
if (!basis)
|
|
1573
1573
|
return { kind: "deferred" };
|
|
1574
1574
|
const pairs = [];
|
|
1575
1575
|
for (const id of basis.ids) {
|
|
1576
|
-
const rows = db.prepare(`SELECT m.id AS summaryId, p.message_id AS boundaryId, p.id AS partId
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
AND json_extract(
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
return { kind: "ambiguous" };
|
|
1586
|
-
if (pairs.length === 0) {
|
|
1587
|
-
for (const marker of recognized) {
|
|
1588
|
-
if (db.prepare(`SELECT 1 FROM message WHERE id = ?
|
|
1589
|
-
UNION ALL SELECT 1 FROM part WHERE id IN (?, ?) LIMIT 1`).get(marker.summaryMessageId, marker.compactionPartId, marker.summaryPartId))
|
|
1590
|
-
return { kind: "ambiguous" };
|
|
1591
|
-
}
|
|
1592
|
-
return { kind: "verified", marker: null };
|
|
1593
|
-
}
|
|
1594
|
-
const pair = pairs[0];
|
|
1595
|
-
const marker = recognized.find((item) => item.summaryMessageId === pair.summaryId && item.boundaryMessageId === pair.boundaryId && item.compactionPartId === pair.partId);
|
|
1596
|
-
if (!marker)
|
|
1597
|
-
return { kind: "ambiguous" };
|
|
1598
|
-
for (const other of recognized) {
|
|
1599
|
-
if (other.summaryMessageId === marker.summaryMessageId && other.compactionPartId === marker.compactionPartId && other.summaryPartId === marker.summaryPartId)
|
|
1600
|
-
continue;
|
|
1601
|
-
if (db.prepare(`SELECT 1 FROM message WHERE id = ?
|
|
1602
|
-
UNION ALL SELECT 1 FROM part WHERE id IN (?, ?) LIMIT 1`).get(other.summaryMessageId, other.compactionPartId, other.summaryPartId))
|
|
1576
|
+
const rows = db.prepare(`SELECT m.id AS summaryId, p.message_id AS boundaryId, p.id AS partId,
|
|
1577
|
+
p.data AS compactionData
|
|
1578
|
+
FROM message m LEFT JOIN part p ON p.message_id = json_extract(m.data, '$.parentID')
|
|
1579
|
+
AND +p.session_id = m.session_id
|
|
1580
|
+
AND json_extract(p.data, '$.type') = 'compaction'
|
|
1581
|
+
WHERE m.id = ? AND m.session_id = ? AND json_extract(m.data, '$.summary') = 1
|
|
1582
|
+
AND json_extract(m.data, '$.providerID') = 'magic-context'`).all(id, sessionId);
|
|
1583
|
+
const canonical = rows.filter((row) => isMcCanonicalCompactionPartData(JSON.parse(row.compactionData ?? "null")));
|
|
1584
|
+
if (rows.length > 0 && canonical.length === 0)
|
|
1603
1585
|
return { kind: "ambiguous" };
|
|
1586
|
+
pairs.push(...canonical);
|
|
1604
1587
|
}
|
|
1605
|
-
const
|
|
1588
|
+
const verified = [];
|
|
1589
|
+
for (const pair of pairs) {
|
|
1590
|
+
if (pair.partId === null)
|
|
1591
|
+
return { kind: "ambiguous" };
|
|
1592
|
+
if (verified.some((marker) => marker.boundaryMessageId === pair.boundaryId))
|
|
1593
|
+
return { kind: "ambiguous" };
|
|
1594
|
+
const row = db.prepare(`SELECT c.data AS compactionData, t.id AS summaryPartId,
|
|
1595
|
+
m.time_created AS timeCreated FROM message m
|
|
1606
1596
|
JOIN message b ON b.id = ? AND b.session_id = m.session_id
|
|
1607
1597
|
JOIN part c ON c.id = ? AND c.message_id = b.id AND c.session_id = m.session_id
|
|
1608
|
-
JOIN part t ON t.
|
|
1598
|
+
JOIN part t ON t.message_id = m.id AND t.session_id = m.session_id
|
|
1609
1599
|
WHERE m.id = ? AND m.session_id = ?
|
|
1610
1600
|
AND json_extract(b.data, '$.role') = 'user'
|
|
1611
1601
|
AND json_extract(m.data, '$.role') = 'assistant'
|
|
@@ -1616,10 +1606,39 @@ function inspectCompactionMarkerPublication(sessionId, recognized, summaryText)
|
|
|
1616
1606
|
AND json_extract(m.data, '$.providerID') = 'magic-context'
|
|
1617
1607
|
AND json_extract(m.data, '$.modelID') = 'magic-context'
|
|
1618
1608
|
AND json_extract(t.data, '$.type') = 'text' AND json_extract(t.data, '$.text') = ?
|
|
1619
|
-
AND (SELECT COUNT(*) FROM part p WHERE p.message_id = m.id AND +p.session_id = m.session_id) = 1`).get(
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1609
|
+
AND (SELECT COUNT(*) FROM part p WHERE p.message_id = m.id AND +p.session_id = m.session_id) = 1`).get(pair.boundaryId, pair.partId, pair.summaryId, sessionId, summaryText);
|
|
1610
|
+
const order = compareOpenCodeMessagesByCanonicalOrder(sessionId, pair.boundaryId, targetBoundaryMessageId);
|
|
1611
|
+
const isRecorded = preferred && preferred.summaryMessageId === pair.summaryId && preferred.boundaryMessageId === pair.boundaryId && preferred.compactionPartId === pair.partId && preferred.summaryPartId === row?.summaryPartId;
|
|
1612
|
+
if (!row || !isMcCanonicalCompactionPartData(JSON.parse(row.compactionData)) || findBoundaryUserMessage(sessionId, pair.boundaryId)?.id !== pair.boundaryId || order === null || order > 0 && !isRecorded)
|
|
1613
|
+
return { kind: "ambiguous" };
|
|
1614
|
+
verified.push({
|
|
1615
|
+
boundaryMessageId: pair.boundaryId,
|
|
1616
|
+
summaryMessageId: pair.summaryId,
|
|
1617
|
+
compactionPartId: pair.partId,
|
|
1618
|
+
summaryPartId: row.summaryPartId,
|
|
1619
|
+
timeCreated: row.timeCreated
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1622
|
+
const matches = (left, right) => left.summaryMessageId === right.summaryMessageId && left.boundaryMessageId === right.boundaryMessageId && left.compactionPartId === right.compactionPartId && left.summaryPartId === right.summaryPartId;
|
|
1623
|
+
for (const marker of recognized) {
|
|
1624
|
+
if (verified.some((item) => matches(item, marker)))
|
|
1625
|
+
continue;
|
|
1626
|
+
if (db.prepare(`SELECT 1 FROM message WHERE id = ?
|
|
1627
|
+
UNION ALL SELECT 1 FROM part WHERE id IN (?, ?) LIMIT 1`).get(marker.summaryMessageId, marker.compactionPartId, marker.summaryPartId))
|
|
1628
|
+
return { kind: "ambiguous" };
|
|
1629
|
+
}
|
|
1630
|
+
verified.sort((left, right) => right.timeCreated - left.timeCreated || (left.summaryMessageId < right.summaryMessageId ? 1 : -1));
|
|
1631
|
+
const state = (marker) => {
|
|
1632
|
+
if (!marker)
|
|
1633
|
+
return null;
|
|
1634
|
+
const { timeCreated: _, ...ids } = marker;
|
|
1635
|
+
return ids;
|
|
1636
|
+
};
|
|
1637
|
+
return {
|
|
1638
|
+
kind: "verified",
|
|
1639
|
+
marker: state(preferred && verified.find((item) => matches(item, preferred)) || verified[0]),
|
|
1640
|
+
markerAtTarget: state(verified.find((item) => item.boundaryMessageId === targetBoundaryMessageId))
|
|
1641
|
+
};
|
|
1623
1642
|
}
|
|
1624
1643
|
var LEGACY_MARKER_LINEAGE_SQL = `SELECT m.id
|
|
1625
1644
|
FROM message m
|
|
@@ -1659,7 +1678,7 @@ async function prepareCompactionMarkerCandidates(sessionId, options = {}) {
|
|
|
1659
1678
|
return false;
|
|
1660
1679
|
}
|
|
1661
1680
|
}
|
|
1662
|
-
function injectCompactionMarkerFromBasis(args, validatedBasis) {
|
|
1681
|
+
function injectCompactionMarkerFromBasis(args, validatedBasis, preserveExistingLineages = false) {
|
|
1663
1682
|
const db = getWritableOpenCodeDb();
|
|
1664
1683
|
if (!isOpenCodeSchemaCompatible(db, getOpenCodeDbPath())) {
|
|
1665
1684
|
return null;
|
|
@@ -1696,14 +1715,15 @@ function injectCompactionMarkerFromBasis(args, validatedBasis) {
|
|
|
1696
1715
|
runMarkerWriteTransaction(db, "compaction-marker-inject", () => {
|
|
1697
1716
|
if (!validatedBasis && !isMarkerCandidateBasisCurrent2(db, basis))
|
|
1698
1717
|
throw new Error("host store changed after marker candidate preparation; marker unchanged");
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1718
|
+
if (!preserveExistingLineages)
|
|
1719
|
+
removeLegacyMarkerLineageRows(db, {
|
|
1720
|
+
sessionId: args.sessionId,
|
|
1721
|
+
boundaryMessageId: boundary.id,
|
|
1722
|
+
candidateIds: basis.ids,
|
|
1723
|
+
summaryText: args.summaryText,
|
|
1724
|
+
summaryMessageId: summaryMsgId,
|
|
1725
|
+
compactionPartId
|
|
1726
|
+
});
|
|
1707
1727
|
db.prepare(`INSERT INTO part (id, message_id, session_id, time_created, time_updated, data)
|
|
1708
1728
|
VALUES (?, ?, ?, ?, ?, ?)
|
|
1709
1729
|
ON CONFLICT(id) DO UPDATE SET
|
|
@@ -1745,7 +1765,7 @@ function injectCompactionMarkerFromBasis(args, validatedBasis) {
|
|
|
1745
1765
|
|
|
1746
1766
|
class MarkerCandidateUnavailableError extends Error {
|
|
1747
1767
|
}
|
|
1748
|
-
function replaceCompactionMarker(existing, args) {
|
|
1768
|
+
function replaceCompactionMarker(existing, args, preserveExistingLineages = false) {
|
|
1749
1769
|
let connection;
|
|
1750
1770
|
let entered = false;
|
|
1751
1771
|
let readyToCommit = false;
|
|
@@ -1764,11 +1784,25 @@ function replaceCompactionMarker(existing, args) {
|
|
|
1764
1784
|
if (!isMarkerCandidateBasisCurrent2(db, basis))
|
|
1765
1785
|
throw new MarkerCandidateUnavailableError("host store changed after marker candidate preparation; marker unchanged");
|
|
1766
1786
|
if (existing) {
|
|
1787
|
+
const referenced = db.prepare(`WITH deleted(id) AS (VALUES (?), (?), (?)), surviving(data) AS (
|
|
1788
|
+
SELECT data FROM part WHERE session_id = ?
|
|
1789
|
+
AND id NOT IN (SELECT id FROM deleted)
|
|
1790
|
+
AND json_extract(data, '$.type') = 'compaction'
|
|
1791
|
+
UNION ALL
|
|
1792
|
+
SELECT data FROM message WHERE session_id = ?
|
|
1793
|
+
AND id NOT IN (SELECT id FROM deleted)
|
|
1794
|
+
)
|
|
1795
|
+
SELECT 1 FROM surviving
|
|
1796
|
+
WHERE json_extract(data, '$.tail_start_id') IN (SELECT id FROM deleted)
|
|
1797
|
+
OR json_extract(data, '$.compaction.tail_start_id') IN (SELECT id FROM deleted)
|
|
1798
|
+
LIMIT 1`).get(existing.summaryMessageId, existing.summaryPartId, existing.compactionPartId, args.sessionId, args.sessionId);
|
|
1799
|
+
if (referenced)
|
|
1800
|
+
throw new Error("a surviving tail_start_id references a recorded marker row; marker unchanged");
|
|
1767
1801
|
db.prepare("DELETE FROM part WHERE id = ?").run(existing.summaryPartId);
|
|
1768
1802
|
db.prepare("DELETE FROM message WHERE id = ?").run(existing.summaryMessageId);
|
|
1769
1803
|
db.prepare("DELETE FROM part WHERE id = ?").run(existing.compactionPartId);
|
|
1770
1804
|
}
|
|
1771
|
-
const replacement = injectCompactionMarkerFromBasis(args, basis);
|
|
1805
|
+
const replacement = injectCompactionMarkerFromBasis(args, basis, preserveExistingLineages);
|
|
1772
1806
|
if (!replacement) {
|
|
1773
1807
|
throw new Error(`failed to inject replacement marker at ordinal ${args.endOrdinal}`);
|
|
1774
1808
|
}
|
|
@@ -3921,6 +3955,18 @@ function messageId(message) {
|
|
|
3921
3955
|
const id = infoOf(message).id;
|
|
3922
3956
|
return typeof id === "string" ? id : null;
|
|
3923
3957
|
}
|
|
3958
|
+
function recordedAssistantError(message) {
|
|
3959
|
+
const info = infoOf(message);
|
|
3960
|
+
if (info.error != null)
|
|
3961
|
+
return info.error;
|
|
3962
|
+
if (isSettledAssistant(message))
|
|
3963
|
+
return;
|
|
3964
|
+
const parts = message?.parts;
|
|
3965
|
+
if (!Array.isArray(parts))
|
|
3966
|
+
return;
|
|
3967
|
+
const retry = parts.slice().reverse().find((part) => part !== null && typeof part === "object" && part.type === "retry");
|
|
3968
|
+
return retry?.error ?? undefined;
|
|
3969
|
+
}
|
|
3924
3970
|
function isSettledAssistant(message) {
|
|
3925
3971
|
const info = infoOf(message);
|
|
3926
3972
|
if (info.role !== "assistant")
|
|
@@ -4036,6 +4082,22 @@ async function promptAsyncAndWaitForIdle(client, request, options = {}) {
|
|
|
4036
4082
|
let completionBaseline = new Set((await readMessages(session, sessionId, dir, signal)).map(messageId).filter((id) => id !== null));
|
|
4037
4083
|
const initialBaseline = new Set(completionBaseline);
|
|
4038
4084
|
activeSessionErrors.set(sessionId, undefined);
|
|
4085
|
+
const failForHostError = async (hostError) => {
|
|
4086
|
+
await abortChildRun(client, sessionId);
|
|
4087
|
+
const error = new Error(`Host recorded session error: ${describeAssistantError(hostError)}`);
|
|
4088
|
+
Object.assign(error, {
|
|
4089
|
+
name: "DreamerProviderOutputFailureError",
|
|
4090
|
+
transient: true,
|
|
4091
|
+
[HOST_SESSION_ERROR]: true,
|
|
4092
|
+
hostError
|
|
4093
|
+
});
|
|
4094
|
+
annotateSubagentInvocationError(error, {
|
|
4095
|
+
attemptedModel: requestModelRef(request),
|
|
4096
|
+
modelConfigKey: options.modelConfigKey,
|
|
4097
|
+
hostError
|
|
4098
|
+
});
|
|
4099
|
+
throw error;
|
|
4100
|
+
};
|
|
4039
4101
|
try {
|
|
4040
4102
|
let sent;
|
|
4041
4103
|
try {
|
|
@@ -4070,22 +4132,17 @@ async function promptAsyncAndWaitForIdle(client, request, options = {}) {
|
|
|
4070
4132
|
await sleep(pollIntervalMs, signal);
|
|
4071
4133
|
const hostError = activeSessionErrors.get(sessionId);
|
|
4072
4134
|
if (hostError !== undefined) {
|
|
4073
|
-
|
|
4074
|
-
Object.assign(error, {
|
|
4075
|
-
name: "DreamerProviderOutputFailureError",
|
|
4076
|
-
transient: true,
|
|
4077
|
-
[HOST_SESSION_ERROR]: true,
|
|
4078
|
-
hostError
|
|
4079
|
-
});
|
|
4080
|
-
annotateSubagentInvocationError(error, {
|
|
4081
|
-
attemptedModel: requestModelRef(request),
|
|
4082
|
-
modelConfigKey: options.modelConfigKey,
|
|
4083
|
-
hostError
|
|
4084
|
-
});
|
|
4085
|
-
throw error;
|
|
4135
|
+
await failForHostError(hostError);
|
|
4086
4136
|
}
|
|
4087
4137
|
const status = await readStatus(session, sessionId, dir, signal);
|
|
4088
4138
|
const messages = await readMessages(session, sessionId, dir, signal);
|
|
4139
|
+
const latestAssistant = messages.slice().reverse().find((message) => {
|
|
4140
|
+
const id = messageId(message);
|
|
4141
|
+
return id !== null && !completionBaseline.has(id) && infoOf(message).role === "assistant";
|
|
4142
|
+
});
|
|
4143
|
+
const assistantError = recordedAssistantError(latestAssistant);
|
|
4144
|
+
if (assistantError !== undefined)
|
|
4145
|
+
await failForHostError(assistantError);
|
|
4089
4146
|
if (!sawOutput && messages.some((message) => {
|
|
4090
4147
|
const id = messageId(message);
|
|
4091
4148
|
return id !== null && !initialBaseline.has(id) && showsModelOutput(message);
|
|
@@ -4380,7 +4437,7 @@ function publishRecoverableCompactionMarker(db, args, targetIsCurrent) {
|
|
|
4380
4437
|
if (!validTarget || !pendingBoundary || !pendingTarget || !samePair(pending, planCompactionMarker({ ...args, endMessageId: pendingTarget }, pendingBoundary)))
|
|
4381
4438
|
pending = null;
|
|
4382
4439
|
}
|
|
4383
|
-
const inspection = inspectCompactionMarkerPublication(sessionId, [intended, ...previous ? [previous] : [], ...pending ? [pending] : []], args.summaryText);
|
|
4440
|
+
const inspection = inspectCompactionMarkerPublication(sessionId, [intended, ...previous ? [previous] : [], ...pending ? [pending] : []], args.summaryText, boundary.id, previous);
|
|
4384
4441
|
if (inspection.kind === "deferred") {
|
|
4385
4442
|
reason = "candidate-preparation";
|
|
4386
4443
|
return {
|
|
@@ -4397,22 +4454,34 @@ function publishRecoverableCompactionMarker(db, args, targetIsCurrent) {
|
|
|
4397
4454
|
}
|
|
4398
4455
|
cut = "definitely-no-cut";
|
|
4399
4456
|
const host = inspection.marker;
|
|
4400
|
-
if (
|
|
4401
|
-
const
|
|
4402
|
-
|
|
4457
|
+
if (inspection.markerAtTarget) {
|
|
4458
|
+
const hostOrder = host ? compareOpenCodeMessagesByCanonicalOrder(sessionId, host.boundaryMessageId, boundary.id) : 0;
|
|
4459
|
+
if (hostOrder === null || hostOrder > 0) {
|
|
4460
|
+
reason = "ahead-of-target-left-alone";
|
|
4461
|
+
return {
|
|
4462
|
+
kind: cut,
|
|
4463
|
+
error: new Error("a later recorded host cut prevents target adoption")
|
|
4464
|
+
};
|
|
4465
|
+
}
|
|
4466
|
+
intended = { ...intended, ...inspection.markerAtTarget };
|
|
4467
|
+
recovered = pending && samePair(intended, pending) ? "pending-intent-recovered" : "adopted-existing-pair";
|
|
4403
4468
|
cut = "uncertain";
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4469
|
+
return { kind: "committed", marker: inspection.markerAtTarget };
|
|
4470
|
+
}
|
|
4471
|
+
if (host && pending && samePair(host, pending)) {
|
|
4472
|
+
recovered = "pending-intent-recovered";
|
|
4473
|
+
cut = "uncertain";
|
|
4474
|
+
persist(pending);
|
|
4407
4475
|
}
|
|
4408
4476
|
writingState = true;
|
|
4409
4477
|
raw = compareAndSetCompactionMarkerPublicationState(db, sessionId, raw, previous, intended);
|
|
4410
4478
|
writingState = false;
|
|
4411
4479
|
cut = "uncertain";
|
|
4412
|
-
const
|
|
4480
|
+
const ownedHost = host && (previous && samePair(host, previous) || pending && samePair(host, pending)) ? host : null;
|
|
4481
|
+
const replacement = replaceCompactionMarker(ownedHost, {
|
|
4413
4482
|
...args,
|
|
4414
4483
|
resolvedBoundary: boundary
|
|
4415
|
-
});
|
|
4484
|
+
}, true);
|
|
4416
4485
|
if (recovered && replacement.kind !== "committed")
|
|
4417
4486
|
return { kind: "uncertain", error: replacement.error };
|
|
4418
4487
|
if (replacement.kind !== "committed")
|
|
@@ -12027,6 +12096,7 @@ function createV1HiddenCompletionExecutor(client, db, directory) {
|
|
|
12027
12096
|
async attempt(handle, request) {
|
|
12028
12097
|
if (!client)
|
|
12029
12098
|
throw new Error("Hidden completion client is unavailable");
|
|
12099
|
+
hostErrors.delete(handle.id);
|
|
12030
12100
|
const identity = runIdentities.get(handle.id);
|
|
12031
12101
|
const requestedModel = request.body?.model;
|
|
12032
12102
|
const requestedRef = requestedModel && typeof requestedModel.providerID === "string" && typeof requestedModel.modelID === "string" ? `${requestedModel.providerID}/${requestedModel.modelID}` : undefined;
|
|
@@ -12069,9 +12139,9 @@ function createV1HiddenCompletionExecutor(client, db, directory) {
|
|
|
12069
12139
|
});
|
|
12070
12140
|
const assistantFailure = extractLatestAssistantFailure(messages);
|
|
12071
12141
|
const hostError = hostErrors.get(handle.id);
|
|
12072
|
-
if (assistantFailure) {
|
|
12073
|
-
const finish = assistantFailure
|
|
12074
|
-
const error = new Error(`Historian host recorded an assistant error${finish}: ${describeAssistantFailure(assistantFailure
|
|
12142
|
+
if (assistantFailure || hostError !== undefined) {
|
|
12143
|
+
const finish = assistantFailure?.finish ? ` (finish=${assistantFailure.finish})` : "";
|
|
12144
|
+
const error = new Error(`Historian host recorded an assistant error${finish}: ${describeAssistantFailure(assistantFailure?.error ?? hostError)}`, hostError === undefined ? undefined : { cause: hostError });
|
|
12075
12145
|
annotateSubagentInvocationError(error, {
|
|
12076
12146
|
attemptedModel: handle.attemptedModel,
|
|
12077
12147
|
modelConfigKey: handle.modelConfigKey,
|
|
@@ -13211,7 +13281,9 @@ function resolveProtectedTailBoundary(ctx) {
|
|
|
13211
13281
|
const offset = Math.max(1, ctx.lastCompartmentEndOrdinal + 1);
|
|
13212
13282
|
const absoluteMessageCount = getCachedAbsoluteMessageCount2(ctx.sessionId) ?? getRawSessionMessageOrdinalCount2(ctx.sessionId);
|
|
13213
13283
|
const messages = readRawSessionMessageRange2(ctx.sessionId, Math.max(1, offset - 1), absoluteMessageCount);
|
|
13214
|
-
const
|
|
13284
|
+
const storedWeights = ctx.storedTokenTotalsForMessages?.(messages.map((m) => m.id), messages);
|
|
13285
|
+
const storedTotals = storedWeights?.totals ?? ctx.storedTokenTotals;
|
|
13286
|
+
const storedRemovedTotals = storedWeights?.summaryRemovedTotals ?? ctx.storedSummaryRemovedTokenTotals;
|
|
13215
13287
|
const index = buildTrueRawTokenIndex(ctx.sessionId, messages, {
|
|
13216
13288
|
providerShapeVersion: ctx.providerShapeVersion,
|
|
13217
13289
|
cacheNamespace: ctx.cacheNamespace,
|
|
@@ -13222,6 +13294,14 @@ function resolveProtectedTailBoundary(ctx) {
|
|
|
13222
13294
|
return v === undefined ? null : v;
|
|
13223
13295
|
} : undefined
|
|
13224
13296
|
});
|
|
13297
|
+
const summaryRemovedIndex = buildTrueRawTokenIndex(ctx.sessionId, messages, {
|
|
13298
|
+
providerShapeVersion: ctx.providerShapeVersion,
|
|
13299
|
+
cacheNamespace: ctx.cacheNamespace,
|
|
13300
|
+
calibration: ctx.calibration,
|
|
13301
|
+
absoluteMessageCount,
|
|
13302
|
+
measure: "summary-removed",
|
|
13303
|
+
storedTotalForMessage: storedRemovedTotals ? (m) => storedRemovedTotals.get(m.id) ?? null : undefined
|
|
13304
|
+
});
|
|
13225
13305
|
const rawMessageCount = index.rawMessageCount;
|
|
13226
13306
|
const usagePercentage = clampPercentage(ctx.usage?.percentage ?? 0);
|
|
13227
13307
|
const usageInputTokens = Math.max(0, Math.round(ctx.usage?.inputTokens ?? 0));
|
|
@@ -13253,6 +13333,7 @@ function resolveProtectedTailBoundary(ctx) {
|
|
|
13253
13333
|
createdAt,
|
|
13254
13334
|
rawRangeFingerprint: "",
|
|
13255
13335
|
trueRawEligibleTokens: 0,
|
|
13336
|
+
summaryRemovedEligibleTokens: 0,
|
|
13256
13337
|
oversizeAtomicUnit: false,
|
|
13257
13338
|
boundaryReason: "empty-session"
|
|
13258
13339
|
};
|
|
@@ -13296,6 +13377,7 @@ function resolveProtectedTailBoundary(ctx) {
|
|
|
13296
13377
|
createdAt,
|
|
13297
13378
|
rawRangeFingerprint,
|
|
13298
13379
|
trueRawEligibleTokens: index.rangeTokens(offset, protectedTailStart),
|
|
13380
|
+
summaryRemovedEligibleTokens: summaryRemovedIndex.rangeTokens(offset, protectedTailStart),
|
|
13299
13381
|
oversizeAtomicUnit: false,
|
|
13300
13382
|
boundaryReason: firstOpenArc ? "open-tool-arc" : "manual-full-recomp"
|
|
13301
13383
|
};
|
|
@@ -13372,7 +13454,7 @@ function resolveProtectedTailBoundary(ctx) {
|
|
|
13372
13454
|
observeDiagnostics: (value) => {
|
|
13373
13455
|
headDiagnostics = value;
|
|
13374
13456
|
},
|
|
13375
|
-
index,
|
|
13457
|
+
index: summaryRemovedIndex,
|
|
13376
13458
|
protectedTailStart,
|
|
13377
13459
|
offset,
|
|
13378
13460
|
arcs,
|
|
@@ -13411,6 +13493,7 @@ function resolveProtectedTailBoundary(ctx) {
|
|
|
13411
13493
|
createdAt,
|
|
13412
13494
|
rawRangeFingerprint,
|
|
13413
13495
|
trueRawEligibleTokens: index.rangeTokens(offset, eligibleEndOrdinal),
|
|
13496
|
+
summaryRemovedEligibleTokens: summaryRemovedIndex.rangeTokens(offset, eligibleEndOrdinal),
|
|
13414
13497
|
oversizeAtomicUnit: head.oversizeAtomicUnit,
|
|
13415
13498
|
boundaryReason,
|
|
13416
13499
|
diagnostics: boundaryDiagnostics({
|
|
@@ -13458,8 +13541,11 @@ function resolveBoundaryContext(args) {
|
|
|
13458
13541
|
const calibration = sessionDecisionCalibration(args.db, args.sessionId);
|
|
13459
13542
|
const storedTokenTotalsForMessages = (messageIds, messages = []) => {
|
|
13460
13543
|
try {
|
|
13461
|
-
const
|
|
13462
|
-
return
|
|
13544
|
+
const weights = getAllStatusTagTokenTotalsFlat2(args.db, args.sessionId, args.taggerFloor ?? 0, calibration, messageIds);
|
|
13545
|
+
return {
|
|
13546
|
+
totals: omitIncompleteFileTokenTotals(args.db, args.sessionId, messages, weights.totals),
|
|
13547
|
+
summaryRemovedTotals: weights.summaryRemovedTotals
|
|
13548
|
+
};
|
|
13463
13549
|
} catch (error) {
|
|
13464
13550
|
sessionLog2(args.sessionId, "protected-tail stored-token map unavailable (live fallback):", error);
|
|
13465
13551
|
return;
|
|
@@ -13495,7 +13581,9 @@ function resolveWrapupProtectedTailBoundary(args) {
|
|
|
13495
13581
|
const offset = Math.max(1, ctx.lastCompartmentEndOrdinal + 1);
|
|
13496
13582
|
const absoluteMessageCount = getCachedAbsoluteMessageCount2(ctx.sessionId) ?? getRawSessionMessageOrdinalCount2(ctx.sessionId);
|
|
13497
13583
|
const messages = readRawSessionMessageRange2(ctx.sessionId, Math.max(1, offset - 1), absoluteMessageCount);
|
|
13498
|
-
const
|
|
13584
|
+
const storedWeights = ctx.storedTokenTotalsForMessages?.(messages.map((m) => m.id), messages);
|
|
13585
|
+
const storedTotals = storedWeights?.totals ?? ctx.storedTokenTotals;
|
|
13586
|
+
const storedRemovedTotals = storedWeights?.summaryRemovedTotals ?? ctx.storedSummaryRemovedTokenTotals;
|
|
13499
13587
|
const index = buildTrueRawTokenIndex(ctx.sessionId, messages, {
|
|
13500
13588
|
providerShapeVersion: ctx.providerShapeVersion,
|
|
13501
13589
|
cacheNamespace: ctx.cacheNamespace,
|
|
@@ -13506,6 +13594,14 @@ function resolveWrapupProtectedTailBoundary(args) {
|
|
|
13506
13594
|
return value === undefined ? null : value;
|
|
13507
13595
|
} : undefined
|
|
13508
13596
|
});
|
|
13597
|
+
const summaryRemovedIndex = buildTrueRawTokenIndex(ctx.sessionId, messages, {
|
|
13598
|
+
providerShapeVersion: ctx.providerShapeVersion,
|
|
13599
|
+
cacheNamespace: ctx.cacheNamespace,
|
|
13600
|
+
calibration: ctx.calibration,
|
|
13601
|
+
absoluteMessageCount,
|
|
13602
|
+
measure: "summary-removed",
|
|
13603
|
+
storedTotalForMessage: storedRemovedTotals ? (m) => storedRemovedTotals.get(m.id) ?? null : undefined
|
|
13604
|
+
});
|
|
13509
13605
|
const rawMessageCount = index.rawMessageCount;
|
|
13510
13606
|
const anchorRawMessageCount = Math.max(0, Math.min(rawMessageCount, Math.floor(args.anchorRawMessageCount ?? rawMessageCount)));
|
|
13511
13607
|
const usagePercentage = clampPercentage(ctx.usage?.percentage ?? 0);
|
|
@@ -13567,7 +13663,7 @@ function resolveWrapupProtectedTailBoundary(args) {
|
|
|
13567
13663
|
observeDiagnostics: (value) => {
|
|
13568
13664
|
headDiagnostics = value;
|
|
13569
13665
|
},
|
|
13570
|
-
index,
|
|
13666
|
+
index: summaryRemovedIndex,
|
|
13571
13667
|
protectedTailStart: targetProtectedTailStart,
|
|
13572
13668
|
offset,
|
|
13573
13669
|
arcs: buildToolArcs(messages),
|
|
@@ -13604,6 +13700,7 @@ function resolveWrapupProtectedTailBoundary(args) {
|
|
|
13604
13700
|
createdAt,
|
|
13605
13701
|
rawRangeFingerprint,
|
|
13606
13702
|
trueRawEligibleTokens: index.rangeTokens(offset, targetProtectedTailStart),
|
|
13703
|
+
summaryRemovedEligibleTokens: summaryRemovedIndex.rangeTokens(offset, eligibleEndOrdinal),
|
|
13607
13704
|
oversizeAtomicUnit: head.oversizeAtomicUnit,
|
|
13608
13705
|
boundaryReason,
|
|
13609
13706
|
diagnostics: boundaryDiagnostics({
|
|
@@ -14210,7 +14307,7 @@ async function runCompartmentAgent(deps) {
|
|
|
14210
14307
|
db,
|
|
14211
14308
|
sessionId,
|
|
14212
14309
|
runId: crypto.randomUUID(),
|
|
14213
|
-
trueRawTokens: boundarySnapshot.
|
|
14310
|
+
trueRawTokens: boundarySnapshot.summaryRemovedEligibleTokens,
|
|
14214
14311
|
usagePercentage: boundarySnapshot.usagePercentage,
|
|
14215
14312
|
usable,
|
|
14216
14313
|
perRunCap,
|
|
@@ -265,8 +265,7 @@ ${data.output?.output ?? ""}`
|
|
|
265
265
|
name: part.name,
|
|
266
266
|
providerExecuted: part.executed,
|
|
267
267
|
providerMetadata: (part.executed === true ? sameProvider : reuse) ? metadata(native) : undefined,
|
|
268
|
-
result: state.status === "error" ? { error: state.error, content: toolContent } : single?.type === "text" ? { type: "text", value: single.text } : { type: "content", value: toolContent }
|
|
269
|
-
...state.status === "error" ? { resultType: "error" } : {}
|
|
268
|
+
result: state.status === "error" ? { type: "error", value: { error: state.error, content: toolContent } } : single?.type === "text" ? { type: "text", value: single.text } : { type: "content", value: toolContent }
|
|
270
269
|
};
|
|
271
270
|
if (part.executed === true)
|
|
272
271
|
content.push(result);
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./server-69m30b21.js";
|
|
16
16
|
import {
|
|
17
17
|
isRecord
|
|
18
|
-
} from "./server-
|
|
18
|
+
} from "./server-xfjjbrkt.js";
|
|
19
19
|
import {
|
|
20
20
|
cleanSearchText,
|
|
21
21
|
keywordRelevance,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
isMessageIndexReconciledThrough,
|
|
26
26
|
clearIndexedMessages,
|
|
27
27
|
indexMessagesAfterOrdinal
|
|
28
|
-
} from "./server-
|
|
28
|
+
} from "./server-dfq5vb8j.js";
|
|
29
29
|
import {
|
|
30
30
|
Priority,
|
|
31
31
|
AdmissionClass,
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
loadCompartmentChunkEmbeddingsForSearch2,
|
|
41
41
|
peekCompartmentChunkSearchPool2,
|
|
42
42
|
warmCompartmentChunkSearchPool2
|
|
43
|
-
} from "./server-
|
|
43
|
+
} from "./server-cp1a03vc.js";
|
|
44
44
|
import {
|
|
45
45
|
saveCommitEmbedding,
|
|
46
46
|
loadProjectCommitEmbeddings,
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
enqueueShadowEmbeddingItems2,
|
|
57
57
|
getProjectEmbeddingSnapshot2,
|
|
58
58
|
embedItemsForProject2
|
|
59
|
-
} from "./server-
|
|
59
|
+
} from "./server-7acq7815.js";
|
|
60
60
|
import {
|
|
61
61
|
recordEmbeddingMeasurement
|
|
62
62
|
} from "./server-2amn2s73.js";
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
isEmbeddingEnabled,
|
|
69
69
|
embedText,
|
|
70
70
|
ensureMemoryEmbeddings2
|
|
71
|
-
} from "./server-
|
|
71
|
+
} from "./server-gkse1wyz.js";
|
|
72
72
|
import {
|
|
73
73
|
ModuleMemoryAuthorityError2,
|
|
74
74
|
getMemoriesByProject2,
|
|
@@ -81,7 +81,7 @@ import {
|
|
|
81
81
|
sanitizeFtsQuery,
|
|
82
82
|
searchMemoriesFTS,
|
|
83
83
|
searchMemoriesFTSUnion
|
|
84
|
-
} from "./server-
|
|
84
|
+
} from "./server-nq3cb7be.js";
|
|
85
85
|
import {
|
|
86
86
|
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
87
87
|
withMessageFtsSessionFilter
|
|
@@ -1766,6 +1766,7 @@ var RERANK_MODEL = "gte-reranker-modernbert-base-f32";
|
|
|
1766
1766
|
var RERANK_LANE_LIMIT = 25;
|
|
1767
1767
|
var DEADLINE_MS = 1500;
|
|
1768
1768
|
var DOCUMENT_BYTES = 1024;
|
|
1769
|
+
var proseWordSegmenter = new Intl.Segmenter(undefined, { granularity: "word" });
|
|
1769
1770
|
function isProseQuery(query) {
|
|
1770
1771
|
const text = query.trim();
|
|
1771
1772
|
if (!text || /[\n;]|^["'`]|["'`]$/.test(text))
|
|
@@ -1774,10 +1775,10 @@ function isProseQuery(query) {
|
|
|
1774
1775
|
return false;
|
|
1775
1776
|
if (/\b(?:[A-Z][A-Z_]+:|\w*(?:Error|Exception):)|\bat\s+\S+\s*\(/.test(text))
|
|
1776
1777
|
return false;
|
|
1777
|
-
const words = text.replace(/[?!.]$/, "").split(/\s+/);
|
|
1778
|
+
const words = /(?![a-zA-Z])\p{L}/u.test(text) ? [...proseWordSegmenter.segment(text)].filter((word) => word.isWordLike).map((word) => word.segment) : text.replace(/[?!.]$/, "").split(/\s+/);
|
|
1778
1779
|
if (words.length < 3)
|
|
1779
1780
|
return false;
|
|
1780
|
-
const plain = words.filter((word) => /^[
|
|
1781
|
+
const plain = words.filter((word) => /^[\p{L}\p{M}]+(?:['’-][\p{L}\p{M}]+)*$/u.test(word));
|
|
1781
1782
|
if (/^(?:how|why|what|where|when|which|who)\b/i.test(text))
|
|
1782
1783
|
return plain.length >= 3;
|
|
1783
1784
|
return words.length >= 4 && plain.length >= 3 && !/[\\/]|::|=/.test(text);
|