@readmagic/workmate 0.0.30 → 0.0.31

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 (215) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-B03NZZuQ.js → AddWorkspaceDirectory-C07tZJZN.js} +1 -1
  2. package/dist/chunks/{AgentsMdExternalIncludesDialog-CIyefOzT.js → AgentsMdExternalIncludesDialog-6_bT7l-8.js} +1 -1
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-BbSA-E68.js +1 -0
  4. package/dist/chunks/{App-WBysAL0_.js → App--Nvun0sE.js} +1 -1
  5. package/dist/chunks/{BackgroundTasksDialog-CvvrjBoq.js → BackgroundTasksDialog-DTWNv4Gc.js} +1 -1
  6. package/dist/chunks/{BypassPermissionsModeDialog-DdVbMyla.js → BypassPermissionsModeDialog-CJ6U9Vb2.js} +1 -1
  7. package/dist/chunks/{CustomSelect-iSG1rbWU.js → CustomSelect-uOjgHk8D.js} +1 -1
  8. package/dist/chunks/{DiffDialog-DSb46fzB.js → DiffDialog-CTFLCtYp.js} +1 -1
  9. package/dist/chunks/Doctor-Bd0k7Jo7.js +1 -0
  10. package/dist/chunks/{Doctor-dR71Dg_D.js → Doctor-CgZxiFf3.js} +1 -1
  11. package/dist/chunks/{ExitFlow-BiBi5Sqk.js → ExitFlow-DGqwlF8J.js} +1 -1
  12. package/dist/chunks/{InvalidConfigDialog-7MkDSXXj.js → InvalidConfigDialog-8ZJmSDBO.js} +1 -1
  13. package/dist/chunks/{InvalidSettingsDialog-D8Ves3Th.js → InvalidSettingsDialog-B7czkYPj.js} +1 -1
  14. package/dist/chunks/{KeybindingProviderSetup-DJSFdVYv.js → KeybindingProviderSetup-C8rq4fwQ.js} +1 -1
  15. package/dist/chunks/{MCPConnectionManager-BZxRMdGO.js → MCPConnectionManager-DbPzbRdc.js} +1 -1
  16. package/dist/chunks/{MCPToolListView-H_Kvvelz.js → MCPToolListView-BsO2uWCL.js} +1 -1
  17. package/dist/chunks/{McpParsingWarnings-D2xvaog9.js → McpParsingWarnings-BIpQ_Dle.js} +1 -1
  18. package/dist/chunks/{MessageSelector-DQgIgPij.js → MessageSelector-DuCpdn-Q.js} +1 -1
  19. package/dist/chunks/{Messages-DyQCr-od.js → Messages-SKlSLbVo.js} +1 -1
  20. package/dist/chunks/{Onboarding-DFufTPIY.js → Onboarding-CLEqdl35.js} +1 -1
  21. package/dist/chunks/{PromptInputFooterSuggestions-B9JRcHHE.js → PromptInputFooterSuggestions-cu1KF4_b.js} +1 -1
  22. package/dist/chunks/{PromptInputHelpMenu-DcGXK5lt.js → PromptInputHelpMenu-MH_gVGmN.js} +1 -1
  23. package/dist/chunks/{ProviderSetup-DJ_Z1BSe.js → ProviderSetup-zjQQUmDr.js} +1 -1
  24. package/dist/chunks/{QueryEngine-BQ5PSqKV.js → QueryEngine-Cb2ncWE6.js} +1 -1
  25. package/dist/chunks/REPL-CWbLkb3q.js +124 -0
  26. package/dist/chunks/REPL-D1bn80_0.js +1 -0
  27. package/dist/chunks/{ResumeConversation-exTLviBY.js → ResumeConversation-DRcIMHTE.js} +1 -1
  28. package/dist/chunks/SearchExtraToolsTool-B6Qlr08G.js +1 -0
  29. package/dist/chunks/{Settings-nM6-cXh0.js → Settings-B-EscJrZ.js} +2 -2
  30. package/dist/chunks/{Spinner-ChT4lOOg.js → Spinner-ByYcKk2V.js} +1 -1
  31. package/dist/chunks/{TextInput-CanSwT9J.js → TextInput-eYxBj_1-.js} +1 -1
  32. package/dist/chunks/{ThemePicker-CXzPiSy0.js → ThemePicker-BqeGU99Q.js} +1 -1
  33. package/dist/chunks/{TrustDialog-D0fJ-YIw.js → TrustDialog-DYZ0i7rH.js} +1 -1
  34. package/dist/chunks/{ValidationErrorsList-29bQ0l-Q.js → ValidationErrorsList-Cw-sjz1h.js} +1 -1
  35. package/dist/chunks/{_baseEach-DPcnudh_.js → _baseEach-BQ2jM5Sg.js} +1 -1
  36. package/dist/chunks/{add-dir-DbNz1SeY.js → add-dir-3q2C-Kfj.js} +1 -1
  37. package/dist/chunks/{agentDisplay-Bif3eE1e.js → agentDisplay-C18dbK7V.js} +1 -1
  38. package/dist/chunks/{agents-CbsNbPbp.js → agents--BKL-glS.js} +1 -1
  39. package/dist/chunks/{agents-yvC-VikU.js → agents-B_Ik_9lY.js} +1 -1
  40. package/dist/chunks/{allErrors-Bv1e8fra.js → allErrors-CJOE7EGx.js} +1 -1
  41. package/dist/chunks/{appleTerminalBackup-Ct9hf1QQ.js → appleTerminalBackup-j8nI5uNK.js} +1 -1
  42. package/dist/chunks/backgroundHousekeeping-COON_jRA.js +1 -0
  43. package/dist/chunks/{backgroundHousekeeping-C75FgxW1.js → backgroundHousekeeping-FPn2H48W.js} +1 -1
  44. package/dist/chunks/{banner-D5m9LUjl.js → banner-BsO6K4Ve.js} +1 -1
  45. package/dist/chunks/{branch-DOQ3yNds.js → branch-7SdIl7ZG.js} +1 -1
  46. package/dist/chunks/{btw-DUjuwyMH.js → btw-BhVWw00h.js} +1 -1
  47. package/dist/chunks/{caches-BKAPMXp9.js → caches-DaOhyHsb.js} +1 -1
  48. package/dist/chunks/caches-DgNr-KX3.js +1 -0
  49. package/dist/chunks/{channel-C8JmEI06.js → channel-BNS35qVl.js} +1 -1
  50. package/dist/chunks/{channel-TEYwDITo.js → channel-DWDK9jut.js} +1 -1
  51. package/dist/chunks/{clear-BFlTcvMt.js → clear-B5WkPxlz.js} +1 -1
  52. package/dist/chunks/commands-DJe5bkNw.js +1 -0
  53. package/dist/chunks/{compact-CyR7Sbo1.js → compact-DriVPdmX.js} +1 -1
  54. package/dist/chunks/{config-Bjwat4P6.js → config-CMtnYZR9.js} +1 -1
  55. package/dist/chunks/config-CgzzjTUe.js +1 -0
  56. package/dist/chunks/config-FEF6EcWp.js +1 -0
  57. package/dist/chunks/{context-Cm_gyngQ.js → context-CXi66Ghx.js} +1 -1
  58. package/dist/chunks/{context-noninteractive-BDmFfPRt.js → context-noninteractive-BRoUkLxt.js} +1 -1
  59. package/dist/chunks/context-noninteractive-Bupgkyt9.js +1 -0
  60. package/dist/chunks/conversation-CCV0BYD_.js +1 -0
  61. package/dist/chunks/{conversation-CYZKYlWc.js → conversation-DrEE7olO.js} +1 -1
  62. package/dist/chunks/{conversationRecovery-BUqpxLl-.js → conversationRecovery-CZzxsT_R.js} +1 -1
  63. package/dist/chunks/{crossProjectResume-BCa2l0KZ.js → crossProjectResume-CbXDWdHE.js} +1 -1
  64. package/dist/chunks/{diff-BEvpLh_b.js → diff-CH8kHqwX.js} +1 -1
  65. package/dist/chunks/doctor-HV7-zZgq.js +1 -0
  66. package/dist/chunks/{entry-JGyBs1p5.js → entry-CyH0Rkjq.js} +1 -1
  67. package/dist/chunks/{exit-DU2KGyDk.js → exit-zYpIKg68.js} +1 -1
  68. package/dist/chunks/{extraUsage-cZx2XLx4.js → extraUsage-Dp_LtcKE.js} +1 -1
  69. package/dist/chunks/extractMemories-1_fkJtc-.js +1 -0
  70. package/dist/chunks/fast-Bi-RRDlf.js +1 -0
  71. package/dist/chunks/{fast-DUJq6-QE.js → fast-DnP_x58e.js} +1 -1
  72. package/dist/chunks/{fetchModelList-Dn8OahtV.js → fetchModelList-BctZn47N.js} +1 -1
  73. package/dist/chunks/fetchModelList-Dfyy0Yds.js +1 -0
  74. package/dist/chunks/{fileSuggestions-XLnnVLwx.js → fileSuggestions-CoYWpIJB.js} +1 -1
  75. package/dist/chunks/{gemini-qzPNGqOX.js → gemini-CyZAw1Wg.js} +1 -1
  76. package/dist/chunks/{generateSessionName-CA-cc58H.js → generateSessionName-CJ13ZLWG.js} +1 -1
  77. package/dist/chunks/{goal-x9Pkx5nv.js → goal-CiuF90SO.js} +1 -1
  78. package/dist/chunks/{grok-36CpLjsq.js → grok-B4R78Wy4.js} +1 -1
  79. package/dist/chunks/{help-DwfAEV0X.js → help-CQ8yZg8_.js} +1 -1
  80. package/dist/chunks/hooks-Cj3t3ItG.js +1 -0
  81. package/dist/chunks/{hooks-DBmA-DWx.js → hooks-DgsxCW0L.js} +1 -1
  82. package/dist/chunks/{install-DF4ep6nb.js → install-W_2JVR8Y.js} +1 -1
  83. package/dist/chunks/{instrumentation-BAbhrE3f.js → instrumentation-Yk5dlvD_.js} +3 -3
  84. package/dist/chunks/{job-CFWKIjNl.js → job-CAbdQPkT.js} +1 -1
  85. package/dist/chunks/{launchLocalMemory-Cf8l-1fz.js → launchLocalMemory-C-KuYLDQ.js} +1 -1
  86. package/dist/chunks/{launchOnboarding-8CDef-v1.js → launchOnboarding-2-AEYja0.js} +1 -1
  87. package/dist/chunks/{loadAgentsDir-DnHL_5cU.js → loadAgentsDir-CgDTTnMX.js} +468 -468
  88. package/dist/chunks/loadAgentsDir-jBY44wEO.js +1 -0
  89. package/dist/chunks/{loadPluginHooks-BuunKr9m.js → loadPluginHooks-CWkivYx4.js} +1 -1
  90. package/dist/chunks/localSearch-B3aRqi3q.js +1 -0
  91. package/dist/chunks/{localSearch-LFCzV7VE.js → localSearch-BhygSl0K.js} +1 -1
  92. package/dist/chunks/{logoUtils-B8MIA7c5.js → logoUtils-rZbHAggC.js} +1 -1
  93. package/dist/chunks/{magicDocs-BoxJusTI.js → magicDocs-430IH4o3.js} +1 -1
  94. package/dist/chunks/{main-B9ciFYnO.js → main-DuS6HbbE.js} +6 -6
  95. package/dist/chunks/managedEnv-BV6T_PdC.js +1 -0
  96. package/dist/chunks/{managedEnv-B0mj-wgE.js → managedEnv-O3Xqe_lk.js} +1 -1
  97. package/dist/chunks/{mcp-CHlAZvpV.js → mcp-BoJ9rdef.js} +1 -1
  98. package/dist/chunks/{mcp-DVKuOqvY.js → mcp-C2GF6Gp7.js} +1 -1
  99. package/dist/chunks/{mcp-B3Ewo-_h.js → mcp-XaHs-eh9.js} +1 -1
  100. package/dist/chunks/{memory-Cr0d-s7U.js → memory-D0vG6luI.js} +1 -1
  101. package/dist/chunks/{mode-DBNBDbVP.js → mode-4ZXGLC71.js} +1 -1
  102. package/dist/chunks/{model-C9ANf1-R.js → model-BidsdFhX.js} +1 -1
  103. package/dist/chunks/{model-B2r1Ms0g.js → model-CcgVXT3w.js} +1 -1
  104. package/dist/chunks/{modelOptions-B4BWYms0.js → modelOptions-Bw53Jebp.js} +1 -1
  105. package/dist/chunks/{nativeInstaller-BDJxBAPV.js → nativeInstaller-BczAzL96.js} +1 -1
  106. package/dist/chunks/{notifications-BV-VeXyJ.js → notifications-B3v1XAdd.js} +1 -1
  107. package/dist/chunks/{onChangeAppState-BGWWkhBg.js → onChangeAppState-wASLrUas.js} +1 -1
  108. package/dist/chunks/{openai-BL_IWBTr.js → openai-CvSNI6b2.js} +1 -1
  109. package/dist/chunks/{overlayContext-DGUFuee9.js → overlayContext-0wuZMXWl.js} +1 -1
  110. package/dist/chunks/{partition-B2VCm4vu.js → partition-CGKLltyv.js} +1 -1
  111. package/dist/chunks/{permissions-Bkj1UB1h.js → permissions-DawwDdur.js} +1 -1
  112. package/dist/chunks/{pidLock-CawSx6hb.js → pidLock-TOlSC34M.js} +2 -2
  113. package/dist/chunks/{plan-D7Ki5ADu.js → plan-D_vIEUQa.js} +1 -1
  114. package/dist/chunks/{plugin-D7I6VZjh.js → plugin-CDWB3AFL.js} +1 -1
  115. package/dist/chunks/{pluginAutoupdate-Cr3jw-ky.js → pluginAutoupdate-CPzXHVsX.js} +1 -1
  116. package/dist/chunks/{pluginBlocklist-JG_kJSSK.js → pluginBlocklist-Bu6GP9_C.js} +1 -1
  117. package/dist/chunks/{pluginCliCommands-BWIBBFJf.js → pluginCliCommands-CNpseXZD.js} +1 -1
  118. package/dist/chunks/{pluginFlagging-yFcXMVin.js → pluginFlagging-1MM3zuMP.js} +1 -1
  119. package/dist/chunks/{pluginOperations-6QXjdPOb.js → pluginOperations-qT-GGKNu.js} +1 -1
  120. package/dist/chunks/pluginStartupCheck-CCDpCchC.js +1 -0
  121. package/dist/chunks/{pluginStartupCheck-CkjyJ4RS.js → pluginStartupCheck-DXPIrR7f.js} +1 -1
  122. package/dist/chunks/{plugins-CMDfjFp-.js → plugins-Bbbvm9KH.js} +1 -1
  123. package/dist/chunks/{print-B6x_8O9w.js → print-Db7IDW_T.js} +2 -2
  124. package/dist/chunks/{processBashCommand-D0BBcBHY.js → processBashCommand-DtEP1Js2.js} +1 -1
  125. package/dist/chunks/{processSlashCommand-BvjNuNyP.js → processSlashCommand-BIIOr3n4.js} +1 -1
  126. package/dist/chunks/{projectOnboardingState-ofkjp9FJ.js → projectOnboardingState-DqGLXSM_.js} +1 -1
  127. package/dist/chunks/prompt-CCP82QoX.js +1 -0
  128. package/dist/chunks/{prompt-DDlkyIzV.js → prompt-CduUPV0s.js} +1 -1
  129. package/dist/chunks/prompt-DmWyLDH6.js +1 -0
  130. package/dist/chunks/{protocolHandler-Bjmx7OmF.js → protocolHandler-DrGjosKa.js} +1 -1
  131. package/dist/chunks/{reconciler-CHbint0C.js → reconciler-DQxjz0OK.js} +1 -1
  132. package/dist/chunks/{refresh-yut9uEfd.js → refresh-BmkkYKno.js} +1 -1
  133. package/dist/chunks/{reject-CrNfit3M.js → reject-DYsU8jkO.js} +1 -1
  134. package/dist/chunks/{reload-plugins-labKy5Eh.js → reload-plugins-CmHAxvlA.js} +1 -1
  135. package/dist/chunks/{rename-c8tElppw.js → rename-BrGuvkvC.js} +1 -1
  136. package/dist/chunks/{resume-C8xif2lo.js → resume-COSo0ATp.js} +1 -1
  137. package/dist/chunks/{runtimeObserver-vmPplAGH.js → runtimeObserver-CoNTwrJ3.js} +1 -1
  138. package/dist/chunks/{runtimeObserver-DuJ8mRfr.js → runtimeObserver-Dpi40Nfi.js} +2 -2
  139. package/dist/chunks/sandbox-adapter-D0bQ6nsv.js +1 -0
  140. package/dist/chunks/{sandbox-toggle-USHaZHD7.js → sandbox-toggle-CrjErH9V.js} +1 -1
  141. package/dist/chunks/searchExtraTools-_Fo0KDnz.js +1 -0
  142. package/dist/chunks/{select-BpiKdirZ.js → select-BNeFiLNP.js} +1 -1
  143. package/dist/chunks/sessionFileAccessHooks-BCBV26Ut.js +1 -0
  144. package/dist/chunks/{sessionObserver-sO6PF7mV.js → sessionObserver-CAvR0MCN.js} +1 -1
  145. package/dist/chunks/sessionObserver-QbHl_0Dr.js +1 -0
  146. package/dist/chunks/sessionStorage-CscAodvT.js +1 -0
  147. package/dist/chunks/{sessionTracing-Bz89tYh5.js → sessionTracing-rMBtalMz.js} +1 -1
  148. package/dist/chunks/{setup-B-FejaeH.js → setup-X5QOX_BW.js} +2 -2
  149. package/dist/chunks/{shadowedRuleDetection-BI6Xz0pY.js → shadowedRuleDetection-BucAPuXp.js} +1 -1
  150. package/dist/chunks/{sideQuestion-BEpCuv_7.js → sideQuestion-B1W_L7NR.js} +1 -1
  151. package/dist/chunks/{sinks-BvOPODnl.js → sinks-Bqzavjot.js} +1 -1
  152. package/dist/chunks/sinks-ofVW99nt.js +1 -0
  153. package/dist/chunks/{skillChangeDetector-D-fxaAMH.js → skillChangeDetector-jKxXTp4F.js} +1 -1
  154. package/dist/chunks/{skillGapStore-A1FCr8Mf.js → skillGapStore-CQVCxlWd.js} +2 -2
  155. package/dist/chunks/{skillLifecycle-CTVa34xO.js → skillLifecycle-GGpX7H8W.js} +2 -2
  156. package/dist/chunks/{skillSearchPanel-CjekGkrw.js → skillSearchPanel-DDM0zZ_r.js} +2 -2
  157. package/dist/chunks/{skills-110JHHbj.js → skills-Bmdrtecu.js} +1 -1
  158. package/dist/chunks/status-CFpCBQX1.js +1 -0
  159. package/dist/chunks/{statusNoticeHelpers-C5BRU3lw.js → statusNoticeHelpers-DRJcaVdx.js} +1 -1
  160. package/dist/chunks/switcher-BCr3vwnq.js +1 -0
  161. package/dist/chunks/{switcher-nLHGsxLw.js → switcher-CqGz0hjQ.js} +1 -1
  162. package/dist/chunks/{tasks-CjYr59Ak.js → tasks-CNQUkXoq.js} +1 -1
  163. package/dist/chunks/{templateJobs-ECX0rRRp.js → templateJobs-CYArZLti.js} +1 -1
  164. package/dist/chunks/{terminalSetup-AptBNs_i.js → terminalSetup-QvvwfSGV.js} +1 -1
  165. package/dist/chunks/{terminalSetup-CKO6eWhS.js → terminalSetup-h_TPZN2E.js} +1 -1
  166. package/dist/chunks/{theme-BCSx9irC.js → theme-DVkXXIPx.js} +1 -1
  167. package/dist/chunks/{tipRegistry-CnQB3TaA.js → tipRegistry-DzOyYhJT.js} +1 -1
  168. package/dist/chunks/{toolEventObserver-Bqtypnkk.js → toolEventObserver-BAkhiG0F.js} +1 -1
  169. package/dist/chunks/{toolPool-B1sXN7SK.js → toolPool-D_7Onp-c.js} +1 -1
  170. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-DegJrysj.js → useExitOnCtrlCDWithKeybindings-z3RiW9jT.js} +1 -1
  171. package/dist/chunks/useMainLoopModel-DMB41HoQ.js +1 -0
  172. package/dist/chunks/{useManagePlugins-BW2Zj_jf.js → useManagePlugins-DSRLHKH5.js} +1 -1
  173. package/dist/chunks/{useMergedTools-CTm1AU9b.js → useMergedTools-C7wh5W03.js} +1 -1
  174. package/dist/chunks/{useSearchInput-DrY4BZKy.js → useSearchInput-r534PKo1.js} +1 -1
  175. package/dist/chunks/{useSettingsErrors-2uIAF6H8.js → useSettingsErrors-DL_ai-el.js} +1 -1
  176. package/dist/chunks/{util-BUgUtaUV.js → util-DombpJHQ.js} +1 -1
  177. package/dist/chunks/{validatePlugin-BGB8T9Mb.js → validatePlugin-DU3C7Mvb.js} +1 -1
  178. package/dist/chunks/vim-BX8ljWbJ.js +1 -0
  179. package/dist/chunks/worktree-CjnMMjR6.js +1 -0
  180. package/dist/cli.js +1 -1
  181. package/package.json +1 -1
  182. package/dist/chunks/AgentsMdExternalIncludesDialog-45Ize2zR.js +0 -1
  183. package/dist/chunks/Doctor--yF3SBsD.js +0 -1
  184. package/dist/chunks/REPL-CjoJCy0g.js +0 -124
  185. package/dist/chunks/REPL-DGieTVDl.js +0 -1
  186. package/dist/chunks/SearchExtraToolsTool-BBhWAuoA.js +0 -1
  187. package/dist/chunks/backgroundHousekeeping-d0qpqWHe.js +0 -1
  188. package/dist/chunks/caches-he4NeZSK.js +0 -1
  189. package/dist/chunks/commands-BoGtXPAA.js +0 -1
  190. package/dist/chunks/config-B-hDBSL8.js +0 -1
  191. package/dist/chunks/config-DubkVeOw.js +0 -1
  192. package/dist/chunks/context-noninteractive-CmOFpwwP.js +0 -1
  193. package/dist/chunks/conversation-B7YCvyCD.js +0 -1
  194. package/dist/chunks/doctor-DYKr9Reu.js +0 -1
  195. package/dist/chunks/extractMemories-4wbv-mTc.js +0 -1
  196. package/dist/chunks/fast-BALHWqpd.js +0 -1
  197. package/dist/chunks/fetchModelList-OZ2sLDEx.js +0 -1
  198. package/dist/chunks/hooks-BofA8GeO.js +0 -1
  199. package/dist/chunks/loadAgentsDir-C-qRJlXH.js +0 -1
  200. package/dist/chunks/localSearch-BulDBrBk.js +0 -1
  201. package/dist/chunks/managedEnv-BFpXdDI8.js +0 -1
  202. package/dist/chunks/pluginStartupCheck-B-nYb61N.js +0 -1
  203. package/dist/chunks/prompt-Cpu4meqR.js +0 -1
  204. package/dist/chunks/prompt-HO8Docca.js +0 -1
  205. package/dist/chunks/sandbox-adapter-BKnsdtVj.js +0 -1
  206. package/dist/chunks/searchExtraTools-DV5iZPdw.js +0 -1
  207. package/dist/chunks/sessionFileAccessHooks-nq8C34WL.js +0 -1
  208. package/dist/chunks/sessionObserver-CKp3uqPg.js +0 -1
  209. package/dist/chunks/sessionStorage-CuQf4d1y.js +0 -1
  210. package/dist/chunks/sinks-DLALCllz.js +0 -1
  211. package/dist/chunks/status-D_b3UMke.js +0 -1
  212. package/dist/chunks/switcher-BFzvv7KT.js +0 -1
  213. package/dist/chunks/useMainLoopModel-CPnigpM1.js +0 -1
  214. package/dist/chunks/vim-DdxGarvY.js +0 -1
  215. package/dist/chunks/worktree-DBZ7f9Lk.js +0 -1
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,P as n,t as r}from"./src-BX54x08P.js";import{t as i}from"./jsx-runtime-Bb4Xn-E0.js";import{Xt as a,qt as o}from"./settings-CA-5Px85.js";import{FC as s,MC as c,NC as l,ab as u,ib as d}from"./loadAgentsDir-DnHL_5cU.js";import{d as f,o as p}from"./config-Bjwat4P6.js";import{i as m,o as h}from"./bundledMode-Dqe4pz0a.js";import{a as g,s as _}from"./sleep-BGewNhNx.js";import{a as v,i as y,r as b}from"./terminalSetup-CKO6eWhS.js";function x(){return p().editorMode===`vim`}function S(){return o.terminal===`Apple_Terminal`&&process.platform===`darwin`||v()?`shift + ⏎ for newline`:b()?`\\⏎ for newline`:`backslash (\\) + return (⏎) for newline`}function C(e,t){return t.ctrl||t.meta||t.escape||t.return||t.tab||t.backspace||t.delete||t.upArrow||t.downArrow||t.leftArrow||t.rightArrow||t.pageUp||t.pageDown||t.home||t.end?!1:e.length>0&&!/^\s/.test(e)&&!e.startsWith(`\x1B`)}var w=e((()=>{y(),f(),a()}));function T(e){return e.replace(/\+/g,` + `)}function E(e){let{dimColor:r,fixedWidth:i,gap:a,paddingX:o}=e,c=T(u(`app:toggleTranscript`,`Global`,`ctrl+o`)),d=T(u(`app:toggleTodos`,`Global`,`ctrl+t`)),f=T(u(`chat:undo`,`Chat`,`ctrl+_`)),p=T(u(`chat:stash`,`Chat`,`ctrl+s`)),h=T(u(`chat:cycleMode`,`Chat`,`shift+tab`)),g=T(u(`chat:modelPicker`,`Chat`,`alt+p`)),v=T(u(`chat:fastMode`,`Chat`,`alt+o`)),y=T(u(`chat:externalEditor`,`Chat`,`ctrl+g`));T(u(`app:toggleTerminal`,`Global`,`meta+j`));let b=T(u(`chat:imagePaste`,`Chat`,`ctrl+v`));return(0,D.jsxs)(t,{paddingX:o,flexDirection:`row`,gap:a,children:[(0,D.jsxs)(t,{flexDirection:`column`,width:i?24:void 0,children:[(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`! for bash mode`})}),(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`/ for commands`})}),(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`@ for file paths`})}),(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`& for background`})}),(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`/btw for side question`})})]}),(0,D.jsxs)(t,{flexDirection:`column`,width:i?35:void 0,children:[(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`double tap esc to clear input`})}),(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[h,` to auto-accept edits`]})}),(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[c,` for verbose output`]})}),(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[d,` to toggle tasks`]})}),(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:S()})})]}),(0,D.jsxs)(t,{flexDirection:`column`,children:[(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[f,` to undo`]})}),m()!==`windows`&&(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`ctrl + z to suspend`})}),(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[b,` to paste images`]})}),(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[g,` to switch model`]})}),s()&&l()&&(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[v,` to toggle fast mode`]})}),(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[p,` to stash prompt`]})}),(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[y,` to edit in $EDITOR`]})}),_()&&(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`/keybindings to customize`})})]})]})}var D,O=e((()=>{r(),h(),g(),d(),c(),w(),D=i()}));export{x as a,C as i,O as n,w as r,E as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,P as n,t as r}from"./src-BX54x08P.js";import{t as i}from"./jsx-runtime-Bb4Xn-E0.js";import{Xt as a,qt as o}from"./settings-CA-5Px85.js";import{FC as s,MC as c,NC as l,ab as u,ib as d}from"./loadAgentsDir-CgDTTnMX.js";import{d as f,o as p}from"./config-CMtnYZR9.js";import{i as m,o as h}from"./bundledMode-Dqe4pz0a.js";import{a as g,s as _}from"./sleep-BGewNhNx.js";import{a as v,i as y,r as b}from"./terminalSetup-h_TPZN2E.js";function x(){return p().editorMode===`vim`}function S(){return o.terminal===`Apple_Terminal`&&process.platform===`darwin`||v()?`shift + ⏎ for newline`:b()?`\\⏎ for newline`:`backslash (\\) + return (⏎) for newline`}function C(e,t){return t.ctrl||t.meta||t.escape||t.return||t.tab||t.backspace||t.delete||t.upArrow||t.downArrow||t.leftArrow||t.rightArrow||t.pageUp||t.pageDown||t.home||t.end?!1:e.length>0&&!/^\s/.test(e)&&!e.startsWith(`\x1B`)}var w=e((()=>{y(),f(),a()}));function T(e){return e.replace(/\+/g,` + `)}function E(e){let{dimColor:r,fixedWidth:i,gap:a,paddingX:o}=e,c=T(u(`app:toggleTranscript`,`Global`,`ctrl+o`)),d=T(u(`app:toggleTodos`,`Global`,`ctrl+t`)),f=T(u(`chat:undo`,`Chat`,`ctrl+_`)),p=T(u(`chat:stash`,`Chat`,`ctrl+s`)),h=T(u(`chat:cycleMode`,`Chat`,`shift+tab`)),g=T(u(`chat:modelPicker`,`Chat`,`alt+p`)),v=T(u(`chat:fastMode`,`Chat`,`alt+o`)),y=T(u(`chat:externalEditor`,`Chat`,`ctrl+g`));T(u(`app:toggleTerminal`,`Global`,`meta+j`));let b=T(u(`chat:imagePaste`,`Chat`,`ctrl+v`));return(0,D.jsxs)(t,{paddingX:o,flexDirection:`row`,gap:a,children:[(0,D.jsxs)(t,{flexDirection:`column`,width:i?24:void 0,children:[(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`! for bash mode`})}),(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`/ for commands`})}),(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`@ for file paths`})}),(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`& for background`})}),(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`/btw for side question`})})]}),(0,D.jsxs)(t,{flexDirection:`column`,width:i?35:void 0,children:[(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`double tap esc to clear input`})}),(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[h,` to auto-accept edits`]})}),(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[c,` for verbose output`]})}),(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[d,` to toggle tasks`]})}),(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:S()})})]}),(0,D.jsxs)(t,{flexDirection:`column`,children:[(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[f,` to undo`]})}),m()!==`windows`&&(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`ctrl + z to suspend`})}),(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[b,` to paste images`]})}),(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[g,` to switch model`]})}),s()&&l()&&(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[v,` to toggle fast mode`]})}),(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[p,` to stash prompt`]})}),(0,D.jsx)(t,{children:(0,D.jsxs)(n,{dimColor:r,children:[y,` to edit in $EDITOR`]})}),_()&&(0,D.jsx)(t,{children:(0,D.jsx)(n,{dimColor:r,children:`/keybindings to customize`})})]})]})}var D,O=e((()=>{r(),h(),g(),d(),c(),w(),D=i()}));export{x as a,C as i,O as n,w as r,E as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,P as n,ai as r,kt as i,t as a}from"./src-BX54x08P.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{i as s,n as c}from"./loader-DsEdsMHv.js";import{r as l,t as u}from"./switcher-nLHGsxLw.js";import{n as d,t as f}from"./useExitOnCtrlCDWithKeybindings-DegJrysj.js";import{t as p}from"./select-BpiKdirZ.js";import{t as m}from"./CustomSelect-iSG1rbWU.js";var h=e(r(),1);a(),f(),c(),l(),m();var g=o(),_=[{key:`id`,label:`Provider id (kebab-case)`,placeholder:`my-provider`},{key:`baseUrl`,label:`Base URL`,placeholder:`https://api.example.com/v1`},{key:`apiKey`,label:`API Key`,placeholder:`sk-...`},{key:`model`,label:`Default model`,placeholder:`gpt-4o-mini`}],v=[{value:`save-openai`,label:`Save as OpenAI-compat (Chat Completions API)`},{value:`save-anthropic`,label:`Save as Anthropic-compat (Messages API)`},{value:`skip`,label:`Skip — configure later with /provider add`}];function y(e){return e===`save-openai`||e===`save-anthropic`||e===`skip`}function b(e){if(!e.id)return`Provider id is required.`;if(!/^[a-z0-9-]+$/.test(e.id))return`Provider id must be kebab-case (lowercase letters, digits, hyphens).`;if(!e.baseUrl)return`Base URL is required.`;try{new URL(e.baseUrl)}catch{return`Base URL must be a valid URL.`}return e.apiKey?null:`API Key is required.`}function x({onDone:e}){let r=(0,h.useRef)({id:``,baseUrl:``,apiKey:``,model:``}),[a,o]=(0,h.useState)(null),c=d();async function l(t){if(t===`skip`){e();return}let n=t===`save-openai`?`openai-compat`:`anthropic-compat`,i=b(r.current);if(i){o(i);return}let a={id:r.current.id,kind:n,baseUrl:r.current.baseUrl,apiKey:r.current.apiKey,defaultModel:r.current.model||`gpt-4o-mini`};try{s([a]),await u(a.id)}catch(e){let t=e instanceof Error?e.message:String(e);o(`Failed to save provider: ${t}`);return}e()}function f(e){o(null),y(e)&&l(e)}let m=[..._.map(e=>({type:`input`,label:e.label,value:e.key,placeholder:e.placeholder,allowEmptySubmitToCancel:!0,onChange:t=>{r.current[e.key]=t}})),...v.map(e=>({type:`text`,label:e.label,value:e.value}))];return(0,g.jsxs)(t,{flexDirection:`column`,gap:1,paddingLeft:1,children:[(0,g.jsx)(n,{bold:!0,color:`permission`,children:`Configure an API provider`}),(0,g.jsx)(t,{flexDirection:`column`,width:70,children:(0,g.jsxs)(n,{dimColor:!0,wrap:`wrap`,children:[`No provider is configured yet — `,(0,g.jsx)(n,{children:`~/.workmate/providers.json`}),` was not found.`,(0,g.jsx)(i,{}),`Fill in the fields below to point Work Mate at any OpenAI- or Anthropic-compatible`,(0,g.jsx)(i,{}),`endpoint. Type to edit a focused field, ↑/↓ to move between rows, Enter to trigger`,(0,g.jsx)(i,{}),`the highlighted action.`]})}),(0,g.jsx)(p,{options:m,onChange:f,onCancel:()=>e(),visibleOptionCount:m.length}),a&&(0,g.jsx)(n,{color:`error`,wrap:`wrap`,children:a}),c.pending&&(0,g.jsxs)(n,{dimColor:!0,children:[`Press `,c.keyName,` again to exit`]})]})}export{x as ProviderSetup};
1
+ import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,P as n,ai as r,kt as i,t as a}from"./src-BX54x08P.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{i as s,n as c}from"./loader-DsEdsMHv.js";import{r as l,t as u}from"./switcher-CqGz0hjQ.js";import{n as d,t as f}from"./useExitOnCtrlCDWithKeybindings-z3RiW9jT.js";import{t as p}from"./select-BNeFiLNP.js";import{t as m}from"./CustomSelect-uOjgHk8D.js";var h=e(r(),1);a(),f(),c(),l(),m();var g=o(),_=[{key:`id`,label:`Provider id (kebab-case)`,placeholder:`my-provider`},{key:`baseUrl`,label:`Base URL`,placeholder:`https://api.example.com/v1`},{key:`apiKey`,label:`API Key`,placeholder:`sk-...`},{key:`model`,label:`Default model`,placeholder:`gpt-4o-mini`}],v=[{value:`save-openai`,label:`Save as OpenAI-compat (Chat Completions API)`},{value:`save-anthropic`,label:`Save as Anthropic-compat (Messages API)`},{value:`skip`,label:`Skip — configure later with /provider add`}];function y(e){return e===`save-openai`||e===`save-anthropic`||e===`skip`}function b(e){if(!e.id)return`Provider id is required.`;if(!/^[a-z0-9-]+$/.test(e.id))return`Provider id must be kebab-case (lowercase letters, digits, hyphens).`;if(!e.baseUrl)return`Base URL is required.`;try{new URL(e.baseUrl)}catch{return`Base URL must be a valid URL.`}return e.apiKey?null:`API Key is required.`}function x({onDone:e}){let r=(0,h.useRef)({id:``,baseUrl:``,apiKey:``,model:``}),[a,o]=(0,h.useState)(null),c=d();async function l(t){if(t===`skip`){e();return}let n=t===`save-openai`?`openai-compat`:`anthropic-compat`,i=b(r.current);if(i){o(i);return}let a={id:r.current.id,kind:n,baseUrl:r.current.baseUrl,apiKey:r.current.apiKey,defaultModel:r.current.model||`gpt-4o-mini`};try{s([a]),await u(a.id)}catch(e){let t=e instanceof Error?e.message:String(e);o(`Failed to save provider: ${t}`);return}e()}function f(e){o(null),y(e)&&l(e)}let m=[..._.map(e=>({type:`input`,label:e.label,value:e.key,placeholder:e.placeholder,allowEmptySubmitToCancel:!0,onChange:t=>{r.current[e.key]=t}})),...v.map(e=>({type:`text`,label:e.label,value:e.value}))];return(0,g.jsxs)(t,{flexDirection:`column`,gap:1,paddingLeft:1,children:[(0,g.jsx)(n,{bold:!0,color:`permission`,children:`Configure an API provider`}),(0,g.jsx)(t,{flexDirection:`column`,width:70,children:(0,g.jsxs)(n,{dimColor:!0,wrap:`wrap`,children:[`No provider is configured yet — `,(0,g.jsx)(n,{children:`~/.workmate/providers.json`}),` was not found.`,(0,g.jsx)(i,{}),`Fill in the fields below to point Work Mate at any OpenAI- or Anthropic-compatible`,(0,g.jsx)(i,{}),`endpoint. Type to edit a focused field, ↑/↓ to move between rows, Enter to trigger`,(0,g.jsx)(i,{}),`the highlighted action.`]})}),(0,g.jsx)(p,{options:m,onChange:f,onCancel:()=>e(),visibleOptionCount:m.length}),a&&(0,g.jsx)(n,{color:`error`,wrap:`wrap`,children:a}),c.pending&&(0,g.jsxs)(n,{dimColor:!0,children:[`Press `,c.keyName,` again to exit`]})]})}export{x as ProviderSetup};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n,s as r}from"./envUtils-QyzA_cFM.js";import{n as i,t as a}from"./defineProperty-C-QyHrDq.js";import{Kr as o,qr as s}from"./src-BX54x08P.js";import{X as c,d as l,m as u,q as d}from"./settings-CA-5Px85.js";import{Ft as ee,K as f,Pt as p,at as m,ft as h,gt as g,rt as _}from"./state-CXY-q5gr.js";import{Aa as te,Cb as ne,Ds as v,Es as re,Gv as y,Hv as b,I_ as x,Ia as S,Kr as C,L_ as w,MC as T,Mi as ie,Pi as E,Q as D,Qn as O,R_ as ae,Ra as oe,SS as k,Sb as se,Ts as ce,Up as A,Vp as j,Vv as M,Xi as le,Xs as ue,Xu as de,YS as fe,Ys as N,Z as pe,_n as P,_v as F,_w as I,bC as me,ct as he,gv as ge,hS as _e,ig as ve,kC as L,lt as ye,ma as be,py as xe,qS as Se,qu as R,qv as z,qx as Ce,ry as B,sg as V,tg as we,tt as Te,uw as H,vn as Ee,vr as De,vw as Oe,ws as ke,yC as Ae}from"./loadAgentsDir-DnHL_5cU.js";import{n as U,t as je}from"./cwd-DrEEb4f5.js";import{C as Me,S as Ne,d as W,o as Pe}from"./config-Bjwat4P6.js";import{i as Fe,o as Ie,q as Le}from"./log-D98mO6yJ.js";import{f as G,s as Re,v as ze}from"./model-C9ANf1-R.js";import{at as K,bn as Be,nt as Ve,vn as He}from"./prompt-DDlkyIzV.js";import{n as Ue,o as We,r as q}from"./MessageSelector-DQgIgPij.js";import{n as Ge,t as J}from"./systemTheme-Ceakddth.js";import{randomUUID as Y}from"crypto";n(),i(),o(),p(),U(),Ie(),u(),Me(),He(),W(),I(),T(),Ae(),k(),xe(),K(),z(),F(),V(),A(),N(),S(),le(),E(),De(),P(),D(),ye(),ae(),b(),G(),B(),R();async function Ke({tools:e,mainLoopModel:t,additionalWorkingDirectories:n,mcpClients:r,customSystemPrompt:i}){let[a,o,s]=await Promise.all([i===void 0?he(e,t,n,r):Promise.resolve([]),w(),i===void 0?x():Promise.resolve({})]);return{defaultSystemPrompt:a,userContext:o,systemContext:s}}async function qe({tools:e,commands:t,mcpClients:n,messages:r,readFileState:i,getAppState:a,setAppState:o,customSystemPrompt:s,appendSystemPrompt:c,thinkingConfig:l,agents:u}){let d=Re(),ee=a(),{defaultSystemPrompt:f,userContext:p,systemContext:m}=await Ke({tools:e,mainLoopModel:d,additionalWorkingDirectories:Array.from(ee.toolPermissionContext.additionalWorkingDirectories.keys()),mcpClients:n,customSystemPrompt:s}),h=Se([...s===void 0?f:[s],...c?[c]:[]]),g=r.at(-1),_=g?.type===`assistant`&&g.message.stop_reason===null?r.slice(0,-1):r;return{systemPrompt:h,userContext:p,systemContext:m,toolUseContext:{options:{commands:t,debug:!1,mainLoopModel:d,tools:e,verbose:!1,thinkingConfig:l??(de()===!1?{type:`disabled`}:{type:`adaptive`}),mcpClients:n,mcpResources:{},isNonInteractiveSession:!0,agentDefinitions:{activeAgents:u,allAgents:[]},customSystemPrompt:s,appendSystemPrompt:c},abortController:M(),readFileState:i,getAppState:a,setAppState:o,messages:_,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},updateAttributionState:()=>{}},forkContextMessages:_}}c(),se(),te(),J(),H();function X(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString()}];case`user`:return[{type:`user`,message:e.message,uuid:e.uuid??Y(),timestamp:e.timestamp??new Date().toISOString(),isMeta:e.isSynthetic}];default:return[]}})}function Je(e){let t=e.preservedSegment;return{trigger:e.trigger,pre_tokens:e.preTokens,...t&&{preserved_segment:{head_uuid:t.headUuid,anchor_uuid:t.anchorUuid,tail_uuid:t.tailUuid}}}}function Ye(e,t){let n=Ce({content:s(e).replace(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/,`$1`).replace(/<local-command-stderr>([\s\S]*?)<\/local-command-stderr>/,`$1`).trim()});return{type:`assistant`,content:n.message?.content,message:n.message,parent_tool_use_id:null,session_id:m(),uuid:t}}function Z(e){if(e)return{type:`rate_limit`,status:e.status,...e.resetsAt!==void 0&&{resetsAt:e.resetsAt},...e.rateLimitType!==void 0&&{rateLimitType:e.rateLimitType},...e.utilization!==void 0&&{utilization:e.utilization},...e.overageStatus!==void 0&&{overageStatus:e.overageStatus},...e.overageResetsAt!==void 0&&{overageResetsAt:e.overageResetsAt},...e.overageDisabledReason!==void 0&&{overageDisabledReason:e.overageDisabledReason},...e.isUsingOverage!==void 0&&{isUsingOverage:e.isUsingOverage},...e.surpassedThreshold!==void 0&&{surpassedThreshold:e.surpassedThreshold}}}p();function Xe(e){return e===`Agent`?d:e}function Ze(e){let t=l()?.outputStyle??`default`,n={type:`system`,subtype:`init`,cwd:je(),session_id:m(),tools:e.tools.map(e=>Xe(e.name)),mcp_servers:e.mcpClients.map(e=>({name:e.name,status:e.type})),model:e.model,permissionMode:e.permissionMode,slash_commands:e.commands.filter(e=>e.userInvocable!==!1).map(e=>e.name),apiKeySource:process.env.ANTHROPIC_API_KEY?`ANTHROPIC_API_KEY`:`none`,betas:_(),claude_code_version:`0.0.30`,output_style:t,agents:e.agents.map(e=>e.agentType),skills:e.skills.filter(e=>e.userInvocable!==!1).map(e=>e.name),plugins:e.plugins.map(e=>({name:e.name,path:e.path,source:e.source})),uuid:Y()};return n.fast_mode_state=L(e.model,e.fastMode),n}p(),o(),Le(),b(),U(),T(),le(),G(),B(),R(),ce();var Qe=()=>{try{return q(),e(Ue)}catch{return null}},Q=class{constructor(e){a(this,`config`,void 0),a(this,`mutableMessages`,void 0),a(this,`abortController`,void 0),a(this,`permissionDenials`,void 0),a(this,`totalUsage`,void 0),a(this,`hasHandledOrphanedPermission`,!1),a(this,`readFileState`,void 0),a(this,`discoveredSkillNames`,new Set),a(this,`loadedNestedMemoryPaths`,new Set),this.config=e,this.mutableMessages=e.initialMessages??[],this.abortController=e.abortController??M(),this.permissionDenials=[],this.readFileState=e.readFileCache,this.totalUsage=fe}async*submitMessage(e,n){let{cwd:i,commands:a,tools:o,mcpClients:c,verbose:l=!1,thinkingConfig:u,maxTurns:d,maxBudgetUsd:p,taskBudget:_,canUseTool:te,customSystemPrompt:y,appendSystemPrompt:b,userSpecifiedModel:x,fallbackModel:S,jsonSchema:w,getAppState:T,setAppState:E,replayUserMessages:D=!1,includePartialMessages:ae=!1,agents:k=[],setSDKStatus:se,orphanedPermission:ce}=this.config;this.discoveredSkillNames.clear(),this.permissionDenials=[],ne(i);let A=!ee(),M=Date.now(),le=async(e,t,n,r,i,a)=>{let o=await te(e,t,n,r,i,a);return o.behavior!==`allow`&&this.permissionDenials.push({type:`permission_denial`,tool_name:Xe(e.name),tool_use_id:i,tool_input:t}),o},N=T(),P=x?ze(x):Re(),F=u||(de()===!1?{type:`disabled`}:{type:`adaptive`});j(`before_getSystemPrompt`);let I=typeof y==`string`?y:void 0,{defaultSystemPrompt:he,userContext:ye,systemContext:xe}=await Ke({tools:o,mainLoopModel:P,additionalWorkingDirectories:Array.from(N.toolPermissionContext.additionalWorkingDirectories.keys()),mcpClients:c,customSystemPrompt:I});j(`after_getSystemPrompt`);let R={...ye},z=I!==void 0&&Ne()?await Oe():null,Ce=Se([...I===void 0?he:[I],...z?[z]:[],...b?[b]:[]]),B=o.some(e=>Be(e,Ve));w&&B&&Ee(E,m());let V={messages:this.mutableMessages,setMessages:e=>{this.mutableMessages=e(this.mutableMessages)},onChangeAPIKey:()=>{},handleElicitation:this.config.handleElicitation,options:{commands:a,debug:!1,tools:o,verbose:l,mainLoopModel:P,thinkingConfig:F,mcpClients:c,mcpResources:{},isNonInteractiveSession:!0,customSystemPrompt:y,appendSystemPrompt:b,agentDefinitions:{activeAgents:k,allAgents:[]},theme:Ge(Pe().theme),maxBudgetUsd:p},getAppState:T,setAppState:E,abortController:this.abortController,readFileState:this.readFileState,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:this.loadedNestedMemoryPaths,dynamicSkillDirTriggers:new Set,discoveredSkillNames:this.discoveredSkillNames,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:e=>{E(t=>{let n=e(t.fileHistory);return n===t.fileHistory?t:{...t,fileHistory:n}})},updateAttributionState:e=>{E(t=>{let n=e(t.attribution);return n===t.attribution?t:{...t,attribution:n}})},setSDKStatus:se};if(ce&&!this.hasHandledOrphanedPermission){this.hasHandledOrphanedPermission=!0;for await(let e of ke(ce,o,this.mutableMessages,V))yield e}let{messages:H,shouldQuery:De,allowedTools:Ae,model:U,resultText:Me}=await We({input:e,mode:`prompt`,setToolJSX:()=>{},context:{...V,messages:this.mutableMessages},messages:this.mutableMessages,uuid:n?.uuid,isMeta:n?.isMeta,querySource:`sdk`});this.mutableMessages.push(...H);let W=[...this.mutableMessages];if(A&&H.length>0){let e=C(W);r()||(await e,(t(process.env.WORKMATE_EAGER_FLUSH)||t(process.env.WORKMATE_IS_COWORK))&&await O())}let Ie=Qe(),Le=H.filter(e=>e.type===`user`&&!e.isMeta&&!e.toolUseResult&&(Ie?.selectableUserMessagesFilter(e)??!0)||e.type===`system`&&e.subtype===`compact_boundary`),G=D?Le:[];E(e=>({...e,toolPermissionContext:{...e.toolPermissionContext,alwaysAllowRules:{...e.toolPermissionContext.alwaysAllowRules,command:Ae}}}));let K=U??P;V={messages:W,setMessages:()=>{},onChangeAPIKey:()=>{},handleElicitation:this.config.handleElicitation,options:{commands:a,debug:!1,tools:o,verbose:l,mainLoopModel:K,thinkingConfig:F,mcpClients:c,mcpResources:{},isNonInteractiveSession:!0,customSystemPrompt:y,appendSystemPrompt:b,theme:Ge(Pe().theme),agentDefinitions:{activeAgents:k,allAgents:[]},maxBudgetUsd:p},getAppState:T,setAppState:E,abortController:this.abortController,readFileState:this.readFileState,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:this.loadedNestedMemoryPaths,dynamicSkillDirTriggers:new Set,discoveredSkillNames:this.discoveredSkillNames,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:V.updateFileHistoryState,updateAttributionState:V.updateAttributionState,setSDKStatus:se},j(`before_skills_plugins`);let[He,{enabled:Ue}]=await Promise.all([ie(je()),oe()]);if(j(`after_skills_plugins`),yield Ze({tools:o,mcpClients:c,model:K,permissionMode:N.toolPermissionContext.mode,commands:a,agents:k,skills:He,plugins:Ue,fastMode:N.fastMode}),j(`system_message_yielded`),!De){for(let e of H)if(e.type===`user`&&typeof e.message.content==`string`&&(e.message.content.includes(`<local-command-stdout>`)||e.message.content.includes(`<local-command-stderr>`)||e.isCompactSummary)&&(yield{type:`user`,message:{...e.message,content:s(e.message.content)},session_id:m(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!e.isCompactSummary,isSynthetic:e.isMeta||e.isVisibleInTranscriptOnly}),e.type===`system`&&e.subtype===`local_command`&&typeof e.content==`string`&&(e.content.includes(`<local-command-stdout>`)||e.content.includes(`<local-command-stderr>`))&&(yield Ye(e.content,e.uuid)),e.type===`system`&&e.subtype===`compact_boundary`){let t=e;yield{type:`system`,subtype:`compact_boundary`,session_id:m(),uuid:e.uuid,compact_metadata:Je(t.compactMetadata)}}A&&(await C(W),(t(process.env.WORKMATE_EAGER_FLUSH)||t(process.env.WORKMATE_IS_COWORK))&&await O()),yield{type:`result`,subtype:`success`,is_error:!1,duration_ms:Date.now()-M,duration_api_ms:h(),num_turns:W.length-1,result:Me??``,stop_reason:null,session_id:m(),total_cost_usd:g(),usage:this.totalUsage,modelUsage:f(),permission_denials:this.permissionDenials,fast_mode_state:L(K,N.fastMode),uuid:Y()};return}if(we()&&A){let e=Qe()?.selectableUserMessagesFilter??(e=>!0);H.filter(e).forEach(e=>{ve(e=>{E(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)})}let q=fe,J=1,qe=!1,X,Z=null,Q=Fe().at(-1),$e=w?be(this.mutableMessages,Ve):0;for await(let e of ue({messages:W,systemPrompt:Ce,userContext:R,systemContext:xe,canUseTool:le,toolUseContext:V,fallbackModel:S,querySource:`sdk`,maxTurns:d,taskBudget:_})){if(e.type===`assistant`||e.type===`user`||e.type===`system`&&e.subtype===`compact_boundary`){if(A&&e.type===`system`&&e.subtype===`compact_boundary`){let t=e.compactMetadata?.preservedSegment?.tailUuid;if(t){let e=this.mutableMessages.findLastIndex(e=>e.uuid===t);e!==-1&&await C(this.mutableMessages.slice(0,e+1))}}if(W.push(e),A&&(e.type===`assistant`?C(W):await C(W)),!qe&&G.length>0){qe=!0;for(let e of G)e.type===`user`&&(yield{type:`user`,message:e.message,session_id:m(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}}switch(e.type===`user`&&J++,e.type){case`tombstone`:break;case`assistant`:{let t=e,n=t.message?.stop_reason;n!=null&&(Z=n),this.mutableMessages.push(t),yield*v(t);break}case`progress`:{let t=e;this.mutableMessages.push(t),A&&(W.push(t),C(W)),yield*v(t);break}case`user`:{let t=e;this.mutableMessages.push(t),yield*v(t);break}case`stream_event`:{let t=e.event;if(t.type===`message_start`){q=fe;let e=t.message;q=Te(q,e.usage)}if(t.type===`message_delta`){q=Te(q,t.usage);let e=t.delta;e.stop_reason!=null&&(Z=e.stop_reason)}t.type===`message_stop`&&(this.totalUsage=pe(this.totalUsage,q)),ae&&(yield{type:`stream_event`,event:t,session_id:m(),parent_tool_use_id:null,uuid:Y()});break}case`attachment`:{let n=e;this.mutableMessages.push(n),A&&(W.push(n),C(W));let r=n.attachment;if(r.type===`structured_output`)X=r.data;else if(r.type===`max_turns_reached`){A&&(t(process.env.WORKMATE_EAGER_FLUSH)||t(process.env.WORKMATE_IS_COWORK))&&await O(),yield{type:`result`,subtype:`error_max_turns`,duration_ms:Date.now()-M,duration_api_ms:h(),is_error:!0,num_turns:r.turnCount,stop_reason:Z,session_id:m(),total_cost_usd:g(),usage:this.totalUsage,modelUsage:f(),permission_denials:this.permissionDenials,fast_mode_state:L(K,N.fastMode),uuid:Y(),errors:[`Reached maximum number of turns (${r.maxTurns})`]};return}else D&&r.type===`queued_command`&&(yield{type:`user`,message:{role:`user`,content:r.prompt},session_id:m(),parent_tool_use_id:null,uuid:r.source_uuid||n.uuid,timestamp:n.timestamp,isReplay:!0});break}case`stream_request_start`:break;case`system`:{let t=e,n=this.config.snipReplay?.(t,this.mutableMessages);if(n!==void 0){n.executed&&(this.mutableMessages.length=0,this.mutableMessages.push(...n.messages));break}if(this.mutableMessages.push(t),t.subtype===`compact_boundary`&&t.compactMetadata){let e=t,n=this.mutableMessages.length-1;n>0&&this.mutableMessages.splice(0,n);let r=W.length-1;r>0&&W.splice(0,r),yield{type:`system`,subtype:`compact_boundary`,session_id:m(),uuid:t.uuid,compact_metadata:Je(e.compactMetadata)}}if(t.subtype===`api_error`){let e=t;yield{type:`system`,subtype:`api_retry`,attempt:e.retryAttempt,max_retries:e.maxRetries,retry_delay_ms:e.retryInMs,error_status:e.error.status??null,error:ge(e.error),session_id:m(),uuid:t.uuid}}break}case`tool_use_summary`:{let t=e;yield{type:`tool_use_summary`,summary:t.summary,preceding_tool_use_ids:t.precedingToolUseIds,session_id:m(),uuid:t.uuid};break}}if(p!==void 0&&g()>=p){A&&(t(process.env.WORKMATE_EAGER_FLUSH)||t(process.env.WORKMATE_IS_COWORK))&&await O(),yield{type:`result`,subtype:`error_max_budget_usd`,duration_ms:Date.now()-M,duration_api_ms:h(),is_error:!0,num_turns:J,stop_reason:Z,session_id:m(),total_cost_usd:g(),usage:this.totalUsage,modelUsage:f(),permission_denials:this.permissionDenials,fast_mode_state:L(K,N.fastMode),uuid:Y(),errors:[`Reached maximum budget ($${p}). Increase the limit with --max-budget-usd or start a new session.`]};return}if(e.type===`user`&&w){let e=be(this.mutableMessages,Ve)-$e,n=parseInt(process.env.MAX_STRUCTURED_OUTPUT_RETRIES||`5`,10);if(e>=n){A&&(t(process.env.WORKMATE_EAGER_FLUSH)||t(process.env.WORKMATE_IS_COWORK))&&await O(),yield{type:`result`,subtype:`error_max_structured_output_retries`,duration_ms:Date.now()-M,duration_api_ms:h(),is_error:!0,num_turns:J,stop_reason:Z,session_id:m(),total_cost_usd:g(),usage:this.totalUsage,modelUsage:f(),permission_denials:this.permissionDenials,fast_mode_state:L(K,N.fastMode),uuid:Y(),errors:[`Failed to provide valid structured output after ${n} attempts`]};return}}}let $=W.findLast(e=>e.type===`assistant`||e.type===`user`),et=$?.type??`undefined`,tt=$?.type===`assistant`?me($.message.content)?.type??`none`:`n/a`;if(A&&(t(process.env.WORKMATE_EAGER_FLUSH)||t(process.env.WORKMATE_IS_COWORK))&&await O(),!re($,Z)){yield{type:`result`,subtype:`error_during_execution`,duration_ms:Date.now()-M,duration_api_ms:h(),is_error:!0,num_turns:J,stop_reason:Z,session_id:m(),total_cost_usd:g(),usage:this.totalUsage,modelUsage:f(),permission_denials:this.permissionDenials,fast_mode_state:L(K,N.fastMode),uuid:Y(),errors:(()=>{let e=Fe(),t=Q?e.lastIndexOf(Q)+1:0;return[`[ede_diagnostic] result_type=${et} last_content_type=${tt} stop_reason=${Z}`,...e.slice(t).map(e=>e.error)]})()};return}let nt=``,rt=!1;if($.type===`assistant`){let e=me($.message.content);e?.type===`text`&&!_e.has(e.text)&&(nt=e.text),rt=!!$.isApiErrorMessage}yield{type:`result`,subtype:`success`,is_error:rt,duration_ms:Date.now()-M,duration_api_ms:h(),num_turns:J,result:nt,stop_reason:Z,session_id:m(),total_cost_usd:g(),usage:this.totalUsage,modelUsage:f(),permission_denials:this.permissionDenials,structured_output:X,fast_mode_state:L(K,N.fastMode),uuid:Y()}}interrupt(){this.abortController.abort()}resetAbortController(){this.abortController=M()}getAbortSignal(){return this.abortController.signal}getMessages(){return this.mutableMessages}getReadFileState(){return this.readFileState}getSessionId(){return m()}setModel(e){this.config.userSpecifiedModel=e}};async function*$e({commands:e,prompt:t,promptUuid:n,isMeta:r,cwd:i,tools:a,mcpClients:o,verbose:s=!1,thinkingConfig:c,maxTurns:l,maxBudgetUsd:u,taskBudget:d,canUseTool:ee,mutableMessages:f=[],getReadFileCache:p,setReadFileCache:m,customSystemPrompt:h,appendSystemPrompt:g,userSpecifiedModel:_,fallbackModel:te,jsonSchema:ne,getAppState:v,setAppState:re,abortController:b,replayUserMessages:x=!1,includePartialMessages:S=!1,handleElicitation:C,agents:w=[],setSDKStatus:T,orphanedPermission:ie}){let E=new Q({cwd:i,tools:a,commands:e,mcpClients:o,agents:w??[],canUseTool:ee,getAppState:v,setAppState:re,initialMessages:f,readFileCache:y(p()),customSystemPrompt:h,appendSystemPrompt:g,userSpecifiedModel:_,fallbackModel:te,thinkingConfig:c,maxTurns:l,maxBudgetUsd:u,taskBudget:d,jsonSchema:ne,verbose:s,handleElicitation:C,replayUserMessages:x,includePartialMessages:S,setSDKStatus:T,abortController:b,orphanedPermission:ie});try{yield*E.submitMessage(t,{uuid:n,isMeta:r})}finally{m(E.getReadFileState())}}export{qe as a,Z as i,$e as n,X as r,Q as t};
1
+ import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n,s as r}from"./envUtils-QyzA_cFM.js";import{n as i,t as a}from"./defineProperty-C-QyHrDq.js";import{Kr as o,qr as s}from"./src-BX54x08P.js";import{X as c,d as l,m as u,q as d}from"./settings-CA-5Px85.js";import{Ft as ee,K as f,Pt as p,at as m,ft as h,gt as g,rt as _}from"./state-CXY-q5gr.js";import{Aa as te,Cb as ne,Ds as v,Es as re,Gv as y,Hv as b,I_ as x,Ia as S,Kr as C,L_ as w,MC as T,Mi as ie,Pi as E,Q as D,Qn as O,R_ as ae,Ra as oe,SS as k,Sb as se,Ts as ce,Up as A,Vp as j,Vv as M,Xi as le,Xs as ue,Xu as de,YS as fe,Ys as N,Z as pe,_n as P,_v as F,_w as I,bC as me,ct as he,gv as ge,hS as _e,ig as ve,kC as L,lt as ye,ma as be,py as xe,qS as Se,qu as R,qv as z,qx as Ce,ry as B,sg as V,tg as we,tt as Te,uw as H,vn as Ee,vr as De,vw as Oe,ws as ke,yC as Ae}from"./loadAgentsDir-CgDTTnMX.js";import{n as U,t as je}from"./cwd-DrEEb4f5.js";import{C as Me,S as Ne,d as W,o as Pe}from"./config-CMtnYZR9.js";import{i as Fe,o as Ie,q as Le}from"./log-D98mO6yJ.js";import{f as G,s as Re,v as ze}from"./model-BidsdFhX.js";import{at as K,bn as Be,nt as Ve,vn as He}from"./prompt-CduUPV0s.js";import{n as Ue,o as We,r as q}from"./MessageSelector-DuCpdn-Q.js";import{n as Ge,t as J}from"./systemTheme-Ceakddth.js";import{randomUUID as Y}from"crypto";n(),i(),o(),p(),U(),Ie(),u(),Me(),He(),W(),I(),T(),Ae(),k(),xe(),K(),z(),F(),V(),A(),N(),S(),le(),E(),De(),P(),D(),ye(),ae(),b(),G(),B(),R();async function Ke({tools:e,mainLoopModel:t,additionalWorkingDirectories:n,mcpClients:r,customSystemPrompt:i}){let[a,o,s]=await Promise.all([i===void 0?he(e,t,n,r):Promise.resolve([]),w(),i===void 0?x():Promise.resolve({})]);return{defaultSystemPrompt:a,userContext:o,systemContext:s}}async function qe({tools:e,commands:t,mcpClients:n,messages:r,readFileState:i,getAppState:a,setAppState:o,customSystemPrompt:s,appendSystemPrompt:c,thinkingConfig:l,agents:u}){let d=Re(),ee=a(),{defaultSystemPrompt:f,userContext:p,systemContext:m}=await Ke({tools:e,mainLoopModel:d,additionalWorkingDirectories:Array.from(ee.toolPermissionContext.additionalWorkingDirectories.keys()),mcpClients:n,customSystemPrompt:s}),h=Se([...s===void 0?f:[s],...c?[c]:[]]),g=r.at(-1),_=g?.type===`assistant`&&g.message.stop_reason===null?r.slice(0,-1):r;return{systemPrompt:h,userContext:p,systemContext:m,toolUseContext:{options:{commands:t,debug:!1,mainLoopModel:d,tools:e,verbose:!1,thinkingConfig:l??(de()===!1?{type:`disabled`}:{type:`adaptive`}),mcpClients:n,mcpResources:{},isNonInteractiveSession:!0,agentDefinitions:{activeAgents:u,allAgents:[]},customSystemPrompt:s,appendSystemPrompt:c},abortController:M(),readFileState:i,getAppState:a,setAppState:o,messages:_,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},updateAttributionState:()=>{}},forkContextMessages:_}}c(),se(),te(),J(),H();function X(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString()}];case`user`:return[{type:`user`,message:e.message,uuid:e.uuid??Y(),timestamp:e.timestamp??new Date().toISOString(),isMeta:e.isSynthetic}];default:return[]}})}function Je(e){let t=e.preservedSegment;return{trigger:e.trigger,pre_tokens:e.preTokens,...t&&{preserved_segment:{head_uuid:t.headUuid,anchor_uuid:t.anchorUuid,tail_uuid:t.tailUuid}}}}function Ye(e,t){let n=Ce({content:s(e).replace(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/,`$1`).replace(/<local-command-stderr>([\s\S]*?)<\/local-command-stderr>/,`$1`).trim()});return{type:`assistant`,content:n.message?.content,message:n.message,parent_tool_use_id:null,session_id:m(),uuid:t}}function Z(e){if(e)return{type:`rate_limit`,status:e.status,...e.resetsAt!==void 0&&{resetsAt:e.resetsAt},...e.rateLimitType!==void 0&&{rateLimitType:e.rateLimitType},...e.utilization!==void 0&&{utilization:e.utilization},...e.overageStatus!==void 0&&{overageStatus:e.overageStatus},...e.overageResetsAt!==void 0&&{overageResetsAt:e.overageResetsAt},...e.overageDisabledReason!==void 0&&{overageDisabledReason:e.overageDisabledReason},...e.isUsingOverage!==void 0&&{isUsingOverage:e.isUsingOverage},...e.surpassedThreshold!==void 0&&{surpassedThreshold:e.surpassedThreshold}}}p();function Xe(e){return e===`Agent`?d:e}function Ze(e){let t=l()?.outputStyle??`default`,n={type:`system`,subtype:`init`,cwd:je(),session_id:m(),tools:e.tools.map(e=>Xe(e.name)),mcp_servers:e.mcpClients.map(e=>({name:e.name,status:e.type})),model:e.model,permissionMode:e.permissionMode,slash_commands:e.commands.filter(e=>e.userInvocable!==!1).map(e=>e.name),apiKeySource:process.env.ANTHROPIC_API_KEY?`ANTHROPIC_API_KEY`:`none`,betas:_(),claude_code_version:`0.0.31`,output_style:t,agents:e.agents.map(e=>e.agentType),skills:e.skills.filter(e=>e.userInvocable!==!1).map(e=>e.name),plugins:e.plugins.map(e=>({name:e.name,path:e.path,source:e.source})),uuid:Y()};return n.fast_mode_state=L(e.model,e.fastMode),n}p(),o(),Le(),b(),U(),T(),le(),G(),B(),R(),ce();var Qe=()=>{try{return q(),e(Ue)}catch{return null}},Q=class{constructor(e){a(this,`config`,void 0),a(this,`mutableMessages`,void 0),a(this,`abortController`,void 0),a(this,`permissionDenials`,void 0),a(this,`totalUsage`,void 0),a(this,`hasHandledOrphanedPermission`,!1),a(this,`readFileState`,void 0),a(this,`discoveredSkillNames`,new Set),a(this,`loadedNestedMemoryPaths`,new Set),this.config=e,this.mutableMessages=e.initialMessages??[],this.abortController=e.abortController??M(),this.permissionDenials=[],this.readFileState=e.readFileCache,this.totalUsage=fe}async*submitMessage(e,n){let{cwd:i,commands:a,tools:o,mcpClients:c,verbose:l=!1,thinkingConfig:u,maxTurns:d,maxBudgetUsd:p,taskBudget:_,canUseTool:te,customSystemPrompt:y,appendSystemPrompt:b,userSpecifiedModel:x,fallbackModel:S,jsonSchema:w,getAppState:T,setAppState:E,replayUserMessages:D=!1,includePartialMessages:ae=!1,agents:k=[],setSDKStatus:se,orphanedPermission:ce}=this.config;this.discoveredSkillNames.clear(),this.permissionDenials=[],ne(i);let A=!ee(),M=Date.now(),le=async(e,t,n,r,i,a)=>{let o=await te(e,t,n,r,i,a);return o.behavior!==`allow`&&this.permissionDenials.push({type:`permission_denial`,tool_name:Xe(e.name),tool_use_id:i,tool_input:t}),o},N=T(),P=x?ze(x):Re(),F=u||(de()===!1?{type:`disabled`}:{type:`adaptive`});j(`before_getSystemPrompt`);let I=typeof y==`string`?y:void 0,{defaultSystemPrompt:he,userContext:ye,systemContext:xe}=await Ke({tools:o,mainLoopModel:P,additionalWorkingDirectories:Array.from(N.toolPermissionContext.additionalWorkingDirectories.keys()),mcpClients:c,customSystemPrompt:I});j(`after_getSystemPrompt`);let R={...ye},z=I!==void 0&&Ne()?await Oe():null,Ce=Se([...I===void 0?he:[I],...z?[z]:[],...b?[b]:[]]),B=o.some(e=>Be(e,Ve));w&&B&&Ee(E,m());let V={messages:this.mutableMessages,setMessages:e=>{this.mutableMessages=e(this.mutableMessages)},onChangeAPIKey:()=>{},handleElicitation:this.config.handleElicitation,options:{commands:a,debug:!1,tools:o,verbose:l,mainLoopModel:P,thinkingConfig:F,mcpClients:c,mcpResources:{},isNonInteractiveSession:!0,customSystemPrompt:y,appendSystemPrompt:b,agentDefinitions:{activeAgents:k,allAgents:[]},theme:Ge(Pe().theme),maxBudgetUsd:p},getAppState:T,setAppState:E,abortController:this.abortController,readFileState:this.readFileState,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:this.loadedNestedMemoryPaths,dynamicSkillDirTriggers:new Set,discoveredSkillNames:this.discoveredSkillNames,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:e=>{E(t=>{let n=e(t.fileHistory);return n===t.fileHistory?t:{...t,fileHistory:n}})},updateAttributionState:e=>{E(t=>{let n=e(t.attribution);return n===t.attribution?t:{...t,attribution:n}})},setSDKStatus:se};if(ce&&!this.hasHandledOrphanedPermission){this.hasHandledOrphanedPermission=!0;for await(let e of ke(ce,o,this.mutableMessages,V))yield e}let{messages:H,shouldQuery:De,allowedTools:Ae,model:U,resultText:Me}=await We({input:e,mode:`prompt`,setToolJSX:()=>{},context:{...V,messages:this.mutableMessages},messages:this.mutableMessages,uuid:n?.uuid,isMeta:n?.isMeta,querySource:`sdk`});this.mutableMessages.push(...H);let W=[...this.mutableMessages];if(A&&H.length>0){let e=C(W);r()||(await e,(t(process.env.WORKMATE_EAGER_FLUSH)||t(process.env.WORKMATE_IS_COWORK))&&await O())}let Ie=Qe(),Le=H.filter(e=>e.type===`user`&&!e.isMeta&&!e.toolUseResult&&(Ie?.selectableUserMessagesFilter(e)??!0)||e.type===`system`&&e.subtype===`compact_boundary`),G=D?Le:[];E(e=>({...e,toolPermissionContext:{...e.toolPermissionContext,alwaysAllowRules:{...e.toolPermissionContext.alwaysAllowRules,command:Ae}}}));let K=U??P;V={messages:W,setMessages:()=>{},onChangeAPIKey:()=>{},handleElicitation:this.config.handleElicitation,options:{commands:a,debug:!1,tools:o,verbose:l,mainLoopModel:K,thinkingConfig:F,mcpClients:c,mcpResources:{},isNonInteractiveSession:!0,customSystemPrompt:y,appendSystemPrompt:b,theme:Ge(Pe().theme),agentDefinitions:{activeAgents:k,allAgents:[]},maxBudgetUsd:p},getAppState:T,setAppState:E,abortController:this.abortController,readFileState:this.readFileState,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:this.loadedNestedMemoryPaths,dynamicSkillDirTriggers:new Set,discoveredSkillNames:this.discoveredSkillNames,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:V.updateFileHistoryState,updateAttributionState:V.updateAttributionState,setSDKStatus:se},j(`before_skills_plugins`);let[He,{enabled:Ue}]=await Promise.all([ie(je()),oe()]);if(j(`after_skills_plugins`),yield Ze({tools:o,mcpClients:c,model:K,permissionMode:N.toolPermissionContext.mode,commands:a,agents:k,skills:He,plugins:Ue,fastMode:N.fastMode}),j(`system_message_yielded`),!De){for(let e of H)if(e.type===`user`&&typeof e.message.content==`string`&&(e.message.content.includes(`<local-command-stdout>`)||e.message.content.includes(`<local-command-stderr>`)||e.isCompactSummary)&&(yield{type:`user`,message:{...e.message,content:s(e.message.content)},session_id:m(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!e.isCompactSummary,isSynthetic:e.isMeta||e.isVisibleInTranscriptOnly}),e.type===`system`&&e.subtype===`local_command`&&typeof e.content==`string`&&(e.content.includes(`<local-command-stdout>`)||e.content.includes(`<local-command-stderr>`))&&(yield Ye(e.content,e.uuid)),e.type===`system`&&e.subtype===`compact_boundary`){let t=e;yield{type:`system`,subtype:`compact_boundary`,session_id:m(),uuid:e.uuid,compact_metadata:Je(t.compactMetadata)}}A&&(await C(W),(t(process.env.WORKMATE_EAGER_FLUSH)||t(process.env.WORKMATE_IS_COWORK))&&await O()),yield{type:`result`,subtype:`success`,is_error:!1,duration_ms:Date.now()-M,duration_api_ms:h(),num_turns:W.length-1,result:Me??``,stop_reason:null,session_id:m(),total_cost_usd:g(),usage:this.totalUsage,modelUsage:f(),permission_denials:this.permissionDenials,fast_mode_state:L(K,N.fastMode),uuid:Y()};return}if(we()&&A){let e=Qe()?.selectableUserMessagesFilter??(e=>!0);H.filter(e).forEach(e=>{ve(e=>{E(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)})}let q=fe,J=1,qe=!1,X,Z=null,Q=Fe().at(-1),$e=w?be(this.mutableMessages,Ve):0;for await(let e of ue({messages:W,systemPrompt:Ce,userContext:R,systemContext:xe,canUseTool:le,toolUseContext:V,fallbackModel:S,querySource:`sdk`,maxTurns:d,taskBudget:_})){if(e.type===`assistant`||e.type===`user`||e.type===`system`&&e.subtype===`compact_boundary`){if(A&&e.type===`system`&&e.subtype===`compact_boundary`){let t=e.compactMetadata?.preservedSegment?.tailUuid;if(t){let e=this.mutableMessages.findLastIndex(e=>e.uuid===t);e!==-1&&await C(this.mutableMessages.slice(0,e+1))}}if(W.push(e),A&&(e.type===`assistant`?C(W):await C(W)),!qe&&G.length>0){qe=!0;for(let e of G)e.type===`user`&&(yield{type:`user`,message:e.message,session_id:m(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}}switch(e.type===`user`&&J++,e.type){case`tombstone`:break;case`assistant`:{let t=e,n=t.message?.stop_reason;n!=null&&(Z=n),this.mutableMessages.push(t),yield*v(t);break}case`progress`:{let t=e;this.mutableMessages.push(t),A&&(W.push(t),C(W)),yield*v(t);break}case`user`:{let t=e;this.mutableMessages.push(t),yield*v(t);break}case`stream_event`:{let t=e.event;if(t.type===`message_start`){q=fe;let e=t.message;q=Te(q,e.usage)}if(t.type===`message_delta`){q=Te(q,t.usage);let e=t.delta;e.stop_reason!=null&&(Z=e.stop_reason)}t.type===`message_stop`&&(this.totalUsage=pe(this.totalUsage,q)),ae&&(yield{type:`stream_event`,event:t,session_id:m(),parent_tool_use_id:null,uuid:Y()});break}case`attachment`:{let n=e;this.mutableMessages.push(n),A&&(W.push(n),C(W));let r=n.attachment;if(r.type===`structured_output`)X=r.data;else if(r.type===`max_turns_reached`){A&&(t(process.env.WORKMATE_EAGER_FLUSH)||t(process.env.WORKMATE_IS_COWORK))&&await O(),yield{type:`result`,subtype:`error_max_turns`,duration_ms:Date.now()-M,duration_api_ms:h(),is_error:!0,num_turns:r.turnCount,stop_reason:Z,session_id:m(),total_cost_usd:g(),usage:this.totalUsage,modelUsage:f(),permission_denials:this.permissionDenials,fast_mode_state:L(K,N.fastMode),uuid:Y(),errors:[`Reached maximum number of turns (${r.maxTurns})`]};return}else D&&r.type===`queued_command`&&(yield{type:`user`,message:{role:`user`,content:r.prompt},session_id:m(),parent_tool_use_id:null,uuid:r.source_uuid||n.uuid,timestamp:n.timestamp,isReplay:!0});break}case`stream_request_start`:break;case`system`:{let t=e,n=this.config.snipReplay?.(t,this.mutableMessages);if(n!==void 0){n.executed&&(this.mutableMessages.length=0,this.mutableMessages.push(...n.messages));break}if(this.mutableMessages.push(t),t.subtype===`compact_boundary`&&t.compactMetadata){let e=t,n=this.mutableMessages.length-1;n>0&&this.mutableMessages.splice(0,n);let r=W.length-1;r>0&&W.splice(0,r),yield{type:`system`,subtype:`compact_boundary`,session_id:m(),uuid:t.uuid,compact_metadata:Je(e.compactMetadata)}}if(t.subtype===`api_error`){let e=t;yield{type:`system`,subtype:`api_retry`,attempt:e.retryAttempt,max_retries:e.maxRetries,retry_delay_ms:e.retryInMs,error_status:e.error.status??null,error:ge(e.error),session_id:m(),uuid:t.uuid}}break}case`tool_use_summary`:{let t=e;yield{type:`tool_use_summary`,summary:t.summary,preceding_tool_use_ids:t.precedingToolUseIds,session_id:m(),uuid:t.uuid};break}}if(p!==void 0&&g()>=p){A&&(t(process.env.WORKMATE_EAGER_FLUSH)||t(process.env.WORKMATE_IS_COWORK))&&await O(),yield{type:`result`,subtype:`error_max_budget_usd`,duration_ms:Date.now()-M,duration_api_ms:h(),is_error:!0,num_turns:J,stop_reason:Z,session_id:m(),total_cost_usd:g(),usage:this.totalUsage,modelUsage:f(),permission_denials:this.permissionDenials,fast_mode_state:L(K,N.fastMode),uuid:Y(),errors:[`Reached maximum budget ($${p}). Increase the limit with --max-budget-usd or start a new session.`]};return}if(e.type===`user`&&w){let e=be(this.mutableMessages,Ve)-$e,n=parseInt(process.env.MAX_STRUCTURED_OUTPUT_RETRIES||`5`,10);if(e>=n){A&&(t(process.env.WORKMATE_EAGER_FLUSH)||t(process.env.WORKMATE_IS_COWORK))&&await O(),yield{type:`result`,subtype:`error_max_structured_output_retries`,duration_ms:Date.now()-M,duration_api_ms:h(),is_error:!0,num_turns:J,stop_reason:Z,session_id:m(),total_cost_usd:g(),usage:this.totalUsage,modelUsage:f(),permission_denials:this.permissionDenials,fast_mode_state:L(K,N.fastMode),uuid:Y(),errors:[`Failed to provide valid structured output after ${n} attempts`]};return}}}let $=W.findLast(e=>e.type===`assistant`||e.type===`user`),et=$?.type??`undefined`,tt=$?.type===`assistant`?me($.message.content)?.type??`none`:`n/a`;if(A&&(t(process.env.WORKMATE_EAGER_FLUSH)||t(process.env.WORKMATE_IS_COWORK))&&await O(),!re($,Z)){yield{type:`result`,subtype:`error_during_execution`,duration_ms:Date.now()-M,duration_api_ms:h(),is_error:!0,num_turns:J,stop_reason:Z,session_id:m(),total_cost_usd:g(),usage:this.totalUsage,modelUsage:f(),permission_denials:this.permissionDenials,fast_mode_state:L(K,N.fastMode),uuid:Y(),errors:(()=>{let e=Fe(),t=Q?e.lastIndexOf(Q)+1:0;return[`[ede_diagnostic] result_type=${et} last_content_type=${tt} stop_reason=${Z}`,...e.slice(t).map(e=>e.error)]})()};return}let nt=``,rt=!1;if($.type===`assistant`){let e=me($.message.content);e?.type===`text`&&!_e.has(e.text)&&(nt=e.text),rt=!!$.isApiErrorMessage}yield{type:`result`,subtype:`success`,is_error:rt,duration_ms:Date.now()-M,duration_api_ms:h(),num_turns:J,result:nt,stop_reason:Z,session_id:m(),total_cost_usd:g(),usage:this.totalUsage,modelUsage:f(),permission_denials:this.permissionDenials,structured_output:X,fast_mode_state:L(K,N.fastMode),uuid:Y()}}interrupt(){this.abortController.abort()}resetAbortController(){this.abortController=M()}getAbortSignal(){return this.abortController.signal}getMessages(){return this.mutableMessages}getReadFileState(){return this.readFileState}getSessionId(){return m()}setModel(e){this.config.userSpecifiedModel=e}};async function*$e({commands:e,prompt:t,promptUuid:n,isMeta:r,cwd:i,tools:a,mcpClients:o,verbose:s=!1,thinkingConfig:c,maxTurns:l,maxBudgetUsd:u,taskBudget:d,canUseTool:ee,mutableMessages:f=[],getReadFileCache:p,setReadFileCache:m,customSystemPrompt:h,appendSystemPrompt:g,userSpecifiedModel:_,fallbackModel:te,jsonSchema:ne,getAppState:v,setAppState:re,abortController:b,replayUserMessages:x=!1,includePartialMessages:S=!1,handleElicitation:C,agents:w=[],setSDKStatus:T,orphanedPermission:ie}){let E=new Q({cwd:i,tools:a,commands:e,mcpClients:o,agents:w??[],canUseTool:ee,getAppState:v,setAppState:re,initialMessages:f,readFileCache:y(p()),customSystemPrompt:h,appendSystemPrompt:g,userSpecifiedModel:_,fallbackModel:te,thinkingConfig:c,maxTurns:l,maxBudgetUsd:u,taskBudget:d,jsonSchema:ne,verbose:s,handleElicitation:C,replayUserMessages:x,includePartialMessages:S,setSDKStatus:T,abortController:b,orphanedPermission:ie});try{yield*E.submitMessage(t,{uuid:n,isMeta:r})}finally{m(E.getReadFileState())}}export{qe as a,Z as i,$e as n,X as r,Q as t};