@cortexkit/opencode-magic-context 0.49.8 → 0.49.9

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 (105) hide show
  1. package/dist/agents/hidden-agent-registrations.d.ts +5 -3
  2. package/dist/agents/hidden-agent-registrations.d.ts.map +1 -1
  3. package/dist/auto-search-worker.js +1 -1
  4. package/dist/config/schema/agent-overrides.d.ts +13 -13
  5. package/dist/config/schema/magic-context.d.ts +500 -500
  6. package/dist/{context-x0ccfv0f.js → context-ey3ap3cc.js} +29 -24
  7. package/dist/features/magic-context/primer-clustering.d.ts.map +1 -1
  8. package/dist/features/magic-context/smart-notes/compiler-prompt.d.ts +1 -1
  9. package/dist/features/magic-context/smart-notes/compiler-prompt.d.ts.map +1 -1
  10. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  11. package/dist/hooks/magic-context/__fixtures__/tail-hygiene-refresh.d.ts +34 -0
  12. package/dist/hooks/magic-context/__fixtures__/tail-hygiene-refresh.d.ts.map +1 -0
  13. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  14. package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts +1 -0
  15. package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts.map +1 -1
  16. package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -1
  17. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +2 -0
  18. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  19. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  20. package/dist/hooks/magic-context/provider-visible-parts.d.ts +10 -4
  21. package/dist/hooks/magic-context/provider-visible-parts.d.ts.map +1 -1
  22. package/dist/hooks/magic-context/supersession-reclaim.d.ts +5 -3
  23. package/dist/hooks/magic-context/supersession-reclaim.d.ts.map +1 -1
  24. package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts +18 -0
  25. package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts.map +1 -0
  26. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +5 -1
  27. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
  28. package/dist/hooks/magic-context/tool-reclaim.d.ts +5 -2
  29. package/dist/hooks/magic-context/tool-reclaim.d.ts.map +1 -1
  30. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +1 -0
  31. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  32. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  33. package/dist/{index-b4gcb3rk.js → index-0x9cn9w1.js} +2 -2
  34. package/dist/{index-ydjgz36f.js → index-16vwdyy5.js} +1 -1
  35. package/dist/{index-xf6k8szp.js → index-21919gcq.js} +3 -3
  36. package/dist/{index-hxrvx6cy.js → index-3403gbzj.js} +129 -103
  37. package/dist/{index-gzg9ekc1.js → index-6k86es2p.js} +129 -15
  38. package/dist/{index-8kk7yh6m.js → index-9jvab89d.js} +1 -1
  39. package/dist/{index-qgp5vnt4.js → index-a865mj02.js} +1 -1
  40. package/dist/{index-xpn05jxq.js → index-f8cn4xqa.js} +287 -58
  41. package/dist/{index-2rw244rh.js → index-ffa8x2as.js} +4 -4
  42. package/dist/{index-bd9cjab3.js → index-g7jkrz0x.js} +35 -15
  43. package/dist/{index-pjgzdezw.js → index-nenz4gpb.js} +3 -3
  44. package/dist/{index-zf9nydbd.js → index-swgpe402.js} +4 -4
  45. package/dist/{index-9g1c4bt9.js → index-wpwpn7nj.js} +88 -8
  46. package/dist/{index-w1ejb9qr.js → index-x57ep4fp.js} +33 -19
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +50 -46
  49. package/dist/{message-index-zs882h8e.js → message-index-6r1x9cqh.js} +5 -5
  50. package/dist/{message-index-bounded-hxjp56qk.js → message-index-bounded-fskdyc81.js} +5 -5
  51. package/dist/migration-worker.js +4 -4
  52. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  53. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  54. package/dist/raw-ordinal-warmup-worker.js +3 -3
  55. package/dist/{read-session-chunk-t9r7r0sg.js → read-session-chunk-zgpvs423.js} +4 -4
  56. package/dist/{recomp-orchestrator-gr36zvd2.js → recomp-orchestrator-77xc8wpe.js} +10 -10
  57. package/dist/{search-qjen1pmz.js → search-72fkjwk2.js} +8 -8
  58. package/dist/shared/hidden-zen-read.d.ts +24 -0
  59. package/dist/shared/hidden-zen-read.d.ts.map +1 -0
  60. package/dist/shared/reclaim-distance.d.ts +33 -0
  61. package/dist/shared/reclaim-distance.d.ts.map +1 -0
  62. package/dist/shared/stable-json.d.ts +7 -0
  63. package/dist/shared/stable-json.d.ts.map +1 -1
  64. package/dist/shared/tail-hygiene-json.d.ts +22 -0
  65. package/dist/shared/tail-hygiene-json.d.ts.map +1 -0
  66. package/dist/shared/transcript.d.ts +5 -0
  67. package/dist/shared/transcript.d.ts.map +1 -1
  68. package/dist/{storage-tags-a513rkj3.js → storage-tags-35m4gms2.js} +2 -2
  69. package/dist/{transform-postprocess-phase-yv463b7y.js → transform-postprocess-phase-r8d406j0.js} +10 -10
  70. package/dist/v2/auto-search-worker.js +1 -1
  71. package/dist/v2/{context-wd82v9z6.js → context-z2yagwy4.js} +168 -35
  72. package/dist/v2/hidden-completion.d.ts.map +1 -1
  73. package/dist/v2/hooks/hidden-child.d.ts +2 -2
  74. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  75. package/dist/v2/{message-index-yd94vt9n.js → message-index-9ezq6wze.js} +5 -5
  76. package/dist/v2/{message-index-bounded-madg2kfr.js → message-index-bounded-rqc603f2.js} +5 -5
  77. package/dist/v2/migration-worker.js +4 -4
  78. package/dist/v2/raw-ordinal-warmup-worker.js +3 -3
  79. package/dist/v2/{read-session-chunk-7qs791f3.js → read-session-chunk-7f87tg2q.js} +4 -4
  80. package/dist/v2/{recomp-orchestrator-ee91r9s6.js → recomp-orchestrator-s5tdpsbs.js} +9 -9
  81. package/dist/v2/{search-pn15rr52.js → search-2td1b1wy.js} +8 -8
  82. package/dist/v2/{server-08k4zkfk.js → server-23znwjqk.js} +4 -4
  83. package/dist/v2/{server-y5g32dhq.js → server-2hxypdx5.js} +4 -4
  84. package/dist/v2/{server-yak3sxya.js → server-4zwx20yg.js} +1 -1
  85. package/dist/v2/{server-shme41gj.js → server-89fcbe37.js} +35 -15
  86. package/dist/v2/{server-q360kdb8.js → server-c9w52qss.js} +30 -13
  87. package/dist/v2/{server-4gz0xkrc.js → server-f27he3j1.js} +1 -1
  88. package/dist/v2/{server-xj4mewze.js → server-gc8x2xdb.js} +66 -8
  89. package/dist/v2/{server-jjsf29aq.js → server-kmapq3v0.js} +286 -57
  90. package/dist/v2/{server-adfte03x.js → server-xqf2d2mg.js} +1 -1
  91. package/dist/v2/{server-j3dm74ey.js → server-z0rjemg1.js} +2 -2
  92. package/dist/v2/server.js +2 -2
  93. package/dist/v2/{storage-tags-spa92sgj.js → storage-tags-c4zfcxv4.js} +2 -2
  94. package/dist/v2/{wrapup-orchestrator-5wxy1ggv.js → wrapup-orchestrator-wg8dmmm9.js} +9 -9
  95. package/dist/{wrapup-orchestrator-gv08c6f9.js → wrapup-orchestrator-b1z99yg5.js} +11 -11
  96. package/package.json +1 -1
  97. package/src/agents/hidden-agent-registrations.ts +22 -4
  98. package/src/shared/hidden-zen-read.test.ts +99 -0
  99. package/src/shared/hidden-zen-read.ts +88 -0
  100. package/src/shared/reclaim-distance.test.ts +111 -0
  101. package/src/shared/reclaim-distance.ts +91 -0
  102. package/src/shared/stable-json.ts +56 -14
  103. package/src/shared/tail-hygiene-json.test.ts +117 -0
  104. package/src/shared/tail-hygiene-json.ts +217 -0
  105. package/src/shared/transcript.ts +7 -0
