@useconvoy/cli 0.48.0
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/LICENSE +90 -0
- package/README.md +495 -0
- package/dist/bin/convoy.d.ts +2 -0
- package/dist/bin/convoy.js +129 -0
- package/dist/bin/convoy.js.map +1 -0
- package/dist/marketplace/.claude-plugin/marketplace.json +14 -0
- package/dist/marketplace/opensana/.claude-plugin/plugin.json +5 -0
- package/dist/marketplace/opensana/README.md +90 -0
- package/dist/marketplace/opensana/skills/tasks/SKILL.md +133 -0
- package/dist/marketplace/opensana/skills/tasks/references/mcp-setup.md +164 -0
- package/dist/src/agent/app/chunk-flush-buffer.d.ts +35 -0
- package/dist/src/agent/app/chunk-flush-buffer.js +133 -0
- package/dist/src/agent/app/chunk-flush-buffer.js.map +1 -0
- package/dist/src/agent/app/chunk-scrub.d.ts +9 -0
- package/dist/src/agent/app/chunk-scrub.js +120 -0
- package/dist/src/agent/app/chunk-scrub.js.map +1 -0
- package/dist/src/agent/app/interaction-router.d.ts +16 -0
- package/dist/src/agent/app/interaction-router.js +29 -0
- package/dist/src/agent/app/interaction-router.js.map +1 -0
- package/dist/src/agent/app/runner.d.ts +41 -0
- package/dist/src/agent/app/runner.js +353 -0
- package/dist/src/agent/app/runner.js.map +1 -0
- package/dist/src/agent/app/runtime-config.d.ts +3 -0
- package/dist/src/agent/app/runtime-config.js +4 -0
- package/dist/src/agent/app/runtime-config.js.map +1 -0
- package/dist/src/agent/app/thread-attachment-cache.d.ts +17 -0
- package/dist/src/agent/app/thread-attachment-cache.js +124 -0
- package/dist/src/agent/app/thread-attachment-cache.js.map +1 -0
- package/dist/src/agent/app/thread-processor.d.ts +40 -0
- package/dist/src/agent/app/thread-processor.js +792 -0
- package/dist/src/agent/app/thread-processor.js.map +1 -0
- package/dist/src/agent/app/worktree-op-processor.d.ts +27 -0
- package/dist/src/agent/app/worktree-op-processor.js +173 -0
- package/dist/src/agent/app/worktree-op-processor.js.map +1 -0
- package/dist/src/agent/runtimes/agent-instructions.d.ts +16 -0
- package/dist/src/agent/runtimes/agent-instructions.js +33 -0
- package/dist/src/agent/runtimes/agent-instructions.js.map +1 -0
- package/dist/src/agent/runtimes/claudeCode/continuation.d.ts +1 -0
- package/dist/src/agent/runtimes/claudeCode/continuation.js +30 -0
- package/dist/src/agent/runtimes/claudeCode/continuation.js.map +1 -0
- package/dist/src/agent/runtimes/claudeCode/detect.d.ts +12 -0
- package/dist/src/agent/runtimes/claudeCode/detect.js +109 -0
- package/dist/src/agent/runtimes/claudeCode/detect.js.map +1 -0
- package/dist/src/agent/runtimes/claudeCode/interactions.d.ts +13 -0
- package/dist/src/agent/runtimes/claudeCode/interactions.js +167 -0
- package/dist/src/agent/runtimes/claudeCode/interactions.js.map +1 -0
- package/dist/src/agent/runtimes/claudeCode/models.d.ts +3 -0
- package/dist/src/agent/runtimes/claudeCode/models.js +16 -0
- package/dist/src/agent/runtimes/claudeCode/models.js.map +1 -0
- package/dist/src/agent/runtimes/claudeCode/prompts.d.ts +1 -0
- package/dist/src/agent/runtimes/claudeCode/prompts.js +5 -0
- package/dist/src/agent/runtimes/claudeCode/prompts.js.map +1 -0
- package/dist/src/agent/runtimes/claudeCode/runner.d.ts +32 -0
- package/dist/src/agent/runtimes/claudeCode/runner.js +941 -0
- package/dist/src/agent/runtimes/claudeCode/runner.js.map +1 -0
- package/dist/src/agent/runtimes/claudeCode/runtime.d.ts +2 -0
- package/dist/src/agent/runtimes/claudeCode/runtime.js +126 -0
- package/dist/src/agent/runtimes/claudeCode/runtime.js.map +1 -0
- package/dist/src/agent/runtimes/claudeCode/streaming.d.ts +8 -0
- package/dist/src/agent/runtimes/claudeCode/streaming.js +88 -0
- package/dist/src/agent/runtimes/claudeCode/streaming.js.map +1 -0
- package/dist/src/agent/runtimes/codex/app-server-rpc.d.ts +26 -0
- package/dist/src/agent/runtimes/codex/app-server-rpc.js +109 -0
- package/dist/src/agent/runtimes/codex/app-server-rpc.js.map +1 -0
- package/dist/src/agent/runtimes/codex/app-server-runner.d.ts +59 -0
- package/dist/src/agent/runtimes/codex/app-server-runner.js +688 -0
- package/dist/src/agent/runtimes/codex/app-server-runner.js.map +1 -0
- package/dist/src/agent/runtimes/codex/commands.d.ts +23 -0
- package/dist/src/agent/runtimes/codex/commands.js +25 -0
- package/dist/src/agent/runtimes/codex/commands.js.map +1 -0
- package/dist/src/agent/runtimes/codex/detect.d.ts +5 -0
- package/dist/src/agent/runtimes/codex/detect.js +17 -0
- package/dist/src/agent/runtimes/codex/detect.js.map +1 -0
- package/dist/src/agent/runtimes/codex/models.d.ts +2 -0
- package/dist/src/agent/runtimes/codex/models.js +4 -0
- package/dist/src/agent/runtimes/codex/models.js.map +1 -0
- package/dist/src/agent/runtimes/codex/runner.d.ts +46 -0
- package/dist/src/agent/runtimes/codex/runner.js +298 -0
- package/dist/src/agent/runtimes/codex/runner.js.map +1 -0
- package/dist/src/agent/runtimes/codex/runtime.d.ts +10 -0
- package/dist/src/agent/runtimes/codex/runtime.js +73 -0
- package/dist/src/agent/runtimes/codex/runtime.js.map +1 -0
- package/dist/src/agent/runtimes/contracts.d.ts +215 -0
- package/dist/src/agent/runtimes/contracts.js +33 -0
- package/dist/src/agent/runtimes/contracts.js.map +1 -0
- package/dist/src/agent/runtimes/cursor/commands.d.ts +7 -0
- package/dist/src/agent/runtimes/cursor/commands.js +39 -0
- package/dist/src/agent/runtimes/cursor/commands.js.map +1 -0
- package/dist/src/agent/runtimes/cursor/detect.d.ts +17 -0
- package/dist/src/agent/runtimes/cursor/detect.js +54 -0
- package/dist/src/agent/runtimes/cursor/detect.js.map +1 -0
- package/dist/src/agent/runtimes/cursor/models.d.ts +9 -0
- package/dist/src/agent/runtimes/cursor/models.js +97 -0
- package/dist/src/agent/runtimes/cursor/models.js.map +1 -0
- package/dist/src/agent/runtimes/cursor/runner.d.ts +36 -0
- package/dist/src/agent/runtimes/cursor/runner.js +293 -0
- package/dist/src/agent/runtimes/cursor/runner.js.map +1 -0
- package/dist/src/agent/runtimes/cursor/runtime.d.ts +2 -0
- package/dist/src/agent/runtimes/cursor/runtime.js +48 -0
- package/dist/src/agent/runtimes/cursor/runtime.js.map +1 -0
- package/dist/src/agent/runtimes/cursor/streaming.d.ts +8 -0
- package/dist/src/agent/runtimes/cursor/streaming.js +78 -0
- package/dist/src/agent/runtimes/cursor/streaming.js.map +1 -0
- package/dist/src/agent/runtimes/debug.d.ts +8 -0
- package/dist/src/agent/runtimes/debug.js +19 -0
- package/dist/src/agent/runtimes/debug.js.map +1 -0
- package/dist/src/agent/runtimes/message-format.d.ts +6 -0
- package/dist/src/agent/runtimes/message-format.js +31 -0
- package/dist/src/agent/runtimes/message-format.js.map +1 -0
- package/dist/src/agent/runtimes/opencode/client.d.ts +82 -0
- package/dist/src/agent/runtimes/opencode/client.js +109 -0
- package/dist/src/agent/runtimes/opencode/client.js.map +1 -0
- package/dist/src/agent/runtimes/opencode/detect.d.ts +18 -0
- package/dist/src/agent/runtimes/opencode/detect.js +100 -0
- package/dist/src/agent/runtimes/opencode/detect.js.map +1 -0
- package/dist/src/agent/runtimes/opencode/json.d.ts +4 -0
- package/dist/src/agent/runtimes/opencode/json.js +17 -0
- package/dist/src/agent/runtimes/opencode/json.js.map +1 -0
- package/dist/src/agent/runtimes/opencode/runner.d.ts +50 -0
- package/dist/src/agent/runtimes/opencode/runner.js +598 -0
- package/dist/src/agent/runtimes/opencode/runner.js.map +1 -0
- package/dist/src/agent/runtimes/opencode/runtime.d.ts +9 -0
- package/dist/src/agent/runtimes/opencode/runtime.js +82 -0
- package/dist/src/agent/runtimes/opencode/runtime.js.map +1 -0
- package/dist/src/agent/runtimes/opencode/server.d.ts +36 -0
- package/dist/src/agent/runtimes/opencode/server.js +210 -0
- package/dist/src/agent/runtimes/opencode/server.js.map +1 -0
- package/dist/src/agent/runtimes/opencode/streaming.d.ts +7 -0
- package/dist/src/agent/runtimes/opencode/streaming.js +47 -0
- package/dist/src/agent/runtimes/opencode/streaming.js.map +1 -0
- package/dist/src/agent/runtimes/registry.d.ts +10 -0
- package/dist/src/agent/runtimes/registry.js +48 -0
- package/dist/src/agent/runtimes/registry.js.map +1 -0
- package/dist/src/agent/sdk/adapters/adapter-interface.d.ts +2 -0
- package/dist/src/agent/sdk/adapters/adapter-interface.js +4 -0
- package/dist/src/agent/sdk/adapters/adapter-interface.js.map +1 -0
- package/dist/src/agent/sdk/adapters/claude/claude-adapter.d.ts +9 -0
- package/dist/src/agent/sdk/adapters/claude/claude-adapter.js +95 -0
- package/dist/src/agent/sdk/adapters/claude/claude-adapter.js.map +1 -0
- package/dist/src/agent/sdk/adapters/codex/codex-adapter.d.ts +10 -0
- package/dist/src/agent/sdk/adapters/codex/codex-adapter.js +87 -0
- package/dist/src/agent/sdk/adapters/codex/codex-adapter.js.map +1 -0
- package/dist/src/agent/sdk/adapters/executable-resolution.d.ts +2 -0
- package/dist/src/agent/sdk/adapters/executable-resolution.js +50 -0
- package/dist/src/agent/sdk/adapters/executable-resolution.js.map +1 -0
- package/dist/src/agent/sdk/adapters/generic/generic-subprocess-adapter.d.ts +11 -0
- package/dist/src/agent/sdk/adapters/generic/generic-subprocess-adapter.js +61 -0
- package/dist/src/agent/sdk/adapters/generic/generic-subprocess-adapter.js.map +1 -0
- package/dist/src/agent/sdk/adapters/provider-registry.d.ts +8 -0
- package/dist/src/agent/sdk/adapters/provider-registry.js +32 -0
- package/dist/src/agent/sdk/adapters/provider-registry.js.map +1 -0
- package/dist/src/agent/sdk/constants.d.ts +5 -0
- package/dist/src/agent/sdk/constants.js +29 -0
- package/dist/src/agent/sdk/constants.js.map +1 -0
- package/dist/src/agent/sdk/index.d.ts +2 -0
- package/dist/src/agent/sdk/index.js +2 -0
- package/dist/src/agent/sdk/index.js.map +1 -0
- package/dist/src/agent/sdk/run-handle.d.ts +22 -0
- package/dist/src/agent/sdk/run-handle.js +90 -0
- package/dist/src/agent/sdk/run-handle.js.map +1 -0
- package/dist/src/agent/sdk/runtime/isolation-env.d.ts +9 -0
- package/dist/src/agent/sdk/runtime/isolation-env.js +39 -0
- package/dist/src/agent/sdk/runtime/isolation-env.js.map +1 -0
- package/dist/src/agent/sdk/runtime/line-parser.d.ts +11 -0
- package/dist/src/agent/sdk/runtime/line-parser.js +59 -0
- package/dist/src/agent/sdk/runtime/line-parser.js.map +1 -0
- package/dist/src/agent/sdk/runtime/output-pump.d.ts +20 -0
- package/dist/src/agent/sdk/runtime/output-pump.js +88 -0
- package/dist/src/agent/sdk/runtime/output-pump.js.map +1 -0
- package/dist/src/agent/sdk/runtime/process-group.d.ts +9 -0
- package/dist/src/agent/sdk/runtime/process-group.js +69 -0
- package/dist/src/agent/sdk/runtime/process-group.js.map +1 -0
- package/dist/src/agent/sdk/runtime/provider-supervisor-entrypoint.d.ts +1 -0
- package/dist/src/agent/sdk/runtime/provider-supervisor-entrypoint.js +3 -0
- package/dist/src/agent/sdk/runtime/provider-supervisor-entrypoint.js.map +1 -0
- package/dist/src/agent/sdk/runtime/provider-supervisor.d.ts +1 -0
- package/dist/src/agent/sdk/runtime/provider-supervisor.js +190 -0
- package/dist/src/agent/sdk/runtime/provider-supervisor.js.map +1 -0
- package/dist/src/agent/sdk/runtime/spawn-process.d.ts +7 -0
- package/dist/src/agent/sdk/runtime/spawn-process.js +16 -0
- package/dist/src/agent/sdk/runtime/spawn-process.js.map +1 -0
- package/dist/src/agent/sdk/runtime/spawn-supervised-process.d.ts +17 -0
- package/dist/src/agent/sdk/runtime/spawn-supervised-process.js +203 -0
- package/dist/src/agent/sdk/runtime/spawn-supervised-process.js.map +1 -0
- package/dist/src/agent/sdk/runtime/supervisor-protocol.d.ts +29 -0
- package/dist/src/agent/sdk/runtime/supervisor-protocol.js +90 -0
- package/dist/src/agent/sdk/runtime/supervisor-protocol.js.map +1 -0
- package/dist/src/agent/sdk/runtime/timeouts.d.ts +24 -0
- package/dist/src/agent/sdk/runtime/timeouts.js +65 -0
- package/dist/src/agent/sdk/runtime/timeouts.js.map +1 -0
- package/dist/src/agent/sdk/session-manager.d.ts +38 -0
- package/dist/src/agent/sdk/session-manager.js +557 -0
- package/dist/src/agent/sdk/session-manager.js.map +1 -0
- package/dist/src/agent/sdk/transport/json-stream-decoder.d.ts +6 -0
- package/dist/src/agent/sdk/transport/json-stream-decoder.js +29 -0
- package/dist/src/agent/sdk/transport/json-stream-decoder.js.map +1 -0
- package/dist/src/agent/sdk/transport/line-text-decoder.d.ts +6 -0
- package/dist/src/agent/sdk/transport/line-text-decoder.js +9 -0
- package/dist/src/agent/sdk/transport/line-text-decoder.js.map +1 -0
- package/dist/src/agent/sdk/transport/pty-contract.d.ts +12 -0
- package/dist/src/agent/sdk/transport/pty-contract.js +2 -0
- package/dist/src/agent/sdk/transport/pty-contract.js.map +1 -0
- package/dist/src/agent/sdk/types.d.ts +194 -0
- package/dist/src/agent/sdk/types.js +2 -0
- package/dist/src/agent/sdk/types.js.map +1 -0
- package/dist/src/agent/sdk/versioning/provider-version.d.ts +9 -0
- package/dist/src/agent/sdk/versioning/provider-version.js +41 -0
- package/dist/src/agent/sdk/versioning/provider-version.js.map +1 -0
- package/dist/src/cli.d.ts +7 -0
- package/dist/src/cli.js +56 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/config/command.d.ts +2 -0
- package/dist/src/commands/config/command.js +150 -0
- package/dist/src/commands/config/command.js.map +1 -0
- package/dist/src/commands/connect/command.d.ts +4 -0
- package/dist/src/commands/connect/command.js +19 -0
- package/dist/src/commands/connect/command.js.map +1 -0
- package/dist/src/commands/connect/workflow.d.ts +92 -0
- package/dist/src/commands/connect/workflow.js +381 -0
- package/dist/src/commands/connect/workflow.js.map +1 -0
- package/dist/src/commands/devcontainer/command.d.ts +2 -0
- package/dist/src/commands/devcontainer/command.js +49 -0
- package/dist/src/commands/devcontainer/command.js.map +1 -0
- package/dist/src/commands/devcontainer/install.d.ts +46 -0
- package/dist/src/commands/devcontainer/install.js +107 -0
- package/dist/src/commands/devcontainer/install.js.map +1 -0
- package/dist/src/commands/init/config/claude-mcp.d.ts +27 -0
- package/dist/src/commands/init/config/claude-mcp.js +56 -0
- package/dist/src/commands/init/config/claude-mcp.js.map +1 -0
- package/dist/src/commands/init/config/codex-mcp.d.ts +12 -0
- package/dist/src/commands/init/config/codex-mcp.js +83 -0
- package/dist/src/commands/init/config/codex-mcp.js.map +1 -0
- package/dist/src/commands/init/config/opencode-mcp.d.ts +16 -0
- package/dist/src/commands/init/config/opencode-mcp.js +55 -0
- package/dist/src/commands/init/config/opencode-mcp.js.map +1 -0
- package/dist/src/commands/init/errors.d.ts +3 -0
- package/dist/src/commands/init/errors.js +7 -0
- package/dist/src/commands/init/errors.js.map +1 -0
- package/dist/src/commands/init/index.d.ts +9 -0
- package/dist/src/commands/init/index.js +10 -0
- package/dist/src/commands/init/index.js.map +1 -0
- package/dist/src/commands/init/io/file-copy.d.ts +18 -0
- package/dist/src/commands/init/io/file-copy.js +129 -0
- package/dist/src/commands/init/io/file-copy.js.map +1 -0
- package/dist/src/commands/init/marketplace.d.ts +8 -0
- package/dist/src/commands/init/marketplace.js +25 -0
- package/dist/src/commands/init/marketplace.js.map +1 -0
- package/dist/src/commands/init/mcp-service.d.ts +2 -0
- package/dist/src/commands/init/mcp-service.js +66 -0
- package/dist/src/commands/init/mcp-service.js.map +1 -0
- package/dist/src/commands/init/parsers.d.ts +4 -0
- package/dist/src/commands/init/parsers.js +40 -0
- package/dist/src/commands/init/parsers.js.map +1 -0
- package/dist/src/commands/init/prompts.d.ts +4 -0
- package/dist/src/commands/init/prompts.js +72 -0
- package/dist/src/commands/init/prompts.js.map +1 -0
- package/dist/src/commands/init/skill-service.d.ts +2 -0
- package/dist/src/commands/init/skill-service.js +36 -0
- package/dist/src/commands/init/skill-service.js.map +1 -0
- package/dist/src/commands/init/summary.d.ts +2 -0
- package/dist/src/commands/init/summary.js +22 -0
- package/dist/src/commands/init/summary.js.map +1 -0
- package/dist/src/commands/init/targets/claude.d.ts +4 -0
- package/dist/src/commands/init/targets/claude.js +178 -0
- package/dist/src/commands/init/targets/claude.js.map +1 -0
- package/dist/src/commands/init/targets/codex.d.ts +4 -0
- package/dist/src/commands/init/targets/codex.js +75 -0
- package/dist/src/commands/init/targets/codex.js.map +1 -0
- package/dist/src/commands/init/targets/driver.d.ts +28 -0
- package/dist/src/commands/init/targets/driver.js +2 -0
- package/dist/src/commands/init/targets/driver.js.map +1 -0
- package/dist/src/commands/init/targets/opencode.d.ts +4 -0
- package/dist/src/commands/init/targets/opencode.js +77 -0
- package/dist/src/commands/init/targets/opencode.js.map +1 -0
- package/dist/src/commands/init/targets/registry.d.ts +4 -0
- package/dist/src/commands/init/targets/registry.js +15 -0
- package/dist/src/commands/init/targets/registry.js.map +1 -0
- package/dist/src/commands/init/types.d.ts +30 -0
- package/dist/src/commands/init/types.js +7 -0
- package/dist/src/commands/init/types.js.map +1 -0
- package/dist/src/commands/init.d.ts +3 -0
- package/dist/src/commands/init.js +143 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/keys/command.d.ts +2 -0
- package/dist/src/commands/keys/command.js +154 -0
- package/dist/src/commands/keys/command.js.map +1 -0
- package/dist/src/commands/labels/create.d.ts +2 -0
- package/dist/src/commands/labels/create.js +31 -0
- package/dist/src/commands/labels/create.js.map +1 -0
- package/dist/src/commands/labels/delete.d.ts +2 -0
- package/dist/src/commands/labels/delete.js +51 -0
- package/dist/src/commands/labels/delete.js.map +1 -0
- package/dist/src/commands/labels/formatters.d.ts +4 -0
- package/dist/src/commands/labels/formatters.js +6 -0
- package/dist/src/commands/labels/formatters.js.map +1 -0
- package/dist/src/commands/labels/index.d.ts +2 -0
- package/dist/src/commands/labels/index.js +13 -0
- package/dist/src/commands/labels/index.js.map +1 -0
- package/dist/src/commands/labels/list.d.ts +2 -0
- package/dist/src/commands/labels/list.js +29 -0
- package/dist/src/commands/labels/list.js.map +1 -0
- package/dist/src/commands/labels/resolve.d.ts +9 -0
- package/dist/src/commands/labels/resolve.js +23 -0
- package/dist/src/commands/labels/resolve.js.map +1 -0
- package/dist/src/commands/labels/update.d.ts +2 -0
- package/dist/src/commands/labels/update.js +37 -0
- package/dist/src/commands/labels/update.js.map +1 -0
- package/dist/src/commands/lists/constants.d.ts +7 -0
- package/dist/src/commands/lists/constants.js +14 -0
- package/dist/src/commands/lists/constants.js.map +1 -0
- package/dist/src/commands/lists/create.d.ts +2 -0
- package/dist/src/commands/lists/create.js +45 -0
- package/dist/src/commands/lists/create.js.map +1 -0
- package/dist/src/commands/lists/index.d.ts +2 -0
- package/dist/src/commands/lists/index.js +10 -0
- package/dist/src/commands/lists/index.js.map +1 -0
- package/dist/src/commands/lists/list.d.ts +2 -0
- package/dist/src/commands/lists/list.js +66 -0
- package/dist/src/commands/lists/list.js.map +1 -0
- package/dist/src/commands/lists/resolve.d.ts +11 -0
- package/dist/src/commands/lists/resolve.js +24 -0
- package/dist/src/commands/lists/resolve.js.map +1 -0
- package/dist/src/commands/lists/update.d.ts +2 -0
- package/dist/src/commands/lists/update.js +61 -0
- package/dist/src/commands/lists/update.js.map +1 -0
- package/dist/src/commands/login/command.d.ts +8 -0
- package/dist/src/commands/login/command.js +20 -0
- package/dist/src/commands/login/command.js.map +1 -0
- package/dist/src/commands/orgs/index.d.ts +2 -0
- package/dist/src/commands/orgs/index.js +6 -0
- package/dist/src/commands/orgs/index.js.map +1 -0
- package/dist/src/commands/orgs/list.d.ts +2 -0
- package/dist/src/commands/orgs/list.js +29 -0
- package/dist/src/commands/orgs/list.js.map +1 -0
- package/dist/src/commands/paths/command.d.ts +2 -0
- package/dist/src/commands/paths/command.js +90 -0
- package/dist/src/commands/paths/command.js.map +1 -0
- package/dist/src/commands/profiles/index.d.ts +2 -0
- package/dist/src/commands/profiles/index.js +6 -0
- package/dist/src/commands/profiles/index.js.map +1 -0
- package/dist/src/commands/profiles/list.d.ts +2 -0
- package/dist/src/commands/profiles/list.js +50 -0
- package/dist/src/commands/profiles/list.js.map +1 -0
- package/dist/src/commands/project-agents/create.d.ts +2 -0
- package/dist/src/commands/project-agents/create.js +53 -0
- package/dist/src/commands/project-agents/create.js.map +1 -0
- package/dist/src/commands/project-agents/index.d.ts +2 -0
- package/dist/src/commands/project-agents/index.js +10 -0
- package/dist/src/commands/project-agents/index.js.map +1 -0
- package/dist/src/commands/project-agents/list.d.ts +2 -0
- package/dist/src/commands/project-agents/list.js +30 -0
- package/dist/src/commands/project-agents/list.js.map +1 -0
- package/dist/src/commands/project-agents/parsers.d.ts +16 -0
- package/dist/src/commands/project-agents/parsers.js +80 -0
- package/dist/src/commands/project-agents/parsers.js.map +1 -0
- package/dist/src/commands/project-agents/update.d.ts +2 -0
- package/dist/src/commands/project-agents/update.js +74 -0
- package/dist/src/commands/project-agents/update.js.map +1 -0
- package/dist/src/commands/projects/index.d.ts +2 -0
- package/dist/src/commands/projects/index.js +6 -0
- package/dist/src/commands/projects/index.js.map +1 -0
- package/dist/src/commands/projects/list.d.ts +2 -0
- package/dist/src/commands/projects/list.js +41 -0
- package/dist/src/commands/projects/list.js.map +1 -0
- package/dist/src/commands/prompts/create.d.ts +2 -0
- package/dist/src/commands/prompts/create.js +48 -0
- package/dist/src/commands/prompts/create.js.map +1 -0
- package/dist/src/commands/prompts/formatters.d.ts +4 -0
- package/dist/src/commands/prompts/formatters.js +7 -0
- package/dist/src/commands/prompts/formatters.js.map +1 -0
- package/dist/src/commands/prompts/index.d.ts +2 -0
- package/dist/src/commands/prompts/index.js +11 -0
- package/dist/src/commands/prompts/index.js.map +1 -0
- package/dist/src/commands/prompts/list.d.ts +2 -0
- package/dist/src/commands/prompts/list.js +34 -0
- package/dist/src/commands/prompts/list.js.map +1 -0
- package/dist/src/commands/prompts/parsers.d.ts +9 -0
- package/dist/src/commands/prompts/parsers.js +12 -0
- package/dist/src/commands/prompts/parsers.js.map +1 -0
- package/dist/src/commands/prompts/resolve.d.ts +17 -0
- package/dist/src/commands/prompts/resolve.js +43 -0
- package/dist/src/commands/prompts/resolve.js.map +1 -0
- package/dist/src/commands/prompts/update.d.ts +2 -0
- package/dist/src/commands/prompts/update.js +58 -0
- package/dist/src/commands/prompts/update.js.map +1 -0
- package/dist/src/commands/setup/command.d.ts +2 -0
- package/dist/src/commands/setup/command.js +15 -0
- package/dist/src/commands/setup/command.js.map +1 -0
- package/dist/src/commands/setup/prompts.d.ts +66 -0
- package/dist/src/commands/setup/prompts.js +199 -0
- package/dist/src/commands/setup/prompts.js.map +1 -0
- package/dist/src/commands/setup/workflow.d.ts +17 -0
- package/dist/src/commands/setup/workflow.js +141 -0
- package/dist/src/commands/setup/workflow.js.map +1 -0
- package/dist/src/commands/status/command.d.ts +2 -0
- package/dist/src/commands/status/command.js +83 -0
- package/dist/src/commands/status/command.js.map +1 -0
- package/dist/src/commands/task-types/index.d.ts +2 -0
- package/dist/src/commands/task-types/index.js +6 -0
- package/dist/src/commands/task-types/index.js.map +1 -0
- package/dist/src/commands/task-types/list.d.ts +2 -0
- package/dist/src/commands/task-types/list.js +32 -0
- package/dist/src/commands/task-types/list.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/comments/add.d.ts +2 -0
- package/dist/src/commands/tasks/artifacts/comments/add.js +32 -0
- package/dist/src/commands/tasks/artifacts/comments/add.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/comments/formatters.d.ts +7 -0
- package/dist/src/commands/tasks/artifacts/comments/formatters.js +32 -0
- package/dist/src/commands/tasks/artifacts/comments/formatters.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/comments/index.d.ts +2 -0
- package/dist/src/commands/tasks/artifacts/comments/index.js +13 -0
- package/dist/src/commands/tasks/artifacts/comments/index.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/comments/list.d.ts +2 -0
- package/dist/src/commands/tasks/artifacts/comments/list.js +24 -0
- package/dist/src/commands/tasks/artifacts/comments/list.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/comments/parsers.d.ts +6 -0
- package/dist/src/commands/tasks/artifacts/comments/parsers.js +8 -0
- package/dist/src/commands/tasks/artifacts/comments/parsers.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/comments/reply.d.ts +2 -0
- package/dist/src/commands/tasks/artifacts/comments/reply.js +23 -0
- package/dist/src/commands/tasks/artifacts/comments/reply.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/comments/resolve.d.ts +3 -0
- package/dist/src/commands/tasks/artifacts/comments/resolve.js +26 -0
- package/dist/src/commands/tasks/artifacts/comments/resolve.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/create.d.ts +2 -0
- package/dist/src/commands/tasks/artifacts/create.js +63 -0
- package/dist/src/commands/tasks/artifacts/create.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/delete.d.ts +2 -0
- package/dist/src/commands/tasks/artifacts/delete.js +27 -0
- package/dist/src/commands/tasks/artifacts/delete.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/get.d.ts +2 -0
- package/dist/src/commands/tasks/artifacts/get.js +54 -0
- package/dist/src/commands/tasks/artifacts/get.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/index.d.ts +2 -0
- package/dist/src/commands/tasks/artifacts/index.js +18 -0
- package/dist/src/commands/tasks/artifacts/index.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/list.d.ts +2 -0
- package/dist/src/commands/tasks/artifacts/list.js +31 -0
- package/dist/src/commands/tasks/artifacts/list.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/parsers.d.ts +13 -0
- package/dist/src/commands/tasks/artifacts/parsers.js +24 -0
- package/dist/src/commands/tasks/artifacts/parsers.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/replace.d.ts +2 -0
- package/dist/src/commands/tasks/artifacts/replace.js +62 -0
- package/dist/src/commands/tasks/artifacts/replace.js.map +1 -0
- package/dist/src/commands/tasks/artifacts/update.d.ts +2 -0
- package/dist/src/commands/tasks/artifacts/update.js +55 -0
- package/dist/src/commands/tasks/artifacts/update.js.map +1 -0
- package/dist/src/commands/tasks/attach.d.ts +2 -0
- package/dist/src/commands/tasks/attach.js +70 -0
- package/dist/src/commands/tasks/attach.js.map +1 -0
- package/dist/src/commands/tasks/attachments/delete.d.ts +2 -0
- package/dist/src/commands/tasks/attachments/delete.js +61 -0
- package/dist/src/commands/tasks/attachments/delete.js.map +1 -0
- package/dist/src/commands/tasks/attachments/download.d.ts +2 -0
- package/dist/src/commands/tasks/attachments/download.js +42 -0
- package/dist/src/commands/tasks/attachments/download.js.map +1 -0
- package/dist/src/commands/tasks/attachments/formatters.d.ts +5 -0
- package/dist/src/commands/tasks/attachments/formatters.js +18 -0
- package/dist/src/commands/tasks/attachments/formatters.js.map +1 -0
- package/dist/src/commands/tasks/attachments/index.d.ts +2 -0
- package/dist/src/commands/tasks/attachments/index.js +11 -0
- package/dist/src/commands/tasks/attachments/index.js.map +1 -0
- package/dist/src/commands/tasks/attachments/list.d.ts +2 -0
- package/dist/src/commands/tasks/attachments/list.js +36 -0
- package/dist/src/commands/tasks/attachments/list.js.map +1 -0
- package/dist/src/commands/tasks/attachments/resolve.d.ts +6 -0
- package/dist/src/commands/tasks/attachments/resolve.js +15 -0
- package/dist/src/commands/tasks/attachments/resolve.js.map +1 -0
- package/dist/src/commands/tasks/attachments/transfer.d.ts +11 -0
- package/dist/src/commands/tasks/attachments/transfer.js +71 -0
- package/dist/src/commands/tasks/attachments/transfer.js.map +1 -0
- package/dist/src/commands/tasks/comments/add.d.ts +2 -0
- package/dist/src/commands/tasks/comments/add.js +44 -0
- package/dist/src/commands/tasks/comments/add.js.map +1 -0
- package/dist/src/commands/tasks/comments/index.d.ts +2 -0
- package/dist/src/commands/tasks/comments/index.js +6 -0
- package/dist/src/commands/tasks/comments/index.js.map +1 -0
- package/dist/src/commands/tasks/create.d.ts +2 -0
- package/dist/src/commands/tasks/create.js +77 -0
- package/dist/src/commands/tasks/create.js.map +1 -0
- package/dist/src/commands/tasks/delete.d.ts +2 -0
- package/dist/src/commands/tasks/delete.js +31 -0
- package/dist/src/commands/tasks/delete.js.map +1 -0
- package/dist/src/commands/tasks/formatters.d.ts +25 -0
- package/dist/src/commands/tasks/formatters.js +40 -0
- package/dist/src/commands/tasks/formatters.js.map +1 -0
- package/dist/src/commands/tasks/get.d.ts +2 -0
- package/dist/src/commands/tasks/get.js +94 -0
- package/dist/src/commands/tasks/get.js.map +1 -0
- package/dist/src/commands/tasks/hydrate.d.ts +20 -0
- package/dist/src/commands/tasks/hydrate.js +47 -0
- package/dist/src/commands/tasks/hydrate.js.map +1 -0
- package/dist/src/commands/tasks/index.d.ts +2 -0
- package/dist/src/commands/tasks/index.js +33 -0
- package/dist/src/commands/tasks/index.js.map +1 -0
- package/dist/src/commands/tasks/links.d.ts +4 -0
- package/dist/src/commands/tasks/links.js +121 -0
- package/dist/src/commands/tasks/links.js.map +1 -0
- package/dist/src/commands/tasks/list.d.ts +2 -0
- package/dist/src/commands/tasks/list.js +47 -0
- package/dist/src/commands/tasks/list.js.map +1 -0
- package/dist/src/commands/tasks/move-to-list.d.ts +2 -0
- package/dist/src/commands/tasks/move-to-list.js +41 -0
- package/dist/src/commands/tasks/move-to-list.js.map +1 -0
- package/dist/src/commands/tasks/move.d.ts +2 -0
- package/dist/src/commands/tasks/move.js +61 -0
- package/dist/src/commands/tasks/move.js.map +1 -0
- package/dist/src/commands/tasks/parsers.d.ts +22 -0
- package/dist/src/commands/tasks/parsers.js +118 -0
- package/dist/src/commands/tasks/parsers.js.map +1 -0
- package/dist/src/commands/tasks/refs.d.ts +2 -0
- package/dist/src/commands/tasks/refs.js +89 -0
- package/dist/src/commands/tasks/refs.js.map +1 -0
- package/dist/src/commands/tasks/resolve.d.ts +20 -0
- package/dist/src/commands/tasks/resolve.js +57 -0
- package/dist/src/commands/tasks/resolve.js.map +1 -0
- package/dist/src/commands/tasks/search.d.ts +2 -0
- package/dist/src/commands/tasks/search.js +110 -0
- package/dist/src/commands/tasks/search.js.map +1 -0
- package/dist/src/commands/tasks/update.d.ts +2 -0
- package/dist/src/commands/tasks/update.js +101 -0
- package/dist/src/commands/tasks/update.js.map +1 -0
- package/dist/src/commands/test-helpers.d.ts +2 -0
- package/dist/src/commands/test-helpers.js +6 -0
- package/dist/src/commands/test-helpers.js.map +1 -0
- package/dist/src/commands/threads/create.d.ts +2 -0
- package/dist/src/commands/threads/create.js +99 -0
- package/dist/src/commands/threads/create.js.map +1 -0
- package/dist/src/commands/threads/formatters.d.ts +10 -0
- package/dist/src/commands/threads/formatters.js +17 -0
- package/dist/src/commands/threads/formatters.js.map +1 -0
- package/dist/src/commands/threads/get.d.ts +2 -0
- package/dist/src/commands/threads/get.js +53 -0
- package/dist/src/commands/threads/get.js.map +1 -0
- package/dist/src/commands/threads/index.d.ts +2 -0
- package/dist/src/commands/threads/index.js +14 -0
- package/dist/src/commands/threads/index.js.map +1 -0
- package/dist/src/commands/threads/list.d.ts +2 -0
- package/dist/src/commands/threads/list.js +69 -0
- package/dist/src/commands/threads/list.js.map +1 -0
- package/dist/src/commands/threads/messages.d.ts +2 -0
- package/dist/src/commands/threads/messages.js +59 -0
- package/dist/src/commands/threads/messages.js.map +1 -0
- package/dist/src/commands/threads/parsers.d.ts +5 -0
- package/dist/src/commands/threads/parsers.js +19 -0
- package/dist/src/commands/threads/parsers.js.map +1 -0
- package/dist/src/commands/threads/send.d.ts +2 -0
- package/dist/src/commands/threads/send.js +49 -0
- package/dist/src/commands/threads/send.js.map +1 -0
- package/dist/src/commands/threads/spawn-target.d.ts +29 -0
- package/dist/src/commands/threads/spawn-target.js +62 -0
- package/dist/src/commands/threads/spawn-target.js.map +1 -0
- package/dist/src/convex/_generated/ai/ai-files.state.json +6 -0
- package/dist/src/convex/_generated/ai/guidelines.md +371 -0
- package/dist/src/convex/_generated/api.d.ts +598 -0
- package/dist/src/convex/_generated/api.js +23 -0
- package/dist/src/convex/_generated/dataModel.d.ts +60 -0
- package/dist/src/convex/_generated/server.d.ts +143 -0
- package/dist/src/convex/_generated/server.js +93 -0
- package/dist/src/lib/argv.d.ts +1 -0
- package/dist/src/lib/argv.js +7 -0
- package/dist/src/lib/argv.js.map +1 -0
- package/dist/src/lib/browser-login.d.ts +43 -0
- package/dist/src/lib/browser-login.js +216 -0
- package/dist/src/lib/browser-login.js.map +1 -0
- package/dist/src/lib/config/convex-client.d.ts +41 -0
- package/dist/src/lib/config/convex-client.js +53 -0
- package/dist/src/lib/config/convex-client.js.map +1 -0
- package/dist/src/lib/config/index.d.ts +7 -0
- package/dist/src/lib/config/index.js +13 -0
- package/dist/src/lib/config/index.js.map +1 -0
- package/dist/src/lib/config/profile.d.ts +40 -0
- package/dist/src/lib/config/profile.js +155 -0
- package/dist/src/lib/config/profile.js.map +1 -0
- package/dist/src/lib/config/provider-keys.d.ts +47 -0
- package/dist/src/lib/config/provider-keys.js +97 -0
- package/dist/src/lib/config/provider-keys.js.map +1 -0
- package/dist/src/lib/config/toml.d.ts +78 -0
- package/dist/src/lib/config/toml.js +228 -0
- package/dist/src/lib/config/toml.js.map +1 -0
- package/dist/src/lib/config/types.d.ts +98 -0
- package/dist/src/lib/config/types.js +65 -0
- package/dist/src/lib/config/types.js.map +1 -0
- package/dist/src/lib/config/validate.d.ts +30 -0
- package/dist/src/lib/config/validate.js +66 -0
- package/dist/src/lib/config/validate.js.map +1 -0
- package/dist/src/lib/connect-events.d.ts +42 -0
- package/dist/src/lib/connect-events.js +65 -0
- package/dist/src/lib/connect-events.js.map +1 -0
- package/dist/src/lib/constants.d.ts +20 -0
- package/dist/src/lib/constants.js +27 -0
- package/dist/src/lib/constants.js.map +1 -0
- package/dist/src/lib/content-type.d.ts +1 -0
- package/dist/src/lib/content-type.js +27 -0
- package/dist/src/lib/content-type.js.map +1 -0
- package/dist/src/lib/convex-error.d.ts +12 -0
- package/dist/src/lib/convex-error.js +33 -0
- package/dist/src/lib/convex-error.js.map +1 -0
- package/dist/src/lib/git/checkpoint.d.ts +74 -0
- package/dist/src/lib/git/checkpoint.js +210 -0
- package/dist/src/lib/git/checkpoint.js.map +1 -0
- package/dist/src/lib/git/exec.d.ts +23 -0
- package/dist/src/lib/git/exec.js +46 -0
- package/dist/src/lib/git/exec.js.map +1 -0
- package/dist/src/lib/git/file-index.d.ts +8 -0
- package/dist/src/lib/git/file-index.js +125 -0
- package/dist/src/lib/git/file-index.js.map +1 -0
- package/dist/src/lib/git/index.d.ts +5 -0
- package/dist/src/lib/git/index.js +6 -0
- package/dist/src/lib/git/index.js.map +1 -0
- package/dist/src/lib/git/repo.d.ts +32 -0
- package/dist/src/lib/git/repo.js +95 -0
- package/dist/src/lib/git/repo.js.map +1 -0
- package/dist/src/lib/git/worktrees.d.ts +49 -0
- package/dist/src/lib/git/worktrees.js +97 -0
- package/dist/src/lib/git/worktrees.js.map +1 -0
- package/dist/src/lib/global-options.d.ts +3 -0
- package/dist/src/lib/global-options.js +8 -0
- package/dist/src/lib/global-options.js.map +1 -0
- package/dist/src/lib/id.d.ts +3 -0
- package/dist/src/lib/id.js +14 -0
- package/dist/src/lib/id.js.map +1 -0
- package/dist/src/lib/one-shot-command.d.ts +7 -0
- package/dist/src/lib/one-shot-command.js +30 -0
- package/dist/src/lib/one-shot-command.js.map +1 -0
- package/dist/src/lib/one-shot-config.d.ts +3 -0
- package/dist/src/lib/one-shot-config.js +7 -0
- package/dist/src/lib/one-shot-config.js.map +1 -0
- package/dist/src/lib/output.d.ts +10 -0
- package/dist/src/lib/output.js +27 -0
- package/dist/src/lib/output.js.map +1 -0
- package/dist/src/lib/pagination.d.ts +16 -0
- package/dist/src/lib/pagination.js +45 -0
- package/dist/src/lib/pagination.js.map +1 -0
- package/dist/src/lib/parsers.d.ts +2 -0
- package/dist/src/lib/parsers.js +21 -0
- package/dist/src/lib/parsers.js.map +1 -0
- package/dist/src/lib/project-resolution.d.ts +41 -0
- package/dist/src/lib/project-resolution.js +84 -0
- package/dist/src/lib/project-resolution.js.map +1 -0
- package/dist/src/lib/pull-requests.d.ts +47 -0
- package/dist/src/lib/pull-requests.js +305 -0
- package/dist/src/lib/pull-requests.js.map +1 -0
- package/dist/src/lib/skill-install-guidance.d.ts +5 -0
- package/dist/src/lib/skill-install-guidance.js +41 -0
- package/dist/src/lib/skill-install-guidance.js.map +1 -0
- package/dist/src/lib/text-input.d.ts +18 -0
- package/dist/src/lib/text-input.js +36 -0
- package/dist/src/lib/text-input.js.map +1 -0
- package/dist/src/lib/thread-attachments.d.ts +21 -0
- package/dist/src/lib/thread-attachments.js +104 -0
- package/dist/src/lib/thread-attachments.js.map +1 -0
- package/dist/src/lib/url.d.ts +13 -0
- package/dist/src/lib/url.js +25 -0
- package/dist/src/lib/url.js.map +1 -0
- package/dist/src/lib/version.d.ts +2 -0
- package/dist/src/lib/version.js +33 -0
- package/dist/src/lib/version.js.map +1 -0
- package/dist/templates/devcontainer/Dockerfile +95 -0
- package/dist/templates/devcontainer/README.md +129 -0
- package/dist/templates/devcontainer/devcontainer.json +92 -0
- package/dist/templates/devcontainer/init-firewall.sh +271 -0
- package/package.json +79 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createInterface } from "node:readline";
|
|
3
|
+
import { resolveExecutable } from "../../sdk/adapters/executable-resolution.js";
|
|
4
|
+
import { isRecord } from "../../sdk/adapters/adapter-interface.js";
|
|
5
|
+
import { RunnerExecutionError, } from "../contracts.js";
|
|
6
|
+
import { withFirstMessageAgentInstructions } from "../agent-instructions.js";
|
|
7
|
+
import { getDebugLevel } from "../debug.js";
|
|
8
|
+
import { ENV_THREAD_ID } from "../../../lib/constants.js";
|
|
9
|
+
import { discoverCursorCommands } from "./commands.js";
|
|
10
|
+
import { supportsTrustFlag } from "./detect.js";
|
|
11
|
+
import { resolveCursorModelName } from "./models.js";
|
|
12
|
+
/** Env var override for the cursor-agent executable path. */
|
|
13
|
+
export const CURSOR_EXECUTABLE_ENV = "OPENSANA_CURSOR_EXECUTABLE";
|
|
14
|
+
/** cursor-agent's stderr line when the machine is not logged in. */
|
|
15
|
+
const CURSOR_AUTH_REQUIRED_MARKER = "Authentication required";
|
|
16
|
+
/** No JSONL output for this long mid-run fails the run. */
|
|
17
|
+
const IDLE_TIMEOUT_MS = 600_000;
|
|
18
|
+
const IDLE_CHECK_INTERVAL_MS = 30_000;
|
|
19
|
+
const ABORT_FORCE_KILL_MS = 5_000;
|
|
20
|
+
/**
|
|
21
|
+
* Build the `cursor-agent` argument list. Print mode is non-interactive and has no
|
|
22
|
+
* sandbox; the only permission knob is `--force`:
|
|
23
|
+
* - `agent` (and unset) auto-allows everything (`--force`)
|
|
24
|
+
* - every other mode follows the machine's Cursor permission config, with `--trust` when
|
|
25
|
+
* the installed binary supports it (newer builds require it non-interactively).
|
|
26
|
+
*/
|
|
27
|
+
export function buildCursorAgentArgs(options) {
|
|
28
|
+
const args = ["-p", "--output-format=stream-json"];
|
|
29
|
+
if (options.cliMode === undefined || options.cliMode === "agent") {
|
|
30
|
+
args.push("--force");
|
|
31
|
+
}
|
|
32
|
+
else if (options.trustFlagSupported) {
|
|
33
|
+
args.push("--trust");
|
|
34
|
+
}
|
|
35
|
+
if (options.runModel) {
|
|
36
|
+
args.push("--model", resolveCursorModelName(options.runModel, options.runEffort));
|
|
37
|
+
}
|
|
38
|
+
if (options.continuationId) {
|
|
39
|
+
args.push("--resume", options.continuationId);
|
|
40
|
+
}
|
|
41
|
+
return args;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Chat id from a parsed stream event. `system` is skipped deliberately: it
|
|
45
|
+
* can fire before the session is initialized, so its `session_id` may be
|
|
46
|
+
* missing or stale (matches the web normalizer's continuation rule).
|
|
47
|
+
*/
|
|
48
|
+
export function extractCursorSessionId(value) {
|
|
49
|
+
if (!isRecord(value) || value.type === "system") {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return typeof value.session_id === "string" && value.session_id.length > 0
|
|
53
|
+
? value.session_id
|
|
54
|
+
: null;
|
|
55
|
+
}
|
|
56
|
+
export async function resolveCursorExecutablePath() {
|
|
57
|
+
const configured = process.env[CURSOR_EXECUTABLE_ENV]?.trim();
|
|
58
|
+
return resolveExecutable("cursor", {
|
|
59
|
+
...(configured ? { executablePath: configured } : {}),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
export function buildCursorSubprocessEnv(threadId) {
|
|
63
|
+
const env = { ...process.env };
|
|
64
|
+
// The API key must never leak into the agent subprocess environment.
|
|
65
|
+
delete env.OPENSANA_API_KEY;
|
|
66
|
+
// Thread identity (OS-1223).
|
|
67
|
+
env[ENV_THREAD_ID] = threadId;
|
|
68
|
+
return env;
|
|
69
|
+
}
|
|
70
|
+
const isWindows = process.platform === "win32";
|
|
71
|
+
/**
|
|
72
|
+
* The cursor-agent install wraps a native binary in a launcher; killing only
|
|
73
|
+
* the wrapper (especially with SIGKILL, which it cannot forward) orphans the
|
|
74
|
+
* native process. Signal the whole process group instead.
|
|
75
|
+
*/
|
|
76
|
+
export function killCursorProcess(child, signal) {
|
|
77
|
+
if (!isWindows && typeof child.pid === "number") {
|
|
78
|
+
try {
|
|
79
|
+
process.kill(-child.pid, signal);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// Group may already be gone; fall through to a direct kill.
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
child.kill(signal);
|
|
87
|
+
}
|
|
88
|
+
function debugLog(kind, payload) {
|
|
89
|
+
if (getDebugLevel() < 1) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
console.log(`[Cursor:${kind}] ${payload.slice(0, 400)}`);
|
|
93
|
+
}
|
|
94
|
+
function formatErrorTail(errorTail) {
|
|
95
|
+
return errorTail.length > 0 ? ` Output: ${errorTail.join(" | ")}` : "";
|
|
96
|
+
}
|
|
97
|
+
function isAuthRequired(errorTail) {
|
|
98
|
+
return errorTail.some((line) => line.includes(CURSOR_AUTH_REQUIRED_MARKER));
|
|
99
|
+
}
|
|
100
|
+
export function createCursorRunner() {
|
|
101
|
+
let activeChild = null;
|
|
102
|
+
let aborted = false;
|
|
103
|
+
let forceKillTimer = null;
|
|
104
|
+
// The processor may abandon the generator mid-yield after an unrelated
|
|
105
|
+
// error, so abort() must also run the per-run cleanup (watchdog, reader)
|
|
106
|
+
// that the generator's own finally would otherwise handle.
|
|
107
|
+
let cleanupActiveRun = null;
|
|
108
|
+
const abort = () => {
|
|
109
|
+
aborted = true;
|
|
110
|
+
cleanupActiveRun?.();
|
|
111
|
+
const child = activeChild;
|
|
112
|
+
if (!child || child.exitCode !== null || child.signalCode !== null) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
killCursorProcess(child, "SIGTERM");
|
|
116
|
+
forceKillTimer = setTimeout(() => {
|
|
117
|
+
killCursorProcess(child, "SIGKILL");
|
|
118
|
+
}, ABORT_FORCE_KILL_MS);
|
|
119
|
+
forceKillTimer.unref?.();
|
|
120
|
+
};
|
|
121
|
+
return {
|
|
122
|
+
async *execute(workingDirectory, prompt, options) {
|
|
123
|
+
aborted = false;
|
|
124
|
+
const executable = await resolveCursorExecutablePath();
|
|
125
|
+
// Only guarded modes use --trust, so skip the --help probe otherwise.
|
|
126
|
+
const isForceMode = options.cliMode === undefined || options.cliMode === "agent";
|
|
127
|
+
const args = buildCursorAgentArgs({
|
|
128
|
+
cliMode: options.cliMode,
|
|
129
|
+
runModel: options.resolvedCliModel,
|
|
130
|
+
runEffort: options.resolvedCliEffort,
|
|
131
|
+
continuationId: options.continuationId,
|
|
132
|
+
trustFlagSupported: isForceMode ? false : await supportsTrustFlag(),
|
|
133
|
+
});
|
|
134
|
+
debugLog("spawn", `${executable.command} ${args.join(" ")}`);
|
|
135
|
+
// Advertise the directory's slash-command inventory so the web
|
|
136
|
+
// composer can autocomplete them (fail-soft; empty list is skipped).
|
|
137
|
+
const commands = await discoverCursorCommands(workingDirectory);
|
|
138
|
+
if (commands.length > 0) {
|
|
139
|
+
yield {
|
|
140
|
+
type: "opensana.commands",
|
|
141
|
+
data: JSON.stringify({ commands }),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const child = spawn(executable.command, args, {
|
|
145
|
+
cwd: workingDirectory,
|
|
146
|
+
env: buildCursorSubprocessEnv(options.threadId),
|
|
147
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
148
|
+
// Own process group so aborts can kill the wrapper and the native
|
|
149
|
+
// binary together (see killCursorProcess).
|
|
150
|
+
detached: !isWindows,
|
|
151
|
+
});
|
|
152
|
+
activeChild = child;
|
|
153
|
+
// Cursor reports some fatal errors as plain text on STDOUT (e.g.
|
|
154
|
+
// "ActionRequiredError: Named models unavailable...") with an empty
|
|
155
|
+
// stderr, so non-JSON stdout lines feed the same error tail.
|
|
156
|
+
const errorTail = [];
|
|
157
|
+
const pushErrorTail = (line) => {
|
|
158
|
+
errorTail.push(line);
|
|
159
|
+
if (errorTail.length > 12) {
|
|
160
|
+
errorTail.shift();
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
if (child.stderr) {
|
|
164
|
+
createInterface({ input: child.stderr }).on("line", (line) => {
|
|
165
|
+
const trimmed = line.trim();
|
|
166
|
+
if (!trimmed) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
debugLog("stderr", trimmed);
|
|
170
|
+
pushErrorTail(trimmed);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
let spawnError = null;
|
|
174
|
+
const exitPromise = new Promise((resolve) => {
|
|
175
|
+
child.once("error", (error) => {
|
|
176
|
+
spawnError = error;
|
|
177
|
+
resolve({ code: null, signal: null });
|
|
178
|
+
});
|
|
179
|
+
child.once("close", (code, signal) => resolve({ code, signal }));
|
|
180
|
+
});
|
|
181
|
+
// EPIPE guard: cursor-agent may exit before consuming the whole prompt.
|
|
182
|
+
child.stdin?.on("error", () => { });
|
|
183
|
+
// First-message agent prompt delivery: fresh sessions only (print mode
|
|
184
|
+
// has no system-prompt flag; rules files would mutate the checkout).
|
|
185
|
+
child.stdin?.end(withFirstMessageAgentInstructions(prompt, options));
|
|
186
|
+
let continuationId = options.continuationId;
|
|
187
|
+
let lastOutputAt = Date.now();
|
|
188
|
+
let idleTimedOut = false;
|
|
189
|
+
const idleWatchdog = setInterval(() => {
|
|
190
|
+
if (Date.now() - lastOutputAt > IDLE_TIMEOUT_MS) {
|
|
191
|
+
idleTimedOut = true;
|
|
192
|
+
killCursorProcess(child, "SIGKILL");
|
|
193
|
+
}
|
|
194
|
+
}, IDLE_CHECK_INTERVAL_MS);
|
|
195
|
+
idleWatchdog.unref?.();
|
|
196
|
+
const stdoutLines = child.stdout
|
|
197
|
+
? createInterface({ input: child.stdout })
|
|
198
|
+
: null;
|
|
199
|
+
const cleanupRun = () => {
|
|
200
|
+
clearInterval(idleWatchdog);
|
|
201
|
+
stdoutLines?.close();
|
|
202
|
+
if (cleanupActiveRun === cleanupRun) {
|
|
203
|
+
cleanupActiveRun = null;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
cleanupActiveRun = cleanupRun;
|
|
207
|
+
try {
|
|
208
|
+
if (stdoutLines) {
|
|
209
|
+
for await (const line of stdoutLines) {
|
|
210
|
+
lastOutputAt = Date.now();
|
|
211
|
+
const trimmed = line.trim();
|
|
212
|
+
if (!trimmed) {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
let parsed;
|
|
216
|
+
try {
|
|
217
|
+
parsed = JSON.parse(trimmed);
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
// Plain lines are dropped from the stream but kept for the
|
|
221
|
+
// error tail — fatal errors can arrive here (see above).
|
|
222
|
+
debugLog("skip", trimmed);
|
|
223
|
+
pushErrorTail(trimmed);
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
const type = isRecord(parsed) && typeof parsed.type === "string"
|
|
227
|
+
? parsed.type
|
|
228
|
+
: "unknown";
|
|
229
|
+
const sessionId = extractCursorSessionId(parsed);
|
|
230
|
+
if (sessionId) {
|
|
231
|
+
continuationId = sessionId;
|
|
232
|
+
}
|
|
233
|
+
debugLog(type, trimmed);
|
|
234
|
+
yield { type, data: trimmed };
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const exit = await exitPromise;
|
|
238
|
+
if (spawnError) {
|
|
239
|
+
const message = spawnError.message;
|
|
240
|
+
throw new RunnerExecutionError(`Failed to run cursor-agent: ${message}`, { continuationId });
|
|
241
|
+
}
|
|
242
|
+
if (aborted) {
|
|
243
|
+
throw new RunnerExecutionError("Cursor run aborted", {
|
|
244
|
+
continuationId,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
if (idleTimedOut) {
|
|
248
|
+
throw new RunnerExecutionError(`Cursor produced no output for ${Math.round(IDLE_TIMEOUT_MS / 60_000)} minutes and was terminated.`, { continuationId });
|
|
249
|
+
}
|
|
250
|
+
if (exit.code !== 0) {
|
|
251
|
+
if (isAuthRequired(errorTail)) {
|
|
252
|
+
throw new RunnerExecutionError("Cursor Agent is not authenticated on this machine. Run 'cursor-agent login' or set CURSOR_API_KEY.", { continuationId });
|
|
253
|
+
}
|
|
254
|
+
const exitDetail = exit.code !== null
|
|
255
|
+
? `exit code ${exit.code}`
|
|
256
|
+
: `signal ${exit.signal ?? "unknown"}`;
|
|
257
|
+
throw new RunnerExecutionError(`Cursor exited with ${exitDetail}.${formatErrorTail(errorTail)}`, { continuationId });
|
|
258
|
+
}
|
|
259
|
+
if (!continuationId && options.requireContinuation) {
|
|
260
|
+
throw new RunnerExecutionError("Cursor run completed without a session_id in stream-json output");
|
|
261
|
+
}
|
|
262
|
+
return continuationId ? { continuationId } : {};
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
if (error instanceof RunnerExecutionError) {
|
|
266
|
+
if (error.continuationId === undefined && continuationId) {
|
|
267
|
+
error.continuationId = continuationId;
|
|
268
|
+
}
|
|
269
|
+
throw error;
|
|
270
|
+
}
|
|
271
|
+
throw new RunnerExecutionError(error instanceof Error ? error.message : String(error), { continuationId });
|
|
272
|
+
}
|
|
273
|
+
finally {
|
|
274
|
+
cleanupRun();
|
|
275
|
+
if (forceKillTimer) {
|
|
276
|
+
clearTimeout(forceKillTimer);
|
|
277
|
+
forceKillTimer = null;
|
|
278
|
+
}
|
|
279
|
+
if (child.exitCode === null && child.signalCode === null) {
|
|
280
|
+
killCursorProcess(child, "SIGKILL");
|
|
281
|
+
}
|
|
282
|
+
if (activeChild === child) {
|
|
283
|
+
activeChild = null;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
abort,
|
|
288
|
+
async shutdown() {
|
|
289
|
+
abort();
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../../../src/agent/runtimes/cursor/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AACnE,OAAO,EACL,oBAAoB,GAMrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iCAAiC,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,6DAA6D;AAC7D,MAAM,CAAC,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAElE,oEAAoE;AACpE,MAAM,2BAA2B,GAAG,yBAAyB,CAAC;AAE9D,2DAA2D;AAC3D,MAAM,eAAe,GAAG,OAAO,CAAC;AAChC,MAAM,sB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C,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;oBACzD,iBAAiB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;gBACtC,CAAC;gBACD,IAAI,WAAW,KAAK,KAAK,EAAE,CAAC;oBAC1B,WAAW,GAAG,IAAI,CAAC;gBACrB,CAAC;YACH,CAAC;QACH,CAAC;QAED,KAAK;QAEL,KAAK,CAAC,QAAQ;YACZ,KAAK,EAAE,CAAC;QACV,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createSandboxUnsupportedRunner, } from "../contracts.js";
|
|
2
|
+
import { formatUserMessageBlock } from "../message-format.js";
|
|
3
|
+
import { detectCursorAgent } from "./detect.js";
|
|
4
|
+
import { isCursorModelSlot } from "./models.js";
|
|
5
|
+
import { createCursorRunner } from "./runner.js";
|
|
6
|
+
import { cursorChunkStreamPolicy } from "./streaming.js";
|
|
7
|
+
export const cursorRuntime = {
|
|
8
|
+
type: "cursor",
|
|
9
|
+
// Print mode has no system-prompt flag; inject into the first prompt of a
|
|
10
|
+
// fresh runtime session (rules files would mutate the user's checkout).
|
|
11
|
+
agentPromptDelivery: "first-message",
|
|
12
|
+
detectAvailableCli: detectCursorAgent,
|
|
13
|
+
createRunner: (options) =>
|
|
14
|
+
// cursor-agent has no OS sandbox flags: isolation (OS-1242) fails fast.
|
|
15
|
+
options.sandbox ? createSandboxUnsupportedRunner("cursor") : createCursorRunner(),
|
|
16
|
+
normalizeCliModel(model) {
|
|
17
|
+
return isCursorModelSlot(model) ? model : undefined;
|
|
18
|
+
},
|
|
19
|
+
isInlineImageAttachment() {
|
|
20
|
+
return false;
|
|
21
|
+
},
|
|
22
|
+
async prepareBatchExecution(input) {
|
|
23
|
+
// A solo runtime command ("/name args") is delivered raw — no batch
|
|
24
|
+
// envelope — so cursor-agent interprets the slash command natively.
|
|
25
|
+
const [message] = input.messages;
|
|
26
|
+
if (input.messages.length === 1 && message.runtimeCommand === true) {
|
|
27
|
+
return {
|
|
28
|
+
prompt: message.contentText.trim(),
|
|
29
|
+
inputFormat: "prompt",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const formattedMessages = input.messages
|
|
33
|
+
.map((entry, index) => formatUserMessageBlock({
|
|
34
|
+
index,
|
|
35
|
+
message: entry,
|
|
36
|
+
attachments: entry.attachments,
|
|
37
|
+
}))
|
|
38
|
+
.join("\n\n");
|
|
39
|
+
return {
|
|
40
|
+
prompt: ["OpenSana batched user messages:", formattedMessages].join("\n\n"),
|
|
41
|
+
inputFormat: "prompt",
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
getChunkStreamPolicy() {
|
|
45
|
+
return cursorChunkStreamPolicy;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../../../src/agent/runtimes/cursor/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,GAI/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,MAAM,CAAC,MAAM,aAAa,GAAyB;IACjD,IAAI,EAAE,QAAQ;IACd,0EAA0E;IAC1E,wEAAwE;IACxE,mBAAmB,EAAE,eAAe;IACpC,kBAAkB,EAAE,iBAAiB;IACrC,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE;IACxB,wEAAwE;IACxE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,8BAA8B,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE;IACnF,iBAAiB,CAAC,KAAK;QACrB,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IACtD,CAAC;IACD,uBAAuB;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,KAAK,CAAC,qBAAqB,CACzB,KAAiC;QAEjC,oEAAoE;QACpE,oEAAoE;QACpE,MAAM,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC;QACjC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;YACnE,OAAO;gBACL,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE;gBAClC,WAAW,EAAE,QAAQ;aACtB,CAAC;QACJ,CAAC;QAED,MAAM,iBAAiB,GAAG,KAAK,CAAC,QAAQ;aACrC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CACpB,sBAAsB,CAAC;YACrB,KAAK;YACL,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,KAAK,CAAC,WAAW;SAC/B,CAAC,CACH;aACA,IAAI,CAAC,MAAM,CAAC,CAAC;QAEhB,OAAO;YACL,MAAM,EAAE,CAAC,iCAAiC,EAAE,iBAAiB,CAAC,CAAC,IAAI,CACjE,MAAM,CACP;YACD,WAAW,EAAE,QAAQ;SACtB,CAAC;IACJ,CAAC;IACD,oBAAoB;QAClB,OAAO,uBAAuB,CAAC;IACjC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ChunkStreamPolicy } from "../contracts.js";
|
|
2
|
+
/**
|
|
3
|
+
* Flush-buffer policy for cursor-agent streaming: `assistant` and `thinking` arrive as
|
|
4
|
+
* micro-chunks with no final aggregated message, so consecutive same-type chunks merge
|
|
5
|
+
* within a flush window — per-token rows have no rendering value and multiply Convex
|
|
6
|
+
* writes. The web normalizer then emits whole events per chunk.
|
|
7
|
+
*/
|
|
8
|
+
export declare const cursorChunkStreamPolicy: ChunkStreamPolicy;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { isRecord } from "../../sdk/adapters/adapter-interface.js";
|
|
2
|
+
// `text` (2026.07+ builds) shares thinking's flat `{subtype, text}` shape.
|
|
3
|
+
const COALESCIBLE_CHUNK_TYPES = new Set(["assistant", "thinking", "text"]);
|
|
4
|
+
const FLAT_TEXT_CHUNK_TYPES = new Set(["thinking", "text"]);
|
|
5
|
+
function safeJsonParse(data) {
|
|
6
|
+
try {
|
|
7
|
+
return JSON.parse(data);
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function getMessageText(event) {
|
|
14
|
+
const message = event.message;
|
|
15
|
+
if (!isRecord(message) || !Array.isArray(message.content)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const parts = [];
|
|
19
|
+
for (const item of message.content) {
|
|
20
|
+
if (!isRecord(item) || item.type !== "text" || typeof item.text !== "string") {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
parts.push(item.text);
|
|
24
|
+
}
|
|
25
|
+
return parts.join("");
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Flush-buffer policy for cursor-agent streaming: `assistant` and `thinking` arrive as
|
|
29
|
+
* micro-chunks with no final aggregated message, so consecutive same-type chunks merge
|
|
30
|
+
* within a flush window — per-token rows have no rendering value and multiply Convex
|
|
31
|
+
* writes. The web normalizer then emits whole events per chunk.
|
|
32
|
+
*/
|
|
33
|
+
export const cursorChunkStreamPolicy = {
|
|
34
|
+
isDeferrable(chunk) {
|
|
35
|
+
return COALESCIBLE_CHUNK_TYPES.has(chunk.type);
|
|
36
|
+
},
|
|
37
|
+
coalesce(prev, next) {
|
|
38
|
+
if (prev.type !== next.type) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const prevParsed = safeJsonParse(prev.data);
|
|
42
|
+
const nextParsed = safeJsonParse(next.data);
|
|
43
|
+
if (!isRecord(prevParsed) || !isRecord(nextParsed)) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
if (FLAT_TEXT_CHUNK_TYPES.has(prev.type)) {
|
|
47
|
+
if (typeof prevParsed.text !== "string" ||
|
|
48
|
+
typeof nextParsed.text !== "string") {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
type: prev.type,
|
|
53
|
+
data: JSON.stringify({
|
|
54
|
+
...prevParsed,
|
|
55
|
+
text: prevParsed.text + nextParsed.text,
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// assistant: merge the concatenated message text into a single item.
|
|
60
|
+
const prevText = getMessageText(prevParsed);
|
|
61
|
+
const nextText = getMessageText(nextParsed);
|
|
62
|
+
if (prevText === null || nextText === null) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const prevMessage = isRecord(prevParsed.message) ? prevParsed.message : {};
|
|
66
|
+
return {
|
|
67
|
+
type: prev.type,
|
|
68
|
+
data: JSON.stringify({
|
|
69
|
+
...prevParsed,
|
|
70
|
+
message: {
|
|
71
|
+
...prevMessage,
|
|
72
|
+
content: [{ type: "text", text: prevText + nextText }],
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=streaming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["../../../../../src/agent/runtimes/cursor/streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AAGnE,2EAA2E;AAC3E,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,WAA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EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC;iBACvD;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug level from `OPENSANA_CLI_DEBUG`, shared by all runtime runners and
|
|
3
|
+
* the app layer:
|
|
4
|
+
* - unset / invalid → 0 (off)
|
|
5
|
+
* - "1" → 1 (debug, truncated)
|
|
6
|
+
* - "2" → 2 (debug, full / no truncation)
|
|
7
|
+
*/
|
|
8
|
+
export function getDebugLevel() {
|
|
9
|
+
const raw = process.env.OPENSANA_CLI_DEBUG;
|
|
10
|
+
if (!raw) {
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
const parsed = Number.parseInt(raw, 10);
|
|
14
|
+
if (!Number.isFinite(parsed) || parsed < 1) {
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
return parsed;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=debug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../../src/agent/runtimes/debug.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAC3C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACxC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3C,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function formatTaskRefLine(taskRef) {
|
|
2
|
+
if (!taskRef) {
|
|
3
|
+
return null;
|
|
4
|
+
}
|
|
5
|
+
return `task(opensana): ${taskRef}`;
|
|
6
|
+
}
|
|
7
|
+
function formatAttachmentLines(attachments) {
|
|
8
|
+
if (attachments.length === 0) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
return [
|
|
12
|
+
"attachments:",
|
|
13
|
+
...attachments.map((attachment) => `- ${attachment.fileName} (${attachment.contentType}): ${attachment.localPath}`),
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
export function formatUserMessageBlock(args) {
|
|
17
|
+
const { index, message } = args;
|
|
18
|
+
return [
|
|
19
|
+
`--- user-message-${index + 1} ---`,
|
|
20
|
+
`id: ${message.id}`,
|
|
21
|
+
`createdAt: ${new Date(message.createdAt).toISOString()}`,
|
|
22
|
+
message.cliMode ? `mode: ${message.cliMode}` : null,
|
|
23
|
+
formatTaskRefLine(message.taskRef),
|
|
24
|
+
"content:",
|
|
25
|
+
message.contentText || "(empty)",
|
|
26
|
+
...formatAttachmentLines(args.attachments ?? []),
|
|
27
|
+
]
|
|
28
|
+
.filter((line) => typeof line === "string" && line.length > 0)
|
|
29
|
+
.join("\n");
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=message-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-format.js","sourceRoot":"","sources":["../../../../src/agent/runtimes/message-format.ts"],"names":[],"mappings":"AAKA,SAAS,iBAAiB,CAAC,OAA2B;IACpD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,mBAAmB,OAAO,EAAE,CAAC;AACtC,CAAC;AAED,SAAS,qBAAqB,CAC5B,WAAwC;IAExC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO;QACL,cAAc;QACd,GAAG,WAAW,CAAC,GAAG,CAChB,CAAC,UAAU,EAAE,EAAE,CACb,KAAK,UAAU,CAAC,QAAQ,KAAK,UAAU,CAAC,WAAW,MAAM,UAAU,CAAC,SAAS,EAAE,CAClF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,IAItC;IACC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEhC,OAAO;QACL,oBAAoB,KAAK,GAAG,CAAC,MAAM;QACnC,OAAO,OAAO,CAAC,EAAE,EAAE;QACnB,cAAc,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,EAAE;QACzD,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI;QACnD,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC;QAClC,UAAU;QACV,OAAO,CAAC,WAAW,IAAI,SAAS;QAChC,GAAG,qBAAqB,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;KACjD;SACE,MAAM,CACL,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CACtE;SACA,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Narrow boundary over the OpenCode SDK v2 client: the runner (and its
|
|
3
|
+
* tests) depend on this structural interface only, so the SDK import stays
|
|
4
|
+
* confined to this module.
|
|
5
|
+
*/
|
|
6
|
+
export type OpencodePermissionAction = "allow" | "ask" | "deny";
|
|
7
|
+
export type OpencodePermissionRule = {
|
|
8
|
+
permission: string;
|
|
9
|
+
pattern: string;
|
|
10
|
+
action: OpencodePermissionAction;
|
|
11
|
+
};
|
|
12
|
+
export type OpencodeModelRef = {
|
|
13
|
+
providerID: string;
|
|
14
|
+
modelID: string;
|
|
15
|
+
};
|
|
16
|
+
export interface OpencodeClientLike {
|
|
17
|
+
createSession(input: {
|
|
18
|
+
title: string;
|
|
19
|
+
permission: OpencodePermissionRule[];
|
|
20
|
+
}): Promise<{
|
|
21
|
+
id: string;
|
|
22
|
+
}>;
|
|
23
|
+
promptAsync(input: {
|
|
24
|
+
sessionID: string;
|
|
25
|
+
model?: OpencodeModelRef;
|
|
26
|
+
/** OpenCode agent to run (e.g. "plan"); omitted = default agent. */
|
|
27
|
+
agent?: string;
|
|
28
|
+
/** Model variant (provider-specific reasoning effort). */
|
|
29
|
+
variant?: string;
|
|
30
|
+
text: string;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Execute a runtime command in a session (OpenCode expands the template
|
|
34
|
+
* server-side). Unlike promptAsync, resolves only when the turn completes.
|
|
35
|
+
*/
|
|
36
|
+
commandAsync(input: {
|
|
37
|
+
sessionID: string;
|
|
38
|
+
command: string;
|
|
39
|
+
arguments?: string;
|
|
40
|
+
model?: OpencodeModelRef;
|
|
41
|
+
variant?: string;
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
/** Names of commands available in the session's directory. */
|
|
44
|
+
listCommands(): Promise<string[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Compact the session's context (`/compact`, OS-1614). OpenCode has no
|
|
47
|
+
* `compact` entry in `command.list()`, so this is a dedicated endpoint
|
|
48
|
+
* rather than a `commandAsync` invocation. It requires an explicit model
|
|
49
|
+
* and, like `commandAsync`, resolves only once the compaction turn ends.
|
|
50
|
+
*/
|
|
51
|
+
compactSession(input: {
|
|
52
|
+
sessionID: string;
|
|
53
|
+
model: OpencodeModelRef;
|
|
54
|
+
}): Promise<void>;
|
|
55
|
+
/** The session's own model, used when the run resolved no explicit one. */
|
|
56
|
+
getSessionModel(sessionID: string): Promise<OpencodeModelRef | null>;
|
|
57
|
+
/** Provider defaults (`providerID` → `modelID`) for the compaction fallback. */
|
|
58
|
+
getDefaultModel(): Promise<OpencodeModelRef | null>;
|
|
59
|
+
abortSession(sessionID: string): Promise<void>;
|
|
60
|
+
/** Server-sent event stream; each item is a raw SDK event object. */
|
|
61
|
+
subscribeEvents(signal: AbortSignal): Promise<AsyncIterable<unknown>>;
|
|
62
|
+
replyPermission(requestID: string, reply: "once" | "always" | "reject"): Promise<void>;
|
|
63
|
+
replyQuestion(requestID: string, answers: string[][]): Promise<void>;
|
|
64
|
+
rejectQuestion(requestID: string): Promise<void>;
|
|
65
|
+
listProviders(): Promise<{
|
|
66
|
+
all: Array<{
|
|
67
|
+
id: string;
|
|
68
|
+
name: string;
|
|
69
|
+
models: Record<string, {
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
variants?: Record<string, unknown>;
|
|
73
|
+
}>;
|
|
74
|
+
}>;
|
|
75
|
+
connected: string[];
|
|
76
|
+
defaults: Record<string, string>;
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
export declare function connectOpencode(args: {
|
|
80
|
+
baseUrl: string;
|
|
81
|
+
directory: string;
|
|
82
|
+
}): OpencodeClientLike;
|