agent-tower 0.1.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/dist/app.d.ts +2 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +62 -0
- package/dist/app.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +131 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/container.d.ts +11 -0
- package/dist/core/container.d.ts.map +1 -0
- package/dist/core/container.js +66 -0
- package/dist/core/container.js.map +1 -0
- package/dist/core/event-bus.d.ts +58 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +29 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/errors.d.ts +22 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +36 -0
- package/dist/errors.js.map +1 -0
- package/dist/executors/base.executor.d.ts +160 -0
- package/dist/executors/base.executor.d.ts.map +1 -0
- package/dist/executors/base.executor.js +122 -0
- package/dist/executors/base.executor.js.map +1 -0
- package/dist/executors/claude-code.executor.d.ts +78 -0
- package/dist/executors/claude-code.executor.d.ts.map +1 -0
- package/dist/executors/claude-code.executor.js +160 -0
- package/dist/executors/claude-code.executor.js.map +1 -0
- package/dist/executors/command-builder.d.ts +64 -0
- package/dist/executors/command-builder.d.ts.map +1 -0
- package/dist/executors/command-builder.js +144 -0
- package/dist/executors/command-builder.js.map +1 -0
- package/dist/executors/cursor-agent.executor.d.ts +57 -0
- package/dist/executors/cursor-agent.executor.d.ts.map +1 -0
- package/dist/executors/cursor-agent.executor.js +109 -0
- package/dist/executors/cursor-agent.executor.js.map +1 -0
- package/dist/executors/default-profiles.json +29 -0
- package/dist/executors/execution-env.d.ts +64 -0
- package/dist/executors/execution-env.d.ts.map +1 -0
- package/dist/executors/execution-env.js +97 -0
- package/dist/executors/execution-env.js.map +1 -0
- package/dist/executors/gemini-cli.executor.d.ts +55 -0
- package/dist/executors/gemini-cli.executor.d.ts.map +1 -0
- package/dist/executors/gemini-cli.executor.js +117 -0
- package/dist/executors/gemini-cli.executor.js.map +1 -0
- package/dist/executors/index.d.ts +49 -0
- package/dist/executors/index.d.ts.map +1 -0
- package/dist/executors/index.js +95 -0
- package/dist/executors/index.js.map +1 -0
- package/dist/executors/profiles.d.ts +61 -0
- package/dist/executors/profiles.d.ts.map +1 -0
- package/dist/executors/profiles.js +192 -0
- package/dist/executors/profiles.js.map +1 -0
- package/dist/git/git-cli.d.ts +59 -0
- package/dist/git/git-cli.d.ts.map +1 -0
- package/dist/git/git-cli.js +156 -0
- package/dist/git/git-cli.js.map +1 -0
- package/dist/git/worktree.manager.d.ts +166 -0
- package/dist/git/worktree.manager.d.ts.map +1 -0
- package/dist/git/worktree.manager.js +481 -0
- package/dist/git/worktree.manager.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/context.d.ts +15 -0
- package/dist/mcp/context.d.ts.map +1 -0
- package/dist/mcp/context.js +19 -0
- package/dist/mcp/context.js.map +1 -0
- package/dist/mcp/http-client.d.ts +46 -0
- package/dist/mcp/http-client.d.ts.map +1 -0
- package/dist/mcp/http-client.js +100 -0
- package/dist/mcp/http-client.js.map +1 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +36 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +6 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +32 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools/projects.d.ts +7 -0
- package/dist/mcp/tools/projects.d.ts.map +1 -0
- package/dist/mcp/tools/projects.js +12 -0
- package/dist/mcp/tools/projects.js.map +1 -0
- package/dist/mcp/tools/sessions.d.ts +7 -0
- package/dist/mcp/tools/sessions.d.ts.map +1 -0
- package/dist/mcp/tools/sessions.js +22 -0
- package/dist/mcp/tools/sessions.js.map +1 -0
- package/dist/mcp/tools/tasks.d.ts +7 -0
- package/dist/mcp/tools/tasks.d.ts.map +1 -0
- package/dist/mcp/tools/tasks.js +68 -0
- package/dist/mcp/tools/tasks.js.map +1 -0
- package/dist/mcp/tools/workspaces.d.ts +7 -0
- package/dist/mcp/tools/workspaces.d.ts.map +1 -0
- package/dist/mcp/tools/workspaces.js +45 -0
- package/dist/mcp/tools/workspaces.js.map +1 -0
- package/dist/mcp/types.d.ts +109 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +55 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/middleware/tunnel-auth.d.ts +13 -0
- package/dist/middleware/tunnel-auth.d.ts.map +1 -0
- package/dist/middleware/tunnel-auth.js +39 -0
- package/dist/middleware/tunnel-auth.js.map +1 -0
- package/dist/output/__tests__/claude-code-parser-token.test.d.ts +2 -0
- package/dist/output/__tests__/claude-code-parser-token.test.d.ts.map +1 -0
- package/dist/output/__tests__/claude-code-parser-token.test.js +233 -0
- package/dist/output/__tests__/claude-code-parser-token.test.js.map +1 -0
- package/dist/output/__tests__/cursor-agent-parser-token.test.d.ts +2 -0
- package/dist/output/__tests__/cursor-agent-parser-token.test.d.ts.map +1 -0
- package/dist/output/__tests__/cursor-agent-parser-token.test.js +95 -0
- package/dist/output/__tests__/cursor-agent-parser-token.test.js.map +1 -0
- package/dist/output/__tests__/msg-store-token.test.d.ts +2 -0
- package/dist/output/__tests__/msg-store-token.test.d.ts.map +1 -0
- package/dist/output/__tests__/msg-store-token.test.js +38 -0
- package/dist/output/__tests__/msg-store-token.test.js.map +1 -0
- package/dist/output/claude-code-parser.d.ts +96 -0
- package/dist/output/claude-code-parser.d.ts.map +1 -0
- package/dist/output/claude-code-parser.js +498 -0
- package/dist/output/claude-code-parser.js.map +1 -0
- package/dist/output/cursor-agent-parser.d.ts +87 -0
- package/dist/output/cursor-agent-parser.d.ts.map +1 -0
- package/dist/output/cursor-agent-parser.js +476 -0
- package/dist/output/cursor-agent-parser.js.map +1 -0
- package/dist/output/index.d.ts +9 -0
- package/dist/output/index.d.ts.map +1 -0
- package/dist/output/index.js +13 -0
- package/dist/output/index.js.map +1 -0
- package/dist/output/msg-store.d.ts +110 -0
- package/dist/output/msg-store.d.ts.map +1 -0
- package/dist/output/msg-store.js +274 -0
- package/dist/output/msg-store.js.map +1 -0
- package/dist/output/types.d.ts +90 -0
- package/dist/output/types.d.ts.map +1 -0
- package/dist/output/types.js +93 -0
- package/dist/output/types.js.map +1 -0
- package/dist/output/utils/ansi.d.ts +8 -0
- package/dist/output/utils/ansi.d.ts.map +1 -0
- package/dist/output/utils/ansi.js +17 -0
- package/dist/output/utils/ansi.js.map +1 -0
- package/dist/output/utils/patch.d.ts +57 -0
- package/dist/output/utils/patch.d.ts.map +1 -0
- package/dist/output/utils/patch.js +113 -0
- package/dist/output/utils/patch.js.map +1 -0
- package/dist/pipeline/agent-pipeline.d.ts +28 -0
- package/dist/pipeline/agent-pipeline.d.ts.map +1 -0
- package/dist/pipeline/agent-pipeline.js +76 -0
- package/dist/pipeline/agent-pipeline.js.map +1 -0
- package/dist/routes/attachments.d.ts +3 -0
- package/dist/routes/attachments.d.ts.map +1 -0
- package/dist/routes/attachments.js +141 -0
- package/dist/routes/attachments.js.map +1 -0
- package/dist/routes/demo.d.ts +3 -0
- package/dist/routes/demo.d.ts.map +1 -0
- package/dist/routes/demo.js +152 -0
- package/dist/routes/demo.js.map +1 -0
- package/dist/routes/files.d.ts +3 -0
- package/dist/routes/files.d.ts.map +1 -0
- package/dist/routes/files.js +313 -0
- package/dist/routes/files.js.map +1 -0
- package/dist/routes/filesystem.d.ts +3 -0
- package/dist/routes/filesystem.d.ts.map +1 -0
- package/dist/routes/filesystem.js +126 -0
- package/dist/routes/filesystem.js.map +1 -0
- package/dist/routes/git.d.ts +3 -0
- package/dist/routes/git.d.ts.map +1 -0
- package/dist/routes/git.js +170 -0
- package/dist/routes/git.js.map +1 -0
- package/dist/routes/index.d.ts +3 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +45 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/notifications.d.ts +10 -0
- package/dist/routes/notifications.d.ts.map +1 -0
- package/dist/routes/notifications.js +54 -0
- package/dist/routes/notifications.js.map +1 -0
- package/dist/routes/profiles.d.ts +12 -0
- package/dist/routes/profiles.d.ts.map +1 -0
- package/dist/routes/profiles.js +76 -0
- package/dist/routes/profiles.js.map +1 -0
- package/dist/routes/projects.d.ts +3 -0
- package/dist/routes/projects.d.ts.map +1 -0
- package/dist/routes/projects.js +94 -0
- package/dist/routes/projects.js.map +1 -0
- package/dist/routes/sessions.d.ts +12 -0
- package/dist/routes/sessions.d.ts.map +1 -0
- package/dist/routes/sessions.js +109 -0
- package/dist/routes/sessions.js.map +1 -0
- package/dist/routes/system.d.ts +3 -0
- package/dist/routes/system.d.ts.map +1 -0
- package/dist/routes/system.js +42 -0
- package/dist/routes/system.js.map +1 -0
- package/dist/routes/tasks.d.ts +3 -0
- package/dist/routes/tasks.d.ts.map +1 -0
- package/dist/routes/tasks.js +136 -0
- package/dist/routes/tasks.js.map +1 -0
- package/dist/routes/terminals.d.ts +3 -0
- package/dist/routes/terminals.d.ts.map +1 -0
- package/dist/routes/terminals.js +54 -0
- package/dist/routes/terminals.js.map +1 -0
- package/dist/routes/tunnel.d.ts +3 -0
- package/dist/routes/tunnel.d.ts.map +1 -0
- package/dist/routes/tunnel.js +36 -0
- package/dist/routes/tunnel.js.map +1 -0
- package/dist/routes/workspaces.d.ts +3 -0
- package/dist/routes/workspaces.d.ts.map +1 -0
- package/dist/routes/workspaces.js +171 -0
- package/dist/routes/workspaces.js.map +1 -0
- package/dist/services/commit-message.service.d.ts +32 -0
- package/dist/services/commit-message.service.d.ts.map +1 -0
- package/dist/services/commit-message.service.js +202 -0
- package/dist/services/commit-message.service.js.map +1 -0
- package/dist/services/notifications/feishu-channel.d.ts +9 -0
- package/dist/services/notifications/feishu-channel.d.ts.map +1 -0
- package/dist/services/notifications/feishu-channel.js +51 -0
- package/dist/services/notifications/feishu-channel.js.map +1 -0
- package/dist/services/notifications/index.d.ts +3 -0
- package/dist/services/notifications/index.d.ts.map +1 -0
- package/dist/services/notifications/index.js +2 -0
- package/dist/services/notifications/index.js.map +1 -0
- package/dist/services/notifications/notification.service.d.ts +10 -0
- package/dist/services/notifications/notification.service.d.ts.map +1 -0
- package/dist/services/notifications/notification.service.js +85 -0
- package/dist/services/notifications/notification.service.js.map +1 -0
- package/dist/services/notifications/os-channel.d.ts +8 -0
- package/dist/services/notifications/os-channel.d.ts.map +1 -0
- package/dist/services/notifications/os-channel.js +38 -0
- package/dist/services/notifications/os-channel.js.map +1 -0
- package/dist/services/notifications/types.d.ts +11 -0
- package/dist/services/notifications/types.d.ts.map +1 -0
- package/dist/services/notifications/types.js +2 -0
- package/dist/services/notifications/types.js.map +1 -0
- package/dist/services/project.service.d.ts +91 -0
- package/dist/services/project.service.d.ts.map +1 -0
- package/dist/services/project.service.js +138 -0
- package/dist/services/project.service.js.map +1 -0
- package/dist/services/session-manager.d.ts +164 -0
- package/dist/services/session-manager.d.ts.map +1 -0
- package/dist/services/session-manager.js +569 -0
- package/dist/services/session-manager.js.map +1 -0
- package/dist/services/task.service.d.ts +179 -0
- package/dist/services/task.service.d.ts.map +1 -0
- package/dist/services/task.service.js +281 -0
- package/dist/services/task.service.js.map +1 -0
- package/dist/services/terminal-manager.d.ts +64 -0
- package/dist/services/terminal-manager.d.ts.map +1 -0
- package/dist/services/terminal-manager.js +217 -0
- package/dist/services/terminal-manager.js.map +1 -0
- package/dist/services/tunnel.service.d.ts +16 -0
- package/dist/services/tunnel.service.d.ts.map +1 -0
- package/dist/services/tunnel.service.js +77 -0
- package/dist/services/tunnel.service.js.map +1 -0
- package/dist/services/workspace.service.d.ts +219 -0
- package/dist/services/workspace.service.d.ts.map +1 -0
- package/dist/services/workspace.service.js +351 -0
- package/dist/services/workspace.service.js.map +1 -0
- package/dist/socket/events.d.ts +2 -0
- package/dist/socket/events.d.ts.map +1 -0
- package/dist/socket/events.js +3 -0
- package/dist/socket/events.js.map +1 -0
- package/dist/socket/index.d.ts +20 -0
- package/dist/socket/index.d.ts.map +1 -0
- package/dist/socket/index.js +77 -0
- package/dist/socket/index.js.map +1 -0
- package/dist/socket/middleware/auth.d.ts +13 -0
- package/dist/socket/middleware/auth.d.ts.map +1 -0
- package/dist/socket/middleware/auth.js +29 -0
- package/dist/socket/middleware/auth.js.map +1 -0
- package/dist/socket/middleware/error-handler.d.ts +11 -0
- package/dist/socket/middleware/error-handler.d.ts.map +1 -0
- package/dist/socket/middleware/error-handler.js +39 -0
- package/dist/socket/middleware/error-handler.js.map +1 -0
- package/dist/socket/middleware/index.d.ts +3 -0
- package/dist/socket/middleware/index.d.ts.map +1 -0
- package/dist/socket/middleware/index.js +3 -0
- package/dist/socket/middleware/index.js.map +1 -0
- package/dist/socket/rooms.d.ts +30 -0
- package/dist/socket/rooms.d.ts.map +1 -0
- package/dist/socket/rooms.js +39 -0
- package/dist/socket/rooms.js.map +1 -0
- package/dist/socket/socket-gateway.d.ts +21 -0
- package/dist/socket/socket-gateway.d.ts.map +1 -0
- package/dist/socket/socket-gateway.js +173 -0
- package/dist/socket/socket-gateway.js.map +1 -0
- package/dist/types/index.d.ts +41 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +41 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +25 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/web/assets/AgentDemoPage-WdWEQtyU.js +1 -0
- package/dist/web/assets/DemoPage-C4Z_ftHI.js +4 -0
- package/dist/web/assets/NotificationSettingsPage-FrLfgt9y.js +1 -0
- package/dist/web/assets/ProfileSettingsPage-Cs93rTRr.js +3 -0
- package/dist/web/assets/ProjectKanbanPage-BmlRVfzo.js +75 -0
- package/dist/web/assets/ProjectKanbanPage-G5OQeJvU.css +1 -0
- package/dist/web/assets/api-client-CEBkg5lt.js +1 -0
- package/dist/web/assets/circle-alert-BEozlsMd.js +1 -0
- package/dist/web/assets/code-block-OCS4YCEC-CGgYYS4A.js +2 -0
- package/dist/web/assets/folder-picker-BP3x3phB.js +1 -0
- package/dist/web/assets/index-BuAijQvi.js +13 -0
- package/dist/web/assets/index-CxV866Yg.css +1 -0
- package/dist/web/assets/loader-circle-yEIqsdJ1.js +1 -0
- package/dist/web/assets/mermaid-NOHMQCX5-CIqtI2jF.js +123 -0
- package/dist/web/assets/mermaid-NOHMQCX5-lI9o3AWT.css +1 -0
- package/dist/web/assets/modal-BoX2RXaV.js +1 -0
- package/dist/web/assets/query-keys-BD_s_Etj.js +1 -0
- package/dist/web/assets/use-profiles-Rh8rBsAt.js +1 -0
- package/dist/web/index.html +14 -0
- package/dist/web/vite.svg +1 -0
- package/node_modules/@agent-tower/shared/dist/dev-port.d.ts +12 -0
- package/node_modules/@agent-tower/shared/dist/dev-port.d.ts.map +1 -0
- package/node_modules/@agent-tower/shared/dist/dev-port.js +31 -0
- package/node_modules/@agent-tower/shared/dist/dev-port.js.map +1 -0
- package/node_modules/@agent-tower/shared/dist/index.d.ts +5 -0
- package/node_modules/@agent-tower/shared/dist/index.d.ts.map +1 -0
- package/node_modules/@agent-tower/shared/dist/index.js +5 -0
- package/node_modules/@agent-tower/shared/dist/index.js.map +1 -0
- package/node_modules/@agent-tower/shared/dist/log-adapter.d.ts +72 -0
- package/node_modules/@agent-tower/shared/dist/log-adapter.d.ts.map +1 -0
- package/node_modules/@agent-tower/shared/dist/log-adapter.js +144 -0
- package/node_modules/@agent-tower/shared/dist/log-adapter.js.map +1 -0
- package/node_modules/@agent-tower/shared/dist/socket/events.d.ts +133 -0
- package/node_modules/@agent-tower/shared/dist/socket/events.d.ts.map +1 -0
- package/node_modules/@agent-tower/shared/dist/socket/events.js +32 -0
- package/node_modules/@agent-tower/shared/dist/socket/events.js.map +1 -0
- package/node_modules/@agent-tower/shared/dist/socket/index.d.ts +2 -0
- package/node_modules/@agent-tower/shared/dist/socket/index.d.ts.map +1 -0
- package/node_modules/@agent-tower/shared/dist/socket/index.js +2 -0
- package/node_modules/@agent-tower/shared/dist/socket/index.js.map +1 -0
- package/node_modules/@agent-tower/shared/dist/types.d.ts +168 -0
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -0
- package/node_modules/@agent-tower/shared/dist/types.js +53 -0
- package/node_modules/@agent-tower/shared/dist/types.js.map +1 -0
- package/node_modules/@agent-tower/shared/package.json +38 -0
- package/package.json +46 -0
- package/prisma/schema.prisma +130 -0
- package/scripts/postinstall.js +120 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CursorAgentExecutor - Cursor Agent CLI 执行器
|
|
3
|
+
* 参考 vibe-kanban Rust 实现: crates/executors/src/executors/cursor.rs
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import * as os from 'os';
|
|
8
|
+
import { AgentType } from '../types/index.js';
|
|
9
|
+
import { which } from '../utils/index.js';
|
|
10
|
+
import { BaseExecutor, AgentCapability, } from './base.executor.js';
|
|
11
|
+
import { CommandBuilder, applyOverrides } from './command-builder.js';
|
|
12
|
+
/**
|
|
13
|
+
* 获取基础命令
|
|
14
|
+
*/
|
|
15
|
+
function getBaseCommand() {
|
|
16
|
+
return 'cursor-agent';
|
|
17
|
+
}
|
|
18
|
+
export class CursorAgentExecutor extends BaseExecutor {
|
|
19
|
+
agentType = AgentType.CURSOR_AGENT;
|
|
20
|
+
displayName = 'Cursor Agent';
|
|
21
|
+
config;
|
|
22
|
+
constructor(config = {}) {
|
|
23
|
+
super();
|
|
24
|
+
this.config = config;
|
|
25
|
+
this.cmdOverrides = config.cmd;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 获取可用性信息
|
|
29
|
+
*/
|
|
30
|
+
async getAvailabilityInfo() {
|
|
31
|
+
// 检查 cursor-agent 命令是否可用
|
|
32
|
+
const cursorAgentPath = await which(getBaseCommand());
|
|
33
|
+
if (!cursorAgentPath) {
|
|
34
|
+
return { type: 'NOT_FOUND', error: 'Cursor Agent CLI not installed. Run: curl https://cursor.com/install -fsS | bash' };
|
|
35
|
+
}
|
|
36
|
+
// 检查 MCP 配置文件是否存在(作为安装标识)
|
|
37
|
+
const mcpConfigPath = this.getDefaultMcpConfigPath();
|
|
38
|
+
if (mcpConfigPath && fs.existsSync(mcpConfigPath)) {
|
|
39
|
+
return { type: 'INSTALLATION_FOUND' };
|
|
40
|
+
}
|
|
41
|
+
// 命令存在但没有配置文件,也视为已安装
|
|
42
|
+
return { type: 'INSTALLATION_FOUND' };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 获取 Agent 能力
|
|
46
|
+
*/
|
|
47
|
+
getCapabilities() {
|
|
48
|
+
return [AgentCapability.SETUP_HELPER];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 获取默认 MCP 配置路径
|
|
52
|
+
*/
|
|
53
|
+
getDefaultMcpConfigPath() {
|
|
54
|
+
return path.join(os.homedir(), '.cursor', 'mcp.json');
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 构建命令
|
|
58
|
+
*/
|
|
59
|
+
buildCommandBuilder() {
|
|
60
|
+
let builder = CommandBuilder.new(getBaseCommand());
|
|
61
|
+
// 基础参数: -p 表示从 stdin 读取 prompt, --output-format=stream-json 输出 JSON 流
|
|
62
|
+
builder.setParams(['-p', '--output-format=stream-json']);
|
|
63
|
+
// 强制模式
|
|
64
|
+
if (this.config.force) {
|
|
65
|
+
builder.extendParams(['--force']);
|
|
66
|
+
}
|
|
67
|
+
// 模型选择
|
|
68
|
+
if (this.config.model) {
|
|
69
|
+
builder.extendParams(['--model', this.config.model]);
|
|
70
|
+
}
|
|
71
|
+
// 应用覆盖
|
|
72
|
+
return applyOverrides(builder, this.cmdOverrides);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 启动新会话
|
|
76
|
+
* Cursor Agent 通过 stdin 接收 prompt,不同于 Claude Code 通过参数传递
|
|
77
|
+
*/
|
|
78
|
+
async spawn(config) {
|
|
79
|
+
const commandBuilder = this.buildCommandBuilder();
|
|
80
|
+
const commandParts = commandBuilder.buildInitial();
|
|
81
|
+
// 组合 prompt
|
|
82
|
+
const prompt = this.combinePrompt(config.prompt);
|
|
83
|
+
const newConfig = { ...config, prompt };
|
|
84
|
+
return this.spawnInternal(newConfig, commandParts);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 继续现有会话
|
|
88
|
+
* Cursor Agent 使用 --resume 参数恢复会话
|
|
89
|
+
*/
|
|
90
|
+
async spawnFollowUp(config, sessionId, _resetToMessageId) {
|
|
91
|
+
const commandBuilder = this.buildCommandBuilder();
|
|
92
|
+
const additionalArgs = ['--resume', sessionId];
|
|
93
|
+
const commandParts = commandBuilder.buildFollowUp(additionalArgs);
|
|
94
|
+
// 组合 prompt
|
|
95
|
+
const prompt = this.combinePrompt(config.prompt);
|
|
96
|
+
const newConfig = { ...config, prompt };
|
|
97
|
+
return this.spawnInternal(newConfig, commandParts);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 组合 prompt
|
|
101
|
+
*/
|
|
102
|
+
combinePrompt(prompt) {
|
|
103
|
+
if (this.config.appendPrompt) {
|
|
104
|
+
return `${prompt}${this.config.appendPrompt}`;
|
|
105
|
+
}
|
|
106
|
+
return prompt;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=cursor-agent.executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-agent.executor.js","sourceRoot":"","sources":["../../src/executors/cursor-agent.executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB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AA0B;QAE1B,MAAM,cAAc,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAElD,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAC/C,MAAM,YAAY,GAAG,cAAc,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QAElE,YAAY;QACZ,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjD,MAAM,SAAS,GAAG,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC;QAExC,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,MAAc;QAClC,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAC7B,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QAChD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"executors": {
|
|
3
|
+
"CLAUDE_CODE": {
|
|
4
|
+
"DEFAULT": {
|
|
5
|
+
"dangerouslySkipPermissions": true
|
|
6
|
+
},
|
|
7
|
+
"PLAN": {
|
|
8
|
+
"plan": true
|
|
9
|
+
},
|
|
10
|
+
"APPROVALS": {
|
|
11
|
+
"approvals": true
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"GEMINI_CLI": {
|
|
15
|
+
"DEFAULT": {
|
|
16
|
+
"yolo": true
|
|
17
|
+
},
|
|
18
|
+
"APPROVALS": {
|
|
19
|
+
"yolo": false
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"CURSOR_AGENT": {
|
|
23
|
+
"DEFAULT": {
|
|
24
|
+
"force": true,
|
|
25
|
+
"model": "auto"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExecutionEnv - 执行环境
|
|
3
|
+
* 参考 Rust 实现: crates/executors/src/env.rs
|
|
4
|
+
*/
|
|
5
|
+
import type { CmdOverrides } from './command-builder.js';
|
|
6
|
+
/**
|
|
7
|
+
* 仓库上下文
|
|
8
|
+
*/
|
|
9
|
+
export interface RepoContext {
|
|
10
|
+
/** 工作区根目录 */
|
|
11
|
+
workspaceRoot: string;
|
|
12
|
+
/** 仓库名称列表 */
|
|
13
|
+
repoNames: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 执行环境 - 管理环境变量和仓库上下文
|
|
17
|
+
*/
|
|
18
|
+
export declare class ExecutionEnv {
|
|
19
|
+
private vars;
|
|
20
|
+
readonly repoContext: RepoContext;
|
|
21
|
+
readonly commitReminder: boolean;
|
|
22
|
+
constructor(repoContext: RepoContext, commitReminder?: boolean);
|
|
23
|
+
/**
|
|
24
|
+
* 创建默认执行环境
|
|
25
|
+
*/
|
|
26
|
+
static default(workingDir: string): ExecutionEnv;
|
|
27
|
+
/**
|
|
28
|
+
* 插入环境变量
|
|
29
|
+
*/
|
|
30
|
+
set(key: string, value: string): this;
|
|
31
|
+
/**
|
|
32
|
+
* 获取环境变量
|
|
33
|
+
*/
|
|
34
|
+
get(key: string): string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* 检查是否包含某个环境变量
|
|
37
|
+
*/
|
|
38
|
+
has(key: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 合并其他环境变量(传入的会覆盖现有的)
|
|
41
|
+
*/
|
|
42
|
+
merge(other: Record<string, string>): this;
|
|
43
|
+
/**
|
|
44
|
+
* 应用 CmdOverrides 中的环境变量
|
|
45
|
+
*/
|
|
46
|
+
withProfile(cmd?: CmdOverrides): ExecutionEnv;
|
|
47
|
+
/**
|
|
48
|
+
* 克隆当前环境
|
|
49
|
+
*/
|
|
50
|
+
clone(): ExecutionEnv;
|
|
51
|
+
/**
|
|
52
|
+
* 转换为普通对象
|
|
53
|
+
*/
|
|
54
|
+
toObject(): Record<string, string>;
|
|
55
|
+
/**
|
|
56
|
+
* 获取完整的环境变量(包含 process.env)
|
|
57
|
+
*/
|
|
58
|
+
getFullEnv(): Record<string, string>;
|
|
59
|
+
/**
|
|
60
|
+
* 获取仓库路径列表
|
|
61
|
+
*/
|
|
62
|
+
getRepoPaths(): string[];
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=execution-env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-env.d.ts","sourceRoot":"","sources":["../../src/executors/execution-env.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,aAAa;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,IAAI,CAAkC;IAC9C,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;gBAErB,WAAW,EAAE,WAAW,EAAE,cAAc,GAAE,OAAe;IAKrE;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY;IAOhD;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAKrC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIpC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAO1C;;OAEG;IACH,WAAW,CAAC,GAAG,CAAC,EAAE,YAAY,GAAG,YAAY;IAS7C;;OAEG;IACH,KAAK,IAAI,YAAY;IAQrB;;OAEG;IACH,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAQlC;;OAEG;IACH,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAOpC;;OAEG;IACH,YAAY,IAAI,MAAM,EAAE;CAKzB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExecutionEnv - 执行环境
|
|
3
|
+
* 参考 Rust 实现: crates/executors/src/env.rs
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 执行环境 - 管理环境变量和仓库上下文
|
|
7
|
+
*/
|
|
8
|
+
export class ExecutionEnv {
|
|
9
|
+
vars = new Map();
|
|
10
|
+
repoContext;
|
|
11
|
+
commitReminder;
|
|
12
|
+
constructor(repoContext, commitReminder = false) {
|
|
13
|
+
this.repoContext = repoContext;
|
|
14
|
+
this.commitReminder = commitReminder;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 创建默认执行环境
|
|
18
|
+
*/
|
|
19
|
+
static default(workingDir) {
|
|
20
|
+
return new ExecutionEnv({ workspaceRoot: workingDir, repoNames: [] }, false);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 插入环境变量
|
|
24
|
+
*/
|
|
25
|
+
set(key, value) {
|
|
26
|
+
this.vars.set(key, value);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 获取环境变量
|
|
31
|
+
*/
|
|
32
|
+
get(key) {
|
|
33
|
+
return this.vars.get(key);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 检查是否包含某个环境变量
|
|
37
|
+
*/
|
|
38
|
+
has(key) {
|
|
39
|
+
return this.vars.has(key);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 合并其他环境变量(传入的会覆盖现有的)
|
|
43
|
+
*/
|
|
44
|
+
merge(other) {
|
|
45
|
+
for (const [key, value] of Object.entries(other)) {
|
|
46
|
+
this.vars.set(key, value);
|
|
47
|
+
}
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 应用 CmdOverrides 中的环境变量
|
|
52
|
+
*/
|
|
53
|
+
withProfile(cmd) {
|
|
54
|
+
if (cmd?.env) {
|
|
55
|
+
const newEnv = this.clone();
|
|
56
|
+
newEnv.merge(cmd.env);
|
|
57
|
+
return newEnv;
|
|
58
|
+
}
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 克隆当前环境
|
|
63
|
+
*/
|
|
64
|
+
clone() {
|
|
65
|
+
const newEnv = new ExecutionEnv(this.repoContext, this.commitReminder);
|
|
66
|
+
for (const [key, value] of this.vars) {
|
|
67
|
+
newEnv.vars.set(key, value);
|
|
68
|
+
}
|
|
69
|
+
return newEnv;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 转换为普通对象
|
|
73
|
+
*/
|
|
74
|
+
toObject() {
|
|
75
|
+
const result = {};
|
|
76
|
+
for (const [key, value] of this.vars) {
|
|
77
|
+
result[key] = value;
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 获取完整的环境变量(包含 process.env)
|
|
83
|
+
*/
|
|
84
|
+
getFullEnv() {
|
|
85
|
+
return {
|
|
86
|
+
...process.env,
|
|
87
|
+
...this.toObject(),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 获取仓库路径列表
|
|
92
|
+
*/
|
|
93
|
+
getRepoPaths() {
|
|
94
|
+
return this.repoContext.repoNames.map(name => `${this.repoContext.workspaceRoot}/${name}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=execution-env.js.map
|
|
@@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
|
5
|
+
import { AgentType } from '../types/index.js';
|
|
6
|
+
import { BaseExecutor, AvailabilityInfo, AgentCapability, ExecutorSpawnConfig, SpawnedChild } from './base.executor.js';
|
|
7
|
+
import { CommandBuilder, CmdOverrides } from './command-builder.js';
|
|
8
|
+
/**
|
|
9
|
+
* Gemini CLI 配置
|
|
10
|
+
*/
|
|
11
|
+
export interface GeminiCliConfig {
|
|
12
|
+
/** 追加到 prompt 的文本 */
|
|
13
|
+
appendPrompt?: string;
|
|
14
|
+
/** 模型选择 */
|
|
15
|
+
model?: string;
|
|
16
|
+
/** YOLO 模式 - 自动批准所有操作 */
|
|
17
|
+
yolo?: boolean;
|
|
18
|
+
/** 命令覆盖 */
|
|
19
|
+
cmd?: CmdOverrides;
|
|
20
|
+
}
|
|
21
|
+
export declare class GeminiCliExecutor extends BaseExecutor {
|
|
22
|
+
readonly agentType = AgentType.GEMINI_CLI;
|
|
23
|
+
readonly displayName = "Gemini CLI";
|
|
24
|
+
private config;
|
|
25
|
+
constructor(config?: GeminiCliConfig);
|
|
26
|
+
/**
|
|
27
|
+
* 获取可用性信息
|
|
28
|
+
*/
|
|
29
|
+
getAvailabilityInfo(): Promise<AvailabilityInfo>;
|
|
30
|
+
/**
|
|
31
|
+
* 获取 Agent 能力
|
|
32
|
+
*/
|
|
33
|
+
getCapabilities(): AgentCapability[];
|
|
34
|
+
/**
|
|
35
|
+
* 获取默认 MCP 配置路径
|
|
36
|
+
*/
|
|
37
|
+
getDefaultMcpConfigPath(): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* 构建命令
|
|
40
|
+
*/
|
|
41
|
+
protected buildCommandBuilder(): CommandBuilder;
|
|
42
|
+
/**
|
|
43
|
+
* 启动新会话
|
|
44
|
+
*/
|
|
45
|
+
spawn(config: ExecutorSpawnConfig): Promise<SpawnedChild>;
|
|
46
|
+
/**
|
|
47
|
+
* 继续现有会话
|
|
48
|
+
*/
|
|
49
|
+
spawnFollowUp(config: ExecutorSpawnConfig, sessionId: string, resetToMessageId?: string): Promise<SpawnedChild>;
|
|
50
|
+
/**
|
|
51
|
+
* 组合 prompt
|
|
52
|
+
*/
|
|
53
|
+
private combinePrompt;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=gemini-cli.executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini-cli.executor.d.ts","sourceRoot":"","sources":["../../src/executors/gemini-cli.executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,YAAY,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAkB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW;IACX,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AASD,qBAAa,iBAAkB,SAAQ,YAAY;IACjD,QAAQ,CAAC,SAAS,wBAAwB;IAC1C,QAAQ,CAAC,WAAW,gBAAgB;IAEpC,OAAO,CAAC,MAAM,CAAkB;gBAEpB,MAAM,GAAE,eAAoB;IAMxC;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IA0BtD;;OAEG;IACH,eAAe,IAAI,eAAe,EAAE;IAIpC;;OAEG;IACH,uBAAuB,IAAI,MAAM,GAAG,IAAI;IAIxC;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,cAAc;IAqB/C;;OAEG;IACG,KAAK,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC;IAW/D;;OAEG;IACG,aAAa,CACjB,MAAM,EAAE,mBAAmB,EAC3B,SAAS,EAAE,MAAM,EACjB,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,YAAY,CAAC;IAgBxB;;OAEG;IACH,OAAO,CAAC,aAAa;CAMtB"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GeminiCliExecutor - Gemini CLI 执行器
|
|
3
|
+
* 参考 Rust 实现: crates/executors/src/executors/gemini.rs
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import * as os from 'os';
|
|
8
|
+
import { AgentType } from '../types/index.js';
|
|
9
|
+
import { BaseExecutor, AgentCapability, } from './base.executor.js';
|
|
10
|
+
import { CommandBuilder, applyOverrides } from './command-builder.js';
|
|
11
|
+
/**
|
|
12
|
+
* 获取基础命令
|
|
13
|
+
*/
|
|
14
|
+
function getBaseCommand() {
|
|
15
|
+
return 'npx -y @google/gemini-cli@0.23.0';
|
|
16
|
+
}
|
|
17
|
+
export class GeminiCliExecutor extends BaseExecutor {
|
|
18
|
+
agentType = AgentType.GEMINI_CLI;
|
|
19
|
+
displayName = 'Gemini CLI';
|
|
20
|
+
config;
|
|
21
|
+
constructor(config = {}) {
|
|
22
|
+
super();
|
|
23
|
+
this.config = config;
|
|
24
|
+
this.cmdOverrides = config.cmd;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 获取可用性信息
|
|
28
|
+
*/
|
|
29
|
+
async getAvailabilityInfo() {
|
|
30
|
+
const oauthCredsPath = path.join(os.homedir(), '.gemini', 'oauth_creds.json');
|
|
31
|
+
try {
|
|
32
|
+
const stats = fs.statSync(oauthCredsPath);
|
|
33
|
+
const timestamp = Math.floor(stats.mtimeMs / 1000);
|
|
34
|
+
return {
|
|
35
|
+
type: 'LOGIN_DETECTED',
|
|
36
|
+
lastAuthTimestamp: timestamp,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// 检查 MCP 配置或安装标识
|
|
41
|
+
const mcpConfigPath = this.getDefaultMcpConfigPath();
|
|
42
|
+
const installationIdPath = path.join(os.homedir(), '.gemini', 'installation_id');
|
|
43
|
+
const mcpConfigFound = mcpConfigPath && fs.existsSync(mcpConfigPath);
|
|
44
|
+
const installationFound = fs.existsSync(installationIdPath);
|
|
45
|
+
if (mcpConfigFound || installationFound) {
|
|
46
|
+
return { type: 'INSTALLATION_FOUND' };
|
|
47
|
+
}
|
|
48
|
+
return { type: 'NOT_FOUND', error: 'Gemini CLI not configured' };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 获取 Agent 能力
|
|
53
|
+
*/
|
|
54
|
+
getCapabilities() {
|
|
55
|
+
return [AgentCapability.SESSION_FORK];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 获取默认 MCP 配置路径
|
|
59
|
+
*/
|
|
60
|
+
getDefaultMcpConfigPath() {
|
|
61
|
+
return path.join(os.homedir(), '.gemini', 'settings.json');
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 构建命令
|
|
65
|
+
*/
|
|
66
|
+
buildCommandBuilder() {
|
|
67
|
+
let builder = CommandBuilder.new(getBaseCommand());
|
|
68
|
+
// 模型选择
|
|
69
|
+
if (this.config.model) {
|
|
70
|
+
builder.extendParams(['--model', this.config.model]);
|
|
71
|
+
}
|
|
72
|
+
// YOLO 模式
|
|
73
|
+
if (this.config.yolo) {
|
|
74
|
+
builder.extendParams(['--yolo']);
|
|
75
|
+
builder.extendParams(['--allowed-tools', 'run_shell_command']);
|
|
76
|
+
}
|
|
77
|
+
// 启用 ACP 协议
|
|
78
|
+
builder.extendParams(['--experimental-acp']);
|
|
79
|
+
// 应用覆盖
|
|
80
|
+
return applyOverrides(builder, this.cmdOverrides);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 启动新会话
|
|
84
|
+
*/
|
|
85
|
+
async spawn(config) {
|
|
86
|
+
const commandBuilder = this.buildCommandBuilder();
|
|
87
|
+
const commandParts = commandBuilder.buildInitial();
|
|
88
|
+
// 组合 prompt
|
|
89
|
+
const prompt = this.combinePrompt(config.prompt);
|
|
90
|
+
const newConfig = { ...config, prompt };
|
|
91
|
+
return this.spawnInternal(newConfig, commandParts);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 继续现有会话
|
|
95
|
+
*/
|
|
96
|
+
async spawnFollowUp(config, sessionId, resetToMessageId) {
|
|
97
|
+
const commandBuilder = this.buildCommandBuilder();
|
|
98
|
+
// Gemini 的 follow-up 参数(根据 ACP 协议)
|
|
99
|
+
const additionalArgs = [];
|
|
100
|
+
// TODO: 添加 Gemini 特定的会话恢复参数
|
|
101
|
+
const commandParts = commandBuilder.buildFollowUp(additionalArgs);
|
|
102
|
+
// 组合 prompt
|
|
103
|
+
const prompt = this.combinePrompt(config.prompt);
|
|
104
|
+
const newConfig = { ...config, prompt };
|
|
105
|
+
return this.spawnInternal(newConfig, commandParts);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 组合 prompt
|
|
109
|
+
*/
|
|
110
|
+
combinePrompt(prompt) {
|
|
111
|
+
if (this.config.appendPrompt) {
|
|
112
|
+
return `${prompt}${this.config.appendPrompt}`;
|
|
113
|
+
}
|
|
114
|
+
return prompt;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=gemini-cli.executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini-cli.executor.js","sourceRoot":"","sources":["../../src/executors/gemini-cli.executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC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Ac,CAAC,YAAY,EAAE,CAAC;QAEnD,YAAY;QACZ,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjD,MAAM,SAAS,GAAG,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC;QAExC,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CACjB,MAA2B,EAC3B,SAAiB,EACjB,gBAAyB;QAEzB,MAAM,cAAc,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAElD,mCAAmC;QACnC,MAAM,cAAc,GAAa,EAAE,CAAC;QACpC,4BAA4B;QAE5B,MAAM,YAAY,GAAG,cAAc,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QAElE,YAAY;QACZ,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjD,MAAM,SAAS,GAAG,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC;QAExC,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,MAAc;QAClC,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAC7B,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QAChD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Executors 模块导出
|
|
3
|
+
*
|
|
4
|
+
* 改造: 不再使用全局单例 Map,而是从 profiles 读取配置动态构造 executor 实例
|
|
5
|
+
*/
|
|
6
|
+
import { AgentType } from '../types/index.js';
|
|
7
|
+
import { BaseExecutor, AvailabilityInfo } from './base.executor.js';
|
|
8
|
+
/**
|
|
9
|
+
* 获取指定类型的执行器(支持 variant)
|
|
10
|
+
*
|
|
11
|
+
* @param agentType - agent 类型
|
|
12
|
+
* @param variant - 配置变体名称,默认 'DEFAULT'
|
|
13
|
+
*/
|
|
14
|
+
export declare function getExecutor(agentType: AgentType, variant?: string): BaseExecutor | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* 获取所有已注册的 agent 类型
|
|
17
|
+
*/
|
|
18
|
+
export declare function getAllAgentTypes(): AgentType[];
|
|
19
|
+
/**
|
|
20
|
+
* 获取所有执行器(每种 agent 的 DEFAULT variant)
|
|
21
|
+
*/
|
|
22
|
+
export declare function getAllExecutors(): BaseExecutor[];
|
|
23
|
+
/**
|
|
24
|
+
* 获取可用的执行器列表
|
|
25
|
+
*/
|
|
26
|
+
export declare function getAvailableExecutors(): Promise<BaseExecutor[]>;
|
|
27
|
+
/**
|
|
28
|
+
* 获取所有执行器的可用性信息
|
|
29
|
+
*/
|
|
30
|
+
export declare function getAllExecutorsAvailability(): Promise<Array<{
|
|
31
|
+
agentType: AgentType;
|
|
32
|
+
displayName: string;
|
|
33
|
+
availability: AvailabilityInfo;
|
|
34
|
+
}>>;
|
|
35
|
+
export { BaseExecutor, CancellationToken } from './base.executor.js';
|
|
36
|
+
export { ClaudeCodeExecutor, PermissionMode } from './claude-code.executor.js';
|
|
37
|
+
export { GeminiCliExecutor } from './gemini-cli.executor.js';
|
|
38
|
+
export { CursorAgentExecutor } from './cursor-agent.executor.js';
|
|
39
|
+
export { CommandBuilder } from './command-builder.js';
|
|
40
|
+
export { ExecutionEnv } from './execution-env.js';
|
|
41
|
+
export { getProfiles, loadProfiles, reloadProfiles, getVariantConfig, getVariantNames, setVariantConfig, deleteVariantConfig, getDefaultProfiles, } from './profiles.js';
|
|
42
|
+
export type { AvailabilityInfo, SpawnedChild, ExecutorSpawnConfig, AgentCapability } from './base.executor.js';
|
|
43
|
+
export type { ClaudeCodeConfig } from './claude-code.executor.js';
|
|
44
|
+
export type { GeminiCliConfig } from './gemini-cli.executor.js';
|
|
45
|
+
export type { CursorAgentConfig } from './cursor-agent.executor.js';
|
|
46
|
+
export type { CmdOverrides, CommandParts } from './command-builder.js';
|
|
47
|
+
export type { RepoContext } from './execution-env.js';
|
|
48
|
+
export type { ExecutorProfiles, VariantConfig, AgentVariants } from './profiles.js';
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/executors/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAwBpE;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,GAAE,MAAkB,GAAG,YAAY,GAAG,SAAS,CASvG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,SAAS,EAAE,CAE9C;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,YAAY,EAAE,CAIhD;AAED;;GAEG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAWrE;AAED;;GAEG;AACH,wBAAsB,2BAA2B,IAAI,OAAO,CAC1D,KAAK,CAAC;IACJ,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,gBAAgB,CAAC;CAChC,CAAC,CACH,CAaA;AAGD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,EACL,WAAW,EACX,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAGvB,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/G,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACvE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Executors 模块导出
|
|
3
|
+
*
|
|
4
|
+
* 改造: 不再使用全局单例 Map,而是从 profiles 读取配置动态构造 executor 实例
|
|
5
|
+
*/
|
|
6
|
+
import { AgentType } from '../types/index.js';
|
|
7
|
+
import { ClaudeCodeExecutor } from './claude-code.executor.js';
|
|
8
|
+
import { GeminiCliExecutor } from './gemini-cli.executor.js';
|
|
9
|
+
import { CursorAgentExecutor } from './cursor-agent.executor.js';
|
|
10
|
+
import { getVariantConfig } from './profiles.js';
|
|
11
|
+
// ─── Executor Factory ────────────────────────────────────────────
|
|
12
|
+
/**
|
|
13
|
+
* 根据 agent 类型和 variant 配置创建 executor 实例
|
|
14
|
+
*/
|
|
15
|
+
function createExecutor(agentType, config = {}) {
|
|
16
|
+
switch (agentType) {
|
|
17
|
+
case AgentType.CLAUDE_CODE:
|
|
18
|
+
return new ClaudeCodeExecutor(config);
|
|
19
|
+
case AgentType.GEMINI_CLI:
|
|
20
|
+
return new GeminiCliExecutor(config);
|
|
21
|
+
case AgentType.CURSOR_AGENT:
|
|
22
|
+
return new CursorAgentExecutor(config);
|
|
23
|
+
default:
|
|
24
|
+
throw new Error(`Unknown agent type: ${agentType}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 获取指定类型的执行器(支持 variant)
|
|
29
|
+
*
|
|
30
|
+
* @param agentType - agent 类型
|
|
31
|
+
* @param variant - 配置变体名称,默认 'DEFAULT'
|
|
32
|
+
*/
|
|
33
|
+
export function getExecutor(agentType, variant = 'DEFAULT') {
|
|
34
|
+
const config = getVariantConfig(agentType, variant);
|
|
35
|
+
if (!config) {
|
|
36
|
+
// variant 不存在时 fallback 到 DEFAULT
|
|
37
|
+
const defaultConfig = getVariantConfig(agentType, 'DEFAULT');
|
|
38
|
+
if (!defaultConfig)
|
|
39
|
+
return undefined;
|
|
40
|
+
return createExecutor(agentType, defaultConfig);
|
|
41
|
+
}
|
|
42
|
+
return createExecutor(agentType, config);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 获取所有已注册的 agent 类型
|
|
46
|
+
*/
|
|
47
|
+
export function getAllAgentTypes() {
|
|
48
|
+
return Object.values(AgentType);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 获取所有执行器(每种 agent 的 DEFAULT variant)
|
|
52
|
+
*/
|
|
53
|
+
export function getAllExecutors() {
|
|
54
|
+
return getAllAgentTypes()
|
|
55
|
+
.map(type => getExecutor(type))
|
|
56
|
+
.filter((e) => e !== undefined);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 获取可用的执行器列表
|
|
60
|
+
*/
|
|
61
|
+
export async function getAvailableExecutors() {
|
|
62
|
+
const available = [];
|
|
63
|
+
for (const executor of getAllExecutors()) {
|
|
64
|
+
const availability = await executor.getAvailabilityInfo();
|
|
65
|
+
if (availability.type !== 'NOT_FOUND') {
|
|
66
|
+
available.push(executor);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return available;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 获取所有执行器的可用性信息
|
|
73
|
+
*/
|
|
74
|
+
export async function getAllExecutorsAvailability() {
|
|
75
|
+
const results = [];
|
|
76
|
+
for (const executor of getAllExecutors()) {
|
|
77
|
+
const availability = await executor.getAvailabilityInfo();
|
|
78
|
+
results.push({
|
|
79
|
+
agentType: executor.agentType,
|
|
80
|
+
displayName: executor.displayName,
|
|
81
|
+
availability,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return results;
|
|
85
|
+
}
|
|
86
|
+
// 导出类
|
|
87
|
+
export { BaseExecutor, CancellationToken } from './base.executor.js';
|
|
88
|
+
export { ClaudeCodeExecutor, PermissionMode } from './claude-code.executor.js';
|
|
89
|
+
export { GeminiCliExecutor } from './gemini-cli.executor.js';
|
|
90
|
+
export { CursorAgentExecutor } from './cursor-agent.executor.js';
|
|
91
|
+
export { CommandBuilder } from './command-builder.js';
|
|
92
|
+
export { ExecutionEnv } from './execution-env.js';
|
|
93
|
+
// 导出 profiles
|
|
94
|
+
export { getProfiles, loadProfiles, reloadProfiles, getVariantConfig, getVariantNames, setVariantConfig, deleteVariantConfig, getDefaultProfiles, } from './profiles.js';
|
|
95
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/executors/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAyB,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAwB,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAA0B,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,gBA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