@sayknow-cli/coding-agent 0.2.2
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 +71 -0
- package/README.md +37 -0
- package/dist/types/async/index.d.ts +2 -0
- package/dist/types/async/job-manager.d.ts +326 -0
- package/dist/types/async/support.d.ts +2 -0
- package/dist/types/autoresearch/dashboard.d.ts +4 -0
- package/dist/types/autoresearch/git.d.ts +36 -0
- package/dist/types/autoresearch/helpers.d.ts +24 -0
- package/dist/types/autoresearch/index.d.ts +2 -0
- package/dist/types/autoresearch/state.d.ts +17 -0
- package/dist/types/autoresearch/storage.d.ts +142 -0
- package/dist/types/autoresearch/tools/init-experiment.d.ts +31 -0
- package/dist/types/autoresearch/tools/log-experiment.d.ts +23 -0
- package/dist/types/autoresearch/tools/run-experiment.d.ts +8 -0
- package/dist/types/autoresearch/tools/update-notes.d.ts +12 -0
- package/dist/types/autoresearch/types.d.ts +154 -0
- package/dist/types/capability/context-file.d.ts +17 -0
- package/dist/types/capability/extension-module.d.ts +15 -0
- package/dist/types/capability/extension.d.ts +28 -0
- package/dist/types/capability/fs.d.ts +20 -0
- package/dist/types/capability/hook.d.ts +19 -0
- package/dist/types/capability/index.d.ts +80 -0
- package/dist/types/capability/instruction.d.ts +17 -0
- package/dist/types/capability/mcp.d.ts +45 -0
- package/dist/types/capability/prompt.d.ts +15 -0
- package/dist/types/capability/rule.d.ts +61 -0
- package/dist/types/capability/settings.d.ts +15 -0
- package/dist/types/capability/skill.d.ts +36 -0
- package/dist/types/capability/slash-command.d.ts +17 -0
- package/dist/types/capability/ssh.d.ts +23 -0
- package/dist/types/capability/system-prompt.d.ts +15 -0
- package/dist/types/capability/tool.d.ts +19 -0
- package/dist/types/capability/types.d.ts +154 -0
- package/dist/types/cli/agents-cli.d.ts +12 -0
- package/dist/types/cli/args.d.ts +56 -0
- package/dist/types/cli/auth-broker-cli.d.ts +25 -0
- package/dist/types/cli/auth-gateway-cli.d.ts +18 -0
- package/dist/types/cli/classify-install-target.d.ts +18 -0
- package/dist/types/cli/commands/init-xdg.d.ts +1 -0
- package/dist/types/cli/config-cli.d.ts +22 -0
- package/dist/types/cli/fast-help.d.ts +1 -0
- package/dist/types/cli/file-processor.d.ts +11 -0
- package/dist/types/cli/grep-cli.d.ts +17 -0
- package/dist/types/cli/initial-message.d.ts +17 -0
- package/dist/types/cli/list-models.d.ts +36 -0
- package/dist/types/cli/plugin-cli.d.ts +32 -0
- package/dist/types/cli/read-cli.d.ts +4 -0
- package/dist/types/cli/session-picker.d.ts +3 -0
- package/dist/types/cli/setup-cli.d.ts +54 -0
- package/dist/types/cli/shell-cli.d.ts +8 -0
- package/dist/types/cli/skills-cli.d.ts +9 -0
- package/dist/types/cli/ssh-cli.d.ts +21 -0
- package/dist/types/cli/stats-cli.d.ts +17 -0
- package/dist/types/cli/update-cli.d.ts +41 -0
- package/dist/types/cli/web-search-cli.d.ts +32 -0
- package/dist/types/cli/worktree-cli.d.ts +26 -0
- package/dist/types/cli.d.ts +3 -0
- package/dist/types/commands/acp.d.ts +12 -0
- package/dist/types/commands/agents.d.ts +34 -0
- package/dist/types/commands/auth-broker.d.ts +54 -0
- package/dist/types/commands/auth-gateway.d.ts +32 -0
- package/dist/types/commands/codex-native-hook.d.ts +6 -0
- package/dist/types/commands/commit.d.ts +27 -0
- package/dist/types/commands/config.d.ts +30 -0
- package/dist/types/commands/contribution-prep.d.ts +18 -0
- package/dist/types/commands/coordinator.d.ts +19 -0
- package/dist/types/commands/deep-interview.d.ts +51 -0
- package/dist/types/commands/gc.d.ts +26 -0
- package/dist/types/commands/grep.d.ts +42 -0
- package/dist/types/commands/harness.d.ts +43 -0
- package/dist/types/commands/launch.d.ts +127 -0
- package/dist/types/commands/mcp-serve.d.ts +24 -0
- package/dist/types/commands/plugin.d.ts +52 -0
- package/dist/types/commands/ralplan.d.ts +7 -0
- package/dist/types/commands/read.d.ts +15 -0
- package/dist/types/commands/rlm.d.ts +10 -0
- package/dist/types/commands/session.d.ts +24 -0
- package/dist/types/commands/setup.d.ts +105 -0
- package/dist/types/commands/shell.d.ts +21 -0
- package/dist/types/commands/skills.d.ts +26 -0
- package/dist/types/commands/ssh.d.ts +48 -0
- package/dist/types/commands/state.d.ts +7 -0
- package/dist/types/commands/stats.d.ts +25 -0
- package/dist/types/commands/team.d.ts +24 -0
- package/dist/types/commands/ultragoal.d.ts +8 -0
- package/dist/types/commands/update.d.ts +20 -0
- package/dist/types/commands/web-search.d.ts +87 -0
- package/dist/types/commands/worktree.d.ts +34 -0
- package/dist/types/commit/agentic/agent.d.ts +31 -0
- package/dist/types/commit/agentic/fallback.d.ts +5 -0
- package/dist/types/commit/agentic/index.d.ts +2 -0
- package/dist/types/commit/agentic/state.d.ts +58 -0
- package/dist/types/commit/agentic/tools/analyze-file.d.ts +19 -0
- package/dist/types/commit/agentic/tools/git-file-diff.d.ts +10 -0
- package/dist/types/commit/agentic/tools/git-hunk.d.ts +9 -0
- package/dist/types/commit/agentic/tools/git-overview.d.ts +9 -0
- package/dist/types/commit/agentic/tools/index.d.ts +16 -0
- package/dist/types/commit/agentic/tools/propose-changelog.d.ts +28 -0
- package/dist/types/commit/agentic/tools/propose-commit.d.ts +36 -0
- package/dist/types/commit/agentic/tools/recent-commits.d.ts +7 -0
- package/dist/types/commit/agentic/tools/schemas.d.ts +27 -0
- package/dist/types/commit/agentic/tools/split-commit.d.ts +53 -0
- package/dist/types/commit/agentic/topo-sort.d.ts +4 -0
- package/dist/types/commit/agentic/trivial.d.ts +7 -0
- package/dist/types/commit/agentic/validation.d.ts +20 -0
- package/dist/types/commit/analysis/conventional.d.ts +22 -0
- package/dist/types/commit/analysis/index.d.ts +4 -0
- package/dist/types/commit/analysis/scope.d.ts +6 -0
- package/dist/types/commit/analysis/summary.d.ts +19 -0
- package/dist/types/commit/analysis/validation.d.ts +8 -0
- package/dist/types/commit/changelog/detect.d.ts +2 -0
- package/dist/types/commit/changelog/generate.d.ts +30 -0
- package/dist/types/commit/changelog/index.d.ts +30 -0
- package/dist/types/commit/changelog/parse.d.ts +2 -0
- package/dist/types/commit/cli.d.ts +3 -0
- package/dist/types/commit/git/diff.d.ts +5 -0
- package/dist/types/commit/index.d.ts +4 -0
- package/dist/types/commit/map-reduce/index.d.ts +28 -0
- package/dist/types/commit/map-reduce/map-phase.d.ts +17 -0
- package/dist/types/commit/map-reduce/reduce-phase.d.ts +13 -0
- package/dist/types/commit/map-reduce/utils.d.ts +2 -0
- package/dist/types/commit/message.d.ts +2 -0
- package/dist/types/commit/model-selection.d.ts +15 -0
- package/dist/types/commit/pipeline.d.ts +5 -0
- package/dist/types/commit/shared-llm.d.ts +54 -0
- package/dist/types/commit/types.d.ts +78 -0
- package/dist/types/commit/utils/exclusions.d.ts +4 -0
- package/dist/types/commit/utils.d.ts +20 -0
- package/dist/types/config/config-file.d.ts +58 -0
- package/dist/types/config/file-lock-gc.d.ts +5 -0
- package/dist/types/config/file-lock.d.ts +35 -0
- package/dist/types/config/keybindings.d.ts +349 -0
- package/dist/types/config/model-equivalence.d.ts +24 -0
- package/dist/types/config/model-profile-activation.d.ts +39 -0
- package/dist/types/config/model-profiles.d.ts +37 -0
- package/dist/types/config/model-registry.d.ts +457 -0
- package/dist/types/config/model-resolver.d.ts +217 -0
- package/dist/types/config/models-config-schema.d.ts +690 -0
- package/dist/types/config/prompt-templates.d.ts +32 -0
- package/dist/types/config/resolve-config-value.d.ts +17 -0
- package/dist/types/config/settings-schema.d.ts +3581 -0
- package/dist/types/config/settings.d.ts +134 -0
- package/dist/types/config/skill-settings-defaults.d.ts +14 -0
- package/dist/types/config.d.ts +66 -0
- package/dist/types/coordinator/contract.d.ts +4 -0
- package/dist/types/coordinator-mcp/policy.d.ts +24 -0
- package/dist/types/coordinator-mcp/safety.d.ts +26 -0
- package/dist/types/coordinator-mcp/server.d.ts +58 -0
- package/dist/types/cursor.d.ts +24 -0
- package/dist/types/dap/client.d.ts +39 -0
- package/dist/types/dap/config.d.ts +6 -0
- package/dist/types/dap/index.d.ts +4 -0
- package/dist/types/dap/session.d.ts +108 -0
- package/dist/types/dap/types.d.ts +524 -0
- package/dist/types/debug/crash-diagnostics.d.ts +45 -0
- package/dist/types/debug/index.d.ts +15 -0
- package/dist/types/debug/log-formatting.d.ts +4 -0
- package/dist/types/debug/log-viewer.d.ts +68 -0
- package/dist/types/debug/profiler.d.ts +24 -0
- package/dist/types/debug/raw-sse-buffer.d.ts +44 -0
- package/dist/types/debug/raw-sse.d.ts +16 -0
- package/dist/types/debug/report-bundle.d.ts +55 -0
- package/dist/types/debug/runtime-gauges.d.ts +6 -0
- package/dist/types/debug/system-info.d.ts +26 -0
- package/dist/types/deep-interview/render-middleware.d.ts +6 -0
- package/dist/types/defaults/skc/extensions/grok-build/index.d.ts +1 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/index.d.ts +1 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/models/catalog.d.ts +25 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/payload/sanitize.d.ts +27 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/provider/billing.d.ts +8 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/provider/register.d.ts +5 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/provider/stream.d.ts +10 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/provider/usage.d.ts +2 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/shared/base-url.d.ts +2 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/shared/errors.d.ts +38 -0
- package/dist/types/defaults/skc-defaults.d.ts +57 -0
- package/dist/types/defaults/skc-grok-cli.d.ts +5 -0
- package/dist/types/discovery/agents-md.d.ts +1 -0
- package/dist/types/discovery/agents.d.ts +12 -0
- package/dist/types/discovery/builtin.d.ts +1 -0
- package/dist/types/discovery/claude-plugins.d.ts +1 -0
- package/dist/types/discovery/claude.d.ts +1 -0
- package/dist/types/discovery/cline.d.ts +1 -0
- package/dist/types/discovery/codex.d.ts +1 -0
- package/dist/types/discovery/cursor.d.ts +16 -0
- package/dist/types/discovery/gemini.d.ts +1 -0
- package/dist/types/discovery/github.d.ts +1 -0
- package/dist/types/discovery/helpers.d.ts +271 -0
- package/dist/types/discovery/index.d.ts +48 -0
- package/dist/types/discovery/mcp-json.d.ts +1 -0
- package/dist/types/discovery/opencode.d.ts +1 -0
- package/dist/types/discovery/plugin-dir-roots.d.ts +15 -0
- package/dist/types/discovery/ssh.d.ts +1 -0
- package/dist/types/discovery/substitute-plugin-root.d.ts +5 -0
- package/dist/types/discovery/vscode.d.ts +1 -0
- package/dist/types/discovery/windsurf.d.ts +13 -0
- package/dist/types/edit/apply-patch/index.d.ts +35 -0
- package/dist/types/edit/apply-patch/parser.d.ts +34 -0
- package/dist/types/edit/diff.d.ts +75 -0
- package/dist/types/edit/file-read-cache.d.ts +25 -0
- package/dist/types/edit/index.d.ts +58 -0
- package/dist/types/edit/modes/apply-patch.d.ts +24 -0
- package/dist/types/edit/modes/patch.d.ts +99 -0
- package/dist/types/edit/modes/replace.d.ts +149 -0
- package/dist/types/edit/normalize.d.ts +43 -0
- package/dist/types/edit/notebook.d.ts +26 -0
- package/dist/types/edit/read-file.d.ts +8 -0
- package/dist/types/edit/renderer.d.ts +110 -0
- package/dist/types/edit/streaming.d.ts +66 -0
- package/dist/types/eval/backend.d.ts +40 -0
- package/dist/types/eval/index.d.ts +4 -0
- package/dist/types/eval/js/context-manager.d.ts +27 -0
- package/dist/types/eval/js/executor.d.ts +29 -0
- package/dist/types/eval/js/index.d.ts +10 -0
- package/dist/types/eval/js/shared/helpers.d.ts +38 -0
- package/dist/types/eval/js/shared/indirect-eval.d.ts +14 -0
- package/dist/types/eval/js/shared/prelude.d.ts +1 -0
- package/dist/types/eval/js/shared/rewrite-imports.d.ts +6 -0
- package/dist/types/eval/js/shared/runtime.d.ts +47 -0
- package/dist/types/eval/js/shared/types.d.ts +24 -0
- package/dist/types/eval/js/tool-bridge.d.ts +18 -0
- package/dist/types/eval/js/worker-core.d.ts +5 -0
- package/dist/types/eval/js/worker-entry.d.ts +1 -0
- package/dist/types/eval/js/worker-protocol.d.ts +77 -0
- package/dist/types/eval/py/display.d.ts +25 -0
- package/dist/types/eval/py/executor.d.ts +88 -0
- package/dist/types/eval/py/index.d.ts +10 -0
- package/dist/types/eval/py/kernel.d.ts +65 -0
- package/dist/types/eval/py/prelude.d.ts +1 -0
- package/dist/types/eval/py/runtime.d.ts +29 -0
- package/dist/types/eval/py/tool-bridge.d.ts +20 -0
- package/dist/types/eval/types.d.ts +52 -0
- package/dist/types/exa/factory.d.ts +13 -0
- package/dist/types/exa/index.d.ts +20 -0
- package/dist/types/exa/mcp-client.d.ts +45 -0
- package/dist/types/exa/render.d.ts +19 -0
- package/dist/types/exa/researcher.d.ts +9 -0
- package/dist/types/exa/search.d.ts +9 -0
- package/dist/types/exa/types.d.ts +155 -0
- package/dist/types/exa/websets.d.ts +9 -0
- package/dist/types/exec/bash-executor.d.ts +64 -0
- package/dist/types/exec/exec.d.ts +25 -0
- package/dist/types/exec/idle-timeout-watchdog.d.ts +18 -0
- package/dist/types/exec/non-interactive-env.d.ts +1 -0
- package/dist/types/export/custom-share.d.ts +20 -0
- package/dist/types/export/html/index.d.ts +10 -0
- package/dist/types/export/html/template.generated.d.ts +1 -0
- package/dist/types/export/html/template.macro.d.ts +5 -0
- package/dist/types/export/ttsr.d.ts +44 -0
- package/dist/types/extensibility/custom-commands/bundled/ci-green/index.d.ts +9 -0
- package/dist/types/extensibility/custom-commands/bundled/review/index.d.ts +10 -0
- package/dist/types/extensibility/custom-commands/index.d.ts +2 -0
- package/dist/types/extensibility/custom-commands/loader.d.ts +29 -0
- package/dist/types/extensibility/custom-commands/types.d.ts +106 -0
- package/dist/types/extensibility/custom-tools/index.d.ts +6 -0
- package/dist/types/extensibility/custom-tools/loader.d.ts +69 -0
- package/dist/types/extensibility/custom-tools/types.d.ts +229 -0
- package/dist/types/extensibility/custom-tools/wrapper.d.ts +24 -0
- package/dist/types/extensibility/extensions/compact-handler.d.ts +26 -0
- package/dist/types/extensibility/extensions/get-commands-handler.d.ts +29 -0
- package/dist/types/extensibility/extensions/index.d.ts +9 -0
- package/dist/types/extensibility/extensions/loader.d.ts +43 -0
- package/dist/types/extensibility/extensions/prefix-command-bridge.d.ts +35 -0
- package/dist/types/extensibility/extensions/runner.d.ts +134 -0
- package/dist/types/extensibility/extensions/types.d.ts +891 -0
- package/dist/types/extensibility/extensions/wrapper.d.ts +55 -0
- package/dist/types/extensibility/hooks/index.d.ts +5 -0
- package/dist/types/extensibility/hooks/loader.d.ts +89 -0
- package/dist/types/extensibility/hooks/runner.d.ts +126 -0
- package/dist/types/extensibility/hooks/tool-wrapper.d.ts +25 -0
- package/dist/types/extensibility/hooks/types.d.ts +431 -0
- package/dist/types/extensibility/plugins/doctor.d.ts +3 -0
- package/dist/types/extensibility/plugins/git-url.d.ts +34 -0
- package/dist/types/extensibility/plugins/index.d.ts +7 -0
- package/dist/types/extensibility/plugins/installer.d.ts +5 -0
- package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +2 -0
- package/dist/types/extensibility/plugins/loader.d.ts +31 -0
- package/dist/types/extensibility/plugins/manager.d.ts +65 -0
- package/dist/types/extensibility/plugins/marketplace/cache.d.ts +41 -0
- package/dist/types/extensibility/plugins/marketplace/fetcher.d.ts +48 -0
- package/dist/types/extensibility/plugins/marketplace/index.d.ts +6 -0
- package/dist/types/extensibility/plugins/marketplace/manager.d.ts +57 -0
- package/dist/types/extensibility/plugins/marketplace/registry.d.ts +34 -0
- package/dist/types/extensibility/plugins/marketplace/source-resolver.d.ts +28 -0
- package/dist/types/extensibility/plugins/marketplace/types.d.ts +130 -0
- package/dist/types/extensibility/plugins/parser.d.ts +52 -0
- package/dist/types/extensibility/plugins/types.d.ts +149 -0
- package/dist/types/extensibility/shared-events.d.ts +280 -0
- package/dist/types/extensibility/skc-plugins/activation.d.ts +14 -0
- package/dist/types/extensibility/skc-plugins/index.d.ts +9 -0
- package/dist/types/extensibility/skc-plugins/injection.d.ts +31 -0
- package/dist/types/extensibility/skc-plugins/loader.d.ts +3 -0
- package/dist/types/extensibility/skc-plugins/paths.d.ts +8 -0
- package/dist/types/extensibility/skc-plugins/schema.d.ts +3 -0
- package/dist/types/extensibility/skc-plugins/state.d.ts +9 -0
- package/dist/types/extensibility/skc-plugins/tools.d.ts +8 -0
- package/dist/types/extensibility/skc-plugins/types.d.ts +64 -0
- package/dist/types/extensibility/skc-plugins/validation.d.ts +4 -0
- package/dist/types/extensibility/skills.d.ts +82 -0
- package/dist/types/extensibility/slash-commands.d.ts +48 -0
- package/dist/types/extensibility/tool-proxy.d.ts +4 -0
- package/dist/types/extensibility/typebox.d.ts +155 -0
- package/dist/types/extensibility/utils.d.ts +12 -0
- package/dist/types/goals/index.d.ts +3 -0
- package/dist/types/goals/runtime.d.ts +62 -0
- package/dist/types/goals/state.d.ts +32 -0
- package/dist/types/goals/tools/goal-tool.d.ts +62 -0
- package/dist/types/harness-control-plane/classifier.d.ts +13 -0
- package/dist/types/harness-control-plane/control-endpoint.d.ts +31 -0
- package/dist/types/harness-control-plane/finalize.d.ts +60 -0
- package/dist/types/harness-control-plane/gc-adapter.d.ts +3 -0
- package/dist/types/harness-control-plane/operate.d.ts +35 -0
- package/dist/types/harness-control-plane/owner.d.ts +53 -0
- package/dist/types/harness-control-plane/phase-rollup.d.ts +23 -0
- package/dist/types/harness-control-plane/preserve.d.ts +19 -0
- package/dist/types/harness-control-plane/receipt-ingest.d.ts +19 -0
- package/dist/types/harness-control-plane/receipt-spool.d.ts +19 -0
- package/dist/types/harness-control-plane/receipts.d.ts +149 -0
- package/dist/types/harness-control-plane/rpc-adapter.d.ts +69 -0
- package/dist/types/harness-control-plane/seams.d.ts +21 -0
- package/dist/types/harness-control-plane/session-lease.d.ts +65 -0
- package/dist/types/harness-control-plane/state-machine.d.ts +24 -0
- package/dist/types/harness-control-plane/storage.d.ts +80 -0
- package/dist/types/harness-control-plane/types.d.ts +187 -0
- package/dist/types/hashline/anchors.d.ts +20 -0
- package/dist/types/hashline/apply.d.ts +14 -0
- package/dist/types/hashline/constants.d.ts +19 -0
- package/dist/types/hashline/diff-preview.d.ts +2 -0
- package/dist/types/hashline/diff.d.ts +17 -0
- package/dist/types/hashline/execute.d.ts +4 -0
- package/dist/types/hashline/hash.d.ts +123 -0
- package/dist/types/hashline/index.d.ts +13 -0
- package/dist/types/hashline/input.d.ts +11 -0
- package/dist/types/hashline/parser.d.ts +7 -0
- package/dist/types/hashline/prefixes.d.ts +7 -0
- package/dist/types/hashline/recovery.d.ts +27 -0
- package/dist/types/hashline/stream.d.ts +2 -0
- package/dist/types/hashline/types.d.ts +77 -0
- package/dist/types/hindsight/backend.d.ts +13 -0
- package/dist/types/hindsight/bank.d.ts +54 -0
- package/dist/types/hindsight/client.d.ts +224 -0
- package/dist/types/hindsight/config.d.ts +51 -0
- package/dist/types/hindsight/content.d.ts +70 -0
- package/dist/types/hindsight/index.d.ts +8 -0
- package/dist/types/hindsight/mental-models.d.ts +125 -0
- package/dist/types/hindsight/state.d.ts +99 -0
- package/dist/types/hindsight/transcript.d.ts +28 -0
- package/dist/types/hooks/codex-native-hooks-config.d.ts +29 -0
- package/dist/types/hooks/native-skill-hook.d.ts +16 -0
- package/dist/types/hooks/skill-keywords.d.ts +18 -0
- package/dist/types/hooks/skill-state.d.ts +85 -0
- package/dist/types/i18n/index.d.ts +38 -0
- package/dist/types/i18n/messages/de.d.ts +2 -0
- package/dist/types/i18n/messages/de.messages.d.ts +1 -0
- package/dist/types/i18n/messages/de.settings.d.ts +1 -0
- package/dist/types/i18n/messages/en.d.ts +66 -0
- package/dist/types/i18n/messages/es.d.ts +2 -0
- package/dist/types/i18n/messages/es.messages.d.ts +1 -0
- package/dist/types/i18n/messages/es.settings.d.ts +1 -0
- package/dist/types/i18n/messages/fr.d.ts +2 -0
- package/dist/types/i18n/messages/fr.messages.d.ts +1 -0
- package/dist/types/i18n/messages/fr.settings.d.ts +1 -0
- package/dist/types/i18n/messages/ja.d.ts +2 -0
- package/dist/types/i18n/messages/ja.messages.d.ts +1 -0
- package/dist/types/i18n/messages/ja.settings.d.ts +1 -0
- package/dist/types/i18n/messages/ko.d.ts +2 -0
- package/dist/types/i18n/messages/ko.messages.d.ts +1 -0
- package/dist/types/i18n/messages/ko.settings.d.ts +1 -0
- package/dist/types/i18n/messages/zh.d.ts +2 -0
- package/dist/types/i18n/messages/zh.messages.d.ts +1 -0
- package/dist/types/i18n/messages/zh.settings.d.ts +1 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/internal-urls/agent-protocol.d.ts +12 -0
- package/dist/types/internal-urls/artifact-protocol.d.ts +6 -0
- package/dist/types/internal-urls/docs-index.generated.d.ts +2 -0
- package/dist/types/internal-urls/index.d.ts +20 -0
- package/dist/types/internal-urls/issue-pr-protocol.d.ts +17 -0
- package/dist/types/internal-urls/json-query.d.ts +30 -0
- package/dist/types/internal-urls/local-protocol.d.ts +39 -0
- package/dist/types/internal-urls/mcp-protocol.d.ts +12 -0
- package/dist/types/internal-urls/memory-protocol.d.ts +23 -0
- package/dist/types/internal-urls/parse.d.ts +19 -0
- package/dist/types/internal-urls/registry-helpers.d.ts +11 -0
- package/dist/types/internal-urls/router.d.ts +14 -0
- package/dist/types/internal-urls/rule-protocol.d.ts +6 -0
- package/dist/types/internal-urls/skc-protocol.d.ts +12 -0
- package/dist/types/internal-urls/skill-protocol.d.ts +13 -0
- package/dist/types/internal-urls/types.d.ts +109 -0
- package/dist/types/lsp/client.d.ts +66 -0
- package/dist/types/lsp/clients/biome-client.d.ts +16 -0
- package/dist/types/lsp/clients/index.d.ts +19 -0
- package/dist/types/lsp/clients/lsp-linter-client.d.ts +16 -0
- package/dist/types/lsp/clients/swiftlint-client.d.ts +20 -0
- package/dist/types/lsp/config.d.ts +65 -0
- package/dist/types/lsp/edits.d.ts +23 -0
- package/dist/types/lsp/index.d.ts +130 -0
- package/dist/types/lsp/lspmux.d.ts +58 -0
- package/dist/types/lsp/render.d.ts +32 -0
- package/dist/types/lsp/startup-events.d.ts +11 -0
- package/dist/types/lsp/types.d.ts +304 -0
- package/dist/types/lsp/utils.d.ts +108 -0
- package/dist/types/main.d.ts +70 -0
- package/dist/types/memories/index.d.ts +28 -0
- package/dist/types/memories/storage.d.ts +110 -0
- package/dist/types/memory-backend/index.d.ts +4 -0
- package/dist/types/memory-backend/local-backend.d.ts +9 -0
- package/dist/types/memory-backend/off-backend.d.ts +7 -0
- package/dist/types/memory-backend/resolve.d.ts +15 -0
- package/dist/types/memory-backend/types.d.ts +61 -0
- package/dist/types/modes/acp/acp-agent.d.ts +61 -0
- package/dist/types/modes/acp/acp-client-bridge.d.ts +9 -0
- package/dist/types/modes/acp/acp-event-mapper.d.ts +34 -0
- package/dist/types/modes/acp/acp-mode.d.ts +5 -0
- package/dist/types/modes/acp/index.d.ts +2 -0
- package/dist/types/modes/acp/terminal-auth.d.ts +6 -0
- package/dist/types/modes/bridge/auth.d.ts +12 -0
- package/dist/types/modes/bridge/bridge-client-bridge.d.ts +9 -0
- package/dist/types/modes/bridge/bridge-mode.d.ts +47 -0
- package/dist/types/modes/bridge/bridge-ui-context.d.ts +88 -0
- package/dist/types/modes/bridge/event-stream.d.ts +8 -0
- package/dist/types/modes/components/agent-dashboard.d.ts +21 -0
- package/dist/types/modes/components/assistant-message.d.ts +16 -0
- package/dist/types/modes/components/bash-execution.d.ts +29 -0
- package/dist/types/modes/components/bordered-loader.d.ts +11 -0
- package/dist/types/modes/components/branch-summary-message.d.ts +13 -0
- package/dist/types/modes/components/btw-panel.d.ts +16 -0
- package/dist/types/modes/components/compaction-summary-message.d.ts +13 -0
- package/dist/types/modes/components/countdown-timer.d.ts +14 -0
- package/dist/types/modes/components/custom-editor.d.ts +62 -0
- package/dist/types/modes/components/custom-message.d.ts +15 -0
- package/dist/types/modes/components/custom-model-preset-wizard.d.ts +12 -0
- package/dist/types/modes/components/custom-provider-wizard.d.ts +10 -0
- package/dist/types/modes/components/diff.d.ts +11 -0
- package/dist/types/modes/components/dynamic-border.d.ts +14 -0
- package/dist/types/modes/components/eval-execution.d.ts +23 -0
- package/dist/types/modes/components/execution-shared.d.ts +46 -0
- package/dist/types/modes/components/extensions/extension-dashboard.d.ts +26 -0
- package/dist/types/modes/components/extensions/extension-list.d.ts +39 -0
- package/dist/types/modes/components/extensions/index.d.ts +8 -0
- package/dist/types/modes/components/extensions/inspector-panel.d.ts +8 -0
- package/dist/types/modes/components/extensions/state-manager.d.ts +50 -0
- package/dist/types/modes/components/extensions/types.d.ts +151 -0
- package/dist/types/modes/components/footer.d.ts +30 -0
- package/dist/types/modes/components/history-search.d.ts +7 -0
- package/dist/types/modes/components/hook-editor.d.ts +18 -0
- package/dist/types/modes/components/hook-input.d.ts +15 -0
- package/dist/types/modes/components/hook-message.d.ts +15 -0
- package/dist/types/modes/components/hook-selector.d.ts +48 -0
- package/dist/types/modes/components/index.d.ts +35 -0
- package/dist/types/modes/components/jobs-overlay-model.d.ts +31 -0
- package/dist/types/modes/components/jobs-overlay.d.ts +30 -0
- package/dist/types/modes/components/keybinding-hints.d.ts +40 -0
- package/dist/types/modes/components/login-dialog.d.ts +32 -0
- package/dist/types/modes/components/message-frame.d.ts +42 -0
- package/dist/types/modes/components/model-selector.d.ts +46 -0
- package/dist/types/modes/components/oauth-selector.d.ts +15 -0
- package/dist/types/modes/components/plugin-selector.d.ts +26 -0
- package/dist/types/modes/components/plugin-settings.d.ts +66 -0
- package/dist/types/modes/components/provider-onboarding-selector.d.ts +7 -0
- package/dist/types/modes/components/queue-mode-selector.d.ts +9 -0
- package/dist/types/modes/components/read-tool-group.d.ts +30 -0
- package/dist/types/modes/components/runtime-mcp-add-wizard.d.ts +26 -0
- package/dist/types/modes/components/session-observer-overlay.d.ts +11 -0
- package/dist/types/modes/components/session-selector.d.ts +30 -0
- package/dist/types/modes/components/settings-defs.d.ts +50 -0
- package/dist/types/modes/components/settings-selector.d.ts +56 -0
- package/dist/types/modes/components/show-images-selector.d.ts +9 -0
- package/dist/types/modes/components/skill-hud/render.d.ts +2 -0
- package/dist/types/modes/components/skill-message.d.ts +9 -0
- package/dist/types/modes/components/status-line/context-thresholds.d.ts +4 -0
- package/dist/types/modes/components/status-line/git-utils.d.ts +22 -0
- package/dist/types/modes/components/status-line/index.d.ts +4 -0
- package/dist/types/modes/components/status-line/presets.d.ts +3 -0
- package/dist/types/modes/components/status-line/segments.d.ts +5 -0
- package/dist/types/modes/components/status-line/separators.d.ts +3 -0
- package/dist/types/modes/components/status-line/token-rate.d.ts +10 -0
- package/dist/types/modes/components/status-line/types.d.ts +79 -0
- package/dist/types/modes/components/status-line.d.ts +82 -0
- package/dist/types/modes/components/theme-selector.d.ts +10 -0
- package/dist/types/modes/components/thinking-selector.d.ts +10 -0
- package/dist/types/modes/components/todo-reminder.d.ts +13 -0
- package/dist/types/modes/components/tool-execution.d.ts +54 -0
- package/dist/types/modes/components/tree-selector.d.ts +31 -0
- package/dist/types/modes/components/ttsr-notification.d.ts +13 -0
- package/dist/types/modes/components/user-message-selector.d.ts +28 -0
- package/dist/types/modes/components/user-message.d.ts +7 -0
- package/dist/types/modes/components/visual-truncate.d.ts +19 -0
- package/dist/types/modes/components/welcome.d.ts +35 -0
- package/dist/types/modes/controllers/btw-controller.d.ts +10 -0
- package/dist/types/modes/controllers/command-controller-shared.d.ts +47 -0
- package/dist/types/modes/controllers/command-controller.d.ts +38 -0
- package/dist/types/modes/controllers/event-controller.d.ts +12 -0
- package/dist/types/modes/controllers/extension-ui-controller.d.ts +80 -0
- package/dist/types/modes/controllers/input-controller.d.ts +39 -0
- package/dist/types/modes/controllers/runtime-mcp-command-controller.d.ts +10 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +57 -0
- package/dist/types/modes/controllers/ssh-command-controller.d.ts +10 -0
- package/dist/types/modes/controllers/todo-command-controller.d.ts +7 -0
- package/dist/types/modes/emoji-autocomplete.d.ts +16 -0
- package/dist/types/modes/index.d.ts +10 -0
- package/dist/types/modes/interactive-mode.d.ts +266 -0
- package/dist/types/modes/jobs-observer.d.ts +57 -0
- package/dist/types/modes/oauth-manual-input.d.ts +8 -0
- package/dist/types/modes/print-mode.d.ts +33 -0
- package/dist/types/modes/prompt-action-autocomplete.d.ts +46 -0
- package/dist/types/modes/rpc/host-tools.d.ts +1 -0
- package/dist/types/modes/rpc/host-uris.d.ts +1 -0
- package/dist/types/modes/rpc/rpc-client.d.ts +288 -0
- package/dist/types/modes/rpc/rpc-mode.d.ts +87 -0
- package/dist/types/modes/rpc/rpc-socket-security.d.ts +7 -0
- package/dist/types/modes/rpc/rpc-types.d.ts +779 -0
- package/dist/types/modes/runtime-init.d.ts +21 -0
- package/dist/types/modes/session-observer-registry.d.ts +26 -0
- package/dist/types/modes/shared/agent-wire/approval-gate.d.ts +57 -0
- package/dist/types/modes/shared/agent-wire/command-contract.d.ts +18 -0
- package/dist/types/modes/shared/agent-wire/command-dispatch.d.ts +37 -0
- package/dist/types/modes/shared/agent-wire/command-validation.d.ts +2 -0
- package/dist/types/modes/shared/agent-wire/deep-interview-gate.d.ts +60 -0
- package/dist/types/modes/shared/agent-wire/event-contract.d.ts +84 -0
- package/dist/types/modes/shared/agent-wire/event-envelope.d.ts +38 -0
- package/dist/types/modes/shared/agent-wire/event-observation.d.ts +37 -0
- package/dist/types/modes/shared/agent-wire/handshake.d.ts +56 -0
- package/dist/types/modes/shared/agent-wire/host-tool-bridge.d.ts +16 -0
- package/dist/types/modes/shared/agent-wire/host-uri-bridge.d.ts +17 -0
- package/dist/types/modes/shared/agent-wire/protocol.d.ts +25 -0
- package/dist/types/modes/shared/agent-wire/responses.d.ts +4 -0
- package/dist/types/modes/shared/agent-wire/scopes.d.ts +18 -0
- package/dist/types/modes/shared/agent-wire/session-registry.d.ts +25 -0
- package/dist/types/modes/shared/agent-wire/ui-request-broker.d.ts +42 -0
- package/dist/types/modes/shared/agent-wire/ui-result.d.ts +27 -0
- package/dist/types/modes/shared/agent-wire/unattended-action-policy.d.ts +29 -0
- package/dist/types/modes/shared/agent-wire/unattended-audit.d.ts +68 -0
- package/dist/types/modes/shared/agent-wire/unattended-run-controller.d.ts +161 -0
- package/dist/types/modes/shared/agent-wire/unattended-session.d.ts +72 -0
- package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +114 -0
- package/dist/types/modes/shared/agent-wire/workflow-gate-schema.d.ts +39 -0
- package/dist/types/modes/shared.d.ts +15 -0
- package/dist/types/modes/theme/defaults/index.d.ts +553 -0
- package/dist/types/modes/theme/mermaid-cache.d.ts +9 -0
- package/dist/types/modes/theme/shimmer.d.ts +38 -0
- package/dist/types/modes/theme/theme.d.ts +275 -0
- package/dist/types/modes/types.d.ts +278 -0
- package/dist/types/modes/utils/abort-message.d.ts +4 -0
- package/dist/types/modes/utils/context-usage.d.ts +51 -0
- package/dist/types/modes/utils/hotkeys-markdown.d.ts +5 -0
- package/dist/types/modes/utils/keybinding-matchers.d.ts +10 -0
- package/dist/types/modes/utils/tools-markdown.d.ts +5 -0
- package/dist/types/modes/utils/ui-helpers.d.ts +53 -0
- package/dist/types/plan-mode/approved-plan.d.ts +49 -0
- package/dist/types/plan-mode/state.d.ts +6 -0
- package/dist/types/registry/agent-registry.d.ts +62 -0
- package/dist/types/reminders/star-reminder.d.ts +115 -0
- package/dist/types/rlm/artifacts.d.ts +9 -0
- package/dist/types/rlm/complete-research-tool.d.ts +35 -0
- package/dist/types/rlm/data-context.d.ts +6 -0
- package/dist/types/rlm/index.d.ts +35 -0
- package/dist/types/rlm/notebook.d.ts +12 -0
- package/dist/types/rlm/preset.d.ts +23 -0
- package/dist/types/rlm/python-tool.d.ts +16 -0
- package/dist/types/rlm/report.d.ts +14 -0
- package/dist/types/rlm/types.d.ts +37 -0
- package/dist/types/runtime/process-lifecycle.d.ts +108 -0
- package/dist/types/runtime-mcp/client.d.ts +74 -0
- package/dist/types/runtime-mcp/config-writer.d.ts +53 -0
- package/dist/types/runtime-mcp/config.d.ts +75 -0
- package/dist/types/runtime-mcp/discoverable-tool-metadata.d.ts +7 -0
- package/dist/types/runtime-mcp/index.d.ts +18 -0
- package/dist/types/runtime-mcp/json-rpc.d.ts +22 -0
- package/dist/types/runtime-mcp/loader.d.ts +43 -0
- package/dist/types/runtime-mcp/manager.d.ts +193 -0
- package/dist/types/runtime-mcp/oauth-discovery.d.ts +40 -0
- package/dist/types/runtime-mcp/oauth-flow.d.ts +59 -0
- package/dist/types/runtime-mcp/render.d.ts +25 -0
- package/dist/types/runtime-mcp/smithery-auth.d.ts +16 -0
- package/dist/types/runtime-mcp/smithery-connect.d.ts +38 -0
- package/dist/types/runtime-mcp/smithery-registry.d.ts +51 -0
- package/dist/types/runtime-mcp/tool-bridge.d.ts +86 -0
- package/dist/types/runtime-mcp/tool-cache.d.ts +8 -0
- package/dist/types/runtime-mcp/transports/http.d.ts +36 -0
- package/dist/types/runtime-mcp/transports/index.d.ts +5 -0
- package/dist/types/runtime-mcp/transports/stdio.d.ts +29 -0
- package/dist/types/runtime-mcp/types.d.ts +335 -0
- package/dist/types/sdk.d.ts +243 -0
- package/dist/types/secrets/index.d.ts +9 -0
- package/dist/types/secrets/obfuscator.d.ts +23 -0
- package/dist/types/secrets/regex.d.ts +2 -0
- package/dist/types/session/agent-session.d.ts +1078 -0
- package/dist/types/session/agent-storage.d.ts +100 -0
- package/dist/types/session/artifacts.d.ts +64 -0
- package/dist/types/session/auth-broker-config.d.ts +13 -0
- package/dist/types/session/auth-storage.d.ts +6 -0
- package/dist/types/session/blob-store.d.ts +135 -0
- package/dist/types/session/client-bridge.d.ts +88 -0
- package/dist/types/session/contribution-prep.d.ts +47 -0
- package/dist/types/session/history-storage.d.ts +16 -0
- package/dist/types/session/messages.d.ts +165 -0
- package/dist/types/session/session-dump-format.d.ts +22 -0
- package/dist/types/session/session-manager.d.ts +587 -0
- package/dist/types/session/session-storage.d.ts +88 -0
- package/dist/types/session/streaming-output.d.ts +209 -0
- package/dist/types/session/tool-choice-queue.d.ts +84 -0
- package/dist/types/session/yield-queue.d.ts +24 -0
- package/dist/types/setup/credential-import.d.ts +79 -0
- package/dist/types/setup/hermes-setup.d.ts +78 -0
- package/dist/types/setup/model-onboarding-guidance.d.ts +9 -0
- package/dist/types/setup/provider-onboarding.d.ts +52 -0
- package/dist/types/skc-runtime/cli-write-receipt.d.ts +24 -0
- package/dist/types/skc-runtime/deep-interview-recorder.d.ts +103 -0
- package/dist/types/skc-runtime/deep-interview-runtime.d.ts +36 -0
- package/dist/types/skc-runtime/deep-interview-state.d.ts +112 -0
- package/dist/types/skc-runtime/gc-render.d.ts +6 -0
- package/dist/types/skc-runtime/gc-runtime.d.ts +134 -0
- package/dist/types/skc-runtime/goal-mode-request.d.ts +53 -0
- package/dist/types/skc-runtime/launch-tmux.d.ts +76 -0
- package/dist/types/skc-runtime/launch-worktree.d.ts +46 -0
- package/dist/types/skc-runtime/ledger-event-renderer.d.ts +68 -0
- package/dist/types/skc-runtime/ralplan-runtime.d.ts +25 -0
- package/dist/types/skc-runtime/restricted-role-agent-bash.d.ts +2 -0
- package/dist/types/skc-runtime/session-state-sidecar.d.ts +27 -0
- package/dist/types/skc-runtime/state-graph.d.ts +4 -0
- package/dist/types/skc-runtime/state-migrations.d.ts +33 -0
- package/dist/types/skc-runtime/state-renderer.d.ts +65 -0
- package/dist/types/skc-runtime/state-runtime.d.ts +37 -0
- package/dist/types/skc-runtime/state-schema.d.ts +317 -0
- package/dist/types/skc-runtime/state-validation.d.ts +6 -0
- package/dist/types/skc-runtime/state-writer.d.ts +209 -0
- package/dist/types/skc-runtime/team-gc.d.ts +7 -0
- package/dist/types/skc-runtime/team-runtime.d.ts +353 -0
- package/dist/types/skc-runtime/tmux-common.d.ts +61 -0
- package/dist/types/skc-runtime/tmux-gc.d.ts +7 -0
- package/dist/types/skc-runtime/tmux-sessions.d.ts +40 -0
- package/dist/types/skc-runtime/ultragoal-guard.d.ts +36 -0
- package/dist/types/skc-runtime/ultragoal-runtime.d.ts +210 -0
- package/dist/types/skc-runtime/workflow-command-ref.d.ts +43 -0
- package/dist/types/skc-runtime/workflow-manifest.d.ts +54 -0
- package/dist/types/skill-state/active-state.d.ts +114 -0
- package/dist/types/skill-state/deep-interview-mutation-guard.d.ts +33 -0
- package/dist/types/skill-state/initial-phase.d.ts +12 -0
- package/dist/types/skill-state/workflow-hud.d.ts +81 -0
- package/dist/types/skill-state/workflow-state-contract.d.ts +57 -0
- package/dist/types/skill-state/workflow-state-version.d.ts +3 -0
- package/dist/types/slash-commands/acp-builtins.d.ts +18 -0
- package/dist/types/slash-commands/builtin-registry.d.ts +24 -0
- package/dist/types/slash-commands/helpers/context-report.d.ts +7 -0
- package/dist/types/slash-commands/helpers/fast-status-report.d.ts +76 -0
- package/dist/types/slash-commands/helpers/format.d.ts +10 -0
- package/dist/types/slash-commands/helpers/mcp.d.ts +3 -0
- package/dist/types/slash-commands/helpers/parse.d.ts +33 -0
- package/dist/types/slash-commands/helpers/ssh.d.ts +3 -0
- package/dist/types/slash-commands/helpers/todo.d.ts +3 -0
- package/dist/types/slash-commands/helpers/usage-report.d.ts +7 -0
- package/dist/types/slash-commands/types.d.ts +118 -0
- package/dist/types/ssh/config-writer.d.ts +49 -0
- package/dist/types/ssh/connection-manager.d.ts +33 -0
- package/dist/types/ssh/ssh-executor.d.ts +37 -0
- package/dist/types/ssh/sshfs-mount.d.ts +6 -0
- package/dist/types/ssh/utils.d.ts +2 -0
- package/dist/types/stt/downloader.d.ts +9 -0
- package/dist/types/stt/index.d.ts +3 -0
- package/dist/types/stt/recorder.d.ts +13 -0
- package/dist/types/stt/setup.d.ts +18 -0
- package/dist/types/stt/stt-controller.d.ts +16 -0
- package/dist/types/stt/transcriber.d.ts +16 -0
- package/dist/types/system-prompt.d.ts +93 -0
- package/dist/types/task/agents.d.ts +28 -0
- package/dist/types/task/commands.d.ts +35 -0
- package/dist/types/task/discovery.d.ts +19 -0
- package/dist/types/task/executor.d.ts +113 -0
- package/dist/types/task/fork-context-advisory.d.ts +13 -0
- package/dist/types/task/id.d.ts +7 -0
- package/dist/types/task/index.d.ts +43 -0
- package/dist/types/task/name-generator.d.ts +16 -0
- package/dist/types/task/output-manager.d.ts +36 -0
- package/dist/types/task/parallel.d.ts +34 -0
- package/dist/types/task/receipt.d.ts +87 -0
- package/dist/types/task/render.d.ts +28 -0
- package/dist/types/task/roi-reconciliation.d.ts +27 -0
- package/dist/types/task/simple-mode.d.ts +8 -0
- package/dist/types/task/skc-command.d.ts +7 -0
- package/dist/types/task/spawn-gate.d.ts +38 -0
- package/dist/types/task/subprocess-tool-registry.d.ts +72 -0
- package/dist/types/task/types.d.ts +508 -0
- package/dist/types/task/worktree.d.ts +94 -0
- package/dist/types/thinking-metadata.d.ts +16 -0
- package/dist/types/thinking.d.ts +22 -0
- package/dist/types/tool-discovery/tool-index.d.ts +112 -0
- package/dist/types/tools/archive-reader.d.ts +40 -0
- package/dist/types/tools/ask.d.ts +123 -0
- package/dist/types/tools/ast-edit.d.ts +77 -0
- package/dist/types/tools/ast-grep.d.ts +69 -0
- package/dist/types/tools/auto-generated-guard.d.ts +17 -0
- package/dist/types/tools/bash-allowed-prefixes.d.ts +10 -0
- package/dist/types/tools/bash-command-fixup.d.ts +11 -0
- package/dist/types/tools/bash-interactive.d.ts +16 -0
- package/dist/types/tools/bash-interceptor.d.ts +24 -0
- package/dist/types/tools/bash-pty-selection.d.ts +7 -0
- package/dist/types/tools/bash-skill-urls.d.ts +31 -0
- package/dist/types/tools/bash.d.ts +157 -0
- package/dist/types/tools/browser/actions.d.ts +54 -0
- package/dist/types/tools/browser/attach.d.ts +50 -0
- package/dist/types/tools/browser/launch.d.ts +62 -0
- package/dist/types/tools/browser/readable.d.ts +17 -0
- package/dist/types/tools/browser/registry.d.ts +57 -0
- package/dist/types/tools/browser/render.d.ts +53 -0
- package/dist/types/tools/browser/tab-protocol.d.ts +144 -0
- package/dist/types/tools/browser/tab-supervisor.d.ts +72 -0
- package/dist/types/tools/browser/tab-worker-entry.d.ts +1 -0
- package/dist/types/tools/browser/tab-worker.d.ts +19 -0
- package/dist/types/tools/browser.d.ts +211 -0
- package/dist/types/tools/calculator.d.ts +76 -0
- package/dist/types/tools/checkpoint.d.ts +63 -0
- package/dist/types/tools/computer/render.d.ts +17 -0
- package/dist/types/tools/computer.d.ts +465 -0
- package/dist/types/tools/conflict-detect.d.ts +205 -0
- package/dist/types/tools/context.d.ts +19 -0
- package/dist/types/tools/cron.d.ts +116 -0
- package/dist/types/tools/debug.d.ts +209 -0
- package/dist/types/tools/eval.d.ts +108 -0
- package/dist/types/tools/fetch.d.ts +61 -0
- package/dist/types/tools/file-recorder.d.ts +13 -0
- package/dist/types/tools/find.d.ts +95 -0
- package/dist/types/tools/fs-cache-invalidation.d.ts +15 -0
- package/dist/types/tools/gh-format.d.ts +6 -0
- package/dist/types/tools/gh-renderer.d.ts +25 -0
- package/dist/types/tools/gh.d.ts +356 -0
- package/dist/types/tools/github-cache.d.ts +103 -0
- package/dist/types/tools/grouped-file-output.d.ts +36 -0
- package/dist/types/tools/hindsight-recall.d.ts +21 -0
- package/dist/types/tools/hindsight-reflect.d.ts +23 -0
- package/dist/types/tools/hindsight-retain.d.ts +27 -0
- package/dist/types/tools/image-gen.d.ts +79 -0
- package/dist/types/tools/index.d.ts +297 -0
- package/dist/types/tools/inspect-image-renderer.d.ts +26 -0
- package/dist/types/tools/inspect-image.d.ts +31 -0
- package/dist/types/tools/irc.d.ts +79 -0
- package/dist/types/tools/job.d.ts +78 -0
- package/dist/types/tools/json-tree.d.ts +23 -0
- package/dist/types/tools/jtd-to-json-schema.d.ts +29 -0
- package/dist/types/tools/jtd-to-typescript.d.ts +26 -0
- package/dist/types/tools/jtd-utils.d.ts +42 -0
- package/dist/types/tools/list-limit.d.ts +12 -0
- package/dist/types/tools/match-line-format.d.ts +11 -0
- package/dist/types/tools/monitor.d.ts +54 -0
- package/dist/types/tools/output-meta.d.ts +204 -0
- package/dist/types/tools/path-utils.d.ts +147 -0
- package/dist/types/tools/plan-mode-guard.d.ts +18 -0
- package/dist/types/tools/read.d.ts +85 -0
- package/dist/types/tools/recipe/index.d.ts +45 -0
- package/dist/types/tools/recipe/render.d.ts +36 -0
- package/dist/types/tools/recipe/runner.d.ts +60 -0
- package/dist/types/tools/recipe/runners/cargo.d.ts +16 -0
- package/dist/types/tools/recipe/runners/index.d.ts +2 -0
- package/dist/types/tools/recipe/runners/just.d.ts +2 -0
- package/dist/types/tools/recipe/runners/make.d.ts +2 -0
- package/dist/types/tools/recipe/runners/pkg.d.ts +2 -0
- package/dist/types/tools/recipe/runners/task.d.ts +2 -0
- package/dist/types/tools/render-mermaid.d.ts +37 -0
- package/dist/types/tools/render-utils.d.ts +158 -0
- package/dist/types/tools/renderers.d.ts +26 -0
- package/dist/types/tools/resolve.d.ts +80 -0
- package/dist/types/tools/review.d.ts +63 -0
- package/dist/types/tools/search-tool-bm25.d.ts +65 -0
- package/dist/types/tools/search.d.ts +93 -0
- package/dist/types/tools/skill.d.ts +47 -0
- package/dist/types/tools/sqlite-reader.d.ts +94 -0
- package/dist/types/tools/ssh.d.ts +67 -0
- package/dist/types/tools/subagent-render.d.ts +31 -0
- package/dist/types/tools/subagent.d.ts +114 -0
- package/dist/types/tools/todo-write.d.ts +120 -0
- package/dist/types/tools/tool-errors.d.ts +33 -0
- package/dist/types/tools/tool-result.d.ts +30 -0
- package/dist/types/tools/tool-timeouts.d.ts +56 -0
- package/dist/types/tools/ultragoal-ask-guard.d.ts +5 -0
- package/dist/types/tools/vim.d.ts +58 -0
- package/dist/types/tools/write.d.ts +59 -0
- package/dist/types/tools/yield.d.ts +25 -0
- package/dist/types/tui/code-cell.d.ts +32 -0
- package/dist/types/tui/file-list.d.ts +22 -0
- package/dist/types/tui/hyperlink.d.ts +42 -0
- package/dist/types/tui/index.d.ts +11 -0
- package/dist/types/tui/output-block.d.ts +28 -0
- package/dist/types/tui/status-line.d.ts +18 -0
- package/dist/types/tui/tree-list.d.ts +19 -0
- package/dist/types/tui/types.d.ts +13 -0
- package/dist/types/tui/utils.d.ts +36 -0
- package/dist/types/utils/changelog.d.ts +36 -0
- package/dist/types/utils/clipboard.d.ts +22 -0
- package/dist/types/utils/command-args.d.ts +9 -0
- package/dist/types/utils/commit-message-generator.d.ts +7 -0
- package/dist/types/utils/edit-mode.d.ts +13 -0
- package/dist/types/utils/event-bus.d.ts +6 -0
- package/dist/types/utils/external-editor.d.ts +17 -0
- package/dist/types/utils/file-display-mode.d.ts +27 -0
- package/dist/types/utils/file-mentions.d.ts +11 -0
- package/dist/types/utils/git.d.ts +361 -0
- package/dist/types/utils/image-loading.d.ts +26 -0
- package/dist/types/utils/image-resize.d.ts +39 -0
- package/dist/types/utils/lang-from-path.d.ts +8 -0
- package/dist/types/utils/markit.d.ts +7 -0
- package/dist/types/utils/open.d.ts +2 -0
- package/dist/types/utils/session-color.d.ts +10 -0
- package/dist/types/utils/shell-snapshot.d.ts +5 -0
- package/dist/types/utils/sixel.d.ts +21 -0
- package/dist/types/utils/title-generator.d.ts +31 -0
- package/dist/types/utils/tool-choice.d.ts +20 -0
- package/dist/types/utils/tools-manager.d.ts +9 -0
- package/dist/types/vim/buffer.d.ts +41 -0
- package/dist/types/vim/commands.d.ts +6 -0
- package/dist/types/vim/engine.d.ts +47 -0
- package/dist/types/vim/parser.d.ts +3 -0
- package/dist/types/vim/render.d.ts +25 -0
- package/dist/types/vim/types.d.ts +182 -0
- package/dist/types/web/kagi.d.ts +23 -0
- package/dist/types/web/parallel.d.ts +58 -0
- package/dist/types/web/scrapers/artifacthub.d.ts +6 -0
- package/dist/types/web/scrapers/arxiv.d.ts +5 -0
- package/dist/types/web/scrapers/aur.d.ts +5 -0
- package/dist/types/web/scrapers/biorxiv.d.ts +5 -0
- package/dist/types/web/scrapers/bluesky.d.ts +5 -0
- package/dist/types/web/scrapers/brew.d.ts +5 -0
- package/dist/types/web/scrapers/cheatsh.d.ts +8 -0
- package/dist/types/web/scrapers/chocolatey.d.ts +5 -0
- package/dist/types/web/scrapers/choosealicense.d.ts +2 -0
- package/dist/types/web/scrapers/cisa-kev.d.ts +5 -0
- package/dist/types/web/scrapers/clojars.d.ts +5 -0
- package/dist/types/web/scrapers/coingecko.d.ts +5 -0
- package/dist/types/web/scrapers/crates-io.d.ts +5 -0
- package/dist/types/web/scrapers/crossref.d.ts +2 -0
- package/dist/types/web/scrapers/devto.d.ts +5 -0
- package/dist/types/web/scrapers/discogs.d.ts +8 -0
- package/dist/types/web/scrapers/discourse.d.ts +5 -0
- package/dist/types/web/scrapers/dockerhub.d.ts +5 -0
- package/dist/types/web/scrapers/docs-rs.d.ts +2 -0
- package/dist/types/web/scrapers/fdroid.d.ts +5 -0
- package/dist/types/web/scrapers/firefox-addons.d.ts +2 -0
- package/dist/types/web/scrapers/flathub.d.ts +2 -0
- package/dist/types/web/scrapers/github-gist.d.ts +5 -0
- package/dist/types/web/scrapers/github.d.ts +12 -0
- package/dist/types/web/scrapers/gitlab.d.ts +5 -0
- package/dist/types/web/scrapers/go-pkg.d.ts +5 -0
- package/dist/types/web/scrapers/hackage.d.ts +5 -0
- package/dist/types/web/scrapers/hackernews.d.ts +2 -0
- package/dist/types/web/scrapers/hex.d.ts +5 -0
- package/dist/types/web/scrapers/huggingface.d.ts +2 -0
- package/dist/types/web/scrapers/iacr.d.ts +5 -0
- package/dist/types/web/scrapers/index.d.ts +84 -0
- package/dist/types/web/scrapers/jetbrains-marketplace.d.ts +2 -0
- package/dist/types/web/scrapers/lemmy.d.ts +2 -0
- package/dist/types/web/scrapers/lobsters.d.ts +5 -0
- package/dist/types/web/scrapers/mastodon.d.ts +5 -0
- package/dist/types/web/scrapers/maven.d.ts +6 -0
- package/dist/types/web/scrapers/mdn.d.ts +2 -0
- package/dist/types/web/scrapers/metacpan.d.ts +5 -0
- package/dist/types/web/scrapers/musicbrainz.d.ts +5 -0
- package/dist/types/web/scrapers/npm.d.ts +5 -0
- package/dist/types/web/scrapers/nuget.d.ts +5 -0
- package/dist/types/web/scrapers/nvd.d.ts +5 -0
- package/dist/types/web/scrapers/ollama.d.ts +2 -0
- package/dist/types/web/scrapers/open-vsx.d.ts +5 -0
- package/dist/types/web/scrapers/opencorporates.d.ts +5 -0
- package/dist/types/web/scrapers/openlibrary.d.ts +5 -0
- package/dist/types/web/scrapers/orcid.d.ts +5 -0
- package/dist/types/web/scrapers/osv.d.ts +5 -0
- package/dist/types/web/scrapers/packagist.d.ts +5 -0
- package/dist/types/web/scrapers/pub-dev.d.ts +5 -0
- package/dist/types/web/scrapers/pubmed.d.ts +5 -0
- package/dist/types/web/scrapers/pypi.d.ts +5 -0
- package/dist/types/web/scrapers/rawg.d.ts +2 -0
- package/dist/types/web/scrapers/readthedocs.d.ts +2 -0
- package/dist/types/web/scrapers/reddit.d.ts +5 -0
- package/dist/types/web/scrapers/repology.d.ts +5 -0
- package/dist/types/web/scrapers/rfc.d.ts +5 -0
- package/dist/types/web/scrapers/rubygems.d.ts +5 -0
- package/dist/types/web/scrapers/searchcode.d.ts +2 -0
- package/dist/types/web/scrapers/sec-edgar.d.ts +5 -0
- package/dist/types/web/scrapers/semantic-scholar.d.ts +2 -0
- package/dist/types/web/scrapers/snapcraft.d.ts +2 -0
- package/dist/types/web/scrapers/sourcegraph.d.ts +2 -0
- package/dist/types/web/scrapers/spdx.d.ts +5 -0
- package/dist/types/web/scrapers/spotify.d.ts +8 -0
- package/dist/types/web/scrapers/stackoverflow.d.ts +6 -0
- package/dist/types/web/scrapers/terraform.d.ts +5 -0
- package/dist/types/web/scrapers/tldr.d.ts +7 -0
- package/dist/types/web/scrapers/twitter.d.ts +5 -0
- package/dist/types/web/scrapers/types.d.ts +78 -0
- package/dist/types/web/scrapers/utils.d.ts +26 -0
- package/dist/types/web/scrapers/vimeo.d.ts +5 -0
- package/dist/types/web/scrapers/vscode-marketplace.d.ts +5 -0
- package/dist/types/web/scrapers/w3c.d.ts +2 -0
- package/dist/types/web/scrapers/wikidata.d.ts +5 -0
- package/dist/types/web/scrapers/wikipedia.d.ts +5 -0
- package/dist/types/web/scrapers/youtube.d.ts +5 -0
- package/dist/types/web/search/index.d.ts +115 -0
- package/dist/types/web/search/provider.d.ts +24 -0
- package/dist/types/web/search/providers/anthropic.d.ts +32 -0
- package/dist/types/web/search/providers/base.d.ts +90 -0
- package/dist/types/web/search/providers/brave.d.ts +27 -0
- package/dist/types/web/search/providers/codex.d.ts +35 -0
- package/dist/types/web/search/providers/duckduckgo.d.ts +57 -0
- package/dist/types/web/search/providers/exa.d.ts +52 -0
- package/dist/types/web/search/providers/gemini.d.ts +57 -0
- package/dist/types/web/search/providers/jina.d.ts +26 -0
- package/dist/types/web/search/providers/kagi.d.ts +24 -0
- package/dist/types/web/search/providers/kimi.d.ts +27 -0
- package/dist/types/web/search/providers/openai-compatible.d.ts +9 -0
- package/dist/types/web/search/providers/parallel.d.ts +15 -0
- package/dist/types/web/search/providers/perplexity.d.ts +38 -0
- package/dist/types/web/search/providers/searxng.d.ts +44 -0
- package/dist/types/web/search/providers/synthetic.d.ts +21 -0
- package/dist/types/web/search/providers/tavily.d.ts +29 -0
- package/dist/types/web/search/providers/utils.d.ts +52 -0
- package/dist/types/web/search/providers/xai.d.ts +64 -0
- package/dist/types/web/search/providers/zai.d.ts +28 -0
- package/dist/types/web/search/render.d.ts +35 -0
- package/dist/types/web/search/types.d.ts +364 -0
- package/dist/types/web/search/utils.d.ts +4 -0
- package/dist/types/workspace-tree.d.ts +42 -0
- package/examples/README.md +21 -0
- package/examples/custom-tools/README.md +104 -0
- package/examples/custom-tools/hello/index.ts +20 -0
- package/examples/extensions/README.md +120 -0
- package/examples/extensions/api-demo.ts +79 -0
- package/examples/extensions/chalk-logger.ts +25 -0
- package/examples/extensions/hello.ts +31 -0
- package/examples/extensions/pirate.ts +43 -0
- package/examples/extensions/plan-mode.ts +549 -0
- package/examples/extensions/reload-runtime.ts +38 -0
- package/examples/extensions/tools.ts +144 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +16 -0
- package/examples/hooks/README.md +56 -0
- package/examples/hooks/auto-commit-on-exit.ts +48 -0
- package/examples/hooks/confirm-destructive.ts +58 -0
- package/examples/hooks/custom-compaction.ts +115 -0
- package/examples/hooks/dirty-repo-guard.ts +51 -0
- package/examples/hooks/file-trigger.ts +40 -0
- package/examples/hooks/git-checkpoint.ts +52 -0
- package/examples/hooks/handoff.ts +149 -0
- package/examples/hooks/permission-gate.ts +33 -0
- package/examples/hooks/protected-paths.ts +29 -0
- package/examples/hooks/qna.ts +118 -0
- package/examples/hooks/status-line.ts +39 -0
- package/examples/sdk/01-minimal.ts +21 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +46 -0
- package/examples/sdk/04-skills.ts +43 -0
- package/examples/sdk/06-extensions.ts +82 -0
- package/examples/sdk/06-hooks.ts +61 -0
- package/examples/sdk/07-context-files.ts +35 -0
- package/examples/sdk/08-prompt-templates.ts +41 -0
- package/examples/sdk/08-slash-commands.ts +46 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +54 -0
- package/examples/sdk/11-sessions.ts +47 -0
- package/examples/sdk/README.md +172 -0
- package/package.json +540 -0
- package/scripts/build-binary.ts +95 -0
- package/scripts/format-prompts.ts +68 -0
- package/scripts/generate-docs-index.ts +71 -0
- package/scripts/generate-template.ts +33 -0
- package/src/async/index.ts +2 -0
- package/src/async/job-manager.ts +1489 -0
- package/src/async/support.ts +6 -0
- package/src/autoresearch/command-resume.md +14 -0
- package/src/autoresearch/dashboard.ts +446 -0
- package/src/autoresearch/git.ts +319 -0
- package/src/autoresearch/helpers.ts +218 -0
- package/src/autoresearch/index.ts +536 -0
- package/src/autoresearch/prompt-setup.md +43 -0
- package/src/autoresearch/prompt.md +103 -0
- package/src/autoresearch/resume-message.md +10 -0
- package/src/autoresearch/state.ts +273 -0
- package/src/autoresearch/storage.ts +699 -0
- package/src/autoresearch/tools/init-experiment.ts +272 -0
- package/src/autoresearch/tools/log-experiment.ts +524 -0
- package/src/autoresearch/tools/run-experiment.ts +475 -0
- package/src/autoresearch/tools/update-notes.ts +109 -0
- package/src/autoresearch/types.ts +168 -0
- package/src/bun-imports.d.ts +28 -0
- package/src/capability/context-file.ts +44 -0
- package/src/capability/extension-module.ts +34 -0
- package/src/capability/extension.ts +47 -0
- package/src/capability/fs.ts +107 -0
- package/src/capability/hook.ts +40 -0
- package/src/capability/index.ts +436 -0
- package/src/capability/instruction.ts +37 -0
- package/src/capability/mcp.ts +74 -0
- package/src/capability/prompt.ts +35 -0
- package/src/capability/rule.ts +244 -0
- package/src/capability/settings.ts +34 -0
- package/src/capability/skill.ts +56 -0
- package/src/capability/slash-command.ts +40 -0
- package/src/capability/ssh.ts +41 -0
- package/src/capability/system-prompt.ts +34 -0
- package/src/capability/tool.ts +38 -0
- package/src/capability/types.ts +168 -0
- package/src/cli/agents-cli.ts +141 -0
- package/src/cli/args.ts +306 -0
- package/src/cli/auth-broker-cli.ts +748 -0
- package/src/cli/auth-gateway-cli.ts +411 -0
- package/src/cli/classify-install-target.ts +50 -0
- package/src/cli/commands/init-xdg.ts +27 -0
- package/src/cli/config-cli.ts +426 -0
- package/src/cli/fast-help.ts +82 -0
- package/src/cli/file-processor.ts +123 -0
- package/src/cli/grep-cli.ts +160 -0
- package/src/cli/initial-message.ts +58 -0
- package/src/cli/list-models.ts +206 -0
- package/src/cli/plugin-cli.ts +942 -0
- package/src/cli/read-cli.ts +57 -0
- package/src/cli/session-picker.ts +52 -0
- package/src/cli/setup-cli.ts +675 -0
- package/src/cli/shell-cli.ts +176 -0
- package/src/cli/skills-cli.ts +88 -0
- package/src/cli/ssh-cli.ts +179 -0
- package/src/cli/stats-cli.ts +238 -0
- package/src/cli/update-cli.ts +459 -0
- package/src/cli/web-search-cli.ts +248 -0
- package/src/cli/worktree-cli.ts +291 -0
- package/src/cli.ts +225 -0
- package/src/commands/acp.ts +24 -0
- package/src/commands/agents.ts +57 -0
- package/src/commands/auth-broker.ts +96 -0
- package/src/commands/auth-gateway.ts +63 -0
- package/src/commands/codex-native-hook.ts +11 -0
- package/src/commands/commit.ts +46 -0
- package/src/commands/config.ts +51 -0
- package/src/commands/contribution-prep.ts +41 -0
- package/src/commands/coordinator.ts +113 -0
- package/src/commands/deep-interview.ts +39 -0
- package/src/commands/gc.ts +22 -0
- package/src/commands/grep.ts +48 -0
- package/src/commands/harness.ts +1207 -0
- package/src/commands/launch.ts +178 -0
- package/src/commands/mcp-serve.ts +63 -0
- package/src/commands/plugin.ts +78 -0
- package/src/commands/ralplan.ts +19 -0
- package/src/commands/read.ts +35 -0
- package/src/commands/rlm.ts +19 -0
- package/src/commands/session.ts +152 -0
- package/src/commands/setup.ts +91 -0
- package/src/commands/shell.ts +29 -0
- package/src/commands/skills.ts +48 -0
- package/src/commands/ssh.ts +60 -0
- package/src/commands/state.ts +24 -0
- package/src/commands/stats.ts +29 -0
- package/src/commands/team.ts +216 -0
- package/src/commands/ultragoal.ts +41 -0
- package/src/commands/update.ts +21 -0
- package/src/commands/web-search.ts +108 -0
- package/src/commands/worktree.ts +56 -0
- package/src/commit/agentic/agent.ts +316 -0
- package/src/commit/agentic/fallback.ts +96 -0
- package/src/commit/agentic/index.ts +356 -0
- package/src/commit/agentic/prompts/analyze-file.md +22 -0
- package/src/commit/agentic/prompts/session-user.md +25 -0
- package/src/commit/agentic/prompts/split-confirm.md +1 -0
- package/src/commit/agentic/prompts/system.md +38 -0
- package/src/commit/agentic/state.ts +60 -0
- package/src/commit/agentic/tools/analyze-file.ts +127 -0
- package/src/commit/agentic/tools/git-file-diff.ts +191 -0
- package/src/commit/agentic/tools/git-hunk.ts +50 -0
- package/src/commit/agentic/tools/git-overview.ts +81 -0
- package/src/commit/agentic/tools/index.ts +54 -0
- package/src/commit/agentic/tools/propose-changelog.ts +144 -0
- package/src/commit/agentic/tools/propose-commit.ts +109 -0
- package/src/commit/agentic/tools/recent-commits.ts +81 -0
- package/src/commit/agentic/tools/schemas.ts +23 -0
- package/src/commit/agentic/tools/split-commit.ts +238 -0
- package/src/commit/agentic/topo-sort.ts +44 -0
- package/src/commit/agentic/trivial.ts +51 -0
- package/src/commit/agentic/validation.ts +183 -0
- package/src/commit/analysis/conventional.ts +64 -0
- package/src/commit/analysis/index.ts +4 -0
- package/src/commit/analysis/scope.ts +242 -0
- package/src/commit/analysis/summary.ts +105 -0
- package/src/commit/analysis/validation.ts +66 -0
- package/src/commit/changelog/detect.ts +40 -0
- package/src/commit/changelog/generate.ts +97 -0
- package/src/commit/changelog/index.ts +234 -0
- package/src/commit/changelog/parse.ts +44 -0
- package/src/commit/cli.ts +85 -0
- package/src/commit/git/diff.ts +148 -0
- package/src/commit/index.ts +5 -0
- package/src/commit/map-reduce/index.ts +69 -0
- package/src/commit/map-reduce/map-phase.ts +193 -0
- package/src/commit/map-reduce/reduce-phase.ts +49 -0
- package/src/commit/map-reduce/utils.ts +9 -0
- package/src/commit/message.ts +11 -0
- package/src/commit/model-selection.ts +51 -0
- package/src/commit/pipeline.ts +244 -0
- package/src/commit/prompts/analysis-system.md +148 -0
- package/src/commit/prompts/analysis-user.md +38 -0
- package/src/commit/prompts/changelog-system.md +50 -0
- package/src/commit/prompts/changelog-user.md +18 -0
- package/src/commit/prompts/file-observer-system.md +24 -0
- package/src/commit/prompts/file-observer-user.md +8 -0
- package/src/commit/prompts/reduce-system.md +50 -0
- package/src/commit/prompts/reduce-user.md +17 -0
- package/src/commit/prompts/summary-retry.md +3 -0
- package/src/commit/prompts/summary-system.md +38 -0
- package/src/commit/prompts/summary-user.md +13 -0
- package/src/commit/prompts/types-description.md +2 -0
- package/src/commit/shared-llm.ts +77 -0
- package/src/commit/types.ts +118 -0
- package/src/commit/utils/exclusions.ts +42 -0
- package/src/commit/utils.ts +58 -0
- package/src/config/config-file.ts +232 -0
- package/src/config/file-lock-gc.ts +193 -0
- package/src/config/file-lock.ts +185 -0
- package/src/config/keybindings.ts +510 -0
- package/src/config/mcp-schema.json +230 -0
- package/src/config/model-equivalence.ts +811 -0
- package/src/config/model-profile-activation.ts +249 -0
- package/src/config/model-profiles.ts +396 -0
- package/src/config/model-registry.ts +2816 -0
- package/src/config/model-resolver.ts +1336 -0
- package/src/config/models-config-schema.ts +258 -0
- package/src/config/prompt-templates.ts +310 -0
- package/src/config/resolve-config-value.ts +94 -0
- package/src/config/settings-schema.ts +3183 -0
- package/src/config/settings.ts +967 -0
- package/src/config/skill-settings-defaults.ts +27 -0
- package/src/config.ts +212 -0
- package/src/coordinator/contract.ts +22 -0
- package/src/coordinator-mcp/policy.ts +160 -0
- package/src/coordinator-mcp/safety.ts +80 -0
- package/src/coordinator-mcp/server.ts +2006 -0
- package/src/cursor.ts +392 -0
- package/src/dap/client.ts +730 -0
- package/src/dap/config.ts +150 -0
- package/src/dap/defaults.json +211 -0
- package/src/dap/index.ts +4 -0
- package/src/dap/session.ts +1343 -0
- package/src/dap/types.ts +600 -0
- package/src/debug/crash-diagnostics.ts +223 -0
- package/src/debug/index.ts +459 -0
- package/src/debug/log-formatting.ts +58 -0
- package/src/debug/log-viewer.ts +908 -0
- package/src/debug/profiler.ts +162 -0
- package/src/debug/raw-sse-buffer.ts +270 -0
- package/src/debug/raw-sse.ts +213 -0
- package/src/debug/report-bundle.ts +365 -0
- package/src/debug/runtime-gauges.ts +20 -0
- package/src/debug/system-info.ts +111 -0
- package/src/deep-interview/render-middleware.ts +372 -0
- package/src/defaults/skc/agent.models.grok-cli.yml +36 -0
- package/src/defaults/skc/extensions/grok-build/index.ts +1 -0
- package/src/defaults/skc/extensions/grok-build/package.json +7 -0
- package/src/defaults/skc/extensions/grok-cli-vendor/biome.json +39 -0
- package/src/defaults/skc/extensions/grok-cli-vendor/package.json +8 -0
- package/src/defaults/skc/extensions/grok-cli-vendor/src/index.ts +1 -0
- package/src/defaults/skc/extensions/grok-cli-vendor/src/models/catalog.ts +155 -0
- package/src/defaults/skc/extensions/grok-cli-vendor/src/payload/sanitize.ts +361 -0
- package/src/defaults/skc/extensions/grok-cli-vendor/src/provider/billing.ts +57 -0
- package/src/defaults/skc/extensions/grok-cli-vendor/src/provider/register.ts +99 -0
- package/src/defaults/skc/extensions/grok-cli-vendor/src/provider/stream.ts +50 -0
- package/src/defaults/skc/extensions/grok-cli-vendor/src/provider/usage.ts +56 -0
- package/src/defaults/skc/extensions/grok-cli-vendor/src/shared/base-url.ts +36 -0
- package/src/defaults/skc/extensions/grok-cli-vendor/src/shared/errors.ts +44 -0
- package/src/defaults/skc/skills/deep-interview/SKILL.md +879 -0
- package/src/defaults/skc/skills/deep-interview/auto-answer-uncertain.md +37 -0
- package/src/defaults/skc/skills/deep-interview/auto-research-greenfield.md +42 -0
- package/src/defaults/skc/skills/deep-interview/lateral-review-panel.md +49 -0
- package/src/defaults/skc/skills/ralplan/SKILL.md +191 -0
- package/src/defaults/skc/skills/team/SKILL.md +442 -0
- package/src/defaults/skc/skills/ultragoal/SKILL.md +349 -0
- package/src/defaults/skc/skills/ultragoal/ai-slop-cleaner.md +61 -0
- package/src/defaults/skc-defaults.ts +217 -0
- package/src/defaults/skc-grok-cli.ts +22 -0
- package/src/discovery/agents-md.ts +67 -0
- package/src/discovery/agents.ts +230 -0
- package/src/discovery/builtin.ts +932 -0
- package/src/discovery/claude-plugins.ts +407 -0
- package/src/discovery/claude.ts +313 -0
- package/src/discovery/cline.ts +83 -0
- package/src/discovery/codex.ts +330 -0
- package/src/discovery/cursor.ts +220 -0
- package/src/discovery/gemini.ts +383 -0
- package/src/discovery/github.ts +118 -0
- package/src/discovery/helpers.ts +992 -0
- package/src/discovery/index.ts +76 -0
- package/src/discovery/mcp-json.ts +171 -0
- package/src/discovery/opencode.ts +398 -0
- package/src/discovery/plugin-dir-roots.ts +28 -0
- package/src/discovery/ssh.ts +153 -0
- package/src/discovery/substitute-plugin-root.ts +29 -0
- package/src/discovery/vscode.ts +105 -0
- package/src/discovery/windsurf.ts +147 -0
- package/src/edit/apply-patch/index.ts +87 -0
- package/src/edit/apply-patch/parser.ts +174 -0
- package/src/edit/diff.ts +873 -0
- package/src/edit/file-read-cache.ts +95 -0
- package/src/edit/index.ts +528 -0
- package/src/edit/modes/apply-patch.lark +19 -0
- package/src/edit/modes/apply-patch.ts +53 -0
- package/src/edit/modes/patch.ts +1835 -0
- package/src/edit/modes/replace.ts +1161 -0
- package/src/edit/normalize.ts +375 -0
- package/src/edit/notebook.ts +226 -0
- package/src/edit/read-file.ts +43 -0
- package/src/edit/renderer.ts +683 -0
- package/src/edit/streaming.ts +561 -0
- package/src/eval/backend.ts +43 -0
- package/src/eval/index.ts +4 -0
- package/src/eval/js/context-manager.ts +577 -0
- package/src/eval/js/executor.ts +136 -0
- package/src/eval/js/index.ts +47 -0
- package/src/eval/js/shared/helpers.ts +237 -0
- package/src/eval/js/shared/indirect-eval.ts +30 -0
- package/src/eval/js/shared/prelude.ts +2 -0
- package/src/eval/js/shared/prelude.txt +70 -0
- package/src/eval/js/shared/rewrite-imports.ts +415 -0
- package/src/eval/js/shared/runtime.ts +301 -0
- package/src/eval/js/shared/types.ts +18 -0
- package/src/eval/js/tool-bridge.ts +144 -0
- package/src/eval/js/worker-core.ts +150 -0
- package/src/eval/js/worker-entry.ts +24 -0
- package/src/eval/js/worker-protocol.ts +41 -0
- package/src/eval/py/display.ts +71 -0
- package/src/eval/py/executor.ts +678 -0
- package/src/eval/py/index.ts +58 -0
- package/src/eval/py/kernel.ts +712 -0
- package/src/eval/py/prelude.py +462 -0
- package/src/eval/py/prelude.ts +3 -0
- package/src/eval/py/runner.py +964 -0
- package/src/eval/py/runtime.ts +331 -0
- package/src/eval/py/tool-bridge.ts +137 -0
- package/src/eval/types.ts +48 -0
- package/src/exa/factory.ts +60 -0
- package/src/exa/index.ts +27 -0
- package/src/exa/mcp-client.ts +364 -0
- package/src/exa/render.ts +244 -0
- package/src/exa/researcher.ts +36 -0
- package/src/exa/search.ts +47 -0
- package/src/exa/types.ts +166 -0
- package/src/exa/websets.ts +248 -0
- package/src/exec/bash-executor.ts +403 -0
- package/src/exec/exec.ts +53 -0
- package/src/exec/idle-timeout-watchdog.ts +126 -0
- package/src/exec/non-interactive-env.ts +48 -0
- package/src/export/custom-share.ts +65 -0
- package/src/export/html/index.ts +168 -0
- package/src/export/html/template.css +1060 -0
- package/src/export/html/template.generated.ts +2 -0
- package/src/export/html/template.html +47 -0
- package/src/export/html/template.js +2268 -0
- package/src/export/html/template.macro.ts +25 -0
- package/src/export/html/vendor/highlight.min.js +1213 -0
- package/src/export/html/vendor/marked.min.js +6 -0
- package/src/export/ttsr.ts +434 -0
- package/src/extensibility/custom-commands/bundled/ci-green/index.ts +25 -0
- package/src/extensibility/custom-commands/bundled/review/index.ts +456 -0
- package/src/extensibility/custom-commands/index.ts +2 -0
- package/src/extensibility/custom-commands/loader.ts +238 -0
- package/src/extensibility/custom-commands/types.ts +113 -0
- package/src/extensibility/custom-tools/index.ts +7 -0
- package/src/extensibility/custom-tools/loader.ts +245 -0
- package/src/extensibility/custom-tools/types.ts +257 -0
- package/src/extensibility/custom-tools/wrapper.ts +49 -0
- package/src/extensibility/extensions/compact-handler.ts +40 -0
- package/src/extensibility/extensions/get-commands-handler.ts +80 -0
- package/src/extensibility/extensions/index.ts +16 -0
- package/src/extensibility/extensions/loader.ts +551 -0
- package/src/extensibility/extensions/prefix-command-bridge.ts +128 -0
- package/src/extensibility/extensions/runner.ts +900 -0
- package/src/extensibility/extensions/types.ts +1286 -0
- package/src/extensibility/extensions/wrapper.ts +190 -0
- package/src/extensibility/hooks/index.ts +5 -0
- package/src/extensibility/hooks/loader.ts +257 -0
- package/src/extensibility/hooks/runner.ts +425 -0
- package/src/extensibility/hooks/tool-wrapper.ts +107 -0
- package/src/extensibility/hooks/types.ts +599 -0
- package/src/extensibility/plugins/doctor.ts +66 -0
- package/src/extensibility/plugins/git-url.ts +281 -0
- package/src/extensibility/plugins/index.ts +9 -0
- package/src/extensibility/plugins/installer.ts +192 -0
- package/src/extensibility/plugins/legacy-pi-compat.ts +336 -0
- package/src/extensibility/plugins/loader.ts +288 -0
- package/src/extensibility/plugins/manager.ts +731 -0
- package/src/extensibility/plugins/marketplace/cache.ts +136 -0
- package/src/extensibility/plugins/marketplace/fetcher.ts +317 -0
- package/src/extensibility/plugins/marketplace/index.ts +6 -0
- package/src/extensibility/plugins/marketplace/manager.ts +770 -0
- package/src/extensibility/plugins/marketplace/registry.ts +196 -0
- package/src/extensibility/plugins/marketplace/source-resolver.ts +147 -0
- package/src/extensibility/plugins/marketplace/types.ts +191 -0
- package/src/extensibility/plugins/parser.ts +105 -0
- package/src/extensibility/plugins/types.ts +194 -0
- package/src/extensibility/shared-events.ts +344 -0
- package/src/extensibility/skc-plugins/activation.ts +87 -0
- package/src/extensibility/skc-plugins/index.ts +9 -0
- package/src/extensibility/skc-plugins/injection.ts +114 -0
- package/src/extensibility/skc-plugins/loader.ts +131 -0
- package/src/extensibility/skc-plugins/paths.ts +66 -0
- package/src/extensibility/skc-plugins/schema.ts +79 -0
- package/src/extensibility/skc-plugins/state.ts +29 -0
- package/src/extensibility/skc-plugins/tools.ts +47 -0
- package/src/extensibility/skc-plugins/types.ts +97 -0
- package/src/extensibility/skc-plugins/validation.ts +76 -0
- package/src/extensibility/skills.ts +423 -0
- package/src/extensibility/slash-commands.ts +236 -0
- package/src/extensibility/tool-proxy.ts +25 -0
- package/src/extensibility/typebox.ts +418 -0
- package/src/extensibility/utils.ts +44 -0
- package/src/goals/index.ts +3 -0
- package/src/goals/runtime.ts +419 -0
- package/src/goals/state.ts +66 -0
- package/src/goals/tools/goal-tool.ts +237 -0
- package/src/harness-control-plane/classifier.ts +128 -0
- package/src/harness-control-plane/control-endpoint.ts +148 -0
- package/src/harness-control-plane/finalize.ts +340 -0
- package/src/harness-control-plane/gc-adapter.ts +184 -0
- package/src/harness-control-plane/operate.ts +225 -0
- package/src/harness-control-plane/owner.ts +684 -0
- package/src/harness-control-plane/phase-rollup.ts +96 -0
- package/src/harness-control-plane/preserve.ts +102 -0
- package/src/harness-control-plane/receipt-ingest.ts +127 -0
- package/src/harness-control-plane/receipt-spool.ts +128 -0
- package/src/harness-control-plane/receipts.ts +482 -0
- package/src/harness-control-plane/rpc-adapter.ts +290 -0
- package/src/harness-control-plane/seams.ts +39 -0
- package/src/harness-control-plane/session-lease.ts +388 -0
- package/src/harness-control-plane/state-machine.ts +119 -0
- package/src/harness-control-plane/storage.ts +492 -0
- package/src/harness-control-plane/types.ts +267 -0
- package/src/hashline/anchors.ts +113 -0
- package/src/hashline/apply.ts +737 -0
- package/src/hashline/bigrams.json +649 -0
- package/src/hashline/constants.ts +25 -0
- package/src/hashline/diff-preview.ts +43 -0
- package/src/hashline/diff.ts +56 -0
- package/src/hashline/execute.ts +267 -0
- package/src/hashline/grammar.lark +21 -0
- package/src/hashline/hash.ts +196 -0
- package/src/hashline/index.ts +13 -0
- package/src/hashline/input.ts +130 -0
- package/src/hashline/parser.ts +246 -0
- package/src/hashline/prefixes.ts +101 -0
- package/src/hashline/recovery.ts +113 -0
- package/src/hashline/stream.ts +123 -0
- package/src/hashline/types.ts +68 -0
- package/src/hindsight/backend.ts +205 -0
- package/src/hindsight/bank.ts +131 -0
- package/src/hindsight/client.ts +598 -0
- package/src/hindsight/config.ts +175 -0
- package/src/hindsight/content.ts +210 -0
- package/src/hindsight/index.ts +8 -0
- package/src/hindsight/mental-models.ts +383 -0
- package/src/hindsight/seeds.json +32 -0
- package/src/hindsight/state.ts +469 -0
- package/src/hindsight/transcript.ts +71 -0
- package/src/hooks/codex-native-hooks-config.ts +143 -0
- package/src/hooks/native-skill-hook.ts +305 -0
- package/src/hooks/skill-keywords.ts +88 -0
- package/src/hooks/skill-state.ts +753 -0
- package/src/i18n/index.ts +188 -0
- package/src/i18n/messages/de.messages.ts +308 -0
- package/src/i18n/messages/de.settings.ts +805 -0
- package/src/i18n/messages/de.ts +65 -0
- package/src/i18n/messages/en.ts +86 -0
- package/src/i18n/messages/es.messages.ts +314 -0
- package/src/i18n/messages/es.settings.ts +798 -0
- package/src/i18n/messages/es.ts +65 -0
- package/src/i18n/messages/fr.messages.ts +312 -0
- package/src/i18n/messages/fr.settings.ts +771 -0
- package/src/i18n/messages/fr.ts +65 -0
- package/src/i18n/messages/ja.messages.ts +314 -0
- package/src/i18n/messages/ja.settings.ts +809 -0
- package/src/i18n/messages/ja.ts +69 -0
- package/src/i18n/messages/ko.messages.ts +312 -0
- package/src/i18n/messages/ko.settings.ts +798 -0
- package/src/i18n/messages/ko.ts +69 -0
- package/src/i18n/messages/zh.messages.ts +298 -0
- package/src/i18n/messages/zh.settings.ts +779 -0
- package/src/i18n/messages/zh.ts +69 -0
- package/src/index.ts +56 -0
- package/src/internal-urls/agent-protocol.ts +176 -0
- package/src/internal-urls/artifact-protocol.ts +84 -0
- package/src/internal-urls/docs-index.generated.ts +106 -0
- package/src/internal-urls/index.ts +21 -0
- package/src/internal-urls/issue-pr-protocol.ts +577 -0
- package/src/internal-urls/json-query.ts +126 -0
- package/src/internal-urls/local-protocol.ts +249 -0
- package/src/internal-urls/mcp-protocol.ts +151 -0
- package/src/internal-urls/memory-protocol.ts +165 -0
- package/src/internal-urls/parse.ts +72 -0
- package/src/internal-urls/registry-helpers.ts +28 -0
- package/src/internal-urls/router.ts +78 -0
- package/src/internal-urls/rule-protocol.ts +38 -0
- package/src/internal-urls/skc-protocol.ts +83 -0
- package/src/internal-urls/skill-protocol.ts +103 -0
- package/src/internal-urls/types.ts +114 -0
- package/src/lsp/client.ts +1012 -0
- package/src/lsp/clients/biome-client.ts +202 -0
- package/src/lsp/clients/index.ts +50 -0
- package/src/lsp/clients/lsp-linter-client.ts +93 -0
- package/src/lsp/clients/swiftlint-client.ts +120 -0
- package/src/lsp/config.ts +492 -0
- package/src/lsp/defaults.json +494 -0
- package/src/lsp/edits.ts +166 -0
- package/src/lsp/index.ts +2283 -0
- package/src/lsp/lspmux.ts +257 -0
- package/src/lsp/render.ts +692 -0
- package/src/lsp/startup-events.ts +13 -0
- package/src/lsp/types.ts +445 -0
- package/src/lsp/utils.ts +678 -0
- package/src/main.ts +1080 -0
- package/src/memories/index.ts +1137 -0
- package/src/memories/storage.ts +577 -0
- package/src/memory-backend/index.ts +4 -0
- package/src/memory-backend/local-backend.ts +38 -0
- package/src/memory-backend/off-backend.ts +16 -0
- package/src/memory-backend/resolve.ts +24 -0
- package/src/memory-backend/types.ts +79 -0
- package/src/modes/acp/acp-agent.ts +2203 -0
- package/src/modes/acp/acp-client-bridge.ts +154 -0
- package/src/modes/acp/acp-event-mapper.ts +911 -0
- package/src/modes/acp/acp-mode.ts +23 -0
- package/src/modes/acp/index.ts +2 -0
- package/src/modes/acp/terminal-auth.ts +37 -0
- package/src/modes/bridge/auth.ts +41 -0
- package/src/modes/bridge/bridge-client-bridge.ts +47 -0
- package/src/modes/bridge/bridge-mode.ts +664 -0
- package/src/modes/bridge/bridge-ui-context.ts +200 -0
- package/src/modes/bridge/event-stream.ts +70 -0
- package/src/modes/components/agent-dashboard.ts +1120 -0
- package/src/modes/components/assistant-message.ts +255 -0
- package/src/modes/components/bash-execution.ts +232 -0
- package/src/modes/components/bordered-loader.ts +41 -0
- package/src/modes/components/branch-summary-message.ts +45 -0
- package/src/modes/components/btw-panel.ts +104 -0
- package/src/modes/components/compaction-summary-message.ts +51 -0
- package/src/modes/components/countdown-timer.ts +75 -0
- package/src/modes/components/custom-editor.ts +363 -0
- package/src/modes/components/custom-message.ts +65 -0
- package/src/modes/components/custom-model-preset-wizard.ts +293 -0
- package/src/modes/components/custom-provider-wizard.ts +318 -0
- package/src/modes/components/diff.ts +363 -0
- package/src/modes/components/dynamic-border.ts +25 -0
- package/src/modes/components/eval-execution.ts +168 -0
- package/src/modes/components/execution-shared.ts +102 -0
- package/src/modes/components/extensions/extension-dashboard.ts +350 -0
- package/src/modes/components/extensions/extension-list.ts +492 -0
- package/src/modes/components/extensions/index.ts +9 -0
- package/src/modes/components/extensions/inspector-panel.ts +317 -0
- package/src/modes/components/extensions/state-manager.ts +628 -0
- package/src/modes/components/extensions/types.ts +191 -0
- package/src/modes/components/footer.ts +270 -0
- package/src/modes/components/history-search.ts +162 -0
- package/src/modes/components/hook-editor.ts +151 -0
- package/src/modes/components/hook-input.ts +79 -0
- package/src/modes/components/hook-message.ts +68 -0
- package/src/modes/components/hook-selector.ts +582 -0
- package/src/modes/components/index.ts +36 -0
- package/src/modes/components/jobs-overlay-model.ts +109 -0
- package/src/modes/components/jobs-overlay.ts +172 -0
- package/src/modes/components/keybinding-hints.ts +65 -0
- package/src/modes/components/login-dialog.ts +164 -0
- package/src/modes/components/message-frame.ts +88 -0
- package/src/modes/components/model-selector.ts +1477 -0
- package/src/modes/components/oauth-selector.ts +253 -0
- package/src/modes/components/plugin-selector.ts +95 -0
- package/src/modes/components/plugin-settings.ts +488 -0
- package/src/modes/components/provider-onboarding-selector.ts +98 -0
- package/src/modes/components/queue-mode-selector.ts +56 -0
- package/src/modes/components/read-tool-group.ts +267 -0
- package/src/modes/components/runtime-mcp-add-wizard.ts +1392 -0
- package/src/modes/components/session-observer-overlay.ts +839 -0
- package/src/modes/components/session-selector.ts +343 -0
- package/src/modes/components/settings-defs.ts +175 -0
- package/src/modes/components/settings-selector.ts +662 -0
- package/src/modes/components/show-images-selector.ts +45 -0
- package/src/modes/components/skill-hud/render.ts +83 -0
- package/src/modes/components/skill-message.ts +152 -0
- package/src/modes/components/status-line/context-thresholds.ts +68 -0
- package/src/modes/components/status-line/git-utils.ts +42 -0
- package/src/modes/components/status-line/index.ts +4 -0
- package/src/modes/components/status-line/presets.ts +119 -0
- package/src/modes/components/status-line/segments.ts +590 -0
- package/src/modes/components/status-line/separators.ts +55 -0
- package/src/modes/components/status-line/token-rate.ts +66 -0
- package/src/modes/components/status-line/types.ts +92 -0
- package/src/modes/components/status-line.ts +853 -0
- package/src/modes/components/theme-selector.ts +63 -0
- package/src/modes/components/thinking-selector.ts +52 -0
- package/src/modes/components/todo-reminder.ts +40 -0
- package/src/modes/components/tool-execution.ts +853 -0
- package/src/modes/components/tree-selector.ts +930 -0
- package/src/modes/components/ttsr-notification.ts +80 -0
- package/src/modes/components/user-message-selector.ts +141 -0
- package/src/modes/components/user-message.ts +51 -0
- package/src/modes/components/visual-truncate.ts +63 -0
- package/src/modes/components/welcome.ts +409 -0
- package/src/modes/controllers/btw-controller.ts +105 -0
- package/src/modes/controllers/command-controller-shared.ts +108 -0
- package/src/modes/controllers/command-controller.ts +1672 -0
- package/src/modes/controllers/event-controller.ts +852 -0
- package/src/modes/controllers/extension-ui-controller.ts +1017 -0
- package/src/modes/controllers/input-controller.ts +1047 -0
- package/src/modes/controllers/runtime-mcp-command-controller.ts +1934 -0
- package/src/modes/controllers/selector-controller.ts +1407 -0
- package/src/modes/controllers/ssh-command-controller.ts +384 -0
- package/src/modes/controllers/todo-command-controller.ts +485 -0
- package/src/modes/data/emojis.json +1 -0
- package/src/modes/emoji-autocomplete.ts +285 -0
- package/src/modes/index.ts +35 -0
- package/src/modes/interactive-mode.ts +2677 -0
- package/src/modes/jobs-observer.ts +204 -0
- package/src/modes/oauth-manual-input.ts +42 -0
- package/src/modes/print-mode.ts +131 -0
- package/src/modes/prompt-action-autocomplete.ts +409 -0
- package/src/modes/rpc/host-tools.ts +1 -0
- package/src/modes/rpc/host-uris.ts +1 -0
- package/src/modes/rpc/rpc-client.ts +1085 -0
- package/src/modes/rpc/rpc-mode.ts +808 -0
- package/src/modes/rpc/rpc-socket-security.ts +103 -0
- package/src/modes/rpc/rpc-types.ts +613 -0
- package/src/modes/runtime-init.ts +116 -0
- package/src/modes/session-observer-registry.ts +146 -0
- package/src/modes/shared/agent-wire/approval-gate.ts +151 -0
- package/src/modes/shared/agent-wire/command-contract.ts +18 -0
- package/src/modes/shared/agent-wire/command-dispatch.ts +466 -0
- package/src/modes/shared/agent-wire/command-validation.ts +167 -0
- package/src/modes/shared/agent-wire/deep-interview-gate.ts +251 -0
- package/src/modes/shared/agent-wire/event-contract.ts +147 -0
- package/src/modes/shared/agent-wire/event-envelope.ts +140 -0
- package/src/modes/shared/agent-wire/event-observation.ts +397 -0
- package/src/modes/shared/agent-wire/handshake.ts +157 -0
- package/src/modes/shared/agent-wire/host-tool-bridge.ts +197 -0
- package/src/modes/shared/agent-wire/host-uri-bridge.ts +236 -0
- package/src/modes/shared/agent-wire/protocol.ts +46 -0
- package/src/modes/shared/agent-wire/responses.ts +17 -0
- package/src/modes/shared/agent-wire/scopes.ts +92 -0
- package/src/modes/shared/agent-wire/session-registry.ts +109 -0
- package/src/modes/shared/agent-wire/ui-request-broker.ts +150 -0
- package/src/modes/shared/agent-wire/ui-result.ts +48 -0
- package/src/modes/shared/agent-wire/unattended-action-policy.ts +365 -0
- package/src/modes/shared/agent-wire/unattended-audit.ts +175 -0
- package/src/modes/shared/agent-wire/unattended-run-controller.ts +426 -0
- package/src/modes/shared/agent-wire/unattended-session.ts +219 -0
- package/src/modes/shared/agent-wire/workflow-gate-broker.ts +324 -0
- package/src/modes/shared/agent-wire/workflow-gate-schema.ts +331 -0
- package/src/modes/shared.ts +55 -0
- package/src/modes/theme/defaults/blue-octopus.json +126 -0
- package/src/modes/theme/defaults/claude-code.json +100 -0
- package/src/modes/theme/defaults/codex.json +100 -0
- package/src/modes/theme/defaults/index.ts +13 -0
- package/src/modes/theme/defaults/opencode.json +102 -0
- package/src/modes/theme/defaults/red-octopus.json +123 -0
- package/src/modes/theme/mermaid-cache.ts +29 -0
- package/src/modes/theme/shimmer.ts +219 -0
- package/src/modes/theme/theme-schema.json +429 -0
- package/src/modes/theme/theme.ts +2452 -0
- package/src/modes/types.ts +313 -0
- package/src/modes/utils/abort-message.ts +41 -0
- package/src/modes/utils/context-usage.ts +391 -0
- package/src/modes/utils/hotkeys-markdown.ts +61 -0
- package/src/modes/utils/keybinding-matchers.ts +30 -0
- package/src/modes/utils/tools-markdown.ts +27 -0
- package/src/modes/utils/ui-helpers.ts +749 -0
- package/src/plan-mode/approved-plan.ts +163 -0
- package/src/plan-mode/state.ts +6 -0
- package/src/prompts/agents/architect.md +92 -0
- package/src/prompts/agents/critic.md +65 -0
- package/src/prompts/agents/executor.md +63 -0
- package/src/prompts/agents/explore.md +58 -0
- package/src/prompts/agents/frontmatter.md +14 -0
- package/src/prompts/agents/init.md +34 -0
- package/src/prompts/agents/plan.md +49 -0
- package/src/prompts/agents/planner.md +60 -0
- package/src/prompts/agents/reviewer.md +141 -0
- package/src/prompts/agents/task.md +16 -0
- package/src/prompts/ci-green-request.md +36 -0
- package/src/prompts/goals/goal-continuation.md +26 -0
- package/src/prompts/goals/goal-mode-active.md +22 -0
- package/src/prompts/memories/consolidation.md +30 -0
- package/src/prompts/memories/read-path.md +10 -0
- package/src/prompts/memories/stage_one_input.md +6 -0
- package/src/prompts/memories/stage_one_system.md +21 -0
- package/src/prompts/memories/unavailable.md +9 -0
- package/src/prompts/review-request.md +70 -0
- package/src/prompts/system/agent-creation-architect.md +75 -0
- package/src/prompts/system/agent-creation-user.md +6 -0
- package/src/prompts/system/auto-continue.md +1 -0
- package/src/prompts/system/btw-user.md +8 -0
- package/src/prompts/system/commit-message-system.md +2 -0
- package/src/prompts/system/custom-system-prompt.md +64 -0
- package/src/prompts/system/eager-todo.md +13 -0
- package/src/prompts/system/irc-incoming.md +8 -0
- package/src/prompts/system/plan-mode-active.md +116 -0
- package/src/prompts/system/plan-mode-approved.md +28 -0
- package/src/prompts/system/plan-mode-compact-instructions.md +16 -0
- package/src/prompts/system/plan-mode-reference.md +14 -0
- package/src/prompts/system/plan-mode-subagent.md +34 -0
- package/src/prompts/system/plan-mode-tool-decision-reminder.md +9 -0
- package/src/prompts/system/project-prompt.md +46 -0
- package/src/prompts/system/rlm-report-command.md +1 -0
- package/src/prompts/system/rlm-research.md +23 -0
- package/src/prompts/system/subagent-system-prompt.md +60 -0
- package/src/prompts/system/subagent-user-prompt.md +3 -0
- package/src/prompts/system/subagent-yield-reminder.md +12 -0
- package/src/prompts/system/system-prompt.md +275 -0
- package/src/prompts/system/title-system.md +2 -0
- package/src/prompts/system/ttsr-interrupt.md +7 -0
- package/src/prompts/system/ttsr-tool-reminder.md +5 -0
- package/src/prompts/system/web-search.md +25 -0
- package/src/prompts/tools/apply-patch.md +65 -0
- package/src/prompts/tools/ask.md +29 -0
- package/src/prompts/tools/ast-edit.md +39 -0
- package/src/prompts/tools/ast-grep.md +42 -0
- package/src/prompts/tools/async-result.md +8 -0
- package/src/prompts/tools/bash.md +69 -0
- package/src/prompts/tools/browser.md +75 -0
- package/src/prompts/tools/calculator.md +10 -0
- package/src/prompts/tools/checkpoint.md +16 -0
- package/src/prompts/tools/computer.md +74 -0
- package/src/prompts/tools/cron.md +25 -0
- package/src/prompts/tools/debug.md +33 -0
- package/src/prompts/tools/eval.md +75 -0
- package/src/prompts/tools/find.md +34 -0
- package/src/prompts/tools/github.md +20 -0
- package/src/prompts/tools/goal.md +21 -0
- package/src/prompts/tools/hashline.md +130 -0
- package/src/prompts/tools/image-gen.md +7 -0
- package/src/prompts/tools/inspect-image-system.md +20 -0
- package/src/prompts/tools/inspect-image.md +32 -0
- package/src/prompts/tools/irc.md +49 -0
- package/src/prompts/tools/job.md +27 -0
- package/src/prompts/tools/lsp.md +42 -0
- package/src/prompts/tools/monitor.md +30 -0
- package/src/prompts/tools/patch.md +70 -0
- package/src/prompts/tools/read.md +82 -0
- package/src/prompts/tools/recall.md +6 -0
- package/src/prompts/tools/recipe.md +16 -0
- package/src/prompts/tools/reflect.md +6 -0
- package/src/prompts/tools/render-mermaid.md +9 -0
- package/src/prompts/tools/replace.md +36 -0
- package/src/prompts/tools/resolve.md +9 -0
- package/src/prompts/tools/retain.md +7 -0
- package/src/prompts/tools/rewind.md +13 -0
- package/src/prompts/tools/search-tool-bm25.md +33 -0
- package/src/prompts/tools/search.md +25 -0
- package/src/prompts/tools/skill.md +28 -0
- package/src/prompts/tools/ssh.md +35 -0
- package/src/prompts/tools/subagent.md +56 -0
- package/src/prompts/tools/task-summary.md +22 -0
- package/src/prompts/tools/task.md +86 -0
- package/src/prompts/tools/todo-write.md +50 -0
- package/src/prompts/tools/vim.md +98 -0
- package/src/prompts/tools/web-search.md +17 -0
- package/src/prompts/tools/write.md +14 -0
- package/src/registry/agent-registry.ts +140 -0
- package/src/reminders/star-reminder.ts +420 -0
- package/src/rlm/artifacts.ts +60 -0
- package/src/rlm/complete-research-tool.ts +163 -0
- package/src/rlm/data-context.ts +26 -0
- package/src/rlm/index.ts +339 -0
- package/src/rlm/notebook.ts +108 -0
- package/src/rlm/preset.ts +76 -0
- package/src/rlm/python-tool.ts +68 -0
- package/src/rlm/report.ts +70 -0
- package/src/rlm/types.ts +40 -0
- package/src/runtime/process-lifecycle.ts +400 -0
- package/src/runtime-mcp/client.ts +485 -0
- package/src/runtime-mcp/config-writer.ts +225 -0
- package/src/runtime-mcp/config.ts +365 -0
- package/src/runtime-mcp/discoverable-tool-metadata.ts +25 -0
- package/src/runtime-mcp/index.ts +29 -0
- package/src/runtime-mcp/json-rpc.ts +84 -0
- package/src/runtime-mcp/loader.ts +124 -0
- package/src/runtime-mcp/manager.ts +1331 -0
- package/src/runtime-mcp/oauth-discovery.ts +349 -0
- package/src/runtime-mcp/oauth-flow.ts +409 -0
- package/src/runtime-mcp/render.ts +123 -0
- package/src/runtime-mcp/smithery-auth.ts +104 -0
- package/src/runtime-mcp/smithery-connect.ts +145 -0
- package/src/runtime-mcp/smithery-registry.ts +477 -0
- package/src/runtime-mcp/tool-bridge.ts +416 -0
- package/src/runtime-mcp/tool-cache.ts +117 -0
- package/src/runtime-mcp/transports/http.ts +504 -0
- package/src/runtime-mcp/transports/index.ts +6 -0
- package/src/runtime-mcp/transports/stdio.ts +352 -0
- package/src/runtime-mcp/types.ts +426 -0
- package/src/sdk.ts +2290 -0
- package/src/secrets/index.ts +116 -0
- package/src/secrets/obfuscator.ts +352 -0
- package/src/secrets/regex.ts +21 -0
- package/src/session/agent-session.ts +10226 -0
- package/src/session/agent-storage.ts +466 -0
- package/src/session/artifacts.ts +150 -0
- package/src/session/auth-broker-config.ts +102 -0
- package/src/session/auth-storage.ts +23 -0
- package/src/session/blob-store.ts +428 -0
- package/src/session/client-bridge.ts +85 -0
- package/src/session/contribution-prep.ts +320 -0
- package/src/session/history-storage.ts +332 -0
- package/src/session/messages.ts +406 -0
- package/src/session/session-dump-format.ts +209 -0
- package/src/session/session-manager.ts +4049 -0
- package/src/session/session-storage.ts +415 -0
- package/src/session/streaming-output.ts +1269 -0
- package/src/session/tool-choice-queue.ts +236 -0
- package/src/session/yield-queue.ts +155 -0
- package/src/setup/credential-import.ts +429 -0
- package/src/setup/hermes/templates/operator-instructions.v1.md +36 -0
- package/src/setup/hermes-setup.ts +484 -0
- package/src/setup/model-onboarding-guidance.ts +48 -0
- package/src/setup/provider-onboarding.ts +358 -0
- package/src/skc-runtime/cli-write-receipt.ts +31 -0
- package/src/skc-runtime/deep-interview-recorder.ts +457 -0
- package/src/skc-runtime/deep-interview-runtime.ts +639 -0
- package/src/skc-runtime/deep-interview-state.ts +324 -0
- package/src/skc-runtime/gc-render.ts +70 -0
- package/src/skc-runtime/gc-runtime.ts +403 -0
- package/src/skc-runtime/goal-mode-request.ts +223 -0
- package/src/skc-runtime/launch-tmux.ts +423 -0
- package/src/skc-runtime/launch-worktree.ts +302 -0
- package/src/skc-runtime/ledger-event-renderer.ts +164 -0
- package/src/skc-runtime/ralplan-runtime.ts +877 -0
- package/src/skc-runtime/restricted-role-agent-bash.ts +5 -0
- package/src/skc-runtime/session-state-sidecar.ts +177 -0
- package/src/skc-runtime/state-graph.ts +86 -0
- package/src/skc-runtime/state-migrations.ts +179 -0
- package/src/skc-runtime/state-renderer.ts +354 -0
- package/src/skc-runtime/state-runtime.ts +2023 -0
- package/src/skc-runtime/state-schema.ts +192 -0
- package/src/skc-runtime/state-validation.ts +49 -0
- package/src/skc-runtime/state-writer.ts +1012 -0
- package/src/skc-runtime/team-gc.ts +49 -0
- package/src/skc-runtime/team-runtime.ts +4355 -0
- package/src/skc-runtime/tmux-common.ts +172 -0
- package/src/skc-runtime/tmux-gc.ts +239 -0
- package/src/skc-runtime/tmux-sessions.ts +271 -0
- package/src/skc-runtime/ultragoal-guard.ts +455 -0
- package/src/skc-runtime/ultragoal-runtime.ts +3684 -0
- package/src/skc-runtime/workflow-command-ref.ts +239 -0
- package/src/skc-runtime/workflow-manifest.generated.json +1676 -0
- package/src/skc-runtime/workflow-manifest.ts +454 -0
- package/src/skill-state/active-state.ts +839 -0
- package/src/skill-state/deep-interview-mutation-guard.ts +452 -0
- package/src/skill-state/initial-phase.ts +19 -0
- package/src/skill-state/workflow-hud.ts +274 -0
- package/src/skill-state/workflow-state-contract.ts +150 -0
- package/src/skill-state/workflow-state-version.ts +3 -0
- package/src/slash-commands/acp-builtins.ts +55 -0
- package/src/slash-commands/builtin-registry.ts +1206 -0
- package/src/slash-commands/helpers/context-report.ts +149 -0
- package/src/slash-commands/helpers/fast-status-report.ts +111 -0
- package/src/slash-commands/helpers/format.ts +46 -0
- package/src/slash-commands/helpers/mcp.ts +532 -0
- package/src/slash-commands/helpers/parse.ts +85 -0
- package/src/slash-commands/helpers/ssh.ts +195 -0
- package/src/slash-commands/helpers/todo.ts +279 -0
- package/src/slash-commands/helpers/usage-report.ts +91 -0
- package/src/slash-commands/types.ts +125 -0
- package/src/ssh/config-writer.ts +183 -0
- package/src/ssh/connection-manager.ts +482 -0
- package/src/ssh/ssh-executor.ts +133 -0
- package/src/ssh/sshfs-mount.ts +140 -0
- package/src/ssh/utils.ts +8 -0
- package/src/stt/downloader.ts +71 -0
- package/src/stt/index.ts +3 -0
- package/src/stt/recorder.ts +351 -0
- package/src/stt/setup.ts +52 -0
- package/src/stt/stt-controller.ts +160 -0
- package/src/stt/transcribe.py +70 -0
- package/src/stt/transcriber.ts +91 -0
- package/src/system-prompt.ts +581 -0
- package/src/task/agents.ts +164 -0
- package/src/task/commands.ts +131 -0
- package/src/task/discovery.ts +136 -0
- package/src/task/executor.ts +1733 -0
- package/src/task/fork-context-advisory.ts +99 -0
- package/src/task/id.ts +33 -0
- package/src/task/index.ts +1788 -0
- package/src/task/name-generator.ts +1577 -0
- package/src/task/output-manager.ts +108 -0
- package/src/task/parallel.ts +116 -0
- package/src/task/receipt.ts +304 -0
- package/src/task/render.ts +1101 -0
- package/src/task/roi-reconciliation.ts +90 -0
- package/src/task/simple-mode.ts +27 -0
- package/src/task/skc-command.ts +26 -0
- package/src/task/spawn-gate.ts +132 -0
- package/src/task/subprocess-tool-registry.ts +88 -0
- package/src/task/types.ts +431 -0
- package/src/task/worktree.ts +506 -0
- package/src/thinking-metadata.ts +51 -0
- package/src/thinking.ts +73 -0
- package/src/tool-discovery/tool-index.ts +400 -0
- package/src/tools/archive-reader.ts +330 -0
- package/src/tools/ask.ts +998 -0
- package/src/tools/ast-edit.ts +550 -0
- package/src/tools/ast-grep.ts +424 -0
- package/src/tools/auto-generated-guard.ts +305 -0
- package/src/tools/bash-allowed-prefixes.ts +252 -0
- package/src/tools/bash-command-fixup.ts +37 -0
- package/src/tools/bash-interactive.ts +388 -0
- package/src/tools/bash-interceptor.ts +67 -0
- package/src/tools/bash-pty-selection.ts +14 -0
- package/src/tools/bash-skill-urls.ts +248 -0
- package/src/tools/bash.ts +1302 -0
- package/src/tools/browser/actions.ts +189 -0
- package/src/tools/browser/attach.ts +275 -0
- package/src/tools/browser/launch.ts +651 -0
- package/src/tools/browser/readable.ts +95 -0
- package/src/tools/browser/registry.ts +384 -0
- package/src/tools/browser/render.ts +220 -0
- package/src/tools/browser/tab-protocol.ts +105 -0
- package/src/tools/browser/tab-supervisor.ts +599 -0
- package/src/tools/browser/tab-worker-entry.ts +21 -0
- package/src/tools/browser/tab-worker.ts +1054 -0
- package/src/tools/browser.ts +458 -0
- package/src/tools/calculator.ts +540 -0
- package/src/tools/checkpoint.ts +134 -0
- package/src/tools/computer/render.ts +78 -0
- package/src/tools/computer.ts +640 -0
- package/src/tools/conflict-detect.ts +672 -0
- package/src/tools/context.ts +39 -0
- package/src/tools/cron.ts +709 -0
- package/src/tools/debug.ts +1014 -0
- package/src/tools/eval.ts +1101 -0
- package/src/tools/fetch.ts +1482 -0
- package/src/tools/file-recorder.ts +35 -0
- package/src/tools/find.ts +543 -0
- package/src/tools/fs-cache-invalidation.ts +28 -0
- package/src/tools/gh-format.ts +12 -0
- package/src/tools/gh-renderer.ts +428 -0
- package/src/tools/gh.ts +3737 -0
- package/src/tools/github-cache.ts +548 -0
- package/src/tools/grouped-file-output.ts +96 -0
- package/src/tools/hindsight-recall.ts +66 -0
- package/src/tools/hindsight-reflect.ts +55 -0
- package/src/tools/hindsight-retain.ts +54 -0
- package/src/tools/image-gen.ts +1284 -0
- package/src/tools/index.ts +595 -0
- package/src/tools/inspect-image-renderer.ts +103 -0
- package/src/tools/inspect-image.ts +167 -0
- package/src/tools/irc.ts +239 -0
- package/src/tools/job.ts +614 -0
- package/src/tools/json-tree.ts +256 -0
- package/src/tools/jtd-to-json-schema.ts +219 -0
- package/src/tools/jtd-to-typescript.ts +136 -0
- package/src/tools/jtd-utils.ts +102 -0
- package/src/tools/list-limit.ts +40 -0
- package/src/tools/match-line-format.ts +22 -0
- package/src/tools/monitor.ts +252 -0
- package/src/tools/output-meta.ts +754 -0
- package/src/tools/path-utils.ts +741 -0
- package/src/tools/plan-mode-guard.ts +68 -0
- package/src/tools/puppeteer/00_stealth_tampering.txt +63 -0
- package/src/tools/puppeteer/01_stealth_activity.txt +20 -0
- package/src/tools/puppeteer/02_stealth_hairline.txt +11 -0
- package/src/tools/puppeteer/03_stealth_botd.txt +384 -0
- package/src/tools/puppeteer/04_stealth_iframe.txt +81 -0
- package/src/tools/puppeteer/05_stealth_webgl.txt +75 -0
- package/src/tools/puppeteer/06_stealth_screen.txt +72 -0
- package/src/tools/puppeteer/07_stealth_fonts.txt +97 -0
- package/src/tools/puppeteer/08_stealth_audio.txt +51 -0
- package/src/tools/puppeteer/09_stealth_locale.txt +46 -0
- package/src/tools/puppeteer/10_stealth_plugins.txt +206 -0
- package/src/tools/puppeteer/11_stealth_hardware.txt +8 -0
- package/src/tools/puppeteer/12_stealth_codecs.txt +40 -0
- package/src/tools/puppeteer/13_stealth_worker.txt +74 -0
- package/src/tools/read.ts +2332 -0
- package/src/tools/recipe/index.ts +80 -0
- package/src/tools/recipe/render.ts +19 -0
- package/src/tools/recipe/runner.ts +219 -0
- package/src/tools/recipe/runners/cargo.ts +131 -0
- package/src/tools/recipe/runners/index.ts +8 -0
- package/src/tools/recipe/runners/just.ts +73 -0
- package/src/tools/recipe/runners/make.ts +101 -0
- package/src/tools/recipe/runners/pkg.ts +167 -0
- package/src/tools/recipe/runners/task.ts +72 -0
- package/src/tools/render-mermaid.ts +68 -0
- package/src/tools/render-utils.ts +774 -0
- package/src/tools/renderers.ts +79 -0
- package/src/tools/resolve.ts +333 -0
- package/src/tools/review.ts +252 -0
- package/src/tools/search-tool-bm25.ts +360 -0
- package/src/tools/search.ts +787 -0
- package/src/tools/skill.ts +170 -0
- package/src/tools/sqlite-reader.ts +750 -0
- package/src/tools/ssh.ts +310 -0
- package/src/tools/subagent-render.ts +268 -0
- package/src/tools/subagent.ts +862 -0
- package/src/tools/todo-write.ts +695 -0
- package/src/tools/tool-errors.ts +62 -0
- package/src/tools/tool-result.ts +86 -0
- package/src/tools/tool-timeouts.ts +31 -0
- package/src/tools/ultragoal-ask-guard.ts +39 -0
- package/src/tools/vim.ts +949 -0
- package/src/tools/write.ts +953 -0
- package/src/tools/yield.ts +268 -0
- package/src/tui/code-cell.ts +201 -0
- package/src/tui/file-list.ts +55 -0
- package/src/tui/hyperlink.ts +126 -0
- package/src/tui/index.ts +12 -0
- package/src/tui/output-block.ts +150 -0
- package/src/tui/status-line.ts +39 -0
- package/src/tui/tree-list.ts +84 -0
- package/src/tui/types.ts +15 -0
- package/src/tui/utils.ts +103 -0
- package/src/utils/changelog.ts +121 -0
- package/src/utils/clipboard.ts +156 -0
- package/src/utils/command-args.ts +76 -0
- package/src/utils/commit-message-generator.ts +135 -0
- package/src/utils/edit-mode.ts +42 -0
- package/src/utils/event-bus.ts +33 -0
- package/src/utils/external-editor.ts +65 -0
- package/src/utils/file-display-mode.ts +45 -0
- package/src/utils/file-mentions.ts +376 -0
- package/src/utils/git.ts +1536 -0
- package/src/utils/image-loading.ts +102 -0
- package/src/utils/image-resize.ts +309 -0
- package/src/utils/lang-from-path.ts +239 -0
- package/src/utils/markit.ts +89 -0
- package/src/utils/open.ts +20 -0
- package/src/utils/session-color.ts +43 -0
- package/src/utils/shell-snapshot.ts +187 -0
- package/src/utils/sixel.ts +69 -0
- package/src/utils/title-generator.ts +237 -0
- package/src/utils/tool-choice.ts +62 -0
- package/src/utils/tools-manager.ts +363 -0
- package/src/vim/buffer.ts +309 -0
- package/src/vim/commands.ts +382 -0
- package/src/vim/engine.ts +2409 -0
- package/src/vim/parser.ts +134 -0
- package/src/vim/render.ts +252 -0
- package/src/vim/types.ts +197 -0
- package/src/web/kagi.ts +183 -0
- package/src/web/parallel.ts +349 -0
- package/src/web/scrapers/artifacthub.ts +207 -0
- package/src/web/scrapers/arxiv.ts +83 -0
- package/src/web/scrapers/aur.ts +162 -0
- package/src/web/scrapers/biorxiv.ts +133 -0
- package/src/web/scrapers/bluesky.ts +262 -0
- package/src/web/scrapers/brew.ts +172 -0
- package/src/web/scrapers/cheatsh.ts +68 -0
- package/src/web/scrapers/chocolatey.ts +196 -0
- package/src/web/scrapers/choosealicense.ts +95 -0
- package/src/web/scrapers/cisa-kev.ts +87 -0
- package/src/web/scrapers/clojars.ts +154 -0
- package/src/web/scrapers/coingecko.ts +177 -0
- package/src/web/scrapers/crates-io.ts +97 -0
- package/src/web/scrapers/crossref.ts +136 -0
- package/src/web/scrapers/devto.ts +147 -0
- package/src/web/scrapers/discogs.ts +306 -0
- package/src/web/scrapers/discourse.ts +197 -0
- package/src/web/scrapers/dockerhub.ts +138 -0
- package/src/web/scrapers/docs-rs.ts +653 -0
- package/src/web/scrapers/fdroid.ts +134 -0
- package/src/web/scrapers/firefox-addons.ts +191 -0
- package/src/web/scrapers/flathub.ts +223 -0
- package/src/web/scrapers/github-gist.ts +58 -0
- package/src/web/scrapers/github.ts +452 -0
- package/src/web/scrapers/gitlab.ts +401 -0
- package/src/web/scrapers/go-pkg.ts +266 -0
- package/src/web/scrapers/hackage.ts +140 -0
- package/src/web/scrapers/hackernews.ts +189 -0
- package/src/web/scrapers/hex.ts +105 -0
- package/src/web/scrapers/huggingface.ts +321 -0
- package/src/web/scrapers/iacr.ts +89 -0
- package/src/web/scrapers/index.ts +252 -0
- package/src/web/scrapers/jetbrains-marketplace.ts +159 -0
- package/src/web/scrapers/lemmy.ts +203 -0
- package/src/web/scrapers/lobsters.ts +175 -0
- package/src/web/scrapers/mastodon.ts +292 -0
- package/src/web/scrapers/maven.ts +138 -0
- package/src/web/scrapers/mdn.ts +173 -0
- package/src/web/scrapers/metacpan.ts +222 -0
- package/src/web/scrapers/musicbrainz.ts +250 -0
- package/src/web/scrapers/npm.ts +98 -0
- package/src/web/scrapers/nuget.ts +183 -0
- package/src/web/scrapers/nvd.ts +222 -0
- package/src/web/scrapers/ollama.ts +239 -0
- package/src/web/scrapers/open-vsx.ts +106 -0
- package/src/web/scrapers/opencorporates.ts +292 -0
- package/src/web/scrapers/openlibrary.ts +336 -0
- package/src/web/scrapers/orcid.ts +286 -0
- package/src/web/scrapers/osv.ts +176 -0
- package/src/web/scrapers/packagist.ts +160 -0
- package/src/web/scrapers/pub-dev.ts +143 -0
- package/src/web/scrapers/pubmed.ts +211 -0
- package/src/web/scrapers/pypi.ts +112 -0
- package/src/web/scrapers/rawg.ts +110 -0
- package/src/web/scrapers/readthedocs.ts +120 -0
- package/src/web/scrapers/reddit.ts +95 -0
- package/src/web/scrapers/repology.ts +251 -0
- package/src/web/scrapers/rfc.ts +201 -0
- package/src/web/scrapers/rubygems.ts +103 -0
- package/src/web/scrapers/searchcode.ts +189 -0
- package/src/web/scrapers/sec-edgar.ts +261 -0
- package/src/web/scrapers/semantic-scholar.ts +171 -0
- package/src/web/scrapers/snapcraft.ts +187 -0
- package/src/web/scrapers/sourcegraph.ts +336 -0
- package/src/web/scrapers/spdx.ts +108 -0
- package/src/web/scrapers/spotify.ts +198 -0
- package/src/web/scrapers/stackoverflow.ts +120 -0
- package/src/web/scrapers/terraform.ts +277 -0
- package/src/web/scrapers/tldr.ts +47 -0
- package/src/web/scrapers/twitter.ts +93 -0
- package/src/web/scrapers/types.ts +318 -0
- package/src/web/scrapers/utils.ts +109 -0
- package/src/web/scrapers/vimeo.ts +133 -0
- package/src/web/scrapers/vscode-marketplace.ts +187 -0
- package/src/web/scrapers/w3c.ts +156 -0
- package/src/web/scrapers/wikidata.ts +344 -0
- package/src/web/scrapers/wikipedia.ts +84 -0
- package/src/web/scrapers/youtube.ts +319 -0
- package/src/web/search/index.ts +326 -0
- package/src/web/search/provider.ts +324 -0
- package/src/web/search/providers/anthropic.ts +302 -0
- package/src/web/search/providers/base.ts +94 -0
- package/src/web/search/providers/brave.ts +149 -0
- package/src/web/search/providers/codex.ts +557 -0
- package/src/web/search/providers/duckduckgo.ts +279 -0
- package/src/web/search/providers/exa.ts +197 -0
- package/src/web/search/providers/gemini.ts +455 -0
- package/src/web/search/providers/jina.ts +101 -0
- package/src/web/search/providers/kagi.ts +75 -0
- package/src/web/search/providers/kimi.ts +171 -0
- package/src/web/search/providers/openai-compatible.ts +151 -0
- package/src/web/search/providers/parallel.ts +210 -0
- package/src/web/search/providers/perplexity.ts +575 -0
- package/src/web/search/providers/searxng.ts +309 -0
- package/src/web/search/providers/synthetic.ts +108 -0
- package/src/web/search/providers/tavily.ts +173 -0
- package/src/web/search/providers/utils.ts +128 -0
- package/src/web/search/providers/xai.ts +511 -0
- package/src/web/search/providers/zai.ts +320 -0
- package/src/web/search/render.ts +306 -0
- package/src/web/search/types.ts +473 -0
- package/src/web/search/utils.ts +17 -0
- package/src/workspace-tree.ts +286 -0
|
@@ -0,0 +1,2006 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import * as nodeFs from "node:fs";
|
|
3
|
+
import * as fs from "node:fs/promises";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
import { VERSION } from "@sayknow-cli/utils/dirs";
|
|
6
|
+
import {
|
|
7
|
+
COORDINATOR_MCP_PROTOCOL_VERSION,
|
|
8
|
+
COORDINATOR_MCP_SERVER_NAME,
|
|
9
|
+
COORDINATOR_MCP_TOOL_NAMES,
|
|
10
|
+
type CoordinatorToolName,
|
|
11
|
+
} from "../coordinator/contract";
|
|
12
|
+
import {
|
|
13
|
+
SKC_COORDINATOR_SESSION_ID_ENV,
|
|
14
|
+
SKC_COORDINATOR_SESSION_STATE_FILE_ENV,
|
|
15
|
+
} from "../skc-runtime/session-state-sidecar";
|
|
16
|
+
import {
|
|
17
|
+
assertCoordinatorArtifactPath,
|
|
18
|
+
assertCoordinatorWorkdir,
|
|
19
|
+
buildCoordinatorMcpConfig,
|
|
20
|
+
type CoordinatorMcpConfig,
|
|
21
|
+
coordinatorNamespacePath,
|
|
22
|
+
requireCoordinatorMutation,
|
|
23
|
+
} from "./policy";
|
|
24
|
+
|
|
25
|
+
export type { CoordinatorToolName };
|
|
26
|
+
export { COORDINATOR_MCP_PROTOCOL_VERSION, COORDINATOR_MCP_SERVER_NAME, COORDINATOR_MCP_TOOL_NAMES };
|
|
27
|
+
|
|
28
|
+
interface JsonRpcRequest {
|
|
29
|
+
jsonrpc: "2.0";
|
|
30
|
+
id?: string | number | null;
|
|
31
|
+
method: string;
|
|
32
|
+
params?: unknown;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type JsonRpcResult = any;
|
|
36
|
+
|
|
37
|
+
interface JsonRpcResponse {
|
|
38
|
+
jsonrpc: "2.0";
|
|
39
|
+
id: string | number | null;
|
|
40
|
+
result?: JsonRpcResult;
|
|
41
|
+
error?: { code: number; message: string; data?: unknown };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface SessionStartInput {
|
|
45
|
+
cwd: string;
|
|
46
|
+
prompt?: string;
|
|
47
|
+
namespace: { profile: string | null; repo: string | null };
|
|
48
|
+
worktree: true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface SessionRegisterInput {
|
|
52
|
+
sessionId: string;
|
|
53
|
+
cwd: string;
|
|
54
|
+
tmuxSession: string;
|
|
55
|
+
tmuxTarget: string;
|
|
56
|
+
visible: boolean;
|
|
57
|
+
warpAttached: boolean | null;
|
|
58
|
+
source: string;
|
|
59
|
+
model: string | null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface CoordinatorFinalResponse {
|
|
63
|
+
text: string | null;
|
|
64
|
+
format: "markdown";
|
|
65
|
+
source: string | null;
|
|
66
|
+
artifact_path: string | null;
|
|
67
|
+
truncated: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function reportableFinalResponse(response: CoordinatorFinalResponse): boolean {
|
|
71
|
+
return (
|
|
72
|
+
(typeof response.text === "string" && response.text.trim().length > 0) ||
|
|
73
|
+
(typeof response.artifact_path === "string" && response.artifact_path.trim().length > 0)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface RuntimeSessionStatePayload extends CoordinatorSessionState {
|
|
78
|
+
final_response?: CoordinatorFinalResponse;
|
|
79
|
+
error?: { code: string; message: string; recoverable: boolean } | null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface CoordinatorServices {
|
|
83
|
+
listSessions?: () => unknown[] | Promise<unknown[]>;
|
|
84
|
+
startSession?: (input: SessionStartInput) => unknown | Promise<unknown>;
|
|
85
|
+
commandRunner?: (command: string[]) => Promise<{ exitCode: number; stdout: string; stderr: string }>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface CoordinatorMcpServerOptions {
|
|
89
|
+
env?: NodeJS.ProcessEnv;
|
|
90
|
+
services?: CoordinatorServices;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
interface LegacyHandlerOptions {
|
|
94
|
+
env?: NodeJS.ProcessEnv;
|
|
95
|
+
createSession?: () => unknown;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
type TurnStatus =
|
|
99
|
+
| "queued"
|
|
100
|
+
| "delivering"
|
|
101
|
+
| "active"
|
|
102
|
+
| "waiting_for_answer"
|
|
103
|
+
| "completing"
|
|
104
|
+
| "completed"
|
|
105
|
+
| "failed"
|
|
106
|
+
| "cancelled"
|
|
107
|
+
| "superseded";
|
|
108
|
+
|
|
109
|
+
interface TurnRecord {
|
|
110
|
+
schema_version: 1;
|
|
111
|
+
turn_id: string;
|
|
112
|
+
session_id: string;
|
|
113
|
+
namespace: { profile: string | null; repo: string | null };
|
|
114
|
+
status: TurnStatus;
|
|
115
|
+
prompt: { text: string; created_at: string; source: "mcp" | "question_answer" };
|
|
116
|
+
delivery: {
|
|
117
|
+
delivered: boolean;
|
|
118
|
+
queued: boolean;
|
|
119
|
+
target: string | null;
|
|
120
|
+
tmux_keys_sent?: boolean;
|
|
121
|
+
prompt_acknowledged?: boolean;
|
|
122
|
+
state?: "queued" | "tmux_keys_sent" | "acknowledged" | "unavailable";
|
|
123
|
+
attempts: Array<{
|
|
124
|
+
delivered: boolean;
|
|
125
|
+
created_at: string;
|
|
126
|
+
reason: string | null;
|
|
127
|
+
channel?: "tmux_keys" | "runtime_ack";
|
|
128
|
+
tmux_keys_sent?: boolean;
|
|
129
|
+
}>;
|
|
130
|
+
};
|
|
131
|
+
question_ids: string[];
|
|
132
|
+
final_response: {
|
|
133
|
+
text: string | null;
|
|
134
|
+
format: "markdown";
|
|
135
|
+
source: string | null;
|
|
136
|
+
artifact_path: string | null;
|
|
137
|
+
truncated: boolean;
|
|
138
|
+
};
|
|
139
|
+
evidence: Array<Record<string, unknown>>;
|
|
140
|
+
error: { code: string; message: string; recoverable: boolean } | null;
|
|
141
|
+
liveness: { checked_at: string | null; live: boolean | null; reason: string | null };
|
|
142
|
+
created_at: string;
|
|
143
|
+
updated_at: string;
|
|
144
|
+
started_at: string | null;
|
|
145
|
+
completed_at: string | null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
type CoordinatorSessionStateValue =
|
|
149
|
+
| "booting"
|
|
150
|
+
| "ready_for_input"
|
|
151
|
+
| "running"
|
|
152
|
+
| "needs_user_input"
|
|
153
|
+
| "completed"
|
|
154
|
+
| "errored"
|
|
155
|
+
| "stale"
|
|
156
|
+
| "unknown";
|
|
157
|
+
|
|
158
|
+
interface CoordinatorSessionState {
|
|
159
|
+
schema_version: 1;
|
|
160
|
+
session_id: string;
|
|
161
|
+
state: CoordinatorSessionStateValue;
|
|
162
|
+
ready_for_input: boolean;
|
|
163
|
+
current_turn_id: string | null;
|
|
164
|
+
last_turn_id: string | null;
|
|
165
|
+
updated_at: string;
|
|
166
|
+
source: "coordinator" | "agent_session_event";
|
|
167
|
+
live: boolean | null;
|
|
168
|
+
reason: string | null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
type CoordinatorEventKind =
|
|
172
|
+
| "session.registered"
|
|
173
|
+
| "session.started"
|
|
174
|
+
| "session.state_changed"
|
|
175
|
+
| "turn.queued"
|
|
176
|
+
| "turn.delivering"
|
|
177
|
+
| "turn.active"
|
|
178
|
+
| "turn.waiting_for_answer"
|
|
179
|
+
| "turn.completed"
|
|
180
|
+
| "turn.failed"
|
|
181
|
+
| "turn.cancelled"
|
|
182
|
+
| "turn.superseded"
|
|
183
|
+
| "question.opened"
|
|
184
|
+
| "question.answered"
|
|
185
|
+
| "report.written"
|
|
186
|
+
| "tmux.delivery_succeeded"
|
|
187
|
+
| "tmux.delivery_failed";
|
|
188
|
+
|
|
189
|
+
interface CoordinatorEvent {
|
|
190
|
+
schema_version: 1;
|
|
191
|
+
seq: number;
|
|
192
|
+
id: string;
|
|
193
|
+
timestamp: string;
|
|
194
|
+
kind: CoordinatorEventKind;
|
|
195
|
+
session_id?: string;
|
|
196
|
+
turn_id?: string;
|
|
197
|
+
question_id?: string;
|
|
198
|
+
report_id?: string;
|
|
199
|
+
summary: string;
|
|
200
|
+
payload_ref?: string;
|
|
201
|
+
metadata?: Record<string, string | number | boolean | null>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
interface CoordinatorEventInput {
|
|
205
|
+
kind: CoordinatorEventKind;
|
|
206
|
+
sessionId?: string | null;
|
|
207
|
+
turnId?: string | null;
|
|
208
|
+
questionId?: string | null;
|
|
209
|
+
reportId?: string | null;
|
|
210
|
+
summary: string;
|
|
211
|
+
payloadRef?: string | null;
|
|
212
|
+
metadata?: Record<string, string | number | boolean | null>;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const MISSING_FINAL_RESPONSE_ADVISORY = "completion_missing_final_response";
|
|
216
|
+
const ACTIVE_TURN_STATUSES = new Set<TurnStatus>(["delivering", "active", "waiting_for_answer", "completing"]);
|
|
217
|
+
const TERMINAL_TURN_STATUSES = new Set<TurnStatus>(["completed", "failed", "cancelled", "superseded"]);
|
|
218
|
+
const TURN_ID_PATTERN = /^turn-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
219
|
+
const SAFE_EXTERNAL_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/;
|
|
220
|
+
function asRecord(value: unknown): Record<string, unknown> | null {
|
|
221
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
222
|
+
? (value as Record<string, unknown>)
|
|
223
|
+
: null;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function textResult(
|
|
227
|
+
payload: unknown,
|
|
228
|
+
isError = false,
|
|
229
|
+
): { content: Array<{ type: "text"; text: string }>; isError: boolean } {
|
|
230
|
+
return {
|
|
231
|
+
content: [{ type: "text", text: typeof payload === "string" ? payload : JSON.stringify(payload) }],
|
|
232
|
+
isError,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function toolSchema(name: CoordinatorToolName): {
|
|
237
|
+
name: CoordinatorToolName;
|
|
238
|
+
description: string;
|
|
239
|
+
inputSchema: Record<string, unknown>;
|
|
240
|
+
} {
|
|
241
|
+
const allowMutation = { type: "boolean", description: "Required and must be true for mutating tools." };
|
|
242
|
+
const cwd = {
|
|
243
|
+
type: "string",
|
|
244
|
+
description: "Canonicalized SKC worktree or project directory inside configured roots.",
|
|
245
|
+
};
|
|
246
|
+
const sessionId = { type: "string", description: "SKC coordinator bridge session id." };
|
|
247
|
+
const pathField = { type: "string", description: "Artifact path inside configured safe roots." };
|
|
248
|
+
const common = { type: "object", properties: {} as Record<string, unknown> };
|
|
249
|
+
if (name === "skc_coordinator_register_session") {
|
|
250
|
+
return {
|
|
251
|
+
name,
|
|
252
|
+
description: "Register an existing visible tmux SKC session as a coordinator-authoritative session.",
|
|
253
|
+
inputSchema: {
|
|
254
|
+
type: "object",
|
|
255
|
+
properties: {
|
|
256
|
+
session_id: sessionId,
|
|
257
|
+
cwd,
|
|
258
|
+
tmux_session: { type: "string" },
|
|
259
|
+
tmux_target: { type: "string" },
|
|
260
|
+
visible: { type: "boolean" },
|
|
261
|
+
warp_attached: { type: "boolean" },
|
|
262
|
+
source: { type: "string" },
|
|
263
|
+
model: { type: "string" },
|
|
264
|
+
allow_mutation: allowMutation,
|
|
265
|
+
},
|
|
266
|
+
required: ["session_id", "cwd", "tmux_session", "tmux_target", "allow_mutation"],
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
if (name === "skc_coordinator_start_session") {
|
|
271
|
+
return {
|
|
272
|
+
name,
|
|
273
|
+
description: "Start a SKC worktree/tmux oriented session through the coordinator bridge.",
|
|
274
|
+
inputSchema: {
|
|
275
|
+
type: "object",
|
|
276
|
+
properties: { cwd, prompt: { type: "string" }, allow_mutation: allowMutation },
|
|
277
|
+
required: ["cwd", "allow_mutation"],
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
if (name === "skc_coordinator_send_prompt") {
|
|
282
|
+
return {
|
|
283
|
+
name,
|
|
284
|
+
description:
|
|
285
|
+
"Create a durable turn and deliver a bounded follow-up prompt for a selected coordinator bridge session.",
|
|
286
|
+
inputSchema: {
|
|
287
|
+
type: "object",
|
|
288
|
+
properties: {
|
|
289
|
+
session_id: sessionId,
|
|
290
|
+
prompt: { type: "string" },
|
|
291
|
+
queue: { type: "boolean" },
|
|
292
|
+
force: { type: "boolean" },
|
|
293
|
+
allow_mutation: allowMutation,
|
|
294
|
+
},
|
|
295
|
+
required: ["session_id", "prompt", "allow_mutation"],
|
|
296
|
+
},
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
if (name === "skc_coordinator_read_turn") {
|
|
300
|
+
return {
|
|
301
|
+
name,
|
|
302
|
+
description: "Read authoritative durable turn state plus bounded advisory tmux status.",
|
|
303
|
+
inputSchema: {
|
|
304
|
+
type: "object",
|
|
305
|
+
properties: { session_id: sessionId, turn_id: { type: "string" }, lines: { type: "number" } },
|
|
306
|
+
required: ["turn_id"],
|
|
307
|
+
},
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
if (name === "skc_coordinator_await_turn") {
|
|
311
|
+
return {
|
|
312
|
+
name,
|
|
313
|
+
description: "Poll a durable turn for a bounded time and return the same shape as read_turn.",
|
|
314
|
+
inputSchema: {
|
|
315
|
+
type: "object",
|
|
316
|
+
properties: {
|
|
317
|
+
session_id: sessionId,
|
|
318
|
+
turn_id: { type: "string" },
|
|
319
|
+
timeout_ms: { type: "number" },
|
|
320
|
+
poll_interval_ms: { type: "number" },
|
|
321
|
+
lines: { type: "number" },
|
|
322
|
+
},
|
|
323
|
+
required: ["turn_id"],
|
|
324
|
+
},
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
if (name === "skc_coordinator_submit_question_answer") {
|
|
328
|
+
return {
|
|
329
|
+
name,
|
|
330
|
+
description: "Submit a bounded structured answer by question id.",
|
|
331
|
+
inputSchema: {
|
|
332
|
+
type: "object",
|
|
333
|
+
properties: {
|
|
334
|
+
session_id: sessionId,
|
|
335
|
+
turn_id: { type: "string" },
|
|
336
|
+
question_id: { type: "string" },
|
|
337
|
+
answer: {},
|
|
338
|
+
allow_mutation: allowMutation,
|
|
339
|
+
},
|
|
340
|
+
required: ["question_id", "answer", "allow_mutation"],
|
|
341
|
+
},
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
if (name === "skc_coordinator_report_status") {
|
|
345
|
+
return {
|
|
346
|
+
name,
|
|
347
|
+
description: "Write a bounded coordinator coordination status report.",
|
|
348
|
+
inputSchema: {
|
|
349
|
+
type: "object",
|
|
350
|
+
properties: {
|
|
351
|
+
session_id: sessionId,
|
|
352
|
+
turn_id: { type: "string" },
|
|
353
|
+
status: { type: "string" },
|
|
354
|
+
summary: { type: "string" },
|
|
355
|
+
blocker: { type: "string" },
|
|
356
|
+
pr_url: { type: "string" },
|
|
357
|
+
evidence_paths: { type: "array", items: { type: "string" } },
|
|
358
|
+
allow_mutation: allowMutation,
|
|
359
|
+
},
|
|
360
|
+
required: ["status", "allow_mutation"],
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
if (name === "skc_coordinator_read_artifact") {
|
|
365
|
+
return {
|
|
366
|
+
name,
|
|
367
|
+
description: "Read one bounded artifact from configured safe roots.",
|
|
368
|
+
inputSchema: { type: "object", properties: { path: pathField }, required: ["path"] },
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
if (name === "skc_coordinator_read_status") {
|
|
372
|
+
return {
|
|
373
|
+
name,
|
|
374
|
+
description: "Read selected coordinator bridge session status.",
|
|
375
|
+
inputSchema: { type: "object", properties: { session_id: sessionId } },
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
if (name === "skc_coordinator_read_tail") {
|
|
379
|
+
return {
|
|
380
|
+
name,
|
|
381
|
+
description: "Read a bounded structured session tail, not tmux scrollback.",
|
|
382
|
+
inputSchema: { type: "object", properties: { session_id: sessionId, lines: { type: "number" } } },
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
if (name === "skc_coordinator_list_questions") {
|
|
386
|
+
return {
|
|
387
|
+
name,
|
|
388
|
+
description: "List bounded structured questions for coordinator coordination.",
|
|
389
|
+
inputSchema: { type: "object", properties: { session_id: sessionId, status: { type: "string" } } },
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
if (name === "skc_coordinator_list_artifacts") {
|
|
393
|
+
return { name, description: "List known safe artifact roots for coordinator coordination.", inputSchema: common };
|
|
394
|
+
}
|
|
395
|
+
if (name === "skc_coordinator_read_coordination_status") {
|
|
396
|
+
return { name, description: "Read coordinator coordination reports.", inputSchema: common };
|
|
397
|
+
}
|
|
398
|
+
if (name === "skc_coordinator_watch_events") {
|
|
399
|
+
return {
|
|
400
|
+
name,
|
|
401
|
+
description: "Long-poll the durable coordinator event journal for new bounded event records.",
|
|
402
|
+
inputSchema: {
|
|
403
|
+
type: "object",
|
|
404
|
+
properties: {
|
|
405
|
+
after_seq: { type: "number" },
|
|
406
|
+
session_id: sessionId,
|
|
407
|
+
event_types: { type: "array", items: { type: "string" } },
|
|
408
|
+
timeout_ms: { type: "number" },
|
|
409
|
+
limit: { type: "number" },
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
return { name, description: "List known scoped SKC coordinator bridge sessions.", inputSchema: common };
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function normalizeSession(session: Record<string, unknown>): Record<string, unknown> {
|
|
418
|
+
return {
|
|
419
|
+
session_id: session.sessionId ?? session.session_id ?? session.name ?? "unknown",
|
|
420
|
+
...(session.tmuxSession ? { tmux_session: session.tmuxSession } : {}),
|
|
421
|
+
...(session.cwd ? { cwd: session.cwd } : {}),
|
|
422
|
+
...(session.createdAt ? { created_at: session.createdAt } : {}),
|
|
423
|
+
...session,
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
async function ensureDir(dir: string): Promise<void> {
|
|
428
|
+
await fs.mkdir(dir, { recursive: true });
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
async function readJsonFile(file: string): Promise<unknown | null> {
|
|
432
|
+
try {
|
|
433
|
+
return JSON.parse(await fs.readFile(file, "utf8"));
|
|
434
|
+
} catch {
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
async function writeJsonFile(file: string, value: unknown): Promise<void> {
|
|
440
|
+
await ensureDir(path.dirname(file));
|
|
441
|
+
await fs.writeFile(file, `${JSON.stringify(value, null, 2)}\n`);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
async function listJsonFiles(dir: string): Promise<unknown[]> {
|
|
445
|
+
try {
|
|
446
|
+
const entries = await fs.readdir(dir);
|
|
447
|
+
const values = await Promise.all(
|
|
448
|
+
entries.filter(entry => entry.endsWith(".json")).map(entry => readJsonFile(path.join(dir, entry))),
|
|
449
|
+
);
|
|
450
|
+
return values.filter(value => value !== null);
|
|
451
|
+
} catch {
|
|
452
|
+
return [];
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const COORDINATOR_STATUS_EVENT_LIMIT = 100;
|
|
457
|
+
|
|
458
|
+
function jsonRecords(values: unknown[]): Array<Record<string, unknown>> {
|
|
459
|
+
return values.map(value => asRecord(value)).filter((value): value is Record<string, unknown> => value !== null);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function firstString(record: Record<string, unknown>, keys: string[]): string | null {
|
|
463
|
+
for (const key of keys) {
|
|
464
|
+
const value = record[key];
|
|
465
|
+
if (typeof value === "string" && value.length > 0) return value;
|
|
466
|
+
}
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function eventTimestamp(record: Record<string, unknown>): string | null {
|
|
471
|
+
return firstString(record, ["updated_at", "completed_at", "answered_at", "created_at", "registered_at"]);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function canonicalCoordinatorEvent(
|
|
475
|
+
event_type: "session_state" | "turn_state" | "question_state" | "coordination_report",
|
|
476
|
+
record: Record<string, unknown>,
|
|
477
|
+
): Record<string, unknown> {
|
|
478
|
+
return {
|
|
479
|
+
schema_version: 1,
|
|
480
|
+
event_type,
|
|
481
|
+
session_id: firstString(record, ["session_id", "sessionId"]),
|
|
482
|
+
turn_id: firstString(record, ["turn_id", "turnId", "current_turn_id", "last_turn_id"]),
|
|
483
|
+
question_id: event_type === "question_state" ? firstString(record, ["id", "question_id"]) : null,
|
|
484
|
+
status: firstString(record, ["status", "state"]),
|
|
485
|
+
source: firstString(record, ["source"]),
|
|
486
|
+
reason: firstString(record, ["reason"]),
|
|
487
|
+
updated_at: eventTimestamp(record),
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
function sortNewestFirst(records: Array<Record<string, unknown>>): Array<Record<string, unknown>> {
|
|
492
|
+
return [...records].sort((left, right) => {
|
|
493
|
+
const leftTime = eventTimestamp(left) ?? "";
|
|
494
|
+
const rightTime = eventTimestamp(right) ?? "";
|
|
495
|
+
return rightTime.localeCompare(leftTime);
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function buildCanonicalCoordinatorEvents(input: {
|
|
500
|
+
sessionStates: Array<Record<string, unknown>>;
|
|
501
|
+
turns: Array<Record<string, unknown>>;
|
|
502
|
+
questions: Array<Record<string, unknown>>;
|
|
503
|
+
reports: Array<Record<string, unknown>>;
|
|
504
|
+
}): Array<Record<string, unknown>> {
|
|
505
|
+
return sortNewestFirst([
|
|
506
|
+
...input.sessionStates.map(record => canonicalCoordinatorEvent("session_state", record)),
|
|
507
|
+
...input.turns.map(record => canonicalCoordinatorEvent("turn_state", record)),
|
|
508
|
+
...input.questions.map(record => canonicalCoordinatorEvent("question_state", record)),
|
|
509
|
+
...input.reports.map(record => canonicalCoordinatorEvent("coordination_report", record)),
|
|
510
|
+
]).slice(0, COORDINATOR_STATUS_EVENT_LIMIT);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function activeSessionStates(sessionStates: Array<Record<string, unknown>>): Array<Record<string, unknown>> {
|
|
514
|
+
return sessionStates.filter(record => {
|
|
515
|
+
const state = record.state;
|
|
516
|
+
return state === "booting" || state === "running" || state === "needs_user_input" || state === "stale";
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function eventsDir(namespaceDir: string): string {
|
|
521
|
+
return path.join(namespaceDir, "events");
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
function eventJournalFile(namespaceDir: string): string {
|
|
525
|
+
return path.join(eventsDir(namespaceDir), "event-journal.jsonl");
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function eventSequenceFile(namespaceDir: string): string {
|
|
529
|
+
return path.join(eventsDir(namespaceDir), "latest-seq.json");
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function boundSummary(value: string): string {
|
|
533
|
+
const normalized = value
|
|
534
|
+
.replace(/[\r\n\t]+/g, " ")
|
|
535
|
+
.replace(/\s+/g, " ")
|
|
536
|
+
.trim();
|
|
537
|
+
return normalized.length > 240 ? `${normalized.slice(0, 237)}...` : normalized;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
async function readLatestEventSeq(namespaceDir: string): Promise<number> {
|
|
541
|
+
const sequence = asRecord(await readJsonFile(eventSequenceFile(namespaceDir)));
|
|
542
|
+
const seq = sequence?.seq;
|
|
543
|
+
if (typeof seq === "number" && Number.isInteger(seq) && seq >= 0) return seq;
|
|
544
|
+
let latestSeq = 0;
|
|
545
|
+
for (const event of await readCoordinatorEvents(namespaceDir)) latestSeq = Math.max(latestSeq, event.seq);
|
|
546
|
+
return latestSeq;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
const eventAppendQueues = new Map<string, Promise<unknown>>();
|
|
550
|
+
|
|
551
|
+
async function appendCoordinatorEvent(namespaceDir: string, input: CoordinatorEventInput): Promise<CoordinatorEvent> {
|
|
552
|
+
const previous = eventAppendQueues.get(namespaceDir) ?? Promise.resolve();
|
|
553
|
+
let release!: () => void;
|
|
554
|
+
const current = new Promise<void>(resolve => {
|
|
555
|
+
release = resolve;
|
|
556
|
+
});
|
|
557
|
+
const queued = previous.then(
|
|
558
|
+
() => current,
|
|
559
|
+
() => current,
|
|
560
|
+
);
|
|
561
|
+
eventAppendQueues.set(namespaceDir, queued);
|
|
562
|
+
|
|
563
|
+
await previous.catch(() => undefined);
|
|
564
|
+
try {
|
|
565
|
+
const latestSeq = await readLatestEventSeq(namespaceDir);
|
|
566
|
+
const seq = latestSeq + 1;
|
|
567
|
+
const timestamp = new Date().toISOString();
|
|
568
|
+
const event: CoordinatorEvent = {
|
|
569
|
+
schema_version: 1,
|
|
570
|
+
seq,
|
|
571
|
+
id: `event-${seq.toString().padStart(12, "0")}`,
|
|
572
|
+
timestamp,
|
|
573
|
+
kind: input.kind,
|
|
574
|
+
summary: boundSummary(input.summary),
|
|
575
|
+
...(input.sessionId ? { session_id: input.sessionId } : {}),
|
|
576
|
+
...(input.turnId ? { turn_id: input.turnId } : {}),
|
|
577
|
+
...(input.questionId ? { question_id: input.questionId } : {}),
|
|
578
|
+
...(input.reportId ? { report_id: input.reportId } : {}),
|
|
579
|
+
...(input.payloadRef ? { payload_ref: input.payloadRef } : {}),
|
|
580
|
+
...(input.metadata ? { metadata: input.metadata } : {}),
|
|
581
|
+
};
|
|
582
|
+
await ensureDir(eventsDir(namespaceDir));
|
|
583
|
+
await fs.appendFile(eventJournalFile(namespaceDir), `${JSON.stringify(event)}\n`);
|
|
584
|
+
await writeJsonFile(eventSequenceFile(namespaceDir), { seq, updated_at: timestamp });
|
|
585
|
+
return event;
|
|
586
|
+
} finally {
|
|
587
|
+
release();
|
|
588
|
+
if (eventAppendQueues.get(namespaceDir) === queued) eventAppendQueues.delete(namespaceDir);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
function parseCoordinatorEvent(line: string): CoordinatorEvent | null {
|
|
593
|
+
try {
|
|
594
|
+
const event = JSON.parse(line) as CoordinatorEvent;
|
|
595
|
+
if (typeof event.seq !== "number" || typeof event.kind !== "string") return null;
|
|
596
|
+
return event;
|
|
597
|
+
} catch {
|
|
598
|
+
return null;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
async function readCoordinatorEvents(namespaceDir: string): Promise<CoordinatorEvent[]> {
|
|
603
|
+
try {
|
|
604
|
+
const content = await fs.readFile(eventJournalFile(namespaceDir), "utf8");
|
|
605
|
+
return content
|
|
606
|
+
.split("\n")
|
|
607
|
+
.map(line => line.trim())
|
|
608
|
+
.filter(Boolean)
|
|
609
|
+
.map(parseCoordinatorEvent)
|
|
610
|
+
.filter((event): event is CoordinatorEvent => event !== null)
|
|
611
|
+
.sort((left, right) => left.seq - right.seq);
|
|
612
|
+
} catch (error) {
|
|
613
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return [];
|
|
614
|
+
throw error;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function boundedEventLimit(value: unknown): number {
|
|
619
|
+
const parsed = typeof value === "number" ? value : Number.parseInt(String(value ?? ""), 10);
|
|
620
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return 100;
|
|
621
|
+
return Math.min(parsed, 100);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
function eventTypeFilter(value: unknown): Set<string> | null {
|
|
625
|
+
if (!Array.isArray(value)) return null;
|
|
626
|
+
const types = value.filter((item): item is string => typeof item === "string" && item.length > 0);
|
|
627
|
+
return types.length > 0 ? new Set(types) : null;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
function filterCoordinatorEvents(
|
|
631
|
+
events: CoordinatorEvent[],
|
|
632
|
+
args: Record<string, unknown>,
|
|
633
|
+
limit: number,
|
|
634
|
+
): CoordinatorEvent[] {
|
|
635
|
+
const afterSeq =
|
|
636
|
+
typeof args.after_seq === "number" ? args.after_seq : Number.parseInt(String(args.after_seq ?? "0"), 10);
|
|
637
|
+
const safeAfterSeq = Number.isFinite(afterSeq) && afterSeq > 0 ? afterSeq : 0;
|
|
638
|
+
const sessionId = args.session_id == null ? null : safeExternalId("session", args.session_id);
|
|
639
|
+
const eventTypes = eventTypeFilter(args.event_types);
|
|
640
|
+
return events
|
|
641
|
+
.filter(event => event.seq > safeAfterSeq)
|
|
642
|
+
.filter(event => !sessionId || event.session_id === sessionId)
|
|
643
|
+
.filter(event => !eventTypes || eventTypes.has(event.kind))
|
|
644
|
+
.slice(0, limit);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
function eventSummaries(
|
|
648
|
+
events: CoordinatorEvent[],
|
|
649
|
+
): Array<
|
|
650
|
+
Pick<
|
|
651
|
+
CoordinatorEvent,
|
|
652
|
+
"seq" | "id" | "timestamp" | "kind" | "session_id" | "turn_id" | "question_id" | "report_id" | "summary"
|
|
653
|
+
>
|
|
654
|
+
> {
|
|
655
|
+
return events.map(event => ({
|
|
656
|
+
seq: event.seq,
|
|
657
|
+
id: event.id,
|
|
658
|
+
timestamp: event.timestamp,
|
|
659
|
+
kind: event.kind,
|
|
660
|
+
...(event.session_id ? { session_id: event.session_id } : {}),
|
|
661
|
+
...(event.turn_id ? { turn_id: event.turn_id } : {}),
|
|
662
|
+
...(event.question_id ? { question_id: event.question_id } : {}),
|
|
663
|
+
...(event.report_id ? { report_id: event.report_id } : {}),
|
|
664
|
+
summary: event.summary,
|
|
665
|
+
}));
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
function safeExternalId(kind: "session" | "question", value: unknown): string {
|
|
669
|
+
if (typeof value !== "string" || !SAFE_EXTERNAL_ID_PATTERN.test(value)) throw new Error(`invalid_${kind}_id`);
|
|
670
|
+
return value;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
function safeTurnId(value: unknown): string {
|
|
674
|
+
if (typeof value !== "string" || !TURN_ID_PATTERN.test(value)) throw new Error("invalid_turn_id");
|
|
675
|
+
return value;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
function safeTmuxSessionName(value: unknown): string {
|
|
679
|
+
if (typeof value !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,127}$/.test(value)) {
|
|
680
|
+
throw new Error("invalid_tmux_session");
|
|
681
|
+
}
|
|
682
|
+
return value;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
function safeTmuxTarget(value: unknown): string {
|
|
686
|
+
if (typeof value !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,160}$/.test(value)) {
|
|
687
|
+
throw new Error("invalid_tmux_target");
|
|
688
|
+
}
|
|
689
|
+
return value;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function optionalString(value: unknown): string | null {
|
|
693
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
function optionalBoolean(value: unknown): boolean | null {
|
|
697
|
+
return typeof value === "boolean" ? value : null;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function turnsDir(namespaceDir: string): string {
|
|
701
|
+
return path.join(namespaceDir, "turns");
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
function activeTurnFile(namespaceDir: string, sessionId: string): string {
|
|
705
|
+
return path.join(namespaceDir, "active-turns", `${safeExternalId("session", sessionId)}.json`);
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
function turnFile(namespaceDir: string, turnId: string): string {
|
|
709
|
+
return path.join(turnsDir(namespaceDir), `${safeTurnId(turnId)}.json`);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
function questionFile(namespaceDir: string, questionId: string): string {
|
|
713
|
+
return path.join(namespaceDir, "questions", `${safeExternalId("question", questionId)}.json`);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
function sessionStateFile(namespaceDir: string, sessionId: string): string {
|
|
717
|
+
return path.join(namespaceDir, "session-states", `${safeExternalId("session", sessionId)}.json`);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
async function readTurnRecord(namespaceDir: string, turnId: unknown): Promise<TurnRecord | null> {
|
|
721
|
+
return (await readJsonFile(turnFile(namespaceDir, safeTurnId(turnId)))) as TurnRecord | null;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
function turnEventKind(status: TurnStatus): CoordinatorEventKind | null {
|
|
725
|
+
if (status === "queued") return "turn.queued";
|
|
726
|
+
if (status === "delivering") return "turn.delivering";
|
|
727
|
+
if (status === "active") return "turn.active";
|
|
728
|
+
if (status === "waiting_for_answer") return "turn.waiting_for_answer";
|
|
729
|
+
if (status === "completed") return "turn.completed";
|
|
730
|
+
if (status === "failed") return "turn.failed";
|
|
731
|
+
if (status === "cancelled") return "turn.cancelled";
|
|
732
|
+
if (status === "superseded") return "turn.superseded";
|
|
733
|
+
return null;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
async function writeTurnRecord(namespaceDir: string, turn: TurnRecord): Promise<void> {
|
|
737
|
+
const previous = (await readJsonFile(turnFile(namespaceDir, turn.turn_id))) as TurnRecord | null;
|
|
738
|
+
await writeJsonFile(turnFile(namespaceDir, turn.turn_id), turn);
|
|
739
|
+
const kind = previous?.status === turn.status ? null : turnEventKind(turn.status);
|
|
740
|
+
if (kind) {
|
|
741
|
+
await appendCoordinatorEvent(namespaceDir, {
|
|
742
|
+
kind,
|
|
743
|
+
sessionId: turn.session_id,
|
|
744
|
+
turnId: turn.turn_id,
|
|
745
|
+
summary: `Turn ${turn.turn_id} is ${turn.status}`,
|
|
746
|
+
payloadRef: path.relative(namespaceDir, turnFile(namespaceDir, turn.turn_id)),
|
|
747
|
+
metadata: {
|
|
748
|
+
status: turn.status,
|
|
749
|
+
queued: turn.delivery.queued,
|
|
750
|
+
tmux_keys_sent: turn.delivery.tmux_keys_sent ?? null,
|
|
751
|
+
},
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
async function readActiveTurn(namespaceDir: string, sessionId: string): Promise<TurnRecord | null> {
|
|
757
|
+
const active = asRecord(await readJsonFile(activeTurnFile(namespaceDir, sessionId)));
|
|
758
|
+
if (!active || typeof active.turn_id !== "string") return null;
|
|
759
|
+
const turn = await readTurnRecord(namespaceDir, active.turn_id);
|
|
760
|
+
if (!turn || turn.session_id !== sessionId || !ACTIVE_TURN_STATUSES.has(turn.status)) return null;
|
|
761
|
+
return turn;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
async function writeActiveTurn(namespaceDir: string, turn: TurnRecord): Promise<void> {
|
|
765
|
+
await writeJsonFile(activeTurnFile(namespaceDir, turn.session_id), {
|
|
766
|
+
session_id: turn.session_id,
|
|
767
|
+
turn_id: turn.turn_id,
|
|
768
|
+
status: turn.status,
|
|
769
|
+
updated_at: turn.updated_at,
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
async function clearActiveTurn(namespaceDir: string, turn: TurnRecord): Promise<void> {
|
|
774
|
+
const active = asRecord(await readJsonFile(activeTurnFile(namespaceDir, turn.session_id)));
|
|
775
|
+
if (active?.turn_id === turn.turn_id) await fs.rm(activeTurnFile(namespaceDir, turn.session_id), { force: true });
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
async function readSessionState(namespaceDir: string, sessionId: string): Promise<CoordinatorSessionState | null> {
|
|
779
|
+
return (await readJsonFile(sessionStateFile(namespaceDir, sessionId))) as CoordinatorSessionState | null;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
async function writeSessionState(
|
|
783
|
+
namespaceDir: string,
|
|
784
|
+
sessionId: string,
|
|
785
|
+
state: CoordinatorSessionStateValue,
|
|
786
|
+
options: {
|
|
787
|
+
currentTurnId?: string | null;
|
|
788
|
+
lastTurnId?: string | null;
|
|
789
|
+
live?: boolean | null;
|
|
790
|
+
reason?: string | null;
|
|
791
|
+
source?: CoordinatorSessionState["source"];
|
|
792
|
+
} = {},
|
|
793
|
+
): Promise<CoordinatorSessionState> {
|
|
794
|
+
const previous = await readSessionState(namespaceDir, sessionId);
|
|
795
|
+
const payload: CoordinatorSessionState = {
|
|
796
|
+
schema_version: 1,
|
|
797
|
+
session_id: sessionId,
|
|
798
|
+
state,
|
|
799
|
+
ready_for_input: state === "ready_for_input" || state === "completed",
|
|
800
|
+
current_turn_id: options.currentTurnId ?? (state === "running" ? (previous?.current_turn_id ?? null) : null),
|
|
801
|
+
last_turn_id: options.lastTurnId ?? previous?.last_turn_id ?? null,
|
|
802
|
+
updated_at: new Date().toISOString(),
|
|
803
|
+
source: options.source ?? "coordinator",
|
|
804
|
+
live: options.live ?? previous?.live ?? null,
|
|
805
|
+
reason: options.reason ?? null,
|
|
806
|
+
};
|
|
807
|
+
await writeJsonFile(sessionStateFile(namespaceDir, sessionId), payload);
|
|
808
|
+
if (
|
|
809
|
+
!previous ||
|
|
810
|
+
previous.state !== payload.state ||
|
|
811
|
+
previous.current_turn_id !== payload.current_turn_id ||
|
|
812
|
+
previous.last_turn_id !== payload.last_turn_id ||
|
|
813
|
+
previous.live !== payload.live ||
|
|
814
|
+
previous.reason !== payload.reason
|
|
815
|
+
) {
|
|
816
|
+
await appendCoordinatorEvent(namespaceDir, {
|
|
817
|
+
kind: "session.state_changed",
|
|
818
|
+
sessionId,
|
|
819
|
+
turnId: payload.current_turn_id ?? payload.last_turn_id,
|
|
820
|
+
summary: `Session ${sessionId} state changed to ${payload.state}`,
|
|
821
|
+
payloadRef: path.relative(namespaceDir, sessionStateFile(namespaceDir, sessionId)),
|
|
822
|
+
metadata: {
|
|
823
|
+
state: payload.state,
|
|
824
|
+
ready_for_input: payload.ready_for_input,
|
|
825
|
+
live: payload.live,
|
|
826
|
+
reason: payload.reason,
|
|
827
|
+
},
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
return payload;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
function hasTmuxIdentity(session: Record<string, unknown>): boolean {
|
|
834
|
+
return (
|
|
835
|
+
(typeof session.tmux_session === "string" && session.tmux_session.length > 0) ||
|
|
836
|
+
(typeof session.tmuxSession === "string" && session.tmuxSession.length > 0)
|
|
837
|
+
);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
async function markTurnFailedForUnavailableSession(
|
|
841
|
+
namespaceDir: string,
|
|
842
|
+
turn: TurnRecord,
|
|
843
|
+
reason: string,
|
|
844
|
+
): Promise<TurnRecord> {
|
|
845
|
+
const timestamp = new Date().toISOString();
|
|
846
|
+
const failed: TurnRecord = {
|
|
847
|
+
...turn,
|
|
848
|
+
status: "failed",
|
|
849
|
+
final_response: {
|
|
850
|
+
text: `Coordinator session unavailable: ${reason}`,
|
|
851
|
+
format: "markdown",
|
|
852
|
+
source: "coordinator_liveness",
|
|
853
|
+
artifact_path: null,
|
|
854
|
+
truncated: false,
|
|
855
|
+
},
|
|
856
|
+
error: { code: "session_unavailable", message: reason, recoverable: true },
|
|
857
|
+
liveness: { checked_at: timestamp, live: false, reason },
|
|
858
|
+
updated_at: timestamp,
|
|
859
|
+
completed_at: timestamp,
|
|
860
|
+
};
|
|
861
|
+
await writeTurnRecord(namespaceDir, failed);
|
|
862
|
+
await clearActiveTurn(namespaceDir, failed);
|
|
863
|
+
await writeSessionState(namespaceDir, failed.session_id, "stale", {
|
|
864
|
+
lastTurnId: failed.turn_id,
|
|
865
|
+
live: false,
|
|
866
|
+
reason,
|
|
867
|
+
});
|
|
868
|
+
return failed;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
async function markTurnTerminalFromSessionState(
|
|
872
|
+
namespaceDir: string,
|
|
873
|
+
turn: TurnRecord,
|
|
874
|
+
sessionState: CoordinatorSessionState,
|
|
875
|
+
): Promise<TurnRecord> {
|
|
876
|
+
const terminalStatus: TurnStatus = sessionState.state === "errored" ? "failed" : "completed";
|
|
877
|
+
const runtimeState = sessionState as RuntimeSessionStatePayload;
|
|
878
|
+
const finalResponse = runtimeState.final_response ?? {
|
|
879
|
+
text: null,
|
|
880
|
+
format: "markdown" as const,
|
|
881
|
+
source: "runtime_state",
|
|
882
|
+
artifact_path: null,
|
|
883
|
+
truncated: false,
|
|
884
|
+
};
|
|
885
|
+
const timestamp = new Date().toISOString();
|
|
886
|
+
const resolved: TurnRecord = {
|
|
887
|
+
...turn,
|
|
888
|
+
status: terminalStatus,
|
|
889
|
+
delivery: {
|
|
890
|
+
...turn.delivery,
|
|
891
|
+
prompt_acknowledged: true,
|
|
892
|
+
state: "acknowledged",
|
|
893
|
+
},
|
|
894
|
+
final_response: finalResponse,
|
|
895
|
+
evidence: reportableFinalResponse(finalResponse)
|
|
896
|
+
? turn.evidence
|
|
897
|
+
: [
|
|
898
|
+
...turn.evidence,
|
|
899
|
+
{
|
|
900
|
+
type: MISSING_FINAL_RESPONSE_ADVISORY,
|
|
901
|
+
message: "Runtime completed without reportable final_response text or artifact_path.",
|
|
902
|
+
created_at: timestamp,
|
|
903
|
+
},
|
|
904
|
+
],
|
|
905
|
+
error:
|
|
906
|
+
terminalStatus === "failed"
|
|
907
|
+
? (runtimeState.error ?? {
|
|
908
|
+
code: "runtime_errored",
|
|
909
|
+
message: sessionState.reason ?? "runtime_errored",
|
|
910
|
+
recoverable: true,
|
|
911
|
+
})
|
|
912
|
+
: null,
|
|
913
|
+
updated_at: timestamp,
|
|
914
|
+
completed_at: timestamp,
|
|
915
|
+
};
|
|
916
|
+
await writeTurnRecord(namespaceDir, resolved);
|
|
917
|
+
await clearActiveTurn(namespaceDir, resolved);
|
|
918
|
+
await writeSessionState(namespaceDir, resolved.session_id, sessionState.state, {
|
|
919
|
+
lastTurnId: resolved.turn_id,
|
|
920
|
+
live: sessionState.live,
|
|
921
|
+
reason: sessionState.reason,
|
|
922
|
+
});
|
|
923
|
+
return resolved;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
function shellQuote(value: string): string {
|
|
927
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
928
|
+
}
|
|
929
|
+
function makeTurnRecord(
|
|
930
|
+
config: CoordinatorMcpConfig,
|
|
931
|
+
sessionId: string,
|
|
932
|
+
prompt: string,
|
|
933
|
+
status: TurnStatus,
|
|
934
|
+
): TurnRecord {
|
|
935
|
+
const timestamp = new Date().toISOString();
|
|
936
|
+
return {
|
|
937
|
+
schema_version: 1,
|
|
938
|
+
turn_id: `turn-${randomUUID()}`,
|
|
939
|
+
session_id: sessionId,
|
|
940
|
+
namespace: config.namespace,
|
|
941
|
+
status,
|
|
942
|
+
prompt: { text: prompt, created_at: timestamp, source: "mcp" },
|
|
943
|
+
delivery: {
|
|
944
|
+
delivered: false,
|
|
945
|
+
queued: true,
|
|
946
|
+
target: null,
|
|
947
|
+
tmux_keys_sent: false,
|
|
948
|
+
prompt_acknowledged: false,
|
|
949
|
+
state: "queued",
|
|
950
|
+
attempts: [],
|
|
951
|
+
},
|
|
952
|
+
question_ids: [],
|
|
953
|
+
final_response: { text: null, format: "markdown", source: null, artifact_path: null, truncated: false },
|
|
954
|
+
evidence: [],
|
|
955
|
+
error: null,
|
|
956
|
+
liveness: { checked_at: null, live: null, reason: null },
|
|
957
|
+
created_at: timestamp,
|
|
958
|
+
updated_at: timestamp,
|
|
959
|
+
started_at: status === "queued" ? null : timestamp,
|
|
960
|
+
completed_at: null,
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
function asTerminalTurnStatus(status: unknown): TurnStatus | null {
|
|
965
|
+
const normalized = String(status ?? "")
|
|
966
|
+
.trim()
|
|
967
|
+
.toLowerCase();
|
|
968
|
+
if (TERMINAL_TURN_STATUSES.has(normalized as TurnStatus)) return normalized as TurnStatus;
|
|
969
|
+
if (normalized === "blocked") return "failed";
|
|
970
|
+
return null;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
function boundedTimeoutMs(value: unknown): number {
|
|
974
|
+
const parsed = typeof value === "number" ? value : Number.parseInt(String(value ?? ""), 10);
|
|
975
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return 1000;
|
|
976
|
+
return Math.min(parsed, 30_000);
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
function boundedPollIntervalMs(value: unknown): number {
|
|
980
|
+
const parsed = typeof value === "number" ? value : Number.parseInt(String(value ?? ""), 10);
|
|
981
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return 100;
|
|
982
|
+
return Math.min(Math.max(parsed, 10), 1000);
|
|
983
|
+
}
|
|
984
|
+
async function runCommand(command: string[]): Promise<{ exitCode: number; stdout: string; stderr: string }> {
|
|
985
|
+
const proc = Bun.spawn(command, { stdout: "pipe", stderr: "pipe" });
|
|
986
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
987
|
+
new Response(proc.stdout).text(),
|
|
988
|
+
new Response(proc.stderr).text(),
|
|
989
|
+
proc.exited,
|
|
990
|
+
]);
|
|
991
|
+
return { exitCode, stdout, stderr };
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
type CommandRunner = (command: string[]) => Promise<{ exitCode: number; stdout: string; stderr: string }>;
|
|
995
|
+
|
|
996
|
+
async function sendTmuxPromptKeys(
|
|
997
|
+
target: string,
|
|
998
|
+
prompt: string,
|
|
999
|
+
runner: CommandRunner = runCommand,
|
|
1000
|
+
): Promise<boolean> {
|
|
1001
|
+
const sent = await runner(["tmux", "send-keys", "-t", target, prompt, "C-m", "C-m"]);
|
|
1002
|
+
return sent.exitCode === 0;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
function boundedLineCount(value: unknown): number {
|
|
1006
|
+
const parsed = typeof value === "number" ? value : Number.parseInt(String(value ?? ""), 10);
|
|
1007
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return 80;
|
|
1008
|
+
return Math.min(parsed, 400);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
async function assertTmuxTargetAvailable(
|
|
1012
|
+
tmuxSession: string,
|
|
1013
|
+
tmuxTarget: string,
|
|
1014
|
+
runner: CommandRunner = runCommand,
|
|
1015
|
+
): Promise<void> {
|
|
1016
|
+
const session = await runner(["tmux", "has-session", "-t", tmuxSession]);
|
|
1017
|
+
if (session.exitCode !== 0) throw new Error("tmux_session_unavailable");
|
|
1018
|
+
const pane = await runner(["tmux", "display-message", "-p", "-t", tmuxTarget, "#{pane_id}"]);
|
|
1019
|
+
if (pane.exitCode !== 0 || pane.stdout.trim().length === 0) throw new Error("tmux_target_unavailable");
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
async function registerExistingTmuxSession(
|
|
1023
|
+
input: SessionRegisterInput,
|
|
1024
|
+
namespaceDir: string,
|
|
1025
|
+
sessionFilePath: string,
|
|
1026
|
+
runner: CommandRunner = runCommand,
|
|
1027
|
+
): Promise<{ session: Record<string, unknown>; sessionState: CoordinatorSessionState }> {
|
|
1028
|
+
await assertTmuxTargetAvailable(input.tmuxSession, input.tmuxTarget, runner);
|
|
1029
|
+
const existing = asRecord(await readJsonFile(sessionFilePath));
|
|
1030
|
+
if (existing) {
|
|
1031
|
+
const existingSession = typeof existing.tmux_session === "string" ? existing.tmux_session : existing.tmuxSession;
|
|
1032
|
+
const existingTarget = typeof existing.tmux_target === "string" ? existing.tmux_target : existing.tmuxTarget;
|
|
1033
|
+
if (existingSession && existingSession !== input.tmuxSession) throw new Error("session_id_conflict");
|
|
1034
|
+
if (existingTarget && existingTarget !== input.tmuxTarget) throw new Error("session_id_conflict");
|
|
1035
|
+
}
|
|
1036
|
+
const timestamp = new Date().toISOString();
|
|
1037
|
+
const session = {
|
|
1038
|
+
...(existing ?? {}),
|
|
1039
|
+
session_id: input.sessionId,
|
|
1040
|
+
sessionId: input.sessionId,
|
|
1041
|
+
tmux_session: input.tmuxSession,
|
|
1042
|
+
tmuxSession: input.tmuxSession,
|
|
1043
|
+
tmux_target: input.tmuxTarget,
|
|
1044
|
+
tmuxTarget: input.tmuxTarget,
|
|
1045
|
+
cwd: input.cwd,
|
|
1046
|
+
created_at: typeof existing?.created_at === "string" ? existing.created_at : timestamp,
|
|
1047
|
+
createdAt: typeof existing?.createdAt === "string" ? existing.createdAt : timestamp,
|
|
1048
|
+
registered_at: timestamp,
|
|
1049
|
+
visible: input.visible,
|
|
1050
|
+
authoritative: true,
|
|
1051
|
+
warp_attached: input.warpAttached,
|
|
1052
|
+
source: input.source,
|
|
1053
|
+
model: input.model,
|
|
1054
|
+
};
|
|
1055
|
+
await writeJsonFile(sessionFilePath, session);
|
|
1056
|
+
const state = await writeSessionState(namespaceDir, input.sessionId, "ready_for_input", {
|
|
1057
|
+
live: true,
|
|
1058
|
+
reason: null,
|
|
1059
|
+
});
|
|
1060
|
+
return { session, sessionState: state };
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
async function startTmuxSession(
|
|
1064
|
+
config: CoordinatorMcpConfig,
|
|
1065
|
+
input: SessionStartInput,
|
|
1066
|
+
namespaceDir: string,
|
|
1067
|
+
runner: CommandRunner = runCommand,
|
|
1068
|
+
): Promise<Record<string, unknown>> {
|
|
1069
|
+
if (!config.sessionCommand) throw new Error("coordinator_session_command_required");
|
|
1070
|
+
const sessionName = `skc-coordinator-${randomUUID().slice(0, 8)}`;
|
|
1071
|
+
const runtimeStateFile = sessionStateFile(namespaceDir, sessionName);
|
|
1072
|
+
const sessionCommand = [
|
|
1073
|
+
"exec env",
|
|
1074
|
+
`${SKC_COORDINATOR_SESSION_STATE_FILE_ENV}=${shellQuote(runtimeStateFile)}`,
|
|
1075
|
+
`${SKC_COORDINATOR_SESSION_ID_ENV}=${shellQuote(sessionName)}`,
|
|
1076
|
+
config.sessionCommand,
|
|
1077
|
+
].join(" ");
|
|
1078
|
+
const started = await runner([
|
|
1079
|
+
"tmux",
|
|
1080
|
+
"new-session",
|
|
1081
|
+
"-d",
|
|
1082
|
+
"-P",
|
|
1083
|
+
"-F",
|
|
1084
|
+
"#{session_name}:#{window_index}.#{pane_index} #{pane_id}",
|
|
1085
|
+
"-s",
|
|
1086
|
+
sessionName,
|
|
1087
|
+
"-c",
|
|
1088
|
+
input.cwd,
|
|
1089
|
+
sessionCommand,
|
|
1090
|
+
]);
|
|
1091
|
+
if (started.exitCode !== 0) throw new Error(`coordinator_tmux_start_failed:${started.stderr || started.stdout}`);
|
|
1092
|
+
const [tmuxTarget, paneId] = started.stdout.trim().split(/\s+/, 2);
|
|
1093
|
+
return {
|
|
1094
|
+
sessionId: sessionName,
|
|
1095
|
+
tmuxSession: sessionName,
|
|
1096
|
+
tmuxTarget: tmuxTarget || sessionName,
|
|
1097
|
+
paneId,
|
|
1098
|
+
cwd: input.cwd,
|
|
1099
|
+
createdAt: new Date().toISOString(),
|
|
1100
|
+
sessionCommand: config.sessionCommand,
|
|
1101
|
+
runtimeStateFile,
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
async function captureTmuxTail(session: Record<string, unknown>, lines: number): Promise<string[]> {
|
|
1106
|
+
const target = typeof session.tmux_target === "string" ? session.tmux_target : session.tmuxTarget;
|
|
1107
|
+
if (typeof target !== "string" || target.length === 0) return [];
|
|
1108
|
+
const captured = await runCommand(["tmux", "capture-pane", "-t", target, "-p", "-S", `-${lines}`]);
|
|
1109
|
+
if (captured.exitCode !== 0) return [];
|
|
1110
|
+
return captured.stdout.split("\n").slice(-lines);
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
async function sendTmuxPrompt(
|
|
1114
|
+
session: Record<string, unknown>,
|
|
1115
|
+
prompt: string,
|
|
1116
|
+
runner: CommandRunner = runCommand,
|
|
1117
|
+
): Promise<boolean> {
|
|
1118
|
+
const target = typeof session.tmux_target === "string" ? session.tmux_target : session.tmuxTarget;
|
|
1119
|
+
if (typeof target !== "string" || target.length === 0) return false;
|
|
1120
|
+
return await sendTmuxPromptKeys(target, prompt, runner);
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
async function hasTmuxSession(
|
|
1124
|
+
session: Record<string, unknown>,
|
|
1125
|
+
runner: CommandRunner = runCommand,
|
|
1126
|
+
): Promise<boolean | null> {
|
|
1127
|
+
const tmuxSession = typeof session.tmux_session === "string" ? session.tmux_session : session.tmuxSession;
|
|
1128
|
+
if (typeof tmuxSession !== "string" || tmuxSession.length === 0) return null;
|
|
1129
|
+
const checked = await runner(["tmux", "has-session", "-t", tmuxSession]);
|
|
1130
|
+
return checked.exitCode === 0;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
function lastMatchingLine(lines: string[], pattern: RegExp): string | null {
|
|
1134
|
+
for (let index = lines.length - 1; index >= 0; index--) {
|
|
1135
|
+
const line = lines[index]?.trim();
|
|
1136
|
+
if (line && pattern.test(line)) return line;
|
|
1137
|
+
}
|
|
1138
|
+
return null;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
function summarizePaneTail(lines: string[]): Record<string, unknown> {
|
|
1142
|
+
const nonEmpty = lines.map(line => line.trim()).filter(Boolean);
|
|
1143
|
+
const spinnerLine = lastMatchingLine(nonEmpty, /^[⠁-⣿]\s+/u);
|
|
1144
|
+
const hudLine = lastMatchingLine(nonEmpty, /\/ 📁 | PR \d+|Status Review|Tracking/i);
|
|
1145
|
+
const errorLine = lastMatchingLine(nonEmpty, /\b(error|failed|exception|404|not_found)\b/i);
|
|
1146
|
+
const assistantLine = lastMatchingLine(nonEmpty, /^(sayknow|assistant)\b/i);
|
|
1147
|
+
const lastContent = nonEmpty.at(-1) ?? null;
|
|
1148
|
+
return {
|
|
1149
|
+
state: spinnerLine ? "working" : errorLine ? "error_or_warning" : "idle_or_unknown",
|
|
1150
|
+
activity: spinnerLine ?? hudLine ?? lastContent,
|
|
1151
|
+
hud: hudLine,
|
|
1152
|
+
last_error: errorLine,
|
|
1153
|
+
last_speaker: assistantLine,
|
|
1154
|
+
last_content: lastContent,
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
async function inspectTmuxSession(
|
|
1159
|
+
session: Record<string, unknown>,
|
|
1160
|
+
lines = 80,
|
|
1161
|
+
runner: CommandRunner = runCommand,
|
|
1162
|
+
): Promise<Record<string, unknown>> {
|
|
1163
|
+
const live = await hasTmuxSession(session, runner);
|
|
1164
|
+
const tail = live ? await captureTmuxTail(session, lines) : [];
|
|
1165
|
+
return {
|
|
1166
|
+
live,
|
|
1167
|
+
...summarizePaneTail(tail),
|
|
1168
|
+
tail_preview: tail.slice(-20),
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
function waitForTurnStateChange(namespaceDir: string, turn: TurnRecord, timeoutMs: number): Promise<void> {
|
|
1173
|
+
const deferred = Promise.withResolvers<void>();
|
|
1174
|
+
const watchers: nodeFs.FSWatcher[] = [];
|
|
1175
|
+
const watchedFiles = new Map<string, Set<string>>([
|
|
1176
|
+
[turnsDir(namespaceDir), new Set([`${turn.turn_id}.json`])],
|
|
1177
|
+
[path.join(namespaceDir, "active-turns"), new Set([`${turn.session_id}.json`])],
|
|
1178
|
+
[path.join(namespaceDir, "session-states"), new Set([`${turn.session_id}.json`])],
|
|
1179
|
+
]);
|
|
1180
|
+
let settled = false;
|
|
1181
|
+
const finish = () => {
|
|
1182
|
+
if (settled) return;
|
|
1183
|
+
settled = true;
|
|
1184
|
+
for (const watcher of watchers) watcher.close();
|
|
1185
|
+
clearTimeout(timer);
|
|
1186
|
+
deferred.resolve();
|
|
1187
|
+
};
|
|
1188
|
+
const timer = setTimeout(finish, Math.max(timeoutMs, 0));
|
|
1189
|
+
timer.unref?.();
|
|
1190
|
+
|
|
1191
|
+
for (const [dir, filenames] of watchedFiles) {
|
|
1192
|
+
try {
|
|
1193
|
+
const watcher = nodeFs.watch(dir, (_eventType, filename) => {
|
|
1194
|
+
if (typeof filename === "string" && filenames.has(filename)) finish();
|
|
1195
|
+
});
|
|
1196
|
+
watchers.push(watcher);
|
|
1197
|
+
} catch {
|
|
1198
|
+
// Directory may not exist yet; the timeout remains a bounded fallback.
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
return deferred.promise;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
async function waitForCoordinatorEvents(namespaceDir: string, timeoutMs: number): Promise<void> {
|
|
1206
|
+
const deferred = Promise.withResolvers<void>();
|
|
1207
|
+
const watchers: nodeFs.FSWatcher[] = [];
|
|
1208
|
+
let settled = false;
|
|
1209
|
+
const finish = () => {
|
|
1210
|
+
if (settled) return;
|
|
1211
|
+
settled = true;
|
|
1212
|
+
for (const watcher of watchers) watcher.close();
|
|
1213
|
+
clearTimeout(timer);
|
|
1214
|
+
deferred.resolve();
|
|
1215
|
+
};
|
|
1216
|
+
const timer = setTimeout(finish, Math.max(timeoutMs, 0));
|
|
1217
|
+
timer.unref?.();
|
|
1218
|
+
await ensureDir(eventsDir(namespaceDir));
|
|
1219
|
+
try {
|
|
1220
|
+
const watcher = nodeFs.watch(eventsDir(namespaceDir), (_eventType, filename) => {
|
|
1221
|
+
if (filename === "event-journal.jsonl" || filename === "latest-seq.json") finish();
|
|
1222
|
+
});
|
|
1223
|
+
watchers.push(watcher);
|
|
1224
|
+
} catch {
|
|
1225
|
+
// Directory may not exist yet; the timeout remains a bounded fallback.
|
|
1226
|
+
}
|
|
1227
|
+
return deferred.promise;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
function decodeUtf8WithinByteCap(bytes: Buffer, byteCap: number): string {
|
|
1231
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
1232
|
+
for (let end = Math.min(bytes.length, byteCap); end >= 0; end--) {
|
|
1233
|
+
try {
|
|
1234
|
+
const text = decoder.decode(bytes.subarray(0, end));
|
|
1235
|
+
if (Buffer.byteLength(text) <= byteCap) return text;
|
|
1236
|
+
} catch {
|
|
1237
|
+
// Keep trimming until the byte slice ends on a valid UTF-8 boundary.
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
return "";
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
export async function readCoordinatorArtifact(
|
|
1244
|
+
config: CoordinatorMcpConfig,
|
|
1245
|
+
args: { path: unknown },
|
|
1246
|
+
): Promise<Record<string, unknown>> {
|
|
1247
|
+
let handle: fs.FileHandle | null = null;
|
|
1248
|
+
try {
|
|
1249
|
+
const resolved = await assertCoordinatorArtifactPath(config, args.path);
|
|
1250
|
+
handle = await fs.open(resolved.path, "r");
|
|
1251
|
+
const readLimit = resolved.byteCap + 1;
|
|
1252
|
+
const buffer = Buffer.alloc(readLimit);
|
|
1253
|
+
const { bytesRead } = await handle.read(buffer, 0, readLimit, 0);
|
|
1254
|
+
const boundedBytes = buffer.subarray(0, Math.min(bytesRead, resolved.byteCap));
|
|
1255
|
+
const text = decodeUtf8WithinByteCap(boundedBytes, resolved.byteCap);
|
|
1256
|
+
return {
|
|
1257
|
+
ok: true,
|
|
1258
|
+
path: resolved.path,
|
|
1259
|
+
text,
|
|
1260
|
+
bytes: Buffer.byteLength(text),
|
|
1261
|
+
truncated: bytesRead > resolved.byteCap,
|
|
1262
|
+
};
|
|
1263
|
+
} catch (error) {
|
|
1264
|
+
return {
|
|
1265
|
+
ok: false,
|
|
1266
|
+
reason: (error instanceof Error ? error.message.split(":")[0] : String(error)).replace(/^coordinator_/, ""),
|
|
1267
|
+
};
|
|
1268
|
+
} finally {
|
|
1269
|
+
await handle?.close();
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
export function createCoordinatorMcpServer(options: CoordinatorMcpServerOptions = {}) {
|
|
1274
|
+
const config = buildCoordinatorMcpConfig(options.env ?? process.env);
|
|
1275
|
+
const services = options.services ?? {};
|
|
1276
|
+
const namespaceDir = coordinatorNamespacePath(config);
|
|
1277
|
+
const commandRunner = services.commandRunner ?? runCommand;
|
|
1278
|
+
|
|
1279
|
+
async function listSessions(): Promise<unknown[]> {
|
|
1280
|
+
if (!config.namespace.profile || !config.namespace.repo) return [];
|
|
1281
|
+
if (services.listSessions) return await services.listSessions();
|
|
1282
|
+
return await listJsonFiles(path.join(namespaceDir, "sessions"));
|
|
1283
|
+
}
|
|
1284
|
+
function sessionFile(sessionId: unknown): string {
|
|
1285
|
+
return path.join(namespaceDir, "sessions", `${safeExternalId("session", sessionId)}.json`);
|
|
1286
|
+
}
|
|
1287
|
+
async function listQuestions(args: Record<string, unknown>): Promise<unknown[]> {
|
|
1288
|
+
const sessionId = args.session_id == null ? null : safeExternalId("session", args.session_id);
|
|
1289
|
+
const status = typeof args.status === "string" && args.status.length > 0 ? args.status : null;
|
|
1290
|
+
return (await listJsonFiles(path.join(namespaceDir, "questions"))).filter(question => {
|
|
1291
|
+
const record = asRecord(question);
|
|
1292
|
+
if (!record) return false;
|
|
1293
|
+
if (sessionId && record.session_id !== sessionId) return false;
|
|
1294
|
+
if (status && record.status !== status) return false;
|
|
1295
|
+
return true;
|
|
1296
|
+
});
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
async function validateEvidencePaths(value: unknown): Promise<Array<{ path: string }>> {
|
|
1300
|
+
if (value == null) return [];
|
|
1301
|
+
if (!Array.isArray(value)) throw new Error("coordinator_evidence_paths_must_be_array");
|
|
1302
|
+
const evidence: Array<{ path: string }> = [];
|
|
1303
|
+
for (const item of value) {
|
|
1304
|
+
const resolved = await assertCoordinatorArtifactPath(config, item);
|
|
1305
|
+
evidence.push({ path: resolved.path });
|
|
1306
|
+
}
|
|
1307
|
+
return evidence;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
async function activateTurn(session: Record<string, unknown>, turn: TurnRecord): Promise<TurnRecord> {
|
|
1311
|
+
const timestamp = new Date().toISOString();
|
|
1312
|
+
const target = typeof session.tmux_target === "string" ? session.tmux_target : session.tmuxTarget;
|
|
1313
|
+
const live = hasTmuxIdentity(session) ? await hasTmuxSession(session, commandRunner) : null;
|
|
1314
|
+
const pendingTurn: TurnRecord = {
|
|
1315
|
+
...turn,
|
|
1316
|
+
status: "active",
|
|
1317
|
+
delivery: {
|
|
1318
|
+
delivered: false,
|
|
1319
|
+
queued: true,
|
|
1320
|
+
target: typeof target === "string" ? target : null,
|
|
1321
|
+
tmux_keys_sent: false,
|
|
1322
|
+
prompt_acknowledged: false,
|
|
1323
|
+
state: "queued",
|
|
1324
|
+
attempts: [
|
|
1325
|
+
{
|
|
1326
|
+
delivered: false,
|
|
1327
|
+
tmux_keys_sent: false,
|
|
1328
|
+
channel: "tmux_keys",
|
|
1329
|
+
created_at: timestamp,
|
|
1330
|
+
reason: "awaiting_tmux_delivery",
|
|
1331
|
+
},
|
|
1332
|
+
],
|
|
1333
|
+
},
|
|
1334
|
+
liveness: { checked_at: timestamp, live, reason: live === false ? "tmux_session_missing" : null },
|
|
1335
|
+
started_at: turn.started_at ?? timestamp,
|
|
1336
|
+
updated_at: timestamp,
|
|
1337
|
+
};
|
|
1338
|
+
await writeTurnRecord(namespaceDir, pendingTurn);
|
|
1339
|
+
await writeActiveTurn(namespaceDir, pendingTurn);
|
|
1340
|
+
await writeSessionState(namespaceDir, pendingTurn.session_id, "running", {
|
|
1341
|
+
currentTurnId: pendingTurn.turn_id,
|
|
1342
|
+
live,
|
|
1343
|
+
reason: null,
|
|
1344
|
+
});
|
|
1345
|
+
|
|
1346
|
+
const tmuxKeysSent = await sendTmuxPrompt(session, turn.prompt.text, commandRunner);
|
|
1347
|
+
const deliveredAt = new Date().toISOString();
|
|
1348
|
+
const activeTurn: TurnRecord = {
|
|
1349
|
+
...pendingTurn,
|
|
1350
|
+
delivery: {
|
|
1351
|
+
delivered: false,
|
|
1352
|
+
queued: !tmuxKeysSent,
|
|
1353
|
+
target: typeof target === "string" ? target : null,
|
|
1354
|
+
tmux_keys_sent: tmuxKeysSent,
|
|
1355
|
+
prompt_acknowledged: false,
|
|
1356
|
+
state: tmuxKeysSent ? "tmux_keys_sent" : "unavailable",
|
|
1357
|
+
attempts: [
|
|
1358
|
+
{
|
|
1359
|
+
delivered: false,
|
|
1360
|
+
tmux_keys_sent: tmuxKeysSent,
|
|
1361
|
+
channel: "tmux_keys",
|
|
1362
|
+
created_at: deliveredAt,
|
|
1363
|
+
reason: tmuxKeysSent ? "awaiting_runtime_ack" : "tmux_delivery_unavailable",
|
|
1364
|
+
},
|
|
1365
|
+
],
|
|
1366
|
+
},
|
|
1367
|
+
updated_at: deliveredAt,
|
|
1368
|
+
};
|
|
1369
|
+
await writeTurnRecord(namespaceDir, activeTurn);
|
|
1370
|
+
await writeActiveTurn(namespaceDir, activeTurn);
|
|
1371
|
+
const sessionState = await readSessionState(namespaceDir, activeTurn.session_id);
|
|
1372
|
+
const runtimeStateAlreadySettled =
|
|
1373
|
+
sessionState?.current_turn_id === activeTurn.turn_id &&
|
|
1374
|
+
(sessionState.state === "completed" || sessionState.state === "errored");
|
|
1375
|
+
if (!runtimeStateAlreadySettled) {
|
|
1376
|
+
await writeSessionState(namespaceDir, activeTurn.session_id, tmuxKeysSent ? "running" : "stale", {
|
|
1377
|
+
currentTurnId: activeTurn.turn_id,
|
|
1378
|
+
live,
|
|
1379
|
+
reason: tmuxKeysSent ? null : "tmux_delivery_unavailable",
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
await appendCoordinatorEvent(namespaceDir, {
|
|
1383
|
+
kind: tmuxKeysSent ? "tmux.delivery_succeeded" : "tmux.delivery_failed",
|
|
1384
|
+
sessionId: activeTurn.session_id,
|
|
1385
|
+
turnId: activeTurn.turn_id,
|
|
1386
|
+
summary: tmuxKeysSent
|
|
1387
|
+
? `Tmux delivery succeeded for turn ${activeTurn.turn_id}`
|
|
1388
|
+
: `Tmux delivery failed for turn ${activeTurn.turn_id}`,
|
|
1389
|
+
payloadRef: path.relative(namespaceDir, turnFile(namespaceDir, activeTurn.turn_id)),
|
|
1390
|
+
metadata: { target: typeof target === "string" ? target : null, live },
|
|
1391
|
+
});
|
|
1392
|
+
return activeTurn;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
async function promoteNextQueuedTurn(sessionId: string): Promise<TurnRecord | null> {
|
|
1396
|
+
const session = asRecord(await readJsonFile(sessionFile(sessionId)));
|
|
1397
|
+
if (!session) return null;
|
|
1398
|
+
const queuedTurns = (await listJsonFiles(turnsDir(namespaceDir)))
|
|
1399
|
+
.map(turn => asRecord(turn) as TurnRecord | null)
|
|
1400
|
+
.filter((turn): turn is TurnRecord => turn?.session_id === sessionId && turn.status === "queued")
|
|
1401
|
+
.sort((left, right) => left.created_at.localeCompare(right.created_at));
|
|
1402
|
+
const nextTurn = queuedTurns[0];
|
|
1403
|
+
return nextTurn ? await activateTurn(session, nextTurn) : null;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
async function readTurnPayload(
|
|
1407
|
+
turnId: unknown,
|
|
1408
|
+
sessionId: unknown,
|
|
1409
|
+
lines: unknown,
|
|
1410
|
+
): Promise<Record<string, unknown>> {
|
|
1411
|
+
const turn = await readTurnRecord(namespaceDir, turnId);
|
|
1412
|
+
if (!turn) return { ok: false, reason: "unknown_turn" };
|
|
1413
|
+
if (sessionId != null && turn.session_id !== safeExternalId("session", sessionId)) {
|
|
1414
|
+
return { ok: false, reason: "turn_session_mismatch" };
|
|
1415
|
+
}
|
|
1416
|
+
const session = asRecord(await readJsonFile(sessionFile(turn.session_id)));
|
|
1417
|
+
let resolvedTurn = turn;
|
|
1418
|
+
let advisoryStatus: Record<string, unknown> = { live: false };
|
|
1419
|
+
let sessionState = await readSessionState(namespaceDir, turn.session_id);
|
|
1420
|
+
if (
|
|
1421
|
+
sessionState &&
|
|
1422
|
+
ACTIVE_TURN_STATUSES.has(turn.status) &&
|
|
1423
|
+
sessionState.current_turn_id === turn.turn_id &&
|
|
1424
|
+
(sessionState.state === "completed" || sessionState.state === "errored")
|
|
1425
|
+
) {
|
|
1426
|
+
resolvedTurn = await markTurnTerminalFromSessionState(namespaceDir, turn, sessionState);
|
|
1427
|
+
sessionState = await readSessionState(namespaceDir, resolvedTurn.session_id);
|
|
1428
|
+
} else if (
|
|
1429
|
+
sessionState &&
|
|
1430
|
+
ACTIVE_TURN_STATUSES.has(turn.status) &&
|
|
1431
|
+
sessionState.current_turn_id === turn.turn_id &&
|
|
1432
|
+
sessionState.state === "stale" &&
|
|
1433
|
+
sessionState.reason === "tmux_delivery_unavailable" &&
|
|
1434
|
+
turn.delivery.state === "unavailable" &&
|
|
1435
|
+
session &&
|
|
1436
|
+
hasTmuxIdentity(session)
|
|
1437
|
+
) {
|
|
1438
|
+
resolvedTurn = await markTurnFailedForUnavailableSession(namespaceDir, turn, "tmux_delivery_unavailable");
|
|
1439
|
+
sessionState = await readSessionState(namespaceDir, resolvedTurn.session_id);
|
|
1440
|
+
} else if (!session && ACTIVE_TURN_STATUSES.has(turn.status)) {
|
|
1441
|
+
resolvedTurn = await markTurnFailedForUnavailableSession(namespaceDir, turn, "session_record_missing");
|
|
1442
|
+
sessionState = await readSessionState(namespaceDir, resolvedTurn.session_id);
|
|
1443
|
+
} else if (session) {
|
|
1444
|
+
advisoryStatus = await inspectTmuxSession(session, boundedLineCount(lines), commandRunner);
|
|
1445
|
+
if (ACTIVE_TURN_STATUSES.has(turn.status) && hasTmuxIdentity(session) && advisoryStatus.live === false) {
|
|
1446
|
+
resolvedTurn = await markTurnFailedForUnavailableSession(namespaceDir, turn, "tmux_session_missing");
|
|
1447
|
+
sessionState = await readSessionState(namespaceDir, resolvedTurn.session_id);
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
const missingFinalResponse =
|
|
1451
|
+
resolvedTurn.status === "completed" && !reportableFinalResponse(resolvedTurn.final_response);
|
|
1452
|
+
return {
|
|
1453
|
+
ok: true,
|
|
1454
|
+
turn: resolvedTurn,
|
|
1455
|
+
advisory_status: advisoryStatus,
|
|
1456
|
+
session_state: sessionState,
|
|
1457
|
+
...(missingFinalResponse
|
|
1458
|
+
? {
|
|
1459
|
+
completion_missing_final_response: true,
|
|
1460
|
+
advisory: MISSING_FINAL_RESPONSE_ADVISORY,
|
|
1461
|
+
}
|
|
1462
|
+
: {}),
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
async function callTool(name: string, args: Record<string, unknown> = {}): Promise<Record<string, unknown>> {
|
|
1467
|
+
try {
|
|
1468
|
+
if (name === "skc_coordinator_list_sessions") return { ok: true, sessions: await listSessions() };
|
|
1469
|
+
if (name === "skc_coordinator_register_session") {
|
|
1470
|
+
requireCoordinatorMutation(config, "sessions", args);
|
|
1471
|
+
const sessionId = safeExternalId("session", args.session_id);
|
|
1472
|
+
const cwd = await assertCoordinatorWorkdir(config, args.cwd);
|
|
1473
|
+
const tmuxSession = safeTmuxSessionName(args.tmux_session);
|
|
1474
|
+
const tmuxTarget = safeTmuxTarget(args.tmux_target);
|
|
1475
|
+
const registered = await registerExistingTmuxSession(
|
|
1476
|
+
{
|
|
1477
|
+
sessionId,
|
|
1478
|
+
cwd,
|
|
1479
|
+
tmuxSession,
|
|
1480
|
+
tmuxTarget,
|
|
1481
|
+
visible: args.visible !== false,
|
|
1482
|
+
warpAttached: optionalBoolean(args.warp_attached),
|
|
1483
|
+
source: optionalString(args.source) ?? "register_session",
|
|
1484
|
+
model: optionalString(args.model),
|
|
1485
|
+
},
|
|
1486
|
+
namespaceDir,
|
|
1487
|
+
sessionFile(sessionId),
|
|
1488
|
+
commandRunner,
|
|
1489
|
+
);
|
|
1490
|
+
await appendCoordinatorEvent(namespaceDir, {
|
|
1491
|
+
kind: "session.registered",
|
|
1492
|
+
sessionId,
|
|
1493
|
+
summary: `Session ${sessionId} registered for coordinator control`,
|
|
1494
|
+
payloadRef: path.relative(namespaceDir, sessionFile(sessionId)),
|
|
1495
|
+
metadata: { source: optionalString(args.source) ?? "register_session", visible: args.visible !== false },
|
|
1496
|
+
});
|
|
1497
|
+
|
|
1498
|
+
return {
|
|
1499
|
+
ok: true,
|
|
1500
|
+
session: registered.session,
|
|
1501
|
+
session_state: registered.sessionState,
|
|
1502
|
+
registered: true,
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1505
|
+
if (name === "skc_coordinator_read_status") {
|
|
1506
|
+
const sessionId = args.session_id;
|
|
1507
|
+
if (sessionId) {
|
|
1508
|
+
const session = asRecord(await readJsonFile(sessionFile(sessionId)));
|
|
1509
|
+
return {
|
|
1510
|
+
ok: true,
|
|
1511
|
+
session,
|
|
1512
|
+
status: session ? await inspectTmuxSession(session, 80, commandRunner) : { live: false },
|
|
1513
|
+
session_state: await readSessionState(namespaceDir, safeExternalId("session", sessionId)),
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
const sessions = await listSessions();
|
|
1517
|
+
const statuses = await Promise.all(
|
|
1518
|
+
sessions.map(async session =>
|
|
1519
|
+
typeof session === "object" && session !== null
|
|
1520
|
+
? {
|
|
1521
|
+
session,
|
|
1522
|
+
status: await inspectTmuxSession(session as Record<string, unknown>, 40, commandRunner),
|
|
1523
|
+
}
|
|
1524
|
+
: { session, status: { live: null } },
|
|
1525
|
+
),
|
|
1526
|
+
);
|
|
1527
|
+
return { ok: true, sessions, statuses };
|
|
1528
|
+
}
|
|
1529
|
+
if (name === "skc_coordinator_read_tail") {
|
|
1530
|
+
const session = asRecord(await readJsonFile(sessionFile(args.session_id)));
|
|
1531
|
+
return { ok: true, lines: session ? await captureTmuxTail(session, boundedLineCount(args.lines)) : [] };
|
|
1532
|
+
}
|
|
1533
|
+
if (name === "skc_coordinator_list_questions") return { ok: true, questions: await listQuestions(args) };
|
|
1534
|
+
if (name === "skc_coordinator_list_artifacts") return { ok: true, roots: config.allowedRoots };
|
|
1535
|
+
if (name === "skc_coordinator_read_artifact")
|
|
1536
|
+
return await readCoordinatorArtifact(config, { path: args.path });
|
|
1537
|
+
if (name === "skc_coordinator_read_coordination_status") {
|
|
1538
|
+
const sessions = jsonRecords(await listSessions());
|
|
1539
|
+
const sessionStates = jsonRecords(await listJsonFiles(path.join(namespaceDir, "session-states")));
|
|
1540
|
+
const turns = jsonRecords(await listJsonFiles(turnsDir(namespaceDir)));
|
|
1541
|
+
const questions = jsonRecords(await listQuestions(args));
|
|
1542
|
+
const reports = jsonRecords(await listJsonFiles(path.join(namespaceDir, "reports")));
|
|
1543
|
+
const events = await readCoordinatorEvents(namespaceDir);
|
|
1544
|
+
return {
|
|
1545
|
+
ok: true,
|
|
1546
|
+
schema_version: 1,
|
|
1547
|
+
namespace: config.namespace,
|
|
1548
|
+
state_root: namespaceDir,
|
|
1549
|
+
transport: { mcp: "polling", push_subscriptions: false },
|
|
1550
|
+
summary: {
|
|
1551
|
+
sessions: sessions.length,
|
|
1552
|
+
active_sessions: activeSessionStates(sessionStates).length,
|
|
1553
|
+
turns: turns.length,
|
|
1554
|
+
active_turns: turns.filter(turn => ACTIVE_TURN_STATUSES.has(turn.status as TurnStatus)).length,
|
|
1555
|
+
queued_turns: turns.filter(turn => turn.status === "queued").length,
|
|
1556
|
+
terminal_turns: turns.filter(turn => TERMINAL_TURN_STATUSES.has(turn.status as TurnStatus)).length,
|
|
1557
|
+
open_questions: questions.filter(question => question.status === "open").length,
|
|
1558
|
+
reports: reports.length,
|
|
1559
|
+
},
|
|
1560
|
+
sessions,
|
|
1561
|
+
session_states: sessionStates,
|
|
1562
|
+
turns,
|
|
1563
|
+
questions,
|
|
1564
|
+
reports,
|
|
1565
|
+
events: buildCanonicalCoordinatorEvents({ sessionStates, turns, questions, reports }),
|
|
1566
|
+
latest_event_seq: await readLatestEventSeq(namespaceDir),
|
|
1567
|
+
recent_events: eventSummaries(events.slice(-10)),
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
if (name === "skc_coordinator_watch_events") {
|
|
1571
|
+
const limit = boundedEventLimit(args.limit);
|
|
1572
|
+
const timeoutMs = boundedTimeoutMs(args.timeout_ms);
|
|
1573
|
+
let events = await readCoordinatorEvents(namespaceDir);
|
|
1574
|
+
let matched = filterCoordinatorEvents(events, args, limit);
|
|
1575
|
+
let timedOut = false;
|
|
1576
|
+
if (matched.length === 0 && timeoutMs > 0) {
|
|
1577
|
+
await waitForCoordinatorEvents(namespaceDir, timeoutMs);
|
|
1578
|
+
events = await readCoordinatorEvents(namespaceDir);
|
|
1579
|
+
matched = filterCoordinatorEvents(events, args, limit);
|
|
1580
|
+
timedOut = matched.length === 0;
|
|
1581
|
+
}
|
|
1582
|
+
return {
|
|
1583
|
+
ok: true,
|
|
1584
|
+
events: matched,
|
|
1585
|
+
latest_seq: await readLatestEventSeq(namespaceDir),
|
|
1586
|
+
timed_out: timedOut,
|
|
1587
|
+
transport: { mcp: "long_poll", push_subscriptions: false },
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
if (name === "skc_coordinator_start_session") {
|
|
1591
|
+
requireCoordinatorMutation(config, "sessions", args);
|
|
1592
|
+
const cwd = await assertCoordinatorWorkdir(config, args.cwd);
|
|
1593
|
+
const input = {
|
|
1594
|
+
cwd,
|
|
1595
|
+
prompt: typeof args.prompt === "string" ? args.prompt : undefined,
|
|
1596
|
+
namespace: config.namespace,
|
|
1597
|
+
worktree: true as const,
|
|
1598
|
+
};
|
|
1599
|
+
const started = services.startSession
|
|
1600
|
+
? await services.startSession(input)
|
|
1601
|
+
: await startTmuxSession(config, input, namespaceDir, commandRunner);
|
|
1602
|
+
const startedRecord = asRecord(started);
|
|
1603
|
+
if (!startedRecord) throw new Error("coordinator_session_command_required");
|
|
1604
|
+
const session = normalizeSession(startedRecord);
|
|
1605
|
+
await writeJsonFile(sessionFile(session.session_id), session);
|
|
1606
|
+
await appendCoordinatorEvent(namespaceDir, {
|
|
1607
|
+
kind: "session.started",
|
|
1608
|
+
sessionId: String(session.session_id),
|
|
1609
|
+
summary: `Session ${String(session.session_id)} started by coordinator`,
|
|
1610
|
+
payloadRef: path.relative(namespaceDir, sessionFile(session.session_id)),
|
|
1611
|
+
metadata: { prompted: typeof args.prompt === "string" && args.prompt.length > 0 },
|
|
1612
|
+
});
|
|
1613
|
+
const live = hasTmuxIdentity(session) ? await hasTmuxSession(session, commandRunner) : null;
|
|
1614
|
+
let sessionState = await writeSessionState(namespaceDir, String(session.session_id), "ready_for_input", {
|
|
1615
|
+
live,
|
|
1616
|
+
reason: null,
|
|
1617
|
+
});
|
|
1618
|
+
if (typeof args.prompt === "string" && args.prompt.length > 0) {
|
|
1619
|
+
const turn = await activateTurn(
|
|
1620
|
+
session,
|
|
1621
|
+
makeTurnRecord(config, String(session.session_id), args.prompt, "active"),
|
|
1622
|
+
);
|
|
1623
|
+
sessionState = (await readSessionState(namespaceDir, turn.session_id)) ?? sessionState;
|
|
1624
|
+
const prompt = {
|
|
1625
|
+
session_id: session.session_id,
|
|
1626
|
+
turn_id: turn.turn_id,
|
|
1627
|
+
prompt: args.prompt,
|
|
1628
|
+
queued: turn.delivery.queued,
|
|
1629
|
+
delivered: turn.delivery.delivered,
|
|
1630
|
+
tmux_keys_sent: turn.delivery.tmux_keys_sent ?? false,
|
|
1631
|
+
prompt_acknowledged: turn.delivery.prompt_acknowledged ?? false,
|
|
1632
|
+
created_at: turn.created_at,
|
|
1633
|
+
};
|
|
1634
|
+
await writeJsonFile(path.join(namespaceDir, "prompts", `${Date.now()}.json`), prompt);
|
|
1635
|
+
return {
|
|
1636
|
+
ok: true,
|
|
1637
|
+
session,
|
|
1638
|
+
session_state: sessionState,
|
|
1639
|
+
turn,
|
|
1640
|
+
turn_id: turn.turn_id,
|
|
1641
|
+
active_turn_id: turn.turn_id,
|
|
1642
|
+
status: turn.status,
|
|
1643
|
+
queued: turn.delivery.queued,
|
|
1644
|
+
delivered: turn.delivery.delivered,
|
|
1645
|
+
delivery: turn.delivery,
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
return { ok: true, session, session_state: sessionState };
|
|
1649
|
+
}
|
|
1650
|
+
if (name === "skc_coordinator_send_prompt") {
|
|
1651
|
+
requireCoordinatorMutation(config, "sessions", args);
|
|
1652
|
+
const sessionId = safeExternalId("session", args.session_id);
|
|
1653
|
+
const session = asRecord(await readJsonFile(sessionFile(sessionId)));
|
|
1654
|
+
if (!session) return { ok: false, reason: "unknown_session", session_id: sessionId };
|
|
1655
|
+
if (typeof args.prompt !== "string" || args.prompt.length === 0)
|
|
1656
|
+
return { ok: false, reason: "prompt_required" };
|
|
1657
|
+
const activeTurn = await readActiveTurn(namespaceDir, sessionId);
|
|
1658
|
+
if (activeTurn && args.force !== true && args.queue !== true) {
|
|
1659
|
+
return {
|
|
1660
|
+
ok: false,
|
|
1661
|
+
reason: "active_turn_exists",
|
|
1662
|
+
session_id: sessionId,
|
|
1663
|
+
active_turn_id: activeTurn.turn_id,
|
|
1664
|
+
};
|
|
1665
|
+
}
|
|
1666
|
+
if (activeTurn && args.force === true) {
|
|
1667
|
+
const timestamp = new Date().toISOString();
|
|
1668
|
+
const superseded = {
|
|
1669
|
+
...activeTurn,
|
|
1670
|
+
status: "superseded" as const,
|
|
1671
|
+
updated_at: timestamp,
|
|
1672
|
+
completed_at: timestamp,
|
|
1673
|
+
};
|
|
1674
|
+
await writeTurnRecord(namespaceDir, superseded);
|
|
1675
|
+
await clearActiveTurn(namespaceDir, superseded);
|
|
1676
|
+
}
|
|
1677
|
+
const shouldQueue = args.queue === true && args.force !== true;
|
|
1678
|
+
const turn = shouldQueue
|
|
1679
|
+
? makeTurnRecord(config, sessionId, args.prompt, "queued")
|
|
1680
|
+
: await activateTurn(session, makeTurnRecord(config, sessionId, args.prompt, "active"));
|
|
1681
|
+
if (shouldQueue) await writeTurnRecord(namespaceDir, turn);
|
|
1682
|
+
const recordedTurn = turn;
|
|
1683
|
+
const prompt = {
|
|
1684
|
+
session_id: sessionId,
|
|
1685
|
+
turn_id: recordedTurn.turn_id,
|
|
1686
|
+
prompt: args.prompt,
|
|
1687
|
+
queued: recordedTurn.delivery.queued,
|
|
1688
|
+
delivered: recordedTurn.delivery.delivered,
|
|
1689
|
+
tmux_keys_sent: recordedTurn.delivery.tmux_keys_sent ?? false,
|
|
1690
|
+
prompt_acknowledged: recordedTurn.delivery.prompt_acknowledged ?? false,
|
|
1691
|
+
created_at: recordedTurn.created_at,
|
|
1692
|
+
};
|
|
1693
|
+
await writeJsonFile(path.join(namespaceDir, "prompts", `${Date.now()}.json`), prompt);
|
|
1694
|
+
return {
|
|
1695
|
+
ok: true,
|
|
1696
|
+
session_id: sessionId,
|
|
1697
|
+
turn_id: recordedTurn.turn_id,
|
|
1698
|
+
active_turn_id: shouldQueue ? activeTurn?.turn_id : recordedTurn.turn_id,
|
|
1699
|
+
status: recordedTurn.status,
|
|
1700
|
+
queued: recordedTurn.delivery.queued,
|
|
1701
|
+
delivered: recordedTurn.delivery.delivered,
|
|
1702
|
+
delivery: recordedTurn.delivery,
|
|
1703
|
+
prompt,
|
|
1704
|
+
tmux_keys_sent: recordedTurn.delivery.tmux_keys_sent ?? false,
|
|
1705
|
+
prompt_acknowledged: recordedTurn.delivery.prompt_acknowledged ?? false,
|
|
1706
|
+
session_state: await readSessionState(namespaceDir, sessionId),
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
if (name === "skc_coordinator_read_turn") {
|
|
1710
|
+
return await readTurnPayload(args.turn_id, args.session_id, args.lines);
|
|
1711
|
+
}
|
|
1712
|
+
if (name === "skc_coordinator_await_turn") {
|
|
1713
|
+
const timeoutMs = boundedTimeoutMs(args.timeout_ms);
|
|
1714
|
+
const pollIntervalMs = boundedPollIntervalMs(args.poll_interval_ms);
|
|
1715
|
+
const deadline = Date.now() + timeoutMs;
|
|
1716
|
+
let payload = await readTurnPayload(args.turn_id, args.session_id, args.lines);
|
|
1717
|
+
while (
|
|
1718
|
+
payload.ok === true &&
|
|
1719
|
+
!TERMINAL_TURN_STATUSES.has((payload.turn as TurnRecord).status) &&
|
|
1720
|
+
Date.now() < deadline
|
|
1721
|
+
) {
|
|
1722
|
+
const remainingMs = deadline - Date.now();
|
|
1723
|
+
await waitForTurnStateChange(
|
|
1724
|
+
namespaceDir,
|
|
1725
|
+
payload.turn as TurnRecord,
|
|
1726
|
+
Math.min(pollIntervalMs, remainingMs),
|
|
1727
|
+
);
|
|
1728
|
+
payload = await readTurnPayload(args.turn_id, args.session_id, args.lines);
|
|
1729
|
+
}
|
|
1730
|
+
if (payload.ok === true && !TERMINAL_TURN_STATUSES.has((payload.turn as TurnRecord).status)) {
|
|
1731
|
+
return {
|
|
1732
|
+
ok: false,
|
|
1733
|
+
reason: "timeout",
|
|
1734
|
+
turn: payload.turn,
|
|
1735
|
+
advisory_status: payload.advisory_status,
|
|
1736
|
+
session_state: payload.session_state,
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
return payload;
|
|
1740
|
+
}
|
|
1741
|
+
if (name === "skc_coordinator_submit_question_answer") {
|
|
1742
|
+
requireCoordinatorMutation(config, "questions", args);
|
|
1743
|
+
const questionId = safeExternalId("question", args.question_id);
|
|
1744
|
+
const questionPath = questionFile(namespaceDir, questionId);
|
|
1745
|
+
const question = asRecord(await readJsonFile(questionPath));
|
|
1746
|
+
if (!question) return { ok: false, reason: "unknown_question" };
|
|
1747
|
+
if (args.session_id != null && question.session_id !== safeExternalId("session", args.session_id)) {
|
|
1748
|
+
return { ok: false, reason: "question_session_mismatch" };
|
|
1749
|
+
}
|
|
1750
|
+
if (args.turn_id != null && question.turn_id !== safeTurnId(args.turn_id)) {
|
|
1751
|
+
return { ok: false, reason: "question_turn_mismatch" };
|
|
1752
|
+
}
|
|
1753
|
+
const answeredTurnId = typeof question.turn_id === "string" ? question.turn_id : null;
|
|
1754
|
+
const answered = {
|
|
1755
|
+
...question,
|
|
1756
|
+
status: "answered",
|
|
1757
|
+
answer: args.answer,
|
|
1758
|
+
answered_at: new Date().toISOString(),
|
|
1759
|
+
};
|
|
1760
|
+
await writeJsonFile(questionPath, answered);
|
|
1761
|
+
if (question.status === "open") {
|
|
1762
|
+
await appendCoordinatorEvent(namespaceDir, {
|
|
1763
|
+
kind: "question.opened",
|
|
1764
|
+
sessionId: typeof question.session_id === "string" ? question.session_id : null,
|
|
1765
|
+
turnId: typeof question.turn_id === "string" ? question.turn_id : null,
|
|
1766
|
+
questionId,
|
|
1767
|
+
summary: `Question ${questionId} opened`,
|
|
1768
|
+
payloadRef: path.relative(namespaceDir, questionPath),
|
|
1769
|
+
});
|
|
1770
|
+
}
|
|
1771
|
+
await appendCoordinatorEvent(namespaceDir, {
|
|
1772
|
+
kind: "question.answered",
|
|
1773
|
+
sessionId: typeof question.session_id === "string" ? question.session_id : null,
|
|
1774
|
+
turnId: typeof question.turn_id === "string" ? question.turn_id : null,
|
|
1775
|
+
questionId,
|
|
1776
|
+
summary: `Question ${questionId} answered`,
|
|
1777
|
+
payloadRef: path.relative(namespaceDir, questionPath),
|
|
1778
|
+
});
|
|
1779
|
+
|
|
1780
|
+
let turn: TurnRecord | null = null;
|
|
1781
|
+
if (answeredTurnId) {
|
|
1782
|
+
turn = await readTurnRecord(namespaceDir, answeredTurnId);
|
|
1783
|
+
if (turn) {
|
|
1784
|
+
const timestamp = new Date().toISOString();
|
|
1785
|
+
turn = {
|
|
1786
|
+
...turn,
|
|
1787
|
+
status: "active",
|
|
1788
|
+
question_ids: [...new Set([...turn.question_ids, questionId])],
|
|
1789
|
+
updated_at: timestamp,
|
|
1790
|
+
};
|
|
1791
|
+
await writeTurnRecord(namespaceDir, turn);
|
|
1792
|
+
await writeActiveTurn(namespaceDir, turn);
|
|
1793
|
+
await writeSessionState(namespaceDir, turn.session_id, "running", {
|
|
1794
|
+
currentTurnId: turn.turn_id,
|
|
1795
|
+
live: null,
|
|
1796
|
+
reason: null,
|
|
1797
|
+
});
|
|
1798
|
+
const session = asRecord(await readJsonFile(sessionFile(turn.session_id)));
|
|
1799
|
+
if (session && typeof args.answer === "string")
|
|
1800
|
+
await sendTmuxPrompt(session, args.answer, commandRunner);
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
return { ok: true, question: answered, ...(turn ? { turn } : {}) };
|
|
1804
|
+
}
|
|
1805
|
+
if (name === "skc_coordinator_report_status") {
|
|
1806
|
+
requireCoordinatorMutation(config, "reports", args);
|
|
1807
|
+
const evidence = await validateEvidencePaths(args.evidence_paths);
|
|
1808
|
+
const sessionId = args.session_id == null ? null : safeExternalId("session", args.session_id);
|
|
1809
|
+
const report = {
|
|
1810
|
+
session_id: sessionId,
|
|
1811
|
+
turn_id: args.turn_id,
|
|
1812
|
+
status: args.status,
|
|
1813
|
+
summary: args.summary,
|
|
1814
|
+
blocker: args.blocker,
|
|
1815
|
+
pr_url: args.pr_url,
|
|
1816
|
+
evidence_paths: evidence.map(item => item.path),
|
|
1817
|
+
created_at: new Date().toISOString(),
|
|
1818
|
+
};
|
|
1819
|
+
let turn: TurnRecord | null = null;
|
|
1820
|
+
let promotedTurn: TurnRecord | null = null;
|
|
1821
|
+
if (args.turn_id != null) {
|
|
1822
|
+
turn = await readTurnRecord(namespaceDir, args.turn_id);
|
|
1823
|
+
if (!turn) return { ok: false, reason: "unknown_turn" };
|
|
1824
|
+
if (sessionId != null && turn.session_id !== sessionId) {
|
|
1825
|
+
return { ok: false, reason: "turn_session_mismatch" };
|
|
1826
|
+
}
|
|
1827
|
+
const terminalStatus = asTerminalTurnStatus(args.status);
|
|
1828
|
+
if (terminalStatus) {
|
|
1829
|
+
const timestamp = new Date().toISOString();
|
|
1830
|
+
turn = {
|
|
1831
|
+
...turn,
|
|
1832
|
+
status: terminalStatus,
|
|
1833
|
+
delivery: {
|
|
1834
|
+
...turn.delivery,
|
|
1835
|
+
prompt_acknowledged: true,
|
|
1836
|
+
state: "acknowledged",
|
|
1837
|
+
},
|
|
1838
|
+
final_response: {
|
|
1839
|
+
text:
|
|
1840
|
+
typeof args.summary === "string"
|
|
1841
|
+
? args.summary
|
|
1842
|
+
: typeof args.blocker === "string"
|
|
1843
|
+
? args.blocker
|
|
1844
|
+
: null,
|
|
1845
|
+
format: "markdown",
|
|
1846
|
+
source: "report_status",
|
|
1847
|
+
artifact_path: null,
|
|
1848
|
+
truncated: false,
|
|
1849
|
+
},
|
|
1850
|
+
evidence,
|
|
1851
|
+
error:
|
|
1852
|
+
terminalStatus === "failed"
|
|
1853
|
+
? {
|
|
1854
|
+
code: "reported_failure",
|
|
1855
|
+
message:
|
|
1856
|
+
typeof args.blocker === "string" ? args.blocker : String(args.summary ?? "failed"),
|
|
1857
|
+
recoverable: true,
|
|
1858
|
+
}
|
|
1859
|
+
: null,
|
|
1860
|
+
updated_at: timestamp,
|
|
1861
|
+
completed_at: timestamp,
|
|
1862
|
+
};
|
|
1863
|
+
await writeTurnRecord(namespaceDir, turn);
|
|
1864
|
+
await clearActiveTurn(namespaceDir, turn);
|
|
1865
|
+
await writeSessionState(
|
|
1866
|
+
namespaceDir,
|
|
1867
|
+
turn.session_id,
|
|
1868
|
+
terminalStatus === "failed" ? "errored" : "completed",
|
|
1869
|
+
{
|
|
1870
|
+
lastTurnId: turn.turn_id,
|
|
1871
|
+
live: null,
|
|
1872
|
+
reason: terminalStatus === "failed" ? "reported_failure" : null,
|
|
1873
|
+
},
|
|
1874
|
+
);
|
|
1875
|
+
promotedTurn = await promoteNextQueuedTurn(turn.session_id);
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
const reportId = `report-${Date.now()}`;
|
|
1879
|
+
const reportPath = path.join(namespaceDir, "reports", `${reportId}.json`);
|
|
1880
|
+
await writeJsonFile(reportPath, report);
|
|
1881
|
+
await appendCoordinatorEvent(namespaceDir, {
|
|
1882
|
+
kind: "report.written",
|
|
1883
|
+
sessionId,
|
|
1884
|
+
turnId: typeof args.turn_id === "string" ? args.turn_id : null,
|
|
1885
|
+
reportId,
|
|
1886
|
+
summary:
|
|
1887
|
+
typeof args.summary === "string"
|
|
1888
|
+
? args.summary
|
|
1889
|
+
: `Report ${String(args.status ?? "unknown")} written`,
|
|
1890
|
+
payloadRef: path.relative(namespaceDir, reportPath),
|
|
1891
|
+
metadata: { status: typeof args.status === "string" ? args.status : null },
|
|
1892
|
+
});
|
|
1893
|
+
return {
|
|
1894
|
+
ok: true,
|
|
1895
|
+
report,
|
|
1896
|
+
...(turn ? { turn, session_state: await readSessionState(namespaceDir, turn.session_id) } : {}),
|
|
1897
|
+
...(promotedTurn ? { promoted_turn: promotedTurn } : {}),
|
|
1898
|
+
};
|
|
1899
|
+
}
|
|
1900
|
+
return { ok: false, reason: "unknown_tool", tool: name };
|
|
1901
|
+
} catch (error) {
|
|
1902
|
+
return { ok: false, reason: error instanceof Error ? error.message : String(error) };
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
async function handleJsonRpc(request: JsonRpcRequest): Promise<JsonRpcResponse> {
|
|
1907
|
+
const id = request.id ?? null;
|
|
1908
|
+
if (request.method === "initialize") {
|
|
1909
|
+
return {
|
|
1910
|
+
jsonrpc: "2.0",
|
|
1911
|
+
id,
|
|
1912
|
+
result: {
|
|
1913
|
+
protocolVersion: COORDINATOR_MCP_PROTOCOL_VERSION,
|
|
1914
|
+
capabilities: { tools: {}, prompts: {}, resources: {} },
|
|
1915
|
+
serverInfo: { name: COORDINATOR_MCP_SERVER_NAME, version: VERSION },
|
|
1916
|
+
},
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
if (request.method === "tools/list") {
|
|
1920
|
+
return { jsonrpc: "2.0", id, result: { tools: COORDINATOR_MCP_TOOL_NAMES.map(toolSchema) } };
|
|
1921
|
+
}
|
|
1922
|
+
if (request.method === "prompts/list") {
|
|
1923
|
+
return { jsonrpc: "2.0", id, result: { prompts: [] } };
|
|
1924
|
+
}
|
|
1925
|
+
if (request.method === "resources/list") {
|
|
1926
|
+
return { jsonrpc: "2.0", id, result: { resources: [] } };
|
|
1927
|
+
}
|
|
1928
|
+
if (request.method === "tools/call") {
|
|
1929
|
+
const params = (request.params ?? {}) as { name?: string; arguments?: Record<string, unknown> };
|
|
1930
|
+
const payload = await callTool(params.name ?? "", params.arguments ?? {});
|
|
1931
|
+
return { jsonrpc: "2.0", id, result: textResult(payload, payload.ok === false) };
|
|
1932
|
+
}
|
|
1933
|
+
return { jsonrpc: "2.0", id, error: { code: -32601, message: `unknown_method:${request.method}` } };
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
return { config, callTool, handleJsonRpc, handle: handleJsonRpc };
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
function legacyToolResult(payload: unknown): { content: Array<{ type: "text"; text: string }>; isError: boolean } {
|
|
1940
|
+
const failed = typeof payload === "object" && payload !== null && (payload as { ok?: unknown }).ok === false;
|
|
1941
|
+
return textResult(payload, failed);
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
export async function handleCoordinatorMcpRequest(
|
|
1945
|
+
request: JsonRpcRequest,
|
|
1946
|
+
options: LegacyHandlerOptions = {},
|
|
1947
|
+
): Promise<JsonRpcResponse> {
|
|
1948
|
+
if (request.method === "initialize") {
|
|
1949
|
+
return {
|
|
1950
|
+
jsonrpc: "2.0",
|
|
1951
|
+
id: request.id ?? null,
|
|
1952
|
+
result: {
|
|
1953
|
+
protocolVersion: COORDINATOR_MCP_PROTOCOL_VERSION,
|
|
1954
|
+
capabilities: { tools: {}, prompts: {}, resources: {} },
|
|
1955
|
+
serverInfo: { name: COORDINATOR_MCP_SERVER_NAME, version: VERSION },
|
|
1956
|
+
},
|
|
1957
|
+
};
|
|
1958
|
+
}
|
|
1959
|
+
if (request.method === "tools/list") {
|
|
1960
|
+
return { jsonrpc: "2.0", id: request.id ?? null, result: { tools: COORDINATOR_MCP_TOOL_NAMES.map(toolSchema) } };
|
|
1961
|
+
}
|
|
1962
|
+
if (request.method === "prompts/list") {
|
|
1963
|
+
return { jsonrpc: "2.0", id: request.id ?? null, result: { prompts: [] } };
|
|
1964
|
+
}
|
|
1965
|
+
if (request.method === "resources/list") {
|
|
1966
|
+
return { jsonrpc: "2.0", id: request.id ?? null, result: { resources: [] } };
|
|
1967
|
+
}
|
|
1968
|
+
if (request.method !== "tools/call")
|
|
1969
|
+
return {
|
|
1970
|
+
jsonrpc: "2.0",
|
|
1971
|
+
id: request.id ?? null,
|
|
1972
|
+
error: { code: -32601, message: `unknown_method:${request.method}` },
|
|
1973
|
+
};
|
|
1974
|
+
const params = (request.params ?? {}) as { name?: string; arguments?: Record<string, unknown> };
|
|
1975
|
+
const args = params.arguments ?? {};
|
|
1976
|
+
const server = createCoordinatorMcpServer({
|
|
1977
|
+
env: options.env ?? process.env,
|
|
1978
|
+
services: options.createSession ? { startSession: () => options.createSession?.() } : undefined,
|
|
1979
|
+
});
|
|
1980
|
+
return {
|
|
1981
|
+
jsonrpc: "2.0",
|
|
1982
|
+
id: request.id ?? null,
|
|
1983
|
+
result: legacyToolResult(await server.callTool(params.name ?? "", args)),
|
|
1984
|
+
};
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
export async function runCoordinatorMcpStdio(options: CoordinatorMcpServerOptions = {}): Promise<void> {
|
|
1988
|
+
const server = createCoordinatorMcpServer(options);
|
|
1989
|
+
let buffer = "";
|
|
1990
|
+
for await (const chunk of process.stdin) {
|
|
1991
|
+
buffer += chunk.toString();
|
|
1992
|
+
let newline = buffer.indexOf("\n");
|
|
1993
|
+
while (newline >= 0) {
|
|
1994
|
+
const line = buffer.slice(0, newline).trim();
|
|
1995
|
+
buffer = buffer.slice(newline + 1);
|
|
1996
|
+
if (line.length > 0) {
|
|
1997
|
+
const request = JSON.parse(line) as JsonRpcRequest;
|
|
1998
|
+
if (request.id !== undefined && request.id !== null) {
|
|
1999
|
+
const response = await server.handleJsonRpc(request);
|
|
2000
|
+
process.stdout.write(`${JSON.stringify(response)}\n`);
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
newline = buffer.indexOf("\n");
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
}
|