@readmagic/workmate 0.0.23 → 0.0.24

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 (210) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-OgcBcK5A.js → AddWorkspaceDirectory-Ch8IcWXO.js} +1 -1
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-Cyia0s4g.js +1 -0
  3. package/dist/chunks/{AgentsMdExternalIncludesDialog-CNEifEyV.js → AgentsMdExternalIncludesDialog-LjI_H_Au.js} +1 -1
  4. package/dist/chunks/{App-B-3tPQ3k.js → App-BOqh_1tN.js} +1 -1
  5. package/dist/chunks/{BackgroundTasksDialog-COuhHcey.js → BackgroundTasksDialog-CSEuuoq9.js} +1 -1
  6. package/dist/chunks/{BypassPermissionsModeDialog-bJek4siJ.js → BypassPermissionsModeDialog-CwfCwUr9.js} +1 -1
  7. package/dist/chunks/CustomSelect-wmZ9jz0W.js +1 -0
  8. package/dist/chunks/{DiffDialog-B3X9FMpO.js → DiffDialog-BpXIEWiE.js} +1 -1
  9. package/dist/chunks/Doctor-CMpr7tdf.js +1 -0
  10. package/dist/chunks/{Doctor-6PXyjIi6.js → Doctor-DqW6j3_B.js} +1 -1
  11. package/dist/chunks/{ExitFlow-DgAZp_8U.js → ExitFlow-DacaBTlk.js} +1 -1
  12. package/dist/chunks/{Grove-CHatOzcE.js → Grove-CNqYPWI6.js} +1 -1
  13. package/dist/chunks/{InvalidConfigDialog-DXL92MN9.js → InvalidConfigDialog-0TMJItCC.js} +1 -1
  14. package/dist/chunks/{InvalidSettingsDialog-Dtmpzeps.js → InvalidSettingsDialog-iwh8H52b.js} +1 -1
  15. package/dist/chunks/{KeybindingProviderSetup-DA37QUFs.js → KeybindingProviderSetup-D49HHTXD.js} +1 -1
  16. package/dist/chunks/{MCPConnectionManager-thZd-xA_.js → MCPConnectionManager-Cie77ZAK.js} +1 -1
  17. package/dist/chunks/{MCPToolListView-CpY-YJg4.js → MCPToolListView-B4ehtkXd.js} +1 -1
  18. package/dist/chunks/{McpParsingWarnings-JvChf3xr.js → McpParsingWarnings-Bff66RtJ.js} +1 -1
  19. package/dist/chunks/{MessageSelector-C0_iw7SI.js → MessageSelector-Dpd6Iywp.js} +1 -1
  20. package/dist/chunks/{Messages-K4DDsDP9.js → Messages-DN7M3oS_.js} +1 -1
  21. package/dist/chunks/{Onboarding-C1UdzM-1.js → Onboarding-CQmE3rUf.js} +1 -1
  22. package/dist/chunks/{PromptInputFooterSuggestions-AyLog8p7.js → PromptInputFooterSuggestions-HI6HH3TP.js} +1 -1
  23. package/dist/chunks/{PromptInputHelpMenu-oyic20ip.js → PromptInputHelpMenu-3QNUC2Cg.js} +1 -1
  24. package/dist/chunks/{ProviderSetup-XcBHjUnd.js → ProviderSetup-BCSPsvfv.js} +1 -1
  25. package/dist/chunks/{QueryEngine-DYxBjJ4i.js → QueryEngine-DdLWvJv6.js} +1 -1
  26. package/dist/chunks/{REPL-CQBJRrT0.js → REPL-BqO9KcK_.js} +5 -5
  27. package/dist/chunks/REPL-CmZmypfF.js +1 -0
  28. package/dist/chunks/{ResumeConversation-Dl8H9Gfy.js → ResumeConversation-DBqX7gva.js} +1 -1
  29. package/dist/chunks/SearchExtraToolsTool-BsSoILFj.js +1 -0
  30. package/dist/chunks/{SelectMulti-Bc6l11_K.js → SelectMulti-BQRHed-d.js} +1 -1
  31. package/dist/chunks/{Settings-TGp3fPrS.js → Settings-B-7yBewS.js} +3 -3
  32. package/dist/chunks/{Spinner-zYPFVFHN.js → Spinner-ByQXTvAA.js} +1 -1
  33. package/dist/chunks/{TextInput-CD9iau2k.js → TextInput-B8ruWRf2.js} +1 -1
  34. package/dist/chunks/{ThemePicker-0F0hZYPX.js → ThemePicker-BQErFFW1.js} +1 -1
  35. package/dist/chunks/{TrustDialog-C76YiMKz.js → TrustDialog-BIhz6AZE.js} +1 -1
  36. package/dist/chunks/{_baseEach-4ff-vRlp.js → _baseEach-CsIRoaTH.js} +1 -1
  37. package/dist/chunks/{add-dir-JMsRLGfx.js → add-dir-CrUDs19x.js} +1 -1
  38. package/dist/chunks/{agentDisplay-BReJUBWg.js → agentDisplay-M4pfwbMC.js} +1 -1
  39. package/dist/chunks/{agents-9qQ8I6zW.js → agents-CGaCQeLw.js} +1 -1
  40. package/dist/chunks/{agents-B3x8yJ_r.js → agents-DddX7lLX.js} +1 -1
  41. package/dist/chunks/{allErrors-DfWylHSw.js → allErrors-BF73lon8.js} +1 -1
  42. package/dist/chunks/{backgroundHousekeeping-CVNIhQg8.js → backgroundHousekeeping-Bq3LMsVR.js} +2 -2
  43. package/dist/chunks/backgroundHousekeeping-Cl3Ox7Qh.js +1 -0
  44. package/dist/chunks/{branch-C4TsMEkx.js → branch-Yg_taNlT.js} +1 -1
  45. package/dist/chunks/{btw-Dn1eYFAz.js → btw-udbprVvu.js} +1 -1
  46. package/dist/chunks/caches-ChjIEcdd.js +1 -0
  47. package/dist/chunks/{caches-DArHxBgL.js → caches-DLJ6urv-.js} +1 -1
  48. package/dist/chunks/{clear-Bdhb6b39.js → clear-B8ZtFPOK.js} +1 -1
  49. package/dist/chunks/commands-CVCpJo7M.js +1 -0
  50. package/dist/chunks/{compact-Bu9BUpxV.js → compact-izk6RKHQ.js} +1 -1
  51. package/dist/chunks/config-CFqpXMFX.js +1 -0
  52. package/dist/chunks/{context-CY_yfdYa.js → context-BbVm4SWK.js} +1 -1
  53. package/dist/chunks/{context-noninteractive-Dd4xIoP1.js → context-noninteractive-C7wrRZnM.js} +1 -1
  54. package/dist/chunks/context-noninteractive-x0HAzWhc.js +1 -0
  55. package/dist/chunks/conversation-DouVzO0K.js +1 -0
  56. package/dist/chunks/{conversation-DUu9qBnq.js → conversation-DrVkifKy.js} +1 -1
  57. package/dist/chunks/{conversationRecovery-2ft8sCPE.js → conversationRecovery-DliPBo_z.js} +1 -1
  58. package/dist/chunks/{crossProjectResume-6boHMUBx.js → crossProjectResume-DxMy05_P.js} +1 -1
  59. package/dist/chunks/{datadog-BPuGcxxC.js → datadog-Cu3s7P48.js} +1 -1
  60. package/dist/chunks/{diff-BOAElpfQ.js → diff-DdpHThJ7.js} +1 -1
  61. package/dist/chunks/doctor-D_kV_D_l.js +1 -0
  62. package/dist/chunks/{entry-TNOoyy7_.js → entry-Bxseqbi_.js} +1 -1
  63. package/dist/chunks/{esm-eTAUP-La.js → esm-BXTZz3av.js} +1 -1
  64. package/dist/chunks/{exit-DXApFJIP.js → exit-C_R_FgzR.js} +1 -1
  65. package/dist/chunks/{extraUsage-CmQaLPV1.js → extraUsage-xMuDiNKh.js} +1 -1
  66. package/dist/chunks/extractMemories-D4Dl1itt.js +1 -0
  67. package/dist/chunks/{fast-eGx2IxD7.js → fast-DH-C5IZs.js} +1 -1
  68. package/dist/chunks/fast-bopOPrtf.js +1 -0
  69. package/dist/chunks/fetchModelList-DC4VQpqa.js +1 -0
  70. package/dist/chunks/{fetchModelList-CxLsVNsu.js → fetchModelList-FE8tzTDc.js} +1 -1
  71. package/dist/chunks/{fileSuggestions-DHxdwq28.js → fileSuggestions-C-9unnoJ.js} +1 -1
  72. package/dist/chunks/{firstPartyEventLogger-M6UMli2c.js → firstPartyEventLogger-QmjjQmgt.js} +2 -2
  73. package/dist/chunks/firstPartyEventLogger-lFeqhtfh.js +1 -0
  74. package/dist/chunks/{gemini-D_ORb_L6.js → gemini-C_ApXgwc.js} +1 -1
  75. package/dist/chunks/{generateSessionName-BQoDduyA.js → generateSessionName-CQ03xlYI.js} +1 -1
  76. package/dist/chunks/{goal-D7c2mSds.js → goal-CdL29Y8C.js} +1 -1
  77. package/dist/chunks/{grok-B2-ZbUiR.js → grok-C6WAslUT.js} +1 -1
  78. package/dist/chunks/{help-CZJdRviD.js → help-DxanITNN.js} +1 -1
  79. package/dist/chunks/{history-CQiUERTL.js → history-BMycjPTT.js} +1 -1
  80. package/dist/chunks/hooks-D9ApLkBp.js +1 -0
  81. package/dist/chunks/{hooks-DIvN6gdv.js → hooks-DR3IYPJ3.js} +1 -1
  82. package/dist/chunks/{install-T_CV1Slu.js → install-0D9u2dZw.js} +1 -1
  83. package/dist/chunks/{instrumentation-BjqUZ383.js → instrumentation-BFiGwntt.js} +3 -3
  84. package/dist/chunks/{job-R6c4-3c8.js → job-YhJQWgE0.js} +1 -1
  85. package/dist/chunks/{keybindings-CLRaiL_Z.js → keybindings-DZrF9iNd.js} +1 -1
  86. package/dist/chunks/{launchLocalMemory-DrbKrwXc.js → launchLocalMemory-DhJ56KDc.js} +1 -1
  87. package/dist/chunks/{launchOnboarding-tqsMD8ni.js → launchOnboarding-DmMoZwv5.js} +1 -1
  88. package/dist/chunks/{loadAgentsDir-DlPbtIsS.js → loadAgentsDir-B0Anodo0.js} +23 -23
  89. package/dist/chunks/loadAgentsDir-BbUR6pqH.js +1 -0
  90. package/dist/chunks/{loadPluginHooks-C_msxVIc.js → loadPluginHooks-BSwCtQ6T.js} +1 -1
  91. package/dist/chunks/{localSearch-CK-sFzPm.js → localSearch-BxLYi6w_.js} +1 -1
  92. package/dist/chunks/localSearch-zfn7jgrh.js +1 -0
  93. package/dist/chunks/{logoUtils-x2pHV-Nl.js → logoUtils-CRxTutvr.js} +1 -1
  94. package/dist/chunks/{magicDocs-BEF8D3if.js → magicDocs-Bkz7ZcmL.js} +1 -1
  95. package/dist/chunks/{main-kOVUGxOS.js → main-9ksgUUY_.js} +5 -5
  96. package/dist/chunks/{mcp-D0wAJrRT.js → mcp-ChF12reQ.js} +1 -1
  97. package/dist/chunks/{mcp-mgOlm1cY.js → mcp-DoEl5uah.js} +1 -1
  98. package/dist/chunks/{mcp-BNd29r6p.js → mcp-hp9qqjAy.js} +2 -2
  99. package/dist/chunks/{memory-DDLk9_LJ.js → memory-Qv-wGNQ5.js} +1 -1
  100. package/dist/chunks/{mode-CcNsWgK3.js → mode-bFXPCR2P.js} +1 -1
  101. package/dist/chunks/{model-DzCP4K-9.js → model-6lkW4o2c.js} +1 -1
  102. package/dist/chunks/{model-BwBG0V1u.js → model-BvQFFOf8.js} +1 -1
  103. package/dist/chunks/{modelOptions-DRaG3bo0.js → modelOptions-BBvF3wHK.js} +1 -1
  104. package/dist/chunks/{nativeInstaller-C3pVPqrZ.js → nativeInstaller-CdjmE9Zy.js} +1 -1
  105. package/dist/chunks/{notifications-4wP1Tx9Y.js → notifications-Bc6k-Ozy.js} +1 -1
  106. package/dist/chunks/{onChangeAppState-BlaoFbYF.js → onChangeAppState-DLjZ1x95.js} +1 -1
  107. package/dist/chunks/{openai-CDN71NdX.js → openai-D46QvESE.js} +1 -1
  108. package/dist/chunks/{overlayContext-BT2Lq8ei.js → overlayContext-8--_fbvY.js} +1 -1
  109. package/dist/chunks/{partition-CIl_ORUT.js → partition-DznN4XZH.js} +1 -1
  110. package/dist/chunks/{permissions-zSNOZSwr.js → permissions-DmGFViHI.js} +1 -1
  111. package/dist/chunks/{pidLock-BTqO-h7Y.js → pidLock-Cm4sW35f.js} +2 -2
  112. package/dist/chunks/{plan-Bs6em6lk.js → plan-CzGBz_87.js} +1 -1
  113. package/dist/chunks/{plugin-DDDxjBa0.js → plugin-CluR79xX.js} +1 -1
  114. package/dist/chunks/{pluginAutoupdate-8qugAFhb.js → pluginAutoupdate-ennb9k8_.js} +1 -1
  115. package/dist/chunks/{pluginBlocklist-q01ackCf.js → pluginBlocklist-9OrNEh--.js} +1 -1
  116. package/dist/chunks/{pluginCliCommands-DXZfCZsv.js → pluginCliCommands-CJv5uhOG.js} +1 -1
  117. package/dist/chunks/{pluginFlagging-BG2MHCQJ.js → pluginFlagging-js_-WmYj.js} +1 -1
  118. package/dist/chunks/{pluginOperations-hXYLrzM2.js → pluginOperations-CcUSHAIa.js} +1 -1
  119. package/dist/chunks/pluginStartupCheck-CRBUO9gP.js +1 -0
  120. package/dist/chunks/{pluginStartupCheck-DTMa6TgL.js → pluginStartupCheck-SRXOyqr7.js} +1 -1
  121. package/dist/chunks/{plugins-COoGBYk6.js → plugins-IwwaCDba.js} +1 -1
  122. package/dist/chunks/{print-BASybEtO.js → print-CgszM1ea.js} +2 -2
  123. package/dist/chunks/{processBashCommand-DDi_Pymt.js → processBashCommand-D098WsqY.js} +1 -1
  124. package/dist/chunks/{processSlashCommand-Cq9kaoSF.js → processSlashCommand-DOQFjJ88.js} +1 -1
  125. package/dist/chunks/prompt-BKPmDAuL.js +1 -0
  126. package/dist/chunks/{prompt-mM79EGnT.js → prompt-CJ1l3XXk.js} +1 -1
  127. package/dist/chunks/prompt-CgOklk7z.js +1 -0
  128. package/dist/chunks/{promptEditor-DLGN_eLu.js → promptEditor-DoGHJN_W.js} +1 -1
  129. package/dist/chunks/{reconciler-CeXqh95g.js → reconciler-ykkSPR-i.js} +1 -1
  130. package/dist/chunks/{refresh-Ce2yk28a.js → refresh-Dn_I1R4v.js} +1 -1
  131. package/dist/chunks/{reject-Bld5E-bn.js → reject-DtcCfuZV.js} +1 -1
  132. package/dist/chunks/{reload-plugins-C42xSB5l.js → reload-plugins-CQZFQLWP.js} +1 -1
  133. package/dist/chunks/{rename-CtBghpxZ.js → rename-DyEfsZiq.js} +1 -1
  134. package/dist/chunks/{resume-BWkaTDqd.js → resume-BcXEDUqZ.js} +1 -1
  135. package/dist/chunks/{runtimeObserver-1wQO8HSZ.js → runtimeObserver-DEuR8z0f.js} +1 -1
  136. package/dist/chunks/{runtimeObserver-XQrOux41.js → runtimeObserver-PJ1o8GRA.js} +2 -2
  137. package/dist/chunks/sandbox-adapter-DfB9kgQD.js +1 -0
  138. package/dist/chunks/{sandbox-toggle-Dir9Polo.js → sandbox-toggle-D9GDUsTl.js} +1 -1
  139. package/dist/chunks/searchExtraTools-D4gMMQv0.js +1 -0
  140. package/dist/chunks/{select-Bxf5-5sI.js → select-DIxfl_VN.js} +1 -1
  141. package/dist/chunks/sessionFileAccessHooks-lbgHnVvi.js +1 -0
  142. package/dist/chunks/{sessionObserver-DS4G6mb9.js → sessionObserver-BtKjvteq.js} +1 -1
  143. package/dist/chunks/sessionObserver-D6qzEdGJ.js +1 -0
  144. package/dist/chunks/sessionStorage-C_7gow_z.js +1 -0
  145. package/dist/chunks/{sessionTracing-BoDDYLxW.js → sessionTracing-CtbeAD0s.js} +1 -1
  146. package/dist/chunks/{setup-BRypY6iT.js → setup-qecdf-ES.js} +2 -2
  147. package/dist/chunks/{shadowedRuleDetection-BRxZjobz.js → shadowedRuleDetection-Bg_aIc5Z.js} +1 -1
  148. package/dist/chunks/{sideQuestion-DLJxyrlp.js → sideQuestion-D49GsfH7.js} +1 -1
  149. package/dist/chunks/sinks-C-lP7uyO.js +1 -0
  150. package/dist/chunks/{sinks-Cz2HfgMU.js → sinks-De-B1lPQ.js} +1 -1
  151. package/dist/chunks/{skillChangeDetector-xviGstqm.js → skillChangeDetector-DkOJoNhT.js} +1 -1
  152. package/dist/chunks/{skillGapStore-CKN_d3pO.js → skillGapStore-CcFoHNLl.js} +2 -2
  153. package/dist/chunks/{skillLifecycle-BMY2JGGG.js → skillLifecycle-Bnz_4wE5.js} +2 -2
  154. package/dist/chunks/{skillSearchPanel-D9trHULQ.js → skillSearchPanel-C_5yUhqn.js} +2 -2
  155. package/dist/chunks/{skills-CX_AvwLG.js → skills-BE5scC-g.js} +1 -1
  156. package/dist/chunks/status-Dw09WZLd.js +1 -0
  157. package/dist/chunks/{statusNoticeHelpers-vFVgIYuw.js → statusNoticeHelpers-BRQpUIlH.js} +1 -1
  158. package/dist/chunks/switcher-CgZVah7U.js +1 -0
  159. package/dist/chunks/{switcher-CAajZeNL.js → switcher-DZwUo5Ed.js} +1 -1
  160. package/dist/chunks/{tasks-BWNQr2d3.js → tasks-DdcUQEeD.js} +1 -1
  161. package/dist/chunks/{templateJobs-gUET39Ho.js → templateJobs-C8qsPrLj.js} +1 -1
  162. package/dist/chunks/{theme-B7fKI6E5.js → theme-f1h2QI8J.js} +1 -1
  163. package/dist/chunks/{tipRegistry-DamZr34w.js → tipRegistry-B71o4qWr.js} +1 -1
  164. package/dist/chunks/{toolEventObserver-BL06sDI4.js → toolEventObserver-7QP38x4t.js} +1 -1
  165. package/dist/chunks/{toolPool-CX5wDBi1.js → toolPool-V-7Yv0GA.js} +1 -1
  166. package/dist/chunks/{use-select-navigation-BiUJdWai.js → use-select-navigation-hWL5VHnL.js} +1 -1
  167. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-C9BYG8Bo.js → useExitOnCtrlCDWithKeybindings-BKwzUpgb.js} +1 -1
  168. package/dist/chunks/useMainLoopModel-DxvV70Ru.js +1 -0
  169. package/dist/chunks/{useManagePlugins-BqfIVa6E.js → useManagePlugins-BXLXazrR.js} +1 -1
  170. package/dist/chunks/useMergedTools-CCgnBJzO.js +1 -0
  171. package/dist/chunks/{useSearchInput-B25K1RnK.js → useSearchInput-CzopttqC.js} +1 -1
  172. package/dist/chunks/{useSettingsErrors-DYQ44kX4.js → useSettingsErrors-SFPWfxsA.js} +1 -1
  173. package/dist/chunks/{util-CtlC2dsN.js → util-Cbb3S6SX.js} +1 -1
  174. package/dist/chunks/{validatePlugin-D6tFo87L.js → validatePlugin-BMSoeb_b.js} +1 -1
  175. package/dist/chunks/worktree-Vm-SNY5x.js +1 -0
  176. package/dist/cli.js +1 -1
  177. package/package.json +1 -1
  178. package/dist/chunks/AgentsMdExternalIncludesDialog-CDNd5-7E.js +0 -1
  179. package/dist/chunks/CustomSelect-DoeEXOIP.js +0 -1
  180. package/dist/chunks/Doctor-DNgkgYhB.js +0 -1
  181. package/dist/chunks/REPL-CrVuMQY2.js +0 -1
  182. package/dist/chunks/SearchExtraToolsTool-lv7VE50N.js +0 -1
  183. package/dist/chunks/backgroundHousekeeping-BGxHB_OX.js +0 -1
  184. package/dist/chunks/caches-BGzKwpnc.js +0 -1
  185. package/dist/chunks/commands-QepeBbFn.js +0 -1
  186. package/dist/chunks/config-D58C3_Lu.js +0 -1
  187. package/dist/chunks/context-noninteractive-BDDi3NLF.js +0 -1
  188. package/dist/chunks/conversation-B0wxBwzv.js +0 -1
  189. package/dist/chunks/doctor-CkLzqAMd.js +0 -1
  190. package/dist/chunks/extractMemories-xP63mv6R.js +0 -1
  191. package/dist/chunks/fast-C5nQH8rm.js +0 -1
  192. package/dist/chunks/fetchModelList-D24lRIgR.js +0 -1
  193. package/dist/chunks/firstPartyEventLogger-BVAogAX8.js +0 -1
  194. package/dist/chunks/hooks-BNuUlMzL.js +0 -1
  195. package/dist/chunks/loadAgentsDir-CcmY8zCj.js +0 -1
  196. package/dist/chunks/localSearch-DrUj0B-d.js +0 -1
  197. package/dist/chunks/pluginStartupCheck-HS1ZceZa.js +0 -1
  198. package/dist/chunks/prompt-CHobfCB1.js +0 -1
  199. package/dist/chunks/prompt-CMm6RHHc.js +0 -1
  200. package/dist/chunks/sandbox-adapter-8GO6eJxw.js +0 -1
  201. package/dist/chunks/searchExtraTools-BhDq8DTJ.js +0 -1
  202. package/dist/chunks/sessionFileAccessHooks-CozocHQE.js +0 -1
  203. package/dist/chunks/sessionObserver-DGEQM4cO.js +0 -1
  204. package/dist/chunks/sessionStorage-BcAscOGE.js +0 -1
  205. package/dist/chunks/sinks-CGdKmq_8.js +0 -1
  206. package/dist/chunks/status-Daaak6Bo.js +0 -1
  207. package/dist/chunks/switcher-BpgmH4AI.js +0 -1
  208. package/dist/chunks/useMainLoopModel-DwjSVzzO.js +0 -1
  209. package/dist/chunks/useMergedTools-Bw8FchX8.js +0 -1
  210. package/dist/chunks/worktree-B8apCnVe.js +0 -1
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Fa as t,Fv as n,Go as r,Ia as i,Mo as a,Pv as o,Wo as s,Yf as c,ah as l,ap as u,ep as d,i as f,ih as p,ip as m,jo as h,np as g,o as _,qf as v}from"./loadAgentsDir-DlPbtIsS.js";import{It as y,J as b}from"./state-B4jiUise.js";import{I as x,M as S,c as C,i as w}from"./debug-Bglx1aTu.js";import{o as T,s as E}from"./log-D2TIwHBV.js";async function D(e){C(`refreshActivePlugins: clearing all plugin caches`),h(),v();let t=await i(),[r,a]=await Promise.all([s(),f(b())]),{enabled:o,disabled:c,errors:d}=t,[p,m]=await Promise.all([Promise.all(o.map(async e=>{if(e.mcpServers)return Object.keys(e.mcpServers).length;let t=await n(e,d);return t&&(e.mcpServers=t),t?Object.keys(t).length:0})),Promise.all(o.map(async e=>{if(e.lspServers)return Object.keys(e.lspServers).length;let t=await u(e,d);return t&&(e.lspServers=t),t?Object.keys(t).length:0}))]),_=p.reduce((e,t)=>e+t,0),y=m.reduce((e,t)=>e+t,0);e(e=>({...e,plugins:{...e.plugins,enabled:o,disabled:c,commands:r,errors:O(e.plugins.errors,d),needsRefresh:!1},agentDefinitions:a,mcp:{...e.mcp,pluginReconnectKey:e.mcp.pluginReconnectKey+1}})),g();let x=!1;try{await l()}catch(e){x=!0,E(e),C(`refreshActivePlugins: loadPluginHooks failed: ${S(e)}`)}let w=o.reduce((e,t)=>t.hooksConfig?e+Object.values(t.hooksConfig).reduce((e,t)=>e+(t?.reduce((e,t)=>e+t.hooks.length,0)??0),0):e,0);return C(`refreshActivePlugins: ${o.length} enabled, ${r.length} commands, ${a.allAgents.length} agents, ${w} hooks, ${_} MCP, ${y} LSP`),{enabled_count:o.length,disabled_count:c.length,command_count:r.length,agent_count:a.allAgents.length,hook_count:w,mcp_count:_,lsp_count:y,error_count:d.length+ +!!x,agentDefinitions:a,pluginCommands:r}}function O(e,t){let n=e.filter(e=>e.source===`lsp-manager`||e.source.startsWith(`plugin:`)),r=new Set(t.map(k));return[...n.filter(e=>!r.has(k(e))),...t]}function k(e){return e.type===`generic-error`?`generic-error:${e.source}:${e.error}`:`${e.type}:${e.source}`}var A=e((()=>{y(),d(),_(),w(),x(),T(),a(),r(),p(),m(),o(),c(),t()}));export{D as n,A as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Fa as t,Fv as n,Go as r,Ia as i,Mo as a,Pv as o,Wo as s,Yf as c,ah as l,ap as u,ep as d,i as f,ih as p,ip as m,jo as h,np as g,o as _,qf as v}from"./loadAgentsDir-B0Anodo0.js";import{It as y,J as b}from"./state-B4jiUise.js";import{I as x,M as S,c as C,i as w}from"./debug-Bglx1aTu.js";import{o as T,s as E}from"./log-D2TIwHBV.js";async function D(e){C(`refreshActivePlugins: clearing all plugin caches`),h(),v();let t=await i(),[r,a]=await Promise.all([s(),f(b())]),{enabled:o,disabled:c,errors:d}=t,[p,m]=await Promise.all([Promise.all(o.map(async e=>{if(e.mcpServers)return Object.keys(e.mcpServers).length;let t=await n(e,d);return t&&(e.mcpServers=t),t?Object.keys(t).length:0})),Promise.all(o.map(async e=>{if(e.lspServers)return Object.keys(e.lspServers).length;let t=await u(e,d);return t&&(e.lspServers=t),t?Object.keys(t).length:0}))]),_=p.reduce((e,t)=>e+t,0),y=m.reduce((e,t)=>e+t,0);e(e=>({...e,plugins:{...e.plugins,enabled:o,disabled:c,commands:r,errors:O(e.plugins.errors,d),needsRefresh:!1},agentDefinitions:a,mcp:{...e.mcp,pluginReconnectKey:e.mcp.pluginReconnectKey+1}})),g();let x=!1;try{await l()}catch(e){x=!0,E(e),C(`refreshActivePlugins: loadPluginHooks failed: ${S(e)}`)}let w=o.reduce((e,t)=>t.hooksConfig?e+Object.values(t.hooksConfig).reduce((e,t)=>e+(t?.reduce((e,t)=>e+t.hooks.length,0)??0),0):e,0);return C(`refreshActivePlugins: ${o.length} enabled, ${r.length} commands, ${a.allAgents.length} agents, ${w} hooks, ${_} MCP, ${y} LSP`),{enabled_count:o.length,disabled_count:c.length,command_count:r.length,agent_count:a.allAgents.length,hook_count:w,mcp_count:_,lsp_count:y,error_count:d.length+ +!!x,agentDefinitions:a,pluginCommands:r}}function O(e,t){let n=e.filter(e=>e.source===`lsp-manager`||e.source.startsWith(`plugin:`)),r=new Set(t.map(k));return[...n.filter(e=>!r.has(k(e))),...t]}function k(e){return e.type===`generic-error`?`generic-error:${e.source}:${e.error}`:`${e.type}:${e.source}`}var A=e((()=>{y(),d(),_(),w(),x(),T(),a(),r(),p(),m(),o(),c(),t()}));export{D as n,A as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,o as n}from"./isObject-C6qM3WEW.js";import{BC as r,FC as i,Gw as a,PC as o,VC as s,Ww as c}from"./loadAgentsDir-DlPbtIsS.js";import{Jr as ee,Yr as l,ai as u,dr as te,ei as ne,fr as d,hr as f,ii as p,mr as m,oi as re,or as ie,pr as h,si as ae,sr as g,ti as _,ur as v,vr as y,yr as b}from"./state-B4jiUise.js";import{Gn as x,Jn as S,Kn as C,Xn as w,Yn as T,fi as E,pi as D,qn as O}from"./settings-B2jvL8Dp.js";import{M as k,N as A}from"./config-C-Y2qtB2.js";import{n as j,t as M}from"./_baseEach-4ff-vRlp.js";function N(e){return u(e)||l(e)||!!(P&&e&&e[P])}var P,F=e((()=>{n(),ee(),p(),P=t?t.isConcatSpreadable:void 0}));function I(e,t,n,r,i){var a=-1,o=e.length;for(n||(n=N),i||(i=[]);++a<o;){var s=e[a];t>0&&n(s)?t>1?I(s,t-1,n,r,i):re(i,s):r||(i[i.length]=s)}return i}var L=e((()=>{ae(),F()}));function R(e){return e!=null&&e.length?I(e,1):[]}var z=e((()=>{L()}));function B(e){return C(S(e,void 0,R),e+``)}var V=e((()=>{z(),O(),x()}));function H(e,t){var n=[];return M(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}var U=e((()=>{j()}));function W(e,t){return t.length<2?e:v(e,r(t,0,-1))}var G=e((()=>{te(),s()}));function K(e){if(typeof e!=`function`)throw TypeError(q);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}var q,J=e((()=>{q=`Expected a function`}));function oe(e,t){t=m(t,e);var n=-1,r=t.length;if(!r)return!0;for(;++n<r;){var a=h(t[n]);if(a===`__proto__`&&!Y.call(e,`__proto__`)||(a===`constructor`||a===`prototype`)&&n<r-1)return!1}var o=W(e,t);return o==null||delete o[h(i(t))]}var Y,se=e((()=>{f(),o(),G(),d(),Y=Object.prototype.hasOwnProperty}));function ce(e){return w(e)?void 0:e}var le=e((()=>{T()})),X,Z,Q,$,ue=e((()=>{b(),a(),se(),f(),D(),le(),V(),A(),X=1,Z=2,Q=4,$=B(function(e,t){var n={};if(e==null)return n;var r=!1;t=y(t,function(t){return t=m(t,e),r||(r=t.length>1),t}),E(e,k(e),n),r&&(n=c(n,X|Z|Q,ce));for(var i=t.length;i--;)oe(n,t[i]);return n})}));function de(e,t){return(u(e)?ne:H)(e,K(ie(t,3)))}var fe=e((()=>{_(),U(),g(),p(),J()}));export{$ as i,de as n,ue as r,fe as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,o as n}from"./isObject-C6qM3WEW.js";import{BC as r,FC as i,Gw as a,PC as o,VC as s,Ww as c}from"./loadAgentsDir-B0Anodo0.js";import{Jr as ee,Yr as l,ai as u,dr as te,ei as ne,fr as d,hr as f,ii as p,mr as m,oi as re,or as ie,pr as h,si as ae,sr as g,ti as _,ur as v,vr as y,yr as b}from"./state-B4jiUise.js";import{Gn as x,Jn as S,Kn as C,Xn as w,Yn as T,fi as E,pi as D,qn as O}from"./settings-B2jvL8Dp.js";import{M as k,N as A}from"./config-C-Y2qtB2.js";import{n as j,t as M}from"./_baseEach-CsIRoaTH.js";function N(e){return u(e)||l(e)||!!(P&&e&&e[P])}var P,F=e((()=>{n(),ee(),p(),P=t?t.isConcatSpreadable:void 0}));function I(e,t,n,r,i){var a=-1,o=e.length;for(n||(n=N),i||(i=[]);++a<o;){var s=e[a];t>0&&n(s)?t>1?I(s,t-1,n,r,i):re(i,s):r||(i[i.length]=s)}return i}var L=e((()=>{ae(),F()}));function R(e){return e!=null&&e.length?I(e,1):[]}var z=e((()=>{L()}));function B(e){return C(S(e,void 0,R),e+``)}var V=e((()=>{z(),O(),x()}));function H(e,t){var n=[];return M(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}var U=e((()=>{j()}));function W(e,t){return t.length<2?e:v(e,r(t,0,-1))}var G=e((()=>{te(),s()}));function K(e){if(typeof e!=`function`)throw TypeError(q);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}var q,J=e((()=>{q=`Expected a function`}));function oe(e,t){t=m(t,e);var n=-1,r=t.length;if(!r)return!0;for(;++n<r;){var a=h(t[n]);if(a===`__proto__`&&!Y.call(e,`__proto__`)||(a===`constructor`||a===`prototype`)&&n<r-1)return!1}var o=W(e,t);return o==null||delete o[h(i(t))]}var Y,se=e((()=>{f(),o(),G(),d(),Y=Object.prototype.hasOwnProperty}));function ce(e){return w(e)?void 0:e}var le=e((()=>{T()})),X,Z,Q,$,ue=e((()=>{b(),a(),se(),f(),D(),le(),V(),A(),X=1,Z=2,Q=4,$=B(function(e,t){var n={};if(e==null)return n;var r=!1;t=y(t,function(t){return t=m(t,e),r||(r=t.length>1),t}),E(e,k(e),n),r&&(n=c(n,X|Z|Q,ce));for(var i=t.length;i--;)oe(n,t[i]);return n})}));function de(e,t){return(u(e)?ne:H)(e,K(ie(t,3)))}var fe=e((()=>{_(),U(),g(),p(),J()}));export{$ as i,de as n,ue as r,fe as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./stringUtils-C718f5ey.js";import{n as r,t as i}from"./refresh-Ce2yk28a.js";function a(e,n){return`${e} ${t(e,n)}`}var o;e((()=>{i(),n(),o=async(e,t)=>{let n=await r(t.setAppState),i=`Reloaded: ${[a(n.enabled_count,`plugin`),a(n.command_count,`skill`),a(n.agent_count,`agent`),a(n.hook_count,`hook`),a(n.mcp_count,`plugin MCP server`),a(n.lsp_count,`plugin LSP server`)].join(` · `)}`;return n.error_count>0&&(i+=`\n${a(n.error_count,`error`)} during load. Run /doctor for details.`),{type:`text`,value:i}}}))();export{o as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./stringUtils-C718f5ey.js";import{n as r,t as i}from"./refresh-Dn_I1R4v.js";function a(e,n){return`${e} ${t(e,n)}`}var o;e((()=>{i(),n(),o=async(e,t)=>{let n=await r(t.setAppState),i=`Reloaded: ${[a(n.enabled_count,`plugin`),a(n.command_count,`skill`),a(n.agent_count,`agent`),a(n.hook_count,`hook`),a(n.mcp_count,`plugin MCP server`),a(n.lsp_count,`plugin LSP server`)].join(` · `)}`;return n.error_count>0&&(i+=`\n${a(n.error_count,`error`)} during load. Run /doctor for details.`),{type:`text`,value:i}}}))();export{o as call};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Qr as t,Qx as n,Yi as r,_r as i,pr as a,ti as o}from"./loadAgentsDir-DlPbtIsS.js";import{It as s,st as c}from"./state-B4jiUise.js";import{n as l,t as u}from"./generateSessionName-BQoDduyA.js";async function d(e,r,i){let s;if(!i||i.trim()===``){let t=await u(n(r.messages),r.abortController.signal);if(!t)return e(`Could not generate a name: no conversation context yet. Usage: /rename <name>`,{display:`system`}),null;s=t}else s=i.trim();let l=c(),d=a();return await o(l,s,d),await t(l,s,d),r.setAppState(e=>({...e,standaloneAgentContext:{...e.standaloneAgentContext,name:s}})),e(`Session renamed to: ${s}`,{display:`system`}),null}e((()=>{s(),r(),i(),l()}))();export{d as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Qr as t,Qx as n,Yi as r,_r as i,pr as a,ti as o}from"./loadAgentsDir-B0Anodo0.js";import{It as s,st as c}from"./state-B4jiUise.js";import{n as l,t as u}from"./generateSessionName-CQ03xlYI.js";async function d(e,r,i){let s;if(!i||i.trim()===``){let t=await u(n(r.messages),r.abortController.signal);if(!t)return e(`Could not generate a name: no conversation context yet. Usage: /rename <name>`,{display:`system`}),null;s=t}else s=i.trim();let l=c(),d=a();return await o(l,s,d),await t(l,s,d),r.setAppState(e=>({...e,standaloneAgentContext:{...e.standaloneAgentContext,name:s}})),e(`Session renamed to: ${s}`,{display:`system`}),null}e((()=>{s(),r(),i(),l()}))();export{d as call};
@@ -1,2 +1,2 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{Er as i,Id as a,Ld as o,_r as s,bb as c,bi as l,jr as u,kr as d,nb as f,rb as p,rr as m,si as h,ur as g,xi as _,xr as v,yr as y}from"./loadAgentsDir-DlPbtIsS.js";import{I as b,P as x,ai as S,di as C,dr as w,fi as T,ot as E,t as D}from"./src-DL3w8VPk.js";import{t as O}from"./jsx-runtime-Bb4Xn-E0.js";import{It as k,J as A,st as j}from"./state-B4jiUise.js";import{o as M,s as N}from"./log-D2TIwHBV.js";import{r as P,t as F}from"./Spinner-zYPFVFHN.js";import{n as I,r as L}from"./modalContext-DDZdU1J8.js";import{a as R,i as z,n as B,o as V,r as H,t as U}from"./crossProjectResume-6boHMUBx.js";function W(e){switch(e.resultType){case`sessionNotFound`:return`Session ${C.bold(e.arg)} was not found. Run ${C.bold(`/resume`)} without arguments to browse all sessions.`;case`multipleMatches`:return`Found ${e.count} sessions matching ${C.bold(e.arg)}. Run ${C.bold(`/resume`)} to pick one from the list.`}}function G({message:e,args:t,onDone:n}){return J.useEffect(()=>{let e=setTimeout(n,0);return()=>clearTimeout(e)},[n]),(0,Y.jsxs)(b,{flexDirection:`column`,children:[(0,Y.jsxs)(x,{dimColor:!0,children:[r.pointer,` /resume `,t]}),(0,Y.jsx)(f,{children:(0,Y.jsx)(x,{children:e})})]})}function K({onDone:e,onResume:t}){let[n,r]=J.useState([]),[a,s]=J.useState([]),[c,f]=J.useState(!0),[p,m]=J.useState(!1),[h,_]=J.useState(!1),{rows:y}=E(),S=L(),C=J.useCallback(async(t,n)=>{f(!0);try{let a=q(t?await i():await u(n),j());if(a.length===0){e(`No conversations found to resume`);return}r(a)}catch{e(`Failed to load conversations`)}finally{f(!1)}},[e]);J.useEffect(()=>{async function e(){let e=await l(A());s(e),C(!1,e)}e()},[C]);let T=J.useCallback(()=>{let e=!h;_(e),C(e,a)},[h,C,a]);async function D(n){let r=o(g(n));if(!r){e(`Failed to resume conversation`);return}let i=v(n)?await d(n):n,a=U(i,h);if(a.isCrossProject){if(a.isSameRepoWorktree){m(!0),t(r,i,`slash_command_picker`);return}let n=await w(a.command);n&&process.stdout.write(n),e([``,`This conversation is from a different directory.`,``,`To resume, run:`,` ${a.command}`,``,`(Command copied to clipboard)`,``].join(`
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{Er as i,Id as a,Ld as o,_r as s,bb as c,bi as l,jr as u,kr as d,nb as f,rb as p,rr as m,si as h,ur as g,xi as _,xr as v,yr as y}from"./loadAgentsDir-B0Anodo0.js";import{I as b,P as x,ai as S,di as C,dr as w,fi as T,ot as E,t as D}from"./src-DL3w8VPk.js";import{t as O}from"./jsx-runtime-Bb4Xn-E0.js";import{It as k,J as A,st as j}from"./state-B4jiUise.js";import{o as M,s as N}from"./log-D2TIwHBV.js";import{r as P,t as F}from"./Spinner-ByQXTvAA.js";import{n as I,r as L}from"./modalContext-DDZdU1J8.js";import{a as R,i as z,n as B,o as V,r as H,t as U}from"./crossProjectResume-DxMy05_P.js";function W(e){switch(e.resultType){case`sessionNotFound`:return`Session ${C.bold(e.arg)} was not found. Run ${C.bold(`/resume`)} without arguments to browse all sessions.`;case`multipleMatches`:return`Found ${e.count} sessions matching ${C.bold(e.arg)}. Run ${C.bold(`/resume`)} to pick one from the list.`}}function G({message:e,args:t,onDone:n}){return J.useEffect(()=>{let e=setTimeout(n,0);return()=>clearTimeout(e)},[n]),(0,Y.jsxs)(b,{flexDirection:`column`,children:[(0,Y.jsxs)(x,{dimColor:!0,children:[r.pointer,` /resume `,t]}),(0,Y.jsx)(f,{children:(0,Y.jsx)(x,{children:e})})]})}function K({onDone:e,onResume:t}){let[n,r]=J.useState([]),[a,s]=J.useState([]),[c,f]=J.useState(!0),[p,m]=J.useState(!1),[h,_]=J.useState(!1),{rows:y}=E(),S=L(),C=J.useCallback(async(t,n)=>{f(!0);try{let a=q(t?await i():await u(n),j());if(a.length===0){e(`No conversations found to resume`);return}r(a)}catch{e(`Failed to load conversations`)}finally{f(!1)}},[e]);J.useEffect(()=>{async function e(){let e=await l(A());s(e),C(!1,e)}e()},[C]);let T=J.useCallback(()=>{let e=!h;_(e),C(e,a)},[h,C,a]);async function D(n){let r=o(g(n));if(!r){e(`Failed to resume conversation`);return}let i=v(n)?await d(n):n,a=U(i,h);if(a.isCrossProject){if(a.isSameRepoWorktree){m(!0),t(r,i,`slash_command_picker`);return}let n=await w(a.command);n&&process.stdout.write(n),e([``,`This conversation is from a different directory.`,``,`To resume, run:`,` ${a.command}`,``,`(Command copied to clipboard)`,``].join(`
2
2
  `),{display:`user`});return}m(!0),t(r,i,`slash_command_picker`)}function O(){e(`Resume cancelled`,{display:`system`})}return c?(0,Y.jsxs)(b,{children:[(0,Y.jsx)(F,{}),(0,Y.jsx)(x,{children:` Loading conversations…`})]}):p?(0,Y.jsxs)(b,{children:[(0,Y.jsx)(F,{}),(0,Y.jsx)(x,{children:` Resuming conversation…`})]}):(0,Y.jsx)(R,{logs:n,maxHeight:S?Math.floor(y/2):y-2,onCancel:O,onSelect:D,onLogsChanged:()=>C(h,a),showAllProjects:h,onToggleAllProjects:T,onAgenticSearch:H})}function q(e,t){return e.filter(e=>!e.isSidechain&&g(e)!==t)}var J,Y,X;e((()=>{T(),n(),J=t(S(),1),k(),V(),p(),P(),I(),c(),D(),z(),B(),_(),M(),s(),a(),Y=O(),X=async(e,t,n)=>{let r=async(n,r,i)=>{try{await t.resume?.(n,r,i),e(void 0,{display:`skip`})}catch(t){N(t),e(`Failed to resume: ${t.message}`)}},i=n?.trim();if(!i)return(0,Y.jsx)(K,{onDone:e,onResume:r},Date.now());let a=await u(await l(A()));if(a.length===0){let t=`No conversations found to resume.`;return(0,Y.jsx)(G,{message:t,args:i,onDone:()=>e(t)})}let s=o(i);if(s){let e=a.filter(e=>g(e)===s).sort((e,t)=>t.modified.getTime()-e.modified.getTime());if(e.length>0){let t=e[0];return r(s,v(t)?await d(t):t,`slash_command_session_id`),null}let t=await m(s);if(t)return r(s,t,`slash_command_session_id`),null}if(y()){let t=await h(i,{exact:!0});if(t.length===1){let e=t[0],n=g(e);if(n)return r(n,v(e)?await d(e):e,`slash_command_title`),null}if(t.length>1){let n=W({resultType:`multipleMatches`,arg:i,count:t.length});return(0,Y.jsx)(G,{message:n,args:i,onDone:()=>e(n)})}}let c=W({resultType:`sessionNotFound`,arg:i});return(0,Y.jsx)(G,{message:c,args:i,onDone:()=>e(c)})}}))();export{X as call,q as filterResumableSessions};
@@ -1 +1 @@
1
- import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./runtimeObserver-XQrOux41.js";t();export{o as RUNTIME_SESSION_ID,n as getRuntimeTurn,i as initSkillLearning,e as resetRuntimeLLMBookkeeping,r as resetRuntimeObserverForTest,a as runSkillLearningPostSampling};
1
+ import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./runtimeObserver-PJ1o8GRA.js";t();export{o as RUNTIME_SESSION_ID,n as getRuntimeTurn,i as initSkillLearning,e as resetRuntimeLLMBookkeeping,r as resetRuntimeObserverForTest,a as runSkillLearningPostSampling};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-DfkgIdYf.js";import{Jd as r,Ni as i,Yd as a,wi as o}from"./loadAgentsDir-DlPbtIsS.js";import{n as s,t as c}from"./featureCheck-D6FjD-nt.js";import{a as l,s as u}from"./projectContext-DhtjLv3k.js";import{a as d,c as ee,i as f,l as p,n as m,o as h,r as te,s as ne,u as g}from"./instinctParser-Dt-lqnDe.js";import{a as re,i as ie,n as _,o as v,r as y,t as ae}from"./observationStore-D0rm3GhP.js";import{a as oe,i as se,o as ce,r as le}from"./sessionObserver-DS4G6mb9.js";import{a as ue,d as b,i as de,l as x,n as S,r as fe,s as C,t as pe,u as w}from"./skillLifecycle-BMY2JGGG.js";import{join as T}from"node:path";import{existsSync as E}from"node:fs";import{randomBytes as me}from"node:crypto";import{mkdir as D,readFile as he,readdir as O,rename as ge,unlink as _e,writeFile as k}from"node:fs/promises";function A(e){let t=_(e),n=e?.project;return(e?.scope??n?.scope??`project`)===`global`||!n||n.projectId===`global`?T(t,`global`,`instincts`,`personal`):T(t,`projects`,n.projectId,`instincts`,`personal`)}async function j(e,t){let n=h(e);await D(A(t),{recursive:!0});let r=N(n.id,t),i=`${r}.${me(6).toString(`hex`)}.tmp`;return await k(i,ee(n)),await ge(i,r),n}async function M(e){let t=A(e),n=[];try{n=await O(t)}catch(e){if(e.code===`ENOENT`)return[];throw e}let r=[];for(let e of n.filter(e=>e.endsWith(`.json`))){let n=await he(T(t,e),`utf8`);r.push(ne(n))}return r.sort((e,t)=>e.id.localeCompare(t.id))}function ve(e,t){let n=P.then(()=>ye(e,t));return P=n.catch(()=>{}),n}async function ye(e,t){let n=await M(t),r=n.find(t=>t.id===e.id)??n.find(t=>t.trigger.toLowerCase()===e.trigger.toLowerCase()&&d(t,e)),i=new Date().toISOString();if(!r)return j(e,t);let a=d(r,e),o=a?-.1:Se(e.evidenceOutcome),s=m(r.confidence+o),c=be(r.status,s,a);return j(h({...r,confidence:s,evidence:[...r.evidence,...e.evidence],evidenceOutcome:e.evidenceOutcome??r.evidenceOutcome,observationIds:[...r.observationIds??[],...e.observationIds??[]],updatedAt:i,status:c}),t)}function be(e,t,n){return n&&t<.3?`conflict-hold`:e===`conflict-hold`&&t>=.5||e===`pending`&&t>=.8?`active`:e}async function xe(e){let t=await M(e),n=Date.now(),r=0;for(let i of t){if(i.status!==`pending`&&i.status!==`active`)continue;let t=Date.parse(i.updatedAt);if(Number.isNaN(t))continue;let a=Math.floor((n-t)/F);if(a<1)continue;let o=-.02*a,s=m(i.confidence+o);s!==i.confidence&&(await j(h({...i,confidence:s,updatedAt:new Date(n).toISOString()}),e),r+=1)}return r}function Se(e){return e===`failure`?-.05:.05}async function Ce(e,t){let n=await M(t),r=Date.now()-e*24*60*60*1e3,i=[];for(let e of n)e.status===`pending`&&Date.parse(e.updatedAt)<r&&(await _e(N(e.id,t)),i.push(e));return i}function N(e,t){return T(A(t),`${e}.json`)}var P,F,I=e((()=>{y(),f(),P=Promise.resolve(),F=10080*60*1e3}));function we(e,t){if(e.length===0)throw Error(`Cannot generate a command draft without instincts`);let n=t?.scope??e[0]?.scope??`project`,r=w(t?.name??De(e)),i=Ae(e),a=t?.description??Oe(e),o=Ee(r,n,t),s=ke({name:r,description:a,confidence:i,instincts:e});return{name:r,description:a,scope:n,sourceInstinctIds:e.map(e=>e.id),confidence:Number(i.toFixed(2)),content:s,outputPath:o}}async function Te(e){await D(e.outputPath,{recursive:!0});let t=T(e.outputPath,`${e.name}.md`);return E(t)?t:(await k(t,e.content,`utf8`),o(),t)}function Ee(e,n,r){return r?.outputRoot?r.outputRoot:n===`project`?T(r?.cwd??process.cwd(),`.workmate`,`commands`):r?.globalCommandsDir??T(t(),`commands`)}function De(e){return w([`learned`,...je(e,4)].join(`-`))||`learned-command`}function Oe(e){return(e[0]?.trigger??`Reuse the learned workflow`).replace(/\s+/g,` `).slice(0,120)}function ke(e){let{name:t,description:n,confidence:r,instincts:i}=e;return[`---`,`name: ${t}`,`description: ${JSON.stringify(n)}`,`origin: skill-learning`,`confidence: ${Number(r.toFixed(2))}`,`evolved_from: [${i.map(e=>JSON.stringify(e.id)).join(`, `)}]`,`---`,``,`# /${t}`,``,`## When to use`,``,i.map(e=>`- ${e.trigger}`).join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-DfkgIdYf.js";import{Jd as r,Ni as i,Yd as a,wi as o}from"./loadAgentsDir-B0Anodo0.js";import{n as s,t as c}from"./featureCheck-D6FjD-nt.js";import{a as l,s as u}from"./projectContext-DhtjLv3k.js";import{a as d,c as ee,i as f,l as p,n as m,o as h,r as te,s as ne,u as g}from"./instinctParser-Dt-lqnDe.js";import{a as re,i as ie,n as _,o as v,r as y,t as ae}from"./observationStore-D0rm3GhP.js";import{a as oe,i as se,o as ce,r as le}from"./sessionObserver-BtKjvteq.js";import{a as ue,d as b,i as de,l as x,n as S,r as fe,s as C,t as pe,u as w}from"./skillLifecycle-Bnz_4wE5.js";import{join as T}from"node:path";import{existsSync as E}from"node:fs";import{randomBytes as me}from"node:crypto";import{mkdir as D,readFile as he,readdir as O,rename as ge,unlink as _e,writeFile as k}from"node:fs/promises";function A(e){let t=_(e),n=e?.project;return(e?.scope??n?.scope??`project`)===`global`||!n||n.projectId===`global`?T(t,`global`,`instincts`,`personal`):T(t,`projects`,n.projectId,`instincts`,`personal`)}async function j(e,t){let n=h(e);await D(A(t),{recursive:!0});let r=N(n.id,t),i=`${r}.${me(6).toString(`hex`)}.tmp`;return await k(i,ee(n)),await ge(i,r),n}async function M(e){let t=A(e),n=[];try{n=await O(t)}catch(e){if(e.code===`ENOENT`)return[];throw e}let r=[];for(let e of n.filter(e=>e.endsWith(`.json`))){let n=await he(T(t,e),`utf8`);r.push(ne(n))}return r.sort((e,t)=>e.id.localeCompare(t.id))}function ve(e,t){let n=P.then(()=>ye(e,t));return P=n.catch(()=>{}),n}async function ye(e,t){let n=await M(t),r=n.find(t=>t.id===e.id)??n.find(t=>t.trigger.toLowerCase()===e.trigger.toLowerCase()&&d(t,e)),i=new Date().toISOString();if(!r)return j(e,t);let a=d(r,e),o=a?-.1:Se(e.evidenceOutcome),s=m(r.confidence+o),c=be(r.status,s,a);return j(h({...r,confidence:s,evidence:[...r.evidence,...e.evidence],evidenceOutcome:e.evidenceOutcome??r.evidenceOutcome,observationIds:[...r.observationIds??[],...e.observationIds??[]],updatedAt:i,status:c}),t)}function be(e,t,n){return n&&t<.3?`conflict-hold`:e===`conflict-hold`&&t>=.5||e===`pending`&&t>=.8?`active`:e}async function xe(e){let t=await M(e),n=Date.now(),r=0;for(let i of t){if(i.status!==`pending`&&i.status!==`active`)continue;let t=Date.parse(i.updatedAt);if(Number.isNaN(t))continue;let a=Math.floor((n-t)/F);if(a<1)continue;let o=-.02*a,s=m(i.confidence+o);s!==i.confidence&&(await j(h({...i,confidence:s,updatedAt:new Date(n).toISOString()}),e),r+=1)}return r}function Se(e){return e===`failure`?-.05:.05}async function Ce(e,t){let n=await M(t),r=Date.now()-e*24*60*60*1e3,i=[];for(let e of n)e.status===`pending`&&Date.parse(e.updatedAt)<r&&(await _e(N(e.id,t)),i.push(e));return i}function N(e,t){return T(A(t),`${e}.json`)}var P,F,I=e((()=>{y(),f(),P=Promise.resolve(),F=10080*60*1e3}));function we(e,t){if(e.length===0)throw Error(`Cannot generate a command draft without instincts`);let n=t?.scope??e[0]?.scope??`project`,r=w(t?.name??De(e)),i=Ae(e),a=t?.description??Oe(e),o=Ee(r,n,t),s=ke({name:r,description:a,confidence:i,instincts:e});return{name:r,description:a,scope:n,sourceInstinctIds:e.map(e=>e.id),confidence:Number(i.toFixed(2)),content:s,outputPath:o}}async function Te(e){await D(e.outputPath,{recursive:!0});let t=T(e.outputPath,`${e.name}.md`);return E(t)?t:(await k(t,e.content,`utf8`),o(),t)}function Ee(e,n,r){return r?.outputRoot?r.outputRoot:n===`project`?T(r?.cwd??process.cwd(),`.workmate`,`commands`):r?.globalCommandsDir??T(t(),`commands`)}function De(e){return w([`learned`,...je(e,4)].join(`-`))||`learned-command`}function Oe(e){return(e[0]?.trigger??`Reuse the learned workflow`).replace(/\s+/g,` `).slice(0,120)}function ke(e){let{name:t,description:n,confidence:r,instincts:i}=e;return[`---`,`name: ${t}`,`description: ${JSON.stringify(n)}`,`origin: skill-learning`,`confidence: ${Number(r.toFixed(2))}`,`evolved_from: [${i.map(e=>JSON.stringify(e.id)).join(`, `)}]`,`---`,``,`# /${t}`,``,`## When to use`,``,i.map(e=>`- ${e.trigger}`).join(`
2
2
  `),``,`## Steps`,``,i.map(e=>`- ${e.action}`).join(`
3
3
  `),``,`## Evidence`,``,i.flatMap(e=>e.evidence.map(e=>`- ${e}`)).join(`
4
4
  `),``].join(`
@@ -6,5 +6,5 @@ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./e
6
6
  `),``,`## Playbook`,``,i.map(e=>`- ${e.action}`).join(`
7
7
  `),``,`## Evidence`,``,i.flatMap(e=>e.evidence.map(e=>`- ${e}`)).slice(0,20).join(`
8
8
  `),``].join(`
9
- `)}function Re(e){return e.reduce((e,t)=>e+t.confidence,0)/e.length}function ze(e,t){let n=new Set([`when`,`with`,`this`,`that`,`user`,`asks`,`for`,`the`,`and`,`debug`,`investigate`,`research`]),r=[];for(let i of e)for(let e of`${i.trigger} ${i.action}`.toLowerCase().split(/[^a-z0-9]+/))if(e.length>2&&!n.has(e)&&!r.includes(e)&&r.push(e),r.length>=t)return r;return r}var R=e((()=>{n(),i(),x()}));function z(e){let t=new Map;for(let n of e){if(n.status!==`active`&&n.status!==`pending`)continue;let e=`${n.domain}:${Ue(n.trigger)}`,r=t.get(e)??[];r.push(n),t.set(e,r)}return Array.from(t.values()).filter(e=>e.length>=p().minClusterSize).map(e=>{let t=e.reduce((e,t)=>e+t.confidence,0)/e.length;return{target:Be(e),trigger:e[0]?.trigger??`learned pattern`,domain:e[0]?.domain??`project`,instincts:e,averageConfidence:Number(t.toFixed(2))}}).sort((e,t)=>t.averageConfidence-e.averageConfidence)}function Be(e){let t=Array.isArray(e)?e:e.instincts,n=t.map(e=>`${e.trigger} ${e.action}`).join(` `).toLowerCase();return/user asks|explicitly request|command|run /.test(n)?`command`:t.length>=4&&/(debug|investigate|research|multi-step)/.test(n)?`agent`:`skill`}function Ve(e,t){return z(e).filter(e=>e.target===`command`&&b(e.instincts)).map(e=>we(e.instincts,{...t,scope:e.instincts[0]?.scope??`project`}))}function He(e,t){return z(e).filter(e=>e.target===`agent`&&b(e.instincts)).map(e=>Me(e.instincts,{...t,scope:e.instincts[0]?.scope??`project`}))}function Ue(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,` `).split(/\s+/).filter(Boolean).slice(0,6).join(` `)}var We=e((()=>{x(),C(),L(),R(),g()}));function Ge(e){if(H.add(e),H.size>B){let e=H.size-V,t=H.values();for(let n=0;n<e;n++){let e=t.next();if(e.done)break;H.delete(e.value)}}}function Ke(e,t=2,n=.8){let r=new Map;for(let t of e){if(t.scope!==`project`)continue;let e=r.get(t.id)??[];e.push(t),r.set(t.id,e)}return Array.from(r.entries()).flatMap(([e,r])=>{let i=Array.from(new Set(r.map(e=>e.projectId).filter(Boolean))),a=r.reduce((e,t)=>e+t.confidence,0)/r.length;return i.length>=t&&a>=n?[{instinctId:e,projectIds:i,averageConfidence:Number(a.toFixed(2))}]:[]})}async function qe(e={}){let t=e.minProjects??2,n=e.minConfidence??.8,r=await Je(e.rootDir),i=Ke(r,t,n),a=[];for(let t of i){if(H.has(t.instinctId))continue;let n=r.find(e=>e.id===t.instinctId);n&&(await j({...n,scope:`global`,projectId:void 0,projectName:void 0,confidence:t.averageConfidence,updatedAt:new Date().toISOString()},{rootDir:e.rootDir,scope:`global`,project:Ye(e.rootDir)}),Ge(t.instinctId),a.push(t))}return a}async function Je(e){let t=T(_(e?{rootDir:e}:void 0),`projects`);if(!E(t))return[];let n=await O(t,{withFileTypes:!0}),r=[];for(let i of n){if(!i.isDirectory())continue;let n=await M({rootDir:e,project:{projectId:i.name,projectName:i.name,scope:`project`,source:`git_root`,cwd:t,storageDir:T(t,i.name)},scope:`project`});r.push(...n)}return r}function Ye(e){let t=_(e?{rootDir:e}:void 0);return{projectId:`global`,projectName:`Global`,scope:`global`,source:`global`,cwd:t,storageDir:T(t,`global`)}}var B,V,H,Xe=e((()=>{I(),y(),B=256,V=192,H=new Set}));function U(){X=0,Z=0,Q.clear()}function Ze(){return J}function Qe(){if(!q){q=!0;try{ce()}catch{}a(W),$e().catch(()=>{})}}async function $e(){if(!s()||process.env.CLAUDE_SKILL_LEARNING_DISABLE)return;let e={project:u(process.cwd())};await Promise.allSettled([xe(e),ie(e),Ce(30,e)])}function et(e){try{let t=_();return e.startsWith(t)}catch{return!1}}async function W(e){if(!s()||process.env.CLAUDE_SKILL_LEARNING_DISABLE||!e.querySource?.startsWith(`repl_main_thread`)||e.toolUseContext.agentId)return;let t=process.cwd();if(et(t))return;let n=u(t),r={project:n};++J;let i=[];for(let t of rt(e.messages,n))i.push(await ae(t,r));let a=(await re(r)).filter(e=>e.source===`tool-hook`&&e.sessionId===`runtime-session`&&typeof e.timestamp==`string`&&e.timestamp>Y);i.push(...a);for(let e of a)e.timestamp>Y&&(Y=e.timestamp);if(i.length===0)return;let o=Date.now(),{llm:c}=p(),l=i.length>=5&&X<c.maxCallsPerSession&&o-Z>=c.cooldownMs,d;if(l)X++,Z=o,d=await se(i,{project:n});else{let{heuristicObserverBackend:e}=await import(`./sessionObserver-DGEQM4cO.js`),t=e.analyze(i,{project:n});d=Array.isArray(t)?t:await t}for(let e of d)await ve(te(e),r);await nt(r)}function tt(){J=0,Y=``,U()}async function nt(e){let n=await M(e),r=process.cwd(),i=[T(r,`.workmate`,`skills`),T(t(),`skills`)],a=z(n).filter(e=>e.target===`skill`&&b(e.instincts));for(let e of a){let t=await ue(e.instincts,{cwd:r,scope:e.instincts[0]?.scope??`project`},i);if(t.action===`append-evidence`)continue;let n=t.draft;E(T(n.outputPath,`SKILL.md`))||await pe(fe(n,await S(`skill`,n,i)))}let o=Ve(n,{cwd:r});for(let e of o)(await S(`command`,e,[T(r,`.workmate`,`commands`),T(t(),`commands`)])).length>0||await Te(e);let s=He(n,{cwd:r});for(let e of s)(await S(`agent`,e,[T(r,`.workmate`,`agents`),T(t(),`agents`)])).length>0||await Ne(e);await qe()}function rt(e,t){let n=K,r={sessionId:n,projectId:t.projectId,projectName:t.projectName,cwd:t.cwd,timestamp:new Date().toISOString(),source:`hook`};return e.flatMap(e=>{let t=`${n}:${String(e.uuid)}`;if(Q.has(t))return[];if(Q.add(t),Q.size>$){let e=Q.size-ot,t=Q.values();for(let n=0;n<e;n++){let e=t.next();if(e.done)break;Q.delete(e.value)}}if(e.type===`user`){let t=at(e.message?.content);if(t.length>0)return t.map(e=>({...r,id:crypto.randomUUID(),event:`tool_complete`,toolName:e.toolName,toolOutput:e.output,outcome:e.isError?`failure`:`success`}));let n=G(e.message?.content);return n.trim()?[{...r,id:crypto.randomUUID(),event:`user_message`,messageText:n}]:[]}if(e.type===`assistant`){let t=it(e.message?.content),n=G(e.message?.content);return[...t.map(e=>({...r,id:crypto.randomUUID(),event:`tool_start`,toolName:e.toolName,toolInput:e.input})),...n.trim()?[{...r,id:crypto.randomUUID(),event:`assistant_message`,messageText:n}]:[]]}return[]})}function G(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`)return``;let t=e;return typeof t.text==`string`?t.text:``}).filter(Boolean).join(`
9
+ `)}function Re(e){return e.reduce((e,t)=>e+t.confidence,0)/e.length}function ze(e,t){let n=new Set([`when`,`with`,`this`,`that`,`user`,`asks`,`for`,`the`,`and`,`debug`,`investigate`,`research`]),r=[];for(let i of e)for(let e of`${i.trigger} ${i.action}`.toLowerCase().split(/[^a-z0-9]+/))if(e.length>2&&!n.has(e)&&!r.includes(e)&&r.push(e),r.length>=t)return r;return r}var R=e((()=>{n(),i(),x()}));function z(e){let t=new Map;for(let n of e){if(n.status!==`active`&&n.status!==`pending`)continue;let e=`${n.domain}:${Ue(n.trigger)}`,r=t.get(e)??[];r.push(n),t.set(e,r)}return Array.from(t.values()).filter(e=>e.length>=p().minClusterSize).map(e=>{let t=e.reduce((e,t)=>e+t.confidence,0)/e.length;return{target:Be(e),trigger:e[0]?.trigger??`learned pattern`,domain:e[0]?.domain??`project`,instincts:e,averageConfidence:Number(t.toFixed(2))}}).sort((e,t)=>t.averageConfidence-e.averageConfidence)}function Be(e){let t=Array.isArray(e)?e:e.instincts,n=t.map(e=>`${e.trigger} ${e.action}`).join(` `).toLowerCase();return/user asks|explicitly request|command|run /.test(n)?`command`:t.length>=4&&/(debug|investigate|research|multi-step)/.test(n)?`agent`:`skill`}function Ve(e,t){return z(e).filter(e=>e.target===`command`&&b(e.instincts)).map(e=>we(e.instincts,{...t,scope:e.instincts[0]?.scope??`project`}))}function He(e,t){return z(e).filter(e=>e.target===`agent`&&b(e.instincts)).map(e=>Me(e.instincts,{...t,scope:e.instincts[0]?.scope??`project`}))}function Ue(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,` `).split(/\s+/).filter(Boolean).slice(0,6).join(` `)}var We=e((()=>{x(),C(),L(),R(),g()}));function Ge(e){if(H.add(e),H.size>B){let e=H.size-V,t=H.values();for(let n=0;n<e;n++){let e=t.next();if(e.done)break;H.delete(e.value)}}}function Ke(e,t=2,n=.8){let r=new Map;for(let t of e){if(t.scope!==`project`)continue;let e=r.get(t.id)??[];e.push(t),r.set(t.id,e)}return Array.from(r.entries()).flatMap(([e,r])=>{let i=Array.from(new Set(r.map(e=>e.projectId).filter(Boolean))),a=r.reduce((e,t)=>e+t.confidence,0)/r.length;return i.length>=t&&a>=n?[{instinctId:e,projectIds:i,averageConfidence:Number(a.toFixed(2))}]:[]})}async function qe(e={}){let t=e.minProjects??2,n=e.minConfidence??.8,r=await Je(e.rootDir),i=Ke(r,t,n),a=[];for(let t of i){if(H.has(t.instinctId))continue;let n=r.find(e=>e.id===t.instinctId);n&&(await j({...n,scope:`global`,projectId:void 0,projectName:void 0,confidence:t.averageConfidence,updatedAt:new Date().toISOString()},{rootDir:e.rootDir,scope:`global`,project:Ye(e.rootDir)}),Ge(t.instinctId),a.push(t))}return a}async function Je(e){let t=T(_(e?{rootDir:e}:void 0),`projects`);if(!E(t))return[];let n=await O(t,{withFileTypes:!0}),r=[];for(let i of n){if(!i.isDirectory())continue;let n=await M({rootDir:e,project:{projectId:i.name,projectName:i.name,scope:`project`,source:`git_root`,cwd:t,storageDir:T(t,i.name)},scope:`project`});r.push(...n)}return r}function Ye(e){let t=_(e?{rootDir:e}:void 0);return{projectId:`global`,projectName:`Global`,scope:`global`,source:`global`,cwd:t,storageDir:T(t,`global`)}}var B,V,H,Xe=e((()=>{I(),y(),B=256,V=192,H=new Set}));function U(){X=0,Z=0,Q.clear()}function Ze(){return J}function Qe(){if(!q){q=!0;try{ce()}catch{}a(W),$e().catch(()=>{})}}async function $e(){if(!s()||process.env.CLAUDE_SKILL_LEARNING_DISABLE)return;let e={project:u(process.cwd())};await Promise.allSettled([xe(e),ie(e),Ce(30,e)])}function et(e){try{let t=_();return e.startsWith(t)}catch{return!1}}async function W(e){if(!s()||process.env.CLAUDE_SKILL_LEARNING_DISABLE||!e.querySource?.startsWith(`repl_main_thread`)||e.toolUseContext.agentId)return;let t=process.cwd();if(et(t))return;let n=u(t),r={project:n};++J;let i=[];for(let t of rt(e.messages,n))i.push(await ae(t,r));let a=(await re(r)).filter(e=>e.source===`tool-hook`&&e.sessionId===`runtime-session`&&typeof e.timestamp==`string`&&e.timestamp>Y);i.push(...a);for(let e of a)e.timestamp>Y&&(Y=e.timestamp);if(i.length===0)return;let o=Date.now(),{llm:c}=p(),l=i.length>=5&&X<c.maxCallsPerSession&&o-Z>=c.cooldownMs,d;if(l)X++,Z=o,d=await se(i,{project:n});else{let{heuristicObserverBackend:e}=await import(`./sessionObserver-D6qzEdGJ.js`),t=e.analyze(i,{project:n});d=Array.isArray(t)?t:await t}for(let e of d)await ve(te(e),r);await nt(r)}function tt(){J=0,Y=``,U()}async function nt(e){let n=await M(e),r=process.cwd(),i=[T(r,`.workmate`,`skills`),T(t(),`skills`)],a=z(n).filter(e=>e.target===`skill`&&b(e.instincts));for(let e of a){let t=await ue(e.instincts,{cwd:r,scope:e.instincts[0]?.scope??`project`},i);if(t.action===`append-evidence`)continue;let n=t.draft;E(T(n.outputPath,`SKILL.md`))||await pe(fe(n,await S(`skill`,n,i)))}let o=Ve(n,{cwd:r});for(let e of o)(await S(`command`,e,[T(r,`.workmate`,`commands`),T(t(),`commands`)])).length>0||await Te(e);let s=He(n,{cwd:r});for(let e of s)(await S(`agent`,e,[T(r,`.workmate`,`agents`),T(t(),`agents`)])).length>0||await Ne(e);await qe()}function rt(e,t){let n=K,r={sessionId:n,projectId:t.projectId,projectName:t.projectName,cwd:t.cwd,timestamp:new Date().toISOString(),source:`hook`};return e.flatMap(e=>{let t=`${n}:${String(e.uuid)}`;if(Q.has(t))return[];if(Q.add(t),Q.size>$){let e=Q.size-ot,t=Q.values();for(let n=0;n<e;n++){let e=t.next();if(e.done)break;Q.delete(e.value)}}if(e.type===`user`){let t=at(e.message?.content);if(t.length>0)return t.map(e=>({...r,id:crypto.randomUUID(),event:`tool_complete`,toolName:e.toolName,toolOutput:e.output,outcome:e.isError?`failure`:`success`}));let n=G(e.message?.content);return n.trim()?[{...r,id:crypto.randomUUID(),event:`user_message`,messageText:n}]:[]}if(e.type===`assistant`){let t=it(e.message?.content),n=G(e.message?.content);return[...t.map(e=>({...r,id:crypto.randomUUID(),event:`tool_start`,toolName:e.toolName,toolInput:e.input})),...n.trim()?[{...r,id:crypto.randomUUID(),event:`assistant_message`,messageText:n}]:[]]}return[]})}function G(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`)return``;let t=e;return typeof t.text==`string`?t.text:``}).filter(Boolean).join(`
10
10
  `):``}function it(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return t.type===`tool_use`?[{toolName:String(t.name??`unknown_tool`),input:v(t.input)}]:[]}):[]}function at(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return t.type===`tool_result`?[{toolName:String(t.name??t.tool_name??`unknown_tool`),output:v(t.content),isError:t.is_error===!0}]:[]}):[]}var K,q,J,Y,X,Z,Q,$,ot,st=e((()=>{r(),g(),c(),y(),l(),le(),f(),oe(),I(),de(),We(),C(),x(),L(),R(),Xe(),n(),K=`runtime-session`,q=!1,J=0,Y=``,X=0,Z=0,Q=new Set,$=1e3,ot=500}));export{U as a,st as i,Ze as n,tt as o,Qe as r,W as s,K as t};
@@ -0,0 +1 @@
1
+ import{gC as e,yC as t}from"./loadAgentsDir-B0Anodo0.js";t();export{e as SandboxManager};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{SC as t,_C as n,gC as r,mb as i,yC as a}from"./loadAgentsDir-DlPbtIsS.js";import{Gt as o,H as s,I as c,Lt as l,P as u,a as d,j as f,n as p,r as m,t as h,x as g}from"./src-DL3w8VPk.js";import{t as _}from"./jsx-runtime-Bb4Xn-E0.js";import{E as v,It as y}from"./state-B4jiUise.js";import{d as b,h as x,o as S}from"./settings-B2jvL8Dp.js";import{i as C,o as w}from"./platform-BacQ6ACS.js";import{n as T,t as E}from"./select-Bxf5-5sI.js";import{relative as D}from"path";function O(){let e=r.isSandboxingEnabled(),n=r.checkDependencies(),i=n.warnings.length>0?(0,k.jsx)(c,{marginTop:1,flexDirection:`column`,children:n.warnings.map((e,t)=>(0,k.jsx)(u,{dimColor:!0,children:e},t))}):null;if(!e)return(0,k.jsxs)(c,{flexDirection:`column`,paddingY:1,children:[(0,k.jsx)(u,{color:`subtle`,children:`Sandbox is not enabled`}),i]});let a=r.getFsReadConfig(),o=r.getFsWriteConfig(),s=r.getNetworkRestrictionConfig(),l=r.getAllowUnixSockets(),d=r.getExcludedCommands(),f=r.getLinuxGlobPatternWarnings();return(0,k.jsxs)(c,{flexDirection:`column`,paddingY:1,children:[(0,k.jsxs)(c,{flexDirection:`column`,children:[(0,k.jsx)(u,{bold:!0,color:`permission`,children:`Excluded Commands:`}),(0,k.jsx)(u,{dimColor:!0,children:d.length>0?d.join(`, `):`None`})]}),a.denyOnly.length>0&&(0,k.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,k.jsx)(u,{bold:!0,color:`permission`,children:`Filesystem Read Restrictions:`}),(0,k.jsxs)(u,{dimColor:!0,children:[`Denied: `,a.denyOnly.join(`, `)]}),a.allowWithinDeny&&a.allowWithinDeny.length>0&&(0,k.jsxs)(u,{dimColor:!0,children:[`Allowed within denied: `,a.allowWithinDeny.join(`, `)]})]}),o.allowOnly.length>0&&(0,k.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,k.jsx)(u,{bold:!0,color:`permission`,children:`Filesystem Write Restrictions:`}),(0,k.jsxs)(u,{dimColor:!0,children:[`Allowed: `,o.allowOnly.join(`, `)]}),o.denyWithinAllow.length>0&&(0,k.jsxs)(u,{dimColor:!0,children:[`Denied within allowed: `,o.denyWithinAllow.join(`, `)]})]}),(s.allowedHosts&&s.allowedHosts.length>0||s.deniedHosts&&s.deniedHosts.length>0)&&(0,k.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,k.jsxs)(u,{bold:!0,color:`permission`,children:[`Network Restrictions`,t()?` (Managed)`:``,`:`]}),s.allowedHosts&&s.allowedHosts.length>0&&(0,k.jsxs)(u,{dimColor:!0,children:[`Allowed: `,s.allowedHosts.join(`, `)]}),s.deniedHosts&&s.deniedHosts.length>0&&(0,k.jsxs)(u,{dimColor:!0,children:[`Denied: `,s.deniedHosts.join(`, `)]})]}),l&&l.length>0&&(0,k.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,k.jsx)(u,{bold:!0,color:`permission`,children:`Allowed Unix Sockets:`}),(0,k.jsx)(u,{dimColor:!0,children:l.join(`, `)})]}),f.length>0&&(0,k.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,k.jsx)(u,{bold:!0,color:`warning`,children:`⚠ Warning: Glob patterns not fully supported on Linux`}),(0,k.jsxs)(u,{dimColor:!0,children:[`The following patterns will be ignored: `,f.slice(0,3).join(`, `),f.length>3&&` (${f.length-3} more)`]})]}),i]})}var k,A=e((()=>{h(),a(),k=_()}));function j({depCheck:e}){let t=C()===`macos`,n=e.errors.some(e=>e.includes(`ripgrep`)),r=e.errors.some(e=>e.includes(`bwrap`)),i=e.errors.some(e=>e.includes(`socat`)),a=e.warnings.length>0,o=e.errors.filter(e=>!e.includes(`ripgrep`)&&!e.includes(`bwrap`)&&!e.includes(`socat`));return(0,M.jsxs)(c,{flexDirection:`column`,paddingY:1,gap:1,children:[t&&(0,M.jsx)(c,{flexDirection:`column`,children:(0,M.jsxs)(u,{children:[`seatbelt: `,(0,M.jsx)(u,{color:`success`,children:`built-in (macOS)`})]})}),(0,M.jsxs)(c,{flexDirection:`column`,children:[(0,M.jsxs)(u,{children:[`ripgrep (rg): `,n?(0,M.jsx)(u,{color:`error`,children:`not found`}):(0,M.jsx)(u,{color:`success`,children:`found`})]}),n&&(0,M.jsxs)(u,{dimColor:!0,children:[` `,`· `,t?`brew install ripgrep`:`apt install ripgrep`]})]}),!t&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(c,{flexDirection:`column`,children:[(0,M.jsxs)(u,{children:[`bubblewrap (bwrap):`,` `,r?(0,M.jsx)(u,{color:`error`,children:`not installed`}):(0,M.jsx)(u,{color:`success`,children:`installed`})]}),r&&(0,M.jsxs)(u,{dimColor:!0,children:[` `,`· apt install bubblewrap`]})]}),(0,M.jsxs)(c,{flexDirection:`column`,children:[(0,M.jsxs)(u,{children:[`socat: `,i?(0,M.jsx)(u,{color:`error`,children:`not installed`}):(0,M.jsx)(u,{color:`success`,children:`installed`})]}),i&&(0,M.jsxs)(u,{dimColor:!0,children:[` `,`· apt install socat`]})]}),(0,M.jsxs)(c,{flexDirection:`column`,children:[(0,M.jsxs)(u,{children:[`seccomp filter:`,` `,a?(0,M.jsx)(u,{color:`warning`,children:`not installed`}):(0,M.jsx)(u,{color:`success`,children:`installed`}),a&&(0,M.jsx)(u,{dimColor:!0,children:` (required to block unix domain sockets)`})]}),a&&(0,M.jsxs)(c,{flexDirection:`column`,children:[(0,M.jsxs)(u,{dimColor:!0,children:[` `,`· npm install -g @anthropic-ai/sandbox-runtime`]}),(0,M.jsxs)(u,{dimColor:!0,children:[` `,`· or copy vendor/seccomp/* from sandbox-runtime and set`]}),(0,M.jsxs)(u,{dimColor:!0,children:[` `,`sandbox.seccomp.bpfPath and applyPath in settings.json`]})]})]})]}),o.map(e=>(0,M.jsx)(u,{color:`error`,children:e},e))]})}var M,N=e((()=>{h(),w(),M=_()}));function P({onComplete:e}){let t=r.isSandboxingEnabled(),n=r.areSandboxSettingsLockedByPolicy(),i=r.areUnsandboxedCommandsAllowed();return t?n?(0,I.jsxs)(c,{flexDirection:`column`,paddingY:1,children:[(0,I.jsx)(u,{color:`subtle`,children:`Override settings are managed by a higher-priority configuration and cannot be changed locally.`}),(0,I.jsx)(c,{marginTop:1,children:(0,I.jsxs)(u,{dimColor:!0,children:[`Current setting: `,i?`Allow unsandboxed fallback`:`Strict sandbox mode`]})})]}):(0,I.jsx)(F,{onComplete:e,currentMode:i?`open`:`closed`}):(0,I.jsx)(c,{flexDirection:`column`,paddingY:1,children:(0,I.jsx)(u,{color:`subtle`,children:`Sandbox is not enabled. Enable sandbox to configure override settings.`})})}function F({onComplete:e,currentMode:t}){let[n]=s(),{headerFocused:i,focusHeader:a}=d(),o=f(`success`,n)(`(current)`),p=[{label:t===`open`?`Allow unsandboxed fallback ${o}`:`Allow unsandboxed fallback`,value:`open`},{label:t===`closed`?`Strict sandbox mode ${o}`:`Strict sandbox mode`,value:`closed`}];async function m(t){let n=t;await r.setSandboxSettings({allowUnsandboxedCommands:n===`open`}),e(n===`open`?`✓ Unsandboxed fallback allowed - commands can run outside sandbox when necessary`:"✓ Strict sandbox mode - all commands must run in sandbox or be excluded via the `excludedCommands` option")}return(0,I.jsxs)(c,{flexDirection:`column`,paddingY:1,children:[(0,I.jsx)(c,{marginBottom:1,children:(0,I.jsx)(u,{bold:!0,children:`Configure Overrides:`})}),(0,I.jsx)(E,{options:p,onChange:m,onCancel:()=>e(void 0,{display:`skip`}),onUpFromFirstItem:a,isDisabled:i}),(0,I.jsxs)(c,{flexDirection:`column`,marginTop:1,gap:1,children:[(0,I.jsxs)(u,{dimColor:!0,children:[(0,I.jsx)(u,{bold:!0,dimColor:!0,children:`Allow unsandboxed fallback:`}),` `,`When a command fails due to sandbox restrictions, Work Mate can retry with dangerouslyDisableSandbox to run outside the sandbox (falling back to default permissions).`]}),(0,I.jsxs)(u,{dimColor:!0,children:[(0,I.jsx)(u,{bold:!0,dimColor:!0,children:`Strict sandbox mode:`}),` `,`All bash commands invoked by the model must run in the sandbox unless they are explicitly listed in excludedCommands.`]}),(0,I.jsxs)(u,{dimColor:!0,children:[`Learn more:`,` `,(0,I.jsx)(l,{url:`https://code.workmate.com/docs/en/sandboxing#configure-sandboxing`,children:`code.workmate.com/docs/en/sandboxing#configure-sandboxing`})]})]})]})}var I,L=e((()=>{h(),a(),T(),I=_()}));function R({onComplete:e,depCheck:t}){let[n]=s(),i=r.isSandboxingEnabled(),a=r.isAutoAllowBashIfSandboxedEnabled(),c=t.warnings.length>0,l=b().sandbox?.network?.allowAllUnixSockets,u=c&&!l,d=i?a?`auto-allow`:`regular`:`disabled`,h=f(`success`,n)(`(current)`),_=[{label:d===`auto-allow`?`Sandbox BashTool, with auto-allow ${h}`:`Sandbox BashTool, with auto-allow`,value:`auto-allow`},{label:d===`regular`?`Sandbox BashTool, with regular permissions ${h}`:`Sandbox BashTool, with regular permissions`,value:`regular`},{label:d===`disabled`?`No Sandbox ${h}`:`No Sandbox`,value:`disabled`}];async function v(t){switch(t){case`auto-allow`:await r.setSandboxSettings({enabled:!0,autoAllowBashIfSandboxed:!0}),e(`✓ Sandbox enabled with auto-allow for bash commands`);break;case`regular`:await r.setSandboxSettings({enabled:!0,autoAllowBashIfSandboxed:!1}),e(`✓ Sandbox enabled with regular bash permissions`);break;case`disabled`:await r.setSandboxSettings({enabled:!1,autoAllowBashIfSandboxed:!1}),e(`○ Sandbox disabled`);break}}o({"confirm:no":()=>e(void 0,{display:`skip`})},{context:`Settings`});let y=(0,B.jsx)(p,{title:`Mode`,children:(0,B.jsx)(z,{showSocketWarning:u,options:_,onSelect:v,onComplete:e})},`mode`),x=(0,B.jsx)(p,{title:`Overrides`,children:(0,B.jsx)(P,{onComplete:e})},`overrides`),S=(0,B.jsx)(p,{title:`Config`,children:(0,B.jsx)(O,{})},`config`);return(0,B.jsx)(g,{color:`permission`,children:(0,B.jsx)(m,{title:`Sandbox:`,color:`permission`,defaultTab:`Mode`,children:t.errors.length>0?[(0,B.jsx)(p,{title:`Dependencies`,children:(0,B.jsx)(j,{depCheck:t})},`dependencies`)]:[y,...c?[(0,B.jsx)(p,{title:`Dependencies`,children:(0,B.jsx)(j,{depCheck:t})},`dependencies`)]:[],x,S]})})}function z({showSocketWarning:e,options:t,onSelect:n,onComplete:r}){let{headerFocused:i,focusHeader:a}=d();return(0,B.jsxs)(c,{flexDirection:`column`,paddingY:1,children:[e&&(0,B.jsx)(c,{marginBottom:1,children:(0,B.jsx)(u,{color:`warning`,children:`Cannot block unix domain sockets (see Dependencies tab)`})}),(0,B.jsx)(c,{marginBottom:1,children:(0,B.jsx)(u,{bold:!0,children:`Configure Mode:`})}),(0,B.jsx)(E,{options:t,onChange:n,onCancel:()=>r(void 0,{display:`skip`}),onUpFromFirstItem:a,isDisabled:i}),(0,B.jsxs)(c,{flexDirection:`column`,marginTop:1,gap:1,children:[(0,B.jsxs)(u,{dimColor:!0,children:[(0,B.jsx)(u,{bold:!0,dimColor:!0,children:`Auto-allow mode:`}),` `,`Commands will try to run in the sandbox automatically, and attempts to run outside of the sandbox fallback to regular permissions. Explicit ask/deny rules are always respected.`]}),(0,B.jsxs)(u,{dimColor:!0,children:[`Learn more:`,` `,(0,B.jsx)(l,{url:`https://code.workmate.com/docs/en/sandboxing`,children:`code.workmate.com/docs/en/sandboxing`})]})]})]})}var B,V=e((()=>{h(),i(),a(),x(),T(),A(),N(),L(),B=_()}));async function H(e,t,i){let a=b().theme||`light`,o=C();if(!r.isSupportedPlatform()){let t=o===`wsl`?`Error: Sandboxing requires WSL2. WSL1 is not supported.`:`Error: Sandboxing is currently only supported on macOS, Linux, and WSL2.`;return e(f(`error`,a)(t)),null}let s=r.checkDependencies();if(!r.isPlatformInEnabledList())return e(f(`error`,a)(`Error: Sandboxing is disabled for this platform (${o}) via the enabledPlatforms setting.`)),null;if(r.areSandboxSettingsLockedByPolicy())return e(f(`error`,a)(`Error: Sandbox settings are overridden by a higher-priority configuration and cannot be changed locally.`)),null;let c=i?.trim()||``;if(!c)return(0,U.jsx)(R,{onComplete:e,depCheck:s});if(c){let t=c.split(` `)[0];if(t===`exclude`){let t=c.slice(8).trim();if(!t)return e(f(`error`,a)(`Error: Please provide a command pattern to exclude (e.g., /sandbox exclude "npm run test:*")`)),null;let r=t.replace(/^["']|["']$/g,``);n(r);let i=S(`localSettings`),o=i?D(v(),i):`.workmate/settings.local.json`;return e(f(`success`,a)(`Added "${r}" to excluded commands in ${o}`)),null}else return e(f(`error`,a)(`Error: Unknown subcommand "${t}". Available subcommand: exclude`)),null}return null}var U;e((()=>{y(),V(),h(),w(),a(),x(),U=_()}))();export{H as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{SC as t,_C as n,gC as r,mb as i,yC as a}from"./loadAgentsDir-B0Anodo0.js";import{Gt as o,H as s,I as c,Lt as l,P as u,a as d,j as f,n as p,r as m,t as h,x as g}from"./src-DL3w8VPk.js";import{t as _}from"./jsx-runtime-Bb4Xn-E0.js";import{E as v,It as y}from"./state-B4jiUise.js";import{d as b,h as x,o as S}from"./settings-B2jvL8Dp.js";import{i as C,o as w}from"./platform-BacQ6ACS.js";import{n as T,t as E}from"./select-DIxfl_VN.js";import{relative as D}from"path";function O(){let e=r.isSandboxingEnabled(),n=r.checkDependencies(),i=n.warnings.length>0?(0,k.jsx)(c,{marginTop:1,flexDirection:`column`,children:n.warnings.map((e,t)=>(0,k.jsx)(u,{dimColor:!0,children:e},t))}):null;if(!e)return(0,k.jsxs)(c,{flexDirection:`column`,paddingY:1,children:[(0,k.jsx)(u,{color:`subtle`,children:`Sandbox is not enabled`}),i]});let a=r.getFsReadConfig(),o=r.getFsWriteConfig(),s=r.getNetworkRestrictionConfig(),l=r.getAllowUnixSockets(),d=r.getExcludedCommands(),f=r.getLinuxGlobPatternWarnings();return(0,k.jsxs)(c,{flexDirection:`column`,paddingY:1,children:[(0,k.jsxs)(c,{flexDirection:`column`,children:[(0,k.jsx)(u,{bold:!0,color:`permission`,children:`Excluded Commands:`}),(0,k.jsx)(u,{dimColor:!0,children:d.length>0?d.join(`, `):`None`})]}),a.denyOnly.length>0&&(0,k.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,k.jsx)(u,{bold:!0,color:`permission`,children:`Filesystem Read Restrictions:`}),(0,k.jsxs)(u,{dimColor:!0,children:[`Denied: `,a.denyOnly.join(`, `)]}),a.allowWithinDeny&&a.allowWithinDeny.length>0&&(0,k.jsxs)(u,{dimColor:!0,children:[`Allowed within denied: `,a.allowWithinDeny.join(`, `)]})]}),o.allowOnly.length>0&&(0,k.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,k.jsx)(u,{bold:!0,color:`permission`,children:`Filesystem Write Restrictions:`}),(0,k.jsxs)(u,{dimColor:!0,children:[`Allowed: `,o.allowOnly.join(`, `)]}),o.denyWithinAllow.length>0&&(0,k.jsxs)(u,{dimColor:!0,children:[`Denied within allowed: `,o.denyWithinAllow.join(`, `)]})]}),(s.allowedHosts&&s.allowedHosts.length>0||s.deniedHosts&&s.deniedHosts.length>0)&&(0,k.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,k.jsxs)(u,{bold:!0,color:`permission`,children:[`Network Restrictions`,t()?` (Managed)`:``,`:`]}),s.allowedHosts&&s.allowedHosts.length>0&&(0,k.jsxs)(u,{dimColor:!0,children:[`Allowed: `,s.allowedHosts.join(`, `)]}),s.deniedHosts&&s.deniedHosts.length>0&&(0,k.jsxs)(u,{dimColor:!0,children:[`Denied: `,s.deniedHosts.join(`, `)]})]}),l&&l.length>0&&(0,k.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,k.jsx)(u,{bold:!0,color:`permission`,children:`Allowed Unix Sockets:`}),(0,k.jsx)(u,{dimColor:!0,children:l.join(`, `)})]}),f.length>0&&(0,k.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,k.jsx)(u,{bold:!0,color:`warning`,children:`⚠ Warning: Glob patterns not fully supported on Linux`}),(0,k.jsxs)(u,{dimColor:!0,children:[`The following patterns will be ignored: `,f.slice(0,3).join(`, `),f.length>3&&` (${f.length-3} more)`]})]}),i]})}var k,A=e((()=>{h(),a(),k=_()}));function j({depCheck:e}){let t=C()===`macos`,n=e.errors.some(e=>e.includes(`ripgrep`)),r=e.errors.some(e=>e.includes(`bwrap`)),i=e.errors.some(e=>e.includes(`socat`)),a=e.warnings.length>0,o=e.errors.filter(e=>!e.includes(`ripgrep`)&&!e.includes(`bwrap`)&&!e.includes(`socat`));return(0,M.jsxs)(c,{flexDirection:`column`,paddingY:1,gap:1,children:[t&&(0,M.jsx)(c,{flexDirection:`column`,children:(0,M.jsxs)(u,{children:[`seatbelt: `,(0,M.jsx)(u,{color:`success`,children:`built-in (macOS)`})]})}),(0,M.jsxs)(c,{flexDirection:`column`,children:[(0,M.jsxs)(u,{children:[`ripgrep (rg): `,n?(0,M.jsx)(u,{color:`error`,children:`not found`}):(0,M.jsx)(u,{color:`success`,children:`found`})]}),n&&(0,M.jsxs)(u,{dimColor:!0,children:[` `,`· `,t?`brew install ripgrep`:`apt install ripgrep`]})]}),!t&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(c,{flexDirection:`column`,children:[(0,M.jsxs)(u,{children:[`bubblewrap (bwrap):`,` `,r?(0,M.jsx)(u,{color:`error`,children:`not installed`}):(0,M.jsx)(u,{color:`success`,children:`installed`})]}),r&&(0,M.jsxs)(u,{dimColor:!0,children:[` `,`· apt install bubblewrap`]})]}),(0,M.jsxs)(c,{flexDirection:`column`,children:[(0,M.jsxs)(u,{children:[`socat: `,i?(0,M.jsx)(u,{color:`error`,children:`not installed`}):(0,M.jsx)(u,{color:`success`,children:`installed`})]}),i&&(0,M.jsxs)(u,{dimColor:!0,children:[` `,`· apt install socat`]})]}),(0,M.jsxs)(c,{flexDirection:`column`,children:[(0,M.jsxs)(u,{children:[`seccomp filter:`,` `,a?(0,M.jsx)(u,{color:`warning`,children:`not installed`}):(0,M.jsx)(u,{color:`success`,children:`installed`}),a&&(0,M.jsx)(u,{dimColor:!0,children:` (required to block unix domain sockets)`})]}),a&&(0,M.jsxs)(c,{flexDirection:`column`,children:[(0,M.jsxs)(u,{dimColor:!0,children:[` `,`· npm install -g @anthropic-ai/sandbox-runtime`]}),(0,M.jsxs)(u,{dimColor:!0,children:[` `,`· or copy vendor/seccomp/* from sandbox-runtime and set`]}),(0,M.jsxs)(u,{dimColor:!0,children:[` `,`sandbox.seccomp.bpfPath and applyPath in settings.json`]})]})]})]}),o.map(e=>(0,M.jsx)(u,{color:`error`,children:e},e))]})}var M,N=e((()=>{h(),w(),M=_()}));function P({onComplete:e}){let t=r.isSandboxingEnabled(),n=r.areSandboxSettingsLockedByPolicy(),i=r.areUnsandboxedCommandsAllowed();return t?n?(0,I.jsxs)(c,{flexDirection:`column`,paddingY:1,children:[(0,I.jsx)(u,{color:`subtle`,children:`Override settings are managed by a higher-priority configuration and cannot be changed locally.`}),(0,I.jsx)(c,{marginTop:1,children:(0,I.jsxs)(u,{dimColor:!0,children:[`Current setting: `,i?`Allow unsandboxed fallback`:`Strict sandbox mode`]})})]}):(0,I.jsx)(F,{onComplete:e,currentMode:i?`open`:`closed`}):(0,I.jsx)(c,{flexDirection:`column`,paddingY:1,children:(0,I.jsx)(u,{color:`subtle`,children:`Sandbox is not enabled. Enable sandbox to configure override settings.`})})}function F({onComplete:e,currentMode:t}){let[n]=s(),{headerFocused:i,focusHeader:a}=d(),o=f(`success`,n)(`(current)`),p=[{label:t===`open`?`Allow unsandboxed fallback ${o}`:`Allow unsandboxed fallback`,value:`open`},{label:t===`closed`?`Strict sandbox mode ${o}`:`Strict sandbox mode`,value:`closed`}];async function m(t){let n=t;await r.setSandboxSettings({allowUnsandboxedCommands:n===`open`}),e(n===`open`?`✓ Unsandboxed fallback allowed - commands can run outside sandbox when necessary`:"✓ Strict sandbox mode - all commands must run in sandbox or be excluded via the `excludedCommands` option")}return(0,I.jsxs)(c,{flexDirection:`column`,paddingY:1,children:[(0,I.jsx)(c,{marginBottom:1,children:(0,I.jsx)(u,{bold:!0,children:`Configure Overrides:`})}),(0,I.jsx)(E,{options:p,onChange:m,onCancel:()=>e(void 0,{display:`skip`}),onUpFromFirstItem:a,isDisabled:i}),(0,I.jsxs)(c,{flexDirection:`column`,marginTop:1,gap:1,children:[(0,I.jsxs)(u,{dimColor:!0,children:[(0,I.jsx)(u,{bold:!0,dimColor:!0,children:`Allow unsandboxed fallback:`}),` `,`When a command fails due to sandbox restrictions, Work Mate can retry with dangerouslyDisableSandbox to run outside the sandbox (falling back to default permissions).`]}),(0,I.jsxs)(u,{dimColor:!0,children:[(0,I.jsx)(u,{bold:!0,dimColor:!0,children:`Strict sandbox mode:`}),` `,`All bash commands invoked by the model must run in the sandbox unless they are explicitly listed in excludedCommands.`]}),(0,I.jsxs)(u,{dimColor:!0,children:[`Learn more:`,` `,(0,I.jsx)(l,{url:`https://code.workmate.com/docs/en/sandboxing#configure-sandboxing`,children:`code.workmate.com/docs/en/sandboxing#configure-sandboxing`})]})]})]})}var I,L=e((()=>{h(),a(),T(),I=_()}));function R({onComplete:e,depCheck:t}){let[n]=s(),i=r.isSandboxingEnabled(),a=r.isAutoAllowBashIfSandboxedEnabled(),c=t.warnings.length>0,l=b().sandbox?.network?.allowAllUnixSockets,u=c&&!l,d=i?a?`auto-allow`:`regular`:`disabled`,h=f(`success`,n)(`(current)`),_=[{label:d===`auto-allow`?`Sandbox BashTool, with auto-allow ${h}`:`Sandbox BashTool, with auto-allow`,value:`auto-allow`},{label:d===`regular`?`Sandbox BashTool, with regular permissions ${h}`:`Sandbox BashTool, with regular permissions`,value:`regular`},{label:d===`disabled`?`No Sandbox ${h}`:`No Sandbox`,value:`disabled`}];async function v(t){switch(t){case`auto-allow`:await r.setSandboxSettings({enabled:!0,autoAllowBashIfSandboxed:!0}),e(`✓ Sandbox enabled with auto-allow for bash commands`);break;case`regular`:await r.setSandboxSettings({enabled:!0,autoAllowBashIfSandboxed:!1}),e(`✓ Sandbox enabled with regular bash permissions`);break;case`disabled`:await r.setSandboxSettings({enabled:!1,autoAllowBashIfSandboxed:!1}),e(`○ Sandbox disabled`);break}}o({"confirm:no":()=>e(void 0,{display:`skip`})},{context:`Settings`});let y=(0,B.jsx)(p,{title:`Mode`,children:(0,B.jsx)(z,{showSocketWarning:u,options:_,onSelect:v,onComplete:e})},`mode`),x=(0,B.jsx)(p,{title:`Overrides`,children:(0,B.jsx)(P,{onComplete:e})},`overrides`),S=(0,B.jsx)(p,{title:`Config`,children:(0,B.jsx)(O,{})},`config`);return(0,B.jsx)(g,{color:`permission`,children:(0,B.jsx)(m,{title:`Sandbox:`,color:`permission`,defaultTab:`Mode`,children:t.errors.length>0?[(0,B.jsx)(p,{title:`Dependencies`,children:(0,B.jsx)(j,{depCheck:t})},`dependencies`)]:[y,...c?[(0,B.jsx)(p,{title:`Dependencies`,children:(0,B.jsx)(j,{depCheck:t})},`dependencies`)]:[],x,S]})})}function z({showSocketWarning:e,options:t,onSelect:n,onComplete:r}){let{headerFocused:i,focusHeader:a}=d();return(0,B.jsxs)(c,{flexDirection:`column`,paddingY:1,children:[e&&(0,B.jsx)(c,{marginBottom:1,children:(0,B.jsx)(u,{color:`warning`,children:`Cannot block unix domain sockets (see Dependencies tab)`})}),(0,B.jsx)(c,{marginBottom:1,children:(0,B.jsx)(u,{bold:!0,children:`Configure Mode:`})}),(0,B.jsx)(E,{options:t,onChange:n,onCancel:()=>r(void 0,{display:`skip`}),onUpFromFirstItem:a,isDisabled:i}),(0,B.jsxs)(c,{flexDirection:`column`,marginTop:1,gap:1,children:[(0,B.jsxs)(u,{dimColor:!0,children:[(0,B.jsx)(u,{bold:!0,dimColor:!0,children:`Auto-allow mode:`}),` `,`Commands will try to run in the sandbox automatically, and attempts to run outside of the sandbox fallback to regular permissions. Explicit ask/deny rules are always respected.`]}),(0,B.jsxs)(u,{dimColor:!0,children:[`Learn more:`,` `,(0,B.jsx)(l,{url:`https://code.workmate.com/docs/en/sandboxing`,children:`code.workmate.com/docs/en/sandboxing`})]})]})]})}var B,V=e((()=>{h(),i(),a(),x(),T(),A(),N(),L(),B=_()}));async function H(e,t,i){let a=b().theme||`light`,o=C();if(!r.isSupportedPlatform()){let t=o===`wsl`?`Error: Sandboxing requires WSL2. WSL1 is not supported.`:`Error: Sandboxing is currently only supported on macOS, Linux, and WSL2.`;return e(f(`error`,a)(t)),null}let s=r.checkDependencies();if(!r.isPlatformInEnabledList())return e(f(`error`,a)(`Error: Sandboxing is disabled for this platform (${o}) via the enabledPlatforms setting.`)),null;if(r.areSandboxSettingsLockedByPolicy())return e(f(`error`,a)(`Error: Sandbox settings are overridden by a higher-priority configuration and cannot be changed locally.`)),null;let c=i?.trim()||``;if(!c)return(0,U.jsx)(R,{onComplete:e,depCheck:s});if(c){let t=c.split(` `)[0];if(t===`exclude`){let t=c.slice(8).trim();if(!t)return e(f(`error`,a)(`Error: Please provide a command pattern to exclude (e.g., /sandbox exclude "npm run test:*")`)),null;let r=t.replace(/^["']|["']$/g,``);n(r);let i=S(`localSettings`),o=i?D(v(),i):`.workmate/settings.local.json`;return e(f(`success`,a)(`Added "${r}" to excluded commands in ${o}`)),null}else return e(f(`error`,a)(`Error: Unknown subcommand "${t}". Available subcommand: exclude`)),null}return null}var U;e((()=>{y(),V(),h(),w(),a(),x(),U=_()}))();export{H as call};
@@ -0,0 +1 @@
1
+ import{_h as e,yh as t}from"./loadAgentsDir-B0Anodo0.js";e();export{t as isSearchExtraToolsEnabled};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{mb as i}from"./loadAgentsDir-DlPbtIsS.js";import{Ft as a,G as o,Gr as s,Gt as c,I as l,P as u,ai as d,hn as f,t as p}from"./src-DL3w8VPk.js";import{t as m}from"./jsx-runtime-Bb4Xn-E0.js";import{Hn as h,Vn as g}from"./settings-B2jvL8Dp.js";import{c as _,o as v,s as y}from"./stringUtils-C718f5ey.js";import{a as b,i as x,n as S,o as C,r as w,t as T}from"./use-select-navigation-BiUJdWai.js";import{i as E,t as D}from"./overlayContext-BT2Lq8ei.js";var O,k,A=e((()=>{O=t(d(),1),D(),p(),i(),v(),k=({isDisabled:e=!1,disableSelection:t=!1,state:n,options:r,isMultiSelect:i=!1,onUpFromFirstItem:a,onDownFromLastItem:o,onInputModeToggle:s,inputValues:l,imagesSelected:u=!1,onEnterImageSelection:d})=>{E(`select`,!!n.onCancel);let p=(0,O.useMemo)(()=>r.find(e=>e.value===n.focusedValue)?.type===`input`,[r,n.focusedValue]);c((0,O.useMemo)(()=>{let e={};return p||(e[`select:next`]=()=>{if(o){let e=r[r.length-1];if(e&&n.focusedValue===e.value){o();return}}n.focusNextOption()},e[`select:previous`]=()=>{if(a&&n.visibleFromIndex===0){let e=r[0];if(e&&n.focusedValue===e.value){a();return}}n.focusPreviousOption()},e[`select:accept`]=()=>{t!==!0&&n.focusedValue!==void 0&&r.find(e=>e.value===n.focusedValue)?.disabled!==!0&&(n.selectFocusedOption?.(),n.onChange?.(n.focusedValue))}),n.onCancel&&(e[`select:cancel`]=()=>{n.onCancel()}),e},[r,n,o,a,p,t]),{context:`Select`,isActive:!e}),f((e,c,f)=>{let p=y(e),m=r.find(e=>e.value===n.focusedValue),h=m?.type===`input`;if(c.tab&&s&&n.focusedValue!==void 0){s(n.focusedValue);return}if(h){if(u)return;if(c.downArrow&&d?.()){f.stopImmediatePropagation();return}if(c.downArrow||c.ctrl&&e===`n`){if(o){let e=r[r.length-1];if(e&&n.focusedValue===e.value){o(),f.stopImmediatePropagation();return}}n.focusNextOption(),f.stopImmediatePropagation();return}if(c.upArrow||c.ctrl&&e===`p`){if(a&&n.visibleFromIndex===0){let e=r[0];if(e&&n.focusedValue===e.value){a(),f.stopImmediatePropagation();return}}n.focusPreviousOption(),f.stopImmediatePropagation();return}return}if(c.pageDown&&n.focusNextPage(),c.pageUp&&n.focusPreviousPage(),t!==!0&&(i&&_(e)===` `&&n.focusedValue!==void 0&&m?.disabled!==!0&&(n.selectFocusedOption?.(),n.onChange?.(n.focusedValue)),t!==`numeric`&&/^[0-9]+$/.test(p))){let e=parseInt(p,10)-1;if(e>=0&&e<n.options.length){let t=n.options[e];if(t.disabled===!0)return;if(t.type===`input`){if((l?.get(t.value)??``).trim()){n.onChange?.(t.value);return}if(t.allowEmptySubmitToCancel){n.onChange?.(t.value);return}n.focusOption(t.value);return}n.onChange?.(t.value);return}}},{isActive:!e})}}));function j({visibleOptionCount:e=5,options:t,defaultValue:n,onChange:r,onCancel:i,onFocus:a,focusValue:o}){let[s,c]=(0,M.useState)(n),l=S({visibleOptionCount:e,options:t,initialFocusValue:void 0,onFocus:a,focusValue:o}),u=(0,M.useCallback)(()=>{c(l.focusedValue)},[l.focusedValue]);return{...l,value:s,selectFocusedOption:u,onChange:r,onCancel:i}}var M,N=e((()=>{M=t(d(),1),T()}));function P(e){return typeof e==`string`?e:typeof e==`number`?String(e):e?Array.isArray(e)?e.map(P).join(``):L.isValidElement(e)?P(e.props.children):``:``}function F({isDisabled:e=!1,hideIndexes:t=!1,visibleOptionCount:n=5,highlightText:i,options:o,defaultValue:c,onCancel:d,onChange:f,onFocus:p,defaultFocusValue:m,layout:h=`compact`,disableSelection:_=!1,inlineDescriptions:v=!1,onUpFromFirstItem:y,onDownFromLastItem:x,onInputModeToggle:S,onOpenEditor:C,onImagePaste:T,pastedContents:E,onRemoveImage:D}){let[O,A]=(0,L.useState)(!1),[M,N]=(0,L.useState)(0),[F,z]=(0,L.useState)(()=>{let e=new Map;return o.forEach(t=>{t.type===`input`&&t.initialValue&&e.set(t.value,t.initialValue)}),e}),B=(0,L.useRef)(new Map);(0,L.useEffect)(()=>{for(let e of o)if(e.type===`input`&&e.initialValue!==void 0){let t=B.current.get(e.value)??``,n=F.get(e.value)??``,r=e.initialValue;r!==t&&n===t&&z(t=>{let n=new Map(t);return n.set(e.value,r),n}),B.current.set(e.value,r)}},[o,F]);let V=j({visibleOptionCount:n,options:o,defaultValue:c,onChange:f,onCancel:d,onFocus:p,focusValue:m});k({isDisabled:e,disableSelection:_||(t?`numeric`:!1),state:V,options:o,isMultiSelect:!1,onUpFromFirstItem:y,onDownFromLastItem:x,onInputModeToggle:S,inputValues:F,imagesSelected:O,onEnterImageSelection:()=>{if(E&&Object.values(E).some(e=>e.type===`image`)){let e=g(Object.values(E),e=>e.type===`image`);return A(!0),N(e-1),!0}return!1}});let H={container:()=>({flexDirection:`column`}),highlightedText:()=>({bold:!0})};if(h===`expanded`){let t=V.options.length.toString().length;return(0,R.jsx)(l,{...H.container(),children:V.visibleOptions.map((n,r)=>{let s=n.index===V.visibleFromIndex,c=n.index===V.visibleToIndex-1,p=V.visibleToIndex<o.length,m=V.visibleFromIndex>0,h=V.visibleFromIndex+r+1,g=!e&&V.focusedValue===n.value,_=V.value===n.value;if(n.type===`input`){let e=F.has(n.value)?F.get(n.value):n.initialValue||``;return(0,R.jsx)(w,{option:n,isFocused:g,isSelected:_,shouldShowDownArrow:p&&c,shouldShowUpArrow:m&&s,maxIndexWidth:t,index:h,inputValue:e,onInputChange:e=>{z(t=>{let r=new Map(t);return r.set(n.value,e),r})},onSubmit:e=>{let t=E&&Object.values(E).some(e=>e.type===`image`);e.trim()||t||n.allowEmptySubmitToCancel?f?.(n.value):d?.()},onExit:d,layout:`expanded`,showLabel:v,onOpenEditor:C,resetCursorOnUpdate:n.resetCursorOnUpdate,onImagePaste:T,pastedContents:E,onRemoveImage:D,imagesSelected:O,selectedImageIndex:M,onImagesSelectedChange:A,onSelectedImageIndexChange:N},String(n.value))}let y=n.label;if(typeof n.label==`string`&&i&&n.label.includes(i)){let e=n.label,t=e.indexOf(i);y=(0,R.jsxs)(R.Fragment,{children:[e.slice(0,t),(0,R.jsx)(u,{...H.highlightedText(),children:i}),e.slice(t+i.length)]})}let x=n.disabled===!0,S=x?void 0:_?`success`:g?`suggestion`:void 0;return(0,R.jsxs)(l,{flexDirection:`column`,flexShrink:0,children:[(0,R.jsx)(b,{isFocused:g,isSelected:_,shouldShowDownArrow:p&&c,shouldShowUpArrow:m&&s,children:(0,R.jsx)(u,{dimColor:x,color:S,children:y})}),n.description&&(0,R.jsx)(l,{paddingLeft:2,children:(0,R.jsx)(u,{dimColor:x||n.dimDescription!==!1,color:S,children:(0,R.jsx)(a,{children:n.description})})}),(0,R.jsx)(u,{children:` `})]},String(n.value))})})}if(h===`compact-vertical`){let n=t?0:V.options.length.toString().length;return(0,R.jsx)(l,{...H.container(),children:V.visibleOptions.map((r,s)=>{let c=r.index===V.visibleFromIndex,p=r.index===V.visibleToIndex-1,m=V.visibleToIndex<o.length,h=V.visibleFromIndex>0,g=V.visibleFromIndex+s+1,_=!e&&V.focusedValue===r.value,y=V.value===r.value;if(r.type===`input`){let e=F.has(r.value)?F.get(r.value):r.initialValue||``;return(0,R.jsx)(w,{option:r,isFocused:_,isSelected:y,shouldShowDownArrow:m&&p,shouldShowUpArrow:h&&c,maxIndexWidth:n,index:g,inputValue:e,onInputChange:e=>{z(t=>{let n=new Map(t);return n.set(r.value,e),n})},onSubmit:e=>{let t=E&&Object.values(E).some(e=>e.type===`image`);e.trim()||t||r.allowEmptySubmitToCancel?f?.(r.value):d?.()},onExit:d,layout:`compact`,showLabel:v,onOpenEditor:C,resetCursorOnUpdate:r.resetCursorOnUpdate,onImagePaste:T,pastedContents:E,onRemoveImage:D,imagesSelected:O,selectedImageIndex:M,onImagesSelectedChange:A,onSelectedImageIndexChange:N},String(r.value))}let x=r.label;if(typeof r.label==`string`&&i&&r.label.includes(i)){let e=r.label,t=e.indexOf(i);x=(0,R.jsxs)(R.Fragment,{children:[e.slice(0,t),(0,R.jsx)(u,{...H.highlightedText(),children:i}),e.slice(t+i.length)]})}let S=r.disabled===!0;return(0,R.jsxs)(l,{flexDirection:`column`,flexShrink:0,children:[(0,R.jsxs)(b,{isFocused:_,isSelected:y,shouldShowDownArrow:m&&p,shouldShowUpArrow:h&&c,children:[!t&&(0,R.jsx)(u,{dimColor:!0,children:`${g}.`.padEnd(n+1)}),(0,R.jsx)(u,{dimColor:S,color:S?void 0:y?`success`:_?`suggestion`:void 0,children:x})]}),r.description&&(0,R.jsx)(l,{paddingLeft:t?4:n+4,children:(0,R.jsx)(u,{dimColor:S||r.dimDescription!==!1,color:S?void 0:y?`success`:_?`suggestion`:void 0,children:(0,R.jsx)(a,{children:r.description})})})]},String(r.value))})})}let U=t?0:V.options.length.toString().length,W=V.visibleOptions.some(e=>e.type===`input`),G=!v&&!W&&V.visibleOptions.some(e=>e.description),K=V.visibleOptions.map((t,n)=>{let r=t.index===V.visibleFromIndex,a=t.index===V.visibleToIndex-1,s=V.visibleToIndex<o.length,c=V.visibleFromIndex>0,l=V.visibleFromIndex+n+1,d=!e&&V.focusedValue===t.value,f=V.value===t.value,p=t.disabled===!0,m=t.label;if(typeof t.label==`string`&&i&&t.label.includes(i)){let e=t.label,n=e.indexOf(i);m=(0,R.jsxs)(R.Fragment,{children:[e.slice(0,n),(0,R.jsx)(u,{...H.highlightedText(),children:i}),e.slice(n+i.length)]})}return{option:t,index:l,label:m,isFocused:d,isSelected:f,isOptionDisabled:p,shouldShowDownArrow:s&&a,shouldShowUpArrow:c&&r}});if(G){let e=Math.max(...K.map(e=>{if(e.option.type===`input`)return 0;let n=P(e.option.label),r=t?0:U+2,i=e.isSelected?2:0;return 2+r+s(n)+i}));return(0,R.jsx)(l,{...H.container(),children:K.map(n=>{if(n.option.type===`input`)return null;let i=P(n.option.label),o=t?0:U+2,c=n.isSelected?2:0,d=2+o+s(i)+c,f=e-d;return(0,R.jsxs)(I,{isFocused:n.isFocused,children:[(0,R.jsxs)(l,{flexDirection:`row`,flexShrink:0,children:[n.isFocused?(0,R.jsx)(u,{color:`suggestion`,children:r.pointer}):n.shouldShowDownArrow?(0,R.jsx)(u,{dimColor:!0,children:r.arrowDown}):n.shouldShowUpArrow?(0,R.jsx)(u,{dimColor:!0,children:r.arrowUp}):(0,R.jsx)(u,{children:` `}),(0,R.jsx)(u,{children:` `}),(0,R.jsxs)(u,{dimColor:n.isOptionDisabled,color:n.isOptionDisabled?void 0:n.isSelected?`success`:n.isFocused?`suggestion`:void 0,children:[!t&&(0,R.jsx)(u,{dimColor:!0,children:`${n.index}.`.padEnd(U+2)}),n.label]}),n.isSelected&&(0,R.jsxs)(u,{color:`success`,children:[` `,r.tick]}),f>0&&(0,R.jsx)(u,{children:` `.repeat(f)})]}),(0,R.jsx)(l,{flexGrow:1,marginLeft:2,children:(0,R.jsx)(u,{wrap:`wrap`,dimColor:n.isOptionDisabled||n.option.dimDescription!==!1,color:n.isOptionDisabled?void 0:n.isSelected?`success`:n.isFocused?`suggestion`:void 0,children:(0,R.jsx)(a,{children:n.option.description||` `})})})]},String(n.option.value))})})}return(0,R.jsx)(l,{...H.container(),children:V.visibleOptions.map((n,r)=>{if(n.type===`input`){let t=F.has(n.value)?F.get(n.value):n.initialValue||``,i=n.index===V.visibleFromIndex,a=n.index===V.visibleToIndex-1,s=V.visibleToIndex<o.length,c=V.visibleFromIndex>0,l=V.visibleFromIndex+r+1;return(0,R.jsx)(w,{option:n,isFocused:!e&&V.focusedValue===n.value,isSelected:V.value===n.value,shouldShowDownArrow:s&&a,shouldShowUpArrow:c&&i,maxIndexWidth:U,index:l,inputValue:t,onInputChange:e=>{z(t=>{let r=new Map(t);return r.set(n.value,e),r})},onSubmit:e=>{let t=E&&Object.values(E).some(e=>e.type===`image`);e.trim()||t||n.allowEmptySubmitToCancel?f?.(n.value):d?.()},onExit:d,layout:`compact`,showLabel:v,onOpenEditor:C,resetCursorOnUpdate:n.resetCursorOnUpdate,onImagePaste:T,pastedContents:E,onRemoveImage:D,imagesSelected:O,selectedImageIndex:M,onImagesSelectedChange:A,onSelectedImageIndexChange:N},String(n.value))}let s=n.label;if(typeof n.label==`string`&&i&&n.label.includes(i)){let e=n.label,t=e.indexOf(i);s=(0,R.jsxs)(R.Fragment,{children:[e.slice(0,t),(0,R.jsx)(u,{...H.highlightedText(),children:i}),e.slice(t+i.length)]})}let c=n.index===V.visibleFromIndex,p=n.index===V.visibleToIndex-1,m=V.visibleToIndex<o.length,h=V.visibleFromIndex>0,g=V.visibleFromIndex+r+1,_=!e&&V.focusedValue===n.value,y=V.value===n.value,x=n.disabled===!0;return(0,R.jsxs)(b,{isFocused:_,isSelected:y,shouldShowDownArrow:m&&p,shouldShowUpArrow:h&&c,children:[(0,R.jsxs)(l,{flexDirection:`row`,flexShrink:0,children:[!t&&(0,R.jsx)(u,{dimColor:!0,children:`${g}.`.padEnd(U+2)}),(0,R.jsxs)(u,{dimColor:x,color:x?void 0:y?`success`:_?`suggestion`:void 0,children:[s,v&&n.description&&(0,R.jsxs)(u,{dimColor:x||n.dimDescription!==!1,children:[` `,n.description]})]})]}),!v&&n.description&&(0,R.jsx)(l,{flexShrink:99,marginLeft:2,children:(0,R.jsx)(u,{wrap:`wrap-trim`,dimColor:x||n.dimDescription!==!1,color:x?void 0:y?`success`:_?`suggestion`:void 0,children:(0,R.jsx)(a,{children:n.description})})})]},String(n.value))})})}function I({isFocused:e,children:t}){return(0,R.jsx)(l,{ref:o({line:0,column:0,active:e}),flexDirection:`row`,children:t})}var L,R,z=e((()=>{n(),L=t(d(),1),p(),h(),x(),C(),A(),N(),R=m()}));export{z as n,F as t};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{mb as i}from"./loadAgentsDir-B0Anodo0.js";import{Ft as a,G as o,Gr as s,Gt as c,I as l,P as u,ai as d,hn as f,t as p}from"./src-DL3w8VPk.js";import{t as m}from"./jsx-runtime-Bb4Xn-E0.js";import{Hn as h,Vn as g}from"./settings-B2jvL8Dp.js";import{c as _,o as v,s as y}from"./stringUtils-C718f5ey.js";import{a as b,i as x,n as S,o as C,r as w,t as T}from"./use-select-navigation-hWL5VHnL.js";import{i as E,t as D}from"./overlayContext-8--_fbvY.js";var O,k,A=e((()=>{O=t(d(),1),D(),p(),i(),v(),k=({isDisabled:e=!1,disableSelection:t=!1,state:n,options:r,isMultiSelect:i=!1,onUpFromFirstItem:a,onDownFromLastItem:o,onInputModeToggle:s,inputValues:l,imagesSelected:u=!1,onEnterImageSelection:d})=>{E(`select`,!!n.onCancel);let p=(0,O.useMemo)(()=>r.find(e=>e.value===n.focusedValue)?.type===`input`,[r,n.focusedValue]);c((0,O.useMemo)(()=>{let e={};return p||(e[`select:next`]=()=>{if(o){let e=r[r.length-1];if(e&&n.focusedValue===e.value){o();return}}n.focusNextOption()},e[`select:previous`]=()=>{if(a&&n.visibleFromIndex===0){let e=r[0];if(e&&n.focusedValue===e.value){a();return}}n.focusPreviousOption()},e[`select:accept`]=()=>{t!==!0&&n.focusedValue!==void 0&&r.find(e=>e.value===n.focusedValue)?.disabled!==!0&&(n.selectFocusedOption?.(),n.onChange?.(n.focusedValue))}),n.onCancel&&(e[`select:cancel`]=()=>{n.onCancel()}),e},[r,n,o,a,p,t]),{context:`Select`,isActive:!e}),f((e,c,f)=>{let p=y(e),m=r.find(e=>e.value===n.focusedValue),h=m?.type===`input`;if(c.tab&&s&&n.focusedValue!==void 0){s(n.focusedValue);return}if(h){if(u)return;if(c.downArrow&&d?.()){f.stopImmediatePropagation();return}if(c.downArrow||c.ctrl&&e===`n`){if(o){let e=r[r.length-1];if(e&&n.focusedValue===e.value){o(),f.stopImmediatePropagation();return}}n.focusNextOption(),f.stopImmediatePropagation();return}if(c.upArrow||c.ctrl&&e===`p`){if(a&&n.visibleFromIndex===0){let e=r[0];if(e&&n.focusedValue===e.value){a(),f.stopImmediatePropagation();return}}n.focusPreviousOption(),f.stopImmediatePropagation();return}return}if(c.pageDown&&n.focusNextPage(),c.pageUp&&n.focusPreviousPage(),t!==!0&&(i&&_(e)===` `&&n.focusedValue!==void 0&&m?.disabled!==!0&&(n.selectFocusedOption?.(),n.onChange?.(n.focusedValue)),t!==`numeric`&&/^[0-9]+$/.test(p))){let e=parseInt(p,10)-1;if(e>=0&&e<n.options.length){let t=n.options[e];if(t.disabled===!0)return;if(t.type===`input`){if((l?.get(t.value)??``).trim()){n.onChange?.(t.value);return}if(t.allowEmptySubmitToCancel){n.onChange?.(t.value);return}n.focusOption(t.value);return}n.onChange?.(t.value);return}}},{isActive:!e})}}));function j({visibleOptionCount:e=5,options:t,defaultValue:n,onChange:r,onCancel:i,onFocus:a,focusValue:o}){let[s,c]=(0,M.useState)(n),l=S({visibleOptionCount:e,options:t,initialFocusValue:void 0,onFocus:a,focusValue:o}),u=(0,M.useCallback)(()=>{c(l.focusedValue)},[l.focusedValue]);return{...l,value:s,selectFocusedOption:u,onChange:r,onCancel:i}}var M,N=e((()=>{M=t(d(),1),T()}));function P(e){return typeof e==`string`?e:typeof e==`number`?String(e):e?Array.isArray(e)?e.map(P).join(``):L.isValidElement(e)?P(e.props.children):``:``}function F({isDisabled:e=!1,hideIndexes:t=!1,visibleOptionCount:n=5,highlightText:i,options:o,defaultValue:c,onCancel:d,onChange:f,onFocus:p,defaultFocusValue:m,layout:h=`compact`,disableSelection:_=!1,inlineDescriptions:v=!1,onUpFromFirstItem:y,onDownFromLastItem:x,onInputModeToggle:S,onOpenEditor:C,onImagePaste:T,pastedContents:E,onRemoveImage:D}){let[O,A]=(0,L.useState)(!1),[M,N]=(0,L.useState)(0),[F,z]=(0,L.useState)(()=>{let e=new Map;return o.forEach(t=>{t.type===`input`&&t.initialValue&&e.set(t.value,t.initialValue)}),e}),B=(0,L.useRef)(new Map);(0,L.useEffect)(()=>{for(let e of o)if(e.type===`input`&&e.initialValue!==void 0){let t=B.current.get(e.value)??``,n=F.get(e.value)??``,r=e.initialValue;r!==t&&n===t&&z(t=>{let n=new Map(t);return n.set(e.value,r),n}),B.current.set(e.value,r)}},[o,F]);let V=j({visibleOptionCount:n,options:o,defaultValue:c,onChange:f,onCancel:d,onFocus:p,focusValue:m});k({isDisabled:e,disableSelection:_||(t?`numeric`:!1),state:V,options:o,isMultiSelect:!1,onUpFromFirstItem:y,onDownFromLastItem:x,onInputModeToggle:S,inputValues:F,imagesSelected:O,onEnterImageSelection:()=>{if(E&&Object.values(E).some(e=>e.type===`image`)){let e=g(Object.values(E),e=>e.type===`image`);return A(!0),N(e-1),!0}return!1}});let H={container:()=>({flexDirection:`column`}),highlightedText:()=>({bold:!0})};if(h===`expanded`){let t=V.options.length.toString().length;return(0,R.jsx)(l,{...H.container(),children:V.visibleOptions.map((n,r)=>{let s=n.index===V.visibleFromIndex,c=n.index===V.visibleToIndex-1,p=V.visibleToIndex<o.length,m=V.visibleFromIndex>0,h=V.visibleFromIndex+r+1,g=!e&&V.focusedValue===n.value,_=V.value===n.value;if(n.type===`input`){let e=F.has(n.value)?F.get(n.value):n.initialValue||``;return(0,R.jsx)(w,{option:n,isFocused:g,isSelected:_,shouldShowDownArrow:p&&c,shouldShowUpArrow:m&&s,maxIndexWidth:t,index:h,inputValue:e,onInputChange:e=>{z(t=>{let r=new Map(t);return r.set(n.value,e),r})},onSubmit:e=>{let t=E&&Object.values(E).some(e=>e.type===`image`);e.trim()||t||n.allowEmptySubmitToCancel?f?.(n.value):d?.()},onExit:d,layout:`expanded`,showLabel:v,onOpenEditor:C,resetCursorOnUpdate:n.resetCursorOnUpdate,onImagePaste:T,pastedContents:E,onRemoveImage:D,imagesSelected:O,selectedImageIndex:M,onImagesSelectedChange:A,onSelectedImageIndexChange:N},String(n.value))}let y=n.label;if(typeof n.label==`string`&&i&&n.label.includes(i)){let e=n.label,t=e.indexOf(i);y=(0,R.jsxs)(R.Fragment,{children:[e.slice(0,t),(0,R.jsx)(u,{...H.highlightedText(),children:i}),e.slice(t+i.length)]})}let x=n.disabled===!0,S=x?void 0:_?`success`:g?`suggestion`:void 0;return(0,R.jsxs)(l,{flexDirection:`column`,flexShrink:0,children:[(0,R.jsx)(b,{isFocused:g,isSelected:_,shouldShowDownArrow:p&&c,shouldShowUpArrow:m&&s,children:(0,R.jsx)(u,{dimColor:x,color:S,children:y})}),n.description&&(0,R.jsx)(l,{paddingLeft:2,children:(0,R.jsx)(u,{dimColor:x||n.dimDescription!==!1,color:S,children:(0,R.jsx)(a,{children:n.description})})}),(0,R.jsx)(u,{children:` `})]},String(n.value))})})}if(h===`compact-vertical`){let n=t?0:V.options.length.toString().length;return(0,R.jsx)(l,{...H.container(),children:V.visibleOptions.map((r,s)=>{let c=r.index===V.visibleFromIndex,p=r.index===V.visibleToIndex-1,m=V.visibleToIndex<o.length,h=V.visibleFromIndex>0,g=V.visibleFromIndex+s+1,_=!e&&V.focusedValue===r.value,y=V.value===r.value;if(r.type===`input`){let e=F.has(r.value)?F.get(r.value):r.initialValue||``;return(0,R.jsx)(w,{option:r,isFocused:_,isSelected:y,shouldShowDownArrow:m&&p,shouldShowUpArrow:h&&c,maxIndexWidth:n,index:g,inputValue:e,onInputChange:e=>{z(t=>{let n=new Map(t);return n.set(r.value,e),n})},onSubmit:e=>{let t=E&&Object.values(E).some(e=>e.type===`image`);e.trim()||t||r.allowEmptySubmitToCancel?f?.(r.value):d?.()},onExit:d,layout:`compact`,showLabel:v,onOpenEditor:C,resetCursorOnUpdate:r.resetCursorOnUpdate,onImagePaste:T,pastedContents:E,onRemoveImage:D,imagesSelected:O,selectedImageIndex:M,onImagesSelectedChange:A,onSelectedImageIndexChange:N},String(r.value))}let x=r.label;if(typeof r.label==`string`&&i&&r.label.includes(i)){let e=r.label,t=e.indexOf(i);x=(0,R.jsxs)(R.Fragment,{children:[e.slice(0,t),(0,R.jsx)(u,{...H.highlightedText(),children:i}),e.slice(t+i.length)]})}let S=r.disabled===!0;return(0,R.jsxs)(l,{flexDirection:`column`,flexShrink:0,children:[(0,R.jsxs)(b,{isFocused:_,isSelected:y,shouldShowDownArrow:m&&p,shouldShowUpArrow:h&&c,children:[!t&&(0,R.jsx)(u,{dimColor:!0,children:`${g}.`.padEnd(n+1)}),(0,R.jsx)(u,{dimColor:S,color:S?void 0:y?`success`:_?`suggestion`:void 0,children:x})]}),r.description&&(0,R.jsx)(l,{paddingLeft:t?4:n+4,children:(0,R.jsx)(u,{dimColor:S||r.dimDescription!==!1,color:S?void 0:y?`success`:_?`suggestion`:void 0,children:(0,R.jsx)(a,{children:r.description})})})]},String(r.value))})})}let U=t?0:V.options.length.toString().length,W=V.visibleOptions.some(e=>e.type===`input`),G=!v&&!W&&V.visibleOptions.some(e=>e.description),K=V.visibleOptions.map((t,n)=>{let r=t.index===V.visibleFromIndex,a=t.index===V.visibleToIndex-1,s=V.visibleToIndex<o.length,c=V.visibleFromIndex>0,l=V.visibleFromIndex+n+1,d=!e&&V.focusedValue===t.value,f=V.value===t.value,p=t.disabled===!0,m=t.label;if(typeof t.label==`string`&&i&&t.label.includes(i)){let e=t.label,n=e.indexOf(i);m=(0,R.jsxs)(R.Fragment,{children:[e.slice(0,n),(0,R.jsx)(u,{...H.highlightedText(),children:i}),e.slice(n+i.length)]})}return{option:t,index:l,label:m,isFocused:d,isSelected:f,isOptionDisabled:p,shouldShowDownArrow:s&&a,shouldShowUpArrow:c&&r}});if(G){let e=Math.max(...K.map(e=>{if(e.option.type===`input`)return 0;let n=P(e.option.label),r=t?0:U+2,i=e.isSelected?2:0;return 2+r+s(n)+i}));return(0,R.jsx)(l,{...H.container(),children:K.map(n=>{if(n.option.type===`input`)return null;let i=P(n.option.label),o=t?0:U+2,c=n.isSelected?2:0,d=2+o+s(i)+c,f=e-d;return(0,R.jsxs)(I,{isFocused:n.isFocused,children:[(0,R.jsxs)(l,{flexDirection:`row`,flexShrink:0,children:[n.isFocused?(0,R.jsx)(u,{color:`suggestion`,children:r.pointer}):n.shouldShowDownArrow?(0,R.jsx)(u,{dimColor:!0,children:r.arrowDown}):n.shouldShowUpArrow?(0,R.jsx)(u,{dimColor:!0,children:r.arrowUp}):(0,R.jsx)(u,{children:` `}),(0,R.jsx)(u,{children:` `}),(0,R.jsxs)(u,{dimColor:n.isOptionDisabled,color:n.isOptionDisabled?void 0:n.isSelected?`success`:n.isFocused?`suggestion`:void 0,children:[!t&&(0,R.jsx)(u,{dimColor:!0,children:`${n.index}.`.padEnd(U+2)}),n.label]}),n.isSelected&&(0,R.jsxs)(u,{color:`success`,children:[` `,r.tick]}),f>0&&(0,R.jsx)(u,{children:` `.repeat(f)})]}),(0,R.jsx)(l,{flexGrow:1,marginLeft:2,children:(0,R.jsx)(u,{wrap:`wrap`,dimColor:n.isOptionDisabled||n.option.dimDescription!==!1,color:n.isOptionDisabled?void 0:n.isSelected?`success`:n.isFocused?`suggestion`:void 0,children:(0,R.jsx)(a,{children:n.option.description||` `})})})]},String(n.option.value))})})}return(0,R.jsx)(l,{...H.container(),children:V.visibleOptions.map((n,r)=>{if(n.type===`input`){let t=F.has(n.value)?F.get(n.value):n.initialValue||``,i=n.index===V.visibleFromIndex,a=n.index===V.visibleToIndex-1,s=V.visibleToIndex<o.length,c=V.visibleFromIndex>0,l=V.visibleFromIndex+r+1;return(0,R.jsx)(w,{option:n,isFocused:!e&&V.focusedValue===n.value,isSelected:V.value===n.value,shouldShowDownArrow:s&&a,shouldShowUpArrow:c&&i,maxIndexWidth:U,index:l,inputValue:t,onInputChange:e=>{z(t=>{let r=new Map(t);return r.set(n.value,e),r})},onSubmit:e=>{let t=E&&Object.values(E).some(e=>e.type===`image`);e.trim()||t||n.allowEmptySubmitToCancel?f?.(n.value):d?.()},onExit:d,layout:`compact`,showLabel:v,onOpenEditor:C,resetCursorOnUpdate:n.resetCursorOnUpdate,onImagePaste:T,pastedContents:E,onRemoveImage:D,imagesSelected:O,selectedImageIndex:M,onImagesSelectedChange:A,onSelectedImageIndexChange:N},String(n.value))}let s=n.label;if(typeof n.label==`string`&&i&&n.label.includes(i)){let e=n.label,t=e.indexOf(i);s=(0,R.jsxs)(R.Fragment,{children:[e.slice(0,t),(0,R.jsx)(u,{...H.highlightedText(),children:i}),e.slice(t+i.length)]})}let c=n.index===V.visibleFromIndex,p=n.index===V.visibleToIndex-1,m=V.visibleToIndex<o.length,h=V.visibleFromIndex>0,g=V.visibleFromIndex+r+1,_=!e&&V.focusedValue===n.value,y=V.value===n.value,x=n.disabled===!0;return(0,R.jsxs)(b,{isFocused:_,isSelected:y,shouldShowDownArrow:m&&p,shouldShowUpArrow:h&&c,children:[(0,R.jsxs)(l,{flexDirection:`row`,flexShrink:0,children:[!t&&(0,R.jsx)(u,{dimColor:!0,children:`${g}.`.padEnd(U+2)}),(0,R.jsxs)(u,{dimColor:x,color:x?void 0:y?`success`:_?`suggestion`:void 0,children:[s,v&&n.description&&(0,R.jsxs)(u,{dimColor:x||n.dimDescription!==!1,children:[` `,n.description]})]})]}),!v&&n.description&&(0,R.jsx)(l,{flexShrink:99,marginLeft:2,children:(0,R.jsx)(u,{wrap:`wrap-trim`,dimColor:x||n.dimDescription!==!1,color:x?void 0:y?`success`:_?`suggestion`:void 0,children:(0,R.jsx)(a,{children:n.description})})})]},String(n.value))})})}function I({isFocused:e,children:t}){return(0,R.jsx)(l,{ref:o({line:0,column:0,active:e}),flexDirection:`row`,children:t})}var L,R,z=e((()=>{n(),L=t(d(),1),p(),h(),x(),C(),A(),N(),R=m()}));export{z as n,F as t};
@@ -0,0 +1 @@
1
+ import{Hf as e,Vf as t}from"./loadAgentsDir-B0Anodo0.js";t();export{e as registerSessionFileAccessHooks};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{X as t,Z as n,aC as r,qg as i}from"./loadAgentsDir-DlPbtIsS.js";import{i as a,l as o,t as s,u as c}from"./instinctParser-Dt-lqnDe.js";function l(e){h.set(e.name,e),g||(g=e.name)}function u(e){if(!h.has(e))throw Error(`Observer backend "${e}" is not registered`);g=e}function d(){let e=g?h.get(g):void 0;if(!e)throw Error(`No observer backend is active — register one before analyzing observations`);return e}async function f(e,t){return Promise.resolve(d().analyze(e,t))}function p(){let e=process.env.SKILL_LEARNING_OBSERVER_BACKEND?.trim();return e&&h.has(e)?e:void 0}function m(){let e=p();return e&&u(e),d()}var h,g,_=e((()=>{h=new Map})),v,y=e((()=>{v=[`workflow`,`testing`,`debugging`,`code-style`,`security`,`git`,`project`]}));async function b(e,t){if(e.length===0)return[];if(Date.now()<L)return x(e,t);let i=e.slice(-30),a=S(i),s=P(o().llm.timeoutMs),c;try{let e=await n({systemPrompt:r([R]),userPrompt:a,signal:s,options:{querySource:`skill_learning_observer`,enablePromptCaching:!0,agents:[],isNonInteractiveSession:!0,hasAppendSystemPrompt:!1,mcpTools:[]}});I=0,c=T(e.message?.content)}catch{return I++,I>=o().llm.failureThreshold&&(L=Date.now()+o().llm.circuitCooldownMs),x(e,t)}let l=E(c,t,i);return l.length===0?(I++,I>=o().llm.failureThreshold&&(L=Date.now()+o().llm.circuitCooldownMs),x(e,t)):l}async function x(e,t){try{let{heuristicObserverBackend:n}=await import(`./sessionObserver-DGEQM4cO.js`),r=n.analyze(e,t);return Array.isArray(r)?r:await r}catch{return[]}}function S(e){return`Observations (chronological, newest last):\n${e.map((e,t)=>C(e,t)).join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{X as t,Z as n,aC as r,qg as i}from"./loadAgentsDir-B0Anodo0.js";import{i as a,l as o,t as s,u as c}from"./instinctParser-Dt-lqnDe.js";function l(e){h.set(e.name,e),g||(g=e.name)}function u(e){if(!h.has(e))throw Error(`Observer backend "${e}" is not registered`);g=e}function d(){let e=g?h.get(g):void 0;if(!e)throw Error(`No observer backend is active — register one before analyzing observations`);return e}async function f(e,t){return Promise.resolve(d().analyze(e,t))}function p(){let e=process.env.SKILL_LEARNING_OBSERVER_BACKEND?.trim();return e&&h.has(e)?e:void 0}function m(){let e=p();return e&&u(e),d()}var h,g,_=e((()=>{h=new Map})),v,y=e((()=>{v=[`workflow`,`testing`,`debugging`,`code-style`,`security`,`git`,`project`]}));async function b(e,t){if(e.length===0)return[];if(Date.now()<L)return x(e,t);let i=e.slice(-30),a=S(i),s=P(o().llm.timeoutMs),c;try{let e=await n({systemPrompt:r([R]),userPrompt:a,signal:s,options:{querySource:`skill_learning_observer`,enablePromptCaching:!0,agents:[],isNonInteractiveSession:!0,hasAppendSystemPrompt:!1,mcpTools:[]}});I=0,c=T(e.message?.content)}catch{return I++,I>=o().llm.failureThreshold&&(L=Date.now()+o().llm.circuitCooldownMs),x(e,t)}let l=E(c,t,i);return l.length===0?(I++,I>=o().llm.failureThreshold&&(L=Date.now()+o().llm.circuitCooldownMs),x(e,t)):l}async function x(e,t){try{let{heuristicObserverBackend:n}=await import(`./sessionObserver-D6qzEdGJ.js`),r=n.analyze(e,t);return Array.isArray(r)?r:await r}catch{return[]}}function S(e){return`Observations (chronological, newest last):\n${e.map((e,t)=>C(e,t)).join(`
2
2
  `)}\n\nExtract up to ${F} atomic instincts. JSON array only.`}function C(e,t){let n=[`#${t+1}`,`event=${e.event}`];return e.toolName&&n.push(`tool=${e.toolName}`),e.outcome&&n.push(`outcome=${e.outcome}`),e.messageText&&n.push(`text=${JSON.stringify(w(e.messageText,200))}`),e.toolInput&&n.push(`in=${JSON.stringify(w(e.toolInput,120))}`),e.toolOutput&&n.push(`out=${JSON.stringify(w(e.toolOutput,120))}`),n.join(` | `)}function w(e,t){return e.length<=t?e:`${e.slice(0,t)}…`}function T(e){if(!Array.isArray(e))return``;let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;e.type===`text`&&typeof e.text==`string`&&t.push(e.text)}return t.join(``).trim()}function E(e,t,n){let r=D(e);if(!r)return[];let i;try{i=JSON.parse(r)}catch{return[]}if(!Array.isArray(i))return[];let a=n.map(e=>e.id),o=[];for(let e of i.slice(0,F)){let n=O(e,t,a);n&&o.push(n)}return o}function D(e){if(!e)return;let t=e.indexOf(`[`),n=e.lastIndexOf(`]`);if(!(t<0||n<=t))return e.slice(t,n+1)}function O(e,t,n){if(!e||typeof e!=`object`)return;let r=e,i=k(r.trigger,80),a=k(r.action,120);if(!i||!a)return;let o=N(r.evidence);if(o.length!==0)return{trigger:i,action:a,confidence:A(r.confidence),domain:j(r.domain),source:`session-observation`,scope:M(r.scope),projectId:t?.project?.projectId,projectName:t?.project?.projectName,evidence:o,observationIds:n}}function k(e,t){if(typeof e!=`string`)return;let n=e.trim();if(n)return n.length>t?n.slice(0,t):n}function A(e){return typeof e!=`number`||!Number.isFinite(e)?.5:e<0?0:e>1?1:e}function j(e){return typeof e==`string`&&v.includes(e)?e:`project`}function M(e){return e===`global`?`global`:`project`}function N(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();if(e&&(t.push(e.length>200?`${e.slice(0,200)}…`:e),t.length===3))break}return t}function P(e){return AbortSignal.timeout(e)}var F,I,L,R,z,B=e((()=>{t(),i(),c(),y(),F=3,I=0,L=0,R=`You analyse a short sequence of observations from a coding-assistant session (user messages, tool invocations with outcomes, assistant messages) and extract atomic, reusable "instincts" — behavioural patterns that would help the assistant act correctly in future similar situations.
3
3
 
4
4
  Respond with ONLY a JSON array (no prose, no code fences, no commentary). Each item must match this schema:
@@ -0,0 +1 @@
1
+ import{n as e,r as t}from"./sessionObserver-BtKjvteq.js";t();export{e as heuristicObserverBackend};
@@ -0,0 +1 @@
1
+ import{Gr as e,_r as t,wr as n}from"./loadAgentsDir-B0Anodo0.js";t();export{n as linkSessionToPR,e as recordTranscript};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DfkgIdYf.js";import{i as r,l as i,n as a}from"./esm-lWlUmoUA.js";import{et as o,ft as s,rt as c,ut as l}from"./esm-eTAUP-La.js";import{D as u,I as d,It as f,st as p,tt as m}from"./state-B4jiUise.js";import{C as h,I as ee,S as g,c as te,i as ne,x as _}from"./debug-Bglx1aTu.js";import{p as re,u as ie}from"./config-C-Y2qtB2.js";import{S as ae,y as oe}from"./log-D2TIwHBV.js";import"path";import"fs";import{createHash as se}from"crypto";import"fs/promises";import{AsyncLocalStorage as ce}from"async_hooks";function le(e){let n=ue[e],r=process.env[e];return r===void 0?n:t(r)}function v(){let e=ie(),t=p(),n={"user.id":e};return le(`OTEL_METRICS_INCLUDE_SESSION_ID`)&&(n[`session.id`]=t),le(`OTEL_METRICS_INCLUDE_VERSION`)&&(n[`app.version`]=`0.0.23`),l.terminal&&(n[`terminal.type`]=l.terminal),n}var ue,y=e((()=>{f(),re(),s(),n(),ue={OTEL_METRICS_INCLUDE_SESSION_ID:!0,OTEL_METRICS_INCLUDE_VERSION:!1,OTEL_METRICS_INCLUDE_ACCOUNT_UUID:!0}}));function de(){return t(process.env.OTEL_LOG_USER_PROMPTS)}function fe(e){return de()?e:`<REDACTED>`}async function b(e,t={}){let n=u();if(!n){x||(x=!0,te(`[3P telemetry] Event dropped (no event logger initialized): ${e}`,{level:`warn`}));return}let r={...v(),"event.name":e,"event.timestamp":new Date().toISOString(),"event.sequence":pe++},i=m();i&&(r[`prompt.id`]=i);let a=process.env.CLAUDE_CODE_WORKSPACE_HOST_PATHS;a&&(r[`workspace.host_paths`]=a.split(`|`));for(let[e,n]of Object.entries(t))n!==void 0&&(r[e]=n);n.emit({body:`claude_code.${e}`,attributes:r})}var pe,x,me=e((()=>{f(),ne(),n(),y(),pe=0,x=!1}));function he(){E.clear(),D.clear()}function S(){return t(process.env.ENABLE_BETA_TRACING_DETAILED)&&process.env.BETA_TRACING_ENDPOINT&&d()||!1}function C(e,t=O){return e.length<=t?{content:e,truncated:!1}:{content:e.slice(0,t)+`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DfkgIdYf.js";import{i as r,l as i,n as a}from"./esm-lWlUmoUA.js";import{et as o,ft as s,rt as c,ut as l}from"./esm-BXTZz3av.js";import{D as u,I as d,It as f,st as p,tt as m}from"./state-B4jiUise.js";import{C as h,I as ee,S as g,c as te,i as ne,x as _}from"./debug-Bglx1aTu.js";import{p as re,u as ie}from"./config-C-Y2qtB2.js";import{S as ae,y as oe}from"./log-D2TIwHBV.js";import"path";import"fs";import{createHash as se}from"crypto";import"fs/promises";import{AsyncLocalStorage as ce}from"async_hooks";function le(e){let n=ue[e],r=process.env[e];return r===void 0?n:t(r)}function v(){let e=ie(),t=p(),n={"user.id":e};return le(`OTEL_METRICS_INCLUDE_SESSION_ID`)&&(n[`session.id`]=t),le(`OTEL_METRICS_INCLUDE_VERSION`)&&(n[`app.version`]=`0.0.24`),l.terminal&&(n[`terminal.type`]=l.terminal),n}var ue,y=e((()=>{f(),re(),s(),n(),ue={OTEL_METRICS_INCLUDE_SESSION_ID:!0,OTEL_METRICS_INCLUDE_VERSION:!1,OTEL_METRICS_INCLUDE_ACCOUNT_UUID:!0}}));function de(){return t(process.env.OTEL_LOG_USER_PROMPTS)}function fe(e){return de()?e:`<REDACTED>`}async function b(e,t={}){let n=u();if(!n){x||(x=!0,te(`[3P telemetry] Event dropped (no event logger initialized): ${e}`,{level:`warn`}));return}let r={...v(),"event.name":e,"event.timestamp":new Date().toISOString(),"event.sequence":pe++},i=m();i&&(r[`prompt.id`]=i);let a=process.env.CLAUDE_CODE_WORKSPACE_HOST_PATHS;a&&(r[`workspace.host_paths`]=a.split(`|`));for(let[e,n]of Object.entries(t))n!==void 0&&(r[e]=n);n.emit({body:`claude_code.${e}`,attributes:r})}var pe,x,me=e((()=>{f(),ne(),n(),y(),pe=0,x=!1}));function he(){E.clear(),D.clear()}function S(){return t(process.env.ENABLE_BETA_TRACING_DETAILED)&&process.env.BETA_TRACING_ENDPOINT&&d()||!1}function C(e,t=O){return e.length<=t?{content:e,truncated:!1}:{content:e.slice(0,t)+`
2
2
 
3
3
  [TRUNCATED - Content exceeds 60KB limit]`,truncated:!0}}function w(e){return se(`sha256`).update(e).digest(`hex`).slice(0,12)}function ge(e){return`sp_${w(e)}`}function _e(e){return`msg_${w(h(e.message.content))}`}function T(e){let t=e.trim().match(k);return t?.[1]?t[1].trim():null}function ve(e){let t=[],n=[];for(let r of e){let e=r.message.content;if(typeof e==`string`){let r=T(e);r?n.push(r):t.push(`[USER]\n${e}`)}else if(Array.isArray(e)){for(let r of e)if(r.type===`text`){let e=T(r.text);e?n.push(e):t.push(`[USER]\n${r.text}`)}else if(r.type===`tool_result`){let e=typeof r.content==`string`?r.content:h(r.content),i=T(e);i?n.push(i):t.push(`[TOOL RESULT: ${r.tool_use_id}]\n${e}`)}}}return{contextParts:t,systemReminders:n}}function ye(e,t){if(!S())return;let{content:n,truncated:r}=C(`[USER PROMPT]\n${t}`);e.setAttributes({new_context:n,...r&&{new_context_truncated:!0,new_context_original_length:t.length}})}function be(e,t,n){if(S()){if(t?.systemPrompt){let n=ge(t.systemPrompt),r=t.systemPrompt.slice(0,500);if(e.setAttribute(`system_prompt_hash`,n),e.setAttribute(`system_prompt_preview`,r),e.setAttribute(`system_prompt_length`,t.systemPrompt.length),!E.has(n)){E.add(n);let{content:e,truncated:r}=C(t.systemPrompt);b(`system_prompt`,{system_prompt_hash:n,system_prompt:e,system_prompt_length:String(t.systemPrompt.length),...r&&{system_prompt_truncated:`true`}})}}if(t?.tools)try{let n=g(t.tools).map(e=>{let t=h(e),n=w(t);return{name:typeof e.name==`string`?e.name:`unknown`,hash:n,json:t}});e.setAttribute(`tools`,h(n.map(({name:e,hash:t})=>({name:e,hash:t})))),e.setAttribute(`tools_count`,n.length);for(let{name:e,hash:t,json:r}of n)if(!E.has(`tool_${t}`)){E.add(`tool_${t}`);let{content:n,truncated:i}=C(r);b(`tool`,{tool_name:c(e),tool_hash:t,tool:n,...i&&{tool_truncated:`true`}})}}catch{e.setAttribute(`tools_parse_error`,!0)}if(n&&n.length>0&&t?.querySource){let r=t.querySource,i=D.get(r),a=0;if(i)for(let e=0;e<n.length;e++){let t=n[e];if(t&&_e(t)===i){a=e+1;break}}let o=n.slice(a).filter(e=>e.type===`user`);if(o.length>0){let{contextParts:t,systemReminders:i}=ve(o);if(t.length>0){let n=t.join(`
4
4
 
@@ -1,3 +1,3 @@
1
- import{n as e,t}from"./memoize-BK3gG5ob.js";import{l as n,o as r,s as i}from"./envUtils-DfkgIdYf.js";import{ft as a,ut as o}from"./esm-eTAUP-La.js";import{$h as s,$y as c,An as l,Aw as u,Bb as d,Bs as f,Gb as ee,Gh as p,Gs as m,Jd as h,Jh as g,Kh as _,Mn as te,Nb as ne,Nh as re,Ni as ie,Oi as ae,Ow as oe,Pb as v,Qh as se,Qy as ce,Ub as le,Us as ue,Vb as de,Wb as fe,Xh as pe,Yd as y,Yh as b,Yi as x,Zh as S,_f as C,_r as w,_t as T,at as E,ba as D,bm as O,df as k,dg as A,eg as j,ff as M,gf as N,ht as P,jn as F,kt as I,m_ as L,mn as R,mt as z,ng as B,oi as me,pS as he,pg as V,pn as ge,qg as _e,qh as ve,rg as ye,tg as be,ug as xe,vf as Se,xm as Ce,xt as we,y_ as Te,zs as Ee}from"./loadAgentsDir-DlPbtIsS.js";import{di as H,fi as De}from"./src-DL3w8VPk.js";import{Dn as Oe,I as U,It as ke,Q as Ae,Wn as je,kn as Me,st as Ne}from"./state-B4jiUise.js";import{n as Pe,t as W}from"./cwd-Pa83R95t.js";import{I as G,M as Fe,N as Ie,f as Le,u as Re}from"./debug-Bglx1aTu.js";import{Dr as ze,Hn as Be,Lr as Ve,Mr as He,Or as Ue,Vn as We,Wt as Ge,Xr as K,Yr as Ke,qt as qe}from"./settings-B2jvL8Dp.js";import{o as Je,p as Ye}from"./config-C-Y2qtB2.js";import{o as Xe,s as Ze}from"./log-D2TIwHBV.js";import{n as q,r as J}from"./analytics-DJobLaWP.js";import{n as Qe,r as Y}from"./startupProfiler-CJdr3SxP.js";import{dt as $e,ut as et}from"./model-BwBG0V1u.js";import{pn as tt,un as X}from"./prompt-mM79EGnT.js";import{a as nt,r as rt}from"./projectOnboardingState-B5YATuc6.js";import{i as it,n as at}from"./appleTerminalBackup-BArZWB21.js";import{c as ot,t as st}from"./nativeInstaller-C3pVPqrZ.js";import{l as ct,s as lt}from"./logoUtils-x2pHV-Nl.js";import{i as ut,r as dt}from"./runtimeObserver-XQrOux41.js";import{t as ft}from"./sinks-Cz2HfgMU.js";import{writeFile as Z}from"fs/promises";r(),De(),ke(),Pe(),Ke(),Xe(),Ve(),qe(),Ye(),u(),fe(),d(),ne(),Ce(),ie(),w(),R(),t(),E(),re(),tt(),c(),Be(),ue(),Le(),h(),x(),te(),et(),_e(),A(),q(),k(),C(),pe(),G();function pt(){return!1}function Q(){return{}}var $;function mt(e,t){let n=0,r=t==null;for(let i of e){if(!r){i.uuid===t&&(r=!0);continue}if(i.type===`assistant`){let e=i.message.content;Array.isArray(e)&&(n+=We(e,e=>e.type===`tool_use`))}}return n}function ht(e){let t=V(e);if(!S()){if(!g(t))return!1;j()}let n=b(t),r=mt(e,$)>=ve(),i=D(e);if(n&&r||n&&!i){let t=e[e.length-1];return t?.uuid&&($=t.uuid),!0}return!1}async function gt(e){let t=Re(),n=l();await t.mkdir(n,{mode:448});let r=F();try{await Z(r,``,{encoding:`utf-8`,mode:384,flag:`wx`}),await Z(r,await Se(),{encoding:`utf-8`,mode:384})}catch(e){if(Ie(e)!==`EEXIST`)throw e}e.readFileState.delete(r);let i=await ce.call({file_path:r},e),a=``,o=i.data;return o.type===`text`&&(a=o.file.content),J(`tengu_session_memory_file_read`,{content_length:a.length}),{memoryPath:r,currentMemory:a}}var _t=e(()=>{let e=Q();ye({minimumMessageTokensToInit:e.minimumMessageTokensToInit&&e.minimumMessageTokensToInit>0?e.minimumMessageTokensToInit:p.minimumMessageTokensToInit,minimumTokensBetweenUpdate:e.minimumTokensBetweenUpdate&&e.minimumTokensBetweenUpdate>0?e.minimumTokensBetweenUpdate:p.minimumTokensBetweenUpdate,toolCallsBetweenUpdates:e.toolCallsBetweenUpdates&&e.toolCallsBetweenUpdates>0?e.toolCallsBetweenUpdates:p.toolCallsBetweenUpdates})}),vt=$e(async e=>{let{messages:t,toolUseContext:n,querySource:r}=e;if(r!==`repl_main_thread`||!pt()||(_t(),!ht(t)))return;s();let i=f(n),{memoryPath:a,currentMemory:o}=await gt(i);await m({promptMessages:[he({content:await N(o,a)})],cacheSafeParams:Ee(e),canUseTool:bt(a),querySource:`session_memory`,forkLabel:`session_memory`,overrides:{readFileState:i.readFileState}});let c=t[t.length-1],l=c?xe(c):void 0,u=_();J(`tengu_session_memory_extraction`,{input_tokens:l?.input_tokens,output_tokens:l?.output_tokens,cache_read_input_tokens:l?.cache_read_input_tokens??void 0,cache_creation_input_tokens:l?.cache_creation_input_tokens??void 0,config_min_message_tokens_to_init:u.minimumMessageTokensToInit,config_min_tokens_between_update:u.minimumTokensBetweenUpdate,config_tool_calls_between_updates:u.toolCallsBetweenUpdates}),be(V(t)),xt(t),se()});function yt(){M()&&y(vt)}function bt(e){return async(t,n)=>{if(t.name===`Edit`&&typeof n==`object`&&n&&`file_path`in n){let t=n.file_path;if(typeof t==`string`&&t===e)return{behavior:`allow`,updatedInput:n}}return{behavior:`deny`,message:`only ${X} on ${e} is allowed`,decisionReason:{type:`other`,reason:`only ${X} on ${e} is allowed`}}}}function xt(e){if(!D(e)){let t=e[e.length-1];t?.uuid&&B(t.uuid)}}q(),ut(),it(),Te(),a(),G(),ct(),st(),rt(),Qe(),we();async function St(e,t,r,a,s,c,l,u){K(`info`,`setup_started`);let d=process.version.match(/^v(\d+)\./)?.[1];if((!d||parseInt(d,10)<18)&&(console.error(H.bold.red(`Error: Work Mate requires Node.js version 18 or higher.`)),process.exit(1)),l&&je(O(l)),!U())try{let e=await at();e.status===`restored`?console.log(H.yellow(`Detected an interrupted Terminal.app setup. Your original settings have been restored. You may need to restart Terminal.app for the changes to take effect.`)):e.status===`failed`&&console.error(H.red(`Failed to restore Terminal.app settings. Please manually restore your original settings with: defaults import com.apple.Terminal ${e.backupPath}.`))}catch(e){Ze(e)}v(e);let f=Date.now();if(le(),K(`info`,`setup_hooks_captured`,{duration_ms:Date.now()-f}),de(e),a){let t=ge(),n=await He();!t&&!n&&(process.stderr.write(H.red(`Error: Can only use --worktree in a git repository, but ${H.bold(e)} is not a git repository. Configure a WorktreeCreate hook in settings.json to use --worktree with other VCS systems.\n`)),process.exit(1));let r=u?`pr-${u}`:s??oe(),i;if(n){let e=ze(W());e||(process.stderr.write(H.red(`Error: Could not determine the main git repository root.
2
- `)),process.exit(1)),e!==(Ue(W())??W())&&(K(`info`,`worktree_resolved_to_main_repo`),process.chdir(e),v(e)),i=c?T(e,I(r)):void 0}else i=c?T(W(),I(r)):void 0;let a;try{a=await P(Ne(),r,i,u?{prNumber:u}:void 0)}catch(e){process.stderr.write(H.red(`Error creating worktree: ${Fe(e)}\n`)),process.exit(1)}if(J(`tengu_worktree_created`,{tmux_enabled:c}),c&&i){let e=await z(i,a.worktreePath);e.created?console.log(H.green(`Created tmux session: ${H.bold(i)}\nTo attach: ${H.bold(`tmux attach -t ${i}`)}`)):console.error(H.yellow(`Warning: Failed to create tmux session: ${e.error}`))}process.chdir(a.worktreePath),v(a.worktreePath),Oe(W()),Me(W()),me(a),L(),ee()}K(`info`,`setup_background_jobs_starting`),i()||(yt(),dt()),ot(),K(`info`,`setup_background_jobs_launched`),Y(`setup_before_prefetch`),K(`info`,`setup_prefetch_starting`);let p=U()&&n(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)||i();if(p||ae(Ae()),import(`./loadPluginHooks-C_msxVIc.js`).then(e=>{p||(e.loadPluginHooks(),e.setupPluginHookHotReload())}),i()||import(`./sessionFileAccessHooks-CozocHQE.js`).then(e=>e.registerSessionFileAccessHooks()),ft(),J(`tengu_started`,{}),Y(`setup_after_prefetch`),!i()&&nt()&&await lt(),t===`bypassPermissions`||r){if(process.platform!==`win32`&&typeof process.getuid==`function`&&process.getuid()===0&&process.env.IS_SANDBOX!==`1`&&!n(process.env.CLAUDE_CODE_BUBBLEWRAP))if(process.stdin.isTTY){console.error(H.bold.red(`WARNING: Running as root/sudo with bypass permissions mode is dangerous.`)),console.error(H.yellow(`Bypass mode skips ALL permission checks. Combined with root, any command (rm -rf /, chmod, dd) executes without review.`));let e=(await import(`readline`)).createInterface({input:process.stdin,output:process.stdout}),t=await new Promise(t=>{e.question(`
1
+ import{n as e,t}from"./memoize-BK3gG5ob.js";import{l as n,o as r,s as i}from"./envUtils-DfkgIdYf.js";import{ft as a,ut as o}from"./esm-BXTZz3av.js";import{$h as s,$y as c,An as l,Aw as u,Bb as d,Bs as f,Gb as ee,Gh as p,Gs as m,Jd as h,Jh as g,Kh as _,Mn as te,Nb as ne,Nh as re,Ni as ie,Oi as ae,Ow as oe,Pb as v,Qh as se,Qy as ce,Ub as le,Us as ue,Vb as de,Wb as fe,Xh as pe,Yd as y,Yh as b,Yi as x,Zh as S,_f as C,_r as w,_t as T,at as E,ba as D,bm as O,df as k,dg as A,eg as j,ff as M,gf as N,ht as P,jn as F,kt as I,m_ as L,mn as R,mt as z,ng as B,oi as me,pS as he,pg as V,pn as ge,qg as _e,qh as ve,rg as ye,tg as be,ug as xe,vf as Se,xm as Ce,xt as we,y_ as Te,zs as Ee}from"./loadAgentsDir-B0Anodo0.js";import{di as H,fi as De}from"./src-DL3w8VPk.js";import{Dn as Oe,I as U,It as ke,Q as Ae,Wn as je,kn as Me,st as Ne}from"./state-B4jiUise.js";import{n as Pe,t as W}from"./cwd-Pa83R95t.js";import{I as G,M as Fe,N as Ie,f as Le,u as Re}from"./debug-Bglx1aTu.js";import{Dr as ze,Hn as Be,Lr as Ve,Mr as He,Or as Ue,Vn as We,Wt as Ge,Xr as K,Yr as Ke,qt as qe}from"./settings-B2jvL8Dp.js";import{o as Je,p as Ye}from"./config-C-Y2qtB2.js";import{o as Xe,s as Ze}from"./log-D2TIwHBV.js";import{n as q,r as J}from"./analytics-DJobLaWP.js";import{n as Qe,r as Y}from"./startupProfiler-CJdr3SxP.js";import{dt as $e,ut as et}from"./model-BvQFFOf8.js";import{pn as tt,un as X}from"./prompt-CJ1l3XXk.js";import{a as nt,r as rt}from"./projectOnboardingState-B5YATuc6.js";import{i as it,n as at}from"./appleTerminalBackup-BArZWB21.js";import{c as ot,t as st}from"./nativeInstaller-CdjmE9Zy.js";import{l as ct,s as lt}from"./logoUtils-CRxTutvr.js";import{i as ut,r as dt}from"./runtimeObserver-PJ1o8GRA.js";import{t as ft}from"./sinks-De-B1lPQ.js";import{writeFile as Z}from"fs/promises";r(),De(),ke(),Pe(),Ke(),Xe(),Ve(),qe(),Ye(),u(),fe(),d(),ne(),Ce(),ie(),w(),R(),t(),E(),re(),tt(),c(),Be(),ue(),Le(),h(),x(),te(),et(),_e(),A(),q(),k(),C(),pe(),G();function pt(){return!1}function Q(){return{}}var $;function mt(e,t){let n=0,r=t==null;for(let i of e){if(!r){i.uuid===t&&(r=!0);continue}if(i.type===`assistant`){let e=i.message.content;Array.isArray(e)&&(n+=We(e,e=>e.type===`tool_use`))}}return n}function ht(e){let t=V(e);if(!S()){if(!g(t))return!1;j()}let n=b(t),r=mt(e,$)>=ve(),i=D(e);if(n&&r||n&&!i){let t=e[e.length-1];return t?.uuid&&($=t.uuid),!0}return!1}async function gt(e){let t=Re(),n=l();await t.mkdir(n,{mode:448});let r=F();try{await Z(r,``,{encoding:`utf-8`,mode:384,flag:`wx`}),await Z(r,await Se(),{encoding:`utf-8`,mode:384})}catch(e){if(Ie(e)!==`EEXIST`)throw e}e.readFileState.delete(r);let i=await ce.call({file_path:r},e),a=``,o=i.data;return o.type===`text`&&(a=o.file.content),J(`tengu_session_memory_file_read`,{content_length:a.length}),{memoryPath:r,currentMemory:a}}var _t=e(()=>{let e=Q();ye({minimumMessageTokensToInit:e.minimumMessageTokensToInit&&e.minimumMessageTokensToInit>0?e.minimumMessageTokensToInit:p.minimumMessageTokensToInit,minimumTokensBetweenUpdate:e.minimumTokensBetweenUpdate&&e.minimumTokensBetweenUpdate>0?e.minimumTokensBetweenUpdate:p.minimumTokensBetweenUpdate,toolCallsBetweenUpdates:e.toolCallsBetweenUpdates&&e.toolCallsBetweenUpdates>0?e.toolCallsBetweenUpdates:p.toolCallsBetweenUpdates})}),vt=$e(async e=>{let{messages:t,toolUseContext:n,querySource:r}=e;if(r!==`repl_main_thread`||!pt()||(_t(),!ht(t)))return;s();let i=f(n),{memoryPath:a,currentMemory:o}=await gt(i);await m({promptMessages:[he({content:await N(o,a)})],cacheSafeParams:Ee(e),canUseTool:bt(a),querySource:`session_memory`,forkLabel:`session_memory`,overrides:{readFileState:i.readFileState}});let c=t[t.length-1],l=c?xe(c):void 0,u=_();J(`tengu_session_memory_extraction`,{input_tokens:l?.input_tokens,output_tokens:l?.output_tokens,cache_read_input_tokens:l?.cache_read_input_tokens??void 0,cache_creation_input_tokens:l?.cache_creation_input_tokens??void 0,config_min_message_tokens_to_init:u.minimumMessageTokensToInit,config_min_tokens_between_update:u.minimumTokensBetweenUpdate,config_tool_calls_between_updates:u.toolCallsBetweenUpdates}),be(V(t)),xt(t),se()});function yt(){M()&&y(vt)}function bt(e){return async(t,n)=>{if(t.name===`Edit`&&typeof n==`object`&&n&&`file_path`in n){let t=n.file_path;if(typeof t==`string`&&t===e)return{behavior:`allow`,updatedInput:n}}return{behavior:`deny`,message:`only ${X} on ${e} is allowed`,decisionReason:{type:`other`,reason:`only ${X} on ${e} is allowed`}}}}function xt(e){if(!D(e)){let t=e[e.length-1];t?.uuid&&B(t.uuid)}}q(),ut(),it(),Te(),a(),G(),ct(),st(),rt(),Qe(),we();async function St(e,t,r,a,s,c,l,u){K(`info`,`setup_started`);let d=process.version.match(/^v(\d+)\./)?.[1];if((!d||parseInt(d,10)<18)&&(console.error(H.bold.red(`Error: Work Mate requires Node.js version 18 or higher.`)),process.exit(1)),l&&je(O(l)),!U())try{let e=await at();e.status===`restored`?console.log(H.yellow(`Detected an interrupted Terminal.app setup. Your original settings have been restored. You may need to restart Terminal.app for the changes to take effect.`)):e.status===`failed`&&console.error(H.red(`Failed to restore Terminal.app settings. Please manually restore your original settings with: defaults import com.apple.Terminal ${e.backupPath}.`))}catch(e){Ze(e)}v(e);let f=Date.now();if(le(),K(`info`,`setup_hooks_captured`,{duration_ms:Date.now()-f}),de(e),a){let t=ge(),n=await He();!t&&!n&&(process.stderr.write(H.red(`Error: Can only use --worktree in a git repository, but ${H.bold(e)} is not a git repository. Configure a WorktreeCreate hook in settings.json to use --worktree with other VCS systems.\n`)),process.exit(1));let r=u?`pr-${u}`:s??oe(),i;if(n){let e=ze(W());e||(process.stderr.write(H.red(`Error: Could not determine the main git repository root.
2
+ `)),process.exit(1)),e!==(Ue(W())??W())&&(K(`info`,`worktree_resolved_to_main_repo`),process.chdir(e),v(e)),i=c?T(e,I(r)):void 0}else i=c?T(W(),I(r)):void 0;let a;try{a=await P(Ne(),r,i,u?{prNumber:u}:void 0)}catch(e){process.stderr.write(H.red(`Error creating worktree: ${Fe(e)}\n`)),process.exit(1)}if(J(`tengu_worktree_created`,{tmux_enabled:c}),c&&i){let e=await z(i,a.worktreePath);e.created?console.log(H.green(`Created tmux session: ${H.bold(i)}\nTo attach: ${H.bold(`tmux attach -t ${i}`)}`)):console.error(H.yellow(`Warning: Failed to create tmux session: ${e.error}`))}process.chdir(a.worktreePath),v(a.worktreePath),Oe(W()),Me(W()),me(a),L(),ee()}K(`info`,`setup_background_jobs_starting`),i()||(yt(),dt()),ot(),K(`info`,`setup_background_jobs_launched`),Y(`setup_before_prefetch`),K(`info`,`setup_prefetch_starting`);let p=U()&&n(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)||i();if(p||ae(Ae()),import(`./loadPluginHooks-BSwCtQ6T.js`).then(e=>{p||(e.loadPluginHooks(),e.setupPluginHookHotReload())}),i()||import(`./sessionFileAccessHooks-lbgHnVvi.js`).then(e=>e.registerSessionFileAccessHooks()),ft(),J(`tengu_started`,{}),Y(`setup_after_prefetch`),!i()&&nt()&&await lt(),t===`bypassPermissions`||r){if(process.platform!==`win32`&&typeof process.getuid==`function`&&process.getuid()===0&&process.env.IS_SANDBOX!==`1`&&!n(process.env.CLAUDE_CODE_BUBBLEWRAP))if(process.stdin.isTTY){console.error(H.bold.red(`WARNING: Running as root/sudo with bypass permissions mode is dangerous.`)),console.error(H.yellow(`Bypass mode skips ALL permission checks. Combined with root, any command (rm -rf /, chmod, dd) executes without review.`));let e=(await import(`readline`)).createInterface({input:process.stdin,output:process.stdout}),t=await new Promise(t=>{e.question(`
3
3
  I understand the risks. Continue? [y/N] `,t)});e.close(),t.trim().toLowerCase()!==`y`&&(console.error(`Aborted.`),process.exit(1))}else console.error(`--dangerously-skip-permissions cannot be used with root/sudo privileges for security reasons`),process.exit(1);if(process.env.CLAUDE_CODE_ENTRYPOINT!==`local-agent`&&process.env.CLAUDE_CODE_ENTRYPOINT!==`claude-desktop`){let[e,t]=await Promise.all([o.getIsDocker(),Ge.hasInternetAccess()]),n=o.getIsBubblewrapSandbox(),r=process.env.IS_SANDBOX===`1`;(!(e||n||r)||t)&&(console.error(`--dangerously-skip-permissions can only be used in Docker/sandbox containers with no internet access but got Docker: ${e}, Bubblewrap: ${n}, IS_SANDBOX: ${r}, hasInternet: ${t}`),process.exit(1))}}let m=Je();m.lastCost!==void 0&&m.lastDuration!==void 0&&J(`tengu_exit`,{last_session_cost:m.lastCost,last_session_api_duration:m.lastAPIDuration,last_session_tool_duration:m.lastToolDuration,last_session_duration:m.lastDuration,last_session_lines_added:m.lastLinesAdded,last_session_lines_removed:m.lastLinesRemoved,last_session_total_input_tokens:m.lastTotalInputTokens,last_session_total_output_tokens:m.lastTotalOutputTokens,last_session_total_cache_creation_input_tokens:m.lastTotalCacheCreationInputTokens,last_session_total_cache_read_input_tokens:m.lastTotalCacheReadInputTokens,last_session_fps_average:m.lastFpsAverage,last_session_fps_low_1_pct:m.lastFpsLow1Pct,last_session_id:m.lastSessionId,...m.lastSessionMetrics})}export{St as setup};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{H as t,L as n,R as r,V as i,z as a}from"./loadAgentsDir-DlPbtIsS.js";import{in as o}from"./prompt-mM79EGnT.js";function s(e){return e===`projectSettings`||e===`policySettings`||e===`command`}function c(e){return t(e)}function l(e,t,n){let r=c(t.source),i=c(n.source),a=t.ruleValue.toolName;return e===`deny`?`Remove the "${a}" deny rule from ${r}, or remove the specific allow rule from ${i}`:`Remove the "${a}" ask rule from ${r}, or remove the specific allow rule from ${i}`}function u(e,t,n){let{toolName:r,ruleContent:i}=e.ruleValue;if(i===void 0)return{shadowed:!1};let a=t.find(e=>e.ruleValue.toolName===r&&e.ruleValue.ruleContent===void 0);return!a||r===`Bash`&&n.sandboxAutoAllowEnabled&&!s(a.source)?{shadowed:!1}:{shadowed:!0,shadowedBy:a,shadowType:`ask`}}function d(e,t){let{toolName:n,ruleContent:r}=e.ruleValue;if(r===void 0)return{shadowed:!1};let i=t.find(e=>e.ruleValue.toolName===n&&e.ruleValue.ruleContent===void 0);return i?{shadowed:!0,shadowedBy:i,shadowType:`deny`}:{shadowed:!1}}function f(e,t){let i=[],o=n(e),s=r(e),f=a(e);for(let e of o){let n=d(e,f);if(n.shadowed){let t=c(n.shadowedBy.source);i.push({rule:e,reason:`Blocked by "${n.shadowedBy.ruleValue.toolName}" deny rule (from ${t})`,shadowedBy:n.shadowedBy,shadowType:`deny`,fix:l(`deny`,n.shadowedBy,e)});continue}let r=u(e,s,t);if(r.shadowed){let t=c(r.shadowedBy.source);i.push({rule:e,reason:`Shadowed by "${r.shadowedBy.ruleValue.toolName}" ask rule (from ${t})`,shadowedBy:r.shadowedBy,shadowType:`ask`,fix:l(`ask`,r.shadowedBy,e)})}}return i}var p=e((()=>{o(),i()}));export{p as n,f as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{H as t,L as n,R as r,V as i,z as a}from"./loadAgentsDir-B0Anodo0.js";import{in as o}from"./prompt-CJ1l3XXk.js";function s(e){return e===`projectSettings`||e===`policySettings`||e===`command`}function c(e){return t(e)}function l(e,t,n){let r=c(t.source),i=c(n.source),a=t.ruleValue.toolName;return e===`deny`?`Remove the "${a}" deny rule from ${r}, or remove the specific allow rule from ${i}`:`Remove the "${a}" ask rule from ${r}, or remove the specific allow rule from ${i}`}function u(e,t,n){let{toolName:r,ruleContent:i}=e.ruleValue;if(i===void 0)return{shadowed:!1};let a=t.find(e=>e.ruleValue.toolName===r&&e.ruleValue.ruleContent===void 0);return!a||r===`Bash`&&n.sandboxAutoAllowEnabled&&!s(a.source)?{shadowed:!1}:{shadowed:!0,shadowedBy:a,shadowType:`ask`}}function d(e,t){let{toolName:n,ruleContent:r}=e.ruleValue;if(r===void 0)return{shadowed:!1};let i=t.find(e=>e.ruleValue.toolName===n&&e.ruleValue.ruleContent===void 0);return i?{shadowed:!0,shadowedBy:i,shadowType:`deny`}:{shadowed:!1}}function f(e,t){let i=[],o=n(e),s=r(e),f=a(e);for(let e of o){let n=d(e,f);if(n.shadowed){let t=c(n.shadowedBy.source);i.push({rule:e,reason:`Blocked by "${n.shadowedBy.ruleValue.toolName}" deny rule (from ${t})`,shadowedBy:n.shadowedBy,shadowType:`deny`,fix:l(`deny`,n.shadowedBy,e)});continue}let r=u(e,s,t);if(r.shadowed){let t=c(r.shadowedBy.source);i.push({rule:e,reason:`Shadowed by "${r.shadowedBy.ruleValue.toolName}" ask rule (from ${t})`,shadowedBy:r.shadowedBy,shadowType:`ask`,fix:l(`ask`,r.shadowedBy,e)})}}return i}var p=e((()=>{o(),i()}));export{p as n,f as t};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Gs as t,HS as n,PS as r,Us as i,Yi as a,Yx as o,pS as s}from"./loadAgentsDir-DlPbtIsS.js";function c(e){let t=[],n=e.matchAll(d);for(let e of n)e.index!==void 0&&t.push({word:e[0],start:e.index,end:e.index+e[0].length});return t}async function l({question:e,cacheSafeParams:n}){let r=await t({promptMessages:[s({content:`<system-reminder>This is a side question from the user. You must answer this question directly in a single response.
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Gs as t,HS as n,PS as r,Us as i,Yi as a,Yx as o,pS as s}from"./loadAgentsDir-B0Anodo0.js";function c(e){let t=[],n=e.matchAll(d);for(let e of n)e.index!==void 0&&t.push({word:e[0],start:e.index,end:e.index+e[0].length});return t}async function l({question:e,cacheSafeParams:n}){let r=await t({promptMessages:[s({content:`<system-reminder>This is a side question from the user. You must answer this question directly in a single response.
2
2
 
3
3
  IMPORTANT CONTEXT:
4
4
  - You are a separate, lightweight agent spawned to answer this one question
@@ -0,0 +1 @@
1
+ import{t as e}from"./sinks-De-B1lPQ.js";export{e as initSinks};
@@ -1 +1 @@
1
- import{n as e,t}from"./axios-DaWTGg7G.js";import{It as n,st as r}from"./state-B4jiUise.js";import{$ as i,C as a,c as o,et as s,f as c,i as l,nt as u,rt as d,u as f,x as p}from"./debug-Bglx1aTu.js";import{_ as m,o as h,r as g,t as _,v}from"./log-D2TIwHBV.js";import{i as y,n as b,t as x}from"./analytics-DJobLaWP.js";import{a as S,n as C,o as w}from"./firstPartyEventLogger-M6UMli2c.js";import{r as T,t as E}from"./datadog-BPuGcxxC.js";import{dirname as D,join as O}from"path";t(),n(),d(),v(),i(),l(),c(),h(),p();var k=g(new Date);function A(){return O(m.errors(),`${k}.jsonl`)}function j(e){return O(m.mcpLogs(e),`${k}.jsonl`)}function M(e){let t=u(e);return{write(e){t.write(`${a(e)}\n`)},flush:t.flush,dispose:t.dispose}}var N=new Map;function P(e){let t=N.get(e);if(!t){let n=D(e);t=M({writeFn:t=>{try{f().appendFileSync(e,t)}catch{f().mkdirSync(n),f().appendFileSync(e,t)}},flushIntervalMs:1e3,maxBufferSize:50}),N.set(e,t),s(async()=>t?.dispose())}return t}function F(e,t){let n={timestamp:new Date().toISOString(),...t,cwd:f().cwd(),userType:process.env.USER_TYPE,sessionId:r(),version:`0.0.23`};P(e).write(n)}function I(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`){let t=e;if(typeof t.message==`string`)return t.message;if(typeof t.error==`object`&&t.error&&`message`in t.error&&typeof t.error.message==`string`)return t.error.message}}function L(t){let n=t.stack||t.message,r=``;if(e.isAxiosError(t)&&t.config?.url){let e=[`url=${t.config.url}`];t.response?.status!==void 0&&e.push(`status=${t.response.status}`);let n=I(t.response?.data);n&&e.push(`body=${n}`),r=`[${e.join(`,`)}] `}o(`${t.name}: ${r}${n}`,{level:`error`}),F(A(),{error:`${r}${n}`})}function R(e,t){o(`MCP server "${e}" ${t}`,{level:`error`});let n=j(e),i={error:t instanceof Error?t.stack||t.message:String(t),timestamp:new Date().toISOString(),sessionId:r(),cwd:f().cwd()};P(n).write(i)}function z(e,t){o(`MCP server "${e}": ${t}`);let n=j(e),i={debug:t,timestamp:new Date().toISOString(),sessionId:r(),cwd:f().cwd()};P(n).write(i)}function B(){_({logError:L,logMCPError:R,logMCPDebug:z,getErrorsPath:A,getMCPLogsPath:j}),o(`Error log sink initialized`)}E(),C(),b();function V(){return!1}function H(e,t){let n=w(e);if(n===0)return;let r=n===null?t:{...t,sample_rate:n};V()&&T(e,y(r)),S(e,r)}function U(e,t){return H(e,t),Promise.resolve()}function W(){x({logEvent:H,logEventAsync:U})}function G(){B(),W()}export{G as t};
1
+ import{n as e,t}from"./axios-DaWTGg7G.js";import{It as n,st as r}from"./state-B4jiUise.js";import{$ as i,C as a,c as o,et as s,f as c,i as l,nt as u,rt as d,u as f,x as p}from"./debug-Bglx1aTu.js";import{_ as m,o as h,r as g,t as _,v}from"./log-D2TIwHBV.js";import{i as y,n as b,t as x}from"./analytics-DJobLaWP.js";import{a as S,n as C,o as w}from"./firstPartyEventLogger-QmjjQmgt.js";import{r as T,t as E}from"./datadog-Cu3s7P48.js";import{dirname as D,join as O}from"path";t(),n(),d(),v(),i(),l(),c(),h(),p();var k=g(new Date);function A(){return O(m.errors(),`${k}.jsonl`)}function j(e){return O(m.mcpLogs(e),`${k}.jsonl`)}function M(e){let t=u(e);return{write(e){t.write(`${a(e)}\n`)},flush:t.flush,dispose:t.dispose}}var N=new Map;function P(e){let t=N.get(e);if(!t){let n=D(e);t=M({writeFn:t=>{try{f().appendFileSync(e,t)}catch{f().mkdirSync(n),f().appendFileSync(e,t)}},flushIntervalMs:1e3,maxBufferSize:50}),N.set(e,t),s(async()=>t?.dispose())}return t}function F(e,t){let n={timestamp:new Date().toISOString(),...t,cwd:f().cwd(),userType:process.env.USER_TYPE,sessionId:r(),version:`0.0.24`};P(e).write(n)}function I(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`){let t=e;if(typeof t.message==`string`)return t.message;if(typeof t.error==`object`&&t.error&&`message`in t.error&&typeof t.error.message==`string`)return t.error.message}}function L(t){let n=t.stack||t.message,r=``;if(e.isAxiosError(t)&&t.config?.url){let e=[`url=${t.config.url}`];t.response?.status!==void 0&&e.push(`status=${t.response.status}`);let n=I(t.response?.data);n&&e.push(`body=${n}`),r=`[${e.join(`,`)}] `}o(`${t.name}: ${r}${n}`,{level:`error`}),F(A(),{error:`${r}${n}`})}function R(e,t){o(`MCP server "${e}" ${t}`,{level:`error`});let n=j(e),i={error:t instanceof Error?t.stack||t.message:String(t),timestamp:new Date().toISOString(),sessionId:r(),cwd:f().cwd()};P(n).write(i)}function z(e,t){o(`MCP server "${e}": ${t}`);let n=j(e),i={debug:t,timestamp:new Date().toISOString(),sessionId:r(),cwd:f().cwd()};P(n).write(i)}function B(){_({logError:L,logMCPError:R,logMCPDebug:z,getErrorsPath:A,getMCPLogsPath:j}),o(`Error log sink initialized`)}E(),C(),b();function V(){return!1}function H(e,t){let n=w(e);if(n===0)return;let r=n===null?t:{...t,sample_rate:n};V()&&T(e,y(r)),S(e,r)}function U(e,t){return H(e,t),Promise.resolve()}function W(){x({logEvent:H,logEventAsync:U})}function G(){B(),W()}export{G as t};
@@ -1 +1 @@
1
- import{$s as e,Aw as t,Bf as n,Ci as r,Dt as i,Gi as a,Hi as o,Hm as s,Jy as ee,Ki as te,Ln as ne,Mt as re,Nb as ie,Ni as ae,Pb as c,Sw as oe,Um as se,Wi as l,Xr as ce,Ys as u,Zr as d,_r as f,bm as p,dn as le,es as ue,im as de,kw as m,m_ as h,mn as fe,nm as pe,o_ as me,oi as g,qy as he,ri as ge,s_ as _e,ts as ve,up as ye,vt as _,wi as v,xm as y,xt as b,xw as x,y_ as S,zf as C,zr as w}from"./loadAgentsDir-DlPbtIsS.js";import{Dn as T,It as E,Jn as D,W as O,Wn as k,bn as A,h as j,qn as M,st as N,xn as P}from"./state-B4jiUise.js";import{n as be,t as F}from"./cwd-Pa83R95t.js";import{$ as xe,c as I,et as L,f as Se,i as R,u as Ce}from"./debug-Bglx1aTu.js";import{n as we,r as Te}from"./analytics-DJobLaWP.js";import{_ as Ee,d as De}from"./model-BwBG0V1u.js";import{Gt as Oe}from"./prompt-mM79EGnT.js";import*as z from"path";import{dirname as ke}from"path";E(),se(),me(),Oe(),y(),S(),ye(),u(),be(),R(),de(),De(),t(),ie(),f(),he(),n(),b();function Ae(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.type!==`assistant`)continue;let r=n.message.content.find(e=>e.type===`tool_use`&&e.name===`TodoWrite`);if(r?.type!==`tool_use`)continue;let i=r.input;if(typeof i!=`object`||!i)return[];let a=C().safeParse(i.todos);return a.success?a.data:[]}return[]}function je(e,t){if(e.fileHistorySnapshots&&e.fileHistorySnapshots.length>0&&pe(e.fileHistorySnapshots,e=>{t(t=>({...t,fileHistory:e}))}),!ee()&&e.messages&&e.messages.length>0){let n=Ae(e.messages);if(n.length>0){let e=N();t(t=>({...t,todos:{...t.todos,[e]:n}}))}}}function B(e,t){if(!(!e&&!t))return{name:e??``,color:t==="default"?void 0:t}}function V(e,t,n){if(t)return{agentDefinition:t,agentType:void 0};if(!e)return P(void 0),{agentDefinition:void 0,agentType:void 0};let r=n.activeAgents.find(t=>t.agentType===e);return r?(P(r.agentType),!O()&&r.model&&r.model!==`inherit`&&A(Ee(r.model)),{agentDefinition:r,agentType:r.agentType}):(I(`Resumed session had agent "${e}" but it is no longer available. Using default behavior.`),P(void 0),{agentDefinition:void 0,agentType:void 0})}function H(e){let t=_();if(t){g(t);return}if(e){try{process.chdir(e.worktreePath)}catch{g(null);return}c(e.worktreePath),T(F()),i(e),h(),s(),m.cache.clear?.()}}function Me(){let e=_();if(e){i(null),h(),s(),m.cache.clear?.();try{process.chdir(e.originalCwd)}catch{return}c(e.originalCwd),T(F())}}async function Ne(t,n,r){if(n.forkSession)t.contentReplacements?.length&&await w(t.contentReplacements);else{let e=n.sessionIdOverride??t.sessionId;e&&(k(p(e),n.transcriptPath?ke(n.transcriptPath):null),await ce(),_e(e))}d(n.forkSession?{...t,worktreeSession:void 0}:t),n.forkSession||(H(t.worktreeSession),ne());let{agentDefinition:i,agentType:a}=V(t.agentSetting,r.mainThreadAgentDefinition,r.agentDefinitions);ge(`normal`),n.includeAttribution;let o=B(t.agentName,t.agentColor);e(t.agentName);let s=r.agentDefinitions;return{messages:t.messages,fileHistorySnapshots:t.fileHistorySnapshots,contentReplacements:t.contentReplacements,agentName:t.agentName,agentColor:t.agentColor==="default"?void 0:t.agentColor,restoredAgentDef:i,initialState:{...r.initialState,...a&&{agent:a},...o&&{standaloneAgentContext:o},agentDefinitions:s}}}oe(),E(),ae(),we(),a(),ue(),xe(),R(),Se(),fe(),D();var Pe=1e3,Fe=500,Ie=300,Le=2e3,Re=typeof Bun<`u`,U=null,W=null,G=new Set,K=!1,q=!1,J=!1,Y=null,X=M(),Z=null;async function ze(){if(K||q)return;K=!0,J||(J=!0,te(()=>{r(),X.emit()}));let e=await Ve();e.length!==0&&(I(`Watching for changes in skill/command directories: ${e.join(`, `)}...`),U=x.watch(e,{persistent:!0,ignoreInitial:!0,depth:2,awaitWriteFinish:{stabilityThreshold:Z?.stabilityThreshold??Pe,pollInterval:Z?.pollInterval??Fe},ignored:(e,t)=>t&&!t.isFile()&&!t.isDirectory()?!0:e.split(z.sep).some(e=>e===`.git`),ignorePermissionErrors:!0,usePolling:Re,interval:Z?.chokidarInterval??Le,atomic:!0}),U.on(`add`,$),U.on(`change`,$),U.on(`unlink`,$),Y=L(async()=>{await Q()}))}function Q(){q=!0,Y&&(Y(),Y=null);let e=Promise.resolve();return U&&(e=U.close(),U=null),W&&(clearTimeout(W),W=null),G.clear(),X.clear(),e}var Be=X.subscribe;async function Ve(){let e=Ce(),t=[],n=l(`userSettings`,`skills`);if(n)try{await e.stat(n),t.push(n)}catch{}let r=l(`userSettings`,`commands`);if(r)try{await e.stat(r),t.push(r)}catch{}let i=l(`projectSettings`,`skills`);if(i)try{let n=z.resolve(i);await e.stat(n),t.push(n)}catch{}let a=l(`projectSettings`,`commands`);if(a)try{let n=z.resolve(a);await e.stat(n),t.push(n)}catch{}for(let n of j()){let r=z.join(n,`.workmate`,`skills`);try{await e.stat(r),t.push(r)}catch{}}return t}function $(e){I(`Detected skill change: ${e}`),Te(`tengu_skill_file_changed`,{source:`chokidar`}),He(e)}function He(e){G.add(e),W&&clearTimeout(W),W=setTimeout(async()=>{W=null;let e=[...G];if(G.clear(),le(await re(`skills`,e[0]))){I(`ConfigChange hook blocked skill reload (${e.length} paths)`);return}o(),v(),ve(),X.emit()},Z?.reloadDebounce??Ie)}async function Ue(e){U&&(await U.close(),U=null),W&&(clearTimeout(W),W=null),G.clear(),X.clear(),K=!1,q=!1,Z=e??null}var We={initialize:ze,dispose:Q,subscribe:Be,resetForTesting:Ue};export{V as a,Ne as i,B as n,je as o,Me as r,H as s,We as t};
1
+ import{$s as e,Aw as t,Bf as n,Ci as r,Dt as i,Gi as a,Hi as o,Hm as s,Jy as ee,Ki as te,Ln as ne,Mt as re,Nb as ie,Ni as ae,Pb as c,Sw as oe,Um as se,Wi as l,Xr as ce,Ys as u,Zr as d,_r as f,bm as p,dn as le,es as ue,im as de,kw as m,m_ as h,mn as fe,nm as pe,o_ as me,oi as g,qy as he,ri as ge,s_ as _e,ts as ve,up as ye,vt as _,wi as v,xm as y,xt as b,xw as x,y_ as S,zf as C,zr as w}from"./loadAgentsDir-B0Anodo0.js";import{Dn as T,It as E,Jn as D,W as O,Wn as k,bn as A,h as j,qn as M,st as N,xn as P}from"./state-B4jiUise.js";import{n as be,t as F}from"./cwd-Pa83R95t.js";import{$ as xe,c as I,et as L,f as Se,i as R,u as Ce}from"./debug-Bglx1aTu.js";import{n as we,r as Te}from"./analytics-DJobLaWP.js";import{_ as Ee,d as De}from"./model-BvQFFOf8.js";import{Gt as Oe}from"./prompt-CJ1l3XXk.js";import*as z from"path";import{dirname as ke}from"path";E(),se(),me(),Oe(),y(),S(),ye(),u(),be(),R(),de(),De(),t(),ie(),f(),he(),n(),b();function Ae(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.type!==`assistant`)continue;let r=n.message.content.find(e=>e.type===`tool_use`&&e.name===`TodoWrite`);if(r?.type!==`tool_use`)continue;let i=r.input;if(typeof i!=`object`||!i)return[];let a=C().safeParse(i.todos);return a.success?a.data:[]}return[]}function je(e,t){if(e.fileHistorySnapshots&&e.fileHistorySnapshots.length>0&&pe(e.fileHistorySnapshots,e=>{t(t=>({...t,fileHistory:e}))}),!ee()&&e.messages&&e.messages.length>0){let n=Ae(e.messages);if(n.length>0){let e=N();t(t=>({...t,todos:{...t.todos,[e]:n}}))}}}function B(e,t){if(!(!e&&!t))return{name:e??``,color:t==="default"?void 0:t}}function V(e,t,n){if(t)return{agentDefinition:t,agentType:void 0};if(!e)return P(void 0),{agentDefinition:void 0,agentType:void 0};let r=n.activeAgents.find(t=>t.agentType===e);return r?(P(r.agentType),!O()&&r.model&&r.model!==`inherit`&&A(Ee(r.model)),{agentDefinition:r,agentType:r.agentType}):(I(`Resumed session had agent "${e}" but it is no longer available. Using default behavior.`),P(void 0),{agentDefinition:void 0,agentType:void 0})}function H(e){let t=_();if(t){g(t);return}if(e){try{process.chdir(e.worktreePath)}catch{g(null);return}c(e.worktreePath),T(F()),i(e),h(),s(),m.cache.clear?.()}}function Me(){let e=_();if(e){i(null),h(),s(),m.cache.clear?.();try{process.chdir(e.originalCwd)}catch{return}c(e.originalCwd),T(F())}}async function Ne(t,n,r){if(n.forkSession)t.contentReplacements?.length&&await w(t.contentReplacements);else{let e=n.sessionIdOverride??t.sessionId;e&&(k(p(e),n.transcriptPath?ke(n.transcriptPath):null),await ce(),_e(e))}d(n.forkSession?{...t,worktreeSession:void 0}:t),n.forkSession||(H(t.worktreeSession),ne());let{agentDefinition:i,agentType:a}=V(t.agentSetting,r.mainThreadAgentDefinition,r.agentDefinitions);ge(`normal`),n.includeAttribution;let o=B(t.agentName,t.agentColor);e(t.agentName);let s=r.agentDefinitions;return{messages:t.messages,fileHistorySnapshots:t.fileHistorySnapshots,contentReplacements:t.contentReplacements,agentName:t.agentName,agentColor:t.agentColor==="default"?void 0:t.agentColor,restoredAgentDef:i,initialState:{...r.initialState,...a&&{agent:a},...o&&{standaloneAgentContext:o},agentDefinitions:s}}}oe(),E(),ae(),we(),a(),ue(),xe(),R(),Se(),fe(),D();var Pe=1e3,Fe=500,Ie=300,Le=2e3,Re=typeof Bun<`u`,U=null,W=null,G=new Set,K=!1,q=!1,J=!1,Y=null,X=M(),Z=null;async function ze(){if(K||q)return;K=!0,J||(J=!0,te(()=>{r(),X.emit()}));let e=await Ve();e.length!==0&&(I(`Watching for changes in skill/command directories: ${e.join(`, `)}...`),U=x.watch(e,{persistent:!0,ignoreInitial:!0,depth:2,awaitWriteFinish:{stabilityThreshold:Z?.stabilityThreshold??Pe,pollInterval:Z?.pollInterval??Fe},ignored:(e,t)=>t&&!t.isFile()&&!t.isDirectory()?!0:e.split(z.sep).some(e=>e===`.git`),ignorePermissionErrors:!0,usePolling:Re,interval:Z?.chokidarInterval??Le,atomic:!0}),U.on(`add`,$),U.on(`change`,$),U.on(`unlink`,$),Y=L(async()=>{await Q()}))}function Q(){q=!0,Y&&(Y(),Y=null);let e=Promise.resolve();return U&&(e=U.close(),U=null),W&&(clearTimeout(W),W=null),G.clear(),X.clear(),e}var Be=X.subscribe;async function Ve(){let e=Ce(),t=[],n=l(`userSettings`,`skills`);if(n)try{await e.stat(n),t.push(n)}catch{}let r=l(`userSettings`,`commands`);if(r)try{await e.stat(r),t.push(r)}catch{}let i=l(`projectSettings`,`skills`);if(i)try{let n=z.resolve(i);await e.stat(n),t.push(n)}catch{}let a=l(`projectSettings`,`commands`);if(a)try{let n=z.resolve(a);await e.stat(n),t.push(n)}catch{}for(let n of j()){let r=z.join(n,`.workmate`,`skills`);try{await e.stat(r),t.push(r)}catch{}}return t}function $(e){I(`Detected skill change: ${e}`),Te(`tengu_skill_file_changed`,{source:`chokidar`}),He(e)}function He(e){G.add(e),W&&clearTimeout(W),W=setTimeout(async()=>{W=null;let e=[...G];if(G.clear(),le(await re(`skills`,e[0]))){I(`ConfigChange hook blocked skill reload (${e.length} paths)`);return}o(),v(),ve(),X.emit()},Z?.reloadDebounce??Ie)}async function Ue(e){U&&(await U.close(),U=null),W&&(clearTimeout(W),W=null),G.clear(),X.clear(),K=!1,q=!1,Z=e??null}var We={initialize:ze,dispose:Q,subscribe:Be,resetForTesting:Ue};export{V as a,Ne as i,B as n,je as o,Me as r,H as s,We as t};
@@ -1,5 +1,5 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,n,s as r}from"./projectContext-DhtjLv3k.js";import{i,r as a}from"./instinctParser-Dt-lqnDe.js";import{c as o,o as s,s as c}from"./skillLifecycle-BMY2JGGG.js";import{dirname as l,join as u}from"node:path";import{existsSync as d}from"node:fs";import{createHash as f}from"node:crypto";import{mkdir as p,readFile as m,rename as h,writeFile as g}from"node:fs/promises";async function _(e){let t=e.prompt.trim();if(!t)throw Error(`Cannot record an empty skill gap`);let n=e.project??r(e.cwd),i=await A(n,e.rootDir),a=F(t),o=new Date().toISOString(),s=i.gaps[a],c={key:a,prompt:t,count:(s?.count??0)+1,draftHits:s?.draftHits??0,draftHitSessions:s?.draftHitSessions??[],status:s?.status??`pending`,sessionId:e.sessionId??`unknown-session`,cwd:e.cwd??n.cwd,projectId:n.projectId,projectName:n.projectName,recommendations:(e.recommendations??[]).slice(0,5).map(e=>({name:e.name,description:e.description,score:e.score})),createdAt:s?.createdAt??o,updatedAt:o,draft:s?.draft,active:s?.active};return c.status===`rejected`?(i.gaps[a]=c,await N(n,i,e.rootDir),c):(!c.draft&&C(c)&&(c.draft=await T(c,n),c.status=`draft`,await z()),c.draft&&!c.active&&w(c)&&(c.active=await E(c,n),c.status=`active`,await z()),i.gaps[a]=c,await N(n,i,e.rootDir),c)}async function v(e=r(),t){let n=await A(e,t);return Object.values(n.gaps).sort((e,t)=>e.key.localeCompare(t.key))}async function y(e,t=r(),n){let i=await A(t,n);for(let t of Object.values(i.gaps))if(t.draft?.skillPath===e)return t.key}async function b(e,t=r(),n,i=`unknown-session`){let a=await A(t,n),o=a.gaps[e];if(!o?.draft||o.active)return o;let s=o.draftHitSessions??[];if(s.includes(i))return o;let c=new Date().toISOString(),l={...o,draftHits:o.draftHits+1,draftHitSessions:[...s,i],updatedAt:c};return w(l)&&(l.active=await E(l,t),l.status=`active`,await z()),a.gaps[e]=l,await N(t,a,n),l}async function x(e,t=r(),n){let i=await A(t,n),a=i.gaps[e];if(!a)return;if(a.status===`rejected`||a.draft)return a;let o={...a,draft:await T(a,t),status:`draft`,updatedAt:new Date().toISOString()};return i.gaps[e]=o,await N(t,i,n),await z(),o}async function S(e,t=r(),n){let i=await A(t,n),a=i.gaps[e];if(!a)return;let o={...a,status:`rejected`,updatedAt:new Date().toISOString()};return i.gaps[e]=o,await N(t,i,n),o}function C(e){return e.count>=B}function w(e){return e.draft?e.count>=V||e.draftHits>=H:!1}async function T(e,t){let n=D(e,`pending`),r=u(t.projectRoot??t.cwd,`.workmate`,`skills`,`.drafts`),i=s([n],{cwd:t.projectRoot??t.cwd,outputRoot:r,scope:`project`,name:`draft-${I(e.prompt)}`,description:`Draft learned skill candidate. Promote after repeated evidence or explicit user correction.`}),a=u(i.outputPath,`SKILL.md`);return d(a)||await o({...i,content:i.content+`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,n,s as r}from"./projectContext-DhtjLv3k.js";import{i,r as a}from"./instinctParser-Dt-lqnDe.js";import{c as o,o as s,s as c}from"./skillLifecycle-Bnz_4wE5.js";import{dirname as l,join as u}from"node:path";import{existsSync as d}from"node:fs";import{createHash as f}from"node:crypto";import{mkdir as p,readFile as m,rename as h,writeFile as g}from"node:fs/promises";async function _(e){let t=e.prompt.trim();if(!t)throw Error(`Cannot record an empty skill gap`);let n=e.project??r(e.cwd),i=await A(n,e.rootDir),a=F(t),o=new Date().toISOString(),s=i.gaps[a],c={key:a,prompt:t,count:(s?.count??0)+1,draftHits:s?.draftHits??0,draftHitSessions:s?.draftHitSessions??[],status:s?.status??`pending`,sessionId:e.sessionId??`unknown-session`,cwd:e.cwd??n.cwd,projectId:n.projectId,projectName:n.projectName,recommendations:(e.recommendations??[]).slice(0,5).map(e=>({name:e.name,description:e.description,score:e.score})),createdAt:s?.createdAt??o,updatedAt:o,draft:s?.draft,active:s?.active};return c.status===`rejected`?(i.gaps[a]=c,await N(n,i,e.rootDir),c):(!c.draft&&C(c)&&(c.draft=await T(c,n),c.status=`draft`,await z()),c.draft&&!c.active&&w(c)&&(c.active=await E(c,n),c.status=`active`,await z()),i.gaps[a]=c,await N(n,i,e.rootDir),c)}async function v(e=r(),t){let n=await A(e,t);return Object.values(n.gaps).sort((e,t)=>e.key.localeCompare(t.key))}async function y(e,t=r(),n){let i=await A(t,n);for(let t of Object.values(i.gaps))if(t.draft?.skillPath===e)return t.key}async function b(e,t=r(),n,i=`unknown-session`){let a=await A(t,n),o=a.gaps[e];if(!o?.draft||o.active)return o;let s=o.draftHitSessions??[];if(s.includes(i))return o;let c=new Date().toISOString(),l={...o,draftHits:o.draftHits+1,draftHitSessions:[...s,i],updatedAt:c};return w(l)&&(l.active=await E(l,t),l.status=`active`,await z()),a.gaps[e]=l,await N(t,a,n),l}async function x(e,t=r(),n){let i=await A(t,n),a=i.gaps[e];if(!a)return;if(a.status===`rejected`||a.draft)return a;let o={...a,draft:await T(a,t),status:`draft`,updatedAt:new Date().toISOString()};return i.gaps[e]=o,await N(t,i,n),await z(),o}async function S(e,t=r(),n){let i=await A(t,n),a=i.gaps[e];if(!a)return;let o={...a,status:`rejected`,updatedAt:new Date().toISOString()};return i.gaps[e]=o,await N(t,i,n),o}function C(e){return e.count>=B}function w(e){return e.draft?e.count>=V||e.draftHits>=H:!1}async function T(e,t){let n=D(e,`pending`),r=u(t.projectRoot??t.cwd,`.workmate`,`skills`,`.drafts`),i=s([n],{cwd:t.projectRoot??t.cwd,outputRoot:r,scope:`project`,name:`draft-${I(e.prompt)}`,description:`Draft learned skill candidate. Promote after repeated evidence or explicit user correction.`}),a=u(i.outputPath,`SKILL.md`);return d(a)||await o({...i,content:i.content+`
2
2
  ## Promotion Rule
3
3
 
4
4
  Do not move this draft into active skills until the same gap repeats or the user explicitly confirms this should become reusable.
5
- `}),{type:`draft`,name:i.name,skillPath:a}}async function E(e,t){let n=s([D(e,`active`)],{cwd:t.projectRoot??t.cwd,scope:`project`,name:I(e.prompt),description:O(e.prompt)}),r=u(n.outputPath,`SKILL.md`);return d(r)||await o(n),{type:`active`,name:n.name,skillPath:r}}function D(e,t){return a({trigger:`When the user asks for ${L(e.prompt,120)}`,action:O(e.prompt),confidence:t===`active`?.82:.55,domain:k(e.prompt),source:`session-observation`,scope:`project`,projectId:e.projectId,projectName:e.projectName,evidence:[`Skill gap prompt: ${L(e.prompt,180)}`,`No high-confidence active skill was auto-loaded.`,`Observed ${e.count} time(s).`],status:t})}function O(e){return/feature\s*\(|feature flag|flag_name|stub|no-op|noop|最小实现/i.test(e)?`Audit feature flags by scanning feature() call sites, excluding generated/dependency noise, classifying each candidate as stub, shell, MVP, or thin-toggle, and writing an evidence-backed document.`:/skill|技能|学习|进化|evolve|learning/i.test(e)?`Run skill discovery first; auto-load only high-confidence matching skills; record a skill gap when none match; promote repeated or corrected gaps into learned skills.`:/test|测试|stub|调用链|参数/i.test(e)?`Infer tests from existing files, parameters, exports, and call chains before simplifying mocks or inventing behavior.`:`Reuse the workflow learned from this prompt: ${L(e,180)}.`}function k(e){let t=e.toLowerCase();return/test|测试|stub|fixture|断言/.test(t)?`testing`:/error|bug|fix|失败|错误|修复|debug/.test(t)?`debugging`:/security|安全|漏洞|secret|token/.test(t)?`security`:/git|commit|branch|pr\b/.test(t)?`git`:/style|lint|format|命名|规范/.test(t)?`code-style`:`workflow`}async function A(e,t){let n=P(e,t),r;try{r=await m(n,`utf8`)}catch(e){if(e.code===`ENOENT`)return{version:1,gaps:{}};throw e}try{return j(JSON.parse(r))}catch{let e=`${n}.corrupt-${Date.now()}`;try{await g(e,r,`utf8`)}catch{}return{version:1,gaps:{}}}}function j(e){let t={};for(let[n,r]of Object.entries(e.gaps??{})){let e=r,i=typeof e.draftHits==`number`&&Number.isFinite(e.draftHits)?e.draftHits:0,a=typeof e.count==`number`?e.count:1,o=M(e.status),s=!!e.draft,c=!!e.active,l=o;l===`draft`&&a<B&&!s&&(l=`pending`),l===`active`&&!c&&(l=s?`draft`:`pending`);let u=Array.isArray(e.draftHitSessions)?e.draftHitSessions.filter(e=>typeof e==`string`):[];t[n]={...r,count:a,draftHits:i,draftHitSessions:u,status:l}}return{version:1,gaps:t}}function M(e){return e===`pending`||e===`draft`||e===`active`||e===`rejected`?e:`pending`}async function N(e,t,n){let r=P(e,n);await p(l(r),{recursive:!0});let i=`${r}.tmp-${process.pid}-${Date.now()}`;await g(i,`${JSON.stringify(t,null,2)}\n`,`utf8`),await h(i,r)}function P(e,t){return u(t?e.projectId===`global`?u(t,`global`):u(t,`projects`,e.projectId):n(e.projectId),`skill-gaps.json`)}function F(e){return`${I(e)}-${R(e).slice(0,8)}`}function I(e){let t=e.replaceAll(`技能`,` skill `).replaceAll(`学习`,` learning `).replaceAll(`进化`,` evolution `).replaceAll(`测试`,` testing `).replaceAll(`最小实现`,` minimal implementation `).toLowerCase(),n=new Set([`the`,`and`,`for`,`with`,`this`,`that`,`user`,`about`,`feature`,`flag`,`name`]);return((t.match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(e=>!n.has(e)).slice(0,5).join(`-`)||`learned-gap`).slice(0,54).replace(/-+$/g,``)}function L(e,t){return e.replace(/\s+/g,` `).trim().slice(0,t)}function R(e){return f(`sha1`).update(e).digest(`hex`)}async function z(){try{let{clearCommandsCache:e}=await import(`./commands-QepeBbFn.js`);e()}catch{}}var B,V,H;e((()=>{i(),t(),c(),B=2,V=4,H=2}))();export{y as findGapKeyByDraftPath,x as promoteGapToDraft,v as readSkillGaps,b as recordDraftHit,_ as recordSkillGap,S as rejectSkillGap,w as shouldPromoteToActive,C as shouldPromoteToDraft};
5
+ `}),{type:`draft`,name:i.name,skillPath:a}}async function E(e,t){let n=s([D(e,`active`)],{cwd:t.projectRoot??t.cwd,scope:`project`,name:I(e.prompt),description:O(e.prompt)}),r=u(n.outputPath,`SKILL.md`);return d(r)||await o(n),{type:`active`,name:n.name,skillPath:r}}function D(e,t){return a({trigger:`When the user asks for ${L(e.prompt,120)}`,action:O(e.prompt),confidence:t===`active`?.82:.55,domain:k(e.prompt),source:`session-observation`,scope:`project`,projectId:e.projectId,projectName:e.projectName,evidence:[`Skill gap prompt: ${L(e.prompt,180)}`,`No high-confidence active skill was auto-loaded.`,`Observed ${e.count} time(s).`],status:t})}function O(e){return/feature\s*\(|feature flag|flag_name|stub|no-op|noop|最小实现/i.test(e)?`Audit feature flags by scanning feature() call sites, excluding generated/dependency noise, classifying each candidate as stub, shell, MVP, or thin-toggle, and writing an evidence-backed document.`:/skill|技能|学习|进化|evolve|learning/i.test(e)?`Run skill discovery first; auto-load only high-confidence matching skills; record a skill gap when none match; promote repeated or corrected gaps into learned skills.`:/test|测试|stub|调用链|参数/i.test(e)?`Infer tests from existing files, parameters, exports, and call chains before simplifying mocks or inventing behavior.`:`Reuse the workflow learned from this prompt: ${L(e,180)}.`}function k(e){let t=e.toLowerCase();return/test|测试|stub|fixture|断言/.test(t)?`testing`:/error|bug|fix|失败|错误|修复|debug/.test(t)?`debugging`:/security|安全|漏洞|secret|token/.test(t)?`security`:/git|commit|branch|pr\b/.test(t)?`git`:/style|lint|format|命名|规范/.test(t)?`code-style`:`workflow`}async function A(e,t){let n=P(e,t),r;try{r=await m(n,`utf8`)}catch(e){if(e.code===`ENOENT`)return{version:1,gaps:{}};throw e}try{return j(JSON.parse(r))}catch{let e=`${n}.corrupt-${Date.now()}`;try{await g(e,r,`utf8`)}catch{}return{version:1,gaps:{}}}}function j(e){let t={};for(let[n,r]of Object.entries(e.gaps??{})){let e=r,i=typeof e.draftHits==`number`&&Number.isFinite(e.draftHits)?e.draftHits:0,a=typeof e.count==`number`?e.count:1,o=M(e.status),s=!!e.draft,c=!!e.active,l=o;l===`draft`&&a<B&&!s&&(l=`pending`),l===`active`&&!c&&(l=s?`draft`:`pending`);let u=Array.isArray(e.draftHitSessions)?e.draftHitSessions.filter(e=>typeof e==`string`):[];t[n]={...r,count:a,draftHits:i,draftHitSessions:u,status:l}}return{version:1,gaps:t}}function M(e){return e===`pending`||e===`draft`||e===`active`||e===`rejected`?e:`pending`}async function N(e,t,n){let r=P(e,n);await p(l(r),{recursive:!0});let i=`${r}.tmp-${process.pid}-${Date.now()}`;await g(i,`${JSON.stringify(t,null,2)}\n`,`utf8`),await h(i,r)}function P(e,t){return u(t?e.projectId===`global`?u(t,`global`):u(t,`projects`,e.projectId):n(e.projectId),`skill-gaps.json`)}function F(e){return`${I(e)}-${R(e).slice(0,8)}`}function I(e){let t=e.replaceAll(`技能`,` skill `).replaceAll(`学习`,` learning `).replaceAll(`进化`,` evolution `).replaceAll(`测试`,` testing `).replaceAll(`最小实现`,` minimal implementation `).toLowerCase(),n=new Set([`the`,`and`,`for`,`with`,`this`,`that`,`user`,`about`,`feature`,`flag`,`name`]);return((t.match(/[a-z0-9][a-z0-9_-]{2,}/g)??[]).filter(e=>!n.has(e)).slice(0,5).join(`-`)||`learned-gap`).slice(0,54).replace(/-+$/g,``)}function L(e,t){return e.replace(/\s+/g,` `).trim().slice(0,t)}function R(e){return f(`sha1`).update(e).digest(`hex`)}async function z(){try{let{clearCommandsCache:e}=await import(`./commands-CVCpJo7M.js`);e()}catch{}}var B,V,H;e((()=>{i(),t(),c(),B=2,V=4,H=2}))();export{y as findGapKeyByDraftPath,x as promoteGapToDraft,v as readSkillGaps,b as recordDraftHit,_ as recordSkillGap,S as rejectSkillGap,w as shouldPromoteToActive,C as shouldPromoteToDraft};
@@ -1,6 +1,6 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-DfkgIdYf.js";import{o as r,t as i}from"./localSearch-CK-sFzPm.js";import{l as a,u as o}from"./instinctParser-Dt-lqnDe.js";import{basename as s,dirname as c,join as l}from"node:path";import{existsSync as u}from"node:fs";import{mkdir as d,readFile as f,readdir as p,rename as m,rm as ee,writeFile as h}from"node:fs/promises";function g(e){return e.length!==0&&e.reduce((e,t)=>e+t.confidence,0)/e.length>=a().minConfidence}function te(e){let t=e[0]?.domain??`project`,n=b[t],r=new Set;for(let t of e){for(let e of`${t.trigger} ${t.action}`.toLowerCase().split(/[^a-z0-9]+/))if(y(e)&&r.add(e),r.size>=5)break;if(r.size>=5)break}let i=_([n,...r].join(`-`));return v(i)?`${n}-learned-pattern`:i}function _(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,64).replace(/-$/g,``)||`learned-skill`}function v(e){return x.has(e)}function y(e){return e.length>2&&![`when`,`with`,`this`,`that`,`user`,`project`,`prefer`,`avoid`,`use`,`using`,`the`,`and`,`for`].includes(e)}var b,x,S=e((()=>{o(),b={workflow:`workflow`,testing:`testing`,debugging:`debugging`,"code-style":`style`,security:`security`,git:`git`,project:`project`},x=new Set([`learned-skill`,`better-skill`,`new-skill`,`project-skill`,`workflow-skill`])}));function C(e,t){if(e.length===0)throw Error(`Cannot generate a skill draft without instincts`);let n=t?.scope??e[0]?.scope??`project`,r=t?.name?_(t.name):E(e),i=e.reduce((e,t)=>e+t.confidence,0)/e.length,a=t?.description??D(e),o=re(r,n,t),s=O({name:r,description:a,confidence:i,instincts:e});return{name:r,description:a,scope:n,sourceInstinctIds:e.map(e=>e.id),confidence:Number(i.toFixed(2)),content:s,outputPath:o}}async function w(e,t,n){let r=C(e,t),i=await P(`skill`,r,n);for(let t of i){let n=ie(r,t);if(n>=.8)return{action:`append-evidence`,target:t,overlap:n,appendedPath:await ne(t,e)}}return{action:`create`,draft:r}}async function ne(e,t){let n=await f(e.path,`utf8`).catch(()=>e.content);if(Buffer.byteLength(n,`utf8`)>=M)return e.path;let r=t.flatMap(e=>e.evidence.map(e=>`- ${e}`)),a=r.slice(0,A);a.length<r.length&&a.push(`- [... ${r.length-a.length} more evidence entries omitted]`);let o=[``,`## Learned evidence (${new Date().toISOString()})`,``,...a,``].join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-DfkgIdYf.js";import{o as r,t as i}from"./localSearch-BxLYi6w_.js";import{l as a,u as o}from"./instinctParser-Dt-lqnDe.js";import{basename as s,dirname as c,join as l}from"node:path";import{existsSync as u}from"node:fs";import{mkdir as d,readFile as f,readdir as p,rename as m,rm as ee,writeFile as h}from"node:fs/promises";function g(e){return e.length!==0&&e.reduce((e,t)=>e+t.confidence,0)/e.length>=a().minConfidence}function te(e){let t=e[0]?.domain??`project`,n=b[t],r=new Set;for(let t of e){for(let e of`${t.trigger} ${t.action}`.toLowerCase().split(/[^a-z0-9]+/))if(y(e)&&r.add(e),r.size>=5)break;if(r.size>=5)break}let i=_([n,...r].join(`-`));return v(i)?`${n}-learned-pattern`:i}function _(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,64).replace(/-$/g,``)||`learned-skill`}function v(e){return x.has(e)}function y(e){return e.length>2&&![`when`,`with`,`this`,`that`,`user`,`project`,`prefer`,`avoid`,`use`,`using`,`the`,`and`,`for`].includes(e)}var b,x,S=e((()=>{o(),b={workflow:`workflow`,testing:`testing`,debugging:`debugging`,"code-style":`style`,security:`security`,git:`git`,project:`project`},x=new Set([`learned-skill`,`better-skill`,`new-skill`,`project-skill`,`workflow-skill`])}));function C(e,t){if(e.length===0)throw Error(`Cannot generate a skill draft without instincts`);let n=t?.scope??e[0]?.scope??`project`,r=t?.name?_(t.name):E(e),i=e.reduce((e,t)=>e+t.confidence,0)/e.length,a=t?.description??D(e),o=re(r,n,t),s=O({name:r,description:a,confidence:i,instincts:e});return{name:r,description:a,scope:n,sourceInstinctIds:e.map(e=>e.id),confidence:Number(i.toFixed(2)),content:s,outputPath:o}}async function w(e,t,n){let r=C(e,t),i=await P(`skill`,r,n);for(let t of i){let n=ie(r,t);if(n>=.8)return{action:`append-evidence`,target:t,overlap:n,appendedPath:await ne(t,e)}}return{action:`create`,draft:r}}async function ne(e,t){let n=await f(e.path,`utf8`).catch(()=>e.content);if(Buffer.byteLength(n,`utf8`)>=M)return e.path;let r=t.flatMap(e=>e.evidence.map(e=>`- ${e}`)),a=r.slice(0,A);a.length<r.length&&a.push(`- [... ${r.length-a.length} more evidence entries omitted]`);let o=[``,`## Learned evidence (${new Date().toISOString()})`,``,...a,``].join(`
2
2
  `),s=n.endsWith(`
3
- `)?n+o:`${n}\n${o}`,c=Buffer.byteLength(s,`utf8`)>M?s.slice(0,M):s;return await h(e.path,c,`utf8`),i(),e.path}async function T(e){await d(e.outputPath,{recursive:!0});let t=l(e.outputPath,`SKILL.md`);await h(t,e.content,`utf8`),i();try{let{clearCommandsCache:e}=await import(`./commands-QepeBbFn.js`);e()}catch{}return t}function re(e,n,r){return r?.outputRoot?l(r.outputRoot,e):n===`project`?l(r?.cwd??process.cwd(),`.workmate`,`skills`,e):l(r?.globalSkillsDir??l(t(),`skills`),e)}function E(e){return te(e)}function D(e){let t=(e[0]?.action??`Apply a learned project pattern`).replace(/\s+/g,` `).slice(0,120);return t.length>0?t:`Apply learned project patterns`}function O(e){let{name:t,description:n,confidence:r,instincts:i}=e;return[`---`,`name: ${t}`,`description: ${JSON.stringify(n)}`,`origin: skill-learning`,`confidence: ${Number(r.toFixed(2))}`,`evolved_from: [${i.map(e=>JSON.stringify(e.id)).join(`, `)}]`,`---`,``,`# ${k(t)}`,``,`## Trigger`,``,i.map(e=>`- ${e.trigger}`).join(`
3
+ `)?n+o:`${n}\n${o}`,c=Buffer.byteLength(s,`utf8`)>M?s.slice(0,M):s;return await h(e.path,c,`utf8`),i(),e.path}async function T(e){await d(e.outputPath,{recursive:!0});let t=l(e.outputPath,`SKILL.md`);await h(t,e.content,`utf8`),i();try{let{clearCommandsCache:e}=await import(`./commands-CVCpJo7M.js`);e()}catch{}return t}function re(e,n,r){return r?.outputRoot?l(r.outputRoot,e):n===`project`?l(r?.cwd??process.cwd(),`.workmate`,`skills`,e):l(r?.globalSkillsDir??l(t(),`skills`),e)}function E(e){return te(e)}function D(e){let t=(e[0]?.action??`Apply a learned project pattern`).replace(/\s+/g,` `).slice(0,120);return t.length>0?t:`Apply learned project patterns`}function O(e){let{name:t,description:n,confidence:r,instincts:i}=e;return[`---`,`name: ${t}`,`description: ${JSON.stringify(n)}`,`origin: skill-learning`,`confidence: ${Number(r.toFixed(2))}`,`evolved_from: [${i.map(e=>JSON.stringify(e.id)).join(`, `)}]`,`---`,``,`# ${k(t)}`,``,`## Trigger`,``,i.map(e=>`- ${e.trigger}`).join(`
4
4
  `),``,`## Action`,``,i.map(e=>`- ${e.action}`).join(`
5
5
  `),``,`## Evidence`,``,i.flatMap(e=>e.evidence.map(e=>`- ${e}`)).slice(0,j).join(`
6
6
  `),``].join(`
@@ -1,5 +1,5 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{HC as n,UC as r}from"./loadAgentsDir-DlPbtIsS.js";import{I as i,P as a,ai as o,hn as s,t as c,y as l}from"./src-DL3w8VPk.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{i as d,t as f}from"./overlayContext-BT2Lq8ei.js";function p(){return[`Skill Search (自动技能匹配)`,`Status: ${r()?`enabled`:`disabled`}`,``,`When enabled, relevant skills are automatically matched and`,`injected into conversation context each turn.`].join(`
2
- `)}async function m(){if(r()&&process.env.SKILL_SEARCH_ENABLED!==`0`)return`Skill Search: already enabled`;process.env.SKILL_SEARCH_ENABLED=`1`;let e=[`Skill Search: enabled (SKILL_SEARCH_ENABLED=1)`];try{let{clearSkillIndexCache:t}=await import(`./localSearch-DrUj0B-d.js`);t(),e.push(`Skill index cache: cleared (will rebuild on next search)`)}catch{e.push(`Skill index cache: clear skipped`)}return e.join(`
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{HC as n,UC as r}from"./loadAgentsDir-B0Anodo0.js";import{I as i,P as a,ai as o,hn as s,t as c,y as l}from"./src-DL3w8VPk.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{i as d,t as f}from"./overlayContext-8--_fbvY.js";function p(){return[`Skill Search (自动技能匹配)`,`Status: ${r()?`enabled`:`disabled`}`,``,`When enabled, relevant skills are automatically matched and`,`injected into conversation context each turn.`].join(`
2
+ `)}async function m(){if(r()&&process.env.SKILL_SEARCH_ENABLED!==`0`)return`Skill Search: already enabled`;process.env.SKILL_SEARCH_ENABLED=`1`;let e=[`Skill Search: enabled (SKILL_SEARCH_ENABLED=1)`];try{let{clearSkillIndexCache:t}=await import(`./localSearch-zfn7jgrh.js`);t(),e.push(`Skill index cache: cleared (will rebuild on next search)`)}catch{e.push(`Skill index cache: clear skipped`)}return e.join(`
3
3
  `)}async function h(){return r()?(process.env.SKILL_SEARCH_ENABLED=`0`,`Skill Search: disabled (SKILL_SEARCH_ENABLED=0)`):`Skill Search: already disabled`}function g({onDone:e}){d(`skill-search-panel`);let[t,n]=(0,v.useState)(0),r=(0,v.useMemo)(()=>[{label:`Status`,description:`显示自动 skill 匹配是否已启用`,run:()=>Promise.resolve(p())},{label:`Start`,description:`为本次会话启用自动 skill 匹配`,run:m},{label:`Stop`,description:`为本次会话禁用自动 skill 匹配`,run:h},{label:`About`,description:`自动 skill 匹配的工作原理`,run:()=>Promise.resolve(x)}],[]),o=()=>{let n=r[t];n&&n.run().then(t=>{e(t,{display:`system`})})};return s((e,t)=>{if(t.upArrow){n(e=>Math.max(0,e-1));return}if(t.downArrow){n(e=>Math.min(r.length-1,e+1));return}t.return&&o()}),(0,y.jsx)(l,{title:`Skill Search`,subtitle:`${r.length} actions`,onCancel:()=>e(`Skill search panel dismissed`,{display:`system`}),color:`background`,hideInputGuide:!0,children:(0,y.jsxs)(i,{flexDirection:`column`,children:[r.map((e,n)=>(0,y.jsxs)(i,{flexDirection:`row`,children:[(0,y.jsx)(a,{children:`${n===t?`›`:` `} ${e.label}`.padEnd(b)}),(0,y.jsx)(a,{dimColor:!0,children:e.description})]},e.label)),(0,y.jsx)(i,{marginTop:1,children:(0,y.jsx)(a,{dimColor:!0,children:`↑/↓ select · Enter run · Esc close`})})]})})}async function _(e,t,n){let r=n?.trim()??``;return r===`start`?(e(await m(),{display:`system`}),null):r===`stop`?(e(await h(),{display:`system`}),null):r===`about`?(e(x,{display:`system`}),null):r===`status`?(e(p(),{display:`system`}),null):(0,y.jsx)(g,{onDone:e})}var v,y,b,x;e((()=>{v=t(o(),1),c(),f(),n(),y=u(),b=28,x=`# Skill Search (自动技能匹配)
4
4
 
5
5
  Skill Search 控制对话中的自动技能匹配功能。
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Gi as n,Ni as r,Pi as i,Ui as a,md as o,pd as s}from"./loadAgentsDir-DlPbtIsS.js";import{I as c,P as l,ai as u,h as d,t as f,y as p}from"./src-DL3w8VPk.js";import{t as m}from"./jsx-runtime-Bb4Xn-E0.js";import{ln as h,sn as g}from"./settings-B2jvL8Dp.js";import{l as _,o as v}from"./stringUtils-C718f5ey.js";import{_ as y,g as b}from"./startupProfiler-CJdr3SxP.js";function x(e,t){let n=t.trim();if(n===``)return e.slice();let r=n.toLowerCase().split(/\s+/);return e.filter(e=>{let t=`${e.name} ${e.description}`.toLowerCase();return r.every(e=>t.includes(e))})}var S=e((()=>{}));function C(e){return e===`plugin`?`plugin`:e===`mcp`?`mcp`:g(e)}function w({onExit:e,commands:t}){let[n,r]=(0,T.useState)(``),o=(0,T.useMemo)(()=>t.filter(e=>e.type===`prompt`&&(e.loadedFrom===`skills`||e.loadedFrom===`commands_DEPRECATED`||e.loadedFrom===`plugin`||e.loadedFrom===`mcp`)),[t]),u=(0,T.useMemo)(()=>x(o.map(e=>({...e,name:i(e),description:e.description??``})),n),[o,n]),f=(0,T.useMemo)(()=>{let e={policySettings:[],userSettings:[],projectSettings:[],localSettings:[],flagSettings:[],plugin:[],mcp:[]};for(let t of u){let n=t.source;n in e&&e[n].push(t)}for(let t of Object.values(e))t.sort((e,t)=>i(e).localeCompare(i(t)));return e},[u]),m=()=>{e(`Skills dialog dismissed`,{display:`system`})};if(o.length===0)return(0,E.jsxs)(p,{title:`Skills`,subtitle:`No skills found`,onCancel:m,hideInputGuide:!0,children:[(0,E.jsx)(l,{dimColor:!0,children:`Create skills in .workmate/skills/ or ~/.workmate/skills/`}),(0,E.jsx)(l,{dimColor:!0,italic:!0,children:(0,E.jsx)(s,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`close`})})]});let h=e=>{switch(e){case`projectSettings`:case`localSettings`:return{label:`local`,color:`yellow`};case`userSettings`:return{label:`global`,color:`cyan`};case`policySettings`:return{label:`managed`,color:`magenta`};default:return}},g=(e,t)=>{let n=`~${b(a(e))}`,r=e.source===`plugin`?e.pluginInfo?.pluginManifest.name:void 0,o=h(e.source);return(0,E.jsxs)(c,{children:[(0,E.jsx)(l,{color:t?`suggestion`:void 0,children:i(e)}),o&&(0,E.jsxs)(l,{color:o.color,children:[` [`,o.label,`]`]}),(0,E.jsxs)(l,{dimColor:!0,children:[r?` · ${r}`:``,` · `,C(e.source),` · `,n,` tokens`]})]})};return(0,E.jsx)(d,{title:`Skills`,placeholder:`Type to filter skills…`,items:(0,T.useMemo)(()=>D.flatMap(e=>f[e]),[f]),getKey:e=>`${e.name}-${e.source}`,visibleCount:12,direction:`down`,onQueryChange:r,onSelect:t=>{e(`/${i(t)}`,{display:`user`})},onCancel:m,emptyMessage:e=>e.trim()?`No skills matching "${e.trim()}"`:`No skills found`,matchLabel:n.trim()===``?`${o.length} ${_(o.length,`skill`)}`:`${u.length}/${o.length} ${_(o.length,`skill`)}`,selectAction:`invoke skill`,renderItem:(e,t)=>g(e,t)})}var T,E,D,O=e((()=>{T=t(u(),1),r(),f(),n(),y(),h(),v(),o(),S(),E=m(),D=[`projectSettings`,`localSettings`,`userSettings`,`flagSettings`,`policySettings`,`plugin`,`mcp`]}));async function k(e,t){return(0,A.jsx)(w,{onExit:e,commands:t.options.commands})}var A;e((()=>{O(),A=m()}))();export{k as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Gi as n,Ni as r,Pi as i,Ui as a,md as o,pd as s}from"./loadAgentsDir-B0Anodo0.js";import{I as c,P as l,ai as u,h as d,t as f,y as p}from"./src-DL3w8VPk.js";import{t as m}from"./jsx-runtime-Bb4Xn-E0.js";import{ln as h,sn as g}from"./settings-B2jvL8Dp.js";import{l as _,o as v}from"./stringUtils-C718f5ey.js";import{_ as y,g as b}from"./startupProfiler-CJdr3SxP.js";function x(e,t){let n=t.trim();if(n===``)return e.slice();let r=n.toLowerCase().split(/\s+/);return e.filter(e=>{let t=`${e.name} ${e.description}`.toLowerCase();return r.every(e=>t.includes(e))})}var S=e((()=>{}));function C(e){return e===`plugin`?`plugin`:e===`mcp`?`mcp`:g(e)}function w({onExit:e,commands:t}){let[n,r]=(0,T.useState)(``),o=(0,T.useMemo)(()=>t.filter(e=>e.type===`prompt`&&(e.loadedFrom===`skills`||e.loadedFrom===`commands_DEPRECATED`||e.loadedFrom===`plugin`||e.loadedFrom===`mcp`)),[t]),u=(0,T.useMemo)(()=>x(o.map(e=>({...e,name:i(e),description:e.description??``})),n),[o,n]),f=(0,T.useMemo)(()=>{let e={policySettings:[],userSettings:[],projectSettings:[],localSettings:[],flagSettings:[],plugin:[],mcp:[]};for(let t of u){let n=t.source;n in e&&e[n].push(t)}for(let t of Object.values(e))t.sort((e,t)=>i(e).localeCompare(i(t)));return e},[u]),m=()=>{e(`Skills dialog dismissed`,{display:`system`})};if(o.length===0)return(0,E.jsxs)(p,{title:`Skills`,subtitle:`No skills found`,onCancel:m,hideInputGuide:!0,children:[(0,E.jsx)(l,{dimColor:!0,children:`Create skills in .workmate/skills/ or ~/.workmate/skills/`}),(0,E.jsx)(l,{dimColor:!0,italic:!0,children:(0,E.jsx)(s,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`close`})})]});let h=e=>{switch(e){case`projectSettings`:case`localSettings`:return{label:`local`,color:`yellow`};case`userSettings`:return{label:`global`,color:`cyan`};case`policySettings`:return{label:`managed`,color:`magenta`};default:return}},g=(e,t)=>{let n=`~${b(a(e))}`,r=e.source===`plugin`?e.pluginInfo?.pluginManifest.name:void 0,o=h(e.source);return(0,E.jsxs)(c,{children:[(0,E.jsx)(l,{color:t?`suggestion`:void 0,children:i(e)}),o&&(0,E.jsxs)(l,{color:o.color,children:[` [`,o.label,`]`]}),(0,E.jsxs)(l,{dimColor:!0,children:[r?` · ${r}`:``,` · `,C(e.source),` · `,n,` tokens`]})]})};return(0,E.jsx)(d,{title:`Skills`,placeholder:`Type to filter skills…`,items:(0,T.useMemo)(()=>D.flatMap(e=>f[e]),[f]),getKey:e=>`${e.name}-${e.source}`,visibleCount:12,direction:`down`,onQueryChange:r,onSelect:t=>{e(`/${i(t)}`,{display:`user`})},onCancel:m,emptyMessage:e=>e.trim()?`No skills matching "${e.trim()}"`:`No skills found`,matchLabel:n.trim()===``?`${o.length} ${_(o.length,`skill`)}`:`${u.length}/${o.length} ${_(o.length,`skill`)}`,selectAction:`invoke skill`,renderItem:(e,t)=>g(e,t)})}var T,E,D,O=e((()=>{T=t(u(),1),r(),f(),n(),y(),h(),v(),o(),S(),E=m(),D=[`projectSettings`,`localSettings`,`userSettings`,`flagSettings`,`policySettings`,`plugin`,`mcp`]}));async function k(e,t){return(0,A.jsx)(w,{onExit:e,commands:t.options.commands})}var A;e((()=>{O(),A=m()}))();export{k as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";import{n,t as r}from"./Settings-B-7yBewS.js";async function i(e,t){return(0,a.jsx)(r,{onClose:e,context:t,defaultTab:`Status`})}var a;e((()=>{n(),a=t()}))();export{i as call};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ji as t,qi as n}from"./loadAgentsDir-DlPbtIsS.js";function r(e){return e?e.activeAgents.filter(e=>e.source!==`built-in`).reduce((e,n)=>e+t(`${n.agentType}: ${n.whenToUse}`),0):0}var i,a=e((()=>{n(),i=15e3}));export{r as n,a as r,i as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ji as t,qi as n}from"./loadAgentsDir-B0Anodo0.js";function r(e){return e?e.activeAgents.filter(e=>e.source!==`built-in`).reduce((e,n)=>e+t(`${n.agentType}: ${n.whenToUse}`),0):0}var i,a=e((()=>{n(),i=15e3}));export{r as n,a as r,i as t};
@@ -0,0 +1 @@
1
+ import{a as e,r as t}from"./switcher-DZwUo5Ed.js";t();export{e as restoreActiveProvider};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{h as t,s as n}from"./settings-B2jvL8Dp.js";import{i as r,n as i,r as a,t as o}from"./loader-CICGtLp2.js";function s(e=a()){let t=n(`userSettings`)?.activeProviderId;if(t&&e.some(e=>e.id===t))return t;let r=process.env.OPENAI_BASE_URL,i=process.env.ANTHROPIC_BASE_URL;for(let t of e)if(t.kind===`anthropic-compat`&&i===t.baseUrl||t.kind===`openai-compat`&&r===t.baseUrl)return t.id}function c(e){if(e.apiKey)return e.apiKey;if(e.apiKeyEnv)return process.env[e.apiKeyEnv]}function l(e,t){let n=t??a(),r=o(e,n);if(!r){let t=n.map(e=>e.id).join(`, `);throw Error(`switchProvider: provider "${e}" not found. Available: ${t}`)}let i=r.kind===`anthropic-compat`?{ANTHROPIC_BASE_URL:r.baseUrl,ANTHROPIC_MODEL:r.defaultModel}:{CLAUDE_CODE_USE_OPENAI:`1`,OPENAI_BASE_URL:r.baseUrl,OPENAI_MODEL:r.defaultModel},s=[];if(r.kind===`openai-compat`){let e=process.env.CLAUDE_CODE_USE_OPENAI===`1`||!!process.env.OPENAI_API_KEY,t=!!process.env.ANTHROPIC_API_KEY;e&&t&&s.push(`Both ANTHROPIC_API_KEY and OpenAI-compat mode are set. ANTHROPIC_API_KEY is for workspace endpoints (/v1/agents, /v1/vaults). OpenAI-compat mode routes /v1/messages to a third-party provider. These are separate planes — verify this is intentional.`)}return!r.apiKey&&!r.apiKeyEnv?s.push(`Provider "${r.id}" has neither apiKey nor apiKeyEnv configured. Edit ~/.workmate/providers.json to add one.`):!r.apiKey&&r.apiKeyEnv&&!process.env[r.apiKeyEnv]&&s.push(`${r.apiKeyEnv} is not set in the current environment. Set it before starting Work Mate: export ${r.apiKeyEnv}=<your-api-key>`),{env:i,warnings:s,provider:r}}function u(e){return e.kind===`anthropic-compat`?`ANTHROPIC_API_KEY`:`OPENAI_API_KEY`}async function d(e,t){delete process.env.CLAUDE_CODE_USE_BEDROCK,delete process.env.CLAUDE_CODE_USE_VERTEX,delete process.env.CLAUDE_CODE_USE_FOUNDRY,delete process.env.CLAUDE_CODE_USE_GEMINI,delete process.env.CLAUDE_CODE_USE_GROK,e.kind===`anthropic-compat`?(delete process.env.CLAUDE_CODE_USE_OPENAI,delete process.env.OPENAI_BASE_URL,delete process.env.OPENAI_API_KEY,delete process.env.OPENAI_MODEL):(delete process.env.ANTHROPIC_BASE_URL,delete process.env.ANTHROPIC_API_KEY,delete process.env.ANTHROPIC_MODEL);let n=e.kind===`anthropic-compat`?{ANTHROPIC_BASE_URL:e.baseUrl,ANTHROPIC_API_KEY:t??``,ANTHROPIC_MODEL:e.defaultModel}:{CLAUDE_CODE_USE_OPENAI:`1`,OPENAI_BASE_URL:e.baseUrl,OPENAI_API_KEY:t??``,OPENAI_MODEL:e.defaultModel},{clearOpenAIClientCache:r}=await import(`./client-CZ8nyVh5.js`);r();let{fetchAvailableModels:i}=await import(`./fetchModelList-D24lRIgR.js`);i.cache.clear();let{applyConfigEnvironmentVariables:a}=await import(`./managedEnv-BEqrGqn1.js`);a(),Object.assign(process.env,n)}async function f(e,t){let{provider:n,warnings:r}=l(e,t),i=c(n),a=u(n);i||r.push(`No API key available for provider "${n.id}" — ${a} will be empty. Set ${n.apiKeyEnv??`an env var`} or add an apiKey field in ~/.workmate/providers.json.`),await d(n,i);let{updateSettingsForSource:o}=await import(`./settings-CisDe8DB.js`);return o(`userSettings`,{activeProviderId:n.id,modelType:n.kind===`anthropic-compat`?`anthropic`:`openai`}),{provider:n,warnings:r}}async function p(e){let{getSettingsForSource:t}=await import(`./settings-CisDe8DB.js`),n=t(`userSettings`)?.activeProviderId;if(!n)return{kind:`no-active-provider`};let i=a(),s=o(n,i);if(!s)return{kind:`provider-not-found`,id:n};if(s.defaultModel===e)return{kind:`unchanged`,providerId:n,model:e};let c=s.defaultModel;return r(i.map(t=>t.id===n?{...t,defaultModel:e}:t)),{kind:`updated`,providerId:n,previousModel:c,newModel:e}}async function m(){let{getSettingsForSource:e}=await import(`./settings-CisDe8DB.js`),t=e(`userSettings`)?.activeProviderId;if(!t)return null;let n=o(t);if(!n)return null;let r=[],i=c(n);if(!i){let e=u(n);r.push(`No API key available for provider "${n.id}" — ${e} will be empty. Set ${n.apiKeyEnv??`an env var`} or add an apiKey field in ~/.workmate/providers.json.`)}return await d(n,i),{provider:n,warnings:r}}var h=e((()=>{t(),i()}));export{m as a,p as i,s as n,l as o,h as r,f as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{h as t,s as n}from"./settings-B2jvL8Dp.js";import{i as r,n as i,r as a,t as o}from"./loader-CICGtLp2.js";function s(e=a()){let t=n(`userSettings`)?.activeProviderId;if(t&&e.some(e=>e.id===t))return t;let r=process.env.OPENAI_BASE_URL,i=process.env.ANTHROPIC_BASE_URL;for(let t of e)if(t.kind===`anthropic-compat`&&i===t.baseUrl||t.kind===`openai-compat`&&r===t.baseUrl)return t.id}function c(e){if(e.apiKey)return e.apiKey;if(e.apiKeyEnv)return process.env[e.apiKeyEnv]}function l(e,t){let n=t??a(),r=o(e,n);if(!r){let t=n.map(e=>e.id).join(`, `);throw Error(`switchProvider: provider "${e}" not found. Available: ${t}`)}let i=r.kind===`anthropic-compat`?{ANTHROPIC_BASE_URL:r.baseUrl,ANTHROPIC_MODEL:r.defaultModel}:{CLAUDE_CODE_USE_OPENAI:`1`,OPENAI_BASE_URL:r.baseUrl,OPENAI_MODEL:r.defaultModel},s=[];if(r.kind===`openai-compat`){let e=process.env.CLAUDE_CODE_USE_OPENAI===`1`||!!process.env.OPENAI_API_KEY,t=!!process.env.ANTHROPIC_API_KEY;e&&t&&s.push(`Both ANTHROPIC_API_KEY and OpenAI-compat mode are set. ANTHROPIC_API_KEY is for workspace endpoints (/v1/agents, /v1/vaults). OpenAI-compat mode routes /v1/messages to a third-party provider. These are separate planes — verify this is intentional.`)}return!r.apiKey&&!r.apiKeyEnv?s.push(`Provider "${r.id}" has neither apiKey nor apiKeyEnv configured. Edit ~/.workmate/providers.json to add one.`):!r.apiKey&&r.apiKeyEnv&&!process.env[r.apiKeyEnv]&&s.push(`${r.apiKeyEnv} is not set in the current environment. Set it before starting Work Mate: export ${r.apiKeyEnv}=<your-api-key>`),{env:i,warnings:s,provider:r}}function u(e){return e.kind===`anthropic-compat`?`ANTHROPIC_API_KEY`:`OPENAI_API_KEY`}async function d(e,t){delete process.env.CLAUDE_CODE_USE_BEDROCK,delete process.env.CLAUDE_CODE_USE_VERTEX,delete process.env.CLAUDE_CODE_USE_FOUNDRY,delete process.env.CLAUDE_CODE_USE_GEMINI,delete process.env.CLAUDE_CODE_USE_GROK,e.kind===`anthropic-compat`?(delete process.env.CLAUDE_CODE_USE_OPENAI,delete process.env.OPENAI_BASE_URL,delete process.env.OPENAI_API_KEY,delete process.env.OPENAI_MODEL):(delete process.env.ANTHROPIC_BASE_URL,delete process.env.ANTHROPIC_API_KEY,delete process.env.ANTHROPIC_MODEL);let n=e.kind===`anthropic-compat`?{ANTHROPIC_BASE_URL:e.baseUrl,ANTHROPIC_API_KEY:t??``,ANTHROPIC_MODEL:e.defaultModel}:{CLAUDE_CODE_USE_OPENAI:`1`,OPENAI_BASE_URL:e.baseUrl,OPENAI_API_KEY:t??``,OPENAI_MODEL:e.defaultModel},{clearOpenAIClientCache:r}=await import(`./client-CZ8nyVh5.js`);r();let{fetchAvailableModels:i}=await import(`./fetchModelList-DC4VQpqa.js`);i.cache.clear();let{applyConfigEnvironmentVariables:a}=await import(`./managedEnv-BEqrGqn1.js`);a(),Object.assign(process.env,n)}async function f(e,t){let{provider:n,warnings:r}=l(e,t),i=c(n),a=u(n);i||r.push(`No API key available for provider "${n.id}" — ${a} will be empty. Set ${n.apiKeyEnv??`an env var`} or add an apiKey field in ~/.workmate/providers.json.`),await d(n,i);let{updateSettingsForSource:o}=await import(`./settings-CisDe8DB.js`);return o(`userSettings`,{activeProviderId:n.id,modelType:n.kind===`anthropic-compat`?`anthropic`:`openai`}),{provider:n,warnings:r}}async function p(e){let{getSettingsForSource:t}=await import(`./settings-CisDe8DB.js`),n=t(`userSettings`)?.activeProviderId;if(!n)return{kind:`no-active-provider`};let i=a(),s=o(n,i);if(!s)return{kind:`provider-not-found`,id:n};if(s.defaultModel===e)return{kind:`unchanged`,providerId:n,model:e};let c=s.defaultModel;return r(i.map(t=>t.id===n?{...t,defaultModel:e}:t)),{kind:`updated`,providerId:n,previousModel:c,newModel:e}}async function m(){let{getSettingsForSource:e}=await import(`./settings-CisDe8DB.js`),t=e(`userSettings`)?.activeProviderId;if(!t)return null;let n=o(t);if(!n)return null;let r=[],i=c(n);if(!i){let e=u(n);r.push(`No API key available for provider "${n.id}" — ${e} will be empty. Set ${n.apiKeyEnv??`an env var`} or add an apiKey field in ~/.workmate/providers.json.`)}return await d(n,i),{provider:n,warnings:r}}var h=e((()=>{t(),i()}));export{m as a,p as i,s as n,l as o,h as r,f as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";import{n,t as r}from"./BackgroundTasksDialog-COuhHcey.js";async function i(e,t){return(0,a.jsx)(r,{toolUseContext:t,onDone:e})}var a;e((()=>{n(),a=t()}))();export{i as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";import{n,t as r}from"./BackgroundTasksDialog-CSEuuoq9.js";async function i(e,t){return(0,a.jsx)(r,{toolUseContext:t,onDone:e})}var a;e((()=>{n(),a=t()}))();export{i as call};