@nervekit/desktop 0.40.2 → 0.41.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 (234) hide show
  1. package/README.md +5 -2
  2. package/THIRD-PARTY-LICENSES.txt +964 -4
  3. package/dist/bin.js +1 -0
  4. package/dist/{chunk-YJT4NXMV.js → chunk-2ICPO4UM.js} +5 -5
  5. package/dist/{chunk-EX63VKXY.js → chunk-3CZXUKLG.js} +1 -1
  6. package/dist/{chunk-KTGSBL6T.js → chunk-4OCDR4DU.js} +11 -11
  7. package/dist/{chunk-BNVMNV4O.js → chunk-62DQXVPO.js} +2 -2
  8. package/dist/{chunk-K2J2VZXO.js → chunk-6GUJQURI.js} +2 -2
  9. package/dist/{chunk-VBM7TD3X.js → chunk-6IHXVT5H.js} +1 -1
  10. package/dist/{chunk-KBNEZR7T.js → chunk-6ZS7TA6E.js} +2 -2
  11. package/dist/{chunk-O6U226AI.js → chunk-7FSH3ABG.js} +4 -4
  12. package/dist/{chunk-RPLBWENJ.js → chunk-7HGFEQSD.js} +5 -5
  13. package/dist/{chunk-XZYFB566.js → chunk-7RPHIJT3.js} +4 -4
  14. package/dist/{chunk-WRTA5G57.js → chunk-APY4TUR3.js} +188 -1
  15. package/dist/{chunk-YUO5V75X.js → chunk-BACYVEE6.js} +2 -2
  16. package/dist/{chunk-H2G55ZPG.js → chunk-BG2KGLIA.js} +2 -2
  17. package/dist/{chunk-7JQBECUL.js → chunk-BN5YDZUZ.js} +1205 -326
  18. package/dist/chunk-BUD4JHBZ.js +7017 -0
  19. package/dist/{chunk-TSV3PFU2.js → chunk-DDBE2VLT.js} +2 -2
  20. package/dist/{chunk-WJULIJOU.js → chunk-EF7ZZKA3.js} +3 -3
  21. package/dist/{chunk-HOCODVKL.js → chunk-EUT45AKW.js} +16 -16
  22. package/dist/{chunk-C6RO4LP3.js → chunk-FCAIYPDJ.js} +2 -2
  23. package/dist/{chunk-6FSDDGFZ.js → chunk-FZ557YWE.js} +47478 -52993
  24. package/dist/{chunk-VC6TX2Y2.js → chunk-HPINJGBO.js} +5 -5
  25. package/dist/{chunk-ANI6J75M.js → chunk-IRRR3PWN.js} +7 -7
  26. package/dist/{chunk-S62LLS4I.js → chunk-IVBMHEPK.js} +12 -12
  27. package/dist/{chunk-SU2USXTD.js → chunk-JBEWFFOK.js} +1 -1
  28. package/dist/{chunk-3VZR3ZUY.js → chunk-KEXKZKN4.js} +6 -6
  29. package/dist/{chunk-ODS5QROC.js → chunk-KUFIFCB4.js} +1 -1
  30. package/dist/{chunk-L2DHKP5C.js → chunk-L5WGVYXM.js} +2 -2
  31. package/dist/{chunk-WIN7KHMV.js → chunk-LGIIT2NF.js} +12 -12
  32. package/dist/{chunk-2BKMOJYJ.js → chunk-LP4APBBQ.js} +1 -1
  33. package/dist/{chunk-6PACEIUY.js → chunk-MI6L5CEA.js} +2 -2
  34. package/dist/{chunk-HDBDYGJQ.js → chunk-N4OXAS3A.js} +1 -1
  35. package/dist/{chunk-KSSM6LUI.js → chunk-N6BUYKF3.js} +5 -5
  36. package/dist/{chunk-MWIKZIAI.js → chunk-NVVW3MWJ.js} +9 -9
  37. package/dist/{chunk-VTDI5KP7.js → chunk-O5JHHRFN.js} +19 -19
  38. package/dist/{chunk-F3MHINI6.js → chunk-O6FDXE54.js} +16 -16
  39. package/dist/{chunk-E4JNHQGT.js → chunk-OMCM3MHS.js} +7 -7
  40. package/dist/{chunk-PST63OUS.js → chunk-OO2KD2L2.js} +18295 -4318
  41. package/dist/{chunk-7FLZA2BD.js → chunk-P72Y5ZBH.js} +7 -7
  42. package/dist/{chunk-O2652RWY.js → chunk-PVPJAGWR.js} +2 -2
  43. package/dist/{chunk-UDC7NPQJ.js → chunk-Q3C7TQ2M.js} +3 -3
  44. package/dist/{chunk-B4IE2GAM.js → chunk-Q5E4ZL2R.js} +1 -1
  45. package/dist/{chunk-5NN7JAJ2.js → chunk-QFK2SWD2.js} +7 -7
  46. package/dist/{chunk-SHEU5KLD.js → chunk-RJR7DJJK.js} +3 -3
  47. package/dist/{chunk-4H3WR7IT.js → chunk-RL52LSTV.js} +1 -1
  48. package/dist/{chunk-FGZX4Q7W.js → chunk-RTB6CF7F.js} +15 -15
  49. package/dist/{chunk-QBAIDKF6.js → chunk-TQURLRHD.js} +1 -1
  50. package/dist/{chunk-3SSNDIQT.js → chunk-TSAUBRRU.js} +1 -1
  51. package/dist/{chunk-ER2ES2RH.js → chunk-U3TEC52G.js} +1 -1
  52. package/dist/{chunk-XY53EFK3.js → chunk-U5KGV63C.js} +1 -1
  53. package/dist/{chunk-WYPVD3HW.js → chunk-UVRULOOP.js} +10 -10
  54. package/dist/{chunk-4VPX67B7.js → chunk-VOATSLRG.js} +3 -1
  55. package/dist/{chunk-TGKIV3F4.js → chunk-W7LEYYFH.js} +18 -18
  56. package/dist/{chunk-T6NRMNLQ.js → chunk-WC5HHPPM.js} +1 -1
  57. package/dist/{chunk-YQFENES6.js → chunk-WG62RHZ2.js} +3 -3
  58. package/dist/{chunk-XE2E2KBP.js → chunk-WIQEPAUG.js} +10 -10
  59. package/dist/{chunk-DTGL5P2V.js → chunk-XM27UVWN.js} +3 -3
  60. package/dist/{chunk-3JJN36GV.js → chunk-XTUSLUQ7.js} +16 -16
  61. package/dist/{chunk-OAEV22IW.js → chunk-Z6AY5VOZ.js} +6 -6
  62. package/dist/{chunk-FZ5N6WXF.js → chunk-ZGWXLG5X.js} +18 -18
  63. package/dist/{chunk-6TAN6WG6.js → chunk-ZUWBEV2O.js} +1 -1
  64. package/dist/{chunk-OANTMDXI.js → chunk-ZVH6EB7S.js} +1 -1
  65. package/dist/daemon.js +65 -31
  66. package/dist/extension-assets/atlassian/docs/confluence-raw.md +31 -0
  67. package/dist/extension-assets/atlassian/docs/confluence-writing.md +101 -0
  68. package/dist/extension-assets/atlassian/docs/jira-raw.md +16 -0
  69. package/dist/extension-assets/atlassian/docs/jira-workflows.md +77 -0
  70. package/dist/extension-assets/atlassian/docs/project-knowledge.md +25 -0
  71. package/dist/extension-assets/atlassian/docs/storage.md +58 -0
  72. package/dist/extension-assets/atlassian/icon.svg +20 -0
  73. package/dist/extension-assets/diagram/docs/diagrams.md +12 -0
  74. package/dist/extension-assets/imagegen/docs/imagegen.md +17 -0
  75. package/dist/extension-assets/web-search/icon.svg +1 -0
  76. package/dist/git-isolated-reader-helper.js +1 -1
  77. package/dist/html-to-markdown.worker.js +6 -7028
  78. package/dist/main.js +583 -169
  79. package/dist/preload.cjs +45 -2
  80. package/dist/quick-script-docs/runtime/documents.md +54 -0
  81. package/dist/quick-script-docs/runtime/files.md +11 -0
  82. package/dist/quick-script-docs/runtime/images.md +10 -0
  83. package/dist/sandbox-libraries/docx.LICENSE +21 -0
  84. package/dist/sandbox-libraries/docx.min.js +9 -0
  85. package/dist/sandbox-libraries/jszip.LICENSE +651 -0
  86. package/dist/sandbox-libraries/jszip.min.js +13 -0
  87. package/dist/sandbox-libraries/mammoth.LICENSE +22 -0
  88. package/dist/sandbox-libraries/mammoth.browser.min.js +13 -0
  89. package/dist/sandbox-libraries/papaparse.LICENSE +20 -0
  90. package/dist/sandbox-libraries/papaparse.min.js +7 -0
  91. package/dist/sandbox-libraries/pptxgen.bundle.js +96 -0
  92. package/dist/sandbox-libraries/pptxgenjs.LICENSE +21 -0
  93. package/dist/sandbox-libraries/xlsx.LICENSE +201 -0
  94. package/dist/sandbox-libraries/xlsx.full.min.js +24 -0
  95. package/dist/web/assets/{AsyncBashCenterHost-BvXKoCVr.js → AsyncBashCenterHost-D2Sy43Ub.js} +1 -1
  96. package/dist/web/assets/ConversationListItem-DvxCcAYm.js +3 -0
  97. package/dist/web/assets/ConversationsWorkbenchPanel-YeNq9LRn.js +1 -0
  98. package/dist/web/assets/DiscoverCenterHost-B6K-QnBF.js +1 -0
  99. package/dist/web/assets/{FileCenterHost-C_7XZAFZ.js → FileCenterHost-Dlk53K5G.js} +1 -1
  100. package/dist/web/assets/FilesWorkbenchPanel-PeCu12oU.js +12 -0
  101. package/dist/web/assets/{GitDiffCenterHost-Cr7lqGI_.js → GitDiffCenterHost-3_Ea0RyG.js} +1 -1
  102. package/dist/web/assets/{GitWorkbenchPanel-BFbwUgIN.js → GitWorkbenchPanel-CYvCkOAW.js} +1 -1
  103. package/dist/web/assets/{LaunchCenterHost-CIu7bcoZ.js → LaunchCenterHost-CP773N_3.js} +1 -1
  104. package/dist/web/assets/LaunchConfigurationNotice-CtmZ1uIQ.js +1 -0
  105. package/dist/web/assets/{LaunchesWorkbenchPanel-BqzJvsrj.js → LaunchesWorkbenchPanel-DP3yVfkO.js} +1 -1
  106. package/dist/web/assets/LogsCenterHost-BFP0doQf.js +1 -0
  107. package/dist/web/assets/{MermaidCenterHost-DVsZB8nB.js → MermaidCenterHost-Bjl6Dvrq.js} +1 -1
  108. package/dist/web/assets/MobileFilesBody-CDp21MGZ.js +1 -0
  109. package/dist/web/assets/{MobileFilesHost-D843vkDF.js → MobileFilesHost-DlJI_yau.js} +1 -1
  110. package/dist/web/assets/MobileLaunchOutputHost-y3TehLWF.js +1 -0
  111. package/dist/web/assets/MobileLaunchesHost-CBNtDTrs.js +2 -0
  112. package/dist/web/assets/MobileLogsHost-BSb2lydK.js +1 -0
  113. package/dist/web/assets/MobileNoteEditorHost-7yW7hIC2.js +1 -0
  114. package/dist/web/assets/{MobileNotesHost-meLV39Yw.js → MobileNotesHost-CvDHzpAh.js} +1 -1
  115. package/dist/web/assets/{MobileProjectSettingsHost-A49Fdn54.js → MobileProjectSettingsHost-CjtPfyKT.js} +1 -1
  116. package/dist/web/assets/{MobileProjectSettingsPageHost-BXpUqS_N.js → MobileProjectSettingsPageHost-j_7N-B9L.js} +1 -1
  117. package/dist/web/assets/{MobileSettingsHost-DPKPajzI.js → MobileSettingsHost-DXIKNF01.js} +1 -1
  118. package/dist/web/assets/{MobileSettingsPageHost-izNWGN0i.js → MobileSettingsPageHost-CEzo7J9p.js} +1 -1
  119. package/dist/web/assets/MobileSettingsPageScreen-99wMLRsn.js +1 -0
  120. package/dist/web/assets/NotesWorkbenchPanel-DqTwXBBv.js +1 -0
  121. package/dist/web/assets/ProjectSettingsCenterHost-D96cL0uH.js +1 -0
  122. package/dist/web/assets/{PullRequestCenterHost-BYkWxXQe.js → PullRequestCenterHost-DY0yPDK2.js} +1 -1
  123. package/dist/web/assets/PullRequestsWorkbenchPanel-D07LE8vJ.js +1 -0
  124. package/dist/web/assets/{SearchWorkbenchPanel-DaC0smfe.js → SearchWorkbenchPanel-D2_3iXo8.js} +1 -1
  125. package/dist/web/assets/SettingsCenter-BQWc24di.js +1 -0
  126. package/dist/web/assets/SettingsCenterHost-BvgNfeZN.js +1 -0
  127. package/dist/web/assets/{SystemPromptCenterHost-B1hfsfAn.js → SystemPromptCenterHost-BLHkB7lp.js} +1 -1
  128. package/dist/web/assets/activity-notices-C9aphS1s.js +1 -0
  129. package/dist/web/assets/adapters-DNU88KT0.js +1 -0
  130. package/dist/web/assets/agent-profiles.svelte-DgI8wSS2.js +1 -0
  131. package/dist/web/assets/api-CHNbLvvY.js +1 -0
  132. package/dist/web/assets/center-tabs.svelte-CyhCD_6b.js +1 -0
  133. package/dist/web/assets/channel-6wGoOwGx.js +57 -0
  134. package/dist/web/assets/circle-question-mark-C7NgqbLL.js +1 -0
  135. package/dist/web/assets/code-DJR0pnqV.js +7 -0
  136. package/dist/web/assets/{confirm-dialog-Bw_IxcZD.js → confirm-dialog-BDjzMiC4.js} +1 -1
  137. package/dist/web/assets/{conversation-connection-3GxIuhbS.js → conversation-connection-mLNyfV2d.js} +1 -1
  138. package/dist/web/assets/dialog-CkRcLEJT.js +1 -0
  139. package/dist/web/assets/discover-Dh4m7djO.js +4 -0
  140. package/dist/web/assets/dist-DSApqEag.js +1 -0
  141. package/dist/web/assets/file-tabs.svelte-cX3MMyG6.js +2 -0
  142. package/dist/web/assets/filesystem-BbIXrkGB.js +1 -0
  143. package/dist/web/assets/{git-store.svelte-CM5k7yRU.js → git-store.svelte-D3uwRVnj.js} +1 -1
  144. package/dist/web/assets/{git.api-D2CfUXZW.js → git.api-CTu-tG8A.js} +1 -1
  145. package/dist/web/assets/index-BrxjAwg0.js +46 -0
  146. package/dist/web/assets/index-yEOHI1Z7.css +1 -0
  147. package/dist/web/assets/launches-CC4gLnSa.js +5 -0
  148. package/dist/web/assets/{launches.api-BZxyWF8t.js → launches.api-CaotSs6l.js} +1 -1
  149. package/dist/web/assets/launches.svelte-DDA5J-RZ.js +2 -0
  150. package/dist/web/assets/{message-square-CqLxHJuW.js → list-checks-zV9Dp7Cu.js} +1 -1
  151. package/dist/web/assets/{logs.api-Coi8HJuy.js → logs.api-DMmVlkSz.js} +1 -1
  152. package/dist/web/assets/{maintenance-state.svelte-CDO9i4dk.js → maintenance-state.svelte-l9v7Hg3i.js} +2 -2
  153. package/dist/web/assets/notify.svelte-BTEXJZ8P.js +1 -0
  154. package/dist/web/assets/popover-panel-C-weKOk3.js +5 -0
  155. package/dist/web/assets/pr-view-loader.svelte-C0NClMS6.js +1 -0
  156. package/dist/web/assets/progress-CKEsTSOk.js +1 -0
  157. package/dist/web/assets/scratch-notes-state.svelte-B_rY_-9q.js +1 -0
  158. package/dist/web/assets/{scratch-notes.api-Cbvag3bv.js → scratch-notes.api-B2gOOK6Z.js} +1 -1
  159. package/dist/web/assets/search-input-CEr0SmAB.js +1 -0
  160. package/dist/web/assets/settings-2-CWd8Y06n.js +1 -0
  161. package/dist/web/assets/settings-CRmC19nG.js +1 -0
  162. package/dist/web/assets/settings-CXoAzSmm.js +1 -0
  163. package/dist/web/assets/settings-actions.svelte-BB6u_lQ0.js +1 -0
  164. package/dist/web/assets/settings-page-controllers.svelte-al78EDTL.js +29 -0
  165. package/dist/web/assets/sheet-content-DauQ7hPL.js +1 -0
  166. package/dist/web/assets/shell-CYbWnH52.js +4 -0
  167. package/dist/web/assets/shell-layout.svelte-CmEWk428.js +2 -0
  168. package/dist/web/assets/textarea-BEZ65po_.js +1 -0
  169. package/dist/web/assets/views-BumCSQ3W.js +2 -0
  170. package/dist/web/assets/{workbench-connection-gGGv4o8i.js → workbench-connection-CGHdORw3.js} +1 -1
  171. package/dist/web/assets/{workspace-Cc47dGjw.js → workspace-CW738NJG.js} +1 -1
  172. package/dist/web/assets/{workspace-actions.svelte-B3oum_9S.js → workspace-actions.svelte-DL9xv7lJ.js} +1 -1
  173. package/dist/web/assets/workspace-selectors.svelte-BRJvPEBh.js +105 -0
  174. package/dist/web/index.html +142 -83
  175. package/dist/web/sw.js +1 -1
  176. package/dist/worker.js +14 -14
  177. package/package.json +7 -7
  178. package/dist/guides/confluence/SKILL.md +0 -36
  179. package/dist/guides/jira/SKILL.md +0 -34
  180. package/dist/web/assets/ConversationListItem-Caz2KiJH.js +0 -3
  181. package/dist/web/assets/ConversationsWorkbenchPanel-CIfK_e3I.js +0 -1
  182. package/dist/web/assets/DiscoverCenterHost-Ep8EN9iJ.js +0 -1
  183. package/dist/web/assets/FilesWorkbenchPanel-CtXo7ywG.js +0 -12
  184. package/dist/web/assets/LaunchConfigurationNotice-CJjWkMhv.js +0 -1
  185. package/dist/web/assets/LogsCenterHost-BI1fSxFW.js +0 -1
  186. package/dist/web/assets/MobileFilesBody-BJMoaP9I.js +0 -1
  187. package/dist/web/assets/MobileLaunchOutputHost-vpltMcar.js +0 -1
  188. package/dist/web/assets/MobileLaunchesHost-CdDrKASg.js +0 -2
  189. package/dist/web/assets/MobileLogsHost-qK7N-C1y.js +0 -1
  190. package/dist/web/assets/MobileNoteEditorHost-Bg1N8o54.js +0 -1
  191. package/dist/web/assets/MobileSettingsPageScreen-DWMg4fDo.js +0 -1
  192. package/dist/web/assets/NotesWorkbenchPanel-Bf6rySTL.js +0 -1
  193. package/dist/web/assets/ProjectSettingsCenterHost-DHeb274m.js +0 -1
  194. package/dist/web/assets/PullRequestsWorkbenchPanel-ZvGbi1Cr.js +0 -1
  195. package/dist/web/assets/SettingsCenter-C_NLBsi6.js +0 -1
  196. package/dist/web/assets/SettingsCenterHost-jP8MULEj.js +0 -1
  197. package/dist/web/assets/adapters-DxJoo6Za.js +0 -1
  198. package/dist/web/assets/agent-profiles.svelte-D5YHPc90.js +0 -1
  199. package/dist/web/assets/api-eaGLre0q.js +0 -1
  200. package/dist/web/assets/center-tabs.svelte-JJGozG_H.js +0 -1
  201. package/dist/web/assets/channel-B503YLZR.js +0 -57
  202. package/dist/web/assets/chevron-left-DPEFG6UJ.js +0 -1
  203. package/dist/web/assets/circle-alert-Cp2l2jcj.js +0 -5
  204. package/dist/web/assets/clock-Db6f9HtS.js +0 -1
  205. package/dist/web/assets/code-BRQC0Tpn.js +0 -7
  206. package/dist/web/assets/dialog-DU4gXD1J.js +0 -1
  207. package/dist/web/assets/discover-B-aZ504j.js +0 -4
  208. package/dist/web/assets/dist-B_NFPhKV.js +0 -1
  209. package/dist/web/assets/file-tabs.svelte-DKtVVVCq.js +0 -2
  210. package/dist/web/assets/filesystem-ReGivxAC.js +0 -1
  211. package/dist/web/assets/index-DIQuyMVT.css +0 -1
  212. package/dist/web/assets/index-TZ1KAAsX.js +0 -48
  213. package/dist/web/assets/launches-DiAl56ED.js +0 -5
  214. package/dist/web/assets/launches.svelte-BVs1pAhl.js +0 -2
  215. package/dist/web/assets/notebook-pen-lVsLYSe4.js +0 -1
  216. package/dist/web/assets/notify.svelte-BKVBraTJ.js +0 -1
  217. package/dist/web/assets/pencil-BrlypebI.js +0 -1
  218. package/dist/web/assets/pr-view-loader.svelte-DcIwqDJV.js +0 -1
  219. package/dist/web/assets/progress-DBCSpVPn.js +0 -1
  220. package/dist/web/assets/scratch-notes-state.svelte-Br_WiMEp.js +0 -1
  221. package/dist/web/assets/search-input-zU4WCZiz.js +0 -1
  222. package/dist/web/assets/settings-2-8MSBUGAl.js +0 -1
  223. package/dist/web/assets/settings-9LBrw4Nv.js +0 -1
  224. package/dist/web/assets/settings-B7uXsflY.js +0 -1
  225. package/dist/web/assets/settings-actions.svelte-B8psX3cj.js +0 -1
  226. package/dist/web/assets/settings-page-controllers.svelte-D_ydJF8u.js +0 -30
  227. package/dist/web/assets/shell-DB5Db5-E.js +0 -4
  228. package/dist/web/assets/shell-layout.svelte-OoLFwzzJ.js +0 -2
  229. package/dist/web/assets/textarea-CeoFJ0-t.js +0 -1
  230. package/dist/web/assets/views-ByPCKDiZ.js +0 -2
  231. package/dist/web/assets/workspace-selectors.svelte-DLUlSgEE.js +0 -131
  232. /package/dist/{html-to-markdown.worker.js.LEGAL.txt → chunk-BUD4JHBZ.js.LEGAL.txt} +0 -0
  233. /package/dist/{chunk-3VZR3ZUY.js.LEGAL.txt → chunk-KEXKZKN4.js.LEGAL.txt} +0 -0
  234. /package/dist/{chunk-PST63OUS.js.LEGAL.txt → chunk-OO2KD2L2.js.LEGAL.txt} +0 -0
