@bastani/atomic 0.10.1 → 0.10.2-alpha.1

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 (295) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  3. package/dist/builtin/intercom/broker/watchdog.ts +4 -0
  4. package/dist/builtin/intercom/package.json +1 -1
  5. package/dist/builtin/mcp/package.json +1 -1
  6. package/dist/builtin/subagents/CHANGELOG.md +16 -0
  7. package/dist/builtin/subagents/README.md +2 -0
  8. package/dist/builtin/subagents/package.json +1 -1
  9. package/dist/builtin/subagents/skills/subagent/SKILL.md +3 -3
  10. package/dist/builtin/subagents/src/extension/index.bundle.mjs +269 -144
  11. package/dist/builtin/web-access/CHANGELOG.md +7 -0
  12. package/dist/builtin/web-access/index.bundle.mjs +9 -5
  13. package/dist/builtin/web-access/package.json +1 -1
  14. package/dist/cli/list-models.d.ts.map +1 -1
  15. package/dist/cli/list-models.js +1 -14
  16. package/dist/cli/list-models.js.map +1 -1
  17. package/dist/core/agent-session-export.d.ts.map +1 -1
  18. package/dist/core/agent-session-export.js +13 -9
  19. package/dist/core/agent-session-export.js.map +1 -1
  20. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  21. package/dist/core/agent-session-message-queue.js +6 -3
  22. package/dist/core/agent-session-message-queue.js.map +1 -1
  23. package/dist/core/agent-session-methods.d.ts +3 -0
  24. package/dist/core/agent-session-methods.d.ts.map +1 -1
  25. package/dist/core/agent-session-methods.js.map +1 -1
  26. package/dist/core/agent-session-nested-tools.d.ts.map +1 -1
  27. package/dist/core/agent-session-nested-tools.js +2 -1
  28. package/dist/core/agent-session-nested-tools.js.map +1 -1
  29. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  30. package/dist/core/agent-session-prompt.js +12 -0
  31. package/dist/core/agent-session-prompt.js.map +1 -1
  32. package/dist/core/agent-session-state.d.ts +6 -0
  33. package/dist/core/agent-session-state.d.ts.map +1 -1
  34. package/dist/core/agent-session-state.js +71 -4
  35. package/dist/core/agent-session-state.js.map +1 -1
  36. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  37. package/dist/core/agent-session-tool-hooks.js +9 -1
  38. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  39. package/dist/core/agent-session-types.d.ts +2 -0
  40. package/dist/core/agent-session-types.d.ts.map +1 -1
  41. package/dist/core/agent-session-types.js.map +1 -1
  42. package/dist/core/agent-session.d.ts +3 -0
  43. package/dist/core/agent-session.d.ts.map +1 -1
  44. package/dist/core/agent-session.js +7 -0
  45. package/dist/core/agent-session.js.map +1 -1
  46. package/dist/core/cache-stats.d.ts +15 -0
  47. package/dist/core/cache-stats.d.ts.map +1 -1
  48. package/dist/core/cache-stats.js +40 -2
  49. package/dist/core/cache-stats.js.map +1 -1
  50. package/dist/core/diagnostic-writer.d.ts.map +1 -1
  51. package/dist/core/diagnostic-writer.js +2 -1
  52. package/dist/core/diagnostic-writer.js.map +1 -1
  53. package/dist/core/export-html/template.js +14 -4
  54. package/dist/core/extensions/context-types.d.ts +6 -0
  55. package/dist/core/extensions/context-types.d.ts.map +1 -1
  56. package/dist/core/extensions/context-types.js.map +1 -1
  57. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  58. package/dist/core/extensions/loader-api.js +5 -2
  59. package/dist/core/extensions/loader-api.js.map +1 -1
  60. package/dist/core/queued-message-delivery.d.ts +100 -7
  61. package/dist/core/queued-message-delivery.d.ts.map +1 -1
  62. package/dist/core/queued-message-delivery.js +194 -4
  63. package/dist/core/queued-message-delivery.js.map +1 -1
  64. package/dist/core/resume-cache-checkpoint.d.ts +32 -0
  65. package/dist/core/resume-cache-checkpoint.d.ts.map +1 -0
  66. package/dist/core/resume-cache-checkpoint.js +67 -0
  67. package/dist/core/resume-cache-checkpoint.js.map +1 -0
  68. package/dist/core/sdk-types.d.ts +37 -0
  69. package/dist/core/sdk-types.d.ts.map +1 -1
  70. package/dist/core/sdk-types.js.map +1 -1
  71. package/dist/core/sdk.d.ts.map +1 -1
  72. package/dist/core/sdk.js +57 -28
  73. package/dist/core/sdk.js.map +1 -1
  74. package/dist/core/session-manager-core.d.ts.map +1 -1
  75. package/dist/core/session-manager-core.js +12 -3
  76. package/dist/core/session-manager-core.js.map +1 -1
  77. package/dist/core/session-manager-entries.d.ts +13 -0
  78. package/dist/core/session-manager-entries.d.ts.map +1 -1
  79. package/dist/core/session-manager-entries.js +38 -6
  80. package/dist/core/session-manager-entries.js.map +1 -1
  81. package/dist/core/settings-lock-directory.d.ts.map +1 -1
  82. package/dist/core/settings-lock-directory.js +2 -1
  83. package/dist/core/settings-lock-directory.js.map +1 -1
  84. package/dist/core/storage/node-sqlite-file-gate.d.ts +173 -0
  85. package/dist/core/storage/node-sqlite-file-gate.d.ts.map +1 -0
  86. package/dist/core/storage/node-sqlite-file-gate.js +1033 -0
  87. package/dist/core/storage/node-sqlite-file-gate.js.map +1 -0
  88. package/dist/core/storage/node-sqlite-thread.d.ts +33 -6
  89. package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -1
  90. package/dist/core/storage/node-sqlite-thread.js +72 -2
  91. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  92. package/dist/core/storage/node-sqlite.d.ts.map +1 -1
  93. package/dist/core/storage/node-sqlite.js +216 -15
  94. package/dist/core/storage/node-sqlite.js.map +1 -1
  95. package/dist/core/storage/session/entry-structure.d.ts.map +1 -1
  96. package/dist/core/storage/session/entry-structure.js +39 -2
  97. package/dist/core/storage/session/entry-structure.js.map +1 -1
  98. package/dist/core/storage/session/session-resume.d.ts.map +1 -1
  99. package/dist/core/storage/session/session-resume.js +1 -0
  100. package/dist/core/storage/session/session-resume.js.map +1 -1
  101. package/dist/core/storage/session/session-search-index.d.ts.map +1 -1
  102. package/dist/core/storage/session/session-search-index.js +56 -9
  103. package/dist/core/storage/session/session-search-index.js.map +1 -1
  104. package/dist/core/storage/statement-sequence.d.ts +36 -0
  105. package/dist/core/storage/statement-sequence.d.ts.map +1 -0
  106. package/dist/core/storage/statement-sequence.js +22 -0
  107. package/dist/core/storage/statement-sequence.js.map +1 -0
  108. package/dist/core/system-prompt.d.ts.map +1 -1
  109. package/dist/core/system-prompt.js +13 -4
  110. package/dist/core/system-prompt.js.map +1 -1
  111. package/dist/core/tasks/heartbeat-notice.d.ts.map +1 -1
  112. package/dist/core/tasks/heartbeat-notice.js +2 -1
  113. package/dist/core/tasks/heartbeat-notice.js.map +1 -1
  114. package/dist/core/tool-loadout.d.ts +4 -2
  115. package/dist/core/tool-loadout.d.ts.map +1 -1
  116. package/dist/core/tool-loadout.js +27 -5
  117. package/dist/core/tool-loadout.js.map +1 -1
  118. package/dist/core/tools/history-regex-worker.d.ts.map +1 -1
  119. package/dist/core/tools/history-regex-worker.js +2 -1
  120. package/dist/core/tools/history-regex-worker.js.map +1 -1
  121. package/dist/core/tools/powershell.d.ts +22 -22
  122. package/dist/core/tools/sqlite-selector-connection.d.ts.map +1 -1
  123. package/dist/core/tools/sqlite-selector-connection.js +7 -0
  124. package/dist/core/tools/sqlite-selector-connection.js.map +1 -1
  125. package/dist/core/transformed-system-prompt.d.ts +92 -0
  126. package/dist/core/transformed-system-prompt.d.ts.map +1 -0
  127. package/dist/core/transformed-system-prompt.js +240 -0
  128. package/dist/core/transformed-system-prompt.js.map +1 -0
  129. package/dist/extensions/codemode/execute.js +1 -1
  130. package/dist/extensions/codemode/execute.js.map +1 -1
  131. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  132. package/dist/extensions/codemode/tool.js +16 -3
  133. package/dist/extensions/codemode/tool.js.map +1 -1
  134. package/dist/extensions/llama/ui.d.ts.map +1 -1
  135. package/dist/extensions/llama/ui.js +13 -8
  136. package/dist/extensions/llama/ui.js.map +1 -1
  137. package/dist/extensions/mcp/config.d.ts +2 -0
  138. package/dist/extensions/mcp/config.d.ts.map +1 -1
  139. package/dist/extensions/mcp/config.js +5 -0
  140. package/dist/extensions/mcp/config.js.map +1 -1
  141. package/dist/extensions/mcp/index.d.ts +4 -0
  142. package/dist/extensions/mcp/index.d.ts.map +1 -1
  143. package/dist/extensions/mcp/index.js +289 -64
  144. package/dist/extensions/mcp/index.js.map +1 -1
  145. package/dist/extensions/mcp/runtime.d.ts +1 -1
  146. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  147. package/dist/extensions/mcp/runtime.js +2 -2
  148. package/dist/extensions/mcp/runtime.js.map +1 -1
  149. package/dist/extensions/mcp/tool-records.d.ts +58 -0
  150. package/dist/extensions/mcp/tool-records.d.ts.map +1 -0
  151. package/dist/extensions/mcp/tool-records.js +129 -0
  152. package/dist/extensions/mcp/tool-records.js.map +1 -0
  153. package/dist/index.d.ts +1 -0
  154. package/dist/index.d.ts.map +1 -1
  155. package/dist/index.js +1 -0
  156. package/dist/index.js.map +1 -1
  157. package/dist/modes/interactive/components/agent-panel.d.ts +2 -4
  158. package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
  159. package/dist/modes/interactive/components/agent-panel.js +65 -80
  160. package/dist/modes/interactive/components/agent-panel.js.map +1 -1
  161. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  162. package/dist/modes/interactive/components/compaction-boundary-message.js +3 -3
  163. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  164. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  165. package/dist/modes/interactive/components/footer.js +35 -28
  166. package/dist/modes/interactive/components/footer.js.map +1 -1
  167. package/dist/modes/interactive/components/notice-line.d.ts +16 -0
  168. package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
  169. package/dist/modes/interactive/components/notice-line.js +7 -0
  170. package/dist/modes/interactive/components/notice-line.js.map +1 -1
  171. package/dist/modes/interactive/components/prompt-slot.d.ts +1 -0
  172. package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -1
  173. package/dist/modes/interactive/components/prompt-slot.js +8 -4
  174. package/dist/modes/interactive/components/prompt-slot.js.map +1 -1
  175. package/dist/modes/interactive/components/task-board.d.ts +0 -1
  176. package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
  177. package/dist/modes/interactive/components/task-board.js +6 -14
  178. package/dist/modes/interactive/components/task-board.js.map +1 -1
  179. package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
  180. package/dist/modes/interactive/components/task-row.js +7 -6
  181. package/dist/modes/interactive/components/task-row.js.map +1 -1
  182. package/dist/modes/interactive/components/token-segment.d.ts +2 -1
  183. package/dist/modes/interactive/components/token-segment.d.ts.map +1 -1
  184. package/dist/modes/interactive/components/token-segment.js +2 -4
  185. package/dist/modes/interactive/components/token-segment.js.map +1 -1
  186. package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
  187. package/dist/modes/interactive/components/tree-selector-content.js +2 -2
  188. package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
  189. package/dist/modes/interactive/components/working-run-meter.d.ts +0 -1
  190. package/dist/modes/interactive/components/working-run-meter.d.ts.map +1 -1
  191. package/dist/modes/interactive/components/working-run-meter.js +0 -9
  192. package/dist/modes/interactive/components/working-run-meter.js.map +1 -1
  193. package/dist/modes/interactive/extension-command-hold.d.ts +25 -0
  194. package/dist/modes/interactive/extension-command-hold.d.ts.map +1 -0
  195. package/dist/modes/interactive/extension-command-hold.js +45 -0
  196. package/dist/modes/interactive/extension-command-hold.js.map +1 -0
  197. package/dist/modes/interactive/interactive-agent-events.js +2 -1
  198. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  199. package/dist/modes/interactive/interactive-extension-context.js +18 -10
  200. package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
  201. package/dist/modes/interactive/interactive-extension-custom-ui.js +3 -0
  202. package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
  203. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  204. package/dist/modes/interactive/interactive-input-handling.js +54 -13
  205. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  206. package/dist/modes/interactive/interactive-model-routing.d.ts +6 -0
  207. package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
  208. package/dist/modes/interactive/interactive-model-routing.js +15 -9
  209. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  210. package/dist/modes/interactive/interactive-prompt-turn.js +4 -0
  211. package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
  212. package/dist/modes/interactive/interactive-queueing.d.ts +7 -0
  213. package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
  214. package/dist/modes/interactive/interactive-queueing.js +47 -1
  215. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  216. package/dist/modes/interactive/interactive-session-routing.js +6 -0
  217. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  218. package/dist/modes/interactive/interactive-slash-commands.js +165 -65
  219. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  220. package/dist/modes/interactive/screen-hold.d.ts +3 -0
  221. package/dist/modes/interactive/screen-hold.d.ts.map +1 -1
  222. package/dist/modes/interactive/screen-hold.js +9 -1
  223. package/dist/modes/interactive/screen-hold.js.map +1 -1
  224. package/dist/modes/interactive-engine/engine-health.d.ts +11 -3
  225. package/dist/modes/interactive-engine/engine-health.d.ts.map +1 -1
  226. package/dist/modes/interactive-engine/engine-health.js +5 -4
  227. package/dist/modes/interactive-engine/engine-health.js.map +1 -1
  228. package/dist/modes/interactive-engine/engine-quit-intent.d.ts +7 -0
  229. package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
  230. package/dist/modes/interactive-engine/engine-quit-intent.js +19 -0
  231. package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
  232. package/dist/modes/interactive-engine/isolated-runtime.d.ts +18 -0
  233. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  234. package/dist/modes/interactive-engine/isolated-runtime.js +56 -4
  235. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  236. package/dist/modes/interactive-engine/protocol.d.ts +7 -0
  237. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  238. package/dist/modes/interactive-engine/protocol.js +1 -0
  239. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  240. package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
  241. package/dist/modes/rpc/agent-panel-bridge.js +0 -13
  242. package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
  243. package/dist/modes/rpc/rpc-client-process.d.ts +14 -1
  244. package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
  245. package/dist/modes/rpc/rpc-client-process.js +74 -10
  246. package/dist/modes/rpc/rpc-client-process.js.map +1 -1
  247. package/dist/modes/rpc/rpc-client.d.ts +27 -1
  248. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  249. package/dist/modes/rpc/rpc-client.js +81 -5
  250. package/dist/modes/rpc/rpc-client.js.map +1 -1
  251. package/dist/modes/rpc/rpc-event-buffer.d.ts +2 -0
  252. package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
  253. package/dist/modes/rpc/rpc-event-buffer.js +9 -0
  254. package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
  255. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  256. package/dist/modes/rpc/rpc-mode.js +16 -3
  257. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  258. package/dist/modes/rpc/rpc-session-binding.d.ts +7 -1
  259. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  260. package/dist/modes/rpc/rpc-session-binding.js +10 -2
  261. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  262. package/dist/utils/image-resize.d.ts.map +1 -1
  263. package/dist/utils/image-resize.js +2 -1
  264. package/dist/utils/image-resize.js.map +1 -1
  265. package/dist/utils/interactive-engine-bootstrap.d.ts +2 -0
  266. package/dist/utils/interactive-engine-bootstrap.d.ts.map +1 -1
  267. package/dist/utils/interactive-engine-bootstrap.js +1 -0
  268. package/dist/utils/interactive-engine-bootstrap.js.map +1 -1
  269. package/dist/utils/interactive-engine-env.d.ts +2 -0
  270. package/dist/utils/interactive-engine-env.d.ts.map +1 -1
  271. package/dist/utils/interactive-engine-env.js +1 -0
  272. package/dist/utils/interactive-engine-env.js.map +1 -1
  273. package/dist/utils/shell.d.ts.map +1 -1
  274. package/dist/utils/shell.js +2 -0
  275. package/dist/utils/shell.js.map +1 -1
  276. package/dist/utils/token-count.d.ts +8 -0
  277. package/dist/utils/token-count.d.ts.map +1 -0
  278. package/dist/utils/token-count.js +25 -0
  279. package/dist/utils/token-count.js.map +1 -0
  280. package/dist/utils/worker-threads.d.ts +18 -0
  281. package/dist/utils/worker-threads.d.ts.map +1 -0
  282. package/dist/utils/worker-threads.js +28 -0
  283. package/dist/utils/worker-threads.js.map +1 -0
  284. package/docs/background-tasks.md +13 -12
  285. package/docs/compaction.md +2 -2
  286. package/docs/development.md +1 -1
  287. package/docs/extensions/api-reference.md +5 -3
  288. package/docs/extensions/events.md +2 -0
  289. package/docs/mcp-servers.md +1 -1
  290. package/docs/settings.md +2 -0
  291. package/docs/storage.md +3 -1
  292. package/docs/subagents.md +6 -2
  293. package/docs/usage.md +1 -1
  294. package/npm-shrinkwrap.json +49 -49
  295. package/package.json +6 -6
