@readmagic/workmate 0.0.14 → 0.0.15

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 (277) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-DcVnvL_u.js +1 -0
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-0Qdg3Rh7.js +1 -0
  3. package/dist/chunks/{AgentsMdExternalIncludesDialog-D58Vn3SK.js → AgentsMdExternalIncludesDialog-D6DopTxc.js} +1 -1
  4. package/dist/chunks/{App-CeC-2dzL.js → App-BoI5EJry.js} +1 -1
  5. package/dist/chunks/{ApproveApiKey-DFpddLyp.js → ApproveApiKey-BjlQDcMx.js} +1 -1
  6. package/dist/chunks/ApproveApiKey-PWFcscjY.js +1 -0
  7. package/dist/chunks/{BackgroundTasksDialog-9ruzl1jm.js → BackgroundTasksDialog-ClSMkcGp.js} +1 -1
  8. package/dist/chunks/BypassPermissionsModeDialog-KCZv-PXl.js +1 -0
  9. package/dist/chunks/{DiffDialog-LTdtTqsC.js → DiffDialog-BGBkuVIn.js} +1 -1
  10. package/dist/chunks/{Doctor-Yvrzcrvx.js → Doctor-CI04juFO.js} +1 -1
  11. package/dist/chunks/Doctor-DCrqcW68.js +1 -0
  12. package/dist/chunks/{ExitFlow-DH0L3tyY.js → ExitFlow-qrCDVA9i.js} +1 -1
  13. package/dist/chunks/Grove-B-M3DWD3.js +11 -0
  14. package/dist/chunks/{HybridTransport-CEWG9ZRi.js → HybridTransport-n5jji6SI.js} +1 -1
  15. package/dist/chunks/{InvalidConfigDialog-Ue3kJUPJ.js → InvalidConfigDialog-By-j6fHE.js} +1 -1
  16. package/dist/chunks/{InvalidSettingsDialog-BO2AOTVf.js → InvalidSettingsDialog-C_reeMzL.js} +1 -1
  17. package/dist/chunks/{MCPConnectionManager-Ciy9y9VV.js → MCPConnectionManager-BNG7iSlw.js} +1 -1
  18. package/dist/chunks/MCPToolListView-jw0tITfc.js +1 -0
  19. package/dist/chunks/{McpParsingWarnings-BsCDFWci.js → McpParsingWarnings-BeZ3Bn8N.js} +1 -1
  20. package/dist/chunks/{MessageSelector-DY5K0NHd.js → MessageSelector-Ci6N-gCw.js} +1 -1
  21. package/dist/chunks/{Messages-LD6ZO301.js → Messages-D6CRTH2m.js} +2 -2
  22. package/dist/chunks/{Onboarding-w0-VVsDz.js → Onboarding-DDkVEq-G.js} +1 -1
  23. package/dist/chunks/{PromptInputFooterSuggestions-OEXx0Abp.js → PromptInputFooterSuggestions-BlhZuQ5F.js} +1 -1
  24. package/dist/chunks/{PromptInputHelpMenu-DyaUsvNx.js → PromptInputHelpMenu-kKyPIMau.js} +1 -1
  25. package/dist/chunks/{QueryEngine-sH-KjJIq.js → QueryEngine-DXpS0Ytq.js} +1 -1
  26. package/dist/chunks/{REPL-BMH_RItw.js → REPL-D1BCm7cR.js} +15 -15
  27. package/dist/chunks/REPL-JQgCrSEv.js +1 -0
  28. package/dist/chunks/RemoteSessionManager-mWVrdNfS.js +2 -0
  29. package/dist/chunks/{ResumeConversation-BbNrpSFB.js → ResumeConversation-BzTn_1jS.js} +1 -1
  30. package/dist/chunks/{SSETransport-CLiI2qnD.js → SSETransport-D86IVNn1.js} +1 -1
  31. package/dist/chunks/SearchExtraToolsTool-BXIja1MR.js +1 -0
  32. package/dist/chunks/{Settings-B1EI5LOU.js → Settings-D_i8HzEW.js} +2 -2
  33. package/dist/chunks/{TeleportProgress-IB--CbqZ.js → TeleportProgress-CW8mLRy2.js} +1 -1
  34. package/dist/chunks/{TeleportRepoMismatchDialog-KjdlS_gA.js → TeleportRepoMismatchDialog-DZD32R-l.js} +1 -1
  35. package/dist/chunks/TeleportResumeWrapper-BhuUE1aq.js +1 -0
  36. package/dist/chunks/{ThemePicker-BrD_T7xF.js → ThemePicker-ByQZgIbH.js} +1 -1
  37. package/dist/chunks/{TrustDialog-L0rvvpit.js → TrustDialog-BzwibD_8.js} +1 -1
  38. package/dist/chunks/{ValidationErrorsList-QZvtUrAy.js → ValidationErrorsList-Cuq6W2yc.js} +1 -1
  39. package/dist/chunks/{add-dir-CpWXReCi.js → add-dir-BQ-ljgk6.js} +1 -1
  40. package/dist/chunks/{agentDisplay-CrQvGkTT.js → agentDisplay-tRprY4gB.js} +1 -1
  41. package/dist/chunks/agents-DMyQUXwl.js +101 -0
  42. package/dist/chunks/{agents-C99yMsVF.js → agents-Dq4BCf0H.js} +1 -1
  43. package/dist/chunks/{allErrors-uyOMiF9U.js → allErrors-CQWZ6BPw.js} +1 -1
  44. package/dist/chunks/{api-C5I2xwgd.js → api-ClAyS7cQ.js} +1 -1
  45. package/dist/chunks/api-CpD5jeKe.js +1 -0
  46. package/dist/chunks/{auth-BYCRa_mb.js → auth-CWAvPfX7.js} +1 -1
  47. package/dist/chunks/auth-DG5bkWDc.js +1 -0
  48. package/dist/chunks/auth-DuHfQBuH.js +1 -0
  49. package/dist/chunks/backgroundHousekeeping-kf_v7Vfr.js +1 -0
  50. package/dist/chunks/{backgroundHousekeeping-CjD8bACB.js → backgroundHousekeeping-rzQFJiND.js} +2 -2
  51. package/dist/chunks/{branch-BOWBZo5K.js → branch-BWbCrXBJ.js} +1 -1
  52. package/dist/chunks/bridgeConfig-CABsoOum.js +1 -0
  53. package/dist/chunks/{bridgeConfig-CgAVrQfz.js → bridgeConfig-CPHAyzdg.js} +1 -1
  54. package/dist/chunks/{bridgeMessaging-cOFtbkf_.js → bridgeMessaging-vR7uQXB9.js} +1 -1
  55. package/dist/chunks/bridgeStatusUtil-CHTx7XwJ.js +1 -0
  56. package/dist/chunks/{btw-B0UmiVKl.js → btw-IGcgP-Qq.js} +1 -1
  57. package/dist/chunks/caches-Dj1YhqrG.js +1 -0
  58. package/dist/chunks/{caches-wN3JyvNE.js → caches-FP8mGB4k.js} +1 -1
  59. package/dist/chunks/{ccrClient-wtUIz75R.js → ccrClient--8aPutWE.js} +1 -1
  60. package/dist/chunks/claudeDesktop-CB3UCt7U.js +1 -0
  61. package/dist/chunks/{clear-CNzBoL7O.js → clear-CF-FZwpe.js} +1 -1
  62. package/dist/chunks/client-BU7upHOb.js +1 -0
  63. package/dist/chunks/commands-Cr1p7OPH.js +1 -0
  64. package/dist/chunks/{compact-Bj8mdDYN.js → compact-BrJGpEFZ.js} +1 -1
  65. package/dist/chunks/{config-BkbL2e5Q.js → config-BSkuQZNf.js} +1 -1
  66. package/dist/chunks/config-BohF3_IV.js +1 -0
  67. package/dist/chunks/{config-WMxn2jLl.js → config-D78R57VA.js} +1 -1
  68. package/dist/chunks/{context-DB1Ar85E.js → context-DADnwl4t.js} +1 -1
  69. package/dist/chunks/context-noninteractive-BAbzwNxu.js +1 -0
  70. package/dist/chunks/{context-noninteractive-CqnJTDcI.js → context-noninteractive-kACWzgS1.js} +1 -1
  71. package/dist/chunks/{conversation-DOgBzrm0.js → conversation-C8w1DtXk.js} +1 -1
  72. package/dist/chunks/conversation-Ds7zRD0x.js +1 -0
  73. package/dist/chunks/{createSSHSession-Cf2tOgK_.js → createSSHSession-B71Plec6.js} +1 -1
  74. package/dist/chunks/{createSession-DD5YaQKM.js → createSession-BJeDECzt.js} +1 -1
  75. package/dist/chunks/createSession-Bozo4Bu8.js +1 -0
  76. package/dist/chunks/{crossProjectResume-CkiPQYYE.js → crossProjectResume-B1I6YzXr.js} +1 -1
  77. package/dist/chunks/{datadog-DcLf1QpG.js → datadog-C9uqPA6N.js} +1 -1
  78. package/dist/chunks/{diff-dfXWiuLA.js → diff-CzChvQyK.js} +1 -1
  79. package/dist/chunks/{directoryCompletion-BtlRKLzw.js → directoryCompletion-i2oWpaUe.js} +1 -1
  80. package/dist/chunks/doctor-DdvdGkNX.js +1 -0
  81. package/dist/chunks/{entry-wISucmYc.js → entry-BoL8sy1Y.js} +2 -2
  82. package/dist/chunks/{esm-CrJVXrKW.js → esm-DtcV71xh.js} +1 -1
  83. package/dist/chunks/{exit-pjN4EJHV.js → exit-Af27f74w.js} +1 -1
  84. package/dist/chunks/{extraUsage-CwDhpClH.js → extraUsage-DsFwXMAj.js} +1 -1
  85. package/dist/chunks/extractMemories-B1KbTMY0.js +1 -0
  86. package/dist/chunks/{fast-Cuj3bfFm.js → fast-BGU8p2uY.js} +1 -1
  87. package/dist/chunks/fast-CuUjONVV.js +1 -0
  88. package/dist/chunks/{fileSuggestions-Dy2BUZzd.js → fileSuggestions-DU7gmksK.js} +1 -1
  89. package/dist/chunks/{firstPartyEventLogger-D4yuDP-n.js → firstPartyEventLogger-7pAyUdbp.js} +2 -2
  90. package/dist/chunks/firstPartyEventLogger-sMeCTEUW.js +1 -0
  91. package/dist/chunks/{flushGate-B6ecrC4j.js → flushGate-4DfYr-Ru.js} +1 -1
  92. package/dist/chunks/{gemini-BC-BxZmj.js → gemini-Cll4fVQn.js} +1 -1
  93. package/dist/chunks/{generateSessionName-JTR8nPYD.js → generateSessionName-BgGMwpps.js} +1 -1
  94. package/dist/chunks/{githubRepoPathMapping-Bk4FZrng.js → githubRepoPathMapping-Px3_GeD1.js} +1 -1
  95. package/dist/chunks/{goal-B09SOyra.js → goal-D4E2WQVn.js} +1 -1
  96. package/dist/chunks/{grok-BBo3jGfP.js → grok-HF1PHxXb.js} +1 -1
  97. package/dist/chunks/{grove-DsAIY-rZ.js → grove-Bck1zFaD.js} +1 -1
  98. package/dist/chunks/help-DJp61Job.js +1 -0
  99. package/dist/chunks/{hooks-BI4NY5IC.js → hooks-CJ17byYD.js} +7 -7
  100. package/dist/chunks/hooks-CjR3Eq0Z.js +1 -0
  101. package/dist/chunks/{initReplBridge-BYrL6ou1.js → initReplBridge-D09JEKHt.js} +1 -1
  102. package/dist/chunks/install-Dd5fw0cA.js +1 -0
  103. package/dist/chunks/{instrumentation-5cSwEKaF.js → instrumentation-jsPu6qqs.js} +3 -3
  104. package/dist/chunks/{job-rW1mEYtm.js → job-BHhkQbvu.js} +1 -1
  105. package/dist/chunks/{keybindings-B5kUoxvg.js → keybindings-Ch5lzNB8.js} +1 -1
  106. package/dist/chunks/{launchLocalMemory-CPucX8Xj.js → launchLocalMemory-DsaijVcO.js} +1 -1
  107. package/dist/chunks/{launchOnboarding--GCJWeeS.js → launchOnboarding-DHOylaqn.js} +1 -1
  108. package/dist/chunks/loadAgentsDir-8FioUEwX.js +1 -0
  109. package/dist/chunks/{loadAgentsDir-JrGMJN05.js → loadAgentsDir-CwEfQDOw.js} +44 -44
  110. package/dist/chunks/{loadPluginHooks-C4zrlV0u.js → loadPluginHooks-C-Yk5KlI.js} +1 -1
  111. package/dist/chunks/{localSearch-C-stDP9C.js → localSearch-BEnlgSB7.js} +1 -1
  112. package/dist/chunks/localSearch-LcgRjjl3.js +1 -0
  113. package/dist/chunks/{logoV2Utils-J2Sqfube.js → logoV2Utils-DG9GwFjl.js} +1 -1
  114. package/dist/chunks/{magicDocs-Dpe3YhyL.js → magicDocs-qGHR3Cqh.js} +1 -1
  115. package/dist/chunks/{main-C_PDzJdv.js → main-CBVQ8bRm.js} +10 -10
  116. package/dist/chunks/{managedEnv-C8SisyLk.js → managedEnv-3MbOWrVs.js} +1 -1
  117. package/dist/chunks/managedEnv-B4YV3A_y.js +1 -0
  118. package/dist/chunks/{mappers-CMJorgSL.js → mappers-CdY45PDA.js} +1 -1
  119. package/dist/chunks/{mcp-_tBxhPV-.js → mcp-BA8XQ6h1.js} +1 -1
  120. package/dist/chunks/{mcp-SuAh71Ht.js → mcp-DI8pGrqi.js} +1 -1
  121. package/dist/chunks/{mcp-B2mJmWKt.js → mcp-DvY_FibT.js} +3 -3
  122. package/dist/chunks/{memory-DK8bOrUr.js → memory-C2U7CCmM.js} +1 -1
  123. package/dist/chunks/{mode-BhfhEpnW.js → mode-ByV6NqmB.js} +1 -1
  124. package/dist/chunks/{model-BCM7RpVk.js → model-C73ETGu9.js} +1 -1
  125. package/dist/chunks/model-CVG_RRTy.js +1 -0
  126. package/dist/chunks/model-CeG-iOKF.js +1 -0
  127. package/dist/chunks/{modelOptions-DEQat7lU.js → modelOptions-A5jrCUBp.js} +1 -1
  128. package/dist/chunks/{nativeInstaller-xxyUjXbl.js → nativeInstaller-CXFD8LDV.js} +1 -1
  129. package/dist/chunks/{omit-od_CYp5o.js → omit-B65XeX8r.js} +1 -1
  130. package/dist/chunks/{onChangeAppState-CqTb0yEa.js → onChangeAppState-EtUxsgYz.js} +1 -1
  131. package/dist/chunks/{openai-qW8mATAs.js → openai-Dx5mvMjY.js} +1 -1
  132. package/dist/chunks/{partition-CYoWXLNU.js → partition-8vZDG3rY.js} +1 -1
  133. package/dist/chunks/{permissions--iKUbWBw.js → permissions-CJUBfBTr.js} +2 -2
  134. package/dist/chunks/{pidLock-BR4hzYgp.js → pidLock-tjm2n1Nd.js} +2 -2
  135. package/dist/chunks/{plan-DiHCGXhM.js → plan-eFur8bdH.js} +1 -1
  136. package/dist/chunks/{plugin-BeC4D7XF.js → plugin-fYLRLdOY.js} +1 -1
  137. package/dist/chunks/{pluginAutoupdate-Bj-CrFuO.js → pluginAutoupdate-B4w7SSYc.js} +1 -1
  138. package/dist/chunks/{pluginBlocklist-DzOs-RS1.js → pluginBlocklist-CMwb7gmY.js} +1 -1
  139. package/dist/chunks/{pluginCliCommands-DwIGn58t.js → pluginCliCommands-3YCj7Y3Q.js} +1 -1
  140. package/dist/chunks/{pluginFlagging-BzuymJuf.js → pluginFlagging-srvq9H7p.js} +1 -1
  141. package/dist/chunks/{pluginOperations-CP1v-nu0.js → pluginOperations-C7BCR7pw.js} +1 -1
  142. package/dist/chunks/{pluginStartupCheck-BUeBiYVq.js → pluginStartupCheck-BLc0U7W7.js} +1 -1
  143. package/dist/chunks/pluginStartupCheck-nzVDPI1k.js +1 -0
  144. package/dist/chunks/{plugins-D1N31THW.js → plugins-CPtmmDDi.js} +1 -1
  145. package/dist/chunks/poorMode-DD88nPJ4.js +1 -0
  146. package/dist/chunks/{poorMode-D4L_-yWS.js → poorMode-wm2WkPF0.js} +1 -1
  147. package/dist/chunks/{print-DaJi1wF_.js → print-BCud0ukQ.js} +3 -3
  148. package/dist/chunks/{processBashCommand-BGCIqxc9.js → processBashCommand-C9-FonuX.js} +1 -1
  149. package/dist/chunks/{processSlashCommand-qR_j1DE8.js → processSlashCommand-Bi8_1MRC.js} +1 -1
  150. package/dist/chunks/{prompt-DnPppVz8.js → prompt-Bm2EEG4F.js} +1 -1
  151. package/dist/chunks/prompt-CX_v9F3s.js +1 -0
  152. package/dist/chunks/prompt-V0WQJrkO2.js +1 -0
  153. package/dist/chunks/{promptEditor-Cilc9N3L.js → promptEditor-DQ9fpdQD.js} +1 -1
  154. package/dist/chunks/{protocolHandler-DdbiucQa.js → protocolHandler--eQQuSyx.js} +1 -1
  155. package/dist/chunks/{reconciler-Bte4gdP-.js → reconciler-DgQ4y1Vn.js} +1 -1
  156. package/dist/chunks/{refresh-MiZ0acBm.js → refresh-CayVRWUY.js} +1 -1
  157. package/dist/chunks/{registerProtocol-Bpte9dly.js → registerProtocol-DrWIX3Lb.js} +1 -1
  158. package/dist/chunks/{reload-plugins-GdqFZblC.js → reload-plugins-6xcH3dLg.js} +1 -1
  159. package/dist/chunks/{remoteBridgeCore-CAl3_H-O.js → remoteBridgeCore-BnZYGaMH.js} +1 -1
  160. package/dist/chunks/{remoteManagedSettings-BcLJLEr7.js → remoteManagedSettings-CfFmrRze.js} +1 -1
  161. package/dist/chunks/{rename-BDo5qIK0.js → rename-mDtCTbnD.js} +1 -1
  162. package/dist/chunks/{resume-Bbweh2hA.js → resume-DRvz4QFs.js} +1 -1
  163. package/dist/chunks/ripgrep-Di-2j8Ws.js +1 -0
  164. package/dist/chunks/{ripgrep-X5m4gJ-3.js → ripgrep-DsLUmulz.js} +1 -1
  165. package/dist/chunks/{runtimeObserver-CxXxUcrm.js → runtimeObserver-Ba6SM-sI.js} +1 -1
  166. package/dist/chunks/{runtimeObserver-Hjbo43xj.js → runtimeObserver-Dt5sGJVb.js} +2 -2
  167. package/dist/chunks/sandbox-adapter-Cmrd6tBj.js +1 -0
  168. package/dist/chunks/{sandbox-toggle-DmNSThQK.js → sandbox-toggle-DKcw3SbO.js} +1 -1
  169. package/dist/chunks/searchExtraTools-DIgC0CFB.js +1 -0
  170. package/dist/chunks/{session-CkuTMD_4.js → session-COVyD8UU.js} +1 -1
  171. package/dist/chunks/sessionFileAccessHooks-yAPDTrbm.js +1 -0
  172. package/dist/chunks/sessionObserver-BizdPx8P.js +1 -0
  173. package/dist/chunks/{sessionObserver-CvQ6oyoj.js → sessionObserver-iAgSetlC.js} +1 -1
  174. package/dist/chunks/{sessionState-C2REgUrs.js → sessionState-zhvcDpb2.js} +1 -1
  175. package/dist/chunks/sessionStorage-LMY409Ji.js +1 -0
  176. package/dist/chunks/{sessionTitle-2IWcNB8H.js → sessionTitle-QPRly1tZ.js} +1 -1
  177. package/dist/chunks/{sessionTracing-Bm7hQKHA.js → sessionTracing-C4uqAdud.js} +1 -1
  178. package/dist/chunks/settings-BgHApyGL.js +1 -0
  179. package/dist/chunks/{settings-aUygByiZ.js → settings-CvhsRFaT.js} +1 -1
  180. package/dist/chunks/{settingsSync-DgzCU1BZ.js → settingsSync-BGo6dHJo.js} +1 -1
  181. package/dist/chunks/{setup-CvaG4nl5.js → setup-Bjw5VS6x.js} +2 -2
  182. package/dist/chunks/{shadowedRuleDetection-CWCQ5dZ0.js → shadowedRuleDetection-CzRAzcC1.js} +1 -1
  183. package/dist/chunks/{sideQuestion-BoW-xYkh.js → sideQuestion-oIYrx5ar.js} +1 -1
  184. package/dist/chunks/{sinks-ZHKfs6gv.js → sinks-Bje3hCkR.js} +1 -1
  185. package/dist/chunks/sinks-FaljTZ-c.js +1 -0
  186. package/dist/chunks/{skillChangeDetector-C-HWR_8v.js → skillChangeDetector-v6mAYzXX.js} +1 -1
  187. package/dist/chunks/{skillGapStore-CCNeSjIb.js → skillGapStore-CJjt3IW7.js} +2 -2
  188. package/dist/chunks/{skillLifecycle-wU4JDNYQ.js → skillLifecycle-BsgH84vl.js} +2 -2
  189. package/dist/chunks/{skillSearchPanel-Cxr1QQn4.js → skillSearchPanel-CneXymsb.js} +2 -2
  190. package/dist/chunks/{skills-BghnKnNo.js → skills-DZRBy7vT.js} +1 -1
  191. package/dist/chunks/{stats-unp6R0Ah.js → stats-Dq-5qizS.js} +1 -1
  192. package/dist/chunks/{status-BraYBx4N.js → status-BP_R8051.js} +1 -1
  193. package/dist/chunks/status-CZYD3NGb.js +1 -0
  194. package/dist/chunks/{statusNoticeHelpers-Dm1aiibR.js → statusNoticeHelpers-ODrnrLAZ.js} +1 -1
  195. package/dist/chunks/{switcher-BUNSEJ-7.js → switcher-BkGOeIzI.js} +1 -1
  196. package/dist/chunks/switcher-DwKN9daN.js +1 -0
  197. package/dist/chunks/{syncCache-1s9xV8WV.js → syncCache-CpmpvjfC.js} +1 -1
  198. package/dist/chunks/{tasks-BjFot03S.js → tasks-CIUuwrX4.js} +1 -1
  199. package/dist/chunks/{teleport-Dj2Kvbmx.js → teleport-IzyDplC7.js} +1 -1
  200. package/dist/chunks/{templateJobs-CY7GNRo5.js → templateJobs-De57J461.js} +1 -1
  201. package/dist/chunks/{terminalSetup-Ty8T8ePM.js → terminalSetup-DDvQ0K5e.js} +1 -1
  202. package/dist/chunks/{terminalSetup-CpMNk6dc.js → terminalSetup-JJiXmszo.js} +1 -1
  203. package/dist/chunks/{theme-c6grxWNn.js → theme-Nwii7354.js} +1 -1
  204. package/dist/chunks/{toolEventObserver-D7WbjgFR.js → toolEventObserver-Cq-uBb0-.js} +1 -1
  205. package/dist/chunks/{toolPool-O5nkEFb1.js → toolPool-BBU4ll_p.js} +1 -1
  206. package/dist/chunks/trustedDevice-BKzkA7fq.js +1 -0
  207. package/dist/chunks/{trustedDevice-BF78PNK8.js → trustedDevice-DWZxDUxS.js} +1 -1
  208. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-qLfN0tc-.js → useExitOnCtrlCDWithKeybindings-D48aDPG9.js} +1 -1
  209. package/dist/chunks/useMainLoopModel-89eUU13X.js +1 -0
  210. package/dist/chunks/{useManagePlugins-E0Qzj-ws.js → useManagePlugins-EqoQELMT.js} +1 -1
  211. package/dist/chunks/{useMergedTools-B7iYaNwM.js → useMergedTools-BJ4L9QSK.js} +1 -1
  212. package/dist/chunks/{useSearchInput-CsxiM9i0.js → useSearchInput-DkVER3cm.js} +1 -1
  213. package/dist/chunks/{useSettingsErrors-DdVTahNa.js → useSettingsErrors-D3MlQ1GF.js} +1 -1
  214. package/dist/chunks/{userAgent-BggRZ-ZE.js → userAgent-aoe_xVAb.js} +1 -1
  215. package/dist/chunks/{util-Xdy1nOjj.js → util-g-5UX5gH.js} +1 -1
  216. package/dist/chunks/{validatePlugin-Be5aSSnP.js → validatePlugin-CSE8zjZn.js} +1 -1
  217. package/dist/chunks/{vim-cFcxfuac.js → vim-s-wmybpU.js} +1 -1
  218. package/dist/chunks/{workerRegistry-GrD7IAVQ.js → workerRegistry-DGwy0YHB.js} +2 -2
  219. package/dist/chunks/worktree-jjuORs7p.js +1 -0
  220. package/dist/cli.js +1 -1
  221. package/package.json +1 -1
  222. package/dist/chunks/AddWorkspaceDirectory-m2d3nOQJ.js +0 -1
  223. package/dist/chunks/AgentsMdExternalIncludesDialog-BRXGkHO4.js +0 -1
  224. package/dist/chunks/ApproveApiKey-NXTWIAMj.js +0 -1
  225. package/dist/chunks/BypassPermissionsModeDialog-C4QGpcBT.js +0 -1
  226. package/dist/chunks/Doctor-DmiDH-lg.js +0 -1
  227. package/dist/chunks/Grove-BhhnrFX9.js +0 -11
  228. package/dist/chunks/MCPToolListView-Ddmu2UcL.js +0 -1
  229. package/dist/chunks/REPL-DkPd3vk5.js +0 -1
  230. package/dist/chunks/RemoteSessionManager-DJhrR1dz.js +0 -2
  231. package/dist/chunks/SearchExtraToolsTool-DupzA6Vm.js +0 -1
  232. package/dist/chunks/TeleportResumeWrapper-DnHTI39O.js +0 -1
  233. package/dist/chunks/agents-BYQO6DbG.js +0 -101
  234. package/dist/chunks/api-j0iE1mkR.js +0 -1
  235. package/dist/chunks/auth-C9FUZzpW.js +0 -1
  236. package/dist/chunks/auth-DwPrlTHv.js +0 -1
  237. package/dist/chunks/backgroundHousekeeping-BxcVB3By.js +0 -1
  238. package/dist/chunks/bridgeConfig-Bxs5dqjH.js +0 -1
  239. package/dist/chunks/bridgeStatusUtil-BQF0AJDO.js +0 -1
  240. package/dist/chunks/caches-C9--b9a7.js +0 -1
  241. package/dist/chunks/claudeDesktop-DPIJpc1V.js +0 -1
  242. package/dist/chunks/client-Dr9AYB-r.js +0 -1
  243. package/dist/chunks/commands-DTB0Qzd5.js +0 -1
  244. package/dist/chunks/config-B1kYcRIP.js +0 -1
  245. package/dist/chunks/context-noninteractive-Bno2Xsmp.js +0 -1
  246. package/dist/chunks/conversation-hNXWaswI.js +0 -1
  247. package/dist/chunks/createSession-BZx-2UIB.js +0 -1
  248. package/dist/chunks/doctor-aKE2bG5C.js +0 -1
  249. package/dist/chunks/extractMemories-WmPLOLUT.js +0 -1
  250. package/dist/chunks/fast-BVABmasw.js +0 -1
  251. package/dist/chunks/firstPartyEventLogger-CabA8fu0.js +0 -1
  252. package/dist/chunks/help-CELr6oJZ.js +0 -1
  253. package/dist/chunks/hooks-9rkDD2iw.js +0 -1
  254. package/dist/chunks/install-Dn3_M1Ui.js +0 -1
  255. package/dist/chunks/loadAgentsDir-D-a1uUb5.js +0 -1
  256. package/dist/chunks/localSearch-hOERAH9v.js +0 -1
  257. package/dist/chunks/managedEnv-AEhH_HUs.js +0 -1
  258. package/dist/chunks/model-BWR43D3c.js +0 -1
  259. package/dist/chunks/model-CmDF8O9G.js +0 -1
  260. package/dist/chunks/pluginStartupCheck-BGN6Je6d.js +0 -1
  261. package/dist/chunks/poorMode-XDBnxTiF.js +0 -1
  262. package/dist/chunks/prompt-B0gADAvI.js +0 -1
  263. package/dist/chunks/prompt-DqyEtC_I2.js +0 -1
  264. package/dist/chunks/ripgrep-DrpZ79Pp.js +0 -1
  265. package/dist/chunks/sandbox-adapter-DQ_fJSIo.js +0 -1
  266. package/dist/chunks/searchExtraTools-C7b2x2p_.js +0 -1
  267. package/dist/chunks/sessionFileAccessHooks-CQvGAbvL.js +0 -1
  268. package/dist/chunks/sessionObserver-BoQY7nOa.js +0 -1
  269. package/dist/chunks/sessionStorage-BeaEgnaa.js +0 -1
  270. package/dist/chunks/settings-Da6ax5aI.js +0 -1
  271. package/dist/chunks/sinks-B_ehGpvp.js +0 -1
  272. package/dist/chunks/status-DwyWiaVc.js +0 -1
  273. package/dist/chunks/switcher-DDUnWU_4.js +0 -1
  274. package/dist/chunks/trustedDevice-D_z7bAQh.js +0 -1
  275. package/dist/chunks/updateCCB-ts7Joyve.js +0 -5
  276. package/dist/chunks/useMainLoopModel-DkjG_ikT.js +0 -1
  277. package/dist/chunks/worktree-V7xiUAtl.js +0 -1