@@ -1,37 +1,45 @@
1
1
  import { createRequire as __nerveCreateRequire } from "node:module";
2
2
  const require = __nerveCreateRequire(import.meta.url);
3
3
  import {
4
+ AGENT_PROFILE_LABEL_MAX_LENGTH,
5
+ AGENT_PROFILE_WHEN_TO_USE_MAX_LENGTH,
4
6
  DiscardableMigrationError,
5
7
  MIGRATION_METADATA,
6
8
  NodeAgentBrowserCommandRunner,
7
9
  NodeExecutionEnv,
8
10
  acquireStorageHomeLock,
9
- agentPreferencesSchema,
11
+ agentProfileInstructionsSchema,
12
+ agentProfileNameSchema,
10
13
  atomicWriteJson,
11
- childConversationAgentSchema,
12
- completeChildSettingsSchema,
13
- conversationDefaultsSchema,
14
+ bashToolSettingsSchema,
15
+ capabilitySkillsSchema,
16
+ compactionProfileSchema,
17
+ convertPermissionOverlayDocument,
18
+ convertRuleSetDocument,
14
19
  coreMigrations,
15
20
  createId,
16
21
  defineStep,
17
22
  external_exports,
23
+ hasEnabledRemovedToolRule,
24
+ imageExplanationToolSettingsSchema,
18
25
  isRetriableRenameError,
19
- leadConversationAgentSchema,
20
- leadSettingsOverridesSchema,
21
26
  loadSkills,
22
27
  manifestBackupPath,
28
+ modelSelectionSchema,
23
29
  pathExists,
24
30
  permissionOverlayDocumentSchema,
25
31
  permissionRuleSetIdSchema,
26
32
  permissionRuleSetSchema,
27
33
  planMigrations,
28
- profileDefinitionSchema,
34
+ planPresentToolSettingsSchema,
35
+ pythonExecToolSettingsSchema,
29
36
  readMigrationHome,
30
37
  require_dist,
31
38
  retryRename,
32
39
  storagePaths,
40
+ thinkingLevelSchema,
33
41
  validateName
34
- } from "./chunk-6FSDDGFZ.js";
42
+ } from "./chunk-FZ557YWE.js";
35
43
  import {
36
44
  __toESM
37
45
  } from "./chunk-CWESUMYQ.js";