@@ -3,6 +3,19 @@ import type { VerbatimCompactionDetails } from "./compaction/compaction-types.js
3
3
  import type { BashExecutionMessage, CustomMessage } from "./messages.ts";
4
4
  import { type BranchSummaryEntry, type CompactionEntry, type ContextEditEntry, type CustomEntry, type CustomMessageEntry, type FileEntry, type LabelEntry, type ModelChangeEntry, type ModelFallbackRecord, type SessionEntry, type SessionHeader, type SessionInfoEntry, type SessionMessageEntry, type SessionNameState, type SessionSummaryEntry, type ThinkingLevelChangeEntry, type WorktreeRestoreHostWarning, type WorktreeSnapshotEntry } from "./session-manager-types.ts";
5
5
  import type { WorktreeRootMapping, WorktreeSnapshot, WorktreeUnrestored } from "./worktree-snapshot/types.ts";
6
+ /**
7
+ * Check an extension-supplied `customType` before it is stored, so the session can be read back (#6097).
8
+ */
9
+ export declare function checkedCustomType(customType: unknown, owner: "custom entry" | "custom message"): string;
10
+ /** Custom message content as the session stores it: text or content blocks, and empty when left out (#6097). */
11
+ export declare function checkedCustomMessageContent(content: unknown): string | (TextContent | ImageContent)[];
12
+ /**
13
+ * A custom message as the session stores it (#6097): `customType` and content are checked, and `display` is read the
14
+ * way the chat has always read it, by truthiness, so a missing `display` is false.
15
+ */
16
+ export declare function checkedCustomMessage<T>(message: Pick<CustomMessage<T>, "customType" | "content" | "display" | "details">): Pick<CustomMessage<T>, "customType" | "content" | "display" | "details">;
17
+ /** Check a label before it is stored, so the session can be read back (#6097). */
18
+ export declare function checkedLabel(label: unknown): string | undefined;
6
19
  export declare function createSessionHeader(id: string, cwd: string, timestamp?: string, parentSession?: string): SessionHeader;
