@cortexkit/opencode-magic-context 0.49.86 → 0.49.89

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 (182) hide show
  1. package/dist/{announcement-fnyxaahs.js → announcement-4ynkaf0d.js} +2 -2
  2. package/dist/auto-search-worker.js +13 -7
  3. package/dist/chunk-embedding-write-worker.js +7 -7
  4. package/dist/{compartment-chunk-embedding-ymc9mtwv.js → compartment-chunk-embedding-fey2bsyf.js} +3 -1
  5. package/dist/{conflict-warning-hook-a0wrnzch.js → conflict-warning-hook-kbq6ppjf.js} +2 -2
  6. package/dist/{context-xesm7rj3.js → context-grdg1k2k.js} +132 -52
  7. package/dist/{derive-budgets-90869322.js → derive-budgets-hzzq71rm.js} +2 -2
  8. package/dist/{embedding-backfill-v6sw58m8.js → embedding-backfill-qjkaee9s.js} +8 -8
  9. package/dist/{v2/embedding-cache-mgyr73ef.js → embedding-cache-zn4r1c31.js} +5 -1
  10. package/dist/embedding-worker.js +2 -2
  11. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +1 -0
  12. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  13. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  14. package/dist/features/magic-context/dreamer/token-budget.d.ts +8 -3
  15. package/dist/features/magic-context/dreamer/token-budget.d.ts.map +1 -1
  16. package/dist/features/magic-context/memory/embedding-cache.d.ts +7 -0
  17. package/dist/features/magic-context/memory/embedding-cache.d.ts.map +1 -1
  18. package/dist/features/magic-context/search.d.ts +6 -0
  19. package/dist/features/magic-context/search.d.ts.map +1 -1
  20. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  21. package/dist/features/magic-context/tool-definition-tokens.d.ts +2 -0
  22. package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  24. package/dist/hooks/magic-context/auto-search-worker-probe.fixture.d.ts +2 -0
  25. package/dist/hooks/magic-context/auto-search-worker-probe.fixture.d.ts.map +1 -0
  26. package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
  27. package/dist/hooks/magic-context/compartment-runner-recomp-carry.d.ts +4 -0
  28. package/dist/hooks/magic-context/compartment-runner-recomp-carry.d.ts.map +1 -0
  29. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts +8 -2
  30. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  31. package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -1
  32. package/dist/hooks/magic-context/emergency-fail-closed.d.ts +2 -0
  33. package/dist/hooks/magic-context/emergency-fail-closed.d.ts.map +1 -1
  34. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +3 -5
  35. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/send-session-notification.d.ts +11 -1
  37. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/transform.d.ts +1 -0
  39. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  40. package/dist/{index-s8ks5nz4.js → index-2pdgy88n.js} +5 -5
  41. package/dist/{index-7j2zv9nm.js → index-2qsca7h7.js} +47 -11
  42. package/dist/{index-1bqkqde0.js → index-39rzef89.js} +9 -7
  43. package/dist/{index-snbpdpa3.js → index-3pdknr07.js} +4 -4
  44. package/dist/{index-c5tmzym6.js → index-5df2fw5b.js} +108 -13
  45. package/dist/{index-7svecf3m.js → index-5pgyqgmx.js} +1 -1
  46. package/dist/{index-xrnhxkz7.js → index-60wnwcwz.js} +1 -1
  47. package/dist/{index-k50xhjw1.js → index-60x5d68t.js} +1 -1
  48. package/dist/{index-4ntnt8ee.js → index-61knrt52.js} +1 -1
  49. package/dist/{index-g6hfh4h4.js → index-6zewd2n5.js} +14 -8
  50. package/dist/{index-70cv85b0.js → index-78t37mcq.js} +2 -2
  51. package/dist/{index-stx8zd81.js → index-83qd3n7s.js} +2 -2
  52. package/dist/{index-nny4gm06.js → index-9d3qgwq0.js} +2 -2
  53. package/dist/{index-jjvbk92s.js → index-9emdjcb5.js} +1 -1
  54. package/dist/{index-05bm2ndp.js → index-chpzb6xy.js} +1 -1
  55. package/dist/{index-2kf73btc.js → index-cr483vx6.js} +1 -1
  56. package/dist/{index-d0rtbv0f.js → index-dk3hy2a2.js} +21 -14
  57. package/dist/{index-gxdc95cp.js → index-g0mb2kb4.js} +585 -82
  58. package/dist/{index-w6v4dw5f.js → index-h9hybzr5.js} +5 -5
  59. package/dist/{index-1pf5qrx4.js → index-jzfsnbmm.js} +3 -3
  60. package/dist/{index-jrj95cce.js → index-m6dnydf8.js} +9 -2
  61. package/dist/{index-xccywqdj.js → index-mrjat4eq.js} +77 -14
  62. package/dist/{index-022w6314.js → index-n1ty0vd3.js} +116 -512
  63. package/dist/{index-ttk3trse.js → index-q7msfgwz.js} +311 -111
  64. package/dist/{index-e32b3x4n.js → index-qfcjrnpe.js} +7 -6
  65. package/dist/{v2/server-4dhv7mqz.js → index-qjwpqvnf.js} +48 -1
  66. package/dist/{index-3dtzyred.js → index-r4y0dczp.js} +1 -1
  67. package/dist/{index-4w5rx7de.js → index-tt0vs4x5.js} +2 -2
  68. package/dist/{index-k0tb2z28.js → index-w51n3576.js} +2 -2
  69. package/dist/{index-25nktq8n.js → index-wmb2mcdw.js} +7 -7
  70. package/dist/{index-zmqx48vt.js → index-xsqw8kbd.js} +1 -1
  71. package/dist/{index-fzgyvsb1.js → index-y14pawe1.js} +3 -0
  72. package/dist/{index-798s7c8s.js → index-zxhev8ze.js} +2 -2
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +68 -59
  75. package/dist/{message-index-bounded-6fr624zf.js → message-index-bounded-r1qys471.js} +4 -4
  76. package/dist/migration-worker.js +5 -5
  77. package/dist/plugin/messages-transform.d.ts +3 -4
  78. package/dist/plugin/messages-transform.d.ts.map +1 -1
  79. package/dist/plugin/refusal-notice.d.ts +3 -0
  80. package/dist/plugin/refusal-notice.d.ts.map +1 -0
  81. package/dist/{project-embedding-registry-q80scexh.js → project-embedding-registry-m3fp1pa4.js} +7 -7
  82. package/dist/raw-ordinal-warmup-worker.js +4 -4
  83. package/dist/{read-session-chunk-6wedfths.js → read-session-chunk-xv9f0wgb.js} +3 -3
  84. package/dist/{recomp-orchestrator-7ecg8ryx.js → recomp-orchestrator-dgyb394j.js} +23 -23
  85. package/dist/{render-yqp7q79f.js → render-d014e603.js} +12 -12
  86. package/dist/{rpc-notifications-t9q0ynq7.js → rpc-notifications-ta2zsxpq.js} +1 -1
  87. package/dist/{search-bw22d7zc.js → search-9gceftb9.js} +18 -18
  88. package/dist/{search-archive-r4h96j2z.js → search-archive-gybn6q7s.js} +5 -5
  89. package/dist/{send-session-notification-7x518gew.js → send-session-notification-gzxz88vq.js} +1 -1
  90. package/dist/shared/assistant-message-extractor.d.ts +2 -0
  91. package/dist/shared/assistant-message-extractor.d.ts.map +1 -1
  92. package/dist/shared/prompt-async-transport.d.ts.map +1 -1
  93. package/dist/shared/recomp-outcome.d.ts +4 -0
  94. package/dist/shared/recomp-outcome.d.ts.map +1 -0
  95. package/dist/shared/rpc-notifications.d.ts +1 -1
  96. package/dist/shared/rpc-notifications.d.ts.map +1 -1
  97. package/dist/shared/storage-permissions.d.ts +16 -2
  98. package/dist/shared/storage-permissions.d.ts.map +1 -1
  99. package/dist/shared/user-facing-codes.d.ts +4 -1
  100. package/dist/shared/user-facing-codes.d.ts.map +1 -1
  101. package/dist/{storage-memory-e6a7mb0k.js → storage-memory-hhrvfw0x.js} +2 -2
  102. package/dist/{storage-tags-y2mrb8e6.js → storage-tags-f1ftvjpw.js} +2 -2
  103. package/dist/{transform-postprocess-phase-t99yj9vt.js → transform-postprocess-phase-34k1zwsy.js} +24 -24
  104. package/dist/v2/auto-search-worker.js +13 -7
  105. package/dist/v2/chunk-embedding-write-worker.js +7 -7
  106. package/dist/v2/{compartment-chunk-embedding-x6qw6mjk.js → compartment-chunk-embedding-knt2468v.js} +3 -1
  107. package/dist/v2/{context-k8sx1nyy.js → context-8bzydxfy.js} +227 -70
  108. package/dist/v2/{derive-budgets-ecjy1aqh.js → derive-budgets-hr4qqrnv.js} +3 -3
  109. package/dist/v2/{embedding-backfill-k8kqnwfq.js → embedding-backfill-0ar1bm97.js} +8 -8
  110. package/dist/{embedding-cache-mgyr73ef.js → v2/embedding-cache-zn4r1c31.js} +5 -1
  111. package/dist/v2/embedding-worker.js +2 -2
  112. package/dist/v2/fold/native-replay.d.ts +3 -1
  113. package/dist/v2/fold/native-replay.d.ts.map +1 -1
  114. package/dist/v2/hidden-child-record.d.ts +1 -0
  115. package/dist/v2/hidden-child-record.d.ts.map +1 -1
  116. package/dist/v2/hidden-completion.d.ts.map +1 -1
  117. package/dist/v2/hooks/context.d.ts.map +1 -1
  118. package/dist/v2/{message-index-bounded-jqy7283g.js → message-index-bounded-b07r9cjv.js} +4 -4
  119. package/dist/v2/migration-worker.js +5 -5
  120. package/dist/v2/{project-embedding-registry-2jp1antr.js → project-embedding-registry-gx2waee8.js} +7 -7
  121. package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
  122. package/dist/v2/{read-session-chunk-n3nhfvd7.js → read-session-chunk-38wdy8nd.js} +3 -3
  123. package/dist/v2/{recomp-orchestrator-ssde9ft1.js → recomp-orchestrator-wq7gbkqa.js} +24 -24
  124. package/dist/v2/{render-fezgh7pa.js → render-2dan17xc.js} +12 -12
  125. package/dist/v2/{rpc-notifications-t9q0ynq7.js → rpc-notifications-ta2zsxpq.js} +1 -1
  126. package/dist/v2/{search-archive-zz1kza50.js → search-archive-89hdy0a2.js} +5 -5
  127. package/dist/v2/{search-m251amra.js → search-nyqykx7q.js} +17 -17
  128. package/dist/v2/{send-session-notification-p52rhjzy.js → send-session-notification-zazaxxpf.js} +1 -1
  129. package/dist/v2/{server-4wwwm2ya.js → server-09h2vyvs.js} +5 -5
  130. package/dist/v2/{server-r2es6zt7.js → server-0tv6kytx.js} +108 -13
  131. package/dist/v2/{server-rz4snd3x.js → server-1rrmxhd1.js} +1 -1
  132. package/dist/v2/{server-wdq85mxj.js → server-6250cxzs.js} +14 -8
  133. package/dist/v2/{server-xa8fefhw.js → server-96nm9vk4.js} +1 -1
  134. package/dist/v2/{server-jjvbk92s.js → server-9emdjcb5.js} +1 -1
  135. package/dist/v2/{server-ap81bk3c.js → server-9n2qgk29.js} +1 -1
  136. package/dist/v2/{server-ps6rz88g.js → server-a85j3kam.js} +2 -2
  137. package/dist/v2/{server-y31y6gws.js → server-add0j5n3.js} +9 -7
  138. package/dist/v2/{server-97w51d8n.js → server-b0a9h3ds.js} +3 -3
  139. package/dist/v2/{server-2k8tkbhz.js → server-c7awk5s2.js} +10 -4
  140. package/dist/v2/{server-hn8b7sfe.js → server-dgjqvpgd.js} +5 -5
  141. package/dist/v2/{server-fsw8kbng.js → server-dtcwkdqj.js} +314 -114
  142. package/dist/v2/{server-mbkwcwgw.js → server-f7tzvmzs.js} +2 -2
  143. package/dist/v2/{server-n5zr7190.js → server-fb5hvvfc.js} +77 -14
  144. package/dist/v2/{server-w7mpvkpj.js → server-fn4ky6mn.js} +1 -1
  145. package/dist/v2/{server-3p6b0qya.js → server-gqkdfdvw.js} +1 -1
  146. package/dist/v2/{server-cwtehwbb.js → server-j4jjtdc5.js} +1 -1
  147. package/dist/v2/{server-b93f0bqh.js → server-pjk9spbf.js} +1 -1
  148. package/dist/v2/{server-s15knz0w.js → server-pmws7we9.js} +1 -1
  149. package/dist/{index-4dhv7mqz.js → v2/server-qjwpqvnf.js} +48 -1
  150. package/dist/v2/{server-a2f1bhyj.js → server-stjy5dxv.js} +9 -2
  151. package/dist/v2/{server-ssg29wjg.js → server-ta4h0fch.js} +21 -14
  152. package/dist/v2/{server-e2k9mt86.js → server-tj65pgvg.js} +1 -1
  153. package/dist/v2/{server-brgandk4.js → server-vy0beygw.js} +2 -2
  154. package/dist/v2/{server-fzgyvsb1.js → server-y14pawe1.js} +3 -0
  155. package/dist/v2/{server-8pdfmc27.js → server-y17r5ryz.js} +4 -4
  156. package/dist/v2/{server-sxfbjdye.js → server-yx0nyj1q.js} +2 -2
  157. package/dist/v2/server.js +6 -6
  158. package/dist/v2/{storage-memory-e6a7mb0k.js → storage-memory-hhrvfw0x.js} +2 -2
  159. package/dist/v2/{storage-tags-xq81zgt2.js → storage-tags-pmw33chf.js} +2 -2
  160. package/dist/v2/{v2-archive-reader-e2w39c3p.js → v2-archive-reader-gh1jghf7.js} +1 -1
  161. package/dist/v2/{wrapup-orchestrator-eg5b1p89.js → wrapup-orchestrator-2h7ayss9.js} +24 -24
  162. package/dist/{v2-archive-reader-8dsngf2j.js → v2-archive-reader-8158kyfd.js} +1 -1
  163. package/dist/{wrapup-orchestrator-nmk6yf7f.js → wrapup-orchestrator-ct59br0c.js} +24 -24
  164. package/package.json +1 -1
  165. package/src/shared/assistant-message-extractor.test.ts +22 -0
  166. package/src/shared/assistant-message-extractor.ts +13 -0
  167. package/src/shared/model-suggestion-retry.test.ts +43 -12
  168. package/src/shared/prompt-async-transport.test.ts +275 -8
  169. package/src/shared/prompt-async-transport.ts +41 -2
  170. package/src/shared/recomp-outcome.ts +8 -0
  171. package/src/shared/reusable-worker.fixture.ts +15 -3
  172. package/src/shared/reusable-worker.test.ts +20 -10
  173. package/src/shared/rpc-notifications.ts +4 -1
  174. package/src/shared/sqlite-foreground-wait.test.ts +2 -2
  175. package/src/shared/startup-maintenance-policy.test.ts +4 -2
  176. package/src/shared/storage-permissions-startup.test.ts +296 -6
  177. package/src/shared/storage-permissions.ts +143 -18
  178. package/src/shared/user-facing-codes.ts +5 -2
  179. package/src/tui/dialogs/status-dialog.tsx +3 -0
  180. package/src/tui/slots/sidebar-content.tsx +6 -2
  181. package/src/tui-compiled/dialogs/status-dialog.tsx +12 -0
  182. package/src/tui-compiled/slots/sidebar-content.tsx +7 -2