@@ -228,10 +236,10 @@ function applyQuarantine(ctx) {
228
236
  function ownPaths(ctx, paths, root = ctx.paths.home) {
229
237
  const boundary = resolve(root);
230
238
  for (const path of paths) {
231
- const owned = resolve(path);
232
- const rel = relative(boundary, owned);
233
- assert(rel && !isAbsolute(rel) && rel !== ".." && !rel.startsWith(`..${sep}`), `Owned path is outside its declared root: ${owned}`);
234
- toolkitState(ctx).owned.set(owned, boundary);
239
+ const owned2 = resolve(path);
240
+ const rel = relative(boundary, owned2);
241
+ assert(rel && !isAbsolute(rel) && rel !== ".." && !rel.startsWith(`..${sep}`), `Owned path is outside its declared root: ${owned2}`);
242
+ toolkitState(ctx).owned.set(owned2, boundary);
235
243
  }
236
244
  }
237
245
  function checkedJson(ctx, path, schema) {
@@ -250,9 +258,9 @@ function checkedJson(ctx, path, schema) {
250
258
  const boundary = state.owned.get(path);
251
259
  for (let entry2 = path; entry2 !== dirname(entry2) && relative(boundary, entry2) !== ""; entry2 = dirname(entry2))
252
260
  assert(!lstatSync(entry2).isSymbolicLink(), `Owned JSON path traverses a symbolic link: ${entry2}`);
253
- const text2 = readFileSync(path, "utf8");
254
- state.checkedText.set(path, text2);
255
- return schema.parse(JSON.parse(text2));
261
+ const text3 = readFileSync(path, "utf8");
262
+ state.checkedText.set(path, text3);
263
+ return schema.parse(JSON.parse(text3));
256
264
  } catch (error) {
257
265
  if (state.unit)
258
266
  throw error;
@@ -314,7 +322,7 @@ function quarantineSource(ctx, path, root) {
314
322
  }
315
323
  return path;
316
324
  }
317
- function quarantine(ctx, item, payload) {
325
+ function quarantine(ctx, item, payload2) {
318
326
  const state = toolkitState(ctx);
319
327
  const original = state.discardedDetails.find((entry2) => entry2.kind === item.kind && entry2.id === item.id);
320
328
  if (original)
@@ -342,7 +350,7 @@ function quarantine(ctx, item, payload) {
342
350
  }
343
351
  ctx.fs.mkdir(path);
344
352
  ctx.fs.mkdir(join(path, "payload"));
345
- const sources = (payload.files ?? []).map((file) => quarantineSource(ctx, file, payload.root));
353
+ const sources = (payload2.files ?? []).map((file) => quarantineSource(ctx, file, payload2.root));
346
354
  const reasonPath = join(path, "reason.json");
347
355
  if (!existsSync2(reasonPath))
348
356
  ctx.fs.write(reasonPath, JSON.stringify({
@@ -350,7 +358,7 @@ function quarantine(ctx, item, payload) {
350
358
  ...sources.length === 1 ? { originalPath: sources[0] } : {},
351
359
  quarantinedAt: (/* @__PURE__ */ new Date()).toISOString()
352
360
  }, null, 2));
353
- if (payload.records) {
361
+ if (payload2.records) {
354
362
  const recordsPath = join(path, "payload", "records.jsonl");
355
363
  function* lines() {
356
364
  const seen = /* @__PURE__ */ new Set();
@@ -359,7 +367,7 @@ function quarantine(ctx, item, payload) {
359
367
  yield `${line}
360
368
  `;
361
369
  }
362
- for (const row2 of payload.records ?? []) {
370
+ for (const row2 of payload2.records ?? []) {
363
371
  const line = serializeRecord(row2);
364
372
  const hash3 = createHash("sha256").update(line).digest("hex");
365
373
  if (seen.has(hash3))
@@ -375,7 +383,7 @@ function quarantine(ctx, item, payload) {
375
383
  const destination = join(path, "payload", basename(file));
376
384
  if (!lstatSync(file, { throwIfNoEntry: false }))
377
385
  continue;
378
- if (payload.retainSource) {
386
+ if (payload2.retainSource) {
379
387
  const copy = (from, to) => {
380
388
  const stat = lstatSync(from);
381
389
  if (stat.isSymbolicLink()) {
@@ -392,7 +400,7 @@ function quarantine(ctx, item, payload) {
392
400
  } else
393
401
  ctx.fs.move(file, destination);
394
402
  }
395
- if (payload.setAside !== false && !state.setAside.some((entry2) => entry2.id === item.id && entry2.kind === item.kind))
403
+ if (payload2.setAside !== false && !state.setAside.some((entry2) => entry2.id === item.id && entry2.kind === item.kind))
396
404
  state.setAside.push({ ...item, quarantinePath: path });
397
405
  ctx.fs.write(join(ctx.scratchDir, "upgrade-report.json"), JSON.stringify({ setAside: state.setAside, losses: state.losses }));
398
406
  };
@@ -725,18 +733,18 @@ function quarantineDiscardedConversations(ctx) {
725
733
  }
726
734
  }
727
735
  for (const row2 of reader.db.prepare("SELECT * FROM domain_documents WHERE namespace IN ('conversation', 'agent', 'task', 'agent_inputs', 'agent_input_preparation')").iterate()) {
728
- let owned = row2.namespace === "conversation" && row2.document_id === id;
729
- owned ||= ["agent", "agent_inputs"].includes(String(row2.namespace)) && agents.has(String(row2.document_id));
730
- owned ||= row2.namespace === "agent_input_preparation" && inputIds.has(String(row2.document_id));
736
+ let owned2 = row2.namespace === "conversation" && row2.document_id === id;
737
+ owned2 ||= ["agent", "agent_inputs"].includes(String(row2.namespace)) && agents.has(String(row2.document_id));
738
+ owned2 ||= row2.namespace === "agent_input_preparation" && inputIds.has(String(row2.document_id));
731
739
  try {
732
740
  const data = decode(row2.data);
733
- owned ||= data.conversationId === id || Array.isArray(data.inputs) && data.inputs.some((input) => input.conversationId === id);
734
- if (owned && row2.namespace === "task" && /^task_[A-Za-z0-9_-]+$/.test(String(row2.document_id)))
741
+ owned2 ||= data.conversationId === id || Array.isArray(data.inputs) && data.inputs.some((input) => input.conversationId === id);
742
+ if (owned2 && row2.namespace === "task" && /^task_[A-Za-z0-9_-]+$/.test(String(row2.document_id)))
735
743
  add(join3(ctx.paths.dataPath, "tasks", String(row2.document_id)));
736
744
  } catch {
737
- owned ||= reader.recordOwners(String(row2.namespace), row2).includes(id);
745
+ owned2 ||= reader.recordOwners(String(row2.namespace), row2).includes(id);
738
746
  }
739
- if (owned)
747
+ if (owned2)
740
748
  records.push({ table: "domain_documents", row: row2 });
741
749
  }
742
750
  ctx.quarantine({
@@ -796,8 +804,8 @@ function outputText(result) {
796
804
  return content;
797
805
  if (!Array.isArray(result.contentBlocks))
798
806
  return void 0;
799
- const text2 = result.contentBlocks.map(record).filter((block) => block.type === "text").map((block) => stringField(block.text)).filter((value) => value !== void 0).join("\n");
800
- return text2.length > 0 ? text2 : void 0;
807
+ const text3 = result.contentBlocks.map(record).filter((block) => block.type === "text").map((block) => stringField(block.text)).filter((value) => value !== void 0).join("\n");
808
+ return text3.length > 0 ? text3 : void 0;
801
809
  }
802
810
  function webSearchResultPreview(value) {
803
811
  const result = record(value);
@@ -850,41 +858,41 @@ function buildWebFetchTranscriptPreview(result) {
850
858
  semanticOverflow: false
851
859
  };
852
860
  }
853
- function headText(text2) {
854
- if (text2 === void 0)
861
+ function headText(text3) {
862
+ if (text3 === void 0)
855
863
  return { value: void 0, hidden: 0, hiddenLines: 0 };
856
- const lineEnd = endAfterFirstLines(text2, WEB_PREVIEW_COUNT);
864
+ const lineEnd = endAfterFirstLines(text3, WEB_PREVIEW_COUNT);
857
865
  const charEnd = Math.min(lineEnd, WEB_PREVIEW_MAX_CHARS);
858
- const hiddenLines = countLinesFrom(text2, lineEnd);
859
- const hiddenChars = Math.max(0, text2.length - charEnd);
866
+ const hiddenLines = countLinesFrom(text3, lineEnd);
867
+ const hiddenChars = Math.max(0, text3.length - charEnd);
860
868
  return {
861
- value: text2.slice(0, charEnd),
869
+ value: text3.slice(0, charEnd),
862
870
  hidden: hiddenLines > 0 ? hiddenLines : hiddenChars,
863
871
  hiddenLines
864
872
  };
865
873
  }
866
- function endAfterFirstLines(text2, count) {
874
+ function endAfterFirstLines(text3, count) {
867
875
  let lines = 1;
868
- for (let index = 0; index < text2.length; index += 1) {
869
- if (text2[index] !== "\n")
876
+ for (let index = 0; index < text3.length; index += 1) {
877
+ if (text3[index] !== "\n")
870
878
  continue;
871
879
  if (lines >= count)
872
880
  return index;
873
881
  lines += 1;
874
882
  }
875
- return text2.length;
883
+ return text3.length;
876
884
  }
877
- function countLinesFrom(text2, offset) {
878
- if (offset >= text2.length)
885
+ function countLinesFrom(text3, offset) {
886
+ if (offset >= text3.length)
879
887
  return 0;
880
888
  let start = offset;
881
- if (text2[start] === "\n")
889
+ if (text3[start] === "\n")
882
890
  start += 1;
883
- if (start >= text2.length)
891
+ if (start >= text3.length)
884
892
  return 0;
885
893
  let lines = 1;
886
- for (let index = start; index < text2.length; index += 1) {
887
- if (text2[index] === "\n")
894
+ for (let index = start; index < text3.length; index += 1) {
895
+ if (text3[index] === "\n")
888
896
  lines += 1;
889
897
  }
890
898
  return lines;
@@ -893,14 +901,14 @@ function countLinesFrom(text2, offset) {
893
901
  // packages/workbench-server/dist/infrastructure/migrations/steps/0001-conversation-core/user-projection/transcript-text-preview.js
894
902
  var PREVIEW_COUNT = 6;
895
903
  var MAX_PREVIEW_CHARS = 8 * 1024;
896
- function firstLines(text2, count = PREVIEW_COUNT, maxChars = MAX_PREVIEW_CHARS) {
897
- if (text2 === void 0)
904
+ function firstLines(text3, count = PREVIEW_COUNT, maxChars = MAX_PREVIEW_CHARS) {
905
+ if (text3 === void 0)
898
906
  return emptyTextPreview(void 0);
899
- const lineEnd = endAfterFirstLines2(text2, count);
907
+ const lineEnd = endAfterFirstLines2(text3, count);
900
908
  const charEnd = Math.min(lineEnd, maxChars);
901
- const value = text2.slice(0, charEnd);
902
- const hiddenLines = countLinesFrom2(text2, lineEnd);
903
- const hiddenChars = Math.max(0, text2.length - charEnd);
909
+ const value = text3.slice(0, charEnd);
910
+ const hiddenLines = countLinesFrom2(text3, lineEnd);
911
+ const hiddenChars = Math.max(0, text3.length - charEnd);
904
912
  return {
905
913
  value,
906
914
  hidden: visibleHiddenCount(hiddenLines, hiddenChars),
@@ -908,14 +916,14 @@ function firstLines(text2, count = PREVIEW_COUNT, maxChars = MAX_PREVIEW_CHARS)
908
916
  hiddenChars
909
917
  };
910
918
  }
911
- function lastLines(text2, count = PREVIEW_COUNT) {
912
- if (text2 === void 0)
919
+ function lastLines(text3, count = PREVIEW_COUNT) {
920
+ if (text3 === void 0)
913
921
  return emptyTextPreview(void 0);
914
- const logicalEnd = text2.endsWith("\n") ? text2.length - 1 : text2.length;
915
- const lineStart = startBeforeLastLines(text2, logicalEnd, count);
922
+ const logicalEnd = text3.endsWith("\n") ? text3.length - 1 : text3.length;
923
+ const lineStart = startBeforeLastLines(text3, logicalEnd, count);
916
924
  const charStart = Math.max(lineStart, logicalEnd - MAX_PREVIEW_CHARS);
917
- const value = text2.slice(charStart, logicalEnd);
918
- const hiddenLines = countLinesUntil(text2, lineStart);
925
+ const value = text3.slice(charStart, logicalEnd);
926
+ const hiddenLines = countLinesUntil(text3, lineStart);
919
927
  const hiddenChars = Math.max(0, charStart);
920
928
  return {
921
929
  value,
@@ -930,25 +938,25 @@ function emptyTextPreview(value) {
930
938
  function visibleHiddenCount(hiddenLines, hiddenChars) {
931
939
  return hiddenLines > 0 ? hiddenLines : hiddenChars;
932
940
  }
933
- function endAfterFirstLines2(text2, count) {
941
+ function endAfterFirstLines2(text3, count) {
934
942
  if (count <= 0)
935
943
  return 0;
936
944
  let lines = 1;
937
- for (let index = 0; index < text2.length; index += 1) {
938
- if (text2[index] !== "\n")
945
+ for (let index = 0; index < text3.length; index += 1) {
946
+ if (text3[index] !== "\n")
939
947
  continue;
940
948
  if (lines >= count)
941
949
  return index;
942
950
  lines += 1;
943
951
  }
944
- return text2.length;
952
+ return text3.length;
945
953
  }
946
- function startBeforeLastLines(text2, logicalEnd, count) {
954
+ function startBeforeLastLines(text3, logicalEnd, count) {
947
955
  if (count <= 0)
948
956
  return logicalEnd;
949
957
  let remaining = count;
950
958
  for (let index = logicalEnd - 1; index >= 0; index -= 1) {
951
- if (text2[index] !== "\n")
959
+ if (text3[index] !== "\n")
952
960
  continue;
953
961
  remaining -= 1;
954
962
  if (remaining === 0)
@@ -956,30 +964,30 @@ function startBeforeLastLines(text2, logicalEnd, count) {
956
964
  }
957
965
  return 0;
958
966
  }
959
- function countLinesFrom2(text2, offset) {
960
- if (offset >= text2.length)
967
+ function countLinesFrom2(text3, offset) {
968
+ if (offset >= text3.length)
961
969
  return 0;
962
970
  let start = offset;
963
- if (text2[start] === "\n")
971
+ if (text3[start] === "\n")
964
972
  start += 1;
965
- if (start >= text2.length)
973
+ if (start >= text3.length)
966
974
  return 0;
967
975
  let lines = 1;
968
- for (let index = start; index < text2.length; index += 1) {
969
- if (text2[index] === "\n")
976
+ for (let index = start; index < text3.length; index += 1) {
977
+ if (text3[index] === "\n")
970
978
  lines += 1;
971
979
  }
972
980
  return lines;
973
981
  }
974
- function countLinesUntil(text2, offset) {
982
+ function countLinesUntil(text3, offset) {
975
983
  if (offset <= 0)
976
984
  return 0;
977
- const end = Math.min(offset - 1, text2.length);
985
+ const end = Math.min(offset - 1, text3.length);
978
986
  if (end <= 0)
979
987
  return 0;
980
988
  let lines = 1;
981
989
  for (let index = 0; index < end; index += 1) {
982
- if (text2[index] === "\n")
990
+ if (text3[index] === "\n")
983
991
  lines += 1;
984
992
  }
985
993
  return lines;
@@ -1045,10 +1053,10 @@ function outputText2(result) {
1045
1053
  return stdout.endsWith("\n") ? `${stdout}${stderr}` : `${stdout}
1046
1054
  ${stderr}`;
1047
1055
  }
1048
- function withTextContent(result, text2) {
1049
- if (text2 === void 0)
1056
+ function withTextContent(result, text3) {
1057
+ if (text3 === void 0)
1050
1058
  return sanitizePreviewValue(result);
1051
- const next = { ...result, content: text2 };
1059
+ const next = { ...result, content: text3 };
1052
1060
  delete next.stdout;
1053
1061
  delete next.stderr;
1054
1062
  const blocks = arrayField(next.contentBlocks);
@@ -1335,10 +1343,10 @@ function withoutProducerArtifactClaims(value) {
1335
1343
  function buildUserProjection(toolName2, args, result) {
1336
1344
  let publicResult = withoutProducerArtifactClaims(result);
1337
1345
  if (toolName2 === "explore" || toolName2.startsWith("task_") || toolName2.startsWith("subagent_")) {
1338
- const text2 = stringField2(record2(publicResult).content);
1339
- if (text2) {
1346
+ const text3 = stringField2(record2(publicResult).content);
1347
+ if (text3) {
1340
1348
  try {
1341
- const value = JSON.parse(text2);
1349
+ const value = JSON.parse(text3);
1342
1350
  publicResult = toolName2 === "explore" ? { reports: value } : value;
1343
1351
  } catch {
1344
1352
  }
@@ -1356,9 +1364,9 @@ function buildUserProjection(toolName2, args, result) {
1356
1364
  case "read": {
1357
1365
  argsPreview = assignPathArgs(argsRecord);
1358
1366
  if (result && typeof result === "object") {
1359
- const text2 = stringField2(resultRecord.content);
1360
- if (text2 !== void 0) {
1361
- const preview = firstLines(text2);
1367
+ const text3 = stringField2(resultRecord.content);
1368
+ if (text3 !== void 0) {
1369
+ const preview = firstLines(text3);
1362
1370
  resultPreview = withTextContent(resultRecord, preview.value);
1363
1371
  ({ hidden, noun } = textOverflowStats([preview]));
1364
1372
  } else {
@@ -1448,15 +1456,15 @@ function buildUserProjection(toolName2, args, result) {
1448
1456
  }
1449
1457
  case "explain_image": {
1450
1458
  const details = record2(resultRecord.details);
1451
- const explanation = firstLines(stringField2(details.explanation) ?? outputText2(resultRecord));
1459
+ const explanation2 = firstLines(stringField2(details.explanation) ?? outputText2(resultRecord));
1452
1460
  resultPreview = {
1453
- ...withTextContent(resultRecord, explanation.value),
1461
+ ...withTextContent(resultRecord, explanation2.value),
1454
1462
  details: {
1455
1463
  ...details,
1456
- explanation: explanation.value ?? ""
1464
+ explanation: explanation2.value ?? ""
1457
1465
  }
1458
1466
  };
1459
- ({ hidden, noun } = textOverflowStats([explanation]));
1467
+ ({ hidden, noun } = textOverflowStats([explanation2]));
1460
1468
  direction = "head";
1461
1469
  break;
1462
1470
  }
@@ -2376,13 +2384,13 @@ var conversationEventSchema = shape((value) => {
2376
2384
  assert7(typeof value.id === "string" && typeof value.conversationId === "string");
2377
2385
  assert7(Number.isSafeInteger(value.sequence) && value.sequence > 0);
2378
2386
  object(value.payload);
2379
- const payload = value.payload;
2387
+ const payload2 = value.payload;
2380
2388
  if (value.type === "user_message")
2381
- assert7(typeof payload.text === "string" && typeof payload.originalText === "string");
2389
+ assert7(typeof payload2.text === "string" && typeof payload2.originalText === "string");
2382
2390
  else if (value.type === "assistant_message") {
2383
- assert7(Array.isArray(payload.content));
2384
- object(payload.usage);
2385
- for (const block of payload.content) {
2391
+ assert7(Array.isArray(payload2.content));
2392
+ object(payload2.usage);
2393
+ for (const block of payload2.content) {
2386
2394
  assert7(["text", "thinking", "toolCall"].includes(block.type));
2387
2395
  if (block.type === "toolCall") {
2388
2396
  assert7(typeof block.id === "string" && typeof block.name === "string");
@@ -2390,16 +2398,16 @@ var conversationEventSchema = shape((value) => {
2390
2398
  }
2391
2399
  }
2392
2400
  } else if (value.type === "tool_call_response") {
2393
- assert7(Array.isArray(payload.agentProjection));
2394
- object(payload.userProjection);
2395
- assert7(!("result" in payload) && !("modelContent" in payload));
2396
- assert7(["completed", "failed", "denied", "cancelled", "indeterminate"].includes(payload.outcome));
2397
- if (payload.origin === "model")
2398
- assert7(typeof payload.providerCallId === "string" && typeof payload.assistantEventId === "string");
2401
+ assert7(Array.isArray(payload2.agentProjection));
2402
+ object(payload2.userProjection);
2403
+ assert7(!("result" in payload2) && !("modelContent" in payload2));
2404
+ assert7(["completed", "failed", "denied", "cancelled", "indeterminate"].includes(payload2.outcome));
2405
+ if (payload2.origin === "model")
2406
+ assert7(typeof payload2.providerCallId === "string" && typeof payload2.assistantEventId === "string");
2399
2407
  } else if (value.type === "compaction")
2400
- assert7(typeof payload.summary === "string");
2408
+ assert7(typeof payload2.summary === "string");
2401
2409
  else
2402
- assert7(value.type === "system_event" && ["notification", "execution_state"].includes(payload.subtype));
2410
+ assert7(value.type === "system_event" && ["notification", "execution_state"].includes(payload2.subtype));
2403
2411
  });
2404
2412
  var supervisionSchema = {
2405
2413
  safeParse(value) {
@@ -2533,9 +2541,9 @@ async function checkConfiguration(input) {
2533
2541
  });
2534
2542
  if (value) {
2535
2543
  checkedDocuments.set(path, value);
2536
- const text2 = checkedText(input.context, path);
2537
- if (text2 !== void 0)
2538
- checkedTexts.set(path, text2);
2544
+ const text3 = checkedText(input.context, path);
2545
+ if (text3 !== void 0)
2546
+ checkedTexts.set(path, text3);
2539
2547
  }
2540
2548
  } catch (error) {
2541
2549
  if (runtime) {
@@ -2563,9 +2571,9 @@ var checkedDocuments = /* @__PURE__ */ new Map();
2563
2571
  var checkedTexts = /* @__PURE__ */ new Map();
2564
2572
  function consumeCheckedText(path) {
2565
2573
  const key2 = resolve4(path);
2566
- const text2 = checkedTexts.get(key2);
2574
+ const text3 = checkedTexts.get(key2);
2567
2575
  checkedTexts.delete(key2);
2568
- return text2;
2576
+ return text3;
2569
2577
  }
2570
2578
  function consumeCheckedDocument(path) {
2571
2579
  const key2 = resolve4(path);
@@ -2616,7 +2624,7 @@ function readJson(path, fallback = {}) {
2616
2624
  return fallback;
2617
2625
  }
2618
2626
  }
2619
- var digest2 = (text2) => `sha256:${createHash5("sha256").update(text2).digest("hex")}`;
2627
+ var digest2 = (text3) => `sha256:${createHash5("sha256").update(text3).digest("hex")}`;
2620
2628
  var normalizeDigest = (value) => value.startsWith("sha256:") ? value : `sha256:${value}`;
2621
2629
  function convertSettings(document) {
2622
2630
  let changed = false;
@@ -2641,10 +2649,10 @@ function convertSettings(document) {
2641
2649
  }
2642
2650
  return convertPermissionRules(document) || changed;
2643
2651
  }
2644
- function renameSuggestionFilter(text2) {
2645
- const match = text2.match(/^(---\r?\n)([\s\S]*?)(\r?\n---(?:\r?\n|$))/);
2652
+ function renameSuggestionFilter(text3) {
2653
+ const match = text3.match(/^(---\r?\n)([\s\S]*?)(\r?\n---(?:\r?\n|$))/);
2646
2654
  if (!match)
2647
- return text2;
2655
+ return text3;
2648
2656
  const lines = match[2].split(/\r?\n/);
2649
2657
  let when = false;
2650
2658
  for (let index = 0; index < lines.length; index++) {
@@ -2659,7 +2667,7 @@ function renameSuggestionFilter(text2) {
2659
2667
  lines[index] = line.replace(/^(\s+["']?)permissionLevels(?=["']?\s*:)/, "$1permissionRuleSets");
2660
2668
  }
2661
2669
  const newline = match[1].includes("\r") ? "\r\n" : "\n";
2662
- return match[1] + lines.join(newline) + match[3] + text2.slice(match[0].length);
2670
+ return match[1] + lines.join(newline) + match[3] + text3.slice(match[0].length);
2663
2671
  }
2664
2672
  async function convertConfiguration(home, scratch, ctx) {
2665
2673
  let settings = 0, suggestions = 0;
@@ -2707,8 +2715,8 @@ async function convertConfiguration(home, scratch, ctx) {
2707
2715
  }
2708
2716
  return { settings, suggestions };
2709
2717
  }
2710
- function predicate(text2) {
2711
- const frontmatter = text2.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/)?.[1];
2718
+ function predicate(text3) {
2719
+ const frontmatter = text3.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/)?.[1];
2712
2720
  if (!frontmatter)
2713
2721
  return null;
2714
2722
  const lines = frontmatter.split(/\r?\n/), index = lines.findIndex((line) => /^(?:enable-js|["']enable-js["']):/.test(line));
@@ -2749,7 +2757,7 @@ function convertPromptTrust(data, home, scratch) {
2749
2757
  return approved ? { ...data, path, status, contentDigest: normalizeDigest(approved) } : null;
2750
2758
  }
2751
2759
  try {
2752
- const text2 = readFileSync3(path, "utf8"), current = digest2(text2);
2760
+ const text3 = readFileSync3(path, "utf8"), current = digest2(text3);
2753
2761
  const old = data.contentDigest ?? data.digest;
2754
2762
  if (old) {
2755
2763
  const conversions = readJson(join7(scratch, "suggestion-digests.json"));
@@ -2762,7 +2770,7 @@ function convertPromptTrust(data, home, scratch) {
2762
2770
  contentDigest: converted ? current : approved
2763
2771
  };
2764
2772
  }
2765
- const code = predicate(text2);
2773
+ const code = predicate(text3);
2766
2774
  if (status === "trusted" && (!code || digest2(code) !== normalizeDigest(data.predicateHash ?? "")))
2767
2775
  return null;
2768
2776
  return { ...data, path, status, contentDigest: current };
@@ -2830,30 +2838,30 @@ End with a short report using these headings: Changes (files and what changed),
2830
2838
  };
2831
2839
  var subagentTools = ["subagent_prompt", "subagent_status", "subagent_stop"];
2832
2840
  var legacySubagentTools = ["subagent_new", "subagent_list"];
2833
- function profileFile(name, model, thinking, compaction2) {
2834
- return profileEntry.parse({ ...builtIns[name], model, thinking, compaction: compaction2 });
2841
+ function profileFile(name, model2, thinking, compaction3) {
2842
+ return profileEntry.parse({ ...builtIns[name], model: model2, thinking, compaction: compaction3 });
2835
2843
  }
2836
2844
  var modelId = (selection2) => selection2 && typeof selection2.provider === "string" && typeof selection2.modelId === "string" ? `${selection2.provider}/${selection2.modelId}` : null;
2837
2845
  function customizedProfiles(harness2) {
2838
2846
  const profiles = [];
2839
2847
  const explore = harness2.exploreAgent;
2840
2848
  if (explore) {
2841
- const model = modelId(explore.model);
2849
+ const model2 = modelId(explore.model);
2842
2850
  const thinking = explore.thinkingLevel ?? "off";
2843
- if (model || thinking !== "off")
2851
+ if (model2 || thinking !== "off")
2844
2852
  profiles.push([
2845
2853
  "explore",
2846
- profileFile("explore", model ?? "lead", thinking, "inherit")
2854
+ profileFile("explore", model2 ?? "lead", thinking, "inherit")
2847
2855
  ]);
2848
2856
  }
2849
2857
  const developer = harness2.asyncSubagent;
2850
2858
  if (developer) {
2851
- const model = modelId(developer.model);
2859
+ const model2 = modelId(developer.model);
2852
2860
  const profile = developer.compactionProfile ?? "inherit";
2853
- if (model || profile !== "inherit")
2861
+ if (model2 || profile !== "inherit")
2854
2862
  profiles.push([
2855
2863
  "developer",
2856
- profileFile("developer", model ?? "lead", model ? developer.thinkingLevel ?? "lead" : "lead", profile === "inherit" ? "inherit" : {
2864
+ profileFile("developer", model2 ?? "lead", model2 ? developer.thinkingLevel ?? "lead" : "lead", profile === "inherit" ? "inherit" : {
2857
2865
  profile,
2858
2866
  ...profile === "custom" ? {
2859
2867
  triggerPercent: developer.customTriggerPercent,
@@ -2864,7 +2872,7 @@ function customizedProfiles(harness2) {
2864
2872
  }
2865
2873
  return profiles;
2866
2874
  }
2867
- var hash = (text2) => createHash6("sha256").update(text2).digest("hex");
2875
+ var hash = (text3) => createHash6("sha256").update(text3).digest("hex");
2868
2876
  var own = (record4, name) => Object.hasOwn(record4, name) ? record4[name] : void 0;
2869
2877
  function verifyAncestors(path, scope) {
2870
2878
  const absolute = resolve5(path);
@@ -2925,8 +2933,8 @@ function convertProfileScope(root, markdownDirectory, customizations = [], disab
2925
2933
  const oldPreferences = existing && !Object.hasOwn(existing, "schemaVersion") ? enabledPreferences.parse(existing) : void 0;
2926
2934
  const document = profilesDocument.parse(oldPreferences || !hasTarget ? { schemaVersion: 1, profiles: {} } : existing);
2927
2935
  const canonicalExploreEnabled = oldPreferences ? void 0 : own(document.profiles, "explore")?.enabled;
2928
- const receipt2 = options.receiptPath && existsSync9(options.receiptPath) ? profileConversionReceipt.parse(readJson(options.receiptPath)) : void 0;
2929
- const verifiedResume = receipt2 && !oldPreferences && isDeepStrictEqual(receipt2.document, document);
2936
+ const receipt3 = options.receiptPath && existsSync9(options.receiptPath) ? profileConversionReceipt.parse(readJson(options.receiptPath)) : void 0;
2937
+ const verifiedResume = receipt3 && !oldPreferences && isDeepStrictEqual(receipt3.document, document);
2930
2938
  const sources = {};
2931
2939
  if (existsSync9(markdownDirectory)) {
2932
2940
  assert10(lstatSync7(markdownDirectory).isDirectory(), "Expected regular profile directory");
@@ -2951,7 +2959,7 @@ function convertProfileScope(root, markdownDirectory, customizations = [], disab
2951
2959
  const missingSkills = lowerSkills && typeof lowerSkills === "object" && upperSkills && typeof upperSkills === "object" ? Object.keys(lowerSkills).filter((key2) => !Object.hasOwn(upperSkills, key2)) : [];
2952
2960
  assert10(!missingTools.length && !missingSkills.length, `Manual review required for legacy project subagent ${name} at ${path}: whole-definition capability shadowing cannot become sparse JSON without changing parent inheritance (tools: ${missingTools.join(", ") || "none"}; skills: ${missingSkills.join(", ") || "none"}). Resolve the selections explicitly in ${target3} and archive the reviewed conflicting Markdown before retrying; legacy files have not been removed.`);
2953
2961
  }
2954
- const resumedSource = verifiedResume && own(receipt2.sources, path) === hash(raw);
2962
+ const resumedSource = verifiedResume && own(receipt3.sources, path) === hash(raw);
2955
2963
  assert10(!current || isDeepStrictEqual(current, entry2) || resumedSource, `Subagent profile collision: ${name} at ${target3}`);
2956
2964
  if (!current)
2957
2965
  document.profiles[name] = entry2;
@@ -3682,16 +3690,16 @@ function mapMessage(mapping, row2, data, base, call) {
3682
3690
  content: [{ type: "text", text: entry2.text ?? "" }],
3683
3691
  isError: entry2.details?.isError
3684
3692
  };
3685
- const payload = responsePayload(mapping, call ?? { id: entry2.details?.toolRecordId }, base.conversationId, fallback);
3693
+ const payload2 = responsePayload(mapping, call ?? { id: entry2.details?.toolRecordId }, base.conversationId, fallback);
3686
3694
  event = {
3687
3695
  ...base,
3688
3696
  type: "tool_call_response",
3689
- llmRepresentation: payload.origin === "model" ? "tool_result" : "user",
3690
- payload
3697
+ llmRepresentation: payload2.origin === "model" ? "tool_result" : "user",
3698
+ payload: payload2
3691
3699
  };
3692
3700
  } else if (message?.role === "user" || entry2.role === "user") {
3693
3701
  const content = message?.content;
3694
- const text2 = typeof content === "string" ? content : Array.isArray(content) ? content.filter((block) => block.type === "text").map((block) => block.text).join("\n") : entry2.text ?? "";
3702
+ const text3 = typeof content === "string" ? content : Array.isArray(content) ? content.filter((block) => block.type === "text").map((block) => block.text).join("\n") : entry2.text ?? "";
3695
3703
  if (Array.isArray(content) && content.some((block) => block.type !== "text"))
3696
3704
  mapping.report.loss("User images cannot be represented by text-only user_message schema");
3697
3705
  event = {
@@ -3699,8 +3707,8 @@ function mapMessage(mapping, row2, data, base, call) {
3699
3707
  type: "user_message",
3700
3708
  llmRepresentation: "user",
3701
3709
  payload: {
3702
- text: text2,
3703
- originalText: entry2.details?.originalText ?? text2,
3710
+ text: text3,
3711
+ originalText: entry2.details?.originalText ?? text3,
3704
3712
  source: "user",
3705
3713
  senderConversationId: null,
3706
3714
  commandPreparation: null
@@ -3770,11 +3778,11 @@ function eventBase(mapping, row2, data, conversationId, sequence, previousEventI
3770
3778
  }
3771
3779
 
3772
3780
  // packages/workbench-server/dist/infrastructure/migrations/steps/0001-conversation-core/commands.js
3773
- function findExecutableCommandBlocks(text2) {
3781
+ function findExecutableCommandBlocks(text3) {
3774
3782
  const lines = [];
3775
- for (let offset = 0; offset < text2.length; ) {
3776
- const newline = text2.indexOf("\n", offset), end = newline < 0 ? text2.length : newline + 1;
3777
- lines.push({ text: text2.slice(offset, end), offset });
3783
+ for (let offset = 0; offset < text3.length; ) {
3784
+ const newline = text3.indexOf("\n", offset), end = newline < 0 ? text3.length : newline + 1;
3785
+ lines.push({ text: text3.slice(offset, end), offset });
3778
3786
  offset = end;
3779
3787
  }
3780
3788
  const blocks = [];
@@ -3785,7 +3793,7 @@ function findExecutableCommandBlocks(text2) {
3785
3793
  for (let end = index + 1; end < lines.length; end++) {
3786
3794
  if (!new RegExp(`^ {0,3}${open3[1][0]}{${open3[1].length},}\\s*$`).test(lines[end].text.replace(/\r?\n$/, "")))
3787
3795
  continue;
3788
- const command = text2.slice(line.offset + line.text.length, lines[end].offset).trim();
3796
+ const command = text3.slice(line.offset + line.text.length, lines[end].offset).trim();
3789
3797
  if (command)
3790
3798
  blocks.push({
3791
3799
  start: line.offset,
@@ -3798,17 +3806,17 @@ function findExecutableCommandBlocks(text2) {
3798
3806
  }
3799
3807
  return blocks;
3800
3808
  }
3801
- function replaceExecutableCommandBlocks(text2, replacements) {
3809
+ function replaceExecutableCommandBlocks(text3, replacements) {
3802
3810
  let cursor = 0, result = "";
3803
3811
  for (const replacement of [...replacements].sort((a, b) => a.block.start - b.block.start)) {
3804
3812
  if (replacement.block.start < cursor)
3805
3813
  throw new Error("Overlapping command receipts");
3806
- result += text2.slice(cursor, replacement.block.start) + replacement.text;
3807
- if (text2[replacement.block.end - 1] === "\n" && !replacement.text.endsWith("\n"))
3814
+ result += text3.slice(cursor, replacement.block.start) + replacement.text;
3815
+ if (text3[replacement.block.end - 1] === "\n" && !replacement.text.endsWith("\n"))
3808
3816
  result += "\n";
3809
3817
  cursor = replacement.block.end;
3810
3818
  }
3811
- return result + text2.slice(cursor);
3819
+ return result + text3.slice(cursor);
3812
3820
  }
3813
3821
 
3814
3822
  // packages/workbench-server/dist/infrastructure/migrations/steps/0001-conversation-core/input.mapper.js
@@ -3825,25 +3833,25 @@ function importPendingInput(mapping, conversationId, input) {
3825
3833
  }
3826
3834
  if (input.eligibility?.kind === "run")
3827
3835
  mapping.report.loss("Pending run-targeted input retargeted to next turn after migration settlement");
3828
- const text2 = input.text ?? "";
3829
- const blocks = source === "system" ? [] : findExecutableCommandBlocks(text2);
3836
+ const text3 = input.text ?? "";
3837
+ const blocks = source === "system" ? [] : findExecutableCommandBlocks(text3);
3830
3838
  const receipts = input.importPreparation?.blocks ?? [];
3831
3839
  const preparation = blocks.length ? commandPreparationSchema.parse({
3832
3840
  blocks: blocks.map((block, index) => {
3833
- const receipt2 = receipts.find((item) => item.index === index && item.command === block.command);
3834
- const state = receipt2?.state === "completed" && receipt2.resultText ? "completed" : receipt2?.state === "running" ? "indeterminate" : "not_run";
3841
+ const receipt3 = receipts.find((item) => item.index === index && item.command === block.command);
3842
+ const state = receipt3?.state === "completed" && receipt3.resultText ? "completed" : receipt3?.state === "running" ? "indeterminate" : "not_run";
3835
3843
  return {
3836
3844
  index,
3837
3845
  command: block.command,
3838
3846
  state,
3839
- result: state === "completed" ? { stdout: receipt2.resultText, stderr: "", exitCode: null } : null
3847
+ result: state === "completed" ? { stdout: receipt3.resultText, stderr: "", exitCode: null } : null
3840
3848
  };
3841
3849
  })
3842
3850
  }) : null;
3843
- const preparedText = preparation ? replaceExecutableCommandBlocks(text2, preparation.blocks.map((block) => ({
3851
+ const preparedText = preparation ? replaceExecutableCommandBlocks(text3, preparation.blocks.map((block) => ({
3844
3852
  block: blocks[block.index],
3845
3853
  text: block.result?.stdout ?? `[Command ${block.state} during migration; it was not repeated: ${block.command}]`
3846
- }))) : source === "system" ? null : text2;
3854
+ }))) : source === "system" ? null : text3;
3847
3855
  if (preparation?.blocks.some((block) => block.state !== "completed"))
3848
3856
  mapping.report.loss("Pending command blocks settled without replaying external effects");
3849
3857
  mapping.storage.inputs.insert({
@@ -3854,8 +3862,8 @@ function importPendingInput(mapping, conversationId, input) {
3854
3862
  content: source === "system" ? {
3855
3863
  subtype: "notification",
3856
3864
  producer: input.origin.producer ?? "import",
3857
- text: text2
3858
- } : text2,
3865
+ text: text3
3866
+ } : text3,
3859
3867
  deliveryTarget: input.eligibility?.kind === "next_run" ? "next_execution" : "next_turn",
3860
3868
  targetExecutionId: null,
3861
3869
  commandPreparation: preparation,
@@ -3869,11 +3877,11 @@ function importPendingInput(mapping, conversationId, input) {
3869
3877
  import { createHash as createHash9 } from "node:crypto";
3870
3878
  function userMessageDigest(message) {
3871
3879
  const content = message.content;
3872
- const text2 = typeof content === "string" ? content : Array.isArray(content) ? content.filter((block) => block.type === "text").map((block) => block.text).join("\n") : "";
3873
- return digest3(text2);
3880
+ const text3 = typeof content === "string" ? content : Array.isArray(content) ? content.filter((block) => block.type === "text").map((block) => block.text).join("\n") : "";
3881
+ return digest3(text3);
3874
3882
  }
3875
- function digest3(text2) {
3876
- return createHash9("sha256").update(text2).digest("hex");
3883
+ function digest3(text3) {
3884
+ return createHash9("sha256").update(text3).digest("hex");
3877
3885
  }
3878
3886
  function verifySelectedPath(input) {
3879
3887
  const { reader, storage, summary } = input;
@@ -4046,12 +4054,12 @@ function importConversation(reader, mapping, conversation, agents, inputs2, task
4046
4054
  if (call.toolName === "task_start" && !mapping.processLinks.has(call.id ?? String(row2.id))) {
4047
4055
  const envelope = call.result ?? (call.resultPayload?.logicalPath ? readPayload(mapping.dataDir, call.resultPayload.logicalPath) : null);
4048
4056
  const result = envelope?.result ?? envelope;
4049
- const bash = result?.asyncBash ?? result?.details?.asyncBash;
4050
- const bashId = bash?.id ?? result?.bashId ?? result?.details?.bashId;
4057
+ const bash2 = result?.asyncBash ?? result?.details?.asyncBash;
4058
+ const bashId = bash2?.id ?? result?.bashId ?? result?.details?.bashId;
4051
4059
  if (typeof bashId === "string" && bashId.startsWith("bash_"))
4052
4060
  mapping.processLinks.set(call.id ?? String(row2.id), {
4053
4061
  id: bashId,
4054
- command: bash?.command ?? call.args?.command
4062
+ command: bash2?.command ?? call.args?.command
4055
4063
  });
4056
4064
  }
4057
4065
  tools.set(String(row2.id), {
@@ -4345,14 +4353,14 @@ function importConversation(reader, mapping, conversation, agents, inputs2, task
4345
4353
  if (preserveSelection)
4346
4354
  scope.head = origin?.eventId ?? null;
4347
4355
  ensureOrigin(scope, call);
4348
- const payload = responsePayload(mapping, call, scope.id);
4356
+ const payload2 = responsePayload(mapping, call, scope.id);
4349
4357
  append(scope, {
4350
4358
  id: mapping.ids.get("evt", `response:${row2.id}`),
4351
4359
  type: "tool_call_response",
4352
- llmRepresentation: payload.origin === "model" ? "tool_result" : "user",
4360
+ llmRepresentation: payload2.origin === "model" ? "tool_result" : "user",
4353
4361
  createdAt: iso(call.settledAt ?? call.updatedAt),
4354
4362
  turnId: call.turnId ? mapping.ids.get("turn", call.turnId) : null,
4355
- payload
4363
+ payload: payload2
4356
4364
  });
4357
4365
  if (preserveSelection)
4358
4366
  scope.head = selectedHead;
@@ -4375,14 +4383,14 @@ function importConversation(reader, mapping, conversation, agents, inputs2, task
4375
4383
  status: "running",
4376
4384
  error: "No durable result existed for this call at migration; its outcome is indeterminate and it was not replayed."
4377
4385
  };
4378
- const payload = responsePayload(mapping, call, scope.id);
4386
+ const payload2 = responsePayload(mapping, call, scope.id);
4379
4387
  append(scope, {
4380
4388
  id: mapping.ids.get("evt", `missing-response:${origin.eventId}:${providerCallId}`),
4381
4389
  type: "tool_call_response",
4382
4390
  llmRepresentation: "tool_result",
4383
4391
  createdAt: origin.createdAt,
4384
4392
  turnId: origin.turnId,
4385
- payload
4393
+ payload: payload2
4386
4394
  });
4387
4395
  branchTails.set(origin.eventId, scope.head);
4388
4396
  if (!cursor)
@@ -4442,11 +4450,11 @@ function importConversation(reader, mapping, conversation, agents, inputs2, task
4442
4450
  while (sourceId) {
4443
4451
  assert12(!seen.has(sourceId), `Source history cycle ${sourceId}`);
4444
4452
  seen.add(sourceId);
4445
- const receipt2 = sourceHistory.get(sourceId);
4446
- assert12(receipt2, `Missing source leaf/predecessor ${sourceId}`);
4447
- if (receipt2.userDigest)
4448
- oldUserDigests.push(receipt2.userDigest);
4449
- sourceId = receipt2.parent;
4453
+ const receipt3 = sourceHistory.get(sourceId);
4454
+ assert12(receipt3, `Missing source leaf/predecessor ${sourceId}`);
4455
+ if (receipt3.userDigest)
4456
+ oldUserDigests.push(receipt3.userDigest);
4457
+ sourceId = receipt3.parent;
4450
4458
  }
4451
4459
  if (expectation.isRoot)
4452
4460
  mapping.report.selectedPaths.roots++;
@@ -5115,13 +5123,13 @@ async function check(ctx, summary) {
5115
5123
  if (problems.length)
5116
5124
  fail(path.conversationId, `History verification failed: ${problems.join(", ")}`);
5117
5125
  }
5118
- for (const receipt2 of summary.salvagedRecords ?? []) {
5126
+ for (const receipt3 of summary.salvagedRecords ?? []) {
5119
5127
  try {
5120
- const event = storage.events.get(receipt2.eventId);
5121
- assert14(event?.type === "system_event" && event.llmRepresentation === "none" && event.payload.subtype === "notification" && event.payload.producer === "import:migration_loss", `Missing history-loss placeholder for ${receipt2.sourceRecordId}`);
5122
- assert14.equal(createHash10("sha256").update(event.payload.text).digest("hex"), receipt2.textDigest, `Changed history-loss placeholder for ${receipt2.sourceRecordId}`);
5128
+ const event = storage.events.get(receipt3.eventId);
5129
+ assert14(event?.type === "system_event" && event.llmRepresentation === "none" && event.payload.subtype === "notification" && event.payload.producer === "import:migration_loss", `Missing history-loss placeholder for ${receipt3.sourceRecordId}`);
5130
+ assert14.equal(createHash10("sha256").update(event.payload.text).digest("hex"), receipt3.textDigest, `Changed history-loss placeholder for ${receipt3.sourceRecordId}`);
5123
5131
  } catch (error) {
5124
- fail(receipt2.conversationId, failureReason(error));
5132
+ fail(receipt3.conversationId, failureReason(error));
5125
5133
  }
5126
5134
  }
5127
5135
  for (const [table, expected] of Object.entries(summary.counts)) {
@@ -5138,15 +5146,15 @@ async function check(ctx, summary) {
5138
5146
  if (failures.has(sourceOf.get(conversationId) ?? conversationId))
5139
5147
  continue;
5140
5148
  try {
5141
- const text2 = String(row2.payload), payload = JSON.parse(text2), bytes = Buffer.byteLength(text2);
5142
- assertProjectedPayload(payload);
5149
+ const text3 = String(row2.payload), payload2 = JSON.parse(text3), bytes = Buffer.byteLength(text3);
5150
+ assertProjectedPayload(payload2);
5143
5151
  payloadCount++;
5144
5152
  payloadTotal += bytes;
5145
5153
  payloadMax = Math.max(payloadMax, bytes);
5146
5154
  if (row2.type === "tool_call_response") {
5147
- assert14(!("result" in payload) && !("modelContent" in payload), "Inline complete result in event");
5148
- assert14(Array.isArray(payload.agentProjection) && payload.userProjection, "Missing projections");
5149
- const assets = payload.assetIds.map((id) => storage.assets.get(id));
5155
+ assert14(!("result" in payload2) && !("modelContent" in payload2), "Inline complete result in event");
5156
+ assert14(Array.isArray(payload2.agentProjection) && payload2.userProjection, "Missing projections");
5157
+ const assets = payload2.assetIds.map((id) => storage.assets.get(id));
5150
5158
  assert14(assets.every(Boolean), "Missing response asset row");
5151
5159
  const result = assets.find((asset) => asset.category === "payload" && asset.logicalPath.endsWith("/result.json"));
5152
5160
  assert14(result, "Missing complete result asset");
@@ -5164,8 +5172,8 @@ async function check(ctx, summary) {
5164
5172
  assert14(assets.some((asset) => asset.id === record4.assetId && asset.category === "image"), "Untracked image reference");
5165
5173
  Object.values(record4).forEach(refs);
5166
5174
  };
5167
- refs(payload.agentProjection);
5168
- refs(payload.userProjection);
5175
+ refs(payload2.agentProjection);
5176
+ refs(payload2.userProjection);
5169
5177
  refs(complete);
5170
5178
  responseCount++;
5171
5179
  responseTotal += bytes;
@@ -5196,10 +5204,10 @@ async function check(ctx, summary) {
5196
5204
  }
5197
5205
  }
5198
5206
  assert14.equal(paths.size, summary.assets.trackedFiles, "Asset coverage changed");
5199
- for (const receipt2 of summary.assets.sourceFiles) {
5200
- const logical = summary.assets.relocatedPayloads[receipt2.logicalPath] ?? receipt2.logicalPath;
5207
+ for (const receipt3 of summary.assets.sourceFiles) {
5208
+ const logical = summary.assets.relocatedPayloads[receipt3.logicalPath] ?? receipt3.logicalPath;
5201
5209
  if (!paths.has(logical))
5202
- fail(receipt2.conversationId, `Untracked source asset: ${receipt2.logicalPath}`);
5210
+ fail(receipt3.conversationId, `Untracked source asset: ${receipt3.logicalPath}`);
5203
5211
  }
5204
5212
  assert14.equal(summary.assets.sourceFiles.length, summary.assets.diskFiles, "Source asset receipt coverage changed");
5205
5213
  assert14.equal(selected.roots + excluded.size, summary.sourceConversationCount, "Source conversation receipt coverage changed");
@@ -5487,9 +5495,9 @@ function safePath(path) {
5487
5495
  function readText(path) {
5488
5496
  safePath(path);
5489
5497
  assert15(lstatSync12(path).isFile(), `Expected regular file: ${path}`);
5490
- const bytes = readFileSync7(path), text2 = bytes.toString("utf8");
5491
- assert15(Buffer.from(text2, "utf8").equals(bytes), `Non-UTF8 migration source: ${path}`);
5492
- return text2;
5498
+ const bytes = readFileSync7(path), text3 = bytes.toString("utf8");
5499
+ assert15(Buffer.from(text3, "utf8").equals(bytes), `Non-UTF8 migration source: ${path}`);
5500
+ return text3;
5493
5501
  }
5494
5502
  function json(path) {
5495
5503
  return JSON.parse(readText(path));
@@ -5577,13 +5585,13 @@ function convertProfileDocument(value) {
5577
5585
  }
5578
5586
  function dropProfileDefaults(profile) {
5579
5587
  for (const section of ["recommendations", "requirements"]) {
5580
- const contribution = structuredClone(profile[section]);
5581
- if (!object4(contribution) || !object4(contribution.skills))
5588
+ const contribution2 = structuredClone(profile[section]);
5589
+ if (!object4(contribution2) || !object4(contribution2.skills))
5582
5590
  continue;
5583
- profile[section] = contribution;
5584
- delete contribution.skills.defaults;
5585
- if (!Object.keys(contribution.skills).length)
5586
- delete contribution.skills;
5591
+ profile[section] = contribution2;
5592
+ delete contribution2.skills.defaults;
5593
+ if (!Object.keys(contribution2.skills).length)
5594
+ delete contribution2.skills;
5587
5595
  }
5588
5596
  }
5589
5597
  function convertAppliedProfileDocument(value) {
@@ -5600,14 +5608,14 @@ function upgradeProfileDocuments(ctx, verifyOnly = false) {
5600
5608
  const roots = /* @__PURE__ */ new Map([
5601
5609
  [ctx.paths.home, join14(ctx.paths.home, "data", "agent-profiles")]
5602
5610
  ]);
5603
- function update(path, root, convert2) {
5611
+ function update(path, root, convert3) {
5604
5612
  let before, after;
5605
5613
  try {
5606
5614
  safePath(path);
5607
5615
  if (!existsSync14(path))
5608
5616
  return;
5609
5617
  before = json(path);
5610
- after = convert2(before);
5618
+ after = convert3(before);
5611
5619
  } catch (error) {
5612
5620
  ctx.quarantine({
5613
5621
  kind: "configuration",
@@ -5645,6 +5653,372 @@ import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
5645
5653
  import assert18 from "node:assert/strict";
5646
5654
  import { createHash as createHash11 } from "node:crypto";
5647
5655
 
5656
+ // packages/workbench-server/dist/infrastructure/migrations/steps/0002-agent-profiles/frozen-agent-schemas.js
5657
+ var krokiToolSettingsSchema = external_exports.object({
5658
+ url: external_exports.string().trim().min(1).max(2048).url().refine((value) => {
5659
+ try {
5660
+ const url = new URL(value);
5661
+ return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password && !url.search && !url.hash;
5662
+ } catch {
5663
+ return false;
5664
+ }
5665
+ }, {
5666
+ message: "Use an HTTP(S) URL without credentials, query parameters, or fragments."
5667
+ }).transform((value) => {
5668
+ const url = new URL(value);
5669
+ if (!url.pathname.endsWith("/"))
5670
+ url.pathname += "/";
5671
+ return url.href;
5672
+ })
5673
+ }).strict();
5674
+ var openAiCodexImageGenerationSettingsSchema = external_exports.object({
5675
+ provider: external_exports.literal("openai-codex"),
5676
+ model: external_exports.enum(["gpt-image-2.5-flare", "gpt-image-2.5-sunburst"]),
5677
+ options: external_exports.object({
5678
+ quality: external_exports.enum(["auto", "low", "medium", "high", "xhigh", "max"]),
5679
+ size: external_exports.union([
5680
+ external_exports.literal("auto"),
5681
+ external_exports.string().regex(/^\d+x\d+$/).refine((value) => {
5682
+ const [width, height] = value.split("x").map(Number);
5683
+ if (!width || !height || width % 16 !== 0 || height % 16 !== 0) {
5684
+ return false;
5685
+ }
5686
+ const longEdge = Math.max(width, height);
5687
+ const shortEdge = Math.min(width, height);
5688
+ const pixels = width * height;
5689
+ return longEdge <= 3840 && longEdge / shortEdge <= 3 && pixels >= 655360 && pixels <= 8294400;
5690
+ })
5691
+ ]),
5692
+ background: external_exports.enum(["auto", "opaque", "transparent"])
5693
+ })
5694
+ });
5695
+ var imageGenerationToolSettingsSchema = external_exports.discriminatedUnion("provider", [
5696
+ openAiCodexImageGenerationSettingsSchema
5697
+ ]);
5698
+ var profileIdSchema = external_exports.string().trim().min(1).max(256);
5699
+ function payloadOf(settings) {
5700
+ return external_exports.object({ enabled: external_exports.boolean().optional(), settings: settings.optional() }).strict();
5701
+ }
5702
+ var accountPayload = external_exports.object({
5703
+ enabled: external_exports.boolean().optional(),
5704
+ profileId: profileIdSchema.optional()
5705
+ }).strict();
5706
+ var quickScriptIntegrationSchema = external_exports.object({ enabled: external_exports.boolean(), profileId: profileIdSchema.optional() }).strict();
5707
+ var quickScriptToolSettingsSchema = external_exports.object({
5708
+ jira: quickScriptIntegrationSchema.optional(),
5709
+ confluence: quickScriptIntegrationSchema.optional(),
5710
+ web: quickScriptIntegrationSchema.optional(),
5711
+ diagram: krokiToolSettingsSchema.optional()
5712
+ }).strict();
5713
+ var capabilityToolPayloadSchemas = {
5714
+ python_exec: payloadOf(pythonExecToolSettingsSchema),
5715
+ web_search: accountPayload,
5716
+ web_fetch: payloadOf(external_exports.never()),
5717
+ explain_image: payloadOf(imageExplanationToolSettingsSchema),
5718
+ generate_image: payloadOf(imageGenerationToolSettingsSchema),
5719
+ kroki_export: payloadOf(krokiToolSettingsSchema),
5720
+ plan_present: payloadOf(planPresentToolSettingsSchema),
5721
+ subagents: payloadOf(external_exports.never()),
5722
+ jira: accountPayload,
5723
+ confluence: accountPayload,
5724
+ quick_script: payloadOf(quickScriptToolSettingsSchema),
5725
+ bash: external_exports.object({ settings: bashToolSettingsSchema }).strict()
5726
+ };
5727
+ var model = modelSelectionSchema.strict();
5728
+ var nonempty = (value) => Object.keys(value).length > 0;
5729
+ var compaction = external_exports.strictObject({
5730
+ auto: external_exports.boolean(),
5731
+ profile: compactionProfileSchema,
5732
+ customTriggerPercent: external_exports.number().int().min(60).max(90)
5733
+ });
5734
+ var retry = external_exports.strictObject({
5735
+ enabled: external_exports.boolean(),
5736
+ maxRetries: external_exports.number().int().nonnegative(),
5737
+ baseDelayMs: external_exports.number().int().positive()
5738
+ });
5739
+ var bash = bashToolSettingsSchema.extend({
5740
+ autoPromotion: bashToolSettingsSchema.shape.autoPromotion.strict(),
5741
+ maxTimeoutMs: bashToolSettingsSchema.shape.maxTimeoutMs.removeDefault()
5742
+ }).strict();
5743
+ var explanation = imageExplanationToolSettingsSchema.extend({ model: model.optional() }).strict();
5744
+ var generation = openAiCodexImageGenerationSettingsSchema.extend({
5745
+ options: openAiCodexImageGenerationSettingsSchema.shape.options.strict()
5746
+ }).strict();
5747
+ var sourceDefaults = external_exports.strictObject({
5748
+ file: external_exports.boolean(),
5749
+ nerve: external_exports.boolean(),
5750
+ agentBrowser: external_exports.boolean()
5751
+ });
5752
+ var skills = capabilitySkillsSchema.partial().extend({ defaults: sourceDefaults.partial().optional() }).strict();
5753
+ function payload(settings) {
5754
+ return external_exports.strictObject({
5755
+ enabled: external_exports.boolean().optional(),
5756
+ settings: settings.optional()
5757
+ }).refine(nonempty, "Empty tool entry");
5758
+ }
5759
+ var toggle = external_exports.strictObject({ enabled: external_exports.boolean() });
5760
+ var account = capabilityToolPayloadSchemas.jira.refine(nonempty, "Empty tool entry");
5761
+ var quickScriptIntegration = quickScriptIntegrationSchema.partial().refine(nonempty);
5762
+ var quickScriptOverrides = external_exports.strictObject({
5763
+ jira: quickScriptIntegration.optional(),
5764
+ confluence: quickScriptIntegration.optional(),
5765
+ web: quickScriptIntegration.optional(),
5766
+ diagram: krokiToolSettingsSchema.partial().refine(nonempty).optional()
5767
+ }).refine(nonempty);
5768
+ var childToolShape = {
5769
+ python_exec: payload(pythonExecToolSettingsSchema.partial()),
5770
+ web_search: account,
5771
+ jira: account,
5772
+ confluence: account,
5773
+ quick_script: payload(quickScriptOverrides),
5774
+ web_fetch: toggle,
5775
+ explain_image: payload(explanation.partial().refine(nonempty)),
5776
+ generate_image: payload(generation),
5777
+ kroki_export: payload(krokiToolSettingsSchema.partial().refine(nonempty)),
5778
+ bash: external_exports.strictObject({ settings: bash.partial().refine(nonempty) })
5779
+ };
5780
+ var leadTools = external_exports.strictObject({
5781
+ ...childToolShape,
5782
+ plan_present: payload(planPresentToolSettingsSchema.partial().refine(nonempty)),
5783
+ subagents: toggle
5784
+ }).partial();
5785
+ var childTools = external_exports.strictObject(childToolShape).partial();
5786
+ var launch = external_exports.strictObject({
5787
+ model: model.optional(),
5788
+ reasoningLevel: thinkingLevelSchema.optional()
5789
+ });
5790
+ var subagent = launch.extend({ enabled: external_exports.boolean().optional() }).refine(nonempty);
5791
+ var childShape = {
5792
+ model: model.optional(),
5793
+ reasoningLevel: thinkingLevelSchema.optional(),
5794
+ permissionRuleSetId: permissionRuleSetIdSchema.optional(),
5795
+ compaction: compaction.partial().optional(),
5796
+ retry: retry.partial().optional(),
5797
+ tools: childTools.optional(),
5798
+ skills: skills.optional()
5799
+ };
5800
+ var childSettingsOverridesSchema = external_exports.strictObject(childShape);
5801
+ var leadSettingsOverridesSchema = external_exports.strictObject({
5802
+ ...childShape,
5803
+ tools: leadTools.optional(),
5804
+ subagents: external_exports.record(agentProfileNameSchema, subagent).optional()
5805
+ });
5806
+ var completeTools = external_exports.strictObject({
5807
+ python_exec: external_exports.strictObject({
5808
+ enabled: external_exports.boolean(),
5809
+ settings: pythonExecToolSettingsSchema
5810
+ }),
5811
+ web_search: capabilityToolPayloadSchemas.web_search.required({
5812
+ enabled: true
5813
+ }),
5814
+ jira: capabilityToolPayloadSchemas.jira.required({ enabled: true }),
5815
+ confluence: capabilityToolPayloadSchemas.confluence.required({
5816
+ enabled: true
5817
+ }),
5818
+ // Optional: configurations frozen before this tool existed omit it (= off).
5819
+ quick_script: capabilityToolPayloadSchemas.quick_script.required({ enabled: true }).optional(),
5820
+ web_fetch: toggle,
5821
+ explain_image: external_exports.strictObject({
5822
+ enabled: external_exports.boolean(),
5823
+ settings: explanation
5824
+ }),
5825
+ generate_image: external_exports.strictObject({
5826
+ enabled: external_exports.boolean(),
5827
+ settings: generation
5828
+ }),
5829
+ kroki_export: external_exports.strictObject({
5830
+ enabled: external_exports.boolean(),
5831
+ settings: krokiToolSettingsSchema
5832
+ }),
5833
+ bash: external_exports.strictObject({ settings: bash })
5834
+ });
5835
+ var completeChildSettingsSchema = childSettingsOverridesSchema.extend({
5836
+ reasoningLevel: thinkingLevelSchema,
5837
+ permissionRuleSetId: permissionRuleSetIdSchema,
5838
+ compaction,
5839
+ retry,
5840
+ tools: completeTools,
5841
+ skills: capabilitySkillsSchema.extend({ defaults: sourceDefaults }).strict()
5842
+ });
5843
+ var sha256HexSchema = external_exports.string().regex(/^[a-f0-9]{64}$/);
5844
+ var revision = external_exports.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
5845
+ var contribution = {
5846
+ name: agentProfileNameSchema,
5847
+ source: external_exports.enum(["builtin", "user", "project"]),
5848
+ sourceDigest: sha256HexSchema,
5849
+ instructions: agentProfileInstructionsSchema
5850
+ };
5851
+ var profileSettingsOverridesSchema = leadSettingsOverridesSchema.extend({
5852
+ skills: capabilitySkillsSchema.partial().strict().optional()
5853
+ });
5854
+ var appliedProfileSchema = external_exports.strictObject({
5855
+ ...contribution,
5856
+ recommendations: profileSettingsOverridesSchema,
5857
+ requirements: profileSettingsOverridesSchema
5858
+ }).superRefine(checkOverlap);
5859
+ var agentPreferencesSchema = external_exports.strictObject({
5860
+ schemaVersion: external_exports.literal(1),
5861
+ revision,
5862
+ overrides: leadSettingsOverridesSchema
5863
+ });
5864
+ var receipt = external_exports.strictObject({
5865
+ id: external_exports.string().min(1),
5866
+ kind: external_exports.enum(["profile", "plan-approval"])
5867
+ });
5868
+ var conversationAgentContextSchema = external_exports.strictObject({
5869
+ instructions: agentProfileInstructionsSchema.optional(),
5870
+ systemPrompt: external_exports.string().optional()
5871
+ });
5872
+ var leadConversationAgentSchema = agentPreferencesSchema.extend({
5873
+ context: conversationAgentContextSchema.optional(),
5874
+ appliedProfile: appliedProfileSchema.nullable(),
5875
+ lastTransition: receipt.optional()
5876
+ });
5877
+ var childConversationAgentSchema = external_exports.strictObject({
5878
+ schemaVersion: external_exports.literal(1),
5879
+ revision,
5880
+ overrides: childSettingsOverridesSchema,
5881
+ appliedProfile: appliedProfileSchema.nullable(),
5882
+ frozenDefaults: completeChildSettingsSchema,
5883
+ context: conversationAgentContextSchema.optional(),
5884
+ lastTransition: receipt.optional()
5885
+ }).superRefine((v, ctx) => {
5886
+ if (v.appliedProfile)
5887
+ for (const section of ["recommendations", "requirements"]) {
5888
+ const parsed = childSettingsOverridesSchema.safeParse(v.appliedProfile[section]);
5889
+ if (!parsed.success)
5890
+ ctx.addIssue({
5891
+ code: "custom",
5892
+ path: ["appliedProfile", section],
5893
+ message: "Child-prohibited profile contribution"
5894
+ });
5895
+ }
5896
+ });
5897
+ var profileDefinitionSchema = external_exports.strictObject({
5898
+ schemaVersion: external_exports.literal(1),
5899
+ name: agentProfileNameSchema,
5900
+ label: external_exports.string().trim().min(1).max(AGENT_PROFILE_LABEL_MAX_LENGTH).optional(),
5901
+ whenToUse: external_exports.string().trim().min(1).max(AGENT_PROFILE_WHEN_TO_USE_MAX_LENGTH),
5902
+ /** Authored launch default (true if omitted), not availability or a requirement. */
5903
+ enabled: external_exports.boolean().optional(),
5904
+ usableBy: external_exports.enum(["lead", "subagent", "both"]),
5905
+ instructions: agentProfileInstructionsSchema,
5906
+ recommendations: profileSettingsOverridesSchema.optional(),
5907
+ requirements: profileSettingsOverridesSchema.optional()
5908
+ }).superRefine((v, ctx) => {
5909
+ checkOverlap(v, ctx);
5910
+ if (v.usableBy !== "lead") {
5911
+ for (const section of ["recommendations", "requirements"])
5912
+ if (v[section] && !childSettingsOverridesSchema.safeParse(v[section]).success)
5913
+ ctx.addIssue({
5914
+ code: "custom",
5915
+ path: [section],
5916
+ message: "Profile must be child-compatible"
5917
+ });
5918
+ }
5919
+ });
5920
+ var conversationDefaultsSchema = external_exports.strictObject({
5921
+ schemaVersion: external_exports.literal(1),
5922
+ revision,
5923
+ overrides: external_exports.strictObject({
5924
+ defaultAgentProfile: agentProfileNameSchema.optional(),
5925
+ scopedModels: external_exports.array(model).optional()
5926
+ })
5927
+ });
5928
+ var agentSummarySchema = external_exports.strictObject({
5929
+ model: model.optional(),
5930
+ reasoningLevel: thinkingLevelSchema.optional(),
5931
+ permissionRuleSetId: permissionRuleSetIdSchema.optional(),
5932
+ agentProfile: agentProfileNameSchema.optional()
5933
+ });
5934
+ var conversationAgentSummariesSchema = external_exports.strictObject({
5935
+ schemaVersion: external_exports.literal(1),
5936
+ entries: external_exports.record(external_exports.string().min(1), agentSummarySchema.extend({ observedDigest: sha256HexSchema }))
5937
+ });
5938
+ var configurationDiagnosticSchema = external_exports.strictObject({
5939
+ scope: external_exports.enum(["user", "project", "conversation"]),
5940
+ scopeId: external_exports.string().optional(),
5941
+ document: external_exports.string().min(1),
5942
+ path: external_exports.string(),
5943
+ schemaVersion: external_exports.number().int().optional(),
5944
+ code: external_exports.string().min(1),
5945
+ pointer: external_exports.string(),
5946
+ message: external_exports.string().optional(),
5947
+ affectedCapability: external_exports.string().min(1),
5948
+ recoveryChoices: external_exports.array(external_exports.enum(["retry", "reload", "repair", "reset", "upgrade"]))
5949
+ });
5950
+ var configurationSourceSchema = external_exports.enum([
5951
+ "builtin",
5952
+ "user",
5953
+ "project",
5954
+ "process",
5955
+ "recommendation",
5956
+ "conversation",
5957
+ "requirement",
5958
+ "frozen",
5959
+ "launch"
5960
+ ]);
5961
+ var fieldProvenanceSchema = external_exports.strictObject({
5962
+ source: configurationSourceSchema,
5963
+ profile: agentProfileNameSchema.optional(),
5964
+ adjusted: external_exports.boolean().optional()
5965
+ }).superRefine((value, ctx) => {
5966
+ if ((value.source === "requirement" || value.source === "recommendation") && !value.profile)
5967
+ ctx.addIssue({
5968
+ code: "custom",
5969
+ path: ["profile"],
5970
+ message: "Profile contributions must identify the controlling profile"
5971
+ });
5972
+ });
5973
+ var resolutionDiagnosticSchema = external_exports.strictObject({
5974
+ code: external_exports.enum([
5975
+ "model-required",
5976
+ "reasoning-adjusted",
5977
+ "unsupported-reasoning",
5978
+ "missing-reference"
5979
+ ]),
5980
+ pointer: external_exports.string()
5981
+ });
5982
+ var agentResolutionSchema = external_exports.strictObject({
5983
+ settings: leadSettingsOverridesSchema,
5984
+ provenance: external_exports.record(external_exports.string().regex(/^\/(?:[^~]|~[01])*$/), fieldProvenanceSchema),
5985
+ diagnostics: external_exports.array(resolutionDiagnosticSchema)
5986
+ });
5987
+ function escapePointer(value) {
5988
+ return value.replaceAll("~", "~0").replaceAll("/", "~1");
5989
+ }
5990
+ function canonicalSettingsEntries(value) {
5991
+ const entries = [];
5992
+ function walk2(node, path) {
5993
+ const atomic = /(?:^|\/)model$/.test(path) || path === "/tools/generate_image/settings" || path === "/tools/bash/settings/autoPromotion";
5994
+ if (node !== void 0 && (atomic || typeof node !== "object" || node === null || Array.isArray(node)))
5995
+ entries.push([path, node]);
5996
+ else if (node)
5997
+ for (const [key2, child] of Object.entries(node))
5998
+ walk2(child, `${path}/${escapePointer(key2)}`);
5999
+ }
6000
+ walk2(value, "");
6001
+ return entries;
6002
+ }
6003
+ function requirementOverlaps(recommendations = {}, requirements = {}) {
6004
+ const a = canonicalSettingsEntries(recommendations).map(([p]) => p), b = canonicalSettingsEntries(requirements).map(([p]) => p);
6005
+ function overlaps(x, y) {
6006
+ if (x === y || x.startsWith(y + "/") || y.startsWith(x + "/"))
6007
+ return true;
6008
+ const source = (p) => p.startsWith("/skills/defaults/") ? p.slice(17) : p.startsWith("/skills/") ? p.split("/")[2] : void 0;
6009
+ return source(x) !== void 0 && source(x) === source(y) && (x.startsWith("/skills/defaults/") || y.startsWith("/skills/defaults/"));
6010
+ }
6011
+ return a.filter((x) => b.some((y) => overlaps(x, y)));
6012
+ }
6013
+ function checkOverlap(v, ctx) {
6014
+ for (const pointer of requirementOverlaps(v.recommendations, v.requirements))
6015
+ ctx.addIssue({
6016
+ code: "custom",
6017
+ path: ["requirements"],
6018
+ message: `Recommendation/requirement overlap: ${pointer}`
6019
+ });
6020
+ }
6021
+
5648
6022
  // packages/workbench-server/dist/infrastructure/migrations/steps/0002-agent-profiles/released-baseline.json
5649
6023
  var released_baseline_default = {
5650
6024
  harness: {
@@ -5899,7 +6273,7 @@ var optionalTools = [
5899
6273
  "confluence"
5900
6274
  ];
5901
6275
  var rename = (name) => name === "plan_mode_present" ? "plan_present" : name === "explore" || name.startsWith("subagent_") ? "subagents" : name;
5902
- function compaction(value, report) {
6276
+ function compaction2(value, report) {
5903
6277
  const result = structuredClone(value);
5904
6278
  for (const key2 of ["customKeepRecentPercent", "keepRecentPercent"])
5905
6279
  if (key2 in result) {
@@ -5967,7 +6341,7 @@ function convertPreferencesV037(input, ctx) {
5967
6341
  if (raw.scopedModels !== void 0)
5968
6342
  creation.scopedModels = raw.scopedModels;
5969
6343
  if (raw.compaction)
5970
- overrides.compaction = compaction(raw.compaction, ctx.report);
6344
+ overrides.compaction = compaction2(raw.compaction, ctx.report);
5971
6345
  if (raw.retry)
5972
6346
  overrides.retry = raw.retry;
5973
6347
  const tools = {};
@@ -6037,9 +6411,9 @@ function convertPreferencesV037(input, ctx) {
6037
6411
  const lower = ctx.inheritedSettings ?? {};
6038
6412
  if (overrides.model)
6039
6413
  overrides.model = { ...lower.model, ...overrides.model };
6040
- const generation = overrides.tools?.generate_image?.settings;
6041
- if (generation && raw.tools?.imageGeneration && !input.capabilities?.toolSettings?.generate_image)
6042
- overrides.tools.generate_image.settings = merge(merge(released_baseline_default.harness.tools.imageGeneration, lower.tools?.generate_image?.settings ?? {}), generation);
6414
+ const generation2 = overrides.tools?.generate_image?.settings;
6415
+ if (generation2 && raw.tools?.imageGeneration && !input.capabilities?.toolSettings?.generate_image)
6416
+ overrides.tools.generate_image.settings = merge(merge(released_baseline_default.harness.tools.imageGeneration, lower.tools?.generate_image?.settings ?? {}), generation2);
6043
6417
  const promotion = overrides.tools?.bash?.settings?.autoPromotion;
6044
6418
  if (promotion)
6045
6419
  overrides.tools.bash.settings.autoPromotion = {
@@ -6047,11 +6421,11 @@ function convertPreferencesV037(input, ctx) {
6047
6421
  ...lower.tools?.bash?.settings?.autoPromotion,
6048
6422
  ...promotion
6049
6423
  };
6050
- const explanation = overrides.tools?.explain_image?.settings;
6051
- if (explanation?.model)
6052
- explanation.model = {
6424
+ const explanation2 = overrides.tools?.explain_image?.settings;
6425
+ if (explanation2?.model)
6426
+ explanation2.model = {
6053
6427
  ...lower.tools?.explain_image?.settings?.model,
6054
- ...explanation.model
6428
+ ...explanation2.model
6055
6429
  };
6056
6430
  }
6057
6431
  const integrations = integration ? { ...integration, version: 2 } : void 0;
@@ -6076,9 +6450,9 @@ function splitCatalogV037(input, scope, ctx) {
6076
6450
  const launches = {}, profiles = {};
6077
6451
  for (const [name, value] of Object.entries(catalog.profiles)) {
6078
6452
  const raw = value;
6079
- const launch = {};
6453
+ const launch2 = {};
6080
6454
  if (raw.enabled !== void 0)
6081
- launch.enabled = raw.enabled;
6455
+ launch2.enabled = raw.enabled;
6082
6456
  for (const [field, key2] of [
6083
6457
  ["model", "model"],
6084
6458
  ["thinking", "reasoningLevel"]
@@ -6089,16 +6463,16 @@ function splitCatalogV037(input, scope, ctx) {
6089
6463
  if (field === "model") {
6090
6464
  const slash = raw.model.indexOf("/");
6091
6465
  assert18(slash > 0, "Invalid released model reference");
6092
- launch.model = {
6466
+ launch2.model = {
6093
6467
  provider: raw.model.slice(0, slash),
6094
6468
  modelId: raw.model.slice(slash + 1)
6095
6469
  };
6096
6470
  } else
6097
- launch[key2] = raw[field];
6471
+ launch2[key2] = raw[field];
6098
6472
  }
6099
6473
  }
6100
- if (Object.keys(launch).length)
6101
- launches[name] = launch;
6474
+ if (Object.keys(launch2).length)
6475
+ launches[name] = launch2;
6102
6476
  const other = Object.keys(raw).filter((key2) => !["enabled", "model", "thinking"].includes(key2));
6103
6477
  if (scope === "conversation") {
6104
6478
  if (other.length)
@@ -6109,12 +6483,12 @@ function splitCatalogV037(input, scope, ctx) {
6109
6483
  continue;
6110
6484
  const complete = merge(Object.hasOwn(ctx.builtins, name) ? ctx.builtins[name] : {}, raw);
6111
6485
  assert18(complete.description && complete.instructions !== void 0 && complete.model !== void 0 && complete.thinking !== void 0 && complete.permission !== void 0 && complete.compaction !== void 0 && complete.skills !== void 0, `Incomplete custom released profile: ${name}`);
6112
- const recommendations = { ...launch };
6486
+ const recommendations = { ...launch2 };
6113
6487
  delete recommendations.enabled;
6114
6488
  if (complete.permission !== void 0)
6115
6489
  recommendations.permissionRuleSetId = complete.permission;
6116
6490
  if (complete.compaction && complete.compaction !== "inherit")
6117
- recommendations.compaction = compaction(complete.compaction, ctx.report);
6491
+ recommendations.compaction = compaction2(complete.compaction, ctx.report);
6118
6492
  for (const [tool, settings] of Object.entries(complete.tools ?? {}))
6119
6493
  (recommendations.tools ??= {})[rename(tool)] = typeof settings === "boolean" ? { enabled: settings } : { settings };
6120
6494
  if (complete.skills && complete.skills !== "none" && complete.skills !== "inherit")
@@ -6166,7 +6540,7 @@ function convertConversationV037(row2, input, ctx) {
6166
6540
  if (input.harness !== void 0) {
6167
6541
  const own2 = releasedConversationHarnessSchema.parse(input.harness);
6168
6542
  if (own2.compaction)
6169
- overrides.compaction = compaction(own2.compaction, ctx.report);
6543
+ overrides.compaction = compaction2(own2.compaction, ctx.report);
6170
6544
  }
6171
6545
  if (input.subagents !== void 0)
6172
6546
  overrides.subagents = splitCatalogV037(input.subagents, "conversation", ctx).launches;
@@ -6330,20 +6704,20 @@ function documentFiles(home, projects, conversations) {
6330
6704
  return result;
6331
6705
  }
6332
6706
  function convertEventPayload(value) {
6333
- const payload = record3(structuredClone(value));
6334
- assert19(payload, "Expected event payload");
6335
- if (Array.isArray(payload.content))
6336
- for (const block of payload.content) {
6707
+ const payload2 = record3(structuredClone(value));
6708
+ assert19(payload2, "Expected event payload");
6709
+ if (Array.isArray(payload2.content))
6710
+ for (const block of payload2.content) {
6337
6711
  const entry2 = record3(block);
6338
6712
  if (entry2?.type === "toolCall")
6339
6713
  entry2.name = toolName(entry2.name);
6340
6714
  }
6341
- if (Object.hasOwn(payload, "toolName"))
6342
- payload.toolName = toolName(payload.toolName);
6343
- const projection = record3(payload.userProjection);
6715
+ if (Object.hasOwn(payload2, "toolName"))
6716
+ payload2.toolName = toolName(payload2.toolName);
6717
+ const projection = record3(payload2.userProjection);
6344
6718
  if (projection && Object.hasOwn(projection, "toolName"))
6345
6719
  projection.toolName = toolName(projection.toolName);
6346
- return payload;
6720
+ return payload2;
6347
6721
  }
6348
6722
  function parsePolicySource(bytes, path, report) {
6349
6723
  try {
@@ -6430,15 +6804,15 @@ function planMetadata(input) {
6430
6804
  for (const event of input.events) {
6431
6805
  const before = JSON.parse(event.payload);
6432
6806
  const after = convertEventPayload(before);
6433
- const payload = objectValue(after);
6807
+ const payload2 = objectValue(after);
6434
6808
  const reasons = [];
6435
6809
  if (JSON.stringify(before) !== JSON.stringify(after))
6436
6810
  reasons.push("Renamed historical planning tool metadata in conversation_event.payload");
6437
- const resolution = objectValue(payload.interactionResolution);
6811
+ const resolution = objectValue(payload2.interactionResolution);
6438
6812
  if (resolution?.kind === "plan_review" && resolution.decision === "approve" && !Object.hasOwn(resolution, "confirmation")) {
6439
- assert21(typeof payload.toolCallId === "string", "Missing historical plan-review tool call ID");
6440
- const id = payload.toolCallId;
6441
- const request = requests.get(id) ?? historicalReviewRequest({ approvalProfile: objectValue(payload.arguments)?.approvalProfile }, id);
6813
+ assert21(typeof payload2.toolCallId === "string", "Missing historical plan-review tool call ID");
6814
+ const id = payload2.toolCallId;
6815
+ const request = requests.get(id) ?? historicalReviewRequest({ approvalProfile: objectValue(payload2.arguments)?.approvalProfile }, id);
6442
6816
  if (historicalReviewConfirmation(resolution, request, id))
6443
6817
  reasons.push(eventConfirmationReason);
6444
6818
  }
@@ -6757,87 +7131,87 @@ function prepareExport(io2, input) {
6757
7131
  }
6758
7132
  function applyExport(io2, receiptPath, proposed) {
6759
7133
  const saved = io2.read(receiptPath);
6760
- const receipt2 = exportReceiptSchema.parse(saved === void 0 ? proposed : JSON.parse(saved));
7134
+ const receipt3 = exportReceiptSchema.parse(saved === void 0 ? proposed : JSON.parse(saved));
6761
7135
  if (saved !== void 0)
6762
- assert23.deepEqual(receipt2, proposed, "Changed migration plan");
6763
- for (const [path, source] of Object.entries(receipt2.sources)) {
7136
+ assert23.deepEqual(receipt3, proposed, "Changed migration plan");
7137
+ for (const [path, source] of Object.entries(receipt3.sources)) {
6764
7138
  const bytes = io2.read(path), backup2 = io2.read(source.backup);
6765
7139
  if (backup2 !== void 0)
6766
7140
  assert23.equal(sha256(backup2), source.digest, "Changed original backup");
6767
- const candidate = receipt2.targets[path];
7141
+ const candidate = receipt3.targets[path];
6768
7142
  assert23(bytes !== void 0 && (sha256(bytes) === source.digest || saved !== void 0 && candidate && sha256(bytes) === candidate.digest), `Changed migration source: ${path}`);
6769
7143
  if (backup2 === void 0) {
6770
7144
  assert23.equal(sha256(bytes), source.digest, "Original missing before backup");
6771
7145
  io2.write(source.backup, bytes);
6772
7146
  }
6773
7147
  }
6774
- for (const [path, output] of Object.entries(receipt2.targets)) {
7148
+ for (const [path, output] of Object.entries(receipt3.targets)) {
6775
7149
  validateTarget(output);
6776
7150
  const actual = io2.read(path);
6777
- assert23(actual === void 0 || receipt2.sources[path] && sha256(actual) === receipt2.sources[path].digest || saved !== void 0 && sha256(actual) === output.digest, `Migration target collision or later edit: ${path}`);
7151
+ assert23(actual === void 0 || receipt3.sources[path] && sha256(actual) === receipt3.sources[path].digest || saved !== void 0 && sha256(actual) === output.digest, `Migration target collision or later edit: ${path}`);
6778
7152
  }
6779
7153
  if (saved === void 0)
6780
- io2.write(receiptPath, jsonBytes(receipt2));
6781
- for (const [path, output] of Object.entries(receipt2.targets)) {
7154
+ io2.write(receiptPath, jsonBytes(receipt3));
7155
+ for (const [path, output] of Object.entries(receipt3.targets)) {
6782
7156
  if (io2.read(path) !== output.bytes)
6783
7157
  io2.write(path, output.bytes);
6784
7158
  assert23.equal(io2.read(path), output.bytes, "Export readback mismatch");
6785
7159
  }
6786
7160
  }
6787
- function verifyExport(io2, receipt2, expectedRowDigest, allowRetired = false) {
6788
- exportReceiptSchema.parse(receipt2);
6789
- assert23.equal(receipt2.rowDigest, expectedRowDigest, "Released database row changed since export");
6790
- for (const [path, source] of Object.entries(receipt2.sources)) {
7161
+ function verifyExport(io2, receipt3, expectedRowDigest, allowRetired = false) {
7162
+ exportReceiptSchema.parse(receipt3);
7163
+ assert23.equal(receipt3.rowDigest, expectedRowDigest, "Released database row changed since export");
7164
+ for (const [path, source] of Object.entries(receipt3.sources)) {
6791
7165
  const current = io2.read(path);
6792
- if (!(allowRetired && current === void 0 && receipt2.retire.includes(path))) {
6793
- assert23(current !== void 0 && sha256(current) === (receipt2.targets[path]?.digest ?? source.digest), `Source changed after export: ${path}`);
7166
+ if (!(allowRetired && current === void 0 && receipt3.retire.includes(path))) {
7167
+ assert23(current !== void 0 && sha256(current) === (receipt3.targets[path]?.digest ?? source.digest), `Source changed after export: ${path}`);
6794
7168
  }
6795
7169
  const original = io2.read(source.backup);
6796
7170
  assert23(original !== void 0 && sha256(original) === source.digest, "Missing or changed protected original");
6797
7171
  }
6798
- for (const [path, output] of Object.entries(receipt2.targets)) {
7172
+ for (const [path, output] of Object.entries(receipt3.targets)) {
6799
7173
  validateTarget(output);
6800
7174
  assert23.equal(io2.read(path), output.bytes, `Missing or changed export: ${path}`);
6801
7175
  }
6802
7176
  }
6803
- function retireExportSources(io2, receipt2) {
6804
- verifyExport(io2, receipt2, receipt2.rowDigest, true);
6805
- for (const path of receipt2.retire) {
6806
- assert23(!receipt2.targets[path] && receipt2.sources[path], "Invalid source retirement");
7177
+ function retireExportSources(io2, receipt3) {
7178
+ verifyExport(io2, receipt3, receipt3.rowDigest, true);
7179
+ for (const path of receipt3.retire) {
7180
+ assert23(!receipt3.targets[path] && receipt3.sources[path], "Invalid source retirement");
6807
7181
  const bytes = io2.read(path);
6808
7182
  if (bytes === void 0)
6809
7183
  continue;
6810
- assert23.equal(sha256(bytes), receipt2.sources[path].digest, "Source changed before retirement");
7184
+ assert23.equal(sha256(bytes), receipt3.sources[path].digest, "Source changed before retirement");
6811
7185
  io2.remove(path);
6812
7186
  }
6813
7187
  }
6814
- function preflightRollbackExport(io2, receipt2) {
6815
- for (const [path, output] of Object.entries(receipt2.targets)) {
7188
+ function preflightRollbackExport(io2, receipt3) {
7189
+ for (const [path, output] of Object.entries(receipt3.targets)) {
6816
7190
  const current = io2.read(path);
6817
- assert23(current === void 0 || sha256(current) === output.digest || receipt2.sources[path] && sha256(current) === receipt2.sources[path].digest, `Rollback conflicts with later edit: ${path}`);
7191
+ assert23(current === void 0 || sha256(current) === output.digest || receipt3.sources[path] && sha256(current) === receipt3.sources[path].digest, `Rollback conflicts with later edit: ${path}`);
6818
7192
  }
6819
- for (const [path, source] of Object.entries(receipt2.sources)) {
7193
+ for (const [path, source] of Object.entries(receipt3.sources)) {
6820
7194
  const backup2 = io2.read(source.backup), current = io2.read(path);
6821
7195
  assert23(backup2 !== void 0 && sha256(backup2) === source.digest, "Rollback original unavailable");
6822
- assert23(current === void 0 || sha256(current) === source.digest || receipt2.targets[path] && sha256(current) === receipt2.targets[path].digest, `Rollback source conflicts with later edit: ${path}`);
7196
+ assert23(current === void 0 || sha256(current) === source.digest || receipt3.targets[path] && sha256(current) === receipt3.targets[path].digest, `Rollback source conflicts with later edit: ${path}`);
6823
7197
  }
6824
7198
  }
6825
- function rollbackExport(io2, receipt2) {
6826
- preflightRollbackExport(io2, receipt2);
6827
- for (const path of Object.keys(receipt2.targets))
6828
- if (!receipt2.sources[path])
7199
+ function rollbackExport(io2, receipt3) {
7200
+ preflightRollbackExport(io2, receipt3);
7201
+ for (const path of Object.keys(receipt3.targets))
7202
+ if (!receipt3.sources[path])
6829
7203
  io2.remove(path);
6830
- for (const [path, source] of Object.entries(receipt2.sources))
7204
+ for (const [path, source] of Object.entries(receipt3.sources))
6831
7205
  io2.write(path, io2.read(source.backup));
6832
7206
  }
6833
7207
 
6834
7208
  // packages/workbench-server/dist/infrastructure/migrations/steps/0002-agent-profiles/released-scope-targets.js
6835
- function isolateScopeTargets(root, input, io2, targets) {
7209
+ function isolateScopeTargets(root, input, io2, targets2) {
6836
7210
  try {
6837
- for (const path of Object.keys(targets))
7211
+ for (const path of Object.keys(targets2))
6838
7212
  if (!input.snapshots.has(path) && io2.read(path) !== void 0)
6839
7213
  throw new Error(`Existing conversion target requires manual reconciliation: ${path}`);
6840
- return targets;
7214
+ return targets2;
6841
7215
  } catch (cause) {
6842
7216
  const error = legacyScopeFailure(cause, root, io2);
6843
7217
  if (!(error instanceof LegacyScopeError))
@@ -6847,7 +7221,7 @@ function isolateScopeTargets(root, input, io2, targets) {
6847
7221
  }
6848
7222
  }
6849
7223
  function releasedScopeTargets(root, scope, before, context, result) {
6850
- const targets = {};
7224
+ const targets2 = {};
6851
7225
  if (before.subagents) {
6852
7226
  const split = splitCatalogV037(before.subagents, scope, context);
6853
7227
  if (Object.keys(split.launches).length)
@@ -6855,15 +7229,15 @@ function releasedScopeTargets(root, scope, before, context, result) {
6855
7229
  subagents: split.launches
6856
7230
  });
6857
7231
  for (const [name, profile] of Object.entries(split.profiles))
6858
- targets[join17(root, scope === "project" ? "agent-profiles" : "data/agent-profiles", name + ".json")] = exportedTarget("profile", profile);
7232
+ targets2[join17(root, scope === "project" ? "agent-profiles" : "data/agent-profiles", name + ".json")] = exportedTarget("profile", profile);
6859
7233
  }
6860
7234
  if (Object.keys(result.agent.overrides).length)
6861
- targets[join17(root, "config/agent.json")] = exportedTarget("preferences", result.agent);
7235
+ targets2[join17(root, "config/agent.json")] = exportedTarget("preferences", result.agent);
6862
7236
  if (Object.keys(result.creation.overrides).length)
6863
- targets[join17(root, "config/conversation-defaults.json")] = exportedTarget("creation", result.creation);
7237
+ targets2[join17(root, "config/conversation-defaults.json")] = exportedTarget("creation", result.creation);
6864
7238
  if (result.integrations)
6865
- targets[join17(root, "config/integrations.json")] = exportedTarget("integrations", result.integrations);
6866
- return targets;
7239
+ targets2[join17(root, "config/integrations.json")] = exportedTarget("integrations", result.integrations);
7240
+ return targets2;
6867
7241
  }
6868
7242
 
6869
7243
  // packages/workbench-server/dist/infrastructure/migrations/steps/0002-agent-profiles/released-archive.js
@@ -6946,24 +7320,24 @@ async function verifyConversationExports(io2, rows, receipts, allowRetired = fal
6946
7320
  assert25.equal(expected.size, rows.length, "Duplicate released conversation row");
6947
7321
  const seen = /* @__PURE__ */ new Set();
6948
7322
  await progress?.(0);
6949
- for (const receipt2 of receipts) {
6950
- if (receipt2.rowDigest === void 0)
7323
+ for (const receipt3 of receipts) {
7324
+ if (receipt3.rowDigest === void 0)
6951
7325
  continue;
6952
- const id = receipt2.identity.replace(/^conversation:/, "");
6953
- assert25(receipt2.identity === `conversation:${id}` && expected.has(id), "Export has no released conversation row");
7326
+ const id = receipt3.identity.replace(/^conversation:/, "");
7327
+ assert25(receipt3.identity === `conversation:${id}` && expected.has(id), "Export has no released conversation row");
6954
7328
  assert25(!seen.has(id), "Duplicate conversation export");
6955
7329
  seen.add(id);
6956
7330
  const row2 = expected.get(id);
6957
- verifyExport(io2, receipt2, releasedRowDigest(row2), allowRetired);
6958
- const targets = Object.values(receipt2.targets).filter((target3) => target3.kind === "lead" || target3.kind === "child");
6959
- assert25.equal(targets.length, 1, "Conversation export must own exactly one agent document");
6960
- const document = JSON.parse(targets[0].bytes);
6961
- if (!receipt2.report.includes("Conversation settings set aside; see quarantine"))
7331
+ verifyExport(io2, receipt3, releasedRowDigest(row2), allowRetired);
7332
+ const targets2 = Object.values(receipt3.targets).filter((target3) => target3.kind === "lead" || target3.kind === "child");
7333
+ assert25.equal(targets2.length, 1, "Conversation export must own exactly one agent document");
7334
+ const document = JSON.parse(targets2[0].bytes);
7335
+ if (!receipt3.report.includes("Conversation settings set aside; see quarantine"))
6962
7336
  assert25.deepEqual(document.context ?? {}, {
6963
7337
  ...row2.instructions !== null ? { instructions: row2.instructions } : {},
6964
7338
  ...row2.system_prompt !== null ? { systemPrompt: row2.system_prompt } : {}
6965
7339
  }, "Conversation prompt context differs from released SQL");
6966
- assert25.equal(targets[0].kind, row2.parent_conversation_id ? "child" : "lead", "Conversation export role changed");
7340
+ assert25.equal(targets2[0].kind, row2.parent_conversation_id ? "child" : "lead", "Conversation export role changed");
6967
7341
  await progress?.(seen.size);
6968
7342
  }
6969
7343
  assert25.equal(seen.size, expected.size, "Unverified conversation rows remain; SQL destruction is forbidden");
@@ -7091,8 +7465,8 @@ async function executeReleasedMigration(db, files, progress) {
7091
7465
  }
7092
7466
  async function retireReleasedSources(files) {
7093
7467
  await files.verifyFiles();
7094
- for (const receipt2 of files.receipts)
7095
- await files.retire(receipt2);
7468
+ for (const receipt3 of files.receipts)
7469
+ await files.retire(receipt3);
7096
7470
  }
7097
7471
 
7098
7472
  // packages/workbench-server/dist/infrastructure/migrations/steps/0002-agent-profiles/released-schema-verification.js
@@ -7154,20 +7528,20 @@ var databaseBackupReceiptSchema = external_exports.object({
7154
7528
  planDigest: external_exports.string().regex(/^[a-f0-9]{64}$/),
7155
7529
  digest: external_exports.string().regex(/^[a-f0-9]{64}$/).optional()
7156
7530
  }).strict().refine((value) => value.phase !== "ready" || value.digest !== void 0, "Ready backup requires a digest");
7157
- function receipt(io2, path) {
7531
+ function receipt2(io2, path) {
7158
7532
  const bytes = io2.read(path);
7159
7533
  if (bytes === void 0)
7160
7534
  return void 0;
7161
7535
  return databaseBackupReceiptSchema.parse(JSON.parse(typeof bytes === "string" ? bytes : Buffer.from(bytes).toString("utf8")));
7162
7536
  }
7163
7537
  function verifyDatabaseBackup(io2, receiptPath, target3, planDigest) {
7164
- const saved = receipt(io2, receiptPath);
7538
+ const saved = receipt2(io2, receiptPath);
7165
7539
  assert27(saved?.phase === "ready" && saved.target === target3 && saved.planDigest === planDigest, "Database backup is not bound to this conversion plan");
7166
7540
  const bytes = io2.read(target3);
7167
7541
  assert27(bytes !== void 0 && sha256(bytes) === saved.digest, "Original database backup changed");
7168
7542
  }
7169
7543
  async function preserveDatabaseBackup(io2, input) {
7170
- let saved = receipt(io2, input.receiptPath);
7544
+ let saved = receipt2(io2, input.receiptPath);
7171
7545
  if (!saved) {
7172
7546
  assert27(io2.read(input.target) === void 0, "Unowned database backup collision");
7173
7547
  saved = {
@@ -7494,11 +7868,11 @@ async function restoreReleasedDatabase(ctx, plan, archiveDirectory) {
7494
7868
  const path = join20(directory, "original.sqlite"), receiptPath = join20(directory, "receipt.json");
7495
7869
  if (!existsSync17(receiptPath))
7496
7870
  return;
7497
- const receipt2 = databaseBackupReceiptSchema.parse(json(receiptPath));
7498
- assert28.equal(receipt2.planDigest, sha256(jsonBytes(plan)), "Rollback plan does not own database backup");
7499
- if (receipt2.phase === "planned")
7871
+ const receipt3 = databaseBackupReceiptSchema.parse(json(receiptPath));
7872
+ assert28.equal(receipt3.planDigest, sha256(jsonBytes(plan)), "Rollback plan does not own database backup");
7873
+ if (receipt3.phase === "planned")
7500
7874
  return;
7501
- assert28.equal(receipt2.phase, "ready");
7875
+ assert28.equal(receipt3.phase, "ready");
7502
7876
  const checker = new ReleasedSqliteBackend(ctx, plan, async () => {
7503
7877
  }, archiveDirectory);
7504
7878
  try {
@@ -7511,7 +7885,7 @@ async function restoreReleasedDatabase(ctx, plan, archiveDirectory) {
7511
7885
  checker.close();
7512
7886
  }
7513
7887
  const bytes = readFileSync8(path);
7514
- assert28.equal(sha256(bytes), receipt2.digest);
7888
+ assert28.equal(sha256(bytes), receipt3.digest);
7515
7889
  for (const suffix of ["-wal", "-shm"])
7516
7890
  rmSync9(ctx.paths.sqlitePath + suffix, { force: true });
7517
7891
  writeProtected(ctx.paths.sqlitePath, bytes);
@@ -7573,26 +7947,26 @@ async function planExports(ctx) {
7573
7947
  const user = userInput.before;
7574
7948
  const receipts = [], rows = {}, trust = [];
7575
7949
  const claimed = /* @__PURE__ */ new Set();
7576
- function add(identity, root, targets, sources, retire, report, rowDigest) {
7577
- for (const path2 of Object.keys(targets)) {
7950
+ function add(identity, root, targets2, sources, retire, report, rowDigest) {
7951
+ for (const path2 of Object.keys(targets2)) {
7578
7952
  assert29(!claimed.has(path2), `Duplicate conversion target: ${path2}`);
7579
7953
  claimed.add(path2);
7580
7954
  }
7581
- ctx.ownPaths([...sources, ...Object.keys(targets)], root);
7955
+ ctx.ownPaths([...sources, ...Object.keys(targets2)], root);
7582
7956
  const path = join21(archiveRoot(ctx), sha256(identity), "receipt.json");
7583
7957
  for (const source of sources)
7584
7958
  assert29.equal(sha256(files.read(source)), snapshots.get(source), "Source changed while planning conversion");
7585
- const receipt2 = prepareExport(files, {
7959
+ const receipt3 = prepareExport(files, {
7586
7960
  identity,
7587
7961
  backupDirectory: join21(archiveRoot(ctx), sha256(identity)),
7588
7962
  sources,
7589
- targets,
7963
+ targets: targets2,
7590
7964
  rowDigest,
7591
7965
  retire,
7592
7966
  report
7593
7967
  });
7594
- receipts.push({ path, receipt: receipt2 });
7595
- return receipt2;
7968
+ receipts.push({ path, receipt: receipt3 });
7969
+ return receipt3;
7596
7970
  }
7597
7971
  const convertScopes = phaseProgress(ctx, "scope-settings", "Converting user settings", 1);
7598
7972
  await convertScopes();
@@ -7614,7 +7988,7 @@ async function planExports(ctx) {
7614
7988
  for (const [path, digest5] of input.snapshots)
7615
7989
  snapshots.set(path, digest5);
7616
7990
  const result = convertPreferencesV037({ ...before, scope: "user" }, context);
7617
- const targets = input.issues.length ? {} : isolateScopeTargets(root, input, files, releasedScopeTargets(root, "user", before, context, result));
7991
+ const targets2 = input.issues.length ? {} : isolateScopeTargets(root, input, files, releasedScopeTargets(root, "user", before, context, result));
7618
7992
  for (const issue of input.issues)
7619
7993
  ctx.quarantine({ kind: "configuration", id: issue.path, reason: issue.reason }, { files: [issue.path], retainSource: true });
7620
7994
  for (const message of scopeIssueReport(input.issues))
@@ -7635,12 +8009,12 @@ async function planExports(ctx) {
7635
8009
  reason: "Invalid policy JSON"
7636
8010
  }, { files: [file.path], retainSource: true });
7637
8011
  if (JSON.stringify(before2) !== JSON.stringify(after)) {
7638
- targets[file.path] = exportedTarget("metadata", after);
8012
+ targets2[file.path] = exportedTarget("metadata", after);
7639
8013
  sources.push(file.path);
7640
8014
  report.push(`Converted planning-tool metadata: ${file.path}`);
7641
8015
  }
7642
8016
  }
7643
- add(`scope:${root}`, root, targets, sources, sources.filter((path) => !input.issues.length && !Object.hasOwn(targets, path)), report);
8017
+ add(`scope:${root}`, root, targets2, sources, sources.filter((path) => !input.issues.length && !Object.hasOwn(targets2, path)), report);
7644
8018
  await convertScopes(++convertedScopes);
7645
8019
  }
7646
8020
  const convertConversations = phaseProgress(ctx, "conversation-settings", "Converting conversation settings", original.rows.length);
@@ -7806,10 +8180,10 @@ function completion(ctx, plan) {
7806
8180
  await progress(++done);
7807
8181
  }
7808
8182
  },
7809
- async retire(receipt2) {
8183
+ async retire(receipt3) {
7810
8184
  if (retired === 0)
7811
8185
  await retireProgress();
7812
- retireExportSources(io(ctx), receipt2);
8186
+ retireExportSources(io(ctx), receipt3);
7813
8187
  await retireProgress(++retired);
7814
8188
  },
7815
8189
  committed() {
@@ -8304,12 +8678,517 @@ var step_default4 = defineStep({
8304
8678
  }
8305
8679
  });
8306
8680
 
8681
+ // packages/workbench-server/dist/infrastructure/migrations/steps/0005-extension-settings/step.js
8682
+ import { existsSync as existsSync22, lstatSync as lstatSync13, readdirSync as readdirSync11, readFileSync as readFileSync12 } from "node:fs";
8683
+ import { join as join24 } from "node:path";
8684
+
8685
+ // packages/workbench-server/dist/infrastructure/migrations/steps/0005-extension-settings/accounts.js
8686
+ import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
8687
+ import { existsSync as existsSync21, readFileSync as readFileSync11 } from "node:fs";
8688
+
8689
+ // packages/workbench-server/dist/infrastructure/migrations/steps/0005-extension-settings/convert.js
8690
+ var KROKI_DEFAULT = "https://kroki.io/";
8691
+ var isRecord2 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
8692
+ var omit = (value, key2) => Object.fromEntries(Object.entries(value).filter(([name]) => name !== key2));
8693
+ var string = (value) => typeof value === "string" && value.trim() ? value : void 0;
8694
+ var boolean = (value) => typeof value === "boolean" ? value : void 0;
8695
+ var REMOVED_TOOLS = /* @__PURE__ */ new Set([
8696
+ "jira",
8697
+ "confluence",
8698
+ "generate_image",
8699
+ "kroki_export",
8700
+ "explain_image"
8701
+ ]);
8702
+ var IMAGEGEN_DEFAULTS = {
8703
+ backend: "openai-codex",
8704
+ model: "gpt-image-2.5-flare",
8705
+ quality: "auto",
8706
+ size: "auto",
8707
+ background: "auto"
8708
+ };
8709
+ function imageGenerationEntry(tool, complete) {
8710
+ if (!isRecord2(tool))
8711
+ return void 0;
8712
+ const settings = isRecord2(tool.settings) ? tool.settings : {};
8713
+ const options = isRecord2(settings.options) ? settings.options : {};
8714
+ const values = {};
8715
+ const set = (key2, value) => {
8716
+ const text3 = string(value);
8717
+ if (text3 && !(complete && text3 === IMAGEGEN_DEFAULTS[key2]))
8718
+ values[key2] = text3;
8719
+ };
8720
+ set("backend", settings.provider);
8721
+ set("model", settings.model);
8722
+ set("quality", options.quality);
8723
+ set("size", options.size);
8724
+ set("background", options.background);
8725
+ const enabled = boolean(tool.enabled);
8726
+ if (enabled === void 0 && Object.keys(values).length === 0)
8727
+ return void 0;
8728
+ return {
8729
+ version: 1,
8730
+ ...enabled !== void 0 ? { enabled } : {},
8731
+ ...Object.keys(values).length ? { settings: values } : {}
8732
+ };
8733
+ }
8734
+ var THINKING_LEVELS = /* @__PURE__ */ new Set([
8735
+ "off",
8736
+ "minimal",
8737
+ "low",
8738
+ "medium",
8739
+ "high",
8740
+ "xhigh",
8741
+ "max"
8742
+ ]);
8743
+ function imageExplanationEntry(tool, complete) {
8744
+ if (!isRecord2(tool))
8745
+ return void 0;
8746
+ const source = isRecord2(tool.settings) ? tool.settings : {};
8747
+ const values = {};
8748
+ if (isRecord2(source.model)) {
8749
+ const provider = string(source.model.provider);
8750
+ const modelId2 = string(source.model.modelId);
8751
+ if (provider && modelId2)
8752
+ values.model = { provider, modelId: modelId2 };
8753
+ }
8754
+ const level = string(source.thinkingLevel);
8755
+ if (level && THINKING_LEVELS.has(level) && !(complete && level === "off"))
8756
+ values.thinkingLevel = level;
8757
+ const enabled = boolean(tool.enabled);
8758
+ if (enabled === void 0 && Object.keys(values).length === 0)
8759
+ return void 0;
8760
+ return {
8761
+ version: 1,
8762
+ ...enabled !== void 0 ? { enabled } : {},
8763
+ ...Object.keys(values).length ? { settings: values } : {}
8764
+ };
8765
+ }
8766
+ function extractFromTools(tools, loss, complete = false) {
8767
+ if (!isRecord2(tools))
8768
+ return { tools: void 0, entries: {} };
8769
+ if (!hasMovedFields(tools))
8770
+ return { tools, entries: {} };
8771
+ const quickScript = isRecord2(tools.quick_script) ? tools.quick_script : void 0;
8772
+ const qs = isRecord2(quickScript?.settings) ? quickScript.settings : {};
8773
+ const sub = (value) => isRecord2(value) ? value : {};
8774
+ const entries = {};
8775
+ const product = (name) => ({
8776
+ enabled: boolean(sub(qs[name]).enabled) ?? boolean(sub(tools[name]).enabled),
8777
+ account: string(sub(qs[name]).profileId) ?? string(sub(tools[name]).profileId)
8778
+ });
8779
+ const jira = product("jira");
8780
+ const confluence = product("confluence");
8781
+ if (jira.account && confluence.account && jira.account !== confluence.account)
8782
+ loss("Jira and Confluence used different Atlassian accounts; the Jira account was kept");
8783
+ const account2 = jira.account ?? confluence.account;
8784
+ const settings = {};
8785
+ if (account2)
8786
+ settings.account = account2;
8787
+ if (jira.enabled !== void 0)
8788
+ settings.jira = jira.enabled;
8789
+ if (confluence.enabled !== void 0)
8790
+ settings.confluence = confluence.enabled;
8791
+ if (Object.keys(settings).length)
8792
+ entries.atlassian = {
8793
+ version: 1,
8794
+ ...jira.enabled || confluence.enabled ? { enabled: true } : {},
8795
+ settings
8796
+ };
8797
+ const web = sub(qs.web);
8798
+ const searchAccount = string(web.profileId) ?? string(sub(tools.web_search).profileId);
8799
+ const webEnabled = boolean(web.enabled) ?? (searchAccount && boolean(sub(tools.web_search).enabled) !== false ? true : void 0);
8800
+ if (searchAccount || webEnabled !== void 0)
8801
+ entries["web-search"] = {
8802
+ version: 1,
8803
+ ...webEnabled !== void 0 ? { enabled: webEnabled } : {},
8804
+ ...searchAccount ? { settings: { searchAccount } } : {}
8805
+ };
8806
+ const server = string(sub(qs.diagram).url) ?? string(sub(sub(tools.kroki_export).settings).url);
8807
+ if (server && !(complete && server === KROKI_DEFAULT))
8808
+ entries.diagram = { version: 1, settings: { server } };
8809
+ const image = imageGenerationEntry(tools.generate_image, complete);
8810
+ if (image)
8811
+ entries.imagegen = image;
8812
+ const explanation2 = imageExplanationEntry(tools.explain_image, complete);
8813
+ if (explanation2)
8814
+ entries["image-explanation"] = explanation2;
8815
+ const cleaned = {};
8816
+ for (const [name, entry2] of Object.entries(tools)) {
8817
+ if (REMOVED_TOOLS.has(name))
8818
+ continue;
8819
+ const drop = name === "web_search" ? "profileId" : name === "quick_script" ? "settings" : void 0;
8820
+ if (drop && isRecord2(entry2)) {
8821
+ const rest = omit(entry2, drop);
8822
+ if (Object.keys(rest).length)
8823
+ cleaned[name] = rest;
8824
+ } else
8825
+ cleaned[name] = entry2;
8826
+ }
8827
+ return {
8828
+ tools: Object.keys(cleaned).length ? cleaned : void 0,
8829
+ entries
8830
+ };
8831
+ }
8832
+ function mergeEntries(base, over) {
8833
+ const merged = structuredClone(base);
8834
+ for (const [id, entry2] of Object.entries(over)) {
8835
+ const current = merged[id];
8836
+ merged[id] = {
8837
+ version: 1,
8838
+ ...entry2.enabled !== void 0 ? { enabled: entry2.enabled } : current?.enabled !== void 0 ? { enabled: current.enabled } : {},
8839
+ ...current?.settings || entry2.settings ? { settings: { ...current?.settings, ...entry2.settings } } : {}
8840
+ };
8841
+ }
8842
+ return merged;
8843
+ }
8844
+ function withTools(value, section, tools) {
8845
+ const holder = value[section];
8846
+ if (!isRecord2(holder))
8847
+ return value;
8848
+ return {
8849
+ ...value,
8850
+ [section]: { ...omit(holder, "tools"), ...tools ? { tools } : {} }
8851
+ };
8852
+ }
8853
+ function convertOverrides(document, loss) {
8854
+ const overrides = isRecord2(document.overrides) ? document.overrides : void 0;
8855
+ if (!overrides || !isRecord2(overrides.tools))
8856
+ return { document, entries: {} };
8857
+ const { tools, entries } = extractFromTools(overrides.tools, loss);
8858
+ return { document: withTools(document, "overrides", tools), entries };
8859
+ }
8860
+ function convertUserAgent(document, loss) {
8861
+ return convertOverrides(document, loss);
8862
+ }
8863
+ function profileSections(holder, loss) {
8864
+ let next = holder;
8865
+ const sections = {};
8866
+ for (const section of ["recommendations", "requirements"]) {
8867
+ const part = next[section];
8868
+ if (!isRecord2(part) || !isRecord2(part.tools))
8869
+ continue;
8870
+ const { tools, entries } = extractFromTools(part.tools, loss);
8871
+ next = withTools(next, section, tools);
8872
+ if (Object.keys(entries).length)
8873
+ sections[section] = entries;
8874
+ }
8875
+ const required = sections.requirements;
8876
+ const recommended = sections.recommendations;
8877
+ if (required && recommended)
8878
+ for (const [id, entry2] of Object.entries(required)) {
8879
+ const other = recommended[id];
8880
+ if (!other)
8881
+ continue;
8882
+ if (entry2.enabled !== void 0 && other.enabled !== void 0) {
8883
+ delete other.enabled;
8884
+ loss("A profile recommended and required the same extension switch; the requirement was kept");
8885
+ }
8886
+ for (const key2 of Object.keys(entry2.settings ?? {}))
8887
+ if (other.settings && key2 in other.settings) {
8888
+ delete other.settings[key2];
8889
+ loss("A profile recommended and required the same extension setting; the requirement was kept");
8890
+ }
8891
+ if (other.enabled === void 0 && !Object.keys(other.settings ?? {}).length)
8892
+ delete recommended[id];
8893
+ }
8894
+ return Object.keys(sections).length ? { holder: next, extensions: sections } : { holder };
8895
+ }
8896
+ function convertProfileDefinition(definition, loss) {
8897
+ const { holder, extensions } = profileSections(definition, loss);
8898
+ return extensions && !isRecord2(holder.extensions) ? { ...holder, extensions } : holder;
8899
+ }
8900
+ function convertConversationAgent(document, loss) {
8901
+ let next = document;
8902
+ let entries = {};
8903
+ if (isRecord2(next.frozenDefaults) && isRecord2(next.frozenDefaults.tools)) {
8904
+ const frozen = extractFromTools(next.frozenDefaults.tools, loss, true);
8905
+ next = withTools(next, "frozenDefaults", frozen.tools);
8906
+ entries = frozen.entries;
8907
+ }
8908
+ const overrides = convertOverrides(next, loss);
8909
+ next = overrides.document;
8910
+ entries = mergeEntries(entries, overrides.entries);
8911
+ if (isRecord2(next.appliedProfile)) {
8912
+ const { holder, extensions } = profileSections(next.appliedProfile, loss);
8913
+ next = {
8914
+ ...next,
8915
+ appliedProfile: extensions && !isRecord2(holder.extensions) ? { ...holder, extensions } : holder
8916
+ };
8917
+ }
8918
+ return { document: next, entries };
8919
+ }
8920
+ function hasMovedFields(tools) {
8921
+ if (!isRecord2(tools))
8922
+ return false;
8923
+ return [...REMOVED_TOOLS].some((name) => name in tools) || isRecord2(tools.web_search) && "profileId" in tools.web_search || isRecord2(tools.quick_script) && "settings" in tools.quick_script;
8924
+ }
8925
+
8926
+ // packages/workbench-server/dist/infrastructure/migrations/steps/0005-extension-settings/accounts.js
8927
+ var apiKeySecret = (credential) => `provider:${credential}:apiKey`;
8928
+ function reshapeAccounts(source, loss) {
8929
+ if (!isRecord2(source.profiles))
8930
+ return void 0;
8931
+ const accounts = {};
8932
+ const renames = [];
8933
+ for (const [kind, profiles] of Object.entries(source.profiles)) {
8934
+ accounts[kind] = [];
8935
+ if (!Array.isArray(profiles))
8936
+ continue;
8937
+ for (const profile of profiles) {
8938
+ if (!isRecord2(profile) || typeof profile.id !== "string" || typeof profile.name !== "string") {
8939
+ loss("An account entry was not valid and was dropped");
8940
+ continue;
8941
+ }
8942
+ const { id, name, credential, ...rest } = profile;
8943
+ const fields = Object.fromEntries(Object.entries(rest).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
8944
+ accounts[kind].push({ id, name, fields });
8945
+ renames.push({
8946
+ from: apiKeySecret(typeof credential === "string" ? credential : `${kind}:${id}`),
8947
+ to: apiKeySecret(`account:${kind}:${id}`)
8948
+ });
8949
+ }
8950
+ }
8951
+ return { document: { version: 2, accounts }, renames };
8952
+ }
8953
+ function renameSecrets(credentialsPath, keyPath, renames) {
8954
+ if (!renames.length || !existsSync21(credentialsPath) || !existsSync21(keyPath))
8955
+ return void 0;
8956
+ const key2 = Buffer.from(readFileSync11(keyPath, "utf8").trim(), "base64");
8957
+ if (key2.byteLength !== 32)
8958
+ throw new Error("Invalid Nerve master key.");
8959
+ const envelope = JSON.parse(readFileSync11(credentialsPath, "utf8"));
8960
+ const decipher = createDecipheriv("aes-256-gcm", key2, Buffer.from(envelope.iv, "base64"));
8961
+ decipher.setAuthTag(Buffer.from(envelope.tag, "base64"));
8962
+ const values = JSON.parse(Buffer.concat([
8963
+ decipher.update(Buffer.from(envelope.data, "base64")),
8964
+ decipher.final()
8965
+ ]).toString("utf8"));
8966
+ let renamed = 0;
8967
+ for (const { from, to } of renames) {
8968
+ if (typeof values[from] !== "string")
8969
+ continue;
8970
+ if (!(to in values))
8971
+ values[to] = values[from];
8972
+ delete values[from];
8973
+ renamed++;
8974
+ }
8975
+ if (!renamed)
8976
+ return void 0;
8977
+ const iv = randomBytes(12);
8978
+ const cipher = createCipheriv("aes-256-gcm", key2, iv);
8979
+ const ordered = Object.fromEntries(Object.entries(values).sort(([a], [b]) => a.localeCompare(b)));
8980
+ const data = Buffer.concat([
8981
+ cipher.update(JSON.stringify(ordered), "utf8"),
8982
+ cipher.final()
8983
+ ]);
8984
+ const sealed = {
8985
+ version: 1,
8986
+ algorithm: "A256GCM",
8987
+ iv: iv.toString("base64"),
8988
+ tag: cipher.getAuthTag().toString("base64"),
8989
+ data: data.toString("base64")
8990
+ };
8991
+ return { content: `${JSON.stringify(sealed, null, 2)}
8992
+ `, renamed };
8993
+ }
8994
+
8995
+ // packages/workbench-server/dist/infrastructure/migrations/steps/0005-extension-settings/step.js
8996
+ var text2 = (path) => {
8997
+ const stat = lstatSync13(path);
8998
+ if (stat.isSymbolicLink() || !stat.isFile())
8999
+ throw new Error(`Expected a regular file: ${path}`);
9000
+ return readFileSync12(path, "utf8");
9001
+ };
9002
+ var readObject = (path) => {
9003
+ const value = JSON.parse(text2(path));
9004
+ if (!isRecord2(value))
9005
+ throw new Error("Expected a JSON object");
9006
+ return value;
9007
+ };
9008
+ var serialize = (value) => `${JSON.stringify(value, null, 2)}
9009
+ `;
9010
+ function targets(context) {
9011
+ const { paths } = context;
9012
+ const found = [];
9013
+ const agent = join24(paths.configPath, "agent.json");
9014
+ if (existsSync22(agent))
9015
+ found.push({
9016
+ path: agent,
9017
+ kind: "user-agent",
9018
+ extensions: join24(paths.configPath, "extensions.json")
9019
+ });
9020
+ if (existsSync22(paths.permissionsConfigPath))
9021
+ found.push({ path: paths.permissionsConfigPath, kind: "permissions" });
9022
+ const ruleSets = join24(paths.configPath, "rule-sets");
9023
+ if (existsSync22(ruleSets)) {
9024
+ for (const file of readdirSync11(ruleSets).sort())
9025
+ if (file.endsWith(".json"))
9026
+ found.push({ path: join24(ruleSets, file), kind: "rule-set" });
9027
+ }
9028
+ if (existsSync22(paths.agentProfilesConfigPath)) {
9029
+ for (const file of readdirSync11(paths.agentProfilesConfigPath).sort())
9030
+ if (file.endsWith(".json"))
9031
+ found.push({
9032
+ path: join24(paths.agentProfilesConfigPath, file),
9033
+ kind: "profile"
9034
+ });
9035
+ }
9036
+ if (existsSync22(paths.conversationsPath))
9037
+ for (const id of readdirSync11(paths.conversationsPath).sort()) {
9038
+ const directory = join24(paths.conversationsPath, id, "config");
9039
+ const path = join24(directory, "agent.json");
9040
+ if (existsSync22(path))
9041
+ found.push({
9042
+ path,
9043
+ kind: "conversation-agent",
9044
+ extensions: join24(directory, "extensions.json")
9045
+ });
9046
+ const permissions = join24(directory, "permissions.json");
9047
+ if (existsSync22(permissions))
9048
+ found.push({ path: permissions, kind: "permissions" });
9049
+ }
9050
+ return found;
9051
+ }
9052
+ function owned(context) {
9053
+ const { paths } = context;
9054
+ return [
9055
+ join24(paths.configPath, "integrations.json"),
9056
+ paths.accountsConfigPath,
9057
+ paths.credentialsPath,
9058
+ ...targets(context).flatMap((target3) => [
9059
+ target3.path,
9060
+ ...target3.extensions ? [target3.extensions] : []
9061
+ ])
9062
+ ];
9063
+ }
9064
+ function extensionsDocument(entries, existing) {
9065
+ const stored = isRecord2(existing?.extensions) ? existing.extensions : {};
9066
+ return {
9067
+ schemaVersion: 1,
9068
+ revision: typeof existing?.revision === "number" ? existing.revision : 1,
9069
+ extensions: mergeEntries(entries, stored)
9070
+ };
9071
+ }
9072
+ function convert2(context, target3) {
9073
+ const losses = /* @__PURE__ */ new Map();
9074
+ const loss = (reason2) => losses.set(reason2, (losses.get(reason2) ?? 0) + 1);
9075
+ const source = readObject(target3.path);
9076
+ let document;
9077
+ let entries = {};
9078
+ if (target3.kind === "permissions" || target3.kind === "rule-set") {
9079
+ const converted = (target3.kind === "permissions" ? convertPermissionOverlayDocument : convertRuleSetDocument)(source, loss);
9080
+ if (converted.changed)
9081
+ context.fs.write(target3.path, serialize(converted.document));
9082
+ for (const [reason2, count] of losses)
9083
+ context.loss(reason2, count);
9084
+ return;
9085
+ }
9086
+ if (target3.kind === "profile")
9087
+ document = convertProfileDefinition(source, loss);
9088
+ else {
9089
+ const converted = target3.kind === "user-agent" ? convertUserAgent(source, loss) : convertConversationAgent(source, loss);
9090
+ document = converted.document;
9091
+ entries = converted.entries;
9092
+ }
9093
+ if (JSON.stringify(document) !== JSON.stringify(source))
9094
+ context.fs.write(target3.path, serialize(document));
9095
+ if (target3.extensions && Object.keys(entries).length) {
9096
+ const existing = existsSync22(target3.extensions) ? readObject(target3.extensions) : void 0;
9097
+ context.fs.write(target3.extensions, serialize(extensionsDocument(entries, existing)));
9098
+ }
9099
+ for (const [reason2, count] of losses)
9100
+ context.loss(reason2, count);
9101
+ }
9102
+ var step_default5 = defineStep({
9103
+ id: "0005-extension-settings",
9104
+ description: "Move account and tool options to extensions",
9105
+ ownedPaths: (context) => owned(context),
9106
+ async run(context) {
9107
+ const { paths } = context;
9108
+ const legacy = join24(paths.configPath, "integrations.json");
9109
+ if (existsSync22(legacy)) {
9110
+ await context.unit({ kind: "configuration", id: legacy }, () => {
9111
+ if (existsSync22(paths.accountsConfigPath))
9112
+ context.loss("config/integrations.json was left in place: config/accounts.json already exists");
9113
+ else
9114
+ context.fs.rename(legacy, paths.accountsConfigPath);
9115
+ });
9116
+ }
9117
+ if (existsSync22(paths.accountsConfigPath)) {
9118
+ if (context.discarded.has(paths.accountsConfigPath))
9119
+ context.quarantine({
9120
+ kind: "configuration",
9121
+ id: paths.accountsConfigPath,
9122
+ reason: "Set aside at user request after an upgrade failure"
9123
+ }, { files: [paths.accountsConfigPath], retainSource: true });
9124
+ else
9125
+ await context.unit({ kind: "configuration", id: paths.accountsConfigPath }, () => {
9126
+ const converted = reshapeAccounts(readObject(paths.accountsConfigPath), (reason2) => context.loss(reason2));
9127
+ if (!converted)
9128
+ return;
9129
+ context.fs.write(paths.accountsConfigPath, serialize(converted.document));
9130
+ const secrets = renameSecrets(paths.credentialsPath, paths.masterKeyPath, converted.renames);
9131
+ if (secrets)
9132
+ context.fs.write(paths.credentialsPath, secrets.content);
9133
+ });
9134
+ }
9135
+ const all = targets(context);
9136
+ context.progress("run", 0, all.length, "Moving extension settings");
9137
+ let done = 0;
9138
+ for (const target3 of all) {
9139
+ if (context.discarded.has(target3.path))
9140
+ context.quarantine({
9141
+ kind: "configuration",
9142
+ id: target3.path,
9143
+ reason: "Set aside at user request after an upgrade failure"
9144
+ }, { files: [target3.path], retainSource: true });
9145
+ else
9146
+ await context.unit({ kind: "configuration", id: target3.path }, () => convert2(context, target3));
9147
+ context.progress("run", ++done, all.length);
9148
+ }
9149
+ },
9150
+ async verify(context) {
9151
+ const { paths } = context;
9152
+ if (existsSync22(join24(paths.configPath, "integrations.json")) && !existsSync22(paths.accountsConfigPath))
9153
+ throw new Error("Integration accounts were not moved to accounts.json");
9154
+ if (existsSync22(paths.accountsConfigPath) && !context.discarded.has(paths.accountsConfigPath) && isRecord2(readObject(paths.accountsConfigPath).profiles))
9155
+ throw new Error("Accounts were not reshaped by kind");
9156
+ for (const target3 of targets(context)) {
9157
+ if (context.discarded.has(target3.path))
9158
+ continue;
9159
+ const document = readObject(target3.path);
9160
+ if (target3.kind === "permissions" || target3.kind === "rule-set") {
9161
+ if (hasEnabledRemovedToolRule(document))
9162
+ throw new Error(`Removed tools remain in ${target3.path}`);
9163
+ continue;
9164
+ }
9165
+ const sections = target3.kind === "profile" ? [document.recommendations, document.requirements] : [
9166
+ document.overrides,
9167
+ document.frozenDefaults,
9168
+ ...isRecord2(document.appliedProfile) ? [
9169
+ document.appliedProfile.recommendations,
9170
+ document.appliedProfile.requirements
9171
+ ] : []
9172
+ ];
9173
+ for (const section of sections)
9174
+ if (isRecord2(section) && hasMovedFields(section.tools))
9175
+ throw new Error(`Moved settings remain in ${target3.path}`);
9176
+ if (target3.extensions && existsSync22(target3.extensions)) {
9177
+ const extensions = readObject(target3.extensions);
9178
+ if (extensions.schemaVersion !== 1 || typeof extensions.revision !== "number" || !isRecord2(extensions.extensions))
9179
+ throw new Error(`Invalid extension settings: ${target3.extensions}`);
9180
+ }
9181
+ }
9182
+ }
9183
+ });
9184
+
8307
9185
  // packages/workbench-server/dist/infrastructure/migrations/steps/index.js
8308
9186
  var implementations = [
8309
9187
  step_default,
8310
9188
  step_default2,
8311
9189
  step_default3,
8312
- step_default4
9190
+ step_default4,
9191
+ step_default5
8313
9192
  ];
8314
9193
  if (implementations.length !== MIGRATION_METADATA.length)
8315
9194
  throw new Error("Migration metadata and implementations must match.");
@@ -8323,8 +9202,8 @@ var MIGRATION_REGISTRY = Object.freeze(MIGRATION_METADATA.map((metadata, index)
8323
9202
  // packages/workbench-server/dist/infrastructure/migrations/framework/filesystem.js
8324
9203
  import { randomUUID as randomUUID6 } from "node:crypto";
8325
9204
  import assert30 from "node:assert/strict";
8326
- import { closeSync as closeSync4, openSync as openSync4, existsSync as existsSync21, lstatSync as lstatSync13, mkdirSync as mkdirSync8, rmSync as rmSync10, writeFileSync as writeFileSync6 } from "node:fs";
8327
- import { dirname as dirname12, join as join24 } from "node:path";
9205
+ import { closeSync as closeSync4, openSync as openSync4, existsSync as existsSync23, lstatSync as lstatSync14, mkdirSync as mkdirSync8, rmSync as rmSync10, writeFileSync as writeFileSync6 } from "node:fs";
9206
+ import { dirname as dirname12, join as join25 } from "node:path";
8328
9207
  var MigrationFilesystem = class {
8329
9208
  scratchDir;
8330
9209
  readOnly = false;
@@ -8340,10 +9219,10 @@ var MigrationFilesystem = class {
8340
9219
  ];
8341
9220
  }
8342
9221
  recoverUnit() {
8343
- const pending = join24(this.scratchDir, "pending-unit");
8344
- if (!existsSync21(pending))
9222
+ const pending = join25(this.scratchDir, "pending-unit");
9223
+ if (!existsSync23(pending))
8345
9224
  return;
8346
- if (!existsSync21(join24(pending, "committed")))
9225
+ if (!existsSync23(join25(pending, "committed")))
8347
9226
  new RollbackJournal(pending).restore();
8348
9227
  setUnitJournal(void 0);
8349
9228
  rmSync10(pending, { recursive: true, force: true });
@@ -8354,7 +9233,7 @@ var MigrationFilesystem = class {
8354
9233
  if (this.readOnly)
8355
9234
  return { finish() {
8356
9235
  } };
8357
- const pending = join24(this.scratchDir, "pending-unit");
9236
+ const pending = join25(this.scratchDir, "pending-unit");
8358
9237
  const journal = new RollbackJournal(pending);
8359
9238
  this.#unit = journal;
8360
9239
  setUnitJournal(journal);
@@ -8364,7 +9243,7 @@ var MigrationFilesystem = class {
8364
9243
  if (!success)
8365
9244
  journal.restore();
8366
9245
  else {
8367
- const marker = join24(pending, "committed");
9246
+ const marker = join25(pending, "committed");
8368
9247
  writeFileSync6(marker, "", { mode: 384 });
8369
9248
  syncFile(marker);
8370
9249
  syncDirectory(pending);
@@ -8404,15 +9283,15 @@ var MigrationFilesystem = class {
8404
9283
  }
8405
9284
  }
8406
9285
  rename(from, to) {
8407
- assert30(lstatSync13(from, { throwIfNoEntry: false }), `Missing rename source ${from}`);
8408
- assert30(!lstatSync13(to, { throwIfNoEntry: false }), `Destination already exists: ${to}`);
9286
+ assert30(lstatSync14(from, { throwIfNoEntry: false }), `Missing rename source ${from}`);
9287
+ assert30(!lstatSync14(to, { throwIfNoEntry: false }), `Destination already exists: ${to}`);
8409
9288
  for (const journal of this.journals())
8410
9289
  journal.recordRename(from, to);
8411
9290
  renameWithRetrySync(from, to);
8412
9291
  }
8413
9292
  move(from, to) {
8414
- if (!lstatSync13(from, { throwIfNoEntry: false })) {
8415
- assert30(lstatSync13(to, { throwIfNoEntry: false }), `Missing move source ${from}`);
9293
+ if (!lstatSync14(from, { throwIfNoEntry: false })) {
9294
+ assert30(lstatSync14(to, { throwIfNoEntry: false }), `Missing move source ${from}`);
8416
9295
  return;
8417
9296
  }
8418
9297
  for (const journal of this.journals())
@@ -8421,9 +9300,9 @@ var MigrationFilesystem = class {
8421
9300
  }
8422
9301
  remove(path) {
8423
9302
  this.journals();
8424
- const stat = lstatSync13(path, { throwIfNoEntry: false });
9303
+ const stat = lstatSync14(path, { throwIfNoEntry: false });
8425
9304
  if (stat?.isDirectory()) {
8426
- const retained = join24(this.scratchDir, "removed", String(Date.now()) + "-" + Math.random().toString(36).slice(2));
9305
+ const retained = join25(this.scratchDir, "removed", String(Date.now()) + "-" + Math.random().toString(36).slice(2));
8427
9306
  mkdirSync8(dirname12(retained), { recursive: true, mode: 448 });
8428
9307
  this.move(path, retained);
8429
9308
  } else {
@@ -8434,7 +9313,7 @@ var MigrationFilesystem = class {
8434
9313
  }
8435
9314
  mkdir(path) {
8436
9315
  const missing = [];
8437
- for (let p = path; !existsSync21(p) && p !== dirname12(p); p = dirname12(p))
9316
+ for (let p = path; !existsSync23(p) && p !== dirname12(p); p = dirname12(p))
8438
9317
  missing.push(p);
8439
9318
  for (const p of missing.reverse()) {
8440
9319
  for (const journal of this.journals())
@@ -8448,9 +9327,9 @@ var MigrationFilesystem = class {
8448
9327
  };
8449
9328
 
8450
9329
  // packages/workbench-server/dist/infrastructure/migrations/framework/context.js
8451
- import { readFileSync as readFileSync11, realpathSync as realpathSync6 } from "node:fs";
9330
+ import { readFileSync as readFileSync13, realpathSync as realpathSync6 } from "node:fs";
8452
9331
  import { appendFile, mkdir, statfs } from "node:fs/promises";
8453
- import { join as join25 } from "node:path";
9332
+ import { join as join26 } from "node:path";
8454
9333
  async function assertFreeDisk(path, required) {
8455
9334
  const stats = await statfs(path, { bigint: true });
8456
9335
  const available = stats.bavail * stats.bsize;
@@ -8458,10 +9337,10 @@ async function assertFreeDisk(path, required) {
8458
9337
  throw new Error(`Migration requires ${required} free bytes; only ${available} available.`);
8459
9338
  }
8460
9339
  }
8461
- var discardedItemsPath = (scratchDir) => join25(scratchDir, "discarded.json");
9340
+ var discardedItemsPath = (scratchDir) => join26(scratchDir, "discarded.json");
8462
9341
  function readDiscardedItems(scratchDir) {
8463
9342
  try {
8464
- const ids = JSON.parse(readFileSync11(discardedItemsPath(scratchDir), "utf8"));
9343
+ const ids = JSON.parse(readFileSync13(discardedItemsPath(scratchDir), "utf8"));
8465
9344
  if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string"))
8466
9345
  throw new Error("Invalid discarded item list");
8467
9346
  return new Set(ids);
@@ -8473,7 +9352,7 @@ function readDiscardedItems(scratchDir) {
8473
9352
  }
8474
9353
  function createStepContext(requestedPaths, id, description, onProgress) {
8475
9354
  const paths = storagePaths(realpathSync6(requestedPaths.home));
8476
- const scratchDir = join25(paths.migrationWorkPath, id);
9355
+ const scratchDir = join26(paths.migrationWorkPath, id);
8477
9356
  let logging = Promise.resolve();
8478
9357
  let logError;
8479
9358
  const context = {
@@ -8482,7 +9361,7 @@ function createStepContext(requestedPaths, id, description, onProgress) {
8482
9361
  ownPaths: (paths2, root) => ownPaths(context, paths2, root),
8483
9362
  unit: (item, fn, options) => runUnit(context, item, fn, options),
8484
9363
  readJson: (path, schema) => checkedJson(context, path, schema),
8485
- quarantine: (item, payload) => quarantine(context, item, payload),
9364
+ quarantine: (item, payload2) => quarantine(context, item, payload2),
8486
9365
  loss: (reason2, count) => recordLoss(context, reason2, count),
8487
9366
  scratchDir,
8488
9367
  discarded: readDiscardedItems(scratchDir),
@@ -8490,7 +9369,7 @@ function createStepContext(requestedPaths, id, description, onProgress) {
8490
9369
  log(message) {
8491
9370
  logging = logging.then(async () => {
8492
9371
  await mkdir(scratchDir, { recursive: true, mode: 448 });
8493
- await appendFile(join25(scratchDir, "step.log"), `${(/* @__PURE__ */ new Date()).toISOString()} ${message}
9372
+ await appendFile(join26(scratchDir, "step.log"), `${(/* @__PURE__ */ new Date()).toISOString()} ${message}
8494
9373
  `, { mode: 384 });
8495
9374
  }).catch((error) => {
8496
9375
  logError = error;
@@ -8510,9 +9389,9 @@ function createStepContext(requestedPaths, id, description, onProgress) {
8510
9389
  }
8511
9390
 
8512
9391
  // packages/workbench-server/dist/infrastructure/migrations/framework/recovery.js
8513
- import { existsSync as existsSync22 } from "node:fs";
9392
+ import { existsSync as existsSync24 } from "node:fs";
8514
9393
  import { copyFile, readFile, rm as rm2 } from "node:fs/promises";
8515
- import { dirname as dirname13, join as join26 } from "node:path";
9394
+ import { dirname as dirname13, join as join27 } from "node:path";
8516
9395
  async function readMigrationFailureReport(paths) {
8517
9396
  try {
8518
9397
  return JSON.parse(await readFile(paths.migrationFailureReportPath, "utf8"));
@@ -8543,8 +9422,8 @@ async function discardFailedItems(home, ids, options = {}) {
8543
9422
  const unknown = ids.filter((id) => !failed.has(id));
8544
9423
  if (!ids.length || unknown.length)
8545
9424
  throw new Error(`Only items reported by the last upgrade attempt can be discarded${unknown.length ? `: ${unknown.join(", ")}` : ""}.`);
8546
- const scratchDir = join26(paths.migrationWorkPath, report.step);
8547
- const dependencyPath = join26(scratchDir, "unit-dependencies.json");
9425
+ const scratchDir = join27(paths.migrationWorkPath, report.step);
9426
+ const dependencyPath = join27(scratchDir, "unit-dependencies.json");
8548
9427
  const dependencies = await pathExists(dependencyPath) ? JSON.parse(await readFile(dependencyPath, "utf8")) : {};
8549
9428
  const chosen = new Set(ids);
8550
9429
  for (const id of chosen)
@@ -8552,7 +9431,7 @@ async function discardFailedItems(home, ids, options = {}) {
8552
9431
  if (failed.has(child))
8553
9432
  chosen.add(child);
8554
9433
  const discarded = readDiscardedItems(scratchDir);
8555
- const detailsPath = join26(scratchDir, "discarded-details.json");
9434
+ const detailsPath = join27(scratchDir, "discarded-details.json");
8556
9435
  const details = await pathExists(detailsPath) ? JSON.parse(await readFile(detailsPath, "utf8")) : [];
8557
9436
  for (const item of report.discardable ?? [])
8558
9437
  if (chosen.has(item.id) && !details.some((saved) => saved.id === item.id))
@@ -8575,15 +9454,15 @@ async function rollbackFailedMigration(home, options = {}) {
8575
9454
  if (entry2?.step.id !== report.step)
8576
9455
  throw new Error(`Upgrade step ${report.step} is not pending.`);
8577
9456
  const { context } = createStepContext(paths, entry2.step.id, entry2.step.description, () => void 0);
8578
- if (existsSync22(join26(context.scratchDir, "verified.json")))
9457
+ if (existsSync24(join27(context.scratchDir, "verified.json")))
8579
9458
  throw new Error("The failed upgrade cannot be rolled back.");
8580
9459
  await entry2.step.rollback?.(context);
8581
- if (existsSync22(join26(context.scratchDir, "rollback")))
9460
+ if (existsSync24(join27(context.scratchDir, "rollback")))
8582
9461
  new RollbackJournal(context.scratchDir).restore();
8583
9462
  const baselineBackup = manifestBackupPath(paths);
8584
- const restoredMarker = join26(context.scratchDir, "manifest-restored.json");
9463
+ const restoredMarker = join27(context.scratchDir, "manifest-restored.json");
8585
9464
  if (!await pathExists(restoredMarker)) {
8586
- const backup2 = !manifest.migrations?.length && await pathExists(baselineBackup) ? baselineBackup : join26(context.scratchDir, "manifest.before.json");
9465
+ const backup2 = !manifest.migrations?.length && await pathExists(baselineBackup) ? baselineBackup : join27(context.scratchDir, "manifest.before.json");
8587
9466
  if (!await pathExists(backup2))
8588
9467
  throw new Error("Missing pre-step manifest rollback snapshot.");
8589
9468
  const temporary = `${paths.manifestPath}.rollback`;
@@ -8595,7 +9474,7 @@ async function rollbackFailedMigration(home, options = {}) {
8595
9474
  }
8596
9475
  await rm2(baselineBackup, { force: true });
8597
9476
  await rm2(context.scratchDir, { recursive: true, force: true });
8598
- await rm2(join26(paths.migrationWorkPath, "cleanup-needed.json"), {
9477
+ await rm2(join27(paths.migrationWorkPath, "cleanup-needed.json"), {
8599
9478
  force: true
8600
9479
  });
8601
9480
  await rm2(paths.migrationFailureReportPath, { force: true });