@cortexkit/opencode-magic-context 0.49.23 → 0.49.25

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 (122) hide show
  1. package/README.md +0 -26
  2. package/dist/agents/permissions.d.ts +8 -3
  3. package/dist/agents/permissions.d.ts.map +1 -1
  4. package/dist/auto-search-worker.js +4 -4
  5. package/dist/chunk-embedding-write-worker.js +5 -5
  6. package/dist/{compartment-chunk-embedding-he60aaa2.js → compartment-chunk-embedding-eypvn607.js} +3 -3
  7. package/dist/{conflict-warning-hook-2r32hyx6.js → conflict-warning-hook-a27bhggg.js} +4 -4
  8. package/dist/{context-j7hp43a0.js → context-keb00be8.js} +30 -24
  9. package/dist/{embedding-backfill-dtke6tck.js → embedding-backfill-vddgmem3.js} +5 -5
  10. package/dist/features/magic-context/dreamer/primer-seed.d.ts.map +1 -1
  11. package/dist/features/magic-context/tool-definition-tokens.d.ts +113 -57
  12. package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
  13. package/dist/hooks/magic-context/ask-answer-notice.d.ts +25 -0
  14. package/dist/hooks/magic-context/ask-answer-notice.d.ts.map +1 -0
  15. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +1 -1
  16. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  17. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +12 -4
  18. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  19. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  20. package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -1
  21. package/dist/hooks/magic-context/lkg-replay-fit.d.ts.map +1 -1
  22. package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +8 -0
  24. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  25. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  26. package/dist/hooks/magic-context/read-session-raw.d.ts +10 -0
  27. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  28. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  29. package/dist/hooks/magic-context/signed-thinking-fit-snapshot.d.ts +42 -0
  30. package/dist/hooks/magic-context/signed-thinking-fit-snapshot.d.ts.map +1 -0
  31. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  32. package/dist/{index-y76rhsnr.js → index-0s8454t2.js} +50 -31
  33. package/dist/{index-1gtfne2c.js → index-2haxh8h3.js} +1 -1
  34. package/dist/{index-m32esgmj.js → index-3d5wnkq7.js} +1 -1
  35. package/dist/{index-jfem3dgz.js → index-7tdtpqrg.js} +5 -1
  36. package/dist/{index-mnnkgq0q.js → index-awcftgmx.js} +7 -49
  37. package/dist/{index-1kbznkft.js → index-axjgxeww.js} +10 -8
  38. package/dist/{index-j32jj2t8.js → index-bhyksfyy.js} +3 -3
  39. package/dist/{index-ksq50rg0.js → index-c9zrgcnt.js} +1 -1
  40. package/dist/index-cfaet9cg.js +405 -0
  41. package/dist/{index-jmq8kfe7.js → index-ebsvmc5s.js} +4 -4
  42. package/dist/{index-66eby7hx.js → index-jcr6pe7z.js} +1 -1
  43. package/dist/{index-syaazvy2.js → index-n18sch77.js} +5 -5
  44. package/dist/{index-a9zvn5fe.js → index-q7ywt6xt.js} +3 -3
  45. package/dist/{index-x6cbrv9h.js → index-szf8r0ba.js} +1 -1
  46. package/dist/{index-rxqr723x.js → index-t6j3qxnd.js} +1 -1
  47. package/dist/{index-11gzxvf4.js → index-y6xpzjzr.js} +98 -48
  48. package/dist/{index-mnhcdfxg.js → index-yrrsp47d.js} +91 -17
  49. package/dist/{index-zy67whjr.js → index-z05n7702.js} +1 -1
  50. package/dist/{index-3svaejkh.js → index-z928hmnp.js} +1 -1
  51. package/dist/{index-ffzhwfzy.js → index-zzrzjnx5.js} +3 -3
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +43 -38
  54. package/dist/{message-fts-rowid-map-e79b7b6x.js → message-fts-rowid-map-9e1getgs.js} +2 -2
  55. package/dist/{message-index-4q8ek2fc.js → message-index-3g966xn7.js} +7 -7
  56. package/dist/{message-index-bounded-rydsg9r5.js → message-index-bounded-vaeqhp9w.js} +7 -7
  57. package/dist/migration-worker.js +4 -4
  58. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  59. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  60. package/dist/{project-embedding-registry-hn529988.js → project-embedding-registry-rstzmb60.js} +4 -4
  61. package/dist/raw-ordinal-warmup-worker.js +6 -6
  62. package/dist/{read-session-chunk-t039f0m5.js → read-session-chunk-z5gnc0zb.js} +4 -4
  63. package/dist/{read-session-raw-aw6jgvwg.js → read-session-raw-s4amywnh.js} +3 -1
  64. package/dist/{recomp-orchestrator-hbm53jj5.js → recomp-orchestrator-qwqeskhq.js} +14 -14
  65. package/dist/{search-hea079d7.js → search-84zfqeky.js} +11 -11
  66. package/dist/{search-archive-weh164mh.js → search-archive-mfabzyn2.js} +5 -5
  67. package/dist/{send-session-notification-gqzkz7da.js → send-session-notification-ygj4mja0.js} +3 -3
  68. package/dist/shared/slow-test.d.ts +7 -0
  69. package/dist/shared/slow-test.d.ts.map +1 -0
  70. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  71. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  72. package/dist/tools/parameter-descriptions.d.ts +6 -6
  73. package/dist/tools/parameter-descriptions.d.ts.map +1 -1
  74. package/dist/{transform-postprocess-phase-0b04tm1p.js → transform-postprocess-phase-hr1ntmjj.js} +14 -14
  75. package/dist/v2/auto-search-worker.js +4 -4
  76. package/dist/v2/chunk-embedding-write-worker.js +5 -5
  77. package/dist/v2/{compartment-chunk-embedding-8jjmcgeg.js → compartment-chunk-embedding-tk6g4q80.js} +3 -3
  78. package/dist/v2/{context-ea3x7smm.js → context-y7wfvdve.js} +106 -50
  79. package/dist/v2/{embedding-backfill-5e74ae0m.js → embedding-backfill-w5qp7t28.js} +5 -5
  80. package/dist/v2/hooks/context.d.ts +4 -0
  81. package/dist/v2/hooks/context.d.ts.map +1 -1
  82. package/dist/v2/{message-fts-rowid-map-n8fdg2ja.js → message-fts-rowid-map-pqk3a55v.js} +2 -2
  83. package/dist/v2/{message-index-bounded-8rcd7qq9.js → message-index-bounded-te303atj.js} +6 -6
  84. package/dist/v2/{message-index-qz9wdp82.js → message-index-fz6b4jeh.js} +6 -6
  85. package/dist/v2/migration-worker.js +4 -4
  86. package/dist/v2/{project-embedding-registry-v38q4xd5.js → project-embedding-registry-e7zftfvj.js} +4 -4
  87. package/dist/v2/raw-ordinal-warmup-worker.js +6 -6
  88. package/dist/v2/{read-session-chunk-wazfyxcg.js → read-session-chunk-knvkq1hf.js} +3 -3
  89. package/dist/v2/{read-session-raw-b70cpwzj.js → read-session-raw-ppjxnqk4.js} +3 -1
  90. package/dist/v2/{recomp-orchestrator-b12zaptj.js → recomp-orchestrator-e8a4jpvr.js} +11 -11
  91. package/dist/v2/{search-archive-x64rtz1z.js → search-archive-vrwgxv6z.js} +4 -4
  92. package/dist/v2/{search-hza9x72a.js → search-hav4dggf.js} +10 -10
  93. package/dist/v2/{send-session-notification-8eqe259v.js → send-session-notification-f8scq6ae.js} +1 -1
  94. package/dist/v2/{server-m4bfaevz.js → server-5brp2rfn.js} +90 -16
  95. package/dist/v2/{server-ppcd1qxh.js → server-6a8pxpxg.js} +7 -49
  96. package/dist/v2/server-7d6m1p2b.js +361 -0
  97. package/dist/v2/{server-zg5y109h.js → server-7weh65vd.js} +45 -27
  98. package/dist/v2/{server-qteg2kt9.js → server-8j2e7t31.js} +1 -1
  99. package/dist/v2/{server-d48x3m4x.js → server-9xbbaekh.js} +1 -1
  100. package/dist/v2/{server-j8h7bsca.js → server-e75vag9d.js} +3 -3
  101. package/dist/v2/{server-132h8twc.js → server-m6yyn961.js} +2 -2
  102. package/dist/v2/{server-62g58aaz.js → server-pw21ypwb.js} +1 -1
  103. package/dist/v2/{server-ad18djzs.js → server-q5z0gag0.js} +1 -1
  104. package/dist/v2/{server-4kjmrjn4.js → server-swvhxhxz.js} +5 -1
  105. package/dist/v2/{server-33nqbqkw.js → server-tfawsj08.js} +5 -5
  106. package/dist/v2/{server-dtp8hcjh.js → server-wxrdher8.js} +1 -1
  107. package/dist/v2/server.js +5 -5
  108. package/dist/v2/{wrapup-orchestrator-3ssd5yy1.js → wrapup-orchestrator-ycs8y6n4.js} +11 -11
  109. package/dist/{wrapup-orchestrator-5vpcd1zx.js → wrapup-orchestrator-f642w8n3.js} +15 -15
  110. package/package.json +4 -4
  111. package/src/agents/permissions.ts +22 -6
  112. package/src/agents/smart-notes-dreamer-gate.golden.json +241 -241
  113. package/src/agents/smart-notes-on.golden.json +4 -4
  114. package/src/config/compaction-accessor-guard.test.ts +0 -5
  115. package/src/config/removed-config-keys.test.ts +12 -26
  116. package/src/shared/announcement.test.ts +55 -59
  117. package/src/shared/prompt-surface-a1-golden.md +6 -7
  118. package/src/shared/slow-test.ts +24 -0
  119. package/src/shared/stable-json-linear.test.ts +18 -10
  120. package/dist/index-j76ah6d7.js +0 -120
  121. package/dist/v2/server-d1dzgvwd.js +0 -120
  122. package/src/config/latch-permanence-guard.test.ts +0 -258
