@cortexkit/opencode-magic-context 0.49.9 → 0.49.11

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 (109) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/{conflict-warning-hook-w3crzrar.js → conflict-warning-hook-xwkfncav.js} +3 -3
  3. package/dist/{context-ey3ap3cc.js → context-twz3s0cg.js} +220 -43
  4. package/dist/{embedding-backfill-3h2m5n0q.js → embedding-backfill-fjbfh1dt.js} +3 -3
  5. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +12 -1
  6. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  7. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  8. package/dist/features/magic-context/memory-enabled.d.ts +5 -0
  9. package/dist/features/magic-context/memory-enabled.d.ts.map +1 -0
  10. package/dist/features/magic-context/search-pool-fixture.d.ts +39 -0
  11. package/dist/features/magic-context/search-pool-fixture.d.ts.map +1 -0
  12. package/dist/features/magic-context/search.d.ts.map +1 -1
  13. package/dist/features/magic-context/transform-decision-log.d.ts +57 -2
  14. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
  15. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
  16. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  17. package/dist/hooks/magic-context/historian-prompt-fit.d.ts +12 -2
  18. package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
  19. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  20. package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -1
  21. package/dist/hooks/magic-context/read-session-db.d.ts +5 -0
  22. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/render-options.d.ts +21 -0
  24. package/dist/hooks/magic-context/render-options.d.ts.map +1 -0
  25. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  26. package/dist/hooks/magic-context/tag-messages.d.ts +4 -0
  27. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  28. package/dist/hooks/magic-context/transform.d.ts +1 -7
  29. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  30. package/dist/{index-pgy3h49n.js → index-0abg88h2.js} +1 -1
  31. package/dist/{index-0x9cn9w1.js → index-0j6crjgh.js} +2 -2
  32. package/dist/{index-a43xq1pg.js → index-4ccdr7yw.js} +1 -1
  33. package/dist/{index-4hb8nt93.js → index-4jkhhpn1.js} +1 -1
  34. package/dist/{index-ffa8x2as.js → index-84j7jq8a.js} +13 -8
  35. package/dist/{index-7bjgyaj1.js → index-9159kk15.js} +238 -130
  36. package/dist/{index-q76br5zn.js → index-bzp9s8z2.js} +24 -19
  37. package/dist/{index-21919gcq.js → index-g40wgxxt.js} +3 -3
  38. package/dist/{index-x57ep4fp.js → index-hqnggmxn.js} +215 -75
  39. package/dist/{index-6k86es2p.js → index-kkvxnbt8.js} +6 -6
  40. package/dist/{index-nenz4gpb.js → index-q3qck7j2.js} +4 -4
  41. package/dist/{index-wpwpn7nj.js → index-qr1mkc2y.js} +1 -1
  42. package/dist/{index-rg1cezmj.js → index-se1w3v2m.js} +1 -1
  43. package/dist/{index-swgpe402.js → index-xztdf9t7.js} +1 -1
  44. package/dist/{index-16vwdyy5.js → index-yhrrx7qa.js} +1 -1
  45. package/dist/{index-3403gbzj.js → index-z7avx6rw.js} +100 -38
  46. package/dist/index.js +27 -34
  47. package/dist/{message-index-bounded-fskdyc81.js → message-index-bounded-0rbbg9rd.js} +4 -4
  48. package/dist/{message-index-6r1x9cqh.js → message-index-ct5x2kwa.js} +4 -4
  49. package/dist/migration-worker.js +1 -1
  50. package/dist/plugin/dream-timer.d.ts.map +1 -1
  51. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  52. package/dist/{project-embedding-registry-vy7sv9jt.js → project-embedding-registry-ft9gh2e2.js} +2 -2
  53. package/dist/raw-ordinal-warmup-worker.js +2 -2
  54. package/dist/{read-session-chunk-zgpvs423.js → read-session-chunk-y3hhsbzw.js} +2 -2
  55. package/dist/{recomp-orchestrator-77xc8wpe.js → recomp-orchestrator-67k45s0b.js} +11 -11
  56. package/dist/{search-72fkjwk2.js → search-jd8xh721.js} +8 -8
  57. package/dist/{send-session-notification-q8ngbap3.js → send-session-notification-vzhj8bsg.js} +2 -2
  58. package/dist/shared/prompt-surface-runtime.d.ts +5 -0
  59. package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
  60. package/dist/{transform-postprocess-phase-r8d406j0.js → transform-postprocess-phase-pmqxfq4q.js} +11 -11
  61. package/dist/v2/auto-search-worker.js +3 -3
  62. package/dist/v2/{context-z2yagwy4.js → context-p1zfcw41.js} +599 -225
  63. package/dist/v2/{embedding-backfill-vr7wdtrf.js → embedding-backfill-xcw3t6hp.js} +5 -5
  64. package/dist/v2/embedding-worker.js +2 -2
  65. package/dist/v2/hooks/context.d.ts.map +1 -1
  66. package/dist/v2/hooks/dream-manual.d.ts +1 -0
  67. package/dist/v2/hooks/dream-manual.d.ts.map +1 -1
  68. package/dist/v2/hooks/dream-timer.d.ts +3 -1
  69. package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
  70. package/dist/v2/hooks/dream-trigger.d.ts +5 -0
  71. package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
  72. package/dist/v2/hooks/payload.d.ts +1 -1
  73. package/dist/v2/hooks/payload.d.ts.map +1 -1
  74. package/dist/v2/hooks/transform-decision-binding.d.ts +15 -0
  75. package/dist/v2/hooks/transform-decision-binding.d.ts.map +1 -0
  76. package/dist/v2/hooks/transform-features.d.ts +39 -0
  77. package/dist/v2/hooks/transform-features.d.ts.map +1 -0
  78. package/dist/v2/{message-index-bounded-rqc603f2.js → message-index-bounded-7wcbp975.js} +5 -5
  79. package/dist/v2/{message-index-9ezq6wze.js → message-index-cjhv92m2.js} +5 -5
  80. package/dist/v2/migration-worker.js +1 -1
  81. package/dist/v2/{project-embedding-registry-ja23aygk.js → project-embedding-registry-g34gcf74.js} +6 -4
  82. package/dist/v2/raw-ordinal-warmup-worker.js +2 -2
  83. package/dist/v2/{read-session-chunk-7f87tg2q.js → read-session-chunk-8d3v87vr.js} +3 -3
  84. package/dist/v2/{recomp-orchestrator-s5tdpsbs.js → recomp-orchestrator-n0pq36f0.js} +13 -13
  85. package/dist/v2/{search-2td1b1wy.js → search-a1acjwf8.js} +10 -10
  86. package/dist/v2/{send-session-notification-6n7chhyp.js → send-session-notification-z5mcjdea.js} +2 -2
  87. package/dist/v2/{server-4qr18rfg.js → server-5x7kmyz8.js} +1 -1
  88. package/dist/v2/{server-c9w52qss.js → server-7fvmt15t.js} +109 -38
  89. package/dist/v2/{server-44ryn9rb.js → server-83d71zab.js} +1 -1
  90. package/dist/v2/{server-z0rjemg1.js → server-d3f4g62c.js} +2 -2
  91. package/dist/v2/{server-zrwaj29a.js → server-d6t16r89.js} +24 -19
  92. package/dist/v2/{server-23znwjqk.js → server-erfp0xb6.js} +5 -2
  93. package/dist/v2/{server-9a6bwc12.js → server-ewqshbs8.js} +251 -131
  94. package/dist/v2/{server-ak7w74j9.js → server-h3wc20sv.js} +1 -1
  95. package/dist/v2/{server-7e087rvk.js → server-jc8v585p.js} +1 -1
  96. package/dist/v2/{server-4zwx20yg.js → server-kn7skz9r.js} +1 -1
  97. package/dist/v2/{server-2hxypdx5.js → server-pbpp8r8h.js} +13 -8
  98. package/dist/v2/{server-4rs8sm06.js → server-rxcq4t50.js} +3 -3
  99. package/dist/v2/{server-4easnf78.js → server-sg68np13.js} +13 -4
  100. package/dist/v2/{server-gc8x2xdb.js → server-wkhfyzpg.js} +2 -2
  101. package/dist/v2/server.js +4 -4
  102. package/dist/v2/store-reader.d.ts +4 -0
  103. package/dist/v2/store-reader.d.ts.map +1 -1
  104. package/dist/v2/{wrapup-orchestrator-wg8dmmm9.js → wrapup-orchestrator-87q9d5e2.js} +13 -13
  105. package/dist/{wrapup-orchestrator-b1z99yg5.js → wrapup-orchestrator-jqapepw0.js} +12 -12
  106. package/package.json +1 -1
  107. package/src/shared/chunk-vector-writer-guard.test.ts +72 -0
  108. package/src/shared/prompt-surface-runtime.test.ts +15 -0
  109. package/src/shared/prompt-surface-runtime.ts +12 -0
