@maxmo74/pi-coding-agent 1.4.0-max.4 → 1.5.0-max.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 (394) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/dist/bundle/chunks/anthropic-messages-BWGCKOF4.js +6 -0
  3. package/dist/bundle/chunks/azure-openai-responses-FSC6BAW3.js +2 -0
  4. package/dist/bundle/chunks/bedrock-converse-stream.js +7 -4
  5. package/dist/bundle/chunks/chunk-36QC74V4.js +2 -0
  6. package/dist/bundle/chunks/{chunk-RWO6Q3KK.js → chunk-3TGLJEWK.js} +1 -1
  7. package/dist/bundle/chunks/chunk-4EYXVSA5.js +129 -0
  8. package/dist/bundle/chunks/{chunk-IUWY2KTF.js → chunk-62VOPMLK.js} +8 -7
  9. package/dist/bundle/chunks/chunk-7O7QKK6A.js +2 -0
  10. package/dist/bundle/chunks/{chunk-A45IWOC6.js → chunk-B46VJEHW.js} +2 -2
  11. package/dist/bundle/chunks/{chunk-TRERZKRC.js → chunk-C2WU32PX.js} +1 -1
  12. package/dist/bundle/chunks/chunk-CHWNPHIS.js +82 -0
  13. package/dist/bundle/chunks/{chunk-Z6I32PHA.js → chunk-EOO47QGR.js} +1 -1
  14. package/dist/bundle/chunks/{chunk-S3C5CJSN.js → chunk-F3CATSP5.js} +1 -1
  15. package/dist/bundle/chunks/chunk-FFMDRXC4.js +10 -0
  16. package/dist/bundle/chunks/{chunk-QSDU2SDK.js → chunk-GN3QYODH.js} +4 -4
  17. package/dist/bundle/chunks/chunk-MBPIC3AF.js +1239 -0
  18. package/dist/bundle/chunks/chunk-NL4X6LBY.js +4 -0
  19. package/dist/bundle/chunks/chunk-NZY7EIPA.js +4 -0
  20. package/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
  21. package/dist/bundle/chunks/{chunk-N43LRJ4N.js → chunk-R2EGYMOO.js} +3 -3
  22. package/dist/bundle/chunks/chunk-V6KH5QG4.js +9 -0
  23. package/dist/bundle/chunks/chunk-VOLAXWGI.js +2 -0
  24. package/dist/bundle/chunks/{chunk-RISAW7OQ.js → chunk-YZKQS34S.js} +2 -2
  25. package/dist/bundle/chunks/{cli-MIMUTM5L.js → cli-MCOUW5WS.js} +11 -9
  26. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-7J6REGDV.js → cloudflare-workers-ai-system-one-WLAFJSP6.js} +1 -1
  27. package/dist/bundle/chunks/{easter-egg-3d-RMLF7AC4.js → easter-egg-3d-WMBNSJ4M.js} +1 -1
  28. package/dist/bundle/chunks/{execute-MT7QEDSI.js → execute-4CEBORGZ.js} +1 -1
  29. package/dist/bundle/chunks/github-copilot.js +1 -1
  30. package/dist/bundle/chunks/{google-generative-ai-VPNFZDHO.js → google-generative-ai-INGKNW72.js} +1 -1
  31. package/dist/bundle/chunks/{google-vertex-ZFM23MQ4.js → google-vertex-IBTX6MBF.js} +1 -1
  32. package/dist/bundle/chunks/image-resize-worker.js +1 -1
  33. package/dist/bundle/chunks/kimi-coding.js +1 -1
  34. package/dist/bundle/chunks/{llama-cpp-classify-U4EH6TAM.js → llama-cpp-classify-V5U3QKXI.js} +1 -1
  35. package/dist/bundle/chunks/meta.js +1 -1
  36. package/dist/bundle/chunks/mistral-conversations-S4OWXIXQ.js +5 -0
  37. package/dist/bundle/chunks/{openai-codex-responses-JQR3IK2C.js → openai-codex-responses-QAWLOQSN.js} +1 -1
  38. package/dist/bundle/chunks/openai-completions-EJNYB6IX.js +7 -0
  39. package/dist/bundle/chunks/{openai-decisions-MJYPUCLX.js → openai-decisions-IXI34BYG.js} +1 -1
  40. package/dist/bundle/chunks/{openai-responses-I2TBW7OL.js → openai-responses-MD3562FB.js} +1 -1
  41. package/dist/bundle/chunks/{openrouter-images-WBAVKHHY.js → openrouter-images-PISKSFMS.js} +1 -1
  42. package/dist/bundle/chunks/pi-messages-NORUKF4E.js +8 -0
  43. package/dist/bundle/chunks/radius.js +1 -1
  44. package/dist/bundle/chunks/{runtime-GJOZRI5I.js → runtime-FQB7RU7U.js} +1 -1
  45. package/dist/bundle/chunks/{typesafe-system-one-4C7ULOVP.js → typesafe-system-one-CHVC2UUI.js} +1 -1
  46. package/dist/bundle/chunks/virtual-modules-CIGIPHNL.js +2 -0
  47. package/dist/bundle/cli-runtime.js +1 -1
  48. package/dist/bundle/index.js +1 -1
  49. package/dist/bundle/rpc-entry.js +1 -1
  50. package/dist/cli/args.d.ts.map +1 -1
  51. package/dist/cli/args.js +8 -7
  52. package/dist/cli/args.js.map +1 -1
  53. package/dist/config.d.ts +10 -0
  54. package/dist/config.d.ts.map +1 -1
  55. package/dist/config.js +24 -5
  56. package/dist/config.js.map +1 -1
  57. package/dist/core/agent-session-runtime.js +3 -3
  58. package/dist/core/agent-session-runtime.js.map +1 -1
  59. package/dist/core/agent-session.d.ts +6 -1
  60. package/dist/core/agent-session.d.ts.map +1 -1
  61. package/dist/core/agent-session.js +19 -1
  62. package/dist/core/agent-session.js.map +1 -1
  63. package/dist/core/bug-report.d.ts +4 -4
  64. package/dist/core/compaction/branch-summarization.d.ts +4 -2
  65. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  66. package/dist/core/compaction/branch-summarization.js +16 -4
  67. package/dist/core/compaction/branch-summarization.js.map +1 -1
  68. package/dist/core/exec.d.ts +9 -1
  69. package/dist/core/exec.d.ts.map +1 -1
  70. package/dist/core/exec.js +104 -60
  71. package/dist/core/exec.js.map +1 -1
  72. package/dist/core/export-html/template.css +9 -0
  73. package/dist/core/export-html/template.js +165 -45
  74. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  75. package/dist/core/export-html/tool-renderer.js +3 -0
  76. package/dist/core/export-html/tool-renderer.js.map +1 -1
  77. package/dist/core/extensions/index.d.ts +1 -1
  78. package/dist/core/extensions/index.d.ts.map +1 -1
  79. package/dist/core/extensions/index.js.map +1 -1
  80. package/dist/core/extensions/loader.d.ts.map +1 -1
  81. package/dist/core/extensions/loader.js +7 -6
  82. package/dist/core/extensions/loader.js.map +1 -1
  83. package/dist/core/extensions/pi-ai-extension-view.d.ts +19 -0
  84. package/dist/core/extensions/pi-ai-extension-view.d.ts.map +1 -0
  85. package/dist/core/extensions/pi-ai-extension-view.js +22 -0
  86. package/dist/core/extensions/pi-ai-extension-view.js.map +1 -0
  87. package/dist/core/extensions/types.d.ts +27 -4
  88. package/dist/core/extensions/types.d.ts.map +1 -1
  89. package/dist/core/extensions/types.js.map +1 -1
  90. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  91. package/dist/core/extensions/virtual-modules.js +8 -7
  92. package/dist/core/extensions/virtual-modules.js.map +1 -1
  93. package/dist/core/mcp-servers.d.ts +11 -4
  94. package/dist/core/mcp-servers.d.ts.map +1 -1
  95. package/dist/core/mcp-servers.js +15 -5
  96. package/dist/core/mcp-servers.js.map +1 -1
  97. package/dist/core/model-config.d.ts +1678 -2029
  98. package/dist/core/model-config.d.ts.map +1 -1
  99. package/dist/core/model-config.js +2 -3
  100. package/dist/core/model-config.js.map +1 -1
  101. package/dist/core/model-resolver.d.ts.map +1 -1
  102. package/dist/core/model-resolver.js +16 -10
  103. package/dist/core/model-resolver.js.map +1 -1
  104. package/dist/core/package-manager.d.ts +14 -0
  105. package/dist/core/package-manager.d.ts.map +1 -1
  106. package/dist/core/package-manager.js +160 -46
  107. package/dist/core/package-manager.js.map +1 -1
  108. package/dist/core/pi-ai-schemas.d.ts +163 -0
  109. package/dist/core/pi-ai-schemas.d.ts.map +1 -0
  110. package/dist/core/pi-ai-schemas.js +21 -0
  111. package/dist/core/pi-ai-schemas.js.map +1 -0
  112. package/dist/core/pi-manifest.d.ts +1 -0
  113. package/dist/core/pi-manifest.d.ts.map +1 -1
  114. package/dist/core/pi-manifest.js +4 -0
  115. package/dist/core/pi-manifest.js.map +1 -1
  116. package/dist/core/project-trust.js +1 -1
  117. package/dist/core/project-trust.js.map +1 -1
  118. package/dist/core/resource-loader.d.ts +4 -1
  119. package/dist/core/resource-loader.d.ts.map +1 -1
  120. package/dist/core/resource-loader.js +39 -24
  121. package/dist/core/resource-loader.js.map +1 -1
  122. package/dist/core/sdk.d.ts.map +1 -1
  123. package/dist/core/sdk.js +3 -1
  124. package/dist/core/sdk.js.map +1 -1
  125. package/dist/core/session-delete.d.ts +1 -1
  126. package/dist/core/session-delete.d.ts.map +1 -1
  127. package/dist/core/session-delete.js +3 -3
  128. package/dist/core/session-delete.js.map +1 -1
  129. package/dist/core/session-manager.d.ts +7 -0
  130. package/dist/core/session-manager.d.ts.map +1 -1
  131. package/dist/core/session-manager.js +32 -13
  132. package/dist/core/session-manager.js.map +1 -1
  133. package/dist/core/session-ownership.d.ts +11 -1
  134. package/dist/core/session-ownership.d.ts.map +1 -1
  135. package/dist/core/session-ownership.js +38 -7
  136. package/dist/core/session-ownership.js.map +1 -1
  137. package/dist/core/settings-manager.d.ts +2 -0
  138. package/dist/core/settings-manager.d.ts.map +1 -1
  139. package/dist/core/settings-manager.js +11 -0
  140. package/dist/core/settings-manager.js.map +1 -1
  141. package/dist/core/settings-schema.d.ts +4 -2
  142. package/dist/core/settings-schema.d.ts.map +1 -1
  143. package/dist/core/settings-schema.js +8 -1
  144. package/dist/core/settings-schema.js.map +1 -1
  145. package/dist/core/skills.d.ts.map +1 -1
  146. package/dist/core/skills.js +6 -14
  147. package/dist/core/skills.js.map +1 -1
  148. package/dist/core/slash-commands.js +2 -2
  149. package/dist/core/slash-commands.js.map +1 -1
  150. package/dist/core/source-info.d.ts +9 -0
  151. package/dist/core/source-info.d.ts.map +1 -1
  152. package/dist/core/source-info.js +13 -0
  153. package/dist/core/source-info.js.map +1 -1
  154. package/dist/core/system-prompt.d.ts.map +1 -1
  155. package/dist/core/system-prompt.js +5 -6
  156. package/dist/core/system-prompt.js.map +1 -1
  157. package/dist/core/tools/bash.d.ts +2 -2
  158. package/dist/core/tools/bash.d.ts.map +1 -1
  159. package/dist/core/tools/bash.js.map +1 -1
  160. package/dist/core/tools/edit.d.ts +3 -3
  161. package/dist/core/tools/edit.d.ts.map +1 -1
  162. package/dist/core/tools/edit.js +2 -4
  163. package/dist/core/tools/edit.js.map +1 -1
  164. package/dist/core/tools/find.d.ts +2 -2
  165. package/dist/core/tools/find.d.ts.map +1 -1
  166. package/dist/core/tools/find.js.map +1 -1
  167. package/dist/core/tools/grep.d.ts +2 -2
  168. package/dist/core/tools/grep.d.ts.map +1 -1
  169. package/dist/core/tools/grep.js +1 -1
  170. package/dist/core/tools/grep.js.map +1 -1
  171. package/dist/core/tools/ls.d.ts +2 -2
  172. package/dist/core/tools/ls.d.ts.map +1 -1
  173. package/dist/core/tools/ls.js.map +1 -1
  174. package/dist/core/tools/read.d.ts +2 -2
  175. package/dist/core/tools/read.d.ts.map +1 -1
  176. package/dist/core/tools/read.js.map +1 -1
  177. package/dist/core/tools/render-utils.d.ts.map +1 -1
  178. package/dist/core/tools/render-utils.js +2 -7
  179. package/dist/core/tools/render-utils.js.map +1 -1
  180. package/dist/core/tools/renderers/write.d.ts.map +1 -1
  181. package/dist/core/tools/renderers/write.js +19 -19
  182. package/dist/core/tools/renderers/write.js.map +1 -1
  183. package/dist/core/tools/tool-definition-wrapper.d.ts +11 -1
  184. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  185. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  186. package/dist/core/tools/write.d.ts +2 -2
  187. package/dist/core/tools/write.d.ts.map +1 -1
  188. package/dist/core/tools/write.js.map +1 -1
  189. package/dist/core/trust-manager.d.ts.map +1 -1
  190. package/dist/core/trust-manager.js +14 -8
  191. package/dist/core/trust-manager.js.map +1 -1
  192. package/dist/core/usage-totals.d.ts.map +1 -1
  193. package/dist/core/usage-totals.js +2 -0
  194. package/dist/core/usage-totals.js.map +1 -1
  195. package/dist/extensions/codemode/renderer.d.ts.map +1 -1
  196. package/dist/extensions/codemode/renderer.js +6 -2
  197. package/dist/extensions/codemode/renderer.js.map +1 -1
  198. package/dist/extensions/codemode/tool.d.ts +2 -1
  199. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  200. package/dist/extensions/codemode/tool.js +33 -8
  201. package/dist/extensions/codemode/tool.js.map +1 -1
  202. package/dist/extensions/llama/ui.d.ts.map +1 -1
  203. package/dist/extensions/llama/ui.js +16 -4
  204. package/dist/extensions/llama/ui.js.map +1 -1
  205. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  206. package/dist/extensions/mcp/cli.js +34 -8
  207. package/dist/extensions/mcp/cli.js.map +1 -1
  208. package/dist/extensions/mcp/oauth.d.ts +1 -1
  209. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  210. package/dist/extensions/mcp/oauth.js +36 -13
  211. package/dist/extensions/mcp/oauth.js.map +1 -1
  212. package/dist/extensions/mcp/ui.d.ts +1 -0
  213. package/dist/extensions/mcp/ui.d.ts.map +1 -1
  214. package/dist/extensions/mcp/ui.js +33 -24
  215. package/dist/extensions/mcp/ui.js.map +1 -1
  216. package/dist/extensions/tool-search/tool.d.ts +21 -6
  217. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  218. package/dist/extensions/tool-search/tool.js +104 -36
  219. package/dist/extensions/tool-search/tool.js.map +1 -1
  220. package/dist/index.d.ts +2 -2
  221. package/dist/index.d.ts.map +1 -1
  222. package/dist/index.js.map +1 -1
  223. package/dist/main.d.ts.map +1 -1
  224. package/dist/main.js +15 -8
  225. package/dist/main.js.map +1 -1
  226. package/dist/modes/interactive/components/assistant-message.d.ts +4 -1
  227. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  228. package/dist/modes/interactive/components/assistant-message.js +45 -21
  229. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  230. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  231. package/dist/modes/interactive/components/config-selector.js +4 -17
  232. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  233. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  234. package/dist/modes/interactive/components/custom-editor.js +7 -0
  235. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  236. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  237. package/dist/modes/interactive/components/custom-entry.js +2 -1
  238. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  239. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  240. package/dist/modes/interactive/components/custom-message.js +2 -1
  241. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  242. package/dist/modes/interactive/components/extension-editor.d.ts +2 -0
  243. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  244. package/dist/modes/interactive/components/extension-editor.js +4 -0
  245. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  246. package/dist/modes/interactive/components/login-dialog.d.ts +5 -0
  247. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  248. package/dist/modes/interactive/components/login-dialog.js +105 -10
  249. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  250. package/dist/modes/interactive/components/markdown-transform.d.ts +2 -1
  251. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
  252. package/dist/modes/interactive/components/markdown-transform.js +3 -2
  253. package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
  254. package/dist/modes/interactive/components/model-selector.d.ts +1 -0
  255. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  256. package/dist/modes/interactive/components/model-selector.js +17 -6
  257. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  258. package/dist/modes/interactive/components/oauth-selector.d.ts +1 -0
  259. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  260. package/dist/modes/interactive/components/oauth-selector.js +13 -4
  261. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  262. package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -0
  263. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  264. package/dist/modes/interactive/components/scoped-models-selector.js +14 -3
  265. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  266. package/dist/modes/interactive/components/session-selector-search.d.ts +4 -0
  267. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  268. package/dist/modes/interactive/components/session-selector-search.js +86 -22
  269. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  270. package/dist/modes/interactive/components/session-selector.d.ts +2 -1
  271. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  272. package/dist/modes/interactive/components/session-selector.js +17 -25
  273. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  274. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  275. package/dist/modes/interactive/components/settings-submenu.js +2 -0
  276. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  277. package/dist/modes/interactive/components/tool-execution.d.ts +6 -0
  278. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  279. package/dist/modes/interactive/components/tool-execution.js +14 -2
  280. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  281. package/dist/modes/interactive/components/tree-selector.d.ts +1 -0
  282. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  283. package/dist/modes/interactive/components/tree-selector.js +5 -6
  284. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  285. package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
  286. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  287. package/dist/modes/interactive/components/user-message-selector.js +9 -1
  288. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  289. package/dist/modes/interactive/components/user-message.d.ts +3 -1
  290. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  291. package/dist/modes/interactive/components/user-message.js +6 -2
  292. package/dist/modes/interactive/components/user-message.js.map +1 -1
  293. package/dist/modes/interactive/external-editor.d.ts +1 -0
  294. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  295. package/dist/modes/interactive/external-editor.js +16 -4
  296. package/dist/modes/interactive/external-editor.js.map +1 -1
  297. package/dist/modes/interactive/interactive-mode.d.ts +5 -0
  298. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  299. package/dist/modes/interactive/interactive-mode.js +154 -45
  300. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  301. package/dist/modes/interactive/model-search.d.ts +10 -0
  302. package/dist/modes/interactive/model-search.d.ts.map +1 -1
  303. package/dist/modes/interactive/model-search.js +21 -0
  304. package/dist/modes/interactive/model-search.js.map +1 -1
  305. package/dist/modes/interactive/theme/theme.d.ts +10 -0
  306. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  307. package/dist/modes/interactive/theme/theme.js +31 -23
  308. package/dist/modes/interactive/theme/theme.js.map +1 -1
  309. package/dist/package-manager-cli.d.ts.map +1 -1
  310. package/dist/package-manager-cli.js +55 -4
  311. package/dist/package-manager-cli.js.map +1 -1
  312. package/dist/utils/ansi.d.ts.map +1 -1
  313. package/dist/utils/ansi.js +5 -2
  314. package/dist/utils/ansi.js.map +1 -1
  315. package/dist/utils/clipboard-command.d.ts.map +1 -1
  316. package/dist/utils/clipboard-command.js +4 -0
  317. package/dist/utils/clipboard-command.js.map +1 -1
  318. package/dist/utils/git.d.ts +1 -1
  319. package/dist/utils/git.d.ts.map +1 -1
  320. package/dist/utils/git.js.map +1 -1
  321. package/dist/utils/image-resize-core.d.ts.map +1 -1
  322. package/dist/utils/image-resize-core.js +5 -3
  323. package/dist/utils/image-resize-core.js.map +1 -1
  324. package/dist/utils/open-browser.d.ts.map +1 -1
  325. package/dist/utils/open-browser.js +4 -1
  326. package/dist/utils/open-browser.js.map +1 -1
  327. package/dist/utils/paths.d.ts +17 -0
  328. package/dist/utils/paths.d.ts.map +1 -1
  329. package/dist/utils/paths.js +42 -1
  330. package/dist/utils/paths.js.map +1 -1
  331. package/dist/utils/shell.d.ts.map +1 -1
  332. package/dist/utils/shell.js +14 -0
  333. package/dist/utils/shell.js.map +1 -1
  334. package/dist/utils/syntax-highlight.d.ts +5 -0
  335. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  336. package/dist/utils/syntax-highlight.js +7 -0
  337. package/dist/utils/syntax-highlight.js.map +1 -1
  338. package/dist/utils/tools-manager.d.ts.map +1 -1
  339. package/dist/utils/tools-manager.js +30 -35
  340. package/dist/utils/tools-manager.js.map +1 -1
  341. package/docs/cli.md +21 -11
  342. package/docs/custom-provider.md +2 -0
  343. package/docs/environment-variables.md +2 -0
  344. package/docs/extensions.md +3172 -225
  345. package/docs/keybindings.md +1 -1
  346. package/docs/llama-cpp.md +23 -12
  347. package/docs/mcp.md +6 -4
  348. package/docs/message-types.md +1 -1
  349. package/docs/packages.md +24 -0
  350. package/docs/quickstart.md +7 -3
  351. package/docs/sessions.md +11 -3
  352. package/docs/settings.md +5 -4
  353. package/docs/slash-commands.md +3 -2
  354. package/docs/terminal-setup.md +3 -1
  355. package/docs/tmux.md +6 -0
  356. package/docs/tui.md +2 -0
  357. package/docs/windows.md +27 -0
  358. package/examples/extensions/README.md +2 -1
  359. package/examples/extensions/custom-provider-anthropic/index.ts +27 -31
  360. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  361. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  362. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  363. package/examples/extensions/debug-provider.ts +2 -2
  364. package/examples/extensions/gondolin/package-lock.json +19 -29
  365. package/examples/extensions/gondolin/package.json +2 -2
  366. package/examples/extensions/preset.ts +2 -0
  367. package/examples/extensions/reload-runtime.ts +17 -5
  368. package/examples/extensions/todo.ts +7 -0
  369. package/examples/extensions/tools.ts +2 -0
  370. package/examples/extensions/with-deps/package-lock.json +2 -2
  371. package/examples/extensions/with-deps/package.json +1 -1
  372. package/examples/tsconfig.json +180 -0
  373. package/package.json +12 -13
  374. package/schemas/models.schema.json +36 -36
  375. package/schemas/settings.schema.json +17 -0
  376. package/dist/bundle/chunks/anthropic-messages-5FHV3XZG.js +0 -6
  377. package/dist/bundle/chunks/azure-openai-responses-KLTRI2FU.js +0 -2
  378. package/dist/bundle/chunks/chunk-3V45WARH.js +0 -7
  379. package/dist/bundle/chunks/chunk-4GGCU36O.js +0 -11
  380. package/dist/bundle/chunks/chunk-A4UDE7GM.js +0 -1227
  381. package/dist/bundle/chunks/chunk-BSS6T6KQ.js +0 -2
  382. package/dist/bundle/chunks/chunk-EGE5YVUM.js +0 -82
  383. package/dist/bundle/chunks/chunk-H76KZMOI.js +0 -2
  384. package/dist/bundle/chunks/chunk-INGZIYBC.js +0 -4
  385. package/dist/bundle/chunks/chunk-NFLURVK3.js +0 -2
  386. package/dist/bundle/chunks/chunk-T726RZZU.js +0 -131
  387. package/dist/bundle/chunks/chunk-TEPMHNKQ.js +0 -2
  388. package/dist/bundle/chunks/mistral-conversations-WCAJTBXO.js +0 -5
  389. package/dist/bundle/chunks/openai-completions-27RKPL37.js +0 -7
  390. package/dist/bundle/chunks/pi-messages-S7RKCD5K.js +0 -8
  391. package/dist/bundle/chunks/virtual-modules-S75NU3SZ.js +0 -2
  392. package/examples/extensions/sandbox/index.ts +0 -321
  393. package/examples/extensions/sandbox/package-lock.json +0 -92
  394. package/examples/extensions/sandbox/package.json +0 -19