@@ -163,12 +163,13 @@ import {
163
163
  DREAM_TASK_PROMOTION_DEFAULTS
164
164
  } from "./index-nxrsns5x.js";
165
165
  import {
166
+ areRustHistorianSyntheticParts2,
166
167
  isRawCompactionSummaryInfo2,
167
168
  extractInMemoryMessageViews2,
168
169
  buildInMemoryTailRawMessages2,
169
170
  RawOrdinalsNotReady2,
170
171
  runSessionWarmupWorker
171
- } from "./index-jfem3dgz.js";
172
+ } from "./index-7tdtpqrg.js";
172
173
  import {
173
174
  openCodeDbExists,
174
175
  withReadOnlySessionDb,
@@ -176,9 +177,10 @@ import {
176
177
  latestPersistedMessageForRecovery,
177
178
  latestRealUserTurnIdFromOpenCodeDb,
178
179
  findLastAssistantModelFromOpenCodeDb
179
- } from "./index-ksq50rg0.js";
180
+ } from "./index-c9zrgcnt.js";
180
181
  import {
181
182
  expandToolPart,
183
+ askAnswerLines,
182
184
  takeCoveredInstructionRows,
183
185
  cloneKeepingCoveredInstructionMarks,
184
186
  estimateTrueRawMessageTokens,
@@ -300,10 +302,11 @@ import {
300
302
  readRawSessionMessageById2,
301
303
  readSessionChunk2,
302
304
  readRawSessionSeedTail2
303
- } from "./index-mnhcdfxg.js";
305
+ } from "./index-yrrsp47d.js";
304
306
  import {
307
+ BoundedSessionMap,
305
308
  getMeasuredToolDefinitionTokens
306
- } from "./index-j76ah6d7.js";
309
+ } from "./index-cfaet9cg.js";
307
310
  import {
308
311
  isFailClosedBlockingError,
309
312
  shouldBypassFailClosedBlock,
@@ -317,7 +320,7 @@ import {
317
320
  runSqliteOptimize,
318
321
  openDatabase,
319
322
  openCurrentDatabase
320
- } from "./index-a9zvn5fe.js";
323
+ } from "./index-q7ywt6xt.js";
321
324
  import {
322
325
  registerOwnRpcServerInstance,
323
326
  rpcPortDir,
@@ -512,7 +515,7 @@ import {
512
515
  snapRangeToCompartments,
513
516
  getActiveCompartmentRun,
514
517
  startCompartmentAgent
515
- } from "./index-y76rhsnr.js";
518
+ } from "./index-0s8454t2.js";
516
519
  import {
517
520
  embedPauseBySession,
518
521
  embedRunStateBySession,
@@ -540,7 +543,7 @@ import {
540
543
  embedSessionCompartmentChunks2,
541
544
  getEmbeddingCoverageStatus2,
542
545
  getAutoEmbeddingSessionCoverage2
543
- } from "./index-zy67whjr.js";
546
+ } from "./index-z05n7702.js";
544
547
  import {
545
548
  SubcClient,
546
549
  connectionFileExists,
@@ -550,7 +553,6 @@ import {
550
553
  SynapseEmbeddingProvider
551
554
  } from "./index-wfybj1dw.js";
552
555
  import {
553
- BoundedSessionMap,
554
556
  LkgRecoveryFenceError,
555
557
  lkgServedArrayDigest,
556
558
  takeLkgRecoveryLockSweepPage,
@@ -571,7 +573,7 @@ import {
571
573
  indexSingleMessage2,
572
574
  indexMessagesAfterOrdinal2,
573
575
  sweepOrphanedOpenCodeMessageIndexesCooperatively2
574
- } from "./index-mnnkgq0q.js";
576
+ } from "./index-awcftgmx.js";
575
577
  import {
576
578
  renderUserFacingFailure,
577
579
  userFacingFailureCode,
@@ -615,7 +617,7 @@ import {
615
617
  readGitFileChangeTimesSince,
616
618
  verificationFileExists,
617
619
  normalizeVerificationFiles
618
- } from "./index-3svaejkh.js";
620
+ } from "./index-z928hmnp.js";
619
621
  import {
620
622
  registerNotificationSink2,
621
623
  pushNotification2,
@@ -635,7 +637,7 @@ import {
635
637
  } from "./index-4dhv7mqz.js";
636
638
  import {
637
639
  cosineSimilarity
638
- } from "./index-rxqr723x.js";
640
+ } from "./index-t6j3qxnd.js";
639
641
  import {
640
642
  computeCueContentHash,
641
643
  hasMuralCueColumns,
@@ -681,17 +683,17 @@ import {
681
683
  resolveMemoriesByIdsForSearch2,
682
684
  unifiedSearch2,
683
685
  formatSearchResults2
684
- } from "./index-syaazvy2.js";
686
+ } from "./index-n18sch77.js";
685
687
  import {
686
688
  flushIgnoredMessages2,
687
689
  clearIgnoredMessages2,
688
690
  observeIgnoredNotificationEvent2,
689
691
  sendStatusNotification2
690
- } from "./index-66eby7hx.js";
692
+ } from "./index-jcr6pe7z.js";
691
693
  import {
692
694
  setRecompStarting2,
693
695
  setRecompTerminal2
694
- } from "./index-ffzhwfzy.js";
696
+ } from "./index-zzrzjnx5.js";
695
697
  import {
696
698
  makeToolCompositeKey,
697
699
  searchMessageHistoryOffThread,
@@ -752,7 +754,7 @@ import {
752
754
  abortSessionFailClosed2,
753
755
  evaluateEmergencyFailClosed2,
754
756
  runPostTransformPhase2
755
- } from "./index-1kbznkft.js";
757
+ } from "./index-axjgxeww.js";
756
758
  import {
757
759
  ANNOUNCEMENT_VERSION2,
758
760
  ANNOUNCEMENT_FEATURES2,
@@ -765,7 +767,7 @@ import {
765
767
  } from "./index-fmsr7v69.js";
766
768
  import {
767
769
  renderSearchArchiveOffThread2
768
- } from "./index-j32jj2t8.js";
770
+ } from "./index-bhyksfyy.js";
769
771
  import {
770
772
  COMPACTION_ENABLED_PATH,
771
773
  isDreamerRunnable,
@@ -7795,7 +7797,10 @@ function orientationRenderer(capTokens) {
7795
7797
  sawMessage = true;
7796
7798
  const out = [];
7797
7799
  if (msg.role === "user" && hasMeaningfulUserText2(msg.parts)) {
7798
- const text = extractTexts2(msg.parts).map((t) => cleanUserText2(t)).map(normalizeText).filter((t) => t.length > 0).join(" / ");
7800
+ const rawTexts = extractTexts2(msg.parts);
7801
+ const parts = rawTexts.map((t) => cleanUserText2(t)).map(normalizeText).filter((t) => t.length > 0);
7802
+ parts.push(...rawTexts.flatMap((t) => askAnswerLines(t)).map(normalizeText));
7803
+ const text = parts.filter((t) => t.length > 0).join(" / ");
7799
7804
  if (text)
7800
7805
  out.push(`U: ${text}`);
7801
7806
  }
@@ -15761,7 +15766,7 @@ function buildSidebarSnapshot(db, sessionId, directory, liveSessionState, inject
15761
15766
  if (model) {
15762
15767
  activeProviderID = model.providerID;
15763
15768
  activeModelID = model.modelID;
15764
- measuredToolDefTokens = getMeasuredToolDefinitionTokens(model.providerID, model.modelID, agent) ?? 0;
15769
+ measuredToolDefTokens = getMeasuredToolDefinitionTokens(model.providerID, model.modelID, agent, sessionId) ?? 0;
15765
15770
  }
15766
15771
  }
15767
15772
  const contextLimit = typeof moduleContextLimit === "number" && moduleContextLimit > 0 ? moduleContextLimit : activeProviderID && activeModelID ? resolveContextLimit(activeProviderID, activeModelID, {
@@ -16475,8 +16480,8 @@ function registerRpcHandlers(rpcServer, args) {
16475
16480
  const db = readDatabase();
16476
16481
  if (!db)
16477
16482
  return { ok: false, error: "db unavailable" };
16478
- const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-hbm53jj5.js"));
16479
- const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-gqzkz7da.js"));
16483
+ const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-qwqeskhq.js"));
16484
+ const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-ygj4mja0.js"));
16480
16485
  log2(`[rpc] recomp requested for session ${sessionId}`);
16481
16486
  if (!args.client && !args.hiddenCompletionExecutor) {
16482
16487
  return {
@@ -16560,7 +16565,7 @@ function registerRpcHandlers(rpcServer, args) {
16560
16565
  const db = readDatabase();
16561
16566
  if (!db)
16562
16567
  return { ok: false, error: "db unavailable" };
16563
- const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-5vpcd1zx.js"));
16568
+ const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-f642w8n3.js"));
16564
16569
  const model = liveSessionState.liveModelBySession.get(sessionId);
16565
16570
  const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
16566
16571
  const ctx = {
@@ -18259,7 +18264,8 @@ function measureLkgReplayRequest(args) {
18259
18264
  systemPromptTokens: args.systemPromptTokens,
18260
18265
  providerID: args.model?.providerID,
18261
18266
  modelID: args.model?.modelID,
18262
- agentName: args.agentName
18267
+ agentName: args.agentName,
18268
+ sessionId: args.sessionId
18263
18269
  })
18264
18270
  });
18265
18271
  }
@@ -18990,8 +18996,7 @@ function encodeOpenCodeMessagesToCk(messages) {
18990
18996
  const createdAtMs = typeof time.created === "number" ? time.created : typeof info.time_created === "number" ? info.time_created : typeof info.timeCreated === "number" ? info.timeCreated : undefined;
18991
18997
  const completedAtMs = typeof time.completed === "number" ? time.completed : typeof info.time_completed === "number" ? info.time_completed : typeof info.timeCompleted === "number" ? info.timeCompleted : undefined;
18992
18998
  const parts = Array.isArray(raw.parts) ? raw.parts : [];
18993
- const syntheticParts = parts.filter((part) => part === null || typeof part !== "object" || part.type !== "compaction");
18994
- const synthetic = syntheticParts.length > 0 && syntheticParts.every((part) => part !== null && typeof part === "object" && (part.synthetic === true || part.syntheticTodoMarker === true));
18999
+ const synthetic = areRustHistorianSyntheticParts2(parts);
18995
19000
  const content = [];
18996
19001
  const recoveryToolTitles = {};
18997
19002
  const userAnswerBlocks = [];
@@ -22149,7 +22154,8 @@ function createRustModeTransform(deps, options) {
22149
22154
  systemPromptTokens: sessionMeta.systemPromptTokens,
22150
22155
  providerID: model?.providerID,
22151
22156
  modelID: model?.modelID,
22152
- agentName: deps.getNotificationParams?.(sessionId)?.agent
22157
+ agentName: deps.getNotificationParams?.(sessionId)?.agent,
22158
+ sessionId
22153
22159
  })
22154
22160
  });
22155
22161
  if (measure.fit !== "under") {
@@ -22720,7 +22726,8 @@ function createRustModeTransform(deps, options) {
22720
22726
  systemPromptTokens: sessionMeta.systemPromptTokens,
22721
22727
  providerID: model?.providerID,
22722
22728
  modelID: model?.modelID,
22723
- agentName: deps.getNotificationParams?.(sessionId)?.agent
22729
+ agentName: deps.getNotificationParams?.(sessionId)?.agent,
22730
+ sessionId
22724
22731
  }) : undefined;
22725
22732
  const renderIdentityFields = {
22726
22733
  modelKey: modelKey ?? null,
@@ -23252,6 +23259,7 @@ function createRustModeTransform(deps, options) {
23252
23259
  providerID: model?.providerID,
23253
23260
  modelID: model?.modelID,
23254
23261
  agentName: deps.getNotificationParams?.(sessionId)?.agent,
23262
+ sessionId,
23255
23263
  systemPromptHash: sessionMeta.systemPromptHash
23256
23264
  }, resolvedWindowGeometry?.usableHard ?? resolvedContextLimit);
23257
23265
  const refusal = outgoingContextRefusal(servedFinalWireEstimate, resolvedWindowGeometry?.usableHard ?? resolvedContextLimit, protectedToolTokenCount(getActiveTagsBySession2(deps.db, sessionId), deps.protectedTools, resolveDecisionCalibration(model?.providerID, model?.modelID))) ?? (signedThinkingReset ? signedTurnContextRefusal(servedFinalWireEstimate, resolvedWindowGeometry?.usableHard ?? resolvedContextLimit) : undefined);
@@ -23487,6 +23495,7 @@ function createRustModeTransform(deps, options) {
23487
23495
  providerID: model?.providerID,
23488
23496
  modelID: model?.modelID,
23489
23497
  agentName: deps.getNotificationParams?.(sessionId)?.agent,
23498
+ sessionId,
23490
23499
  systemPromptHash: sessionMeta.systemPromptHash
23491
23500
  });
23492
23501
  captureOpencodeReasoningBudgetStatus(sessionId, output.messages, resolveKeepReasoningTokens(deps.keepReasoningTokens, modelKey ?? undefined), isPrefixBoundThinkingModel(model?.providerID, model?.modelID));
@@ -23750,6 +23759,27 @@ function createRustModeTransform(deps, options) {
23750
23759
  return adapter;
23751
23760
  }
23752
23761
 
23762
+ // src/hooks/magic-context/signed-thinking-fit-snapshot.ts
23763
+ function takeSignedThinkingFitSnapshot(args) {
23764
+ let snapshot = null;
23765
+ if (args.held && !args.compactionOff) {
23766
+ try {
23767
+ snapshot = cloneKeepingCoveredInstructionMarks(args.entryOrder);
23768
+ } catch (error) {
23769
+ sessionLog2(args.sessionId, `signed thinking fit: could not copy the pass input (${error instanceof Error ? error.message : String(error)}); an over-window held request will be refused rather than retried`);
23770
+ }
23771
+ }
23772
+ snapshotObserver?.({
23773
+ sessionId: args.sessionId,
23774
+ held: args.held,
23775
+ activeAnthropicThinkingTurn: args.activeAnthropicThinkingTurn,
23776
+ compactionOff: args.compactionOff,
23777
+ snapshot
23778
+ });
23779
+ return snapshot;
23780
+ }
23781
+ var snapshotObserver;
23782
+
23753
23783
  // src/hooks/magic-context/signed-thinking-hold.ts
23754
23784
  var HEAVY_REASONING_TOKENS = 1500;
23755
23785
  var HEAVY_REASONING_WINDOW_STEPS = 15;
@@ -24370,7 +24400,7 @@ function createTransform(deps) {
24370
24400
  const startTime = performance.now();
24371
24401
  const historianRun = deps.resolveHistorianRun?.();
24372
24402
  const messages = output.messages;
24373
- const originalForThinkingFit = messages.some((message) => message.parts.some((part) => isRecord(part) && ["reasoning", "thinking", "redacted_thinking"].includes(String(part.type)))) ? cloneKeepingCoveredInstructionMarks(messages) : null;
24403
+ const entryOrderForThinkingFit = messages.slice();
24374
24404
  const coveredHostInstructions = takeCoveredInstructionRows(messages);
24375
24405
  const passOutcome = createPassOutcome();
24376
24406
  const tSessionId = performance.now();
@@ -24724,7 +24754,8 @@ function createTransform(deps) {
24724
24754
  systemPromptTokens: sessionMeta.systemPromptTokens,
24725
24755
  providerID: modelForBudget?.providerID,
24726
24756
  modelID: modelForBudget?.modelID,
24727
- agentName: runNotificationParams(sessionId)?.agent
24757
+ agentName: runNotificationParams(sessionId)?.agent,
24758
+ sessionId
24728
24759
  });
24729
24760
  const incomingTokens = incoming.messageTokens.conversation + incoming.messageTokens.toolCall;
24730
24761
  if (unmanagedOverWindowCarried || isClearlyOverWindow(incomingTokens, resolvedContextLimit)) {
@@ -24770,6 +24801,13 @@ function createTransform(deps) {
24770
24801
  }) : null;
24771
24802
  activeThinkingPrefixHold = signedThinkingPrefixBound && (compactionOff || signedThinkingHold?.held === true);
24772
24803
  freezeM0M1 ||= activeThinkingPrefixHold;
24804
+ const originalForThinkingFit = takeSignedThinkingFitSnapshot({
24805
+ sessionId,
24806
+ entryOrder: entryOrderForThinkingFit,
24807
+ held: activeThinkingPrefixHold,
24808
+ activeAnthropicThinkingTurn: activeThinkingTurn,
24809
+ compactionOff
24810
+ });
24773
24811
  const prefixHoldLogKey = signedThinkingHold ? `${currentTurnId}:${signedThinkingHold.reason}:${signedThinkingHold.heavyStepsBack ?? "none"}` : freezeM0M1 ? `${currentTurnId}:directory` : null;
24774
24812
  if (prefixHoldLogKey !== null && prefixHoldLogTurnIds.get(sessionId) !== prefixHoldLogKey) {
24775
24813
  prefixHoldLogTurnIds.set(sessionId, prefixHoldLogKey);
@@ -25261,7 +25299,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
25261
25299
  systemPromptTokens: sessionMeta.systemPromptTokens,
25262
25300
  providerID: modelForBudget?.providerID,
25263
25301
  modelID: modelForBudget?.modelID,
25264
- agentName: notificationParams.agent
25302
+ agentName: notificationParams.agent,
25303
+ sessionId
25265
25304
  });
25266
25305
  } catch (error) {
25267
25306
  sessionLog2(sessionId, `transform: wire-estimate pressure fallback unavailable: ${getErrorMessage(error)}`);
@@ -25429,6 +25468,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
25429
25468
  providerID: modelForBudget?.providerID,
25430
25469
  modelID: modelForBudget?.modelID,
25431
25470
  agentName: notificationParams.agent,
25471
+ sessionId,
25432
25472
  systemPromptHash: sessionMeta.systemPromptHash
25433
25473
  }, boundaryContextLimit);