@@ -74,7 +74,7 @@ import {
74
74
  withReadOnlySessionDb,
75
75
  getRawSessionMessageCountFromDb,
76
76
  getMessageTimesFromOpenCodeDb
77
- } from "./index-q76br5zn.js";
77
+ } from "./index-bzp9s8z2.js";
78
78
  import {
79
79
  getToolDefinitionMeasurementSignature,
80
80
  getLargestMeasuredToolDefinitionTokens,
@@ -40,7 +40,7 @@ import {
40
40
  countSessionCompartmentEmbedCoverage,
41
41
  countSessionCompartmentEmbedCoveragePolite,
42
42
  countUnembeddedSessionCompartmentsPolite
43
- } from "./index-7bjgyaj1.js";
43
+ } from "./index-9159kk15.js";
44
44
  import {
45
45
  DEFAULT_LOCAL_EMBEDDING_MODEL
46
46
  } from "./index-w28y7d0z.js";
@@ -1270,7 +1270,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1270
1270
  startMessageFtsRowidMapBackfill(db).then(async () => {
1271
1271
  if (!readsOpenCodeStore)
1272
1272
  return;
1273
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-zgpvs423.js"));
1273
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-y3hhsbzw.js"));
1274
1274
  const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-nb5hhnrt.js"));
1275
1275
  await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
1276
1276
  readPage: readRawSessionMessagePage
@@ -17,7 +17,7 @@ import {
17
17
  } from "./index-a865mj02.js";
18
18
  import {
19
19
  embedTextForProject2
20
- } from "./index-rg1cezmj.js";
20
+ } from "./index-se1w3v2m.js";
21
21
  import {
22
22
  saveEmbeddingIfHashMatches
23
23
  } from "./index-4dhv7mqz.js";
@@ -92,7 +92,7 @@ import {
92
92
  getRawSessionTagKeysThrough2,
93
93
  getLegacyProtectedTailStartOrdinal2,
94
94
  readSessionChunk2
95
- } from "./index-wpwpn7nj.js";
95
+ } from "./index-qr1mkc2y.js";
96
96
  import {
97
97
  getHarness2,
98
98
  harnessOwnsOpenCodeStore2
@@ -159,7 +159,7 @@ import {
159
159
  LATEST_SUPPORTED_VERSION,
160
160
  getPersistedSchemaVersion,
161
161
  openDatabase
162
- } from "./index-swgpe402.js";
162
+ } from "./index-xztdf9t7.js";
163
163
  import {
164
164
  inRootAsyncContext2,
165
165
  Database2,
@@ -211,7 +211,7 @@ import {
211
211
  replaceCompartmentChunkEmbeddings,
212
212
  deleteChunkEmbedBackoffForSession,
213
213
  chunkWindowSourceKey
214
- } from "./index-7bjgyaj1.js";
214
+ } from "./index-9159kk15.js";
215
215
  import {
216
216
  BoundedSessionMap,
217
217
  clearCompressionDepth,
@@ -226,7 +226,7 @@ import {
226
226
  toMessageIndexSource2,
227
227
  clearIndexedMessagesInTransaction2,
228
228
  indexSourcesAfterOrdinal2
229
- } from "./index-0x9cn9w1.js";
229
+ } from "./index-0j6crjgh.js";
230
230
  import {
231
231
  stripWellFormedLeadingTagPrefix,
232
232
  stripTagPrefix,
@@ -247,7 +247,7 @@ import {
247
247
  import {
248
248
  withReadOnlySessionDb,
249
249
  getMessageTimesFromOpenCodeDb
250
- } from "./index-q76br5zn.js";
250
+ } from "./index-bzp9s8z2.js";
251
251
  import {
252
252
  drainBackgroundBatches,
253
253
  contentSha2562,
@@ -255,7 +255,7 @@ import {
255
255
  getProjectChunkEmbeddingModelId2,
256
256
  getProjectEmbeddingMaxInputTokens2,
257
257
  embedItemsForProject2
258
- } from "./index-rg1cezmj.js";
258
+ } from "./index-se1w3v2m.js";
259
259
  import {
260
260
  renderUserFacingFailure,
261
261
  userFacingFailureCode,
@@ -264,7 +264,7 @@ import {
264
264
  insertPrimerCandidates,
265
265
  promoteSessionFactsDurable,
266
266
  embedPromotedFacts
267
- } from "./index-16vwdyy5.js";
267
+ } from "./index-yhrrx7qa.js";
268
268
  import {
269
269
  pushNotification2
270
270
  } from "./index-x8a7jmkh.js";
@@ -284,7 +284,7 @@ import {
284
284
  } from "./index-s178h9z8.js";
285
285
  import {
286
286
  sendStatusNotification2
287
- } from "./index-pgy3h49n.js";
287
+ } from "./index-0abg88h2.js";
288
288
  import {
289
289
  sameProjectDirectory
290
290
  } from "./index-knvkbfvh.js";