@@ -18,11 +18,11 @@ import {
18
18
  finalizeMessageRepresentation2,
19
19
  runPostTransformPhase2,
20
20
  checkM0MutationDriftAndSignal2
21
- } from "./index-gzg9ekc1.js";
22
- import"./index-hxrvx6cy.js";
21
+ } from "./index-6k86es2p.js";
22
+ import"./index-3403gbzj.js";
23
23
  import"./index-s178h9z8.js";
24
- import"./index-ydjgz36f.js";
25
- import"./index-b4gcb3rk.js";
24
+ import"./index-16vwdyy5.js";
25
+ import"./index-0x9cn9w1.js";
26
26
  import"./index-sd3egckz.js";
27
27
  import"./index-a43xq1pg.js";
28
28
  import"./index-n78avt2p.js";
@@ -36,22 +36,22 @@ import"./index-x8a7jmkh.js";
36
36
  import"./index-a4b0gbyg.js";
37
37
  import"./index-bmwfzz28.js";
38
38
  import"./index-kvw6xew3.js";
39
- import"./index-zf9nydbd.js";
40
- import"./index-qgp5vnt4.js";
39
+ import"./index-swgpe402.js";
40
+ import"./index-a865mj02.js";
41
41
  import"./index-fb3zxn06.js";
42
42
  import"./index-fr0wbhdn.js";
43
43
  import"./index-0jz47061.js";
44
44
  import"./index-mp2kghkv.js";
45
45
  import"./index-q28hsbpg.js";
46
- import"./index-9g1c4bt9.js";
47
- import"./index-xpn05jxq.js";
46
+ import"./index-wpwpn7nj.js";
47
+ import"./index-f8cn4xqa.js";
48
48
  import"./index-1zx87sdm.js";
49
49
  import"./index-q76br5zn.js";
50
50
  import"./index-angx1s0k.js";
51
51
  import"./index-v0p37hm2.js";
52
52
  import"./index-w28y7d0z.js";
53
- import"./index-8kk7yh6m.js";
54
- import"./index-bd9cjab3.js";
53
+ import"./index-9jvab89d.js";
54
+ import"./index-g7jkrz0x.js";
55
55
  import"./index-58e3y90n.js";
56
56
  import"./index-150zz6fh.js";
57
57
  import"./index-gjvjh960.js";
