@cortexkit/opencode-magic-context 0.49.92 → 0.49.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/chunk-embedding-write-worker.js +1 -1
  3. package/dist/{context-e8qd2v00.js → context-jpxthqxg.js} +34 -25
  4. package/dist/{embedding-backfill-w0yq71q2.js → embedding-backfill-6wzc4p2n.js} +4 -4
  5. package/dist/embedding-worker.js +2 -2
  6. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  7. package/dist/features/magic-context/memory/embedding-worker-client.d.ts +3 -0
  8. package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
  9. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
  10. package/dist/hooks/magic-context/lkg-measured-request.d.ts +1 -0
  11. package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -1
  12. package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
  13. package/dist/hooks/magic-context/lkg-replay.d.ts +1 -0
  14. package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
  15. package/dist/{index-5a9kwapd.js → index-1kem0xxx.js} +4 -4
  16. package/dist/{index-f25ha337.js → index-5zrzg8r1.js} +1 -1
  17. package/dist/{index-5y9w2ax7.js → index-dr6bd4c8.js} +2 -2
  18. package/dist/{index-41bma6qs.js → index-fpjnjxyx.js} +2 -2
  19. package/dist/{index-zzhcshdk.js → index-g5c67kay.js} +9 -9
  20. package/dist/{index-xg1zjht5.js → index-g6y2wk32.js} +3 -3
  21. package/dist/{index-5pmf4jpj.js → index-g9qtxv87.js} +6 -6
  22. package/dist/{index-6rk44cer.js → index-gqfy38m9.js} +1 -1
  23. package/dist/{index-n71006wq.js → index-hee64h6k.js} +5 -5
  24. package/dist/{index-xn9efn18.js → index-hes3k87g.js} +12 -5
  25. package/dist/{index-hbn5g7rt.js → index-kty5k23y.js} +1 -1
  26. package/dist/{index-3n376ann.js → index-n9kd68vc.js} +2 -2
  27. package/dist/{index-hre29c1a.js → index-pnawfv4e.js} +1 -1
  28. package/dist/{index-wvbg9m0h.js → index-rz47hf2m.js} +2 -2
  29. package/dist/{index-ydhymf0b.js → index-ttdk2w0z.js} +3 -3
  30. package/dist/{index-901exj0f.js → index-xr1t0fxb.js} +1 -1
  31. package/dist/{index-r3tdqqtq.js → index-y2vshk67.js} +21 -23
  32. package/dist/{index-6nqz8hsz.js → index-y915t3ey.js} +1 -1
  33. package/dist/{index-anwy2mfb.js → index-yqha238s.js} +44 -23
  34. package/dist/{index-3f3d548g.js → index-za1yx1m4.js} +8 -8
  35. package/dist/index.js +23 -23
  36. package/dist/{message-index-bounded-f6fc00ze.js → message-index-bounded-vjrnptar.js} +4 -4
  37. package/dist/migration-worker.js +1 -1
  38. package/dist/{project-embedding-registry-8je0xg18.js → project-embedding-registry-m8zcmrsg.js} +3 -3
  39. package/dist/raw-ordinal-warmup-worker.js +4 -4
  40. package/dist/{read-session-chunk-y2ew3630.js → read-session-chunk-zkzdc0e5.js} +3 -3
  41. package/dist/{recomp-orchestrator-ggtcvb9g.js → recomp-orchestrator-qb2hymj5.js} +12 -12
  42. package/dist/{render-q8c6wrq9.js → render-34p0kek8.js} +7 -7
  43. package/dist/{search-archive-pz1jf655.js → search-archive-08ppk0q5.js} +5 -5
  44. package/dist/{search-gjyrwapc.js → search-e9bb9hpx.js} +10 -10
  45. package/dist/{storage-tags-7raphcw6.js → storage-tags-gk7gjkqt.js} +2 -2
  46. package/dist/{transform-postprocess-phase-pmzdd3s2.js → transform-postprocess-phase-neds90e3.js} +13 -13
  47. package/dist/v2/auto-search-worker.js +3 -3
  48. package/dist/v2/chunk-embedding-write-worker.js +1 -1
  49. package/dist/v2/{context-qqbpzk1q.js → context-ctsd80vc.js} +35 -28
  50. package/dist/v2/{embedding-backfill-95m72gxa.js → embedding-backfill-40g0anxh.js} +4 -4
  51. package/dist/v2/embedding-worker.js +2 -2
  52. package/dist/v2/fold/native-replay.d.ts.map +1 -1
  53. package/dist/v2/{message-index-bounded-70g28hyg.js → message-index-bounded-1vew9c37.js} +4 -4
  54. package/dist/v2/migration-worker.js +1 -1
  55. package/dist/v2/{project-embedding-registry-fcxf4qht.js → project-embedding-registry-je5jam7y.js} +3 -3
  56. package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
  57. package/dist/v2/{read-session-chunk-9rf0n9e6.js → read-session-chunk-09sre4xv.js} +3 -3
  58. package/dist/v2/{recomp-orchestrator-cwghhjc9.js → recomp-orchestrator-mgcty3we.js} +12 -12
  59. package/dist/v2/{render-e852zmxz.js → render-ygcmyn9x.js} +7 -7
  60. package/dist/v2/{search-archive-tmn6b5w8.js → search-archive-nrsqqmk5.js} +5 -5
  61. package/dist/v2/{search-jd3vczhn.js → search-gmye6n25.js} +9 -9
  62. package/dist/v2/{server-vsqmkvxc.js → server-00adcfjd.js} +1 -1
  63. package/dist/v2/{server-mgxqfprb.js → server-2xm0gxke.js} +1 -1
  64. package/dist/v2/{server-6t3asmx8.js → server-4ecpanyn.js} +44 -23
  65. package/dist/v2/{server-7e89a2kf.js → server-6chcnnhq.js} +12 -5
  66. package/dist/v2/{server-ysjjcatk.js → server-6x40bnb7.js} +2 -2
  67. package/dist/v2/{server-bvr9xs8h.js → server-bnkc9kph.js} +3 -3
  68. package/dist/v2/{server-fj3pekz2.js → server-btgnkr9z.js} +1 -1
  69. package/dist/v2/{server-7x5a46hf.js → server-cvp9w5gs.js} +9 -9
  70. package/dist/v2/{server-9011eteb.js → server-dgsjamm4.js} +2 -2
  71. package/dist/v2/{server-rz6g5xne.js → server-e6xneh68.js} +1 -1
  72. package/dist/v2/{server-p4g021y5.js → server-g53asaqt.js} +2 -2
  73. package/dist/v2/{server-b4efn08m.js → server-k1xc2bw1.js} +1 -1
  74. package/dist/v2/{server-js2v309w.js → server-myp4pc6x.js} +5 -5
  75. package/dist/v2/{server-72k2r3kt.js → server-pcarsvj2.js} +2 -2
  76. package/dist/v2/{server-8ps3717t.js → server-vc5fta6s.js} +3 -3
  77. package/dist/v2/{server-d4trxrj3.js → server-z9czv2vb.js} +1 -1
  78. package/dist/v2/server.js +4 -4
  79. package/dist/v2/{storage-tags-wgsemtw1.js → storage-tags-nccqr0kr.js} +2 -2
  80. package/dist/v2/{v2-archive-reader-dm1aeqk2.js → v2-archive-reader-7vmng8q7.js} +1 -1
  81. package/dist/v2/{wrapup-orchestrator-cke368np.js → wrapup-orchestrator-7r4y0bf6.js} +12 -12
  82. package/dist/{v2-archive-reader-39ye0d3b.js → v2-archive-reader-7s90gfax.js} +1 -1
  83. package/dist/{wrapup-orchestrator-ggnk0r4r.js → wrapup-orchestrator-m2p89973.js} +13 -13
  84. package/package.json +1 -1
  85. package/src/config/schema/magic-context.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_LOCAL_EMBEDDING_MODEL