@@ -3386,6 +3386,14 @@ function createDreamerOutputCapSampler(boot, fresh) {
3386
3386
  };
3387
3387
  }
3388
3388
 
3389
+ // src/features/magic-context/memory-enabled.ts
3390
+ function isProjectMemoryEnabled(enabled) {
3391
+ return enabled !== false;
3392
+ }
3393
+ function readEnabledProjectMemories(enabled, read) {
3394
+ return isProjectMemoryEnabled(enabled) ? read() : [];
3395
+ }
3396
+
3389
3397
  // src/hooks/magic-context/historian-prompt.generated.ts
3390
3398
  var COMPARTMENT_AGENT_SYSTEM_PROMPT = `# Historian
3391
3399
 
@@ -4268,8 +4276,7 @@ function buildCompartmentAgentPrompt(inputs) {
4268
4276
  parts.push(inputs.seedExamples);
4269
4277
  if (inputs.sessionReferences)
4270
4278
  parts.push(inputs.sessionReferences);
4271
- if (inputs.projectMemory)
4272
- parts.push(inputs.projectMemory);
4279
+ parts.push(...readEnabledProjectMemories(inputs.memoryEnabled, () => inputs.projectMemory ? [inputs.projectMemory] : []));
4273
4280
  if (inputs.extractionFree) {
4274
4281
  parts.push(`<extraction>disabled</extraction>
4275
4282
  Structural recomp mode: emit compartments and <meta> only. Do NOT emit <facts>, <events>, <user_observations>, or <primer_candidates>.`);
@@ -4339,7 +4346,7 @@ ${HISTORIAN_TRUNCATION_MARKER}
4339
4346
  function fitAtomicHistorianSourceToProducerWindow(args) {
4340
4347
  const producerInputLimitTokens = producerInputTokenLimit(args.contextLimitTokens, args.maxOutputTokens, args.inputLimitTokens);
4341
4348
  const originalTokens = estimateTokens(args.text);
4342
- const target = producerInputLimitTokens === undefined ? undefined : Math.min(producerInputLimitTokens, args.maxSourceTokens ?? Infinity);
4349
+ const target = producerInputLimitTokens === undefined ? args.maxSourceTokens : Math.min(producerInputLimitTokens, args.maxSourceTokens ?? Infinity);
4343
4350
  if (target === undefined || originalTokens < target || target <= 0) {
4344
4351
  return { text: args.text, producerInputLimitTokens, removedTokens: 0 };
4345
4352
  }
@@ -5429,6 +5436,21 @@ class V2StoreReader {
5429
5436
  return row ? decode(row) : null;
5430
5437
  });
5431
5438
  }
5439
+ messageTimes(sessionID, ids) {
5440
+ const times = new Map;
5441
+ for (let offset = 0;offset < ids.length; offset += 500) {
5442
+ const batch = ids.slice(offset, offset + 500);
5443
+ const rows = this.prepare(`SELECT id, COALESCE(time_created, json_extract(data, '$.time.created')) AS created,
5444
+ json_extract(data, '$.time.completed') AS completed
5445
+ FROM session_message WHERE session_id = ? AND id IN (${batch.map(() => "?").join(",")})`).all(sessionID, ...batch);
5446
+ for (const row of rows)
5447
+ times.set(row.id, {
5448
+ created: typeof row.created === "number" ? row.created : undefined,
5449
+ completed: typeof row.completed === "number" ? row.completed : undefined
5450
+ });
5451
+ }
5452
+ return times;
5453
+ }
5432
5454
  messageExistsById(sessionID, id) {
5433
5455
  return trackDecodeOperation("messageExistsById", () => {
5434
5456
  const rawTypes = RAW_MESSAGE_TYPES.map(() => "?").join(", ");
@@ -10205,6 +10227,7 @@ async function promptAsyncAndWaitForIdle(client, request, options = {}) {
10205
10227
  }
10206
10228
  }
10207
10229
  // src/shared/prompt-surface-runtime.ts
10230
+ import { createHash as createHash9 } from "node:crypto";
10208
10231
  import { existsSync as existsSync5, readFileSync as readFileSync6, statSync as statSync6 } from "node:fs";
10209
10232
  import { dirname as dirname4, isAbsolute as isAbsolute3, resolve as resolve3 } from "node:path";
10210
10233
 
@@ -10236,6 +10259,9 @@ function promptSurfaceHashMaterial(systemContent, preset = "full") {
10236
10259
  return preset === "full" ? systemContent : `${systemContent}
