@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
package/src/utils/open.ts
CHANGED
|
@@ -1,15 +1,84 @@
|
|
|
1
|
-
/** Open
|
|
1
|
+
/** Open an http(s) URL or local path. Best-effort, never throws. */
|
|
2
|
+
const ALLOWED_OPEN_PROTOCOLS = new Set(["http:", "https:"]);
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Zero-width and non-ASCII spaces. ASCII controls are rejected, not stripped:
|
|
6
|
+
* the URL parser drops some of them and would turn a hostile string into a clean href.
|
|
7
|
+
*/
|
|
8
|
+
const OUTER_FORMAT = /[\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF\u200B\u2060]/;
|
|
9
|
+
|
|
10
|
+
function hasAsciiControl(value: string): boolean {
|
|
11
|
+
for (let i = 0; i < value.length; i++) {
|
|
12
|
+
const code = value.charCodeAt(i);
|
|
13
|
+
if (code <= 0x1f || code === 0x7f) return true;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isOuterPadding(ch: string): boolean {
|
|
19
|
+
return ch.trim() === "" || OUTER_FORMAT.test(ch);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Drop every outer space or format character. Classification only; local paths stay raw. */
|
|
23
|
+
function peelPadding(value: string): string {
|
|
24
|
+
let start = 0;
|
|
25
|
+
let end = value.length;
|
|
26
|
+
while (start < end && isOuterPadding(value.charAt(start))) start++;
|
|
27
|
+
while (end > start && isOuterPadding(value.charAt(end - 1))) end--;
|
|
28
|
+
return start === 0 && end === value.length ? value : value.slice(start, end);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Drive paths parse as one-letter schemes (`c:`). Recognize them before that check. */
|
|
32
|
+
function isWindowsDrivePath(value: string): boolean {
|
|
33
|
+
return /^[A-Za-z]:[\\/]/.test(value);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const SCHEME_PREFIX = /^[A-Za-z][A-Za-z0-9+.-]*:/;
|
|
37
|
+
|
|
38
|
+
/** http(s) href, "reject" for any other URL, or undefined when `value` is not a URL. */
|
|
39
|
+
function classifyUrl(value: string): string | "reject" | undefined {
|
|
40
|
+
if (isWindowsDrivePath(value) || isWindowsDrivePath(value.trim())) return undefined;
|
|
41
|
+
try {
|
|
42
|
+
const parsed = new URL(value);
|
|
43
|
+
if (!ALLOWED_OPEN_PROTOCOLS.has(parsed.protocol) || hasAsciiControl(parsed.href)) return "reject";
|
|
44
|
+
return parsed.href;
|
|
45
|
+
} catch {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function resolveOpenTarget(raw: string): string | undefined {
|
|
51
|
+
if (hasAsciiControl(raw) || raw.length === 0) return undefined;
|
|
52
|
+
// Local paths, including surrounding spaces, are spawned unchanged.
|
|
53
|
+
if (isWindowsDrivePath(raw)) return raw;
|
|
54
|
+
const direct = classifyUrl(raw);
|
|
55
|
+
if (direct === "reject") return undefined;
|
|
56
|
+
if (direct !== undefined) return direct;
|
|
57
|
+
|
|
58
|
+
const peeled = peelPadding(raw);
|
|
59
|
+
if (peeled.length === 0) return undefined;
|
|
60
|
+
// Padding can hide a scheme or a flag. Refuse that instead of opening a different string.
|
|
61
|
+
if (peeled !== raw && !isWindowsDrivePath(peeled)) {
|
|
62
|
+
const hidden = classifyUrl(peeled);
|
|
63
|
+
if (hidden !== undefined || peeled.startsWith("-") || SCHEME_PREFIX.test(peeled)) return undefined;
|
|
64
|
+
}
|
|
65
|
+
if (raw.startsWith("-") || SCHEME_PREFIX.test(raw)) return undefined;
|
|
66
|
+
return raw;
|
|
67
|
+
}
|
|
68
|
+
|
|
2
69
|
export function openPath(urlOrPath: string): void {
|
|
70
|
+
const target = resolveOpenTarget(urlOrPath);
|
|
71
|
+
if (target === undefined) return;
|
|
3
72
|
let cmd: string[];
|
|
4
73
|
switch (process.platform) {
|
|
5
74
|
case "darwin":
|
|
6
|
-
cmd = ["open",
|
|
75
|
+
cmd = ["open", target];
|
|
7
76
|
break;
|
|
8
77
|
case "win32":
|
|
9
|
-
cmd = ["rundll32", "url.dll,FileProtocolHandler",
|
|
78
|
+
cmd = ["rundll32", "url.dll,FileProtocolHandler", target];
|
|
10
79
|
break;
|
|
11
80
|
default:
|
|
12
|
-
cmd = ["xdg-open",
|
|
81
|
+
cmd = ["xdg-open", target];
|
|
13
82
|
break;
|
|
14
83
|
}
|
|
15
84
|
try {
|
|
@@ -31,6 +31,11 @@ function getShellConfigFile(shell: string, home: string): string {
|
|
|
31
31
|
return path.join(home, ".profile");
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/** One POSIX shell word. Double quotes would still run `$()` and backticks. */
|
|
35
|
+
export function quotePosixShell(value: string): string {
|
|
36
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
/**
|
|
35
40
|
* Generate the snapshot creation script.
|
|
36
41
|
* This script sources the user's rc file and extracts functions, aliases, and options.
|
|
@@ -43,6 +48,9 @@ function generateSnapshotScript(shell: string, snapshotPath: string, rcFile: str
|
|
|
43
48
|
|
|
44
49
|
// Escape the snapshot path for shell
|
|
45
50
|
const escapedPath = snapshotPath.replace(/'/g, "'\\''");
|
|
51
|
+
const rcSource = hasRcFile
|
|
52
|
+
? `source ${quotePosixShell(rcFile)} < /dev/null 2>/dev/null`
|
|
53
|
+
: "# No user config file to source";
|
|
46
54
|
|
|
47
55
|
// Function extraction differs between bash and zsh
|
|
48
56
|
const functionScript = isZsh
|
|
@@ -83,7 +91,7 @@ umask 077
|
|
|
83
91
|
SNAPSHOT_FILE='${escapedPath}'
|
|
84
92
|
|
|
85
93
|
# Source user's rc file if it exists
|
|
86
|
-
${
|
|
94
|
+
${rcSource}
|
|
87
95
|
|
|
88
96
|
# Create/clear the snapshot file
|
|
89
97
|
echo "# Shell snapshot - generated by skc agent" >| "$SNAPSHOT_FILE"
|
|
@@ -5,11 +5,12 @@ import * as path from "node:path";
|
|
|
5
5
|
|
|
6
6
|
import type { AgentMessage } from "@sayknow-cli/agent-core";
|
|
7
7
|
import { type Api, type AssistantMessage, completeSimple, type Model, type Tool } from "@sayknow-cli/ai";
|
|
8
|
-
import { logger, prompt } from "@sayknow-cli/utils";
|
|
8
|
+
import { logger, prompt, redactCrashSecrets } from "@sayknow-cli/utils";
|
|
9
9
|
import type { ModelRegistry } from "../config/model-registry";
|
|
10
10
|
import { resolveRoleSelection } from "../config/model-resolver";
|
|
11
11
|
import type { Settings } from "../config/settings";
|
|
12
12
|
import titleSystemPrompt from "../prompts/system/title-system.md" with { type: "text" };
|
|
13
|
+
import { collectEnvSecrets, createSecretObfuscator, loadSecrets } from "../secrets";
|
|
13
14
|
import { syncCmuxWorkspaceTitle } from "./cmux-workspace";
|
|
14
15
|
|
|
15
16
|
const TITLE_SYSTEM_PROMPT = prompt.render(titleSystemPrompt);
|
|
@@ -36,8 +37,13 @@ const MAX_TITLE_WORDS = 12;
|
|
|
36
37
|
* Build a bounded conversation digest for title regeneration. Regeneration
|
|
37
38
|
* reads several messages so a throwaway first prompt can be corrected, while
|
|
38
39
|
* the automatic first-message path intentionally uses only its initial input.
|
|
40
|
+
* `obfuscateText`, when set, runs on each kept message's full text before the
|
|
41
|
+
* per-message character cut so a secret cannot be split by that cut.
|
|
39
42
|
*/
|
|
40
|
-
export function buildConversationTitleInput(
|
|
43
|
+
export function buildConversationTitleInput(
|
|
44
|
+
messages: readonly AgentMessage[],
|
|
45
|
+
obfuscateText?: (text: string) => string,
|
|
46
|
+
): string | undefined {
|
|
41
47
|
const userMessages: string[] = [];
|
|
42
48
|
for (const message of messages) {
|
|
43
49
|
if (message.role !== "user") continue;
|
|
@@ -50,7 +56,10 @@ export function buildConversationTitleInput(messages: readonly AgentMessage[]):
|
|
|
50
56
|
.map(block => block.text)
|
|
51
57
|
.join("\n");
|
|
52
58
|
const trimmed = text.trim();
|
|
53
|
-
if (trimmed)
|
|
59
|
+
if (!trimmed) continue;
|
|
60
|
+
// Emptiness uses the trimmed text. With an obfuscator, keep the original
|
|
61
|
+
// so a secret that includes edge whitespace still matches, then trim.
|
|
62
|
+
userMessages.push(obfuscateText ? text : trimmed);
|
|
54
63
|
}
|
|
55
64
|
|
|
56
65
|
if (userMessages.length === 0) return undefined;
|
|
@@ -59,13 +68,19 @@ export function buildConversationTitleInput(messages: readonly AgentMessage[]):
|
|
|
59
68
|
userMessages.length > MAX_TITLE_CONVERSATION_MESSAGES
|
|
60
69
|
? [userMessages[0]!, ...userMessages.slice(-(MAX_TITLE_CONVERSATION_MESSAGES - 1))]
|
|
61
70
|
: userMessages;
|
|
71
|
+
// Obfuscate the full kept text first. The 400-character cut below, and the
|
|
72
|
+
// later 2,000-character cap, then keep their existing limits.
|
|
73
|
+
const preparedMessages = obfuscateText
|
|
74
|
+
? keptMessages.map(message => obfuscateText(message).trim()).filter(message => message.length > 0)
|
|
75
|
+
: keptMessages;
|
|
76
|
+
if (preparedMessages.length === 0) return undefined;
|
|
62
77
|
// Reserve separator and ellipsis room so the digest is already within the
|
|
63
78
|
// generator's MAX_INPUT_CHARS bound; its existing truncation is a no-op here.
|
|
64
79
|
const maxMessageChars = Math.min(
|
|
65
80
|
MAX_TITLE_MESSAGE_CHARS,
|
|
66
|
-
Math.floor((MAX_INPUT_CHARS - (
|
|
81
|
+
Math.floor((MAX_INPUT_CHARS - (preparedMessages.length - 1) - preparedMessages.length) / preparedMessages.length),
|
|
67
82
|
);
|
|
68
|
-
return
|
|
83
|
+
return preparedMessages
|
|
69
84
|
.map(message => (message.length > maxMessageChars ? `${message.slice(0, maxMessageChars)}…` : message))
|
|
70
85
|
.join("\n");
|
|
71
86
|
}
|
|
@@ -98,6 +113,32 @@ function getTitleModel(registry: ModelRegistry, settings: Settings, currentModel
|
|
|
98
113
|
return undefined;
|
|
99
114
|
}
|
|
100
115
|
|
|
116
|
+
/**
|
|
117
|
+
* Obfuscate the full title input, then truncate, then wrap.
|
|
118
|
+
* A secret that crosses the character cap is replaced before the cut, and the
|
|
119
|
+
* `<user-message>` fence stays outside the truncated body.
|
|
120
|
+
*/
|
|
121
|
+
export function prepareTitleOutboundText(firstMessage: string, obfuscateText?: (text: string) => string): string {
|
|
122
|
+
const source = obfuscateText ? obfuscateText(firstMessage) : firstMessage;
|
|
123
|
+
const truncated = source.length > MAX_INPUT_CHARS ? `${source.slice(0, MAX_INPUT_CHARS)}…` : source;
|
|
124
|
+
return `<user-message>\n${truncated}\n</user-message>`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export async function titleInputObfuscator(
|
|
128
|
+
settings: Settings,
|
|
129
|
+
activeCwd?: string,
|
|
130
|
+
): Promise<((text: string) => string) | undefined> {
|
|
131
|
+
const reader = settings as Partial<Pick<Settings, "get" | "getCwd" | "getAgentDir">>;
|
|
132
|
+
if (typeof reader.get !== "function" || reader.get("secrets.enabled") !== true) return undefined;
|
|
133
|
+
const cwd = activeCwd ?? (typeof reader.getCwd === "function" ? reader.getCwd() : process.cwd());
|
|
134
|
+
const agentDir = typeof reader.getAgentDir === "function" ? reader.getAgentDir() : cwd;
|
|
135
|
+
const entries = [...collectEnvSecrets(), ...(await loadSecrets(cwd, agentDir))];
|
|
136
|
+
if (entries.length === 0) return undefined;
|
|
137
|
+
const obfuscator = createSecretObfuscator(entries);
|
|
138
|
+
if (!obfuscator.hasSecrets()) return undefined;
|
|
139
|
+
return text => obfuscator.obfuscate(text);
|
|
140
|
+
}
|
|
141
|
+
|
|
101
142
|
/**
|
|
102
143
|
* Generate a title for a session based on the provided user-message input.
|
|
103
144
|
* Automatic titles pass the first user message; regeneration passes a bounded
|
|
@@ -112,6 +153,7 @@ function getTitleModel(registry: ModelRegistry, settings: Settings, currentModel
|
|
|
112
153
|
* to produce request metadata (e.g. user_id for session attribution). Using a
|
|
113
154
|
* resolver instead of a pre-evaluated value ensures the metadata's account_uuid
|
|
114
155
|
* reflects the credential actually selected for this request.
|
|
156
|
+
* @param activeCwd Active session cwd for project-scoped secret lookup.
|
|
115
157
|
*/
|
|
116
158
|
export async function generateSessionTitle(
|
|
117
159
|
firstMessage: string,
|
|
@@ -120,6 +162,7 @@ export async function generateSessionTitle(
|
|
|
120
162
|
sessionId?: string,
|
|
121
163
|
currentModel?: Model<Api>,
|
|
122
164
|
metadataResolver?: (provider: string) => Record<string, unknown> | undefined,
|
|
165
|
+
activeCwd?: string,
|
|
123
166
|
): Promise<string | null> {
|
|
124
167
|
const model = getTitleModel(registry, settings, currentModel);
|
|
125
168
|
if (!model) {
|
|
@@ -127,13 +170,6 @@ export async function generateSessionTitle(
|
|
|
127
170
|
return null;
|
|
128
171
|
}
|
|
129
172
|
|
|
130
|
-
// Truncate message if too long
|
|
131
|
-
const truncatedMessage =
|
|
132
|
-
firstMessage.length > MAX_INPUT_CHARS ? `${firstMessage.slice(0, MAX_INPUT_CHARS)}…` : firstMessage;
|
|
133
|
-
const userMessage = `<user-message>
|
|
134
|
-
${truncatedMessage}
|
|
135
|
-
</user-message>`;
|
|
136
|
-
|
|
137
173
|
const apiKey = await registry.getApiKey(model, sessionId);
|
|
138
174
|
if (!apiKey) {
|
|
139
175
|
logger.debug("title-generator: no API key for smol model", {
|
|
@@ -146,6 +182,7 @@ ${truncatedMessage}
|
|
|
146
182
|
// request is already recorded; metadataResolver can then return the correct
|
|
147
183
|
// account_uuid rather than the snapshot-at-call-site value.
|
|
148
184
|
const metadata = metadataResolver?.(model.provider);
|
|
185
|
+
const userMessage = prepareTitleOutboundText(firstMessage, await titleInputObfuscator(settings, activeCwd));
|
|
149
186
|
|
|
150
187
|
// Title generation is a 3-6 word task, but some reasoning backends ignore
|
|
151
188
|
// disableReasoning. Keep the normal cheap budget for non-reasoning models
|
|
@@ -158,7 +195,12 @@ ${truncatedMessage}
|
|
|
158
195
|
userMessage,
|
|
159
196
|
maxTokens,
|
|
160
197
|
};
|
|
161
|
-
logger.debug("title-generator: request",
|
|
198
|
+
logger.debug("title-generator: request", {
|
|
199
|
+
model: request.model,
|
|
200
|
+
systemPrompt: request.systemPrompt,
|
|
201
|
+
userMessage: redactCrashSecrets(request.userMessage),
|
|
202
|
+
maxTokens: request.maxTokens,
|
|
203
|
+
});
|
|
162
204
|
|
|
163
205
|
try {
|
|
164
206
|
const response = await completeSimple(
|
|
@@ -181,7 +223,10 @@ ${truncatedMessage}
|
|
|
181
223
|
logger.debug("title-generator: response error", {
|
|
182
224
|
model: request.model,
|
|
183
225
|
stopReason: response.stopReason,
|
|
184
|
-
errorMessage:
|
|
226
|
+
errorMessage:
|
|
227
|
+
typeof response.errorMessage === "string"
|
|
228
|
+
? redactCrashSecrets(response.errorMessage)
|
|
229
|
+
: response.errorMessage,
|
|
185
230
|
});
|
|
186
231
|
return null;
|
|
187
232
|
}
|
|
@@ -190,7 +235,7 @@ ${truncatedMessage}
|
|
|
190
235
|
|
|
191
236
|
logger.debug("title-generator: response", {
|
|
192
237
|
model: request.model,
|
|
193
|
-
title,
|
|
238
|
+
title: redactCrashSecrets(title),
|
|
194
239
|
usage: response.usage,
|
|
195
240
|
stopReason: response.stopReason,
|
|
196
241
|
});
|
|
@@ -203,7 +248,7 @@ ${truncatedMessage}
|
|
|
203
248
|
} catch (err) {
|
|
204
249
|
logger.debug("title-generator: error", {
|
|
205
250
|
model: request.model,
|
|
206
|
-
error: err instanceof Error ? err.message : String(err),
|
|
251
|
+
error: redactCrashSecrets(err instanceof Error ? err.message : String(err)),
|
|
207
252
|
});
|
|
208
253
|
return null;
|
|
209
254
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
const SHA256_DIGEST_RE = /^sha256:([a-fA-F0-9]{64})$/;
|
|
5
|
+
|
|
6
|
+
export interface ReleaseAssetDigest {
|
|
7
|
+
name?: string;
|
|
8
|
+
digest?: string | null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function sha256FromReleaseDigest(digest: string | null | undefined): string | null {
|
|
12
|
+
if (typeof digest !== "string") return null;
|
|
13
|
+
const match = SHA256_DIGEST_RE.exec(digest.trim());
|
|
14
|
+
return match ? match[1].toLowerCase() : null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function requireAssetSha256(assets: readonly ReleaseAssetDigest[], assetName: string): string {
|
|
18
|
+
const asset = assets.find(entry => entry.name === assetName);
|
|
19
|
+
const sha256 = sha256FromReleaseDigest(asset?.digest);
|
|
20
|
+
if (!sha256) {
|
|
21
|
+
throw new Error(`Release asset ${assetName} has no sha256 digest; refusing to install an unverified binary`);
|
|
22
|
+
}
|
|
23
|
+
return sha256;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function assertFileMatchesSha256(filePath: string, expectedSha256: string): Promise<void> {
|
|
27
|
+
const actual = createHash("sha256")
|
|
28
|
+
.update(await fs.readFile(filePath))
|
|
29
|
+
.digest("hex");
|
|
30
|
+
if (actual !== expectedSha256.toLowerCase()) {
|
|
31
|
+
await fs.rm(filePath, { force: true });
|
|
32
|
+
throw new Error(`Checksum mismatch for ${filePath}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -2,6 +2,7 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import * as os from "node:os";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { $which, APP_NAME, getToolsDir, logger, ptree, TempDir } from "@sayknow-cli/utils";
|
|
5
|
+
import { assertFileMatchesSha256, requireAssetSha256 } from "./tools-checksum";
|
|
5
6
|
|
|
6
7
|
const TOOLS_DIR = getToolsDir();
|
|
7
8
|
const TOOL_DOWNLOAD_TIMEOUT_MS = 120_000;
|
|
@@ -112,8 +113,18 @@ export function getToolPath(tool: ToolName): string | null {
|
|
|
112
113
|
return $which(config.binaryName);
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
interface GithubReleaseAsset {
|
|
117
|
+
name?: string;
|
|
118
|
+
digest?: string | null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface GithubRelease {
|
|
122
|
+
version: string;
|
|
123
|
+
assets: GithubReleaseAsset[];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Fetch latest release metadata from GitHub, including asset digests.
|
|
127
|
+
async function getLatestRelease(repo: string, signal?: AbortSignal): Promise<GithubRelease> {
|
|
117
128
|
let response: Response;
|
|
118
129
|
try {
|
|
119
130
|
response = await fetch(`https://api.github.com/repos/${repo}/releases/latest`, {
|
|
@@ -131,8 +142,11 @@ async function getLatestVersion(repo: string, signal?: AbortSignal): Promise<str
|
|
|
131
142
|
throw new Error(`GitHub API error: ${response.status}`);
|
|
132
143
|
}
|
|
133
144
|
|
|
134
|
-
const data = (await response.json()) as { tag_name
|
|
135
|
-
|
|
145
|
+
const data = (await response.json()) as { tag_name?: string; assets?: GithubReleaseAsset[] };
|
|
146
|
+
if (!data.tag_name) {
|
|
147
|
+
throw new Error("GitHub API error: missing tag_name");
|
|
148
|
+
}
|
|
149
|
+
return { version: data.tag_name.replace(/^v/, ""), assets: data.assets ?? [] };
|
|
136
150
|
}
|
|
137
151
|
|
|
138
152
|
// Download a file from URL
|
|
@@ -164,14 +178,16 @@ async function downloadTool(tool: ToolName, signal?: AbortSignal): Promise<strin
|
|
|
164
178
|
const plat = os.platform();
|
|
165
179
|
const architecture = os.arch();
|
|
166
180
|
|
|
167
|
-
// Get latest version
|
|
168
|
-
const
|
|
181
|
+
// Get latest version and the published digest for this asset.
|
|
182
|
+
const release = await getLatestRelease(config.repo, signal);
|
|
183
|
+
const version = release.version;
|
|
169
184
|
|
|
170
185
|
// Get asset name for this platform
|
|
171
186
|
const assetName = config.getAssetName(version, plat, architecture);
|
|
172
187
|
if (!assetName) {
|
|
173
188
|
throw new Error(`Unsupported platform: ${plat}/${architecture}`);
|
|
174
189
|
}
|
|
190
|
+
const expectedSha256 = requireAssetSha256(release.assets, assetName);
|
|
175
191
|
|
|
176
192
|
// Create tools directory
|
|
177
193
|
await fs.promises.mkdir(TOOLS_DIR, { recursive: true });
|
|
@@ -183,6 +199,7 @@ async function downloadTool(tool: ToolName, signal?: AbortSignal): Promise<strin
|
|
|
183
199
|
// Handle direct binary downloads (no archive extraction needed)
|
|
184
200
|
if (config.isDirectBinary) {
|
|
185
201
|
await downloadFile(downloadUrl, binaryPath, signal);
|
|
202
|
+
await assertFileMatchesSha256(binaryPath, expectedSha256);
|
|
186
203
|
if (plat !== "win32") {
|
|
187
204
|
await fs.promises.chmod(binaryPath, 0o755);
|
|
188
205
|
}
|
|
@@ -192,6 +209,7 @@ async function downloadTool(tool: ToolName, signal?: AbortSignal): Promise<strin
|
|
|
192
209
|
// Download archive
|
|
193
210
|
const archivePath = path.join(TOOLS_DIR, assetName);
|
|
194
211
|
await downloadFile(downloadUrl, archivePath, signal);
|
|
212
|
+
await assertFileMatchesSha256(archivePath, expectedSha256);
|
|
195
213
|
|
|
196
214
|
// Extract
|
|
197
215
|
const tmp = await TempDir.create("@skc-tools-extract-");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Escape a string for interpolation inside a double- or single-quoted XML attribute. */
|
|
2
|
+
export function escapeXmlAttribute(input: string): string {
|
|
3
|
+
if (!/[&<>"']/.test(input)) return input;
|
|
4
|
+
let output = "";
|
|
5
|
+
for (const char of input) {
|
|
6
|
+
if (char === "&") output += "&";
|
|
7
|
+
else if (char === "<") output += "<";
|
|
8
|
+
else if (char === ">") output += ">";
|
|
9
|
+
else if (char === '"') output += """;
|
|
10
|
+
else if (char === "'") output += "'";
|
|
11
|
+
else output += char;
|
|
12
|
+
}
|
|
13
|
+
return output;
|
|
14
|
+
}
|
|
@@ -74,7 +74,7 @@ function isBlockedHostname(hostname: string): boolean {
|
|
|
74
74
|
function isPrivateIPv4(address: string): boolean {
|
|
75
75
|
const parts = address.split(".").map(part => Number.parseInt(part, 10));
|
|
76
76
|
if (parts.length !== 4 || parts.some(part => !Number.isInteger(part) || part < 0 || part > 255)) return true;
|
|
77
|
-
const [a, b] = parts;
|
|
77
|
+
const [a, b, c] = parts;
|
|
78
78
|
return (
|
|
79
79
|
a === 0 || // unspecified / "this network"
|
|
80
80
|
a === 10 || // RFC1918
|
|
@@ -83,6 +83,7 @@ function isPrivateIPv4(address: string): boolean {
|
|
|
83
83
|
(a === 169 && b === 254) || // link-local
|
|
84
84
|
(a === 172 && b >= 16 && b <= 31) || // RFC1918
|
|
85
85
|
(a === 192 && b === 0) || // 192.0.0/24 & 192.0.2/24 (documentation/reserved)
|
|
86
|
+
(a === 192 && b === 88 && c === 99) || // 192.88.99.0/24 deprecated 6to4 anycast; 192.88.99.2/32 is not globally reachable
|
|
86
87
|
(a === 192 && b === 168) || // RFC1918
|
|
87
88
|
(a === 198 && (b === 18 || b === 19)) || // benchmarking 198.18/15
|
|
88
89
|
(a === 198 && b === 51) || // 198.51.100/24 documentation
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Shared types and utilities for web-fetch handlers
|
|
3
3
|
*/
|
|
4
4
|
import { ptree } from "@sayknow-cli/utils";
|
|
5
|
+
import type { Settings } from "../../config/settings";
|
|
5
6
|
import type { AgentStorage } from "../../session/agent-storage";
|
|
6
7
|
import { ToolAbortError } from "../../tools/tool-errors";
|
|
7
8
|
import type { AddressResolver } from "../insane/url-guard";
|
|
@@ -20,11 +21,18 @@ export interface RenderResult {
|
|
|
20
21
|
notes: string[];
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
/**
|
|
25
|
+
* `settings` is the caller's session settings. Handlers must read through it
|
|
26
|
+
* rather than the process-global singleton: the SDK/ACP host path runs tools
|
|
27
|
+
* without ever calling `Settings.init()`, where a global read throws
|
|
28
|
+
* "Settings not initialized" instead of scraping the page.
|
|
29
|
+
*/
|
|
23
30
|
export type SpecialHandler = (
|
|
24
31
|
url: string,
|
|
25
32
|
timeout: number,
|
|
26
33
|
signal?: AbortSignal,
|
|
27
34
|
storage?: AgentStorage | null,
|
|
35
|
+
settings?: Settings,
|
|
28
36
|
) => Promise<RenderResult | null>;
|
|
29
37
|
|
|
30
38
|
export const MAX_OUTPUT_CHARS = 500_000;
|
|
@@ -2,7 +2,7 @@ import * as fs from "node:fs/promises";
|
|
|
2
2
|
import * as os from "node:os";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { ptree, Snowflake } from "@sayknow-cli/utils";
|
|
5
|
-
import {
|
|
5
|
+
import type { Settings } from "../../config/settings";
|
|
6
6
|
import type { AgentStorage } from "../../session/agent-storage";
|
|
7
7
|
import { throwIfAborted } from "../../tools/tool-errors";
|
|
8
8
|
import { ensureTool } from "../../utils/tools-manager";
|
|
@@ -115,6 +115,7 @@ export const handleYouTube: SpecialHandler = async (
|
|
|
115
115
|
timeout: number,
|
|
116
116
|
userSignal?: AbortSignal,
|
|
117
117
|
storage?: AgentStorage | null,
|
|
118
|
+
settings?: Settings,
|
|
118
119
|
): Promise<RenderResult | null> => {
|
|
119
120
|
throwIfAborted(userSignal);
|
|
120
121
|
const yt = parseYouTubeUrl(url);
|
|
@@ -126,7 +127,7 @@ export const handleYouTube: SpecialHandler = async (
|
|
|
126
127
|
const videoUrl = `https://www.youtube.com/watch?v=${yt.videoId}`;
|
|
127
128
|
|
|
128
129
|
// Prefer Parallel extract when credentials are available
|
|
129
|
-
if (settings
|
|
130
|
+
if (settings?.get("providers.parallelFetch") === true && findParallelApiKey(storage)) {
|
|
130
131
|
try {
|
|
131
132
|
const parallelResult = await extractWithParallel(
|
|
132
133
|
[videoUrl],
|
package/src/web/search/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ import webSearchSystemPrompt from "../../prompts/system/web-search.md" with { ty
|
|
|
14
14
|
import webSearchDescription from "../../prompts/tools/web-search.md" with { type: "text" };
|
|
15
15
|
import { discoverAuthStorage } from "../../sdk";
|
|
16
16
|
import type { ToolSession } from "../../tools";
|
|
17
|
+
import { wrapUntrustedContent } from "../../tools/fetch";
|
|
17
18
|
import { formatAge } from "../../tools/render-utils";
|
|
18
19
|
import { throwIfAborted } from "../../tools/tool-errors";
|
|
19
20
|
import { getSearchProviderLabel, prewarmSearchProviders, resolveProviderChain, type SearchProvider } from "./provider";
|
|
@@ -25,10 +26,10 @@ import { SearchProviderError } from "./types";
|
|
|
25
26
|
export const webSearchSchema = z.object({
|
|
26
27
|
query: z.string().describe("search query"),
|
|
27
28
|
recency: z.enum(["day", "week", "month", "year"]).describe("recency filter").optional(),
|
|
28
|
-
limit: z.number().describe("max results").optional(),
|
|
29
|
+
limit: z.number().int().min(1).describe("max results").optional(),
|
|
29
30
|
max_tokens: z.number().describe("max output tokens").optional(),
|
|
30
31
|
temperature: z.number().describe("sampling temperature").optional(),
|
|
31
|
-
num_search_results: z.number().describe("number of search results").optional(),
|
|
32
|
+
num_search_results: z.number().int().min(1).describe("number of search results").optional(),
|
|
32
33
|
xai_search_mode: z
|
|
33
34
|
.enum(["web", "x", "web_and_x"])
|
|
34
35
|
.describe("xAI only: use web_search, x_search, or both")
|
|
@@ -138,7 +139,7 @@ export function formatSearchResponseForLlm(response: SearchResponse): string {
|
|
|
138
139
|
}
|
|
139
140
|
}
|
|
140
141
|
|
|
141
|
-
return
|
|
142
|
+
return wrapUntrustedContent(parts.join("\n"));
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
interface ExecuteSearchOptions {
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
buildAnthropicUrl,
|
|
15
15
|
stripClaudeToolPrefix,
|
|
16
16
|
} from "@sayknow-cli/ai";
|
|
17
|
-
import { $env } from "@sayknow-cli/utils";
|
|
17
|
+
import { $credentialEnv, $env } from "@sayknow-cli/utils";
|
|
18
18
|
import type {
|
|
19
19
|
AnthropicApiResponse,
|
|
20
20
|
AnthropicCitation,
|
|
@@ -275,8 +275,8 @@ export async function searchAnthropic(
|
|
|
275
275
|
params: SearchParams | AnthropicSearchParams,
|
|
276
276
|
_legacyStorage?: unknown,
|
|
277
277
|
): Promise<SearchResponse> {
|
|
278
|
-
const searchApiKey = $
|
|
279
|
-
const searchBaseUrl = $
|
|
278
|
+
const searchApiKey = $credentialEnv("ANTHROPIC_SEARCH_API_KEY");
|
|
279
|
+
const searchBaseUrl = $credentialEnv("ANTHROPIC_SEARCH_BASE_URL");
|
|
280
280
|
let auth: AnthropicAuthConfig | undefined;
|
|
281
281
|
// When reusing the active model's own credentials (native search over a
|
|
282
282
|
// proxy), prefer its wire model id and carry its request headers through.
|
|
@@ -360,7 +360,7 @@ export class AnthropicProvider extends SearchProvider {
|
|
|
360
360
|
readonly label = "Anthropic";
|
|
361
361
|
|
|
362
362
|
isAvailable(authStorage: AuthStorage): Promise<boolean> | boolean {
|
|
363
|
-
return Boolean($
|
|
363
|
+
return Boolean($credentialEnv("ANTHROPIC_SEARCH_API_KEY")) || authStorage.hasAuth("anthropic");
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
search(params: SearchParams): Promise<SearchResponse> {
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* SQLite store, never POSTs the broker sentinel to an OpenAI token endpoint.
|
|
8
8
|
*/
|
|
9
9
|
import * as os from "node:os";
|
|
10
|
-
import {
|
|
10
|
+
import type { AuthStorage } from "@sayknow-cli/ai";
|
|
11
|
+
import { fetchCodexModels } from "@sayknow-cli/ai/utils/discovery/codex";
|
|
11
12
|
import { decodeJwt } from "@sayknow-cli/ai/utils/oauth/openai-codex";
|
|
12
|
-
import { $env, readSseJson } from "@sayknow-cli/utils";
|
|
13
|
+
import { $env, readSseJson, sanitizeHeaderComponent } from "@sayknow-cli/utils";
|
|
13
14
|
import packageJson from "../../../../package.json" with { type: "json" };
|
|
14
15
|
import type { SearchResponse, SearchSource } from "../../../web/search/types";
|
|
15
16
|
import { SearchProviderError } from "../../../web/search/types";
|
|
@@ -20,17 +21,9 @@ import { classifyProviderHttpError, withHardTimeout } from "./utils";
|
|
|
20
21
|
|
|
21
22
|
const CODEX_BASE_URL = "https://chatgpt.com/backend-api";
|
|
22
23
|
const CODEX_RESPONSES_PATH = "/codex/responses";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"gpt-5.4",
|
|
27
|
-
"gpt-5-codex",
|
|
28
|
-
"gpt-5",
|
|
29
|
-
"gpt-5.3-codex",
|
|
30
|
-
"gpt-5.2-codex",
|
|
31
|
-
"gpt-5.1-codex",
|
|
32
|
-
"gpt-5-codex-mini",
|
|
33
|
-
];
|
|
24
|
+
// Reviewed search candidates, additionally filtered by current account discovery.
|
|
25
|
+
// Upstream Codex web-search metadata informs this policy, not bundle presence.
|
|
26
|
+
const DEFAULT_MODEL_PREFERENCES = ["gpt-6.1-sol", "gpt-6-luna"];
|
|
34
27
|
const JWT_CLAIM_PATH = "https://api.openai.com/auth";
|
|
35
28
|
const DEFAULT_INSTRUCTIONS =
|
|
36
29
|
"You are a helpful assistant with web search capabilities. Search the web to answer the user's question accurately and cite your sources.";
|
|
@@ -40,21 +33,26 @@ function getConfiguredModel(): string | undefined {
|
|
|
40
33
|
return configuredModel ? configuredModel : undefined;
|
|
41
34
|
}
|
|
42
35
|
|
|
43
|
-
function getDefaultModelCandidates(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
async function getDefaultModelCandidates(
|
|
37
|
+
auth: { accessToken: string; accountId: string },
|
|
38
|
+
signal: AbortSignal | undefined,
|
|
39
|
+
): Promise<string[]> {
|
|
40
|
+
signal?.throwIfAborted();
|
|
41
|
+
const discovery = await fetchCodexModels({ ...auth, signal: withHardTimeout(signal, "llm") });
|
|
42
|
+
signal?.throwIfAborted();
|
|
43
|
+
if (!discovery) {
|
|
44
|
+
throw new SearchProviderError("codex", "Codex model discovery unavailable", 503);
|
|
50
45
|
}
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
|
|
46
|
+
const advertisedIds = new Set(discovery.models.map(model => model.id));
|
|
47
|
+
const candidates = DEFAULT_MODEL_PREFERENCES.filter(modelId => advertisedIds.has(modelId));
|
|
48
|
+
if (candidates.length === 0) {
|
|
49
|
+
throw new SearchProviderError(
|
|
50
|
+
"codex",
|
|
51
|
+
"No preferred Codex web-search models are advertised for this account",
|
|
52
|
+
503,
|
|
53
|
+
);
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
return bundledModels[0]?.id ? [bundledModels[0].id] : [FALLBACK_MODEL];
|
|
55
|
+
return candidates;
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
function shouldRetryWithNextDefaultModel(error: unknown): boolean {
|
|
@@ -158,7 +156,7 @@ function buildCodexHeaders(accessToken: string, accountId: string): Record<strin
|
|
|
158
156
|
"chatgpt-account-id": accountId,
|
|
159
157
|
"OpenAI-Beta": "responses=experimental",
|
|
160
158
|
originator: "pi",
|
|
161
|
-
"User-Agent": `pi/${packageJson.version} (${os.platform()} ${os.release()}; ${os.arch()})`,
|
|
159
|
+
"User-Agent": `pi/${packageJson.version} (${sanitizeHeaderComponent(os.platform())} ${sanitizeHeaderComponent(os.release())}; ${sanitizeHeaderComponent(os.arch())})`,
|
|
162
160
|
Accept: "text/event-stream",
|
|
163
161
|
"Content-Type": "application/json",
|
|
164
162
|
};
|
|
@@ -336,12 +334,11 @@ async function callCodexSearch(
|
|
|
336
334
|
* Executes a web search using OpenAI code provider's built-in web search tool.
|
|
337
335
|
*
|
|
338
336
|
* Default-model behavior:
|
|
339
|
-
* -
|
|
340
|
-
* upstream
|
|
341
|
-
* - Otherwise
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
* `gpt-5-codex-mini` first on ChatGPT accounts, which OpenAI rejects.
|
|
337
|
+
* - Use `SKC_OPENAI_CODE_WEB_SEARCH_MODEL` (then `PI_CODEX_WEB_SEARCH_MODEL`)
|
|
338
|
+
* exactly once when configured and surface upstream errors without model retries.
|
|
339
|
+
* - Otherwise intersect current account discovery with GPT-6.1 Sol, then GPT-6 Luna.
|
|
340
|
+
* Fail closed when discovery is unavailable or neither candidate is advertised.
|
|
341
|
+
* Retry the next advertised candidate only for the known unsupported-model 400 family.
|
|
345
342
|
*/
|
|
346
343
|
export async function searchCodex(params: SearchParams): Promise<SearchResponse> {
|
|
347
344
|
const auth = await findCodexAuth(params.authStorage, params.sessionId, params.signal);
|
|
@@ -352,7 +349,7 @@ export async function searchCodex(params: SearchParams): Promise<SearchResponse>
|
|
|
352
349
|
}
|
|
353
350
|
|
|
354
351
|
const configuredModel = getConfiguredModel();
|
|
355
|
-
const modelCandidates = configuredModel ? [configuredModel] : getDefaultModelCandidates();
|
|
352
|
+
const modelCandidates = configuredModel ? [configuredModel] : await getDefaultModelCandidates(auth, params.signal);
|
|
356
353
|
|
|
357
354
|
let result:
|
|
358
355
|
| {
|