@readmagic/workmate 0.0.20 → 0.0.22
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-DWgTWJ7R.js +1 -0
- package/dist/chunks/AgentsMdExternalIncludesDialog-DCvgQ6n3.js +1 -0
- package/dist/chunks/AgentsMdExternalIncludesDialog-s0Orgord.js +1 -0
- package/dist/chunks/App-BcEI6U5j.js +1 -0
- package/dist/chunks/ApproveApiKey-DegdTXZl.js +1 -0
- package/dist/chunks/ApproveApiKey-_VXIMSwY.js +1 -0
- package/dist/chunks/BackgroundTasksDialog-CjBt1L0p.js +2 -0
- package/dist/chunks/BypassPermissionsModeDialog-D2Gesf-u.js +1 -0
- package/dist/chunks/CustomSelect-B46Eh0gU.js +1 -0
- package/dist/chunks/DiffDialog-v2IiYyi3.js +6 -0
- package/dist/chunks/Doctor-BP0Rqraa.js +1 -0
- package/dist/chunks/Doctor-By_y3C2V.js +3 -0
- package/dist/chunks/ExitFlow-BasHk1mk.js +2 -0
- package/dist/chunks/Grove-C3mhgshv.js +11 -0
- package/dist/chunks/InvalidConfigDialog-DYVQK5js.js +1 -0
- package/dist/chunks/InvalidSettingsDialog-Dg6OiStR.js +1 -0
- package/dist/chunks/KeybindingProviderSetup-Bn1jzN5F.js +1 -0
- package/dist/chunks/MCPConnectionManager-ChN4Ayjk.js +1 -0
- package/dist/chunks/MCPToolListView-DLSrQHDc.js +1 -0
- package/dist/chunks/McpParsingWarnings-DZejAh8b.js +1 -0
- package/dist/chunks/MessageSelector-CdDlJE48.js +3 -0
- package/dist/chunks/Messages-DuL_r1Or.js +10 -0
- package/dist/chunks/Onboarding-CE2GNA-h.js +1 -0
- package/dist/chunks/PermissionDialog-BaibiQae.js +1 -0
- package/dist/chunks/PressEnterToContinue-DZc_s_pE.js +1 -0
- package/dist/chunks/PromptInputFooterSuggestions-lkr_A5jQ.js +1 -0
- package/dist/chunks/PromptInputHelpMenu-DaQKKyM5.js +1 -0
- package/dist/chunks/QueryEngine-DNNy1UCD.js +1 -0
- package/dist/chunks/REPL-CEhW-C41.js +1 -0
- package/dist/chunks/REPL-CkSL4C_8.js +124 -0
- package/dist/chunks/ResumeConversation-BMCO_3X7.js +1 -0
- package/dist/chunks/{SearchBox-CwwV0W-w.js → SearchBox-C9xxQzh1.js} +1 -1
- package/dist/chunks/SearchExtraToolsTool-DSy_jDhf.js +1 -0
- package/dist/chunks/SelectMulti-CNE06VAN.js +1 -0
- package/dist/chunks/Settings-mDykHLok.js +2 -0
- package/dist/chunks/Spinner-DwsJJUtn.js +1 -0
- package/dist/chunks/SpinnerGlyph-A6G-gloN.js +1 -0
- package/dist/chunks/TextInput-7uqPhq9T.js +22 -0
- package/dist/chunks/ThemePicker-DT9zVy-0.js +1 -0
- package/dist/chunks/TrustDialog-G4jM9IfM.js +1 -0
- package/dist/chunks/{ValidationErrorsList-BfZ5gcIv.js → ValidationErrorsList-BLtP647v.js} +1 -1
- package/dist/chunks/add-dir-7RfQAC3h.js +1 -0
- package/dist/chunks/{agentDisplay-BM4QG_RX.js → agentDisplay-vLQHFrmq.js} +1 -1
- package/dist/chunks/agents-BNg_skSm.js +101 -0
- package/dist/chunks/{agents-BbDBN5l9.js → agents-DLz0kfsr.js} +1 -1
- package/dist/chunks/allErrors-DaztSMrw.js +1 -0
- package/dist/chunks/appleTerminalBackup-BYKdf3of.js +1 -0
- package/dist/chunks/auth-BTB00dq5.js +10 -0
- package/dist/chunks/auth-Bbc0Ny8i.js +1 -0
- package/dist/chunks/backgroundHousekeeping-DYz83_8C.js +1 -0
- package/dist/chunks/backgroundHousekeeping-bEZtlJSf.js +17 -0
- package/dist/chunks/banner-mqZEluky.js +2 -0
- package/dist/chunks/branch-exFKkymg.js +2 -0
- package/dist/chunks/{break-cache-CcwOjTKt.js → break-cache-BL2gnDLX.js} +2 -2
- package/dist/chunks/btw-3l78DYET.js +1 -0
- package/dist/chunks/caches-6Nx6tsk9.js +1 -0
- package/dist/chunks/caches-ouaWB9bY.js +1 -0
- package/dist/chunks/claudeDesktop-D3PEgx3U.js +1 -0
- package/dist/chunks/{clear-DmqQBNKg.js → clear-CXfhVRp8.js} +1 -1
- package/dist/chunks/client-C01Bnxxv.js +1 -0
- package/dist/chunks/client-DYRgRQsr.js +1 -0
- package/dist/chunks/{client-C_jBL1yC.js → client-DdenNfkQ.js} +1 -1
- package/dist/chunks/client-DvhWKIOx.js +1 -0
- package/dist/chunks/commands-BoxOw75F.js +1 -0
- package/dist/chunks/compact-BOYr105K.js +2 -0
- package/dist/chunks/config-BddEvZZl.js +3 -0
- package/dist/chunks/config-GEv9hUzz.js +1 -0
- package/dist/chunks/config-kw4xg7Nk.js +1 -0
- package/dist/chunks/context-3s9wtn4L.js +1 -0
- package/dist/chunks/{context-noninteractive-BzDVMnWC.js → context-noninteractive-CJhUu_4y.js} +9 -9
- package/dist/chunks/context-noninteractive-DFvoZ2L9.js +1 -0
- package/dist/chunks/conversation-CoGharlH.js +1 -0
- package/dist/chunks/conversation-MxEVm54C.js +1 -0
- package/dist/chunks/conversationRecovery-Da_8uldZ.js +1 -0
- package/dist/chunks/convert-legacy-node-http-options-BZnGSjx2.js +1 -0
- package/dist/chunks/crossProjectResume-CzPCHq_K.js +40 -0
- package/dist/chunks/cwd-BcO6WHKo.js +1 -0
- package/dist/chunks/cwd-CDUelriw.js +1 -0
- package/dist/chunks/{datadog-Bc6wkPne.js → datadog-v_mXWncN.js} +1 -1
- package/dist/chunks/{debug-D58GQBDG.js → debug-8DCufdSp.js} +4 -4
- package/dist/chunks/detectRepository-DfX8xXw2.js +1 -0
- package/dist/chunks/{diff-DIg66U_d.js → diff-DJSt7QO6.js} +1 -1
- package/dist/chunks/directoryCompletion-CT6YVeg7.js +1 -0
- package/dist/chunks/doctor-DWvioSU9.js +1 -0
- package/dist/chunks/entry-ex0-RyYV.js +13 -0
- package/dist/chunks/esm-0CwQE5CJ.js +10 -0
- package/dist/chunks/esm-BCmY8V0C.js +1 -0
- package/dist/chunks/esm-BQY8jJNR.js +1 -0
- package/dist/chunks/esm-BUJtY-Rb.js +1 -0
- package/dist/chunks/esm-BadZVa27.js +1 -0
- package/dist/chunks/esm-BbMeEYcz.js +1 -0
- package/dist/chunks/esm-sVMjGuep.js +1 -0
- package/dist/chunks/execFileNoThrow-BsfuytkN.js +34 -0
- package/dist/chunks/exit-BxC_ZEtO.js +1 -0
- package/dist/chunks/extraUsage-DYm33Occ.js +1 -0
- package/dist/chunks/extractMemories-CzN3Ax2B.js +1 -0
- package/dist/chunks/fast-DqUpl_Lr.js +1 -0
- package/dist/chunks/fast-NUdUyAaM.js +1 -0
- package/dist/chunks/fetchModelList-CqsTAWEN.js +1 -0
- package/dist/chunks/fetchModelList-DBMHE6Ng.js +1 -0
- package/dist/chunks/fileSuggestions-B-SLfb-o.js +3 -0
- package/dist/chunks/firstPartyEventLogger-C0q45h_4.js +3 -0
- package/dist/chunks/firstPartyEventLogger-CP8hCBDj.js +1 -0
- package/dist/chunks/fpsMetrics-wxj9GAsd.js +1 -0
- package/dist/chunks/gemini-BC9kHhwe.js +2 -0
- package/dist/chunks/generateSessionName-ChvKBVxB.js +1 -0
- package/dist/chunks/{genericProcessUtils-6E7fB1dI.js → genericProcessUtils-BYi0OefF.js} +3 -3
- package/dist/chunks/goal-ByyimpVU.js +3 -0
- package/dist/chunks/grok-DenjixMl.js +1 -0
- package/dist/chunks/grove-Dq8QbQ9o.js +7 -0
- package/dist/chunks/help-CK90i4hE.js +1 -0
- package/dist/chunks/history-CNQNd6hT.js +1 -0
- package/dist/chunks/{hooks-7iyENdDG.js → hooks-BRFDg9DV.js} +2 -2
- package/dist/chunks/hooks-BaYwmkxD.js +1 -0
- package/dist/chunks/install-ZMll-dAa.js +1 -0
- package/dist/chunks/instrumentation-BwVyvRfY.js +21 -0
- package/dist/chunks/{job-CXz7SLZp.js → job-G_ukhLc4.js} +1 -1
- package/dist/chunks/keybindings-wNxBzDVQ.js +1 -0
- package/dist/chunks/launchLocalMemory-BcRlXLm6.js +3 -0
- package/dist/chunks/launchOnboarding-CDjQ64RO.js +8 -0
- package/dist/chunks/{loadAgentsDir-DaNpxaO-.js → loadAgentsDir-C1LkW7gl.js} +571 -641
- package/dist/chunks/loadAgentsDir-DKXap_Om.js +1 -0
- package/dist/chunks/loadPluginHooks-DtmHtEiS.js +1 -0
- package/dist/chunks/{loader-C33o_5kS.js → loader-C61fB6vU.js} +1 -1
- package/dist/chunks/localSearch-BB9x5C2N.js +1 -0
- package/dist/chunks/{localSearch-C2SZ9bGW.js → localSearch-DFo_WTMm.js} +1 -1
- package/dist/chunks/log-DaILwWJa.js +1 -0
- package/dist/chunks/logoUtils-Dj_2SWmO.js +1 -0
- package/dist/chunks/{magicDocs-CrTwULyJ.js → magicDocs-DYc9TFmI.js} +2 -2
- package/dist/chunks/main-BRg8L_aw.js +346 -0
- package/dist/chunks/managedEnv-DsqAYOJ4.js +1 -0
- package/dist/chunks/managedEnv-lybrMred.js +1 -0
- package/dist/chunks/mcp-Bsw3cMiJ.js +6 -0
- package/dist/chunks/mcp-DDdud6Y7.js +1 -0
- package/dist/chunks/mcp-DbgTDUt7.js +2 -0
- package/dist/chunks/memory-CzwTzihf.js +1 -0
- package/dist/chunks/modalContext-DDZdU1J8.js +1 -0
- package/dist/chunks/mode-Pan-Q2c4.js +2 -0
- package/dist/chunks/model-BYfmXKHf.js +1 -0
- package/dist/chunks/model-BwBE0Pt5.js +1 -0
- package/dist/chunks/modelOptions-DvNBapgG.js +1 -0
- package/dist/chunks/nativeInstaller-DnSNJWIi.js +1 -0
- package/dist/chunks/notifications-B0DTaYoy.js +1 -0
- package/dist/chunks/omit-Dl1Us_PY.js +1 -0
- package/dist/chunks/onChangeAppState-4KOJMN82.js +1 -0
- package/dist/chunks/openai-C_6C1_0N.js +10 -0
- package/dist/chunks/overlayContext-CMV7nYR9.js +1 -0
- package/dist/chunks/panel-D9fGQgln.js +1 -0
- package/dist/chunks/parser-BKAVMTyD.js +1 -0
- package/dist/chunks/{parser-eVu-cTRs.js → parser-D8slvrJP.js} +1 -1
- package/dist/chunks/partition-B504IgAa.js +1 -0
- package/dist/chunks/pasteStore-DNV1M5Xd.js +1 -0
- package/dist/chunks/permissions-CLFMhdRk.js +3 -0
- package/dist/chunks/pidLock-D9do1Afy.js +3 -0
- package/dist/chunks/plan-CQLnPLuE.js +1 -0
- package/dist/chunks/{platform-DMQxcm4K.js → platform-Dzff1WWw.js} +1 -1
- package/dist/chunks/plugin-BYdF7uob.js +17 -0
- package/dist/chunks/pluginAutoupdate-BJaAqwTH.js +1 -0
- package/dist/chunks/pluginBlocklist-DKKmOnWM.js +1 -0
- package/dist/chunks/pluginCliCommands-z8TtJMKH.js +1 -0
- package/dist/chunks/{pluginFlagging-DRA0m76J.js → pluginFlagging-DQP8tBi2.js} +1 -1
- package/dist/chunks/pluginOperations-BcfJCDco.js +2 -0
- package/dist/chunks/{pluginStartupCheck-BF1N4Lih.js → pluginStartupCheck-CfRvCrFg.js} +1 -1
- package/dist/chunks/pluginStartupCheck-Cq4PvULa.js +1 -0
- package/dist/chunks/plugins-CTM8jpOw.js +4 -0
- package/dist/chunks/policyLimits-a7ix6GnU.js +1 -0
- package/dist/chunks/poorMode-C11JEH3d.js +1 -0
- package/dist/chunks/{poorMode-CKQfWf3S.js → poorMode-J5SYJvoY.js} +1 -1
- package/dist/chunks/print-u6MzL5Cr.js +13 -0
- package/dist/chunks/processBashCommand-DIwrI2QC.js +1 -0
- package/dist/chunks/processSlashCommand-B-Gujpxm.js +5 -0
- package/dist/chunks/projectOnboardingState-CJycxw5P.js +1 -0
- package/dist/chunks/{prompt-8u06WVES.js → prompt-BGqgPgCU.js} +3 -3
- package/dist/chunks/prompt-BPJDGlx5.js +1 -0
- package/dist/chunks/prompt-DEdZzkEz.js +1 -0
- package/dist/chunks/promptEditor-CmQ9p4oe.js +4 -0
- package/dist/chunks/{protocolHandler-DzHVaPl3.js → protocolHandler-CJo9-PfZ.js} +2 -2
- package/dist/chunks/{proxy-BhIc7-mj.js → proxy-CB17QimU.js} +2 -2
- package/dist/chunks/reconciler-DSKLuOS7.js +1 -0
- package/dist/chunks/refresh-BbZFCNpn.js +1 -0
- package/dist/chunks/registerProtocol-CLIpzVwF.js +1 -0
- package/dist/chunks/reload-plugins-DjugL8jH.js +1 -0
- package/dist/chunks/rename-DOtCOtEr.js +1 -0
- package/dist/chunks/{renderOptions-D-aQZbzS.js → renderOptions-Zqfm2U1y.js} +1 -1
- package/dist/chunks/resume-BB4T4WIV.js +2 -0
- package/dist/chunks/ripgrep-BuzOTf1S.js +5 -0
- package/dist/chunks/ripgrep-CZ2CqaHb.js +1 -0
- package/dist/chunks/{runtimeObserver-DzesbvgI.js → runtimeObserver-CK_iZ6OB.js} +1 -1
- package/dist/chunks/{runtimeObserver-L6041elO.js → runtimeObserver-CpP0L9T9.js} +4 -4
- package/dist/chunks/sandbox-adapter-DhJJ6WOV.js +1 -0
- package/dist/chunks/sandbox-toggle-KOHYvbQT.js +1 -0
- package/dist/chunks/searchExtraTools-CdJghGkj.js +1 -0
- package/dist/chunks/select-C_KXmqbI.js +1 -0
- package/dist/chunks/sessionFileAccessHooks-D7KbWFp7.js +1 -0
- package/dist/chunks/sessionObserver-DB-sLv-X.js +1 -0
- package/dist/chunks/{sessionObserver-0D8xFoRK.js → sessionObserver-WOYv2n7C.js} +2 -2
- package/dist/chunks/sessionStorage-sgOAbDn7.js +1 -0
- package/dist/chunks/sessionTracing-yBre24PH.js +11 -0
- package/dist/chunks/settings-C-KNkvsM.js +1 -0
- package/dist/chunks/settings-DKN4xSpQ.js +24 -0
- package/dist/chunks/setup-CN_Pk7AR.js +3 -0
- package/dist/chunks/{shadowedRuleDetection-Cy9tsuKc.js → shadowedRuleDetection-Df-kZ_pK.js} +1 -1
- package/dist/chunks/{sideQuestion-Ds7Elgs4.js → sideQuestion-CMB8hfgX.js} +3 -3
- package/dist/chunks/sinks-BS17vtN0.js +1 -0
- package/dist/chunks/sinks-D1EjkHb4.js +1 -0
- package/dist/chunks/skillChangeDetector-CBKuGuEi.js +1 -0
- package/dist/chunks/{skillGapStore-BxCxKPev.js → skillGapStore-CfmlO6pb.js} +2 -2
- package/dist/chunks/{skillLifecycle-CfyNC3sW.js → skillLifecycle-BQ2LMfMx.js} +2 -2
- package/dist/chunks/{skillSearchPanel-CMNJFIEC.js → skillSearchPanel-BwYuwLFs.js} +4 -4
- package/dist/chunks/skills-BVHPQma0.js +1 -0
- package/dist/chunks/src-9vmGsuSI.js +1 -0
- package/dist/chunks/{src-CgZmCiiH.js → src-BacxF9BD.js} +2 -2
- package/dist/chunks/startupProfiler-B_U4QDtf.js +1 -0
- package/dist/chunks/startupProfiler-DTs9w9EN.js +3 -0
- package/dist/chunks/{state-D5D6QpTX.js → state-BowF111d.js} +1 -1
- package/dist/chunks/state-CGuyDES7.js +1 -0
- package/dist/chunks/staticRender-BVWx0IM1.js +1 -0
- package/dist/chunks/status-BurdTfyz.js +2 -0
- package/dist/chunks/status-DMq1An5h.js +1 -0
- package/dist/chunks/statusNoticeHelpers-X75JNlx5.js +1 -0
- package/dist/chunks/stringUtils-BQm3OfeJ.js +4 -0
- package/dist/chunks/{switcher-DQF5ZNal.js → switcher-Bq1Ct_Sn.js} +1 -1
- package/dist/chunks/switcher-DGD4ORVf.js +1 -0
- package/dist/chunks/{tasks-C8pb6ftc.js → tasks-0c8Uy04D.js} +1 -1
- package/dist/chunks/tempfile-CHO5wXsV.js +1 -0
- package/dist/chunks/{templateJobs-DJ4dcfcL.js → templateJobs-BdFzE9XG.js} +1 -1
- package/dist/chunks/terminalSetup-Cf_r6pwK.js +32 -0
- package/dist/chunks/{terminalSetup-7PdC4fV5.js → terminalSetup-D7J6bxcn.js} +1 -1
- package/dist/chunks/theme-Bby4fssR.js +1 -0
- package/dist/chunks/tipRegistry-CyRXWWTz.js +2 -0
- package/dist/chunks/{toolEventObserver-D2nk8ZbW.js → toolEventObserver-CzFZUIsM.js} +1 -1
- package/dist/chunks/toolPool-CnrZcprA.js +1 -0
- package/dist/chunks/types-zk5Ltv5q.js +81 -0
- package/dist/chunks/udsClient-ftP0yIpe.js +1 -0
- package/dist/chunks/use-select-navigation-DMaC_3iw.js +1 -0
- package/dist/chunks/useDoublePress-C9xxQzh1.js +1 -0
- package/dist/chunks/useExitOnCtrlCDWithKeybindings-CjW3gUOt.js +1 -0
- package/dist/chunks/useMainLoopModel-DWscpA9I.js +1 -0
- package/dist/chunks/useManagePlugins-CYXVcql2.js +1 -0
- package/dist/chunks/useMergedTools-DarmnCEw.js +1 -0
- package/dist/chunks/useSearchInput-C2JuUW3g.js +1 -0
- package/dist/chunks/useSettingsErrors-DutJBiKZ.js +1 -0
- package/dist/chunks/util-Bq5l7FF5.js +1 -0
- package/dist/chunks/validatePlugin-DIdEydz_.js +1 -0
- package/dist/chunks/{vim-BagKUX4j.js → vim-D8prM2IH.js} +1 -1
- package/dist/chunks/worktree-Caqt2WRZ.js +1 -0
- package/dist/cli.js +1 -1
- package/package.json +3 -21
- package/dist/chunks/AddWorkspaceDirectory-BYNvxNrD.js +0 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog-BSSz86ER.js +0 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog-CMEGV4Md.js +0 -1
- package/dist/chunks/App-W_9d1DjK.js +0 -1
- package/dist/chunks/ApproveApiKey-Bf1Rb8Ql.js +0 -1
- package/dist/chunks/ApproveApiKey-wpdvXpFr.js +0 -1
- package/dist/chunks/BackgroundTasksDialog-lGn1Wj1k.js +0 -2
- package/dist/chunks/BypassPermissionsModeDialog-CjVjyNf8.js +0 -1
- package/dist/chunks/DiffDialog-DCpchgp5.js +0 -6
- package/dist/chunks/Doctor-6SjW91rd.js +0 -1
- package/dist/chunks/Doctor-FPYTivHw.js +0 -3
- package/dist/chunks/ExitFlow-Dy8_1D8J.js +0 -2
- package/dist/chunks/Grove-Dd6rjs5P.js +0 -11
- package/dist/chunks/HybridTransport-CJVkWa2u.js +0 -2
- package/dist/chunks/InvalidConfigDialog-Bisj9ic_.js +0 -1
- package/dist/chunks/InvalidSettingsDialog-DyTPNRQR.js +0 -1
- package/dist/chunks/MCPConnectionManager-DfyoZaiu.js +0 -1
- package/dist/chunks/MCPToolListView-Dioupv8F.js +0 -1
- package/dist/chunks/McpParsingWarnings-BUlgpZAF.js +0 -1
- package/dist/chunks/MessageSelector-D8fylxPg.js +0 -3
- package/dist/chunks/Messages-BZDFMYBT.js +0 -10
- package/dist/chunks/Onboarding-BKLomZYo.js +0 -1
- package/dist/chunks/PermissionDialog-BPhvs5xH.js +0 -1
- package/dist/chunks/PressEnterToContinue-Dwoh6CaW.js +0 -1
- package/dist/chunks/PromptInputFooterSuggestions-DCum89fF.js +0 -1
- package/dist/chunks/PromptInputHelpMenu-DG2lRqis.js +0 -1
- package/dist/chunks/QueryEngine-CyGHpX7M.js +0 -1
- package/dist/chunks/REPL-BDsz8KIx.js +0 -1
- package/dist/chunks/REPL-CCBNfZfs.js +0 -128
- package/dist/chunks/RemoteSessionManager-BfsOv4K6.js +0 -2
- package/dist/chunks/ResumeConversation-pC8NLq0F.js +0 -1
- package/dist/chunks/SSETransport-B3K6eH9I.js +0 -2
- package/dist/chunks/SearchExtraToolsTool-DYoxHo9T.js +0 -1
- package/dist/chunks/Settings-CKaGmKg2.js +0 -2
- package/dist/chunks/TeleportProgress-CkgSp1cs.js +0 -1
- package/dist/chunks/TeleportRepoMismatchDialog-DdO_rECq.js +0 -1
- package/dist/chunks/TeleportResumeWrapper-BeG4N-2z.js +0 -1
- package/dist/chunks/ThemePicker-iD9ufy99.js +0 -1
- package/dist/chunks/TrustDialog-qO5OdQt8.js +0 -1
- package/dist/chunks/add-dir-C4eSVlZ6.js +0 -1
- package/dist/chunks/agents-D3APE_8d.js +0 -101
- package/dist/chunks/allErrors-BkgB7JNK.js +0 -1
- package/dist/chunks/api-BHBK9axp.js +0 -1
- package/dist/chunks/api-DyUWfg3a.js +0 -1
- package/dist/chunks/auth-0rn1U4Eq.js +0 -10
- package/dist/chunks/auth-BEoTPSgC.js +0 -1
- package/dist/chunks/auth-BPug7U_u.js +0 -1
- package/dist/chunks/backgroundHousekeeping-D7xAhUaE.js +0 -1
- package/dist/chunks/backgroundHousekeeping-km82qEh0.js +0 -17
- package/dist/chunks/banner-BkUdig-T.js +0 -2
- package/dist/chunks/bg-tGgpwpYx.js +0 -9
- package/dist/chunks/branch-CQ38cx5n.js +0 -2
- package/dist/chunks/bridgeConfig-C5L-7KaP.js +0 -1
- package/dist/chunks/bridgeConfig-CJMjDoaP.js +0 -1
- package/dist/chunks/bridgeMessaging-DVC3qj-C.js +0 -1
- package/dist/chunks/bridgePointer-DfTOjgtX.js +0 -1
- package/dist/chunks/bridgeStatusUtil-Cex6VowM.js +0 -1
- package/dist/chunks/btw-_P96ffHR.js +0 -1
- package/dist/chunks/bundledMode--fG1S62b.js +0 -1
- package/dist/chunks/caches-DH-q8Fjf.js +0 -1
- package/dist/chunks/caches-Dq0pJFDP.js +0 -1
- package/dist/chunks/capacityWake-BpP6c7x3.js +0 -3
- package/dist/chunks/ccrClient-DO563xlf.js +0 -1
- package/dist/chunks/claudeDesktop-DPc_SaVn.js +0 -1
- package/dist/chunks/cliLaunch-DDtwAolw.js +0 -1
- package/dist/chunks/client-9uHzAmFH.js +0 -1
- package/dist/chunks/client-BVal_QII.js +0 -1
- package/dist/chunks/client-C19cqYQS.js +0 -1
- package/dist/chunks/client-Dd7CKMRX.js +0 -1
- package/dist/chunks/commands-BkpqHY9F.js +0 -1
- package/dist/chunks/compact-DuVIvqMu.js +0 -2
- package/dist/chunks/config-DMP6-Ccr.js +0 -1
- package/dist/chunks/config-DRy1I12M.js +0 -3
- package/dist/chunks/config-e0Goy478.js +0 -1
- package/dist/chunks/context-DjgMzIfe.js +0 -1
- package/dist/chunks/context-noninteractive-DV7bIJCm.js +0 -1
- package/dist/chunks/controlMessageCompat-IFu4Gc1y.js +0 -1
- package/dist/chunks/conversation-BBOE_EoE.js +0 -1
- package/dist/chunks/conversation-WxH5pb2z.js +0 -1
- package/dist/chunks/createSSHSession-LVGVXHXL.js +0 -5
- package/dist/chunks/createSession-BUzna9-E.js +0 -1
- package/dist/chunks/createSession-Dgwxk1WA.js +0 -1
- package/dist/chunks/crossProjectResume-6B2NYy8a.js +0 -40
- package/dist/chunks/cwd-DLK3znO7.js +0 -1
- package/dist/chunks/cwd-Nh5IZNKO.js +0 -1
- package/dist/chunks/debugUtils-DXBRbwCE.js +0 -1
- package/dist/chunks/detached-Biz-xhu0.js +0 -4
- package/dist/chunks/detectRepository-CDOJ-M7h.js +0 -1
- package/dist/chunks/detectRepository-Cv9-k6dg.js +0 -1
- package/dist/chunks/directoryCompletion-BDGcGDuv.js +0 -1
- package/dist/chunks/doctor-BhUmhHQU.js +0 -1
- package/dist/chunks/entry-B-Y-AYeK.js +0 -13
- package/dist/chunks/esm-BYnFh4pG.js +0 -1
- package/dist/chunks/esm-Bx6rTxIs.js +0 -1
- package/dist/chunks/esm-C367Cyo-.js +0 -1
- package/dist/chunks/esm-CXM9jqO_.js +0 -1
- package/dist/chunks/esm-CXczu_-W.js +0 -1
- package/dist/chunks/esm-CXt5K8Xt.js +0 -1
- package/dist/chunks/esm-Cb-L4oAk.js +0 -1
- package/dist/chunks/esm-CvHtYRrr.js +0 -1
- package/dist/chunks/esm-DhRjocaU.js +0 -1
- package/dist/chunks/esm-DklLYEuz.js +0 -1
- package/dist/chunks/esm-IYgGg4wR.js +0 -1
- package/dist/chunks/esm-lyfry1WB.js +0 -10
- package/dist/chunks/execFileNoThrow-Bmb5HEFz.js +0 -34
- package/dist/chunks/execSyncWrapper-C3ZFV9od.js +0 -1
- package/dist/chunks/exit-CW2eqUrR.js +0 -1
- package/dist/chunks/extraUsage-CkTon7ib.js +0 -1
- package/dist/chunks/extractMemories-CfmbvayQ.js +0 -1
- package/dist/chunks/fast-ByahC7Gw.js +0 -1
- package/dist/chunks/fast-xtIP4u4y.js +0 -1
- package/dist/chunks/fetchModelList-D9aePIPW.js +0 -1
- package/dist/chunks/fetchModelList-Dy-x4h3G.js +0 -1
- package/dist/chunks/fileSuggestions-CFkJktgc.js +0 -3
- package/dist/chunks/firstPartyEventLogger-Bt9iG9xk.js +0 -1
- package/dist/chunks/firstPartyEventLogger-DqGSujCz.js +0 -3
- package/dist/chunks/flushGate-BjKW7PFC.js +0 -1
- package/dist/chunks/fpsMetrics-Dk_pnSHJ.js +0 -1
- package/dist/chunks/gemini-NnmxBoEp.js +0 -1
- package/dist/chunks/generateSessionName-EpqGW-T2.js +0 -1
- package/dist/chunks/git-By_J4XJL.js +0 -5
- package/dist/chunks/git-zJCasBa6.js +0 -1
- package/dist/chunks/githubRepoPathMapping-CzgPGOHQ.js +0 -1
- package/dist/chunks/goal-DbS8yJfB.js +0 -3
- package/dist/chunks/grok-BxZ4vTDw.js +0 -1
- package/dist/chunks/grove-CYE1Cfcz.js +0 -7
- package/dist/chunks/hash-Tu-My5Vp.js +0 -1
- package/dist/chunks/help-DatnwM25.js +0 -1
- package/dist/chunks/hooks-DjbqtbUV.js +0 -1
- package/dist/chunks/initReplBridge-BEZW5PEY.js +0 -1
- package/dist/chunks/install-DJukI-kL.js +0 -1
- package/dist/chunks/instrumentation-2HH15DPu.js +0 -21
- package/dist/chunks/jwtUtils-C_LG1txt.js +0 -1
- package/dist/chunks/keybindings-C9l5il16.js +0 -1
- package/dist/chunks/launchLocalMemory-BfGenqj1.js +0 -3
- package/dist/chunks/launchOnboarding-DjMmXeQE.js +0 -8
- package/dist/chunks/lazySchema-DULtBUCI.js +0 -65
- package/dist/chunks/lib-BlVGipXx.js +0 -14
- package/dist/chunks/loadAgentsDir-DcI-8FQF.js +0 -1
- package/dist/chunks/loadPluginHooks-CGgpcyEC.js +0 -1
- package/dist/chunks/localSearch-CTTwYTU1.js +0 -1
- package/dist/chunks/log-CZ7ploQm.js +0 -1
- package/dist/chunks/logoUtils-CbIqOFrX.js +0 -1
- package/dist/chunks/main-Blm02_Js.js +0 -31
- package/dist/chunks/main-bJXadFi0.js +0 -356
- package/dist/chunks/managedEnv-CUsdYhAI.js +0 -1
- package/dist/chunks/managedEnv-DXeaUDSK.js +0 -1
- package/dist/chunks/mappers-_B-s9fNz.js +0 -1
- package/dist/chunks/mcp-BbbYzWpy.js +0 -6
- package/dist/chunks/mcp-D91sH9a8.js +0 -1
- package/dist/chunks/mcp-Dx-zgUgu.js +0 -2
- package/dist/chunks/memoize-CumjjK2Q.js +0 -1
- package/dist/chunks/memory-BeL7ui9m.js +0 -1
- package/dist/chunks/modalContext-wY9CeN4G.js +0 -1
- package/dist/chunks/mode-D695kgLI.js +0 -2
- package/dist/chunks/model-DX0TtzqX.js +0 -1
- package/dist/chunks/model-Do0f476p.js +0 -1
- package/dist/chunks/model-DpcM8dz5.js +0 -1
- package/dist/chunks/modelOptions-B3nis9cC.js +0 -1
- package/dist/chunks/nativeInstaller-CymO8TNe.js +0 -1
- package/dist/chunks/oauth-D38aRTUb.js +0 -1
- package/dist/chunks/oauth-U649LV5H.js +0 -1
- package/dist/chunks/omit-DO61BHZu.js +0 -1
- package/dist/chunks/onChangeAppState-vKml_lit.js +0 -1
- package/dist/chunks/openai-DdupGVdC.js +0 -10
- package/dist/chunks/panel-CVd1dzYl.js +0 -1
- package/dist/chunks/parser-Cq9X7HMP.js +0 -1
- package/dist/chunks/partition-BivH9MBJ.js +0 -1
- package/dist/chunks/permissions-C9iqR4_N.js +0 -3
- package/dist/chunks/pidLock-DiKz5Tza.js +0 -3
- package/dist/chunks/plan-KDN5IGWY.js +0 -1
- package/dist/chunks/plugin-D0rzUb8E.js +0 -17
- package/dist/chunks/pluginAutoupdate-C2xTKLR_.js +0 -1
- package/dist/chunks/pluginBlocklist-xdiUmUpt.js +0 -1
- package/dist/chunks/pluginCliCommands-CIDDvVN7.js +0 -1
- package/dist/chunks/pluginOperations-BEYsarAn.js +0 -2
- package/dist/chunks/pluginStartupCheck-DVkI4pqo.js +0 -1
- package/dist/chunks/plugins-CWWU4BKs.js +0 -4
- package/dist/chunks/pollConfig-2nFzv6Hy.js +0 -1
- package/dist/chunks/poorMode-BTIe8W_H.js +0 -1
- package/dist/chunks/print-B5H2xbBS.js +0 -14
- package/dist/chunks/processBashCommand-EQ9EWaRV.js +0 -1
- package/dist/chunks/processSlashCommand-C4PKNyFT.js +0 -5
- package/dist/chunks/prompt-B9sDzLPK.js +0 -1
- package/dist/chunks/prompt-WsoTRhoh.js +0 -1
- package/dist/chunks/promptEditor-Cr4w-4Bz.js +0 -4
- package/dist/chunks/rcDebugLog-DSchf3Hs.js +0 -1
- package/dist/chunks/reconciler-RIKmaPg7.js +0 -1
- package/dist/chunks/refresh-CCSCAjgz.js +0 -1
- package/dist/chunks/registerProtocol-C0IlPEoa.js +0 -1
- package/dist/chunks/reload-plugins-DC-tbXVv.js +0 -1
- package/dist/chunks/remoteBridgeCore-NGTnhQgw.js +0 -1
- package/dist/chunks/remoteManagedSettings-BoOYHzYP.js +0 -1
- package/dist/chunks/rename-DS1AmW-F.js +0 -1
- package/dist/chunks/resume-Cf5PSoPw.js +0 -2
- package/dist/chunks/ripgrep-C3jtZL7k.js +0 -5
- package/dist/chunks/ripgrep-CBUbn6Po.js +0 -1
- package/dist/chunks/sandbox-adapter-Z4Phj31K.js +0 -1
- package/dist/chunks/sandbox-toggle-COZE8Lo4.js +0 -1
- package/dist/chunks/searchExtraTools-CvkRbL2m.js +0 -1
- package/dist/chunks/session-BvA99K4j.js +0 -2
- package/dist/chunks/sessionFileAccessHooks-6XfAf6ke.js +0 -1
- package/dist/chunks/sessionIdCompat-Dgp6PW_1.js +0 -1
- package/dist/chunks/sessionObserver-CRWUBJEY.js +0 -1
- package/dist/chunks/sessionState-CQhbGfmh.js +0 -11
- package/dist/chunks/sessionStorage-DqEuxDlb.js +0 -1
- package/dist/chunks/sessionStoragePortable-x0Yn02-G.js +0 -3
- package/dist/chunks/sessionTracing-BoOZsXU2.js +0 -11
- package/dist/chunks/settings-3xZ0fsvE.js +0 -19
- package/dist/chunks/settings-Crx1cI1u.js +0 -1
- package/dist/chunks/settingsSync-rkWmClKS.js +0 -1
- package/dist/chunks/setup-D8L275fT.js +0 -3
- package/dist/chunks/shellQuote-Ddgr1vif.js +0 -4
- package/dist/chunks/sinks-BXX72cbf.js +0 -1
- package/dist/chunks/sinks-DMp6uEzM.js +0 -1
- package/dist/chunks/skillChangeDetector-CtithJ4a.js +0 -1
- package/dist/chunks/skills-DXMk-498.js +0 -1
- package/dist/chunks/src-D3yIF9I42.js +0 -1
- package/dist/chunks/src-DQOX_xI1.js +0 -1
- package/dist/chunks/src-Dt5IJd3C.js +0 -1
- package/dist/chunks/src-Dvp6-vB7.js +0 -19
- package/dist/chunks/src-PM8NIIu_.js +0 -1
- package/dist/chunks/startupProfiler-CbzxVmbv.js +0 -3
- package/dist/chunks/startupProfiler-uHetQush.js +0 -1
- package/dist/chunks/state-BStOuCh4.js +0 -1
- package/dist/chunks/staticRender-D9AbnQFr.js +0 -1
- package/dist/chunks/stats-Ce15gc3E.js +0 -1
- package/dist/chunks/status-CFrLuGbf.js +0 -2
- package/dist/chunks/status-D5OCkMZG.js +0 -1
- package/dist/chunks/statusNoticeHelpers-CZoOse-_.js +0 -1
- package/dist/chunks/stringUtils-CKD8qDqx.js +0 -4
- package/dist/chunks/subprocessEnv-CNBOhlDV.js +0 -1
- package/dist/chunks/subprocessEnv-DtBCqQIo.js +0 -1
- package/dist/chunks/switcher-AiMcRzoi.js +0 -1
- package/dist/chunks/syncCache-qWJ_VfBo.js +0 -1
- package/dist/chunks/teleport-Bi_1VFIZ.js +0 -1
- package/dist/chunks/terminalSetup-kWdZRKWq.js +0 -32
- package/dist/chunks/theme-CEKOCSLw.js +0 -1
- package/dist/chunks/tmux-CpGd0Aca.js +0 -1
- package/dist/chunks/toolPool-Df5iUqJ-.js +0 -1
- package/dist/chunks/trustedDevice-CB6rNzl-.js +0 -1
- package/dist/chunks/trustedDevice-DXGePUAC.js +0 -1
- package/dist/chunks/types-APu4OCXJ.js +0 -17
- package/dist/chunks/udsClient-U7MEfYj7.js +0 -1
- package/dist/chunks/upstreamproxy-CTOuotLO.js +0 -10
- package/dist/chunks/useExitOnCtrlCDWithKeybindings-Bw0mlTT9.js +0 -1
- package/dist/chunks/useMainLoopModel-CIG2cjS2.js +0 -1
- package/dist/chunks/useManagePlugins-MSHw-qHx.js +0 -1
- package/dist/chunks/useMergedTools-Bb-INJa2.js +0 -1
- package/dist/chunks/useSearchInput-QL_VtdJD.js +0 -1
- package/dist/chunks/useSettingsErrors-Dvi6zLCr.js +0 -1
- package/dist/chunks/userAgent-i-oGzf40.js +0 -1
- package/dist/chunks/util-CLQvtXuD.js +0 -1
- package/dist/chunks/validatePlugin-1mTZ3TJR.js +0 -1
- package/dist/chunks/which-BxQ1hpjp.js +0 -1
- package/dist/chunks/windowsPaths-BdhjMYTm.js +0 -1
- package/dist/chunks/windowsPaths-DtGZ83kH.js +0 -1
- package/dist/chunks/workSecret-CaM2yIJD.js +0 -1
- package/dist/chunks/workerRegistry-BjxoZ12l.js +0 -2
- package/dist/chunks/worktree-DpksgxdF.js +0 -1
- /package/dist/chunks/{src-DL3w8VPk2.js → src-DL3w8VPk.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./memoize-BK3gG5ob.js";import{i,l as a,o}from"./envUtils-DcaKZlRU.js";import{n as s,t as c}from"./defineProperty-C-QyHrDq.js";import{Ut as l,ft as u}from"./state-D5D6QpTX.js";import{a as ee,n as d}from"./process-gEbdy6uY.js";import{homedir as f}from"os";import*as p from"path";import{dirname as te,join as ne,resolve as re}from"path";import*as m from"fs";import{closeSync as ie,fsyncSync as ae,openSync as oe,writeFileSync as se}from"fs";import{appendFile as ce,mkdir as le,open as ue,readFile as de,readdir as fe,rename as pe,rm as me,rmdir as he,stat as ge,symlink as _e,unlink as ve}from"fs/promises";function ye({writeFn:e,flushIntervalMs:t=1e3,maxBufferSize:n=100,maxBufferBytes:r=1/0,immediateMode:i=!1}){let a=[],o=0,s=null,c=null;function l(){s&&(clearTimeout(s),s=null)}function u(){c&&(e(c.join(``)),c=null),a.length!==0&&(e(a.join(``)),a=[],o=0,l())}function ee(){s||(s=setTimeout(u,t))}function d(){if(c){c.push(...a),a=[],o=0,l();return}let t=a;a=[],o=0,l(),c=t,setImmediate(()=>{let t=c;c=null,t&&e(t.join(``))})}return{write(t){if(i){e(t);return}a.push(t),o+=t.length,ee(),(a.length>=n||o>=r)&&d()},flush:u,dispose(){u()}}}var be=e((()=>{}));function xe(e){return Ce.add(e),()=>Ce.delete(e)}async function Se(){await Promise.all(Array.from(Ce).map(e=>e()))}var Ce,we=e((()=>{Ce=new Set}));function Te(e){let t=[],n=e.match(/^MCP server ["']([^"']+)["']/);if(n?.[1])t.push(`mcp`),t.push(n[1].toLowerCase());else{let n=e.match(/^([^:[]+):/);n?.[1]&&t.push(n[1].trim().toLowerCase())}let r=e.match(/^\[([^\]]+)]/);r?.[1]&&t.push(r[1].trim().toLowerCase()),e.toLowerCase().includes(`1p event:`)&&t.push(`1p`);let i=e.match(/:\s*([^:]+?)(?:\s+(?:type|mode|status|event))?:/);if(i?.[1]){let e=i[1].trim().toLowerCase();e.length<30&&!e.includes(` `)&&t.push(e)}return Array.from(new Set(t))}function Ee(e,t){return t?e.length===0?!1:t.isExclusive?!e.some(e=>t.exclude.includes(e)):e.some(e=>t.include.includes(e)):!0}function De(e,t){return!t||Ee(Te(e),t)}var Oe,ke=e((()=>{r(),Oe=n(e=>{if(!e||e.trim()===``)return null;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return null;let n=t.some(e=>e.startsWith(`!`)),r=t.some(e=>!e.startsWith(`!`));if(n&&r)return null;let i=t.map(e=>e.replace(/^!/,``).toLowerCase());return{include:n?[]:i,exclude:n?i:[],isExclusive:n}})}));function h(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function g(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var _=e((()=>{})),Ae,je=e((()=>{Ae=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return Ae=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))}}));function Me(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var Ne,Pe=e((()=>{Ne=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)}})),v,y,b,x,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,S=e((()=>{Pe(),v=class extends Error{},y=class e extends v{constructor(t,n,r,i,a){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`request-id`),this.error=n,this.type=a??null}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new x({message:r,cause:Ne(n)});let a=n,o=a?.error?.type;return t===400?new Ie(t,a,r,i,o):t===401?new Le(t,a,r,i,o):t===403?new Re(t,a,r,i,o):t===404?new ze(t,a,r,i,o):t===409?new Be(t,a,r,i,o):t===422?new Ve(t,a,r,i,o):t===429?new He(t,a,r,i,o):t>=500?new Ue(t,a,r,i,o):new e(t,a,r,i,o)}},b=class extends y{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},x=class extends y{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},Fe=class extends x{constructor({message:e}={}){super({message:e??`Request timed out.`})}},Ie=class extends y{},Le=class extends y{},Re=class extends y{},ze=class extends y{},Be=class extends y{},Ve=class extends y{},He=class extends y{},Ue=class extends y{}}));function We(e){return typeof e==`object`?e??{}:{}}function Ge(e){if(!e)return!0;for(let t in e)return!1;return!0}function Ke(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var qe,Je,Ye,Xe,Ze,Qe,$e=e((()=>{S(),qe=/^[a-z][a-z0-9+.-]*:/i,Je=e=>qe.test(e),Ye=e=>(Ye=Array.isArray,Ye(e)),Xe=Ye,Ze=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new v(`${e} must be an integer`);if(t<0)throw new v(`${e} must be a positive integer`);return t},Qe=e=>{try{return JSON.parse(e)}catch{return}}})),et,tt=e((()=>{et=e=>new Promise(t=>setTimeout(t,e))})),C,nt=e((()=>{C=`0.81.0`}));function rt(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}function it(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var at,ot,st,ct,lt,ut,dt=e((()=>{nt(),at=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`,ot=()=>{let e=rt();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":ct(Deno.build.os),"X-Stainless-Arch":st(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":ct(globalThis.process.platform??`unknown`),"X-Stainless-Arch":st(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=it();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}},st=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,ct=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),ut=()=>lt??(lt=ot())}));function ft(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function pt(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function mt(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return pt({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function ht(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function gt(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var _t=e((()=>{})),vt,yt=e((()=>{vt=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)})}));function bt(e){return Object.entries(e).filter(([e,t])=>t!==void 0).map(([e,t])=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new v(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join(`&`)}var xt=e((()=>{S()}));function St(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function Ct(e){let t;return(Tt??(t=new globalThis.TextEncoder,Tt=t.encode.bind(t)))(e)}function wt(e){let t;return(Et??(t=new globalThis.TextDecoder,Et=t.decode.bind(t)))(e)}var Tt,Et,Dt=e((()=>{}));function Ot(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function kt(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}var w,T,At,jt=e((()=>{_(),Dt(),At=class{constructor(){w.set(this,void 0),T.set(this,void 0),h(this,w,new Uint8Array,`f`),h(this,T,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Ct(e):e;h(this,w,St([g(this,w,`f`),t]),`f`);let n=[],r;for(;(r=Ot(g(this,w,`f`),g(this,T,`f`)))!=null;){if(r.carriage&&g(this,T,`f`)==null){h(this,T,r.index,`f`);continue}if(g(this,T,`f`)!=null&&(r.index!==g(this,T,`f`)+1||r.carriage)){n.push(wt(g(this,w,`f`).subarray(0,g(this,T,`f`)-1))),h(this,w,g(this,w,`f`).subarray(g(this,T,`f`)),`f`),h(this,T,null,`f`);continue}let e=g(this,T,`f`)===null?r.preceding:r.preceding-1,t=wt(g(this,w,`f`).subarray(0,e));n.push(t),h(this,w,g(this,w,`f`).subarray(r.index),`f`),h(this,T,null,`f`)}return n}flush(){return g(this,w,`f`).length?this.decode(`
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./memoize-BK3gG5ob.js";import{i,l as a,o}from"./envUtils-DcaKZlRU.js";import{n as s,t as c}from"./defineProperty-C-QyHrDq.js";import{ut as l,zt as u}from"./state-BowF111d.js";import{a as ee,n as d}from"./process-gEbdy6uY.js";import{homedir as f}from"os";import*as p from"path";import{dirname as te,join as ne,resolve as re}from"path";import*as m from"fs";import{closeSync as ie,fsyncSync as ae,openSync as oe,writeFileSync as se}from"fs";import{appendFile as ce,mkdir as le,open as ue,readFile as de,readdir as fe,rename as pe,rm as me,rmdir as he,stat as ge,symlink as _e,unlink as ve}from"fs/promises";function ye({writeFn:e,flushIntervalMs:t=1e3,maxBufferSize:n=100,maxBufferBytes:r=1/0,immediateMode:i=!1}){let a=[],o=0,s=null,c=null;function l(){s&&(clearTimeout(s),s=null)}function u(){c&&(e(c.join(``)),c=null),a.length!==0&&(e(a.join(``)),a=[],o=0,l())}function ee(){s||(s=setTimeout(u,t))}function d(){if(c){c.push(...a),a=[],o=0,l();return}let t=a;a=[],o=0,l(),c=t,setImmediate(()=>{let t=c;c=null,t&&e(t.join(``))})}return{write(t){if(i){e(t);return}a.push(t),o+=t.length,ee(),(a.length>=n||o>=r)&&d()},flush:u,dispose(){u()}}}var be=e((()=>{}));function xe(e){return Ce.add(e),()=>Ce.delete(e)}async function Se(){await Promise.all(Array.from(Ce).map(e=>e()))}var Ce,we=e((()=>{Ce=new Set}));function Te(e){let t=[],n=e.match(/^MCP server ["']([^"']+)["']/);if(n?.[1])t.push(`mcp`),t.push(n[1].toLowerCase());else{let n=e.match(/^([^:[]+):/);n?.[1]&&t.push(n[1].trim().toLowerCase())}let r=e.match(/^\[([^\]]+)]/);r?.[1]&&t.push(r[1].trim().toLowerCase()),e.toLowerCase().includes(`1p event:`)&&t.push(`1p`);let i=e.match(/:\s*([^:]+?)(?:\s+(?:type|mode|status|event))?:/);if(i?.[1]){let e=i[1].trim().toLowerCase();e.length<30&&!e.includes(` `)&&t.push(e)}return Array.from(new Set(t))}function Ee(e,t){return t?e.length===0?!1:t.isExclusive?!e.some(e=>t.exclude.includes(e)):e.some(e=>t.include.includes(e)):!0}function De(e,t){return!t||Ee(Te(e),t)}var Oe,ke=e((()=>{r(),Oe=n(e=>{if(!e||e.trim()===``)return null;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return null;let n=t.some(e=>e.startsWith(`!`)),r=t.some(e=>!e.startsWith(`!`));if(n&&r)return null;let i=t.map(e=>e.replace(/^!/,``).toLowerCase());return{include:n?[]:i,exclude:n?i:[],isExclusive:n}})}));function h(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function g(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var _=e((()=>{})),Ae,je=e((()=>{Ae=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return Ae=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))}}));function Me(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var Ne,Pe=e((()=>{Ne=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)}})),v,y,b,x,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,S=e((()=>{Pe(),v=class extends Error{},y=class e extends v{constructor(t,n,r,i,a){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`request-id`),this.error=n,this.type=a??null}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new x({message:r,cause:Ne(n)});let a=n,o=a?.error?.type;return t===400?new Ie(t,a,r,i,o):t===401?new Le(t,a,r,i,o):t===403?new Re(t,a,r,i,o):t===404?new ze(t,a,r,i,o):t===409?new Be(t,a,r,i,o):t===422?new Ve(t,a,r,i,o):t===429?new He(t,a,r,i,o):t>=500?new Ue(t,a,r,i,o):new e(t,a,r,i,o)}},b=class extends y{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},x=class extends y{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},Fe=class extends x{constructor({message:e}={}){super({message:e??`Request timed out.`})}},Ie=class extends y{},Le=class extends y{},Re=class extends y{},ze=class extends y{},Be=class extends y{},Ve=class extends y{},He=class extends y{},Ue=class extends y{}}));function We(e){return typeof e==`object`?e??{}:{}}function Ge(e){if(!e)return!0;for(let t in e)return!1;return!0}function Ke(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var qe,Je,Ye,Xe,Ze,Qe,$e=e((()=>{S(),qe=/^[a-z][a-z0-9+.-]*:/i,Je=e=>qe.test(e),Ye=e=>(Ye=Array.isArray,Ye(e)),Xe=Ye,Ze=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new v(`${e} must be an integer`);if(t<0)throw new v(`${e} must be a positive integer`);return t},Qe=e=>{try{return JSON.parse(e)}catch{return}}})),et,tt=e((()=>{et=e=>new Promise(t=>setTimeout(t,e))})),C,nt=e((()=>{C=`0.81.0`}));function rt(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}function it(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var at,ot,st,ct,lt,ut,dt=e((()=>{nt(),at=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`,ot=()=>{let e=rt();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":ct(Deno.build.os),"X-Stainless-Arch":st(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":ct(globalThis.process.platform??`unknown`),"X-Stainless-Arch":st(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=it();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}},st=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,ct=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),ut=()=>lt??(lt=ot())}));function ft(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function pt(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function mt(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return pt({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function ht(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function gt(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var _t=e((()=>{})),vt,yt=e((()=>{vt=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)})}));function bt(e){return Object.entries(e).filter(([e,t])=>t!==void 0).map(([e,t])=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new v(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join(`&`)}var xt=e((()=>{S()}));function St(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function Ct(e){let t;return(Tt??(t=new globalThis.TextEncoder,Tt=t.encode.bind(t)))(e)}function wt(e){let t;return(Et??(t=new globalThis.TextDecoder,Et=t.decode.bind(t)))(e)}var Tt,Et,Dt=e((()=>{}));function Ot(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function kt(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}var w,T,At,jt=e((()=>{_(),Dt(),At=class{constructor(){w.set(this,void 0),T.set(this,void 0),h(this,w,new Uint8Array,`f`),h(this,T,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Ct(e):e;h(this,w,St([g(this,w,`f`),t]),`f`);let n=[],r;for(;(r=Ot(g(this,w,`f`),g(this,T,`f`)))!=null;){if(r.carriage&&g(this,T,`f`)==null){h(this,T,r.index,`f`);continue}if(g(this,T,`f`)!=null&&(r.index!==g(this,T,`f`)+1||r.carriage)){n.push(wt(g(this,w,`f`).subarray(0,g(this,T,`f`)-1))),h(this,w,g(this,w,`f`).subarray(g(this,T,`f`)),`f`),h(this,T,null,`f`);continue}let e=g(this,T,`f`)===null?r.preceding:r.preceding-1,t=wt(g(this,w,`f`).subarray(0,e));n.push(t),h(this,w,g(this,w,`f`).subarray(r.index),`f`),h(this,T,null,`f`)}return n}flush(){return g(this,w,`f`).length?this.decode(`
|
|
2
2
|
`):[]}},w=new WeakMap,T=new WeakMap,At.NEWLINE_CHARS=new Set([`
|
|
3
3
|
`,`\r`]),At.NEWLINE_REGEXP=/\r\n|[\n\r]/g}));function Mt(){}function Nt(e,t,n){return!t||Pt[e]>Pt[n]?Mt:t[e].bind(t)}function E(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return It;let r=Lt.get(t);if(r&&r[0]===n)return r[1];let i={error:Nt(`error`,t,n),warn:Nt(`warn`,t,n),info:Nt(`info`,t,n),debug:Nt(`debug`,t,n)};return Lt.set(t,[n,i]),i}var Pt,Ft,It,Lt,D,Rt=e((()=>{$e(),Pt={off:0,error:200,warn:300,info:400,debug:500},Ft=(e,t,n)=>{if(e){if(Ke(Pt,e))return e;E(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Pt))}`)}},It={error:Mt,warn:Mt,info:Mt,debug:Mt},Lt=new WeakMap,D=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`x-api-key`||e.toLowerCase()===`authorization`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t]))),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e)}));async function*zt(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new v(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new v(`Attempted to iterate over a response with no body`);let n=new Wt,r=new At,i=ht(e.body);for await(let e of Bt(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*Bt(e){let t=new Uint8Array;for await(let n of e){if(n==null)continue;let e=n instanceof ArrayBuffer?new Uint8Array(n):typeof n==`string`?Ct(n):n,r=new Uint8Array(t.length+e.length);r.set(t),r.set(e,t.length),t=r;let i;for(;(i=kt(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}function Vt(e,t){let n=e.indexOf(t);return n===-1?[e,``,``]:[e.substring(0,n),t,e.substring(n+t.length)]}var Ht,Ut,Wt,Gt=e((()=>{_(),S(),_t(),jt(),Pe(),$e(),Dt(),Rt(),Ut=class e{constructor(e,t,n){this.iterator=e,Ht.set(this,void 0),this.controller=t,h(this,Ht,n,`f`)}static fromSSEResponse(t,n,r){let i=!1,a=r?E(r):console;async function*o(){if(i)throw new v("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let e of zt(t,n)){if(e.event===`completion`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event===`message_start`||e.event===`message_delta`||e.event===`message_stop`||e.event===`content_block_start`||e.event===`content_block_delta`||e.event===`content_block_stop`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event!==`ping`&&e.event===`error`){let n=Qe(e.data)??e.data,r=n?.error?.type;throw new y(void 0,n,void 0,t.headers,r)}}e=!0}catch(e){if(Me(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new At,n=ht(t);for await(let t of n)for(let n of e.decode(t))yield n;for(let t of e.flush())yield t}async function*o(){if(i)throw new v("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(Me(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(Ht=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,g(this,Ht,`f`)),new e(()=>i(n),this.controller,g(this,Ht,`f`))]}toReadableStream(){let e=this,t;return pt({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=Ct(JSON.stringify(n)+`
|
|
4
4
|
`);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.()}})}},Wt=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
|
|
@@ -34,6 +34,6 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
34
34
|
new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
35
35
|
`);this.baseURL=i.baseURL,this.timeout=i.timeout??zi.DEFAULT_TIMEOUT,this.logger=i.logger??console;let a=`warn`;this.logLevel=a,this.logLevel=Ft(i.logLevel,`ClientOptions.logLevel`,this)??Ft(Ii(`ANTHROPIC_LOG`),`process.env['ANTHROPIC_LOG']`,this)??a,this.fetchOptions=i.fetchOptions,this.maxRetries=i.maxRetries??2,this.fetch=i.fetch??ft(),h(this,Bi,vt,`f`),this._options=i,this.apiKey=typeof t==`string`?t:null,this.authToken=n}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.get(`x-api-key`)||e.get(`authorization`))&&!(this.apiKey&&e.get(`x-api-key`))&&!t.has(`x-api-key`)&&!(this.authToken&&e.get(`authorization`))&&!t.has(`authorization`))throw Error(`Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted`)}async authHeaders(e){return M([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(this.apiKey!=null)return M([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(this.authToken!=null)return M([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return bt(e)}getUserAgent(){return`${this.constructor.name}/JS ${C}`}defaultIdempotencyKey(){return`stainless-node-retry-${Ae()}`}makeStatusError(e,t,n,r){return y.generate(e,t,n,r)}buildURL(e,t,n){let r=!g(this,Ri,`m`,Vi).call(this)&&n||this.baseURL,i=Je(e)?new URL(e):new URL(r+(r.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),a=this.defaultQuery(),o=Object.fromEntries(i.searchParams);return(!Ge(a)||!Ge(o))&&(t={...o,...a,...t}),typeof t==`object`&&t&&!Array.isArray(t)&&(i.search=this.stringifyQuery(t)),i.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new v(`Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details`);return 600*1e3}async prepareOptions(e){}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest(`get`,e,t)}post(e,t){return this.methodRequest(`post`,e,t)}patch(e,t){return this.methodRequest(`patch`,e,t)}put(e,t){return this.methodRequest(`put`,e,t)}delete(e,t){return this.methodRequest(`delete`,e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new Xt(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){let r=await e,i=r.maxRetries??this.maxRetries;t??(t=i),await this.prepareOptions(r);let{req:a,url:o,timeout:s}=await this.buildRequest(r,{retryCount:i-t});await this.prepareRequest(a,{url:o,options:r});let c=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),l=n===void 0?``:`, retryOf: ${n}`,u=Date.now();if(E(this).debug(`[${c}] sending request`,D({retryOfRequestLogID:n,method:r.method,url:o,options:r,headers:a.headers})),r.signal?.aborted)throw new b;let ee=new AbortController,d=await this.fetchWithTimeout(o,a,s,ee).catch(Ne),f=Date.now();if(d instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted)throw new b;let i=Me(d)||/timed? ?out/i.test(String(d)+(`cause`in d?String(d.cause):``));if(t)return E(this).info(`[${c}] connection ${i?`timed out`:`failed`} - ${e}`),E(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (${e})`,D({retryOfRequestLogID:n,url:o,durationMs:f-u,message:d.message})),this.retryRequest(r,t,n??c);throw E(this).info(`[${c}] connection ${i?`timed out`:`failed`} - error; no more retries left`),E(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (error; no more retries left)`,D({retryOfRequestLogID:n,url:o,durationMs:f-u,message:d.message})),i?new Fe:new x({cause:d})}let p=`[${c}${l}${[...d.headers.entries()].filter(([e])=>e===`request-id`).map(([e,t])=>`, `+e+`: `+JSON.stringify(t)).join(``)}] ${a.method} ${o} ${d.ok?`succeeded`:`failed`} with status ${d.status} in ${f-u}ms`;if(!d.ok){let e=await this.shouldRetry(d);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await gt(d.body),E(this).info(`${p} - ${e}`),E(this).debug(`[${c}] response error (${e})`,D({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,durationMs:f-u})),this.retryRequest(r,t,n??c,d.headers)}let i=e?`error; no more retries left`:`error; not retryable`;E(this).info(`${p} - ${i}`);let a=await d.text().catch(e=>Ne(e).message),o=Qe(a),s=o?void 0:a;throw E(this).debug(`[${c}] response error (${i})`,D({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,message:s,durationMs:Date.now()-u})),this.makeStatusError(d.status,o,s,d.headers)}return E(this).info(p),E(this).debug(`[${c}] response start`,D({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,durationMs:f-u})),{response:d,options:r,controller:ee,requestLogID:c,retryOfRequestLogID:n,startTime:u}}getAPIList(e,t,n){return this.requestAPIList(t,n&&`then`in n?n.then(t=>({method:`get`,path:e,...t})):{method:`get`,path:e,...n})}requestAPIList(e,t){let n=this.makeRequest(t,null,void 0);return new en(this,n,e)}async fetchWithTimeout(e,t,n,r){let{signal:i,method:a,...o}=t||{},s=this._makeAbort(r);i&&i.addEventListener(`abort`,s,{once:!0});let c=setTimeout(s,n),l=globalThis.ReadableStream&&o.body instanceof globalThis.ReadableStream||typeof o.body==`object`&&o.body!==null&&Symbol.asyncIterator in o.body,u={signal:r.signal,...l?{duplex:`half`}:{},method:`GET`,...o};a&&(u.method=a.toUpperCase());try{return await this.fetch.call(void 0,e,u)}finally{clearTimeout(c)}}async shouldRetry(e){let t=e.headers.get(`x-should-retry`);return t===`true`?!0:t===`false`?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,n,r){let i,a=r?.get(`retry-after-ms`);if(a){let e=parseFloat(a);Number.isNaN(e)||(i=e)}let o=r?.get(`retry-after`);if(o&&!i){let e=parseFloat(o);i=Number.isNaN(e)?Date.parse(o)-Date.now():e*1e3}if(i===void 0){let n=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,n)}return await et(i),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){let n=t-e;return Math.min(.5*2**n,8)*(1-Math.random()*.25)*1e3}calculateNonstreamingTimeout(e,t){let n=600*1e3;if(36e5*e/128e3>n||t!=null&&e>t)throw new v(`Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details`);return n}async buildRequest(e,{retryCount:t=0}={}){let n={...e},{method:r,path:i,query:a,defaultBaseURL:o}=n,s=this.buildURL(i,a,o);`timeout`in n&&Ze(`timeout`,n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:c,body:l}=this.buildBody({options:n});return{req:{method:r,headers:await this.buildHeaders({options:e,method:r,bodyHeaders:c,retryCount:t}),...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:`half`},...l&&{body:l},...this.fetchOptions??{},...n.fetchOptions??{}},url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:r}){let i={};this.idempotencyHeader&&t!==`get`&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=e.idempotencyKey);let a=M([i,{Accept:`application/json`,"User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...ut(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":`true`}:void 0,"anthropic-version":`2023-06-01`},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(a),a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let n=M([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==`string`&&n.values.has(`content-type`)||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e==`object`&&(Symbol.asyncIterator in e||Symbol.iterator in e&&`next`in e&&typeof e.next==`function`)?{bodyHeaders:void 0,body:mt(e)}:typeof e==`object`&&n.values.get(`content-type`)===`application/x-www-form-urlencoded`?{bodyHeaders:{"content-type":`application/x-www-form-urlencoded`},body:this.stringifyQuery(e)}:g(this,Bi,`f`).call(this,{body:e,headers:n})}},zi=Z,Bi=new WeakMap,Ri=new WeakSet,Vi=function(){return this.baseURL!==`https://api.anthropic.com`},Z.Anthropic=zi,Z.HUMAN_PROMPT=Hi,Z.AI_PROMPT=Ui,Z.DEFAULT_TIMEOUT=6e5,Z.AnthropicError=v,Z.APIError=y,Z.APIConnectionError=x,Z.APIConnectionTimeoutError=Fe,Z.APIUserAbortError=b,Z.NotFoundError=ze,Z.ConflictError=Be,Z.RateLimitError=He,Z.BadRequestError=Ie,Z.AuthenticationError=Le,Z.InternalServerError=Ue,Z.PermissionDeniedError=Re,Z.UnprocessableEntityError=Ve,Z.toFile=mn,Wi=class extends Z{constructor(){super(...arguments),this.completions=new Xr(this),this.messages=new ki(this),this.models=new Ni(this),this.beta=new K(this)}},Wi.Completions=Xr,Wi.Messages=ki,Wi.Models=Ni,Wi.Beta=K})),Ki=e((()=>{Gi(),xn(),Zt(),O(),S()}));function qi(e){return e instanceof aa||e instanceof b||e instanceof Error&&e.name===`AbortError`}function Ji(e,t){return e instanceof Error&&e.message===t}function Yi(e){return e instanceof Error?e:Error(String(e))}function Xi(e){return e instanceof Error?e.message:String(e)}function Zi(e){if(e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`)return e.code}function Qi(e){return Zi(e)===`ENOENT`}function $i(e){if(e&&typeof e==`object`&&`path`in e&&typeof e.path==`string`)return e.path}function ea(e,t=5){if(!(e instanceof Error))return String(e);if(!e.stack)return e.message;let n=e.stack.split(`
|
|
36
36
|
`),r=n[0]??e.message,i=n.slice(1).filter(e=>e.trim().startsWith(`at `));return i.length<=t?e.stack:[r,...i.slice(0,t)].join(`
|
|
37
|
-
`)}function ta(e){let t=Zi(e);return t===`ENOENT`||t===`EACCES`||t===`EPERM`||t===`ENOTDIR`||t===`ELOOP`}function na(e){let t=Xi(e);if(!e||typeof e!=`object`||!(`isAxiosError`in e)||!e.isAxiosError)return{kind:`other`,message:t};let n=e,r=n.response?.status;return r===401||r===403?{kind:`auth`,status:r,message:t}:n.code===`ECONNABORTED`?{kind:`timeout`,status:r,message:t}:n.code===`ECONNREFUSED`||n.code===`ENOTFOUND`?{kind:`network`,status:r,message:t}:{kind:`http`,status:r,message:t}}var ra,ia,aa,oa,sa,ca,la
|
|
38
|
-
`);for(let e=c.length-1;e>=0;e--){let t=c[e];t&&(yield t)}}r.length>0&&(yield r.toString(`utf8`))}finally{await n.close()}}var Oa,ka
|
|
39
|
-
`)&&(e=
|
|
37
|
+
`)}function ta(e){let t=Zi(e);return t===`ENOENT`||t===`EACCES`||t===`EPERM`||t===`ENOTDIR`||t===`ELOOP`}function na(e){let t=Xi(e);if(!e||typeof e!=`object`||!(`isAxiosError`in e)||!e.isAxiosError)return{kind:`other`,message:t};let n=e,r=n.response?.status;return r===401||r===403?{kind:`auth`,status:r,message:t}:n.code===`ECONNABORTED`?{kind:`timeout`,status:r,message:t}:n.code===`ECONNREFUSED`||n.code===`ENOTFOUND`?{kind:`network`,status:r,message:t}:{kind:`http`,status:r,message:t}}var ra,ia,aa,oa,sa,ca,la=e((()=>{Ki(),s(),ra=class extends Error{constructor(e){super(e),this.name=this.constructor.name}},ia=class extends Error{},aa=class extends Error{constructor(e){super(e),this.name=`AbortError`}},oa=class extends Error{constructor(e,t,n){super(e),c(this,`filePath`,void 0),c(this,`defaultConfig`,void 0),this.name=`ConfigParseError`,this.filePath=t,this.defaultConfig=n}},sa=class extends Error{constructor(e,t,n,r){super(`Shell command failed`),c(this,`stdout`,void 0),c(this,`stderr`,void 0),c(this,`code`,void 0),c(this,`interrupted`,void 0),this.stdout=e,this.stderr=t,this.code=n,this.interrupted=r,this.name=`ShellError`}},ca=class extends Error{constructor(e,t){super(e),c(this,`telemetryMessage`,void 0),this.name=`TelemetrySafeError`,this.telemetryMessage=t??e}}}));function ua(){return ma}function da(e,t,n){return Q`JSON.stringify(${e})`,JSON.stringify(e,t,n)}function fa(e,t){return Q`structuredClone(${e})`,structuredClone(e,t)}function pa(e,t,n){if(Q`fs.writeFileSync(${e}, ${t})`,typeof n==`object`&&n&&`flush`in n&&n.flush===!0){let r=typeof n==`object`&&`encoding`in n?n.encoding:void 0,i=typeof n==`object`&&`mode`in n?n.mode:void 0,a;try{a=oe(e,`w`,i),se(a,t,{encoding:r??void 0}),ae(a)}finally{a!==void 0&&ie(a)}}else se(e,t,n)}var ma,Q,ha,ga=e((()=>{u(),Xa(),(()=>{let e=process.env.CLAUDE_CODE_SLOW_OPERATION_THRESHOLD_MS;if(e!==void 0){let t=Number(e);if(!Number.isNaN(t)&&t>=0)return t}return 1/0})(),ma={[Symbol.dispose](){}},Q=ua,ha=(e,t)=>(Q`JSON.parse(${e})`,t===void 0?JSON.parse(e):JSON.parse(e,t))}));function _a(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}var va=e((()=>{}));function ya(e,t){if(t.startsWith(`//`)||t.startsWith(`\\\\`))return{resolvedPath:t,isSymlink:!1,isCanonical:!1};try{let n=e.lstatSync(t);if(n.isFIFO()||n.isSocket()||n.isCharacterDevice()||n.isBlockDevice())return{resolvedPath:t,isSymlink:!1,isCanonical:!1};let r=e.realpathSync(t);return{resolvedPath:r,isSymlink:r!==t,isCanonical:!0}}catch{return{resolvedPath:t,isSymlink:!1,isCanonical:!1}}}function ba(e,t,n){let{resolvedPath:r}=ya(e,t);return n.has(r)?!0:(n.add(r),!1)}function xa(e,t){let n=t,r=[];for(;n!==p.dirname(n);){let t;try{t=e.lstatSync(n)}catch{r.unshift(p.basename(n)),n=p.dirname(n);continue}if(t.isSymbolicLink())try{let t=e.realpathSync(n);return r.length===0?t:p.join(t,...r)}catch{let t=e.readlinkSync(n),i=p.isAbsolute(t)?t:p.resolve(p.dirname(n),t);return r.length===0?i:p.join(i,...r)}try{let t=e.realpathSync(n);if(t!==n)return r.length===0?t:p.join(t,...r)}catch{}return}}function Sa(e){let t=e;t===`~`?t=f().normalize(`NFC`):t.startsWith(`~/`)&&(t=p.join(f().normalize(`NFC`),t.slice(2)));let n=new Set,r=Ca();if(n.add(t),t.startsWith(`//`)||t.startsWith(`\\\\`))return Array.from(n);try{let e=t,i=new Set;for(let a=0;a<40&&!i.has(e);a++){if(i.add(e),!r.existsSync(e)){if(e===t){let e=xa(r,t);e!==void 0&&n.add(e)}break}let a=r.lstatSync(e);if(a.isFIFO()||a.isSocket()||a.isCharacterDevice()||a.isBlockDevice()||!a.isSymbolicLink())break;let o=r.readlinkSync(e),s=p.isAbsolute(o)?o:p.resolve(p.dirname(e),o);n.add(s),e=s}}catch{}let{resolvedPath:i,isSymlink:a}=ya(r,t);return a&&i!==t&&n.add(i),Array.from(n)}function Ca(){return Oa}async function wa(e,t,n){try{var r=_a();let i=r.a(await ue(e,`r`)),a=(await i.stat()).size;if(a<=t)return null;let o=Math.min(a-t,n),s=Buffer.allocUnsafe(o),c=0;for(;c<o;){let{bytesRead:e}=await i.read(s,c,o-c,t+c);if(e===0)break;c+=e}return{content:s.toString(`utf8`,0,c),bytesRead:c,bytesTotal:a}}catch(e){r.e=e}finally{await r.d()}}async function Ta(e,t){try{var n=_a();let r=n.a(await ue(e,`r`)),i=(await r.stat()).size;if(i===0)return{content:``,bytesRead:0,bytesTotal:0};let a=Math.max(0,i-t),o=i-a,s=Buffer.allocUnsafe(o),c=0;for(;c<o;){let{bytesRead:e}=await r.read(s,c,o-c,a+c);if(e===0)break;c+=e}return{content:s.toString(`utf8`,0,c),bytesRead:c,bytesTotal:i}}catch(e){n.e=e}finally{await n.d()}}async function*Ea(e){let t=1024*4,n=await ue(e,`r`);try{let e=(await n.stat()).size,r=Buffer.alloc(0),i=Buffer.alloc(t);for(;e>0;){let a=Math.min(t,e);e-=a,await n.read(i,0,a,e);let o=Buffer.concat([i.subarray(0,a),r]),s=o.indexOf(10);if(s===-1){r=o;continue}r=Buffer.from(o.subarray(0,s));let c=o.toString(`utf8`,s+1).split(`
|
|
38
|
+
`);for(let e=c.length-1;e>=0;e--){let t=c[e];t&&(yield t)}}r.length>0&&(yield r.toString(`utf8`))}finally{await n.close()}}var Da,Oa,ka=e((()=>{la(),ga(),va(),Da={cwd(){return process.cwd()},existsSync(e){return Q`fs.existsSync(${e})`,m.existsSync(e)},async stat(e){return ge(e)},async readdir(e){return fe(e,{withFileTypes:!0})},async unlink(e){return ve(e)},async rmdir(e){return he(e)},async rm(e,t){return me(e,t)},async mkdir(e,t){try{await le(e,{recursive:!0,...t})}catch(e){if(Zi(e)!==`EEXIST`)throw e}},async readFile(e,t){return de(e,{encoding:t.encoding})},async rename(e,t){return pe(e,t)},statSync(e){return Q`fs.statSync(${e})`,m.statSync(e)},lstatSync(e){return Q`fs.lstatSync(${e})`,m.lstatSync(e)},readFileSync(e,t){return Q`fs.readFileSync(${e})`,m.readFileSync(e,{encoding:t.encoding})},readFileBytesSync(e){return Q`fs.readFileBytesSync(${e})`,m.readFileSync(e)},readSync(e,t){Q`fs.readSync(${e}, ${t.length} bytes)`;let n;try{n=m.openSync(e,`r`);let r=Buffer.alloc(t.length);return{buffer:r,bytesRead:m.readSync(n,r,0,t.length,0)}}finally{n&&m.closeSync(n)}},appendFileSync(e,t,n){if(Q`fs.appendFileSync(${e}, ${t.length} chars)`,n?.mode!==void 0)try{let r=m.openSync(e,`ax`,n.mode);try{m.appendFileSync(r,t)}finally{m.closeSync(r)}return}catch(e){if(Zi(e)!==`EEXIST`)throw e}m.appendFileSync(e,t)},copyFileSync(e,t){Q`fs.copyFileSync(${e} → ${t})`,m.copyFileSync(e,t)},unlinkSync(e){Q`fs.unlinkSync(${e})`,m.unlinkSync(e)},renameSync(e,t){Q`fs.renameSync(${e} → ${t})`,m.renameSync(e,t)},linkSync(e,t){Q`fs.linkSync(${e} → ${t})`,m.linkSync(e,t)},symlinkSync(e,t,n){Q`fs.symlinkSync(${e} → ${t})`,m.symlinkSync(e,t,n)},readlinkSync(e){return Q`fs.readlinkSync(${e})`,m.readlinkSync(e)},realpathSync(e){return Q`fs.realpathSync(${e})`,m.realpathSync(e).normalize(`NFC`)},mkdirSync(e,t){Q`fs.mkdirSync(${e})`;let n={recursive:!0};t?.mode!==void 0&&(n.mode=t.mode);try{m.mkdirSync(e,n)}catch(e){if(Zi(e)!==`EEXIST`)throw e}},readdirSync(e){return Q`fs.readdirSync(${e})`,m.readdirSync(e,{withFileTypes:!0})},readdirStringSync(e){return Q`fs.readdirStringSync(${e})`,m.readdirSync(e)},isDirEmptySync(e){return Q`fs.isDirEmptySync(${e})`,this.readdirSync(e).length===0},rmdirSync(e){Q`fs.rmdirSync(${e})`,m.rmdirSync(e)},rmSync(e,t){Q`fs.rmSync(${e})`,m.rmSync(e,t)},createWriteStream(e){return m.createWriteStream(e)},async readFileBytes(e,t){if(t===void 0)return de(e);let n=await ue(e,`r`);try{let{size:e}=await n.stat(),r=Math.min(e,t),i=Buffer.allocUnsafe(r),a=0;for(;a<r;){let{bytesRead:e}=await n.read(i,a,r-a,a);if(e===0)break;a+=e}return a<r?i.subarray(0,a):i}finally{await n.close()}}},Oa=Da})),Aa=t({flushDebugLogs:()=>La,getDebugFilePath:()=>Ka,getDebugFilter:()=>Wa,getDebugLogPath:()=>za,getHasFormattedOutput:()=>Na,getMinDebugLogLevel:()=>Ha,isDebugMode:()=>Ua,isDebugToStdErr:()=>Ga,logAntError:()=>Ba,logForDebugging:()=>Ra,setHasFormattedOutput:()=>Ma});function ja(e){return!Ua()||typeof process>`u`||process.versions===void 0||process.versions.node===void 0?!1:De(e,Wa())}function Ma(e){qa=e}function Na(){return qa}async function Pa(e,t,n,r){e&&await le(t,{recursive:!0}).catch(()=>{}),await ce(n,r),Ya()}function Fa(){}function Ia(){if(!$){let e=null;$=ye({writeFn:t=>{let n=za(),r=te(n),i=e!==r;if(e=r,Ua()){if(i)try{Ca().mkdirSync(r)}catch{}try{Ca().appendFileSync(n,t)}catch{try{Ca().mkdirSync(r),Ca().appendFileSync(n,t)}catch{}}Ya();return}Ja=Ja.then(Pa.bind(null,i,r,n,t)).catch(Fa)},flushIntervalMs:1e3,maxBufferSize:100,immediateMode:Ua()}),xe(async()=>{$?.dispose(),await Ja})}return $}async function La(){$?.flush(),await Ja}function Ra(e,{level:t}={level:`debug`}){if(Va[t]<Va[Ha()]||!ja(e))return;qa&&e.includes(`
|
|
39
|
+
`)&&(e=da(e));let n=`${new Date().toISOString()} [${t.toUpperCase()}] ${e.trim()}\n`;if(Ga()){ee(n);return}Ia().write(n)}function za(){return Ka()??(process.env.CLAUDE_CODE_DEBUG_LOGS_DIR?re(process.env.CLAUDE_CODE_DEBUG_LOGS_DIR):null)??ne(i(),`debug`,`${l()}.txt`)}function Ba(e,t){t instanceof Error&&t.stack&&Ra(`[ANT-ONLY] ${e} stack trace:\n${t.stack}`,{level:`error`})}var Va,Ha,Ua,Wa,Ga,Ka,qa,$,Ja,Ya,Xa=e((()=>{r(),u(),be(),we(),ke(),o(),ka(),d(),ga(),Va={verbose:0,debug:1,info:2,warn:3,error:4},Ha=n(()=>{let e=process.env.CLAUDE_CODE_DEBUG_LOG_LEVEL?.toLowerCase().trim();return e&&Object.hasOwn(Va,e)?e:`debug`}),Ua=n(()=>a(process.env.DEBUG)||a(process.env.DEBUG_SDK)||process.argv.includes(`--debug`)||process.argv.includes(`-d`)||Ga()||process.argv.some(e=>e.startsWith(`--debug=`))||Ka()!==null),Wa=n(()=>{let e=process.argv.find(e=>e.startsWith(`--debug=`));return e?Oe(e.substring(8)):null}),Ga=n(()=>process.argv.includes(`--debug-to-stderr`)),Ka=n(()=>{for(let e=0;e<process.argv.length;e++){let t=process.argv[e];if(t.startsWith(`--debug-file=`))return re(t.substring(13));if(t===`--debug-file`&&e+1<process.argv.length)return re(process.argv[e+1])}return null}),qa=!1,$=null,Ja=Promise.resolve(),Ya=n(async()=>{try{let e=za(),t=ne(te(e),`latest`);await ve(t).catch(()=>{}),await _e(e,t)}catch{}})}));export{S as $,sa as A,ta as B,da as C,ra as D,aa as E,$i as F,Gi as G,Yi as H,Ji as I,Fe as J,Rn as K,la as L,na as M,Xi as N,oa as O,Zi as P,ze as Q,qi as R,ha as S,pa as T,Ki as U,ea as V,Wi as W,b as X,y as Y,Le as Z,Ta as _,Ua as a,fa as b,Ra as c,Sa as d,we as et,ka as f,ya as g,Ea as h,Xa as i,be as it,ca as j,ia as k,Ma as l,wa as m,za as n,Se as nt,Ga as o,ba as p,x as q,Na as r,ye as rt,Ba as s,Aa as t,xe as tt,Ca as u,_a as v,Q as w,ga as x,va as y,Qi as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./cwd-BcO6WHKo.js";import{c as r,i}from"./debug-8DCufdSp.js";import{Ur as a,zr as o}from"./settings-DKN4xSpQ.js";function s(){f.clear()}async function c(){let e=await l();return!e||e.host!==`github.com`?null:`${e.owner}/${e.name}`}async function l(){let e=n();if(f.has(e))return f.get(e)??null;try{let t=await o();if(r(`Git remote URL: ${t}`),!t)return r(`No git remote URL found`),f.set(e,null),null;let n=u(t);return r(`Parsed repository: ${n?`${n.host}/${n.owner}/${n.name}`:null} from URL: ${t}`),f.set(e,n),n}catch(t){return r(`Error detecting repository: ${t}`),f.set(e,null),null}}function u(e){let t=e.trim(),n=t.match(/^git@([^:]+):([^/]+)\/([^/]+?)(?:\.git)?$/);if(n?.[1]&&n[2]&&n[3])return d(n[1])?{host:n[1],owner:n[2],name:n[3]}:null;let r=t.match(/^(https?|ssh|git):\/\/(?:[^@]+@)?([^/:]+(?::\d+)?)\/([^/]+)\/([^/]+?)(?:\.git)?$/);if(r?.[1]&&r[2]&&r[3]&&r[4]){let e=r[1],t=r[2],n=t.split(`:`)[0]??``;return d(n)?{host:e===`https`||e===`http`?t:n,owner:r[3],name:r[4]}:null}return null}function d(e){if(!e.includes(`.`))return!1;let t=e.split(`.`).pop();return t?/^[a-zA-Z]+$/.test(t):!1}var f,p=e((()=>{t(),i(),a(),f=new Map}));export{c as n,p as r,s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";var n,r;e((()=>{n=t(),r=async(e,t)=>{let{DiffDialog:r}=await import(`./DiffDialog-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";var n,r;e((()=>{n=t(),r=async(e,t)=>{let{DiffDialog:r}=await import(`./DiffDialog-v2IiYyi3.js`);return(0,n.jsx)(r,{messages:t.messages,onDone:e})}}))();export{r as call};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{b as t,y as n}from"./types-zk5Ltv5q.js";import{n as r,t as i}from"./cwd-BcO6WHKo.js";import{f as a,u as o}from"./debug-8DCufdSp.js";import{cr as s,or as c}from"./settings-DKN4xSpQ.js";import{o as l,s as u}from"./log-DaILwWJa.js";import{basename as d,dirname as f,join as p,sep as m}from"path";function h(e,t){if(!e)return{directory:t||i(),prefix:``};let n=c(e,t);return e.endsWith(`/`)||e.endsWith(m)?{directory:n,prefix:``}:{directory:f(n),prefix:d(e)}}async function g(e){let t=C.get(e);if(t)return t;try{let t=(await o().readdir(e)).filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).map(t=>({name:t.name,path:p(e,t.name),type:`directory`})).slice(0,100);return C.set(e,t),t}catch(e){return u(e),[]}}async function _(e,t={}){let{basePath:n=i(),maxResults:r=10}=t,{directory:a,prefix:o}=h(e,n),s=await g(a),c=o.toLowerCase();return s.filter(e=>e.name.toLowerCase().startsWith(c)).slice(0,r).map(e=>({id:e.path,displayText:`${e.name}/`,description:`directory`,metadata:{type:`directory`}}))}function v(e){return e.startsWith(`~/`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)||e===`~`||e===`.`||e===`..`}async function y(e,t=!1){let n=`${e}:${t}`,r=w.get(n);if(r)return r;try{let r=(await o().readdir(e)).filter(e=>t||!e.name.startsWith(`.`)).map(t=>({name:t.name,path:p(e,t.name),type:t.isDirectory()?`directory`:`file`})).sort((e,t)=>e.type===`directory`&&t.type!==`directory`?-1:e.type!==`directory`&&t.type===`directory`?1:e.name.localeCompare(t.name)).slice(0,100);return w.set(n,r),r}catch(e){return u(e),[]}}async function b(e,t={}){let{basePath:n=i(),maxResults:r=10,includeFiles:a=!0,includeHidden:o=!1}=t,{directory:s,prefix:c}=h(e,n),l=await y(s,o),u=c.toLowerCase(),d=l.filter(e=>!a&&e.type===`file`?!1:e.name.toLowerCase().startsWith(u)).slice(0,r),f=e.includes(`/`)||e.includes(m),p=``;if(f){let t=e.lastIndexOf(`/`),n=e.lastIndexOf(m),r=Math.max(t,n);p=e.substring(0,r+1)}return(p.startsWith(`./`)||p.startsWith(`.${m}`))&&(p=p.slice(2)),d.map(e=>{let t=p+e.name;return{id:t,displayText:e.type===`directory`?`${t}/`:t,metadata:{type:e.type}}})}var x,S,C,w,T=e((()=>{t(),r(),a(),l(),s(),x=500,S=300*1e3,C=new n({max:x,ttl:S}),w=new n({max:x,ttl:S})}));export{v as i,b as n,T as r,_ as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";import{n,t as r}from"./Doctor-By_y3C2V.js";var i,a;e((()=>{n(),i=t(),a=(e,t,n)=>Promise.resolve((0,i.jsx)(r,{onDone:e}))}))();export{a as call};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{A_ as n,B as r,Cc as i,E_ as a,Gl as o,Kl as s,Os as c,Pi as l,Sc as u,V as d,i as f,ir as p,ki as m,ks as h,o as g,vr as _}from"./loadAgentsDir-C1LkW7gl.js";import{$ as v,A as y,F as b,G as x,P as S,Q as C,V as w,W as T,Y as E,Z as D,tt as ee,x as te,z as O}from"./types-zk5Ltv5q.js";import{Mn as k,Yn as A,Z as ne,ar as re,dt as ie,or as ae,zt as j}from"./state-BowF111d.js";import{Cr as oe,d as se,h as ce,pr as le,yr as ue}from"./settings-DKN4xSpQ.js";import{m as de,r as fe}from"./config-BddEvZZl.js";import{f as pe,s as me}from"./model-BwBE0Pt5.js";import{_n as he,vn as ge}from"./prompt-BGqgPgCU.js";import{t as _e}from"./conversationRecovery-Da_8uldZ.js";import{t as ve}from"./QueryEngine-DNNy1UCD.js";import{n as ye,r as be}from"./modelOptions-DvNBapgG.js";import{n as xe,r as Se}from"./managedEnv-lybrMred.js";import{dirname as Ce}from"node:path";import{randomUUID as M}from"node:crypto";import{Readable as we,Writable as Te}from"node:stream";import{unlink as Ee}from"node:fs/promises";import*as N from"node:path/posix";import{isAbsolute as De,resolve as Oe}from"node:path/posix";te();var P={authenticate:`authenticate`,document_did_change:`document/didChange`,document_did_close:`document/didClose`,document_did_focus:`document/didFocus`,document_did_open:`document/didOpen`,document_did_save:`document/didSave`,initialize:`initialize`,logout:`logout`,nes_accept:`nes/accept`,nes_close:`nes/close`,nes_reject:`nes/reject`,nes_start:`nes/start`,nes_suggest:`nes/suggest`,session_cancel:`session/cancel`,session_close:`session/close`,session_fork:`session/fork`,session_list:`session/list`,session_load:`session/load`,session_new:`session/new`,session_prompt:`session/prompt`,session_resume:`session/resume`,session_set_config_option:`session/set_config_option`,session_set_mode:`session/set_mode`,session_set_model:`session/set_model`},F={elicitation_complete:`elicitation/complete`,elicitation_create:`elicitation/create`,fs_read_text_file:`fs/read_text_file`,fs_write_text_file:`fs/write_text_file`,session_request_permission:`session/request_permission`,session_update:`session/update`,terminal_create:`terminal/create`,terminal_kill:`terminal/kill`,terminal_output:`terminal/output`,terminal_release:`terminal/release`,terminal_wait_for_exit:`terminal/wait_for_exit`},ke=x({_meta:E(D(),v()).nullish(),terminal:b().optional().default(!1)}),Ae=x({_meta:E(D(),v()).nullish(),label:D().nullish(),name:D(),optional:b().optional().default(!1),secret:b().optional().default(!0)}),je=x({_meta:E(D(),v()).nullish(),description:D().nullish(),id:D(),name:D()}),Me=x({_meta:E(D(),v()).nullish(),description:D().nullish(),id:D(),link:D().nullish(),name:D(),vars:S(Ae)}),Ne=x({_meta:E(D(),v()).nullish(),args:S(D()).optional(),description:D().nullish(),env:E(D(),D()).optional(),id:D(),name:D()}),Pe=C([Me.and(x({type:w(`env_var`)})),Ne.and(x({type:w(`terminal`)})),je]),Fe=x({_meta:E(D(),v()).nullish(),methodId:D()}),Ie=x({_meta:E(D(),v()).nullish()}),Le=x({_meta:E(D(),v()).nullish(),blob:D(),mimeType:D().nullish(),uri:D()}),Re=x({default:b().nullish(),description:D().nullish(),title:D().nullish()}),ze=x({_meta:E(D(),v()).nullish()}),Be=x({_meta:E(D(),v()).nullish()}),Ve=x({amount:T(),currency:D()}),He=x({_meta:E(D(),v()).nullish(),terminalId:D()}),Ue=x({_meta:E(D(),v()).nullish(),newText:D(),oldText:D().nullish(),path:D()}),We=C([D(),T(),T(),b(),S(D())]),Ge=O(C([x({content:E(D(),We).nullish()}).and(x({action:w(`accept`)})),x({action:w(`decline`)}),x({action:w(`cancel`)})]),x({_meta:E(D(),v()).nullish()})),Ke=x({_meta:E(D(),v()).nullish()}),qe=D(),Je=x({_meta:E(D(),v()).nullish(),elicitationId:qe}),Ye=w(`object`),Xe=w(`string`),Ze=x({_meta:E(D(),v()).nullish()}),Qe=x({_meta:E(D(),v()).nullish(),form:Ke.nullish(),url:Ze.nullish()}),$e=x({const:D(),title:D()}),et=x({_meta:E(D(),v()).nullish(),name:D(),value:D()}),tt=x({code:C([w(-32700),w(-32600),w(-32601),w(-32602),w(-32603),w(-32800),w(-32e3),w(-32002),w(-32042),T().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),data:v().optional(),message:D()}),nt=v(),rt=v(),it=v(),at=x({_meta:E(D(),v()).nullish(),readTextFile:b().optional().default(!1),writeTextFile:b().optional().default(!1)}),ot=x({_meta:E(D(),v()).nullish(),name:D(),value:D()}),st=x({_meta:E(D(),v()).nullish(),name:D(),title:D().nullish(),version:D()}),ct=x({default:T().nullish(),description:D().nullish(),maximum:T().nullish(),minimum:T().nullish(),title:D().nullish()}),lt=x({_meta:E(D(),v()).nullish()}),ut=x({_meta:E(D(),v()).nullish(),additionalDirectories:S(D()).optional(),cursor:D().nullish(),cwd:D().nullish()}),dt=x({_meta:E(D(),v()).nullish()}),ft=x({_meta:E(D(),v()).nullish(),logout:dt.nullish()}),pt=x({_meta:E(D(),v()).nullish()}),mt=x({_meta:E(D(),v()).nullish()}),ht=x({_meta:E(D(),v()).nullish(),http:b().optional().default(!1),sse:b().optional().default(!1)}),gt=x({_meta:E(D(),v()).nullish(),headers:S(ot),name:D(),url:D()}),_t=x({_meta:E(D(),v()).nullish(),headers:S(ot),name:D(),url:D()}),vt=x({_meta:E(D(),v()).nullish(),args:S(D()),command:D(),env:S(et),name:D()}),I=C([gt.and(x({type:w(`http`)})),_t.and(x({type:w(`sse`)})),vt]),yt=D(),bt=x({_meta:E(D(),v()).nullish(),description:D().nullish(),modelId:yt,name:D()}),xt=C([w(`error`),w(`warning`),w(`information`),w(`hint`)]),St=x({_meta:E(D(),v()).nullish()}),Ct=x({_meta:E(D(),v()).nullish()}),wt=x({_meta:E(D(),v()).nullish()}),Tt=x({_meta:E(D(),v()).nullish()}),Et=x({_meta:E(D(),v()).nullish()}),Dt=x({_meta:E(D(),v()).nullish(),maxCount:T().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Ot=x({diff:D(),uri:D()}),kt=x({endLine:T().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),startLine:T().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),text:D()}),At=x({_meta:E(D(),v()).nullish()}),jt=x({_meta:E(D(),v()).nullish()}),Mt=x({languageId:D(),text:D(),uri:D()}),Nt=x({_meta:E(D(),v()).nullish(),maxCount:T().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Pt=C([w(`rejected`),w(`ignored`),w(`replaced`),w(`cancelled`)]),Ft=x({excerpts:S(kt),uri:D()}),It=x({_meta:E(D(),v()).nullish()}),Lt=x({_meta:E(D(),v()).nullish()}),Rt=x({name:D(),owner:D(),remoteUrl:D()}),zt=x({_meta:E(D(),v()).nullish()}),Bt=x({_meta:E(D(),v()).nullish(),jump:At.nullish(),rename:Lt.nullish(),searchAndReplace:zt.nullish()}),Vt=x({id:D(),isRegex:b().nullish(),replace:D(),search:D(),uri:D()}),Ht=C([w(`automatic`),w(`diagnostic`),w(`manual`)]),Ut=x({_meta:E(D(),v()).nullish(),maxCount:T().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Wt=x({_meta:E(D(),v()).nullish(),diagnostics:St.nullish(),editHistory:Dt.nullish(),openFiles:jt.nullish(),recentFiles:Nt.nullish(),relatedSnippets:It.nullish(),userActions:Ut.nullish()}),Gt=x({_meta:E(D(),v()).nullish(),additionalDirectories:S(D()).optional(),cwd:D(),mcpServers:S(I)}),Kt=x({default:T().nullish(),description:D().nullish(),maximum:T().nullish(),minimum:T().nullish(),title:D().nullish()}),qt=D(),Jt=C([w(`allow_once`),w(`allow_always`),w(`reject_once`),w(`reject_always`)]),Yt=x({_meta:E(D(),v()).nullish(),kind:Jt,name:D(),optionId:qt}),Xt=C([w(`high`),w(`medium`),w(`low`)]),Zt=C([w(`pending`),w(`in_progress`),w(`completed`)]),Qt=x({_meta:E(D(),v()).nullish(),content:D(),priority:Xt,status:Zt}),$t=x({_meta:E(D(),v()).nullish(),entries:S(Qt)}),L=x({character:T().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),line:T().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`})}),en=x({id:D(),position:L,uri:D()}),tn=x({id:D(),newName:D(),position:L,uri:D()}),nn=x({action:D(),position:L,timestampMs:T(),uri:D()}),rn=C([w(`utf-16`),w(`utf-32`),w(`utf-8`)]),an=x({_meta:E(D(),v()).nullish(),auth:ke.optional().default({terminal:!1}),elicitation:Qe.nullish(),fs:at.optional().default({readTextFile:!1,writeTextFile:!1}),nes:Bt.nullish(),positionEncodings:S(rn).optional(),terminal:b().optional().default(!1)}),on=x({_meta:E(D(),v()).nullish(),audio:b().optional().default(!1),embeddedContext:b().optional().default(!1),image:b().optional().default(!1)}),sn=T().int().gte(0).lte(65535),cn=x({_meta:E(D(),v()).nullish(),clientCapabilities:an.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:st.nullish(),protocolVersion:sn}),R=x({end:L,start:L}),ln=x({message:D(),range:R,severity:xt,uri:D()}),un=x({languageId:D(),lastFocusedMs:T().nullish(),uri:D(),visibleRange:R.nullish()}),dn=x({_meta:E(D(),v()).nullish(),diagnostics:S(ln).nullish(),editHistory:S(Ot).nullish(),openFiles:S(un).nullish(),recentFiles:S(Mt).nullish(),relatedSnippets:S(Ft).nullish(),userActions:S(nn).nullish()}),fn=x({newText:D(),range:R}),pn=C([x({cursorPosition:L.nullish(),edits:S(fn),id:D(),uri:D()}).and(x({kind:w(`edit`)})),en.and(x({kind:w(`jump`)})),tn.and(x({kind:w(`rename`)})),Vt.and(x({kind:w(`searchAndReplace`)}))]),mn=x({_meta:E(D(),v()).nullish(),content:D()}),hn=x({_meta:E(D(),v()).nullish()}),z=C([T(),D()]).nullable();x({_meta:E(D(),v()).nullish(),requestId:z});var gn=x({requestId:z}),_n=y([`assistant`,`user`]),B=x({_meta:E(D(),v()).nullish(),audience:S(_n).nullish(),lastModified:D().nullish(),priority:T().nullish()}),vn=x({_meta:E(D(),v()).nullish(),annotations:B.nullish(),data:D(),mimeType:D()}),yn=x({_meta:E(D(),v()).nullish(),annotations:B.nullish(),data:D(),mimeType:D(),uri:D().nullish()}),bn=x({_meta:E(D(),v()).nullish(),annotations:B.nullish(),description:D().nullish(),mimeType:D().nullish(),name:D(),size:T().nullish(),title:D().nullish(),uri:D()}),xn=x({_meta:E(D(),v()).nullish(),optionId:qt}),Sn=C([x({outcome:w(`cancelled`)}),xn.and(x({outcome:w(`selected`)}))]),Cn=x({_meta:E(D(),v()).nullish(),outcome:Sn}),wn=x({_meta:E(D(),v()).nullish()}),Tn=x({_meta:E(D(),v()).nullish()}),En=x({currentValue:b()}),Dn=D(),On=D(),kn=C([w(`mode`),w(`model`),w(`thought_level`),D()]),V=D(),An=x({_meta:E(D(),v()).nullish(),description:D().nullish(),name:D(),value:V}),jn=x({_meta:E(D(),v()).nullish(),group:Dn,name:D(),options:S(An)}),H=O(C([x({currentValue:V,options:C([S(An),S(jn)])}).and(x({type:w(`select`)})),En.and(x({type:w(`boolean`)}))]),x({_meta:E(D(),v()).nullish(),category:kn.nullish(),description:D().nullish(),id:On,name:D()})),Mn=x({_meta:E(D(),v()).nullish(),configOptions:S(H)}),Nn=x({_meta:E(D(),v()).nullish()}),U=D(),Pn=x({_meta:E(D(),v()).nullish(),id:D(),sessionId:U}),Fn=x({_meta:E(D(),v()).nullish(),sessionId:U}),In=x({_meta:E(D(),v()).nullish(),sessionId:U}),Ln=x({_meta:E(D(),v()).nullish(),sessionId:U}),Rn=x({_meta:E(D(),v()).nullish(),args:S(D()).optional(),command:D(),cwd:D().nullish(),env:S(et).optional(),outputByteLimit:T().nullish(),sessionId:U}),zn=x({_meta:E(D(),v()).nullish(),sessionId:U,uri:D()}),Bn=x({_meta:E(D(),v()).nullish(),position:L,sessionId:U,uri:D(),version:T(),visibleRange:R}),Vn=x({_meta:E(D(),v()).nullish(),languageId:D(),sessionId:U,text:D(),uri:D(),version:T()}),Hn=x({_meta:E(D(),v()).nullish(),sessionId:U,uri:D()}),Un=x({_meta:E(D(),v()).nullish(),additionalDirectories:S(D()).optional(),cwd:D(),mcpServers:S(I).optional(),sessionId:U}),Wn=x({_meta:E(D(),v()).nullish(),sessionId:U,terminalId:D()}),Gn=x({_meta:E(D(),v()).nullish(),additionalDirectories:S(D()).optional(),cwd:D(),mcpServers:S(I),sessionId:U}),Kn=x({_meta:E(D(),v()).nullish(),limit:T().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:T().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:D(),sessionId:U}),qn=x({_meta:E(D(),v()).nullish(),id:D(),reason:Pt.nullish(),sessionId:U}),Jn=x({_meta:E(D(),v()).nullish(),sessionId:U,terminalId:D()}),Yn=x({_meta:E(D(),v()).nullish(),additionalDirectories:S(D()).optional(),cwd:D(),mcpServers:S(I).optional(),sessionId:U}),Xn=x({_meta:E(D(),v()).nullish(),additionalDirectories:S(D()).optional(),cwd:D(),sessionId:U,title:D().nullish(),updatedAt:D().nullish()}),Zn=x({_meta:E(D(),v()).nullish(),nextCursor:D().nullish(),sessions:S(Xn)}),Qn=x({_meta:E(D(),v()).nullish(),title:D().nullish(),updatedAt:D().nullish()}),$n=x({_meta:E(D(),v()).nullish()}),W=D(),er=x({_meta:E(D(),v()).nullish(),currentModeId:W}),tr=x({_meta:E(D(),v()).nullish(),description:D().nullish(),id:W,name:D()}),G=x({_meta:E(D(),v()).nullish(),availableModes:S(tr),currentModeId:W}),K=x({_meta:E(D(),v()).nullish(),availableModels:S(bt),currentModelId:yt}),nr=x({_meta:E(D(),v()).nullish(),configOptions:S(H).nullish(),models:K.nullish(),modes:G.nullish(),sessionId:U}),rr=x({_meta:E(D(),v()).nullish(),configOptions:S(H).nullish(),models:K.nullish(),modes:G.nullish()}),ir=x({_meta:E(D(),v()).nullish(),configOptions:S(H).nullish(),models:K.nullish(),modes:G.nullish(),sessionId:U}),ar=x({_meta:E(D(),v()).nullish(),configOptions:S(H).nullish(),models:K.nullish(),modes:G.nullish()}),or=x({_meta:E(D(),v()).nullish()}),sr=x({_meta:E(D(),v()).nullish(),additionalDirectories:wn.nullish(),close:Tn.nullish(),fork:Nn.nullish(),list:$n.nullish(),resume:or.nullish()}),cr=O(C([x({type:w(`boolean`),value:b()}),x({value:V})]),x({_meta:E(D(),v()).nullish(),configId:On,sessionId:U})),lr=x({_meta:E(D(),v()).nullish(),configOptions:S(H)}),ur=x({_meta:E(D(),v()).nullish(),modeId:W,sessionId:U}),dr=x({_meta:E(D(),v()).nullish()}),fr=x({_meta:E(D(),v()).nullish(),modelId:yt,sessionId:U}),pr=x({_meta:E(D(),v()).nullish()}),mr=x({_meta:E(D(),v()).nullish(),sessionId:U}),hr=C([w(`end_turn`),w(`max_tokens`),w(`max_turn_requests`),w(`refusal`),w(`cancelled`)]),gr=C([w(`email`),w(`uri`),w(`date`),w(`date-time`)]),_r=x({default:D().nullish(),description:D().nullish(),enum:S(D()).nullish(),format:gr.nullish(),maxLength:T().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),minLength:T().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),oneOf:S($e).nullish(),pattern:D().nullish(),title:D().nullish()}),vr=x({_meta:E(D(),v()).nullish(),context:dn.nullish(),position:L,selection:R.nullish(),sessionId:U,triggerKind:Ht,uri:D(),version:T()}),yr=x({_meta:E(D(),v()).nullish(),suggestions:S(pn)}),br=x({_meta:E(D(),v()).nullish(),terminalId:D()}),xr=x({_meta:E(D(),v()).nullish(),exitCode:T().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:D().nullish()}),Sr=x({_meta:E(D(),v()).nullish(),sessionId:U,terminalId:D()}),Cr=x({_meta:E(D(),v()).nullish(),exitStatus:xr.nullish(),output:D(),truncated:b()}),wr=x({_meta:E(D(),v()).nullish(),annotations:B.nullish(),text:D()}),Tr=x({range:R.nullish(),text:D()}),Er=x({_meta:E(D(),v()).nullish(),contentChanges:S(Tr),sessionId:U,uri:D(),version:T()});x({method:D(),params:C([Fn,Vn,Er,zn,Hn,Bn,Pn,qn,nt]).nullish()});var Dr=C([w(`full`),w(`incremental`)]),Or=x({_meta:E(D(),v()).nullish(),syncKind:Dr}),kr=x({_meta:E(D(),v()).nullish(),didChange:Or.nullish(),didClose:Ct.nullish(),didFocus:wt.nullish(),didOpen:Tt.nullish(),didSave:Et.nullish()}),Ar=x({_meta:E(D(),v()).nullish(),document:kr.nullish()}),jr=x({_meta:E(D(),v()).nullish(),context:Wt.nullish(),events:Ar.nullish()}),Mr=x({_meta:E(D(),v()).nullish(),auth:ft.optional().default({}),loadSession:b().optional().default(!1),mcpCapabilities:ht.optional().default({http:!1,sse:!1}),nes:jr.nullish(),positionEncoding:rn.nullish(),promptCapabilities:on.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:sr.optional().default({})}),Nr=x({_meta:E(D(),v()).nullish(),agentCapabilities:Mr.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:st.nullish(),authMethods:S(Pe).optional().default([]),protocolVersion:sn}),Pr=C([x({_meta:E(D(),v()).nullish(),mimeType:D().nullish(),text:D(),uri:D()}),Le]),Fr=x({_meta:E(D(),v()).nullish(),annotations:B.nullish(),resource:Pr}),Ir=C([wr.and(x({type:w(`text`)})),yn.and(x({type:w(`image`)})),vn.and(x({type:w(`audio`)})),bn.and(x({type:w(`resource_link`)})),Fr.and(x({type:w(`resource`)}))]),Lr=x({_meta:E(D(),v()).nullish(),content:Ir}),Rr=x({_meta:E(D(),v()).nullish(),content:Ir,messageId:D().nullish()}),zr=x({_meta:E(D(),v()).nullish(),messageId:D().nullish(),prompt:S(Ir),sessionId:U}),Br=x({anyOf:S($e)}),Vr=C([Lr.and(x({type:w(`content`)})),Ue.and(x({type:w(`diff`)})),br.and(x({type:w(`terminal`)}))]),Hr=D(),Ur=x({sessionId:U,toolCallId:Hr.nullish()}),Wr=O(C([Ur,gn]),x({elicitationId:qe,url:D().url()})),Gr=x({_meta:E(D(),v()).nullish(),line:T().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:D()}),Kr=C([w(`pending`),w(`in_progress`),w(`completed`),w(`failed`)]),qr=C([w(`read`),w(`edit`),w(`delete`),w(`move`),w(`search`),w(`execute`),w(`think`),w(`fetch`),w(`switch_mode`),w(`other`)]),Jr=x({_meta:E(D(),v()).nullish(),content:S(Vr).optional(),kind:qr.optional(),locations:S(Gr).optional(),rawInput:v().optional(),rawOutput:v().optional(),status:Kr.optional(),title:D(),toolCallId:Hr}),Yr=x({_meta:E(D(),v()).nullish(),content:S(Vr).nullish(),kind:qr.nullish(),locations:S(Gr).nullish(),rawInput:v().optional(),rawOutput:v().optional(),status:Kr.nullish(),title:D().nullish(),toolCallId:Hr}),Xr=x({_meta:E(D(),v()).nullish(),options:S(Yt),sessionId:U,toolCall:Yr}),Zr=x({_meta:E(D(),v()).nullish(),hint:D()}),Qr=x({_meta:E(D(),v()).nullish(),description:D(),input:Zr.nullish(),name:D()}),$r=x({_meta:E(D(),v()).nullish(),availableCommands:S(Qr)}),ei=C([x({enum:S(D()),type:Xe}),Br]),ti=x({default:S(D()).nullish(),description:D().nullish(),items:ei,maxItems:T().nullish(),minItems:T().nullish(),title:D().nullish()}),ni=C([_r.and(x({type:w(`string`)})),Kt.and(x({type:w(`number`)})),ct.and(x({type:w(`integer`)})),Re.and(x({type:w(`boolean`)})),ti.and(x({type:w(`array`)}))]),ri=x({description:D().nullish(),properties:E(D(),ni).optional().default({}),required:S(D()).nullish(),title:D().nullish(),type:Ye.optional().default(`object`)}),ii=O(C([O(C([Ur,gn]),x({requestedSchema:ri})).and(x({mode:w(`form`)})),Wr.and(x({mode:w(`url`)}))]),x({_meta:E(D(),v()).nullish(),message:D()})),ai=x({cachedReadTokens:T().nullish(),cachedWriteTokens:T().nullish(),inputTokens:T(),outputTokens:T(),thoughtTokens:T().nullish(),totalTokens:T()});C([x({id:z,result:C([Nr,Ie,mt,ir,rr,Zn,nr,ar,Be,dr,lr,x({_meta:E(D(),v()).nullish(),stopReason:hr,usage:ai.nullish(),userMessageId:D().nullish()}),pr,mr,yr,ze,it])}),x({error:tt,id:z})]);var oi=x({_meta:E(D(),v()).nullish(),cost:Ve.nullish(),size:T(),used:T()}),si=C([Rr.and(x({sessionUpdate:w(`user_message_chunk`)})),Rr.and(x({sessionUpdate:w(`agent_message_chunk`)})),Rr.and(x({sessionUpdate:w(`agent_thought_chunk`)})),Jr.and(x({sessionUpdate:w(`tool_call`)})),Yr.and(x({sessionUpdate:w(`tool_call_update`)})),$t.and(x({sessionUpdate:w(`plan`)})),$r.and(x({sessionUpdate:w(`available_commands_update`)})),er.and(x({sessionUpdate:w(`current_mode_update`)})),Mn.and(x({sessionUpdate:w(`config_option_update`)})),Qn.and(x({sessionUpdate:w(`session_info_update`)})),oi.and(x({sessionUpdate:w(`usage_update`)}))]),ci=x({_meta:E(D(),v()).nullish(),sessionId:U,update:si});x({method:D(),params:C([ci,Je,nt]).nullish()});var li=x({_meta:E(D(),v()).nullish(),sessionId:U,terminalId:D()}),ui=x({_meta:E(D(),v()).nullish(),exitCode:T().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:D().nullish()}),di=x({name:D(),uri:D()}),fi=x({_meta:E(D(),v()).nullish(),repository:Rt.nullish(),workspaceFolders:S(di).nullish(),workspaceUri:D().nullish()});x({id:z,method:D(),params:C([cn,Fe,pt,Gt,Gn,ut,Un,Yn,Ln,ur,cr,zr,fr,fi,vr,In,rt]).nullish()});var pi=x({_meta:E(D(),v()).nullish(),content:D(),path:D(),sessionId:U});x({id:z,method:D(),params:C([pi,Kn,Xr,Rn,Sr,Jn,li,Wn,ii,rt]).nullish()}),C([x({id:z,result:C([x({_meta:E(D(),v()).nullish()}),mn,Cn,He,Cr,hn,ui,lt,Ge,it])}),x({error:tt,id:z})]),e();function mi(e,t){let n=new TextEncoder,r=new TextDecoder;return{readable:new ReadableStream({async start(e){let n=``,i=t.getReader();try{for(;;){let{value:t,done:a}=await i.read();if(a){n+=r.decode();break}if(!t)continue;n+=r.decode(t,{stream:!0});let o=n.split(`
|
|
2
|
+
`);n=o.pop()||``;for(let t of o){let n=t.trim();if(n)try{let t=JSON.parse(n);e.enqueue(t)}catch(e){console.error(`Failed to parse JSON message:`,n,e)}}}let t=n.trim();if(t)try{let n=JSON.parse(t);e.enqueue(n)}catch(e){console.error(`Failed to parse JSON message:`,t,e)}}catch(t){e.error(t);return}finally{i.releaseLock()}e.close()}}),writable:new WritableStream({async write(t){let r=JSON.stringify(t)+`
|
|
3
|
+
`,i=e.getWriter();try{await i.write(n.encode(r))}finally{i.releaseLock()}}})}}te();var hi,gi=class{constructor(e,n){t(this,`connection`,void 0);let r=e(this),i=async(e,t)=>{switch(e){case P.initialize:{let e=cn.parse(t);return r.initialize(e)}case P.session_new:{let e=Gt.parse(t);return r.newSession(e)}case P.session_load:{if(!r.loadSession)throw q.methodNotFound(e);let n=Gn.parse(t);return r.loadSession(n)}case P.session_list:{if(!r.listSessions)throw q.methodNotFound(e);let n=ut.parse(t);return r.listSessions(n)}case P.session_fork:{if(!r.unstable_forkSession)throw q.methodNotFound(e);let n=Un.parse(t);return r.unstable_forkSession(n)}case P.session_resume:{if(!r.unstable_resumeSession)throw q.methodNotFound(e);let n=Yn.parse(t);return r.unstable_resumeSession(n)}case P.session_close:{if(!r.unstable_closeSession)throw q.methodNotFound(e);let n=Ln.parse(t);return r.unstable_closeSession(n)}case P.session_set_mode:{if(!r.setSessionMode)throw q.methodNotFound(e);let n=ur.parse(t);return await r.setSessionMode(n)??{}}case P.authenticate:{let e=Fe.parse(t);return await r.authenticate(e)??{}}case P.logout:{if(!r.unstable_logout)throw q.methodNotFound(e);let n=pt.parse(t);return await r.unstable_logout(n)??{}}case P.session_prompt:{let e=zr.parse(t);return r.prompt(e)}case P.session_set_model:{if(!r.unstable_setSessionModel)throw q.methodNotFound(e);let n=fr.parse(t);return await r.unstable_setSessionModel(n)??{}}case P.session_set_config_option:{if(!r.setSessionConfigOption)throw q.methodNotFound(e);let n=cr.parse(t);return r.setSessionConfigOption(n)}case P.nes_start:{if(!r.unstable_startNes)throw q.methodNotFound(e);let n=fi.parse(t);return r.unstable_startNes(n)}case P.nes_suggest:{if(!r.unstable_suggestNes)throw q.methodNotFound(e);let n=vr.parse(t);return r.unstable_suggestNes(n)}case P.nes_close:{if(!r.unstable_closeNes)throw q.methodNotFound(e);let n=In.parse(t);return await r.unstable_closeNes(n)??{}}default:if(r.extMethod)return r.extMethod(e,t);throw q.methodNotFound(e)}},a=async(e,t)=>{switch(e){case P.session_cancel:{let e=Fn.parse(t);return r.cancel(e)}case P.document_did_open:{if(!r.unstable_didOpenDocument)return;let e=Vn.parse(t);return r.unstable_didOpenDocument(e)}case P.document_did_change:{if(!r.unstable_didChangeDocument)return;let e=Er.parse(t);return r.unstable_didChangeDocument(e)}case P.document_did_close:{if(!r.unstable_didCloseDocument)return;let e=zn.parse(t);return r.unstable_didCloseDocument(e)}case P.document_did_save:{if(!r.unstable_didSaveDocument)return;let e=Hn.parse(t);return r.unstable_didSaveDocument(e)}case P.document_did_focus:{if(!r.unstable_didFocusDocument)return;let e=Bn.parse(t);return r.unstable_didFocusDocument(e)}case P.nes_accept:{if(!r.unstable_acceptNes)return;let e=Pn.parse(t);return r.unstable_acceptNes(e)}case P.nes_reject:{if(!r.unstable_rejectNes)return;let e=qn.parse(t);return r.unstable_rejectNes(e)}default:if(r.extNotification)return r.extNotification(e,t);throw q.methodNotFound(e)}};this.connection=new vi(i,a,n)}async sessionUpdate(e){return await this.connection.sendNotification(F.session_update,e)}async requestPermission(e){return await this.connection.sendRequest(F.session_request_permission,e)}async readTextFile(e){return await this.connection.sendRequest(F.fs_read_text_file,e)}async writeTextFile(e){return await this.connection.sendRequest(F.fs_write_text_file,e)??{}}async createTerminal(e){return new _i((await this.connection.sendRequest(F.terminal_create,e)).terminalId,e.sessionId,this.connection)}async unstable_createElicitation(e){return await this.connection.sendRequest(F.elicitation_create,e)}async unstable_completeElicitation(e){return await this.connection.sendNotification(F.elicitation_complete,e)}async extMethod(e,t){return await this.connection.sendRequest(e,t)}async extNotification(e,t){return await this.connection.sendNotification(e,t)}get signal(){return this.connection.signal}get closed(){return this.connection.closed}};hi=Symbol.asyncDispose;var _i=class{constructor(e,n,r){t(this,`id`,void 0),t(this,`sessionId`,void 0),t(this,`connection`,void 0),this.id=e,this.sessionId=n,this.connection=r}async currentOutput(){return await this.connection.sendRequest(F.terminal_output,{sessionId:this.sessionId,terminalId:this.id})}async waitForExit(){return await this.connection.sendRequest(F.terminal_wait_for_exit,{sessionId:this.sessionId,terminalId:this.id})}async kill(){return await this.connection.sendRequest(F.terminal_kill,{sessionId:this.sessionId,terminalId:this.id})??{}}async release(){return await this.connection.sendRequest(F.terminal_release,{sessionId:this.sessionId,terminalId:this.id})??{}}async[hi](){await this.release()}},vi=class{constructor(e,n,r){t(this,`pendingResponses`,new Map),t(this,`nextRequestId`,0),t(this,`requestHandler`,void 0),t(this,`notificationHandler`,void 0),t(this,`stream`,void 0),t(this,`writeQueue`,Promise.resolve()),t(this,`abortController`,new AbortController),t(this,`closedPromise`,void 0),this.requestHandler=e,this.notificationHandler=n,this.stream=r,this.closedPromise=new Promise(e=>{this.abortController.signal.addEventListener(`abort`,()=>e())}),this.receive()}get signal(){return this.abortController.signal}get closed(){return this.closedPromise}async receive(){let e;try{let e=this.stream.readable.getReader();try{for(;!this.abortController.signal.aborted;){let{value:t,done:n}=await e.read();if(n)break;if(t)try{this.processMessage(t)}catch(e){console.error(`Unexpected error during message processing:`,t,e),`id`in t&&t.id!==void 0&&this.sendMessage({jsonrpc:`2.0`,id:t.id,error:{code:-32700,message:`Parse error`}})}}}finally{e.releaseLock()}}catch(t){e=t}finally{this.close(e)}}close(e){if(this.abortController.signal.aborted)return;let t=e??Error(`ACP connection closed`);for(let e of this.pendingResponses.values())e.reject(t);this.pendingResponses.clear(),this.abortController.abort(t)}async processMessage(e){if(`method`in e&&`id`in e){let t=await this.tryCallRequestHandler(e.method,e.params);`error`in t&&console.error(`Error handling request`,e,t.error),await this.sendMessage({jsonrpc:`2.0`,id:e.id,...t})}else if(`method`in e){let t=await this.tryCallNotificationHandler(e.method,e.params);`error`in t&&console.error(`Error handling notification`,e,t.error)}else`id`in e?this.handleResponse(e):console.error(`Invalid message`,{message:e})}async tryCallRequestHandler(e,t){try{return{result:await this.requestHandler(e,t)??null}}catch(e){if(e instanceof q)return e.toResult();if(e instanceof ee)return q.invalidParams(e.format()).toResult();let t;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(t=e.message);try{return q.internalError(t?JSON.parse(t):{}).toResult()}catch{return q.internalError({details:t}).toResult()}}}async tryCallNotificationHandler(e,t){try{return await this.notificationHandler(e,t),{result:null}}catch(e){if(e instanceof q)return e.toResult();if(e instanceof ee)return q.invalidParams(e.format()).toResult();let t;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(t=e.message);try{return q.internalError(t?JSON.parse(t):{}).toResult()}catch{return q.internalError({details:t}).toResult()}}}handleResponse(e){let t=this.pendingResponses.get(e.id);if(t){if(`result`in e)t.resolve(e.result);else if(`error`in e){let{code:n,message:r,data:i}=e.error;t.reject(new q(n,r,i))}this.pendingResponses.delete(e.id)}else console.error(`Got response to unknown request`,e.id)}sendRequest(e,t){this.throwIfClosed();let n=this.nextRequestId++,r=new Promise((e,t)=>{this.pendingResponses.set(n,{resolve:e,reject:t})});return r.catch(()=>{}),this.sendMessage({jsonrpc:`2.0`,id:n,method:e,params:t}),r}async sendNotification(e,t){this.throwIfClosed(),await this.sendMessage({jsonrpc:`2.0`,method:e,params:t})}throwIfClosed(){if(this.abortController.signal.aborted)throw this.abortController.signal.reason??Error(`ACP connection closed`)}async sendMessage(e){return this.writeQueue=this.writeQueue.then(async()=>{let t=this.stream.writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(e=>{this.close(e)}),this.writeQueue}},q=class e extends Error{constructor(e,n,r){super(n),t(this,`code`,void 0),t(this,`data`,void 0),this.code=e,this.name=`RequestError`,this.data=r}static parseError(t,n){return new e(-32700,`Parse error${n?`: ${n}`:``}`,t)}static invalidRequest(t,n){return new e(-32600,`Invalid request${n?`: ${n}`:``}`,t)}static methodNotFound(t){return new e(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,n){return new e(-32602,`Invalid params${n?`: ${n}`:``}`,t)}static internalError(t,n){return new e(-32603,`Internal error${n?`: ${n}`:``}`,t)}static authRequired(t,n){return new e(-32e3,`Authentication required${n?`: ${n}`:``}`,t)}static resourceNotFound(t){return new e(-32002,`Resource not found${t?`: ${t}`:``}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}};re(),j(),ce(),ge(),de(),n(),i(),h(),l(),d(),g(),Se();function J(e,t){if(e)return t?De(e)?e:Oe(t,e):e}var yi=!(typeof process.geteuid==`function`?process.geteuid()===0:typeof process.getuid==`function`&&process.getuid()===0)||!!process.env.IS_SANDBOX,bi={auto:`auto`,default:`default`,acceptedits:`acceptEdits`,dontask:`dontAsk`,plan:`plan`,bypasspermissions:`bypassPermissions`,bypass:`bypassPermissions`};function xi(e,t=`permissions.defaultMode`){if(e===void 0)return`default`;if(typeof e!=`string`)throw Error(`Invalid ${t}: expected a string.`);let n=e.trim().toLowerCase();if(n===``)throw Error(`Invalid ${t}: expected a non-empty string.`);let r=bi[n];if(!r)throw Error(`Invalid ${t}: ${e}.`);if(r===`bypassPermissions`&&!yi)throw Error(`Invalid ${t}: bypassPermissions is not available when running as root.`);return r}function Si(e){let t=[...e.mcpServers??[]].sort((e,t)=>e.name.localeCompare(t.name));return JSON.stringify({cwd:e.cwd,mcpServers:t})}var Ci=256;function wi(e){let t=e.replace(/[\r\n]+/g,` `).replace(/\s+/g,` `).trim();return t.length<=Ci?t:`${t.slice(0,Ci-1)}…`}function Ti(e,t){if(!t)return e;let n=N.resolve(t),r=N.resolve(e);return r.startsWith(n+N.sep)||r===n?N.relative(n,r):e}function Ei(e){let t="```";for(let n of e.matchAll(/^```+/gm)??[])for(;n[0].length>=t.length;)t+="`";return`${t}\n${e}${e.endsWith(`
|
|
4
|
+
`)?``:`
|
|
5
|
+
`}${t}`}function Y(e,t=!1,n){let r=e.name,i=e.input;switch(r){case`Agent`:case`Task`:{let e=i?.description??`Task`,t=i?.prompt;return{title:e,kind:`think`,content:t?[{type:`content`,content:{type:`text`,text:t}}]:[]}}case`Bash`:{let e=i?.command??`Terminal`,t=i?.description;return{title:e,kind:`execute`,content:t?[{type:`content`,content:{type:`text`,text:t}}]:[]}}case`Read`:{let e=i?.file_path,t=e??`File`,r=i?.offset,a=i?.limit,o=``;a&&a>0?o=` (${r??1} - ${(r??1)+a-1})`:r&&(o=` (from line ${r})`);let s=t?Ti(t,n):`File`,c=J(e,n);return{title:`Read ${s}${o}`,kind:`read`,locations:c?[{path:c,line:r??1}]:[],content:[]}}case`Write`:{let e=i?.file_path??``,t=i?.content??``,r=e?Ti(e,n):void 0,a=J(e,n);return{title:r?`Write ${r}`:`Write`,kind:`edit`,content:a?[{type:`diff`,path:a,oldText:null,newText:t}]:[{type:`content`,content:{type:`text`,text:t}}],locations:a?[{path:a}]:[]}}case`Edit`:{let e=i?.file_path??``,t=i?.old_string??``,r=i?.new_string??``,a=e?Ti(e,n):void 0,o=J(e,n);return{title:a?`Edit ${a}`:`Edit`,kind:`edit`,content:o?[{type:`diff`,path:o,oldText:t||null,newText:r}]:[],locations:o?[{path:o}]:[]}}case`Glob`:{let e=i?.path??``,t=i?.pattern??``,r=J(e,n),a=`Find`;return e&&(a+=` \`${e}\``),t&&(a+=` \`${t}\``),{title:a,kind:`search`,content:[],locations:r?[{path:r}]:[]}}case`Grep`:{let e=i?.pattern??``,t=i?.path??``,n=`grep`;return i?.[`-i`]&&(n+=` -i`),i?.[`-n`]&&(n+=` -n`),i?.[`-A`]!==void 0&&(n+=` -A ${i[`-A`]}`),i?.[`-B`]!==void 0&&(n+=` -B ${i[`-B`]}`),i?.[`-C`]!==void 0&&(n+=` -C ${i[`-C`]}`),i?.output_mode===`files_with_matches`?n+=` -l`:i?.output_mode===`count`&&(n+=` -c`),i?.head_limit!==void 0&&(n+=` | head -${i.head_limit}`),i?.glob&&(n+=` --include="${i.glob}"`),i?.type&&(n+=` --type=${i.type}`),i?.multiline&&(n+=` -P`),e&&(n+=` "${e}"`),t&&(n+=` ${t}`),{title:n,kind:`search`,content:[]}}case`TodoWrite`:{let e=i?.todos;return{title:Array.isArray(e)?`Update TODOs: ${e.map(e=>e.content).join(`, `)}`:`Update TODOs`,kind:`think`,content:[]}}case`ExitPlanMode`:{let e=i?.plan;return{title:`Ready to code?`,kind:`switch_mode`,content:e?[{type:`content`,content:{type:`text`,text:e}}]:[]}}default:return{title:r||`Unknown Tool`,kind:`other`,content:[]}}}function Di(e,t){return Array.isArray(e)&&e.length>0?{content:e.map(e=>({type:`content`,content:Oi(e,t)}))}:typeof e==`string`&&e.length>0?{content:[{type:`content`,content:{type:`text`,text:t?`\`\`\`\n${e}\n\`\`\``:e}}]}:{}}function Oi(e,t){let n=e=>({type:`text`,text:t?`\`\`\`\n${e}\n\`\`\``:e});switch(e.type){case`text`:{let n=e.text;return{type:`text`,text:t?`\`\`\`\n${n}\n\`\`\``:n}}case`image`:{let t=e.source;return t?.type===`base64`?{type:`image`,data:t.data,mimeType:t.media_type}:n(t?.type===`url`?`[image: ${t.url}]`:`[image: file reference]`)}case`resource_link`:{let t=e.uri;return{type:`resource_link`,uri:t,name:e.name??t,mimeType:e.mimeType}}case`resource`:{let t=e.resource;return{type:`resource`,resource:{uri:t?.uri??``,mimeType:t?.mimeType,...typeof t?.text==`string`?{text:t.text}:{},...typeof t?.blob==`string`?{blob:t.blob}:{}}}}case`tool_reference`:return n(`Tool: ${e.tool_name}`);case`tool_search_tool_search_result`:{let t=e.tool_references;return n(`Tools found: ${t?.map(e=>e.tool_name).join(`, `)||`none`}`)}case`tool_search_tool_result_error`:return n(`Error: ${e.error_code}${e.error_message?` - ${e.error_message}`:``}`);case`web_fetch_result`:return n(`Fetched: ${e.url}`);case`web_fetch_tool_result_error`:return n(`Error: ${e.error_code}`);case`code_execution_result`:case`bash_code_execution_result`:return n(`Output: ${e.stdout||e.stderr||``}`);case`code_execution_tool_result_error`:case`bash_code_execution_tool_result_error`:return n(`Error: ${e.error_code}`);case`text_editor_code_execution_view_result`:return n(e.content);case`text_editor_code_execution_create_result`:return n(e.is_file_update?`File updated`:`File created`);case`text_editor_code_execution_str_replace_result`:{let t=e.lines;return n(t?.join(`
|
|
6
|
+
`)||``)}case`text_editor_code_execution_tool_result_error`:return n(`Error: ${e.error_code}${e.error_message?` - ${e.error_message}`:``}`);default:try{return{type:`text`,text:JSON.stringify(e)}}catch{return{type:`text`,text:`[content]`}}}}function ki(e,t,n=!1){if(!t)return{};let r=e.is_error===!0,i=e.content;if(r&&i)return Di(i,!0);switch(t.name){case`Read`:return typeof i==`string`&&i.length>0?{content:[{type:`content`,content:{type:`text`,text:Ei(i)}}]}:Array.isArray(i)&&i.length>0?{content:i.map(e=>({type:`content`,content:e.type===`text`?{type:`text`,text:Ei(e.text)}:Oi(e,!1)}))}:{};case`Bash`:{let e=``;if(i&&typeof i==`object`&&!Array.isArray(i)&&i.type===`bash_code_execution_result`){let t=i;e=[t.stdout,t.stderr].filter(Boolean).join(`
|
|
7
|
+
`)}else typeof i==`string`?e=i:Array.isArray(i)&&i.length>0&&(e=i.map(e=>e.type===`text`?e.text:``).join(`
|
|
8
|
+
`));return e.trim()?{content:[{type:`content`,content:{type:`text`,text:`\`\`\`console\n${e.trimEnd()}\n\`\`\``}}]}:{}}case`Edit`:case`Write`:return{};case`ExitPlanMode`:return{title:`Exited Plan Mode`};default:return Di(i??``,r)}}function Ai(e){return e===`in_progress`?`in_progress`:e===`completed`?`completed`:`pending`}function X(e,t,n,r,i,a,o){let s=[];for(let i of e){let e=i.type,a=null;switch(e){case`text`:case`text_delta`:{let e=i.text??``;a={sessionUpdate:t===`assistant`?`agent_message_chunk`:`user_message_chunk`,...o?.messageId?{messageId:o.messageId}:{},content:{type:`text`,text:e}};break}case`thinking`:case`thinking_delta`:{let e=i.thinking??``;a={sessionUpdate:`agent_thought_chunk`,...o?.messageId?{messageId:o.messageId}:{},content:{type:`text`,text:e}};break}case`image`:{let e=i.source;e?.type===`base64`&&(a={sessionUpdate:t===`assistant`?`agent_message_chunk`:`user_message_chunk`,...o?.messageId?{messageId:o.messageId}:{},content:{type:`image`,data:e.data,mimeType:e.media_type}});break}case`tool_use`:case`server_tool_use`:case`mcp_tool_use`:{let t=i.id??``,n=i.name??`unknown`,s=i.input,c=t in r;if(r[t]={type:e,id:t,name:n,input:s},n===`TodoWrite`){let e=s?.todos;Array.isArray(e)&&(a={sessionUpdate:`plan`,entries:e.map(e=>({content:e.content,status:Ai(e.status),priority:`medium`}))})}else{let e=s?{...s}:{};a=c?{_meta:{claudeCode:{toolName:n}},toolCallId:t,sessionUpdate:`tool_call_update`,status:`in_progress`,rawInput:e,...Y({name:n,id:t,input:s??{}},!1,o?.cwd)}:{_meta:{claudeCode:{toolName:n}},toolCallId:t,sessionUpdate:`tool_call`,rawInput:e,status:`pending`,...Y({name:n,id:t,input:s??{}},!1,o?.cwd)}}break}case`tool_result`:case`mcp_tool_result`:{let e=i.tool_use_id??``,t=r[e];if(!t)break;if(t.name!==`TodoWrite`){let n=ki(i,{name:t.name,id:t.id},!1);a={_meta:{claudeCode:{toolName:t.name}},toolCallId:e,sessionUpdate:`tool_call_update`,status:i.is_error===!0?`failed`:`completed`,rawOutput:i.content,...n}}break}case`redacted_thinking`:case`input_json_delta`:case`citations_delta`:case`signature_delta`:case`container_upload`:case`compaction`:case`compaction_delta`:break}if(a){if(o?.parentToolUseId){let e=a._meta;a._meta={...e,claudeCode:{...e?.claudeCode??{},parentToolUseId:o.parentToolUseId}}}s.push({sessionId:n,update:a})}}return s}function ji(e,t,n,r,i){let a=e.message;if(!a)return[];let o=a.content;if(!o)return[];if(typeof o==`string`)return[{sessionId:t,update:{sessionUpdate:`agent_message_chunk`,...i?.messageId?{messageId:i.messageId}:{},content:{type:`text`,text:o}}}];let s=i?.streamingActive?o.filter(e=>e.type!==`text`&&e.type!==`thinking`):o;return s.length===0?[]:X(s,`assistant`,t,n,r,void 0,i)}function Mi(e,t,n,r,i){let a=e.event;if(!a)return[];switch(a.type){case`content_block_start`:{let o=a.content_block;return o?X([o],`assistant`,t,n,r,void 0,{clientCapabilities:i?.clientCapabilities,parentToolUseId:e.parent_tool_use_id,cwd:i?.cwd,messageId:i?.messageId}):[]}case`content_block_delta`:{let o=a.delta;return o?X([o],`assistant`,t,n,r,void 0,{clientCapabilities:i?.clientCapabilities,parentToolUseId:e.parent_tool_use_id,cwd:i?.cwd,messageId:i?.messageId}):[]}case`message_start`:case`message_delta`:case`message_stop`:case`content_block_stop`:return[];default:return[]}}function Ni(e,t){let n=0,r=Math.min(e.length,t.length);for(;n<r&&e[n]===t[n];)n++;return n}function Pi(e,t){let n=null,r=0;for(let i of Object.keys(e)){let e=Ni(i,t);e>r&&(r=e,n=i)}return n?e[n]??null:null}var Fi=console;function Ii(e,t){if(t.aborted)return Promise.resolve({done:!0,value:void 0});let n,r=new Promise(e=>{n=()=>e({done:!0,value:void 0}),t.addEventListener(`abort`,n,{once:!0})});return Promise.race([e.next(),r]).finally(()=>{n&&t.removeEventListener(`abort`,n)})}async function Li(e,t,n,r,i,a,o,s){let c=`end_turn`,l={inputTokens:0,outputTokens:0,cachedReadTokens:0,cachedWriteTokens:0},u=null,d=null,f=2e5,p=!1,m=null;try{for(;!r.aborted;){let s=await Ii(t,r);if(s.done||r.aborted)break;let h=s.value;if(h==null)continue;let g=h;switch(g.type){case`system`:g.subtype===`compact_boundary`&&(u=0,await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`agent_message_chunk`,content:{type:`text`,text:`
|
|
9
|
+
|
|
10
|
+
Compacting completed.`}}}));break;case`result`:{let t=g.usage;t&&(l.inputTokens+=t.input_tokens??0,l.outputTokens+=t.output_tokens??0,l.cachedReadTokens+=t.cache_read_input_tokens??0,l.cachedWriteTokens+=t.cache_creation_input_tokens??0);let i=g.modelUsage;if(i&&d){let e=Pi(i,d);e?.contextWindow&&(f=e.contextWindow)}u!==null&&await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`usage_update`,used:u,size:f}});let a=g.subtype,o=g.is_error;if(r.aborted){c=`cancelled`;break}switch(a){case`success`:{let e=g.stop_reason;c=e===`max_tokens`?`max_tokens`:e===`refusal`?`refusal`:`end_turn`,o&&(c=`end_turn`);break}case`error_during_execution`:c=g.stop_reason===`max_tokens`?`max_tokens`:`end_turn`;break;case`error_max_budget_usd`:case`error_max_turns`:case`error_max_structured_output_retries`:c=`max_turn_requests`;break}break}case`stream_event`:{let t=g.parent_tool_use_id;t===null&&m===null&&(m=M());let r=Mi(g,e,i,n,{clientCapabilities:a,cwd:o,messageId:t===null?m??void 0:void 0});for(let e of r)await n.sessionUpdate(e);p=!0;break}case`assistant`:{let t=g.message,r=g.parent_tool_use_id;if(t?.usage&&r===null){let e=t.usage;u=(typeof e.input_tokens==`number`?e.input_tokens:0)+(typeof e.output_tokens==`number`?e.output_tokens:0)+(typeof e.cache_read_input_tokens==`number`?e.cache_read_input_tokens:0)+(typeof e.cache_creation_input_tokens==`number`?e.cache_creation_input_tokens:0)}r===null&&t?.model&&t.model!==`<synthetic>`&&(d=t.model);let s;r===null&&(m===null&&(m=M()),s=m);let c=ji(g,e,i,n,{clientCapabilities:a,cwd:o,parentToolUseId:r,streamingActive:p,messageId:s});for(let e of c)await n.sessionUpdate(e);r===null&&(m=null);break}case`user`:break;case`progress`:{let t=g.data;if(!t)break;let r=t.type;if(r===`agent_progress`||r===`skill_progress`){let r=t.message;if(r){let t=r.content;if(t)for(let r of t)r.type===`text`&&await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`agent_message_chunk`,content:{type:`text`,text:r.text}}})}}break}case`tool_use_summary`:break;case`attachment`:break;case`compact_boundary`:u=0,await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`agent_message_chunk`,content:{type:`text`,text:`
|
|
11
|
+
|
|
12
|
+
Compacting completed.`}}});break;default:Fi.debug(`Ignoring unknown SDK message type`);break}}if(r.aborted||s?.())return{stopReason:`cancelled`,usage:l}}catch(e){if(r.aborted)return{stopReason:`cancelled`,usage:l};throw e}return{stopReason:c,usage:l}}async function Ri(e,t,n,r,i,a){for(let o of t){let t=o;if(t.type!==`user`&&t.type!==`assistant`){Fi.debug(`Ignoring unknown SDK message type`);continue}if(t.isMeta===!0)continue;let s=t.message?.content;if(!s)continue;let c=t.type===`assistant`?`assistant`:`user`;if(typeof s==`string`){if(!s.trim())continue;let t=M();await n.sessionUpdate({sessionId:e,update:{sessionUpdate:c===`assistant`?`agent_message_chunk`:`user_message_chunk`,...t?{messageId:t}:{},content:{type:`text`,text:s}}});continue}if(Array.isArray(s)){let t=X(s,c,e,r,n,void 0,{clientCapabilities:i,cwd:a,messageId:M()});for(let e of t)await n.sessionUpdate(e)}}}function zi(e,t,n,i,a,o,s,c){return async(n,l,u,d,f,p)=>{let m=Vi(i);if(n.name===`ExitPlanMode`)return Bi(e,t,f,l,m,a,o,s,c);if(p!==void 0)return p;try{let e=await r(n,l,u,d,f);if(e.behavior===`allow`||e.behavior===`deny`)return e}catch(e){return console.error(`[ACP Permissions] Pipeline error:`,e),{behavior:`deny`,message:`Permission pipeline failed`,decisionReason:{type:`other`,reason:`Permission pipeline failed`},toolUseID:f}}let h=Y({name:n.name,id:f,input:l},m,a),g={toolCallId:f,title:h.title,kind:h.kind,status:`pending`,rawInput:l},_=[{kind:`allow_always`,name:`Always Allow`,optionId:`allow_always`},{kind:`allow_once`,name:`Allow`,optionId:`allow`},{kind:`reject_once`,name:`Reject`,optionId:`reject`},{kind:`reject_always`,name:`Always Reject`,optionId:`reject_always`}];try{let n=await e.requestPermission({sessionId:t,toolCall:g,options:_});if(n.outcome.outcome===`cancelled`)return c?.(),{behavior:`deny`,message:`Permission request cancelled by client`,decisionReason:{type:`mode`,mode:`default`},toolUseID:f};if(n.outcome.outcome===`selected`&&`optionId`in n.outcome&&n.outcome.optionId!==void 0){let e=n.outcome.optionId;if(e===`allow`||e===`allow_always`)return{behavior:`allow`,updatedInput:l}}return{behavior:`deny`,message:`Permission denied by client`,decisionReason:{type:`mode`,mode:`default`}}}catch(e){return console.error(`[ACP Permissions] Client request error:`,e),{behavior:`deny`,message:`Permission request failed`,decisionReason:{type:`mode`,mode:`default`}}}}}async function Bi(e,t,n,r,i,a,o,s,c){let l=[{kind:`allow_always`,name:`Yes, and use "auto" mode`,optionId:`auto`},{kind:`allow_always`,name:`Yes, and auto-accept edits`,optionId:`acceptEdits`},{kind:`allow_once`,name:`Yes, and manually approve edits`,optionId:`default`},{kind:`reject_once`,name:`No, keep planning`,optionId:`plan`}];s?.()===!0&&l.unshift({kind:`allow_always`,name:`Yes, and bypass permissions`,optionId:`bypassPermissions`});let u=Y({name:`ExitPlanMode`,id:n,input:r},i,a),d={toolCallId:n,title:u.title,kind:u.kind,status:`pending`,rawInput:r},f=await e.requestPermission({sessionId:t,toolCall:d,options:l});if(f.outcome.outcome===`cancelled`)return c?.(),{behavior:`deny`,message:`Tool use aborted`,decisionReason:{type:`mode`,mode:`default`}};if(f.outcome.outcome===`selected`&&`optionId`in f.outcome&&f.outcome.optionId!==void 0){let n=f.outcome.optionId;if(l.some(e=>e.optionId===n)&&(n==="default"||n===`acceptEdits`||n===`auto`||n===`bypassPermissions`))return o?.(n),await e.sessionUpdate({sessionId:t,update:{sessionUpdate:`current_mode_update`,currentModeId:n}}),{behavior:`allow`,updatedInput:r}}return{behavior:`deny`,message:`User rejected request to exit plan mode.`,decisionReason:{type:`mode`,mode:`plan`}}}function Vi(e){if(!e)return!1;if(e.terminal===!0)return!0;let t=e._meta;return!t||typeof t!=`object`?!1:t.terminal_output===!0}pe(),be(),o(),ue(),e(),_();var Z=class{constructor(e){t(this,`conn`,void 0),t(this,`sessions`,new Map),t(this,`clientCapabilities`,void 0),this.conn=e}async initialize(e){return this.clientCapabilities=e.clientCapabilities,{protocolVersion:1,authMethods:[],agentInfo:{name:`workmate`,title:`Work Mate`,version:typeof globalThis.MACRO==`object`&&globalThis.MACRO!==null?String(globalThis.MACRO.VERSION??`0.0.0`):`0.0.0`},agentCapabilities:{_meta:{claudeCode:{promptQueueing:!0,forkSession:!0}},promptCapabilities:{image:!1,embeddedContext:!0},mcpCapabilities:{http:!0,sse:!0},loadSession:!0,sessionCapabilities:{list:{},resume:{},close:{},delete:{}}}}}async authenticate(e){return{}}async newSession(e){let t=await this.createSession(e);return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async unstable_resumeSession(e){let t=await this.getOrCreateSession({...e,replay:!1});return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async loadSession(e){let t=await this.getOrCreateSession(e);return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async listSessions(e){if(e.cursor!==void 0&&e.cursor!==null)throw Error(`Pagination cursor not supported: listSessions returns all results in a single page.`);let t=e.cwd||ne(),n=await le(t),r=await s({dir:t}),i=[];for(let e of r){if(!e.cwd||await le(e.cwd)!==n)continue;let t=wi(e.summary??``);i.push({sessionId:e.sessionId,cwd:e.cwd,...t?{title:t}:{},updatedAt:new Date(e.lastModified).toISOString()})}return{sessions:i}}async unstable_forkSession(e){let{initialMessages:t}=await Hi(e.sessionId),n=await this.createSession({cwd:e.cwd,mcpServers:e.mcpServers??[],_meta:e._meta},{initialMessages:t});return this.scheduleAvailableCommandsUpdate(n.sessionId),n}async unstable_closeSession(e){if(!this.sessions.get(e.sessionId))throw Error(`Session not found`);return await this.teardownSession(e.sessionId),{}}async unstable_deleteSession(e){let t=await oe(e.sessionId);if(t)try{await Ee(t.filePath)}catch(e){if(e.code!==`ENOENT`)throw e}return this.sessions.has(e.sessionId)&&await this.teardownSession(e.sessionId),{}}async extMethod(e,t){if(e===`session/delete`){let e=t.sessionId;if(typeof e!=`string`||e.length===0)throw Error(`session/delete requires a non-empty sessionId`);return this.unstable_deleteSession({sessionId:e})}throw q.methodNotFound(e)}async cancel(e){let t=this.sessions.get(e.sessionId);if(t){t.cancelled=!0,t.cancelGeneration+=1;for(let[,e]of t.pendingMessages)e.resolve(!0);t.pendingMessages.clear(),t.pendingQueue=[],t.pendingQueueHead=0,t.queryEngine.interrupt()}}async setSessionMode(e){if(!this.sessions.get(e.sessionId))throw Error(`Session not found`);return this.applySessionMode(e.sessionId,e.modeId),await this.conn.sessionUpdate({sessionId:e.sessionId,update:{sessionUpdate:`current_mode_update`,currentModeId:e.modeId}}),await this.updateConfigOption(e.sessionId,`mode`,e.modeId),{}}async unstable_setSessionModel(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session not found`);return t.queryEngine.setModel(e.modelId),await this.updateConfigOption(e.sessionId,`model`,e.modelId),{}}async sendAvailableCommandsUpdate(e){let t=this.sessions.get(e);if(!t)return;let n=t.commands.filter(e=>e.type===`prompt`&&!e.isHidden&&e.userInvocable!==!1).map(e=>({name:e.name,description:e.description,input:e.argumentHint?{hint:e.argumentHint}:void 0}));await this.conn.sessionUpdate({sessionId:e,update:{sessionUpdate:`available_commands_update`,availableCommands:n}})}scheduleAvailableCommandsUpdate(e){setTimeout(()=>{this.sendAvailableCommandsUpdate(e).catch(e=>{console.error(`[ACP] Failed to send available commands update:`,e)})},0)}};async function Hi(e){let t;try{let n=await p(e);n&&n.messages.length>0&&(t=_e(n.messages))}catch(e){console.error(`[ACP] fork source load failed:`,e)}return{initialMessages:t}}var Ui=[`auto`,`default`,`acceptEdits`,`bypassPermissions`,`dontAsk`,`plan`];function Wi(e){return Ui.includes(e)}function Gi(e,t,n){if(t){let t=Ki(e,`_meta.permissionMode`);if(t===`bypassPermissions`&&!Yi())throw Error(`Mode not available: bypassPermissions cannot run as root (start the agent as a non-root user, or set IS_SANDBOX=1).`);return t}return qi(n)??`default`}function Ki(e,t){if(e==null)throw Error(`Invalid ${t}: expected a string.`);return xi(e,t)}function qi(e){if(e!=null)try{return xi(e,`permissions.defaultMode`)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[ACP] Invalid permissions.defaultMode, using default:`,t);return}}function Ji(e,t){return!!e&&Object.hasOwn(e,t)}function Yi(){return Xi()}function Xi(){return process.env.IS_SANDBOX?!0:typeof process.geteuid==`function`?process.geteuid()!==0:typeof process.getuid!=`function`||process.getuid()!==0}function Zi(e,t){return[{id:`mode`,name:`Mode`,description:`Session permission mode`,category:`mode`,type:`select`,currentValue:e.currentModeId,options:e.availableModes.map(e=>({value:e.id,name:e.name,description:e.description}))},{id:`model`,name:`Model`,description:`AI model to use`,category:`model`,type:`select`,currentValue:t.currentModelId,options:t.availableModels.map(e=>({value:e.modelId,name:e.name,description:e.description??void 0}))}]}function Qi(e){let t=[];if(!Array.isArray(e))return t;for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;if(Array.isArray(e.options))for(let n of e.options)n&&typeof n==`object`&&typeof n.value==`string`&&t.push(n.value);else typeof n.value==`string`&&t.push(n.value)}return t}function Q(e){return e.conn}function $(e){return e.clientCapabilities}function $i(e,t,n,r){n===`mode`?t.modes={...t.modes,currentModeId:r}:n===`model`&&(t.models={...t.models,currentModelId:r})}j();function ea(){return se().permissions?.defaultMode}async function ta(e,t={}){fe();let n=t.sessionId??M(),r=e.cwd;A(n,ie()),k(r);let i=process.cwd(),o=!1;try{process.chdir(r),o=!0}catch{}ae(),xe();try{let i=he(),o=u(i),s=e._meta,l=Ji(s,`permissionMode`),d=Gi(l?s?.permissionMode:void 0,l,ea()),p=$(this),h=this.conn,g=zi(h,n,()=>this.sessions.get(n)?.modes.currentModeId??`default`,p,r,e=>{this.applySessionMode(n,e)},()=>this.sessions.get(n)?.appState.toolPermissionContext.isBypassPermissionsModeAvailable??!1),_=Yi(),v={...c(),toolPermissionContext:{...i,mode:d,isBypassPermissionsModeAvailable:_}},[y,b]=await Promise.all([m(r),f(r)]);v.agentDefinitions=b;let x=new ve({cwd:r,tools:o,commands:y,mcpClients:[],agents:b.activeAgents,canUseTool:g,getAppState:()=>v,setAppState:e=>{let t=e(v);Object.assign(v,t)},readFileCache:new a(500,50*1024*1024),includePartialMessages:!0,replayUserMessages:!0,initialMessages:t.initialMessages}),S={currentModeId:d,availableModes:[{id:`default`,name:`Default`,description:`Standard behavior, prompts for dangerous operations`},{id:`acceptEdits`,name:`Accept Edits`,description:`Auto-accept file edit operations`},{id:`plan`,name:`Plan Mode`,description:`Planning mode, no actual tool execution`},{id:`auto`,name:`Auto`,description:`Use a model classifier to approve/deny permission prompts.`},..._?[{id:`bypassPermissions`,name:`Bypass Permissions`,description:`Skip all permission checks`}]:[],{id:`dontAsk`,name:`Don't Ask`,description:`Don't prompt for permissions, deny if not pre-approved`}]},C=ye(),w=me(),T={availableModels:C.map(e=>({modelId:String(e.value??``),name:e.label??String(e.value??``),description:e.description??void 0})),currentModelId:w};x.setModel(w);let E=Zi(S,T),D={queryEngine:x,cancelled:!1,cancelGeneration:0,cwd:r,modes:S,models:T,configOptions:E,promptRunning:!1,pendingMessages:new Map,pendingQueue:[],pendingQueueHead:0,toolUseCache:{},clientCapabilities:p,appState:v,commands:y,sessionFingerprint:Si({cwd:r,mcpServers:e.mcpServers})};return this.sessions.set(n,D),{sessionId:n,modes:S,models:T,configOptions:E}}finally{o&&process.chdir(i)}}Object.assign(Z.prototype,{createSession:ta}),_(),j(),ue();async function na(e){let t=e.replay!==!1,n=this.sessions.get(e.sessionId);if(n){if(Si({cwd:e.cwd,mcpServers:e.mcpServers})===n.sessionFingerprint){let r=await oe(e.sessionId,e.cwd);return A(e.sessionId,r?Ce(r.filePath):null),k(e.cwd),t&&await this.replaySessionHistory(e),{sessionId:e.sessionId,modes:n.modes,models:n.models,configOptions:n.configOptions}}await this.teardownSession(e.sessionId)}let r=await oe(e.sessionId,e.cwd),i=r?Ce(r.filePath):null;A(e.sessionId,i),k(e.cwd);let a;if(r)try{let t=await p(e.sessionId);t&&t.messages.length>0&&(a=_e(t.messages))}catch(e){console.error(`[ACP] Failed to load session history:`,e)}let o=await this.createSession({cwd:e.cwd,mcpServers:e.mcpServers??[],_meta:e._meta},{sessionId:e.sessionId,initialMessages:a});if(t&&a&&a.length>0){let t=this.sessions.get(e.sessionId);t&&await Ri(e.sessionId,a,Q(this),t.toolUseCache,$(this),t.cwd)}return{sessionId:o.sessionId,modes:o.modes,models:o.models,configOptions:o.configOptions}}async function ra(e){this.sessions.get(e)&&(await this.cancel({sessionId:e}),this.sessions.delete(e))}async function ia(e){try{let t=await p(e.sessionId);if(!t||t.messages.length===0)return;let n=_e(t.messages);if(n.length===0)return;let r=this.sessions.get(e.sessionId);if(!r)return;await Ri(e.sessionId,n,Q(this),r.toolUseCache,$(this),r.cwd)}catch(e){console.error(`[ACP] Failed to replay session history:`,e)}}function aa(e,t){if(!Wi(t))throw Error(`Invalid mode: ${t}`);let n=this.sessions.get(e);if(n){if(t===`bypassPermissions`&&!n.appState.toolPermissionContext.isBypassPermissionsModeAvailable||!n.modes.availableModes.some(e=>e.id===t))throw Error(`Mode not available: ${t}`);n.modes={...n.modes,currentModeId:t},n.appState.toolPermissionContext={...n.appState.toolPermissionContext,mode:t}}}async function oa(e,t,n){let r=this.sessions.get(e);r&&($i(this,r,t,n),r.configOptions=r.configOptions.map(e=>e.id===t&&typeof e.currentValue==`string`?{...e,currentValue:n}:e),await Q(this).sessionUpdate({sessionId:e,update:{sessionUpdate:`config_option_update`,configOptions:r.configOptions}}))}Object.assign(Z.prototype,{getOrCreateSession:na,teardownSession:ra,replaySessionHistory:ia,applySessionMode:aa,updateConfigOption:oa});function sa(e){if(!e||e.length===0)return``;let t=[];for(let n of e){let e=n;if(e.type===`text`)t.push(String(e.text??``));else if(e.type===`resource_link`){let n=typeof e.name==`string`?e.name:void 0,r=typeof e.uri==`string`?e.uri:void 0;t.push(ca(n,r))}else if(e.type===`resource`){let n=e.resource;if(n&&typeof n.text==`string`)t.push(n.text);else if(n&&typeof n.blob==`string`){let e=typeof n.mimeType==`string`?n.mimeType:`application/octet-stream`,r=typeof n.uri==`string`?n.uri:`(unknown uri)`;t.push(`Embedded resource: ${r} (${e}, base64 blob, ${n.blob.length} chars)`)}}}return t.filter(e=>e.length>0).join(`
|
|
13
|
+
`)}function ca(e,t){let n=[];return e&&e.length>0&&n.push(`name=${e}`),t&&t.length>0&&n.push(`uri=${t}`),n.length>0?`Resource link: ${n.join(`, `)}`:`Resource link`}function la(e){for(;e.pendingQueueHead<e.pendingQueue.length;){let t=e.pendingQueue[e.pendingQueueHead++];if(!t)continue;let n=e.pendingMessages.get(t);if(n)return e.pendingMessages.delete(t),ua(e),n}ua(e)}function ua(e){if(e.pendingQueueHead!==0){if(e.pendingQueueHead>=e.pendingQueue.length){e.pendingQueue=[],e.pendingQueueHead=0;return}e.pendingQueueHead>1024&&e.pendingQueueHead*2>e.pendingQueue.length&&(e.pendingQueue=e.pendingQueue.slice(e.pendingQueueHead),e.pendingQueueHead=0)}}j();async function da(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session ${e.sessionId} not found`);let n=e.messageId??void 0,r=sa(e.prompt);if(!r.trim())throw Error(`Prompt content is empty`);let i=t.cancelGeneration;if(t.promptRunning){let e=M();if(await new Promise(n=>{t.pendingQueue.push(e),t.pendingMessages.set(e,{resolve:n})}))return{stopReason:`cancelled`}}if(t.cancelGeneration!==i)return{stopReason:`cancelled`};t.cancelled=!1,t.promptRunning=!0;try{t.queryEngine.resetAbortController(),A(e.sessionId,ie());let i=t.queryEngine.submitMessage(r),{stopReason:a,usage:o}=await Li(e.sessionId,i,Q(this),t.queryEngine.getAbortSignal(),t.toolUseCache,$(this),t.cwd,()=>t.cancelled);if(t.cancelled)return{stopReason:`cancelled`};if(await pa(this,e.sessionId,r),o){let e={inputTokens:o.inputTokens,outputTokens:o.outputTokens,cachedReadTokens:o.cachedReadTokens,cachedWriteTokens:o.cachedWriteTokens,thoughtTokens:0,totalTokens:o.inputTokens+o.outputTokens+o.cachedReadTokens+o.cachedWriteTokens+0};return{stopReason:a,usage:e,...n?{userMessageId:n}:{},_meta:{claudeCode:{usage:e}}}}return{stopReason:a,...n?{userMessageId:n}:{}}}catch(n){let r=n instanceof Error&&(n.name===`AbortError`||/abort|cancelled|interrupt/i.test(n.message));if(t.cancelled||r)return{stopReason:`cancelled`};throw n instanceof Error&&(n.message.includes(`terminated`)||n.message.includes(`process exited`))?(await this.teardownSession(e.sessionId),Error(`The Work Mate Agent process exited unexpectedly. Please start a new session.`)):n}finally{let e=la(t);e?(t.promptRunning=!0,e.resolve(!1)):t.promptRunning=!1}}async function fa(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session not found`);if(typeof e.value!=`string`)throw Error(`Invalid value for config option ${e.configId}: ${String(e.value)}`);let n=t.configOptions.find(t=>t.id===e.configId);if(!n)throw Error(`Unknown config option: ${e.configId}`);if(n.type===`select`){let t=Qi(n.options);if(!t.includes(e.value))throw Error(`Invalid value '${e.value}' for config option ${e.configId}; must be one of: ${t.join(`, `)}`)}let r=e.value;return e.configId===`mode`?(this.applySessionMode(e.sessionId,r),await Q(this).sessionUpdate({sessionId:e.sessionId,update:{sessionUpdate:`current_mode_update`,currentModeId:r}})):e.configId===`model`&&t.queryEngine.setModel(r),$i(this,t,e.configId,r),t.configOptions=t.configOptions.map(t=>t.id===e.configId&&typeof t.currentValue==`string`?{...t,currentValue:r}:t),{configOptions:t.configOptions}}async function pa(e,t,n){let r=e.sessions.get(t);if(!r)return;let i=r.toolUseCache;if(i.__sessionInfoTitleSent)return;i.__sessionInfoTitleSent=!0;let a=wi(n).slice(0,100);try{await Q(e).sessionUpdate({sessionId:t,update:{sessionUpdate:`session_info_update`,...a?{title:a}:{},updatedAt:new Date().toISOString()}})}catch(e){console.error(`[ACP] Failed to send session_info_update:`,e)}}Object.assign(Z.prototype,{prompt:da,setSessionConfigOption:fa}),de(),Se();function ma(e,t){let n=we.toWeb(e);return mi(Te.toWeb(t),n)}async function ha(){fe(),xe();let e=ma(process.stdin,process.stdout),t,n=new gi(e=>(t=new Z(e),t),e);console.log=console.error,console.info=console.error,console.warn=console.error,console.debug=console.error;async function r(){for(let[e]of t.sessions)try{await t.unstable_closeSession({sessionId:e})}catch{}process.exit(0)}n.closed.then(r).catch(r),process.on(`SIGTERM`,r),process.on(`SIGINT`,r),process.on(`unhandledRejection`,(e,t)=>{console.error(`Unhandled Rejection at:`,t,`reason:`,e)}),process.stdin.resume()}export{ha as runAcpAgent};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./defineProperty-C-QyHrDq.js";import{E as i,l as a,n as o,s,w as c}from"./esm-lWlUmoUA.js";import{F as ee,c as l,n as u,p as d,r as te,u as f}from"./esm-BbMeEYcz.js";import{n as ne,t as re}from"./esm-sVMjGuep.js";var p,m=e((()=>{(function(e){e[e.DELTA=0]=`DELTA`,e[e.CUMULATIVE=1]=`CUMULATIVE`})(p||(p={}))})),h,g,_=e((()=>{(function(e){e.COUNTER=`COUNTER`,e.GAUGE=`GAUGE`,e.HISTOGRAM=`HISTOGRAM`,e.UP_DOWN_COUNTER=`UP_DOWN_COUNTER`,e.OBSERVABLE_COUNTER=`OBSERVABLE_COUNTER`,e.OBSERVABLE_GAUGE=`OBSERVABLE_GAUGE`,e.OBSERVABLE_UP_DOWN_COUNTER=`OBSERVABLE_UP_DOWN_COUNTER`})(h||(h={})),(function(e){e[e.HISTOGRAM=0]=`HISTOGRAM`,e[e.EXPONENTIAL_HISTOGRAM=1]=`EXPONENTIAL_HISTOGRAM`,e[e.GAUGE=2]=`GAUGE`,e[e.SUM=3]=`SUM`})(g||(g={}))}));function ie(e){let t=Object.keys(e);return t.length===0?``:(t=t.sort(),JSON.stringify(t.map(t=>[t,e[t]])))}function ae(e){return`${e.name}:${e.version??``}:${e.schemaUrl??``}`}function v(e,t){let n,r=new Promise(function(e,r){n=setTimeout(function(){r(new y(`Operation timed out.`))},t)});return Promise.race([e,r]).then(e=>(clearTimeout(n),e),e=>{throw clearTimeout(n),e})}function oe(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function se(e,t){let n=0,r=e.length-1,i=e.length;for(;r>=n;){let a=n+Math.trunc((r-n)/2);e[a]<t?n=a+1:(i=a,r=a-1)}return i}function ce(e,t){return e.toLowerCase()===t.toLowerCase()}var y,b=e((()=>{y=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}}})),x,S=e((()=>{(function(e){e[e.DROP=0]=`DROP`,e[e.SUM=1]=`SUM`,e[e.LAST_VALUE=2]=`LAST_VALUE`,e[e.HISTOGRAM=3]=`HISTOGRAM`,e[e.EXPONENTIAL_HISTOGRAM=4]=`EXPONENTIAL_HISTOGRAM`})(x||(x={}))})),le,ue=e((()=>{S(),n(),le=class{constructor(){r(this,`kind`,x.DROP)}createAccumulation(){}merge(e,t){}diff(e,t){}toMetricData(e,t,n,r){}}}));function de(e){let t=e.map(()=>0);return t.push(0),{buckets:{boundaries:e,counts:t},sum:0,count:0,hasMinMax:!1,min:1/0,max:-1/0}}var C,fe,pe=e((()=>{S(),_(),b(),n(),C=class{constructor(e,t,n=!0,i=de(t)){r(this,`startTime`,void 0),r(this,`_boundaries`,void 0),r(this,`_recordMinMax`,void 0),r(this,`_current`,void 0),this.startTime=e,this._boundaries=t,this._recordMinMax=n,this._current=i}record(e){if(Number.isNaN(e))return;this._current.count+=1,this._current.sum+=e,this._recordMinMax&&(this._current.min=Math.min(e,this._current.min),this._current.max=Math.max(e,this._current.max),this._current.hasMinMax=!0);let t=se(this._boundaries,e);this._current.buckets.counts[t]+=1}setStartTime(e){this.startTime=e}toPointValue(){return this._current}},fe=class{constructor(e,t){r(this,`kind`,x.HISTOGRAM),r(this,`_boundaries`,void 0),r(this,`_recordMinMax`,void 0),this._boundaries=e,this._recordMinMax=t}createAccumulation(e){return new C(e,this._boundaries,this._recordMinMax)}merge(e,t){let n=e.toPointValue(),r=t.toPointValue(),i=n.buckets.counts,a=r.buckets.counts,o=Array(i.length);for(let e=0;e<i.length;e++)o[e]=i[e]+a[e];let s=1/0,c=-1/0;return this._recordMinMax&&(n.hasMinMax&&r.hasMinMax?(s=Math.min(n.min,r.min),c=Math.max(n.max,r.max)):n.hasMinMax?(s=n.min,c=n.max):r.hasMinMax&&(s=r.min,c=r.max)),new C(e.startTime,n.buckets.boundaries,this._recordMinMax,{buckets:{boundaries:n.buckets.boundaries,counts:o},count:n.count+r.count,sum:n.sum+r.sum,hasMinMax:this._recordMinMax&&(n.hasMinMax||r.hasMinMax),min:s,max:c})}diff(e,t){let n=e.toPointValue(),r=t.toPointValue(),i=n.buckets.counts,a=r.buckets.counts,o=Array(i.length);for(let e=0;e<i.length;e++)o[e]=a[e]-i[e];return new C(t.startTime,n.buckets.boundaries,this._recordMinMax,{buckets:{boundaries:n.buckets.boundaries,counts:o},count:r.count-n.count,sum:r.sum-n.sum,hasMinMax:!1,min:1/0,max:-1/0})}toMetricData(e,t,n,r){return{descriptor:e,aggregationTemporality:t,dataPointType:g.HISTOGRAM,dataPoints:n.map(([t,n])=>{let i=n.toPointValue(),a=e.type===h.GAUGE||e.type===h.UP_DOWN_COUNTER||e.type===h.OBSERVABLE_GAUGE||e.type===h.OBSERVABLE_UP_DOWN_COUNTER;return{attributes:t,startTime:n.startTime,endTime:r,value:{min:i.hasMinMax?i.min:void 0,max:i.hasMinMax?i.max:void 0,sum:a?void 0:i.sum,buckets:i.buckets,count:i.count}}})}}}})),w,me,he=e((()=>{n(),w=class e{constructor(e=new me,t=0,n=0,i=0){r(this,`backing`,void 0),r(this,`indexBase`,void 0),r(this,`indexStart`,void 0),r(this,`indexEnd`,void 0),this.backing=e,this.indexBase=t,this.indexStart=n,this.indexEnd=i}get offset(){return this.indexStart}get length(){return this.backing.length===0||this.indexEnd===this.indexStart&&this.at(0)===0?0:this.indexEnd-this.indexStart+1}counts(){return Array.from({length:this.length},(e,t)=>this.at(t))}at(e){let t=this.indexBase-this.indexStart;return e<t&&(e+=this.backing.length),e-=t,this.backing.countAt(e)}incrementBucket(e,t){this.backing.increment(e,t)}decrementBucket(e,t){this.backing.decrement(e,t)}trim(){for(let e=0;e<this.length;e++)if(this.at(e)!==0){this.indexStart+=e;break}else if(e===this.length-1){this.indexStart=this.indexEnd=this.indexBase=0;return}for(let e=this.length-1;e>=0;e--)if(this.at(e)!==0){this.indexEnd-=this.length-e-1;break}this._rotate()}downscale(e){this._rotate();let t=1+this.indexEnd-this.indexStart,n=1<<e,r=0,i=0;for(let e=this.indexStart;e<=this.indexEnd;){let a=e%n;a<0&&(a+=n);for(let o=a;o<n&&r<t;o++)this._relocateBucket(i,r),r++,e++;i++}this.indexStart>>=e,this.indexEnd>>=e,this.indexBase=this.indexStart}clone(){return new e(this.backing.clone(),this.indexBase,this.indexStart,this.indexEnd)}_rotate(){let e=this.indexBase-this.indexStart;e!==0&&(e>0?(this.backing.reverse(0,this.backing.length),this.backing.reverse(0,e),this.backing.reverse(e,this.backing.length)):(this.backing.reverse(0,this.backing.length),this.backing.reverse(0,this.backing.length+e)),this.indexBase=this.indexStart)}_relocateBucket(e,t){e!==t&&this.incrementBucket(e,this.backing.emptyBucket(t))}},me=class e{constructor(e=[0]){r(this,`_counts`,void 0),this._counts=e}get length(){return this._counts.length}countAt(e){return this._counts[e]}growTo(e,t,n){let r=Array(e).fill(0);r.splice(n,this._counts.length-t,...this._counts.slice(t)),r.splice(0,t,...this._counts.slice(0,t)),this._counts=r}reverse(e,t){let n=Math.floor((e+t)/2)-e;for(let r=0;r<n;r++){let n=this._counts[e+r];this._counts[e+r]=this._counts[t-r-1],this._counts[t-r-1]=n}}emptyBucket(e){let t=this._counts[e];return this._counts[e]=0,t}increment(e,t){this._counts[e]+=t}decrement(e,t){this._counts[e]>=t?this._counts[e]-=t:this._counts[e]=0}clone(){return new e([...this._counts])}}}));function ge(e){let t=new DataView(new ArrayBuffer(8));return t.setFloat64(0,e),((t.getUint32(0)&ve)>>20)-be}function _e(e){let t=new DataView(new ArrayBuffer(8));t.setFloat64(0,e);let n=t.getUint32(0),r=t.getUint32(4);return(n&ye)*2**32+r}var ve,ye,be,xe,Se,T,Ce=e((()=>{ve=2146435072,ye=1048575,be=1023,xe=-1022,Se=be,T=2**-1022}));function E(e,t){return e===0||e===1/0||e===-1/0||Number.isNaN(e)?e:e*2**t}function we(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}var D=e((()=>{})),O,Te=e((()=>{O=class extends Error{}})),Ee,De=e((()=>{Ce(),D(),Te(),n(),Ee=class{constructor(e){r(this,`_shift`,void 0),this._shift=-e}mapToIndex(e){return e<T?this._minNormalLowerBoundaryIndex():ge(e)+this._rightShift(_e(e)-1,52)>>this._shift}lowerBoundary(e){let t=this._minNormalLowerBoundaryIndex();if(e<t)throw new O(`underflow: ${e} is < minimum lower boundary: ${t}`);let n=this._maxNormalLowerBoundaryIndex();if(e>n)throw new O(`overflow: ${e} is > maximum lower boundary: ${n}`);return E(1,e<<this._shift)}get scale(){return this._shift===0?0:-this._shift}_minNormalLowerBoundaryIndex(){let e=xe>>this._shift;return this._shift<2&&e--,e}_maxNormalLowerBoundaryIndex(){return Se>>this._shift}_rightShift(e,t){return Math.floor(e*2**-t)}}})),Oe,ke=e((()=>{Ce(),D(),Te(),n(),Oe=class{constructor(e){r(this,`_scale`,void 0),r(this,`_scaleFactor`,void 0),r(this,`_inverseFactor`,void 0),this._scale=e,this._scaleFactor=E(Math.LOG2E,e),this._inverseFactor=E(Math.LN2,-e)}mapToIndex(e){if(e<=T)return this._minNormalLowerBoundaryIndex()-1;if(_e(e)===0)return(ge(e)<<this._scale)-1;let t=Math.floor(Math.log(e)*this._scaleFactor),n=this._maxNormalLowerBoundaryIndex();return t>=n?n:t}lowerBoundary(e){let t=this._maxNormalLowerBoundaryIndex();if(e>=t){if(e===t)return 2*Math.exp((e-(1<<this._scale))/this._scaleFactor);throw new O(`overflow: ${e} is > maximum lower boundary: ${t}`)}let n=this._minNormalLowerBoundaryIndex();if(e<=n){if(e===n)return T;if(e===n-1)return Math.exp((e+(1<<this._scale))/this._scaleFactor)/2;throw new O(`overflow: ${e} is < minimum lower boundary: ${n}`)}return Math.exp(e*this._inverseFactor)}get scale(){return this._scale}_minNormalLowerBoundaryIndex(){return xe<<this._scale}_maxNormalLowerBoundaryIndex(){return(Se+1<<this._scale)-1}}}));function Ae(e){if(e>Me||e<je)throw new O(`expected scale >= ${je} && <= ${Me}, got: ${e}`);return Ne[e+10]}var je,Me,Ne,Pe=e((()=>{De(),ke(),Te(),je=-10,Me=20,Ne=Array.from({length:31},(e,t)=>t>10?new Oe(t-10):new Ee(t-10))})),k,Fe,Ie,A,Le,Re,ze=e((()=>{S(),_(),o(),he(),Pe(),D(),n(),k=class e{static combine(t,n){return new e(Math.min(t.low,n.low),Math.max(t.high,n.high))}constructor(e,t){r(this,`low`,void 0),r(this,`high`,void 0),this.low=e,this.high=t}},Fe=20,Ie=160,A=2,Le=class e{constructor(e,t=Ie,n=!0,i=0,a=0,o=0,c=1/0,ee=-1/0,l=new w,u=new w,d=Ae(Fe)){r(this,`startTime`,void 0),r(this,`_maxSize`,void 0),r(this,`_recordMinMax`,void 0),r(this,`_sum`,void 0),r(this,`_count`,void 0),r(this,`_zeroCount`,void 0),r(this,`_min`,void 0),r(this,`_max`,void 0),r(this,`_positive`,void 0),r(this,`_negative`,void 0),r(this,`_mapping`,void 0),this.startTime=e,this._maxSize=t,this._recordMinMax=n,this._sum=i,this._count=a,this._zeroCount=o,this._min=c,this._max=ee,this._positive=l,this._negative=u,this._mapping=d,this._maxSize<A&&(s.warn(`Exponential Histogram Max Size set to ${this._maxSize}, \
|
|
2
|
+
changing to the minimum size of: ${A}`),this._maxSize=A)}record(e){this.updateByIncrement(e,1)}setStartTime(e){this.startTime=e}toPointValue(){return{hasMinMax:this._recordMinMax,min:this.min,max:this.max,sum:this.sum,positive:{offset:this.positive.offset,bucketCounts:this.positive.counts()},negative:{offset:this.negative.offset,bucketCounts:this.negative.counts()},count:this.count,scale:this.scale,zeroCount:this.zeroCount}}get sum(){return this._sum}get min(){return this._min}get max(){return this._max}get count(){return this._count}get zeroCount(){return this._zeroCount}get scale(){return this._count===this._zeroCount?0:this._mapping.scale}get positive(){return this._positive}get negative(){return this._negative}updateByIncrement(e,t){if(!Number.isNaN(e)){if(e>this._max&&(this._max=e),e<this._min&&(this._min=e),this._count+=t,e===0){this._zeroCount+=t;return}this._sum+=e*t,e>0?this._updateBuckets(this._positive,e,t):this._updateBuckets(this._negative,-e,t)}}merge(e){this._count===0?(this._min=e.min,this._max=e.max):e.count!==0&&(e.min<this.min&&(this._min=e.min),e.max>this.max&&(this._max=e.max)),this.startTime=e.startTime,this._sum+=e.sum,this._count+=e.count,this._zeroCount+=e.zeroCount;let t=this._minScale(e);this._downscale(this.scale-t),this._mergeBuckets(this.positive,e,e.positive,t),this._mergeBuckets(this.negative,e,e.negative,t)}diff(e){this._min=1/0,this._max=-1/0,this._sum-=e.sum,this._count-=e.count,this._zeroCount-=e.zeroCount;let t=this._minScale(e);this._downscale(this.scale-t),this._diffBuckets(this.positive,e,e.positive,t),this._diffBuckets(this.negative,e,e.negative,t)}clone(){return new e(this.startTime,this._maxSize,this._recordMinMax,this._sum,this._count,this._zeroCount,this._min,this._max,this.positive.clone(),this.negative.clone(),this._mapping)}_updateBuckets(e,t,n){let r=this._mapping.mapToIndex(t),i=!1,a=0,o=0;if(e.length===0?(e.indexStart=r,e.indexEnd=e.indexStart,e.indexBase=e.indexStart):r<e.indexStart&&e.indexEnd-r>=this._maxSize?(i=!0,o=r,a=e.indexEnd):r>e.indexEnd&&r-e.indexStart>=this._maxSize&&(i=!0,o=e.indexStart,a=r),i){let e=this._changeScale(a,o);this._downscale(e),r=this._mapping.mapToIndex(t)}this._incrementIndexBy(e,r,n)}_incrementIndexBy(e,t,n){if(n===0)return;if(e.length===0&&(e.indexStart=e.indexEnd=e.indexBase=t),t<e.indexStart){let n=e.indexEnd-t;n>=e.backing.length&&this._grow(e,n+1),e.indexStart=t}else if(t>e.indexEnd){let n=t-e.indexStart;n>=e.backing.length&&this._grow(e,n+1),e.indexEnd=t}let r=t-e.indexBase;r<0&&(r+=e.backing.length),e.incrementBucket(r,n)}_grow(e,t){let n=e.backing.length,r=e.indexBase-e.indexStart,i=n-r,a=we(t);a>this._maxSize&&(a=this._maxSize);let o=a-r;e.backing.growTo(a,i,o)}_changeScale(e,t){let n=0;for(;e-t>=this._maxSize;)e>>=1,t>>=1,n++;return n}_downscale(e){if(e===0)return;if(e<0)throw Error(`impossible change of scale: ${this.scale}`);let t=this._mapping.scale-e;this._positive.downscale(e),this._negative.downscale(e),this._mapping=Ae(t)}_minScale(e){let t=Math.min(this.scale,e.scale),n=k.combine(this._highLowAtScale(this.positive,this.scale,t),this._highLowAtScale(e.positive,e.scale,t)),r=k.combine(this._highLowAtScale(this.negative,this.scale,t),this._highLowAtScale(e.negative,e.scale,t));return Math.min(t-this._changeScale(n.high,n.low),t-this._changeScale(r.high,r.low))}_highLowAtScale(e,t,n){if(e.length===0)return new k(0,-1);let r=t-n;return new k(e.indexStart>>r,e.indexEnd>>r)}_mergeBuckets(e,t,n,r){let i=n.offset,a=t.scale-r;for(let t=0;t<n.length;t++)this._incrementIndexBy(e,i+t>>a,n.at(t))}_diffBuckets(e,t,n,r){let i=n.offset,a=t.scale-r;for(let t=0;t<n.length;t++){let r=(i+t>>a)-e.indexBase;r<0&&(r+=e.backing.length),e.decrementBucket(r,n.at(t))}e.trim()}},Re=class{constructor(e,t){r(this,`kind`,x.EXPONENTIAL_HISTOGRAM),r(this,`_maxSize`,void 0),r(this,`_recordMinMax`,void 0),this._maxSize=e,this._recordMinMax=t}createAccumulation(e){return new Le(e,this._maxSize,this._recordMinMax)}merge(e,t){let n=t.clone();return n.merge(e),n}diff(e,t){let n=t.clone();return n.diff(e),n}toMetricData(e,t,n,r){return{descriptor:e,aggregationTemporality:t,dataPointType:g.EXPONENTIAL_HISTOGRAM,dataPoints:n.map(([t,n])=>{let i=n.toPointValue(),a=e.type===h.GAUGE||e.type===h.UP_DOWN_COUNTER||e.type===h.OBSERVABLE_GAUGE||e.type===h.OBSERVABLE_UP_DOWN_COUNTER;return{attributes:t,startTime:n.startTime,endTime:r,value:{min:i.hasMinMax?i.min:void 0,max:i.hasMinMax?i.max:void 0,sum:a?void 0:i.sum,positive:{offset:i.positive.offset,bucketCounts:i.positive.bucketCounts},negative:{offset:i.negative.offset,bucketCounts:i.negative.bucketCounts},count:i.count,scale:i.scale,zeroCount:i.zeroCount}}})}}}})),j,Be,Ve=e((()=>{S(),u(),_(),n(),j=class{constructor(e,t=0,n=[0,0]){r(this,`startTime`,void 0),r(this,`_current`,void 0),r(this,`sampleTime`,void 0),this.startTime=e,this._current=t,this.sampleTime=n}record(e){this._current=e,this.sampleTime=d(Date.now())}setStartTime(e){this.startTime=e}toPointValue(){return this._current}},Be=class{constructor(){r(this,`kind`,x.LAST_VALUE)}createAccumulation(e){return new j(e)}merge(e,t){let n=f(t.sampleTime)>=f(e.sampleTime)?t:e;return new j(e.startTime,n.toPointValue(),n.sampleTime)}diff(e,t){let n=f(t.sampleTime)>=f(e.sampleTime)?t:e;return new j(t.startTime,n.toPointValue(),n.sampleTime)}toMetricData(e,t,n,r){return{descriptor:e,aggregationTemporality:t,dataPointType:g.GAUGE,dataPoints:n.map(([e,t])=>({attributes:e,startTime:t.startTime,endTime:r,value:t.toPointValue()}))}}}})),M,He,Ue=e((()=>{S(),_(),n(),M=class{constructor(e,t,n=0,i=!1){r(this,`startTime`,void 0),r(this,`monotonic`,void 0),r(this,`_current`,void 0),r(this,`reset`,void 0),this.startTime=e,this.monotonic=t,this._current=n,this.reset=i}record(e){this.monotonic&&e<0||(this._current+=e)}setStartTime(e){this.startTime=e}toPointValue(){return this._current}},He=class{constructor(e){r(this,`kind`,x.SUM),r(this,`monotonic`,void 0),this.monotonic=e}createAccumulation(e){return new M(e,this.monotonic)}merge(e,t){let n=e.toPointValue(),r=t.toPointValue();return t.reset?new M(t.startTime,this.monotonic,r,t.reset):new M(e.startTime,this.monotonic,n+r)}diff(e,t){let n=e.toPointValue(),r=t.toPointValue();return this.monotonic&&n>r?new M(t.startTime,this.monotonic,r,!0):new M(t.startTime,this.monotonic,r-n)}toMetricData(e,t,n,r){return{descriptor:e,aggregationTemporality:t,dataPointType:g.SUM,dataPoints:n.map(([e,t])=>({attributes:e,startTime:t.startTime,endTime:r,value:t.toPointValue()})),isMonotonic:this.monotonic}}}})),We=e((()=>{ue(),pe(),ze(),Ve(),Ue()})),N,P,F,I,L,R,Ge,z,B,V,H,Ke,qe=e((()=>{o(),We(),_(),n(),N=class e{createAggregator(t){return e.DEFAULT_INSTANCE}},r(N,`DEFAULT_INSTANCE`,new le),P=class e{createAggregator(t){switch(t.type){case h.COUNTER:case h.OBSERVABLE_COUNTER:case h.HISTOGRAM:return e.MONOTONIC_INSTANCE;default:return e.NON_MONOTONIC_INSTANCE}}},r(P,`MONOTONIC_INSTANCE`,new He(!0)),r(P,`NON_MONOTONIC_INSTANCE`,new He(!1)),F=class e{createAggregator(t){return e.DEFAULT_INSTANCE}},r(F,`DEFAULT_INSTANCE`,new Be),I=class e{createAggregator(t){return e.DEFAULT_INSTANCE}},r(I,`DEFAULT_INSTANCE`,new fe([0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4],!0)),L=class{constructor(e,t=!0){if(r(this,`_boundaries`,void 0),r(this,`_recordMinMax`,void 0),e==null)throw Error(`ExplicitBucketHistogramAggregation should be created with explicit boundaries, if a single bucket histogram is required, please pass an empty array`);e=e.concat(),e=e.sort((e,t)=>e-t);let n=e.lastIndexOf(-1/0),i=e.indexOf(1/0);i===-1&&(i=void 0),this._boundaries=e.slice(n+1,i),this._recordMinMax=t}createAggregator(e){return new fe(this._boundaries,this._recordMinMax)}},R=class{constructor(e=160,t=!0){r(this,`_maxSize`,void 0),r(this,`_recordMinMax`,void 0),this._maxSize=e,this._recordMinMax=t}createAggregator(e){return new Re(this._maxSize,this._recordMinMax)}},Ge=class{_resolve(e){switch(e.type){case h.COUNTER:case h.UP_DOWN_COUNTER:case h.OBSERVABLE_COUNTER:case h.OBSERVABLE_UP_DOWN_COUNTER:return B;case h.GAUGE:case h.OBSERVABLE_GAUGE:return V;case h.HISTOGRAM:return e.advice.explicitBucketBoundaries?new L(e.advice.explicitBucketBoundaries):H}return s.warn(`Unable to recognize instrument type: ${e.type}`),z}createAggregator(e){return this._resolve(e).createAggregator(e)}},z=new N,B=new P,V=new F,H=new I,new R,Ke=new Ge}));function Je(e){switch(e.type){case U.DEFAULT:return Ke;case U.DROP:return z;case U.SUM:return B;case U.LAST_VALUE:return V;case U.EXPONENTIAL_HISTOGRAM:{let t=e;return new R(t.options?.maxSize,t.options?.recordMinMax)}case U.EXPLICIT_BUCKET_HISTOGRAM:{let t=e;return t.options==null?H:new L(t.options?.boundaries,t.options?.recordMinMax)}default:throw Error(`Unsupported Aggregation`)}}var U,W=e((()=>{qe(),(function(e){e[e.DEFAULT=0]=`DEFAULT`,e[e.DROP=1]=`DROP`,e[e.SUM=2]=`SUM`,e[e.LAST_VALUE=3]=`LAST_VALUE`,e[e.EXPLICIT_BUCKET_HISTOGRAM=4]=`EXPLICIT_BUCKET_HISTOGRAM`,e[e.EXPONENTIAL_HISTOGRAM=5]=`EXPONENTIAL_HISTOGRAM`})(U||(U={}))})),Ye,G,Xe=e((()=>{m(),W(),Ye=e=>({type:U.DEFAULT}),G=e=>p.CUMULATIVE})),Ze,Qe=e((()=>{o(),b(),Xe(),n(),Ze=class{constructor(e){r(this,`_shutdown`,!1),r(this,`_metricProducers`,void 0),r(this,`_sdkMetricProducer`,void 0),r(this,`_aggregationTemporalitySelector`,void 0),r(this,`_aggregationSelector`,void 0),r(this,`_cardinalitySelector`,void 0),this._aggregationSelector=e?.aggregationSelector??Ye,this._aggregationTemporalitySelector=e?.aggregationTemporalitySelector??G,this._metricProducers=e?.metricProducers??[],this._cardinalitySelector=e?.cardinalitySelector}setMetricProducer(e){if(this._sdkMetricProducer)throw Error(`MetricReader can not be bound to a MeterProvider again.`);this._sdkMetricProducer=e,this.onInitialized()}selectAggregation(e){return this._aggregationSelector(e)}selectAggregationTemporality(e){return this._aggregationTemporalitySelector(e)}selectCardinalityLimit(e){return this._cardinalitySelector?this._cardinalitySelector(e):2e3}onInitialized(){}async collect(e){if(this._sdkMetricProducer===void 0)throw Error(`MetricReader is not bound to a MetricProducer`);if(this._shutdown)throw Error(`MetricReader is shutdown`);let[t,...n]=await Promise.all([this._sdkMetricProducer.collect({timeoutMillis:e?.timeoutMillis}),...this._metricProducers.map(t=>t.collect({timeoutMillis:e?.timeoutMillis}))]),r=t.errors.concat(n.flatMap(e=>e.errors));return{resourceMetrics:{resource:t.resourceMetrics.resource,scopeMetrics:t.resourceMetrics.scopeMetrics.concat(n.flatMap(e=>e.resourceMetrics.scopeMetrics))},errors:r}}async shutdown(e){if(this._shutdown){s.error(`Cannot call shutdown twice.`);return}e?.timeoutMillis==null?await this.onShutdown():await v(this.onShutdown(),e.timeoutMillis),this._shutdown=!0}async forceFlush(e){if(this._shutdown){s.warn(`Cannot forceFlush on already shutdown MetricReader.`);return}if(e?.timeoutMillis==null){await this.onForceFlush();return}await v(this.onForceFlush(),e.timeoutMillis)}}})),$e,et=e((()=>{o(),u(),Qe(),b(),_(),n(),$e=class extends Ze{constructor(e){let{exporter:t,exportIntervalMillis:n=6e4,metricProducers:i,cardinalityLimits:a}=e,{exportTimeoutMillis:o=3e4}=e;if(super({aggregationSelector:t.selectAggregation?.bind(t),aggregationTemporalitySelector:t.selectAggregationTemporality?.bind(t),metricProducers:i,cardinalitySelector:e=>{let t={default:2e3,...a};switch(e){case h.COUNTER:return t.counter??t.default;case h.GAUGE:return t.gauge??t.default;case h.HISTOGRAM:return t.histogram??t.default;case h.OBSERVABLE_COUNTER:return t.observableCounter??t.default;case h.OBSERVABLE_UP_DOWN_COUNTER:return t.observableUpDownCounter??t.default;case h.OBSERVABLE_GAUGE:return t.observableGauge??t.default;case h.UP_DOWN_COUNTER:return t.upDownCounter??t.default;default:return t.default}}}),r(this,`_interval`,void 0),r(this,`_exporter`,void 0),r(this,`_exportInterval`,void 0),r(this,`_exportTimeout`,void 0),n<=0)throw Error(`exportIntervalMillis must be greater than 0`);if(o<=0)throw Error(`exportTimeoutMillis must be greater than 0`);if(n<o){if(`exportIntervalMillis`in e&&`exportTimeoutMillis`in e)throw Error(`exportIntervalMillis must be greater than or equal to exportTimeoutMillis`);s.info(`Timeout of ${o} exceeds the interval of ${n}. Clamping timeout to interval duration.`),o=n}this._exportInterval=n,this._exportTimeout=o,this._exporter=t}async _runOnce(){try{await v(this._doRun(),this._exportTimeout)}catch(e){if(e instanceof y){s.error(`Export took longer than %s milliseconds and timed out.`,this._exportTimeout);return}ee(e)}}async _doRun(){let{resourceMetrics:e,errors:t}=await this.collect({timeoutMillis:this._exportTimeout});if(t.length>0&&s.error(`PeriodicExportingMetricReader: metrics collection errors`,...t),e.resource.asyncAttributesPending)try{await e.resource.waitForAsyncAttributes?.()}catch(e){s.debug(`Error while resolving async portion of resource: `,e),ee(e)}if(e.scopeMetrics.length===0)return;let n=await te._export(this._exporter,e);if(n.code!==l.SUCCESS)throw Error(`PeriodicExportingMetricReader: metrics export failed (error ${n.error})`)}onInitialized(){this._interval=setInterval(()=>{this._runOnce()},this._exportInterval),typeof this._interval!=`number`&&this._interval.unref()}async onForceFlush(){await this._runOnce(),await this._exporter.forceFlush()}async onShutdown(){this._interval&&clearInterval(this._interval),await this.onForceFlush(),await this._exporter.shutdown()}}})),tt,nt=e((()=>{u(),n(),tt=class{constructor(e){r(this,`_shutdown`,!1),r(this,`_aggregationTemporality`,void 0),r(this,`_metrics`,[]),this._aggregationTemporality=e}export(e,t){if(this._shutdown){setTimeout(()=>t({code:l.FAILED}),0);return}this._metrics.push(e),setTimeout(()=>t({code:l.SUCCESS}),0)}getMetrics(){return this._metrics}forceFlush(){return Promise.resolve()}reset(){this._metrics=[]}selectAggregationTemporality(e){return this._aggregationTemporality}shutdown(){return this._shutdown=!0,Promise.resolve()}}})),rt,it=e((()=>{u(),Xe(),n(),rt=class e{constructor(e){r(this,`_shutdown`,!1),r(this,`_temporalitySelector`,void 0),this._temporalitySelector=e?.temporalitySelector??G}export(t,n){if(this._shutdown){n({code:l.FAILED});return}return e._sendMetrics(t,n)}forceFlush(){return Promise.resolve()}selectAggregationTemporality(e){return this._temporalitySelector(e)}shutdown(){return this._shutdown=!0,Promise.resolve()}static _sendMetrics(e,t){for(let t of e.scopeMetrics)for(let e of t.metrics)console.dir({descriptor:e.descriptor,dataPointType:e.dataPointType,dataPoints:e.dataPoints},{depth:null});t({code:l.SUCCESS})}}})),at,ot=e((()=>{n(),at=class{constructor(){r(this,`_registeredViews`,[])}addView(e){this._registeredViews.push(e)}findViews(e,t){return this._registeredViews.filter(n=>this._matchInstrument(n.instrumentSelector,e)&&this._matchMeter(n.meterSelector,t))}_matchInstrument(e,t){return(e.getType()===void 0||t.type===e.getType())&&e.getNameFilter().match(t.name)&&e.getUnitFilter().match(t.unit)}_matchMeter(e,t){return e.getNameFilter().match(t.name)&&(t.version===void 0||e.getVersionFilter().match(t.version))&&(t.schemaUrl===void 0||e.getSchemaUrlFilter().match(t.schemaUrl))}}}));function K(e,t,n){return lt(e)||s.warn(`Invalid metric name: "${e}". The metric name should be a ASCII string with a length no greater than 255 characters.`),{name:e,type:t,description:n?.description??``,unit:n?.unit??``,valueType:n?.valueType??c.DOUBLE,advice:n?.advice??{}}}function st(e,t){return{name:e.name??t.name,description:e.description??t.description,type:t.type,unit:t.unit,valueType:t.valueType,advice:t.advice}}function ct(e,t){return ce(e.name,t.name)&&e.unit===t.unit&&e.type===t.type&&e.valueType===t.valueType}function lt(e){return ut.test(e)}var ut,q=e((()=>{o(),b(),ut=/^[a-z][a-z0-9_.\-/]{0,254}$/i}));function dt(e){return e instanceof Y}var J,ft,pt,mt,ht,Y,gt,_t,vt,yt=e((()=>{o(),u(),n(),J=class{constructor(e,t){r(this,`_writableMetricStorage`,void 0),r(this,`_descriptor`,void 0),this._writableMetricStorage=e,this._descriptor=t}_record(e,t={},n=a.active()){if(typeof e!=`number`){s.warn(`non-number value provided to metric ${this._descriptor.name}: ${e}`);return}this._descriptor.valueType===c.INT&&!Number.isInteger(e)&&(s.warn(`INT value type cannot accept a floating-point value for ${this._descriptor.name}, ignoring the fractional digits.`),e=Math.trunc(e),!Number.isInteger(e))||this._writableMetricStorage.record(e,t,n,d(Date.now()))}},ft=class extends J{add(e,t,n){this._record(e,t,n)}},pt=class extends J{add(e,t,n){if(e<0){s.warn(`negative value provided to counter ${this._descriptor.name}: ${e}`);return}this._record(e,t,n)}},mt=class extends J{record(e,t,n){this._record(e,t,n)}},ht=class extends J{record(e,t,n){if(e<0){s.warn(`negative value provided to histogram ${this._descriptor.name}: ${e}`);return}this._record(e,t,n)}},Y=class{constructor(e,t,n){r(this,`_metricStorages`,void 0),r(this,`_descriptor`,void 0),r(this,`_observableRegistry`,void 0),this._descriptor=e,this._metricStorages=t,this._observableRegistry=n}addCallback(e){this._observableRegistry.addCallback(e,this)}removeCallback(e){this._observableRegistry.removeCallback(e,this)}},gt=class extends Y{},_t=class extends Y{},vt=class extends Y{}})),bt,xt=e((()=>{q(),yt(),_(),n(),bt=class{constructor(e){r(this,`_meterSharedState`,void 0),this._meterSharedState=e}createGauge(e,t){let n=K(e,h.GAUGE,t);return new mt(this._meterSharedState.registerMetricStorage(n),n)}createHistogram(e,t){let n=K(e,h.HISTOGRAM,t);return new ht(this._meterSharedState.registerMetricStorage(n),n)}createCounter(e,t){let n=K(e,h.COUNTER,t);return new pt(this._meterSharedState.registerMetricStorage(n),n)}createUpDownCounter(e,t){let n=K(e,h.UP_DOWN_COUNTER,t);return new ft(this._meterSharedState.registerMetricStorage(n),n)}createObservableGauge(e,t){let n=K(e,h.OBSERVABLE_GAUGE,t);return new _t(n,this._meterSharedState.registerAsyncMetricStorage(n),this._meterSharedState.observableRegistry)}createObservableCounter(e,t){let n=K(e,h.OBSERVABLE_COUNTER,t);return new gt(n,this._meterSharedState.registerAsyncMetricStorage(n),this._meterSharedState.observableRegistry)}createObservableUpDownCounter(e,t){let n=K(e,h.OBSERVABLE_UP_DOWN_COUNTER,t);return new vt(n,this._meterSharedState.registerAsyncMetricStorage(n),this._meterSharedState.observableRegistry)}addBatchObservableCallback(e,t){this._meterSharedState.observableRegistry.addBatchCallback(e,t)}removeBatchObservableCallback(e,t){this._meterSharedState.observableRegistry.removeBatchCallback(e,t)}}})),X,St=e((()=>{q(),n(),X=class{constructor(e){r(this,`_instrumentDescriptor`,void 0),this._instrumentDescriptor=e}getInstrumentDescriptor(){return this._instrumentDescriptor}updateDescription(e){this._instrumentDescriptor=K(this._instrumentDescriptor.name,this._instrumentDescriptor.type,{description:e,valueType:this._instrumentDescriptor.valueType,unit:this._instrumentDescriptor.unit,advice:this._instrumentDescriptor.advice})}}})),Ct,Z,Q=e((()=>{b(),n(),Ct=class{constructor(e){r(this,`_valueMap`,new Map),r(this,`_keyMap`,new Map),r(this,`_hash`,void 0),this._hash=e}get(e,t){return t??(t=this._hash(e)),this._valueMap.get(t)}getOrDefault(e,t){let n=this._hash(e);if(this._valueMap.has(n))return this._valueMap.get(n);let r=t();return this._keyMap.has(n)||this._keyMap.set(n,e),this._valueMap.set(n,r),r}set(e,t,n){n??(n=this._hash(e)),this._keyMap.has(n)||this._keyMap.set(n,e),this._valueMap.set(n,t)}has(e,t){return t??(t=this._hash(e)),this._valueMap.has(t)}*keys(){let e=this._keyMap.entries(),t=e.next();for(;t.done!==!0;)yield[t.value[1],t.value[0]],t=e.next()}*entries(){let e=this._valueMap.entries(),t=e.next();for(;t.done!==!0;)yield[this._keyMap.get(t.value[0]),t.value[1],t.value[0]],t=e.next()}get size(){return this._valueMap.size}},Z=class extends Ct{constructor(){super(ie)}}})),wt,Tt=e((()=>{b(),Q(),n(),wt=class{constructor(e,t){r(this,`_activeCollectionStorage`,new Z),r(this,`_cumulativeMemoStorage`,new Z),r(this,`_cardinalityLimit`,void 0),r(this,`_overflowAttributes`,{"otel.metric.overflow":!0}),r(this,`_overflowHashCode`,void 0),r(this,`_aggregator`,void 0),this._aggregator=e,this._cardinalityLimit=(t??2e3)-1,this._overflowHashCode=ie(this._overflowAttributes)}record(e,t,n,r){let i=this._activeCollectionStorage.get(t);if(!i){if(this._activeCollectionStorage.size>=this._cardinalityLimit){this._activeCollectionStorage.getOrDefault(this._overflowAttributes,()=>this._aggregator.createAccumulation(r))?.record(e);return}i=this._aggregator.createAccumulation(r),this._activeCollectionStorage.set(t,i)}i?.record(e)}batchCumulate(e,t){Array.from(e.entries()).forEach(([e,n,r])=>{let i=this._aggregator.createAccumulation(t);i?.record(n);let a=i;if(this._cumulativeMemoStorage.has(e,r)){let t=this._cumulativeMemoStorage.get(e,r);a=this._aggregator.diff(t,i)}else if(this._cumulativeMemoStorage.size>=this._cardinalityLimit&&(e=this._overflowAttributes,r=this._overflowHashCode,this._cumulativeMemoStorage.has(e,r))){let t=this._cumulativeMemoStorage.get(e,r);a=this._aggregator.diff(t,i)}if(this._activeCollectionStorage.has(e,r)){let t=this._activeCollectionStorage.get(e,r);a=this._aggregator.merge(t,a)}this._cumulativeMemoStorage.set(e,i,r),this._activeCollectionStorage.set(e,a,r)})}collect(){let e=this._activeCollectionStorage;return this._activeCollectionStorage=new Z,e}}}));function Et(e){return Array.from(e.entries())}var Dt,Ot=e((()=>{m(),Q(),n(),Dt=class e{constructor(e,t){r(this,`_aggregator`,void 0),r(this,`_unreportedAccumulations`,new Map),r(this,`_reportHistory`,new Map),this._aggregator=e,t.forEach(e=>{this._unreportedAccumulations.set(e,[])})}buildMetrics(t,n,r,i){this._stashAccumulations(r);let a=this._getMergedUnreportedAccumulations(t),o=a,s;if(this._reportHistory.has(t)){let n=this._reportHistory.get(t),r=n.collectionTime;s=n.aggregationTemporality,o=s===p.CUMULATIVE?e.merge(n.accumulations,a,this._aggregator):e.calibrateStartTime(n.accumulations,a,r)}else s=t.selectAggregationTemporality(n.type);this._reportHistory.set(t,{accumulations:o,collectionTime:i,aggregationTemporality:s});let c=Et(o);if(c.length!==0)return this._aggregator.toMetricData(n,s,c,i)}_stashAccumulations(e){let t=this._unreportedAccumulations.keys();for(let n of t){let t=this._unreportedAccumulations.get(n);t===void 0&&(t=[],this._unreportedAccumulations.set(n,t)),t.push(e)}}_getMergedUnreportedAccumulations(t){let n=new Z,r=this._unreportedAccumulations.get(t);if(this._unreportedAccumulations.set(t,[]),r===void 0)return n;for(let t of r)n=e.merge(n,t,this._aggregator);return n}static merge(e,t,n){let r=e,i=t.entries(),a=i.next();for(;a.done!==!0;){let[t,o,s]=a.value;if(e.has(t,s)){let i=e.get(t,s),a=n.merge(i,o);r.set(t,a,s)}else r.set(t,o,s);a=i.next()}return r}static calibrateStartTime(e,t,n){for(let[r,i]of e.keys())t.get(r,i)?.setStartTime(n);return t}}})),kt,At=e((()=>{St(),Tt(),Ot(),Q(),n(),kt=class extends X{constructor(e,t,n,i,a){super(e),r(this,`_aggregationCardinalityLimit`,void 0),r(this,`_deltaMetricStorage`,void 0),r(this,`_temporalMetricStorage`,void 0),r(this,`_attributesProcessor`,void 0),this._aggregationCardinalityLimit=a,this._deltaMetricStorage=new wt(t,this._aggregationCardinalityLimit),this._temporalMetricStorage=new Dt(t,i),this._attributesProcessor=n}record(e,t){let n=new Z;Array.from(e.entries()).forEach(([e,t])=>{n.set(this._attributesProcessor.process(e),t)}),this._deltaMetricStorage.batchCumulate(n,t)}collect(e,t){let n=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(e,this._instrumentDescriptor,n,t)}}}));function jt(e,t){let n=``;return e.unit!==t.unit&&(n+=`\t- Unit '${e.unit}' does not match '${t.unit}'\n`),e.type!==t.type&&(n+=`\t- Type '${e.type}' does not match '${t.type}'\n`),e.valueType!==t.valueType&&(n+=`\t- Value Type '${e.valueType}' does not match '${t.valueType}'\n`),e.description!==t.description&&(n+=`\t- Description '${e.description}' does not match '${t.description}'\n`),n}function Mt(e,t){return`\t- use valueType '${e.valueType}' on instrument creation or use an instrument name other than '${t.name}'`}function Nt(e,t){return`\t- use unit '${e.unit}' on instrument creation or use an instrument name other than '${t.name}'`}function Pt(e,t){let n={name:t.name,type:t.type,unit:t.unit},r=JSON.stringify(n);return`\t- create a new view with a name other than '${e.name}' and InstrumentSelector '${r}'`}function Ft(e,t){let n={name:t.name,type:t.type,unit:t.unit},r=JSON.stringify(n);return`\t- create a new view with a name other than '${e.name}' and InstrumentSelector '${r}'
|
|
3
|
+
\t- OR - create a new view with the name ${e.name} and description '${e.description}' and InstrumentSelector ${r}
|
|
4
|
+
\t- OR - create a new view with the name ${t.name} and description '${e.description}' and InstrumentSelector ${r}`}function It(e,t){return e.valueType===t.valueType?e.unit===t.unit?e.type===t.type?e.description===t.description?``:Ft(e,t):Pt(e,t):Nt(e,t):Mt(e,t)}var Lt=e((()=>{})),Rt,zt=e((()=>{q(),o(),Lt(),n(),Rt=class e{constructor(){r(this,`_sharedRegistry`,new Map),r(this,`_perCollectorRegistry`,new Map)}static create(){return new e}getStorages(e){let t=[];for(let e of this._sharedRegistry.values())t=t.concat(e);let n=this._perCollectorRegistry.get(e);if(n!=null)for(let e of n.values())t=t.concat(e);return t}register(e){this._registerStorage(e,this._sharedRegistry)}registerForCollector(e,t){let n=this._perCollectorRegistry.get(e);n??(n=new Map,this._perCollectorRegistry.set(e,n)),this._registerStorage(t,n)}findOrUpdateCompatibleStorage(e){let t=this._sharedRegistry.get(e.name);return t===void 0?null:this._findOrUpdateCompatibleStorage(e,t)}findOrUpdateCompatibleCollectorStorage(e,t){let n=this._perCollectorRegistry.get(e);if(n===void 0)return null;let r=n.get(t.name);return r===void 0?null:this._findOrUpdateCompatibleStorage(t,r)}_registerStorage(e,t){let n=e.getInstrumentDescriptor(),r=t.get(n.name);if(r===void 0){t.set(n.name,[e]);return}r.push(e)}_findOrUpdateCompatibleStorage(e,t){let n=null;for(let r of t){let t=r.getInstrumentDescriptor();ct(t,e)?(t.description!==e.description&&(e.description.length>t.description.length&&r.updateDescription(e.description),s.warn(`A view or instrument with the name `,e.name,` has already been registered, but has a different description and is incompatible with another registered view.
|
|
5
|
+
`,`Details:
|
|
6
|
+
`,jt(t,e),`The longer description will be used.
|
|
7
|
+
To resolve the conflict:`,It(t,e))),n=r):s.warn(`A view or instrument with the name `,e.name,` has already been registered and is incompatible with another registered view.
|
|
8
|
+
`,`Details:
|
|
9
|
+
`,jt(t,e),`To resolve the conflict:
|
|
10
|
+
`,It(t,e))}return n}}})),Bt,Vt=e((()=>{n(),Bt=class{constructor(e){r(this,`_backingStorages`,void 0),this._backingStorages=e}record(e,t,n,r){this._backingStorages.forEach(i=>{i.record(e,t,n,r)})}}})),Ht,Ut,Wt=e((()=>{o(),Q(),yt(),n(),Ht=class{constructor(e,t){r(this,`_buffer`,new Z),r(this,`_instrumentName`,void 0),r(this,`_valueType`,void 0),this._instrumentName=e,this._valueType=t}observe(e,t={}){if(typeof e!=`number`){s.warn(`non-number value provided to metric ${this._instrumentName}: ${e}`);return}this._valueType===c.INT&&!Number.isInteger(e)&&(s.warn(`INT value type cannot accept a floating-point value for ${this._instrumentName}, ignoring the fractional digits.`),e=Math.trunc(e),!Number.isInteger(e))||this._buffer.set(t,e)}},Ut=class{constructor(){r(this,`_buffer`,new Map)}observe(e,t,n={}){if(!dt(e))return;let r=this._buffer.get(e);if(r??(r=new Z,this._buffer.set(e,r)),typeof t!=`number`){s.warn(`non-number value provided to metric ${e._descriptor.name}: ${t}`);return}e._descriptor.valueType===c.INT&&!Number.isInteger(t)&&(s.warn(`INT value type cannot accept a floating-point value for ${e._descriptor.name}, ignoring the fractional digits.`),t=Math.trunc(t),!Number.isInteger(t))||r.set(n,t)}}})),Gt,Kt=e((()=>{o(),yt(),Wt(),b(),n(),Gt=class{constructor(){r(this,`_callbacks`,[]),r(this,`_batchCallbacks`,[])}addCallback(e,t){this._findCallback(e,t)>=0||this._callbacks.push({callback:e,instrument:t})}removeCallback(e,t){let n=this._findCallback(e,t);n<0||this._callbacks.splice(n,1)}addBatchCallback(e,t){let n=new Set(t.filter(dt));if(n.size===0){s.error(`BatchObservableCallback is not associated with valid instruments`,t);return}this._findBatchCallback(e,n)>=0||this._batchCallbacks.push({callback:e,instruments:n})}removeBatchCallback(e,t){let n=new Set(t.filter(dt)),r=this._findBatchCallback(e,n);r<0||this._batchCallbacks.splice(r,1)}async observe(e,t){let n=this._observeCallbacks(e,t),r=this._observeBatchCallbacks(e,t);return(await Promise.allSettled([...n,...r])).filter(e=>e.status===`rejected`).map(e=>e.reason)}_observeCallbacks(e,t){return this._callbacks.map(async({callback:n,instrument:r})=>{let i=new Ht(r._descriptor.name,r._descriptor.valueType),a=Promise.resolve(n(i));t!=null&&(a=v(a,t)),await a,r._metricStorages.forEach(t=>{t.record(i._buffer,e)})})}_observeBatchCallbacks(e,t){return this._batchCallbacks.map(async({callback:n,instruments:r})=>{let i=new Ut,a=Promise.resolve(n(i));t!=null&&(a=v(a,t)),await a,r.forEach(t=>{let n=i._buffer.get(t);n!=null&&t._metricStorages.forEach(t=>{t.record(n,e)})})})}_findCallback(e,t){return this._callbacks.findIndex(n=>n.callback===e&&n.instrument===t)}_findBatchCallback(e,t){return this._batchCallbacks.findIndex(n=>n.callback===e&&oe(n.instruments,t))}}})),qt,Jt=e((()=>{St(),Tt(),Ot(),n(),qt=class extends X{constructor(e,t,n,i,a){super(e),r(this,`_aggregationCardinalityLimit`,void 0),r(this,`_deltaMetricStorage`,void 0),r(this,`_temporalMetricStorage`,void 0),r(this,`_attributesProcessor`,void 0),this._aggregationCardinalityLimit=a,this._deltaMetricStorage=new wt(t,this._aggregationCardinalityLimit),this._temporalMetricStorage=new Dt(t,i),this._attributesProcessor=n}record(e,t,n,r){t=this._attributesProcessor.process(t,n),this._deltaMetricStorage.record(e,t,n,r)}collect(e,t){let n=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(e,this._instrumentDescriptor,n,t)}}}));function Yt(){return rn}function Xt(e){return new en(e)}function Zt(e){return new tn(e)}function Qt(e){return new nn(e)}var $t,en,tn,nn,rn,an=e((()=>{n(),$t=class{process(e,t){return e}},en=class{constructor(e){r(this,`_processors`,void 0),this._processors=e}process(e,t){let n=e;for(let e of this._processors)n=e.process(n,t);return n}},tn=class{constructor(e){r(this,`_allowedAttributeNames`,void 0),this._allowedAttributeNames=e}process(e,t){let n={};return Object.keys(e).forEach(t=>{this._allowedAttributeNames.includes(t)&&(n[t]=e[t])}),n}},nn=class{constructor(e){r(this,`_deniedAttributeNames`,void 0),this._deniedAttributeNames=e}process(e,t){let n={};return Object.keys(e).forEach(t=>{this._deniedAttributeNames.includes(t)||(n[t]=e[t])}),n}},rn=new $t})),on,sn=e((()=>{q(),xt(),At(),zt(),Vt(),Kt(),Jt(),an(),n(),on=class{constructor(e,t){r(this,`metricStorageRegistry`,new Rt),r(this,`observableRegistry`,new Gt),r(this,`meter`,void 0),r(this,`_meterProviderSharedState`,void 0),r(this,`_instrumentationScope`,void 0),this.meter=new bt(this),this._meterProviderSharedState=e,this._instrumentationScope=t}registerMetricStorage(e){let t=this._registerMetricStorage(e,qt);return t.length===1?t[0]:new Bt(t)}registerAsyncMetricStorage(e){return this._registerMetricStorage(e,kt)}async collect(e,t,n){let r=await this.observableRegistry.observe(t,n?.timeoutMillis),i=this.metricStorageRegistry.getStorages(e);if(i.length===0)return null;let a=[];return i.forEach(n=>{let r=n.collect(e,t);r!=null&&a.push(r)}),a.length===0?{errors:r}:{scopeMetrics:{scope:this._instrumentationScope,metrics:a},errors:r}}_registerMetricStorage(e,t){let n=this._meterProviderSharedState.viewRegistry.findViews(e,this._instrumentationScope).map(n=>{let r=st(n,e),i=this.metricStorageRegistry.findOrUpdateCompatibleStorage(r);if(i!=null)return i;let a=new t(r,n.aggregation.createAggregator(r),n.attributesProcessor,this._meterProviderSharedState.metricCollectors,n.aggregationCardinalityLimit);return this.metricStorageRegistry.register(a),a});if(n.length===0){let r=this._meterProviderSharedState.selectAggregations(e.type).map(([n,r])=>{let i=this.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(n,e);if(i!=null)return i;let a=r.createAggregator(e),o=n.selectCardinalityLimit(e.type),s=new t(e,a,Yt(),[n],o);return this.metricStorageRegistry.registerForCollector(n,s),s});n=n.concat(r)}return n}}})),cn,ln=e((()=>{b(),ot(),sn(),W(),n(),cn=class{constructor(e){r(this,`viewRegistry`,new at),r(this,`metricCollectors`,[]),r(this,`meterSharedStates`,new Map),r(this,`resource`,void 0),this.resource=e}getMeterSharedState(e){let t=ae(e),n=this.meterSharedStates.get(t);return n??(n=new on(this,e),this.meterSharedStates.set(t,n)),n}selectAggregations(e){let t=[];for(let n of this.metricCollectors)t.push([n,Je(n.selectAggregation(e))]);return t}}})),un,dn=e((()=>{u(),n(),un=class{constructor(e,t){r(this,`_sharedState`,void 0),r(this,`_metricReader`,void 0),this._sharedState=e,this._metricReader=t}async collect(e){let t=d(Date.now()),n=[],r=[],i=Array.from(this._sharedState.meterSharedStates.values()).map(async i=>{let a=await i.collect(this,t,e);a?.scopeMetrics!=null&&n.push(a.scopeMetrics),a?.errors!=null&&r.push(...a.errors)});return await Promise.all(i),{resourceMetrics:{resource:this._sharedState.resource,scopeMetrics:n},errors:r}}async forceFlush(e){await this._metricReader.forceFlush(e)}async shutdown(e){await this._metricReader.shutdown(e)}selectAggregationTemporality(e){return this._metricReader.selectAggregationTemporality(e)}selectAggregation(e){return this._metricReader.selectAggregation(e)}selectCardinalityLimit(e){return this._metricReader.selectCardinalityLimit?.(e)??2e3}}})),fn,pn,$,mn=e((()=>{n(),fn=/[\^$\\.+?()[\]{}|]/g,pn=class e{constructor(t){r(this,`_matchAll`,void 0),r(this,`_regexp`,void 0),t===`*`?(this._matchAll=!0,this._regexp=/.*/):(this._matchAll=!1,this._regexp=new RegExp(e.escapePattern(t)))}match(e){return this._matchAll?!0:this._regexp.test(e)}static escapePattern(e){return`^${e.replace(fn,`\\$&`).replace(`*`,`.*`)}$`}static hasWildcard(e){return e.includes(`*`)}},$=class{constructor(e){r(this,`_matchAll`,void 0),r(this,`_pattern`,void 0),this._matchAll=e===void 0,this._pattern=e}match(e){return!!(this._matchAll||e===this._pattern)}}})),hn,gn=e((()=>{mn(),n(),hn=class{constructor(e){r(this,`_nameFilter`,void 0),r(this,`_type`,void 0),r(this,`_unitFilter`,void 0),this._nameFilter=new pn(e?.name??`*`),this._type=e?.type,this._unitFilter=new $(e?.unit)}getType(){return this._type}getNameFilter(){return this._nameFilter}getUnitFilter(){return this._unitFilter}}})),_n,vn=e((()=>{mn(),n(),_n=class{constructor(e){r(this,`_nameFilter`,void 0),r(this,`_versionFilter`,void 0),r(this,`_schemaUrlFilter`,void 0),this._nameFilter=new $(e?.name),this._versionFilter=new $(e?.version),this._schemaUrlFilter=new $(e?.schemaUrl)}getNameFilter(){return this._nameFilter}getVersionFilter(){return this._versionFilter}getSchemaUrlFilter(){return this._schemaUrlFilter}}}));function yn(e){return e.instrumentName==null&&e.instrumentType==null&&e.instrumentUnit==null&&e.meterName==null&&e.meterVersion==null&&e.meterSchemaUrl==null}function bn(e){if(yn(e))throw Error(`Cannot create view with no selector arguments supplied`);if(e.name!=null&&(e?.instrumentName==null||pn.hasWildcard(e.instrumentName)))throw Error(`Views with a specified name must be declared with an instrument selector that selects at most one instrument per meter.`)}var xn,Sn=e((()=>{mn(),an(),gn(),vn(),W(),n(),xn=class{constructor(e){r(this,`name`,void 0),r(this,`description`,void 0),r(this,`aggregation`,void 0),r(this,`attributesProcessor`,void 0),r(this,`instrumentSelector`,void 0),r(this,`meterSelector`,void 0),r(this,`aggregationCardinalityLimit`,void 0),bn(e),e.attributesProcessors==null?this.attributesProcessor=Yt():this.attributesProcessor=Xt(e.attributesProcessors),this.name=e.name,this.description=e.description,this.aggregation=Je(e.aggregation??{type:U.DEFAULT}),this.instrumentSelector=new hn({name:e.instrumentName,type:e.instrumentType,unit:e.instrumentUnit}),this.meterSelector=new _n({name:e.meterName,version:e.meterVersion,schemaUrl:e.meterSchemaUrl}),this.aggregationCardinalityLimit=e.aggregationCardinalityLimit}}})),Cn,wn=e((()=>{o(),re(),ln(),dn(),Sn(),n(),Cn=class{constructor(e){if(r(this,`_sharedState`,void 0),r(this,`_shutdown`,!1),this._sharedState=new cn(e?.resource??ne()),e?.views!=null&&e.views.length>0)for(let t of e.views)this._sharedState.viewRegistry.addView(new xn(t));if(e?.readers!=null&&e.readers.length>0)for(let t of e.readers){let e=new un(this._sharedState,t);t.setMetricProducer(e),this._sharedState.metricCollectors.push(e)}}getMeter(e,t=``,n={}){return this._shutdown?(s.warn(`A shutdown MeterProvider cannot provide a Meter`),i()):this._sharedState.getMeterSharedState({name:e,version:t,schemaUrl:n.schemaUrl}).meter}async shutdown(e){if(this._shutdown){s.warn(`shutdown may only be called once per MeterProvider`);return}this._shutdown=!0,await Promise.all(this._sharedState.metricCollectors.map(t=>t.shutdown(e)))}async forceFlush(e){if(this._shutdown){s.warn(`invalid attempt to force flush after MeterProvider shutdown`);return}await Promise.all(this._sharedState.metricCollectors.map(t=>t.forceFlush(e)))}}})),Tn=t({AggregationTemporality:()=>p,AggregationType:()=>U,ConsoleMetricExporter:()=>rt,DataPointType:()=>g,InMemoryMetricExporter:()=>tt,InstrumentType:()=>h,MeterProvider:()=>Cn,MetricReader:()=>Ze,PeriodicExportingMetricReader:()=>$e,TimeoutError:()=>y,createAllowListAttributesProcessor:()=>Zt,createDenyListAttributesProcessor:()=>Qt}),En=e((()=>{m(),_(),Qe(),et(),nt(),it(),wn(),W(),an(),b()}));export{g as a,p as c,W as i,m as l,En as n,h as o,U as r,_ as s,Tn as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,t as s}from"./convert-legacy-node-http-options-BZnGSjx2.js";import{n as c,s as l}from"./esm-lWlUmoUA.js";function u(e,t){return{resourceLogs:f(e,t)}}function d(e){let t=new Map;for(let n of e){let{resource:e,instrumentationScope:{name:r,version:i=``,schemaUrl:a=``}}=n,o=t.get(e);o||(o=new Map,t.set(e,o));let s=`${r}@${i}:${a}`,c=o.get(s);c||(c=[],o.set(s,c)),c.push(n)}return t}function f(t,r){let i=d(t);return Array.from(i,([t,i])=>{let a=e(t,r);return{resource:a,scopeLogs:Array.from(i,([,e])=>({scope:n(e[0].instrumentationScope),logRecords:e.map(e=>p(e,r)),schemaUrl:e[0].instrumentationScope.schemaUrl})),schemaUrl:a.schemaUrl}})}function p(e,t){return{timeUnixNano:t.encodeHrTime(e.hrTime),observedTimeUnixNano:t.encodeHrTime(e.hrTimeObserved),severityNumber:m(e.severityNumber),severityText:e.severityText,body:a(e.body,t),eventName:e.eventName,attributes:h(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,flags:e.spanContext?.traceFlags,traceId:t.encodeOptionalSpanContext(e.spanContext?.traceId),spanId:t.encodeOptionalSpanContext(e.spanContext?.spanId)}}function m(e){return e}function h(e,n){return Object.keys(e).map(r=>t(r,e[r],n))}c();var g={serializeRequest:e=>{let t=u(e,o);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return l.warn(`Failed to parse logs export response: ${e.message}. Returning empty response`),{}}}},_=class extends r{constructor(e={}){super(i(s(e,`LOGS`,`v1/logs`,{"Content-Type":`application/json`}),g))}};export{_ as OTLPLogExporter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{l as r,o as i}from"./envUtils-DcaKZlRU.js";import{n as a,t as o}from"./defineProperty-C-QyHrDq.js";import{E as s,O as c,S as l,i as u,l as d,n as f,s as p,v as ee}from"./esm-lWlUmoUA.js";import{B as te,C as ne,D as re,E as ie,F as m,O as ae,S as oe,T as h,b as se,c as ce,i as le,m as ue,n as g,o as de,u as fe,v as _,x as pe}from"./esm-BbMeEYcz.js";import{n as me,t as he}from"./esm-sVMjGuep.js";import{I as ge,Q as _e,S as ve,ut as ye,zt as be}from"./state-BowF111d.js";import{C as xe,L as Se,i as Ce,x as we}from"./debug-8DCufdSp.js";import{Br as Te,Gt as Ee,Ur as De,Ut as Oe,Wt as v,qt as ke}from"./settings-DKN4xSpQ.js";import{i as Ae,t as je}from"./execFileNoThrow-BsfuytkN.js";import{a as Me,n as Ne,o as Pe,r as Fe}from"./platform-Dzff1WWw.js";import{St as Ie,Tt as Le,en as Re,f as ze,s as Be,tn as Ve,yt as He}from"./model-BwBE0Pt5.js";import{i as Ue,t as We}from"./genericProcessUtils-BYi0OefF.js";import{arch as Ge,hostname as Ke,platform as qe,release as Je}from"os";import{extname as Ye}from"path";import{stat as Xe}from"fs/promises";import{inspect as Ze}from"util";import*as Qe from"process";import{AsyncLocalStorage as $e}from"async_hooks";var y,et=e((()=>{(function(e){e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TRACE=1]=`TRACE`,e[e.TRACE2=2]=`TRACE2`,e[e.TRACE3=3]=`TRACE3`,e[e.TRACE4=4]=`TRACE4`,e[e.DEBUG=5]=`DEBUG`,e[e.DEBUG2=6]=`DEBUG2`,e[e.DEBUG3=7]=`DEBUG3`,e[e.DEBUG4=8]=`DEBUG4`,e[e.INFO=9]=`INFO`,e[e.INFO2=10]=`INFO2`,e[e.INFO3=11]=`INFO3`,e[e.INFO4=12]=`INFO4`,e[e.WARN=13]=`WARN`,e[e.WARN2=14]=`WARN2`,e[e.WARN3=15]=`WARN3`,e[e.WARN4=16]=`WARN4`,e[e.ERROR=17]=`ERROR`,e[e.ERROR2=18]=`ERROR2`,e[e.ERROR3=19]=`ERROR3`,e[e.ERROR4=20]=`ERROR4`,e[e.FATAL=21]=`FATAL`,e[e.FATAL2=22]=`FATAL2`,e[e.FATAL3=23]=`FATAL3`,e[e.FATAL4=24]=`FATAL4`})(y||(y={}))})),b,x,S=e((()=>{b=class{emit(e){}enabled(){return!1}},x=new b}));function tt(e,t,n){return r=>r===e?t:n}var C,w,nt=e((()=>{C=Symbol.for(`io.opentelemetry.js.api.logs`),w=globalThis})),rt,T,it=e((()=>{S(),rt=class{getLogger(e,t,n){return new b}},T=new rt})),at,ot=e((()=>{S(),at=class{constructor(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):x}}})),st,ct=e((()=>{it(),ot(),st=class{getLogger(e,t,n){return this._getDelegateLogger(e,t,n)??new at(this,e,t,n)}_getDelegate(){return this._delegate??T}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,t,n){return this._delegate?.getLogger(e,t,n)}}})),lt,ut=e((()=>{nt(),it(),ct(),lt=class e{constructor(){this._proxyLoggerProvider=new st}static getInstance(){return this._instance||(this._instance=new e),this._instance}setGlobalLoggerProvider(e){return w[C]?this.getLoggerProvider():(w[C]=tt(1,e,T),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){return w[C]?.call(w,1)??this._proxyLoggerProvider}getLogger(e,t,n){return this.getLoggerProvider().getLogger(e,t,n)}disable(){delete w[C],this._proxyLoggerProvider=new st}}})),dt,E=e((()=>{et(),S(),ut(),dt=lt.getInstance()}));function ft(){return`workmate/0.0.22`}var pt=e((()=>{}));function mt(){return process.platform===`linux`&&r(process.env.CLAUDE_CODE_BUBBLEWRAP)}function ht(){return process.platform===`linux`?D??!1:!1}async function gt(){if(O!==void 0)return O;if(process.platform===`darwin`)return O=null,null;try{let e=await We(process.pid,10);for(let t of e){let e=t.toLowerCase();for(let t of Oe)if(e.includes(t))return O=t,t}}catch{}return O=null,null}async function _t(){return process.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`&&v.platform!==`darwin`?await gt()||`pycharm`:v.terminal}function vt(){return process.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`&&v.platform!==`darwin`?O===void 0?`pycharm`:O||`pycharm`:v.terminal}async function yt(){process.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`&&await gt()}var bt,D,O,xt,St=e((()=>{n(),ke(),i(),Ae(),Ue(),bt=t(async()=>{if(process.platform!==`linux`)return!1;let{code:e}=await je(`test`,[`-f`,`/.dockerenv`]);return e===0}),D=null,process.platform===`linux`&&Xe(`/lib/libc.musl-${process.arch===`x64`?`x86_64`:`aarch64`}.so.1`).then(()=>{D=!0},()=>{D=!1}),xt={...v,terminal:vt(),getIsDocker:bt,getIsBubblewrapSandbox:mt,isMuslEnvironment:ht,getTerminalWithJetBrainsDetectionAsync:_t,initJetBrainsDetection:yt}}));function Ct(e){return wt?.has(e)??!1}var wt,Tt=e((()=>{Ce(),Se()}));function k(){return At.getStore()}function Et(e,t){return At.run(e,t)}function Dt(e){return e?.agentType===`subagent`}function Ot(){let e=k();if(!(!Dt(e)||!e.subagentName))return e.isBuiltIn?e.subagentName:`user-defined`}function kt(){let e=k();if(!(!e?.invokingRequestId||e.invocationEmitted))return e.invocationEmitted=!0,{invokingRequestId:e.invokingRequestId,invocationKind:e.invocationKind}}var At,jt=e((()=>{At=new $e}));function Mt(e){return e.startsWith(`mcp__`)?`mcp_tool`:e}function Nt(){return r(process.env.OTEL_LOG_TOOL_DETAILS)}function Pt(e,t){return!!(process.env.CLAUDE_CODE_ENTRYPOINT===`local-agent`||e===`claudeai-proxy`||t&&Ct(t))}function Ft(e,t,n){let r=It(e);return!r||!Gt.has(r.serverName)&&!Pt(t,n)?{}:{mcpServerName:r.serverName,mcpToolName:r.mcpToolName}}function It(e){if(!e.startsWith(`mcp__`))return;let t=e.split(`__`);if(t.length<3)return;let n=t[1],r=t.slice(2).join(`__`);if(!(!n||!r))return{serverName:n,mcpToolName:r}}function Lt(e,t){if(e===`Skill`&&typeof t==`object`&&t&&`skill`in t&&typeof t.skill==`string`)return t.skill}function Rt(e,t=0){if(typeof e==`string`)return e.length>Kt?`${e.slice(0,qt)}…[${e.length} chars]`:e;if(typeof e==`number`||typeof e==`boolean`||e==null)return e;if(t>=Jt)return`<nested>`;if(Array.isArray(e)){let n=e.slice(0,M).map(e=>Rt(e,t+1));return e.length>M&&n.push(`…[${e.length} items]`),n}if(typeof e==`object`){let n=Object.entries(e).filter(([e])=>!e.startsWith(`_`)),r=n.slice(0,M).map(([e,n])=>[e,Rt(n,t+1)]);return n.length>M&&r.push([`…`,`${n.length} keys`]),Object.fromEntries(r)}return String(e)}function zt(e){if(!Nt())return;let t=xe(Rt(e));return t.length>j&&(t=`${t.slice(0,j)}…[truncated]`),t}function A(e){let t=Ye(e).toLowerCase();if(!t||t===`.`)return;let n=t.slice(1);return n.length>Yt?`other`:n}function Bt(e,t){if(!e.includes(`.`)&&!t)return;let n,r=new Set;if(t){let e=A(t);e&&(r.add(e),n=e)}for(let t of e.split(Zt)){if(!t)continue;let e=t.split(Qt);if(e.length<2)continue;let i=e[0],a=i.lastIndexOf(`/`),o=a>=0?i.slice(a+1):i;if(Xt.has(o))for(let t=1;t<e.length;t++){let i=e[t];if(i.charCodeAt(0)===45)continue;let a=A(i);a&&!r.has(a)&&(r.add(a),n=n?`${n},${a}`:a)}}if(n)return n}function Vt(){let e=k();if(e)return{agentId:e.agentId,parentSessionId:e.parentSessionId,agentType:e.agentType};let t=process.env.CLAUDE_CODE_AGENT_ID,n=process.env.CLAUDE_CODE_PARENT_SESSION_ID,r=t?`standalone`:void 0;if(t||r||n)return{...t?{agentId:t}:{},...r?{agentType:r}:{},...n?{parentSessionId:n}:{}};let i=_e();return i?{parentSessionId:i}:{}}function Ht(){try{let e=process.memoryUsage(),t=process.cpuUsage(),n=Date.now(),r;if(N&&P){let e=n-P;e>0&&(r=(t.user-N.user+(t.system-N.system))/(e*1e3)*100)}return N=t,P=n,{uptime:process.uptime(),rss:e.rss,heapTotal:e.heapTotal,heapUsed:e.heapUsed,external:e.external,arrayBuffers:e.arrayBuffers,constrainedMemory:process.constrainedMemory(),cpuUsage:t,cpuPercent:r}}catch{return}}async function Ut(e={}){let t=e.model?String(e.model):Be(),n=typeof e.betas==`string`?e.betas:Re(t).join(`,`),[r,i]=await Promise.all([en(),Te()]),a=Ht();return{model:t,sessionId:ye(),userType:process.env.USER_TYPE||``,...n.length>0?{betas:n}:{},envContext:r,...process.env.CLAUDE_CODE_ENTRYPOINT&&{entrypoint:process.env.CLAUDE_CODE_ENTRYPOINT},...process.env.CLAUDE_AGENT_SDK_VERSION&&{agentSdkVersion:process.env.CLAUDE_AGENT_SDK_VERSION},isInteractive:String(ge()),clientType:ve(),...a&&{processMetrics:a},sweBenchRunId:process.env.SWE_BENCH_RUN_ID||``,sweBenchInstanceId:process.env.SWE_BENCH_INSTANCE_ID||``,sweBenchTaskId:process.env.SWE_BENCH_TASK_ID||``,...Vt(),...He()&&{subscriptionType:He()},...i&&{rh:i}}}function Wt(e,t,n={}){let{envContext:r,processMetrics:i,rh:a,skillMode:o,observerMode:s,...c}=e,l={platform:r.platform,platform_raw:r.platformRaw,arch:r.arch,node_version:r.nodeVersion,terminal:r.terminal||`unknown`,package_managers:r.packageManagers,runtimes:r.runtimes,is_running_with_bun:r.isRunningWithBun,is_ci:r.isCi,is_claubbit:r.isClaubbit,is_claude_code_remote:r.isClaudeCodeRemote,is_local_agent_mode:r.isLocalAgentMode,is_conductor:r.isConductor,is_github_action:r.isGithubAction,is_claude_code_action:r.isClaudeCodeAction,is_claude_ai_auth:r.isClaudeAiAuth,version:r.version,build_time:r.buildTime,deployment_environment:r.deploymentEnvironment};r.remoteEnvironmentType&&(l.remote_environment_type=r.remoteEnvironmentType),r.claudeCodeContainerId&&(l.claude_code_container_id=r.claudeCodeContainerId),r.claudeCodeRemoteSessionId&&(l.claude_code_remote_session_id=r.claudeCodeRemoteSessionId),r.tags&&(l.tags=r.tags.split(`,`).map(e=>e.trim()).filter(Boolean)),r.githubEventName&&(l.github_event_name=r.githubEventName),r.githubActionsRunnerEnvironment&&(l.github_actions_runner_environment=r.githubActionsRunnerEnvironment),r.githubActionsRunnerOs&&(l.github_actions_runner_os=r.githubActionsRunnerOs),r.githubActionRef&&(l.github_action_ref=r.githubActionRef),r.wslVersion&&(l.wsl_version=r.wslVersion),r.linuxDistroId&&(l.linux_distro_id=r.linuxDistroId),r.linuxDistroVersion&&(l.linux_distro_version=r.linuxDistroVersion),r.linuxKernel&&(l.linux_kernel=r.linuxKernel),r.vcs&&(l.vcs=r.vcs),r.versionBase&&(l.version_base=r.versionBase);let u={session_id:c.sessionId,model:c.model,user_type:c.userType,is_interactive:c.isInteractive===`true`,client_type:c.clientType};if(c.betas&&(u.betas=c.betas),c.entrypoint&&(u.entrypoint=c.entrypoint),c.agentSdkVersion&&(u.agent_sdk_version=c.agentSdkVersion),c.sweBenchRunId&&(u.swe_bench_run_id=c.sweBenchRunId),c.sweBenchInstanceId&&(u.swe_bench_instance_id=c.sweBenchInstanceId),c.sweBenchTaskId&&(u.swe_bench_task_id=c.sweBenchTaskId),c.agentId&&(u.agent_id=c.agentId),c.parentSessionId&&(u.parent_session_id=c.parentSessionId),c.agentType&&(u.agent_type=c.agentType),t.githubActionsMetadata){let e=t.githubActionsMetadata;l.github_actions_metadata={actor_id:e.actorId,repository_id:e.repositoryId,repository_owner_id:e.repositoryOwnerId}}let d;return(t.accountUuid||t.organizationUuid)&&(d={account_uuid:t.accountUuid,organization_uuid:t.organizationUuid}),{env:l,...i&&{process:Buffer.from(xe(i)).toString(`base64`)},...d&&{auth:d},core:u,additional:{...a&&{rh:a},...o&&{skill_mode:o},...s&&{observer_mode:s},...n}}}var Gt,Kt,qt,j,M,Jt,Yt,Xt,Zt,Qt,$t,en,N,P,tn=e((()=>{n(),ke(),St(),Ve(),ze(),be(),i(),Tt(),Ie(),De(),Pe(),jt(),we(),Gt=new Set,Kt=512,qt=128,j=4*1024,M=20,Jt=2,Yt=10,Xt=new Set([`rm`,`mv`,`cp`,`touch`,`mkdir`,`chmod`,`chown`,`cat`,`head`,`tail`,`sort`,`stat`,`diff`,`wc`,`grep`,`rg`,`sed`]),Zt=/\s*(?:&&|\|\||[;|])\s*/,Qt=/\s+/,$t=t(()=>{let e=`0.0.22`.match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);return e?e[0]:void 0}),en=t(async()=>{let[e,t,n,i]=await Promise.all([v.getPackageManagers(),v.getRuntimes(),Fe(),Ne()]);return{platform:Ee(),platformRaw:process.env.CLAUDE_CODE_HOST_PLATFORM||process.platform,arch:v.arch,nodeVersion:v.nodeVersion,terminal:xt.terminal,packageManagers:e.join(`,`),runtimes:t.join(`,`),isRunningWithBun:v.isRunningWithBun(),isCi:r(process.env.CI),isClaubbit:r(process.env.CLAUBBIT),isClaudeCodeRemote:r(process.env.CLAUDE_CODE_REMOTE),isLocalAgentMode:process.env.CLAUDE_CODE_ENTRYPOINT===`local-agent`,isConductor:v.isConductor(),...process.env.CLAUDE_CODE_REMOTE_ENVIRONMENT_TYPE&&{remoteEnvironmentType:process.env.CLAUDE_CODE_REMOTE_ENVIRONMENT_TYPE},...process.env.CLAUDE_CODE_CONTAINER_ID&&{claudeCodeContainerId:process.env.CLAUDE_CODE_CONTAINER_ID},...process.env.CLAUDE_CODE_REMOTE_SESSION_ID&&{claudeCodeRemoteSessionId:process.env.CLAUDE_CODE_REMOTE_SESSION_ID},...process.env.CLAUDE_CODE_TAGS&&{tags:process.env.CLAUDE_CODE_TAGS},isGithubAction:r(process.env.GITHUB_ACTIONS),isClaudeCodeAction:r(process.env.CLAUDE_CODE_ACTION),isClaudeAiAuth:Le(),version:`0.0.22`,versionBase:$t(),buildTime:`2026-08-20T09:27:22.266Z`,deploymentEnvironment:v.detectDeploymentEnvironment(),...r(process.env.GITHUB_ACTIONS)&&{githubEventName:process.env.GITHUB_EVENT_NAME,githubActionsRunnerEnvironment:process.env.RUNNER_ENVIRONMENT,githubActionsRunnerOs:process.env.RUNNER_OS,githubActionRef:process.env.GITHUB_ACTION_PATH?.includes(`claude-code-action/`)?process.env.GITHUB_ACTION_PATH.split(`claude-code-action/`)[1]:void 0},...Me()&&{wslVersion:Me()},...n??{},...i.length>0?{vcs:i.join(`,`)}:{}}}),N=null,P=null}));function nn(e){return e.setValue(F,!0)}function rn(e){return e.getValue(F)===!0}var F,I=e((()=>{f(),F=c(`OpenTelemetry SDK Context Key SUPPRESS_TRACING`)}));function an(e){let t={};if(typeof e!=`object`||!e)return t;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(!on(n)){p.warn(`Invalid attribute key: ${n}`);continue}let r=e[n];if(!sn(r)){p.warn(`Invalid attribute value set for key: ${n}`);continue}Array.isArray(r)?t[n]=r.slice():t[n]=r}return t}function on(e){return typeof e==`string`&&e!==``}function sn(e){return e==null?!0:Array.isArray(e)?cn(e):ln(typeof e)}function cn(e){let t;for(let n of e){if(n==null)continue;let e=typeof n;if(e!==t){if(!t){if(ln(e)){t=e;continue}return!1}return!1}}return!0}function ln(e){switch(e){case`number`:case`boolean`:case`string`:return!0}return!1}var un=e((()=>{f()}));function dn(){return e=>{p.error(fn(e))}}function fn(e){return typeof e==`string`?e:JSON.stringify(pn(e))}function pn(e){let t={},n=e;for(;n!==null;)Object.getOwnPropertyNames(n).forEach(e=>{if(t[e])return;let r=n[e];r&&(t[e]=String(r))}),n=Object.getPrototypeOf(n);return t}var mn=e((()=>{f()}));function hn(e){try{gn(e)}catch{}}var gn,_n=e((()=>{mn(),gn=dn()}));function vn(e){let t=process.env[e];if(t==null||t.trim()===``)return;let n=Number(t);if(isNaN(n)){p.warn(`Unknown value ${Ze(t)} for ${e}, expected a number, using defaults`);return}return n}function L(e){let t=process.env[e];if(!(t==null||t.trim()===``))return t}var yn=e((()=>{f()})),bn,xn=e((()=>{bn=`2.9.0`})),Sn,Cn=e((()=>{Sn=`process.runtime.name`})),R,wn=e((()=>{xn(),_(),Cn(),R={[ie]:`opentelemetry`,[Sn]:`node`,[h]:ae,[re]:bn}})),z,Tn=e((()=>{yn(),wn(),z=performance})),En=e((()=>{Tn()}));function B(e){let t=e/1e3;return[Math.trunc(t),Math.round(e%1e3*Fn)]}function Dn(e){return Nn(B(z.timeOrigin),B(typeof e==`number`?e:z.now()))}function On(e,t){let n=t[0]-e[0],r=t[1]-e[1];return r<0&&(--n,r+=V),[n,r]}function kn(e){return e[0]*1e6+e[1]/1e3}function An(e){return e[0]+e[1]/V}function jn(e){return Array.isArray(e)&&e.length===2&&typeof e[0]==`number`&&typeof e[1]==`number`}function Mn(e){return jn(e)||typeof e==`number`||e instanceof Date}function Nn(e,t){let n=[e[0]+t[0],e[1]+t[1]];return n[1]>=V&&(n[1]-=V,n[0]+=1),n}var Pn,Fn,V,In=e((()=>{En(),Pn=9,Fn=10**6,V=10**Pn})),H,Ln=e((()=>{(function(e){e[e.SUCCESS=0]=`SUCCESS`,e[e.FAILED=1]=`FAILED`})(H||(H={}))}));function Rn(e){if(!zn(e)||Bn(e)!==Un)return!1;let t=qn(e);if(t===null)return!0;let n=G.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&U.call(n)===Kn}function zn(e){return typeof e==`object`&&!!e}function Bn(e){return e==null?e===void 0?Gn:Wn:K&&K in Object(e)?Vn(e):Hn(e)}function Vn(e){let t=G.call(e,K),n=e[K],r=!1;try{e[K]=void 0,r=!0}catch{}let i=Jn.call(e);return r&&(t?e[K]=n:delete e[K]),i}function Hn(e){return Jn.call(e)}var Un,Wn,Gn,U,Kn,qn,W,G,K,Jn,Yn=e((()=>{Un=`[object Object]`,Wn=`[object Null]`,Gn=`[object Undefined]`,U=Function.prototype.toString,Kn=U.call(Object),qn=Object.getPrototypeOf,W=Object.prototype,G=W.hasOwnProperty,K=Symbol?Symbol.toStringTag:void 0,Jn=W.toString}));function Xn(...e){let t=e.shift(),n=new WeakMap;for(;e.length>0;)t=Qn(t,e.shift(),0,n);return t}function Zn(e){return q(e)?e.slice():e}function Qn(e,t,n=0,r){let i;if(!(n>nr)){if(n++,Y(e)||Y(t)||er(t))i=Zn(t);else if(q(e)){if(i=e.slice(),q(t))for(let e=0,n=t.length;e<n;e++)i.push(Zn(t[e]));else if(J(t)){let e=Object.keys(t);for(let n=0,r=e.length;n<r;n++){let r=e[n];r===`__proto__`||r===`constructor`||r===`prototype`||(i[r]=Zn(t[r]))}}}else if(J(e))if(J(t)){if(!tr(e,t))return t;i=Object.assign({},e);let a=Object.keys(t);for(let o=0,s=a.length;o<s;o++){let s=a[o];if(s===`__proto__`||s===`constructor`||s===`prototype`)continue;let c=t[s];if(Y(c))c===void 0?delete i[s]:i[s]=c;else{let a=i[s],o=c;if($n(e,s,r)||$n(t,s,r))delete i[s];else{if(J(a)&&J(o)){let n=r.get(a)||[],i=r.get(o)||[];n.push({obj:e,key:s}),i.push({obj:t,key:s}),r.set(a,n),r.set(o,i)}i[s]=Qn(i[s],c,n,r)}}}}else i=t;return i}}function $n(e,t,n){let r=n.get(e[t])||[];for(let n=0,i=r.length;n<i;n++){let i=r[n];if(i.key===t&&i.obj===e)return!0}return!1}function q(e){return Array.isArray(e)}function er(e){return typeof e==`function`}function J(e){return!Y(e)&&!q(e)&&!er(e)&&typeof e==`object`}function Y(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===void 0||e instanceof Date||e instanceof RegExp||e===null}function tr(e,t){return!(!Rn(e)||!Rn(t))}var nr,rr=e((()=>{Yn(),nr=20})),ir,ar=e((()=>{a(),ir=class{constructor(){o(this,`_promise`,void 0),o(this,`_resolve`,void 0),o(this,`_reject`,void 0),this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}}})),or,sr=e((()=>{ar(),a(),or=class{constructor(e,t){o(this,`_isCalled`,!1),o(this,`_deferred`,new ir),o(this,`_callback`,void 0),o(this,`_that`,void 0),this._callback=e,this._that=t}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(e=>this._deferred.resolve(e),e=>this._deferred.reject(e))}catch(e){this._deferred.reject(e)}}return this._deferred.promise}}}));function cr(e,t){return new Promise(n=>{d.with(nn(d.active()),()=>{e.export(t,n)})})}var lr=e((()=>{f(),I()})),ur,X=e((()=>{I(),un(),_n(),mn(),In(),Ln(),En(),rr(),sr(),lr(),ur={_export:cr}}));function dr(){if(Z===void 0)try{let e=globalThis.process.argv0;Z=e?`unknown_service:${e}`:`unknown_service`}catch{Z=`unknown_service`}return Z}var Z,fr=e((()=>{})),Q,pr=e((()=>{Q=e=>typeof e==`object`&&!!e&&typeof e.then==`function`}));function mr(e,t){return yr.FromAttributeList(Object.entries(e),t)}function hr(){return mr({[ne]:dr(),[h]:R[h],[ie]:R[ie],[re]:R[re]})}function gr(e){return e.map(([e,t])=>Q(t)?[e,t.catch(t=>{p.debug(`promise rejection for resource attribute: %s - %s`,e,t)})]:[e,t])}function _r(e){if(typeof e==`string`||e===void 0)return e;p.warn(`Schema URL must be string or undefined, got %s. Schema URL will be ignored.`,e)}function vr(e,t){let n=e?.schemaUrl,r=t?.schemaUrl,i=n===void 0||n===``,a=r===void 0||r===``;if(i)return r;if(a||n===r)return n;p.warn(`Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.`,n,r)}var yr,br=e((()=>{f(),X(),_(),fr(),pr(),a(),yr=class e{static FromAttributeList(t,n){let r=new e({},n);return r._rawAttributes=gr(t),r._asyncAttributesPending=t.filter(([e,t])=>Q(t)).length>0,r}constructor(e,t){o(this,`_rawAttributes`,void 0),o(this,`_asyncAttributesPending`,!1),o(this,`_schemaUrl`,void 0),o(this,`_memoizedAttributes`,void 0);let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([e,t])=>(Q(t)&&(this._asyncAttributesPending=!0),[e,t])),this._rawAttributes=gr(this._rawAttributes),this._schemaUrl=_r(t?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[t,n]=this._rawAttributes[e];this._rawAttributes[e]=[t,Q(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&p.error(`Accessing resource attributes before async attributes settled`),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[t,n]of this._rawAttributes){if(Q(n)){p.debug(`Unsettled resource attribute ${t} skipped`);continue}n!=null&&(e[t]??(e[t]=n))}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(t){if(t==null)return this;let n=vr(this,t),r=n?{schemaUrl:n}:void 0;return e.FromAttributeList([...t.getRawAttributes(),...this.getRawAttributes()],r)}}})),xr,Sr,Cr=e((()=>{f(),_(),X(),a(),xr=class{constructor(){o(this,`_MAX_LENGTH`,255),o(this,`_COMMA_SEPARATOR`,`,`),o(this,`_LABEL_KEY_VALUE_SPLITTER`,`=`)}detect(e){let t={},n=L(`OTEL_RESOURCE_ATTRIBUTES`),r=L(`OTEL_SERVICE_NAME`);if(n)try{let e=this._parseResourceAttributes(n);Object.assign(t,e)}catch(e){p.debug(`EnvDetector failed: ${e instanceof Error?e.message:e}`)}return r&&(t[ne]=r),{attributes:t}}_parseResourceAttributes(e){if(!e)return{};let t={},n=e.split(this._COMMA_SEPARATOR).filter(e=>e.trim()!==``);for(let e of n){let n=e.split(this._LABEL_KEY_VALUE_SPLITTER);if(n.length!==2)throw Error(`Invalid format for OTEL_RESOURCE_ATTRIBUTES: "${e}". Expected format: key=value. The ',' and '=' characters must be percent-encoded in keys and values.`);let[r,i]=n,a=r.trim(),o=i.trim();if(a.length===0)throw Error(`Invalid OTEL_RESOURCE_ATTRIBUTES: empty attribute key in "${e}".`);let s,c;try{s=decodeURIComponent(a),c=decodeURIComponent(o)}catch(t){throw Error(`Failed to percent-decode OTEL_RESOURCE_ATTRIBUTES entry "${e}": ${t instanceof Error?t.message:t}`,{cause:t})}if(s.length>this._MAX_LENGTH)throw Error(`Attribute key exceeds the maximum length of ${this._MAX_LENGTH} characters: "${s}".`);if(c.length>this._MAX_LENGTH)throw Error(`Attribute value exceeds the maximum length of ${this._MAX_LENGTH} characters for key "${s}".`);t[s]=c}return t}},Sr=new xr})),wr,Tr,Er,Dr,Or,kr=e((()=>{wr=`host.arch`,Tr=`host.id`,Er=`host.name`,Dr=`os.type`,Or=`os.version`}));async function Ar(){if(!$)switch(Qe.platform){case`darwin`:$=(await import(`./getMachineId-darwin-CsRhaP3y.js`)).getMachineId;break;case`linux`:$=(await import(`./getMachineId-linux-Bd7UBNRQ.js`)).getMachineId;break;case`freebsd`:$=(await import(`./getMachineId-bsd-Cut1kHoA.js`)).getMachineId;break;case`win32`:$=(await import(`./getMachineId-win-DamF2CH_.js`)).getMachineId;break;default:$=(await import(`./getMachineId-unsupported-vFGP8E_8.js`)).getMachineId;break}return $()}var $,jr=e((()=>{})),Mr,Nr,Pr=e((()=>{Mr=e=>{switch(e){case`arm`:return`arm32`;case`ppc`:return`ppc32`;case`x64`:return`amd64`;default:return e}},Nr=e=>{switch(e){case`sunos`:return`solaris`;case`win32`:return`windows`;default:return e}}})),Fr,Ir,Lr=e((()=>{kr(),jr(),Pr(),Fr=class{detect(e){return{attributes:{[Er]:Ke(),[wr]:Mr(Ge()),[Tr]:Ar()}}}},Ir=new Fr})),Rr,zr,Br=e((()=>{kr(),Pr(),Rr=class{detect(e){return{attributes:{[Dr]:Nr(qe()),[Or]:Je()}}}},zr=new Rr})),Vr=e((()=>{Lr(),Br(),kr()})),Hr=e((()=>{Vr()})),Ur=e((()=>{Cr(),Hr()})),Wr=e((()=>{br(),Ur(),fr()}));function Gr(e){return Kr(e,new WeakSet)}function Kr(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e instanceof Uint8Array)return!0;if(typeof e==`object`){if(t.has(e))return!1;if(t.add(e),Array.isArray(e))return e.every(e=>Kr(e,t));let n=e;return n.constructor!==Object&&n.constructor!==void 0?!1:Object.values(n).every(e=>Kr(e,t))}return!1}var qr=e((()=>{})),Jr,Yr=e((()=>{f(),g(),_(),qr(),a(),Jr=class{set severityText(e){this._isLogRecordReadonly()||(this._severityText=e)}get severityText(){return this._severityText}set severityNumber(e){this._isLogRecordReadonly()||(this._severityNumber=e)}get severityNumber(){return this._severityNumber}set body(e){this._isLogRecordReadonly()||(this._body=e)}get body(){return this._body}get eventName(){return this._eventName}set eventName(e){this._isLogRecordReadonly()||(this._eventName=e)}get droppedAttributesCount(){return this._droppedAttributesCount}constructor(e,t,n){o(this,`hrTime`,void 0),o(this,`hrTimeObserved`,void 0),o(this,`spanContext`,void 0),o(this,`resource`,void 0),o(this,`instrumentationScope`,void 0),o(this,`attributes`,{}),o(this,`_severityText`,void 0),o(this,`_severityNumber`,void 0),o(this,`_body`,void 0),o(this,`_eventName`,void 0),o(this,`_attributesCount`,0),o(this,`_droppedAttributesCount`,0),o(this,`_isReadonly`,!1),o(this,`_logRecordLimits`,void 0);let{timestamp:r,observedTimestamp:i,eventName:a,severityNumber:s,severityText:c,body:l,attributes:d={},exception:f,context:p}=n,te=Date.now();if(this.hrTime=ue(r??te),this.hrTimeObserved=ue(i??te),p){let e=u.getSpanContext(p);e&&ee(e)&&(this.spanContext=e)}this.severityNumber=s,this.severityText=c,this.body=l,this.resource=e.resource,this.instrumentationScope=t,this._logRecordLimits=e.logRecordLimits,this._eventName=a,this.setAttributes(d),f!=null&&this._setException(f)}setAttribute(e,t){if(this._isLogRecordReadonly())return this;if(e.length===0)return p.warn(`Invalid attribute key: ${e}`),this;if(!Gr(t))return p.warn(`Invalid attribute value set for key: ${e}`),this;let n=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n&&this._attributesCount>=this._logRecordLimits.attributeCountLimit?(this._droppedAttributesCount++,this._droppedAttributesCount===1&&p.warn(`Dropping extra attributes.`),this):(this.attributes[e]=this._truncateToSize(t),n&&this._attributesCount++,this)}setAttributes(e){for(let[t,n]of Object.entries(e))this.setAttribute(t,n);return this}setBody(e){return this.body=e,this}setEventName(e){return this.eventName=e,this}setSeverityNumber(e){return this.severityNumber=e,this}setSeverityText(e){return this.severityText=e,this}_makeReadonly(){this._isReadonly=!0}_truncateToSize(e){let t=this._logRecordLimits.attributeValueLengthLimit;if(t<=0)return p.warn(`Attribute value limit must be positive, got ${t}`),e;if(e==null)return e;if(typeof e==`string`)return this._truncateToLimitUtil(e,t);if(e instanceof Uint8Array)return e;if(Array.isArray(e))return e.map(e=>this._truncateToSize(e));if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=this._truncateToSize(r);return t}return e}_setException(e){let t=!1;if(typeof e==`string`||typeof e==`number`)Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(se,String(e)),t=!0;else if(e&&typeof e==`object`){let n=e;n.code?(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(oe,n.code.toString()),t=!0):n.name&&(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(oe,n.name),t=!0),n.message&&(Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(se,n.message),t=!0),n.stack&&(Object.hasOwn(this.attributes,`exception.stacktrace`)||this.setAttribute(pe,n.stack),t=!0)}t||p.warn(`Failed to record an exception ${e}`)}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_isLogRecordReadonly(){return this._isReadonly&&p.warn(`Can not execute the operation on emitted log record`),this._isReadonly}}})),Xr,Zr=e((()=>{E(),f(),Yr(),a(),Xr=class{constructor(e,t){o(this,`instrumentationScope`,void 0),o(this,`_sharedState`,void 0),o(this,`_loggerConfig`,void 0),this.instrumentationScope=e,this._sharedState=t,this._loggerConfig=this._sharedState.getLoggerConfig(this.instrumentationScope)}emit(e){let t=this._loggerConfig,n=e.context||d.active(),r=e.severityNumber??y.UNSPECIFIED;if(r!==y.UNSPECIFIED&&r<t.minimumSeverity)return;if(t.traceBased){let e=u.getSpanContext(n);if(e&&ee(e)&&(e.traceFlags&l.SAMPLED)!==l.SAMPLED)return}let i=new Jr(this._sharedState,this.instrumentationScope,{context:n,...e});this._sharedState.loggerMetrics.emitLog(),this._sharedState.activeProcessor.onEmit(i,n),i._makeReadonly()}enabled(e){let t=this._loggerConfig;if(t.disabled)return!1;let n=e?.severityNumber;if(typeof n==`number`&&n!==y.UNSPECIFIED&&n<t.minimumSeverity)return!1;let r=e?.context||d.active();if(t.traceBased){let e=u.getSpanContext(r);if(e&&ee(e)&&(e.traceFlags&l.SAMPLED)!==l.SAMPLED)return!1}let i={context:r,instrumentationScope:this.instrumentationScope,severityNumber:e?.severityNumber,eventName:e?.eventName};for(let e of this._sharedState.processors)if(!e.enabled||e.enabled(i))return!0;return!1}}})),Qr,$r=e((()=>{Qr=class{forceFlush(){return Promise.resolve()}onEmit(e,t){}shutdown(){return Promise.resolve()}enabled(e){return!1}}})),ei,ti=e((()=>{g(),a(),ei=class{constructor(e,t){o(this,`processors`,void 0),o(this,`forceFlushTimeoutMillis`,void 0),this.processors=e,this.forceFlushTimeoutMillis=t}async forceFlush(){let e=this.forceFlushTimeoutMillis;await Promise.all(this.processors.map(t=>de(t.forceFlush(),e)))}onEmit(e,t){this.processors.forEach(n=>n.onEmit(e,t))}async shutdown(){await Promise.all(this.processors.map(e=>e.shutdown()))}enabled(e){for(let t of this.processors)if(!t.enabled||t.enabled(e))return!0;return!1}}}));function ni(e){return`${e.name}@${e.version||``}:${e.schemaUrl||``}`}var ri=e((()=>{})),ii,ai=e((()=>{ii=`otel.sdk.log.created`})),oi,si=e((()=>{ai(),a(),oi=class{constructor(e){o(this,`createdLogs`,void 0),this.createdLogs=e.createCounter(ii,{unit:`{log_record}`,description:`The number of logs submitted to enabled SDK Loggers.`})}emitLog(){this.createdLogs.add(1)}}})),ci,li=e((()=>{ci=`0.215.0`})),ui,di,fi,pi=e((()=>{f(),E(),$r(),ti(),ri(),si(),li(),a(),ui={disabled:!1,minimumSeverity:y.UNSPECIFIED,traceBased:!1},di=()=>({...ui}),fi=class{constructor(e,t,n,r,i,a){o(this,`loggers`,new Map),o(this,`activeProcessor`,void 0),o(this,`registeredLogRecordProcessors`,[]),o(this,`resource`,void 0),o(this,`forceFlushTimeoutMillis`,void 0),o(this,`logRecordLimits`,void 0),o(this,`processors`,void 0),o(this,`loggerMetrics`,void 0),o(this,`_loggerConfigurator`,void 0),o(this,`_loggerConfigs`,new Map),this.resource=e,this.forceFlushTimeoutMillis=t,this.logRecordLimits=n,this.processors=r,r.length>0?(this.registeredLogRecordProcessors=r,this.activeProcessor=new ei(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis)):this.activeProcessor=new Qr,this._loggerConfigurator=i??di;let c=a?a.getMeter(`@opentelemetry/sdk-logs`,ci):s();this.loggerMetrics=new oi(c)}getLoggerConfig(e){let t=ni(e),n=this._loggerConfigs.get(t);return n||(n=this._loggerConfigurator(e),this._loggerConfigs.set(t,n),n)}}})),mi,hi=e((()=>{f(),E(),he(),g(),Zr(),pi(),a(),mi=class{constructor(e={}){o(this,`_shutdownOnce`,void 0),o(this,`_sharedState`,void 0);let t={resource:e.resource??me(),forceFlushTimeoutMillis:e.forceFlushTimeoutMillis??3e4,logRecordLimits:{attributeCountLimit:e.logRecordLimits?.attributeCountLimit??128,attributeValueLengthLimit:e.logRecordLimits?.attributeValueLengthLimit??1/0},loggerConfigurator:e.loggerConfigurator??di,processors:e.processors??[],meterProvider:e.meterProvider};this._sharedState=new fi(t.resource,t.forceFlushTimeoutMillis,t.logRecordLimits,t.processors,t.loggerConfigurator,t.meterProvider),this._shutdownOnce=new le(this._shutdown,this)}getLogger(e,t,n){if(this._shutdownOnce.isCalled)return p.warn(`A shutdown LoggerProvider cannot provide a Logger`),x;e||p.warn(`Logger requested without instrumentation scope name.`);let r=e||`unknown`,i=`${r}@${t||``}:${n?.schemaUrl||``}`;return this._sharedState.loggers.has(i)||this._sharedState.loggers.set(i,new Xr({name:r,version:t,schemaUrl:n?.schemaUrl},this._sharedState)),this._sharedState.loggers.get(i)}forceFlush(){return this._shutdownOnce.isCalled?(p.warn(`invalid attempt to force flush after LoggerProvider shutdown`),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()}shutdown(){return this._shutdownOnce.isCalled?(p.warn(`shutdown may only be called once per LoggerProvider`),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.activeProcessor.shutdown()}}})),gi,_i=e((()=>{g(),gi=class{export(e,t){this._sendLogRecords(e,t)}async forceFlush(){}async shutdown(){}_exportInfo(e){return{resource:{attributes:e.resource.attributes},instrumentationScope:e.instrumentationScope,timestamp:fe(e.hrTime),traceId:e.spanContext?.traceId,spanId:e.spanContext?.spanId,traceFlags:e.spanContext?.traceFlags,severityText:e.severityText,severityNumber:e.severityNumber,eventName:e.eventName,body:e.body,attributes:e.attributes}}_sendLogRecords(e,t){for(let t of e)console.dir(this._exportInfo(t),{depth:3});t?.({code:ce.SUCCESS})}}}));async function vi(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];r.resource.asyncAttributesPending&&r.resource.waitForAsyncAttributes&&t.push(r.resource.waitForAsyncAttributes())}t!=null&&t.length>0&&await Promise.all(t)}var yi,bi,xi=e((()=>{f(),g(),a(),yi=class{constructor(e,t,n){o(this,`_exportCompleted`,void 0),o(this,`_exportScheduledPromise`,void 0),o(this,`_exportScheduledResolve`,void 0),this._exportScheduledPromise=new Promise(e=>{this._exportScheduledResolve=e}),this._exportCompleted=this._executeExport(e,t,n)}get exportCompleted(){return this._exportCompleted}get exportScheduled(){return this._exportScheduledPromise}async _executeExport(e,t,n){try{await vi(t),await d.with(te(d.active()),async()=>this._exportWithTimeout(e,t,n))}catch(e){m(e),this._exportScheduledResolve()}}async _exportWithTimeout(e,t,n){return new Promise((r,i)=>{let a=setTimeout(()=>{i(Error(`Timeout`))},n);e.export(t,e=>{clearTimeout(a),e.code===ce.SUCCESS?r():i(e.error??Error(`BatchLogRecordProcessor: log record export failed`))}),this._exportScheduledResolve()})}},bi=class{constructor(e,t){o(this,`_maxExportBatchSize`,void 0),o(this,`_maxQueueSize`,void 0),o(this,`_scheduledDelayMillis`,void 0),o(this,`_exportTimeoutMillis`,void 0),o(this,`_exporter`,void 0),o(this,`_currentExport`,null),o(this,`_finishedLogRecords`,[]),o(this,`_timer`,void 0),o(this,`_shutdownOnce`,void 0),o(this,`_flushing`,!1),this._exporter=e,this._maxExportBatchSize=t?.maxExportBatchSize??512,this._maxQueueSize=t?.maxQueueSize??2048,this._scheduledDelayMillis=t?.scheduledDelayMillis??5e3,this._exportTimeoutMillis=t?.exportTimeoutMillis??3e4,this._shutdownOnce=new le(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(p.warn(`BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize)}onEmit(e){this._shutdownOnce.isCalled||this._addToBuffer(e)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}_addToBuffer(e){this._finishedLogRecords.length>=this._maxQueueSize||(this._finishedLogRecords.push(e),this._maybeStartTimer())}shutdown(){return this._shutdownOnce.call()}async _shutdown(){this.onShutdown(),await this._flushAll(),await this._exporter.shutdown()}async _flushAll(){if(this._flushing)return;this._flushing=!0;let e=this._finishedLogRecords;for(this._finishedLogRecords=[],this._clearTimer(),this._currentExport!==null&&(await this._exporter.forceFlush(),await this._currentExport.exportCompleted,this._currentExport=null);e.length>0;){let t;e.length<=this._maxExportBatchSize?(t=e,e=[]):t=e.splice(0,this._maxExportBatchSize);let n=new yi(this._exporter,t,this._exportTimeoutMillis);this._currentExport=n;try{await n.exportScheduled,await this._exporter.forceFlush(),await n.exportCompleted}catch(e){m(e)}finally{this._currentExport=null}}this._flushing=!1,this._maybeStartTimer()}_extractBatch(){if(this._finishedLogRecords.length===0)return null;if(this._finishedLogRecords.length<=this._maxExportBatchSize){let e=this._finishedLogRecords;return this._finishedLogRecords=[],e}else return this._finishedLogRecords.splice(0,this._maxExportBatchSize)}_exportOneBatch(){this._clearTimer();let e=this._extractBatch();if(e===null)return;let t=new yi(this._exporter,e,this._exportTimeoutMillis);this._currentExport=t,t.exportCompleted.then(()=>{this._currentExport=null,this._maybeStartTimer()}).catch(e=>{this._currentExport=null,m(e),this._maybeStartTimer()})}_maybeStartTimer(){if(!this._shutdownOnce.isCalled&&!this._flushing&&this._finishedLogRecords.length!==0&&this._currentExport===null){if(this._finishedLogRecords.length>=this._maxExportBatchSize){this._exportOneBatch();return}this._timer===void 0&&(this._timer=setTimeout(()=>{this._timer=void 0,this._exportOneBatch()},this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}}})),Si,Ci=e((()=>{xi(),Si=class extends bi{onShutdown(){}}})),wi=e((()=>{Ci()})),Ti=e((()=>{wi()})),Ei=e((()=>{hi(),_i(),Ti(),E()}));export{Bt as $,An as A,hn as B,Xn as C,Dn as D,Nn as E,Tn as F,I as G,un as H,z as I,It as J,rn as K,vn as L,Mn as M,jn as N,On as O,B as P,A as Q,L as R,rr as S,Ln as T,sn as U,_n as V,an as W,zt as X,Lt as Y,Ut as Z,mr as _,_i as a,kt as at,or as b,Wr as c,jt as ct,Ir as d,yt as dt,tn as et,Lr as f,St as ft,br as g,dt as gt,hr as h,E as ht,gi as i,Wt as it,In as j,kn as k,Br as l,Et as lt,Cr as m,pt as mt,Si as n,Ft as nt,mi as o,k as ot,Sr as p,ft as pt,nn as q,Ci as r,Mt as rt,hi as s,Ot as st,Ei as t,Nt as tt,zr as u,xt as ut,X as v,H as w,sr as x,ur as y,yn as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,l as n,n as r,r as i,s as a,t as o}from"./convert-legacy-node-http-options-BZnGSjx2.js";import{n as s,s as c}from"./esm-lWlUmoUA.js";var l=256,u=512;function d(e,t){let n=e&255|l;return t&&(n|=u),n}function f(e,t){let n=e.spanContext(),r=e.status,i=e.parentSpanContext?.spanId?t.encodeSpanContext(e.parentSpanContext?.spanId):void 0;return{traceId:t.encodeSpanContext(n.traceId),spanId:t.encodeSpanContext(n.spanId),parentSpanId:i,traceState:n.traceState?.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:a(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>m(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:r.code,message:r.message},links:e.links.map(e=>p(e,t)),droppedLinksCount:e.droppedLinksCount,flags:d(n.traceFlags,e.parentSpanContext?.isRemote)}}function p(e,t){return{attributes:e.attributes?a(e.attributes,t):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:e.context.traceState?.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:d(e.context.traceFlags,e.context.isRemote)}}function m(e,t){return{attributes:e.attributes?a(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function h(e,t){return{resourceSpans:_(e,t)}}function g(e){let t=new Map;for(let n of e){let e=t.get(n.resource);e||(e=new Map,t.set(n.resource,e));let r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||``}:${n.instrumentationScope.schemaUrl||``}`,i=e.get(r);i||(i=[],e.set(r,i)),i.push(n)}return t}function _(n,r){let i=g(n),a=[],o=i.entries(),s=o.next();for(;!s.done;){let[n,i]=s.value,c=[],l=i.values(),u=l.next();for(;!u.done;){let e=u.value;if(e.length>0){let n=e.map(e=>f(e,r));c.push({scope:t(e[0].instrumentationScope),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}u=l.next()}let d=e(n,r),p={resource:d,scopeSpans:c,schemaUrl:d.schemaUrl};a.push(p),s=o.next()}return a}s();var v={serializeRequest:e=>{let t=h(e,i);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return c.warn(`Failed to parse trace export response: ${e.message}. Returning empty response`),{}}}},y=class extends n{constructor(e={}){super(r(o(e,`TRACES`,`v1/traces`,{"Content-Type":`application/json`}),v))}};export{y as OTLPTraceExporter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{a as n,i as r,l as i,n as a,r as o,s,t as c}from"./convert-legacy-node-http-options-BZnGSjx2.js";import{n as l,s as u,w as d}from"./esm-lWlUmoUA.js";import{N as f,n as p}from"./esm-BbMeEYcz.js";import{a as m,c as h,n as g,o as _,r as v}from"./esm-0CwQE5CJ.js";var y;(function(e){e[e.AGGREGATION_TEMPORALITY_UNSPECIFIED=0]=`AGGREGATION_TEMPORALITY_UNSPECIFIED`,e[e.AGGREGATION_TEMPORALITY_DELTA=1]=`AGGREGATION_TEMPORALITY_DELTA`,e[e.AGGREGATION_TEMPORALITY_CUMULATIVE=2]=`AGGREGATION_TEMPORALITY_CUMULATIVE`})(y||(y={})),l(),g();function b(e,t){let r=n(e.resource,t);return{resource:r,schemaUrl:r.schemaUrl,scopeMetrics:x(e.scopeMetrics,t)}}function x(e,t){return Array.from(e.map(e=>({scope:r(e.scope),metrics:e.metrics.map(e=>S(e,t)),schemaUrl:e.scope.schemaUrl})))}function S(e,t){let n={name:e.descriptor.name,description:e.descriptor.description,unit:e.descriptor.unit},r=D(e.aggregationTemporality);switch(e.dataPointType){case m.SUM:n.sum={aggregationTemporality:r,isMonotonic:e.isMonotonic,dataPoints:w(e,t)};break;case m.GAUGE:n.gauge={dataPoints:w(e,t)};break;case m.HISTOGRAM:n.histogram={aggregationTemporality:r,dataPoints:T(e,t)};break;case m.EXPONENTIAL_HISTOGRAM:n.exponentialHistogram={aggregationTemporality:r,dataPoints:E(e,t)};break}return n}function C(e,t,n){let r={attributes:s(e.attributes,n),startTimeUnixNano:n.encodeHrTime(e.startTime),timeUnixNano:n.encodeHrTime(e.endTime)};switch(t){case d.INT:r.asInt=e.value;break;case d.DOUBLE:r.asDouble=e.value;break}return r}function w(e,t){return e.dataPoints.map(n=>C(n,e.descriptor.valueType,t))}function T(e,t){return e.dataPoints.map(e=>{let n=e.value;return{attributes:s(e.attributes,t),bucketCounts:n.buckets.counts,explicitBounds:n.buckets.boundaries,count:n.count,sum:n.sum,min:n.min,max:n.max,startTimeUnixNano:t.encodeHrTime(e.startTime),timeUnixNano:t.encodeHrTime(e.endTime)}})}function E(e,t){return e.dataPoints.map(e=>{let n=e.value;return{attributes:s(e.attributes,t),count:n.count,min:n.min,max:n.max,sum:n.sum,positive:{offset:n.positive.offset,bucketCounts:n.positive.bucketCounts},negative:{offset:n.negative.offset,bucketCounts:n.negative.bucketCounts},scale:n.scale,zeroCount:n.zeroCount,startTimeUnixNano:t.encodeHrTime(e.startTime),timeUnixNano:t.encodeHrTime(e.endTime)}})}function D(e){switch(e){case h.DELTA:return y.AGGREGATION_TEMPORALITY_DELTA;case h.CUMULATIVE:return y.AGGREGATION_TEMPORALITY_CUMULATIVE}}function O(e,t){return{resourceMetrics:e.map(e=>b(e,t))}}l();var k={serializeRequest:e=>{let t=O([e],o);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return u.warn(`Failed to parse metrics export response: ${e.message}. Returning empty response`),{}}}},A;(function(e){e[e.DELTA=0]=`DELTA`,e[e.CUMULATIVE=1]=`CUMULATIVE`,e[e.LOWMEMORY=2]=`LOWMEMORY`})(A||(A={})),p(),g(),l(),e();var j=()=>h.CUMULATIVE,M=e=>{switch(e){case _.COUNTER:case _.OBSERVABLE_COUNTER:case _.GAUGE:case _.HISTOGRAM:case _.OBSERVABLE_GAUGE:return h.DELTA;case _.UP_DOWN_COUNTER:case _.OBSERVABLE_UP_DOWN_COUNTER:return h.CUMULATIVE}},N=e=>{switch(e){case _.COUNTER:case _.HISTOGRAM:return h.DELTA;case _.GAUGE:case _.UP_DOWN_COUNTER:case _.OBSERVABLE_UP_DOWN_COUNTER:case _.OBSERVABLE_COUNTER:case _.OBSERVABLE_GAUGE:return h.CUMULATIVE}};function P(){let e=(f(`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE`)??`cumulative`).toLowerCase();return e===`cumulative`?j:e===`delta`?M:e===`lowmemory`?N:(u.warn(`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '${e}', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead.`),j)}function F(e){return e==null?P():e===A.DELTA?M:e===A.LOWMEMORY?N:j}var I=Object.freeze({type:v.DEFAULT});function L(e){return e?.aggregationPreference??(()=>I)}var R=class extends i{constructor(e,n){super(e),t(this,`_aggregationTemporalitySelector`,void 0),t(this,`_aggregationSelector`,void 0),this._aggregationSelector=L(n),this._aggregationTemporalitySelector=F(n?.temporalityPreference)}selectAggregation(e){return this._aggregationSelector(e)}selectAggregationTemporality(e){return this._aggregationTemporalitySelector(e)}},z=class extends R{constructor(e){super(a(c(e??{},`METRICS`,`v1/metrics`,{"Content-Type":`application/json`}),k),e)}};export{z as OTLPMetricExporter};
|