3
- } from "./index-6nqz8hsz.js";
3
+ } from "./index-y915t3ey.js";
4
4
  import {
5
5
  getSynapseLaneIdentity
6
6
  } from "./index-6r99v53h.js";
@@ -795,6 +795,11 @@ async function prepareNativeOnnxTelemetry() {
795
795
  }
796
796
 
797
797
  // src/features/magic-context/memory/embedding-worker-client.ts
798
+ class EmbeddingRequestAbortedError extends Error {
799
+ constructor() {
800
+ super("embedding request aborted");
801
+ }
802
+ }
798
803
  var warnedWindowsTelemetry = false;
799
804
  var EMBEDDING_WORKER_STOP_GRACE_MS = 5000;
800
805
  var EMBEDDING_WORKER_FORCED_EXIT_WAIT_MS = 2000;
@@ -968,7 +973,7 @@ class EmbeddingWorkerClient {
968
973
  }
969
974
  async request(texts, signal) {
970
975
  if (signal?.aborted)
971
- return Promise.reject(new Error("embedding request aborted"));
976
+ throw new EmbeddingRequestAbortedError;
972
977
  this.activeRequests++;
973
978
  this.clearIdleTimer();
974
979
  try {
@@ -998,7 +1003,7 @@ class EmbeddingWorkerClient {
998
1003
  if (this.disposed)
999
1004
  throw new Error("embedding worker disposed");
1000
1005
  if (signal?.aborted)
1001
- throw new Error("embedding request aborted");
1006
+ throw new EmbeddingRequestAbortedError;
1002
1007
  return new Promise((resolve, reject) => {
1003
1008
  const id = this.nextId++;
1004
1009
  const timer = setTimeout(() => {
@@ -1008,7 +1013,7 @@ class EmbeddingWorkerClient {
1008
1013
  clearTimeout(timer);
1009
1014
  this.pending.delete(id);
1010
1015
  signal?.removeEventListener("abort", abort);
1011
- reject(new Error("embedding request aborted"));
1016
+ reject(new EmbeddingRequestAbortedError);
1012
1017
  if (this.pending.size === 0) {
1013
1018
  worker.unref();
1014
1019
  if (!(worker instanceof Worker))
@@ -1729,7 +1734,9 @@ class LocalEmbeddingProvider {
1729
1734
  this.recordWorkerReply(reply);
1730
1735
  return reply.vectors ?? texts.map(() => null);
1731
1736
  } catch (error) {
1732
- this.recordWorkerFailure(error);
1737
+ if (!(signal?.aborted && error instanceof EmbeddingRequestAbortedError)) {
1738
+ this.recordWorkerFailure(error);
1739
+ }
1733
1740
  return texts.map(() => null);
1734
1741
  }
1735
1742
  }
@@ -28,7 +28,7 @@ import {
28
28
  clearIndexedMessages,
29
29
  indexSingleMessage,
30
30
  indexMessagesAfterOrdinal
31
- } from "./index-hre29c1a.js";
31
+ } from "./index-pnawfv4e.js";
32
32
 
33
33
  // src/features/magic-context/message-index-async.ts
34
34
  var indexCancellations = new Map;
@@ -46,7 +46,7 @@ import {
46
46
  } from "./index-0twg41mh.js";
47
47
  import {
48
48
  DEFAULT_LOCAL_EMBEDDING_MODEL
49
- } from "./index-6nqz8hsz.js";
49
+ } from "./index-y915t3ey.js";
50
50
  import {
51
51
  embeddingModelsMatch,
52
52
  resolveEmbeddingTextPrefixes,
@@ -56,7 +56,7 @@ import {
56
56
  getEmbeddingProviderIdentity,
57
57
  dominantEmbeddingFailure,
58
58
  LocalEmbeddingProvider
59
- } from "./index-xn9efn18.js";
59
+ } from "./index-hes3k87g.js";
60
60
  import {
61
61
  embedPauseBySession,
62
62
  activeEmbeddingSessions,
@@ -9,7 +9,7 @@ import {
9
9
  } from "./index-s7460efs.js";
10
10
  import {
11
11
  cleanUserText2
12
- } from "./index-5y9w2ax7.js";
12
+ } from "./index-dr6bd4c8.js";
13
13
  import {
14
14
  recordMessageFtsRowid2,
15
15
  recordIndexedMessageTime2,
@@ -19,10 +19,10 @@ import {
19
19
  rawMessageWorkerSource2,
20
20
  rawMessageOffThreadRangeReader2,
21
21
  readRawSessionMessageIdOrdinalsForRange2
22
- } from "./index-5y9w2ax7.js";
22
+ } from "./index-dr6bd4c8.js";
23
23
  import {
24
24
  readV2ArchiveOffThread2
25
- } from "./index-xg1zjht5.js";
25
+ } from "./index-g6y2wk32.js";
26
26
 
27
27
  // src/tools/ctx-expand/search-archive.ts
28
28
  var archiveReadsOnThisThread = 0;
@@ -7,7 +7,7 @@ import {
7
7
  } from "./index-fr0wbhdn.js";
8
8
  import {
9
9
  DEFAULT_LOCAL_EMBEDDING_MODEL
10
- } from "./index-6nqz8hsz.js";
10
+ } from "./index-y915t3ey.js";
11
11
  import {
12
12
  sessionLog2
13
13
  } from "./index-ywrz4wy2.js";
@@ -17,11 +17,11 @@ import {
17
17
  } from "./index-6r99v53h.js";
18
18
  import {
19
19
  LocalEmbeddingProvider
20
- } from "./index-xn9efn18.js";
20
+ } from "./index-hes3k87g.js";
21
21
  import {
22
22
  OpenAICompatibleEmbeddingProvider,
23
23
  embedTextForProject2
24
- } from "./index-3n376ann.js";
24
+ } from "./index-n9kd68vc.js";
25
25
  import {
26
26
  saveEmbeddingIfHashMatches
27
27
  } from "./index-qjwpqvnf.js";
@@ -32,7 +32,7 @@ import {
32
32
  normalizeProtectedToolName,
33
33
  mergeProtectedTools,
34
34
  deriveDefaultProtectedTokens
35
- } from "./index-6nqz8hsz.js";
35
+ } from "./index-y915t3ey.js";
36
36
  import {
37
37
  getTagIdentityWriteGeneration2,
38
38
  getSqliteDatabasePath2,
@@ -214,7 +214,7 @@ import {
214
214
  snapRangeToCompartments,
215
215
  getActiveCompartmentRun,
216
216
  startCompartmentAgent
217
- } from "./index-3f3d548g.js";
217
+ } from "./index-za1yx1m4.js";
218
218
  import {
219
219
  formatWindowDerivationLine,
220
220
  getSdkWindowGeometry,
@@ -370,7 +370,7 @@ import {
370
370
  getTagsByNumbers2,
371
371
  getDroppedTagsByNumbers2,
372
372
  getMaxDroppedTagNumber2
373
- } from "./index-901exj0f.js";
373
+ } from "./index-xr1t0fxb.js";
374
374
  import {
375
375
  BoundedSessionMap,
376
376
  observeTemporalDecisions,
@@ -397,7 +397,7 @@ import {
397
397
  DEFAULT_HISTORIAN_TIMEOUT_MS,
398
398
  DEFAULT_LOCAL_EMBEDDING_MODEL,
399
399
  DREAM_TASK_PROMOTION_DEFAULTS
400
- } from "./index-6nqz8hsz.js";
400
+ } from "./index-y915t3ey.js";
401
401
  import {
402
402
  areRustHistorianSyntheticParts2,
403
403
  isRawCompactionSummaryInfo2,
@@ -443,7 +443,7 @@ import {
443
443
  readRawSessionMessageById2,
444
444
  readSessionChunk2,
445
445
  readRawSessionSeedTail2
446
- } from "./index-5y9w2ax7.js";
446
+ } from "./index-dr6bd4c8.js";
447
447
  import {
448
448
  buildDreamTaskRuntimeConfigs2,
449
449
  userMemoryCollectionEnabled2
@@ -467,7 +467,7 @@ import {
467
467
  runSqliteOptimize,
468
468
  openDatabase,
469
469
  openCurrentDatabase
470
- } from "./index-6rk44cer.js";
470
+ } from "./index-gqfy38m9.js";
471
471
  import {
472
472
  unescapeXml,
473
473
  resolveWorkspaceShareCategories,
@@ -582,10 +582,10 @@ import {
582
582
  GLOBAL_USER_PROFILE_PROJECT_PATH,
583
583
  getProjectState,
584
584
  bumpProjectUserProfileVersion
585
- } from "./index-anwy2mfb.js";
585
+ } from "./index-yqha238s.js";
586
586
  import {
587
587
  getLastIndexedOrdinal
588
- } from "./index-hre29c1a.js";
588
+ } from "./index-pnawfv4e.js";
589
589
  import {
590
590
  SESSION_NOTE_CONDITION_ERROR,
591
591
  getNoteByIdInScope,
@@ -623,7 +623,7 @@ import {
623
623
  getCachedLocalEmbeddingPooling,
624
624
  preflightLocalEmbeddingPooling,
625
625
  getLocalEmbeddingNativeMemoryStats
626
- } from "./index-xn9efn18.js";
626
+ } from "./index-hes3k87g.js";
627
627
  import {
628
628
  withQueryEmbeddingDeadline,
629
629
  describeShadowBackfillWriteRefusal2,
@@ -645,7 +645,7 @@ import {
645
645
  embedSessionCompartmentChunks2,
646
646
  getEmbeddingCoverageStatus2,
647
647
  getAutoEmbeddingSessionCoverage2
648
- } from "./index-3n376ann.js";
648
+ } from "./index-n9kd68vc.js";
649
649
  import {
650
650
  saveEmbeddingIfHashMatches,
651
651
  invalidateProject2,
@@ -671,7 +671,7 @@ import {
671
671
  readGitFileChangeTimesSince,
672
672
  verificationFileExists,
673
673
  normalizeVerificationFiles
674
- } from "./index-ydhymf0b.js";
674
+ } from "./index-ttdk2w0z.js";
675
675
  import {
676
676
  computeCueContentHash,
677
677
  hasMuralCueColumns,
@@ -719,13 +719,13 @@ import {
719
719
  resolveMemoriesByIdsForSearch2,
720
720
  unifiedSearch2,
721
721
  formatSearchResults2
722
- } from "./index-5pmf4jpj.js";
722
+ } from "./index-g9qtxv87.js";
723
723
  import {
724
724
  scheduleReconciliation,
725
725
  scheduleIncrementalIndex,
726
726
  getMessageIndexQueueHeapStats,
727
727
  clearSessionTracking
728
- } from "./index-hbn5g7rt.js";
728
+ } from "./index-kty5k23y.js";
729
729
  import {
730
730
  resolveModelCacheTtl,
731
731
  resolveContextWindowGeometry,
@@ -824,7 +824,7 @@ import {
824
824
  abortSessionFailClosed2,
825
825
  evaluateEmergencyFailClosed2,
826
826
  runPostTransformPhase2
827
- } from "./index-zzhcshdk.js";
827
+ } from "./index-g5c67kay.js";
828
828
  import {
829
829
  flushIgnoredMessages2,
830
830
  clearIgnoredMessages2,
@@ -834,7 +834,7 @@ import {
834
834
  import {
835
835
  setRecompStarting2,
836
836
  setRecompTerminal2
837
- } from "./index-5a9kwapd.js";
837
+ } from "./index-1kem0xxx.js";
838
838
  import {
839
839
  ANNOUNCEMENT_VERSION2,
840
840
  ANNOUNCEMENT_FEATURES2,
@@ -849,13 +849,13 @@ import {
849
849
  renderMessageByOrdinal2,
850
850
  renderVerboseRangeForTool2,
851
851
  renderItemByTag2
852
- } from "./index-41bma6qs.js";
852
+ } from "./index-fpjnjxyx.js";
853
853
  import {
854
854
  readV2ArchiveOffThread2
855
- } from "./index-xg1zjht5.js";
855
+ } from "./index-g6y2wk32.js";
856
856
  import {
857
857
  renderSearchArchiveOffThread2
858
- } from "./index-wvbg9m0h.js";
858
+ } from "./index-rz47hf2m.js";
859
859
  import {
860
860
  takeCoveredInstructionRows,
861
861
  cloneKeepingCoveredInstructionMarks
@@ -16344,7 +16344,7 @@ function registerRpcHandlers(rpcServer, args) {
16344
16344
  const db = readDatabase();
16345
16345
  if (!db)
16346
16346
  return { ok: false, error: "db unavailable" };
16347
- const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-ggtcvb9g.js"));
16347
+ const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-qb2hymj5.js"));
16348
16348
  const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-0779tyd9.js"));
16349
16349
  log2(`[rpc] recomp requested for session ${sessionId}`);
16350
16350
  if (!args.client && !args.hiddenCompletionExecutor) {
@@ -16429,7 +16429,7 @@ function registerRpcHandlers(rpcServer, args) {
16429
16429
  const db = readDatabase();
16430
16430
  if (!db)
16431
16431
  return { ok: false, error: "db unavailable" };
16432
- const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-ggnk0r4r.js"));
16432
+ const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-m2p89973.js"));
16433
16433
  const model = await args.readSelectedSessionModel?.(sessionId) ?? liveSessionState.liveModelBySession.get(sessionId);
16434
16434
  const window = resolveOpenCodeWrapupWindow(db, sessionId, model);
16435
16435
  if (!window)
@@ -16890,14 +16890,12 @@ function writeTransformDecisionRow(dbPath, row) {
16890
16890
  try {
16891
16891
  db.exec("PRAGMA busy_timeout=0");
16892
16892
  configureContextDatabasePragmas2(db);
16893
- writeTransformDecisionRowOnDatabase(db, row, true);
16893
+ writeTransformDecisionRowOnDatabase(db, row);
16894
16894
  } finally {
16895
16895
  closeQuietly(db);
16896
16896
  }
16897
16897
  }
16898
- function writeTransformDecisionRowOnDatabase(db, row, configureBusyTimeout) {
16899
- if (configureBusyTimeout)
16900
- db.exec("PRAGMA busy_timeout=0");
16898
+ function writeTransformDecisionRowOnDatabase(db, row) {
16901
16899
  const systemHashPrev = row.materialized ? row.systemHashPrev : null;
16902
16900
  const systemHashNew = row.materialized ? row.systemHashNew : null;
16903
16901
  const m0ModelKeyPrev = row.materialized ? row.m0ModelKeyPrev : null;
@@ -7029,7 +7029,7 @@ var MagicContextConfigSchema = object({
7029
7029
  execute_threshold_percentage: union([
7030
7030
  number().min(20).max(90, EXECUTE_THRESHOLD_CAP_MESSAGE),
7031
7031
  object({ default: number().min(20).max(90, EXECUTE_THRESHOLD_CAP_MESSAGE) }).catchall(number().min(20).max(90, EXECUTE_THRESHOLD_CAP_MESSAGE))
7032
- ]).default(DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE).describe('Context percentage that forces queued operations to execute. Number or per-model object ({ default: 65, "provider/model": 45 }). Values above 90 are rejected because the runtime caps at 90% of the output-reserved safe window (MAX_EXECUTE_THRESHOLD). Default: DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE'),
7032
+ ]).default(DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE).describe('Context usage above which a pass counts as an execute pass. Queued drops and cleanup then apply on the next rewrite of the cached prompt (a new summary, a fold, /ctx-flush, or high pressure); the threshold does not start a rewrite for every queued drop. Number or per-model object ({ default: 65, "provider/model": 45 }). Values above 90 are rejected because the runtime caps at 90% of the output-reserved safe window (MAX_EXECUTE_THRESHOLD). Default: DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE'),
7033
7033
  execute_threshold_tokens: object({
7034
7034
  default: number().min(5000).max(2000000).optional()
7035
7035
  }).catchall(number().min(5000).max(2000000)).optional().describe("Absolute token thresholds per model. When matched, overrides execute_threshold_percentage for that model. Accepts `default` for all models or per-model keys. Values above 90% × context_limit are clamped with a warning log. Min 5_000, max 2_000_000."),
@@ -68,7 +68,7 @@ import {
68
68
  getPendingPiCompactionMarkerState,
69
69
  logPiCompactionMarkerClear,
70
70
  isPrefixBoundThinkingModel
71
- } from "./index-901exj0f.js";
71
+ } from "./index-xr1t0fxb.js";
72
72
  import {
73
73
  withReadOnlySessionDb
74
74
  } from "./index-sp5pvs95.js";
@@ -1836,7 +1836,7 @@ function noteCapturedLkgRequest(args) {
1836
1836
  captures.set(args.sessionId, {
1837
1837
  request,
1838
1838
  slot: identity(args.slot),
1839
- prefixCount: JSON.parse(args.slot.jsonPrefix).length,
1839
+ prefixCount: args.prefixCount ?? JSON.parse(args.slot.jsonPrefix).length,
1840
1840
  envelope: envelope(request.modelKey, args.systemPromptTokens, args.agentName, args.sessionId)
1841
1841
  });
1842
1842
  }
@@ -1998,22 +1998,32 @@ function rememberFingerprint(db, sessionId, fingerprint) {
1998
1998
  }
1999
1999
  saved.set(sessionId, fingerprint);
2000
2000
  }
2001
- function slotFingerprint(slot) {
2002
- return createHash5("sha256").update(JSON.stringify([
2003
- slot.jsonPrefix,
2004
- slot.inputIdSeq,
2005
- slot.inputContentDigests,
2006
- slot.inputContentSignatures,
2007
- slot.piOutputEntryIds,
2008
- slot.lastInputMessageId,
2009
- slot.modelKey,
2010
- slot.providerKey,
2011
- slot.rowVersion,
2012
- slot.captureSequence
2013
- ])).digest("hex");
2001
+ function serializeSlotMetadata(slot) {
2002
+ return {
2003
+ inputIdSeq: JSON.stringify(slot.piOutputEntryIds ? { version: 1, inputIds: slot.inputIdSeq, piOutputEntryIds: slot.piOutputEntryIds } : slot.inputIdSeq),
2004
+ inputContentDigests: JSON.stringify(slot.inputContentDigests),
2005
+ inputContentSignatures: slot.inputContentSignatures ? JSON.stringify(slot.inputContentSignatures) : null
2006
+ };
2007
+ }
2008
+ function slotFingerprint(slot, metadata = serializeSlotMetadata(slot)) {
2009
+ return createHash5("sha256").update([
2010
+ JSON.stringify([
2011
+ slot.jsonPrefix,
2012
+ slot.lastInputMessageId,
2013
+ slot.modelKey,
2014
+ slot.providerKey,
2015
+ slot.rowVersion,
2016
+ slot.captureSequence
2017
+ ]),
2018
+ metadata.inputIdSeq,
2019
+ metadata.inputContentDigests,
2020
+ metadata.inputContentSignatures ?? "null"
2021
+ ].join(`
2022
+ `)).digest("hex");
2014
2023
  }
2015
2024
  function persistLkgSlot(db, sessionId, slot, publishMetadata) {
2016
- const fingerprint = slotFingerprint(slot);
2025
+ const metadata = serializeSlotMetadata(slot);
2026
+ const fingerprint = slotFingerprint(slot, metadata);
2017
2027
  if (!publishMetadata && persistedFingerprints.get(db)?.get(sessionId) === fingerprint) {
2018
2028
  const durable = loadPersistedLkgSlot(db, sessionId);
2019
2029
  if (durable && slotFingerprint(durable) === fingerprint)
@@ -2021,9 +2031,6 @@ function persistLkgSlot(db, sessionId, slot, publishMetadata) {
2021
2031
  }
2022
2032
  const layout = layoutLkgPrefix(slot.jsonPrefix);
2023
2033
  try {
2024
- const inputIdSeq = JSON.stringify(slot.piOutputEntryIds ? { version: 1, inputIds: slot.inputIdSeq, piOutputEntryIds: slot.piOutputEntryIds } : slot.inputIdSeq);
2025
- const inputContentDigests = JSON.stringify(slot.inputContentDigests);
2026
- const inputContentSignatures = slot.inputContentSignatures ? JSON.stringify(slot.inputContentSignatures) : null;
2027
2034
  db.transaction(() => {
2028
2035
  const storedHashes = new Map;
2029
2036
  for (const row of db.prepare("SELECT chunk, hash FROM lkg_slot_chunks WHERE session_id = ?").all(sessionId)) {
@@ -2055,7 +2062,7 @@ function persistLkgSlot(db, sessionId, slot, publishMetadata) {
2055
2062
  provider_key = excluded.provider_key,
2056
2063
  captured_at = excluded.captured_at,
2057
2064
  row_version = excluded.row_version,
2058
- capture_sequence = excluded.capture_sequence`).run(sessionId, layout.chars, layout.chunks.length, layout.hash, inputIdSeq, inputContentDigests, inputContentSignatures, slot.lastInputMessageId, slot.modelKey, slot.providerKey, slot.capturedAt, slot.rowVersion ?? null, slot.captureSequence ?? null);
2065
+ capture_sequence = excluded.capture_sequence`).run(sessionId, layout.chars, layout.chunks.length, layout.hash, metadata.inputIdSeq, metadata.inputContentDigests, metadata.inputContentSignatures, slot.lastInputMessageId, slot.modelKey, slot.providerKey, slot.capturedAt, slot.rowVersion ?? null, slot.captureSequence ?? null);
2059
2066
  publishMetadata?.();
2060
2067
  }).immediate();
2061
2068
  rememberFingerprint(db, sessionId, fingerprint);
@@ -2468,6 +2475,13 @@ function outputMessageIsPostAnchor(message, inputIndexById, anchorIndex, systemI
2468
2475
  const linkedIndex = inputIndexById.get(linked);
2469
2476
  return linkedIndex === undefined ? null : linkedIndex > anchorIndex;
2470
2477
  }
2478
+ function canCountWithoutToJSON(value) {
2479
+ try {
2480
+ return !("toJSON" in value);
2481
+ } catch {
2482
+ return false;
2483
+ }
2484
+ }
2471
2485
  function buildLkgPrefix(input, output, completeOutput = false) {
2472
2486
  const projected = asEntryProjection(input);
2473
2487
  let anchorIndex = completeOutput && projected.length > 0 ? projected.length - 1 : findLkgAnchor(projected);
@@ -2517,14 +2531,18 @@ function buildLkgPrefix(input, output, completeOutput = false) {
2517
2531
  if (inputContentDigests.some((digest) => digest === null))
2518
2532
  return null;
2519
2533
  const prefix = [];
2534
+ let canCountFromArray = canCountWithoutToJSON(prefix);
2520
2535
  for (const message of output) {
2521
2536
  const postAnchor = completeOutput ? false : outputMessageIsPostAnchor(message, inputIndexById, anchorIndex, systemIndices);
2522
2537
  if (postAnchor === null)
2523
2538
  return null;
2524
2539
  if (isRetiredInstructionRow(message.info) && messageRole(message) === "system" && messageParts(message).length === 0)
2525
2540
  continue;
2526
- if (!postAnchor)
2527
- prefix.push(providerVisibleMessage(message));
2541
+ if (!postAnchor) {
2542
+ const visible = providerVisibleMessage(message);
2543
+ canCountFromArray &&= canCountWithoutToJSON(visible);
2544
+ prefix.push(visible);
2545
+ }
2528
2546
  }
2529
2547
  let jsonPrefix;
2530
2548
  try {
@@ -2534,12 +2552,14 @@ function buildLkgPrefix(input, output, completeOutput = false) {
2534
2552
  } catch {
2535
2553
  return null;
2536
2554
  }
2555
+ canCountFromArray &&= canCountWithoutToJSON(prefix);
2537
2556
  return {
2538
2557
  anchorIndex,
2539
2558
  anchorMessageId,
2540
2559
  inputIdSeq: validIds.slice(0, anchorIndex + 1),
2541
2560
  inputContentDigests,
2542
- jsonPrefix
2561
+ jsonPrefix,
2562
+ prefixCount: canCountFromArray ? prefix.length : undefined
2543
2563
  };
2544
2564
  }
2545
2565
  function captureLkgSlot(args) {
@@ -2561,6 +2581,7 @@ function captureLkgSlot(args) {
2561
2581
  noteCapturedLkgRequest({
2562
2582
  sessionId: args.sessionId,
2563
2583
  slot,
2584
+ prefixCount: built.prefixCount,
2564
2585
  request: built.anchorIndex === args.input.length - 1 ? claimLkgRequestIdentity(args.sessionId) : undefined,
2565
2586
  systemPromptTokens: args.systemPromptTokens ?? 0,
2566
2587
  agentName: args.agentName
@@ -35,7 +35,7 @@ import {
35
35
  getRawSessionTagKeysThrough2,
36
36
  getLegacyProtectedTailStartOrdinal2,
37
37
  readSessionChunk2
38
- } from "./index-5y9w2ax7.js";
38
+ } from "./index-dr6bd4c8.js";
39
39
  import {
40
40
  getHarness2,
41
41
  harnessOwnsOpenCodeStore2
@@ -93,7 +93,7 @@ import {
93
93
  ConfigProfilesSchema,
94
94
  MagicContextConfigSchema,
95
95
  LIVE_RELOAD_CONFIG_PATHS
96
- } from "./index-6nqz8hsz.js";
96
+ } from "./index-y915t3ey.js";
97
97
  import {
98
98
  providerMass,
99
99
  calibrationForModelKey,
@@ -123,7 +123,7 @@ import {
123
123
  LATEST_SUPPORTED_VERSION,
124
124
  getPersistedSchemaVersion,
125
125
  openDatabase
126
- } from "./index-6rk44cer.js";
126
+ } from "./index-gqfy38m9.js";
127
127
  import {
128
128
  areRustHistorianSyntheticParts2,
129
129
  isStrictGapHealingMessage2,
@@ -212,14 +212,14 @@ import {
212
212
  getProjectState,
213
213
  recordSubagentInvocation,
214
214
  getLatestHistorianInvocationId
215
- } from "./index-anwy2mfb.js";
215
+ } from "./index-yqha238s.js";
216
216
  import {
217
217
  clearCompressionDepth,
218
218
  clearCompressionDepthRange,
219
219
  toMessageIndexSource,
220
220
  clearIndexedMessagesInTransaction,
221
221
  indexSourcesAfterOrdinal
222
- } from "./index-hre29c1a.js";
222
+ } from "./index-pnawfv4e.js";
223
223
  import {
224
224
  stripWellFormedLeadingTagPrefix,
225
225
  peelLeadingMcTagNotation,
@@ -270,7 +270,7 @@ import {
270
270
  foldShrunkPartTags2,
271
271
  getTagNumberByMessageId2,
272
272
  getActiveTagsBySession2
273
- } from "./index-901exj0f.js";
273
+ } from "./index-xr1t0fxb.js";
274
274
  import {
275
275
  openCodeDbExists,
276
276
  withReadOnlySessionDb,
@@ -298,13 +298,13 @@ import {
298
298
  getProjectChunkEmbeddingModelId2,
299
299
  getProjectEmbeddingMaxInputTokens2,
300
300
  embedItemsWindowBounded2
301
- } from "./index-3n376ann.js";
301
+ } from "./index-n9kd68vc.js";
302
302
  import {
303
303
  renderUserFacingFailure,
304
304
  userFacingFailureCode,
305
305
  promoteSessionFactsDurable,
306
306
  embedPromotedFacts
307
- } from "./index-ydhymf0b.js";
307
+ } from "./index-ttdk2w0z.js";
308
308
  import {
309
309
  isMarkerCandidateBasisCurrent2,
310
310
  invalidateMarkerCandidateBasis2,