@@ -7,7 +7,7 @@ import {
7
7
  deleteTagIdentityRevisions,
8
8
  getTableColumnNames,
9
9
  getMeasuredToolDefinitionTokens
10
- } from "./index-jrj95cce.js";
10
+ } from "./index-m6dnydf8.js";
11
11
  import {
12
12
  invalidateAutoEmbedSession,
13
13
  drainBackgroundBatches
@@ -31,7 +31,7 @@ import {
31
31
  } from "./index-s32f8y67.js";
32
32
  import {
33
33
  deleteChunkEmbedBackoffForSession2
34
- } from "./index-snbpdpa3.js";
34
+ } from "./index-3pdknr07.js";
35
35
  import {
36
36
  isPidAlive,
37
37
  readProcessStartTime
@@ -68,21 +68,21 @@ import {
68
68
  getPendingPiCompactionMarkerState,
69
69
  logPiCompactionMarkerClear,
70
70
  isPrefixBoundThinkingModel
71
- } from "./index-xrnhxkz7.js";
71
+ } from "./index-60wnwcwz.js";
72
72
  import {
73
73
  withReadOnlySessionDb
74
74
  } from "./index-x40zr813.js";
75
75
  import {
76
76
  layoutLkgPrefix,
77
77
  assembleLkgPrefix
78
- } from "./index-4w5rx7de.js";
78
+ } from "./index-tt0vs4x5.js";
79
79
  import {
80
80
  ensurePrivateStorageDirectorySync,
81
81
  writeStorageFileSync,
82
82
  writeStorageFileAtomicSync,
83
83
  syncStorageDirectorySync,
84
84
  writeStorageFileDurableAtomicSync
85
- } from "./index-c5tmzym6.js";
85
+ } from "./index-5df2fw5b.js";
86
86
  import {
87
87
  gaDatabasePath2,
88
88
  V2StoreReader2
@@ -139,9 +139,9 @@ async function serveV2ArchiveReads2(port, openConnections) {
139
139
  import("./sqlite-zdgm52sv.js"),
140
140
  import("./store-reader-nf8z86n9.js"),
141
141
  import("./store-n4yz3n66.js"),
142
- import("./read-session-chunk-6wedfths.js"),
143
- import("./render-yqp7q79f.js"),
144
- import("./search-archive-r4h96j2z.js"),
142
+ import("./read-session-chunk-xv9f0wgb.js"),
143
+ import("./render-d014e603.js"),
144
+ import("./search-archive-gybn6q7s.js"),
145
145
  import("./expand-attachments-h33jbgyz.js")
146
146
  ]);