@@ -0,0 +1,101 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{i as n,o as r}from"./envUtils-DcaKZlRU.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{$S as o,$h as s,$m as c,$p as l,$u as u,AT as d,Bb as f,Cx as p,Dp as m,Gl as h,Gp as g,Hb as _,Hp as v,J_ as ee,Jf as y,Jp as b,Ka as te,Kc as ne,Kl as re,Kp as ie,La as ae,Mu as oe,Op as x,Pu as se,Q as ce,Ql as le,Qm as ue,Qp as de,Qu as fe,Sa as pe,Sp as me,Um as he,Up as ge,Vb as _e,Vp as ve,Wl as ye,Wm as be,Wp as xe,X as Se,Xf as Ce,Xh as we,Y_ as Te,Yf as Ee,Zh as De,Zl as Oe,ah as ke,by as Ae,c as je,cE as Me,cS as Ne,cd as Pe,dh as Fe,eC as Ie,fh as Le,hC as S,ih as Re,kT as ze,l as Be,lE as Ve,lS as He,ld as Ue,o as We,oh as Ge,qc as Ke,qf as qe,ql as Je,qp as Ye,r as Xe,rt as Ze,s as Qe,sh as $e,t as et,tm as tt,tt as nt,uE as rt,wp as it,wx as at,zb as ot}from"./loadAgentsDir-CwEfQDOw.js";import{C as st,D as C,I as w,P as T,T as E,Wt as D,ai as O,di as ct,fi as lt,t as k,y as ut}from"./src-DL3w8VPk2.js";import{t as A}from"./jsx-runtime-Bb4Xn-E0.js";import{n as dt,t as ft}from"./cwd-Besi3Os3.js";import{F as pt,R as mt,S as ht,U as gt,W as _t,Z as vt,x as yt}from"./debug-BQj6h99Q.js";import{J as bt,Ln as xt,Q as St,Qt as Ct,Rn as wt,Xt as Tt,at as Et,it as Dt,ln as Ot,sn as kt}from"./settings-CvhsRFaT.js";import{M as At,P as jt}from"./config-BSkuQZNf.js";import{o as Mt,s as Nt}from"./log-BlJ7CcKG.js";import{n as Pt,r as Ft}from"./analytics-DJobLaWP.js";import{C as It,v as Lt}from"./startupProfiler-2sjXZkIP.js";import{l as Rt,n as zt,o as Bt}from"./stringUtils-BjnclTLB.js";import{vn as Vt,yn as Ht}from"./prompt-Bm2EEG4F.js";import{Q as Ut}from"./sessionState-zhvcDpb2.js";import{a as Wt,i as Gt,n as Kt,o as qt,r as Jt,t as Yt}from"./agentDisplay-tRprY4gB.js";import{n as Xt,t as Zt}from"./useExitOnCtrlCDWithKeybindings-D48aDPG9.js";import{n as Qt,t as $t}from"./useMergedTools-BJ4L9QSK.js";import{n as en,r as tn,t as nn}from"./promptEditor-DQ9fpdQD.js";import{n as rn,t as an}from"./useMainLoopModel-89eUU13X.js";import{join as j}from"path";import{mkdir as on,open as sn,unlink as cn}from"fs/promises";var M,ln=e((()=>{M={FOLDER_NAME:`.workmate`,AGENTS_DIR:`agents`}}));function un(e,t,n,r,i,a,o){return`---
2
+ name: ${e}
3
+ description: "${t.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\n/g,`\\\\n`)}"${n===void 0||n.length===1&&n[0]===`*`?``:`\ntools: ${n.join(`, `)}`}${a?`\nmodel: ${a}`:``}${i?`\ncolor: ${i}`:``}${o?`\nmemory: ${o}`:``}
4
+ ---
5
+
6
+ ${r}
7
+ `}function dn(e){switch(e){case`flagSettings`:throw Error(`Cannot get directory path for ${e} agents`);case`userSettings`:return j(n(),M.AGENTS_DIR);case`projectSettings`:return j(ft(),M.FOLDER_NAME,M.AGENTS_DIR);case`policySettings`:return j(Tt(),M.FOLDER_NAME,M.AGENTS_DIR);case`localSettings`:return j(ft(),M.FOLDER_NAME,M.AGENTS_DIR)}}function fn(e){switch(e){case`projectSettings`:return j(`.`,M.FOLDER_NAME,M.AGENTS_DIR);default:return dn(e)}}function pn(e){return j(dn(e.source),`${e.agentType}.md`)}function mn(e){if(e.source===`built-in`)return`Built-in`;if(e.source===`plugin`)throw Error(`Cannot get file path for plugin agents`);return j(dn(e.source),`${e.filename||e.agentType}.md`)}function hn(e){return e.source===`built-in`?`Built-in`:j(fn(e.source),`${e.agentType}.md`)}function gn(e){return Qe(e)?`Built-in`:Be(e)?`Plugin: ${e.plugin||`Unknown`}`:e.source===`flagSettings`?`CLI argument`:j(fn(e.source),`${e.filename||e.agentType}.md`)}async function _n(e){let t=dn(e);return await on(t,{recursive:!0}),t}async function vn(e,t,n,r,i,a=!0,o,s,c){if(e===`built-in`)throw Error(`Cannot save built-in agents`);await _n(e);let l=pn({source:e,agentType:t}),u=un(t,n,r,i,o,s,c);try{await xn(l,u,a?`wx`:`w`)}catch(e){throw pt(e)===`EEXIST`?Error(`Agent file already exists: ${l}`):e}}async function yn(e,t,n,r,i,a,o){if(e.source===`built-in`)throw Error(`Cannot update built-in agents`);await xn(mn(e),un(e.agentType,t,n,r,i,a,o))}async function bn(e){if(e.source===`built-in`)throw Error(`Cannot delete built-in agents`);let t=mn(e);try{await cn(t)}catch(e){if(pt(e)!==`ENOENT`)throw e}}async function xn(e,t,n=`w`){let r=await sn(e,n);try{await r.writeFile(t,{encoding:`utf-8`}),await r.datasync()}finally{await r.close()}}var Sn=e((()=>{Ct(),We(),dt(),r(),mt(),ln()}));function Cn({agent:e,tools:t,onBack:n}){let r=ge(e,t,!1),i=gn(e),o=ie(e.agentType);D(`confirm:no`,n,{context:`Confirmation`});let s=e=>{e.key===`return`&&(e.preventDefault(),n())};function c(){return r.hasWildcard?(0,N.jsx)(T,{children:`All tools`}):!e.tools||e.tools.length===0?(0,N.jsx)(T,{children:`None`}):(0,N.jsxs)(N.Fragment,{children:[r.validTools.length>0&&(0,N.jsx)(T,{children:r.validTools.join(`, `)}),r.invalidTools.length>0&&(0,N.jsxs)(T,{color:`warning`,children:[a.warning,` Unrecognized: `,r.invalidTools.join(`, `)]})]})}return(0,N.jsxs)(w,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:s,children:[(0,N.jsx)(T,{dimColor:!0,children:i}),(0,N.jsxs)(w,{flexDirection:`column`,children:[(0,N.jsxs)(T,{children:[(0,N.jsx)(T,{bold:!0,children:`Description`}),` (tells Work Mate when to use this agent):`]}),(0,N.jsx)(w,{marginLeft:2,children:(0,N.jsx)(T,{children:e.whenToUse})})]}),(0,N.jsxs)(w,{children:[(0,N.jsxs)(T,{children:[(0,N.jsx)(T,{bold:!0,children:`Tools`}),`:`,` `]}),c()]}),(0,N.jsxs)(T,{children:[(0,N.jsx)(T,{bold:!0,children:`Model`}),`: `,de(e.model)]}),e.permissionMode&&(0,N.jsxs)(T,{children:[(0,N.jsx)(T,{bold:!0,children:`Permission mode`}),`: `,e.permissionMode]}),e.memory&&(0,N.jsxs)(T,{children:[(0,N.jsx)(T,{bold:!0,children:`Memory`}),`: `,Me(e.memory)]}),e.hooks&&Object.keys(e.hooks).length>0&&(0,N.jsxs)(T,{children:[(0,N.jsx)(T,{bold:!0,children:`Hooks`}),`: `,Object.keys(e.hooks).join(`, `)]}),e.skills&&e.skills.length>0&&(0,N.jsxs)(T,{children:[(0,N.jsx)(T,{bold:!0,children:`Skills`}),`:`,` `,e.skills.length>10?`${e.skills.length} skills`:e.skills.join(`, `)]}),o&&(0,N.jsx)(w,{children:(0,N.jsxs)(T,{children:[(0,N.jsx)(T,{bold:!0,children:`Color`}),`:`,` `,(0,N.jsxs)(T,{backgroundColor:o,color:`inverseText`,children:[` `,e.agentType,` `]})]})}),!Qe(e)&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(w,{children:(0,N.jsxs)(T,{children:[(0,N.jsx)(T,{bold:!0,children:`System prompt`}),`:`]})}),(0,N.jsx)(w,{marginLeft:2,marginRight:2,children:(0,N.jsx)(me,{children:e.getSystemPrompt()})})]})]})}var N,wn=e((()=>{i(),k(),S(),Ye(),Ve(),v(),We(),tt(),it(),Sn(),N=A()}));function Tn({agentName:e,currentColor:t=`automatic`,onConfirm:n}){let[r,i]=(0,En.useState)(Math.max(0,Dn.indexOf(t))),o=e=>{if(e.key===`up`)e.preventDefault(),i(e=>e>0?e-1:Dn.length-1);else if(e.key===`down`)e.preventDefault(),i(e=>e<Dn.length-1?e+1:0);else if(e.key===`return`){e.preventDefault();let t=Dn[r];n(t===`automatic`?void 0:t)}},s=Dn[r];return(0,P.jsxs)(w,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:o,children:[(0,P.jsx)(w,{flexDirection:`column`,children:Dn.map((e,t)=>{let n=t===r;return(0,P.jsxs)(w,{flexDirection:`row`,gap:1,children:[(0,P.jsx)(T,{color:n?`suggestion`:void 0,children:n?a.pointer:` `}),e===`automatic`?(0,P.jsx)(T,{bold:n,children:`Automatic color`}):(0,P.jsxs)(w,{gap:1,children:[(0,P.jsx)(T,{backgroundColor:g[e],color:`inverseText`,children:` `}),(0,P.jsx)(T,{bold:n,children:zt(e)})]})]},e)})}),(0,P.jsxs)(w,{marginTop:1,children:[(0,P.jsx)(T,{children:`Preview: `}),s===void 0||s===`automatic`?(0,P.jsxs)(T,{inverse:!0,bold:!0,children:[` `,`@`,e,` `]}):(0,P.jsxs)(T,{backgroundColor:g[s],color:`inverseText`,bold:!0,children:[` `,`@`,e,` `]})]})]})}var En,P,Dn,On=e((()=>{i(),En=t(O(),1),k(),Ye(),Bt(),P=A(),Dn=[`automatic`,...xe]}));function kn({initialModel:e,onComplete:t,onCancel:n}){let r=An.useMemo(()=>{let t=l();return e&&!t.some(t=>t.value===e)?[{value:e,label:e,description:`Current model (custom ID)`},...t]:t},[e]);return(0,jn.jsxs)(w,{flexDirection:`column`,children:[(0,jn.jsx)(w,{marginBottom:1,children:(0,jn.jsx)(T,{dimColor:!0,children:`Model determines the agent's reasoning capabilities and speed.`})}),(0,jn.jsx)(fe,{options:r,defaultValue:e??`sonnet`,onChange:t,onCancel:()=>n?n():t(void 0)})]})}var An,jn,Mn=e((()=>{An=t(O(),1),k(),tt(),u(),jn=A()}));function Nn(){return{READ_ONLY:{name:`Read-only tools`,toolNames:new Set([Re.name,Ge.name,ye.name,o.name,ue.name,Oe.name,re.name,Ne.name,_e.name])},EDIT:{name:`Edit tools`,toolNames:new Set([Ee.name,Fe.name,qe.name])},EXECUTION:{name:`Execution tools`,toolNames:new Set([he.name])},MCP:{name:`MCP tools`,toolNames:new Set,isMcp:!0},OTHER:{name:`Other tools`,toolNames:new Set}}}function Pn(e){let t=new Map;return e.forEach(e=>{if(at(e)){let n=Et(e.name);if(n?.serverName){let r=t.get(n.serverName)||[];r.push(e),t.set(n.serverName,r)}}}),Array.from(t.entries()).map(([e,t])=>({serverName:e,tools:t})).sort((e,t)=>e.serverName.localeCompare(t.serverName))}function Fn({tools:e,initialTools:t,onComplete:n,onCancel:r}){let i=(0,F.useMemo)(()=>ve({tools:e,isBuiltIn:!1,isAsync:!1}),[e]),[o,s]=(0,F.useState)(!t||t.includes(`*`)?i.map(e=>e.name):t),[c,l]=(0,F.useState)(0),[u,d]=(0,F.useState)(!1),f=(0,F.useMemo)(()=>{let e=new Set(i.map(e=>e.name));return o.filter(t=>e.has(t))},[o,i]),p=new Set(f),m=f.length===i.length&&i.length>0,h=e=>{e&&s(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},g=(e,t)=>{s(n=>{if(t){let t=e.filter(e=>!n.includes(e));return[...n,...t]}else return n.filter(t=>!e.includes(t))})},_=()=>{let e=i.map(e=>e.name);n(f.length===e.length&&e.every(e=>f.includes(e))?void 0:f)},v=(0,F.useMemo)(()=>{let e=Nn(),t={readOnly:[],edit:[],execution:[],mcp:[],other:[]};return i.forEach(n=>{at(n)?t.mcp.push(n):e.READ_ONLY.toolNames.has(n.name)?t.readOnly.push(n):e.EDIT.toolNames.has(n.name)?t.edit.push(n):e.EXECUTION.toolNames.has(n.name)?t.execution.push(n):n.name!==`Agent`&&t.other.push(n)}),t},[i]),ee=e=>{let t=xt(e,e=>p.has(e.name))<e.length;return()=>{let n=e.map(e=>e.name);g(n,t)}},y=[];y.push({id:`continue`,label:`Continue`,action:_,isContinue:!0}),y.push({id:`bucket-all`,label:`${m?a.checkboxOn:a.checkboxOff} All tools`,action:()=>{let e=i.map(e=>e.name);g(e,!m)}});let b=Nn();[{id:`bucket-readonly`,name:b.READ_ONLY.name,tools:v.readOnly},{id:`bucket-edit`,name:b.EDIT.name,tools:v.edit},{id:`bucket-execution`,name:b.EXECUTION.name,tools:v.execution},{id:`bucket-mcp`,name:b.MCP.name,tools:v.mcp},{id:`bucket-other`,name:b.OTHER.name,tools:v.other}].forEach(({id:e,name:t,tools:n})=>{if(n.length===0)return;let r=xt(n,e=>p.has(e.name))===n.length;y.push({id:e,label:`${r?a.checkboxOn:a.checkboxOff} ${t}`,action:ee(n)})});let te=y.length;y.push({id:`toggle-individual`,label:u?`Hide advanced options`:`Show advanced options`,action:()=>{d(!u),u&&c>te&&l(te)},isToggle:!0});let ne=(0,F.useMemo)(()=>Pn(i),[i]);return u&&(ne.length>0&&(y.push({id:`mcp-servers-header`,label:`MCP Servers:`,action:()=>{},isHeader:!0}),ne.forEach(({serverName:e,tools:t})=>{let n=xt(t,e=>p.has(e.name))===t.length;y.push({id:`mcp-server-${e}`,label:`${n?a.checkboxOn:a.checkboxOff} ${e} (${t.length} ${Rt(t.length,`tool`)})`,action:()=>{let e=t.map(e=>e.name);g(e,!n)}})}),y.push({id:`tools-header`,label:`Individual Tools:`,action:()=>{},isHeader:!0})),i.forEach(e=>{let t=e.name;if(e.name.startsWith(`mcp__`)){let n=Et(e.name);t=n?`${n.toolName} (${n.serverName})`:e.name}y.push({id:`tool-${e.name}`,label:`${p.has(e.name)?a.checkboxOn:a.checkboxOff} ${t}`,action:()=>h(e.name)})})),D(`confirm:no`,(0,F.useCallback)(()=>{r?r():n(t)},[r,n,t]),{context:`Confirmation`}),(0,I.jsxs)(w,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:e=>{if(e.key===`return`){e.preventDefault();let t=y[c];t&&!t.isHeader&&t.action()}else if(e.key===`up`){e.preventDefault();let t=c-1;for(;t>0&&y[t]?.isHeader;)t--;l(Math.max(0,t))}else if(e.key===`down`){e.preventDefault();let t=c+1;for(;t<y.length-1&&y[t]?.isHeader;)t++;l(Math.min(y.length-1,t))}},children:[(0,I.jsxs)(T,{color:c===0?`suggestion`:void 0,bold:c===0,children:[c===0?`${a.pointer} `:` `,`[ Continue ]`]}),(0,I.jsx)(st,{width:40}),y.slice(1).map((e,t)=>{let n=t+1===c,r=e.isToggle,i=e.isHeader;return(0,I.jsxs)(F.Fragment,{children:[r&&(0,I.jsx)(st,{width:40}),i&&t>0&&(0,I.jsx)(w,{marginTop:1}),(0,I.jsxs)(T,{color:i?void 0:n?`suggestion`:void 0,dimColor:i,bold:r&&n,children:[i?``:n?`${a.pointer} `:` `,r?`[ ${e.label} ]`:e.label]})]},e.id)}),(0,I.jsx)(w,{marginTop:1,flexDirection:`column`,children:(0,I.jsx)(T,{dimColor:!0,children:m?`All tools selected`:`${p.size} of ${i.length} tools selected`})})]})}var F,I,In=e((()=>{i(),F=t(O(),1),Dt(),p(),v(),St(),be(),h(),Ce(),Ie(),Le(),ke(),$e(),He(),y(),_(),Je(),le(),c(),k(),S(),wt(),Bt(),I=A()}));function Ln(e){return e===`all`?`Agents`:e===`built-in`?`Built-in agents`:e===`plugin`?`Plugin agents`:ze(kt(e))}var Rn=e((()=>{d(),Ot()}));function zn({agent:e,tools:t,onSaved:n,onBack:r}){let i=s(),[o,c]=(0,L.useState)(`menu`),[l,u]=(0,L.useState)(0),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(e.color),h=(0,L.useCallback)(async()=>{let t=await nn(mn(e));t.error?f(t.error):n(`Opened ${e.agentType} in editor. If you made edits, restart to load the latest version.`)},[e,n]),g=(0,L.useCallback)(async(t={})=>{let{tools:r,color:a,model:o}=t,s=a??p,c=r!==void 0,l=o!==void 0,u=s!==e.color;if(!c&&!l&&!u)return!1;try{return!je(e)&&!Be(e)?!1:(await yn(e,e.whenToUse,r??e.tools,e.getSystemPrompt(),s,o??e.model),u&&s&&b(e.agentType,s),i(t=>{let n=t.agentDefinitions.allAgents.map(t=>t.agentType===e.agentType?{...t,tools:r??t.tools,color:s,model:o??t.model}:t);return{...t,agentDefinitions:{...t.agentDefinitions,activeAgents:Xe(n),allAgents:n}}}),n(`Updated agent: ${ct.bold(e.agentType)}`),!0)}catch(e){return f(e instanceof Error?e.message:`Failed to save agent`),!1}},[e,p,n,i]),_=(0,L.useMemo)(()=>[{label:`Open in editor`,action:h},{label:`Edit tools`,action:()=>c(`edit-tools`)},{label:`Edit model`,action:()=>c(`edit-model`)},{label:`Edit color`,action:()=>c(`edit-color`)}],[h]),v=(0,L.useCallback)(()=>{f(null),o===`menu`?r():c(`menu`)},[o,r]),ee=(0,L.useCallback)(e=>{if(e.key===`up`)e.preventDefault(),u(e=>Math.max(0,e-1));else if(e.key===`down`)e.preventDefault(),u(e=>Math.min(_.length-1,e+1));else if(e.key===`return`){e.preventDefault();let t=_[l];t&&t.action()}},[_,l]);D(`confirm:no`,v,{context:`Confirmation`});let y=()=>(0,R.jsxs)(w,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:ee,children:[(0,R.jsxs)(T,{dimColor:!0,children:[`Source: `,Ln(e.source)]}),(0,R.jsx)(w,{marginTop:1,flexDirection:`column`,children:_.map((e,t)=>(0,R.jsxs)(T,{color:t===l?`suggestion`:void 0,children:[t===l?`${a.pointer} `:` `,e.label]},e.label))}),d&&(0,R.jsx)(w,{marginTop:1,children:(0,R.jsx)(T,{color:`error`,children:d})})]});switch(o){case`menu`:return y();case`edit-tools`:return(0,R.jsx)(Fn,{tools:t,initialTools:e.tools,onComplete:async e=>{c(`menu`),await g({tools:e})}});case`edit-color`:return(0,R.jsx)(Tn,{agentName:e.agentType,currentColor:p||e.color||`automatic`,onConfirm:async e=>{m(e),c(`menu`),await g({color:e})}});case`edit-model`:return(0,R.jsx)(kn,{initialModel:e.model,onComplete:async e=>{c(`menu`),await g({model:e})}});default:return null}}var L,R,Bn=e((()=>{lt(),i(),L=t(O(),1),we(),k(),S(),Ye(),We(),tn(),Sn(),On(),Mn(),In(),Rn(),R=A()}));function Vn({instructions:e=`Press ↑↓ to navigate · Enter to select · Esc to go back`}){let t=Xt();return(0,Hn.jsx)(w,{marginLeft:2,children:(0,Hn.jsx)(T,{dimColor:!0,children:t.pending?`Press ${t.keyName} again to exit`:e})})}var Hn,Un=e((()=>{Zt(),k(),Hn=A()}));function Wn({source:e,agents:t,onBack:n,onSelect:r,onCreateNew:i,changes:o}){let[s,c]=Gn.useState(null),[l,u]=Gn.useState(!0),d=Gn.useMemo(()=>[...t].sort(Kt),[t]),f=e=>({isOverridden:!!e.overriddenBy,overriddenBy:e.overriddenBy||null}),p=()=>(0,z.jsxs)(w,{children:[(0,z.jsx)(T,{color:l?`suggestion`:void 0,children:l?`${a.pointer} `:` `}),(0,z.jsx)(T,{color:l?`suggestion`:void 0,children:`Create new agent`})]}),m=e=>{let t=e.source===`built-in`,n=!t&&!l&&s?.agentType===e.agentType&&s?.source===e.source,{isOverridden:r,overriddenBy:i}=f(e),o=t||r,c=!t&&n?`suggestion`:void 0,u=Wt(e);return(0,z.jsxs)(w,{children:[(0,z.jsx)(T,{dimColor:o&&!n,color:c,children:t?``:n?`${a.pointer} `:` `}),(0,z.jsx)(T,{dimColor:o&&!n,color:c,children:e.agentType}),u&&(0,z.jsxs)(T,{dimColor:!0,color:c,children:[` · `,u]}),e.memory&&(0,z.jsxs)(T,{dimColor:!0,color:c,children:[` · `,e.memory,` memory`]}),i&&(0,z.jsxs)(T,{dimColor:!n,color:n?`warning`:void 0,children:[` `,a.warning,` shadowed by `,Jt(i)]})]},`${e.agentType}-${e.source}`)},h=Gn.useMemo(()=>{let t=d.filter(e=>e.source!==`built-in`);return e===`all`?Yt.filter(e=>e.source!==`built-in`).flatMap(({source:e})=>t.filter(t=>t.source===e)):t},[d,e]);Gn.useEffect(()=>{!s&&!l&&h.length>0&&(i?u(!0):c(h[0]||null))},[h,s,l,i]);let g=e=>{if(e.key===`return`){e.preventDefault(),l&&i?i():s&&r(s);return}if(e.key!==`up`&&e.key!==`down`)return;e.preventDefault();let t=!!i,n=h.length+ +!!t;if(n===0)return;let a=0;if(!l&&s){let e=h.findIndex(e=>e.agentType===s.agentType&&e.source===s.source);e>=0&&(a=t?e+1:e)}let o=e.key===`up`?a===0?n-1:a-1:a===n-1?0:a+1;if(t&&o===0)u(!0),c(null);else{let e=t?o-1:o,n=h[e];n&&(u(!1),c(n))}},_=(e=`Built-in (always available):`)=>{let t=d.filter(e=>e.source===`built-in`);return(0,z.jsxs)(w,{flexDirection:`column`,marginBottom:1,paddingLeft:2,children:[(0,z.jsx)(T,{bold:!0,dimColor:!0,children:e}),t.map(m)]})},v=(e,t)=>{if(!t.length)return null;let n=t[0]?.baseDir;return(0,z.jsxs)(w,{flexDirection:`column`,marginBottom:1,children:[(0,z.jsxs)(w,{paddingLeft:2,children:[(0,z.jsx)(T,{bold:!0,dimColor:!0,children:e}),n&&(0,z.jsxs)(T,{dimColor:!0,children:[` (`,n,`)`]})]}),t.map(e=>m(e))]})},ee=Ln(e),y=d.filter(e=>e.source===`built-in`);return!d.length||e!==`built-in`&&!d.some(e=>e.source!==`built-in`)?(0,z.jsx)(ut,{title:ee,subtitle:`No agents found`,onCancel:n,hideInputGuide:!0,children:(0,z.jsxs)(w,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:g,children:[i&&(0,z.jsx)(w,{children:p()}),(0,z.jsx)(T,{dimColor:!0,children:`No agents found. Create specialized subagents that Work Mate can delegate to.`}),(0,z.jsx)(T,{dimColor:!0,children:`Each subagent has its own context window, custom system prompt, and specific tools.`}),(0,z.jsx)(T,{dimColor:!0,children:`Try creating: Code Reviewer, Code Simplifier, Security Reviewer, Tech Lead, or UX Reviewer.`}),e!==`built-in`&&d.some(e=>e.source===`built-in`)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(st,{}),_()]})]})}):(0,z.jsxs)(ut,{title:ee,subtitle:`${xt(d,e=>!e.overriddenBy)} agents`,onCancel:n,hideInputGuide:!0,children:[o&&o.length>0&&(0,z.jsx)(w,{marginTop:1,children:(0,z.jsx)(T,{dimColor:!0,children:o[o.length-1]})}),(0,z.jsxs)(w,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:g,children:[i&&(0,z.jsx)(w,{marginBottom:1,children:p()}),e===`all`?(0,z.jsxs)(z.Fragment,{children:[Yt.filter(e=>e.source!==`built-in`).map(({label:e,source:t})=>(0,z.jsx)(Gn.Fragment,{children:v(e,d.filter(e=>e.source===t))},t)),y.length>0&&(0,z.jsxs)(w,{flexDirection:`column`,marginBottom:1,paddingLeft:2,children:[(0,z.jsxs)(T,{dimColor:!0,children:[(0,z.jsx)(T,{bold:!0,children:`Built-in agents`}),` (always available)`]}),y.map(m)]})]}):e===`built-in`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(T,{dimColor:!0,italic:!0,children:`Built-in agents are provided by default and cannot be modified.`}),(0,z.jsx)(w,{marginTop:1,flexDirection:`column`,children:d.map(e=>m(e))})]}):(0,z.jsxs)(z.Fragment,{children:[d.filter(e=>e.source!==`built-in`).map(e=>m(e)),d.some(e=>e.source===`built-in`)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(st,{}),_()]})]})]})]})}var Gn,z,Kn=e((()=>{i(),Gn=t(O(),1),k(),Gt(),wt(),Rn(),z=A()}));function qn({steps:e,initialData:t={},onComplete:n,onCancel:r,children:i,title:a,showStepCounter:o=!0}){let[s,c]=(0,B.useState)(0),[l,u]=(0,B.useState)(t),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)([]);Xt(),(0,B.useEffect)(()=>{d&&(m([]),n(l))},[d,l,n]);let h=(0,B.useCallback)(()=>{s<e.length-1?(p.length>0&&m(e=>[...e,s]),c(e=>e+1)):f(!0)},[s,e.length,p]),g=(0,B.useCallback)(()=>{if(p.length>0){let e=p[p.length-1];e!==void 0&&(m(e=>e.slice(0,-1)),c(e))}else s>0?c(e=>e-1):r&&r()},[s,p,r]),_=(0,B.useCallback)(t=>{t>=0&&t<e.length&&(m(e=>[...e,s]),c(t))},[s,e.length]),v=(0,B.useCallback)(()=>{m([]),r&&r()},[r]),ee=(0,B.useCallback)(e=>{u(t=>({...t,...e}))},[]),y=(0,B.useMemo)(()=>({currentStepIndex:s,totalSteps:e.length,wizardData:l,setWizardData:u,updateWizardData:ee,goNext:h,goBack:g,goToStep:_,cancel:v,title:a,showStepCounter:o}),[s,e.length,l,ee,h,g,_,v,a,o]),b=e[s];return!b||d?null:(0,Jn.jsx)(Yn.Provider,{value:y,children:i||(0,Jn.jsx)(b,{})})}var B,Jn,Yn,Xn=e((()=>{B=t(O(),1),Zt(),Jn=A(),Yn=(0,B.createContext)(null)}));function V(){let e=(0,Zn.useContext)(Yn);if(!e)throw Error(`useWizard must be used within a WizardProvider`);return e}var Zn,Qn=e((()=>{Zn=t(O(),1),Xn()}));function $n({instructions:e=(0,er.jsxs)(E,{children:[(0,er.jsx)(C,{shortcut:`↑↓`,action:`navigate`}),(0,er.jsx)(C,{shortcut:`Enter`,action:`select`}),(0,er.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})}){let t=Xt();return(0,er.jsx)(w,{marginLeft:3,marginTop:1,children:(0,er.jsx)(T,{dimColor:!0,children:t.pending?`Press ${t.keyName} again to exit`:e})})}var er,tr=e((()=>{Zt(),k(),x(),er=A()}));function H({title:e,color:t=`suggestion`,children:n,subtitle:r,footerText:i}){let{currentStepIndex:a,totalSteps:o,title:s,showStepCounter:c,goBack:l}=V();return(0,nr.jsxs)(nr.Fragment,{children:[(0,nr.jsx)(ut,{title:`${e||s||`Wizard`}${c===!1?``:` (${a+1}/${o})`}`,subtitle:r,onCancel:l,color:t,hideInputGuide:!0,isCancelActive:!1,children:n}),(0,nr.jsx)($n,{instructions:i})]})}var nr,U=e((()=>{k(),Qn(),tr(),nr=A()})),W=e((()=>{Qn(),U(),tr(),Xn()}));function rr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=V();return D(`confirm:no`,t,{context:`Confirmation`}),(0,ir.jsx)(H,{subtitle:`Choose background color`,footerText:(0,ir.jsxs)(E,{children:[(0,ir.jsx)(C,{shortcut:`↑↓`,action:`navigate`}),(0,ir.jsx)(C,{shortcut:`Enter`,action:`select`}),(0,ir.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,ir.jsx)(w,{children:(0,ir.jsx)(Tn,{agentName:r.agentType||`agent`,currentColor:`automatic`,onConfirm:t=>{n({selectedColor:t,finalAgent:{agentType:r.agentType,whenToUse:r.whenToUse,getSystemPrompt:()=>r.systemPrompt,tools:r.selectedTools,...r.selectedModel?{model:r.selectedModel}:{},...t?{color:t}:{},source:r.location}}),e()}})})})}var ir,ar=e((()=>{k(),S(),x(),W(),U(),On(),ir=A()}));function or(e){return e?/^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$/.test(e)?e.length<3?`Agent type must be at least 3 characters long`:e.length>50?`Agent type must be less than 50 characters`:null:`Agent type must start and end with alphanumeric characters and contain only letters, numbers, and hyphens`:`Agent type is required`}function sr(e,t,n){let r=[],i=[];if(!e.agentType)r.push(`Agent type is required`);else{let t=or(e.agentType);t&&r.push(t);let i=n.find(t=>t.agentType===e.agentType&&t.source!==e.source);i&&r.push(`Agent type "${e.agentType}" already exists in ${Ln(i.source)}`)}if(e.whenToUse?e.whenToUse.length<10?i.push(`Description should be more descriptive (at least 10 characters)`):e.whenToUse.length>5e3&&i.push(`Description is very long (over 5000 characters)`):r.push(`Description (description) is required`),e.tools!==void 0&&!Array.isArray(e.tools))r.push(`Tools must be an array`);else{e.tools===void 0?i.push(`Agent has access to all tools`):e.tools.length===0&&i.push(`No tools selected - agent will have very limited capabilities`);let n=ge(e,t,!1);n.invalidTools.length>0&&r.push(`Invalid tools: ${n.invalidTools.join(`, `)}`)}let a=e.getSystemPrompt();return a?a.length<20?r.push(`System prompt is too short (minimum 20 characters)`):a.length>1e4&&i.push(`System prompt is very long (over 10,000 characters)`):r.push(`System prompt is required`),{isValid:r.length===0,errors:r,warnings:i}}var cr=e((()=>{v(),Rn()}));function lr({tools:e,existingAgents:t,onSave:n,onSaveAndEdit:r,error:i}){let{goBack:a,wizardData:o}=V();D(`confirm:no`,a,{context:`Confirmation`});let s=e=>{e.key===`s`||e.key===`return`?(e.preventDefault(),n()):e.key===`e`&&(e.preventDefault(),r())},c=o.finalAgent,l=sr(c,e,t),u=It(c.getSystemPrompt(),240),d=It(c.whenToUse,240),f=e=>e===void 0?`All tools`:e.length===0?`None`:e.length===1?e[0]||`None`:e.length===2?e.join(` and `):`${e.slice(0,-1).join(`, `)}, and ${e[e.length-1]}`,p=jt()?(0,G.jsxs)(T,{children:[(0,G.jsx)(T,{bold:!0,children:`Memory`}),`: `,Me(c.memory)]}):null;return(0,G.jsx)(H,{subtitle:`Confirm and save`,footerText:(0,G.jsxs)(E,{children:[(0,G.jsx)(C,{shortcut:`s/Enter`,action:`save`}),(0,G.jsx)(C,{shortcut:`e`,action:`edit in your editor`}),(0,G.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]}),children:(0,G.jsxs)(w,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:s,children:[(0,G.jsxs)(T,{children:[(0,G.jsx)(T,{bold:!0,children:`Name`}),`: `,c.agentType]}),(0,G.jsxs)(T,{children:[(0,G.jsx)(T,{bold:!0,children:`Location`}),`:`,` `,hn({source:o.location,agentType:c.agentType})]}),(0,G.jsxs)(T,{children:[(0,G.jsx)(T,{bold:!0,children:`Tools`}),`: `,f(c.tools)]}),(0,G.jsxs)(T,{children:[(0,G.jsx)(T,{bold:!0,children:`Model`}),`: `,de(c.model)]}),p,(0,G.jsx)(w,{marginTop:1,children:(0,G.jsxs)(T,{children:[(0,G.jsx)(T,{bold:!0,children:`Description`}),` (tells Work Mate when to use this agent):`]})}),(0,G.jsx)(w,{marginLeft:2,marginTop:1,children:(0,G.jsx)(T,{children:d})}),(0,G.jsx)(w,{marginTop:1,children:(0,G.jsxs)(T,{children:[(0,G.jsx)(T,{bold:!0,children:`System prompt`}),`:`]})}),(0,G.jsx)(w,{marginLeft:2,marginTop:1,children:(0,G.jsx)(T,{children:u})}),l.warnings.length>0&&(0,G.jsxs)(w,{marginTop:1,flexDirection:`column`,children:[(0,G.jsx)(T,{color:`warning`,children:`Warnings:`}),l.warnings.map((e,t)=>(0,G.jsxs)(T,{dimColor:!0,children:[` `,`• `,e]},t))]}),l.errors.length>0&&(0,G.jsxs)(w,{marginTop:1,flexDirection:`column`,children:[(0,G.jsx)(T,{color:`error`,children:`Errors:`}),l.errors.map((e,t)=>(0,G.jsxs)(T,{color:`error`,children:[` `,`• `,e]},t))]}),i&&(0,G.jsx)(w,{marginTop:1,children:(0,G.jsx)(T,{color:`error`,children:i})}),(0,G.jsx)(w,{marginTop:2,children:(0,G.jsxs)(T,{color:`success`,children:[`Press `,(0,G.jsx)(T,{bold:!0,children:`s`}),` or `,(0,G.jsx)(T,{bold:!0,children:`Enter`}),` to save, `,(0,G.jsx)(T,{bold:!0,children:`e`}),` to save and edit`]})})]})})}var G,ur=e((()=>{k(),S(),At(),Ve(),Lt(),tt(),x(),W(),U(),Sn(),cr(),G=A()}));function dr({tools:e,existingAgents:t,onComplete:n}){let{wizardData:r}=V(),[i,a]=(0,fr.useState)(null),o=s(),c=(0,fr.useCallback)(async e=>{if(r?.finalAgent)try{await vn(r.location,r.finalAgent.agentType,r.finalAgent.whenToUse,r.finalAgent.tools,r.finalAgent.getSystemPrompt(),!0,r.finalAgent.color,r.finalAgent.model,r.finalAgent.memory),o(e=>{if(!r.finalAgent)return e;let t=e.agentDefinitions.allAgents.concat(r.finalAgent);return{...e,agentDefinitions:{...e.agentDefinitions,activeAgents:Xe(t),allAgents:t}}}),et(),e&&await nn(pn({source:r.location,agentType:r.finalAgent.agentType})),Ft(`tengu_agent_created`,{agent_type:r.finalAgent.agentType,generation_method:r.wasGenerated?`generated`:`manual`,source:r.location,tool_count:r.finalAgent.tools?.length??`all`,has_custom_model:!!r.finalAgent.model,has_custom_color:!!r.finalAgent.color,has_memory:!!r.finalAgent.memory,memory_scope:r.finalAgent.memory??`none`,...e?{opened_in_editor:!0}:{}}),n(e?`Created agent: ${ct.bold(r.finalAgent.agentType)} and opened in editor. If you made edits, restart to load the latest version.`:`Created agent: ${ct.bold(r.finalAgent.agentType)}`)}catch(e){a(e instanceof Error?e.message:`Failed to save agent`)}},[r,n,o]);return(0,pr.jsx)(lr,{tools:e,existingAgents:t,onSave:(0,fr.useCallback)(()=>c(!1),[c]),onSaveAndEdit:(0,fr.useCallback)(()=>c(!0),[c]),error:i})}var fr,pr,mr=e((()=>{lt(),fr=t(O(),1),Pt(),we(),We(),tn(),W(),Sn(),ur(),pr=A()}));function hr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=V(),[i,a]=(0,gr.useState)(r.whenToUse||``),[o,s]=(0,gr.useState)(i.length),[c,l]=(0,gr.useState)(null);return D(`confirm:no`,t,{context:`Settings`}),D(`chat:externalEditor`,(0,gr.useCallback)(async()=>{let e=await en(i);e.content!==null&&(a(e.content),s(e.content.length))},[i]),{context:`Chat`}),(0,K.jsx)(H,{subtitle:`Description (tell Work Mate when to use this agent)`,footerText:(0,K.jsxs)(E,{children:[(0,K.jsx)(C,{shortcut:`Type`,action:`enter text`}),(0,K.jsx)(C,{shortcut:`Enter`,action:`continue`}),(0,K.jsx)(m,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,K.jsx)(m,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,K.jsxs)(w,{flexDirection:`column`,children:[(0,K.jsx)(T,{children:`When should Work Mate use this agent?`}),(0,K.jsx)(w,{marginTop:1,children:(0,K.jsx)(Pe,{value:i,onChange:a,onSubmit:t=>{let r=t.trim();if(!r){l(`Description is required`);return}l(null),n({whenToUse:r}),e()},placeholder:`e.g., use this agent after you're done writing code...`,columns:80,cursorOffset:o,onChangeCursorOffset:s,focus:!0,showCursor:!0})}),c&&(0,K.jsx)(w,{marginTop:1,children:(0,K.jsx)(T,{color:`error`,children:c})})]})})}var gr,K,_r=e((()=>{gr=t(O(),1),k(),S(),tn(),x(),Ue(),W(),U(),K=A()}));async function vr(e,t,n,r){let i=pe({content:`Create an agent configuration based on this request: "${e}".${n.length>0?`\n\nIMPORTANT: The following identifiers already exist and must NOT be used: ${n.join(`, `)}`:``}
8
+ Return ONLY the JSON object, no other text.`}),a=await ee(),o=Ze([i],a),s=jt()?yr+br:yr,c=await ce({messages:te(o),systemPrompt:Ut([s]),thinkingConfig:{type:`disabled`},tools:[],signal:r,options:{getToolPermissionContext:async()=>Vt(),model:t,toolChoice:void 0,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,querySource:`agent_creation`,mcpTools:[]}}),l=(Array.isArray(c.message.content)?c.message.content:[]).filter(e=>e.type===`text`).map(e=>e.text).join(`
9
+ `),u;try{u=ht(l.trim())}catch{let e=l.match(/\{[\s\S]*\}/);if(!e)throw Error(`No JSON object found in response`);u=ht(e[0])}if(!u.identifier||!u.whenToUse||!u.systemPrompt)throw Error(`Invalid agent configuration generated`);return Ft(`tengu_agent_definition_generated`,{agent_identifier:u.identifier}),{identifier:u.identifier,whenToUse:u.whenToUse,systemPrompt:u.systemPrompt}}var yr,br,xr=e((()=>{Te(),Se(),Ht(),St(),nt(),ae(),At(),Pt(),yt(),Ae(),yr=`You are an elite AI agent architect specializing in crafting high-performance agent configurations. Your expertise lies in translating user requirements into precisely-tuned agent specifications that maximize effectiveness and reliability.
10
+
11
+ **Important Context**: You may have access to project-specific instructions from AGENTS.md files and other context that may include coding standards, project structure, and custom requirements. Consider this context when creating agents to ensure they align with the project's established patterns and practices.
12
+
13
+ When a user describes what they want an agent to do, you will:
14
+
15
+ 1. **Extract Core Intent**: Identify the fundamental purpose, key responsibilities, and success criteria for the agent. Look for both explicit requirements and implicit needs. Consider any project-specific context from AGENTS.md files. For agents that are meant to review code, you should assume that the user is asking to review recently written code and not the whole codebase, unless the user has explicitly instructed you otherwise.
16
+
17
+ 2. **Design Expert Persona**: Create a compelling expert identity that embodies deep domain knowledge relevant to the task. The persona should inspire confidence and guide the agent's decision-making approach.
18
+
19
+ 3. **Architect Comprehensive Instructions**: Develop a system prompt that:
20
+ - Establishes clear behavioral boundaries and operational parameters
21
+ - Provides specific methodologies and best practices for task execution
22
+ - Anticipates edge cases and provides guidance for handling them
23
+ - Incorporates any specific requirements or preferences mentioned by the user
24
+ - Defines output format expectations when relevant
25
+ - Aligns with project-specific coding standards and patterns from AGENTS.md
26
+
27
+ 4. **Optimize for Performance**: Include:
28
+ - Decision-making frameworks appropriate to the domain
29
+ - Quality control mechanisms and self-verification steps
30
+ - Efficient workflow patterns
31
+ - Clear escalation or fallback strategies
32
+
33
+ 5. **Create Identifier**: Design a concise, descriptive identifier that:
34
+ - Uses lowercase letters, numbers, and hyphens only
35
+ - Is typically 2-4 words joined by hyphens
36
+ - Clearly indicates the agent's primary function
37
+ - Is memorable and easy to type
38
+ - Avoids generic terms like "helper" or "assistant"
39
+
40
+ 6 **Example agent descriptions**:
41
+ - in the 'whenToUse' field of the JSON object, you should include examples of when this agent should be used.
42
+ - examples should be of the form:
43
+ - <example>
44
+ Context: The user is creating a test-runner agent that should be called after a logical chunk of code is written.
45
+ user: "Please write a function that checks if a number is prime"
46
+ assistant: "Here is the relevant function: "
47
+ <function call omitted for brevity only for this example>
48
+ <commentary>
49
+ Since a significant piece of code was written, use the ${bt} tool to launch the test-runner agent to run the tests.
50
+ </commentary>
51
+ assistant: "Now let me use the test-runner agent to run the tests"
52
+ </example>
53
+ - <example>
54
+ Context: User is creating an agent to respond to the word "hello" with a friendly jok.
55
+ user: "Hello"
56
+ assistant: "I'm going to use the ${bt} tool to launch the greeting-responder agent to respond with a friendly joke"
57
+ <commentary>
58
+ Since the user is greeting, use the greeting-responder agent to respond with a friendly joke.
59
+ </commentary>
60
+ </example>
61
+ - If the user mentioned or implied that the agent should be used proactively, you should include examples of this.
62
+ - NOTE: Ensure that in the examples, you are making the assistant use the Agent tool and not simply respond directly to the task.
63
+
64
+ Your output must be a valid JSON object with exactly these fields:
65
+ {
66
+ "identifier": "A unique, descriptive identifier using lowercase letters, numbers, and hyphens (e.g., 'test-runner', 'api-docs-writer', 'code-formatter')",
67
+ "whenToUse": "A precise, actionable description starting with 'Use this agent when...' that clearly defines the triggering conditions and use cases. Ensure you include examples as described above.",
68
+ "systemPrompt": "The complete system prompt that will govern the agent's behavior, written in second person ('You are...', 'You will...') and structured for maximum clarity and effectiveness"
69
+ }
70
+
71
+ Key principles for your system prompts:
72
+ - Be specific rather than generic - avoid vague instructions
73
+ - Include concrete examples when they would clarify behavior
74
+ - Balance comprehensiveness with clarity - every instruction should add value
75
+ - Ensure the agent has enough context to handle variations of the core task
76
+ - Make the agent proactive in seeking clarification when needed
77
+ - Build in quality assurance and self-correction mechanisms
78
+
79
+ Remember: The agents you create should be autonomous experts capable of handling their designated tasks with minimal additional guidance. Your system prompts are their complete operational manual.
80
+ `,br=`
81
+
82
+ 7. **Agent Memory Instructions**: If the user mentions "memory", "remember", "learn", "persist", or similar concepts, OR if the agent would benefit from building up knowledge across conversations (e.g., code reviewers learning patterns, architects learning codebase structure, etc.), include domain-specific memory update instructions in the systemPrompt.
83
+
84
+ Add a section like this to the systemPrompt, tailored to the agent's specific domain:
85
+
86
+ "**Update your agent memory** as you discover [domain-specific items]. This builds up institutional knowledge across conversations. Write concise notes about what you found and where.
87
+
88
+ Examples of what to record:
89
+ - [domain-specific item 1]
90
+ - [domain-specific item 2]
91
+ - [domain-specific item 3]"
92
+
93
+ Examples of domain-specific memory instructions:
94
+ - For a code-reviewer: "Update your agent memory as you discover code patterns, style conventions, common issues, and architectural decisions in this codebase."
95
+ - For a test-runner: "Update your agent memory as you discover test patterns, common failure modes, flaky tests, and testing best practices."
96
+ - For an architect: "Update your agent memory as you discover codepaths, library locations, key architectural decisions, and component relationships."
97
+ - For a documentation writer: "Update your agent memory as you discover documentation patterns, API structures, and terminology conventions."
98
+
99
+ The memory instructions should be specific to what the agent would naturally learn while performing its core tasks.
100
+ `}));function Sr(){let{updateWizardData:e,goBack:t,goToStep:n,wizardData:r}=V(),[i,a]=(0,q.useState)(r.generationPrompt||``),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(i.length),f=rn(),p=(0,q.useRef)(null);D(`confirm:no`,(0,q.useCallback)(()=>{p.current&&(p.current.abort(),p.current=null,s(!1),l(`Generation cancelled`))},[]),{context:`Settings`,isActive:o}),D(`chat:externalEditor`,(0,q.useCallback)(async()=>{let e=await en(i);e.content!==null&&(a(e.content),d(e.content.length))},[i]),{context:`Chat`,isActive:!o}),D(`confirm:no`,(0,q.useCallback)(()=>{e({generationPrompt:``,agentType:``,systemPrompt:``,whenToUse:``,generatedAgent:void 0,wasGenerated:!1}),a(``),l(null),t()},[e,t]),{context:`Settings`,isActive:!o});let h=async()=>{let t=i.trim();if(!t){l(`Please describe what the agent should do`);return}l(null),s(!0),e({generationPrompt:t,isGenerating:!0});let r=ot();p.current=r;try{let i=await vr(t,f,[],r.signal);e({agentType:i.identifier,whenToUse:i.whenToUse,systemPrompt:i.systemPrompt,generatedAgent:i,isGenerating:!1,wasGenerated:!0}),n(6)}catch(t){t instanceof vt||t instanceof Error&&!t.message.includes(`No assistant message found`)&&l(t.message||`Failed to generate agent`),e({isGenerating:!1})}finally{s(!1),p.current=null}},g=`Describe what this agent should do and when it should be used (be comprehensive for best results)`;return o?(0,J.jsx)(H,{subtitle:g,footerText:(0,J.jsx)(m,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`}),children:(0,J.jsxs)(w,{flexDirection:`row`,alignItems:`center`,children:[(0,J.jsx)(oe,{}),(0,J.jsx)(T,{color:`suggestion`,children:` Generating agent from description...`})]})}):(0,J.jsx)(H,{subtitle:g,footerText:(0,J.jsxs)(E,{children:[(0,J.jsx)(m,{action:`confirm:yes`,context:`Confirmation`,fallback:`Enter`,description:`submit`}),(0,J.jsx)(m,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,J.jsx)(m,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,J.jsxs)(w,{flexDirection:`column`,children:[c&&(0,J.jsx)(w,{marginBottom:1,children:(0,J.jsx)(T,{color:`error`,children:c})}),(0,J.jsx)(Pe,{value:i,onChange:a,onSubmit:h,placeholder:`e.g., Help me write unit tests for my code...`,columns:80,cursorOffset:u,onChangeCursorOffset:d,focus:!0,showCursor:!0})]})})}var q,J,Cr=e((()=>{_t(),q=t(O(),1),an(),k(),S(),f(),tn(),x(),se(),Ue(),W(),U(),xr(),J=A()}));function wr(){let{goNext:e,updateWizardData:t,cancel:n}=V();return(0,Y.jsx)(H,{subtitle:`Choose location`,footerText:(0,Y.jsxs)(E,{children:[(0,Y.jsx)(C,{shortcut:`↑↓`,action:`navigate`}),(0,Y.jsx)(C,{shortcut:`Enter`,action:`select`}),(0,Y.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]}),children:(0,Y.jsx)(w,{children:(0,Y.jsx)(fe,{options:[{label:`Project (.workmate/agents/)`,value:`projectSettings`},{label:`Personal (~/.workmate/agents/)`,value:`userSettings`}],onChange:n=>{t({location:n}),e()},onCancel:()=>n()},`location-select`)})})}var Y,Tr=e((()=>{k(),x(),u(),W(),U(),Y=A()}));function Er(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=V();D(`confirm:no`,t,{context:`Confirmation`});let i=r.location===`userSettings`?[{label:`User scope (~/.workmate/agent-memory/) (Recommended)`,value:`user`},{label:`None (no persistent memory)`,value:`none`},{label:`Project scope (.workmate/agent-memory/)`,value:`project`},{label:`Local scope (.workmate/agent-memory-local/)`,value:`local`}]:[{label:`Project scope (.workmate/agent-memory/) (Recommended)`,value:`project`},{label:`None (no persistent memory)`,value:`none`},{label:`User scope (~/.workmate/agent-memory/)`,value:`user`},{label:`Local scope (.workmate/agent-memory-local/)`,value:`local`}];return(0,X.jsx)(H,{subtitle:`Configure agent memory`,footerText:(0,X.jsxs)(E,{children:[(0,X.jsx)(C,{shortcut:`↑↓`,action:`navigate`}),(0,X.jsx)(C,{shortcut:`Enter`,action:`select`}),(0,X.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,X.jsx)(w,{children:(0,X.jsx)(fe,{options:i,onChange:t=>{let i=t===`none`?void 0:t,a=r.finalAgent?.agentType;n({selectedMemory:i,finalAgent:r.finalAgent?{...r.finalAgent,memory:i,getSystemPrompt:jt()&&i&&a?()=>`${r.systemPrompt}\n\n${rt(a,i)}`:()=>r.systemPrompt}:void 0}),e()},onCancel:t},`memory-select`)})})}var X,Dr=e((()=>{k(),S(),At(),Ve(),x(),u(),W(),U(),X=A()}));function Or(){let{goNext:e,goBack:t,updateWizardData:n,goToStep:r}=V();return(0,kr.jsx)(H,{subtitle:`Creation method`,footerText:(0,kr.jsxs)(E,{children:[(0,kr.jsx)(C,{shortcut:`↑↓`,action:`navigate`}),(0,kr.jsx)(C,{shortcut:`Enter`,action:`select`}),(0,kr.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,kr.jsx)(w,{children:(0,kr.jsx)(fe,{options:[{label:`Generate with Work Mate (recommended)`,value:`generate`},{label:`Manual configuration`,value:`manual`}],onChange:t=>{let i=t;n({method:i,wasGenerated:i===`generate`}),i===`generate`?e():r(3)},onCancel:()=>t()},`method-select`)})})}var kr,Ar=e((()=>{k(),x(),u(),W(),U(),kr=A()}));function jr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=V();return(0,Mr.jsx)(H,{subtitle:`Select model`,footerText:(0,Mr.jsxs)(E,{children:[(0,Mr.jsx)(C,{shortcut:`↑↓`,action:`navigate`}),(0,Mr.jsx)(C,{shortcut:`Enter`,action:`select`}),(0,Mr.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,Mr.jsx)(kn,{initialModel:r.selectedModel,onComplete:t=>{n({selectedModel:t}),e()},onCancel:t})})}var Mr,Nr=e((()=>{x(),k(),W(),U(),Mn(),Mr=A()}));function Pr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=V(),[i,a]=(0,Fr.useState)(r.systemPrompt||``),[o,s]=(0,Fr.useState)(i.length),[c,l]=(0,Fr.useState)(null);return D(`confirm:no`,t,{context:`Settings`}),D(`chat:externalEditor`,(0,Fr.useCallback)(async()=>{let e=await en(i);e.content!==null&&(a(e.content),s(e.content.length))},[i]),{context:`Chat`}),(0,Z.jsx)(H,{subtitle:`System prompt`,footerText:(0,Z.jsxs)(E,{children:[(0,Z.jsx)(C,{shortcut:`Type`,action:`enter text`}),(0,Z.jsx)(C,{shortcut:`Enter`,action:`continue`}),(0,Z.jsx)(m,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,Z.jsx)(m,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,Z.jsxs)(w,{flexDirection:`column`,children:[(0,Z.jsx)(T,{children:`Enter the system prompt for your agent:`}),(0,Z.jsx)(T,{dimColor:!0,children:`Be comprehensive for best results`}),(0,Z.jsx)(w,{marginTop:1,children:(0,Z.jsx)(Pe,{value:i,onChange:a,onSubmit:()=>{let t=i.trim();if(!t){l(`System prompt is required`);return}l(null),n({systemPrompt:t}),e()},placeholder:`You are a helpful code reviewer who...`,columns:80,cursorOffset:o,onChangeCursorOffset:s,focus:!0,showCursor:!0})}),c&&(0,Z.jsx)(w,{marginTop:1,children:(0,Z.jsx)(T,{color:`error`,children:c})})]})})}var Fr,Z,Ir=e((()=>{Fr=t(O(),1),k(),S(),tn(),x(),Ue(),W(),U(),Z=A()}));function Lr({tools:e}){let{goNext:t,goBack:n,updateWizardData:r,wizardData:i}=V(),a=e=>{r({selectedTools:e}),t()},o=i.selectedTools;return(0,Rr.jsx)(H,{subtitle:`Select tools`,footerText:(0,Rr.jsxs)(E,{children:[(0,Rr.jsx)(C,{shortcut:`Enter`,action:`toggle selection`}),(0,Rr.jsx)(C,{shortcut:`↑↓`,action:`navigate`}),(0,Rr.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,Rr.jsx)(Fn,{tools:e,initialTools:o,onComplete:a,onCancel:n})})}var Rr,zr=e((()=>{k(),x(),W(),U(),In(),Rr=A()}));function Br(e){let{goNext:t,goBack:n,updateWizardData:r,wizardData:i}=V(),[a,o]=(0,Vr.useState)(i.agentType||``),[s,c]=(0,Vr.useState)(null),[l,u]=(0,Vr.useState)(a.length);return D(`confirm:no`,n,{context:`Settings`}),(0,Q.jsx)(H,{subtitle:`Agent type (identifier)`,footerText:(0,Q.jsxs)(E,{children:[(0,Q.jsx)(C,{shortcut:`Type`,action:`enter text`}),(0,Q.jsx)(C,{shortcut:`Enter`,action:`continue`}),(0,Q.jsx)(m,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,Q.jsxs)(w,{flexDirection:`column`,children:[(0,Q.jsx)(T,{children:`Enter a unique identifier for your agent:`}),(0,Q.jsx)(w,{marginTop:1,children:(0,Q.jsx)(Pe,{value:a,onChange:o,onSubmit:e=>{let n=e.trim(),i=or(n);if(i){c(i);return}c(null),r({agentType:n}),t()},placeholder:`e.g., test-runner, tech-lead, etc`,columns:60,cursorOffset:l,onChangeCursorOffset:u,focus:!0,showCursor:!0})}),s&&(0,Q.jsx)(w,{marginTop:1,children:(0,Q.jsx)(T,{color:`error`,children:s})})]})})}var Vr,Q,Hr=e((()=>{Vr=t(O(),1),k(),S(),x(),Ue(),W(),U(),cr(),Q=A()}));function Ur({tools:e,existingAgents:t,onComplete:n,onCancel:r}){return(0,Wr.jsx)(qn,{steps:[wr,Or,Sr,()=>(0,Wr.jsx)(Br,{existingAgents:t}),Pr,hr,()=>(0,Wr.jsx)(Lr,{tools:e}),jr,rr,...jt()?[Er]:[],()=>(0,Wr.jsx)(dr,{tools:e,existingAgents:t,onComplete:n})],initialData:{},onComplete:()=>{},onCancel:r,title:`Create new agent`,showStepCounter:!1})}var Wr,Gr=e((()=>{At(),W(),ar(),mr(),_r(),Cr(),Tr(),Dr(),Ar(),Nr(),Ir(),zr(),Hr(),Wr=A()}));function Kr({tools:e,onExit:t}){let[n,r]=(0,qr.useState)({mode:`list-agents`,source:`all`}),i=De(e=>e.agentDefinitions),a=De(e=>e.mcp.tools),o=De(e=>e.toolPermissionContext),c=s(),{allAgents:l,activeAgents:u}=i,[d,f]=(0,qr.useState)([]),p=Qt(e,a,o);Xt();let m=(0,qr.useMemo)(()=>({"built-in":l.filter(e=>e.source===`built-in`),userSettings:l.filter(e=>e.source===`userSettings`),projectSettings:l.filter(e=>e.source===`projectSettings`),policySettings:l.filter(e=>e.source===`policySettings`),localSettings:l.filter(e=>e.source===`localSettings`),flagSettings:l.filter(e=>e.source===`flagSettings`),plugin:l.filter(e=>e.source===`plugin`),all:l}),[l]),h=(0,qr.useCallback)(e=>{f(t=>[...t,e]),r({mode:`list-agents`,source:`all`})},[]),g=(0,qr.useCallback)(async e=>{try{await bn(e),c(t=>{let n=t.agentDefinitions.allAgents.filter(t=>!(t.agentType===e.agentType&&t.source===e.source));return{...t,agentDefinitions:{...t.agentDefinitions,allAgents:n,activeAgents:Xe(n)}}}),f(t=>[...t,`Deleted agent: ${ct.bold(e.agentType)}`]),r({mode:`list-agents`,source:`all`})}catch(e){Nt(gt(e))}},[c]);switch(n.mode){case`list-agents`:{let e=qt(n.source===`all`?[...m[`built-in`],...m.userSettings,...m.projectSettings,...m.localSettings,...m.policySettings,...m.flagSettings,...m.plugin]:m[n.source],u);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Wn,{source:n.source,agents:e,onBack:()=>{t((d.length>0?`Agent changes:\n${d.join(`
101
+ `)}`:void 0)??`Agents dialog dismissed`,{display:d.length===0?`system`:void 0})},onSelect:e=>r({mode:`agent-menu`,agent:e,previousMode:n}),onCreateNew:()=>r({mode:`create-agent`}),changes:d}),(0,$.jsx)(Vn,{})]})}case`create-agent`:return(0,$.jsx)(Ur,{tools:p,existingAgents:u,onComplete:h,onCancel:()=>r({mode:`list-agents`,source:`all`})});case`agent-menu`:{let e=l.find(e=>e.agentType===n.agent.agentType&&e.source===n.agent.source)||n.agent,t=[{label:`View agent`,value:`view`},...e.source!==`built-in`&&e.source!==`plugin`&&e.source!==`flagSettings`?[{label:`Edit agent`,value:`edit`},{label:`Delete agent`,value:`delete`}]:[],{label:`Back`,value:`back`}];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ut,{title:n.agent.agentType,onCancel:()=>r(n.previousMode),hideInputGuide:!0,children:(0,$.jsxs)(w,{flexDirection:`column`,children:[(0,$.jsx)(fe,{options:t,onChange:t=>{switch(t){case`view`:r({mode:`view-agent`,agent:e,previousMode:n.previousMode});break;case`edit`:r({mode:`edit-agent`,agent:e,previousMode:n});break;case`delete`:r({mode:`delete-confirm`,agent:e,previousMode:n});break;case`back`:r(n.previousMode);break}},onCancel:()=>r(n.previousMode)}),d.length>0&&(0,$.jsx)(w,{marginTop:1,children:(0,$.jsx)(T,{dimColor:!0,children:d[d.length-1]})})]})}),(0,$.jsx)(Vn,{})]})}case`view-agent`:{let e=l.find(e=>e.agentType===n.agent.agentType&&e.source===n.agent.source)||n.agent;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ut,{title:e.agentType,onCancel:()=>r({mode:`agent-menu`,agent:e,previousMode:n.previousMode}),hideInputGuide:!0,children:(0,$.jsx)(Cn,{agent:e,tools:p,allAgents:l,onBack:()=>r({mode:`agent-menu`,agent:e,previousMode:n.previousMode})})}),(0,$.jsx)(Vn,{instructions:`Press Enter or Esc to go back`})]})}case`delete-confirm`:return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ut,{title:`Delete agent`,onCancel:()=>{`previousMode`in n&&r(n.previousMode)},color:`error`,children:[(0,$.jsxs)(T,{children:[`Are you sure you want to delete the agent `,(0,$.jsx)(T,{bold:!0,children:n.agent.agentType}),`?`]}),(0,$.jsx)(w,{marginTop:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`Source: `,n.agent.source]})}),(0,$.jsx)(w,{marginTop:1,children:(0,$.jsx)(fe,{options:[{label:`Yes, delete`,value:`yes`},{label:`No, cancel`,value:`no`}],onChange:e=>{e===`yes`?g(n.agent):`previousMode`in n&&r(n.previousMode)},onCancel:()=>{`previousMode`in n&&r(n.previousMode)}})})]}),(0,$.jsx)(Vn,{instructions:`Press ↑↓ to navigate, Enter to select, Esc to cancel`})]});case`edit-agent`:{let e=l.find(e=>e.agentType===n.agent.agentType&&e.source===n.agent.source)||n.agent;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ut,{title:`Edit agent: ${e.agentType}`,onCancel:()=>r(n.previousMode),hideInputGuide:!0,children:(0,$.jsx)(zn,{agent:e,tools:p,onSaved:e=>{h(e),r(n.previousMode)},onBack:()=>r(n.previousMode)})}),(0,$.jsx)(Vn,{})]})}default:return null}}var qr,$,Jr=e((()=>{lt(),qr=t(O(),1),Zt(),$t(),k(),we(),Gt(),We(),mt(),Mt(),u(),wn(),Bn(),Un(),Kn(),Sn(),Gr(),$=A()}));async function Yr(e,t){let n=t.getAppState().toolPermissionContext;return(0,Xr.jsx)(Kr,{tools:ne(n),onExit:e})}var Xr;e((()=>{Jr(),Ke(),Xr=A()}))();export{Yr as call};
@@ -1,2 +1,2 @@
1
- import{i as e,o as t,r as n}from"./loadAgentsDir-JrGMJN05.js";import{n as r,t as i}from"./cwd-Besi3Os3.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./agentDisplay-CrQvGkTT.js";o(),t(),r();function d(e){let t=a(e),n=[e.agentType];return t&&n.push(t),e.memory&&n.push(`${e.memory} memory`),n.join(` · `)}async function f(){let{allAgents:t}=await e(i()),r=c(t,n(t)),a=[],o=0;for(let{label:e,source:t}of u){let n=r.filter(e=>e.source===t).sort(s);if(n.length!==0){a.push(`${e}:`);for(let e of n)if(e.overriddenBy){let t=l(e.overriddenBy);a.push(` (shadowed by ${t}) ${d(e)}`)}else a.push(` ${d(e)}`),o++;a.push(``)}}a.length===0?console.log(`No agents found.`):(console.log(`${o} active agents\n`),console.log(a.join(`
1
+ import{i as e,o as t,r as n}from"./loadAgentsDir-CwEfQDOw.js";import{n as r,t as i}from"./cwd-Besi3Os3.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./agentDisplay-tRprY4gB.js";o(),t(),r();function d(e){let t=a(e),n=[e.agentType];return t&&n.push(t),e.memory&&n.push(`${e.memory} memory`),n.join(` · `)}async function f(){let{allAgents:t}=await e(i()),r=c(t,n(t)),a=[],o=0;for(let{label:e,source:t}of u){let n=r.filter(e=>e.source===t).sort(s);if(n.length!==0){a.push(`${e}:`);for(let e of n)if(e.overriddenBy){let t=l(e.overriddenBy);a.push(` (shadowed by ${t}) ${d(e)}`)}else a.push(` ${d(e)}`),o++;a.push(``)}}a.length===0?console.log(`No agents found.`):(console.log(`${o} active agents\n`),console.log(a.join(`
2
2
  `).trimEnd()))}export{f as agentsHandler};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ix as t,Nx as n}from"./loadAgentsDir-JrGMJN05.js";import{g as r,u as i}from"./settings-aUygByiZ.js";function a(){let e=i(),t=[`user`,`project`,`local`].flatMap(e=>n(e).errors);return{settings:e.settings,errors:[...e.errors,...t]}}var o=e((()=>{t(),r()}));export{o as n,a as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ix as t,Nx as n}from"./loadAgentsDir-CwEfQDOw.js";import{g as r,u as i}from"./settings-CvhsRFaT.js";function a(){let e=i(),t=[`user`,`project`,`local`].flatMap(e=>n(e).errors);return{settings:e.settings,errors:[...e.errors,...t]}}var o=e((()=>{t(),r()}));export{o as n,a as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./axios-DaWTGg7G.js";import{i as r,n as i,r as a,t as o}from"./lazySchema-B4D4qJVE.js";import{C as s,P as c,R as l,U as u,c as d,i as f,x as p}from"./debug-BQj6h99Q.js";import{h as m}from"./config-BkbL2e5Q.js";import{o as h,s as g}from"./log-BlJ7CcKG.js";import{l as _,u as v}from"./oauth-D38aRTUb.js";import{Bt as y,Nr as b,Ot as x,Pr as S,_n as C,vn as w}from"./model-CmDF8O9G.js";import{a as T,i as E}from"./detectRepository-Qy3zKoyn.js";import{randomUUID as D}from"crypto";function O(e){return t.isAxiosError(e)?!e.response||e.response.status>=500:!1}async function k(e,n){let r;for(let i=0;i<=R;i++)try{return await t.get(e,n)}catch(e){if(r=e,!O(e))throw e;if(i>=R)throw d(`Teleport request failed after ${i+1} attempts: ${c(e)}`),e;let t=L[i]??2e3;d(`Teleport request failed (attempt ${i+1}/${R+1}), retrying in ${t}ms: ${c(e)}`),await w(t)}throw r}async function A(){let e=x()?.accessToken;if(e===void 0)throw Error(`Work Mate web sessions require authentication with a Claude.ai account. API key authentication is not sufficient.`);let t=await b();if(!t)throw Error(`Unable to get organization UUID`);return{accessToken:e,orgUUID:t}}async function j(){let{accessToken:e,orgUUID:t}=await A(),n=`${_().BASE_API_URL}/v1/sessions`;try{let r=await k(n,{headers:{...M(e),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":t}});if(r.status!==200)throw Error(`Failed to fetch code sessions: ${r.statusText}`);return r.data.data.map(e=>{let t=e.session_context.sources.find(e=>e.type===`git_repository`),n=null;if(t?.url){let e=T(t.url);if(e){let[r,i]=e.split(`/`);r&&i&&(n={name:i,owner:{login:r},default_branch:t.revision||void 0})}}return{id:e.id,title:e.title||`Untitled`,description:``,status:e.session_status,repo:n,turns:[],created_at:e.created_at,updated_at:e.updated_at}})}catch(e){throw g(u(e)),e}}function M(e){return{Authorization:`Bearer ${e}`,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`}}async function N(e){let{accessToken:n,orgUUID:r}=await A(),i=`${_().BASE_API_URL}/v1/sessions/${e}`,a={...M(n),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":r},o=await t.get(i,{headers:a,timeout:15e3,validateStatus:e=>e<500});if(o.status!==200){let t=o.data?.error?.message;throw o.status===404?Error(`Session not found: ${e}`):o.status===401?Error(`Session expired.`):Error(t||`Failed to fetch session: ${o.status} ${o.statusText}`)}return o.data}function P(e){return(e.session_context.outcomes?.find(e=>e.type===`git_repository`))?.git_info?.branches[0]}async function F(e,n,r){try{let{accessToken:i,orgUUID:a}=await A(),o=`${_().BASE_API_URL}/v1/sessions/${e}/events`,c={...M(i),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":a},l={events:[{uuid:r?.uuid??D(),session_id:e,type:`user`,parent_tool_use_id:null,message:{role:`user`,content:n}}]};d(`[sendEventToRemoteSession] Sending event to session ${e}`);let u=await t.post(o,l,{headers:c,validateStatus:e=>e<500,timeout:3e4});return u.status===200||u.status===201?(d(`[sendEventToRemoteSession] Successfully sent event to session ${e}`),!0):(d(`[sendEventToRemoteSession] Failed with status ${u.status}: ${s(u.data)}`),!1)}catch(e){return d(`[sendEventToRemoteSession] Error: ${c(e)}`),!1}}async function I(e,n){try{let{accessToken:r,orgUUID:i}=await A(),a=`${_().BASE_API_URL}/v1/sessions/${e}`,o={...M(r),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":i};d(`[updateSessionTitle] Updating title for session ${e}: "${n}"`);let c=await t.patch(a,{title:n},{headers:o,validateStatus:e=>e<500});return c.status===200?(d(`[updateSessionTitle] Successfully updated title for session ${e}`),!0):(d(`[updateSessionTitle] Failed with status ${c.status}: ${s(c.data)}`),!1)}catch(e){return d(`[updateSessionTitle] Error: ${c(e)}`),!1}}var L,R,z=e((()=>{n(),v(),S(),a(),y(),m(),f(),E(),l(),o(),h(),C(),p(),L=[2e3,4e3,8e3,16e3],R=L.length,i(()=>r.object({id:r.string(),title:r.string(),description:r.string(),status:r.enum([`idle`,`working`,`waiting`,`completed`,`archived`,`cancelled`,`rejected`]),repo:r.object({name:r.string(),owner:r.object({login:r.string()}),default_branch:r.string().optional()}).nullable(),turns:r.array(r.string()),created_at:r.string(),updated_at:r.string()}))}));export{M as a,A as c,P as i,F as l,j as n,z as o,N as r,O as s,k as t,I as u};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./axios-DaWTGg7G.js";import{i as r,n as i,r as a,t as o}from"./lazySchema-B4D4qJVE.js";import{C as s,P as c,R as l,U as u,c as d,i as f,x as p}from"./debug-BQj6h99Q.js";import{h as m}from"./config-BSkuQZNf.js";import{o as h,s as g}from"./log-BlJ7CcKG.js";import{l as _,u as v}from"./oauth-D38aRTUb.js";import{Bt as y,Nr as b,Ot as x,Pr as S,_n as C,vn as w}from"./model-CeG-iOKF.js";import{a as T,i as E}from"./detectRepository-Qy3zKoyn.js";import{randomUUID as D}from"crypto";function O(e){return t.isAxiosError(e)?!e.response||e.response.status>=500:!1}async function k(e,n){let r;for(let i=0;i<=R;i++)try{return await t.get(e,n)}catch(e){if(r=e,!O(e))throw e;if(i>=R)throw d(`Teleport request failed after ${i+1} attempts: ${c(e)}`),e;let t=L[i]??2e3;d(`Teleport request failed (attempt ${i+1}/${R+1}), retrying in ${t}ms: ${c(e)}`),await w(t)}throw r}async function A(){let e=x()?.accessToken;if(e===void 0)throw Error(`Work Mate web sessions require authentication with a Claude.ai account. API key authentication is not sufficient.`);let t=await b();if(!t)throw Error(`Unable to get organization UUID`);return{accessToken:e,orgUUID:t}}async function j(){let{accessToken:e,orgUUID:t}=await A(),n=`${_().BASE_API_URL}/v1/sessions`;try{let r=await k(n,{headers:{...M(e),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":t}});if(r.status!==200)throw Error(`Failed to fetch code sessions: ${r.statusText}`);return r.data.data.map(e=>{let t=e.session_context.sources.find(e=>e.type===`git_repository`),n=null;if(t?.url){let e=T(t.url);if(e){let[r,i]=e.split(`/`);r&&i&&(n={name:i,owner:{login:r},default_branch:t.revision||void 0})}}return{id:e.id,title:e.title||`Untitled`,description:``,status:e.session_status,repo:n,turns:[],created_at:e.created_at,updated_at:e.updated_at}})}catch(e){throw g(u(e)),e}}function M(e){return{Authorization:`Bearer ${e}`,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`}}async function N(e){let{accessToken:n,orgUUID:r}=await A(),i=`${_().BASE_API_URL}/v1/sessions/${e}`,a={...M(n),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":r},o=await t.get(i,{headers:a,timeout:15e3,validateStatus:e=>e<500});if(o.status!==200){let t=o.data?.error?.message;throw o.status===404?Error(`Session not found: ${e}`):o.status===401?Error(`Session expired.`):Error(t||`Failed to fetch session: ${o.status} ${o.statusText}`)}return o.data}function P(e){return(e.session_context.outcomes?.find(e=>e.type===`git_repository`))?.git_info?.branches[0]}async function F(e,n,r){try{let{accessToken:i,orgUUID:a}=await A(),o=`${_().BASE_API_URL}/v1/sessions/${e}/events`,c={...M(i),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":a},l={events:[{uuid:r?.uuid??D(),session_id:e,type:`user`,parent_tool_use_id:null,message:{role:`user`,content:n}}]};d(`[sendEventToRemoteSession] Sending event to session ${e}`);let u=await t.post(o,l,{headers:c,validateStatus:e=>e<500,timeout:3e4});return u.status===200||u.status===201?(d(`[sendEventToRemoteSession] Successfully sent event to session ${e}`),!0):(d(`[sendEventToRemoteSession] Failed with status ${u.status}: ${s(u.data)}`),!1)}catch(e){return d(`[sendEventToRemoteSession] Error: ${c(e)}`),!1}}async function I(e,n){try{let{accessToken:r,orgUUID:i}=await A(),a=`${_().BASE_API_URL}/v1/sessions/${e}`,o={...M(r),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":i};d(`[updateSessionTitle] Updating title for session ${e}: "${n}"`);let c=await t.patch(a,{title:n},{headers:o,validateStatus:e=>e<500});return c.status===200?(d(`[updateSessionTitle] Successfully updated title for session ${e}`),!0):(d(`[updateSessionTitle] Failed with status ${c.status}: ${s(c.data)}`),!1)}catch(e){return d(`[updateSessionTitle] Error: ${c(e)}`),!1}}var L,R,z=e((()=>{n(),v(),S(),a(),y(),m(),f(),E(),l(),o(),h(),C(),p(),L=[2e3,4e3,8e3,16e3],R=L.length,i(()=>r.object({id:r.string(),title:r.string(),description:r.string(),status:r.enum([`idle`,`working`,`waiting`,`completed`,`archived`,`cancelled`,`rejected`]),repo:r.object({name:r.string(),owner:r.object({login:r.string()}),default_branch:r.string().optional()}).nullable(),turns:r.array(r.string()),created_at:r.string(),updated_at:r.string()}))}));export{M as a,A as c,P as i,F as l,j as n,z as o,N as r,O as s,k as t,I as u};
@@ -0,0 +1 @@
1
+ import{a as e,o as t}from"./api-ClAyS7cQ.js";t();export{e as getOAuthHeaders};
@@ -1,4 +1,4 @@
1
- import{d as e,o as t}from"./envUtils-DcaKZlRU.js";import{n,t as r}from"./defineProperty-C-QyHrDq.js";import{n as i,t as a}from"./axios-DaWTGg7G.js";import{aS as o,nf as s,oS as c,rf as l}from"./loadAgentsDir-JrGMJN05.js";import{C as ee,P as u,R as te,c as d,i as ne,x as f}from"./debug-BQj6h99Q.js";import{g as p,n as m}from"./settings-aUygByiZ.js";import{c as re,h,y as g}from"./config-BkbL2e5Q.js";import{o as _,s as v}from"./log-BlJ7CcKG.js";import{n as y,r as b}from"./analytics-DJobLaWP.js";import{l as x,u as S}from"./oauth-D38aRTUb.js";import{$n as ie,Ar as ae,Br as C,Bt as w,Cn as oe,Dt as se,En as ce,Ft as le,Hr as T,Ir as E,Mr as D,Or as O,Ot as k,Pr as A,Rr as j,Sn as M,St as N,Ur as P,fn as F,gn as I,ii as L,jn as R,jr as z,jt as B,kr as V,mn as H,nn as U,nr as W,oi as ue,pn as G,un as de,yt as fe,zr as K}from"./model-CmDF8O9G.js";import{n as pe,t as me}from"./userAgent-BggRZ-ZE.js";import{F as q,T as he}from"./sessionState-C2REgUrs.js";import{d as ge,u as _e}from"./firstPartyEventLogger-D4yuDP-n.js";import{n as ve}from"./trustedDevice-BF78PNK8.js";import{i as ye,r as be}from"./grove-DsAIY-rZ.js";import{t as xe}from"./remoteManagedSettings-BcLJLEr7.js";import{d as Se,n as Ce,t as we}from"./status-BraYBx4N.js";import{createHash as Te,randomBytes as J}from"crypto";import{createServer as Ee}from"http";l(),w(),R(),h(),oe(),I(),_e();async function Y(){k.cache?.clear?.(),ve(),ce(),H(),ge(),be.cache?.clear?.(),ye.cache?.clear?.(),await xe(),await s()}async function De({clearOnboarding:e=!1}){let{flushTelemetry:t}=await import(`./instrumentation-5cSwEKaF.js`);await t(),await de(),M().delete(),await Y(),g(t=>{let n={...t};return e&&(n.hasCompletedOnboarding=!1,n.subscriptionNoticeCount=0,n.hasAvailableSubscription=!1,n.customApiKeyResponses?.approved&&(n.customApiKeyResponses={...n.customApiKeyResponses,approved:[]})),n.oauthAccount=void 0,n})}t(),n(),te(),f(),ne(),y(),p(),ue(),P(),A(),he(),a(),S(),h(),W(),_(),pe();async function Oe(){try{if(re().claudeCodeFirstTokenDate!==void 0)return;let e=ie();if(e.error){v(Error(`Failed to get auth headers: ${e.error}`));return}let t=`${x().BASE_API_URL}/api/organization/claude_code_first_token_date`,n=(await i.get(t,{headers:{...e.headers,"User-Agent":me()},timeout:1e4})).data?.first_token_date??null;if(n!==null){let e=new Date(n).getTime();if(isNaN(e)){v(Error(`Received invalid first_token_date from API: ${n}`));return}}g(e=>({...e,claudeCodeFirstTokenDate:n}))}catch(e){v(e)}}o(),S(),_();var ke=class{constructor(e=`/callback`){r(this,`localServer`,void 0),r(this,`port`,0),r(this,`promiseResolver`,null),r(this,`promiseRejecter`,null),r(this,`expectedState`,null),r(this,`pendingResponse`,null),r(this,`callbackPath`,void 0),this.localServer=Ee(),this.callbackPath=e}async start(e){return new Promise((t,n)=>{this.localServer.once(`error`,e=>{n(Error(`Failed to start OAuth callback server: ${e.message}`))}),this.localServer.listen(e??0,`localhost`,()=>{let e=this.localServer.address();this.port=e.port,t(this.port)})})}getPort(){return this.port}hasPendingResponse(){return this.pendingResponse!==null}async waitForAuthorization(e,t){return new Promise((n,r)=>{this.promiseResolver=n,this.promiseRejecter=r,this.expectedState=e,this.startLocalListener(t)})}handleSuccessRedirect(e,t){if(!this.pendingResponse)return;if(t){t(this.pendingResponse,e),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect`,{custom_handler:!0});return}let n=K(e)?x().CLAUDEAI_SUCCESS_URL:x().CONSOLE_SUCCESS_URL;this.pendingResponse.writeHead(302,{Location:n}),this.pendingResponse.end(),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect`,{})}handleErrorRedirect(){if(!this.pendingResponse)return;let e=x().CLAUDEAI_SUCCESS_URL;this.pendingResponse.writeHead(302,{Location:e}),this.pendingResponse.end(),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect_error`,{})}startLocalListener(e){this.localServer.on(`request`,this.handleRedirect.bind(this)),this.localServer.on(`error`,this.handleError.bind(this)),e()}handleRedirect(e,t){let n=new URL(e.url||``,`http://${e.headers.host||`localhost`}`);if(n.pathname!==this.callbackPath){t.writeHead(404),t.end();return}let r=n.searchParams.get(`code`)??void 0,i=n.searchParams.get(`state`)??void 0;this.validateAndRespond(r,i,t)}validateAndRespond(e,t,n){if(!e){n.writeHead(400),n.end(`Authorization code not found`),this.reject(Error(`No authorization code received`));return}if(t!==this.expectedState){n.writeHead(400),n.end(`Invalid state parameter`),this.reject(Error(`Invalid state parameter`));return}this.pendingResponse=n,this.resolve(e)}handleError(e){v(e),this.close(),this.reject(e)}resolve(e){this.promiseResolver&&(this.promiseResolver(e),this.promiseResolver=null,this.promiseRejecter=null)}reject(e){this.promiseRejecter&&(this.promiseRejecter(e),this.promiseResolver=null,this.promiseRejecter=null)}close(){this.pendingResponse&&this.handleErrorRedirect(),this.localServer&&(this.localServer.removeAllListeners(),this.localServer.close())}};function X(e){return e.toString(`base64`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function Z(){return X(J(32))}function Ae(e){let t=Te(`sha256`);return t.update(e),X(t.digest())}function je(){return X(J(32))}y(),A(),n();var Q=class{constructor(){r(this,`codeVerifier`,void 0),r(this,`authCodeListener`,null),r(this,`port`,null),r(this,`manualAuthCodeResolver`,null),this.codeVerifier=Z()}async startOAuthFlow(e,t){this.authCodeListener=new ke,this.port=await this.authCodeListener.start();let n=Ae(this.codeVerifier),r=je(),i={codeChallenge:n,state:r,port:this.port,loginWithClaudeAi:t?.loginWithClaudeAi,inferenceOnly:t?.inferenceOnly,orgUUID:t?.orgUUID,loginHint:t?.loginHint,loginMethod:t?.loginMethod},a=O({...i,isManual:!0}),o=O({...i,isManual:!1}),s=await this.waitForAuthorizationCode(r,async()=>{t?.skipBrowserOpen?await e(a,o):(await e(a),await c(o))}),l=this.authCodeListener?.hasPendingResponse()??!1;b(`tengu_oauth_auth_code_received`,{automatic:l});try{let e=await ae(s,r,this.codeVerifier,this.port,!l,t?.expiresIn),n=await D(e.access_token);if(l){let t=E(e.scope);this.authCodeListener?.handleSuccessRedirect(t)}return this.formatTokens(e,n.subscriptionType,n.rateLimitTier,n.rawProfile)}catch(e){throw l&&this.authCodeListener?.handleErrorRedirect(),e}finally{this.authCodeListener?.close()}}async waitForAuthorizationCode(e,t){return new Promise((n,r)=>{this.manualAuthCodeResolver=n,this.authCodeListener?.waitForAuthorization(e,t).then(e=>{this.manualAuthCodeResolver=null,n(e)}).catch(e=>{this.manualAuthCodeResolver=null,r(e)})})}handleManualAuthCodeInput(e){this.manualAuthCodeResolver&&(this.manualAuthCodeResolver(e.authorizationCode),this.manualAuthCodeResolver=null,this.authCodeListener?.close())}formatTokens(e,t,n,r){return{accessToken:e.access_token,refreshToken:e.refresh_token,expiresAt:Date.now()+e.expires_in*1e3,scopes:E(e.scope),subscriptionType:t,rateLimitTier:n,profile:r,tokenAccount:e.account?{uuid:e.account.uuid,emailAddress:e.account.email_address,organizationUuid:e.organization?.uuid}:void 0}}cleanup(){this.authCodeListener?.close(),this.manualAuthCodeResolver=null}};y(),A(),w(),h(),_(),Se();async function $(e){await De({clearOnboarding:!1});let t=e.profile??await T(e.accessToken);t?C({accountUuid:t.account.uuid,emailAddress:t.account.email,organizationUuid:t.organization.uuid,displayName:t.account.display_name||void 0,hasExtraUsageEnabled:t.organization.has_extra_usage_enabled??void 0,billingType:t.organization.billing_type??void 0,subscriptionCreatedAt:t.organization.subscription_created_at??void 0,accountCreatedAt:t.account.created_at}):e.tokenAccount&&C({accountUuid:e.tokenAccount.uuid,emailAddress:e.tokenAccount.emailAddress,organizationUuid:e.tokenAccount.organizationUuid});let n=F(e);if(fe(),n.warning&&b(`tengu_oauth_storage_warning`,{warning:n.warning}),await z(e.accessToken).catch(e=>d(String(e),{level:`error`})),K(e.scopes))await Oe().catch(e=>d(String(e),{level:`error`}));else if(!await V(e.accessToken))throw Error(`Unable to create API key. The server accepted the request but did not return a key.`);await Y()}async function Me({email:e,sso:t,console:n,claudeai:r}){n&&r&&(process.stderr.write(`Error: --console and --claudeai cannot be used together.
1
+ import{d as e,o as t}from"./envUtils-DcaKZlRU.js";import{n,t as r}from"./defineProperty-C-QyHrDq.js";import{n as i,t as a}from"./axios-DaWTGg7G.js";import{aS as o,nf as s,oS as c,rf as l}from"./loadAgentsDir-CwEfQDOw.js";import{C as ee,P as u,R as te,c as d,i as ne,x as f}from"./debug-BQj6h99Q.js";import{g as p,n as m}from"./settings-CvhsRFaT.js";import{c as re,h,y as g}from"./config-BSkuQZNf.js";import{o as _,s as v}from"./log-BlJ7CcKG.js";import{n as y,r as b}from"./analytics-DJobLaWP.js";import{l as x,u as S}from"./oauth-D38aRTUb.js";import{$n as ie,Ar as ae,Br as C,Bt as w,Cn as oe,Dt as se,En as ce,Ft as le,Hr as T,Ir as E,Mr as D,Or as O,Ot as k,Pr as A,Rr as j,Sn as M,St as N,Ur as P,fn as F,gn as I,ii as L,jn as R,jr as z,jt as B,kr as V,mn as H,nn as U,nr as W,oi as ue,pn as G,un as de,yt as fe,zr as K}from"./model-CeG-iOKF.js";import{n as pe,t as me}from"./userAgent-aoe_xVAb.js";import{F as q,T as he}from"./sessionState-zhvcDpb2.js";import{d as ge,u as _e}from"./firstPartyEventLogger-7pAyUdbp.js";import{n as ve}from"./trustedDevice-DWZxDUxS.js";import{i as ye,r as be}from"./grove-Bck1zFaD.js";import{t as xe}from"./remoteManagedSettings-CfFmrRze.js";import{d as Se,n as Ce,t as we}from"./status-BP_R8051.js";import{createHash as Te,randomBytes as J}from"crypto";import{createServer as Ee}from"http";l(),w(),R(),h(),oe(),I(),_e();async function Y(){k.cache?.clear?.(),ve(),ce(),H(),ge(),be.cache?.clear?.(),ye.cache?.clear?.(),await xe(),await s()}async function De({clearOnboarding:e=!1}){let{flushTelemetry:t}=await import(`./instrumentation-jsPu6qqs.js`);await t(),await de(),M().delete(),await Y(),g(t=>{let n={...t};return e&&(n.hasCompletedOnboarding=!1,n.subscriptionNoticeCount=0,n.hasAvailableSubscription=!1,n.customApiKeyResponses?.approved&&(n.customApiKeyResponses={...n.customApiKeyResponses,approved:[]})),n.oauthAccount=void 0,n})}t(),n(),te(),f(),ne(),y(),p(),ue(),P(),A(),he(),a(),S(),h(),W(),_(),pe();async function Oe(){try{if(re().claudeCodeFirstTokenDate!==void 0)return;let e=ie();if(e.error){v(Error(`Failed to get auth headers: ${e.error}`));return}let t=`${x().BASE_API_URL}/api/organization/claude_code_first_token_date`,n=(await i.get(t,{headers:{...e.headers,"User-Agent":me()},timeout:1e4})).data?.first_token_date??null;if(n!==null){let e=new Date(n).getTime();if(isNaN(e)){v(Error(`Received invalid first_token_date from API: ${n}`));return}}g(e=>({...e,claudeCodeFirstTokenDate:n}))}catch(e){v(e)}}o(),S(),_();var ke=class{constructor(e=`/callback`){r(this,`localServer`,void 0),r(this,`port`,0),r(this,`promiseResolver`,null),r(this,`promiseRejecter`,null),r(this,`expectedState`,null),r(this,`pendingResponse`,null),r(this,`callbackPath`,void 0),this.localServer=Ee(),this.callbackPath=e}async start(e){return new Promise((t,n)=>{this.localServer.once(`error`,e=>{n(Error(`Failed to start OAuth callback server: ${e.message}`))}),this.localServer.listen(e??0,`localhost`,()=>{let e=this.localServer.address();this.port=e.port,t(this.port)})})}getPort(){return this.port}hasPendingResponse(){return this.pendingResponse!==null}async waitForAuthorization(e,t){return new Promise((n,r)=>{this.promiseResolver=n,this.promiseRejecter=r,this.expectedState=e,this.startLocalListener(t)})}handleSuccessRedirect(e,t){if(!this.pendingResponse)return;if(t){t(this.pendingResponse,e),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect`,{custom_handler:!0});return}let n=K(e)?x().CLAUDEAI_SUCCESS_URL:x().CONSOLE_SUCCESS_URL;this.pendingResponse.writeHead(302,{Location:n}),this.pendingResponse.end(),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect`,{})}handleErrorRedirect(){if(!this.pendingResponse)return;let e=x().CLAUDEAI_SUCCESS_URL;this.pendingResponse.writeHead(302,{Location:e}),this.pendingResponse.end(),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect_error`,{})}startLocalListener(e){this.localServer.on(`request`,this.handleRedirect.bind(this)),this.localServer.on(`error`,this.handleError.bind(this)),e()}handleRedirect(e,t){let n=new URL(e.url||``,`http://${e.headers.host||`localhost`}`);if(n.pathname!==this.callbackPath){t.writeHead(404),t.end();return}let r=n.searchParams.get(`code`)??void 0,i=n.searchParams.get(`state`)??void 0;this.validateAndRespond(r,i,t)}validateAndRespond(e,t,n){if(!e){n.writeHead(400),n.end(`Authorization code not found`),this.reject(Error(`No authorization code received`));return}if(t!==this.expectedState){n.writeHead(400),n.end(`Invalid state parameter`),this.reject(Error(`Invalid state parameter`));return}this.pendingResponse=n,this.resolve(e)}handleError(e){v(e),this.close(),this.reject(e)}resolve(e){this.promiseResolver&&(this.promiseResolver(e),this.promiseResolver=null,this.promiseRejecter=null)}reject(e){this.promiseRejecter&&(this.promiseRejecter(e),this.promiseResolver=null,this.promiseRejecter=null)}close(){this.pendingResponse&&this.handleErrorRedirect(),this.localServer&&(this.localServer.removeAllListeners(),this.localServer.close())}};function X(e){return e.toString(`base64`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function Z(){return X(J(32))}function Ae(e){let t=Te(`sha256`);return t.update(e),X(t.digest())}function je(){return X(J(32))}y(),A(),n();var Q=class{constructor(){r(this,`codeVerifier`,void 0),r(this,`authCodeListener`,null),r(this,`port`,null),r(this,`manualAuthCodeResolver`,null),this.codeVerifier=Z()}async startOAuthFlow(e,t){this.authCodeListener=new ke,this.port=await this.authCodeListener.start();let n=Ae(this.codeVerifier),r=je(),i={codeChallenge:n,state:r,port:this.port,loginWithClaudeAi:t?.loginWithClaudeAi,inferenceOnly:t?.inferenceOnly,orgUUID:t?.orgUUID,loginHint:t?.loginHint,loginMethod:t?.loginMethod},a=O({...i,isManual:!0}),o=O({...i,isManual:!1}),s=await this.waitForAuthorizationCode(r,async()=>{t?.skipBrowserOpen?await e(a,o):(await e(a),await c(o))}),l=this.authCodeListener?.hasPendingResponse()??!1;b(`tengu_oauth_auth_code_received`,{automatic:l});try{let e=await ae(s,r,this.codeVerifier,this.port,!l,t?.expiresIn),n=await D(e.access_token);if(l){let t=E(e.scope);this.authCodeListener?.handleSuccessRedirect(t)}return this.formatTokens(e,n.subscriptionType,n.rateLimitTier,n.rawProfile)}catch(e){throw l&&this.authCodeListener?.handleErrorRedirect(),e}finally{this.authCodeListener?.close()}}async waitForAuthorizationCode(e,t){return new Promise((n,r)=>{this.manualAuthCodeResolver=n,this.authCodeListener?.waitForAuthorization(e,t).then(e=>{this.manualAuthCodeResolver=null,n(e)}).catch(e=>{this.manualAuthCodeResolver=null,r(e)})})}handleManualAuthCodeInput(e){this.manualAuthCodeResolver&&(this.manualAuthCodeResolver(e.authorizationCode),this.manualAuthCodeResolver=null,this.authCodeListener?.close())}formatTokens(e,t,n,r){return{accessToken:e.access_token,refreshToken:e.refresh_token,expiresAt:Date.now()+e.expires_in*1e3,scopes:E(e.scope),subscriptionType:t,rateLimitTier:n,profile:r,tokenAccount:e.account?{uuid:e.account.uuid,emailAddress:e.account.email_address,organizationUuid:e.organization?.uuid}:void 0}}cleanup(){this.authCodeListener?.close(),this.manualAuthCodeResolver=null}};y(),A(),w(),h(),_(),Se();async function $(e){await De({clearOnboarding:!1});let t=e.profile??await T(e.accessToken);t?C({accountUuid:t.account.uuid,emailAddress:t.account.email,organizationUuid:t.organization.uuid,displayName:t.account.display_name||void 0,hasExtraUsageEnabled:t.organization.has_extra_usage_enabled??void 0,billingType:t.organization.billing_type??void 0,subscriptionCreatedAt:t.organization.subscription_created_at??void 0,accountCreatedAt:t.account.created_at}):e.tokenAccount&&C({accountUuid:e.tokenAccount.uuid,emailAddress:e.tokenAccount.emailAddress,organizationUuid:e.tokenAccount.organizationUuid});let n=F(e);if(fe(),n.warning&&b(`tengu_oauth_storage_warning`,{warning:n.warning}),await z(e.accessToken).catch(e=>d(String(e),{level:`error`})),K(e.scopes))await Oe().catch(e=>d(String(e),{level:`error`}));else if(!await V(e.accessToken))throw Error(`Unable to create API key. The server accepted the request but did not return a key.`);await Y()}async function Me({email:e,sso:t,console:n,claudeai:r}){n&&r&&(process.stderr.write(`Error: --console and --claudeai cannot be used together.
2
2
  `),process.exit(1));let i=m(),a=i.forceLoginMethod?i.forceLoginMethod===`claudeai`:!n,o=i.forceLoginOrgUUID,s=process.env.CLAUDE_CODE_OAUTH_REFRESH_TOKEN;if(s){let e=process.env.CLAUDE_CODE_OAUTH_SCOPES;e||(process.stderr.write(`CLAUDE_CODE_OAUTH_SCOPES is required when using CLAUDE_CODE_OAUTH_REFRESH_TOKEN.
3
3
  Set it to the space-separated scopes the refresh token was issued with
4
4
  (e.g. "user:inference" or "user:profile user:inference user:sessions:claude_code user:mcp_servers").
@@ -0,0 +1 @@
1
+ import{Bt as e,It as t,Ot as n,mt as r,yt as i}from"./model-CeG-iOKF.js";e();export{r as checkAndRefreshOAuthTokenIfNeeded,i as clearOAuthTokenCache,n as getClaudeAIOAuthTokens,t as handleOAuth401Error};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./auth-CWAvPfX7.js";export{t as authLogin,e as authStatus};
@@ -0,0 +1 @@
1
+ import{t as e}from"./backgroundHousekeeping-rzQFJiND.js";export{e as startBackgroundHousekeeping};
@@ -1,4 +1,4 @@
1
- import{i as e,o as t}from"./envUtils-DcaKZlRU.js";import{Bb as n,Bd as r,Cc as i,DC as a,La as o,Q as s,Qf as c,Sa as ee,St as l,TC as u,Ta as te,X as d,br as ne,by as f,cm as p,dt as m,ep as h,lr as g,wa as _,wc as v,zb as re,zd as ie}from"./loadAgentsDir-JrGMJN05.js";import{R as y,W as b,Wt as x}from"./state-BPFYBqm1.js";import{n as ae,t as oe}from"./cwd-Besi3Os3.js";import{R as S,U as C,c as w,f as T,i as E,u as D,x as O}from"./debug-BQj6h99Q.js";import{f as k,g as A,y as j}from"./settings-aUygByiZ.js";import{S as M}from"./config-BkbL2e5Q.js";import{o as N,s as P,v as F,y as I}from"./log-BlJ7CcKG.js";import{n as L,r as R}from"./analytics-DJobLaWP.js";import{_ as z,h as B}from"./model-CmDF8O9G.js";import{vn as V,yn as H}from"./prompt-DnPppVz8.js";import{Q as U}from"./sessionState-C2REgUrs.js";import{i as W,t as G}from"./nativeInstaller-xxyUjXbl.js";import{n as se,t as K}from"./allErrors-uyOMiF9U.js";import{r as ce}from"./magicDocs-Dpe3YhyL.js";import{n as le,t as ue}from"./pluginAutoupdate-Bj-CrFuO.js";import{n as de}from"./registerProtocol-Bpte9dly.js";import"os";import{join as q}from"path";import"crypto";t(),x(),ae(),O(),T(),E(),I(),A(),H(),z(),v(),ne(),ce(),d(),N(),S(),o(),f(),d(),n(),S(),N(),o(),f(),p();async function fe(e,t){if(!e)return;let{join:n}=await import(`path`),r=await import(`fs/promises`),i=n(oe(),`.workmate`,`skills`,e,`SKILL.md`),a;try{a=await r.readFile(i,`utf-8`)}catch{P(Error(`Failed to read skill file for improvement: ${i}`));return}let o=t.map(e=>`- ${e.section}: ${e.change}`).join(`
1
+ import{i as e,o as t}from"./envUtils-DcaKZlRU.js";import{Bb as n,Bd as r,Cc as i,DC as a,La as o,Q as s,Qf as c,Sa as ee,St as l,TC as u,Ta as te,X as d,br as ne,by as f,cm as p,dt as m,ep as h,lr as g,wa as _,wc as v,zb as re,zd as ie}from"./loadAgentsDir-CwEfQDOw.js";import{R as y,W as b,Wt as x}from"./state-BPFYBqm1.js";import{n as ae,t as oe}from"./cwd-Besi3Os3.js";import{R as S,U as C,c as w,f as T,i as E,u as D,x as O}from"./debug-BQj6h99Q.js";import{f as k,g as A,y as j}from"./settings-CvhsRFaT.js";import{S as M}from"./config-BSkuQZNf.js";import{o as N,s as P,v as F,y as I}from"./log-BlJ7CcKG.js";import{n as L,r as R}from"./analytics-DJobLaWP.js";import{_ as z,h as B}from"./model-CeG-iOKF.js";import{vn as V,yn as H}from"./prompt-Bm2EEG4F.js";import{Q as U}from"./sessionState-zhvcDpb2.js";import{i as W,t as G}from"./nativeInstaller-CXFD8LDV.js";import{n as se,t as K}from"./allErrors-CQWZ6BPw.js";import{r as ce}from"./magicDocs-qGHR3Cqh.js";import{n as le,t as ue}from"./pluginAutoupdate-B4w7SSYc.js";import{n as de}from"./registerProtocol-DrWIX3Lb.js";import"os";import{join as q}from"path";import"crypto";t(),x(),ae(),O(),T(),E(),I(),A(),H(),z(),v(),ne(),ce(),d(),N(),S(),o(),f(),d(),n(),S(),N(),o(),f(),p();async function fe(e,t){if(!e)return;let{join:n}=await import(`path`),r=await import(`fs/promises`),i=n(oe(),`.workmate`,`skills`,e,`SKILL.md`),a;try{a=await r.readFile(i,`utf-8`)}catch{P(Error(`Failed to read skill file for improvement: ${i}`));return}let o=t.map(e=>`- ${e.section}: ${e.change}`).join(`
2
2
  `),c=B(),l=await s({messages:[ee({content:`You are editing a skill definition file. Apply the following improvements to the skill.
3
3
 
4
4
  <current_skill_file>
@@ -14,4 +14,4 @@ Rules:
14
14
  - Preserve frontmatter (--- block) exactly as-is
15
15
  - Preserve the overall format and style
16
16
  - Do not remove existing content unless an improvement explicitly replaces it
17
- - Output the complete updated file inside <updated_file> tags`})],systemPrompt:U([`You edit skill definition files to incorporate user preferences. Output only the updated file content.`]),thinkingConfig:{type:`disabled`},tools:[],signal:re().signal,options:{getToolPermissionContext:async()=>V(),model:c,toolChoice:void 0,isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,temperatureOverride:0,agents:[],querySource:`skill_improvement_apply`,mcpTools:[]}}),u=_(te(Array.isArray(l.message.content)?l.message.content:[]).trim(),`updated_file`);if(!u){P(Error(`Skill improvement apply: no updated_file tag in response`));return}try{await r.writeFile(i,u,`utf-8`)}catch(e){P(C(e))}}L(),h(),M(),N(),G(),r(),se(),a(),l();var pe=30;function J(){let e=((k()||{}).cleanupPeriodDays??pe)*24*60*60*1e3;return new Date(Date.now()-e)}function me(e,t){return{messages:e.messages+t.messages,errors:e.errors+t.errors}}function he(e){let t=e.split(`.`)[0].replace(/T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z/,`T$1:$2:$3.$4Z`);return new Date(t)}async function Y(e,t,n){let r={messages:0,errors:0};try{let i=await D().readdir(e);for(let a of i)try{he(a.name)<t&&(await D().unlink(q(e,a.name)),n?r.messages++:r.errors++)}catch(e){P(e)}}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&P(e)}return r}async function ge(){let e=D(),t=J(),n=F.errors(),r=F.baseLogs(),i=await Y(n,t,!1);try{let n;try{n=await e.readdir(r)}catch{return i}let a=n.filter(e=>e.isDirectory()&&e.name.startsWith(`mcp-logs-`)).map(e=>q(r,e.name));for(let n of a)i=me(i,await Y(n,t,!0)),await Z(n,e)}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&P(e)}return i}async function X(e,t,n){return(await n.stat(e)).mtime<t?(await n.unlink(e),!0):!1}async function Z(e,t){try{await t.rmdir(e)}catch{}}async function _e(){let e=J(),t={messages:0,errors:0},n=g(),r=D(),i;try{i=await r.readdir(n)}catch{return t}for(let a of i){if(!a.isDirectory())continue;let i=q(n,a.name),o;try{o=await r.readdir(i)}catch{t.errors++;continue}for(let n of o)if(n.isFile()){if(!n.name.endsWith(`.jsonl`)&&!n.name.endsWith(`.cast`))continue;try{await X(q(i,n.name),e,r)&&t.messages++}catch{t.errors++}}else if(n.isDirectory()){let a=q(i,n.name),o=q(a,u),s;try{s=await r.readdir(o)}catch{await Z(a,r);continue}for(let n of s)if(n.isFile())try{await X(q(o,n.name),e,r)&&t.messages++}catch{t.errors++}else if(n.isDirectory()){let i=q(o,n.name),a;try{a=await r.readdir(i)}catch{continue}for(let n of a)if(n.isFile())try{await X(q(i,n.name),e,r)&&t.messages++}catch{t.errors++}await Z(i,r)}await Z(o,r),await Z(a,r)}await Z(i,r)}return t}async function Q(e,t,n=!0){let r=J(),i={messages:0,errors:0},a=D(),o;try{o=await a.readdir(e)}catch{return i}for(let n of o)if(!(!n.isFile()||!n.name.endsWith(t)))try{await X(q(e,n.name),r,a)&&i.messages++}catch{i.errors++}return n&&await Z(e,a),i}function ve(){return Q(q(e(),`plans`),`.md`)}async function ye(){let t=J(),n={messages:0,errors:0},r=D();try{let i=q(e(),`file-history`),a;try{a=await r.readdir(i)}catch{return n}let o=a.filter(e=>e.isDirectory()).map(e=>q(i,e.name));await Promise.all(o.map(async e=>{try{(await r.stat(e)).mtime<t&&(await r.rm(e,{recursive:!0,force:!0}),n.messages++)}catch{n.errors++}})),await Z(i,r)}catch(e){P(e)}return n}async function be(){let t=J(),n={messages:0,errors:0},r=D();try{let i=q(e(),`session-env`),a;try{a=await r.readdir(i)}catch{return n}let o=a.filter(e=>e.isDirectory()).map(e=>q(i,e.name));for(let e of o)try{(await r.stat(e)).mtime<t&&(await r.rm(e,{recursive:!0,force:!0}),n.messages++)}catch{n.errors++}await Z(i,r)}catch(e){P(e)}return n}async function xe(){let t=J(),n={messages:0,errors:0},r=D(),i=q(e(),`debug`),a;try{a=await r.readdir(i)}catch{return n}for(let e of a)if(!(!e.isFile()||!e.name.endsWith(`.txt`)||e.name===`latest`))try{await X(q(i,e.name),t,r)&&n.messages++}catch{n.errors++}return n}async function Se(){let{errors:e}=K();if(e.length>0&&j(`cleanupPeriodDays`)){w(`Skipping cleanup: settings have validation errors but cleanupPeriodDays was explicitly set. Fix settings errors to enable cleanup.`);return}await ge(),await _e(),await ve(),await ye(),await be(),await xe(),await c(),await ie(J());let t=await m(J());t>0&&R(`tengu_worktree_cleanup`,{removed:t})}x(),G(),le();var $=600*1e3;function Ce(){import(`./extractMemories-WmPLOLUT.js`).then(({initExtractMemories:e})=>{e()}).catch(()=>{}),i(),ue(),y()&&de();let e=!0;async function t(){if(y()&&b()>Date.now()-1e3*60){setTimeout(t,$).unref();return}if(e&&(e=!1,await Se()),y()&&b()>Date.now()-1e3*60){setTimeout(t,$).unref();return}await W()}setTimeout(t,$).unref()}export{fe as n,Ce as t};
17
+ - Output the complete updated file inside <updated_file> tags`})],systemPrompt:U([`You edit skill definition files to incorporate user preferences. Output only the updated file content.`]),thinkingConfig:{type:`disabled`},tools:[],signal:re().signal,options:{getToolPermissionContext:async()=>V(),model:c,toolChoice:void 0,isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,temperatureOverride:0,agents:[],querySource:`skill_improvement_apply`,mcpTools:[]}}),u=_(te(Array.isArray(l.message.content)?l.message.content:[]).trim(),`updated_file`);if(!u){P(Error(`Skill improvement apply: no updated_file tag in response`));return}try{await r.writeFile(i,u,`utf-8`)}catch(e){P(C(e))}}L(),h(),M(),N(),G(),r(),se(),a(),l();var pe=30;function J(){let e=((k()||{}).cleanupPeriodDays??pe)*24*60*60*1e3;return new Date(Date.now()-e)}function me(e,t){return{messages:e.messages+t.messages,errors:e.errors+t.errors}}function he(e){let t=e.split(`.`)[0].replace(/T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z/,`T$1:$2:$3.$4Z`);return new Date(t)}async function Y(e,t,n){let r={messages:0,errors:0};try{let i=await D().readdir(e);for(let a of i)try{he(a.name)<t&&(await D().unlink(q(e,a.name)),n?r.messages++:r.errors++)}catch(e){P(e)}}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&P(e)}return r}async function ge(){let e=D(),t=J(),n=F.errors(),r=F.baseLogs(),i=await Y(n,t,!1);try{let n;try{n=await e.readdir(r)}catch{return i}let a=n.filter(e=>e.isDirectory()&&e.name.startsWith(`mcp-logs-`)).map(e=>q(r,e.name));for(let n of a)i=me(i,await Y(n,t,!0)),await Z(n,e)}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&P(e)}return i}async function X(e,t,n){return(await n.stat(e)).mtime<t?(await n.unlink(e),!0):!1}async function Z(e,t){try{await t.rmdir(e)}catch{}}async function _e(){let e=J(),t={messages:0,errors:0},n=g(),r=D(),i;try{i=await r.readdir(n)}catch{return t}for(let a of i){if(!a.isDirectory())continue;let i=q(n,a.name),o;try{o=await r.readdir(i)}catch{t.errors++;continue}for(let n of o)if(n.isFile()){if(!n.name.endsWith(`.jsonl`)&&!n.name.endsWith(`.cast`))continue;try{await X(q(i,n.name),e,r)&&t.messages++}catch{t.errors++}}else if(n.isDirectory()){let a=q(i,n.name),o=q(a,u),s;try{s=await r.readdir(o)}catch{await Z(a,r);continue}for(let n of s)if(n.isFile())try{await X(q(o,n.name),e,r)&&t.messages++}catch{t.errors++}else if(n.isDirectory()){let i=q(o,n.name),a;try{a=await r.readdir(i)}catch{continue}for(let n of a)if(n.isFile())try{await X(q(i,n.name),e,r)&&t.messages++}catch{t.errors++}await Z(i,r)}await Z(o,r),await Z(a,r)}await Z(i,r)}return t}async function Q(e,t,n=!0){let r=J(),i={messages:0,errors:0},a=D(),o;try{o=await a.readdir(e)}catch{return i}for(let n of o)if(!(!n.isFile()||!n.name.endsWith(t)))try{await X(q(e,n.name),r,a)&&i.messages++}catch{i.errors++}return n&&await Z(e,a),i}function ve(){return Q(q(e(),`plans`),`.md`)}async function ye(){let t=J(),n={messages:0,errors:0},r=D();try{let i=q(e(),`file-history`),a;try{a=await r.readdir(i)}catch{return n}let o=a.filter(e=>e.isDirectory()).map(e=>q(i,e.name));await Promise.all(o.map(async e=>{try{(await r.stat(e)).mtime<t&&(await r.rm(e,{recursive:!0,force:!0}),n.messages++)}catch{n.errors++}})),await Z(i,r)}catch(e){P(e)}return n}async function be(){let t=J(),n={messages:0,errors:0},r=D();try{let i=q(e(),`session-env`),a;try{a=await r.readdir(i)}catch{return n}let o=a.filter(e=>e.isDirectory()).map(e=>q(i,e.name));for(let e of o)try{(await r.stat(e)).mtime<t&&(await r.rm(e,{recursive:!0,force:!0}),n.messages++)}catch{n.errors++}await Z(i,r)}catch(e){P(e)}return n}async function xe(){let t=J(),n={messages:0,errors:0},r=D(),i=q(e(),`debug`),a;try{a=await r.readdir(i)}catch{return n}for(let e of a)if(!(!e.isFile()||!e.name.endsWith(`.txt`)||e.name===`latest`))try{await X(q(i,e.name),t,r)&&n.messages++}catch{n.errors++}return n}async function Se(){let{errors:e}=K();if(e.length>0&&j(`cleanupPeriodDays`)){w(`Skipping cleanup: settings have validation errors but cleanupPeriodDays was explicitly set. Fix settings errors to enable cleanup.`);return}await ge(),await _e(),await ve(),await ye(),await be(),await xe(),await c(),await ie(J());let t=await m(J());t>0&&R(`tengu_worktree_cleanup`,{removed:t})}x(),G(),le();var $=600*1e3;function Ce(){import(`./extractMemories-B1KbTMY0.js`).then(({initExtractMemories:e})=>{e()}).catch(()=>{}),i(),ue(),y()&&de();let e=!0;async function t(){if(y()&&b()>Date.now()-1e3*60){setTimeout(t,$).unref();return}if(e&&(e=!1,await Se()),y()&&b()>Date.now()-1e3*60){setTimeout(t,$).unref();return}await W()}setTimeout(t,$).unref()}export{fe as n,Ce as t};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Er as t,br as n,cr as r,fi as i,gr as a,hr as o,oi as s}from"./loadAgentsDir-JrGMJN05.js";import{Wt as c,et as l,pt as u}from"./state-BPFYBqm1.js";import{C as d,x as f}from"./debug-BQj6h99Q.js";import{c as p,s as m}from"./types-BomO8WUz.js";import{n as h,r as g}from"./analytics-DJobLaWP.js";import{i as _,o as v}from"./stringUtils-BjnclTLB.js";import{randomUUID as y}from"crypto";import{mkdir as b,readFile as x,writeFile as S}from"fs/promises";function C(e){let t=e?.message?.content;if(!t)return`Branched conversation`;let n=typeof t==`string`?t:t.find(e=>e.type===`text`)?.text;return n&&n.replace(/\s+/g,` `).trim().slice(0,100)||`Branched conversation`}async function w(e){let n=y(),i=u(),s=r(l()),c=a(n),f=o();await b(s,{recursive:!0,mode:448});let m;try{m=await x(f)}catch{throw Error(`No conversation to branch`)}if(m.length===0)throw Error(`No conversation to branch`);let h=p(m),g=h.filter(e=>t(e)&&!e.isSidechain),_=h.filter(e=>e.type===`content-replacement`&&e.sessionId===i).flatMap(e=>e.replacements);if(g.length===0)throw Error(`No messages to branch`);let v=null,C=[],w=[];for(let e of g){let t={...e,sessionId:n,parentUuid:v,isSidechain:!1,forkedFrom:{sessionId:i,messageUuid:e.uuid}},r={...e,sessionId:n};w.push(r),C.push(d(t)),e.type!==`progress`&&(v=e.uuid)}if(_.length>0){let e={type:`content-replacement`,sessionId:n,replacements:_};C.push(d(e))}return await S(c,`${C.join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Er as t,br as n,cr as r,fi as i,gr as a,hr as o,oi as s}from"./loadAgentsDir-CwEfQDOw.js";import{Wt as c,et as l,pt as u}from"./state-BPFYBqm1.js";import{C as d,x as f}from"./debug-BQj6h99Q.js";import{c as p,s as m}from"./types-BomO8WUz.js";import{n as h,r as g}from"./analytics-DJobLaWP.js";import{i as _,o as v}from"./stringUtils-BjnclTLB.js";import{randomUUID as y}from"crypto";import{mkdir as b,readFile as x,writeFile as S}from"fs/promises";function C(e){let t=e?.message?.content;if(!t)return`Branched conversation`;let n=typeof t==`string`?t:t.find(e=>e.type===`text`)?.text;return n&&n.replace(/\s+/g,` `).trim().slice(0,100)||`Branched conversation`}async function w(e){let n=y(),i=u(),s=r(l()),c=a(n),f=o();await b(s,{recursive:!0,mode:448});let m;try{m=await x(f)}catch{throw Error(`No conversation to branch`)}if(m.length===0)throw Error(`No conversation to branch`);let h=p(m),g=h.filter(e=>t(e)&&!e.isSidechain),_=h.filter(e=>e.type===`content-replacement`&&e.sessionId===i).flatMap(e=>e.replacements);if(g.length===0)throw Error(`No messages to branch`);let v=null,C=[],w=[];for(let e of g){let t={...e,sessionId:n,parentUuid:v,isSidechain:!1,forkedFrom:{sessionId:i,messageUuid:e.uuid}},r={...e,sessionId:n};w.push(r),C.push(d(t)),e.type!==`progress`&&(v=e.uuid)}if(_.length>0){let e={type:`content-replacement`,sessionId:n,replacements:_};C.push(d(e))}return await S(c,`${C.join(`
2
2
  `)}\n`,{encoding:`utf8`,mode:384}),{sessionId:n,title:e,forkPath:c,serializedMessages:w,contentReplacementRecords:_}}async function T(e){let t=`${e} (Branch)`;if((await i(t,{exact:!0})).length===0)return t;let n=await i(`${e} (Branch`),r=new Set([1]),a=RegExp(`^${_(e)} \\(Branch(?: (\\d+))?\\)$`);for(let e of n){let t=e.customTitle?.match(a);t&&(t[1]?r.add(parseInt(t[1],10)):r.add(1))}let o=2;for(;r.has(o);)o++;return`${e} (Branch ${o})`}async function E(e,t,n){let r=n?.trim()||void 0,i=u();try{let{sessionId:n,title:a,forkPath:o,serializedMessages:c,contentReplacementRecords:l}=await w(r),u=new Date,d=C(c.find(e=>e.type===`user`)),f=await T(a??d);await s(n,f,o),g(`tengu_conversation_forked`,{message_count:c.length,has_custom_title:!!a});let p={date:u.toISOString().split(`T`)[0],messages:c,fullPath:o,value:u.getTime(),created:u,modified:u,firstPrompt:d,messageCount:c.length,isSidechain:!1,sessionId:n,customTitle:f,contentReplacements:l},m=a?` "${a}"`:``,h=`Branched conversation${m}. You are now in the branch.${`\nTo resume the original: claude -r ${i}`}`;return t.resume?(await t.resume(n,p,`fork`),e(h,{display:`system`})):e(`Branched conversation${m}. Resume with: /resume ${n}`),null}catch(t){return e(`Failed to branch conversation: ${t instanceof Error?t.message:`Unknown error occurred`}`),null}}e((()=>{c(),h(),m(),n(),f(),v()}))();export{E as call,C as deriveFirstPrompt};
@@ -0,0 +1 @@
1
+ import{a as e,n as t,o as n,t as r}from"./bridgeConfig-CPHAyzdg.js";e();export{r as getBridgeAccessToken,t as getBridgeBaseUrl,n as isSelfHostedBridge};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,u as n}from"./oauth-D38aRTUb.js";import{Bt as r,Ot as i}from"./model-CmDF8O9G.js";function a(){return process.env.CLAUDE_BRIDGE_OAUTH_TOKEN||void 0}function o(){return process.env.CLAUDE_BRIDGE_BASE_URL||void 0}function s(){return a()??i()?.accessToken}function c(){return o()??t().BASE_API_URL}function l(){return!!o()}var u=e((()=>{n(),r()}));export{u as a,a as i,c as n,l as o,o as r,s as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,u as n}from"./oauth-D38aRTUb.js";import{Bt as r,Ot as i}from"./model-CeG-iOKF.js";function a(){return process.env.CLAUDE_BRIDGE_OAUTH_TOKEN||void 0}function o(){return process.env.CLAUDE_BRIDGE_BASE_URL||void 0}function s(){return a()??i()?.accessToken}function c(){return o()??t().BASE_API_URL}function l(){return!!o()}var u=e((()=>{n(),r()}));export{u as a,a as i,c as n,l as o,o as r,s as t};
@@ -1 +1 @@
1
- import{o as e}from"./envUtils-DcaKZlRU.js";import{n as t,t as n}from"./defineProperty-C-QyHrDq.js";import{P as r,R as i,S as a,c as o,i as s,x as c}from"./debug-BQj6h99Q.js";import{B as l,F as u,H as d,I as f,O as p,b as m,g as h,m as g,q as _}from"./log-BlJ7CcKG.js";import{n as v,r as y}from"./analytics-DJobLaWP.js";import{T as b,et as x}from"./sessionState-C2REgUrs.js";import{n as S,t as C}from"./rcDebugLog-DSchf3Hs.js";import{t as w}from"./controlMessageCompat-IFu4Gc1y.js";import{randomUUID as T}from"crypto";e();async function E(){return!1}function D(){return!1}function O(){return!0}function k(){return null}v(),b(),s(),C(),g(),i(),c(),_(),t();function A(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function j(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_response`&&`response`in e}function M(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_request`&&`request_id`in e&&`request`in e}function N(e){return(e.type===`user`||e.type===`assistant`)&&e.isVirtual?!1:e.type===`user`||e.type===`assistant`||e.type===`system`&&e.subtype===`local_command`}function P(e){if(e.type!==`user`||e.isMeta||e.toolUseResult||e.isCompactSummary||e.origin&&e.origin.kind!==`human`)return;let t=e.message.content,n;if(typeof t==`string`)n=t;else for(let e of t??[])if(e.type===`text`){n=e.text;break}if(n)return h(n)||void 0}var F=`system-reminder`,I=/\s*<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\s*/gy,L=new Set([m,p,u,f,l,d]);function R(e){let t=e.message?.content;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``):``}function z(e){let t=e.trim();if(!t)return null;I.lastIndex=0;let n=[];for(;I.lastIndex<t.length;){let e=I.exec(t);if(!e)return null;n.push(e[1])}return n.length>0?n:null}function B(e){if(e.type!==`user`||e.isVisibleInTranscriptOnly)return!1;if(e.toolUseResult!==void 0||!e.isMeta)return!0;let t=z(R(e));return!t||t.some(e=>e!==`local-command-caveat`&&e!==F&&L.has(e))}function V(e){return e.some(B)}function H(e,t,n,i,s,c){try{let r=w(a(e));if(j(r)){o(`[bridge:repl] Ingress message type=control_response`),s?.(r);return}if(M(r)){o(`[bridge:repl] Inbound control_request subtype=${r.request.subtype}`),c?.(r);return}if(!A(r))return;let l=`uuid`in r&&typeof r.uuid==`string`?r.uuid:void 0;if(l&&t.has(l)){o(`[bridge:repl] Ignoring echo: type=${r.type} uuid=${l}`);return}if(l&&n.has(l)){o(`[bridge:repl] Ignoring re-delivered inbound: type=${r.type} uuid=${l}`);return}o(`[bridge:repl] Ingress message type=${r.type}${l?` uuid=${l}`:``}`),r.type===`user`?(l&&n.add(l),y(`tengu_bridge_message_received`,{is_repl:!0}),i?.(r)):o(`[bridge:repl] Ignoring non-user inbound message: type=${r.type}`)}catch(e){o(`[bridge:repl] Failed to parse ingress message: ${r(e)}`)}}var U=`This session is outbound-only. Enable Remote Control locally to allow inbound control.`;function W(e,t){let{transport:n,sessionId:r,outboundOnly:i,onInterrupt:a,onSetModel:s,onSetMaxThinkingTokens:c,onSetPermissionMode:l}=t;if(!n){o(`[bridge:repl] Cannot respond to control_request: transport not configured`);return}let u,d=e.request;if(i&&d.subtype!==`initialize`){u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:U}};let t={...u,session_id:r};n.write(t),o(`[bridge:repl] Rejected ${d.subtype} (outbound-only) request_id=${e.request_id}`);return}switch(d.subtype){case`initialize`:u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:{commands:[],output_style:`normal`,available_output_styles:[`normal`],models:[],account:{},pid:process.pid}}};break;case`set_model`:s?.(d.model),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_max_thinking_tokens`:c?.(d.max_thinking_tokens??null),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_permission_mode`:{let t=l?.(d.mode)??{ok:!1,error:`set_permission_mode is not supported in this context (onSetPermissionMode callback not registered)`};u=t.ok?{type:`control_response`,response:{subtype:`success`,request_id:e.request_id}}:{type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t.error}};break}case`interrupt`:a?.(),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;default:u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:`REPL bridge does not handle control_request subtype: ${d.subtype}`}}}let f={...u,session_id:r};n.write(f),S(`control_response: subtype=${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`),o(`[bridge:repl] Sent control_response for ${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`)}function G(e){return{type:`result_success`,subtype:`success`,duration_ms:0,duration_api_ms:0,is_error:!1,num_turns:0,result:``,stop_reason:null,total_cost_usd:0,usage:{...x},modelUsage:{},permission_denials:[],session_id:e,uuid:T()}}var K=class{constructor(e){n(this,`capacity`,void 0),n(this,`ring`,void 0),n(this,`set`,new Set),n(this,`writeIdx`,0),this.capacity=e,this.ring=Array(e)}add(e){if(this.set.has(e))return;let t=this.ring[this.writeIdx];t!==void 0&&this.set.delete(t),this.ring[this.writeIdx]=e,this.set.add(e),this.writeIdx=(this.writeIdx+1)%this.capacity}has(e){return this.set.has(e)}clear(){this.set.clear(),this.ring.fill(void 0),this.writeIdx=0}};export{N as a,V as c,O as d,D as f,W as i,k as l,P as n,G as o,H as r,B as s,K as t,E as u};
1
+ import{o as e}from"./envUtils-DcaKZlRU.js";import{n as t,t as n}from"./defineProperty-C-QyHrDq.js";import{P as r,R as i,S as a,c as o,i as s,x as c}from"./debug-BQj6h99Q.js";import{B as l,F as u,H as d,I as f,O as p,b as m,g as h,m as g,q as _}from"./log-BlJ7CcKG.js";import{n as v,r as y}from"./analytics-DJobLaWP.js";import{T as b,et as x}from"./sessionState-zhvcDpb2.js";import{n as S,t as C}from"./rcDebugLog-DSchf3Hs.js";import{t as w}from"./controlMessageCompat-IFu4Gc1y.js";import{randomUUID as T}from"crypto";e();async function E(){return!1}function D(){return!1}function O(){return!0}function k(){return null}v(),b(),s(),C(),g(),i(),c(),_(),t();function A(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function j(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_response`&&`response`in e}function M(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_request`&&`request_id`in e&&`request`in e}function N(e){return(e.type===`user`||e.type===`assistant`)&&e.isVirtual?!1:e.type===`user`||e.type===`assistant`||e.type===`system`&&e.subtype===`local_command`}function P(e){if(e.type!==`user`||e.isMeta||e.toolUseResult||e.isCompactSummary||e.origin&&e.origin.kind!==`human`)return;let t=e.message.content,n;if(typeof t==`string`)n=t;else for(let e of t??[])if(e.type===`text`){n=e.text;break}if(n)return h(n)||void 0}var F=`system-reminder`,I=/\s*<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\s*/gy,L=new Set([m,p,u,f,l,d]);function R(e){let t=e.message?.content;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``):``}function z(e){let t=e.trim();if(!t)return null;I.lastIndex=0;let n=[];for(;I.lastIndex<t.length;){let e=I.exec(t);if(!e)return null;n.push(e[1])}return n.length>0?n:null}function B(e){if(e.type!==`user`||e.isVisibleInTranscriptOnly)return!1;if(e.toolUseResult!==void 0||!e.isMeta)return!0;let t=z(R(e));return!t||t.some(e=>e!==`local-command-caveat`&&e!==F&&L.has(e))}function V(e){return e.some(B)}function H(e,t,n,i,s,c){try{let r=w(a(e));if(j(r)){o(`[bridge:repl] Ingress message type=control_response`),s?.(r);return}if(M(r)){o(`[bridge:repl] Inbound control_request subtype=${r.request.subtype}`),c?.(r);return}if(!A(r))return;let l=`uuid`in r&&typeof r.uuid==`string`?r.uuid:void 0;if(l&&t.has(l)){o(`[bridge:repl] Ignoring echo: type=${r.type} uuid=${l}`);return}if(l&&n.has(l)){o(`[bridge:repl] Ignoring re-delivered inbound: type=${r.type} uuid=${l}`);return}o(`[bridge:repl] Ingress message type=${r.type}${l?` uuid=${l}`:``}`),r.type===`user`?(l&&n.add(l),y(`tengu_bridge_message_received`,{is_repl:!0}),i?.(r)):o(`[bridge:repl] Ignoring non-user inbound message: type=${r.type}`)}catch(e){o(`[bridge:repl] Failed to parse ingress message: ${r(e)}`)}}var U=`This session is outbound-only. Enable Remote Control locally to allow inbound control.`;function W(e,t){let{transport:n,sessionId:r,outboundOnly:i,onInterrupt:a,onSetModel:s,onSetMaxThinkingTokens:c,onSetPermissionMode:l}=t;if(!n){o(`[bridge:repl] Cannot respond to control_request: transport not configured`);return}let u,d=e.request;if(i&&d.subtype!==`initialize`){u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:U}};let t={...u,session_id:r};n.write(t),o(`[bridge:repl] Rejected ${d.subtype} (outbound-only) request_id=${e.request_id}`);return}switch(d.subtype){case`initialize`:u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:{commands:[],output_style:`normal`,available_output_styles:[`normal`],models:[],account:{},pid:process.pid}}};break;case`set_model`:s?.(d.model),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_max_thinking_tokens`:c?.(d.max_thinking_tokens??null),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_permission_mode`:{let t=l?.(d.mode)??{ok:!1,error:`set_permission_mode is not supported in this context (onSetPermissionMode callback not registered)`};u=t.ok?{type:`control_response`,response:{subtype:`success`,request_id:e.request_id}}:{type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t.error}};break}case`interrupt`:a?.(),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;default:u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:`REPL bridge does not handle control_request subtype: ${d.subtype}`}}}let f={...u,session_id:r};n.write(f),S(`control_response: subtype=${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`),o(`[bridge:repl] Sent control_response for ${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`)}function G(e){return{type:`result_success`,subtype:`success`,duration_ms:0,duration_api_ms:0,is_error:!1,num_turns:0,result:``,stop_reason:null,total_cost_usd:0,usage:{...x},modelUsage:{},permission_denials:[],session_id:e,uuid:T()}}var K=class{constructor(e){n(this,`capacity`,void 0),n(this,`ring`,void 0),n(this,`set`,new Set),n(this,`writeIdx`,0),this.capacity=e,this.ring=Array(e)}add(e){if(this.set.has(e))return;let t=this.ring[this.writeIdx];t!==void 0&&this.set.delete(t),this.ring[this.writeIdx]=e,this.set.add(e),this.writeIdx=(this.writeIdx+1)%this.capacity}has(e){return this.set.has(e)}clear(){this.set.clear(),this.ring.fill(void 0),this.writeIdx=0}};export{N as a,V as c,O as d,D as f,W as i,k as l,P as n,G as o,H as r,B as s,K as t,E as u};
@@ -0,0 +1 @@
1
+ import{fS as e,uS as t}from"./loadAgentsDir-CwEfQDOw.js";import{t as n}from"./src-DL3w8VPk2.js";import{v as r}from"./startupProfiler-2sjXZkIP.js";import{a as i,n as a,o}from"./bridgeConfig-CPHAyzdg.js";e(),i(),n(),r();function s(e,n){return`${o()?a():t(void 0,n)}/code?bridge=${e}`}function c({error:e,connected:t,sessionActive:n,reconnecting:r}){return e?{label:`Remote Control failed`,color:`error`}:r?{label:`Remote Control reconnecting`,color:`warning`}:n||t?{label:`Remote Control active`,color:`success`}:{label:`Remote Control connecting…`,color:`warning`}}function l(e){return`Code everywhere with the Work Mate app or ${e}`}function u(e){return`Continue coding in the Work Mate app or ${e}`}var d=`Something went wrong, please try again`;export{c as a,l as i,u as n,s as r,d as t};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Bb as n,J_ as r,La as i,Lu as a,Ru as o,Sp as s,Y_ as c,at as l,by as u,cc as d,ka as f,lc as p,ot as m,q_ as h,wp as g,xC as _,zb as v}from"./loadAgentsDir-JrGMJN05.js";import{I as y,P as b,ai as x,bn as S,ot as C,t as w,vn as T,xt as E}from"./src-DL3w8VPk2.js";import{t as D}from"./jsx-runtime-Bb4Xn-E0.js";import{P as O,R as k}from"./debug-BQj6h99Q.js";import{Wt as A}from"./settings-aUygByiZ.js";import{h as j,y as M}from"./config-BkbL2e5Q.js";import{Q as N}from"./sessionState-C2REgUrs.js";import{n as P,r as F}from"./sideQuestion-BoW-xYkh.js";import{i as I,n as L}from"./modalContext-wY9CeN4G.js";function R({question:e,context:t,onDone:n}){let[r,i]=(0,H.useState)(null),[o,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(0),d=(0,H.useRef)(null),{rows:f}=I(C());S(()=>u(e=>e+1),r||o?null:80);function p(e){if(e.key===`escape`||e.key===`return`||e.key===` `||e.ctrl&&(e.key===`c`||e.key===`d`)){e.preventDefault(),n(void 0,{display:`skip`});return}(e.key===`up`||e.ctrl&&e.key===`p`)&&(e.preventDefault(),d.current?.scrollBy(-3)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),d.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=v();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?i(r.response):c(`No response received`))}catch(e){n.signal.aborted||c(O(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let m=Math.max(5,f-W-G);return(0,U.jsxs)(y,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:p,children:[(0,U.jsxs)(y,{children:[(0,U.jsxs)(b,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(b,{dimColor:!0,children:e})]}),(0,U.jsx)(y,{marginTop:1,marginLeft:2,maxHeight:m,children:(0,U.jsx)(E,{ref:d,flexDirection:`column`,flexGrow:1,children:o?(0,U.jsx)(b,{color:`error`,children:o}):r?(0,U.jsx)(s,{children:r}):(0,U.jsxs)(y,{children:[(0,U.jsx)(a,{frame:l,messageColor:`warning`}),(0,U.jsx)(b,{color:`warning`,children:`Answering...`})]})})}),(r||o)&&(0,U.jsx)(y,{marginTop:1,children:(0,U.jsxs)(b,{dimColor:!0,children:[`↑`,`/`,`↓`,` to scroll · Space, Enter, or Escape to dismiss`]})})]})}function z(e){let t=e.at(-1);return t?.type===`assistant`&&t.message.stop_reason===null?e.slice(0,-1):e}async function B(e){let t=f(z(e.messages)),n=d();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[i,a,o]=await Promise.all([l(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),r(),h()]);return{systemPrompt:N(i),userContext:a,systemContext:o,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(M(e=>({...e,btwUseCount:e.btwUseCount+1})),(0,U.jsx)(R,{question:r,context:t,onDone:e})):(e(`Usage: /btw <your question>`,{display:`system`}),null)}var H,U,W,G,K;e((()=>{H=t(x(),1),T(),g(),o(),A(),m(),L(),c(),_(),w(),n(),j(),k(),p(),i(),P(),u(),U=D(),W=5,G=6,K=3}))();export{V as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Bb as n,J_ as r,La as i,Lu as a,Ru as o,Sp as s,Y_ as c,at as l,by as u,cc as d,ka as f,lc as p,ot as m,q_ as h,wp as g,xC as _,zb as v}from"./loadAgentsDir-CwEfQDOw.js";import{I as y,P as b,ai as x,bn as S,ot as C,t as w,vn as T,xt as E}from"./src-DL3w8VPk2.js";import{t as D}from"./jsx-runtime-Bb4Xn-E0.js";import{P as O,R as k}from"./debug-BQj6h99Q.js";import{Wt as A}from"./settings-CvhsRFaT.js";import{h as j,y as M}from"./config-BSkuQZNf.js";import{Q as N}from"./sessionState-zhvcDpb2.js";import{n as P,r as F}from"./sideQuestion-oIYrx5ar.js";import{i as I,n as L}from"./modalContext-wY9CeN4G.js";function R({question:e,context:t,onDone:n}){let[r,i]=(0,H.useState)(null),[o,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(0),d=(0,H.useRef)(null),{rows:f}=I(C());S(()=>u(e=>e+1),r||o?null:80);function p(e){if(e.key===`escape`||e.key===`return`||e.key===` `||e.ctrl&&(e.key===`c`||e.key===`d`)){e.preventDefault(),n(void 0,{display:`skip`});return}(e.key===`up`||e.ctrl&&e.key===`p`)&&(e.preventDefault(),d.current?.scrollBy(-3)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),d.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=v();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?i(r.response):c(`No response received`))}catch(e){n.signal.aborted||c(O(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let m=Math.max(5,f-W-G);return(0,U.jsxs)(y,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:p,children:[(0,U.jsxs)(y,{children:[(0,U.jsxs)(b,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(b,{dimColor:!0,children:e})]}),(0,U.jsx)(y,{marginTop:1,marginLeft:2,maxHeight:m,children:(0,U.jsx)(E,{ref:d,flexDirection:`column`,flexGrow:1,children:o?(0,U.jsx)(b,{color:`error`,children:o}):r?(0,U.jsx)(s,{children:r}):(0,U.jsxs)(y,{children:[(0,U.jsx)(a,{frame:l,messageColor:`warning`}),(0,U.jsx)(b,{color:`warning`,children:`Answering...`})]})})}),(r||o)&&(0,U.jsx)(y,{marginTop:1,children:(0,U.jsxs)(b,{dimColor:!0,children:[`↑`,`/`,`↓`,` to scroll · Space, Enter, or Escape to dismiss`]})})]})}function z(e){let t=e.at(-1);return t?.type===`assistant`&&t.message.stop_reason===null?e.slice(0,-1):e}async function B(e){let t=f(z(e.messages)),n=d();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[i,a,o]=await Promise.all([l(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),r(),h()]);return{systemPrompt:N(i),userContext:a,systemContext:o,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(M(e=>({...e,btwUseCount:e.btwUseCount+1})),(0,U.jsx)(R,{question:r,context:t,onDone:e})):(e(`Usage: /btw <your question>`,{display:`system`}),null)}var H,U,W,G,K;e((()=>{H=t(x(),1),T(),g(),o(),A(),m(),L(),c(),_(),w(),n(),j(),k(),p(),i(),P(),u(),U=D(),W=5,G=6,K=3}))();export{V as call};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./caches-FP8mGB4k.js";e();export{t as clearSessionCaches};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$f as t,Di as n,Ds as r,Du as i,Eu as a,G as o,IC as s,Im as c,J_ as l,K_ as u,Ki as d,Ky as f,LC as p,Li as m,Os as h,Pm as g,Q_ as _,Sh as v,Sv as y,X_ as b,Xi as x,Y_ as S,Z_ as C,bv as w,ep as T,q as E,q_ as D,qy as O,rm as k,xh as A}from"./loadAgentsDir-JrGMJN05.js";import{On as j,Wt as M,l as N}from"./state-BPFYBqm1.js";import{S as P,v as F}from"./git-DplvjXEY.js";import{i as I,t as L}from"./detectRepository-Qy3zKoyn.js";import{a as R,n as z}from"./fileSuggestions-Dy2BUZzd.js";import{r as B,t as V}from"./magicDocs-Dpe3YhyL.js";function H(e=new Set){let r=e.size>0;l.cache.clear?.(),D.cache.clear?.(),u.cache.clear?.(),C.cache.clear?.(),z(),n(),r||y(),b(null),j(null),c(),h(),O(`session_start`),t(),a(),import(`./attributionHooks-C0aXyx9L.js`).then(({clearAttributionCaches:e})=>e()),L(),o(),N(e),F(),d(),v(),V(),s(),import(`./SearchExtraToolsTool-DupzA6Vm.js`).then(({clearSearchExtraToolsDescriptionCache:e})=>e()),import(`./loadAgentsDir-D-a1uUb5.js`).then(({clearAgentDefinitionsCache:e})=>e()),import(`./prompt-DqyEtC_I2.js`).then(({clearPromptCache:e})=>e())}var U=e((()=>{M(),m(),_(),S(),R(),k(),w(),i(),g(),A(),B(),x(),r(),E(),f(),I(),P(),T(),p()}));export{U as n,H as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$f as t,Di as n,Ds as r,Du as i,Eu as a,G as o,IC as s,Im as c,J_ as l,K_ as u,Ki as d,Ky as f,LC as p,Li as m,Os as h,Pm as g,Q_ as _,Sh as v,Sv as y,X_ as b,Xi as x,Y_ as S,Z_ as C,bv as w,ep as T,q as E,q_ as D,qy as O,rm as k,xh as A}from"./loadAgentsDir-CwEfQDOw.js";import{On as j,Wt as M,l as N}from"./state-BPFYBqm1.js";import{S as P,v as F}from"./git-DplvjXEY.js";import{i as I,t as L}from"./detectRepository-Qy3zKoyn.js";import{a as R,n as z}from"./fileSuggestions-DU7gmksK.js";import{r as B,t as V}from"./magicDocs-qGHR3Cqh.js";function H(e=new Set){let r=e.size>0;l.cache.clear?.(),D.cache.clear?.(),u.cache.clear?.(),C.cache.clear?.(),z(),n(),r||y(),b(null),j(null),c(),h(),O(`session_start`),t(),a(),import(`./attributionHooks-C0aXyx9L.js`).then(({clearAttributionCaches:e})=>e()),L(),o(),N(e),F(),d(),v(),V(),s(),import(`./SearchExtraToolsTool-BXIja1MR.js`).then(({clearSearchExtraToolsDescriptionCache:e})=>e()),import(`./loadAgentsDir-8FioUEwX.js`).then(({clearAgentDefinitionsCache:e})=>e()),import(`./prompt-V0WQJrkO2.js`).then(({clearPromptCache:e})=>e())}var U=e((()=>{M(),m(),_(),S(),R(),k(),w(),i(),g(),A(),B(),x(),r(),E(),f(),I(),P(),T(),p()}));export{U as n,H as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,F as r,P as i,R as a,c as o,i as s,x as c}from"./debug-BQj6h99Q.js";import{O as l,k as u}from"./git-DplvjXEY.js";import{_n as d,vn as f}from"./model-CmDF8O9G.js";import{l as p,r as m}from"./proxy-C0j74LqT.js";import{n as h,t as g}from"./userAgent-BggRZ-ZE.js";import{C as _,S as v,f as y,g as b,u as x,x as S}from"./sessionState-C2REgUrs.js";import{n as C}from"./jwtUtils-YCoZL0FW.js";import{randomUUID as w}from"crypto";a(),s(),l(),p(),h(),d(),_(),x(),c(),e();var T=class extends Error{constructor(e,n){super(e),t(this,`retryAfterMs`,void 0),this.retryAfterMs=n}},E=class{constructor(e){t(this,`pending`,[]),t(this,`pendingAtClose`,0),t(this,`draining`,!1),t(this,`closed`,!1),t(this,`backpressureResolvers`,[]),t(this,`sleepResolve`,null),t(this,`flushResolvers`,[]),t(this,`droppedBatches`,0),t(this,`config`,void 0),this.config=e}get droppedBatchCount(){return this.droppedBatches}get pendingCount(){return this.closed?this.pendingAtClose:this.pending.length}async enqueue(e){if(this.closed)return;let t=Array.isArray(e)?e:[e];if(t.length!==0){for(;this.pending.length+t.length>this.config.maxQueueSize&&!this.closed;)await new Promise(e=>{this.backpressureResolvers.push(e)});this.closed||(this.pending.push(...t),this.drain())}}flush(){return this.pending.length===0&&!this.draining?Promise.resolve():(this.drain(),new Promise(e=>{this.flushResolvers.push(e)}))}close(){if(!this.closed){this.closed=!0,this.pendingAtClose=this.pending.length,this.pending=[],this.sleepResolve?.(),this.sleepResolve=null;for(let e of this.backpressureResolvers)e();this.backpressureResolvers=[];for(let e of this.flushResolvers)e();this.flushResolvers=[]}}async drain(){if(this.draining||this.closed)return;this.draining=!0;let e=0;try{for(;this.pending.length>0&&!this.closed;){let t=this.takeBatch();if(t.length!==0){try{await this.config.send(t),e=0}catch(n){if(e++,this.config.maxConsecutiveFailures!==void 0&&e>=this.config.maxConsecutiveFailures){this.droppedBatches++,this.config.onBatchDropped?.(t.length,e),e=0,this.releaseBackpressure();continue}this.pending=t.concat(this.pending);let r=n instanceof T?n.retryAfterMs:void 0;await this.sleep(this.retryDelay(e,r));continue}this.releaseBackpressure()}}}finally{if(this.draining=!1,this.pending.length===0){for(let e of this.flushResolvers)e();this.flushResolvers=[]}}}takeBatch(){let{maxBatchSize:e,maxBatchBytes:t}=this.config;if(t===void 0)return this.pending.splice(0,e);let r=0,i=0;for(;i<this.pending.length&&i<e;){let e;try{e=Buffer.byteLength(n(this.pending[i]))}catch{this.pending.splice(i,1);continue}if(i>0&&r+e>t)break;r+=e,i++}return this.pending.splice(0,i)}retryDelay(e,t){let n=Math.random()*this.config.jitterMs;return t===void 0?Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+n:Math.max(this.config.baseDelayMs,Math.min(t,this.config.maxDelayMs))+n}releaseBackpressure(){let e=this.backpressureResolvers;this.backpressureResolvers=[];for(let t of e)t()}sleep(e){return new Promise(t=>{this.sleepResolve=t,setTimeout((e,t)=>{e.sleepResolve=null,t()},e,this,t)})}};e();var D=class{constructor(e){t(this,`inflight`,null),t(this,`pending`,null),t(this,`closed`,!1),t(this,`config`,void 0),this.config=e}enqueue(e){this.closed||(this.pending=this.pending?O(this.pending,e):e,this.drain())}close(){this.closed=!0,this.pending=null}async drain(){if(this.inflight||this.closed||!this.pending)return;let e=this.pending;this.pending=null,this.inflight=this.sendWithRetry(e).then(()=>{this.inflight=null,this.pending&&!this.closed&&this.drain()})}async sendWithRetry(e){let t=e,n=0;for(;!this.closed;){if(await this.config.send(t))return;n++,await f(this.retryDelay(n)),this.pending&&!this.closed&&(t=O(t,this.pending),this.pending=null)}}retryDelay(e){return Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+Math.random()*this.config.jitterMs}};function O(e,t){let n={...e};for(let[e,r]of Object.entries(t))(e===`external_metadata`||e===`internal_metadata`)&&n[e]&&typeof n[e]==`object`&&typeof r==`object`&&r?n[e]={...n[e],...r}:n[e]=r;return n}d(),e();var k=2e4,A=100;function j(){return!0}var M=class extends Error{constructor(e){super(`CCRClient init failed: ${e}`),t(this,`reason`,void 0),this.reason=e}},N=10;function P(){return{byMessage:new Map,scopeToMessage:new Map}}function F(e){return`${e.session_id}:${e.parent_tool_use_id??``}`}function I(e,t){let n=[],r=new Map;for(let i of e){let e=i.event;switch(e.type){case`message_start`:{let r=e.message.id,a=t.scopeToMessage.get(F(i));a&&t.byMessage.delete(a),t.scopeToMessage.set(F(i),r),t.byMessage.set(r,[]),n.push(i);break}case`content_block_delta`:{let a=e.delta;if(a.type!==`text_delta`){n.push(i);break}let o=t.scopeToMessage.get(F(i)),s=o?t.byMessage.get(o):void 0;if(!s){n.push(i);break}let c=e.index,l=s[c]??(s[c]=[]);l.push(a.text);let u=r.get(l);if(u){u.event.delta={type:`text_delta`,text:l.join(``)};break}let d={type:`stream_event`,uuid:i.uuid,session_id:i.session_id,parent_tool_use_id:i.parent_tool_use_id,event:{type:`content_block_delta`,index:c,delta:{type:`text_delta`,text:l.join(``)}}};r.set(l,d),n.push(d);break}default:n.push(i)}}return n}function L(e,t){e.byMessage.delete(t.message.id);let n=F(t);e.scopeToMessage.get(n)===t.message.id&&e.scopeToMessage.delete(n)}var R=class{constructor(e,n,r){if(t(this,`workerEpoch`,0),t(this,`heartbeatIntervalMs`,void 0),t(this,`heartbeatJitterFraction`,void 0),t(this,`heartbeatTimer`,null),t(this,`heartbeatInFlight`,!1),t(this,`closed`,!1),t(this,`consecutiveAuthFailures`,0),t(this,`currentState`,null),t(this,`sessionBaseUrl`,void 0),t(this,`sessionId`,void 0),t(this,`http`,m({keepAlive:!0})),t(this,`streamEventBuffer`,[]),t(this,`streamEventTimer`,null),t(this,`streamTextAccumulator`,P()),t(this,`workerState`,void 0),t(this,`eventUploader`,void 0),t(this,`internalEventUploader`,void 0),t(this,`deliveryUploader`,void 0),t(this,`onEpochMismatch`,void 0),t(this,`getAuthHeaders`,void 0),this.onEpochMismatch=r?.onEpochMismatch??(()=>{process.exit(1)}),this.heartbeatIntervalMs=r?.heartbeatIntervalMs??k,this.heartbeatJitterFraction=r?.heartbeatJitterFraction??0,this.getAuthHeaders=r?.getAuthHeaders??S,n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`CCRClient: Expected http(s) URL, got ${n.protocol}`);let i=n.pathname.replace(/\/$/,``);this.sessionBaseUrl=`${n.protocol}//${n.host}${i}`,this.sessionId=i.split(`/`).pop()||``,this.workerState=new D({send:e=>this.request(`put`,`/worker`,{worker_epoch:this.workerEpoch,...e},`PUT worker`).then(e=>e.ok),baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.eventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:1e5,send:async e=>{let t=await this.request(`post`,`/worker/events`,{worker_epoch:this.workerEpoch,events:e},`client events`);if(!t.ok)throw new T(`client event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.internalEventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:200,send:async e=>{let t=await this.request(`post`,`/worker/internal-events`,{worker_epoch:this.workerEpoch,events:e},`internal events`);if(!t.ok)throw new T(`internal event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.deliveryUploader=new E({maxBatchSize:64,maxQueueSize:64,send:async e=>{let t=await this.request(`post`,`/worker/events/delivery`,{worker_epoch:this.workerEpoch,updates:e.map(e=>({event_id:e.eventId,status:e.status}))},`delivery batch`);if(!t.ok)throw new T(`delivery POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),e.setOnEvent(e=>{this.reportDelivery(e.event_id,`received`)})}async initialize(e){let t=Date.now();if(Object.keys(this.getAuthHeaders()).length===0)throw new M(`no_auth_headers`);if(e===void 0){let t=process.env.CLAUDE_CODE_WORKER_EPOCH;e=t?parseInt(t,10):NaN}if(isNaN(e))throw new M(`missing_epoch`);this.workerEpoch=e;let n=this.getWorkerState();if(!(await this.request(`put`,`/worker`,{worker_status:`idle`,worker_epoch:this.workerEpoch,external_metadata:{pending_action:null,task_summary:null,automation_state:null}},`PUT worker (init)`)).ok)throw new M(`worker_register_failed`);this.currentState=`idle`,this.startHeartbeat(),y(()=>{this.writeEvent({type:`keep_alive`})}),o(`CCRClient: initialized, epoch=${this.workerEpoch}`),u(`info`,`cli_worker_lifecycle_initialized`,{epoch:this.workerEpoch,duration_ms:Date.now()-t});let{metadata:r,durationMs:i}=await n;return this.closed||u(`info`,`cli_worker_state_restored`,{duration_ms:i,had_state:r!==null}),r}async getWorkerState(){let e=Date.now(),t=this.getAuthHeaders();return Object.keys(t).length===0?{metadata:null,durationMs:0}:{metadata:(await this.getWithRetry(`${this.sessionBaseUrl}/worker`,t,`worker_state`))?.worker?.external_metadata??null,durationMs:Date.now()-e}}async request(e,t,n,a,{timeout:s=1e4}={}){let c=this.getAuthHeaders();if(Object.keys(c).length===0)return{ok:!1};try{let r=await this.http[e](`${this.sessionBaseUrl}${t}`,n,{headers:{...c,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`,"User-Agent":g()},validateStatus:j,timeout:s});if(r.status>=200&&r.status<300)return this.consecutiveAuthFailures=0,{ok:!0};if(r.status===409&&this.handleEpochMismatch(),r.status===401||r.status===403){let e=v(),t=e?C(e):null;t!==null&&t*1e3<Date.now()&&(o(`CCRClient: session_token expired (exp=${new Date(t*1e3).toISOString()}) — no refresh was delivered, exiting`,{level:`error`}),u(`error`,`cli_worker_token_expired_no_refresh`),this.onEpochMismatch()),this.consecutiveAuthFailures++,this.consecutiveAuthFailures>=N&&(o(`CCRClient: ${this.consecutiveAuthFailures} consecutive auth failures with a valid-looking token — server-side auth unrecoverable, exiting`,{level:`error`}),u(`error`,`cli_worker_auth_failures_exhausted`),this.onEpochMismatch())}if(o(`CCRClient: ${a} returned ${r.status}`,{level:`warn`}),u(`warn`,`cli_worker_request_failed`,{method:e,path:t,status:r.status}),r.status===429){let e=r.headers?.[`retry-after`],t=typeof e==`string`?parseInt(e,10):NaN;if(!isNaN(t)&&t>=0)return{ok:!1,retryAfterMs:t*1e3}}return{ok:!1}}catch(n){return o(`CCRClient: ${a} failed: ${i(n)}`,{level:`warn`}),u(`warn`,`cli_worker_request_error`,{method:e,path:t,error_code:r(n)}),{ok:!1}}}reportState(e,t){e===this.currentState&&!t||(this.currentState=e,this.workerState.enqueue({worker_status:e,requires_action_details:t?{tool_name:t.tool_name,action_description:t.action_description,request_id:t.request_id}:null}))}reportMetadata(e){this.workerState.enqueue({external_metadata:e})}handleEpochMismatch(){o(`CCRClient: Epoch mismatch (409), shutting down`,{level:`error`}),u(`error`,`cli_worker_epoch_mismatch`),this.onEpochMismatch()}startHeartbeat(){this.stopHeartbeat();let e=()=>{let e=this.heartbeatIntervalMs*this.heartbeatJitterFraction*(2*Math.random()-1);this.heartbeatTimer=setTimeout(t,this.heartbeatIntervalMs+e)},t=()=>{this.sendHeartbeat(),this.heartbeatTimer!==null&&e()};e()}stopHeartbeat(){this.heartbeatTimer&&(clearTimeout(this.heartbeatTimer),this.heartbeatTimer=null)}async sendHeartbeat(){if(!this.heartbeatInFlight){this.heartbeatInFlight=!0;try{(await this.request(`post`,`/worker/heartbeat`,{session_id:this.sessionId,worker_epoch:this.workerEpoch},`Heartbeat`,{timeout:5e3})).ok&&o(`CCRClient: Heartbeat sent`)}finally{this.heartbeatInFlight=!1}}}async writeEvent(e){if(e.type===`stream_event`){this.streamEventBuffer.push(e),this.streamEventTimer||(this.streamEventTimer=setTimeout(()=>void this.flushStreamEventBuffer(),A));return}await this.flushStreamEventBuffer(),e.type===`assistant`&&L(this.streamTextAccumulator,e),await this.eventUploader.enqueue(this.toClientEvent(e))}toClientEvent(e){let t=e;return{payload:{...t,uuid:typeof t.uuid==`string`?t.uuid:w()}}}async flushStreamEventBuffer(){if(this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer.length===0)return;let e=this.streamEventBuffer;this.streamEventBuffer=[];let t=I(e,this.streamTextAccumulator);await this.eventUploader.enqueue(t.map(e=>({payload:e,ephemeral:!0})))}async writeInternalEvent(e,t,{isCompaction:n=!1,agentId:r}={}){let i={payload:{type:e,...t,uuid:typeof t.uuid==`string`?t.uuid:w()},...n&&{is_compaction:!0},...r&&{agent_id:r}};await this.internalEventUploader.enqueue(i)}flushInternalEvents(){return this.internalEventUploader.flush()}async flush(){return await this.flushStreamEventBuffer(),this.eventUploader.flush()}async readInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{},`internal_events`)}async readSubagentInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{subagents:`true`},`subagent_events`)}async paginatedGet(e,t,n){let r=this.getAuthHeaders();if(Object.keys(r).length===0)return null;let i=[],a;do{let o=new URL(`${this.sessionBaseUrl}${e}`);for(let[e,n]of Object.entries(t))o.searchParams.set(e,n);a&&o.searchParams.set(`cursor`,a);let s=await this.getWithRetry(o.toString(),r,n);if(!s)return null;i.push(...s.data??[]),a=s.next_cursor}while(a);return o(`CCRClient: Read ${i.length} internal events from ${e}${t.subagents?` (subagents)`:``}`),i}async getWithRetry(e,t,n){for(let n=1;n<=10;n++){let r;try{r=await this.http.get(e,{headers:{...t,"anthropic-version":`2023-06-01`,"User-Agent":g()},validateStatus:j,timeout:3e4})}catch(t){o(`CCRClient: GET ${e} failed (attempt ${n}/10): ${i(t)}`,{level:`warn`}),n<10&&await f(Math.min(500*2**(n-1),3e4)+Math.random()*500);continue}if(r.status>=200&&r.status<300)return r.data;r.status===409&&this.handleEpochMismatch(),o(`CCRClient: GET ${e} returned ${r.status} (attempt ${n}/10)`,{level:`warn`}),n<10&&await f(Math.min(500*2**(n-1),3e4)+Math.random()*500)}return o(`CCRClient: GET retries exhausted`,{level:`error`}),u(`error`,`cli_worker_get_retries_exhausted`,{context:n}),null}reportDelivery(e,t){this.deliveryUploader.enqueue({eventId:e,status:t})}getWorkerEpoch(){return this.workerEpoch}get internalEventsPending(){return this.internalEventUploader.pendingCount}close(){this.closed=!0,this.stopHeartbeat(),b(),this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer=[],this.streamTextAccumulator.byMessage.clear(),this.streamTextAccumulator.scopeToMessage.clear(),this.workerState.close(),this.eventUploader.close(),this.internalEventUploader.close(),this.deliveryUploader.close()}};export{M as n,E as r,R as t};
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,F as r,P as i,R as a,c as o,i as s,x as c}from"./debug-BQj6h99Q.js";import{O as l,k as u}from"./git-DplvjXEY.js";import{_n as d,vn as f}from"./model-CeG-iOKF.js";import{l as p,r as m}from"./proxy-C0j74LqT.js";import{n as h,t as g}from"./userAgent-aoe_xVAb.js";import{C as _,S as v,f as y,g as b,u as x,x as S}from"./sessionState-zhvcDpb2.js";import{n as C}from"./jwtUtils-YCoZL0FW.js";import{randomUUID as w}from"crypto";a(),s(),l(),p(),h(),d(),_(),x(),c(),e();var T=class extends Error{constructor(e,n){super(e),t(this,`retryAfterMs`,void 0),this.retryAfterMs=n}},E=class{constructor(e){t(this,`pending`,[]),t(this,`pendingAtClose`,0),t(this,`draining`,!1),t(this,`closed`,!1),t(this,`backpressureResolvers`,[]),t(this,`sleepResolve`,null),t(this,`flushResolvers`,[]),t(this,`droppedBatches`,0),t(this,`config`,void 0),this.config=e}get droppedBatchCount(){return this.droppedBatches}get pendingCount(){return this.closed?this.pendingAtClose:this.pending.length}async enqueue(e){if(this.closed)return;let t=Array.isArray(e)?e:[e];if(t.length!==0){for(;this.pending.length+t.length>this.config.maxQueueSize&&!this.closed;)await new Promise(e=>{this.backpressureResolvers.push(e)});this.closed||(this.pending.push(...t),this.drain())}}flush(){return this.pending.length===0&&!this.draining?Promise.resolve():(this.drain(),new Promise(e=>{this.flushResolvers.push(e)}))}close(){if(!this.closed){this.closed=!0,this.pendingAtClose=this.pending.length,this.pending=[],this.sleepResolve?.(),this.sleepResolve=null;for(let e of this.backpressureResolvers)e();this.backpressureResolvers=[];for(let e of this.flushResolvers)e();this.flushResolvers=[]}}async drain(){if(this.draining||this.closed)return;this.draining=!0;let e=0;try{for(;this.pending.length>0&&!this.closed;){let t=this.takeBatch();if(t.length!==0){try{await this.config.send(t),e=0}catch(n){if(e++,this.config.maxConsecutiveFailures!==void 0&&e>=this.config.maxConsecutiveFailures){this.droppedBatches++,this.config.onBatchDropped?.(t.length,e),e=0,this.releaseBackpressure();continue}this.pending=t.concat(this.pending);let r=n instanceof T?n.retryAfterMs:void 0;await this.sleep(this.retryDelay(e,r));continue}this.releaseBackpressure()}}}finally{if(this.draining=!1,this.pending.length===0){for(let e of this.flushResolvers)e();this.flushResolvers=[]}}}takeBatch(){let{maxBatchSize:e,maxBatchBytes:t}=this.config;if(t===void 0)return this.pending.splice(0,e);let r=0,i=0;for(;i<this.pending.length&&i<e;){let e;try{e=Buffer.byteLength(n(this.pending[i]))}catch{this.pending.splice(i,1);continue}if(i>0&&r+e>t)break;r+=e,i++}return this.pending.splice(0,i)}retryDelay(e,t){let n=Math.random()*this.config.jitterMs;return t===void 0?Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+n:Math.max(this.config.baseDelayMs,Math.min(t,this.config.maxDelayMs))+n}releaseBackpressure(){let e=this.backpressureResolvers;this.backpressureResolvers=[];for(let t of e)t()}sleep(e){return new Promise(t=>{this.sleepResolve=t,setTimeout((e,t)=>{e.sleepResolve=null,t()},e,this,t)})}};e();var D=class{constructor(e){t(this,`inflight`,null),t(this,`pending`,null),t(this,`closed`,!1),t(this,`config`,void 0),this.config=e}enqueue(e){this.closed||(this.pending=this.pending?O(this.pending,e):e,this.drain())}close(){this.closed=!0,this.pending=null}async drain(){if(this.inflight||this.closed||!this.pending)return;let e=this.pending;this.pending=null,this.inflight=this.sendWithRetry(e).then(()=>{this.inflight=null,this.pending&&!this.closed&&this.drain()})}async sendWithRetry(e){let t=e,n=0;for(;!this.closed;){if(await this.config.send(t))return;n++,await f(this.retryDelay(n)),this.pending&&!this.closed&&(t=O(t,this.pending),this.pending=null)}}retryDelay(e){return Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+Math.random()*this.config.jitterMs}};function O(e,t){let n={...e};for(let[e,r]of Object.entries(t))(e===`external_metadata`||e===`internal_metadata`)&&n[e]&&typeof n[e]==`object`&&typeof r==`object`&&r?n[e]={...n[e],...r}:n[e]=r;return n}d(),e();var k=2e4,A=100;function j(){return!0}var M=class extends Error{constructor(e){super(`CCRClient init failed: ${e}`),t(this,`reason`,void 0),this.reason=e}},N=10;function P(){return{byMessage:new Map,scopeToMessage:new Map}}function F(e){return`${e.session_id}:${e.parent_tool_use_id??``}`}function I(e,t){let n=[],r=new Map;for(let i of e){let e=i.event;switch(e.type){case`message_start`:{let r=e.message.id,a=t.scopeToMessage.get(F(i));a&&t.byMessage.delete(a),t.scopeToMessage.set(F(i),r),t.byMessage.set(r,[]),n.push(i);break}case`content_block_delta`:{let a=e.delta;if(a.type!==`text_delta`){n.push(i);break}let o=t.scopeToMessage.get(F(i)),s=o?t.byMessage.get(o):void 0;if(!s){n.push(i);break}let c=e.index,l=s[c]??(s[c]=[]);l.push(a.text);let u=r.get(l);if(u){u.event.delta={type:`text_delta`,text:l.join(``)};break}let d={type:`stream_event`,uuid:i.uuid,session_id:i.session_id,parent_tool_use_id:i.parent_tool_use_id,event:{type:`content_block_delta`,index:c,delta:{type:`text_delta`,text:l.join(``)}}};r.set(l,d),n.push(d);break}default:n.push(i)}}return n}function L(e,t){e.byMessage.delete(t.message.id);let n=F(t);e.scopeToMessage.get(n)===t.message.id&&e.scopeToMessage.delete(n)}var R=class{constructor(e,n,r){if(t(this,`workerEpoch`,0),t(this,`heartbeatIntervalMs`,void 0),t(this,`heartbeatJitterFraction`,void 0),t(this,`heartbeatTimer`,null),t(this,`heartbeatInFlight`,!1),t(this,`closed`,!1),t(this,`consecutiveAuthFailures`,0),t(this,`currentState`,null),t(this,`sessionBaseUrl`,void 0),t(this,`sessionId`,void 0),t(this,`http`,m({keepAlive:!0})),t(this,`streamEventBuffer`,[]),t(this,`streamEventTimer`,null),t(this,`streamTextAccumulator`,P()),t(this,`workerState`,void 0),t(this,`eventUploader`,void 0),t(this,`internalEventUploader`,void 0),t(this,`deliveryUploader`,void 0),t(this,`onEpochMismatch`,void 0),t(this,`getAuthHeaders`,void 0),this.onEpochMismatch=r?.onEpochMismatch??(()=>{process.exit(1)}),this.heartbeatIntervalMs=r?.heartbeatIntervalMs??k,this.heartbeatJitterFraction=r?.heartbeatJitterFraction??0,this.getAuthHeaders=r?.getAuthHeaders??S,n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`CCRClient: Expected http(s) URL, got ${n.protocol}`);let i=n.pathname.replace(/\/$/,``);this.sessionBaseUrl=`${n.protocol}//${n.host}${i}`,this.sessionId=i.split(`/`).pop()||``,this.workerState=new D({send:e=>this.request(`put`,`/worker`,{worker_epoch:this.workerEpoch,...e},`PUT worker`).then(e=>e.ok),baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.eventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:1e5,send:async e=>{let t=await this.request(`post`,`/worker/events`,{worker_epoch:this.workerEpoch,events:e},`client events`);if(!t.ok)throw new T(`client event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.internalEventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:200,send:async e=>{let t=await this.request(`post`,`/worker/internal-events`,{worker_epoch:this.workerEpoch,events:e},`internal events`);if(!t.ok)throw new T(`internal event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.deliveryUploader=new E({maxBatchSize:64,maxQueueSize:64,send:async e=>{let t=await this.request(`post`,`/worker/events/delivery`,{worker_epoch:this.workerEpoch,updates:e.map(e=>({event_id:e.eventId,status:e.status}))},`delivery batch`);if(!t.ok)throw new T(`delivery POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),e.setOnEvent(e=>{this.reportDelivery(e.event_id,`received`)})}async initialize(e){let t=Date.now();if(Object.keys(this.getAuthHeaders()).length===0)throw new M(`no_auth_headers`);if(e===void 0){let t=process.env.CLAUDE_CODE_WORKER_EPOCH;e=t?parseInt(t,10):NaN}if(isNaN(e))throw new M(`missing_epoch`);this.workerEpoch=e;let n=this.getWorkerState();if(!(await this.request(`put`,`/worker`,{worker_status:`idle`,worker_epoch:this.workerEpoch,external_metadata:{pending_action:null,task_summary:null,automation_state:null}},`PUT worker (init)`)).ok)throw new M(`worker_register_failed`);this.currentState=`idle`,this.startHeartbeat(),y(()=>{this.writeEvent({type:`keep_alive`})}),o(`CCRClient: initialized, epoch=${this.workerEpoch}`),u(`info`,`cli_worker_lifecycle_initialized`,{epoch:this.workerEpoch,duration_ms:Date.now()-t});let{metadata:r,durationMs:i}=await n;return this.closed||u(`info`,`cli_worker_state_restored`,{duration_ms:i,had_state:r!==null}),r}async getWorkerState(){let e=Date.now(),t=this.getAuthHeaders();return Object.keys(t).length===0?{metadata:null,durationMs:0}:{metadata:(await this.getWithRetry(`${this.sessionBaseUrl}/worker`,t,`worker_state`))?.worker?.external_metadata??null,durationMs:Date.now()-e}}async request(e,t,n,a,{timeout:s=1e4}={}){let c=this.getAuthHeaders();if(Object.keys(c).length===0)return{ok:!1};try{let r=await this.http[e](`${this.sessionBaseUrl}${t}`,n,{headers:{...c,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`,"User-Agent":g()},validateStatus:j,timeout:s});if(r.status>=200&&r.status<300)return this.consecutiveAuthFailures=0,{ok:!0};if(r.status===409&&this.handleEpochMismatch(),r.status===401||r.status===403){let e=v(),t=e?C(e):null;t!==null&&t*1e3<Date.now()&&(o(`CCRClient: session_token expired (exp=${new Date(t*1e3).toISOString()}) — no refresh was delivered, exiting`,{level:`error`}),u(`error`,`cli_worker_token_expired_no_refresh`),this.onEpochMismatch()),this.consecutiveAuthFailures++,this.consecutiveAuthFailures>=N&&(o(`CCRClient: ${this.consecutiveAuthFailures} consecutive auth failures with a valid-looking token — server-side auth unrecoverable, exiting`,{level:`error`}),u(`error`,`cli_worker_auth_failures_exhausted`),this.onEpochMismatch())}if(o(`CCRClient: ${a} returned ${r.status}`,{level:`warn`}),u(`warn`,`cli_worker_request_failed`,{method:e,path:t,status:r.status}),r.status===429){let e=r.headers?.[`retry-after`],t=typeof e==`string`?parseInt(e,10):NaN;if(!isNaN(t)&&t>=0)return{ok:!1,retryAfterMs:t*1e3}}return{ok:!1}}catch(n){return o(`CCRClient: ${a} failed: ${i(n)}`,{level:`warn`}),u(`warn`,`cli_worker_request_error`,{method:e,path:t,error_code:r(n)}),{ok:!1}}}reportState(e,t){e===this.currentState&&!t||(this.currentState=e,this.workerState.enqueue({worker_status:e,requires_action_details:t?{tool_name:t.tool_name,action_description:t.action_description,request_id:t.request_id}:null}))}reportMetadata(e){this.workerState.enqueue({external_metadata:e})}handleEpochMismatch(){o(`CCRClient: Epoch mismatch (409), shutting down`,{level:`error`}),u(`error`,`cli_worker_epoch_mismatch`),this.onEpochMismatch()}startHeartbeat(){this.stopHeartbeat();let e=()=>{let e=this.heartbeatIntervalMs*this.heartbeatJitterFraction*(2*Math.random()-1);this.heartbeatTimer=setTimeout(t,this.heartbeatIntervalMs+e)},t=()=>{this.sendHeartbeat(),this.heartbeatTimer!==null&&e()};e()}stopHeartbeat(){this.heartbeatTimer&&(clearTimeout(this.heartbeatTimer),this.heartbeatTimer=null)}async sendHeartbeat(){if(!this.heartbeatInFlight){this.heartbeatInFlight=!0;try{(await this.request(`post`,`/worker/heartbeat`,{session_id:this.sessionId,worker_epoch:this.workerEpoch},`Heartbeat`,{timeout:5e3})).ok&&o(`CCRClient: Heartbeat sent`)}finally{this.heartbeatInFlight=!1}}}async writeEvent(e){if(e.type===`stream_event`){this.streamEventBuffer.push(e),this.streamEventTimer||(this.streamEventTimer=setTimeout(()=>void this.flushStreamEventBuffer(),A));return}await this.flushStreamEventBuffer(),e.type===`assistant`&&L(this.streamTextAccumulator,e),await this.eventUploader.enqueue(this.toClientEvent(e))}toClientEvent(e){let t=e;return{payload:{...t,uuid:typeof t.uuid==`string`?t.uuid:w()}}}async flushStreamEventBuffer(){if(this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer.length===0)return;let e=this.streamEventBuffer;this.streamEventBuffer=[];let t=I(e,this.streamTextAccumulator);await this.eventUploader.enqueue(t.map(e=>({payload:e,ephemeral:!0})))}async writeInternalEvent(e,t,{isCompaction:n=!1,agentId:r}={}){let i={payload:{type:e,...t,uuid:typeof t.uuid==`string`?t.uuid:w()},...n&&{is_compaction:!0},...r&&{agent_id:r}};await this.internalEventUploader.enqueue(i)}flushInternalEvents(){return this.internalEventUploader.flush()}async flush(){return await this.flushStreamEventBuffer(),this.eventUploader.flush()}async readInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{},`internal_events`)}async readSubagentInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{subagents:`true`},`subagent_events`)}async paginatedGet(e,t,n){let r=this.getAuthHeaders();if(Object.keys(r).length===0)return null;let i=[],a;do{let o=new URL(`${this.sessionBaseUrl}${e}`);for(let[e,n]of Object.entries(t))o.searchParams.set(e,n);a&&o.searchParams.set(`cursor`,a);let s=await this.getWithRetry(o.toString(),r,n);if(!s)return null;i.push(...s.data??[]),a=s.next_cursor}while(a);return o(`CCRClient: Read ${i.length} internal events from ${e}${t.subagents?` (subagents)`:``}`),i}async getWithRetry(e,t,n){for(let n=1;n<=10;n++){let r;try{r=await this.http.get(e,{headers:{...t,"anthropic-version":`2023-06-01`,"User-Agent":g()},validateStatus:j,timeout:3e4})}catch(t){o(`CCRClient: GET ${e} failed (attempt ${n}/10): ${i(t)}`,{level:`warn`}),n<10&&await f(Math.min(500*2**(n-1),3e4)+Math.random()*500);continue}if(r.status>=200&&r.status<300)return r.data;r.status===409&&this.handleEpochMismatch(),o(`CCRClient: GET ${e} returned ${r.status} (attempt ${n}/10)`,{level:`warn`}),n<10&&await f(Math.min(500*2**(n-1),3e4)+Math.random()*500)}return o(`CCRClient: GET retries exhausted`,{level:`error`}),u(`error`,`cli_worker_get_retries_exhausted`,{context:n}),null}reportDelivery(e,t){this.deliveryUploader.enqueue({eventId:e,status:t})}getWorkerEpoch(){return this.workerEpoch}get internalEventsPending(){return this.internalEventUploader.pendingCount}close(){this.closed=!0,this.stopHeartbeat(),b(),this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer=[],this.streamTextAccumulator.byMessage.clear(),this.streamTextAccumulator.scopeToMessage.clear(),this.workerState.close(),this.eventUploader.close(),this.internalEventUploader.close(),this.deliveryUploader.close()}};export{M as n,E as r,R as t};
@@ -0,0 +1 @@
1
+ import{F as e,R as t}from"./debug-BQj6h99Q.js";import{o as n,s as r}from"./log-BlJ7CcKG.js";import{i,o as a,t as o}from"./platform-DVeTi9mp.js";import{a as s,i as c,s as l,u}from"./types-BomO8WUz.js";import{homedir as d}from"os";import{join as f}from"path";import{readFile as p,readdir as m,stat as h}from"fs/promises";s(),t(),l(),n(),a();async function g(){let e=i();if(!o.includes(e))throw Error(`Unsupported platform: ${e} - Work Mate Desktop integration only works on macOS and WSL.`);if(e===`macos`)return f(d(),`Library`,`Application Support`,`Work Mate`,`claude_desktop_config.json`);let t=process.env.USERPROFILE?process.env.USERPROFILE.replace(/\\/g,`/`):null;if(t){let e=`/mnt/c${t.replace(/^[A-Z]:/,``)}/AppData/Roaming/Work Mate/claude_desktop_config.json`;try{return await h(e),e}catch{}}try{let e=`/mnt/c/Users`;try{let t=await m(e,{withFileTypes:!0});for(let n of t){if(n.name===`Public`||n.name===`Default`||n.name===`Default User`||n.name===`All Users`)continue;let t=f(e,n.name,`AppData`,`Roaming`,`Work Mate`,`claude_desktop_config.json`);try{return await h(t),t}catch{}}}catch{}}catch(e){r(e)}throw Error(`Could not find Work Mate Desktop config file in Windows. Make sure Work Mate Desktop is installed on Windows.`)}async function _(){if(!o.includes(i()))throw Error(`Unsupported platform - Work Mate Desktop integration only works on macOS and WSL.`);try{let t=await g(),n;try{n=await p(t,{encoding:`utf8`})}catch(t){if(e(t)===`ENOENT`)return{};throw t}let r=u(n);if(!r||typeof r!=`object`)return{};let i=r.mcpServers;if(!i||typeof i!=`object`)return{};let a={};for(let[e,t]of Object.entries(i)){if(!t||typeof t!=`object`)continue;let n=c().safeParse(t);n.success&&(a[e]=n.data)}return a}catch(e){return r(e),{}}}export{_ as readClaudeDesktopMcpServers};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./conversation-DOgBzrm0.js";var r;e((()=>{t(),r=async(e,t)=>(await n(t),{type:`text`,value:``})}))();export{r as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./conversation-C8w1DtXk.js";var r;e((()=>{t(),r=async(e,t)=>(await n(t),{type:`text`,value:``})}))();export{r as call};
@@ -0,0 +1 @@
1
+ import{Nr as e,Pr as t}from"./model-CeG-iOKF.js";t();export{e as getOrganizationUUID};
@@ -0,0 +1 @@
1
+ import{Di as e,Li as t,Mi as n}from"./loadAgentsDir-CwEfQDOw.js";t();export{e as clearCommandsCache,n as getCommands};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,Am as n,G_ as r,Im as i,J_ as a,La as o,Om as s,Pm as c,W_ as l,Y_ as u,_p as d,at as f,bC as p,bv as m,ev as h,fv as g,hn as _,iv as v,ka as y,l_ as b,o_ as x,ot as S,q_ as C,rv as w,s_ as T,u_ as E,vp as D,vv as O,xv as k,yC as A}from"./loadAgentsDir-JrGMJN05.js";import{di as j,fi as M}from"./src-DL3w8VPk2.js";import{Wt as N,qt as P}from"./state-BPFYBqm1.js";import{L as F,R as I}from"./debug-BQj6h99Q.js";import{o as L,s as R}from"./log-BlJ7CcKG.js";function z(e,t){let n=d(`tip`),r=A(`app:toggleTranscript`,`Global`,`ctrl+o`),i=[...e.options.verbose?[]:[`(${r} to see full summary)`],...t?[t]:[],...n?[n]:[]];return j.dim(`Compacted ${i.join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,Am as n,G_ as r,Im as i,J_ as a,La as o,Om as s,Pm as c,W_ as l,Y_ as u,_p as d,at as f,bC as p,bv as m,ev as h,fv as g,hn as _,iv as v,ka as y,l_ as b,o_ as x,ot as S,q_ as C,rv as w,s_ as T,u_ as E,vp as D,vv as O,xv as k,yC as A}from"./loadAgentsDir-CwEfQDOw.js";import{di as j,fi as M}from"./src-DL3w8VPk2.js";import{Wt as N,qt as P}from"./state-BPFYBqm1.js";import{L as F,R as I}from"./debug-BQj6h99Q.js";import{o as L,s as R}from"./log-BlJ7CcKG.js";function z(e,t){let n=d(`tip`),r=A(`app:toggleTranscript`,`Global`,`ctrl+o`),i=[...e.options.verbose?[]:[`(${r} to see full summary)`],...t?[t]:[],...n?[n]:[]];return j.dim(`Compacted ${i.join(`
2
2
  `)}`)}async function B(e,t){let n=e.getAppState(),r=await f(e.options.tools,e.options.mainLoopModel,Array.from(n.toolPermissionContext.additionalWorkingDirectories.keys()),e.options.mcpClients),i=l({mainThreadAgentDefinition:void 0,toolUseContext:e,customSystemPrompt:e.options.customSystemPrompt,defaultSystemPrompt:r,appendSystemPrompt:e.options.appendSystemPrompt}),[o,s]=await Promise.all([a(),C()]);return{systemPrompt:i,userContext:o,systemContext:s,toolUseContext:e,forkContextMessages:t}}var V;e((()=>{M(),N(),S(),u(),p(),m(),E(),w(),t(),c(),s(),g(),I(),_(),L(),o(),D(),r(),V=async(e,t)=>{let{abortController:r}=t,{messages:o}=t;if(o=y(o),o.length===0)throw Error(`No messages to compact`);let s=e.trim();try{if(!s){let e=await n(o,t.agentId);if(e)return a.cache.clear?.(),i(),k(t.options.querySource??`compact`,t.agentId),P(),v(),{type:`compact`,compactionResult:e,displayText:z(t)}}let e=(await h(o,t)).messages,r=await b(e,t,await B(t,e),!1,s,!1);return O(void 0),v(),a.cache.clear?.(),i(),{type:`compact`,compactionResult:r,displayText:z(t,r.userDisplayMessage)}}catch(e){throw r.signal.aborted?Error(`Compaction canceled.`):F(e,`Not enough messages to compact. Send a few more messages first, then try again.`)?Error(T):F(e,`Compaction interrupted · This may be due to network issues — please try again.`)?Error(x):(R(e),Error(`Error during compaction: ${e}`))}}}))();export{V as call};