@cortexkit/opencode-magic-context 0.49.18 → 0.49.19

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 (86) hide show
  1. package/dist/auto-search-worker.js +6 -2
  2. package/dist/chunk-embedding-write-worker.js +2 -2
  3. package/dist/{context-m897gfp9.js → context-j31m2dv7.js} +16 -12
  4. package/dist/features/magic-context/dreamer/classify.d.ts +3 -0
  5. package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
  6. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +11 -0
  7. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  8. package/dist/features/magic-context/dreamer/map-memories.d.ts +3 -0
  9. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  10. package/dist/features/magic-context/dreamer/verify.d.ts +3 -0
  11. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  12. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  13. package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
  14. package/dist/features/magic-context/storage-meta-persisted.d.ts +13 -0
  15. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  16. package/dist/hooks/magic-context/auto-search-worker-evaluation.fixture.d.ts +2 -0
  17. package/dist/hooks/magic-context/auto-search-worker-evaluation.fixture.d.ts.map +1 -0
  18. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  19. package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts +13 -0
  20. package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts.map +1 -1
  21. package/dist/hooks/magic-context/system-date-refresh.d.ts +15 -2
  22. package/dist/hooks/magic-context/system-date-refresh.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  24. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +2 -0
  25. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  26. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  27. package/dist/{index-936py2wm.js → index-3esx8tkf.js} +60 -26
  28. package/dist/{index-v8awdgvd.js → index-3h4dp9wb.js} +1 -1
  29. package/dist/{index-24jbw52d.js → index-4911rn0b.js} +3 -3
  30. package/dist/{index-qn7xstt2.js → index-63k48rv9.js} +1 -2
  31. package/dist/{index-rmwykbbb.js → index-9zcsy3hh.js} +16 -1
  32. package/dist/{index-r4nkrs05.js → index-c1p88z1y.js} +3 -3
  33. package/dist/{index-s7j8tvhv.js → index-dxmq29t1.js} +3 -3
  34. package/dist/{index-6s5941tm.js → index-edmpdxcw.js} +1 -1
  35. package/dist/{index-e4xv8890.js → index-jhghdnsm.js} +26 -12
  36. package/dist/{index-fgncb0ng.js → index-jrr131e0.js} +2 -2
  37. package/dist/{index-s1ex9y6p.js → index-rpxdjkm0.js} +165 -27
  38. package/dist/{index-x4njr8df.js → index-se4m2g6w.js} +1 -1
  39. package/dist/index.js +20 -16
  40. package/dist/{message-index-bounded-n1frdn85.js → message-index-bounded-zyc8h32y.js} +2 -2
  41. package/dist/{message-index-66jv6fh4.js → message-index-gtpqnj8w.js} +2 -2
  42. package/dist/migration-worker.js +2 -2
  43. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  44. package/dist/plugin/messages-transform.d.ts.map +1 -1
  45. package/dist/plugin/tool-registry.d.ts.map +1 -1
  46. package/dist/raw-ordinal-warmup-worker.js +3 -3
  47. package/dist/{read-session-chunk-v06g3vka.js → read-session-chunk-jjb48bt9.js} +1 -1
  48. package/dist/{recomp-orchestrator-ghpk2dtq.js → recomp-orchestrator-999jj4bc.js} +7 -7
  49. package/dist/{search-archive-4d53y23e.js → search-archive-6vm0e2f5.js} +2 -2
  50. package/dist/{search-nkf271d4.js → search-xsqk1bj4.js} +5 -5
  51. package/dist/shared/model-suggestion-retry.d.ts +30 -1
  52. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  53. package/dist/shared/prompt-async-transport.d.ts.map +1 -1
  54. package/dist/tools/ctx-expand/rust-mode-tag.test-support.d.ts +15 -0
  55. package/dist/tools/ctx-expand/rust-mode-tag.test-support.d.ts.map +1 -0
  56. package/dist/tools/ctx-expand/tools.d.ts +11 -0
  57. package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
  58. package/dist/{transform-postprocess-phase-zpgav0h7.js → transform-postprocess-phase-jj99r7z2.js} +7 -7
  59. package/dist/v2/auto-search-worker.js +6 -2
  60. package/dist/v2/chunk-embedding-write-worker.js +2 -2
  61. package/dist/v2/{context-f2xh7ba4.js → context-y5yamxak.js} +85 -33
  62. package/dist/v2/hooks/tools.d.ts.map +1 -1
  63. package/dist/v2/{message-index-48f7hw7a.js → message-index-8vz2pq76.js} +2 -2
  64. package/dist/v2/{message-index-bounded-w3hfm29z.js → message-index-bounded-spd8r7pj.js} +2 -2
  65. package/dist/v2/migration-worker.js +2 -2
  66. package/dist/v2/raw-ordinal-warmup-worker.js +3 -3
  67. package/dist/v2/{read-session-chunk-zpgmxwte.js → read-session-chunk-cwkxrmns.js} +1 -1
  68. package/dist/v2/{recomp-orchestrator-4vfxej9t.js → recomp-orchestrator-f6m9jr7p.js} +6 -6
  69. package/dist/v2/{search-archive-vv48s2aa.js → search-archive-wve3tq1k.js} +2 -2
  70. package/dist/v2/{search-kza414f0.js → search-hwg7jfbj.js} +5 -5
  71. package/dist/v2/{server-2ehj0bw7.js → server-2ar62dyx.js} +1 -1
  72. package/dist/v2/{server-qv7f0hhe.js → server-45q69hkq.js} +1 -1
  73. package/dist/v2/{server-bfpda1tb.js → server-6vdzn1td.js} +165 -27
  74. package/dist/v2/{server-xhab8jx8.js → server-9hx7g5jp.js} +16 -1
  75. package/dist/v2/{server-a2eqhkxr.js → server-bmymkx73.js} +2 -2
  76. package/dist/v2/{server-1nyybqan.js → server-gsxjv2q2.js} +3 -3
  77. package/dist/v2/{server-my7k4eds.js → server-hm38q7r0.js} +1 -1
  78. package/dist/v2/{server-gpvay0xz.js → server-xq7dfjke.js} +1 -2
  79. package/dist/v2/server.js +2 -2
  80. package/dist/v2/{wrapup-orchestrator-psqz7yh0.js → wrapup-orchestrator-embdz8gj.js} +6 -6
  81. package/dist/{wrapup-orchestrator-s9zc5b00.js → wrapup-orchestrator-whhbjmaz.js} +8 -8
  82. package/package.json +1 -1
  83. package/src/shared/model-suggestion-retry.test.ts +166 -0
  84. package/src/shared/model-suggestion-retry.ts +165 -14
  85. package/src/shared/prompt-async-transport.test.ts +107 -0
  86. package/src/shared/prompt-async-transport.ts +39 -0
