@readmagic/workmate 0.0.4 → 0.0.6
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.
- package/dist/chunks/{AddWorkspaceDirectory-BTC7FPqM.js → AddWorkspaceDirectory-ClHi-Dr6.js} +1 -1
- package/dist/chunks/{App-DOm71vtY.js → App-BP06lHmf.js} +1 -1
- package/dist/chunks/{ApproveApiKey-9YQzwrrC.js → ApproveApiKey-Bsy8kr2a.js} +1 -1
- package/dist/chunks/ApproveApiKey-a2ZonQ3n.js +1 -0
- package/dist/chunks/{AssistantSessionChooser-CnYfFWrx.js → AssistantSessionChooser-CcocKoTJ.js} +1 -1
- package/dist/chunks/BackgroundTasksDialog-DNeBhGCf.js +2 -0
- package/dist/chunks/{BypassPermissionsModeDialog-DAq-qbqC.js → BypassPermissionsModeDialog-BKj_3Idm.js} +1 -1
- package/dist/chunks/{ClaudeMdExternalIncludesDialog-CyvidoR3.js → ClaudeMdExternalIncludesDialog-BD-7yAZh.js} +1 -1
- package/dist/chunks/ClaudeMdExternalIncludesDialog-DFivNFuo.js +1 -0
- package/dist/chunks/ConsoleOAuthFlow-CS3zjEPF.js +1 -0
- package/dist/chunks/{DesktopHandoff-gRvy-WlW.js → DesktopHandoff-BmPmCfT3.js} +1 -1
- package/dist/chunks/{DiffDialog-CdfVTgOx.js → DiffDialog-C4XSSjvV.js} +2 -2
- package/dist/chunks/Doctor-BhD-ZzZm.js +1 -0
- package/dist/chunks/Doctor-DEQe2q16.js +3 -0
- package/dist/chunks/ExitFlow-BttnAv-O.js +2 -0
- package/dist/chunks/{Feedback-gGpjUC_F.js → Feedback-BaYA8-SU.js} +2 -2
- package/dist/chunks/Grove-BJziCbZH.js +11 -0
- package/dist/chunks/Grove-sWm-oLBf.js +1 -0
- package/dist/chunks/{HybridTransport-kN1jmg26.js → HybridTransport-B8V6O6rM.js} +1 -1
- package/dist/chunks/{InvalidConfigDialog-BpJub73a.js → InvalidConfigDialog-CHzBSJDf.js} +1 -1
- package/dist/chunks/{InvalidSettingsDialog-DzOp3Ihx.js → InvalidSettingsDialog-BKenH3bD.js} +1 -1
- package/dist/chunks/MCPConnectionManager-CNh9dNlk.js +1 -0
- package/dist/chunks/{McpParsingWarnings-Cc6FWyU4.js → McpParsingWarnings-Bj2-YL8o.js} +1 -1
- package/dist/chunks/MessageSelector-DdR6wJhh.js +3 -0
- package/dist/chunks/Messages-Ch6cboMV.js +11 -0
- package/dist/chunks/{Onboarding-D00lTweB.js → Onboarding-BrAJp0aL.js} +1 -1
- package/dist/chunks/{OverageCreditUpsell-B-Bf_-UX.js → OverageCreditUpsell-Ds1cB7RC.js} +1 -1
- package/dist/chunks/PluginSettings-CGqEzejq.js +17 -0
- package/dist/chunks/{PromptInputFooterSuggestions-MwS_cExV.js → PromptInputFooterSuggestions-egs9VvUs.js} +1 -1
- package/dist/chunks/{PromptInputHelpMenu-V2dEpzhC.js → PromptInputHelpMenu-SieM5NoY.js} +1 -1
- package/dist/chunks/QueryEngine-CZZMl3PB.js +1 -0
- package/dist/chunks/REPL-CG2N7E4Q.js +142 -0
- package/dist/chunks/REPL-DvA910N_.js +1 -0
- package/dist/chunks/{RemoteCallout-ChCjmgw1.js → RemoteCallout-Cs-ro8_i.js} +1 -1
- package/dist/chunks/RemoteSessionManager-B740Dp6m.js +2 -0
- package/dist/chunks/ResumeConversation-DzV2zmuX.js +1 -0
- package/dist/chunks/{SSETransport-h43pQVlJ.js → SSETransport-DtpMDekF.js} +3 -3
- package/dist/chunks/SearchExtraToolsTool-C4uO-Zx3.js +1 -0
- package/dist/chunks/Settings-XKw6FI_m.js +2 -0
- package/dist/chunks/{TeleportProgress-QtJrXSCX.js → TeleportProgress-rYaHIEfe.js} +1 -1
- package/dist/chunks/{TeleportRepoMismatchDialog-D-HVj-A6.js → TeleportRepoMismatchDialog-DY97YZMB.js} +1 -1
- package/dist/chunks/{TeleportResumeWrapper-C6sbzJsJ.js → TeleportResumeWrapper-jaQzyTCh.js} +1 -1
- package/dist/chunks/{ThemePicker-CqPCp5Hs.js → ThemePicker-BViWzLp3.js} +1 -1
- package/dist/chunks/{TrustDialog-CeVwxDlZ.js → TrustDialog-DGJ_BisZ.js} +1 -1
- package/dist/chunks/{ValidationErrorsList-Bl68E-2-.js → ValidationErrorsList-B8pRiGuy.js} +1 -1
- package/dist/chunks/{WelcomeV2-DNiXQ5ES.js → WelcomeV2-DqnbSdIu.js} +1 -1
- package/dist/chunks/{add-dir-V3xjklnJ.js → add-dir-C2Hu3oE4.js} +1 -1
- package/dist/chunks/{agentDisplay-BuiwcrQi.js → agentDisplay-XoDJhr03.js} +1 -1
- package/dist/chunks/agents-BIHTGDYh.js +103 -0
- package/dist/chunks/{agents-ZY6IaVE7.js → agents-C4QXeHIJ.js} +1 -1
- package/dist/chunks/allErrors-1896uQA1.js +1 -0
- package/dist/chunks/{ant-D66LZCap.js → ant-B6k6cBts.js} +1 -1
- package/dist/chunks/api-BsFW57_Q.js +1 -0
- package/dist/chunks/api-gqTA-D7n.js +1 -0
- package/dist/chunks/{assistant-CYF7ch7C.js → assistant-DJ9hd4uC.js} +1 -1
- package/dist/chunks/auth-8Vd3_U8t.js +1 -0
- package/dist/chunks/auth-BnSrKyJe.js +15 -0
- package/dist/chunks/auth-DRTjfnGy.js +1 -0
- package/dist/chunks/{autoMode-TysBQkU_.js → autoMode-BNukrVAB.js} +1 -1
- package/dist/chunks/{autonomy-k3QPea5z.js → autonomy-BEmI7WVW.js} +1 -1
- package/dist/chunks/{autonomy-CNEbT-t_.js → autonomy-DGcy5Rml.js} +7 -7
- package/dist/chunks/{autonomyPanel-DiztRblF.js → autonomyPanel-fhge09AG.js} +1 -1
- package/dist/chunks/backgroundHousekeeping-3i_d_WW5.js +1 -0
- package/dist/chunks/backgroundHousekeeping-BVMf_Tjn.js +17 -0
- package/dist/chunks/{branch-_NBgDfrK.js → branch-Bpe-gocq.js} +1 -1
- package/dist/chunks/{break-cache-BQfgkNAo.js → break-cache-C_p7Kmx2.js} +3 -3
- package/dist/chunks/{bridge-DpmFl8p8.js → bridge-D12Shbkj.js} +2 -2
- package/dist/chunks/{bridgeConfig-DMBOO3gW.js → bridgeConfig-BhxRF2vm.js} +1 -1
- package/dist/chunks/bridgeConfig-CqIQ_rvD.js +1 -0
- package/dist/chunks/bridgeEnabled-D0XC5kNh.js +1 -0
- package/dist/chunks/bridgeEnabled-SbB-6zdY.js +1 -0
- package/dist/chunks/bridgeMain-DHUpZFgL.js +68 -0
- package/dist/chunks/bridgeMain-DUbQjgCp.js +1 -0
- package/dist/chunks/{bridgeMessaging-N5zlzCCr.js → bridgeMessaging-DHc5dOhB.js} +1 -1
- package/dist/chunks/{btw-BFRje_Zi.js → btw-D9hMM5d2.js} +1 -1
- package/dist/chunks/caches-CWzT7e6Y.js +1 -0
- package/dist/chunks/{caches-CcfPJ4_A.js → caches-UeVVM3T0.js} +2 -2
- package/dist/chunks/{ccrClient-q2JCVCU2.js → ccrClient-Iza0L8Zw.js} +1 -1
- package/dist/chunks/{clear-CxY7W5Wt.js → clear-B4d38ssF.js} +1 -1
- package/dist/chunks/client-BzKQTXzF.js +1 -0
- package/dist/chunks/{color-DOWhfjnA.js → color-D8VOyoYl.js} +1 -1
- package/dist/chunks/commands-DDamMmo4.js +1 -0
- package/dist/chunks/commitAttribution-CgohL8vD.js +1 -0
- package/dist/chunks/{commitAttribution-CLbEIaRJ.js → commitAttribution-ChAgixdj.js} +2 -2
- package/dist/chunks/compact-IFHwxjZ9.js +2 -0
- package/dist/chunks/config-DY5-_kk_.js +1 -0
- package/dist/chunks/{config-DiT2Z8dY.js → config-DmomySWC.js} +1 -1
- package/dist/chunks/config-WxgxrQoP.js +1 -0
- package/dist/chunks/{context-B2OvKo2t.js → context-Cl6BJ2vm.js} +1 -1
- package/dist/chunks/{context-noninteractive-BuGxX3YL.js → context-noninteractive-9hELVC29.js} +2 -2
- package/dist/chunks/context-noninteractive-Beij5MfU.js +1 -0
- package/dist/chunks/conversation-BBB91hEw.js +1 -0
- package/dist/chunks/conversation-BWVTM40Y.js +1 -0
- package/dist/chunks/{createSSHSession-C-c7I5iJ.js → createSSHSession-BM-5pbv6.js} +1 -1
- package/dist/chunks/createSession-CoQtL5Rj.js +1 -0
- package/dist/chunks/{createSession-D_fIDqgc.js → createSession-Cvl1Q50F.js} +1 -1
- package/dist/chunks/crossProjectResume-BasMLl2n.js +40 -0
- package/dist/chunks/{datadog-Ed8emSFA.js → datadog-CpqEQbHa.js} +1 -1
- package/dist/chunks/{desktop-D_ofPlyi.js → desktop-B_L6T6jI.js} +1 -1
- package/dist/chunks/{diff-CUAgBDu1.js → diff-CVzOodeg.js} +1 -1
- package/dist/chunks/doctor-1L0TFuGw.js +1 -0
- package/dist/chunks/{entry-Bh0gPOAo.js → entry-DHVYCR26.js} +3 -3
- package/dist/chunks/envLessBridgeConfig-CN0_44-p.js +1 -0
- package/dist/chunks/{envLessBridgeConfig-DJHZAlU-.js → envLessBridgeConfig-Ck2-KMq0.js} +1 -1
- package/dist/chunks/{esm-B62dCLgf.js → esm-D5q6s4l8.js} +1 -1
- package/dist/chunks/exit-Bm1S_f3i.js +1 -0
- package/dist/chunks/extra-usage-UHAWtypK.js +1 -0
- package/dist/chunks/{extra-usage-core-B6ga8Rni.js → extra-usage-core-BFOolqoi.js} +1 -1
- package/dist/chunks/{extra-usage-noninteractive-Dc9AndId.js → extra-usage-noninteractive-cUGZy0en.js} +1 -1
- package/dist/chunks/{extra-usage-CjaHpu8y.js → extra-usage-zDHVtWKZ.js} +1 -1
- package/dist/chunks/extraUsage-Dq66zzqR.js +1 -0
- package/dist/chunks/extractMemories-BcaklA33.js +1 -0
- package/dist/chunks/fast-DALAHO3d.js +1 -0
- package/dist/chunks/{fast-CW_NsL0x.js → fast-MS7WZpD8.js} +1 -1
- package/dist/chunks/{feedback-BpRorTAC.js → feedback-Fw4m28ZC.js} +1 -1
- package/dist/chunks/firstPartyEventLogger-CS9jVz6D.js +1 -0
- package/dist/chunks/{firstPartyEventLogger-CuUiNdj8.js → firstPartyEventLogger-CoSUd0a1.js} +2 -2
- package/dist/chunks/{flushGate-BltVae97.js → flushGate-De-yppeo.js} +1 -1
- package/dist/chunks/{gemini-YyIxfveQ.js → gemini-BPziscyN.js} +1 -1
- package/dist/chunks/{generateRecap-tx4wLIkI.js → generateRecap-jGDLI_wU.js} +1 -1
- package/dist/chunks/{generateSessionName-BkDigIN8.js → generateSessionName-hDJ6HBJ1.js} +1 -1
- package/dist/chunks/{githubRepoPathMapping-C4umZ1oC.js → githubRepoPathMapping-qAoiyj6P.js} +1 -1
- package/dist/chunks/{goal-DZrD4puM.js → goal-CFx4eRkf.js} +3 -3
- package/dist/chunks/{grok-BZf7W_hL.js → grok-Byblph7F.js} +1 -1
- package/dist/chunks/{grove-CFBPplP6.js → grove-CpqjcGCb.js} +2 -2
- package/dist/chunks/{heapdump-DWc3Z2NO.js → heapdump-C4kPlqGt.js} +1 -1
- package/dist/chunks/{help-pap9jNUJ.js → help-B1h-faJ3.js} +1 -1
- package/dist/chunks/hooks-DPLIIpAD.js +1 -0
- package/dist/chunks/{hooks-Bmat0L6A.js → hooks-X6J03MnA.js} +2 -2
- package/dist/chunks/hostGuard-BHI6Q8Mt.js +1 -0
- package/dist/chunks/inboundAttachments-BekVc0W-.js +1 -0
- package/dist/chunks/{inboundAttachments-DkfNHtF9.js → inboundAttachments-CUJE3KaU.js} +1 -1
- package/dist/chunks/initReplBridge-JQ-afRx9.js +1 -0
- package/dist/chunks/{install-D4jmHjmk.js → install-D5YORIJL.js} +1 -1
- package/dist/chunks/{instrumentation-Nqgm1SMw.js → instrumentation-Bw3CxPQf.js} +4 -4
- package/dist/chunks/{job-CT9bcgPb.js → job-DOWtcltx.js} +1 -1
- package/dist/chunks/keybindings-BLw5J-Zj.js +2 -0
- package/dist/chunks/{language-BA5WprZv.js → language-C6Fq-XOZ.js} +1 -1
- package/dist/chunks/language-Cqw5gYJR.js +1 -0
- package/dist/chunks/launchAgentsPlatform-jWWf-Lk9.js +1 -0
- package/dist/chunks/{launchLocalMemory-CRMqifzn.js → launchLocalMemory-kHeD0I0y.js} +2 -2
- package/dist/chunks/{launchLocalVault-DlKX_oDE.js → launchLocalVault-DLqkOjmb.js} +3 -3
- package/dist/chunks/launchMemoryStores-Ct7AVXrO.js +1 -0
- package/dist/chunks/{launchOnboarding-DTdUA_wE.js → launchOnboarding-Cc6WwPX9.js} +1 -1
- package/dist/chunks/launchSchedule-ZyvuvjgU.js +1 -0
- package/dist/chunks/launchSkillStore-BejQnLog.js +1 -0
- package/dist/chunks/{launchTeleport-CXFRPVMR.js → launchTeleport-8CuYUfIR.js} +3 -3
- package/dist/chunks/launchVault-DIvIOuPh.js +1 -0
- package/dist/chunks/{loadAgentsDir-BURvZNN6.js → loadAgentsDir-D206qwP3.js} +632 -632
- package/dist/chunks/loadAgentsDir-TZjwTqdr.js +1 -0
- package/dist/chunks/loadPluginHooks-Ddhsyn0_.js +1 -0
- package/dist/chunks/{localSearch-D2Rs8wQP.js → localSearch-CzrbOklu.js} +1 -1
- package/dist/chunks/localSearch-DrOAL6f4.js +1 -0
- package/dist/chunks/{logoV2Utils-DN9nzdX-.js → logoV2Utils-8M56V7oN.js} +1 -1
- package/dist/chunks/{magicDocs-DIeTcwAA.js → magicDocs-DWjL2k7P.js} +3 -3
- package/dist/chunks/{main-CI54PZrG.js → main-BohPzJFF.js} +86 -86
- package/dist/chunks/{mappers-Q_Z3Kjo-.js → mappers-BDMZFgKx.js} +1 -1
- package/dist/chunks/mcp-Bt1ITh-Z.js +1 -0
- package/dist/chunks/{mcp-RvwPC7FB.js → mcp-CwJ-AIpt.js} +4 -4
- package/dist/chunks/mcp-W0LFoyFR.js +2 -0
- package/dist/chunks/memory-3wV7m7UU.js +1 -0
- package/dist/chunks/{mode-Jl_Boaym.js → mode-CUkHFkju.js} +2 -2
- package/dist/chunks/model-BY3auM2c.js +1 -0
- package/dist/chunks/model-CKkOnnnx.js +1 -0
- package/dist/chunks/model-DRXcJyU9.js +1 -0
- package/dist/chunks/{nativeInstaller-8arnRiUO.js → nativeInstaller-CA5d6_G7.js} +1 -1
- package/dist/chunks/{onChangeAppState-DBantDJ6.js → onChangeAppState-DBmy2Ow_.js} +1 -1
- package/dist/chunks/openai-Cbomn0Ws.js +10 -0
- package/dist/chunks/{overageCreditGrant-CN_sVURL.js → overageCreditGrant-DsUrmeBh.js} +1 -1
- package/dist/chunks/{panel-CrTPqXCv.js → panel-BSZGX6jN.js} +1 -1
- package/dist/chunks/{panelCall-CPKC6VR5.js → panelCall-BsVoL1uF.js} +1 -1
- package/dist/chunks/{partition-CW0BJ881.js → partition-BAakXjvj.js} +1 -1
- package/dist/chunks/{passes-DOm9ukdK.js → passes-CLRt7Cvm.js} +1 -1
- package/dist/chunks/permissions-BVSFuwNP.js +3 -0
- package/dist/chunks/{pidLock-C69HNTTb.js → pidLock-D5rUnDB-.js} +2 -2
- package/dist/chunks/{plan-B0rEs32a.js → plan-SYZ4DXR8.js} +1 -1
- package/dist/chunks/{plugin-BSEMgcGu.js → plugin-Bfjzhmrk.js} +1 -1
- package/dist/chunks/{pluginAutoupdate-CTByPD8J.js → pluginAutoupdate-reO2PgtQ.js} +1 -1
- package/dist/chunks/{pluginBlocklist-mogKaK0p.js → pluginBlocklist-C3H2afWG.js} +1 -1
- package/dist/chunks/pluginCliCommands-lqdxdkQp.js +1 -0
- package/dist/chunks/{pluginFlagging-mHNff1t9.js → pluginFlagging-D9HKAGBC.js} +1 -1
- package/dist/chunks/{pluginOperations-JEedVzfS.js → pluginOperations-EN3EKLux.js} +2 -2
- package/dist/chunks/{pluginStartupCheck-RscVZDi4.js → pluginStartupCheck-BY73BMT2.js} +1 -1
- package/dist/chunks/pluginStartupCheck-CwWOlveD.js +1 -0
- package/dist/chunks/plugins-Dn6ceWrT.js +4 -0
- package/dist/chunks/policyLimits-CkTI5KEt.js +1 -0
- package/dist/chunks/{poor-DekfGNT7.js → poor-j-y-bv8o.js} +1 -1
- package/dist/chunks/{poorMode-CtcqaiwD.js → poorMode-DhzFKpPl.js} +1 -1
- package/dist/chunks/poorMode-V11s-3cf.js +1 -0
- package/dist/chunks/print-Db_VXmfO.js +23 -0
- package/dist/chunks/{privacy-settings-CwJ1H8Ua.js → privacy-settings-DHMJREbb.js} +1 -1
- package/dist/chunks/processBashCommand-BcM_fhV9.js +1 -0
- package/dist/chunks/processSlashCommand-DEVo3GPX.js +5 -0
- package/dist/chunks/{prompt-DNDgGM9q.js → prompt-BNHtszmZ.js} +1 -1
- package/dist/chunks/prompt-CrX31AGm.js +1 -0
- package/dist/chunks/prompt-IAvMxKDl.js +1 -0
- package/dist/chunks/{promptEditor-DMJyosKj.js → promptEditor-DeMrXUir.js} +2 -2
- package/dist/chunks/{protocolHandler-z2zxAtB1.js → protocolHandler-BHxBy84Z.js} +1 -1
- package/dist/chunks/rate-limit-options-DIudL9fb.js +1 -0
- package/dist/chunks/{rcDebugLog-DoL1FpGJ.js → rcDebugLog-CUy1_F23.js} +1 -1
- package/dist/chunks/reconciler-BXpPyfSY.js +4 -0
- package/dist/chunks/{referral-UKJv23_5.js → referral-CUaIo_vT.js} +1 -1
- package/dist/chunks/{refresh-ul_i5R1a.js → refresh-CuaVBIQ0.js} +1 -1
- package/dist/chunks/{registerProtocol-CukLQuxJ.js → registerProtocol-B7Fzdofu.js} +1 -1
- package/dist/chunks/{release-notes-CGv_6MMt.js → release-notes-fbfv2DC0.js} +1 -1
- package/dist/chunks/{releaseNotes-BKZNuDLD.js → releaseNotes-CxAHFLPl.js} +2 -2
- package/dist/chunks/{reload-plugins-2W11dpLQ.js → reload-plugins-B9IT9CFA.js} +1 -1
- package/dist/chunks/{remote-env-D9xsoBfx.js → remote-env-BOklGlll.js} +1 -1
- package/dist/chunks/{remoteBridgeCore-asY9JAXU.js → remoteBridgeCore-j0bG1zjv.js} +1 -1
- package/dist/chunks/{remoteManagedSettings-Bxo3bv1U.js → remoteManagedSettings-Cq994lyc.js} +1 -1
- package/dist/chunks/{rename-CHsHMWpO.js → rename-Iev7wQsI.js} +1 -1
- package/dist/chunks/{resume-NduOaghx.js → resume-y7MCTZHJ.js} +2 -2
- package/dist/chunks/{runtimeObserver-Bo80nWQf.js → runtimeObserver-BZcJ1FbH.js} +1 -1
- package/dist/chunks/{runtimeObserver-BXbjibFk.js → runtimeObserver-CyzLASla.js} +3 -3
- package/dist/chunks/sandbox-adapter-Cu1FYrkh.js +1 -0
- package/dist/chunks/{sandbox-toggle-C-WCDRN4.js → sandbox-toggle-CWpBO228.js} +1 -1
- package/dist/chunks/searchExtraTools-BUOUds7p.js +1 -0
- package/dist/chunks/{session-pDd13-wE.js → session-DL4cA_8l.js} +2 -2
- package/dist/chunks/{sessionDiscovery-CSUnpsCy.js → sessionDiscovery-DAfNKqp1.js} +1 -1
- package/dist/chunks/sessionFileAccessHooks-2cgIIxPk.js +1 -0
- package/dist/chunks/sessionMemory-BS8_TbKj.js +1 -0
- package/dist/chunks/sessionMemory-D5fSHXvZ.js +1 -0
- package/dist/chunks/sessionMemoryUtils-BWUztNh6.js +1 -0
- package/dist/chunks/sessionObserver-ChfQtK2m.js +1 -0
- package/dist/chunks/{sessionObserver-Ur7PqKl_.js → sessionObserver-ShbCwJ8x.js} +1 -1
- package/dist/chunks/sessionStorage-Cf5wmnyB.js +1 -0
- package/dist/chunks/{sessionTitle-pWMaI79N.js → sessionTitle-coed9IuJ.js} +1 -1
- package/dist/chunks/{sessionTracing-CCPRzOvy.js → sessionTracing-D9rUyiq0.js} +1 -1
- package/dist/chunks/{settings-DfWP5y6X.js → settings-BovzmwMP.js} +2 -2
- package/dist/chunks/settingsSync-PqU9XGJq.js +1 -0
- package/dist/chunks/setup-B_FOvNpp.js +3 -0
- package/dist/chunks/{shadowedRuleDetection-Chi3afMR.js → shadowedRuleDetection-D1wsAdpp.js} +1 -1
- package/dist/chunks/{sideQuestion-D03MXdE2.js → sideQuestion-wSi38p81.js} +1 -1
- package/dist/chunks/sinks-BpcRrN_T.js +1 -0
- package/dist/chunks/{sinks-B4_pw0Gb.js → sinks-C_Dl1p4K.js} +2 -2
- package/dist/chunks/{skill-learning-7ZQF5JvA.js → skill-learning-B5tmc7EX.js} +1 -1
- package/dist/chunks/skillChangeDetector-DNqohXxz.js +1 -0
- package/dist/chunks/{skillGapStore-BND2Lq0Z.js → skillGapStore-D-kQKVDZ.js} +1 -1
- package/dist/chunks/{skillGapStore-z3LP64O-.js → skillGapStore-Df5BWAk5.js} +2 -2
- package/dist/chunks/{skillGenerator-DaNb-yKH.js → skillGenerator-DbcdpAkw.js} +2 -2
- package/dist/chunks/skillLearning-C5cXZE6_.js +1 -0
- package/dist/chunks/{skillLearning-rMX1bSBa.js → skillLearning-ClRiDcJH.js} +1 -1
- package/dist/chunks/{skillPanel-q7GPSQ6_.js → skillPanel-LBd4E-MM.js} +3 -3
- package/dist/chunks/{skillSearchPanel-oj8gy1ZL.js → skillSearchPanel-CErRnUwo.js} +3 -3
- package/dist/chunks/{skills-QqbeFP0s.js → skills-CBKhfg_a.js} +1 -1
- package/dist/chunks/{stats-DmFubHpI.js → stats-BY4dskVg.js} +1 -1
- package/dist/chunks/{status-DW3Z_7xa.js → status-BnJIXtKl.js} +2 -2
- package/dist/chunks/{status-BEIsLmfj.js → status-DU-B4SMW.js} +1 -1
- package/dist/chunks/{statusNoticeHelpers-CaHS8xig.js → statusNoticeHelpers-CzTuGNuC.js} +1 -1
- package/dist/chunks/{tag-CRg93Die.js → tag-B-wVW9Aj.js} +2 -2
- package/dist/chunks/{tasks-BEohK1ij.js → tasks-CBVL005y.js} +1 -1
- package/dist/chunks/teleport-dtqQXM4x.js +1 -0
- package/dist/chunks/{templateJobs-DYP1fjYU.js → templateJobs-D6998LcG.js} +1 -1
- package/dist/chunks/{terminalSetup-RDKg8dVa.js → terminalSetup-0SBdyKF5.js} +1 -1
- package/dist/chunks/{terminalSetup-BNs9nLbT.js → terminalSetup-CuV-qU6v.js} +1 -1
- package/dist/chunks/{theme-kNL4kl_3.js → theme-p0AooruD.js} +1 -1
- package/dist/chunks/thinkback-Catprqs_.js +1 -0
- package/dist/chunks/thinkback-DI2NpvG-.js +1 -0
- package/dist/chunks/{thinkback-play-BpWMqbgJ.js → thinkback-play-CqrIRx2o.js} +1 -1
- package/dist/chunks/{toolEventObserver-C98uraqD.js → toolEventObserver-DTccwC3c.js} +1 -1
- package/dist/chunks/{toolEventObserver-ar5NDa0M.js → toolEventObserver-DlH73w-S.js} +1 -1
- package/dist/chunks/toolPool-B64V-jmK.js +1 -0
- package/dist/chunks/{trustedDevice-BBKUhCCL.js → trustedDevice-BTYoQCkC.js} +1 -1
- package/dist/chunks/trustedDevice-CiwjT_Y6.js +1 -0
- package/dist/chunks/types-Bh9S_JG5.js +3 -0
- package/dist/chunks/types-DHkZVzJe.js +1 -0
- package/dist/chunks/{ultrareviewCommand-yXlFsMnv.js → ultrareviewCommand-BDFUS3hf.js} +2 -2
- package/dist/chunks/undercover-XYapZ_SS.js +1 -0
- package/dist/chunks/{undercover-BTIRVF1t.js → undercover-vuTpCnQJ.js} +2 -2
- package/dist/chunks/{updateCCB-B2xAJ4Nr.js → updateCCB-DFL5Wt_I.js} +1 -1
- package/dist/chunks/upgrade-D5qwcaWQ.js +1 -0
- package/dist/chunks/upgrade-DIg3j929.js +1 -0
- package/dist/chunks/{upload-BWVIHmMB.js → upload-B_yADHX9.js} +1 -1
- package/dist/chunks/usage-C0SnnC-i.js +1 -0
- package/dist/chunks/usage-CYJKE8N6.js +1 -0
- package/dist/chunks/{useExitOnCtrlCDWithKeybindings-CV4GZ-sq.js → useExitOnCtrlCDWithKeybindings-DKIqRraH.js} +1 -1
- package/dist/chunks/useMainLoopModel-XetDUXd-.js +1 -0
- package/dist/chunks/useManagePlugins-B2KhKiu5.js +1 -0
- package/dist/chunks/{useMergedTools-CRLWSGDl.js → useMergedTools-CKvwz_Zt.js} +1 -1
- package/dist/chunks/{useSearchInput-BzGq4t7t.js → useSearchInput-D1Vr2Js1.js} +1 -1
- package/dist/chunks/useSettingsErrors-B7BXHchG.js +1 -0
- package/dist/chunks/{util-BnReK81E.js → util-BaDs-wL5.js} +1 -1
- package/dist/chunks/validatePlugin-DtiYlXby.js +1 -0
- package/dist/chunks/{vim-C0KTnJJs.js → vim-C-icQDz1.js} +1 -1
- package/dist/chunks/{workerRegistry-CUXbNyL9.js → workerRegistry-ChqPPIaO.js} +1 -1
- package/dist/chunks/worktree-DAn8ooa1.js +1 -0
- package/dist/cli.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/ApproveApiKey-LPrZMlgU.js +0 -1
- package/dist/chunks/BackgroundTasksDialog-D_UHm7xo.js +0 -2
- package/dist/chunks/ClaudeMdExternalIncludesDialog--w2zWWEn.js +0 -1
- package/dist/chunks/ConsoleOAuthFlow-BXdC6j3_.js +0 -1
- package/dist/chunks/Doctor-BuiYwjAS.js +0 -1
- package/dist/chunks/Doctor-DKlHJBXq.js +0 -3
- package/dist/chunks/ExitFlow-rExuBL3w.js +0 -2
- package/dist/chunks/Grove-CD769Wvw.js +0 -11
- package/dist/chunks/Grove-ENfM8hC6.js +0 -1
- package/dist/chunks/MCPConnectionManager-CaBvO7NB.js +0 -1
- package/dist/chunks/MessageSelector-DOB1S2-O.js +0 -3
- package/dist/chunks/Messages-Clihwd2F.js +0 -11
- package/dist/chunks/PluginSettings-DUxj_oAg.js +0 -17
- package/dist/chunks/QueryEngine-BLcPQYq_.js +0 -1
- package/dist/chunks/REPL-B_E07dnf.js +0 -142
- package/dist/chunks/REPL-BhURgntS.js +0 -1
- package/dist/chunks/RemoteSessionManager-B43isWQs.js +0 -2
- package/dist/chunks/ResumeConversation-DaQ9n8_C.js +0 -1
- package/dist/chunks/SearchExtraToolsTool-DSq7beKs.js +0 -1
- package/dist/chunks/Settings-CNsaWv8g.js +0 -2
- package/dist/chunks/agents-D7um1IXM.js +0 -103
- package/dist/chunks/allErrors-CHVdQ3fT.js +0 -1
- package/dist/chunks/api-C-rOQY-l.js +0 -1
- package/dist/chunks/api-Dmn7DUgU.js +0 -1
- package/dist/chunks/auth-C4Rvit2q.js +0 -1
- package/dist/chunks/auth-Cj7EX1eG.js +0 -1
- package/dist/chunks/auth-DAxGNCIR.js +0 -15
- package/dist/chunks/backgroundHousekeeping-C9m4tiFi.js +0 -17
- package/dist/chunks/backgroundHousekeeping-DQjzXBe0.js +0 -1
- package/dist/chunks/bridgeConfig-DsI5d0s7.js +0 -1
- package/dist/chunks/bridgeEnabled-DZzlF2d8.js +0 -1
- package/dist/chunks/bridgeEnabled-FjPuA7zx.js +0 -1
- package/dist/chunks/bridgeMain-BppY0KW3.js +0 -68
- package/dist/chunks/bridgeMain-BrY4tkF6.js +0 -1
- package/dist/chunks/caches-BBLH8G1I.js +0 -1
- package/dist/chunks/client-CtVu3BLD.js +0 -1
- package/dist/chunks/commands-BWw1sQeH.js +0 -1
- package/dist/chunks/commitAttribution-DIT_s0vY.js +0 -1
- package/dist/chunks/compact-CaOnQVkH.js +0 -2
- package/dist/chunks/config-DmPGzNmi.js +0 -1
- package/dist/chunks/config-HHTwEsWp.js +0 -1
- package/dist/chunks/context-noninteractive-BilCSCV1.js +0 -1
- package/dist/chunks/conversation-BWXf3un9.js +0 -1
- package/dist/chunks/conversation-awh8AwwL.js +0 -1
- package/dist/chunks/createSession-Hvpx3Le7.js +0 -1
- package/dist/chunks/crossProjectResume-_XjvSXA3.js +0 -40
- package/dist/chunks/doctor-CkdQ7Fv7.js +0 -1
- package/dist/chunks/effort-DCgooYMY.js +0 -9
- package/dist/chunks/envLessBridgeConfig-sxodu0xO.js +0 -1
- package/dist/chunks/exit-CFJR3NfE.js +0 -1
- package/dist/chunks/extra-usage-D1Y-3OWQ.js +0 -1
- package/dist/chunks/extraUsage-2DwLEr26.js +0 -1
- package/dist/chunks/extractMemories-C3qrwpu2.js +0 -1
- package/dist/chunks/fast-D3CPmUX4.js +0 -1
- package/dist/chunks/firstPartyEventLogger-DPUQnc6J.js +0 -1
- package/dist/chunks/hooks-cCAzfabs.js +0 -1
- package/dist/chunks/hostGuard-C5xydXZI.js +0 -1
- package/dist/chunks/inboundAttachments-DZgSqDwY.js +0 -1
- package/dist/chunks/initReplBridge-myzllvlk.js +0 -1
- package/dist/chunks/keybindings-DETOn3qJ.js +0 -2
- package/dist/chunks/language-BbaOTWm3.js +0 -1
- package/dist/chunks/launchAgentsPlatform-CuRQgd2Q.js +0 -1
- package/dist/chunks/launchMemoryStores-CN0ecWpP.js +0 -1
- package/dist/chunks/launchSchedule-psiSLmTA.js +0 -1
- package/dist/chunks/launchSkillStore-CQQ00Ads.js +0 -1
- package/dist/chunks/launchVault-Dn6jq0Rc.js +0 -1
- package/dist/chunks/loadAgentsDir-Db9UTm45.js +0 -1
- package/dist/chunks/loadPluginHooks-C9A9oS-w.js +0 -1
- package/dist/chunks/localSearch-hBh1ATr2.js +0 -1
- package/dist/chunks/mcp-CtbhGaLC.js +0 -2
- package/dist/chunks/mcp-DMacvhqZ.js +0 -1
- package/dist/chunks/memory-BPN8gW7n.js +0 -1
- package/dist/chunks/model-BIVmcl_N.js +0 -1
- package/dist/chunks/model-CWBwPvTH.js +0 -1
- package/dist/chunks/model-DlVpqR0P.js +0 -1
- package/dist/chunks/openai-yin1iDG8.js +0 -10
- package/dist/chunks/permissions-CxDJ__l6.js +0 -3
- package/dist/chunks/pluginCliCommands-DQQ7C7kk.js +0 -1
- package/dist/chunks/pluginStartupCheck-D7ts2V3p.js +0 -1
- package/dist/chunks/plugins-Cr03lISA.js +0 -4
- package/dist/chunks/policyLimits-DWtLyJ4n.js +0 -1
- package/dist/chunks/poorMode-AE4WNYZo.js +0 -1
- package/dist/chunks/print-CZUmAzmt.js +0 -23
- package/dist/chunks/processBashCommand-aKNneP2u.js +0 -1
- package/dist/chunks/processSlashCommand-BcPnWNxZ.js +0 -5
- package/dist/chunks/prompt-CIyhCdkE.js +0 -1
- package/dist/chunks/prompt-DRhjinu2.js +0 -1
- package/dist/chunks/rate-limit-options--Y3oF1g0.js +0 -1
- package/dist/chunks/reconciler-CJcSh6xo.js +0 -4
- package/dist/chunks/sandbox-adapter-DDfVl_2V.js +0 -1
- package/dist/chunks/searchExtraTools-BHWzsbNO.js +0 -1
- package/dist/chunks/sessionFileAccessHooks-BZvxeufx.js +0 -1
- package/dist/chunks/sessionMemory-CAmpw2yb.js +0 -1
- package/dist/chunks/sessionMemory-DT0IkiA1.js +0 -1
- package/dist/chunks/sessionMemoryUtils-B4kGNH4j.js +0 -1
- package/dist/chunks/sessionObserver-oIkwTidC.js +0 -1
- package/dist/chunks/sessionStorage-DqARUj0K.js +0 -1
- package/dist/chunks/settingsSync-D_4P3Esd.js +0 -1
- package/dist/chunks/setup-JHvhWKh9.js +0 -3
- package/dist/chunks/sinks-Cro1Y8C2.js +0 -1
- package/dist/chunks/skillChangeDetector-uCaYrerZ.js +0 -1
- package/dist/chunks/skillLearning-GZxYPlyl.js +0 -1
- package/dist/chunks/teleport-4Srg5vcP.js +0 -1
- package/dist/chunks/thinkback-gV-sKkMM.js +0 -1
- package/dist/chunks/thinkback-hc5eJ9ul.js +0 -1
- package/dist/chunks/toolPool-CNYKDRq5.js +0 -1
- package/dist/chunks/trustedDevice-0dehm9qz.js +0 -1
- package/dist/chunks/types-BUyOCzUt.js +0 -1
- package/dist/chunks/types-Czs-_G1S.js +0 -3
- package/dist/chunks/undercover-CG_269xD.js +0 -1
- package/dist/chunks/upgrade-J7lKLkD2.js +0 -1
- package/dist/chunks/upgrade-yNl7EO4e.js +0 -1
- package/dist/chunks/usage-B2PbCUMi.js +0 -1
- package/dist/chunks/usage-Ck8Cu45g.js +0 -1
- package/dist/chunks/useMainLoopModel-CO4yBjRM.js +0 -1
- package/dist/chunks/useManagePlugins-BzFKIDrD.js +0 -1
- package/dist/chunks/useSettingsErrors-CSemUjj1.js +0 -1
- package/dist/chunks/validatePlugin-D6sPqea1.js +0 -1
- package/dist/chunks/worktree-89ttIVxH.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./figures-5ThXQEtq.js";import{I as r,P as i,fi as a,s as o,t as s}from"./src-CDCSSo0U2.js";import{t as c}from"./jsx-runtime-Bb4Xn-E0.js";import{Ao as l,GE as u,WE as d,al as f,rl as p,zo as m}from"./loadAgentsDir-BURvZNN6.js";import{dn as h,un as g}from"./settings-DfWP5y6X.js";import{f as _,l as v}from"./file-DcZWPH2V.js";import{b as y,y as b}from"./startupProfiler-xa3NmN7Z.js";import{$t as x,an as S,bn as C,gn as w,vn as T,yn as ee}from"./prompt-DNDgGM9q.js";import{n as E,t as D}from"./staticRender-BIxpgNUq.js";function O(e){let t=[];return k(e,t),A(e,t),M(e,t),N(e,t),P(e,t),t.sort((e,t)=>e.severity===t.severity?(t.savingsTokens??0)-(e.savingsTokens??0):e.severity===`warning`?-1:1),t}function k(e,t){e.percentage>=R&&t.push({severity:`warning`,title:`Context is ${e.percentage}% full`,detail:e.isAutoCompactEnabled?`Autocompact will trigger soon, which discards older messages. Use /compact now to control what gets kept.`:`Autocompact is disabled. Use /compact to free space, or enable autocompact in /config.`})}function A(e,t){if(e.messageBreakdown)for(let n of e.messageBreakdown.toolCallsByType){let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100;if(i<F||r<I)continue;let a=j(n.name,r,i);a&&t.push(a)}}function j(e,t,n){let r=b(t);switch(e){case ee:return{severity:`warning`,title:`Bash results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Pipe output through head, tail, or grep to reduce result size. Avoid cat on large files — use Read with offset/limit instead.`,savingsTokens:Math.floor(t*.5)};case x:return{severity:`info`,title:`Read results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Use offset and limit parameters to read only the sections you need. Avoid re-reading entire files when you only need a few lines.`,savingsTokens:Math.floor(t*.3)};case w:return{severity:`info`,title:`Grep results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Add more specific patterns or use the glob or type parameter to narrow file types. Consider Glob for file discovery instead of Grep.`,savingsTokens:Math.floor(t*.3)};default:return n>=20?{severity:`info`,title:`${e} using ${r} tokens (${n.toFixed(0)}%)`,detail:`This tool is consuming a significant portion of context.`,savingsTokens:Math.floor(t*.2)}:null}}function M(e,t){if(!e.messageBreakdown)return;let n=e.messageBreakdown.toolCallsByType.find(e=>e.name===x);if(!n)return;let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100,a=n.resultTokens/e.rawMaxTokens*100;i>=F&&r>=I||a>=L&&n.resultTokens>=I&&t.push({severity:`info`,title:`File reads using ${b(n.resultTokens)} tokens (${a.toFixed(0)}%)`,detail:`If you are re-reading files, consider referencing earlier reads. Use offset/limit for large files.`,savingsTokens:Math.floor(n.resultTokens*.3)})}function N(e,t){let n=e.memoryFiles.reduce((e,t)=>e+t.tokens,0),r=n/e.rawMaxTokens*100;if(r>=z&&n>=B){let i=[...e.memoryFiles].sort((e,t)=>t.tokens-e.tokens).slice(0,3).map(e=>`${v(e.path)} (${b(e.tokens)})`).join(`, `);t.push({severity:`info`,title:`Memory files using ${b(n)} tokens (${r.toFixed(0)}%)`,detail:`Largest: ${i}. Use /memory to review and prune stale entries.`,savingsTokens:Math.floor(n*.3)})}}function P(e,t){!e.isAutoCompactEnabled&&e.percentage>=50&&e.percentage<R&&t.push({severity:`info`,title:`Autocompact is disabled`,detail:`Without autocompact, you will hit context limits and lose the conversation. Enable it in /config or use /compact manually.`})}var F,I,L,R,z,B,V=e((()=>{C(),S(),T(),_(),y(),F=15,I=1e4,L=5,R=80,z=5,B=5e3}));function H({suggestions:e}){return e.length===0?null:(0,U.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,U.jsx)(i,{bold:!0,children:`Suggestions`}),e.map((e,t)=>(0,U.jsxs)(r,{flexDirection:`column`,marginTop:t===0?0:1,children:[(0,U.jsxs)(r,{children:[(0,U.jsx)(o,{status:e.severity,withSpace:!0}),(0,U.jsx)(i,{bold:!0,children:e.title}),e.savingsTokens?(0,U.jsxs)(i,{dimColor:!0,children:[` `,n.arrowRight,` save ~`,b(e.savingsTokens)]}):null]}),(0,U.jsx)(r,{marginLeft:2,children:(0,U.jsx)(i,{dimColor:!0,children:e.detail})})]},t))]})}var U,W=e((()=>{t(),a(),s(),y(),U=c()}));function G(){return null}function K(e){let t=new Map;for(let n of e){let e=g(n.source),r=t.get(e)||[];r.push(n),t.set(e,r)}for(let[e,n]of t.entries())t.set(e,n.sort((e,t)=>t.tokens-e.tokens));let n=new Map;for(let e of X){let r=t.get(e);r&&n.set(e,r)}return n}function q({data:e}){let{categories:t,totalTokens:n,rawMaxTokens:a,percentage:o,gridRows:s,model:c,memoryFiles:l,mcpTools:u,deferredBuiltinTools:d=[],systemTools:f,systemPromptSections:p,agents:m,skills:h,messageBreakdown:g,cacheHitRate:_,cacheThreshold:y}=e,x=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==Y&&!e.isDeferred),S=t.some(e=>e.isDeferred&&e.name.includes(`MCP`)),C=d.length>0,w=t.find(e=>e.name===Y);return(0,J.jsxs)(r,{flexDirection:`column`,paddingLeft:1,children:[(0,J.jsx)(i,{bold:!0,children:`Context Usage`}),(0,J.jsxs)(r,{flexDirection:`row`,gap:2,children:[(0,J.jsx)(r,{flexDirection:`column`,flexShrink:0,children:s.map((e,t)=>(0,J.jsx)(r,{flexDirection:`row`,marginLeft:-1,children:e.map((e,t)=>e.categoryName===`Free space`?(0,J.jsx)(i,{dimColor:!0,children:`⛶ `},t):e.categoryName===Y?(0,J.jsx)(i,{color:e.color,children:`⛝ `},t):(0,J.jsx)(i,{color:e.color,children:e.squareFullness>=.7?`⛁ `:`⛀ `},t))},t))}),(0,J.jsxs)(r,{flexDirection:`column`,gap:0,flexShrink:0,children:[(0,J.jsxs)(i,{dimColor:!0,children:[c,` · `,b(n),`/`,b(a),` tokens (`,o,`%)`]}),(0,J.jsx)(G,{}),_!==void 0&&y!==void 0&&(0,J.jsxs)(i,{color:_<y?`warning`:void 0,children:[`Cache hit rate: `,_.toFixed(0),`%`,_<y?` (below ${y}% threshold)`:``]}),(0,J.jsx)(i,{children:` `}),(0,J.jsx)(i,{dimColor:!0,italic:!0,children:`Estimated usage by category`}),x.map((e,t)=>{let n=b(e.tokens),o=e.isDeferred?`N/A`:`${(e.tokens/a*100).toFixed(1)}%`,s=e.name===Y,c=e.name,l=e.isDeferred?` `:s?`⛝`:`⛁`;return(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{color:e.color,children:l}),(0,J.jsxs)(i,{children:[` `,c,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[n,` tokens (`,o,`)`]})]},t)}),(t.find(e=>e.name===`Free space`)?.tokens??0)>0&&(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{dimColor:!0,children:`⛶`}),(0,J.jsx)(i,{children:` Free space: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(t.find(e=>e.name===`Free space`)?.tokens||0),` (`,((t.find(e=>e.name===`Free space`)?.tokens||0)/a*100).toFixed(1),`%)`]})]}),w&&w.tokens>0&&(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{color:w.color,children:`⛝`}),(0,J.jsxs)(i,{dimColor:!0,children:[` `,w.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(w.tokens),` tokens (`,(w.tokens/a*100).toFixed(1),`%)`]})]})]})]}),(0,J.jsxs)(r,{flexDirection:`column`,marginLeft:-1,children:[u.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`MCP tools`}),(0,J.jsxs)(i,{dimColor:!0,children:[` · /mcp`,S?` (loaded on-demand)`:``]})]}),u.some(e=>e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Loaded`}),u.filter(e=>e.isLoaded).map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),S&&u.some(e=>!e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Available`}),u.filter(e=>!e.isLoaded).map((e,t)=>(0,J.jsx)(r,{children:(0,J.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]}),!S&&u.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),(f&&f.length>0||C)&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] System tools`}),C&&(0,J.jsx)(i,{dimColor:!0,children:` (some loaded on-demand)`})]}),(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Loaded`}),f?.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},`sys-${t}`)),d.filter(e=>e.isLoaded).map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},`def-${t}`))]}),C&&d.some(e=>!e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Available`}),d.filter(e=>!e.isLoaded).map((e,t)=>(0,J.jsx)(r,{children:(0,J.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]})]}),p&&p.length>0&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] System prompt sections`}),p.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),m.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Custom agents`}),(0,J.jsx)(i,{dimColor:!0,children:` · /agents`})]}),Array.from(K(m).entries()).map(([e,t])=>(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.agentType,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]},e))]}),l.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Memory files`}),(0,J.jsx)(i,{dimColor:!0,children:` · /memory`})]}),l.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,v(e.path),`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),h&&h.tokens>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Skills`}),(0,J.jsx)(i,{dimColor:!0,children:` · /skills`})]}),Array.from(K(h.skillFrontmatter).entries()).map(([e,t])=>(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]},e))]}),g&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Message breakdown`}),(0,J.jsxs)(r,{flexDirection:`column`,marginLeft:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Tool calls: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.toolCallTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Tool results: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.toolResultTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Attachments: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.attachmentTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Assistant messages (non-tool): `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.assistantMessageTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`User messages (non-tool-result): `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.userMessageTokens),` tokens`]})]})]}),g.toolCallsByType.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Top tools`}),g.toolCallsByType.slice(0,5).map((e,t)=>(0,J.jsxs)(r,{marginLeft:1,children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[`calls `,b(e.callTokens),`, results `,b(e.resultTokens)]})]},t))]}),g.attachmentsByType.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Top attachments`}),g.attachmentsByType.slice(0,5).map((e,t)=>(0,J.jsxs)(r,{marginLeft:1,children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]})]})]}),(0,J.jsx)(H,{suggestions:O(e)})]})}var J,Y,X,Z=e((()=>{a(),s(),V(),_(),y(),h(),W(),J=c(),Y=`Autocompact buffer`,X=[`Project`,`User`,`Managed`,`Plugin`,`Built-in`]}));function Q(e){return l(e)}async function te(e,t){let{messages:n,getAppState:r,options:{mainLoopModel:i,tools:a}}=t,o=Q(n),{messages:s}=await u(o),c=process.stdout.columns||80,l=r();return e(await E((0,$.jsx)(q,{data:await p(s,i,async()=>l.toolPermissionContext,a,l.agentDefinitions,c,t,void 0,o)}))),null}var $;e((()=>{a(),Z(),d(),f(),m(),D(),$=c()}))();export{te as call};
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./figures-5ThXQEtq.js";import{I as r,P as i,fi as a,s as o,t as s}from"./src-CDCSSo0U2.js";import{t as c}from"./jsx-runtime-Bb4Xn-E0.js";import{Ao as l,KE as u,al as d,qE as f,rl as p,zo as m}from"./loadAgentsDir-D206qwP3.js";import{dn as h,un as g}from"./settings-BovzmwMP.js";import{f as _,l as v}from"./file-DcZWPH2V.js";import{b as y,y as b}from"./startupProfiler-xa3NmN7Z.js";import{$t as x,an as S,bn as C,gn as w,vn as T,yn as ee}from"./prompt-BNHtszmZ.js";import{n as E,t as D}from"./staticRender-BIxpgNUq.js";function O(e){let t=[];return k(e,t),A(e,t),M(e,t),N(e,t),P(e,t),t.sort((e,t)=>e.severity===t.severity?(t.savingsTokens??0)-(e.savingsTokens??0):e.severity===`warning`?-1:1),t}function k(e,t){e.percentage>=R&&t.push({severity:`warning`,title:`Context is ${e.percentage}% full`,detail:e.isAutoCompactEnabled?`Autocompact will trigger soon, which discards older messages. Use /compact now to control what gets kept.`:`Autocompact is disabled. Use /compact to free space, or enable autocompact in /config.`})}function A(e,t){if(e.messageBreakdown)for(let n of e.messageBreakdown.toolCallsByType){let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100;if(i<F||r<I)continue;let a=j(n.name,r,i);a&&t.push(a)}}function j(e,t,n){let r=b(t);switch(e){case ee:return{severity:`warning`,title:`Bash results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Pipe output through head, tail, or grep to reduce result size. Avoid cat on large files — use Read with offset/limit instead.`,savingsTokens:Math.floor(t*.5)};case x:return{severity:`info`,title:`Read results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Use offset and limit parameters to read only the sections you need. Avoid re-reading entire files when you only need a few lines.`,savingsTokens:Math.floor(t*.3)};case w:return{severity:`info`,title:`Grep results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Add more specific patterns or use the glob or type parameter to narrow file types. Consider Glob for file discovery instead of Grep.`,savingsTokens:Math.floor(t*.3)};default:return n>=20?{severity:`info`,title:`${e} using ${r} tokens (${n.toFixed(0)}%)`,detail:`This tool is consuming a significant portion of context.`,savingsTokens:Math.floor(t*.2)}:null}}function M(e,t){if(!e.messageBreakdown)return;let n=e.messageBreakdown.toolCallsByType.find(e=>e.name===x);if(!n)return;let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100,a=n.resultTokens/e.rawMaxTokens*100;i>=F&&r>=I||a>=L&&n.resultTokens>=I&&t.push({severity:`info`,title:`File reads using ${b(n.resultTokens)} tokens (${a.toFixed(0)}%)`,detail:`If you are re-reading files, consider referencing earlier reads. Use offset/limit for large files.`,savingsTokens:Math.floor(n.resultTokens*.3)})}function N(e,t){let n=e.memoryFiles.reduce((e,t)=>e+t.tokens,0),r=n/e.rawMaxTokens*100;if(r>=z&&n>=B){let i=[...e.memoryFiles].sort((e,t)=>t.tokens-e.tokens).slice(0,3).map(e=>`${v(e.path)} (${b(e.tokens)})`).join(`, `);t.push({severity:`info`,title:`Memory files using ${b(n)} tokens (${r.toFixed(0)}%)`,detail:`Largest: ${i}. Use /memory to review and prune stale entries.`,savingsTokens:Math.floor(n*.3)})}}function P(e,t){!e.isAutoCompactEnabled&&e.percentage>=50&&e.percentage<R&&t.push({severity:`info`,title:`Autocompact is disabled`,detail:`Without autocompact, you will hit context limits and lose the conversation. Enable it in /config or use /compact manually.`})}var F,I,L,R,z,B,V=e((()=>{C(),S(),T(),_(),y(),F=15,I=1e4,L=5,R=80,z=5,B=5e3}));function H({suggestions:e}){return e.length===0?null:(0,U.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,U.jsx)(i,{bold:!0,children:`Suggestions`}),e.map((e,t)=>(0,U.jsxs)(r,{flexDirection:`column`,marginTop:t===0?0:1,children:[(0,U.jsxs)(r,{children:[(0,U.jsx)(o,{status:e.severity,withSpace:!0}),(0,U.jsx)(i,{bold:!0,children:e.title}),e.savingsTokens?(0,U.jsxs)(i,{dimColor:!0,children:[` `,n.arrowRight,` save ~`,b(e.savingsTokens)]}):null]}),(0,U.jsx)(r,{marginLeft:2,children:(0,U.jsx)(i,{dimColor:!0,children:e.detail})})]},t))]})}var U,W=e((()=>{t(),a(),s(),y(),U=c()}));function G(){return null}function K(e){let t=new Map;for(let n of e){let e=g(n.source),r=t.get(e)||[];r.push(n),t.set(e,r)}for(let[e,n]of t.entries())t.set(e,n.sort((e,t)=>t.tokens-e.tokens));let n=new Map;for(let e of X){let r=t.get(e);r&&n.set(e,r)}return n}function q({data:e}){let{categories:t,totalTokens:n,rawMaxTokens:a,percentage:o,gridRows:s,model:c,memoryFiles:l,mcpTools:u,deferredBuiltinTools:d=[],systemTools:f,systemPromptSections:p,agents:m,skills:h,messageBreakdown:g,cacheHitRate:_,cacheThreshold:y}=e,x=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==Y&&!e.isDeferred),S=t.some(e=>e.isDeferred&&e.name.includes(`MCP`)),C=d.length>0,w=t.find(e=>e.name===Y);return(0,J.jsxs)(r,{flexDirection:`column`,paddingLeft:1,children:[(0,J.jsx)(i,{bold:!0,children:`Context Usage`}),(0,J.jsxs)(r,{flexDirection:`row`,gap:2,children:[(0,J.jsx)(r,{flexDirection:`column`,flexShrink:0,children:s.map((e,t)=>(0,J.jsx)(r,{flexDirection:`row`,marginLeft:-1,children:e.map((e,t)=>e.categoryName===`Free space`?(0,J.jsx)(i,{dimColor:!0,children:`⛶ `},t):e.categoryName===Y?(0,J.jsx)(i,{color:e.color,children:`⛝ `},t):(0,J.jsx)(i,{color:e.color,children:e.squareFullness>=.7?`⛁ `:`⛀ `},t))},t))}),(0,J.jsxs)(r,{flexDirection:`column`,gap:0,flexShrink:0,children:[(0,J.jsxs)(i,{dimColor:!0,children:[c,` · `,b(n),`/`,b(a),` tokens (`,o,`%)`]}),(0,J.jsx)(G,{}),_!==void 0&&y!==void 0&&(0,J.jsxs)(i,{color:_<y?`warning`:void 0,children:[`Cache hit rate: `,_.toFixed(0),`%`,_<y?` (below ${y}% threshold)`:``]}),(0,J.jsx)(i,{children:` `}),(0,J.jsx)(i,{dimColor:!0,italic:!0,children:`Estimated usage by category`}),x.map((e,t)=>{let n=b(e.tokens),o=e.isDeferred?`N/A`:`${(e.tokens/a*100).toFixed(1)}%`,s=e.name===Y,c=e.name,l=e.isDeferred?` `:s?`⛝`:`⛁`;return(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{color:e.color,children:l}),(0,J.jsxs)(i,{children:[` `,c,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[n,` tokens (`,o,`)`]})]},t)}),(t.find(e=>e.name===`Free space`)?.tokens??0)>0&&(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{dimColor:!0,children:`⛶`}),(0,J.jsx)(i,{children:` Free space: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(t.find(e=>e.name===`Free space`)?.tokens||0),` (`,((t.find(e=>e.name===`Free space`)?.tokens||0)/a*100).toFixed(1),`%)`]})]}),w&&w.tokens>0&&(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{color:w.color,children:`⛝`}),(0,J.jsxs)(i,{dimColor:!0,children:[` `,w.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(w.tokens),` tokens (`,(w.tokens/a*100).toFixed(1),`%)`]})]})]})]}),(0,J.jsxs)(r,{flexDirection:`column`,marginLeft:-1,children:[u.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`MCP tools`}),(0,J.jsxs)(i,{dimColor:!0,children:[` · /mcp`,S?` (loaded on-demand)`:``]})]}),u.some(e=>e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Loaded`}),u.filter(e=>e.isLoaded).map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),S&&u.some(e=>!e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Available`}),u.filter(e=>!e.isLoaded).map((e,t)=>(0,J.jsx)(r,{children:(0,J.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]}),!S&&u.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),(f&&f.length>0||C)&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] System tools`}),C&&(0,J.jsx)(i,{dimColor:!0,children:` (some loaded on-demand)`})]}),(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Loaded`}),f?.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},`sys-${t}`)),d.filter(e=>e.isLoaded).map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},`def-${t}`))]}),C&&d.some(e=>!e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Available`}),d.filter(e=>!e.isLoaded).map((e,t)=>(0,J.jsx)(r,{children:(0,J.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]})]}),p&&p.length>0&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] System prompt sections`}),p.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),m.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Custom agents`}),(0,J.jsx)(i,{dimColor:!0,children:` · /agents`})]}),Array.from(K(m).entries()).map(([e,t])=>(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.agentType,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]},e))]}),l.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Memory files`}),(0,J.jsx)(i,{dimColor:!0,children:` · /memory`})]}),l.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,v(e.path),`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),h&&h.tokens>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Skills`}),(0,J.jsx)(i,{dimColor:!0,children:` · /skills`})]}),Array.from(K(h.skillFrontmatter).entries()).map(([e,t])=>(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]},e))]}),g&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Message breakdown`}),(0,J.jsxs)(r,{flexDirection:`column`,marginLeft:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Tool calls: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.toolCallTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Tool results: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.toolResultTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Attachments: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.attachmentTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Assistant messages (non-tool): `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.assistantMessageTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`User messages (non-tool-result): `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.userMessageTokens),` tokens`]})]})]}),g.toolCallsByType.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Top tools`}),g.toolCallsByType.slice(0,5).map((e,t)=>(0,J.jsxs)(r,{marginLeft:1,children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[`calls `,b(e.callTokens),`, results `,b(e.resultTokens)]})]},t))]}),g.attachmentsByType.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Top attachments`}),g.attachmentsByType.slice(0,5).map((e,t)=>(0,J.jsxs)(r,{marginLeft:1,children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]})]})]}),(0,J.jsx)(H,{suggestions:O(e)})]})}var J,Y,X,Z=e((()=>{a(),s(),V(),_(),y(),h(),W(),J=c(),Y=`Autocompact buffer`,X=[`Project`,`User`,`Managed`,`Plugin`,`Built-in`]}));function Q(e){return l(e)}async function te(e,t){let{messages:n,getAppState:r,options:{mainLoopModel:i,tools:a}}=t,o=Q(n),{messages:s}=await f(o),c=process.stdout.columns||80,l=r();return e(await E((0,$.jsx)(q,{data:await p(s,i,async()=>l.toolPermissionContext,a,l.agentDefinitions,c,t,void 0,o)}))),null}var $;e((()=>{a(),Z(),u(),d(),m(),D(),$=c()}))();export{te as call};
|
package/dist/chunks/{context-noninteractive-BuGxX3YL.js → context-noninteractive-9hELVC29.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ao as t,
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ao as t,KE as n,al as r,qE as i,rl as a,zo as o}from"./loadAgentsDir-D206qwP3.js";import{dn as s,un as c}from"./settings-BovzmwMP.js";import{b as l,y as u}from"./startupProfiler-xa3NmN7Z.js";async function d(e){let{messages:n,getAppState:r,options:{mainLoopModel:o,tools:s,agentDefinitions:c,customSystemPrompt:l,appendSystemPrompt:u}}=e,d=t(n),{messages:f}=await i(d),p=r();return a(f,o,async()=>p.toolPermissionContext,s,c,void 0,{options:{customSystemPrompt:l,appendSystemPrompt:u}},void 0,d)}async function f(e,t){return{type:`text`,value:p(await d(t))}}function p(e){let{categories:t,totalTokens:n,rawMaxTokens:r,percentage:i,model:a,memoryFiles:o,mcpTools:s,agents:l,skills:d,messageBreakdown:f,systemTools:p,systemPromptSections:m}=e,h=`## Context Usage
|
|
2
2
|
|
|
3
3
|
`;h+=`**Model:** ${a} \n`,h+=`**Tokens:** ${u(n)} / ${u(r)} (${i}%)\n`,h+=`
|
|
4
4
|
`;let g=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==`Autocompact buffer`);if(g.length>0){h+=`### Estimated usage by category
|
|
@@ -51,4 +51,4 @@ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ao as t,GE as n,WE as
|
|
|
51
51
|
`,h+=`| Attachment | Tokens |
|
|
52
52
|
`,h+=`|------------|--------|
|
|
53
53
|
`;for(let e of f.attachmentsByType)h+=`| ${e.name} | ${u(e.tokens)} |\n`;h+=`
|
|
54
|
-
`}}return h}var m=e((()=>{
|
|
54
|
+
`}}return h}var m=e((()=>{n(),r(),l(),o(),s()}));export{d as n,m as r,f as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t,t as n}from"./context-noninteractive-9hELVC29.js";t();export{n as call,e as collectContextData};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./conversation-BWVTM40Y.js";e();export{t as clearConversation};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,n as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Fn as n,In as r,Rn as i,cn as a,en as o,ht as s,nt as c,q as l,un as u}from"./state-ix0xIunV.js";import{Au as d,Bl as f,Ci as p,Ct as m,Ei as h,Et as g,Gp as _,Il as v,Ky as y,LC as b,Mn as x,Wp as S,Zt as ee,ab as te,dn as C,dr as w,eg as T,fb as E,fi as D,jn as O,jr as k,ju as A,kn as j,nr as M,qy as N,tg as P,yn as F,zC as I}from"./loadAgentsDir-D206qwP3.js";import{o as L,s as ne}from"./log-BMCygSzM.js";import{n as R,r as z}from"./analytics-BotDBGh0.js";import{C as B,y as V}from"./rcDebugLog-CUy1_F23.js";import{l as H,r as U}from"./commitAttribution-ChAgixdj.js";import{c as W,d as G}from"./debugUtils-NO5KtXqi.js";import{n as K,t as q}from"./caches-UeVVM3T0.js";import{randomUUID as J}from"crypto";function Y(e){Q=e,f(Z()??null).catch(()=>{})}function X(){return Q}function Z(){let e=X();return e?G(e.bridgeSessionId):void 0}var Q,$=t((()=>{v(),W(),Q=null}));function re(){let e=X();if(!e)return;e.markTranscriptReset?.();let t={type:`status`,subtype:`status`,status:`conversation_cleared`,message:`conversation_cleared`,uuid:J()};e.writeSdkMessages([t])}async function ie({setMessages:t,readFileState:o,discoveredSkillNames:d,loadedNestedMemoryPaths:f,getAppState:g,setAppState:v,setConversationId:y}){let x=C();await ee(`clear`,{getAppState:g,setAppState:v,signal:AbortSignal.timeout(x),timeoutMs:x});let S=l();S&&z(`tengu_cache_eviction_hint`,{scope:`conversation_clear`,last_request_id:S});let T=new Set,E=[],F=e=>`isBackgrounded`in e&&e.isBackgrounded===!1;if(g)for(let e of Object.values(g().tasks))F(e)||A(e)&&(T.add(e.agentId),E.push(e));t(()=>[]),re();{let{setContextBlocked:t}=(V(),e(B));t(!1)}y&&y(J()),q(T),n(null),r(null),i(null),u(),_(c()),o.clear(),d?.clear(),f?.clear(),v&&v(e=>{let t={};for(let[n,r]of Object.entries(e.tasks)){if(!F(r)){t[n]=r;continue}try{r.status===`running`&&(P(r)&&(r.shellCommand?.kill(),r.shellCommand?.cleanup(),r.cleanupTimeoutId&&clearTimeout(r.cleanupTimeoutId)),`abortController`in r&&r.abortController?.abort(),`unregisterCleanup`in r&&r.unregisterCleanup?.())}catch(e){ne(e)}j(n)}return{...e,tasks:t,attribution:U(),standaloneAgentContext:void 0,fileHistory:{snapshots:[],trackedFiles:new Set,snapshotSequence:0},mcp:{clients:[],tools:[],commands:[],resources:{},pluginReconnectKey:e.mcp.pluginReconnectKey}}}),te(),M(),a({setCurrentAsParent:!0}),process.env.USER_TYPE===`ant`&&process.env.CLAUDE_CODE_SESSION_ID&&(process.env.CLAUDE_CODE_SESSION_ID=s()),await D();for(let e of E)e.status===`running`&&O(e.id,w(b(e.agentId)));let{saveMode:I}=(k(),e(h));I(`normal`);let L=m();L&&p(L);let R=await N(`clear`);R.length>0&&t(()=>R)}var ae=t((()=>{$(),o(),R(),d(),T(),I(),H(),F(),L(),E(),S(),y(),k(),x(),g(),K()}));export{Y as i,ae as n,$ as r,ie as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,S as r,a as i,l as a,w as o}from"./debug-BrXObCdR.js";import{l as s,u as c}from"./oauth-BqJqV-2M.js";import{
|
|
1
|
+
import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,S as r,a as i,l as a,w as o}from"./debug-BrXObCdR.js";import{l as s,u as c}from"./oauth-BqJqV-2M.js";import{Bt as l,Ot as u}from"./model-CKkOnnnx.js";import{i as d,t as f}from"./cliLaunch-BkPAatcs.js";import{resolve as p}from"path";import{existsSync as m,unlinkSync as h}from"fs";import{randomUUID as g}from"crypto";i(),r(),e();function _(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var v=2e3,y=15e3,b=3,x=class{constructor(e,n){t(this,`proc`,void 0),t(this,`options`,void 0),t(this,`connected`,!1),t(this,`disconnected`,!1),t(this,`readLoopAbort`,null),t(this,`reconnectAttempt`,0),t(this,`maxReconnectAttempts`,void 0),t(this,`userInitiatedDisconnect`,!1),t(this,`reconnecting`,!1),this.proc=e,this.options=n,this.maxReconnectAttempts=n.maxReconnectAttempts??b}connect(){this.connected||(this.readLoopAbort=new AbortController,this.startReadLoop(),this.monitorExit(),this.connected=!0,this.options.onConnected())}async startReadLoop(){let e=this.proc.stdout;if(!e){this.options.onError(Error(`SSH process stdout is not available`));return}let t=e.getReader(),n=new TextDecoder,r=``;try{for(;!this.disconnected;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.split(`
|
|
2
2
|
`);r=a.pop()??``;for(let e of a){let t=e.trim();t&&this.processLine(t)}}}catch(e){this.disconnected||this.options.onError(e instanceof Error?e:Error(String(e)))}finally{t.releaseLock(),!this.disconnected&&!this.userInitiatedDisconnect&&this.handleProcessExit()}}monitorExit(){if(this.proc.exitCode!==null){this.userInitiatedDisconnect||this.handleProcessExit();return}this.proc.exited.then(()=>{!this.disconnected&&!this.userInitiatedDisconnect&&this.handleProcessExit()}).catch(()=>{!this.disconnected&&!this.userInitiatedDisconnect&&this.handleProcessExit()})}async handleProcessExit(){if(!(this.disconnected||this.reconnecting)){if(this.connected=!1,!this.options.reconnect){this.disconnected=!0,this.options.onDisconnected();return}if(this.reconnectAttempt>=this.maxReconnectAttempts){this.disconnected=!0,this.options.onDisconnected();return}this.reconnecting=!0;try{await this.attemptReconnect()}finally{this.reconnecting=!1}}}async attemptReconnect(){let e=this.options.reconnect;for(;this.reconnectAttempt<this.maxReconnectAttempts;){this.reconnectAttempt++,this.options.onReconnecting(this.reconnectAttempt,this.maxReconnectAttempts);let t=Math.min(v*2**(this.reconnectAttempt-1),y);if(await new Promise(e=>setTimeout(e,t)),this.userInitiatedDisconnect)return;try{let t=await e();this.proc=t,this.reconnectAttempt=0,this.connected=!0,this.startReadLoop(),this.monitorExit(),this.options.onConnected();return}catch(e){a(`[SSH] reconnect attempt ${this.reconnectAttempt} failed: ${e instanceof Error?e.message:String(e)}`)}}this.disconnected=!0,this.options.onDisconnected()}processLine(e){let t;try{t=n(e)}catch{return}if(!_(t))return;let r=t;if(r.type===`control_request`){let e=r;e.request.subtype===`can_use_tool`?this.options.onPermissionRequest(e.request,e.request_id):(a(`[SSH] Unsupported control request subtype: ${e.request.subtype}`),this.sendErrorResponse(e.request_id,`Unsupported control request subtype: ${e.request.subtype}`));return}r.type!==`control_response`&&r.type!==`keep_alive`&&r.type!==`control_cancel_request`&&r.type!==`streamlined_text`&&r.type!==`streamlined_tool_use_summary`&&!(r.type===`system`&&r.subtype===`post_turn_summary`)&&this.options.onMessage(r)}writeToStdin(e){try{let t=this.proc.stdin;if(!t||typeof t==`number`||this.disconnected)return!1;let n=new TextEncoder().encode(e+`
|
|
3
3
|
`);return t.write(n),t.flush?.(),!0}catch{return!1}}async sendMessage(e){let t=o({type:`user`,message:{role:`user`,content:e},parent_tool_use_id:null,session_id:``});return this.writeToStdin(t)}sendInterrupt(){let e=o({type:`control_request`,request_id:crypto.randomUUID(),request:{subtype:`interrupt`}});this.writeToStdin(e)}respondToPermissionRequest(e,t){let n=o({type:`control_response`,response:{subtype:`success`,request_id:e,response:{behavior:t.behavior,...t.behavior===`allow`?{updatedInput:t.updatedInput}:{message:t.message}}}});this.writeToStdin(n)}sendErrorResponse(e,t){let n=o({type:`control_response`,response:{subtype:`error`,request_id:e,error:t}});this.writeToStdin(n)}disconnect(){if(!this.disconnected){this.userInitiatedDisconnect=!0,this.disconnected=!0,this.connected=!1,this.readLoopAbort?.abort();try{let e=this.proc.stdin;e&&typeof e!=`number`&&e.end?.()}catch{}try{this.proc.kill()}catch{}}}isConnected(){return this.connected&&!this.disconnected}};l(),c(),i();var S=process.platform===`win32`;function C(){let e=process.env.ANTHROPIC_API_KEY;if(e)return{"x-api-key":e};let t=u();return t?.accessToken?{Authorization:`Bearer ${t.accessToken}`}:{}}function w(){return process.env.ANTHROPIC_BASE_URL||s().BASE_API_URL}async function T(e,t){if(t&&e.headers.get(`x-auth-nonce`)!==t)return new Response(`Forbidden`,{status:403});let n=w(),r=new URL(e.url),i=`${n}${r.pathname}${r.search}`,o=C();if(Object.keys(o).length===0)return new Response(JSON.stringify({error:`No API credentials available on local machine`}),{status:401,headers:{"content-type":`application/json`}});let s=new Headers(e.headers);for(let[e,t]of Object.entries(o))s.set(e,t);s.delete(`host`),s.delete(`x-auth-nonce`),a(`[SSHAuthProxy] ${e.method} ${r.pathname} -> ${i}`);try{let t=await fetch(i,{method:e.method,headers:s,body:e.body,duplex:`half`}),n=new Headers(t.headers);return n.delete(`content-encoding`),n.delete(`content-length`),new Response(t.body,{status:t.status,statusText:t.statusText,headers:n})}catch(e){let t=e instanceof Error?e.message:String(e);return a(`[SSHAuthProxy] upstream error: ${t}`),new Response(JSON.stringify({error:`Proxy upstream error: ${t}`}),{status:502,headers:{"content-type":`application/json`}})}}async function E(){let e=g();return S?O(e):D(e)}async function D(e){let t=`/tmp/claude-ssh-auth-${e}.sock`,n=Bun.serve({unix:t,fetch:e=>T(e,null)});return a(`[SSHAuthProxy] listening on unix:${t}`),{proxy:{stop(){n.stop(!0);try{h(t)}catch{}}},localAddress:t,authEnv:{ANTHROPIC_AUTH_SOCKET:t}}}async function O(e){let t=g(),n=Bun.serve({port:0,hostname:`127.0.0.1`,fetch:e=>T(e,t)}),r=n.port;return a(`[SSHAuthProxy] listening on TCP 127.0.0.1:${r} (nonce-protected)`),{proxy:{stop(){n.stop(!0)}},localAddress:`127.0.0.1:${r}`,authEnv:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${r}`,ANTHROPIC_AUTH_NONCE:t}}}i();var k=15e3,A=class extends Error{constructor(e){super(e),this.name=`SSHProbeError`}};async function j(e,t){t?.(`Probing remote host…`);let n=Bun.spawn([`ssh`,`-o`,`BatchMode=yes`,`-o`,`ConnectTimeout=10`,e,`CLAUDE_BIN=$(test -x "$HOME/.local/bin/claude" && echo "$HOME/.local/bin/claude" || command -v claude 2>/dev/null); echo "$CLAUDE_BIN"; $CLAUDE_BIN --version 2>/dev/null; uname -sm; pwd`],{stdin:`ignore`,stdout:`pipe`,stderr:`pipe`}),r=await Promise.race([n.exited,new Promise((e,t)=>setTimeout(()=>t(new A(`SSH probe timed out after ${k/1e3}s`)),k))]),i=await new Response(n.stdout).text(),o=await new Response(n.stderr).text();if(r!==0)throw new A(`SSH probe failed: ${o.trim()||`exit code ${r}`}`);let s=i.split(`
|
|
4
4
|
`).map(e=>e.trim()).filter(Boolean);a(`[SSHProbe] raw lines: ${JSON.stringify(s)}`);let c=s.findIndex(e=>/^(Linux|Darwin)\s/.test(e));if(c===-1)throw new A(`Could not detect remote platform (uname output missing)`);let l=c>=2&&s[c-2]||null,u=c>=1&&s[c-1]||null,d=u&&/^\d+\.\d+/.test(u)?u:null,f=l!==null&&l.startsWith(`/`),p=s[c+1]||`/`,[m,h]=s[c].split(/\s+/),g=m===`Darwin`?`darwin`:`linux`,_=h===`aarch64`||h===`arm64`?`arm64`:`x64`;return t?.(`Detected ${g}/${_}`),{hasBinary:f&&d!==null,remoteVersion:d,remotePlatform:g,remoteArch:_,defaultCwd:p,binaryPath:f?l:null}}i();var M=6e4,N=`~/.local/bin`,P=`claude-code-cli.js`,F=`claude`;async function I(e,t,n=M){let r=Bun.spawn([`ssh`,`-o`,`ConnectTimeout=10`,e,t],{stdout:`pipe`,stderr:`pipe`}),i=setTimeout(()=>r.kill(),n);try{let[e,t]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text()]),n=await r.exited;return{stdout:e.trim(),stderr:t.trim(),exitCode:n}}finally{clearTimeout(i)}}function L(){let e=p(import.meta.dir,`../..`),t=p(e,`dist/cli.js`);if(m(t))return t;let n=p(e,`src/entrypoints/cli.tsx`);if(m(n))return n;throw Error("Cannot find local CLI binary to deploy. Run `bun run build` first.")}async function R(e){let{host:t,remotePlatform:n,remoteArch:r,localVersion:i,onProgress:o}=e;if(n!==`linux`&&n!==`darwin`)throw Error(`Remote platform "${n}" is not supported. Only linux and darwin are supported.`);a(`[SSHDeploy] deploying to ${t} (${n}/${r}, v${i})`);let s=L();a(`[SSHDeploy] local binary: ${s}`),o?.(`Creating remote directory...`);let c=await I(t,`mkdir -p ${N}`);if(c.exitCode!==0)throw Error(`Failed to create remote directory: ${c.stderr}`);o?.(`Uploading binary...`);let l=`${N}/${P}`,u=Bun.spawn([`scp`,`-o`,`ConnectTimeout=10`,s,`${t}:${l}`],{stdout:`pipe`,stderr:`pipe`}),d=setTimeout(()=>u.kill(),M),f=await new Response(u.stderr).text(),p=await u.exited;if(clearTimeout(d),p!==0)throw Error(`SCP upload failed (exit ${p}): ${f.trim()}`);o?.(`Installing wrapper script...`);let m=await I(t,[`cat > ${N}/${F} << 'WRAPPER'`,`#!/bin/sh`,`exec bun ${N}/${P} "$@"`,`WRAPPER`,`chmod +x ${N}/${F}`].join(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,n,r}from"./createSession-Cvl1Q50F.js";t();export{n as createBridgeSession,r as getBridgeSession,e as updateBridgeSessionTitle};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{F as t,a as n,l as r,z as i}from"./debug-BrXObCdR.js";import{c as a,d as o,i as s,o as c}from"./debugUtils-NO5KtXqi.js";async function l({environmentId:e,title:n,events:i,gitRepoUrl:a,branch:o,signal:c,baseUrl:l,getAccessToken:u,permissionMode:d}){let{getClaudeAIOAuthTokens:f}=await import(`./auth-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{F as t,a as n,l as r,z as i}from"./debug-BrXObCdR.js";import{c as a,d as o,i as s,o as c}from"./debugUtils-NO5KtXqi.js";async function l({environmentId:e,title:n,events:i,gitRepoUrl:a,branch:o,signal:c,baseUrl:l,getAccessToken:u,permissionMode:d}){let{getClaudeAIOAuthTokens:f}=await import(`./auth-DRTjfnGy.js`),{getOrganizationUUID:p}=await import(`./client-BzKQTXzF.js`),{getOauthConfig:m}=await import(`./oauth-C8X_p8Gc.js`),{getOAuthHeaders:h}=await import(`./api-BsFW57_Q.js`),{parseGitHubRepository:g}=await import(`./detectRepository-BTPgN89l.js`),{getDefaultBranch:_}=await import(`./git-CbcnOf0E.js`),{getMainLoopModel:v}=await import(`./model-DRXcJyU9.js`),{default:y}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:b}=await import(`./bridgeConfig-CqIQ_rvD.js`),x=u?.()??f()?.accessToken;if(!x)return r(`[bridge] No access token for session creation`),null;let S=b()?`self-hosted`:await p();if(!S)return r(`[bridge] No org UUID for session creation`),null;let C=null,w=null;if(a){let{parseGitRemote:e}=await import(`./detectRepository-BTPgN89l.js`),t=e(a);if(t){let{host:e,owner:n,name:r}=t,i=o||await _()||void 0;C={type:`git_repository`,url:`https://${e}/${n}/${r}`,revision:i},w={type:`git_repository`,git_info:{type:`github`,repo:`${n}/${r}`,branches:[`claude/${o||`task`}`]}}}else{let e=g(a);if(e){let[t,n]=e.split(`/`);if(t&&n){let e=o||await _()||void 0;C={type:`git_repository`,url:`https://github.com/${t}/${n}`,revision:e},w={type:`git_repository`,git_info:{type:`github`,repo:`${t}/${n}`,branches:[`claude/${o||`task`}`]}}}}}}let T={...n!==void 0&&{title:n},events:i,session_context:{sources:C?[C]:[],outcomes:w?[w]:[],model:v()},environment_id:e,source:`remote-control`,...d&&{permission_mode:d}},E={...h(x),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":S},D=`${l??m().BASE_API_URL}/v1/sessions`,O;try{O=await y.post(D,T,{headers:E,signal:c,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session creation request failed: ${t(e)}`),null}if(!(O.status===200||O.status===201)){let e=s(O.data);return r(`[bridge] Session creation failed with status ${O.status}${e?`: ${e}`:``}`),null}let k=O.data;return!k||typeof k!=`object`||!(`id`in k)||typeof k.id!=`string`?(r(`[bridge] No session ID in response`),null):k.id}async function u(e,n){let{getClaudeAIOAuthTokens:i}=await import(`./auth-DRTjfnGy.js`),{getOrganizationUUID:a}=await import(`./client-BzKQTXzF.js`),{getOauthConfig:o}=await import(`./oauth-C8X_p8Gc.js`),{getOAuthHeaders:c}=await import(`./api-BsFW57_Q.js`),{default:l}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:u}=await import(`./bridgeConfig-CqIQ_rvD.js`),d=n?.getAccessToken?.()??i()?.accessToken;if(!d)return r(`[bridge] No access token for session fetch`),null;let f=u()?`self-hosted`:await a();if(!f)return r(`[bridge] No org UUID for session fetch`),null;let p={...c(d),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":f},m=`${n?.baseUrl??o().BASE_API_URL}/v1/sessions/${e}`;r(`[bridge] Fetching session ${e}`);let h;try{h=await l.get(m,{headers:p,timeout:1e4,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session fetch request failed: ${t(e)}`),null}if(h.status!==200){let e=s(h.data);return r(`[bridge] Session fetch failed with status ${h.status}${e?`: ${e}`:``}`),null}return h.data}async function d(e,t){let{getClaudeAIOAuthTokens:n}=await import(`./auth-DRTjfnGy.js`),{getOrganizationUUID:i}=await import(`./client-BzKQTXzF.js`),{getOauthConfig:a}=await import(`./oauth-C8X_p8Gc.js`),{getOAuthHeaders:o}=await import(`./api-BsFW57_Q.js`),{default:c}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:l}=await import(`./bridgeConfig-CqIQ_rvD.js`),u=t?.getAccessToken?.()??n()?.accessToken;if(!u){r(`[bridge] No access token for session archive`);return}let d=l()?`self-hosted`:await i();if(!d){r(`[bridge] No org UUID for session archive`);return}let f={...o(u),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":d},p=`${t?.baseUrl??a().BASE_API_URL}/v1/sessions/${e}/archive`;r(`[bridge] Archiving session ${e}`);let m=await c.post(p,{},{headers:f,timeout:t?.timeoutMs??1e4,validateStatus:e=>e<500});if(m.status===200)r(`[bridge] Session ${e} archived successfully`);else{let e=s(m.data);r(`[bridge] Session archive failed with status ${m.status}${e?`: ${e}`:``}`)}}async function f(e,n,i){let{getClaudeAIOAuthTokens:a}=await import(`./auth-DRTjfnGy.js`),{getOrganizationUUID:c}=await import(`./client-BzKQTXzF.js`),{getOauthConfig:l}=await import(`./oauth-C8X_p8Gc.js`),{getOAuthHeaders:u}=await import(`./api-BsFW57_Q.js`),{default:d}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:f}=await import(`./bridgeConfig-CqIQ_rvD.js`),p=i?.getAccessToken?.()??a()?.accessToken;if(!p){r(`[bridge] No access token for session title update`);return}let m=f()?`self-hosted`:await c();if(!m){r(`[bridge] No org UUID for session title update`);return}let h={...u(p),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":m},g=o(e),_=`${i?.baseUrl??l().BASE_API_URL}/v1/sessions/${g}`;r(`[bridge] Updating session title: ${g} → ${n}`);try{let e=await d.patch(_,{title:n},{headers:h,timeout:1e4,validateStatus:e=>e<500});if(e.status===200)r(`[bridge] Session title updated successfully`);else{let t=s(e.data);r(`[bridge] Session title update failed with status ${e.status}${t?`: ${t}`:``}`)}}catch(e){r(`[bridge] Session title update request failed: ${t(e)}`)}}var p=e((()=>{n(),i(),c(),a()}));export{f as a,p as i,l as n,u as r,d as t};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{C as i,D as a,Gr as o,H as s,I as c,P as l,T as u,Wt as d,Xn as f,ai as p,di as m,fi as h,hn as ee,k as te,ot as ne,p as re,t as g,ui as _}from"./src-CDCSSo0U2.js";import{t as v}from"./jsx-runtime-Bb4Xn-E0.js";import{en as y,ht as ie,nt as ae}from"./state-ix0xIunV.js";import{Cr as b,Fb as oe,Fh as x,Fi as se,Fr as S,Fx as C,Gb as ce,Ju as w,Kb as le,Nb as ue,Nr as de,Ph as fe,Pi as pe,Px as me,Sx as T,Wr as he,Xu as E,aC as ge,hr as _e,jr as D,mx as ve,px as ye,vi as be,xx as O}from"./loadAgentsDir-D206qwP3.js";import{C as k,S as xe,a as A,l as j}from"./debug-BrXObCdR.js";import{_n as Se,gn as Ce}from"./settings-BovzmwMP.js";import{_ as we,i as Te}from"./git-Do0wJvux.js";import{a as Ee,o as De,s as Oe}from"./log-BMCygSzM.js";import{n as ke,r as M}from"./analytics-BotDBGh0.js";import{T as Ae,b as je,f as Me,h as Ne}from"./startupProfiler-xa3NmN7Z.js";import{_ as Pe,h as Fe}from"./model-CKkOnnnx.js";import{i as N,r as P}from"./shellQuote-DkSy9MYE.js";import{u as Ie}from"./referral-CUaIo_vT.js";import{n as Le,t as Re}from"./useExitOnCtrlCDWithKeybindings-DKIqRraH.js";import{t as ze}from"./SearchBox-vfLXEPed.js";import{n as Be,t as Ve}from"./useSearchInput-D1Vr2Js1.js";import{d as He,n as F,t as Ue,u as We}from"./Messages-Ch6cboMV.js";import{sep as I}from"path";function Ge({log:e,onExit:t,onSelect:n}){let[r,i]=L.useState(null);L.useEffect(()=>{i(null),S(e)&&he(e).then(i)},[e]);let o=S(e)&&r===null,s=r??e,f=b(s)||``,p=w();return d(`confirm:no`,t,{context:`Confirmation`}),d(`confirm:yes`,(0,L.useCallback)(()=>{n(r??e)},[n,r,e]),{context:`Confirmation`}),o?(0,R.jsxs)(c,{flexDirection:`column`,padding:1,children:[(0,R.jsx)(re,{message:`Loading session…`}),(0,R.jsx)(l,{dimColor:!0,children:(0,R.jsx)(u,{children:(0,R.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})})})]}):(0,R.jsxs)(c,{flexDirection:`column`,children:[(0,R.jsx)(Ue,{messages:s.messages,tools:p,commands:[],verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:new Set,isMessageSelectorVisible:!1,conversationId:f,screen:`transcript`,streamingToolUses:[],showAllInTranscript:!0,isLoading:!1}),(0,R.jsxs)(c,{flexShrink:0,flexDirection:`column`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,paddingLeft:2,children:[(0,R.jsxs)(l,{children:[Ne(s.modified),` · `,s.messageCount,` messages`,s.gitBranch?` · ${s.gitBranch}`:``]}),(0,R.jsx)(l,{dimColor:!0,children:(0,R.jsxs)(u,{children:[(0,R.jsx)(a,{shortcut:`Enter`,action:`resume`}),(0,R.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})]})}var L,R,z=e((()=>{L=t(h(),1),g(),Ie(),E(),je(),D(),T(),F(),R=v()}));function Ke(e,t){if(e===V)return 5;let n=o(e),r=t?Math.min(n,t-H-U):n;return Math.max(0,r)+H+U}function qe(e,t){let n=t-H-U;return o(e)<=n?e:n<=1?e.charAt(0):Ae(e,n)}function Je({tabs:e,selectedIndex:t,availableWidth:n,showAllProjects:r=!1}){let i=r?`Resume (All Projects)`:`Resume`,a=i.length+1,o=Math.max(et,W),s=n-a-o-2,u=Math.max(0,Math.min(t,e.length-1)),d=Math.max(20,Math.floor(s/2)),f=e.map(e=>Ke(e,d)),p=0,m=e.length;if(f.reduce((e,t,n)=>e+t+ +(n<f.length-1),0)>s){let t=s-$e,n=f[u]??0;for(p=u,m=u+1;p>0||m<e.length;){let r=p>0,i=m<e.length;if(r){let e=(f[p-1]??0)+1;if(n+e<=t){p--,n+=e;continue}}if(i){let e=(f[m]??0)+1;if(n+e<=t){m++,n+=e;continue}}break}}let h=p,ee=e.length-m,te=e.slice(p,m),ne=te.map((e,t)=>p+t);return(0,B.jsxs)(c,{flexDirection:`row`,gap:1,children:[(0,B.jsx)(l,{color:`suggestion`,children:i}),h>0&&(0,B.jsxs)(l,{dimColor:!0,children:[Ye,h]}),te.map((e,t)=>{let n=ne[t]===u,r=e===V?e:`#${qe(e,d-H)}`;return(0,B.jsxs)(l,{backgroundColor:n?`suggestion`:void 0,color:n?`inverseText`:void 0,bold:n,children:[` `,r,` `]},e)}),ee>0?(0,B.jsxs)(l,{dimColor:!0,children:[Xe,ee,Ze]}):(0,B.jsx)(l,{dimColor:!0,children:Qe})]})}var B,V,H,U,Ye,Xe,Ze,Qe,$e,et,W,G=e((()=>{h(),g(),je(),B=v(),V=`All`,H=2,U=1,Ye=`← `,Xe=`→`,Ze=` (tab to cycle)`,Qe=`(tab to cycle)`,$e=5,et=18,W=14}));function tt({nodes:e,onSelect:t,onCancel:n,onFocus:r,focusNodeId:i,visibleOptionCount:a,layout:o=`expanded`,isDisabled:s=!1,hideIndexes:l=!1,isNodeExpanded:u,onExpand:d,onCollapse:f,getParentPrefix:p,getChildPrefix:m,onUpFromFirstItem:h}){let[ee,te]=K.useState(new Set),ne=K.useRef(!1),re=K.useRef(null),g=K.useCallback(e=>u?u(e):ee.has(e),[u,ee]),_=K.useMemo(()=>{let t=[];function n(e,r,i){let a=!!e.children&&e.children.length>0,o=g(e.id);if(t.push({node:e,depth:r,isExpanded:o,hasChildren:a,parentId:i}),a&&o&&e.children)for(let t of e.children)n(t,r+1,e.id)}for(let t of e)n(t,0);return t},[e,g]),v=K.useCallback(e=>e?`▼ `:`▶ `,[]),y=K.useCallback(e=>` ▸ `,[]),ie=p??v,ae=m??y,b=K.useCallback(e=>{let t=``;return e.hasChildren?t=ie(e.isExpanded):e.depth>0&&(t=ae(e.depth)),t+e.node.label},[ie,ae]),oe=K.useMemo(()=>_.map(e=>({label:b(e),description:e.node.description,dimDescription:e.node.dimDescription??!0,value:e.node.id})),[_,b]),x=K.useMemo(()=>{let e=new Map;return _.forEach(t=>e.set(t.node.id,t.node)),e},[_]),se=K.useCallback(e=>_.find(t=>t.node.id===e),[_]),S=K.useCallback((e,t)=>{let n=se(e);!n||!n.hasChildren||(t?d?d(e):te(t=>new Set(t).add(e)):f?f(e):te(t=>{let n=new Set(t);return n.delete(e),n}))},[se,d,f]);return(0,nt.jsx)(c,{tabIndex:0,autoFocus:!0,onKeyDown:e=>{if(!i||s)return;let t=se(i);if(t){if(e.key===`right`&&t.hasChildren)e.preventDefault(),S(i,!0);else if(e.key===`left`){if(t.hasChildren&&t.isExpanded)e.preventDefault(),S(i,!1);else if(t.parentId!==void 0&&(e.preventDefault(),ne.current=!0,S(t.parentId,!1),r)){let e=x.get(t.parentId);e&&r(e)}}}},children:(0,nt.jsx)(ye,{options:oe,onChange:K.useCallback(e=>{let n=x.get(e);n&&t(n)},[x,t]),onFocus:K.useCallback(e=>{if(ne.current){ne.current=!1;return}if(re.current!==e&&(re.current=e,r)){let t=x.get(e);t&&r(t)}},[r,x]),onCancel:n,defaultFocusValue:i,visibleOptionCount:a,layout:o,isDisabled:s,hideIndexes:l,onUpFromFirstItem:h})})}var K,nt,rt=e((()=>{K=t(h(),1),g(),ve(),nt=v()}));function it(e,t){return Ae(e.replace(/\s+/g,` `).trim(),t)}function at({before:e,match:t,after:n},r){return _.dim(e)+r(t)+_.dim(n)}function ot(e,t,n){let r=e.toLowerCase().indexOf(t.toLowerCase());if(r===-1)return null;let i=r+t.length,a=Math.max(0,r-n),o=Math.min(e.length,i+n),s=e.slice(a,r),c=e.slice(r,i),l=e.slice(i,o);return{before:(a>0?`…`:``)+s.replace(/\s+/g,` `).trimStart(),match:c.trim(),after:l.replace(/\s+/g,` `).trimEnd()+(o<e.length?`…`:``)}}function st(e,t,n){let{isGroupHeader:r=!1,isChild:i=!1,forkCount:a=0}=n||{},o=r&&a>0?mt:i?ht:0,s=r&&a>0?` (+${a} other ${a===1?`session`:`sessions`})`:``,c=e.isSidechain?` (sidechain)`:``,l=t-o-c.length-s.length;return`${it(Ee(e),l)}${c}${s}`}function ct(e,t){let{isChild:n=!1,showProjectPath:r=!1}=t||{},i=n?` `:``,a=Me(e),o=r&&e.projectPath?` · ${e.projectPath}`:``;return i+a+o}function lt({logs:e,maxHeight:t=1/0,forceWidth:n,onCancel:o,onSelect:m,onLogsChanged:h,onLoadMore:re,initialSearchQuery:g,showAllProjects:_=!1,onToggleAllProjects:v,onAgenticSearch:y}){let oe=ne(),x=n===void 0?oe.columns:n,se=Le(o),S=f(),C=de(),w=process.env.USER_TYPE===`ant`,[le]=s(),fe=ce(le),T=q.useMemo(()=>e=>p(e,fe.warning),[fe.warning]),he=process.env.USER_TYPE===`ant`,[E,ge]=q.useState(null),[D,ve]=q.useState(!1),[k,xe]=q.useState(!1),[A,j]=q.useState(!1),Se=q.useMemo(()=>ae(),[]),[Ce,we]=q.useState(``),[De,Oe]=q.useState(0),[ke,Ae]=q.useState(new Set),[je,Ne]=q.useState(null),[Pe,Fe]=q.useState(1),[N,P]=q.useState(`list`),[Ie,Re]=q.useState(null),ze=q.useRef(null),[Ve,He]=q.useState(0),[F,Ue]=q.useState({status:`idle`}),[I,L]=q.useState(!1),R=q.useRef(null),{query:z,setQuery:Ke,cursorOffset:qe}=Be({isActive:N===`search`&&F.status!==`searching`,onExit:()=>{P(`list`),M(`tengu_session_search_toggled`,{enabled:!1})},onExitUp:()=>{P(`list`),M(`tengu_session_search_toggled`,{enabled:!1})},passthroughCtrlKeys:[`n`],initialQuery:g||``}),B=q.useDeferredValue(z),[V,H]=q.useState(``);q.useEffect(()=>{if(!B){H(``);return}let e=setTimeout(H,300,B);return()=>clearTimeout(e)},[B]);let[U,Ye]=q.useState(null),[Xe,Ze]=q.useState(!1);q.useEffect(()=>{Te().then(e=>ge(e)),pe(Se).then(e=>{j(e.length>1)})},[Se]);let Qe=q.useMemo(()=>new Map(e.map(e=>[e,dt(e)])),[e]),$e=q.useMemo(()=>w?new We(e.map(e=>({log:e,searchableText:Qe.get(e)??``})).filter(e=>e.searchableText),{keys:[`searchableText`],threshold:gt,ignoreLocation:!0,includeScore:!0}):null,[e,Qe,w]),et=q.useMemo(()=>pt(e),[e]),W=et.length>0,G=q.useMemo(()=>W?[`All`,...et]:[],[W,et]),K=G.length>0&&Ve<G.length?Ve:0,nt=G[K],rt=nt===`All`?void 0:nt,lt=+!!W,ut=q.useMemo(()=>{let t=e;return C&&(t=e.filter(e=>{let t=ie(),n=b(e);return!!(t&&n===t||e.customTitle||_e(e.messages)||e.firstPrompt||e.customTitle)})),rt!==void 0&&(t=t.filter(e=>e.tag===rt)),D&&E&&(t=t.filter(e=>e.gitBranch===E)),A&&!k&&(t=t.filter(e=>e.projectPath===Se)),t},[e,C,rt,D,E,A,k,Se]),mt=q.useMemo(()=>{if(!z)return ut;let e=z.toLowerCase();return ut.filter(t=>{let n=Ee(t).toLowerCase(),r=(t.gitBranch||``).toLowerCase(),i=(t.tag||``).toLowerCase(),a=t.prNumber?`pr #${t.prNumber} ${t.prRepository||``}`.toLowerCase():``;return n.includes(e)||r.includes(e)||i.includes(e)||a.includes(e)})},[ut,z]);q.useEffect(()=>{w&&B&&B!==V&&Ze(!0)},[B,V,w]),q.useEffect(()=>{if(!w||!V||!$e){Ye(null),Ze(!1);return}let e=setTimeout((e,t,n,r)=>{let i=e.search(t);i.sort((e,t)=>{let n=new Date(e.item.log.modified).getTime(),r=new Date(t.item.log.modified).getTime()-n;return Math.abs(r)>_t?r:(e.score??1)-(t.score??1)}),n({results:i.map(e=>({log:e.item.log,score:e.score,searchableText:e.item.searchableText})),query:t}),r(!1)},0,$e,V,Ye,Ze);return()=>{clearTimeout(e)}},[V,$e,w]);let{filteredLogs:ht,snippets:Y}=q.useMemo(()=>{let e=new Map,t=mt;if(U&&V&&U.query===V){for(let t of U.results)if(t.searchableText){let n=ot(t.searchableText,V,vt);n&&e.set(t.log,n)}let n=new Set(t.map(e=>e.messages[0]?.uuid)),r=U.results.map(e=>e.log).filter(e=>!n.has(e.messages[0]?.uuid));t=[...t,...r]}return{filteredLogs:t,snippets:e}},[mt,U,V]),X=q.useMemo(()=>F.status===`results`&&F.results.length>0?F.results:ht,[F,ht]),Z=Math.max(30,x-4),yt=q.useMemo(()=>{if(!C)return[];let e=ft(X);return Array.from(e.entries()).map(([e,t])=>{let n=t[0],r=X.indexOf(n),i=Y.get(n),a=i?at(i,T):null;if(t.length===1){let t=ct(n,{showProjectPath:_});return{id:`log:${e}:0`,value:{log:n,indexInFiltered:r},label:st(n,Z),description:a?`${t}\n ${a}`:t,dimDescription:!0}}let o=t.length-1,s=t.slice(1).map((t,n)=>{let r=X.indexOf(t),i=Y.get(t),a=i?at(i,T):null,o=ct(t,{isChild:!0,showProjectPath:_});return{id:`log:${e}:${n+1}`,value:{log:t,indexInFiltered:r},label:st(t,Z,{isChild:!0}),description:a?`${o}\n ${a}`:o,dimDescription:!0}}),c=ct(n,{showProjectPath:_});return{id:`group:${e}`,value:{log:n,indexInFiltered:r},label:st(n,Z,{isGroupHeader:!0,forkCount:o}),description:a?`${c}\n ${a}`:c,dimDescription:!0,children:s}})},[C,X,Z,_,Y,T]),bt=q.useMemo(()=>C?[]:X.map((e,t)=>{let n=it(Ee(e)+(e.isSidechain?` (sidechain)`:``),Z),r=Me(e),i=_&&e.projectPath?` · ${e.projectPath}`:``,a=Y.get(e),o=a?at(a,T):null;return{label:n,description:o?`${r}${i}\n ${o}`:r+i,dimDescription:!0,value:t.toString()}}),[C,X,T,Z,_,Y]),Q=je?.value.log??null,xt=()=>{if(!C||!Q)return``;let e=b(Q);if(!e)return``;let t=X.filter(t=>b(t)===e);if(!(t.length>1))return``;let n=ke.has(e);return t.indexOf(Q)>0||n?`← to collapse`:`→ to expand`},St=q.useCallback(async()=>{let e=Q?b(Q):void 0;if(!Q||!e){P(`list`),we(``);return}Ce.trim()&&(await be(e,Ce.trim(),Q.fullPath),C&&h&&h()),P(`list`),we(``)},[Q,Ce,h,C]),Ct=q.useCallback(()=>{P(`list`),M(`tengu_session_search_toggled`,{enabled:!1})},[]),wt=q.useCallback(()=>{P(`search`),M(`tengu_session_search_toggled`,{enabled:!0})},[]),Tt=q.useCallback(async()=>{if(!z.trim()||!y||!he)return;R.current?.abort();let t=new AbortController;R.current=t,Ue({status:`searching`}),M(`tengu_agentic_search_started`,{query_length:z.length});try{let n=await y(z,e,t.signal);if(t.signal.aborted)return;Ue({status:`results`,results:n,query:z}),M(`tengu_agentic_search_completed`,{query_length:z.length,results_count:n.length})}catch(e){if(t.signal.aborted)return;Ue({status:`error`,message:e instanceof Error?e.message:`Search failed`}),M(`tengu_agentic_search_error`,{query_length:z.length})}},[z,y,he,e]);q.useEffect(()=>{F.status!==`idle`&&F.status!==`searching`&&(F.status===`results`&&F.query!==z||F.status===`error`)&&Ue({status:`idle`})},[z,F]),q.useEffect(()=>()=>{R.current?.abort()},[]);let Et=q.useRef(F.status);q.useEffect(()=>{let e=Et.current;if(Et.current=F.status,e===`searching`&&F.status===`results`){if(C&&yt.length>0)Ne(yt[0]);else if(!C&&X.length>0){let e=X[0];Ne({id:`0`,value:{log:e,indexInFiltered:0},label:``})}}},[F.status,C,yt,X]);let Dt=q.useCallback(e=>{let t=parseInt(e,10),n=X[t];!n||ze.current===t.toString()||(ze.current=t.toString(),Ne({id:t.toString(),value:{log:n,indexInFiltered:t},label:``}),Fe(t+1))},[X]),Ot=q.useCallback(e=>{Ne(e);let t=X.findIndex(t=>b(t)===b(e.value.log));t>=0&&Fe(t+1)},[X]);d(`confirm:no`,()=>{R.current?.abort(),Ue({status:`idle`}),M(`tengu_agentic_search_cancelled`,{})},{context:`Confirmation`,isActive:N!==`preview`&&F.status===`searching`}),d(`confirm:no`,()=>{P(`list`),we(``)},{context:`Settings`,isActive:N===`rename`&&F.status!==`searching`}),d(`confirm:no`,()=>{Ke(``),L(!1),o?.()},{context:`Confirmation`,isActive:N!==`preview`&&N!==`rename`&&N!==`search`&&I&&F.status!==`searching`}),ee((e,t)=>{if(N!==`preview`&&F.status!==`searching`&&N!==`rename`)if(N===`search`)e.toLowerCase()===`n`&&t.ctrl?Ct():(t.return||t.downArrow)&&z.trim()&&y&&he&&F.status!==`results`&&L(!0);else{if(I){if(t.return){Tt(),L(!1);return}else if(t.downArrow){L(!1);return}else if(t.upArrow){P(`search`),L(!1);return}}if(W&&t.tab){let e=t.shift?-1:1;He(t=>{let n=((t<G.length?t:0)+G.length+e)%G.length,r=G[n];return M(`tengu_session_tag_filter_changed`,{is_all:r===`All`,tag_count:et.length}),n});return}let n=!t.ctrl&&!t.meta,r=e.toLowerCase();if(r===`a`&&t.ctrl&&v)v(),M(`tengu_session_all_projects_toggled`,{enabled:!_});else if(r===`b`&&t.ctrl){let e=!D;ve(e),M(`tengu_session_branch_filter_toggled`,{enabled:e})}else if(r===`w`&&t.ctrl&&A){let e=!k;xe(e),M(`tengu_session_worktree_filter_toggled`,{enabled:e})}else r===`/`&&n?(P(`search`),M(`tengu_session_search_toggled`,{enabled:!0})):r===`r`&&t.ctrl&&Q?(P(`rename`),we(``),M(`tengu_session_rename_started`,{})):r===`v`&&t.ctrl&&Q?(Re(Q),P(`preview`),M(`tengu_session_preview_opened`,{messageCount:Q.messageCount})):Q&&n&&e.length>0&&!/^\s+$/.test(e)&&(P(`search`),Ke(e),M(`tengu_session_search_toggled`,{enabled:!0}))}},{isActive:!0});let kt=[];D&&E&&kt.push(E),A&&!k&&kt.push(`current worktree`);let At=8+ +(kt.length>0&&N!==`search`)+lt,$=Math.max(1,Math.floor((t-At-2)/3));return q.useEffect(()=>{if(!re)return;let e=$*2;Pe+e>=X.length&&re($*3)},[Pe,$,X.length,re]),e.length===0?null:N===`preview`&&Ie&&C?(0,J.jsx)(Ge,{log:Ie,onExit:()=>{P(`list`),Re(null)},onSelect:m}):(0,J.jsxs)(c,{flexDirection:`column`,height:t-1,children:[(0,J.jsx)(c,{flexShrink:0,children:(0,J.jsx)(i,{color:`suggestion`})}),(0,J.jsx)(c,{flexShrink:0,children:(0,J.jsx)(l,{children:` `})}),W?(0,J.jsx)(Je,{tabs:G,selectedIndex:K,availableWidth:x,showAllProjects:_}):(0,J.jsx)(c,{flexShrink:0,children:(0,J.jsxs)(l,{bold:!0,color:`suggestion`,children:[`Resume Session`,N===`list`&&X.length>$&&(0,J.jsxs)(l,{dimColor:!0,children:[` `,`(`,Pe,` of `,X.length,`)`]})]})}),(0,J.jsx)(te,{query:z,isFocused:N===`search`,isTerminalFocused:S,cursorOffset:qe}),kt.length>0&&N!==`search`&&(0,J.jsx)(c,{flexShrink:0,paddingLeft:2,children:(0,J.jsx)(l,{dimColor:!0,children:(0,J.jsx)(u,{children:kt})})}),(0,J.jsx)(c,{flexShrink:0,children:(0,J.jsx)(l,{children:` `})}),F.status===`searching`&&(0,J.jsxs)(c,{paddingLeft:1,flexShrink:0,children:[(0,J.jsx)(ue,{}),(0,J.jsx)(l,{children:` Searching…`})]}),F.status===`results`&&F.results.length>0&&(0,J.jsx)(c,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(l,{dimColor:!0,italic:!0,children:`Claude found these results:`})}),F.status===`results`&&F.results.length===0&&ht.length===0&&(0,J.jsx)(c,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(l,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),F.status===`error`&&ht.length===0&&(0,J.jsx)(c,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(l,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),!!z.trim()&&y&&he&&F.status!==`searching`&&F.status!==`results`&&F.status!==`error`&&(0,J.jsxs)(c,{flexShrink:0,flexDirection:`column`,children:[(0,J.jsxs)(c,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(l,{color:I?`suggestion`:void 0,children:I?r.pointer:` `}),(0,J.jsx)(l,{color:I?`suggestion`:void 0,bold:I,children:`Search deeply using Claude →`})]}),(0,J.jsx)(c,{height:1})]}),F.status===`searching`?null:N===`rename`&&Q?(0,J.jsxs)(c,{paddingLeft:2,flexDirection:`column`,children:[(0,J.jsx)(l,{bold:!0,children:`Rename session:`}),(0,J.jsx)(c,{paddingTop:1,children:(0,J.jsx)(me,{value:Ce,onChange:we,onSubmit:St,placeholder:Ee(Q,`Enter new session name`),columns:x,cursorOffset:De,onChangeCursorOffset:Oe,showCursor:!0})})]}):C?(0,J.jsx)(tt,{nodes:yt,onSelect:e=>{m(e.value.log)},onFocus:Ot,onCancel:o,focusNodeId:je?.id,visibleOptionCount:$,layout:`expanded`,isDisabled:N===`search`||I,hideIndexes:!1,isNodeExpanded:e=>{if(N===`search`||D)return!0;let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;return t?ke.has(t):!1},onExpand:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&(Ae(e=>new Set(e).add(t)),M(`tengu_session_group_expanded`,{}))},onCollapse:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&Ae(e=>{let n=new Set(e);return n.delete(t),n})},onUpFromFirstItem:wt}):(0,J.jsx)(ye,{options:bt,onChange:e=>{let t=X[parseInt(e,10)];t&&m(t)},visibleOptionCount:$,onCancel:o,onFocus:Dt,defaultFocusValue:je?.id.toString(),layout:`expanded`,isDisabled:N===`search`||I,onUpFromFirstItem:wt}),(0,J.jsx)(c,{paddingLeft:2,children:se.pending?(0,J.jsxs)(l,{dimColor:!0,children:[`Press `,se.keyName,` again to exit`]}):N===`rename`?(0,J.jsx)(l,{dimColor:!0,children:(0,J.jsxs)(u,{children:[(0,J.jsx)(a,{shortcut:`Enter`,action:`save`}),(0,J.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):F.status===`searching`?(0,J.jsx)(l,{dimColor:!0,children:(0,J.jsxs)(u,{children:[(0,J.jsx)(l,{children:`Searching with Claude…`}),(0,J.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):I?(0,J.jsx)(l,{dimColor:!0,children:(0,J.jsxs)(u,{children:[(0,J.jsx)(a,{shortcut:`Enter`,action:`search`}),(0,J.jsx)(a,{shortcut:`↓`,action:`skip`}),(0,J.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):N===`search`?(0,J.jsx)(l,{dimColor:!0,children:(0,J.jsxs)(u,{children:[(0,J.jsx)(l,{children:Xe&&w?`Searching…`:`Type to Search`}),(0,J.jsx)(a,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`clear`})]})}):(0,J.jsx)(l,{dimColor:!0,children:(0,J.jsxs)(u,{children:[v&&(0,J.jsx)(a,{shortcut:`Ctrl+A`,action:`show ${_?`current dir`:`all projects`}`}),E&&(0,J.jsx)(a,{shortcut:`Ctrl+B`,action:`toggle branch`}),A&&(0,J.jsx)(a,{shortcut:`Ctrl+W`,action:`show ${k?`current worktree`:`all worktrees`}`}),(0,J.jsx)(a,{shortcut:`Ctrl+V`,action:`preview`}),(0,J.jsx)(a,{shortcut:`Ctrl+R`,action:`rename`}),(0,J.jsx)(l,{children:`Type to search`}),(0,J.jsx)(O,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),xt()&&(0,J.jsx)(l,{children:xt()})]})})})]})}function ut(e){if(e.type!==`user`&&e.type!==`assistant`)return``;let t=`message`in e?e.message?.content:void 0;return t?typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` `):``:``}function dt(e){let t=(e.messages.length<=Y?e.messages:[...e.messages.slice(0,X),...e.messages.slice(-1e3)]).map(ut).filter(Boolean).join(` `),n=`${[e.customTitle,e.summary,e.firstPrompt,e.gitBranch,e.tag,e.prNumber?`PR #${e.prNumber}`:void 0,e.prRepository].filter(Boolean).join(` `)} ${t}`.trim();return n.length>Z?n.slice(0,Z):n}function ft(e){let t=new Map;for(let n of e){let e=b(n);if(e){let r=t.get(e);r?r.push(n):t.set(e,[n])}}return t.forEach(e=>e.sort((e,t)=>new Date(t.modified).getTime()-new Date(e.modified).getTime())),t}function pt(e){let t=new Set;for(let n of e)n.tag&&t.add(n.tag);return Array.from(t).sort((e,t)=>e.localeCompare(t))}var q,J,mt,ht,Y,X,Z,gt,_t,vt,yt=e((()=>{m(),n(),He(),q=t(h(),1),y(),Re(),Ve(),ge(),g(),Ie(),ke(),je(),se(),we(),De(),D(),le(),T(),ve(),ze(),z(),oe(),G(),C(),rt(),J=v(),mt=2,ht=4,Y=2e3,X=1e3,Z=5e4,gt=.3,_t=60*1e3,vt=50}));function bt(e){if(e.type!==`user`&&e.type!==`assistant`)return``;let t=`message`in e?e.message?.content:void 0;return t?typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` `):``:``}function Q(e){if(e.length===0)return``;let t=(e.length<=wt?e:[...e.slice(0,wt/2),...e.slice(-100/2)]).map(bt).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();return t.length>Ct?t.slice(0,Ct)+`…`:t}function xt(e,t){return!!(Ee(e).toLowerCase().includes(t)||e.customTitle?.toLowerCase().includes(t)||e.tag?.toLowerCase().includes(t)||e.gitBranch?.toLowerCase().includes(t)||e.summary?.toLowerCase().includes(t)||e.firstPrompt?.toLowerCase().includes(t)||e.messages&&e.messages.length>0&&Q(e.messages).toLowerCase().includes(t))}async function St(e,t,n){if(!e.trim()||t.length===0)return[];let r=e.toLowerCase(),i=t.filter(e=>xt(e,r)),a;if(i.length>=Tt)a=i.slice(0,Tt);else{let e=t.filter(e=>!xt(e,r)),n=Tt-i.length;a=[...i,...e.slice(0,n)]}j(`Agentic search: ${a.length}/${t.length} logs, query="${e}", matching: ${i.length}, with messages: ${Ce(a,e=>e.messages?.length>0)}`);let o=a.map(async e=>{if(S(e))try{return await he(e)}catch(t){return Oe(t),e}return e}),s=await Promise.all(o);j(`Agentic search: loaded ${Ce(s,e=>e.messages?.length>0)}/${a.length} logs with transcripts`);let c=`Sessions:
|
|
2
|
+
${s.map((e,t)=>{let n=[`${t}:`],r=Ee(e);if(n.push(r),e.customTitle&&e.customTitle!==r&&n.push(`[custom title: ${e.customTitle}]`),e.tag&&n.push(`[tag: ${e.tag}]`),e.gitBranch&&n.push(`[branch: ${e.gitBranch}]`),e.summary&&n.push(`- Summary: ${e.summary}`),e.firstPrompt&&e.firstPrompt!==`No prompt`&&n.push(`- First message: ${e.firstPrompt.slice(0,300)}`),e.messages&&e.messages.length>0){let t=Q(e.messages);t&&n.push(`- Transcript: ${t}`)}return n.join(` `)}).join(`
|
|
3
|
+
`)}
|
|
4
|
+
|
|
5
|
+
Search query: "${e}"
|
|
6
|
+
|
|
7
|
+
Find the sessions that are most relevant to this query.`;j(`Agentic search prompt (first 500 chars): ${c.slice(0,500)}...`);try{let e=Fe();j(`Agentic search using model: ${e}`);let t=(await x({model:e,system:Et,messages:[{role:`user`,content:c}],signal:n,querySource:`session_search`})).content.find(e=>e.type===`text`);if(!t||t.type!==`text`)return j(`No text content in agentic search response`),[];j(`Agentic search response: ${t.text}`);let r=t.text.match(/\{[\s\S]*\}/);if(!r)return j(`Could not find JSON in agentic search response`),[];let i=(k(r[0]).relevant_indices||[]).filter(e=>e>=0&&e<s.length).map(e=>s[e]);return j(`Agentic search found ${i.length} relevant sessions`),i}catch(e){return Oe(e),j(`Agentic search error: ${e}`),[]}}var Ct,wt,Tt,Et,Dt=e((()=>{Se(),A(),De(),Pe(),D(),fe(),xe(),Ct=2e3,wt=100,Tt=100,Et=`Your goal is to find relevant sessions based on a user's search query.
|
|
8
|
+
|
|
9
|
+
You will be given a list of sessions with their metadata and a search query. Identify which sessions are most relevant to the query.
|
|
10
|
+
|
|
11
|
+
Each session may include:
|
|
12
|
+
- Title (display name or custom title)
|
|
13
|
+
- Tag (user-assigned category, shown as [tag: name] - users tag sessions with /tag command to categorize them)
|
|
14
|
+
- Branch (git branch name, shown as [branch: name])
|
|
15
|
+
- Summary (AI-generated summary)
|
|
16
|
+
- First message (beginning of the conversation)
|
|
17
|
+
- Transcript (excerpt of conversation content)
|
|
18
|
+
|
|
19
|
+
IMPORTANT: Tags are user-assigned labels that indicate the session's topic or category. If the query matches a tag exactly or partially, those sessions should be highly prioritized.
|
|
20
|
+
|
|
21
|
+
For each session, consider (in order of priority):
|
|
22
|
+
1. Exact tag matches (highest priority - user explicitly categorized this session)
|
|
23
|
+
2. Partial tag matches or tag-related terms
|
|
24
|
+
3. Title matches (custom titles or first message content)
|
|
25
|
+
4. Branch name matches
|
|
26
|
+
5. Summary and transcript content matches
|
|
27
|
+
6. Semantic similarity and related concepts
|
|
28
|
+
|
|
29
|
+
CRITICAL: Be VERY inclusive in your matching. Include sessions that:
|
|
30
|
+
- Contain the query term anywhere in any field
|
|
31
|
+
- Are semantically related to the query (e.g., "testing" matches sessions about "tests", "unit tests", "QA", etc.)
|
|
32
|
+
- Discuss topics that could be related to the query
|
|
33
|
+
- Have transcripts that mention the concept even in passing
|
|
34
|
+
|
|
35
|
+
When in doubt, INCLUDE the session. It's better to return too many results than too few. The user can easily scan through results, but missing relevant sessions is frustrating.
|
|
36
|
+
|
|
37
|
+
Return sessions ordered by relevance (most relevant first). If truly no sessions have ANY connection to the query, return an empty array - but this should be rare.
|
|
38
|
+
|
|
39
|
+
Respond with ONLY the JSON object, no markdown formatting:
|
|
40
|
+
{"relevant_indices": [2, 5, 0]}`}));function Ot(e,t,n){let r=ae();if(!t||!e.projectPath||e.projectPath===r)return{isCrossProject:!1};if(process.env.USER_TYPE!==`ant`){let t=b(e);return{isCrossProject:!0,isSameRepoWorktree:!1,command:`cd ${N([e.projectPath])} && claude --resume ${t}`,projectPath:e.projectPath}}if(n.some(t=>e.projectPath===t||e.projectPath.startsWith(t+I)))return{isCrossProject:!0,isSameRepoWorktree:!0,projectPath:e.projectPath};let i=b(e);return{isCrossProject:!0,isSameRepoWorktree:!1,command:`cd ${N([e.projectPath])} && claude --resume ${i}`,projectPath:e.projectPath}}var kt=e((()=>{y(),P(),D()}));export{lt as a,Dt as i,kt as n,yt as o,St as r,Ot as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{f as a,g as o}from"./config-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{f as a,g as o}from"./config-DmomySWC.js";import{o as s,s as c}from"./log-BMCygSzM.js";import{Si as l,W as u,_ as d,r as f,wi as p,z as m}from"./model-CKkOnnnx.js";import{Z as h,et as g}from"./esm-D5q6s4l8.js";import{f as _,p as v}from"./firstPartyEventLogger-CoSUd0a1.js";import{createHash as y}from"crypto";function b(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}async function x(){if(N.length===0)return;let e=N;N=[];try{await r.post(E,e,{headers:{"Content-Type":`application/json`,"DD-API-KEY":D},timeout:A})}catch(e){c(e)}}function S(){P||(P=setTimeout(()=>{P=null,x()},T()).unref())}async function C(){P&&(clearTimeout(P),P=null),await x()}async function w(e,t){if(l()!==`firstParty`)return;let n=F;if(n===null&&(n=await I()),!(!n||!j.has(e)))try{let{envContext:n,...r}=await h({model:t.model,betas:t.betas}),i={...r,...n,...t,userBucket:R()};if(typeof i.toolName==`string`&&i.toolName.startsWith(`mcp__`)&&(i.toolName=`mcp`),process.env.USER_TYPE!==`ant`&&typeof i.model==`string`){let e=f(i.model.replace(/\[1m]$/i,``));i.model=e in m?e:`other`}if(typeof i.version==`string`&&(i.version=i.version.replace(/^(\d+\.\d+\.\d+-dev\.\d{8})\.t\d+\.sha[a-f0-9]+$/,`$1`)),i.status!==void 0&&i.status!==null){let e=String(i.status);i.http_status=e;let t=e.charAt(0);t>=`1`&&t<=`5`&&(i.http_status_range=`${t}xx`),delete i.status}let a=i,o={ddsource:`nodejs`,ddtags:[`event:${e}`,...M.filter(e=>a[e]!==void 0&&a[e]!==null).map(e=>`${b(e)}:${a[e]}`)].join(`,`),message:e,service:`claude-code`,hostname:`claude-code`,env:process.env.USER_TYPE};for(let[e,t]of Object.entries(i))t!=null&&(o[b(e)]=t);N.push(o),N.length>=k?(P&&(clearTimeout(P),P=null),x()):S()}catch(e){c(e)}}function T(){return parseInt(process.env.CLAUDE_CODE_DATADOG_FLUSH_INTERVAL_MS||``,10)||O}var E,D,O,k,A,j,M,N,P,F,I,L,R,z=e((()=>{i(),n(),o(),s(),d(),p(),u(),_(),g(),E=process.env.DATADOG_LOGS_ENDPOINT??``,D=process.env.DATADOG_API_KEY??``,O=15e3,k=100,A=5e3,j=new Set(`tengu_api_error.tengu_api_success.tengu_brief_mode_enabled.tengu_brief_mode_toggled.tengu_brief_send.tengu_cancel.tengu_compact_failed.tengu_exit.tengu_flicker.tengu_init.tengu_model_fallback_triggered.tengu_oauth_error.tengu_oauth_success.tengu_oauth_token_refresh_failure.tengu_oauth_token_refresh_success.tengu_oauth_token_refresh_lock_acquiring.tengu_oauth_token_refresh_lock_acquired.tengu_oauth_token_refresh_starting.tengu_oauth_token_refresh_completed.tengu_oauth_token_refresh_lock_releasing.tengu_oauth_token_refresh_lock_released.tengu_query_error.tengu_session_file_read.tengu_started.tengu_tool_use_error.tengu_tool_use_granted_in_prompt_permanent.tengu_tool_use_granted_in_prompt_temporary.tengu_tool_use_rejected_in_prompt.tengu_tool_use_success.tengu_uncaught_exception.tengu_unhandled_rejection.tengu_voice_recording_started.tengu_voice_toggled.tengu_team_mem_sync_pull.tengu_team_mem_sync_push.tengu_team_mem_sync_started.tengu_team_mem_entries_capped`.split(`.`)),M=[`arch`,`clientType`,`errorType`,`http_status_range`,`http_status`,`kairosActive`,`model`,`platform`,`provider`,`skillMode`,`subscriptionType`,`toolName`,`userBucket`,`userType`,`version`,`versionBase`],N=[],P=null,F=null,I=t(async()=>{if(v()||!E||!D)return F=!1,!1;try{return F=!0,!0}catch(e){return c(e),F=!1,!1}}),L=30,R=t(()=>{let e=a(),t=y(`sha256`).update(e).digest(`hex`);return parseInt(t.slice(0,8),16)%L})}));export{C as n,w as r,z as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{fi as t}from"./src-CDCSSo0U2.js";import{t as n}from"./jsx-runtime-Bb4Xn-E0.js";import{n as r,t as i}from"./DesktopHandoff-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{fi as t}from"./src-CDCSSo0U2.js";import{t as n}from"./jsx-runtime-Bb4Xn-E0.js";import{n as r,t as i}from"./DesktopHandoff-BmPmCfT3.js";async function a(e){return(0,o.jsx)(i,{onDone:e})}var o;e((()=>{t(),r(),o=n()}))();export{a as call};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";var n,r;e((()=>{n=t(),r=async(e,t)=>{let{DiffDialog:r}=await import(`./DiffDialog-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";var n,r;e((()=>{n=t(),r=async(e,t)=>{let{DiffDialog:r}=await import(`./DiffDialog-C4XSSjvV.js`);return(0,n.jsx)(r,{messages:t.messages,onDone:e})}}))();export{r as call};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";import{n,t as r}from"./Doctor-DEQe2q16.js";var i,a;e((()=>{n(),i=t(),a=(e,t,n)=>Promise.resolve((0,i.jsx)(r,{onDone:e}))}))();export{a as call};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{A as n,E as r,I as i,M as a,N as o,P as s,S as c,T as l,b as u,d,g as f,h as p,r as m}from"./lazySchema-DcIJE_0i.js";import{Or as h,Zn as g,_t as _,en as v,kr as y,nt as b,vr as x}from"./state-ix0xIunV.js";import{G as ee,Gy as S,Ky as te,Md as ne,Qi as re,W as ie,Xu as ae,Yu as oe,_f as se,cw as ce,gr as C,i as le,jd as ue,jr as de,lw as fe,o as pe,qi as me,va as he,vf as ge,ya as _e}from"./loadAgentsDir-BURvZNN6.js";import{f as ve,g as ye}from"./settings-DfWP5y6X.js";import{g as be,r as xe}from"./config-DiT2Z8dY.js";import{l as w,p as T,r as Se}from"./sessionStoragePortable-Cx6JQ5Ye.js";import{_ as Ce,u as we}from"./model-BIVmcl_N.js";import{Tn as Te,wn as Ee}from"./prompt-DNDgGM9q.js";import{o as De,t as Oe}from"./fileStateCache-DDW5toIs.js";import{t as ke}from"./QueryEngine-BLcPQYq_.js";import{dirname as Ae}from"node:path";import{randomUUID as E}from"node:crypto";import{Readable as je,Writable as Me}from"node:stream";import{unlink as Ne}from"node:fs/promises";import*as D from"node:path/posix";import{isAbsolute as Pe,resolve as Fe}from"node:path/posix";m();var O={authenticate:`authenticate`,document_did_change:`document/didChange`,document_did_close:`document/didClose`,document_did_focus:`document/didFocus`,document_did_open:`document/didOpen`,document_did_save:`document/didSave`,initialize:`initialize`,logout:`logout`,nes_accept:`nes/accept`,nes_close:`nes/close`,nes_reject:`nes/reject`,nes_start:`nes/start`,nes_suggest:`nes/suggest`,session_cancel:`session/cancel`,session_close:`session/close`,session_fork:`session/fork`,session_list:`session/list`,session_load:`session/load`,session_new:`session/new`,session_prompt:`session/prompt`,session_resume:`session/resume`,session_set_config_option:`session/set_config_option`,session_set_mode:`session/set_mode`,session_set_model:`session/set_model`},k={elicitation_complete:`elicitation/complete`,elicitation_create:`elicitation/create`,fs_read_text_file:`fs/read_text_file`,fs_write_text_file:`fs/write_text_file`,session_request_permission:`session/request_permission`,session_update:`session/update`,terminal_create:`terminal/create`,terminal_kill:`terminal/kill`,terminal_output:`terminal/output`,terminal_release:`terminal/release`,terminal_wait_for_exit:`terminal/wait_for_exit`},Ie=r({_meta:n(a(),s()).nullish(),terminal:f().optional().default(!1)}),Le=r({_meta:n(a(),s()).nullish(),label:a().nullish(),name:a(),optional:f().optional().default(!1),secret:f().optional().default(!0)}),Re=r({_meta:n(a(),s()).nullish(),description:a().nullish(),id:a(),name:a()}),ze=r({_meta:n(a(),s()).nullish(),description:a().nullish(),id:a(),link:a().nullish(),name:a(),vars:p(Le)}),Be=r({_meta:n(a(),s()).nullish(),args:p(a()).optional(),description:a().nullish(),env:n(a(),a()).optional(),id:a(),name:a()}),Ve=o([ze.and(r({type:c(`env_var`)})),Be.and(r({type:c(`terminal`)})),Re]),He=r({_meta:n(a(),s()).nullish(),methodId:a()}),Ue=r({_meta:n(a(),s()).nullish()}),We=r({_meta:n(a(),s()).nullish(),blob:a(),mimeType:a().nullish(),uri:a()}),Ge=r({default:f().nullish(),description:a().nullish(),title:a().nullish()}),Ke=r({_meta:n(a(),s()).nullish()}),qe=r({_meta:n(a(),s()).nullish()}),Je=r({amount:l(),currency:a()}),Ye=r({_meta:n(a(),s()).nullish(),terminalId:a()}),Xe=r({_meta:n(a(),s()).nullish(),newText:a(),oldText:a().nullish(),path:a()}),Ze=o([a(),l(),l(),f(),p(a())]),Qe=u(o([r({content:n(a(),Ze).nullish()}).and(r({action:c(`accept`)})),r({action:c(`decline`)}),r({action:c(`cancel`)})]),r({_meta:n(a(),s()).nullish()})),$e=r({_meta:n(a(),s()).nullish()}),et=a(),tt=r({_meta:n(a(),s()).nullish(),elicitationId:et}),nt=c(`object`),rt=c(`string`),it=r({_meta:n(a(),s()).nullish()}),at=r({_meta:n(a(),s()).nullish(),form:$e.nullish(),url:it.nullish()}),ot=r({const:a(),title:a()}),st=r({_meta:n(a(),s()).nullish(),name:a(),value:a()}),ct=r({code:o([c(-32700),c(-32600),c(-32601),c(-32602),c(-32603),c(-32800),c(-32e3),c(-32002),c(-32042),l().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),data:s().optional(),message:a()}),lt=s(),ut=s(),dt=s(),ft=r({_meta:n(a(),s()).nullish(),readTextFile:f().optional().default(!1),writeTextFile:f().optional().default(!1)}),pt=r({_meta:n(a(),s()).nullish(),name:a(),value:a()}),mt=r({_meta:n(a(),s()).nullish(),name:a(),title:a().nullish(),version:a()}),ht=r({default:l().nullish(),description:a().nullish(),maximum:l().nullish(),minimum:l().nullish(),title:a().nullish()}),gt=r({_meta:n(a(),s()).nullish()}),_t=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cursor:a().nullish(),cwd:a().nullish()}),vt=r({_meta:n(a(),s()).nullish()}),yt=r({_meta:n(a(),s()).nullish(),logout:vt.nullish()}),bt=r({_meta:n(a(),s()).nullish()}),xt=r({_meta:n(a(),s()).nullish()}),St=r({_meta:n(a(),s()).nullish(),http:f().optional().default(!1),sse:f().optional().default(!1)}),Ct=r({_meta:n(a(),s()).nullish(),headers:p(pt),name:a(),url:a()}),wt=r({_meta:n(a(),s()).nullish(),headers:p(pt),name:a(),url:a()}),Tt=r({_meta:n(a(),s()).nullish(),args:p(a()),command:a(),env:p(st),name:a()}),A=o([Ct.and(r({type:c(`http`)})),wt.and(r({type:c(`sse`)})),Tt]),j=a(),Et=r({_meta:n(a(),s()).nullish(),description:a().nullish(),modelId:j,name:a()}),Dt=o([c(`error`),c(`warning`),c(`information`),c(`hint`)]),Ot=r({_meta:n(a(),s()).nullish()}),kt=r({_meta:n(a(),s()).nullish()}),At=r({_meta:n(a(),s()).nullish()}),jt=r({_meta:n(a(),s()).nullish()}),Mt=r({_meta:n(a(),s()).nullish()}),Nt=r({_meta:n(a(),s()).nullish(),maxCount:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Pt=r({diff:a(),uri:a()}),Ft=r({endLine:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),startLine:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),text:a()}),It=r({_meta:n(a(),s()).nullish()}),Lt=r({_meta:n(a(),s()).nullish()}),Rt=r({languageId:a(),text:a(),uri:a()}),zt=r({_meta:n(a(),s()).nullish(),maxCount:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Bt=o([c(`rejected`),c(`ignored`),c(`replaced`),c(`cancelled`)]),Vt=r({excerpts:p(Ft),uri:a()}),Ht=r({_meta:n(a(),s()).nullish()}),Ut=r({_meta:n(a(),s()).nullish()}),Wt=r({name:a(),owner:a(),remoteUrl:a()}),Gt=r({_meta:n(a(),s()).nullish()}),Kt=r({_meta:n(a(),s()).nullish(),jump:It.nullish(),rename:Ut.nullish(),searchAndReplace:Gt.nullish()}),qt=r({id:a(),isRegex:f().nullish(),replace:a(),search:a(),uri:a()}),Jt=o([c(`automatic`),c(`diagnostic`),c(`manual`)]),Yt=r({_meta:n(a(),s()).nullish(),maxCount:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Xt=r({_meta:n(a(),s()).nullish(),diagnostics:Ot.nullish(),editHistory:Nt.nullish(),openFiles:Lt.nullish(),recentFiles:zt.nullish(),relatedSnippets:Ht.nullish(),userActions:Yt.nullish()}),Zt=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),mcpServers:p(A)}),Qt=r({default:l().nullish(),description:a().nullish(),maximum:l().nullish(),minimum:l().nullish(),title:a().nullish()}),$t=a(),en=o([c(`allow_once`),c(`allow_always`),c(`reject_once`),c(`reject_always`)]),tn=r({_meta:n(a(),s()).nullish(),kind:en,name:a(),optionId:$t}),nn=o([c(`high`),c(`medium`),c(`low`)]),rn=o([c(`pending`),c(`in_progress`),c(`completed`)]),an=r({_meta:n(a(),s()).nullish(),content:a(),priority:nn,status:rn}),on=r({_meta:n(a(),s()).nullish(),entries:p(an)}),M=r({character:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),line:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`})}),sn=r({id:a(),position:M,uri:a()}),cn=r({id:a(),newName:a(),position:M,uri:a()}),ln=r({action:a(),position:M,timestampMs:l(),uri:a()}),un=o([c(`utf-16`),c(`utf-32`),c(`utf-8`)]),dn=r({_meta:n(a(),s()).nullish(),auth:Ie.optional().default({terminal:!1}),elicitation:at.nullish(),fs:ft.optional().default({readTextFile:!1,writeTextFile:!1}),nes:Kt.nullish(),positionEncodings:p(un).optional(),terminal:f().optional().default(!1)}),fn=r({_meta:n(a(),s()).nullish(),audio:f().optional().default(!1),embeddedContext:f().optional().default(!1),image:f().optional().default(!1)}),pn=l().int().gte(0).lte(65535),mn=r({_meta:n(a(),s()).nullish(),clientCapabilities:dn.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:mt.nullish(),protocolVersion:pn}),N=r({end:M,start:M}),hn=r({message:a(),range:N,severity:Dt,uri:a()}),gn=r({languageId:a(),lastFocusedMs:l().nullish(),uri:a(),visibleRange:N.nullish()}),_n=r({_meta:n(a(),s()).nullish(),diagnostics:p(hn).nullish(),editHistory:p(Pt).nullish(),openFiles:p(gn).nullish(),recentFiles:p(Rt).nullish(),relatedSnippets:p(Vt).nullish(),userActions:p(ln).nullish()}),vn=r({newText:a(),range:N}),yn=o([r({cursorPosition:M.nullish(),edits:p(vn),id:a(),uri:a()}).and(r({kind:c(`edit`)})),sn.and(r({kind:c(`jump`)})),cn.and(r({kind:c(`rename`)})),qt.and(r({kind:c(`searchAndReplace`)}))]),bn=r({_meta:n(a(),s()).nullish(),content:a()}),xn=r({_meta:n(a(),s()).nullish()}),P=o([l(),a()]).nullable();r({_meta:n(a(),s()).nullish(),requestId:P});var Sn=r({requestId:P}),Cn=d([`assistant`,`user`]),F=r({_meta:n(a(),s()).nullish(),audience:p(Cn).nullish(),lastModified:a().nullish(),priority:l().nullish()}),wn=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),data:a(),mimeType:a()}),Tn=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),data:a(),mimeType:a(),uri:a().nullish()}),En=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),description:a().nullish(),mimeType:a().nullish(),name:a(),size:l().nullish(),title:a().nullish(),uri:a()}),Dn=r({_meta:n(a(),s()).nullish(),optionId:$t}),On=o([r({outcome:c(`cancelled`)}),Dn.and(r({outcome:c(`selected`)}))]),kn=r({_meta:n(a(),s()).nullish(),outcome:On}),An=r({_meta:n(a(),s()).nullish()}),jn=r({_meta:n(a(),s()).nullish()}),Mn=r({currentValue:f()}),Nn=a(),Pn=a(),Fn=o([c(`mode`),c(`model`),c(`thought_level`),a()]),I=a(),In=r({_meta:n(a(),s()).nullish(),description:a().nullish(),name:a(),value:I}),Ln=r({_meta:n(a(),s()).nullish(),group:Nn,name:a(),options:p(In)}),L=u(o([r({currentValue:I,options:o([p(In),p(Ln)])}).and(r({type:c(`select`)})),Mn.and(r({type:c(`boolean`)}))]),r({_meta:n(a(),s()).nullish(),category:Fn.nullish(),description:a().nullish(),id:Pn,name:a()})),Rn=r({_meta:n(a(),s()).nullish(),configOptions:p(L)}),zn=r({_meta:n(a(),s()).nullish()}),R=a(),Bn=r({_meta:n(a(),s()).nullish(),id:a(),sessionId:R}),Vn=r({_meta:n(a(),s()).nullish(),sessionId:R}),Hn=r({_meta:n(a(),s()).nullish(),sessionId:R}),Un=r({_meta:n(a(),s()).nullish(),sessionId:R}),Wn=r({_meta:n(a(),s()).nullish(),args:p(a()).optional(),command:a(),cwd:a().nullish(),env:p(st).optional(),outputByteLimit:l().nullish(),sessionId:R}),Gn=r({_meta:n(a(),s()).nullish(),sessionId:R,uri:a()}),Kn=r({_meta:n(a(),s()).nullish(),position:M,sessionId:R,uri:a(),version:l(),visibleRange:N}),qn=r({_meta:n(a(),s()).nullish(),languageId:a(),sessionId:R,text:a(),uri:a(),version:l()}),Jn=r({_meta:n(a(),s()).nullish(),sessionId:R,uri:a()}),Yn=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),mcpServers:p(A).optional(),sessionId:R}),Xn=r({_meta:n(a(),s()).nullish(),sessionId:R,terminalId:a()}),Zn=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),mcpServers:p(A),sessionId:R}),Qn=r({_meta:n(a(),s()).nullish(),limit:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:a(),sessionId:R}),$n=r({_meta:n(a(),s()).nullish(),id:a(),reason:Bt.nullish(),sessionId:R}),er=r({_meta:n(a(),s()).nullish(),sessionId:R,terminalId:a()}),tr=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),mcpServers:p(A).optional(),sessionId:R}),nr=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),sessionId:R,title:a().nullish(),updatedAt:a().nullish()}),rr=r({_meta:n(a(),s()).nullish(),nextCursor:a().nullish(),sessions:p(nr)}),ir=r({_meta:n(a(),s()).nullish(),title:a().nullish(),updatedAt:a().nullish()}),ar=r({_meta:n(a(),s()).nullish()}),z=a(),or=r({_meta:n(a(),s()).nullish(),currentModeId:z}),sr=r({_meta:n(a(),s()).nullish(),description:a().nullish(),id:z,name:a()}),B=r({_meta:n(a(),s()).nullish(),availableModes:p(sr),currentModeId:z}),V=r({_meta:n(a(),s()).nullish(),availableModels:p(Et),currentModelId:j}),cr=r({_meta:n(a(),s()).nullish(),configOptions:p(L).nullish(),models:V.nullish(),modes:B.nullish(),sessionId:R}),lr=r({_meta:n(a(),s()).nullish(),configOptions:p(L).nullish(),models:V.nullish(),modes:B.nullish()}),ur=r({_meta:n(a(),s()).nullish(),configOptions:p(L).nullish(),models:V.nullish(),modes:B.nullish(),sessionId:R}),dr=r({_meta:n(a(),s()).nullish(),configOptions:p(L).nullish(),models:V.nullish(),modes:B.nullish()}),fr=r({_meta:n(a(),s()).nullish()}),pr=r({_meta:n(a(),s()).nullish(),additionalDirectories:An.nullish(),close:jn.nullish(),fork:zn.nullish(),list:ar.nullish(),resume:fr.nullish()}),mr=u(o([r({type:c(`boolean`),value:f()}),r({value:I})]),r({_meta:n(a(),s()).nullish(),configId:Pn,sessionId:R})),hr=r({_meta:n(a(),s()).nullish(),configOptions:p(L)}),gr=r({_meta:n(a(),s()).nullish(),modeId:z,sessionId:R}),_r=r({_meta:n(a(),s()).nullish()}),vr=r({_meta:n(a(),s()).nullish(),modelId:j,sessionId:R}),yr=r({_meta:n(a(),s()).nullish()}),br=r({_meta:n(a(),s()).nullish(),sessionId:R}),xr=o([c(`end_turn`),c(`max_tokens`),c(`max_turn_requests`),c(`refusal`),c(`cancelled`)]),Sr=o([c(`email`),c(`uri`),c(`date`),c(`date-time`)]),Cr=r({default:a().nullish(),description:a().nullish(),enum:p(a()).nullish(),format:Sr.nullish(),maxLength:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),minLength:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),oneOf:p(ot).nullish(),pattern:a().nullish(),title:a().nullish()}),wr=r({_meta:n(a(),s()).nullish(),context:_n.nullish(),position:M,selection:N.nullish(),sessionId:R,triggerKind:Jt,uri:a(),version:l()}),Tr=r({_meta:n(a(),s()).nullish(),suggestions:p(yn)}),Er=r({_meta:n(a(),s()).nullish(),terminalId:a()}),Dr=r({_meta:n(a(),s()).nullish(),exitCode:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:a().nullish()}),Or=r({_meta:n(a(),s()).nullish(),sessionId:R,terminalId:a()}),kr=r({_meta:n(a(),s()).nullish(),exitStatus:Dr.nullish(),output:a(),truncated:f()}),Ar=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),text:a()}),jr=r({range:N.nullish(),text:a()}),Mr=r({_meta:n(a(),s()).nullish(),contentChanges:p(jr),sessionId:R,uri:a(),version:l()});r({method:a(),params:o([Vn,qn,Mr,Gn,Jn,Kn,Bn,$n,lt]).nullish()});var Nr=o([c(`full`),c(`incremental`)]),Pr=r({_meta:n(a(),s()).nullish(),syncKind:Nr}),Fr=r({_meta:n(a(),s()).nullish(),didChange:Pr.nullish(),didClose:kt.nullish(),didFocus:At.nullish(),didOpen:jt.nullish(),didSave:Mt.nullish()}),Ir=r({_meta:n(a(),s()).nullish(),document:Fr.nullish()}),Lr=r({_meta:n(a(),s()).nullish(),context:Xt.nullish(),events:Ir.nullish()}),Rr=r({_meta:n(a(),s()).nullish(),auth:yt.optional().default({}),loadSession:f().optional().default(!1),mcpCapabilities:St.optional().default({http:!1,sse:!1}),nes:Lr.nullish(),positionEncoding:un.nullish(),promptCapabilities:fn.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:pr.optional().default({})}),zr=r({_meta:n(a(),s()).nullish(),agentCapabilities:Rr.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:mt.nullish(),authMethods:p(Ve).optional().default([]),protocolVersion:pn}),Br=o([r({_meta:n(a(),s()).nullish(),mimeType:a().nullish(),text:a(),uri:a()}),We]),Vr=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),resource:Br}),H=o([Ar.and(r({type:c(`text`)})),Tn.and(r({type:c(`image`)})),wn.and(r({type:c(`audio`)})),En.and(r({type:c(`resource_link`)})),Vr.and(r({type:c(`resource`)}))]),Hr=r({_meta:n(a(),s()).nullish(),content:H}),U=r({_meta:n(a(),s()).nullish(),content:H,messageId:a().nullish()}),Ur=r({_meta:n(a(),s()).nullish(),messageId:a().nullish(),prompt:p(H),sessionId:R}),Wr=r({anyOf:p(ot)}),Gr=o([Hr.and(r({type:c(`content`)})),Xe.and(r({type:c(`diff`)})),Er.and(r({type:c(`terminal`)}))]),W=a(),Kr=r({sessionId:R,toolCallId:W.nullish()}),qr=u(o([Kr,Sn]),r({elicitationId:et,url:a().url()})),Jr=r({_meta:n(a(),s()).nullish(),line:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:a()}),Yr=o([c(`pending`),c(`in_progress`),c(`completed`),c(`failed`)]),Xr=o([c(`read`),c(`edit`),c(`delete`),c(`move`),c(`search`),c(`execute`),c(`think`),c(`fetch`),c(`switch_mode`),c(`other`)]),Zr=r({_meta:n(a(),s()).nullish(),content:p(Gr).optional(),kind:Xr.optional(),locations:p(Jr).optional(),rawInput:s().optional(),rawOutput:s().optional(),status:Yr.optional(),title:a(),toolCallId:W}),Qr=r({_meta:n(a(),s()).nullish(),content:p(Gr).nullish(),kind:Xr.nullish(),locations:p(Jr).nullish(),rawInput:s().optional(),rawOutput:s().optional(),status:Yr.nullish(),title:a().nullish(),toolCallId:W}),$r=r({_meta:n(a(),s()).nullish(),options:p(tn),sessionId:R,toolCall:Qr}),ei=r({_meta:n(a(),s()).nullish(),hint:a()}),ti=r({_meta:n(a(),s()).nullish(),description:a(),input:ei.nullish(),name:a()}),ni=r({_meta:n(a(),s()).nullish(),availableCommands:p(ti)}),ri=o([r({enum:p(a()),type:rt}),Wr]),ii=r({default:p(a()).nullish(),description:a().nullish(),items:ri,maxItems:l().nullish(),minItems:l().nullish(),title:a().nullish()}),ai=o([Cr.and(r({type:c(`string`)})),Qt.and(r({type:c(`number`)})),ht.and(r({type:c(`integer`)})),Ge.and(r({type:c(`boolean`)})),ii.and(r({type:c(`array`)}))]),oi=r({description:a().nullish(),properties:n(a(),ai).optional().default({}),required:p(a()).nullish(),title:a().nullish(),type:nt.optional().default(`object`)}),si=u(o([u(o([Kr,Sn]),r({requestedSchema:oi})).and(r({mode:c(`form`)})),qr.and(r({mode:c(`url`)}))]),r({_meta:n(a(),s()).nullish(),message:a()})),ci=r({cachedReadTokens:l().nullish(),cachedWriteTokens:l().nullish(),inputTokens:l(),outputTokens:l(),thoughtTokens:l().nullish(),totalTokens:l()});o([r({id:P,result:o([zr,Ue,xt,ur,lr,rr,cr,dr,qe,_r,hr,r({_meta:n(a(),s()).nullish(),stopReason:xr,usage:ci.nullish(),userMessageId:a().nullish()}),yr,br,Tr,Ke,dt])}),r({error:ct,id:P})]);var li=r({_meta:n(a(),s()).nullish(),cost:Je.nullish(),size:l(),used:l()}),ui=o([U.and(r({sessionUpdate:c(`user_message_chunk`)})),U.and(r({sessionUpdate:c(`agent_message_chunk`)})),U.and(r({sessionUpdate:c(`agent_thought_chunk`)})),Zr.and(r({sessionUpdate:c(`tool_call`)})),Qr.and(r({sessionUpdate:c(`tool_call_update`)})),on.and(r({sessionUpdate:c(`plan`)})),ni.and(r({sessionUpdate:c(`available_commands_update`)})),or.and(r({sessionUpdate:c(`current_mode_update`)})),Rn.and(r({sessionUpdate:c(`config_option_update`)})),ir.and(r({sessionUpdate:c(`session_info_update`)})),li.and(r({sessionUpdate:c(`usage_update`)}))]),di=r({_meta:n(a(),s()).nullish(),sessionId:R,update:ui});r({method:a(),params:o([di,tt,lt]).nullish()});var fi=r({_meta:n(a(),s()).nullish(),sessionId:R,terminalId:a()}),pi=r({_meta:n(a(),s()).nullish(),exitCode:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:a().nullish()}),mi=r({name:a(),uri:a()}),hi=r({_meta:n(a(),s()).nullish(),repository:Wt.nullish(),workspaceFolders:p(mi).nullish(),workspaceUri:a().nullish()});r({id:P,method:a(),params:o([mn,He,bt,Zt,Zn,_t,Yn,tr,Un,gr,mr,Ur,vr,hi,wr,Hn,ut]).nullish()});var gi=r({_meta:n(a(),s()).nullish(),content:a(),path:a(),sessionId:R});r({id:P,method:a(),params:o([gi,Qn,$r,Wn,Or,er,fi,Xn,si,ut]).nullish()}),o([r({id:P,result:o([r({_meta:n(a(),s()).nullish()}),bn,kn,Ye,kr,xn,pi,gt,Qe,dt])}),r({error:ct,id:P})]),e();function _i(e,t){let n=new TextEncoder,r=new TextDecoder;return{readable:new ReadableStream({async start(e){let n=``,i=t.getReader();try{for(;;){let{value:t,done:a}=await i.read();if(a){n+=r.decode();break}if(!t)continue;n+=r.decode(t,{stream:!0});let o=n.split(`
|
|
1
|
+
import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{A as n,E as r,I as i,M as a,N as o,P as s,S as c,T as l,b as u,d,g as f,h as p,r as m}from"./lazySchema-DcIJE_0i.js";import{Or as h,Zn as g,_t as _,en as v,kr as y,nt as b,vr as x}from"./state-ix0xIunV.js";import{G as ee,Hy as te,Md as ne,Qi as re,Vy as S,W as ie,Xu as ae,Yu as oe,_f as se,aw as ce,gr as C,i as le,iw as ue,jd as de,jr as fe,o as pe,qi as me,va as he,vf as ge,ya as _e}from"./loadAgentsDir-D206qwP3.js";import{f as ve,g as ye}from"./settings-BovzmwMP.js";import{g as be,r as xe}from"./config-DmomySWC.js";import{l as w,p as T,r as Se}from"./sessionStoragePortable-Cx6JQ5Ye.js";import{_ as Ce,u as we}from"./model-CKkOnnnx.js";import{Tn as Te,wn as Ee}from"./prompt-BNHtszmZ.js";import{o as De,t as Oe}from"./fileStateCache-DDW5toIs.js";import{t as ke}from"./QueryEngine-CZZMl3PB.js";import{dirname as Ae}from"node:path";import{randomUUID as E}from"node:crypto";import{Readable as je,Writable as Me}from"node:stream";import{unlink as Ne}from"node:fs/promises";import*as D from"node:path/posix";import{isAbsolute as Pe,resolve as Fe}from"node:path/posix";m();var O={authenticate:`authenticate`,document_did_change:`document/didChange`,document_did_close:`document/didClose`,document_did_focus:`document/didFocus`,document_did_open:`document/didOpen`,document_did_save:`document/didSave`,initialize:`initialize`,logout:`logout`,nes_accept:`nes/accept`,nes_close:`nes/close`,nes_reject:`nes/reject`,nes_start:`nes/start`,nes_suggest:`nes/suggest`,session_cancel:`session/cancel`,session_close:`session/close`,session_fork:`session/fork`,session_list:`session/list`,session_load:`session/load`,session_new:`session/new`,session_prompt:`session/prompt`,session_resume:`session/resume`,session_set_config_option:`session/set_config_option`,session_set_mode:`session/set_mode`,session_set_model:`session/set_model`},k={elicitation_complete:`elicitation/complete`,elicitation_create:`elicitation/create`,fs_read_text_file:`fs/read_text_file`,fs_write_text_file:`fs/write_text_file`,session_request_permission:`session/request_permission`,session_update:`session/update`,terminal_create:`terminal/create`,terminal_kill:`terminal/kill`,terminal_output:`terminal/output`,terminal_release:`terminal/release`,terminal_wait_for_exit:`terminal/wait_for_exit`},Ie=r({_meta:n(a(),s()).nullish(),terminal:f().optional().default(!1)}),Le=r({_meta:n(a(),s()).nullish(),label:a().nullish(),name:a(),optional:f().optional().default(!1),secret:f().optional().default(!0)}),Re=r({_meta:n(a(),s()).nullish(),description:a().nullish(),id:a(),name:a()}),ze=r({_meta:n(a(),s()).nullish(),description:a().nullish(),id:a(),link:a().nullish(),name:a(),vars:p(Le)}),Be=r({_meta:n(a(),s()).nullish(),args:p(a()).optional(),description:a().nullish(),env:n(a(),a()).optional(),id:a(),name:a()}),Ve=o([ze.and(r({type:c(`env_var`)})),Be.and(r({type:c(`terminal`)})),Re]),He=r({_meta:n(a(),s()).nullish(),methodId:a()}),Ue=r({_meta:n(a(),s()).nullish()}),We=r({_meta:n(a(),s()).nullish(),blob:a(),mimeType:a().nullish(),uri:a()}),Ge=r({default:f().nullish(),description:a().nullish(),title:a().nullish()}),Ke=r({_meta:n(a(),s()).nullish()}),qe=r({_meta:n(a(),s()).nullish()}),Je=r({amount:l(),currency:a()}),Ye=r({_meta:n(a(),s()).nullish(),terminalId:a()}),Xe=r({_meta:n(a(),s()).nullish(),newText:a(),oldText:a().nullish(),path:a()}),Ze=o([a(),l(),l(),f(),p(a())]),Qe=u(o([r({content:n(a(),Ze).nullish()}).and(r({action:c(`accept`)})),r({action:c(`decline`)}),r({action:c(`cancel`)})]),r({_meta:n(a(),s()).nullish()})),$e=r({_meta:n(a(),s()).nullish()}),et=a(),tt=r({_meta:n(a(),s()).nullish(),elicitationId:et}),nt=c(`object`),rt=c(`string`),it=r({_meta:n(a(),s()).nullish()}),at=r({_meta:n(a(),s()).nullish(),form:$e.nullish(),url:it.nullish()}),ot=r({const:a(),title:a()}),st=r({_meta:n(a(),s()).nullish(),name:a(),value:a()}),ct=r({code:o([c(-32700),c(-32600),c(-32601),c(-32602),c(-32603),c(-32800),c(-32e3),c(-32002),c(-32042),l().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),data:s().optional(),message:a()}),lt=s(),ut=s(),dt=s(),ft=r({_meta:n(a(),s()).nullish(),readTextFile:f().optional().default(!1),writeTextFile:f().optional().default(!1)}),pt=r({_meta:n(a(),s()).nullish(),name:a(),value:a()}),mt=r({_meta:n(a(),s()).nullish(),name:a(),title:a().nullish(),version:a()}),ht=r({default:l().nullish(),description:a().nullish(),maximum:l().nullish(),minimum:l().nullish(),title:a().nullish()}),gt=r({_meta:n(a(),s()).nullish()}),_t=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cursor:a().nullish(),cwd:a().nullish()}),vt=r({_meta:n(a(),s()).nullish()}),yt=r({_meta:n(a(),s()).nullish(),logout:vt.nullish()}),bt=r({_meta:n(a(),s()).nullish()}),xt=r({_meta:n(a(),s()).nullish()}),St=r({_meta:n(a(),s()).nullish(),http:f().optional().default(!1),sse:f().optional().default(!1)}),Ct=r({_meta:n(a(),s()).nullish(),headers:p(pt),name:a(),url:a()}),wt=r({_meta:n(a(),s()).nullish(),headers:p(pt),name:a(),url:a()}),Tt=r({_meta:n(a(),s()).nullish(),args:p(a()),command:a(),env:p(st),name:a()}),A=o([Ct.and(r({type:c(`http`)})),wt.and(r({type:c(`sse`)})),Tt]),j=a(),Et=r({_meta:n(a(),s()).nullish(),description:a().nullish(),modelId:j,name:a()}),Dt=o([c(`error`),c(`warning`),c(`information`),c(`hint`)]),Ot=r({_meta:n(a(),s()).nullish()}),kt=r({_meta:n(a(),s()).nullish()}),At=r({_meta:n(a(),s()).nullish()}),jt=r({_meta:n(a(),s()).nullish()}),Mt=r({_meta:n(a(),s()).nullish()}),Nt=r({_meta:n(a(),s()).nullish(),maxCount:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Pt=r({diff:a(),uri:a()}),Ft=r({endLine:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),startLine:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),text:a()}),It=r({_meta:n(a(),s()).nullish()}),Lt=r({_meta:n(a(),s()).nullish()}),Rt=r({languageId:a(),text:a(),uri:a()}),zt=r({_meta:n(a(),s()).nullish(),maxCount:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Bt=o([c(`rejected`),c(`ignored`),c(`replaced`),c(`cancelled`)]),Vt=r({excerpts:p(Ft),uri:a()}),Ht=r({_meta:n(a(),s()).nullish()}),Ut=r({_meta:n(a(),s()).nullish()}),Wt=r({name:a(),owner:a(),remoteUrl:a()}),Gt=r({_meta:n(a(),s()).nullish()}),Kt=r({_meta:n(a(),s()).nullish(),jump:It.nullish(),rename:Ut.nullish(),searchAndReplace:Gt.nullish()}),qt=r({id:a(),isRegex:f().nullish(),replace:a(),search:a(),uri:a()}),Jt=o([c(`automatic`),c(`diagnostic`),c(`manual`)]),Yt=r({_meta:n(a(),s()).nullish(),maxCount:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Xt=r({_meta:n(a(),s()).nullish(),diagnostics:Ot.nullish(),editHistory:Nt.nullish(),openFiles:Lt.nullish(),recentFiles:zt.nullish(),relatedSnippets:Ht.nullish(),userActions:Yt.nullish()}),Zt=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),mcpServers:p(A)}),Qt=r({default:l().nullish(),description:a().nullish(),maximum:l().nullish(),minimum:l().nullish(),title:a().nullish()}),$t=a(),en=o([c(`allow_once`),c(`allow_always`),c(`reject_once`),c(`reject_always`)]),tn=r({_meta:n(a(),s()).nullish(),kind:en,name:a(),optionId:$t}),nn=o([c(`high`),c(`medium`),c(`low`)]),rn=o([c(`pending`),c(`in_progress`),c(`completed`)]),an=r({_meta:n(a(),s()).nullish(),content:a(),priority:nn,status:rn}),on=r({_meta:n(a(),s()).nullish(),entries:p(an)}),M=r({character:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),line:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`})}),sn=r({id:a(),position:M,uri:a()}),cn=r({id:a(),newName:a(),position:M,uri:a()}),ln=r({action:a(),position:M,timestampMs:l(),uri:a()}),un=o([c(`utf-16`),c(`utf-32`),c(`utf-8`)]),dn=r({_meta:n(a(),s()).nullish(),auth:Ie.optional().default({terminal:!1}),elicitation:at.nullish(),fs:ft.optional().default({readTextFile:!1,writeTextFile:!1}),nes:Kt.nullish(),positionEncodings:p(un).optional(),terminal:f().optional().default(!1)}),fn=r({_meta:n(a(),s()).nullish(),audio:f().optional().default(!1),embeddedContext:f().optional().default(!1),image:f().optional().default(!1)}),pn=l().int().gte(0).lte(65535),mn=r({_meta:n(a(),s()).nullish(),clientCapabilities:dn.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:mt.nullish(),protocolVersion:pn}),N=r({end:M,start:M}),hn=r({message:a(),range:N,severity:Dt,uri:a()}),gn=r({languageId:a(),lastFocusedMs:l().nullish(),uri:a(),visibleRange:N.nullish()}),_n=r({_meta:n(a(),s()).nullish(),diagnostics:p(hn).nullish(),editHistory:p(Pt).nullish(),openFiles:p(gn).nullish(),recentFiles:p(Rt).nullish(),relatedSnippets:p(Vt).nullish(),userActions:p(ln).nullish()}),vn=r({newText:a(),range:N}),yn=o([r({cursorPosition:M.nullish(),edits:p(vn),id:a(),uri:a()}).and(r({kind:c(`edit`)})),sn.and(r({kind:c(`jump`)})),cn.and(r({kind:c(`rename`)})),qt.and(r({kind:c(`searchAndReplace`)}))]),bn=r({_meta:n(a(),s()).nullish(),content:a()}),xn=r({_meta:n(a(),s()).nullish()}),P=o([l(),a()]).nullable();r({_meta:n(a(),s()).nullish(),requestId:P});var Sn=r({requestId:P}),Cn=d([`assistant`,`user`]),F=r({_meta:n(a(),s()).nullish(),audience:p(Cn).nullish(),lastModified:a().nullish(),priority:l().nullish()}),wn=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),data:a(),mimeType:a()}),Tn=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),data:a(),mimeType:a(),uri:a().nullish()}),En=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),description:a().nullish(),mimeType:a().nullish(),name:a(),size:l().nullish(),title:a().nullish(),uri:a()}),Dn=r({_meta:n(a(),s()).nullish(),optionId:$t}),On=o([r({outcome:c(`cancelled`)}),Dn.and(r({outcome:c(`selected`)}))]),kn=r({_meta:n(a(),s()).nullish(),outcome:On}),An=r({_meta:n(a(),s()).nullish()}),jn=r({_meta:n(a(),s()).nullish()}),Mn=r({currentValue:f()}),Nn=a(),Pn=a(),Fn=o([c(`mode`),c(`model`),c(`thought_level`),a()]),I=a(),In=r({_meta:n(a(),s()).nullish(),description:a().nullish(),name:a(),value:I}),Ln=r({_meta:n(a(),s()).nullish(),group:Nn,name:a(),options:p(In)}),L=u(o([r({currentValue:I,options:o([p(In),p(Ln)])}).and(r({type:c(`select`)})),Mn.and(r({type:c(`boolean`)}))]),r({_meta:n(a(),s()).nullish(),category:Fn.nullish(),description:a().nullish(),id:Pn,name:a()})),Rn=r({_meta:n(a(),s()).nullish(),configOptions:p(L)}),zn=r({_meta:n(a(),s()).nullish()}),R=a(),Bn=r({_meta:n(a(),s()).nullish(),id:a(),sessionId:R}),Vn=r({_meta:n(a(),s()).nullish(),sessionId:R}),Hn=r({_meta:n(a(),s()).nullish(),sessionId:R}),Un=r({_meta:n(a(),s()).nullish(),sessionId:R}),Wn=r({_meta:n(a(),s()).nullish(),args:p(a()).optional(),command:a(),cwd:a().nullish(),env:p(st).optional(),outputByteLimit:l().nullish(),sessionId:R}),Gn=r({_meta:n(a(),s()).nullish(),sessionId:R,uri:a()}),Kn=r({_meta:n(a(),s()).nullish(),position:M,sessionId:R,uri:a(),version:l(),visibleRange:N}),qn=r({_meta:n(a(),s()).nullish(),languageId:a(),sessionId:R,text:a(),uri:a(),version:l()}),Jn=r({_meta:n(a(),s()).nullish(),sessionId:R,uri:a()}),Yn=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),mcpServers:p(A).optional(),sessionId:R}),Xn=r({_meta:n(a(),s()).nullish(),sessionId:R,terminalId:a()}),Zn=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),mcpServers:p(A),sessionId:R}),Qn=r({_meta:n(a(),s()).nullish(),limit:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:a(),sessionId:R}),$n=r({_meta:n(a(),s()).nullish(),id:a(),reason:Bt.nullish(),sessionId:R}),er=r({_meta:n(a(),s()).nullish(),sessionId:R,terminalId:a()}),tr=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),mcpServers:p(A).optional(),sessionId:R}),nr=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),sessionId:R,title:a().nullish(),updatedAt:a().nullish()}),rr=r({_meta:n(a(),s()).nullish(),nextCursor:a().nullish(),sessions:p(nr)}),ir=r({_meta:n(a(),s()).nullish(),title:a().nullish(),updatedAt:a().nullish()}),ar=r({_meta:n(a(),s()).nullish()}),z=a(),or=r({_meta:n(a(),s()).nullish(),currentModeId:z}),sr=r({_meta:n(a(),s()).nullish(),description:a().nullish(),id:z,name:a()}),B=r({_meta:n(a(),s()).nullish(),availableModes:p(sr),currentModeId:z}),V=r({_meta:n(a(),s()).nullish(),availableModels:p(Et),currentModelId:j}),cr=r({_meta:n(a(),s()).nullish(),configOptions:p(L).nullish(),models:V.nullish(),modes:B.nullish(),sessionId:R}),lr=r({_meta:n(a(),s()).nullish(),configOptions:p(L).nullish(),models:V.nullish(),modes:B.nullish()}),ur=r({_meta:n(a(),s()).nullish(),configOptions:p(L).nullish(),models:V.nullish(),modes:B.nullish(),sessionId:R}),dr=r({_meta:n(a(),s()).nullish(),configOptions:p(L).nullish(),models:V.nullish(),modes:B.nullish()}),fr=r({_meta:n(a(),s()).nullish()}),pr=r({_meta:n(a(),s()).nullish(),additionalDirectories:An.nullish(),close:jn.nullish(),fork:zn.nullish(),list:ar.nullish(),resume:fr.nullish()}),mr=u(o([r({type:c(`boolean`),value:f()}),r({value:I})]),r({_meta:n(a(),s()).nullish(),configId:Pn,sessionId:R})),hr=r({_meta:n(a(),s()).nullish(),configOptions:p(L)}),gr=r({_meta:n(a(),s()).nullish(),modeId:z,sessionId:R}),_r=r({_meta:n(a(),s()).nullish()}),vr=r({_meta:n(a(),s()).nullish(),modelId:j,sessionId:R}),yr=r({_meta:n(a(),s()).nullish()}),br=r({_meta:n(a(),s()).nullish(),sessionId:R}),xr=o([c(`end_turn`),c(`max_tokens`),c(`max_turn_requests`),c(`refusal`),c(`cancelled`)]),Sr=o([c(`email`),c(`uri`),c(`date`),c(`date-time`)]),Cr=r({default:a().nullish(),description:a().nullish(),enum:p(a()).nullish(),format:Sr.nullish(),maxLength:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),minLength:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),oneOf:p(ot).nullish(),pattern:a().nullish(),title:a().nullish()}),wr=r({_meta:n(a(),s()).nullish(),context:_n.nullish(),position:M,selection:N.nullish(),sessionId:R,triggerKind:Jt,uri:a(),version:l()}),Tr=r({_meta:n(a(),s()).nullish(),suggestions:p(yn)}),Er=r({_meta:n(a(),s()).nullish(),terminalId:a()}),Dr=r({_meta:n(a(),s()).nullish(),exitCode:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:a().nullish()}),Or=r({_meta:n(a(),s()).nullish(),sessionId:R,terminalId:a()}),kr=r({_meta:n(a(),s()).nullish(),exitStatus:Dr.nullish(),output:a(),truncated:f()}),Ar=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),text:a()}),jr=r({range:N.nullish(),text:a()}),Mr=r({_meta:n(a(),s()).nullish(),contentChanges:p(jr),sessionId:R,uri:a(),version:l()});r({method:a(),params:o([Vn,qn,Mr,Gn,Jn,Kn,Bn,$n,lt]).nullish()});var Nr=o([c(`full`),c(`incremental`)]),Pr=r({_meta:n(a(),s()).nullish(),syncKind:Nr}),Fr=r({_meta:n(a(),s()).nullish(),didChange:Pr.nullish(),didClose:kt.nullish(),didFocus:At.nullish(),didOpen:jt.nullish(),didSave:Mt.nullish()}),Ir=r({_meta:n(a(),s()).nullish(),document:Fr.nullish()}),Lr=r({_meta:n(a(),s()).nullish(),context:Xt.nullish(),events:Ir.nullish()}),Rr=r({_meta:n(a(),s()).nullish(),auth:yt.optional().default({}),loadSession:f().optional().default(!1),mcpCapabilities:St.optional().default({http:!1,sse:!1}),nes:Lr.nullish(),positionEncoding:un.nullish(),promptCapabilities:fn.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:pr.optional().default({})}),zr=r({_meta:n(a(),s()).nullish(),agentCapabilities:Rr.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:mt.nullish(),authMethods:p(Ve).optional().default([]),protocolVersion:pn}),Br=o([r({_meta:n(a(),s()).nullish(),mimeType:a().nullish(),text:a(),uri:a()}),We]),Vr=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),resource:Br}),H=o([Ar.and(r({type:c(`text`)})),Tn.and(r({type:c(`image`)})),wn.and(r({type:c(`audio`)})),En.and(r({type:c(`resource_link`)})),Vr.and(r({type:c(`resource`)}))]),Hr=r({_meta:n(a(),s()).nullish(),content:H}),U=r({_meta:n(a(),s()).nullish(),content:H,messageId:a().nullish()}),Ur=r({_meta:n(a(),s()).nullish(),messageId:a().nullish(),prompt:p(H),sessionId:R}),Wr=r({anyOf:p(ot)}),Gr=o([Hr.and(r({type:c(`content`)})),Xe.and(r({type:c(`diff`)})),Er.and(r({type:c(`terminal`)}))]),W=a(),Kr=r({sessionId:R,toolCallId:W.nullish()}),qr=u(o([Kr,Sn]),r({elicitationId:et,url:a().url()})),Jr=r({_meta:n(a(),s()).nullish(),line:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:a()}),Yr=o([c(`pending`),c(`in_progress`),c(`completed`),c(`failed`)]),Xr=o([c(`read`),c(`edit`),c(`delete`),c(`move`),c(`search`),c(`execute`),c(`think`),c(`fetch`),c(`switch_mode`),c(`other`)]),Zr=r({_meta:n(a(),s()).nullish(),content:p(Gr).optional(),kind:Xr.optional(),locations:p(Jr).optional(),rawInput:s().optional(),rawOutput:s().optional(),status:Yr.optional(),title:a(),toolCallId:W}),Qr=r({_meta:n(a(),s()).nullish(),content:p(Gr).nullish(),kind:Xr.nullish(),locations:p(Jr).nullish(),rawInput:s().optional(),rawOutput:s().optional(),status:Yr.nullish(),title:a().nullish(),toolCallId:W}),$r=r({_meta:n(a(),s()).nullish(),options:p(tn),sessionId:R,toolCall:Qr}),ei=r({_meta:n(a(),s()).nullish(),hint:a()}),ti=r({_meta:n(a(),s()).nullish(),description:a(),input:ei.nullish(),name:a()}),ni=r({_meta:n(a(),s()).nullish(),availableCommands:p(ti)}),ri=o([r({enum:p(a()),type:rt}),Wr]),ii=r({default:p(a()).nullish(),description:a().nullish(),items:ri,maxItems:l().nullish(),minItems:l().nullish(),title:a().nullish()}),ai=o([Cr.and(r({type:c(`string`)})),Qt.and(r({type:c(`number`)})),ht.and(r({type:c(`integer`)})),Ge.and(r({type:c(`boolean`)})),ii.and(r({type:c(`array`)}))]),oi=r({description:a().nullish(),properties:n(a(),ai).optional().default({}),required:p(a()).nullish(),title:a().nullish(),type:nt.optional().default(`object`)}),si=u(o([u(o([Kr,Sn]),r({requestedSchema:oi})).and(r({mode:c(`form`)})),qr.and(r({mode:c(`url`)}))]),r({_meta:n(a(),s()).nullish(),message:a()})),ci=r({cachedReadTokens:l().nullish(),cachedWriteTokens:l().nullish(),inputTokens:l(),outputTokens:l(),thoughtTokens:l().nullish(),totalTokens:l()});o([r({id:P,result:o([zr,Ue,xt,ur,lr,rr,cr,dr,qe,_r,hr,r({_meta:n(a(),s()).nullish(),stopReason:xr,usage:ci.nullish(),userMessageId:a().nullish()}),yr,br,Tr,Ke,dt])}),r({error:ct,id:P})]);var li=r({_meta:n(a(),s()).nullish(),cost:Je.nullish(),size:l(),used:l()}),ui=o([U.and(r({sessionUpdate:c(`user_message_chunk`)})),U.and(r({sessionUpdate:c(`agent_message_chunk`)})),U.and(r({sessionUpdate:c(`agent_thought_chunk`)})),Zr.and(r({sessionUpdate:c(`tool_call`)})),Qr.and(r({sessionUpdate:c(`tool_call_update`)})),on.and(r({sessionUpdate:c(`plan`)})),ni.and(r({sessionUpdate:c(`available_commands_update`)})),or.and(r({sessionUpdate:c(`current_mode_update`)})),Rn.and(r({sessionUpdate:c(`config_option_update`)})),ir.and(r({sessionUpdate:c(`session_info_update`)})),li.and(r({sessionUpdate:c(`usage_update`)}))]),di=r({_meta:n(a(),s()).nullish(),sessionId:R,update:ui});r({method:a(),params:o([di,tt,lt]).nullish()});var fi=r({_meta:n(a(),s()).nullish(),sessionId:R,terminalId:a()}),pi=r({_meta:n(a(),s()).nullish(),exitCode:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:a().nullish()}),mi=r({name:a(),uri:a()}),hi=r({_meta:n(a(),s()).nullish(),repository:Wt.nullish(),workspaceFolders:p(mi).nullish(),workspaceUri:a().nullish()});r({id:P,method:a(),params:o([mn,He,bt,Zt,Zn,_t,Yn,tr,Un,gr,mr,Ur,vr,hi,wr,Hn,ut]).nullish()});var gi=r({_meta:n(a(),s()).nullish(),content:a(),path:a(),sessionId:R});r({id:P,method:a(),params:o([gi,Qn,$r,Wn,Or,er,fi,Xn,si,ut]).nullish()}),o([r({id:P,result:o([r({_meta:n(a(),s()).nullish()}),bn,kn,Ye,kr,xn,pi,gt,Qe,dt])}),r({error:ct,id:P})]),e();function _i(e,t){let n=new TextEncoder,r=new TextDecoder;return{readable:new ReadableStream({async start(e){let n=``,i=t.getReader();try{for(;;){let{value:t,done:a}=await i.read();if(a){n+=r.decode();break}if(!t)continue;n+=r.decode(t,{stream:!0});let o=n.split(`
|
|
2
2
|
`);n=o.pop()||``;for(let t of o){let n=t.trim();if(n)try{let t=JSON.parse(n);e.enqueue(t)}catch(e){console.error(`Failed to parse JSON message:`,n,e)}}}let t=n.trim();if(t)try{let n=JSON.parse(t);e.enqueue(n)}catch(e){console.error(`Failed to parse JSON message:`,t,e)}}catch(t){e.error(t);return}finally{i.releaseLock()}e.close()}}),writable:new WritableStream({async write(t){let r=JSON.stringify(t)+`
|
|
3
|
-
`,i=e.getWriter();try{await i.write(n.encode(r))}finally{i.releaseLock()}}})}}m();var vi,yi=class{constructor(e,n){t(this,`connection`,void 0);let r=e(this),i=async(e,t)=>{switch(e){case O.initialize:{let e=mn.parse(t);return r.initialize(e)}case O.session_new:{let e=Zt.parse(t);return r.newSession(e)}case O.session_load:{if(!r.loadSession)throw G.methodNotFound(e);let n=Zn.parse(t);return r.loadSession(n)}case O.session_list:{if(!r.listSessions)throw G.methodNotFound(e);let n=_t.parse(t);return r.listSessions(n)}case O.session_fork:{if(!r.unstable_forkSession)throw G.methodNotFound(e);let n=Yn.parse(t);return r.unstable_forkSession(n)}case O.session_resume:{if(!r.unstable_resumeSession)throw G.methodNotFound(e);let n=tr.parse(t);return r.unstable_resumeSession(n)}case O.session_close:{if(!r.unstable_closeSession)throw G.methodNotFound(e);let n=Un.parse(t);return r.unstable_closeSession(n)}case O.session_set_mode:{if(!r.setSessionMode)throw G.methodNotFound(e);let n=gr.parse(t);return await r.setSessionMode(n)??{}}case O.authenticate:{let e=He.parse(t);return await r.authenticate(e)??{}}case O.logout:{if(!r.unstable_logout)throw G.methodNotFound(e);let n=bt.parse(t);return await r.unstable_logout(n)??{}}case O.session_prompt:{let e=Ur.parse(t);return r.prompt(e)}case O.session_set_model:{if(!r.unstable_setSessionModel)throw G.methodNotFound(e);let n=vr.parse(t);return await r.unstable_setSessionModel(n)??{}}case O.session_set_config_option:{if(!r.setSessionConfigOption)throw G.methodNotFound(e);let n=mr.parse(t);return r.setSessionConfigOption(n)}case O.nes_start:{if(!r.unstable_startNes)throw G.methodNotFound(e);let n=hi.parse(t);return r.unstable_startNes(n)}case O.nes_suggest:{if(!r.unstable_suggestNes)throw G.methodNotFound(e);let n=wr.parse(t);return r.unstable_suggestNes(n)}case O.nes_close:{if(!r.unstable_closeNes)throw G.methodNotFound(e);let n=Hn.parse(t);return await r.unstable_closeNes(n)??{}}default:if(r.extMethod)return r.extMethod(e,t);throw G.methodNotFound(e)}},a=async(e,t)=>{switch(e){case O.session_cancel:{let e=Vn.parse(t);return r.cancel(e)}case O.document_did_open:{if(!r.unstable_didOpenDocument)return;let e=qn.parse(t);return r.unstable_didOpenDocument(e)}case O.document_did_change:{if(!r.unstable_didChangeDocument)return;let e=Mr.parse(t);return r.unstable_didChangeDocument(e)}case O.document_did_close:{if(!r.unstable_didCloseDocument)return;let e=Gn.parse(t);return r.unstable_didCloseDocument(e)}case O.document_did_save:{if(!r.unstable_didSaveDocument)return;let e=Jn.parse(t);return r.unstable_didSaveDocument(e)}case O.document_did_focus:{if(!r.unstable_didFocusDocument)return;let e=Kn.parse(t);return r.unstable_didFocusDocument(e)}case O.nes_accept:{if(!r.unstable_acceptNes)return;let e=Bn.parse(t);return r.unstable_acceptNes(e)}case O.nes_reject:{if(!r.unstable_rejectNes)return;let e=$n.parse(t);return r.unstable_rejectNes(e)}default:if(r.extNotification)return r.extNotification(e,t);throw G.methodNotFound(e)}};this.connection=new xi(i,a,n)}async sessionUpdate(e){return await this.connection.sendNotification(k.session_update,e)}async requestPermission(e){return await this.connection.sendRequest(k.session_request_permission,e)}async readTextFile(e){return await this.connection.sendRequest(k.fs_read_text_file,e)}async writeTextFile(e){return await this.connection.sendRequest(k.fs_write_text_file,e)??{}}async createTerminal(e){return new bi((await this.connection.sendRequest(k.terminal_create,e)).terminalId,e.sessionId,this.connection)}async unstable_createElicitation(e){return await this.connection.sendRequest(k.elicitation_create,e)}async unstable_completeElicitation(e){return await this.connection.sendNotification(k.elicitation_complete,e)}async extMethod(e,t){return await this.connection.sendRequest(e,t)}async extNotification(e,t){return await this.connection.sendNotification(e,t)}get signal(){return this.connection.signal}get closed(){return this.connection.closed}};vi=Symbol.asyncDispose;var bi=class{constructor(e,n,r){t(this,`id`,void 0),t(this,`sessionId`,void 0),t(this,`connection`,void 0),this.id=e,this.sessionId=n,this.connection=r}async currentOutput(){return await this.connection.sendRequest(k.terminal_output,{sessionId:this.sessionId,terminalId:this.id})}async waitForExit(){return await this.connection.sendRequest(k.terminal_wait_for_exit,{sessionId:this.sessionId,terminalId:this.id})}async kill(){return await this.connection.sendRequest(k.terminal_kill,{sessionId:this.sessionId,terminalId:this.id})??{}}async release(){return await this.connection.sendRequest(k.terminal_release,{sessionId:this.sessionId,terminalId:this.id})??{}}async[vi](){await this.release()}},xi=class{constructor(e,n,r){t(this,`pendingResponses`,new Map),t(this,`nextRequestId`,0),t(this,`requestHandler`,void 0),t(this,`notificationHandler`,void 0),t(this,`stream`,void 0),t(this,`writeQueue`,Promise.resolve()),t(this,`abortController`,new AbortController),t(this,`closedPromise`,void 0),this.requestHandler=e,this.notificationHandler=n,this.stream=r,this.closedPromise=new Promise(e=>{this.abortController.signal.addEventListener(`abort`,()=>e())}),this.receive()}get signal(){return this.abortController.signal}get closed(){return this.closedPromise}async receive(){let e;try{let e=this.stream.readable.getReader();try{for(;!this.abortController.signal.aborted;){let{value:t,done:n}=await e.read();if(n)break;if(t)try{this.processMessage(t)}catch(e){console.error(`Unexpected error during message processing:`,t,e),`id`in t&&t.id!==void 0&&this.sendMessage({jsonrpc:`2.0`,id:t.id,error:{code:-32700,message:`Parse error`}})}}}finally{e.releaseLock()}}catch(t){e=t}finally{this.close(e)}}close(e){if(this.abortController.signal.aborted)return;let t=e??Error(`ACP connection closed`);for(let e of this.pendingResponses.values())e.reject(t);this.pendingResponses.clear(),this.abortController.abort(t)}async processMessage(e){if(`method`in e&&`id`in e){let t=await this.tryCallRequestHandler(e.method,e.params);`error`in t&&console.error(`Error handling request`,e,t.error),await this.sendMessage({jsonrpc:`2.0`,id:e.id,...t})}else if(`method`in e){let t=await this.tryCallNotificationHandler(e.method,e.params);`error`in t&&console.error(`Error handling notification`,e,t.error)}else`id`in e?this.handleResponse(e):console.error(`Invalid message`,{message:e})}async tryCallRequestHandler(e,t){try{return{result:await this.requestHandler(e,t)??null}}catch(e){if(e instanceof G)return e.toResult();if(e instanceof i)return G.invalidParams(e.format()).toResult();let t;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(t=e.message);try{return G.internalError(t?JSON.parse(t):{}).toResult()}catch{return G.internalError({details:t}).toResult()}}}async tryCallNotificationHandler(e,t){try{return await this.notificationHandler(e,t),{result:null}}catch(e){if(e instanceof G)return e.toResult();if(e instanceof i)return G.invalidParams(e.format()).toResult();let t;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(t=e.message);try{return G.internalError(t?JSON.parse(t):{}).toResult()}catch{return G.internalError({details:t}).toResult()}}}handleResponse(e){let t=this.pendingResponses.get(e.id);if(t){if(`result`in e)t.resolve(e.result);else if(`error`in e){let{code:n,message:r,data:i}=e.error;t.reject(new G(n,r,i))}this.pendingResponses.delete(e.id)}else console.error(`Got response to unknown request`,e.id)}sendRequest(e,t){this.throwIfClosed();let n=this.nextRequestId++,r=new Promise((e,t)=>{this.pendingResponses.set(n,{resolve:e,reject:t})});return r.catch(()=>{}),this.sendMessage({jsonrpc:`2.0`,id:n,method:e,params:t}),r}async sendNotification(e,t){this.throwIfClosed(),await this.sendMessage({jsonrpc:`2.0`,method:e,params:t})}throwIfClosed(){if(this.abortController.signal.aborted)throw this.abortController.signal.reason??Error(`ACP connection closed`)}async sendMessage(e){return this.writeQueue=this.writeQueue.then(async()=>{let t=this.stream.writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(e=>{this.close(e)}),this.writeQueue}},G=class e extends Error{constructor(e,n,r){super(n),t(this,`code`,void 0),t(this,`data`,void 0),this.code=e,this.name=`RequestError`,this.data=r}static parseError(t,n){return new e(-32700,`Parse error${n?`: ${n}`:``}`,t)}static invalidRequest(t,n){return new e(-32600,`Invalid request${n?`: ${n}`:``}`,t)}static methodNotFound(t){return new e(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,n){return new e(-32602,`Invalid params${n?`: ${n}`:``}`,t)}static internalError(t,n){return new e(-32603,`Internal error${n?`: ${n}`:``}`,t)}static authRequired(t,n){return new e(-32e3,`Authentication required${n?`: ${n}`:``}`,t)}static resourceNotFound(t){return new e(-32002,`Resource not found${t?`: ${t}`:``}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}};h(),v(),ye(),be(),Te(),De(),fe(),ae(),_e(),re(),ee(),pe();function K(e,t){if(e)return t?Pe(e)?e:Fe(t,e):e}var Si=!(typeof process.geteuid==`function`?process.geteuid()===0:typeof process.getuid==`function`&&process.getuid()===0)||!!process.env.IS_SANDBOX,Ci={auto:`auto`,default:`default`,acceptedits:`acceptEdits`,dontask:`dontAsk`,plan:`plan`,bypasspermissions:`bypassPermissions`,bypass:`bypassPermissions`};function wi(e,t=`permissions.defaultMode`){if(e===void 0)return`default`;if(typeof e!=`string`)throw Error(`Invalid ${t}: expected a string.`);let n=e.trim().toLowerCase();if(n===``)throw Error(`Invalid ${t}: expected a non-empty string.`);let r=Ci[n];if(!r)throw Error(`Invalid ${t}: ${e}.`);if(r===`bypassPermissions`&&!Si)throw Error(`Invalid ${t}: bypassPermissions is not available when running as root.`);return r}function Ti(e){let t=[...e.mcpServers??[]].sort((e,t)=>e.name.localeCompare(t.name));return JSON.stringify({cwd:e.cwd,mcpServers:t})}var Ei=256;function Di(e){let t=e.replace(/[\r\n]+/g,` `).replace(/\s+/g,` `).trim();return t.length<=Ei?t:t.slice(0,Ei-1)+`…`}function q(e,t){if(!t)return e;let n=D.resolve(t),r=D.resolve(e);return r.startsWith(n+D.sep)||r===n?D.relative(n,r):e}function Oi(e){let t="```";for(let n of e.matchAll(/^```+/gm)??[])for(;n[0].length>=t.length;)t+="`";return t+`
|
|
3
|
+
`,i=e.getWriter();try{await i.write(n.encode(r))}finally{i.releaseLock()}}})}}m();var vi,yi=class{constructor(e,n){t(this,`connection`,void 0);let r=e(this),i=async(e,t)=>{switch(e){case O.initialize:{let e=mn.parse(t);return r.initialize(e)}case O.session_new:{let e=Zt.parse(t);return r.newSession(e)}case O.session_load:{if(!r.loadSession)throw G.methodNotFound(e);let n=Zn.parse(t);return r.loadSession(n)}case O.session_list:{if(!r.listSessions)throw G.methodNotFound(e);let n=_t.parse(t);return r.listSessions(n)}case O.session_fork:{if(!r.unstable_forkSession)throw G.methodNotFound(e);let n=Yn.parse(t);return r.unstable_forkSession(n)}case O.session_resume:{if(!r.unstable_resumeSession)throw G.methodNotFound(e);let n=tr.parse(t);return r.unstable_resumeSession(n)}case O.session_close:{if(!r.unstable_closeSession)throw G.methodNotFound(e);let n=Un.parse(t);return r.unstable_closeSession(n)}case O.session_set_mode:{if(!r.setSessionMode)throw G.methodNotFound(e);let n=gr.parse(t);return await r.setSessionMode(n)??{}}case O.authenticate:{let e=He.parse(t);return await r.authenticate(e)??{}}case O.logout:{if(!r.unstable_logout)throw G.methodNotFound(e);let n=bt.parse(t);return await r.unstable_logout(n)??{}}case O.session_prompt:{let e=Ur.parse(t);return r.prompt(e)}case O.session_set_model:{if(!r.unstable_setSessionModel)throw G.methodNotFound(e);let n=vr.parse(t);return await r.unstable_setSessionModel(n)??{}}case O.session_set_config_option:{if(!r.setSessionConfigOption)throw G.methodNotFound(e);let n=mr.parse(t);return r.setSessionConfigOption(n)}case O.nes_start:{if(!r.unstable_startNes)throw G.methodNotFound(e);let n=hi.parse(t);return r.unstable_startNes(n)}case O.nes_suggest:{if(!r.unstable_suggestNes)throw G.methodNotFound(e);let n=wr.parse(t);return r.unstable_suggestNes(n)}case O.nes_close:{if(!r.unstable_closeNes)throw G.methodNotFound(e);let n=Hn.parse(t);return await r.unstable_closeNes(n)??{}}default:if(r.extMethod)return r.extMethod(e,t);throw G.methodNotFound(e)}},a=async(e,t)=>{switch(e){case O.session_cancel:{let e=Vn.parse(t);return r.cancel(e)}case O.document_did_open:{if(!r.unstable_didOpenDocument)return;let e=qn.parse(t);return r.unstable_didOpenDocument(e)}case O.document_did_change:{if(!r.unstable_didChangeDocument)return;let e=Mr.parse(t);return r.unstable_didChangeDocument(e)}case O.document_did_close:{if(!r.unstable_didCloseDocument)return;let e=Gn.parse(t);return r.unstable_didCloseDocument(e)}case O.document_did_save:{if(!r.unstable_didSaveDocument)return;let e=Jn.parse(t);return r.unstable_didSaveDocument(e)}case O.document_did_focus:{if(!r.unstable_didFocusDocument)return;let e=Kn.parse(t);return r.unstable_didFocusDocument(e)}case O.nes_accept:{if(!r.unstable_acceptNes)return;let e=Bn.parse(t);return r.unstable_acceptNes(e)}case O.nes_reject:{if(!r.unstable_rejectNes)return;let e=$n.parse(t);return r.unstable_rejectNes(e)}default:if(r.extNotification)return r.extNotification(e,t);throw G.methodNotFound(e)}};this.connection=new xi(i,a,n)}async sessionUpdate(e){return await this.connection.sendNotification(k.session_update,e)}async requestPermission(e){return await this.connection.sendRequest(k.session_request_permission,e)}async readTextFile(e){return await this.connection.sendRequest(k.fs_read_text_file,e)}async writeTextFile(e){return await this.connection.sendRequest(k.fs_write_text_file,e)??{}}async createTerminal(e){return new bi((await this.connection.sendRequest(k.terminal_create,e)).terminalId,e.sessionId,this.connection)}async unstable_createElicitation(e){return await this.connection.sendRequest(k.elicitation_create,e)}async unstable_completeElicitation(e){return await this.connection.sendNotification(k.elicitation_complete,e)}async extMethod(e,t){return await this.connection.sendRequest(e,t)}async extNotification(e,t){return await this.connection.sendNotification(e,t)}get signal(){return this.connection.signal}get closed(){return this.connection.closed}};vi=Symbol.asyncDispose;var bi=class{constructor(e,n,r){t(this,`id`,void 0),t(this,`sessionId`,void 0),t(this,`connection`,void 0),this.id=e,this.sessionId=n,this.connection=r}async currentOutput(){return await this.connection.sendRequest(k.terminal_output,{sessionId:this.sessionId,terminalId:this.id})}async waitForExit(){return await this.connection.sendRequest(k.terminal_wait_for_exit,{sessionId:this.sessionId,terminalId:this.id})}async kill(){return await this.connection.sendRequest(k.terminal_kill,{sessionId:this.sessionId,terminalId:this.id})??{}}async release(){return await this.connection.sendRequest(k.terminal_release,{sessionId:this.sessionId,terminalId:this.id})??{}}async[vi](){await this.release()}},xi=class{constructor(e,n,r){t(this,`pendingResponses`,new Map),t(this,`nextRequestId`,0),t(this,`requestHandler`,void 0),t(this,`notificationHandler`,void 0),t(this,`stream`,void 0),t(this,`writeQueue`,Promise.resolve()),t(this,`abortController`,new AbortController),t(this,`closedPromise`,void 0),this.requestHandler=e,this.notificationHandler=n,this.stream=r,this.closedPromise=new Promise(e=>{this.abortController.signal.addEventListener(`abort`,()=>e())}),this.receive()}get signal(){return this.abortController.signal}get closed(){return this.closedPromise}async receive(){let e;try{let e=this.stream.readable.getReader();try{for(;!this.abortController.signal.aborted;){let{value:t,done:n}=await e.read();if(n)break;if(t)try{this.processMessage(t)}catch(e){console.error(`Unexpected error during message processing:`,t,e),`id`in t&&t.id!==void 0&&this.sendMessage({jsonrpc:`2.0`,id:t.id,error:{code:-32700,message:`Parse error`}})}}}finally{e.releaseLock()}}catch(t){e=t}finally{this.close(e)}}close(e){if(this.abortController.signal.aborted)return;let t=e??Error(`ACP connection closed`);for(let e of this.pendingResponses.values())e.reject(t);this.pendingResponses.clear(),this.abortController.abort(t)}async processMessage(e){if(`method`in e&&`id`in e){let t=await this.tryCallRequestHandler(e.method,e.params);`error`in t&&console.error(`Error handling request`,e,t.error),await this.sendMessage({jsonrpc:`2.0`,id:e.id,...t})}else if(`method`in e){let t=await this.tryCallNotificationHandler(e.method,e.params);`error`in t&&console.error(`Error handling notification`,e,t.error)}else`id`in e?this.handleResponse(e):console.error(`Invalid message`,{message:e})}async tryCallRequestHandler(e,t){try{return{result:await this.requestHandler(e,t)??null}}catch(e){if(e instanceof G)return e.toResult();if(e instanceof i)return G.invalidParams(e.format()).toResult();let t;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(t=e.message);try{return G.internalError(t?JSON.parse(t):{}).toResult()}catch{return G.internalError({details:t}).toResult()}}}async tryCallNotificationHandler(e,t){try{return await this.notificationHandler(e,t),{result:null}}catch(e){if(e instanceof G)return e.toResult();if(e instanceof i)return G.invalidParams(e.format()).toResult();let t;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(t=e.message);try{return G.internalError(t?JSON.parse(t):{}).toResult()}catch{return G.internalError({details:t}).toResult()}}}handleResponse(e){let t=this.pendingResponses.get(e.id);if(t){if(`result`in e)t.resolve(e.result);else if(`error`in e){let{code:n,message:r,data:i}=e.error;t.reject(new G(n,r,i))}this.pendingResponses.delete(e.id)}else console.error(`Got response to unknown request`,e.id)}sendRequest(e,t){this.throwIfClosed();let n=this.nextRequestId++,r=new Promise((e,t)=>{this.pendingResponses.set(n,{resolve:e,reject:t})});return r.catch(()=>{}),this.sendMessage({jsonrpc:`2.0`,id:n,method:e,params:t}),r}async sendNotification(e,t){this.throwIfClosed(),await this.sendMessage({jsonrpc:`2.0`,method:e,params:t})}throwIfClosed(){if(this.abortController.signal.aborted)throw this.abortController.signal.reason??Error(`ACP connection closed`)}async sendMessage(e){return this.writeQueue=this.writeQueue.then(async()=>{let t=this.stream.writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(e=>{this.close(e)}),this.writeQueue}},G=class e extends Error{constructor(e,n,r){super(n),t(this,`code`,void 0),t(this,`data`,void 0),this.code=e,this.name=`RequestError`,this.data=r}static parseError(t,n){return new e(-32700,`Parse error${n?`: ${n}`:``}`,t)}static invalidRequest(t,n){return new e(-32600,`Invalid request${n?`: ${n}`:``}`,t)}static methodNotFound(t){return new e(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,n){return new e(-32602,`Invalid params${n?`: ${n}`:``}`,t)}static internalError(t,n){return new e(-32603,`Internal error${n?`: ${n}`:``}`,t)}static authRequired(t,n){return new e(-32e3,`Authentication required${n?`: ${n}`:``}`,t)}static resourceNotFound(t){return new e(-32002,`Resource not found${t?`: ${t}`:``}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}};h(),v(),ye(),Te(),be(),De(),ce(),ae(),_e(),re(),ee(),pe();function K(e,t){if(e)return t?Pe(e)?e:Fe(t,e):e}var Si=!(typeof process.geteuid==`function`?process.geteuid()===0:typeof process.getuid==`function`&&process.getuid()===0)||!!process.env.IS_SANDBOX,Ci={auto:`auto`,default:`default`,acceptedits:`acceptEdits`,dontask:`dontAsk`,plan:`plan`,bypasspermissions:`bypassPermissions`,bypass:`bypassPermissions`};function wi(e,t=`permissions.defaultMode`){if(e===void 0)return`default`;if(typeof e!=`string`)throw Error(`Invalid ${t}: expected a string.`);let n=e.trim().toLowerCase();if(n===``)throw Error(`Invalid ${t}: expected a non-empty string.`);let r=Ci[n];if(!r)throw Error(`Invalid ${t}: ${e}.`);if(r===`bypassPermissions`&&!Si)throw Error(`Invalid ${t}: bypassPermissions is not available when running as root.`);return r}function Ti(e){let t=[...e.mcpServers??[]].sort((e,t)=>e.name.localeCompare(t.name));return JSON.stringify({cwd:e.cwd,mcpServers:t})}var Ei=256;function Di(e){let t=e.replace(/[\r\n]+/g,` `).replace(/\s+/g,` `).trim();return t.length<=Ei?t:t.slice(0,Ei-1)+`…`}function q(e,t){if(!t)return e;let n=D.resolve(t),r=D.resolve(e);return r.startsWith(n+D.sep)||r===n?D.relative(n,r):e}function Oi(e){let t="```";for(let n of e.matchAll(/^```+/gm)??[])for(;n[0].length>=t.length;)t+="`";return t+`
|
|
4
4
|
`+e+(e.endsWith(`
|
|
5
5
|
`)?``:`
|
|
6
6
|
`)+t}function J(e,t=!1,n){let r=e.name,i=e.input;switch(r){case`Agent`:case`Task`:{let e=i?.description??`Task`,t=i?.prompt;return{title:e,kind:`think`,content:t?[{type:`content`,content:{type:`text`,text:t}}]:[]}}case`Bash`:{let e=i?.command??`Terminal`,t=i?.description;return{title:e,kind:`execute`,content:t?[{type:`content`,content:{type:`text`,text:t}}]:[]}}case`Read`:{let e=i?.file_path,t=e??`File`,r=i?.offset,a=i?.limit,o=``;a&&a>0?o=` (${r??1} - ${(r??1)+a-1})`:r&&(o=` (from line ${r})`);let s=t?q(t,n):`File`,c=K(e,n);return{title:`Read ${s}${o}`,kind:`read`,locations:c?[{path:c,line:r??1}]:[],content:[]}}case`Write`:{let e=i?.file_path??``,t=i?.content??``,r=e?q(e,n):void 0,a=K(e,n);return{title:r?`Write ${r}`:`Write`,kind:`edit`,content:a?[{type:`diff`,path:a,oldText:null,newText:t}]:[{type:`content`,content:{type:`text`,text:t}}],locations:a?[{path:a}]:[]}}case`Edit`:{let e=i?.file_path??``,t=i?.old_string??``,r=i?.new_string??``,a=e?q(e,n):void 0,o=K(e,n);return{title:a?`Edit ${a}`:`Edit`,kind:`edit`,content:o?[{type:`diff`,path:o,oldText:t||null,newText:r}]:[],locations:o?[{path:o}]:[]}}case`Glob`:{let e=i?.path??``,t=i?.pattern??``,r=K(e,n),a=`Find`;return e&&(a+=` \`${e}\``),t&&(a+=` \`${t}\``),{title:a,kind:`search`,content:[],locations:r?[{path:r}]:[]}}case`Grep`:{let e=i?.pattern??``,t=i?.path??``,n=`grep`;return i?.[`-i`]&&(n+=` -i`),i?.[`-n`]&&(n+=` -n`),i?.[`-A`]!==void 0&&(n+=` -A ${i[`-A`]}`),i?.[`-B`]!==void 0&&(n+=` -B ${i[`-B`]}`),i?.[`-C`]!==void 0&&(n+=` -C ${i[`-C`]}`),i?.output_mode===`files_with_matches`?n+=` -l`:i?.output_mode===`count`&&(n+=` -c`),i?.head_limit!==void 0&&(n+=` | head -${i.head_limit}`),i?.glob&&(n+=` --include="${i.glob}"`),i?.type&&(n+=` --type=${i.type}`),i?.multiline&&(n+=` -P`),e&&(n+=` "${e}"`),t&&(n+=` ${t}`),{title:n,kind:`search`,content:[]}}case`TodoWrite`:{let e=i?.todos;return{title:Array.isArray(e)?`Update TODOs: ${e.map(e=>e.content).join(`, `)}`:`Update TODOs`,kind:`think`,content:[]}}case`ExitPlanMode`:{let e=i?.plan;return{title:`Ready to code?`,kind:`switch_mode`,content:e?[{type:`content`,content:{type:`text`,text:e}}]:[]}}default:return{title:r||`Unknown Tool`,kind:`other`,content:[]}}}function ki(e,t){return Array.isArray(e)&&e.length>0?{content:e.map(e=>({type:`content`,content:Ai(e,t)}))}:typeof e==`string`&&e.length>0?{content:[{type:`content`,content:{type:`text`,text:t?`\`\`\`\n${e}\n\`\`\``:e}}]}:{}}function Ai(e,t){let n=e=>({type:`text`,text:t?`\`\`\`\n${e}\n\`\`\``:e});switch(e.type){case`text`:{let n=e.text;return{type:`text`,text:t?`\`\`\`\n${n}\n\`\`\``:n}}case`image`:{let t=e.source;return t?.type===`base64`?{type:`image`,data:t.data,mimeType:t.media_type}:n(t?.type===`url`?`[image: ${t.url}]`:`[image: file reference]`)}case`resource_link`:{let t=e.uri;return{type:`resource_link`,uri:t,name:e.name??t,mimeType:e.mimeType}}case`resource`:{let t=e.resource;return{type:`resource`,resource:{uri:t?.uri??``,mimeType:t?.mimeType,...typeof t?.text==`string`?{text:t.text}:{},...typeof t?.blob==`string`?{blob:t.blob}:{}}}}case`tool_reference`:return n(`Tool: ${e.tool_name}`);case`tool_search_tool_search_result`:{let t=e.tool_references;return n(`Tools found: ${t?.map(e=>e.tool_name).join(`, `)||`none`}`)}case`tool_search_tool_result_error`:return n(`Error: ${e.error_code}${e.error_message?` - ${e.error_message}`:``}`);case`web_fetch_result`:return n(`Fetched: ${e.url}`);case`web_fetch_tool_result_error`:return n(`Error: ${e.error_code}`);case`code_execution_result`:case`bash_code_execution_result`:return n(`Output: ${e.stdout||e.stderr||``}`);case`code_execution_tool_result_error`:case`bash_code_execution_tool_result_error`:return n(`Error: ${e.error_code}`);case`text_editor_code_execution_view_result`:return n(e.content);case`text_editor_code_execution_create_result`:return n(e.is_file_update?`File updated`:`File created`);case`text_editor_code_execution_str_replace_result`:{let t=e.lines;return n(t?.join(`
|
|
@@ -10,5 +10,5 @@ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{A as n,E as r,I as i,M
|
|
|
10
10
|
|
|
11
11
|
Compacting completed.`}}}));break;case`result`:{let t=g.usage;t&&(l.inputTokens+=t.input_tokens??0,l.outputTokens+=t.output_tokens??0,l.cachedReadTokens+=t.cache_read_input_tokens??0,l.cachedWriteTokens+=t.cache_creation_input_tokens??0);let i=g.modelUsage;if(i&&d){let e=Ii(i,d);e?.contextWindow&&(f=e.contextWindow)}u!==null&&await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`usage_update`,used:u,size:f}});let a=g.subtype,o=g.is_error;if(r.aborted){c=`cancelled`;break}switch(a){case`success`:{let e=g.stop_reason;c=e===`max_tokens`?`max_tokens`:e===`refusal`?`refusal`:`end_turn`,o&&(c=`end_turn`);break}case`error_during_execution`:c=g.stop_reason===`max_tokens`?`max_tokens`:`end_turn`;break;case`error_max_budget_usd`:case`error_max_turns`:case`error_max_structured_output_retries`:c=`max_turn_requests`;break}break}case`stream_event`:{let t=g.parent_tool_use_id;t===null&&m===null&&(m=E());let r=Pi(g,e,i,n,{clientCapabilities:a,cwd:o,messageId:t===null?m??void 0:void 0});for(let e of r)await n.sessionUpdate(e);p=!0;break}case`assistant`:{let t=g.message,r=g.parent_tool_use_id;if(t?.usage&&r===null){let e=t.usage;u=(typeof e.input_tokens==`number`?e.input_tokens:0)+(typeof e.output_tokens==`number`?e.output_tokens:0)+(typeof e.cache_read_input_tokens==`number`?e.cache_read_input_tokens:0)+(typeof e.cache_creation_input_tokens==`number`?e.cache_creation_input_tokens:0)}r===null&&t?.model&&t.model!==`<synthetic>`&&(d=t.model);let s;r===null&&(m===null&&(m=E()),s=m);let c=Ni(g,e,i,n,{clientCapabilities:a,cwd:o,parentToolUseId:r,streamingActive:p,messageId:s});for(let e of c)await n.sessionUpdate(e);r===null&&(m=null);break}case`user`:break;case`progress`:{let t=g.data;if(!t)break;let r=t.type;if(r===`agent_progress`||r===`skill_progress`){let r=t.message;if(r){let t=r.content;if(t)for(let r of t)r.type===`text`&&await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`agent_message_chunk`,content:{type:`text`,text:r.text}}})}}break}case`tool_use_summary`:break;case`attachment`:break;case`compact_boundary`:u=0,await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`agent_message_chunk`,content:{type:`text`,text:`
|
|
12
12
|
|
|
13
|
-
Compacting completed.`}}});break;default:Li.debug(`Ignoring unknown SDK message type`);break}}if(r.aborted||s?.())return{stopReason:`cancelled`,usage:l}}catch(e){if(r.aborted)return{stopReason:`cancelled`,usage:l};throw e}return{stopReason:c,usage:l}}async function X(e,t,n,r,i,a){for(let o of t){let t=o;if(t.type!==`user`&&t.type!==`assistant`){Li.debug(`Ignoring unknown SDK message type`);continue}if(t.isMeta===!0)continue;let s=t.message?.content;if(!s)continue;let c=t.type===`assistant`?`assistant`:`user`;if(typeof s==`string`){if(!s.trim())continue;let t=E();await n.sessionUpdate({sessionId:e,update:{sessionUpdate:c===`assistant`?`agent_message_chunk`:`user_message_chunk`,...t?{messageId:t}:{},content:{type:`text`,text:s}}});continue}if(Array.isArray(s)){let t=Y(s,c,e,r,n,void 0,{clientCapabilities:i,cwd:a,messageId:E()});for(let e of t)await n.sessionUpdate(e)}}}function Bi(e,t,n,r,i,a,o,s){return async(n,c,l,u,d,f)=>{let p=Hi(r);if(n.name===`ExitPlanMode`)return Vi(e,t,d,c,p,i,a,o,s);if(f!==void 0)return f;try{let e=await ie(n,c,l,u,d);if(e.behavior===`allow`||e.behavior===`deny`)return e}catch(e){return console.error(`[ACP Permissions] Pipeline error:`,e),{behavior:`deny`,message:`Permission pipeline failed`,decisionReason:{type:`other`,reason:`Permission pipeline failed`},toolUseID:d}}let m=J({name:n.name,id:d,input:c},p,i),h={toolCallId:d,title:m.title,kind:m.kind,status:`pending`,rawInput:c},g=[{kind:`allow_always`,name:`Always Allow`,optionId:`allow_always`},{kind:`allow_once`,name:`Allow`,optionId:`allow`},{kind:`reject_once`,name:`Reject`,optionId:`reject`},{kind:`reject_always`,name:`Always Reject`,optionId:`reject_always`}];try{let n=await e.requestPermission({sessionId:t,toolCall:h,options:g});if(n.outcome.outcome===`cancelled`)return s?.(),{behavior:`deny`,message:`Permission request cancelled by client`,decisionReason:{type:`mode`,mode:`default`},toolUseID:d};if(n.outcome.outcome===`selected`&&`optionId`in n.outcome&&n.outcome.optionId!==void 0){let e=n.outcome.optionId;if(e===`allow`||e===`allow_always`)return{behavior:`allow`,updatedInput:c}}return{behavior:`deny`,message:`Permission denied by client`,decisionReason:{type:`mode`,mode:`default`}}}catch(e){return console.error(`[ACP Permissions] Client request error:`,e),{behavior:`deny`,message:`Permission request failed`,decisionReason:{type:`mode`,mode:`default`}}}}}async function Vi(e,t,n,r,i,a,o,s,c){let l=[{kind:`allow_always`,name:`Yes, and use "auto" mode`,optionId:`auto`},{kind:`allow_always`,name:`Yes, and auto-accept edits`,optionId:`acceptEdits`},{kind:`allow_once`,name:`Yes, and manually approve edits`,optionId:`default`},{kind:`reject_once`,name:`No, keep planning`,optionId:`plan`}];s?.()===!0&&l.unshift({kind:`allow_always`,name:`Yes, and bypass permissions`,optionId:`bypassPermissions`});let u=J({name:`ExitPlanMode`,id:n,input:r},i,a),d={toolCallId:n,title:u.title,kind:u.kind,status:`pending`,rawInput:r},f=await e.requestPermission({sessionId:t,toolCall:d,options:l});if(f.outcome.outcome===`cancelled`)return c?.(),{behavior:`deny`,message:`Tool use aborted`,decisionReason:{type:`mode`,mode:`default`}};if(f.outcome.outcome===`selected`&&`optionId`in f.outcome&&f.outcome.optionId!==void 0){let n=f.outcome.optionId;if(l.some(e=>e.optionId===n)&&(n==="default"||n===`acceptEdits`||n===`auto`||n===`bypassPermissions`))return o?.(n),await e.sessionUpdate({sessionId:t,update:{sessionUpdate:`current_mode_update`,currentModeId:n}}),{behavior:`allow`,updatedInput:r}}return{behavior:`deny`,message:`User rejected request to exit plan mode.`,decisionReason:{type:`mode`,mode:`plan`}}}function Hi(e){if(!e)return!1;if(e.terminal===!0)return!0;let t=e._meta;return!t||typeof t!=`object`?!1:t.terminal_output===!0}Ce(),ne(),se(),w(),e(),te(),de();var Z=class{constructor(e){t(this,`conn`,void 0),t(this,`sessions`,new Map),t(this,`clientCapabilities`,void 0),this.conn=e}async initialize(e){return this.clientCapabilities=e.clientCapabilities,{protocolVersion:1,authMethods:[],agentInfo:{name:`claude-code`,title:`Work Mate`,version:typeof globalThis.MACRO==`object`&&globalThis.MACRO!==null?String(globalThis.MACRO.VERSION??`0.0.0`):`0.0.0`},agentCapabilities:{_meta:{claudeCode:{promptQueueing:!0,forkSession:!0}},promptCapabilities:{image:!1,embeddedContext:!0},mcpCapabilities:{http:!0,sse:!0},loadSession:!0,sessionCapabilities:{list:{},resume:{},close:{},delete:{}}}}}async authenticate(e){return{}}async newSession(e){let t=await this.createSession(e);return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async unstable_resumeSession(e){let t=await this.getOrCreateSession({...e,replay:!1});return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async loadSession(e){let t=await this.getOrCreateSession(e);return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async listSessions(e){if(e.cursor!==void 0&&e.cursor!==null)throw Error(`Pagination cursor not supported: listSessions returns all results in a single page.`);let t=e.cwd||b(),n=await Se(t),r=await ge({dir:t}),i=[];for(let e of r){if(!e.cwd||await Se(e.cwd)!==n)continue;let t=Di(e.summary??``);i.push({sessionId:e.sessionId,cwd:e.cwd,...t?{title:t}:{},updatedAt:new Date(e.lastModified).toISOString()})}return{sessions:i}}async unstable_forkSession(e){let{initialMessages:t}=await Ui(e.sessionId),n=await this.createSession({cwd:e.cwd,mcpServers:e.mcpServers??[],_meta:e._meta},{initialMessages:t});return this.scheduleAvailableCommandsUpdate(n.sessionId),n}async unstable_closeSession(e){if(!this.sessions.get(e.sessionId))throw Error(`Session not found`);return await this.teardownSession(e.sessionId),{}}async unstable_deleteSession(e){let t=await T(e.sessionId);if(t)try{await Ne(t.filePath)}catch(e){if(e.code!==`ENOENT`)throw e}return this.sessions.has(e.sessionId)&&await this.teardownSession(e.sessionId),{}}async extMethod(e,t){if(e===`session/delete`){let e=t.sessionId;if(typeof e!=`string`||e.length===0)throw Error(`session/delete requires a non-empty sessionId`);return this.unstable_deleteSession({sessionId:e})}throw G.methodNotFound(e)}async cancel(e){let t=this.sessions.get(e.sessionId);if(t){t.cancelled=!0,t.cancelGeneration+=1;for(let[,e]of t.pendingMessages)e.resolve(!0);t.pendingMessages.clear(),t.pendingQueue=[],t.pendingQueueHead=0,t.queryEngine.interrupt()}}async setSessionMode(e){if(!this.sessions.get(e.sessionId))throw Error(`Session not found`);return this.applySessionMode(e.sessionId,e.modeId),await this.conn.sessionUpdate({sessionId:e.sessionId,update:{sessionUpdate:`current_mode_update`,currentModeId:e.modeId}}),await this.updateConfigOption(e.sessionId,`mode`,e.modeId),{}}async unstable_setSessionModel(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session not found`);return t.queryEngine.setModel(e.modelId),await this.updateConfigOption(e.sessionId,`model`,e.modelId),{}}async sendAvailableCommandsUpdate(e){let t=this.sessions.get(e);if(!t)return;let n=t.commands.filter(e=>e.type===`prompt`&&!e.isHidden&&e.userInvocable!==!1).map(e=>({name:e.name,description:e.description,input:e.argumentHint?{hint:e.argumentHint}:void 0}));await this.conn.sessionUpdate({sessionId:e,update:{sessionUpdate:`available_commands_update`,availableCommands:n}})}scheduleAvailableCommandsUpdate(e){setTimeout(()=>{this.sendAvailableCommandsUpdate(e).catch(e=>{console.error(`[ACP] Failed to send available commands update:`,e)})},0)}};async function Ui(e){let t;try{let n=await C(e);n&&n.messages.length>0&&(t=S(n.messages))}catch(e){console.error(`[ACP] fork source load failed:`,e)}return{initialMessages:t}}var Wi=[`auto`,`default`,`acceptEdits`,`bypassPermissions`,`dontAsk`,`plan`];function Gi(e){return Wi.includes(e)}function Ki(e,t,n){if(t){let t=qi(e,`_meta.permissionMode`);if(t===`bypassPermissions`&&!Xi())throw Error(`Mode not available: bypassPermissions cannot run as root (start the agent as a non-root user, or set IS_SANDBOX=1).`);return t}return Ji(n)??`default`}function qi(e,t){if(e==null)throw Error(`Invalid ${t}: expected a string.`);return wi(e,t)}function Ji(e){if(e!=null)try{return wi(e,`permissions.defaultMode`)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[ACP] Invalid permissions.defaultMode, using default:`,t);return}}function Yi(e,t){return!!e&&Object.hasOwn(e,t)}function Xi(){return Zi()}function Zi(){return process.env.IS_SANDBOX?!0:typeof process.geteuid==`function`?process.geteuid()!==0:typeof process.getuid!=`function`||process.getuid()!==0}function Qi(e,t){return[{id:`mode`,name:`Mode`,description:`Session permission mode`,category:`mode`,type:`select`,currentValue:e.currentModeId,options:e.availableModes.map(e=>({value:e.id,name:e.name,description:e.description}))},{id:`model`,name:`Model`,description:`AI model to use`,category:`model`,type:`select`,currentValue:t.currentModelId,options:t.availableModels.map(e=>({value:e.modelId,name:e.name,description:e.description??void 0}))}]}function $i(e){let t=[];if(!Array.isArray(e))return t;for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;if(Array.isArray(e.options))for(let n of e.options)n&&typeof n==`object`&&typeof n.value==`string`&&t.push(n.value);else typeof n.value==`string`&&t.push(n.value)}return t}function Q(e){return e.conn}function $(e){return e.clientCapabilities}function ea(e,t,n,r){n===`mode`?t.modes={...t.modes,currentModeId:r}:n===`model`&&(t.models={...t.models,currentModelId:r})}v();function ta(){return ve().permissions?.defaultMode}async function na(e,t={}){xe();let n=t.sessionId??E(),r=e.cwd;x(n,_()),g(r);let i=process.cwd(),a=!1;try{process.chdir(r),a=!0}catch{}y(),he();try{let i=Ee(),a=oe(i),o=e._meta,s=Yi(o,`permissionMode`),c=Ki(s?o?.permissionMode:void 0,s,ta()),l=$(this),u=this.conn,d=Bi(u,n,()=>this.sessions.get(n)?.modes.currentModeId??`default`,l,r,e=>{this.applySessionMode(n,e)},()=>this.sessions.get(n)?.appState.toolPermissionContext.isBypassPermissionsModeAvailable??!1),f=Xi(),p={...ce(),toolPermissionContext:{...i,mode:c,isBypassPermissionsModeAvailable:f}},[m,h]=await Promise.all([me(r),le(r)]);p.agentDefinitions=h;let g=new ke({cwd:r,tools:a,commands:m,mcpClients:[],agents:h.activeAgents,canUseTool:d,getAppState:()=>p,setAppState:e=>{let t=e(p);Object.assign(p,t)},readFileCache:new Oe(500,50*1024*1024),includePartialMessages:!0,replayUserMessages:!0,initialMessages:t.initialMessages}),_={currentModeId:c,availableModes:[{id:`default`,name:`Default`,description:`Standard behavior, prompts for dangerous operations`},{id:`acceptEdits`,name:`Accept Edits`,description:`Auto-accept file edit operations`},{id:`plan`,name:`Plan Mode`,description:`Planning mode, no actual tool execution`},{id:`auto`,name:`Auto`,description:`Use a model classifier to approve/deny permission prompts.`},...f?[{id:`bypassPermissions`,name:`Bypass Permissions`,description:`Skip all permission checks`}]:[],{id:`dontAsk`,name:`Don't Ask`,description:`Don't prompt for permissions, deny if not pre-approved`}]},v=ue(),y=we(),b={availableModels:v.map(e=>({modelId:String(e.value??``),name:e.label??String(e.value??``),description:e.description??void 0})),currentModelId:y};g.setModel(y);let x=Qi(_,b),ee={queryEngine:g,cancelled:!1,cancelGeneration:0,cwd:r,modes:_,models:b,configOptions:x,promptRunning:!1,pendingMessages:new Map,pendingQueue:[],pendingQueueHead:0,toolUseCache:{},clientCapabilities:l,appState:p,commands:m,sessionFingerprint:Ti({cwd:r,mcpServers:e.mcpServers})};return this.sessions.set(n,ee),{sessionId:n,modes:_,models:b,configOptions:x}}finally{a&&process.chdir(i)}}Object.assign(Z.prototype,{createSession:na}),te(),de(),v(),w();async function ra(e){let t=e.replay!==!1,n=this.sessions.get(e.sessionId);if(n){if(Ti({cwd:e.cwd,mcpServers:e.mcpServers})===n.sessionFingerprint){let r=await T(e.sessionId,e.cwd);return x(e.sessionId,r?Ae(r.filePath):null),g(e.cwd),t&&await this.replaySessionHistory(e),{sessionId:e.sessionId,modes:n.modes,models:n.models,configOptions:n.configOptions}}await this.teardownSession(e.sessionId)}let r=await T(e.sessionId,e.cwd),i=r?Ae(r.filePath):null;x(e.sessionId,i),g(e.cwd);let a;if(r)try{let t=await C(e.sessionId);t&&t.messages.length>0&&(a=S(t.messages))}catch(e){console.error(`[ACP] Failed to load session history:`,e)}let o=await this.createSession({cwd:e.cwd,mcpServers:e.mcpServers??[],_meta:e._meta},{sessionId:e.sessionId,initialMessages:a});if(t&&a&&a.length>0){let t=this.sessions.get(e.sessionId);t&&await X(e.sessionId,a,Q(this),t.toolUseCache,$(this),t.cwd)}return{sessionId:o.sessionId,modes:o.modes,models:o.models,configOptions:o.configOptions}}async function ia(e){this.sessions.get(e)&&(await this.cancel({sessionId:e}),this.sessions.delete(e))}async function aa(e){try{let t=await C(e.sessionId);if(!t||t.messages.length===0)return;let n=S(t.messages);if(n.length===0)return;let r=this.sessions.get(e.sessionId);if(!r)return;await X(e.sessionId,n,Q(this),r.toolUseCache,$(this),r.cwd)}catch(e){console.error(`[ACP] Failed to replay session history:`,e)}}function oa(e,t){if(!Gi(t))throw Error(`Invalid mode: ${t}`);let n=this.sessions.get(e);if(n){if(t===`bypassPermissions`&&!n.appState.toolPermissionContext.isBypassPermissionsModeAvailable||!n.modes.availableModes.some(e=>e.id===t))throw Error(`Mode not available: ${t}`);n.modes={...n.modes,currentModeId:t},n.appState.toolPermissionContext={...n.appState.toolPermissionContext,mode:t}}}async function sa(e,t,n){let r=this.sessions.get(e);r&&(ea(this,r,t,n),r.configOptions=r.configOptions.map(e=>e.id===t&&typeof e.currentValue==`string`?{...e,currentValue:n}:e),await Q(this).sessionUpdate({sessionId:e,update:{sessionUpdate:`config_option_update`,configOptions:r.configOptions}}))}Object.assign(Z.prototype,{getOrCreateSession:ra,teardownSession:ia,replaySessionHistory:aa,applySessionMode:oa,updateConfigOption:sa});function ca(e){if(!e||e.length===0)return``;let t=[];for(let n of e){let e=n;if(e.type===`text`)t.push(String(e.text??``));else if(e.type===`resource_link`){let n=typeof e.name==`string`?e.name:void 0,r=typeof e.uri==`string`?e.uri:void 0;t.push(la(n,r))}else if(e.type===`resource`){let n=e.resource;if(n&&typeof n.text==`string`)t.push(n.text);else if(n&&typeof n.blob==`string`){let e=typeof n.mimeType==`string`?n.mimeType:`application/octet-stream`,r=typeof n.uri==`string`?n.uri:`(unknown uri)`;t.push(`Embedded resource: ${r} (${e}, base64 blob, ${n.blob.length} chars)`)}}}return t.filter(e=>e.length>0).join(`
|
|
13
|
+
Compacting completed.`}}});break;default:Li.debug(`Ignoring unknown SDK message type`);break}}if(r.aborted||s?.())return{stopReason:`cancelled`,usage:l}}catch(e){if(r.aborted)return{stopReason:`cancelled`,usage:l};throw e}return{stopReason:c,usage:l}}async function X(e,t,n,r,i,a){for(let o of t){let t=o;if(t.type!==`user`&&t.type!==`assistant`){Li.debug(`Ignoring unknown SDK message type`);continue}if(t.isMeta===!0)continue;let s=t.message?.content;if(!s)continue;let c=t.type===`assistant`?`assistant`:`user`;if(typeof s==`string`){if(!s.trim())continue;let t=E();await n.sessionUpdate({sessionId:e,update:{sessionUpdate:c===`assistant`?`agent_message_chunk`:`user_message_chunk`,...t?{messageId:t}:{},content:{type:`text`,text:s}}});continue}if(Array.isArray(s)){let t=Y(s,c,e,r,n,void 0,{clientCapabilities:i,cwd:a,messageId:E()});for(let e of t)await n.sessionUpdate(e)}}}function Bi(e,t,n,r,i,a,o,s){return async(n,c,l,u,d,f)=>{let p=Hi(r);if(n.name===`ExitPlanMode`)return Vi(e,t,d,c,p,i,a,o,s);if(f!==void 0)return f;try{let e=await ie(n,c,l,u,d);if(e.behavior===`allow`||e.behavior===`deny`)return e}catch(e){return console.error(`[ACP Permissions] Pipeline error:`,e),{behavior:`deny`,message:`Permission pipeline failed`,decisionReason:{type:`other`,reason:`Permission pipeline failed`},toolUseID:d}}let m=J({name:n.name,id:d,input:c},p,i),h={toolCallId:d,title:m.title,kind:m.kind,status:`pending`,rawInput:c},g=[{kind:`allow_always`,name:`Always Allow`,optionId:`allow_always`},{kind:`allow_once`,name:`Allow`,optionId:`allow`},{kind:`reject_once`,name:`Reject`,optionId:`reject`},{kind:`reject_always`,name:`Always Reject`,optionId:`reject_always`}];try{let n=await e.requestPermission({sessionId:t,toolCall:h,options:g});if(n.outcome.outcome===`cancelled`)return s?.(),{behavior:`deny`,message:`Permission request cancelled by client`,decisionReason:{type:`mode`,mode:`default`},toolUseID:d};if(n.outcome.outcome===`selected`&&`optionId`in n.outcome&&n.outcome.optionId!==void 0){let e=n.outcome.optionId;if(e===`allow`||e===`allow_always`)return{behavior:`allow`,updatedInput:c}}return{behavior:`deny`,message:`Permission denied by client`,decisionReason:{type:`mode`,mode:`default`}}}catch(e){return console.error(`[ACP Permissions] Client request error:`,e),{behavior:`deny`,message:`Permission request failed`,decisionReason:{type:`mode`,mode:`default`}}}}}async function Vi(e,t,n,r,i,a,o,s,c){let l=[{kind:`allow_always`,name:`Yes, and use "auto" mode`,optionId:`auto`},{kind:`allow_always`,name:`Yes, and auto-accept edits`,optionId:`acceptEdits`},{kind:`allow_once`,name:`Yes, and manually approve edits`,optionId:`default`},{kind:`reject_once`,name:`No, keep planning`,optionId:`plan`}];s?.()===!0&&l.unshift({kind:`allow_always`,name:`Yes, and bypass permissions`,optionId:`bypassPermissions`});let u=J({name:`ExitPlanMode`,id:n,input:r},i,a),d={toolCallId:n,title:u.title,kind:u.kind,status:`pending`,rawInput:r},f=await e.requestPermission({sessionId:t,toolCall:d,options:l});if(f.outcome.outcome===`cancelled`)return c?.(),{behavior:`deny`,message:`Tool use aborted`,decisionReason:{type:`mode`,mode:`default`}};if(f.outcome.outcome===`selected`&&`optionId`in f.outcome&&f.outcome.optionId!==void 0){let n=f.outcome.optionId;if(l.some(e=>e.optionId===n)&&(n==="default"||n===`acceptEdits`||n===`auto`||n===`bypassPermissions`))return o?.(n),await e.sessionUpdate({sessionId:t,update:{sessionUpdate:`current_mode_update`,currentModeId:n}}),{behavior:`allow`,updatedInput:r}}return{behavior:`deny`,message:`User rejected request to exit plan mode.`,decisionReason:{type:`mode`,mode:`plan`}}}function Hi(e){if(!e)return!1;if(e.terminal===!0)return!0;let t=e._meta;return!t||typeof t!=`object`?!1:t.terminal_output===!0}Ce(),ne(),se(),w(),e(),te(),fe();var Z=class{constructor(e){t(this,`conn`,void 0),t(this,`sessions`,new Map),t(this,`clientCapabilities`,void 0),this.conn=e}async initialize(e){return this.clientCapabilities=e.clientCapabilities,{protocolVersion:1,authMethods:[],agentInfo:{name:`claude-code`,title:`Work Mate`,version:typeof globalThis.MACRO==`object`&&globalThis.MACRO!==null?String(globalThis.MACRO.VERSION??`0.0.0`):`0.0.0`},agentCapabilities:{_meta:{claudeCode:{promptQueueing:!0,forkSession:!0}},promptCapabilities:{image:!1,embeddedContext:!0},mcpCapabilities:{http:!0,sse:!0},loadSession:!0,sessionCapabilities:{list:{},resume:{},close:{},delete:{}}}}}async authenticate(e){return{}}async newSession(e){let t=await this.createSession(e);return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async unstable_resumeSession(e){let t=await this.getOrCreateSession({...e,replay:!1});return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async loadSession(e){let t=await this.getOrCreateSession(e);return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async listSessions(e){if(e.cursor!==void 0&&e.cursor!==null)throw Error(`Pagination cursor not supported: listSessions returns all results in a single page.`);let t=e.cwd||b(),n=await Se(t),r=await ge({dir:t}),i=[];for(let e of r){if(!e.cwd||await Se(e.cwd)!==n)continue;let t=Di(e.summary??``);i.push({sessionId:e.sessionId,cwd:e.cwd,...t?{title:t}:{},updatedAt:new Date(e.lastModified).toISOString()})}return{sessions:i}}async unstable_forkSession(e){let{initialMessages:t}=await Ui(e.sessionId),n=await this.createSession({cwd:e.cwd,mcpServers:e.mcpServers??[],_meta:e._meta},{initialMessages:t});return this.scheduleAvailableCommandsUpdate(n.sessionId),n}async unstable_closeSession(e){if(!this.sessions.get(e.sessionId))throw Error(`Session not found`);return await this.teardownSession(e.sessionId),{}}async unstable_deleteSession(e){let t=await T(e.sessionId);if(t)try{await Ne(t.filePath)}catch(e){if(e.code!==`ENOENT`)throw e}return this.sessions.has(e.sessionId)&&await this.teardownSession(e.sessionId),{}}async extMethod(e,t){if(e===`session/delete`){let e=t.sessionId;if(typeof e!=`string`||e.length===0)throw Error(`session/delete requires a non-empty sessionId`);return this.unstable_deleteSession({sessionId:e})}throw G.methodNotFound(e)}async cancel(e){let t=this.sessions.get(e.sessionId);if(t){t.cancelled=!0,t.cancelGeneration+=1;for(let[,e]of t.pendingMessages)e.resolve(!0);t.pendingMessages.clear(),t.pendingQueue=[],t.pendingQueueHead=0,t.queryEngine.interrupt()}}async setSessionMode(e){if(!this.sessions.get(e.sessionId))throw Error(`Session not found`);return this.applySessionMode(e.sessionId,e.modeId),await this.conn.sessionUpdate({sessionId:e.sessionId,update:{sessionUpdate:`current_mode_update`,currentModeId:e.modeId}}),await this.updateConfigOption(e.sessionId,`mode`,e.modeId),{}}async unstable_setSessionModel(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session not found`);return t.queryEngine.setModel(e.modelId),await this.updateConfigOption(e.sessionId,`model`,e.modelId),{}}async sendAvailableCommandsUpdate(e){let t=this.sessions.get(e);if(!t)return;let n=t.commands.filter(e=>e.type===`prompt`&&!e.isHidden&&e.userInvocable!==!1).map(e=>({name:e.name,description:e.description,input:e.argumentHint?{hint:e.argumentHint}:void 0}));await this.conn.sessionUpdate({sessionId:e,update:{sessionUpdate:`available_commands_update`,availableCommands:n}})}scheduleAvailableCommandsUpdate(e){setTimeout(()=>{this.sendAvailableCommandsUpdate(e).catch(e=>{console.error(`[ACP] Failed to send available commands update:`,e)})},0)}};async function Ui(e){let t;try{let n=await C(e);n&&n.messages.length>0&&(t=S(n.messages))}catch(e){console.error(`[ACP] fork source load failed:`,e)}return{initialMessages:t}}var Wi=[`auto`,`default`,`acceptEdits`,`bypassPermissions`,`dontAsk`,`plan`];function Gi(e){return Wi.includes(e)}function Ki(e,t,n){if(t){let t=qi(e,`_meta.permissionMode`);if(t===`bypassPermissions`&&!Xi())throw Error(`Mode not available: bypassPermissions cannot run as root (start the agent as a non-root user, or set IS_SANDBOX=1).`);return t}return Ji(n)??`default`}function qi(e,t){if(e==null)throw Error(`Invalid ${t}: expected a string.`);return wi(e,t)}function Ji(e){if(e!=null)try{return wi(e,`permissions.defaultMode`)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[ACP] Invalid permissions.defaultMode, using default:`,t);return}}function Yi(e,t){return!!e&&Object.hasOwn(e,t)}function Xi(){return Zi()}function Zi(){return process.env.IS_SANDBOX?!0:typeof process.geteuid==`function`?process.geteuid()!==0:typeof process.getuid!=`function`||process.getuid()!==0}function Qi(e,t){return[{id:`mode`,name:`Mode`,description:`Session permission mode`,category:`mode`,type:`select`,currentValue:e.currentModeId,options:e.availableModes.map(e=>({value:e.id,name:e.name,description:e.description}))},{id:`model`,name:`Model`,description:`AI model to use`,category:`model`,type:`select`,currentValue:t.currentModelId,options:t.availableModels.map(e=>({value:e.modelId,name:e.name,description:e.description??void 0}))}]}function $i(e){let t=[];if(!Array.isArray(e))return t;for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;if(Array.isArray(e.options))for(let n of e.options)n&&typeof n==`object`&&typeof n.value==`string`&&t.push(n.value);else typeof n.value==`string`&&t.push(n.value)}return t}function Q(e){return e.conn}function $(e){return e.clientCapabilities}function ea(e,t,n,r){n===`mode`?t.modes={...t.modes,currentModeId:r}:n===`model`&&(t.models={...t.models,currentModelId:r})}v();function ta(){return ve().permissions?.defaultMode}async function na(e,t={}){xe();let n=t.sessionId??E(),r=e.cwd;x(n,_()),g(r);let i=process.cwd(),a=!1;try{process.chdir(r),a=!0}catch{}y(),he();try{let i=Ee(),a=oe(i),o=e._meta,s=Yi(o,`permissionMode`),c=Ki(s?o?.permissionMode:void 0,s,ta()),l=$(this),u=this.conn,d=Bi(u,n,()=>this.sessions.get(n)?.modes.currentModeId??`default`,l,r,e=>{this.applySessionMode(n,e)},()=>this.sessions.get(n)?.appState.toolPermissionContext.isBypassPermissionsModeAvailable??!1),f=Xi(),p={...ue(),toolPermissionContext:{...i,mode:c,isBypassPermissionsModeAvailable:f}},[m,h]=await Promise.all([me(r),le(r)]);p.agentDefinitions=h;let g=new ke({cwd:r,tools:a,commands:m,mcpClients:[],agents:h.activeAgents,canUseTool:d,getAppState:()=>p,setAppState:e=>{let t=e(p);Object.assign(p,t)},readFileCache:new Oe(500,50*1024*1024),includePartialMessages:!0,replayUserMessages:!0,initialMessages:t.initialMessages}),_={currentModeId:c,availableModes:[{id:`default`,name:`Default`,description:`Standard behavior, prompts for dangerous operations`},{id:`acceptEdits`,name:`Accept Edits`,description:`Auto-accept file edit operations`},{id:`plan`,name:`Plan Mode`,description:`Planning mode, no actual tool execution`},{id:`auto`,name:`Auto`,description:`Use a model classifier to approve/deny permission prompts.`},...f?[{id:`bypassPermissions`,name:`Bypass Permissions`,description:`Skip all permission checks`}]:[],{id:`dontAsk`,name:`Don't Ask`,description:`Don't prompt for permissions, deny if not pre-approved`}]},v=de(),y=we(),b={availableModels:v.map(e=>({modelId:String(e.value??``),name:e.label??String(e.value??``),description:e.description??void 0})),currentModelId:y};g.setModel(y);let x=Qi(_,b),ee={queryEngine:g,cancelled:!1,cancelGeneration:0,cwd:r,modes:_,models:b,configOptions:x,promptRunning:!1,pendingMessages:new Map,pendingQueue:[],pendingQueueHead:0,toolUseCache:{},clientCapabilities:l,appState:p,commands:m,sessionFingerprint:Ti({cwd:r,mcpServers:e.mcpServers})};return this.sessions.set(n,ee),{sessionId:n,modes:_,models:b,configOptions:x}}finally{a&&process.chdir(i)}}Object.assign(Z.prototype,{createSession:na}),te(),fe(),v(),w();async function ra(e){let t=e.replay!==!1,n=this.sessions.get(e.sessionId);if(n){if(Ti({cwd:e.cwd,mcpServers:e.mcpServers})===n.sessionFingerprint){let r=await T(e.sessionId,e.cwd);return x(e.sessionId,r?Ae(r.filePath):null),g(e.cwd),t&&await this.replaySessionHistory(e),{sessionId:e.sessionId,modes:n.modes,models:n.models,configOptions:n.configOptions}}await this.teardownSession(e.sessionId)}let r=await T(e.sessionId,e.cwd),i=r?Ae(r.filePath):null;x(e.sessionId,i),g(e.cwd);let a;if(r)try{let t=await C(e.sessionId);t&&t.messages.length>0&&(a=S(t.messages))}catch(e){console.error(`[ACP] Failed to load session history:`,e)}let o=await this.createSession({cwd:e.cwd,mcpServers:e.mcpServers??[],_meta:e._meta},{sessionId:e.sessionId,initialMessages:a});if(t&&a&&a.length>0){let t=this.sessions.get(e.sessionId);t&&await X(e.sessionId,a,Q(this),t.toolUseCache,$(this),t.cwd)}return{sessionId:o.sessionId,modes:o.modes,models:o.models,configOptions:o.configOptions}}async function ia(e){this.sessions.get(e)&&(await this.cancel({sessionId:e}),this.sessions.delete(e))}async function aa(e){try{let t=await C(e.sessionId);if(!t||t.messages.length===0)return;let n=S(t.messages);if(n.length===0)return;let r=this.sessions.get(e.sessionId);if(!r)return;await X(e.sessionId,n,Q(this),r.toolUseCache,$(this),r.cwd)}catch(e){console.error(`[ACP] Failed to replay session history:`,e)}}function oa(e,t){if(!Gi(t))throw Error(`Invalid mode: ${t}`);let n=this.sessions.get(e);if(n){if(t===`bypassPermissions`&&!n.appState.toolPermissionContext.isBypassPermissionsModeAvailable||!n.modes.availableModes.some(e=>e.id===t))throw Error(`Mode not available: ${t}`);n.modes={...n.modes,currentModeId:t},n.appState.toolPermissionContext={...n.appState.toolPermissionContext,mode:t}}}async function sa(e,t,n){let r=this.sessions.get(e);r&&(ea(this,r,t,n),r.configOptions=r.configOptions.map(e=>e.id===t&&typeof e.currentValue==`string`?{...e,currentValue:n}:e),await Q(this).sessionUpdate({sessionId:e,update:{sessionUpdate:`config_option_update`,configOptions:r.configOptions}}))}Object.assign(Z.prototype,{getOrCreateSession:ra,teardownSession:ia,replaySessionHistory:aa,applySessionMode:oa,updateConfigOption:sa});function ca(e){if(!e||e.length===0)return``;let t=[];for(let n of e){let e=n;if(e.type===`text`)t.push(String(e.text??``));else if(e.type===`resource_link`){let n=typeof e.name==`string`?e.name:void 0,r=typeof e.uri==`string`?e.uri:void 0;t.push(la(n,r))}else if(e.type===`resource`){let n=e.resource;if(n&&typeof n.text==`string`)t.push(n.text);else if(n&&typeof n.blob==`string`){let e=typeof n.mimeType==`string`?n.mimeType:`application/octet-stream`,r=typeof n.uri==`string`?n.uri:`(unknown uri)`;t.push(`Embedded resource: ${r} (${e}, base64 blob, ${n.blob.length} chars)`)}}}return t.filter(e=>e.length>0).join(`
|
|
14
14
|
`)}function la(e,t){let n=[];return e&&e.length>0&&n.push(`name=${e}`),t&&t.length>0&&n.push(`uri=${t}`),n.length>0?`Resource link: ${n.join(`, `)}`:`Resource link`}function ua(e){for(;e.pendingQueueHead<e.pendingQueue.length;){let t=e.pendingQueue[e.pendingQueueHead++];if(!t)continue;let n=e.pendingMessages.get(t);if(n)return e.pendingMessages.delete(t),da(e),n}da(e)}function da(e){if(e.pendingQueueHead!==0){if(e.pendingQueueHead>=e.pendingQueue.length){e.pendingQueue=[],e.pendingQueueHead=0;return}e.pendingQueueHead>1024&&e.pendingQueueHead*2>e.pendingQueue.length&&(e.pendingQueue=e.pendingQueue.slice(e.pendingQueueHead),e.pendingQueueHead=0)}}v();async function fa(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session ${e.sessionId} not found`);let n=e.messageId??void 0,r=ca(e.prompt);if(!r.trim())throw Error(`Prompt content is empty`);let i=t.cancelGeneration;if(t.promptRunning){let e=E();if(await new Promise(n=>{t.pendingQueue.push(e),t.pendingMessages.set(e,{resolve:n})}))return{stopReason:`cancelled`}}if(t.cancelGeneration!==i)return{stopReason:`cancelled`};t.cancelled=!1,t.promptRunning=!0;try{t.queryEngine.resetAbortController(),x(e.sessionId,_());let i=t.queryEngine.submitMessage(r),{stopReason:a,usage:o}=await zi(e.sessionId,i,Q(this),t.queryEngine.getAbortSignal(),t.toolUseCache,$(this),t.cwd,()=>t.cancelled);if(t.cancelled)return{stopReason:`cancelled`};if(await ma(this,e.sessionId,r),o){let e={inputTokens:o.inputTokens,outputTokens:o.outputTokens,cachedReadTokens:o.cachedReadTokens,cachedWriteTokens:o.cachedWriteTokens,thoughtTokens:0,totalTokens:o.inputTokens+o.outputTokens+o.cachedReadTokens+o.cachedWriteTokens+0};return{stopReason:a,usage:e,...n?{userMessageId:n}:{},_meta:{claudeCode:{usage:e}}}}return{stopReason:a,...n?{userMessageId:n}:{}}}catch(n){let r=n instanceof Error&&(n.name===`AbortError`||/abort|cancelled|interrupt/i.test(n.message));if(t.cancelled||r)return{stopReason:`cancelled`};throw n instanceof Error&&(n.message.includes(`terminated`)||n.message.includes(`process exited`))?(await this.teardownSession(e.sessionId),Error(`The Claude Agent process exited unexpectedly. Please start a new session.`)):n}finally{let e=ua(t);e?(t.promptRunning=!0,e.resolve(!1)):t.promptRunning=!1}}async function pa(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session not found`);if(typeof e.value!=`string`)throw Error(`Invalid value for config option ${e.configId}: ${String(e.value)}`);let n=t.configOptions.find(t=>t.id===e.configId);if(!n)throw Error(`Unknown config option: ${e.configId}`);if(n.type===`select`){let t=$i(n.options);if(!t.includes(e.value))throw Error(`Invalid value '${e.value}' for config option ${e.configId}; must be one of: ${t.join(`, `)}`)}let r=e.value;return e.configId===`mode`?(this.applySessionMode(e.sessionId,r),await Q(this).sessionUpdate({sessionId:e.sessionId,update:{sessionUpdate:`current_mode_update`,currentModeId:r}})):e.configId===`model`&&t.queryEngine.setModel(r),ea(this,t,e.configId,r),t.configOptions=t.configOptions.map(t=>t.id===e.configId&&typeof t.currentValue==`string`?{...t,currentValue:r}:t),{configOptions:t.configOptions}}async function ma(e,t,n){let r=e.sessions.get(t);if(!r)return;let i=r.toolUseCache;if(i.__sessionInfoTitleSent)return;i.__sessionInfoTitleSent=!0;let a=Di(n).slice(0,100);try{await Q(e).sessionUpdate({sessionId:t,update:{sessionUpdate:`session_info_update`,...a?{title:a}:{},updatedAt:new Date().toISOString()}})}catch(e){console.error(`[ACP] Failed to send session_info_update:`,e)}}Object.assign(Z.prototype,{prompt:fa,setSessionConfigOption:pa}),be(),_e();function ha(e,t){let n=je.toWeb(e);return _i(Me.toWeb(t),n)}async function ga(){xe(),he();let e=ha(process.stdin,process.stdout),t,n=new yi(e=>(t=new Z(e),t),e);console.log=console.error,console.info=console.error,console.warn=console.error,console.debug=console.error;async function r(){for(let[e]of t.sessions)try{await t.unstable_closeSession({sessionId:e})}catch{}process.exit(0)}n.closed.then(r).catch(r),process.on(`SIGTERM`,r),process.on(`SIGINT`,r),process.on(`unhandledRejection`,(e,t)=>{console.error(`Unhandled Rejection at:`,t,`reason:`,e)}),process.stdin.resume()}export{ga as runAcpAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t}from"./envLessBridgeConfig-Ck2-KMq0.js";t();export{e as shouldShowAppUpgradeMessage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{E as t,M as n,T as r,g as i,n as a,r as o,t as s}from"./lazySchema-DcIJE_0i.js";import{i as c,r as l}from"./semver-BMRJYn3q.js";import{r as u,s as d}from"./bridgeEnabled-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{E as t,M as n,T as r,g as i,n as a,r as o,t as s}from"./lazySchema-DcIJE_0i.js";import{i as c,r as l}from"./semver-BMRJYn3q.js";import{r as u,s as d}from"./bridgeEnabled-SbB-6zdY.js";async function f(){let e=h,t=g().safeParse(e);return t.success?t.data:h}async function p(){let e=await f();return e.min_version&&c(`0.0.6`,e.min_version)?`Your version of Work Mate (0.0.6) is too old for Remote Control.\nVersion ${e.min_version} or higher is required. Run \`claude update\` to update.`:null}async function m(){return d()?(await f()).should_show_app_upgrade_message:!1}var h,g,_=e((()=>{o(),s(),l(),u(),h={init_retry_max_attempts:3,init_retry_base_delay_ms:500,init_retry_jitter_fraction:.25,init_retry_max_delay_ms:4e3,http_timeout_ms:1e4,uuid_dedup_buffer_size:2e3,heartbeat_interval_ms:2e4,heartbeat_jitter_fraction:.1,token_refresh_buffer_ms:3e5,teardown_archive_timeout_ms:1500,connect_timeout_ms:15e3,min_version:`0.0.0`,should_show_app_upgrade_message:!1},g=a(()=>t({init_retry_max_attempts:r().int().min(1).max(10).default(3),init_retry_base_delay_ms:r().int().min(100).default(500),init_retry_jitter_fraction:r().min(0).max(1).default(.25),init_retry_max_delay_ms:r().int().min(500).default(4e3),http_timeout_ms:r().int().min(2e3).default(1e4),uuid_dedup_buffer_size:r().int().min(100).max(5e4).default(2e3),heartbeat_interval_ms:r().int().min(5e3).max(3e4).default(2e4),heartbeat_jitter_fraction:r().min(0).max(.5).default(.1),token_refresh_buffer_ms:r().int().min(3e4).max(18e5).default(3e5),teardown_archive_timeout_ms:r().int().min(500).max(2e3).default(1500),connect_timeout_ms:r().int().min(5e3).max(6e4).default(15e3),min_version:n().refine(e=>{try{return c(e,`0.0.0`),!0}catch{return!1}}).default(`0.0.0`),should_show_app_upgrade_message:i().default(!1)}))}));export{m as a,_ as i,p as n,f as r,h as t};
|