147
147
  const pool = new V2StoreReaderPool;
@@ -912,7 +912,10 @@ function recordToolDefinitionSet(providerID, modelID, agentName, tools, sessionI
912
912
  for (const [toolID, slot] of next)
913
913
  writeSlot(route, toolID, slot);
914
914
  if (sessionId)
915
- sessionFlights.set(sessionId, { key, exact: summarize([...next.entries()], true) });
915
+ sessionFlights.set(sessionId, {
916
+ key,
917
+ exact: { ...summarize([...next.entries()], true), providerID, modelID }
918
+ });
916
919
  }
917
920
  function getCurrentToolSetHash(providerID, modelID, agentName, sessionId) {
918
921
  return resolve(providerID, modelID, agentName, sessionId)?.hash ?? "";
@@ -923,6 +926,10 @@ function getToolDefinitionMeasurementSignature(providerID, modelID, agentName, s
923
926
  function getMeasuredToolDefinitionTokens(providerID, modelID, agentName, sessionId) {
924
927
  return resolve(providerID, modelID, agentName, sessionId)?.total;
925
928
  }
929
+ function getExactSessionToolDefinitionTokens(providerID, modelID, sessionId) {
930
+ const exact = sessionFlights.peek(sessionId)?.exact;
931
+ return exact && exact.providerID === providerID && exact.modelID === modelID ? exact.total : undefined;
932
+ }
926
933
  function getSessionToolDefinitionTokens(sessionId) {
927
934
  if (!sessionId)
928
935
  return;
@@ -935,4 +942,4 @@ function getSessionToolDefinitionTokens(sessionId) {
935
942
  return route ? summarize(currentTools(route), route.live).total : undefined;
936
943
  }
937
944
 
938
- export { BoundedSessionMap, tagTombstoneOwnerRange, tagTombstoneOwnerKey, tagRevisionKey, tagIdentityRevisionKey, installTagIdentityRevisionTrigger, deleteTagIdentityRevisions, getTableColumnNames, ensureColumn, healAllNullColumns, getTemporalDecisions, observeTemporalDecisions, freezeTemporalDecisions, deleteTemporalDecision, installV95PerfSchema, tagOrderConstraintIndex, stableStringify, stableStringifyHash, setDatabase, loadToolDefinitionMeasurements, recordToolDefinition, recordToolDefinitionSet, getCurrentToolSetHash, getToolDefinitionMeasurementSignature, getMeasuredToolDefinitionTokens, getSessionToolDefinitionTokens };
945
+ export { BoundedSessionMap, tagTombstoneOwnerRange, tagTombstoneOwnerKey, tagRevisionKey, tagIdentityRevisionKey, installTagIdentityRevisionTrigger, deleteTagIdentityRevisions, getTableColumnNames, ensureColumn, healAllNullColumns, getTemporalDecisions, observeTemporalDecisions, freezeTemporalDecisions, deleteTemporalDecision, installV95PerfSchema, tagOrderConstraintIndex, stableStringify, stableStringifyHash, setDatabase, loadToolDefinitionMeasurements, recordToolDefinition, recordToolDefinitionSet, getCurrentToolSetHash, getToolDefinitionMeasurementSignature, getMeasuredToolDefinitionTokens, getExactSessionToolDefinitionTokens, getSessionToolDefinitionTokens };
@@ -13,7 +13,7 @@ import {
13
13
  } from "./index-gzy5w8ya.js";
14
14
  import {
15
15
  scheduleAfterBootQuiet
16
- } from "./index-7svecf3m.js";
16
+ } from "./index-5pgyqgmx.js";
17
17
  import {
18
18
  getHarness2,
19
19
  harnessOwnsOpenCodeStore2
@@ -46,7 +46,7 @@ import {
46
46
  copyStorageFileSync,
47
47
  copyStorageTreeSync,
48
48
  tightenStorageTreeSync
49
- } from "./index-c5tmzym6.js";
49
+ } from "./index-5df2fw5b.js";
50
50
  import {
51
51
  attachFailClosedBlockingProcessEvidence
52
52
  } from "./index-wh9fxds5.js";
@@ -65,14 +65,14 @@ import {
65
65
  hasPendingMigrations,
66
66
  getMainThreadMigrationBodyCount,
67
67
  runMigrations
68
- } from "./index-4w5rx7de.js";
68
+ } from "./index-tt0vs4x5.js";
69
69
  import {
70
70
  installTagIdentityRevisionTrigger,
71
71
  ensureColumn,
72
72
  installV95PerfSchema,
73
73
  setDatabase,
74
74
  loadToolDefinitionMeasurements
75
- } from "./index-jrj95cce.js";
75
+ } from "./index-m6dnydf8.js";
76
76
  import {
77
77
  resolveOpenCodeDbPath,
78
78
  hasV1MessageTables
@@ -90,6 +90,7 @@ import {
90
90
  // src/features/magic-context/storage-db.ts
91
91
  import {
92
92
  existsSync as existsSync2,
93
+ lstatSync,
93
94
  readdirSync,
94
95
  readFileSync,
95
96
  rmdirSync,
@@ -583,11 +584,73 @@ function getMigrationOnOpenRefusal() {
583
584
  }
584
585
  var LATEST_SUPPORTED_VERSION = 95;
585
586
  var BOOT_SQLITE_BUSY_TIMEOUT_MS = 5000;
586
- function ensureSecureStorageDir(dir) {
587
- ensureStorageDirectorySync(dir);
587
+ function isLinkedStorageRoot(dir) {
588
+ if (process.platform === "win32")
589
+ return false;
590
+ try {
591
+ return lstatSync(dir).isSymbolicLink();
592
+ } catch {
593
+ return false;
594
+ }
595
+ }
596
+ function ensureSecureStorageDir(dir, dbPath) {
597
+ try {
598
+ ensureStorageDirectorySync(dir);
599
+ } catch (error) {
600
+ if (shouldEnforcePrivateStoragePermissions() && isLinkedStorageRoot(dir)) {
601
+ tightenStorageTree(dbPath, true);
602
+ }
603
+ throw error;
604
+ }
605
+ }
606
+ function describeLinkedStorageSkip(reason) {
607
+ switch (reason) {
608
+ case "filesystem-root":
609
+ return "it is a filesystem root";
610
+ case "home-folder":
611
+ return "it is your home folder";
612
+ case "mount-point":
613
+ return "it is a mount point";
614
+ default: {
615
+ const entries = reason === 1 ? "entry" : "entries";
616
+ return `it holds ${reason} ${entries} that Magic Context did not create`;
617
+ }
618
+ }
588
619
  }
589
- function tightenStorageTree(dbPath) {
590
- const { failures } = tightenStorageTreeSync(dirname(dbPath), dbPath);
620
+ function describeLinkedStorageFailure(failure, nonDirectoryPath) {
621
+ if (nonDirectoryPath !== undefined)
622
+ return `${nonDirectoryPath} is not a directory`;
623
+ switch (failure) {
624
+ case "ENOENT":
625
+ return "ENOENT";
626
+ case "ELOOP":
627
+ return "ELOOP";
628
+ case "EACCES":
629
+ return "EACCES";
630
+ case "EPERM":
631
+ return "EPERM";
632
+ case "ENOTDIR":
633
+ return "ENOTDIR";
634
+ default:
635
+ return "could not resolve or inspect the linked target";
636
+ }
637
+ }
638
+ function tightenStorageTree(dbPath, reportResolvedLink = false) {
639
+ const { failures, rootLink } = tightenStorageTreeSync(dirname(dbPath), dbPath);
640
+ if (rootLink && "failure" in rootLink) {
641
+ log2(`[magic-context] storage permission tightening failures=${failures}: storage root link ${rootLink.path}: ${describeLinkedStorageFailure(rootLink.failure, rootLink.nonDirectoryTarget)}`);
642
+ return;
643
+ }
644
+ if (rootLink?.skipped !== undefined) {
645
+ if (reportResolvedLink) {
646
+ const { path: linkPath, target: targetPath } = rootLink;
647
+ log2(`[magic-context] linked storage folder ${linkPath} -> ${targetPath} was not made private because ${describeLinkedStorageSkip(rootLink.skipped)}. Move the store to a folder of its own so Magic Context can protect it.`);
648
+ }
649
+ return;
650
+ }
651
+ if (rootLink && reportResolvedLink) {
652
+ log2(`[magic-context] resolved storage root link ${rootLink.path} -> ${rootLink.target}`);
653
+ }
591
654
  log2(`[magic-context] storage permission tightening failures=${failures}`);
592
655
  }
593
656
  function resolveBootBusyTimeoutMs(value) {
@@ -623,7 +686,7 @@ function migrateLegacyStorageIfNeeded(targetDbPath, targetDbDir) {
623
686
  if (!existsSync2(legacyDbPath))
624
687
  return;
625
688
  log2(`[magic-context] migrating legacy plugin storage: ${legacyDir} -> ${targetDbDir} (legacy left in place as backup)`);
626
- ensureSecureStorageDir(targetDbDir);
689
+ ensureSecureStorageDir(targetDbDir, targetDbPath);
627
690
  try {
628
691
  const legacyDb = new Database2(legacyDbPath);
629
692
  try {
@@ -1021,7 +1084,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1021
1084
  state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
1022
1085
  if (signal.aborted || !readsOpenCodeStore)
1023
1086
  return;
1024
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-6wedfths.js"));
1087
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-xv9f0wgb.js"));
1025
1088
  const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-pz5981mf.js"));
1026
1089
  if (signal.aborted)
1027
1090
  return;
@@ -2346,8 +2409,8 @@ function openDatabase(dbPathOrOptions) {
2346
2409
  if (!explicitDbPath) {
2347
2410
  migrateLegacyStorageIfNeeded(dbPath, dbDir);
2348
2411
  }
2349
- ensureSecureStorageDir(dbDir);
2350
- tightenStorageTree(dbPath);
2412
+ ensureSecureStorageDir(dbDir, dbPath);
2413
+ tightenStorageTree(dbPath, true);
2351
2414
  if (!existsSync2(dbPath) && shouldEnforcePrivateStoragePermissions()) {
2352
2415
  try {
2353
2416
  writeStorageFileSync(dbPath, new Uint8Array, { flag: "wx" });
@@ -2443,8 +2506,8 @@ async function openDatabaseAsync(dbPathOrOptions) {
2443
2506
  try {
2444
2507
  if (!explicitDbPath)
2445
2508
  migrateLegacyStorageIfNeeded(dbPath, dbDir);
2446
- ensureSecureStorageDir(dbDir);
2447
- tightenStorageTree(dbPath);
2509
+ ensureSecureStorageDir(dbDir, dbPath);
2510
+ tightenStorageTree(dbPath, true);
2448
2511
  if (!existsSync2(dbPath) && shouldEnforcePrivateStoragePermissions()) {
2449
2512
  try {
2450
2513
  writeStorageFileSync(dbPath, new Uint8Array, { flag: "wx" });