@tencent-ai/agent-harness 0.2.0-beta.6 → 0.2.0-beta.8
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/CHANGELOG.md +42 -0
- package/cli/CHANGELOG.md +123 -0
- package/cli/dist-server/lite/in-memory-session-store.js +1 -1
- package/cli/dist-server/shared.cjs +338 -291
- package/cli/dist-server/types/node/a2a/a2a-protocol.d.ts +516 -0
- package/cli/dist-server/types/node/agent/agent-completion-waiter.d.ts +28 -0
- package/cli/dist-server/types/node/agent/agent-controller.d.ts +147 -0
- package/cli/dist-server/types/node/agent/agent-display.d.ts +77 -0
- package/cli/dist-server/types/node/agent/agent-manager.d.ts +964 -0
- package/cli/dist-server/types/node/agent/agent-memory.d.ts +72 -0
- package/cli/dist-server/types/node/agent/agent-runtime-adapter.d.ts +71 -0
- package/cli/dist-server/types/node/agent/builtin-agent-modes.d.ts +47 -0
- package/cli/dist-server/types/node/agent/custom-agent-identity.d.ts +54 -0
- package/cli/dist-server/types/node/agent/custom-agent-manager.d.ts +43 -0
- package/cli/dist-server/types/node/agent/custom-agent-path-registry.d.ts +19 -0
- package/cli/dist-server/types/node/agent/exit-planmode-visibility.d.ts +64 -0
- package/cli/dist-server/types/node/agent/index.d.ts +22 -0
- package/cli/dist-server/types/node/agent/insights-data-agent-run-interceptor.d.ts +67 -0
- package/cli/dist-server/types/node/agent/interceptors/command-interceptors.d.ts +89 -0
- package/cli/dist-server/types/node/agent/interceptors/deep-research-pending-interceptor.d.ts +30 -0
- package/cli/dist-server/types/node/agent/interceptors/env-interceptor.d.ts +7 -0
- package/cli/dist-server/types/node/agent/interceptors/file-interceptors.d.ts +45 -0
- package/cli/dist-server/types/node/agent/interceptors/image-interceptors.d.ts +47 -0
- package/cli/dist-server/types/node/agent/interceptors/index.d.ts +16 -0
- package/cli/dist-server/types/node/agent/interceptors/initial-prompt-interceptor.d.ts +29 -0
- package/cli/dist-server/types/node/agent/interceptors/manual-compact-request-handler.d.ts +29 -0
- package/cli/dist-server/types/node/agent/interceptors/model-interceptors.d.ts +43 -0
- package/cli/dist-server/types/node/agent/interceptors/sandbox-interceptor.d.ts +84 -0
- package/cli/dist-server/types/node/agent/interceptors/sensitive-user-input-interceptor.d.ts +7 -0
- package/cli/dist-server/types/node/agent/interceptors/system-reminder-interceptor.d.ts +101 -0
- package/cli/dist-server/types/node/agent/interceptors/team-resume-intent-interceptor.d.ts +31 -0
- package/cli/dist-server/types/node/agent/interceptors/telemetry-interceptors.d.ts +43 -0
- package/cli/dist-server/types/node/agent/interceptors/ultracode-effort-reminder-interceptor.d.ts +21 -0
- package/cli/dist-server/types/node/agent/interceptors/ultracode-keyword-interceptor.d.ts +34 -0
- package/cli/dist-server/types/node/agent/main-agent-policy.d.ts +33 -0
- package/cli/dist-server/types/node/agent/main-agent-preset.d.ts +32 -0
- package/cli/dist-server/types/node/agent/main-agent-resolver.d.ts +156 -0
- package/cli/dist-server/types/node/agent/main-agent-session.d.ts +212 -0
- package/cli/dist-server/types/node/agent/memory-context-interceptor.d.ts +84 -0
- package/cli/dist-server/types/node/agent/standing-main-agent.d.ts +12 -0
- package/cli/dist-server/types/node/agent/stream-json-init-interceptor.d.ts +9 -0
- package/cli/dist-server/types/node/agent/subagent-limits.d.ts +90 -0
- package/cli/dist-server/types/node/agent/team-context-interceptor.d.ts +42 -0
- package/cli/dist-server/types/node/agent/teammate-failure-interceptor.d.ts +67 -0
- package/cli/dist-server/types/node/agent-home/agent-home-attachments.d.ts +83 -0
- package/cli/dist-server/types/node/agent-home/agent-home-channel-system-event.d.ts +15 -0
- package/cli/dist-server/types/node/agent-home/agent-home-channel-task-event.d.ts +24 -0
- package/cli/dist-server/types/node/agent-home/agent-home-channel-wake.d.ts +115 -0
- package/cli/dist-server/types/node/agent-home/agent-home-channel-widget.d.ts +45 -0
- package/cli/dist-server/types/node/agent-home/agent-home-directory.d.ts +304 -0
- package/cli/dist-server/types/node/agent-home/agent-home-limits.d.ts +73 -0
- package/cli/dist-server/types/node/agent-home/agent-home-membership.d.ts +34 -0
- package/cli/dist-server/types/node/agent-home/agent-home-mentions.d.ts +39 -0
- package/cli/dist-server/types/node/agent-home/agent-home-room-contacts.d.ts +51 -0
- package/cli/dist-server/types/node/agent-home/channel-wake-service.d.ts +69 -0
- package/cli/dist-server/types/node/agent-task/agent-task-manager.d.ts +242 -0
- package/cli/dist-server/types/node/agent-task/agent-task-output-manager.d.ts +55 -0
- package/cli/dist-server/types/node/agent-task/agent-task-protocol.d.ts +687 -0
- package/cli/dist-server/types/node/agent-task/agent-task.d.ts +405 -0
- package/cli/dist-server/types/node/agent-task/background-task-notifier.d.ts +212 -0
- package/cli/dist-server/types/node/agent-task/background-task-tool-approval-service.d.ts +36 -0
- package/cli/dist-server/types/node/agent-task/index.d.ts +9 -0
- package/cli/dist-server/types/node/agent-task/retained-agent-task.d.ts +11 -0
- package/cli/dist-server/types/node/agent-task/stream-json-drain-trigger.d.ts +23 -0
- package/cli/dist-server/types/node/agent-task/subagent-output-scanner.d.ts +53 -0
- package/cli/dist-server/types/node/agent-team/backends/teammate-backend-protocol.d.ts +119 -0
- package/cli/dist-server/types/node/agent-team/team-member.d.ts +391 -0
- package/cli/dist-server/types/node/agent-team/team-protocol.d.ts +375 -0
- package/cli/dist-server/types/node/agent-view/agent-view-actions.d.ts +209 -0
- package/cli/dist-server/types/node/agent-view/agent-view-protocol.d.ts +714 -0
- package/cli/dist-server/types/node/agent-view/handoff-policy.d.ts +80 -0
- package/cli/dist-server/types/node/agent-view/launch-workspace.d.ts +9 -0
- package/cli/dist-server/types/node/agent-view/session-handoff.d.ts +161 -0
- package/cli/dist-server/types/node/ask/ask-protoctol.d.ts +102 -0
- package/cli/dist-server/types/node/ask/ask-service.d.ts +62 -0
- package/cli/dist-server/types/node/ask/index.d.ts +3 -0
- package/cli/dist-server/types/node/ask/session-ask-user-question-handler.d.ts +25 -0
- package/cli/dist-server/types/node/authentication/api-key-authentication-storage.d.ts +17 -0
- package/cli/dist-server/types/node/authentication/custom-token-authentication-storage.d.ts +10 -0
- package/cli/dist-server/types/node/authentication/file-authentication-storage.d.ts +71 -0
- package/cli/dist-server/types/node/bash-sandbox/bash-sandbox-manager.d.ts +125 -0
- package/cli/dist-server/types/node/bash-sandbox/index.d.ts +4 -0
- package/cli/dist-server/types/node/bash-sandbox/legacy-sandbox-shell-protocol.d.ts +33 -0
- package/cli/dist-server/types/node/bash-sandbox/legacy-sandbox-shell-service.d.ts +33 -0
- package/cli/dist-server/types/node/blob-store/blob-store-protocol.d.ts +104 -0
- package/cli/dist-server/types/node/blob-store/blob-store-service.d.ts +22 -0
- package/cli/dist-server/types/node/blob-store/image-blob-service.d.ts +121 -0
- package/cli/dist-server/types/node/blob-store/index.d.ts +4 -0
- package/cli/dist-server/types/node/blob-store/tool-result-blob-service.d.ts +109 -0
- package/cli/dist-server/types/node/channel/channel-event-service.d.ts +18 -0
- package/cli/dist-server/types/node/channel/channel-manager.d.ts +41 -0
- package/cli/dist-server/types/node/channel/channel-permission-adapter.d.ts +27 -0
- package/cli/dist-server/types/node/channel/channel-protocol.d.ts +192 -0
- package/cli/dist-server/types/node/channel/channel-security-manager.d.ts +12 -0
- package/cli/dist-server/types/node/channel/index.d.ts +5 -0
- package/cli/dist-server/types/node/cli/tui-mode-service.d.ts +20 -0
- package/cli/dist-server/types/node/code-ratio/cli-git-commit-watcher.d.ts +142 -0
- package/cli/dist-server/types/node/code-ratio/cli-svn-commit-watcher.d.ts +111 -0
- package/cli/dist-server/types/node/code-ratio/code-ratio-reporting-service.d.ts +90 -0
- package/cli/dist-server/types/node/code-ratio/fs-file-reader.d.ts +26 -0
- package/cli/dist-server/types/node/code-ratio/index.d.ts +5 -0
- package/cli/dist-server/types/node/code-ratio/vcs-repo-resolver.d.ts +51 -0
- package/cli/dist-server/types/node/command/add-dir-command-executor.d.ts +11 -0
- package/cli/dist-server/types/node/command/agent-mode-command-executor.d.ts +11 -0
- package/cli/dist-server/types/node/command/agents-command-executor.d.ts +9 -0
- package/cli/dist-server/types/node/command/auto-compact-command-executor.d.ts +20 -0
- package/cli/dist-server/types/node/command/background-command-executor.d.ts +29 -0
- package/cli/dist-server/types/node/command/bash-command-executor.d.ts +62 -0
- package/cli/dist-server/types/node/command/btw-command-executor.d.ts +13 -0
- package/cli/dist-server/types/node/command/clear-command-executor.d.ts +17 -0
- package/cli/dist-server/types/node/command/command-manager.d.ts +54 -0
- package/cli/dist-server/types/node/command/command-protocol.d.ts +106 -0
- package/cli/dist-server/types/node/command/config-command-executor.d.ts +15 -0
- package/cli/dist-server/types/node/command/context-command-executor.d.ts +42 -0
- package/cli/dist-server/types/node/command/copy-command-executor.d.ts +10 -0
- package/cli/dist-server/types/node/command/cost-command-executor.d.ts +13 -0
- package/cli/dist-server/types/node/command/custom-command-renderer.d.ts +29 -0
- package/cli/dist-server/types/node/command/debug-command-executor.d.ts +15 -0
- package/cli/dist-server/types/node/command/deep-research-command-executor.d.ts +27 -0
- package/cli/dist-server/types/node/command/doctor-command-executor.d.ts +7 -0
- package/cli/dist-server/types/node/command/effort-command-executor.d.ts +68 -0
- package/cli/dist-server/types/node/command/exit-command-executor.d.ts +14 -0
- package/cli/dist-server/types/node/command/export-command-executor.d.ts +7 -0
- package/cli/dist-server/types/node/command/feedback-command-executor.d.ts +9 -0
- package/cli/dist-server/types/node/command/fork-bg-command-executor.d.ts +29 -0
- package/cli/dist-server/types/node/command/fork-command-executor.d.ts +28 -0
- package/cli/dist-server/types/node/command/goal-command-executor.d.ts +50 -0
- package/cli/dist-server/types/node/command/handoff-message-adapter.d.ts +9 -0
- package/cli/dist-server/types/node/command/help-command-executor.d.ts +9 -0
- package/cli/dist-server/types/node/command/hooks-command-executor.d.ts +9 -0
- package/cli/dist-server/types/node/command/ide-command-executor.d.ts +11 -0
- package/cli/dist-server/types/node/command/index.d.ts +66 -0
- package/cli/dist-server/types/node/command/local-shell.d.ts +31 -0
- package/cli/dist-server/types/node/command/mcp-command-executor.d.ts +15 -0
- package/cli/dist-server/types/node/command/mcp-prompt-renderer.d.ts +44 -0
- package/cli/dist-server/types/node/command/memory-command-executor.d.ts +17 -0
- package/cli/dist-server/types/node/command/model-command-executor.d.ts +11 -0
- package/cli/dist-server/types/node/command/model-image-to-image-command-executor.d.ts +17 -0
- package/cli/dist-server/types/node/command/model-image-to-video-command-executor.d.ts +17 -0
- package/cli/dist-server/types/node/command/model-lite-command-executor.d.ts +17 -0
- package/cli/dist-server/types/node/command/model-reasoning-command-executor.d.ts +17 -0
- package/cli/dist-server/types/node/command/model-text-to-image-command-executor.d.ts +17 -0
- package/cli/dist-server/types/node/command/model-text-to-video-command-executor.d.ts +17 -0
- package/cli/dist-server/types/node/command/multitask-command-executor.d.ts +9 -0
- package/cli/dist-server/types/node/command/permissions-command-executor.d.ts +9 -0
- package/cli/dist-server/types/node/command/plan-command-executor.d.ts +11 -0
- package/cli/dist-server/types/node/command/plugin-command-executor.d.ts +25 -0
- package/cli/dist-server/types/node/command/plugin-validate-command-executor.d.ts +21 -0
- package/cli/dist-server/types/node/command/release-notes-command-executor.d.ts +18 -0
- package/cli/dist-server/types/node/command/reload-plugins-command-executor.d.ts +22 -0
- package/cli/dist-server/types/node/command/remote-control-command-executor.d.ts +44 -0
- package/cli/dist-server/types/node/command/rename-command-executor.d.ts +11 -0
- package/cli/dist-server/types/node/command/reset-command-executor.d.ts +9 -0
- package/cli/dist-server/types/node/command/resume-command-executor.d.ts +21 -0
- package/cli/dist-server/types/node/command/rewind-command-executor.d.ts +10 -0
- package/cli/dist-server/types/node/command/sandbox-command-executor.d.ts +20 -0
- package/cli/dist-server/types/node/command/save-workflow-command-executor.d.ts +43 -0
- package/cli/dist-server/types/node/command/skills-command-executor.d.ts +9 -0
- package/cli/dist-server/types/node/command/stats-command-executor.d.ts +11 -0
- package/cli/dist-server/types/node/command/status-command-executor.d.ts +11 -0
- package/cli/dist-server/types/node/command/tasks-command-executor.d.ts +9 -0
- package/cli/dist-server/types/node/command/terminal-setup-command-executor.d.ts +7 -0
- package/cli/dist-server/types/node/command/theme-command-executor.d.ts +7 -0
- package/cli/dist-server/types/node/command/todos-command-executor.d.ts +16 -0
- package/cli/dist-server/types/node/command/upgrade-command-executor.d.ts +13 -0
- package/cli/dist-server/types/node/command/vim-command-executor.d.ts +11 -0
- package/cli/dist-server/types/node/command/web-command-executor.d.ts +18 -0
- package/cli/dist-server/types/node/command/workflows-command-executor.d.ts +26 -0
- package/cli/dist-server/types/node/command-parser/command-parser-protocol.d.ts +81 -0
- package/cli/dist-server/types/node/console/console-manager.d.ts +37 -0
- package/cli/dist-server/types/node/console/console-protocol.d.ts +112 -0
- package/cli/dist-server/types/node/console/index.d.ts +2 -0
- package/cli/dist-server/types/node/context/deferred-tools-description-builder.d.ts +145 -0
- package/cli/dist-server/types/node/context/token-calculator/token-calculator-protocol.d.ts +27 -0
- package/cli/dist-server/types/node/debug/debug-middleware.d.ts +8 -0
- package/cli/dist-server/types/node/debug/debug-protocol.d.ts +63 -0
- package/cli/dist-server/types/node/debug/debug-service.d.ts +26 -0
- package/cli/dist-server/types/node/debug/index.d.ts +3 -0
- package/cli/dist-server/types/node/elicitation/elicitation-service.d.ts +100 -0
- package/cli/dist-server/types/node/feedback/feedback-protocol.d.ts +32 -0
- package/cli/dist-server/types/node/feedback/feedback-service.d.ts +19 -0
- package/cli/dist-server/types/node/feedback/index.d.ts +2 -0
- package/cli/dist-server/types/node/galileo/agent-metrics-aggregator.d.ts +115 -0
- package/cli/dist-server/types/node/galileo/error-category.d.ts +65 -0
- package/cli/dist-server/types/node/galileo/galileo-chat-reporter.d.ts +302 -0
- package/cli/dist-server/types/node/galileo/galileo-protocol.d.ts +78 -0
- package/cli/dist-server/types/node/galileo/galileo-service.d.ts +171 -0
- package/cli/dist-server/types/node/galileo/galileo-session-bridge-protocol.d.ts +134 -0
- package/cli/dist-server/types/node/galileo/galileo-session-bridge.d.ts +105 -0
- package/cli/dist-server/types/node/galileo/galileo-timing-hook.d.ts +115 -0
- package/cli/dist-server/types/node/galileo/galileo-tool-error-report-hook.d.ts +32 -0
- package/cli/dist-server/types/node/galileo/galileo-tool-post-hook.d.ts +18 -0
- package/cli/dist-server/types/node/galileo/galileo-tool-pre-hook.d.ts +16 -0
- package/cli/dist-server/types/node/galileo/galileo-tool-start-report-hook.d.ts +14 -0
- package/cli/dist-server/types/node/galileo/galileo-tool-success-report-hook.d.ts +14 -0
- package/cli/dist-server/types/node/galileo/index.d.ts +15 -0
- package/cli/dist-server/types/node/galileo/session-error-tracker.d.ts +44 -0
- package/cli/dist-server/types/node/galileo/task-outcome-resolver.d.ts +28 -0
- package/cli/dist-server/types/node/galileo/task-outcome.d.ts +35 -0
- package/cli/dist-server/types/node/hooks/functional-hooks-protocol.d.ts +78 -0
- package/cli/dist-server/types/node/hooks/functional-hooks.d.ts +23 -0
- package/cli/dist-server/types/node/http/certificate-manager.d.ts +50 -0
- package/cli/dist-server/types/node/http/classify-network-error.d.ts +21 -0
- package/cli/dist-server/types/node/http/custom-header-http-interceptor.d.ts +14 -0
- package/cli/dist-server/types/node/http/custom-headers-provider.d.ts +26 -0
- package/cli/dist-server/types/node/http/fetch-proxy.d.ts +22 -0
- package/cli/dist-server/types/node/http/http-proxy-interceptor.d.ts +116 -0
- package/cli/dist-server/types/node/http/index.d.ts +6 -0
- package/cli/dist-server/types/node/ide-integration/ide-edit-manager.d.ts +53 -0
- package/cli/dist-server/types/node/ide-integration/ide-protocol.d.ts +450 -0
- package/cli/dist-server/types/node/install/index.d.ts +6 -0
- package/cli/dist-server/types/node/install/install-controller.d.ts +15 -0
- package/cli/dist-server/types/node/install/install-env.d.ts +12 -0
- package/cli/dist-server/types/node/install/install-protocol.d.ts +83 -0
- package/cli/dist-server/types/node/install/install-service.d.ts +36 -0
- package/cli/dist-server/types/node/install/releases-service.d.ts +29 -0
- package/cli/dist-server/types/node/install/shell-setup.d.ts +36 -0
- package/cli/dist-server/types/node/library-runtime.d.ts +9 -0
- package/cli/dist-server/types/node/loopback/endpoint-provider.d.ts +9 -0
- package/cli/dist-server/types/node/loopback/error-provider.d.ts +9 -0
- package/cli/dist-server/types/node/loopback/index.d.ts +4 -0
- package/cli/dist-server/types/node/loopback/loopback-body-limit.d.ts +52 -0
- package/cli/dist-server/types/node/lsp/index.d.ts +6 -0
- package/cli/dist-server/types/node/lsp/lsp-client.d.ts +104 -0
- package/cli/dist-server/types/node/lsp/lsp-manager.d.ts +90 -0
- package/cli/dist-server/types/node/lsp/lsp-protocol.d.ts +245 -0
- package/cli/dist-server/types/node/mcp/agent-scoped-mcp-manager.d.ts +38 -0
- package/cli/dist-server/types/node/mcp/index.d.ts +32 -0
- package/cli/dist-server/types/node/mcp/mcp-cli-config-initializer.d.ts +18 -0
- package/cli/dist-server/types/node/mcp/mcp-config-diagnostics-manager.d.ts +29 -0
- package/cli/dist-server/types/node/mcp/mcp-config-env-expand-service.d.ts +45 -0
- package/cli/dist-server/types/node/mcp/mcp-config-fingerprint.d.ts +28 -0
- package/cli/dist-server/types/node/mcp/mcp-config-manager.d.ts +110 -0
- package/cli/dist-server/types/node/mcp/mcp-config-store.d.ts +18 -0
- package/cli/dist-server/types/node/mcp/mcp-connection-manager.d.ts +35 -0
- package/cli/dist-server/types/node/mcp/mcp-controller.d.ts +56 -0
- package/cli/dist-server/types/node/mcp/mcp-descriptor-environment.d.ts +5 -0
- package/cli/dist-server/types/node/mcp/mcp-first-run-status-service.d.ts +37 -0
- package/cli/dist-server/types/node/mcp/mcp-log-service.d.ts +5 -0
- package/cli/dist-server/types/node/mcp/mcp-manager.d.ts +339 -0
- package/cli/dist-server/types/node/mcp/mcp-oauth-controller.d.ts +26 -0
- package/cli/dist-server/types/node/mcp/mcp-oauth-manager.d.ts +33 -0
- package/cli/dist-server/types/node/mcp/mcp-oauth-store.d.ts +30 -0
- package/cli/dist-server/types/node/mcp/mcp-permissions-manager.d.ts +52 -0
- package/cli/dist-server/types/node/mcp/mcp-plugin-registry.d.ts +39 -0
- package/cli/dist-server/types/node/mcp/mcp-ready-service.d.ts +94 -0
- package/cli/dist-server/types/node/mcp/mcp-resource-catalog-protocol.d.ts +62 -0
- package/cli/dist-server/types/node/mcp/mcp-resource-catalog.d.ts +32 -0
- package/cli/dist-server/types/node/mcp/mcp-server-manager.d.ts +283 -0
- package/cli/dist-server/types/node/mcp/mcp-server-model-manager.d.ts +14 -0
- package/cli/dist-server/types/node/mcp/mcp-subagent-tool-manager.d.ts +36 -0
- package/cli/dist-server/types/node/mcp/mcp-toggle-manager.d.ts +45 -0
- package/cli/dist-server/types/node/mcp/mcp-transport-manager.d.ts +34 -0
- package/cli/dist-server/types/node/mcp/mcp-validate-middleware.d.ts +25 -0
- package/cli/dist-server/types/node/mcp/node-websocket-transport.d.ts +38 -0
- package/cli/dist-server/types/node/mcp/official-mcp-egress-policy.d.ts +17 -0
- package/cli/dist-server/types/node/mcp/sdk-mcp-server.d.ts +149 -0
- package/cli/dist-server/types/node/mcp/sdk-mcp-transport.d.ts +97 -0
- package/cli/dist-server/types/node/memory/conditional-rules-service.d.ts +21 -0
- package/cli/dist-server/types/node/memory/glob-matcher.d.ts +16 -0
- package/cli/dist-server/types/node/memory/index.d.ts +20 -0
- package/cli/dist-server/types/node/memory/memory-age.d.ts +44 -0
- package/cli/dist-server/types/node/memory/memory-cache.d.ts +8 -0
- package/cli/dist-server/types/node/memory/memory-controller.d.ts +62 -0
- package/cli/dist-server/types/node/memory/memory-extraction-prompts.d.ts +11 -0
- package/cli/dist-server/types/node/memory/memory-extraction-service.d.ts +56 -0
- package/cli/dist-server/types/node/memory/memory-extraction-stop-hook.d.ts +18 -0
- package/cli/dist-server/types/node/memory/memory-freshness-post-tool-hook.d.ts +22 -0
- package/cli/dist-server/types/node/memory/memory-loader.d.ts +62 -0
- package/cli/dist-server/types/node/memory/memory-manager.d.ts +24 -0
- package/cli/dist-server/types/node/memory/memory-parser.d.ts +15 -0
- package/cli/dist-server/types/node/memory/memory-prompt-builder.d.ts +38 -0
- package/cli/dist-server/types/node/memory/memory-protocol.d.ts +235 -0
- package/cli/dist-server/types/node/memory/memory-relevance-protocol.d.ts +33 -0
- package/cli/dist-server/types/node/memory/memory-relevance-service.d.ts +30 -0
- package/cli/dist-server/types/node/memory/memory-scan.d.ts +35 -0
- package/cli/dist-server/types/node/memory/memory-types.d.ts +49 -0
- package/cli/dist-server/types/node/memory/memory-validator.d.ts +6 -0
- package/cli/dist-server/types/node/memory/subdirectory-memory-loader.d.ts +55 -0
- package/cli/dist-server/types/node/model/model-protocol.d.ts +22 -0
- package/cli/dist-server/types/node/multitask/session-flags.d.ts +110 -0
- package/cli/dist-server/types/node/multitask/types.d.ts +123 -0
- package/cli/dist-server/types/node/navigation/index.d.ts +2 -0
- package/cli/dist-server/types/node/navigation/navigation-manager.d.ts +12 -0
- package/cli/dist-server/types/node/navigation/navigation-protocol.d.ts +23 -0
- package/cli/dist-server/types/node/notification/notification-protocol.d.ts +19 -0
- package/cli/dist-server/types/node/output-style/output-style-protocol.d.ts +60 -0
- package/cli/dist-server/types/node/permission/brokered-sandbox/approval-coordinator.d.ts +32 -0
- package/cli/dist-server/types/node/permission/brokered-sandbox/host-protocol.d.ts +103 -0
- package/cli/dist-server/types/node/permission/canonicalize-command.d.ts +30 -0
- package/cli/dist-server/types/node/permission/codebuddy-sandbox-env.d.ts +35 -0
- package/cli/dist-server/types/node/permission/directory-trust-service.d.ts +45 -0
- package/cli/dist-server/types/node/permission/file-policy-assessment.d.ts +35 -0
- package/cli/dist-server/types/node/permission/index.d.ts +16 -0
- package/cli/dist-server/types/node/permission/permission-protocol.d.ts +9 -0
- package/cli/dist-server/types/node/permission/sandbox-attribution-analyzer.d.ts +108 -0
- package/cli/dist-server/types/node/permission/sandbox-audit-service.d.ts +40 -0
- package/cli/dist-server/types/node/permission/sandbox-exec-policy-builtin.d.ts +30 -0
- package/cli/dist-server/types/node/permission/sandbox-exec-policy-protocol.d.ts +67 -0
- package/cli/dist-server/types/node/permission/sandbox-exec-policy.d.ts +13 -0
- package/cli/dist-server/types/node/permission/sandbox-orchestrator-protocol.d.ts +239 -0
- package/cli/dist-server/types/node/permission/sandbox-orchestrator.d.ts +308 -0
- package/cli/dist-server/types/node/permission/sandbox-permission-gateway.d.ts +36 -0
- package/cli/dist-server/types/node/permission/sandbox-telemetry-context.d.ts +27 -0
- package/cli/dist-server/types/node/permission/sensitive-command-detector.d.ts +71 -0
- package/cli/dist-server/types/node/prewarm/prewarm-protocol.d.ts +296 -0
- package/cli/dist-server/types/node/product/api-key-helper-product-provider.d.ts +105 -0
- package/cli/dist-server/types/node/product/cli-options-product-provider.d.ts +30 -0
- package/cli/dist-server/types/node/product/cloud-pre-product-provider.d.ts +76 -0
- package/cli/dist-server/types/node/product/config-watch-service.d.ts +201 -0
- package/cli/dist-server/types/node/product/craft-to-cli-agent-models-sync-provider.d.ts +16 -0
- package/cli/dist-server/types/node/product/custom-agents-product-provider.d.ts +67 -0
- package/cli/dist-server/types/node/product/custom-commands-product-provider.d.ts +49 -0
- package/cli/dist-server/types/node/product/custom-product-config-provider.d.ts +6 -0
- package/cli/dist-server/types/node/product/index.d.ts +21 -0
- package/cli/dist-server/types/node/product/internet-enviroment-product-provider.d.ts +61 -0
- package/cli/dist-server/types/node/product/mcp-prompt-product-provider.d.ts +17 -0
- package/cli/dist-server/types/node/product/mcp-watch-service.d.ts +31 -0
- package/cli/dist-server/types/node/product/models-product-provider.d.ts +41 -0
- package/cli/dist-server/types/node/product/plugin-product-provider.d.ts +13 -0
- package/cli/dist-server/types/node/product/product-capabilities.d.ts +55 -0
- package/cli/dist-server/types/node/product/product-config-controller.d.ts +27 -0
- package/cli/dist-server/types/node/product/product-env-service.d.ts +20 -0
- package/cli/dist-server/types/node/product/product-identity.d.ts +57 -0
- package/cli/dist-server/types/node/product/product-protocol.d.ts +7 -0
- package/cli/dist-server/types/node/product/sdk-initialize-product-provider.d.ts +17 -0
- package/cli/dist-server/types/node/product/settings-endpoint-product-provider.d.ts +20 -0
- package/cli/dist-server/types/node/product/skill-product-provider.d.ts +62 -0
- package/cli/dist-server/types/node/references/index.d.ts +2 -0
- package/cli/dist-server/types/node/references/reference-protocol.d.ts +20 -0
- package/cli/dist-server/types/node/references/reference-service.d.ts +42 -0
- package/cli/dist-server/types/node/remote-control/remote-control-protocol.d.ts +288 -0
- package/cli/dist-server/types/node/runtime/add-dir-middleware.d.ts +13 -0
- package/cli/dist-server/types/node/runtime/cli-capabilities.d.ts +28 -0
- package/cli/dist-server/types/node/runtime/external-uri-opener.d.ts +8 -0
- package/cli/dist-server/types/node/runtime/file-local-storage.d.ts +17 -0
- package/cli/dist-server/types/node/runtime/host-capability-provider.d.ts +57 -0
- package/cli/dist-server/types/node/runtime/host-detection.d.ts +34 -0
- package/cli/dist-server/types/node/runtime/index.d.ts +8 -0
- package/cli/dist-server/types/node/runtime/workspace-folder-manager.d.ts +45 -0
- package/cli/dist-server/types/node/runtime/workspace.d.ts +5 -0
- package/cli/dist-server/types/node/sandbox-cli/sandbox-backend-support.d.ts +7 -0
- package/cli/dist-server/types/node/sandbox-cli/sandbox-cli-lifecycle-protocol.d.ts +109 -0
- package/cli/dist-server/types/node/sandbox-cli/sandbox-cli-protocol.d.ts +376 -0
- package/cli/dist-server/types/node/sandbox-cli/sandbox-rule-sync-service.d.ts +310 -0
- package/cli/dist-server/types/node/sandbox-cli/sandbox-session-preparation.d.ts +49 -0
- package/cli/dist-server/types/node/sandbox-cli/sandbox-turn-config.d.ts +32 -0
- package/cli/dist-server/types/node/sandbox-cli/threat-domain-checker.d.ts +137 -0
- package/cli/dist-server/types/node/security-review/gate.d.ts +13 -0
- package/cli/dist-server/types/node/security-review/index.d.ts +2 -0
- package/cli/dist-server/types/node/security-review/protocol.d.ts +14 -0
- package/cli/dist-server/types/node/sensitive-content/index.d.ts +15 -0
- package/cli/dist-server/types/node/sensitive-content/managed-cipher-stream-restorer.d.ts +22 -0
- package/cli/dist-server/types/node/sensitive-content/sandbox-center-ipc-client-protocol.d.ts +3 -0
- package/cli/dist-server/types/node/sensitive-content/sandbox-center-ipc-client.d.ts +7 -0
- package/cli/dist-server/types/node/sensitive-content/sandbox-center-port.d.ts +17 -0
- package/cli/dist-server/types/node/sensitive-content/sensitive-approval-port.d.ts +22 -0
- package/cli/dist-server/types/node/sensitive-content/sensitive-content-mediation.d.ts +6 -0
- package/cli/dist-server/types/node/sensitive-content/sensitive-decision-mediation.d.ts +69 -0
- package/cli/dist-server/types/node/sensitive-content/sensitive-history-admission.d.ts +42 -0
- package/cli/dist-server/types/node/sensitive-content/sensitive-history-replay.d.ts +6 -0
- package/cli/dist-server/types/node/sensitive-content/sensitive-local-sideband.d.ts +21 -0
- package/cli/dist-server/types/node/sensitive-content/sensitive-model-boundary.d.ts +22 -0
- package/cli/dist-server/types/node/sensitive-content/sensitive-protection-metadata.d.ts +7 -0
- package/cli/dist-server/types/node/sensitive-content/sensitive-session-grants.d.ts +41 -0
- package/cli/dist-server/types/node/sensitive-content/sensitive-tool-egress-guard.d.ts +7 -0
- package/cli/dist-server/types/node/sensitive-content/sensitive-user-input-review.d.ts +7 -0
- package/cli/dist-server/types/node/sensitive-content/settings-sensitive-protection-policy.d.ts +14 -0
- package/cli/dist-server/types/node/server/types.d.ts +11 -2
- package/cli/dist-server/types/node/session/index.d.ts +15 -0
- package/cli/dist-server/types/node/session/input-history-service.d.ts +47 -0
- package/cli/dist-server/types/node/session/input-item-processors.d.ts +70 -0
- package/cli/dist-server/types/node/session/session-abort-middleware.d.ts +22 -0
- package/cli/dist-server/types/node/session/session-controller.d.ts +126 -0
- package/cli/dist-server/types/node/session/session-history-clean-flag.d.ts +2 -0
- package/cli/dist-server/types/node/session/session-history-clean-service.d.ts +49 -0
- package/cli/dist-server/types/node/session/session-hook-host-adapter.d.ts +21 -0
- package/cli/dist-server/types/node/session/session-host-adapter.d.ts +34 -0
- package/cli/dist-server/types/node/session/session-http-protocol.d.ts +1 -0
- package/cli/dist-server/types/node/session/session-interruption-host-adapter.d.ts +115 -0
- package/cli/dist-server/types/node/session/session-manager-host-adapter.d.ts +100 -0
- package/cli/dist-server/types/node/session/session-middleware.d.ts +68 -0
- package/cli/dist-server/types/node/session/session-response-host-adapter.d.ts +9 -0
- package/cli/dist-server/types/node/session/session-store-host-adapter.d.ts +23 -0
- package/cli/dist-server/types/node/session/tasks-controller.d.ts +80 -0
- package/cli/dist-server/types/node/settings/current-session-model-transition-protocol.d.ts +23 -0
- package/cli/dist-server/types/node/settings/current-session-model-transition.d.ts +15 -0
- package/cli/dist-server/types/node/settings/index.d.ts +8 -0
- package/cli/dist-server/types/node/settings/settings-controller.d.ts +23 -0
- package/cli/dist-server/types/node/settings/settings-manager.d.ts +1 -0
- package/cli/dist-server/types/node/settings/settings-protocol.d.ts +4 -0
- package/cli/dist-server/types/node/settings/settings-validate-middleware.d.ts +9 -0
- package/cli/dist-server/types/node/shell/delegating-shell-service.d.ts +44 -0
- package/cli/dist-server/types/node/shell/driver-shell-service.d.ts +8 -0
- package/cli/dist-server/types/node/shell/index.d.ts +10 -0
- package/cli/dist-server/types/node/shell/language-shim-env.d.ts +11 -0
- package/cli/dist-server/types/node/shell/output-spiller.d.ts +39 -0
- package/cli/dist-server/types/node/shell/powershell-safe-delete.d.ts +16 -0
- package/cli/dist-server/types/node/shell/safe-delete/bulk-guard/contract.d.ts +61 -0
- package/cli/dist-server/types/node/shell/safe-delete/bulk-guard/index.d.ts +3 -0
- package/cli/dist-server/types/node/shell/safe-delete/bulk-guard/marker.d.ts +5 -0
- package/cli/dist-server/types/node/shell/safe-delete/bulk-guard/service.d.ts +12 -0
- package/cli/dist-server/types/node/shell/safe-delete/index.d.ts +17 -0
- package/cli/dist-server/types/node/shell/safe-delete/safe-delete-attribution.d.ts +16 -0
- package/cli/dist-server/types/node/shell/safe-delete/safe-delete-bootstrap.d.ts +1 -0
- package/cli/dist-server/types/node/shell/safe-delete/safe-delete-env.d.ts +42 -0
- package/cli/dist-server/types/node/shell/safe-delete/safe-delete-report.d.ts +18 -0
- package/cli/dist-server/types/node/shell/safe-delete/safe-delete-sandbox-helpers.d.ts +39 -0
- package/cli/dist-server/types/node/shell/safe-delete/safe-delete-settings.d.ts +42 -0
- package/cli/dist-server/types/node/shell/safe-delete/safe-delete-trash-service.d.ts +12 -0
- package/cli/dist-server/types/node/shell/shell-protocol.d.ts +287 -0
- package/cli/dist-server/types/node/shell/shell-runtime-paths.d.ts +23 -0
- package/cli/dist-server/types/node/shell/shell-service.d.ts +257 -0
- package/cli/dist-server/types/node/shell/shell-snapshot-protocol.d.ts +75 -0
- package/cli/dist-server/types/node/shell/shell-snapshot-service.d.ts +86 -0
- package/cli/dist-server/types/node/shell/terminal-serializer.d.ts +26 -0
- package/cli/dist-server/types/node/shell/truncate-buffer.d.ts +24 -0
- package/cli/dist-server/types/node/shell/windows-process-utils.d.ts +42 -0
- package/cli/dist-server/types/node/shortcut/shortcut-protocol.d.ts +41 -0
- package/cli/dist-server/types/node/skills/skill-approval.d.ts +31 -0
- package/cli/dist-server/types/node/stats/index.d.ts +5 -0
- package/cli/dist-server/types/node/stats/insights-protocol.d.ts +59 -0
- package/cli/dist-server/types/node/stats/insights-report-service.d.ts +17 -0
- package/cli/dist-server/types/node/stats/session-facet-service.d.ts +46 -0
- package/cli/dist-server/types/node/stats/stats-protocol.d.ts +145 -0
- package/cli/dist-server/types/node/stats/stats-service.d.ts +48 -0
- package/cli/dist-server/types/node/telemetry/cost-protocol.d.ts +67 -0
- package/cli/dist-server/types/node/telemetry/cost-service.d.ts +21 -0
- package/cli/dist-server/types/node/telemetry/extension-info-processor.d.ts +13 -0
- package/cli/dist-server/types/node/telemetry/friction-analysis.d.ts +54 -0
- package/cli/dist-server/types/node/telemetry/friction-recall-client.d.ts +15 -0
- package/cli/dist-server/types/node/telemetry/host-ide-info-processor.d.ts +11 -0
- package/cli/dist-server/types/node/telemetry/index.d.ts +21 -0
- package/cli/dist-server/types/node/telemetry/logger/index.d.ts +1 -0
- package/cli/dist-server/types/node/telemetry/logger/storage-path-provider.d.ts +4 -0
- package/cli/dist-server/types/node/telemetry/plugin-telemetry-protocol.d.ts +68 -0
- package/cli/dist-server/types/node/telemetry/plugin-telemetry-service.d.ts +31 -0
- package/cli/dist-server/types/node/telemetry/qimei-env-detector.d.ts +16 -0
- package/cli/dist-server/types/node/telemetry/sandbox-telemetry-protocol.d.ts +164 -0
- package/cli/dist-server/types/node/telemetry/sandbox-telemetry-service.d.ts +181 -0
- package/cli/dist-server/types/node/telemetry/startup-profiler.d.ts +32 -0
- package/cli/dist-server/types/node/telemetry/status-reporter.d.ts +39 -0
- package/cli/dist-server/types/node/telemetry/telemetry-client-carrier.d.ts +14 -0
- package/cli/dist-server/types/node/telemetry/telemetry-client-info-event-processor.d.ts +8 -0
- package/cli/dist-server/types/node/telemetry/telemetry-protocol.d.ts +137 -0
- package/cli/dist-server/types/node/telemetry/telemetry-service.d.ts +115 -0
- package/cli/dist-server/types/node/telemetry/turn-baggage-processor.d.ts +23 -0
- package/cli/dist-server/types/node/telemetry/vcs-event-processor.d.ts +19 -0
- package/cli/dist-server/types/node/tips/builtin-tips.d.ts +2 -0
- package/cli/dist-server/types/node/tips/index.d.ts +4 -0
- package/cli/dist-server/types/node/tips/tips-manager.d.ts +14 -0
- package/cli/dist-server/types/node/tips/tips-protocol.d.ts +42 -0
- package/cli/dist-server/types/node/tips/user-state-manager.d.ts +25 -0
- package/cli/dist-server/types/node/tool-control/index.d.ts +1 -0
- package/cli/dist-server/types/node/tool-control/tool-control-policy.d.ts +34 -0
- package/cli/dist-server/types/node/tools/a2a-cancel-task-tool.d.ts +55 -0
- package/cli/dist-server/types/node/tools/a2a-get-agent-card-tool.d.ts +59 -0
- package/cli/dist-server/types/node/tools/a2a-get-task-tool.d.ts +334 -0
- package/cli/dist-server/types/node/tools/a2a-send-message-tool.d.ts +168 -0
- package/cli/dist-server/types/node/tools/a2a-tool-guards.d.ts +48 -0
- package/cli/dist-server/types/node/tools/agent-tool.d.ts +202 -0
- package/cli/dist-server/types/node/tools/artifact-control-tool.d.ts +103 -0
- package/cli/dist-server/types/node/tools/artifact-tool.d.ts +96 -0
- package/cli/dist-server/types/node/tools/ask-user-for-structured-input-tool.d.ts +127 -0
- package/cli/dist-server/types/node/tools/ask-user-question-tool.d.ts +237 -0
- package/cli/dist-server/types/node/tools/audio-transcribe-service.d.ts +61 -0
- package/cli/dist-server/types/node/tools/audio-transcribe-tool.d.ts +66 -0
- package/cli/dist-server/types/node/tools/auto-mode/auto-mode-allow-filter.d.ts +33 -0
- package/cli/dist-server/types/node/tools/auto-mode/auto-mode-classifier-client.d.ts +230 -0
- package/cli/dist-server/types/node/tools/auto-mode/auto-mode-critique-client.d.ts +51 -0
- package/cli/dist-server/types/node/tools/auto-mode/auto-mode-defaults.d.ts +16 -0
- package/cli/dist-server/types/node/tools/auto-mode/auto-mode-denial-tracker.d.ts +114 -0
- package/cli/dist-server/types/node/tools/auto-mode/auto-mode-permission-service.d.ts +51 -0
- package/cli/dist-server/types/node/tools/auto-mode/auto-mode-project-instructions.d.ts +26 -0
- package/cli/dist-server/types/node/tools/auto-mode/auto-mode-protocol.d.ts +140 -0
- package/cli/dist-server/types/node/tools/auto-mode/auto-mode-settings.d.ts +36 -0
- package/cli/dist-server/types/node/tools/auto-mode/auto-mode-strategy.d.ts +21 -0
- package/cli/dist-server/types/node/tools/auto-mode/auto-mode-system-prompt-builder.d.ts +28 -0
- package/cli/dist-server/types/node/tools/auto-mode/auto-mode-timeout.d.ts +16 -0
- package/cli/dist-server/types/node/tools/auto-mode/auto-mode-transcript-limit.d.ts +29 -0
- package/cli/dist-server/types/node/tools/auto-mode/auto-mode-transcript.d.ts +50 -0
- package/cli/dist-server/types/node/tools/auto-mode/index.d.ts +15 -0
- package/cli/dist-server/types/node/tools/auto-mode/permission-mode-policy.d.ts +63 -0
- package/cli/dist-server/types/node/tools/bash-output-tool.d.ts +34 -0
- package/cli/dist-server/types/node/tools/bash-sandbox-approval-requester.d.ts +55 -0
- package/cli/dist-server/types/node/tools/bash-tool.d.ts +211 -0
- package/cli/dist-server/types/node/tools/brief-mode-service.d.ts +26 -0
- package/cli/dist-server/types/node/tools/channel-tasks-tool.d.ts +174 -0
- package/cli/dist-server/types/node/tools/computer-use-tool.d.ts +86 -0
- package/cli/dist-server/types/node/tools/create-channel-tool.d.ts +82 -0
- package/cli/dist-server/types/node/tools/create-colleague-tool.d.ts +64 -0
- package/cli/dist-server/types/node/tools/cron-create-tool.d.ts +46 -0
- package/cli/dist-server/types/node/tools/cron-delete-tool.d.ts +28 -0
- package/cli/dist-server/types/node/tools/cron-list-tool.d.ts +27 -0
- package/cli/dist-server/types/node/tools/defer-execute-tool.d.ts +265 -0
- package/cli/dist-server/types/node/tools/defer-tool-config-protocol.d.ts +88 -0
- package/cli/dist-server/types/node/tools/defer-tool-config-service.d.ts +23 -0
- package/cli/dist-server/types/node/tools/deferred-tool-bridge.d.ts +50 -0
- package/cli/dist-server/types/node/tools/delegate-tool.d.ts +71 -0
- package/cli/dist-server/types/node/tools/edit-tool.d.ts +83 -0
- package/cli/dist-server/types/node/tools/enter-planmode-tool.d.ts +29 -0
- package/cli/dist-server/types/node/tools/enter-worktree-tool.d.ts +59 -0
- package/cli/dist-server/types/node/tools/exit-planmode-tool.d.ts +86 -0
- package/cli/dist-server/types/node/tools/file-change-artifact-publisher.d.ts +82 -0
- package/cli/dist-server/types/node/tools/glob-tool.d.ts +102 -0
- package/cli/dist-server/types/node/tools/grep-tool.d.ts +141 -0
- package/cli/dist-server/types/node/tools/image-edit-tool.d.ts +94 -0
- package/cli/dist-server/types/node/tools/image-gen-tool.d.ts +107 -0
- package/cli/dist-server/types/node/tools/image-service.d.ts +113 -0
- package/cli/dist-server/types/node/tools/index.d.ts +109 -0
- package/cli/dist-server/types/node/tools/kill-shell-tool.d.ts +27 -0
- package/cli/dist-server/types/node/tools/leave-worktree-tool.d.ts +54 -0
- package/cli/dist-server/types/node/tools/library-upload-tool.d.ts +70 -0
- package/cli/dist-server/types/node/tools/list-colleagues-tool.d.ts +35 -0
- package/cli/dist-server/types/node/tools/list-mcp-resources-tool.d.ts +58 -0
- package/cli/dist-server/types/node/tools/lsp-tool.d.ts +68 -0
- package/cli/dist-server/types/node/tools/main-agent-meta-tools.d.ts +107 -0
- package/cli/dist-server/types/node/tools/memory-tool.d.ts +33 -0
- package/cli/dist-server/types/node/tools/message-colleague-tool.d.ts +83 -0
- package/cli/dist-server/types/node/tools/monitor-tool.d.ts +216 -0
- package/cli/dist-server/types/node/tools/multi-edit-tool.d.ts +109 -0
- package/cli/dist-server/types/node/tools/notebook-edit-tool.d.ts +75 -0
- package/cli/dist-server/types/node/tools/notebook-read-tool.d.ts +55 -0
- package/cli/dist-server/types/node/tools/notebook-write-tool.d.ts +7 -0
- package/cli/dist-server/types/node/tools/plan-storage-service.d.ts +68 -0
- package/cli/dist-server/types/node/tools/powershell-clm-types.d.ts +30 -0
- package/cli/dist-server/types/node/tools/powershell-command-semantics.d.ts +23 -0
- package/cli/dist-server/types/node/tools/powershell-dangerous-cmdlets.d.ts +72 -0
- package/cli/dist-server/types/node/tools/powershell-destructive-warning.d.ts +12 -0
- package/cli/dist-server/types/node/tools/powershell-detection.d.ts +51 -0
- package/cli/dist-server/types/node/tools/powershell-git-safety.d.ts +60 -0
- package/cli/dist-server/types/node/tools/powershell-security.d.ts +93 -0
- package/cli/dist-server/types/node/tools/powershell-tool.d.ts +174 -0
- package/cli/dist-server/types/node/tools/produced-artifact-report.d.ts +35 -0
- package/cli/dist-server/types/node/tools/push-notification-tool.d.ts +55 -0
- package/cli/dist-server/types/node/tools/read-file-state-service.d.ts +27 -0
- package/cli/dist-server/types/node/tools/read-mcp-resource-tool.d.ts +71 -0
- package/cli/dist-server/types/node/tools/read-tool.d.ts +71 -0
- package/cli/dist-server/types/node/tools/repl/index.d.ts +10 -0
- package/cli/dist-server/types/node/tools/repl/repl-bridge-broker.d.ts +150 -0
- package/cli/dist-server/types/node/tools/repl/repl-bridge-host.d.ts +29 -0
- package/cli/dist-server/types/node/tools/repl/repl-catalog-protocol.d.ts +149 -0
- package/cli/dist-server/types/node/tools/repl/repl-catalog-render.d.ts +56 -0
- package/cli/dist-server/types/node/tools/repl/repl-catalog-source.d.ts +108 -0
- package/cli/dist-server/types/node/tools/repl/repl-import-rewrite.d.ts +17 -0
- package/cli/dist-server/types/node/tools/repl/repl-protocol.d.ts +210 -0
- package/cli/dist-server/types/node/tools/repl/repl-tool.d.ts +142 -0
- package/cli/dist-server/types/node/tools/repl/repl-worker-manager.d.ts +103 -0
- package/cli/dist-server/types/node/tools/repl/repl-worker-source.d.ts +16 -0
- package/cli/dist-server/types/node/tools/repl/repl-worker-source.generated.d.ts +2 -0
- package/cli/dist-server/types/node/tools/report-findings-tool.d.ts +97 -0
- package/cli/dist-server/types/node/tools/sandbox-approval-review.d.ts +40 -0
- package/cli/dist-server/types/node/tools/sandbox-permission-file-tool.d.ts +14 -0
- package/cli/dist-server/types/node/tools/sandbox-write-rule-guard.d.ts +126 -0
- package/cli/dist-server/types/node/tools/send-message-tool.d.ts +116 -0
- package/cli/dist-server/types/node/tools/send-user-message-attachments.d.ts +22 -0
- package/cli/dist-server/types/node/tools/send-user-message-tool.d.ts +60 -0
- package/cli/dist-server/types/node/tools/shell-stream-pusher.d.ts +25 -0
- package/cli/dist-server/types/node/tools/skill-manage-tool.d.ts +77 -0
- package/cli/dist-server/types/node/tools/skill-tool.d.ts +129 -0
- package/cli/dist-server/types/node/tools/slash-command-tool.d.ts +51 -0
- package/cli/dist-server/types/node/tools/space-upload/errors.d.ts +14 -0
- package/cli/dist-server/types/node/tools/space-upload/index.d.ts +4 -0
- package/cli/dist-server/types/node/tools/space-upload/local-file-source.d.ts +33 -0
- package/cli/dist-server/types/node/tools/space-upload/types.d.ts +65 -0
- package/cli/dist-server/types/node/tools/space-upload/upload-file.d.ts +27 -0
- package/cli/dist-server/types/node/tools/speak-in-channel-tool.d.ts +182 -0
- package/cli/dist-server/types/node/tools/structured-output-tool.d.ts +43 -0
- package/cli/dist-server/types/node/tools/task-create-tool.d.ts +71 -0
- package/cli/dist-server/types/node/tools/task-get-tool.d.ts +31 -0
- package/cli/dist-server/types/node/tools/task-list-tool.d.ts +20 -0
- package/cli/dist-server/types/node/tools/task-output-tool.d.ts +142 -0
- package/cli/dist-server/types/node/tools/task-stop-tool.d.ts +61 -0
- package/cli/dist-server/types/node/tools/task-storage-service.d.ts +161 -0
- package/cli/dist-server/types/node/tools/task-update-tool.d.ts +79 -0
- package/cli/dist-server/types/node/tools/team-create-tool.d.ts +84 -0
- package/cli/dist-server/types/node/tools/team-delete-tool.d.ts +38 -0
- package/cli/dist-server/types/node/tools/todo-storage-service.d.ts +48 -0
- package/cli/dist-server/types/node/tools/todo-write-tool.d.ts +117 -0
- package/cli/dist-server/types/node/tools/tool-always-approval-service.d.ts +73 -0
- package/cli/dist-server/types/node/tools/tool-argument-rewrite-service.d.ts +4 -0
- package/cli/dist-server/types/node/tools/tool-error-codes.d.ts +140 -0
- package/cli/dist-server/types/node/tools/tool-hook-manager.d.ts +61 -0
- package/cli/dist-server/types/node/tools/tool-manager.d.ts +585 -0
- package/cli/dist-server/types/node/tools/tool-permission-service.d.ts +145 -0
- package/cli/dist-server/types/node/tools/tool-permission-strategy.d.ts +83 -0
- package/cli/dist-server/types/node/tools/tool-protocol.d.ts +2 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/content-history-admission.d.ts +10 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/content-review.d.ts +56 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/execution-approval-adapter.d.ts +11 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/index.d.ts +7 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/mcp-permission-review.d.ts +15 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/mcp-projector.d.ts +5 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/permission-metadata.d.ts +8 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/projector-registry.d.ts +22 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/projectors/index.d.ts +5 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/prompt.d.ts +6 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/protocol.d.ts +231 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/review-context-build.d.ts +2 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/review-context.d.ts +42 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/review-runtime.d.ts +6 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/reviewer-client-impl.d.ts +3 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/reviewer-client.d.ts +37 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/scope.d.ts +6 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/service.d.ts +75 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/session-state.d.ts +49 -0
- package/cli/dist-server/types/node/tools/tool-risk-review/trusted-builtin-code.d.ts +25 -0
- package/cli/dist-server/types/node/tools/tool-search-protocol.d.ts +286 -0
- package/cli/dist-server/types/node/tools/tool-search-service.d.ts +137 -0
- package/cli/dist-server/types/node/tools/tool-search-tool.d.ts +103 -0
- package/cli/dist-server/types/node/tools/tool-spec/agent-tool-defer-overlay-cache.d.ts +45 -0
- package/cli/dist-server/types/node/tools/tool-spec/index.d.ts +6 -0
- package/cli/dist-server/types/node/tools/tool-spec/legacy-ide-tool-names.d.ts +2 -0
- package/cli/dist-server/types/node/tools/tool-spec/tool-defer-overlay.d.ts +70 -0
- package/cli/dist-server/types/node/tools/tool-spec/tool-spec-augment.d.ts +17 -0
- package/cli/dist-server/types/node/tools/tool-spec/tool-spec-parser.d.ts +38 -0
- package/cli/dist-server/types/node/tools/tool-spec/tool-spec-protocol.d.ts +83 -0
- package/cli/dist-server/types/node/tools/video-gen-tool.d.ts +88 -0
- package/cli/dist-server/types/node/tools/video-service.d.ts +57 -0
- package/cli/dist-server/types/node/tools/wait-for-mcp-servers-tool.d.ts +79 -0
- package/cli/dist-server/types/node/tools/web-fetch-tool.d.ts +164 -0
- package/cli/dist-server/types/node/tools/web-search-tool.d.ts +79 -0
- package/cli/dist-server/types/node/tools/wechat-reply-tool.d.ts +43 -0
- package/cli/dist-server/types/node/tools/wecom-reply-tool.d.ts +65 -0
- package/cli/dist-server/types/node/tools/workflow-background-task.d.ts +54 -0
- package/cli/dist-server/types/node/tools/workflow-tool.d.ts +83 -0
- package/cli/dist-server/types/node/tools/write-tool.d.ts +80 -0
- package/cli/dist-server/types/node/trace/trace-collector-protocol.d.ts +203 -0
- package/cli/dist-server/types/node/utils/installation-utils.d.ts +35 -0
- package/cli/dist-server/types/node/utils/osc-protocol-utils.d.ts +209 -0
- package/cli/dist-server/types/node/utils/process-identity.d.ts +40 -0
- package/cli/dist-server/types/node/utils/security-audit-log.d.ts +134 -0
- package/cli/dist-server/types/node/utils/terminal-detector-utils.d.ts +78 -0
- package/cli/dist-server/types/node/vim/index.d.ts +2 -0
- package/cli/dist-server/types/node/vim/vim-manager.d.ts +12 -0
- package/cli/dist-server/types/node/vim/vim-protocol.d.ts +24 -0
- package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-protocol.d.ts +12 -2
- package/cli/dist-server/types/vendor/cbc-core/node/agent/reviewer-recovery.d.ts +7 -0
- package/cli/dist-server/types/vendor/cbc-core/node/context/mods-bridge.d.ts +38 -2
- package/cli/dist-server/types/vendor/cbc-core/node/session/background-task-protocol.d.ts +14 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/interruption-service.d.ts +4 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-hook-host-protocol.d.ts +2 -1
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-interruption-host-protocol.d.ts +3 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-protocol.d.ts +8 -2
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-store.d.ts +59 -7
- package/cli/dist-server/types/vendor/cbc-core/node/session/truncation-recovery.d.ts +8 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session-title/session-title-utils.d.ts +36 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/history-utils.d.ts +37 -9
- package/cli/dist-server/types/vendor/cbc-core/node/utils/input-item-utils.d.ts +28 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/message-utils.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/model-utils.d.ts +9 -5
- package/cli/dist-server/types/vendor/cbc-shared/node/agent/custom-input-item-types.d.ts +20 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/agent/openai-agents-types.d.ts +2 -2
- package/cli/dist-server/types/vendor/cbc-shared/node/index.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/model/model-errors.d.ts +23 -6
- package/cli/dist-server/types/vendor/cbc-shared/node/tools/tool-names.d.ts +2 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/utils/concurrency-utils.d.ts +5 -0
- package/cli/dist-server/types/workspace/agent-client-protocol/lib/common/prompt-codec.d.ts +2 -0
- package/cli/dist-server/types/workspace/agent-client-protocol/lib/common/security-review-reason-code.d.ts +0 -10
- package/cli/dist-server/types/workspace/cbc-checkpoint/lib/node/checkpoint/checkpoint-path-utils.d.ts +10 -0
- package/cli/dist-server/types/workspace/cbc-checkpoint/lib/node/checkpoint/checkpoint-service.d.ts +2 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-protocol.d.ts +12 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/reviewer-recovery.d.ts +7 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/context/mods-bridge.d.ts +38 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/background-task-protocol.d.ts +14 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/interruption-service.d.ts +4 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-hook-host-protocol.d.ts +2 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-interruption-host-protocol.d.ts +3 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-protocol.d.ts +8 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-store.d.ts +59 -7
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/truncation-recovery.d.ts +8 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session-title/session-title-utils.d.ts +36 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/history-utils.d.ts +37 -9
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/input-item-utils.d.ts +28 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/message-utils.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/model-utils.d.ts +9 -5
- package/cli/dist-server/types/workspace/cbc-cron/lib/node/cron/cron-parser.d.ts +34 -0
- package/cli/dist-server/types/workspace/cbc-cron/lib/node/cron/cron-protocol.d.ts +191 -0
- package/cli/dist-server/types/workspace/cbc-cron/lib/node/cron/cron-scheduler-service.d.ts +131 -0
- package/cli/dist-server/types/workspace/cbc-cron/lib/node/cron/cron-scheduler.d.ts +20 -0
- package/cli/dist-server/types/workspace/cbc-cron/lib/node/cron/cron-state-manager.d.ts +50 -0
- package/cli/dist-server/types/workspace/cbc-cron/lib/node/cron/cron-storage.d.ts +61 -0
- package/cli/dist-server/types/workspace/cbc-cron/lib/node/cron/cron-task-session.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-cron/lib/node/cron/index.d.ts +8 -0
- package/cli/dist-server/types/workspace/cbc-cron/lib/node/cron/loop-skill-provider.d.ts +36 -0
- package/cli/dist-server/types/workspace/cbc-cron/lib/node/index.d.ts +10 -0
- package/cli/dist-server/types/workspace/cbc-daemon/lib/node/daemon/bg-session-handler.d.ts +88 -0
- package/cli/dist-server/types/workspace/cbc-daemon/lib/node/daemon/daemon-auto-restart.d.ts +61 -0
- package/cli/dist-server/types/workspace/cbc-daemon/lib/node/daemon/daemon-channel-autoconnect.d.ts +28 -0
- package/cli/dist-server/types/workspace/cbc-daemon/lib/node/daemon/daemon-enhancements-lifecycle.d.ts +45 -0
- package/cli/dist-server/types/workspace/cbc-daemon/lib/node/daemon/daemon-process.d.ts +77 -0
- package/cli/dist-server/types/workspace/cbc-daemon/lib/node/daemon/daemon-protocol.d.ts +324 -0
- package/cli/dist-server/types/workspace/cbc-daemon/lib/node/daemon/daemon-service.d.ts +45 -0
- package/cli/dist-server/types/workspace/cbc-daemon/lib/node/daemon/index.d.ts +10 -0
- package/cli/dist-server/types/workspace/cbc-daemon/lib/node/daemon/session-registry.d.ts +39 -0
- package/cli/dist-server/types/workspace/cbc-daemon/lib/node/daemon/system-service.d.ts +60 -0
- package/cli/dist-server/types/workspace/cbc-daemon/lib/node/daemon/wake-detector.d.ts +47 -0
- package/cli/dist-server/types/workspace/cbc-daemon/lib/node/index.d.ts +11 -0
- package/cli/dist-server/types/workspace/cbc-goal/lib/node/goal/goal-format.d.ts +25 -0
- package/cli/dist-server/types/workspace/cbc-goal/lib/node/goal/goal-policy.d.ts +55 -0
- package/cli/dist-server/types/workspace/cbc-goal/lib/node/goal/goal-protocol.d.ts +204 -0
- package/cli/dist-server/types/workspace/cbc-goal/lib/node/goal/goal-service.d.ts +353 -0
- package/cli/dist-server/types/workspace/cbc-goal/lib/node/goal/goal-session-start-hook.d.ts +25 -0
- package/cli/dist-server/types/workspace/cbc-goal/lib/node/goal/goal-utils.d.ts +23 -0
- package/cli/dist-server/types/workspace/cbc-goal/lib/node/goal/index.d.ts +6 -0
- package/cli/dist-server/types/workspace/cbc-goal/lib/node/index.d.ts +12 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/index.d.ts +35 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/builtin/index.d.ts +14 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/builtin/sec-default.d.ts +32 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/builtin/telemetry.d.ts +43 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/engine/enable-flag.d.ts +41 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/engine/engine-builder.d.ts +61 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/engine/hooks-registry.d.ts +188 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/engine/index.d.ts +6 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/engine/mods-runtime.d.ts +101 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/engine/op-table.d.ts +37 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/engine/pattern.d.ts +20 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/host/core-handler.d.ts +78 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/host/host-bindings.d.ts +215 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/host/index.d.ts +6 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/host/plugin-store.d.ts +22 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/host/render-component.d.ts +115 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/host/render-registry.d.ts +99 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/host/terminal-play.d.ts +56 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/index.d.ts +9 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/legacy-adapter/fan-out.d.ts +23 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/legacy-adapter/hook-result-mapper.d.ts +27 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/legacy-adapter/index.d.ts +2 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/loader/bootstrap.d.ts +104 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/loader/bundle-cache.d.ts +59 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/loader/index.d.ts +8 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/loader/isolated-import.d.ts +20 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/loader/load-mod.d.ts +151 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/loader/manifest-dir.d.ts +33 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/loader/mounted-import.d.ts +12 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/loader/ts-runtime.d.ts +64 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/loader/types-emitter.d.ts +105 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/testing/harness.d.ts +84 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/testing/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/types/events/agent.d.ts +188 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/types/events/command.d.ts +114 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/types/events/prompt.d.ts +310 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/types/events/tool.d.ts +308 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/types/events/upstream.d.ts +8777 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/types/events.d.ts +651 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/types/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/concurrency.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/dependency-resolver.d.ts +43 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/directory-plugin-cache-projection.d.ts +2 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/guards/index.d.ts +2 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/guards/weixinpay-integrity-guard.d.ts +48 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/index.d.ts +42 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/installers/git-plugin-installer.d.ts +42 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/installers/git-subdir-plugin-installer.d.ts +19 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/installers/index.d.ts +4 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/installers/local-plugin-installer.d.ts +40 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/installers/npm-plugin-installer.d.ts +23 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/loaders/agent-loader.d.ts +43 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/loaders/command-loader.d.ts +39 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/loaders/hook-loader.d.ts +55 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/loaders/index.d.ts +8 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/loaders/lsp-loader.d.ts +47 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/loaders/mcp-loader.d.ts +75 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/loaders/output-style-loader.d.ts +49 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/loaders/plugin-loader-manager.d.ts +73 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/loaders/skill-loader.d.ts +45 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplace-name-validator.d.ts +50 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplace-path-safety.d.ts +86 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplaces/base-marketplace.d.ts +48 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplaces/builtin-marketplace-provider.d.ts +47 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplaces/directory-marketplace.d.ts +19 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplaces/git-availability-detector.d.ts +62 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplaces/git-fallback-coordinator.d.ts +42 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplaces/git-to-zip-url-converter.d.ts +50 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplaces/github-marketplace.d.ts +41 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplaces/http-marketplace.d.ts +47 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplaces/index.d.ts +13 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplaces/marketplace-config-manager.d.ts +43 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplaces/marketplace-factory.d.ts +12 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplaces/marketplace-storage.d.ts +142 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplaces/marketplace-update-checker.d.ts +41 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/marketplaces/zip-marketplace.d.ts +150 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/mcpb-handler.d.ts +29 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/plugin-controller.d.ts +77 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/plugin-environment.d.ts +36 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/plugin-error-collector.d.ts +17 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/plugin-install-stats-service.d.ts +20 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/plugin-manager.d.ts +765 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/plugin-mcp-snapshot.d.ts +63 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/plugin-options-storage.d.ts +87 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/plugin-policy-service.d.ts +55 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/plugin-protocol.d.ts +1567 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/plugin-read-summary.d.ts +61 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/plugin-runtime-refresh-service.d.ts +262 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/plugin-validator.d.ts +48 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/session-plugin-snapshot.d.ts +5 -0
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/plugins/zip-utils.d.ts +94 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/agent/custom-input-item-types.d.ts +20 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/agent/openai-agents-types.d.ts +2 -2
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/model/model-errors.d.ts +23 -6
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/tools/tool-names.d.ts +2 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/utils/concurrency-utils.d.ts +5 -0
- package/cli/dist-server/types/workspace/code-ratio/lib/common/code-ratio-protocol.d.ts +124 -0
- package/cli/dist-server/types/workspace/code-ratio/lib/common/code-ratio-reporter.d.ts +57 -0
- package/cli/dist-server/types/workspace/code-ratio/lib/common/diff/unified-diff.d.ts +37 -0
- package/cli/dist-server/types/workspace/code-ratio/lib/common/feature-gate.d.ts +59 -0
- package/cli/dist-server/types/workspace/code-ratio/lib/common/filters/file-filter.d.ts +41 -0
- package/cli/dist-server/types/workspace/code-ratio/lib/common/index.d.ts +6 -0
- package/cli/dist-server/types/workspace/code-ratio/lib/common/vcs-repo-resolver-protocol.d.ts +50 -0
- package/cli/dist-server/types/workspace/product/lib/common/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/product/lib/common/repo-params.d.ts +14 -0
- package/cli/dist-server/types/workspace/product/lib/common/types/features.d.ts +69 -44
- package/cli/dist-server/types/workspace/product/lib/common/types/language-model.d.ts +6 -1
- package/cli/dist-server/types/workspace/sandbox-cli/lib/common/protocol.generated.d.ts +392 -0
- package/cli/dist-server/types/workspace/sandbox-cli/lib/node/file-policy.d.ts +48 -0
- package/cli/dist-server/types/workspace/sandbox-cli/lib/node/resolver.d.ts +95 -0
- package/cli/dist-server/types/workspace/sandbox-cli/lib/node/sandbox-cli-client.d.ts +78 -0
- package/cli/dist-server/types/workspace/telemetry/lib/common/event/types/security-review.d.ts +35 -6
- package/cli/dist-server/types/workspace/telemetry/lib/common/tracing/index.d.ts +1 -1
- package/cli/dist-server/types/workspace/telemetry/lib/common/tracing/otel-env.d.ts +1 -0
- package/cli/package.json +1 -1
- package/cli/product.cloudhosted.json +1 -1
- package/cli/product.internal.json +1 -1
- package/cli/product.ioa.json +1 -1
- package/cli/product.json +1 -1
- package/cli/product.selfhosted.json +1 -1
- package/docs/client.md +62 -0
- package/docs/in-process.md +151 -14
- package/docs/server.md +40 -1
- package/executor/lib/capsule/THIRD_PARTY_LICENSES.md +2 -2
- package/executor/lib/capsule/entry.mjs +8 -8
- package/executor/lib/capsule/manifest.json +2 -2
- package/executor/lib/private-protocol.cjs +33 -2
- package/executor/lib/private-protocol.d.cts +21 -1
- package/executor/lib/types.d.cts +15 -0
- package/lib/agent/v2.d.ts +1 -1
- package/lib/agent/v2.js +1 -1
- package/lib/application/services.d.ts +13 -1
- package/lib/application/services.js +1 -1
- package/lib/cli/main.js +3 -3
- package/lib/client/rpc.d.ts +16 -0
- package/lib/components/functional-hooks.d.mts +4 -0
- package/lib/components/functional-hooks.mjs +1 -0
- package/lib/harness/create-harness.js +1 -1
- package/lib/harness/hooks.d.ts +8 -0
- package/lib/harness/hooks.js +1 -0
- package/lib/harness/runtime.js +1 -1
- package/lib/harness/types.d.ts +7 -2
- package/lib/integration/agent-integration.d.ts +5 -1
- package/lib/integration/agent-integration.js +1 -1
- package/lib/integration/client-mcp-attachment.d.ts +5 -1
- package/lib/integration/client-mcp-attachment.js +1 -1
- package/lib/integration/executor-supervisor.d.ts +10 -1
- package/lib/integration/executor-supervisor.js +1 -1
- package/lib/integration/session-mcp-scope.d.ts +5 -1
- package/lib/integration/session-mcp-scope.js +1 -1
- package/lib/integration/session-mcp-view.d.ts +6 -1
- package/lib/integration/session-mcp-view.js +1 -1
- package/lib/mcp-server/module.d.ts +22 -2
- package/lib/mcp-server/module.js +1 -1
- package/lib/mcp-server/rpcs.d.ts +174 -123
- package/lib/mcp-server/rpcs.js +1 -1
- package/lib/mcp-server/schemas.d.ts +33 -0
- package/lib/mcp-server/schemas.js +1 -1
- package/lib/protocol/rpc.d.ts +73 -3
- package/lib/public.d.ts +1 -1
- package/package.json +24 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
var O=Object.defineProperty;var u=(o,e)=>O(o,"name",{value:e,configurable:!0});import{fork as k,spawn as P}from"node:child_process";import{randomUUID as x}from"node:crypto";import v from"node:path";import{EXECUTOR_PRIVATE_MAX_MESSAGE_BYTES as S,EXECUTOR_PRIVATE_MAX_TELEMETRY_MESSAGE_BYTES as q,EXECUTOR_PRIVATE_PROTOCOL_VERSION as T,isExecutorPrivateCatalogNotification as I,isExecutorPrivateResponse as B,isExecutorPrivateResult as D,isExecutorPrivateReverseRequest as N,isExecutorPrivateTelemetryNotification as V,isExecutorPrivateTelemetryNotificationCandidate as U}from"#agent-harness-executor/private-protocol";import{currentHarnessTraceCarrier as H,parseHarnessTraceCarrier as j,withHarnessTraceContext as C}from"#agent-harness-executor/trace-context";import{DEFAULT_MCP_TOOLS_SYNC_TTL_MS as z}from"#agent-harness-executor/types";import{maybeCurrentHarnessProcessRuntime as W}from"../effect-runtime/process-runtime-context.js";import{normalizeError as g}from"../internal/errors.js";import{boundedStringifyJson as E}from"../protocol/bounded-json.js";import{applyNodeRuntimeEnvironment as G,resolveNodeRuntimeLaunch as M}from"../runtime/node-runtime.js";import{AGENT_HARNESS_PRIVATE_RUNTIME_ROLE as _,createPrivateRuntimeLaunchSpec as A,isAgentHarnessStandaloneBinary as X}from"../runtime/private-runtime-role.js";import{CodeBuddyProcessContainment as $}from"../runtime/process-containment.js";import{isMissingProcess as J}from"../runtime/process-tree.js";import{assertAgentHarnessProcessContainment as Y}from"../runtime/sfe-process-containment.js";import{measure as w}from"../telemetry/index.js";import{attachPosixStdioMcpGuardian as K,resolveStdioMcpContainment as Q}from"./stdio-guardian.js";const Z=3e4,ee=15e3,te=5e3,ie=3e3,se=1e3,re=1e4,ne=3e3,oe=1024,ae=8*1024*1024,he=5,ce=6e4,le=100,b=5e3,F=16;export class ExecutorPrivateProcessExitedError extends Error{static{u(this,"ExecutorPrivateProcessExitedError")}constructor(){super("Private Executor child exited unexpectedly"),this.name="ExecutorPrivateProcessExitedError"}}export class ExecutorPrivateProtocolError extends Error{static{u(this,"ExecutorPrivateProtocolError")}constructor(e){super(e),this.name="ExecutorPrivateProtocolError"}}export class ExecutorPrivateOverloadedError extends Error{static{u(this,"ExecutorPrivateOverloadedError")}constructor(){super("Private Executor IPC queue is overloaded"),this.name="ExecutorPrivateOverloadedError"}}class ue extends Error{static{u(this,"ExecutorPrivateOperationError")}constructor(e,t,i){super(i),this.code=e,this.retryable=t,this.name=e}}export class ExecutorPrivateStartupCleanupError extends AggregateError{static{u(this,"ExecutorPrivateStartupCleanupError")}constructor(e,t){super([e,t],"Private Executor startup and cleanup both failed"),this.startupFailure=e,this.cleanupFailure=t,this.name="ExecutorPrivateStartupCleanupError"}}export class ExecutorPrivateShutdownTimeoutError extends Error{static{u(this,"ExecutorPrivateShutdownTimeoutError")}constructor(e){super(`Private Executor cleanup timed out after ${e}ms`),this.timeoutMs=e,this._tag="ExecutorPrivateShutdownTimeoutError",this.name=this._tag}}function de(){return X()?process.execPath:v.resolve(import.meta.dirname,"../../executor/lib/capsule/entry.mjs")}u(de,"defaultChildEntryPath");const fe=Object.freeze(["ALL_PROXY","HTTP_PROXY","HTTPS_PROXY","LANG","LC_ALL","NODE_EXTRA_CA_CERTS","NODE_NO_WARNINGS","NO_PROXY","PATH","SSL_CERT_DIR","SSL_CERT_FILE","SystemRoot","TEMP","TMP","TMPDIR","TZ","WINDIR","http_proxy","https_proxy","all_proxy","no_proxy"]);function pe(o){const e=u(n=>{const a=n?.trim();if(a)try{const h=new URL(a.includes("://")?a:`http://${a}`);return h.protocol==="http:"||h.protocol==="https:"?h.toString():void 0}catch{return}},"normalize"),t=e(o.ALL_PROXY??o.all_proxy),i=e(o.HTTP_PROXY??o.http_proxy??t),s=e(o.HTTPS_PROXY??o.https_proxy??t??i),r=[...new Set([...(o.NO_PROXY??o.no_proxy??"").split(",").map(n=>n.trim()).filter(Boolean),"localhost","127.0.0.1","::1"])];return Object.freeze({...i===void 0?{}:{httpProxyUrl:i},...s===void 0?{}:{httpsProxyUrl:s},mode:"auto",noProxy:Object.freeze(r),revision:"environment"})}u(pe,"defaultExecutorProxyPolicy");export function createExecutorChildEnvironment(o=process.env,e=M()){const t={AGENT_HARNESS_PRIVATE_EXECUTOR:"1"};for(const i of fe){const s=o[i];s!==void 0&&(t[i]=s)}return G(t,e)}u(createExecutorChildEnvironment,"createExecutorChildEnvironment");export function createExecutorWindowsSpawnSpec(o,e){const{execArgv:t=process.execArgv,execPath:i=process.execPath,silent:s,...r}=e,a=A({entryPath:o,nodeRuntime:{environment:{},executable:i},role:_.executor}),h=a.args[0]===o;return{...{args:Object.freeze([...h?t:[],...a.args]),command:a.command},options:{...r,env:{...r.env},windowsHide:!0}}}u(createExecutorWindowsSpawnSpec,"createExecutorWindowsSpawnSpec");function me(o,e){Y();const t=createExecutorWindowsSpawnSpec(o,e);return P(t.command,[...t.args],t.options)}u(me,"spawnExecutorChildOnWindows");function ge(o,e,t,i){if(t==="win32")return me(o,e);const s=A({entryPath:o,nodeRuntime:i,role:_.executor});if(s.args[0]===o)return k(o,[],e);const{execArgv:r,execPath:n,silent:a,...h}=e;return P(s.command,[...s.args],h)}u(ge,"spawnExecutorChild");function we(o){const e=u((a,h,l)=>{const d=a??h;if(!Number.isSafeInteger(d)||d<=0)throw new RangeError(`${l} must be a positive integer`);return d},"positive"),t=u((a,h,l)=>{const d=a??h;if(!Number.isSafeInteger(d)||d<0)throw new RangeError(`${l} must be a non-negative integer`);return d},"nonNegative"),i=o.platform??process.platform,s=Q({platform:i,requested:o.allowStdio??!0,windowsProcessContainmentEnabled:o.windowsProcessContainmentEnabled,windowsJob:o.windowsJob}),r=o.nodeRuntime??M(),n=createExecutorChildEnvironment(o.environment,r);return{allowStdio:s.allowStdio,childEntryPath:o.childEntryPath??de(),closeTimeoutMs:e(o.closeTimeoutMs,te,"closeTimeoutMs"),containment:o.containment??new $,crashWindowMs:e(o.crashWindowMs,ce,"crashWindowMs"),environment:n,healthIntervalMs:t(o.healthIntervalMs,re,"healthIntervalMs"),healthTimeoutMs:e(o.healthTimeoutMs,ne,"healthTimeoutMs"),instanceId:o.instanceId??x(),maxCrashes:e(o.maxCrashes,he,"maxCrashes"),maxPendingRequestBytes:e(o.maxPendingRequestBytes,ae,"maxPendingRequestBytes"),maxPendingRequests:e(o.maxPendingRequests,oe,"maxPendingRequests"),nodeRuntime:r,toolsSyncTtlMs:o.toolsSyncTtlMs===null?null:e(o.toolsSyncTtlMs,z,"toolsSyncTtlMs"),onElicitation:o.onElicitation,...o.onFailure===void 0?{}:{onFailure:o.onFailure},platform:i,proxyPolicy:o.proxyPolicy??pe(n),...o.recordLifecycle===void 0?{}:{recordLifecycle:o.recordLifecycle},...o.recordEffectTelemetry===void 0?{}:{recordEffectTelemetry:o.recordEffectTelemetry},requestTimeoutMs:e(o.requestTimeoutMs,Z,"requestTimeoutMs"),restartBackoffMs:e(o.restartBackoffMs,le,"restartBackoffMs"),spawnChild:o.spawnChild??((a,h)=>ge(a,h,i,r)),startTimeoutMs:e(o.startTimeoutMs,ee,"startTimeoutMs"),...o.stdioGuardianEntryPath===void 0?{}:{stdioGuardianEntryPath:o.stdioGuardianEntryPath},stdioContainment:s.mode,...s.mode==="windows_native_job_object"?{windowsJob:s.windowsJob}:{},termTimeoutMs:e(o.termTimeoutMs,ie,"termTimeoutMs")}}u(we,"resolveOptions");function L(o,e){return e?.aborted?Promise.reject(e.reason):new Promise((t,i)=>{let s=!1;const r=u(h=>{s||(s=!0,clearTimeout(a),e?.removeEventListener("abort",n),h===void 0?t():i(h))},"finish"),n=u(()=>r(e?.reason),"onAbort"),a=setTimeout(()=>r(),o);a.unref?.(),e?.addEventListener("abort",n,{once:!0})})}u(L,"standaloneDelay");function R(o,e,t){const i=new AbortController,s=setTimeout(()=>i.abort(t),o);s.unref?.();const r=AbortSignal.any([...e,i.signal]),n=[];let a=!1;const h=u(()=>{if(!a){a=!0,clearTimeout(s);for(const[l,d]of n)l.removeEventListener("abort",d);n.length=0}},"close");for(const l of e)n.push([l,h]),l.addEventListener("abort",h,{once:!0});return Object.freeze({close:h,signal:r})}u(R,"standaloneDeadline");export class ExecutorProcessSupervisor{static{u(this,"ExecutorProcessSupervisor")}registerClientSource(e,t){if(this.assertAccepting(),this.clientSources.has(e))throw new Error("Duplicate Client MCP source");const i=t.subscribe(()=>{for(const s of this.registrations.values())s.transport.transport==="client"&&s.transport.sourceId===e&&this.invalidateCatalog(s.registrationId)});return this.clientSources.set(e,{source:t,release:i}),()=>{if(this.clientSources.get(e)?.source===t){this.clientSources.delete(e),i();for(const r of this.clientRequests.values())r.sourceId===e&&r.controller.abort(new Error("Client MCP source closed"))}}}invalidateCatalog(e){if(this.isStopping()||!this.registrations.has(e))return;const t=this.catalogRefreshes.get(e);if(t){t.dirty=!0;return}const i={dirty:!0,promise:Promise.resolve()};i.promise=Promise.resolve().then(async()=>{do{if(i.dirty=!1,this.isStopping()||!this.registrations.has(e))return;await this.refreshRegistration(e)}while(i.dirty)}).catch(()=>{}).finally(()=>{this.catalogRefreshes.delete(e),this.scheduleCatalogRefresh(e)}),this.catalogRefreshes.set(e,i)}scheduleCatalogRefresh(e){if(clearTimeout(this.catalogTimers.get(e)),this.catalogTimers.delete(e),this.isStopping()||!this.registrations.has(e)||this.options.toolsSyncTtlMs===null)return;const t=setTimeout(()=>{this.catalogTimers.delete(e),this.invalidateCatalog(e)},Math.min(this.options.toolsSyncTtlMs,2147483647));t.unref(),this.catalogTimers.set(e,t)}constructor(e){if(this.crashTimes=[],this.failureTasks=new Set,this.fuseOpenAttempt=0,this.fuseState="closed",this.nextRequestId=1,this.nextRegistrationRevision=1,this.pending=new Map,this.pendingSendBytes=0,this.pendingSends=0,this.proxyTask=Promise.resolve(),this.registrationRevisions=new Map,this.registrationTasks=new Map,this.restartAttempt=0,this.shutdownController=new AbortController,this.registrations=new Map,this.snapshots=new Map,this.clientSources=new Map,this.clientRequests=new Map,this.catalogTimers=new Map,this.catalogRefreshes=new Map,this.snapshotListeners=new Set,this.stateValue="idle",this.options=we(e),this.proxyPolicy=this.options.proxyPolicy,this.processRuntime=e.processRuntime??W(),this.processRuntime===void 0&&process.env.NODE_ENV!=="test")throw new Error("Executor supervisor requires the process-owned Effect runtime");this.releaseProcessOwnership=this.processRuntime?.addFinalizer(()=>this.close(new Error("Agent Harness process runtime is closing")));const t=this.processRuntime?.shutdownSignal;if(t){const i=u(()=>{this.close(t.reason).catch(()=>{})},"onProcessShutdown");t.addEventListener("abort",i,{once:!0}),this.releaseProcessShutdownListener=()=>t.removeEventListener("abort",i)}}get runtimeEpoch(){return this.active?.epoch}get state(){return this.stateValue}async start(){await this.ensureReady()}async configureProxy(e){this.assertAccepting(),this.proxyPolicy=e;const t=this.proxyTask.then(()=>this.reconcileProxyPolicy());this.proxyTask=t.catch(()=>{}),await t}subscribeSnapshots(e){return this.snapshotListeners.add(e),()=>this.snapshotListeners.delete(e)}async upsertRegistration(e,t){this.assertAccepting();const i=this.nextRegistrationRevision++;this.registrations.set(e.registrationId,e),this.registrationRevisions.set(e.registrationId,i);try{return await this.ensureReady(),await this.withRegistrationLock(e.registrationId,async()=>{if(this.assertCurrentRegistration(e.registrationId,i),t?.signal?.aborted)throw t.signal.reason;const s=this.active,r=this.snapshots.get(e.registrationId);if(this.stateValue==="ready"&&s?.initialized===!0&&s.child.connected&&s.child.exitCode===null&&s.child.signalCode===null&&s.appliedRegistrationRevisions.get(e.registrationId)===i&&r?.status==="available"&&r?.registrationId===e.registrationId&&r?.runtimeEpoch===s.epoch)return r;const n=await w("registrationReconcile",()=>this.request("registration/upsert",{registration:e},t));return this.assertCurrentRegistration(e.registrationId,i),this.setSnapshot(e.registrationId,n),n})}catch(s){throw this.isCurrentRegistration(e.registrationId,i)&&this.deleteSnapshot(e.registrationId),s}}async refreshRegistration(e,t){this.requireRegistration(e);const i=this.requireRegistrationRevision(e);return await this.ensureReady(),this.withRegistrationLock(e,async()=>{this.assertCurrentRegistration(e,i);const s=await this.request("registration/refresh",{registrationId:e},t);return this.assertCurrentRegistration(e,i),this.setSnapshot(e,s),s})}getSnapshot(e){return this.snapshots.get(e)}async removeRegistration(e,t){const i=this.nextRegistrationRevision++;this.registrations.delete(e),this.registrationRevisions.set(e,i),this.deleteSnapshot(e),this.registrations.size===0&&this.cancelFuseRecovery(new Error("Executor fuse recovery is no longer needed")),!(this.stateValue==="closed"||this.stateValue==="closing")&&(await this.withRegistrationLock(e,async()=>{if(!this.isCurrentRegistrationRevision(e,i)||this.isStopping())return;const s=this.active;if(s?.initialized)try{await this.requestOnActive(s,"registration/remove",{registrationId:e},t),s.appliedRegistrationRevisions.delete(e)}catch(r){if(this.active===s&&!this.isStopping())throw this.handleChildFailure(s,r),r}}),this.isCurrentRegistrationRevision(e,i)&&(this.deleteSnapshot(e),this.registrationRevisions.delete(e)))}async callTool(e,t,i,s,r={}){this.requireRegistration(e);const n=this.requireRegistrationRevision(e);await this.ensureReady(),this.assertCurrentRegistration(e,n);let a=!1;const h=u(()=>{a||(a=!0,this.request("tool/cancel",{invocationId:t},{timeoutMs:Math.min(r.timeoutMs??this.options.requestTimeoutMs,2e3)}).catch(()=>{}))},"cancelInvocation");let l;r.signal&&(l=h,r.signal.addEventListener("abort",l,{once:!0}));try{return await this.request("tool/call",{args:s,executorAddress:i,invocationId:t,registrationId:e},r)}catch(d){throw h(),d}finally{l&&r.signal?.removeEventListener("abort",l)}}async close(e){return this.closePromise??=this.closeInternal(e),this.closePromise}async closeInternal(e){for(const c of this.catalogTimers.values())clearTimeout(c);this.catalogTimers.clear();for(const c of this.clientRequests.values())c.controller.abort(e);for(const c of this.clientSources.values())c.release();if(this.clientSources.clear(),this.stateValue==="closed")return;const t=e??new Error("Executor supervisor is closing"),i=this.createShutdownBudget(this.options.closeTimeoutMs,this.processRuntime?.shutdownDeadlineAt),{timeoutError:s}=i;this.shutdownBudget=i,this.stateValue="closing",this.cancelFuseRecovery(t),this.shutdownController.abort(t);const r=[],n=[],a=u((c,p=r)=>{c===s&&(r.includes(s)||n.includes(s))||p.push(c)},"addFailure"),h=u(async(c,p=r)=>{const y=await this.settleWithinShutdown(c,i);y.status==="rejected"?a(y.reason,p):y.status==="timed_out"&&a(s,p)},"attempt");this.clearHealthTimer();const l=this.active,d=this.startPromise;if(this.rejectPending(t),l&&!d&&l.initialized){const c=this.gracefulCloseBudgetMs(i,l.guardian!==void 0);c>0&&await h(this.requestOnActive(l,"runtime/close",{},{signal:i.deadline.signal,timeoutMs:c}))}if(l)try{await this.terminateChild(l,i)}catch(c){a(c,n)}if(d){const c=await this.settleWithinShutdown(d,i);c.status==="rejected"?c.reason instanceof ExecutorPrivateStartupCleanupError&&r.push(...this.flattenCleanupFailure(c.reason.cleanupFailure)):c.status==="timed_out"&&a(s)}const f=await this.settleWithinShutdown(Promise.allSettled([...this.failureTasks,...this.registrationTasks.values(),...[...this.catalogRefreshes.values()].map(c=>c.promise)]),i);if(f.status==="fulfilled")for(const c of f.value)c.status==="rejected"&&r.push(c.reason);else f.status==="rejected"?r.push(f.reason):a(s);r.push(...n);const m=this.active;if(m&&(m!==l||m.child.exitCode===null&&m.child.signalCode===null))try{await this.terminateChild(m,i)}catch(c){a(c)}i.deadline.signal.aborted&&a(s),this.active=void 0,this.recoveryPromise=void 0,this.startPromise=void 0,this.registrations.clear(),this.registrationRevisions.clear(),this.registrationTasks.clear();for(const c of this.snapshots.keys())this.deleteSnapshot(c);if(this.snapshotListeners.clear(),this.stateValue="closed",this.releaseProcessShutdownListener?.(),this.releaseProcessOwnership?.(),i.deadline.close(),r.length>0){const c=r.length===1?r[0]:new AggregateError(r,"Private Executor cleanup failed"),p=m??l;throw this.recordLifecycle({component:"executor",error:c,phase:"cleanup",...p===void 0?{}:{process:{exitCode:p.child.exitCode,pid:p.child.pid,signal:p.child.signalCode}},reason:"cleanup_failed",state:"shutdown_failed"}),c}}async ensureReady(){for(;;){if(this.assertAccepting(),this.stateValue==="ready"&&this.active)return;if(this.fuseState!=="closed")throw new Error(`Executor supervisor fuse is ${this.fuseState}; recovery is pending`);const e=this.recoveryPromise;if(!e)break;await e}await this.startWithoutRecoveryWait()}async startWithoutRecoveryWait(e){this.assertAccepting();const t=[this.shutdownController.signal];this.processRuntime?.shutdownSignal&&t.push(this.processRuntime.shutdownSignal),e&&t.push(e);const i=t.length===1?t[0]:AbortSignal.any(t);if(i.aborted)throw i.reason;if(this.stateValue==="ready"&&this.active)return;const s=this.startPromise??this.startChild(i);this.startPromise=s;try{await s}finally{this.startPromise===s&&(this.startPromise=void 0)}}async startChild(e){if(this.options.containment.assertHealthy(),e?.aborted||(this.stateValue=this.stateValue==="idle"?"starting":"restarting",this.restartAttempt>0&&await this.waitForRestartBackoff(this.restartAttempt,e),this.assertAccepting(),e?.aborted))throw e.reason;const t=x(),i=this.options.spawnChild(this.options.childEntryPath,{cwd:v.dirname(this.options.childEntryPath),detached:this.options.platform!=="win32",env:this.options.environment,execArgv:[],execPath:this.options.nodeRuntime.executable,serialization:"json",stdio:["ignore","ignore","pipe","ipc"]});if(!i.pid||!i.send)throw i.kill(),new Error("Private Executor child did not expose PID and IPC");const s=i.pid;i.stderr?.resume();const r={appliedRegistrationRevisions:new Map,child:i,epoch:t,exit:i.exitCode!==null||i.signalCode!==null?Promise.resolve():new Promise(n=>{i.once("exit",()=>n())}),initialized:!1};this.active=r,i.on("message",n=>this.handleMessage(r,n)),i.once("error",n=>this.handleChildFailure(r,n)),i.once("exit",()=>{this.isStopping()||this.handleChildFailure(r,new ExecutorPrivateProcessExitedError)}),i.once("disconnect",()=>{this.isStopping()&&this.handleChildFailure(r,new ExecutorPrivateProcessExitedError)});try{if(this.options.windowsJob&&!this.options.windowsJob.isProcessInJob(s))throw new Error("Private Executor did not inherit the host Windows Job");this.options.stdioContainment==="posix_guardian"&&await w("guardianBind",async()=>{const h=await K({...this.options.stdioGuardianEntryPath===void 0?{}:{childEntryPath:this.options.stdioGuardianEntryPath},containment:this.options.containment,...e===void 0?{}:{signal:e},shutdownDeadlineAt:u(()=>this.processRuntime?.shutdownDeadlineAt,"shutdownDeadlineAt"),targetProcessGroupId:s,termTimeoutMs:this.options.termTimeoutMs});if(r.guardian=h,e?.aborted||this.isStopping())throw e?.reason??new Error("Executor supervisor is closing");await h.bindAnchor(s),r.guardianBound=!0});const n=this.proxyPolicy,a=await w("executorInitialize",()=>this.requestOnActive(r,"runtime/initialize",{allowStdio:this.options.allowStdio,proxy:n,protocolVersion:T,runtimeEpoch:t,stdioContainment:this.options.stdioContainment,...this.options.windowsJob===void 0?{}:{windowsJobAddonPath:this.options.windowsJob.addonPath},...!this.options.allowStdio||r.guardian===void 0?{}:{stdioGuardianPid:r.guardian.guardianPid},tenantId:this.options.instanceId},{...e===void 0?{}:{signal:e},timeoutMs:this.options.startTimeoutMs}));if(a.protocolVersion!==T||a.runtimeEpoch!==t||a.proxyRevision!==n.revision||(this.options.stdioContainment==="posix_guardian"?a.stdioAnchorPid===void 0||a.stdioAnchorPid<=0:a.stdioAnchorPid!==void 0))throw new ExecutorPrivateProtocolError("Private Executor initialize response did not match its epoch");r.anchorPid=a.stdioAnchorPid,r.appliedProxyRevision=a.proxyRevision,await this.reconcileProxyPolicyOnActive(r,e),r.initialized=!0,await w("registrationReconcile",()=>this.reconcileRegistrationsAndCommitReady(r,e))}catch(n){let a=!1,h;try{await this.terminateChild(r)}catch(l){a=!0,h=l}throw this.active===r&&(this.active=void 0),!this.isStopping()&&this.fuseState==="closed"&&(this.stateValue="idle"),a?(this.recordLifecycle({component:"executor",error:h,phase:"cleanup",process:{exitCode:r.child.exitCode,pid:r.child.pid,signal:r.child.signalCode},reason:"cleanup_failed",state:"shutdown_failed"}),new ExecutorPrivateStartupCleanupError(n,h)):n}}async reconcileProxyPolicy(){const e=this.active;e?.initialized!==!0||this.isStopping()||await this.reconcileProxyPolicyOnActive(e)}async reconcileProxyPolicyOnActive(e,t){for(let i=0;i<F;i+=1){if(this.active!==e||this.isStopping())return;const s=this.proxyPolicy;if(e.appliedProxyRevision===s.revision)return;const r=await this.requestOnActive(e,"runtime/proxy-configure",{proxy:s},{...t===void 0?{}:{signal:t},timeoutMs:this.options.requestTimeoutMs});if(r.proxyRevision!==s.revision)throw new ExecutorPrivateProtocolError("Private Executor proxy revision did not match its request");e.appliedProxyRevision=r.proxyRevision}throw new ExecutorPrivateProtocolError("Private Executor proxy policy did not converge")}async reconcileRegistrationsAndCommitReady(e,t){for(let i=0;i<F;i+=1){const s=new Set([...e.appliedRegistrationRevisions.keys(),...this.registrations.keys()]);for(const r of s)await this.withRegistrationLock(r,async()=>{if(this.active!==e||this.isStopping()||t?.aborted)throw t?.reason??new ExecutorPrivateProcessExitedError;const n=this.registrations.get(r),a=this.registrationRevisions.get(r),h=e.appliedRegistrationRevisions.get(r);if(n&&a!==void 0){if(h===a)return;const l=await this.requestOnActive(e,"registration/upsert",{registration:n},t===void 0?{}:{signal:t});e.appliedRegistrationRevisions.set(r,a),this.isCurrentRegistration(r,a)&&this.setSnapshot(r,l);return}h!==void 0&&(await this.requestOnActive(e,"registration/remove",{registrationId:r},t===void 0?{}:{signal:t}),e.appliedRegistrationRevisions.delete(r),this.deleteSnapshot(r))});if(this.active!==e||this.isStopping()||t?.aborted)throw t?.reason??new ExecutorPrivateProcessExitedError;if(this.registrationsConverged(e)){this.restartAttempt=0,this.stateValue="ready",this.scheduleHealthCheck(e);return}}throw new ExecutorPrivateProtocolError("Private Executor registration state did not converge during startup")}registrationsConverged(e){if(e.appliedRegistrationRevisions.size!==this.registrations.size)return!1;for(const t of this.registrations.keys()){const i=this.registrationRevisions.get(t);if(i===void 0||e.appliedRegistrationRevisions.get(t)!==i)return!1}return!0}handleMessage(e,t){if(this.active===e){if(U(t)){try{E(t,q)}catch{return}if(!V(t)||t.params.runtimeEpoch!==e.epoch)return;try{const{signal:i}=t.params;i.kind==="log"?this.options.recordEffectTelemetry?.log(i.value):i.kind==="metrics"?this.options.recordEffectTelemetry?.metrics(Object.freeze({...i.value,runtimeEpoch:e.epoch})):this.options.recordEffectTelemetry?.span(i.value)}catch{}return}try{E(t,S)}catch(i){this.failProtocol(e,new ExecutorPrivateProtocolError(`Private Executor sent an invalid or oversized IPC payload: ${g(i).message}`));return}if(B(t)){if(t.runtimeEpoch!==e.epoch)return;if(typeof t.id!="number"){this.failProtocol(e,new ExecutorPrivateProtocolError("Private Executor response used an invalid request id"));return}const i=this.pending.get(t.id);if(!i||i.epoch!==e.epoch)return;if(this.pending.delete(t.id),i.deadline.close(),"error"in t){const s=new ue(t.error.data?.code??"ExecutorPrivateError",t.error.data?.retryable,t.error.message);i.reject(s)}else{if(!D(i.method,t.result)){i.reject(new ExecutorPrivateProtocolError(`Private Executor returned an invalid ${i.method} result`)),this.failProtocol(e,new ExecutorPrivateProtocolError("Private Executor response violated its method contract"));return}i.resolve(t.result)}return}if(I(t)){if(t.params.runtimeEpoch!==e.epoch)return;if(t.method==="client-mcp/cancel")this.clientRequests.get(t.params.requestId)?.controller.abort(new Error("MCP request cancelled"));else for(const i of this.registrations.values())i.executorSlug===t.params.integration&&i.connectionName===t.params.connection&&this.invalidateCatalog(i.registrationId);return}if(N(t)){if(t.params.runtimeEpoch!==e.epoch)return;this.handleReverseRequest(e,t);return}this.failProtocol(e,new ExecutorPrivateProtocolError("Private Executor sent an unknown IPC message"))}}async handleClientMcpRequest(e,t){const i=new AbortController;try{const s=this.clientSources.get(t.params.sourceId)?.source;if(!s||this.clientRequests.size>=this.options.maxPendingRequests||this.clientRequests.has(t.id)||![...this.registrations.values()].some(n=>n.transport.transport==="client"&&n.transport.sourceId===t.params.sourceId))throw new Error("Client MCP source unavailable");this.clientRequests.set(t.id,{sourceId:t.params.sourceId,epoch:e.epoch,controller:i});const r=await s.request(t.params.method,t.params.params,i.signal);if(this.active!==e||i.signal.aborted)return;await this.send(e,{id:t.id,jsonrpc:"2.0",result:r,runtimeEpoch:e.epoch})}catch{await this.send(e,{id:t.id,jsonrpc:"2.0",error:{code:-32e3,message:"Client MCP request failed"},runtimeEpoch:e.epoch}).catch(()=>{})}finally{this.clientRequests.delete(t.id)}}async handleReverseRequest(e,t){if(t.method==="client-mcp/request")return this.handleClientMcpRequest(e,t);try{const i=t.trace===void 0?void 0:j(t.trace),s=await C(i,()=>this.options.onElicitation({invocationId:t.params.invocationId,request:t.params.request,runtimeEpoch:e.epoch}));await this.send(e,{id:t.id,jsonrpc:"2.0",result:s,runtimeEpoch:e.epoch})}catch{await this.send(e,{error:{code:-32e3,message:"Elicitation was cancelled"},id:t.id,jsonrpc:"2.0",runtimeEpoch:e.epoch}).catch(()=>{})}}failProtocol(e,t){this.handleChildFailure(e,t)}handleChildFailure(e,t){if(this.active!==e)return;this.active=void 0;for(const n of this.clientRequests.values())n.epoch===e.epoch&&n.controller.abort(t);if(this.clearHealthTimer(),this.rejectPending(t,e.epoch),this.stateValue==="closing"||this.stateValue==="closed")return;const i=g(t);if(this.fuseState==="half_open"){const n=this.recordHalfOpenFailure(e,i).catch(()=>{});this.failureTasks.add(n),n.finally(()=>this.failureTasks.delete(n)).catch(()=>{}),this.reportFailure(i);return}this.stateValue="idle";const r=this.finishChildFailure(e,i).catch(n=>this.reportFailure(g(n))).catch(()=>{}).then(()=>{});this.recoveryPromise=r,this.failureTasks.add(r),r.then(()=>{this.failureTasks.delete(r),this.recoveryPromise===r&&(this.recoveryPromise=void 0,this.fuseRecoveryController=void 0)}).catch(()=>{}),this.reportFailure(i)}async finishChildFailure(e,t){const i=this.readPolicyNow();for(this.crashTimes.push(i);this.crashTimes.length>0&&this.crashTimes[0]<i-this.options.crashWindowMs;)this.crashTimes.shift();const s=this.crashTimes.length>this.options.maxCrashes;s?this.openFuse(e.epoch,t,e):(this.restartAttempt+=1,this.stateValue="idle",this.publishUnavailable(e.epoch,!1),this.registrations.size>0&&this.recordLifecycle({component:"executor",counts:{attempt:this.restartAttempt,failuresInWindow:this.crashTimes.length},error:t,phase:"recovery",process:{exitCode:e.child.exitCode,pid:e.child.pid,signal:e.child.signalCode},reason:t instanceof ExecutorPrivateProcessExitedError?"process_exit":t instanceof ExecutorPrivateProtocolError?"protocol_error":"process_error",state:"restarting"}));const r=s?new AbortController:void 0;r&&(this.fuseRecoveryController=r),await this.recoverAfterChildFailure(e,s,r)}async recordHalfOpenFailure(e,t){const i=this.readPolicyNow();for(this.crashTimes.push(i);this.crashTimes.length>0&&this.crashTimes[0]<i-this.options.crashWindowMs;)this.crashTimes.shift();this.openFuse(e.epoch,t,e)}async recoverAfterChildFailure(e,t,i){try{await this.terminateChild(e)}catch(r){throw this.recordLifecycle({component:"executor",error:r,phase:"cleanup",process:{exitCode:e.child.exitCode,pid:e.child.pid,signal:e.child.signalCode},reason:"cleanup_failed",state:"shutdown_failed"}),r}const s=this.startPromise;if(s&&await s.catch(()=>{}),this.isStopping()||this.registrations.size===0){t&&!this.isStopping()&&this.closeUnusedFuse();return}if(!t){await this.startWithoutRecoveryWait();return}if(!i)throw new Error("Executor fuse recovery omitted its controller");await this.recoverOpenFuse(i.signal)}async recoverOpenFuse(e){let t=e;for(;!this.isStopping();){if(t.aborted){const i=this.renewFuseRecoveryAfterCancellation(t);if(!i)return;t=i}if(this.registrations.size===0){this.closeUnusedFuse();return}this.fuseState="open",this.stateValue="failed";try{await this.waitForRestartBackoff(Math.max(1,this.fuseOpenAttempt),t)}catch(i){if(t.aborted){const s=this.renewFuseRecoveryAfterCancellation(t);if(!s)return;t=s;continue}if(this.isStopping())return;throw i}if(this.isStopping()||this.registrations.size===0){this.registrations.size===0&&!this.isStopping()&&this.closeUnusedFuse();return}this.fuseState="half_open",this.stateValue="restarting";try{if(await this.startWithoutRecoveryWait(t),this.fuseState==="half_open"&&this.state==="ready"&&this.active){this.closeFuse();return}this.fuseState==="half_open"&&this.openFuse()}catch(i){if(t.aborted){const s=this.renewFuseRecoveryAfterCancellation(t);if(!s)return;t=s;continue}if(this.isStopping())return;this.fuseState==="half_open"&&this.openFuse(),this.reportFailure(g(i))}}}renewFuseRecoveryAfterCancellation(e){if(this.isStopping())return;if(this.registrations.size===0){this.closeUnusedFuse();return}const t=this.fuseRecoveryController;if(t&&t.signal!==e&&!t.signal.aborted)return t.signal;const i=new AbortController;return this.fuseRecoveryController=i,i.signal}openFuse(e,t,i){const s=this.fuseState!=="open";this.fuseState!=="open"&&(this.fuseOpenAttempt+=1),this.fuseState="open",this.stateValue="failed",this.publishUnavailable(e,!0),s&&this.recordLifecycle({component:"executor",counts:{attempt:this.fuseOpenAttempt,failuresInWindow:this.crashTimes.length},...t===void 0?{}:{error:t},phase:"recovery",...i===void 0?{}:{process:{exitCode:i.child.exitCode,pid:i.child.pid,signal:i.child.signalCode}},reason:t instanceof ExecutorPrivateProcessExitedError?"process_exit":t instanceof ExecutorPrivateProtocolError?"protocol_error":"recovery_failed",state:"fused"})}closeFuse(){this.fuseState="closed",this.fuseOpenAttempt=0,this.crashTimes.length=0,this.restartAttempt=0,this.stateValue="ready"}closeUnusedFuse(){this.fuseState="closed",this.fuseOpenAttempt=0,this.crashTimes.length=0,this.restartAttempt=0,this.stateValue="idle"}cancelFuseRecovery(e){this.fuseRecoveryController?.abort(e)}publishUnavailable(e,t){for(const[i,s]of this.snapshots)this.setSnapshot(i,{error:{code:t?"executor_failed":"executor_restarting",message:t?"MCP runtime exceeded its restart limit; recovery is pending":"MCP runtime is restarting",retryable:!0},generation:s.generation+1,registrationId:i,runtimeEpoch:e??s.runtimeEpoch,status:"unavailable",tools:[]})}setSnapshot(e,t){this.snapshots.set(e,t),this.scheduleCatalogRefresh(e),this.publishSnapshot(e,t)}deleteSnapshot(e){clearTimeout(this.catalogTimers.get(e)),this.catalogTimers.delete(e),this.snapshots.delete(e)&&this.publishSnapshot(e,void 0)}publishSnapshot(e,t){for(const i of this.snapshotListeners)try{i(e,t)}catch{}}request(e,t,i){const s=this.active;return!s||this.stateValue!=="ready"?Promise.reject(new Error("Private Executor is not ready")):this.requestOnActive(s,e,t,i)}scheduleHealthCheck(e){if(this.clearHealthTimer(),this.options.healthIntervalMs===0)return;const t=new AbortController,i={close:u(()=>t.abort(new Error("Executor health delay completed")),"close")};this.healthTimer=i,C(void 0,()=>{this.waitForPolicyDelay(this.options.healthIntervalMs,t.signal,"Executor health delay cancelled").then(()=>{if(this.healthTimer===i)return this.healthTimer=void 0,this.checkHealth(e)}).catch(s=>{this.healthTimer===i&&(this.healthTimer=void 0),!t.signal.aborted&&!this.isStopping()&&this.failProtocol(e,g(s))})})}async checkHealth(e){if(!(this.active!==e||this.stateValue!=="ready")){try{const t=await this.requestOnActive(e,"runtime/health",{},{timeoutMs:this.options.healthTimeoutMs});if(t.status!=="ready"||t.runtimeEpoch!==e.epoch||t.stdioAnchorPid!==e.anchorPid)throw new ExecutorPrivateProtocolError("Private Executor health response did not match its epoch")}catch(t){this.active===e&&!this.isStopping()&&this.failProtocol(e,g(t));return}this.active===e&&this.stateValue==="ready"&&this.scheduleHealthCheck(e)}}clearHealthTimer(){this.healthTimer&&(this.healthTimer.close(),this.healthTimer=void 0)}requestOnActive(e,t,i,s={}){if(s.signal?.aborted)return Promise.reject(s.signal.reason);if(this.pending.size>=this.options.maxPendingRequests)return Promise.reject(new ExecutorPrivateOverloadedError);const r=this.nextRequestId++,n=H(),a={id:r,jsonrpc:"2.0",method:t,params:i,...n===void 0?{}:{trace:n}},h=s.timeoutMs??this.options.requestTimeoutMs;return new Promise((l,d)=>{const f=this.createPolicyDeadline(h,s.signal===void 0?[]:[s.signal],new Error(`Private Executor ${t} timed out after ${h}ms`)),m=u(()=>{const c=this.pending.get(r);c&&(this.pending.delete(r),f.close(),c.reject(f.signal.reason))},"onAbort");f.signal.addEventListener("abort",m,{once:!0}),this.pending.set(r,{deadline:f,epoch:e.epoch,method:t,reject:u(c=>{f.signal.removeEventListener("abort",m),d(c)},"reject"),resolve:u(c=>{f.signal.removeEventListener("abort",m),l(c)},"resolve")}),this.send(e,a).catch(c=>{const p=this.pending.get(r);p&&(this.pending.delete(r),f.close(),p.reject(c))})})}send(e,t){const{bytes:i}=E(t,S);return this.pendingSends>=this.options.maxPendingRequests||this.pendingSendBytes+i>this.options.maxPendingRequestBytes?Promise.reject(new ExecutorPrivateOverloadedError):this.active!==e||!e.child.connected||!e.child.send?Promise.reject(new ExecutorPrivateProcessExitedError):(this.pendingSends+=1,this.pendingSendBytes+=i,new Promise((s,r)=>{let n=!1;const a=u(h=>{n||(n=!0,this.pendingSends-=1,this.pendingSendBytes-=i,h?r(h):s())},"finish");try{e.child.send?.(t,h=>a(h))}catch(h){a(g(h))}}))}rejectPending(e,t){for(const[i,s]of this.pending)t!==void 0&&s.epoch!==t||(this.pending.delete(i),s.deadline.close(),s.reject(e))}terminateChild(e,t=this.shutdownBudget){if(e.terminationPromise)return e.terminationPromise;const i=t===void 0,s=t??this.createShutdownBudget(Math.min(Number.MAX_SAFE_INTEGER,this.options.termTimeoutMs*2));return e.terminationPromise=this.terminateChildOnce(e,s).finally(()=>{i&&s.deadline.close()}),e.terminationPromise}async terminateChildOnce(e,t){let i=!1,s;if(e.guardian){const n=this.remainingBeforeHandleReleaseReserve(t),a=Date.now()+n;try{await e.guardian.close({deadlineAt:a})}catch(h){i=!0,s=h}if(!i&&(e.guardianBound===!0||e.anchorPid!==void 0)){if(await this.waitForChildExit(e,this.remainingBeforeKillReserve(t)))return;const h=new Error("Private Executor did not exit after guardian cleanup");this.options.containment.trip(h);const l=[h];try{await this.terminateWithSignals(e,!0,t)}catch(d){l.push(...this.flattenCleanupFailure(d))}this.throwCleanupFailures(l,"Private Executor guardian cleanup did not reap its child")}}if(e.child.exitCode!==null||e.child.signalCode!==null){if(i)throw s;return}const r=[];i&&r.push(s);try{await this.terminateWithSignals(e,e.guardian!==void 0||this.options.allowStdio&&this.options.platform!=="win32",t)}catch(n){r.push(...this.flattenCleanupFailure(n))}this.throwCleanupFailures(r,"Private Executor guardian and child cleanup failed")}async terminateWithSignals(e,t,i){const s=[];try{e.child.disconnect?.()}catch(r){s.push(r)}for(const r of["SIGTERM","SIGKILL"]){if(e.child.exitCode!==null||e.child.signalCode!==null)break;const n=r==="SIGTERM"?this.remainingBeforeKillReserve(i):this.remainingBeforeHandleReleaseReserve(i);try{if(await this.killAndWait(e,r,n,t))break}catch(a){s.push(a)}}if(e.child.exitCode===null&&e.child.signalCode===null){const r=new Error("Private Executor process cleanup timed out");this.options.containment.trip(r),s.push(r);try{this.releaseChildHandles(e)}catch(n){s.push(...this.flattenCleanupFailure(n))}}this.throwCleanupFailures(s,"Private Executor child cleanup failed")}async killAndWait(e,t,i,s=!1){let r,n=!1;try{s||this.options.platform==="win32"?n=!e.child.kill(t):e.child.pid?process.kill(-e.child.pid,t):r=new Error(`Private Executor child has no PID for ${t}`)}catch(h){J(h)||(r=h)}const a=await this.waitForChildExit(e,i)||e.child.exitCode!==null||e.child.signalCode!==null;if(r!==void 0)throw r;if(n&&!a)throw new Error(`Private Executor child refused ${t}`);return a}async waitForChildExit(e,t){if(e.child.exitCode!==null||e.child.signalCode!==null)return!0;if(t<=0)return!1;let i;return Promise.race([e.exit.then(()=>!0),new Promise(s=>{i=setTimeout(()=>s(!1),t),i.unref?.()})]).finally(()=>{i&&clearTimeout(i)})}releaseChildHandles(e){const t=[],i=u(s=>{try{s()}catch(r){t.push(r)}},"attempt");e.child.connected&&i(()=>e.child.disconnect?.()),i(()=>e.child.channel?.unref()),i(()=>e.child.stdin?.destroy()),i(()=>e.child.stdout?.destroy()),i(()=>e.child.stderr?.destroy()),i(()=>e.child.unref()),this.throwCleanupFailures(t,"Private Executor child handles could not be released")}flattenCleanupFailure(e){return e instanceof AggregateError?e.errors:[e]}throwCleanupFailures(e,t){if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,t)}assertCurrentRegistration(e,t){if(!this.isCurrentRegistration(e,t))throw new Error(`MCP registration "${e}" was superseded`)}isCurrentRegistration(e,t){return this.registrations.has(e)&&this.isCurrentRegistrationRevision(e,t)}isCurrentRegistrationRevision(e,t){return this.registrationRevisions.get(e)===t}requireRegistration(e){const t=this.registrations.get(e);if(!t)throw new Error(`Unknown MCP registration "${e}"`);return t}requireRegistrationRevision(e){const t=this.registrationRevisions.get(e);if(t===void 0)throw new Error(`Unknown MCP registration "${e}"`);return t}async withRegistrationLock(e,t){const i=this.registrationTasks.get(e);let s;const r=new Promise(n=>{s=n});this.registrationTasks.set(e,r),i&&await i;try{return await t()}finally{s(),this.registrationTasks.get(e)===r&&this.registrationTasks.delete(e)}}createShutdownBudget(e,t){const i=Date.now(),s=i+e,r=t===void 0?s:Math.min(s,t),n=Math.max(1,Math.ceil(r-i)),a=new ExecutorPrivateShutdownTimeoutError(n);return{deadlineAt:r,deadline:R(n,[],a),timeoutError:a}}gracefulCloseBudgetMs(e,t=!1){if(!t)return this.remainingBeforeKillReserve(e);const i=this.remainingShutdownMs(e),s=Math.min(i,this.options.termTimeoutMs+se);return Math.max(0,i-s)}remainingBeforeKillReserve(e){const t=this.remainingShutdownMs(e);if(t<=1)return 0;const i=Math.min(this.options.termTimeoutMs,Math.max(1,Math.ceil(t/2)));return Math.max(0,t-i)}remainingBeforeHandleReleaseReserve(e){const t=this.remainingShutdownMs(e);if(t<=1)return 0;const i=Math.min(10,Math.max(1,Math.ceil(t/10)));return Math.max(0,t-i)}remainingShutdownMs(e){return Math.max(0,Math.ceil(e.deadlineAt-Date.now()))}async settleWithinShutdown(e,t,i=this.remainingShutdownMs(t)){const s=Math.min(this.remainingShutdownMs(t),Math.max(0,i));if(s<=0||t.deadline.signal.aborted)return e.catch(()=>{}),{status:"timed_out"};const r=R(s,[t.deadline.signal],t.timeoutError);return new Promise(n=>{let a=!1;const h=u(d=>{a||(a=!0,r.signal.removeEventListener("abort",l),r.close(),n(d))},"finish"),l=u(()=>h({status:"timed_out"}),"onAbort");if(r.signal.addEventListener("abort",l,{once:!0}),r.signal.aborted){l(),e.catch(()=>{});return}e.then(d=>h({status:"fulfilled",value:d}),d=>h({reason:d,status:"rejected"}))})}createPolicyDeadline(e,t,i){return this.processRuntime?.createPolicyDeadline(e,{signals:t,timeoutReason:i})??R(e,t,i)}readPolicyNow(){return this.processRuntime?.policyNow()??Date.now()}waitForPolicyDelay(e,t,i){return this.processRuntime?.policyDelay(e,t,i)??L(e,t)}waitForRestartBackoff(e,t){const i=t??new AbortController().signal;return this.processRuntime?this.processRuntime.policyBackoff(this.options.restartBackoffMs,e,b,i,"Executor restart backoff cancelled"):L(Math.min(b,this.options.restartBackoffMs*2**(e-1)),i)}assertAccepting(){if(this.stateValue==="closing"||this.stateValue==="closed")throw new Error(`Executor supervisor is ${this.stateValue}`);this.options.containment.assertHealthy()}isStopping(){return this.stateValue==="closing"||this.stateValue==="closed"}reportFailure(e){Promise.resolve().then(()=>this.options.onFailure?.(e)).catch(()=>{})}recordLifecycle(e){try{this.options.recordLifecycle?.(e)}catch{}}}
|
|
1
|
+
var L=Object.defineProperty;var u=(o,e)=>L(o,"name",{value:e,configurable:!0});import{fork as q,spawn as P}from"node:child_process";import{randomUUID as x}from"node:crypto";import v from"node:path";import{EXECUTOR_PRIVATE_MAX_MESSAGE_BYTES as S,EXECUTOR_PRIVATE_MAX_TELEMETRY_MESSAGE_BYTES as k,EXECUTOR_PRIVATE_PROTOCOL_VERSION as T,isExecutorPrivateCatalogNotification as B,isExecutorPrivateResponse as D,isExecutorPrivateResult as N,isExecutorPrivateReverseRequest as V,isExecutorPrivateTelemetryNotification as U,isExecutorPrivateTelemetryNotificationCandidate as H}from"#agent-harness-executor/private-protocol";import{currentHarnessTraceCarrier as j,parseHarnessTraceCarrier as z,withHarnessTraceContext as C}from"#agent-harness-executor/trace-context";import{DEFAULT_MCP_TOOLS_SYNC_TTL_MS as W}from"#agent-harness-executor/types";import{maybeCurrentHarnessProcessRuntime as I}from"../effect-runtime/process-runtime-context.js";import{normalizeError as g}from"../internal/errors.js";import{boundedStringifyJson as E}from"../protocol/bounded-json.js";import{applyNodeRuntimeEnvironment as G,resolveNodeRuntimeLaunch as M}from"../runtime/node-runtime.js";import{AGENT_HARNESS_PRIVATE_RUNTIME_ROLE as A,createPrivateRuntimeLaunchSpec as _,isAgentHarnessStandaloneBinary as X}from"../runtime/private-runtime-role.js";import{CodeBuddyProcessContainment as $}from"../runtime/process-containment.js";import{isMissingProcess as J}from"../runtime/process-tree.js";import{assertAgentHarnessProcessContainment as Y}from"../runtime/sfe-process-containment.js";import{measure as w}from"../telemetry/index.js";import{attachPosixStdioMcpGuardian as K,resolveStdioMcpContainment as Q}from"./stdio-guardian.js";const Z=3e4,ee=15e3,te=5e3,ie=3e3,se=1e3,re=1e4,ne=3e3,oe=1024,ae=8*1024*1024,he=5,ce=6e4,le=100,b=5e3,F=16;export class ExecutorPrivateProcessExitedError extends Error{static{u(this,"ExecutorPrivateProcessExitedError")}constructor(){super("Private Executor child exited unexpectedly"),this.name="ExecutorPrivateProcessExitedError"}}export class ExecutorPrivateProtocolError extends Error{static{u(this,"ExecutorPrivateProtocolError")}constructor(e){super(e),this.name="ExecutorPrivateProtocolError"}}export class ExecutorPrivateOverloadedError extends Error{static{u(this,"ExecutorPrivateOverloadedError")}constructor(){super("Private Executor IPC queue is overloaded"),this.name="ExecutorPrivateOverloadedError"}}class ue extends Error{static{u(this,"ExecutorPrivateOperationError")}constructor(e,t,i){super(i),this.code=e,this.retryable=t,this.name=e}}export class ExecutorPrivateStartupCleanupError extends AggregateError{static{u(this,"ExecutorPrivateStartupCleanupError")}constructor(e,t){super([e,t],"Private Executor startup and cleanup both failed"),this.startupFailure=e,this.cleanupFailure=t,this.name="ExecutorPrivateStartupCleanupError"}}export class ExecutorPrivateShutdownTimeoutError extends Error{static{u(this,"ExecutorPrivateShutdownTimeoutError")}constructor(e){super(`Private Executor cleanup timed out after ${e}ms`),this.timeoutMs=e,this._tag="ExecutorPrivateShutdownTimeoutError",this.name=this._tag}}function de(){return X()?process.execPath:v.resolve(import.meta.dirname,"../../executor/lib/capsule/entry.mjs")}u(de,"defaultChildEntryPath");const pe=Object.freeze(["ALL_PROXY","HTTP_PROXY","HTTPS_PROXY","LANG","LC_ALL","NODE_EXTRA_CA_CERTS","NODE_NO_WARNINGS","NO_PROXY","PATH","SSL_CERT_DIR","SSL_CERT_FILE","SystemRoot","TEMP","TMP","TMPDIR","TZ","WINDIR","http_proxy","https_proxy","all_proxy","no_proxy"]);function fe(o){const e=u(n=>{const a=n?.trim();if(a)try{const h=new URL(a.includes("://")?a:`http://${a}`);return h.protocol==="http:"||h.protocol==="https:"?h.toString():void 0}catch{return}},"normalize"),t=e(o.ALL_PROXY??o.all_proxy),i=e(o.HTTP_PROXY??o.http_proxy??t),s=e(o.HTTPS_PROXY??o.https_proxy??t??i),r=[...new Set([...(o.NO_PROXY??o.no_proxy??"").split(",").map(n=>n.trim()).filter(Boolean),"localhost","127.0.0.1","::1"])];return Object.freeze({...i===void 0?{}:{httpProxyUrl:i},...s===void 0?{}:{httpsProxyUrl:s},mode:"auto",noProxy:Object.freeze(r),revision:"environment"})}u(fe,"defaultExecutorProxyPolicy");export function createExecutorChildEnvironment(o=process.env,e=M()){const t={AGENT_HARNESS_PRIVATE_EXECUTOR:"1"};for(const i of pe){const s=o[i];s!==void 0&&(t[i]=s)}return G(t,e)}u(createExecutorChildEnvironment,"createExecutorChildEnvironment");export function createExecutorWindowsSpawnSpec(o,e){const{execArgv:t=process.execArgv,execPath:i=process.execPath,silent:s,...r}=e,a=_({entryPath:o,nodeRuntime:{environment:{},executable:i},role:A.executor}),h=a.args[0]===o;return{...{args:Object.freeze([...h?t:[],...a.args]),command:a.command},options:{...r,env:{...r.env},windowsHide:!0}}}u(createExecutorWindowsSpawnSpec,"createExecutorWindowsSpawnSpec");function me(o,e){Y();const t=createExecutorWindowsSpawnSpec(o,e);return P(t.command,[...t.args],t.options)}u(me,"spawnExecutorChildOnWindows");function ge(o,e,t,i){if(t==="win32")return me(o,e);const s=_({entryPath:o,nodeRuntime:i,role:A.executor});if(s.args[0]===o)return q(o,[],e);const{execArgv:r,execPath:n,silent:a,...h}=e;return P(s.command,[...s.args],h)}u(ge,"spawnExecutorChild");function we(o){const e=u((a,h,l)=>{const d=a??h;if(!Number.isSafeInteger(d)||d<=0)throw new RangeError(`${l} must be a positive integer`);return d},"positive"),t=u((a,h,l)=>{const d=a??h;if(!Number.isSafeInteger(d)||d<0)throw new RangeError(`${l} must be a non-negative integer`);return d},"nonNegative"),i=o.platform??process.platform,s=Q({platform:i,requested:o.allowStdio??!0,windowsProcessContainmentEnabled:o.windowsProcessContainmentEnabled,windowsJob:o.windowsJob}),r=o.nodeRuntime??M(),n=createExecutorChildEnvironment(o.environment,r);return{allowStdio:s.allowStdio,childEntryPath:o.childEntryPath??de(),closeTimeoutMs:e(o.closeTimeoutMs,te,"closeTimeoutMs"),containment:o.containment??new $,crashWindowMs:e(o.crashWindowMs,ce,"crashWindowMs"),environment:n,healthIntervalMs:t(o.healthIntervalMs,re,"healthIntervalMs"),healthTimeoutMs:e(o.healthTimeoutMs,ne,"healthTimeoutMs"),instanceId:o.instanceId??x(),maxCrashes:e(o.maxCrashes,he,"maxCrashes"),maxPendingRequestBytes:e(o.maxPendingRequestBytes,ae,"maxPendingRequestBytes"),maxPendingRequests:e(o.maxPendingRequests,oe,"maxPendingRequests"),nodeRuntime:r,toolsSyncTtlMs:o.toolsSyncTtlMs===null?null:e(o.toolsSyncTtlMs,W,"toolsSyncTtlMs"),onElicitation:o.onElicitation,...o.onFailure===void 0?{}:{onFailure:o.onFailure},platform:i,proxyPolicy:o.proxyPolicy??fe(n),...o.recordLifecycle===void 0?{}:{recordLifecycle:o.recordLifecycle},...o.recordEffectTelemetry===void 0?{}:{recordEffectTelemetry:o.recordEffectTelemetry},requestTimeoutMs:e(o.requestTimeoutMs,Z,"requestTimeoutMs"),restartBackoffMs:e(o.restartBackoffMs,le,"restartBackoffMs"),spawnChild:o.spawnChild??((a,h)=>ge(a,h,i,r)),startTimeoutMs:e(o.startTimeoutMs,ee,"startTimeoutMs"),...o.stdioGuardianEntryPath===void 0?{}:{stdioGuardianEntryPath:o.stdioGuardianEntryPath},stdioContainment:s.mode,...s.mode==="windows_native_job_object"?{windowsJob:s.windowsJob}:{},termTimeoutMs:e(o.termTimeoutMs,ie,"termTimeoutMs")}}u(we,"resolveOptions");function O(o,e){return e?.aborted?Promise.reject(e.reason):new Promise((t,i)=>{let s=!1;const r=u(h=>{s||(s=!0,clearTimeout(a),e?.removeEventListener("abort",n),h===void 0?t():i(h))},"finish"),n=u(()=>r(e?.reason),"onAbort"),a=setTimeout(()=>r(),o);a.unref?.(),e?.addEventListener("abort",n,{once:!0})})}u(O,"standaloneDelay");function R(o,e,t){const i=new AbortController,s=setTimeout(()=>i.abort(t),o);s.unref?.();const r=AbortSignal.any([...e,i.signal]),n=[];let a=!1;const h=u(()=>{if(!a){a=!0,clearTimeout(s);for(const[l,d]of n)l.removeEventListener("abort",d);n.length=0}},"close");for(const l of e)n.push([l,h]),l.addEventListener("abort",h,{once:!0});return Object.freeze({close:h,signal:r})}u(R,"standaloneDeadline");export class ExecutorProcessSupervisor{static{u(this,"ExecutorProcessSupervisor")}registerClientSource(e,t){if(this.assertAccepting(),this.clientSources.has(e))throw new Error("Duplicate Client MCP source");const i=t.subscribe(()=>{for(const s of this.registrations.values())s.transport.transport==="client"&&s.transport.sourceId===e&&this.invalidateCatalog(s.registrationId)});return this.clientSources.set(e,{source:t,release:i}),()=>{if(this.clientSources.get(e)?.source===t){this.clientSources.delete(e),i();for(const r of this.clientRequests.values())r.sourceId===e&&r.controller.abort(new Error("Client MCP source closed"))}}}invalidateCatalog(e){if(this.isStopping()||!this.registrations.has(e))return;const t=this.catalogRefreshes.get(e);if(t){t.dirty=!0;return}const i={dirty:!0,promise:Promise.resolve()};i.promise=Promise.resolve().then(async()=>{do{if(i.dirty=!1,this.isStopping()||!this.registrations.has(e))return;await this.refreshRegistration(e)}while(i.dirty)}).catch(()=>{}).finally(()=>{this.catalogRefreshes.delete(e),this.scheduleCatalogRefresh(e)}),this.catalogRefreshes.set(e,i)}scheduleCatalogRefresh(e){if(clearTimeout(this.catalogTimers.get(e)),this.catalogTimers.delete(e),this.isStopping()||!this.registrations.has(e)||this.options.toolsSyncTtlMs===null)return;const t=setTimeout(()=>{this.catalogTimers.delete(e),this.invalidateCatalog(e)},Math.min(this.options.toolsSyncTtlMs,2147483647));t.unref(),this.catalogTimers.set(e,t)}constructor(e){if(this.crashTimes=[],this.failureTasks=new Set,this.fuseOpenAttempt=0,this.fuseState="closed",this.nextRequestId=1,this.nextRegistrationRevision=1,this.pending=new Map,this.pendingSendBytes=0,this.pendingSends=0,this.proxyTask=Promise.resolve(),this.registrationRevisions=new Map,this.registrationTasks=new Map,this.restartAttempt=0,this.shutdownController=new AbortController,this.registrations=new Map,this.snapshots=new Map,this.clientSources=new Map,this.clientRequests=new Map,this.catalogTimers=new Map,this.catalogRefreshes=new Map,this.snapshotListeners=new Set,this.stateValue="idle",this.options=we(e),this.proxyPolicy=this.options.proxyPolicy,this.processRuntime=e.processRuntime??I(),this.processRuntime===void 0&&process.env.NODE_ENV!=="test")throw new Error("Executor supervisor requires the process-owned Effect runtime");this.releaseProcessOwnership=this.processRuntime?.addFinalizer(()=>this.close(new Error("Agent Harness process runtime is closing")));const t=this.processRuntime?.shutdownSignal;if(t){const i=u(()=>{this.close(t.reason).catch(()=>{})},"onProcessShutdown");t.addEventListener("abort",i,{once:!0}),this.releaseProcessShutdownListener=()=>t.removeEventListener("abort",i)}}get runtimeEpoch(){return this.active?.epoch}get state(){return this.stateValue}async start(){await this.ensureReady()}async configureProxy(e){this.assertAccepting(),this.proxyPolicy=e;const t=this.proxyTask.then(()=>this.reconcileProxyPolicy());this.proxyTask=t.catch(()=>{}),await t}subscribeSnapshots(e){return this.snapshotListeners.add(e),()=>this.snapshotListeners.delete(e)}async upsertRegistration(e,t){this.assertAccepting();const i=this.nextRegistrationRevision++;this.registrations.set(e.registrationId,e),this.registrationRevisions.set(e.registrationId,i);try{return await this.ensureReady(),await this.withRegistrationLock(e.registrationId,async()=>{if(this.assertCurrentRegistration(e.registrationId,i),t?.signal?.aborted)throw t.signal.reason;const s=this.active,r=this.snapshots.get(e.registrationId);if(this.stateValue==="ready"&&s?.initialized===!0&&s.child.connected&&s.child.exitCode===null&&s.child.signalCode===null&&s.appliedRegistrationRevisions.get(e.registrationId)===i&&r?.status==="available"&&r?.registrationId===e.registrationId&&r?.runtimeEpoch===s.epoch)return r;const n=await w("registrationReconcile",()=>this.request("registration/upsert",{registration:e},t));return this.assertCurrentRegistration(e.registrationId,i),this.setSnapshot(e.registrationId,n),n})}catch(s){throw this.isCurrentRegistration(e.registrationId,i)&&this.deleteSnapshot(e.registrationId),s}}async startOAuth(e,t,i){this.requireRegistration(e);const s=this.requireRegistrationRevision(e);return await this.ensureReady(),this.withRegistrationLock(e,async()=>{this.assertCurrentRegistration(e,s);const r=this.active;try{return await this.request("oauth/start",{registrationId:e,input:t},i)}catch(n){throw r===this.active&&!this.isStopping()&&await this.request("oauth/cancel",{registrationId:e}).catch(()=>{}),n}})}async completeOAuth(e,t,i,s){return this.mutateOAuth(e,()=>this.request("oauth/complete",{registrationId:e,state:t,code:i},s))}async cancelOAuth(e,t,i){this.requireRegistration(e),await this.withRegistrationLock(e,()=>this.request("oauth/cancel",{registrationId:e,state:t},i))}async logoutOAuth(e,t){return this.mutateOAuth(e,()=>this.request("oauth/logout",{registrationId:e},t))}async mutateOAuth(e,t){this.requireRegistration(e);const i=this.requireRegistrationRevision(e);return this.withRegistrationLock(e,async()=>{this.assertCurrentRegistration(e,i);const s=await t();return this.assertCurrentRegistration(e,i),this.setSnapshot(e,s),s})}async refreshRegistration(e,t){this.requireRegistration(e);const i=this.requireRegistrationRevision(e);return await this.ensureReady(),this.withRegistrationLock(e,async()=>{this.assertCurrentRegistration(e,i);const s=await this.request("registration/refresh",{registrationId:e},t);return this.assertCurrentRegistration(e,i),this.setSnapshot(e,s),s})}getSnapshot(e){return this.snapshots.get(e)}async removeRegistration(e,t){const i=this.nextRegistrationRevision++;this.registrations.delete(e),this.registrationRevisions.set(e,i),this.deleteSnapshot(e),this.registrations.size===0&&this.cancelFuseRecovery(new Error("Executor fuse recovery is no longer needed")),!(this.stateValue==="closed"||this.stateValue==="closing")&&(await this.withRegistrationLock(e,async()=>{if(!this.isCurrentRegistrationRevision(e,i)||this.isStopping())return;const s=this.active;if(s?.initialized)try{await this.requestOnActive(s,"registration/remove",{registrationId:e},t),s.appliedRegistrationRevisions.delete(e)}catch(r){if(this.active===s&&!this.isStopping())throw this.handleChildFailure(s,r),r}}),this.isCurrentRegistrationRevision(e,i)&&(this.deleteSnapshot(e),this.registrationRevisions.delete(e)))}async callTool(e,t,i,s,r={}){this.requireRegistration(e);const n=this.requireRegistrationRevision(e);await this.ensureReady(),this.assertCurrentRegistration(e,n);let a=!1;const h=u(()=>{a||(a=!0,this.request("tool/cancel",{invocationId:t},{timeoutMs:Math.min(r.timeoutMs??this.options.requestTimeoutMs,2e3)}).catch(()=>{}))},"cancelInvocation");let l;r.signal&&(l=h,r.signal.addEventListener("abort",l,{once:!0}));try{return await this.request("tool/call",{args:s,executorAddress:i,invocationId:t,registrationId:e},r)}catch(d){throw h(),d}finally{l&&r.signal?.removeEventListener("abort",l)}}async close(e){return this.closePromise??=this.closeInternal(e),this.closePromise}async closeInternal(e){for(const c of this.catalogTimers.values())clearTimeout(c);this.catalogTimers.clear();for(const c of this.clientRequests.values())c.controller.abort(e);for(const c of this.clientSources.values())c.release();if(this.clientSources.clear(),this.stateValue==="closed")return;const t=e??new Error("Executor supervisor is closing"),i=this.createShutdownBudget(this.options.closeTimeoutMs,this.processRuntime?.shutdownDeadlineAt),{timeoutError:s}=i;this.shutdownBudget=i,this.stateValue="closing",this.cancelFuseRecovery(t),this.shutdownController.abort(t);const r=[],n=[],a=u((c,f=r)=>{c===s&&(r.includes(s)||n.includes(s))||f.push(c)},"addFailure"),h=u(async(c,f=r)=>{const y=await this.settleWithinShutdown(c,i);y.status==="rejected"?a(y.reason,f):y.status==="timed_out"&&a(s,f)},"attempt");this.clearHealthTimer();const l=this.active,d=this.startPromise;if(this.rejectPending(t),l&&!d&&l.initialized){const c=this.gracefulCloseBudgetMs(i,l.guardian!==void 0);c>0&&await h(this.requestOnActive(l,"runtime/close",{},{signal:i.deadline.signal,timeoutMs:c}))}if(l)try{await this.terminateChild(l,i)}catch(c){a(c,n)}if(d){const c=await this.settleWithinShutdown(d,i);c.status==="rejected"?c.reason instanceof ExecutorPrivateStartupCleanupError&&r.push(...this.flattenCleanupFailure(c.reason.cleanupFailure)):c.status==="timed_out"&&a(s)}const p=await this.settleWithinShutdown(Promise.allSettled([...this.failureTasks,...this.registrationTasks.values(),...[...this.catalogRefreshes.values()].map(c=>c.promise)]),i);if(p.status==="fulfilled")for(const c of p.value)c.status==="rejected"&&r.push(c.reason);else p.status==="rejected"?r.push(p.reason):a(s);r.push(...n);const m=this.active;if(m&&(m!==l||m.child.exitCode===null&&m.child.signalCode===null))try{await this.terminateChild(m,i)}catch(c){a(c)}i.deadline.signal.aborted&&a(s),this.active=void 0,this.recoveryPromise=void 0,this.startPromise=void 0,this.registrations.clear(),this.registrationRevisions.clear(),this.registrationTasks.clear();for(const c of this.snapshots.keys())this.deleteSnapshot(c);if(this.snapshotListeners.clear(),this.stateValue="closed",this.releaseProcessShutdownListener?.(),this.releaseProcessOwnership?.(),i.deadline.close(),r.length>0){const c=r.length===1?r[0]:new AggregateError(r,"Private Executor cleanup failed"),f=m??l;throw this.recordLifecycle({component:"executor",error:c,phase:"cleanup",...f===void 0?{}:{process:{exitCode:f.child.exitCode,pid:f.child.pid,signal:f.child.signalCode}},reason:"cleanup_failed",state:"shutdown_failed"}),c}}async ensureReady(){for(;;){if(this.assertAccepting(),this.stateValue==="ready"&&this.active)return;if(this.fuseState!=="closed")throw new Error(`Executor supervisor fuse is ${this.fuseState}; recovery is pending`);const e=this.recoveryPromise;if(!e)break;await e}await this.startWithoutRecoveryWait()}async startWithoutRecoveryWait(e){this.assertAccepting();const t=[this.shutdownController.signal];this.processRuntime?.shutdownSignal&&t.push(this.processRuntime.shutdownSignal),e&&t.push(e);const i=t.length===1?t[0]:AbortSignal.any(t);if(i.aborted)throw i.reason;if(this.stateValue==="ready"&&this.active)return;const s=this.startPromise??this.startChild(i);this.startPromise=s;try{await s}finally{this.startPromise===s&&(this.startPromise=void 0)}}async startChild(e){if(this.options.containment.assertHealthy(),e?.aborted||(this.stateValue=this.stateValue==="idle"?"starting":"restarting",this.restartAttempt>0&&await this.waitForRestartBackoff(this.restartAttempt,e),this.assertAccepting(),e?.aborted))throw e.reason;const t=x(),i=this.options.spawnChild(this.options.childEntryPath,{cwd:v.dirname(this.options.childEntryPath),detached:this.options.platform!=="win32",env:this.options.environment,execArgv:[],execPath:this.options.nodeRuntime.executable,serialization:"json",stdio:["ignore","ignore","pipe","ipc"]});if(!i.pid||!i.send)throw i.kill(),new Error("Private Executor child did not expose PID and IPC");const s=i.pid;i.stderr?.resume();const r={appliedRegistrationRevisions:new Map,child:i,epoch:t,exit:i.exitCode!==null||i.signalCode!==null?Promise.resolve():new Promise(n=>{i.once("exit",()=>n())}),initialized:!1};this.active=r,i.on("message",n=>this.handleMessage(r,n)),i.once("error",n=>this.handleChildFailure(r,n)),i.once("exit",()=>{this.isStopping()||this.handleChildFailure(r,new ExecutorPrivateProcessExitedError)}),i.once("disconnect",()=>{this.isStopping()&&this.handleChildFailure(r,new ExecutorPrivateProcessExitedError)});try{if(this.options.windowsJob&&!this.options.windowsJob.isProcessInJob(s))throw new Error("Private Executor did not inherit the host Windows Job");this.options.stdioContainment==="posix_guardian"&&await w("guardianBind",async()=>{const h=await K({...this.options.stdioGuardianEntryPath===void 0?{}:{childEntryPath:this.options.stdioGuardianEntryPath},containment:this.options.containment,...e===void 0?{}:{signal:e},shutdownDeadlineAt:u(()=>this.processRuntime?.shutdownDeadlineAt,"shutdownDeadlineAt"),targetProcessGroupId:s,termTimeoutMs:this.options.termTimeoutMs});if(r.guardian=h,e?.aborted||this.isStopping())throw e?.reason??new Error("Executor supervisor is closing");await h.bindAnchor(s),r.guardianBound=!0});const n=this.proxyPolicy,a=await w("executorInitialize",()=>this.requestOnActive(r,"runtime/initialize",{allowStdio:this.options.allowStdio,proxy:n,protocolVersion:T,runtimeEpoch:t,stdioContainment:this.options.stdioContainment,...this.options.windowsJob===void 0?{}:{windowsJobAddonPath:this.options.windowsJob.addonPath},...!this.options.allowStdio||r.guardian===void 0?{}:{stdioGuardianPid:r.guardian.guardianPid},tenantId:this.options.instanceId},{...e===void 0?{}:{signal:e},timeoutMs:this.options.startTimeoutMs}));if(a.protocolVersion!==T||a.runtimeEpoch!==t||a.proxyRevision!==n.revision||(this.options.stdioContainment==="posix_guardian"?a.stdioAnchorPid===void 0||a.stdioAnchorPid<=0:a.stdioAnchorPid!==void 0))throw new ExecutorPrivateProtocolError("Private Executor initialize response did not match its epoch");r.anchorPid=a.stdioAnchorPid,r.appliedProxyRevision=a.proxyRevision,await this.reconcileProxyPolicyOnActive(r,e),r.initialized=!0,await w("registrationReconcile",()=>this.reconcileRegistrationsAndCommitReady(r,e))}catch(n){let a=!1,h;try{await this.terminateChild(r)}catch(l){a=!0,h=l}throw this.active===r&&(this.active=void 0),!this.isStopping()&&this.fuseState==="closed"&&(this.stateValue="idle"),a?(this.recordLifecycle({component:"executor",error:h,phase:"cleanup",process:{exitCode:r.child.exitCode,pid:r.child.pid,signal:r.child.signalCode},reason:"cleanup_failed",state:"shutdown_failed"}),new ExecutorPrivateStartupCleanupError(n,h)):n}}async reconcileProxyPolicy(){const e=this.active;e?.initialized!==!0||this.isStopping()||await this.reconcileProxyPolicyOnActive(e)}async reconcileProxyPolicyOnActive(e,t){for(let i=0;i<F;i+=1){if(this.active!==e||this.isStopping())return;const s=this.proxyPolicy;if(e.appliedProxyRevision===s.revision)return;const r=await this.requestOnActive(e,"runtime/proxy-configure",{proxy:s},{...t===void 0?{}:{signal:t},timeoutMs:this.options.requestTimeoutMs});if(r.proxyRevision!==s.revision)throw new ExecutorPrivateProtocolError("Private Executor proxy revision did not match its request");e.appliedProxyRevision=r.proxyRevision}throw new ExecutorPrivateProtocolError("Private Executor proxy policy did not converge")}async reconcileRegistrationsAndCommitReady(e,t){for(let i=0;i<F;i+=1){const s=new Set([...e.appliedRegistrationRevisions.keys(),...this.registrations.keys()]);for(const r of s)await this.withRegistrationLock(r,async()=>{if(this.active!==e||this.isStopping()||t?.aborted)throw t?.reason??new ExecutorPrivateProcessExitedError;const n=this.registrations.get(r),a=this.registrationRevisions.get(r),h=e.appliedRegistrationRevisions.get(r);if(n&&a!==void 0){if(h===a)return;const l=await this.requestOnActive(e,"registration/upsert",{registration:n},t===void 0?{}:{signal:t});e.appliedRegistrationRevisions.set(r,a),this.isCurrentRegistration(r,a)&&this.setSnapshot(r,l);return}h!==void 0&&(await this.requestOnActive(e,"registration/remove",{registrationId:r},t===void 0?{}:{signal:t}),e.appliedRegistrationRevisions.delete(r),this.deleteSnapshot(r))});if(this.active!==e||this.isStopping()||t?.aborted)throw t?.reason??new ExecutorPrivateProcessExitedError;if(this.registrationsConverged(e)){this.restartAttempt=0,this.stateValue="ready",this.scheduleHealthCheck(e);return}}throw new ExecutorPrivateProtocolError("Private Executor registration state did not converge during startup")}registrationsConverged(e){if(e.appliedRegistrationRevisions.size!==this.registrations.size)return!1;for(const t of this.registrations.keys()){const i=this.registrationRevisions.get(t);if(i===void 0||e.appliedRegistrationRevisions.get(t)!==i)return!1}return!0}handleMessage(e,t){if(this.active===e){if(H(t)){try{E(t,k)}catch{return}if(!U(t)||t.params.runtimeEpoch!==e.epoch)return;try{const{signal:i}=t.params;i.kind==="log"?this.options.recordEffectTelemetry?.log(i.value):i.kind==="metrics"?this.options.recordEffectTelemetry?.metrics(Object.freeze({...i.value,runtimeEpoch:e.epoch})):this.options.recordEffectTelemetry?.span(i.value)}catch{}return}try{E(t,S)}catch(i){this.failProtocol(e,new ExecutorPrivateProtocolError(`Private Executor sent an invalid or oversized IPC payload: ${g(i).message}`));return}if(D(t)){if(t.runtimeEpoch!==e.epoch)return;if(typeof t.id!="number"){this.failProtocol(e,new ExecutorPrivateProtocolError("Private Executor response used an invalid request id"));return}const i=this.pending.get(t.id);if(!i||i.epoch!==e.epoch)return;if(this.pending.delete(t.id),i.deadline.close(),"error"in t){const s=new ue(t.error.data?.code??"ExecutorPrivateError",t.error.data?.retryable,t.error.message);i.reject(s)}else{if(!N(i.method,t.result)){i.reject(new ExecutorPrivateProtocolError(`Private Executor returned an invalid ${i.method} result`)),this.failProtocol(e,new ExecutorPrivateProtocolError("Private Executor response violated its method contract"));return}i.resolve(t.result)}return}if(B(t)){if(t.params.runtimeEpoch!==e.epoch)return;if(t.method==="client-mcp/cancel")this.clientRequests.get(t.params.requestId)?.controller.abort(new Error("MCP request cancelled"));else for(const i of this.registrations.values())i.executorSlug===t.params.integration&&i.connectionName===t.params.connection&&this.invalidateCatalog(i.registrationId);return}if(V(t)){if(t.params.runtimeEpoch!==e.epoch)return;this.handleReverseRequest(e,t);return}this.failProtocol(e,new ExecutorPrivateProtocolError("Private Executor sent an unknown IPC message"))}}async handleClientMcpRequest(e,t){const i=new AbortController;try{const s=this.clientSources.get(t.params.sourceId)?.source;if(!s||this.clientRequests.size>=this.options.maxPendingRequests||this.clientRequests.has(t.id)||![...this.registrations.values()].some(n=>n.transport.transport==="client"&&n.transport.sourceId===t.params.sourceId))throw new Error("Client MCP source unavailable");this.clientRequests.set(t.id,{sourceId:t.params.sourceId,epoch:e.epoch,controller:i});const r=await s.request(t.params.method,t.params.params,i.signal);if(this.active!==e||i.signal.aborted)return;await this.send(e,{id:t.id,jsonrpc:"2.0",result:r,runtimeEpoch:e.epoch})}catch{await this.send(e,{id:t.id,jsonrpc:"2.0",error:{code:-32e3,message:"Client MCP request failed"},runtimeEpoch:e.epoch}).catch(()=>{})}finally{this.clientRequests.delete(t.id)}}async handleReverseRequest(e,t){if(t.method==="client-mcp/request")return this.handleClientMcpRequest(e,t);try{const i=t.trace===void 0?void 0:z(t.trace),s=await C(i,()=>this.options.onElicitation({invocationId:t.params.invocationId,request:t.params.request,runtimeEpoch:e.epoch}));await this.send(e,{id:t.id,jsonrpc:"2.0",result:s,runtimeEpoch:e.epoch})}catch{await this.send(e,{error:{code:-32e3,message:"Elicitation was cancelled"},id:t.id,jsonrpc:"2.0",runtimeEpoch:e.epoch}).catch(()=>{})}}failProtocol(e,t){this.handleChildFailure(e,t)}handleChildFailure(e,t){if(this.active!==e)return;this.active=void 0;for(const n of this.clientRequests.values())n.epoch===e.epoch&&n.controller.abort(t);if(this.clearHealthTimer(),this.rejectPending(t,e.epoch),this.stateValue==="closing"||this.stateValue==="closed")return;const i=g(t);if(this.fuseState==="half_open"){const n=this.recordHalfOpenFailure(e,i).catch(()=>{});this.failureTasks.add(n),n.finally(()=>this.failureTasks.delete(n)).catch(()=>{}),this.reportFailure(i);return}this.stateValue="idle";const r=this.finishChildFailure(e,i).catch(n=>this.reportFailure(g(n))).catch(()=>{}).then(()=>{});this.recoveryPromise=r,this.failureTasks.add(r),r.then(()=>{this.failureTasks.delete(r),this.recoveryPromise===r&&(this.recoveryPromise=void 0,this.fuseRecoveryController=void 0)}).catch(()=>{}),this.reportFailure(i)}async finishChildFailure(e,t){const i=this.readPolicyNow();for(this.crashTimes.push(i);this.crashTimes.length>0&&this.crashTimes[0]<i-this.options.crashWindowMs;)this.crashTimes.shift();const s=this.crashTimes.length>this.options.maxCrashes;s?this.openFuse(e.epoch,t,e):(this.restartAttempt+=1,this.stateValue="idle",this.publishUnavailable(e.epoch,!1),this.registrations.size>0&&this.recordLifecycle({component:"executor",counts:{attempt:this.restartAttempt,failuresInWindow:this.crashTimes.length},error:t,phase:"recovery",process:{exitCode:e.child.exitCode,pid:e.child.pid,signal:e.child.signalCode},reason:t instanceof ExecutorPrivateProcessExitedError?"process_exit":t instanceof ExecutorPrivateProtocolError?"protocol_error":"process_error",state:"restarting"}));const r=s?new AbortController:void 0;r&&(this.fuseRecoveryController=r),await this.recoverAfterChildFailure(e,s,r)}async recordHalfOpenFailure(e,t){const i=this.readPolicyNow();for(this.crashTimes.push(i);this.crashTimes.length>0&&this.crashTimes[0]<i-this.options.crashWindowMs;)this.crashTimes.shift();this.openFuse(e.epoch,t,e)}async recoverAfterChildFailure(e,t,i){try{await this.terminateChild(e)}catch(r){throw this.recordLifecycle({component:"executor",error:r,phase:"cleanup",process:{exitCode:e.child.exitCode,pid:e.child.pid,signal:e.child.signalCode},reason:"cleanup_failed",state:"shutdown_failed"}),r}const s=this.startPromise;if(s&&await s.catch(()=>{}),this.isStopping()||this.registrations.size===0){t&&!this.isStopping()&&this.closeUnusedFuse();return}if(!t){await this.startWithoutRecoveryWait();return}if(!i)throw new Error("Executor fuse recovery omitted its controller");await this.recoverOpenFuse(i.signal)}async recoverOpenFuse(e){let t=e;for(;!this.isStopping();){if(t.aborted){const i=this.renewFuseRecoveryAfterCancellation(t);if(!i)return;t=i}if(this.registrations.size===0){this.closeUnusedFuse();return}this.fuseState="open",this.stateValue="failed";try{await this.waitForRestartBackoff(Math.max(1,this.fuseOpenAttempt),t)}catch(i){if(t.aborted){const s=this.renewFuseRecoveryAfterCancellation(t);if(!s)return;t=s;continue}if(this.isStopping())return;throw i}if(this.isStopping()||this.registrations.size===0){this.registrations.size===0&&!this.isStopping()&&this.closeUnusedFuse();return}this.fuseState="half_open",this.stateValue="restarting";try{if(await this.startWithoutRecoveryWait(t),this.fuseState==="half_open"&&this.state==="ready"&&this.active){this.closeFuse();return}this.fuseState==="half_open"&&this.openFuse()}catch(i){if(t.aborted){const s=this.renewFuseRecoveryAfterCancellation(t);if(!s)return;t=s;continue}if(this.isStopping())return;this.fuseState==="half_open"&&this.openFuse(),this.reportFailure(g(i))}}}renewFuseRecoveryAfterCancellation(e){if(this.isStopping())return;if(this.registrations.size===0){this.closeUnusedFuse();return}const t=this.fuseRecoveryController;if(t&&t.signal!==e&&!t.signal.aborted)return t.signal;const i=new AbortController;return this.fuseRecoveryController=i,i.signal}openFuse(e,t,i){const s=this.fuseState!=="open";this.fuseState!=="open"&&(this.fuseOpenAttempt+=1),this.fuseState="open",this.stateValue="failed",this.publishUnavailable(e,!0),s&&this.recordLifecycle({component:"executor",counts:{attempt:this.fuseOpenAttempt,failuresInWindow:this.crashTimes.length},...t===void 0?{}:{error:t},phase:"recovery",...i===void 0?{}:{process:{exitCode:i.child.exitCode,pid:i.child.pid,signal:i.child.signalCode}},reason:t instanceof ExecutorPrivateProcessExitedError?"process_exit":t instanceof ExecutorPrivateProtocolError?"protocol_error":"recovery_failed",state:"fused"})}closeFuse(){this.fuseState="closed",this.fuseOpenAttempt=0,this.crashTimes.length=0,this.restartAttempt=0,this.stateValue="ready"}closeUnusedFuse(){this.fuseState="closed",this.fuseOpenAttempt=0,this.crashTimes.length=0,this.restartAttempt=0,this.stateValue="idle"}cancelFuseRecovery(e){this.fuseRecoveryController?.abort(e)}publishUnavailable(e,t){for(const[i,s]of this.snapshots)this.setSnapshot(i,{error:{code:t?"executor_failed":"executor_restarting",message:t?"MCP runtime exceeded its restart limit; recovery is pending":"MCP runtime is restarting",retryable:!0},generation:s.generation+1,registrationId:i,runtimeEpoch:e??s.runtimeEpoch,status:"unavailable",tools:[]})}setSnapshot(e,t){this.snapshots.set(e,t),this.scheduleCatalogRefresh(e),this.publishSnapshot(e,t)}deleteSnapshot(e){clearTimeout(this.catalogTimers.get(e)),this.catalogTimers.delete(e),this.snapshots.delete(e)&&this.publishSnapshot(e,void 0)}publishSnapshot(e,t){for(const i of this.snapshotListeners)try{i(e,t)}catch{}}request(e,t,i){const s=this.active;return!s||this.stateValue!=="ready"?Promise.reject(new Error("Private Executor is not ready")):this.requestOnActive(s,e,t,i)}scheduleHealthCheck(e){if(this.clearHealthTimer(),this.options.healthIntervalMs===0)return;const t=new AbortController,i={close:u(()=>t.abort(new Error("Executor health delay completed")),"close")};this.healthTimer=i,C(void 0,()=>{this.waitForPolicyDelay(this.options.healthIntervalMs,t.signal,"Executor health delay cancelled").then(()=>{if(this.healthTimer===i)return this.healthTimer=void 0,this.checkHealth(e)}).catch(s=>{this.healthTimer===i&&(this.healthTimer=void 0),!t.signal.aborted&&!this.isStopping()&&this.failProtocol(e,g(s))})})}async checkHealth(e){if(!(this.active!==e||this.stateValue!=="ready")){try{const t=await this.requestOnActive(e,"runtime/health",{},{timeoutMs:this.options.healthTimeoutMs});if(t.status!=="ready"||t.runtimeEpoch!==e.epoch||t.stdioAnchorPid!==e.anchorPid)throw new ExecutorPrivateProtocolError("Private Executor health response did not match its epoch")}catch(t){this.active===e&&!this.isStopping()&&this.failProtocol(e,g(t));return}this.active===e&&this.stateValue==="ready"&&this.scheduleHealthCheck(e)}}clearHealthTimer(){this.healthTimer&&(this.healthTimer.close(),this.healthTimer=void 0)}requestOnActive(e,t,i,s={}){if(s.signal?.aborted)return Promise.reject(s.signal.reason);if(this.pending.size>=this.options.maxPendingRequests)return Promise.reject(new ExecutorPrivateOverloadedError);const r=this.nextRequestId++,n=j(),a={id:r,jsonrpc:"2.0",method:t,params:i,...n===void 0?{}:{trace:n}},h=s.timeoutMs??this.options.requestTimeoutMs;return new Promise((l,d)=>{const p=this.createPolicyDeadline(h,s.signal===void 0?[]:[s.signal],new Error(`Private Executor ${t} timed out after ${h}ms`)),m=u(()=>{const c=this.pending.get(r);c&&(this.pending.delete(r),p.close(),c.reject(p.signal.reason))},"onAbort");p.signal.addEventListener("abort",m,{once:!0}),this.pending.set(r,{deadline:p,epoch:e.epoch,method:t,reject:u(c=>{p.signal.removeEventListener("abort",m),d(c)},"reject"),resolve:u(c=>{p.signal.removeEventListener("abort",m),l(c)},"resolve")}),this.send(e,a).catch(c=>{const f=this.pending.get(r);f&&(this.pending.delete(r),p.close(),f.reject(c))})})}send(e,t){const{bytes:i}=E(t,S);return this.pendingSends>=this.options.maxPendingRequests||this.pendingSendBytes+i>this.options.maxPendingRequestBytes?Promise.reject(new ExecutorPrivateOverloadedError):this.active!==e||!e.child.connected||!e.child.send?Promise.reject(new ExecutorPrivateProcessExitedError):(this.pendingSends+=1,this.pendingSendBytes+=i,new Promise((s,r)=>{let n=!1;const a=u(h=>{n||(n=!0,this.pendingSends-=1,this.pendingSendBytes-=i,h?r(h):s())},"finish");try{e.child.send?.(t,h=>a(h))}catch(h){a(g(h))}}))}rejectPending(e,t){for(const[i,s]of this.pending)t!==void 0&&s.epoch!==t||(this.pending.delete(i),s.deadline.close(),s.reject(e))}terminateChild(e,t=this.shutdownBudget){if(e.terminationPromise)return e.terminationPromise;const i=t===void 0,s=t??this.createShutdownBudget(Math.min(Number.MAX_SAFE_INTEGER,this.options.termTimeoutMs*2));return e.terminationPromise=this.terminateChildOnce(e,s).finally(()=>{i&&s.deadline.close()}),e.terminationPromise}async terminateChildOnce(e,t){let i=!1,s;if(e.guardian){const n=this.remainingBeforeHandleReleaseReserve(t),a=Date.now()+n;try{await e.guardian.close({deadlineAt:a})}catch(h){i=!0,s=h}if(!i&&(e.guardianBound===!0||e.anchorPid!==void 0)){if(await this.waitForChildExit(e,this.remainingBeforeKillReserve(t)))return;const h=new Error("Private Executor did not exit after guardian cleanup");this.options.containment.trip(h);const l=[h];try{await this.terminateWithSignals(e,!0,t)}catch(d){l.push(...this.flattenCleanupFailure(d))}this.throwCleanupFailures(l,"Private Executor guardian cleanup did not reap its child")}}if(e.child.exitCode!==null||e.child.signalCode!==null){if(i)throw s;return}const r=[];i&&r.push(s);try{await this.terminateWithSignals(e,e.guardian!==void 0||this.options.allowStdio&&this.options.platform!=="win32",t)}catch(n){r.push(...this.flattenCleanupFailure(n))}this.throwCleanupFailures(r,"Private Executor guardian and child cleanup failed")}async terminateWithSignals(e,t,i){const s=[];try{e.child.disconnect?.()}catch(r){s.push(r)}for(const r of["SIGTERM","SIGKILL"]){if(e.child.exitCode!==null||e.child.signalCode!==null)break;const n=r==="SIGTERM"?this.remainingBeforeKillReserve(i):this.remainingBeforeHandleReleaseReserve(i);try{if(await this.killAndWait(e,r,n,t))break}catch(a){s.push(a)}}if(e.child.exitCode===null&&e.child.signalCode===null){const r=new Error("Private Executor process cleanup timed out");this.options.containment.trip(r),s.push(r);try{this.releaseChildHandles(e)}catch(n){s.push(...this.flattenCleanupFailure(n))}}this.throwCleanupFailures(s,"Private Executor child cleanup failed")}async killAndWait(e,t,i,s=!1){let r,n=!1;try{s||this.options.platform==="win32"?n=!e.child.kill(t):e.child.pid?process.kill(-e.child.pid,t):r=new Error(`Private Executor child has no PID for ${t}`)}catch(h){J(h)||(r=h)}const a=await this.waitForChildExit(e,i)||e.child.exitCode!==null||e.child.signalCode!==null;if(r!==void 0)throw r;if(n&&!a)throw new Error(`Private Executor child refused ${t}`);return a}async waitForChildExit(e,t){if(e.child.exitCode!==null||e.child.signalCode!==null)return!0;if(t<=0)return!1;let i;return Promise.race([e.exit.then(()=>!0),new Promise(s=>{i=setTimeout(()=>s(!1),t),i.unref?.()})]).finally(()=>{i&&clearTimeout(i)})}releaseChildHandles(e){const t=[],i=u(s=>{try{s()}catch(r){t.push(r)}},"attempt");e.child.connected&&i(()=>e.child.disconnect?.()),i(()=>e.child.channel?.unref()),i(()=>e.child.stdin?.destroy()),i(()=>e.child.stdout?.destroy()),i(()=>e.child.stderr?.destroy()),i(()=>e.child.unref()),this.throwCleanupFailures(t,"Private Executor child handles could not be released")}flattenCleanupFailure(e){return e instanceof AggregateError?e.errors:[e]}throwCleanupFailures(e,t){if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,t)}assertCurrentRegistration(e,t){if(!this.isCurrentRegistration(e,t))throw new Error(`MCP registration "${e}" was superseded`)}isCurrentRegistration(e,t){return this.registrations.has(e)&&this.isCurrentRegistrationRevision(e,t)}isCurrentRegistrationRevision(e,t){return this.registrationRevisions.get(e)===t}requireRegistration(e){const t=this.registrations.get(e);if(!t)throw new Error(`Unknown MCP registration "${e}"`);return t}requireRegistrationRevision(e){const t=this.registrationRevisions.get(e);if(t===void 0)throw new Error(`Unknown MCP registration "${e}"`);return t}async withRegistrationLock(e,t){const i=this.registrationTasks.get(e);let s;const r=new Promise(n=>{s=n});this.registrationTasks.set(e,r),i&&await i;try{return await t()}finally{s(),this.registrationTasks.get(e)===r&&this.registrationTasks.delete(e)}}createShutdownBudget(e,t){const i=Date.now(),s=i+e,r=t===void 0?s:Math.min(s,t),n=Math.max(1,Math.ceil(r-i)),a=new ExecutorPrivateShutdownTimeoutError(n);return{deadlineAt:r,deadline:R(n,[],a),timeoutError:a}}gracefulCloseBudgetMs(e,t=!1){if(!t)return this.remainingBeforeKillReserve(e);const i=this.remainingShutdownMs(e),s=Math.min(i,this.options.termTimeoutMs+se);return Math.max(0,i-s)}remainingBeforeKillReserve(e){const t=this.remainingShutdownMs(e);if(t<=1)return 0;const i=Math.min(this.options.termTimeoutMs,Math.max(1,Math.ceil(t/2)));return Math.max(0,t-i)}remainingBeforeHandleReleaseReserve(e){const t=this.remainingShutdownMs(e);if(t<=1)return 0;const i=Math.min(10,Math.max(1,Math.ceil(t/10)));return Math.max(0,t-i)}remainingShutdownMs(e){return Math.max(0,Math.ceil(e.deadlineAt-Date.now()))}async settleWithinShutdown(e,t,i=this.remainingShutdownMs(t)){const s=Math.min(this.remainingShutdownMs(t),Math.max(0,i));if(s<=0||t.deadline.signal.aborted)return e.catch(()=>{}),{status:"timed_out"};const r=R(s,[t.deadline.signal],t.timeoutError);return new Promise(n=>{let a=!1;const h=u(d=>{a||(a=!0,r.signal.removeEventListener("abort",l),r.close(),n(d))},"finish"),l=u(()=>h({status:"timed_out"}),"onAbort");if(r.signal.addEventListener("abort",l,{once:!0}),r.signal.aborted){l(),e.catch(()=>{});return}e.then(d=>h({status:"fulfilled",value:d}),d=>h({reason:d,status:"rejected"}))})}createPolicyDeadline(e,t,i){return this.processRuntime?.createPolicyDeadline(e,{signals:t,timeoutReason:i})??R(e,t,i)}readPolicyNow(){return this.processRuntime?.policyNow()??Date.now()}waitForPolicyDelay(e,t,i){return this.processRuntime?.policyDelay(e,t,i)??O(e,t)}waitForRestartBackoff(e,t){const i=t??new AbortController().signal;return this.processRuntime?this.processRuntime.policyBackoff(this.options.restartBackoffMs,e,b,i,"Executor restart backoff cancelled"):O(Math.min(b,this.options.restartBackoffMs*2**(e-1)),i)}assertAccepting(){if(this.stateValue==="closing"||this.stateValue==="closed")throw new Error(`Executor supervisor is ${this.stateValue}`);this.options.containment.assertHealthy()}isStopping(){return this.stateValue==="closing"||this.stateValue==="closed"}reportFailure(e){Promise.resolve().then(()=>this.options.onFailure?.(e)).catch(()=>{})}recordLifecycle(e){try{this.options.recordLifecycle?.(e)}catch{}}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExecutorMcpCallResult, ExecutorRegistrationSnapshot } from '#agent-harness-executor/types';
|
|
1
|
+
import type { ExecutorMcpCallResult, ExecutorOAuthLoginInput, ExecutorOAuthLoginResult, ExecutorRegistrationSnapshot } from '#agent-harness-executor/types';
|
|
2
2
|
import type { AcpV2ConnectMcpRequest, AcpV2ConnectMcpResponse, AcpV2DisconnectMcpRequest, AcpV2McpServer, AcpV2MessageMcpNotification, AcpV2MessageMcpRequest } from '../protocol/acp-v2.js';
|
|
3
3
|
import { type AgentMcpConnectOptions, type AgentMcpMessageOptions, type AgentMcpNotificationOptions } from './agent-mcp-protocol.js';
|
|
4
4
|
import type { SessionMcpServerStatus, SessionMcpView } from './session-mcp-view.js';
|
|
@@ -29,6 +29,10 @@ export declare class SessionMcpScope {
|
|
|
29
29
|
ping(connectionId: string, peerToken: object): Promise<unknown>;
|
|
30
30
|
refresh(logicalName: string, signal?: AbortSignal): Promise<ExecutorRegistrationSnapshot>;
|
|
31
31
|
listServerStatuses(): readonly SessionMcpServerStatus[];
|
|
32
|
+
startOAuth(name: string, input: ExecutorOAuthLoginInput, signal?: AbortSignal): Promise<ExecutorOAuthLoginResult>;
|
|
33
|
+
completeOAuth(name: string, state: string, code: string, signal?: AbortSignal): Promise<void>;
|
|
34
|
+
cancelOAuth(name: string, state: string, signal?: AbortSignal): Promise<void>;
|
|
35
|
+
logoutOAuth(name: string, signal?: AbortSignal): Promise<void>;
|
|
32
36
|
callTool(logicalName: string, toolName: string, args: unknown, signal?: AbortSignal): Promise<ExecutorMcpCallResult>;
|
|
33
37
|
subscribeServerStatus(listener: (status: SessionMcpServerStatus) => void): () => void;
|
|
34
38
|
revoke(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var m=Object.defineProperty;var
|
|
1
|
+
var m=Object.defineProperty;var r=(u,t)=>m(u,"name",{value:t,configurable:!0});import{randomUUID as p}from"node:crypto";import{Server as f}from"@modelcontextprotocol/sdk/server/index.js";import{CallToolRequestSchema as C,ListToolsRequestSchema as g}from"@modelcontextprotocol/sdk/types.js";import{AgentMcpRequestError as c}from"./agent-mcp-protocol.js";import{McpPeerTransport as y}from"./mcp-peer-transport.js";const A=128,S=64,b=16*1024;export class SessionMcpScope{static{r(this,"SessionMcpScope")}constructor(t){this.view=t,this.connections=new Map,this.controller=new AbortController,this.servers=new Map,this.subscriptionsBound=!1;for(const e of t.serverNames()){const s=p(),n=t.metaOf(e);this.servers.set(s,{...n===void 0?{}:{_meta:n},logicalName:e,serverId:s})}this.lifecycle=import("../effect-runtime/mcp-lifecycle.mjs").then(async e=>{const s=t.processRuntimeHandle(),n=await e.openMcpEffectScope(s);await n.acquire({acquire:r(async()=>t,"acquire"),release:r(o=>o.revoke(),"release")});const i=await e.openMcpLiveQueue({capacity:S,consume:r(o=>this.publishToolListChanged(o),"consume"),maxBufferedBytes:b,processRuntime:s,sizeOf:r(o=>Buffer.byteLength(o,"utf8"),"sizeOf")});return await n.acquire({acquire:r(async()=>i,"acquire"),release:r(o=>o.close(),"release")}),{listChanged:i,scope:n}})}get revoked(){return this.revokePromise!==void 0}bindSessionId(t){this.view.bindSessionId(t)}async materialize(){this.assertActive();const t=await this.lifecycle;return this.assertActive(),await this.view.materialize(),this.assertActive(),this.subscriptionsBound||(this.subscriptionsBound=!0,await t.scope.acquire({acquire:r(async()=>[...this.servers.values()].map(e=>this.view.subscribe(e.logicalName,()=>this.notifyToolListChanged(e.logicalName))),"acquire"),release:r(async e=>{for(const s of e)s()},"release")})),{mcpServers:[...this.servers.values()].map(e=>({...e._meta===void 0?{}:{_meta:structuredClone(e._meta)},name:e.logicalName,serverId:e.serverId,type:"acp"}))}}async connect(t,e){if(this.assertActive(),e.signal?.aborted)throw e.signal.reason;const s=this.servers.get(t.serverId);if(!s)throw new c(-32602,"Unknown MCP serverId");if(this.connections.size>=A)throw new c(-32e3,"MCP connection limit reached");await this.view.materialize(),this.assertActive();const n=await this.lifecycle;this.assertActive();const i=p(),o=new y(i,e.peer),d=this.createServer(s.logicalName);let v;const a={connectionId:i,logicalName:s.logicalName,peerToken:e.peerToken,peer:e.peer,server:d,transport:o,release:r(()=>v(),"release")};try{if(v=(await n.scope.acquire({acquire:r(async l=>{this.connections.set(i,a);try{if(await d.connect(o),l.aborted||e.signal?.aborted||this.revoked)throw l.reason??e.signal?.reason??new Error("MCP session scope is revoked");return a}catch(w){throw await this.releaseConnection(a,w),w}},"acquire"),release:r(l=>this.releaseConnection(l,new Error("MCP connection scope closed")),"release")})).release,this.assertActive(),e.signal?.aborted)throw e.signal.reason;return{connectionId:i}}catch(h){throw await this.releaseConnection(a,h),h}}async message(t,e){return this.requireConnection(t.connectionId,e.peerToken).transport.receiveRequest(t.method,t.params,e.signal)}notify(t,e){this.requireConnection(t.connectionId,e.peerToken).transport.receiveNotification(t.method,t.params)}async disconnect(t,e){const s=this.connections.get(t.connectionId);if(s){if(s.peerToken!==e.peerToken)throw new c(-32602,"Unknown MCP connectionId");await this.closeConnection(s,new Error("MCP peer disconnected"))}}async disconnectPeer(t){const e=[...this.connections.values()].filter(s=>s.peerToken===t);await Promise.allSettled(e.map(s=>this.closeConnection(s,new Error("Private ACP child closed"))))}ping(t,e){return this.requireConnection(t,e).server.ping()}async refresh(t,e){return this.view.refresh(t,e)}listServerStatuses(){return this.assertActive(),this.view.listServerStatuses()}startOAuth(t,e,s){return this.view.startOAuth(t,e,s)}completeOAuth(t,e,s,n){return this.view.completeOAuth(t,e,s,n)}cancelOAuth(t,e,s){return this.view.cancelOAuth(t,e,s)}logoutOAuth(t,e){return this.view.logoutOAuth(t,e)}callTool(t,e,s,n){return this.assertActive(),this.view.callTool(t,e,s,n)}subscribeServerStatus(t){return this.assertActive(),this.view.subscribeServerStatus(t)}revoke(){return this.revokePromise??=this.revokeInternal(),this.revokePromise}createServer(t){const e=new f({name:t,version:"1.0.0"},{capabilities:{tools:{listChanged:!0}}});return e.setRequestHandler(g,async()=>({tools:this.view.listTools(t)})),e.setRequestHandler(C,async(s,n)=>this.view.callTool(t,s.params.name,s.params.arguments??{},n.signal)),e}requireConnection(t,e){this.assertActive();const s=this.connections.get(t);if(!s||s.peerToken!==e)throw new c(-32602,"Unknown MCP connectionId");return s}async closeConnection(t,e){t.transport.closeFromScope(e),await t.release()}async revokeInternal(){const t=new Error("MCP session scope revoked");this.controller.abort(t),await(await this.lifecycle).scope.close()}notifyToolListChanged(t){this.lifecycle.then(e=>{e.listChanged.offer(t)}).catch(()=>{})}async publishToolListChanged(t){for(const e of this.connections.values())e.logicalName===t&&await e.server.sendToolListChanged().catch(()=>{})}async releaseConnection(t,e){this.connections.get(t.connectionId)===t&&this.connections.delete(t.connectionId),t.transport.closeFromScope(e),await t.server.close().catch(()=>{})}assertActive(){if(this.revoked||this.controller.signal.aborted)throw new c(-32602,"MCP session scope is revoked")}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExecutorPrivateProxyPolicy } from '#agent-harness-executor/private-protocol';
|
|
2
|
-
import type { CompiledSessionMcpServer, ExecutorElicitationRequest, ExecutorElicitationResponse, ExecutorMcpCallResult, ExecutorRegistrationSnapshot, ExecutorToolBinding } from '#agent-harness-executor/types';
|
|
2
|
+
import type { CompiledSessionMcpServer, ExecutorElicitationRequest, ExecutorElicitationResponse, ExecutorMcpAuthStatus, ExecutorMcpCallResult, ExecutorOAuthLoginInput, ExecutorOAuthLoginResult, ExecutorRegistrationSnapshot, ExecutorToolBinding } from '#agent-harness-executor/types';
|
|
3
3
|
import { type HarnessProcessRuntimeHandle } from '../effect-runtime/process-runtime-context.js';
|
|
4
4
|
import type { ExecutorRuntimeBackend, ExecutorSupervisorElicitation } from './executor-supervisor.js';
|
|
5
5
|
import { McpRegistrationRegistry } from './registration-registry.js';
|
|
@@ -18,6 +18,7 @@ export interface SessionMcpTool {
|
|
|
18
18
|
* credentials, and opaque source metadata are deliberately not projected.
|
|
19
19
|
*/
|
|
20
20
|
export interface SessionMcpServerStatus {
|
|
21
|
+
readonly authStatus?: ExecutorMcpAuthStatus;
|
|
21
22
|
readonly error?: {
|
|
22
23
|
readonly code: string;
|
|
23
24
|
readonly message: string;
|
|
@@ -113,6 +114,10 @@ export declare class SessionMcpView {
|
|
|
113
114
|
serverStatus(logicalName: string): SessionMcpServerStatus;
|
|
114
115
|
subscribeServerStatus(listener: (status: SessionMcpServerStatus) => void): () => void;
|
|
115
116
|
listTools(logicalName: string): readonly SessionMcpTool[];
|
|
117
|
+
startOAuth(logicalName: string, input: ExecutorOAuthLoginInput, signal?: AbortSignal): Promise<ExecutorOAuthLoginResult>;
|
|
118
|
+
completeOAuth(logicalName: string, state: string, code: string, signal?: AbortSignal): Promise<void>;
|
|
119
|
+
cancelOAuth(logicalName: string, state: string, signal?: AbortSignal): Promise<void>;
|
|
120
|
+
logoutOAuth(logicalName: string, signal?: AbortSignal): Promise<void>;
|
|
116
121
|
refresh(logicalName: string, signal?: AbortSignal): Promise<ExecutorRegistrationSnapshot>;
|
|
117
122
|
callTool(logicalName: string, toolName: string, args: unknown, signal?: AbortSignal): Promise<ExecutorMcpCallResult>;
|
|
118
123
|
revoke(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var f=Object.defineProperty;var n=(u,e)=>f(u,"name",{value:e,configurable:!0});import{randomUUID as d}from"node:crypto";import{isDeepStrictEqual as m}from"node:util";import{currentHarnessProcessRuntime as S}from"../effect-runtime/process-runtime-context.js";import{McpRegistrationRegistry as b}from"./registration-registry.js";export class SessionMcpSourceUnavailableError extends Error{static{n(this,"SessionMcpSourceUnavailableError")}constructor(e){super(`MCP server "${e}" is unavailable`),this.logicalName=e,this.name="SessionMcpSourceUnavailableError"}}export class SessionMcpViewRevokedError extends Error{static{n(this,"SessionMcpViewRevokedError")}constructor(){super("MCP session view is revoked"),this.name="SessionMcpViewRevokedError"}}class g{static{n(this,"InteractionBroker")}constructor(){this.invocations=new Map}begin(e,t){if(this.invocations.has(e))throw new Error(`Duplicate MCP invocation "${e}"`);const s={...t,controller:new AbortController};return this.invocations.set(e,s),()=>{this.invocations.get(e)===s&&(this.invocations.delete(e),s.controller.abort(new Error("MCP invocation completed")))}}revokeView(e){for(const[t,s]of this.invocations)s.view===e&&(this.invocations.delete(t),s.controller.abort(new SessionMcpViewRevokedError))}async handle(e){const t=this.invocations.get(e.invocationId);if(!t||t.epoch!==e.runtimeEpoch||t.view.revoked)return{action:"cancel"};let s;const r=new Promise(i=>{s=n(()=>i({action:"cancel"}),"abortListener"),t.controller.signal.aborted?s():t.controller.signal.addEventListener("abort",s,{once:!0})});try{const i=await Promise.race([Promise.resolve().then(()=>t.controller.signal.aborted||t.view.revoked||this.invocations.get(e.invocationId)!==t?{action:"cancel"}:t.interaction(e.request,{invocationId:e.invocationId,...t.sessionId===void 0?{}:{sessionId:t.sessionId},signal:t.controller.signal})),r]);return t.controller.signal.aborted||t.view.revoked||this.invocations.get(e.invocationId)!==t?{action:"cancel"}:i}catch(i){if(t.controller.signal.aborted||t.view.revoked||this.invocations.get(e.invocationId)!==t)return{action:"cancel"};throw i}finally{s&&t.controller.signal.removeEventListener("abort",s)}}}export class ExecutorMcpIntegration{static{n(this,"ExecutorMcpIntegration")}static create(e){const t=new g,s=e.createSupervisor(i=>t.handle(i)),r=e.processRuntime??S();return new ExecutorMcpIntegration(s,new b(s,r),t,r)}constructor(e,t,s,r){this.supervisor=e,this.registry=t,this.broker=s,this.processRuntime=r,this.closed=!1,this.views=new Set}registerClientSource(e,t){if(this.closed||!this.supervisor.registerClientSource)throw new Error("Executor Client MCP bridge unavailable");return this.supervisor.registerClientSource(e,t)}createView(e){if(this.closed)throw new Error("Executor MCP integration is closed");const t=new SessionMcpView(e,this.supervisor,this.registry,this.broker,this.processRuntime,()=>this.views.delete(t));return this.views.add(t),t}configureProxy(e){return this.supervisor.configureProxy?.(e)??Promise.resolve()}async close(e){if(this.closed)return;this.closed=!0;const t=[...this.views];this.views.clear(),await Promise.allSettled(t.map(s=>s.revoke())),await this.registry.close(),await this.supervisor.close(e)}}export class SessionMcpView{static{n(this,"SessionMcpView")}constructor(e,t,s,r,i,o){this.options=e,this.supervisor=t,this.registry=s,this.broker=r,this.processRuntime=i,this.onRevoked=o,this.materialized=new Map,this.snapshotListeners=new Map,this.statusListeners=new Set,this.viewId=e.viewId??d(),this.effectScope=import("../effect-runtime/mcp-lifecycle.mjs").then(c=>c.openMcpEffectScope(i))}get revoked(){return this.revokePromise!==void 0}get sessionId(){return this.sessionIdValue}processRuntimeHandle(){return this.processRuntime}bindSessionId(e){if(this.sessionIdValue&&this.sessionIdValue!==e)throw new Error("MCP session view is already bound to another session");this.sessionIdValue=e}async materialize(){if(this.revoked)throw new SessionMcpViewRevokedError;return this.materialization??=this.materializeInternal(),this.materialization}serverNames(){return this.options.servers.map(e=>e.logicalName)}metaOf(e){const t=this.options.servers.find(s=>s.logicalName===e);if(!t)throw new Error(`Unknown MCP server "${e}"`);return t._meta}subscribe(e,t){this.requireServer(e);let s=this.snapshotListeners.get(e);return s||(s=new Set,this.snapshotListeners.set(e,s)),s.add(t),()=>{s?.delete(t),s?.size===0&&this.snapshotListeners.delete(e)}}snapshot(e){const t=this.requireServer(e);return this.synchronizeSnapshot(e,t)}listServerStatuses(){return this.assertActive(),this.options.servers.map(({logicalName:e})=>this.serverStatus(e))}serverStatus(e){this.assertActive();const t=this.requireServer(e),s=this.synchronizeSnapshot(e,t);return this.projectServerStatus(e,t,s)}subscribeServerStatus(e){return this.assertActive(),this.statusListeners.add(e),()=>this.statusListeners.delete(e)}listTools(e){const t=this.requireServer(e);return this.synchronizeSnapshot(e,t).status!=="available"?[]:[...t.bindings.values()].map(s=>this.projectTool(s))}async refresh(e,t){this.assertActive();const s=this.requireServer(e),r=await s.lease.refresh(t);return this.replaceBindings(e,s,r)&&this.publishSnapshot(e,r),this.publishServerStatus(this.projectServerStatus(e,s,r)),r}async callTool(e,t,s,r){this.assertActive(),await this.materialize();const i=this.requireServer(e);if(this.synchronizeSnapshot(e,i).status!=="available")throw new SessionMcpSourceUnavailableError(e);const o=i.bindings.get(t);if(!o)throw new Error(`MCP tool "${t}" is not visible through "${e}"`);await this.supervisor.start();const c=this.supervisor.runtimeEpoch;if(!c)throw new SessionMcpSourceUnavailableError(e);const a=d(),h=new AbortController,v=await(await this.effectScope).acquire({acquire:n(async()=>h,"acquire"),release:n(async w=>{w.abort(new SessionMcpViewRevokedError)},"release")});let l;r&&(l=n(()=>{h.abort(r.reason)},"externalAbortListener"),r.aborted?l():r.addEventListener("abort",l,{once:!0}));const p=this.broker.begin(a,{epoch:c,interaction:this.options.interaction,...this.sessionIdValue===void 0?{}:{sessionId:this.sessionIdValue},view:this});try{return await this.supervisor.callTool(i.lease.registration.registrationId,a,o.executorAddress,s,{signal:h.signal})}finally{p(),await v.release(),l&&r?.removeEventListener("abort",l)}}async revoke(){return this.revokePromise??=this.revokeInternal(),this.revokePromise}async materializeInternal(){const e=await this.effectScope;try{for(const t of this.options.servers){if(this.revoked)throw new SessionMcpViewRevokedError;const r=(await e.acquire({acquire:n(()=>this.registry.acquire(t.registration),"acquire"),release:n(o=>o.release(),"release")})).value;if(this.revoked)throw new SessionMcpViewRevokedError;const i={bindings:new Map,lease:r,snapshotKey:""};this.replaceBindings(t.logicalName,i,r.snapshot),i.unsubscribe=r.subscribe(o=>{if(this.revoked)return;this.replaceBindings(t.logicalName,i,o)&&this.publishSnapshot(t.logicalName,o),this.publishServerStatus(this.projectServerStatus(t.logicalName,i,o))}),this.materialized.set(t.logicalName,i)}}catch(t){throw await e.close().catch(()=>{}),this.materialized.clear(),this.revoked?new SessionMcpViewRevokedError:t}}replaceBindings(e,t,s){const r=[s.runtimeEpoch,s.generation,s.status].join(":"),i=new Map;for(const a of s.tools){if(i.has(a.upstreamToolName))throw new Error(`MCP server "${e}" exposes duplicate tool "${a.upstreamToolName}"`);i.set(a.upstreamToolName,a)}const o=n(a=>new Map([...a].map(([h,v])=>[h,this.projectTool(v)])),"project"),c=!m(o(t.bindings),o(i));t.bindings.clear();for(const[a,h]of i)t.bindings.set(a,h);return t.snapshotKey=r,c}synchronizeSnapshot(e,t){const s=t.lease.snapshot;return[s.runtimeEpoch,s.generation,s.status].join(":")!==t.snapshotKey&&this.replaceBindings(e,t,s)&&this.publishSnapshot(e,s),s}async revokeInternal(){this.broker.revokeView(this);for(const e of this.materialized.values())e.unsubscribe?.();this.materialized.clear(),this.snapshotListeners.clear(),this.statusListeners.clear(),await(await this.effectScope).close(),this.onRevoked()}requireServer(e){const t=this.materialized.get(e);if(!t)throw this.revoked?new SessionMcpViewRevokedError:new Error(`Unknown MCP server "${e}"`);return t}assertActive(){if(this.revoked)throw new SessionMcpViewRevokedError}publishSnapshot(e,t){for(const s of this.snapshotListeners.get(e)??[])try{s(t)}catch{}}projectServerStatus(e,t,s){return{...s.error===void 0?{}:{error:{code:s.error.code,message:s.error.message,retryable:s.error.retryable}},generation:s.generation,logicalName:e,status:s.status,tools:[...t.bindings.values()].map(r=>this.projectTool(r))}}projectTool(e){return{...e._meta===void 0?{}:{_meta:structuredClone(e._meta)},...e.annotations===void 0?{}:{annotations:structuredClone(e.annotations)},...e.description===void 0?{}:{description:e.description},inputSchema:structuredClone(e.inputSchema),name:e.upstreamToolName,...e.outputSchema===void 0?{}:{outputSchema:structuredClone(e.outputSchema)}}}publishServerStatus(e){for(const t of this.statusListeners)try{t(e)}catch{}}}
|
|
1
|
+
var f=Object.defineProperty;var a=(u,e)=>f(u,"name",{value:e,configurable:!0});import{createHash as S,randomUUID as p}from"node:crypto";import{isDeepStrictEqual as m}from"node:util";import{currentHarnessProcessRuntime as b}from"../effect-runtime/process-runtime-context.js";import{McpRegistrationRegistry as g}from"./registration-registry.js";export class SessionMcpSourceUnavailableError extends Error{static{a(this,"SessionMcpSourceUnavailableError")}constructor(e){super(`MCP server "${e}" is unavailable`),this.logicalName=e,this.name="SessionMcpSourceUnavailableError"}}export class SessionMcpViewRevokedError extends Error{static{a(this,"SessionMcpViewRevokedError")}constructor(){super("MCP session view is revoked"),this.name="SessionMcpViewRevokedError"}}class y{static{a(this,"InteractionBroker")}constructor(){this.invocations=new Map}begin(e,t){if(this.invocations.has(e))throw new Error(`Duplicate MCP invocation "${e}"`);const s={...t,controller:new AbortController};return this.invocations.set(e,s),()=>{this.invocations.get(e)===s&&(this.invocations.delete(e),s.controller.abort(new Error("MCP invocation completed")))}}revokeView(e){for(const[t,s]of this.invocations)s.view===e&&(this.invocations.delete(t),s.controller.abort(new SessionMcpViewRevokedError))}async handle(e){const t=this.invocations.get(e.invocationId);if(!t||t.epoch!==e.runtimeEpoch||t.view.revoked)return{action:"cancel"};let s;const r=new Promise(i=>{s=a(()=>i({action:"cancel"}),"abortListener"),t.controller.signal.aborted?s():t.controller.signal.addEventListener("abort",s,{once:!0})});try{const i=await Promise.race([Promise.resolve().then(()=>t.controller.signal.aborted||t.view.revoked||this.invocations.get(e.invocationId)!==t?{action:"cancel"}:t.interaction(e.request,{invocationId:e.invocationId,...t.sessionId===void 0?{}:{sessionId:t.sessionId},signal:t.controller.signal})),r]);return t.controller.signal.aborted||t.view.revoked||this.invocations.get(e.invocationId)!==t?{action:"cancel"}:i}catch(i){if(t.controller.signal.aborted||t.view.revoked||this.invocations.get(e.invocationId)!==t)return{action:"cancel"};throw i}finally{s&&t.controller.signal.removeEventListener("abort",s)}}}export class ExecutorMcpIntegration{static{a(this,"ExecutorMcpIntegration")}static create(e){const t=new y,s=e.createSupervisor(i=>t.handle(i)),r=e.processRuntime??b();return new ExecutorMcpIntegration(s,new g(s,r),t,r)}constructor(e,t,s,r){this.supervisor=e,this.registry=t,this.broker=s,this.processRuntime=r,this.closed=!1,this.views=new Set}registerClientSource(e,t){if(this.closed||!this.supervisor.registerClientSource)throw new Error("Executor Client MCP bridge unavailable");return this.supervisor.registerClientSource(e,t)}createView(e){if(this.closed)throw new Error("Executor MCP integration is closed");const t=new SessionMcpView(e,this.supervisor,this.registry,this.broker,this.processRuntime,()=>this.views.delete(t));return this.views.add(t),t}configureProxy(e){return this.supervisor.configureProxy?.(e)??Promise.resolve()}async close(e){if(this.closed)return;this.closed=!0;const t=[...this.views];this.views.clear(),await Promise.allSettled(t.map(s=>s.revoke())),await this.registry.close(),await this.supervisor.close(e)}}export class SessionMcpView{static{a(this,"SessionMcpView")}constructor(e,t,s,r,i,n){this.options=e,this.supervisor=t,this.registry=s,this.broker=r,this.processRuntime=i,this.onRevoked=n,this.materialized=new Map,this.snapshotListeners=new Map,this.statusListeners=new Set,this.viewId=e.viewId??p();const c=S("sha256").update(this.viewId).digest("hex").slice(0,24);this.options={...e,servers:e.servers.map(o=>o.registration.transport.transport==="remote"&&o.registration.transport.authentication.kind==="none"?{...o,registration:{...o.registration,connectionName:`${o.registration.connectionName}${c}`,registrationId:`${o.registration.registrationId}-${c}`}}:o)},this.effectScope=import("../effect-runtime/mcp-lifecycle.mjs").then(o=>o.openMcpEffectScope(i))}get revoked(){return this.revokePromise!==void 0}get sessionId(){return this.sessionIdValue}processRuntimeHandle(){return this.processRuntime}bindSessionId(e){if(this.sessionIdValue&&this.sessionIdValue!==e)throw new Error("MCP session view is already bound to another session");this.sessionIdValue=e}async materialize(){if(this.revoked)throw new SessionMcpViewRevokedError;return this.materialization??=this.materializeInternal(),this.materialization}serverNames(){return this.options.servers.map(e=>e.logicalName)}metaOf(e){const t=this.options.servers.find(s=>s.logicalName===e);if(!t)throw new Error(`Unknown MCP server "${e}"`);return t._meta}subscribe(e,t){this.requireServer(e);let s=this.snapshotListeners.get(e);return s||(s=new Set,this.snapshotListeners.set(e,s)),s.add(t),()=>{s?.delete(t),s?.size===0&&this.snapshotListeners.delete(e)}}snapshot(e){const t=this.requireServer(e);return this.synchronizeSnapshot(e,t)}listServerStatuses(){return this.assertActive(),this.options.servers.map(({logicalName:e})=>this.serverStatus(e))}serverStatus(e){this.assertActive();const t=this.requireServer(e),s=this.synchronizeSnapshot(e,t);return this.projectServerStatus(e,t,s)}subscribeServerStatus(e){return this.assertActive(),this.statusListeners.add(e),()=>this.statusListeners.delete(e)}listTools(e){const t=this.requireServer(e);return this.synchronizeSnapshot(e,t).status!=="available"?[]:[...t.bindings.values()].map(s=>this.projectTool(s))}async startOAuth(e,t,s){this.assertActive();const r=this.requireServer(e);if(!this.supervisor.startOAuth)throw new Error("MCP OAuth unavailable");const i=await this.supervisor.startOAuth(r.lease.registration.registrationId,t,{signal:s});return this.assertActive(),i}async completeOAuth(e,t,s,r){this.assertActive();const i=this.requireServer(e);if(!this.supervisor.completeOAuth)throw new Error("MCP OAuth unavailable");const n=await this.supervisor.completeOAuth(i.lease.registration.registrationId,t,s,{signal:r});this.assertActive(),this.replaceBindings(e,i,n)&&this.publishSnapshot(e,n),this.publishServerStatus(this.projectServerStatus(e,i,n))}async cancelOAuth(e,t,s){this.assertActive();const r=this.requireServer(e);if(!this.supervisor.cancelOAuth)throw new Error("MCP OAuth unavailable");await this.supervisor.cancelOAuth(r.lease.registration.registrationId,t,{signal:s})}async logoutOAuth(e,t){this.assertActive();const s=this.requireServer(e);if(!this.supervisor.logoutOAuth)throw new Error("MCP OAuth unavailable");const r=await this.supervisor.logoutOAuth(s.lease.registration.registrationId,{signal:t});this.assertActive(),this.replaceBindings(e,s,r)&&this.publishSnapshot(e,r),this.publishServerStatus(this.projectServerStatus(e,s,r))}async refresh(e,t){this.assertActive();const s=this.requireServer(e),r=await s.lease.refresh(t);return this.replaceBindings(e,s,r)&&this.publishSnapshot(e,r),this.publishServerStatus(this.projectServerStatus(e,s,r)),r}async callTool(e,t,s,r){this.assertActive(),await this.materialize();const i=this.requireServer(e);if(this.synchronizeSnapshot(e,i).status!=="available")throw new SessionMcpSourceUnavailableError(e);const n=i.bindings.get(t);if(!n)throw new Error(`MCP tool "${t}" is not visible through "${e}"`);await this.supervisor.start();const c=this.supervisor.runtimeEpoch;if(!c)throw new SessionMcpSourceUnavailableError(e);const o=p(),h=new AbortController,v=await(await this.effectScope).acquire({acquire:a(async()=>h,"acquire"),release:a(async w=>{w.abort(new SessionMcpViewRevokedError)},"release")});let l;r&&(l=a(()=>{h.abort(r.reason)},"externalAbortListener"),r.aborted?l():r.addEventListener("abort",l,{once:!0}));const d=this.broker.begin(o,{epoch:c,interaction:this.options.interaction,...this.sessionIdValue===void 0?{}:{sessionId:this.sessionIdValue},view:this});try{return await this.supervisor.callTool(i.lease.registration.registrationId,o,n.executorAddress,s,{signal:h.signal})}finally{d(),await v.release(),l&&r?.removeEventListener("abort",l)}}async revoke(){return this.revokePromise??=this.revokeInternal(),this.revokePromise}async materializeInternal(){const e=await this.effectScope;try{for(const t of this.options.servers){if(this.revoked)throw new SessionMcpViewRevokedError;const r=(await e.acquire({acquire:a(()=>this.registry.acquire(t.registration),"acquire"),release:a(n=>n.release(),"release")})).value;if(this.revoked)throw new SessionMcpViewRevokedError;const i={bindings:new Map,lease:r,snapshotKey:""};this.replaceBindings(t.logicalName,i,r.snapshot),i.unsubscribe=r.subscribe(n=>{if(this.revoked)return;this.replaceBindings(t.logicalName,i,n)&&this.publishSnapshot(t.logicalName,n),this.publishServerStatus(this.projectServerStatus(t.logicalName,i,n))}),this.materialized.set(t.logicalName,i)}}catch(t){throw await e.close().catch(()=>{}),this.materialized.clear(),this.revoked?new SessionMcpViewRevokedError:t}}replaceBindings(e,t,s){const r=[s.runtimeEpoch,s.generation,s.status].join(":"),i=new Map;for(const o of s.tools){if(i.has(o.upstreamToolName))throw new Error(`MCP server "${e}" exposes duplicate tool "${o.upstreamToolName}"`);i.set(o.upstreamToolName,o)}const n=a(o=>new Map([...o].map(([h,v])=>[h,this.projectTool(v)])),"project"),c=!m(n(t.bindings),n(i));t.bindings.clear();for(const[o,h]of i)t.bindings.set(o,h);return t.snapshotKey=r,c}synchronizeSnapshot(e,t){const s=t.lease.snapshot;return[s.runtimeEpoch,s.generation,s.status].join(":")!==t.snapshotKey&&this.replaceBindings(e,t,s)&&this.publishSnapshot(e,s),s}async revokeInternal(){this.broker.revokeView(this);for(const e of this.materialized.values())e.unsubscribe?.();this.materialized.clear(),this.snapshotListeners.clear(),this.statusListeners.clear(),await(await this.effectScope).close(),this.onRevoked()}requireServer(e){const t=this.materialized.get(e);if(!t)throw this.revoked?new SessionMcpViewRevokedError:new Error(`Unknown MCP server "${e}"`);return t}assertActive(){if(this.revoked)throw new SessionMcpViewRevokedError}publishSnapshot(e,t){for(const s of this.snapshotListeners.get(e)??[])try{s(t)}catch{}}projectServerStatus(e,t,s){return{...s.error===void 0?{}:{error:{code:s.error.code,message:s.error.message,retryable:s.error.retryable}},...s.authStatus===void 0?{}:{authStatus:s.authStatus},generation:s.generation,logicalName:e,status:s.status,tools:[...t.bindings.values()].map(r=>this.projectTool(r))}}projectTool(e){return{...e._meta===void 0?{}:{_meta:structuredClone(e._meta)},...e.annotations===void 0?{}:{annotations:structuredClone(e.annotations)},...e.description===void 0?{}:{description:e.description},inputSchema:structuredClone(e.inputSchema),name:e.upstreamToolName,...e.outputSchema===void 0?{}:{outputSchema:structuredClone(e.outputSchema)}}}publishServerStatus(e){for(const t of this.statusListeners)try{t(e)}catch{}}}
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import type { AgentHarnessProtocolModule } from '../module/types.js';
|
|
2
2
|
import type { AgentHarnessHandlerContext } from '../server/types.js';
|
|
3
|
-
import { type ListMcpServerStatusParams, type ListMcpServerStatusResponse, type McpServerToolCallParams, type McpServerToolCallResponse } from './schemas.js';
|
|
3
|
+
import { type ListMcpServerStatusParams, type ListMcpServerStatusResponse, type McpServerOAuthCancelParams, type McpServerOAuthCompleteParams, type McpServerOAuthLoginParams, type McpServerOAuthLoginResponse, type McpServerOAuthLogoutParams, type McpServerToolCallParams, type McpServerToolCallResponse } from './schemas.js';
|
|
4
4
|
type MaybePromise<Value> = Value | PromiseLike<Value>;
|
|
5
5
|
export declare const MCP_SERVER_PROTOCOL_METHODS: Readonly<{
|
|
6
6
|
readonly mcpServer: {
|
|
7
|
+
readonly oauth: {
|
|
8
|
+
readonly cancel: "mcpServer/oauth/cancel";
|
|
9
|
+
};
|
|
10
|
+
} & {
|
|
11
|
+
readonly oauth: {
|
|
12
|
+
readonly complete: "mcpServer/oauth/complete";
|
|
13
|
+
};
|
|
14
|
+
} & {
|
|
15
|
+
readonly oauth: {
|
|
16
|
+
readonly login: "mcpServer/oauth/login";
|
|
17
|
+
};
|
|
18
|
+
} & {
|
|
19
|
+
readonly oauth: {
|
|
20
|
+
readonly logout: "mcpServer/oauth/logout";
|
|
21
|
+
};
|
|
22
|
+
} & {
|
|
7
23
|
readonly startupStatus: {
|
|
8
24
|
readonly updated: "mcpServer/startupStatus/updated";
|
|
9
25
|
};
|
|
@@ -17,6 +33,10 @@ export declare const MCP_SERVER_PROTOCOL_METHODS: Readonly<{
|
|
|
17
33
|
};
|
|
18
34
|
}>;
|
|
19
35
|
export interface McpServerProtocolBackend {
|
|
36
|
+
loginMcpServerOAuth?(params: McpServerOAuthLoginParams, context: AgentHarnessHandlerContext): MaybePromise<McpServerOAuthLoginResponse>;
|
|
37
|
+
completeMcpServerOAuth?(params: McpServerOAuthCompleteParams, context: AgentHarnessHandlerContext): MaybePromise<Record<string, never>>;
|
|
38
|
+
cancelMcpServerOAuth?(params: McpServerOAuthCancelParams, context: AgentHarnessHandlerContext): MaybePromise<Record<string, never>>;
|
|
39
|
+
logoutMcpServerOAuth?(params: McpServerOAuthLogoutParams, context: AgentHarnessHandlerContext): MaybePromise<Record<string, never>>;
|
|
20
40
|
listMcpServerStatuses(params: ListMcpServerStatusParams, context: AgentHarnessHandlerContext): MaybePromise<ListMcpServerStatusResponse>;
|
|
21
41
|
callMcpServerTool(params: McpServerToolCallParams, context: AgentHarnessHandlerContext): MaybePromise<McpServerToolCallResponse>;
|
|
22
42
|
}
|
|
@@ -24,7 +44,7 @@ export interface CreateMcpServerProtocolModuleOptions {
|
|
|
24
44
|
readonly backend: McpServerProtocolBackend;
|
|
25
45
|
}
|
|
26
46
|
/**
|
|
27
|
-
* Installs
|
|
47
|
+
* Installs session-scoped MCP management and Host-completed OAuth.
|
|
28
48
|
*
|
|
29
49
|
* The methods are part of the default Harness profile and therefore have no
|
|
30
50
|
* capability gate. Runtime ownership and session isolation stay behind the
|
package/lib/mcp-server/module.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var O=Object.defineProperty;var c=(n,e)=>O(n,"name",{value:e,configurable:!0});import{requestHandler as o}from"../module/validation.js";import{HARNESS_METHODS as i}from"../protocol/methods.js";import{AGENT_HARNESS_JSON_RPC_ERROR_CODES as v,AgentHarnessInvalidParamsError as a,AgentHarnessJsonRpcError as M}from"../server/errors.js";import{McpServerOAuthCancel as s,McpServerOAuthComplete as l,McpServerOAuthLogin as p,McpServerOAuthLogout as h,McpServerStatusList as m,McpServerToolCall as A}from"./rpcs.js";import"./schemas.js";async function u(n){try{return await n()}catch(e){switch(e instanceof Error?e.name:void 0){case"McpOAuthUnsupportedTransport":throw new a("OAuth requires a remote MCP server without Host-managed headers");case"McpOAuthClientRequired":throw new a("The authorization server requires a registered client; pass client.clientId");case"McpOAuthInvalidState":throw new a("OAuth attempt is no longer valid for this attachment; start a new login");case"OAuthProbeError":case"OAuthRegisterDynamicError":case"OAuthStartError":case"OAuthCompleteError":throw new M(v.internalError,"MCP OAuth authorization failed",{reason:e instanceof Error?e.name:void 0});default:throw e}}}c(u,"oauthResult");export const MCP_SERVER_PROTOCOL_METHODS=Object.freeze({mcpServer:i.mcpServer,mcpServerStatus:i.mcpServerStatus});export function createMcpServerProtocolModule(n){const{backend:e}=n,S=new Map([[MCP_SERVER_PROTOCOL_METHODS.mcpServerStatus.list,o(m,(r,t)=>e.listMcpServerStatuses(r,t))],[MCP_SERVER_PROTOCOL_METHODS.mcpServer.tool.call,o(A,(r,t)=>e.callMcpServerTool(r,t))],[p._tag,o(p,(r,t)=>{if(!e.loginMcpServerOAuth)throw new a("MCP OAuth unavailable");return u(()=>e.loginMcpServerOAuth(r,t))})],[l._tag,o(l,(r,t)=>{if(!e.completeMcpServerOAuth)throw new a("MCP OAuth unavailable");return u(()=>e.completeMcpServerOAuth(r,t))})],[s._tag,o(s,(r,t)=>{if(!e.cancelMcpServerOAuth)throw new a("MCP OAuth unavailable");return u(()=>e.cancelMcpServerOAuth(r,t))})],[h._tag,o(h,(r,t)=>{if(!e.logoutMcpServerOAuth)throw new a("MCP OAuth unavailable");return u(()=>e.logoutMcpServerOAuth(r,t))})]]);return Object.freeze({capabilities:Object.freeze({}),initialize:c(()=>({registry:Object.freeze({outboundNotificationMethods:Object.freeze([MCP_SERVER_PROTOCOL_METHODS.mcpServer.startupStatus.updated])})}),"initialize"),name:"mcp-server",requestHandlers:S})}c(createMcpServerProtocolModule,"createMcpServerProtocolModule");
|