claude-code-zanii 2.8.4
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/README.md +146 -0
- package/dist/chunks/AddWorkspaceDirectory-y_rd6sRl.js +1 -0
- package/dist/chunks/App-DgWSavG1.js +1 -0
- package/dist/chunks/ApproveApiKey-CJKWha-a.js +1 -0
- package/dist/chunks/ApproveApiKey-DTs2ExZH.js +1 -0
- package/dist/chunks/AssistantSessionChooser-BAhVk4id.js +1 -0
- package/dist/chunks/BackgroundTasksDialog-XU_JPh7R.js +2 -0
- package/dist/chunks/BypassPermissionsModeDialog-DV0Pi7ys.js +1 -0
- package/dist/chunks/ClaudeInChromeOnboarding-6erm_8Fn.js +1 -0
- package/dist/chunks/ClaudeMdExternalIncludesDialog-CjBvzB5s.js +1 -0
- package/dist/chunks/ClaudeMdExternalIncludesDialog-ts0XnWwl.js +1 -0
- package/dist/chunks/ConsoleOAuthFlow-DySPdSqQ.js +1 -0
- package/dist/chunks/CustomSelect-DqZxzBZP.js +1 -0
- package/dist/chunks/DesktopHandoff-5c90JK88.js +1 -0
- package/dist/chunks/DevChannelsDialog-DCMderzu.js +1 -0
- package/dist/chunks/Dialog-Dgg8bqcG.js +1 -0
- package/dist/chunks/DiffDialog-BU765aqh.js +6 -0
- package/dist/chunks/Doctor-B73iDB-d.js +3 -0
- package/dist/chunks/Doctor-CLZDdNRo.js +1 -0
- package/dist/chunks/ExitFlow-DBqn2mUf.js +2 -0
- package/dist/chunks/Feedback-D-JHabwi.js +2 -0
- package/dist/chunks/Grove-D-uQNMMo.js +11 -0
- package/dist/chunks/HybridTransport-B-G4QJcy.js +4 -0
- package/dist/chunks/ITermBackend-KP1vKsRN.js +1 -0
- package/dist/chunks/InProcessTransport-ByBEKxrQ.js +1 -0
- package/dist/chunks/InvalidConfigDialog-CMqiZ5nG.js +1 -0
- package/dist/chunks/InvalidSettingsDialog-CjPCKzVZ.js +1 -0
- package/dist/chunks/ListItem-B6MyhHvM.js +1 -0
- package/dist/chunks/MCPConnectionManager-BJ8PcYPe.js +1 -0
- package/dist/chunks/Message-DNxJ_tMS.js +1 -0
- package/dist/chunks/MessageSelector-D79Ug71B.js +3 -0
- package/dist/chunks/Messages-CtIbkB2M.js +11 -0
- package/dist/chunks/Onboarding-DVrgKrI9.js +1 -0
- package/dist/chunks/OverageCreditUpsell-D_td1ss4.js +1 -0
- package/dist/chunks/PermissionDialog-BCS22yEO.js +1 -0
- package/dist/chunks/PermissionDialog-C5O1fL53.js +1 -0
- package/dist/chunks/PermissionRequestTitle-CtlbBU9t.js +1 -0
- package/dist/chunks/PluginSettings-OPrg-_3N.js +17 -0
- package/dist/chunks/PressEnterToContinue-DmzxIgbZ.js +1 -0
- package/dist/chunks/PromptInputFooterSuggestions-CcsKj5DK.js +1 -0
- package/dist/chunks/PromptInputHelpMenu-JedFdsxU.js +1 -0
- package/dist/chunks/REPL-ByhyIRnf.js +1 -0
- package/dist/chunks/REPL-Clve-8zC.js +157 -0
- package/dist/chunks/RemoteCallout-BZcabEKb.js +1 -0
- package/dist/chunks/RemoteSessionManager-C2PIFDHt.js +1 -0
- package/dist/chunks/ResumeConversation-D3ZRTFcF.js +1 -0
- package/dist/chunks/SSETransport-DmZWnH0k.js +4 -0
- package/dist/chunks/SearchBox-DQg2Ph0V.js +1 -0
- package/dist/chunks/SearchExtraToolsTool-CLO4nt6N.js +1 -0
- package/dist/chunks/SentryErrorBoundary-BVfBaOOU.js +2 -0
- package/dist/chunks/SentryErrorBoundary-DIaVFad-.js +1 -0
- package/dist/chunks/Settings-rOCxQdS8.js +2 -0
- package/dist/chunks/TeleportProgress-CP8IY6bz.js +1 -0
- package/dist/chunks/TeleportRepoMismatchDialog-DMmHgBqo.js +1 -0
- package/dist/chunks/TeleportResumeWrapper-D5wEAW1-.js +1 -0
- package/dist/chunks/ThemePicker-Bgr7yOQB.js +1 -0
- package/dist/chunks/TmuxBackend-BzbtUtP1.js +9 -0
- package/dist/chunks/TrustDialog-BI5U3BQ0.js +1 -0
- package/dist/chunks/TungstenTool-CiQclNwj.js +1 -0
- package/dist/chunks/TungstenTool-kMqy-ifa.js +1 -0
- package/dist/chunks/ValidationErrorsList-DprGtB2w.js +2 -0
- package/dist/chunks/WelcomeV2-C4vfBnIy.js +1 -0
- package/dist/chunks/WindowsTerminalBackend-BSoezOCE.js +2 -0
- package/dist/chunks/add-dir-DpOmv6kv.js +1 -0
- package/dist/chunks/agentDisplay-DuYEwOwO.js +1 -0
- package/dist/chunks/agents-BlurXZrF.js +2 -0
- package/dist/chunks/agents-DhZf7ftU.js +103 -0
- package/dist/chunks/ajv-CDrSAj3O.js +8 -0
- package/dist/chunks/analytics-i6X1et4O.js +1 -0
- package/dist/chunks/ant-D9hd_iYy.js +1 -0
- package/dist/chunks/api-CoaOHwDQ.js +4 -0
- package/dist/chunks/api-DvyGR-L7.js +1 -0
- package/dist/chunks/api-YHYC4Zdk.js +1 -0
- package/dist/chunks/artifacts-BMAYdaqh.js +1 -0
- package/dist/chunks/asciicast-DpHRoebc.js +1 -0
- package/dist/chunks/asciicast-HG1EoAQe.js +4 -0
- package/dist/chunks/assistant-D4-qcNT1.js +1 -0
- package/dist/chunks/assistant-DO2ZmZn1.js +1 -0
- package/dist/chunks/assistant-Dd86NmJM.js +1 -0
- package/dist/chunks/attributionHooks-BUmHrLhB.js +1 -0
- package/dist/chunks/attributionTrailer-r2Pbpu2N.js +1 -0
- package/dist/chunks/auth-CF3BGNYT.js +1 -0
- package/dist/chunks/auth-DwWwG43F.js +1 -0
- package/dist/chunks/auth-V_Xk2iea.js +1 -0
- package/dist/chunks/autoMode-DUksX5_i.js +45 -0
- package/dist/chunks/autoModeDenials-0CPO-Jbu.js +1 -0
- package/dist/chunks/autonomy-C5mNhAdz.js +21 -0
- package/dist/chunks/autonomy-CLt1dWaC.js +1 -0
- package/dist/chunks/autonomyPanel-rioFnrQO.js +1 -0
- package/dist/chunks/axios-DPuSPBlH.js +1 -0
- package/dist/chunks/axios-Zh7qGPze.js +12 -0
- package/dist/chunks/backgroundHousekeeping-BGtfqu-J.js +1 -0
- package/dist/chunks/backgroundHousekeeping-BqKZEvy0.js +17 -0
- package/dist/chunks/banner-BGLr3KYQ.js +2 -0
- package/dist/chunks/base64-js-B1tFNiG0.js +1 -0
- package/dist/chunks/bedrockClient-BFzWuhQK.js +15 -0
- package/dist/chunks/bg-B-YgGwLj.js +9 -0
- package/dist/chunks/bg-IU4gG3jc.js +1 -0
- package/dist/chunks/branch-BWY5W7hf.js +3 -0
- package/dist/chunks/break-cache-CY-O23fJ.js +8 -0
- package/dist/chunks/bridge-CqWd70vK.js +2 -0
- package/dist/chunks/bridgeConfig-CWO8AmCY.js +1 -0
- package/dist/chunks/bridgeConfig-D38y9eXn.js +1 -0
- package/dist/chunks/bridgeConfig-EwUq__ct.js +1 -0
- package/dist/chunks/bridgeConfig-GYR-LUiu.js +1 -0
- package/dist/chunks/bridgeEnabled-DKqmLnKO.js +1 -0
- package/dist/chunks/bridgeEnabled-DZIGDtfY.js +1 -0
- package/dist/chunks/bridgeMain-CXVks2ND.js +1 -0
- package/dist/chunks/bridgeMain-D4nsECwJ.js +68 -0
- package/dist/chunks/bridgeMessaging-BUOZU_ba.js +1 -0
- package/dist/chunks/bridgePointer-BpzIEsD_.js +1 -0
- package/dist/chunks/browser-D1vC3BNd.js +1 -0
- package/dist/chunks/btw-CVXJwoXo.js +1 -0
- package/dist/chunks/buddy-BLcvL8lP.js +3 -0
- package/dist/chunks/bundledMode-DQNSSQbt.js +1 -0
- package/dist/chunks/caches-BrfvzKn5.js +1 -0
- package/dist/chunks/caches-CkSv3MfC.js +3 -0
- package/dist/chunks/capacityWake-BWCSatN6.js +1 -0
- package/dist/chunks/changeDetector-DEZU6tum.js +1 -0
- package/dist/chunks/changeDetector-Df7c6U3d.js +1 -0
- package/dist/chunks/channelAllowlist-BApjAS0V.js +1 -0
- package/dist/chunks/channelNotification-BjWwF85R.js +1 -0
- package/dist/chunks/channelNotification-D01YVwNj.js +1 -0
- package/dist/chunks/chokidar-DPwMBcWI.js +1 -0
- package/dist/chunks/chokidar-DkDXNCTz.js +1 -0
- package/dist/chunks/chrome-D7coxEOI.js +1 -0
- package/dist/chunks/chromeNativeHost-CPj9M_4-.js +1 -0
- package/dist/chunks/chunk-DR8-3Aex.js +1 -0
- package/dist/chunks/classPrivateFieldSet2-DZkxcFPS.js +1 -0
- package/dist/chunks/claudeAiLimitsHook-ATshVrOH.js +1 -0
- package/dist/chunks/claudeDesktop-PVa9tWsM.js +1 -0
- package/dist/chunks/cleanup-C-PGmKpV.js +1 -0
- package/dist/chunks/clear-CxGE9Ntr.js +1 -0
- package/dist/chunks/cliLaunch-CMXoY_LO.js +1 -0
- package/dist/chunks/client-BWED8Tbu.js +35 -0
- package/dist/chunks/client-CinDjeSq.js +7 -0
- package/dist/chunks/client-CpXGg9e0.js +1 -0
- package/dist/chunks/color-B3w_VQTn.js +1 -0
- package/dist/chunks/color-convert-BQZnVz_5.js +1 -0
- package/dist/chunks/commands-DFp48zwy.js +1 -0
- package/dist/chunks/commitAttribution-B0cXmbvv.js +2 -0
- package/dist/chunks/commitAttribution-DRSKRoH6.js +1 -0
- package/dist/chunks/common-BX7bn3hg.js +1 -0
- package/dist/chunks/common-Ce3LanTX.js +1 -0
- package/dist/chunks/common-DdLQuE2_.js +1 -0
- package/dist/chunks/common-HfKcqOYK.js +1 -0
- package/dist/chunks/compact-C8ljGMdo.js +3 -0
- package/dist/chunks/companion-mD1jw6xX.js +1 -0
- package/dist/chunks/completionCache-BqQXVTa9.js +1 -0
- package/dist/chunks/completionCache-BtP4vfAi.js +4 -0
- package/dist/chunks/computerUseLock-ADE_PhIK.js +1 -0
- package/dist/chunks/config-CmyaIIOY.js +1 -0
- package/dist/chunks/config-Rl1Y_Dtq.js +1 -0
- package/dist/chunks/connectHeadless-MFABhXpz.js +1 -0
- package/dist/chunks/constants-BM62Vf_X.js +1 -0
- package/dist/chunks/constants-BfXy-5cI.js +1 -0
- package/dist/chunks/context-BeiZkUNq.js +1 -0
- package/dist/chunks/context-noninteractive-CRdF3iv8.js +54 -0
- package/dist/chunks/controlMessageCompat-591iGHUK.js +1 -0
- package/dist/chunks/conversation-BoguXZEI.js +1 -0
- package/dist/chunks/conversation-yhs7tT-g.js +1 -0
- package/dist/chunks/copy-BpeUcqku.js +7 -0
- package/dist/chunks/createSSHSession-B3JOB4TE.js +6 -0
- package/dist/chunks/createSession-BJSnFBGt.js +1 -0
- package/dist/chunks/createSession-CnRHI3RU.js +1 -0
- package/dist/chunks/cron-iqTFGIos.js +1 -0
- package/dist/chunks/cronScheduler-zRXhgEEU.js +6 -0
- package/dist/chunks/cronTasks-CMJldfoP.js +2 -0
- package/dist/chunks/crossProjectResume-DxO6TX30.js +40 -0
- package/dist/chunks/cwd-B2guYBbl.js +1 -0
- package/dist/chunks/cwd-B5bbyUwz.js +1 -0
- package/dist/chunks/cwd-BXiaJzLh.js +1 -0
- package/dist/chunks/daemon-B3v4OoOu.js +2 -0
- package/dist/chunks/dangerousBackend-OmCzoW35.js +1 -0
- package/dist/chunks/datadog-3-Vvz0yz.js +1 -0
- package/dist/chunks/datadog-BQlp3bTs.js +1 -0
- package/dist/chunks/debug-BDBIipC1.js +2 -0
- package/dist/chunks/debug-C7tW7DFW.js +1 -0
- package/dist/chunks/debug-CjIaNjpK.js +5 -0
- package/dist/chunks/debugUtils-Dsg-UHeg.js +1 -0
- package/dist/chunks/defineProperty-CaCI0a5T.js +1 -0
- package/dist/chunks/desktop-C_SS0068.js +1 -0
- package/dist/chunks/detached-B7RNZeyl.js +5 -0
- package/dist/chunks/detect-libc-DFFGDzPC.js +1 -0
- package/dist/chunks/detectRepository-BnTCJAXR.js +1 -0
- package/dist/chunks/detectRepository-Gobn9eFt.js +1 -0
- package/dist/chunks/detection-CN_uLGU2.js +1 -0
- package/dist/chunks/detection-DW6grIlc.js +1 -0
- package/dist/chunks/diff-B8YmRG5T.js +1 -0
- package/dist/chunks/directoryCompletion-J560aATd.js +1 -0
- package/dist/chunks/dist-B1wOprSs.js +29 -0
- package/dist/chunks/dist-DZQOarNX.js +5 -0
- package/dist/chunks/dist-HZfkKiUF.js +20 -0
- package/dist/chunks/dist-es-4xyrZoNc2.js +1 -0
- package/dist/chunks/dist-es-6kjvVbJd.js +1 -0
- package/dist/chunks/dist-es-BJldFHbt.js +3 -0
- package/dist/chunks/dist-es-BM013UFT.js +1 -0
- package/dist/chunks/dist-es-BPPewn1A.js +1 -0
- package/dist/chunks/dist-es-BZGG3Hnm.js +1 -0
- package/dist/chunks/dist-es-BZjJL64k2.js +1 -0
- package/dist/chunks/dist-es-BctcPxLN.js +1 -0
- package/dist/chunks/dist-es-Bf2jR30y.js +1 -0
- package/dist/chunks/dist-es-BgLoR-hQ.js +1 -0
- package/dist/chunks/dist-es-BismPcTW.js +1 -0
- package/dist/chunks/dist-es-BrPzXmSP.js +1 -0
- package/dist/chunks/dist-es-Bu21Wvhs.js +1 -0
- package/dist/chunks/dist-es-BuWNNAXW.js +1 -0
- package/dist/chunks/dist-es-Bz11sFiK2.js +1 -0
- package/dist/chunks/dist-es-C5VplyPL2.js +5 -0
- package/dist/chunks/dist-es-C66BuLgn.js +1 -0
- package/dist/chunks/dist-es-CCIzgNln2.js +1 -0
- package/dist/chunks/dist-es-CLyx7Kge2.js +1 -0
- package/dist/chunks/dist-es-CUbatGdn.js +1 -0
- package/dist/chunks/dist-es-CYe_-TbD.js +1 -0
- package/dist/chunks/dist-es-C_IHUdzL.js +1 -0
- package/dist/chunks/dist-es-Ci_rKlMr.js +1 -0
- package/dist/chunks/dist-es-ClDZBAj7.js +1 -0
- package/dist/chunks/dist-es-Cp--qjOi.js +1 -0
- package/dist/chunks/dist-es-CzE4kW1L.js +9 -0
- package/dist/chunks/dist-es-DUg5w7-v.js +1 -0
- package/dist/chunks/dist-es-Dl0ZRczY.js +1 -0
- package/dist/chunks/dist-es-Do_155z5.js +1 -0
- package/dist/chunks/dist-es-DxIM0jd82.js +1 -0
- package/dist/chunks/dist-es-Fav2oBDs.js +1 -0
- package/dist/chunks/dist-es-TZjwPaGn.js +1 -0
- package/dist/chunks/dist-es-W22ud2el2.js +1 -0
- package/dist/chunks/dist-es-aU8-02YH.js +1 -0
- package/dist/chunks/dist-es-b3yZSGx82.js +1 -0
- package/dist/chunks/dist-es-dIP5JtXz.js +5 -0
- package/dist/chunks/dist-es-mQ4HvnYs2.js +1 -0
- package/dist/chunks/distRoot-CJaacAHy.js +1 -0
- package/dist/chunks/doctor-DLZPF4iY.js +1 -0
- package/dist/chunks/earlyInput-BTI1CSNt.js +2 -0
- package/dist/chunks/earlyInput-BwGtzhhP.js +1 -0
- package/dist/chunks/effort-BaHvpBWr.js +9 -0
- package/dist/chunks/entry-_e-lyRwv.js +14 -0
- package/dist/chunks/env-CesrOJJq.js +1 -0
- package/dist/chunks/envLessBridgeConfig-4oys0_9A.js +1 -0
- package/dist/chunks/envLessBridgeConfig-DJ1Sts3F.js +1 -0
- package/dist/chunks/envUtils-CFG7IQID.js +1 -0
- package/dist/chunks/errorLogSink-Ti4Suoz6.js +2 -0
- package/dist/chunks/escHotkey-CVn_80xM.js +259 -0
- package/dist/chunks/esm-BFnjHW38.js +1 -0
- package/dist/chunks/esm-BQg_LX3V.js +1 -0
- package/dist/chunks/esm-BtC6CMmM.js +1 -0
- package/dist/chunks/esm-BwzC0MQp.js +1 -0
- package/dist/chunks/esm-CFybeQ_Q.js +1 -0
- package/dist/chunks/esm-CK-5CT5X.js +1 -0
- package/dist/chunks/esm-CL1OwlZB.js +1 -0
- package/dist/chunks/esm-CMzgSTAl.js +1 -0
- package/dist/chunks/esm-CPE_H2Lx.js +1 -0
- package/dist/chunks/esm-CcWquv5a.js +10 -0
- package/dist/chunks/esm-CeNEpRZt.js +1 -0
- package/dist/chunks/esm-D7hykoRB.js +1 -0
- package/dist/chunks/esm-DUtcefEV.js +1 -0
- package/dist/chunks/esm-DhrUwJBp.js +1 -0
- package/dist/chunks/esm-Duu1fRQ8.js +1 -0
- package/dist/chunks/esm-Ght2BaU2.js +1 -0
- package/dist/chunks/esm-Q6Yz2GMx.js +56 -0
- package/dist/chunks/esm-WONEiurY.js +13 -0
- package/dist/chunks/event-streams-BumpU1aB.js +1 -0
- package/dist/chunks/eventLoopStallDetector-DxyFdg1h.js +1 -0
- package/dist/chunks/execAsync-ChKxDZ8C.js +1 -0
- package/dist/chunks/execFileNoThrow-DdmR1mBS.js +1 -0
- package/dist/chunks/execSyncWrapper-Ch4TNj8u.js +1 -0
- package/dist/chunks/execa-BMaINL7N.js +34 -0
- package/dist/chunks/executor-C7INr19-.js +1 -0
- package/dist/chunks/executor-Dnf3YYma.js +1604 -0
- package/dist/chunks/exit-BakzsOD0.js +1 -0
- package/dist/chunks/exit-CiDn2tN9.js +2 -0
- package/dist/chunks/export-b-6pqMqz.js +2 -0
- package/dist/chunks/exportRenderer-RxtEIyTm.js +1 -0
- package/dist/chunks/extra-usage-7EPJNjNW.js +1 -0
- package/dist/chunks/extra-usage-ChvuewCq.js +1 -0
- package/dist/chunks/extra-usage-core-BVhLtoDF.js +1 -0
- package/dist/chunks/extra-usage-noninteractive-_Njh6q-q.js +1 -0
- package/dist/chunks/extraUsage-qOBMQB6g.js +1 -0
- package/dist/chunks/extractMemories-CRBVNiG1.js +1 -0
- package/dist/chunks/fast-C4uw_g7o.js +1 -0
- package/dist/chunks/fast-CEaIzaPl.js +1 -0
- package/dist/chunks/featureCheck-B1GSTyhh.js +1 -0
- package/dist/chunks/featureCheck-DKigAPal.js +1 -0
- package/dist/chunks/feedback-Bf3TjjuD.js +1 -0
- package/dist/chunks/figures-fES5sASd.js +1 -0
- package/dist/chunks/fileStateCache-DAsLEZau.js +1 -0
- package/dist/chunks/files-B-m_4X8b.js +2 -0
- package/dist/chunks/findExecutable-D8vJrFnO.js +1 -0
- package/dist/chunks/firstPartyEventLogger-BtrGagNa.js +1 -0
- package/dist/chunks/flushGate-2zqab-Pp.js +1 -0
- package/dist/chunks/foundry-sdk-CtX8C0x3.js +1 -0
- package/dist/chunks/fpsMetrics-ts_jaF3g.js +1 -0
- package/dist/chunks/fuse-ivQ_eRwF.js +1 -0
- package/dist/chunks/gates-CmKoQ0O-.js +1 -0
- package/dist/chunks/gates-_wbPDQ3M.js +1 -0
- package/dist/chunks/gemini-DRx495gn.js +3 -0
- package/dist/chunks/generateRecap-Cv8gd_QF.js +1 -0
- package/dist/chunks/generateSessionName-Dpjg-u_x.js +1 -0
- package/dist/chunks/genericProcessUtils-BFJMxLqn.js +23 -0
- package/dist/chunks/getMachineId-bsd-C9pL9Ajr.js +1 -0
- package/dist/chunks/getMachineId-darwin-Ma4F9rJg.js +2 -0
- package/dist/chunks/getMachineId-linux-C0lXMqsj.js +1 -0
- package/dist/chunks/getMachineId-unsupported-ByHQTXat.js +1 -0
- package/dist/chunks/getMachineId-win-DZsXZmTz.js +1 -0
- package/dist/chunks/git-Bj8Ow4pJ.js +6 -0
- package/dist/chunks/git-Q_b4oZ17.js +1 -0
- package/dist/chunks/githubRepoPathMapping-DGivBX9h.js +1 -0
- package/dist/chunks/goal-BrHEJv8o.js +3 -0
- package/dist/chunks/goalStorage-CsuPOQbk.js +1 -0
- package/dist/chunks/graceful-fs-BuPWC-vB.js +2 -0
- package/dist/chunks/grok-CDkDDaY_.js +1 -0
- package/dist/chunks/growthbook-D3_Cr9n-.js +1 -0
- package/dist/chunks/growthbook-p4aJ_UMv.js +32 -0
- package/dist/chunks/hash-KW-tVnPp.js +1 -0
- package/dist/chunks/heapdump-CloylIZ9.js +5 -0
- package/dist/chunks/help-DpSJlHIc.js +1 -0
- package/dist/chunks/hooks-2pogt8nv.js +79 -0
- package/dist/chunks/hooks-BBODdwnE.js +1 -0
- package/dist/chunks/hostAdapter-B5KTUqhv.js +1 -0
- package/dist/chunks/hostGuard-DyWr2TwE.js +1 -0
- package/dist/chunks/httpAuthSchemes-CgPbtGos.js +13 -0
- package/dist/chunks/ide-CJEcfBZq.js +2 -0
- package/dist/chunks/inboundAttachments-RNpYpRTO.js +1 -0
- package/dist/chunks/index.min-DCDiLq-j.js +1 -0
- package/dist/chunks/initReplBridge-D2E6IM2B.js +1 -0
- package/dist/chunks/initReplBridge-p2uwDBPx.js +1 -0
- package/dist/chunks/insights-DnpZScKs.js +822 -0
- package/dist/chunks/install-D_vTxUlG.js +1 -0
- package/dist/chunks/install-github-app-BK8A7g3i.js +147 -0
- package/dist/chunks/install-slack-app-C47R9VoI.js +1 -0
- package/dist/chunks/instinctParser-DxKdI3JC.js +1 -0
- package/dist/chunks/instrumentation-DkdAJFrZ.js +12 -0
- package/dist/chunks/intl-Pse97ORk.js +1 -0
- package/dist/chunks/isObject-DaxDnPKm.js +1 -0
- package/dist/chunks/isSymbol-D7QeUnS5.js +1 -0
- package/dist/chunks/job-opl00C4l.js +2 -0
- package/dist/chunks/json-bigint-BRRVs1dv.js +8 -0
- package/dist/chunks/jsx-runtime-BTgGEFjL.js +1 -0
- package/dist/chunks/jws-B_ieuaZg.js +3 -0
- package/dist/chunks/jwtUtils-D-tJzoJY.js +1 -0
- package/dist/chunks/keybindings-mRf9VSe8.js +2 -0
- package/dist/chunks/lang-eH4EJErj.js +1 -0
- package/dist/chunks/language-DD9ar6RA.js +1 -0
- package/dist/chunks/language-EZLNdETg.js +1 -0
- package/dist/chunks/launchAgentsPlatform-Cq0_7-IM.js +1 -0
- package/dist/chunks/launchAutofixPr-Bw7aUHUs.js +18 -0
- package/dist/chunks/launchCommand-Bk1Fn-qZ.js +1 -0
- package/dist/chunks/launchLocalMemory-CLBCUgwd.js +3 -0
- package/dist/chunks/launchLocalVault-BfWJWrBg.js +3 -0
- package/dist/chunks/launchMemoryStores-DdnSVSDZ.js +1 -0
- package/dist/chunks/launchOnboarding-ziCEX3GI.js +8 -0
- package/dist/chunks/launchSchedule-G_c7sgmy.js +1 -0
- package/dist/chunks/launchSkillStore-Z1Kd7nCg.js +1 -0
- package/dist/chunks/launchTeleport-Dp9AFbPx.js +3 -0
- package/dist/chunks/launchVault-hwK-Ljek.js +1 -0
- package/dist/chunks/lazySchema-2sOku3cX.js +1 -0
- package/dist/chunks/lib-BHRYgENJ.js +8 -0
- package/dist/chunks/lib-DRyNc7xD.js +2 -0
- package/dist/chunks/lib-Ddq71jM5.js +14 -0
- package/dist/chunks/loadAgentsDir-Bz0FfcVt.js +5620 -0
- package/dist/chunks/loadAgentsDir-CLM0ws7u.js +1 -0
- package/dist/chunks/loadPluginHooks-B5SIS2uo.js +1 -0
- package/dist/chunks/loadSso-RY87rrJO.js +1 -0
- package/dist/chunks/localSearch-BLF6PSv2.js +1 -0
- package/dist/chunks/localSearch-CTycGe3E.js +1 -0
- package/dist/chunks/localSearch-inDahM8I.js +1 -0
- package/dist/chunks/lockfile--gk1HDM6.js +1 -0
- package/dist/chunks/log-B-Nj3Yed.js +1 -0
- package/dist/chunks/log-DVv8YiNo.js +1 -0
- package/dist/chunks/login-BeLvLowc.js +1 -0
- package/dist/chunks/login-DUUOeNoz.js +1 -0
- package/dist/chunks/logoV2Utils-D5SpeZ3C.js +1 -0
- package/dist/chunks/logout-C2QuTBdS.js +1 -0
- package/dist/chunks/magicDocs-CUXKi-Wv.js +57 -0
- package/dist/chunks/main-CFhpWtpC.js +1420 -0
- package/dist/chunks/main-sboa5RKc.js +31 -0
- package/dist/chunks/mappers-DLkk0PZz.js +1 -0
- package/dist/chunks/mcp-C2f6IgAp.js +2 -0
- package/dist/chunks/mcp-Djui9m3_.js +6 -0
- package/dist/chunks/mcp-DvTSxrJ4.js +1 -0
- package/dist/chunks/mcpServer-DMA0bdFC.js +1 -0
- package/dist/chunks/mcpServer-DxEHfW2v.js +1 -0
- package/dist/chunks/memoize-Bg2dXTzV.js +1 -0
- package/dist/chunks/memoize-DNnuA2aU.js +1 -0
- package/dist/chunks/memory-B9io9Zcv.js +1 -0
- package/dist/chunks/mobile-CPnnvkQV.js +2 -0
- package/dist/chunks/modalContext-B1b0Gsro.js +1 -0
- package/dist/chunks/mode-BDgwh_Xb.js +2 -0
- package/dist/chunks/model-B6cpEh-s.js +1 -0
- package/dist/chunks/model-BcunOCC9.js +1 -0
- package/dist/chunks/modelOptions-CHUHQ9WG.js +1 -0
- package/dist/chunks/normalization-cjPqid31.js +1 -0
- package/dist/chunks/oauth-CnBLewrU.js +1 -0
- package/dist/chunks/oauth-DMPGYAoZ.js +1 -0
- package/dist/chunks/observationStore-DVBxrSdI.js +4 -0
- package/dist/chunks/onChangeAppState-M61XDN6V.js +1 -0
- package/dist/chunks/open-CsUNPSNx.js +1 -0
- package/dist/chunks/openai-BHvlYW3m.js +2 -0
- package/dist/chunks/output-style-BtKuBrs4.js +1 -0
- package/dist/chunks/outputStyles-hHuIBkRB.js +84 -0
- package/dist/chunks/overageCreditGrant-BLFT-rF3.js +1 -0
- package/dist/chunks/p-map-C-WNcN6g.js +1 -0
- package/dist/chunks/p-map-CQ2NythB.js +1 -0
- package/dist/chunks/package-9IAs5Qf0.js +1 -0
- package/dist/chunks/panel-27xLZI7c.js +1 -0
- package/dist/chunks/panel-NoDfShEZ.js +1 -0
- package/dist/chunks/panelCall-CEOWVNCM.js +1 -0
- package/dist/chunks/parseConnectUrl-CxU4IX9o.js +1 -0
- package/dist/chunks/parser-DGlAnaNj.js +1 -0
- package/dist/chunks/parser-DGoLe2RS.js +1 -0
- package/dist/chunks/passes-CExcqu66.js +1 -0
- package/dist/chunks/path-uaxlnhva.js +1 -0
- package/dist/chunks/permissions-B3PceQul.js +1 -0
- package/dist/chunks/permissions-DezIL2xF.js +3 -0
- package/dist/chunks/permissions-DnpI8Whh.js +1 -0
- package/dist/chunks/pipeTransport-CB_Wq_Kx.js +1 -0
- package/dist/chunks/plan-cfZBclh9.js +1 -0
- package/dist/chunks/platform-BXz_rgpy.js +2 -0
- package/dist/chunks/plist-DLGDWBD6.js +6 -0
- package/dist/chunks/plugin-CuhENLRs.js +1 -0
- package/dist/chunks/pluginAutoupdate-wTeOXfQe.js +1 -0
- package/dist/chunks/pluginBlocklist-D6pkKfXr.js +1 -0
- package/dist/chunks/pluginCliCommands-DqxdCwsq.js +1 -0
- package/dist/chunks/pluginFlagging-CjH48f-K.js +1 -0
- package/dist/chunks/pluginOperations-DMFYB3pK.js +2 -0
- package/dist/chunks/pluginStartupCheck-BW3_KfZz.js +1 -0
- package/dist/chunks/pluginStartupCheck-Cj2BMjVw.js +1 -0
- package/dist/chunks/plugins-CarsG2v8.js +4 -0
- package/dist/chunks/policyLimits-DFn1vHkN.js +1 -0
- package/dist/chunks/pollConfig-C8nODJY1.js +1 -0
- package/dist/chunks/poller-DXZJ-dUP.js +1 -0
- package/dist/chunks/poor-C7GQ4a5X.js +1 -0
- package/dist/chunks/poorMode-CBe0rfxB.js +1 -0
- package/dist/chunks/poorMode-CbZTudtw.js +1 -0
- package/dist/chunks/postCommitAttribution--vvAWIqD.js +1 -0
- package/dist/chunks/print-CwwtGSbK.js +114 -0
- package/dist/chunks/privacy-settings-Bz8cAVp5.js +11 -0
- package/dist/chunks/privacyLevel-CRCHhztk.js +1 -0
- package/dist/chunks/process-CnhUplBr.js +1 -0
- package/dist/chunks/process-X4vCP9x0.js +1 -0
- package/dist/chunks/processBashCommand-NL0YEUqW.js +3 -0
- package/dist/chunks/processSlashCommand-FPMWElsI.js +6 -0
- package/dist/chunks/processSlashCommand-_oJs6_w8.js +6 -0
- package/dist/chunks/processUserInput-QAJK0XSn.js +1 -0
- package/dist/chunks/projectContext-B21hXj9q.js +1 -0
- package/dist/chunks/projectContext-DbTQHQS3.js +1 -0
- package/dist/chunks/prompt-C6eleu4x.js +1 -0
- package/dist/chunks/prompt-CUdoQXyN.js +1 -0
- package/dist/chunks/prompt-CsBCtw4l.js +228 -0
- package/dist/chunks/prompt-hnIDYhP4.js +54 -0
- package/dist/chunks/promptEditor-CrlVcc17.js +4 -0
- package/dist/chunks/protectedNamespace-Cn4901XG.js +1 -0
- package/dist/chunks/protocolHandler-DM_w7sJ5.js +13 -0
- package/dist/chunks/protocols-CpoQzjyI.js +7 -0
- package/dist/chunks/proxy-9WvtUy8E.js +99 -0
- package/dist/chunks/rate-limit-options-BehQ3MoX.js +1 -0
- package/dist/chunks/rcDebugLog-BbHlIxCm.js +11 -0
- package/dist/chunks/referral-BfAZEIZL.js +1 -0
- package/dist/chunks/refresh-Bl3Miver.js +1 -0
- package/dist/chunks/registerProtocol-BHZ3vZED.js +36 -0
- package/dist/chunks/registerSkillHooks-BR7v5qDA.js +1 -0
- package/dist/chunks/registry-C2igpRd-.js +1 -0
- package/dist/chunks/release-notes-C_Cou6ye.js +4 -0
- package/dist/chunks/releaseNotes-DveQShyB.js +2 -0
- package/dist/chunks/reload-plugins-D-pAUoB5.js +1 -0
- package/dist/chunks/remote-env-C_dBgbgo.js +1 -0
- package/dist/chunks/remoteBridgeCore-BxWhTy1u.js +1 -0
- package/dist/chunks/remoteControlServer-D3OjUlB-.js +3 -0
- package/dist/chunks/rename-f3m0ETSt.js +1 -0
- package/dist/chunks/renderOptions-QZLxGnh_.js +1 -0
- package/dist/chunks/replBridge-qeVmCJOb.js +1 -0
- package/dist/chunks/resume-CM_8p9Iu.js +2 -0
- package/dist/chunks/rewind-0cB7o6fx.js +1 -0
- package/dist/chunks/ripgrep-BEWqxrpl.js +5 -0
- package/dist/chunks/ripgrep-G82m12Ng.js +1 -0
- package/dist/chunks/rollback-CVo2gqgR.js +11 -0
- package/dist/chunks/runtimeObserver-1EdvvoYw.js +1 -0
- package/dist/chunks/runtimeObserver-CX6vepq9.js +10 -0
- package/dist/chunks/sandbox-adapter-DzHfW2tH.js +1 -0
- package/dist/chunks/sandbox-toggle-N6KgmH2T.js +1 -0
- package/dist/chunks/sanitization-CIBpY9KT.js +1 -0
- package/dist/chunks/satisfies-B7ZvBUQP.js +1 -0
- package/dist/chunks/schemas-Bwt-7U5W.js +40 -0
- package/dist/chunks/sdk-Drp69kIx.js +1 -0
- package/dist/chunks/sdkHeapDumpMonitor-B9GVkISU.js +1 -0
- package/dist/chunks/searchExtraTools-BphNJsl8.js +1 -0
- package/dist/chunks/semver-BsItM2Z4.js +1 -0
- package/dist/chunks/semver-D3lOjiBN.js +1 -0
- package/dist/chunks/sentry-ySzRCXGd.js +1 -0
- package/dist/chunks/server-C8nMDji6.js +1 -0
- package/dist/chunks/server-XZG51Slr.js +1 -0
- package/dist/chunks/serverBanner-D68EBGzH.js +1 -0
- package/dist/chunks/serverLog-hv2hc5US.js +1 -0
- package/dist/chunks/session-CVoGFb8a.js +2 -0
- package/dist/chunks/sessionDataUploader-BaD1Q7v3.js +1 -0
- package/dist/chunks/sessionDiscovery-D7g66TX6.js +1 -0
- package/dist/chunks/sessionFileAccessHooks-9lPjspRX.js +1 -0
- package/dist/chunks/sessionManager-BhOjMNAP.js +1 -0
- package/dist/chunks/sessionMemory-BA6cdxqP.js +1 -0
- package/dist/chunks/sessionMemory-CtEhIRGF.js +1 -0
- package/dist/chunks/sessionMemoryUtils-D_B92ypa.js +1 -0
- package/dist/chunks/sessionObserver-CESI-uVZ.js +1 -0
- package/dist/chunks/sessionObserver-SpE_eglb.js +20 -0
- package/dist/chunks/sessionRestore-DqsqYK4K.js +1 -0
- package/dist/chunks/sessionState-Dgky34M4.js +1 -0
- package/dist/chunks/sessionStorage-DJb5HKhQ.js +1 -0
- package/dist/chunks/sessionStorage-DSMfHTcg.js +1 -0
- package/dist/chunks/sessionStoragePortable-DyM_hZnp.js +3 -0
- package/dist/chunks/sessionTitle-Bzxk_EW9.js +14 -0
- package/dist/chunks/sessionTracing-DR8O0686.js +12 -0
- package/dist/chunks/setup-BHNS9sBS.js +9 -0
- package/dist/chunks/setup-BafJxZ0F.js +4 -0
- package/dist/chunks/setup-MLNNYLi6.js +1 -0
- package/dist/chunks/shadowedRuleDetection-Ch9gTxfD.js +1 -0
- package/dist/chunks/shellQuote-3s6tV-hK.js +1 -0
- package/dist/chunks/sideQuestion-BBn6XIOD.js +20 -0
- package/dist/chunks/signal-BTxmab6r.js +1 -0
- package/dist/chunks/signin-ChbUAEGq.js +1 -0
- package/dist/chunks/sink-B1qICbRh.js +1 -0
- package/dist/chunks/sink-yBIcxQf1.js +1 -0
- package/dist/chunks/sinks-C7weduDR.js +1 -0
- package/dist/chunks/skill-learning-08nEdOJ2.js +5 -0
- package/dist/chunks/skillGapStore-CuvWGqFb.js +5 -0
- package/dist/chunks/skillGapStore-DmMuDXKO.js +1 -0
- package/dist/chunks/skillGenerator-mEMjcmmm.js +8 -0
- package/dist/chunks/skillLearning-B3a-8Ys3.js +1 -0
- package/dist/chunks/skillLearning-q5T6o0mH.js +1 -0
- package/dist/chunks/skillPanel-BuUMhONI.js +28 -0
- package/dist/chunks/skillSearchPanel-BUEv7Sm9.js +21 -0
- package/dist/chunks/skillUsageTracking-BBTiWOKB.js +1 -0
- package/dist/chunks/skills-DvQuQfDW.js +1 -0
- package/dist/chunks/slashCommandParsing-BkTC3GRb.js +1 -0
- package/dist/chunks/sleep-CC8jykQd.js +1 -0
- package/dist/chunks/slowOperations-niPqC54V.js +1 -0
- package/dist/chunks/sprites-C5X62Vyh.js +1 -0
- package/dist/chunks/src-58uAJYF_.js +6 -0
- package/dist/chunks/src-7Y8fx6gl.js +2 -0
- package/dist/chunks/src-BuserDTl.js +1 -0
- package/dist/chunks/src-CMY4XoRy.js +1 -0
- package/dist/chunks/src-CfeAM1FB.js +1 -0
- package/dist/chunks/src-CxT2FDXy.js +1 -0
- package/dist/chunks/src-CyQf7rVu.js +26 -0
- package/dist/chunks/src-DJLbU8sT.js +1 -0
- package/dist/chunks/src-DJQlyVK6.js +5 -0
- package/dist/chunks/src-DNHWYkls.js +53 -0
- package/dist/chunks/src-DU_g0n_Q.js +1 -0
- package/dist/chunks/src-DhqzQjMg.js +19 -0
- package/dist/chunks/src-Duzv1Znh.js +1 -0
- package/dist/chunks/src-OBx6GAig.js +1 -0
- package/dist/chunks/src-WjnK2Dbo.js +1 -0
- package/dist/chunks/src-hjAMxWFj.js +7 -0
- package/dist/chunks/src-lLwoqdC0.js +9 -0
- package/dist/chunks/src-yRsWbJp_.js +2 -0
- package/dist/chunks/sso-oidc-yfC-A2A2.js +1 -0
- package/dist/chunks/startupProfiler-4P7GdVw6.js +3 -0
- package/dist/chunks/startupProfiler-CipS0otN.js +1 -0
- package/dist/chunks/state-9wSimHaL.js +1 -0
- package/dist/chunks/state-BQkyHx88.js +1 -0
- package/dist/chunks/state-CEAUTY3A.js +1 -0
- package/dist/chunks/state-CUZTq6r0.js +1 -0
- package/dist/chunks/state-U0HNbTx8.js +1 -0
- package/dist/chunks/staticRender-BB3CisKd.js +1 -0
- package/dist/chunks/stats-Dyi2U_mq.js +1 -0
- package/dist/chunks/status-CSL-GMou.js +1 -0
- package/dist/chunks/statusNoticeHelpers-BaXE951d.js +1 -0
- package/dist/chunks/stdio-BuUJYJFs.js +3 -0
- package/dist/chunks/stdio-iX0TTmbp.js +1 -0
- package/dist/chunks/stickers-2CRSckfH.js +1 -0
- package/dist/chunks/store-DdfsZvtr.js +1 -0
- package/dist/chunks/stringUtils-U7kMYMJq.js +4 -0
- package/dist/chunks/sts-CJmdeT7s.js +1 -0
- package/dist/chunks/subprocessEnv-DKTILev5.js +1 -0
- package/dist/chunks/subprocessEnv-WjRguKWf.js +1 -0
- package/dist/chunks/supports-color-DaytqqjM.js +1 -0
- package/dist/chunks/systemPromptSections-BnrxBWdc.js +1 -0
- package/dist/chunks/systemPromptSections-Dk6azdAb.js +1 -0
- package/dist/chunks/systemTheme-C1GNqIfy.js +1 -0
- package/dist/chunks/tag-C4cH016L.js +11 -0
- package/dist/chunks/tasks-CEdUW3RQ.js +1 -0
- package/dist/chunks/teamHelpers-CTA_CtTT.js +1 -0
- package/dist/chunks/teamHelpers-D65qZInv.js +1 -0
- package/dist/chunks/teammate-C-FiRloZ.js +1 -0
- package/dist/chunks/teammateModeSnapshot-DWRG5-Us.js +1 -0
- package/dist/chunks/teammateModeSnapshot-DtgsNj1G.js +1 -0
- package/dist/chunks/teleport-C_UgMy0V.js +1 -0
- package/dist/chunks/templateJobs-CMbS0tuk.js +12 -0
- package/dist/chunks/terminalSetup--jwGVap8.js +33 -0
- package/dist/chunks/terminalSetup-zID-wokH.js +1 -0
- package/dist/chunks/theme-C6XwTpVy.js +1 -0
- package/dist/chunks/thinkback-CVLnmLAT.js +1 -0
- package/dist/chunks/thinkback-MeOOO7gf.js +1 -0
- package/dist/chunks/thinkback-play-D7G260F4.js +1 -0
- package/dist/chunks/tmux-DtYJuTWh.js +1 -0
- package/dist/chunks/toolEventObserver-BtC9xDYY.js +1 -0
- package/dist/chunks/toolEventObserver-MfsHAt8h.js +1 -0
- package/dist/chunks/toolPool-CEi_2xIH.js +1 -0
- package/dist/chunks/toolPool-CdYJcCnc.js +1 -0
- package/dist/chunks/trustedDevice-CjQTGAa4.js +1 -0
- package/dist/chunks/trustedDevice-DADcxAAs.js +1 -0
- package/dist/chunks/tui-B8Ijq4Pk.js +6 -0
- package/dist/chunks/turndown.es-T-Xe93nc.js +69 -0
- package/dist/chunks/types-BVelRhgb.js +17 -0
- package/dist/chunks/types-Bqp3meR4.js +1 -0
- package/dist/chunks/types-CNmINIu3.js +1 -0
- package/dist/chunks/types-DgzOOCDl.js +3 -0
- package/dist/chunks/udsClient-ClY_0CKr.js +1 -0
- package/dist/chunks/ultrareviewCommand-CqvHj9Io.js +3 -0
- package/dist/chunks/undercover-CVCVOSrs.js +1 -0
- package/dist/chunks/undercover-CbxiJO2b.js +31 -0
- package/dist/chunks/up-CBJhVVbd.js +12 -0
- package/dist/chunks/updateCCB-DPPpquAw.js +11 -0
- package/dist/chunks/upgrade-DaaHOvft.js +1 -0
- package/dist/chunks/upgrade-k7ZvAWZ0.js +1 -0
- package/dist/chunks/upload-CEDxwMa1.js +1 -0
- package/dist/chunks/upstreamproxy-BtGJ2LRi.js +11 -0
- package/dist/chunks/usage-CsUSu4fb.js +1 -0
- package/dist/chunks/usage-oABvixCs.js +1 -0
- package/dist/chunks/useExitOnCtrlCDWithKeybindings-CBce_-hb.js +1 -0
- package/dist/chunks/useExitOnCtrlCDWithKeybindings-CLYjTZXb.js +1 -0
- package/dist/chunks/useKeybinding-DAQL_dB_.js +1 -0
- package/dist/chunks/useMainLoopModel-QC_H3esG.js +1 -0
- package/dist/chunks/useManageMCPConnections-bf-VfJGD.js +1 -0
- package/dist/chunks/useManagePlugins-CXdYUpit.js +1 -0
- package/dist/chunks/useMergedTools-DERzhQOJ.js +1 -0
- package/dist/chunks/useSearchInput-nqhdILI2.js +1 -0
- package/dist/chunks/useTerminalSize-DzV4aaTi.js +1 -0
- package/dist/chunks/useVoice-CO69xtWC.js +1 -0
- package/dist/chunks/util-C8wqPqv0.js +1 -0
- package/dist/chunks/utils-CDFsSXHr.js +1 -0
- package/dist/chunks/utils-ZO5TryVH.js +1 -0
- package/dist/chunks/v4-DLhvDPkt.js +1 -0
- package/dist/chunks/validatePlugin-C4cd71Yz.js +1 -0
- package/dist/chunks/vertex-sdk-CC3U26o7.js +9 -0
- package/dist/chunks/vim-BNiQx5Vf.js +1 -0
- package/dist/chunks/voice-BCbnJzYL.js +8 -0
- package/dist/chunks/voice-BJyz9KZO.js +8 -0
- package/dist/chunks/voice-CP2ULpju.js +2 -0
- package/dist/chunks/voiceModeEnabled-C-pa8B3Q.js +1 -0
- package/dist/chunks/voiceModeEnabled-CMtRN2pa.js +1 -0
- package/dist/chunks/voiceStreamSTT-31b2u0rj.js +1 -0
- package/dist/chunks/voiceStreamSTT-Fkhm6Ftg.js +1 -0
- package/dist/chunks/voiceStreamSTT-sI-hg-aP.js +1 -0
- package/dist/chunks/web-tools-CLmlPgLk.js +1 -0
- package/dist/chunks/which-C0ex-06E.js +1 -0
- package/dist/chunks/windowsPaths-C5TNvKYu.js +1 -0
- package/dist/chunks/windowsPaths-Kue_7s52.js +1 -0
- package/dist/chunks/workSecret-Dh5Ayceu.js +1 -0
- package/dist/chunks/workerRegistry-B5iWYqpK.js +1 -0
- package/dist/chunks/worktree-BypJA0GB.js +1 -0
- package/dist/chunks/worktreeModeEnabled-DPTdK3JV.js +1 -0
- package/dist/chunks/worktreeModeEnabled-Dtrcn7eD.js +1 -0
- package/dist/chunks/wrapper-BDPb4PTV.js +6 -0
- package/dist/chunks/wrapper-DRTs77RK.js +1 -0
- package/dist/chunks/xdg-BaVL-FHd.js +1 -0
- package/dist/chunks/xml-E8VMPwdJ.js +1 -0
- package/dist/chunks/zod-B_P2Eo_D.js +1 -0
- package/dist/cli-bun.js +2 -0
- package/dist/cli-node.js +2 -0
- package/dist/cli.js +2 -0
- package/dist/vendor/audio-capture/arm64-darwin/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/arm64-linux/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/arm64-win32/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-darwin/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-linux/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-win32/audio-capture.node +0 -0
- package/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/package.json +233 -0
- package/scripts/postinstall.cjs +389 -0
- package/scripts/run-parallel.mjs +10 -0
- package/scripts/setup-chrome-mcp.mjs +70 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,t}from"./chunk-DR8-3Aex.js";import{n,t as r}from"./esm-CL1OwlZB.js";import{t as i}from"./src-DhqzQjMg.js";import{n as a,t as o}from"./esm-DUtcefEV.js";var s=t((t=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.OTLPMetricExporter=void 0;var s=(a(),e(o)),c=i(),l=(n(),e(r));t.OTLPMetricExporter=class extends s.OTLPMetricExporterBase{constructor(e){super((0,c.createOtlpGrpcExportDelegate)((0,c.convertLegacyOtlpGrpcOptions)(e??{},`METRICS`),l.ProtobufMetricsSerializer,`MetricsExportService`,`/opentelemetry.proto.collector.metrics.v1.MetricsService/Export`),e)}}})),c=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.OTLPMetricExporter=void 0;var t=s();Object.defineProperty(e,`OTLPMetricExporter`,{enumerable:!0,get:function(){return t.OTLPMetricExporter}})}));export default c();export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./src-58uAJYF_.js";t();export{e as createClaudeForChromeMcpServer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./chunk-DR8-3Aex.js";import{createRequire as t}from"node:module";import{dirname as n,resolve as r,sep as i}from"node:path";import{fileURLToPath as a}from"node:url";function o(){let e=n(a(import.meta.url)),t=e.split(i),o=t.lastIndexOf(`dist`);return o===-1?r(e,`..`,`..`,`..`,`vendor`):t.slice(0,o+1).join(i)+i+`vendor`}function s(){if(y)return v;y=!0;let e=process.platform;if(e!==`darwin`&&e!==`linux`&&e!==`win32`)return null;if(process.env.AUDIO_CAPTURE_NODE_PATH)try{return v=_(process.env.AUDIO_CAPTURE_NODE_PATH),v}catch{}let t=`audio-capture/${`${process.arch}-${e}`}/audio-capture.node`,n=[r(o(),t),`./vendor/${t}`,`../vendor/${t}`,`../../vendor/${t}`,`${process.cwd()}/vendor/${t}`];for(let e of n)try{return v=_(e),v}catch{}return null}function c(){return s()!==null}function l(e,t){let n=s();return n?n.startRecording(e,t):!1}function u(){let e=s();e&&e.stopRecording()}function d(){let e=s();return e?e.isRecording():!1}function f(e,t){let n=s();return n?n.startPlayback(e,t):!1}function p(e){let t=s();t&&t.writePlaybackData(e)}function m(){let e=s();e&&e.stopPlayback()}function h(){let e=s();return e?e.isPlaying():!1}function g(){let e=s();return!e||!e.microphoneAuthorizationStatus?0:e.microphoneAuthorizationStatus()}var _,v,y;e((()=>{_=t(import.meta.url),v=null,y=!1}))();export{c as isNativeAudioAvailable,h as isNativePlaying,d as isNativeRecordingActive,g as microphoneAuthorizationStatus,f as startNativePlayback,l as startNativeRecording,m as stopNativePlayback,u as stopNativeRecording,p as writeNativePlaybackData};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{n as e}from"./chunk-DR8-3Aex.js";import{B as t,M as n,d as r,n as i,t as a}from"./server-XZG51Slr.js";import{randomUUID as o}from"node:crypto";function s(e){return e instanceof Error?e:void 0}var c,l=e((()=>{c={clipboardRead:!1,clipboardWrite:!1,systemKeyCombos:!1}}));function u(e){return d.has(e)?`shell`:f.has(e)?`filesystem`:p.has(e)?`system_settings`:null}var d,f,p,m,h=e((()=>{d=new Set([`com.apple.Terminal`,`com.googlecode.iterm2`,`com.microsoft.VSCode`,`dev.warp.Warp-Stable`,`com.github.wez.wezterm`,`io.alacritty`,`net.kovidgoyal.kitty`,`com.jetbrains.intellij`,`com.jetbrains.pycharm`]),f=new Set([`com.apple.finder`]),p=new Set([`com.apple.systempreferences`]),m=new Set([...d,...f,...p])}));function g(e){return e===`browser`||e===`trading`?`read`:e===`terminal`?`click`:`full`}function _(e,t){if(e&&re.has(e))return!0;let n=t.toLowerCase();for(let e of ie)if(n.includes(e))return!0;return!1}function v(e){return ee.has(e)?`browser`:te.has(e)?`terminal`:ne.has(e)?`trading`:null}function y(e){let t=e.toLowerCase();for(let e of se)if(t.includes(e))return`trading`;for(let e of ae)if(t.includes(e))return`browser`;for(let e of oe)if(t.includes(e))return`terminal`;return null}function b(e,t){if(e){let t=v(e);if(t)return t}return y(t)}function x(e,t){return g(b(e,t))}var ee,te,ne,re,ie,ae,oe,se,ce=e((()=>{ee=new Set(`com.apple.Safari,com.apple.SafariTechnologyPreview,com.google.Chrome,com.google.Chrome.beta,com.google.Chrome.dev,com.google.Chrome.canary,com.microsoft.edgemac,com.microsoft.edgemac.Beta,com.microsoft.edgemac.Dev,com.microsoft.edgemac.Canary,org.mozilla.firefox,org.mozilla.firefoxdeveloperedition,org.mozilla.nightly,org.chromium.Chromium,com.brave.Browser,com.brave.Browser.beta,com.brave.Browser.nightly,com.operasoftware.Opera,com.operasoftware.OperaGX,com.operasoftware.OperaDeveloper,com.vivaldi.Vivaldi,company.thebrowser.Browser,company.thebrowser.dia,org.torproject.torbrowser,com.duckduckgo.macos.browser,ru.yandex.desktop.yandex-browser,ai.perplexity.comet,com.sigmaos.sigmaos.macos,com.kagi.kagimacOS`.split(`,`)),te=new Set(`com.apple.Terminal,com.googlecode.iterm2,dev.warp.Warp-Stable,dev.warp.Warp-Beta,com.github.wez.wezterm,org.alacritty,io.alacritty,net.kovidgoyal.kitty,co.zeit.hyper,com.mitchellh.ghostty,org.tabby,com.termius-dmg.mac,com.microsoft.VSCode,com.microsoft.VSCodeInsiders,com.vscodium,com.todesktop.230313mzl4w4u92,com.exafunction.windsurf,dev.zed.Zed,dev.zed.Zed-Preview,com.jetbrains.intellij,com.jetbrains.intellij.ce,com.jetbrains.pycharm,com.jetbrains.pycharm.ce,com.jetbrains.WebStorm,com.jetbrains.CLion,com.jetbrains.goland,com.jetbrains.rubymine,com.jetbrains.PhpStorm,com.jetbrains.datagrip,com.jetbrains.rider,com.jetbrains.AppCode,com.jetbrains.rustrover,com.jetbrains.fleet,com.google.android.studio,com.axosoft.gitkraken,com.sublimetext.4,com.sublimetext.3,org.vim.MacVim,com.neovim.neovim,org.gnu.Emacs,com.apple.dt.Xcode,org.eclipse.platform.ide,org.netbeans.ide,com.microsoft.visual-studio,com.apple.ScriptEditor2,com.apple.Automator,com.apple.shortcuts`.split(`,`)),ne=new Set([`com.webull.desktop.v1`,`com.webull.trade.mac.v1`,`com.tastytrade.desktop`,`com.tradingview.tradingviewapp.desktop`,`com.fidelity.activetrader`,`com.fmr.activetrader`,`com.install4j.5889-6375-8446-2021`,`com.binance.BinanceDesktop`,`com.electron.exodus`,`org.pythonmac.unspecified.Electrum`,`com.ledger.live`,`io.trezor.TrezorSuite`]),re=new Set([`com.apple.TV`,`com.apple.Music`,`com.apple.iBooksX`,`com.apple.podcasts`,`com.spotify.client`,`com.amazon.music`,`com.tidal.desktop`,`com.deezer.deezer-desktop`,`com.pandora.desktop`,`com.electron.pocket-casts`,`au.com.shiftyjelly.PocketCasts`,`tv.plex.desktop`,`tv.plex.htpc`,`tv.plex.plexamp`,`com.amazon.aiv.AIVApp`,`net.kovidgoyal.calibre`,`com.amazon.Kindle`,`com.amazon.Lassen`,`com.kobo.desktop.Kobo`]),ie=`netflix,disney+,hulu,prime video,apple tv,peacock,paramount+,tubi,crunchyroll,vudu,kindle,apple books,kobo,play books,calibre,libby,readium,audible,libro.fm,speechify,spotify,apple music,amazon music,youtube music,tidal,deezer,pandora,pocket casts,naver,reddit,sony music,vegas pro,pitchfork,economist,nytimes`.split(`,`),ae=[`safari`,`chrome`,`firefox`,`microsoft edge`,`brave`,`opera`,`vivaldi`,`chromium`,`arc browser`,`tor browser`,`duckduckgo`,`yandex`,`orion browser`,`comet`,`sigmaos`,`dia browser`],oe=`terminal,iterm,wezterm,alacritty,kitty,ghostty,tabby,termius,script editor,automator,powershell,cmd.exe,command prompt,git bash,conemu,cmder,visual studio code,visual studio,vscode,vs code,vscodium,cursor,windsurf,intellij,pycharm,webstorm,clion,goland,rubymine,phpstorm,datagrip,rider,appcode,rustrover,fleet,android studio,sublime text,macvim,neovim,emacs,xcode,eclipse,netbeans`.split(`,`),se=`bloomberg,ameritrade,thinkorswim,schwab,fidelity,e*trade,interactive brokers,trader workstation,tradestation,webull,robinhood,tastytrade,ninjatrader,tradingview,moomoo,tradezero,prorealtime,plus500,saxotrader,oanda,metatrader,forex.com,avaoptions,ctrader,jforex,iq option,olymp trade,binomo,pocket option,raceoption,expertoption,quotex,naga,morgan stanley,ubs neo,eikon,coinbase,kraken,binance,okx,bybit,phemex,stormgain,crypto.com,electrum,ledger live,trezor,guarda,atomic wallet,bitpay,bisq,koinly,cointracker,blockfi,stripe cli,decentraland,axie infinity,gods unchained`.split(`,`)}));function le(e){let t=e.toLowerCase().split(`+`).map(e=>e.trim()).filter(Boolean),n=[],r=[];for(let e of t){let t=ue[e];t===void 0?r.push(e):n.push(t)}let i=[...new Set(n)];return i.sort((e,t)=>C.indexOf(e)-C.indexOf(t)),{mods:i,keys:r}}function S(e,t){let n=t===`darwin`?de:fe,{mods:r,keys:i}=le(e),a=r.length>0?r.join(`+`)+`+`:``;if(i.length===0)return n.has(r.join(`+`));for(let e of i)if(n.has(a+e))return!0;return!1}var ue,C,de,fe,pe=e((()=>{ue={meta:`meta`,super:`meta`,command:`meta`,cmd:`meta`,windows:`meta`,win:`meta`,ctrl:`ctrl`,control:`ctrl`,lctrl:`ctrl`,lcontrol:`ctrl`,rctrl:`ctrl`,rcontrol:`ctrl`,shift:`shift`,lshift:`shift`,rshift:`shift`,alt:`alt`,option:`alt`},C=[`ctrl`,`alt`,`shift`,`meta`],de=new Set([`meta+q`,`shift+meta+q`,`alt+meta+escape`,`meta+tab`,`meta+space`,`ctrl+meta+q`]),fe=new Set([`ctrl+alt+delete`,`alt+f4`,`alt+tab`,`meta+l`,`meta+d`])}));function me(e,t){return Math.floor((e-1)/t)+1}function he(e,t,n){return me(e,n)*me(t,n)}function ge(e,t,n){let{pxPerToken:r,maxTargetPx:i,maxTargetTokens:a}=n;if(e<=i&&t<=i&&he(e,t,r)<=a)return[e,t];if(t>e){let[r,i]=ge(t,e,n);return[i,r]}let o=e/t,s=e,c=1;for(;;){if(c+1===s)return[c,Math.max(Math.round(c/o),1)];let e=Math.floor((c+s)/2),t=Math.max(Math.round(e/o),1);e<=i&&he(e,t,r)<=a?c=e:s=e}}var _e,ve=e((()=>{_e={pxPerToken:28,maxTargetPx:1568,maxTargetTokens:1568}}));function ye(e,t,n,r,i){if(!e||!t)return null;let a=Math.max(0,Math.min(100,n)),o=Math.max(0,Math.min(100,r)),s=Math.round(a/100*e),c=Math.round(o/100*t),l=Math.floor(i/2),u=Math.max(0,s-l),d=Math.max(0,c-l),f=Math.min(i,e-u),p=Math.min(i,t-d);return f<=0||p<=0?null:{x:u,y:d,width:f,height:p}}function be(e,t,n,r,i,a=w){let o=ye(n.width,n.height,r,i,a);if(!o)return!1;let s=e(t.base64,o),c=e(n.base64,o);return!s||!c?!1:s.equals(c)}async function xe(e,t,n,r,i,a,o=w){if(!t)return{valid:!0,skipped:!0};try{let a=await i();return a?be(e,t,a,n,r,o)?{valid:!0,skipped:!1}:{valid:!1,skipped:!1,warning:`Screen content at the target location changed since the last screenshot. Take a new screenshot before clicking.`}:{valid:!0,skipped:!0}}catch(e){return a.debug(`[pixelCompare] validation error, skipping`,s(e)),{valid:!0,skipped:!0}}}var w,Se=e((()=>{l(),w=9}));function T(e){let t=Buffer.from(e.slice(0,16),`base64`);return t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?`image/png`:t[0]===255&&t[1]===216&&t[2]===255?`image/jpeg`:t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80?`image/webp`:t[0]===71&&t[1]===73&&t[2]===70?`image/gif`:`image/png`}function E(e,t){return{content:[{type:`text`,text:e}],isError:!0,telemetry:t?{error_kind:t}:void 0}}function D(e){return{content:[{type:`text`,text:e}]}}function O(e,t){return{content:[{type:`text`,text:JSON.stringify(e)}],telemetry:t}}function Ce(e){return typeof e==`object`&&e?e:{}}function k(e,t){let n=e[t];return typeof n==`string`?n:Error(`"${t}" must be a string.`)}function A(e,t=`coordinate`){let n=e[t];if(n===void 0)return Error(`${t} is required`);if(!Array.isArray(n)||n.length!==2)return Error(`${t} must be an array of length 2`);let[r,i]=n;return typeof r!=`number`||typeof i!=`number`||r<0||i<0?Error(`${t} must be a tuple of non-negative numbers`):[r,i]}function j(e,t,n,r,i,a){return n===`normalized_0_100`?{x:Math.round(e/100*r.width)+r.originX,y:Math.round(t/100*r.height)+r.originY}:i?{x:Math.round(e*(i.displayWidth/i.width))+i.originX,y:Math.round(t*(i.displayHeight/i.height))+i.originY}:(a.warn(`[computer-use] pixels-mode coordinate received with no prior screenshot; falling back to /scaleFactor. Click may be off if downsample is active.`),{x:Math.round(e/r.scaleFactor)+r.originX,y:Math.round(t/r.scaleFactor)+r.originY})}function we(e,t,n,r){return n===`normalized_0_100`?{xPct:e,yPct:t}:r?{xPct:e/r.width*100,yPct:t/r.height*100}:{xPct:0,yPct:0}}function Te(e,t){let n=e??`full`;return t===`mouse_position`?!0:t===`keyboard`||t===`mouse_full`?n===`full`:n===`click`||n===`full`}async function M(e,t,n){let r=t.getClipboardStash?.();if(!n){if(r===void 0)return;try{await e.executor.writeClipboard(r),t.onClipboardStashChanged?.(void 0)}catch{}return}if(r===void 0)try{let n=await e.executor.readClipboard();t.onClipboardStashChanged?.(n)}catch{t.onClipboardStashChanged?.(``)}try{await e.executor.writeClipboard(``)}catch{}}async function N(e,t,n,r){if(n.hideBeforeAction){let n=await e.executor.prepareForAction(t.allowedApps.map(e=>e.bundleId),t.selectedDisplayId);n.length>0&&t.onAppsHidden?.(n)}if(e.executor.capabilities.screenshotFiltering===`none`)return null;let i=await e.executor.getFrontmostApp(),a=new Map(t.allowedApps.map(e=>[e.bundleId,e.tier])),o=i?a.get(i.bundleId):void 0;if(n.clipboardGuard&&await M(e,t,o===`click`),!i)return null;let{hostBundleId:s}=e.executor.capabilities;if(o!==void 0){if(Te(o,r))return null;if(o===`read`){let e=b(i.bundleId,i.displayName)===`browser`;return E(`"${i.displayName}" is granted at tier "read" — visible in screenshots only, no clicks or typing.`+(e?" Use the Claude-in-Chrome MCP for browser interaction (tools named `mcp__Claude_in_Chrome__*`; load via SearchExtraTools if deferred).":` No interaction is permitted; ask the user to take any actions in this app themselves.`)+K,`tier_insufficient`)}return E(r===`keyboard`?`"${i.displayName}" is granted at tier "click" — typing, key presses, and paste require tier "full". The keys would go to this app's text fields or integrated terminal. To type into a different app, click it first to bring it forward. For shell commands, use the Bash tool. Do not attempt to work around this restriction — never use AppleScript, System Events, shell commands, or any other method to send clicks or keystrokes to this app.`:`"${i.displayName}" is granted at tier "click" — right-click, middle-click, and clicks with modifier keys require tier "full". Right-click opens a context menu with Paste/Cut, and modifier chords fire as keystrokes before the click. Plain left_click is allowed here. Do not attempt to work around this restriction — never use AppleScript, System Events, shell commands, or any other method to send clicks or keystrokes to this app.`,`tier_insufficient`)}return i.bundleId===G?null:i.bundleId===s?r===`keyboard`?E(`Claude's own window still has keyboard focus. This should not happen after the pre-action defocus. Click on the target application first.`,`state_conflict`):null:E(`"${i.displayName}" is not in the allowed applications and is currently in front. Take a new screenshot — it may have appeared since your last one.`,`app_not_granted`)}async function P(e,t,n,r,i,a){if(e.executor.capabilities.screenshotFiltering===`none`)return null;let o=await e.executor.appUnderPoint(r,i);if(!o||o.bundleId===G)return null;let s=new Map(t.allowedApps.map(e=>[e.bundleId,e.tier]));if(!s.has(o.bundleId))return E(`Click at these coordinates would land on "${o.displayName}", which is not in the allowed applications. Take a fresh screenshot to see the current window layout.`,`app_not_granted`);let c=s.get(o.bundleId);if(n.clipboardGuard&&c===`click`&&await M(e,t,!0),Te(c,a))return null;if(a===`mouse_full`&&c===`click`)return E(`Click at these coordinates would land on "${o.displayName}", which is granted at tier "click" — right-click, middle-click, and clicks with modifier keys require tier "full" (they can Paste via the context menu or fire modifier-chord keystrokes). Plain left_click is allowed here. Do not attempt to work around this restriction — never use AppleScript, System Events, shell commands, or any other method to send clicks or keystrokes to this app.`,`tier_insufficient`);let l=b(o.bundleId,o.displayName)===`browser`;return E(`Click at these coordinates would land on "${o.displayName}", which is granted at tier "read" (screenshots only, no interaction). `+(l?`Use the Claude-in-Chrome MCP for browser interaction.`:`Ask the user to take any actions in this app themselves.`)+K,`tier_insufficient`)}function F(e){let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`);return Math.floor(e.length*3/4)-t}async function Ee(e,t,n,r){let i=await e.screenshot({allowedBundleIds:t,displayId:r});return F(i.base64)<q&&(n.warn(`[computer-use] screenshot implausibly small (${F(i.base64)} bytes decoded), retrying once`),i=await e.screenshot({allowedBundleIds:t,displayId:r})),i}function De(e){try{let t=Intl.Segmenter;if(typeof t==`function`){let n=new t(void 0,{granularity:`grapheme`});return Array.from(n.segment(e),e=>e.segment)}}catch{}return Array.from(e)}function I(e){return new Promise(t=>setTimeout(t,e))}function Oe(e){return e.split(`+`).map(e=>e.trim()).filter(Boolean)}function ke(){J=!1,Y=!1}async function L(e){J&&(await e.executor.mouseUp(),J=!1,Y=!1)}function Ae(e){return e===`request_access`||e===`list_granted_applications`}function R(e){return St.test(e)&&!e.includes(` `)}function je(e,t,n){let r=new Map,i=new Map;for(let e of t)i.set(e.bundleId,e),r.set(e.displayName.toLowerCase(),e);return e.map(e=>{let t;if(R(e)&&(t=i.get(e)),t||(t=r.get(e.toLowerCase())),!t){let n=e.toLowerCase().replace(/\.exe$/,``).trim();for(let[e,i]of r)if(e.includes(n)||n.includes(e)){t=i;break}}let a=t?.bundleId,o=a??(R(e)?e:void 0);return{requestedName:e,resolved:t,isSentinel:a?m.has(a):!1,alreadyGranted:a?n.has(a):!1,proposedTier:x(o,t?.displayName??e)}})}async function Me(e,t,n,r){if(!n.onPermissionRequest)return E(`This session was not wired with a permission handler. Computer control is not available here.`,`feature_unavailable`);if(n.getTeachModeActive?.())return E(`Cannot request additional permissions during teach mode — the permission dialog would be hidden. End teach mode (finish the tour or let the turn complete), then call request_access, then start a new tour.`,`teach_mode_conflict`);let i=k(t,`reason`);if(i instanceof Error)return E(i.message,`bad_args`);if(r){let t={requestId:o(),reason:i,apps:[],requestedFlags:{},screenshotFiltering:e.executor.capabilities.screenshotFiltering,tccState:r};await n.onPermissionRequest(t);let a=await e.ensureOsPermissions();if(a.granted)return E(`macOS Accessibility and Screen Recording are now both granted. Call request_access again immediately — the next call will show the app selection list.`);let s=a,c=[];return s.accessibility||c.push(`Accessibility`),s.screenRecording||c.push(`Screen Recording`),E(`macOS ${c.join(` and `)} permission(s) not yet granted. The permission panel has been shown. Once the user grants the missing permission(s), call request_access again.`,`tcc_not_granted`)}let a=t.apps;if(!Array.isArray(a)||!a.every(e=>typeof e==`string`))return E(`"apps" must be an array of strings.`,`bad_args`);let s=a,c={};typeof t.clipboardRead==`boolean`&&(c.clipboardRead=t.clipboardRead),typeof t.clipboardWrite==`boolean`&&(c.clipboardWrite=t.clipboardWrite),typeof t.systemKeyCombos==`boolean`&&(c.systemKeyCombos=t.systemKeyCombos);let{needDialog:l,skipDialogGrants:u,willHide:d,tieredApps:f,userDenied:p,policyDenied:m}=await Pe(e,s,n.allowedApps,new Set(n.userDeniedBundleIds),n.selectedDisplayId),h=[],g=[];if(n.grantFlags,l.length>0||Object.keys(c).length>0){let t={requestId:o(),reason:i,apps:l,requestedFlags:c,screenshotFiltering:e.executor.capabilities.screenshotFiltering,...d.length>0&&{willHide:d,autoUnhideEnabled:e.getAutoUnhideEnabled()}},r=await n.onPermissionRequest(t);h=r.granted,g=r.denied,r.flags}let _=[...u,...h],v=new Set(_.map(e=>e.bundleId)),y=f.filter(e=>v.has(e.bundleId)),b=[];try{b=await Ne(e,_)}catch(t){e.logger.warn(`[computer-use] buildWindowLocations failed: ${String(t)}`)}return O({granted:_,denied:g,...m.length>0&&{policyDenied:{apps:m,guidance:B(m)}},...p.length>0&&{userDenied:{apps:p,guidance:z(p)}},...y.length>0&&{tierGuidance:Fe(y)},screenshotFiltering:e.executor.capabilities.screenshotFiltering,...b.length>0?{windowLocations:b}:{}},{granted_count:h.length,denied_count:g.length,...Ie(y)})}async function Ne(e,t){if(t.length===0)return[];let n=await e.executor.listDisplays();if(n.length<=1)return[];let r=t.map(e=>e.bundleId),i=await e.executor.findWindowDisplays(r),a=new Map(n.map(e=>[e.displayId,e])),o=new Map(i.map(e=>[e.bundleId,e.displayIds])),s=[];for(let e of t){let t=o.get(e.bundleId);!t||t.length===0||s.push({bundleId:e.bundleId,displayName:e.displayName,displays:t.map(e=>{let t=a.get(e);return{id:e,label:t?.label,isPrimary:t?.isPrimary}})})}return s}async function Pe(e,t,n,r,i){let a=new Set(n.map(e=>e.bundleId)),o=je(t,await e.executor.listInstalledApps(),a),s=[],c=[];for(let e of o){let t=e.resolved?.displayName??e.requestedName;_(e.resolved?.bundleId,t)?s.push({requestedName:e.requestedName,displayName:t}):c.push(e)}let l=[],u=[];for(let e of c)e.resolved&&r.has(e.resolved.bundleId)?l.push({requestedName:e.requestedName,displayName:e.resolved.displayName}):u.push(e);let d=[];for(let e of u)e.proposedTier===`full`||!e.resolved||d.push({bundleId:e.resolved.bundleId,displayName:e.resolved.displayName,tier:e.proposedTier});let f=u.filter(e=>e.alreadyGranted),p=u.filter(e=>!e.alreadyGranted);for(let t of p)if(t.resolved)try{t.resolved.iconDataUrl=await e.executor.getAppIcon(t.resolved.path)}catch{}let m=Date.now(),h=f.filter(e=>e.resolved).map(e=>n.find(t=>t.bundleId===e.resolved.bundleId)??{bundleId:e.resolved.bundleId,displayName:e.resolved.displayName,grantedAt:m,tier:e.proposedTier}),g=[...n.map(e=>e.bundleId),...u.filter(e=>e.resolved).map(e=>e.resolved.bundleId)];return{needDialog:p,skipDialogGrants:h,willHide:await e.executor.previewHideSet(g,i),tieredApps:d,userDenied:l,policyDenied:s}}function Fe(e){let t=e.filter(e=>e.tier===`read`&&b(e.bundleId,e.displayName)===`browser`),n=e.filter(e=>e.tier===`read`&&b(e.bundleId,e.displayName)!==`browser`),r=e.filter(e=>e.tier===`click`),i=[];if(t.length>0){let e=t.map(e=>`"${e.displayName}"`).join(`, `);i.push(`${e} ${t.length===1?`is a browser`:`are browsers`} — granted at tier "read" (visible in screenshots only; no clicks or typing). You can read what's on screen but cannot navigate, click, or type into ${t.length===1?`it`:`them`}. For browser interaction, use the Claude-in-Chrome MCP (tools named \`mcp__Claude_in_Chrome__*\`; load via SearchExtraTools if deferred).`)}if(n.length>0){let e=n.map(e=>`"${e.displayName}"`).join(`, `);i.push(`${e} ${n.length===1?`is`:`are`} granted at tier "read" (visible in screenshots only; no clicks or typing). You can read what's on screen but cannot interact. Ask the user to take any actions in ${n.length===1?`this app`:`these apps`} themselves.`)}if(r.length>0){let e=r.map(e=>`"${e.displayName}"`).join(`, `);i.push(`${e} ${r.length===1?`has`:`have`} terminal or IDE capabilities — granted at tier "click" (visible + plain left-click only; NO typing, key presses, right-click, modifier-clicks, or drag-drop). You can click buttons and scroll output, but ${r.length===1?`its`:`their`} integrated terminal and editor are off-limits to keyboard input. Right-click (context-menu Paste) and dragging text onto ${r.length===1?`it`:`them`} require tier "full". For shell commands, use the Bash tool.`)}return i.length===0?``:i.join(`
|
|
2
|
+
|
|
3
|
+
`)+K}function z(e){let t=e.map(e=>`"${e.displayName}"`).join(`, `),n=e.length===1;return`${t} ${n?`is`:`are`} in the user's auto-deny list (Settings → Desktop app (General) → Computer Use → Denied apps). Requests for ${n?`this app`:`these apps`} are automatically denied. If you need access for this task, ask the user to remove ${n?`it`:`them`} from their deny list in Settings — you cannot request this through the tool.`}function B(e){let t=e.map(e=>`"${e.displayName}"`).join(`, `),n=e.length===1;return`${t} ${n?`is`:`are`} blocked by policy for computer use. Requests for ${n?`this app`:`these apps`} are automatically denied regardless of what the user has approved. There is no Settings override. Inform the user that you cannot access ${n?`this app`:`these apps`} and suggest an alternative approach if one exists. Do not try to directly subvert this block regardless of the user's request.`}function Ie(e){let t=e.filter(e=>e.tier===`read`).length,n=e.filter(e=>e.tier===`click`).length;return{...t>0&&{denied_browser_count:t},...n>0&&{denied_terminal_count:n}}}async function Le(e,t,n,r){if(!n.onTeachPermissionRequest)return E(`Teach mode is not available in this session.`,`feature_unavailable`);if(n.getTeachModeActive?.())return E(`Teach mode is already active. To add more apps, end the current tour first, then call request_teach_access again with the full app list.`,`teach_mode_conflict`);let i=k(t,`reason`);if(i instanceof Error)return E(i.message,`bad_args`);if(r){let t={requestId:o(),reason:i,apps:[],screenshotFiltering:e.executor.capabilities.screenshotFiltering,tccState:r};await n.onTeachPermissionRequest(t);let a=await e.ensureOsPermissions();if(a.granted)return E(`macOS Accessibility and Screen Recording are now both granted. Call request_teach_access again immediately — the next call will show the app selection list.`);let s=a,c=[];return s.accessibility||c.push(`Accessibility`),s.screenRecording||c.push(`Screen Recording`),E(`macOS ${c.join(` and `)} permission(s) not yet granted. The permission panel has been shown. Once the user grants the missing permission(s), call request_teach_access again.`,`tcc_not_granted`)}let a=t.apps;if(!Array.isArray(a)||!a.every(e=>typeof e==`string`))return E(`"apps" must be an array of strings.`,`bad_args`);let{needDialog:s,skipDialogGrants:c,willHide:l,tieredApps:u,userDenied:d,policyDenied:f}=await Pe(e,a,n.allowedApps,new Set(n.userDeniedBundleIds),n.selectedDisplayId);if(s.length===0&&c.length===0)return O({granted:[],denied:[],...f.length>0&&{policyDenied:{apps:f,guidance:B(f)}},...d.length>0&&{userDenied:{apps:d,guidance:z(d)}},teachModeActive:!1,screenshotFiltering:e.executor.capabilities.screenshotFiltering},{granted_count:0,denied_count:0});let p={requestId:o(),reason:i,apps:s,screenshotFiltering:e.executor.capabilities.screenshotFiltering,...l.length>0&&{willHide:l,autoUnhideEnabled:e.getAutoUnhideEnabled()}},m=await n.onTeachPermissionRequest(p),h=[...c,...m.granted],g=m.userConsented===!0&&h.length>0;g&&n.onTeachModeActivated?.();let _=new Set(h.map(e=>e.bundleId)),v=u.filter(e=>_.has(e.bundleId));return O({granted:h,denied:m.denied,...f.length>0&&{policyDenied:{apps:f,guidance:B(f)}},...d.length>0&&{userDenied:{apps:d,guidance:z(d)}},...v.length>0&&{tierGuidance:Fe(v)},teachModeActive:g,screenshotFiltering:e.executor.capabilities.screenshotFiltering},{granted_count:m.granted.length,denied_count:m.denied.length,...Ie(v)})}async function Re(e,t,n,r){let i=k(e,`explanation`);if(i instanceof Error)return Error(`${r}: ${i.message}`);let a=k(e,`next_preview`);if(a instanceof Error)return Error(`${r}: ${a.message}`);let o=e.actions;if(!Array.isArray(o))return Error(`${r}: "actions" must be an array (empty is allowed).`);for(let[e,t]of o.entries()){if(typeof t!=`object`||!t)return Error(`${r}: actions[${e}] must be an object`);let n=t.action;if(typeof n!=`string`)return Error(`${r}: actions[${e}].action must be a string`);if(!X.has(n))return Error(`${r}: actions[${e}].action="${n}" is not allowed. Allowed: ${[...X].join(`, `)}.`)}let s;if(e.anchor!==void 0){let i=e.anchor;if(!Array.isArray(i)||i.length!==2||typeof i[0]!=`number`||typeof i[1]!=`number`||!Number.isFinite(i[0])||!Number.isFinite(i[1]))return Error(`${r}: "anchor" must be a [x, y] number tuple or omitted.`);let a=await t.executor.getDisplaySize(n.selectedDisplayId);s=j(i[0],i[1],n.coordinateMode,a,n.lastScreenshot,t.logger)}return{explanation:i,nextPreview:a,anchorLogical:s,actions:o}}async function ze(e,t,n,r){if((await n.onTeachStep({explanation:e.explanation,nextPreview:e.nextPreview,anchorLogical:e.anchorLogical})).action===`exit`)return await L(t),{kind:`exit`};if(n.onTeachWorking?.(),e.actions.length===0)return{kind:`ok`,results:[]};if(r.hideBeforeAction){let e=await t.executor.prepareForAction(n.allowedApps.map(e=>e.bundleId),n.selectedDisplayId);e.length>0&&n.onAppsHidden?.(e)}let i={...r,hideBeforeAction:!1,pixelValidation:!1,autoTargetDisplay:!1},a=[];for(let[r,o]of e.actions.entries()){if(n.isAborted?.())return await L(t),{kind:`exit`};r>0&&await I(10);let s=o.action,{screenshot:c,...l}=await W(s,o,t,n,i),u=yt(l),d={action:s,ok:!l.isError,output:u};if(a.push(d),l.isError)return await L(t),{kind:`action_error`,executed:a.length-1,failed:d,remaining:e.actions.length-a.length,telemetry:l.telemetry}}return{kind:`ok`,results:a}}async function Be(e,t,n,r){let i=await Ke(t,n,r);return i.isError?O(e):{content:[{type:`text`,text:JSON.stringify(e)},...i.content],screenshot:i.screenshot}}async function Ve(e,t,n,r){if(!n.onTeachStep)return E(`Teach mode is not active. Call request_teach_access first.`,`teach_mode_not_active`);let i=await Re(t,e,n,`teach_step`);if(i instanceof Error)return E(i.message,`bad_args`);let a=await ze(i,e,n,r);return a.kind===`exit`?O({exited:!0}):a.kind===`action_error`?O({executed:a.executed,failed:a.failed,remaining:a.remaining},a.telemetry):i.actions.length===0?O({executed:0,results:[]}):Be({executed:a.results.length,results:a.results},e,n,r)}async function He(e,t,n,r){if(!n.onTeachStep)return E(`Teach mode is not active. Call request_teach_access first.`,`teach_mode_not_active`);let i=t.steps;if(!Array.isArray(i)||i.length<1)return E(`"steps" must be a non-empty array.`,`bad_args`);let a=[];for(let[t,r]of i.entries()){if(typeof r!=`object`||!r)return E(`steps[${t}] must be an object`,`bad_args`);let i=await Re(r,e,n,`steps[${t}]`);if(i instanceof Error)return E(i.message,`bad_args`);a.push(i)}let o=[];for(let[t,i]of a.entries()){let a=await ze(i,e,n,r);if(a.kind===`exit`)return O({exited:!0,stepsCompleted:t});if(a.kind===`action_error`)return O({stepsCompleted:t,stepFailed:t,executed:a.executed,failed:a.failed,remaining:a.remaining,results:o},a.telemetry);o.push(a.results)}let s=a.some(e=>e.actions.length>0),c={stepsCompleted:a.length,results:o};return s?Be(c,e,n,r):O(c)}async function Ue(e,t){if(t.length===0)return;let n=await e.executor.listRunningApps(),r=new Map(n.map(e=>[e.bundleId,e.displayName])),i=t.map(e=>r.get(e)??e),a=i.map(e=>`"${e}"`).join(`, `),o=i.length===1;return`${a} ${o?`was`:`were`} open and got hidden before this screenshot (not in the session allowlist). If a previous action was meant to open ${o?`it`:`one of them`}, that's why you don't see it — call request_access to add ${o?`it`:`them`} to the allowlist.`}function We(e){let t=[...e].sort((e,t)=>e.displayId-t.displayId),n=new Map,r=new Map;for(let e of t){let t=e.label??`display ${e.displayId}`,i=(n.get(t)??0)+1;n.set(t,i),r.set(e.displayId,i===1?t:`${t} (${i})`)}return r}async function Ge(e,t,n,r){let i;try{i=await e.executor.listDisplays()}catch(t){e.logger.warn(`[computer-use] listDisplays failed: ${String(t)}`);return}if(i.length<2)return;let a=We(i),o=e=>a.get(e)??`display ${e}`,s=o(t),c=i.filter(e=>e.displayId!==t).map(e=>o(e.displayId)),l=r?` Use switch_display to capture a different monitor.`:``,u=c.length>0?` Other attached monitors: ${c.map(e=>`"${e}"`).join(`, `)}.`+l:``;if(n===void 0||n===0)return`This screenshot was taken on monitor "${s}".`+u;if(n!==t)return`This screenshot was taken on monitor "${s}", which is different from your previous screenshot (taken on "${o(n)}").`+u}async function Ke(e,t,n){if(t.allowedApps.length===0)return E(`No applications are granted for this session. Call request_access first.`,`allowlist_empty`);if(n.autoTargetDisplay){let r=t.allowedApps.map(e=>e.bundleId),i=r.slice().sort().join(`,`),a=i!==t.displayResolvedForApps,o=!t.displayPinnedByModel&&a,s=await e.executor.resolvePrepareCapture({allowedBundleIds:r,preferredDisplayId:t.selectedDisplayId,autoResolve:o,doHide:n.hideBeforeAction});s.captureError===void 0&&F(s.base64)<q&&e.logger.warn(`[computer-use] resolvePrepareCapture result implausibly small (${F(s.base64)} bytes decoded) — possible transient display state`),s.displayId!==t.selectedDisplayId&&(e.logger.debug(`[computer-use] resolver: preferred=${t.selectedDisplayId} resolved=${s.displayId}`),t.onResolvedDisplayUpdated?.(s.displayId)),o&&t.onDisplayResolvedForApps?.(i);let c=[];if(t.lastScreenshot!==void 0&&(c=s.hidden),s.hidden.length>0&&t.onAppsHidden?.(s.hidden),s.captureError!==void 0)return E(s.captureError,`capture_failed`);let l=await Ue(e,c),u={base64:s.base64,width:s.width,height:s.height,displayWidth:s.displayWidth,displayHeight:s.displayHeight,displayId:s.displayId,originX:s.originX,originY:s.originY},d=await Ge(e,u.displayId??0,t.lastScreenshot?.displayId,t.onDisplayPinned!==void 0);return{content:[...d?[{type:`text`,text:d}]:[],...l?[{type:`text`,text:l}]:[],...u.accessibilityText?[{type:`text`,text:`GUI elements in this window:\n${u.accessibilityText}`}]:[],{type:`image`,data:u.base64,mimeType:T(u.base64)}],screenshot:u}}let r=[];if(n.hideBeforeAction){let n=await e.executor.prepareForAction(t.allowedApps.map(e=>e.bundleId),t.selectedDisplayId);t.lastScreenshot!==void 0&&(r=n),n.length>0&&t.onAppsHidden?.(n)}let i=t.allowedApps.map(e=>e.bundleId),a=await Ee(e.executor,i,e.logger,t.selectedDisplayId),o=await Ue(e,r),s=await Ge(e,a.displayId??0,t.lastScreenshot?.displayId,t.onDisplayPinned!==void 0);return{content:[...s?[{type:`text`,text:s}]:[],...o?[{type:`text`,text:o}]:[],...a.accessibilityText?[{type:`text`,text:`GUI elements in this window:\n${a.accessibilityText}`}]:[],{type:`image`,data:a.base64,mimeType:T(a.base64)}],screenshot:a}}async function qe(e,t,n){let r=t.region;if(!Array.isArray(r)||r.length!==4)return E(`region must be an array of length 4: [x0, y0, x1, y1]`,`bad_args`);let[i,a,o,s]=r;if(![i,a,o,s].every(e=>typeof e==`number`&&e>=0))return E(`region values must be non-negative numbers`,`bad_args`);if(o<=i)return E(`region x1 must be greater than x0`,`bad_args`);if(s<=a)return E(`region y1 must be greater than y0`,`bad_args`);let c=n.lastScreenshot;if(!c)return E(`take a screenshot before zooming (region coords are relative to it)`,`state_conflict`);if(o>c.width||s>c.height)return E(`region exceeds screenshot bounds (${c.width}×${c.height})`,`bad_args`);let l=c.displayWidth/c.width,u=c.displayHeight/c.height,d={x:i*l,y:a*u,w:(o-i)*l,h:(s-a)*u},f=n.allowedApps.map(e=>e.bundleId),p=await e.executor.zoom(d,f,c.displayId);return{content:[{type:`image`,data:p.base64,mimeType:T(p.base64)}]}}async function V(e,t,n,r,i,a){J&&(await e.executor.mouseUp(),J=!1,Y=!1);let o=A(t);if(o instanceof Error)return E(o.message,`bad_args`);let[s,c]=o,l;if(t.text!==void 0){if(typeof t.text!=`string`)return E(`text must be a string`,`bad_args`);if(S(t.text,e.executor.capabilities.platform)&&!n.grantFlags.systemKeyCombos)return E(`The modifier chord "${t.text}" would fire a system shortcut. Request the systemKeyCombos grant flag via request_access, or use only modifier keys (shift, ctrl, alt, cmd) in the text parameter.`,`grant_flag_required`);l=Oe(t.text)}let u=i!==`left`||l!==void 0&&l.length>0?`mouse_full`:`mouse`,d=await N(e,n,r,u);if(d)return d;let f=await e.executor.getDisplaySize(n.selectedDisplayId);if(r.pixelValidation){let{xPct:t,yPct:r}=we(s,c,n.coordinateMode,n.lastScreenshot),i=await xe(e.cropRawPatch,n.lastScreenshot,t,r,async()=>{let t=n.allowedApps.map(e=>e.bundleId);try{return await e.executor.screenshot({allowedBundleIds:t,displayId:n.lastScreenshot?.displayId})}catch{return null}},e.logger);if(!i.valid&&i.warning)return D(i.warning)}let{x:p,y:m}=j(s,c,n.coordinateMode,f,n.lastScreenshot,e.logger);return await P(e,n,r,p,m,u)||(await e.executor.click(p,m,i,a,l),D(`Clicked.`))}async function Je(e,t,n,r){let i=k(t,`text`);if(i instanceof Error)return E(i.message,`bad_args`);let a=await N(e,n,r,`keyboard`);if(a)return a;if(i.includes(`
|
|
4
|
+
`)&&n.grantFlags.clipboardWrite&&r.clipboardPasteMultiline)return await e.executor.type(i,{viaClipboard:!0}),D(`Typed (via clipboard).`);let o=De(i);for(let[t,r]of o.entries()){if(n.isAborted?.())return E(`Typing aborted after ${t} of ${o.length} graphemes (user interrupt).`);await I(xt),r===`
|
|
5
|
+
`||r===`\r`||r===`\r
|
|
6
|
+
`?await e.executor.key(`return`):r===` `?await e.executor.key(`tab`):await e.executor.type(r,{viaClipboard:!1})}return D(`Typed ${o.length} grapheme(s).`)}async function Ye(e,t,n,r){let i=k(t,`text`);if(i instanceof Error)return E(`text is required`,`bad_args`);let a;if(t.repeat!==void 0){if(typeof t.repeat!=`number`||!Number.isInteger(t.repeat)||t.repeat<1)return E(`repeat must be a positive integer`,`bad_args`);if(t.repeat>100)return E(`repeat exceeds maximum of 100`,`bad_args`);a=t.repeat}return S(i,e.executor.capabilities.platform)&&!n.grantFlags.systemKeyCombos?E(`"${i}" is a system-level shortcut. Request the \`systemKeyCombos\` grant via request_access to use it.`,`grant_flag_required`):await N(e,n,r,`keyboard`)||(await e.executor.key(i,a),D(`Key pressed.`))}async function Xe(e,t,n,r){let i=A(t);if(i instanceof Error)return E(i.message,`bad_args`);let[a,o]=i,s=t.scroll_direction;if(s!==`up`&&s!==`down`&&s!==`left`&&s!==`right`)return E(`scroll_direction must be 'up', 'down', 'left', or 'right'`,`bad_args`);let c=t.scroll_amount;if(typeof c!=`number`||!Number.isInteger(c)||c<0)return E(`scroll_amount must be a non-negative int`,`bad_args`);if(c>100)return E(`scroll_amount exceeds maximum of 100`,`bad_args`);let l=s===`left`?-c:s===`right`?c:0,u=s===`up`?-c:s===`down`?c:0,d=await N(e,n,r,`mouse`);if(d)return d;let f=await e.executor.getDisplaySize(n.selectedDisplayId),{x:p,y:m}=j(a,o,n.coordinateMode,f,n.lastScreenshot,e.logger);return await P(e,n,r,p,m,J?`mouse_full`:`mouse`)||(J&&(Y=!0),await e.executor.scroll(p,m,l,u),D(`Scrolled.`))}async function Ze(e,t,n,r){J&&(await e.executor.mouseUp(),J=!1,Y=!1);let i=A(t,`coordinate`);if(i instanceof Error)return E(i.message,`bad_args`);let a=i,o;if(t.start_coordinate!==void 0){let e=A(t,`start_coordinate`);if(e instanceof Error)return E(e.message,`bad_args`);o=e}let s=await N(e,n,r,`mouse`);if(s)return s;let c=await e.executor.getDisplaySize(n.selectedDisplayId),l=o===void 0?void 0:j(o[0],o[1],n.coordinateMode,c,n.lastScreenshot,e.logger),u=j(a[0],a[1],n.coordinateMode,c,n.lastScreenshot,e.logger),d=l??await e.executor.getCursorPosition();return await P(e,n,r,d.x,d.y,`mouse`)||await P(e,n,r,u.x,u.y,`mouse_full`)||(await e.executor.drag(l,u),D(`Dragged.`))}async function Qe(e,t,n,r){let i=A(t);if(i instanceof Error)return E(i.message,`bad_args`);let[a,o]=i,s=await N(e,n,r,J?`mouse`:`mouse_position`);if(s)return s;let c=await e.executor.getDisplaySize(n.selectedDisplayId),{x:l,y:u}=j(a,o,n.coordinateMode,c,n.lastScreenshot,e.logger);if(J){let t=await P(e,n,r,l,u,`mouse_full`);if(t)return t}return await e.executor.moveMouse(l,u),J&&(Y=!0),D(`Moved.`)}async function $e(e,t,n){let r=k(t,`app`);if(r instanceof Error)return E(r.message,`bad_args`);let i=new Set(n.allowedApps.map(e=>e.bundleId)),a;if(a=R(r)&&i.has(r)?r:n.allowedApps.find(e=>e.displayName.toLowerCase()===r.toLowerCase())?.bundleId,!a||!i.has(a))return E(`"${r}" is not granted for this session. Call request_access first.`,`app_not_granted`);if(await e.executor.openApp(a),n.onDisplayPinned!==void 0){let t=1;try{t=(await e.executor.listDisplays()).length}catch{}if(t>=2)return D(`Opened "${r}". If it isn't visible in the next screenshot, it may have opened on a different monitor — use switch_display to check.`)}return D(`Opened "${r}".`)}async function H(e,t){if(!e.executor.virtualMouse)return E(`virtual_mouse is only available on Windows with a bound window.`,`feature_unavailable`);let n=k(t,`action`);if(n instanceof Error)return E(n.message,`bad_args`);let r=t.coordinate;if(!Array.isArray(r)||r.length<2)return E(`coordinate [x, y] is required.`,`bad_args`);let i=new Set([`click`,`double_click`,`right_click`,`move`,`drag`,`down`,`up`]);if(!i.has(n))return E(`Invalid action "${n}". Valid: ${[...i].join(`, `)}`,`bad_args`);let a=Array.isArray(t.start_coordinate)?t.start_coordinate:void 0;return await e.executor.virtualMouse({action:n,x:r[0],y:r[1],startX:a?.[0],startY:a?.[1]})?D({click:`Click at (${r[0]},${r[1]})`,double_click:`Double-click at (${r[0]},${r[1]})`,right_click:`Right-click at (${r[0]},${r[1]})`,move:`Moved to (${r[0]},${r[1]})`,drag:`Dragged ${a?`(${a[0]},${a[1]})`:`current`} → (${r[0]},${r[1]})`,down:`Button down at (${r[0]},${r[1]})`,up:`Button up at (${r[0]},${r[1]})`}[n]??n):E(`No window is currently bound.`,`bad_args`)}async function U(e,t){if(!e.executor.virtualKeyboard)return E(`virtual_keyboard is only available on Windows with a bound window.`,`feature_unavailable`);let n=k(t,`action`);if(n instanceof Error)return E(n.message,`bad_args`);let r=k(t,`text`);if(r instanceof Error)return E(r.message,`bad_args`);let i=new Set([`type`,`combo`,`press`,`release`,`hold`]);if(!i.has(n))return E(`Invalid action "${n}". Valid: ${[...i].join(`, `)}`,`bad_args`);let a=typeof t.duration==`number`?t.duration:void 0,o=typeof t.repeat==`number`?t.repeat:void 0;return await e.executor.virtualKeyboard({action:n,text:r,duration:a,repeat:o})?D(`${{type:`Typed "${r.length>40?r.slice(0,40)+`...`:r}"`,combo:`Sent ${r}`,press:`Pressed ${r} (holding)`,release:`Released ${r}`,hold:`Held ${r} for ${a??1}s`}[n]}${o&&o>1?` ×${o}`:``}`):E(`No window is currently bound. Use open_application or bind_window first.`,`bad_args`)}async function et(e,t){if(!e.executor.statusIndicator)return E(`status_indicator is only available on Windows.`,`feature_unavailable`);let n=k(t,`action`);if(n instanceof Error)return E(n.message,`bad_args`);if(![`show`,`hide`,`status`].includes(n))return E(`Invalid action "${n}". Valid: show, hide, status.`,`bad_args`);let r=typeof t.message==`string`?t.message:void 0;if(n===`show`&&!r)return E(`'show' requires a message parameter.`,`bad_args`);let i=await e.executor.statusIndicator(n,r);return D(n===`status`?i.active?`Indicator is active on the bound window.`:`Indicator is not active (no window bound).`:n===`show`?`Indicator showing: "${r}"`:`Indicator hidden.`)}async function tt(e,t){if(!e.executor.mouseWheel)return E(`mouse_wheel is only available on Windows with a bound window.`,`feature_unavailable`);let n=t.coordinate;if(!Array.isArray(n)||n.length<2)return E(`coordinate must be [x, y] array.`,`bad_args`);let r=typeof t.delta==`number`?t.delta:void 0;if(r===void 0)return E(`delta is required (positive=up, negative=down).`,`bad_args`);let i=t.direction===`horizontal`;return await e.executor.mouseWheel(n[0],n[1],r,i)?D(`Mouse wheel: ${i?`horizontal`:`vertical`} scroll ${r>0?`up`:`down`} ${Math.abs(r)} click(s) at (${n[0]},${n[1]}).`):E(`No window is currently bound. Use open_application or bind_window first.`,`bad_args`)}async function nt(e,t){if(!e.executor.activateWindow)return E(`activate_window is only available on Windows with a bound window.`,`feature_unavailable`);let n=typeof t.click_x==`number`?t.click_x:void 0,r=typeof t.click_y==`number`?t.click_y:void 0;return await e.executor.activateWindow(n,r)?D(`Window activated and focused. Ready for input.`):E(`No window is currently bound. Use open_application or bind_window first.`,`bad_args`)}async function rt(e,t){if(!e.executor.respondToPrompt)return E(`prompt_respond is only available on Windows with a bound window.`,`feature_unavailable`);let n=k(t,`response_type`);if(n instanceof Error)return E(n.message,`bad_args`);let r=new Set([`yes`,`no`,`enter`,`escape`,`select`,`type`]);return r.has(n)?n===`select`&&typeof t.arrow_count!=`number`?E(`'select' requires arrow_count parameter.`,`bad_args`):n===`type`&&typeof t.text!=`string`?E(`'type' requires text parameter.`,`bad_args`):await e.executor.respondToPrompt({responseType:n,arrowDirection:typeof t.arrow_direction==`string`?t.arrow_direction:void 0,arrowCount:typeof t.arrow_count==`number`?t.arrow_count:void 0,text:typeof t.text==`string`?t.text:void 0})?D(`Prompt responded: ${{yes:`Sent 'y' + Enter.`,no:`Sent 'n' + Enter.`,enter:`Sent Enter.`,escape:`Sent Escape.`,select:`Navigated ${t.arrow_direction??`down`} ${t.arrow_count??1} time(s) + Enter.`,type:`Typed "${t.text}" + Enter.`}[n]??n}. Take a screenshot to verify.`):E(`No window is currently bound. Use open_application or bind_window first.`,`bad_args`):E(`Invalid response_type "${n}". Valid: ${[...r].join(`, `)}`,`bad_args`)}async function it(e,t){if(!e.executor.openTerminal)return E(`open_terminal is only available on Windows.`,`feature_unavailable`);let n=k(t,`agent`);if(n instanceof Error)return E(n.message,`bad_args`);if(!new Set([`claude`,`codex`,`gemini`,`custom`]).has(n))return E(`Invalid agent "${n}". Valid: claude, codex, gemini, custom.`,`bad_args`);if(n===`custom`&&typeof t.command!=`string`)return E(`agent='custom' requires 'command' parameter.`,`bad_args`);let r=await e.executor.openTerminal({agent:n,command:typeof t.command==`string`?t.command:void 0,terminal:typeof t.terminal==`string`?t.terminal:void 0,workingDirectory:typeof t.working_directory==`string`?t.working_directory:void 0});return r?r.launched?D(`Terminal opened and ${{claude:`Claude Code`,codex:`Codex`,gemini:`Gemini`,custom:t.command}[n]??n} launched.\nWindow: hwnd=${r.hwnd} "${r.title}"\nCommand: '${n===`custom`?t.command:n}' + Enter\nStatus: bound to this terminal. Take a screenshot to verify the agent started.`):D(`Terminal opened (hwnd=${r.hwnd}, "${r.title}") but no command was sent. Window is now bound.`):E(`Failed to open terminal. Windows Terminal (wt.exe) may not be installed.`,`launch_failed`)}async function at(e,t){let n=k(t,`action`);if(n instanceof Error)return E(n.message,`bad_args`);switch(n){case`list`:{if(!e.executor.listVisibleWindows)return E(`bind_window is only available on Windows.`,`feature_unavailable`);let t=await e.executor.listVisibleWindows();if(t.length===0)return D(`No visible windows found.`);let n=t.map(e=>`hwnd=${e.hwnd} pid=${e.pid} "${e.title}"`);return D(`Visible windows (${t.length}):\n${n.join(`
|
|
7
|
+
`)}`)}case`status`:{if(!e.executor.getBindingStatus)return E(`bind_window is only available on Windows.`,`feature_unavailable`);let t=await e.executor.getBindingStatus();if(!t||!t.bound)return D(`No window is currently bound. Use bind_window(action='list') to see available windows, then bind_window(action='bind', title='...') to bind.`);let n=`Bound to: hwnd=${t.hwnd}`;return t.title&&(n+=` "${t.title}"`),t.pid&&(n+=` pid=${t.pid}`),t.rect&&(n+=` rect=(${t.rect.x},${t.rect.y} ${t.rect.width}x${t.rect.height})`),D(n)}case`bind`:{if(!e.executor.bindToWindow)return E(`bind_window is only available on Windows.`,`feature_unavailable`);let n=typeof t.title==`string`?t.title:void 0,r=typeof t.hwnd==`string`?t.hwnd:void 0,i=typeof t.pid==`number`?t.pid:void 0;if(!n&&!r&&!i)return E(`Specify at least one of: title, hwnd, or pid.`,`bad_args`);let a=await e.executor.bindToWindow({hwnd:r,title:n,pid:i});return a?D(`Bound to window: hwnd=${a.hwnd} pid=${a.pid} "${a.title}". All subsequent screenshot/click/type operations target this window.`):E(`No window found matching: ${[n&&`title="${n}"`,r&&`hwnd=${r}`,i&&`pid=${i}`].filter(Boolean).join(`, `)}. Use bind_window(action='list') to see available windows.`,`element_not_found`)}case`unbind`:return e.executor.unbindFromWindow?(await e.executor.unbindFromWindow(),D(`Window binding released. Operations now target the full screen.`)):E(`bind_window is only available on Windows.`,`feature_unavailable`);default:return E(`Unknown bind_window action "${n}". Valid: list, bind, unbind, status.`,`bad_args`)}}async function ot(e,t){if(!e.executor.clickElement)return E(`click_element is only available on Windows with a bound window.`,`feature_unavailable`);let n=typeof t.name==`string`?t.name:void 0,r=typeof t.role==`string`?t.role:void 0,i=typeof t.automationId==`string`?t.automationId:void 0;return!n&&!r&&!i?E(`At least one of name, role, or automationId is required.`,`bad_args`):await e.executor.clickElement({name:n,role:r,automationId:i})?D(`Clicked element: ${[n&&`"${n}"`,r,i].filter(Boolean).join(` `)}`):E(`Element not found: ${[n&&`name="${n}"`,r&&`role=${r}`,i&&`id=${i}`].filter(Boolean).join(`, `)}. Take a screenshot to see current GUI elements.`,`element_not_found`)}async function st(e,t){if(!e.executor.typeIntoElement)return E(`type_into_element is only available on Windows with a bound window.`,`feature_unavailable`);let n=k(t,`text`);if(n instanceof Error)return E(n.message,`bad_args`);let r=typeof t.name==`string`?t.name:void 0,i=typeof t.role==`string`?t.role:void 0,a=typeof t.automationId==`string`?t.automationId:void 0;return await e.executor.typeIntoElement({name:r,role:i,automationId:a},n)?D(`Typed ${n.length} chars into: ${[r&&`"${r}"`,i,a].filter(Boolean).join(` `)}`):E(`Could not type into element: ${[r&&`name="${r}"`,i&&`role=${i}`,a&&`id=${a}`].filter(Boolean).join(`, `)}. The element was not found or doesn't support text input.`,`element_not_found`)}async function ct(e,t){let n=k(t,`action`);if(n instanceof Error)return E(n.message,`bad_args`);let r=new Set([`minimize`,`maximize`,`restore`,`close`,`focus`,`move_offscreen`,`move_resize`,`get_rect`]);if(!r.has(n))return E(`Unknown window_management action "${n}". Valid: ${[...r].join(`, `)}`,`bad_args`);if(!e.executor.manageWindow)return E(`window_management is only available on Windows with a bound window.`,`feature_unavailable`);if(n===`get_rect`){if(!e.executor.getWindowRect)return E(`getWindowRect not available.`,`feature_unavailable`);let t=await e.executor.getWindowRect();return t?D(`Window rect: x=${t.x}, y=${t.y}, width=${t.width}, height=${t.height}`):E(`No window is currently bound. Call open_application first.`,`bad_args`)}if(n===`move_resize`){let r=typeof t.x==`number`?t.x:void 0,i=typeof t.y==`number`?t.y:void 0;if(r===void 0||i===void 0)return E(`move_resize requires x and y parameters.`,`bad_args`);let a=typeof t.width==`number`?t.width:void 0,o=typeof t.height==`number`?t.height:void 0;return await e.executor.manageWindow(n,{x:r,y:i,width:a,height:o})?D(a&&o?`Moved window to (${r}, ${i}) and resized to ${a}×${o}.`:`Moved window to (${r}, ${i}).`):E(`No window is currently bound. Call open_application first.`,`bad_args`)}return await e.executor.manageWindow(n)?D({minimize:`Window minimized (ShowWindow SW_MINIMIZE).`,maximize:`Window maximized (ShowWindow SW_MAXIMIZE).`,restore:`Window restored (ShowWindow SW_RESTORE).`,close:`Window closed (SendMessage WM_CLOSE). The window binding has been released.`,focus:`Window brought to front (SetForegroundWindow).`,move_offscreen:`Window moved offscreen (-32000,-32000). Still usable via SendMessage/PrintWindow.`}[n]??`Action "${n}" completed.`):E(`No window is currently bound. Call open_application first.`,`bad_args`)}async function lt(e,t,n){let r=k(t,`display`);if(r instanceof Error)return E(r.message,`bad_args`);if(!n.onDisplayPinned)return E(`Display switching is not available in this session.`,`feature_unavailable`);if(r.toLowerCase()===`auto`)return n.onDisplayPinned(void 0),D(`Returned to automatic monitor selection. Call screenshot to continue.`);let i;try{i=await e.executor.listDisplays()}catch(e){return E(`Failed to enumerate displays: ${String(e)}`,`display_error`)}if(i.length<2)return E(`Only one monitor is connected. There is nothing to switch to.`,`bad_args`);let a=We(i),o=r.toLowerCase(),s=i.find(e=>a.get(e.displayId)?.toLowerCase()===o);return s?(n.onDisplayPinned(s.displayId),D(`Switched to monitor "${a.get(s.displayId)}". Call screenshot to see it.`)):E(`No monitor named "${r}" is connected. Available monitors: ${i.map(e=>`"${a.get(e.displayId)}"`).join(`, `)}.`,`bad_args`)}function ut(e){return O({allowedApps:e.allowedApps,grantFlags:e.grantFlags})}async function dt(e,t,n){if(!t.grantFlags.clipboardRead)return E("Clipboard read is not granted. Request `clipboardRead` via request_access.",`grant_flag_required`);if(n.clipboardGuard){let n=await e.executor.getFrontmostApp(),r=new Map(t.allowedApps.map(e=>[e.bundleId,e.tier]));await M(e,t,(n?r.get(n.bundleId):void 0)===`click`)}return O({text:await e.executor.readClipboard()})}async function ft(e,t,n,r){if(!n.grantFlags.clipboardWrite)return E("Clipboard write is not granted. Request `clipboardWrite` via request_access.",`grant_flag_required`);let i=k(t,`text`);if(i instanceof Error)return E(i.message,`bad_args`);if(r.clipboardGuard){let t=await e.executor.getFrontmostApp(),r=new Map(n.allowedApps.map(e=>[e.bundleId,e.tier])),i=t?r.get(t.bundleId):void 0;if(t&&i===`click`)return E(`"${t.displayName}" is a tier-"click" app and currently frontmost. write_clipboard is blocked because the next action would clear the clipboard anyway — a UI Paste button in this app cannot be used to inject text. Bring a tier-"full" app forward before writing to the clipboard. Do not attempt to work around this restriction — never use AppleScript, System Events, shell commands, or any other method to send clicks or keystrokes to this app.`,`tier_insufficient`);await M(e,n,i===`click`)}return await e.executor.writeClipboard(i),D(`Clipboard written.`)}async function pt(e){let t=e.duration;return typeof t!=`number`||!Number.isFinite(t)?E(`duration must be a number`,`bad_args`):t<0?E(`duration must be non-negative`,`bad_args`):t>100?E(`duration is too long. Duration is in seconds.`,`bad_args`):(await I(t*1e3),D(`Waited ${t}s.`))}async function mt(e,t){let n=await e.executor.getCursorPosition(),r=t.lastScreenshot;if(r){let e=n.x-r.originX,t=n.y-r.originY;return e<0||e>r.displayWidth||t<0||t>r.displayHeight?O({x:n.x,y:n.y,coordinateSpace:`logical_points`,note:`cursor is on a different monitor than your last screenshot; take a fresh screenshot`}):O({x:Math.round(e*(r.width/r.displayWidth)),y:Math.round(t*(r.height/r.displayHeight)),coordinateSpace:`image_pixels`})}return O({x:n.x,y:n.y,coordinateSpace:`logical_points`,note:`take a screenshot first for image-pixel coordinates`})}async function ht(e,t,n,r){let i=k(t,`text`);if(i instanceof Error)return E(i.message,`bad_args`);let a=t.duration;if(typeof a!=`number`||!Number.isFinite(a))return E(`duration must be a number`,`bad_args`);if(a<0)return E(`duration must be non-negative`,`bad_args`);if(a>100)return E(`duration is too long. Duration is in seconds.`,`bad_args`);if(S(i,e.executor.capabilities.platform)&&!n.grantFlags.systemKeyCombos)return E(`"${i}" is a system-level shortcut. Request the \`systemKeyCombos\` grant via request_access to use it.`,`grant_flag_required`);let o=await N(e,n,r,`keyboard`);if(o)return o;let s=Oe(i);return await e.executor.holdKey(s,a*1e3),D(`Key held.`)}async function gt(e,t,n){if(J)return E(`mouse button already held, call left_mouse_up first`,`state_conflict`);let r=await N(e,t,n,`mouse`);if(r)return r;let i=await e.executor.getCursorPosition();return await P(e,t,n,i.x,i.y,`mouse`)||(await e.executor.mouseDown(),J=!0,Y=!1,D(`Mouse button pressed.`))}async function _t(e,t,n){let r=async t=>(await e.executor.mouseUp(),J=!1,Y=!1,t),i=await N(e,t,n,`mouse`);if(i)return r(i);let a=await e.executor.getCursorPosition(),o=await P(e,t,n,a.x,a.y,Y?`mouse_full`:`mouse`);return o?r(o):(await e.executor.mouseUp(),J=!1,Y=!1,D(`Mouse button released.`))}async function vt(e,t,n,r){let i=t.actions;if(!Array.isArray(i)||i.length===0)return E(`actions must be a non-empty array`,`bad_args`);for(let[e,t]of i.entries()){if(typeof t!=`object`||!t)return E(`actions[${e}] must be an object`,`bad_args`);let n=t.action;if(typeof n!=`string`)return E(`actions[${e}].action must be a string`,`bad_args`);if(!X.has(n))return E(`actions[${e}].action="${n}" is not allowed in a batch. Allowed: ${[...X].join(`, `)}.`,`bad_args`)}if(r.hideBeforeAction){let t=await e.executor.prepareForAction(n.allowedApps.map(e=>e.bundleId),n.selectedDisplayId);t.length>0&&n.onAppsHidden?.(t)}let a={...r,hideBeforeAction:!1,pixelValidation:!1,autoTargetDisplay:!1},o=[];for(let[t,r]of i.entries()){if(n.isAborted?.())return await L(e),E(`Batch aborted after ${o.length} of ${i.length} actions (user interrupt).`);t>0&&await I(10);let s=r,c=s.action,{screenshot:l,...u}=await W(c,s,e,n,a),d=yt(u),f={action:c,ok:!u.isError,output:d};if(o.push(f),u.isError)return await L(e),O({completed:o.slice(0,-1),failed:f,remaining:i.length-o.length},u.telemetry)}return O({completed:o})}function yt(e){let t=e.content[0];return t&&t.type===`text`?t.text:``}async function W(e,t,n,r,i){if(await n.executor.hasBoundWindow?.()===!0&&n.executor.virtualMouse&&n.executor.virtualKeyboard){let r=Array.isArray(t.coordinate)?t.coordinate:void 0;switch(e){case`left_click`:if(r)return H(n,{action:`click`,coordinate:r});break;case`double_click`:if(r)return H(n,{action:`double_click`,coordinate:r});break;case`right_click`:if(r)return H(n,{action:`right_click`,coordinate:r});break;case`mouse_move`:if(r)return H(n,{action:`move`,coordinate:r});break;case`left_click_drag`:if(r)return H(n,{action:`drag`,coordinate:r,start_coordinate:Array.isArray(t.start_coordinate)?t.start_coordinate:void 0});break;case`left_mouse_down`:if(r)return H(n,{action:`down`,coordinate:r});break;case`left_mouse_up`:if(r)return H(n,{action:`up`,coordinate:r});break;case`type`:if(typeof t.text==`string`)return U(n,{action:`type`,text:t.text});break;case`key`:if(typeof t.text==`string`)return U(n,{action:`combo`,text:t.text,repeat:t.repeat});break;case`hold_key`:if(typeof t.text==`string`)return U(n,{action:`hold`,text:t.text,duration:typeof t.duration==`number`?t.duration:1});break;case`scroll`:if(r)return tt(n,{coordinate:r,delta:t.scroll_direction===`up`?t.scroll_amount??3:-(t.scroll_amount??3),direction:t.scroll_direction===`left`||t.scroll_direction===`right`?`horizontal`:`vertical`});break}}switch(e){case`screenshot`:return Ke(n,r,i);case`zoom`:return qe(n,t,r);case`left_click`:return V(n,t,r,i,`left`,1);case`double_click`:return V(n,t,r,i,`left`,2);case`triple_click`:return V(n,t,r,i,`left`,3);case`right_click`:return V(n,t,r,i,`right`,1);case`middle_click`:return V(n,t,r,i,`middle`,1);case`type`:return Je(n,t,r,i);case`key`:return Ye(n,t,r,i);case`scroll`:return Xe(n,t,r,i);case`left_click_drag`:return Ze(n,t,r,i);case`mouse_move`:return Qe(n,t,r,i);case`wait`:return pt(t);case`cursor_position`:return mt(n,r);case`hold_key`:return ht(n,t,r,i);case`left_mouse_down`:return gt(n,r,i);case`left_mouse_up`:return _t(n,r,i);case`open_application`:return $e(n,t,r);case`window_management`:return ct(n,t);case`click_element`:return ot(n,t);case`type_into_element`:return st(n,t);case`open_terminal`:return it(n,t);case`bind_window`:return at(n,t);case`virtual_mouse`:return H(n,t);case`virtual_keyboard`:return U(n,t);case`status_indicator`:return et(n,t);case`mouse_wheel`:return tt(n,t);case`activate_window`:return nt(n,t);case`prompt_respond`:return rt(n,t);case`switch_display`:return lt(n,t,r);case`list_granted_applications`:return ut(r);case`read_clipboard`:return dt(n,r,i);case`write_clipboard`:return ft(n,t,r,i);case`computer_batch`:return vt(n,t,r,i);default:return E(`Unknown tool "${e}".`,`bad_args`)}}async function bt(e,t,n,r){let{logger:i,serverName:a}=e,o=new Set(r.userDeniedBundleIds),c=r.allowedApps.some(e=>e.tier===void 0||o.has(e.bundleId)||_(e.bundleId,e.displayName))?{...r,allowedApps:r.allowedApps.filter(e=>!o.has(e.bundleId)).filter(e=>!_(e.bundleId,e.displayName)).map(e=>e.tier===void 0?{...e,tier:x(e.bundleId,e.displayName)}:e)}:r;if(e.isDisabled())return E(`Computer control is disabled in Settings. Enable it and try again.`,`other`);let l=await e.ensureOsPermissions(),u;if(!l.granted){if(t!==`request_access`&&t!==`request_teach_access`)return E(`Accessibility and Screen Recording permissions are required. Call request_access to show the permission panel.`,`tcc_not_granted`);u={accessibility:l.accessibility,screenRecording:l.screenRecording}}let d=Ae(t),f=c.checkCuLock?.();if(f){if(f.holder!==void 0&&!f.isSelf)return E(`Another Claude session is currently using the computer. Wait for the user to acknowledge it is finished (stop button in the Claude window), or find a non-computer-use approach if one is readily apparent.`,`cu_lock_held`);f.holder===void 0&&!d&&(c.acquireCuLock?.(),ke())}let p=e.getSubGates(),m=Ce(n);i.silly(`[${a}] tool=${t} args=${JSON.stringify(m).slice(0,200)}`);try{return t===`request_access`?await Me(e,m,c,u):t===`request_teach_access`?await Le(e,m,c,u):t===`teach_step`?await Ve(e,m,c,p):t===`teach_batch`?await He(e,m,c,p):await W(t,m,e,c,p)}catch(e){let n=e instanceof Error?e.message:String(e);return i.error(`[${a}] tool=${t} threw: ${n}`,s(e)),E(`Tool "${t}" failed: ${n}`,`executor_threw`)}}var G,K,q,xt,J,Y,St,X,Ct=e((()=>{ce(),pe(),Se(),h(),l(),G=`com.apple.finder`,K=` Do not attempt to work around this restriction — never use AppleScript, System Events, shell commands, or any other method to send clicks or keystrokes to this app.`,q=1024,xt=8,J=!1,Y=!1,St=/^[A-Za-z0-9][\w.-]*\.[A-Za-z0-9][\w.-]*$/,X=new Set([`key`,`type`,`mouse_move`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`triple_click`,`scroll`,`hold_key`,`screenshot`,`cursor_position`,`left_mouse_down`,`left_mouse_up`,`wait`])}));function wt(e,t,n){let r=Et[t],i=n&&n.length>0?` Available applications on this machine: ${n.join(`, `)}.`:``,a={type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:`(x, y): ${r.x}`},o={type:`string`,description:`Modifier keys to hold during the click (e.g. "shift", "ctrl+shift"). Supports the same syntax as the key tool.`},s=e.screenshotFiltering===`native`?`Take a screenshot of the primary display. Applications not in the session allowlist are excluded at the compositor level — only granted apps and the desktop are visible.`:`Take a screenshot of the primary display. On this platform, screenshots are NOT filtered — all open windows are visible. Input actions targeting apps not in the session allowlist are rejected.`;return[{name:`request_access`,description:`Request user permission to control a set of applications for this session. Must be called before any other tool in this server. The user sees a single dialog listing all requested apps and either allows the whole set or denies it. Call this again mid-session to add more apps; previously granted apps remain granted. Returns the granted apps, denied apps, and screenshot filtering capability.`,inputSchema:{type:`object`,properties:{apps:{type:`array`,items:{type:`string`},description:`Application display names (e.g. "Slack", "Calendar") or bundle identifiers (e.g. "com.tinyspeck.slackmacgap"). Display names are resolved case-insensitively against installed apps.`+i},reason:{type:`string`,description:`One-sentence explanation shown to the user in the approval dialog. Explain the task, not the mechanism.`},clipboardRead:{type:`boolean`,description:`Also request permission to read the user's clipboard (separate checkbox in the dialog).`},clipboardWrite:{type:`boolean`,description:"Also request permission to write the user's clipboard. When granted, multi-line `type` calls use the clipboard fast path."},systemKeyCombos:{type:`boolean`,description:`Also request permission to send system-level key combos (quit app, switch app, lock screen). Without this, those specific combos are blocked.`}},required:[`apps`,`reason`]}},{name:`screenshot`,description:s+` Returns an error if the allowlist is empty. The returned image is what subsequent click coordinates are relative to.`,inputSchema:{type:`object`,properties:{save_to_disk:{type:`boolean`,description:`Save the image to disk so it can be attached to a message for the user. Returns the saved path in the tool result. Only set this when you intend to share the image — screenshots you're just looking at don't need saving.`}},required:[]}},{name:`zoom`,description:`Take a higher-resolution screenshot of a specific region of the last full-screen screenshot. Use this liberally to inspect small text, button labels, or fine UI details that are hard to read in the downsampled full-screen image. IMPORTANT: Coordinates in subsequent click calls always refer to the full-screen screenshot, never the zoomed image. This tool is read-only for inspecting detail.`,inputSchema:{type:`object`,properties:{region:{type:`array`,items:{type:`integer`},minItems:4,maxItems:4,description:`(x0, y0, x1, y1): Rectangle to zoom into, in the coordinate space of the most recent full-screen screenshot. x0,y0 = top-left, x1,y1 = bottom-right.`},save_to_disk:{type:`boolean`,description:`Save the image to disk so it can be attached to a message for the user. Returns the saved path in the tool result. Only set this when you intend to share the image.`}},required:[`region`]}},{name:`left_click`,description:`Left-click at the given coordinates. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:a,text:o},required:[`coordinate`]}},{name:`double_click`,description:`Double-click at the given coordinates. Selects a word in most text editors. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:a,text:o},required:[`coordinate`]}},{name:`triple_click`,description:`Triple-click at the given coordinates. Selects a line in most text editors. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:a,text:o},required:[`coordinate`]}},{name:`right_click`,description:`Right-click at the given coordinates. Opens a context menu in most applications. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:a,text:o},required:[`coordinate`]}},{name:`middle_click`,description:`Middle-click (scroll-wheel click) at the given coordinates. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:a,text:o},required:[`coordinate`]}},{name:`type`,description:`Type text into whatever currently has keyboard focus. ${Z} Newlines are supported. For keyboard shortcuts use \`key\` instead.`,inputSchema:{type:`object`,properties:{text:{type:`string`,description:`Text to type.`}},required:[`text`]}},{name:`key`,description:`Press a key or key combination (e.g. "return", "escape", "cmd+a", "ctrl+shift+tab"). ${Z} System-level combos (quit app, switch app, lock screen) require the \`systemKeyCombos\` grant — without it they return an error. All other combos work.`,inputSchema:{type:`object`,properties:{text:{type:`string`,description:`Modifiers joined with "+", e.g. "cmd+shift+a".`},repeat:{type:`integer`,minimum:1,maximum:100,description:`Number of times to repeat the key press. Default is 1.`}},required:[`text`]}},{name:`scroll`,description:`Scroll at the given coordinates. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:a,scroll_direction:{type:`string`,enum:[`up`,`down`,`left`,`right`],description:`Direction to scroll.`},scroll_amount:{type:`integer`,minimum:0,maximum:100,description:`Number of scroll ticks.`}},required:[`coordinate`,`scroll_direction`,`scroll_amount`]}},{name:`left_click_drag`,description:`Press, move to target, and release. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:{...a,description:`(x, y) end point: ${r.x}`},start_coordinate:{...a,description:`(x, y) start point. If omitted, drags from the current cursor position. ${r.x}`}},required:[`coordinate`]}},{name:`mouse_move`,description:`Move the mouse cursor without clicking. Useful for triggering hover states. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:a},required:[`coordinate`]}},{name:`open_application`,description:`Bring an application to the front, launching it if necessary. The target application must already be in the session allowlist — call request_access first.`,inputSchema:{type:`object`,properties:{app:{type:`string`,description:`Display name (e.g. "Slack") or bundle identifier (e.g. "com.tinyspeck.slackmacgap").`}},required:[`app`]}},...e.platform===`win32`?[{name:`window_management`,description:`Manage the bound application window via Win32 API calls (ShowWindow, SetWindowPos, SendMessage). All operations target the bound HWND directly — NO global shortcuts (Win+Down, Alt+F4, etc.). The window must have been opened via open_application first. Actions: minimize (hide to taskbar), maximize (fill screen), restore (undo min/max), close (graceful WM_CLOSE), focus (bring to front), move_offscreen (move to -32000,-32000 for background operation). Use move_resize to reposition or resize the window to specific coordinates.`,inputSchema:{type:`object`,properties:{action:{type:`string`,enum:[`minimize`,`maximize`,`restore`,`close`,`focus`,`move_offscreen`,`move_resize`,`get_rect`],description:`minimize: ShowWindow(SW_MINIMIZE). maximize: ShowWindow(SW_MAXIMIZE). restore: ShowWindow(SW_RESTORE) — undo minimize or maximize. close: SendMessage(WM_CLOSE) — graceful close. focus: SetForegroundWindow + BringWindowToTop. move_offscreen: SetWindowPos(-32000,-32000) — keeps window usable by SendMessage/PrintWindow but invisible. move_resize: SetWindowPos to specific x,y,width,height. get_rect: GetWindowRect — returns current position and size.`},x:{type:`integer`,description:`X position for move_resize.`},y:{type:`integer`,description:`Y position for move_resize.`},width:{type:`integer`,description:`Width for move_resize.`},height:{type:`integer`,description:`Height for move_resize.`}},required:[`action`]}},{name:`click_element`,description:`Click a GUI element by its accessible name, role, or automationId — no pixel coordinates needed. Uses Windows UI Automation to find the element and InvokePattern to click it. Prefer this over left_click when the element name is visible in the accessibility snapshot. Falls back to BoundingRect center-click if InvokePattern is not supported.`,inputSchema:{type:`object`,properties:{name:{type:`string`,description:`Accessible name of the element (e.g. "Save", "File", "Search..."). Case-insensitive partial match.`},role:{type:`string`,description:`Control type (e.g. "Button", "MenuItem", "Edit", "Link"). Optional — narrows the search.`},automationId:{type:`string`,description:`Exact automationId from the accessibility snapshot. Most precise selector.`}},required:[]}},{name:`type_into_element`,description:`Type text into a named GUI element using Windows UI Automation ValuePattern. Finds the element by name/role/automationId, then sets its value directly — no need to click first or use pixel coordinates. Works on Edit, ComboBox, and other value-holding controls.`,inputSchema:{type:`object`,properties:{name:{type:`string`,description:`Accessible name of the target element.`},role:{type:`string`,description:`Control type (optional, e.g. "Edit").`},automationId:{type:`string`,description:`Exact automationId.`},text:{type:`string`,description:`Text to type/set into the element.`}},required:[`text`]}},{name:`open_terminal`,description:`Open a new terminal window and launch an AI agent CLI. This is a workflow tool that automates: open terminal → type startup command → press Enter → wait → verify. Supported agents: claude (runs 'claude'), codex (runs 'codex'), gemini (runs 'gemini'), or any custom command. After launching, the tool binds to the new terminal window and takes a screenshot to verify the agent started successfully. Use this when the user says: 'open Claude Code', 'start a Codex terminal', 'launch Gemini', etc.`,inputSchema:{type:`object`,properties:{agent:{type:`string`,enum:[`claude`,`codex`,`gemini`,`custom`],description:`Which agent to launch. claude: runs 'claude' command. codex: runs 'codex' command. gemini: runs 'gemini' command. custom: runs the command specified in 'command' parameter.`},command:{type:`string`,description:`Custom command to run in the terminal. Only used when agent='custom'. Example: 'python app.py'`},terminal:{type:`string`,enum:[`wt`,`powershell`,`cmd`],description:`Which terminal to open. Default: 'wt' (Windows Terminal). 'powershell' for PowerShell window, 'cmd' for Command Prompt.`},working_directory:{type:`string`,description:`Working directory for the terminal. If omitted, uses current directory.`}},required:[`agent`]}},{name:`bind_window`,description:`Bind to a specific window for all subsequent operations (screenshot, click, type, etc.). Once bound, screenshots capture only that window via PrintWindow, and all input goes through SendMessageW — no cursor movement, no focus steal, no interference with the user's desktop. Actions: bind (by title, hwnd, or pid), unbind (release binding), status (show current binding), list (show all visible windows). Use 'list' first to see available windows, then 'bind' with a title or hwnd. open_application auto-binds the launched window, but use this tool to bind to already-running windows or switch between windows.`,inputSchema:{type:`object`,properties:{action:{type:`string`,enum:[`bind`,`unbind`,`status`,`list`],description:`bind: Bind to a window (specify title, hwnd, or pid). unbind: Release the current binding, return to full-screen mode. status: Show the currently bound window (hwnd, title, rect). list: List all visible windows with hwnd, pid, and title.`},title:{type:`string`,description:`Window title to search for (partial match, case-insensitive). For 'bind' action.`},hwnd:{type:`string`,description:`Exact window handle from 'list' output. For 'bind' action.`},pid:{type:`integer`,description:`Process ID to find window for. For 'bind' action.`}},required:[`action`]}},{name:`activate_window`,description:`Activate the bound window: bring it to foreground, click to ensure keyboard focus, and optionally send an initial key sequence. Use this before any input operations to guarantee the window is ready to receive keyboard/mouse events. Combines SetForegroundWindow + BringWindowToTop + SendMessage(WM_LBUTTONDOWN) in one call.`,inputSchema:{type:`object`,properties:{click_x:{type:`integer`,description:`X coordinate to click after activation (client-area). If omitted, clicks center of window.`},click_y:{type:`integer`,description:`Y coordinate to click after activation (client-area). If omitted, clicks center of window.`}},required:[]}},{name:`prompt_respond`,description:`Handle interactive CLI/terminal prompts (Yes/No, selection menus, confirmations). Sends a sequence of key events to the bound window to navigate and confirm a prompt. This is a convenience wrapper around bound-window keyboard input for common prompt flows. Typical flows: 1) Yes/No prompt → send 'y' or 'n' + Enter. 2) Arrow-key selection menu → send arrow_down/arrow_up N times + Enter. 3) Text input prompt → type the response + Enter. After responding, take a screenshot to verify the result.`,inputSchema:{type:`object`,properties:{response_type:{type:`string`,enum:[`yes`,`no`,`enter`,`escape`,`select`,`type`],description:`yes: send 'y' + Enter. no: send 'n' + Enter. enter: send Enter only. escape: send Escape (cancel). select: use arrow keys to navigate to an option, then Enter. Requires 'arrow_count'. type: type custom text then Enter. Requires 'text'.`},arrow_direction:{type:`string`,enum:[`up`,`down`],description:`Arrow key direction for 'select' type. Default: 'down'.`},arrow_count:{type:`integer`,description:`Number of arrow key presses for 'select' type. Default: 1.`,minimum:0,maximum:50},text:{type:`string`,description:`Text to type for 'type' response_type.`}},required:[`response_type`]}},{name:`status_indicator`,description:`Control the visual status indicator overlay on the bound window. The indicator is a small floating label at the bottom of the window that shows what Computer Use is doing. It auto-shows during click/type/key/scroll operations, but you can also send custom messages. Actions: show (display a custom message), hide (dismiss), status (check if active).`,inputSchema:{type:`object`,properties:{action:{type:`string`,enum:[`show`,`hide`,`status`],description:`show: display a custom message on the indicator. hide: dismiss the indicator. status: check if indicator is active.`},message:{type:`string`,description:`Custom message to display (for 'show' action). Supports emoji. Auto-fades after 2 seconds.`}},required:[`action`]}},{name:`virtual_keyboard`,description:`Send keyboard input directly to the bound window via SendMessageW — independent of the physical keyboard. The user can keep typing on their own keyboard without interference. Supports: single keys, key combinations (Ctrl+S, Alt+F4), text input, and hold-key operations. All input targets the bound HWND only — no global keyboard events.`,inputSchema:{type:`object`,properties:{action:{type:`string`,enum:[`type`,`combo`,`press`,`release`,`hold`],description:`type: Send text string via WM_CHAR (Unicode, supports Chinese/emoji). combo: Send a key combination like ctrl+s, alt+f4, ctrl+shift+a (press all, release in reverse). press: Press a key down and hold it (pair with 'release'). release: Release a previously pressed key. hold: Press key(s) for a duration then release.`},text:{type:`string`,description:`For 'type': the text to input. For 'combo': key combination string (e.g. 'ctrl+s', 'alt+tab', 'ctrl+shift+a'). For 'press'/'release': single key name (e.g. 'shift', 'ctrl', 'a').`},duration:{type:`number`,description:`For 'hold': seconds to hold the key(s) before releasing. Default: 1.`},repeat:{type:`integer`,description:`Number of times to repeat the action. Default: 1.`,minimum:1,maximum:100}},required:[`action`,`text`]}},{name:`virtual_mouse`,description:`Control a virtual mouse on the bound window via SendMessageW — independent of the physical mouse. The user's real cursor stays free. All operations target the bound HWND only.`,inputSchema:{type:`object`,properties:{action:{type:`string`,enum:[`click`,`double_click`,`right_click`,`move`,`drag`,`down`,`up`],description:`click: left-click at coordinate. double_click: double left-click. right_click: right-click. move: move virtual cursor (visual only, no click). drag: press at start, move to end, release. Requires coordinate (end) and start_coordinate. down: press left button at coordinate (hold). up: release left button at coordinate.`},coordinate:{type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:`(x, y) client-area coordinate on the bound window.`},start_coordinate:{type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:`(x, y) start point for drag. If omitted, drags from current virtual cursor position.`}},required:[`action`,`coordinate`]}},{name:`mouse_wheel`,description:`Scroll inside the bound window using mouse wheel (WM_MOUSEWHEEL / WM_MOUSEHWHEEL). Unlike the generic 'scroll' tool which uses WM_VSCROLL (only works on scrollbar controls), mouse_wheel simulates the physical mouse wheel and works on Excel spreadsheets, web pages, code editors, PDF viewers, and any modern UI. Specify the click point within the window where the scroll should occur — this determines which panel/pane/element receives the scroll.`,inputSchema:{type:`object`,properties:{coordinate:{type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:`(x, y) client-area coordinate where the scroll should occur. Determines which element receives the scroll.`},delta:{type:`integer`,description:`Scroll amount in 'clicks'. Positive = scroll up, negative = scroll down. Each click = 3 lines typically. Use -3 to -5 for page-like scrolling.`},direction:{type:`string`,enum:[`vertical`,`horizontal`],description:`Scroll direction. Default: 'vertical'. Use 'horizontal' for side-scrolling (e.g. wide Excel sheets, timeline views).`}},required:[`coordinate`,`delta`]}}]:[],{name:`switch_display`,description:`Switch which monitor subsequent screenshots capture. Use this when the application you need is on a different monitor than the one shown. The screenshot tool tells you which monitor it captured and lists other attached monitors by name — pass one of those names here. After switching, call screenshot to see the new monitor. Pass "auto" to return to automatic monitor selection.`,inputSchema:{type:`object`,properties:{display:{type:`string`,description:`Monitor name from the screenshot note (e.g. "Built-in Retina Display", "LG UltraFine"), or "auto" to re-enable automatic selection.`}},required:[`display`]}},{name:`list_granted_applications`,description:`List the applications currently in the session allowlist, plus the active grant flags and coordinate mode. No side effects.`,inputSchema:{type:`object`,properties:{},required:[]}},{name:`read_clipboard`,description:"Read the current clipboard contents as text. Requires the `clipboardRead` grant.",inputSchema:{type:`object`,properties:{},required:[]}},{name:`write_clipboard`,description:"Write text to the clipboard. Requires the `clipboardWrite` grant.",inputSchema:{type:`object`,properties:{text:{type:`string`}},required:[`text`]}},{name:`wait`,description:`Wait for a specified duration.`,inputSchema:{type:`object`,properties:{duration:{type:`number`,description:`Duration in seconds (0–100).`}},required:[`duration`]}},{name:`cursor_position`,description:`Get the current mouse cursor position. Returns image-pixel coordinates relative to the most recent screenshot, or logical points if no screenshot has been taken.`,inputSchema:{type:`object`,properties:{},required:[]}},{name:`hold_key`,description:`Press and hold a key or key combination for the specified duration, then release. ${Z} System-level combos require the \`systemKeyCombos\` grant.`,inputSchema:{type:`object`,properties:{text:{type:`string`,description:`Key or chord to hold, e.g. "space", "shift+down".`},duration:{type:`number`,description:`Duration in seconds (0–100).`}},required:[`text`,`duration`]}},{name:`left_mouse_down`,description:`Press the left mouse button at the current cursor position and leave it held. ${Z} Use mouse_move first to position the cursor. Call left_mouse_up to release. Errors if the button is already held.`,inputSchema:{type:`object`,properties:{},required:[]}},{name:`left_mouse_up`,description:`Release the left mouse button at the current cursor position. ${Z} Pairs with left_mouse_down. Safe to call even if the button is not currently held.`,inputSchema:{type:`object`,properties:{},required:[]}},{name:`computer_batch`,description:`Execute a sequence of actions in ONE tool call. Each individual tool call requires a model→API round trip (seconds); batching a predictable sequence eliminates all but one. Use this whenever you can predict the outcome of several actions ahead — e.g. click a field, type into it, press Return. Actions execute sequentially and stop on the first error. ${Z} The frontmost check runs before EACH action inside the batch — if an action opens a non-allowed app, the next action's gate fires and the batch stops there. Mid-batch screenshot actions are allowed for inspection but coordinates in subsequent clicks always refer to the PRE-BATCH full-screen screenshot.`,inputSchema:{type:`object`,properties:{actions:{type:`array`,minItems:1,items:Q,description:`List of actions. Example: [{"action":"left_click","coordinate":[100,200]},{"action":"type","text":"hello"},{"action":"key","text":"Return"}]`}},required:[`actions`]}},...e.teachMode?Tt(r,i):[]]}function Tt(e,t){let n={explanation:{type:`string`,description:`Tooltip body text. Explain what the user is looking at and why it matters. This is the ONLY place the user sees your words — be complete but concise.`},next_preview:{type:`string`,description:`One line describing exactly what will happen when the user clicks Next. Example: "Next: I'll click Create Bucket and type the name." Shown below the explanation in a smaller font.`},anchor:{type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:`(x, y) — where the tooltip arrow points. ${e.x} Omit to center the tooltip with no arrow (for general-context steps).`},actions:{type:`array`,items:Q,description:`Actions to execute when the user clicks Next. Same item schema as computer_batch.actions. Empty array is valid for purely explanatory steps. Actions run sequentially and stop on first error.`}};return[{name:`request_teach_access`,description:`Request permission to guide the user through a task step-by-step with on-screen tooltips. Use this INSTEAD OF request_access when the user wants to LEARN how to do something (phrases like "teach me", "walk me through", "show me how", "help me learn"). On approval the main Claude window hides and a fullscreen tooltip overlay appears. You then call teach_step repeatedly; each call shows one tooltip and waits for the user to click Next. Same app-allowlist semantics as request_access, but no clipboard/system-key flags. Teach mode ends automatically when your turn ends.`,inputSchema:{type:`object`,properties:{apps:{type:`array`,items:{type:`string`},description:`Application display names (e.g. "Slack", "Calendar") or bundle identifiers. Resolved case-insensitively against installed apps.`+t},reason:{type:`string`,description:`What you will be teaching. Shown in the approval dialog as "Claude wants to guide you through {reason}". Keep it short and task-focused.`}},required:[`apps`,`reason`]}},{name:`teach_step`,description:"Show one guided-tour tooltip and wait for the user to click Next. On Next, execute the actions, take a fresh screenshot, and return both — you do NOT need a separate screenshot call between steps. The returned image shows the state after your actions ran; anchor the next teach_step against it. IMPORTANT — the user only sees the tooltip during teach mode. Put ALL narration in `explanation`. Text you emit outside teach_step calls is NOT visible until teach mode ends. Pack as many actions as possible into each step's `actions` array — the user waits through the whole round trip between clicks, so one step that fills a form beats five steps that fill one field each. Returns {exited:true} if the user clicks Exit — do not call teach_step again after that. Take an initial screenshot before your FIRST teach_step to anchor it.",inputSchema:{type:`object`,properties:n,required:[`explanation`,`next_preview`,`actions`]}},{name:`teach_batch`,description:`Queue multiple teach steps in one tool call. Parallels computer_batch: N steps → one model↔API round trip instead of N. Each step still shows a tooltip and waits for the user's Next click, but YOU aren't waiting for a round trip between steps. You can call teach_batch multiple times in one tour — treat each batch as one predictable SEGMENT (typically: all the steps on one page). The returned screenshot shows the state after the batch's final actions; anchor the NEXT teach_batch against it. WITHIN a batch, all anchors and click coordinates refer to the PRE-BATCH screenshot (same invariant as computer_batch) — for steps 2+ in a batch, either omit anchor (centered tooltip) or target elements you know won't have moved. Good pattern: batch 5 tooltips on page A (last step navigates) → read returned screenshot → batch 3 tooltips on page B → done. Returns {exited:true, stepsCompleted:N} if the user clicks Exit — do NOT call again after that; {stepsCompleted, stepFailed, ...} if an action errors mid-batch; otherwise {stepsCompleted, results:[...]} plus a final screenshot. Fall back to individual teach_step calls when you need to react to each intermediate screenshot.`,inputSchema:{type:`object`,properties:{steps:{type:`array`,minItems:1,items:{type:`object`,properties:n,required:[`explanation`,`next_preview`,`actions`]},description:`Ordered steps. Validated upfront — a typo in step 5 errors before any tooltip shows.`}},required:[`steps`]}}]}var Et,Z,Q,Dt=e((()=>{Et={pixels:{x:`Horizontal pixel position read directly from the most recent screenshot image, measured from the left edge. The server handles all scaling.`,y:`Vertical pixel position read directly from the most recent screenshot image, measured from the top edge. The server handles all scaling.`},normalized_0_100:{x:`Horizontal position as a percentage of screen width, 0.0–100.0 (0 = left edge, 100 = right edge).`,y:`Vertical position as a percentage of screen height, 0.0–100.0 (0 = top edge, 100 = bottom edge).`}},Z=`The frontmost application must be in the session allowlist at the time of this call, or this tool returns an error and does nothing.`,Q={type:`object`,properties:{action:{type:`string`,enum:[`key`,`type`,`mouse_move`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`triple_click`,`scroll`,`hold_key`,`screenshot`,`cursor_position`,`left_mouse_down`,`left_mouse_up`,`wait`],description:`The action to perform.`},coordinate:{type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:`(x, y) for click/mouse_move/scroll/left_click_drag end point.`},start_coordinate:{type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:`(x, y) drag start — left_click_drag only. Omit to drag from current cursor.`},text:{type:`string`,description:`For type: the text. For key/hold_key: the chord string. For click/scroll: modifier keys to hold.`},scroll_direction:{type:`string`,enum:[`up`,`down`,`left`,`right`]},scroll_amount:{type:`integer`,minimum:0,maximum:100},duration:{type:`number`,description:`Seconds (0–100). For hold_key/wait.`},repeat:{type:`integer`,minimum:1,maximum:100,description:`For key: repeat count.`}},required:[`action`]}}));function Ot(e,t,n){let r=new Set(e.map(e=>e.bundleId)),i=[...e,...n.granted.filter(e=>!r.has(e.bundleId))],a=Object.fromEntries(Object.entries(n.flags).filter(([,e])=>e===!0));return{apps:i,flags:{...c,...t,...a}}}function kt(e,t,n){let{logger:r,serverName:i}=e,a,o=n.onPermissionRequest?async(e,t)=>{let a=await n.onPermissionRequest(e,t),{apps:o,flags:s}=Ot(n.getAllowedApps(),n.getGrantFlags(),a);return r.debug(`[${i}] permission result: granted=${a.granted.length} denied=${a.denied.length}`),n.onAllowedAppsChanged?.(o,s),a}:void 0,s=n.onTeachPermissionRequest?async(e,t)=>{let a=await n.onTeachPermissionRequest(e,t);r.debug(`[${i}] teach permission result: granted=${a.granted.length} denied=${a.denied.length}`);let{apps:o}=Ot(n.getAllowedApps(),n.getGrantFlags(),a);return n.onAllowedAppsChanged?.(o,{...c,...n.getGrantFlags()}),a}:void 0;return async(c,l)=>{if(n.checkCuLock){let e=await n.checkCuLock();if(e.holder!==void 0&&!e.isSelf)return{content:[{type:`text`,text:n.formatLockHeldMessage?.(e.holder)??$}],isError:!0,telemetry:{error_kind:`cu_lock_held`}};if(e.holder===void 0&&!Ae(c)){await n.acquireCuLock?.();let e=await n.checkCuLock();if(e.holder!==void 0&&!e.isSelf)return{content:[{type:`text`,text:n.formatLockHeldMessage?.(e.holder)??$}],isError:!0,telemetry:{error_kind:`cu_lock_held`}};ke()}}let u=a?void 0:n.getLastScreenshotDims?.(),d=new AbortController,f={allowedApps:[...n.getAllowedApps()],grantFlags:n.getGrantFlags(),userDeniedBundleIds:n.getUserDeniedBundleIds(),coordinateMode:t,selectedDisplayId:n.getSelectedDisplayId(),displayPinnedByModel:n.getDisplayPinnedByModel?.(),displayResolvedForApps:n.getDisplayResolvedForApps?.(),lastScreenshot:a??(u?{...u,base64:``}:void 0),onPermissionRequest:o?e=>o(e,d.signal):void 0,onTeachPermissionRequest:s?e=>s(e,d.signal):void 0,onAppsHidden:n.onAppsHidden,getClipboardStash:n.getClipboardStash,onClipboardStashChanged:n.onClipboardStashChanged,onResolvedDisplayUpdated:n.onResolvedDisplayUpdated,onDisplayPinned:n.onDisplayPinned,onDisplayResolvedForApps:n.onDisplayResolvedForApps,onTeachModeActivated:n.onTeachModeActivated,onTeachStep:n.onTeachStep,onTeachWorking:n.onTeachWorking,getTeachModeActive:n.getTeachModeActive,checkCuLock:void 0,acquireCuLock:void 0,isAborted:n.isAborted};r.debug(`[${i}] tool=${c} allowedApps=${f.allowedApps.length} coordMode=${t}`);try{let t=await bt(e,c,l,f);if(t.screenshot){a=t.screenshot;let{base64:e,...o}=t.screenshot;r.debug(`[${i}] screenshot dims: ${JSON.stringify(o)}`),n.onScreenshotCaptured?.(o)}return t}finally{d.abort()}}}function At(e,t,i){let{serverName:o,logger:s}=e,c=new a({name:o,version:`0.1.3`},{capabilities:{tools:{},logging:{}}}),l=wt(e.executor.capabilities,t);if(c.setRequestHandler(n,async()=>e.isDisabled()?{tools:[]}:{tools:l}),i){let n=kt(e,t,i);return c.setRequestHandler(r,async e=>{let{screenshot:t,telemetry:r,...i}=await n(e.params.name,e.params.arguments??{});return i}),c}return c.setRequestHandler(r,async e=>(s.warn(`[${o}] tool call "${e.params.name}" reached the stub handler — no session context bound. Per-session state unavailable.`),{content:[{type:`text`,text:`This computer-use server instance is not wired to a session. Per-session app permissions are not available on this code path.`}],isError:!0})),c}var $,jt=e((()=>{i(),t(),Ct(),Dt(),l(),$=`Another Claude session is currently using the computer. Wait for that session to finish, or find a non-computer-use approach.`})),Mt=e((()=>{l(),h(),ce(),pe(),ve(),Ct(),jt(),Dt(),Se()}));export{_e as a,h as c,wt as i,c as l,kt as n,ge as o,At as r,u as s,Mt as t,l as u};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./chunk-DR8-3Aex.js";import{n as a,t as o}from"./defineProperty-CaCI0a5T.js";import{a as s,c,i as l,l as u,n as d,o as f,r as p,s as m,t as h,u as g}from"./classPrivateFieldSet2-DZkxcFPS.js";import{n as _,t as v}from"./json-bigint-BRRVs1dv.js";import{t as y}from"./base64-js-B1tFNiG0.js";import{n as b,t as x}from"./jws-B_ieuaZg.js";var S=r({author:()=>P,default:()=>ee,dependencies:()=>L,description:()=>T,devDependencies:()=>I,engines:()=>N,exports:()=>k,files:()=>O,homepage:()=>R,keywords:()=>M,license:()=>F,main:()=>E,name:()=>C,repository:()=>j,scripts:()=>A,types:()=>D,version:()=>w}),C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,R,ee,te=n((()=>{C=`gaxios`,w=`7.1.4`,T=`A simple common HTTP client specifically for Google APIs and services.`,E=`build/cjs/src/index.js`,D=`build/cjs/src/index.d.ts`,O=[`build/`],k={".":{import:{types:`./build/esm/src/index.d.ts`,default:`./build/esm/src/index.js`},require:{types:`./build/cjs/src/index.d.ts`,default:`./build/cjs/src/index.js`}}},A={lint:`gts check --no-inline-config`,test:`c8 mocha build/esm/test`,"presystem-test":`npm run compile`,"system-test":`mocha build/esm/system-test --timeout 80000`,compile:`tsc -b ./tsconfig.json ./tsconfig.cjs.json && node utils/enable-esm.mjs`,fix:`gts fix`,prepare:`npm run compile`,pretest:`npm run compile`,webpack:`webpack`,"prebrowser-test":`npm run compile`,"browser-test":`node build/browser-test/browser-test-runner.js`,docs:`jsdoc -c .jsdoc.js`,"docs-test":`linkinator docs`,"predocs-test":`npm run docs`,"samples-test":`cd samples/ && npm link ../ && npm test && cd ../`,prelint:`cd samples; npm link ../; npm install`,clean:`gts clean`},j={type:`git`,directory:`packages/gaxios`,url:`https://github.com/googleapis/google-cloud-node-core.git`},M=[`google`],N={node:`>=18`},P=`Google, LLC`,F=`Apache-2.0`,I={"@babel/plugin-proposal-private-methods":`^7.18.6`,"@types/cors":`^2.8.6`,"@types/express":`^5.0.0`,"@types/extend":`^3.0.1`,"@types/mocha":`^10.0.10`,"@types/multiparty":`4.2.1`,"@types/mv":`^2.1.0`,"@types/ncp":`^2.0.8`,"@types/node":`^22.13.1`,"@types/sinon":`^17.0.3`,"@types/tmp":`^0.2.6`,assert:`^2.0.0`,browserify:`^17.0.0`,c8:`^10.1.3`,cors:`^2.8.5`,express:`^5.0.0`,gts:`^6.0.2`,"is-docker":`^3.0.0`,jsdoc:`^4.0.4`,"jsdoc-fresh":`^5.0.0`,"jsdoc-region-tag":`^4.0.0`,karma:`^6.0.0`,"karma-chrome-launcher":`^3.0.0`,"karma-coverage":`^2.0.0`,"karma-firefox-launcher":`^2.0.0`,"karma-mocha":`^2.0.0`,"karma-remap-coverage":`^0.1.5`,"karma-sourcemap-loader":`^0.4.0`,"karma-webpack":`^5.0.1`,linkinator:`^6.1.2`,mocha:`^11.1.0`,multiparty:`^4.2.1`,mv:`^2.1.1`,ncp:`^2.0.0`,nock:`^14.0.5`,"null-loader":`^4.0.1`,"pack-n-play":`^4.0.0`,puppeteer:`^24.0.0`,sinon:`^21.0.0`,"stream-browserify":`^3.0.0`,tmp:`0.2.5`,"ts-loader":`^9.5.2`,typescript:`5.8.3`,webpack:`^5.97.1`,"webpack-cli":`^6.0.1`},L={extend:`^3.0.2`,"https-proxy-agent":`^7.0.1`,"node-fetch":`^3.3.2`},R=`https://github.com/googleapis/google-cloud-node-core/tree/main/packages/gaxios`,ee={name:C,version:w,description:T,main:E,types:D,files:O,exports:k,scripts:A,repository:j,keywords:M,engines:N,author:P,license:F,devDependencies:I,dependencies:L,homepage:R}})),ne=i(((t,n)=>{n.exports={pkg:(te(),e(S).default)}})),re=i((e=>{a();var t,n,r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.GaxiosError=e.GAXIOS_ERROR_SYMBOL=void 0,e.defaultErrorRedactor=l;var i=r(_()),s=r(ne()).default.pkg;e.GAXIOS_ERROR_SYMBOL=Symbol.for(`${s.name}-gaxios-error`),t=e.GAXIOS_ERROR_SYMBOL,n=Symbol.hasInstance,e.GaxiosError=class r extends Error{static[n](t){return t&&typeof t==`object`&&e.GAXIOS_ERROR_SYMBOL in t&&t[e.GAXIOS_ERROR_SYMBOL]===s.version?!0:Function.prototype[Symbol.hasInstance].call(r,t)}constructor(e,n,r,a){if(super(e,{cause:a}),o(this,`config`,void 0),o(this,`response`,void 0),o(this,`code`,void 0),o(this,`status`,void 0),o(this,`error`,void 0),o(this,t,s.version),this.config=n,this.response=r,this.error=a instanceof Error?a:void 0,this.config=(0,i.default)(!0,{},n),this.response&&(this.response.config=(0,i.default)(!0,{},this.response.config)),this.response){try{this.response.data=c(this.config.responseType,this.response?.bodyUsed?this.response?.data:void 0)}catch{}this.status=this.response.status}a instanceof DOMException?this.code=a.name:a&&typeof a==`object`&&`code`in a&&(typeof a.code==`string`||typeof a.code==`number`)&&(this.code=a.code)}static extractAPIErrorFromResponse(e,t=`The request failed`){let n=t;if(typeof e.data==`string`&&(n=e.data),e.data&&typeof e.data==`object`&&`error`in e.data&&e.data.error&&!e.ok){if(typeof e.data.error==`string`)return{message:e.data.error,code:e.status,status:e.statusText};if(typeof e.data.error==`object`){n=`message`in e.data.error&&typeof e.data.error.message==`string`?e.data.error.message:n;let t=`status`in e.data.error&&typeof e.data.error.status==`string`?e.data.error.status:e.statusText,r=`code`in e.data.error&&typeof e.data.error.code==`number`?e.data.error.code:e.status;if(`errors`in e.data.error&&Array.isArray(e.data.error.errors)){let i=[];for(let t of e.data.error.errors)typeof t==`object`&&`message`in t&&typeof t.message==`string`&&i.push(t.message);return Object.assign({message:i.join(`
|
|
2
|
+
`)||n,code:r,status:t},e.data.error)}return Object.assign({message:n,code:r,status:t},e.data.error)}}return{message:n,code:e.status,status:e.statusText}}};function c(e,t){switch(e){case`stream`:return t;case`json`:return JSON.parse(JSON.stringify(t));case`arraybuffer`:return JSON.parse(Buffer.from(t).toString(`utf8`));case`blob`:return JSON.parse(t.text());default:return t}}function l(e){let t="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";function n(e){e&&e.forEach((n,r)=>{(/^authentication$/i.test(r)||/^authorization$/i.test(r)||/secret/i.test(r))&&e.set(r,t)})}function r(e,n){if(typeof e==`object`&&e&&typeof e[n]==`string`){let r=e[n];(/grant_type=/i.test(r)||/assertion=/i.test(r)||/secret/i.test(r))&&(e[n]=t)}}function i(e){!e||typeof e!=`object`||(e instanceof FormData||e instanceof URLSearchParams||`forEach`in e&&`set`in e?e.forEach((n,r)=>{([`grant_type`,`assertion`].includes(r)||/secret/.test(r))&&e.set(r,t)}):(`grant_type`in e&&(e.grant_type=t),`assertion`in e&&(e.assertion=t),`client_secret`in e&&(e.client_secret=t)))}return e.config&&(n(e.config.headers),r(e.config,`data`),i(e.config.data),r(e.config,`body`),i(e.config.body),e.config.url.searchParams.has(`token`)&&e.config.url.searchParams.set(`token`,t),e.config.url.searchParams.has(`client_secret`)&&e.config.url.searchParams.set(`client_secret`,t)),e.response&&(l({config:e.response.config}),n(e.response.headers),e.response.bodyUsed&&(r(e.response,`data`),i(e.response.data))),e}})),ie=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRetryConfig=t;async function t(e){let t=r(e);if(!e||!e.config||!t&&!e.config.retry)return{shouldRetry:!1};if(t=t||{},t.currentRetryAttempt=t.currentRetryAttempt||0,t.retry=t.retry===void 0||t.retry===null?3:t.retry,t.httpMethodsToRetry=t.httpMethodsToRetry||[`GET`,`HEAD`,`PUT`,`OPTIONS`,`DELETE`],t.noResponseRetries=t.noResponseRetries===void 0||t.noResponseRetries===null?2:t.noResponseRetries,t.retryDelayMultiplier=t.retryDelayMultiplier?t.retryDelayMultiplier:2,t.timeOfFirstRequest=t.timeOfFirstRequest?t.timeOfFirstRequest:Date.now(),t.totalTimeout=t.totalTimeout?t.totalTimeout:2**53-1,t.maxRetryDelay=t.maxRetryDelay?t.maxRetryDelay:2**53-1,t.statusCodesToRetry=t.statusCodesToRetry||[[100,199],[408,408],[429,429],[500,599]],e.config.retryConfig=t,!await(t.shouldRetry||n)(e))return{shouldRetry:!1,config:e.config};let a=i(t);e.config.retryConfig.currentRetryAttempt+=1;let o=t.retryBackoff?t.retryBackoff(e,a):new Promise(e=>{setTimeout(e,a)});return t.onRetryAttempt&&await t.onRetryAttempt(e),await o,{shouldRetry:!0,config:e.config}}function n(e){let t=r(e);if(e.config.signal?.aborted&&e.code!==`TimeoutError`||e.code===`AbortError`||!t||t.retry===0||!e.response&&(t.currentRetryAttempt||0)>=t.noResponseRetries||!t.httpMethodsToRetry||!t.httpMethodsToRetry.includes(e.config.method?.toUpperCase()||`GET`))return!1;if(e.response&&e.response.status){let n=!1;for(let[r,i]of t.statusCodesToRetry){let t=e.response.status;if(t>=r&&t<=i){n=!0;break}}if(!n)return!1}return t.currentRetryAttempt=t.currentRetryAttempt||0,!(t.currentRetryAttempt>=t.retry)}function r(e){if(e&&e.config&&e.config.retryConfig)return e.config.retryConfig}function i(e){let t=(e.currentRetryAttempt?0:e.retryDelay??100)+(e.retryDelayMultiplier**+e.currentRetryAttempt-1)/2*1e3,n=e.totalTimeout-(Date.now()-e.timeOfFirstRequest);return Math.min(t,n,e.maxRetryDelay)}})),ae=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.GaxiosInterceptorManager=void 0,e.GaxiosInterceptorManager=class extends Set{}})),oe=i((e=>{g(),a(),f();var n,r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},i;Object.defineProperty(e,`__esModule`,{value:!0}),e.Gaxios=void 0;var c=r(_()),l=t(`https`),d=re(),p=ie(),m=t(`stream`),h=ae(),v=async()=>globalThis.crypto?.randomUUID()||(await import(`crypto`)).randomUUID(),y=204,b=new WeakSet,x=class e{constructor(e){u(this,b),o(this,`agentCache`,new Map),o(this,`defaults`,void 0),o(this,`interceptors`,void 0),this.defaults=e||{},this.interceptors={request:new h.GaxiosInterceptorManager,response:new h.GaxiosInterceptorManager}}fetch(...e){let t=e[0],n=e[1],r,a=new Headers;return typeof t==`string`?r=new URL(t):t instanceof URL?r=t:t&&t.url&&(r=new URL(t.url)),t&&typeof t==`object`&&`headers`in t&&i.mergeHeaders(a,t.headers),n&&i.mergeHeaders(a,new Headers(n.headers)),typeof t==`object`&&!(t instanceof URL)?this.request({...n,...t,headers:a,url:r}):this.request({...n,headers:a,url:r})}async request(e={}){let t=await s(b,this,T).call(this,e);return t=await s(b,this,C).call(this,t),s(b,this,w).call(this,this._request(t))}async _defaultAdapter(t){let n=t.fetchImplementation||this.defaults.fetchImplementation||await s(e,i,O).call(i),r={...t};delete r.data;let a=await n(t.url,r),o=await this.getResponseData(t,a);return Object.getOwnPropertyDescriptor(a,`data`)?.configurable||Object.defineProperties(a,{data:{configurable:!0,writable:!0,enumerable:!0,value:o}}),Object.assign(a,{config:t,data:o})}async _request(e){try{let t;if(t=e.adapter?await e.adapter(e,this._defaultAdapter.bind(this)):await this._defaultAdapter(e),!e.validateStatus(t.status)){if(e.responseType===`stream`){let e=[];for await(let n of t.data)e.push(n);t.data=e.toString()}let n=d.GaxiosError.extractAPIErrorFromResponse(t,`Request failed with status code ${t.status}`);throw new d.GaxiosError(n?.message,e,t,n)}return t}catch(t){let n;n=t instanceof d.GaxiosError?t:t instanceof Error?new d.GaxiosError(t.message,e,void 0,t):new d.GaxiosError(`Unexpected Gaxios Error`,e,void 0,t);let{shouldRetry:r,config:i}=await(0,p.getRetryConfig)(n);if(r&&i)return n.config.retryConfig.currentRetryAttempt=i.retryConfig.currentRetryAttempt,e.retryConfig=n.config?.retryConfig,s(b,this,E).call(this,e),this._request(e);throw e.errorRedactor&&e.errorRedactor(n),n}}async getResponseData(e,t){if(t.status===y)return``;if(e.maxContentLength&&t.headers.has(`content-length`)&&e.maxContentLength<Number.parseInt(t.headers?.get(`content-length`)||``))throw new d.GaxiosError("Response's `Content-Length` is over the limit.",e,Object.assign(t,{config:e}));switch(e.responseType){case`stream`:return t.body;case`json`:{let e=await t.text();try{return JSON.parse(e)}catch{return e}}case`arraybuffer`:return t.arrayBuffer();case`blob`:return t.blob();case`text`:return t.text();default:return this.getResponseDataFromContentType(t)}}validateStatus(e){return e>=200&&e<300}async getResponseDataFromContentType(e){let t=e.headers.get(`Content-Type`);if(t===null)return e.text();if(t=t.toLowerCase(),t.includes(`application/json`)){let t=await e.text();try{t=JSON.parse(t)}catch{}return t}else if(t.match(/^text\//))return e.text();else return e.blob()}async*getMultipartRequest(e,t){let n=`--${t}--`;for(let n of e)yield`--${t}\r\nContent-Type: ${n.headers.get(`Content-Type`)||`application/octet-stream`}\r\n\r\n`,typeof n.content==`string`?yield n.content:yield*n.content,yield`\r
|
|
3
|
+
`;yield n}static mergeHeaders(e,...t){e=e instanceof Headers?e:new Headers(e);for(let n of t)(n instanceof Headers?n:new Headers(n)).forEach((t,n)=>{n===`set-cookie`?e.append(n,t):e.set(n,t)});return e}};n=x;function S(e,t=[]){let n=new URL(e),r=[...t],i=(process.env.NO_PROXY??process.env.no_proxy)?.split(`,`)||[];for(let e of i)r.push(e.trim());for(let e of r)if(e instanceof RegExp){if(e.test(n.toString()))return!1}else if(e instanceof URL){if(e.origin===n.origin)return!1}else if(e.startsWith(`*.`)||e.startsWith(`.`)){let t=e.replace(/^\*\./,`.`);if(n.hostname.endsWith(t))return!1}else if(e===n.origin||e===n.hostname||e===n.href)return!1;return!0}async function C(e){let t=Promise.resolve(e);for(let e of this.interceptors.request.values())e&&(t=t.then(e.resolved,e.rejected));return t}async function w(e){let t=Promise.resolve(e);for(let e of this.interceptors.response.values())e&&(t=t.then(e.resolved,e.rejected));return t}async function T(e){let t=new Headers(this.defaults.headers);i.mergeHeaders(t,e.headers);let r=(0,c.default)(!0,{},this.defaults,e);if(!r.url)throw Error(`URL is required.`);if(r.baseURL&&(r.url=new URL(r.url,r.baseURL)),r.url=new URL(r.url),r.params)if(r.paramsSerializer){let e=r.paramsSerializer(r.params);e.startsWith(`?`)&&(e=e.slice(1));let t=r.url.toString().includes(`?`)?`&`:`?`;r.url=r.url+t+e}else{let e=r.url instanceof URL?r.url:new URL(r.url);for(let[t,n]of new URLSearchParams(r.params))e.searchParams.append(t,n);r.url=e}typeof e.maxContentLength==`number`&&(r.size=e.maxContentLength),typeof e.maxRedirects==`number`&&(r.follow=e.maxRedirects);let a=typeof r.data==`string`||r.data instanceof ArrayBuffer||r.data instanceof Blob||globalThis.File&&r.data instanceof File||r.data instanceof FormData||r.data instanceof m.Readable||r.data instanceof ReadableStream||r.data instanceof String||r.data instanceof URLSearchParams||ArrayBuffer.isView(r.data)||[`Blob`,`File`,`FormData`].includes(r.data?.constructor?.name||``);if(r.multipart?.length){let e=await v();t.set(`content-type`,`multipart/related; boundary=${e}`),r.body=m.Readable.from(this.getMultipartRequest(r.multipart,e))}else a?r.body=r.data:typeof r.data==`object`?t.get(`Content-Type`)===`application/x-www-form-urlencoded`?r.body=r.paramsSerializer?r.paramsSerializer(r.data):new URLSearchParams(r.data):(t.has(`content-type`)||t.set(`content-type`,`application/json`),r.body=JSON.stringify(r.data)):r.data&&(r.body=r.data);r.validateStatus=r.validateStatus||this.validateStatus,r.responseType=r.responseType||`unknown`,!t.has(`accept`)&&r.responseType===`json`&&t.set(`accept`,`application/json`);let o=r.proxy||process?.env?.HTTPS_PROXY||process?.env?.https_proxy||process?.env?.HTTP_PROXY||process?.env?.http_proxy;if(!r.agent)if(o&&s(b,this,S).call(this,r.url,r.noProxy)){let e=await s(n,i,D).call(i);this.agentCache.has(o)?r.agent=this.agentCache.get(o):(r.agent=new e(o,{cert:r.cert,key:r.key}),this.agentCache.set(o,r.agent))}else r.cert&&r.key&&(this.agentCache.has(r.key)?r.agent=this.agentCache.get(r.key):(r.agent=new l.Agent({cert:r.cert,key:r.key}),this.agentCache.set(r.key,r.agent)));return typeof r.errorRedactor!=`function`&&r.errorRedactor!==!1&&(r.errorRedactor=d.defaultErrorRedactor),r.body&&!(`duplex`in r)&&(r.duplex=`half`),s(b,this,E).call(this,r),Object.assign(r,{headers:t,url:r.url instanceof URL?r.url:new URL(r.url)})}function E(e){if(e.timeout){let t=AbortSignal.timeout(e.timeout);e.signal&&!e.signal.aborted?e.signal=AbortSignal.any([e.signal,t]):e.signal=t}}async function D(){return s(n,this,k)._||(k._=s(n,this,null)),s(n,this,k)._}async function O(){return s(n,this,A)._||(A._=s(n,this,null)),s(n,this,A)._}var k={_:void 0},A={_:void 0};e.Gaxios=x,i=x})),z=i((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.instance=e.Gaxios=e.GaxiosError=void 0,e.request=a;var r=oe();Object.defineProperty(e,`Gaxios`,{enumerable:!0,get:function(){return r.Gaxios}});var i=re();Object.defineProperty(e,`GaxiosError`,{enumerable:!0,get:function(){return i.GaxiosError}}),n(ae(),e),e.instance=new r.Gaxios;async function a(t){return e.instance.request(t)}})),se=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.GCE_LINUX_BIOS_PATHS=void 0,e.isGoogleCloudServerless=a,e.isGoogleComputeEngineLinux=o,e.isGoogleComputeEngineMACAddress=s,e.isGoogleComputeEngine=c,e.detectGCPResidency=l;var n=t(`fs`),r=t(`os`);e.GCE_LINUX_BIOS_PATHS={BIOS_DATE:`/sys/class/dmi/id/bios_date`,BIOS_VENDOR:`/sys/class/dmi/id/bios_vendor`};var i=/^42:01/;function a(){return!!(process.env.CLOUD_RUN_JOB||process.env.FUNCTION_NAME||process.env.K_SERVICE)}function o(){if((0,r.platform)()!==`linux`)return!1;try{(0,n.statSync)(e.GCE_LINUX_BIOS_PATHS.BIOS_DATE);let t=(0,n.readFileSync)(e.GCE_LINUX_BIOS_PATHS.BIOS_VENDOR,`utf8`);return/Google/.test(t)}catch{return!1}}function s(){let e=(0,r.networkInterfaces)();for(let t of Object.values(e))if(t){for(let{mac:e}of t)if(i.test(e))return!0}return!1}function c(){return o()||s()}function l(){return a()||c()}})),ce=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Colours=void 0;var t=class e{static isEnabled(e){return e&&e.isTTY&&(typeof e.getColorDepth==`function`?e.getColorDepth()>2:!0)}static refresh(){e.enabled=e.isEnabled(process==null?void 0:process.stderr),this.enabled?(e.reset=`\x1B[0m`,e.bright=`\x1B[1m`,e.dim=`\x1B[2m`,e.red=`\x1B[31m`,e.green=`\x1B[32m`,e.yellow=`\x1B[33m`,e.blue=`\x1B[34m`,e.magenta=`\x1B[35m`,e.cyan=`\x1B[36m`,e.white=`\x1B[37m`,e.grey=`\x1B[90m`):(e.reset=``,e.bright=``,e.dim=``,e.red=``,e.green=``,e.yellow=``,e.blue=``,e.magenta=``,e.cyan=``,e.white=``,e.grey=``)}};e.Colours=t,t.enabled=!1,t.reset=``,t.bright=``,t.dim=``,t.red=``,t.green=``,t.yellow=``,t.blue=``,t.magenta=``,t.cyan=``,t.white=``,t.grey=``,t.refresh()})),le=i((e=>{var n=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var i={};if(t!=null)for(var a=e(t),o=0;o<a.length;o++)a[o]!==`default`&&n(i,t,a[o]);return r(i,t),i}})();Object.defineProperty(e,`__esModule`,{value:!0}),e.env=e.DebugLogBackendBase=e.placeholder=e.AdhocDebugLogger=e.LogSeverity=void 0,e.getNodeBackend=p,e.getDebugBackend=h,e.getStructuredBackend=_,e.setBackend=b,e.log=x;var a=t(`events`),o=i(t(`process`)),s=i(t(`util`)),c=ce(),l;(function(e){e.DEFAULT=`DEFAULT`,e.DEBUG=`DEBUG`,e.INFO=`INFO`,e.WARNING=`WARNING`,e.ERROR=`ERROR`})(l||(e.LogSeverity=l={}));var u=class extends a.EventEmitter{constructor(e,t){super(),this.namespace=e,this.upstream=t,this.func=Object.assign(this.invoke.bind(this),{instance:this,on:(e,t)=>this.on(e,t)}),this.func.debug=(...e)=>this.invokeSeverity(l.DEBUG,...e),this.func.info=(...e)=>this.invokeSeverity(l.INFO,...e),this.func.warn=(...e)=>this.invokeSeverity(l.WARNING,...e),this.func.error=(...e)=>this.invokeSeverity(l.ERROR,...e),this.func.sublog=e=>x(e,this.func)}invoke(e,...t){if(this.upstream)try{this.upstream(e,...t)}catch{}try{this.emit(`log`,e,t)}catch{}}invokeSeverity(e,...t){this.invoke({severity:e},...t)}};e.AdhocDebugLogger=u,e.placeholder=new u(``,()=>{}).func;var d=class{constructor(){this.cached=new Map,this.filters=[],this.filtersSet=!1;let t=o.env[e.env.nodeEnables]??`*`;t===`all`&&(t=`*`),this.filters=t.split(`,`)}log(e,t,...n){try{this.filtersSet||(this.setFilters(),this.filtersSet=!0);let r=this.cached.get(e);r||(r=this.makeLogger(e),this.cached.set(e,r)),r(t,...n)}catch(e){console.error(e)}}};e.DebugLogBackendBase=d;var f=class extends d{constructor(){super(...arguments),this.enabledRegexp=/.*/g}isEnabled(e){return this.enabledRegexp.test(e)}makeLogger(e){return this.enabledRegexp.test(e)?(t,...n)=>{let r=`${c.Colours.green}${e}${c.Colours.reset}`,i=`${c.Colours.yellow}${o.pid}${c.Colours.reset}`,a;switch(t.severity){case l.ERROR:a=`${c.Colours.red}${t.severity}${c.Colours.reset}`;break;case l.INFO:a=`${c.Colours.magenta}${t.severity}${c.Colours.reset}`;break;case l.WARNING:a=`${c.Colours.yellow}${t.severity}${c.Colours.reset}`;break;default:a=t.severity??l.DEFAULT;break}let u=s.formatWithOptions({colors:c.Colours.enabled},...n),d=Object.assign({},t);delete d.severity;let f=Object.getOwnPropertyNames(d).length?JSON.stringify(d):``,p=f?`${c.Colours.grey}${f}${c.Colours.reset}`:``;console.error(`%s [%s|%s] %s%s`,i,r,a,u,f?` ${p}`:``)}:()=>{}}setFilters(){let e=this.filters.join(`,`).replace(/[|\\{}()[\]^$+?.]/g,`\\$&`).replace(/\*/g,`.*`).replace(/,/g,`$|^`);this.enabledRegexp=RegExp(`^${e}$`,`i`)}};function p(){return new f}var m=class extends d{constructor(e){super(),this.debugPkg=e}makeLogger(e){let t=this.debugPkg(e);return(e,...n)=>{t(n[0],...n.slice(1))}}setFilters(){let e=o.env.NODE_DEBUG??``;o.env.NODE_DEBUG=`${e}${e?`,`:``}${this.filters.join(`,`)}`}};function h(e){return new m(e)}var g=class extends d{constructor(e){super(),this.upstream=e??void 0}makeLogger(e){let t=this.upstream?.makeLogger(e);return(e,...n)=>{let r=e.severity??l.INFO,i=Object.assign({severity:r,message:s.format(...n)},e),a=JSON.stringify(i);t?t(e,a):console.log(`%s`,a)}}setFilters(){var e;(e=this.upstream)==null||e.setFilters()}};function _(e){return new g(e)}e.env={nodeEnables:`GOOGLE_SDK_NODE_LOGGING`};var v=new Map,y=void 0;function b(e){y=e,v.clear()}function x(t,n){if(!y&&!o.env[e.env.nodeEnables]||!t)return e.placeholder;n&&(t=`${n.instance.namespace}:${t}`);let r=v.get(t);if(r)return r.func;if(y===null)return e.placeholder;y===void 0&&(y=p());let i=(()=>{let e;return new u(t,(n,...r)=>{if(e!==y){if(y===null)return;y===void 0&&(y=p()),e=y}y?.log(t,n,...r)})})();return v.set(t,i),i.func}})),ue=i((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(le(),e)})),B=i((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=e(r),o=0;o<a.length;o++)a[o]!==`default`&&t(i,r,a[o]);return n(i,r),i}})(),i=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.gcpResidencyCache=e.METADATA_SERVER_DETECTION=e.HEADERS=e.HEADER_VALUE=e.HEADER_NAME=e.SECONDARY_HOST_ADDRESS=e.HOST_ADDRESS=e.BASE_PATH=void 0,e.instance=m,e.project=h,e.universe=g,e.bulk=_,e.isAvailable=x,e.resetIsAvailableCache=S,e.getGCPResidency=C,e.setGCPResidency=w,e.requestTimeout=T;var a=z(),o=v(),s=se(),c=r(ue());e.BASE_PATH=`/computeMetadata/v1`,e.HOST_ADDRESS=`http://169.254.169.254`,e.SECONDARY_HOST_ADDRESS=`http://metadata.google.internal.`,e.HEADER_NAME=`Metadata-Flavor`,e.HEADER_VALUE=`Google`,e.HEADERS=Object.freeze({[e.HEADER_NAME]:e.HEADER_VALUE});var l=c.log(`gcp-metadata`);e.METADATA_SERVER_DETECTION=Object.freeze({"assume-present":`don't try to ping the metadata server, but assume it's present`,none:`don't try to ping the metadata server, but don't try to use it either`,"bios-only":`treat the result of a BIOS probe as canonical (don't fall back to pinging)`,"ping-only":`skip the BIOS probe, and go straight to pinging`});function u(t){return t||(t=process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST||e.HOST_ADDRESS),/^https?:\/\//.test(t)||(t=`http://${t}`),new URL(e.BASE_PATH,t).href}function d(e){Object.keys(e).forEach(e=>{switch(e){case`params`:case`property`:case`headers`:break;case`qs`:throw Error(`'qs' is not a valid configuration option. Please use 'params' instead.`);default:throw Error(`'${e}' is not a valid configuration option.`)}})}async function f(t,n={},r=3,i=!1){let s=new Headers(e.HEADERS),c=``,f={};if(typeof t==`object`){let e=t;new Headers(e.headers).forEach((e,t)=>s.set(t,e)),c=e.metadataKey,f=e.params||f,r=e.noResponseRetries||r,i=e.fastFail||i}else c=t;typeof n==`string`?c+=`/${n}`:(d(n),n.property&&(c+=`/${n.property}`),new Headers(n.headers).forEach((e,t)=>s.set(t,e)),f=n.params||f);let m=i?p:a.request,h={url:`${u()}/${c}`,headers:s,retryConfig:{noResponseRetries:r},params:f,responseType:`text`,timeout:T()};l.info(`instance request %j`,h);let g=await m(h);l.info(`instance metadata is %s`,g.data);let _=g.headers.get(e.HEADER_NAME);if(_!==e.HEADER_VALUE)throw RangeError(`Invalid response from metadata service: incorrect ${e.HEADER_NAME} header. Expected '${e.HEADER_VALUE}', got ${_?`'${_}'`:`no header`}`);if(typeof g.data==`string`)try{return o.parse(g.data)}catch{}return g.data}async function p(t){let n={...t,url:t.url?.toString().replace(u(),u(e.SECONDARY_HOST_ADDRESS))},r=(0,a.request)(t),i=(0,a.request)(n);return Promise.any([r,i])}function m(e){return f(`instance`,e)}function h(e){return f(`project`,e)}function g(e){return f(`universe`,e)}async function _(e){let t={};return await Promise.all(e.map(e=>(async()=>{let n=await f(e),r=e.metadataKey;t[r]=n})())),t}function y(){return process.env.DETECT_GCP_RETRIES?Number(process.env.DETECT_GCP_RETRIES):0}var b;async function x(){if(process.env.METADATA_SERVER_DETECTION){let t=process.env.METADATA_SERVER_DETECTION.trim().toLocaleLowerCase();if(!(t in e.METADATA_SERVER_DETECTION))throw RangeError(`Unknown \`METADATA_SERVER_DETECTION\` env variable. Got \`${t}\`, but it should be \`${Object.keys(e.METADATA_SERVER_DETECTION).join("`, `")}\`, or unset`);switch(t){case`assume-present`:return!0;case`none`:return!1;case`bios-only`:return C();case`ping-only`:}}try{return b===void 0&&(b=f(`instance`,void 0,y(),!(process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST))),await b,!0}catch(e){let t=e;if(process.env.DEBUG_AUTH&&console.info(t),t.type===`request-timeout`||t.response&&t.response.status===404)return!1;if(!(t.response&&t.response.status===404)&&(!t.code||![`EHOSTDOWN`,`EHOSTUNREACH`,`ENETUNREACH`,`ENOENT`,`ENOTFOUND`,`ECONNREFUSED`].includes(t.code.toString()))){let e=`UNKNOWN`;t.code&&(e=t.code.toString()),process.emitWarning(`received unexpected error = ${t.message} code = ${e}`,`MetadataLookupWarning`)}return!1}}function S(){b=void 0}e.gcpResidencyCache=null;function C(){return e.gcpResidencyCache===null&&w(),e.gcpResidencyCache}function w(t=null){e.gcpResidencyCache=t===null?(0,s.detectGCPResidency)():t}function T(){return C()?0:3e3}i(se(),e)})),de=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromArrayBufferToHex=t;function t(e){return Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}})),fe=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.BrowserCrypto=void 0;var t=y(),n=de();e.BrowserCrypto=class e{constructor(){if(typeof window>`u`||window.crypto===void 0||window.crypto.subtle===void 0)throw Error(`SubtleCrypto not found. Make sure it's an https:// website.`)}async sha256DigestBase64(e){let n=new TextEncoder().encode(e),r=await window.crypto.subtle.digest(`SHA-256`,n);return t.fromByteArray(new Uint8Array(r))}randomBytesBase64(e){let n=new Uint8Array(e);return window.crypto.getRandomValues(n),t.fromByteArray(n)}static padBase64(e){for(;e.length%4!=0;)e+=`=`;return e}async verify(n,r,i){let a={name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-256`}},o=new TextEncoder().encode(r),s=t.toByteArray(e.padBase64(i)),c=await window.crypto.subtle.importKey(`jwk`,n,a,!0,[`verify`]);return await window.crypto.subtle.verify(a,c,Buffer.from(s),o)}async sign(e,n){let r={name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-256`}},i=new TextEncoder().encode(n),a=await window.crypto.subtle.importKey(`jwk`,e,r,!0,[`sign`]),o=await window.crypto.subtle.sign(r,a,i);return t.fromByteArray(new Uint8Array(o))}decodeBase64StringUtf8(n){let r=t.toByteArray(e.padBase64(n));return new TextDecoder().decode(r)}encodeBase64StringUtf8(e){let n=new TextEncoder().encode(e);return t.fromByteArray(n)}async sha256DigestHex(e){let t=new TextEncoder().encode(e),r=await window.crypto.subtle.digest(`SHA-256`,t);return(0,n.fromArrayBufferToHex)(r)}async signWithHmacSha256(e,t){let n=typeof e==`string`?e:String.fromCharCode(...new Uint16Array(e)),r=new TextEncoder,i=await window.crypto.subtle.importKey(`raw`,r.encode(n),{name:`HMAC`,hash:{name:`SHA-256`}},!1,[`sign`]);return window.crypto.subtle.sign(`HMAC`,i,r.encode(t))}}})),pe=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.NodeCrypto=void 0;var n=t(`crypto`);e.NodeCrypto=class{async sha256DigestBase64(e){return n.createHash(`sha256`).update(e).digest(`base64`)}randomBytesBase64(e){return n.randomBytes(e).toString(`base64`)}async verify(e,t,r){let i=n.createVerify(`RSA-SHA256`);return i.update(t),i.end(),i.verify(e,r,`base64`)}async sign(e,t){let r=n.createSign(`RSA-SHA256`);return r.update(t),r.end(),r.sign(e,`base64`)}decodeBase64StringUtf8(e){return Buffer.from(e,`base64`).toString(`utf-8`)}encodeBase64StringUtf8(e){return Buffer.from(e,`utf-8`).toString(`base64`)}async sha256DigestHex(e){return n.createHash(`sha256`).update(e).digest(`hex`)}async signWithHmacSha256(e,t){let a=typeof e==`string`?e:i(e);return r(n.createHmac(`sha256`,a).update(t).digest())}};function r(e){let t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let t=0;t<e.length;++t)n[t]=e[t];return t}function i(e){return Buffer.from(e)}})),V=i((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.createCrypto=a,e.hasBrowserCrypto=o;var r=fe(),i=pe();n(de(),e);function a(){return o()?new r.BrowserCrypto:new i.NodeCrypto}function o(){return typeof window<`u`&&window.crypto!==void 0&&window.crypto.subtle!==void 0}})),H=i((e=>{g(),a(),c(),l(),f(),Object.defineProperty(e,`__esModule`,{value:!0}),e.LRUCache=void 0,e.snakeToCamel=_,e.originalOrCamelOptions=v,e.removeUndefinedValuesInObject=w,e.isValidFile=T,e.getWellKnownCertificateConfigFileLocation=E;var n=t(`fs`),r=t(`os`),i=t(`path`),d=`certificate_config.json`,h=`gcloud`;function _(e){return e.replace(/([_][^_])/g,e=>e.slice(1).toUpperCase())}function v(e){function t(t){let n=e||{};return n[t]??n[_(t)]}return{get:t}}var y=new WeakMap,b=new WeakSet,x=class{constructor(e){u(this,b),o(this,`capacity`,void 0),m(this,y,new Map),o(this,`maxAge`,void 0),this.capacity=e.capacity,this.maxAge=e.maxAge}set(e,t){s(b,this,S).call(this,e,t),s(b,this,C).call(this)}get(e){let t=p(y,this).get(e);if(t)return s(b,this,S).call(this,e,t.value),s(b,this,C).call(this),t.value}};function S(e,t){p(y,this).delete(e),p(y,this).set(e,{value:t,lastAccessed:Date.now()})}function C(){let e=this.maxAge?Date.now()-this.maxAge:0,t=p(y,this).entries().next();for(;!t.done&&(p(y,this).size>this.capacity||t.value[1].lastAccessed<e);)p(y,this).delete(t.value[0]),t=p(y,this).entries().next()}e.LRUCache=x;function w(e){return Object.entries(e).forEach(([t,n])=>{(n===void 0||n===`undefined`)&&delete e[t]}),e}async function T(e){try{return(await n.promises.lstat(e)).isFile()}catch{return!1}}function E(){let e=process.env.CLOUDSDK_CONFIG||(D()?i.join(process.env.APPDATA||``,h):i.join(process.env.HOME||``,`.config`,h));return i.join(e,d)}function D(){return r.platform().startsWith(`win`)}})),me=r({author:()=>G,default:()=>Se,dependencies:()=>ge,description:()=>K,devDependencies:()=>_e,engines:()=>q,files:()=>ve,homepage:()=>xe,keywords:()=>he,license:()=>be,main:()=>J,name:()=>U,repository:()=>X,scripts:()=>ye,types:()=>Y,version:()=>W}),U,W,G,K,q,J,Y,X,he,ge,_e,ve,ye,be,xe,Se,Ce=n((()=>{U=`google-auth-library`,W=`10.6.2`,G=`Google Inc.`,K=`Google APIs Authentication Client Library for Node.js`,q={node:`>=18`},J=`./build/src/index.js`,Y=`./build/src/index.d.ts`,X={type:`git`,directory:`packages/google-auth-library-nodejs`,url:`https://github.com/googleapis/google-cloud-node-core.git`},he=[`google`,`api`,`google apis`,`client`,`client library`],ge={"base64-js":`^1.3.0`,"ecdsa-sig-formatter":`^1.0.11`,gaxios:`^7.1.4`,"gcp-metadata":`8.1.2`,"google-logging-utils":`1.1.3`,jws:`^4.0.0`},_e={"@types/base64-js":`^1.2.5`,"@types/jws":`^3.1.0`,"@types/mocha":`^10.0.10`,"@types/mv":`^2.1.0`,"@types/ncp":`^2.0.8`,"@types/node":`^24.0.0`,"@types/sinon":`^21.0.0`,"assert-rejects":`^1.0.0`,c8:`^10.1.3`,codecov:`^3.8.3`,gts:`^6.0.2`,"is-docker":`^3.0.0`,jsdoc:`^4.0.4`,"jsdoc-fresh":`^5.0.0`,"jsdoc-region-tag":`^4.0.0`,karma:`^6.0.0`,"karma-chrome-launcher":`^3.0.0`,"karma-coverage":`^2.0.0`,"karma-firefox-launcher":`^2.0.0`,"karma-mocha":`^2.0.0`,"karma-sourcemap-loader":`^0.4.0`,"karma-webpack":`^5.0.1`,keypair:`^1.0.4`,mocha:`^11.1.0`,mv:`^2.1.1`,ncp:`^2.0.0`,nock:`^14.0.5`,"null-loader":`^4.0.1`,puppeteer:`^24.0.0`,sinon:`^21.0.0`,"ts-loader":`^9.5.2`,typescript:`5.8.3`,webpack:`^5.97.1`,"webpack-cli":`^6.0.1`},ve=[`build/src`,`!build/src/**/*.map`],ye={test:`c8 mocha build/test`,clean:`gts clean`,prepare:`npm run compile`,lint:`gts check --no-inline-config`,compile:`tsc -p .`,fix:`gts fix`,pretest:`npm run compile -- --sourceMap`,docs:`jsdoc -c .jsdoc.js`,"samples-setup":`cd samples/ && npm link ../ && npm run setup && cd ../`,"samples-test":`cd samples/ && npm link ../ && npm test && cd ../`,"system-test":`mocha build/system-test --timeout 60000`,"presystem-test":`npm run compile -- --sourceMap`,webpack:`webpack`,"browser-test":`karma start`,"docs-test":`echo 'disabled until linkinator is fixed'`,"predocs-test":`npm run docs`,prelint:`cd samples; npm link ../; npm install`},be=`Apache-2.0`,xe=`https://github.com/googleapis/google-cloud-node-core/tree/main/packages/google-auth-library-nodejs`,Se={name:U,version:W,author:G,description:K,engines:q,main:J,types:Y,repository:X,keywords:he,dependencies:ge,devDependencies:_e,files:ve,scripts:ye,license:be,homepage:xe}})),we=i((t=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.USER_AGENT=t.PRODUCT_NAME=t.pkg=void 0;var n=(Ce(),e(me).default);t.pkg=n;var r=`google-api-nodejs-client`;t.PRODUCT_NAME=r,t.USER_AGENT=`${r}/${n.version}`})),Z=i((e=>{a();var n;Object.defineProperty(e,`__esModule`,{value:!0}),e.AuthClient=e.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS=e.DEFAULT_UNIVERSE=void 0;var r=t(`events`),i=z(),s=H(),c=ue(),l=we();e.DEFAULT_UNIVERSE=`googleapis.com`,e.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS=300*1e3;var u=class t extends r.EventEmitter{constructor(n={}){super(),o(this,`apiKey`,void 0),o(this,`projectId`,void 0),o(this,`quotaProjectId`,void 0),o(this,`transporter`,void 0),o(this,`credentials`,{}),o(this,`eagerRefreshThresholdMillis`,e.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS),o(this,`forceRefreshOnFailure`,!1),o(this,`universeDomain`,e.DEFAULT_UNIVERSE);let r=(0,s.originalOrCamelOptions)(n);this.apiKey=n.apiKey,this.projectId=r.get(`project_id`)??null,this.quotaProjectId=r.get(`quota_project_id`),this.credentials=r.get(`credentials`)??{},this.universeDomain=r.get(`universe_domain`)??e.DEFAULT_UNIVERSE,this.transporter=n.transporter??new i.Gaxios(n.transporterOptions),r.get(`useAuthRequestParameters`)!==!1&&(this.transporter.interceptors.request.add(t.DEFAULT_REQUEST_INTERCEPTOR),this.transporter.interceptors.response.add(t.DEFAULT_RESPONSE_INTERCEPTOR)),n.eagerRefreshThresholdMillis&&(this.eagerRefreshThresholdMillis=n.eagerRefreshThresholdMillis),this.forceRefreshOnFailure=n.forceRefreshOnFailure??!1}fetch(...e){let t=e[0],n=e[1],r,a=new Headers;return typeof t==`string`?r=new URL(t):t instanceof URL?r=t:t&&t.url&&(r=new URL(t.url)),t&&typeof t==`object`&&`headers`in t&&i.Gaxios.mergeHeaders(a,t.headers),n&&i.Gaxios.mergeHeaders(a,new Headers(n.headers)),typeof t==`object`&&!(t instanceof URL)?this.request({...n,...t,headers:a,url:r}):this.request({...n,headers:a,url:r})}setCredentials(e){this.credentials=e}addSharedMetadataHeaders(e){return!e.has(`x-goog-user-project`)&&this.quotaProjectId&&e.set(`x-goog-user-project`,this.quotaProjectId),e}addUserProjectAndAuthHeaders(e,t){let n=t.get(`x-goog-user-project`),r=t.get(`authorization`);return n&&e.set(`x-goog-user-project`,n),r&&e.set(`authorization`,r),e}static setMethodName(e,n){try{let r=e;r[t.RequestMethodNameSymbol]=n}catch{}}static get RETRY_CONFIG(){return{retry:!0,retryConfig:{httpMethodsToRetry:[`GET`,`PUT`,`POST`,`HEAD`,`OPTIONS`,`DELETE`]}}}};n=u,o(u,`RequestMethodNameSymbol`,Symbol(`request method name`)),o(u,`RequestLogIdSymbol`,Symbol(`request log id`)),o(u,`log`,(0,c.log)(`auth`)),o(u,`DEFAULT_REQUEST_INTERCEPTOR`,{resolved:async e=>{if(!e.headers.has(`x-goog-api-client`)){let t=process.version.replace(/^v/,``);e.headers.set(`x-goog-api-client`,`gl-node/${t}`)}let t=e.headers.get(`User-Agent`);t?t.includes(`${l.PRODUCT_NAME}/`)||e.headers.set(`User-Agent`,`${t} ${l.USER_AGENT}`):e.headers.set(`User-Agent`,l.USER_AGENT);try{let t=e,r=t[n.RequestMethodNameSymbol],i=`${Math.floor(Math.random()*1e3)}`;t[n.RequestLogIdSymbol]=i;let a={url:e.url,headers:e.headers};r?n.log.info(`%s [%s] request %j`,r,i,a):n.log.info(`[%s] request %j`,i,a)}catch{}return e}}),o(u,`DEFAULT_RESPONSE_INTERCEPTOR`,{resolved:async e=>{try{let t=e.config,r=t[n.RequestMethodNameSymbol],i=t[n.RequestLogIdSymbol];r?n.log.info(`%s [%s] response %j`,r,i,e.data):n.log.info(`[%s] response %j`,i,e.data)}catch{}return e},rejected:async e=>{try{let t=e.config,r=t[n.RequestMethodNameSymbol],i=t[n.RequestLogIdSymbol];r?n.log.info(`%s [%s] error %j`,r,i,e.response?.data):n.log.error(`[%s] error %j`,i,e.response?.data)}catch{}throw e}}),e.AuthClient=u})),Te=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.LoginTicket=void 0,e.LoginTicket=class{constructor(e,t){o(this,`envelope`,void 0),o(this,`payload`,void 0),this.envelope=e,this.payload=t}getEnvelope(){return this.envelope}getPayload(){return this.payload}getUserId(){let e=this.getPayload();return e&&e.sub?e.sub:null}getAttributes(){return{envelope:this.getEnvelope(),payload:this.getPayload()}}}})),Q=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.OAuth2Client=e.ClientAuthentication=e.CertificateFormat=e.CodeChallengeMethod=void 0;var n=z(),r=t(`querystring`),i=t(`stream`),s=b(),c=H(),l=V(),u=Z(),d=Te(),f;(function(e){e.Plain=`plain`,e.S256=`S256`})(f||(e.CodeChallengeMethod=f={}));var p;(function(e){e.PEM=`PEM`,e.JWK=`JWK`})(p||(e.CertificateFormat=p={}));var m;(function(e){e.ClientSecretPost=`ClientSecretPost`,e.ClientSecretBasic=`ClientSecretBasic`,e.None=`None`})(m||(e.ClientAuthentication=m={}));var h=class e extends u.AuthClient{constructor(e={},t,n){super(typeof e==`object`?e:{}),o(this,`redirectUri`,void 0),o(this,`certificateCache`,{}),o(this,`certificateExpiry`,null),o(this,`certificateCacheFormat`,p.PEM),o(this,`refreshTokenPromises`,new Map),o(this,`endpoints`,void 0),o(this,`issuers`,void 0),o(this,`clientAuthentication`,void 0),o(this,`_clientId`,void 0),o(this,`_clientSecret`,void 0),o(this,`refreshHandler`,void 0),typeof e!=`object`&&(e={clientId:e,clientSecret:t,redirectUri:n}),this._clientId=e.clientId||e.client_id,this._clientSecret=e.clientSecret||e.client_secret,this.redirectUri=e.redirectUri||e.redirect_uris?.[0],this.endpoints={tokenInfoUrl:`https://oauth2.googleapis.com/tokeninfo`,oauth2AuthBaseUrl:`https://accounts.google.com/o/oauth2/v2/auth`,oauth2TokenUrl:`https://oauth2.googleapis.com/token`,oauth2RevokeUrl:`https://oauth2.googleapis.com/revoke`,oauth2FederatedSignonPemCertsUrl:`https://www.googleapis.com/oauth2/v1/certs`,oauth2FederatedSignonJwkCertsUrl:`https://www.googleapis.com/oauth2/v3/certs`,oauth2IapPublicKeyUrl:`https://www.gstatic.com/iap/verify/public_key`,...e.endpoints},this.clientAuthentication=e.clientAuthentication||m.ClientSecretPost,this.issuers=e.issuers||[`accounts.google.com`,`https://accounts.google.com`,this.universeDomain]}generateAuthUrl(e={}){if(e.code_challenge_method&&!e.code_challenge)throw Error(`If a code_challenge_method is provided, code_challenge must be included.`);return e.response_type=e.response_type||`code`,e.client_id=e.client_id||this._clientId,e.redirect_uri=e.redirect_uri||this.redirectUri,Array.isArray(e.scope)&&(e.scope=e.scope.join(` `)),this.endpoints.oauth2AuthBaseUrl.toString()+`?`+r.stringify(e)}generateCodeVerifier(){throw Error(`generateCodeVerifier is removed, please use generateCodeVerifierAsync instead.`)}async generateCodeVerifierAsync(){let e=(0,l.createCrypto)(),t=e.randomBytesBase64(96).replace(/\+/g,`~`).replace(/=/g,`_`).replace(/\//g,`-`);return{codeVerifier:t,codeChallenge:(await e.sha256DigestBase64(t)).split(`=`)[0].replace(/\+/g,`-`).replace(/\//g,`_`)}}getToken(e,t){let n=typeof e==`string`?{code:e}:e;if(t)this.getTokenAsync(n).then(e=>t(null,e.tokens,e.res),e=>t(e,null,e.response));else return this.getTokenAsync(n)}async getTokenAsync(t){let n=this.endpoints.oauth2TokenUrl.toString(),r=new Headers,i={client_id:t.client_id||this._clientId,code_verifier:t.codeVerifier,code:t.code,grant_type:`authorization_code`,redirect_uri:t.redirect_uri||this.redirectUri};if(this.clientAuthentication===m.ClientSecretBasic){let e=Buffer.from(`${this._clientId}:${this._clientSecret}`);r.set(`authorization`,`Basic ${e.toString(`base64`)}`)}this.clientAuthentication===m.ClientSecretPost&&(i.client_secret=this._clientSecret);let a={...e.RETRY_CONFIG,method:`POST`,url:n,data:new URLSearchParams((0,c.removeUndefinedValuesInObject)(i)),headers:r};u.AuthClient.setMethodName(a,`getTokenAsync`);let o=await this.transporter.request(a),s=o.data;return o.data&&o.data.expires_in&&(s.expiry_date=new Date().getTime()+o.data.expires_in*1e3,delete s.expires_in),this.emit(`tokens`,s),{tokens:s,res:o}}async refreshToken(e){if(!e)return this.refreshTokenNoCache(e);if(this.refreshTokenPromises.has(e))return this.refreshTokenPromises.get(e);let t=this.refreshTokenNoCache(e).then(t=>(this.refreshTokenPromises.delete(e),t),t=>{throw this.refreshTokenPromises.delete(e),t});return this.refreshTokenPromises.set(e,t),t}async refreshTokenNoCache(t){if(!t)throw Error(`No refresh token is set.`);let r=this.endpoints.oauth2TokenUrl.toString(),i={refresh_token:t,client_id:this._clientId,client_secret:this._clientSecret,grant_type:`refresh_token`},a;try{let t={...e.RETRY_CONFIG,method:`POST`,url:r,data:new URLSearchParams((0,c.removeUndefinedValuesInObject)(i))};u.AuthClient.setMethodName(t,`refreshTokenNoCache`),a=await this.transporter.request(t)}catch(e){throw e instanceof n.GaxiosError&&e.message===`invalid_grant`&&e.response?.data&&/ReAuth/i.test(e.response.data.error_description)&&(e.message=JSON.stringify(e.response.data)),e}let o=a.data;return a.data&&a.data.expires_in&&(o.expiry_date=new Date().getTime()+a.data.expires_in*1e3,delete o.expires_in),this.emit(`tokens`,o),{tokens:o,res:a}}refreshAccessToken(e){if(e)this.refreshAccessTokenAsync().then(t=>e(null,t.credentials,t.res),e);else return this.refreshAccessTokenAsync()}async refreshAccessTokenAsync(){let e=await this.refreshToken(this.credentials.refresh_token),t=e.tokens;return t.refresh_token=this.credentials.refresh_token,this.credentials=t,{credentials:this.credentials,res:e.res}}getAccessToken(e){if(e)this.getAccessTokenAsync().then(t=>e(null,t.token,t.res),e);else return this.getAccessTokenAsync()}async getAccessTokenAsync(){if(!this.credentials.access_token||this.isTokenExpiring()){if(!this.credentials.refresh_token)if(this.refreshHandler){let e=await this.processAndValidateRefreshHandler();if(e?.access_token)return this.setCredentials(e),{token:this.credentials.access_token}}else throw Error(`No refresh token or refresh handler callback is set.`);let e=await this.refreshAccessTokenAsync();if(!e.credentials||e.credentials&&!e.credentials.access_token)throw Error(`Could not refresh access token.`);return{token:e.credentials.access_token,res:e.res}}else return{token:this.credentials.access_token}}async getRequestHeaders(e){return(await this.getRequestMetadataAsync(e)).headers}async getRequestMetadataAsync(e){let t=this.credentials;if(!t.access_token&&!t.refresh_token&&!this.apiKey&&!this.refreshHandler)throw Error(`No access, refresh token, API key or refresh handler callback is set.`);if(t.access_token&&!this.isTokenExpiring()){t.token_type=t.token_type||`Bearer`;let e=new Headers({authorization:t.token_type+` `+t.access_token});return{headers:this.addSharedMetadataHeaders(e)}}if(this.refreshHandler){let e=await this.processAndValidateRefreshHandler();if(e?.access_token){this.setCredentials(e);let t=new Headers({authorization:`Bearer `+this.credentials.access_token});return{headers:this.addSharedMetadataHeaders(t)}}}if(this.apiKey)return{headers:new Headers({"X-Goog-Api-Key":this.apiKey})};let n=null,r=null;try{n=await this.refreshToken(t.refresh_token),r=n.tokens}catch(e){let t=e;throw t.response&&(t.response.status===403||t.response.status===404)&&(t.message=`Could not refresh access token: ${t.message}`),t}let i=this.credentials;i.token_type=i.token_type||`Bearer`,r.refresh_token=i.refresh_token,this.credentials=r;let a=new Headers({authorization:i.token_type+` `+r.access_token});return{headers:this.addSharedMetadataHeaders(a),res:n.res}}static getRevokeTokenUrl(t){return new e().getRevokeTokenURL(t).toString()}getRevokeTokenURL(e){let t=new URL(this.endpoints.oauth2RevokeUrl);return t.searchParams.append(`token`,e),t}revokeToken(t,n){let r={...e.RETRY_CONFIG,url:this.getRevokeTokenURL(t).toString(),method:`POST`};if(u.AuthClient.setMethodName(r,`revokeToken`),n)this.transporter.request(r).then(e=>n(null,e),n);else return this.transporter.request(r)}revokeCredentials(e){if(e)this.revokeCredentialsAsync().then(t=>e(null,t),e);else return this.revokeCredentialsAsync()}async revokeCredentialsAsync(){let e=this.credentials.access_token;if(this.credentials={},e)return this.revokeToken(e);throw Error(`No access token to revoke.`)}request(e,t){if(t)this.requestAsync(e).then(e=>t(null,e),e=>t(e,e.response));else return this.requestAsync(e)}async requestAsync(e,t=!1){try{let t=await this.getRequestMetadataAsync();return e.headers=n.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,t.headers),this.apiKey&&e.headers.set(`X-Goog-Api-Key`,this.apiKey),await this.transporter.request(e)}catch(n){let r=n.response;if(r){let n=r.status,a=this.credentials&&this.credentials.access_token&&this.credentials.refresh_token&&(!this.credentials.expiry_date||this.forceRefreshOnFailure),o=this.credentials&&this.credentials.access_token&&!this.credentials.refresh_token&&(!this.credentials.expiry_date||this.forceRefreshOnFailure)&&this.refreshHandler,s=r.config.data instanceof i.Readable,c=n===401||n===403;if(!t&&c&&!s&&a)return await this.refreshAccessTokenAsync(),this.requestAsync(e,!0);if(!t&&c&&!s&&o){let t=await this.processAndValidateRefreshHandler();return t?.access_token&&this.setCredentials(t),this.requestAsync(e,!0)}}throw n}}verifyIdToken(e,t){if(t&&typeof t!=`function`)throw Error(`This method accepts an options object as the first parameter, which includes the idToken, audience, and maxExpiry.`);if(t)this.verifyIdTokenAsync(e).then(e=>t(null,e),t);else return this.verifyIdTokenAsync(e)}async verifyIdTokenAsync(e){if(!e.idToken)throw Error(`The verifyIdToken method requires an ID Token`);let t=await this.getFederatedSignonCertsAsync();return await this.verifySignedJwtWithCertsAsync(e.idToken,t.certs,e.audience,this.issuers,e.maxExpiry)}async getTokenInfo(t){let{data:n}=await this.transporter.request({...e.RETRY_CONFIG,method:`POST`,headers:{"content-type":`application/x-www-form-urlencoded;charset=UTF-8`,authorization:`Bearer ${t}`},url:this.endpoints.tokenInfoUrl.toString()}),r=Object.assign({expiry_date:new Date().getTime()+n.expires_in*1e3,scopes:n.scope.split(` `)},n);return delete r.expires_in,delete r.scope,r}getFederatedSignonCerts(e){if(e)this.getFederatedSignonCertsAsync().then(t=>e(null,t.certs,t.res),e);else return this.getFederatedSignonCertsAsync()}async getFederatedSignonCertsAsync(){let t=new Date().getTime(),n=(0,l.hasBrowserCrypto)()?p.JWK:p.PEM;if(this.certificateExpiry&&t<this.certificateExpiry.getTime()&&this.certificateCacheFormat===n)return{certs:this.certificateCache,format:n};let r,i;switch(n){case p.PEM:i=this.endpoints.oauth2FederatedSignonPemCertsUrl.toString();break;case p.JWK:i=this.endpoints.oauth2FederatedSignonJwkCertsUrl.toString();break;default:throw Error(`Unsupported certificate format ${n}`)}try{let t={...e.RETRY_CONFIG,url:i};u.AuthClient.setMethodName(t,`getFederatedSignonCertsAsync`),r=await this.transporter.request(t)}catch(e){throw e instanceof Error&&(e.message=`Failed to retrieve verification certificates: ${e.message}`),e}let a=r?.headers.get(`cache-control`),o=-1;if(a){let e=/max-age=(?<maxAge>[0-9]+)/.exec(a)?.groups?.maxAge;e&&(o=Number(e)*1e3)}let s={};switch(n){case p.PEM:s=r.data;break;case p.JWK:for(let e of r.data.keys)s[e.kid]=e;break;default:throw Error(`Unsupported certificate format ${n}`)}return this.certificateExpiry=o===-1?null:new Date(new Date().getTime()+o),this.certificateCache=s,this.certificateCacheFormat=n,{certs:s,format:n,res:r}}getIapPublicKeys(e){if(e)this.getIapPublicKeysAsync().then(t=>e(null,t.pubkeys,t.res),e);else return this.getIapPublicKeysAsync()}async getIapPublicKeysAsync(){let t,n=this.endpoints.oauth2IapPublicKeyUrl.toString();try{let r={...e.RETRY_CONFIG,url:n};u.AuthClient.setMethodName(r,`getIapPublicKeysAsync`),t=await this.transporter.request(r)}catch(e){throw e instanceof Error&&(e.message=`Failed to retrieve verification certificates: ${e.message}`),e}return{pubkeys:t.data,res:t}}verifySignedJwtWithCerts(){throw Error(`verifySignedJwtWithCerts is removed, please use verifySignedJwtWithCertsAsync instead.`)}async verifySignedJwtWithCertsAsync(t,n,r,i,a){let o=(0,l.createCrypto)();a||(a=e.DEFAULT_MAX_TOKEN_LIFETIME_SECS_);let c=t.split(`.`);if(c.length!==3)throw Error(`Wrong number of segments in token: `+t);let u=c[0]+`.`+c[1],f=c[2],p,m;try{p=JSON.parse(o.decodeBase64StringUtf8(c[0]))}catch(e){throw e instanceof Error&&(e.message=`Can't parse token envelope: ${c[0]}': ${e.message}`),e}if(!p)throw Error(`Can't parse token envelope: `+c[0]);try{m=JSON.parse(o.decodeBase64StringUtf8(c[1]))}catch(e){throw e instanceof Error&&(e.message=`Can't parse token payload '${c[0]}`),e}if(!m)throw Error(`Can't parse token payload: `+c[1]);if(!Object.prototype.hasOwnProperty.call(n,p.kid))throw Error(`No pem found for envelope: `+JSON.stringify(p));let h=n[p.kid];if(p.alg===`ES256`&&(f=s.joseToDer(f,`ES256`).toString(`base64`)),!await o.verify(h,u,f))throw Error(`Invalid token signature: `+t);if(!m.iat)throw Error(`No issue time in token: `+JSON.stringify(m));if(!m.exp)throw Error(`No expiration time in token: `+JSON.stringify(m));let g=Number(m.iat);if(isNaN(g))throw Error(`iat field using invalid format`);let _=Number(m.exp);if(isNaN(_))throw Error(`exp field using invalid format`);let v=new Date().getTime()/1e3;if(_>=v+a)throw Error(`Expiration time too far in future: `+JSON.stringify(m));let y=g-e.CLOCK_SKEW_SECS_,b=_+e.CLOCK_SKEW_SECS_;if(v<y)throw Error(`Token used too early, `+v+` < `+y+`: `+JSON.stringify(m));if(v>b)throw Error(`Token used too late, `+v+` > `+b+`: `+JSON.stringify(m));if(i&&i.indexOf(m.iss)<0)throw Error(`Invalid issuer, expected one of [`+i+`], but got `+m.iss);if(r!=null){let e=m.aud,t=!1;if(t=r.constructor===Array?r.indexOf(e)>-1:e===r,!t)throw Error(`Wrong recipient, payload audience != requiredAudience`)}return new d.LoginTicket(p,m)}async processAndValidateRefreshHandler(){if(this.refreshHandler){let e=await this.refreshHandler();if(!e.access_token)throw Error(`No access token is returned by the refreshHandler callback.`);return e}}isTokenExpiring(){let e=this.credentials.expiry_date;return e?e<=new Date().getTime()+this.eagerRefreshThresholdMillis:!1}};o(h,`GOOGLE_TOKEN_INFO_URL`,`https://oauth2.googleapis.com/tokeninfo`),o(h,`CLOCK_SKEW_SECS_`,300),o(h,`DEFAULT_MAX_TOKEN_LIFETIME_SECS_`,86400),e.OAuth2Client=h})),Ee=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.Compute=void 0;var t=z(),n=B(),r=Q();e.Compute=class extends r.OAuth2Client{constructor(e={}){super(e),o(this,`serviceAccountEmail`,void 0),o(this,`scopes`,void 0),this.credentials={expiry_date:1,refresh_token:`compute-placeholder`},this.serviceAccountEmail=e.serviceAccountEmail||`default`,this.scopes=Array.isArray(e.scopes)?e.scopes:e.scopes?[e.scopes]:[]}async refreshTokenNoCache(){let e=`service-accounts/${this.serviceAccountEmail}/token`,r;try{let t={property:e};this.scopes.length>0&&(t.params={scopes:this.scopes.join(`,`)}),r=await n.instance(t)}catch(e){throw e instanceof t.GaxiosError&&(e.message=`Could not refresh access token: ${e.message}`,this.wrapError(e)),e}let i=r;return r&&r.expires_in&&(i.expiry_date=new Date().getTime()+r.expires_in*1e3,delete i.expires_in),this.emit(`tokens`,i),{tokens:i,res:null}}async fetchIdToken(e){let t=`service-accounts/${this.serviceAccountEmail}/identity?format=full&audience=${e}`,r;try{let e={property:t};r=await n.instance(e)}catch(e){throw e instanceof Error&&(e.message=`Could not fetch ID token: ${e.message}`),e}return r}wrapError(e){let t=e.response;t&&t.status&&(e.status=t.status,t.status===403?e.message=`A Forbidden error was returned while attempting to retrieve an access token for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have the correct permission scopes specified: `+e.message:t.status===404&&(e.message=`A Not Found error was returned while attempting to retrieve an accesstoken for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have any permission scopes specified: `+e.message))}}})),De=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.IdTokenClient=void 0;var t=Q();e.IdTokenClient=class extends t.OAuth2Client{constructor(e){super(e),o(this,`targetAudience`,void 0),o(this,`idTokenProvider`,void 0),this.targetAudience=e.targetAudience,this.idTokenProvider=e.idTokenProvider}async getRequestMetadataAsync(){if(!this.credentials.id_token||!this.credentials.expiry_date||this.isTokenExpiring()){let e=await this.idTokenProvider.fetchIdToken(this.targetAudience);this.credentials={id_token:e,expiry_date:this.getIdTokenExpiryDate(e)}}return{headers:new Headers({authorization:`Bearer `+this.credentials.id_token})}}getIdTokenExpiryDate(e){let t=e.split(`.`)[1];if(t)return JSON.parse(Buffer.from(t,`base64`).toString(`ascii`)).exp*1e3}}})),Oe=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.GCPEnv=void 0,e.clear=i,e.getEnv=a;var t=B(),n;(function(e){e.APP_ENGINE=`APP_ENGINE`,e.KUBERNETES_ENGINE=`KUBERNETES_ENGINE`,e.CLOUD_FUNCTIONS=`CLOUD_FUNCTIONS`,e.COMPUTE_ENGINE=`COMPUTE_ENGINE`,e.CLOUD_RUN=`CLOUD_RUN`,e.CLOUD_RUN_JOBS=`CLOUD_RUN_JOBS`,e.NONE=`NONE`})(n||(e.GCPEnv=n={}));var r;function i(){r=void 0}async function a(){return r||(r=o(),r)}async function o(){let e=n.NONE;return e=s()?n.APP_ENGINE:c()?n.CLOUD_FUNCTIONS:await f()?await d()?n.KUBERNETES_ENGINE:l()?n.CLOUD_RUN:u()?n.CLOUD_RUN_JOBS:n.COMPUTE_ENGINE:n.NONE,e}function s(){return!!(process.env.GAE_SERVICE||process.env.GAE_MODULE_NAME)}function c(){return!!(process.env.FUNCTION_NAME||process.env.FUNCTION_TARGET)}function l(){return!!process.env.K_CONFIGURATION}function u(){return!!process.env.CLOUD_RUN_JOB}async function d(){try{return await t.instance(`attributes/cluster-name`),!0}catch{return!1}}async function f(){return t.isAvailable()}})),ke=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.buildPayloadForJwsSign=i,e.getJwsSign=a;var t=x(),n=`RS256`,r=`https://oauth2.googleapis.com/token`;function i(e){let t=Math.floor(new Date().getTime()/1e3);return{iss:e.iss,scope:e.scope,aud:r,exp:t+3600,iat:t,sub:e.sub,...e.additionalClaims}}function a(e){let r=i(e);return(0,t.sign)({header:{alg:n},payload:r,secret:e.key})}})),Ae=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getToken=a;var t=ke(),n=`https://oauth2.googleapis.com/token`,r=`urn:ietf:params:oauth:grant-type:jwt-bearer`,i=e=>({method:`POST`,url:n,data:new URLSearchParams({grant_type:r,assertion:(0,t.getJwsSign)(e)}),responseType:`json`,retryConfig:{httpMethodsToRetry:[`POST`]}});async function a(e){if(!e.transporter)throw Error(`No transporter set.`);try{let t=i(e);return(await e.transporter.request(t)).data}catch(e){let t=e,n=t.response?.data;throw n?.error&&(t.message=`${n.error}: ${n.error_description}`),t}}})),je=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.ErrorWithCode=void 0,e.ErrorWithCode=class extends Error{constructor(e,t){super(e),o(this,`code`,void 0),this.code=t}}})),Me=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.getCredentials=m;var n=t(`path`),r=t(`fs`),i=t(`util`),s=je(),c=r.readFile?(0,i.promisify)(r.readFile):async()=>{throw new s.ErrorWithCode(`use key rather than keyFile.`,`MISSING_CREDENTIALS`)},l;(function(e){e.JSON=`.json`,e.DER=`.der`,e.CRT=`.crt`,e.PEM=`.pem`,e.P12=`.p12`,e.PFX=`.pfx`})(l||(l={}));var u=class{constructor(e){o(this,`keyFilePath`,void 0),this.keyFilePath=e}async getCredentials(){let e=await c(this.keyFilePath,`utf8`),t;try{t=JSON.parse(e)}catch(e){throw Error(`Invalid JSON key file: ${e.message}`)}let n=t.private_key,r=t.client_email;if(!n||!r)throw new s.ErrorWithCode(`private_key and client_email are required.`,`MISSING_CREDENTIALS`);return{privateKey:n,clientEmail:r}}},d=class{constructor(e){o(this,`keyFilePath`,void 0),this.keyFilePath=e}async getCredentials(){return{privateKey:await c(this.keyFilePath,`utf8`)}}},f=class{async getCredentials(){throw new s.ErrorWithCode(`*.p12 certificates are not supported after v6.1.2. Consider utilizing *.json format or converting *.p12 to *.pem using the OpenSSL CLI.`,`UNKNOWN_CERTIFICATE_TYPE`)}},p=class{static create(e){switch(n.extname(e)){case l.JSON:return new u(e);case l.DER:case l.CRT:case l.PEM:return new d(e);case l.P12:case l.PFX:return new f;default:throw new s.ErrorWithCode(`Unknown certificate type. Type is determined based on file extension. Current supported extensions are *.json, and *.pem.`,`UNKNOWN_CERTIFICATE_TYPE`)}}};async function m(e){return p.create(e).getCredentials()}})),Ne=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.TokenHandler=void 0;var t=Ae(),n=Me();e.TokenHandler=class{constructor(e){o(this,`token`,void 0),o(this,`tokenExpiresAt`,void 0),o(this,`inFlightRequest`,void 0),o(this,`tokenOptions`,void 0),this.tokenOptions=e}async processCredentials(){if(!this.tokenOptions.key&&!this.tokenOptions.keyFile)throw Error(`No key or keyFile set.`);if(!this.tokenOptions.key&&this.tokenOptions.keyFile){let e=await(0,n.getCredentials)(this.tokenOptions.keyFile);this.tokenOptions.key=e.privateKey,this.tokenOptions.email=e.clientEmail}}isTokenExpiring(){if(!this.token||!this.tokenExpiresAt)return!0;let e=new Date().getTime(),t=this.tokenOptions.eagerRefreshThresholdMillis??0;return this.tokenExpiresAt<=e+t}hasExpired(){return new Date().getTime(),this.token&&this.tokenExpiresAt?new Date().getTime()>=this.tokenExpiresAt:!0}async getToken(e){if(await this.processCredentials(),this.inFlightRequest&&!e)return this.inFlightRequest;if(this.token&&!this.isTokenExpiring()&&!e)return this.token;try{this.inFlightRequest=(0,t.getToken)(this.tokenOptions);let e=await this.inFlightRequest;return this.token=e,this.tokenExpiresAt=new Date().getTime()+(e.expires_in??0)*1e3,e}finally{this.inFlightRequest=void 0}}}})),Pe=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.revokeToken=r;var t=`https://oauth2.googleapis.com/revoke?token=`,n=!0;async function r(e,r){let i=t+e;return await r.request({url:i,retry:n})}})),Fe=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.GoogleToken=void 0;var t=z(),n=Ne(),r=Pe();e.GoogleToken=class{constructor(e){o(this,`tokenOptions`,void 0),o(this,`tokenHandler`,void 0),this.tokenOptions=e||{},this.tokenOptions.transporter=this.tokenOptions.transporter||{request:e=>(0,t.request)(e)},this.tokenOptions.iss||(this.tokenOptions.iss=this.tokenOptions.email),typeof this.tokenOptions.scope==`object`&&(this.tokenOptions.scope=this.tokenOptions.scope.join(` `)),this.tokenHandler=new n.TokenHandler(this.tokenOptions)}get expiresAt(){return this.tokenHandler.tokenExpiresAt}get accessToken(){return this.tokenHandler.token?.access_token}get idToken(){return this.tokenHandler.token?.id_token}get tokenType(){return this.tokenHandler.token?.token_type}get refreshToken(){return this.tokenHandler.token?.refresh_token}hasExpired(){return this.tokenHandler.hasExpired()}isTokenExpiring(){return this.tokenHandler.isTokenExpiring()}getToken(e,t={forceRefresh:!1}){let n;typeof e==`function`?n=e:typeof e==`object`&&(t=e);let r=this.tokenHandler.getToken(t.forceRefresh??!1);return n&&r.then(e=>n(null,e),n),r}revokeToken(e){if(!this.accessToken)return Promise.reject(Error(`No token to revoke.`));let t=(0,r.revokeToken)(this.accessToken,this.tokenOptions.transporter);e&&t.then(()=>e(),e),this.tokenHandler=new n.TokenHandler(this.tokenOptions)}get googleTokenOptions(){return this.tokenOptions}}})),Ie=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.JWTAccess=void 0;var t=x(),n=H(),r={alg:`RS256`,typ:`JWT`};e.JWTAccess=class e{constructor(e,t,r,i){o(this,`email`,void 0),o(this,`key`,void 0),o(this,`keyId`,void 0),o(this,`projectId`,void 0),o(this,`eagerRefreshThresholdMillis`,void 0),o(this,`cache`,new n.LRUCache({capacity:500,maxAge:3600*1e3})),this.email=e,this.key=t,this.keyId=r,this.eagerRefreshThresholdMillis=i??300*1e3}getCachedKey(e,t){let n=e;if(t&&Array.isArray(t)&&t.length?n=e?`${e}_${t.join(`_`)}`:`${t.join(`_`)}`:typeof t==`string`&&(n=e?`${e}_${t}`:t),!n)throw Error(`Scopes or url must be provided`);return n}getRequestHeaders(n,i,a){let o=this.getCachedKey(n,a),s=this.cache.get(o),c=Date.now();if(s&&s.expiration-c>this.eagerRefreshThresholdMillis)return new Headers(s.headers);let l=Math.floor(Date.now()/1e3),u=e.getExpirationTime(l),d;if(Array.isArray(a)&&(a=a.join(` `)),d=a?{iss:this.email,sub:this.email,scope:a,exp:u,iat:l}:{iss:this.email,sub:this.email,aud:n,exp:u,iat:l},i){for(let e in d)if(i[e])throw Error(`The '${e}' property is not allowed when passing additionalClaims. This claim is included in the JWT by default.`)}let f=this.keyId?{...r,kid:this.keyId}:r,p=Object.assign(d,i),m=t.sign({header:f,payload:p,secret:this.key}),h=new Headers({authorization:`Bearer ${m}`});return this.cache.set(o,{expiration:u*1e3,headers:h}),h}static getExpirationTime(e){return e+3600}fromJSON(e){if(!e)throw Error(`Must pass in a JSON object containing the service account auth settings.`);if(!e.client_email)throw Error(`The incoming JSON object does not contain a client_email field`);if(!e.private_key)throw Error(`The incoming JSON object does not contain a private_key field`);this.email=e.client_email,this.key=e.private_key,this.keyId=e.private_key_id,this.projectId=e.project_id}fromStream(e,t){if(t)this.fromStreamAsync(e).then(()=>t(),t);else return this.fromStreamAsync(e)}fromStreamAsync(e){return new Promise((t,n)=>{e||n(Error(`Must pass in a stream containing the service account auth settings.`));let r=``;e.setEncoding(`utf8`).on(`data`,e=>r+=e).on(`error`,n).on(`end`,()=>{try{let e=JSON.parse(r);this.fromJSON(e),t()}catch(e){n(e)}})})}}})),Le=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.JWT=void 0;var t=Fe(),n=Me(),r=Ie(),i=Q(),s=Z();e.JWT=class e extends i.OAuth2Client{constructor(e={}){super(e),o(this,`email`,void 0),o(this,`keyFile`,void 0),o(this,`key`,void 0),o(this,`keyId`,void 0),o(this,`defaultScopes`,void 0),o(this,`scopes`,void 0),o(this,`scope`,void 0),o(this,`subject`,void 0),o(this,`gtoken`,void 0),o(this,`additionalClaims`,void 0),o(this,`useJWTAccessWithScope`,void 0),o(this,`defaultServicePath`,void 0),o(this,`access`,void 0),this.email=e.email,this.keyFile=e.keyFile,this.key=e.key,this.keyId=e.keyId,this.scopes=e.scopes,this.subject=e.subject,this.additionalClaims=e.additionalClaims,this.credentials={refresh_token:`jwt-placeholder`,expiry_date:1}}createScoped(t){let n=new e(this);return n.scopes=t,n}async getRequestMetadataAsync(e){e=this.defaultServicePath?`https://${this.defaultServicePath}/`:e;let t=!this.hasUserScopes()&&e||this.useJWTAccessWithScope&&this.hasAnyScopes()||this.universeDomain!==s.DEFAULT_UNIVERSE;if(this.subject&&this.universeDomain!==s.DEFAULT_UNIVERSE)throw RangeError(`Service Account user is configured for the credential. Domain-wide delegation is not supported in universes other than ${s.DEFAULT_UNIVERSE}`);if(!this.apiKey&&t)if(this.additionalClaims&&this.additionalClaims.target_audience){let{tokens:e}=await this.refreshToken();return{headers:this.addSharedMetadataHeaders(new Headers({authorization:`Bearer ${e.id_token}`}))}}else{this.access||(this.access=new r.JWTAccess(this.email,this.key,this.keyId,this.eagerRefreshThresholdMillis));let t;this.hasUserScopes()?t=this.scopes:e||(t=this.defaultScopes);let n=this.useJWTAccessWithScope||this.universeDomain!==s.DEFAULT_UNIVERSE,i=await this.access.getRequestHeaders(e??void 0,this.additionalClaims,n?t:void 0);return{headers:this.addSharedMetadataHeaders(i)}}else if(this.hasAnyScopes()||this.apiKey)return super.getRequestMetadataAsync(e);else return{headers:new Headers}}async fetchIdToken(e){let n=new t.GoogleToken({iss:this.email,sub:this.subject,scope:this.scopes||this.defaultScopes,keyFile:this.keyFile,key:this.key,additionalClaims:{target_audience:e},transporter:this.transporter});if(await n.getToken({forceRefresh:!0}),!n.idToken)throw Error(`Unknown error: Failed to fetch ID token`);return n.idToken}hasUserScopes(){return this.scopes?this.scopes.length>0:!1}hasAnyScopes(){return!!(this.scopes&&this.scopes.length>0||this.defaultScopes&&this.defaultScopes.length>0)}authorize(e){if(e)this.authorizeAsync().then(t=>e(null,t),e);else return this.authorizeAsync()}async authorizeAsync(){let e=await this.refreshToken();if(!e)throw Error(`No result returned`);return this.credentials=e.tokens,this.credentials.refresh_token=`jwt-placeholder`,this.key=this.gtoken.googleTokenOptions?.key,this.email=this.gtoken.googleTokenOptions?.iss,e.tokens}async refreshTokenNoCache(){let e=this.createGToken(),t={access_token:(await e.getToken({forceRefresh:this.isTokenExpiring()})).access_token,token_type:`Bearer`,expiry_date:e.expiresAt,id_token:e.idToken};return this.emit(`tokens`,t),{res:null,tokens:t}}createGToken(){return this.gtoken||(this.gtoken=new t.GoogleToken({iss:this.email,sub:this.subject,scope:this.scopes||this.defaultScopes,keyFile:this.keyFile,key:this.key,additionalClaims:this.additionalClaims,transporter:this.transporter})),this.gtoken}fromJSON(e){if(!e)throw Error(`Must pass in a JSON object containing the service account auth settings.`);if(!e.client_email)throw Error(`The incoming JSON object does not contain a client_email field`);if(!e.private_key)throw Error(`The incoming JSON object does not contain a private_key field`);this.email=e.client_email,this.key=e.private_key,this.keyId=e.private_key_id,this.projectId=e.project_id,this.quotaProjectId=e.quota_project_id,this.universeDomain=e.universe_domain||this.universeDomain}fromStream(e,t){if(t)this.fromStreamAsync(e).then(()=>t(),t);else return this.fromStreamAsync(e)}fromStreamAsync(e){return new Promise((t,n)=>{if(!e)throw Error(`Must pass in a stream containing the service account auth settings.`);let r=``;e.setEncoding(`utf8`).on(`error`,n).on(`data`,e=>r+=e).on(`end`,()=>{try{let e=JSON.parse(r);this.fromJSON(e),t()}catch(e){n(e)}})})}fromAPIKey(e){if(typeof e!=`string`)throw Error(`Must provide an API Key string.`);this.apiKey=e}async getCredentials(){if(this.key)return{private_key:this.key,client_email:this.email};if(this.keyFile){this.createGToken();let e=await(0,n.getCredentials)(this.keyFile);return{private_key:e.privateKey,client_email:e.clientEmail}}throw Error(`A key or a keyFile must be provided to getCredentials.`)}}})),Re=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.UserRefreshClient=e.USER_REFRESH_ACCOUNT_TYPE=void 0;var t=Q(),n=Z();e.USER_REFRESH_ACCOUNT_TYPE=`authorized_user`,e.UserRefreshClient=class e extends t.OAuth2Client{constructor(e,t,n,r,i){let a=e&&typeof e==`object`?e:{clientId:e,clientSecret:t,refreshToken:n,eagerRefreshThresholdMillis:r,forceRefreshOnFailure:i};super(a),o(this,`_refreshToken`,void 0),this._refreshToken=a.refreshToken,this.credentials.refresh_token=a.refreshToken}async refreshTokenNoCache(){return super.refreshTokenNoCache(this._refreshToken)}async fetchIdToken(t){let r={...e.RETRY_CONFIG,url:this.endpoints.oauth2TokenUrl,method:`POST`,data:new URLSearchParams({client_id:this._clientId,client_secret:this._clientSecret,grant_type:`refresh_token`,refresh_token:this._refreshToken,target_audience:t}),responseType:`json`};return n.AuthClient.setMethodName(r,`fetchIdToken`),(await this.transporter.request(r)).data.id_token}fromJSON(e){if(!e)throw Error(`Must pass in a JSON object containing the user refresh token`);if(e.type!==`authorized_user`)throw Error(`The incoming JSON object does not have the "authorized_user" type`);if(!e.client_id)throw Error(`The incoming JSON object does not contain a client_id field`);if(!e.client_secret)throw Error(`The incoming JSON object does not contain a client_secret field`);if(!e.refresh_token)throw Error(`The incoming JSON object does not contain a refresh_token field`);this._clientId=e.client_id,this._clientSecret=e.client_secret,this._refreshToken=e.refresh_token,this.credentials.refresh_token=e.refresh_token,this.quotaProjectId=e.quota_project_id,this.universeDomain=e.universe_domain||this.universeDomain}fromStream(e,t){if(t)this.fromStreamAsync(e).then(()=>t(),t);else return this.fromStreamAsync(e)}async fromStreamAsync(e){return new Promise((t,n)=>{if(!e)return n(Error(`Must pass in a stream containing the user refresh token.`));let r=``;e.setEncoding(`utf8`).on(`error`,n).on(`data`,e=>r+=e).on(`end`,()=>{try{let e=JSON.parse(r);return this.fromJSON(e),t()}catch(e){return n(e)}})})}static fromJSON(t){let n=new e;return n.fromJSON(t),n}}})),ze=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.Impersonated=e.IMPERSONATED_ACCOUNT_TYPE=void 0;var t=Q(),n=z(),r=H();e.IMPERSONATED_ACCOUNT_TYPE=`impersonated_service_account`,e.Impersonated=class e extends t.OAuth2Client{constructor(e={}){if(super(e),o(this,`sourceClient`,void 0),o(this,`targetPrincipal`,void 0),o(this,`targetScopes`,void 0),o(this,`delegates`,void 0),o(this,`lifetime`,void 0),o(this,`endpoint`,void 0),this.credentials={expiry_date:1,refresh_token:`impersonated-placeholder`},this.sourceClient=e.sourceClient??new t.OAuth2Client,this.targetPrincipal=e.targetPrincipal??``,this.delegates=e.delegates??[],this.targetScopes=e.targetScopes??[],this.lifetime=e.lifetime??3600,!(0,r.originalOrCamelOptions)(e).get(`universe_domain`))this.universeDomain=this.sourceClient.universeDomain;else if(this.sourceClient.universeDomain!==this.universeDomain)throw RangeError(`Universe domain ${this.sourceClient.universeDomain} in source credentials does not match ${this.universeDomain} universe domain set for impersonated credentials.`);this.endpoint=e.endpoint??`https://iamcredentials.${this.universeDomain}`}async sign(t){await this.sourceClient.getAccessToken();let n=`projects/-/serviceAccounts/${this.targetPrincipal}`,r=`${this.endpoint}/v1/${n}:signBlob`,i={delegates:this.delegates,payload:Buffer.from(t).toString(`base64`)};return(await this.sourceClient.request({...e.RETRY_CONFIG,url:r,data:i,method:`POST`})).data}getTargetPrincipal(){return this.targetPrincipal}async refreshToken(){try{await this.sourceClient.getAccessToken();let t=`projects/-/serviceAccounts/`+this.targetPrincipal,n=`${this.endpoint}/v1/${t}:generateAccessToken`,r={delegates:this.delegates,scope:this.targetScopes,lifetime:this.lifetime+`s`},i=await this.sourceClient.request({...e.RETRY_CONFIG,url:n,data:r,method:`POST`}),a=i.data;return this.credentials.access_token=a.accessToken,this.credentials.expiry_date=Date.parse(a.expireTime),{tokens:this.credentials,res:i}}catch(e){if(!(e instanceof Error))throw e;let t=0,r=``;throw e instanceof n.GaxiosError&&(t=e?.response?.data?.error?.status,r=e?.response?.data?.error?.message),t&&r?(e.message=`${t}: unable to impersonate: ${r}`,e):(e.message=`unable to impersonate: ${e}`,e)}}async fetchIdToken(t,n){await this.sourceClient.getAccessToken();let r=`projects/-/serviceAccounts/${this.targetPrincipal}`,i=`${this.endpoint}/v1/${r}:generateIdToken`,a={delegates:this.delegates,audience:t,includeEmail:n?.includeEmail??!0,useEmailAzp:n?.includeEmail??!0};return(await this.sourceClient.request({...e.RETRY_CONFIG,url:i,data:a,method:`POST`})).data.token}}})),Be=i((e=>{c(),a(),d(),l(),Object.defineProperty(e,`__esModule`,{value:!0}),e.OAuthClientAuthHandler=void 0,e.getErrorFromOAuthErrorResponse=u;var t=z(),n=V(),r=[`PUT`,`POST`,`PATCH`],i=new WeakMap,s=new WeakMap;e.OAuthClientAuthHandler=class{constructor(e){m(this,i,(0,n.createCrypto)()),m(this,s,void 0),o(this,`transporter`,void 0),e&&`clientId`in e?(h(s,this,e),this.transporter=new t.Gaxios):(h(s,this,e?.clientAuthentication),this.transporter=e?.transporter||new t.Gaxios)}applyClientAuthenticationOptions(e,n){e.headers=t.Gaxios.mergeHeaders(e.headers),this.injectAuthenticatedHeaders(e,n),n||this.injectAuthenticatedRequestBody(e)}injectAuthenticatedHeaders(e,n){if(n)e.headers=t.Gaxios.mergeHeaders(e.headers,{authorization:`Bearer ${n}`});else if(p(s,this)?.confidentialClientType===`basic`){e.headers=t.Gaxios.mergeHeaders(e.headers);let n=p(s,this).clientId,r=p(s,this).clientSecret||``,a=p(i,this).encodeBase64StringUtf8(`${n}:${r}`);t.Gaxios.mergeHeaders(e.headers,{authorization:`Basic ${a}`})}}injectAuthenticatedRequestBody(e){if(p(s,this)?.confidentialClientType===`request-body`){let t=(e.method||`GET`).toUpperCase();if(!r.includes(t))throw Error(`${t} HTTP method does not support ${p(s,this).confidentialClientType} client authentication`);let n=new Headers(e.headers).get(`content-type`);if(n?.startsWith(`application/x-www-form-urlencoded`)||e.data instanceof URLSearchParams){let t=new URLSearchParams(e.data??``);t.append(`client_id`,p(s,this).clientId),t.append(`client_secret`,p(s,this).clientSecret||``),e.data=t}else if(n?.startsWith(`application/json`))e.data=e.data||{},Object.assign(e.data,{client_id:p(s,this).clientId,client_secret:p(s,this).clientSecret||``});else throw Error(`${n} content-types are not supported with ${p(s,this).confidentialClientType} client authentication`)}}static get RETRY_CONFIG(){return{retry:!0,retryConfig:{httpMethodsToRetry:[`GET`,`PUT`,`POST`,`HEAD`,`OPTIONS`,`DELETE`]}}}};function u(e,t){let n=e.error,r=e.error_description,i=e.error_uri,a=`Error code ${n}`;r!==void 0&&(a+=`: ${r}`),i!==void 0&&(a+=` - ${i}`);let o=Error(a);if(t){let e=Object.keys(t);t.stack&&e.push(`stack`),e.forEach(e=>{e!==`message`&&Object.defineProperty(o,e,{value:t[e],writable:!1,enumerable:!0})})}return o}})),Ve=i((e=>{c(),d(),l(),Object.defineProperty(e,`__esModule`,{value:!0}),e.StsCredentials=void 0;var t=z(),n=Z(),r=Be(),i=H(),a=new WeakMap;e.StsCredentials=class e extends r.OAuthClientAuthHandler{constructor(e={tokenExchangeEndpoint:``},t){(typeof e!=`object`||e instanceof URL)&&(e={tokenExchangeEndpoint:e,clientAuthentication:t}),super(e),m(this,a,void 0),h(a,this,e.tokenExchangeEndpoint)}async exchangeToken(o,s,c){let l={grant_type:o.grantType,resource:o.resource,audience:o.audience,scope:o.scope?.join(` `),requested_token_type:o.requestedTokenType,subject_token:o.subjectToken,subject_token_type:o.subjectTokenType,actor_token:o.actingParty?.actorToken,actor_token_type:o.actingParty?.actorTokenType,options:c&&JSON.stringify(c)},u={...e.RETRY_CONFIG,url:p(a,this).toString(),method:`POST`,headers:s,data:new URLSearchParams((0,i.removeUndefinedValuesInObject)(l)),responseType:`json`};n.AuthClient.setMethodName(u,`exchangeToken`),this.applyClientAuthenticationOptions(u);try{let e=await this.transporter.request(u),t=e.data;return t.res=e,t}catch(e){throw e instanceof t.GaxiosError&&e.response?(0,r.getErrorFromOAuthErrorResponse)(e.response.data,e):e}}}})),$=i((e=>{g(),a(),c(),d(),l(),f(),Object.defineProperty(e,`__esModule`,{value:!0}),e.BaseExternalAccountClient=e.CLOUD_RESOURCE_MANAGER=e.EXTERNAL_ACCOUNT_TYPE=e.EXPIRATION_TIME_OFFSET=void 0;var n=z(),r=t(`stream`),i=Z(),_=Ve(),v=H(),y=we(),b=`urn:ietf:params:oauth:grant-type:token-exchange`,x=`urn:ietf:params:oauth:token-type:access_token`,S=`https://www.googleapis.com/auth/cloud-platform`,C=3600;e.EXPIRATION_TIME_OFFSET=300*1e3,e.EXTERNAL_ACCOUNT_TYPE=`external_account`,e.CLOUD_RESOURCE_MANAGER=`https://cloudresourcemanager.googleapis.com/v1/projects/`;var w=`//iam\\.googleapis\\.com/locations/[^/]+/workforcePools/[^/]+/providers/.+`,T=`https://sts.{universeDomain}/v1/token`,E=new WeakMap,D=new WeakSet,O=class t extends i.AuthClient{constructor(t){super(t),u(this,D),o(this,`scopes`,void 0),o(this,`projectNumber`,void 0),o(this,`audience`,void 0),o(this,`subjectTokenType`,void 0),o(this,`stsCredential`,void 0),o(this,`clientAuth`,void 0),o(this,`credentialSourceType`,void 0),o(this,`cachedAccessToken`,void 0),o(this,`serviceAccountImpersonationUrl`,void 0),o(this,`serviceAccountImpersonationLifetime`,void 0),o(this,`workforcePoolUserProject`,void 0),o(this,`configLifetimeRequested`,void 0),o(this,`tokenUrl`,void 0),o(this,`cloudResourceManagerURL`,void 0),o(this,`supplierContext`,void 0),m(this,E,null);let n=(0,v.originalOrCamelOptions)(t),r=n.get(`type`);if(r&&r!==e.EXTERNAL_ACCOUNT_TYPE)throw Error(`Expected "${e.EXTERNAL_ACCOUNT_TYPE}" type but received "${t.type}"`);let i=n.get(`client_id`),a=n.get(`client_secret`);this.tokenUrl=n.get(`token_url`)??T.replace(`{universeDomain}`,this.universeDomain);let s=n.get(`subject_token_type`),c=n.get(`workforce_pool_user_project`),l=n.get(`service_account_impersonation_url`),d=n.get(`service_account_impersonation`),f=(0,v.originalOrCamelOptions)(d).get(`token_lifetime_seconds`);this.cloudResourceManagerURL=new URL(n.get(`cloud_resource_manager_url`)||`https://cloudresourcemanager.${this.universeDomain}/v1/projects/`),i&&(this.clientAuth={confidentialClientType:`basic`,clientId:i,clientSecret:a}),this.stsCredential=new _.StsCredentials({tokenExchangeEndpoint:this.tokenUrl,clientAuthentication:this.clientAuth}),this.scopes=n.get(`scopes`)||[S],this.cachedAccessToken=null,this.audience=n.get(`audience`),this.subjectTokenType=s,this.workforcePoolUserProject=c;let p=new RegExp(w);if(this.workforcePoolUserProject&&!this.audience.match(p))throw Error(`workforcePoolUserProject should not be set for non-workforce pool credentials.`);this.serviceAccountImpersonationUrl=l,this.serviceAccountImpersonationLifetime=f,this.serviceAccountImpersonationLifetime?this.configLifetimeRequested=!0:(this.configLifetimeRequested=!1,this.serviceAccountImpersonationLifetime=C),this.projectNumber=this.getProjectNumber(this.audience),this.supplierContext={audience:this.audience,subjectTokenType:this.subjectTokenType,transporter:this.transporter}}getServiceAccountEmail(){if(this.serviceAccountImpersonationUrl){if(this.serviceAccountImpersonationUrl.length>256)throw RangeError(`URL is too long: ${this.serviceAccountImpersonationUrl}`);return/serviceAccounts\/(?<email>[^:]+):generateAccessToken$/.exec(this.serviceAccountImpersonationUrl)?.groups?.email||null}return null}setCredentials(e){super.setCredentials(e),this.cachedAccessToken=e}async getAccessToken(){return(!this.cachedAccessToken||this.isExpired(this.cachedAccessToken))&&await this.refreshAccessTokenAsync(),{token:this.cachedAccessToken.access_token,res:this.cachedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(t)this.requestAsync(e).then(e=>t(null,e),e=>t(e,e.response));else return this.requestAsync(e)}async getProjectId(){let e=this.projectNumber||this.workforcePoolUserProject;if(this.projectId)return this.projectId;if(e){let n=await this.getRequestHeaders(),r={...t.RETRY_CONFIG,headers:n,url:`${this.cloudResourceManagerURL.toString()}${e}`,responseType:`json`};return i.AuthClient.setMethodName(r,`getProjectId`),this.projectId=(await this.transporter.request(r)).data.projectId,this.projectId}return null}async requestAsync(e,t=!1){let i;try{let t=await this.getRequestHeaders();e.headers=n.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,t),i=await this.transporter.request(e)}catch(n){let i=n.response;if(i){let n=i.status,a=i.config.data instanceof r.Readable;if(!t&&(n===401||n===403)&&!a&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return i}async refreshAccessTokenAsync(){h(E,this,p(E,this)||s(D,this,k).call(this));try{return await p(E,this)}finally{h(E,this,null)}}getProjectNumber(e){let t=e.match(/\/projects\/([^/]+)/);return t?t[1]:null}async getImpersonatedAccessToken(e){let n={...t.RETRY_CONFIG,url:this.serviceAccountImpersonationUrl,method:`POST`,headers:{"content-type":`application/json`,authorization:`Bearer ${e}`},data:{scope:this.getScopesArray(),lifetime:this.serviceAccountImpersonationLifetime+`s`},responseType:`json`};i.AuthClient.setMethodName(n,`getImpersonatedAccessToken`);let r=await this.transporter.request(n),a=r.data;return{access_token:a.accessToken,expiry_date:new Date(a.expireTime).getTime(),res:r}}isExpired(e){let t=new Date().getTime();return e.expiry_date?t>=e.expiry_date-this.eagerRefreshThresholdMillis:!1}getScopesArray(){return typeof this.scopes==`string`?[this.scopes]:this.scopes||[S]}getMetricsHeaderValue(){let e=process.version.replace(/^v/,``),t=this.serviceAccountImpersonationUrl!==void 0,n=this.credentialSourceType?this.credentialSourceType:`unknown`;return`gl-node/${e} auth/${y.pkg.version} google-byoid-sdk source/${n} sa-impersonation/${t} config-lifetime/${this.configLifetimeRequested}`}getTokenUrl(){return this.tokenUrl}};async function k(){let e=await this.retrieveSubjectToken(),t={grantType:b,audience:this.audience,requestedTokenType:x,subjectToken:e,subjectTokenType:this.subjectTokenType,scope:this.serviceAccountImpersonationUrl?[S]:this.getScopesArray()},n=!this.clientAuth&&this.workforcePoolUserProject?{userProject:this.workforcePoolUserProject}:void 0,r=new Headers({"x-goog-api-client":this.getMetricsHeaderValue()}),i=await this.stsCredential.exchangeToken(t,r,n);return this.serviceAccountImpersonationUrl?this.cachedAccessToken=await this.getImpersonatedAccessToken(i.access_token):i.expires_in?this.cachedAccessToken={access_token:i.access_token,expiry_date:new Date().getTime()+i.expires_in*1e3,res:i.res}:this.cachedAccessToken={access_token:i.access_token,res:i.res},this.credentials={},Object.assign(this.credentials,this.cachedAccessToken),delete this.credentials.res,this.emit(`tokens`,{refresh_token:null,expiry_date:this.cachedAccessToken.expiry_date,access_token:this.cachedAccessToken.access_token,token_type:`Bearer`,id_token:null}),this.cachedAccessToken}e.BaseExternalAccountClient=O})),He=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.FileSubjectTokenSupplier=void 0;var n=t(`util`),r=t(`fs`),i=(0,n.promisify)(r.readFile??(()=>{})),s=(0,n.promisify)(r.realpath??(()=>{})),c=(0,n.promisify)(r.lstat??(()=>{}));e.FileSubjectTokenSupplier=class{constructor(e){o(this,`filePath`,void 0),o(this,`formatType`,void 0),o(this,`subjectTokenFieldName`,void 0),this.filePath=e.filePath,this.formatType=e.formatType,this.subjectTokenFieldName=e.subjectTokenFieldName}async getSubjectToken(){let e=this.filePath;try{if(e=await s(e),!(await c(e)).isFile())throw Error()}catch(t){throw t instanceof Error&&(t.message=`The file at ${e} does not exist, or it is not a file. ${t.message}`),t}let t,n=await i(e,{encoding:`utf8`});if(this.formatType===`text`?t=n:this.formatType===`json`&&this.subjectTokenFieldName&&(t=JSON.parse(n)[this.subjectTokenFieldName]),!t)throw Error(`Unable to parse the subject_token from the credential_source file`);return t}}})),Ue=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.UrlSubjectTokenSupplier=void 0;var t=Z();e.UrlSubjectTokenSupplier=class{constructor(e){o(this,`url`,void 0),o(this,`headers`,void 0),o(this,`formatType`,void 0),o(this,`subjectTokenFieldName`,void 0),o(this,`additionalGaxiosOptions`,void 0),this.url=e.url,this.formatType=e.formatType,this.subjectTokenFieldName=e.subjectTokenFieldName,this.headers=e.headers,this.additionalGaxiosOptions=e.additionalGaxiosOptions}async getSubjectToken(e){let n={...this.additionalGaxiosOptions,url:this.url,method:`GET`,headers:this.headers,responseType:this.formatType};t.AuthClient.setMethodName(n,`getSubjectToken`);let r;if(this.formatType===`text`?r=(await e.transporter.request(n)).data:this.formatType===`json`&&this.subjectTokenFieldName&&(r=(await e.transporter.request(n)).data[this.subjectTokenFieldName]),!r)throw Error(`Unable to parse the subject_token from the credential_source URL`);return r}}})),We=i((e=>{g(),a(),f(),Object.defineProperty(e,`__esModule`,{value:!0}),e.CertificateSubjectTokenSupplier=e.InvalidConfigurationError=e.CertificateSourceUnavailableError=e.CERTIFICATE_CONFIGURATION_ENV_VARIABLE=void 0;var n=H(),r=t(`fs`),i=t(`crypto`),c=t(`https`);e.CERTIFICATE_CONFIGURATION_ENV_VARIABLE=`GOOGLE_API_CERTIFICATE_CONFIG`;var l=class extends Error{constructor(e){super(e),this.name=`CertificateSourceUnavailableError`}};e.CertificateSourceUnavailableError=l;var d=class extends Error{constructor(e){super(e),this.name=`InvalidConfigurationError`}};e.InvalidConfigurationError=d;var p=new WeakSet,m=class{constructor(e){if(u(this,p),o(this,`certificateConfigPath`,void 0),o(this,`trustChainPath`,void 0),o(this,`cert`,void 0),o(this,`key`,void 0),!e.useDefaultCertificateConfig&&!e.certificateConfigLocation)throw new d("Either `useDefaultCertificateConfig` must be true or a `certificateConfigLocation` must be provided.");if(e.useDefaultCertificateConfig&&e.certificateConfigLocation)throw new d("Both `useDefaultCertificateConfig` and `certificateConfigLocation` cannot be provided.");this.trustChainPath=e.trustChainPath,this.certificateConfigPath=e.certificateConfigLocation??``}async createMtlsHttpsAgent(){if(!this.key||!this.cert)throw new d(`Cannot create mTLS Agent with missing certificate or key`);return new c.Agent({key:this.key,cert:this.cert})}async getSubjectToken(){this.certificateConfigPath=await s(p,this,h).call(this);let{certPath:e,keyPath:t}=await s(p,this,_).call(this);return{cert:this.cert,key:this.key}=await s(p,this,v).call(this,e,t),await s(p,this,y).call(this,this.cert)}};async function h(){let t=this.certificateConfigPath;if(t){if(await(0,n.isValidFile)(t))return t;throw new l(`Provided certificate config path is invalid: ${t}`)}let r=process.env[e.CERTIFICATE_CONFIGURATION_ENV_VARIABLE];if(r){if(await(0,n.isValidFile)(r))return r;throw new l(`Path from environment variable "${e.CERTIFICATE_CONFIGURATION_ENV_VARIABLE}" is invalid: ${r}`)}let i=(0,n.getWellKnownCertificateConfigFileLocation)();if(await(0,n.isValidFile)(i))return i;throw new l(`Could not find certificate configuration file. Searched override path, the "${e.CERTIFICATE_CONFIGURATION_ENV_VARIABLE}" env var, and the gcloud path (${i}).`)}async function _(){let e=this.certificateConfigPath,t;try{t=await r.promises.readFile(e,`utf8`)}catch{throw new l(`Failed to read certificate config file at: ${e}`)}try{let n=JSON.parse(t),r=n?.cert_configs?.workload?.cert_path,i=n?.cert_configs?.workload?.key_path;if(!r||!i)throw new d(`Certificate config file (${e}) is missing required "cert_path" or "key_path" in the workload config.`);return{certPath:r,keyPath:i}}catch(t){throw t instanceof d?t:new d(`Failed to parse certificate config from ${e}: ${t.message}`)}}async function v(e,t){let n,a;try{n=await r.promises.readFile(e),new i.X509Certificate(n)}catch(t){throw new l(`Failed to read certificate file at ${e}: ${t instanceof Error?t.message:String(t)}`)}try{a=await r.promises.readFile(t),(0,i.createPrivateKey)(a)}catch(e){throw new l(`Failed to read private key file at ${t}: ${e instanceof Error?e.message:String(e)}`)}return{cert:n,key:a}}async function y(e){let t=new i.X509Certificate(e);if(!this.trustChainPath)return JSON.stringify([t.raw.toString(`base64`)]);try{let e=((await r.promises.readFile(this.trustChainPath,`utf8`)).match(/-----BEGIN CERTIFICATE-----[^-]+-----END CERTIFICATE-----/g)??[]).map((e,t)=>{try{return new i.X509Certificate(e)}catch(e){let n=e instanceof Error?e.message:String(e);throw new d(`Failed to parse certificate at index ${t} in trust chain file ${this.trustChainPath}: ${n}`)}}),n=e.findIndex(e=>t.raw.equals(e.raw)),a;if(n===-1)a=[t,...e];else if(n===0)a=e;else throw new d(`Leaf certificate exists in the trust chain but is not the first entry (found at index ${n}).`);return JSON.stringify(a.map(e=>e.raw.toString(`base64`)))}catch(e){if(e instanceof d)throw e;let t=e instanceof Error?e.message:String(e);throw new l(`Failed to process certificate chain from ${this.trustChainPath}: ${t}`)}}e.CertificateSubjectTokenSupplier=m})),Ge=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.IdentityPoolClient=void 0;var t=$(),n=H(),r=He(),i=Ue(),s=We(),c=Ve(),l=z();e.IdentityPoolClient=class e extends t.BaseExternalAccountClient{constructor(t){super(t),o(this,`subjectTokenSupplier`,void 0);let a=(0,n.originalOrCamelOptions)(t),c=a.get(`credential_source`),l=a.get(`subject_token_supplier`);if(!c&&!l)throw Error(`A credential source or subject token supplier must be specified.`);if(c&&l)throw Error(`Only one of credential source or subject token supplier can be specified.`);if(l)this.subjectTokenSupplier=l,this.credentialSourceType=`programmatic`;else{let t=(0,n.originalOrCamelOptions)(c),a=(0,n.originalOrCamelOptions)(t.get(`format`)),o=a.get(`type`)||`text`,l=a.get(`subject_token_field_name`);if(o!==`json`&&o!==`text`)throw Error(`Invalid credential_source format "${o}"`);if(o===`json`&&!l)throw Error(`Missing subject_token_field_name for JSON credential_source format`);let u=t.get(`file`),d=t.get(`url`),f=t.get(`certificate`),p=t.get(`headers`);if(u&&d||d&&f||u&&f)throw Error(`No valid Identity Pool "credential_source" provided, must be either file, url, or certificate.`);if(u)this.credentialSourceType=`file`,this.subjectTokenSupplier=new r.FileSubjectTokenSupplier({filePath:u,formatType:o,subjectTokenFieldName:l});else if(d)this.credentialSourceType=`url`,this.subjectTokenSupplier=new i.UrlSubjectTokenSupplier({url:d,formatType:o,subjectTokenFieldName:l,headers:p,additionalGaxiosOptions:e.RETRY_CONFIG});else if(f)this.credentialSourceType=`certificate`,this.subjectTokenSupplier=new s.CertificateSubjectTokenSupplier({useDefaultCertificateConfig:f.use_default_certificate_config,certificateConfigLocation:f.certificate_config_location,trustChainPath:f.trust_chain_path});else throw Error(`No valid Identity Pool "credential_source" provided, must be either file, url, or certificate.`)}}async retrieveSubjectToken(){let e=await this.subjectTokenSupplier.getSubjectToken(this.supplierContext);if(this.subjectTokenSupplier instanceof s.CertificateSubjectTokenSupplier){let e=await this.subjectTokenSupplier.createMtlsHttpsAgent();this.stsCredential=new c.StsCredentials({tokenExchangeEndpoint:this.getTokenUrl(),clientAuthentication:this.clientAuth,transporter:new l.Gaxios({agent:e})}),this.transporter=new l.Gaxios({...this.transporter.defaults||{},agent:e})}return e}}})),Ke=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.AwsRequestSigner=void 0;var t=z(),n=V(),r=`AWS4-HMAC-SHA256`,i=`aws4_request`;e.AwsRequestSigner=class{constructor(e,t){o(this,`getCredentials`,void 0),o(this,`region`,void 0),o(this,`crypto`,void 0),this.getCredentials=e,this.region=t,this.crypto=(0,n.createCrypto)()}async getRequestOptions(e){if(!e.url)throw RangeError(`"url" is required in "amzOptions"`);let n=typeof e.data==`object`?JSON.stringify(e.data):e.data,r=e.url,i=e.method||`GET`,a=e.body||n,o=e.headers,s=await this.getCredentials(),c=new URL(r);if(typeof a!=`string`&&a!==void 0)throw TypeError(`'requestPayload' is expected to be a string if provided. Got: ${a}`);let u=await l({crypto:this.crypto,host:c.host,canonicalUri:c.pathname,canonicalQuerystring:c.search.slice(1),method:i,region:this.region,securityCredentials:s,requestPayload:a,additionalAmzHeaders:o}),d=t.Gaxios.mergeHeaders(u.amzDate?{"x-amz-date":u.amzDate}:{},{authorization:u.authorizationHeader,host:c.host},o||{});s.token&&t.Gaxios.mergeHeaders(d,{"x-amz-security-token":s.token});let f={url:r,method:i,headers:d};return a!==void 0&&(f.body=a),f}};async function s(e,t,n){return await e.signWithHmacSha256(t,n)}async function c(e,t,n,r,i){return await s(e,await s(e,await s(e,await s(e,`AWS4${t}`,n),r),i),`aws4_request`)}async function l(e){let a=t.Gaxios.mergeHeaders(e.additionalAmzHeaders),o=e.requestPayload||``,l=e.host.split(`.`)[0],u=new Date,d=u.toISOString().replace(/[-:]/g,``).replace(/\.[0-9]+/,``),f=u.toISOString().replace(/[-]/g,``).replace(/T.*/,``);e.securityCredentials.token&&a.set(`x-amz-security-token`,e.securityCredentials.token);let p=t.Gaxios.mergeHeaders({host:e.host},a.has(`date`)?{}:{"x-amz-date":d},a),m=``,h=[...p.keys()].sort();h.forEach(e=>{m+=`${e}:${p.get(e)}\n`});let g=h.join(`;`),_=await e.crypto.sha256DigestHex(o),v=`${e.method.toUpperCase()}\n${e.canonicalUri}\n${e.canonicalQuerystring}\n${m}\n${g}\n${_}`,y=`${f}/${e.region}/${l}/${i}`,b=`${r}\n${d}\n${y}\n`+await e.crypto.sha256DigestHex(v),x=await c(e.crypto,e.securityCredentials.secretAccessKey,f,e.region,l),S=await s(e.crypto,x,b),C=`${r} Credential=${e.securityCredentials.accessKeyId}/${y}, SignedHeaders=${g}, Signature=${(0,n.fromArrayBufferToHex)(S)}`;return{amzDate:a.has(`date`)?void 0:d,authorizationHeader:C,canonicalQuerystring:e.canonicalQuerystring}}})),qe=i((e=>{g(),a(),f(),Object.defineProperty(e,`__esModule`,{value:!0}),e.DefaultAwsSecurityCredentialsSupplier=void 0;var t=Z(),n=new WeakSet,r=class{constructor(e){u(this,n),o(this,`regionUrl`,void 0),o(this,`securityCredentialsUrl`,void 0),o(this,`imdsV2SessionTokenUrl`,void 0),o(this,`additionalGaxiosOptions`,void 0),this.regionUrl=e.regionUrl,this.securityCredentialsUrl=e.securityCredentialsUrl,this.imdsV2SessionTokenUrl=e.imdsV2SessionTokenUrl,this.additionalGaxiosOptions=e.additionalGaxiosOptions}async getAwsRegion(e){if(d.call(s(n,this)))return d.call(s(n,this));let r=new Headers;if(!d.call(s(n,this))&&this.imdsV2SessionTokenUrl&&r.set(`x-aws-ec2-metadata-token`,await s(n,this,i).call(this,e.transporter)),!this.regionUrl)throw RangeError(`Unable to determine AWS region due to missing "options.credential_source.region_url"`);let a={...this.additionalGaxiosOptions,url:this.regionUrl,method:`GET`,responseType:`text`,headers:r};t.AuthClient.setMethodName(a,`getAwsRegion`);let o=await e.transporter.request(a);return o.data.substr(0,o.data.length-1)}async getAwsSecurityCredentials(e){if(p.call(s(n,this)))return p.call(s(n,this));let t=new Headers;this.imdsV2SessionTokenUrl&&t.set(`x-aws-ec2-metadata-token`,await s(n,this,i).call(this,e.transporter));let r=await s(n,this,c).call(this,t,e.transporter),a=await s(n,this,l).call(this,r,t,e.transporter);return{accessKeyId:a.AccessKeyId,secretAccessKey:a.SecretAccessKey,token:a.Token}}};async function i(e){let n={...this.additionalGaxiosOptions,url:this.imdsV2SessionTokenUrl,method:`PUT`,responseType:`text`,headers:{"x-aws-ec2-metadata-token-ttl-seconds":`300`}};return t.AuthClient.setMethodName(n,`#getImdsV2SessionToken`),(await e.request(n)).data}async function c(e,n){if(!this.securityCredentialsUrl)throw Error(`Unable to determine AWS role name due to missing "options.credential_source.url"`);let r={...this.additionalGaxiosOptions,url:this.securityCredentialsUrl,method:`GET`,responseType:`text`,headers:e};return t.AuthClient.setMethodName(r,`#getAwsRoleName`),(await n.request(r)).data}async function l(e,n,r){let i={...this.additionalGaxiosOptions,url:`${this.securityCredentialsUrl}/${e}`,headers:n,responseType:`json`};return t.AuthClient.setMethodName(i,`#retrieveAwsSecurityCredentials`),(await r.request(i)).data}function d(){return process.env.AWS_REGION||process.env.AWS_DEFAULT_REGION||null}function p(){return process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY?{accessKeyId:process.env.AWS_ACCESS_KEY_ID,secretAccessKey:process.env.AWS_SECRET_ACCESS_KEY,token:process.env.AWS_SESSION_TOKEN}:null}e.DefaultAwsSecurityCredentialsSupplier=r})),Je=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.AwsClient=void 0;var t=Ke(),n=$(),r=qe(),i=H(),s=z(),c=class e extends n.BaseExternalAccountClient{constructor(e){super(e),o(this,`environmentId`,void 0),o(this,`awsSecurityCredentialsSupplier`,void 0),o(this,`regionalCredVerificationUrl`,void 0),o(this,`awsRequestSigner`,void 0),o(this,`region`,void 0);let t=(0,i.originalOrCamelOptions)(e),n=t.get(`credential_source`),a=t.get(`aws_security_credentials_supplier`);if(!n&&!a)throw Error(`A credential source or AWS security credentials supplier must be specified.`);if(n&&a)throw Error(`Only one of credential source or AWS security credentials supplier can be specified.`);if(a)this.awsSecurityCredentialsSupplier=a,this.regionalCredVerificationUrl=l._,this.credentialSourceType=`programmatic`;else{let e=(0,i.originalOrCamelOptions)(n);this.environmentId=e.get(`environment_id`);let t=e.get(`region_url`),a=e.get(`url`),o=e.get(`imdsv2_session_token_url`);this.awsSecurityCredentialsSupplier=new r.DefaultAwsSecurityCredentialsSupplier({regionUrl:t,securityCredentialsUrl:a,imdsV2SessionTokenUrl:o}),this.regionalCredVerificationUrl=e.get(`regional_cred_verification_url`),this.credentialSourceType=`aws`,this.validateEnvironmentId()}this.awsRequestSigner=null,this.region=``}validateEnvironmentId(){let e=this.environmentId?.match(/^(aws)(\d+)$/);if(!e||!this.regionalCredVerificationUrl)throw Error(`No valid AWS "credential_source" provided`);if(parseInt(e[2],10)!==1)throw Error(`aws version "${e[2]}" is not supported in the current build.`)}async retrieveSubjectToken(){this.awsRequestSigner||(this.region=await this.awsSecurityCredentialsSupplier.getAwsRegion(this.supplierContext),this.awsRequestSigner=new t.AwsRequestSigner(async()=>this.awsSecurityCredentialsSupplier.getAwsSecurityCredentials(this.supplierContext),this.region));let n=await this.awsRequestSigner.getRequestOptions({...e.RETRY_CONFIG,url:this.regionalCredVerificationUrl.replace(`{region}`,this.region),method:`POST`}),r=[];return s.Gaxios.mergeHeaders({"x-goog-cloud-target-resource":this.audience},n.headers).forEach((e,t)=>r.push({key:t,value:e})),encodeURIComponent(JSON.stringify({url:n.url,method:n.method,headers:r}))}},l={_:`https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15`};o(c,`AWS_EC2_METADATA_IPV4_ADDRESS`,`169.254.169.254`),o(c,`AWS_EC2_METADATA_IPV6_ADDRESS`,`fd00:ec2::254`),e.AwsClient=c})),Ye=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.InvalidSubjectTokenError=e.InvalidMessageFieldError=e.InvalidCodeFieldError=e.InvalidTokenTypeFieldError=e.InvalidExpirationTimeFieldError=e.InvalidSuccessFieldError=e.InvalidVersionFieldError=e.ExecutableResponseError=e.ExecutableResponse=void 0;var t=`urn:ietf:params:oauth:token-type:saml2`,n=`urn:ietf:params:oauth:token-type:id_token`,r=`urn:ietf:params:oauth:token-type:jwt`;e.ExecutableResponse=class{constructor(e){if(o(this,`version`,void 0),o(this,`success`,void 0),o(this,`expirationTime`,void 0),o(this,`tokenType`,void 0),o(this,`errorCode`,void 0),o(this,`errorMessage`,void 0),o(this,`subjectToken`,void 0),!e.version)throw new s(`Executable response must contain a 'version' field.`);if(e.success===void 0)throw new c(`Executable response must contain a 'success' field.`);if(this.version=e.version,this.success=e.success,this.success){if(this.expirationTime=e.expiration_time,this.tokenType=e.token_type,this.tokenType!==t&&this.tokenType!==n&&this.tokenType!==r)throw new l(`Executable response must contain a 'token_type' field when successful and it must be one of ${n}, ${r}, or ${t}.`);if(this.tokenType===t){if(!e.saml_response)throw new f(`Executable response must contain a 'saml_response' field when token_type=${t}.`);this.subjectToken=e.saml_response}else{if(!e.id_token)throw new f(`Executable response must contain a 'id_token' field when token_type=${n} or ${r}.`);this.subjectToken=e.id_token}}else{if(!e.code)throw new u(`Executable response must contain a 'code' field when unsuccessful.`);if(!e.message)throw new d(`Executable response must contain a 'message' field when unsuccessful.`);this.errorCode=e.code,this.errorMessage=e.message}}isValid(){return!this.isExpired()&&this.success}isExpired(){return this.expirationTime!==void 0&&this.expirationTime<Math.round(Date.now()/1e3)}};var i=class extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}};e.ExecutableResponseError=i;var s=class extends i{};e.InvalidVersionFieldError=s;var c=class extends i{};e.InvalidSuccessFieldError=c,e.InvalidExpirationTimeFieldError=class extends i{};var l=class extends i{};e.InvalidTokenTypeFieldError=l;var u=class extends i{};e.InvalidCodeFieldError=u;var d=class extends i{};e.InvalidMessageFieldError=d;var f=class extends i{};e.InvalidSubjectTokenError=f})),Xe=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.PluggableAuthHandler=e.ExecutableError=void 0;var n=Ye(),r=t(`child_process`),i=t(`fs`),s=class extends Error{constructor(e,t){super(`The executable failed with exit code: ${t} and error message: ${e}.`),o(this,`code`,void 0),this.code=t,Object.setPrototypeOf(this,new.target.prototype)}};e.ExecutableError=s,e.PluggableAuthHandler=class e{constructor(t){if(o(this,`commandComponents`,void 0),o(this,`timeoutMillis`,void 0),o(this,`outputFile`,void 0),!t.command)throw Error(`No command provided.`);if(this.commandComponents=e.parseCommand(t.command),this.timeoutMillis=t.timeoutMillis,!this.timeoutMillis)throw Error(`No timeoutMillis provided.`);this.outputFile=t.outputFile}retrieveResponseFromExecutable(e){return new Promise((t,i)=>{let a=r.spawn(this.commandComponents[0],this.commandComponents.slice(1),{env:{...process.env,...Object.fromEntries(e)}}),o=``;a.stdout.on(`data`,e=>{o+=e}),a.stderr.on(`data`,e=>{o+=e});let c=setTimeout(()=>(a.removeAllListeners(),a.kill(),i(Error(`The executable failed to finish within the timeout specified.`))),this.timeoutMillis);a.on(`close`,e=>{if(clearTimeout(c),e===0)try{let e=JSON.parse(o);return t(new n.ExecutableResponse(e))}catch(e){return e instanceof n.ExecutableResponseError?i(e):i(new n.ExecutableResponseError(`The executable returned an invalid response: ${o}`))}else return i(new s(o,e.toString()))})})}async retrieveCachedResponse(){if(!this.outputFile||this.outputFile.length===0)return;let e;try{e=await i.promises.realpath(this.outputFile)}catch{return}if(!(await i.promises.lstat(e)).isFile())return;let t=await i.promises.readFile(e,{encoding:`utf8`});if(t!==``)try{let e=JSON.parse(t);return new n.ExecutableResponse(e).isValid()?new n.ExecutableResponse(e):void 0}catch(e){throw e instanceof n.ExecutableResponseError?e:new n.ExecutableResponseError(`The output file contained an invalid response: ${t}`)}}static parseCommand(e){let t=e.match(/(?:[^\s"]+|"[^"]*")+/g);if(!t)throw Error(`Provided command: "${e}" could not be parsed.`);for(let e=0;e<t.length;e++)t[e][0]===`"`&&t[e].slice(-1)===`"`&&(t[e]=t[e].slice(1,-1));return t}}})),Ze=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.PluggableAuthClient=e.ExecutableError=void 0;var t=$(),n=Ye(),r=Xe(),i=Xe();Object.defineProperty(e,`ExecutableError`,{enumerable:!0,get:function(){return i.ExecutableError}});var s=30*1e3,c=5*1e3,l=120*1e3,u=`GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES`,d=1;e.PluggableAuthClient=class extends t.BaseExternalAccountClient{constructor(e){if(super(e),o(this,`command`,void 0),o(this,`timeoutMillis`,void 0),o(this,`outputFile`,void 0),o(this,`handler`,void 0),!e.credential_source.executable||(this.command=e.credential_source.executable.command,!this.command))throw Error(`No valid Pluggable Auth "credential_source" provided.`);if(e.credential_source.executable.timeout_millis===void 0)this.timeoutMillis=s;else if(this.timeoutMillis=e.credential_source.executable.timeout_millis,this.timeoutMillis<c||this.timeoutMillis>l)throw Error(`Timeout must be between ${c} and ${l} milliseconds.`);this.outputFile=e.credential_source.executable.output_file,this.handler=new r.PluggableAuthHandler({command:this.command,timeoutMillis:this.timeoutMillis,outputFile:this.outputFile}),this.credentialSourceType=`executable`}async retrieveSubjectToken(){if(process.env[u]!==`1`)throw Error(`Pluggable Auth executables need to be explicitly allowed to run by setting the GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES environment Variable to 1.`);let e;if(this.outputFile&&(e=await this.handler.retrieveCachedResponse()),!e){let t=new Map;t.set(`GOOGLE_EXTERNAL_ACCOUNT_AUDIENCE`,this.audience),t.set(`GOOGLE_EXTERNAL_ACCOUNT_TOKEN_TYPE`,this.subjectTokenType),t.set(`GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE`,`0`),this.outputFile&&t.set(`GOOGLE_EXTERNAL_ACCOUNT_OUTPUT_FILE`,this.outputFile);let n=this.getServiceAccountEmail();n&&t.set(`GOOGLE_EXTERNAL_ACCOUNT_IMPERSONATED_EMAIL`,n),e=await this.handler.retrieveResponseFromExecutable(t)}if(e.version>d)throw Error(`Version of executable is not currently supported, maximum supported version is ${d}.`);if(!e.success)throw new r.ExecutableError(e.errorMessage,e.errorCode);if(this.outputFile&&!e.expirationTime)throw new n.InvalidExpirationTimeFieldError("The executable response must contain the `expiration_time` field for successful responses when an output_file has been specified in the configuration.");if(e.isExpired())throw Error(`Executable response is expired.`);return e.subjectToken}}})),Qe=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ExternalAccountClient=void 0;var t=$(),n=Ge(),r=Je(),i=Ze();e.ExternalAccountClient=class{constructor(){throw Error(`ExternalAccountClients should be initialized via: ExternalAccountClient.fromJSON(), directly via explicit constructors, eg. new AwsClient(options), new IdentityPoolClient(options), newPluggableAuthClientOptions, or via new GoogleAuth(options).getClient()`)}static fromJSON(e){return e&&e.type===t.EXTERNAL_ACCOUNT_TYPE?e.credential_source?.environment_id?new r.AwsClient(e):e.credential_source?.executable?new i.PluggableAuthClient(e):new n.IdentityPoolClient(e):null}}})),$e=i((e=>{c(),d(),l(),a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.ExternalAccountAuthorizedUserClient=e.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=void 0;var n=Z(),r=Be(),i=z(),s=t(`stream`),u=$();e.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=`external_account_authorized_user`;var f=`https://sts.{universeDomain}/v1/oauthtoken`,g=new WeakMap,_=class e extends r.OAuthClientAuthHandler{constructor(e){super(e),m(this,g,void 0),h(g,this,e.tokenRefreshEndpoint)}async refreshToken(t,a){let o={...e.RETRY_CONFIG,url:p(g,this),method:`POST`,headers:a,data:new URLSearchParams({grant_type:`refresh_token`,refresh_token:t}),responseType:`json`};n.AuthClient.setMethodName(o,`refreshToken`),this.applyClientAuthenticationOptions(o);try{let e=await this.transporter.request(o),t=e.data;return t.res=e,t}catch(e){throw e instanceof i.GaxiosError&&e.response?(0,r.getErrorFromOAuthErrorResponse)(e.response.data,e):e}}};e.ExternalAccountAuthorizedUserClient=class extends n.AuthClient{constructor(e){super(e),o(this,`cachedAccessToken`,void 0),o(this,`externalAccountAuthorizedUserHandler`,void 0),o(this,`refreshToken`,void 0),e.universe_domain&&(this.universeDomain=e.universe_domain),this.refreshToken=e.refresh_token;let t={confidentialClientType:`basic`,clientId:e.client_id,clientSecret:e.client_secret};this.externalAccountAuthorizedUserHandler=new _({tokenRefreshEndpoint:e.token_url??f.replace(`{universeDomain}`,this.universeDomain),transporter:this.transporter,clientAuthentication:t}),this.cachedAccessToken=null,this.quotaProjectId=e.quota_project_id,typeof e?.eagerRefreshThresholdMillis==`number`?this.eagerRefreshThresholdMillis=e.eagerRefreshThresholdMillis:this.eagerRefreshThresholdMillis=u.EXPIRATION_TIME_OFFSET,this.forceRefreshOnFailure=!!e?.forceRefreshOnFailure}async getAccessToken(){return(!this.cachedAccessToken||this.isExpired(this.cachedAccessToken))&&await this.refreshAccessTokenAsync(),{token:this.cachedAccessToken.access_token,res:this.cachedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(t)this.requestAsync(e).then(e=>t(null,e),e=>t(e,e.response));else return this.requestAsync(e)}async requestAsync(e,t=!1){let n;try{let t=await this.getRequestHeaders();e.headers=i.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,t),n=await this.transporter.request(e)}catch(n){let r=n.response;if(r){let n=r.status,i=r.config.data instanceof s.Readable;if(!t&&(n===401||n===403)&&!i&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return n}async refreshAccessTokenAsync(){let e=await this.externalAccountAuthorizedUserHandler.refreshToken(this.refreshToken);return this.cachedAccessToken={access_token:e.access_token,expiry_date:new Date().getTime()+e.expires_in*1e3,res:e.res},e.refresh_token!==void 0&&(this.refreshToken=e.refresh_token),this.cachedAccessToken}isExpired(e){let t=new Date().getTime();return e.expiry_date?t>=e.expiry_date-this.eagerRefreshThresholdMillis:!1}}})),et=i((e=>{g(),a(),c(),f(),d(),l(),Object.defineProperty(e,`__esModule`,{value:!0}),e.GoogleAuth=e.GoogleAuthExceptionMessages=void 0;var n=t(`child_process`),r=t(`fs`),i=z(),_=B(),v=t(`os`),y=t(`path`),b=V(),x=Ee(),S=De(),C=Oe(),w=Le(),T=Re(),E=ze(),D=Qe(),O=$(),k=Z(),A=$e(),j=H();e.GoogleAuthExceptionMessages={API_KEY_WITH_CREDENTIALS:`API Keys and Credentials are mutually exclusive authentication methods and cannot be used together.`,NO_PROJECT_ID_FOUND:`Unable to detect a Project Id in the current environment.
|
|
4
|
+
To learn more about authentication and Google APIs, visit:
|
|
5
|
+
https://cloud.google.com/docs/authentication/getting-started`,NO_CREDENTIALS_FOUND:`Unable to find credentials in current environment.
|
|
6
|
+
To learn more about authentication and Google APIs, visit:
|
|
7
|
+
https://cloud.google.com/docs/authentication/getting-started`,NO_ADC_FOUND:`Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.`,NO_UNIVERSE_DOMAIN_FOUND:`Unable to detect a Universe Domain in the current environment.
|
|
8
|
+
To learn more about Universe Domain retrieval, visit:
|
|
9
|
+
https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys`};var M=new WeakMap,N=new WeakSet,P=class{get isGCE(){return this.checkIsGCE}constructor(t={}){if(u(this,N),o(this,`checkIsGCE`,void 0),o(this,`useJWTAccessWithScope`,void 0),o(this,`defaultServicePath`,void 0),o(this,`_findProjectIdPromise`,void 0),o(this,`_cachedProjectId`,void 0),o(this,`jsonContent`,null),o(this,`apiKey`,void 0),o(this,`cachedCredential`,null),m(this,M,null),o(this,`defaultScopes`,void 0),o(this,`keyFilename`,void 0),o(this,`scopes`,void 0),o(this,`clientOptions`,{}),this._cachedProjectId=t.projectId||null,this.cachedCredential=t.authClient||null,this.keyFilename=t.keyFilename||t.keyFile,this.scopes=t.scopes,this.clientOptions=t.clientOptions||{},this.jsonContent=t.credentials||null,this.apiKey=t.apiKey||this.clientOptions.apiKey||null,this.apiKey&&(this.jsonContent||this.clientOptions.credentials))throw RangeError(e.GoogleAuthExceptionMessages.API_KEY_WITH_CREDENTIALS);t.universeDomain&&(this.clientOptions.universeDomain=t.universeDomain)}setGapicJWTValues(e){e.defaultServicePath=this.defaultServicePath,e.useJWTAccessWithScope=this.useJWTAccessWithScope,e.defaultScopes=this.defaultScopes}getProjectId(e){if(e)this.getProjectIdAsync().then(t=>e(null,t),e);else return this.getProjectIdAsync()}async getProjectIdOptional(){try{return await this.getProjectId()}catch(t){if(t instanceof Error&&t.message===e.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)return null;throw t}}async findAndCacheProjectId(){let t=null;if(t||(t=await this.getProductionProjectId()),t||(t=await this.getFileProjectId()),t||(t=await this.getDefaultServiceProjectId()),t||(t=await this.getGCEProjectId()),t||(t=await this.getExternalAccountClientProjectId()),t)return this._cachedProjectId=t,t;throw Error(e.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)}async getProjectIdAsync(){return this._cachedProjectId?this._cachedProjectId:(this._findProjectIdPromise||(this._findProjectIdPromise=this.findAndCacheProjectId()),this._findProjectIdPromise)}async getUniverseDomainFromMetadataServer(){let e;try{e=await _.universe(`universe-domain`),e||(e=k.DEFAULT_UNIVERSE)}catch(t){if(t&&t?.response?.status===404)e=k.DEFAULT_UNIVERSE;else throw t}return e}async getUniverseDomain(){let e=(0,j.originalOrCamelOptions)(this.clientOptions).get(`universe_domain`);try{e??(e=(await this.getClient()).universeDomain)}catch{e??(e=k.DEFAULT_UNIVERSE)}return e}getAnyScopes(){return this.scopes||this.defaultScopes}getApplicationDefault(e={},t){let n;if(typeof e==`function`?t=e:n=e,t)this.getApplicationDefaultAsync(n).then(e=>t(null,e.credential,e.projectId),t);else return this.getApplicationDefaultAsync(n)}async getApplicationDefaultAsync(t={}){if(this.cachedCredential)return await s(N,this,F).call(this,this.cachedCredential,null);let n;if(n=await this._tryGetApplicationCredentialsFromEnvironmentVariable(t),n||(n=await this._tryGetApplicationCredentialsFromWellKnownFile(t),n))return n instanceof w.JWT?n.scopes=this.scopes:n instanceof O.BaseExternalAccountClient&&(n.scopes=this.getAnyScopes()),await s(N,this,F).call(this,n);if(await this._checkIsGCE())return t.scopes=this.getAnyScopes(),await s(N,this,F).call(this,new x.Compute(t));throw Error(e.GoogleAuthExceptionMessages.NO_ADC_FOUND)}async _checkIsGCE(){return this.checkIsGCE===void 0&&(this.checkIsGCE=_.getGCPResidency()||await _.isAvailable()),this.checkIsGCE}async _tryGetApplicationCredentialsFromEnvironmentVariable(e){let t=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials;if(!t||t.length===0)return null;try{return this._getApplicationCredentialsFromFilePath(t,e)}catch(e){throw e instanceof Error&&(e.message=`Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable: ${e.message}`),e}}async _tryGetApplicationCredentialsFromWellKnownFile(e){let t=null;if(this._isWindows())t=process.env.APPDATA;else{let e=process.env.HOME;e&&(t=y.join(e,`.config`))}return t&&(t=y.join(t,`gcloud`,`application_default_credentials.json`),r.existsSync(t)||(t=null)),t?await this._getApplicationCredentialsFromFilePath(t,e):null}async _getApplicationCredentialsFromFilePath(e,t={}){if(!e||e.length===0)throw Error(`The file path is invalid.`);try{if(e=r.realpathSync(e),!r.lstatSync(e).isFile())throw Error()}catch(t){throw t instanceof Error&&(t.message=`The file at ${e} does not exist, or it is not a file. ${t.message}`),t}let n=r.createReadStream(e);return this.fromStream(n,t)}fromImpersonatedJSON(e){if(!e)throw Error(`Must pass in a JSON object containing an impersonated refresh token`);if(e.type!==E.IMPERSONATED_ACCOUNT_TYPE)throw Error(`The incoming JSON object does not have the "${E.IMPERSONATED_ACCOUNT_TYPE}" type`);if(!e.source_credentials)throw Error(`The incoming JSON object does not contain a source_credentials field`);if(!e.service_account_impersonation_url)throw Error(`The incoming JSON object does not contain a service_account_impersonation_url field`);let t=this.fromJSON(e.source_credentials);if(e.service_account_impersonation_url?.length>256)throw RangeError(`Target principal is too long: ${e.service_account_impersonation_url}`);let n=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(e.service_account_impersonation_url)?.groups?.target;if(!n)throw RangeError(`Cannot extract target principal from ${e.service_account_impersonation_url}`);let r=(this.scopes||e.scopes||this.defaultScopes)??[];return new E.Impersonated({...e,sourceClient:t,targetPrincipal:n,targetScopes:Array.isArray(r)?r:[r]})}fromJSON(e,t={}){let n,r=(0,j.originalOrCamelOptions)(t).get(`universe_domain`);return e.type===T.USER_REFRESH_ACCOUNT_TYPE?(n=new T.UserRefreshClient(t),n.fromJSON(e)):e.type===E.IMPERSONATED_ACCOUNT_TYPE?n=this.fromImpersonatedJSON(e):e.type===O.EXTERNAL_ACCOUNT_TYPE?(n=D.ExternalAccountClient.fromJSON({...e,...t}),n.scopes=this.getAnyScopes()):e.type===A.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE?n=new A.ExternalAccountAuthorizedUserClient({...e,...t}):(t.scopes=this.scopes,n=new w.JWT(t),this.setGapicJWTValues(n),n.fromJSON(e)),r&&(n.universeDomain=r),n}_cacheClientFromJSON(e,t){let n=this.fromJSON(e,t);return this.jsonContent=e,this.cachedCredential=n,n}fromStream(e,t={},n){let r={};if(typeof t==`function`?n=t:r=t,n)this.fromStreamAsync(e,r).then(e=>n(null,e),n);else return this.fromStreamAsync(e,r)}fromStreamAsync(e,t){return new Promise((n,r)=>{if(!e)throw Error(`Must pass in a stream containing the Google auth settings.`);let i=[];e.setEncoding(`utf8`).on(`error`,r).on(`data`,e=>i.push(e)).on(`end`,()=>{try{try{let e=JSON.parse(i.join(``));return n(this._cacheClientFromJSON(e,t))}catch(e){if(!this.keyFilename)throw e;let t=new w.JWT({...this.clientOptions,keyFile:this.keyFilename});return this.cachedCredential=t,this.setGapicJWTValues(t),n(t)}}catch(e){return r(e)}})})}fromAPIKey(e,t={}){return new w.JWT({...t,apiKey:e})}_isWindows(){let e=v.platform();return!!(e&&e.length>=3&&e.substring(0,3).toLowerCase()===`win`)}async getDefaultServiceProjectId(){return new Promise(e=>{(0,n.exec)(`gcloud config config-helper --format json`,(t,n)=>{if(!t&&n)try{let t=JSON.parse(n).configuration.properties.core.project;e(t);return}catch{}e(null)})})}getProductionProjectId(){return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project}async getFileProjectId(){if(this.cachedCredential)return this.cachedCredential.projectId;if(this.keyFilename){let e=await this.getClient();if(e&&e.projectId)return e.projectId}let e=await this._tryGetApplicationCredentialsFromEnvironmentVariable();return e?e.projectId:null}async getExternalAccountClientProjectId(){return!this.jsonContent||this.jsonContent.type!==O.EXTERNAL_ACCOUNT_TYPE?null:await(await this.getClient()).getProjectId()}async getGCEProjectId(){try{return await _.project(`project-id`)}catch{return null}}getCredentials(e){if(e)this.getCredentialsAsync().then(t=>e(null,t),e);else return this.getCredentialsAsync()}async getCredentialsAsync(){let t=await this.getClient();if(t instanceof E.Impersonated)return{client_email:t.getTargetPrincipal()};if(t instanceof O.BaseExternalAccountClient){let e=t.getServiceAccountEmail();if(e)return{client_email:e,universe_domain:t.universeDomain}}if(this.jsonContent)return{client_email:this.jsonContent.client_email,private_key:this.jsonContent.private_key,universe_domain:this.jsonContent.universe_domain};if(await this._checkIsGCE()){let[e,t]=await Promise.all([_.instance(`service-accounts/default/email`),this.getUniverseDomain()]);return{client_email:e,universe_domain:t}}throw Error(e.GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND)}async getClient(){if(this.cachedCredential)return this.cachedCredential;h(M,this,p(M,this)||s(N,this,I).call(this));try{return await p(M,this)}finally{h(M,this,null)}}async getIdTokenClient(e){let t=await this.getClient();if(!(`fetchIdToken`in t))throw Error(`Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.`);return new S.IdTokenClient({targetAudience:e,idTokenProvider:t})}async getAccessToken(){return(await(await this.getClient()).getAccessToken()).token}async getRequestHeaders(e){return(await this.getClient()).getRequestHeaders(e)}async authorizeRequest(e={}){let t=e.url,n=await(await this.getClient()).getRequestHeaders(t);return e.headers=i.Gaxios.mergeHeaders(e.headers,n),e}async fetch(...e){return(await this.getClient()).fetch(...e)}async request(e){return(await this.getClient()).request(e)}getEnv(){return(0,C.getEnv)()}async sign(e,t){let n=await this.getClient(),r=await this.getUniverseDomain();if(t=t||`https://iamcredentials.${r}/v1/projects/-/serviceAccounts/`,n instanceof E.Impersonated)return(await n.sign(e)).signedBlob;let i=(0,b.createCrypto)();if(n instanceof w.JWT&&n.key)return await i.sign(n.key,e);let a=await this.getCredentials();if(!a.client_email)throw Error("Cannot sign data without `client_email`.");return this.signBlob(i,a.client_email,e,t)}async signBlob(e,t,n,r){let i=new URL(r+`${t}:signBlob`);return(await this.request({method:`POST`,url:i.href,data:{payload:e.encodeBase64StringUtf8(n)},retry:!0,retryConfig:{httpMethodsToRetry:[`POST`]}})).data.signedBlob}};async function F(e,t=process.env.GOOGLE_CLOUD_QUOTA_PROJECT||null){let n=await this.getProjectIdOptional();return t&&(e.quotaProjectId=t),this.cachedCredential=e,{credential:e,projectId:n}}async function I(){if(this.jsonContent)return this._cacheClientFromJSON(this.jsonContent,this.clientOptions);if(this.keyFilename){let e=y.resolve(this.keyFilename),t=r.createReadStream(e);return await this.fromStreamAsync(t,this.clientOptions)}else if(this.apiKey){let e=await this.fromAPIKey(this.apiKey,this.clientOptions);e.scopes=this.scopes;let{credential:t}=await s(N,this,F).call(this,e);return t}else{let{credential:e}=await this.getApplicationDefaultAsync(this.clientOptions);return e}}e.GoogleAuth=P})),tt=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.IAMAuth=void 0,e.IAMAuth=class{constructor(e,t){o(this,`selector`,void 0),o(this,`token`,void 0),this.selector=e,this.token=t,this.selector=e,this.token=t}getRequestHeaders(){return{"x-goog-iam-authority-selector":this.selector,"x-goog-iam-authorization-token":this.token}}}})),nt=i((e=>{a(),Object.defineProperty(e,`__esModule`,{value:!0}),e.DownscopedClient=e.EXPIRATION_TIME_OFFSET=e.MAX_ACCESS_BOUNDARY_RULES_COUNT=void 0;var n=z(),r=t(`stream`),i=Z(),s=Ve(),c=`urn:ietf:params:oauth:grant-type:token-exchange`,l=`urn:ietf:params:oauth:token-type:access_token`,u=`urn:ietf:params:oauth:token-type:access_token`;e.MAX_ACCESS_BOUNDARY_RULES_COUNT=10,e.EXPIRATION_TIME_OFFSET=300*1e3,e.DownscopedClient=class extends i.AuthClient{constructor(t,n={accessBoundary:{accessBoundaryRules:[]}}){if(super(t instanceof i.AuthClient?{}:t),o(this,`authClient`,void 0),o(this,`credentialAccessBoundary`,void 0),o(this,`cachedDownscopedAccessToken`,void 0),o(this,`stsCredential`,void 0),t instanceof i.AuthClient?(this.authClient=t,this.credentialAccessBoundary=n):(this.authClient=t.authClient,this.credentialAccessBoundary=t.credentialAccessBoundary),this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length===0)throw Error(`At least one access boundary rule needs to be defined.`);if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length>e.MAX_ACCESS_BOUNDARY_RULES_COUNT)throw Error(`The provided access boundary has more than ${e.MAX_ACCESS_BOUNDARY_RULES_COUNT} access boundary rules.`);for(let e of this.credentialAccessBoundary.accessBoundary.accessBoundaryRules)if(e.availablePermissions.length===0)throw Error(`At least one permission should be defined in access boundary rules.`);this.stsCredential=new s.StsCredentials({tokenExchangeEndpoint:`https://sts.${this.universeDomain}/v1/token`}),this.cachedDownscopedAccessToken=null}setCredentials(e){if(!e.expiry_date)throw Error(`The access token expiry_date field is missing in the provided credentials.`);super.setCredentials(e),this.cachedDownscopedAccessToken=e}async getAccessToken(){return(!this.cachedDownscopedAccessToken||this.isExpired(this.cachedDownscopedAccessToken))&&await this.refreshAccessTokenAsync(),{token:this.cachedDownscopedAccessToken.access_token,expirationTime:this.cachedDownscopedAccessToken.expiry_date,res:this.cachedDownscopedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(t)this.requestAsync(e).then(e=>t(null,e),e=>t(e,e.response));else return this.requestAsync(e)}async requestAsync(e,t=!1){let i;try{let t=await this.getRequestHeaders();e.headers=n.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,t),i=await this.transporter.request(e)}catch(n){let i=n.response;if(i){let n=i.status,a=i.config.data instanceof r.Readable;if(!t&&(n===401||n===403)&&!a&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return i}async refreshAccessTokenAsync(){let e={grantType:c,requestedTokenType:l,subjectToken:(await this.authClient.getAccessToken()).token,subjectTokenType:u},t=await this.stsCredential.exchangeToken(e,void 0,this.credentialAccessBoundary),n=this.authClient.credentials?.expiry_date||null,r=t.expires_in?new Date().getTime()+t.expires_in*1e3:n;return this.cachedDownscopedAccessToken={access_token:t.access_token,expiry_date:r,res:t.res},this.credentials={},Object.assign(this.credentials,this.cachedDownscopedAccessToken),delete this.credentials.res,this.emit(`tokens`,{refresh_token:null,expiry_date:this.cachedDownscopedAccessToken.expiry_date,access_token:this.cachedDownscopedAccessToken.access_token,token_type:`Bearer`,id_token:null}),this.cachedDownscopedAccessToken}isExpired(e){let t=new Date().getTime();return e.expiry_date?t>=e.expiry_date-this.eagerRefreshThresholdMillis:!1}}})),rt=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.PassThroughClient=void 0;var t=Z();e.PassThroughClient=class extends t.AuthClient{async request(e){return this.transporter.request(e)}async getAccessToken(){return{}}async getRequestHeaders(){return new Headers}}})),it=i((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.GoogleAuth=e.auth=e.PassThroughClient=e.ExternalAccountAuthorizedUserClient=e.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=e.ExecutableError=e.PluggableAuthClient=e.DownscopedClient=e.BaseExternalAccountClient=e.ExternalAccountClient=e.IdentityPoolClient=e.AwsRequestSigner=e.AwsClient=e.UserRefreshClient=e.LoginTicket=e.ClientAuthentication=e.OAuth2Client=e.CodeChallengeMethod=e.Impersonated=e.JWT=e.JWTAccess=e.IdTokenClient=e.IAMAuth=e.GCPEnv=e.Compute=e.DEFAULT_UNIVERSE=e.AuthClient=e.gaxios=e.gcpMetadata=void 0;var r=et();Object.defineProperty(e,`GoogleAuth`,{enumerable:!0,get:function(){return r.GoogleAuth}}),e.gcpMetadata=B(),e.gaxios=z();var i=Z();Object.defineProperty(e,`AuthClient`,{enumerable:!0,get:function(){return i.AuthClient}}),Object.defineProperty(e,`DEFAULT_UNIVERSE`,{enumerable:!0,get:function(){return i.DEFAULT_UNIVERSE}});var a=Ee();Object.defineProperty(e,`Compute`,{enumerable:!0,get:function(){return a.Compute}});var o=Oe();Object.defineProperty(e,`GCPEnv`,{enumerable:!0,get:function(){return o.GCPEnv}});var s=tt();Object.defineProperty(e,`IAMAuth`,{enumerable:!0,get:function(){return s.IAMAuth}});var c=De();Object.defineProperty(e,`IdTokenClient`,{enumerable:!0,get:function(){return c.IdTokenClient}});var l=Ie();Object.defineProperty(e,`JWTAccess`,{enumerable:!0,get:function(){return l.JWTAccess}});var u=Le();Object.defineProperty(e,`JWT`,{enumerable:!0,get:function(){return u.JWT}});var d=ze();Object.defineProperty(e,`Impersonated`,{enumerable:!0,get:function(){return d.Impersonated}});var f=Q();Object.defineProperty(e,`CodeChallengeMethod`,{enumerable:!0,get:function(){return f.CodeChallengeMethod}}),Object.defineProperty(e,`OAuth2Client`,{enumerable:!0,get:function(){return f.OAuth2Client}}),Object.defineProperty(e,`ClientAuthentication`,{enumerable:!0,get:function(){return f.ClientAuthentication}});var p=Te();Object.defineProperty(e,`LoginTicket`,{enumerable:!0,get:function(){return p.LoginTicket}});var m=Re();Object.defineProperty(e,`UserRefreshClient`,{enumerable:!0,get:function(){return m.UserRefreshClient}});var h=Je();Object.defineProperty(e,`AwsClient`,{enumerable:!0,get:function(){return h.AwsClient}});var g=Ke();Object.defineProperty(e,`AwsRequestSigner`,{enumerable:!0,get:function(){return g.AwsRequestSigner}});var _=Ge();Object.defineProperty(e,`IdentityPoolClient`,{enumerable:!0,get:function(){return _.IdentityPoolClient}});var v=Qe();Object.defineProperty(e,`ExternalAccountClient`,{enumerable:!0,get:function(){return v.ExternalAccountClient}});var y=$();Object.defineProperty(e,`BaseExternalAccountClient`,{enumerable:!0,get:function(){return y.BaseExternalAccountClient}});var b=nt();Object.defineProperty(e,`DownscopedClient`,{enumerable:!0,get:function(){return b.DownscopedClient}});var x=Ze();Object.defineProperty(e,`PluggableAuthClient`,{enumerable:!0,get:function(){return x.PluggableAuthClient}}),Object.defineProperty(e,`ExecutableError`,{enumerable:!0,get:function(){return x.ExecutableError}});var S=$e();Object.defineProperty(e,`EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE`,{enumerable:!0,get:function(){return S.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE}}),Object.defineProperty(e,`ExternalAccountAuthorizedUserClient`,{enumerable:!0,get:function(){return S.ExternalAccountAuthorizedUserClient}});var C=rt();Object.defineProperty(e,`PassThroughClient`,{enumerable:!0,get:function(){return C.PassThroughClient}}),n(Fe(),e),e.auth=new r.GoogleAuth}));export default it();export{};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e,i as t,t as n}from"./chunk-DR8-3Aex.js";import{n as r,t as i}from"./defineProperty-CaCI0a5T.js";import{n as a,t as o}from"./esm-BwzC0MQp.js";import{A as s,c,j as l,s as u}from"./esm-BtC6CMmM.js";import{n as d,t as f}from"./esm-CcWquv5a.js";var p=n((t=>{r(),Object.defineProperty(t,`__esModule`,{value:!0}),t.PrometheusSerializer=void 0;var n=(a(),e(o)),p=(d(),e(f)),m=(c(),e(u)),h=(l(),e(s)),g=`otel.scope.schema_url`;function _(e){return e.replace(/\\/g,`\\\\`).replace(/\n/g,`\\n`)}function v(e=``){return typeof e!=`string`&&(e=JSON.stringify(e)),_(e).replace(/"/g,`\\"`)}var y=/[^a-z0-9_]/gi,b=/_{2,}/g;function x(e){return e.replace(y,`_`).replace(b,`_`)}function S(e,t){return!e.endsWith(`_total`)&&t.dataPointType===p.DataPointType.SUM&&t.isMonotonic&&(e+=`_total`),e}function C(e){return e===1/0?`+Inf`:e===-1/0?`-Inf`:`${e}`}function w(e){switch(e.dataPointType){case p.DataPointType.SUM:return e.isMonotonic?`counter`:`gauge`;case p.DataPointType.GAUGE:return`gauge`;case p.DataPointType.HISTOGRAM:return`histogram`;default:return`untyped`}}function T(e,t,n,r,i){let a=!1,o=``;for(let[e,n]of Object.entries(t)){let t=x(e);a=!0,o+=`${o.length>0?`,`:``}${t}="${v(n)}"`}if(i)for(let[e,t]of Object.entries(i)){let n=x(e);a=!0,o+=`${o.length>0?`,`:``}${n}="${v(t)}"`}return a&&(e+=`{${o}}`),`${e} ${C(n)}${r===void 0?``:` `+String(r)}\n`}var E=`# no registered metrics`;t.PrometheusSerializer=class{constructor(e,t=!1,n,r,a){i(this,`_prefix`,void 0),i(this,`_appendTimestamp`,void 0),i(this,`_additionalAttributes`,void 0),i(this,`_withResourceConstantLabels`,void 0),i(this,`_withoutScopeInfo`,void 0),i(this,`_withoutTargetInfo`,void 0),e&&(this._prefix=e+`_`),this._appendTimestamp=t,this._withResourceConstantLabels=n,this._withoutScopeInfo=!!a,this._withoutTargetInfo=!!r}serialize(e){let t=``;this._additionalAttributes=this._filterResourceConstantLabels(e.resource.attributes,this._withResourceConstantLabels);for(let n of e.scopeMetrics)t+=this._serializeScopeMetrics(n);return t===``&&(t+=E),this._serializeResource(e.resource)+t}_filterResourceConstantLabels(e,t){if(t){let n={};for(let[r,i]of Object.entries(e))r.match(t)&&(n[r]=i);return n}}_serializeScopeMetrics(e){let t=``;for(let n of e.metrics)t+=this._serializeMetricData(n,e.scope)+`
|
|
2
|
+
`;return t}_serializeMetricData(e,t){let r=x(_(e.descriptor.name));this._prefix&&(r=`${this._prefix}${r}`);let i=e.dataPointType;r=S(r,e);let a=`# HELP ${r} ${_(e.descriptor.description||`description missing`)}`,o=e.descriptor.unit?`\n# UNIT ${r} ${_(e.descriptor.unit)}`:``,s=`# TYPE ${r} ${w(e)}`,c;if(this._withoutScopeInfo)c=this._additionalAttributes;else{let e={[h.ATTR_OTEL_SCOPE_NAME]:t.name};t.schemaUrl&&(e[g]=t.schemaUrl),t.version&&(e[h.ATTR_OTEL_SCOPE_VERSION]=t.version),c=Object.assign(e,this._additionalAttributes)}let l=``;switch(i){case p.DataPointType.SUM:case p.DataPointType.GAUGE:l=e.dataPoints.map(t=>this._serializeSingularDataPoint(r,e,t,c)).join(``);break;case p.DataPointType.HISTOGRAM:l=e.dataPoints.map(t=>this._serializeHistogramDataPoint(r,e,t,c)).join(``);break;default:n.diag.error(`Unrecognizable DataPointType: ${i} for metric "${r}"`)}return`${a}${o}\n${s}\n${l}`.trim()}_serializeSingularDataPoint(e,t,n,r){let i=``;e=S(e,t);let{value:a,attributes:o}=n,s=(0,m.hrTimeToMilliseconds)(n.endTime);return i+=T(e,o,a,this._appendTimestamp?s:void 0,r),i}_serializeHistogramDataPoint(e,t,n,r){let i=``;e=S(e,t);let a=n.attributes,o=n.value,s=(0,m.hrTimeToMilliseconds)(n.endTime);for(let t of[`count`,`sum`]){let n=o[t];n!=null&&(i+=T(e+`_`+t,a,n,this._appendTimestamp?s:void 0,r))}let c=0,l=o.buckets.counts.entries(),u=!1;for(let[t,n]of l){c+=n;let l=o.buckets.boundaries[t];if(l===void 0&&u)break;l===1/0&&(u=!0),i+=T(e+`_bucket`,a,c,this._appendTimestamp?s:void 0,Object.assign({},r,{le:l===void 0||l===1/0?`+Inf`:String(l)}))}return i}_serializeResource(e){if(this._withoutTargetInfo===!0)return``;let t=`target_info`;return`${`# HELP ${t} Target metadata`}\n${`# TYPE ${t} gauge`}\n${T(t,e.attributes,1).trim()}\n`}}})),m=n((n=>{r(),Object.defineProperty(n,`__esModule`,{value:!0}),n.PrometheusExporter=void 0;var s=(a(),e(o)),l=(c(),e(u)),m=(d(),e(f)),h=t(`http`),g=p(),_=t(`url`),v=class e extends m.MetricReader{constructor(t={},n=()=>{}){super({aggregationSelector:e=>({type:m.AggregationType.DEFAULT}),aggregationTemporalitySelector:e=>m.AggregationTemporality.CUMULATIVE,metricProducers:t.metricProducers}),i(this,`_host`,void 0),i(this,`_port`,void 0),i(this,`_baseUrl`,void 0),i(this,`_endpoint`,void 0),i(this,`_server`,void 0),i(this,`_prefix`,void 0),i(this,`_appendTimestamp`,void 0),i(this,`_serializer`,void 0),i(this,`_startServerPromise`,void 0),i(this,`_requestHandler`,(e,t)=>{e.url!=null&&new _.URL(e.url,this._baseUrl).pathname===this._endpoint?this._exportMetrics(t):this._notFound(t)}),i(this,`_exportMetrics`,e=>{e.statusCode=200,e.setHeader(`content-type`,`text/plain`),this.collect().then(t=>{let{resourceMetrics:n,errors:r}=t;r.length&&s.diag.error(`PrometheusExporter: metrics collection errors`,...r),e.end(this._serializer.serialize(n))},t=>{e.end(`# failed to export metrics: ${t}`)})}),i(this,`_notFound`,e=>{e.statusCode=404,e.end()}),this._host=t.host||process.env.OTEL_EXPORTER_PROMETHEUS_HOST||e.DEFAULT_OPTIONS.host,this._port=t.port||Number(process.env.OTEL_EXPORTER_PROMETHEUS_PORT)||e.DEFAULT_OPTIONS.port,this._prefix=t.prefix||e.DEFAULT_OPTIONS.prefix,this._appendTimestamp=typeof t.appendTimestamp==`boolean`?t.appendTimestamp:e.DEFAULT_OPTIONS.appendTimestamp;let r=t.withResourceConstantLabels||e.DEFAULT_OPTIONS.withResourceConstantLabels,a=t.withoutScopeInfo||e.DEFAULT_OPTIONS.withoutScopeInfo,o=t.withoutTargetInfo||e.DEFAULT_OPTIONS.withoutTargetInfo;this._server=(0,h.createServer)(this._requestHandler).unref(),this._serializer=new g.PrometheusSerializer(this._prefix,this._appendTimestamp,r,o,a),this._baseUrl=`http://${this._host}:${this._port}/`,this._endpoint=(t.endpoint||e.DEFAULT_OPTIONS.endpoint).replace(/^([^/])/,`/$1`),t.preventServerStart===!0?n&&queueMicrotask(n):this.startServer().then(n,e=>{s.diag.error(e),n(e)})}async onForceFlush(){}onShutdown(){return this.stopServer()}stopServer(){return this._server?new Promise(e=>{this._server.close(t=>{t?t.code!==`ERR_SERVER_NOT_RUNNING`&&(0,l.globalErrorHandler)(t):s.diag.debug(`Prometheus exporter was stopped`),e()})}):(s.diag.debug(`Prometheus stopServer() was called but server was never started.`),Promise.resolve())}startServer(){return this._startServerPromise??(this._startServerPromise=new Promise((e,t)=>{this._server.once(`error`,t),this._server.listen({port:this._port,host:this._host},()=>{s.diag.debug(`Prometheus exporter server started: ${this._host}:${this._port}/${this._endpoint}`),e()})})),this._startServerPromise}getMetricsRequestHandler(e,t){this._exportMetrics(t)}};i(v,`DEFAULT_OPTIONS`,{host:void 0,port:9464,endpoint:`/metrics`,prefix:``,appendTimestamp:!1,withResourceConstantLabels:void 0,withoutScopeInfo:!1,withoutTargetInfo:!1}),n.PrometheusExporter=v})),h=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.PrometheusSerializer=e.PrometheusExporter=void 0;var t=m();Object.defineProperty(e,`PrometheusExporter`,{enumerable:!0,get:function(){return t.PrometheusExporter}});var n=p();Object.defineProperty(e,`PrometheusSerializer`,{enumerable:!0,get:function(){return n.PrometheusSerializer}})}));export default h();export{};
|