@sayknow-cli/coding-agent 0.7.11 → 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 +10 -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 +116 -8
- 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
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
closeSync,
|
|
3
|
+
constants,
|
|
4
|
+
existsSync,
|
|
5
|
+
fchmodSync,
|
|
6
|
+
fstatSync,
|
|
7
|
+
ftruncateSync,
|
|
8
|
+
lstatSync,
|
|
9
|
+
openSync,
|
|
10
|
+
readFileSync,
|
|
11
|
+
renameSync,
|
|
12
|
+
unlinkSync,
|
|
13
|
+
writeSync,
|
|
14
|
+
} from "node:fs";
|
|
2
15
|
import * as path from "node:path";
|
|
3
16
|
import {
|
|
4
17
|
type Keybinding,
|
|
@@ -463,22 +476,156 @@ function loadRawConfig(filePath: string): unknown {
|
|
|
463
476
|
}
|
|
464
477
|
}
|
|
465
478
|
|
|
479
|
+
const KEYBINDINGS_MARKER_MODE = 0o600;
|
|
480
|
+
|
|
481
|
+
type KeybindingsLeaf = "absent" | "file" | "symlink" | "other";
|
|
482
|
+
|
|
483
|
+
function keybindingsLeaf(filePath: string): KeybindingsLeaf {
|
|
484
|
+
try {
|
|
485
|
+
const stat = lstatSync(filePath);
|
|
486
|
+
if (stat.isSymbolicLink()) return "symlink";
|
|
487
|
+
if (stat.isFile()) return "file";
|
|
488
|
+
return "other";
|
|
489
|
+
} catch (error) {
|
|
490
|
+
if (isEnoent(error)) return "absent";
|
|
491
|
+
throw error;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
function writeAllSync(fd: number, content: string | Buffer): void {
|
|
496
|
+
const buffer = typeof content === "string" ? Buffer.from(content) : content;
|
|
497
|
+
let offset = 0;
|
|
498
|
+
while (offset < buffer.length) {
|
|
499
|
+
const wrote = writeSync(fd, buffer, offset, buffer.length - offset);
|
|
500
|
+
if (wrote <= 0) throw new Error("keybindings migration write was incomplete");
|
|
501
|
+
offset += wrote;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/** Create a new file. O_NOFOLLOW refuses a final symlink. A set mode is fchmod'd. */
|
|
506
|
+
function writeExclusiveNoFollow(filePath: string, content: string | Buffer, mode: number | undefined): void {
|
|
507
|
+
const noFollow = process.platform === "win32" ? 0 : (constants.O_NOFOLLOW ?? 0);
|
|
508
|
+
const fd = openSync(filePath, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | noFollow, mode ?? 0o666);
|
|
509
|
+
try {
|
|
510
|
+
writeAllSync(fd, content);
|
|
511
|
+
if (mode !== undefined && process.platform !== "win32") fchmodSync(fd, mode);
|
|
512
|
+
} finally {
|
|
513
|
+
closeSync(fd);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/** Copy bytes to the backup. A final symlink at either path is not opened for write. */
|
|
518
|
+
function copyKeybindingsBackup(
|
|
519
|
+
source: string,
|
|
520
|
+
dest: string,
|
|
521
|
+
sourceKind: KeybindingsLeaf,
|
|
522
|
+
destKind: KeybindingsLeaf,
|
|
523
|
+
): void {
|
|
524
|
+
const noFollow = process.platform === "win32" ? 0 : (constants.O_NOFOLLOW ?? 0);
|
|
525
|
+
// A symlinked config is still backed up from its target. The backup path itself stays no-follow.
|
|
526
|
+
const sourceFlags = constants.O_RDONLY | (sourceKind === "file" ? noFollow : 0);
|
|
527
|
+
const srcFd = openSync(source, sourceFlags);
|
|
528
|
+
try {
|
|
529
|
+
const stat = fstatSync(srcFd);
|
|
530
|
+
if (!stat.isFile()) throw new Error("keybindings migration target is not a regular file");
|
|
531
|
+
const bytes = readFileSync(srcFd);
|
|
532
|
+
const mode = stat.mode & 0o777;
|
|
533
|
+
if (destKind === "absent") {
|
|
534
|
+
writeExclusiveNoFollow(dest, bytes, mode);
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
const fd = openSync(dest, constants.O_WRONLY | noFollow);
|
|
538
|
+
try {
|
|
539
|
+
const destStat = fstatSync(fd);
|
|
540
|
+
if (!destStat.isFile()) throw new Error("keybindings migration target is not a regular file");
|
|
541
|
+
if (destStat.dev === stat.dev && destStat.ino === stat.ino) return;
|
|
542
|
+
ftruncateSync(fd, 0);
|
|
543
|
+
writeAllSync(fd, bytes);
|
|
544
|
+
if (process.platform !== "win32") fchmodSync(fd, mode);
|
|
545
|
+
} finally {
|
|
546
|
+
closeSync(fd);
|
|
547
|
+
}
|
|
548
|
+
} finally {
|
|
549
|
+
closeSync(srcFd);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
function migrationMarkerState(markerPath: string): { present: boolean; kind: KeybindingsLeaf } {
|
|
554
|
+
const kind = keybindingsLeaf(markerPath);
|
|
555
|
+
// A symlink is not a completed marker. existsSync only preserves the historical
|
|
556
|
+
// skip when that link already names a real target. The write path never opens it.
|
|
557
|
+
const present = kind === "file" || kind === "other" || (kind === "symlink" && existsSync(markerPath));
|
|
558
|
+
return { present, kind };
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function writeMigratedKeybindings(
|
|
562
|
+
filePath: string,
|
|
563
|
+
markerPath: string,
|
|
564
|
+
markerKind: KeybindingsLeaf,
|
|
565
|
+
body: string,
|
|
566
|
+
): void {
|
|
567
|
+
const tempPath = `${filePath}.${process.pid}.tmp`;
|
|
568
|
+
const bakPath = `${filePath}.bak`;
|
|
569
|
+
const bakKind = keybindingsLeaf(bakPath);
|
|
570
|
+
const tempKind = keybindingsLeaf(tempPath);
|
|
571
|
+
const sourceKind = keybindingsLeaf(filePath);
|
|
572
|
+
if (
|
|
573
|
+
bakKind === "symlink" ||
|
|
574
|
+
bakKind === "other" ||
|
|
575
|
+
tempKind === "symlink" ||
|
|
576
|
+
tempKind === "other" ||
|
|
577
|
+
(sourceKind !== "file" && sourceKind !== "symlink")
|
|
578
|
+
) {
|
|
579
|
+
throw new Error("keybindings migration target is not a regular file");
|
|
580
|
+
}
|
|
581
|
+
if (tempKind === "file") unlinkSync(tempPath);
|
|
582
|
+
if (keybindingsLeaf(filePath) !== sourceKind) {
|
|
583
|
+
throw new Error("keybindings migration target is not a regular file");
|
|
584
|
+
}
|
|
585
|
+
const mode = sourceKind === "file" ? lstatSync(filePath).mode & 0o777 : undefined;
|
|
586
|
+
try {
|
|
587
|
+
copyKeybindingsBackup(filePath, bakPath, sourceKind, bakKind);
|
|
588
|
+
writeExclusiveNoFollow(tempPath, body, mode);
|
|
589
|
+
const current = lstatSync(filePath);
|
|
590
|
+
if (sourceKind === "file" && (current.isSymbolicLink() || !current.isFile())) {
|
|
591
|
+
throw new Error("keybindings migration target is not a regular file");
|
|
592
|
+
}
|
|
593
|
+
renameSync(tempPath, filePath);
|
|
594
|
+
if (markerKind === "absent") writeExclusiveNoFollow(markerPath, "v1\n", KEYBINDINGS_MARKER_MODE);
|
|
595
|
+
} catch (error) {
|
|
596
|
+
if (keybindingsLeaf(tempPath) === "file") {
|
|
597
|
+
try {
|
|
598
|
+
unlinkSync(tempPath);
|
|
599
|
+
} catch {
|
|
600
|
+
// Best-effort removal of the unreplaced temp file.
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
throw error;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
466
607
|
/** Migrate legacy keybindings once, preserving the original file as .bak. */
|
|
467
608
|
function loadKeybindingsConfig(filePath: string, writeBack: boolean): KeybindingsConfig {
|
|
468
609
|
const rawConfig = loadRawConfig(filePath);
|
|
469
610
|
if (rawConfig === null) return {};
|
|
470
611
|
const markerPath = `${filePath}.migration-v1`;
|
|
471
|
-
|
|
612
|
+
let markerKind: KeybindingsLeaf = "absent";
|
|
613
|
+
let markerPresent = false;
|
|
614
|
+
try {
|
|
615
|
+
const marker = migrationMarkerState(markerPath);
|
|
616
|
+
markerKind = marker.kind;
|
|
617
|
+
markerPresent = marker.present;
|
|
618
|
+
} catch (error) {
|
|
619
|
+
logger.warn("Failed to read keybindings migration marker", { path: markerPath, error: String(error) });
|
|
620
|
+
return toKeybindingsConfig(rawConfig);
|
|
621
|
+
}
|
|
622
|
+
const { config: migratedConfig, migrated } = markerPresent
|
|
472
623
|
? { config: toKeybindingsConfig(rawConfig), migrated: false }
|
|
473
624
|
: migrateKeybindingNames(rawConfig);
|
|
474
625
|
if (writeBack && migrated) {
|
|
475
626
|
const ordered = orderKeybindingsConfig(migratedConfig);
|
|
476
|
-
const tempPath = `${filePath}.${process.pid}.tmp`;
|
|
477
627
|
try {
|
|
478
|
-
|
|
479
|
-
writeFileSync(tempPath, `${JSON.stringify(ordered, null, 2)}\n`, "utf-8");
|
|
480
|
-
renameSync(tempPath, filePath);
|
|
481
|
-
writeFileSync(markerPath, "v1\n", "utf-8");
|
|
628
|
+
writeMigratedKeybindings(filePath, markerPath, markerKind, `${JSON.stringify(ordered, null, 2)}\n`);
|
|
482
629
|
logger.debug("Migrated keybindings config", { path: filePath });
|
|
483
630
|
} catch (error) {
|
|
484
631
|
logger.warn("Failed to write migrated keybindings config", { path: filePath, error: String(error) });
|
|
@@ -182,6 +182,10 @@
|
|
|
182
182
|
"headers": {
|
|
183
183
|
"$ref": "#/$defs/stringMap",
|
|
184
184
|
"description": "HTTP headers sent with MCP requests. Public CLI output redacts values."
|
|
185
|
+
},
|
|
186
|
+
"publicNetwork": {
|
|
187
|
+
"type": "boolean",
|
|
188
|
+
"description": "When true, MCP HTTP requests and redirects must stay on public addresses."
|
|
185
189
|
}
|
|
186
190
|
},
|
|
187
191
|
"not": {
|
|
@@ -41,6 +41,7 @@ import { $pickCredentialEnv, isRecord, logger } from "@sayknow-cli/utils";
|
|
|
41
41
|
import { parseModelString, resolveProviderModelReference } from "../config/model-resolver";
|
|
42
42
|
import { isValidThemeColor, type ThemeColor } from "../modes/theme/theme";
|
|
43
43
|
import type { AuthStorage, OAuthCredential } from "../session/auth-storage";
|
|
44
|
+
import { writeExplicitOwnerOnlyTextSync } from "../session/session-storage";
|
|
44
45
|
import type { ActiveSearchModelContext, WebSearchMode } from "../web/search/types";
|
|
45
46
|
import { type ConfigError, ConfigFile } from "./config-file";
|
|
46
47
|
import {
|
|
@@ -1787,8 +1788,15 @@ export class ModelRegistry {
|
|
|
1787
1788
|
}
|
|
1788
1789
|
|
|
1789
1790
|
async #writeCheckedModelsConfig(config: ModelsConfig): Promise<void> {
|
|
1790
|
-
|
|
1791
|
-
|
|
1791
|
+
const configPath = this.#modelsConfigFile.path();
|
|
1792
|
+
const parentPath = path.dirname(configPath);
|
|
1793
|
+
await fs.mkdir(parentPath, { recursive: true, mode: 0o700 });
|
|
1794
|
+
// The owner-only writer rejects a symlink in any path component and rejects
|
|
1795
|
+
// "..". Resolve only the parent so an alias directory and a lexical ".."
|
|
1796
|
+
// still reach the same file. The final name stays lexical, so a symlink
|
|
1797
|
+
// at models.yml is still opened with O_NOFOLLOW.
|
|
1798
|
+
const parent = await fs.realpath(parentPath);
|
|
1799
|
+
writeExplicitOwnerOnlyTextSync(path.join(parent, path.basename(configPath)), Bun.YAML.stringify(config, null, 2));
|
|
1792
1800
|
this.#modelsConfigFile.invalidate();
|
|
1793
1801
|
this.#reloadStaticModels();
|
|
1794
1802
|
}
|
|
@@ -2509,6 +2509,12 @@ export const SETTINGS_SCHEMA = {
|
|
|
2509
2509
|
type: "string",
|
|
2510
2510
|
default: undefined,
|
|
2511
2511
|
},
|
|
2512
|
+
// xxHash64 hex pin for settingsPath. Only the user/global value is a pin;
|
|
2513
|
+
// a project file cannot authorize the TOML path it names.
|
|
2514
|
+
"shellMinimizer.settingsHash": {
|
|
2515
|
+
type: "string",
|
|
2516
|
+
default: undefined,
|
|
2517
|
+
},
|
|
2512
2518
|
"shellMinimizer.only": { type: "array", default: EMPTY_STRING_ARRAY },
|
|
2513
2519
|
"shellMinimizer.except": { type: "array", default: EMPTY_STRING_ARRAY },
|
|
2514
2520
|
"shellMinimizer.maxCaptureBytes": {
|
|
@@ -2783,6 +2789,17 @@ export const SETTINGS_SCHEMA = {
|
|
|
2783
2789
|
},
|
|
2784
2790
|
},
|
|
2785
2791
|
|
|
2792
|
+
"reverseEngineer.enabled": {
|
|
2793
|
+
type: "boolean",
|
|
2794
|
+
default: true,
|
|
2795
|
+
ui: {
|
|
2796
|
+
tab: "tools",
|
|
2797
|
+
label: "Reverse Engineer (REA)",
|
|
2798
|
+
description:
|
|
2799
|
+
"Enable the reverse_engineer tool (REA via npx/bunx) for building something modeled on a user-supplied link, app, or binary",
|
|
2800
|
+
},
|
|
2801
|
+
},
|
|
2802
|
+
|
|
2786
2803
|
"github.cache.enabled": {
|
|
2787
2804
|
type: "boolean",
|
|
2788
2805
|
default: true,
|
|
@@ -4399,6 +4416,7 @@ export interface BashInterceptorRule {
|
|
|
4399
4416
|
export interface ShellMinimizerSettings {
|
|
4400
4417
|
enabled: boolean;
|
|
4401
4418
|
settingsPath: string | undefined;
|
|
4419
|
+
settingsHash: string | undefined;
|
|
4402
4420
|
only: string[];
|
|
4403
4421
|
except: string[];
|
|
4404
4422
|
maxCaptureBytes: number;
|
package/src/config/settings.ts
CHANGED
|
@@ -184,6 +184,15 @@ function getByPath(obj: RawSettings, segments: string[]): unknown {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
const PATH_SCOPED_ARRAY_SETTINGS = new Set<SettingPath>(["enabledModels", "disabledProviders"]);
|
|
187
|
+
/** Operator-owned settings which a project settings file must never control. */
|
|
188
|
+
const GLOBAL_ONLY_SETTINGS = new Set<SettingPath>([
|
|
189
|
+
// Destination of the operator Hindsight server. A project file must not redirect it.
|
|
190
|
+
"hindsight.apiUrl",
|
|
191
|
+
// Destination of generic remote compaction. A project file must not redirect the transcript POST.
|
|
192
|
+
"compaction.remoteEndpoint",
|
|
193
|
+
// Operator consent for repository skills. A project file must not flip it.
|
|
194
|
+
"skills.enablePiProject",
|
|
195
|
+
]);
|
|
187
196
|
const LEGACY_THEME_NAME_REPLACEMENTS = {
|
|
188
197
|
dark: "blue-octopus",
|
|
189
198
|
light: "blue-octopus",
|
|
@@ -810,6 +819,14 @@ export class Settings implements NotificationSettingsReader {
|
|
|
810
819
|
this.#rebuildMerged();
|
|
811
820
|
}
|
|
812
821
|
|
|
822
|
+
/**
|
|
823
|
+
* Get a runtime override value only (not persisted; excludes user and project files).
|
|
824
|
+
*/
|
|
825
|
+
getOverride<P extends SettingPath>(path: P): SettingValue<P> | undefined {
|
|
826
|
+
const value = getByPath(this.#overrides, path.split("."));
|
|
827
|
+
return value === undefined ? undefined : (value as SettingValue<P>);
|
|
828
|
+
}
|
|
829
|
+
|
|
813
830
|
/**
|
|
814
831
|
* Clear a runtime override.
|
|
815
832
|
*/
|
|
@@ -941,10 +958,12 @@ export class Settings implements NotificationSettingsReader {
|
|
|
941
958
|
}
|
|
942
959
|
|
|
943
960
|
/**
|
|
944
|
-
*
|
|
961
|
+
* Shell configuration for bash and the Python executor.
|
|
962
|
+
* `shellPath` comes from the user/global config only, so a project
|
|
963
|
+
* `.skc/settings.json` cannot select the binary those executors run.
|
|
945
964
|
*/
|
|
946
965
|
getShellConfig() {
|
|
947
|
-
const shell = this.
|
|
966
|
+
const shell = this.getGlobal("shellPath");
|
|
948
967
|
return procmgr.getShellConfig(shell);
|
|
949
968
|
}
|
|
950
969
|
|
|
@@ -1995,8 +2014,17 @@ export class Settings implements NotificationSettingsReader {
|
|
|
1995
2014
|
}
|
|
1996
2015
|
}
|
|
1997
2016
|
#rebuildMerged(): void {
|
|
1998
|
-
|
|
1999
|
-
|
|
2017
|
+
// Global-only destinations come from the operator's user layer; neither a
|
|
2018
|
+
// project file nor a runtime override may redirect them.
|
|
2019
|
+
const project = structuredClone(this.#project);
|
|
2020
|
+
const overrides = structuredClone(this.#overrides);
|
|
2021
|
+
for (const settingPath of GLOBAL_ONLY_SETTINGS) {
|
|
2022
|
+
const segments = settingPath.split(".");
|
|
2023
|
+
deleteByPath(project, segments);
|
|
2024
|
+
deleteByPath(overrides, segments);
|
|
2025
|
+
}
|
|
2026
|
+
this.#merged = this.#deepMerge(this.#deepMerge({}, this.#global), project);
|
|
2027
|
+
this.#merged = this.#deepMerge(this.#merged, overrides);
|
|
2000
2028
|
}
|
|
2001
2029
|
|
|
2002
2030
|
#fireAllHooks(): void {
|
|
@@ -72,9 +72,19 @@ const LEGACY_MUTATION_CLASS_ALIASES = new Map<string, CoordinatorMutationClass>(
|
|
|
72
72
|
["report", "reports"],
|
|
73
73
|
]);
|
|
74
74
|
|
|
75
|
+
// Number.parseInt reads a leading digit prefix ("64KB" -> 64, "1e6" -> 1,
|
|
76
|
+
// "1.5" -> 1), which would silently shrink a cap or TTL to a tiny value. Only
|
|
77
|
+
// plain decimal digits count; anything else falls back to the default.
|
|
78
|
+
function parsePositiveInt(value: string | undefined): number | undefined {
|
|
79
|
+
const trimmed = (value ?? "").trim();
|
|
80
|
+
if (!/^\d+$/.test(trimmed)) return undefined;
|
|
81
|
+
const parsed = Number.parseInt(trimmed, 10);
|
|
82
|
+
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : undefined;
|
|
83
|
+
}
|
|
84
|
+
|
|
75
85
|
function parsePositiveIntMs(value: string | undefined, fallback: number, floor: number): number {
|
|
76
|
-
const parsed =
|
|
77
|
-
if (
|
|
86
|
+
const parsed = parsePositiveInt(value);
|
|
87
|
+
if (parsed === undefined) return fallback;
|
|
78
88
|
return Math.max(floor, parsed);
|
|
79
89
|
}
|
|
80
90
|
|
|
@@ -113,8 +123,8 @@ function parseMutationClasses(value: string | undefined): Set<CoordinatorMutatio
|
|
|
113
123
|
}
|
|
114
124
|
|
|
115
125
|
function parseByteCap(value: string | undefined): number {
|
|
116
|
-
const parsed =
|
|
117
|
-
if (
|
|
126
|
+
const parsed = parsePositiveInt(value);
|
|
127
|
+
if (parsed === undefined) return DEFAULT_ARTIFACT_BYTE_CAP;
|
|
118
128
|
return Math.min(parsed, MAX_ARTIFACT_BYTE_CAP);
|
|
119
129
|
}
|
|
120
130
|
|
|
@@ -85,6 +85,13 @@ interface JsonRpcResponse {
|
|
|
85
85
|
error?: { code: number; message: string; data?: unknown };
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
function artifactRejectionReason(error: unknown): string | undefined {
|
|
89
|
+
if (!(error instanceof Error)) return undefined;
|
|
90
|
+
if (error.message.startsWith("coordinator_artifact_outside_allowed_roots:")) return "artifact_outside_allowed_roots";
|
|
91
|
+
if (error.message === "coordinator_artifact_state_root_denied") return "artifact_state_root_denied";
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
88
95
|
function sinkErrorCode(error: unknown): string | undefined {
|
|
89
96
|
if (error === null || (typeof error !== "object" && typeof error !== "function")) return undefined;
|
|
90
97
|
try {
|
|
@@ -1177,8 +1184,20 @@ async function readCoordinatorEvents(namespaceDir: string): Promise<CoordinatorE
|
|
|
1177
1184
|
}
|
|
1178
1185
|
}
|
|
1179
1186
|
|
|
1187
|
+
// Tool arguments and env values arrive untyped. `Number.parseInt(String(v))`
|
|
1188
|
+
// reads a leading digit prefix ("1e4" -> 1, "5s" -> 5) and flattens arrays
|
|
1189
|
+
// ([50] -> "50"), so a malformed value silently became a 1 ms timeout or a
|
|
1190
|
+
// one-row limit. Numbers pass through; strings must be plain decimal digits;
|
|
1191
|
+
// anything else is NaN so each caller falls back to its default.
|
|
1192
|
+
function integerArg(value: unknown): number {
|
|
1193
|
+
if (typeof value === "number") return value;
|
|
1194
|
+
if (typeof value !== "string") return Number.NaN;
|
|
1195
|
+
const trimmed = value.trim();
|
|
1196
|
+
return /^\d+$/.test(trimmed) ? Number.parseInt(trimmed, 10) : Number.NaN;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1180
1199
|
function boundedEventLimit(value: unknown): number {
|
|
1181
|
-
const parsed =
|
|
1200
|
+
const parsed = integerArg(value);
|
|
1182
1201
|
if (!Number.isFinite(parsed) || parsed <= 0) return 100;
|
|
1183
1202
|
return Math.min(parsed, 100);
|
|
1184
1203
|
}
|
|
@@ -1764,7 +1783,7 @@ export const COORDINATOR_EVENT_WATCH_TIMEOUT_MAX_MS = 30_000;
|
|
|
1764
1783
|
export const COORDINATOR_POLL_INTERVAL_MAX_MS = 10_000;
|
|
1765
1784
|
|
|
1766
1785
|
function parsePositiveIntegerMs(value: unknown, fallback: number): number {
|
|
1767
|
-
const parsed =
|
|
1786
|
+
const parsed = integerArg(value);
|
|
1768
1787
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
1769
1788
|
}
|
|
1770
1789
|
|
|
@@ -1788,7 +1807,7 @@ export function boundedPollIntervalMs(value: unknown): number {
|
|
|
1788
1807
|
}
|
|
1789
1808
|
|
|
1790
1809
|
function boundedLineCount(value: unknown): number {
|
|
1791
|
-
const parsed =
|
|
1810
|
+
const parsed = integerArg(value);
|
|
1792
1811
|
if (!Number.isFinite(parsed) || parsed <= 0) return 80;
|
|
1793
1812
|
return Math.min(parsed, 400);
|
|
1794
1813
|
}
|
|
@@ -2493,7 +2512,20 @@ export function createCoordinatorMcpServer(options: CoordinatorMcpServerOptions
|
|
|
2493
2512
|
}
|
|
2494
2513
|
|
|
2495
2514
|
async function queryLastAssistant(session: Record<string, unknown>): Promise<string | null> {
|
|
2496
|
-
|
|
2515
|
+
let item: unknown;
|
|
2516
|
+
try {
|
|
2517
|
+
item = sdkQueryPageItem(await querySession(session, "session.last_assistant"), "session.last_assistant");
|
|
2518
|
+
} catch (error) {
|
|
2519
|
+
// Compatibility with running older hosts: this exact Q17 diagnostic
|
|
2520
|
+
// denotes an absent text payload, not a missing session or closed store.
|
|
2521
|
+
if (
|
|
2522
|
+
error instanceof SdkClientError &&
|
|
2523
|
+
error.code === "resource_gone" &&
|
|
2524
|
+
error.message === "snapshot payload is unavailable"
|
|
2525
|
+
)
|
|
2526
|
+
return null;
|
|
2527
|
+
throw error;
|
|
2528
|
+
}
|
|
2497
2529
|
if (typeof item === "string") return item;
|
|
2498
2530
|
const message = asRecord(item);
|
|
2499
2531
|
return typeof message?.text === "string"
|
|
@@ -4746,6 +4778,14 @@ export function createCoordinatorMcpServer(options: CoordinatorMcpServerOptions
|
|
|
4746
4778
|
return { ok: false, reason: "unknown_tool", tool: name };
|
|
4747
4779
|
} catch (error) {
|
|
4748
4780
|
if (error instanceof SdkClientError) return sdkError(error);
|
|
4781
|
+
const artifactReason = artifactRejectionReason(error);
|
|
4782
|
+
// Evidence-root rejections are caller input errors; the denied path stays private.
|
|
4783
|
+
if (artifactReason)
|
|
4784
|
+
return {
|
|
4785
|
+
ok: false,
|
|
4786
|
+
reason: artifactReason,
|
|
4787
|
+
error: { code: "invalid_input", message: "Coordinator request input is invalid." },
|
|
4788
|
+
};
|
|
4749
4789
|
return { ok: false, reason: error instanceof Error ? error.message : String(error) };
|
|
4750
4790
|
}
|
|
4751
4791
|
}
|
|
@@ -21,6 +21,11 @@ export const DEFAULT_SESSION_IDLE_TTL_MS = 30 * 60_000; // 30 min idle → reap
|
|
|
21
21
|
export const DEFAULT_SESSION_SWEEP_INTERVAL_MS = 5 * 60_000; // sweep every 5 min
|
|
22
22
|
export const MIN_SESSION_IDLE_TTL_MS = 60_000; // never reap a <1min-idle session
|
|
23
23
|
export const MIN_SESSION_SWEEP_INTERVAL_MS = 30_000;
|
|
24
|
+
/**
|
|
25
|
+
* Longest delay setTimeout honors. Bun, like Node, treats any larger delay as 1 ms,
|
|
26
|
+
* so an operator's very long sweep interval would otherwise re-sweep back to back.
|
|
27
|
+
*/
|
|
28
|
+
export const MAX_SESSION_SWEEP_INTERVAL_MS = 2 ** 31 - 1;
|
|
24
29
|
|
|
25
30
|
/** Minimal projection of a coordinator session the reaper needs to decide. */
|
|
26
31
|
export interface ReapableSession {
|
|
@@ -68,7 +73,10 @@ export interface SessionReaper {
|
|
|
68
73
|
|
|
69
74
|
export function createSessionReaper(deps: SessionReaperDeps, policy: SessionReaperPolicy): SessionReaper {
|
|
70
75
|
const idleTtlMs = Math.max(MIN_SESSION_IDLE_TTL_MS, policy.idleTtlMs);
|
|
71
|
-
const sweepIntervalMs = Math.
|
|
76
|
+
const sweepIntervalMs = Math.min(
|
|
77
|
+
MAX_SESSION_SWEEP_INTERVAL_MS,
|
|
78
|
+
Math.max(MIN_SESSION_SWEEP_INTERVAL_MS, policy.sweepIntervalMs),
|
|
79
|
+
);
|
|
72
80
|
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
73
81
|
let generation = 0;
|
|
74
82
|
let inProgress = false;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export async function assertDeleteInsideWorkspace(cwd: string, filePath: string): Promise<void> {
|
|
5
|
+
const root = await fs.realpath(cwd);
|
|
6
|
+
const target = await fs.realpath(filePath);
|
|
7
|
+
if (target !== root && !target.startsWith(`${root}${path.sep}`)) {
|
|
8
|
+
throw new Error(`Delete escapes the workspace: ${filePath}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tools Cursor already runs on a dedicated exec channel.
|
|
3
|
+
* Keep this aligned with CURSOR_NATIVE_TOOL_NAMES in packages/ai/src/providers/cursor.ts.
|
|
4
|
+
*/
|
|
5
|
+
const CURSOR_DEDICATED_CHANNEL_TOOLS = new Set(["bash", "read", "write", "delete", "ls", "grep", "lsp", "todo_write"]);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Name to dispatch from a Cursor MCP call.
|
|
9
|
+
* Dedicated-channel tools are refused here. Advertised session tools such as eval stay allowed.
|
|
10
|
+
*/
|
|
11
|
+
export function cursorMcpDispatchName(call: { toolName?: string; name?: string }): string | null {
|
|
12
|
+
const toolName = call.toolName || call.name || "";
|
|
13
|
+
if (toolName.length === 0 || CURSOR_DEDICATED_CHANNEL_TOOLS.has(toolName)) return null;
|
|
14
|
+
return toolName;
|
|
15
|
+
}
|
package/src/cursor.ts
CHANGED
|
@@ -14,6 +14,8 @@ import type {
|
|
|
14
14
|
ToolResultMessage,
|
|
15
15
|
} from "@sayknow-cli/ai";
|
|
16
16
|
import { sanitizeText } from "@sayknow-cli/utils";
|
|
17
|
+
import { assertDeleteInsideWorkspace } from "./cursor-delete-path";
|
|
18
|
+
import { cursorMcpDispatchName } from "./cursor-mcp-name";
|
|
17
19
|
import { resolveToCwd } from "./tools/path-utils";
|
|
18
20
|
|
|
19
21
|
interface CursorExecBridgeOptions {
|
|
@@ -123,6 +125,7 @@ async function executeDelete(options: CursorExecBridgeOptions, pathArg: string,
|
|
|
123
125
|
throw new Error(`Path is not a file: ${pathArg}`);
|
|
124
126
|
}
|
|
125
127
|
|
|
128
|
+
await assertDeleteInsideWorkspace(options.cwd, absolutePath);
|
|
126
129
|
fs.rmSync(absolutePath);
|
|
127
130
|
|
|
128
131
|
const sizeText = fileStat.size ? ` (${fileStat.size} bytes)` : "";
|
|
@@ -375,11 +378,19 @@ export class CursorExecHandlers implements ICursorExecHandlers {
|
|
|
375
378
|
|
|
376
379
|
async mcp(call: CursorMcpCall) {
|
|
377
380
|
const options = this.#optionsForCall();
|
|
378
|
-
const
|
|
381
|
+
const requestedName = call.toolName || call.name || "";
|
|
382
|
+
const toolName = cursorMcpDispatchName(call);
|
|
379
383
|
const toolCallId = decodeToolCallId(call.toolCallId);
|
|
384
|
+
const availableTools = Array.from(options.tools.keys()).filter(
|
|
385
|
+
name => cursorMcpDispatchName({ toolName: name }) !== null,
|
|
386
|
+
);
|
|
387
|
+
if (!toolName) {
|
|
388
|
+
const message = formatMcpToolErrorMessage(requestedName, availableTools);
|
|
389
|
+
const result = buildToolErrorResult(message);
|
|
390
|
+
return createToolResultMessage(toolCallId, requestedName || "mcp", result, true);
|
|
391
|
+
}
|
|
380
392
|
const tool = options.tools.get(toolName);
|
|
381
393
|
if (!tool) {
|
|
382
|
-
const availableTools = Array.from(options.tools.keys()).filter(name => name.startsWith("mcp__"));
|
|
383
394
|
const message = formatMcpToolErrorMessage(toolName, availableTools);
|
|
384
395
|
const result = buildToolErrorResult(message);
|
|
385
396
|
return createToolResultMessage(toolCallId, toolName, result, true);
|
package/src/dap/client.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import { isKnownSinkPeerClosedError, logger } from "@sayknow-cli/utils";
|
|
4
|
+
import { projectSafeSpawnEnv } from "@sayknow-cli/utils/shell-config";
|
|
4
5
|
import { formatCrashDiagnosticNotice, writeCrashReport } from "../debug/crash-diagnostics";
|
|
5
6
|
import { NON_INTERACTIVE_ENV } from "../exec/non-interactive-env";
|
|
6
7
|
import { type OwnedProcess, spawnOwnedProcess } from "../runtime/process-lifecycle";
|
|
@@ -143,7 +144,7 @@ export class DapClient {
|
|
|
143
144
|
// debuggee children can reach /dev/tty and trigger SIGTTIN, suspending
|
|
144
145
|
// the parent harness under shell job control.
|
|
145
146
|
const env = {
|
|
146
|
-
...
|
|
147
|
+
...projectSafeSpawnEnv(),
|
|
147
148
|
...NON_INTERACTIVE_ENV,
|
|
148
149
|
};
|
|
149
150
|
const owner = spawnOwnedProcess([adapter.resolvedCommand, ...adapter.args], {
|
|
@@ -168,7 +169,7 @@ export class DapClient {
|
|
|
168
169
|
*/
|
|
169
170
|
static async #spawnSocket({ adapter, cwd }: DapSpawnOptions): Promise<DapClient> {
|
|
170
171
|
const env = {
|
|
171
|
-
...
|
|
172
|
+
...projectSafeSpawnEnv(),
|
|
172
173
|
...NON_INTERACTIVE_ENV,
|
|
173
174
|
};
|
|
174
175
|
const isLinux = process.platform === "linux";
|
|
@@ -343,6 +344,8 @@ export class DapClient {
|
|
|
343
344
|
throw signal.reason instanceof Error ? signal.reason : new ToolAbortError();
|
|
344
345
|
}
|
|
345
346
|
const { promise, resolve, reject } = Promise.withResolvers<TBody>();
|
|
347
|
+
// A transport close can reject this before the caller awaits it; the caller still observes the rejection.
|
|
348
|
+
void promise.catch(() => {});
|
|
346
349
|
let timeout: NodeJS.Timeout | undefined;
|
|
347
350
|
const cleanup = () => {
|
|
348
351
|
unsubscribe();
|
|
@@ -394,6 +397,10 @@ export class DapClient {
|
|
|
394
397
|
arguments: args,
|
|
395
398
|
};
|
|
396
399
|
const { promise, resolve, reject } = Promise.withResolvers<TBody>();
|
|
400
|
+
// The readable side can close (rejecting every pending request) while the write below is still awaited,
|
|
401
|
+
// before this promise is returned to a caller. Mark it handled so that rejection is not reported as
|
|
402
|
+
// unhandled; the caller still observes it when it awaits the returned promise.
|
|
403
|
+
void promise.catch(() => {});
|
|
397
404
|
let timeout: NodeJS.Timeout | undefined;
|
|
398
405
|
const cleanup = () => {
|
|
399
406
|
if (timeout) clearTimeout(timeout);
|
package/src/dap/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
2
|
import { isRecord } from "@sayknow-cli/utils";
|
|
3
|
-
import { hasRootMarkers,
|
|
3
|
+
import { hasRootMarkers, resolveTrustedCommand } from "../lsp/config";
|
|
4
|
+
import { isProjectControlledPath } from "../lsp/path-trust";
|
|
4
5
|
import DEFAULTS from "./defaults.json" with { type: "json" };
|
|
5
6
|
import type { DapAdapterConfig, DapResolvedAdapter } from "./types";
|
|
6
7
|
|
|
@@ -48,11 +49,20 @@ export function getAdapterConfigs(): Record<string, DapAdapterConfig> {
|
|
|
48
49
|
return { ...DEFAULT_ADAPTERS };
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
/**
|
|
53
|
+
* `trustCwds` are extra trust roots, such as the session workspace when the command
|
|
54
|
+
* cwd is a different directory. A command controlled by any of them is refused.
|
|
55
|
+
*/
|
|
56
|
+
export function resolveAdapter(
|
|
57
|
+
adapterName: string,
|
|
58
|
+
cwd: string,
|
|
59
|
+
trustCwds?: readonly string[],
|
|
60
|
+
): DapResolvedAdapter | null {
|
|
52
61
|
const config = DEFAULT_ADAPTERS[adapterName];
|
|
53
62
|
if (!config) return null;
|
|
54
|
-
const resolvedCommand =
|
|
63
|
+
const resolvedCommand = resolveTrustedCommand(config.command, cwd);
|
|
55
64
|
if (!resolvedCommand) return null;
|
|
65
|
+
if (trustCwds?.some(root => isProjectControlledPath(resolvedCommand, root))) return null;
|
|
56
66
|
return {
|
|
57
67
|
name: adapterName,
|
|
58
68
|
command: config.command,
|
|
@@ -67,15 +77,15 @@ export function resolveAdapter(adapterName: string, cwd: string): DapResolvedAda
|
|
|
67
77
|
};
|
|
68
78
|
}
|
|
69
79
|
|
|
70
|
-
export function getAvailableAdapters(cwd: string): DapResolvedAdapter[] {
|
|
80
|
+
export function getAvailableAdapters(cwd: string, trustCwds?: readonly string[]): DapResolvedAdapter[] {
|
|
71
81
|
return Object.keys(DEFAULT_ADAPTERS)
|
|
72
|
-
.map(name => resolveAdapter(name, cwd))
|
|
82
|
+
.map(name => resolveAdapter(name, cwd, trustCwds))
|
|
73
83
|
.filter((adapter): adapter is DapResolvedAdapter => adapter !== null);
|
|
74
84
|
}
|
|
75
85
|
|
|
76
|
-
function getMatchingAdapters(program: string, cwd: string): DapResolvedAdapter[] {
|
|
86
|
+
function getMatchingAdapters(program: string, cwd: string, trustCwds?: readonly string[]): DapResolvedAdapter[] {
|
|
77
87
|
const extension = path.extname(program).toLowerCase();
|
|
78
|
-
const available = getAvailableAdapters(cwd);
|
|
88
|
+
const available = getAvailableAdapters(cwd, trustCwds);
|
|
79
89
|
if (!extension) {
|
|
80
90
|
// For extensionless binaries, only consider native debuggers (gdb, lldb-dap)
|
|
81
91
|
// or adapters that match by root markers. Don't silently fall back to
|
|
@@ -124,20 +134,30 @@ function sortAdaptersForLaunch(program: string, cwd: string, adapters: DapResolv
|
|
|
124
134
|
return rootAware.map(entry => entry.adapter);
|
|
125
135
|
}
|
|
126
136
|
|
|
127
|
-
export function selectLaunchAdapter(
|
|
137
|
+
export function selectLaunchAdapter(
|
|
138
|
+
program: string,
|
|
139
|
+
cwd: string,
|
|
140
|
+
adapterName?: string,
|
|
141
|
+
trustCwds?: readonly string[],
|
|
142
|
+
): DapResolvedAdapter | null {
|
|
128
143
|
if (adapterName) {
|
|
129
|
-
return resolveAdapter(adapterName, cwd);
|
|
144
|
+
return resolveAdapter(adapterName, cwd, trustCwds);
|
|
130
145
|
}
|
|
131
|
-
const matches = getMatchingAdapters(program, cwd);
|
|
146
|
+
const matches = getMatchingAdapters(program, cwd, trustCwds);
|
|
132
147
|
const sorted = sortAdaptersForLaunch(program, cwd, matches);
|
|
133
148
|
return sorted[0] ?? null;
|
|
134
149
|
}
|
|
135
150
|
|
|
136
|
-
export function selectAttachAdapter(
|
|
151
|
+
export function selectAttachAdapter(
|
|
152
|
+
cwd: string,
|
|
153
|
+
adapterName?: string,
|
|
154
|
+
port?: number,
|
|
155
|
+
trustCwds?: readonly string[],
|
|
156
|
+
): DapResolvedAdapter | null {
|
|
137
157
|
if (adapterName) {
|
|
138
|
-
return resolveAdapter(adapterName, cwd);
|
|
158
|
+
return resolveAdapter(adapterName, cwd, trustCwds);
|
|
139
159
|
}
|
|
140
|
-
const available = getAvailableAdapters(cwd);
|
|
160
|
+
const available = getAvailableAdapters(cwd, trustCwds);
|
|
141
161
|
if (port !== undefined) {
|
|
142
162
|
const debugpy = available.find(adapter => adapter.name === "debugpy");
|
|
143
163
|
if (debugpy) return debugpy;
|