@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
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `reverse_engineer` — REA (Reverse Engineer Anything, https://github.com/morluto/rea, MIT) as a
|
|
3
|
+
* built-in tool for "build something like this" requests.
|
|
4
|
+
*
|
|
5
|
+
* REA ships as the `rea-agents` npm package. SKC does not bundle it: with Playwright, Frida and
|
|
6
|
+
* node-pty its install tree is about 230 MB, and its MCP server advertises 207 tools whose input
|
|
7
|
+
* schemas alone are about 720 KB. This tool instead runs the pinned release through npx/bunx on
|
|
8
|
+
* demand (cached after the first call), exposes a vetted subset of its CLI, and keeps the model's
|
|
9
|
+
* view of each result small while the full result is saved for follow-up commands.
|
|
10
|
+
*/
|
|
11
|
+
import * as path from "node:path";
|
|
12
|
+
import type { AgentTool, AgentToolContext, AgentToolResult } from "@sayknow-cli/agent-core";
|
|
13
|
+
import { $which, prompt, untilAborted } from "@sayknow-cli/utils";
|
|
14
|
+
import * as z from "zod/v4";
|
|
15
|
+
import reverseEngineerDescription from "../prompts/tools/reverse-engineer.md" with { type: "text" };
|
|
16
|
+
import type { ToolSession } from ".";
|
|
17
|
+
import { publishExplicitArtifactText } from "./explicit-artifact";
|
|
18
|
+
import type { OutputMeta } from "./output-meta";
|
|
19
|
+
import { ToolAbortError, ToolError, throwIfAborted } from "./tool-errors";
|
|
20
|
+
import { toolResult } from "./tool-result";
|
|
21
|
+
import { wrapUntrustedContent } from "./untrusted-content";
|
|
22
|
+
|
|
23
|
+
export const REA_PACKAGE = "rea-agents";
|
|
24
|
+
/** Pinned so the command list below always matches the CLI that runs. */
|
|
25
|
+
export const REA_VERSION = "6.7.0";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Commands of rea-agents@6.7.0 the tool may run. Left out on purpose: commands that change the
|
|
29
|
+
* host, a device, or an analysis database (`setup`, `uninstall`, `update`, `annotate-native-function`,
|
|
30
|
+
* adb install/uninstall/push/start/stop), unrestricted debugger or Rizin/Cutter consoles, and
|
|
31
|
+
* commands that drive or instrument the user's own running apps (`capture-native-ui-scenario`,
|
|
32
|
+
* `capture-process`, `observe-native-calls`).
|
|
33
|
+
*/
|
|
34
|
+
export const REA_COMMANDS = [
|
|
35
|
+
"address-to-file-offset",
|
|
36
|
+
"analyze",
|
|
37
|
+
"analyze-javascript-application",
|
|
38
|
+
"analyze-web-bundle",
|
|
39
|
+
"build-reconstruction-obligation-ledger",
|
|
40
|
+
"capabilities",
|
|
41
|
+
"capture-adb-screen",
|
|
42
|
+
"capture-browser-scenario",
|
|
43
|
+
"capture-electron-scenario",
|
|
44
|
+
"capture-web-screenshot",
|
|
45
|
+
"collect-adb-bugreport",
|
|
46
|
+
"compare",
|
|
47
|
+
"compare-application-versions",
|
|
48
|
+
"compare-javascript-export-shapes",
|
|
49
|
+
"compare-managed-members",
|
|
50
|
+
"compare-process-captures",
|
|
51
|
+
"compare-source-to-bundle",
|
|
52
|
+
"compare-wasm-interfaces",
|
|
53
|
+
"compare-web-captures",
|
|
54
|
+
"compare-web-screenshots",
|
|
55
|
+
"decode-android-resources",
|
|
56
|
+
"decode-interface-builder",
|
|
57
|
+
"decode-signal-recording",
|
|
58
|
+
"decompile",
|
|
59
|
+
"decompile-jeb-item",
|
|
60
|
+
"demangle-swift",
|
|
61
|
+
"discover-webmcp-tools",
|
|
62
|
+
"doctor",
|
|
63
|
+
"evaluate-reconstruction-coverage",
|
|
64
|
+
"evidence-export",
|
|
65
|
+
"evidence-import",
|
|
66
|
+
"export-web-scripts",
|
|
67
|
+
"extract-artifact",
|
|
68
|
+
"extract-firmware",
|
|
69
|
+
"function",
|
|
70
|
+
"identify-flutter-build",
|
|
71
|
+
"import-managed-reconstruction",
|
|
72
|
+
"import-reference-source",
|
|
73
|
+
"inspect",
|
|
74
|
+
"inspect-adb-client",
|
|
75
|
+
"inspect-adb-device",
|
|
76
|
+
"inspect-adb-display",
|
|
77
|
+
"inspect-adb-package",
|
|
78
|
+
"inspect-adb-window",
|
|
79
|
+
"inspect-analysis-view",
|
|
80
|
+
"inspect-android-class",
|
|
81
|
+
"inspect-android-method",
|
|
82
|
+
"inspect-android-package",
|
|
83
|
+
"inspect-apktool-client",
|
|
84
|
+
"inspect-artifact",
|
|
85
|
+
"inspect-asset-catalog",
|
|
86
|
+
"inspect-binary-layout",
|
|
87
|
+
"inspect-dart-aot",
|
|
88
|
+
"inspect-electron-fuses",
|
|
89
|
+
"inspect-electron-page",
|
|
90
|
+
"inspect-evidence-bundle",
|
|
91
|
+
"inspect-evm-interface",
|
|
92
|
+
"inspect-firmware-regions",
|
|
93
|
+
"inspect-go-binary",
|
|
94
|
+
"inspect-jeb-client",
|
|
95
|
+
"inspect-keyed-archive",
|
|
96
|
+
"inspect-macho",
|
|
97
|
+
"inspect-managed-artifact",
|
|
98
|
+
"inspect-managed-members",
|
|
99
|
+
"inspect-managed-native-boundaries",
|
|
100
|
+
"inspect-native-api",
|
|
101
|
+
"inspect-native-data-type",
|
|
102
|
+
"inspect-native-dispatch-metadata",
|
|
103
|
+
"inspect-native-instruction",
|
|
104
|
+
"inspect-native-load-image",
|
|
105
|
+
"inspect-packet-capture",
|
|
106
|
+
"inspect-packet-fields",
|
|
107
|
+
"inspect-pcap-capture",
|
|
108
|
+
"inspect-pcap-client",
|
|
109
|
+
"inspect-pe-resources",
|
|
110
|
+
"inspect-plist",
|
|
111
|
+
"inspect-recorded-crash",
|
|
112
|
+
"inspect-rust-binary",
|
|
113
|
+
"inspect-signal-decoders",
|
|
114
|
+
"inspect-signature",
|
|
115
|
+
"inspect-sqlite-database",
|
|
116
|
+
"inspect-wasm-artifact",
|
|
117
|
+
"inspect-web-event-listeners",
|
|
118
|
+
"inspect-web-network-capture",
|
|
119
|
+
"inspect-web-page",
|
|
120
|
+
"inspect-with-objdump",
|
|
121
|
+
"instructions",
|
|
122
|
+
"instrument-with-frida",
|
|
123
|
+
"list-adb-devices",
|
|
124
|
+
"list-adb-directory",
|
|
125
|
+
"list-adb-features",
|
|
126
|
+
"list-adb-packages",
|
|
127
|
+
"list-adb-processes",
|
|
128
|
+
"list-adb-services",
|
|
129
|
+
"list-architectures",
|
|
130
|
+
"list-browser-targets",
|
|
131
|
+
"list-cutter-sessions",
|
|
132
|
+
"list-electron-targets",
|
|
133
|
+
"list-frida-devices",
|
|
134
|
+
"list-frida-processes",
|
|
135
|
+
"list-javascript-runtime-targets",
|
|
136
|
+
"list-jeb-units",
|
|
137
|
+
"list-objdump-architectures",
|
|
138
|
+
"observe-javascript-runtime",
|
|
139
|
+
"observe-native-ui",
|
|
140
|
+
"observe-web-execution",
|
|
141
|
+
"observe-web-session",
|
|
142
|
+
"open-jeb-project",
|
|
143
|
+
"project-android-application-graph",
|
|
144
|
+
"project-apple-application-graph",
|
|
145
|
+
"project-harmony-application-graph",
|
|
146
|
+
"project-managed-application-graph",
|
|
147
|
+
"providers",
|
|
148
|
+
"pull-adb-file",
|
|
149
|
+
"pull-adb-package",
|
|
150
|
+
"read-adb-logcat",
|
|
151
|
+
"read-adb-setting",
|
|
152
|
+
"read-bytes",
|
|
153
|
+
"reconcile-javascript-runtime",
|
|
154
|
+
"recover-javascript-sources",
|
|
155
|
+
"resolve-adb-packages",
|
|
156
|
+
"resolve-native-call-targets",
|
|
157
|
+
"search",
|
|
158
|
+
"search-android-classes",
|
|
159
|
+
"search-bytes",
|
|
160
|
+
"trace",
|
|
161
|
+
"trace-android-references",
|
|
162
|
+
"trace-application-feature",
|
|
163
|
+
"trace-dylib-resolution",
|
|
164
|
+
"trace-javascript-semantics",
|
|
165
|
+
"trace-native-ui-action",
|
|
166
|
+
"trace-native-values",
|
|
167
|
+
"trace-web-module-imports",
|
|
168
|
+
"trace-web-source-location",
|
|
169
|
+
"verify-managed-native-boundaries",
|
|
170
|
+
"xrefs",
|
|
171
|
+
] as const;
|
|
172
|
+
|
|
173
|
+
const COMMAND_SET = new Set<string>(REA_COMMANDS);
|
|
174
|
+
const DEFAULT_TIMEOUT_SECONDS = 300;
|
|
175
|
+
const MAX_TIMEOUT_SECONDS = 1800;
|
|
176
|
+
/** Strings longer than this (screenshots, script bodies, DOM dumps) are elided from the model view. */
|
|
177
|
+
const MAX_INLINE_STRING = 2000;
|
|
178
|
+
const MAX_VISIBLE_CHARS = 24_000;
|
|
179
|
+
|
|
180
|
+
const BROWSER_CANDIDATES: Record<string, string[]> = {
|
|
181
|
+
darwin: [
|
|
182
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
183
|
+
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
184
|
+
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
|
185
|
+
"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser",
|
|
186
|
+
],
|
|
187
|
+
linux: [
|
|
188
|
+
"/usr/bin/google-chrome",
|
|
189
|
+
"/usr/bin/google-chrome-stable",
|
|
190
|
+
"/usr/bin/chromium",
|
|
191
|
+
"/usr/bin/chromium-browser",
|
|
192
|
+
"/usr/bin/microsoft-edge",
|
|
193
|
+
"/snap/bin/chromium",
|
|
194
|
+
],
|
|
195
|
+
win32: [
|
|
196
|
+
"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
|
|
197
|
+
"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe",
|
|
198
|
+
],
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const reverseEngineerSchema = z
|
|
202
|
+
.object({
|
|
203
|
+
op: z.enum(["run", "help", "browsers"] as const).describe("operation"),
|
|
204
|
+
command: z.string().describe("REA command in kebab-case, e.g. analyze-javascript-application").optional(),
|
|
205
|
+
args: z.array(z.string()).describe("positional arguments and flags, one element each").optional(),
|
|
206
|
+
timeout: z.number().describe("seconds before the command is stopped (default 300, max 1800)").optional(),
|
|
207
|
+
})
|
|
208
|
+
.strict();
|
|
209
|
+
|
|
210
|
+
type ReverseEngineerInput = z.infer<typeof reverseEngineerSchema>;
|
|
211
|
+
|
|
212
|
+
export interface ReverseEngineerToolDetails {
|
|
213
|
+
meta?: OutputMeta;
|
|
214
|
+
op: ReverseEngineerInput["op"];
|
|
215
|
+
command?: string;
|
|
216
|
+
exitCode?: number;
|
|
217
|
+
savedPath?: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface ReaRunResult {
|
|
221
|
+
exitCode: number;
|
|
222
|
+
stdout: string;
|
|
223
|
+
stderr: string;
|
|
224
|
+
timedOut: boolean;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export type ReaRunner = (
|
|
228
|
+
argv: string[],
|
|
229
|
+
options: { cwd: string; signal?: AbortSignal; timeoutMs: number },
|
|
230
|
+
) => Promise<ReaRunResult>;
|
|
231
|
+
|
|
232
|
+
export interface ReverseEngineerDeps {
|
|
233
|
+
which?: (command: string) => string | null | undefined;
|
|
234
|
+
run?: ReaRunner;
|
|
235
|
+
fileExists?: (filePath: string) => Promise<boolean>;
|
|
236
|
+
listDir?: (dir: string) => Promise<string[]>;
|
|
237
|
+
homeDir?: string;
|
|
238
|
+
platform?: NodeJS.Platform;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Package-runner argv prefix that starts the pinned REA release, or null when none is installed. */
|
|
242
|
+
export function reaRunnerArgv(which: (command: string) => string | null | undefined): string[] | null {
|
|
243
|
+
const spec = `${REA_PACKAGE}@${REA_VERSION}`;
|
|
244
|
+
if (which("npx")) return ["npx", "-y", spec];
|
|
245
|
+
if (which("bunx")) return ["bunx", spec];
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const defaultRun: ReaRunner = async (argv, { cwd, signal, timeoutMs }) => {
|
|
250
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
251
|
+
const combined = signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
252
|
+
const child = Bun.spawn(argv, {
|
|
253
|
+
cwd,
|
|
254
|
+
stdin: "ignore",
|
|
255
|
+
stdout: "pipe",
|
|
256
|
+
stderr: "pipe",
|
|
257
|
+
windowsHide: true,
|
|
258
|
+
signal: combined,
|
|
259
|
+
env: { ...process.env, NO_COLOR: "1", CI: "1" },
|
|
260
|
+
});
|
|
261
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
262
|
+
new Response(child.stdout).text(),
|
|
263
|
+
new Response(child.stderr).text(),
|
|
264
|
+
child.exited,
|
|
265
|
+
]);
|
|
266
|
+
return { exitCode: exitCode ?? 1, stdout, stderr, timedOut: timeout.aborted && !signal?.aborted };
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
/** Replace long strings so a screenshot or script body cannot flood the context. */
|
|
270
|
+
export function elideLargeStrings(value: unknown): unknown {
|
|
271
|
+
if (typeof value === "string") {
|
|
272
|
+
return value.length > MAX_INLINE_STRING
|
|
273
|
+
? `${value.slice(0, 200)}… [${value.length - 200} more chars elided; see saved result]`
|
|
274
|
+
: value;
|
|
275
|
+
}
|
|
276
|
+
if (Array.isArray(value)) return value.map(elideLargeStrings);
|
|
277
|
+
if (value && typeof value === "object") {
|
|
278
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, elideLargeStrings(entry)]));
|
|
279
|
+
}
|
|
280
|
+
return value;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export function summarizeReaOutput(stdout: string): string {
|
|
284
|
+
let text: string;
|
|
285
|
+
try {
|
|
286
|
+
text = JSON.stringify(elideLargeStrings(JSON.parse(stdout)), null, 1);
|
|
287
|
+
} catch {
|
|
288
|
+
text = stdout.trim();
|
|
289
|
+
}
|
|
290
|
+
return text.length > MAX_VISIBLE_CHARS
|
|
291
|
+
? `${text.slice(0, MAX_VISIBLE_CHARS)}\n… [output truncated at ${MAX_VISIBLE_CHARS} chars; read the saved result for the rest]`
|
|
292
|
+
: text;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function lastLines(text: string, count: number): string {
|
|
296
|
+
return text.trim().split("\n").slice(-count).join("\n");
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export class ReverseEngineerTool implements AgentTool<typeof reverseEngineerSchema, ReverseEngineerToolDetails> {
|
|
300
|
+
readonly name = "reverse_engineer";
|
|
301
|
+
readonly summary =
|
|
302
|
+
"Reverse engineer a referenced website, app, or binary (REA) to build one like it: clone, copy, make this, 참고해서 만들어줘, 똑같이 만들어줘";
|
|
303
|
+
readonly loadMode = "discoverable";
|
|
304
|
+
readonly label = "Reverse Engineer";
|
|
305
|
+
readonly description = prompt.render(reverseEngineerDescription, { version: REA_VERSION });
|
|
306
|
+
readonly parameters = reverseEngineerSchema;
|
|
307
|
+
readonly strict = true;
|
|
308
|
+
|
|
309
|
+
readonly #which: (command: string) => string | null | undefined;
|
|
310
|
+
readonly #run: ReaRunner;
|
|
311
|
+
readonly #fileExists: (filePath: string) => Promise<boolean>;
|
|
312
|
+
readonly #listDir: (dir: string) => Promise<string[]>;
|
|
313
|
+
readonly #homeDir: string;
|
|
314
|
+
readonly #platform: NodeJS.Platform;
|
|
315
|
+
|
|
316
|
+
constructor(
|
|
317
|
+
private readonly session: ToolSession,
|
|
318
|
+
deps: ReverseEngineerDeps = {},
|
|
319
|
+
) {
|
|
320
|
+
this.#which = deps.which ?? $which;
|
|
321
|
+
this.#run = deps.run ?? defaultRun;
|
|
322
|
+
this.#fileExists = deps.fileExists ?? (filePath => Bun.file(filePath).exists());
|
|
323
|
+
this.#listDir =
|
|
324
|
+
deps.listDir ??
|
|
325
|
+
(async dir => {
|
|
326
|
+
try {
|
|
327
|
+
return await Array.fromAsync(new Bun.Glob("*").scan({ cwd: dir, onlyFiles: false }));
|
|
328
|
+
} catch {
|
|
329
|
+
return [];
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
this.#homeDir = deps.homeDir ?? (process.env.HOME || process.env.USERPROFILE || "");
|
|
333
|
+
this.#platform = deps.platform ?? process.platform;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
static createIf(session: ToolSession): ReverseEngineerTool | null {
|
|
337
|
+
if (!reaRunnerArgv($which)) return null;
|
|
338
|
+
return new ReverseEngineerTool(session);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
async execute(
|
|
342
|
+
_toolCallId: string,
|
|
343
|
+
params: ReverseEngineerInput,
|
|
344
|
+
signal?: AbortSignal,
|
|
345
|
+
_onUpdate?: unknown,
|
|
346
|
+
_context?: AgentToolContext,
|
|
347
|
+
): Promise<AgentToolResult<ReverseEngineerToolDetails>> {
|
|
348
|
+
return untilAborted(signal, async () => {
|
|
349
|
+
switch (params.op) {
|
|
350
|
+
case "run":
|
|
351
|
+
return this.#runCommand(params, signal);
|
|
352
|
+
case "help":
|
|
353
|
+
return this.#help(params, signal);
|
|
354
|
+
case "browsers":
|
|
355
|
+
return this.#browsers();
|
|
356
|
+
default:
|
|
357
|
+
throw new ToolError(`Unsupported reverse_engineer op: ${String((params as { op: unknown }).op)}`);
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
#runner(): string[] {
|
|
363
|
+
const argv = reaRunnerArgv(this.#which);
|
|
364
|
+
if (!argv) throw new ToolError("REA needs npx (Node.js) or bunx (Bun) on PATH.");
|
|
365
|
+
return argv;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
#command(params: ReverseEngineerInput): string {
|
|
369
|
+
const command = params.command?.trim();
|
|
370
|
+
if (!command) throw new ToolError("command is required");
|
|
371
|
+
if (!COMMAND_SET.has(command)) {
|
|
372
|
+
throw new ToolError(
|
|
373
|
+
`"${command}" is not an allowed REA command. Use kebab-case names such as analyze-javascript-application, capture-browser-scenario, export-web-scripts, analyze, decompile, or inspect-android-package.`,
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
return command;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
async #exec(argv: string[], signal: AbortSignal | undefined, timeoutSeconds: number | undefined) {
|
|
380
|
+
throwIfAborted(signal);
|
|
381
|
+
const seconds = Math.min(Math.max(Math.floor(timeoutSeconds ?? DEFAULT_TIMEOUT_SECONDS), 1), MAX_TIMEOUT_SECONDS);
|
|
382
|
+
try {
|
|
383
|
+
return await this.#run(argv, { cwd: this.session.cwd, signal, timeoutMs: seconds * 1000 });
|
|
384
|
+
} catch (error) {
|
|
385
|
+
if (signal?.aborted) throw new ToolAbortError();
|
|
386
|
+
throw error;
|
|
387
|
+
} finally {
|
|
388
|
+
throwIfAborted(signal);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
async #runCommand(
|
|
393
|
+
params: ReverseEngineerInput,
|
|
394
|
+
signal: AbortSignal | undefined,
|
|
395
|
+
): Promise<AgentToolResult<ReverseEngineerToolDetails>> {
|
|
396
|
+
const command = this.#command(params);
|
|
397
|
+
const args = params.args ?? [];
|
|
398
|
+
const argv = [...this.#runner(), command, ...args];
|
|
399
|
+
if (!args.includes("--format")) argv.push("--format", "json");
|
|
400
|
+
const result = await this.#exec(argv, signal, params.timeout);
|
|
401
|
+
if (result.timedOut) {
|
|
402
|
+
throw new ToolError(`rea ${command} did not finish within the timeout; raise timeout or narrow the request.`);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
let savedPath: string | undefined;
|
|
406
|
+
if (result.stdout.trim()) {
|
|
407
|
+
const artifact = await this.session.allocateOutputArtifact?.("reverse_engineer");
|
|
408
|
+
if (artifact?.path) {
|
|
409
|
+
await publishExplicitArtifactText(artifact.path, result.stdout);
|
|
410
|
+
savedPath = path.resolve(artifact.path);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const header =
|
|
415
|
+
result.exitCode === 0
|
|
416
|
+
? `rea ${command} completed.`
|
|
417
|
+
: `rea ${command} failed with exit code ${result.exitCode}.`;
|
|
418
|
+
const lines = [header];
|
|
419
|
+
if (savedPath) lines.push(`Saved full result: ${savedPath}`);
|
|
420
|
+
if (result.stdout.trim()) lines.push("", summarizeReaOutput(result.stdout));
|
|
421
|
+
else if (result.stderr.trim()) lines.push("", lastLines(result.stderr, 20));
|
|
422
|
+
const details: ReverseEngineerToolDetails = { op: "run", command, exitCode: result.exitCode, savedPath };
|
|
423
|
+
return toolResult<ReverseEngineerToolDetails>(details)
|
|
424
|
+
.text(wrapUntrustedContent(lines.join("\n")))
|
|
425
|
+
.done();
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
async #help(
|
|
429
|
+
params: ReverseEngineerInput,
|
|
430
|
+
signal: AbortSignal | undefined,
|
|
431
|
+
): Promise<AgentToolResult<ReverseEngineerToolDetails>> {
|
|
432
|
+
const command = this.#command(params);
|
|
433
|
+
const runner = this.#runner();
|
|
434
|
+
const usage = await this.#exec([...runner, command, "--help"], signal, params.timeout);
|
|
435
|
+
const schema = await this.#exec([...runner, command, "--schema", "--format", "json"], signal, params.timeout);
|
|
436
|
+
const text = [
|
|
437
|
+
`# rea ${command}`,
|
|
438
|
+
"",
|
|
439
|
+
usage.stdout.trim() || lastLines(usage.stderr, 20),
|
|
440
|
+
"",
|
|
441
|
+
"## Input schema",
|
|
442
|
+
summarizeReaOutput(schema.stdout) || lastLines(schema.stderr, 20),
|
|
443
|
+
].join("\n");
|
|
444
|
+
return toolResult<ReverseEngineerToolDetails>({ op: "help", command }).text(text).done();
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
async #browsers(): Promise<AgentToolResult<ReverseEngineerToolDetails>> {
|
|
448
|
+
const found: string[] = [];
|
|
449
|
+
for (const candidate of BROWSER_CANDIDATES[this.#platform] ?? []) {
|
|
450
|
+
if (await this.#fileExists(candidate)) found.push(candidate);
|
|
451
|
+
}
|
|
452
|
+
for (const name of ["google-chrome", "chromium", "chromium-browser", "microsoft-edge"]) {
|
|
453
|
+
const resolved = this.#which(name);
|
|
454
|
+
if (resolved && !found.includes(resolved)) found.push(resolved);
|
|
455
|
+
}
|
|
456
|
+
found.push(...(await this.#playwrightBrowsers()));
|
|
457
|
+
const text =
|
|
458
|
+
found.length > 0
|
|
459
|
+
? [
|
|
460
|
+
"Chromium-family executables for capture-browser-scenario launch mode:",
|
|
461
|
+
...found.map(f => `- ${f}`),
|
|
462
|
+
].join("\n")
|
|
463
|
+
: "No Chromium-family browser found. Install Google Chrome or run `npx playwright install chromium`, or connect to a running browser with list-browser-targets.";
|
|
464
|
+
return toolResult<ReverseEngineerToolDetails>({ op: "browsers" }).text(text).done();
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/** Browsers installed by Playwright (`npx playwright install chromium`). */
|
|
468
|
+
async #playwrightBrowsers(): Promise<string[]> {
|
|
469
|
+
const cacheDir =
|
|
470
|
+
this.#platform === "darwin"
|
|
471
|
+
? path.join(this.#homeDir, "Library", "Caches", "ms-playwright")
|
|
472
|
+
: this.#platform === "linux"
|
|
473
|
+
? path.join(this.#homeDir, ".cache", "ms-playwright")
|
|
474
|
+
: undefined;
|
|
475
|
+
if (!cacheDir || !this.#homeDir) return [];
|
|
476
|
+
const relative =
|
|
477
|
+
this.#platform === "darwin"
|
|
478
|
+
? [
|
|
479
|
+
"chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",
|
|
480
|
+
"chrome-mac/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",
|
|
481
|
+
"chrome-mac-arm64/Chromium.app/Contents/MacOS/Chromium",
|
|
482
|
+
"chrome-mac/Chromium.app/Contents/MacOS/Chromium",
|
|
483
|
+
]
|
|
484
|
+
: ["chrome-linux64/chrome", "chrome-linux/chrome"];
|
|
485
|
+
const found: string[] = [];
|
|
486
|
+
const entries = (await this.#listDir(cacheDir))
|
|
487
|
+
.filter(entry => /^chromium-\d+$/.test(entry))
|
|
488
|
+
.sort((a, b) => Number(b.slice(9)) - Number(a.slice(9)));
|
|
489
|
+
for (const entry of entries) {
|
|
490
|
+
for (const rel of relative) {
|
|
491
|
+
const candidate = path.join(cacheDir, entry, rel);
|
|
492
|
+
if (await this.#fileExists(candidate)) found.push(candidate);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return found;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
@@ -45,6 +45,8 @@ export interface SearchToolBm25Details {
|
|
|
45
45
|
limit: number;
|
|
46
46
|
total_tools: number;
|
|
47
47
|
activated_tools: string[];
|
|
48
|
+
/** Matching (or, when nothing new matched, all) already-active discovered tools. */
|
|
49
|
+
already_active_tools: string[];
|
|
48
50
|
active_selected_tools: string[];
|
|
49
51
|
tools: SearchToolBm25Match[];
|
|
50
52
|
}
|
|
@@ -65,6 +67,7 @@ function buildSearchToolBm25Content(details: SearchToolBm25Details): string {
|
|
|
65
67
|
return JSON.stringify({
|
|
66
68
|
query: details.query,
|
|
67
69
|
activated_tools: details.activated_tools,
|
|
70
|
+
...(details.already_active_tools.length > 0 ? { already_active_tools: details.already_active_tools } : {}),
|
|
68
71
|
match_count: details.tools.length,
|
|
69
72
|
total_tools: details.total_tools,
|
|
70
73
|
});
|
|
@@ -192,10 +195,17 @@ export class SearchToolBm25Tool implements AgentTool<typeof searchToolBm25Schema
|
|
|
192
195
|
const searchIndex = getDiscoverableToolSearchIndexForExecution(this.session);
|
|
193
196
|
const selectedToolNames = new Set(getSelectedToolNames(this.session));
|
|
194
197
|
let ranked: Array<{ tool: DiscoverableTool; score: number }> = [];
|
|
198
|
+
let alreadyActive: string[] = [];
|
|
195
199
|
try {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
200
|
+
const matches = searchDiscoverableTools(searchIndex, query, searchIndex.documents.length);
|
|
201
|
+
ranked = matches.filter(result => !selectedToolNames.has(result.tool.name)).slice(0, limit);
|
|
202
|
+
alreadyActive = matches
|
|
203
|
+
.filter(result => selectedToolNames.has(result.tool.name))
|
|
204
|
+
.slice(0, limit)
|
|
205
|
+
.map(result => result.tool.name);
|
|
206
|
+
// The session index omits active tools, so a repeated search finds nothing. Say what
|
|
207
|
+
// is already active rather than reporting a bare miss the model reads as "unavailable".
|
|
208
|
+
if (ranked.length === 0 && alreadyActive.length === 0) alreadyActive = [...selectedToolNames];
|
|
199
209
|
} catch (error) {
|
|
200
210
|
if (error instanceof Error) {
|
|
201
211
|
throw new ToolError(error.message);
|
|
@@ -215,6 +225,7 @@ export class SearchToolBm25Tool implements AgentTool<typeof searchToolBm25Schema
|
|
|
215
225
|
limit,
|
|
216
226
|
total_tools: searchIndex.documents.length,
|
|
217
227
|
activated_tools: activated,
|
|
228
|
+
already_active_tools: alreadyActive,
|
|
218
229
|
active_selected_tools: getSelectedToolNames(this.session),
|
|
219
230
|
tools: ranked.map(result => formatMatch(result.tool, result.score)),
|
|
220
231
|
};
|
package/src/tools/search.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
openArchive,
|
|
22
22
|
parseArchivePathCandidates,
|
|
23
23
|
} from "./archive-reader";
|
|
24
|
+
import { wrapUntrustedContent } from "./fetch";
|
|
24
25
|
import { createFileRecorder, formatResultPath } from "./file-recorder";
|
|
25
26
|
import { formatGroupedFiles } from "./grouped-file-output";
|
|
26
27
|
import { formatMatchLine } from "./match-line-format";
|
|
@@ -478,7 +479,7 @@ export class SearchTool implements AgentTool<typeof searchSchema, SearchToolDeta
|
|
|
478
479
|
missingPaths: missingPaths.length > 0 ? missingPaths : undefined,
|
|
479
480
|
};
|
|
480
481
|
const text = warningNote ? `No matches found\n${warningNote}` : "No matches found";
|
|
481
|
-
return toolResult(details).text(text).done();
|
|
482
|
+
return toolResult(details).text(wrapUntrustedContent(text)).done();
|
|
482
483
|
}
|
|
483
484
|
const outputLines: string[] = [];
|
|
484
485
|
let linesTruncated = false;
|
|
@@ -595,7 +596,7 @@ export class SearchTool implements AgentTool<typeof searchSchema, SearchToolDeta
|
|
|
595
596
|
if (truncation.truncated) details.truncation = truncation;
|
|
596
597
|
if (linesTruncated) details.linesTruncated = true;
|
|
597
598
|
const resultBuilder = toolResult(details)
|
|
598
|
-
.text(output)
|
|
599
|
+
.text(wrapUntrustedContent(output))
|
|
599
600
|
.limits({ columnMax: linesTruncated ? DEFAULT_MAX_COLUMN : undefined });
|
|
600
601
|
if (truncation.truncated) {
|
|
601
602
|
resultBuilder.truncation(truncation, { direction: "head" });
|