@readmagic/workmate 0.0.17 → 0.0.18
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-YAhnVwyN.js → AddWorkspaceDirectory-Wa6Q24nu.js} +1 -1
- package/dist/chunks/{AgentsMdExternalIncludesDialog-Ba4GYFl3.js → AgentsMdExternalIncludesDialog-3I_KlOLv.js} +1 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog-h150UBir.js +1 -0
- package/dist/chunks/{App-mri25OrC.js → App-BgPs1Bu8.js} +1 -1
- package/dist/chunks/{ApproveApiKey-DCw6d7dm.js → ApproveApiKey-BxpapUq0.js} +1 -1
- package/dist/chunks/ApproveApiKey-DIIIi6U8.js +1 -0
- package/dist/chunks/{BackgroundTasksDialog-CZND8e_Z.js → BackgroundTasksDialog-nfRmiGl3.js} +1 -1
- package/dist/chunks/{BypassPermissionsModeDialog-B5QBJTB4.js → BypassPermissionsModeDialog-8Cq982M0.js} +1 -1
- package/dist/chunks/{DiffDialog-Bd-DcTsK.js → DiffDialog-DwQTDWYh.js} +1 -1
- package/dist/chunks/Doctor-Beo5yEMD.js +1 -0
- package/dist/chunks/{Doctor-C9t7udHN.js → Doctor-BxXAGr-Z.js} +1 -1
- package/dist/chunks/{ExitFlow-CShdrKmr.js → ExitFlow-CVIuvrHT.js} +1 -1
- package/dist/chunks/{Grove-CClEZT2e.js → Grove-_QX_wR9C.js} +1 -1
- package/dist/chunks/{HybridTransport-DyEuslQB.js → HybridTransport-BG2VIIBC.js} +1 -1
- package/dist/chunks/{InvalidConfigDialog-Wyrk_cXR.js → InvalidConfigDialog-BDdMkuaL.js} +1 -1
- package/dist/chunks/{InvalidSettingsDialog-Cr9fmSyh.js → InvalidSettingsDialog-DSCqbVER.js} +1 -1
- package/dist/chunks/{MCPConnectionManager-BnUw0nYN.js → MCPConnectionManager-Cer1UawR.js} +1 -1
- package/dist/chunks/{MCPToolListView-CY2EezWF.js → MCPToolListView-DndNWDr1.js} +1 -1
- package/dist/chunks/{McpParsingWarnings-BF4np2Y3.js → McpParsingWarnings-Cr_n2QR6.js} +1 -1
- package/dist/chunks/{MessageSelector-Dtt2Sf65.js → MessageSelector-BfmbAG8E.js} +1 -1
- package/dist/chunks/{Messages-D5Uuapmf.js → Messages-CUJJ6nHV.js} +1 -1
- package/dist/chunks/{Onboarding-BAJXV7Ay.js → Onboarding-Cz3CfOTl.js} +1 -1
- package/dist/chunks/{PromptInputFooterSuggestions-Cm4WN3qd.js → PromptInputFooterSuggestions-GhA5Qa1I.js} +1 -1
- package/dist/chunks/{PromptInputHelpMenu-ESj8sOpK.js → PromptInputHelpMenu-sX_yHORM.js} +1 -1
- package/dist/chunks/{QueryEngine-B79JLwG4.js → QueryEngine-C6Dx_-U8.js} +1 -1
- package/dist/chunks/{REPL-cAXdORs2.js → REPL-BPig-OIh.js} +38 -38
- package/dist/chunks/REPL-e5wWV2Sl.js +1 -0
- package/dist/chunks/{RemoteSessionManager-C5pAD0Lh.js → RemoteSessionManager-Cax4g0GH.js} +1 -1
- package/dist/chunks/{ResumeConversation-NSVT3gn7.js → ResumeConversation-e5sISbWn.js} +1 -1
- package/dist/chunks/{SSETransport-CDGMGrxN.js → SSETransport-BuDKErlN.js} +1 -1
- package/dist/chunks/SearchExtraToolsTool-B_z74zwG.js +1 -0
- package/dist/chunks/{Settings-_b5Yxt_9.js → Settings-B9rxF2wR.js} +2 -2
- package/dist/chunks/{TeleportProgress-8cS6aHVO.js → TeleportProgress-BUtze4qa.js} +1 -1
- package/dist/chunks/{TeleportRepoMismatchDialog-B0epkMgp.js → TeleportRepoMismatchDialog-Dp7rzrrz.js} +1 -1
- package/dist/chunks/{TeleportResumeWrapper-Bb14JeEk.js → TeleportResumeWrapper-Ch2osY21.js} +1 -1
- package/dist/chunks/{ThemePicker-CnX8faYA.js → ThemePicker-AA-0hjpq.js} +1 -1
- package/dist/chunks/{TrustDialog-6wJF3W6K.js → TrustDialog-rO5dZ8G-.js} +1 -1
- package/dist/chunks/{ValidationErrorsList-Cuq6W2yc.js → ValidationErrorsList-DayOwxq9.js} +1 -1
- package/dist/chunks/{add-dir-LLAv-rGS.js → add-dir-Cz33IGht.js} +1 -1
- package/dist/chunks/{agentDisplay-QqGqcHGz.js → agentDisplay-nVTmC7tL.js} +1 -1
- package/dist/chunks/{agents-DFPEienW.js → agents-BQwi-6GV.js} +1 -1
- package/dist/chunks/{agents-C8wRUTNV.js → agents-rfuJUSSc.js} +1 -1
- package/dist/chunks/{allErrors-DUYYPpdH.js → allErrors-YIRWFBD9.js} +1 -1
- package/dist/chunks/api-CGk-0H2x.js +1 -0
- package/dist/chunks/{api-B3Wnozaf.js → api-DAyhTxgY.js} +1 -1
- package/dist/chunks/{auth-CQGJitIV.js → auth-BzrroWLq.js} +1 -1
- package/dist/chunks/auth-DWWb8STf.js +1 -0
- package/dist/chunks/auth-DsqlBO-Q.js +1 -0
- package/dist/chunks/{backgroundHousekeeping-Bjb_Jc7L.js → backgroundHousekeeping-CXv_Pm5h.js} +2 -2
- package/dist/chunks/backgroundHousekeeping-Crx3oXIu.js +1 -0
- package/dist/chunks/{banner-HfMnBd03.js → banner-BfIcVEUU.js} +1 -1
- package/dist/chunks/{bg-DltfF1_K.js → bg-C15c_rMK.js} +2 -2
- package/dist/chunks/{branch-BWq5ynjm.js → branch-BEaujq-M.js} +1 -1
- package/dist/chunks/{break-cache-Cd1yQ-0h.js → break-cache-XKbOAw-u.js} +2 -2
- package/dist/chunks/{bridgeConfig-B3mR0kJ0.js → bridgeConfig-Bxkrv8ZL.js} +1 -1
- package/dist/chunks/bridgeConfig-Ctl7I_RR.js +1 -0
- package/dist/chunks/{bridgeMessaging-wZ5EKxW_.js → bridgeMessaging-BcSjIPCZ.js} +1 -1
- package/dist/chunks/bridgePointer-CGhOBNMg.js +1 -0
- package/dist/chunks/bridgeStatusUtil-DBWBTU31.js +1 -0
- package/dist/chunks/{btw-XNgXHnNr.js → btw-8JqSG3o7.js} +1 -1
- package/dist/chunks/caches-dnO4Ae_m.js +1 -0
- package/dist/chunks/caches-lPzD_yGv.js +1 -0
- package/dist/chunks/{capacityWake-LRiPhPeM.js → capacityWake-C24_KT1x.js} +1 -1
- package/dist/chunks/{ccrClient-EisctZbc.js → ccrClient-CH6PsxJJ.js} +1 -1
- package/dist/chunks/{claudeDesktop-CB3UCt7U.js → claudeDesktop-CovdLe-b.js} +1 -1
- package/dist/chunks/{clear-BjtPf2Jb.js → clear-D72LxXA6.js} +1 -1
- package/dist/chunks/{cliLaunch-xIVvtPZy.js → cliLaunch-DDA65zeR.js} +1 -1
- package/dist/chunks/client-BFjMSlp7.js +1 -0
- package/dist/chunks/client-Byat5HpG.js +1 -0
- package/dist/chunks/client-Dzx24jGZ.js +1 -0
- package/dist/chunks/{client-Bb2eZnuq.js → client-eLOYyeES.js} +1 -1
- package/dist/chunks/{client-DNEVh6Wu.js → client-o5_awagP.js} +1 -1
- package/dist/chunks/commands-D3lQbt9p.js +1 -0
- package/dist/chunks/{compact-w8AhLkr6.js → compact--fnu8Zd-.js} +1 -1
- package/dist/chunks/{config-D78R57VA.js → config-BlQhL9Bh.js} +1 -1
- package/dist/chunks/{config-BSkuQZNf.js → config-BybjRr09.js} +1 -1
- package/dist/chunks/config-CPGSP_1Z.js +1 -0
- package/dist/chunks/{context-Btn2JU2y.js → context-D6PaqwrR.js} +1 -1
- package/dist/chunks/context-noninteractive-CwlOID3q.js +1 -0
- package/dist/chunks/{context-noninteractive-044464Vs.js → context-noninteractive-CxoMCfR4.js} +1 -1
- package/dist/chunks/conversation-BLEWB1BE.js +1 -0
- package/dist/chunks/{conversation-a82khZ_n.js → conversation-Bos7yTIv.js} +1 -1
- package/dist/chunks/{createSSHSession-C0KSI0fJ.js → createSSHSession-B3FdForb.js} +1 -1
- package/dist/chunks/createSession-B4wkDNam.js +1 -0
- package/dist/chunks/{createSession-8ScCWTKb.js → createSession-C0e_DHsW.js} +1 -1
- package/dist/chunks/{crossProjectResume-BCN462Wa.js → crossProjectResume-C5QtstD6.js} +1 -1
- package/dist/chunks/cwd-BfiQQAqr.js +1 -0
- package/dist/chunks/{cwd-Besi3Os3.js → cwd-Dj2ynhWd.js} +1 -1
- package/dist/chunks/{datadog-BqINRWAW.js → datadog-ZxeaKwKd.js} +1 -1
- package/dist/chunks/{debug-BQj6h99Q.js → debug-D7OBvqC2.js} +1 -1
- package/dist/chunks/{debugUtils-B86DM1Sp.js → debugUtils-B-GMBTBk.js} +1 -1
- package/dist/chunks/{detached--wGwkuHX.js → detached-uMuMcLsV.js} +1 -1
- package/dist/chunks/{detectRepository-Qy3zKoyn.js → detectRepository-AVEUw4lk.js} +1 -1
- package/dist/chunks/detectRepository-CWI2xcdR.js +1 -0
- package/dist/chunks/{diff-CcrSQNvQ.js → diff-BA2vN7sD.js} +1 -1
- package/dist/chunks/{directoryCompletion-i2oWpaUe.js → directoryCompletion-CLcmLin8.js} +1 -1
- package/dist/chunks/doctor-BV6zhneX.js +1 -0
- package/dist/chunks/{entry-oVZ7Z59B.js → entry-cou5DS53.js} +2 -2
- package/dist/chunks/{esm-BZciQG9N.js → esm-D9-9wS1F.js} +1 -1
- package/dist/chunks/{execFileNoThrow-DYm1GeGn.js → execFileNoThrow-BHDSgTpZ.js} +1 -1
- package/dist/chunks/{execSyncWrapper-CqvQqke-.js → execSyncWrapper-pYxQXqb-.js} +1 -1
- package/dist/chunks/{exit-jikLI2Zh.js → exit-DdZJHhy2.js} +1 -1
- package/dist/chunks/{extraUsage-BT3in1Aj.js → extraUsage-CHnG6JNH.js} +1 -1
- package/dist/chunks/extractMemories-DxGHxoNO.js +1 -0
- package/dist/chunks/fast-Bf-g-wR6.js +1 -0
- package/dist/chunks/{fast-CKhtBOx7.js → fast-Bl_0cs9e.js} +1 -1
- package/dist/chunks/{fetchModelList-DmaMgpa2.js → fetchModelList-CheIBH5f.js} +1 -1
- package/dist/chunks/fetchModelList-vk-RMDfG.js +1 -0
- package/dist/chunks/{fileSuggestions-BfG3sbET.js → fileSuggestions-Dl87JhBr.js} +1 -1
- package/dist/chunks/{firstPartyEventLogger-Q3fMF0BR.js → firstPartyEventLogger-Cw9Bc3on.js} +2 -2
- package/dist/chunks/firstPartyEventLogger-DvsZdBy2.js +1 -0
- package/dist/chunks/flushGate-BD3Tk3_k.js +1 -0
- package/dist/chunks/{gemini-L8Gj2B4H.js → gemini-BARUjH_t.js} +1 -1
- package/dist/chunks/{generateSessionName-cAL5T7pG.js → generateSessionName-CHaK44K-.js} +1 -1
- package/dist/chunks/{genericProcessUtils-Bbcbi11g.js → genericProcessUtils-D5hCZ2ho.js} +1 -1
- package/dist/chunks/git-Bujlb5tq.js +1 -0
- package/dist/chunks/{git-DplvjXEY.js → git-CNhyfMtb.js} +1 -1
- package/dist/chunks/{githubRepoPathMapping-Px3_GeD1.js → githubRepoPathMapping-Dhz4cvw2.js} +1 -1
- package/dist/chunks/{goal-D-x2WXm7.js → goal-fTQFogdl.js} +1 -1
- package/dist/chunks/{grok-DtypRM4d.js → grok-D0J4IiCe.js} +1 -1
- package/dist/chunks/{grove-CSivzrhe.js → grove-mDH4wkhM.js} +1 -1
- package/dist/chunks/{help-DKZhC0lL.js → help-Dr7st1Yv.js} +1 -1
- package/dist/chunks/hooks-C5YSYzSl.js +1 -0
- package/dist/chunks/{hooks-D_afUDcs.js → hooks-DCfpFhl2.js} +1 -1
- package/dist/chunks/{initReplBridge-sTaq4a0K.js → initReplBridge-BFYTAFlT.js} +1 -1
- package/dist/chunks/{install-BWe3Jz4M.js → install-CjacxFXg.js} +1 -1
- package/dist/chunks/{instrumentation-IljwxX0V.js → instrumentation-DS2S1m1a.js} +3 -3
- package/dist/chunks/{job-N25KhSUu.js → job-Dry-GMc5.js} +1 -1
- package/dist/chunks/{jwtUtils-YCoZL0FW.js → jwtUtils-ClCcC8lO.js} +1 -1
- package/dist/chunks/{keybindings-DLEorhlY.js → keybindings-D01jzjKu.js} +1 -1
- package/dist/chunks/{launchLocalMemory-DJsuNLIf.js → launchLocalMemory-_T0oHfh9.js} +1 -1
- package/dist/chunks/{launchOnboarding-CVvuxeH-.js → launchOnboarding-D4fS6pLc.js} +1 -1
- package/dist/chunks/{external-CEp-aPkt.js → lazySchema-DULtBUCI.js} +1 -1
- package/dist/chunks/{loadAgentsDir-CbtNPJV3.js → loadAgentsDir-DnsldjYU.js} +560 -560
- package/dist/chunks/loadAgentsDir-xG1HswS_.js +1 -0
- package/dist/chunks/{loadPluginHooks-BxkDBFd6.js → loadPluginHooks-CRoYa_il.js} +1 -1
- package/dist/chunks/loader-C-PQ3onD.js +1 -0
- package/dist/chunks/localSearch-B17Mzd84.js +1 -0
- package/dist/chunks/{localSearch-B5mTHBwK.js → localSearch-nuNjYVKq.js} +1 -1
- package/dist/chunks/{log-BlJ7CcKG.js → log-CR0v5KUR.js} +1 -1
- package/dist/chunks/{logoV2Utils-D5nRpirL.js → logoV2Utils-CZwL_VX1.js} +1 -1
- package/dist/chunks/{magicDocs-C9aIo4Oe.js → magicDocs-D0rjtxup.js} +1 -1
- package/dist/chunks/{main-DeUt_aE2.js → main-C8n_p7yX.js} +11 -11
- package/dist/chunks/{main-Zh18lf2J.js → main-DKqCPH3G.js} +2 -2
- package/dist/chunks/managedEnv-C7bVtcgA.js +1 -0
- package/dist/chunks/managedEnv-d7HliQYg.js +1 -0
- package/dist/chunks/{mappers-Del1KoA7.js → mappers-BIDALdjB.js} +1 -1
- package/dist/chunks/{mcp-nnBVM5Lt.js → mcp-BcEApfqn.js} +1 -1
- package/dist/chunks/{mcp-D7vMhEOV.js → mcp-CBbVcOTy.js} +1 -1
- package/dist/chunks/{mcp-Bh3MNBIj.js → mcp-DYtfHeRa.js} +3 -3
- package/dist/chunks/{memoize-_2f7NWDv.js → memoize-C7xmvAQ0.js} +1 -1
- package/dist/chunks/{memory-DtqQhHu8.js → memory-CijapyZk.js} +1 -1
- package/dist/chunks/{mode-DPbrxU32.js → mode-CajUX4Uz.js} +1 -1
- package/dist/chunks/model-CyF5u3zH.js +1 -0
- package/dist/chunks/model-DaYZWYJe.js +1 -0
- package/dist/chunks/model-xI2MbgRj.js +1 -0
- package/dist/chunks/{modelOptions-SMq3one0.js → modelOptions-Ct80yABl.js} +1 -1
- package/dist/chunks/{nativeInstaller-DTJ4clp-.js → nativeInstaller-C6aWHxve.js} +1 -1
- package/dist/chunks/{omit-CMldTqqy.js → omit-BhPlISSj.js} +1 -1
- package/dist/chunks/{onChangeAppState-EAnsmOuo.js → onChangeAppState-BOJd4Yce.js} +1 -1
- package/dist/chunks/{openai-D9KvLMrj.js → openai-wsPCDwGL.js} +1 -1
- package/dist/chunks/{panel-Bg_0PHE6.js → panel-BKMLX5AR.js} +1 -1
- package/dist/chunks/parser-B-QFQfSO.js +1 -0
- package/dist/chunks/{parser-a2S_eFyE.js → parser-Dy-RMf4a.js} +1 -1
- package/dist/chunks/{partition-B8Y4jvjW.js → partition-_qZZlGjS.js} +1 -1
- package/dist/chunks/{permissions-cDtIZRM1.js → permissions-CcjGscyg.js} +1 -1
- package/dist/chunks/{pidLock-Br3_YNi_.js → pidLock-Cm9FWa4w.js} +2 -2
- package/dist/chunks/{plan-dG2H4eQl.js → plan-CTiLy_c4.js} +1 -1
- package/dist/chunks/{platform-DVeTi9mp.js → platform-BZm4WVLM.js} +1 -1
- package/dist/chunks/{plugin-CzQHuIlP.js → plugin-D7vjs6Hu.js} +1 -1
- package/dist/chunks/{pluginAutoupdate-B9W_vxOG.js → pluginAutoupdate-DzK-fXJC.js} +1 -1
- package/dist/chunks/{pluginBlocklist-BvdBsnJG.js → pluginBlocklist-B3JVl1h2.js} +1 -1
- package/dist/chunks/{pluginCliCommands-NKIgFTUF.js → pluginCliCommands-CubOvlhc.js} +1 -1
- package/dist/chunks/{pluginFlagging-C0PtAJEg.js → pluginFlagging-Dp7W2eL8.js} +1 -1
- package/dist/chunks/{pluginOperations-wUUdFpu9.js → pluginOperations-BxHoy0pC.js} +1 -1
- package/dist/chunks/{pluginStartupCheck-p0njap1l.js → pluginStartupCheck-CL24_zVV.js} +1 -1
- package/dist/chunks/pluginStartupCheck-CtX6QkdO.js +1 -0
- package/dist/chunks/{plugins-B9WBqOAW.js → plugins-DA3lpRU4.js} +1 -1
- package/dist/chunks/pollConfig-2nFzv6Hy.js +1 -0
- package/dist/chunks/poorMode-DyAWNRRM.js +1 -0
- package/dist/chunks/{poorMode-wm2WkPF0.js → poorMode-aMzKXz6G.js} +1 -1
- package/dist/chunks/{print-G3DgPTxy.js → print-BrqZ3AgP.js} +5 -5
- package/dist/chunks/{processBashCommand-zLWgCRws.js → processBashCommand-C6mBgRVz.js} +1 -1
- package/dist/chunks/{processSlashCommand-BHBnHBjj.js → processSlashCommand-t0-BVku8.js} +1 -1
- package/dist/chunks/prompt-BJ3xYAvE.js +1 -0
- package/dist/chunks/{prompt-BRGC5U9Y.js → prompt-CzQkcxfg.js} +3 -3
- package/dist/chunks/prompt-Di2lNwYp.js +1 -0
- package/dist/chunks/{promptEditor-CRIw6vJS.js → promptEditor-C6w1vT5E.js} +1 -1
- package/dist/chunks/{protocolHandler--eQQuSyx.js → protocolHandler-B3bQyB6W.js} +1 -1
- package/dist/chunks/{proxy-C0j74LqT.js → proxy-DFIxRT0i.js} +1 -1
- package/dist/chunks/{reconciler-DiU1RvGD.js → reconciler-p4lAu9ft.js} +1 -1
- package/dist/chunks/{refresh-DEXe3Lmx.js → refresh-DCQChX5A.js} +1 -1
- package/dist/chunks/{registerProtocol-DrWIX3Lb.js → registerProtocol-CrzdmgCD.js} +1 -1
- package/dist/chunks/{reload-plugins-Cl6wvT6V.js → reload-plugins-BnZzcRcd.js} +1 -1
- package/dist/chunks/{remoteBridgeCore-DnFZoXaw.js → remoteBridgeCore-DAK9KSWp.js} +1 -1
- package/dist/chunks/remoteManagedSettings-DkLfclxa.js +1 -0
- package/dist/chunks/{rename-CdzxOzN5.js → rename-OSN3Ua2J.js} +1 -1
- package/dist/chunks/{renderOptions-CkqTbz6d.js → renderOptions-XgkOdKCJ.js} +1 -1
- package/dist/chunks/{resume-DgFXYWTN.js → resume-K9q5B1li.js} +1 -1
- package/dist/chunks/{ripgrep-DsLUmulz.js → ripgrep-C_XuTqp3.js} +1 -1
- package/dist/chunks/ripgrep-DLPH9MP9.js +1 -0
- package/dist/chunks/{runtimeObserver-CwtRE2cj.js → runtimeObserver-CuTsWhhF.js} +1 -1
- package/dist/chunks/{runtimeObserver-Dov-m2dl.js → runtimeObserver-D9sujsqj.js} +2 -2
- package/dist/chunks/sandbox-adapter-CRxZBMAP.js +1 -0
- package/dist/chunks/{sandbox-toggle-DWCrG9zV.js → sandbox-toggle-oasrWfbj.js} +1 -1
- package/dist/chunks/searchExtraTools-BAYzzTE8.js +1 -0
- package/dist/chunks/{session-L5191BSn.js → session-c46jULDV.js} +1 -1
- package/dist/chunks/sessionFileAccessHooks-CwnjOk6S.js +1 -0
- package/dist/chunks/{sessionObserver-DpY0DOjI.js → sessionObserver-Cu7vykWp.js} +1 -1
- package/dist/chunks/sessionObserver-DNjDoJmy.js +1 -0
- package/dist/chunks/{sessionState-BlbRQ3Y6.js → sessionState-B3tFm9SC.js} +1 -1
- package/dist/chunks/sessionStorage-CVZ0MUSE.js +1 -0
- package/dist/chunks/{sessionTracing-DqVx8aFD.js → sessionTracing-BRp_Ej-e.js} +1 -1
- package/dist/chunks/{settings-CvhsRFaT.js → settings-DUyIag_5.js} +4 -4
- package/dist/chunks/settings-DsqFBv6J.js +1 -0
- package/dist/chunks/settingsSync-yE43qjMS.js +1 -0
- package/dist/chunks/{setup-DvnKMqDy.js → setup-CFOc-hPM.js} +2 -2
- package/dist/chunks/{shadowedRuleDetection-Gerk3t93.js → shadowedRuleDetection-ChoqK1Iq.js} +1 -1
- package/dist/chunks/{shellQuote-D3Ocv_U-.js → shellQuote-C-7PluUY.js} +1 -1
- package/dist/chunks/{sideQuestion-RndkXExy.js → sideQuestion-CkC27Pf3.js} +1 -1
- package/dist/chunks/sinks-B64r_OBE.js +1 -0
- package/dist/chunks/{sinks-CfzgqLH5.js → sinks-C9qCsi94.js} +1 -1
- package/dist/chunks/{skillChangeDetector-BQx4xe_b.js → skillChangeDetector-CLnn22Jo.js} +1 -1
- package/dist/chunks/{skillGapStore-CLxhWLyq.js → skillGapStore-DC8s2Whn.js} +2 -2
- package/dist/chunks/{skillLifecycle-CSNX2qOH.js → skillLifecycle-BaqH5lw_.js} +2 -2
- package/dist/chunks/{skillSearchPanel-CsQDjy_E.js → skillSearchPanel-Dtvyo2Dk.js} +2 -2
- package/dist/chunks/{skills-DM9ACPW-.js → skills-DXW57WeY.js} +1 -1
- package/dist/chunks/{startupProfiler-2sjXZkIP.js → startupProfiler-BqUlQEaV.js} +1 -1
- package/dist/chunks/startupProfiler-yBU6FaAV.js +1 -0
- package/dist/chunks/{state-BPFYBqm1.js → state-B3zvBu4R.js} +1 -1
- package/dist/chunks/state-mHtumqEo.js +1 -0
- package/dist/chunks/{stats-Dq-5qizS.js → stats-vvwEVnon.js} +1 -1
- package/dist/chunks/status--Ql7l0VG.js +1 -0
- package/dist/chunks/{status-C5v7KsX4.js → status-g_dhM6Ep.js} +1 -1
- package/dist/chunks/{statusNoticeHelpers-BY_8pK19.js → statusNoticeHelpers-B235FWru.js} +1 -1
- package/dist/chunks/{stringUtils-BjnclTLB.js → stringUtils-CGZoOfer.js} +1 -1
- package/dist/chunks/switcher-Cb9R9247.js +1 -0
- package/dist/chunks/switcher-OAeeTHHt.js +1 -0
- package/dist/chunks/{syncCache-Dff4hbz4.js → syncCache-BiqQEess.js} +1 -1
- package/dist/chunks/{tasks-qVyXOLBf.js → tasks--7yJk7MD.js} +1 -1
- package/dist/chunks/{teleport-Deq_ecN9.js → teleport-ja50aVy3.js} +1 -1
- package/dist/chunks/{templateJobs-CntPyct-.js → templateJobs-DSM3tNDS.js} +1 -1
- package/dist/chunks/{terminalSetup-JJiXmszo.js → terminalSetup-BpZXqE_G.js} +1 -1
- package/dist/chunks/{terminalSetup-DDvQ0K5e.js → terminalSetup-C735-5lZ.js} +1 -1
- package/dist/chunks/{theme-DVWYzSct.js → theme-BX54e0r7.js} +1 -1
- package/dist/chunks/{tmux-g0cQ0Buz.js → tmux-BIdWN33b.js} +1 -1
- package/dist/chunks/{toolEventObserver-BZn8ZJB5.js → toolEventObserver-O6ljakS9.js} +1 -1
- package/dist/chunks/{toolPool-Dzp1ob3I.js → toolPool-H_kXc8vo.js} +1 -1
- package/dist/chunks/trustedDevice-Dm_SY3Ko.js +1 -0
- package/dist/chunks/{trustedDevice-CdLAZK6m.js → trustedDevice-Kyid5Fuy.js} +1 -1
- package/dist/chunks/{types-BomO8WUz.js → types-DDku8UKF.js} +2 -2
- package/dist/chunks/{udsClient-DSvRPCvR.js → udsClient-B2yCKNgT.js} +1 -1
- package/dist/chunks/{upstreamproxy-DYoLvdM9.js → upstreamproxy--RTAcgrE.js} +1 -1
- package/dist/chunks/{useExitOnCtrlCDWithKeybindings-YSWYVWk6.js → useExitOnCtrlCDWithKeybindings-BnmDpMkm.js} +1 -1
- package/dist/chunks/useMainLoopModel-DG8pghH7.js +1 -0
- package/dist/chunks/{useManagePlugins-DfuI4Nhd.js → useManagePlugins-HMHtjIY-.js} +1 -1
- package/dist/chunks/{useMergedTools-B4qRVJ8b.js → useMergedTools-ChLA8dsy.js} +1 -1
- package/dist/chunks/{useSearchInput-DfUNYhqC.js → useSearchInput-DqymtQhH.js} +1 -1
- package/dist/chunks/{useSettingsErrors-Bls74ocI.js → useSettingsErrors-Bs9uyzW4.js} +1 -1
- package/dist/chunks/{userAgent-CNPTS7ix.js → userAgent-D8vvjitA.js} +1 -1
- package/dist/chunks/{util-6aJHnBQ_.js → util-CC-NRn16.js} +1 -1
- package/dist/chunks/validatePlugin-yCb8gsVF.js +1 -0
- package/dist/chunks/{vim-s-wmybpU.js → vim-CIK2DjfK.js} +1 -1
- package/dist/chunks/{which-BR8YVCCW.js → which-3MmqfsNV.js} +1 -1
- package/dist/chunks/windowsPaths-Dd_S96Bq.js +1 -0
- package/dist/chunks/{windowsPaths-BmXyrasP.js → windowsPaths-x-CxdtFP.js} +1 -1
- package/dist/chunks/{workSecret-BUd8cQ6-.js → workSecret-BsolC5S7.js} +1 -1
- package/dist/chunks/{workerRegistry-BwJ54Lzk.js → workerRegistry-DE4Ghp-n.js} +2 -2
- package/dist/chunks/worktree-D-CgffvU.js +1 -0
- package/dist/cli.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog--D4BeNAN.js +0 -1
- package/dist/chunks/ApproveApiKey-lv4Sg0RR.js +0 -1
- package/dist/chunks/Doctor-V-JLC4e3.js +0 -1
- package/dist/chunks/REPL-B7evbhvN.js +0 -1
- package/dist/chunks/SearchExtraToolsTool-CddjJcAH.js +0 -1
- package/dist/chunks/api-BAT--5sp.js +0 -1
- package/dist/chunks/auth-DaJXqwN5.js +0 -1
- package/dist/chunks/auth-DkhPycBL.js +0 -1
- package/dist/chunks/backgroundHousekeeping-V-dg2j2E.js +0 -1
- package/dist/chunks/bridgeConfig-D31i4BRi.js +0 -1
- package/dist/chunks/bridgePointer-CiHy2tTN.js +0 -1
- package/dist/chunks/bridgeStatusUtil-mvVQSVN-.js +0 -1
- package/dist/chunks/caches-ByLjTvdy.js +0 -1
- package/dist/chunks/caches-ckqJ4Qso.js +0 -1
- package/dist/chunks/client-Bl43xcRk.js +0 -1
- package/dist/chunks/client-Pap_HyZZ.js +0 -1
- package/dist/chunks/client-zhozU2ws.js +0 -1
- package/dist/chunks/commands-BDhn7EPO.js +0 -1
- package/dist/chunks/config-CbAvTdZ7.js +0 -1
- package/dist/chunks/context-noninteractive-ulRLlYg5.js +0 -1
- package/dist/chunks/conversation-D08lU377.js +0 -1
- package/dist/chunks/createSession-CnlPXXkA.js +0 -1
- package/dist/chunks/cwd-DpqwaYHw.js +0 -1
- package/dist/chunks/detectRepository-tRUoPOKy.js +0 -1
- package/dist/chunks/doctor-DRFDBrH1.js +0 -1
- package/dist/chunks/extractMemories-BsQU2bVO.js +0 -1
- package/dist/chunks/fast-B9vVL3sY.js +0 -1
- package/dist/chunks/fetchModelList-BeL40TyR.js +0 -1
- package/dist/chunks/firstPartyEventLogger-6GwZ6VLr.js +0 -1
- package/dist/chunks/flushGate-COa_KO98.js +0 -1
- package/dist/chunks/git-BaSq69E7.js +0 -1
- package/dist/chunks/hooks-DvVuNKRx.js +0 -1
- package/dist/chunks/lazySchema-B4D4qJVE.js +0 -1
- package/dist/chunks/loadAgentsDir-D0gl_H2S.js +0 -1
- package/dist/chunks/localSearch-D3UrYUre.js +0 -1
- package/dist/chunks/managedEnv-ADMKY7-G.js +0 -1
- package/dist/chunks/managedEnv-CDxyrUw1.js +0 -1
- package/dist/chunks/model-B50j-O5v.js +0 -1
- package/dist/chunks/model-DLG1nrnf.js +0 -1
- package/dist/chunks/model-DlLO7TSx.js +0 -1
- package/dist/chunks/parser-x-w3ikxt.js +0 -1
- package/dist/chunks/pluginStartupCheck-hDT6pEAd.js +0 -1
- package/dist/chunks/pollConfig-BgpfHQPJ.js +0 -1
- package/dist/chunks/poorMode-DD88nPJ4.js +0 -1
- package/dist/chunks/prompt-Ct3Ryb3C.js +0 -1
- package/dist/chunks/prompt-TZJKyomz.js +0 -1
- package/dist/chunks/remoteManagedSettings-BboLJ46D.js +0 -1
- package/dist/chunks/ripgrep-Di-2j8Ws.js +0 -1
- package/dist/chunks/sandbox-adapter-CtEngx-6.js +0 -1
- package/dist/chunks/searchExtraTools-zFMN5MqY.js +0 -1
- package/dist/chunks/sessionFileAccessHooks-C2VjT-PU.js +0 -1
- package/dist/chunks/sessionObserver-BuhXr3FP.js +0 -1
- package/dist/chunks/sessionStorage-CiYSwyY3.js +0 -1
- package/dist/chunks/settings-BgHApyGL.js +0 -1
- package/dist/chunks/settingsSync-BhlegQAU.js +0 -1
- package/dist/chunks/sinks-Cf4vx9UX.js +0 -1
- package/dist/chunks/startupProfiler-B2fyaBEa.js +0 -1
- package/dist/chunks/state-CsdHk8n-.js +0 -1
- package/dist/chunks/status-C3z0CSBw.js +0 -1
- package/dist/chunks/switcher-C9VsM-ip.js +0 -1
- package/dist/chunks/switcher-CnBKuiNp.js +0 -1
- package/dist/chunks/trustedDevice-1Q4FTNyX.js +0 -1
- package/dist/chunks/useMainLoopModel-C1JRp4zE.js +0 -1
- package/dist/chunks/validatePlugin-BajM6yNf.js +0 -1
- package/dist/chunks/windowsPaths-BybjGW7e.js +0 -1
- package/dist/chunks/worktree-BFP10vim.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{S as e,m as t,s as n,y as r}from"./git-
|
|
1
|
+
import{S as e,m as t,s as n,y as r}from"./git-CNhyfMtb.js";import{f as i,m as a,v as o}from"./startupProfiler-BqUlQEaV.js";import{homedir as s}from"os";import{join as c,sep as l}from"path";import{stat as u}from"fs/promises";o(),e(),t();var d=10080*60*1e3,f=1e3;function p(e){let t=[`This session was opened by an external deep link in ${g(e.cwd)}`];if(e.repo){let n=e.lastFetch?a(e.lastFetch):`never`,r=!e.lastFetch||Date.now()-e.lastFetch.getTime()>d;t.push(`Resolved ${e.repo} from local clones · last fetched ${n}${r?` — AGENTS.md may be stale`:``}`)}return e.prefillLength&&t.push(e.prefillLength>f?`The prompt below (${i(e.prefillLength)} chars) was supplied by the link — scroll to review the entire prompt before pressing Enter.`:`The prompt below was supplied by the link — review carefully before pressing Enter.`),t.join(`
|
|
2
2
|
`)}async function m(e){let t=await n(e);if(!t)return;let i=await r(t),[a,o]=await Promise.all([h(c(t,`FETCH_HEAD`)),i?h(c(i,`FETCH_HEAD`)):Promise.resolve(void 0)]);return a&&o?a>o?a:o:a??o}async function h(e){try{let{mtime:t}=await u(e);return t}catch{return}}function g(e){let t=s();return e===t?`~`:e.startsWith(t+l)?`~${e.slice(t.length)}`:e}export{m as n,p as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{i as e,o as t}from"./envUtils-DcaKZlRU.js";import{S as n,x as r}from"./debug-
|
|
2
|
-
`)),console.log()}}async function v(e){let t=await p();if(!e){if(t.length===0){console.log(`No active sessions.`);return}if(t.length===1)e=t[0].sessionId;else{console.log(`Multiple sessions active. Specify one:`);for(let e of t){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId;console.log(` ${t} PID=${e.pid}`)}return}}let n=m(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}if(!n.logPath){console.log(`No log path recorded for session ${n.sessionId}`);return}try{let e=await c(n.logPath,`utf-8`);process.stdout.write(e)}catch(e){console.error(`Failed to read log file: ${n.logPath}`),console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function y(e){let t=await p();if(!e){let n=t.filter(e=>e.tmuxSessionName||e.engine===`detached`);if(n.length===0){console.log("No background sessions to attach to. Start one with `claude daemon bg`.");return}if(n.length===1)e=n[0].sessionId;else{console.log(`Multiple background sessions. Specify one:`);for(let e of n){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId,n=g(e);console.log(` ${t} PID=${e.pid} engine=${n}`)}return}}let n=m(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}let r=g(n);try{if(r===`tmux`){let{TmuxEngine:e}=await import(`./tmux-
|
|
1
|
+
import{i as e,o as t}from"./envUtils-DcaKZlRU.js";import{S as n,x as r}from"./debug-D7OBvqC2.js";import{a as i,i as a}from"./genericProcessUtils-D5hCZ2ho.js";import{join as o}from"path";import{randomUUID as s}from"crypto";import{readFile as c,readdir as l,unlink as u}from"fs/promises";t(),r(),a();async function d(){if(process.platform===`win32`){let{DetachedEngine:e}=await import(`./detached-uMuMcLsV.js`);return new e}let{TmuxEngine:e}=await import(`./tmux-BIdWN33b.js`),t=new e;if(await t.available())return t;let{DetachedEngine:n}=await import(`./detached-uMuMcLsV.js`);return new n}function f(){return o(e(),`sessions`)}async function p(){let e=f(),t;try{t=await l(e)}catch{return[]}let r=[];for(let a of t)if(/^\d+\.json$/.test(a)){if(!i(parseInt(a.slice(0,-5),10))){u(o(e,a)).catch(()=>{});continue}try{let t=n(await c(o(e,a),`utf-8`));r.push(t)}catch{}}return r}function m(e,t){let n=parseInt(t,10);return e.find(e=>e.sessionId===t||e.pid===n||e.name&&e.name===t)}function h(e){return new Date(e).toLocaleString()}function g(e){return e.engine?e.engine:e.tmuxSessionName?`tmux`:`detached`}async function _(e){let t=await p();if(t.length===0){console.log(`No active sessions.`);return}console.log(`${t.length} active session${t.length>1?`s`:``}:\n`);for(let e of t){let t=g(e),n=[` PID: ${e.pid}`,` Kind: ${e.kind}`,` Engine: ${t}`,` Session: ${e.sessionId}`,` CWD: ${e.cwd}`];e.name&&n.push(` Name: ${e.name}`),e.startedAt&&n.push(` Started: ${h(e.startedAt)}`),e.status&&n.push(` Status: ${e.status}`),e.waitingFor&&n.push(` Waiting for: ${e.waitingFor}`),e.bridgeSessionId&&n.push(` Bridge: ${e.bridgeSessionId}`),e.tmuxSessionName&&n.push(` Tmux: ${e.tmuxSessionName}`),e.logPath&&n.push(` Log: ${e.logPath}`),console.log(n.join(`
|
|
2
|
+
`)),console.log()}}async function v(e){let t=await p();if(!e){if(t.length===0){console.log(`No active sessions.`);return}if(t.length===1)e=t[0].sessionId;else{console.log(`Multiple sessions active. Specify one:`);for(let e of t){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId;console.log(` ${t} PID=${e.pid}`)}return}}let n=m(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}if(!n.logPath){console.log(`No log path recorded for session ${n.sessionId}`);return}try{let e=await c(n.logPath,`utf-8`);process.stdout.write(e)}catch(e){console.error(`Failed to read log file: ${n.logPath}`),console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function y(e){let t=await p();if(!e){let n=t.filter(e=>e.tmuxSessionName||e.engine===`detached`);if(n.length===0){console.log("No background sessions to attach to. Start one with `claude daemon bg`.");return}if(n.length===1)e=n[0].sessionId;else{console.log(`Multiple background sessions. Specify one:`);for(let e of n){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId,n=g(e);console.log(` ${t} PID=${e.pid} engine=${n}`)}return}}let n=m(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}let r=g(n);try{if(r===`tmux`){let{TmuxEngine:e}=await import(`./tmux-BIdWN33b.js`),t=new e;if(!await t.available()){console.error(`tmux is no longer available. Cannot attach to tmux session.`),process.exitCode=1;return}await t.attach(n)}else{let{DetachedEngine:e}=await import(`./detached-uMuMcLsV.js`);await new e().attach(n)}}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function b(e){let t=await p();if(!e){if(t.length===0){console.log(`No active sessions to kill.`);return}console.log(`Specify a session to kill:`);for(let e of t){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId;console.log(` ${t} PID=${e.pid}`)}return}let n=m(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}console.log(`Killing session ${n.sessionId} (PID: ${n.pid})...`);try{process.kill(n.pid,`SIGTERM`)}catch{console.log(`Session already exited.`);return}if(await new Promise(e=>setTimeout(e,2e3)),i(n.pid))try{process.kill(n.pid,`SIGKILL`),console.log(`Session force-killed.`)}catch{console.log(`Session exited during grace period.`)}else console.log(`Session stopped.`);u(o(f(),`${n.pid}.json`)).catch(()=>{})}async function x(t){let n=await d(),r=t.filter(e=>e!==`--bg`&&e!==`--background`);if(!n.supportsInteractiveInput&&!r.some(e=>e===`-p`||e===`--print`||e===`--pipe`)){console.error(`Error: Background sessions with detached engine require -p/--print flag.
|
|
3
3
|
The detached engine has no terminal for interactive input.
|
|
4
4
|
|
|
5
5
|
Usage:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Er as t,br as n,cr as r,fi as i,gr as a,hr as o,oi as s}from"./loadAgentsDir-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Er as t,br as n,cr as r,fi as i,gr as a,hr as o,oi as s}from"./loadAgentsDir-DnsldjYU.js";import{Wt as c,et as l,pt as u}from"./state-B3zvBu4R.js";import{C as d,x as f}from"./debug-D7OBvqC2.js";import{c as p,s as m}from"./types-DDku8UKF.js";import{n as h,r as g}from"./analytics-DJobLaWP.js";import{i as _,o as v}from"./stringUtils-CGZoOfer.js";import{randomUUID as y}from"crypto";import{mkdir as b,readFile as x,writeFile as S}from"fs/promises";function C(e){let t=e?.message?.content;if(!t)return`Branched conversation`;let n=typeof t==`string`?t:t.find(e=>e.type===`text`)?.text;return n&&n.replace(/\s+/g,` `).trim().slice(0,100)||`Branched conversation`}async function w(e){let n=y(),i=u(),s=r(l()),c=a(n),f=o();await b(s,{recursive:!0,mode:448});let m;try{m=await x(f)}catch{throw Error(`No conversation to branch`)}if(m.length===0)throw Error(`No conversation to branch`);let h=p(m),g=h.filter(e=>t(e)&&!e.isSidechain),_=h.filter(e=>e.type===`content-replacement`&&e.sessionId===i).flatMap(e=>e.replacements);if(g.length===0)throw Error(`No messages to branch`);let v=null,C=[],w=[];for(let e of g){let t={...e,sessionId:n,parentUuid:v,isSidechain:!1,forkedFrom:{sessionId:i,messageUuid:e.uuid}},r={...e,sessionId:n};w.push(r),C.push(d(t)),e.type!==`progress`&&(v=e.uuid)}if(_.length>0){let e={type:`content-replacement`,sessionId:n,replacements:_};C.push(d(e))}return await S(c,`${C.join(`
|
|
2
2
|
`)}\n`,{encoding:`utf8`,mode:384}),{sessionId:n,title:e,forkPath:c,serializedMessages:w,contentReplacementRecords:_}}async function T(e){let t=`${e} (Branch)`;if((await i(t,{exact:!0})).length===0)return t;let n=await i(`${e} (Branch`),r=new Set([1]),a=RegExp(`^${_(e)} \\(Branch(?: (\\d+))?\\)$`);for(let e of n){let t=e.customTitle?.match(a);t&&(t[1]?r.add(parseInt(t[1],10)):r.add(1))}let o=2;for(;r.has(o);)o++;return`${e} (Branch ${o})`}async function E(e,t,n){let r=n?.trim()||void 0,i=u();try{let{sessionId:n,title:a,forkPath:o,serializedMessages:c,contentReplacementRecords:l}=await w(r),u=new Date,d=C(c.find(e=>e.type===`user`)),f=await T(a??d);await s(n,f,o),g(`tengu_conversation_forked`,{message_count:c.length,has_custom_title:!!a});let p={date:u.toISOString().split(`T`)[0],messages:c,fullPath:o,value:u.getTime(),created:u,modified:u,firstPrompt:d,messageCount:c.length,isSidechain:!1,sessionId:n,customTitle:f,contentReplacements:l},m=a?` "${a}"`:``,h=`Branched conversation${m}. You are now in the branch.${`\nTo resume the original: claude -r ${i}`}`;return t.resume?(await t.resume(n,p,`fork`),e(h,{display:`system`})):e(`Branched conversation${m}. Resume with: /resume ${n}`),null}catch(t){return e(`Failed to branch conversation: ${t instanceof Error?t.message:`Unknown error occurred`}`),null}}e((()=>{c(),h(),m(),n(),f(),v()}))();export{E as call,C as deriveFirstPrompt};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-DcaKZlRU.js";import{Wt as r,z as i}from"./state-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-DcaKZlRU.js";import{Wt as r,z as i}from"./state-B3zvBu4R.js";import{join as a}from"node:path";import{appendFileSync as o,existsSync as s,mkdirSync as c,readFileSync as l,unlinkSync as u,writeFileSync as d}from"node:fs";function f(){return a(t(),`.next-request-no-cache`)}function p(){return a(t(),`.break-cache-always`)}function m(){return a(t(),`break-cache-events.jsonl`)}function h(){try{let e=l(m(),`utf8`).trim().split(`
|
|
2
2
|
`).filter(Boolean).map(e=>{try{return JSON.parse(e)}catch{return null}}).filter(e=>e!==null),t=e.filter(e=>e.kind===`once`),n=e[e.length-1],r=e.filter(e=>e.kind===`always_on`||e.kind===`always_off`),i=r[r.length-1];return{totalBreaks:t.length,lastBreakAt:n?.at??null,alwaysModeEnabled:i?.kind===`always_on`}}catch{return{totalBreaks:0,lastBreakAt:null,alwaysModeEnabled:!1}}}function g(e){let n=m();c(t(),{recursive:!0});let r={at:new Date().toISOString(),kind:e};o(n,`${JSON.stringify(r)}\n`,`utf8`)}function _(){g(`once`)}async function v(e){let t=e.trim().toLowerCase(),n=f(),r=p();if(t===`status`){let e=h(),t=s(n),i=s(r);return{type:`text`,value:[`## Break-Cache Status`,``,` Once marker: ${t?`ACTIVE (next call will bust cache)`:`not set`}`,` Always mode: ${i?`ON (every call busts cache)`:`off`}`,``,`## Stats`,` total_breaks: ${e.totalBreaks}`,` last_break_at: ${e.lastBreakAt??`never`}`].join(`
|
|
3
3
|
`)}}if(t===`off`){let e=!1;return s(n)&&(u(n),e=!0),s(r)&&(u(r),e=!0),g(`always_off`),{type:`text`,value:e?`Break-cache disabled. Removed once marker and/or always flag.`:`Break-cache was not active.`}}if(t===`--clear`)return s(n)?(u(n),{type:`text`,value:`Cache-break marker cleared.\n \`${n}\``}):{type:`text`,value:`No cache-break marker was set.`};if(t===`always`)return d(r,new Date().toISOString(),`utf8`),g(`always_on`),{type:`text`,value:[`## Always-on cache break enabled`,``,`Flag written: \`${r}\``,``,`Every API call will now append a random nonce to the system prompt,`,`permanently preventing prompt-cache hits for this session.`,``,"To disable: `/break-cache off`"].join(`
|
|
4
4
|
`)};if(t===``||t===`once`){let e=new Date().toISOString();d(n,e,`utf8`),_();let t=h();return{type:`text`,value:[`## Cache break scheduled`,``,`Marker written: \`${n}\``,`Timestamp: ${e}`,``,`The next API call will append a random nonce to the system prompt,`,`causing a cache miss. The marker is removed automatically after use.`,``,"To cancel before the next call: `/break-cache --clear`","For every call: `/break-cache always`",``,`Total breaks this session: ${t.totalBreaks}`,``,`_How it works: The prompt cache keys on the system-prompt prefix hash._`,`_A unique nonce invalidates the hash, forcing a fresh compute._`].join(`
|
|
5
5
|
`)}}return{type:`text`,value:[`Unknown scope: "${t}"`,``,y].join(`
|
|
6
6
|
`)}}var y,b,x,S=e((()=>{r(),n(),y=[`Usage: /break-cache [scope]`,``,` (no args) Schedule a one-time cache break for the next API call`,` once Same as no args`,` always Enable persistent cache-break mode (every request)`,` off Disable always mode and clear any pending marker`,` --clear Clear the pending once marker (cancel before next call)`,` status Show current break-cache status and stats`,``,`How it works:`,` The prompt cache keys on the system-prompt prefix hash.`,` A unique nonce invalidates the hash, forcing a fresh compute.`,` This is useful when you want to ensure a clean context window.`].join(`
|
|
7
|
-
`),b={type:`local-jsx`,name:`break-cache`,description:`管理 prompt cache 的打断。打开操作面板,或运行:once、status、always、off`,isHidden:!1,isEnabled:()=>!i(),argumentHint:`[once|status|always|off|--clear]`,load:()=>import(`./panel-
|
|
7
|
+
`),b={type:`local-jsx`,name:`break-cache`,description:`管理 prompt cache 的打断。打开操作面板,或运行:once、status、always、off`,isHidden:!1,isEnabled:()=>!i(),argumentHint:`[once|status|always|off|--clear]`,load:()=>import(`./panel-BKMLX5AR.js`)},x={type:`local`,name:`break-cache`,description:`强制下一次(或所有)API 调用不命中 prompt cache。作用域:once、status、always、off`,isHidden:!1,isEnabled:()=>i(),supportsNonInteractive:!0,load:async()=>({call:v})}}));export{f as a,p as i,x as n,S as o,v as r,b as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,u as n}from"./oauth-D38aRTUb.js";import{Pt as r,St as i}from"./model-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,u as n}from"./oauth-D38aRTUb.js";import{Pt as r,St as i}from"./model-xI2MbgRj.js";function a(){return process.env.CLAUDE_BRIDGE_OAUTH_TOKEN||void 0}function o(){return process.env.CLAUDE_BRIDGE_BASE_URL||void 0}function s(){return a()??i()?.accessToken}function c(){return o()??t().BASE_API_URL}function l(){return!!o()}var u=e((()=>{n(),r()}));export{u as a,a as i,c as n,l as o,o as r,s as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,n as t,o as n,t as r}from"./bridgeConfig-Bxkrv8ZL.js";e();export{r as getBridgeAccessToken,t as getBridgeBaseUrl,n as isSelfHostedBridge};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./envUtils-DcaKZlRU.js";import{n as t,t as n}from"./defineProperty-C-QyHrDq.js";import{P as r,R as i,S as a,c as o,i as s,x as c}from"./debug-
|
|
1
|
+
import{o as e}from"./envUtils-DcaKZlRU.js";import{n as t,t as n}from"./defineProperty-C-QyHrDq.js";import{P as r,R as i,S as a,c as o,i as s,x as c}from"./debug-D7OBvqC2.js";import{B as l,F as u,H as d,I as f,O as p,b as m,g as h,m as g,q as _}from"./log-CR0v5KUR.js";import{n as v,r as y}from"./analytics-DJobLaWP.js";import{T as b,et as x}from"./sessionState-B3tFm9SC.js";import{n as S,t as C}from"./rcDebugLog-DSchf3Hs.js";import{t as w}from"./controlMessageCompat-IFu4Gc1y.js";import{randomUUID as T}from"crypto";e();async function E(){return!1}function D(){return!1}function O(){return!0}function k(){return null}v(),b(),s(),C(),g(),i(),c(),_(),t();function A(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function j(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_response`&&`response`in e}function M(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_request`&&`request_id`in e&&`request`in e}function N(e){return(e.type===`user`||e.type===`assistant`)&&e.isVirtual?!1:e.type===`user`||e.type===`assistant`||e.type===`system`&&e.subtype===`local_command`}function P(e){if(e.type!==`user`||e.isMeta||e.toolUseResult||e.isCompactSummary||e.origin&&e.origin.kind!==`human`)return;let t=e.message.content,n;if(typeof t==`string`)n=t;else for(let e of t??[])if(e.type===`text`){n=e.text;break}if(n)return h(n)||void 0}var F=`system-reminder`,I=/\s*<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\s*/gy,L=new Set([m,p,u,f,l,d]);function R(e){let t=e.message?.content;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``):``}function z(e){let t=e.trim();if(!t)return null;I.lastIndex=0;let n=[];for(;I.lastIndex<t.length;){let e=I.exec(t);if(!e)return null;n.push(e[1])}return n.length>0?n:null}function B(e){if(e.type!==`user`||e.isVisibleInTranscriptOnly)return!1;if(e.toolUseResult!==void 0||!e.isMeta)return!0;let t=z(R(e));return!t||t.some(e=>e!==`local-command-caveat`&&e!==F&&L.has(e))}function V(e){return e.some(B)}function H(e,t,n,i,s,c){try{let r=w(a(e));if(j(r)){o(`[bridge:repl] Ingress message type=control_response`),s?.(r);return}if(M(r)){o(`[bridge:repl] Inbound control_request subtype=${r.request.subtype}`),c?.(r);return}if(!A(r))return;let l=`uuid`in r&&typeof r.uuid==`string`?r.uuid:void 0;if(l&&t.has(l)){o(`[bridge:repl] Ignoring echo: type=${r.type} uuid=${l}`);return}if(l&&n.has(l)){o(`[bridge:repl] Ignoring re-delivered inbound: type=${r.type} uuid=${l}`);return}o(`[bridge:repl] Ingress message type=${r.type}${l?` uuid=${l}`:``}`),r.type===`user`?(l&&n.add(l),y(`tengu_bridge_message_received`,{is_repl:!0}),i?.(r)):o(`[bridge:repl] Ignoring non-user inbound message: type=${r.type}`)}catch(e){o(`[bridge:repl] Failed to parse ingress message: ${r(e)}`)}}var U=`This session is outbound-only. Enable Remote Control locally to allow inbound control.`;function W(e,t){let{transport:n,sessionId:r,outboundOnly:i,onInterrupt:a,onSetModel:s,onSetMaxThinkingTokens:c,onSetPermissionMode:l}=t;if(!n){o(`[bridge:repl] Cannot respond to control_request: transport not configured`);return}let u,d=e.request;if(i&&d.subtype!==`initialize`){u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:U}};let t={...u,session_id:r};n.write(t),o(`[bridge:repl] Rejected ${d.subtype} (outbound-only) request_id=${e.request_id}`);return}switch(d.subtype){case`initialize`:u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:{commands:[],output_style:`normal`,available_output_styles:[`normal`],models:[],account:{},pid:process.pid}}};break;case`set_model`:s?.(d.model),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_max_thinking_tokens`:c?.(d.max_thinking_tokens??null),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_permission_mode`:{let t=l?.(d.mode)??{ok:!1,error:`set_permission_mode is not supported in this context (onSetPermissionMode callback not registered)`};u=t.ok?{type:`control_response`,response:{subtype:`success`,request_id:e.request_id}}:{type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t.error}};break}case`interrupt`:a?.(),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;default:u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:`REPL bridge does not handle control_request subtype: ${d.subtype}`}}}let f={...u,session_id:r};n.write(f),S(`control_response: subtype=${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`),o(`[bridge:repl] Sent control_response for ${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`)}function G(e){return{type:`result_success`,subtype:`success`,duration_ms:0,duration_api_ms:0,is_error:!1,num_turns:0,result:``,stop_reason:null,total_cost_usd:0,usage:{...x},modelUsage:{},permission_denials:[],session_id:e,uuid:T()}}var K=class{constructor(e){n(this,`capacity`,void 0),n(this,`ring`,void 0),n(this,`set`,new Set),n(this,`writeIdx`,0),this.capacity=e,this.ring=Array(e)}add(e){if(this.set.has(e))return;let t=this.ring[this.writeIdx];t!==void 0&&this.set.delete(t),this.ring[this.writeIdx]=e,this.set.add(e),this.writeIdx=(this.writeIdx+1)%this.capacity}has(e){return this.set.has(e)}clear(){this.set.clear(),this.ring.fill(void 0),this.writeIdx=0}};export{N as a,V as c,O as d,D as f,W as i,k as l,P as n,G as o,H as r,B as s,K as t,E as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as e,N as t,f as n,n as r,r as i,t as a}from"./lazySchema-DULtBUCI.js";import{B as o,C as s,R as c,S as l,c as u,i as d,x as f}from"./debug-D7OBvqC2.js";import{c as p,l as m,m as h}from"./sessionStoragePortable-x0Yn02-G.js";import{dirname as g,join as _}from"path";import{mkdir as v,readFile as y,stat as b,unlink as x,writeFile as S}from"fs/promises";i(),d(),c(),a(),m(),f();var C=r(()=>e({sessionId:t(),environmentId:t(),source:n([`standalone`,`repl`])}));function w(e){return _(p(),h(e),`bridge-pointer.json`)}async function T(e,t){let n=w(e);try{await v(g(n),{recursive:!0}),await S(n,s(t),`utf8`),u(`[bridge:pointer] wrote ${n}`)}catch(e){u(`[bridge:pointer] write failed: ${e}`,{level:`warn`})}}async function E(e){let t=w(e),n,r;try{r=(await b(t)).mtimeMs,n=await y(t,`utf8`)}catch{return null}let i=C().safeParse(O(n));if(!i.success)return u(`[bridge:pointer] invalid schema, clearing: ${t}`),await D(e),null;let a=Math.max(0,Date.now()-r);return a>144e5?(u(`[bridge:pointer] stale (>4h mtime), clearing: ${t}`),await D(e),null):{...i.data,ageMs:a}}async function D(e){let t=w(e);try{await x(t),u(`[bridge:pointer] cleared ${t}`)}catch(e){o(e)||u(`[bridge:pointer] clear failed: ${e}`,{level:`warn`})}}function O(e){try{return l(e)}catch{return null}}export{D as clearBridgePointer,E as readBridgePointer,T as writeBridgePointer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fS as e,uS as t}from"./loadAgentsDir-DnsldjYU.js";import{v as n}from"./startupProfiler-BqUlQEaV.js";import{a as r,n as i,o as a}from"./bridgeConfig-Bxkrv8ZL.js";e(),r(),n();function o(e,n){return`${a()?i():t(void 0,n)}/code?bridge=${e}`}function s({error:e,connected:t,sessionActive:n,reconnecting:r}){return e?{label:`Remote Control failed`,color:`error`}:r?{label:`Remote Control reconnecting`,color:`warning`}:n||t?{label:`Remote Control active`,color:`success`}:{label:`Remote Control connecting…`,color:`warning`}}function c(e){return`Code everywhere with the Work Mate app or ${e}`}function l(e){return`Continue coding in the Work Mate app or ${e}`}var u=`Something went wrong, please try again`;export{s as a,c as i,l as n,o as r,u as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Bb as n,J_ as r,La as i,Lu as a,Ru as o,Sp as s,Y_ as c,at as l,by as u,cc as d,ka as f,lc as p,ot as m,q_ as h,wp as g,xC as _,zb as v}from"./loadAgentsDir-
|
|
1
|
+
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Bb as n,J_ as r,La as i,Lu as a,Ru as o,Sp as s,Y_ as c,at as l,by as u,cc as d,ka as f,lc as p,ot as m,q_ as h,wp as g,xC as _,zb as v}from"./loadAgentsDir-DnsldjYU.js";import{I as y,P as b,ai as x,bn as S,ot as C,t as w,vn as T,xt as E}from"./src-DL3w8VPk2.js";import{t as D}from"./jsx-runtime-Bb4Xn-E0.js";import{P as O,R as k}from"./debug-D7OBvqC2.js";import{Wt as A}from"./settings-DUyIag_5.js";import{h as j,y as M}from"./config-BybjRr09.js";import{Q as N}from"./sessionState-B3tFm9SC.js";import{n as P,r as F}from"./sideQuestion-CkC27Pf3.js";import{i as I,n as L}from"./modalContext-wY9CeN4G.js";function R({question:e,context:t,onDone:n}){let[r,i]=(0,H.useState)(null),[o,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(0),d=(0,H.useRef)(null),{rows:f}=I(C());S(()=>u(e=>e+1),r||o?null:80);function p(e){if(e.key===`escape`||e.key===`return`||e.key===` `||e.ctrl&&(e.key===`c`||e.key===`d`)){e.preventDefault(),n(void 0,{display:`skip`});return}(e.key===`up`||e.ctrl&&e.key===`p`)&&(e.preventDefault(),d.current?.scrollBy(-3)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),d.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=v();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?i(r.response):c(`No response received`))}catch(e){n.signal.aborted||c(O(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let m=Math.max(5,f-W-G);return(0,U.jsxs)(y,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:p,children:[(0,U.jsxs)(y,{children:[(0,U.jsxs)(b,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(b,{dimColor:!0,children:e})]}),(0,U.jsx)(y,{marginTop:1,marginLeft:2,maxHeight:m,children:(0,U.jsx)(E,{ref:d,flexDirection:`column`,flexGrow:1,children:o?(0,U.jsx)(b,{color:`error`,children:o}):r?(0,U.jsx)(s,{children:r}):(0,U.jsxs)(y,{children:[(0,U.jsx)(a,{frame:l,messageColor:`warning`}),(0,U.jsx)(b,{color:`warning`,children:`Answering...`})]})})}),(r||o)&&(0,U.jsx)(y,{marginTop:1,children:(0,U.jsxs)(b,{dimColor:!0,children:[`↑`,`/`,`↓`,` to scroll · Space, Enter, or Escape to dismiss`]})})]})}function z(e){let t=e.at(-1);return t?.type===`assistant`&&t.message.stop_reason===null?e.slice(0,-1):e}async function B(e){let t=f(z(e.messages)),n=d();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[i,a,o]=await Promise.all([l(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),r(),h()]);return{systemPrompt:N(i),userContext:a,systemContext:o,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(M(e=>({...e,btwUseCount:e.btwUseCount+1})),(0,U.jsx)(R,{question:r,context:t,onDone:e})):(e(`Usage: /btw <your question>`,{display:`system`}),null)}var H,U,W,G,K;e((()=>{H=t(x(),1),T(),g(),o(),A(),m(),L(),c(),_(),w(),n(),j(),k(),p(),i(),P(),u(),U=D(),W=5,G=6,K=3}))();export{V as call};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$f as t,Di as n,Ds as r,Du as i,Eu as a,G as o,IC as s,Im as c,J_ as l,K_ as u,Ki as d,Ky as f,LC as p,Li as m,Os as h,Pm as g,Q_ as _,Sh as v,Sv as y,X_ as b,Xi as x,Y_ as S,Z_ as C,bv as w,ep as T,q as E,q_ as D,qy as O,rm as k,xh as A}from"./loadAgentsDir-DnsldjYU.js";import{On as j,Wt as M,l as N}from"./state-B3zvBu4R.js";import{S as P,v as F}from"./git-CNhyfMtb.js";import{i as I,t as L}from"./detectRepository-AVEUw4lk.js";import{a as R,n as z}from"./fileSuggestions-Dl87JhBr.js";import{r as B,t as V}from"./magicDocs-D0rjtxup.js";function H(e=new Set){let r=e.size>0;l.cache.clear?.(),D.cache.clear?.(),u.cache.clear?.(),C.cache.clear?.(),z(),n(),r||y(),b(null),j(null),c(),h(),O(`session_start`),t(),a(),import(`./attributionHooks-C0aXyx9L.js`).then(({clearAttributionCaches:e})=>e()),L(),o(),N(e),F(),d(),v(),V(),s(),import(`./SearchExtraToolsTool-B_z74zwG.js`).then(({clearSearchExtraToolsDescriptionCache:e})=>e()),import(`./loadAgentsDir-xG1HswS_.js`).then(({clearAgentDefinitionsCache:e})=>e()),import(`./prompt-Di2lNwYp.js`).then(({clearPromptCache:e})=>e())}var U=e((()=>{M(),m(),_(),S(),R(),k(),w(),i(),g(),A(),B(),x(),r(),E(),f(),I(),P(),T(),p()}));export{U as n,H as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./caches-dnO4Ae_m.js";e();export{t as clearSessionCaches};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{n,t as r}from"./axios-DaWTGg7G.js";import{i,o as a,t as o}from"./debugUtils-
|
|
1
|
+
import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{n,t as r}from"./axios-DaWTGg7G.js";import{i,o as a,t as o}from"./debugUtils-B-GMBTBk.js";import{n as s,t as c}from"./rcDebugLog-DSchf3Hs.js";r(),a(),c();var l=1440*60*1e3,u=`Remote Control requires authentication.`,d=`Error: You must be logged in to use Remote Control.
|
|
2
2
|
|
|
3
3
|
Remote Control requires authentication.`;e();var f=`environments-2025-11-01`,p=/^[a-zA-Z0-9_-]+$/;function m(e,t){if(!e||!p.test(e))throw Error(`Invalid ${t}: contains unsafe characters`);return e}var h=class extends Error{constructor(e,n,r){super(e),t(this,`status`,void 0),t(this,`errorType`,void 0),this.name=`BridgeFatalError`,this.status=n,this.errorType=r}};function g(e){function t(t){e.onDebug?.(t)}let r=0;function i(t){let n={Authorization:`Bearer ${t}`,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`,"anthropic-beta":f,"x-environment-runner-version":e.runnerVersion},r=e.getTrustedDeviceToken?.();return r&&(n[`X-Trusted-Device-Token`]=r),n}function a(){let t=e.getAccessToken();if(!t)throw Error(u);return t}async function c(n,r){let i=a(),o=await n(i);if(o.status!==401)return o;if(!e.onAuth401)return t(`[bridge:api] ${r}: 401 received, no refresh handler`),o;if(t(`[bridge:api] ${r}: 401 received, attempting token refresh`),await e.onAuth401(i)){t(`[bridge:api] ${r}: Token refreshed, retrying request`);let e=await n(a());if(e.status!==401)return e;t(`[bridge:api] ${r}: Retry after refresh also got 401`)}else t(`[bridge:api] ${r}: Token refresh failed`);return o}return{async registerBridgeEnvironment(r){t(`[bridge:api] POST /v1/environments/bridge bridgeId=${r.bridgeId}`);let a=await c(t=>n.post(`${e.baseUrl}/v1/environments/bridge`,{machine_name:r.machineName,directory:r.dir,branch:r.branch,git_repo_url:r.gitRepoUrl,max_sessions:r.maxSessions,metadata:{worker_type:r.workerType},...r.reuseEnvironmentId&&{environment_id:r.reuseEnvironmentId}},{headers:i(t),timeout:15e3,validateStatus:e=>e<500}),`Registration`);return _(a.status,a.data,`Registration`),t(`[bridge:api] POST /v1/environments/bridge -> ${a.status} environment_id=${a.data.environment_id}`),t(`[bridge:api] >>> ${o({machine_name:r.machineName,directory:r.dir,branch:r.branch,git_repo_url:r.gitRepoUrl,max_sessions:r.maxSessions,metadata:{worker_type:r.workerType}})}`),t(`[bridge:api] <<< ${o(a.data)}`),a.data},async pollForWork(a,c,l,u){m(a,`environmentId`);let d=r;r=0;let f=await n.get(`${e.baseUrl}/v1/environments/${a}/work/poll`,{headers:i(c),params:u===void 0?void 0:{reclaim_older_than_ms:u},timeout:1e4,signal:l,validateStatus:e=>e<500});return _(f.status,f.data,`Poll`),s(`poll response: status=${f.status} hasData=${!!f.data} url=${e.baseUrl}`),f.data?(t(`[bridge:api] GET .../work/poll -> ${f.status} workId=${f.data.id} type=${f.data.data?.type}${f.data.data?.id?` sessionId=${f.data.data.id}`:``}`),t(`[bridge:api] <<< ${o(f.data)}`),f.data):(r=d+1,(r===1||r%100==0)&&t(`[bridge:api] GET .../work/poll -> ${f.status} (no work, ${r} consecutive empty polls)`),null)},async acknowledgeWork(r,a,o){m(r,`environmentId`),m(a,`workId`),t(`[bridge:api] POST .../work/${a}/ack`);let s=await n.post(`${e.baseUrl}/v1/environments/${r}/work/${a}/ack`,{},{headers:i(o),timeout:1e4,validateStatus:e=>e<500});_(s.status,s.data,`Acknowledge`),t(`[bridge:api] POST .../work/${a}/ack -> ${s.status}`)},async stopWork(r,a,o){m(r,`environmentId`),m(a,`workId`),t(`[bridge:api] POST .../work/${a}/stop force=${o}`);let s=await c(t=>n.post(`${e.baseUrl}/v1/environments/${r}/work/${a}/stop`,{force:o},{headers:i(t),timeout:1e4,validateStatus:e=>e<500}),`StopWork`);_(s.status,s.data,`StopWork`),t(`[bridge:api] POST .../work/${a}/stop -> ${s.status}`)},async deregisterEnvironment(r){m(r,`environmentId`),t(`[bridge:api] DELETE /v1/environments/bridge/${r}`);let a=await c(t=>n.delete(`${e.baseUrl}/v1/environments/bridge/${r}`,{headers:i(t),timeout:1e4,validateStatus:e=>e<500}),`Deregister`);_(a.status,a.data,`Deregister`),t(`[bridge:api] DELETE /v1/environments/bridge/${r} -> ${a.status}`)},async archiveSession(r){m(r,`sessionId`),t(`[bridge:api] POST /v1/sessions/${r}/archive`);let a=await c(t=>n.post(`${e.baseUrl}/v1/sessions/${r}/archive`,{},{headers:i(t),timeout:1e4,validateStatus:e=>e<500}),`ArchiveSession`);if(a.status===409){t(`[bridge:api] POST /v1/sessions/${r}/archive -> 409 (already archived)`);return}_(a.status,a.data,`ArchiveSession`),t(`[bridge:api] POST /v1/sessions/${r}/archive -> ${a.status}`)},async reconnectSession(r,a){m(r,`environmentId`),m(a,`sessionId`),t(`[bridge:api] POST /v1/environments/${r}/bridge/reconnect session_id=${a}`);let o=await c(t=>n.post(`${e.baseUrl}/v1/environments/${r}/bridge/reconnect`,{session_id:a},{headers:i(t),timeout:1e4,validateStatus:e=>e<500}),`ReconnectSession`);_(o.status,o.data,`ReconnectSession`),t(`[bridge:api] POST .../bridge/reconnect -> ${o.status}`)},async heartbeatWork(r,a,o){m(r,`environmentId`),m(a,`workId`),t(`[bridge:api] POST .../work/${a}/heartbeat`);let s=await n.post(`${e.baseUrl}/v1/environments/${r}/work/${a}/heartbeat`,{},{headers:i(o),timeout:1e4,validateStatus:e=>e<500});return _(s.status,s.data,`Heartbeat`),t(`[bridge:api] POST .../work/${a}/heartbeat -> ${s.status} lease_extended=${s.data.lease_extended} state=${s.data.state}`),s.data},async sendPermissionResponseEvent(r,a,s){m(r,`sessionId`),t(`[bridge:api] POST /v1/sessions/${r}/events type=${a.type}`);let c=await n.post(`${e.baseUrl}/v1/sessions/${r}/events`,{events:[a]},{headers:i(s),timeout:1e4,validateStatus:e=>e<500});_(c.status,c.data,`SendPermissionResponseEvent`),t(`[bridge:api] POST /v1/sessions/${r}/events -> ${c.status}`),t(`[bridge:api] >>> ${o({events:[a]})}`),t(`[bridge:api] <<< ${o(c.data)}`)}}}function _(e,t,n){if(e===200||e===204)return;let r=i(t),a=b(t);switch(e){case 401:throw new h(`${n}: Authentication failed (401)${r?`: ${r}`:``}. ${u}`,401,a);case 403:throw new h(v(a)?"Remote Control session has expired. Please restart with `claude remote-control` or /remote-control.":`${n}: Access denied (403)${r?`: ${r}`:``}. Check your organization permissions.`,403,a);case 404:throw new h(r??`${n}: Not found (404). Remote Control may not be available for this organization.`,404,a);case 410:throw new h(r??"Remote Control session has expired. Please restart with `claude remote-control` or /remote-control.",410,a??`environment_expired`);case 429:throw Error(`${n}: Rate limited (429). Polling too frequently.`);default:throw Error(`${n}: Failed with status ${e}${r?`: ${r}`:``}`)}}function v(e){return e?e.includes(`expired`)||e.includes(`lifetime`):!1}function y(e){return e.status===403?e.message.includes(`external_poll_sessions`)||e.message.includes(`environments:manage`):!1}function b(e){if(e&&typeof e==`object`&&`error`in e&&e.error&&typeof e.error==`object`&&`type`in e.error&&typeof e.error.type==`string`)return e.error.type}function x(e){let t=new AbortController;function n(){t.abort(),t=new AbortController}function r(){let n=new AbortController,r=()=>n.abort();if(e.aborted||t.signal.aborted)return n.abort(),{signal:n.signal,cleanup:()=>{}};e.addEventListener(`abort`,r,{once:!0});let i=t.signal;return i.addEventListener(`abort`,r,{once:!0}),{signal:n.signal,cleanup:()=>{e.removeEventListener(`abort`,r),i.removeEventListener(`abort`,r)}}}return{signal:r,wake:n}}export{y as a,l as c,v as i,h as n,m as o,g as r,d as s,x as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,F as r,P as i,R as a,c as o,i as s,x as c}from"./debug-BQj6h99Q.js";import{O as l,k as u}from"./git-DplvjXEY.js";import{dn as d,fn as f}from"./model-DlLO7TSx.js";import{l as p,r as m}from"./proxy-C0j74LqT.js";import{n as h,t as g}from"./userAgent-CNPTS7ix.js";import{C as _,S as v,f as y,g as b,u as x,x as S}from"./sessionState-BlbRQ3Y6.js";import{n as C}from"./jwtUtils-YCoZL0FW.js";import{randomUUID as w}from"crypto";a(),s(),l(),p(),h(),d(),_(),x(),c(),e();var T=class extends Error{constructor(e,n){super(e),t(this,`retryAfterMs`,void 0),this.retryAfterMs=n}},E=class{constructor(e){t(this,`pending`,[]),t(this,`pendingAtClose`,0),t(this,`draining`,!1),t(this,`closed`,!1),t(this,`backpressureResolvers`,[]),t(this,`sleepResolve`,null),t(this,`flushResolvers`,[]),t(this,`droppedBatches`,0),t(this,`config`,void 0),this.config=e}get droppedBatchCount(){return this.droppedBatches}get pendingCount(){return this.closed?this.pendingAtClose:this.pending.length}async enqueue(e){if(this.closed)return;let t=Array.isArray(e)?e:[e];if(t.length!==0){for(;this.pending.length+t.length>this.config.maxQueueSize&&!this.closed;)await new Promise(e=>{this.backpressureResolvers.push(e)});this.closed||(this.pending.push(...t),this.drain())}}flush(){return this.pending.length===0&&!this.draining?Promise.resolve():(this.drain(),new Promise(e=>{this.flushResolvers.push(e)}))}close(){if(!this.closed){this.closed=!0,this.pendingAtClose=this.pending.length,this.pending=[],this.sleepResolve?.(),this.sleepResolve=null;for(let e of this.backpressureResolvers)e();this.backpressureResolvers=[];for(let e of this.flushResolvers)e();this.flushResolvers=[]}}async drain(){if(this.draining||this.closed)return;this.draining=!0;let e=0;try{for(;this.pending.length>0&&!this.closed;){let t=this.takeBatch();if(t.length!==0){try{await this.config.send(t),e=0}catch(n){if(e++,this.config.maxConsecutiveFailures!==void 0&&e>=this.config.maxConsecutiveFailures){this.droppedBatches++,this.config.onBatchDropped?.(t.length,e),e=0,this.releaseBackpressure();continue}this.pending=t.concat(this.pending);let r=n instanceof T?n.retryAfterMs:void 0;await this.sleep(this.retryDelay(e,r));continue}this.releaseBackpressure()}}}finally{if(this.draining=!1,this.pending.length===0){for(let e of this.flushResolvers)e();this.flushResolvers=[]}}}takeBatch(){let{maxBatchSize:e,maxBatchBytes:t}=this.config;if(t===void 0)return this.pending.splice(0,e);let r=0,i=0;for(;i<this.pending.length&&i<e;){let e;try{e=Buffer.byteLength(n(this.pending[i]))}catch{this.pending.splice(i,1);continue}if(i>0&&r+e>t)break;r+=e,i++}return this.pending.splice(0,i)}retryDelay(e,t){let n=Math.random()*this.config.jitterMs;return t===void 0?Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+n:Math.max(this.config.baseDelayMs,Math.min(t,this.config.maxDelayMs))+n}releaseBackpressure(){let e=this.backpressureResolvers;this.backpressureResolvers=[];for(let t of e)t()}sleep(e){return new Promise(t=>{this.sleepResolve=t,setTimeout((e,t)=>{e.sleepResolve=null,t()},e,this,t)})}};e();var D=class{constructor(e){t(this,`inflight`,null),t(this,`pending`,null),t(this,`closed`,!1),t(this,`config`,void 0),this.config=e}enqueue(e){this.closed||(this.pending=this.pending?O(this.pending,e):e,this.drain())}close(){this.closed=!0,this.pending=null}async drain(){if(this.inflight||this.closed||!this.pending)return;let e=this.pending;this.pending=null,this.inflight=this.sendWithRetry(e).then(()=>{this.inflight=null,this.pending&&!this.closed&&this.drain()})}async sendWithRetry(e){let t=e,n=0;for(;!this.closed;){if(await this.config.send(t))return;n++,await f(this.retryDelay(n)),this.pending&&!this.closed&&(t=O(t,this.pending),this.pending=null)}}retryDelay(e){return Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+Math.random()*this.config.jitterMs}};function O(e,t){let n={...e};for(let[e,r]of Object.entries(t))(e===`external_metadata`||e===`internal_metadata`)&&n[e]&&typeof n[e]==`object`&&typeof r==`object`&&r?n[e]={...n[e],...r}:n[e]=r;return n}d(),e();var k=2e4,A=100;function j(){return!0}var M=class extends Error{constructor(e){super(`CCRClient init failed: ${e}`),t(this,`reason`,void 0),this.reason=e}},N=10;function P(){return{byMessage:new Map,scopeToMessage:new Map}}function F(e){return`${e.session_id}:${e.parent_tool_use_id??``}`}function I(e,t){let n=[],r=new Map;for(let i of e){let e=i.event;switch(e.type){case`message_start`:{let r=e.message.id,a=t.scopeToMessage.get(F(i));a&&t.byMessage.delete(a),t.scopeToMessage.set(F(i),r),t.byMessage.set(r,[]),n.push(i);break}case`content_block_delta`:{let a=e.delta;if(a.type!==`text_delta`){n.push(i);break}let o=t.scopeToMessage.get(F(i)),s=o?t.byMessage.get(o):void 0;if(!s){n.push(i);break}let c=e.index,l=s[c]??(s[c]=[]);l.push(a.text);let u=r.get(l);if(u){u.event.delta={type:`text_delta`,text:l.join(``)};break}let d={type:`stream_event`,uuid:i.uuid,session_id:i.session_id,parent_tool_use_id:i.parent_tool_use_id,event:{type:`content_block_delta`,index:c,delta:{type:`text_delta`,text:l.join(``)}}};r.set(l,d),n.push(d);break}default:n.push(i)}}return n}function L(e,t){e.byMessage.delete(t.message.id);let n=F(t);e.scopeToMessage.get(n)===t.message.id&&e.scopeToMessage.delete(n)}var R=class{constructor(e,n,r){if(t(this,`workerEpoch`,0),t(this,`heartbeatIntervalMs`,void 0),t(this,`heartbeatJitterFraction`,void 0),t(this,`heartbeatTimer`,null),t(this,`heartbeatInFlight`,!1),t(this,`closed`,!1),t(this,`consecutiveAuthFailures`,0),t(this,`currentState`,null),t(this,`sessionBaseUrl`,void 0),t(this,`sessionId`,void 0),t(this,`http`,m({keepAlive:!0})),t(this,`streamEventBuffer`,[]),t(this,`streamEventTimer`,null),t(this,`streamTextAccumulator`,P()),t(this,`workerState`,void 0),t(this,`eventUploader`,void 0),t(this,`internalEventUploader`,void 0),t(this,`deliveryUploader`,void 0),t(this,`onEpochMismatch`,void 0),t(this,`getAuthHeaders`,void 0),this.onEpochMismatch=r?.onEpochMismatch??(()=>{process.exit(1)}),this.heartbeatIntervalMs=r?.heartbeatIntervalMs??k,this.heartbeatJitterFraction=r?.heartbeatJitterFraction??0,this.getAuthHeaders=r?.getAuthHeaders??S,n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`CCRClient: Expected http(s) URL, got ${n.protocol}`);let i=n.pathname.replace(/\/$/,``);this.sessionBaseUrl=`${n.protocol}//${n.host}${i}`,this.sessionId=i.split(`/`).pop()||``,this.workerState=new D({send:e=>this.request(`put`,`/worker`,{worker_epoch:this.workerEpoch,...e},`PUT worker`).then(e=>e.ok),baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.eventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:1e5,send:async e=>{let t=await this.request(`post`,`/worker/events`,{worker_epoch:this.workerEpoch,events:e},`client events`);if(!t.ok)throw new T(`client event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.internalEventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:200,send:async e=>{let t=await this.request(`post`,`/worker/internal-events`,{worker_epoch:this.workerEpoch,events:e},`internal events`);if(!t.ok)throw new T(`internal event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.deliveryUploader=new E({maxBatchSize:64,maxQueueSize:64,send:async e=>{let t=await this.request(`post`,`/worker/events/delivery`,{worker_epoch:this.workerEpoch,updates:e.map(e=>({event_id:e.eventId,status:e.status}))},`delivery batch`);if(!t.ok)throw new T(`delivery POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),e.setOnEvent(e=>{this.reportDelivery(e.event_id,`received`)})}async initialize(e){let t=Date.now();if(Object.keys(this.getAuthHeaders()).length===0)throw new M(`no_auth_headers`);if(e===void 0){let t=process.env.CLAUDE_CODE_WORKER_EPOCH;e=t?parseInt(t,10):NaN}if(isNaN(e))throw new M(`missing_epoch`);this.workerEpoch=e;let n=this.getWorkerState();if(!(await this.request(`put`,`/worker`,{worker_status:`idle`,worker_epoch:this.workerEpoch,external_metadata:{pending_action:null,task_summary:null,automation_state:null}},`PUT worker (init)`)).ok)throw new M(`worker_register_failed`);this.currentState=`idle`,this.startHeartbeat(),y(()=>{this.writeEvent({type:`keep_alive`})}),o(`CCRClient: initialized, epoch=${this.workerEpoch}`),u(`info`,`cli_worker_lifecycle_initialized`,{epoch:this.workerEpoch,duration_ms:Date.now()-t});let{metadata:r,durationMs:i}=await n;return this.closed||u(`info`,`cli_worker_state_restored`,{duration_ms:i,had_state:r!==null}),r}async getWorkerState(){let e=Date.now(),t=this.getAuthHeaders();return Object.keys(t).length===0?{metadata:null,durationMs:0}:{metadata:(await this.getWithRetry(`${this.sessionBaseUrl}/worker`,t,`worker_state`))?.worker?.external_metadata??null,durationMs:Date.now()-e}}async request(e,t,n,a,{timeout:s=1e4}={}){let c=this.getAuthHeaders();if(Object.keys(c).length===0)return{ok:!1};try{let r=await this.http[e](`${this.sessionBaseUrl}${t}`,n,{headers:{...c,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`,"User-Agent":g()},validateStatus:j,timeout:s});if(r.status>=200&&r.status<300)return this.consecutiveAuthFailures=0,{ok:!0};if(r.status===409&&this.handleEpochMismatch(),r.status===401||r.status===403){let e=v(),t=e?C(e):null;t!==null&&t*1e3<Date.now()&&(o(`CCRClient: session_token expired (exp=${new Date(t*1e3).toISOString()}) — no refresh was delivered, exiting`,{level:`error`}),u(`error`,`cli_worker_token_expired_no_refresh`),this.onEpochMismatch()),this.consecutiveAuthFailures++,this.consecutiveAuthFailures>=N&&(o(`CCRClient: ${this.consecutiveAuthFailures} consecutive auth failures with a valid-looking token — server-side auth unrecoverable, exiting`,{level:`error`}),u(`error`,`cli_worker_auth_failures_exhausted`),this.onEpochMismatch())}if(o(`CCRClient: ${a} returned ${r.status}`,{level:`warn`}),u(`warn`,`cli_worker_request_failed`,{method:e,path:t,status:r.status}),r.status===429){let e=r.headers?.[`retry-after`],t=typeof e==`string`?parseInt(e,10):NaN;if(!isNaN(t)&&t>=0)return{ok:!1,retryAfterMs:t*1e3}}return{ok:!1}}catch(n){return o(`CCRClient: ${a} failed: ${i(n)}`,{level:`warn`}),u(`warn`,`cli_worker_request_error`,{method:e,path:t,error_code:r(n)}),{ok:!1}}}reportState(e,t){e===this.currentState&&!t||(this.currentState=e,this.workerState.enqueue({worker_status:e,requires_action_details:t?{tool_name:t.tool_name,action_description:t.action_description,request_id:t.request_id}:null}))}reportMetadata(e){this.workerState.enqueue({external_metadata:e})}handleEpochMismatch(){o(`CCRClient: Epoch mismatch (409), shutting down`,{level:`error`}),u(`error`,`cli_worker_epoch_mismatch`),this.onEpochMismatch()}startHeartbeat(){this.stopHeartbeat();let e=()=>{let e=this.heartbeatIntervalMs*this.heartbeatJitterFraction*(2*Math.random()-1);this.heartbeatTimer=setTimeout(t,this.heartbeatIntervalMs+e)},t=()=>{this.sendHeartbeat(),this.heartbeatTimer!==null&&e()};e()}stopHeartbeat(){this.heartbeatTimer&&(clearTimeout(this.heartbeatTimer),this.heartbeatTimer=null)}async sendHeartbeat(){if(!this.heartbeatInFlight){this.heartbeatInFlight=!0;try{(await this.request(`post`,`/worker/heartbeat`,{session_id:this.sessionId,worker_epoch:this.workerEpoch},`Heartbeat`,{timeout:5e3})).ok&&o(`CCRClient: Heartbeat sent`)}finally{this.heartbeatInFlight=!1}}}async writeEvent(e){if(e.type===`stream_event`){this.streamEventBuffer.push(e),this.streamEventTimer||(this.streamEventTimer=setTimeout(()=>void this.flushStreamEventBuffer(),A));return}await this.flushStreamEventBuffer(),e.type===`assistant`&&L(this.streamTextAccumulator,e),await this.eventUploader.enqueue(this.toClientEvent(e))}toClientEvent(e){let t=e;return{payload:{...t,uuid:typeof t.uuid==`string`?t.uuid:w()}}}async flushStreamEventBuffer(){if(this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer.length===0)return;let e=this.streamEventBuffer;this.streamEventBuffer=[];let t=I(e,this.streamTextAccumulator);await this.eventUploader.enqueue(t.map(e=>({payload:e,ephemeral:!0})))}async writeInternalEvent(e,t,{isCompaction:n=!1,agentId:r}={}){let i={payload:{type:e,...t,uuid:typeof t.uuid==`string`?t.uuid:w()},...n&&{is_compaction:!0},...r&&{agent_id:r}};await this.internalEventUploader.enqueue(i)}flushInternalEvents(){return this.internalEventUploader.flush()}async flush(){return await this.flushStreamEventBuffer(),this.eventUploader.flush()}async readInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{},`internal_events`)}async readSubagentInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{subagents:`true`},`subagent_events`)}async paginatedGet(e,t,n){let r=this.getAuthHeaders();if(Object.keys(r).length===0)return null;let i=[],a;do{let o=new URL(`${this.sessionBaseUrl}${e}`);for(let[e,n]of Object.entries(t))o.searchParams.set(e,n);a&&o.searchParams.set(`cursor`,a);let s=await this.getWithRetry(o.toString(),r,n);if(!s)return null;i.push(...s.data??[]),a=s.next_cursor}while(a);return o(`CCRClient: Read ${i.length} internal events from ${e}${t.subagents?` (subagents)`:``}`),i}async getWithRetry(e,t,n){for(let n=1;n<=10;n++){let r;try{r=await this.http.get(e,{headers:{...t,"anthropic-version":`2023-06-01`,"User-Agent":g()},validateStatus:j,timeout:3e4})}catch(t){o(`CCRClient: GET ${e} failed (attempt ${n}/10): ${i(t)}`,{level:`warn`}),n<10&&await f(Math.min(500*2**(n-1),3e4)+Math.random()*500);continue}if(r.status>=200&&r.status<300)return r.data;r.status===409&&this.handleEpochMismatch(),o(`CCRClient: GET ${e} returned ${r.status} (attempt ${n}/10)`,{level:`warn`}),n<10&&await f(Math.min(500*2**(n-1),3e4)+Math.random()*500)}return o(`CCRClient: GET retries exhausted`,{level:`error`}),u(`error`,`cli_worker_get_retries_exhausted`,{context:n}),null}reportDelivery(e,t){this.deliveryUploader.enqueue({eventId:e,status:t})}getWorkerEpoch(){return this.workerEpoch}get internalEventsPending(){return this.internalEventUploader.pendingCount}close(){this.closed=!0,this.stopHeartbeat(),b(),this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer=[],this.streamTextAccumulator.byMessage.clear(),this.streamTextAccumulator.scopeToMessage.clear(),this.workerState.close(),this.eventUploader.close(),this.internalEventUploader.close(),this.deliveryUploader.close()}};export{M as n,E as r,R as t};
|
|
1
|
+
import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,F as r,P as i,R as a,c as o,i as s,x as c}from"./debug-D7OBvqC2.js";import{O as l,k as u}from"./git-CNhyfMtb.js";import{dn as d,fn as f}from"./model-xI2MbgRj.js";import{l as p,r as m}from"./proxy-DFIxRT0i.js";import{n as h,t as g}from"./userAgent-D8vvjitA.js";import{C as _,S as v,f as y,g as b,u as x,x as S}from"./sessionState-B3tFm9SC.js";import{n as C}from"./jwtUtils-ClCcC8lO.js";import{randomUUID as w}from"crypto";a(),s(),l(),p(),h(),d(),_(),x(),c(),e();var T=class extends Error{constructor(e,n){super(e),t(this,`retryAfterMs`,void 0),this.retryAfterMs=n}},E=class{constructor(e){t(this,`pending`,[]),t(this,`pendingAtClose`,0),t(this,`draining`,!1),t(this,`closed`,!1),t(this,`backpressureResolvers`,[]),t(this,`sleepResolve`,null),t(this,`flushResolvers`,[]),t(this,`droppedBatches`,0),t(this,`config`,void 0),this.config=e}get droppedBatchCount(){return this.droppedBatches}get pendingCount(){return this.closed?this.pendingAtClose:this.pending.length}async enqueue(e){if(this.closed)return;let t=Array.isArray(e)?e:[e];if(t.length!==0){for(;this.pending.length+t.length>this.config.maxQueueSize&&!this.closed;)await new Promise(e=>{this.backpressureResolvers.push(e)});this.closed||(this.pending.push(...t),this.drain())}}flush(){return this.pending.length===0&&!this.draining?Promise.resolve():(this.drain(),new Promise(e=>{this.flushResolvers.push(e)}))}close(){if(!this.closed){this.closed=!0,this.pendingAtClose=this.pending.length,this.pending=[],this.sleepResolve?.(),this.sleepResolve=null;for(let e of this.backpressureResolvers)e();this.backpressureResolvers=[];for(let e of this.flushResolvers)e();this.flushResolvers=[]}}async drain(){if(this.draining||this.closed)return;this.draining=!0;let e=0;try{for(;this.pending.length>0&&!this.closed;){let t=this.takeBatch();if(t.length!==0){try{await this.config.send(t),e=0}catch(n){if(e++,this.config.maxConsecutiveFailures!==void 0&&e>=this.config.maxConsecutiveFailures){this.droppedBatches++,this.config.onBatchDropped?.(t.length,e),e=0,this.releaseBackpressure();continue}this.pending=t.concat(this.pending);let r=n instanceof T?n.retryAfterMs:void 0;await this.sleep(this.retryDelay(e,r));continue}this.releaseBackpressure()}}}finally{if(this.draining=!1,this.pending.length===0){for(let e of this.flushResolvers)e();this.flushResolvers=[]}}}takeBatch(){let{maxBatchSize:e,maxBatchBytes:t}=this.config;if(t===void 0)return this.pending.splice(0,e);let r=0,i=0;for(;i<this.pending.length&&i<e;){let e;try{e=Buffer.byteLength(n(this.pending[i]))}catch{this.pending.splice(i,1);continue}if(i>0&&r+e>t)break;r+=e,i++}return this.pending.splice(0,i)}retryDelay(e,t){let n=Math.random()*this.config.jitterMs;return t===void 0?Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+n:Math.max(this.config.baseDelayMs,Math.min(t,this.config.maxDelayMs))+n}releaseBackpressure(){let e=this.backpressureResolvers;this.backpressureResolvers=[];for(let t of e)t()}sleep(e){return new Promise(t=>{this.sleepResolve=t,setTimeout((e,t)=>{e.sleepResolve=null,t()},e,this,t)})}};e();var D=class{constructor(e){t(this,`inflight`,null),t(this,`pending`,null),t(this,`closed`,!1),t(this,`config`,void 0),this.config=e}enqueue(e){this.closed||(this.pending=this.pending?O(this.pending,e):e,this.drain())}close(){this.closed=!0,this.pending=null}async drain(){if(this.inflight||this.closed||!this.pending)return;let e=this.pending;this.pending=null,this.inflight=this.sendWithRetry(e).then(()=>{this.inflight=null,this.pending&&!this.closed&&this.drain()})}async sendWithRetry(e){let t=e,n=0;for(;!this.closed;){if(await this.config.send(t))return;n++,await f(this.retryDelay(n)),this.pending&&!this.closed&&(t=O(t,this.pending),this.pending=null)}}retryDelay(e){return Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+Math.random()*this.config.jitterMs}};function O(e,t){let n={...e};for(let[e,r]of Object.entries(t))(e===`external_metadata`||e===`internal_metadata`)&&n[e]&&typeof n[e]==`object`&&typeof r==`object`&&r?n[e]={...n[e],...r}:n[e]=r;return n}d(),e();var k=2e4,A=100;function j(){return!0}var M=class extends Error{constructor(e){super(`CCRClient init failed: ${e}`),t(this,`reason`,void 0),this.reason=e}},N=10;function P(){return{byMessage:new Map,scopeToMessage:new Map}}function F(e){return`${e.session_id}:${e.parent_tool_use_id??``}`}function I(e,t){let n=[],r=new Map;for(let i of e){let e=i.event;switch(e.type){case`message_start`:{let r=e.message.id,a=t.scopeToMessage.get(F(i));a&&t.byMessage.delete(a),t.scopeToMessage.set(F(i),r),t.byMessage.set(r,[]),n.push(i);break}case`content_block_delta`:{let a=e.delta;if(a.type!==`text_delta`){n.push(i);break}let o=t.scopeToMessage.get(F(i)),s=o?t.byMessage.get(o):void 0;if(!s){n.push(i);break}let c=e.index,l=s[c]??(s[c]=[]);l.push(a.text);let u=r.get(l);if(u){u.event.delta={type:`text_delta`,text:l.join(``)};break}let d={type:`stream_event`,uuid:i.uuid,session_id:i.session_id,parent_tool_use_id:i.parent_tool_use_id,event:{type:`content_block_delta`,index:c,delta:{type:`text_delta`,text:l.join(``)}}};r.set(l,d),n.push(d);break}default:n.push(i)}}return n}function L(e,t){e.byMessage.delete(t.message.id);let n=F(t);e.scopeToMessage.get(n)===t.message.id&&e.scopeToMessage.delete(n)}var R=class{constructor(e,n,r){if(t(this,`workerEpoch`,0),t(this,`heartbeatIntervalMs`,void 0),t(this,`heartbeatJitterFraction`,void 0),t(this,`heartbeatTimer`,null),t(this,`heartbeatInFlight`,!1),t(this,`closed`,!1),t(this,`consecutiveAuthFailures`,0),t(this,`currentState`,null),t(this,`sessionBaseUrl`,void 0),t(this,`sessionId`,void 0),t(this,`http`,m({keepAlive:!0})),t(this,`streamEventBuffer`,[]),t(this,`streamEventTimer`,null),t(this,`streamTextAccumulator`,P()),t(this,`workerState`,void 0),t(this,`eventUploader`,void 0),t(this,`internalEventUploader`,void 0),t(this,`deliveryUploader`,void 0),t(this,`onEpochMismatch`,void 0),t(this,`getAuthHeaders`,void 0),this.onEpochMismatch=r?.onEpochMismatch??(()=>{process.exit(1)}),this.heartbeatIntervalMs=r?.heartbeatIntervalMs??k,this.heartbeatJitterFraction=r?.heartbeatJitterFraction??0,this.getAuthHeaders=r?.getAuthHeaders??S,n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`CCRClient: Expected http(s) URL, got ${n.protocol}`);let i=n.pathname.replace(/\/$/,``);this.sessionBaseUrl=`${n.protocol}//${n.host}${i}`,this.sessionId=i.split(`/`).pop()||``,this.workerState=new D({send:e=>this.request(`put`,`/worker`,{worker_epoch:this.workerEpoch,...e},`PUT worker`).then(e=>e.ok),baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.eventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:1e5,send:async e=>{let t=await this.request(`post`,`/worker/events`,{worker_epoch:this.workerEpoch,events:e},`client events`);if(!t.ok)throw new T(`client event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.internalEventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:200,send:async e=>{let t=await this.request(`post`,`/worker/internal-events`,{worker_epoch:this.workerEpoch,events:e},`internal events`);if(!t.ok)throw new T(`internal event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.deliveryUploader=new E({maxBatchSize:64,maxQueueSize:64,send:async e=>{let t=await this.request(`post`,`/worker/events/delivery`,{worker_epoch:this.workerEpoch,updates:e.map(e=>({event_id:e.eventId,status:e.status}))},`delivery batch`);if(!t.ok)throw new T(`delivery POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),e.setOnEvent(e=>{this.reportDelivery(e.event_id,`received`)})}async initialize(e){let t=Date.now();if(Object.keys(this.getAuthHeaders()).length===0)throw new M(`no_auth_headers`);if(e===void 0){let t=process.env.CLAUDE_CODE_WORKER_EPOCH;e=t?parseInt(t,10):NaN}if(isNaN(e))throw new M(`missing_epoch`);this.workerEpoch=e;let n=this.getWorkerState();if(!(await this.request(`put`,`/worker`,{worker_status:`idle`,worker_epoch:this.workerEpoch,external_metadata:{pending_action:null,task_summary:null,automation_state:null}},`PUT worker (init)`)).ok)throw new M(`worker_register_failed`);this.currentState=`idle`,this.startHeartbeat(),y(()=>{this.writeEvent({type:`keep_alive`})}),o(`CCRClient: initialized, epoch=${this.workerEpoch}`),u(`info`,`cli_worker_lifecycle_initialized`,{epoch:this.workerEpoch,duration_ms:Date.now()-t});let{metadata:r,durationMs:i}=await n;return this.closed||u(`info`,`cli_worker_state_restored`,{duration_ms:i,had_state:r!==null}),r}async getWorkerState(){let e=Date.now(),t=this.getAuthHeaders();return Object.keys(t).length===0?{metadata:null,durationMs:0}:{metadata:(await this.getWithRetry(`${this.sessionBaseUrl}/worker`,t,`worker_state`))?.worker?.external_metadata??null,durationMs:Date.now()-e}}async request(e,t,n,a,{timeout:s=1e4}={}){let c=this.getAuthHeaders();if(Object.keys(c).length===0)return{ok:!1};try{let r=await this.http[e](`${this.sessionBaseUrl}${t}`,n,{headers:{...c,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`,"User-Agent":g()},validateStatus:j,timeout:s});if(r.status>=200&&r.status<300)return this.consecutiveAuthFailures=0,{ok:!0};if(r.status===409&&this.handleEpochMismatch(),r.status===401||r.status===403){let e=v(),t=e?C(e):null;t!==null&&t*1e3<Date.now()&&(o(`CCRClient: session_token expired (exp=${new Date(t*1e3).toISOString()}) — no refresh was delivered, exiting`,{level:`error`}),u(`error`,`cli_worker_token_expired_no_refresh`),this.onEpochMismatch()),this.consecutiveAuthFailures++,this.consecutiveAuthFailures>=N&&(o(`CCRClient: ${this.consecutiveAuthFailures} consecutive auth failures with a valid-looking token — server-side auth unrecoverable, exiting`,{level:`error`}),u(`error`,`cli_worker_auth_failures_exhausted`),this.onEpochMismatch())}if(o(`CCRClient: ${a} returned ${r.status}`,{level:`warn`}),u(`warn`,`cli_worker_request_failed`,{method:e,path:t,status:r.status}),r.status===429){let e=r.headers?.[`retry-after`],t=typeof e==`string`?parseInt(e,10):NaN;if(!isNaN(t)&&t>=0)return{ok:!1,retryAfterMs:t*1e3}}return{ok:!1}}catch(n){return o(`CCRClient: ${a} failed: ${i(n)}`,{level:`warn`}),u(`warn`,`cli_worker_request_error`,{method:e,path:t,error_code:r(n)}),{ok:!1}}}reportState(e,t){e===this.currentState&&!t||(this.currentState=e,this.workerState.enqueue({worker_status:e,requires_action_details:t?{tool_name:t.tool_name,action_description:t.action_description,request_id:t.request_id}:null}))}reportMetadata(e){this.workerState.enqueue({external_metadata:e})}handleEpochMismatch(){o(`CCRClient: Epoch mismatch (409), shutting down`,{level:`error`}),u(`error`,`cli_worker_epoch_mismatch`),this.onEpochMismatch()}startHeartbeat(){this.stopHeartbeat();let e=()=>{let e=this.heartbeatIntervalMs*this.heartbeatJitterFraction*(2*Math.random()-1);this.heartbeatTimer=setTimeout(t,this.heartbeatIntervalMs+e)},t=()=>{this.sendHeartbeat(),this.heartbeatTimer!==null&&e()};e()}stopHeartbeat(){this.heartbeatTimer&&(clearTimeout(this.heartbeatTimer),this.heartbeatTimer=null)}async sendHeartbeat(){if(!this.heartbeatInFlight){this.heartbeatInFlight=!0;try{(await this.request(`post`,`/worker/heartbeat`,{session_id:this.sessionId,worker_epoch:this.workerEpoch},`Heartbeat`,{timeout:5e3})).ok&&o(`CCRClient: Heartbeat sent`)}finally{this.heartbeatInFlight=!1}}}async writeEvent(e){if(e.type===`stream_event`){this.streamEventBuffer.push(e),this.streamEventTimer||(this.streamEventTimer=setTimeout(()=>void this.flushStreamEventBuffer(),A));return}await this.flushStreamEventBuffer(),e.type===`assistant`&&L(this.streamTextAccumulator,e),await this.eventUploader.enqueue(this.toClientEvent(e))}toClientEvent(e){let t=e;return{payload:{...t,uuid:typeof t.uuid==`string`?t.uuid:w()}}}async flushStreamEventBuffer(){if(this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer.length===0)return;let e=this.streamEventBuffer;this.streamEventBuffer=[];let t=I(e,this.streamTextAccumulator);await this.eventUploader.enqueue(t.map(e=>({payload:e,ephemeral:!0})))}async writeInternalEvent(e,t,{isCompaction:n=!1,agentId:r}={}){let i={payload:{type:e,...t,uuid:typeof t.uuid==`string`?t.uuid:w()},...n&&{is_compaction:!0},...r&&{agent_id:r}};await this.internalEventUploader.enqueue(i)}flushInternalEvents(){return this.internalEventUploader.flush()}async flush(){return await this.flushStreamEventBuffer(),this.eventUploader.flush()}async readInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{},`internal_events`)}async readSubagentInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{subagents:`true`},`subagent_events`)}async paginatedGet(e,t,n){let r=this.getAuthHeaders();if(Object.keys(r).length===0)return null;let i=[],a;do{let o=new URL(`${this.sessionBaseUrl}${e}`);for(let[e,n]of Object.entries(t))o.searchParams.set(e,n);a&&o.searchParams.set(`cursor`,a);let s=await this.getWithRetry(o.toString(),r,n);if(!s)return null;i.push(...s.data??[]),a=s.next_cursor}while(a);return o(`CCRClient: Read ${i.length} internal events from ${e}${t.subagents?` (subagents)`:``}`),i}async getWithRetry(e,t,n){for(let n=1;n<=10;n++){let r;try{r=await this.http.get(e,{headers:{...t,"anthropic-version":`2023-06-01`,"User-Agent":g()},validateStatus:j,timeout:3e4})}catch(t){o(`CCRClient: GET ${e} failed (attempt ${n}/10): ${i(t)}`,{level:`warn`}),n<10&&await f(Math.min(500*2**(n-1),3e4)+Math.random()*500);continue}if(r.status>=200&&r.status<300)return r.data;r.status===409&&this.handleEpochMismatch(),o(`CCRClient: GET ${e} returned ${r.status} (attempt ${n}/10)`,{level:`warn`}),n<10&&await f(Math.min(500*2**(n-1),3e4)+Math.random()*500)}return o(`CCRClient: GET retries exhausted`,{level:`error`}),u(`error`,`cli_worker_get_retries_exhausted`,{context:n}),null}reportDelivery(e,t){this.deliveryUploader.enqueue({eventId:e,status:t})}getWorkerEpoch(){return this.workerEpoch}get internalEventsPending(){return this.internalEventUploader.pendingCount}close(){this.closed=!0,this.stopHeartbeat(),b(),this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer=[],this.streamTextAccumulator.byMessage.clear(),this.streamTextAccumulator.scopeToMessage.clear(),this.workerState.close(),this.eventUploader.close(),this.internalEventUploader.close(),this.deliveryUploader.close()}};export{M as n,E as r,R as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as e,R as t}from"./debug-
|
|
1
|
+
import{F as e,R as t}from"./debug-D7OBvqC2.js";import{o as n,s as r}from"./log-CR0v5KUR.js";import{i,o as a,t as o}from"./platform-BZm4WVLM.js";import{a as s,i as c,s as l,u}from"./types-DDku8UKF.js";import{homedir as d}from"os";import{join as f}from"path";import{readFile as p,readdir as m,stat as h}from"fs/promises";s(),t(),l(),n(),a();async function g(){let e=i();if(!o.includes(e))throw Error(`Unsupported platform: ${e} - Work Mate Desktop integration only works on macOS and WSL.`);if(e===`macos`)return f(d(),`Library`,`Application Support`,`Work Mate`,`claude_desktop_config.json`);let t=process.env.USERPROFILE?process.env.USERPROFILE.replace(/\\/g,`/`):null;if(t){let e=`/mnt/c${t.replace(/^[A-Z]:/,``)}/AppData/Roaming/Work Mate/claude_desktop_config.json`;try{return await h(e),e}catch{}}try{let e=`/mnt/c/Users`;try{let t=await m(e,{withFileTypes:!0});for(let n of t){if(n.name===`Public`||n.name===`Default`||n.name===`Default User`||n.name===`All Users`)continue;let t=f(e,n.name,`AppData`,`Roaming`,`Work Mate`,`claude_desktop_config.json`);try{return await h(t),t}catch{}}}catch{}}catch(e){r(e)}throw Error(`Could not find Work Mate Desktop config file in Windows. Make sure Work Mate Desktop is installed on Windows.`)}async function _(){if(!o.includes(i()))throw Error(`Unsupported platform - Work Mate Desktop integration only works on macOS and WSL.`);try{let t=await g(),n;try{n=await p(t,{encoding:`utf8`})}catch(t){if(e(t)===`ENOENT`)return{};throw t}let r=u(n);if(!r||typeof r!=`object`)return{};let i=r.mcpServers;if(!i||typeof i!=`object`)return{};let a={};for(let[e,t]of Object.entries(i)){if(!t||typeof t!=`object`)continue;let n=c().safeParse(t);n.success&&(a[e]=n.data)}return a}catch(e){return r(e),{}}}export{_ as readClaudeDesktopMcpServers};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./conversation-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./conversation-Bos7yTIv.js";var r;e((()=>{t(),r=async(e,t)=>(await n(t),{type:`text`,value:``})}))();export{r as call};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./bundledMode--fG1S62b.js";import{i as n,r}from"./shellQuote-
|
|
1
|
+
import{n as e,t}from"./bundledMode--fG1S62b.js";import{i as n,r}from"./shellQuote-C-7PluUY.js";import{spawn as i}from"child_process";t(),r();function a(t){let n=[];for(let r=0;r<t.length;r++){let i=t[r];if(i===`-d`||i.startsWith(`-d `)||i.startsWith(`-d `)){n.push(i),i===`-d`&&r+1<t.length&&n.push(t[++r]);continue}if(i.startsWith(`-d`)&&i.includes(`:`)){n.push(i);continue}if(i===`--feature`){n.push(i),r+1<t.length&&n.push(t[++r]);continue}if(/^--inspect(-brk)?(=|$)/.test(i)){n.push(i);continue}if(i.startsWith(`--`)&&!i.includes(`=`)&&r+1<t.length){if(e())continue;n.push(i),n.push(t[++r]);continue}i.startsWith(`-`)&&!e()&&n.push(i)}return n}var o=Object.freeze(a(process.execArgv)),s=process.argv[1],c=process.execPath,l=process.platform===`win32`;function u(t,n){let r=n?.env??process.env,i=e()||!s?[...o,...t]:[...o,s,...t],a={...r};return l&&(process.env.CLAUDE_CODE_GIT_BASH_PATH&&!a.CLAUDE_CODE_GIT_BASH_PATH&&(a.CLAUDE_CODE_GIT_BASH_PATH=process.env.CLAUDE_CODE_GIT_BASH_PATH),process.env.SHELL&&!a.SHELL&&(a.SHELL=process.env.SHELL)),{execPath:c,args:i,env:a,windowsHide:l}}function d(e,t){return i(e.execPath,e.args,{...t,env:{...e.env,...t.env},windowsHide:e.windowsHide})}function f(e){return n([e.execPath,...e.args])}function p(){return o}function m(){return s}export{d as a,f as i,p as n,m as r,u as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./client-eLOYyeES.js";e();export{t as clearOpenAIClientCache};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Dr as e,Or as t}from"./model-xI2MbgRj.js";t();export{e as getOrganizationUUID};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./client-o5_awagP.js";e();export{t as getGrokClient};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,l as n}from"./proxy-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,l as n}from"./proxy-DFIxRT0i.js";import{n as r,t as i}from"./openai-CR3CcjCE.js";import{r as a,t as o}from"./store-Z8rTjDHe.js";function s(e){if(!e)return 0;let t=0,n=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g,r;for(;(r=n.exec(e))!==null;){let e=Number(r[1]);switch(r[2]){case`ms`:t+=e/1e3;break;case`s`:t+=e;break;case`m`:t+=e*60;break;case`h`:t+=e*3600;break;case`d`:t+=e*86400;break}}if(t===0){let n=Number(e);Number.isFinite(n)&&(t=n)}return t<=0?0:Math.floor(Date.now()/1e3)+t}function c(e,t){if(e===null||t===null)return null;let n=Number(e),r=Number(t);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=0)return null;let i=Math.max(0,r-n);return Math.min(1,Math.max(0,i/r))}var l,u=e((()=>{l={providerId:`openai`,parseHeaders(e){let t=[],n=c(e.get(`x-ratelimit-remaining-requests`),e.get(`x-ratelimit-limit-requests`));n!==null&&t.push({kind:`requests`,label:`RPM`,utilization:n,resetsAt:s(e.get(`x-ratelimit-reset-requests`))||void 0});let r=c(e.get(`x-ratelimit-remaining-tokens`),e.get(`x-ratelimit-limit-tokens`));return r!==null&&t.push({kind:`tokens`,label:`TPM`,utilization:r,resetsAt:s(e.get(`x-ratelimit-reset-tokens`))||void 0}),t}}}));function d(e){return async(...t)=>{let n=await e(...t);try{a(`openai`,l.parseHeaders(n.headers))}catch{}return n}}function f(e){if(m)return m;let n=process.env.OPENAI_API_KEY||``,i=process.env.OPENAI_BASE_URL,a=d(e?.fetchOverride??globalThis.fetch),o=new r({apiKey:n,...i&&{baseURL:i},maxRetries:e?.maxRetries??0,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,...process.env.OPENAI_ORG_ID&&{organization:process.env.OPENAI_ORG_ID},...process.env.OPENAI_PROJECT_ID&&{project:process.env.OPENAI_PROJECT_ID},fetchOptions:t({forAnthropicAPI:!1}),fetch:a});return e?.fetchOverride||(m=o),o}function p(){m=null}var m,h=e((()=>{i(),u(),o(),n(),m=null}));export{f as n,h as r,p as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,l as n}from"./proxy-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,l as n}from"./proxy-DFIxRT0i.js";import{n as r,t as i}from"./openai-CR3CcjCE.js";function a(e){if(s)return s;let n=new r({apiKey:process.env.GROK_API_KEY||process.env.XAI_API_KEY||``,baseURL:process.env.GROK_BASE_URL||o,maxRetries:e?.maxRetries??0,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,fetchOptions:t({forAnthropicAPI:!1}),...e?.fetchOverride&&{fetch:e.fetchOverride}});return e?.fetchOverride||(s=n),n}var o,s,c=e((()=>{i(),n(),o=`https://api.x.ai/v1`,s=null}));export{c as n,a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Di as e,Li as t,Mi as n}from"./loadAgentsDir-DnsldjYU.js";t();export{e as clearCommandsCache,n as getCommands};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,Am as n,G_ as r,Im as i,J_ as a,La as o,Om as s,Pm as c,W_ as l,Y_ as u,_p as d,at as f,bC as p,bv as m,ev as h,fv as g,hn as _,iv as v,ka as y,l_ as b,o_ as x,ot as S,q_ as C,rv as w,s_ as T,u_ as E,vp as D,vv as O,xv as k,yC as A}from"./loadAgentsDir-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,Am as n,G_ as r,Im as i,J_ as a,La as o,Om as s,Pm as c,W_ as l,Y_ as u,_p as d,at as f,bC as p,bv as m,ev as h,fv as g,hn as _,iv as v,ka as y,l_ as b,o_ as x,ot as S,q_ as C,rv as w,s_ as T,u_ as E,vp as D,vv as O,xv as k,yC as A}from"./loadAgentsDir-DnsldjYU.js";import{di as j,fi as M}from"./src-DL3w8VPk2.js";import{Wt as N,qt as P}from"./state-B3zvBu4R.js";import{L as F,R as I}from"./debug-D7OBvqC2.js";import{o as L,s as R}from"./log-CR0v5KUR.js";function z(e,t){let n=d(`tip`),r=A(`app:toggleTranscript`,`Global`,`ctrl+o`),i=[...e.options.verbose?[]:[`(${r} to see full summary)`],...t?[t]:[],...n?[n]:[]];return j.dim(`Compacted ${i.join(`
|
|
2
2
|
`)}`)}async function B(e,t){let n=e.getAppState(),r=await f(e.options.tools,e.options.mainLoopModel,Array.from(n.toolPermissionContext.additionalWorkingDirectories.keys()),e.options.mcpClients),i=l({mainThreadAgentDefinition:void 0,toolUseContext:e,customSystemPrompt:e.options.customSystemPrompt,defaultSystemPrompt:r,appendSystemPrompt:e.options.appendSystemPrompt}),[o,s]=await Promise.all([a(),C()]);return{systemPrompt:i,userContext:o,systemContext:s,toolUseContext:e,forkContextMessages:t}}var V;e((()=>{M(),N(),S(),u(),p(),m(),E(),w(),t(),c(),s(),g(),I(),_(),L(),o(),D(),r(),V=async(e,t)=>{let{abortController:r}=t,{messages:o}=t;if(o=y(o),o.length===0)throw Error(`No messages to compact`);let s=e.trim();try{if(!s){let e=await n(o,t.agentId);if(e)return a.cache.clear?.(),i(),k(t.options.querySource??`compact`,t.agentId),P(),v(),{type:`compact`,compactionResult:e,displayText:z(t)}}let e=(await h(o,t)).messages,r=await b(e,t,await B(t,e),!1,s,!1);return O(void 0),v(),a.cache.clear?.(),i(),{type:`compact`,compactionResult:r,displayText:z(t,r.userDisplayMessage)}}catch(e){throw r.signal.aborted?Error(`Compaction canceled.`):F(e,`Not enough messages to compact. Send a few more messages first, then try again.`)?Error(T):F(e,`Compaction interrupted · This may be due to network issues — please try again.`)?Error(x):(R(e),Error(`Error during compaction: ${e}`))}}}))();export{V as call};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,h as t,n,o as r,r as i,v as a,y as o}from"./config-
|
|
1
|
+
import{c as e,h as t,n,o as r,r as i,v as a,y as o}from"./config-BybjRr09.js";t();export{n as checkHasTrustDialogAccepted,i as enableConfigs,r as getCurrentProjectConfig,e as getGlobalConfig,a as saveCurrentProjectConfig,o as saveGlobalConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as e,n as t,t as n}from"./rolldown-runtime-DaDcL9Zw.js";import{n as r,t as i}from"./isObject-C6qM3WEW.js";import{n as a,t as o}from"./memoize-BK3gG5ob.js";import{c as s,i as c,l,o as u}from"./envUtils-DcaKZlRU.js";import{t as d}from"./graceful-fs-DDVg0cja.js";import{Ar as f,Ci as p,Cr as m,Dr as h,Er as g,Fr as _,Or as v,Pr as ee,Si as te,Sr as ne,Wt as re,et as ie,fi as ae,gt as oe,hi as se,it as ce,jr as le,kr as ue,mi as de,oi as fe,pi as pe,si as me,vi as he,yi as ge}from"./state-BPFYBqm1.js";import{n as _e,t as ve}from"./cwd-Besi3Os3.js";import{C as y,F as b,O as x,R as ye,S as be,c as S,f as xe,i as Se,nt as Ce,tt as we,u as C,x as Te}from"./debug-BQj6h99Q.js";import{Cr as Ee,Dr as De,Fn as Oe,Jt as w,Or as ke,Qt as Ae,Xt as je,Yt as Me,_r as Ne,c as T,cr as Pe,g as Fe,lr as E,n as Ie,vr as Le,wn as Re,wr as ze}from"./settings-CvhsRFaT.js";import{O as Be,k as Ve,m as He,n as Ue}from"./git-DplvjXEY.js";import{d as We,o as Ge,s as Ke,u as qe}from"./log-BlJ7CcKG.js";import{m as Je}from"./sessionStoragePortable-x0Yn02-G.js";import{f as Ye,p as Xe,s as Ze,u as Qe}from"./types-BomO8WUz.js";import{n as $e,r as D}from"./analytics-DJobLaWP.js";import{homedir as et}from"os";import{basename as O,dirname as k,isAbsolute as tt,join as A,normalize as j,resolve as nt,sep as rt}from"path";import{unwatchFile as it,watchFile as at}from"fs";import{randomBytes as ot}from"crypto";var M,st=t((()=>{p(),Le(),pe(),de(),M=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)te(t,ae(e)),e=Ne(e);return t}:se}));function ct(e){return he(e,ze,M)}var lt=t((()=>{ge(),st(),Ee()}));function ut(){let e=process.env.CLAUDE_CODE_DISABLE_AUTO_MEMORY;if(l(e))return!1;if(s(e))return!0;if(l(process.env.CLAUDE_CODE_SIMPLE)||l(process.env.CLAUDE_CODE_REMOTE)&&!process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR)return!1;let t=Ie();return t.autoMemoryEnabled===void 0||t.autoMemoryEnabled}function dt(){return!1}function ft(){return process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR?process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR:c()}function pt(e,t){if(!e)return;let n=e;if(t&&(n.startsWith(`~/`)||n.startsWith(`~\\`))){let e=n.slice(2),t=j(e||`.`);if(t===`.`||t===`..`)return;n=A(et(),e)}let r=j(n).replace(/[/\\]+$/,``);if(!(!tt(r)||r.length<3||/^[A-Za-z]:$/.test(r)||r.startsWith(`\\\\`)||r.startsWith(`//`)||r.includes(`\0`)))return(r+rt).normalize(`NFC`)}function mt(){return pt(process.env.CLAUDE_COWORK_MEMORY_PATH_OVERRIDE,!1)}function ht(){return pt(T(`policySettings`)?.autoMemoryDirectory??T(`flagSettings`)?.autoMemoryDirectory??T(`localSettings`)?.autoMemoryDirectory??T(`userSettings`)?.autoMemoryDirectory,!0)}function gt(){return mt()!==void 0}function _t(){return Ue(ce())??ce()}function vt(){return A(N(),xt)}function yt(e){return j(e).startsWith(N())}var bt,xt,N,St=t((()=>{o(),re(),u(),He(),Pe(),Fe(),bt=`memory`,xt=`MEMORY.md`,N=a(()=>(mt()??ht())||(A(A(ft(),`projects`),Je(_t()),bt)+rt).normalize(`NFC`),()=>ce())}));function Ct(e,t,n,i){if(!r(e))return e;t=f(t,e);for(var a=-1,o=t.length,s=o-1,c=e;c!=null&&++a<o;){var l=ue(t[a]),u=n;if(l===`__proto__`||l===`constructor`||l===`prototype`)return e;if(a!=s){var d=c[l];u=i?i(d,l,c):void 0,u===void 0&&(u=r(d)?d:me(t[a+1])?[]:{})}De(c,l,u),c=c[l]}return e}var wt=t((()=>{ke(),le(),fe(),i(),v()}));function Tt(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=g(e,o);n(s,o)&&Ct(a,f(o,e),s)}return a}var Et=t((()=>{h(),wt(),le()}));function P(e,t){if(e==null)return{};var n=ee(ct(e),function(e){return[e]});return t=ne(t),Tt(e,n,function(e,n){return t(e,n[0])})}var Dt=t((()=>{_(),m(),Et(),lt()})),Ot=n(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),kt=n((e=>{var t=Ot();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&n.forever,unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),At=n(((e,t)=>{t.exports=kt()})),jt=n(((e,t)=>{t.exports=[`SIGABRT`,`SIGALRM`,`SIGHUP`,`SIGINT`,`SIGTERM`],process.platform!==`win32`&&t.exports.push(`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&t.exports.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`,`SIGUNUSED`)})),Mt=n(((t,n)=>{var r=global.process,i=function(e){return e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`};if(!i(r))n.exports=function(){return function(){}};else{var a=e(`assert`),o=jt(),s=/^win/i.test(r.platform),c=e(`events`);typeof c!=`function`&&(c=c.EventEmitter);var l;r.__signal_exit_emitter__?l=r.__signal_exit_emitter__:(l=r.__signal_exit_emitter__=new c,l.count=0,l.emitted={}),l.infinite||(l.setMaxListeners(1/0),l.infinite=!0),n.exports=function(e,t){if(!i(global.process))return function(){};a.equal(typeof e,`function`,`a callback must be provided for exit handler`),p===!1&&m();var n=`exit`;return t&&t.alwaysLast&&(n=`afterexit`),l.on(n,e),function(){l.removeListener(n,e),l.listeners(`exit`).length===0&&l.listeners(`afterexit`).length===0&&u()}};var u=function(){!p||!i(global.process)||(p=!1,o.forEach(function(e){try{r.removeListener(e,f[e])}catch{}}),r.emit=_,r.reallyExit=h,--l.count)};n.exports.unload=u;var d=function(e,t,n){l.emitted[e]||(l.emitted[e]=!0,l.emit(e,t,n))},f={};o.forEach(function(e){f[e]=function(){i(global.process)&&r.listeners(e).length===l.count&&(u(),d(`exit`,null,e),d(`afterexit`,null,e),s&&e===`SIGHUP`&&(e=`SIGINT`),r.kill(r.pid,e))}}),n.exports.signals=function(){return o};var p=!1,m=function(){p||!i(global.process)||(p=!0,l.count+=1,o=o.filter(function(e){try{return r.on(e,f[e]),!0}catch{return!1}}),r.emit=v,r.reallyExit=g)};n.exports.load=m;var h=r.reallyExit,g=function(e){i(global.process)&&(r.exitCode=e||0,d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),h.call(r,r.exitCode))},_=r.emit,v=function(e,t){if(e===`exit`&&i(global.process)){t!==void 0&&(r.exitCode=t);var n=_.apply(this,arguments);return d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),n}else return _.apply(this,arguments)}}})),Nt=n(((e,t)=>{var n=Symbol();function r(e,t,r){let i=t[n];if(i)return t.stat(e,(e,t)=>{if(e)return r(e);r(null,t.mtime,i)});let a=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,a,a,i=>{if(i)return r(i);t.stat(e,(e,i)=>{if(e)return r(e);let a=i.mtime.getTime()%1e3==0?`s`:`ms`;Object.defineProperty(t,n,{value:a}),r(null,i.mtime,a)})})}function i(e){let t=Date.now();return e===`s`&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}t.exports.probe=r,t.exports.getMtime=i})),Pt=n(((t,n)=>{var r=e(`path`),i=d(),a=At(),o=Mt(),s=Nt(),c={};function l(e,t){return t.lockfilePath||`${e}.lock`}function u(e,t,n){if(!t.realpath)return n(null,r.resolve(e));t.fs.realpath(e,n)}function f(e,t,n){let r=l(e,t);t.fs.mkdir(r,i=>{if(!i)return s.probe(r,t.fs,(e,i,a)=>{if(e)return t.fs.rmdir(r,()=>{}),n(e);n(null,i,a)});if(i.code!==`EEXIST`)return n(i);if(t.stale<=0)return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));t.fs.stat(r,(r,i)=>{if(r)return r.code===`ENOENT`?f(e,{...t,stale:0},n):n(r);if(!p(i,t))return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));m(e,t,r=>{if(r)return n(r);f(e,{...t,stale:0},n)})})})}function p(e,t){return e.mtime.getTime()<Date.now()-t.stale}function m(e,t,n){t.fs.rmdir(l(e,t),e=>{if(e&&e.code!==`ENOENT`)return n(e);n()})}function h(e,t){let n=c[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,t.fs.stat(n.lockfilePath,(r,i)=>{let a=n.lastUpdate+t.stale<Date.now();if(r)return r.code===`ENOENT`||a?g(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,h(e,t));if(n.mtime.getTime()!==i.mtime.getTime())return g(e,n,Object.assign(Error(`Unable to update lock within the stale threshold`),{code:`ECOMPROMISED`}));let o=s.getMtime(n.mtimePrecision);t.fs.utimes(n.lockfilePath,o,o,r=>{let i=n.lastUpdate+t.stale<Date.now();if(!n.released){if(r)return r.code===`ENOENT`||i?g(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,h(e,t));n.mtime=o,n.lastUpdate=Date.now(),n.updateDelay=null,h(e,t)}})})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function g(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),c[e]===t&&delete c[e],t.options.onCompromised(n)}function _(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:i,onCompromised:e=>{throw e},...t},t.retries=t.retries||0,t.retries=typeof t.retries==`number`?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),u(e,t,(e,r)=>{if(e)return n(e);let i=a.operation(t.retries);i.attempt(()=>{f(r,t,(e,a,o)=>{if(i.retry(e))return;if(e)return n(i.mainError());let s=c[r]={lockfilePath:l(r,t),mtime:a,mtimePrecision:o,options:t,lastUpdate:Date.now()};h(r,t),n(null,e=>{if(s.released)return e&&e(Object.assign(Error(`Lock is already released`),{code:`ERELEASED`}));v(r,{...t,realpath:!1},e)})})})})}function v(e,t,n){t={fs:i,realpath:!0,...t},u(e,t,(e,r)=>{if(e)return n(e);let i=c[r];if(!i)return n(Object.assign(Error(`Lock is not acquired/owned by you`),{code:`ENOTACQUIRED`}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete c[r],m(r,t,n)})}function ee(e,t,n){t={stale:1e4,realpath:!0,fs:i,...t},t.stale=Math.max(t.stale||0,2e3),u(e,t,(e,r)=>{if(e)return n(e);t.fs.stat(l(r,t),(e,r)=>e?e.code===`ENOENT`?n(null,!1):n(e):n(null,!p(r,t)))})}function te(){return c}o(()=>{for(let e in c){let t=c[e].options;try{t.fs.rmdirSync(l(e,t))}catch{}}}),n.exports.lock=_,n.exports.unlock=v,n.exports.check=ee,n.exports.getLocks=te})),Ft=n(((e,t)=>{var n=d();function r(e){let t=[`mkdir`,`realpath`,`stat`,`rmdir`,`utimes`],n={...e};return t.forEach(t=>{n[t]=(...n)=>{let r=n.pop(),i;try{i=e[`${t}Sync`](...n)}catch(e){return r(e)}r(null,i)}}),n}function i(e){return(...t)=>new Promise((n,r)=>{t.push((e,t)=>{e?r(e):n(t)}),e(...t)})}function a(e){return(...t)=>{let n,r;if(t.push((e,t)=>{n=e,r=t}),e(...t),n)throw n;return r}}function o(e){if(e={...e},e.fs=r(e.fs||n),typeof e.retries==`number`&&e.retries>0||e.retries&&typeof e.retries.retries==`number`&&e.retries.retries>0)throw Object.assign(Error(`Cannot use retries with the sync api`),{code:`ESYNC`});return e}t.exports={toPromise:i,toSync:a,toSyncOptions:o}})),It=n(((e,t)=>{var n=Pt(),{toPromise:r,toSync:i,toSyncOptions:a}=Ft();async function o(e,t){return r(await r(n.lock)(e,t))}function s(e,t){return i(i(n.lock)(e,a(t)))}function c(e,t){return r(n.unlock)(e,t)}function l(e,t){return i(n.unlock)(e,a(t))}function u(e,t){return r(n.check)(e,t)}function d(e,t){return i(n.check)(e,a(t))}t.exports=o,t.exports.lock=o,t.exports.unlock=c,t.exports.lockSync=s,t.exports.unlockSync=l,t.exports.check=u,t.exports.checkSync=d}));function F(){return I||(I=It()),I}function Lt(e,t){return F().lock(e,t)}function Rt(e,t){return F().lockSync(e,t)}function zt(e,t){return F().check(e,t)}var I,Bt=t((()=>{}));function L(){return{numStartups:0,installMethod:void 0,autoUpdates:void 0,theme:`dark`,preferredNotifChannel:`auto`,verbose:!1,editorMode:`normal`,autoCompactEnabled:!0,showTurnDuration:!0,hasSeenTasksHint:!1,hasUsedStash:!1,hasUsedBackgroundTask:!1,queuedCommandUpHintCount:0,diffTool:`auto`,customApiKeyResponses:{approved:[],rejected:[]},env:{},tipsHistory:{},memoryUsageCount:0,promptQueueUseCount:0,btwUseCount:0,todoFeatureEnabled:!0,showExpandedTodos:!1,messageIdleNotifThresholdMs:6e4,autoConnectIde:!1,autoInstallIdeExtension:!0,fileCheckpointingEnabled:!0,terminalProgressBarEnabled:!0,cachedStatsigGates:{},cachedDynamicConfigs:{},respectGitignore:!0}}function Vt(){return fn||(fn=Ht())}function Ht(){if(oe())return!0;let e=B(),t=$();if(e.projects?.[t]?.hasTrustDialogAccepted)return!0;let n=E(ve());for(;;){if(e.projects?.[n]?.hasTrustDialogAccepted)return!0;let t=E(nt(n,`..`));if(t===n)break;n=t}return!1}function R(e){let t=K.config;if(!t)return!1;let n=t.oauthAccount!==void 0&&e.oauthAccount===void 0,r=t.hasCompletedOnboarding===!0&&e.hasCompletedOnboarding!==!0;return n||r}function Ut(e){let t=null;try{Zt(w(),L,n=>{let r=e(n);return r===n?n:(t={...r,projects:Kt(n.projects)},t)})&&t&&z(t)}catch(n){S(`Failed to save config with lock: ${n}`,{level:`error`});let r=H(w(),L);if(R(r)){S(`saveGlobalConfig fallback: re-read config is missing auth that cache has; refusing to write. See GH #3117.`,{level:`error`}),D(`tengu_config_auth_loss_prevented`,{});return}let i=e(r);if(i===r)return;t={...i,projects:Kt(r.projects)},Xt(w(),t,G),z(t)}}function Wt(){let e=J+Y;e>0&&D(`tengu_config_cache_stats`,{cache_hits:J,cache_misses:Y,hit_rate:J/e}),J=0,Y=0}function Gt(e){if(e.installMethod!==void 0)return e;let t=e,n=`unknown`,r=e.autoUpdates??!0;switch(t.autoUpdaterStatus){case`migrated`:n=`local`;break;case`installed`:n=`native`;break;case`disabled`:r=!1;break;case`enabled`:case`no_permissions`:case`not_configured`:n=`global`;break;case void 0:break}return{...e,installMethod:n,autoUpdates:r}}function Kt(e){if(!e)return e;let t={},n=!1;for(let[r,i]of Object.entries(e)){let e=i;if(e.history!==void 0){n=!0;let{history:i,...a}=e;t[r]=a}else t[r]=i}return n?t:e}function qt(){if(Z)return;Z=!0;let e=w();at(e,{interval:pn,persistent:!1},t=>{t.mtimeMs<=K.mtime||C().readFile(e,{encoding:`utf-8`}).then(e=>{if(t.mtimeMs<=K.mtime)return;let n=Qe(Xe(e));typeof n!=`object`||!n||(K={config:Gt({...L(),...n}),mtime:t.mtimeMs},q={mtime:t.mtimeMs,size:t.size})}).catch(()=>{})}),Ce(async()=>{it(e),Z=!1})}function z(e){K={config:e,mtime:Date.now()},q=null}function B(){if(K.config)return J++,K.config;Y++;try{let e=null;try{e=C().statSync(w())}catch{}let t=Gt(H(w(),L));return K={config:t,mtime:e?.mtimeMs??Date.now()},q=e?{mtime:e.mtimeMs,size:e.size}:null,qt(),t}catch{return Gt(H(w(),L))}}function Jt(){let e=B().remoteControlAtStartup;return e!==void 0&&e}function Yt(e){let t=B();return t.customApiKeyResponses?.approved?.includes(e)?`approved`:t.customApiKeyResponses?.rejected?.includes(e)?`rejected`:`new`}function Xt(e,t,n){let r=k(e);C().mkdirSync(r),Oe(e,y(P(t,(e,t)=>y(e)!==y(n[t])),null,2),{encoding:`utf-8`,mode:384}),e===w()&&X++}function Zt(e,t,n){let r=t(),i=k(e),a=C();a.mkdirSync(i);let o;try{let i=`${e}.lock`,s=Date.now();o=Rt(e,{lockfilePath:i,onCompromised:e=>{S(`Config lock compromised: ${e}`,{level:`error`})}});let c=Date.now()-s;if(c>100&&(S(`Lock acquisition took longer than expected - another Work Mate instance may be running`),D(`tengu_config_lock_contention`,{lock_time_ms:c})),q&&e===w())try{let t=a.statSync(e);(t.mtimeMs!==q.mtime||t.size!==q.size)&&D(`tengu_config_stale_write`,{read_mtime:q.mtime,write_mtime:t.mtimeMs,read_size:q.size,write_size:t.size})}catch(e){if(b(e)!==`ENOENT`)throw e}let l=H(e,t);if(e===w()&&R(l))return S(`saveConfigWithLock: re-read config is missing auth that cache has; refusing to write to avoid wiping ~/.workmate.json. See GH #3117.`,{level:`error`}),D(`tengu_config_auth_loss_prevented`,{}),!1;let u=n(l);if(u===l)return!1;let d=P(u,(e,t)=>y(e)!==y(r[t]));try{let t=O(e),n=V();try{a.mkdirSync(n)}catch(e){if(b(e)!==`EEXIST`)throw e}let r=a.readdirStringSync(n).filter(e=>e.startsWith(`${t}.backup.`)).sort().reverse(),i=r[0],o=i?Number(i.split(`.backup.`).pop()):0,s=Number.isNaN(o)||Date.now()-o>=6e4;if(s){let r=A(n,`${t}.backup.${Date.now()}`);a.copyFileSync(e,r)}let c=s?a.readdirStringSync(n).filter(e=>e.startsWith(`${t}.backup.`)).sort().reverse():r;for(let e of c.slice(5))try{a.unlinkSync(A(n,e))}catch{}}catch(e){b(e)!==`ENOENT`&&S(`Failed to backup config: ${e}`,{level:`error`})}return Oe(e,y(d,null,2),{encoding:`utf-8`,mode:384}),e===w()&&X++,!0}finally{o&&o()}}function Qt(){if(Q)return;let e=Date.now();Ve(`info`,`enable_configs_started`),Q=!0,H(w(),L,!0),Ve(`info`,`enable_configs_completed`,{duration_ms:Date.now()-e})}function V(){return A(c(),`backups`)}function $t(e){let t=C(),n=O(e),r=V();try{let e=t.readdirStringSync(r).filter(e=>e.startsWith(`${n}.backup.`)).sort().at(-1);if(e)return A(r,e)}catch{}let i=k(e);try{let r=t.readdirStringSync(i).filter(e=>e.startsWith(`${n}.backup.`)).sort().at(-1);if(r)return A(i,r);let a=`${e}.backup`;try{return t.statSync(a),a}catch{}}catch{}return null}function H(e,t,n){if(!Q)throw Error(`Config accessed before allowed.`);let r=C();try{let n=r.readFileSync(e,{encoding:`utf-8`});try{let e=be(Xe(n));return{...t(),...e}}catch(n){throw new x(n instanceof Error?n.message:String(n),e,t())}}catch(i){if(b(i)===`ENOENT`){let n=$t(e);return n&&process.stderr.write(`\nWork Mate configuration file not found at: ${e}\nA backup file exists at: ${n}\nYou can manually restore it by running: cp "${n}" "${e}"\n\n`),t()}if(i instanceof x&&n)throw i;if(i instanceof x){if(S(`Config file corrupted, resetting to defaults: ${i.message}`,{level:`error`}),!U){U=!0;try{Ke(i);let t=!1;try{r.statSync(`${e}.backup`),t=!0}catch{}D(`tengu_config_parse_error`,{has_backup:t})}finally{U=!1}}process.stderr.write(`\nWork Mate configuration file at ${e} is corrupted: ${i.message}\n`);let t=O(e),n=V();try{r.mkdirSync(n)}catch(e){if(b(e)!==`EEXIST`)throw e}let a=r.readdirStringSync(n).filter(e=>e.startsWith(`${t}.corrupted.`)),o,s=!1,c=r.readFileSync(e,{encoding:`utf-8`});for(let e of a)try{if(c===r.readFileSync(A(n,e),{encoding:`utf-8`})){s=!0;break}}catch{}if(!s){o=A(n,`${t}.corrupted.${Date.now()}`);try{r.copyFileSync(e,o),S(`Corrupted config backed up to: ${o}`,{level:`error`})}catch{}}let l=$t(e);o?process.stderr.write(`The corrupted file has been backed up to: ${o}\n`):s&&process.stderr.write(`The corrupted file has already been backed up.
|
|
1
|
+
import{i as e,n as t,t as n}from"./rolldown-runtime-DaDcL9Zw.js";import{n as r,t as i}from"./isObject-C6qM3WEW.js";import{n as a,t as o}from"./memoize-BK3gG5ob.js";import{c as s,i as c,l,o as u}from"./envUtils-DcaKZlRU.js";import{t as d}from"./graceful-fs-DDVg0cja.js";import{Ar as f,Ci as p,Cr as m,Dr as h,Er as g,Fr as _,Or as v,Pr as ee,Si as te,Sr as ne,Wt as re,et as ie,fi as ae,gt as oe,hi as se,it as ce,jr as le,kr as ue,mi as de,oi as fe,pi as pe,si as me,vi as he,yi as ge}from"./state-B3zvBu4R.js";import{n as _e,t as ve}from"./cwd-Dj2ynhWd.js";import{C as y,F as b,O as x,R as ye,S as be,c as S,f as xe,i as Se,nt as Ce,tt as we,u as C,x as Te}from"./debug-D7OBvqC2.js";import{Cr as Ee,Dr as De,Fn as Oe,Jt as w,Or as ke,Qt as Ae,Xt as je,Yt as Me,_r as Ne,c as T,cr as Pe,g as Fe,lr as E,n as Ie,vr as Le,wn as Re,wr as ze}from"./settings-DUyIag_5.js";import{O as Be,k as Ve,m as He,n as Ue}from"./git-CNhyfMtb.js";import{d as We,o as Ge,s as Ke,u as qe}from"./log-CR0v5KUR.js";import{m as Je}from"./sessionStoragePortable-x0Yn02-G.js";import{f as Ye,p as Xe,s as Ze,u as Qe}from"./types-DDku8UKF.js";import{n as $e,r as D}from"./analytics-DJobLaWP.js";import{homedir as et}from"os";import{basename as O,dirname as k,isAbsolute as tt,join as A,normalize as j,resolve as nt,sep as rt}from"path";import{unwatchFile as it,watchFile as at}from"fs";import{randomBytes as ot}from"crypto";var M,st=t((()=>{p(),Le(),pe(),de(),M=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)te(t,ae(e)),e=Ne(e);return t}:se}));function ct(e){return he(e,ze,M)}var lt=t((()=>{ge(),st(),Ee()}));function ut(){let e=process.env.CLAUDE_CODE_DISABLE_AUTO_MEMORY;if(l(e))return!1;if(s(e))return!0;if(l(process.env.CLAUDE_CODE_SIMPLE)||l(process.env.CLAUDE_CODE_REMOTE)&&!process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR)return!1;let t=Ie();return t.autoMemoryEnabled===void 0||t.autoMemoryEnabled}function dt(){return!1}function ft(){return process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR?process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR:c()}function pt(e,t){if(!e)return;let n=e;if(t&&(n.startsWith(`~/`)||n.startsWith(`~\\`))){let e=n.slice(2),t=j(e||`.`);if(t===`.`||t===`..`)return;n=A(et(),e)}let r=j(n).replace(/[/\\]+$/,``);if(!(!tt(r)||r.length<3||/^[A-Za-z]:$/.test(r)||r.startsWith(`\\\\`)||r.startsWith(`//`)||r.includes(`\0`)))return(r+rt).normalize(`NFC`)}function mt(){return pt(process.env.CLAUDE_COWORK_MEMORY_PATH_OVERRIDE,!1)}function ht(){return pt(T(`policySettings`)?.autoMemoryDirectory??T(`flagSettings`)?.autoMemoryDirectory??T(`localSettings`)?.autoMemoryDirectory??T(`userSettings`)?.autoMemoryDirectory,!0)}function gt(){return mt()!==void 0}function _t(){return Ue(ce())??ce()}function vt(){return A(N(),xt)}function yt(e){return j(e).startsWith(N())}var bt,xt,N,St=t((()=>{o(),re(),u(),He(),Pe(),Fe(),bt=`memory`,xt=`MEMORY.md`,N=a(()=>(mt()??ht())||(A(A(ft(),`projects`),Je(_t()),bt)+rt).normalize(`NFC`),()=>ce())}));function Ct(e,t,n,i){if(!r(e))return e;t=f(t,e);for(var a=-1,o=t.length,s=o-1,c=e;c!=null&&++a<o;){var l=ue(t[a]),u=n;if(l===`__proto__`||l===`constructor`||l===`prototype`)return e;if(a!=s){var d=c[l];u=i?i(d,l,c):void 0,u===void 0&&(u=r(d)?d:me(t[a+1])?[]:{})}De(c,l,u),c=c[l]}return e}var wt=t((()=>{ke(),le(),fe(),i(),v()}));function Tt(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=g(e,o);n(s,o)&&Ct(a,f(o,e),s)}return a}var Et=t((()=>{h(),wt(),le()}));function P(e,t){if(e==null)return{};var n=ee(ct(e),function(e){return[e]});return t=ne(t),Tt(e,n,function(e,n){return t(e,n[0])})}var Dt=t((()=>{_(),m(),Et(),lt()})),Ot=n(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),kt=n((e=>{var t=Ot();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&n.forever,unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),At=n(((e,t)=>{t.exports=kt()})),jt=n(((e,t)=>{t.exports=[`SIGABRT`,`SIGALRM`,`SIGHUP`,`SIGINT`,`SIGTERM`],process.platform!==`win32`&&t.exports.push(`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&t.exports.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`,`SIGUNUSED`)})),Mt=n(((t,n)=>{var r=global.process,i=function(e){return e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`};if(!i(r))n.exports=function(){return function(){}};else{var a=e(`assert`),o=jt(),s=/^win/i.test(r.platform),c=e(`events`);typeof c!=`function`&&(c=c.EventEmitter);var l;r.__signal_exit_emitter__?l=r.__signal_exit_emitter__:(l=r.__signal_exit_emitter__=new c,l.count=0,l.emitted={}),l.infinite||(l.setMaxListeners(1/0),l.infinite=!0),n.exports=function(e,t){if(!i(global.process))return function(){};a.equal(typeof e,`function`,`a callback must be provided for exit handler`),p===!1&&m();var n=`exit`;return t&&t.alwaysLast&&(n=`afterexit`),l.on(n,e),function(){l.removeListener(n,e),l.listeners(`exit`).length===0&&l.listeners(`afterexit`).length===0&&u()}};var u=function(){!p||!i(global.process)||(p=!1,o.forEach(function(e){try{r.removeListener(e,f[e])}catch{}}),r.emit=_,r.reallyExit=h,--l.count)};n.exports.unload=u;var d=function(e,t,n){l.emitted[e]||(l.emitted[e]=!0,l.emit(e,t,n))},f={};o.forEach(function(e){f[e]=function(){i(global.process)&&r.listeners(e).length===l.count&&(u(),d(`exit`,null,e),d(`afterexit`,null,e),s&&e===`SIGHUP`&&(e=`SIGINT`),r.kill(r.pid,e))}}),n.exports.signals=function(){return o};var p=!1,m=function(){p||!i(global.process)||(p=!0,l.count+=1,o=o.filter(function(e){try{return r.on(e,f[e]),!0}catch{return!1}}),r.emit=v,r.reallyExit=g)};n.exports.load=m;var h=r.reallyExit,g=function(e){i(global.process)&&(r.exitCode=e||0,d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),h.call(r,r.exitCode))},_=r.emit,v=function(e,t){if(e===`exit`&&i(global.process)){t!==void 0&&(r.exitCode=t);var n=_.apply(this,arguments);return d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),n}else return _.apply(this,arguments)}}})),Nt=n(((e,t)=>{var n=Symbol();function r(e,t,r){let i=t[n];if(i)return t.stat(e,(e,t)=>{if(e)return r(e);r(null,t.mtime,i)});let a=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,a,a,i=>{if(i)return r(i);t.stat(e,(e,i)=>{if(e)return r(e);let a=i.mtime.getTime()%1e3==0?`s`:`ms`;Object.defineProperty(t,n,{value:a}),r(null,i.mtime,a)})})}function i(e){let t=Date.now();return e===`s`&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}t.exports.probe=r,t.exports.getMtime=i})),Pt=n(((t,n)=>{var r=e(`path`),i=d(),a=At(),o=Mt(),s=Nt(),c={};function l(e,t){return t.lockfilePath||`${e}.lock`}function u(e,t,n){if(!t.realpath)return n(null,r.resolve(e));t.fs.realpath(e,n)}function f(e,t,n){let r=l(e,t);t.fs.mkdir(r,i=>{if(!i)return s.probe(r,t.fs,(e,i,a)=>{if(e)return t.fs.rmdir(r,()=>{}),n(e);n(null,i,a)});if(i.code!==`EEXIST`)return n(i);if(t.stale<=0)return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));t.fs.stat(r,(r,i)=>{if(r)return r.code===`ENOENT`?f(e,{...t,stale:0},n):n(r);if(!p(i,t))return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));m(e,t,r=>{if(r)return n(r);f(e,{...t,stale:0},n)})})})}function p(e,t){return e.mtime.getTime()<Date.now()-t.stale}function m(e,t,n){t.fs.rmdir(l(e,t),e=>{if(e&&e.code!==`ENOENT`)return n(e);n()})}function h(e,t){let n=c[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,t.fs.stat(n.lockfilePath,(r,i)=>{let a=n.lastUpdate+t.stale<Date.now();if(r)return r.code===`ENOENT`||a?g(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,h(e,t));if(n.mtime.getTime()!==i.mtime.getTime())return g(e,n,Object.assign(Error(`Unable to update lock within the stale threshold`),{code:`ECOMPROMISED`}));let o=s.getMtime(n.mtimePrecision);t.fs.utimes(n.lockfilePath,o,o,r=>{let i=n.lastUpdate+t.stale<Date.now();if(!n.released){if(r)return r.code===`ENOENT`||i?g(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,h(e,t));n.mtime=o,n.lastUpdate=Date.now(),n.updateDelay=null,h(e,t)}})})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function g(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),c[e]===t&&delete c[e],t.options.onCompromised(n)}function _(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:i,onCompromised:e=>{throw e},...t},t.retries=t.retries||0,t.retries=typeof t.retries==`number`?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),u(e,t,(e,r)=>{if(e)return n(e);let i=a.operation(t.retries);i.attempt(()=>{f(r,t,(e,a,o)=>{if(i.retry(e))return;if(e)return n(i.mainError());let s=c[r]={lockfilePath:l(r,t),mtime:a,mtimePrecision:o,options:t,lastUpdate:Date.now()};h(r,t),n(null,e=>{if(s.released)return e&&e(Object.assign(Error(`Lock is already released`),{code:`ERELEASED`}));v(r,{...t,realpath:!1},e)})})})})}function v(e,t,n){t={fs:i,realpath:!0,...t},u(e,t,(e,r)=>{if(e)return n(e);let i=c[r];if(!i)return n(Object.assign(Error(`Lock is not acquired/owned by you`),{code:`ENOTACQUIRED`}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete c[r],m(r,t,n)})}function ee(e,t,n){t={stale:1e4,realpath:!0,fs:i,...t},t.stale=Math.max(t.stale||0,2e3),u(e,t,(e,r)=>{if(e)return n(e);t.fs.stat(l(r,t),(e,r)=>e?e.code===`ENOENT`?n(null,!1):n(e):n(null,!p(r,t)))})}function te(){return c}o(()=>{for(let e in c){let t=c[e].options;try{t.fs.rmdirSync(l(e,t))}catch{}}}),n.exports.lock=_,n.exports.unlock=v,n.exports.check=ee,n.exports.getLocks=te})),Ft=n(((e,t)=>{var n=d();function r(e){let t=[`mkdir`,`realpath`,`stat`,`rmdir`,`utimes`],n={...e};return t.forEach(t=>{n[t]=(...n)=>{let r=n.pop(),i;try{i=e[`${t}Sync`](...n)}catch(e){return r(e)}r(null,i)}}),n}function i(e){return(...t)=>new Promise((n,r)=>{t.push((e,t)=>{e?r(e):n(t)}),e(...t)})}function a(e){return(...t)=>{let n,r;if(t.push((e,t)=>{n=e,r=t}),e(...t),n)throw n;return r}}function o(e){if(e={...e},e.fs=r(e.fs||n),typeof e.retries==`number`&&e.retries>0||e.retries&&typeof e.retries.retries==`number`&&e.retries.retries>0)throw Object.assign(Error(`Cannot use retries with the sync api`),{code:`ESYNC`});return e}t.exports={toPromise:i,toSync:a,toSyncOptions:o}})),It=n(((e,t)=>{var n=Pt(),{toPromise:r,toSync:i,toSyncOptions:a}=Ft();async function o(e,t){return r(await r(n.lock)(e,t))}function s(e,t){return i(i(n.lock)(e,a(t)))}function c(e,t){return r(n.unlock)(e,t)}function l(e,t){return i(n.unlock)(e,a(t))}function u(e,t){return r(n.check)(e,t)}function d(e,t){return i(n.check)(e,a(t))}t.exports=o,t.exports.lock=o,t.exports.unlock=c,t.exports.lockSync=s,t.exports.unlockSync=l,t.exports.check=u,t.exports.checkSync=d}));function F(){return I||(I=It()),I}function Lt(e,t){return F().lock(e,t)}function Rt(e,t){return F().lockSync(e,t)}function zt(e,t){return F().check(e,t)}var I,Bt=t((()=>{}));function L(){return{numStartups:0,installMethod:void 0,autoUpdates:void 0,theme:`dark`,preferredNotifChannel:`auto`,verbose:!1,editorMode:`normal`,autoCompactEnabled:!0,showTurnDuration:!0,hasSeenTasksHint:!1,hasUsedStash:!1,hasUsedBackgroundTask:!1,queuedCommandUpHintCount:0,diffTool:`auto`,customApiKeyResponses:{approved:[],rejected:[]},env:{},tipsHistory:{},memoryUsageCount:0,promptQueueUseCount:0,btwUseCount:0,todoFeatureEnabled:!0,showExpandedTodos:!1,messageIdleNotifThresholdMs:6e4,autoConnectIde:!1,autoInstallIdeExtension:!0,fileCheckpointingEnabled:!0,terminalProgressBarEnabled:!0,cachedStatsigGates:{},cachedDynamicConfigs:{},respectGitignore:!0}}function Vt(){return fn||(fn=Ht())}function Ht(){if(oe())return!0;let e=B(),t=$();if(e.projects?.[t]?.hasTrustDialogAccepted)return!0;let n=E(ve());for(;;){if(e.projects?.[n]?.hasTrustDialogAccepted)return!0;let t=E(nt(n,`..`));if(t===n)break;n=t}return!1}function R(e){let t=K.config;if(!t)return!1;let n=t.oauthAccount!==void 0&&e.oauthAccount===void 0,r=t.hasCompletedOnboarding===!0&&e.hasCompletedOnboarding!==!0;return n||r}function Ut(e){let t=null;try{Zt(w(),L,n=>{let r=e(n);return r===n?n:(t={...r,projects:Kt(n.projects)},t)})&&t&&z(t)}catch(n){S(`Failed to save config with lock: ${n}`,{level:`error`});let r=H(w(),L);if(R(r)){S(`saveGlobalConfig fallback: re-read config is missing auth that cache has; refusing to write. See GH #3117.`,{level:`error`}),D(`tengu_config_auth_loss_prevented`,{});return}let i=e(r);if(i===r)return;t={...i,projects:Kt(r.projects)},Xt(w(),t,G),z(t)}}function Wt(){let e=J+Y;e>0&&D(`tengu_config_cache_stats`,{cache_hits:J,cache_misses:Y,hit_rate:J/e}),J=0,Y=0}function Gt(e){if(e.installMethod!==void 0)return e;let t=e,n=`unknown`,r=e.autoUpdates??!0;switch(t.autoUpdaterStatus){case`migrated`:n=`local`;break;case`installed`:n=`native`;break;case`disabled`:r=!1;break;case`enabled`:case`no_permissions`:case`not_configured`:n=`global`;break;case void 0:break}return{...e,installMethod:n,autoUpdates:r}}function Kt(e){if(!e)return e;let t={},n=!1;for(let[r,i]of Object.entries(e)){let e=i;if(e.history!==void 0){n=!0;let{history:i,...a}=e;t[r]=a}else t[r]=i}return n?t:e}function qt(){if(Z)return;Z=!0;let e=w();at(e,{interval:pn,persistent:!1},t=>{t.mtimeMs<=K.mtime||C().readFile(e,{encoding:`utf-8`}).then(e=>{if(t.mtimeMs<=K.mtime)return;let n=Qe(Xe(e));typeof n!=`object`||!n||(K={config:Gt({...L(),...n}),mtime:t.mtimeMs},q={mtime:t.mtimeMs,size:t.size})}).catch(()=>{})}),Ce(async()=>{it(e),Z=!1})}function z(e){K={config:e,mtime:Date.now()},q=null}function B(){if(K.config)return J++,K.config;Y++;try{let e=null;try{e=C().statSync(w())}catch{}let t=Gt(H(w(),L));return K={config:t,mtime:e?.mtimeMs??Date.now()},q=e?{mtime:e.mtimeMs,size:e.size}:null,qt(),t}catch{return Gt(H(w(),L))}}function Jt(){let e=B().remoteControlAtStartup;return e!==void 0&&e}function Yt(e){let t=B();return t.customApiKeyResponses?.approved?.includes(e)?`approved`:t.customApiKeyResponses?.rejected?.includes(e)?`rejected`:`new`}function Xt(e,t,n){let r=k(e);C().mkdirSync(r),Oe(e,y(P(t,(e,t)=>y(e)!==y(n[t])),null,2),{encoding:`utf-8`,mode:384}),e===w()&&X++}function Zt(e,t,n){let r=t(),i=k(e),a=C();a.mkdirSync(i);let o;try{let i=`${e}.lock`,s=Date.now();o=Rt(e,{lockfilePath:i,onCompromised:e=>{S(`Config lock compromised: ${e}`,{level:`error`})}});let c=Date.now()-s;if(c>100&&(S(`Lock acquisition took longer than expected - another Work Mate instance may be running`),D(`tengu_config_lock_contention`,{lock_time_ms:c})),q&&e===w())try{let t=a.statSync(e);(t.mtimeMs!==q.mtime||t.size!==q.size)&&D(`tengu_config_stale_write`,{read_mtime:q.mtime,write_mtime:t.mtimeMs,read_size:q.size,write_size:t.size})}catch(e){if(b(e)!==`ENOENT`)throw e}let l=H(e,t);if(e===w()&&R(l))return S(`saveConfigWithLock: re-read config is missing auth that cache has; refusing to write to avoid wiping ~/.workmate.json. See GH #3117.`,{level:`error`}),D(`tengu_config_auth_loss_prevented`,{}),!1;let u=n(l);if(u===l)return!1;let d=P(u,(e,t)=>y(e)!==y(r[t]));try{let t=O(e),n=V();try{a.mkdirSync(n)}catch(e){if(b(e)!==`EEXIST`)throw e}let r=a.readdirStringSync(n).filter(e=>e.startsWith(`${t}.backup.`)).sort().reverse(),i=r[0],o=i?Number(i.split(`.backup.`).pop()):0,s=Number.isNaN(o)||Date.now()-o>=6e4;if(s){let r=A(n,`${t}.backup.${Date.now()}`);a.copyFileSync(e,r)}let c=s?a.readdirStringSync(n).filter(e=>e.startsWith(`${t}.backup.`)).sort().reverse():r;for(let e of c.slice(5))try{a.unlinkSync(A(n,e))}catch{}}catch(e){b(e)!==`ENOENT`&&S(`Failed to backup config: ${e}`,{level:`error`})}return Oe(e,y(d,null,2),{encoding:`utf-8`,mode:384}),e===w()&&X++,!0}finally{o&&o()}}function Qt(){if(Q)return;let e=Date.now();Ve(`info`,`enable_configs_started`),Q=!0,H(w(),L,!0),Ve(`info`,`enable_configs_completed`,{duration_ms:Date.now()-e})}function V(){return A(c(),`backups`)}function $t(e){let t=C(),n=O(e),r=V();try{let e=t.readdirStringSync(r).filter(e=>e.startsWith(`${n}.backup.`)).sort().at(-1);if(e)return A(r,e)}catch{}let i=k(e);try{let r=t.readdirStringSync(i).filter(e=>e.startsWith(`${n}.backup.`)).sort().at(-1);if(r)return A(i,r);let a=`${e}.backup`;try{return t.statSync(a),a}catch{}}catch{}return null}function H(e,t,n){if(!Q)throw Error(`Config accessed before allowed.`);let r=C();try{let n=r.readFileSync(e,{encoding:`utf-8`});try{let e=be(Xe(n));return{...t(),...e}}catch(n){throw new x(n instanceof Error?n.message:String(n),e,t())}}catch(i){if(b(i)===`ENOENT`){let n=$t(e);return n&&process.stderr.write(`\nWork Mate configuration file not found at: ${e}\nA backup file exists at: ${n}\nYou can manually restore it by running: cp "${n}" "${e}"\n\n`),t()}if(i instanceof x&&n)throw i;if(i instanceof x){if(S(`Config file corrupted, resetting to defaults: ${i.message}`,{level:`error`}),!U){U=!0;try{Ke(i);let t=!1;try{r.statSync(`${e}.backup`),t=!0}catch{}D(`tengu_config_parse_error`,{has_backup:t})}finally{U=!1}}process.stderr.write(`\nWork Mate configuration file at ${e} is corrupted: ${i.message}\n`);let t=O(e),n=V();try{r.mkdirSync(n)}catch(e){if(b(e)!==`EEXIST`)throw e}let a=r.readdirStringSync(n).filter(e=>e.startsWith(`${t}.corrupted.`)),o,s=!1,c=r.readFileSync(e,{encoding:`utf-8`});for(let e of a)try{if(c===r.readFileSync(A(n,e),{encoding:`utf-8`})){s=!0;break}}catch{}if(!s){o=A(n,`${t}.corrupted.${Date.now()}`);try{r.copyFileSync(e,o),S(`Corrupted config backed up to: ${o}`,{level:`error`})}catch{}}let l=$t(e);o?process.stderr.write(`The corrupted file has been backed up to: ${o}\n`):s&&process.stderr.write(`The corrupted file has already been backed up.
|
|
2
2
|
`),l?process.stderr.write(`A backup file exists at: ${l}\nYou can manually restore it by running: cp "${l}" "${e}"\n\n`):process.stderr.write(`
|
|
3
3
|
`)}return t()}}function en(){let e=$(),t=B();if(!t.projects)return W;let n=t.projects[e]??W;return typeof n.allowedTools==`string`&&(n.allowedTools=Qe(n.allowedTools)??[]),n}function tn(e){let t=$(),n=null;try{Zt(w(),L,r=>{let i=r.projects?.[t]??W,a=e(i);return a===i?r:(n={...r,projects:{...r.projects,[t]:a}},n)})&&n&&z(n)}catch(r){S(`Failed to save config with lock: ${r}`,{level:`error`});let i=H(w(),L);if(R(i)){S(`saveCurrentProjectConfig fallback: re-read config is missing auth that cache has; refusing to write. See GH #3117.`,{level:`error`}),D(`tengu_config_auth_loss_prevented`,{});return}let a=i.projects?.[t]??W,o=e(a);if(o===a)return;n={...i,projects:{...i.projects,[t]:o}},Xt(w(),n,G),z(n)}}function nn(){return on()!==null}function rn(){return nn()&&!l(process.env.FORCE_AUTOUPDATE_PLUGINS)}function an(e){switch(e.type){case`development`:return`development build`;case`env`:return`${e.envVar} set`;case`config`:return`config`}}function on(){if(!l(process.env.ENABLE_AUTOUPDATER))return{type:`config`};if(l(process.env.DISABLE_AUTOUPDATER))return{type:`env`,envVar:`DISABLE_AUTOUPDATER`};let e=qe();if(e)return{type:`env`,envVar:e};let t=B();return t.autoUpdates===!1&&(t.installMethod!==`native`||t.autoUpdatesProtectedForNative!==!0)?{type:`config`}:null}function sn(){let e=B();if(e.userID)return e.userID;let t=ot(32).toString(`hex`);return Ut(e=>({...e,userID:t})),t}function cn(){if(!B().firstStartTime){let e=new Date().toISOString();Ut(t=>({...t,firstStartTime:t.firstStartTime??e}))}}function ln(e){let t=ie();switch(e){case`User`:return A(c(),`AGENTS.md`);case`Local`:return A(t,`AGENTS.local.md`);case`Project`:return A(t,`AGENTS.md`);case`Managed`:return A(je(),`AGENTS.md`);case`AutoMem`:return vt();default:return A(c(),`AGENTS.md`)}}function un(){return A(je(),`.workmate`,`rules`)}function dn(){return A(c(),`rules`)}var U,W,G,fn,K,q,J,Y,X,pn,Z,Q,$,mn=t((()=>{o(),Dt(),re(),St(),$e(),_e(),we(),Se(),Be(),Me(),u(),ye(),Re(),xe(),He(),Ze(),Ye(),Bt(),Ge(),Pe(),We(),Ae(),Te(),U=!1,W={allowedTools:[],mcpContextUris:[],mcpServers:{},enabledMcpjsonServers:[],disabledMcpjsonServers:[],hasTrustDialogAccepted:!1,projectOnboardingSeenCount:0,hasAgentsMdExternalIncludesApproved:!1,hasAgentsMdExternalIncludesWarningShown:!1},G=L(),fn=!1,{...G},{...W},K={config:null,mtime:0},q=null,J=0,Y=0,X=0,Ce(async()=>{Wt()}),pn=1e3,Z=!1,Q=!1,$=a(()=>{let e=ie();return E(Ue(e)||nt(e))})}));export{ft as A,Lt as C,wt as D,Ct as E,dt as F,ct as I,lt as L,St as M,yt as N,vt as O,ut as P,M as R,Bt as S,P as T,cn as _,on as a,rn as b,B as c,sn as d,$ as f,nn as g,mn as h,an as i,gt as j,N as k,un as l,dn as m,Vt as n,en as o,Jt as p,Qt as r,Yt as s,G as t,ln as u,tn as v,Dt as w,zt as x,Ut as y,st as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";import{n,t as r}from"./Settings-B9rxF2wR.js";var i,a;e((()=>{n(),i=t(),a=async(e,t)=>(0,i.jsx)(r,{onClose:e,context:t,defaultTab:`Config`})}))();export{a as call};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./figures-5ThXQEtq.js";import{$_ as r,La as i,U_ as a,V_ as o,ev as s,ka as c}from"./loadAgentsDir-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./figures-5ThXQEtq.js";import{$_ as r,La as i,U_ as a,V_ as o,ev as s,ka as c}from"./loadAgentsDir-DnsldjYU.js";import{I as l,P as u,s as d,t as f}from"./src-DL3w8VPk2.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{cn as m,ln as h,wn as g,xn as _}from"./settings-DUyIag_5.js";import{_ as v,v as y}from"./startupProfiler-BqUlQEaV.js";import{Et as b,Ot as x,Xt as S,an as C,in as w,nn as T}from"./prompt-CzQkcxfg.js";import{n as E,t as D}from"./staticRender-D9AbnQFr.js";function O(e){let t=[];return k(e,t),A(e,t),M(e,t),N(e,t),ee(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>=L&&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<P||r<F)continue;let a=j(n.name,r,i);a&&t.push(a)}}function j(e,t,n){let r=v(t);switch(e){case w: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 S: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 b: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===S);if(!n)return;let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100,a=n.resultTokens/e.rawMaxTokens*100;i>=P&&r>=F||a>=I&&n.resultTokens>=F&&t.push({severity:`info`,title:`File reads using ${v(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>=R&&n>=z){let i=[...e.memoryFiles].sort((e,t)=>t.tokens-e.tokens).slice(0,3).map(e=>`${_(e.path)} (${v(e.tokens)})`).join(`, `);t.push({severity:`info`,title:`Memory files using ${v(n)} tokens (${r.toFixed(0)}%)`,detail:`Largest: ${i}. Use /memory to review and prune stale entries.`,savingsTokens:Math.floor(n*.3)})}}function ee(e,t){!e.isAutoCompactEnabled&&e.percentage>=50&&e.percentage<L&&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 P,F,I,L,R,z,B=e((()=>{C(),T(),x(),g(),y(),P=15,F=1e4,I=5,L=80,R=5,z=5e3}));function V({suggestions:e}){return e.length===0?null:(0,H.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,H.jsx)(u,{bold:!0,children:`Suggestions`}),e.map((e,t)=>(0,H.jsxs)(l,{flexDirection:`column`,marginTop:t===0?0:1,children:[(0,H.jsxs)(l,{children:[(0,H.jsx)(d,{status:e.severity,withSpace:!0}),(0,H.jsx)(u,{bold:!0,children:e.title}),e.savingsTokens?(0,H.jsxs)(u,{dimColor:!0,children:[` `,n.arrowRight,` save ~`,v(e.savingsTokens)]}):null]}),(0,H.jsx)(l,{marginLeft:2,children:(0,H.jsx)(u,{dimColor:!0,children:e.detail})})]},t))]})}var H,U=e((()=>{t(),f(),y(),H=p()}));function W(){return null}function G(e){let t=new Map;for(let n of e){let e=m(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 Y){let r=t.get(e);r&&n.set(e,r)}return n}function K({data:e}){let{categories:t,totalTokens:n,rawMaxTokens:r,percentage:i,gridRows:a,model:o,memoryFiles:s,mcpTools:c,deferredBuiltinTools:d=[],agents:f,skills:p,cacheHitRate:m,cacheThreshold:h}=e,g=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==J&&!e.isDeferred),y=t.some(e=>e.isDeferred&&e.name.includes(`MCP`)),b=t.find(e=>e.name===J);return(0,q.jsxs)(l,{flexDirection:`column`,paddingLeft:1,children:[(0,q.jsx)(u,{bold:!0,children:`Context Usage`}),(0,q.jsxs)(l,{flexDirection:`row`,gap:2,children:[(0,q.jsx)(l,{flexDirection:`column`,flexShrink:0,children:a.map((e,t)=>(0,q.jsx)(l,{flexDirection:`row`,marginLeft:-1,children:e.map((e,t)=>e.categoryName===`Free space`?(0,q.jsx)(u,{dimColor:!0,children:`⛶ `},t):e.categoryName===J?(0,q.jsx)(u,{color:e.color,children:`⛝ `},t):(0,q.jsx)(u,{color:e.color,children:e.squareFullness>=.7?`⛁ `:`⛀ `},t))},t))}),(0,q.jsxs)(l,{flexDirection:`column`,gap:0,flexShrink:0,children:[(0,q.jsxs)(u,{dimColor:!0,children:[o,` · `,v(n),`/`,v(r),` tokens (`,i,`%)`]}),(0,q.jsx)(W,{}),m!==void 0&&h!==void 0&&(0,q.jsxs)(u,{color:m<h?`warning`:void 0,children:[`Cache hit rate: `,m.toFixed(0),`%`,m<h?` (below ${h}% threshold)`:``]}),(0,q.jsx)(u,{children:` `}),(0,q.jsx)(u,{dimColor:!0,italic:!0,children:`Estimated usage by category`}),g.map((e,t)=>{let n=v(e.tokens),i=e.isDeferred?`N/A`:`${(e.tokens/r*100).toFixed(1)}%`,a=e.name===J,o=e.name,s=e.isDeferred?` `:a?`⛝`:`⛁`;return(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{color:e.color,children:s}),(0,q.jsxs)(u,{children:[` `,o,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[n,` tokens (`,i,`)`]})]},t)}),(t.find(e=>e.name===`Free space`)?.tokens??0)>0&&(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{dimColor:!0,children:`⛶`}),(0,q.jsx)(u,{children:` Free space: `}),(0,q.jsxs)(u,{dimColor:!0,children:[v(t.find(e=>e.name===`Free space`)?.tokens||0),` (`,((t.find(e=>e.name===`Free space`)?.tokens||0)/r*100).toFixed(1),`%)`]})]}),b&&b.tokens>0&&(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{color:b.color,children:`⛝`}),(0,q.jsxs)(u,{dimColor:!0,children:[` `,b.name,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(b.tokens),` tokens (`,(b.tokens/r*100).toFixed(1),`%)`]})]})]})]}),(0,q.jsxs)(l,{flexDirection:`column`,marginLeft:-1,children:[c.length>0&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{bold:!0,children:`MCP tools`}),(0,q.jsxs)(u,{dimColor:!0,children:[` · /mcp`,y?` (loaded on-demand)`:``]})]}),c.some(e=>e.isLoaded)&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(u,{dimColor:!0,children:`Loaded`}),c.filter(e=>e.isLoaded).map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,e.name,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]}),y&&c.some(e=>!e.isLoaded)&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(u,{dimColor:!0,children:`Available`}),c.filter(e=>!e.isLoaded).map((e,t)=>(0,q.jsx)(l,{children:(0,q.jsxs)(u,{dimColor:!0,children:[`└ `,e.name]})},t))]}),!y&&c.map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,e.name,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]}),f.length>0&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{bold:!0,children:`Custom agents`}),(0,q.jsx)(u,{dimColor:!0,children:` · /agents`})]}),Array.from(G(f).entries()).map(([e,t])=>(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(u,{dimColor:!0,children:e}),t.map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,e.agentType,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]},e))]}),s.length>0&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{bold:!0,children:`Memory files`}),(0,q.jsx)(u,{dimColor:!0,children:` · /memory`})]}),s.map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,_(e.path),`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]}),p&&p.tokens>0&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{bold:!0,children:`Skills`}),(0,q.jsx)(u,{dimColor:!0,children:` · /skills`})]}),Array.from(G(p.skillFrontmatter).entries()).map(([e,t])=>(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(u,{dimColor:!0,children:e}),t.map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,e.name,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]},e))]})]}),(0,q.jsx)(V,{suggestions:O(e)})]})}var q,J,Y,X=e((()=>{f(),B(),g(),y(),h(),U(),q=p(),J=`Autocompact buffer`,Y=[`Project`,`User`,`Managed`,`Plugin`,`Built-in`]}));function Z(e){return c(e)}async function Q(e,t){let{messages:n,getAppState:r,options:{mainLoopModel:i,tools:a}}=t,c=Z(n),{messages:l}=await s(c),u=process.stdout.columns||80,d=r();return e(await E((0,$.jsx)(K,{data:await o(l,i,async()=>d.toolPermissionContext,a,d.agentDefinitions,u,t,void 0,c)}))),null}var $;e((()=>{X(),r(),a(),i(),D(),$=p()}))();export{Q as call};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t,t as n}from"./context-noninteractive-CxoMCfR4.js";t();export{n as call,e as collectContextData};
|
package/dist/chunks/{context-noninteractive-044464Vs.js → context-noninteractive-CxoMCfR4.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,La as n,U_ as r,V_ as i,ev as a,ka as o}from"./loadAgentsDir-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,La as n,U_ as r,V_ as i,ev as a,ka as o}from"./loadAgentsDir-DnsldjYU.js";import{cn as s,ln as c}from"./settings-DUyIag_5.js";import{_ as l,v as u}from"./startupProfiler-BqUlQEaV.js";async function d(e){let{messages:t,getAppState:n,options:{mainLoopModel:r,tools:s,agentDefinitions:c,customSystemPrompt:l,appendSystemPrompt:u}}=e,d=o(t),{messages:f}=await a(d),p=n();return i(f,r,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:c,agents:u,skills:d}=e,f=`## Context Usage
|
|
2
2
|
|
|
3
3
|
`;f+=`**Model:** ${a} \n`,f+=`**Tokens:** ${l(n)} / ${l(r)} (${i}%)\n`,f+=`
|
|
4
4
|
`;let p=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==`Autocompact buffer`);if(p.length>0){f+=`### Estimated usage by category
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./conversation-Bos7yTIv.js";e();export{t as clearConversation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,n as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Ch as n,Dn as r,FC as i,Fg as a,Kn as o,Lg as s,Ls as c,Mg as l,On as u,PC as d,Rs as f,St as p,Th as m,Tn as h,br as g,di as _,eE as v,h_ as y,hc as b,hn as x,jg as S,m_ as C,mi as w,qT as T,qt as E,sn as D,ti as O,tr as k,yt as A}from"./loadAgentsDir-
|
|
1
|
+
import{a as e,n as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Ch as n,Dn as r,FC as i,Fg as a,Kn as o,Lg as s,Ls as c,Mg as l,On as u,PC as d,Rs as f,St as p,Th as m,Tn as h,br as g,di as _,eE as v,h_ as y,hc as b,hn as x,jg as S,m_ as C,mi as w,qT as T,qt as E,sn as D,ti as O,tr as k,yt as A}from"./loadAgentsDir-DnsldjYU.js";import{Dn as j,G as M,Qt as N,Tn as P,Wt as F,en as I,et as L,wn as R}from"./state-B3zvBu4R.js";import{o as z,s as B}from"./log-CR0v5KUR.js";import{n as V,r as H}from"./analytics-DJobLaWP.js";import{at as U,ut as W}from"./sessionState-B3tFm9SC.js";import{n as G,t as K}from"./caches-dnO4Ae_m.js";import{randomUUID as q}from"crypto";function J(){return Y}var Y,X=t((()=>{b(),Y=null}));function Z(){let e=J();if(!e)return;e.markTranscriptReset?.();let t={type:`status`,subtype:`status`,status:`conversation_cleared`,message:`conversation_cleared`,uuid:q()};e.writeSdkMessages([t])}async function Q({setMessages:t,readFileState:s,discoveredSkillNames:c,loadedNestedMemoryPaths:u,getAppState:d,setAppState:p,setConversationId:m}){let v=D();await E(`clear`,{getAppState:d,setAppState:p,signal:AbortSignal.timeout(v),timeoutMs:v});let b=M();b&&H(`tengu_cache_eviction_hint`,{scope:`conversation_clear`,last_request_id:b});let x=new Set,S=[],C=e=>`isBackgrounded`in e&&e.isBackgrounded===!1;if(d)for(let e of Object.values(d().tasks))C(e)||f(e)&&(x.add(e.agentId),S.push(e));t(()=>[]),Z();let{setContextBlocked:F}=(U(),e(W));F(!1),m&&m(q()),K(x),R(null),P(null),j(null),I(),i(L()),s.clear(),c?.clear(),u?.clear(),p&&p(e=>{let t={};for(let[n,r]of Object.entries(e.tasks)){if(!C(r)){t[n]=r;continue}try{r.status===`running`&&(l(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){B(e)}h(n)}return{...e,tasks:t,attribution:n(),standaloneAgentContext:void 0,fileHistory:{snapshots:[],trackedFiles:new Set,snapshotSequence:0},mcp:{clients:[],tools:[],commands:[],resources:{},pluginReconnectKey:e.mcp.pluginReconnectKey}}}),T(),o(),N({setCurrentAsParent:!0}),await O();for(let e of S)e.status===`running`&&r(e.id,k(a(e.agentId)));let{saveMode:z}=(g(),e(w));z(`normal`);let V=A();V&&_(V);let G=await y(`clear`);G.length>0&&t(()=>G)}var $=t((()=>{X(),F(),V(),c(),S(),s(),m(),x(),z(),v(),d(),C(),g(),u(),p(),G()}));export{$ as n,Q as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,S as r,c as i,i as a,x as o}from"./debug-
|
|
1
|
+
import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,S as r,c as i,i as a,x as o}from"./debug-D7OBvqC2.js";import{l as s,u as c}from"./oauth-D38aRTUb.js";import{Pt as l,St as u}from"./model-xI2MbgRj.js";import{t as d}from"./cliLaunch-DDA65zeR.js";import{resolve as f}from"path";import{existsSync as p,unlinkSync as m}from"fs";import{randomUUID as h}from"crypto";a(),o(),e();function g(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var _=2e3,v=15e3,y=3,b=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??y}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(_*2**(this.reconnectAttempt-1),v);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){i(`[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=r(e)}catch{return}if(!g(t))return;let n=t;if(n.type===`control_request`){let e=n;e.request.subtype===`can_use_tool`?this.options.onPermissionRequest(e.request,e.request_id):(i(`[SSH] Unsupported control request subtype: ${e.request.subtype}`),this.sendErrorResponse(e.request_id,`Unsupported control request subtype: ${e.request.subtype}`));return}n.type!==`control_response`&&n.type!==`keep_alive`&&n.type!==`control_cancel_request`&&n.type!==`streamlined_text`&&n.type!==`streamlined_tool_use_summary`&&!(n.type===`system`&&n.subtype===`post_turn_summary`)&&this.options.onMessage(n)}writeToStdin(e){try{let t=this.proc.stdin;if(!t||typeof t==`number`||this.disconnected)return!1;let n=new TextEncoder().encode(`${e}\n`);return t.write(n),t.flush?.(),!0}catch{return!1}}async sendMessage(e){let t=n({type:`user`,message:{role:`user`,content:e},parent_tool_use_id:null,session_id:``});return this.writeToStdin(t)}sendInterrupt(){let e=n({type:`control_request`,request_id:crypto.randomUUID(),request:{subtype:`interrupt`}});this.writeToStdin(e)}respondToPermissionRequest(e,t){let r=n({type:`control_response`,response:{subtype:`success`,request_id:e,response:{behavior:t.behavior,...t.behavior===`allow`?{updatedInput:t.updatedInput}:{message:t.message}}}});this.writeToStdin(r)}sendErrorResponse(e,t){let r=n({type:`control_response`,response:{subtype:`error`,request_id:e,error:t}});this.writeToStdin(r)}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(),a();var x=process.platform===`win32`;function S(){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 C(){return process.env.ANTHROPIC_BASE_URL||s().BASE_API_URL}async function w(e,t){if(t&&e.headers.get(`x-auth-nonce`)!==t)return new Response(`Forbidden`,{status:403});let n=C(),r=new URL(e.url),a=`${n}${r.pathname}${r.search}`,o=S();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`),i(`[SSHAuthProxy] ${e.method} ${r.pathname} -> ${a}`);try{let t=await fetch(a,{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 i(`[SSHAuthProxy] upstream error: ${t}`),new Response(JSON.stringify({error:`Proxy upstream error: ${t}`}),{status:502,headers:{"content-type":`application/json`}})}}async function T(){let e=h();return x?D(e):E(e)}async function E(e){let t=`/tmp/claude-ssh-auth-${e}.sock`,n=Bun.serve({unix:t,fetch:e=>w(e,null)});return i(`[SSHAuthProxy] listening on unix:${t}`),{proxy:{stop(){n.stop(!0);try{m(t)}catch{}}},localAddress:t,authEnv:{ANTHROPIC_AUTH_SOCKET:t}}}async function D(e){let t=h(),n=Bun.serve({port:0,hostname:`127.0.0.1`,fetch:e=>w(e,t)}),r=n.port;return i(`[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}}}a();var O=15e3,k=class extends Error{constructor(e){super(e),this.name=`SSHProbeError`}};async function A(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 k(`SSH probe timed out after ${O/1e3}s`)),O))]),a=await new Response(n.stdout).text(),o=await new Response(n.stderr).text();if(r!==0)throw new k(`SSH probe failed: ${o.trim()||`exit code ${r}`}`);let s=a.split(`
|
|
3
3
|
`).map(e=>e.trim()).filter(Boolean);i(`[SSHProbe] raw lines: ${JSON.stringify(s)}`);let c=s.findIndex(e=>/^(Linux|Darwin)\s/.test(e));if(c===-1)throw new k(`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?.startsWith(`/`)??!1,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}}a();var j=6e4,M=`~/.local/bin`,N=`claude-code-cli.js`,P=`claude`;async function F(e,t,n=j){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 I(){let e=f(import.meta.dir,`../..`),t=f(e,`dist/cli.js`);if(p(t))return t;let n=f(e,`src/entrypoints/cli.tsx`);if(p(n))return n;throw Error("Cannot find local CLI binary to deploy. Run `bun run build` first.")}async function L(e){let{host:t,remotePlatform:n,remoteArch:r,localVersion:a,onProgress:o}=e;if(n!==`linux`&&n!==`darwin`)throw Error(`Remote platform "${n}" is not supported. Only linux and darwin are supported.`);i(`[SSHDeploy] deploying to ${t} (${n}/${r}, v${a})`);let s=I();i(`[SSHDeploy] local binary: ${s}`),o?.(`Creating remote directory...`);let c=await F(t,`mkdir -p ${M}`);if(c.exitCode!==0)throw Error(`Failed to create remote directory: ${c.stderr}`);o?.(`Uploading binary...`);let l=`${M}/${N}`,u=Bun.spawn([`scp`,`-o`,`ConnectTimeout=10`,s,`${t}:${l}`],{stdout:`pipe`,stderr:`pipe`}),d=setTimeout(()=>u.kill(),j),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 F(t,[`cat > ${M}/${P} << 'WRAPPER'`,`#!/bin/sh`,`exec bun ${M}/${N} "$@"`,`WRAPPER`,`chmod +x ${M}/${P}`].join(`
|
|
4
4
|
`));if(m.exitCode!==0)throw Error(`Failed to install wrapper script: ${m.stderr}`);o?.(`Verifying installation...`);let h=await F(t,`${M}/${P} --version`);if(h.exitCode!==0)throw Error(`Binary deployed but verification failed (exit ${h.exitCode}): ${h.stderr}`);return i(`[SSHDeploy] deployed successfully, remote version: ${h.stdout}`),o?.(`Deployed v${h.stdout}`),`${M}/${P}`}a(),o();var R=3e4,z=20,B=class extends Error{constructor(e){super(e),this.name=`SSHSessionError`}};async function V(e,t){let{host:n,localVersion:r,extraCliArgs:a,remoteBin:o}=e,s=t?.onProgress,c,l=`/`;if(o){s?.(`Using custom remote binary, skipping probe/deploy…`),c=o,i(`[SSH] custom remoteBin: ${o}`);try{let e=Bun.spawn([`ssh`,`-o`,`BatchMode=yes`,`-o`,`ConnectTimeout=5`,n,`pwd`],{stdin:`ignore`,stdout:`pipe`,stderr:`ignore`});await e.exited;let t=(await new Response(e.stdout).text()).trim();t.startsWith(`/`)&&(l=t)}catch{}}else{let e=await A(n,s);i(`[SSH] probe result: ${JSON.stringify(e)}`),l=e.defaultCwd,c=e.binaryPath??`~/.local/bin/claude`,(!e.hasBinary||e.remoteVersion!==r)&&(s?.(e.hasBinary?`Updating remote binary (${e.remoteVersion} → ${r})…`:`Deploying binary to remote…`),c=await L({host:n,remotePlatform:e.remotePlatform,remoteArch:e.remoteArch,localVersion:r,onProgress:s}))}let{proxy:u,localAddress:d,authEnv:f}=await T();i(`[SSH] auth proxy listening on ${d}`);let p=h().slice(0,8),m=process.platform===`win32`,g=[];for(let[e,t]of Object.entries(f))g.push(`${e}=${t}`);g.push(c,`--output-format`,`stream-json`,`--input-format`,`stream-json`,`--verbose`,`-p`),e.cwd&&g.push(`--cwd`,e.cwd),e.permissionMode&&g.push(`--permission-mode`,e.permissionMode),e.dangerouslySkipPermissions&&g.push(`--dangerously-skip-permissions`),g.push(...a);let _=[`ssh`];if(m){let e=d.split(`:`)[1],t=1e4+Math.floor(Math.random()*5e4);_.push(`-R`,`${t}:127.0.0.1:${e}`);let n=g.findIndex(e=>e.startsWith(`ANTHROPIC_BASE_URL=`));n!==-1&&(g[n]=`ANTHROPIC_BASE_URL=http://127.0.0.1:${t}`)}else{let e=`/tmp/claude-ssh-auth-${p}.sock`;_.push(`-R`,`${e}:${d}`),_.push(`-o`,`StreamLocalBindUnlink=yes`);let t=g.indexOf(`ANTHROPIC_AUTH_SOCKET=${f.ANTHROPIC_AUTH_SOCKET}`);t!==-1&&(g[t]=`ANTHROPIC_AUTH_SOCKET=${e}`)}_.push(n,g.join(` `)),s?.(`Starting remote session…`),i(`[SSH] spawning: ${_.join(` `)}`);let v;try{v=Bun.spawn(_,{stdin:`pipe`,stdout:`pipe`,stderr:`pipe`})}catch(e){throw u.stop(),new B(`Failed to spawn SSH process: ${e instanceof Error?e.message:String(e)}`)}let y=[];W(v,y);let x;if(o){let t=await Promise.race([v.exited.then(e=>e),new Promise(e=>setTimeout(()=>e(null),3e3))]);if(t!==null){u.stop();let e=y.join(``).trim();throw new B(`Remote process exited immediately (code ${t})${e?`: ${e}`:``}`)}x=e.cwd||l||`/`}else try{x=await U(v,e.cwd||l)}catch(e){throw u.stop(),v.kill(),e}i(`[SSH] remote session initialized, remoteCwd=${x}`);let S=v,C=async()=>{i(`[SSH] reconnect: re-spawning SSH process with --continue`);let e=[..._],t=e.length-1,n=e[t];n.includes(`--continue`)||(e[t]=n.replace(/ -p(?:\s|$)/,` -p --continue `));let r=Bun.spawn(e,{stdin:`pipe`,stdout:`pipe`,stderr:`pipe`}),a=[];return W(r,a),await U(r,x),S=r,y.length=0,y.push(...a),r};return{remoteCwd:x,get proc(){return S},proxy:u,createManager(e){return new b(S,{...e,reconnect:C})},getStderrTail(){return y.slice(-20).join(``)}}}async function H(e){let{proxy:t,authEnv:n}=await T(),r=[`--output-format`,`stream-json`,`--input-format`,`stream-json`,`-p`];e.cwd&&r.push(`--cwd`,e.cwd),e.permissionMode&&r.push(`--permission-mode`,e.permissionMode),e.dangerouslySkipPermissions&&r.push(`--dangerously-skip-permissions`);let a=d(r),o;try{o=Bun.spawn([a.execPath,...a.args],{stdin:`pipe`,stdout:`pipe`,stderr:`pipe`,env:{...a.env,...n}})}catch(e){throw t.stop(),new B(`Failed to spawn local CLI process: ${e instanceof Error?e.message:String(e)}`)}i(`[SSH] local session spawned, waiting for init message...`);let s=[];W(o,s);let c;try{c=await U(o,e.cwd)}catch(e){throw t.stop(),o.kill(),e}i(`[SSH] local session initialized, remoteCwd=${c}`);let l=o,u=async()=>{i(`[SSH] local reconnect: re-spawning CLI with --continue`);let e=[...r];e.includes(`--continue`)||e.push(`--continue`);let t=d(e),a=Bun.spawn([t.execPath,...t.args],{stdin:`pipe`,stdout:`pipe`,stderr:`pipe`,env:{...t.env,...n}}),o=[];return W(a,o),await U(a,c),l=a,s.length=0,s.push(...o),a};return{remoteCwd:c,get proc(){return l},proxy:t,createManager(e){return new b(l,{...e,reconnect:u})},getStderrTail(){return s.slice(-20).join(``)}}}async function U(e,t){let n=e.stdout;if(!n)throw new B(`Child process stdout is not readable`);let i=n.getReader(),a=new TextDecoder,o=``,s=Date.now()+R;try{for(;Date.now()<s;){let e=s-Date.now(),n=await Promise.race([i.read(),new Promise((t,n)=>setTimeout(()=>n(new B(`Remote CLI did not initialize within 30 seconds. Check SSH connectivity and remote binary.`)),e))]);if(n.done)throw new B(`Child process exited before sending init message`);o+=a.decode(n.value,{stream:!0});let c=o.split(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,n,r}from"./createSession-C0e_DHsW.js";t();export{n as createBridgeSession,r as getBridgeSession,e as updateBridgeSessionTitle};
|