25434
25474
  } catch {
@@ -25443,13 +25483,15 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
25443
25483
  providerID: modelForBudget?.providerID,
25444
25484
  modelID: modelForBudget?.modelID,
25445
25485
  agentName: notificationParams.agent,
25486
+ sessionId,
25446
25487
  systemPromptHash: sessionMeta.systemPromptHash
25447
25488
  }, boundaryContextLimit) : undefined);
25448
25489
  if (finalWireEstimate) {
25449
25490
  sessionLog2(sessionId, `transform: final-wire telemetry estimate=${finalWireEstimate.tokens} trusted=${finalWireEstimate.trusted} conversation=${finalWireEstimate.messageTokens.conversation} tools=${finalWireEstimate.messageTokens.toolCall} system=${finalWireEstimate.systemTokens} toolDefinitions=${finalWireEstimate.toolDefinitionTokens ?? "unknown"} tail=${finalWireTail}`);
25450
25491
  }
25451
25492
  if ((finalWireEstimate?.refusalGrade || finalWireEstimate?.refusalBasis === "byte-bound" && finalWireEstimate.refusalTokens !== undefined) && boundaryContextLimit > 0 && (finalWireEstimate.refusalTokens ?? finalWireEstimate.tokens) > boundaryContextLimit) {
25452
- if (!thinkingFitRetries.has(sessionId) && activeThinkingPrefixHold && originalForThinkingFit && hasActiveAnthropicThinkingTurn(messages, resolvedProviderID, modelForBudget?.modelID)) {
25493
+ const signedFitRetryWanted = !thinkingFitRetries.has(sessionId) && activeThinkingPrefixHold && hasActiveAnthropicThinkingTurn(messages, resolvedProviderID, modelForBudget?.modelID);
25494
+ if (signedFitRetryWanted && originalForThinkingFit) {
25453
25495
  thinkingFitRetries.add(sessionId);
25454
25496
  requestPendingMaterialization(deps.pendingMaterializationSessions, sessionId, "fit_retry");
25455
25497
  messages.splice(0, messages.length, ...originalForThinkingFit);
@@ -25460,7 +25502,10 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
25460
25502
  }
25461
25503
  return;
25462
25504
  }
25463
- if (thinkingFitRetries.has(sessionId) || postTransformResult.thinkingReleasedForFit || signedFitPreviouslyRefused) {
25505
+ if (signedFitRetryWanted) {
25506
+ sessionLog2(sessionId, "signed thinking fit: the held request is over the window and no copy of the pass input exists to retry from; refusing it");
25507
+ }
25508
+ if (signedFitRetryWanted || thinkingFitRetries.has(sessionId) || postTransformResult.thinkingReleasedForFit || signedFitPreviouslyRefused) {
25464
25509
  if (!signedFitPreviouslyRefused && !addMergedReasoningStrippedIds(db, sessionId, [SIGNED_FIT_REFUSED_MARKER]))
25465
25510
  throw contextRefusalError("Cannot persist the signed-fit refusal");
25466
25511
  throw contextRefusalError("The request remains over the model window after stripping signed thinking and reclaiming context");
@@ -25472,7 +25517,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
25472
25517
  systemPromptTokens: sessionMeta.systemPromptTokens,
25473
25518
  providerID: modelForBudget?.providerID,
25474
25519
  modelID: modelForBudget?.modelID,
25475
- agentName: notificationParams.agent
25520
+ agentName: notificationParams.agent,
25521
+ sessionId
25476
25522
  });
25477
25523
  if (untrimmed.tokens > boundaryContextLimit) {
25478
25524
  sessionLog2(sessionId, `history boundary unresolved: prefix trim refused and the untrimmed request estimate ${untrimmed.tokens} (trusted=${untrimmed.trusted}) exceeds the context limit ${boundaryContextLimit}; not sending it`);
@@ -25485,7 +25531,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
25485
25531
  systemPromptTokens: sessionMeta.systemPromptTokens,
25486
25532
  providerID: modelForBudget?.providerID,
25487
25533
  modelID: modelForBudget?.modelID,
25488
- agentName: notificationParams.agent
25534
+ agentName: notificationParams.agent,
25535
+ sessionId
25489
25536
  });