7
20
  export declare function createSessionFilePath(sessionDir: string, timestamp: string, sessionId: string): string;
8
21
  export declare function createMessageEntry(message: Message | CustomMessage | BashExecutionMessage, byId: {
@@ -1 +1 @@
1
- {"version":3,"file":"session-manager-entries.d.ts","sourceRoot":"","sources":["../../src/core/session-manager-entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAE3F,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAErB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAEjB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,0BA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YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,GAAG,SAAS,EACxB,QAAQ,EAAE,OAAO,GAAG,SAAS,EAC7B,IAAI,EAAE;IAAE,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,GACzD,kBAAkB,CAUpB;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,SAAS,EAAE,GAAG,YAAY,EAAE,CAEhF"}
@@ -8,6 +8,41 @@ function entryBase(byId, parentId) {
8
8
  timestamp: new Date().toISOString(),
9
9
  };
10
10
  }
11
+ const kindOf = (value) => (value === null ? "null" : Array.isArray(value) ? "array" : typeof value);
12
+ /**
13
+ * Check an extension-supplied `customType` before it is stored, so the session can be read back (#6097).
14
+ */
15
+ export function checkedCustomType(customType, owner) {
16
+ if (typeof customType !== "string")
17
+ throw new TypeError(`A ${owner} customType must be a string, not ${kindOf(customType)}`);
18
+ return customType;
19
+ }
20
+ /** Custom message content as the session stores it: text or content blocks, and empty when left out (#6097). */
21
+ export function checkedCustomMessageContent(content) {
22
+ if (content === undefined || content === null)
23
+ return [];
24
+ if (typeof content === "string" || Array.isArray(content))
25
+ return content;
26
+ throw new TypeError(`A custom message content must be a string or an array of content blocks, not ${kindOf(content)}`);
27
+ }
28
+ /**
29
+ * A custom message as the session stores it (#6097): `customType` and content are checked, and `display` is read the
30
+ * way the chat has always read it, by truthiness, so a missing `display` is false.
31
+ */
32
+ export function checkedCustomMessage(message) {
33
+ return {
34
+ customType: checkedCustomType(message.customType, "custom message"),
35
+ content: checkedCustomMessageContent(message.content),
36
+ display: Boolean(message.display),
37
+ details: message.details,
38
+ };
39
+ }
40
+ /** Check a label before it is stored, so the session can be read back (#6097). */
41
+ export function checkedLabel(label) {
42
+ if (label === undefined || typeof label === "string")
43
+ return label;
44
+ throw new TypeError(`A label must be a string or undefined, not ${kindOf(label)}`);
45
+ }
11
46
  export function createSessionHeader(id, cwd, timestamp = new Date().toISOString(), parentSession) {
12
47
  return {
13
48
  type: "session",
@@ -69,7 +104,7 @@ export function createContextEditEntry(targetId, replacement, byId, parentId) {
69
104
  export function createCustomEntry(customType, data, byId, parentId) {
70
105
  return {
71
106
  type: "custom",
72
- customType,
107
+ customType: checkedCustomType(customType, "custom entry"),
73
108
  data,
74
109
  ...entryBase(byId, parentId),
75
110
  };
@@ -159,10 +194,7 @@ export function getLatestSessionName(entries) {
159
194
  export function createCustomMessageEntry(customType, content, display, details, excludeFromContext, protectedReconciliation, byId, parentId, stageAdmissionKey) {
160
195
  return {
161
196
  type: "custom_message",
162
- customType,
163
- content,
164
- display,
165
- details,
197
+ ...checkedCustomMessage({ customType, content, display, details }),
166
198
  ...(excludeFromContext === true ? { excludeFromContext: true } : {}),
167
199
  ...(stageAdmissionKey === undefined ? {} : { stageAdmissionKey }),
168
200
  ...(protectedReconciliation === undefined ? {} : { protectedReconciliation }),
@@ -175,7 +207,7 @@ export function createLabelEntry(targetId, label, byId, parentId, timestamp) {
175
207
  ...entryBase(byId, parentId),
176
208
  ...(timestamp !== undefined ? { timestamp } : {}),
177
209
  targetId,
178
- label,
210
+ label: checkedLabel(label),
179
211
  };
180
212
  }
181
213
  export function createBranchSummaryEntry(branchFromId, fromId, summary, details, usage, fromHook, byId) {
@@ -1 +1 @@
1
- {"version":3,"file":"session-manager-entries.js","sourceRoot":"","sources":["../../src/core/session-manager-entries.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,EAIN,uBAAuB,GAiBvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG7D,SAAS,SAAS,CACjB,IAA2D,EAC3D,QAAuB;IAEvB,OAAO;QACN,EAAE,EAAE,UAAU,CAAC,IAAI,CAA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C,EAAE,CAAC;QACjD,QAAQ;QACR,KAAK;KACL,CAAC;AACH,CAAC;AAED,MAAM,UAAU,wBAAwB,CACvC,YAA2B,EAC3B,MAAc,EACd,OAAe,EACf,OAAgB,EAChB,KAAwB,EACxB,QAA6B,EAC7B,IAA2D;IAE3D,OAAO;QACN,IAAI,EAAE,gBAAgB;QACtB,GAAG,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC;QAChC,MAAM;QACN,OAAO;QACP,OAAO;QACP,KAAK;QACL,QAAQ;KACR,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,WAAwB;IAC/D,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,KAAK,EAAyB,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;AACvF,CAAC","sourcesContent":["import type { ImageContent, Message, TextContent, Usage } from \"@bastani/atomic-ai/compat\";\nimport { join } from \"path\";\nimport type { VerbatimCompactionDetails } from \"./compaction/compaction-types.js\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport {\n\ttype BranchSummaryEntry,\n\ttype CompactionEntry,\n\ttype ContextEditEntry,\n\tCURRENT_SESSION_VERSION,\n\ttype CustomEntry,\n\ttype CustomMessageEntry,\n\ttype FileEntry,\n\ttype LabelEntry,\n\ttype ModelChangeEntry,\n\ttype ModelFallbackRecord,\n\ttype SessionEntry,\n\ttype SessionEntryBase,\n\ttype SessionHeader,\n\ttype SessionInfoEntry,\n\ttype SessionMessageEntry,\n\ttype SessionNameState,\n\ttype SessionSummaryEntry,\n\ttype ThinkingLevelChangeEntry,\n\ttype WorktreeRestoreHostWarning,\n\ttype WorktreeSnapshotEntry,\n} from \"./session-manager-types.ts\";\nimport { generateId } from \"./session-manager-validation.ts\";\nimport type { WorktreeRootMapping, WorktreeSnapshot, WorktreeUnrestored } from \"./worktree-snapshot/types.ts\";\n\nfunction entryBase(\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n): Pick<SessionEntryBase, \"id\" | \"parentId\" | \"timestamp\"> {\n\treturn {\n\t\tid: generateId(byId),\n\t\tparentId,\n\t\ttimestamp: new Date().toISOString(),\n\t};\n}\n\nexport function createSessionHeader(\n\tid: string,\n\tcwd: string,\n\ttimestamp: string = new Date().toISOString(),\n\tparentSession?: string,\n): SessionHeader {\n\treturn {\n\t\ttype: \"session\",\n\t\tversion: CURRENT_SESSION_VERSION,\n\t\tid,\n\t\tcreatedAt: timestamp,\n\t\tcwd,\n\t\t...(parentSession === undefined ? {} : { parentSessionId: parentSession }),\n\t};\n}\n\nexport function createSessionFilePath(sessionDir: string, timestamp: string, sessionId: string): string {\n\tconst fileTimestamp = timestamp.replace(/[:.]/g, \"-\");\n\treturn join(sessionDir, `${fileTimestamp}_${sessionId}.jsonl`);\n}\n\nexport function createMessageEntry(\n\tmessage: Message | CustomMessage | BashExecutionMessage,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n): SessionMessageEntry {\n\treturn {\n\t\ttype: \"message\",\n\t\t...entryBase(byId, parentId),\n\t\tmessage,\n\t};\n}\n\nexport function createThinkingLevelChangeEntry(\n\tthinkingLevel: string,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n): ThinkingLevelChangeEntry {\n\treturn {\n\t\ttype: \"thinking_level_change\",\n\t\t...entryBase(byId, parentId),\n\t\tthinkingLevel,\n\t};\n}\n\nexport function createModelChangeEntry(\n\tprovider: string,\n\tmodelId: string,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n\tfallback?: ModelFallbackRecord,\n): ModelChangeEntry {\n\treturn {\n\t\ttype: \"model_change\",\n\t\t...entryBase(byId, parentId),\n\t\tprovider,\n\t\tmodelId,\n\t\t...(fallback === undefined ? {} : { fallback }),\n\t};\n}\n\nexport function createCompactionEntry(\n\tcompactedText: string,\n\tfirstKeptEntryId: string | null,\n\ttokensBefore: number,\n\tdetails: VerbatimCompactionDetails,\n\tusage: Usage | undefined,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n\tcoveredThroughEntryId?: string,\n): CompactionEntry<VerbatimCompactionDetails> {\n\treturn {\n\t\ttype: \"compaction\",\n\t\t...entryBase(byId, parentId),\n\t\tsummary: compactedText,\n\t\tfirstKeptEntryId,\n\t\ttokensBefore,\n\t\t...(coveredThroughEntryId === undefined ? {} : { coveredThroughEntryId }),\n\t\tdetails,\n\t\tusage,\n\t\tfromHook: details.backend === \"extension\" || undefined,\n\t};\n}\n\nexport function createContextEditEntry(\n\ttargetId: string,\n\treplacement: ContextEditEntry[\"replacement\"],\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n): ContextEditEntry {\n\treturn {\n\t\ttype: \"context_edit\",\n\t\t...entryBase(byId, parentId),\n\t\ttargetId,\n\t\treplacement,\n\t};\n}\n\nexport function createCustomEntry(\n\tcustomType: string,\n\tdata: unknown,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n): CustomEntry {\n\treturn {\n\t\ttype: \"custom\",\n\t\tcustomType,\n\t\tdata,\n\t\t...entryBase(byId, parentId),\n\t};\n}\n\nexport function createSessionInfoEntry(\n\tname: string,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n): SessionInfoEntry {\n\treturn {\n\t\ttype: \"session_info\",\n\t\t...entryBase(byId, parentId),\n\t\tname: name.trim(),\n\t};\n}\n\nexport function createWorktreeSnapshotEntry(\n\troot: string,\n\tsnapshotId: string,\n\tsnapshot: WorktreeSnapshot | undefined,\n\trestore: WorktreeRootMapping | undefined,\n\trestoreWarnings: readonly WorktreeRestoreHostWarning[],\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n\tunrestored?: WorktreeUnrestored,\n\tcaptureMs?: number,\n\tdegradedFrom?: string,\n): WorktreeSnapshotEntry {\n\treturn {\n\t\ttype: \"worktree_snapshot\",\n\t\t...entryBase(byId, parentId),\n\t\troot,\n\t\tsnapshotId,\n\t\t...(snapshot === undefined ? {} : { snapshot }),\n\t\t...(restore === undefined ? {} : { restore }),\n\t\t...(restoreWarnings.length === 0 ? {} : { restoreWarnings: [...restoreWarnings] }),\n\t\t...(unrestored === undefined ? {} : { unrestored }),\n\t\t...(captureMs === undefined ? {} : { captureMs }),\n\t\t...(degradedFrom === undefined ? {} : { degradedFrom }),\n\t};\n}\n\nexport function createSessionSummaryEntry(\n\tsummary: string,\n\tsummarizedThroughId: string,\n\tusage: Usage | undefined,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n): SessionSummaryEntry {\n\treturn {\n\t\ttype: \"session_summary\",\n\t\t...entryBase(byId, parentId),\n\t\tsummary: summary.trim(),\n\t\tsummarizedThroughId,\n\t\tusage,\n\t};\n}\n\n/**\n * Anchor for a session summary: the newest user/assistant message entry.\n *\n * Both sides of the freshness check call this so they cannot drift apart. Tool results and\n * non-message entries are ignored, and an assistant turn made only of tool calls still counts —\n * it carries no text, but it is a real conversation step.\n */\nexport function getLastConversationMessageId(entries: FileEntry[]): string | undefined {\n\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\tconst entry = entries[i];\n\t\tif (entry.type !== \"message\") continue;\n\t\tconst role = entry.message.role;\n\t\tif (role === \"user\" || role === \"assistant\") return entry.id;\n\t}\n\treturn undefined;\n}\n\n/**\n * Latest generated resume summary that has not been retired, entry and all.\n *\n * Returns the entry rather than its text: callers need `summarizedThroughId` alongside the\n * summary to decide whether it still describes the conversation.\n *\n * A `branch_summary` written afterwards retires it, because the branch it described was\n * abandoned. Both the picker and the generation guard call this, so a retired summary is hidden\n * from the picker *and* lets a replacement be generated; splitting the two rules leaves such a\n * session showing fallback text forever.\n */\nexport function getLatestSessionSummary(entries: FileEntry[]): SessionSummaryEntry | undefined {\n\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\tconst entry = entries[i];\n\t\tif (entry.type === \"branch_summary\") return undefined;\n\t\tif (entry.type === \"session_summary\") return entry;\n\t}\n\treturn undefined;\n}\n\nexport function getLatestSessionName(entries: readonly FileEntry[]): SessionNameState {\n\t// Walk entries in reverse to find the latest session_info entry. An existing entry\n\t// with an empty name is an explicit clear, not a never-named session: the fact that\n\t// a session was named is separate from the name it currently holds (upstream 7bdb16c2).\n\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\tconst entry = entries[i];\n\t\tif (entry.type === \"session_info\") {\n\t\t\tconst name = entry.name?.trim() || undefined;\n\t\t\treturn { hasName: true, ...(name !== undefined ? { name } : {}) };\n\t\t}\n\t}\n\treturn { hasName: false };\n}\n\nexport function createCustomMessageEntry<T = unknown>(\n\tcustomType: string,\n\tcontent: string | (TextContent | ImageContent)[],\n\tdisplay: boolean,\n\tdetails: T | undefined,\n\texcludeFromContext: boolean | undefined,\n\tprotectedReconciliation: CustomMessageEntry[\"protectedReconciliation\"],\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n\tstageAdmissionKey?: string,\n): CustomMessageEntry<T> {\n\treturn {\n\t\ttype: \"custom_message\",\n\t\tcustomType,\n\t\tcontent,\n\t\tdisplay,\n\t\tdetails,\n\t\t...(excludeFromContext === true ? { excludeFromContext: true } : {}),\n\t\t...(stageAdmissionKey === undefined ? {} : { stageAdmissionKey }),\n\t\t...(protectedReconciliation === undefined ? {} : { protectedReconciliation }),\n\t\t...entryBase(byId, parentId),\n\t};\n}\n\nexport function createLabelEntry(\n\ttargetId: string,\n\tlabel: string | undefined,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n\ttimestamp?: string,\n): LabelEntry {\n\treturn {\n\t\ttype: \"label\",\n\t\t...entryBase(byId, parentId),\n\t\t...(timestamp !== undefined ? { timestamp } : {}),\n\t\ttargetId,\n\t\tlabel,\n\t};\n}\n\nexport function createBranchSummaryEntry(\n\tbranchFromId: string | null,\n\tfromId: string,\n\tsummary: string,\n\tdetails: unknown,\n\tusage: Usage | undefined,\n\tfromHook: boolean | undefined,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n): BranchSummaryEntry {\n\treturn {\n\t\ttype: \"branch_summary\",\n\t\t...entryBase(byId, branchFromId),\n\t\tfromId,\n\t\tsummary,\n\t\tdetails,\n\t\tusage,\n\t\tfromHook,\n\t};\n}\n\nexport function getEntriesWithoutHeader(fileEntries: FileEntry[]): SessionEntry[] {\n\treturn fileEntries.filter((entry): entry is SessionEntry => entry.type !== \"session\");\n}\n"]}
1
+ {"version":3,"file":"session-manager-entries.js","sourceRoot":"","sources":["../../src/core/session-manager-entries.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,EAIN,uBAAuB,GAiBvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG7D,SAAS,SAAS,CACjB,IAA2D,EAC3D,QAAuB;IAEvB,OAAO;QACN,EAAE,EAAE,UAAU,CAAC,IAAI,CAAC;QACpB,QAAQ;QACR,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACnC,CAAC;AACH,CAAC;AAED,MAAM,MAAM,GAAG,CAAC,KAAc,EAAU,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC;AAErH;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAmB,EAAE,KAAwC;IAC9F,IAAI,OAAO,UAAU,KAAK,QAAQ;QACjC,MAAM,IAAI,SAAS,CAAC,KAAK,KAAK,qCAAqC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC1F,OAAO,UAAU,CAAC;AACnB,CAAC;AAED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,MAAM,UAAU,uBAAuB,CAAC,WAAwB;IAC/D,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,KAAK,EAAyB,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;AACvF,CAAC","sourcesContent":["import type { ImageContent, Message, TextContent, Usage } from \"@bastani/atomic-ai/compat\";\nimport { join } from \"path\";\nimport type { VerbatimCompactionDetails } from \"./compaction/compaction-types.js\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport {\n\ttype BranchSummaryEntry,\n\ttype CompactionEntry,\n\ttype ContextEditEntry,\n\tCURRENT_SESSION_VERSION,\n\ttype CustomEntry,\n\ttype CustomMessageEntry,\n\ttype FileEntry,\n\ttype LabelEntry,\n\ttype ModelChangeEntry,\n\ttype ModelFallbackRecord,\n\ttype SessionEntry,\n\ttype SessionEntryBase,\n\ttype SessionHeader,\n\ttype SessionInfoEntry,\n\ttype SessionMessageEntry,\n\ttype SessionNameState,\n\ttype SessionSummaryEntry,\n\ttype ThinkingLevelChangeEntry,\n\ttype WorktreeRestoreHostWarning,\n\ttype WorktreeSnapshotEntry,\n} from \"./session-manager-types.ts\";\nimport { generateId } from \"./session-manager-validation.ts\";\nimport type { WorktreeRootMapping, WorktreeSnapshot, WorktreeUnrestored } from \"./worktree-snapshot/types.ts\";\n\nfunction entryBase(\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n): Pick<SessionEntryBase, \"id\" | \"parentId\" | \"timestamp\"> {\n\treturn {\n\t\tid: generateId(byId),\n\t\tparentId,\n\t\ttimestamp: new Date().toISOString(),\n\t};\n}\n\nconst kindOf = (value: unknown): string => (value === null ? \"null\" : Array.isArray(value) ? \"array\" : typeof value);\n\n/**\n * Check an extension-supplied `customType` before it is stored, so the session can be read back (#6097).\n */\nexport function checkedCustomType(customType: unknown, owner: \"custom entry\" | \"custom message\"): string {\n\tif (typeof customType !== \"string\")\n\t\tthrow new TypeError(`A ${owner} customType must be a string, not ${kindOf(customType)}`);\n\treturn customType;\n}\n\n/** Custom message content as the session stores it: text or content blocks, and empty when left out (#6097). */\nexport function checkedCustomMessageContent(content: unknown): string | (TextContent | ImageContent)[] {\n\tif (content === undefined || content === null) return [];\n\tif (typeof content === \"string\" || Array.isArray(content)) return content;\n\tthrow new TypeError(\n\t\t`A custom message content must be a string or an array of content blocks, not ${kindOf(content)}`,\n\t);\n}\n\n/**\n * A custom message as the session stores it (#6097): `customType` and content are checked, and `display` is read the\n * way the chat has always read it, by truthiness, so a missing `display` is false.\n */\nexport function checkedCustomMessage<T>(\n\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n): Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\"> {\n\treturn {\n\t\tcustomType: checkedCustomType(message.customType, \"custom message\"),\n\t\tcontent: checkedCustomMessageContent(message.content),\n\t\tdisplay: Boolean(message.display),\n\t\tdetails: message.details,\n\t};\n}\n\n/** Check a label before it is stored, so the session can be read back (#6097). */\nexport function checkedLabel(label: unknown): string | undefined {\n\tif (label === undefined || typeof label === \"string\") return label;\n\tthrow new TypeError(`A label must be a string or undefined, not ${kindOf(label)}`);\n}\n\nexport function createSessionHeader(\n\tid: string,\n\tcwd: string,\n\ttimestamp: string = new Date().toISOString(),\n\tparentSession?: string,\n): SessionHeader {\n\treturn {\n\t\ttype: \"session\",\n\t\tversion: CURRENT_SESSION_VERSION,\n\t\tid,\n\t\tcreatedAt: timestamp,\n\t\tcwd,\n\t\t...(parentSession === undefined ? {} : { parentSessionId: parentSession }),\n\t};\n}\n\nexport function createSessionFilePath(sessionDir: string, timestamp: string, sessionId: string): string {\n\tconst fileTimestamp = timestamp.replace(/[:.]/g, \"-\");\n\treturn join(sessionDir, `${fileTimestamp}_${sessionId}.jsonl`);\n}\n\nexport function createMessageEntry(\n\tmessage: Message | CustomMessage | BashExecutionMessage,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n): SessionMessageEntry {\n\treturn {\n\t\ttype: \"message\",\n\t\t...entryBase(byId, parentId),\n\t\tmessage,\n\t};\n}\n\nexport function createThinkingLevelChangeEntry(\n\tthinkingLevel: string,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n): ThinkingLevelChangeEntry {\n\treturn {\n\t\ttype: \"thinking_level_change\",\n\t\t...entryBase(byId, parentId),\n\t\tthinkingLevel,\n\t};\n}\n\nexport function createModelChangeEntry(\n\tprovider: string,\n\tmodelId: string,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n\tfallback?: ModelFallbackRecord,\n): ModelChangeEntry {\n\treturn {\n\t\ttype: \"model_change\",\n\t\t...entryBase(byId, parentId),\n\t\tprovider,\n\t\tmodelId,\n\t\t...(fallback === undefined ? {} : { fallback }),\n\t};\n}\n\nexport function createCompactionEntry(\n\tcompactedText: string,\n\tfirstKeptEntryId: string | null,\n\ttokensBefore: number,\n\tdetails: VerbatimCompactionDetails,\n\tusage: Usage | undefined,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n\tcoveredThroughEntryId?: string,\n): CompactionEntry<VerbatimCompactionDetails> {\n\treturn {\n\t\ttype: \"compaction\",\n\t\t...entryBase(byId, parentId),\n\t\tsummary: compactedText,\n\t\tfirstKeptEntryId,\n\t\ttokensBefore,\n\t\t...(coveredThroughEntryId === undefined ? {} : { coveredThroughEntryId }),\n\t\tdetails,\n\t\tusage,\n\t\tfromHook: details.backend === \"extension\" || undefined,\n\t};\n}\n\nexport function createContextEditEntry(\n\ttargetId: string,\n\treplacement: ContextEditEntry[\"replacement\"],\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n): ContextEditEntry {\n\treturn {\n\t\ttype: \"context_edit\",\n\t\t...entryBase(byId, parentId),\n\t\ttargetId,\n\t\treplacement,\n\t};\n}\n\nexport function createCustomEntry(\n\tcustomType: string,\n\tdata: unknown,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n): CustomEntry {\n\treturn {\n\t\ttype: \"custom\",\n\t\tcustomType: checkedCustomType(customType, \"custom entry\"),\n\t\tdata,\n\t\t...entryBase(byId, parentId),\n\t};\n}\n\nexport function createSessionInfoEntry(\n\tname: string,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n): SessionInfoEntry {\n\treturn {\n\t\ttype: \"session_info\",\n\t\t...entryBase(byId, parentId),\n\t\tname: name.trim(),\n\t};\n}\n\nexport function createWorktreeSnapshotEntry(\n\troot: string,\n\tsnapshotId: string,\n\tsnapshot: WorktreeSnapshot | undefined,\n\trestore: WorktreeRootMapping | undefined,\n\trestoreWarnings: readonly WorktreeRestoreHostWarning[],\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n\tunrestored?: WorktreeUnrestored,\n\tcaptureMs?: number,\n\tdegradedFrom?: string,\n): WorktreeSnapshotEntry {\n\treturn {\n\t\ttype: \"worktree_snapshot\",\n\t\t...entryBase(byId, parentId),\n\t\troot,\n\t\tsnapshotId,\n\t\t...(snapshot === undefined ? {} : { snapshot }),\n\t\t...(restore === undefined ? {} : { restore }),\n\t\t...(restoreWarnings.length === 0 ? {} : { restoreWarnings: [...restoreWarnings] }),\n\t\t...(unrestored === undefined ? {} : { unrestored }),\n\t\t...(captureMs === undefined ? {} : { captureMs }),\n\t\t...(degradedFrom === undefined ? {} : { degradedFrom }),\n\t};\n}\n\nexport function createSessionSummaryEntry(\n\tsummary: string,\n\tsummarizedThroughId: string,\n\tusage: Usage | undefined,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n): SessionSummaryEntry {\n\treturn {\n\t\ttype: \"session_summary\",\n\t\t...entryBase(byId, parentId),\n\t\tsummary: summary.trim(),\n\t\tsummarizedThroughId,\n\t\tusage,\n\t};\n}\n\n/**\n * Anchor for a session summary: the newest user/assistant message entry.\n *\n * Both sides of the freshness check call this so they cannot drift apart. Tool results and\n * non-message entries are ignored, and an assistant turn made only of tool calls still counts —\n * it carries no text, but it is a real conversation step.\n */\nexport function getLastConversationMessageId(entries: FileEntry[]): string | undefined {\n\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\tconst entry = entries[i];\n\t\tif (entry.type !== \"message\") continue;\n\t\tconst role = entry.message.role;\n\t\tif (role === \"user\" || role === \"assistant\") return entry.id;\n\t}\n\treturn undefined;\n}\n\n/**\n * Latest generated resume summary that has not been retired, entry and all.\n *\n * Returns the entry rather than its text: callers need `summarizedThroughId` alongside the\n * summary to decide whether it still describes the conversation.\n *\n * A `branch_summary` written afterwards retires it, because the branch it described was\n * abandoned. Both the picker and the generation guard call this, so a retired summary is hidden\n * from the picker *and* lets a replacement be generated; splitting the two rules leaves such a\n * session showing fallback text forever.\n */\nexport function getLatestSessionSummary(entries: FileEntry[]): SessionSummaryEntry | undefined {\n\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\tconst entry = entries[i];\n\t\tif (entry.type === \"branch_summary\") return undefined;\n\t\tif (entry.type === \"session_summary\") return entry;\n\t}\n\treturn undefined;\n}\n\nexport function getLatestSessionName(entries: readonly FileEntry[]): SessionNameState {\n\t// Walk entries in reverse to find the latest session_info entry. An existing entry\n\t// with an empty name is an explicit clear, not a never-named session: the fact that\n\t// a session was named is separate from the name it currently holds (upstream 7bdb16c2).\n\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\tconst entry = entries[i];\n\t\tif (entry.type === \"session_info\") {\n\t\t\tconst name = entry.name?.trim() || undefined;\n\t\t\treturn { hasName: true, ...(name !== undefined ? { name } : {}) };\n\t\t}\n\t}\n\treturn { hasName: false };\n}\n\nexport function createCustomMessageEntry<T = unknown>(\n\tcustomType: string,\n\tcontent: string | (TextContent | ImageContent)[],\n\tdisplay: boolean,\n\tdetails: T | undefined,\n\texcludeFromContext: boolean | undefined,\n\tprotectedReconciliation: CustomMessageEntry[\"protectedReconciliation\"],\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n\tstageAdmissionKey?: string,\n): CustomMessageEntry<T> {\n\treturn {\n\t\ttype: \"custom_message\",\n\t\t...checkedCustomMessage({ customType, content, display, details }),\n\t\t...(excludeFromContext === true ? { excludeFromContext: true } : {}),\n\t\t...(stageAdmissionKey === undefined ? {} : { stageAdmissionKey }),\n\t\t...(protectedReconciliation === undefined ? {} : { protectedReconciliation }),\n\t\t...entryBase(byId, parentId),\n\t};\n}\n\nexport function createLabelEntry(\n\ttargetId: string,\n\tlabel: string | undefined,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n\tparentId: string | null,\n\ttimestamp?: string,\n): LabelEntry {\n\treturn {\n\t\ttype: \"label\",\n\t\t...entryBase(byId, parentId),\n\t\t...(timestamp !== undefined ? { timestamp } : {}),\n\t\ttargetId,\n\t\tlabel: checkedLabel(label),\n\t};\n}\n\nexport function createBranchSummaryEntry(\n\tbranchFromId: string | null,\n\tfromId: string,\n\tsummary: string,\n\tdetails: unknown,\n\tusage: Usage | undefined,\n\tfromHook: boolean | undefined,\n\tbyId: { has(id: string): boolean; preferFullIds?: boolean },\n): BranchSummaryEntry {\n\treturn {\n\t\ttype: \"branch_summary\",\n\t\t...entryBase(byId, branchFromId),\n\t\tfromId,\n\t\tsummary,\n\t\tdetails,\n\t\tusage,\n\t\tfromHook,\n\t};\n}\n\nexport function getEntriesWithoutHeader(fileEntries: FileEntry[]): SessionEntry[] {\n\treturn fileEntries.filter((entry): entry is SessionEntry => entry.type !== \"session\");\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"settings-lock-directory.d.ts","sourceRoot":"","sources":["../../src/core/settings-lock-directory.ts"],"names":[],"mappings":"AAgCA,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI,CAEtF;AA8CD,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC3B;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAUvE;AAED,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,qBAAqB,GAAG,OAAO,CAKvF"}
1
+ {"version":3,"file":"settings-lock-directory.d.ts","sourceRoot":"","sources":["../../src/core/settings-lock-directory.ts"],"names":[],"mappings":"AAiCA,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI,CAEtF;AA8CD,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC3B;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAUvE;AAED,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,qBAAqB,GAAG,OAAO,CAKvF"}
@@ -1,4 +1,5 @@
1
1
  import { Worker } from "node:worker_threads";
2
+ import { evalWorkerExecArgv } from "../utils/worker-threads.js";
2
3
  const QUEUED = 0;
3
4
  const CREATING = 1;
4
5
  const CREATED = 2;
@@ -35,7 +36,7 @@ const pending = new Map();
35
36
  function creatorWorker() {
36
37
  if (creator)
37
38
  return creator;
38
- const worker = new Worker(CREATOR_SOURCE, { eval: true });
39
+ const worker = new Worker(CREATOR_SOURCE, { eval: true, execArgv: evalWorkerExecArgv() });
39
40
  worker.unref();
40
41
  worker.on("message", (reply) => {
41
42
  const creation = pending.get(reply.id);
@@ -1 +1 @@
1
- {"version":3,"file":"settings-lock-directory.js","sourceRoot":"","sources":["../../src/core/settings-lock-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,MAAM,MAAM,GAAG,CAAC,CAAC;AACjB,MAAM,QA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EAAE,KAAK,EAAE,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,QAA+B;IAC7E,MAAM,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7E,IAAI,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAC9D,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC/F,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC;AACpD,CAAC","sourcesContent":["import { Worker } from \"node:worker_threads\";\n\nconst QUEUED = 0;\nconst CREATING = 1;\nconst CREATED = 2;\nconst FAILED = 3;\nconst CLAIMED = 4;\n\nconst CREATOR_SOURCE = `\nconst { parentPort } = require(\"node:worker_threads\");\nconst { mkdirSync } = require(\"node:fs\");\nparentPort.on(\"message\", ({ id, path, state, gate }) => {\n const slot = new Int32Array(state);\n if (Atomics.compareExchange(slot, 0, ${QUEUED}, ${CREATING}) !== ${QUEUED}) {\n parentPort.postMessage({ id, claimed: true });\n return;\n }\n let failure;\n try {\n mkdirSync(path);\n } catch (error) {\n failure = { code: error && error.code, message: String(error && error.message) };\n }\n if (gate) Atomics.wait(new Int32Array(gate), 0, 0);\n Atomics.store(slot, 0, failure ? ${FAILED} : ${CREATED});\n Atomics.notify(slot, 0);\n parentPort.postMessage(failure ? { id, ...failure } : { id });\n});\n`;\n\nlet publicationGate: SharedArrayBuffer | undefined;\n\nexport function gateLockDirectoryPublication(gate: SharedArrayBuffer | undefined): void {\n\tpublicationGate = gate;\n}\n\ninterface CreatorReply {\n\treadonly id: number;\n\treadonly claimed?: boolean;\n\treadonly code?: string;\n\treadonly message?: string;\n}\n\ninterface PendingCreation {\n\treadonly resolve: () => void;\n\treadonly reject: (error: Error) => void;\n}\n\nlet creator: Worker | undefined;\nlet nextId = 0;\nconst pending = new Map<number, PendingCreation>();\n\nfunction creatorWorker(): Worker {\n\tif (creator) return creator;\n\tconst worker = new Worker(CREATOR_SOURCE, { eval: true });\n\tworker.unref();\n\tworker.on(\"message\", (reply: CreatorReply) => {\n\t\tconst creation = pending.get(reply.id);\n\t\tif (!creation) return;\n\t\tpending.delete(reply.id);\n\t\tif (pending.size === 0) worker.unref();\n\t\tif (reply.claimed)\n\t\t\tcreation.reject(\n\t\t\t\tObject.assign(new Error(\"The process exited before the lock was taken\"), { code: \"ECANCELED\" }),\n\t\t\t);\n\t\telse if (reply.code !== undefined || reply.message !== undefined)\n\t\t\tcreation.reject(Object.assign(new Error(reply.message ?? \"mkdir failed\"), { code: reply.code }));\n\t\telse creation.resolve();\n\t});\n\tworker.on(\"error\", (error) => {\n\t\tif (creator === worker) creator = undefined;\n\t\tfor (const [id, creation] of pending) {\n\t\t\tpending.delete(id);\n\t\t\tcreation.reject(error);\n\t\t}\n\t});\n\tcreator = worker;\n\treturn worker;\n}\n\nexport interface LockDirectoryCreation {\n\treadonly created: Promise<void>;\n\treadonly state: Int32Array;\n}\n\nexport function createLockDirectory(path: string): LockDirectoryCreation {\n\tconst state = new SharedArrayBuffer(4);\n\tconst id = nextId++;\n\tconst created = new Promise<void>((resolve, reject) => {\n\t\tpending.set(id, { resolve, reject });\n\t});\n\tconst worker = creatorWorker();\n\tif (pending.size === 1) worker.ref();\n\tworker.postMessage({ id, path, state, gate: publicationGate });\n\treturn { created, state: new Int32Array(state) };\n}\n\nexport function lockDirectoryCreatedBeforeExit(creation: LockDirectoryCreation): boolean {\n\tconst previous = Atomics.compareExchange(creation.state, 0, QUEUED, CLAIMED);\n\tif (previous === QUEUED || previous === CLAIMED) return false;\n\twhile (Atomics.load(creation.state, 0) === CREATING) Atomics.wait(creation.state, 0, CREATING);\n\treturn Atomics.load(creation.state, 0) === CREATED;\n}\n"]}
1
+ {"version":3,"file":"settings-lock-directory.js","sourceRoot":"","sources":["../../src/core/settings-lock-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,MAAM,MAAM,GAAG,CAAC,CAAC;AACjB,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,OAAO,GAAG,CAAC,CAAC;AAClB,MAAM,MAAM,GAAG,CAAC,CAAC;AACjB,MAAM,OAAO,GAAG,CAAC,CAAC;AAElB,MAAM,cAAc,GAAG;;;;;yCAKkB,MAAM,KAAK,QAAQ,SAAS,MAAM;;;;;;;;;;;qCAWtC,MAAM,MAAM,OAAO;;;;CAIvD,CAAC;AAEF,IAAI,eAA8C,CAAC;AAEnD,MAAM,UAAU,4BAA4B,CAAC,IAAmC;IAC/E,eAAe,GAAG,IAAI,CAAC;AACxB,CAAC;AAcD,IAAI,OAA2B,CAAC;AAChC,IAAI,MAAM,GAAG,CAAC,CAAC;AACf,MAAM,OAAO,GAAG,IAAI,GAAG,EAA2B,CAAC;AAEnD,SAAS,aAAa;IACrB,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC;IAC1F,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,KAAmB,EAAE,EAAE;QAC5C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ;YAA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EAAE,MAAM,EAAE,EAAE;QACrD,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC;QAAE,MAAM,CAAC,GAAG,EAAE,CAAC;IACrC,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;IAC/D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,QAA+B;IAC7E,MAAM,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7E,IAAI,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAC9D,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC/F,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC;AACpD,CAAC","sourcesContent":["import { Worker } from \"node:worker_threads\";\nimport { evalWorkerExecArgv } from \"../utils/worker-threads.js\";\n\nconst QUEUED = 0;\nconst CREATING = 1;\nconst CREATED = 2;\nconst FAILED = 3;\nconst CLAIMED = 4;\n\nconst CREATOR_SOURCE = `\nconst { parentPort } = require(\"node:worker_threads\");\nconst { mkdirSync } = require(\"node:fs\");\nparentPort.on(\"message\", ({ id, path, state, gate }) => {\n const slot = new Int32Array(state);\n if (Atomics.compareExchange(slot, 0, ${QUEUED}, ${CREATING}) !== ${QUEUED}) {\n parentPort.postMessage({ id, claimed: true });\n return;\n }\n let failure;\n try {\n mkdirSync(path);\n } catch (error) {\n failure = { code: error && error.code, message: String(error && error.message) };\n }\n if (gate) Atomics.wait(new Int32Array(gate), 0, 0);\n Atomics.store(slot, 0, failure ? ${FAILED} : ${CREATED});\n Atomics.notify(slot, 0);\n parentPort.postMessage(failure ? { id, ...failure } : { id });\n});\n`;\n\nlet publicationGate: SharedArrayBuffer | undefined;\n\nexport function gateLockDirectoryPublication(gate: SharedArrayBuffer | undefined): void {\n\tpublicationGate = gate;\n}\n\ninterface CreatorReply {\n\treadonly id: number;\n\treadonly claimed?: boolean;\n\treadonly code?: string;\n\treadonly message?: string;\n}\n\ninterface PendingCreation {\n\treadonly resolve: () => void;\n\treadonly reject: (error: Error) => void;\n}\n\nlet creator: Worker | undefined;\nlet nextId = 0;\nconst pending = new Map<number, PendingCreation>();\n\nfunction creatorWorker(): Worker {\n\tif (creator) return creator;\n\tconst worker = new Worker(CREATOR_SOURCE, { eval: true, execArgv: evalWorkerExecArgv() });\n\tworker.unref();\n\tworker.on(\"message\", (reply: CreatorReply) => {\n\t\tconst creation = pending.get(reply.id);\n\t\tif (!creation) return;\n\t\tpending.delete(reply.id);\n\t\tif (pending.size === 0) worker.unref();\n\t\tif (reply.claimed)\n\t\t\tcreation.reject(\n\t\t\t\tObject.assign(new Error(\"The process exited before the lock was taken\"), { code: \"ECANCELED\" }),\n\t\t\t);\n\t\telse if (reply.code !== undefined || reply.message !== undefined)\n\t\t\tcreation.reject(Object.assign(new Error(reply.message ?? \"mkdir failed\"), { code: reply.code }));\n\t\telse creation.resolve();\n\t});\n\tworker.on(\"error\", (error) => {\n\t\tif (creator === worker) creator = undefined;\n\t\tfor (const [id, creation] of pending) {\n\t\t\tpending.delete(id);\n\t\t\tcreation.reject(error);\n\t\t}\n\t});\n\tcreator = worker;\n\treturn worker;\n}\n\nexport interface LockDirectoryCreation {\n\treadonly created: Promise<void>;\n\treadonly state: Int32Array;\n}\n\nexport function createLockDirectory(path: string): LockDirectoryCreation {\n\tconst state = new SharedArrayBuffer(4);\n\tconst id = nextId++;\n\tconst created = new Promise<void>((resolve, reject) => {\n\t\tpending.set(id, { resolve, reject });\n\t});\n\tconst worker = creatorWorker();\n\tif (pending.size === 1) worker.ref();\n\tworker.postMessage({ id, path, state, gate: publicationGate });\n\treturn { created, state: new Int32Array(state) };\n}\n\nexport function lockDirectoryCreatedBeforeExit(creation: LockDirectoryCreation): boolean {\n\tconst previous = Atomics.compareExchange(creation.state, 0, QUEUED, CLAIMED);\n\tif (previous === QUEUED || previous === CLAIMED) return false;\n\twhile (Atomics.load(creation.state, 0) === CREATING) Atomics.wait(creation.state, 0, CREATING);\n\treturn Atomics.load(creation.state, 0) === CREATED;\n}\n"]}
@@ -0,0 +1,173 @@
1
+ import type { DatabaseSync, SQLInputValue, StatementSync } from "node:sqlite";
2
+ /**
3
+ * A connection on a thread of its own taking or holding a file's write lock: open from the moment it sends
4
+ * `BEGIN IMMEDIATE` until it learns that the attempt was refused or failed, or until its transaction let go of the
5
+ * lock. Only a `scoped` hold, one opened while the process had a wrapped connection to the file, makes wrapped calls
6
+ * wait: its transaction's callback runs in its asynchronous context (`runInHold`), so calls made inside it are told
7
+ * apart. A process that wraps no connection to the file never enters that context, and wrapped calls made while an
8
+ * unscoped hold is open run at once, as they always have.
9
+ */
10
+ export interface FileHold {
11
+ readonly file: string;
12
+ readonly scoped: boolean;
13
+ open: boolean;
14
+ }
15
+ /** The holds whose transaction callbacks an asynchronous context runs in, innermost first. */
16
+ export interface HoldScope {
17
+ readonly hold: FileHold;
18
+ readonly outer: HoldScope | undefined;
19
+ }
20
+ /** A threaded connection's share of its file's word: the word, its tag, and how to stop using it. */
21
+ export interface FileLock {
22
+ readonly buffer: SharedArrayBuffer;
23
+ readonly tag: number;
24
+ /** Gives the word back if this connection still takes or holds it, as when its thread exited. */
25
+ clear(): void;
26
+ /** This connection no longer uses the word; the file's word goes once no connection does. */
27
+ release(): void;
28
+ }
29
+ /** A call waiting for its turn; one decided only at its turn (see `runDeferred`) is armed then. */
30
+ interface Waiter {
31
+ deadline: number;
32
+ timer: ReturnType<typeof setTimeout> | undefined;
33
+ /** The connection the call runs on: later calls on it wait behind this one (see `runDeferred`). */
34
+ readonly connection: DatabaseSync;
35
+ /** Runs the call if it can run now; whether it did. */
36
+ tryRun: () => boolean;
37
+ fail: () => void;
38
+ }
39
+ /** Statements a calling-thread connection prepared to decide how its calls run while the file is held; see `modeOf`. */
40
+ interface Plans {
41
+ readonly explained: Map<string, StatementSync>;
42
+ busyTimeout?: StatementSync;
43
+ /** Whether the file is in WAL mode; see `inWriteAheadLog`. */
44
+ writeAheadLog?: boolean;
45
+ /** Whether the connection lets its busy timeout be set; see `triesAllowed`. */
46
+ timeoutSettable?: boolean;
47
+ }
48
+ /**
49
+ * One file's open holds, the calls waiting to run, and what those calls' connections prepared meanwhile, by the
50
+ * object that owns each connection (not the connection, which its own statements keep alive), so they are kept no
51
+ * longer than it is.
52
+ */
53
+ export interface FileGate {
54
+ readonly holds: Set<FileHold>;
55
+ readonly waiters: Waiter[];
56
+ readonly plans: WeakMap<object, Plans>;
57
+ watching: boolean;
58
+ /** A call ran on this file in the current turn of the event loop; the next one waits for the next turn. */
59
+ paced: boolean;
60
+ pumping: boolean;
61
+ polling: boolean;
62
+ }
63
+ /** A threaded connection to `file` starts using the file's word (see `FREE`). */
64
+ export declare function useFileLock(file: string): FileLock;
65
+ /**
66
+ * A wrapped connection, `owner`, to `file` counts as open until `release` or until `owner` is collected, whichever
67
+ * comes first; see `FileHold`.
68
+ */
69
+ export declare function useWrappedFile(file: string, owner: object): {
70
+ release(): void;
71
+ };
72
+ /** Opens a hold on `file`, identified as `fileIdentity` identifies it, scoped if a wrapped connection to it is open. */
73
+ export declare function holdFile(file: string): FileHold;
74
+ /**
75
+ * Closes `hold`, once. When it was the file's last, the oldest call waiting for the file runs now, if the word is free
76
+ * and no call ran in this turn; the others follow one per turn (see `runNextWaiter`).
77
+ */
78
+ export declare function releaseHold(hold: FileHold | undefined): void;
79
+ /**
80
+ * Runs a transaction's callback inside the transaction callbacks it was requested in (`scope`, captured when it was
81
+ * requested, since a group commit runs it from another's request) and inside its own hold, so calls it makes can be
82
+ * told apart.
83
+ */
84
+ export declare function runInHold<T>(hold: FileHold | undefined, scope: HoldScope | undefined, callback: () => T): T;
85
+ /** The holds whose callbacks the caller runs in; captured when a call is made, not when it runs. */
86
+ export declare function currentHoldScope(): HoldScope | undefined;
87
+ /**
88
+ * Whether a call made now on a wrapped connection to `file` comes in behind a transaction: a scoped hold is open or
89
+ * calls wait for their turn. Read when the call is made; one made once that is over runs as it always has, however
90
+ * busy the file was before.
91
+ */
92
+ export declare function inBacklog(file: string): boolean;
93
+ /**
94
+ * The gate of `file` when another context holds it open: some hold is open, and none of the callbacks `scope` runs in
95
+ * belongs to an open hold of it. A call made inside an open hold's own callback cannot wait for it, since the
96
+ * transaction waits for the call: it runs at once, as it always has. A call made in the backlog of a transaction
97
+ * (`backlog`, see `inBacklog`) also takes its turn behind the calls queued before it, one per turn.
98
+ */
99
+ export declare function heldElsewhere(file: string, scope: HoldScope | undefined, backlog: boolean): FileGate | undefined;
100
+ /**
101
+ * Runs `run` as soon as the file's word is free: at once if it is, as SQLite's busy handler would find the lock free;
102
+ * otherwise once a threaded connection gives the word back, or the file's last hold closes. Fails it with `busy()`,
103
+ * having run nothing, if the word is still taken at the end of the busy timeout of `database`, which `owner` owns
104
+ * (read only when the call has to wait). When that cannot be read, `run` runs at once, as it always has.
105
+ */
106
+ export declare function runWhenFree<T>(file: string, gate: FileGate, owner: object, database: DatabaseSync, run: () => Promise<T>, busy: () => Error): Promise<T>;
107
+ /** Drops what the connection of `owner` prepared while `file` was held, as it closes. */
108
+ export declare function forgetPlans(file: string, owner: object): void;
109
+ /**
110
+ * How a wrapped call runs while a threaded transaction of this thread holds its file:
111
+ *
112
+ * - `try first`: once at once with a busy timeout of 0 (see `runTryingFirst`), refused the lock, tried again. Only a
113
+ * statement whose plan proves that a refusal comes from its opening steps, before it did anything: the only
114
+ * databases it writes are the file and the temporary one, and the file is in WAL mode, where a commit needs no
115
+ * further lock; it calls no code but SQLite's own (no function or collating sequence SQLite does not build in, no
116
+ * virtual table, no `UNSAFE_FUNCTIONS`); it is no VACUUM, which may create the file it writes into before it is
117
+ * refused. A PRAGMA, which is never prepared ahead since SQLite may carry one out while preparing it, is tried first
118
+ * only if it is one of `TRIED_PRAGMAS`.
119
+ * - `as before`: every other single statement, an `exec` of no statement, and every call while the connection is
120
+ * inside a transaction of its own or the file is not in WAL mode. It runs exactly as it always has, with the
121
+ * connection's own busy timeout.
122
+ * - `script`: an `exec` of more than one statement (see `splitStatements`). It waits until no transaction of this
123
+ * thread holds the lock (see `runWhenFree`), so no part of it runs while the lock is held. An `exec` of exactly one
124
+ * statement runs as that statement.
125
+ *
126
+ * At a busy timeout of 0 every single statement runs as before: it never waits for the lock, and setting the timeout,
127
+ * as a try does, would remove a busy handler an extension installed, which reads as a timeout of 0. A script still
128
+ * waits (for no time), which sets no timeout.
129
+ *
130
+ * The plan of a statement is made once while the file is held and listed again for later calls. Listing the plan of
131
+ * an INSERT, UPDATE or DELETE resets the connection's `changes()`, which the statement's own run sets again; so a
132
+ * statement that names a function that reads the change counters or may (see `namesUnsafeFunction`) runs as before
133
+ * without its plan being listed.
134
+ */
135
+ export declare function modeOf(gate: FileGate, owner: object, database: DatabaseSync, sql: string, params: readonly SQLInputValue[], single: boolean): "try first" | "as before" | "script";
136
+ /**
137
+ * Runs a single statement, `attempt` (synchronous on `database`, the connection `owner` owns), the way SQLite's busy
138
+ * handler would, without holding this thread: once at once with a busy timeout of 0; refused the lock, it waits off
139
+ * this thread and is tried again once a threaded transaction gives the lock back, or on a short poll for a lock another
140
+ * process holds, oldest first and one call per turn of the event loop; still refused at the end of the connection's
141
+ * busy timeout, it fails with that SQLITE_BUSY. Calls already waiting go first. When the busy timeout cannot be read,
142
+ * `asBefore` runs it as it always has.
143
+ */
144
+ export declare function runTryingFirst<T>(file: string, gate: FileGate, owner: object, database: DatabaseSync, attempt: () => T, asBefore: () => Promise<T>, busy: () => Error): Promise<T>;
145
+ /** Whether a call on `database` waits for its turn. */
146
+ export declare function connectionWaits(gate: FileGate, database: DatabaseSync): boolean;
147
+ /**
148
+ * Runs a call on `database`, which `owner` owns, behind an earlier call on the same connection that waits, from this
149
+ * or another wrapped handle, so no call runs on a connection between a refused try of an earlier call and the try that
150
+ * follows, as none could while SQLite's busy handler waited. It is decided (see `modeOf`) only at its turn,
151
+ * since listing the plan of an INSERT, UPDATE or DELETE resets the connection's `changes()`, which a call before it
152
+ * could read; then it runs as `runTryingFirst` or `runWhenFree` would, or as before, with `call`. Once no threaded
153
+ * transaction holds the file, it runs as before.
154
+ */
155
+ export declare function runDeferred<T>(file: string, gate: FileGate, owner: object, database: DatabaseSync, statement: {
156
+ readonly sql: string;
157
+ readonly params: readonly SQLInputValue[];
158
+ readonly single: boolean;
159
+ }, attempt: () => T, call: () => Promise<T>, busy: () => Error): Promise<T>;
160
+ /**
161
+ * The statements of an `exec` text, split as SQLite reads them: past quoted strings and names (`'…'`, `"…"`, `` `…` ``,
162
+ * `[…]`) and comments, with a trigger's body (`CREATE TRIGGER … BEGIN … END`) kept in its statement. Empty statements
163
+ * are dropped. A comment left open runs to the end of the text; past a quote left open, or in a trigger's body without
164
+ * its END, the rest of the text is one statement, which SQLite fails.
165
+ */
166
+ export declare function splitStatements(sql: string): string[];
167
+ /**
168
+ * SQLITE_BUSY as the runtime's node:sqlite reports it, for a call that waited out its busy timeout without running:
169
+ * the runtime's own error class with the fields a refused statement carries.
170
+ */
171
+ export declare function sqliteBusyError(): Error;
172
+ export {};
173
+ //# sourceMappingURL=node-sqlite-file-gate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-sqlite-file-gate.d.ts","sourceRoot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