@readmagic/workmate 0.0.11 → 0.0.13

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 (428) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-ag2JTpmU.js → AddWorkspaceDirectory-BzNj9rS6.js} +1 -1
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-CDZPR488.js +1 -0
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-CH9x1Ngp.js +1 -0
  4. package/dist/chunks/App-D-bYAYAl.js +1 -0
  5. package/dist/chunks/ApproveApiKey-BEGV9Zj9.js +1 -0
  6. package/dist/chunks/ApproveApiKey-CjacpIqq.js +1 -0
  7. package/dist/chunks/BackgroundTasksDialog-A9hw_SV0.js +2 -0
  8. package/dist/chunks/{BypassPermissionsModeDialog-B05t83wa.js → BypassPermissionsModeDialog-B0BizN_J.js} +1 -1
  9. package/dist/chunks/{DiffDialog-DUbFrzKu.js → DiffDialog-mQ-5_TSv.js} +2 -2
  10. package/dist/chunks/Doctor-BC6IuQhd.js +3 -0
  11. package/dist/chunks/Doctor-i_5_AQd-.js +1 -0
  12. package/dist/chunks/ExitFlow-Bu2cVGpC.js +2 -0
  13. package/dist/chunks/{Grove-BDoVj02t.js → Grove-D0nn8zOV.js} +2 -2
  14. package/dist/chunks/{HybridTransport-C_U0IJfz.js → HybridTransport-BQNLZNa_.js} +1 -1
  15. package/dist/chunks/InvalidConfigDialog-C5CIiSIE.js +1 -0
  16. package/dist/chunks/{InvalidSettingsDialog-Br8kQOHz.js → InvalidSettingsDialog-Dq7hKXcO.js} +1 -1
  17. package/dist/chunks/MCPConnectionManager-aDDsYkGM.js +1 -0
  18. package/dist/chunks/MCPToolListView-Cr0MDkzT.js +1 -0
  19. package/dist/chunks/{McpParsingWarnings-COa71S9q.js → McpParsingWarnings-CUx2zexI.js} +1 -1
  20. package/dist/chunks/MessageSelector-DwGOWKKL.js +3 -0
  21. package/dist/chunks/Messages-C1jh4ixt.js +11 -0
  22. package/dist/chunks/Onboarding-t-P6Q5O6.js +1 -0
  23. package/dist/chunks/{PromptInputFooterSuggestions-to5eYBvI.js → PromptInputFooterSuggestions-R12fbdmp.js} +1 -1
  24. package/dist/chunks/{PromptInputHelpMenu-CfMFx-TF.js → PromptInputHelpMenu-BgADIzRj.js} +1 -1
  25. package/dist/chunks/QueryEngine-HlLQJmsd.js +1 -0
  26. package/dist/chunks/REPL-Rs_JQkDc.js +1 -0
  27. package/dist/chunks/REPL-VKAmKkII.js +133 -0
  28. package/dist/chunks/RemoteSessionManager-BbgXeM-t.js +2 -0
  29. package/dist/chunks/ResumeConversation-66zbx12g.js +1 -0
  30. package/dist/chunks/{SSETransport-DN4tCDEh.js → SSETransport-BBQkdn4e.js} +1 -1
  31. package/dist/chunks/SearchExtraToolsTool-Bq87I_vu.js +1 -0
  32. package/dist/chunks/Settings-BKdLcyXe.js +2 -0
  33. package/dist/chunks/{TeleportProgress-C2LQVLav.js → TeleportProgress-3hmIApkj.js} +1 -1
  34. package/dist/chunks/{TeleportRepoMismatchDialog-BZL8Zblz.js → TeleportRepoMismatchDialog-BA1a66RK.js} +1 -1
  35. package/dist/chunks/{TeleportResumeWrapper-wPiIs8xg.js → TeleportResumeWrapper-BT4O-Wsi.js} +1 -1
  36. package/dist/chunks/{ThemePicker-BT_NaRQC.js → ThemePicker-DUlhcoso.js} +1 -1
  37. package/dist/chunks/TrustDialog-Dpk03V1Y.js +1 -0
  38. package/dist/chunks/{ValidationErrorsList-C-hWdy_8.js → ValidationErrorsList-DSSUWdgd.js} +1 -1
  39. package/dist/chunks/add-dir-BUr0z-VU.js +1 -0
  40. package/dist/chunks/{agentDisplay-CuSHqgZc.js → agentDisplay-D7bdOOG7.js} +1 -1
  41. package/dist/chunks/{agents-CMC0iQP4.js → agents-22wiC58F.js} +1 -1
  42. package/dist/chunks/agents-8ELI8RJo.js +103 -0
  43. package/dist/chunks/allErrors-C1eMbHSv.js +1 -0
  44. package/dist/chunks/api-DgjIFdMn.js +1 -0
  45. package/dist/chunks/{api-BbJfMXRS.js → api-f3GN2I_J.js} +1 -1
  46. package/dist/chunks/auth-B73a4Cob.js +1 -0
  47. package/dist/chunks/{auth-7mJGtlZp.js → auth-Czy7GoRh.js} +1 -1
  48. package/dist/chunks/auth-D_0waidQ.js +1 -0
  49. package/dist/chunks/backgroundHousekeeping-C_ArdTFX.js +17 -0
  50. package/dist/chunks/backgroundHousekeeping-YJhvZ0dh.js +1 -0
  51. package/dist/chunks/{banner-1Wyeyawe.js → banner-BcAM7iSx.js} +1 -1
  52. package/dist/chunks/bg-Ci7pG4eo.js +9 -0
  53. package/dist/chunks/branch-bb4-bErF.js +3 -0
  54. package/dist/chunks/{break-cache-CAoZ9b72.js → break-cache-4rlQORVk.js} +2 -2
  55. package/dist/chunks/{bridgeConfig-UgaUfuP6.js → bridgeConfig-B80T_lw7.js} +1 -1
  56. package/dist/chunks/bridgeConfig-DywkIo_k.js +1 -0
  57. package/dist/chunks/{bridgeMessaging-Ci5H68MX.js → bridgeMessaging-DyvHd16Z.js} +1 -1
  58. package/dist/chunks/{bridgePointer-BL8-lGvN.js → bridgePointer-DHWK3LEe.js} +1 -1
  59. package/dist/chunks/{bridgeStatusUtil-C36w15ge.js → bridgeStatusUtil-DStiD05t.js} +1 -1
  60. package/dist/chunks/btw-BRmV51bR.js +1 -0
  61. package/dist/chunks/caches-C5DIVdvI.js +1 -0
  62. package/dist/chunks/caches-zDZEgNKq.js +1 -0
  63. package/dist/chunks/{capacityWake-BOySRJUJ.js → capacityWake-ByL6fM6I.js} +1 -1
  64. package/dist/chunks/{ccrClient-Br4LAofR.js → ccrClient-BALhzhPF.js} +1 -1
  65. package/dist/chunks/{claudeDesktop-Bgds1-YT.js → claudeDesktop-Ct_hyICL.js} +1 -1
  66. package/dist/chunks/{clear-C4Vtnbye.js → clear-B_yVyJXP.js} +1 -1
  67. package/dist/chunks/cliLaunch-OPOtzhvA.js +1 -0
  68. package/dist/chunks/client-7lIxWcaM.js +1 -0
  69. package/dist/chunks/{client-B9404qIP.js → client-BMA05FW8.js} +1 -1
  70. package/dist/chunks/client-DVg8PpFX.js +1 -0
  71. package/dist/chunks/commands-ByFXqW43.js +1 -0
  72. package/dist/chunks/compact-BUShp2eQ.js +2 -0
  73. package/dist/chunks/config-9rLTDOYW.js +3 -0
  74. package/dist/chunks/config-BwHNU_pI.js +1 -0
  75. package/dist/chunks/{config-kB2eazPX.js → config-DMKtiMzJ.js} +1 -1
  76. package/dist/chunks/{context-BN7DEjoH.js → context-6Pk3iVhh.js} +1 -1
  77. package/dist/chunks/{context-noninteractive-D91W2B8e.js → context-noninteractive-CHzerxnH.js} +2 -2
  78. package/dist/chunks/context-noninteractive-DFwRQyFE.js +1 -0
  79. package/dist/chunks/conversation-5zb5XkSA.js +1 -0
  80. package/dist/chunks/conversation-JP2ZXrwu.js +1 -0
  81. package/dist/chunks/createSSHSession-XkHMiGRN.js +6 -0
  82. package/dist/chunks/{createSession-DRqkLZWt.js → createSession-BNGm9fL4.js} +1 -1
  83. package/dist/chunks/createSession-VTqzWAu6.js +1 -0
  84. package/dist/chunks/crossProjectResume-DxgQVYSi.js +40 -0
  85. package/dist/chunks/{cwd-Cfdf7z7s.js → cwd-Besi3Os3.js} +1 -1
  86. package/dist/chunks/cwd-DpqwaYHw.js +1 -0
  87. package/dist/chunks/datadog-3WUWcCFn.js +1 -0
  88. package/dist/chunks/{debug-BecbSVoN.js → debug-Dr1SjdXn.js} +2 -2
  89. package/dist/chunks/{debugUtils-CmJfIUxW.js → debugUtils-cK-iOsEV.js} +1 -1
  90. package/dist/chunks/detached-CqfQYVOi.js +5 -0
  91. package/dist/chunks/detectRepository-BsKZDRoI.js +1 -0
  92. package/dist/chunks/{detectRepository-C15umvKN.js → detectRepository-CMEkS5_2.js} +1 -1
  93. package/dist/chunks/{diff-DeK4bwjw.js → diff-CKlLimGq.js} +1 -1
  94. package/dist/chunks/{directoryCompletion-BJCu19HJ.js → directoryCompletion-ByBTSuLu.js} +1 -1
  95. package/dist/chunks/doctor-Bvx0u0sO.js +1 -0
  96. package/dist/chunks/{entry-mdegyj8z.js → entry-DCbq734V.js} +4 -4
  97. package/dist/chunks/{envUtils-BDhHQY0-.js → envUtils-DcaKZlRU.js} +1 -1
  98. package/dist/chunks/{esm-Ka3lhafK.js → esm-CtQkOk5D.js} +1 -1
  99. package/dist/chunks/{execFileNoThrow-DHyW8FMX.js → execFileNoThrow-mXq4K0rl.js} +1 -1
  100. package/dist/chunks/{execSyncWrapper-CDzB0BM1.js → execSyncWrapper-Ne33rRiD.js} +1 -1
  101. package/dist/chunks/exit-DTsz5Lcb.js +1 -0
  102. package/dist/chunks/{extraUsage-BrKbpBK-.js → extraUsage-C86bZVgt.js} +1 -1
  103. package/dist/chunks/extractMemories-6OnMgL2S.js +1 -0
  104. package/dist/chunks/fast-B2ziqJEA.js +1 -0
  105. package/dist/chunks/{fast-DWn40OcQ.js → fast-BkhjaTkZ.js} +1 -1
  106. package/dist/chunks/{fileSuggestions-C7Pwq2yj.js → fileSuggestions-BalHmi1-.js} +2 -2
  107. package/dist/chunks/{firstPartyEventLogger-BHjBQH0J.js → firstPartyEventLogger-1RTgXHSz.js} +2 -2
  108. package/dist/chunks/firstPartyEventLogger-CXMzhLrF.js +1 -0
  109. package/dist/chunks/{flushGate-DdJjxCes.js → flushGate-DWL05x7v.js} +1 -1
  110. package/dist/chunks/{gemini-DHv2iVfy.js → gemini-BLpLJyli.js} +1 -1
  111. package/dist/chunks/generateSessionName-CdbMksHi.js +1 -0
  112. package/dist/chunks/{genericProcessUtils-B2HcDYhg.js → genericProcessUtils-Dc1pfb7J.js} +1 -1
  113. package/dist/chunks/git-Bs1vtuvX.js +1 -0
  114. package/dist/chunks/{git-DBlOv64X.js → git-CoQQ6YEf.js} +1 -1
  115. package/dist/chunks/{githubRepoPathMapping-CK56bUDe.js → githubRepoPathMapping-CmpEaQoo.js} +1 -1
  116. package/dist/chunks/{goal-BZG4gtnb.js → goal-V3qix-i1.js} +3 -3
  117. package/dist/chunks/grok-BLLATotv.js +1 -0
  118. package/dist/chunks/{grove-_zlQ83yR.js → grove-b9gGKgu4.js} +1 -1
  119. package/dist/chunks/{help-C_2tdXHC.js → help-BR7UEr5R.js} +1 -1
  120. package/dist/chunks/{hooks-C7Bn7MBe.js → hooks-C-QMGvCg.js} +3 -3
  121. package/dist/chunks/hooks-D6wtd0Qq.js +1 -0
  122. package/dist/chunks/{initReplBridge-NkZRcM77.js → initReplBridge-DyScxedy.js} +1 -1
  123. package/dist/chunks/{install-Du-DSVzj.js → install-DGH_bjUh.js} +1 -1
  124. package/dist/chunks/{instrumentation-DMs3b82f.js → instrumentation-DQ705pC7.js} +4 -4
  125. package/dist/chunks/{job-rbX1VZmp.js → job-BaMT6Lb2.js} +1 -1
  126. package/dist/chunks/{jwtUtils-OzxN2zts.js → jwtUtils-FQWtM6iM.js} +1 -1
  127. package/dist/chunks/keybindings-CG292HS1.js +2 -0
  128. package/dist/chunks/{launchLocalMemory-BLRCK1_o.js → launchLocalMemory-CtZrkmaw.js} +2 -2
  129. package/dist/chunks/{launchOnboarding-Al_X75Vz.js → launchOnboarding-CyOtdZkT.js} +1 -1
  130. package/dist/chunks/loadAgentsDir-4UC4yLg1.js +1 -0
  131. package/dist/chunks/{loadAgentsDir-BL93ulMm.js → loadAgentsDir-mcRW90aq.js} +596 -604
  132. package/dist/chunks/loadPluginHooks-CWI0RMUx.js +1 -0
  133. package/dist/chunks/{localSearch-C5ipegd9.js → localSearch-CCCDKpYx.js} +1 -1
  134. package/dist/chunks/localSearch-D4hVR7-d.js +1 -0
  135. package/dist/chunks/{log-Dauqle-Z.js → log-27kCA_9u.js} +1 -1
  136. package/dist/chunks/{logoV2Utils-CkvOihX7.js → logoV2Utils--8OUQQPd.js} +1 -1
  137. package/dist/chunks/{magicDocs-DLav5QK0.js → magicDocs-26J_l1De.js} +3 -3
  138. package/dist/chunks/main-CGLCy2pM.js +31 -0
  139. package/dist/chunks/main-DUjtDK1Q.js +513 -0
  140. package/dist/chunks/managedEnv-BuCurT_S.js +1 -0
  141. package/dist/chunks/{managedEnv-DJSCuqCb.js → managedEnv-Ds6MlFQE.js} +1 -1
  142. package/dist/chunks/{mappers-DQxMcezy.js → mappers-DwZw084m.js} +1 -1
  143. package/dist/chunks/mcp-CEKR7PjL.js +6 -0
  144. package/dist/chunks/mcp-DCAf2hHD.js +1 -0
  145. package/dist/chunks/mcp-mCuc8dNe.js +2 -0
  146. package/dist/chunks/{memoize-FeyE7JEh.js → memoize-Co4vS6UF.js} +1 -1
  147. package/dist/chunks/memory-B5SkpC7u.js +1 -0
  148. package/dist/chunks/{mode-Bl2RZC8M.js → mode-B80CHkqo.js} +1 -1
  149. package/dist/chunks/model-BqaneI4D.js +1 -0
  150. package/dist/chunks/model-C29_32BD.js +1 -0
  151. package/dist/chunks/model-NG8fvuT2.js +1 -0
  152. package/dist/chunks/{modelOptions-BtEZe5BB.js → modelOptions-CiZgZxZC.js} +1 -1
  153. package/dist/chunks/{nativeInstaller-BEwayifa.js → nativeInstaller-DqbEfGSX.js} +1 -1
  154. package/dist/chunks/oauth-D38aRTUb.js +1 -0
  155. package/dist/chunks/oauth-U649LV5H.js +1 -0
  156. package/dist/chunks/{observationStore-BpjlK0pG.js → observationStore-D0rm3GhP.js} +1 -1
  157. package/dist/chunks/{omit--yH_T4rf.js → omit-KEhe84f4.js} +1 -1
  158. package/dist/chunks/{onChangeAppState-ZdwI7boX.js → onChangeAppState-Dq1tIEJI.js} +1 -1
  159. package/dist/chunks/openai-BvnsYTpQ.js +10 -0
  160. package/dist/chunks/{panel-CoNfXy3K.js → panel-CoF2a-h4.js} +1 -1
  161. package/dist/chunks/parser-B2PlJg4C.js +1 -0
  162. package/dist/chunks/{parser-BH4u7QiV.js → parser-CUUiH40T.js} +1 -1
  163. package/dist/chunks/partition-DeT341qu.js +1 -0
  164. package/dist/chunks/permissions-BPpeHxpk.js +3 -0
  165. package/dist/chunks/pidLock-DQGDoFQP.js +3 -0
  166. package/dist/chunks/{plan-BNYDTnQd.js → plan-BRiC5ujG.js} +1 -1
  167. package/dist/chunks/{platform-B0uTQc9P.js → platform-Dg1c9F_1.js} +1 -1
  168. package/dist/chunks/plugin-Dcg_GGR9.js +17 -0
  169. package/dist/chunks/pluginAutoupdate-ByH9IPC9.js +1 -0
  170. package/dist/chunks/pluginBlocklist-BfoLN9a-.js +1 -0
  171. package/dist/chunks/pluginCliCommands-Bc2Iybhz.js +1 -0
  172. package/dist/chunks/{pluginFlagging-DcJ_FQuv.js → pluginFlagging-Cr0d0hBA.js} +1 -1
  173. package/dist/chunks/pluginOperations-CKNyYjS-.js +2 -0
  174. package/dist/chunks/pluginStartupCheck-B48_cGgo.js +1 -0
  175. package/dist/chunks/{pluginStartupCheck-CKBFaMFr.js → pluginStartupCheck-DiCDQQlr.js} +1 -1
  176. package/dist/chunks/plugins-BP_36tOl.js +4 -0
  177. package/dist/chunks/poorMode-Djw0P9Gu.js +1 -0
  178. package/dist/chunks/{poorMode-B_xEvuEV.js → poorMode-DxgO_bUb.js} +1 -1
  179. package/dist/chunks/print-2uavraPq.js +26 -0
  180. package/dist/chunks/processBashCommand-g3sAMpHt.js +1 -0
  181. package/dist/chunks/processSlashCommand-tIbeCrv5.js +5 -0
  182. package/dist/chunks/{projectContext-CIxul6vA.js → projectContext-BN2ZWzOG.js} +1 -1
  183. package/dist/chunks/{projectContext-RUMJB798.js → projectContext-Bw3o5BrN.js} +1 -1
  184. package/dist/chunks/{prompt-Dx7IWhBt.js → prompt-DIlq8NTy.js} +4 -4
  185. package/dist/chunks/prompt-DLv-Cd67.js +1 -0
  186. package/dist/chunks/prompt-DV5tCLRh.js +1 -0
  187. package/dist/chunks/{promptEditor-WCkmpejM.js → promptEditor-BILqOGl1.js} +2 -2
  188. package/dist/chunks/{protocolHandler-BiVWrpHi.js → protocolHandler-B83fCYI4.js} +1 -1
  189. package/dist/chunks/{proxy-CVn7o19p.js → proxy-BEKNaTXI.js} +1 -1
  190. package/dist/chunks/rcDebugLog-DSchf3Hs.js +1 -0
  191. package/dist/chunks/reconciler-CDq6XgAS.js +1 -0
  192. package/dist/chunks/refresh-ysrhoWCo.js +1 -0
  193. package/dist/chunks/{registerProtocol-E0Iu5hEx.js → registerProtocol-DduKPsn_.js} +1 -1
  194. package/dist/chunks/{reload-plugins-D-3AUT9g.js → reload-plugins-CGb0HTsH.js} +1 -1
  195. package/dist/chunks/{remoteBridgeCore-CV6we3ZA.js → remoteBridgeCore-BmteXmI9.js} +1 -1
  196. package/dist/chunks/{remoteManagedSettings-D26Q09-7.js → remoteManagedSettings-CwDGxL5p.js} +1 -1
  197. package/dist/chunks/rename-1GLIUlYk.js +1 -0
  198. package/dist/chunks/{renderOptions-DDLbSMQU.js → renderOptions-45A-EdsK.js} +1 -1
  199. package/dist/chunks/resume-DWtlUiHW.js +2 -0
  200. package/dist/chunks/ripgrep-BLQnqPnE.js +1 -0
  201. package/dist/chunks/{ripgrep-C1ydIMzT.js → ripgrep-DQ_ILUJV.js} +1 -1
  202. package/dist/chunks/{runtimeObserver-L7pSIWBT.js → runtimeObserver-4ZqaCXYy.js} +4 -4
  203. package/dist/chunks/{runtimeObserver-OU8KrZQG.js → runtimeObserver-CtNY8Al2.js} +1 -1
  204. package/dist/chunks/sandbox-adapter-BzjRQh_r.js +1 -0
  205. package/dist/chunks/sandbox-toggle-Bz49-F6e.js +1 -0
  206. package/dist/chunks/searchExtraTools-D6vj8qJ-.js +1 -0
  207. package/dist/chunks/{session-DUYsfPy_.js → session-wb6X4Wrq.js} +2 -2
  208. package/dist/chunks/sessionFileAccessHooks-Da97UA2n.js +1 -0
  209. package/dist/chunks/{sessionObserver-Dv3Ba8eA.js → sessionObserver-BJQ5hwjU.js} +2 -2
  210. package/dist/chunks/sessionObserver-DXO4trhk.js +1 -0
  211. package/dist/chunks/{sessionState-D-SaBzWD.js → sessionState-Bn3ESS5f.js} +1 -1
  212. package/dist/chunks/sessionStorage-DlPVsQn9.js +1 -0
  213. package/dist/chunks/{sessionStoragePortable-JZnGwqUM.js → sessionStoragePortable-BhkGMZWp.js} +1 -1
  214. package/dist/chunks/sessionTitle-Cbzrb9jT.js +14 -0
  215. package/dist/chunks/{sessionTracing-Bqb3vJTt.js → sessionTracing-CEsm8pZL.js} +1 -1
  216. package/dist/chunks/settings-3ionQKNv.js +1 -0
  217. package/dist/chunks/settings-DiBMs2gM.js +20 -0
  218. package/dist/chunks/settingsSync-eHaSngKo.js +1 -0
  219. package/dist/chunks/setup-DeyiuGNX.js +3 -0
  220. package/dist/chunks/{shadowedRuleDetection-BzAZ57p2.js → shadowedRuleDetection-D5X5fhzj.js} +1 -1
  221. package/dist/chunks/{shellQuote-DS6WrivY.js → shellQuote-C_I6DHLV.js} +1 -1
  222. package/dist/chunks/{sideQuestion-CvMBBjI8.js → sideQuestion-BHRtwhyj.js} +3 -3
  223. package/dist/chunks/{sinks-f7qYjbKJ.js → sinks-Bgy2UNK-.js} +2 -2
  224. package/dist/chunks/sinks-CgzLmim2.js +1 -0
  225. package/dist/chunks/skillChangeDetector-BlSP16j6.js +1 -0
  226. package/dist/chunks/{skillGapStore-CqaT8c0C.js → skillGapStore-BjQSSz2E.js} +2 -2
  227. package/dist/chunks/{skillLifecycle-CnR8IqJM.js → skillLifecycle-Sp8strFv.js} +2 -2
  228. package/dist/chunks/{skillSearchPanel-D9qrOXpI.js → skillSearchPanel-3sYRez_Q.js} +5 -5
  229. package/dist/chunks/skills-CJhWI8t1.js +1 -0
  230. package/dist/chunks/startupProfiler-CUlV07MD.js +1 -0
  231. package/dist/chunks/{startupProfiler-CmH_aVy2.js → startupProfiler-Dc5r6LgE.js} +2 -2
  232. package/dist/chunks/{state-BemZdQIl.js → state-BPFYBqm1.js} +1 -1
  233. package/dist/chunks/state-CsdHk8n-.js +1 -0
  234. package/dist/chunks/{stats-B8uQ-UDi.js → stats-BkadEKa-.js} +1 -1
  235. package/dist/chunks/status-CDCurOqs.js +2 -0
  236. package/dist/chunks/{status-BekdWoIj.js → status-yoQIQ2Ni.js} +1 -1
  237. package/dist/chunks/statusNoticeHelpers-Sl4jjauz.js +1 -0
  238. package/dist/chunks/{stringUtils-C8PaYpQF.js → stringUtils-Df-Lnjxd.js} +1 -1
  239. package/dist/chunks/{subprocessEnv-Ci8VV_bi.js → subprocessEnv-CNBOhlDV.js} +1 -1
  240. package/dist/chunks/subprocessEnv-DtBCqQIo.js +1 -0
  241. package/dist/chunks/switcher-C-m6MUwE.js +1 -0
  242. package/dist/chunks/switcher-uoQMHmEZ.js +1 -0
  243. package/dist/chunks/{syncCache-ClP9aBqK.js → syncCache-BooMjgU6.js} +1 -1
  244. package/dist/chunks/{tasks-Dmh6qikm.js → tasks-CHG_6sXQ.js} +1 -1
  245. package/dist/chunks/teleport-C9KRE4X8.js +1 -0
  246. package/dist/chunks/{templateJobs-CxqU-s5i.js → templateJobs-BYYfF4m5.js} +2 -2
  247. package/dist/chunks/{terminalSetup-BKGcmlWp.js → terminalSetup-CbXKCpWM.js} +1 -1
  248. package/dist/chunks/{terminalSetup-Cy19F1Js.js → terminalSetup-fwhFTxGi.js} +1 -1
  249. package/dist/chunks/{theme-U7lMFHQ0.js → theme-MvX7hojJ.js} +1 -1
  250. package/dist/chunks/tmux-d3cNCIZA.js +1 -0
  251. package/dist/chunks/{toolEventObserver-D9qjoVl5.js → toolEventObserver-BFEl47bq.js} +1 -1
  252. package/dist/chunks/toolPool-Cq74Cvjp.js +1 -0
  253. package/dist/chunks/trustedDevice-BGwujSqc.js +1 -0
  254. package/dist/chunks/{trustedDevice-DL0pWP4_.js → trustedDevice-BLiKbGpG.js} +1 -1
  255. package/dist/chunks/{types-DafcFtmb.js → types-BJ7qTz75.js} +1 -1
  256. package/dist/chunks/{udsClient-CWnfsgFP.js → udsClient-CF8BmZgN.js} +1 -1
  257. package/dist/chunks/{updateCCB-C6XftzIG.js → updateCCB-CfckOy7T.js} +1 -1
  258. package/dist/chunks/{upstreamproxy-CXmjxHpl.js → upstreamproxy-BuBFDFAD.js} +1 -1
  259. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-DEEJhm_W.js → useExitOnCtrlCDWithKeybindings-CPLBDluY.js} +1 -1
  260. package/dist/chunks/useMainLoopModel-C00PbZ1Q.js +1 -0
  261. package/dist/chunks/useManagePlugins-DFaGntzJ.js +1 -0
  262. package/dist/chunks/{useMergedTools-DbhqKk1-.js → useMergedTools-DYobZ5N4.js} +1 -1
  263. package/dist/chunks/{useSearchInput-gUDbkLaC.js → useSearchInput-KFKh2ozY.js} +1 -1
  264. package/dist/chunks/useSettingsErrors-BRgjvaHd.js +1 -0
  265. package/dist/chunks/{userAgent-CU7Ndh79.js → userAgent-DUrr02yh.js} +1 -1
  266. package/dist/chunks/util-D7uwPgF1.js +1 -0
  267. package/dist/chunks/validatePlugin-VukX52bx.js +1 -0
  268. package/dist/chunks/{vim-w37BfGZ5.js → vim-C4Hs5U2h.js} +1 -1
  269. package/dist/chunks/{which-BRWBO7Gu.js → which-mplwBbc0.js} +1 -1
  270. package/dist/chunks/windowsPaths-B8p9tFRF.js +1 -0
  271. package/dist/chunks/{windowsPaths-DtWHLjmE.js → windowsPaths-C7Mdo9aU.js} +1 -1
  272. package/dist/chunks/{workSecret-BEhXgH2M.js → workSecret-XLodD7tw.js} +1 -1
  273. package/dist/chunks/workerRegistry-BA37PVbv.js +6 -0
  274. package/dist/chunks/worktree-Lik8xuKd.js +1 -0
  275. package/dist/cli.js +1 -1
  276. package/package.json +1 -1
  277. package/dist/chunks/App-BuKmqFPm.js +0 -1
  278. package/dist/chunks/ApproveApiKey-CIWOi_7v.js +0 -1
  279. package/dist/chunks/ApproveApiKey-M6U-NafA.js +0 -1
  280. package/dist/chunks/BackgroundTasksDialog-Pnpl3Ixx.js +0 -2
  281. package/dist/chunks/ClaudeMdExternalIncludesDialog-CSywJdVL.js +0 -1
  282. package/dist/chunks/ClaudeMdExternalIncludesDialog-D-w166RC.js +0 -1
  283. package/dist/chunks/ConsoleOAuthFlow-CV6PcJOP.js +0 -1
  284. package/dist/chunks/Doctor-BcnUfJ4I.js +0 -1
  285. package/dist/chunks/Doctor-Dz4TuYas.js +0 -3
  286. package/dist/chunks/ExitFlow-BwyAtIHx.js +0 -2
  287. package/dist/chunks/InvalidConfigDialog-bih293Xt.js +0 -1
  288. package/dist/chunks/MCPConnectionManager-B9n4SXN4.js +0 -1
  289. package/dist/chunks/MCPToolListView-DJ06N1DG.js +0 -1
  290. package/dist/chunks/MessageSelector-o4ULADFg.js +0 -3
  291. package/dist/chunks/Messages-qqwHuAW5.js +0 -11
  292. package/dist/chunks/Onboarding-BzuQjney.js +0 -1
  293. package/dist/chunks/QueryEngine-Dt0BKUeF.js +0 -1
  294. package/dist/chunks/REPL-CUbEDqEl.js +0 -133
  295. package/dist/chunks/REPL-DMaKNhTa.js +0 -1
  296. package/dist/chunks/RemoteSessionManager-Bf44A0Ol.js +0 -2
  297. package/dist/chunks/ResumeConversation-Ctw5Q1g9.js +0 -1
  298. package/dist/chunks/SearchExtraToolsTool-C80OdtPZ.js +0 -1
  299. package/dist/chunks/Settings-DfdcmvOV.js +0 -2
  300. package/dist/chunks/TrustDialog-ACaJ_m7A.js +0 -1
  301. package/dist/chunks/WelcomeV2-ZQRKlcT4.js +0 -1
  302. package/dist/chunks/add-dir-SAKTkw0S.js +0 -1
  303. package/dist/chunks/agents-ZgRKpjHv.js +0 -103
  304. package/dist/chunks/allErrors-_cOQksHC.js +0 -1
  305. package/dist/chunks/api-DS1MiW01.js +0 -1
  306. package/dist/chunks/auth-DGZzCbU0.js +0 -1
  307. package/dist/chunks/auth-DN1MUpB8.js +0 -1
  308. package/dist/chunks/autoMode-CBtY7ACs.js +0 -45
  309. package/dist/chunks/autonomy-DuQmYhq6.js +0 -15
  310. package/dist/chunks/autonomy-lJV7yWUl.js +0 -1
  311. package/dist/chunks/autonomyPanel-DAQm6lDz.js +0 -1
  312. package/dist/chunks/backgroundHousekeeping-BTy71bcY.js +0 -1
  313. package/dist/chunks/backgroundHousekeeping-Cc7Ag7JG.js +0 -17
  314. package/dist/chunks/bg-CJ0YWFli.js +0 -9
  315. package/dist/chunks/bg-CeUrRz_7.js +0 -1
  316. package/dist/chunks/branch-k3kirqbA.js +0 -3
  317. package/dist/chunks/bridgeConfig-CzRUPn-D.js +0 -1
  318. package/dist/chunks/btw-nVoVuIae.js +0 -1
  319. package/dist/chunks/caches-B8sM3Zys.js +0 -1
  320. package/dist/chunks/caches-Bp9MZ7IE.js +0 -1
  321. package/dist/chunks/cliLaunch-BTpfAGGI.js +0 -1
  322. package/dist/chunks/client-BCAbKdNz.js +0 -1
  323. package/dist/chunks/client-CJE6gEvU.js +0 -1
  324. package/dist/chunks/commands-DL-BzoMQ.js +0 -1
  325. package/dist/chunks/compact-Cx7BPXLU.js +0 -2
  326. package/dist/chunks/config-S5OW4Xqr.js +0 -1
  327. package/dist/chunks/config-aRiTrtCv.js +0 -3
  328. package/dist/chunks/connectHeadless-CqRoEtrg.js +0 -1
  329. package/dist/chunks/context-noninteractive-DPacEFJ1.js +0 -1
  330. package/dist/chunks/conversation-D5Nbu9eT.js +0 -1
  331. package/dist/chunks/conversation-hcUx9e-C.js +0 -1
  332. package/dist/chunks/createSSHSession-DecOR6M5.js +0 -6
  333. package/dist/chunks/createSession-D27zvmOs.js +0 -1
  334. package/dist/chunks/crossProjectResume-Bw3U0Ty6.js +0 -40
  335. package/dist/chunks/cwd-ClLru_7T.js +0 -1
  336. package/dist/chunks/dangerousBackend-DwcP0P08.js +0 -1
  337. package/dist/chunks/datadog-bm551AVV.js +0 -1
  338. package/dist/chunks/detached-CIyF0M5O.js +0 -5
  339. package/dist/chunks/detectRepository-DDfLfKcM.js +0 -1
  340. package/dist/chunks/doctor-BJORBomU.js +0 -1
  341. package/dist/chunks/exit-CF3KBl-S.js +0 -1
  342. package/dist/chunks/extractMemories-4lBn134y.js +0 -1
  343. package/dist/chunks/fast-0Vi354KI.js +0 -1
  344. package/dist/chunks/firstPartyEventLogger-BNBnLYPK.js +0 -1
  345. package/dist/chunks/generateSessionName-DhS_6oHd.js +0 -1
  346. package/dist/chunks/git-DF4RFFaT.js +0 -1
  347. package/dist/chunks/grok-BS57ZhyW.js +0 -1
  348. package/dist/chunks/hooks-DT80Arzc.js +0 -1
  349. package/dist/chunks/keybindings-CwdC_8S0.js +0 -2
  350. package/dist/chunks/loadAgentsDir-eVKq8efm.js +0 -1
  351. package/dist/chunks/loadPluginHooks-B0au35a4.js +0 -1
  352. package/dist/chunks/localSearch-CZlFfR_X.js +0 -1
  353. package/dist/chunks/lockfile-D5-j7HOZ.js +0 -1
  354. package/dist/chunks/main-CVNWNAoh.js +0 -513
  355. package/dist/chunks/main-LMyE3jXY.js +0 -31
  356. package/dist/chunks/managedEnv-CYepSnm8.js +0 -1
  357. package/dist/chunks/mcp-BAbbEaBA.js +0 -1
  358. package/dist/chunks/mcp-Ct4Sum6A.js +0 -6
  359. package/dist/chunks/mcp-D5HkCqUh.js +0 -2
  360. package/dist/chunks/memory-COa7aUbx.js +0 -1
  361. package/dist/chunks/model-B7rtZ7KV.js +0 -1
  362. package/dist/chunks/model-Bgh_r4lg.js +0 -1
  363. package/dist/chunks/model-DiuEAv6h.js +0 -1
  364. package/dist/chunks/oauth-BN2I0_jl.js +0 -1
  365. package/dist/chunks/oauth-C9VBDB0Y.js +0 -1
  366. package/dist/chunks/openai-DWs4D-nQ.js +0 -10
  367. package/dist/chunks/parseConnectUrl-BiyKR5-x.js +0 -1
  368. package/dist/chunks/parser-BMIaRErw.js +0 -1
  369. package/dist/chunks/partition-DLcW5Oo_.js +0 -1
  370. package/dist/chunks/permissions-CaucYK3s.js +0 -3
  371. package/dist/chunks/pidLock-DgOBc1Xo.js +0 -3
  372. package/dist/chunks/plugin-BN-of1_H.js +0 -17
  373. package/dist/chunks/pluginAutoupdate-BBU9Jn4p.js +0 -1
  374. package/dist/chunks/pluginBlocklist-DXQlbG0P.js +0 -1
  375. package/dist/chunks/pluginCliCommands-CfdVNs8D.js +0 -1
  376. package/dist/chunks/pluginOperations-DnhzFbYI.js +0 -2
  377. package/dist/chunks/pluginStartupCheck-CpNB4jxG.js +0 -1
  378. package/dist/chunks/plugins-CBW7kPyp.js +0 -4
  379. package/dist/chunks/poorMode-yH1o41cQ.js +0 -1
  380. package/dist/chunks/print-BZOx09SU.js +0 -26
  381. package/dist/chunks/processBashCommand-dcCNCiBp.js +0 -1
  382. package/dist/chunks/processSlashCommand-YDiM63Qr.js +0 -5
  383. package/dist/chunks/prompt-CXGy0llt.js +0 -1
  384. package/dist/chunks/prompt-DovNDmcx.js +0 -1
  385. package/dist/chunks/rcDebugLog-CARUIORE.js +0 -1
  386. package/dist/chunks/reconciler-C2Nd_e4n.js +0 -1
  387. package/dist/chunks/refresh-B84H2Ezd.js +0 -1
  388. package/dist/chunks/rename-CSavuBIE.js +0 -1
  389. package/dist/chunks/resume-CROylN3J.js +0 -2
  390. package/dist/chunks/ripgrep-2M1GkXqJ.js +0 -1
  391. package/dist/chunks/sandbox-adapter-6UwMLh6e.js +0 -1
  392. package/dist/chunks/sandbox-toggle-YrQNWGsr.js +0 -1
  393. package/dist/chunks/searchExtraTools-Bdv5HJ74.js +0 -1
  394. package/dist/chunks/server-LdbAb0sV.js +0 -1
  395. package/dist/chunks/serverBanner-BdExKFHT.js +0 -1
  396. package/dist/chunks/serverLog-BFmvyJ93.js +0 -1
  397. package/dist/chunks/sessionFileAccessHooks-Czen7Ejz.js +0 -1
  398. package/dist/chunks/sessionManager-CPa049BO.js +0 -1
  399. package/dist/chunks/sessionObserver-B0zucj_c.js +0 -1
  400. package/dist/chunks/sessionStorage-BM1x51Z7.js +0 -1
  401. package/dist/chunks/sessionTitle-uCuYaNif.js +0 -14
  402. package/dist/chunks/settings-BG15IFYx.js +0 -1
  403. package/dist/chunks/settings-D4CpDv2y.js +0 -20
  404. package/dist/chunks/settingsSync-BSrpnyqo.js +0 -1
  405. package/dist/chunks/setup-C62oq4AZ.js +0 -3
  406. package/dist/chunks/sinks-WJ7nzLQs.js +0 -1
  407. package/dist/chunks/skillChangeDetector-U5kRU5nd.js +0 -1
  408. package/dist/chunks/skills-BgcFh0vy.js +0 -1
  409. package/dist/chunks/startupProfiler-B4HBBbHN.js +0 -1
  410. package/dist/chunks/state-BAGmpVBn.js +0 -1
  411. package/dist/chunks/state-D_lk6z-C.js +0 -1
  412. package/dist/chunks/status-D6KlRJmR.js +0 -2
  413. package/dist/chunks/statusNoticeHelpers-BMM8_uJ1.js +0 -1
  414. package/dist/chunks/subprocessEnv-CZkA9Cdp.js +0 -1
  415. package/dist/chunks/switcher-Ck9CrXrr.js +0 -1
  416. package/dist/chunks/switcher-DnAhkyIn.js +0 -1
  417. package/dist/chunks/teleport-DH3IuAUQ.js +0 -1
  418. package/dist/chunks/tmux-D5EvHWi3.js +0 -1
  419. package/dist/chunks/toolPool-69mfSPAs.js +0 -1
  420. package/dist/chunks/trustedDevice-B6AKlsl_.js +0 -1
  421. package/dist/chunks/useMainLoopModel-6w7mhwhU.js +0 -1
  422. package/dist/chunks/useManagePlugins-CjnsO-Of.js +0 -1
  423. package/dist/chunks/useSettingsErrors-CgPad-H0.js +0 -1
  424. package/dist/chunks/util-B4oMhJKh.js +0 -1
  425. package/dist/chunks/validatePlugin-y_O_tCEL.js +0 -1
  426. package/dist/chunks/windowsPaths-BY-IVNwQ.js +0 -1
  427. package/dist/chunks/workerRegistry-Bq9bS5pw.js +0 -6
  428. package/dist/chunks/worktree-4SUJ4dtz.js +0 -1