25490
25537
  const servedTokens = served.toolDefinitionsMeasured ? served.rawTokens ?? served.tokens : Math.max(0, sessionMeta.systemPromptTokens) + served.messageTokens.conversation + served.messageTokens.toolCall;
25491
25538
  if (!Number.isFinite(servedTokens) || servedTokens > unmanagedOverWindowPass.limit) {
@@ -25563,7 +25610,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
25563
25610
  systemPromptTokens: sessionMeta.systemPromptTokens,
25564
25611
  providerID: modelForBudget?.providerID,
25565
25612
  modelID: modelForBudget?.modelID,
25566
- agentName: notificationParams.agent
25613
+ agentName: notificationParams.agent,
25614
+ sessionId
25567
25615
  });
25568
25616
  } catch (error) {
25569
25617
  sessionLog2(sessionId, "degraded pass size guard could not estimate:", error);
@@ -25779,6 +25827,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
25779
25827
  providerID: modelForBudget?.providerID,
25780
25828
  modelID: modelForBudget?.modelID,
25781
25829
  agentName: notificationParams.agent,
25830
+ sessionId,
25782
25831
  systemPromptHash: sessionMeta.systemPromptHash
25783
25832
  });
25784
25833
  };
@@ -27619,10 +27668,10 @@ function updateMemoryContentInCurrentTransaction(db, memory, content, normalized
27619
27668
  invalidateMemory2(memory.projectPath, memory.id);
27620
27669
  }