10237
10260
  \x00magic-context-prompt-surface:${preset}`;
10238
10261
  }
10262
+ function systemPromptFingerprint(systemContent, preset = "full") {
10263
+ return createHash9("md5").update(promptSurfaceHashMaterial(systemContent, preset)).digest("hex");
10264
+ }
10239
10265
  var PROMPT_SURFACE_TOOL_ID_SET = new Set(ACTIVE_TOOL_IDS);
10240
10266
  function resolveUserConfigDirectory(options) {
10241
10267
  if (options.userConfigDirectory)
@@ -10916,7 +10942,7 @@ function compareMemorySelectionPriority(left, right) {
10916
10942
  }
10917
10943
 
10918
10944
  // src/features/magic-context/mural/render-trigger.ts
10919
- import { createHash as createHash9 } from "node:crypto";
10945
+ import { createHash as createHash10 } from "node:crypto";
10920
10946
 
10921
10947
  // src/features/magic-context/mural/mural-selection.ts
10922
10948
  var DEFAULT_MURAL_MEMORY_BUDGET = 8000;
@@ -11620,7 +11646,7 @@ function ensureMuralRendered(db, projectIdentity, budgetTokens = DEFAULT_MURAL_M
11620
11646
  return { ...cached.result };
11621
11647
  }
11622
11648
  const plan = planMuralRender(entries);
11623
- const textHash = createHash9("sha256").update(plan.layout.text).digest("hex");
11649
+ const textHash = createHash10("sha256").update(plan.layout.text).digest("hex");
11624
11650
  if (existing && existing.contentHash === textHash && existing.width === plan.width && existing.height === plan.height) {
11625
11651
  return rememberRender(db, projectIdentity, key, existing.image, {
11626
11652
  hasMural: true,
@@ -11809,14 +11835,14 @@ function parseUserMemoryRow(row) {
11809
11835
  }
11810
11836
 
11811
11837
  // src/features/magic-context/compaction-marker.ts
11812
- import { createHash as createHash10 } from "node:crypto";
11838
+ import { createHash as createHash11 } from "node:crypto";
11813
11839
  import { existsSync as existsSync6, statSync as statSync7 } from "node:fs";
11814
11840
  var BASE62_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
11815
11841
  var ID_PREFIX_HEX_LENGTH = 12;
11816
11842
  var ID_SUFFIX_LENGTH = 14;
11817
11843
  var ID_PREFIX_MASK = (1n << BigInt(ID_PREFIX_HEX_LENGTH * 4)) - 1n;
11818
11844
  function deterministicBase62(seed, length) {
11819
- let value = BigInt(`0x${createHash10("sha256").update(seed).digest("hex")}`);
11845
+ let value = BigInt(`0x${createHash11("sha256").update(seed).digest("hex")}`);
11820
11846
  const chars = Array(length);
11821
11847
  for (let index = length - 1;index >= 0; index -= 1) {
11822
11848
  chars[index] = BASE62_CHARS[Number(value % 62n)];
@@ -17412,7 +17438,7 @@ function fitHistorianPrompt(args) {
17412
17438
  const requested = Math.max(0, Math.floor(args.requestedChunkTokens));
17413
17439
  const seeds = selectSeeds(args.sessionId, args.chunkStart);
17414
17440
  const references = selectSessionReferences(args.sessionCompartments, seeds, args.sessionId, args.chunkStart);
17415
- const memories = orderHistorianMemories(args.memories);
17441
+ const memories = orderHistorianMemories(readEnabledProjectMemories(args.memoryEnabled, () => typeof args.memories === "function" ? args.memories() : args.memories));
17416
17442
  const render = (refs, memoryCount, seedCount) => ({
17417
17443
  seedExamples: renderSeedExamplesBlock(seeds.slice(0, seedCount)),
17418
17444
  sessionReferences: renderSessionReferencesBlock(references, refs),
@@ -17425,26 +17451,38 @@ function fitHistorianPrompt(args) {
17425
17451
  seeds: seedCount,
17426
17452
  seedsTotal: seeds.length
17427
17453
  });
17428
- const limit = producerInputTokenLimit(args.window.contextLimitTokens, args.window.maxOutputTokens, args.window.inputLimitTokens);
17429
- if (limit === undefined) {
17454
+ let systemLocal;
17455
+ const fitLimitFor = (window) => {
17456
+ const limit = producerInputTokenLimit(window.contextLimitTokens, window.maxOutputTokens, window.inputLimitTokens);
17457
+ if (limit === undefined)
17458
+ return;
17459
+ const calibration = calibrationForModelKey(window.modelKey);
17460
+ systemLocal ??= estimateFixedPromptTokens(args.systemPrompt);
17461
+ const system = systemLocal;
17430
17462
  return {
17431
- ok: true,
17432
- guarded: false,
17433
- chunkTokens: requested,
17434
- ...render(references.length, memories.length, seeds.length),
17435
- trimmed: false,
17436
- kept: kept(references.length, memories.length, seeds.length)
17463
+ modelKey: window.modelKey,
17464
+ limit,
17465
+ mass: (proseLocal) => providerMass({ prose: proseLocal, system }, calibration, true)
17437
17466
  };
17438
- }
17439
- const calibration = calibrationForModelKey(args.window.modelKey);
17440
- const systemLocal = estimateFixedPromptTokens(args.systemPrompt);
17441
- const mass = (proseLocal) => providerMass({ prose: proseLocal, system: systemLocal }, calibration, true);
17442
- if (!Number.isFinite(mass(0)) || mass(0) <= 0) {
17467
+ };
17468
+ const primary = fitLimitFor(args.window);
17469
+ if (primary && (!Number.isFinite(primary.mass(0)) || primary.mass(0) <= 0)) {
17443
17470
  return {
17444
17471
  ok: false,
17445
17472
  reason: `producer_prompt_fit_unavailable model=${args.window.modelKey ?? "unknown"}`
17446
17473
  };
17447
17474
  }
17475
+ const fallbackLimits = (args.fallbackWindows ?? []).map(fitLimitFor).filter((entry) => entry !== undefined && Number.isFinite(entry.mass(0)) && entry.mass(0) > 0);
17476
+ const unguarded = () => ({
17477
+ ok: true,
17478
+ guarded: false,
17479
+ chunkTokens: requested,
17480
+ ...render(references.length, memories.length, seeds.length),
17481
+ trimmed: false,
17482
+ kept: kept(references.length, memories.length, seeds.length)
17483
+ });
17484
+ if (!primary && fallbackLimits.length === 0)
17485
+ return unguarded();
17448
17486
  const chunkHeader = `Messages ${args.chunkStart}-${args.lastOrdinal}:
