@pixelbyte-software/pixcode 1.34.0 → 1.35.1
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 +718 -718
- package/README.de.md +248 -248
- package/README.ja.md +240 -240
- package/README.ko.md +240 -240
- package/README.md +303 -303
- package/README.ru.md +248 -248
- package/README.tr.md +250 -250
- package/README.zh-CN.md +240 -240
- package/dist/api-docs.html +548 -395
- package/dist/assets/index-B8w57E1r.css +32 -0
- package/dist/assets/index-CBdsvGSR.js +854 -0
- package/dist/clear-cache.html +85 -85
- package/dist/convert-icons.md +52 -52
- package/dist/favicon.svg +8 -8
- package/dist/generate-icons.js +48 -48
- package/dist/icons/codex-white.svg +3 -3
- package/dist/icons/codex.svg +3 -3
- package/dist/icons/cursor-white.svg +11 -11
- package/dist/icons/icon-128x128.svg +9 -9
- package/dist/icons/icon-144x144.svg +9 -9
- package/dist/icons/icon-152x152.svg +9 -9
- package/dist/icons/icon-192x192.svg +9 -9
- package/dist/icons/icon-384x384.svg +9 -9
- package/dist/icons/icon-512x512.svg +9 -9
- package/dist/icons/icon-72x72.svg +9 -9
- package/dist/icons/icon-96x96.svg +9 -9
- package/dist/icons/icon-template.svg +9 -9
- package/dist/icons/qwen-logo.svg +14 -14
- package/dist/index.html +59 -59
- package/dist/logo.svg +12 -12
- package/dist/manifest.json +60 -60
- package/dist/openapi.yaml +1693 -1311
- package/dist/sw.js +124 -124
- package/dist-server/server/claude-sdk.js +38 -7
- package/dist-server/server/claude-sdk.js.map +1 -1
- package/dist-server/server/cli.js +107 -112
- package/dist-server/server/cli.js.map +1 -1
- package/dist-server/server/daemon/manager.js +33 -33
- package/dist-server/server/daemon-manager.js +159 -112
- package/dist-server/server/daemon-manager.js.map +1 -1
- package/dist-server/server/database/json-store.js +8 -5
- package/dist-server/server/database/json-store.js.map +1 -1
- package/dist-server/server/index.js +31 -10
- package/dist-server/server/index.js.map +1 -1
- package/dist-server/server/modules/orchestration/a2a/adapter-registry.js +45 -19
- package/dist-server/server/modules/orchestration/a2a/adapter-registry.js.map +1 -1
- package/dist-server/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js.map +1 -1
- package/dist-server/server/modules/orchestration/a2a/adapters/claude-code.adapter.js +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/claude-code.adapter.js.map +1 -1
- package/dist-server/server/modules/orchestration/a2a/adapters/codex.adapter.js +202 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/codex.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/cursor.adapter.js +205 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/cursor.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/gemini.adapter.js +205 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/gemini.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/opencode.adapter.js +205 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/opencode.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/qwen.adapter.js +205 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/qwen.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/routes.js +298 -34
- package/dist-server/server/modules/orchestration/a2a/routes.js.map +1 -1
- package/dist-server/server/modules/orchestration/a2a/task-store.js +144 -0
- package/dist-server/server/modules/orchestration/a2a/task-store.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/validator.js +16 -0
- package/dist-server/server/modules/orchestration/a2a/validator.js.map +1 -1
- package/dist-server/server/modules/orchestration/index.js +14 -0
- package/dist-server/server/modules/orchestration/index.js.map +1 -1
- package/dist-server/server/modules/orchestration/preview/port-watcher.js +90 -0
- package/dist-server/server/modules/orchestration/preview/port-watcher.js.map +1 -0
- package/dist-server/server/modules/orchestration/preview/preview-proxy.js +58 -0
- package/dist-server/server/modules/orchestration/preview/preview-proxy.js.map +1 -0
- package/dist-server/server/modules/orchestration/preview/types.js +2 -0
- package/dist-server/server/modules/orchestration/preview/types.js.map +1 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task-store.js +37 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task-store.js.map +1 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.routes.js +68 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.routes.js.map +1 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.service.js +128 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.service.js.map +1 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.types.js +2 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.types.js.map +1 -0
- package/dist-server/server/modules/orchestration/workflows/built-in-workflows.js +126 -0
- package/dist-server/server/modules/orchestration/workflows/built-in-workflows.js.map +1 -0
- package/dist-server/server/modules/orchestration/workflows/workflow-runner.js +1047 -0
- package/dist-server/server/modules/orchestration/workflows/workflow-runner.js.map +1 -0
- package/dist-server/server/modules/orchestration/workflows/workflow-store.js +76 -0
- package/dist-server/server/modules/orchestration/workflows/workflow-store.js.map +1 -0
- package/dist-server/server/modules/orchestration/workflows/workflow.routes.js +151 -0
- package/dist-server/server/modules/orchestration/workflows/workflow.routes.js.map +1 -0
- package/dist-server/server/modules/orchestration/workflows/workflow.types.js +2 -0
- package/dist-server/server/modules/orchestration/workflows/workflow.types.js.map +1 -0
- package/dist-server/server/modules/orchestration/workflows/workspace-target.js +98 -0
- package/dist-server/server/modules/orchestration/workflows/workspace-target.js.map +1 -0
- package/dist-server/server/modules/orchestration/workspace/docker-workspace.js +122 -0
- package/dist-server/server/modules/orchestration/workspace/docker-workspace.js.map +1 -0
- package/dist-server/server/modules/orchestration/workspace/path-safety.js +48 -0
- package/dist-server/server/modules/orchestration/workspace/path-safety.js.map +1 -0
- package/dist-server/server/modules/orchestration/workspace/types.js +11 -0
- package/dist-server/server/modules/orchestration/workspace/types.js.map +1 -0
- package/dist-server/server/modules/orchestration/workspace/workspace-manager.js +80 -0
- package/dist-server/server/modules/orchestration/workspace/workspace-manager.js.map +1 -0
- package/dist-server/server/modules/orchestration/workspace/worktree-workspace.js +96 -0
- package/dist-server/server/modules/orchestration/workspace/worktree-workspace.js.map +1 -0
- package/dist-server/server/modules/providers/index.js +3 -0
- package/dist-server/server/modules/providers/index.js.map +1 -0
- package/dist-server/server/openai-codex.js +35 -4
- package/dist-server/server/openai-codex.js.map +1 -1
- package/dist-server/server/routes/commands.js +25 -25
- package/dist-server/server/routes/git.js +17 -17
- package/dist-server/server/routes/taskmaster.js +525 -508
- package/dist-server/server/routes/taskmaster.js.map +1 -1
- package/package.json +180 -178
- package/scripts/fix-node-pty.js +67 -67
- package/scripts/smoke/a2a-roundtrip.mjs +86 -17
- package/scripts/smoke/orchestration-api.mjs +172 -0
- package/scripts/smoke/orchestration-live-run.mjs +176 -0
- package/server/claude-sdk.js +898 -857
- package/server/cli.js +935 -940
- package/server/constants/config.js +4 -4
- package/server/cursor-cli.js +342 -342
- package/server/daemon/manager.js +564 -564
- package/server/daemon-manager.js +959 -920
- package/server/database/db.js +794 -794
- package/server/database/json-store.js +197 -194
- package/server/gemini-cli.js +535 -535
- package/server/gemini-response-handler.js +79 -79
- package/server/index.js +3135 -3104
- package/server/load-env.js +34 -34
- package/server/middleware/auth.js +173 -173
- package/server/modules/orchestration/a2a/adapter-registry.ts +72 -22
- package/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.ts +9 -3
- package/server/modules/orchestration/a2a/adapters/claude-code.adapter.ts +1 -0
- package/server/modules/orchestration/a2a/adapters/codex.adapter.ts +244 -0
- package/server/modules/orchestration/a2a/adapters/cursor.adapter.ts +249 -0
- package/server/modules/orchestration/a2a/adapters/gemini.adapter.ts +248 -0
- package/server/modules/orchestration/a2a/adapters/opencode.adapter.ts +248 -0
- package/server/modules/orchestration/a2a/adapters/qwen.adapter.ts +248 -0
- package/server/modules/orchestration/a2a/routes.ts +349 -36
- package/server/modules/orchestration/a2a/task-store.ts +178 -0
- package/server/modules/orchestration/a2a/types.ts +14 -0
- package/server/modules/orchestration/a2a/validator.ts +25 -2
- package/server/modules/orchestration/index.ts +40 -0
- package/server/modules/orchestration/preview/port-watcher.ts +112 -0
- package/server/modules/orchestration/preview/preview-proxy.ts +60 -0
- package/server/modules/orchestration/preview/types.ts +19 -0
- package/server/modules/orchestration/tasks/orchestration-task-store.ts +45 -0
- package/server/modules/orchestration/tasks/orchestration-task.routes.ts +73 -0
- package/server/modules/orchestration/tasks/orchestration-task.service.ts +145 -0
- package/server/modules/orchestration/tasks/orchestration-task.types.ts +29 -0
- package/server/modules/orchestration/workflows/built-in-workflows.ts +127 -0
- package/server/modules/orchestration/workflows/workflow-runner.ts +1206 -0
- package/server/modules/orchestration/workflows/workflow-store.ts +97 -0
- package/server/modules/orchestration/workflows/workflow.routes.ts +169 -0
- package/server/modules/orchestration/workflows/workflow.types.ts +70 -0
- package/server/modules/orchestration/workflows/workspace-target.ts +120 -0
- package/server/modules/orchestration/workspace/docker-workspace.ts +135 -0
- package/server/modules/orchestration/workspace/path-safety.ts +55 -0
- package/server/modules/orchestration/workspace/types.ts +52 -0
- package/server/modules/orchestration/workspace/workspace-manager.ts +97 -0
- package/server/modules/orchestration/workspace/worktree-workspace.ts +125 -0
- package/server/modules/providers/index.ts +2 -0
- package/server/modules/providers/list/claude/claude-auth.provider.ts +145 -145
- package/server/modules/providers/list/claude/claude-mcp.provider.ts +135 -135
- package/server/modules/providers/list/claude/claude-sessions.provider.ts +306 -306
- package/server/modules/providers/list/claude/claude.provider.ts +15 -15
- package/server/modules/providers/list/codex/codex-auth.provider.ts +115 -115
- package/server/modules/providers/list/codex/codex-mcp.provider.ts +135 -135
- package/server/modules/providers/list/codex/codex-sessions.provider.ts +319 -319
- package/server/modules/providers/list/codex/codex.provider.ts +15 -15
- package/server/modules/providers/list/cursor/cursor-auth.provider.ts +143 -143
- package/server/modules/providers/list/cursor/cursor-mcp.provider.ts +108 -108
- package/server/modules/providers/list/cursor/cursor-sessions.provider.ts +421 -421
- package/server/modules/providers/list/cursor/cursor.provider.ts +15 -15
- package/server/modules/providers/list/gemini/gemini-auth.provider.ts +163 -163
- package/server/modules/providers/list/gemini/gemini-mcp.provider.ts +110 -110
- package/server/modules/providers/list/gemini/gemini-sessions.provider.ts +227 -227
- package/server/modules/providers/list/gemini/gemini.provider.ts +15 -15
- package/server/modules/providers/list/opencode/opencode-auth.provider.ts +130 -130
- package/server/modules/providers/list/opencode/opencode-mcp.provider.ts +126 -126
- package/server/modules/providers/list/opencode/opencode-sessions.provider.ts +232 -232
- package/server/modules/providers/list/opencode/opencode.provider.ts +29 -29
- package/server/modules/providers/list/qwen/qwen-auth.provider.ts +145 -145
- package/server/modules/providers/list/qwen/qwen-mcp.provider.ts +114 -114
- package/server/modules/providers/list/qwen/qwen-sessions.provider.ts +265 -265
- package/server/modules/providers/list/qwen/qwen.provider.ts +21 -21
- package/server/modules/providers/provider.registry.ts +40 -40
- package/server/modules/providers/provider.routes.ts +819 -819
- package/server/modules/providers/services/mcp.service.ts +86 -86
- package/server/modules/providers/services/provider-auth.service.ts +26 -26
- package/server/modules/providers/services/sessions.service.ts +45 -45
- package/server/modules/providers/shared/base/abstract.provider.ts +20 -20
- package/server/modules/providers/shared/mcp/mcp.provider.ts +151 -151
- package/server/modules/providers/shared/provider-configs.ts +142 -142
- package/server/modules/providers/tests/mcp.test.ts +293 -293
- package/server/openai-codex.js +462 -426
- package/server/opencode-cli.js +459 -459
- package/server/opencode-response-handler.js +107 -107
- package/server/projects.js +3105 -3105
- package/server/qwen-code-cli.js +395 -395
- package/server/qwen-response-handler.js +73 -73
- package/server/routes/agent.js +1365 -1365
- package/server/routes/auth.js +138 -138
- package/server/routes/codex.js +19 -19
- package/server/routes/commands.js +554 -554
- package/server/routes/cursor.js +52 -52
- package/server/routes/gemini.js +24 -24
- package/server/routes/git.js +1488 -1488
- package/server/routes/mcp-utils.js +31 -31
- package/server/routes/messages.js +61 -61
- package/server/routes/network.js +120 -120
- package/server/routes/plugins.js +318 -318
- package/server/routes/projects.js +915 -915
- package/server/routes/qwen.js +27 -27
- package/server/routes/settings.js +286 -286
- package/server/routes/taskmaster.js +1496 -1471
- package/server/routes/telegram.js +125 -125
- package/server/routes/user.js +123 -123
- package/server/services/external-access.js +171 -171
- package/server/services/install-jobs.js +571 -571
- package/server/services/notification-orchestrator.js +242 -242
- package/server/services/provider-credentials.js +189 -189
- package/server/services/provider-models.js +381 -381
- package/server/services/telegram/bot.js +279 -279
- package/server/services/telegram/telegram-http-client.js +130 -130
- package/server/services/telegram/translations.js +170 -170
- package/server/services/vapid-keys.js +36 -36
- package/server/sessionManager.js +225 -225
- package/server/shared/interfaces.ts +54 -54
- package/server/shared/types.ts +172 -172
- package/server/shared/utils.ts +193 -193
- package/server/tsconfig.json +36 -36
- package/server/utils/colors.js +21 -21
- package/server/utils/commandParser.js +303 -303
- package/server/utils/frontmatter.js +18 -18
- package/server/utils/gitConfig.js +34 -34
- package/server/utils/mcp-detector.js +147 -147
- package/server/utils/plugin-loader.js +457 -457
- package/server/utils/plugin-process-manager.js +184 -184
- package/server/utils/port-access.js +209 -209
- package/server/utils/runtime-paths.js +37 -37
- package/server/utils/taskmaster-websocket.js +128 -128
- package/server/utils/url-detection.js +71 -71
- package/server/vite-daemon.js +78 -78
- package/shared/modelConstants.js +162 -162
- package/shared/networkHosts.js +22 -22
- package/dist/assets/index-B1ghfb4w.css +0 -32
- package/dist/assets/index-BvClqlMf.js +0 -852
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
// server/modules/orchestration/a2a/adapters/codex.adapter.ts
|
|
2
|
+
// Wraps the existing server/openai-codex.js queryCodex() runtime.
|
|
3
|
+
// That runtime already emits provider-neutral NormalizedMessage frames,
|
|
4
|
+
// so this adapter mainly translates those frames into A2A bus events.
|
|
5
|
+
|
|
6
|
+
import crypto from 'node:crypto';
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line boundaries/no-unknown -- openai-codex.js is a top-level CLI runtime not yet classified by eslint.config.js; cleanup deferred.
|
|
9
|
+
import { abortCodexSession, queryCodex } from '@/openai-codex.js';
|
|
10
|
+
import { AbstractA2AAdapter } from '@/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js';
|
|
11
|
+
import type {
|
|
12
|
+
AdapterContext,
|
|
13
|
+
TaskHandle,
|
|
14
|
+
} from '@/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js';
|
|
15
|
+
import type { AgentCard, Part, Task } from '@/modules/orchestration/a2a/types.js';
|
|
16
|
+
import type { NormalizedMessage } from '@/shared/types.js';
|
|
17
|
+
|
|
18
|
+
interface FakeWriter {
|
|
19
|
+
send(data: unknown): void;
|
|
20
|
+
isSSEStreamWriter: true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function joinPartsToPrompt(parts: Part[]): string {
|
|
24
|
+
return parts
|
|
25
|
+
.map((part) => {
|
|
26
|
+
if (part.kind === 'text') return part.text;
|
|
27
|
+
if (part.kind === 'data') return JSON.stringify(part.data);
|
|
28
|
+
return `[file:${part.name}${part.uri ? ` uri=${part.uri}` : ''}]`;
|
|
29
|
+
})
|
|
30
|
+
.join('\n');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function newId(prefix: string): string {
|
|
34
|
+
return `${prefix}_${crypto.randomBytes(8).toString('hex')}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class CodexA2AAdapter extends AbstractA2AAdapter {
|
|
38
|
+
readonly id = 'codex';
|
|
39
|
+
|
|
40
|
+
readonly agentCard: AgentCard = {
|
|
41
|
+
name: 'pixcode-codex',
|
|
42
|
+
description: 'OpenAI Codex, accessed via Pixcode',
|
|
43
|
+
url: '/a2a/agents/codex',
|
|
44
|
+
version: '1.0.0',
|
|
45
|
+
capabilities: ['streaming', 'fileEdit', 'commandExec', 'webSearch', 'mcp'],
|
|
46
|
+
skills: [
|
|
47
|
+
{
|
|
48
|
+
id: 'typescript-edit',
|
|
49
|
+
description: 'Edit TypeScript and JavaScript files with CLI-driven reasoning',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'command-execution',
|
|
53
|
+
description: 'Run shell commands and react to their output',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'web-research',
|
|
57
|
+
description: 'Use web search as part of the development workflow',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'task-planning',
|
|
61
|
+
description: 'Create and update TODO-style execution plans',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
authentication: { type: 'bearer' },
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
private readonly active = new Map<string, { sessionId: string | null }>();
|
|
68
|
+
|
|
69
|
+
async submitTask(task: Task, ctx: AdapterContext): Promise<TaskHandle> {
|
|
70
|
+
const promptText = joinPartsToPrompt(
|
|
71
|
+
task.history[task.history.length - 1]?.parts ?? [],
|
|
72
|
+
);
|
|
73
|
+
const session = { sessionId: null as string | null };
|
|
74
|
+
this.active.set(task.id, session);
|
|
75
|
+
|
|
76
|
+
this.emitState(task.id, 'working');
|
|
77
|
+
|
|
78
|
+
const fakeWriter: FakeWriter = {
|
|
79
|
+
isSSEStreamWriter: true,
|
|
80
|
+
send: (data) => this.handleRuntimeFrame(task.id, data, session),
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const finished = (async () => {
|
|
84
|
+
try {
|
|
85
|
+
await queryCodex(
|
|
86
|
+
promptText,
|
|
87
|
+
{
|
|
88
|
+
cwd: ctx.cwd,
|
|
89
|
+
permissionMode: ctx.permissionMode ?? 'default',
|
|
90
|
+
model: ctx.model,
|
|
91
|
+
},
|
|
92
|
+
fakeWriter,
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
if (this.active.has(task.id)) {
|
|
96
|
+
this.emitState(task.id, 'completed');
|
|
97
|
+
}
|
|
98
|
+
} catch (err) {
|
|
99
|
+
if (this.active.has(task.id)) {
|
|
100
|
+
this.emitState(task.id, 'failed', {
|
|
101
|
+
code: 'ADAPTER_RUNTIME_ERROR',
|
|
102
|
+
message: err instanceof Error ? err.message : String(err),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
} finally {
|
|
106
|
+
this.active.delete(task.id);
|
|
107
|
+
}
|
|
108
|
+
})();
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
cancel: () => this.cancelTask(task.id),
|
|
112
|
+
finished,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async cancelTask(taskId: string): Promise<void> {
|
|
117
|
+
const session = this.active.get(taskId);
|
|
118
|
+
if (!session) {
|
|
119
|
+
this.emitState(taskId, 'canceled');
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
this.active.delete(taskId);
|
|
124
|
+
if (session.sessionId) {
|
|
125
|
+
abortCodexSession(session.sessionId);
|
|
126
|
+
}
|
|
127
|
+
this.emitState(taskId, 'canceled');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private handleRuntimeFrame(
|
|
131
|
+
taskId: string,
|
|
132
|
+
frame: unknown,
|
|
133
|
+
session: { sessionId: string | null },
|
|
134
|
+
): void {
|
|
135
|
+
if (!frame || typeof frame !== 'object') return;
|
|
136
|
+
const message = frame as Partial<NormalizedMessage>;
|
|
137
|
+
|
|
138
|
+
if (
|
|
139
|
+
message.kind === 'session_created' &&
|
|
140
|
+
typeof message.newSessionId === 'string' &&
|
|
141
|
+
!session.sessionId
|
|
142
|
+
) {
|
|
143
|
+
session.sessionId = message.newSessionId;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
switch (message.kind) {
|
|
148
|
+
case 'text': {
|
|
149
|
+
const text = typeof message.content === 'string' ? message.content : null;
|
|
150
|
+
if (text && text.trim()) {
|
|
151
|
+
this.emitMessage(taskId, {
|
|
152
|
+
messageId: typeof message.id === 'string' ? message.id : newId('msg'),
|
|
153
|
+
role: message.role === 'user' ? 'user' : 'agent',
|
|
154
|
+
parts: [{ kind: 'text', text }],
|
|
155
|
+
taskId,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
case 'thinking': {
|
|
162
|
+
const text = typeof message.content === 'string' ? message.content : '';
|
|
163
|
+
this.emitArtifact(taskId, {
|
|
164
|
+
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
165
|
+
type: 'data',
|
|
166
|
+
parts: [{ kind: 'data', data: { kind: 'thinking', text } }],
|
|
167
|
+
metadata: { source: 'codex-thinking' },
|
|
168
|
+
});
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
case 'tool_use': {
|
|
173
|
+
this.emitArtifact(taskId, {
|
|
174
|
+
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
175
|
+
type: 'command-output',
|
|
176
|
+
parts: [
|
|
177
|
+
{
|
|
178
|
+
kind: 'data',
|
|
179
|
+
data: {
|
|
180
|
+
toolName: message.toolName,
|
|
181
|
+
toolInput: message.toolInput,
|
|
182
|
+
toolResult: message.toolResult,
|
|
183
|
+
output: message.output,
|
|
184
|
+
exitCode: message.exitCode,
|
|
185
|
+
status: message.status,
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
metadata: { source: 'codex-tool-use' },
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
case 'tool_result': {
|
|
195
|
+
this.emitArtifact(taskId, {
|
|
196
|
+
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
197
|
+
type: 'command-output',
|
|
198
|
+
parts: [
|
|
199
|
+
{
|
|
200
|
+
kind: 'data',
|
|
201
|
+
data: {
|
|
202
|
+
toolId: message.toolId,
|
|
203
|
+
content: message.content,
|
|
204
|
+
isError: message.isError,
|
|
205
|
+
toolUseResult: message.toolUseResult,
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
metadata: { source: 'codex-tool-result' },
|
|
210
|
+
});
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
case 'status':
|
|
215
|
+
case 'stream_delta':
|
|
216
|
+
case 'stream_end':
|
|
217
|
+
case 'complete':
|
|
218
|
+
case 'session_created':
|
|
219
|
+
return;
|
|
220
|
+
|
|
221
|
+
case 'error': {
|
|
222
|
+
const text =
|
|
223
|
+
typeof message.content === 'string' && message.content.length > 0
|
|
224
|
+
? message.content
|
|
225
|
+
: 'Codex reported an error';
|
|
226
|
+
this.emitState(taskId, 'failed', {
|
|
227
|
+
code: 'ADAPTER_RUNTIME_ERROR',
|
|
228
|
+
message: text,
|
|
229
|
+
});
|
|
230
|
+
this.active.delete(taskId);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
default: {
|
|
235
|
+
this.emitArtifact(taskId, {
|
|
236
|
+
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
237
|
+
type: 'data',
|
|
238
|
+
parts: [{ kind: 'data', data: message as Record<string, unknown> }],
|
|
239
|
+
metadata: { source: `codex-${String(message.kind ?? 'event')}` },
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
// server/modules/orchestration/a2a/adapters/cursor.adapter.ts
|
|
2
|
+
// Wraps the existing server/cursor-cli.js runtime, which emits
|
|
3
|
+
// provider-neutral NormalizedMessage frames over a writer interface.
|
|
4
|
+
|
|
5
|
+
import crypto from 'node:crypto';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line boundaries/no-unknown -- cursor-cli.js is a top-level CLI runtime not yet classified by eslint.config.js; cleanup deferred.
|
|
8
|
+
import { abortCursorSession, spawnCursor } from '@/cursor-cli.js';
|
|
9
|
+
import { AbstractA2AAdapter } from '@/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js';
|
|
10
|
+
import type {
|
|
11
|
+
AdapterContext,
|
|
12
|
+
TaskHandle,
|
|
13
|
+
} from '@/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js';
|
|
14
|
+
import type { AgentCard, Part, Task } from '@/modules/orchestration/a2a/types.js';
|
|
15
|
+
import type { NormalizedMessage } from '@/shared/types.js';
|
|
16
|
+
|
|
17
|
+
interface FakeWriter {
|
|
18
|
+
send(data: unknown): void;
|
|
19
|
+
getSessionId(): string | null;
|
|
20
|
+
setSessionId(sessionId: string): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function joinPartsToPrompt(parts: Part[]): string {
|
|
24
|
+
return parts
|
|
25
|
+
.map((part) => {
|
|
26
|
+
if (part.kind === 'text') return part.text;
|
|
27
|
+
if (part.kind === 'data') return JSON.stringify(part.data);
|
|
28
|
+
return `[file:${part.name}${part.uri ? ` uri=${part.uri}` : ''}]`;
|
|
29
|
+
})
|
|
30
|
+
.join('\n');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function newId(prefix: string): string {
|
|
34
|
+
return `${prefix}_${crypto.randomBytes(8).toString('hex')}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class CursorA2AAdapter extends AbstractA2AAdapter {
|
|
38
|
+
readonly id = 'cursor';
|
|
39
|
+
|
|
40
|
+
readonly agentCard: AgentCard = {
|
|
41
|
+
name: 'pixcode-cursor',
|
|
42
|
+
description: 'Cursor CLI, accessed via Pixcode',
|
|
43
|
+
url: '/a2a/agents/cursor',
|
|
44
|
+
version: '1.0.0',
|
|
45
|
+
capabilities: ['streaming', 'fileEdit', 'commandExec'],
|
|
46
|
+
skills: [
|
|
47
|
+
{
|
|
48
|
+
id: 'rapid-prototyping',
|
|
49
|
+
description: 'Fast implementation for coding tasks in Cursor CLI',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'reasoning-assist',
|
|
53
|
+
description: 'Emit reasoning and tool traces during execution',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'multi-file-refactor',
|
|
57
|
+
description: 'Coordinate edits across multiple files',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
authentication: { type: 'bearer' },
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
private readonly active = new Map<string, { sessionId: string | null }>();
|
|
64
|
+
|
|
65
|
+
async submitTask(task: Task, ctx: AdapterContext): Promise<TaskHandle> {
|
|
66
|
+
const promptText = joinPartsToPrompt(
|
|
67
|
+
task.history[task.history.length - 1]?.parts ?? [],
|
|
68
|
+
);
|
|
69
|
+
const session = { sessionId: null as string | null };
|
|
70
|
+
this.active.set(task.id, session);
|
|
71
|
+
|
|
72
|
+
this.emitState(task.id, 'working');
|
|
73
|
+
|
|
74
|
+
const fakeWriter: FakeWriter = {
|
|
75
|
+
send: (data) => this.handleRuntimeFrame(task.id, data, session),
|
|
76
|
+
getSessionId: () => session.sessionId,
|
|
77
|
+
setSessionId: (sessionId) => {
|
|
78
|
+
session.sessionId = sessionId;
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const finished = (async () => {
|
|
83
|
+
try {
|
|
84
|
+
await spawnCursor(
|
|
85
|
+
promptText,
|
|
86
|
+
{
|
|
87
|
+
cwd: ctx.cwd,
|
|
88
|
+
model: ctx.model,
|
|
89
|
+
toolsSettings: ctx.toolsSettings,
|
|
90
|
+
skipPermissions:
|
|
91
|
+
ctx.permissionMode === 'acceptEdits' || ctx.permissionMode === 'bypassPermissions',
|
|
92
|
+
},
|
|
93
|
+
fakeWriter,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
if (this.active.has(task.id)) {
|
|
97
|
+
this.emitState(task.id, 'completed');
|
|
98
|
+
}
|
|
99
|
+
} catch (err) {
|
|
100
|
+
if (this.active.has(task.id)) {
|
|
101
|
+
this.emitState(task.id, 'failed', {
|
|
102
|
+
code: 'ADAPTER_RUNTIME_ERROR',
|
|
103
|
+
message: err instanceof Error ? err.message : String(err),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
} finally {
|
|
107
|
+
this.active.delete(task.id);
|
|
108
|
+
}
|
|
109
|
+
})();
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
cancel: () => this.cancelTask(task.id),
|
|
113
|
+
finished,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async cancelTask(taskId: string): Promise<void> {
|
|
118
|
+
const session = this.active.get(taskId);
|
|
119
|
+
if (!session) {
|
|
120
|
+
this.emitState(taskId, 'canceled');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
this.active.delete(taskId);
|
|
125
|
+
if (session.sessionId) {
|
|
126
|
+
abortCursorSession(session.sessionId);
|
|
127
|
+
}
|
|
128
|
+
this.emitState(taskId, 'canceled');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private handleRuntimeFrame(
|
|
132
|
+
taskId: string,
|
|
133
|
+
frame: unknown,
|
|
134
|
+
session: { sessionId: string | null },
|
|
135
|
+
): void {
|
|
136
|
+
if (!frame || typeof frame !== 'object') return;
|
|
137
|
+
const message = frame as Partial<NormalizedMessage>;
|
|
138
|
+
|
|
139
|
+
if (
|
|
140
|
+
message.kind === 'session_created' &&
|
|
141
|
+
typeof message.newSessionId === 'string' &&
|
|
142
|
+
!session.sessionId
|
|
143
|
+
) {
|
|
144
|
+
session.sessionId = message.newSessionId;
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
switch (message.kind) {
|
|
149
|
+
case 'stream_delta':
|
|
150
|
+
case 'text': {
|
|
151
|
+
const text = typeof message.content === 'string' ? message.content : null;
|
|
152
|
+
if (text && text.trim()) {
|
|
153
|
+
this.emitMessage(taskId, {
|
|
154
|
+
messageId: typeof message.id === 'string' ? message.id : newId('msg'),
|
|
155
|
+
role: message.role === 'user' ? 'user' : 'agent',
|
|
156
|
+
parts: [{ kind: 'text', text }],
|
|
157
|
+
taskId,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
case 'thinking': {
|
|
164
|
+
this.emitArtifact(taskId, {
|
|
165
|
+
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
166
|
+
type: 'data',
|
|
167
|
+
parts: [
|
|
168
|
+
{
|
|
169
|
+
kind: 'data',
|
|
170
|
+
data: {
|
|
171
|
+
kind: 'thinking',
|
|
172
|
+
content: message.content,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
metadata: { source: 'cursor-thinking' },
|
|
177
|
+
});
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
case 'tool_use': {
|
|
182
|
+
this.emitArtifact(taskId, {
|
|
183
|
+
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
184
|
+
type: 'command-output',
|
|
185
|
+
parts: [
|
|
186
|
+
{
|
|
187
|
+
kind: 'data',
|
|
188
|
+
data: {
|
|
189
|
+
toolName: message.toolName,
|
|
190
|
+
toolInput: message.toolInput,
|
|
191
|
+
toolId: message.toolId,
|
|
192
|
+
toolResult: message.toolResult,
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
metadata: { source: 'cursor-tool-use' },
|
|
197
|
+
});
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
case 'tool_result': {
|
|
202
|
+
this.emitArtifact(taskId, {
|
|
203
|
+
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
204
|
+
type: 'command-output',
|
|
205
|
+
parts: [
|
|
206
|
+
{
|
|
207
|
+
kind: 'data',
|
|
208
|
+
data: {
|
|
209
|
+
toolId: message.toolId,
|
|
210
|
+
content: message.content,
|
|
211
|
+
isError: message.isError,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
metadata: { source: 'cursor-tool-result' },
|
|
216
|
+
});
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
case 'status':
|
|
221
|
+
case 'stream_end':
|
|
222
|
+
case 'complete':
|
|
223
|
+
case 'session_created':
|
|
224
|
+
return;
|
|
225
|
+
|
|
226
|
+
case 'error': {
|
|
227
|
+
const text =
|
|
228
|
+
typeof message.content === 'string' && message.content.length > 0
|
|
229
|
+
? message.content
|
|
230
|
+
: 'Cursor reported an error';
|
|
231
|
+
this.emitState(taskId, 'failed', {
|
|
232
|
+
code: 'ADAPTER_RUNTIME_ERROR',
|
|
233
|
+
message: text,
|
|
234
|
+
});
|
|
235
|
+
this.active.delete(taskId);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
default: {
|
|
240
|
+
this.emitArtifact(taskId, {
|
|
241
|
+
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
242
|
+
type: 'data',
|
|
243
|
+
parts: [{ kind: 'data', data: message as Record<string, unknown> }],
|
|
244
|
+
metadata: { source: `cursor-${String(message.kind ?? 'event')}` },
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|