27621
27670
  var ctxMemoryArgsShape = {
27622
- action: tool2.schema.enum([...CTX_MEMORY_ACTIONS]).optional().describe("write | update | archive | merge | get"),
27623
- content: tool2.schema.string().optional().describe("The memory text — one standalone fact (write, update, merge)."),
27624
- category: tool2.schema.enum([...V2_MEMORY_CATEGORIES]).optional().describe("Kind of fact (required for write; on update/merge optional, omitted keeps the current category)."),
27625
- ids: tool2.schema.array(tool2.schema.number()).optional().describe("Memory ids from <project-memory>: one for update, one or more for archive, two or more for merge, 1–20 for get."),
27671
+ action: tool2.schema.enum([...CTX_MEMORY_ACTIONS]).describe("write | update | archive | merge | get"),
27672
+ content: tool2.schema.string().describe("The memory text — one standalone fact (write, update, merge)."),
27673
+ category: tool2.schema.enum([...V2_MEMORY_CATEGORIES]).describe("Kind of fact (required for write; on update/merge, pass the memory's current category to keep it)."),
27674
+ ids: tool2.schema.array(tool2.schema.number()).describe("Memory ids from <project-memory>: one for update, one or more for archive, two or more for merge, 1–20 for get."),
27626
27675
  reason: tool2.schema.string().optional().describe("Why it is being archived (optional).")
27627
27676
  };