17449
17487
 
17450
17488
  `;
@@ -17463,8 +17501,7 @@ function fitHistorianPrompt(args) {
17463
17501
  }
17464
17502
  return tokens;
17465
17503
  };
17466
- const roomFor = (blocks) => {
17467
- const fixed = fixedLocal(blocks);
17504
+ const roomUnder = ({ mass, limit }, fixed) => {
17468
17505
  if (mass(fixed) > limit)
17469
17506
  return -1;
17470
17507
  let lo = 0;
@@ -17480,8 +17517,29 @@ function fitHistorianPrompt(args) {
17480
17517
  else
17481
17518
  hi = mid;
17482
17519
  }
17483
- return Math.max(0, lo - FIT_SLACK_TOKENS);
17520
+ return lo;
17521
+ };
17522
+ const roomAmong = (limits, blocks) => {
17523
+ const fixed = fixedLocal(blocks);
17524
+ let room = Infinity;
17525
+ for (const entry of limits) {
17526
+ const one = roomUnder(entry, fixed);
17527
+ if (one < 0)
17528
+ return -1;
17529
+ room = Math.min(room, one);
17530
+ }
17531
+ return Math.max(0, room - FIT_SLACK_TOKENS);
17484
17532
  };
17533
+ const floor = Math.min(requested, HISTORIAN_MIN_FIT_CHUNK_TOKENS);
17534
+ const sizedFor = primary ? [primary] : [];
17535
+ for (const entry of fallbackLimits) {
17536
+ const alone = roomAmong([entry], render(0, 0, 0));
17537
+ if (alone >= floor && alone > 0)
17538
+ sizedFor.push(entry);
17539
+ }
17540
+ if (sizedFor.length === 0)
17541
+ return unguarded();
17542
+ const roomFor = (blocks) => roomAmong(sizedFor, blocks);
17485
17543
  const accept = (refs, memoryCount, seedCount, chunkTokens) => ({
17486
17544
  ok: true,
17487
17545
  guarded: true,
@@ -17513,16 +17571,16 @@ function fitHistorianPrompt(args) {
17513
17571
  return accept(0, 0, seedCount, requested);
17514
17572
  }
17515
17573
  }
17516
- const floor = Math.min(requested, HISTORIAN_MIN_FIT_CHUNK_TOKENS);
17517
17574
  const room = roomFor(render(0, 0, 0));
17518
17575
  if (room >= floor && room > 0)
17519
17576
  return accept(0, 0, 0, Math.min(requested, room));
17520
- const fixedTokens = mass(fixedLocal(render(0, 0, 0), `Messages 1-1:
17577
+ const refused = sizedFor[0];
17578
+ const fixedTokens = refused.mass(fixedLocal(render(0, 0, 0), `Messages 1-1:
17521
17579
 
17522
17580
  `));
17523
17581
  return {
17524
17582
  ok: false,
17525
- reason: `producer_prompt_unfit model=${args.window.modelKey ?? "unknown"} limit=${limit} fixed_tokens=${fixedTokens} min_chunk_tokens=${floor}`
17583
+ reason: `producer_prompt_unfit model=${refused.modelKey ?? "unknown"} limit=${refused.limit} fixed_tokens=${fixedTokens} min_chunk_tokens=${floor}`
17526
17584
  };
17527
17585
  }
17528
17586
 
