@sayknow-cli/coding-agent 0.7.10 → 0.7.12
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 +18 -0
- package/dist/types/async/result-formatting.d.ts +2 -0
- package/dist/types/capability/fs.d.ts +22 -3
- package/dist/types/capability/mcp.d.ts +2 -0
- package/dist/types/cli/append-system-prompt.d.ts +6 -0
- package/dist/types/cli/update-cli.d.ts +3 -0
- package/dist/types/commands/contribution-prep.d.ts +0 -3
- package/dist/types/commands/migrate.d.ts +1 -1
- package/dist/types/commands/sdk.d.ts +9 -0
- package/dist/types/commit/changelog/index.d.ts +1 -0
- package/dist/types/config/settings-schema.d.ts +14 -0
- package/dist/types/config/settings.d.ts +7 -1
- package/dist/types/coordinator-mcp/session-reaper.d.ts +5 -0
- package/dist/types/cursor-delete-path.d.ts +1 -0
- package/dist/types/cursor-mcp-name.d.ts +8 -0
- package/dist/types/dap/config.d.ts +8 -4
- package/dist/types/dap/session.d.ts +11 -2
- package/dist/types/debug/report-bundle-parent.d.ts +2 -0
- package/dist/types/debug/system-info.d.ts +6 -1
- package/dist/types/discovery/helpers.d.ts +11 -3
- package/dist/types/discovery/mcp-json.d.ts +1 -0
- package/dist/types/edit/file-read-cache.d.ts +4 -0
- package/dist/types/edit/modes/patch.d.ts +14 -0
- package/dist/types/edit/modes/replace.d.ts +8 -0
- package/dist/types/eval/py/runtime.d.ts +9 -0
- package/dist/types/exa/mcp-client.d.ts +11 -6
- package/dist/types/exec/bash-executor.d.ts +18 -1
- package/dist/types/export/html/css-color.d.ts +2 -0
- package/dist/types/export/html/html-export-destination.d.ts +2 -0
- package/dist/types/export/html/template.generated.d.ts +1 -1
- package/dist/types/extensibility/custom-tools/loader.d.ts +3 -2
- package/dist/types/extensibility/custom-tools/types.d.ts +3 -1
- package/dist/types/extensibility/plugins/marketplace/cache.d.ts +2 -0
- package/dist/types/extensibility/plugins/plugin-link-path.d.ts +2 -0
- package/dist/types/goals/runtime.d.ts +6 -0
- package/dist/types/harness-control-plane/receipt-spool.d.ts +4 -0
- package/dist/types/hindsight/content.d.ts +5 -6
- package/dist/types/internal-urls/skill-path.d.ts +1 -0
- package/dist/types/internal-urls/types.d.ts +2 -0
- package/dist/types/lsp/clients/swiftlint-client.d.ts +0 -4
- package/dist/types/lsp/config.d.ts +8 -5
- package/dist/types/lsp/workspace-path.d.ts +1 -0
- package/dist/types/migrate/adapters/codex.d.ts +2 -1
- package/dist/types/migrate/adapters/index.d.ts +10 -1
- package/dist/types/migrate/executor.d.ts +3 -1
- package/dist/types/migrate/types.d.ts +15 -3
- package/dist/types/modes/components/custom-editor.d.ts +6 -0
- package/dist/types/modes/components/extensions/state-manager.d.ts +4 -3
- package/dist/types/modes/components/model-selector.d.ts +46 -0
- package/dist/types/modes/controllers/input-controller.d.ts +9 -0
- package/dist/types/modes/interactive-mode.d.ts +1 -0
- package/dist/types/modes/utils/macos-option-forwarding.d.ts +17 -0
- package/dist/types/runtime-mcp/content-limits.d.ts +4 -0
- package/dist/types/runtime-mcp/manager.d.ts +9 -1
- package/dist/types/runtime-mcp/mcp-redirect.d.ts +9 -0
- package/dist/types/runtime-mcp/oauth-public-url.d.ts +1 -0
- package/dist/types/runtime-mcp/plugin-mcp-name-filter.d.ts +22 -0
- package/dist/types/runtime-mcp/plugin-network-boundary.d.ts +1 -0
- package/dist/types/runtime-mcp/project-host-values.d.ts +33 -0
- package/dist/types/runtime-mcp/smithery-registry.d.ts +24 -0
- package/dist/types/runtime-mcp/tool-bridge.d.ts +4 -0
- package/dist/types/runtime-mcp/types.d.ts +6 -0
- package/dist/types/sdk/broker/ensure.d.ts +2 -0
- package/dist/types/sdk/broker/lifecycle-ledger.d.ts +5 -1
- package/dist/types/sdk/broker/runtime.d.ts +1 -1
- package/dist/types/sdk/bus/chat-daemon-control.d.ts +3 -1
- package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +3 -1
- package/dist/types/sdk/bus/telegram-daemon.d.ts +1 -0
- package/dist/types/sdk/host/events.d.ts +4 -0
- package/dist/types/session/agent-session.d.ts +20 -1
- package/dist/types/session/messages.d.ts +5 -1
- package/dist/types/session/session-manager.d.ts +13 -0
- package/dist/types/session/session-storage.d.ts +8 -0
- package/dist/types/session/streaming-output.d.ts +11 -0
- package/dist/types/session-import/redact.d.ts +1 -1
- package/dist/types/skc-runtime/managed-owner-admission.d.ts +3 -0
- package/dist/types/skc-runtime/psmux-detect.d.ts +5 -4
- package/dist/types/skc-runtime/ralplan-runtime.d.ts +5 -0
- package/dist/types/skc-runtime/sidecar-bootstrap-env.d.ts +6 -0
- package/dist/types/skc-runtime/state-writer.d.ts +4 -1
- package/dist/types/skc-runtime/tmux-sessions.d.ts +24 -0
- package/dist/types/skc-runtime/ultragoal-runtime.d.ts +4 -0
- package/dist/types/skill-state/workflow-mutation-guard.d.ts +20 -1
- package/dist/types/slash-commands/helpers/mcp.d.ts +5 -0
- package/dist/types/ssh/ssh-executor.d.ts +3 -1
- package/dist/types/system-prompt.d.ts +5 -2
- package/dist/types/task/executor.d.ts +17 -3
- package/dist/types/task/isolation-dir.d.ts +26 -0
- package/dist/types/task/role-body.d.ts +11 -0
- package/dist/types/task/token-log-mode.test.d.ts +1 -0
- package/dist/types/tools/ask.d.ts +77 -254
- package/dist/types/tools/ast-edit-write-path.d.ts +23 -0
- package/dist/types/tools/atomic-file-write.d.ts +74 -0
- package/dist/types/tools/auto-generated-guard.d.ts +5 -2
- package/dist/types/tools/bash-allowed-prefixes.d.ts +16 -0
- package/dist/types/tools/bash-interactive.d.ts +2 -0
- package/dist/types/tools/bash-skill-urls.d.ts +5 -1
- package/dist/types/tools/bash.d.ts +1 -0
- package/dist/types/tools/browser/cdp-url.d.ts +2 -0
- package/dist/types/tools/browser/tab-worker.d.ts +2 -0
- package/dist/types/tools/debug.d.ts +2 -2
- package/dist/types/tools/explicit-artifact.d.ts +8 -0
- package/dist/types/tools/fetch.d.ts +7 -4
- package/dist/types/tools/github-side-effect.d.ts +22 -0
- package/dist/types/tools/index.d.ts +3 -0
- package/dist/types/tools/monitor-mutation.d.ts +9 -0
- package/dist/types/tools/recipe/index.d.ts +2 -0
- package/dist/types/tools/recipe/recipe-guard.d.ts +7 -0
- package/dist/types/tools/restricted-cwd.d.ts +1 -0
- package/dist/types/tools/reverse-engineer.d.ts +81 -0
- package/dist/types/tools/search-tool-bm25.d.ts +2 -0
- package/dist/types/tools/tmux-self-injection-guard.d.ts +17 -0
- package/dist/types/tools/untrusted-content.d.ts +12 -0
- package/dist/types/utils/file-mentions.d.ts +5 -0
- package/dist/types/utils/open.d.ts +0 -1
- package/dist/types/utils/shell-snapshot.d.ts +2 -0
- package/dist/types/utils/title-generator.d.ts +12 -2
- package/dist/types/utils/tools-checksum.d.ts +7 -0
- package/dist/types/utils/xml-escape.d.ts +2 -0
- package/dist/types/web/scrapers/types.d.ts +8 -1
- package/dist/types/web/search/providers/codex.d.ts +6 -7
- package/dist/types/web/search/providers/insane.d.ts +7 -1
- package/dist/types/web/search/providers/kimi.d.ts +2 -0
- package/dist/types/web/search/providers/searxng.d.ts +7 -0
- package/dist/types/web/search/providers/xai.d.ts +2 -0
- package/package.json +7 -7
- package/scripts/generate-sdk-operation-inventory.ts +4 -0
- package/src/async/job-manager.ts +23 -9
- package/src/async/result-formatting.ts +40 -0
- package/src/capability/fs.ts +78 -11
- package/src/capability/mcp.ts +2 -0
- package/src/cli/append-system-prompt.ts +12 -0
- package/src/cli/auth-broker-cli.ts +22 -12
- package/src/cli/config-cli.ts +8 -18
- package/src/cli/migrate-cli.ts +7 -5
- package/src/cli/ssh-cli.ts +6 -3
- package/src/cli/stats-cli.ts +9 -4
- package/src/cli/update-cli.ts +42 -0
- package/src/cli/web-search-cli.ts +9 -3
- package/src/cli.ts +5 -9
- package/src/commands/commit.ts +2 -2
- package/src/commands/contribution-prep.ts +1 -3
- package/src/commands/harness.ts +25 -15
- package/src/commands/launch.ts +1 -1
- package/src/commands/migrate.ts +3 -3
- package/src/commands/sdk.ts +115 -14
- package/src/commands/ultragoal.ts +14 -8
- package/src/commit/agentic/agent.ts +6 -6
- package/src/commit/analysis/conventional.ts +14 -5
- package/src/commit/changelog/index.ts +39 -1
- package/src/commit/message.ts +10 -3
- package/src/config/config-file.ts +106 -3
- package/src/config/keybindings.ts +154 -7
- package/src/config/mcp-schema.json +4 -0
- package/src/config/model-registry.ts +10 -2
- package/src/config/settings-schema.ts +18 -0
- package/src/config/settings.ts +32 -4
- package/src/coordinator-mcp/policy.ts +14 -4
- package/src/coordinator-mcp/server.ts +44 -4
- package/src/coordinator-mcp/session-reaper.ts +9 -1
- package/src/cursor-delete-path.ts +10 -0
- package/src/cursor-mcp-name.ts +15 -0
- package/src/cursor.ts +13 -2
- package/src/dap/client.ts +9 -2
- package/src/dap/config.ts +33 -13
- package/src/dap/defaults.json +1 -1
- package/src/dap/session.ts +161 -36
- package/src/debug/crash-diagnostics.ts +89 -6
- package/src/debug/report-bundle-parent.ts +22 -0
- package/src/debug/report-bundle.ts +100 -3
- package/src/debug/system-info.ts +21 -4
- package/src/defaults/skc/extensions/grok-cli-vendor/src/shared/base-url.ts +21 -7
- package/src/defaults/skc/skills/deep-interview/SKILL.md +1 -1
- package/src/discovery/agents-md.ts +3 -2
- package/src/discovery/agents.ts +3 -2
- package/src/discovery/builtin.ts +21 -11
- package/src/discovery/claude.ts +5 -4
- package/src/discovery/cline.ts +2 -2
- package/src/discovery/codex.ts +6 -5
- package/src/discovery/cursor.ts +11 -2
- package/src/discovery/gemini.ts +4 -3
- package/src/discovery/github.ts +2 -2
- package/src/discovery/helpers.ts +51 -11
- package/src/discovery/mcp-json.ts +28 -12
- package/src/discovery/opencode.ts +2 -1
- package/src/discovery/ssh.ts +11 -6
- package/src/discovery/substitute-plugin-root.ts +3 -1
- package/src/discovery/vscode.ts +3 -3
- package/src/edit/apply-patch/index.ts +12 -1
- package/src/edit/file-read-cache.ts +24 -6
- package/src/edit/index.ts +90 -20
- package/src/edit/modes/patch.ts +215 -9
- package/src/edit/modes/replace.ts +141 -0
- package/src/eval/js/context-manager.ts +29 -3
- package/src/eval/js/worker-entry.ts +51 -18
- package/src/eval/py/runner.py +144 -5
- package/src/eval/py/runtime.ts +44 -4
- package/src/eval/py/tool-bridge.ts +4 -0
- package/src/exa/mcp-client.ts +53 -11
- package/src/exec/bash-executor.ts +87 -4
- package/src/exec/non-interactive-env.ts +0 -1
- package/src/export/html/css-color.ts +9 -0
- package/src/export/html/html-export-destination.ts +16 -0
- package/src/export/html/index.ts +102 -8
- package/src/export/html/template.generated.ts +1 -1
- package/src/extensibility/custom-tools/loader.ts +13 -3
- package/src/extensibility/custom-tools/types.ts +3 -1
- package/src/extensibility/custom-tools/wrapper.ts +3 -1
- package/src/extensibility/plugins/manager.ts +3 -2
- package/src/extensibility/plugins/marketplace/cache.ts +15 -0
- package/src/extensibility/plugins/marketplace/fetcher.ts +2 -2
- package/src/extensibility/plugins/marketplace/manager.ts +5 -3
- package/src/extensibility/plugins/plugin-link-path.ts +12 -0
- package/src/extensibility/skc-plugins/mcp-policy.ts +2 -1
- package/src/goals/runtime.ts +30 -8
- package/src/harness-control-plane/finalize.ts +10 -0
- package/src/harness-control-plane/operate.ts +12 -4
- package/src/harness-control-plane/owner.ts +8 -1
- package/src/harness-control-plane/receipt-spool.ts +105 -28
- package/src/harness-control-plane/storage.ts +124 -6
- package/src/hashline/execute.ts +3 -3
- package/src/hashline/recovery.ts +85 -2
- package/src/hindsight/config.ts +9 -3
- package/src/hindsight/content.ts +116 -16
- package/src/hindsight/mental-models.ts +22 -10
- package/src/hindsight/state.ts +7 -4
- package/src/hooks/native-skill-hook.ts +17 -12
- package/src/i18n/messages/de.settings.ts +3 -0
- package/src/i18n/messages/es.settings.ts +3 -0
- package/src/i18n/messages/fr.settings.ts +3 -0
- package/src/i18n/messages/ja.settings.ts +3 -0
- package/src/i18n/messages/ko.settings.ts +3 -0
- package/src/i18n/messages/zh.settings.ts +3 -0
- package/src/internal-urls/artifact-protocol.ts +3 -1
- package/src/internal-urls/docs-index.generated.ts +10 -10
- package/src/internal-urls/local-protocol.ts +167 -8
- package/src/internal-urls/skill-path.ts +18 -0
- package/src/internal-urls/skill-protocol.ts +2 -0
- package/src/internal-urls/types.ts +2 -0
- package/src/lsp/client.ts +2 -1
- package/src/lsp/clients/biome-client.ts +2 -0
- package/src/lsp/clients/swiftlint-client.ts +2 -0
- package/src/lsp/config.ts +18 -62
- package/src/lsp/edits.ts +6 -0
- package/src/lsp/index.ts +29 -0
- package/src/lsp/workspace-path.ts +75 -0
- package/src/main.ts +33 -11
- package/src/memories/index.ts +141 -9
- package/src/migrate/action-planner.ts +57 -0
- package/src/migrate/adapters/claude-code.ts +23 -4
- package/src/migrate/adapters/codex.ts +22 -4
- package/src/migrate/adapters/index.ts +22 -4
- package/src/migrate/adapters/opencode.ts +6 -1
- package/src/migrate/executor.ts +84 -7
- package/src/migrate/report.ts +19 -2
- package/src/migrate/types.ts +14 -4
- package/src/modes/DESIGN.md +5 -0
- package/src/modes/acp/acp-agent.ts +35 -2
- package/src/modes/acp/permission-mode.ts +18 -1
- package/src/modes/components/custom-editor.ts +14 -0
- package/src/modes/components/extensions/extension-dashboard.ts +2 -2
- package/src/modes/components/extensions/inspector-panel.ts +9 -5
- package/src/modes/components/extensions/state-manager.ts +15 -5
- package/src/modes/components/model-selector.ts +144 -94
- package/src/modes/components/welcome.ts +3 -2
- package/src/modes/controllers/command-controller.ts +300 -9
- package/src/modes/controllers/event-controller.ts +1 -1
- package/src/modes/controllers/extension-ui-controller.ts +32 -19
- package/src/modes/controllers/input-controller.ts +62 -26
- package/src/modes/controllers/plan-mode-controller.ts +17 -7
- package/src/modes/controllers/runtime-mcp-command-controller.ts +25 -20
- package/src/modes/controllers/ssh-command-controller.ts +3 -1
- package/src/modes/interactive-mode.ts +10 -0
- package/src/modes/utils/macos-option-forwarding.ts +80 -0
- package/src/prompts/system/irc-incoming.md +3 -1
- package/src/prompts/system/project-prompt.md +19 -0
- package/src/prompts/system/system-prompt.md +3 -0
- package/src/prompts/tools/ask.md +2 -0
- package/src/prompts/tools/debug.md +1 -1
- package/src/prompts/tools/monitor.md +7 -5
- package/src/prompts/tools/reverse-engineer.md +29 -0
- package/src/runtime-credential-selector.ts +2 -2
- package/src/runtime-mcp/config-writer.ts +10 -6
- package/src/runtime-mcp/config.ts +1 -0
- package/src/runtime-mcp/content-limits.ts +7 -0
- package/src/runtime-mcp/json-rpc.ts +2 -1
- package/src/runtime-mcp/manager.ts +57 -9
- package/src/runtime-mcp/mcp-redirect.ts +73 -0
- package/src/runtime-mcp/oauth-flow.ts +43 -5
- package/src/runtime-mcp/oauth-public-url.ts +8 -0
- package/src/runtime-mcp/plugin-mcp-name-filter.ts +62 -0
- package/src/runtime-mcp/plugin-network-boundary.ts +4 -0
- package/src/runtime-mcp/project-host-values.ts +50 -0
- package/src/runtime-mcp/render.ts +16 -1
- package/src/runtime-mcp/smithery-registry.ts +22 -3
- package/src/runtime-mcp/tool-bridge.ts +194 -21
- package/src/runtime-mcp/transports/http.ts +4 -3
- package/src/runtime-mcp/transports/stdio.ts +2 -1
- package/src/runtime-mcp/types.ts +6 -0
- package/src/sdk/broker/broker.ts +11 -2
- package/src/sdk/broker/ensure.ts +131 -10
- package/src/sdk/broker/lifecycle-ledger.ts +18 -3
- package/src/sdk/broker/lifecycle.ts +21 -19
- package/src/sdk/broker/runtime.ts +1 -1
- package/src/sdk/bus/chat-daemon-cli.ts +38 -1
- package/src/sdk/bus/chat-daemon-control.ts +5 -3
- package/src/sdk/bus/index.ts +5 -3
- package/src/sdk/bus/lifecycle-control-runtime.ts +9 -2
- package/src/sdk/bus/session-control.ts +2 -0
- package/src/sdk/bus/slack-daemon.ts +8 -1
- package/src/sdk/bus/slack-live-provider.ts +3 -1
- package/src/sdk/bus/telegram-daemon-contract.ts +3 -1
- package/src/sdk/bus/telegram-daemon-control.ts +17 -12
- package/src/sdk/bus/telegram-daemon.ts +41 -1
- package/src/sdk/host/events.ts +67 -4
- package/src/sdk/mcp/server.ts +16 -3
- package/src/sdk/protocol/operation-inventory.generated.json +22 -0
- package/src/sdk/session.ts +18 -25
- package/src/secrets/obfuscator.ts +92 -12
- package/src/session/agent-session.ts +395 -79
- package/src/session/artifacts.ts +3 -1
- package/src/session/history-storage.ts +172 -8
- package/src/session/internal/managed-session-scope.ts +130 -52
- package/src/session/messages.ts +47 -6
- package/src/session/session-manager.ts +170 -10
- package/src/session/session-storage.ts +31 -1
- package/src/session/streaming-output.ts +263 -4
- package/src/session-import/redact.ts +76 -3
- package/src/setup/hermes-setup.ts +4 -1
- package/src/skc-runtime/gc-runtime.ts +26 -4
- package/src/skc-runtime/launch-tmux.ts +21 -11
- package/src/skc-runtime/launch-worktree.ts +42 -3
- package/src/skc-runtime/managed-owner-admission.ts +46 -2
- package/src/skc-runtime/psmux-detect.ts +29 -5
- package/src/skc-runtime/ralplan-runtime.ts +14 -1
- package/src/skc-runtime/session-resolution.ts +38 -6
- package/src/skc-runtime/sidecar-bootstrap-env.ts +19 -0
- package/src/skc-runtime/state-writer.ts +134 -16
- package/src/skc-runtime/tmux-sessions.ts +85 -4
- package/src/skc-runtime/ultragoal-change-set.ts +18 -2
- package/src/skc-runtime/ultragoal-guard.ts +9 -1
- package/src/skc-runtime/ultragoal-runtime.ts +26 -9
- package/src/skill-state/active-state.ts +13 -0
- package/src/skill-state/workflow-mutation-guard.ts +3297 -180
- package/src/slash-commands/builtin-registry.ts +14 -8
- package/src/slash-commands/helpers/mcp.ts +20 -7
- package/src/ssh/ssh-executor.ts +3 -1
- package/src/stt/recorder.ts +26 -9
- package/src/system-prompt.ts +65 -16
- package/src/task/commands.ts +3 -1
- package/src/task/executor.ts +52 -7
- package/src/task/index.ts +28 -0
- package/src/task/isolation-dir.ts +143 -0
- package/src/task/role-body.ts +84 -0
- package/src/task/token-log-mode.test.ts +162 -0
- package/src/task/token-log.ts +91 -2
- package/src/task/worktree.ts +16 -7
- package/src/tools/archive-reader.ts +653 -31
- package/src/tools/ask.ts +86 -14
- package/src/tools/ast-edit-write-path.ts +133 -0
- package/src/tools/ast-edit.ts +27 -1
- package/src/tools/ast-grep.ts +7 -2
- package/src/tools/atomic-file-write.ts +625 -0
- package/src/tools/auto-generated-guard.ts +28 -8
- package/src/tools/bash-allowed-prefixes.ts +225 -6
- package/src/tools/bash-interactive.ts +12 -0
- package/src/tools/bash-skill-urls.ts +113 -7
- package/src/tools/bash.ts +152 -20
- package/src/tools/browser/cdp-url.ts +18 -0
- package/src/tools/browser/tab-worker.ts +49 -14
- package/src/tools/browser.ts +25 -8
- package/src/tools/cron.ts +10 -1
- package/src/tools/debug.ts +16 -8
- package/src/tools/eval.ts +71 -34
- package/src/tools/explicit-artifact.ts +89 -0
- package/src/tools/fetch.ts +26 -17
- package/src/tools/gh.ts +40 -12
- package/src/tools/github-side-effect.ts +112 -0
- package/src/tools/image-gen.ts +24 -10
- package/src/tools/index.ts +6 -0
- package/src/tools/monitor-mutation.ts +27 -0
- package/src/tools/monitor.ts +28 -1
- package/src/tools/output-meta.ts +74 -5
- package/src/tools/read.ts +24 -36
- package/src/tools/recipe/index.ts +12 -0
- package/src/tools/recipe/recipe-guard.ts +19 -0
- package/src/tools/recipe/runner.ts +23 -12
- package/src/tools/render-utils.ts +2 -2
- package/src/tools/restricted-cwd.ts +10 -0
- package/src/tools/reverse-engineer.ts +497 -0
- package/src/tools/search-tool-bm25.ts +14 -3
- package/src/tools/search.ts +3 -2
- package/src/tools/ssh.ts +235 -8
- package/src/tools/subagent-render.ts +43 -7
- package/src/tools/subagent.ts +7 -3
- package/src/tools/tmux-self-injection-guard.ts +3538 -0
- package/src/tools/todo-write.ts +41 -3
- package/src/tools/untrusted-content.ts +23 -0
- package/src/tools/vim.ts +2 -2
- package/src/tools/write.ts +37 -4
- package/src/tui/tree-list.ts +15 -1
- package/src/utils/commit-message-generator.ts +9 -2
- package/src/utils/external-editor.ts +21 -7
- package/src/utils/file-mentions.ts +75 -7
- package/src/utils/git.ts +38 -7
- package/src/utils/open.ts +73 -4
- package/src/utils/shell-snapshot.ts +9 -1
- package/src/utils/title-generator.ts +61 -16
- package/src/utils/tools-checksum.ts +34 -0
- package/src/utils/tools-manager.ts +24 -6
- package/src/utils/xml-escape.ts +14 -0
- package/src/web/insane/url-guard.ts +2 -1
- package/src/web/scrapers/types.ts +8 -0
- package/src/web/scrapers/youtube.ts +3 -2
- package/src/web/search/index.ts +4 -3
- package/src/web/search/providers/anthropic.ts +4 -4
- package/src/web/search/providers/codex.ts +31 -34
- package/src/web/search/providers/insane.ts +145 -28
- package/src/web/search/providers/kimi.ts +15 -5
- package/src/web/search/providers/searxng.ts +47 -4
- package/src/web/search/providers/xai.ts +7 -2
- package/dist/types/cli/shell-cli.d.ts +0 -8
- package/dist/types/commands/shell.d.ts +0 -21
- package/src/cli/shell-cli.ts +0 -176
- package/src/commands/shell.ts +0 -29
package/src/tools/bash.ts
CHANGED
|
@@ -14,15 +14,43 @@ import bashDescription from "../prompts/tools/bash.md" with { type: "text" };
|
|
|
14
14
|
import type { ClientBridgeTerminalExitStatus, ClientBridgeTerminalOutput } from "../session/client-bridge";
|
|
15
15
|
import { DEFAULT_MAX_BYTES, streamTailUpdates, TailBuffer } from "../session/streaming-output";
|
|
16
16
|
import { buildSkcRuntimeSessionEnv } from "../skc-runtime/goal-mode-request";
|
|
17
|
+
import { SKC_TMUX_LAUNCHED_ENV } from "../skc-runtime/launch-tmux";
|
|
18
|
+
import {
|
|
19
|
+
MANAGED_OWNER_PREDECESSOR_GENERATION_ENV,
|
|
20
|
+
MANAGED_OWNER_PREDECESSOR_INCARNATION_ENV,
|
|
21
|
+
MANAGED_OWNER_PREDECESSOR_RUN_ID_ENV,
|
|
22
|
+
MANAGED_OWNER_PREDECESSOR_TOKEN_ENV,
|
|
23
|
+
MANAGED_OWNER_TRANSCRIPT_PATH_ENV,
|
|
24
|
+
} from "../skc-runtime/managed-owner-admission";
|
|
25
|
+
import {
|
|
26
|
+
MANAGED_OWNER_CHILD_TOKEN_ENV,
|
|
27
|
+
MANAGED_OWNER_COMMAND_ENV,
|
|
28
|
+
MANAGED_OWNER_GENERATION_ENV,
|
|
29
|
+
MANAGED_OWNER_INCARNATION_ENV,
|
|
30
|
+
MANAGED_OWNER_RUN_ID_ENV,
|
|
31
|
+
MANAGED_OWNER_STATE_DIR_ENV,
|
|
32
|
+
} from "../skc-runtime/managed-owner-supervisor";
|
|
17
33
|
import {
|
|
18
34
|
SKC_RALPLAN_ARTIFACT_ENV,
|
|
19
35
|
SKC_RESTRICTED_ROLE_AGENT_BASH_ENV,
|
|
20
36
|
} from "../skc-runtime/restricted-role-agent-bash";
|
|
37
|
+
import {
|
|
38
|
+
SKC_COORDINATOR_SESSION_BRANCH_ENV,
|
|
39
|
+
SKC_COORDINATOR_SESSION_ID_ENV,
|
|
40
|
+
SKC_COORDINATOR_SESSION_LAUNCH_ID_ENV,
|
|
41
|
+
SKC_COORDINATOR_SESSION_READINESS_FILE_ENV,
|
|
42
|
+
SKC_COORDINATOR_SESSION_STATE_FILE_ENV,
|
|
43
|
+
SKC_TMUX_OWNER_SERVER_KEY_ENV,
|
|
44
|
+
} from "../skc-runtime/session-state-sidecar";
|
|
21
45
|
import { renderStatusLine } from "../tui";
|
|
22
46
|
import { CachedOutputBlock } from "../tui/output-block";
|
|
23
47
|
import { getSixelLineMask } from "../utils/sixel";
|
|
24
48
|
import type { ToolSession } from ".";
|
|
25
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
checkBashAllowedPrefixes,
|
|
51
|
+
normalizeReadOnlyBashCommand,
|
|
52
|
+
normalizeWorkflowBashCommand,
|
|
53
|
+
} from "./bash-allowed-prefixes";
|
|
26
54
|
import { applyBashFixups } from "./bash-command-fixup";
|
|
27
55
|
import { type BashInteractiveResult, runInteractiveBashPty } from "./bash-interactive";
|
|
28
56
|
import { checkBashInterception } from "./bash-interceptor";
|
|
@@ -32,6 +60,8 @@ import { checkComposerBashPolicy } from "./composer-bash-policy";
|
|
|
32
60
|
import { formatStyledTruncationWarning, type OutputMeta, stripOutputNotice } from "./output-meta";
|
|
33
61
|
import { resolveToCwd } from "./path-utils";
|
|
34
62
|
import { formatToolWorkingDirectory, replaceTabs } from "./render-utils";
|
|
63
|
+
import { assertCwdInsideWorkspace } from "./restricted-cwd";
|
|
64
|
+
import { checkTmuxSelfInjection } from "./tmux-self-injection-guard";
|
|
35
65
|
import { ToolAbortError, ToolError } from "./tool-errors";
|
|
36
66
|
import { toolResult } from "./tool-result";
|
|
37
67
|
import { clampTimeout, TOOL_TIMEOUTS } from "./tool-timeouts";
|
|
@@ -39,6 +69,38 @@ import { clampTimeout, TOOL_TIMEOUTS } from "./tool-timeouts";
|
|
|
39
69
|
export const BASH_DEFAULT_PREVIEW_LINES = 10;
|
|
40
70
|
|
|
41
71
|
const BASH_ENV_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
72
|
+
// Managed-owner env vars that must be scrubbed from child processes.
|
|
73
|
+
// Exported for testing the env scrubbing behavior.
|
|
74
|
+
export const MANAGED_OWNER_BASH_ENV = [
|
|
75
|
+
MANAGED_OWNER_STATE_DIR_ENV,
|
|
76
|
+
MANAGED_OWNER_GENERATION_ENV,
|
|
77
|
+
MANAGED_OWNER_RUN_ID_ENV,
|
|
78
|
+
MANAGED_OWNER_INCARNATION_ENV,
|
|
79
|
+
MANAGED_OWNER_CHILD_TOKEN_ENV,
|
|
80
|
+
MANAGED_OWNER_COMMAND_ENV,
|
|
81
|
+
MANAGED_OWNER_PREDECESSOR_TOKEN_ENV,
|
|
82
|
+
MANAGED_OWNER_PREDECESSOR_GENERATION_ENV,
|
|
83
|
+
MANAGED_OWNER_PREDECESSOR_RUN_ID_ENV,
|
|
84
|
+
MANAGED_OWNER_PREDECESSOR_INCARNATION_ENV,
|
|
85
|
+
MANAGED_OWNER_TRANSCRIPT_PATH_ENV,
|
|
86
|
+
// The rest of the tmux-owner tuple (tmux-sessions.ts managedEnvironment): leaving
|
|
87
|
+
// either behind makes ownerTerminalContextFromEnvironment() report "invalid" in a
|
|
88
|
+
// nested skc, because a server key or SKC_TMUX_LAUNCHED=1 without generation/state
|
|
89
|
+
// dir is an incomplete owner context.
|
|
90
|
+
SKC_TMUX_OWNER_SERVER_KEY_ENV,
|
|
91
|
+
SKC_TMUX_LAUNCHED_ENV,
|
|
92
|
+
] as const;
|
|
93
|
+
|
|
94
|
+
// Coordinator-only session markers. A nested skc started from the bash tool
|
|
95
|
+
// would otherwise adopt this session's state file and identity.
|
|
96
|
+
const COORDINATOR_ONLY_BASH_ENV = [
|
|
97
|
+
SKC_COORDINATOR_SESSION_STATE_FILE_ENV,
|
|
98
|
+
SKC_COORDINATOR_SESSION_ID_ENV,
|
|
99
|
+
SKC_COORDINATOR_SESSION_BRANCH_ENV,
|
|
100
|
+
SKC_COORDINATOR_SESSION_LAUNCH_ID_ENV,
|
|
101
|
+
SKC_COORDINATOR_SESSION_READINESS_FILE_ENV,
|
|
102
|
+
...MANAGED_OWNER_BASH_ENV,
|
|
103
|
+
] as const;
|
|
42
104
|
const DEFAULT_AUTO_BACKGROUND_THRESHOLD_MS = 60_000;
|
|
43
105
|
const READ_ONLY_BASH_ENV: Record<string, string> = {
|
|
44
106
|
GREP_OPTIONS: "",
|
|
@@ -401,6 +463,7 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
401
463
|
notices?: readonly string[];
|
|
402
464
|
|
|
403
465
|
resolvedEnv?: Record<string, string>;
|
|
466
|
+
unsetEnv: string[];
|
|
404
467
|
onUpdate?: AgentToolUpdateCallback<BashToolDetails>;
|
|
405
468
|
startBackgrounded: boolean;
|
|
406
469
|
}): ManagedBashJobHandle {
|
|
@@ -433,11 +496,12 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
433
496
|
timeout: options.timeoutMs,
|
|
434
497
|
signal: runSignal,
|
|
435
498
|
env: options.resolvedEnv,
|
|
499
|
+
unsetEnv: options.unsetEnv,
|
|
436
500
|
artifactPath,
|
|
437
501
|
artifactId,
|
|
438
502
|
oneShot: true,
|
|
439
|
-
ignoreShellPrefix: this
|
|
440
|
-
disableShellSnapshot: this
|
|
503
|
+
ignoreShellPrefix: this.#isolateRestrictedShell(),
|
|
504
|
+
disableShellSnapshot: this.#isolateRestrictedShell(),
|
|
441
505
|
onChunk: chunk => {
|
|
442
506
|
tailBuffer.append(chunk);
|
|
443
507
|
latestText = tailBuffer.text();
|
|
@@ -494,7 +558,7 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
494
558
|
|
|
495
559
|
async #waitForManagedBashJob(
|
|
496
560
|
job: ManagedBashJobHandle,
|
|
497
|
-
thresholdMs: number,
|
|
561
|
+
thresholdMs: number | undefined,
|
|
498
562
|
signal?: AbortSignal,
|
|
499
563
|
backgroundRequest?: Promise<void>,
|
|
500
564
|
): Promise<ManagedBashJobCompletion | { kind: "running" } | { kind: "aborted" }> {
|
|
@@ -502,26 +566,32 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
502
566
|
return { kind: "aborted" };
|
|
503
567
|
}
|
|
504
568
|
|
|
569
|
+
// No threshold means no timer fold: the job leaves the foreground only on an
|
|
570
|
+
// explicit background request.
|
|
571
|
+
let thresholdTimer: NodeJS.Timeout | undefined;
|
|
505
572
|
const waiters: Array<Promise<ManagedBashJobCompletion | { kind: "running" } | { kind: "aborted" }>> = [
|
|
506
573
|
job.completion,
|
|
507
|
-
Bun.sleep(thresholdMs).then(() => ({ kind: "running" as const })),
|
|
508
574
|
];
|
|
575
|
+
if (thresholdMs !== undefined) {
|
|
576
|
+
const threshold = Promise.withResolvers<{ kind: "running" }>();
|
|
577
|
+
thresholdTimer = setTimeout(() => threshold.resolve({ kind: "running" }), Math.max(0, thresholdMs));
|
|
578
|
+
waiters.push(threshold.promise);
|
|
579
|
+
}
|
|
509
580
|
if (backgroundRequest) {
|
|
510
581
|
waiters.push(backgroundRequest.then(() => ({ kind: "running" as const })));
|
|
511
582
|
}
|
|
512
583
|
|
|
513
|
-
if (!signal) {
|
|
514
|
-
return await Promise.race(waiters);
|
|
515
|
-
}
|
|
516
|
-
|
|
517
584
|
const { promise: abortedPromise, resolve: resolveAborted } = Promise.withResolvers<{ kind: "aborted" }>();
|
|
518
585
|
const onAbort = () => resolveAborted({ kind: "aborted" });
|
|
519
|
-
signal
|
|
520
|
-
|
|
586
|
+
if (signal) {
|
|
587
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
588
|
+
waiters.push(abortedPromise);
|
|
589
|
+
}
|
|
521
590
|
try {
|
|
522
591
|
return await Promise.race(waiters);
|
|
523
592
|
} finally {
|
|
524
|
-
|
|
593
|
+
if (thresholdTimer !== undefined) clearTimeout(thresholdTimer);
|
|
594
|
+
signal?.removeEventListener("abort", onAbort);
|
|
525
595
|
}
|
|
526
596
|
}
|
|
527
597
|
|
|
@@ -531,6 +601,11 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
531
601
|
return Math.max(0, Math.min(this.#autoBackgroundThresholdMs, timeoutMs - timeoutBufferMs));
|
|
532
602
|
}
|
|
533
603
|
|
|
604
|
+
/** Read-only and workflow allowlists must not source a snapshot or a shell prefix. */
|
|
605
|
+
#isolateRestrictedShell(): boolean {
|
|
606
|
+
return this.session.bashRestrictionProfile === "read-only" || (this.session.bashAllowedPrefixes?.length ?? 0) > 0;
|
|
607
|
+
}
|
|
608
|
+
|
|
534
609
|
/**
|
|
535
610
|
* Build the fully-prepared parameters for a `bash`-flavored execution
|
|
536
611
|
* (interceptors, internal URL expansion, env resolution, cwd validation,
|
|
@@ -545,6 +620,7 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
545
620
|
command: string;
|
|
546
621
|
commandCwd: string;
|
|
547
622
|
resolvedEnv: Record<string, string>;
|
|
623
|
+
unsetEnv: string[];
|
|
548
624
|
requestedTimeoutSec: number;
|
|
549
625
|
timeoutSec: number;
|
|
550
626
|
timeoutMs: number;
|
|
@@ -592,9 +668,22 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
592
668
|
}
|
|
593
669
|
if (allowedPrefixes && allowedPrefixes.length > 0) {
|
|
594
670
|
const commandsToCheck = rawCommand === command ? [command] : [rawCommand, command];
|
|
671
|
+
const invocationCwd =
|
|
672
|
+
cwd && !cwd.includes("://") && !cwd.includes("local:/")
|
|
673
|
+
? resolveToCwd(cwd, this.session.cwd)
|
|
674
|
+
: this.session.cwd;
|
|
595
675
|
for (const commandToCheck of commandsToCheck) {
|
|
596
676
|
const allowlist = checkBashAllowedPrefixes(commandToCheck, allowedPrefixes, {
|
|
597
677
|
profile: this.session.bashRestrictionProfile,
|
|
678
|
+
...(this.session.bashRestrictionProfile === "read-only"
|
|
679
|
+
? {}
|
|
680
|
+
: {
|
|
681
|
+
skcSessionBinding: {
|
|
682
|
+
sessionId: this.session.getSessionId?.() ?? null,
|
|
683
|
+
worktreeRoot: this.session.cwd,
|
|
684
|
+
invocationCwd,
|
|
685
|
+
},
|
|
686
|
+
}),
|
|
598
687
|
});
|
|
599
688
|
if (!allowlist.allowed) {
|
|
600
689
|
throw new ToolError(allowlist.reason ?? "Command blocked by restricted role-agent bash allowlist.");
|
|
@@ -670,6 +759,7 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
670
759
|
...(this.session.bashRestrictionProfile === "read-only" ? READ_ONLY_BASH_ENV : {}),
|
|
671
760
|
...(allowedPrefixes && allowedPrefixes.length > 0 ? { [SKC_RESTRICTED_ROLE_AGENT_BASH_ENV]: "1" } : {}),
|
|
672
761
|
};
|
|
762
|
+
const unsetEnv = COORDINATOR_ONLY_BASH_ENV.filter(name => !Object.hasOwn(expandedEnv ?? {}, name));
|
|
673
763
|
|
|
674
764
|
if (cwd?.includes("://") || cwd?.includes("local:/")) {
|
|
675
765
|
cwd = await expandInternalUrls(cwd, { ...internalUrlOptions, noEscape: true });
|
|
@@ -688,6 +778,42 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
688
778
|
if (!cwdStat.isDirectory()) {
|
|
689
779
|
throw new ToolError(`Working directory is not a directory: ${commandCwd}`);
|
|
690
780
|
}
|
|
781
|
+
if (this.session.bashRestrictionProfile === "read-only" || (allowedPrefixes?.length ?? 0) > 0) {
|
|
782
|
+
await assertCwdInsideWorkspace(this.session.cwd, commandCwd);
|
|
783
|
+
}
|
|
784
|
+
// Issue #5039: refuse tmux write verbs whose target resolves to this
|
|
785
|
+
// agent's own tmux pane — such bytes forge a human `user` turn in the
|
|
786
|
+
// transcript. This is after command/env/cwd preparation but before any
|
|
787
|
+
// spawn, so guard discovery matches execution without trusting caller env
|
|
788
|
+
// for the agent's tmux identity.
|
|
789
|
+
if (this.session.bashRestrictionProfile !== "read-only") {
|
|
790
|
+
const shellConfigEnv = this.session.settings.getShellConfig().env;
|
|
791
|
+
const injection = await checkTmuxSelfInjection(command, {
|
|
792
|
+
env: process.env,
|
|
793
|
+
cwd: commandCwd,
|
|
794
|
+
executionEnv: { ...process.env, ...shellConfigEnv, ...resolvedEnv },
|
|
795
|
+
});
|
|
796
|
+
if (injection.block) {
|
|
797
|
+
throw new ToolError(injection.reason ?? "Blocked: tmux self-pane injection.");
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// Every restricted workflow command is rebound to its resolved executable
|
|
802
|
+
// here, after the allowlist and interceptor have seen the caller's text.
|
|
803
|
+
if (this.session.bashRestrictionProfile !== "read-only" && allowedPrefixes && allowedPrefixes.length > 0) {
|
|
804
|
+
const normalizedWorkflowCommand = normalizeWorkflowBashCommand(command, allowedPrefixes, {
|
|
805
|
+
profile: "workflow",
|
|
806
|
+
skcSessionBinding: {
|
|
807
|
+
sessionId: this.session.getSessionId?.() ?? null,
|
|
808
|
+
worktreeRoot: this.session.cwd,
|
|
809
|
+
invocationCwd: commandCwd,
|
|
810
|
+
},
|
|
811
|
+
});
|
|
812
|
+
if (!normalizedWorkflowCommand) {
|
|
813
|
+
throw new ToolError("Restricted role-agent bash command could not be normalized safely.");
|
|
814
|
+
}
|
|
815
|
+
command = normalizedWorkflowCommand;
|
|
816
|
+
}
|
|
691
817
|
|
|
692
818
|
const requestedTimeoutSec = input.timeout ?? 300;
|
|
693
819
|
const timeoutSec = clampTimeout("bash", requestedTimeoutSec);
|
|
@@ -696,7 +822,7 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
696
822
|
const timeoutClampNotice = formatTimeoutClampNotice(requestedTimeoutSec, timeoutSec);
|
|
697
823
|
if (timeoutClampNotice) notices.push(timeoutClampNotice);
|
|
698
824
|
|
|
699
|
-
return { command, commandCwd, resolvedEnv, requestedTimeoutSec, timeoutSec, timeoutMs, notices };
|
|
825
|
+
return { command, commandCwd, resolvedEnv, unsetEnv, requestedTimeoutSec, timeoutSec, timeoutMs, notices };
|
|
700
826
|
}
|
|
701
827
|
|
|
702
828
|
/**
|
|
@@ -779,11 +905,12 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
779
905
|
timeout: monitorTimeoutMs,
|
|
780
906
|
signal,
|
|
781
907
|
env: prepared.resolvedEnv,
|
|
908
|
+
unsetEnv: prepared.unsetEnv,
|
|
782
909
|
artifactPath,
|
|
783
910
|
artifactId,
|
|
784
911
|
oneShot: true,
|
|
785
|
-
ignoreShellPrefix: this
|
|
786
|
-
disableShellSnapshot: this
|
|
912
|
+
ignoreShellPrefix: this.#isolateRestrictedShell(),
|
|
913
|
+
disableShellSnapshot: this.#isolateRestrictedShell(),
|
|
787
914
|
onChunk: chunk => {
|
|
788
915
|
tailBuffer.append(chunk);
|
|
789
916
|
void reportProgress(tailBuffer.text(), {
|
|
@@ -843,6 +970,7 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
843
970
|
command,
|
|
844
971
|
commandCwd,
|
|
845
972
|
resolvedEnv,
|
|
973
|
+
unsetEnv,
|
|
846
974
|
requestedTimeoutSec,
|
|
847
975
|
timeoutSec,
|
|
848
976
|
timeoutMs,
|
|
@@ -862,6 +990,7 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
862
990
|
notices: pendingNotices,
|
|
863
991
|
|
|
864
992
|
resolvedEnv,
|
|
993
|
+
unsetEnv,
|
|
865
994
|
onUpdate,
|
|
866
995
|
startBackgrounded: true,
|
|
867
996
|
});
|
|
@@ -882,11 +1011,11 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
882
1011
|
// even when auto-background is disabled. When a client terminal will handle the
|
|
883
1012
|
// command, keep the existing bridge path unless auto-background is enabled.
|
|
884
1013
|
if (!pty && autoBgManager && (this.#autoBackgroundEnabled || !clientTerminalActive)) {
|
|
885
|
-
// With auto-background off, wait
|
|
886
|
-
// leaves the foreground on an explicit Ctrl+B fold
|
|
1014
|
+
// With auto-background off, the foreground wait has no timer threshold, so the job
|
|
1015
|
+
// only leaves the foreground on an explicit Ctrl+B fold.
|
|
887
1016
|
const autoBackgroundWaitMs = this.#autoBackgroundEnabled
|
|
888
1017
|
? this.#resolveAutoBackgroundWaitMs(timeoutMs)
|
|
889
|
-
:
|
|
1018
|
+
: undefined;
|
|
890
1019
|
const startBackgrounded = autoBackgroundWaitMs === 0;
|
|
891
1020
|
const job = this.#startManagedBashJob({
|
|
892
1021
|
command,
|
|
@@ -897,6 +1026,7 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
897
1026
|
notices: pendingNotices,
|
|
898
1027
|
|
|
899
1028
|
resolvedEnv,
|
|
1029
|
+
unsetEnv,
|
|
900
1030
|
onUpdate,
|
|
901
1031
|
startBackgrounded,
|
|
902
1032
|
});
|
|
@@ -1127,6 +1257,7 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
1127
1257
|
timeoutMs,
|
|
1128
1258
|
signal,
|
|
1129
1259
|
env: resolvedEnv,
|
|
1260
|
+
unsetEnv,
|
|
1130
1261
|
artifactPath,
|
|
1131
1262
|
artifactId,
|
|
1132
1263
|
})
|
|
@@ -1137,12 +1268,13 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
|
|
|
1137
1268
|
timeout: timeoutMs,
|
|
1138
1269
|
signal,
|
|
1139
1270
|
env: resolvedEnv,
|
|
1271
|
+
unsetEnv,
|
|
1140
1272
|
artifactPath,
|
|
1141
1273
|
artifactId,
|
|
1142
1274
|
onChunk: streamTailUpdates(tailBuffer, onUpdate),
|
|
1143
1275
|
onMinimizedSave: originalText => saveBashOriginalArtifactForTests(this.session, originalText),
|
|
1144
|
-
ignoreShellPrefix: this
|
|
1145
|
-
disableShellSnapshot: this
|
|
1276
|
+
ignoreShellPrefix: this.#isolateRestrictedShell(),
|
|
1277
|
+
disableShellSnapshot: this.#isolateRestrictedShell(),
|
|
1146
1278
|
});
|
|
1147
1279
|
if (result.cancelled) {
|
|
1148
1280
|
if (signal?.aborted) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "::1", "[::1]"]);
|
|
2
|
+
|
|
3
|
+
/** Require an http(s) CDP URL whose host is loopback. */
|
|
4
|
+
export function assertLoopbackCdpUrl(cdpUrl: string): string {
|
|
5
|
+
let parsed: URL;
|
|
6
|
+
try {
|
|
7
|
+
parsed = new URL(cdpUrl);
|
|
8
|
+
} catch {
|
|
9
|
+
throw new Error(`Refusing non-loopback CDP endpoint: ${cdpUrl}`);
|
|
10
|
+
}
|
|
11
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
12
|
+
throw new Error(`Refusing non-loopback CDP endpoint: ${cdpUrl}`);
|
|
13
|
+
}
|
|
14
|
+
if (!LOOPBACK_HOSTS.has(parsed.hostname.toLowerCase())) {
|
|
15
|
+
throw new Error(`Refusing non-loopback CDP endpoint: ${cdpUrl}`);
|
|
16
|
+
}
|
|
17
|
+
return cdpUrl;
|
|
18
|
+
}
|
|
@@ -3,7 +3,6 @@ import * as os from "node:os";
|
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
|
|
5
5
|
import { untilAborted } from "@sayknow-cli/utils/abortable";
|
|
6
|
-
import { Snowflake } from "@sayknow-cli/utils/snowflake";
|
|
7
6
|
import type { HTMLElement } from "linkedom";
|
|
8
7
|
import type {
|
|
9
8
|
Browser,
|
|
@@ -79,6 +78,15 @@ type DialogPolicy = "accept" | "dismiss";
|
|
|
79
78
|
type DragTarget = string | { readonly x: number; readonly y: number };
|
|
80
79
|
type ActionabilityResult = { ok: true; x: number; y: number } | { ok: false; reason: string };
|
|
81
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Test seam: override the worker's puppeteer loader so WorkerCore-level tests can
|
|
83
|
+
* inject a fake browser/page without a live Chromium.
|
|
84
|
+
*/
|
|
85
|
+
let loadPuppeteerInWorkerForTest: typeof loadPuppeteerInWorker | undefined;
|
|
86
|
+
export function __setLoadPuppeteerInWorkerForTest(loader: typeof loadPuppeteerInWorker | undefined): void {
|
|
87
|
+
loadPuppeteerInWorkerForTest = loader;
|
|
88
|
+
}
|
|
89
|
+
|
|
82
90
|
interface ScreenshotOptions {
|
|
83
91
|
selector?: string;
|
|
84
92
|
fullPage?: boolean;
|
|
@@ -394,6 +402,31 @@ interface ActiveRun {
|
|
|
394
402
|
pendingTools: Map<string, { resolve(value: unknown): void; reject(error: Error): void }>;
|
|
395
403
|
}
|
|
396
404
|
|
|
405
|
+
async function writePrivateScreenshot(bytes: Uint8Array): Promise<string> {
|
|
406
|
+
// Random directory plus an exclusive create: a preexisting symlink under the
|
|
407
|
+
// shared temp directory is not opened, and the screenshot is not left world-readable.
|
|
408
|
+
// Create the temp root first: base created it with a recursive mkdir, and
|
|
409
|
+
// mkdtemp fails when that root does not exist yet. Do not change the root's mode.
|
|
410
|
+
const root = os.tmpdir();
|
|
411
|
+
await fs.promises.mkdir(root, { recursive: true });
|
|
412
|
+
const tempDir = await fs.promises.mkdtemp(path.join(root, "skc-sshots-"));
|
|
413
|
+
try {
|
|
414
|
+
if (process.platform !== "win32") await fs.promises.chmod(tempDir, 0o700);
|
|
415
|
+
const dest = path.join(tempDir, "screenshot.png");
|
|
416
|
+
const handle = await fs.promises.open(dest, "wx", 0o600);
|
|
417
|
+
try {
|
|
418
|
+
await handle.writeFile(bytes);
|
|
419
|
+
} finally {
|
|
420
|
+
await handle.close();
|
|
421
|
+
}
|
|
422
|
+
if (process.platform !== "win32") await fs.promises.chmod(dest, 0o600);
|
|
423
|
+
return dest;
|
|
424
|
+
} catch (error) {
|
|
425
|
+
await fs.promises.rm(tempDir, { recursive: true, force: true });
|
|
426
|
+
throw error;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
397
430
|
export class WorkerCore {
|
|
398
431
|
#transport: Transport;
|
|
399
432
|
#browser?: Browser;
|
|
@@ -447,7 +480,7 @@ export class WorkerCore {
|
|
|
447
480
|
async #init(payload: WorkerInitPayload): Promise<void> {
|
|
448
481
|
try {
|
|
449
482
|
this.#mode = payload.mode;
|
|
450
|
-
const puppeteer = await loadPuppeteerInWorker(payload.safeDir);
|
|
483
|
+
const puppeteer = await (loadPuppeteerInWorkerForTest ?? loadPuppeteerInWorker)(payload.safeDir);
|
|
451
484
|
this.#browser = await puppeteer.connect({
|
|
452
485
|
browserWSEndpoint: payload.browserWSEndpoint,
|
|
453
486
|
defaultViewport: null,
|
|
@@ -815,20 +848,22 @@ export class WorkerCore {
|
|
|
815
848
|
{ maxWidth: 1024, maxHeight: 1024, maxBytes: 150 * 1024, jpegQuality: 70 },
|
|
816
849
|
);
|
|
817
850
|
const explicitPath = opts.save ? resolveTabWorkerPath(opts.save, session.cwd) : undefined;
|
|
818
|
-
|
|
819
|
-
const
|
|
820
|
-
explicitPath ??
|
|
821
|
-
(session.browserScreenshotDir
|
|
822
|
-
? path.join(
|
|
823
|
-
session.browserScreenshotDir,
|
|
824
|
-
`screenshot-${new Date().toISOString().replace(/[:.]/g, "-").slice(0, -1)}.png`,
|
|
825
|
-
)
|
|
826
|
-
: path.join(os.tmpdir(), `skc-sshots-${Snowflake.next()}.png`));
|
|
827
|
-
await fs.promises.mkdir(path.dirname(dest), { recursive: true });
|
|
828
|
-
const saveFullRes = !!(explicitPath || session.browserScreenshotDir);
|
|
851
|
+
const configuredDir = session.browserScreenshotDir;
|
|
852
|
+
const saveFullRes = !!(explicitPath || configuredDir);
|
|
829
853
|
const savedBuffer = saveFullRes ? buffer : resized.buffer;
|
|
830
854
|
const savedMimeType = saveFullRes ? "image/png" : resized.mimeType;
|
|
831
|
-
|
|
855
|
+
// Caller-chosen destinations stay as they were. Only the shared temp
|
|
856
|
+
// fallback is an exclusive private file: a preexisting symlink at the old
|
|
857
|
+
// predictable name is not opened, and the bytes are not left world-readable.
|
|
858
|
+
const dest = explicitPath
|
|
859
|
+
? explicitPath
|
|
860
|
+
: configuredDir
|
|
861
|
+
? path.join(configuredDir, `screenshot-${new Date().toISOString().replace(/[:.]/g, "-").slice(0, -1)}.png`)
|
|
862
|
+
: await writePrivateScreenshot(savedBuffer);
|
|
863
|
+
if (explicitPath || configuredDir) {
|
|
864
|
+
await fs.promises.mkdir(path.dirname(dest), { recursive: true });
|
|
865
|
+
await Bun.write(dest, savedBuffer);
|
|
866
|
+
}
|
|
832
867
|
const info: ScreenshotResult = {
|
|
833
868
|
dest,
|
|
834
869
|
mimeType: savedMimeType,
|
package/src/tools/browser.ts
CHANGED
|
@@ -4,9 +4,11 @@ import * as z from "zod/v4";
|
|
|
4
4
|
import browserDescription from "../prompts/tools/browser.md" with { type: "text" };
|
|
5
5
|
import type { ToolSession } from "../sdk";
|
|
6
6
|
import { type BrowserActionStep, compileActionSteps } from "./browser/actions";
|
|
7
|
+
import { assertLoopbackCdpUrl } from "./browser/cdp-url";
|
|
7
8
|
import { acquireBrowser, type BrowserHandle, type BrowserKind, type BrowserKindTag } from "./browser/registry";
|
|
8
|
-
import type { Observation, ScreenshotResult } from "./browser/tab-protocol";
|
|
9
|
+
import type { Observation, RunResultOk, ScreenshotResult } from "./browser/tab-protocol";
|
|
9
10
|
import { acquireTab, dropHeadlessTabs, getTab, releaseAllTabs, releaseTab, runInTab } from "./browser/tab-supervisor";
|
|
11
|
+
import { wrapUntrustedContent } from "./fetch";
|
|
10
12
|
import type { OutputMeta } from "./output-meta";
|
|
11
13
|
import { resolveToCwd } from "./path-utils";
|
|
12
14
|
import { ToolAbortError, ToolError, throwIfAborted } from "./tool-errors";
|
|
@@ -117,7 +119,13 @@ export function resolveBrowserKindForTest(params: BrowserParams, session: ToolSe
|
|
|
117
119
|
function resolveBrowserKind(params: BrowserParams, session: ToolSession): BrowserKind {
|
|
118
120
|
const app = params.app;
|
|
119
121
|
if (app?.cdp_url) {
|
|
120
|
-
|
|
122
|
+
const cdpUrl = app.cdp_url.replace(/\/+$/, "");
|
|
123
|
+
try {
|
|
124
|
+
assertLoopbackCdpUrl(cdpUrl);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
throw new ToolError(error instanceof Error ? error.message : String(error));
|
|
127
|
+
}
|
|
128
|
+
return { kind: "connected", cdpUrl };
|
|
121
129
|
}
|
|
122
130
|
if (app?.browser === "chrome") {
|
|
123
131
|
if (!app.path) throw new ToolError('app.path is required when app.browser is "chrome".');
|
|
@@ -269,8 +277,8 @@ export class BrowserTool implements AgentTool<typeof browserSchema, BrowserToolD
|
|
|
269
277
|
const verb = result.created ? "Opened" : "Reused";
|
|
270
278
|
const lines = [
|
|
271
279
|
`${verb} tab ${JSON.stringify(name)} on ${describeBrowser(browser)}`,
|
|
272
|
-
`URL: ${url}`,
|
|
273
|
-
title ? `Title: ${title}` : null,
|
|
280
|
+
`URL: ${frameBrowserPageText(url)}`,
|
|
281
|
+
title ? `Title: ${frameBrowserPageText(title)}` : null,
|
|
274
282
|
].filter((l): l is string => typeof l === "string");
|
|
275
283
|
details.result = lines.join("\n");
|
|
276
284
|
return toolResult(details).text(lines.join("\n")).done();
|
|
@@ -323,9 +331,9 @@ export class BrowserTool implements AgentTool<typeof browserSchema, BrowserToolD
|
|
|
323
331
|
|
|
324
332
|
if (screenshots.length) details.screenshots = screenshots;
|
|
325
333
|
|
|
326
|
-
const content =
|
|
334
|
+
const content = frameBrowserPageDisplays(displays);
|
|
327
335
|
if (returnValue !== undefined) {
|
|
328
|
-
content.push({ type: "text", text: stringifyReturnValue(returnValue) });
|
|
336
|
+
content.push({ type: "text", text: frameBrowserPageText(stringifyReturnValue(returnValue)) });
|
|
329
337
|
}
|
|
330
338
|
if (!content.length) {
|
|
331
339
|
content.push({ type: "text", text: `Ran code on tab ${JSON.stringify(name)}` });
|
|
@@ -373,9 +381,9 @@ export class BrowserTool implements AgentTool<typeof browserSchema, BrowserToolD
|
|
|
373
381
|
});
|
|
374
382
|
|
|
375
383
|
if (screenshots.length) details.screenshots = screenshots;
|
|
376
|
-
const content =
|
|
384
|
+
const content = frameBrowserPageDisplays(displays);
|
|
377
385
|
if (returnValue !== undefined) {
|
|
378
|
-
content.push({ type: "text", text: stringifyReturnValue(returnValue) });
|
|
386
|
+
content.push({ type: "text", text: frameBrowserPageText(stringifyReturnValue(returnValue)) });
|
|
379
387
|
}
|
|
380
388
|
if (!content.length) {
|
|
381
389
|
content.push({ type: "text", text: `Ran ${steps.length} action(s) on tab ${JSON.stringify(name)}` });
|
|
@@ -426,6 +434,15 @@ function sameBrowserKind(a: BrowserKind, b: BrowserKind): boolean {
|
|
|
426
434
|
return false;
|
|
427
435
|
}
|
|
428
436
|
|
|
437
|
+
/** Page URL, title, extract/observe text, and script return values are external content. */
|
|
438
|
+
function frameBrowserPageText(text: string): string {
|
|
439
|
+
return wrapUntrustedContent(text);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function frameBrowserPageDisplays(displays: RunResultOk["displays"]): RunResultOk["displays"] {
|
|
443
|
+
return displays.map(block => (block.type === "text" ? { ...block, text: frameBrowserPageText(block.text) } : block));
|
|
444
|
+
}
|
|
445
|
+
|
|
429
446
|
/** Max chars of a browser return value surfaced into the tool result (F22). */
|
|
430
447
|
const MAX_BROWSER_RETURN_CHARS = 256 * 1024;
|
|
431
448
|
|
package/src/tools/cron.ts
CHANGED
|
@@ -443,7 +443,16 @@ function toCronListJobDetails(snapshot: CronJobSnapshot): CronListJobDetails {
|
|
|
443
443
|
}
|
|
444
444
|
|
|
445
445
|
function formatCronFireContent(snapshot: CronJobSnapshot): string {
|
|
446
|
-
|
|
446
|
+
// A fired cron prompt is an instruction to execute, not a notification to
|
|
447
|
+
// acknowledge. Wrapping it in a notification-only envelope made models
|
|
448
|
+
// restate the prompt and end the turn without calling a tool.
|
|
449
|
+
return [
|
|
450
|
+
"<system-reminder>",
|
|
451
|
+
`Scheduled task ${snapshot.id} fired (${snapshot.humanSchedule}). The text below is this turn's task instruction: execute it now, using tools as needed. Do not merely restate, summarize, or acknowledge it.`,
|
|
452
|
+
"</system-reminder>",
|
|
453
|
+
"",
|
|
454
|
+
snapshot.prompt,
|
|
455
|
+
].join("\n");
|
|
447
456
|
}
|
|
448
457
|
|
|
449
458
|
function deliverCronFire(record: CronScheduleRecord): Promise<void> | undefined {
|
package/src/tools/debug.ts
CHANGED
|
@@ -466,8 +466,8 @@ function buildOutcomeText(outcome: DapContinueOutcome, timeoutSec: number, verb:
|
|
|
466
466
|
return lines.join("\n");
|
|
467
467
|
}
|
|
468
468
|
|
|
469
|
-
function getConfiguredAdapters(cwd: string): string {
|
|
470
|
-
const adapters = getAvailableAdapters(cwd).map(adapter => adapter.name);
|
|
469
|
+
function getConfiguredAdapters(cwd: string, trustCwds?: readonly string[]): string {
|
|
470
|
+
const adapters = getAvailableAdapters(cwd, trustCwds).map(adapter => adapter.name);
|
|
471
471
|
return adapters.length > 0 ? adapters.join(", ") : "none";
|
|
472
472
|
}
|
|
473
473
|
async function validateLaunchProgram(program: string, cwd: string): Promise<void> {
|
|
@@ -636,6 +636,7 @@ export class DebugTool implements AgentTool<typeof debugSchema, DebugToolDetails
|
|
|
636
636
|
const combinedSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
|
|
637
637
|
const details: DebugToolDetails = { action: params.action, success: true };
|
|
638
638
|
const result = toolResult(details);
|
|
639
|
+
const trustCwds = [this.session.cwd];
|
|
639
640
|
switch (params.action) {
|
|
640
641
|
case "launch": {
|
|
641
642
|
if (!params.program) {
|
|
@@ -644,14 +645,14 @@ export class DebugTool implements AgentTool<typeof debugSchema, DebugToolDetails
|
|
|
644
645
|
const commandCwd = params.cwd ? resolveToCwd(params.cwd, this.session.cwd) : this.session.cwd;
|
|
645
646
|
const program = resolveToCwd(params.program, commandCwd);
|
|
646
647
|
await validateLaunchProgram(program, commandCwd);
|
|
647
|
-
const adapter = selectLaunchAdapter(program, commandCwd, params.adapter);
|
|
648
|
+
const adapter = selectLaunchAdapter(program, commandCwd, params.adapter, trustCwds);
|
|
648
649
|
if (!adapter) {
|
|
649
650
|
throw new ToolError(
|
|
650
|
-
`No debugger adapter available. Installed adapters: ${getConfiguredAdapters(commandCwd)}`,
|
|
651
|
+
`No debugger adapter available. Installed adapters: ${getConfiguredAdapters(commandCwd, trustCwds)}`,
|
|
651
652
|
);
|
|
652
653
|
}
|
|
653
654
|
const snapshot = await dapSessionManager.launch(
|
|
654
|
-
{ adapter, program, args: params.args, cwd: commandCwd },
|
|
655
|
+
{ adapter, program, args: params.args, cwd: commandCwd, workspace: this.session.cwd },
|
|
655
656
|
combinedSignal,
|
|
656
657
|
timeoutSec * 1000,
|
|
657
658
|
);
|
|
@@ -664,14 +665,21 @@ export class DebugTool implements AgentTool<typeof debugSchema, DebugToolDetails
|
|
|
664
665
|
throw new ToolError("attach requires pid or port");
|
|
665
666
|
}
|
|
666
667
|
const commandCwd = params.cwd ? resolveToCwd(params.cwd, this.session.cwd) : this.session.cwd;
|
|
667
|
-
const adapter = selectAttachAdapter(commandCwd, params.adapter, params.port);
|
|
668
|
+
const adapter = selectAttachAdapter(commandCwd, params.adapter, params.port, trustCwds);
|
|
668
669
|
if (!adapter) {
|
|
669
670
|
throw new ToolError(
|
|
670
|
-
`No debugger adapter available. Installed adapters: ${getConfiguredAdapters(commandCwd)}`,
|
|
671
|
+
`No debugger adapter available. Installed adapters: ${getConfiguredAdapters(commandCwd, trustCwds)}`,
|
|
671
672
|
);
|
|
672
673
|
}
|
|
673
674
|
const snapshot = await dapSessionManager.attach(
|
|
674
|
-
{
|
|
675
|
+
{
|
|
676
|
+
adapter,
|
|
677
|
+
cwd: commandCwd,
|
|
678
|
+
workspace: this.session.cwd,
|
|
679
|
+
pid: params.pid,
|
|
680
|
+
port: params.port,
|
|
681
|
+
host: params.host,
|
|
682
|
+
},
|
|
675
683
|
combinedSignal,
|
|
676
684
|
timeoutSec * 1000,
|
|
677
685
|
);
|