@@ -8,8 +8,18 @@ export declare function withSessionFileUsage<T>(path: string, operation: () => T
8
8
  export declare function markSessionMoved(path: string, destination: string): void;
9
9
  /** Roll back a relocation marker when the source was not removed. */
10
10
  export declare function unmarkSessionMoved(path: string): void;
11
- /** Reject live users and, on Linux, untracked Pi processes. Caller must hold the ownership gate. */
11
+ /** Refuse live users of this file and, on Linux, untracked Pi processes. Caller must hold the ownership gate. */
12
12
  export declare function assertSessionUnused(path: string): void;
13
+ /**
14
+ * Refuse a delete where the harm is proven, and allow an override where it is only possible. A live
15
+ * process that registered this file always blocks it, with or without the override: deleting a session
16
+ * out from under its writer is the same loss as forking its history. An untracked Pi cannot be
17
+ * inspected at all, so it blocks too, but `PI_ALLOW_SHARED_SESSION` clears that case. Without the
18
+ * override, one unrelated official Pi on Linux would make session cleanup impossible, and the worst
19
+ * outcome it prevents is a process writing to a removed file rather than lost conversation.
20
+ * Caller must hold the ownership gate.
21
+ */
22
+ export declare function assertSessionDeletable(path: string): void;
13
23
  /**
14
24
  * Refuse resuming a session a live Pi already holds. Appends carry the writer's own leaf, so two
15
25
  * writers on one file fork its history and a later read follows the branch that appended last,
@@ -1 +1 @@
1
- {"version":3,"file":"session-ownership.d.ts","sourceRoot":"","sources":["../../src/core/session-ownership.ts"],"names":[],"mappings":"AAyBA,6FAA6F;AAC7F,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,CAiCjE;AAED,2FAA2F;AAC3F,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CA2BnG;AAED,0FAA0F;AAC1F,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,CAO3E;AAWD,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAExE;AAED,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAErD;AAuCD,oGAAoG;AACpG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CA8BtD;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAStE"}
1
+ {"version":3,"file":"session-ownership.d.ts","sourceRoot":"","sources":["../../src/core/session-ownership.ts"],"names":[],"mappings":"AAyBA,6FAA6F;AAC7F,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,CAiCjE;AAED,2FAA2F;AAC3F,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CA2BnG;AAED,0FAA0F;AAC1F,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,CAO3E;AAWD,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAExE;AAED,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAErD;AAuCD,iHAAiH;AACjH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CActD;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAUzD;AA+BD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAStE"}
@@ -138,19 +138,49 @@ function processIsLive(pid) {
138
138
  return error.code !== "ESRCH";
139
139
  }
140
140
  }
141
- /** Reject live users and, on Linux, untracked Pi processes. Caller must hold the ownership gate. */
141
+ /** Refuse live users of this file and, on Linux, untracked Pi processes. Caller must hold the ownership gate. */
142
142
  export function assertSessionUnused(path) {
143
143
  const canonical = canonicalSessionPath(path);
144
144
  const owners = collectLiveOwners();
145
- for (const owner of owners) {
146
- if (owner.sessions.includes(canonical))
147
- throw new Error(`Session is open in process ${owner.pid}. Close it before moving.`);
148
- }
145
+ refuseWhileOpen(owners, canonical, "moving");
146
+ // Relocation splits a session across two paths if any process keeps the old one open, including
147
+ // a process that cannot be inspected, so an untracked Pi blocks a move with no override.
149
148
  // Detecting Pi processes that predate ownership requires scanning the process table, and the
150
149
  // portable process list is not reliable enough to do so outside Linux. Those platforms only
151
150
  // enforce ownership registered by cooperating Pi instances.
152
- if (process.platform !== "linux")
151
+ const untracked = findUntrackedPiPid(owners);
152
+ if (untracked !== undefined)
153
+ throw new Error(`Pi process ${untracked} does not report session ownership. Close older Pi instances before moving.`);
154
+ }
155
+ /**
156
+ * Refuse a delete where the harm is proven, and allow an override where it is only possible. A live
157
+ * process that registered this file always blocks it, with or without the override: deleting a session
158
+ * out from under its writer is the same loss as forking its history. An untracked Pi cannot be
159
+ * inspected at all, so it blocks too, but `PI_ALLOW_SHARED_SESSION` clears that case. Without the
160
+ * override, one unrelated official Pi on Linux would make session cleanup impossible, and the worst
161
+ * outcome it prevents is a process writing to a removed file rather than lost conversation.
162
+ * Caller must hold the ownership gate.
163
+ */
164
+ export function assertSessionDeletable(path) {
165
+ const canonical = canonicalSessionPath(path);
166
+ const owners = collectLiveOwners();
167
+ refuseWhileOpen(owners, canonical, "deleting");
168
+ if (process.env.PI_ALLOW_SHARED_SESSION)
153
169
  return;
170
+ const untracked = findUntrackedPiPid(owners);
171
+ if (untracked !== undefined)
172
+ throw new Error(`Pi process ${untracked} does not report session ownership, so it may hold this session. Close it, or set PI_ALLOW_SHARED_SESSION to delete anyway.`);
173
+ }
174
+ function refuseWhileOpen(owners, canonical, purpose) {
175
+ for (const owner of owners) {
176
+ if (owner.sessions.includes(canonical))
177
+ throw new Error(`Session is open in process ${owner.pid}. Close it before ${purpose}.`);
178
+ }
179
+ }
180
+ /** First Pi process of this user that runs without an ownership record, if any. Linux only. */
181
+ function findUntrackedPiPid(owners) {
182
+ if (process.platform !== "linux")
183
+ return undefined;
154
184
  const registered = new Set(owners.map((owner) => owner.pid));
155
185
  const processes = execFileSync("ps", ["-u", String(process.getuid()), "-o", "pid=,comm=,args="], {
156
186
  encoding: "utf8",
@@ -165,8 +195,9 @@ export function assertSessionUnused(path) {
165
195
  const isPi = match[2] === "pi" ||
166
196
  /(?:^|\s)\S*(?:pi-coding-agent\/(?:dist|src)\/cli\.(?:js|ts)|\/pi\/packages\/coding-agent\/src\/cli\.ts)(?:\s|$)/.test(match[3]);
167
197
  if (isPi)
168
- throw new Error(`Pi process ${pid} does not report session ownership. Close older Pi instances before moving.`);
198
+ return pid;
169
199
  }
200
+ return undefined;
170
201
  }
171
202
  /**
172
203
  * Refuse resuming a session a live Pi already holds. Appends carry the writer's own leaf, so two
@@ -1 +1 @@
1
- {"version":3,"file":"session-ownership.js","sourceRoot":"","sources":["../../src/core/session-ownership.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,SAAS,EACT,UAAU,EACV,aAAa,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,qBAAqB,OAAO,CAAC,MAAM,EAAE,EAAE,IAAI,MAAM,EAAE,CAAC,CAAC;AACjF,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;AAC3C,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB,6FAA6F;AAC7F,MAAM,UAAU,wBAAwB,CAAI,SAAkB;IAC7D,IAAI,WAAW;QAAE,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACtG,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAClD,uFAAuF;IACvF,gFAAgF;IAChF,MAAM,IAAI,GAAG,SAAS,CAA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;YACvB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAC9B,CAAC;YACF,MAAM,IAAI,KAAK,CAAC,qCAAqC,IAAI,EAAE,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC3B,yFAAyF;YACzF,mCAAmC;YACnC,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;gBACnD,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;gBACpC,SAAS;YACV,CAAC;QACF,CAAC;aAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,wFAAwF;YACxF,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;YACpC,SAAS;QACV,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["// Coordinate session users and relocation within one local user account.\n\nimport { execFileSync } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport {\n\texistsSync,\n\tlstatSync,\n\tmkdirSync,\n\treaddirSync,\n\treadFileSync,\n\trenameSync,\n\trmdirSync,\n\tunlinkSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { canonicalizePath } from \"../utils/paths.ts\";\n\nconst root = join(tmpdir(), `pi-session-owners-${process.getuid?.() ?? \"user\"}`);\nconst sessions = new Map<string, number>();\nconst gateWait = new Int32Array(new SharedArrayBuffer(4));\nconst gateTimeoutMs = 2000;\nlet holdingGate = false;\n\n/** Serialize registration and moves; an abandoned gate fails closed rather than guessing. */\nexport function withSessionOwnershipGate<T>(operation: () => T): T {\n\tif (holdingGate) throw new Error(\"Session ownership operations cannot acquire the gate recursively.\");\n\tmkdirSync(root, { recursive: true, mode: 0o700 });\n\t// POSIX mode bits are only meaningful where they are reported. On Windows the per-user\n\t// temporary directory is the isolation boundary and lstat reports a fixed mode.\n\tconst info = lstatSync(root);\n\tconst uid = process.getuid?.();\n\tif (!info.isDirectory() || (uid !== undefined && (info.uid !== uid || (info.mode & 0o077) !== 0))) {\n\t\tthrow new Error(`Unsafe session ownership directory: ${root}`);\n\t}\n\tconst gate = join(root, \"gate\");\n\tconst deadline = performance.now() + gateTimeoutMs;\n\tfor (;;) {\n\t\ttry {\n\t\t\tmkdirSync(gate, { mode: 0o700 });\n\t\t\tbreak;\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n\t\t\tconst remaining = deadline - performance.now();\n\t\t\tif (remaining <= 0) {\n\t\t\t\tthrow new Error(`Session ownership is busy. Retry later. If a process crashed, inspect ${gate}.`);\n\t\t\t}\n\t\t\t// SessionManager's API is synchronous. Wait only for other processes, never for work on this event loop.\n\t\t\tAtomics.wait(gateWait, 0, 0, Math.min(25, remaining));\n\t\t}\n\t}\n\tholdingGate = true;\n\ttry {\n\t\treturn operation();\n\t} finally {\n\t\tholdingGate = false;\n\t\trmdirSync(gate);\n\t}\n}\n\n/** Register a manager's session before reading it, releasing its previous registration. */\nexport function changeSessionOwnership(previous: string | undefined, next: string | undefined): void {\n\tif (previous === next) return;\n\twithSessionOwnershipGate(() => {\n\t\tif (next && !existsSync(next) && existsSync(movedMarker(next)))\n\t\t\tthrow new Error(\"This session has moved. Refresh the session picker.\");\n\t\tconst updated = new Map(sessions);\n\t\tif (previous) {\n\t\t\tconst path = canonicalSessionPath(previous);\n\t\t\tconst count = updated.get(path) ?? 0;\n\t\t\tif (count <= 1) updated.delete(path);\n\t\t\telse updated.set(path, count - 1);\n\t\t}\n\t\tif (next) {\n\t\t\tconst path = canonicalSessionPath(next);\n\t\t\tupdated.set(path, (updated.get(path) ?? 0) + 1);\n\t\t}\n\t\t// A null start means the platform cannot distinguish a PID from a later process that reused it.\n\t\tconst temporary = join(root, `${process.pid}.tmp`);\n\t\twriteFileSync(\n\t\t\ttemporary,\n\t\t\tJSON.stringify({ start: processIdentity(process.pid) ?? null, sessions: [...updated.keys()] }),\n\t\t\t{ mode: 0o600 },\n\t\t);\n\t\trenameSync(temporary, join(root, `${process.pid}.json`));\n\t\tsessions.clear();\n\t\tfor (const [path, count] of updated) sessions.set(path, count);\n\t});\n}\n\n/** Hold a counted session reference during a synchronous read/copy/mutation operation. */\nexport function withSessionFileUsage<T>(path: string, operation: () => T): T {\n\tchangeSessionOwnership(undefined, path);\n\ttry {\n\t\treturn operation();\n\t} finally {\n\t\tchangeSessionOwnership(path, undefined);\n\t}\n}\n\nfunction canonicalSessionPath(path: string): string {\n\tconst absolute = resolve(path);\n\treturn canonicalizePath(join(canonicalizePath(dirname(absolute)), basename(absolute)));\n}\n\nfunction movedMarker(path: string): string {\n\treturn join(root, `${createHash(\"sha256\").update(canonicalSessionPath(path)).digest(\"hex\")}.moved`);\n}\n\n/** Prevent a concurrent opener from recreating the old path after relocation. */\nexport function markSessionMoved(path: string, destination: string): void {\n\twriteFileSync(movedMarker(path), destination, { mode: 0o600 });\n}\n\n/** Roll back a relocation marker when the source was not removed. */\nexport function unmarkSessionMoved(path: string): void {\n\tunlinkSync(movedMarker(path));\n}\n\n// Linux only: stat field 22 distinguishes a PID from a later process that reused it.\n// comm can contain spaces and parentheses, so fields are read after the last ')'.\nfunction linuxProcessStart(pid: number): string {\n\tconst stat = readFileSync(`/proc/${pid}/stat`, \"utf8\");\n\treturn stat.slice(stat.lastIndexOf(\")\") + 2).split(\" \")[19];\n}\n\nconst processIdentity = process.platform === \"linux\" ? linuxProcessStart : () => undefined;\n\n/**\n * Drop a record whose owner is provably gone. This is cleanup only: a failed removal must never\n * affect the safety decision, because Windows can report EPERM or EBUSY for a file another\n * process still has open.\n */\nfunction removeStaleRecord(path: string): void {\n\ttry {\n\t\tunlinkSync(path);\n\t} catch {\n\t\t// The next move retries the cleanup. A surviving stale record only ever causes a refusal.\n\t}\n}\n\n/**\n * Report whether a recorded owner process is still running. Anything other than a confirmed\n * absence counts as running, including a permission error, so an uncertain check never allows\n * the operation. On non-Linux platforms a reused PID is indistinguishable and also counts as\n * running, which can refuse an operation that would have been safe.\n */\nfunction processIsLive(pid: number): boolean {\n\ttry {\n\t\tprocess.kill(pid, 0);\n\t\treturn true;\n\t} catch (error) {\n\t\treturn (error as NodeJS.ErrnoException).code !== \"ESRCH\";\n\t}\n}\n\n/** Reject live users and, on Linux, untracked Pi processes. Caller must hold the ownership gate. */\nexport function assertSessionUnused(path: string): void {\n\tconst canonical = canonicalSessionPath(path);\n\tconst owners = collectLiveOwners();\n\tfor (const owner of owners) {\n\t\tif (owner.sessions.includes(canonical))\n\t\t\tthrow new Error(`Session is open in process ${owner.pid}. Close it before moving.`);\n\t}\n\t// Detecting Pi processes that predate ownership requires scanning the process table, and the\n\t// portable process list is not reliable enough to do so outside Linux. Those platforms only\n\t// enforce ownership registered by cooperating Pi instances.\n\tif (process.platform !== \"linux\") return;\n\tconst registered = new Set(owners.map((owner) => owner.pid));\n\tconst processes = execFileSync(\"ps\", [\"-u\", String(process.getuid!()), \"-o\", \"pid=,comm=,args=\"], {\n\t\tencoding: \"utf8\",\n\t});\n\tfor (const line of processes.split(\"\\n\")) {\n\t\tconst match = line.trim().match(/^(\\d+)\\s+(\\S+)\\s+(.*)$/);\n\t\tif (!match) continue;\n\t\tconst pid = Number(match[1]);\n\t\tif (pid === process.pid || registered.has(pid)) continue;\n\t\tconst isPi =\n\t\t\tmatch[2] === \"pi\" ||\n\t\t\t/(?:^|\\s)\\S*(?:pi-coding-agent\\/(?:dist|src)\\/cli\\.(?:js|ts)|\\/pi\\/packages\\/coding-agent\\/src\\/cli\\.ts)(?:\\s|$)/.test(\n\t\t\t\tmatch[3],\n\t\t\t);\n\t\tif (isPi)\n\t\t\tthrow new Error(\n\t\t\t\t`Pi process ${pid} does not report session ownership. Close older Pi instances before moving.`,\n\t\t\t);\n\t}\n}\n\n/**\n * Refuse resuming a session a live Pi already holds. Appends carry the writer's own leaf, so two\n * writers on one file fork its history and a later read follows the branch that appended last,\n * hiding the other one without warning. This process's own registrations never refuse, so\n * re-selecting the current session stays a no-op and unrelated sessions are unaffected. Returns\n * the message instead of throwing so the interactive picker can refuse without ending its session.\n * Set PI_ALLOW_SHARED_SESSION to resume anyway.\n */\nexport function getSessionOpenRefusal(path: string): string | undefined {\n\tif (process.env.PI_ALLOW_SHARED_SESSION) return undefined;\n\tconst canonical = canonicalSessionPath(path);\n\tfor (const owner of collectLiveOwners()) {\n\t\tif (owner.pid === process.pid) continue;\n\t\tif (owner.sessions.includes(canonical))\n\t\t\treturn `This session is open in process ${owner.pid}. Close that Pi first, or set PI_ALLOW_SHARED_SESSION to resume anyway. Two writers on one session fork its history: only the branch written last stays visible.`;\n\t}\n\treturn undefined;\n}\n\ninterface LiveOwner {\n\tpid: number;\n\tsessions: unknown[];\n}\n\n/**\n * Owners that a record claims are running, after records proven stale are dropped. Removal is\n * idempotent and its failure is ignored, so this is safe with and without the ownership gate.\n * Records are written only by Pi in a directory only this user can read.\n */\nfunction collectLiveOwners(): LiveOwner[] {\n\tconst owners: LiveOwner[] = [];\n\tfor (const file of readdirSync(root)) {\n\t\tif (!/^\\d+\\.json$/.test(file)) continue;\n\t\tconst pid = Number(file.split(\".\")[0]);\n\t\tlet start: string | undefined;\n\t\ttry {\n\t\t\tstart = processIdentity(pid);\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n\t\t\tremoveStaleRecord(join(root, file));\n\t\t\tcontinue;\n\t\t}\n\t\tconst record: unknown = JSON.parse(readFileSync(join(root, file), \"utf8\"));\n\t\tif (\n\t\t\t!record ||\n\t\t\ttypeof record !== \"object\" ||\n\t\t\t!(\"start\" in record) ||\n\t\t\t!(\"sessions\" in record) ||\n\t\t\t!Array.isArray(record.sessions)\n\t\t) {\n\t\t\tthrow new Error(`Invalid session ownership record: ${file}`);\n\t\t}\n\t\tif (record.start !== null) {\n\t\t\t// Linux records carry a start identity. A mismatch means another process reused the PID,\n\t\t\t// so the record is provably stale.\n\t\t\tif (start === undefined || record.start !== start) {\n\t\t\t\tremoveStaleRecord(join(root, file));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (!processIsLive(pid)) {\n\t\t\t// Without a start identity, only a PID the OS confirms is gone proves the owner exited.\n\t\t\tremoveStaleRecord(join(root, file));\n\t\t\tcontinue;\n\t\t}\n\t\towners.push({ pid, sessions: record.sessions });\n\t}\n\treturn owners;\n}\n"]}
1
+ {"version":3,"file":"session-ownership.js","sourceRoot":"","sources":["../../src/core/session-ownership.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,SAAS,EACT,UAAU,EACV,aAAa,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,qBAAqB,OAAO,CAAC,MAAM,EAAE,EAAE,IAAI,MAAM,EAAE,CAAC,CAAC;AACjF,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;AAC3C,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1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,CAAC,EAC9B,CAAC;YACF,MAAM,IAAI,KAAK,CAAC,qCAAqC,IAAI,EAAE,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC3B,yFAAyF;YACzF,mCAAmC;YACnC,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;gBACnD,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;gBACpC,SAAS;YACV,CAAC;QACF,CAAC;aAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,wFAAwF;YACxF,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;YACpC,SAAS;QACV,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["// Coordinate session users and relocation within one local user account.\n\nimport { execFileSync } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport {\n\texistsSync,\n\tlstatSync,\n\tmkdirSync,\n\treaddirSync,\n\treadFileSync,\n\trenameSync,\n\trmdirSync,\n\tunlinkSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { canonicalizePath } from \"../utils/paths.ts\";\n\nconst root = join(tmpdir(), `pi-session-owners-${process.getuid?.() ?? \"user\"}`);\nconst sessions = new Map<string, number>();\nconst gateWait = new Int32Array(new SharedArrayBuffer(4));\nconst gateTimeoutMs = 2000;\nlet holdingGate = false;\n\n/** Serialize registration and moves; an abandoned gate fails closed rather than guessing. */\nexport function withSessionOwnershipGate<T>(operation: () => T): T {\n\tif (holdingGate) throw new Error(\"Session ownership operations cannot acquire the gate recursively.\");\n\tmkdirSync(root, { recursive: true, mode: 0o700 });\n\t// POSIX mode bits are only meaningful where they are reported. On Windows the per-user\n\t// temporary directory is the isolation boundary and lstat reports a fixed mode.\n\tconst info = lstatSync(root);\n\tconst uid = process.getuid?.();\n\tif (!info.isDirectory() || (uid !== undefined && (info.uid !== uid || (info.mode & 0o077) !== 0))) {\n\t\tthrow new Error(`Unsafe session ownership directory: ${root}`);\n\t}\n\tconst gate = join(root, \"gate\");\n\tconst deadline = performance.now() + gateTimeoutMs;\n\tfor (;;) {\n\t\ttry {\n\t\t\tmkdirSync(gate, { mode: 0o700 });\n\t\t\tbreak;\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n\t\t\tconst remaining = deadline - performance.now();\n\t\t\tif (remaining <= 0) {\n\t\t\t\tthrow new Error(`Session ownership is busy. Retry later. If a process crashed, inspect ${gate}.`);\n\t\t\t}\n\t\t\t// SessionManager's API is synchronous. Wait only for other processes, never for work on this event loop.\n\t\t\tAtomics.wait(gateWait, 0, 0, Math.min(25, remaining));\n\t\t}\n\t}\n\tholdingGate = true;\n\ttry {\n\t\treturn operation();\n\t} finally {\n\t\tholdingGate = false;\n\t\trmdirSync(gate);\n\t}\n}\n\n/** Register a manager's session before reading it, releasing its previous registration. */\nexport function changeSessionOwnership(previous: string | undefined, next: string | undefined): void {\n\tif (previous === next) return;\n\twithSessionOwnershipGate(() => {\n\t\tif (next && !existsSync(next) && existsSync(movedMarker(next)))\n\t\t\tthrow new Error(\"This session has moved. Refresh the session picker.\");\n\t\tconst updated = new Map(sessions);\n\t\tif (previous) {\n\t\t\tconst path = canonicalSessionPath(previous);\n\t\t\tconst count = updated.get(path) ?? 0;\n\t\t\tif (count <= 1) updated.delete(path);\n\t\t\telse updated.set(path, count - 1);\n\t\t}\n\t\tif (next) {\n\t\t\tconst path = canonicalSessionPath(next);\n\t\t\tupdated.set(path, (updated.get(path) ?? 0) + 1);\n\t\t}\n\t\t// A null start means the platform cannot distinguish a PID from a later process that reused it.\n\t\tconst temporary = join(root, `${process.pid}.tmp`);\n\t\twriteFileSync(\n\t\t\ttemporary,\n\t\t\tJSON.stringify({ start: processIdentity(process.pid) ?? null, sessions: [...updated.keys()] }),\n\t\t\t{ mode: 0o600 },\n\t\t);\n\t\trenameSync(temporary, join(root, `${process.pid}.json`));\n\t\tsessions.clear();\n\t\tfor (const [path, count] of updated) sessions.set(path, count);\n\t});\n}\n\n/** Hold a counted session reference during a synchronous read/copy/mutation operation. */\nexport function withSessionFileUsage<T>(path: string, operation: () => T): T {\n\tchangeSessionOwnership(undefined, path);\n\ttry {\n\t\treturn operation();\n\t} finally {\n\t\tchangeSessionOwnership(path, undefined);\n\t}\n}\n\nfunction canonicalSessionPath(path: string): string {\n\tconst absolute = resolve(path);\n\treturn canonicalizePath(join(canonicalizePath(dirname(absolute)), basename(absolute)));\n}\n\nfunction movedMarker(path: string): string {\n\treturn join(root, `${createHash(\"sha256\").update(canonicalSessionPath(path)).digest(\"hex\")}.moved`);\n}\n\n/** Prevent a concurrent opener from recreating the old path after relocation. */\nexport function markSessionMoved(path: string, destination: string): void {\n\twriteFileSync(movedMarker(path), destination, { mode: 0o600 });\n}\n\n/** Roll back a relocation marker when the source was not removed. */\nexport function unmarkSessionMoved(path: string): void {\n\tunlinkSync(movedMarker(path));\n}\n\n// Linux only: stat field 22 distinguishes a PID from a later process that reused it.\n// comm can contain spaces and parentheses, so fields are read after the last ')'.\nfunction linuxProcessStart(pid: number): string {\n\tconst stat = readFileSync(`/proc/${pid}/stat`, \"utf8\");\n\treturn stat.slice(stat.lastIndexOf(\")\") + 2).split(\" \")[19];\n}\n\nconst processIdentity = process.platform === \"linux\" ? linuxProcessStart : () => undefined;\n\n/**\n * Drop a record whose owner is provably gone. This is cleanup only: a failed removal must never\n * affect the safety decision, because Windows can report EPERM or EBUSY for a file another\n * process still has open.\n */\nfunction removeStaleRecord(path: string): void {\n\ttry {\n\t\tunlinkSync(path);\n\t} catch {\n\t\t// The next move retries the cleanup. A surviving stale record only ever causes a refusal.\n\t}\n}\n\n/**\n * Report whether a recorded owner process is still running. Anything other than a confirmed\n * absence counts as running, including a permission error, so an uncertain check never allows\n * the operation. On non-Linux platforms a reused PID is indistinguishable and also counts as\n * running, which can refuse an operation that would have been safe.\n */\nfunction processIsLive(pid: number): boolean {\n\ttry {\n\t\tprocess.kill(pid, 0);\n\t\treturn true;\n\t} catch (error) {\n\t\treturn (error as NodeJS.ErrnoException).code !== \"ESRCH\";\n\t}\n}\n\n/** Refuse live users of this file and, on Linux, untracked Pi processes. Caller must hold the ownership gate. */\nexport function assertSessionUnused(path: string): void {\n\tconst canonical = canonicalSessionPath(path);\n\tconst owners = collectLiveOwners();\n\trefuseWhileOpen(owners, canonical, \"moving\");\n\t// Relocation splits a session across two paths if any process keeps the old one open, including\n\t// a process that cannot be inspected, so an untracked Pi blocks a move with no override.\n\t// Detecting Pi processes that predate ownership requires scanning the process table, and the\n\t// portable process list is not reliable enough to do so outside Linux. Those platforms only\n\t// enforce ownership registered by cooperating Pi instances.\n\tconst untracked = findUntrackedPiPid(owners);\n\tif (untracked !== undefined)\n\t\tthrow new Error(\n\t\t\t`Pi process ${untracked} does not report session ownership. Close older Pi instances before moving.`,\n\t\t);\n}\n\n/**\n * Refuse a delete where the harm is proven, and allow an override where it is only possible. A live\n * process that registered this file always blocks it, with or without the override: deleting a session\n * out from under its writer is the same loss as forking its history. An untracked Pi cannot be\n * inspected at all, so it blocks too, but `PI_ALLOW_SHARED_SESSION` clears that case. Without the\n * override, one unrelated official Pi on Linux would make session cleanup impossible, and the worst\n * outcome it prevents is a process writing to a removed file rather than lost conversation.\n * Caller must hold the ownership gate.\n */\nexport function assertSessionDeletable(path: string): void {\n\tconst canonical = canonicalSessionPath(path);\n\tconst owners = collectLiveOwners();\n\trefuseWhileOpen(owners, canonical, \"deleting\");\n\tif (process.env.PI_ALLOW_SHARED_SESSION) return;\n\tconst untracked = findUntrackedPiPid(owners);\n\tif (untracked !== undefined)\n\t\tthrow new Error(\n\t\t\t`Pi process ${untracked} does not report session ownership, so it may hold this session. Close it, or set PI_ALLOW_SHARED_SESSION to delete anyway.`,\n\t\t);\n}\n\nfunction refuseWhileOpen(owners: LiveOwner[], canonical: string, purpose: string): void {\n\tfor (const owner of owners) {\n\t\tif (owner.sessions.includes(canonical))\n\t\t\tthrow new Error(`Session is open in process ${owner.pid}. Close it before ${purpose}.`);\n\t}\n}\n\n/** First Pi process of this user that runs without an ownership record, if any. Linux only. */\nfunction findUntrackedPiPid(owners: LiveOwner[]): number | undefined {\n\tif (process.platform !== \"linux\") return undefined;\n\tconst registered = new Set(owners.map((owner) => owner.pid));\n\tconst processes = execFileSync(\"ps\", [\"-u\", String(process.getuid!()), \"-o\", \"pid=,comm=,args=\"], {\n\t\tencoding: \"utf8\",\n\t});\n\tfor (const line of processes.split(\"\\n\")) {\n\t\tconst match = line.trim().match(/^(\\d+)\\s+(\\S+)\\s+(.*)$/);\n\t\tif (!match) continue;\n\t\tconst pid = Number(match[1]);\n\t\tif (pid === process.pid || registered.has(pid)) continue;\n\t\tconst isPi =\n\t\t\tmatch[2] === \"pi\" ||\n\t\t\t/(?:^|\\s)\\S*(?:pi-coding-agent\\/(?:dist|src)\\/cli\\.(?:js|ts)|\\/pi\\/packages\\/coding-agent\\/src\\/cli\\.ts)(?:\\s|$)/.test(\n\t\t\t\tmatch[3],\n\t\t\t);\n\t\tif (isPi) return pid;\n\t}\n\treturn undefined;\n}\n\n/**\n * Refuse resuming a session a live Pi already holds. Appends carry the writer's own leaf, so two\n * writers on one file fork its history and a later read follows the branch that appended last,\n * hiding the other one without warning. This process's own registrations never refuse, so\n * re-selecting the current session stays a no-op and unrelated sessions are unaffected. Returns\n * the message instead of throwing so the interactive picker can refuse without ending its session.\n * Set PI_ALLOW_SHARED_SESSION to resume anyway.\n */\nexport function getSessionOpenRefusal(path: string): string | undefined {\n\tif (process.env.PI_ALLOW_SHARED_SESSION) return undefined;\n\tconst canonical = canonicalSessionPath(path);\n\tfor (const owner of collectLiveOwners()) {\n\t\tif (owner.pid === process.pid) continue;\n\t\tif (owner.sessions.includes(canonical))\n\t\t\treturn `This session is open in process ${owner.pid}. Close that Pi first, or set PI_ALLOW_SHARED_SESSION to resume anyway. Two writers on one session fork its history: only the branch written last stays visible.`;\n\t}\n\treturn undefined;\n}\n\ninterface LiveOwner {\n\tpid: number;\n\tsessions: unknown[];\n}\n\n/**\n * Owners that a record claims are running, after records proven stale are dropped. Removal is\n * idempotent and its failure is ignored, so this is safe with and without the ownership gate.\n * Records are written only by Pi in a directory only this user can read.\n */\nfunction collectLiveOwners(): LiveOwner[] {\n\tconst owners: LiveOwner[] = [];\n\tfor (const file of readdirSync(root)) {\n\t\tif (!/^\\d+\\.json$/.test(file)) continue;\n\t\tconst pid = Number(file.split(\".\")[0]);\n\t\tlet start: string | undefined;\n\t\ttry {\n\t\t\tstart = processIdentity(pid);\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n\t\t\tremoveStaleRecord(join(root, file));\n\t\t\tcontinue;\n\t\t}\n\t\tconst record: unknown = JSON.parse(readFileSync(join(root, file), \"utf8\"));\n\t\tif (\n\t\t\t!record ||\n\t\t\ttypeof record !== \"object\" ||\n\t\t\t!(\"start\" in record) ||\n\t\t\t!(\"sessions\" in record) ||\n\t\t\t!Array.isArray(record.sessions)\n\t\t) {\n\t\t\tthrow new Error(`Invalid session ownership record: ${file}`);\n\t\t}\n\t\tif (record.start !== null) {\n\t\t\t// Linux records carry a start identity. A mismatch means another process reused the PID,\n\t\t\t// so the record is provably stale.\n\t\t\tif (start === undefined || record.start !== start) {\n\t\t\t\tremoveStaleRecord(join(root, file));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (!processIsLive(pid)) {\n\t\t\t// Without a start identity, only a PID the OS confirms is gone proves the owner exited.\n\t\t\tremoveStaleRecord(join(root, file));\n\t\t\tcontinue;\n\t\t}\n\t\towners.push({ pid, sessions: record.sessions });\n\t}\n\treturn owners;\n}\n"]}
@@ -98,6 +98,8 @@ export declare class SettingsManager {
98
98
  drainErrors(): SettingsError[];
99
99
  getLastChangelogVersion(): string | undefined;
100
100
  setLastChangelogVersion(version: string): void;
101
+ getExtensionChangelogVersion(key: string): string | undefined;
102
+ setExtensionChangelogVersion(key: string, version: string): void;
101
103
  getSessionDir(): string | undefined;
102
104
  getDefaultProvider(): string | undefined;
103
105
  getDefaultModel(): string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"settings-manager.d.ts","sourceRoot":"","sources":["../../src/core/settings-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAU1G,OAAO,KAAK,EACX,gBAAgB,EAEhB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,uBAAuB,EACvB,QAAQ,EACR,uBAAuB,EACvB,gBAAgB,EAChB,OAAO,EACP,eAAe,EACf,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACX,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,uBAAuB,EACvB,QAAQ,EACR,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,OAAO,EACP,eAAe,GACf,MAAM,sBAAsB,CAAC;AAC9B,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,uCAA8E,CAAC;AA8B/G,yEAAyE;AACzE,eAAO,MAAM,kBAA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;IAED,uBAAuB,IAAI,oBAAoB,CAG9C;IAED,uBAAuB,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAKxD;IAED,WAAW,IAAI,eAAe,CAE7B;IAED,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAI3C;CACD"}
1
+ {"version":3,"file":"settings-manager.d.ts","sourceRoot":"","sources":["../../src/core/settings-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAU1G,OAAO,KAAK,EACX,gBAAgB,EAEhB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,uBAAuB,EACvB,QAAQ,EACR,uBAAuB,EACvB,gBAAgB,EAChB,OAAO,EACP,eAAe,EACf,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACX,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,uBAAuB,EACvB,QAAQ,EACR,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,OAAO,EACP,eAAe,GACf,MAAM,sBAAsB,CAAC;AAC9B,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,uCAA8E,CAAC;AA8B/G,yEAAyE;AACzE,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAAsC,CAAC;AAEvF,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEtD;AAED;;;;GAIG;AACH,w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I,MAAM,CAE3B;IAED,uBAAuB,IAAI,oBAAoB,CAG9C;IAED,uBAAuB,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAKxD;IAED,WAAW,IAAI,eAAe,CAE7B;IAED,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAI3C;CACD"}
@@ -520,6 +520,17 @@ export class SettingsManager {
520
520
  this.markModified("lastChangelogVersion");
521
521
  this.save();
522
522
  }
523
+ getExtensionChangelogVersion(key) {
524
+ return this.settings.extensionChangelogVersions?.[key];
525
+ }
526
+ setExtensionChangelogVersion(key, version) {
527
+ this.globalSettings.extensionChangelogVersions = {
528
+ ...(this.globalSettings.extensionChangelogVersions ?? {}),
529
+ [key]: version,
530
+ };
531
+ this.markModified("extensionChangelogVersions", key);
532
+ this.save();
533
+ }
523
534
  getSessionDir() {
524
535
  const sessionDir = this.settings.sessionDir;
525
536
  return sessionDir ? normalizePath(sessionDir) : sessionDir;