@@ -22,7 +22,7 @@ var [
22
22
  import("./embedding-cache-mgyr73ef.js"),
23
23
  import("./storage-memory-j3v3hc83.js"),
24
24
  import("./project-embedding-registry-ja23aygk.js"),
25
- import("./search-pn15rr52.js"),
25
+ import("./search-2td1b1wy.js"),
26
26
  import("./embedding-activity-g1dhes6g.js"),
27
27
  import("./harness-e4avh192.js"),
28
28
  import("./sqlite-4pqyynrs.js"),
@@ -265,7 +265,7 @@ import {
265
265
  startCompartmentAgent,
266
266
  setRecompStarting2,
267
267
  setRecompTerminal2
268
- } from "./server-q360kdb8.js";
268
+ } from "./server-c9w52qss.js";
269
269
  import {
270
270
  CANONICAL_DREAM_TASKS,
271
271
  DREAM_TASK_CAPABILITIES,
@@ -303,7 +303,7 @@ import {
303
303
  openDatabaseAsync,
304
304
  isDatabasePersisted,
305
305
  getDatabasePersistenceError
306
- } from "./server-08k4zkfk.js";
306
+ } from "./server-23znwjqk.js";
307
307
  import {
308
308
  setHomeProjectPermission,
309
309
  shouldSkipHomeProjectMemory,
@@ -337,6 +337,7 @@ import {
337
337
  toolPartHasUserAnswer,
338
338
  DreamTokenBudgetExceeded,
339
339
  createDreamTokenBudget,
340
+ needsBlockedRead,
340
341
  recordToolParameters,
341
342
  createDroppedInputGuard,
342
343
  assertExecutableToolInput,
@@ -473,6 +474,7 @@ import {
473
474
  reasoningTextAndOpaque,
474
475
  opencodeReasoningBudgetCutoff,
475
476
  describeFinalWireTail,
477
+ estimatePartImageTokens,
476
478
  estimateMessageTokens,
477
479
  wireContentBytes,
478
480
  createFinalWireUsageTracker,
@@ -504,7 +506,7 @@ import {
504
506
  readRawSessionMessageById2,
505
507
  readSessionChunk2,
506
508
  readRawSessionSeedTail2
507
- } from "./server-xj4mewze.js";
509
+ } from "./server-gc8x2xdb.js";
508
510
  import {
509
511
  textMentionsRecentCommit,
510
512
  hasMeaningfulUserText2,
@@ -567,14 +569,14 @@ import {
567
569
  isMessageIndexReconciledThrough2,
568
570
  indexMessagesAfterOrdinal2,
569
571
  sweepOrphanedOpenCodeMessageIndexes2
570
- } from "./server-j3dm74ey.js";
572
+ } from "./server-z0rjemg1.js";
571
573
  import {
572
574
  stableStringify,
573
575
  getTemporalDecisions,
574
576
  observeTemporalDecisions,
575
577
  freezeTemporalDecisions,
576
578
  tagIdentityRevisionKey
577
- } from "./server-shme41gj.js";
579
+ } from "./server-89fcbe37.js";
578
580
  import {
579
581
  resolveModelCalibration,
580
582
  calibrateBuckets,
@@ -589,6 +591,7 @@ import {
589
591
  peelLeadingMcTagNotation,
590
592
  prependTag,
591
593
  isThinkingPart,
594
+ currentReclaimableToolOutputCount,
592
595
  isRecord,
593
596
  contentTagOwnerMessageId,
594
597
  estimateImageTokensFromDataUrl,
@@ -613,7 +616,6 @@ import {
613
616
  evaluateChannel2,
614
617
  formatChannel1Evaluation,
615
618
  formatChannel2Evaluation,
616
- reclaimableToolOutputCount,
617
619
  buildChannel2Reminder,
618
620
  buildChannel1Reminder,
619
621
  estimateEmergencyDropReclaimTokens,
@@ -666,7 +668,7 @@ import {
666
668
  adoptNullOwnerToolTag2,
667
669
  getCandidateToolOwners2,
668
670
  pickNearestPriorOwner2
669
- } from "./server-jjsf29aq.js";
671
+ } from "./server-kmapq3v0.js";
670
672
  import"./server-51779zs2.js";
671
673
  import {
672
674
  isRawCompactionSummaryInfo2,
@@ -694,7 +696,7 @@ import {
694
696
  getCurrentToolSetHash,
695
697
  recordToolDefinition,
696
698
  getMeasuredToolDefinitionTokens
697
- } from "./server-adfte03x.js";
699
+ } from "./server-xqf2d2mg.js";
698
700
  import {
699
701
  V2_MEMORY_CATEGORIES,
700
702
  CATEGORY_PRIORITY
@@ -707,7 +709,7 @@ import {
707
709
  resolveStoredPathWorkspaceIdentity,
708
710
  storedPathBelongsToWorkspace,
709
711
  computeWorkspaceEpochFingerprint
710
- } from "./server-4gz0xkrc.js";
712
+ } from "./server-f27he3j1.js";
711
713
  import {
712
714
  GIT_SWEEP_LEASE_RENEWAL_MS,
713
715
  acquireGitSweepLease,
@@ -778,7 +780,7 @@ import {
778
780
  readGitFileChangeTimesSince,
779
781
  verificationFileExists,
780
782
  normalizeVerificationFiles
781
- } from "./server-yak3sxya.js";
783
+ } from "./server-4zwx20yg.js";
782
784
  import {
783
785
  deriveTriggerBudget2,
784
786
  deriveHistorianChunkTokens2,
@@ -858,7 +860,7 @@ import {
858
860
  resolveMemoriesByIdsForSearch2,
859
861
  unifiedSearch2,
860
862
  formatSearchResults2
861
- } from "./server-y5g32dhq.js";
863
+ } from "./server-2hxypdx5.js";
862
864
  import {
863
865
  resolvePromptContext2
864
866
  } from "./server-fmsr7v69.js";
@@ -5934,7 +5936,7 @@ function maybeInjectChannel1Nudge(args, sessionId, tool, output) {
5934
5936
  setChannel1NudgeState(args.db, sessionId, nextNudgeState);
5935
5937
  return;
5936
5938
  }
5937
- out.output += buildChannel1Reminder(decision.level, decision.undroppedTokens, reclaimableToolOutputCount(state.baselineParts), state.oldestReclaimableToolTags, decision.sticky);
5939
+ out.output += buildChannel1Reminder(decision.level, decision.undroppedTokens, currentReclaimableToolOutputCount(state), state.oldestReclaimableToolTags, decision.sticky);
5938
5940
  setChannel1NudgeState(args.db, sessionId, {
5939
5941
  ...nextNudgeState,
5940
5942
  ordinal: state.realUserTurnCount
@@ -7675,7 +7677,7 @@ function buildEditSupersessionReclaim(input) {
7675
7677
  seenFile.add(filePath);
7676
7678
  continue;
7677
7679
  }
7678
- if (input.recentMessageIds && (tag.toolOwnerMessageId === null || input.recentMessageIds.has(tag.toolOwnerMessageId))) {
7680
+ if (tag.tagNumber > input.watermark || input.recentMessageIds && (tag.toolOwnerMessageId === null || input.recentMessageIds.has(tag.toolOwnerMessageId))) {
7679
7681
  continue;
7680
7682
  }
7681
7683
  if (realPendingTagIds.has(tag.tagNumber))
@@ -7773,6 +7775,51 @@ async function waitForTagOwners(db, sessionId, ratio, waitMs = 250) {
7773
7775
  }
7774
7776
  }
7775
7777
 
7778
+ // src/shared/reclaim-distance.ts
7779
+ var RECLAIM_DISTANCE_USER_TURNS = 3;
7780
+ var RECLAIM_DISTANCE_WINDOW_FRACTION = 0.25;
7781
+ function isReclaimUserTurn(args) {
7782
+ return args.role === "user" && !args.syntheticHead && !args.synthetic && !args.ignored && args.parts.some((part) => {
7783
+ if (part.synthetic || part.ignored)
7784
+ return false;
7785
+ if (part.kind !== "text" && part.kind !== "image" && part.kind !== "file")
7786
+ return false;
7787
+ if (part.kind !== "text")
7788
+ return true;
7789
+ return stripReclaimMcText(part.text ?? "").trim().length > 0;
7790
+ });
7791
+ }
7792
+ function stripReclaimMcText(text) {
7793
+ return text.replace(/^§\d+§\s*/, "").replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, (reminder) => /^(?:Your next step: call ctx_reduce on the outputs you've already used|Still unstamped:|Housekeeping: .* are reclaimable\. Stamp each output with ctx_reduce|.* are reclaimable\. Make a ctx_reduce pass now|.* are still unstamped\. Call ctx_reduce now)/.test(reminder.slice("<system-reminder>".length).trimStart()) ? "" : reminder).replace(/<instruction name="deferred_notes">[\s\S]*?<\/instruction>/g, "");
7794
+ }
7795
+ function farBehindToolBookmark(entries, usableWindow) {
7796
+ let newerTurns = 0;
7797
+ let newerTokens = 0;
7798
+ const farTags = [];
7799
+ let firstYoungTag = Infinity;
7800
+ const seenOutputs = new Set;
7801
+ const tokenDistance = usableWindow > 0 && Number.isFinite(usableWindow) ? usableWindow * RECLAIM_DISTANCE_WINDOW_FRACTION : Infinity;
7802
+ for (let index = entries.length - 1;index >= 0; index--) {
7803
+ const entry = entries[index];
7804
+ if (!entry)
7805
+ continue;
7806
+ const tag = entry.toolOutputTag;
7807
+ if (tag !== undefined && !seenOutputs.has(tag)) {
7808
+ seenOutputs.add(tag);
7809
+ if (newerTurns >= RECLAIM_DISTANCE_USER_TURNS || newerTokens >= tokenDistance) {
7810
+ farTags.push(tag);
7811
+ } else {
7812
+ firstYoungTag = Math.min(firstYoungTag, tag);
7813
+ }
7814
+ }
7815
+ if (entry.userTurn)
7816
+ newerTurns++;
7817
+ if (Number.isFinite(entry.tokens) && entry.tokens > 0)
7818
+ newerTokens += entry.tokens;
7819
+ }
7820
+ return farTags.reduce((bookmark, tag) => tag < firstYoungTag ? Math.max(bookmark, tag) : bookmark, 0);
7821
+ }
7822
+
7776
7823
  // src/hooks/magic-context/tool-reclaim.ts
7777
7824
  function buildSyntheticToolReclaimOps(input) {
7778
7825
  const watermark = Math.max(0, input.watermark);
@@ -7804,10 +7851,74 @@ function buildSyntheticToolReclaimOps(input) {
7804
7851
  }
7805
7852
  return synthetic;
7806
7853
  }
7807
- function advanceToolReclaimWatermarkToCurrentMax(db, sessionId) {
7808
- const maxTagNumber = getMaxTagNumberBySession2(db, sessionId);
7809
- advanceToolReclaimWatermark(db, sessionId, maxTagNumber);
7810
- return maxTagNumber;
7854
+ function advanceToolReclaimWatermarkByDistance(db, sessionId, entries, usableWindow) {
7855
+ const bookmark = farBehindToolBookmark(entries, usableWindow);
7856
+ advanceToolReclaimWatermark(db, sessionId, bookmark);
7857
+ return bookmark;
7858
+ }
7859
+ function toolReclaimDistanceEntries(messages, targets) {
7860
+ const outputTags = new Map;
7861
+ for (const [tag, target] of targets) {
7862
+ for (const location of target.mutationParts ?? []) {
7863
+ const part = distancePart(location.part);
7864
+ if (part.kind === "tool_result" || part.kind === "tool")
7865
+ outputTags.set(location.part, tag);
7866
+ }
7867
+ }
7868
+ const entries = [];
7869
+ for (const message of messages) {
7870
+ const parts = message.parts.map(distancePart);
7871
+ let userTurn = isReclaimUserTurn({ ...message.info, parts });
7872
+ for (const [index, part] of parts.entries()) {
7873
+ const authored = isReclaimUserTurn({ role: "user", parts: [part] });
7874
+ entries.push({
7875
+ tokens: message.info.syntheticHead ? 0 : estimateTokens(stripReclaimMcText(part.text ?? "")) + part.imageTokens,
7876
+ userTurn: userTurn && authored,
7877
+ toolOutputTag: outputTags.get(message.parts[index])
7878
+ });
7879
+ if (authored)
7880
+ userTurn = false;
7881
+ }
7882
+ }
7883
+ return entries;
7884
+ }
7885
+ function distancePart(raw) {
7886
+ if (!raw || typeof raw !== "object")
7887
+ return { kind: "structural", imageTokens: 0 };
7888
+ const part = raw;
7889
+ const provenance = { synthetic: part.synthetic === true, ignored: part.ignored === true };
7890
+ if (typeof part.getText === "function") {
7891
+ const text = part.getText();
7892
+ return {
7893
+ ...provenance,
7894
+ kind: String(part.kind),
7895
+ text: typeof text === "string" ? text : undefined,
7896
+ imageTokens: typeof part.imageTokens === "function" ? Number(part.imageTokens()) : 0
7897
+ };
7898
+ }
7899
+ const metadata = { ...provenance, imageTokens: estimatePartImageTokens(raw) };
7900
+ if (part.type === "tool") {
7901
+ const state = part.state;
7902
+ return {
7903
+ ...metadata,
7904
+ kind: "tool",
7905
+ text: `${JSON.stringify(state?.input ?? {})}
7906
+ ${typeof state?.output === "string" ? state.output : JSON.stringify(state?.output ?? "")}`
7907
+ };
7908
+ }
7909
+ if (part.type === "tool_use")
7910
+ return { ...metadata, kind: "tool_use", text: JSON.stringify(part.input ?? {}) };
7911
+ if (part.type === "tool_result")
7912
+ return {
7913
+ ...metadata,
7914
+ kind: "tool_result",
7915
+ text: typeof part.content === "string" ? part.content : JSON.stringify(part.content ?? "")
7916
+ };
7917
+ return {
7918
+ ...metadata,
7919
+ kind: String(part.type),
7920
+ text: typeof part.text === "string" ? part.text : typeof part.thinking === "string" ? part.thinking : undefined
7921
+ };
7811
7922
  }
7812
7923
  // src/hooks/magic-context/strip-structural-noise.ts
7813
7924
  var STRUCTURAL_PART_TYPES = new Set(["meta", "step-start", "step-finish", "reasoning"]);
@@ -9352,6 +9463,7 @@ async function runPostTransformPhase(args) {
9352
9463
  const shouldApplyPendingOps = publishedWorkDrainAllowed;
9353
9464
  const shouldRunHeuristics = publishedWorkDrainAllowed && (rideSignals.publishedHistory || materializationRequested || forceMaterialization || foldBustsServedPrefixThisPass || firstRenderBust || heldIdleExpiryRebuild || emergencyDropEligible || args.schedulerDecision === "execute" && (!alreadyRanThisTurn || !args.fullFeatureMode));
9354
9465
  const isCacheBustingPass = publishedWorkDrainAllowed;
9466
+ const reclaimDistance = isCacheBustingPass ? toolReclaimDistanceEntries(args.messages, args.targets) : [];
9355
9467
  const canEditWholePrefix = isCacheBustingPass && !activeThinkingPrefixHold;
9356
9468
  const previousTemporalDecisions = args.temporalCandidates && !compactionOff ? new Map([
9357
9469
  ...args.temporalObservedDecisions ?? [],
@@ -9695,6 +9807,7 @@ async function runPostTransformPhase(args) {
9695
9807
  }
9696
9808
  }
9697
9809
  const editReclaim = buildEditSupersessionReclaim({
9810
+ watermark: args.sessionMeta.toolReclaimWatermark ?? 0,
9698
9811
  db: args.db,
9699
9812
  sessionId: args.sessionId,
9700
9813
  targets: newTargets,
@@ -9733,7 +9846,7 @@ async function runPostTransformPhase(args) {
9733
9846
  const tBatchFinalize = performance.now();
9734
9847
  args.batch?.finalize();
9735
9848
  if (toolReclaimApplicationOpportunity) {
9736
- const maxTagNumber = advanceToolReclaimWatermarkToCurrentMax(args.db, args.sessionId);
9849
+ const maxTagNumber = advanceToolReclaimWatermarkByDistance(args.db, args.sessionId, reclaimDistance, args.usableWindow);
9737
9850
  args.sessionMeta.toolReclaimWatermark = Math.max(args.sessionMeta.toolReclaimWatermark ?? 0, maxTagNumber);
9738
9851
  }
9739
9852
  if (autoReclaimTargetCount > 0) {
@@ -10412,6 +10525,7 @@ async function runPostTransformPhase(args) {
10412
10525
  const hygieneCalibration = sessionDecisionCalibration(args.db, args.sessionId);
10413
10526
  const hygieneUnitsVersion = transitionSessionHygieneUnits(args.db, args.sessionId, bustedThisPass, hygieneCalibration);
10414
10527
  const baseline = refreshTailHygieneBaseline({
10528
+ opencode2: args.opencode2,
10415
10529
  messages: args.messages,
10416
10530
  tags,
10417
10531
  protectedTagNumbers: args.protectedTagNumbers,
@@ -10428,7 +10542,7 @@ async function runPostTransformPhase(args) {
10428
10542
  sessionLog2(args.sessionId, formatTailHygienePrefixMismatch(baseline.lastPrefixMismatch, baseline.baselineGeneration));
10429
10543
  }
10430
10544
  const tTailState = performance.now();
10431
- const structuralSignature = tailHygieneStructuralSignature(args.messages);
10545
+ const structuralSignature = tailHygieneStructuralSignature(args.messages, args.opencode2);
10432
10546
  const effective = effectiveTailHygiene(baseline);
10433
10547
  const durableGrace = baseline.evaluable && !baseline.generationInvalidated ? captureChannel1PostReduceGraceBaseline(args.db, args.sessionId, effective.u) : getChannel1NudgeState(args.db, args.sessionId);
10434
10548
  baseline.channel1PostReduceGrace = durableGrace.postReduceGracePending || durableGrace.postReduceGraceBaselineU !== undefined ? {
@@ -10440,7 +10554,7 @@ async function runPostTransformPhase(args) {
10440
10554
  ...baseline,
10441
10555
  usableWindow: args.usableWindow,
10442
10556
  realUserTurnCount: countRealUserMessages(args.messages),
10443
- reducedSinceRefresh: baseline.baselineGeneration !== previous?.baselineGeneration ? false : previous?.reducedSinceRefresh ?? false,
10557
+ reducedSinceRefresh: baseline.baselineGeneration !== previous?.baselineGeneration || (previous?.generationInvalidated === true || previous?.evaluable === false) && baseline.evaluable && !baseline.generationInvalidated ? false : previous?.reducedSinceRefresh ?? false,
10444
10558
  agentDropsAppliedThisPass: pendingOpsDidMutate,
10445
10559
  oldestReclaimableToolTags: postprocessOldestTags(args.db, args.sessionId, args.protectedTagNumbers)
10446
10560
  });
@@ -10478,7 +10592,7 @@ async function runPostTransformPhase(args) {
10478
10592
  const tTailGuard = performance.now();
10479
10593
  if (assertedBaseline) {
10480
10594
  try {
10481
- const servedSignature = tailHygieneStructuralSignature(args.messages);
10595
+ const servedSignature = tailHygieneStructuralSignature(args.messages, args.opencode2);
10482
10596
  if (!sameTailHygieneStructuralSignature(assertedBaseline.structuralSignature, servedSignature)) {
10483
10597
  sessionLog2(args.sessionId, `ERROR [tail-hygiene-last-writer-mismatch]: served messages changed after tail-hygiene baseline refresh (expected messages=${assertedBaseline.structuralSignature.messageCount}, parts=[${assertedBaseline.structuralSignature.partCounts.join(",")}], bytes=${assertedBaseline.structuralSignature.totalBytes}; actual messages=${servedSignature.messageCount}, parts=[${servedSignature.partCounts.join(",")}], bytes=${servedSignature.totalBytes})`);
10484
10598
  }
@@ -10486,6 +10600,7 @@ async function runPostTransformPhase(args) {
10486
10600
  sessionLog2(args.sessionId, "ERROR [tail-hygiene-last-writer-check-failed]: structural production guard failed open:", error);
10487
10601
  }
10488
10602
  assertTailHygieneContentUnchangedIfEnabled({
10603
+ opencode2: args.opencode2,
10489
10604
  messages: args.messages,
10490
10605
  tags: assertedBaseline.tags,
10491
10606
  protectedTagNumbers: assertedBaseline.protectedTagNumbers,
@@ -18527,6 +18642,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
18527
18642
  const protectedCutoff = protectionWindow.cutoff;
18528
18643
  const tPostProcess = performance.now();
18529
18644
  const postTransformResult = await runPostTransformPhase({
18645
+ opencode2: deps.storeGeneration === "v2",
18530
18646
  normalizeRecoveryTail,
18531
18647
  compactionMarkerStrategy: deps.compactionMarkerStrategy ?? defaultCompactionMarkerStrategy,
18532
18648
  sessionId,
@@ -21733,6 +21849,7 @@ function buildStatusDetail(db, sessionId, directory, modelKey, config, liveSessi
21733
21849
  const ops = db.prepare("SELECT tag_id, operation FROM pending_ops WHERE session_id = ? LIMIT 100").all(sessionId);
21734
21850
  detail.pendingOps = ops.map((o) => ({ tagId: o.tag_id, operation: o.operation }));
21735
21851
  } catch {}
21852
+ modelKey ??= persistedModelKey ?? undefined;
21736
21853
  const modelSlash = modelKey?.indexOf("/") ?? -1;
21737
21854
  if (modelKey && modelSlash > 0) {
21738
21855
  detail.windowGeometry = resolveContextWindowGeometry(modelKey.slice(0, modelSlash), modelKey.slice(modelSlash + 1), { db, sessionID: sessionId });
@@ -22199,7 +22316,7 @@ function registerRpcHandlers(rpcServer, args) {
22199
22316
  const db = readDatabase();
22200
22317
  if (!db)
22201
22318
  return { ok: false, error: "db unavailable" };
22202
- const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-ee91r9s6.js"));
22319
+ const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-s5tdpsbs.js"));
22203
22320
  const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-6n7chhyp.js"));
22204
22321
  log2(`[rpc] recomp requested for session ${sessionId}`);
22205
22322
  if (!args.client && !args.hiddenCompletionExecutor) {
@@ -22284,7 +22401,7 @@ function registerRpcHandlers(rpcServer, args) {
22284
22401
  const db = readDatabase();
22285
22402
  if (!db)
22286
22403
  return { ok: false, error: "db unavailable" };
22287
- const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-5wxy1ggv.js"));
22404
+ const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-wg8dmmm9.js"));
22288
22405
  const model = liveSessionState.liveModelBySession.get(sessionId);
22289
22406
  const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
22290
22407
  const ctx = {
@@ -24780,7 +24897,7 @@ function childCreateInput(identity, role, model) {
24780
24897
  },
24781
24898
  location: { directory: identity.directory },
24782
24899
  metadata: { magic_context: "hidden-run", role },
24783
- permissions: hiddenChildPermissions(agent)
24900
+ permissions: hiddenChildPermissions(agent, model.providerID)
24784
24901
  };
24785
24902
  }
24786
24903
  function assistantOutcome(row) {
@@ -25460,6 +25577,9 @@ async function createV2HiddenCompletionExecutor(host, options) {
25460
25577
  body.temperature = temperature;
25461
25578
  request = { ...request, body };
25462
25579
  }
25580
+ if (needsBlockedRead(run.identity.agent, run.child.model.providerID) !== needsBlockedRead(run.identity.agent, requested.providerID)) {
25581
+ retire(run, "hidden-run-tool-surface-changed");
25582
+ }
25463
25583
  if (run.retired) {
25464
25584
  run.child = await lifecycle.create(run.identity, run.role, requested);
25465
25585
  run.failed = false;
@@ -25571,8 +25691,14 @@ async function createV2HiddenCompletionExecutor(host, options) {
25571
25691
  const system = typeof request.body.system === "string" ? request.body.system : run.identity.system;
25572
25692
  const tokens = row.data.tokens;
25573
25693
  const tokenNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
25574
- const reportedInput = tokenNumber(tokens?.input);
25575
- const reportedOutput = tokenNumber(tokens?.output);
25694
+ const steps = withReader(options.openReader, (reader) => reader.assistantSince?.(run.child.id, baseline) ?? [row]).filter((step) => step.seq > baseline && step.seq <= row.seq);
25695
+ const reportedUsage = steps.some((step) => tokenNumber(step.data.tokens?.input) !== undefined || tokenNumber(step.data.tokens?.output) !== undefined);
25696
+ const usage = steps.reduce((total, step) => ({
25697
+ input: total.input + (tokenNumber(step.data.tokens?.input) ?? 0),
25698
+ output: total.output + (tokenNumber(step.data.tokens?.output) ?? 0),
25699
+ cacheRead: total.cacheRead + (tokenNumber(step.data.tokens?.cache?.read) ?? 0),
25700
+ cacheWrite: total.cacheWrite + (tokenNumber(step.data.tokens?.cache?.write) ?? 0)
25701
+ }), { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
25576
25702
  if (request.signal?.aborted || run.retired || Date.now() >= deadline) {
25577
25703
  await interruptAndRetire(run, "prompt-aborted-or-timeout");
25578
25704
  throw new Error(request.signal?.aborted ? "Hidden completion prompt aborted" : "Hidden completion prompt timed out");
@@ -25582,12 +25708,7 @@ async function createV2HiddenCompletionExecutor(host, options) {
25582
25708
  tokenLog: runTokenLog(tokens, run.identity.maxOutputTokens, row.data.finish),
25583
25709
  ...hiddenToolLoop(run.identity) ? { messages: toolLoopMessages(attempt) } : {},
25584
25710
  reasoning: text ? null : assistantReasoning(row),
25585
- usage: reportedInput !== undefined || reportedOutput !== undefined ? {
25586
- input: reportedInput ?? 0,
25587
- output: reportedOutput ?? 0,
25588
- cacheRead: tokenNumber(tokens?.cache?.read) ?? 0,
25589
- cacheWrite: tokenNumber(tokens?.cache?.write) ?? 0
25590
- } : meter(system, promptText(request), text ?? ""),
25711
+ usage: reportedUsage ? usage : meter(system, promptText(request), text ?? ""),
25591
25712
  lengthCapped: ["length", "max_tokens"].includes(row.data.finish ?? ""),
25592
25713
  providerId: row.data.model?.providerID ?? requested.providerID,
25593
25714
  modelId: row.data.model?.id ?? requested.modelID
@@ -25688,7 +25809,7 @@ async function deliverPendingChannel2(context, db, sessionID, baseline) {
25688
25809
  if (!claimChannel2NudgeState(db, sessionID, token))
25689
25810
  return;
25690
25811
  try {
25691
- await deliverSynthetic(context, sessionID, buildChannel2Reminder(evaluation.reclaimableTokens, reclaimableToolOutputCount(baseline?.baselineParts ?? [])));
25812
+ await deliverSynthetic(context, sessionID, buildChannel2Reminder(evaluation.reclaimableTokens, currentReclaimableToolOutputCount(baseline)));
25692
25813
  } catch (error) {
25693
25814
  casChannel2NudgeClaim(db, sessionID, "pending", token);
25694
25815
  throw error;
@@ -28482,6 +28603,7 @@ Capability API available to check(cap):
28482
28603
  - cap.httpGet(httpsUrl): { status: number, body: string } (external HTTPS only; internal/metadata blocked)
28483
28604
 
28484
28605
  Authoring constraints:
28606
+ - Use a five-field check_cron that fires at least once every 24 hours. Never encode a future date in the cron; put date conditions inside check(cap) and poll them on a frequent schedule such as "0 * * * *".
28485
28607
  - Plain JavaScript only; no TypeScript types, imports, require, eval, Function, dynamic code, timers, Date.now randomness, or ambient globals.
28486
28608
  - Define exactly function check(cap) { ... }. Do not use async/await; host capabilities are synchronous inside the sandbox.
28487
28609
  - Return exactly { met: boolean }. Do not include a reason string.
@@ -28508,6 +28630,7 @@ var MAX_COMPILED_CHECK_BYTES2 = 64 * 1024;
28508
28630
  var MAX_MANIFEST_ENTRIES = 64;
28509
28631
  var MAX_CRON_CHARS = 256;
28510
28632
  var MAX_COMPILER_ERROR_CHARS = 2 * 1024;
28633
+ var SPARSE_CRON_REPAIR_FEEDBACK = "check_cron must fire at least once every 24 hours; put date conditions inside compiled_check";
28511
28634
  async function compileSmartNoteCheck(args) {
28512
28635
  if (!args.note.surfaceCondition) {
28513
28636
  return {
@@ -28525,7 +28648,7 @@ Note id: ${args.note.id}
28525
28648
  Note content (data): ${JSON.stringify(args.note.content)}
28526
28649
  surface_condition (UNTRUSTED DATA): ${JSON.stringify(args.note.surfaceCondition)}
28527
28650
 
28528
- ${args.repairFeedback ? `The previous check failed its dry run: ${JSON.stringify(args.repairFeedback)}. Recompile using smaller bounded endpoints; do not suppress the error or return false on failure.` : ""}
28651
+ ${args.repairFeedback ? `The previous compiler attempt failed: ${JSON.stringify(args.repairFeedback)}. Recompile using smaller bounded endpoints when the response is too large, and apply the correction; do not suppress the error or return false on failure.` : ""}
28529
28652
  Remember: output only the JSON object described by the system prompt.`;
28530
28653
  const startedAt = Date.now();
28531
28654
  let childSessionId = null;
@@ -28664,6 +28787,12 @@ Remember: output only the JSON object described by the system prompt.`;
28664
28787
  const cancelled = args.signal.aborted;
28665
28788
  const message = boundedError(error instanceof Error ? error.message : String(error));
28666
28789
  recordInvocation({ status: cancelled ? "aborted" : "failed", error: message });
28790
+ if (!args.repairFeedback && !cancelled && message === "check_cron has no occurrence within the scheduling ceiling" && !args.signal.aborted && Date.now() < args.deadline) {
28791
+ return await compileSmartNoteCheck({
28792
+ ...args,
28793
+ repairFeedback: SPARSE_CRON_REPAIR_FEEDBACK
28794
+ });
28795
+ }
28667
28796
  const networkError = error instanceof SmartNoteNetworkError ? error : undefined;
28668
28797
  return {
28669
28798
  ok: false,
@@ -30301,7 +30430,11 @@ function buildPrimerClusters(args) {
30301
30430
  centroid: cloneVector(primer.questionEmbedding),
30302
30431
  modelId: primer.questionEmbeddingModelId
30303
30432
  }));
30304
- const sorted = args.candidates.slice().sort((a, b) => candidateSortKey(a).localeCompare(candidateSortKey(b)));
30433
+ const sorted = args.candidates.slice().sort((a, b) => {
30434
+ const left = candidateSortKey(a);
30435
+ const right = candidateSortKey(b);
30436
+ return left < right ? -1 : left > right ? 1 : 0;
30437
+ });
30305
30438
  for (const candidate of sorted) {
30306
30439
  let best = null;
30307
30440
  for (const cluster of clusters) {
@@ -1 +1 @@
1
- {"version":3,"file":"hidden-completion.d.ts","sourceRoot":"","sources":["../../src/v2/hidden-completion.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAER,wBAAwB,EAG3B,MAAM,iDAAiD,CAAC;AAQzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAGH,KAAK,eAAe,EAIpB,KAAK,eAAe,EAGvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGH,KAAK,kBAAkB,EACvB,KAAK,eAAe,EAEvB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI9E,MAAM,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,OAAO,EAAE,OAAO,CAAC;gBAEd,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAO;CAKlE;AA4GD,uEAAuE;AACvE,eAAO,MAAM,+BAA+B,EAAE,wBAAwB,CAAC,cAAc,CAGpF,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACpC,OAAO,EAAE,MAAM,wBAAwB,GAAG,SAAS,GACpD,wBAAwB,CAiB1B;AAED,wBAAsB,gCAAgC,CAClD,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,yBAAyB,GACnC,OAAO,CAAC,wBAAwB,CAAC,CAyenC"}
@@ -22,7 +22,7 @@ export interface HiddenPermissionRule {
22
22
  effect: "allow" | "deny";
23
23
  }
24
24
  /**
25
- * Deny everything, then allow exactly the agent's own tools.
25
+ * Deny everything, then expose the agent's model-specific tool surface.
26
26
  *
27
27
  * OpenCode 2 evaluates a tool call against the agent's rules followed by the
28
28
  * session's rules, and the LAST matching rule wins. Its config loader appends
@@ -32,7 +32,7 @@ export interface HiddenPermissionRule {
32
32
  * it is created: session rules come after every agent rule, which is the one
33
33
  * place where these rules are guaranteed to be evaluated last.
34
34
  */
35
- export declare function hiddenChildPermissions(agent: string): HiddenPermissionRule[];
35
+ export declare function hiddenChildPermissions(agent: string, providerID?: string): HiddenPermissionRule[];
36
36
  export declare function registerHiddenChildAgents(agent: Pick<V2AgentDomain, "transform">): Promise<void>;
37
37
  /**
38
38
  * Why a tool call must not run, or undefined when it may. A call is refused
@@ -1 +1 @@
1
- {"version":3,"file":"hidden-child.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/hidden-child.ts"],"names":[],"mappings":"AAQA,OAAO,EACH,sBAAsB,EAEzB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EACH,uBAAuB,EACvB,KAAK,iBAAiB,EACzB,MAAM,oDAAoD,CAAC;AAG5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAq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G,SAAS,CAqBtE;AA6CD;;;;;GAKG;AACH,qBAAa,eAAe;IAMZ,OAAO,CAAC,QAAQ,CAAC,IAAI;IALjC,8EAA8E;IAC9E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyC;IAClE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyC;IAClE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;gBAEnC,IAAI,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAU;IAElE,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAKtD,yEAAyE;IACzE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI/C,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAMlE,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQpC,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIhC;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IA8BxE;;;;OAIG;IACH,OAAO,CAAC,MAAM;IA0Cd,OAAO,CAAC,eAAe;IAWvB;;;;;;;;;;OAUG;IACH,KAAK,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO;CAgIxC"}
@@ -17,20 +17,20 @@ import {
17
17
  indexMessagesAfterOrdinal2,
18
18
  indexSourcesAfterOrdinal2,
19
19
  sweepOrphanedOpenCodeMessageIndexes2
20
- } from "./server-j3dm74ey.js";
20
+ } from "./server-z0rjemg1.js";
21
21
  import"./server-9a6bwc12.js";
22
22
  import"./server-988cqjme.js";
23
23
  import"./server-63ha7f0f.js";
24
24
  import"./server-cxsr0ng6.js";
25
- import"./server-xj4mewze.js";
26
- import"./server-jjsf29aq.js";
25
+ import"./server-gc8x2xdb.js";
26
+ import"./server-kmapq3v0.js";
27
27
  import"./server-1zx87sdm.js";
28
28
  import"./server-zrwaj29a.js";
29
29
  import"./server-bx59ezg6.js";
30
30
  import"./server-51779zs2.js";
31
31
  import"./server-7e087rvk.js";
32
- import"./server-adfte03x.js";
33
- import"./server-shme41gj.js";
32
+ import"./server-xqf2d2mg.js";
33
+ import"./server-89fcbe37.js";
34
34
  import"./server-2ra6pwf3.js";
35
35
  import"./server-7dv9wt9r.js";
36
36
  import"./server-s6jqh8bj.js";
@@ -4,18 +4,18 @@ import {
4
4
  yieldIndexChunk2
5
5
  } from "./server-wafzvyhg.js";
6
6
  import"./server-1zx87sdm.js";
7
- import"./server-jjsf29aq.js";
7
+ import"./server-kmapq3v0.js";
8
8
  import"./server-s6jqh8bj.js";
9
9
  import"./server-pavzsdc6.js";
10
10
  import"./server-9e5r8y60.js";
11
- import"./server-shme41gj.js";
11
+ import"./server-89fcbe37.js";
12
12
  import"./server-7e087rvk.js";
13
13
  import"./server-51779zs2.js";
14
14
  import"./server-bx59ezg6.js";
15
15
  import"./server-2ra6pwf3.js";
16
16
  import"./server-zrwaj29a.js";
17
- import"./server-xj4mewze.js";
18
- import"./server-adfte03x.js";
17
+ import"./server-gc8x2xdb.js";
18
+ import"./server-xqf2d2mg.js";
19
19
  import {
20
20
  MESSAGE_INDEX_MAX_FTS_BYTES2,
21
21
  messageIndexSkipKey2,
@@ -23,7 +23,7 @@ import {
23
23
  markMessageIndexDirty2,
24
24
  getIndexableContent2,
25
25
  indexSingleMessage2
26
- } from "./server-j3dm74ey.js";
26
+ } from "./server-z0rjemg1.js";
27
27
  import"./server-63ha7f0f.js";
28
28
  import"./server-cxsr0ng6.js";
29
29
  import"./server-988cqjme.js";
@@ -9,8 +9,8 @@ import {
9
9
  import"./server-fr0wbhdn.js";
10
10
  import {
11
11
  runMigrationsWithRetry
12
- } from "./server-4gz0xkrc.js";
13
- import"./server-shme41gj.js";
12
+ } from "./server-f27he3j1.js";
13
+ import"./server-89fcbe37.js";
14
14
  import"./server-2ra6pwf3.js";
15
15
  import"./server-njnx39q2.js";
16
16
  import"./server-cxsr0ng6.js";
@@ -18,10 +18,10 @@ import"./server-fb3zxn06.js";
18
18
  import {
19
19
  setSqlitePragmaConfig,
20
20
  initializeDatabase
21
- } from "./server-08k4zkfk.js";
21
+ } from "./server-23znwjqk.js";
22
22
  import"./server-63ha7f0f.js";
23
23
  import"./server-s6jqh8bj.js";
24
- import"./server-adfte03x.js";
24
+ import"./server-xqf2d2mg.js";
25
25
  import {
26
26
  closeQuietly
27
27
  } from "./server-8ajstryz.js";