@anthropic-field/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.last_build +0 -0
- package/dist/docs/architecture.md +80 -0
- package/dist/docs/assets/connected_devtools.png +0 -0
- package/dist/docs/assets/gemini-screenshot.png +0 -0
- package/dist/docs/assets/monitoring-dashboard-logs.png +0 -0
- package/dist/docs/assets/monitoring-dashboard-metrics.png +0 -0
- package/dist/docs/assets/monitoring-dashboard-overview.png +0 -0
- package/dist/docs/assets/release_patch.png +0 -0
- package/dist/docs/assets/theme-ansi-light.png +0 -0
- package/dist/docs/assets/theme-ansi.png +0 -0
- package/dist/docs/assets/theme-atom-one.png +0 -0
- package/dist/docs/assets/theme-ayu-light.png +0 -0
- package/dist/docs/assets/theme-ayu.png +0 -0
- package/dist/docs/assets/theme-custom.png +0 -0
- package/dist/docs/assets/theme-default-light.png +0 -0
- package/dist/docs/assets/theme-default.png +0 -0
- package/dist/docs/assets/theme-dracula.png +0 -0
- package/dist/docs/assets/theme-github-light.png +0 -0
- package/dist/docs/assets/theme-github.png +0 -0
- package/dist/docs/assets/theme-google-light.png +0 -0
- package/dist/docs/assets/theme-xcode-light.png +0 -0
- package/dist/docs/changelogs/index.md +743 -0
- package/dist/docs/changelogs/latest.md +338 -0
- package/dist/docs/changelogs/preview.md +437 -0
- package/dist/docs/cli/authentication.md +3 -0
- package/dist/docs/cli/checkpointing.md +94 -0
- package/dist/docs/cli/cli-reference.md +101 -0
- package/dist/docs/cli/commands.md +430 -0
- package/dist/docs/cli/creating-skills.md +80 -0
- package/dist/docs/cli/custom-commands.md +315 -0
- package/dist/docs/cli/enterprise.md +565 -0
- package/dist/docs/cli/gemini-ignore.md +71 -0
- package/dist/docs/cli/gemini-md.md +108 -0
- package/dist/docs/cli/generation-settings.md +210 -0
- package/dist/docs/cli/headless.md +388 -0
- package/dist/docs/cli/index.md +65 -0
- package/dist/docs/cli/keyboard-shortcuts.md +140 -0
- package/dist/docs/cli/model-routing.md +42 -0
- package/dist/docs/cli/model.md +62 -0
- package/dist/docs/cli/rewind.md +51 -0
- package/dist/docs/cli/sandbox.md +171 -0
- package/dist/docs/cli/session-management.md +158 -0
- package/dist/docs/cli/settings.md +139 -0
- package/dist/docs/cli/skills.md +112 -0
- package/dist/docs/cli/system-prompt.md +125 -0
- package/dist/docs/cli/telemetry.md +826 -0
- package/dist/docs/cli/themes.md +235 -0
- package/dist/docs/cli/token-caching.md +20 -0
- package/dist/docs/cli/trusted-folders.md +95 -0
- package/dist/docs/cli/tutorials/skills-getting-started.md +97 -0
- package/dist/docs/cli/tutorials.md +87 -0
- package/dist/docs/cli/uninstall.md +65 -0
- package/dist/docs/core/index.md +107 -0
- package/dist/docs/core/memport.md +246 -0
- package/dist/docs/core/policy-engine.md +305 -0
- package/dist/docs/core/remote-agents.md +84 -0
- package/dist/docs/core/subagents.md +191 -0
- package/dist/docs/core/tools-api.md +131 -0
- package/dist/docs/examples/proxy-script.md +83 -0
- package/dist/docs/extensions/best-practices.md +139 -0
- package/dist/docs/extensions/index.md +45 -0
- package/dist/docs/extensions/reference.md +336 -0
- package/dist/docs/extensions/releasing.md +183 -0
- package/dist/docs/extensions/writing-extensions.md +281 -0
- package/dist/docs/faq.md +154 -0
- package/dist/docs/get-started/authentication.md +321 -0
- package/dist/docs/get-started/configuration-v1.md +888 -0
- package/dist/docs/get-started/configuration.md +1585 -0
- package/dist/docs/get-started/examples.md +219 -0
- package/dist/docs/get-started/gemini-3.md +101 -0
- package/dist/docs/get-started/index.md +71 -0
- package/dist/docs/get-started/installation.md +141 -0
- package/dist/docs/hooks/best-practices.md +677 -0
- package/dist/docs/hooks/index.md +164 -0
- package/dist/docs/hooks/reference.md +322 -0
- package/dist/docs/hooks/writing-hooks.md +450 -0
- package/dist/docs/ide-integration/ide-companion-spec.md +267 -0
- package/dist/docs/ide-integration/index.md +202 -0
- package/dist/docs/index.md +149 -0
- package/dist/docs/integration-tests.md +211 -0
- package/dist/docs/issue-and-pr-automation.md +134 -0
- package/dist/docs/local-development.md +128 -0
- package/dist/docs/mermaid/context.mmd +103 -0
- package/dist/docs/mermaid/render-path.mmd +64 -0
- package/dist/docs/npm.md +62 -0
- package/dist/docs/quota-and-pricing.md +158 -0
- package/dist/docs/release-confidence.md +164 -0
- package/dist/docs/releases.md +540 -0
- package/dist/docs/sidebar.json +152 -0
- package/dist/docs/tools/file-system.md +217 -0
- package/dist/docs/tools/index.md +98 -0
- package/dist/docs/tools/mcp-server.md +1079 -0
- package/dist/docs/tools/memory.md +54 -0
- package/dist/docs/tools/shell.md +260 -0
- package/dist/docs/tools/todos.md +57 -0
- package/dist/docs/tools/web-fetch.md +59 -0
- package/dist/docs/tools/web-search.md +42 -0
- package/dist/docs/tos-privacy.md +96 -0
- package/dist/docs/troubleshooting.md +173 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/src/__mocks__/fs/promises.d.ts +11 -0
- package/dist/src/__mocks__/fs/promises.js +17 -0
- package/dist/src/__mocks__/fs/promises.js.map +1 -0
- package/dist/src/agents/a2a-client-manager.d.ts +77 -0
- package/dist/src/agents/a2a-client-manager.js +173 -0
- package/dist/src/agents/a2a-client-manager.js.map +1 -0
- package/dist/src/agents/a2aUtils.d.ts +29 -0
- package/dist/src/agents/a2aUtils.js +113 -0
- package/dist/src/agents/a2aUtils.js.map +1 -0
- package/dist/src/agents/acknowledgedAgents.d.ts +18 -0
- package/dist/src/agents/acknowledgedAgents.js +58 -0
- package/dist/src/agents/acknowledgedAgents.js.map +1 -0
- package/dist/src/agents/agent-scheduler.d.ts +33 -0
- package/dist/src/agents/agent-scheduler.js +29 -0
- package/dist/src/agents/agent-scheduler.js.map +1 -0
- package/dist/src/agents/agentLoader.d.ts +73 -0
- package/dist/src/agents/agentLoader.js +268 -0
- package/dist/src/agents/agentLoader.js.map +1 -0
- package/dist/src/agents/cli-help-agent.d.ts +24 -0
- package/dist/src/agents/cli-help-agent.js +80 -0
- package/dist/src/agents/cli-help-agent.js.map +1 -0
- package/dist/src/agents/codebase-investigator.d.ts +47 -0
- package/dist/src/agents/codebase-investigator.js +159 -0
- package/dist/src/agents/codebase-investigator.js.map +1 -0
- package/dist/src/agents/generalist-agent.d.ts +21 -0
- package/dist/src/agents/generalist-agent.js +60 -0
- package/dist/src/agents/generalist-agent.js.map +1 -0
- package/dist/src/agents/local-executor.d.ts +110 -0
- package/dist/src/agents/local-executor.js +879 -0
- package/dist/src/agents/local-executor.js.map +1 -0
- package/dist/src/agents/local-invocation.d.ts +45 -0
- package/dist/src/agents/local-invocation.js +101 -0
- package/dist/src/agents/local-invocation.js.map +1 -0
- package/dist/src/agents/registry.d.ts +85 -0
- package/dist/src/agents/registry.js +374 -0
- package/dist/src/agents/registry.js.map +1 -0
- package/dist/src/agents/remote-invocation.d.ts +35 -0
- package/dist/src/agents/remote-invocation.js +127 -0
- package/dist/src/agents/remote-invocation.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.d.ts +38 -0
- package/dist/src/agents/subagent-tool-wrapper.js +51 -0
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -0
- package/dist/src/agents/subagent-tool.d.ts +15 -0
- package/dist/src/agents/subagent-tool.js +61 -0
- package/dist/src/agents/subagent-tool.js.map +1 -0
- package/dist/src/agents/types.d.ts +154 -0
- package/dist/src/agents/types.js +23 -0
- package/dist/src/agents/types.js.map +1 -0
- package/dist/src/agents/utils.d.ts +15 -0
- package/dist/src/agents/utils.js +29 -0
- package/dist/src/agents/utils.js.map +1 -0
- package/dist/src/availability/errorClassification.d.ts +7 -0
- package/dist/src/availability/errorClassification.js +20 -0
- package/dist/src/availability/errorClassification.js.map +1 -0
- package/dist/src/availability/modelAvailabilityService.d.ts +36 -0
- package/dist/src/availability/modelAvailabilityService.js +87 -0
- package/dist/src/availability/modelAvailabilityService.js.map +1 -0
- package/dist/src/availability/modelPolicy.d.ts +49 -0
- package/dist/src/availability/modelPolicy.js +7 -0
- package/dist/src/availability/modelPolicy.js.map +1 -0
- package/dist/src/availability/policyCatalog.d.ts +24 -0
- package/dist/src/availability/policyCatalog.js +106 -0
- package/dist/src/availability/policyCatalog.js.map +1 -0
- package/dist/src/availability/policyHelpers.d.ts +52 -0
- package/dist/src/availability/policyHelpers.js +143 -0
- package/dist/src/availability/policyHelpers.js.map +1 -0
- package/dist/src/availability/testUtils.d.ts +10 -0
- package/dist/src/availability/testUtils.js +22 -0
- package/dist/src/availability/testUtils.js.map +1 -0
- package/dist/src/code_assist/admin/admin_controls.d.ts +32 -0
- package/dist/src/code_assist/admin/admin_controls.js +120 -0
- package/dist/src/code_assist/admin/admin_controls.js.map +1 -0
- package/dist/src/code_assist/codeAssist.d.ts +12 -0
- package/dist/src/code_assist/codeAssist.js +31 -0
- package/dist/src/code_assist/codeAssist.js.map +1 -0
- package/dist/src/code_assist/converter.d.ts +75 -0
- package/dist/src/code_assist/converter.js +161 -0
- package/dist/src/code_assist/converter.js.map +1 -0
- package/dist/src/code_assist/experiments/client_metadata.d.ts +12 -0
- package/dist/src/code_assist/experiments/client_metadata.js +51 -0
- package/dist/src/code_assist/experiments/client_metadata.js.map +1 -0
- package/dist/src/code_assist/experiments/experiments.d.ts +17 -0
- package/dist/src/code_assist/experiments/experiments.js +57 -0
- package/dist/src/code_assist/experiments/experiments.js.map +1 -0
- package/dist/src/code_assist/experiments/flagNames.d.ts +16 -0
- package/dist/src/code_assist/experiments/flagNames.js +16 -0
- package/dist/src/code_assist/experiments/flagNames.js.map +1 -0
- package/dist/src/code_assist/experiments/types.d.ts +35 -0
- package/dist/src/code_assist/experiments/types.js +7 -0
- package/dist/src/code_assist/experiments/types.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.d.ts +25 -0
- package/dist/src/code_assist/oauth-credential-storage.js +109 -0
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -0
- package/dist/src/code_assist/oauth2.d.ts +25 -0
- package/dist/src/code_assist/oauth2.js +579 -0
- package/dist/src/code_assist/oauth2.js.map +1 -0
- package/dist/src/code_assist/server.d.ts +50 -0
- package/dist/src/code_assist/server.js +228 -0
- package/dist/src/code_assist/server.js.map +1 -0
- package/dist/src/code_assist/setup.d.ts +46 -0
- package/dist/src/code_assist/setup.js +179 -0
- package/dist/src/code_assist/setup.js.map +1 -0
- package/dist/src/code_assist/telemetry.d.ts +14 -0
- package/dist/src/code_assist/telemetry.js +157 -0
- package/dist/src/code_assist/telemetry.js.map +1 -0
- package/dist/src/code_assist/types.d.ts +306 -0
- package/dist/src/code_assist/types.js +94 -0
- package/dist/src/code_assist/types.js.map +1 -0
- package/dist/src/cognitive/gemini-adapter.d.ts +29 -0
- package/dist/src/cognitive/gemini-adapter.js +109 -0
- package/dist/src/cognitive/gemini-adapter.js.map +1 -0
- package/dist/src/cognitive/index.d.ts +22 -0
- package/dist/src/cognitive/index.js +50 -0
- package/dist/src/cognitive/index.js.map +1 -0
- package/dist/src/cognitive/integration.d.ts +57 -0
- package/dist/src/cognitive/integration.js +103 -0
- package/dist/src/cognitive/integration.js.map +1 -0
- package/dist/src/cognitive/loader/index.d.ts +8 -0
- package/dist/src/cognitive/loader/index.js +9 -0
- package/dist/src/cognitive/loader/index.js.map +1 -0
- package/dist/src/cognitive/loader/module-loader.d.ts +67 -0
- package/dist/src/cognitive/loader/module-loader.js +369 -0
- package/dist/src/cognitive/loader/module-loader.js.map +1 -0
- package/dist/src/cognitive/runtime/envelope.d.ts +31 -0
- package/dist/src/cognitive/runtime/envelope.js +167 -0
- package/dist/src/cognitive/runtime/envelope.js.map +1 -0
- package/dist/src/cognitive/runtime/executor.d.ts +65 -0
- package/dist/src/cognitive/runtime/executor.js +245 -0
- package/dist/src/cognitive/runtime/executor.js.map +1 -0
- package/dist/src/cognitive/runtime/index.d.ts +12 -0
- package/dist/src/cognitive/runtime/index.js +18 -0
- package/dist/src/cognitive/runtime/index.js.map +1 -0
- package/dist/src/cognitive/runtime/prompt-builder.d.ts +34 -0
- package/dist/src/cognitive/runtime/prompt-builder.js +216 -0
- package/dist/src/cognitive/runtime/prompt-builder.js.map +1 -0
- package/dist/src/cognitive/runtime/repair-pass.d.ts +43 -0
- package/dist/src/cognitive/runtime/repair-pass.js +170 -0
- package/dist/src/cognitive/runtime/repair-pass.js.map +1 -0
- package/dist/src/cognitive/runtime/risk-aggregator.d.ts +39 -0
- package/dist/src/cognitive/runtime/risk-aggregator.js +90 -0
- package/dist/src/cognitive/runtime/risk-aggregator.js.map +1 -0
- package/dist/src/cognitive/tool/cognitive-registry.d.ts +99 -0
- package/dist/src/cognitive/tool/cognitive-registry.js +192 -0
- package/dist/src/cognitive/tool/cognitive-registry.js.map +1 -0
- package/dist/src/cognitive/tool/cognitive-tool.d.ts +56 -0
- package/dist/src/cognitive/tool/cognitive-tool.js +217 -0
- package/dist/src/cognitive/tool/cognitive-tool.js.map +1 -0
- package/dist/src/cognitive/tool/index.d.ts +9 -0
- package/dist/src/cognitive/tool/index.js +10 -0
- package/dist/src/cognitive/tool/index.js.map +1 -0
- package/dist/src/cognitive/types.d.ts +234 -0
- package/dist/src/cognitive/types.js +10 -0
- package/dist/src/cognitive/types.js.map +1 -0
- package/dist/src/cognitive/validator/envelope-validator.d.ts +45 -0
- package/dist/src/cognitive/validator/envelope-validator.js +214 -0
- package/dist/src/cognitive/validator/envelope-validator.js.map +1 -0
- package/dist/src/cognitive/validator/index.d.ts +9 -0
- package/dist/src/cognitive/validator/index.js +10 -0
- package/dist/src/cognitive/validator/index.js.map +1 -0
- package/dist/src/cognitive/validator/schema-validator.d.ts +46 -0
- package/dist/src/cognitive/validator/schema-validator.js +202 -0
- package/dist/src/cognitive/validator/schema-validator.js.map +1 -0
- package/dist/src/commands/cognitive.d.ts +39 -0
- package/dist/src/commands/cognitive.js +335 -0
- package/dist/src/commands/cognitive.js.map +1 -0
- package/dist/src/commands/extensions.d.ts +7 -0
- package/dist/src/commands/extensions.js +9 -0
- package/dist/src/commands/extensions.js.map +1 -0
- package/dist/src/commands/init.d.ts +7 -0
- package/dist/src/commands/init.js +53 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/memory.d.ts +11 -0
- package/dist/src/commands/memory.js +80 -0
- package/dist/src/commands/memory.js.map +1 -0
- package/dist/src/commands/restore.d.ts +9 -0
- package/dist/src/commands/restore.js +46 -0
- package/dist/src/commands/restore.js.map +1 -0
- package/dist/src/commands/types.d.ts +41 -0
- package/dist/src/commands/types.js +7 -0
- package/dist/src/commands/types.js.map +1 -0
- package/dist/src/config/config.d.ts +766 -0
- package/dist/src/config/config.js +1625 -0
- package/dist/src/config/config.js.map +1 -0
- package/dist/src/config/constants.d.ts +15 -0
- package/dist/src/config/constants.js +24 -0
- package/dist/src/config/constants.js.map +1 -0
- package/dist/src/config/defaultModelConfigs.d.ts +7 -0
- package/dist/src/config/defaultModelConfigs.js +231 -0
- package/dist/src/config/defaultModelConfigs.js.map +1 -0
- package/dist/src/config/models.d.ts +67 -0
- package/dist/src/config/models.js +144 -0
- package/dist/src/config/models.js.map +1 -0
- package/dist/src/config/storage.d.ts +44 -0
- package/dist/src/config/storage.js +139 -0
- package/dist/src/config/storage.js.map +1 -0
- package/dist/src/confirmation-bus/index.d.ts +7 -0
- package/dist/src/confirmation-bus/index.js +8 -0
- package/dist/src/confirmation-bus/index.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.d.ts +24 -0
- package/dist/src/confirmation-bus/message-bus.js +120 -0
- package/dist/src/confirmation-bus/message-bus.js.map +1 -0
- package/dist/src/confirmation-bus/types.d.ts +147 -0
- package/dist/src/confirmation-bus/types.js +25 -0
- package/dist/src/confirmation-bus/types.js.map +1 -0
- package/dist/src/core/apiKeyCredentialStorage.d.ts +17 -0
- package/dist/src/core/apiKeyCredentialStorage.js +64 -0
- package/dist/src/core/apiKeyCredentialStorage.js.map +1 -0
- package/dist/src/core/baseLlmClient.d.ts +74 -0
- package/dist/src/core/baseLlmClient.js +167 -0
- package/dist/src/core/baseLlmClient.js.map +1 -0
- package/dist/src/core/client.d.ts +59 -0
- package/dist/src/core/client.js +716 -0
- package/dist/src/core/client.js.map +1 -0
- package/dist/src/core/contentGenerator.d.ts +34 -0
- package/dist/src/core/contentGenerator.js +107 -0
- package/dist/src/core/contentGenerator.js.map +1 -0
- package/dist/src/core/coreToolHookTriggers.d.ts +23 -0
- package/dist/src/core/coreToolHookTriggers.js +195 -0
- package/dist/src/core/coreToolHookTriggers.js.map +1 -0
- package/dist/src/core/coreToolScheduler.d.ts +50 -0
- package/dist/src/core/coreToolScheduler.js +703 -0
- package/dist/src/core/coreToolScheduler.js.map +1 -0
- package/dist/src/core/fakeContentGenerator.d.ts +34 -0
- package/dist/src/core/fakeContentGenerator.js +59 -0
- package/dist/src/core/fakeContentGenerator.js.map +1 -0
- package/dist/src/core/geminiChat.d.ts +160 -0
- package/dist/src/core/geminiChat.js +744 -0
- package/dist/src/core/geminiChat.js.map +1 -0
- package/dist/src/core/geminiRequest.d.ts +13 -0
- package/dist/src/core/geminiRequest.js +11 -0
- package/dist/src/core/geminiRequest.js.map +1 -0
- package/dist/src/core/logger.d.ts +65 -0
- package/dist/src/core/logger.js +368 -0
- package/dist/src/core/logger.js.map +1 -0
- package/dist/src/core/loggingContentGenerator.d.ts +29 -0
- package/dist/src/core/loggingContentGenerator.js +202 -0
- package/dist/src/core/loggingContentGenerator.js.map +1 -0
- package/dist/src/core/prompts.d.ts +19 -0
- package/dist/src/core/prompts.js +27 -0
- package/dist/src/core/prompts.js.map +1 -0
- package/dist/src/core/recordingContentGenerator.d.ts +19 -0
- package/dist/src/core/recordingContentGenerator.js +82 -0
- package/dist/src/core/recordingContentGenerator.js.map +1 -0
- package/dist/src/core/tokenLimits.d.ts +10 -0
- package/dist/src/core/tokenLimits.js +22 -0
- package/dist/src/core/tokenLimits.js.map +1 -0
- package/dist/src/core/turn.d.ts +167 -0
- package/dist/src/core/turn.js +209 -0
- package/dist/src/core/turn.js.map +1 -0
- package/dist/src/fallback/handler.d.ts +7 -0
- package/dist/src/fallback/handler.js +110 -0
- package/dist/src/fallback/handler.js.map +1 -0
- package/dist/src/fallback/types.d.ts +31 -0
- package/dist/src/fallback/types.js +7 -0
- package/dist/src/fallback/types.js.map +1 -0
- package/dist/src/generated/git-commit.d.ts +7 -0
- package/dist/src/generated/git-commit.js +10 -0
- package/dist/src/generated/git-commit.js.map +1 -0
- package/dist/src/hooks/hookAggregator.d.ts +68 -0
- package/dist/src/hooks/hookAggregator.js +279 -0
- package/dist/src/hooks/hookAggregator.js.map +1 -0
- package/dist/src/hooks/hookEventHandler.d.ts +107 -0
- package/dist/src/hooks/hookEventHandler.js +325 -0
- package/dist/src/hooks/hookEventHandler.js.map +1 -0
- package/dist/src/hooks/hookPlanner.d.ts +42 -0
- package/dist/src/hooks/hookPlanner.js +103 -0
- package/dist/src/hooks/hookPlanner.js.map +1 -0
- package/dist/src/hooks/hookRegistry.d.ts +75 -0
- package/dist/src/hooks/hookRegistry.js +215 -0
- package/dist/src/hooks/hookRegistry.js.map +1 -0
- package/dist/src/hooks/hookRunner.d.ts +44 -0
- package/dist/src/hooks/hookRunner.js +329 -0
- package/dist/src/hooks/hookRunner.js.map +1 -0
- package/dist/src/hooks/hookSystem.d.ts +99 -0
- package/dist/src/hooks/hookSystem.js +262 -0
- package/dist/src/hooks/hookSystem.js.map +1 -0
- package/dist/src/hooks/hookTranslator.d.ts +113 -0
- package/dist/src/hooks/hookTranslator.js +233 -0
- package/dist/src/hooks/hookTranslator.js.map +1 -0
- package/dist/src/hooks/index.d.ts +16 -0
- package/dist/src/hooks/index.js +16 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/hooks/trustedHooks.d.ts +28 -0
- package/dist/src/hooks/trustedHooks.js +90 -0
- package/dist/src/hooks/trustedHooks.js.map +1 -0
- package/dist/src/hooks/types.d.ts +442 -0
- package/dist/src/hooks/types.js +303 -0
- package/dist/src/hooks/types.js.map +1 -0
- package/dist/src/ide/constants.d.ts +9 -0
- package/dist/src/ide/constants.js +10 -0
- package/dist/src/ide/constants.js.map +1 -0
- package/dist/src/ide/detect-ide.d.ts +109 -0
- package/dist/src/ide/detect-ide.js +125 -0
- package/dist/src/ide/detect-ide.js.map +1 -0
- package/dist/src/ide/ide-client.d.ts +113 -0
- package/dist/src/ide/ide-client.js +669 -0
- package/dist/src/ide/ide-client.js.map +1 -0
- package/dist/src/ide/ide-installer.d.ts +14 -0
- package/dist/src/ide/ide-installer.js +227 -0
- package/dist/src/ide/ide-installer.js.map +1 -0
- package/dist/src/ide/ideContext.d.ts +44 -0
- package/dist/src/ide/ideContext.js +101 -0
- package/dist/src/ide/ideContext.js.map +1 -0
- package/dist/src/ide/process-utils.d.ts +21 -0
- package/dist/src/ide/process-utils.js +181 -0
- package/dist/src/ide/process-utils.js.map +1 -0
- package/dist/src/ide/types.d.ts +486 -0
- package/dist/src/ide/types.js +138 -0
- package/dist/src/ide/types.js.map +1 -0
- package/dist/src/index.d.ts +145 -0
- package/dist/src/index.js +161 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcp/auth-provider.d.ts +16 -0
- package/dist/src/mcp/auth-provider.js +7 -0
- package/dist/src/mcp/auth-provider.js.map +1 -0
- package/dist/src/mcp/google-auth-provider.d.ts +33 -0
- package/dist/src/mcp/google-auth-provider.js +118 -0
- package/dist/src/mcp/google-auth-provider.js.map +1 -0
- package/dist/src/mcp/oauth-provider.d.ts +160 -0
- package/dist/src/mcp/oauth-provider.js +729 -0
- package/dist/src/mcp/oauth-provider.js.map +1 -0
- package/dist/src/mcp/oauth-token-storage.d.ts +65 -0
- package/dist/src/mcp/oauth-token-storage.js +181 -0
- package/dist/src/mcp/oauth-token-storage.js.map +1 -0
- package/dist/src/mcp/oauth-utils.d.ts +142 -0
- package/dist/src/mcp/oauth-utils.js +289 -0
- package/dist/src/mcp/oauth-utils.js.map +1 -0
- package/dist/src/mcp/sa-impersonation-provider.d.ts +27 -0
- package/dist/src/mcp/sa-impersonation-provider.js +113 -0
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.d.ts +19 -0
- package/dist/src/mcp/token-storage/base-token-storage.js +36 -0
- package/dist/src/mcp/token-storage/base-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.d.ts +24 -0
- package/dist/src/mcp/token-storage/file-token-storage.js +145 -0
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.d.ts +23 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js +78 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/index.d.ts +11 -0
- package/dist/src/mcp/token-storage/index.js +12 -0
- package/dist/src/mcp/token-storage/index.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +35 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js +246 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/types.d.ts +44 -0
- package/dist/src/mcp/token-storage/types.js +11 -0
- package/dist/src/mcp/token-storage/types.js.map +1 -0
- package/dist/src/mocks/msw.d.ts +6 -0
- package/dist/src/mocks/msw.js +8 -0
- package/dist/src/mocks/msw.js.map +1 -0
- package/dist/src/output/json-formatter.d.ts +11 -0
- package/dist/src/output/json-formatter.js +33 -0
- package/dist/src/output/json-formatter.js.map +1 -0
- package/dist/src/output/stream-json-formatter.d.ts +32 -0
- package/dist/src/output/stream-json-formatter.js +58 -0
- package/dist/src/output/stream-json-formatter.js.map +1 -0
- package/dist/src/output/types.d.ts +85 -0
- package/dist/src/output/types.js +22 -0
- package/dist/src/output/types.js.map +1 -0
- package/dist/src/policy/config.d.ts +31 -0
- package/dist/src/policy/config.js +355 -0
- package/dist/src/policy/config.js.map +1 -0
- package/dist/src/policy/index.d.ts +9 -0
- package/dist/src/policy/index.js +10 -0
- package/dist/src/policy/index.js.map +1 -0
- package/dist/src/policy/policies/discovered.toml +8 -0
- package/dist/src/policy/policies/plan.toml +79 -0
- package/dist/src/policy/policies/read-only.toml +51 -0
- package/dist/src/policy/policies/write.toml +78 -0
- package/dist/src/policy/policies/yolo.toml +32 -0
- package/dist/src/policy/policy-engine.d.ts +65 -0
- package/dist/src/policy/policy-engine.js +357 -0
- package/dist/src/policy/policy-engine.js.map +1 -0
- package/dist/src/policy/stable-stringify.d.ts +58 -0
- package/dist/src/policy/stable-stringify.js +122 -0
- package/dist/src/policy/stable-stringify.js.map +1 -0
- package/dist/src/policy/toml-loader.d.ts +45 -0
- package/dist/src/policy/toml-loader.js +366 -0
- package/dist/src/policy/toml-loader.js.map +1 -0
- package/dist/src/policy/types.d.ts +220 -0
- package/dist/src/policy/types.js +44 -0
- package/dist/src/policy/types.js.map +1 -0
- package/dist/src/policy/utils.d.ts +21 -0
- package/dist/src/policy/utils.js +45 -0
- package/dist/src/policy/utils.js.map +1 -0
- package/dist/src/prompts/mcp-prompts.d.ts +8 -0
- package/dist/src/prompts/mcp-prompts.js +13 -0
- package/dist/src/prompts/mcp-prompts.js.map +1 -0
- package/dist/src/prompts/prompt-registry.d.ts +34 -0
- package/dist/src/prompts/prompt-registry.js +64 -0
- package/dist/src/prompts/prompt-registry.js.map +1 -0
- package/dist/src/prompts/promptProvider.d.ts +18 -0
- package/dist/src/prompts/promptProvider.js +129 -0
- package/dist/src/prompts/promptProvider.js.map +1 -0
- package/dist/src/prompts/snippets.d.ts +76 -0
- package/dist/src/prompts/snippets.js +455 -0
- package/dist/src/prompts/snippets.js.map +1 -0
- package/dist/src/prompts/utils.d.ts +23 -0
- package/dist/src/prompts/utils.js +72 -0
- package/dist/src/prompts/utils.js.map +1 -0
- package/dist/src/resources/resource-registry.d.ts +30 -0
- package/dist/src/resources/resource-registry.js +57 -0
- package/dist/src/resources/resource-registry.js.map +1 -0
- package/dist/src/routing/modelRouterService.d.ts +23 -0
- package/dist/src/routing/modelRouterService.js +80 -0
- package/dist/src/routing/modelRouterService.js.map +1 -0
- package/dist/src/routing/routingStrategy.d.ts +64 -0
- package/dist/src/routing/routingStrategy.js +7 -0
- package/dist/src/routing/routingStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/classifierStrategy.js +152 -0
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.d.ts +26 -0
- package/dist/src/routing/strategies/compositeStrategy.js +70 -0
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/defaultStrategy.js +21 -0
- package/dist/src/routing/strategies/defaultStrategy.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/fallbackStrategy.js +33 -0
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.d.ts +13 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.js +178 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.d.ts +15 -0
- package/dist/src/routing/strategies/overrideStrategy.js +29 -0
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -0
- package/dist/src/safety/built-in.d.ts +21 -0
- package/dist/src/safety/built-in.js +106 -0
- package/dist/src/safety/built-in.js.map +1 -0
- package/dist/src/safety/checker-runner.d.ts +48 -0
- package/dist/src/safety/checker-runner.js +219 -0
- package/dist/src/safety/checker-runner.js.map +1 -0
- package/dist/src/safety/context-builder.d.ts +23 -0
- package/dist/src/safety/context-builder.js +47 -0
- package/dist/src/safety/context-builder.js.map +1 -0
- package/dist/src/safety/protocol.d.ts +88 -0
- package/dist/src/safety/protocol.js +15 -0
- package/dist/src/safety/protocol.js.map +1 -0
- package/dist/src/safety/registry.d.ts +26 -0
- package/dist/src/safety/registry.js +65 -0
- package/dist/src/safety/registry.js.map +1 -0
- package/dist/src/scheduler/confirmation.d.ts +49 -0
- package/dist/src/scheduler/confirmation.js +183 -0
- package/dist/src/scheduler/confirmation.js.map +1 -0
- package/dist/src/scheduler/policy.d.ts +25 -0
- package/dist/src/scheduler/policy.js +108 -0
- package/dist/src/scheduler/policy.js.map +1 -0
- package/dist/src/scheduler/scheduler.d.ts +61 -0
- package/dist/src/scheduler/scheduler.js +356 -0
- package/dist/src/scheduler/scheduler.js.map +1 -0
- package/dist/src/scheduler/state-manager.d.ts +73 -0
- package/dist/src/scheduler/state-manager.js +356 -0
- package/dist/src/scheduler/state-manager.js.map +1 -0
- package/dist/src/scheduler/tool-executor.d.ts +22 -0
- package/dist/src/scheduler/tool-executor.js +201 -0
- package/dist/src/scheduler/tool-executor.js.map +1 -0
- package/dist/src/scheduler/tool-modifier.d.ts +23 -0
- package/dist/src/scheduler/tool-modifier.js +50 -0
- package/dist/src/scheduler/tool-modifier.js.map +1 -0
- package/dist/src/scheduler/types.d.ts +118 -0
- package/dist/src/scheduler/types.js +7 -0
- package/dist/src/scheduler/types.js.map +1 -0
- package/dist/src/services/chatCompressionService.d.ts +41 -0
- package/dist/src/services/chatCompressionService.js +339 -0
- package/dist/src/services/chatCompressionService.js.map +1 -0
- package/dist/src/services/chatRecordingService.d.ts +174 -0
- package/dist/src/services/chatRecordingService.js +427 -0
- package/dist/src/services/chatRecordingService.js.map +1 -0
- package/dist/src/services/contextManager.d.ts +29 -0
- package/dist/src/services/contextManager.js +71 -0
- package/dist/src/services/contextManager.js.map +1 -0
- package/dist/src/services/environmentSanitization.d.ts +15 -0
- package/dist/src/services/environmentSanitization.js +145 -0
- package/dist/src/services/environmentSanitization.js.map +1 -0
- package/dist/src/services/fileDiscoveryService.d.ts +45 -0
- package/dist/src/services/fileDiscoveryService.js +141 -0
- package/dist/src/services/fileDiscoveryService.js.map +1 -0
- package/dist/src/services/fileSystemService.d.ts +31 -0
- package/dist/src/services/fileSystemService.js +18 -0
- package/dist/src/services/fileSystemService.js.map +1 -0
- package/dist/src/services/gitService.d.ts +24 -0
- package/dist/src/services/gitService.js +132 -0
- package/dist/src/services/gitService.js.map +1 -0
- package/dist/src/services/loopDetectionService.d.ts +106 -0
- package/dist/src/services/loopDetectionService.js +433 -0
- package/dist/src/services/loopDetectionService.js.map +1 -0
- package/dist/src/services/modelConfigService.d.ts +86 -0
- package/dist/src/services/modelConfigService.js +215 -0
- package/dist/src/services/modelConfigService.js.map +1 -0
- package/dist/src/services/modelConfigServiceTestUtils.d.ts +10 -0
- package/dist/src/services/modelConfigServiceTestUtils.js +17 -0
- package/dist/src/services/modelConfigServiceTestUtils.js.map +1 -0
- package/dist/src/services/sessionSummaryService.d.ts +28 -0
- package/dist/src/services/sessionSummaryService.js +131 -0
- package/dist/src/services/sessionSummaryService.js.map +1 -0
- package/dist/src/services/sessionSummaryUtils.d.ts +16 -0
- package/dist/src/services/sessionSummaryUtils.js +129 -0
- package/dist/src/services/sessionSummaryUtils.js.map +1 -0
- package/dist/src/services/shellExecutionService.d.ts +145 -0
- package/dist/src/services/shellExecutionService.js +871 -0
- package/dist/src/services/shellExecutionService.js.map +1 -0
- package/dist/src/services/test-data/resolved-aliases-retry.golden.json +238 -0
- package/dist/src/services/test-data/resolved-aliases.golden.json +238 -0
- package/dist/src/skills/builtin/skill-creator/SKILL.md +382 -0
- package/dist/src/skills/builtin/skill-creator/scripts/init_skill.cjs +235 -0
- package/dist/src/skills/builtin/skill-creator/scripts/package_skill.cjs +102 -0
- package/dist/src/skills/builtin/skill-creator/scripts/validate_skill.cjs +127 -0
- package/dist/src/skills/skillLoader.d.ts +31 -0
- package/dist/src/skills/skillLoader.js +133 -0
- package/dist/src/skills/skillLoader.js.map +1 -0
- package/dist/src/skills/skillManager.d.ts +69 -0
- package/dist/src/skills/skillManager.js +138 -0
- package/dist/src/skills/skillManager.js.map +1 -0
- package/dist/src/telemetry/activity-detector.d.ts +41 -0
- package/dist/src/telemetry/activity-detector.js +61 -0
- package/dist/src/telemetry/activity-detector.js.map +1 -0
- package/dist/src/telemetry/activity-monitor.d.ts +116 -0
- package/dist/src/telemetry/activity-monitor.js +209 -0
- package/dist/src/telemetry/activity-monitor.js.map +1 -0
- package/dist/src/telemetry/activity-types.d.ts +19 -0
- package/dist/src/telemetry/activity-types.js +21 -0
- package/dist/src/telemetry/activity-types.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +172 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +1316 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +150 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +377 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -0
- package/dist/src/telemetry/config.d.ts +31 -0
- package/dist/src/telemetry/config.js +78 -0
- package/dist/src/telemetry/config.js.map +1 -0
- package/dist/src/telemetry/constants.d.ts +6 -0
- package/dist/src/telemetry/constants.js +7 -0
- package/dist/src/telemetry/constants.js.map +1 -0
- package/dist/src/telemetry/file-exporters.d.ts +29 -0
- package/dist/src/telemetry/file-exporters.js +62 -0
- package/dist/src/telemetry/file-exporters.js.map +1 -0
- package/dist/src/telemetry/gcp-exporters.d.ts +35 -0
- package/dist/src/telemetry/gcp-exporters.js +120 -0
- package/dist/src/telemetry/gcp-exporters.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.d.ts +43 -0
- package/dist/src/telemetry/high-water-mark-tracker.js +88 -0
- package/dist/src/telemetry/high-water-mark-tracker.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +33 -0
- package/dist/src/telemetry/index.js +44 -0
- package/dist/src/telemetry/index.js.map +1 -0
- package/dist/src/telemetry/integration.test.circular.d.ts +6 -0
- package/dist/src/telemetry/integration.test.circular.js +54 -0
- package/dist/src/telemetry/integration.test.circular.js.map +1 -0
- package/dist/src/telemetry/loggers.d.ts +46 -0
- package/dist/src/telemetry/loggers.js +517 -0
- package/dist/src/telemetry/loggers.js.map +1 -0
- package/dist/src/telemetry/loggers.test.circular.d.ts +6 -0
- package/dist/src/telemetry/loggers.test.circular.js +107 -0
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -0
- package/dist/src/telemetry/memory-monitor.d.ts +149 -0
- package/dist/src/telemetry/memory-monitor.js +335 -0
- package/dist/src/telemetry/memory-monitor.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +533 -0
- package/dist/src/telemetry/metrics.js +852 -0
- package/dist/src/telemetry/metrics.js.map +1 -0
- package/dist/src/telemetry/rate-limiter.d.ts +48 -0
- package/dist/src/telemetry/rate-limiter.js +100 -0
- package/dist/src/telemetry/rate-limiter.js.map +1 -0
- package/dist/src/telemetry/sanitize.d.ts +25 -0
- package/dist/src/telemetry/sanitize.js +48 -0
- package/dist/src/telemetry/sanitize.js.map +1 -0
- package/dist/src/telemetry/sdk.d.ts +16 -0
- package/dist/src/telemetry/sdk.js +307 -0
- package/dist/src/telemetry/sdk.js.map +1 -0
- package/dist/src/telemetry/semantic.d.ts +82 -0
- package/dist/src/telemetry/semantic.js +357 -0
- package/dist/src/telemetry/semantic.js.map +1 -0
- package/dist/src/telemetry/startupProfiler.d.ts +51 -0
- package/dist/src/telemetry/startupProfiler.js +170 -0
- package/dist/src/telemetry/startupProfiler.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.js +14 -0
- package/dist/src/telemetry/telemetry-utils.js.map +1 -0
- package/dist/src/telemetry/telemetryAttributes.d.ts +8 -0
- package/dist/src/telemetry/telemetryAttributes.js +19 -0
- package/dist/src/telemetry/telemetryAttributes.js.map +1 -0
- package/dist/src/telemetry/tool-call-decision.d.ts +13 -0
- package/dist/src/telemetry/tool-call-decision.js +29 -0
- package/dist/src/telemetry/tool-call-decision.js.map +1 -0
- package/dist/src/telemetry/trace.d.ts +46 -0
- package/dist/src/telemetry/trace.js +121 -0
- package/dist/src/telemetry/trace.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +566 -0
- package/dist/src/telemetry/types.js +1495 -0
- package/dist/src/telemetry/types.js.map +1 -0
- package/dist/src/telemetry/uiTelemetry.d.ts +76 -0
- package/dist/src/telemetry/uiTelemetry.js +154 -0
- package/dist/src/telemetry/uiTelemetry.js.map +1 -0
- package/dist/src/test-utils/config.d.ts +17 -0
- package/dist/src/test-utils/config.js +32 -0
- package/dist/src/test-utils/config.js.map +1 -0
- package/dist/src/test-utils/index.d.ts +6 -0
- package/dist/src/test-utils/index.js +7 -0
- package/dist/src/test-utils/index.js.map +1 -0
- package/dist/src/test-utils/mock-message-bus.d.ts +43 -0
- package/dist/src/test-utils/mock-message-bus.js +96 -0
- package/dist/src/test-utils/mock-message-bus.js.map +1 -0
- package/dist/src/test-utils/mock-tool.d.ts +69 -0
- package/dist/src/test-utils/mock-tool.js +123 -0
- package/dist/src/test-utils/mock-tool.js.map +1 -0
- package/dist/src/test-utils/mockWorkspaceContext.d.ts +13 -0
- package/dist/src/test-utils/mockWorkspaceContext.js +24 -0
- package/dist/src/test-utils/mockWorkspaceContext.js.map +1 -0
- package/dist/src/tools/activate-skill.d.ts +27 -0
- package/dist/src/tools/activate-skill.js +133 -0
- package/dist/src/tools/activate-skill.js.map +1 -0
- package/dist/src/tools/ask-user.d.ts +23 -0
- package/dist/src/tools/ask-user.js +155 -0
- package/dist/src/tools/ask-user.js.map +1 -0
- package/dist/src/tools/constants.d.ts +7 -0
- package/dist/src/tools/constants.js +8 -0
- package/dist/src/tools/constants.js.map +1 -0
- package/dist/src/tools/diffOptions.d.ts +9 -0
- package/dist/src/tools/diffOptions.js +50 -0
- package/dist/src/tools/diffOptions.js.map +1 -0
- package/dist/src/tools/edit.d.ts +79 -0
- package/dist/src/tools/edit.js +750 -0
- package/dist/src/tools/edit.js.map +1 -0
- package/dist/src/tools/get-internal-docs.d.ts +27 -0
- package/dist/src/tools/get-internal-docs.js +122 -0
- package/dist/src/tools/get-internal-docs.js.map +1 -0
- package/dist/src/tools/glob.d.ts +57 -0
- package/dist/src/tools/glob.js +240 -0
- package/dist/src/tools/glob.js.map +1 -0
- package/dist/src/tools/grep.d.ts +41 -0
- package/dist/src/tools/grep.js +505 -0
- package/dist/src/tools/grep.js.map +1 -0
- package/dist/src/tools/ls.d.ts +69 -0
- package/dist/src/tools/ls.js +214 -0
- package/dist/src/tools/ls.js.map +1 -0
- package/dist/src/tools/mcp-client-manager.d.ts +93 -0
- package/dist/src/tools/mcp-client-manager.js +338 -0
- package/dist/src/tools/mcp-client-manager.js.map +1 -0
- package/dist/src/tools/mcp-client.d.ts +243 -0
- package/dist/src/tools/mcp-client.js +1351 -0
- package/dist/src/tools/mcp-client.js.map +1 -0
- package/dist/src/tools/mcp-tool.d.ts +49 -0
- package/dist/src/tools/mcp-tool.js +300 -0
- package/dist/src/tools/mcp-tool.js.map +1 -0
- package/dist/src/tools/memoryTool.d.ts +42 -0
- package/dist/src/tools/memoryTool.js +269 -0
- package/dist/src/tools/memoryTool.js.map +1 -0
- package/dist/src/tools/modifiable-tool.d.ts +36 -0
- package/dist/src/tools/modifiable-tool.js +110 -0
- package/dist/src/tools/modifiable-tool.js.map +1 -0
- package/dist/src/tools/read-file.d.ts +37 -0
- package/dist/src/tools/read-file.js +141 -0
- package/dist/src/tools/read-file.js.map +1 -0
- package/dist/src/tools/read-many-files.d.ts +54 -0
- package/dist/src/tools/read-many-files.js +364 -0
- package/dist/src/tools/read-many-files.js.map +1 -0
- package/dist/src/tools/ripGrep.d.ts +74 -0
- package/dist/src/tools/ripGrep.js +422 -0
- package/dist/src/tools/ripGrep.js.map +1 -0
- package/dist/src/tools/shell.d.ts +33 -0
- package/dist/src/tools/shell.js +436 -0
- package/dist/src/tools/shell.js.map +1 -0
- package/dist/src/tools/tool-error.d.ts +70 -0
- package/dist/src/tools/tool-error.js +92 -0
- package/dist/src/tools/tool-error.js.map +1 -0
- package/dist/src/tools/tool-names.d.ts +41 -0
- package/dist/src/tools/tool-names.js +94 -0
- package/dist/src/tools/tool-names.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +103 -0
- package/dist/src/tools/tool-registry.js +429 -0
- package/dist/src/tools/tool-registry.js.map +1 -0
- package/dist/src/tools/tools.d.ts +347 -0
- package/dist/src/tools/tools.js +405 -0
- package/dist/src/tools/tools.js.map +1 -0
- package/dist/src/tools/web-fetch.d.ts +35 -0
- package/dist/src/tools/web-fetch.js +299 -0
- package/dist/src/tools/web-fetch.js.map +1 -0
- package/dist/src/tools/web-search.d.ts +50 -0
- package/dist/src/tools/web-search.js +141 -0
- package/dist/src/tools/web-search.js.map +1 -0
- package/dist/src/tools/write-file.d.ts +53 -0
- package/dist/src/tools/write-file.js +341 -0
- package/dist/src/tools/write-file.js.map +1 -0
- package/dist/src/tools/write-todos.d.ts +50 -0
- package/dist/src/tools/write-todos.js +194 -0
- package/dist/src/tools/write-todos.js.map +1 -0
- package/dist/src/utils/apiConversionUtils.d.ts +12 -0
- package/dist/src/utils/apiConversionUtils.js +46 -0
- package/dist/src/utils/apiConversionUtils.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.d.ts +32 -0
- package/dist/src/utils/bfsFileSearch.js +136 -0
- package/dist/src/utils/bfsFileSearch.js.map +1 -0
- package/dist/src/utils/browser.d.ts +13 -0
- package/dist/src/utils/browser.js +50 -0
- package/dist/src/utils/browser.js.map +1 -0
- package/dist/src/utils/channel.d.ts +19 -0
- package/dist/src/utils/channel.js +49 -0
- package/dist/src/utils/channel.js.map +1 -0
- package/dist/src/utils/checkpointUtils.d.ts +82 -0
- package/dist/src/utils/checkpointUtils.js +117 -0
- package/dist/src/utils/checkpointUtils.js.map +1 -0
- package/dist/src/utils/constants.d.ts +7 -0
- package/dist/src/utils/constants.js +8 -0
- package/dist/src/utils/constants.js.map +1 -0
- package/dist/src/utils/customHeaderUtils.d.ts +9 -0
- package/dist/src/utils/customHeaderUtils.js +34 -0
- package/dist/src/utils/customHeaderUtils.js.map +1 -0
- package/dist/src/utils/debugLogger.d.ts +28 -0
- package/dist/src/utils/debugLogger.js +61 -0
- package/dist/src/utils/debugLogger.js.map +1 -0
- package/dist/src/utils/delay.d.ts +16 -0
- package/dist/src/utils/delay.js +43 -0
- package/dist/src/utils/delay.js.map +1 -0
- package/dist/src/utils/editCorrector.d.ts +54 -0
- package/dist/src/utils/editCorrector.js +596 -0
- package/dist/src/utils/editCorrector.js.map +1 -0
- package/dist/src/utils/editor.d.ts +39 -0
- package/dist/src/utils/editor.js +219 -0
- package/dist/src/utils/editor.js.map +1 -0
- package/dist/src/utils/environmentContext.d.ts +23 -0
- package/dist/src/utils/environmentContext.js +81 -0
- package/dist/src/utils/environmentContext.js.map +1 -0
- package/dist/src/utils/errorParsing.d.ts +8 -0
- package/dist/src/utils/errorParsing.js +65 -0
- package/dist/src/utils/errorParsing.js.map +1 -0
- package/dist/src/utils/errorReporting.d.ts +14 -0
- package/dist/src/utils/errorReporting.js +89 -0
- package/dist/src/utils/errorReporting.js.map +1 -0
- package/dist/src/utils/errors.d.ts +53 -0
- package/dist/src/utils/errors.js +145 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/events.d.ts +211 -0
- package/dist/src/utils/events.js +134 -0
- package/dist/src/utils/events.js.map +1 -0
- package/dist/src/utils/exitCodes.d.ts +12 -0
- package/dist/src/utils/exitCodes.js +13 -0
- package/dist/src/utils/exitCodes.js.map +1 -0
- package/dist/src/utils/extensionLoader.d.ts +86 -0
- package/dist/src/utils/extensionLoader.js +208 -0
- package/dist/src/utils/extensionLoader.js.map +1 -0
- package/dist/src/utils/fetch.d.ts +12 -0
- package/dist/src/utils/fetch.js +55 -0
- package/dist/src/utils/fetch.js.map +1 -0
- package/dist/src/utils/fileDiffUtils.d.ts +18 -0
- package/dist/src/utils/fileDiffUtils.js +37 -0
- package/dist/src/utils/fileDiffUtils.js.map +1 -0
- package/dist/src/utils/fileUtils.d.ts +86 -0
- package/dist/src/utils/fileUtils.js +495 -0
- package/dist/src/utils/fileUtils.js.map +1 -0
- package/dist/src/utils/filesearch/crawlCache.d.ts +25 -0
- package/dist/src/utils/filesearch/crawlCache.js +57 -0
- package/dist/src/utils/filesearch/crawlCache.js.map +1 -0
- package/dist/src/utils/filesearch/crawler.d.ts +16 -0
- package/dist/src/utils/filesearch/crawler.js +67 -0
- package/dist/src/utils/filesearch/crawler.js.map +1 -0
- package/dist/src/utils/filesearch/fileSearch.d.ts +39 -0
- package/dist/src/utils/filesearch/fileSearch.js +192 -0
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -0
- package/dist/src/utils/filesearch/ignore.d.ts +37 -0
- package/dist/src/utils/filesearch/ignore.js +99 -0
- package/dist/src/utils/filesearch/ignore.js.map +1 -0
- package/dist/src/utils/filesearch/result-cache.d.ts +33 -0
- package/dist/src/utils/filesearch/result-cache.js +59 -0
- package/dist/src/utils/filesearch/result-cache.js.map +1 -0
- package/dist/src/utils/formatters.d.ts +7 -0
- package/dist/src/utils/formatters.js +17 -0
- package/dist/src/utils/formatters.js.map +1 -0
- package/dist/src/utils/generateContentResponseUtilities.d.ts +15 -0
- package/dist/src/utils/generateContentResponseUtilities.js +186 -0
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -0
- package/dist/src/utils/getFolderStructure.d.ts +31 -0
- package/dist/src/utils/getFolderStructure.js +243 -0
- package/dist/src/utils/getFolderStructure.js.map +1 -0
- package/dist/src/utils/getPty.d.ts +19 -0
- package/dist/src/utils/getPty.js +23 -0
- package/dist/src/utils/getPty.js.map +1 -0
- package/dist/src/utils/gitIgnoreParser.d.ts +19 -0
- package/dist/src/utils/gitIgnoreParser.js +169 -0
- package/dist/src/utils/gitIgnoreParser.js.map +1 -0
- package/dist/src/utils/gitUtils.d.ts +17 -0
- package/dist/src/utils/gitUtils.js +61 -0
- package/dist/src/utils/gitUtils.js.map +1 -0
- package/dist/src/utils/googleErrors.d.ts +104 -0
- package/dist/src/utils/googleErrors.js +165 -0
- package/dist/src/utils/googleErrors.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.d.ts +51 -0
- package/dist/src/utils/googleQuotaErrors.js +250 -0
- package/dist/src/utils/googleQuotaErrors.js.map +1 -0
- package/dist/src/utils/httpErrors.d.ts +18 -0
- package/dist/src/utils/httpErrors.js +36 -0
- package/dist/src/utils/httpErrors.js.map +1 -0
- package/dist/src/utils/ignoreFileParser.d.ts +30 -0
- package/dist/src/utils/ignoreFileParser.js +100 -0
- package/dist/src/utils/ignoreFileParser.js.map +1 -0
- package/dist/src/utils/ignorePatterns.d.ts +103 -0
- package/dist/src/utils/ignorePatterns.js +220 -0
- package/dist/src/utils/ignorePatterns.js.map +1 -0
- package/dist/src/utils/installationManager.d.ts +16 -0
- package/dist/src/utils/installationManager.js +51 -0
- package/dist/src/utils/installationManager.js.map +1 -0
- package/dist/src/utils/language-detection.d.ts +6 -0
- package/dist/src/utils/language-detection.js +101 -0
- package/dist/src/utils/language-detection.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.d.ts +26 -0
- package/dist/src/utils/llm-edit-fixer.js +152 -0
- package/dist/src/utils/llm-edit-fixer.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.d.ts +40 -0
- package/dist/src/utils/memoryDiscovery.js +421 -0
- package/dist/src/utils/memoryDiscovery.js.map +1 -0
- package/dist/src/utils/memoryImportProcessor.d.ts +42 -0
- package/dist/src/utils/memoryImportProcessor.js +273 -0
- package/dist/src/utils/memoryImportProcessor.js.map +1 -0
- package/dist/src/utils/messageInspectors.d.ts +8 -0
- package/dist/src/utils/messageInspectors.js +16 -0
- package/dist/src/utils/messageInspectors.js.map +1 -0
- package/dist/src/utils/nextSpeakerChecker.d.ts +12 -0
- package/dist/src/utils/nextSpeakerChecker.js +97 -0
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -0
- package/dist/src/utils/package.d.ts +26 -0
- package/dist/src/utils/package.js +35 -0
- package/dist/src/utils/package.js.map +1 -0
- package/dist/src/utils/partUtils.d.ts +35 -0
- package/dist/src/utils/partUtils.js +133 -0
- package/dist/src/utils/partUtils.js.map +1 -0
- package/dist/src/utils/pathCorrector.d.ts +25 -0
- package/dist/src/utils/pathCorrector.js +43 -0
- package/dist/src/utils/pathCorrector.js.map +1 -0
- package/dist/src/utils/pathReader.d.ts +17 -0
- package/dist/src/utils/pathReader.js +92 -0
- package/dist/src/utils/pathReader.js.map +1 -0
- package/dist/src/utils/paths.d.ts +78 -0
- package/dist/src/utils/paths.js +311 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/src/utils/process-utils.d.ts +32 -0
- package/dist/src/utils/process-utils.js +88 -0
- package/dist/src/utils/process-utils.js.map +1 -0
- package/dist/src/utils/promptIdContext.d.ts +13 -0
- package/dist/src/utils/promptIdContext.js +23 -0
- package/dist/src/utils/promptIdContext.js.map +1 -0
- package/dist/src/utils/quotaErrorDetection.d.ts +16 -0
- package/dist/src/utils/quotaErrorDetection.js +19 -0
- package/dist/src/utils/quotaErrorDetection.js.map +1 -0
- package/dist/src/utils/retry.d.ts +39 -0
- package/dist/src/utils/retry.js +267 -0
- package/dist/src/utils/retry.js.map +1 -0
- package/dist/src/utils/safeJsonStringify.d.ts +13 -0
- package/dist/src/utils/safeJsonStringify.js +49 -0
- package/dist/src/utils/safeJsonStringify.js.map +1 -0
- package/dist/src/utils/schemaValidator.d.ts +21 -0
- package/dist/src/utils/schemaValidator.js +59 -0
- package/dist/src/utils/schemaValidator.js.map +1 -0
- package/dist/src/utils/secure-browser-launcher.d.ts +23 -0
- package/dist/src/utils/secure-browser-launcher.js +165 -0
- package/dist/src/utils/secure-browser-launcher.js.map +1 -0
- package/dist/src/utils/security.d.ts +16 -0
- package/dist/src/utils/security.js +88 -0
- package/dist/src/utils/security.js.map +1 -0
- package/dist/src/utils/session.d.ts +6 -0
- package/dist/src/utils/session.js +8 -0
- package/dist/src/utils/session.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +118 -0
- package/dist/src/utils/shell-utils.js +708 -0
- package/dist/src/utils/shell-utils.js.map +1 -0
- package/dist/src/utils/stdio.d.ts +32 -0
- package/dist/src/utils/stdio.js +85 -0
- package/dist/src/utils/stdio.js.map +1 -0
- package/dist/src/utils/summarizer.d.ts +27 -0
- package/dist/src/utils/summarizer.js +50 -0
- package/dist/src/utils/summarizer.js.map +1 -0
- package/dist/src/utils/systemEncoding.d.ts +40 -0
- package/dist/src/utils/systemEncoding.js +150 -0
- package/dist/src/utils/systemEncoding.js.map +1 -0
- package/dist/src/utils/terminal.d.ts +22 -0
- package/dist/src/utils/terminal.js +62 -0
- package/dist/src/utils/terminal.js.map +1 -0
- package/dist/src/utils/terminalSerializer.d.ts +25 -0
- package/dist/src/utils/terminalSerializer.js +444 -0
- package/dist/src/utils/terminalSerializer.js.map +1 -0
- package/dist/src/utils/testUtils.d.ts +29 -0
- package/dist/src/utils/testUtils.js +70 -0
- package/dist/src/utils/testUtils.js.map +1 -0
- package/dist/src/utils/textUtils.d.ts +32 -0
- package/dist/src/utils/textUtils.js +65 -0
- package/dist/src/utils/textUtils.js.map +1 -0
- package/dist/src/utils/thoughtUtils.d.ts +21 -0
- package/dist/src/utils/thoughtUtils.js +39 -0
- package/dist/src/utils/thoughtUtils.js.map +1 -0
- package/dist/src/utils/tokenCalculation.d.ts +19 -0
- package/dist/src/utils/tokenCalculation.js +150 -0
- package/dist/src/utils/tokenCalculation.js.map +1 -0
- package/dist/src/utils/tool-utils.d.ts +28 -0
- package/dist/src/utils/tool-utils.js +96 -0
- package/dist/src/utils/tool-utils.js.map +1 -0
- package/dist/src/utils/toolCallContext.d.ts +35 -0
- package/dist/src/utils/toolCallContext.js +29 -0
- package/dist/src/utils/toolCallContext.js.map +1 -0
- package/dist/src/utils/userAccountManager.d.ts +20 -0
- package/dist/src/utils/userAccountManager.js +115 -0
- package/dist/src/utils/userAccountManager.js.map +1 -0
- package/dist/src/utils/version.d.ts +6 -0
- package/dist/src/utils/version.js +15 -0
- package/dist/src/utils/version.js.map +1 -0
- package/dist/src/utils/workspaceContext.d.ts +82 -0
- package/dist/src/utils/workspaceContext.js +192 -0
- package/dist/src/utils/workspaceContext.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +97 -0
|
@@ -0,0 +1,871 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import stripAnsi from 'strip-ansi';
|
|
7
|
+
import { getPty } from '../utils/getPty.js';
|
|
8
|
+
import { spawn as cpSpawn } from 'node:child_process';
|
|
9
|
+
import { TextDecoder } from 'node:util';
|
|
10
|
+
import os from 'node:os';
|
|
11
|
+
import { getCachedEncodingForBuffer } from '../utils/systemEncoding.js';
|
|
12
|
+
import { getShellConfiguration, resolveExecutable, } from '../utils/shell-utils.js';
|
|
13
|
+
import { isBinary } from '../utils/textUtils.js';
|
|
14
|
+
import pkg from '@xterm/headless';
|
|
15
|
+
import { serializeTerminalToObject, } from '../utils/terminalSerializer.js';
|
|
16
|
+
import { sanitizeEnvironment, } from './environmentSanitization.js';
|
|
17
|
+
import { killProcessGroup } from '../utils/process-utils.js';
|
|
18
|
+
const { Terminal } = pkg;
|
|
19
|
+
const MAX_CHILD_PROCESS_BUFFER_SIZE = 16 * 1024 * 1024; // 16MB
|
|
20
|
+
// We want to allow shell outputs that are close to the context window in size.
|
|
21
|
+
// 300,000 lines is roughly equivalent to a large context window, ensuring
|
|
22
|
+
// we capture significant output from long-running commands.
|
|
23
|
+
export const SCROLLBACK_LIMIT = 300000;
|
|
24
|
+
const BASH_SHOPT_OPTIONS = 'promptvars nullglob extglob nocaseglob dotglob';
|
|
25
|
+
const BASH_SHOPT_GUARD = `shopt -u ${BASH_SHOPT_OPTIONS};`;
|
|
26
|
+
function ensurePromptvarsDisabled(command, shell) {
|
|
27
|
+
if (shell !== 'bash') {
|
|
28
|
+
return command;
|
|
29
|
+
}
|
|
30
|
+
const trimmed = command.trimStart();
|
|
31
|
+
if (trimmed.startsWith(BASH_SHOPT_GUARD)) {
|
|
32
|
+
return command;
|
|
33
|
+
}
|
|
34
|
+
return `${BASH_SHOPT_GUARD} ${command}`;
|
|
35
|
+
}
|
|
36
|
+
const getFullBufferText = (terminal) => {
|
|
37
|
+
const buffer = terminal.buffer.active;
|
|
38
|
+
const lines = [];
|
|
39
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
40
|
+
const line = buffer.getLine(i);
|
|
41
|
+
if (!line) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
// If the NEXT line is wrapped, it means it's a continuation of THIS line.
|
|
45
|
+
// We should not trim the right side of this line because trailing spaces
|
|
46
|
+
// might be significant parts of the wrapped content.
|
|
47
|
+
// If it's not wrapped, we trim normally.
|
|
48
|
+
let trimRight = true;
|
|
49
|
+
if (i + 1 < buffer.length) {
|
|
50
|
+
const nextLine = buffer.getLine(i + 1);
|
|
51
|
+
if (nextLine?.isWrapped) {
|
|
52
|
+
trimRight = false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const lineContent = line.translateToString(trimRight);
|
|
56
|
+
if (line.isWrapped && lines.length > 0) {
|
|
57
|
+
lines[lines.length - 1] += lineContent;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
lines.push(lineContent);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Remove trailing empty lines
|
|
64
|
+
while (lines.length > 0 && lines[lines.length - 1] === '') {
|
|
65
|
+
lines.pop();
|
|
66
|
+
}
|
|
67
|
+
return lines.join('\n');
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* A centralized service for executing shell commands with robust process
|
|
71
|
+
* management, cross-platform compatibility, and streaming output capabilities.
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
export class ShellExecutionService {
|
|
75
|
+
static activePtys = new Map();
|
|
76
|
+
static activeChildProcesses = new Map();
|
|
77
|
+
static exitedPtyInfo = new Map();
|
|
78
|
+
static activeResolvers = new Map();
|
|
79
|
+
static activeListeners = new Map();
|
|
80
|
+
/**
|
|
81
|
+
* Executes a shell command using `node-pty`, capturing all output and lifecycle events.
|
|
82
|
+
*
|
|
83
|
+
* @param commandToExecute The exact command string to run.
|
|
84
|
+
* @param cwd The working directory to execute the command in.
|
|
85
|
+
* @param onOutputEvent A callback for streaming structured events about the execution, including data chunks and status updates.
|
|
86
|
+
* @param abortSignal An AbortSignal to terminate the process and its children.
|
|
87
|
+
* @returns An object containing the process ID (pid) and a promise that
|
|
88
|
+
* resolves with the complete execution result.
|
|
89
|
+
*/
|
|
90
|
+
static async execute(commandToExecute, cwd, onOutputEvent, abortSignal, shouldUseNodePty, shellExecutionConfig) {
|
|
91
|
+
if (shouldUseNodePty) {
|
|
92
|
+
const ptyInfo = await getPty();
|
|
93
|
+
if (ptyInfo) {
|
|
94
|
+
try {
|
|
95
|
+
return await this.executeWithPty(commandToExecute, cwd, onOutputEvent, abortSignal, shellExecutionConfig, ptyInfo);
|
|
96
|
+
}
|
|
97
|
+
catch (_e) {
|
|
98
|
+
// Fallback to child_process
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return this.childProcessFallback(commandToExecute, cwd, onOutputEvent, abortSignal, shellExecutionConfig.sanitizationConfig);
|
|
103
|
+
}
|
|
104
|
+
static appendAndTruncate(currentBuffer, chunk, maxSize) {
|
|
105
|
+
const chunkLength = chunk.length;
|
|
106
|
+
const currentLength = currentBuffer.length;
|
|
107
|
+
const newTotalLength = currentLength + chunkLength;
|
|
108
|
+
if (newTotalLength <= maxSize) {
|
|
109
|
+
return { newBuffer: currentBuffer + chunk, truncated: false };
|
|
110
|
+
}
|
|
111
|
+
// Truncation is needed.
|
|
112
|
+
if (chunkLength >= maxSize) {
|
|
113
|
+
// The new chunk is larger than or equal to the max buffer size.
|
|
114
|
+
// The new buffer will be the tail of the new chunk.
|
|
115
|
+
return {
|
|
116
|
+
newBuffer: chunk.substring(chunkLength - maxSize),
|
|
117
|
+
truncated: true,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
// The combined buffer exceeds the max size, but the new chunk is smaller than it.
|
|
121
|
+
// We need to truncate the current buffer from the beginning to make space.
|
|
122
|
+
const charsToTrim = newTotalLength - maxSize;
|
|
123
|
+
const truncatedBuffer = currentBuffer.substring(charsToTrim);
|
|
124
|
+
return { newBuffer: truncatedBuffer + chunk, truncated: true };
|
|
125
|
+
}
|
|
126
|
+
static emitEvent(pid, event) {
|
|
127
|
+
const listeners = this.activeListeners.get(pid);
|
|
128
|
+
if (listeners) {
|
|
129
|
+
listeners.forEach((listener) => listener(event));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
static childProcessFallback(commandToExecute, cwd, onOutputEvent, abortSignal, sanitizationConfig) {
|
|
133
|
+
try {
|
|
134
|
+
const isWindows = os.platform() === 'win32';
|
|
135
|
+
const { executable, argsPrefix, shell } = getShellConfiguration();
|
|
136
|
+
const guardedCommand = ensurePromptvarsDisabled(commandToExecute, shell);
|
|
137
|
+
const spawnArgs = [...argsPrefix, guardedCommand];
|
|
138
|
+
const child = cpSpawn(executable, spawnArgs, {
|
|
139
|
+
cwd,
|
|
140
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
141
|
+
windowsVerbatimArguments: isWindows ? false : undefined,
|
|
142
|
+
shell: false,
|
|
143
|
+
detached: !isWindows,
|
|
144
|
+
env: {
|
|
145
|
+
...sanitizeEnvironment(process.env, sanitizationConfig),
|
|
146
|
+
GEMINI_CLI: '1',
|
|
147
|
+
TERM: 'xterm-256color',
|
|
148
|
+
PAGER: 'cat',
|
|
149
|
+
GIT_PAGER: 'cat',
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
const state = {
|
|
153
|
+
output: '',
|
|
154
|
+
truncated: false,
|
|
155
|
+
outputChunks: [],
|
|
156
|
+
};
|
|
157
|
+
if (child.pid) {
|
|
158
|
+
this.activeChildProcesses.set(child.pid, {
|
|
159
|
+
process: child,
|
|
160
|
+
state,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
const result = new Promise((resolve) => {
|
|
164
|
+
if (child.pid) {
|
|
165
|
+
this.activeResolvers.set(child.pid, resolve);
|
|
166
|
+
}
|
|
167
|
+
let stdoutDecoder = null;
|
|
168
|
+
let stderrDecoder = null;
|
|
169
|
+
let error = null;
|
|
170
|
+
let exited = false;
|
|
171
|
+
let isStreamingRawContent = true;
|
|
172
|
+
const MAX_SNIFF_SIZE = 4096;
|
|
173
|
+
let sniffedBytes = 0;
|
|
174
|
+
const handleOutput = (data, stream) => {
|
|
175
|
+
if (!stdoutDecoder || !stderrDecoder) {
|
|
176
|
+
const encoding = getCachedEncodingForBuffer(data);
|
|
177
|
+
try {
|
|
178
|
+
stdoutDecoder = new TextDecoder(encoding);
|
|
179
|
+
stderrDecoder = new TextDecoder(encoding);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
stdoutDecoder = new TextDecoder('utf-8');
|
|
183
|
+
stderrDecoder = new TextDecoder('utf-8');
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
state.outputChunks.push(data);
|
|
187
|
+
if (isStreamingRawContent && sniffedBytes < MAX_SNIFF_SIZE) {
|
|
188
|
+
const sniffBuffer = Buffer.concat(state.outputChunks.slice(0, 20));
|
|
189
|
+
sniffedBytes = sniffBuffer.length;
|
|
190
|
+
if (isBinary(sniffBuffer)) {
|
|
191
|
+
isStreamingRawContent = false;
|
|
192
|
+
const event = { type: 'binary_detected' };
|
|
193
|
+
onOutputEvent(event);
|
|
194
|
+
if (child.pid)
|
|
195
|
+
ShellExecutionService.emitEvent(child.pid, event);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (isStreamingRawContent) {
|
|
199
|
+
const decoder = stream === 'stdout' ? stdoutDecoder : stderrDecoder;
|
|
200
|
+
const decodedChunk = decoder.decode(data, { stream: true });
|
|
201
|
+
const { newBuffer, truncated } = this.appendAndTruncate(state.output, decodedChunk, MAX_CHILD_PROCESS_BUFFER_SIZE);
|
|
202
|
+
state.output = newBuffer;
|
|
203
|
+
if (truncated) {
|
|
204
|
+
state.truncated = true;
|
|
205
|
+
}
|
|
206
|
+
if (decodedChunk) {
|
|
207
|
+
const event = {
|
|
208
|
+
type: 'data',
|
|
209
|
+
chunk: decodedChunk,
|
|
210
|
+
};
|
|
211
|
+
onOutputEvent(event);
|
|
212
|
+
if (child.pid)
|
|
213
|
+
ShellExecutionService.emitEvent(child.pid, event);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
const totalBytes = state.outputChunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
218
|
+
const event = {
|
|
219
|
+
type: 'binary_progress',
|
|
220
|
+
bytesReceived: totalBytes,
|
|
221
|
+
};
|
|
222
|
+
onOutputEvent(event);
|
|
223
|
+
if (child.pid)
|
|
224
|
+
ShellExecutionService.emitEvent(child.pid, event);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
const handleExit = (code, signal) => {
|
|
228
|
+
const { finalBuffer } = cleanup();
|
|
229
|
+
let combinedOutput = state.output;
|
|
230
|
+
if (state.truncated) {
|
|
231
|
+
const truncationMessage = `\n[GEMINI_CLI_WARNING: Output truncated. The buffer is limited to ${MAX_CHILD_PROCESS_BUFFER_SIZE / (1024 * 1024)}MB.]`;
|
|
232
|
+
combinedOutput += truncationMessage;
|
|
233
|
+
}
|
|
234
|
+
const finalStrippedOutput = stripAnsi(combinedOutput).trim();
|
|
235
|
+
const exitCode = code;
|
|
236
|
+
const exitSignal = signal ? os.constants.signals[signal] : null;
|
|
237
|
+
if (child.pid) {
|
|
238
|
+
const event = {
|
|
239
|
+
type: 'exit',
|
|
240
|
+
exitCode,
|
|
241
|
+
signal: exitSignal,
|
|
242
|
+
};
|
|
243
|
+
onOutputEvent(event);
|
|
244
|
+
ShellExecutionService.emitEvent(child.pid, event);
|
|
245
|
+
this.activeChildProcesses.delete(child.pid);
|
|
246
|
+
this.activeResolvers.delete(child.pid);
|
|
247
|
+
this.activeListeners.delete(child.pid);
|
|
248
|
+
}
|
|
249
|
+
resolve({
|
|
250
|
+
rawOutput: finalBuffer,
|
|
251
|
+
output: finalStrippedOutput,
|
|
252
|
+
exitCode,
|
|
253
|
+
signal: exitSignal,
|
|
254
|
+
error,
|
|
255
|
+
aborted: abortSignal.aborted,
|
|
256
|
+
pid: child.pid,
|
|
257
|
+
executionMethod: 'child_process',
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
child.stdout.on('data', (data) => handleOutput(data, 'stdout'));
|
|
261
|
+
child.stderr.on('data', (data) => handleOutput(data, 'stderr'));
|
|
262
|
+
child.on('error', (err) => {
|
|
263
|
+
error = err;
|
|
264
|
+
handleExit(1, null);
|
|
265
|
+
});
|
|
266
|
+
const abortHandler = async () => {
|
|
267
|
+
if (child.pid && !exited) {
|
|
268
|
+
await killProcessGroup({
|
|
269
|
+
pid: child.pid,
|
|
270
|
+
escalate: true,
|
|
271
|
+
isExited: () => exited,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
abortSignal.addEventListener('abort', abortHandler, { once: true });
|
|
276
|
+
child.on('exit', (code, signal) => {
|
|
277
|
+
handleExit(code, signal);
|
|
278
|
+
});
|
|
279
|
+
function cleanup() {
|
|
280
|
+
exited = true;
|
|
281
|
+
abortSignal.removeEventListener('abort', abortHandler);
|
|
282
|
+
if (stdoutDecoder) {
|
|
283
|
+
const remaining = stdoutDecoder.decode();
|
|
284
|
+
if (remaining) {
|
|
285
|
+
state.output += remaining;
|
|
286
|
+
// If there's remaining output, we should technically emit it too,
|
|
287
|
+
// but it's rare to have partial utf8 chars at the very end of stream.
|
|
288
|
+
if (isStreamingRawContent && remaining) {
|
|
289
|
+
const event = {
|
|
290
|
+
type: 'data',
|
|
291
|
+
chunk: remaining,
|
|
292
|
+
};
|
|
293
|
+
onOutputEvent(event);
|
|
294
|
+
if (child.pid)
|
|
295
|
+
ShellExecutionService.emitEvent(child.pid, event);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (stderrDecoder) {
|
|
300
|
+
const remaining = stderrDecoder.decode();
|
|
301
|
+
if (remaining) {
|
|
302
|
+
state.output += remaining;
|
|
303
|
+
if (isStreamingRawContent && remaining) {
|
|
304
|
+
const event = {
|
|
305
|
+
type: 'data',
|
|
306
|
+
chunk: remaining,
|
|
307
|
+
};
|
|
308
|
+
onOutputEvent(event);
|
|
309
|
+
if (child.pid)
|
|
310
|
+
ShellExecutionService.emitEvent(child.pid, event);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const finalBuffer = Buffer.concat(state.outputChunks);
|
|
315
|
+
return { finalBuffer };
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
return { pid: child.pid, result };
|
|
319
|
+
}
|
|
320
|
+
catch (e) {
|
|
321
|
+
const error = e;
|
|
322
|
+
return {
|
|
323
|
+
pid: undefined,
|
|
324
|
+
result: Promise.resolve({
|
|
325
|
+
error,
|
|
326
|
+
rawOutput: Buffer.from(''),
|
|
327
|
+
output: '',
|
|
328
|
+
exitCode: 1,
|
|
329
|
+
signal: null,
|
|
330
|
+
aborted: false,
|
|
331
|
+
pid: undefined,
|
|
332
|
+
executionMethod: 'none',
|
|
333
|
+
}),
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
static async executeWithPty(commandToExecute, cwd, onOutputEvent, abortSignal, shellExecutionConfig, ptyInfo) {
|
|
338
|
+
if (!ptyInfo) {
|
|
339
|
+
// This should not happen, but as a safeguard...
|
|
340
|
+
throw new Error('PTY implementation not found');
|
|
341
|
+
}
|
|
342
|
+
try {
|
|
343
|
+
const cols = shellExecutionConfig.terminalWidth ?? 80;
|
|
344
|
+
const rows = shellExecutionConfig.terminalHeight ?? 30;
|
|
345
|
+
const { executable, argsPrefix, shell } = getShellConfiguration();
|
|
346
|
+
const resolvedExecutable = await resolveExecutable(executable);
|
|
347
|
+
if (!resolvedExecutable) {
|
|
348
|
+
throw new Error(`Shell executable "${executable}" not found in PATH or at absolute location. Please ensure the shell is installed and available in your environment.`);
|
|
349
|
+
}
|
|
350
|
+
const guardedCommand = ensurePromptvarsDisabled(commandToExecute, shell);
|
|
351
|
+
const args = [...argsPrefix, guardedCommand];
|
|
352
|
+
const ptyProcess = ptyInfo.module.spawn(executable, args, {
|
|
353
|
+
cwd,
|
|
354
|
+
name: 'xterm-256color',
|
|
355
|
+
cols,
|
|
356
|
+
rows,
|
|
357
|
+
env: {
|
|
358
|
+
...sanitizeEnvironment(process.env, shellExecutionConfig.sanitizationConfig),
|
|
359
|
+
GEMINI_CLI: '1',
|
|
360
|
+
TERM: 'xterm-256color',
|
|
361
|
+
PAGER: shellExecutionConfig.pager ?? 'cat',
|
|
362
|
+
GIT_PAGER: shellExecutionConfig.pager ?? 'cat',
|
|
363
|
+
},
|
|
364
|
+
handleFlowControl: true,
|
|
365
|
+
});
|
|
366
|
+
const result = new Promise((resolve) => {
|
|
367
|
+
this.activeResolvers.set(ptyProcess.pid, resolve);
|
|
368
|
+
const headlessTerminal = new Terminal({
|
|
369
|
+
allowProposedApi: true,
|
|
370
|
+
cols,
|
|
371
|
+
rows,
|
|
372
|
+
scrollback: shellExecutionConfig.scrollback ?? SCROLLBACK_LIMIT,
|
|
373
|
+
});
|
|
374
|
+
headlessTerminal.scrollToTop();
|
|
375
|
+
this.activePtys.set(ptyProcess.pid, {
|
|
376
|
+
ptyProcess,
|
|
377
|
+
headlessTerminal,
|
|
378
|
+
maxSerializedLines: shellExecutionConfig.maxSerializedLines,
|
|
379
|
+
});
|
|
380
|
+
let processingChain = Promise.resolve();
|
|
381
|
+
let decoder = null;
|
|
382
|
+
let output = null;
|
|
383
|
+
const outputChunks = [];
|
|
384
|
+
const error = null;
|
|
385
|
+
let exited = false;
|
|
386
|
+
let isStreamingRawContent = true;
|
|
387
|
+
const MAX_SNIFF_SIZE = 4096;
|
|
388
|
+
let sniffedBytes = 0;
|
|
389
|
+
let isWriting = false;
|
|
390
|
+
let hasStartedOutput = false;
|
|
391
|
+
let renderTimeout = null;
|
|
392
|
+
const renderFn = () => {
|
|
393
|
+
renderTimeout = null;
|
|
394
|
+
if (!isStreamingRawContent) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (!shellExecutionConfig.disableDynamicLineTrimming) {
|
|
398
|
+
if (!hasStartedOutput) {
|
|
399
|
+
const bufferText = getFullBufferText(headlessTerminal);
|
|
400
|
+
if (bufferText.trim().length === 0) {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
hasStartedOutput = true;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
const buffer = headlessTerminal.buffer.active;
|
|
407
|
+
const endLine = buffer.length;
|
|
408
|
+
const startLine = Math.max(0, endLine - (shellExecutionConfig.maxSerializedLines ?? 2000));
|
|
409
|
+
let newOutput;
|
|
410
|
+
if (shellExecutionConfig.showColor) {
|
|
411
|
+
newOutput = serializeTerminalToObject(headlessTerminal, startLine, endLine);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
newOutput = (serializeTerminalToObject(headlessTerminal, startLine, endLine) ||
|
|
415
|
+
[]).map((line) => line.map((token) => {
|
|
416
|
+
token.fg = '';
|
|
417
|
+
token.bg = '';
|
|
418
|
+
return token;
|
|
419
|
+
}));
|
|
420
|
+
}
|
|
421
|
+
let lastNonEmptyLine = -1;
|
|
422
|
+
for (let i = newOutput.length - 1; i >= 0; i--) {
|
|
423
|
+
const line = newOutput[i];
|
|
424
|
+
if (line
|
|
425
|
+
.map((segment) => segment.text)
|
|
426
|
+
.join('')
|
|
427
|
+
.trim().length > 0) {
|
|
428
|
+
lastNonEmptyLine = i;
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
const absoluteCursorY = buffer.baseY + buffer.cursorY;
|
|
433
|
+
const cursorRelativeIndex = absoluteCursorY - startLine;
|
|
434
|
+
if (cursorRelativeIndex > lastNonEmptyLine) {
|
|
435
|
+
lastNonEmptyLine = cursorRelativeIndex;
|
|
436
|
+
}
|
|
437
|
+
const trimmedOutput = newOutput.slice(0, lastNonEmptyLine + 1);
|
|
438
|
+
const finalOutput = shellExecutionConfig.disableDynamicLineTrimming
|
|
439
|
+
? newOutput
|
|
440
|
+
: trimmedOutput;
|
|
441
|
+
if (output !== finalOutput) {
|
|
442
|
+
output = finalOutput;
|
|
443
|
+
const event = {
|
|
444
|
+
type: 'data',
|
|
445
|
+
chunk: finalOutput,
|
|
446
|
+
};
|
|
447
|
+
onOutputEvent(event);
|
|
448
|
+
ShellExecutionService.emitEvent(ptyProcess.pid, event);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
const render = (finalRender = false) => {
|
|
452
|
+
if (finalRender) {
|
|
453
|
+
if (renderTimeout) {
|
|
454
|
+
clearTimeout(renderTimeout);
|
|
455
|
+
}
|
|
456
|
+
renderFn();
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
if (renderTimeout) {
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
renderTimeout = setTimeout(() => {
|
|
463
|
+
renderFn();
|
|
464
|
+
renderTimeout = null;
|
|
465
|
+
}, 68);
|
|
466
|
+
};
|
|
467
|
+
headlessTerminal.onScroll(() => {
|
|
468
|
+
if (!isWriting) {
|
|
469
|
+
render();
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
const handleOutput = (data) => {
|
|
473
|
+
processingChain = processingChain.then(() => new Promise((resolve) => {
|
|
474
|
+
if (!decoder) {
|
|
475
|
+
const encoding = getCachedEncodingForBuffer(data);
|
|
476
|
+
try {
|
|
477
|
+
decoder = new TextDecoder(encoding);
|
|
478
|
+
}
|
|
479
|
+
catch {
|
|
480
|
+
decoder = new TextDecoder('utf-8');
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
outputChunks.push(data);
|
|
484
|
+
if (isStreamingRawContent && sniffedBytes < MAX_SNIFF_SIZE) {
|
|
485
|
+
const sniffBuffer = Buffer.concat(outputChunks.slice(0, 20));
|
|
486
|
+
sniffedBytes = sniffBuffer.length;
|
|
487
|
+
if (isBinary(sniffBuffer)) {
|
|
488
|
+
isStreamingRawContent = false;
|
|
489
|
+
const event = { type: 'binary_detected' };
|
|
490
|
+
onOutputEvent(event);
|
|
491
|
+
ShellExecutionService.emitEvent(ptyProcess.pid, event);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
if (isStreamingRawContent) {
|
|
495
|
+
const decodedChunk = decoder.decode(data, { stream: true });
|
|
496
|
+
if (decodedChunk.length === 0) {
|
|
497
|
+
resolve();
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
isWriting = true;
|
|
501
|
+
headlessTerminal.write(decodedChunk, () => {
|
|
502
|
+
render();
|
|
503
|
+
isWriting = false;
|
|
504
|
+
resolve();
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
const totalBytes = outputChunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
509
|
+
const event = {
|
|
510
|
+
type: 'binary_progress',
|
|
511
|
+
bytesReceived: totalBytes,
|
|
512
|
+
};
|
|
513
|
+
onOutputEvent(event);
|
|
514
|
+
ShellExecutionService.emitEvent(ptyProcess.pid, event);
|
|
515
|
+
resolve();
|
|
516
|
+
}
|
|
517
|
+
}));
|
|
518
|
+
};
|
|
519
|
+
ptyProcess.onData((data) => {
|
|
520
|
+
const bufferData = Buffer.from(data, 'utf-8');
|
|
521
|
+
handleOutput(bufferData);
|
|
522
|
+
});
|
|
523
|
+
ptyProcess.onExit(({ exitCode, signal }) => {
|
|
524
|
+
exited = true;
|
|
525
|
+
abortSignal.removeEventListener('abort', abortHandler);
|
|
526
|
+
this.activePtys.delete(ptyProcess.pid);
|
|
527
|
+
// Attempt to destroy the PTY to ensure FD is closed
|
|
528
|
+
try {
|
|
529
|
+
ptyProcess.destroy?.();
|
|
530
|
+
}
|
|
531
|
+
catch {
|
|
532
|
+
// Ignore errors during cleanup
|
|
533
|
+
}
|
|
534
|
+
const finalize = () => {
|
|
535
|
+
render(true);
|
|
536
|
+
// Store exit info for late subscribers (e.g. backgrounding race condition)
|
|
537
|
+
this.exitedPtyInfo.set(ptyProcess.pid, { exitCode, signal });
|
|
538
|
+
setTimeout(() => {
|
|
539
|
+
this.exitedPtyInfo.delete(ptyProcess.pid);
|
|
540
|
+
}, 5 * 60 * 1000).unref();
|
|
541
|
+
this.activePtys.delete(ptyProcess.pid);
|
|
542
|
+
this.activeResolvers.delete(ptyProcess.pid);
|
|
543
|
+
const event = {
|
|
544
|
+
type: 'exit',
|
|
545
|
+
exitCode,
|
|
546
|
+
signal: signal ?? null,
|
|
547
|
+
};
|
|
548
|
+
onOutputEvent(event);
|
|
549
|
+
ShellExecutionService.emitEvent(ptyProcess.pid, event);
|
|
550
|
+
this.activeListeners.delete(ptyProcess.pid);
|
|
551
|
+
const finalBuffer = Buffer.concat(outputChunks);
|
|
552
|
+
resolve({
|
|
553
|
+
rawOutput: finalBuffer,
|
|
554
|
+
output: getFullBufferText(headlessTerminal),
|
|
555
|
+
exitCode,
|
|
556
|
+
signal: signal ?? null,
|
|
557
|
+
error,
|
|
558
|
+
aborted: abortSignal.aborted,
|
|
559
|
+
pid: ptyProcess.pid,
|
|
560
|
+
executionMethod: ptyInfo?.name ?? 'node-pty',
|
|
561
|
+
});
|
|
562
|
+
};
|
|
563
|
+
if (abortSignal.aborted) {
|
|
564
|
+
finalize();
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
const processingComplete = processingChain.then(() => 'processed');
|
|
568
|
+
const abortFired = new Promise((res) => {
|
|
569
|
+
if (abortSignal.aborted) {
|
|
570
|
+
res('aborted');
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
abortSignal.addEventListener('abort', () => res('aborted'), {
|
|
574
|
+
once: true,
|
|
575
|
+
});
|
|
576
|
+
});
|
|
577
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
578
|
+
Promise.race([processingComplete, abortFired]).then(() => {
|
|
579
|
+
finalize();
|
|
580
|
+
});
|
|
581
|
+
});
|
|
582
|
+
const abortHandler = async () => {
|
|
583
|
+
if (ptyProcess.pid && !exited) {
|
|
584
|
+
await killProcessGroup({
|
|
585
|
+
pid: ptyProcess.pid,
|
|
586
|
+
escalate: true,
|
|
587
|
+
isExited: () => exited,
|
|
588
|
+
pty: ptyProcess,
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
abortSignal.addEventListener('abort', abortHandler, { once: true });
|
|
593
|
+
});
|
|
594
|
+
return { pid: ptyProcess.pid, result };
|
|
595
|
+
}
|
|
596
|
+
catch (e) {
|
|
597
|
+
const error = e;
|
|
598
|
+
if (error.message.includes('posix_spawnp failed')) {
|
|
599
|
+
onOutputEvent({
|
|
600
|
+
type: 'data',
|
|
601
|
+
chunk: '[GEMINI_CLI_WARNING] PTY execution failed, falling back to child_process. This may be due to sandbox restrictions.\n',
|
|
602
|
+
});
|
|
603
|
+
throw e;
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
return {
|
|
607
|
+
pid: undefined,
|
|
608
|
+
result: Promise.resolve({
|
|
609
|
+
error,
|
|
610
|
+
rawOutput: Buffer.from(''),
|
|
611
|
+
output: '',
|
|
612
|
+
exitCode: 1,
|
|
613
|
+
signal: null,
|
|
614
|
+
aborted: false,
|
|
615
|
+
pid: undefined,
|
|
616
|
+
executionMethod: 'none',
|
|
617
|
+
}),
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Writes a string to the pseudo-terminal (PTY) of a running process.
|
|
624
|
+
*
|
|
625
|
+
* @param pid The process ID of the target PTY.
|
|
626
|
+
* @param input The string to write to the terminal.
|
|
627
|
+
*/
|
|
628
|
+
static writeToPty(pid, input) {
|
|
629
|
+
if (this.activeChildProcesses.has(pid)) {
|
|
630
|
+
const activeChild = this.activeChildProcesses.get(pid);
|
|
631
|
+
if (activeChild) {
|
|
632
|
+
activeChild.process.stdin?.write(input);
|
|
633
|
+
}
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
if (!this.isPtyActive(pid)) {
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
const activePty = this.activePtys.get(pid);
|
|
640
|
+
if (activePty) {
|
|
641
|
+
activePty.ptyProcess.write(input);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
static isPtyActive(pid) {
|
|
645
|
+
if (this.activeChildProcesses.has(pid)) {
|
|
646
|
+
try {
|
|
647
|
+
return process.kill(pid, 0);
|
|
648
|
+
}
|
|
649
|
+
catch {
|
|
650
|
+
return false;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
try {
|
|
654
|
+
// process.kill with signal 0 is a way to check for the existence of a process.
|
|
655
|
+
// It doesn't actually send a signal.
|
|
656
|
+
return process.kill(pid, 0);
|
|
657
|
+
}
|
|
658
|
+
catch (_) {
|
|
659
|
+
return false;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Registers a callback to be invoked when the process with the given PID exits.
|
|
664
|
+
* This attaches directly to the PTY's exit event.
|
|
665
|
+
*
|
|
666
|
+
* @param pid The process ID to watch.
|
|
667
|
+
* @param callback The function to call on exit.
|
|
668
|
+
* @returns An unsubscribe function.
|
|
669
|
+
*/
|
|
670
|
+
static onExit(pid, callback) {
|
|
671
|
+
const activePty = this.activePtys.get(pid);
|
|
672
|
+
if (activePty) {
|
|
673
|
+
const disposable = activePty.ptyProcess.onExit(({ exitCode, signal }) => {
|
|
674
|
+
callback(exitCode, signal);
|
|
675
|
+
disposable.dispose();
|
|
676
|
+
});
|
|
677
|
+
return () => disposable.dispose();
|
|
678
|
+
}
|
|
679
|
+
else if (this.activeChildProcesses.has(pid)) {
|
|
680
|
+
const activeChild = this.activeChildProcesses.get(pid);
|
|
681
|
+
const listener = (code, signal) => {
|
|
682
|
+
let signalNumber;
|
|
683
|
+
if (signal) {
|
|
684
|
+
signalNumber = os.constants.signals[signal];
|
|
685
|
+
}
|
|
686
|
+
callback(code ?? 0, signalNumber);
|
|
687
|
+
};
|
|
688
|
+
activeChild?.process.on('exit', listener);
|
|
689
|
+
return () => {
|
|
690
|
+
activeChild?.process.removeListener('exit', listener);
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
else {
|
|
694
|
+
// Check if it already exited recently
|
|
695
|
+
const exitedInfo = this.exitedPtyInfo.get(pid);
|
|
696
|
+
if (exitedInfo) {
|
|
697
|
+
callback(exitedInfo.exitCode, exitedInfo.signal);
|
|
698
|
+
}
|
|
699
|
+
return () => { };
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Kills a process by its PID.
|
|
704
|
+
*
|
|
705
|
+
* @param pid The process ID to kill.
|
|
706
|
+
*/
|
|
707
|
+
static kill(pid) {
|
|
708
|
+
const activePty = this.activePtys.get(pid);
|
|
709
|
+
const activeChild = this.activeChildProcesses.get(pid);
|
|
710
|
+
if (activeChild) {
|
|
711
|
+
killProcessGroup({ pid }).catch(() => { });
|
|
712
|
+
this.activeChildProcesses.delete(pid);
|
|
713
|
+
}
|
|
714
|
+
else if (activePty) {
|
|
715
|
+
killProcessGroup({ pid, pty: activePty.ptyProcess }).catch(() => { });
|
|
716
|
+
this.activePtys.delete(pid);
|
|
717
|
+
}
|
|
718
|
+
this.activeResolvers.delete(pid);
|
|
719
|
+
this.activeListeners.delete(pid);
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Moves a running shell command to the background.
|
|
723
|
+
* This resolves the execution promise but keeps the PTY active.
|
|
724
|
+
*
|
|
725
|
+
* @param pid The process ID of the target PTY.
|
|
726
|
+
*/
|
|
727
|
+
static background(pid) {
|
|
728
|
+
const resolve = this.activeResolvers.get(pid);
|
|
729
|
+
if (resolve) {
|
|
730
|
+
let output = '';
|
|
731
|
+
const rawOutput = Buffer.from('');
|
|
732
|
+
const activePty = this.activePtys.get(pid);
|
|
733
|
+
const activeChild = this.activeChildProcesses.get(pid);
|
|
734
|
+
if (activePty) {
|
|
735
|
+
output = getFullBufferText(activePty.headlessTerminal);
|
|
736
|
+
resolve({
|
|
737
|
+
rawOutput,
|
|
738
|
+
output,
|
|
739
|
+
exitCode: null,
|
|
740
|
+
signal: null,
|
|
741
|
+
error: null,
|
|
742
|
+
aborted: false,
|
|
743
|
+
pid,
|
|
744
|
+
executionMethod: 'node-pty',
|
|
745
|
+
backgrounded: true,
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
else if (activeChild) {
|
|
749
|
+
output = activeChild.state.output;
|
|
750
|
+
resolve({
|
|
751
|
+
rawOutput,
|
|
752
|
+
output,
|
|
753
|
+
exitCode: null,
|
|
754
|
+
signal: null,
|
|
755
|
+
error: null,
|
|
756
|
+
aborted: false,
|
|
757
|
+
pid,
|
|
758
|
+
executionMethod: 'child_process',
|
|
759
|
+
backgrounded: true,
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
this.activeResolvers.delete(pid);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
static subscribe(pid, listener) {
|
|
766
|
+
if (!this.activeListeners.has(pid)) {
|
|
767
|
+
this.activeListeners.set(pid, new Set());
|
|
768
|
+
}
|
|
769
|
+
this.activeListeners.get(pid)?.add(listener);
|
|
770
|
+
// Send current buffer content immediately
|
|
771
|
+
const activePty = this.activePtys.get(pid);
|
|
772
|
+
const activeChild = this.activeChildProcesses.get(pid);
|
|
773
|
+
if (activePty) {
|
|
774
|
+
// Use serializeTerminalToObject to preserve colors and structure
|
|
775
|
+
const endLine = activePty.headlessTerminal.buffer.active.length;
|
|
776
|
+
const startLine = Math.max(0, endLine - (activePty.maxSerializedLines ?? 2000));
|
|
777
|
+
const bufferData = serializeTerminalToObject(activePty.headlessTerminal, startLine, endLine);
|
|
778
|
+
if (bufferData && bufferData.length > 0) {
|
|
779
|
+
listener({ type: 'data', chunk: bufferData });
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
else if (activeChild) {
|
|
783
|
+
const output = activeChild.state.output;
|
|
784
|
+
if (output) {
|
|
785
|
+
listener({ type: 'data', chunk: output });
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
return () => {
|
|
789
|
+
this.activeListeners.get(pid)?.delete(listener);
|
|
790
|
+
if (this.activeListeners.get(pid)?.size === 0) {
|
|
791
|
+
this.activeListeners.delete(pid);
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Resizes the pseudo-terminal (PTY) of a running process.
|
|
797
|
+
*
|
|
798
|
+
* @param pid The process ID of the target PTY.
|
|
799
|
+
* @param cols The new number of columns.
|
|
800
|
+
* @param rows The new number of rows.
|
|
801
|
+
*/
|
|
802
|
+
static resizePty(pid, cols, rows) {
|
|
803
|
+
if (!this.isPtyActive(pid)) {
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
const activePty = this.activePtys.get(pid);
|
|
807
|
+
if (activePty) {
|
|
808
|
+
try {
|
|
809
|
+
activePty.ptyProcess.resize(cols, rows);
|
|
810
|
+
activePty.headlessTerminal.resize(cols, rows);
|
|
811
|
+
}
|
|
812
|
+
catch (e) {
|
|
813
|
+
// Ignore errors if the pty has already exited, which can happen
|
|
814
|
+
// due to a race condition between the exit event and this call.
|
|
815
|
+
const err = e;
|
|
816
|
+
const isEsrch = err.code === 'ESRCH';
|
|
817
|
+
const isWindowsPtyError = err.message?.includes('Cannot resize a pty that has already exited');
|
|
818
|
+
if (isEsrch || isWindowsPtyError) {
|
|
819
|
+
// On Unix, we get an ESRCH error.
|
|
820
|
+
// On Windows, we get a message-based error.
|
|
821
|
+
// In both cases, it's safe to ignore.
|
|
822
|
+
}
|
|
823
|
+
else {
|
|
824
|
+
throw e;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
// Force emit the new state after resize
|
|
829
|
+
if (activePty) {
|
|
830
|
+
const endLine = activePty.headlessTerminal.buffer.active.length;
|
|
831
|
+
const startLine = Math.max(0, endLine - (activePty.maxSerializedLines ?? 2000));
|
|
832
|
+
const bufferData = serializeTerminalToObject(activePty.headlessTerminal, startLine, endLine);
|
|
833
|
+
const event = { type: 'data', chunk: bufferData };
|
|
834
|
+
const listeners = ShellExecutionService.activeListeners.get(pid);
|
|
835
|
+
if (listeners) {
|
|
836
|
+
listeners.forEach((listener) => listener(event));
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Scrolls the pseudo-terminal (PTY) of a running process.
|
|
842
|
+
*
|
|
843
|
+
* @param pid The process ID of the target PTY.
|
|
844
|
+
* @param lines The number of lines to scroll.
|
|
845
|
+
*/
|
|
846
|
+
static scrollPty(pid, lines) {
|
|
847
|
+
if (!this.isPtyActive(pid)) {
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
const activePty = this.activePtys.get(pid);
|
|
851
|
+
if (activePty) {
|
|
852
|
+
try {
|
|
853
|
+
activePty.headlessTerminal.scrollLines(lines);
|
|
854
|
+
if (activePty.headlessTerminal.buffer.active.viewportY < 0) {
|
|
855
|
+
activePty.headlessTerminal.scrollToTop();
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
catch (e) {
|
|
859
|
+
// Ignore errors if the pty has already exited, which can happen
|
|
860
|
+
// due to a race condition between the exit event and this call.
|
|
861
|
+
if (e instanceof Error && 'code' in e && e.code === 'ESRCH') {
|
|
862
|
+
// ignore
|
|
863
|
+
}
|
|
864
|
+
else {
|
|
865
|
+
throw e;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
//# sourceMappingURL=shellExecutionService.js.map
|