@@ -52,7 +52,7 @@ import {
52
52
  hasPendingMigrations,
53
53
  getMainThreadMigrationBodyCount,
54
54
  runMigrations
55
- } from "./index-qn7xstt2.js";
55
+ } from "./index-63k48rv9.js";
56
56
  import {
57
57
  installTagIdentityRevisionTrigger,
58
58
  ensureColumn,
@@ -1277,7 +1277,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1277
1277
  state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
1278
1278
  if (signal.aborted || !readsOpenCodeStore)
1279
1279
  return;
1280
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-v06g3vka.js"));
1280
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-jjb48bt9.js"));
1281
1281
  const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-73mmm76q.js"));
1282
1282
  if (signal.aborted)
1283
1283
  return;
@@ -39,6 +39,7 @@ import {
39
39
  isRustMarkerAdmissionFenced,
40
40
  readReplayEnvelope,
41
41
  readReplayDocument,
42
+ updateReplayDocument,
42
43
  writeReplayDocument,
43
44
  describeProtectedTailDrainBudgetSkip,
44
45
  loadProtectedTailMeta,
@@ -69,6 +70,7 @@ import {
69
70
  serializeStrippedPlaceholderState,
70
71
  THINKING_BINDING_RECOVERY_FROZEN_PREFIX,
71
72
  THINKING_BINDING_STRIP_ORDER_END_MARKER,
73
+ COMPACTION_OFF_THINKING_FROZEN_PREFIX,
72
74
  getMergedReasoningStrippedIds,
73
75
  addMergedReasoningStrippedIds,
74
76
  parseProcessedImageMarkers,
@@ -95,7 +97,7 @@ import {
95
97
  getRawSessionTagKeysThrough2,
96
98
  getLegacyProtectedTailStartOrdinal2,
97
99
  readSessionChunk2
98
- } from "./index-rmwykbbb.js";
100
+ } from "./index-9zcsy3hh.js";
99
101
  import {
100
102
  getHarness2,
101
103
  harnessOwnsOpenCodeStore2
@@ -162,7 +164,7 @@ import {
162
164
  LATEST_SUPPORTED_VERSION,
163
165
  getPersistedSchemaVersion,
164
166
  openDatabase
165
- } from "./index-fgncb0ng.js";
167
+ } from "./index-jrr131e0.js";
166
168
  import {
167
169
  inRootAsyncContext2,
168
170
  Database2,
@@ -194,7 +196,7 @@ import {
194
196
  resolveStoredPathWorkspaceIdentity,
195
197
  sourceNameForMemory,
196
198
  computeWorkspaceEpochFingerprint
197
- } from "./index-qn7xstt2.js";
199
+ } from "./index-63k48rv9.js";
198
200
  import {
199
201
  getTableColumnNames
200
202
  } from "./index-bp5083x2.js";
@@ -247,7 +249,7 @@ import {
247
249
  toMessageIndexSource2,
248
250
  clearIndexedMessagesInTransaction2,
249
251
  indexSourcesAfterOrdinal2
250
- } from "./index-x4njr8df.js";
252
+ } from "./index-se4m2g6w.js";
251
253
  import {
252
254
  stripWellFormedLeadingTagPrefix,
253
255
  stripTagPrefix,
@@ -274,7 +276,7 @@ import {
274
276
  insertPrimerCandidates,
275
277
  promoteSessionFactsDurable,
276
278
  embedPromotedFacts
277
- } from "./index-v8awdgvd.js";
279
+ } from "./index-3h4dp9wb.js";
278
280
  import {
279
281
  pushNotification2
280
282
  } from "./index-x8a7jmkh.js";
@@ -6436,6 +6438,34 @@ function noteLkgCapturedPrefix(sessionId) {
6436
6438
  if (!sessions.has(sessionId))
6437
6439
  sessions.set(sessionId, {});
6438
6440
  }
6441
+ function readPersistedLkgUntaggedInputIds(db, sessionId) {
6442
+ try {
6443
+ const saved = readReplayEnvelope(db, sessionId, "read").lkgUntaggedInputIds;
6444
+ return Array.isArray(saved) ? saved.filter((id) => typeof id === "string" && id.length > 0) : [];
6445
+ } catch (error) {
6446
+ sessionLog2(sessionId, "LKG untagged-input record unreadable:", error);
6447
+ return [];
6448
+ }
6449
+ }
6450
+ function persistLkgUntaggedInputIds(db, sessionId, ids) {
6451
+ const next = [...new Set(ids)].sort();
6452
+ try {
6453
+ return updateReplayDocument(db, sessionId, (doc) => {
6454
+ const saved = Array.isArray(doc.lkgUntaggedInputIds) ? doc.lkgUntaggedInputIds : [];
6455
+ if (JSON.stringify(saved) === JSON.stringify(next))
6456
+ return false;
6457
+ doc.version = 2;
6458
+ if (next.length > 0)
6459
+ doc.lkgUntaggedInputIds = next;
6460
+ else
6461
+ delete doc.lkgUntaggedInputIds;
6462
+ return true;
6463
+ });
6464
+ } catch (error) {
6465
+ sessionLog2(sessionId, "LKG untagged-input record write failed:", error);
6466
+ return false;
6467
+ }
6468
+ }
6439
6469
  function noteLkgRecoveryPrefix(args) {
6440
6470
  const digests = [
6441
6471
  ...args.entry.entryContentDigests,
@@ -6446,19 +6476,23 @@ function noteLkgRecoveryPrefix(args) {
6446
6476
  const ids = args.entry.entryInputIds;
6447
6477
  if (ids.some((id) => !id) || new Set(ids).size !== ids.length)
6448
6478
  return false;
6479
+ const untaggedInputIds = new Set([
6480
+ ...sessions.get(args.sessionId)?.prefix?.untaggedInputIds ?? [],
6481
+ ...args.db ? readPersistedLkgUntaggedInputIds(args.db, args.sessionId) : [],
6482
+ ...ids.slice(args.entry.anchorIndex + 1)
6483
+ ]);
6449
6484
  sessions.set(args.sessionId, {
6450
6485
  fenceRevision: sessions.get(args.sessionId)?.fenceRevision,
6451
6486
  prefix: {
6452
6487
  inputs: ids.map((id, index) => ({ id, digest: digests[index] })),
6453
6488
  json: JSON.stringify(args.messages),
6454
- untaggedInputIds: new Set([
6455
- ...sessions.get(args.sessionId)?.prefix?.untaggedInputIds ?? [],
6456
- ...ids.slice(args.entry.anchorIndex + 1)
6457
- ]),
6489
+ untaggedInputIds,
6458
6490
  modelKey: args.modelKey,
6459
6491
  providerKey: args.providerKey
6460
6492
  }
6461
6493
  });
6494
+ if (args.db)
6495
+ persistLkgUntaggedInputIds(args.db, args.sessionId, untaggedInputIds);
6462
6496
  return true;
6463
6497
  }
6464
6498
  function readLkgRecoveryPrefix(sessionId, inputs, messages, db) {
@@ -7463,11 +7497,15 @@ function clonePiContentDecisions(raw, filter) {
7463
7497
  ])}`);
7464
7498
  continue;
7465
7499
  }
7466
- if (entry.startsWith(THINKING_BINDING_RECOVERY_FROZEN_PREFIX)) {
7467
- const messageId = entry.slice(THINKING_BINDING_RECOVERY_FROZEN_PREFIX.length);
7500
+ const thinkingPrefix = [
7501
+ THINKING_BINDING_RECOVERY_FROZEN_PREFIX,
7502
+ COMPACTION_OFF_THINKING_FROZEN_PREFIX
7503
+ ].find((prefix) => entry.startsWith(prefix));
7504
+ if (thinkingPrefix) {
7505
+ const messageId = entry.slice(thinkingPrefix.length);
7468
7506
  if (messageId.length === 0 || !filter.includeMessageId(messageId))
7469
7507
  continue;
7470
- copied.push(`${THINKING_BINDING_RECOVERY_FROZEN_PREFIX}${mapMessageId(filter, messageId) ?? messageId}`);
7508
+ copied.push(`${thinkingPrefix}${mapMessageId(filter, messageId) ?? messageId}`);
7471
7509
  continue;
7472
7510
  }
7473
7511
  if (entry.startsWith(MERGED_REASONING_PARTS_PREFIX) || entry.startsWith("pi-content-replay-"))
@@ -8877,9 +8915,33 @@ var promptFailureDetails = new WeakMap;
8877
8915
  function isHostTimeoutError(error) {
8878
8916
  return error !== null && typeof error === "object" && error.name === "TimeoutError";
8879
8917
  }
8918
+
8919
+ class ModelProducedNoOutputError extends Error {
8920
+ waitedMs;
8921
+ constructor(waitedMs) {
8922
+ super(`prompt timed out after ${waitedMs}ms with no model output`);
8923
+ this.waitedMs = waitedMs;
8924
+ this.name = "ModelProducedNoOutputError";
8925
+ }
8926
+ }
8927
+ var modelActivityBySignal = new WeakMap;
8928
+ function noteModelActivityMonitored(signal) {
8929
+ const activity = signal ? modelActivityBySignal.get(signal) : undefined;
8930
+ if (activity)
8931
+ activity.monitored = true;
8932
+ }
8933
+ function noteModelOutputReceived(signal) {
8934
+ const activity = signal ? modelActivityBySignal.get(signal) : undefined;
8935
+ if (activity) {
8936
+ activity.monitored = true;
8937
+ activity.received = true;
8938
+ }
8939
+ }
8880
8940
  function isPromptTimeoutError(error) {
8881
8941
  if (isHostTimeoutError(error))
8882
8942
  return true;
8943
+ if (error instanceof ModelProducedNoOutputError)
8944
+ return true;
8883
8945
  return error instanceof Error && /^prompt timed out after \d+ms$/.test(error.message);
8884
8946
  }
8885
8947
  function getPromptFailureDetail(error) {
@@ -8957,12 +9019,22 @@ function raceWithSignal(work, signal) {
8957
9019
  work.then(resolve, reject).finally(() => signal.removeEventListener("abort", abort));
8958
9020
  });
8959
9021
  }
8960
- async function promptWithTimeout(client, args, timeoutMs, signal, transport) {
9022
+ async function promptWithTimeout(client, args, timeoutMs, signal, transport, firstOutputTimeoutMs) {
8961
9023
  if (signal?.aborted) {
8962
9024
  throw new Error(externalAbortMessage(signal));
8963
9025
  }
8964
9026
  const controller = new AbortController;
8965
9027
  const timeout = setTimeout(() => controller.abort(), timeoutMs);
9028
+ const activity = { monitored: false, received: false };
9029
+ modelActivityBySignal.set(controller.signal, activity);
9030
+ let silent = false;
9031
+ const firstOutputTimer = firstOutputTimeoutMs !== undefined && firstOutputTimeoutMs < timeoutMs ? setTimeout(() => {
9032
+ if (!activity.monitored || activity.received)
9033
+ return;
9034
+ silent = true;
9035
+ controller.abort();
9036
+ }, firstOutputTimeoutMs) : undefined;
9037
+ const timeoutError = () => silent && firstOutputTimeoutMs !== undefined ? new ModelProducedNoOutputError(firstOutputTimeoutMs) : new Error(`prompt timed out after ${timeoutMs}ms`);
8966
9038
  const onExternalAbort = () => controller.abort();
8967
9039
  signal?.addEventListener("abort", onExternalAbort);
8968
9040
  try {
@@ -8985,7 +9057,7 @@ async function promptWithTimeout(client, args, timeoutMs, signal, transport) {
8985
9057
  if (!transport || transport.childSessionId) {
8986
9058
  await abortChildRun(client, transport?.childSessionId ?? args.path.id);
8987
9059
  }
8988
- throw new Error(`prompt timed out after ${timeoutMs}ms`);
9060
+ throw timeoutError();
8989
9061
  }
8990
9062
  if (isHostTimeoutError(error)) {
8991
9063
  if (!transport || transport.childSessionId) {
@@ -8995,13 +9067,15 @@ async function promptWithTimeout(client, args, timeoutMs, signal, transport) {
8995
9067
  throw error;
8996
9068
  } finally {
8997
9069
  clearTimeout(timeout);
9070
+ if (firstOutputTimer)
9071
+ clearTimeout(firstOutputTimer);
8998
9072
  signal?.removeEventListener("abort", onExternalAbort);
8999
9073
  }
9000
9074
  if (signal?.aborted || controller.signal.aborted) {
9001
9075
  if (!transport || transport.childSessionId) {
9002
9076
  await abortChildRun(client, transport?.childSessionId ?? args.path.id);
9003
9077
  }
9004
- throw new Error(signal?.aborted ? externalAbortMessage(signal) : `prompt timed out after ${timeoutMs}ms`);
9078
+ throw signal?.aborted ? new Error(externalAbortMessage(signal)) : timeoutError();
9005
9079
  }
9006
9080
  }
9007
9081
  async function abortChildRun(client, sessionId) {
@@ -9019,6 +9093,8 @@ async function abortChildRun(client, sessionId) {
9019
9093
  function isNonRetryable(error, externalSignal) {
9020
9094
  if (externalSignal?.aborted || error instanceof HiddenCompletionRefusal && error.terminal || error instanceof HiddenAgentStepLimit || error instanceof DreamTokenBudgetExceeded)
9021
9095
  return true;
9096
+ if (error instanceof ModelProducedNoOutputError)
9097
+ return false;
9022
9098
  if (error instanceof Error) {
9023
9099
  if (error.name === "AbortError")
9024
9100
  return true;
@@ -9050,7 +9126,7 @@ function classifyPromptFailure(error, phase, externalSignal) {
9050
9126
  if (externalSignal?.aborted || message === "prompt aborted by external signal") {
9051
9127
  return "child_aborted";
9052
9128
  }
9053
- if (/^prompt timed out after \d+ms$/.test(message) || isHostTimeoutError(error)) {
9129
+ if (error instanceof ModelProducedNoOutputError || /^prompt timed out after \d+ms$/.test(message) || isHostTimeoutError(error)) {
9054
9130
  return "provider_timeout";
9055
9131
  }
9056
9132
  if (phase === "validation") {
@@ -9085,11 +9161,11 @@ function throwWithPromptFailure(legacyError, failedAttempts, args, timeoutMs, tr
9085
9161
  });
9086
9162
  throw error;
9087
9163
  }
9088
- async function attemptOnce(client, args, timeoutMs, signal, callContext, label, transport, allowModelSuggestions = true) {
9164
+ async function attemptOnce(client, args, timeoutMs, signal, callContext, label, transport, allowModelSuggestions = true, firstOutputTimeoutMs) {
9089
9165
  const originalBody = { ...args.body };
9090
9166
  const attemptArgs = copyPromptArgs(args, originalBody);
9091
9167
  try {
9092
- await promptWithTimeout(client, attemptArgs, timeoutMs, signal, transport);
9168
+ await promptWithTimeout(client, attemptArgs, timeoutMs, signal, transport, firstOutputTimeoutMs);
9093
9169
  return;
9094
9170
  } catch (error) {
9095
9171
  if (isNonRetryable(error, signal) || !allowModelSuggestions)
@@ -9108,9 +9184,30 @@ async function attemptOnce(client, args, timeoutMs, signal, callContext, label,
9108
9184
  providerID: suggestion.providerID,
9109
9185
  modelID: suggestion.suggestion
9110
9186
  }
9111
- }), timeoutMs, signal, transport);
9187
+ }), timeoutMs, signal, transport, firstOutputTimeoutMs);
9112
9188
  }
9113
9189
  }
9190
+ function createChainClock(options, timeoutMs) {
9191
+ const fallbacks = options.fallbackModels ?? [];
9192
+ const hasValidFallbackFrom = (index) => fallbacks.slice(index).some((fallback) => {
9193
+ const entry = toModelEntry(fallback);
9194
+ return entry ? parseProviderModel(entry.model) !== null : false;
9195
+ });
9196
+ let silentSpentMs = 0;
9197
+ return {
9198
+ budget(nextFallbackIndex) {
9199
+ const attemptTimeoutMs = Math.max(1, timeoutMs - silentSpentMs);
9200
+ if (options.firstOutputTimeoutMs === undefined || !hasValidFallbackFrom(nextFallbackIndex))
9201
+ return { timeoutMs: attemptTimeoutMs };
9202
+ const bound = Math.min(options.firstOutputTimeoutMs, Math.floor(attemptTimeoutMs / 2));
9203
+ return bound > 0 ? { timeoutMs: attemptTimeoutMs, firstOutputTimeoutMs: bound } : { timeoutMs: attemptTimeoutMs };
9204
+ },
9205
+ settle(error, startedAt) {
9206
+ if (error instanceof ModelProducedNoOutputError)
9207
+ silentSpentMs += Date.now() - startedAt;
9208
+ }
9209
+ };
9210
+ }
9114
9211
  async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
9115
9212
  const timeoutMs = options.timeoutMs ?? 300000;
9116
9213
  const callContext = options.callContext ?? "subagent";
@@ -9119,11 +9216,15 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
9119
9216
  const baseArgs = copyPromptArgs(args, baseBody);
9120
9217
  const explicitPrimaryLabel = baseBody.model?.providerID && baseBody.model.modelID ? `${baseBody.model.providerID}/${baseBody.model.modelID}` : "primary";
9121
9218
  let lastError = null;
9219
+ const clock = createChainClock(options, timeoutMs);
9220
+ const primaryStartedAt = Date.now();
9122
9221
  try {
9123
- await attemptOnce(client, baseArgs, timeoutMs, options.signal, callContext, explicitPrimaryLabel, options.transport, options.allowModelSuggestions);
9222
+ const budget = clock.budget(0);
9223
+ await attemptOnce(client, baseArgs, budget.timeoutMs, options.signal, callContext, explicitPrimaryLabel, options.transport, options.allowModelSuggestions, budget.firstOutputTimeoutMs);
9124
9224
  return;
9125
9225
  } catch (error) {
9126
9226
  lastError = error;
9227
+ clock.settle(error, primaryStartedAt);
9127
9228
  if (isNonRetryable(error, options.signal))
9128
9229
  throw error;
9129
9230
  if (fallbacks.length === 0) {
@@ -9145,12 +9246,15 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
9145
9246
  model: parsed,
9146
9247
  ...fallback?.qualifier ? { variant: fallback.qualifier } : {}
9147
9248
  });
9249
+ const attemptStartedAt = Date.now();
9148
9250
  try {
9149
- await attemptOnce(client, attemptArgs, timeoutMs, options.signal, callContext, label, options.transport, options.allowModelSuggestions);
9251
+ const budget = clock.budget(i + 1);
9252
+ await attemptOnce(client, attemptArgs, budget.timeoutMs, options.signal, callContext, label, options.transport, options.allowModelSuggestions, budget.firstOutputTimeoutMs);
9150
9253
  log2(`[${callContext}] fallback succeeded with ${label} (attempt ${i + 2}/${fallbacks.length + 1})`);
9151
9254
  return;
9152
9255
  } catch (error) {
9153
9256
  lastError = error;
9257
+ clock.settle(error, attemptStartedAt);
9154
9258
  if (isNonRetryable(error, options.signal))
9155
9259
  throw error;
9156
9260
  const remaining = fallbacks.length - i - 1;
@@ -9162,9 +9266,9 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
9162
9266
  log2(`[${callContext}] all models exhausted; tried: ${[explicitPrimaryLabel, ...fallbacks.map((fallback) => toModelEntry(fallback)?.model ?? String(fallback))].join(", ")}; last error: ${shortErr(lastError)}`);
9163
9267
  throw lastError ?? new Error("All fallback models failed");
9164
9268
  }
9165
- async function attemptAndValidate(client, args, timeoutMs, signal, callContext, attempt, options) {
9269
+ async function attemptAndValidate(client, args, timeoutMs, signal, callContext, attempt, options, firstOutputTimeoutMs) {
9166
9270
  try {
9167
- await attemptOnce(client, args, timeoutMs, signal, callContext, attempt.label, options.transport, options.allowModelSuggestions);
9271
+ await attemptOnce(client, args, timeoutMs, signal, callContext, attempt.label, options.transport, options.allowModelSuggestions, firstOutputTimeoutMs);
9168
9272
  } catch (error) {
9169
9273
  throw {
9170
9274
  error,
@@ -9226,6 +9330,8 @@ async function promptSyncWithValidatedOutputRetry(client, args, options) {
9226
9330
  let firstError = null;
9227
9331
  let lastError = null;
9228
9332
  const cooledPrimary = primaryQuotaFailure(explicitPrimaryLabel);
9333
+ const clock = createChainClock(options, timeoutMs);
9334
+ const primaryStartedAt = Date.now();
9229
9335
  try {
9230
9336
  if (cooledPrimary)
9231
9337
  throw {
@@ -9240,16 +9346,18 @@ async function promptSyncWithValidatedOutputRetry(client, args, options) {
9240
9346
  skipped: true
9241
9347
  }
9242
9348
  };
9243
- return await attemptAndValidate(client, baseArgs, timeoutMs, options.signal, callContext, {
9349
+ const budget = clock.budget(0);
9350
+ return await attemptAndValidate(client, baseArgs, budget.timeoutMs, options.signal, callContext, {
9244
9351
  label: explicitPrimaryLabel,
9245
9352
  attemptIndex: 0,
9246
9353
  isFallback: false,
9247
9354
  totalAttempts,
9248
9355
  model: baseBody.model
9249
- }, options);
9356
+ }, options, budget.firstOutputTimeoutMs);
9250
9357
  } catch (caught) {
9251
9358
  const failure = caught;
9252
9359
  failedAttempts.push(failure);
9360
+ clock.settle(failure.error, primaryStartedAt);
9253
9361
  firstError = failure.error;
9254
9362
  lastError = failure.error;
9255
9363
  if (failure.error instanceof DreamerProviderOutputFailureError && failure.error.quotaResetAt !== undefined)
@@ -9287,13 +9395,16 @@ async function promptSyncWithValidatedOutputRetry(client, args, options) {
9287
9395
  totalAttempts,
9288
9396
  model: parsed
9289
9397
  };
9398
+ const attemptStartedAt = Date.now();
9290
9399
  try {
9291
- const result = await attemptAndValidate(client, attemptArgs, timeoutMs, options.signal, callContext, attempt, options);
9400
+ const budget = clock.budget(i + 1);
9401
+ const result = await attemptAndValidate(client, attemptArgs, budget.timeoutMs, options.signal, callContext, attempt, options, budget.firstOutputTimeoutMs);
9292
9402
  log2(`[${callContext}] fallback succeeded with ${label} (attempt ${i + 2}/${fallbacks.length + 1})`);
9293
9403
  return result;
9294
9404
  } catch (caught) {
9295
9405
  const failure = caught;
9296
9406
  failedAttempts.push(failure);
9407
+ clock.settle(failure.error, attemptStartedAt);
9297
9408
  lastError = failure.error;
9298
9409
  if (isNonRetryable(failure.error, options.signal)) {
9299
9410
  throwWithPromptFailure(failure.error, failedAttempts, args, timeoutMs, options.transport);
@@ -9515,6 +9626,24 @@ function isTerminalAssistant(message) {
9515
9626
  const info = infoOf(message);
9516
9627
  return isSettledAssistant(message) && info.finish !== "tool-calls" && info.finish !== "tool_use" && !(message && typeof message === "object" && Array.isArray(message.parts) && message.parts.some((part) => part.type === "tool"));
9517
9628
  }
9629
+ function showsModelOutput(message) {
9630
+ if (infoOf(message).role !== "assistant")
9631
+ return false;
9632
+ const tokens = sumTokensFromChildMessages([message]);
9633
+ if (tokens.input + tokens.output + tokens.cacheRead + tokens.cacheWrite > 0)
9634
+ return true;
9635
+ const parts = message?.parts;
9636
+ if (!Array.isArray(parts))
9637
+ return false;
9638
+ return parts.some((part) => {
9639
+ if (!part || typeof part !== "object")
9640
+ return false;
9641
+ const { type, text } = part;
9642
+ if (type === "tool")
9643
+ return true;
9644
+ return (type === "text" || type === "reasoning") && typeof text === "string" && text.trim().length > 0;
9645
+ });
9646
+ }
9518
9647
  function unwrapData(response) {
9519
9648
  if (response && typeof response === "object" && "data" in response) {
9520
9649
  return response.data;
@@ -9612,6 +9741,8 @@ async function promptAsyncAndWaitForIdle(client, request, options = {}) {
9612
9741
  }
9613
9742
  let sentAt = Date.now();
9614
9743
  let sawBusy = false;
9744
+ noteModelActivityMonitored(signal);
9745
+ let sawOutput = false;
9615
9746
  for (;; ) {
9616
9747
  await sleep(pollIntervalMs, signal);
9617
9748
  const hostError = activeSessionErrors.get(sessionId);
@@ -9626,6 +9757,13 @@ async function promptAsyncAndWaitForIdle(client, request, options = {}) {
9626
9757
  }
9627
9758
  const status = await readStatus(session, sessionId, dir, signal);
9628
9759
  const messages = await readMessages(session, sessionId, dir, signal);
9760
+ if (!sawOutput && messages.some((message) => {
9761
+ const id = messageId2(message);
9762
+ return id !== null && !initialBaseline.has(id) && showsModelOutput(message);
9763
+ })) {
9764
+ sawOutput = true;
9765
+ noteModelOutputReceived(signal);
9766
+ }
9629
9767
  if (budget) {
9630
9768
  const latest = messages.at(-1);
9631
9769
  const latestId = messageId2(latest);
@@ -21378,4 +21516,4 @@ async function executeContextRecomp(deps, options = {}) {
21378
21516
  return (await executeContextRecompWithResult(deps, options)).message;
21379
21517
  }
21380
21518
 
21381
- export { denyTaskRoutingToCallerAgents, buildHiddenAgentRegistrations, buildZenReadAgentRegistrations, buildHiddenAgentConfig, getMagicContextBuiltinCommands, formatConfigParseStatusLine, claimConfigParseFailuresOnce, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, loadPluginConfigDetailed, historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, createDreamerOutputCapSampler, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, registerLkgPersistence, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, queueMemoryMutation, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, createChildSessionWithFence, HiddenCompletionRefusal, DreamerProviderOutputFailureError, withDreamerModelCooldown, providerOutputFailureFromInvalidManifest, HIDDEN_HISTORIAN_AGENT, HIDDEN_DREAMER_AGENT, HIDDEN_CURATE_AGENT, hiddenAgentFor, hiddenToolLoop, HIDDEN_RUN_DISPOSED_REASON, noteChildOfDisposedInstance, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, isPromptTimeoutError, getPromptFailureDetail, raceWithSignal, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, failedInvocationStatus, sumTokensFromChildMessages, recordChildInvocation, recordPromptSessionError, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, setKeepSubagents, teardownChildSession, getCompartmentEvents, runTokenLog, formatRunTokenLog, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, prepareCompactionMarkerCandidates, removeMcOwnedCompactionMarkers, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, extractM0Block, formatDate, TEMPORAL_MARKER_REPLAY_PATTERN, collectTemporalCandidates, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, MaterializeContentionError, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, materializeM0, hydrateCachedM0Mural, resetPrefixTrimFallbackState, findHostCompactionWindow, capturePrefixTrimSourceOrder, prepareCachedM0M1Replay, hasCompleteCachedM0M1, injectM0M1, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, readCoordinateGeneration, readCoordinateRebaseNotice, formatCoordinateRebaseNotice, rebaseSessionCoordinatesAsync, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, omitIncompleteFileTokenTotals, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, noteTransformPassForExactOrdinalReads, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, executeContextRecomp };
21519
+ export { denyTaskRoutingToCallerAgents, buildHiddenAgentRegistrations, buildZenReadAgentRegistrations, buildHiddenAgentConfig, getMagicContextBuiltinCommands, formatConfigParseStatusLine, claimConfigParseFailuresOnce, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, loadPluginConfigDetailed, historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, createDreamerOutputCapSampler, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, readPersistedLkgUntaggedInputIds, persistLkgUntaggedInputIds, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, registerLkgPersistence, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, queueMemoryMutation, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, createChildSessionWithFence, HiddenCompletionRefusal, DreamerProviderOutputFailureError, withDreamerModelCooldown, providerOutputFailureFromInvalidManifest, HIDDEN_HISTORIAN_AGENT, HIDDEN_DREAMER_AGENT, HIDDEN_CURATE_AGENT, hiddenAgentFor, hiddenToolLoop, HIDDEN_RUN_DISPOSED_REASON, noteChildOfDisposedInstance, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, isPromptTimeoutError, getPromptFailureDetail, raceWithSignal, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, failedInvocationStatus, sumTokensFromChildMessages, recordChildInvocation, recordPromptSessionError, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, setKeepSubagents, teardownChildSession, getCompartmentEvents, runTokenLog, formatRunTokenLog, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, prepareCompactionMarkerCandidates, removeMcOwnedCompactionMarkers, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, extractM0Block, formatDate, TEMPORAL_MARKER_REPLAY_PATTERN, collectTemporalCandidates, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, MaterializeContentionError, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, materializeM0, hydrateCachedM0Mural, resetPrefixTrimFallbackState, findHostCompactionWindow, capturePrefixTrimSourceOrder, prepareCachedM0M1Replay, hasCompleteCachedM0M1, injectM0M1, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, readCoordinateGeneration, readCoordinateRebaseNotice, formatCoordinateRebaseNotice, rebaseSessionCoordinatesAsync, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, omitIncompleteFileTokenTotals, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, noteTransformPassForExactOrdinalReads, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, executeContextRecomp };
@@ -35,7 +35,7 @@ import {
35
35
  } from "./index-58e3y90n.js";
36
36
  import {
37
37
  cleanUserText2
38
- } from "./index-rmwykbbb.js";
38
+ } from "./index-9zcsy3hh.js";
39
39
  import {
40
40
  recordMessageFtsRowid2,
41
41
  recordIndexedMessageTime2,
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  detectOverflow,
29
29
  isAnthropicFamilyRoute,
30
30
  readRawSessionMessages2
31
- } from "./index-rmwykbbb.js";
31
+ } from "./index-9zcsy3hh.js";
32
32
  import {
33
33
  setHarness2
34
34
  } from "./index-pavzsdc6.js";
@@ -97,7 +97,7 @@ import {
97
97
  checkCompactionMarkerConsistency,
98
98
  clearInjectionCache,
99
99
  clearNoteNudgeTriggerOnly
100
- } from "./index-s1ex9y6p.js";
100
+ } from "./index-rpxdjkm0.js";
101
101
  import"./index-sd3egckz.js";
102
102
  import {
103
103
  hasTrustedAbsoluteWall,
@@ -185,7 +185,7 @@ import {
185
185
  parameterDescriptionsFor,
186
186
  MagicContextRpcServer,
187
187
  applyHiddenSubagentTemperature
188
- } from "./index-936py2wm.js";
188
+ } from "./index-3esx8tkf.js";
189
189
  import {
190
190
  resolveOpenCodeDbPath,
191
191
  openCodeDbPathExists,
@@ -209,7 +209,7 @@ import {
209
209
  openDatabaseAsync,
210
210
  isDatabasePersisted,
211
211
  getDatabasePersistenceError
212
- } from "./index-fgncb0ng.js";
212
+ } from "./index-jrr131e0.js";
213
213
  import {
214
214
  setHomeProjectPermission,
215
215
  ProjectIdentityError,
@@ -229,7 +229,7 @@ import {
229
229
  observeSessionActivity,
230
230
  backfillSessionActivity,
231
231
  deleteIndexedMessage2
232
- } from "./index-x4njr8df.js";
232
+ } from "./index-se4m2g6w.js";
233
233
  import {
234
234
  recordSessionProjectIdentity
235
235
  } from "./index-rr2bb45z.js";
@@ -243,7 +243,7 @@ import {
243
243
  forgetRawSessionOrdinalWatermark2
244
244
  } from "./index-s734jcsr.js";
245
245
  import"./index-a6mc0v4d.js";
246
- import"./index-qn7xstt2.js";
246
+ import"./index-63k48rv9.js";
247
247
  import"./index-fr0wbhdn.js";
248
248
  import {
249
249
  preloadTokenizer
@@ -256,7 +256,7 @@ import"./index-6x57ar45.js";
256
256
  import {
257
257
  getDefaultSubcConnectionFile,
258
258
  SubcModuleTransport
259
- } from "./index-s7j8tvhv.js";
259
+ } from "./index-dxmq29t1.js";
260
260
  import"./index-qt1qqasc.js";
261
261
  import"./index-y9f76s3f.js";
262
262
  import {
@@ -293,7 +293,7 @@ import {
293
293
  getEmbeddingCoverageStatus2
294
294
  } from "./index-ze7mvk54.js";
295
295
  import"./index-b5vqckbw.js";
296
- import"./index-v8awdgvd.js";
296
+ import"./index-3h4dp9wb.js";
297
297
  import {
298
298
  pushNotification2
299
299
  } from "./index-x8a7jmkh.js";
@@ -308,10 +308,10 @@ import {
308
308
  setCtxReduceRegisteredGlobally,
309
309
  clearToolPermissionDenied,
310
310
  resetDegradedCacheCount2
311
- } from "./index-e4xv8890.js";
311
+ } from "./index-jhghdnsm.js";
312
312
  import {
313
313
  runManagedRecomp2
314
- } from "./index-r4nkrs05.js";
314
+ } from "./index-c1p88z1y.js";
315
315
  import {
316
316
  isValidSemver,
317
317
  compareSemverCore
@@ -319,9 +319,9 @@ import {
319
319
  import"./index-fmsr7v69.js";
320
320
  import {
321
321
  runManagedWrapup2
322
- } from "./index-24jbw52d.js";
322
+ } from "./index-4911rn0b.js";
323
323
  import"./index-kaqs6h31.js";
324
- import"./index-6s5941tm.js";
324
+ import"./index-edmpdxcw.js";
325
325
  import {
326
326
  isDreamerRunnable,
327
327
  isSmartNoteSurfaceAvailable,
@@ -8189,7 +8189,7 @@ var require_src2 = __commonJS(function(exports, module) {
8189
8189
  // package.json
8190
8190
  var package_default = {
8191
8191
  name: "@cortexkit/opencode-magic-context",
8192
- version: "0.49.18",
8192
+ version: "0.49.19",
8193
8193
  type: "module",
8194
8194
  description: "OpenCode plugin for Magic Context — cross-session memory and context management",
8195
8195
  main: "dist/index.js",
@@ -11853,7 +11853,11 @@ function createToolRegistry(args) {
11853
11853
  getProtectionWindow: (sessionId) => getProtectionWindowForSession(db, sessionId, getObservedEpochFloor(db, sessionId)),
11854
11854
  rustToolBackends
11855
11855
  }),
11856
- ...createCtxExpandTools({ db, expandTools: pluginConfig.historian?.expand_tools }),
11856
+ ...createCtxExpandTools({
11857
+ db,
11858
+ expandTools: pluginConfig.historian?.expand_tools,
11859
+ transformMode: pluginConfig.transform_mode
11860
+ }),
11857
11861
  ...createCtxNoteTools({
11858
11862
  db,
11859
11863
  dreamerEnabled: isDreamerRunnable(pluginConfig),
@@ -12035,7 +12039,7 @@ async function setup(context) {
12035
12039
  if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
12036
12040
  log2(`[magic-context] Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
12037
12041
  }
12038
- const { registerContext } = await import("./context-m897gfp9.js");
12042
+ const { registerContext } = await import("./context-j31m2dv7.js");
12039
12043
  setHarness2("opencode2");
12040
12044
  bindStaleBuildNotice({}, import.meta.url, "opencode2");
12041
12045
  const duties = await registerContext(context);
@@ -12512,7 +12516,7 @@ var server = async (ctx) => {
12512
12516
  rustReplayParticipant: () => magicContextRuntime.magicContext?.getRustReplayParticipant?.() ?? null,
12513
12517
  onStorageBusyRefusal: async (sessionId, message) => {
12514
12518
  const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-6ve0e8p4.js"));
12515
- const { abortSessionFailClosed } = await importPluginModule(() => import("./transform-postprocess-phase-zpgav0h7.js"));
12519
+ const { abortSessionFailClosed } = await importPluginModule(() => import("./transform-postprocess-phase-jj99r7z2.js"));
12516
12520
  await sendStatusNotification(ctx.client, sessionId, message, {
12517
12521
  toastDurationMs: 15000
12518
12522
  });
@@ -14,7 +14,7 @@ import {
14
14
  markMessageIndexDirty2,
15
15
  getIndexableContent2,
16
16
  indexSingleMessage2
17
- } from "./index-x4njr8df.js";
17
+ } from "./index-se4m2g6w.js";
18
18
  import"./index-1zx87sdm.js";
19
19
  import"./index-cf74k5ak.js";
20
20
  import"./index-c5pytzne.js";
@@ -24,7 +24,7 @@ import"./index-v0p37hm2.js";
24
24
  import"./index-s734jcsr.js";
25
25
  import"./index-58e3y90n.js";
26
26
  import"./index-kq82mtg0.js";
27
- import"./index-rmwykbbb.js";
27
+ import"./index-9zcsy3hh.js";
28
28
  import"./index-ke416mdc.js";
29
29
  import"./index-a6mc0v4d.js";
30
30
  import"./index-6x57ar45.js";
@@ -17,8 +17,8 @@ import {
17
17
  indexMessagesAfterOrdinal2,
18
18
  indexSourcesAfterOrdinal2,
19
19
  sweepOrphanedOpenCodeMessageIndexesCooperatively2
20
- } from "./index-x4njr8df.js";
21
- import"./index-rmwykbbb.js";
20
+ } from "./index-se4m2g6w.js";
21
+ import"./index-9zcsy3hh.js";
22
22
  import"./index-cf74k5ak.js";
23
23
  import"./index-1zx87sdm.js";
24
24
  import"./index-kq82mtg0.js";
@@ -10,7 +10,7 @@ import {
10
10
  import"./index-fr0wbhdn.js";
11
11
  import {
12
12
  runMigrationsWithRetry
13
- } from "./index-qn7xstt2.js";
13
+ } from "./index-63k48rv9.js";
14
14
  import"./index-bp5083x2.js";
15
15
  import"./index-58e3y90n.js";
16
16
  import"./index-2vxtcb95.js";
@@ -19,7 +19,7 @@ import"./index-fb3zxn06.js";
19
19
  import {
20
20
  setSqlitePragmaConfig,
21
21
  initializeDatabase
22
- } from "./index-fgncb0ng.js";
22
+ } from "./index-jrr131e0.js";
23
23
  import"./index-v0p37hm2.js";
24
24
  import"./index-s734jcsr.js";
25
25
  import"./index-a6mc0v4d.js";