@@ -20232,16 +20290,20 @@ async function runCompartmentAgent(deps) {
20232
20290
  const producerLimits = { input: producerWindow.inputLimitTokens };
20233
20291
  const producerReserve = producerWindow.maxOutputTokens;
20234
20292
  const projectPath = resolveProjectIdentity(directory ?? process.cwd());
20235
- const memories = getMemoriesByProject2(db, projectPath, ["active", "permanent"]);
20293
+ const fallbackWindows = [
20294
+ ...(deps.fallbackModels ?? []).map((entry) => toModelEntry(entry)?.model),
20295
+ deps.fallbackModelId
20296
+ ].filter((key) => typeof key === "string" && key !== producerModel).map((key) => resolveHistorianProducerWindow(key, deps.historianMaxOutputTokens));
20236
20297
  const promptFit = fitHistorianPrompt({
20237
20298
  window: producerWindow,
20299
+ fallbackWindows,
20238
20300
  systemPrompt: withContentLanguageDirective(COMPARTMENT_AGENT_SYSTEM_PROMPT, deps.language),
20239
20301
  requestedChunkTokens: historianChunkTokens,
20240
20302
  sessionId,
20241
20303
  chunkStart: Math.max(1, offset),
20242
20304
  lastOrdinal: eligibleEndOrdinal - 1,
20243
20305
  sessionCompartments: priorCompartments,
20244
- memories,
20306
+ memories: () => getMemoriesByProject2(db, projectPath, ["active", "permanent"]),
20245
20307
  memoryEnabled: deps.memoryEnabled !== false
20246
20308
  });
20247
20309
  if (!promptFit.ok) {
@@ -21659,4 +21721,4 @@ async function executeContextRecomp(deps, options = {}) {
21659
21721
  return (await executeContextRecompWithResult(deps, options)).message;
21660
21722
  }
21661
21723
 
21662
- export { denyTaskRoutingToCallerAgents, buildHiddenAgentRegistrations, buildZenReadAgentRegistrations, buildHiddenAgentConfig, getMagicContextBuiltinCommands, formatConfigParseStatusLine, claimConfigParseFailuresOnce, COMPACTION_ENABLED_PATH, isDreamerRunnable, isHistorianRunnable, isCompactionEnabled, 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, embedPauseBySession, embedRunStateBySession, autoEmbedAttemptedBySession, autoEmbedIdentityBySession, invalidateAutoEmbedSession, getEmbedDrainUiStatus, clearEmbedSessionState, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, 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, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, isPromptTimeoutError, getPromptFailureDetail, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, failedInvocationStatus, recordChildInvocation, recordPromptSessionError, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, promptSurfaceHashMaterial, 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, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, executeContextRecomp };
21724
+ export { denyTaskRoutingToCallerAgents, buildHiddenAgentRegistrations, buildZenReadAgentRegistrations, buildHiddenAgentConfig, getMagicContextBuiltinCommands, formatConfigParseStatusLine, claimConfigParseFailuresOnce, COMPACTION_ENABLED_PATH, isDreamerRunnable, isHistorianRunnable, isCompactionEnabled, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, loadPluginConfigDetailed, historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, createDreamerOutputCapSampler, isProjectMemoryEnabled, 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, embedPauseBySession, embedRunStateBySession, autoEmbedAttemptedBySession, autoEmbedIdentityBySession, invalidateAutoEmbedSession, getEmbedDrainUiStatus, clearEmbedSessionState, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, 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, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, isPromptTimeoutError, getPromptFailureDetail, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, failedInvocationStatus, 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, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, executeContextRecomp };
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  detectOverflow,
29
29
  isAnthropicFamilyRoute,
30
30
  readRawSessionMessages2
31
- } from "./index-wpwpn7nj.js";
31
+ } from "./index-qr1mkc2y.js";
32
32
  import {
33
33
  setHarness2
34
34
  } from "./index-pavzsdc6.js";
@@ -104,7 +104,7 @@ import {
104
104
  checkCompactionMarkerConsistency,
105
105
  clearInjectionCache,
106
106
  clearNoteNudgeTriggerOnly
107
- } from "./index-3403gbzj.js";
107
+ } from "./index-z7avx6rw.js";
108
108
  import"./index-sd3egckz.js";
109
109
  import {
110
110
  hasTrustedAbsoluteWall,
@@ -136,6 +136,7 @@ import {
136
136
  runDueTasksForProject,
137
137
  scheduleClearAndReindex,
138
138
  startDreamScheduleTimer,
139
+ createDreamTimerModuleClient,
139
140
  ensureProjectRegisteredFromOpenCodeDirectory,
140
141
  recordOpenCodeProvenInputFloor,
141
142
  resolveOpenCodeProvenInputFloor,
@@ -192,7 +193,7 @@ import {
192
193
  parameterDescriptionsFor,
193
194
  MagicContextRpcServer,
194
195
  applyHiddenSubagentTemperature
195
- } from "./index-x57ep4fp.js";
196
+ } from "./index-hqnggmxn.js";
196
197
  import {
197
198
  formatFailClosedBlockingMessage,
198
199
  createFailClosedController,
@@ -207,7 +208,7 @@ import {
207
208
  openDatabaseAsync,
208
209
  isDatabasePersisted,
209
210
  getDatabasePersistenceError
210
- } from "./index-swgpe402.js";
211
+ } from "./index-xztdf9t7.js";
211
212
  import {
212
213
  setHomeProjectPermission,
213
214
  ProjectIdentityError,
@@ -227,13 +228,13 @@ import {
227
228
  observeSessionActivity,
228
229
  backfillSessionActivity,
229
230
  deleteIndexedMessage2
230
- } from "./index-0x9cn9w1.js";
231
+ } from "./index-0j6crjgh.js";
231
232
  import {
232
233
  recordSessionProjectIdentity,
233
234
  getProjectEmbeddingSnapshot2,
234
235
  getEmbeddingCoverageStatus2,
235
236
  getAutoEmbeddingSessionCoverage2
236
- } from "./index-rg1cezmj.js";
237
+ } from "./index-se1w3v2m.js";
237
238
  import"./index-q28hsbpg.js";
238
239
  import"./index-fb3zxn06.js";
239
240
  import"./index-mp2kghkv.js";
@@ -250,7 +251,7 @@ import"./index-kvw6xew3.js";
250
251
  import {
251
252
  getDefaultSubcConnectionFile,
252
253
  SubcModuleTransport
253
- } from "./index-ffa8x2as.js";
254
+ } from "./index-84j7jq8a.js";
254
255
  import {
255
256
  isEmbeddingHostBusy2
256
257
  } from "./index-qt1qqasc.js";