27628
27677
  var ctxMemoryListArgsShape = {
@@ -28603,13 +28652,13 @@ function writeTray(db, sessionId) {
28603
28652
  return { activeCount: active.length, oldestTouchedAt: oldest };
28604
28653
  }
28605
28654
  var ctxNoteArgsShape = {
28606
- action: tool3.schema.enum(["write", "read", "dismiss", "update"]).optional().describe("write | read | update | dismiss. Defaults to write when content is given, else read."),
28607
- content: tool3.schema.string().optional().describe("Note text for write/update: first line is the title (under 80 chars), then the detail."),
28655
+ action: tool3.schema.enum(["write", "read", "dismiss", "update"]).describe("write | read | update | dismiss."),
28656
+ content: tool3.schema.string().describe("Note text for write/update: first line is the title (under 80 chars), then the detail."),
28608
28657
  surface_condition: tool3.schema.string().optional().describe("Makes this a smart note: a condition an outside checker can verify on its own, periodically — repository state, releases, web pages, anything it can look up — never something only this conversation knows. The note is parked until the condition holds."),
28609
28658
  filter: tool3.schema.enum(["all", "active", "pending", "ready", "dismissed"]).optional().describe("Read filter: all, active, pending (unsurfaced smart notes), ready, dismissed. Omitted, it shows active session notes plus every current smart note (pending included); active shows only notes whose stored status is active."),
28610
28659
  limit: tool3.schema.number().optional().describe("Rows per read (default 25)."),
28611
28660
  offset: tool3.schema.number().optional().describe("Skip this many newest rows (default 0)."),
28612
- note_ids: tool3.schema.array(tool3.schema.number().int().min(1)).min(1).max(50).optional().describe("Note ids: one for update, 1–50 for dismiss or read (read returns full bodies). Ignored by write.")
28661
+ note_ids: tool3.schema.array(tool3.schema.number().int().min(1)).max(50).describe("Note ids: one for update, 1–50 for dismiss, or 1–50 to read those notes in full. Write and a plain read take an empty list.")
28613
28662
  };
28614
28663
  var ctxNoteArgsSchema = tool3.schema.object(ctxNoteArgsShape).passthrough();
28615
28664
  function formatDismissResults(results) {
@@ -28657,7 +28706,8 @@ function createCtxNoteTool(deps) {
28657
28706
  }
28658
28707
  const sessionId = toolContext.sessionID;
28659
28708
  const action = args.action ?? (args.content?.trim() ? "write" : "read");
28660
- const noteIds = action === "dismiss" || action === "update" || action === "read" && args.note_ids !== undefined ? parseNoteIds(action, args.note_ids) : undefined;
28709
+ const targetedReadIds = action === "read" && Array.isArray(args.note_ids) && args.note_ids.length === 0 ? undefined : args.note_ids;
28710
+ const noteIds = action === "dismiss" || action === "update" || action === "read" && targetedReadIds !== undefined ? parseNoteIds(action, targetedReadIds) : undefined;
28661
28711
  if (typeof noteIds === "string")
28662
28712
  return noteIds;
28663
28713
  const wakePlaneActive = action === "write" && Boolean(args.surface_condition?.trim()) && await wakePlaneStatus() === "present";
@@ -29214,18 +29264,18 @@ var FULL_PARAMETER_DESCRIPTIONS = {
29214
29264
  message: "Message ordinal from a <session-history> heading or a ctx_search hit, not a tag number. Returns that one message in full. Use alone."
29215
29265
  },
29216
29266
  ctx_note: {
29217
- action: "write | read | update | dismiss. Defaults to write when content is given, else read.",
29267
+ action: "write | read | update | dismiss.",
29218
29268
  content: "Note text for write/update: first line is the title (under 80 chars), then the detail.",
29219
29269
  surface_condition: "Makes this a smart note: a condition an outside checker can verify on its own, periodically — repository state, releases, web pages, anything it can look up — never something only this conversation knows. The note is parked until the condition holds.",
29220
29270
  filter: "Read filter: all, active, pending (unsurfaced smart notes), ready, dismissed. Omitted, it shows active session notes plus every current smart note (pending included); active shows only notes whose stored status is active.",
29221
29271
  limit: "Rows per read (default 25).",
29222
29272
  offset: "Skip this many newest rows (default 0).",
29223
- note_ids: "Note ids: one for update, 1–50 for dismiss or read (read returns full bodies). Ignored by write."
29273
+ note_ids: "Note ids: one for update, 1–50 for dismiss, or 1–50 to read those notes in full. Write and a plain read take an empty list."
29224
29274
  },
29225
29275
  ctx_memory: {
29226
29276
  action: "write | update | archive | merge | get",
29227
29277
  content: "The memory text — one standalone fact (write, update, merge).",
29228
- category: "Kind of fact (required for write; on update/merge optional, omitted keeps the current category).",
29278
+ category: "Kind of fact (required for write; on update/merge, pass the memory's current category to keep it).",
29229
29279
  ids: "Memory ids from <project-memory>: one for update, one or more for archive, two or more for merge, 1–20 for get.",
29230
29280
  reason: "Why it is being archived (optional)."
29231
29281
  },
@@ -29249,18 +29299,18 @@ var LIGHT_PARAMETER_DESCRIPTIONS = {
29249
29299
  message: "Message ordinal from a <session-history> heading or a ctx_search hit, not a tag number. Returns that one message in full. Use alone."
29250
29300
  },
29251
29301
  ctx_note: {
29252
- action: "write | read | update | dismiss (default: write with content, else read).",
29302
+ action: "write | read | update | dismiss.",
29253
29303
  content: "Note text: first line title (<80 chars), then detail.",
29254
29304
  surface_condition: "A condition an outside checker can verify on its own, periodically (repository, releases, web — anything it can look up); never something only this conversation knows.",
29255
29305
  filter: "Read filter: all, active, pending, ready, dismissed. Omitted: active notes plus every current smart note (pending included); active: only active-status notes.",
29256
29306
  limit: "Rows per read (default 25).",
29257
29307
  offset: "Skip newest rows (default 0).",
29258
- note_ids: "One id for update, 1–50 for dismiss or read (full bodies). Ignored by write."
29308
+ note_ids: "One id for update, 1–50 for dismiss, or 1–50 to read those notes in full. Write and a plain read take an empty list."
29259
29309
  },
29260
29310
  ctx_memory: {
29261
29311
  action: "write | update | archive | merge | get",
29262
29312
  content: "One standalone fact (write, update, merge).",
29263
- category: "Kind of fact (required for write; optional on update/merge).",
29313
+ category: "Kind of fact (required for write; on update/merge pass the current category to keep it).",
29264
29314
  ids: "Ids from <project-memory>: one for update, 1+ for archive, 2+ for merge, 1–20 for get.",
29265
29315
  reason: "Why it is archived (optional)."
29266
29316
  },