@@ -1 +1 @@
1
- import{o as e,u as t}from"./envUtils-BDhHQY0-.js";import{n,t as r}from"./axios-DaWTGg7G.js";import{C as i,P as a,R as o,c as s,i as c,nt as l,tt as u,x as d}from"./debug-BecbSVoN.js";import{O as f,k as p}from"./git-DBlOv64X.js";import{n as m,r as h}from"./analytics-DJobLaWP.js";import{_n as g,vn as _}from"./model-Bgh_r4lg.js";import{c as ee,n as v}from"./sessionState-D-SaBzWD.js";import{i as y,t as b}from"./sessionIdCompat-DMayYBrf.js";import{a as x,r as S}from"./bridgeConfig-UgaUfuP6.js";import{i as C,o as w,s as T}from"./debugUtils-CmJfIUxW.js";import{a as E,c as D,i as te,n as ne,o as O,r as re,s as ie,t as k}from"./bridgeMessaging-Ci5H68MX.js";import{a as ae,r as A,t as oe}from"./flushGate-DdJjxCes.js";import{t as j}from"./workSecret-BEhXgH2M.js";import{i as M}from"./trustedDevice-DL0pWP4_.js";import{t as se}from"./jwtUtils-OzxN2zts.js";e(),u(),f(),m(),g(),b(),v(),r(),c(),o(),d(),w();var N=`2023-06-01`;function P(e){return{Authorization:`Bearer ${e}`,"Content-Type":`application/json`,"anthropic-version":N}}async function ce(e,t,r,o,c){let l=`${e}/v1/code/sessions`,u;try{u=await n.post(l,{title:r,bridge:{},...c?.length?{tags:c}:{}},{headers:P(t),timeout:o,validateStatus:e=>e<500})}catch(e){return s(`[code-session] Session create request failed: ${a(e)}`),null}if(u.status!==200&&u.status!==201){let e=C(u.data);return s(`[code-session] Session create failed ${u.status}${e?`: ${e}`:``}`),null}let d=u.data;return!d||typeof d!=`object`||!(`session`in d)||!d.session||typeof d.session!=`object`||!(`id`in d.session)||typeof d.session.id!=`string`||!d.session.id.startsWith(`cse_`)?(s(`[code-session] No session.id (cse_*) in response: ${i(d).slice(0,200)}`),null):d.session.id}async function F(e,t,r,o,c){let l=`${t}/v1/code/sessions/${e}/bridge`,u=P(r);c&&(u[`X-Trusted-Device-Token`]=c);let d;try{d=await n.post(l,{},{headers:u,timeout:o,validateStatus:e=>e<500})}catch(e){return s(`[code-session] /bridge request failed: ${a(e)}`),null}if(d.status!==200){let e=C(d.data);return s(`[code-session] /bridge failed ${d.status}${e?`: ${e}`:``}`),null}let f=d.data;if(typeof f!=`object`||!f||!(`worker_jwt`in f)||typeof f.worker_jwt!=`string`||!(`expires_in`in f)||typeof f.expires_in!=`number`||!(`api_base_url`in f)||typeof f.api_base_url!=`string`||!(`worker_epoch`in f))return s(`[code-session] /bridge response malformed (need worker_jwt, expires_in, api_base_url, worker_epoch): ${i(f).slice(0,200)}`),null;let p=f.worker_epoch,m=typeof p==`string`?Number(p):p;return typeof m!=`number`||!Number.isFinite(m)||!Number.isSafeInteger(m)?(s(`[code-session] /bridge worker_epoch invalid: ${i(p)}`),null):{worker_jwt:f.worker_jwt,api_base_url:f.api_base_url,expires_in:f.expires_in,worker_epoch:m}}r(),w(),c(),o(),x();var I=`2023-06-01`;function L(e){return{Authorization:`Bearer ${e}`,"Content-Type":`application/json`,"anthropic-version":I}}async function R(e){let{baseUrl:n,orgUUID:r,title:i,getAccessToken:o,onAuth401:c,toSDKMessages:u,initialHistoryCap:d,initialMessages:f,onInboundMessage:m,onUserMessage:g,onPermissionResponse:_,onInterrupt:v,onSetModel:y,onSetMaxThinkingTokens:b,onSetPermissionMode:x,onStateChange:S,outboundOnly:C,tags:w}=e,M=await ae(),N=o();if(!N)return s(`[remote-bridge] No OAuth token`),null;let P=await z(()=>ce(n,N,i,M.http_timeout_ms,w),`createCodeSession`,M);if(!P)return S?.(`failed`,`Session creation failed — see debug log`),T(`v2_session_create_failed`,void 0,!0),null;let F=P;s(`[remote-bridge] Created session ${F}`),p(`info`,`bridge_repl_v2_session_created`);let I=await z(()=>B(F,n,N,M.http_timeout_ms),`fetchRemoteCredentials`,M);if(!I)return S?.(`failed`,`Remote credentials fetch failed — see debug log`),T(`v2_remote_creds_failed`,void 0,!0),V(F,n,N,r,M.http_timeout_ms),null;s(`[remote-bridge] Fetched bridge credentials (expires_in=${I.expires_in}s)`);let L=j(I.api_base_url,F);s(`[remote-bridge] v2 session URL: ${L}`);let R;try{R=await A({sessionUrl:L,ingressToken:I.worker_jwt,sessionId:F,epoch:I.worker_epoch,heartbeatIntervalMs:M.heartbeat_interval_ms,heartbeatJitterFraction:M.heartbeat_jitter_fraction,getAuthToken:()=>I.worker_jwt,outboundOnly:C})}catch(e){return s(`[remote-bridge] v2 transport setup failed: ${a(e)}`,{level:`error`}),S?.(`failed`,`Transport setup failed: ${a(e)}`),T(`v2_transport_setup_failed`,void 0,!0),V(F,n,N,r,M.http_timeout_ms),null}s(`[remote-bridge] v2 transport created (epoch=${I.worker_epoch})`),S?.(`ready`);let H=new k(M.uuid_dedup_buffer_size),U=new Set;if(f)for(let e of f)U.add(e.uuid),H.add(e.uuid);let le=new k(M.uuid_dedup_buffer_size),W=new oe,G=!1,K=!1,q=!1,J=!g,Y=`initial`,X;function Z(e){K||h(`tengu_bridge_repl_connect_timeout`,{v2:!0,elapsed_ms:M.connect_timeout_ms,cause:e})}ee(e=>{K||R.reportMetadata(e)},{replayCurrent:!0});let Q=se({refreshBufferMs:M.token_refresh_buffer_ms,getAccessToken:async()=>{let e=o();return c&&await c(e??``),o()??e},onRefresh:(e,t)=>{(async()=>{if(q||K){s(`[remote-bridge] Recovery already in flight, skipping proactive refresh`);return}q=!0;try{let r=await z(()=>B(e,n,t,M.http_timeout_ms),`fetchRemoteCredentials (proactive)`,M);if(!r||K)return;await ue(r,`proactive_refresh`),s(`[remote-bridge] Transport rebuilt (proactive refresh)`)}catch(e){s(`[remote-bridge] Proactive refresh rebuild failed: ${a(e)}`,{level:`error`}),p(`error`,`bridge_repl_v2_proactive_refresh_failed`),K||S?.(`failed`,`Refresh failed: ${a(e)}`)}finally{q=!1}})()},label:`remote`});Q.scheduleFromExpiresIn(F,I.expires_in);function $(){R.setOnConnect(()=>{if(clearTimeout(X),s(`[remote-bridge] v2 transport connected`),p(`info`,`bridge_repl_v2_transport_connected`),h(`tengu_bridge_repl_ws_connected`,{v2:!0,cause:Y}),!G&&f&&f.length>0){G=!0;let e=R;pe(f).catch(e=>s(`[remote-bridge] flushHistory failed: ${e}`)).finally(()=>{R!==e||K||q||(fe(),S?.(`connected`))})}else W.active||S?.(`connected`)}),R.setOnData(e=>{re(e,H,le,m,_?e=>{R.reportState(`running`),_(e)}:void 0,e=>te(e,{transport:R,sessionId:F,onInterrupt:v,onSetModel:y,onSetMaxThinkingTokens:b,onSetPermissionMode:x,outboundOnly:C}))}),R.setOnClose(e=>{if(clearTimeout(X),!K){if(s(`[remote-bridge] v2 transport closed (code=${e})`),h(`tengu_bridge_repl_ws_closed`,{code:e,v2:!0}),e===401&&!q){de();return}S?.(`failed`,`Transport closed (code ${e})`)}})}async function ue(e,t){Y=t,W.start();try{let t=R.getLastSequenceNum();if(R.close(),R=await A({sessionUrl:j(e.api_base_url,F),ingressToken:e.worker_jwt,sessionId:F,epoch:e.worker_epoch,heartbeatIntervalMs:M.heartbeat_interval_ms,heartbeatJitterFraction:M.heartbeat_jitter_fraction,initialSequenceNum:t,getAuthToken:()=>e.worker_jwt,outboundOnly:C}),K){R.close();return}$(),R.connect(),X=setTimeout(Z,M.connect_timeout_ms,Y),Q.scheduleFromExpiresIn(F,e.expires_in),fe()}finally{W.drop()}}async function de(){if(!q){q=!0,S?.(`reconnecting`,`JWT expired — refreshing`),s(`[remote-bridge] 401 on SSE — attempting JWT refresh`);try{let e=o();c&&await c(e??``);let t=o()??e;if(!t||K){K||S?.(`failed`,`JWT refresh failed: no OAuth token`);return}let r=await z(()=>B(F,n,t,M.http_timeout_ms),`fetchRemoteCredentials (recovery)`,M);if(!r||K){K||S?.(`failed`,`JWT refresh failed after 401`);return}G=!1,await ue(r,`auth_401_recovery`),s(`[remote-bridge] Transport rebuilt after 401`)}catch(e){s(`[remote-bridge] 401 recovery failed: ${a(e)}`,{level:`error`}),p(`error`,`bridge_repl_v2_jwt_refresh_failed`),K||S?.(`failed`,`JWT refresh failed: ${a(e)}`)}finally{q=!1}}}$(),f&&f.length>0&&W.start(),R.connect(),X=setTimeout(Z,M.connect_timeout_ms,Y);function fe(){let e=W.end();if(e.length===0)return;for(let t of e)H.add(t.uuid);let t=u(e).map(e=>({...e,session_id:F}));D(e)&&R.reportState(`running`),s(`[remote-bridge] Drained ${e.length} queued message(s) after flush`),R.writeBatch(t)}async function pe(e){let t=e.filter(E),n=d>0&&t.length>d?t.slice(-d):t;n.length<t.length&&s(`[remote-bridge] Capped initial flush: ${t.length} -> ${n.length} (cap=${d})`);let r=u(n).map(e=>({...e,session_id:F}));if(r.length===0)return;let i=t.at(-1);i&&ie(i)&&R.reportState(`running`),s(`[remote-bridge] Flushing ${r.length} history events`),await R.writeBatch(r)}async function me(){if(K)return;K=!0,Q.cancelAll(),clearTimeout(X),W.drop(),R.reportState(`idle`);let e={...O(F),session_id:F};R.write(e);let t=o(),i=await V(F,n,t,r,M.teardown_archive_timeout_ms);if(i===401&&c)try{await c(t??``),t=o(),i=await V(F,n,t,r,M.teardown_archive_timeout_ms)}catch(e){s(`[remote-bridge] Teardown 401 retry threw: ${a(e)}`,{level:`error`})}R.close();let l=i===`no_token`?`skipped_no_token`:i===`timeout`||i===`error`?`network_error`:i>=500?`server_5xx`:i>=400?`server_4xx`:`ok`;s(`[remote-bridge] Torn down (archive=${i})`),p(`info`,`bridge_repl_v2_teardown`),h(`tengu_bridge_repl_teardown`,{v2:!0,archive_status:l,archive_ok:typeof i==`number`&&i<400,archive_http_status:typeof i==`number`?i:void 0,archive_timeout:i===`timeout`,archive_no_token:i===`no_token`})}let he=l(me);return h(`tengu_bridge_repl_started`,{has_initial_messages:!!(f&&f.length>0),v2:!0,expires_in_s:I.expires_in,inProtectedNamespace:t()}),{bridgeSessionId:F,environmentId:``,sessionIngressUrl:I.api_base_url,writeMessages(e){let t=e.filter(e=>E(e)&&!U.has(e.uuid)&&!H.has(e.uuid));if(t.length===0)return;if(!J)for(let e of t){let t=ne(e);if(t!==void 0&&g?.(t,F)){J=!0;break}}if(W.enqueue(...t)){s(`[remote-bridge] Queued ${t.length} message(s) during flush`);return}for(let e of t)H.add(e.uuid);let n=u(t).map(e=>({...e,session_id:F}));D(t)&&R.reportState(`running`),s(`[remote-bridge] Sending ${t.length} message(s)`),R.writeBatch(n)},writeSdkMessages(e){let t=e.filter(e=>!e.uuid||!H.has(e.uuid));if(t.length===0)return;for(let e of t)e.uuid&&H.add(e.uuid);let n=t.map(e=>({...e,session_id:F}));R.writeBatch(n)},sendControlRequest(e){if(q){s(`[remote-bridge] Dropping control_request during 401 recovery: ${e.request_id}`);return}let t={...e,session_id:F};e.request?.subtype===`can_use_tool`&&R.reportState(`requires_action`),R.write(t),s(`[remote-bridge] Sent control_request request_id=${e.request_id}`)},sendControlResponse(e){if(q){s(`[remote-bridge] Dropping control_response during 401 recovery`);return}let t={...e,session_id:F};R.reportState(`running`),R.write(t),s(`[remote-bridge] Sent control_response`)},sendControlCancelRequest(e){if(q){s(`[remote-bridge] Dropping control_cancel_request during 401 recovery: ${e}`);return}let t={type:`control_cancel_request`,request_id:e,session_id:F};R.reportState(`running`),R.write(t),s(`[remote-bridge] Sent control_cancel_request request_id=${e}`)},sendResult(){if(q){s(`[remote-bridge] Dropping result during 401 recovery`);return}R.reportState(`idle`);let e={...O(F),session_id:F};R.write(e),s(`[remote-bridge] Sent result`)},async teardown(){he(),await me()}}}async function z(e,t,n){let r=n.init_retry_max_attempts;for(let i=1;i<=r;i++){let a=await e();if(a!==null)return a;if(i<r){let e=n.init_retry_base_delay_ms*2**(i-1),a=e*n.init_retry_jitter_fraction*(2*Math.random()-1),o=Math.min(e+a,n.init_retry_max_delay_ms);s(`[remote-bridge] ${t} failed (attempt ${i}/${r}), retrying in ${Math.round(o)}ms`),await _(o)}}return null}async function B(e,t,n,r){let i=await F(e,t,n,r,M());return i?S()?{...i,api_base_url:t}:i:null}async function V(e,t,r,i,o){if(!r)return`no_token`;let c=y(e);try{let e=await n.post(`${t}/v1/sessions/${c}/archive`,{},{headers:{...L(r),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":i},timeout:o,validateStatus:()=>!0});return s(`[remote-bridge] Archive ${c} status=${e.status}`),e.status}catch(e){return s(`[remote-bridge] Archive failed: ${a(e)}`),n.isAxiosError(e)&&e.code===`ECONNABORTED`?`timeout`:`error`}}export{R as initEnvLessBridgeCore};
1
+ import{o as e,u as t}from"./envUtils-DcaKZlRU.js";import{n,t as r}from"./axios-DaWTGg7G.js";import{C as i,P as a,R as o,c as s,i as c,nt as l,tt as u,x as d}from"./debug-Dr1SjdXn.js";import{O as f,k as p}from"./git-CoQQ6YEf.js";import{n as m,r as h}from"./analytics-DJobLaWP.js";import{_n as g,vn as _}from"./model-C29_32BD.js";import{c as ee,n as v}from"./sessionState-Bn3ESS5f.js";import{i as y,t as b}from"./sessionIdCompat-DMayYBrf.js";import{a as x,r as S}from"./bridgeConfig-B80T_lw7.js";import{i as C,o as w,s as T}from"./debugUtils-cK-iOsEV.js";import{a as E,c as D,i as te,n as ne,o as O,r as re,s as ie,t as k}from"./bridgeMessaging-DyvHd16Z.js";import{a as ae,r as A,t as oe}from"./flushGate-DWL05x7v.js";import{t as j}from"./workSecret-XLodD7tw.js";import{i as M}from"./trustedDevice-BLiKbGpG.js";import{t as se}from"./jwtUtils-FQWtM6iM.js";e(),u(),f(),m(),g(),b(),v(),r(),c(),o(),d(),w();var N=`2023-06-01`;function P(e){return{Authorization:`Bearer ${e}`,"Content-Type":`application/json`,"anthropic-version":N}}async function ce(e,t,r,o,c){let l=`${e}/v1/code/sessions`,u;try{u=await n.post(l,{title:r,bridge:{},...c?.length?{tags:c}:{}},{headers:P(t),timeout:o,validateStatus:e=>e<500})}catch(e){return s(`[code-session] Session create request failed: ${a(e)}`),null}if(u.status!==200&&u.status!==201){let e=C(u.data);return s(`[code-session] Session create failed ${u.status}${e?`: ${e}`:``}`),null}let d=u.data;return!d||typeof d!=`object`||!(`session`in d)||!d.session||typeof d.session!=`object`||!(`id`in d.session)||typeof d.session.id!=`string`||!d.session.id.startsWith(`cse_`)?(s(`[code-session] No session.id (cse_*) in response: ${i(d).slice(0,200)}`),null):d.session.id}async function F(e,t,r,o,c){let l=`${t}/v1/code/sessions/${e}/bridge`,u=P(r);c&&(u[`X-Trusted-Device-Token`]=c);let d;try{d=await n.post(l,{},{headers:u,timeout:o,validateStatus:e=>e<500})}catch(e){return s(`[code-session] /bridge request failed: ${a(e)}`),null}if(d.status!==200){let e=C(d.data);return s(`[code-session] /bridge failed ${d.status}${e?`: ${e}`:``}`),null}let f=d.data;if(typeof f!=`object`||!f||!(`worker_jwt`in f)||typeof f.worker_jwt!=`string`||!(`expires_in`in f)||typeof f.expires_in!=`number`||!(`api_base_url`in f)||typeof f.api_base_url!=`string`||!(`worker_epoch`in f))return s(`[code-session] /bridge response malformed (need worker_jwt, expires_in, api_base_url, worker_epoch): ${i(f).slice(0,200)}`),null;let p=f.worker_epoch,m=typeof p==`string`?Number(p):p;return typeof m!=`number`||!Number.isFinite(m)||!Number.isSafeInteger(m)?(s(`[code-session] /bridge worker_epoch invalid: ${i(p)}`),null):{worker_jwt:f.worker_jwt,api_base_url:f.api_base_url,expires_in:f.expires_in,worker_epoch:m}}r(),w(),c(),o(),x();var I=`2023-06-01`;function L(e){return{Authorization:`Bearer ${e}`,"Content-Type":`application/json`,"anthropic-version":I}}async function R(e){let{baseUrl:n,orgUUID:r,title:i,getAccessToken:o,onAuth401:c,toSDKMessages:u,initialHistoryCap:d,initialMessages:f,onInboundMessage:m,onUserMessage:g,onPermissionResponse:_,onInterrupt:v,onSetModel:y,onSetMaxThinkingTokens:b,onSetPermissionMode:x,onStateChange:S,outboundOnly:C,tags:w}=e,M=await ae(),N=o();if(!N)return s(`[remote-bridge] No OAuth token`),null;let P=await z(()=>ce(n,N,i,M.http_timeout_ms,w),`createCodeSession`,M);if(!P)return S?.(`failed`,`Session creation failed — see debug log`),T(`v2_session_create_failed`,void 0,!0),null;let F=P;s(`[remote-bridge] Created session ${F}`),p(`info`,`bridge_repl_v2_session_created`);let I=await z(()=>B(F,n,N,M.http_timeout_ms),`fetchRemoteCredentials`,M);if(!I)return S?.(`failed`,`Remote credentials fetch failed — see debug log`),T(`v2_remote_creds_failed`,void 0,!0),V(F,n,N,r,M.http_timeout_ms),null;s(`[remote-bridge] Fetched bridge credentials (expires_in=${I.expires_in}s)`);let L=j(I.api_base_url,F);s(`[remote-bridge] v2 session URL: ${L}`);let R;try{R=await A({sessionUrl:L,ingressToken:I.worker_jwt,sessionId:F,epoch:I.worker_epoch,heartbeatIntervalMs:M.heartbeat_interval_ms,heartbeatJitterFraction:M.heartbeat_jitter_fraction,getAuthToken:()=>I.worker_jwt,outboundOnly:C})}catch(e){return s(`[remote-bridge] v2 transport setup failed: ${a(e)}`,{level:`error`}),S?.(`failed`,`Transport setup failed: ${a(e)}`),T(`v2_transport_setup_failed`,void 0,!0),V(F,n,N,r,M.http_timeout_ms),null}s(`[remote-bridge] v2 transport created (epoch=${I.worker_epoch})`),S?.(`ready`);let H=new k(M.uuid_dedup_buffer_size),U=new Set;if(f)for(let e of f)U.add(e.uuid),H.add(e.uuid);let le=new k(M.uuid_dedup_buffer_size),W=new oe,G=!1,K=!1,q=!1,J=!g,Y=`initial`,X;function Z(e){K||h(`tengu_bridge_repl_connect_timeout`,{v2:!0,elapsed_ms:M.connect_timeout_ms,cause:e})}ee(e=>{K||R.reportMetadata(e)},{replayCurrent:!0});let Q=se({refreshBufferMs:M.token_refresh_buffer_ms,getAccessToken:async()=>{let e=o();return c&&await c(e??``),o()??e},onRefresh:(e,t)=>{(async()=>{if(q||K){s(`[remote-bridge] Recovery already in flight, skipping proactive refresh`);return}q=!0;try{let r=await z(()=>B(e,n,t,M.http_timeout_ms),`fetchRemoteCredentials (proactive)`,M);if(!r||K)return;await ue(r,`proactive_refresh`),s(`[remote-bridge] Transport rebuilt (proactive refresh)`)}catch(e){s(`[remote-bridge] Proactive refresh rebuild failed: ${a(e)}`,{level:`error`}),p(`error`,`bridge_repl_v2_proactive_refresh_failed`),K||S?.(`failed`,`Refresh failed: ${a(e)}`)}finally{q=!1}})()},label:`remote`});Q.scheduleFromExpiresIn(F,I.expires_in);function $(){R.setOnConnect(()=>{if(clearTimeout(X),s(`[remote-bridge] v2 transport connected`),p(`info`,`bridge_repl_v2_transport_connected`),h(`tengu_bridge_repl_ws_connected`,{v2:!0,cause:Y}),!G&&f&&f.length>0){G=!0;let e=R;pe(f).catch(e=>s(`[remote-bridge] flushHistory failed: ${e}`)).finally(()=>{R!==e||K||q||(fe(),S?.(`connected`))})}else W.active||S?.(`connected`)}),R.setOnData(e=>{re(e,H,le,m,_?e=>{R.reportState(`running`),_(e)}:void 0,e=>te(e,{transport:R,sessionId:F,onInterrupt:v,onSetModel:y,onSetMaxThinkingTokens:b,onSetPermissionMode:x,outboundOnly:C}))}),R.setOnClose(e=>{if(clearTimeout(X),!K){if(s(`[remote-bridge] v2 transport closed (code=${e})`),h(`tengu_bridge_repl_ws_closed`,{code:e,v2:!0}),e===401&&!q){de();return}S?.(`failed`,`Transport closed (code ${e})`)}})}async function ue(e,t){Y=t,W.start();try{let t=R.getLastSequenceNum();if(R.close(),R=await A({sessionUrl:j(e.api_base_url,F),ingressToken:e.worker_jwt,sessionId:F,epoch:e.worker_epoch,heartbeatIntervalMs:M.heartbeat_interval_ms,heartbeatJitterFraction:M.heartbeat_jitter_fraction,initialSequenceNum:t,getAuthToken:()=>e.worker_jwt,outboundOnly:C}),K){R.close();return}$(),R.connect(),X=setTimeout(Z,M.connect_timeout_ms,Y),Q.scheduleFromExpiresIn(F,e.expires_in),fe()}finally{W.drop()}}async function de(){if(!q){q=!0,S?.(`reconnecting`,`JWT expired — refreshing`),s(`[remote-bridge] 401 on SSE — attempting JWT refresh`);try{let e=o();c&&await c(e??``);let t=o()??e;if(!t||K){K||S?.(`failed`,`JWT refresh failed: no OAuth token`);return}let r=await z(()=>B(F,n,t,M.http_timeout_ms),`fetchRemoteCredentials (recovery)`,M);if(!r||K){K||S?.(`failed`,`JWT refresh failed after 401`);return}G=!1,await ue(r,`auth_401_recovery`),s(`[remote-bridge] Transport rebuilt after 401`)}catch(e){s(`[remote-bridge] 401 recovery failed: ${a(e)}`,{level:`error`}),p(`error`,`bridge_repl_v2_jwt_refresh_failed`),K||S?.(`failed`,`JWT refresh failed: ${a(e)}`)}finally{q=!1}}}$(),f&&f.length>0&&W.start(),R.connect(),X=setTimeout(Z,M.connect_timeout_ms,Y);function fe(){let e=W.end();if(e.length===0)return;for(let t of e)H.add(t.uuid);let t=u(e).map(e=>({...e,session_id:F}));D(e)&&R.reportState(`running`),s(`[remote-bridge] Drained ${e.length} queued message(s) after flush`),R.writeBatch(t)}async function pe(e){let t=e.filter(E),n=d>0&&t.length>d?t.slice(-d):t;n.length<t.length&&s(`[remote-bridge] Capped initial flush: ${t.length} -> ${n.length} (cap=${d})`);let r=u(n).map(e=>({...e,session_id:F}));if(r.length===0)return;let i=t.at(-1);i&&ie(i)&&R.reportState(`running`),s(`[remote-bridge] Flushing ${r.length} history events`),await R.writeBatch(r)}async function me(){if(K)return;K=!0,Q.cancelAll(),clearTimeout(X),W.drop(),R.reportState(`idle`);let e={...O(F),session_id:F};R.write(e);let t=o(),i=await V(F,n,t,r,M.teardown_archive_timeout_ms);if(i===401&&c)try{await c(t??``),t=o(),i=await V(F,n,t,r,M.teardown_archive_timeout_ms)}catch(e){s(`[remote-bridge] Teardown 401 retry threw: ${a(e)}`,{level:`error`})}R.close();let l=i===`no_token`?`skipped_no_token`:i===`timeout`||i===`error`?`network_error`:i>=500?`server_5xx`:i>=400?`server_4xx`:`ok`;s(`[remote-bridge] Torn down (archive=${i})`),p(`info`,`bridge_repl_v2_teardown`),h(`tengu_bridge_repl_teardown`,{v2:!0,archive_status:l,archive_ok:typeof i==`number`&&i<400,archive_http_status:typeof i==`number`?i:void 0,archive_timeout:i===`timeout`,archive_no_token:i===`no_token`})}let he=l(me);return h(`tengu_bridge_repl_started`,{has_initial_messages:!!(f&&f.length>0),v2:!0,expires_in_s:I.expires_in,inProtectedNamespace:t()}),{bridgeSessionId:F,environmentId:``,sessionIngressUrl:I.api_base_url,writeMessages(e){let t=e.filter(e=>E(e)&&!U.has(e.uuid)&&!H.has(e.uuid));if(t.length===0)return;if(!J)for(let e of t){let t=ne(e);if(t!==void 0&&g?.(t,F)){J=!0;break}}if(W.enqueue(...t)){s(`[remote-bridge] Queued ${t.length} message(s) during flush`);return}for(let e of t)H.add(e.uuid);let n=u(t).map(e=>({...e,session_id:F}));D(t)&&R.reportState(`running`),s(`[remote-bridge] Sending ${t.length} message(s)`),R.writeBatch(n)},writeSdkMessages(e){let t=e.filter(e=>!e.uuid||!H.has(e.uuid));if(t.length===0)return;for(let e of t)e.uuid&&H.add(e.uuid);let n=t.map(e=>({...e,session_id:F}));R.writeBatch(n)},sendControlRequest(e){if(q){s(`[remote-bridge] Dropping control_request during 401 recovery: ${e.request_id}`);return}let t={...e,session_id:F};e.request?.subtype===`can_use_tool`&&R.reportState(`requires_action`),R.write(t),s(`[remote-bridge] Sent control_request request_id=${e.request_id}`)},sendControlResponse(e){if(q){s(`[remote-bridge] Dropping control_response during 401 recovery`);return}let t={...e,session_id:F};R.reportState(`running`),R.write(t),s(`[remote-bridge] Sent control_response`)},sendControlCancelRequest(e){if(q){s(`[remote-bridge] Dropping control_cancel_request during 401 recovery: ${e}`);return}let t={type:`control_cancel_request`,request_id:e,session_id:F};R.reportState(`running`),R.write(t),s(`[remote-bridge] Sent control_cancel_request request_id=${e}`)},sendResult(){if(q){s(`[remote-bridge] Dropping result during 401 recovery`);return}R.reportState(`idle`);let e={...O(F),session_id:F};R.write(e),s(`[remote-bridge] Sent result`)},async teardown(){he(),await me()}}}async function z(e,t,n){let r=n.init_retry_max_attempts;for(let i=1;i<=r;i++){let a=await e();if(a!==null)return a;if(i<r){let e=n.init_retry_base_delay_ms*2**(i-1),a=e*n.init_retry_jitter_fraction*(2*Math.random()-1),o=Math.min(e+a,n.init_retry_max_delay_ms);s(`[remote-bridge] ${t} failed (attempt ${i}/${r}), retrying in ${Math.round(o)}ms`),await _(o)}}return null}async function B(e,t,n,r){let i=await F(e,t,n,r,M());return i?S()?{...i,api_base_url:t}:i:null}async function V(e,t,r,i,o){if(!r)return`no_token`;let c=y(e);try{let e=await n.post(`${t}/v1/sessions/${c}/archive`,{},{headers:{...L(r),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":i},timeout:o,validateStatus:()=>!0});return s(`[remote-bridge] Archive ${c} status=${e.status}`),e.status}catch(e){return s(`[remote-bridge] Archive failed: ${a(e)}`),n.isAxiosError(e)&&e.code===`ECONNABORTED`?`timeout`:`error`}}export{R as initEnvLessBridgeCore};
@@ -1 +1 @@
1
- import{n as e,t}from"./axios-DaWTGg7G.js";import{HT as n,UT as r,ny as i,ry as a}from"./loadAgentsDir-BL93ulMm.js";import{A as o,M as s,O as c,w as l}from"./external-CEp-aPkt.js";import{n as ee,r as te,t as u}from"./lazySchema-B4D4qJVE.js";import{C as d,F as f,N as p,R as m,c as h,i as g,nt as ne,tt as re,x as ie}from"./debug-BecbSVoN.js";import{Hn as _,Kn as v,N as y,P as b,Un as x,Vn as S}from"./settings-D4CpDv2y.js";import{l as C,s as w,u as T}from"./oauth-C9VBDB0Y.js";import{Bt as E,Ot as D,St as O,_n as k,mt as A,vn as j}from"./model-Bgh_r4lg.js";import{n as M,t as N}from"./userAgent-CU7Ndh79.js";import{n as P,r as F,t as I}from"./syncCache-ClP9aBqK.js";import{createHash as L}from"crypto";import{open as R,unlink as z}from"fs/promises";t(),te(),re(),m(),ie(),g(),u(),T(),b(),M(),k(),E(),n(),a();async function B(e,t){return`no_check_needed`}function V(e){return!0}x(),I();var H=ee(()=>l({uuid:o(),checksum:o(),settings:c(o(),s())})),ae=1e4,U=5,W=3600*1e3,G=null,K=null,q=null,J=3e4;function oe(){K||P()&&(K=new Promise(e=>{q=e,setTimeout(()=>{q&&(h(`Remote settings: Loading promise timed out, resolving anyway`),q(),q=null)},J)}))}function se(){return`${C().BASE_API_URL}/api/claude_code/settings`}function Y(e){if(Array.isArray(e))return e.map(Y);if(typeof e==`object`&&e){let t={};for(let n of Object.keys(e).sort())t[n]=Y(e[n]);return t}return e}function ce(e){let t=d(Y(e));return`sha256:${L(`sha256`).update(t).digest(`hex`)}`}function le(){return P()}async function ue(){K&&await K}function de(){try{let{key:e}=O({skipRetrievingKeyFromApiKeyHelper:!0});if(e)return{headers:{"x-api-key":e}}}catch{}let e=D();return e?.accessToken?{headers:{Authorization:`Bearer ${e.accessToken}`,"anthropic-beta":w}}:{headers:{},error:`No authentication available`}}async function fe(e){let t=null;for(let n=1;n<=6;n++){if(t=await pe(e),t.success||t.skipRetry||n>U)return t;let r=i(n);h(`Remote settings: Retry ${n}/${U} after ${r}ms`),await j(r)}return t}async function pe(t){try{await A();let n=de();if(n.error)return{success:!1,error:`Authentication required for remote settings`,skipRetry:!0};let r=se(),i={...n.headers,"User-Agent":N()};t&&(i[`If-None-Match`]=`"${t}"`);let a=await e.get(r,{headers:i,timeout:ae,validateStatus:e=>e===200||e===204||e===304||e===404});if(a.status===304)return h(`Remote settings: Using cached settings (304)`),{success:!0,settings:null,checksum:t};if(a.status===204||a.status===404)return h(`Remote settings: No settings found (${a.status})`),{success:!0,settings:{},checksum:void 0};let o=H().safeParse(a.data);if(!o.success)return h(`Remote settings: Invalid response format - ${o.error.message}`),{success:!1,error:`Invalid remote settings format`};let s=y().safeParse(o.data.settings);return s.success?(h(`Remote settings: Fetched successfully`),{success:!0,settings:s.data,checksum:o.data.checksum}):(h(`Remote settings: Settings validation failed - ${s.error.message}`),{success:!1,error:`Invalid settings structure`})}catch(e){let{kind:t,status:n,message:r}=p(e);if(n===404)return{success:!0,settings:{},checksum:``};switch(t){case`auth`:return{success:!1,error:`Not authorized for remote settings`,skipRetry:!0};case`timeout`:return{success:!1,error:`Remote settings request timeout`};case`network`:return{success:!1,error:`Cannot connect to server`};default:return{success:!1,error:r}}}}async function me(e){try{let t=_(),n=await R(t,`w`,384);try{await n.writeFile(d(e,null,2),{encoding:`utf-8`}),await n.datasync()}finally{await n.close()}h(`Remote settings: Saved to ${t}`)}catch(e){h(`Remote settings: Failed to save - ${e instanceof Error?e.message:`unknown error`}`)}}async function X(){$(),F(),K=null,q=null;try{await z(_())}catch{}}async function Z(){if(!P())return null;let e=S(),t=e?ce(e):void 0;try{let n=await fe(t);if(!n.success)return e?(h(`Remote settings: Using stale cache after fetch failure`),v(e),e):null;if(n.settings===null&&e)return h(`Remote settings: Cache still valid (304 Not Modified)`),v(e),e;let r=n.settings||{};if(Object.keys(r).length>0)return V(await B(e,r))?(v(r),await me(r),h(`Remote settings: Applied new settings successfully`),r):(h(`Remote settings: User rejected new settings, using cached settings`),e);v(r);try{await z(_()),h(`Remote settings: Deleted cached file (404 response)`)}catch(e){f(e)!==`ENOENT`&&h(`Remote settings: Failed to delete cached file - ${e instanceof Error?e.message:`unknown error`}`)}return r}catch{return e?(h(`Remote settings: Using stale cache after error`),v(e),e):null}}async function Q(){P()&&!K&&(K=new Promise(e=>{q=e})),S()&&q&&(q(),q=null);try{let e=await Z();P()&&_e(),e!==null&&r.notifyChange(`policySettings`)}finally{q&&(q(),q=null)}}async function he(){if(await X(),!P()){r.notifyChange(`policySettings`);return}await Z(),h(`Remote settings: Refreshed after auth change`),r.notifyChange(`policySettings`)}async function ge(){if(!P())return;let e=S(),t=e?d(e):null;try{await Z();let e=S();(e?d(e):null)!==t&&(h(`Remote settings: Changed during background poll`),r.notifyChange(`policySettings`))}catch{}}function _e(){G===null&&P()&&(G=setInterval(()=>{ge()},W),G.unref(),ne(async()=>$()))}function $(){G!==null&&(clearInterval(G),G=null)}export{he as a,Q as i,oe as n,ue as o,le as r,X as t};
1
+ import{n as e,t}from"./axios-DaWTGg7G.js";import{CT as n,Lv as r,Rv as i,wT as a}from"./loadAgentsDir-mcRW90aq.js";import{A as o,M as s,O as c,w as l}from"./external-CEp-aPkt.js";import{n as ee,r as te,t as u}from"./lazySchema-B4D4qJVE.js";import{C as d,F as f,N as p,R as m,c as h,i as g,nt as ne,tt as re,x as ie}from"./debug-Dr1SjdXn.js";import{Hn as _,Kn as v,N as y,P as b,Un as x,Vn as S}from"./settings-DiBMs2gM.js";import{l as C,s as w,u as T}from"./oauth-D38aRTUb.js";import{Bt as E,Ot as D,St as O,_n as k,mt as A,vn as j}from"./model-C29_32BD.js";import{n as M,t as N}from"./userAgent-DUrr02yh.js";import{n as P,r as F,t as I}from"./syncCache-BooMjgU6.js";import{createHash as L}from"crypto";import{open as R,unlink as z}from"fs/promises";t(),te(),re(),m(),ie(),g(),u(),T(),b(),M(),k(),E(),n(),i();async function B(e,t){return`no_check_needed`}function V(e){return!0}x(),I();var H=ee(()=>l({uuid:o(),checksum:o(),settings:c(o(),s())})),ae=1e4,U=5,W=3600*1e3,G=null,K=null,q=null,J=3e4;function oe(){K||P()&&(K=new Promise(e=>{q=e,setTimeout(()=>{q&&(h(`Remote settings: Loading promise timed out, resolving anyway`),q(),q=null)},J)}))}function se(){return`${C().BASE_API_URL}/api/claude_code/settings`}function Y(e){if(Array.isArray(e))return e.map(Y);if(typeof e==`object`&&e){let t={};for(let n of Object.keys(e).sort())t[n]=Y(e[n]);return t}return e}function ce(e){let t=d(Y(e));return`sha256:${L(`sha256`).update(t).digest(`hex`)}`}function le(){return P()}async function ue(){K&&await K}function de(){try{let{key:e}=O({skipRetrievingKeyFromApiKeyHelper:!0});if(e)return{headers:{"x-api-key":e}}}catch{}let e=D();return e?.accessToken?{headers:{Authorization:`Bearer ${e.accessToken}`,"anthropic-beta":w}}:{headers:{},error:`No authentication available`}}async function fe(e){let t=null;for(let n=1;n<=6;n++){if(t=await pe(e),t.success||t.skipRetry||n>U)return t;let i=r(n);h(`Remote settings: Retry ${n}/${U} after ${i}ms`),await j(i)}return t}async function pe(t){try{await A();let n=de();if(n.error)return{success:!1,error:`Authentication required for remote settings`,skipRetry:!0};let r=se(),i={...n.headers,"User-Agent":N()};t&&(i[`If-None-Match`]=`"${t}"`);let a=await e.get(r,{headers:i,timeout:ae,validateStatus:e=>e===200||e===204||e===304||e===404});if(a.status===304)return h(`Remote settings: Using cached settings (304)`),{success:!0,settings:null,checksum:t};if(a.status===204||a.status===404)return h(`Remote settings: No settings found (${a.status})`),{success:!0,settings:{},checksum:void 0};let o=H().safeParse(a.data);if(!o.success)return h(`Remote settings: Invalid response format - ${o.error.message}`),{success:!1,error:`Invalid remote settings format`};let s=y().safeParse(o.data.settings);return s.success?(h(`Remote settings: Fetched successfully`),{success:!0,settings:s.data,checksum:o.data.checksum}):(h(`Remote settings: Settings validation failed - ${s.error.message}`),{success:!1,error:`Invalid settings structure`})}catch(e){let{kind:t,status:n,message:r}=p(e);if(n===404)return{success:!0,settings:{},checksum:``};switch(t){case`auth`:return{success:!1,error:`Not authorized for remote settings`,skipRetry:!0};case`timeout`:return{success:!1,error:`Remote settings request timeout`};case`network`:return{success:!1,error:`Cannot connect to server`};default:return{success:!1,error:r}}}}async function me(e){try{let t=_(),n=await R(t,`w`,384);try{await n.writeFile(d(e,null,2),{encoding:`utf-8`}),await n.datasync()}finally{await n.close()}h(`Remote settings: Saved to ${t}`)}catch(e){h(`Remote settings: Failed to save - ${e instanceof Error?e.message:`unknown error`}`)}}async function X(){$(),F(),K=null,q=null;try{await z(_())}catch{}}async function Z(){if(!P())return null;let e=S(),t=e?ce(e):void 0;try{let n=await fe(t);if(!n.success)return e?(h(`Remote settings: Using stale cache after fetch failure`),v(e),e):null;if(n.settings===null&&e)return h(`Remote settings: Cache still valid (304 Not Modified)`),v(e),e;let r=n.settings||{};if(Object.keys(r).length>0)return V(await B(e,r))?(v(r),await me(r),h(`Remote settings: Applied new settings successfully`),r):(h(`Remote settings: User rejected new settings, using cached settings`),e);v(r);try{await z(_()),h(`Remote settings: Deleted cached file (404 response)`)}catch(e){f(e)!==`ENOENT`&&h(`Remote settings: Failed to delete cached file - ${e instanceof Error?e.message:`unknown error`}`)}return r}catch{return e?(h(`Remote settings: Using stale cache after error`),v(e),e):null}}async function Q(){P()&&!K&&(K=new Promise(e=>{q=e})),S()&&q&&(q(),q=null);try{let e=await Z();P()&&_e(),e!==null&&a.notifyChange(`policySettings`)}finally{q&&(q(),q=null)}}async function he(){if(await X(),!P()){a.notifyChange(`policySettings`);return}await Z(),h(`Remote settings: Refreshed after auth change`),a.notifyChange(`policySettings`)}async function ge(){if(!P())return;let e=S(),t=e?d(e):null;try{await Z();let e=S();(e?d(e):null)!==t&&(h(`Remote settings: Changed during background poll`),a.notifyChange(`policySettings`))}catch{}}function _e(){G===null&&P()&&(G=setInterval(()=>{ge()},W),G.unref(),ne(async()=>$()))}function $(){G!==null&&(clearInterval(G),G=null)}export{he as a,Q as i,oe as n,ue as o,le as r,X as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Sr as t,_r as n,ai as r,ci as i,ja as a,za as o}from"./loadAgentsDir-mcRW90aq.js";import{Wt as s,pt as c}from"./state-BPFYBqm1.js";import{a as l,i as u,r as d}from"./bridgeConfig-B80T_lw7.js";import{n as f,t as p}from"./generateSessionName-CdbMksHi.js";async function m(e,t,o){let s;if(!o||o.trim()===``){let n=await p(a(t.messages),t.abortController.signal);if(!n)return e(`Could not generate a name: no conversation context yet. Usage: /rename <name>`,{display:`system`}),null;s=n}else s=o.trim();let l=c(),f=n();await i(l,s,f);let m=t.getAppState().replBridgeSessionId;if(m){let e=u();import(`./createSession-VTqzWAu6.js`).then(({updateBridgeSessionTitle:t})=>t(m,s,{baseUrl:d(),getAccessToken:e?()=>e:void 0}).catch(()=>{}))}return await r(l,s,f),t.setAppState(e=>({...e,standaloneAgentContext:{...e.standaloneAgentContext,name:s}})),e(`Session renamed to: ${s}`,{display:`system`}),null}e((()=>{s(),l(),o(),t(),f()}))();export{m as call};
@@ -1 +1 @@
1
- import{l as e,o as t}from"./envUtils-BDhHQY0-.js";import{o as n,s as r}from"./log-Dauqle-Z.js";import{ReadStream as i}from"tty";import{openSync as a}from"fs";t(),n();var o=null;function s(){if(o!==null)return o;if(process.stdin.isTTY){o=void 0;return}if(e(process.env.CI)){o=void 0;return}if(process.argv.includes(`mcp`)){o=void 0;return}if(process.platform===`win32`){o=void 0;return}try{let e=new i(a(`/dev/tty`,`r`));return e.isTTY=!0,o=e,o}catch(e){r(e),o=void 0;return}}function c(e=!1){let t=s(),n={exitOnCtrlC:e};return t&&(n.stdin=t),n}export{c as t};
1
+ import{l as e,o as t}from"./envUtils-DcaKZlRU.js";import{o as n,s as r}from"./log-27kCA_9u.js";import{ReadStream as i}from"tty";import{openSync as a}from"fs";t(),n();var o=null;function s(){if(o!==null)return o;if(process.stdin.isTTY){o=void 0;return}if(e(process.env.CI)){o=void 0;return}if(process.argv.includes(`mcp`)){o=void 0;return}if(process.platform===`win32`){o=void 0;return}try{let e=new i(a(`/dev/tty`,`r`));return e.isTTY=!0,o=e,o}catch(e){r(e),o=void 0;return}}function c(e=!1){let t=s(),n={exitOnCtrlC:e};return t&&(n.stdin=t),n}export{c as t};
@@ -0,0 +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{$p as i,Au as a,Er as o,Fr as s,Lr as c,MC as l,Mr as u,Mu as d,Sr as f,Ti as p,em as m,hC as h,mC as g,mi as _,mr as v,sr as y,wi as b,wr as x}from"./loadAgentsDir-mcRW90aq.js";import{I as S,P as C,di as w,dr as T,fi as E,ot as D,t as O,ui as k}from"./src-P_wYS_NJ2.js";import{t as A}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as j,et as M,pt as N}from"./state-BPFYBqm1.js";import{o as P,s as F}from"./log-27kCA_9u.js";import{n as I,r as L}from"./modalContext-CUThy6Ph.js";import{a as R,i as z,n as B,o as V,r as H,t as U}from"./crossProjectResume-DxgQVYSi.js";function W(e){switch(e.resultType){case`sessionNotFound`:return`Session ${k.bold(e.arg)} was not found. Run ${k.bold(`/resume`)} without arguments to browse all sessions.`;case`multipleMatches`:return`Found ${e.count} sessions matching ${k.bold(e.arg)}. Run ${k.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)(S,{flexDirection:`column`,children:[(0,Y.jsxs)(C,{dimColor:!0,children:[r.pointer,` /resume `,t]}),(0,Y.jsx)(g,{children:(0,Y.jsx)(C,{children:e})})]})}function K({onDone:e,onResume:t}){let[n,r]=J.useState([]),[i,l]=J.useState([]),[d,f]=J.useState(!0),[p,h]=J.useState(!1),[g,_]=J.useState(!1),{rows:y}=D(),x=L(),w=J.useCallback(async(t,n)=>{f(!0);try{let i=q(t?await u():await c(n),N());if(i.length===0){e(`No conversations found to resume`);return}r(i)}catch{e(`Failed to load conversations`)}finally{f(!1)}},[e]);J.useEffect(()=>{async function e(){let e=await b(M());l(e),w(!1,e)}e()},[w]);let E=J.useCallback(()=>{let e=!g;_(e),w(e,i)},[g,w,i]);async function O(n){let r=m(v(n));if(!r){e(`Failed to resume conversation`);return}let i=o(n)?await s(n):n,a=U(i,g);if(a.isCrossProject){if(a.isSameRepoWorktree){h(!0),t(r,i,`slash_command_picker`);return}let n=await T(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
+ `),{display:`user`});return}h(!0),t(r,i,`slash_command_picker`)}function k(){e(`Resume cancelled`,{display:`system`})}return d?(0,Y.jsxs)(S,{children:[(0,Y.jsx)(a,{}),(0,Y.jsx)(C,{children:` Loading conversations…`})]}):p?(0,Y.jsxs)(S,{children:[(0,Y.jsx)(a,{}),(0,Y.jsx)(C,{children:` Resuming conversation…`})]}):(0,Y.jsx)(R,{logs:n,maxHeight:x?Math.floor(y/2):y-2,onCancel:k,onSelect:O,onLogsChanged:()=>w(g,i),showAllProjects:g,onToggleAllProjects:E,onAgenticSearch:H})}function q(e,t){return e.filter(e=>!e.isSidechain&&v(e)!==t)}var J,Y,X;e((()=>{w(),n(),J=t(E(),1),j(),V(),h(),d(),I(),l(),O(),z(),B(),p(),P(),f(),i(),Y=A(),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){F(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 c(await b(M()));if(a.length===0){let t=`No conversations found to resume.`;return(0,Y.jsx)(G,{message:t,args:i,onDone:()=>e(t)})}let l=m(i);if(l){let e=a.filter(e=>v(e)===l).sort((e,t)=>t.modified.getTime()-e.modified.getTime());if(e.length>0){let t=e[0];return r(l,o(t)?await s(t):t,`slash_command_session_id`),null}let t=await y(l);if(t)return r(l,t,`slash_command_session_id`),null}if(x()){let t=await _(i,{exact:!0});if(t.length===1){let e=t[0],n=v(e);if(n)return r(n,o(e)?await s(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 u=W({resultType:`sessionNotFound`,arg:i});return(0,Y.jsx)(G,{message:u,args:i,onDone:()=>e(u)})}}))();export{X as call,q as filterResumableSessions};
@@ -0,0 +1 @@
1
+ import{a as e,i as t}from"./ripgrep-DQ_ILUJV.js";e();export{t as getRipgrepStatus};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{c as r,o as i}from"./envUtils-BDhHQY0-.js";import{n as a,t as o}from"./defineProperty-C-QyHrDq.js";import{c as s,i as c}from"./debug-BecbSVoN.js";import{r as l,t as u}from"./execFileNoThrow-DHyW8FMX.js";import{o as d,s as f}from"./log-Dauqle-Z.js";import{i as p,o as m}from"./platform-B0uTQc9P.js";import{n as h,r as g}from"./analytics-DJobLaWP.js";import{n as _,t as v}from"./bundledMode--fG1S62b.js";import{f as y,o as b,p as x,r as S}from"./stringUtils-C8PaYpQF.js";import{homedir as C}from"os";import*as w from"path";import{existsSync as T}from"fs";import{execFile as E,spawn as D}from"child_process";import{fileURLToPath as O}from"url";var k,A,j,M=e((()=>{k=O(import.meta.url),A=w.dirname(k),j=(()=>{let e=A.split(w.sep),t=e.lastIndexOf(`dist`);if(t!==-1)return e.slice(0,t+1).join(w.sep);let n=e.lastIndexOf(`src`);return n===-1?A:e.slice(0,n).join(w.sep)})()}));function N(e,t,n){let r=n??process.platform;return T(e)?{mode:`builtin`,command:e,args:[]}:(t===void 0?y(`rg`,[]).cmd:t??`rg`)===`rg`?{mode:`builtin`,command:e,args:[],note:`no ripgrep available on ${r}; install ripgrep via apt/pkg/brew`}:{mode:`system`,command:`rg`,args:[]}}function P(){let e=H();return{rgPath:e.command,rgArgs:e.args,argv0:e.argv0}}function F(e){return e.includes(`os error 11`)||e.includes(`Resource temporarily unavailable`)}function I(e,t,n,r,i=!1){let{rgPath:a,rgArgs:o,argv0:s}=P(),c=i?[`-j`,`1`]:[],l=[...o,...c,...e,t],u=p()===`wsl`?6e4:2e4,d=parseInt(process.env.CLAUDE_CODE_GLOB_TIMEOUT_SECONDS||``,10)||0,f=d>0?d*1e3:u;if(s){let e=D(a,l,{argv0:s,signal:n,windowsHide:!0}),t=``,i=``,o=!1,c=!1;e.stdout?.on(`data`,e=>{o||(t+=e.toString(),t.length>U&&(t=t.slice(0,U),o=!0))}),e.stderr?.on(`data`,e=>{c||(i+=e.toString(),i.length>U&&(i=i.slice(0,U),c=!0))});let u,d=setTimeout(()=>{process.platform===`win32`?e.kill():(e.kill(`SIGTERM`),u=setTimeout(e=>e.kill(`SIGKILL`),5e3,e))},f),p=!1;return e.on(`close`,(e,n)=>{if(!p)if(p=!0,clearTimeout(d),clearTimeout(u),e===0||e===1)r(null,t,i);else{let a=Error(`ripgrep exited with code ${e}`);a.code=e??void 0,a.signal=n??void 0,r(a,t,i)}}),e.on(`error`,e=>{p||(p=!0,clearTimeout(d),clearTimeout(u),r(e,t,i))}),e}return E(a,l,{maxBuffer:U,signal:n,timeout:f,killSignal:process.platform===`win32`?void 0:`SIGKILL`},r)}async function L(e,t,n){await B();let{rgPath:r,rgArgs:i,argv0:a}=P();return new Promise((o,s)=>{let c=D(r,[...i,...e,t],{argv0:a,signal:n,windowsHide:!0,stdio:[`ignore`,`pipe`,`ignore`]}),l=0;c.stdout?.on(`data`,e=>{l+=S(e,`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{c as r,o as i}from"./envUtils-DcaKZlRU.js";import{n as a,t as o}from"./defineProperty-C-QyHrDq.js";import{c as s,i as c}from"./debug-Dr1SjdXn.js";import{r as l,t as u}from"./execFileNoThrow-mXq4K0rl.js";import{o as d,s as f}from"./log-27kCA_9u.js";import{i as p,o as m}from"./platform-Dg1c9F_1.js";import{n as h,r as g}from"./analytics-DJobLaWP.js";import{n as _,t as v}from"./bundledMode--fG1S62b.js";import{f as y,o as b,p as x,r as S}from"./stringUtils-Df-Lnjxd.js";import{homedir as C}from"os";import*as w from"path";import{existsSync as T}from"fs";import{execFile as E,spawn as D}from"child_process";import{fileURLToPath as O}from"url";var k,A,j,M=e((()=>{k=O(import.meta.url),A=w.dirname(k),j=(()=>{let e=A.split(w.sep),t=e.lastIndexOf(`dist`);if(t!==-1)return e.slice(0,t+1).join(w.sep);let n=e.lastIndexOf(`src`);return n===-1?A:e.slice(0,n).join(w.sep)})()}));function N(e,t,n){let r=n??process.platform;return T(e)?{mode:`builtin`,command:e,args:[]}:(t===void 0?y(`rg`,[]).cmd:t??`rg`)===`rg`?{mode:`builtin`,command:e,args:[],note:`no ripgrep available on ${r}; install ripgrep via apt/pkg/brew`}:{mode:`system`,command:`rg`,args:[]}}function P(){let e=H();return{rgPath:e.command,rgArgs:e.args,argv0:e.argv0}}function F(e){return e.includes(`os error 11`)||e.includes(`Resource temporarily unavailable`)}function I(e,t,n,r,i=!1){let{rgPath:a,rgArgs:o,argv0:s}=P(),c=i?[`-j`,`1`]:[],l=[...o,...c,...e,t],u=p()===`wsl`?6e4:2e4,d=parseInt(process.env.CLAUDE_CODE_GLOB_TIMEOUT_SECONDS||``,10)||0,f=d>0?d*1e3:u;if(s){let e=D(a,l,{argv0:s,signal:n,windowsHide:!0}),t=``,i=``,o=!1,c=!1;e.stdout?.on(`data`,e=>{o||(t+=e.toString(),t.length>U&&(t=t.slice(0,U),o=!0))}),e.stderr?.on(`data`,e=>{c||(i+=e.toString(),i.length>U&&(i=i.slice(0,U),c=!0))});let u,d=setTimeout(()=>{process.platform===`win32`?e.kill():(e.kill(`SIGTERM`),u=setTimeout(e=>e.kill(`SIGKILL`),5e3,e))},f),p=!1;return e.on(`close`,(e,n)=>{if(!p)if(p=!0,clearTimeout(d),clearTimeout(u),e===0||e===1)r(null,t,i);else{let a=Error(`ripgrep exited with code ${e}`);a.code=e??void 0,a.signal=n??void 0,r(a,t,i)}}),e.on(`error`,e=>{p||(p=!0,clearTimeout(d),clearTimeout(u),r(e,t,i))}),e}return E(a,l,{maxBuffer:U,signal:n,timeout:f,killSignal:process.platform===`win32`?void 0:`SIGKILL`},r)}async function L(e,t,n){await B();let{rgPath:r,rgArgs:i,argv0:a}=P();return new Promise((o,s)=>{let c=D(r,[...i,...e,t],{argv0:a,signal:n,windowsHide:!0,stdio:[`ignore`,`pipe`,`ignore`]}),l=0;c.stdout?.on(`data`,e=>{l+=S(e,`
2
2
  `)});let u=!1;c.on(`close`,e=>{u||(u=!0,e===0||e===1?o(l):s(Error(`rg --files exited ${e}`)))}),c.on(`error`,e=>{u||(u=!0,s(e))})})}async function R(e,t,n){return await B(),q().catch(e=>{f(e)}),new Promise((r,i)=>{let a=(o,c,l,u)=>{if(!o){r(c.trim().split(`
3
3
  `).map(e=>e.replace(/\r$/,``)).filter(Boolean));return}if(o.code===1){r([]);return}if([`ENOENT`,`EACCES`,`EPERM`].includes(o.code)){i(o);return}if(!u&&F(l)){s(`rg EAGAIN error detected, retrying with single-threaded mode (-j 1)`),g(`tengu_ripgrep_eagain_retry`,{}),I(e,t,n,(e,t,n)=>{a(e,t,n,!0)},!0);return}let d=c&&c.trim().length>0,m=o.signal===`SIGTERM`||o.signal===`SIGKILL`||o.code===`ABORT_ERR`,h=o.code===`ERR_CHILD_PROCESS_STDIO_MAXBUFFER`,_=[];if(d&&(_=c.trim().split(`
4
4
  `).map(e=>e.replace(/\r$/,``)).filter(Boolean),_.length>0&&(m||h)&&(_=_.slice(0,-1))),s(`rg error (signal=${o.signal}, code=${o.code}, stderr: ${l}), ${_.length} results`),o.code!==2&&o.code!==`ABORT_ERR`&&f(o),m&&_.length===0){i(new W(`Ripgrep search timed out after ${p()===`wsl`?60:20} seconds. The search may have matched files but did not complete in time. Try searching a more specific path or pattern.`,_));return}r(_)};I(e,t,n,(e,t,n)=>{a(e,t,n,!1)})})}function z(){let e=H();return{mode:e.mode,path:e.command,working:K?.working??null,note:K?.note??e.note}}async function B(){if(process.platform!==`darwin`||J)return;J=!0;let e=H();if(e.mode!==`builtin`)return;let t=e.command;if((await u(`codesign`,[`-vv`,`-d`,t],{preserveOutputOnError:!1})).stdout.split(`
@@ -1,10 +1,10 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{Ai as r,Bi as i,vm as a,ym as o}from"./loadAgentsDir-BL93ulMm.js";import{n as s,t as c}from"./featureCheck-D6FjD-nt.js";import{a as l,s as u}from"./projectContext-CIxul6vA.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-BpjlK0pG.js";import{a as oe,i as se,o as ce,r as le}from"./sessionObserver-Dv3Ba8eA.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-CnR8IqJM.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`),r(),t)}function Ee(e,n,r){return r?.outputRoot?r.outputRoot:n===`project`?T(r?.cwd??process.cwd(),`.claude`,`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-DcaKZlRU.js";import{dm as r,fm as i,ki as a,zi as o}from"./loadAgentsDir-mcRW90aq.js";import{n as s,t as c}from"./featureCheck-D6FjD-nt.js";import{a as l,s as u}from"./projectContext-BN2ZWzOG.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-BJQ5hwjU.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-Sp8strFv.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`),a(),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(`
5
- `)}function Ae(e){return e.reduce((e,t)=>e+t.confidence,0)/e.length}function je(e,t){let n=new Set([`when`,`with`,`this`,`that`,`user`,`asks`,`for`,`the`,`and`,`run`,`use`,`prefer`,`avoid`]),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 L=e((()=>{n(),i(),x()}));function Me(e,t){if(e.length===0)throw Error(`Cannot generate an agent draft without instincts`);let n=t?.scope??e[0]?.scope??`project`,r=w(t?.name??Fe(e)),i=Re(e),a=t?.description??Ie(e),o=Pe(r,n,t),s=Le({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 Ne(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`),r(),t)}function Pe(e,n,r){return r?.outputRoot?r.outputRoot:n===`project`?T(r?.cwd??process.cwd(),`.claude`,`agents`):r?.globalAgentsDir??T(t(),`agents`)}function Fe(e){return w([`learned`,`agent`,...ze(e,4)].join(`-`))||`learned-agent`}function Ie(e){return(e[0]?.trigger??`Run the learned multi-step workflow`).replace(/\s+/g,` `).slice(0,120)}function Le(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(`, `)}]`,`---`,``,`You are the ${t} learned agent.`,``,`## Triggers`,``,i.map(e=>`- ${e.trigger}`).join(`
5
+ `)}function Ae(e){return e.reduce((e,t)=>e+t.confidence,0)/e.length}function je(e,t){let n=new Set([`when`,`with`,`this`,`that`,`user`,`asks`,`for`,`the`,`and`,`run`,`use`,`prefer`,`avoid`]),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 L=e((()=>{n(),o(),x()}));function Me(e,t){if(e.length===0)throw Error(`Cannot generate an agent draft without instincts`);let n=t?.scope??e[0]?.scope??`project`,r=w(t?.name??Fe(e)),i=Re(e),a=t?.description??Ie(e),o=Pe(r,n,t),s=Le({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 Ne(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`),a(),t)}function Pe(e,n,r){return r?.outputRoot?r.outputRoot:n===`project`?T(r?.cwd??process.cwd(),`.workmate`,`agents`):r?.globalAgentsDir??T(t(),`agents`)}function Fe(e){return w([`learned`,`agent`,...ze(e,4)].join(`-`))||`learned-agent`}function Ie(e){return(e[0]?.trigger??`Run the learned multi-step workflow`).replace(/\s+/g,` `).slice(0,120)}function Le(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(`, `)}]`,`---`,``,`You are the ${t} learned agent.`,``,`## Triggers`,``,i.map(e=>`- ${e.trigger}`).join(`
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{}o(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-B0zucj_c.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,`.claude`,`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,`.claude`,`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,`.claude`,`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
- `):``}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((()=>{a(),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};
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(),o(),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{}i(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-DXO4trhk.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
+ `):``}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};
@@ -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-L7pSIWBT.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-4ZqaCXYy.js";t();export{o as RUNTIME_SESSION_ID,n as getRuntimeTurn,i as initSkillLearning,e as resetRuntimeLLMBookkeeping,r as resetRuntimeObserverForTest,a as runSkillLearningPostSampling};
@@ -0,0 +1 @@
1
+ import{gT as e,yT as t}from"./loadAgentsDir-mcRW90aq.js";t();export{e as SandboxManager};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{EC as t,ST as n,Xu as r,Zu as i,_T as a,gT as o,yT as s}from"./loadAgentsDir-mcRW90aq.js";import{Gt as c,H as l,I as u,Lt as d,P as f,a as p,fi as m,j as h,n as g,r as _,t as v,x as y}from"./src-P_wYS_NJ2.js";import{t as b}from"./jsx-runtime-Bb4Xn-E0.js";import{O as x,Wt as S}from"./state-BPFYBqm1.js";import{f as C,g as w,s as T}from"./settings-DiBMs2gM.js";import{i as E,o as D}from"./platform-Dg1c9F_1.js";import{relative as O}from"path";function k(){let e=o.isSandboxingEnabled(),t=o.checkDependencies(),r=t.warnings.length>0?(0,A.jsx)(u,{marginTop:1,flexDirection:`column`,children:t.warnings.map((e,t)=>(0,A.jsx)(f,{dimColor:!0,children:e},t))}):null;if(!e)return(0,A.jsxs)(u,{flexDirection:`column`,paddingY:1,children:[(0,A.jsx)(f,{color:`subtle`,children:`Sandbox is not enabled`}),r]});let i=o.getFsReadConfig(),a=o.getFsWriteConfig(),s=o.getNetworkRestrictionConfig(),c=o.getAllowUnixSockets(),l=o.getExcludedCommands(),d=o.getLinuxGlobPatternWarnings();return(0,A.jsxs)(u,{flexDirection:`column`,paddingY:1,children:[(0,A.jsxs)(u,{flexDirection:`column`,children:[(0,A.jsx)(f,{bold:!0,color:`permission`,children:`Excluded Commands:`}),(0,A.jsx)(f,{dimColor:!0,children:l.length>0?l.join(`, `):`None`})]}),i.denyOnly.length>0&&(0,A.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,A.jsx)(f,{bold:!0,color:`permission`,children:`Filesystem Read Restrictions:`}),(0,A.jsxs)(f,{dimColor:!0,children:[`Denied: `,i.denyOnly.join(`, `)]}),i.allowWithinDeny&&i.allowWithinDeny.length>0&&(0,A.jsxs)(f,{dimColor:!0,children:[`Allowed within denied: `,i.allowWithinDeny.join(`, `)]})]}),a.allowOnly.length>0&&(0,A.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,A.jsx)(f,{bold:!0,color:`permission`,children:`Filesystem Write Restrictions:`}),(0,A.jsxs)(f,{dimColor:!0,children:[`Allowed: `,a.allowOnly.join(`, `)]}),a.denyWithinAllow.length>0&&(0,A.jsxs)(f,{dimColor:!0,children:[`Denied within allowed: `,a.denyWithinAllow.join(`, `)]})]}),(s.allowedHosts&&s.allowedHosts.length>0||s.deniedHosts&&s.deniedHosts.length>0)&&(0,A.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,A.jsxs)(f,{bold:!0,color:`permission`,children:[`Network Restrictions`,n()?` (Managed)`:``,`:`]}),s.allowedHosts&&s.allowedHosts.length>0&&(0,A.jsxs)(f,{dimColor:!0,children:[`Allowed: `,s.allowedHosts.join(`, `)]}),s.deniedHosts&&s.deniedHosts.length>0&&(0,A.jsxs)(f,{dimColor:!0,children:[`Denied: `,s.deniedHosts.join(`, `)]})]}),c&&c.length>0&&(0,A.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,A.jsx)(f,{bold:!0,color:`permission`,children:`Allowed Unix Sockets:`}),(0,A.jsx)(f,{dimColor:!0,children:c.join(`, `)})]}),d.length>0&&(0,A.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,A.jsx)(f,{bold:!0,color:`warning`,children:`⚠ Warning: Glob patterns not fully supported on Linux`}),(0,A.jsxs)(f,{dimColor:!0,children:[`The following patterns will be ignored: `,d.slice(0,3).join(`, `),d.length>3&&` (${d.length-3} more)`]})]}),r]})}var A,j=e((()=>{m(),v(),s(),A=b()}));function M({depCheck:e}){let t=E()===`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,N.jsxs)(u,{flexDirection:`column`,paddingY:1,gap:1,children:[t&&(0,N.jsx)(u,{flexDirection:`column`,children:(0,N.jsxs)(f,{children:[`seatbelt: `,(0,N.jsx)(f,{color:`success`,children:`built-in (macOS)`})]})}),(0,N.jsxs)(u,{flexDirection:`column`,children:[(0,N.jsxs)(f,{children:[`ripgrep (rg): `,n?(0,N.jsx)(f,{color:`error`,children:`not found`}):(0,N.jsx)(f,{color:`success`,children:`found`})]}),n&&(0,N.jsxs)(f,{dimColor:!0,children:[` `,`· `,t?`brew install ripgrep`:`apt install ripgrep`]})]}),!t&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(u,{flexDirection:`column`,children:[(0,N.jsxs)(f,{children:[`bubblewrap (bwrap):`,` `,r?(0,N.jsx)(f,{color:`error`,children:`not installed`}):(0,N.jsx)(f,{color:`success`,children:`installed`})]}),r&&(0,N.jsxs)(f,{dimColor:!0,children:[` `,`· apt install bubblewrap`]})]}),(0,N.jsxs)(u,{flexDirection:`column`,children:[(0,N.jsxs)(f,{children:[`socat: `,i?(0,N.jsx)(f,{color:`error`,children:`not installed`}):(0,N.jsx)(f,{color:`success`,children:`installed`})]}),i&&(0,N.jsxs)(f,{dimColor:!0,children:[` `,`· apt install socat`]})]}),(0,N.jsxs)(u,{flexDirection:`column`,children:[(0,N.jsxs)(f,{children:[`seccomp filter:`,` `,a?(0,N.jsx)(f,{color:`warning`,children:`not installed`}):(0,N.jsx)(f,{color:`success`,children:`installed`}),a&&(0,N.jsx)(f,{dimColor:!0,children:` (required to block unix domain sockets)`})]}),a&&(0,N.jsxs)(u,{flexDirection:`column`,children:[(0,N.jsxs)(f,{dimColor:!0,children:[` `,`· npm install -g @anthropic-ai/sandbox-runtime`]}),(0,N.jsxs)(f,{dimColor:!0,children:[` `,`· or copy vendor/seccomp/* from sandbox-runtime and set`]}),(0,N.jsxs)(f,{dimColor:!0,children:[` `,`sandbox.seccomp.bpfPath and applyPath in settings.json`]})]})]})]}),o.map(e=>(0,N.jsx)(f,{color:`error`,children:e},e))]})}var N,P=e((()=>{m(),v(),D(),N=b()}));function F({onComplete:e}){let t=o.isSandboxingEnabled(),n=o.areSandboxSettingsLockedByPolicy(),r=o.areUnsandboxedCommandsAllowed();return t?n?(0,L.jsxs)(u,{flexDirection:`column`,paddingY:1,children:[(0,L.jsx)(f,{color:`subtle`,children:`Override settings are managed by a higher-priority configuration and cannot be changed locally.`}),(0,L.jsx)(u,{marginTop:1,children:(0,L.jsxs)(f,{dimColor:!0,children:[`Current setting: `,r?`Allow unsandboxed fallback`:`Strict sandbox mode`]})})]}):(0,L.jsx)(I,{onComplete:e,currentMode:r?`open`:`closed`}):(0,L.jsx)(u,{flexDirection:`column`,paddingY:1,children:(0,L.jsx)(f,{color:`subtle`,children:`Sandbox is not enabled. Enable sandbox to configure override settings.`})})}function I({onComplete:e,currentMode:t}){let[n]=l(),{headerFocused:i,focusHeader:a}=p(),s=h(`success`,n)(`(current)`),c=[{label:t===`open`?`Allow unsandboxed fallback ${s}`:`Allow unsandboxed fallback`,value:`open`},{label:t===`closed`?`Strict sandbox mode ${s}`:`Strict sandbox mode`,value:`closed`}];async function m(t){let n=t;await o.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,L.jsxs)(u,{flexDirection:`column`,paddingY:1,children:[(0,L.jsx)(u,{marginBottom:1,children:(0,L.jsx)(f,{bold:!0,children:`Configure Overrides:`})}),(0,L.jsx)(r,{options:c,onChange:m,onCancel:()=>e(void 0,{display:`skip`}),onUpFromFirstItem:a,isDisabled:i}),(0,L.jsxs)(u,{flexDirection:`column`,marginTop:1,gap:1,children:[(0,L.jsxs)(f,{dimColor:!0,children:[(0,L.jsx)(f,{bold:!0,dimColor:!0,children:`Allow unsandboxed fallback:`}),` `,`When a command fails due to sandbox restrictions, Claude can retry with dangerouslyDisableSandbox to run outside the sandbox (falling back to default permissions).`]}),(0,L.jsxs)(f,{dimColor:!0,children:[(0,L.jsx)(f,{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,L.jsxs)(f,{dimColor:!0,children:[`Learn more:`,` `,(0,L.jsx)(d,{url:`https://code.workmate.com/docs/en/sandboxing#configure-sandboxing`,children:`code.workmate.com/docs/en/sandboxing#configure-sandboxing`})]})]})]})}var L,R=e((()=>{m(),v(),s(),i(),L=b()}));function z({onComplete:e,depCheck:t}){let[n]=l(),r=o.isSandboxingEnabled(),i=o.isAutoAllowBashIfSandboxedEnabled(),a=t.warnings.length>0,s=C().sandbox?.network?.allowAllUnixSockets,u=a&&!s,d=r?i?`auto-allow`:`regular`:`disabled`,f=h(`success`,n)(`(current)`),p=[{label:d===`auto-allow`?`Sandbox BashTool, with auto-allow ${f}`:`Sandbox BashTool, with auto-allow`,value:`auto-allow`},{label:d===`regular`?`Sandbox BashTool, with regular permissions ${f}`:`Sandbox BashTool, with regular permissions`,value:`regular`},{label:d===`disabled`?`No Sandbox ${f}`:`No Sandbox`,value:`disabled`}];async function m(t){switch(t){case`auto-allow`:await o.setSandboxSettings({enabled:!0,autoAllowBashIfSandboxed:!0}),e(`✓ Sandbox enabled with auto-allow for bash commands`);break;case`regular`:await o.setSandboxSettings({enabled:!0,autoAllowBashIfSandboxed:!1}),e(`✓ Sandbox enabled with regular bash permissions`);break;case`disabled`:await o.setSandboxSettings({enabled:!1,autoAllowBashIfSandboxed:!1}),e(`○ Sandbox disabled`);break}}c({"confirm:no":()=>e(void 0,{display:`skip`})},{context:`Settings`});let v=(0,V.jsx)(g,{title:`Mode`,children:(0,V.jsx)(B,{showSocketWarning:u,options:p,onSelect:m,onComplete:e})},`mode`),b=(0,V.jsx)(g,{title:`Overrides`,children:(0,V.jsx)(F,{onComplete:e})},`overrides`),x=(0,V.jsx)(g,{title:`Config`,children:(0,V.jsx)(k,{})},`config`);return(0,V.jsx)(y,{color:`permission`,children:(0,V.jsx)(_,{title:`Sandbox:`,color:`permission`,defaultTab:`Mode`,children:t.errors.length>0?[(0,V.jsx)(g,{title:`Dependencies`,children:(0,V.jsx)(M,{depCheck:t})},`dependencies`)]:[v,...a?[(0,V.jsx)(g,{title:`Dependencies`,children:(0,V.jsx)(M,{depCheck:t})},`dependencies`)]:[],b,x]})})}function B({showSocketWarning:e,options:t,onSelect:n,onComplete:i}){let{headerFocused:a,focusHeader:o}=p();return(0,V.jsxs)(u,{flexDirection:`column`,paddingY:1,children:[e&&(0,V.jsx)(u,{marginBottom:1,children:(0,V.jsx)(f,{color:`warning`,children:`Cannot block unix domain sockets (see Dependencies tab)`})}),(0,V.jsx)(u,{marginBottom:1,children:(0,V.jsx)(f,{bold:!0,children:`Configure Mode:`})}),(0,V.jsx)(r,{options:t,onChange:n,onCancel:()=>i(void 0,{display:`skip`}),onUpFromFirstItem:o,isDisabled:a}),(0,V.jsxs)(u,{flexDirection:`column`,marginTop:1,gap:1,children:[(0,V.jsxs)(f,{dimColor:!0,children:[(0,V.jsx)(f,{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,V.jsxs)(f,{dimColor:!0,children:[`Learn more:`,` `,(0,V.jsx)(d,{url:`https://code.workmate.com/docs/en/sandboxing`,children:`code.workmate.com/docs/en/sandboxing`})]})]})]})}var V,H=e((()=>{m(),v(),t(),s(),w(),i(),j(),P(),R(),V=b()}));async function U(e,t,n){let r=C().theme||`light`,i=E();if(!o.isSupportedPlatform()){let t=i===`wsl`?`Error: Sandboxing requires WSL2. WSL1 is not supported.`:`Error: Sandboxing is currently only supported on macOS, Linux, and WSL2.`;return e(h(`error`,r)(t)),null}let s=o.checkDependencies();if(!o.isPlatformInEnabledList())return e(h(`error`,r)(`Error: Sandboxing is disabled for this platform (${i}) via the enabledPlatforms setting.`)),null;if(o.areSandboxSettingsLockedByPolicy())return e(h(`error`,r)(`Error: Sandbox settings are overridden by a higher-priority configuration and cannot be changed locally.`)),null;let c=n?.trim()||``;if(!c)return(0,W.jsx)(z,{onComplete:e,depCheck:s});if(c){let t=c.split(` `)[0];if(t===`exclude`){let t=c.slice(8).trim();if(!t)return e(h(`error`,r)(`Error: Please provide a command pattern to exclude (e.g., /sandbox exclude "npm run test:*")`)),null;let n=t.replace(/^["']|["']$/g,``);a(n);let i=T(`localSettings`),o=i?O(x(),i):`.workmate/settings.local.json`;return e(h(`success`,r)(`Added "${n}" to excluded commands in ${o}`)),null}else return e(h(`error`,r)(`Error: Unknown subcommand "${t}". Available subcommand: exclude`)),null}return null}var W;e((()=>{m(),S(),H(),v(),D(),s(),w(),W=b()}))();export{U as call};
@@ -0,0 +1 @@
1
+ import{V_ as e,z_ as t}from"./loadAgentsDir-mcRW90aq.js";t();export{e as isSearchExtraToolsEnabled};
@@ -1,2 +1,2 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{GC as n,Sg as r,xg as i}from"./loadAgentsDir-BL93ulMm.js";import{I as a,P as o,Wt as s,fi as c,t as l,x as u}from"./src-P_wYS_NJ2.js";import{t as d}from"./jsx-runtime-Bb4Xn-E0.js";import{c as f,i as p}from"./debug-BecbSVoN.js";import{t as m}from"./lib-BlVGipXx.js";function h({onDone:e}){let t=r(e=>e.remoteSessionUrl),[n,i]=(0,_.useState)(``);if((0,_.useEffect)(()=>{if(!t)return;let e=t;async function n(){let t=await(0,g.toString)(e,{type:`utf8`,errorCorrectionLevel:`L`});i(t)}n().catch(e=>{f(`QR code generation failed`,e)})},[t]),s(`confirm:no`,e,{context:`Confirmation`}),!t)return(0,v.jsxs)(u,{children:[(0,v.jsx)(o,{color:`warning`,children:"Not in remote mode. Start with `claude --remote` to use this command."}),(0,v.jsx)(o,{dimColor:!0,children:`(press esc to close)`})]});let c=n.split(`
2
- `).filter(e=>e.length>0),l=c.length===0;return(0,v.jsxs)(u,{children:[(0,v.jsx)(a,{marginBottom:1,children:(0,v.jsx)(o,{bold:!0,children:`Remote session`})}),l?(0,v.jsx)(o,{dimColor:!0,children:`Generating QR code…`}):c.map((e,t)=>(0,v.jsx)(o,{children:e},t)),(0,v.jsxs)(a,{marginTop:1,children:[(0,v.jsx)(o,{dimColor:!0,children:`Open in browser: `}),(0,v.jsx)(o,{color:`ide`,children:t})]}),(0,v.jsx)(a,{marginTop:1,children:(0,v.jsx)(o,{dimColor:!0,children:`(press esc to close)`})})]})}var g,_,v,y;e((()=>{g=m(),c(),_=t(c(),1),l(),n(),i(),p(),v=d(),y=async e=>(0,v.jsx)(h,{onDone:e})}))();export{y as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{EC as n,ng as r,rg as i}from"./loadAgentsDir-mcRW90aq.js";import{I as a,P as o,Wt as s,fi as c,t as l,x as u}from"./src-P_wYS_NJ2.js";import{t as d}from"./jsx-runtime-Bb4Xn-E0.js";import{c as f,i as p}from"./debug-Dr1SjdXn.js";import{t as m}from"./lib-BlVGipXx.js";function h({onDone:e}){let t=i(e=>e.remoteSessionUrl),[n,r]=(0,_.useState)(``);if((0,_.useEffect)(()=>{if(!t)return;let e=t;async function n(){let t=await(0,g.toString)(e,{type:`utf8`,errorCorrectionLevel:`L`});r(t)}n().catch(e=>{f(`QR code generation failed`,e)})},[t]),s(`confirm:no`,e,{context:`Confirmation`}),!t)return(0,v.jsxs)(u,{children:[(0,v.jsx)(o,{color:`warning`,children:"Not in remote mode. Start with `claude --remote` to use this command."}),(0,v.jsx)(o,{dimColor:!0,children:`(press esc to close)`})]});let c=n.split(`
2
+ `).filter(e=>e.length>0),l=c.length===0;return(0,v.jsxs)(u,{children:[(0,v.jsx)(a,{marginBottom:1,children:(0,v.jsx)(o,{bold:!0,children:`Remote session`})}),l?(0,v.jsx)(o,{dimColor:!0,children:`Generating QR code…`}):c.map((e,t)=>(0,v.jsx)(o,{children:e},t)),(0,v.jsxs)(a,{marginTop:1,children:[(0,v.jsx)(o,{dimColor:!0,children:`Open in browser: `}),(0,v.jsx)(o,{color:`ide`,children:t})]}),(0,v.jsx)(a,{marginTop:1,children:(0,v.jsx)(o,{dimColor:!0,children:`(press esc to close)`})})]})}var g,_,v,y;e((()=>{g=m(),c(),_=t(c(),1),l(),n(),r(),p(),v=d(),y=async e=>(0,v.jsx)(h,{onDone:e})}))();export{y as call};
@@ -0,0 +1 @@
1
+ import{oh as e,sh as t}from"./loadAgentsDir-mcRW90aq.js";e();export{t as registerSessionFileAccessHooks};
@@ -1,5 +1,5 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$ as t,_v as n,et as r}from"./loadAgentsDir-BL93ulMm.js";import{at as i}from"./sessionState-D-SaBzWD.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 n=e.slice(-30),a=S(n),s=P(o().llm.timeoutMs),c;try{let e=await r({systemPrompt:i([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,n);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-B0zucj_c.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
- `)}\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(),n(),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.
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$ as t,Q as n,Q_ as r}from"./loadAgentsDir-mcRW90aq.js";import{at as i}from"./sessionState-Bn3ESS5f.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,n){if(e.length===0)return[];if(Date.now()<L)return x(e,n);let r=e.slice(-30),a=S(r),s=P(o().llm.timeoutMs),c;try{let e=await t({systemPrompt:i([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,n)}let l=E(c,n,r);return l.length===0?(I++,I>=o().llm.failureThreshold&&(L=Date.now()+o().llm.circuitCooldownMs),x(e,n)):l}async function x(e,t){try{let{heuristicObserverBackend:n}=await import(`./sessionObserver-DXO4trhk.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
+ `)}\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((()=>{n(),r(),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:
5
5
 
@@ -0,0 +1 @@
1
+ import{n as e,r as t}from"./sessionObserver-BJQ5hwjU.js";t();export{e as heuristicObserverBackend};
@@ -1,4 +1,4 @@
1
- import{n as e,r as t}from"./rolldown-runtime-DaDcL9Zw.js";import{l as n,o as r}from"./envUtils-BDhHQY0-.js";import{t as i}from"./semver-DQo45qGo.js";import{Wt as a,Xn as o,mt as s,pt as c,z as l}from"./state-BemZdQIl.js";import{P as u,R as d,c as f,f as p,i as m,nt as h,tt as g,u as _}from"./debug-BecbSVoN.js";import{O as ee,k as te}from"./git-DBlOv64X.js";import{Dr as ne,Er as re,Or as ie,Tr as v}from"./model-Bgh_r4lg.js";import{randomUUID as y}from"crypto";function b(){return x||(x=i()),x}function ae(e,t){return typeof Bun<`u`?Bun.semver.order(e,t)===1:b().gt(e,t,{loose:!0})}function oe(e,t){return typeof Bun<`u`?Bun.semver.order(e,t)>=0:b().gte(e,t,{loose:!0})}function se(e,t){return typeof Bun<`u`?Bun.semver.order(e,t)===-1:b().lt(e,t,{loose:!0})}function ce(e,t){return typeof Bun<`u`?Bun.semver.satisfies(e,t):b().satisfies(e,t,{loose:!0})}var x,le=e((()=>{})),ue=e((()=>{})),de,fe=e((()=>{de={input_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,output_tokens:0,server_tool_use:{web_search_requests:0,web_fetch_requests:0},service_tier:`standard`,cache_creation:{ephemeral_1h_input_tokens:0,ephemeral_5m_input_tokens:0},inference_geo:``,iterations:[],speed:`standard`}})),pe=e((()=>{}));function me(e){return e}var he=e((()=>{})),ge=e((()=>{ue(),fe(),pe(),he()}));function _e(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function ve(e){if(process.env.OPENAI_MODEL)return process.env.OPENAI_MODEL;let t=e.replace(/\[1m\]$/,``),n=_e(t);if(n){let e=`OPENAI_DEFAULT_${n.toUpperCase()}_MODEL`,t=process.env[e];if(t)return t;let r=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i}return ye[t]??t}var ye,be=e((()=>{ye={"claude-sonnet-4-20250514":`gpt-4o`,"claude-sonnet-4-5-20250929":`gpt-4o`,"claude-sonnet-4-6":`gpt-4o`,"claude-opus-4-20250514":`o3`,"claude-opus-4-1-20250805":`o3`,"claude-opus-4-5-20251101":`o3`,"claude-opus-4-6":`o3`,"claude-haiku-4-5-20251001":`gpt-4o-mini`,"claude-3-5-haiku-20241022":`gpt-4o-mini`,"claude-3-7-sonnet-20250219":`gpt-4o`,"claude-3-5-sonnet-20241022":`gpt-4o`}}));function xe(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function Se(){let e=process.env.GROK_MODEL_MAP;if(!e)return null;try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t}catch{}return null}function Ce(e){if(process.env.GROK_MODEL)return process.env.GROK_MODEL;let t=e.replace(/\[1m\]$/,``),n=xe(t),r=Se();if(r&&n&&r[n])return r[n];if(n){let e=`GROK_DEFAULT_${n.toUpperCase()}_MODEL`,t=process.env[e];if(t)return t;let r=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i}return S[t]?S[t]:n&&C[n]?C[n]:t}var S,C,we=e((()=>{S={"claude-sonnet-4-20250514":`grok-3-mini-fast`,"claude-sonnet-4-5-20250929":`grok-3-mini-fast`,"claude-sonnet-4-6":`grok-3-mini-fast`,"claude-opus-4-20250514":`grok-4.20-reasoning`,"claude-opus-4-1-20250805":`grok-4.20-reasoning`,"claude-opus-4-5-20251101":`grok-4.20-reasoning`,"claude-opus-4-6":`grok-4.20-reasoning`,"claude-haiku-4-5-20251001":`grok-3-mini-fast`,"claude-3-5-haiku-20241022":`grok-3-mini-fast`,"claude-3-7-sonnet-20250219":`grok-3-mini-fast`,"claude-3-5-sonnet-20241022":`grok-3-mini-fast`},C={opus:`grok-4.20-reasoning`,sonnet:`grok-3-mini-fast`,haiku:`grok-3-mini-fast`}}));function Te(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function Ee(e){if(process.env.GEMINI_MODEL)return process.env.GEMINI_MODEL;let t=e.replace(/\[1m\]$/i,``),n=Te(t);if(!n)return t;let r=`GEMINI_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i;let a=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,o=process.env[a];if(o)return o;throw Error(`Gemini provider requires GEMINI_MODEL or ${r} (or ${a} for backward compatibility) to be configured.`)}var De=e((()=>{})),w,T=e((()=>{w=`_geminiThoughtSignature`}));function E(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Oe(e,t){let n=[],r=new Map;for(let t of e){if(t.type===`assistant`){let e=Me(t);e.parts.length>0&&n.push(e);let i=t.message.content;if(Array.isArray(i))for(let e of i)typeof e!=`string`&&e.type===`tool_use`&&r.set(e.id,e.name);continue}if(t.type===`user`){let e=Ae(t,r);e.parts.length>0&&n.push(e)}}let i=ke(t);return{contents:n,...i?{systemInstruction:{parts:[{text:i}]}}:{}}}function ke(e){return!e||e.length===0?``:e.filter(Boolean).join(`
1
+ import{n as e,r as t}from"./rolldown-runtime-DaDcL9Zw.js";import{l as n,o as r}from"./envUtils-DcaKZlRU.js";import{t as i}from"./semver-DQo45qGo.js";import{Wt as a,Xn as o,mt as s,pt as c,z as l}from"./state-BPFYBqm1.js";import{P as u,R as d,c as f,f as p,i as m,nt as h,tt as g,u as _}from"./debug-Dr1SjdXn.js";import{O as ee,k as te}from"./git-CoQQ6YEf.js";import{Dr as ne,Er as re,Or as ie,Tr as v}from"./model-C29_32BD.js";import{randomUUID as y}from"crypto";function b(){return x||(x=i()),x}function ae(e,t){return typeof Bun<`u`?Bun.semver.order(e,t)===1:b().gt(e,t,{loose:!0})}function oe(e,t){return typeof Bun<`u`?Bun.semver.order(e,t)>=0:b().gte(e,t,{loose:!0})}function se(e,t){return typeof Bun<`u`?Bun.semver.order(e,t)===-1:b().lt(e,t,{loose:!0})}function ce(e,t){return typeof Bun<`u`?Bun.semver.satisfies(e,t):b().satisfies(e,t,{loose:!0})}var x,le=e((()=>{})),ue=e((()=>{})),de,fe=e((()=>{de={input_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,output_tokens:0,server_tool_use:{web_search_requests:0,web_fetch_requests:0},service_tier:`standard`,cache_creation:{ephemeral_1h_input_tokens:0,ephemeral_5m_input_tokens:0},inference_geo:``,iterations:[],speed:`standard`}})),pe=e((()=>{}));function me(e){return e}var he=e((()=>{})),ge=e((()=>{ue(),fe(),pe(),he()}));function _e(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function ve(e){if(process.env.OPENAI_MODEL)return process.env.OPENAI_MODEL;let t=e.replace(/\[1m\]$/,``),n=_e(t);if(n){let e=`OPENAI_DEFAULT_${n.toUpperCase()}_MODEL`,t=process.env[e];if(t)return t;let r=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i}return ye[t]??t}var ye,be=e((()=>{ye={"claude-sonnet-4-20250514":`gpt-4o`,"claude-sonnet-4-5-20250929":`gpt-4o`,"claude-sonnet-4-6":`gpt-4o`,"claude-opus-4-20250514":`o3`,"claude-opus-4-1-20250805":`o3`,"claude-opus-4-5-20251101":`o3`,"claude-opus-4-6":`o3`,"claude-haiku-4-5-20251001":`gpt-4o-mini`,"claude-3-5-haiku-20241022":`gpt-4o-mini`,"claude-3-7-sonnet-20250219":`gpt-4o`,"claude-3-5-sonnet-20241022":`gpt-4o`}}));function xe(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function Se(){let e=process.env.GROK_MODEL_MAP;if(!e)return null;try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t}catch{}return null}function Ce(e){if(process.env.GROK_MODEL)return process.env.GROK_MODEL;let t=e.replace(/\[1m\]$/,``),n=xe(t),r=Se();if(r&&n&&r[n])return r[n];if(n){let e=`GROK_DEFAULT_${n.toUpperCase()}_MODEL`,t=process.env[e];if(t)return t;let r=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i}return S[t]?S[t]:n&&C[n]?C[n]:t}var S,C,we=e((()=>{S={"claude-sonnet-4-20250514":`grok-3-mini-fast`,"claude-sonnet-4-5-20250929":`grok-3-mini-fast`,"claude-sonnet-4-6":`grok-3-mini-fast`,"claude-opus-4-20250514":`grok-4.20-reasoning`,"claude-opus-4-1-20250805":`grok-4.20-reasoning`,"claude-opus-4-5-20251101":`grok-4.20-reasoning`,"claude-opus-4-6":`grok-4.20-reasoning`,"claude-haiku-4-5-20251001":`grok-3-mini-fast`,"claude-3-5-haiku-20241022":`grok-3-mini-fast`,"claude-3-7-sonnet-20250219":`grok-3-mini-fast`,"claude-3-5-sonnet-20241022":`grok-3-mini-fast`},C={opus:`grok-4.20-reasoning`,sonnet:`grok-3-mini-fast`,haiku:`grok-3-mini-fast`}}));function Te(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function Ee(e){if(process.env.GEMINI_MODEL)return process.env.GEMINI_MODEL;let t=e.replace(/\[1m\]$/i,``),n=Te(t);if(!n)return t;let r=`GEMINI_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i;let a=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,o=process.env[a];if(o)return o;throw Error(`Gemini provider requires GEMINI_MODEL or ${r} (or ${a} for backward compatibility) to be configured.`)}var De=e((()=>{})),w,T=e((()=>{w=`_geminiThoughtSignature`}));function E(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Oe(e,t){let n=[],r=new Map;for(let t of e){if(t.type===`assistant`){let e=Me(t);e.parts.length>0&&n.push(e);let i=t.message.content;if(Array.isArray(i))for(let e of i)typeof e!=`string`&&e.type===`tool_use`&&r.set(e.id,e.name);continue}if(t.type===`user`){let e=Ae(t,r);e.parts.length>0&&n.push(e)}}let i=ke(t);return{contents:n,...i?{systemInstruction:{parts:[{text:i}]}}:{}}}function ke(e){return!e||e.length===0?``:e.filter(Boolean).join(`
2
2
 
3
3
  `)}function Ae(e,t){let n=e.message.content;return typeof n==`string`?{role:`user`,parts:D(n)}:Array.isArray(n)?{role:`user`,parts:n.flatMap(e=>je(e,t))}:{role:`user`,parts:[]}}function je(e,t){if(typeof e==`string`)return D(e);if(e.type===`text`)return D(e.text);if(e.type===`tool_result`){let n=e;return[{functionResponse:{name:t.get(n.tool_use_id)??n.tool_use_id,response:Fe(n)}}]}if(e.type===`image`){let t=e.source;if(t?.type===`base64`&&typeof t.data==`string`)return[{inlineData:{mimeType:t.media_type||`image/png`,data:t.data}}];if(t?.type===`url`&&typeof t.url==`string`)return D(`[image: ${t.url}]`)}return[]}function Me(e){let t=e.message.content;if(typeof t==`string`)return{role:`model`,parts:D(t)};if(!Array.isArray(t))return{role:`model`,parts:[]};let n=[];for(let e of t){if(typeof e==`string`){n.push(...D(e));continue}if(e.type===`text`){n.push(...D(e.text,O(e)));continue}if(e.type===`thinking`){let t=Ne(e.thinking,e.signature);t&&n.push(t);continue}if(e.type===`tool_use`){let t=e;n.push({functionCall:{name:t.name,args:Pe(t.input)},...O(e)&&{thoughtSignature:O(e)}})}}return{role:`model`,parts:n}}function D(e,t){return typeof e!=`string`||e.length===0?[]:[{text:e,...t&&{thoughtSignature:t}}]}function Ne(e,t){if(!(typeof e!=`string`||e.length===0))return{text:e,thought:!0,...t&&{thoughtSignature:t}}}function Pe(e){if(typeof e==`string`){let t=E(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:t===null?{}:{value:t}}return e&&typeof e==`object`&&!Array.isArray(e)?e:e===void 0?{}:{value:e}}function Fe(e){let t=Ie(e.content);return t&&typeof t==`object`&&!Array.isArray(t)?e.is_error?{...t,is_error:!0}:t:{result:t,...e.is_error?{is_error:!0}:{}}}function Ie(e){if(typeof e==`string`)return E(e)??e;if(Array.isArray(e)){let t=e.map(e=>typeof e==`string`?e:e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(`
4
4
  `);return E(t)??t}return e??``}function O(e){let t=e[w];return typeof t==`string`&&t.length>0?t:void 0}var Le=e((()=>{T()}));function Re(e){if(typeof e==`string`)return qe.has(e)?e:void 0;if(Array.isArray(e)){let t=e.filter(e=>typeof e==`string`&&qe.has(e)),n=Array.from(new Set(t));return n.length===0?void 0:n.length===1?n[0]:n}}function ze(e){if(e===null)return`null`;if(Array.isArray(e))return`array`;if(typeof e==`string`)return`string`;if(typeof e==`boolean`)return`boolean`;if(typeof e==`number`)return Number.isInteger(e)?`integer`:`number`;if(typeof e==`object`)return`object`}function Be(e){let t=e.map(ze).filter(e=>e!==void 0),n=Array.from(new Set(t));if(n.length!==0)return n.length===1?n[0]:n}function Ve(e){return e===void 0?[`null`]:Array.isArray(e)?e.includes(`null`)?e:[...e,`null`]:e===`null`?e:[e,`null`]}function He(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=Object.entries(e).map(([e,t])=>[e,k(t)]).filter(([,e])=>Object.keys(e).length>0);if(t.length!==0)return Object.fromEntries(t)}function Ue(e){if(!Array.isArray(e))return;let t=e.map(e=>k(e)).filter(e=>Object.keys(e).length>0);return t.length>0?t:void 0}function k(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t=e,n={},r=Re(t.type);t.const===void 0?Array.isArray(t.enum)&&t.enum.length>0&&(n.enum=t.enum,r=r??Be(t.enum)):(n.enum=[t.const],r=r??ze(t.const)),r||(t.properties&&typeof t.properties==`object`?r=`object`:(t.items!==void 0||t.prefixItems!==void 0)&&(r=`array`)),t.nullable===!0&&(r=Ve(r)),r&&(n.type=r),typeof t.title==`string`&&(n.title=t.title),typeof t.description==`string`&&(n.description=t.description),typeof t.format==`string`&&(n.format=t.format),typeof t.pattern==`string`&&(n.pattern=t.pattern),typeof t.minimum==`number`?n.minimum=t.minimum:typeof t.exclusiveMinimum==`number`&&(n.minimum=t.exclusiveMinimum),typeof t.maximum==`number`?n.maximum=t.maximum:typeof t.exclusiveMaximum==`number`&&(n.maximum=t.exclusiveMaximum),typeof t.minItems==`number`&&(n.minItems=t.minItems),typeof t.maxItems==`number`&&(n.maxItems=t.maxItems),typeof t.minLength==`number`&&(n.minLength=t.minLength),typeof t.maxLength==`number`&&(n.maxLength=t.maxLength),typeof t.minProperties==`number`&&(n.minProperties=t.minProperties),typeof t.maxProperties==`number`&&(n.maxProperties=t.maxProperties);let i=He(t.properties);if(i&&(n.properties=i,n.propertyOrdering=Object.keys(i)),Array.isArray(t.required)){let e=t.required.filter(e=>typeof e==`string`);e.length>0&&(n.required=e)}if(typeof t.additionalProperties==`boolean`)n.additionalProperties=t.additionalProperties;else{let e=k(t.additionalProperties);Object.keys(e).length>0&&(n.additionalProperties=e)}let a=k(t.items);Object.keys(a).length>0&&(n.items=a);let o=Ue(t.prefixItems);o&&(n.prefixItems=o);let s=Ue(t.anyOf??t.oneOf);return s&&(n.anyOf=s),n}function We(e){let t=k(e);return Object.keys(t).length>0?t:{type:`object`,properties:{}}}function Ge(e){let t=e.filter(e=>{let t=e.type;return e.type===`custom`||!(`type`in e)||t!==`server`}).map(e=>{let t=e;return{name:t.name||``,description:t.description||``,parametersJsonSchema:We(t.input_schema??{type:`object`,properties:{}})}});return t.length>0?[{functionDeclarations:t}]:[]}function Ke(e){if(!e||typeof e!=`object`)return;let t=e;switch(t.type){case`auto`:return{mode:`AUTO`};case`any`:return{mode:`ANY`};case`tool`:return{mode:`ANY`,allowedFunctionNames:typeof t.name==`string`?[t.name]:void 0};default:return}}var qe,Je=e((()=>{qe=new Set([`string`,`number`,`integer`,`boolean`,`object`,`array`,`null`])}));async function*Ye(e,t){let n=`msg_${y().replace(/-/g,``).slice(0,24)}`,r=!1,i=!1,a=0,o=null,s=!1,c,l=0,u=0,d=0;for await(let i of e){let e=i.usageMetadata;e&&(l=e.promptTokenCount??l,u=(e.candidatesTokenCount??0)+(e.thoughtsTokenCount??0),d=e.cachedContentTokenCount??d),r||(r=!0,yield{type:`message_start`,message:{id:n,type:`message`,role:`assistant`,content:[],model:t,stop_reason:null,stop_sequence:null,usage:{input_tokens:l,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:d}}});let f=i.candidates?.[0],p=f?.content?.parts??[];for(let e of p){if(e.functionCall){o&&(yield{type:`content_block_stop`,index:o.index},o=null),s=!0;let t=a++;yield{type:`content_block_start`,index:t,content_block:{type:`tool_use`,id:`toolu_${y().replace(/-/g,``).slice(0,24)}`,name:e.functionCall.name||``,input:{}}},e.thoughtSignature&&(yield{type:`content_block_delta`,index:t,delta:{type:`signature_delta`,signature:e.thoughtSignature}}),e.functionCall.args&&Object.keys(e.functionCall.args).length>0&&(yield{type:`content_block_delta`,index:t,delta:{type:`input_json_delta`,partial_json:JSON.stringify(e.functionCall.args)}}),yield{type:`content_block_stop`,index:t};continue}let t=Xe(e);if(t){(!o||o.type!==t)&&(o&&(yield{type:`content_block_stop`,index:o.index}),o={index:a++,type:t},yield{type:`content_block_start`,index:o.index,content_block:t===`thinking`?{type:`thinking`,thinking:``,signature:``}:{type:`text`,text:``}}),e.text&&(yield{type:`content_block_delta`,index:o.index,delta:t===`thinking`?{type:`thinking_delta`,thinking:e.text}:{type:`text_delta`,text:e.text}}),e.thoughtSignature&&(yield{type:`content_block_delta`,index:o.index,delta:{type:`signature_delta`,signature:e.thoughtSignature}});continue}e.thoughtSignature&&o&&(yield{type:`content_block_delta`,index:o.index,delta:{type:`signature_delta`,signature:e.thoughtSignature}})}f?.finishReason&&(c=f.finishReason)}r&&(o&&(yield{type:`content_block_stop`,index:o.index}),i||(yield{type:`message_delta`,delta:{stop_reason:Ze(c,s),stop_sequence:null},usage:{input_tokens:l,output_tokens:u,cache_creation_input_tokens:0,cache_read_input_tokens:d}},yield{type:`message_stop`},i=!0))}function Xe(e){return typeof e.text==`string`?e.thought?`thinking`:`text`:null}function Ze(e,t){switch(e){case`MAX_TOKENS`:return`max_tokens`;default:return t?`tool_use`:`end_turn`}}var Qe=e((()=>{}));function $e(e){if(!e||typeof e!=`object`)return null;let t=e,n=0;for(;t&&n<5;){if(t instanceof Error&&`code`in t&&typeof t.code==`string`){let e=t.code,n=ot.has(e);return{code:e,message:t.message,isSSLError:n}}if(t instanceof Error&&`cause`in t&&t.cause!==t)t=t.cause,n++;else break}return null}function et(e){let t=$e(e);return t?.isSSLError?`SSL certificate error (${t.code}). If you are behind a corporate proxy or TLS-intercepting firewall, set NODE_EXTRA_CA_CERTS to your CA bundle path, or ask IT to allowlist *.anthropic.com. Run /doctor for details.`:null}function tt(e){if(e.includes(`<!DOCTYPE html`)||e.includes(`<html`)){let t=e.match(/<title>([^<]+)<\/title>/);return t&&t[1]?t[1].trim():``}return e}function nt(e){let t=e.message;return t?tt(t):``}function rt(e){return typeof e==`object`&&!!e&&`error`in e&&typeof e.error==`object`&&e.error!==null}function it(e){if(!rt(e))return null;let t=e.error,n=t?.error?.message;if(typeof n==`string`&&n.length>0){let e=tt(n);if(e.length>0)return e}let r=t?.message;if(typeof r==`string`&&r.length>0){let e=tt(r);if(e.length>0)return e}return null}function at(e){let t=$e(e);if(t){let{code:e,isSSLError:n}=t;if(e===`ETIMEDOUT`)return`Request timed out. Check your internet connection and proxy settings`;if(n)switch(e){case`UNABLE_TO_VERIFY_LEAF_SIGNATURE`:case`UNABLE_TO_GET_ISSUER_CERT`:case`UNABLE_TO_GET_ISSUER_CERT_LOCALLY`:return`Unable to connect to API: SSL certificate verification failed. Check your proxy or corporate SSL certificates`;case`CERT_HAS_EXPIRED`:return`Unable to connect to API: SSL certificate has expired`;case`CERT_REVOKED`:return`Unable to connect to API: SSL certificate has been revoked`;case`DEPTH_ZERO_SELF_SIGNED_CERT`:case`SELF_SIGNED_CERT_IN_CHAIN`:return`Unable to connect to API: Self-signed certificate detected. Check your proxy or corporate SSL certificates`;case`ERR_TLS_CERT_ALTNAME_INVALID`:case`HOSTNAME_MISMATCH`:return`Unable to connect to API: SSL certificate hostname mismatch`;case`CERT_NOT_YET_VALID`:return`Unable to connect to API: SSL certificate is not yet valid`;default:return`Unable to connect to API: SSL error (${e})`}}if(e.message===`Connection error.`)return t?.code?`Unable to connect to API (${t.code})`:`Unable to connect to API. Check your internet connection`;if(!e.message)return it(e)??`API error (status ${e.status??`unknown`})`;let n=nt(e);return n!==e.message&&n.length>0?n:e.message}var ot,st=e((()=>{ot=new Set([`UNABLE_TO_VERIFY_LEAF_SIGNATURE`,`UNABLE_TO_GET_ISSUER_CERT`,`UNABLE_TO_GET_ISSUER_CERT_LOCALLY`,`CERT_SIGNATURE_FAILURE`,`CERT_NOT_YET_VALID`,`CERT_HAS_EXPIRED`,`CERT_REVOKED`,`CERT_REJECTED`,`CERT_UNTRUSTED`,`DEPTH_ZERO_SELF_SIGNED_CERT`,`SELF_SIGNED_CERT_IN_CHAIN`,`CERT_CHAIN_TOO_LONG`,`PATH_LENGTH_EXCEEDED`,`ERR_TLS_CERT_ALTNAME_INVALID`,`HOSTNAME_MISMATCH`,`ERR_TLS_HANDSHAKE_TIMEOUT`,`ERR_SSL_WRONG_VERSION_NUMBER`,`ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC`])}));function ct(e,t,n){let r=[],i=lt(t);i&&r.push({role:`system`,content:i});for(let t of e)switch(t.type){case`user`:r.push(...ut(t));break;case`assistant`:r.push(...ft(t));break;default:break}return r}function lt(e){return!e||e.length===0?``:e.filter(Boolean).join(`
@@ -0,0 +1 @@
1
+ import{Qr as e,Sr as t,kr as n}from"./loadAgentsDir-mcRW90aq.js";t();export{n as linkSessionToPR,e as recordTranscript};
@@ -1,3 +1,3 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{i as r,t as i}from"./hash-Tu-My5Vp.js";import{join as a}from"path";import{open as o,readdir as s,realpath as c,stat as l}from"fs/promises";import{promisify as u}from"util";import{execFile as d}from"child_process";async function f(e){try{let{stdout:t}=await p(`git`,[`worktree`,`list`,`--porcelain`],{cwd:e,timeout:5e3});return t?t.split(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-DcaKZlRU.js";import{i as r,t as i}from"./hash-Tu-My5Vp.js";import{join as a}from"path";import{open as o,readdir as s,realpath as c,stat as l}from"fs/promises";import{promisify as u}from"util";import{execFile as d}from"child_process";async function f(e){try{let{stdout:t}=await p(`git`,[`worktree`,`list`,`--porcelain`],{cwd:e,timeout:5e3});return t?t.split(`
2
2
  `).filter(e=>e.startsWith(`worktree `)).map(e=>e.slice(9).normalize(`NFC`)):[]}catch{return[]}}var p,m=e((()=>{p=u(d)}));function h(e){return typeof e==`string`&&B.test(e)?e:null}function g(e){if(!e.includes(`\\`))return e;try{return JSON.parse(`"${e}"`)}catch{return e}}function _(e,t){let n=[`"${t}":"`,`"${t}": "`];for(let t of n){let n=e.indexOf(t);if(n<0)continue;let r=n+t.length,i=r;for(;i<e.length;){if(e[i]===`\\`){i+=2;continue}if(e[i]===`"`)return g(e.slice(r,i));i++}}}function v(e,t){let n=[`"${t}":"`,`"${t}": "`],r;for(let t of n){let n=0;for(;;){let i=e.indexOf(t,n);if(i<0)break;let a=i+t.length,o=a;for(;o<e.length;){if(e[o]===`\\`){o+=2;continue}if(e[o]===`"`){r=g(e.slice(a,o));break}o++}n=o+1}}return r}function y(e){let t=0,n=``;for(;t<e.length;){let r=e.indexOf(`
3
3
  `,t),i=r>=0?e.slice(t,r):e.slice(t);if(t=r>=0?r+1:e.length,!(!i.includes(`"type":"user"`)&&!i.includes(`"type": "user"`))&&!i.includes(`"tool_result"`)&&!(i.includes(`"isMeta":true`)||i.includes(`"isMeta": true`))&&!(i.includes(`"isCompactSummary":true`)||i.includes(`"isCompactSummary": true`)))try{let e=JSON.parse(i);if(e.type!==`user`)continue;let t=e.message;if(!t)continue;let r=t.content,a=[];if(typeof r==`string`)a.push(r);else if(Array.isArray(r))for(let e of r)e.type===`text`&&typeof e.text==`string`&&a.push(e.text);for(let e of a){let t=e.replace(/\n/g,` `).trim();if(!t)continue;let r=H.exec(t);if(r){n||(n=r[1]);continue}let i=/<bash-input>([\s\S]*?)<\/bash-input>/.exec(t);if(i)return`! ${i[1].trim()}`;if(!V.test(t))return t.length>200&&(t=t.slice(0,200).trim()+`…`),t}}catch{}}return n||``}async function b(e,t,n){try{let r=await o(e,`r`);try{let e=await r.read(n,0,z,0);if(e.bytesRead===0)return{head:``,tail:``};let i=n.toString(`utf8`,0,e.bytesRead),a=Math.max(0,t-z),o=i;if(a>0){let e=await r.read(n,0,z,a);o=n.toString(`utf8`,0,e.bytesRead)}return{head:i,tail:o}}finally{await r.close()}}catch{return{head:``,tail:``}}}async function x(e){try{let t=await o(e,`r`);try{let e=await t.stat(),n=Buffer.allocUnsafe(z),r=await t.read(n,0,z,0);if(r.bytesRead===0)return null;let i=n.toString(`utf8`,0,r.bytesRead),a=Math.max(0,e.size-z),o=i;if(a>0){let e=await t.read(n,0,z,a);o=n.toString(`utf8`,0,e.bytesRead)}return{mtime:e.mtime.getTime(),size:e.size,head:i,tail:o}}finally{await t.close()}}catch{return null}}function S(e){return Math.abs(i(e)).toString(36)}function C(e){let t=e.replace(/[^a-zA-Z0-9]/g,`-`);if(t.length<=200)return t;let n=typeof Bun<`u`?Bun.hash(e).toString(36):S(e);return`${t.slice(0,200)}-${n}`}function w(){return a(t(),`projects`)}function T(e){return a(w(),C(e))}async function E(e){try{return(await c(e)).normalize(`NFC`)}catch{return e.normalize(`NFC`)}}async function D(e){let t=T(e);try{return await s(t),t}catch{let t=C(e);if(t.length<=200)return;let n=t.slice(0,200),r=w();try{let e=(await s(r,{withFileTypes:!0})).find(e=>e.isDirectory()&&e.name.startsWith(n+`-`));return e?a(r,e.name):void 0}catch{return}}}async function O(e,t){let n=`${e}.jsonl`;if(t){let e=await E(t),r=await D(e);if(r){let t=a(r,n);try{let n=await l(t);if(n.size>0)return{filePath:t,projectPath:e,fileSize:n.size}}catch{}}let i;try{i=await f(e)}catch{i=[]}for(let t of i){if(t===e)continue;let r=await D(t);if(!r)continue;let i=a(r,n);try{let e=await l(i);if(e.size>0)return{filePath:i,projectPath:t,fileSize:e.size}}catch{}}return}let r=w(),i;try{i=await s(r)}catch{return}for(let e of i){let t=a(r,e,n);try{let e=await l(t);if(e.size>0)return{filePath:t,projectPath:void 0,fileSize:e.size}}catch{}}}function k(){return G??(G=Buffer.from(`"compact_boundary"`))}function A(e){try{let t=JSON.parse(e);return t.type!==`system`||t.subtype!==`compact_boundary`?null:{hasPreservedSegment:!!t.compactMetadata?.preservedSegment}}catch{return null}}function j(e,t,n,r){let i=r-n;if(!(i<=0)){if(e.len+i>e.buf.length){let t=Buffer.allocUnsafe(Math.min(Math.max(e.buf.length*2,e.len+i),e.cap));e.buf.copy(t,0,0,e.len),e.buf=t}t.copy(e.buf,e.len,n,r),e.len+=i}}function M(e,t,n,r){return r-n>=t.length&&e.compare(t,0,t.length,n,n+t.length)===0}function N(e,t,n){if(e.straddleSnapCarryLen=0,e.straddleSnapTailEnd=0,e.carryLen===0)return 0;let r=e.carryBuf,i=t.indexOf(J);if(i===-1||i>=n)return 0;let a=i+1;if(M(r,K,0,e.carryLen))e.straddleSnapCarryLen=e.carryLen,e.straddleSnapTailEnd=a,e.lastSnapSrc=null;else if(e.carryLen<K.length)return 0;else{if(M(r,q,0,e.carryLen)){let n=A(r.toString(`utf-8`,0,e.carryLen)+t.toString(`utf-8`,0,i));n?.hasPreservedSegment?e.hasPreservedSegment=!0:n&&(e.out.len=0,e.boundaryStartOffset=e.bufFileOff,e.hasPreservedSegment=!1,e.lastSnapSrc=null)}j(e.out,r,0,e.carryLen),j(e.out,t,0,a)}return e.bufFileOff+=e.carryLen+a,e.carryLen=0,a}function P(e,t,n){let r=t.indexOf(n),i=0,a=0,o=-1,s=-1,c=t.indexOf(J);for(;c!==-1;){let l=c+1;if(r!==-1&&r<a&&(r=t.indexOf(n,a)),M(t,K,a,l))j(e.out,t,i,a),o=a,s=l,i=l;else if(r>=a&&r<Math.min(a+X,l)){let s=A(t.toString(`utf-8`,a,c));s?.hasPreservedSegment?e.hasPreservedSegment=!0:s&&(e.out.len=0,e.boundaryStartOffset=e.bufFileOff+a,e.hasPreservedSegment=!1,e.lastSnapSrc=null,o=-1,e.straddleSnapCarryLen=0,i=a),r=t.indexOf(n,r+n.length)}a=l,c=t.indexOf(J,a)}return j(e.out,t,i,a),{lastSnapStart:o,lastSnapEnd:s,trailStart:a}}function F(e,t,n,r,i){r===-1?e.straddleSnapCarryLen>0&&(e.lastSnapLen=e.straddleSnapCarryLen+e.straddleSnapTailEnd,(e.lastSnapBuf===void 0||e.lastSnapLen>e.lastSnapBuf.length)&&(e.lastSnapBuf=Buffer.allocUnsafe(e.lastSnapLen)),e.carryBuf.copy(e.lastSnapBuf,0,0,e.straddleSnapCarryLen),n.copy(e.lastSnapBuf,e.straddleSnapCarryLen,0,e.straddleSnapTailEnd),e.lastSnapSrc=e.lastSnapBuf):(e.lastSnapLen=i-r,(e.lastSnapBuf===void 0||e.lastSnapLen>e.lastSnapBuf.length)&&(e.lastSnapBuf=Buffer.allocUnsafe(e.lastSnapLen)),t.copy(e.lastSnapBuf,0,r,i),e.lastSnapSrc=e.lastSnapBuf)}function I(e,t,n){e.carryLen=t.length-n,e.carryLen>0&&((e.carryBuf===void 0||e.carryLen>e.carryBuf.length)&&(e.carryBuf=Buffer.allocUnsafe(e.carryLen)),t.copy(e.carryBuf,0,n,t.length))}function L(e){if(e.carryLen>0){let t=e.carryBuf;M(t,K,0,e.carryLen)?(e.lastSnapSrc=t,e.lastSnapLen=e.carryLen):j(e.out,t,0,e.carryLen)}e.lastSnapSrc&&(e.out.len>0&&e.out.buf[e.out.len-1]!==J&&j(e.out,Y,0,1),j(e.out,e.lastSnapSrc,0,e.lastSnapLen))}async function R(e,t){let n=k(),r=U,i={out:{buf:Buffer.allocUnsafe(Math.min(t,8*1024*1024)),len:0,cap:t+1},boundaryStartOffset:0,hasPreservedSegment:!1,lastSnapSrc:null,lastSnapLen:0,lastSnapBuf:void 0,bufFileOff:0,carryLen:0,carryBuf:void 0,straddleSnapCarryLen:0,straddleSnapTailEnd:0},a=Buffer.allocUnsafe(r),s=await o(e,`r`);try{let e=0;for(;e<t;){let{bytesRead:o}=await s.read(a,0,Math.min(r,t-e),e);if(o===0)break;e+=o;let c=N(i,a,o),l;if(i.carryLen>0){let e=i.carryLen+(o-c);l=Buffer.allocUnsafe(e),i.carryBuf.copy(l,0,0,i.carryLen),a.copy(l,i.carryLen,c,o)}else l=a.subarray(c,o);let u=P(i,l,n);F(i,l,a,u.lastSnapStart,u.lastSnapEnd),I(i,l,u.trailStart),i.bufFileOff+=u.trailStart}L(i)}finally{await s.close()}return{boundaryStartOffset:i.boundaryStartOffset,postBoundaryBuf:i.out.buf.subarray(0,i.out.len),hasPreservedSegment:i.hasPreservedSegment}}var z,B,V,H,U,W,G,K,q,J,Y,X,Z=e((()=>{n(),m(),r(),z=65536,B=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,V=/^(?:\s*<[a-z][\w-]*[\s>]|\[Request interrupted by user[^\]]*\])/,H=/<command-name>(.*?)<\/command-name>/,U=1024*1024,W=5*1024*1024,K=Buffer.from(`{"type":"attribution-snapshot"`),q=Buffer.from(`{"type":"system"`),J=10,Y=Buffer.from([J]),X=256}));export{m as _,_ as a,w as c,x as d,R as f,f as g,h,y as i,Z as l,C as m,W as n,v as o,O as p,E as r,D as s,z as t,b as u};
@@ -0,0 +1,14 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$ as t,Da as n,Q as r,Q_ as i,za as a}from"./loadAgentsDir-mcRW90aq.js";import{A as o,w as s}from"./external-CEp-aPkt.js";import{n as c,r as l,t as u}from"./lazySchema-B4D4qJVE.js";import{Wt as d,z as f}from"./state-BPFYBqm1.js";import{c as p,i as m}from"./debug-Dr1SjdXn.js";import{s as h,u as g}from"./types-BJ7qTz75.js";import{n as _,r as v}from"./analytics-DJobLaWP.js";import{at as y}from"./sessionState-Bn3ESS5f.js";function b(e){let t=[];for(let n of e){if(n.type!==`user`&&n.type!==`assistant`||`isMeta`in n&&n.isMeta||`origin`in n&&n.origin&&n.origin.kind!==`human`)continue;let e=n.message.content;if(typeof e==`string`)t.push(e);else if(Array.isArray(e))for(let n of e)`type`in n&&n.type===`text`&&`text`in n&&t.push(n.text)}let n=t.join(`
2
+ `);return n.length>S?n.slice(-1e3):n}async function x(e,r){let i=e.trim();if(!i)return null;try{let e=n((await t({systemPrompt:y([C]),userPrompt:i,outputFormat:{type:`json_schema`,schema:{type:`object`,properties:{title:{type:`string`}},required:[`title`],additionalProperties:!1}},signal:r,options:{querySource:`generate_session_title`,agents:[],isNonInteractiveSession:f(),hasAppendSystemPrompt:!1,mcpTools:[]}})).message.content),a=w().safeParse(g(e)),o=a.success&&a.data.title.trim()||null;return v(`tengu_session_title_generated`,{success:o!==null}),o}catch(e){return p(`generateSessionTitle failed: ${e}`,{level:`error`}),v(`tengu_session_title_generated`,{success:!1}),null}}var S,C,w,T=e((()=>{l(),d(),_(),r(),m(),h(),u(),a(),i(),S=1e3,C=`Generate a concise, sentence-case title (3-7 words) that captures the main topic or goal of this coding session. The title should be clear enough that the user recognizes the session in a list. Use sentence case: capitalize only the first word and proper nouns.
3
+
4
+ Return JSON with a single "title" field.
5
+
6
+ Good examples:
7
+ {"title": "Fix login button on mobile"}
8
+ {"title": "Add OAuth authentication"}
9
+ {"title": "Debug failing CI tests"}
10
+ {"title": "Refactor API client error handling"}
11
+
12
+ Bad (too vague): {"title": "Code changes"}
13
+ Bad (too long): {"title": "Investigate and fix the issue where the login button does not respond on mobile devices"}
14
+ Bad (wrong case): {"title": "Fix Login Button On Mobile"}`,w=c(()=>s({title:o()}))}));export{x as n,T as r,b as t};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-BDhHQY0-.js";import{i as r,l as i,n as a}from"./esm-lWlUmoUA.js";import{A as o,Wt as s,pt as c,st as l,z as u}from"./state-BemZdQIl.js";import{C as d,R as f,S as p,c as m,i as h,x as g}from"./debug-BecbSVoN.js";import{d as _,h as ee}from"./config-aRiTrtCv.js";import{i as te,t as ne}from"./hash-Tu-My5Vp.js";import{Bt as re,jt as ie}from"./model-Bgh_r4lg.js";import{et as ae,ft as oe,rt as se,ut as ce}from"./esm-Ka3lhafK.js";import"path";import"fs";import{createHash as le}from"crypto";import"fs/promises";import{AsyncLocalStorage as ue}from"async_hooks";function de(e){let t=BigInt(58),n=Array(y).fill(v[0]),r=y-1,i=e;for(;i>0n;){let e=Number(i%t);n[r]=v[e],i/=t,r--}return n.join(``)}function fe(e){let t=e.replace(/-/g,``);if(t.length!==32)throw Error(`Invalid UUID hex length: ${t.length}`);return BigInt(`0x`+t)}function pe(e,t){let n=fe(t);return`${e}_${me}${de(n)}`}var v,me,y,he=e((()=>{v=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`,me=`01`,y=22}));function b(e){let n=ge[e],r=process.env[e];return r===void 0?n:t(r)}function x(){let e=_(),t=c(),n={"user.id":e};b(`OTEL_METRICS_INCLUDE_SESSION_ID`)&&(n[`session.id`]=t),b(`OTEL_METRICS_INCLUDE_VERSION`)&&(n[`app.version`]=`0.0.11`);let r=ie();if(r){let e=r.organizationUuid,t=r.emailAddress,i=r.accountUuid;e&&(n[`organization.id`]=e),t&&(n[`user.email`]=t),i&&b(`OTEL_METRICS_INCLUDE_ACCOUNT_UUID`)&&(n[`user.account_uuid`]=i,n[`user.account_id`]=process.env.CLAUDE_CODE_ACCOUNT_TAGGED_ID||pe(`user`,i))}return ce.terminal&&(n[`terminal.type`]=ce.terminal),n}var ge,S=e((()=>{s(),re(),ee(),oe(),n(),he(),ge={OTEL_METRICS_INCLUDE_SESSION_ID:!0,OTEL_METRICS_INCLUDE_VERSION:!1,OTEL_METRICS_INCLUDE_ACCOUNT_UUID:!0}}));function _e(){return t(process.env.OTEL_LOG_USER_PROMPTS)}function ve(e){return _e()?e:`<REDACTED>`}async function C(e,t={}){let n=o();if(!n){w||(w=!0,m(`[3P telemetry] Event dropped (no event logger initialized): ${e}`,{level:`warn`}));return}let r={...x(),"event.name":e,"event.timestamp":new Date().toISOString(),"event.sequence":ye++},i=l();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 ye,w,T=e((()=>{s(),h(),n(),S(),ye=0,w=!1}));function be(){A.clear(),j.clear()}function E(){return t(process.env.ENABLE_BETA_TRACING_DETAILED)&&process.env.BETA_TRACING_ENDPOINT&&u()||!1}function D(e,t=ke){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-DcaKZlRU.js";import{i as r,l as i,n as a}from"./esm-lWlUmoUA.js";import{A as o,Wt as s,pt as c,st as l,z as u}from"./state-BPFYBqm1.js";import{C as d,R as f,S as p,c as m,i as h,x as g}from"./debug-Dr1SjdXn.js";import{d as _,h as ee}from"./config-9rLTDOYW.js";import{i as te,t as ne}from"./hash-Tu-My5Vp.js";import{Bt as re,jt as ie}from"./model-C29_32BD.js";import{et as ae,ft as oe,rt as se,ut as ce}from"./esm-CtQkOk5D.js";import"path";import"fs";import{createHash as le}from"crypto";import"fs/promises";import{AsyncLocalStorage as ue}from"async_hooks";function de(e){let t=BigInt(58),n=Array(y).fill(v[0]),r=y-1,i=e;for(;i>0n;){let e=Number(i%t);n[r]=v[e],i/=t,r--}return n.join(``)}function fe(e){let t=e.replace(/-/g,``);if(t.length!==32)throw Error(`Invalid UUID hex length: ${t.length}`);return BigInt(`0x`+t)}function pe(e,t){let n=fe(t);return`${e}_${me}${de(n)}`}var v,me,y,he=e((()=>{v=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`,me=`01`,y=22}));function b(e){let n=ge[e],r=process.env[e];return r===void 0?n:t(r)}function x(){let e=_(),t=c(),n={"user.id":e};b(`OTEL_METRICS_INCLUDE_SESSION_ID`)&&(n[`session.id`]=t),b(`OTEL_METRICS_INCLUDE_VERSION`)&&(n[`app.version`]=`0.0.13`);let r=ie();if(r){let e=r.organizationUuid,t=r.emailAddress,i=r.accountUuid;e&&(n[`organization.id`]=e),t&&(n[`user.email`]=t),i&&b(`OTEL_METRICS_INCLUDE_ACCOUNT_UUID`)&&(n[`user.account_uuid`]=i,n[`user.account_id`]=process.env.CLAUDE_CODE_ACCOUNT_TAGGED_ID||pe(`user`,i))}return ce.terminal&&(n[`terminal.type`]=ce.terminal),n}var ge,S=e((()=>{s(),re(),ee(),oe(),n(),he(),ge={OTEL_METRICS_INCLUDE_SESSION_ID:!0,OTEL_METRICS_INCLUDE_VERSION:!1,OTEL_METRICS_INCLUDE_ACCOUNT_UUID:!0}}));function _e(){return t(process.env.OTEL_LOG_USER_PROMPTS)}function ve(e){return _e()?e:`<REDACTED>`}async function C(e,t={}){let n=o();if(!n){w||(w=!0,m(`[3P telemetry] Event dropped (no event logger initialized): ${e}`,{level:`warn`}));return}let r={...x(),"event.name":e,"event.timestamp":new Date().toISOString(),"event.sequence":ye++},i=l();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 ye,w,T=e((()=>{s(),h(),n(),S(),ye=0,w=!1}));function be(){A.clear(),j.clear()}function E(){return t(process.env.ENABLE_BETA_TRACING_DETAILED)&&process.env.BETA_TRACING_ENDPOINT&&u()||!1}function D(e,t=ke){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 O(e){return le(`sha256`).update(e).digest(`hex`).slice(0,12)}function xe(e){return`sp_${O(e)}`}function Se(e){return`msg_${O(d(e.message.content))}`}function k(e){let t=e.trim().match(Ae);return t&&t[1]?t[1].trim():null}function Ce(e){let t=[],n=[];for(let r of e){let e=r.message.content;if(typeof e==`string`){let r=k(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=k(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:d(r.content),i=k(e);i?n.push(i):t.push(`[TOOL RESULT: ${r.tool_use_id}]\n${e}`)}}}return{contextParts:t,systemReminders:n}}function we(e,t){if(!E())return;let{content:n,truncated:r}=D(`[USER PROMPT]\n${t}`);e.setAttributes({new_context:n,...r&&{new_context_truncated:!0,new_context_original_length:t.length}})}function Te(e,t,n){if(E()){if(t?.systemPrompt){let n=xe(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),!A.has(n)){A.add(n);let{content:e,truncated:r}=D(t.systemPrompt);C(`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=p(t.tools).map(e=>{let t=d(e),n=O(t);return{name:typeof e.name==`string`?e.name:`unknown`,hash:n,json:t}});e.setAttribute(`tools`,d(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(!A.has(`tool_${t}`)){A.add(`tool_${t}`);let{content:n,truncated:i}=D(r);C(`tool`,{tool_name:se(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=j.get(r),a=0;if(i)for(let e=0;e<n.length;e++){let t=n[e];if(t&&Se(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}=Ce(o);if(t.length>0){let n=t.join(`
4
4
 
@@ -0,0 +1 @@
1
+ import{c as e,g as t,x as n}from"./settings-DiBMs2gM.js";t();export{e as getSettingsForSource,n as updateSettingsForSource};