@@ -266,11 +267,11 @@ import {
266
267
  observeOpenCodeTurnEvent,
267
268
  clearTrackedOpenCodeSession,
268
269
  findLastAssistantModelFromOpenCodeDb
269
- } from "./index-q76br5zn.js";
270
+ } from "./index-bzp9s8z2.js";
270
271
  import {
271
272
  sendCommandResult2,
272
273
  sendStatusNotification2
273
- } from "./index-pgy3h49n.js";
274
+ } from "./index-0abg88h2.js";
274
275
  import {
275
276
  detectConflicts,
276
277
  resolveCompactionForBoot
@@ -278,7 +279,7 @@ import {
278
279
  import {
279
280
  sendConflictWarning2,
280
281
  cleanupConflictWarnings2
281
- } from "./index-4hb8nt93.js";
282
+ } from "./index-4jkhhpn1.js";
282
283
  import"./index-1zx87sdm.js";
283
284
  import {
284
285
  stripPersistedAssistantText,
@@ -294,14 +295,14 @@ import {
294
295
  buildDreamTaskRuntimeConfigs2,
295
296
  userMemoryCollectionEnabled2
296
297
  } from "./index-ghc9f0n7.js";
297
- import"./index-7bjgyaj1.js";
298
- import"./index-16vwdyy5.js";
298
+ import"./index-9159kk15.js";
299
+ import"./index-yhrrx7qa.js";
299
300
  import {
300
301
  pushNotification2
301
302
  } from "./index-x8a7jmkh.js";
302
303
  import"./index-bmwfzz28.js";
303
304
  import"./index-4dhv7mqz.js";
304
- import"./index-a43xq1pg.js";
305
+ import"./index-4ccdr7yw.js";
305
306
  import"./index-n78avt2p.js";
306
307
  import"./index-s178h9z8.js";
307
308
  import {
@@ -310,10 +311,10 @@ import {
310
311
  setCtxReduceRegisteredGlobally,
311
312
  clearToolPermissionDenied,
312
313
  resetDegradedCacheCount2
313
- } from "./index-6k86es2p.js";
314
+ } from "./index-kkvxnbt8.js";
314
315
  import {
315
316
  runManagedRecomp2
316
- } from "./index-21919gcq.js";
317
+ } from "./index-g40wgxxt.js";
317
318
  import {
318
319
  isValidSemver,
319
320
  compareSemverCore
@@ -321,7 +322,7 @@ import {
321
322
  import"./index-fmsr7v69.js";
322
323
  import {
323
324
  runManagedWrapup2
324
- } from "./index-nenz4gpb.js";
325
+ } from "./index-q3qck7j2.js";
325
326
  import {
326
327
  __toESM,
327
328
  __commonJS
@@ -8183,7 +8184,7 @@ var require_src2 = __commonJS(function(exports, module) {
8183
8184
  // package.json
8184
8185
  var package_default = {
8185
8186
  name: "@cortexkit/opencode-magic-context",
8186
- version: "0.49.9",
8187
+ version: "0.49.11",
8187
8188
  type: "module",
8188
8189
  description: "OpenCode plugin for Magic Context — cross-session memory and context management",
8189
8190
  main: "dist/index.js",
@@ -9261,15 +9262,6 @@ function runBootPhaseWithinBudget(budget, phase, operation, report) {
9261
9262
  return runBootPhaseWithDeadline(phase, operation, remainingMs, report, `the whole-server ${budget.totalMs}ms budget`);
9262
9263
  }
9263
9264
 
9264
- // src/plugin/dream-timer-module-client.ts
9265
- function createDreamTimerModuleClient(moduleClient) {
9266
- if (!moduleClient)
9267
- return;
9268
- return {
9269
- call: (args) => moduleClient.call(args)
9270
- };
9271
- }
9272
-
9273
9265
  // src/plugin/event.ts
9274
9266
  function createEventHandler(args) {
9275
9267
  return async (input) => {
@@ -10781,6 +10773,7 @@ function createMagicContextHook(deps) {
10781
10773
  return runManualDream({
10782
10774
  db,
10783
10775
  projectIdentity: projectPath,
10776
+ projectMemoryEnabled: sampledDream.memory?.enabled,
10784
10777
  tasks: buildDreamTaskRuntimeConfigs2(currentDreamer, "opencode", deps.config.language, deps.config.smart_notes?.enabled),
10785
10778
  executor: createDreamTaskExecutor({
10786
10779
  client: deps.client,
@@ -12060,7 +12053,7 @@ async function setup(context) {
12060
12053
  log2("v2 setup() called on a host without session.hook; v1 server lane owns this host, v2 lane inert");
12061
12054
  return async () => {};
12062
12055
  }
12063
- const { registerContext } = await import("./context-ey3ap3cc.js");
12056
+ const { registerContext } = await import("./context-twz3s0cg.js");
12064
12057
  setHarness2("opencode2");
12065
12058
  bindStaleBuildNotice({}, import.meta.url, "opencode2");
12066
12059
  const duties = await registerContext(context);
@@ -12131,7 +12124,7 @@ var server = async (ctx) => {
12131
12124
  if (hasBannerEntries)
12132
12125
  setTimeout(async () => {
12133
12126
  try {
12134
- const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-q8ngbap3.js"));
12127
+ const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-vzhj8bsg.js"));
12135
12128
  const clientWithSessions = ctx.client;
12136
12129
  const sessions = await Promise.resolve(clientWithSessions.session?.list?.()).catch(() => null);
12137
12130
  const sessionList = Array.isArray(sessions) ? sessions : sessions?.data;
@@ -12148,7 +12141,7 @@ var server = async (ctx) => {
12148
12141
  log2(`[magic-context] opencode_db_missing path=${openCodeDbResolution.path} source=${openCodeDbResolution.source}`);
12149
12142
  setTimeout(async () => {
12150
12143
  try {
12151
- const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-q8ngbap3.js"));
12144
+ const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-vzhj8bsg.js"));
12152
12145
  const clientWithSessions = ctx.client;
12153
12146
  const sessions = await Promise.resolve(clientWithSessions.session?.list?.()).catch(() => null);
12154
12147
  const sessionList = Array.isArray(sessions) ? sessions : sessions?.data;
@@ -12424,12 +12417,12 @@ var server = async (ctx) => {
12424
12417
  {
12425
12418
  const fence = getSchemaFenceRejection();
12426
12419
  if (fence) {
12427
- importPluginModule(() => import("./conflict-warning-hook-w3crzrar.js")).then(({ sendSchemaFenceWarning }) => sendSchemaFenceWarning(ctx.client, ctx.directory, fence)).catch((error) => log2("[magic-context] schema-fence warning unavailable:", error));
12420
+ importPluginModule(() => import("./conflict-warning-hook-xwkfncav.js")).then(({ sendSchemaFenceWarning }) => sendSchemaFenceWarning(ctx.client, ctx.directory, fence)).catch((error) => log2("[magic-context] schema-fence warning unavailable:", error));
12428
12421
  }
12429
12422
  }
12430
12423
  const serverUrl = ctx.serverUrl;
12431
12424
  const serverUrlStr = serverUrl instanceof URL ? serverUrl.toString().replace(/\/$/, "") : typeof serverUrl === "string" ? serverUrl.replace(/\/$/, "") : undefined;
12432
- importPluginModule(() => import("./send-session-notification-q8ngbap3.js")).then(({ setNotificationServerUrl }) => {
12425
+ importPluginModule(() => import("./send-session-notification-vzhj8bsg.js")).then(({ setNotificationServerUrl }) => {
12433
12426
  setNotificationServerUrl(serverUrlStr);
12434
12427
  }).catch((error) => log2("[magic-context] notification transport unavailable:", error));
12435
12428
  if (conflictResult?.hasConflict) {
@@ -12452,7 +12445,7 @@ var server = async (ctx) => {
12452
12445
  }) => {
12453
12446
  if (!shouldShowAnnouncement())
12454
12447
  return;
12455
- return importPluginModule(() => import("./conflict-warning-hook-w3crzrar.js")).then(({ sendStartupAnnouncement }) => sendStartupAnnouncement(ctx.client, ctx.directory, ANNOUNCEMENT_VERSION, ANNOUNCEMENT_FEATURES, ANNOUNCEMENT_FOOTER, markAnnouncementSeen));
12448
+ return importPluginModule(() => import("./conflict-warning-hook-xwkfncav.js")).then(({ sendStartupAnnouncement }) => sendStartupAnnouncement(ctx.client, ctx.directory, ANNOUNCEMENT_VERSION, ANNOUNCEMENT_FEATURES, ANNOUNCEMENT_FOOTER, markAnnouncementSeen));
12456
12449
  }).catch(() => {});
12457
12450
  }, 8000);
12458
12451
  }
@@ -12526,8 +12519,8 @@ var server = async (ctx) => {
12526
12519
  tryReopenStorage,
12527
12520
  rustReplayParticipant: () => magicContextRuntime.magicContext?.getRustReplayParticipant?.() ?? null,
12528
12521
  onStorageBusyRefusal: async (sessionId, message) => {
12529
- const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-q8ngbap3.js"));
12530
- const { abortSessionFailClosed } = await importPluginModule(() => import("./transform-postprocess-phase-r8d406j0.js"));
12522
+ const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-vzhj8bsg.js"));
12523
+ const { abortSessionFailClosed } = await importPluginModule(() => import("./transform-postprocess-phase-pmqxfq4q.js"));
12531
12524
  await sendStatusNotification(ctx.client, sessionId, message, {
12532
12525
  toastDurationMs: 15000
12533
12526
  });
@@ -14,8 +14,8 @@ import"./index-w28y7d0z.js";
14
14
  import"./index-v0p37hm2.js";
15
15
  import"./index-angx1s0k.js";
16
16
  import"./index-58e3y90n.js";
17
- import"./index-q76br5zn.js";
18
- import"./index-wpwpn7nj.js";
17
+ import"./index-bzp9s8z2.js";
18
+ import"./index-qr1mkc2y.js";
19
19
  import"./index-9jvab89d.js";
20
20
  import {
21
21
  MESSAGE_INDEX_MAX_FTS_BYTES2,
@@ -24,11 +24,11 @@ import {
24
24
  markMessageIndexDirty2,
25
25
  getIndexableContent2,
26
26
  indexSingleMessage2
27
- } from "./index-0x9cn9w1.js";
27
+ } from "./index-0j6crjgh.js";
28
28
  import"./index-mp2kghkv.js";
29
29
  import"./index-q28hsbpg.js";
30
30
  import"./index-kvw6xew3.js";
31
- import"./index-7bjgyaj1.js";
31
+ import"./index-9159kk15.js";
32
32
  import"./index-150zz6fh.js";
33
33
 
34
34
  // src/features/magic-context/message-index-bounded.ts
@@ -17,15 +17,15 @@ import {
17
17
  indexMessagesAfterOrdinal2,
18
18
  indexSourcesAfterOrdinal2,
19
19
  sweepOrphanedOpenCodeMessageIndexes2
20
- } from "./index-0x9cn9w1.js";
21
- import"./index-7bjgyaj1.js";
20
+ } from "./index-0j6crjgh.js";
21
+ import"./index-9159kk15.js";
22
22
  import"./index-kvw6xew3.js";
23
23
  import"./index-mp2kghkv.js";
24
24
  import"./index-q28hsbpg.js";
25
- import"./index-wpwpn7nj.js";
25
+ import"./index-qr1mkc2y.js";
26
26
  import"./index-f8cn4xqa.js";
27
27
  import"./index-1zx87sdm.js";
28
- import"./index-q76br5zn.js";
28
+ import"./index-bzp9s8z2.js";
29
29
  import"./index-angx1s0k.js";
30
30
  import"./index-v0p37hm2.js";
31
31
  import"./index-w28y7d0z.js";