@pixelbyte-software/pixcode 1.35.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 -548
- package/dist/assets/{index-Djuh0wHV.js → index-CBdsvGSR.js} +133 -133
- package/dist/clear-cache.html +85 -85
- package/dist/convert-icons.md +52 -52
- 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/qwen-logo.svg +14 -14
- package/dist/index.html +58 -58
- package/dist/manifest.json +60 -60
- package/dist/openapi.yaml +1693 -1693
- package/dist/sw.js +124 -124
- package/dist-server/server/cli.js +96 -96
- package/dist-server/server/daemon/manager.js +33 -33
- package/dist-server/server/daemon-manager.js +64 -64
- package/dist-server/server/modules/orchestration/preview/preview-proxy.js +3 -3
- package/dist-server/server/modules/orchestration/preview/preview-proxy.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 +419 -419
- package/package.json +180 -180
- package/scripts/fix-node-pty.js +67 -67
- package/scripts/smoke/a2a-roundtrip.mjs +167 -167
- package/scripts/smoke/orchestration-api.mjs +172 -172
- package/scripts/smoke/orchestration-live-run.mjs +176 -176
- package/server/claude-sdk.js +898 -898
- package/server/cli.js +935 -935
- 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 -959
- package/server/database/json-store.js +197 -197
- package/server/gemini-cli.js +535 -535
- package/server/gemini-response-handler.js +79 -79
- package/server/index.js +3135 -3135
- package/server/load-env.js +34 -34
- package/server/middleware/auth.js +173 -173
- package/server/modules/orchestration/a2a/adapter-registry.ts +108 -108
- package/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.ts +55 -55
- package/server/modules/orchestration/a2a/adapters/claude-code.adapter.ts +284 -284
- package/server/modules/orchestration/a2a/adapters/codex.adapter.ts +244 -244
- package/server/modules/orchestration/a2a/adapters/cursor.adapter.ts +249 -249
- package/server/modules/orchestration/a2a/adapters/gemini.adapter.ts +248 -248
- package/server/modules/orchestration/a2a/adapters/opencode.adapter.ts +248 -248
- package/server/modules/orchestration/a2a/adapters/qwen.adapter.ts +248 -248
- package/server/modules/orchestration/a2a/agent-card.ts +55 -55
- package/server/modules/orchestration/a2a/auth.middleware.ts +29 -29
- package/server/modules/orchestration/a2a/bus.ts +46 -46
- package/server/modules/orchestration/a2a/routes.ts +577 -577
- package/server/modules/orchestration/a2a/task-store.ts +178 -178
- package/server/modules/orchestration/a2a/types.ts +125 -125
- package/server/modules/orchestration/a2a/validator.ts +113 -113
- package/server/modules/orchestration/index.ts +66 -66
- package/server/modules/orchestration/preview/port-watcher.ts +112 -112
- package/server/modules/orchestration/preview/preview-proxy.ts +60 -60
- package/server/modules/orchestration/preview/types.ts +19 -19
- package/server/modules/orchestration/tasks/orchestration-task-store.ts +45 -45
- package/server/modules/orchestration/tasks/orchestration-task.routes.ts +73 -73
- package/server/modules/orchestration/tasks/orchestration-task.service.ts +145 -145
- package/server/modules/orchestration/tasks/orchestration-task.types.ts +29 -29
- package/server/modules/orchestration/workflows/built-in-workflows.ts +127 -127
- package/server/modules/orchestration/workflows/workflow-runner.ts +1206 -1206
- package/server/modules/orchestration/workflows/workflow-store.ts +97 -97
- package/server/modules/orchestration/workflows/workflow.routes.ts +169 -169
- package/server/modules/orchestration/workflows/workflow.types.ts +70 -70
- package/server/modules/orchestration/workflows/workspace-target.ts +120 -120
- package/server/modules/orchestration/workspace/docker-workspace.ts +135 -135
- package/server/modules/orchestration/workspace/path-safety.ts +55 -55
- package/server/modules/orchestration/workspace/types.ts +52 -52
- package/server/modules/orchestration/workspace/workspace-manager.ts +97 -97
- package/server/modules/orchestration/workspace/worktree-workspace.ts +125 -125
- package/server/modules/providers/index.ts +2 -2
- 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-sessions.provider.ts +232 -232
- package/server/modules/providers/list/qwen/qwen-sessions.provider.ts +265 -265
- 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/tests/mcp.test.ts +293 -293
- package/server/openai-codex.js +462 -462
- package/server/opencode-cli.js +459 -459
- package/server/opencode-response-handler.js +107 -107
- package/server/projects.js +3105 -3105
- 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/settings.js +286 -286
- package/server/routes/taskmaster.js +1496 -1496
- package/server/routes/telegram.js +125 -125
- package/server/routes/user.js +123 -123
- 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/telegram/bot.js +279 -279
- package/server/services/telegram/translations.js +170 -170
- 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/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
|
@@ -1,248 +1,248 @@
|
|
|
1
|
-
// server/modules/orchestration/a2a/adapters/qwen.adapter.ts
|
|
2
|
-
// Wraps the existing server/qwen-code-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 -- qwen-code-cli.js is a top-level CLI runtime not yet classified by eslint.config.js; cleanup deferred.
|
|
8
|
-
import { abortQwenSession, spawnQwen } from '@/qwen-code-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 QwenA2AAdapter extends AbstractA2AAdapter {
|
|
38
|
-
readonly id = 'qwen';
|
|
39
|
-
|
|
40
|
-
readonly agentCard: AgentCard = {
|
|
41
|
-
name: 'pixcode-qwen',
|
|
42
|
-
description: 'Qwen Code CLI, accessed via Pixcode',
|
|
43
|
-
url: '/a2a/agents/qwen',
|
|
44
|
-
version: '1.0.0',
|
|
45
|
-
capabilities: ['streaming', 'fileEdit', 'commandExec', 'mcp'],
|
|
46
|
-
skills: [
|
|
47
|
-
{
|
|
48
|
-
id: 'rapid-prototyping',
|
|
49
|
-
description: 'Fast implementation and iteration for coding tasks',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
id: 'tool-augmented-editing',
|
|
53
|
-
description: 'Use CLI tools and MCP servers while editing code',
|
|
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 spawnQwen(
|
|
85
|
-
promptText,
|
|
86
|
-
{
|
|
87
|
-
cwd: ctx.cwd,
|
|
88
|
-
model: ctx.model,
|
|
89
|
-
permissionMode: ctx.permissionMode === 'bypassPermissions' ? 'yolo' : ctx.permissionMode,
|
|
90
|
-
toolsSettings: ctx.toolsSettings,
|
|
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
|
-
abortQwenSession(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 'stream_delta':
|
|
149
|
-
case 'text': {
|
|
150
|
-
const text = typeof message.content === 'string' ? message.content : null;
|
|
151
|
-
if (text && text.trim()) {
|
|
152
|
-
this.emitMessage(taskId, {
|
|
153
|
-
messageId: typeof message.id === 'string' ? message.id : newId('msg'),
|
|
154
|
-
role: 'agent',
|
|
155
|
-
parts: [{ kind: 'text', text }],
|
|
156
|
-
taskId,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
case 'tool_use': {
|
|
163
|
-
this.emitArtifact(taskId, {
|
|
164
|
-
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
165
|
-
type: 'command-output',
|
|
166
|
-
parts: [
|
|
167
|
-
{
|
|
168
|
-
kind: 'data',
|
|
169
|
-
data: {
|
|
170
|
-
toolName: message.toolName,
|
|
171
|
-
toolInput: message.toolInput,
|
|
172
|
-
toolId: message.toolId,
|
|
173
|
-
toolResult: message.toolResult,
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
],
|
|
177
|
-
metadata: { source: 'qwen-tool-use' },
|
|
178
|
-
});
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
case 'tool_result': {
|
|
183
|
-
this.emitArtifact(taskId, {
|
|
184
|
-
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
185
|
-
type: 'command-output',
|
|
186
|
-
parts: [
|
|
187
|
-
{
|
|
188
|
-
kind: 'data',
|
|
189
|
-
data: {
|
|
190
|
-
toolId: message.toolId,
|
|
191
|
-
content: message.content,
|
|
192
|
-
isError: message.isError,
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
],
|
|
196
|
-
metadata: { source: 'qwen-tool-result' },
|
|
197
|
-
});
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
case 'status': {
|
|
202
|
-
this.emitArtifact(taskId, {
|
|
203
|
-
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
204
|
-
type: 'data',
|
|
205
|
-
parts: [
|
|
206
|
-
{
|
|
207
|
-
kind: 'data',
|
|
208
|
-
data: {
|
|
209
|
-
kind: 'status',
|
|
210
|
-
text: message.text,
|
|
211
|
-
tokens: message.tokens,
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
],
|
|
215
|
-
metadata: { source: 'qwen-status' },
|
|
216
|
-
});
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
case 'stream_end':
|
|
221
|
-
case 'complete':
|
|
222
|
-
case 'session_created':
|
|
223
|
-
return;
|
|
224
|
-
|
|
225
|
-
case 'error': {
|
|
226
|
-
const text =
|
|
227
|
-
typeof message.content === 'string' && message.content.length > 0
|
|
228
|
-
? message.content
|
|
229
|
-
: 'Qwen reported an error';
|
|
230
|
-
this.emitState(taskId, 'failed', {
|
|
231
|
-
code: 'ADAPTER_RUNTIME_ERROR',
|
|
232
|
-
message: text,
|
|
233
|
-
});
|
|
234
|
-
this.active.delete(taskId);
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
default: {
|
|
239
|
-
this.emitArtifact(taskId, {
|
|
240
|
-
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
241
|
-
type: 'data',
|
|
242
|
-
parts: [{ kind: 'data', data: message as Record<string, unknown> }],
|
|
243
|
-
metadata: { source: `qwen-${String(message.kind ?? 'event')}` },
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
1
|
+
// server/modules/orchestration/a2a/adapters/qwen.adapter.ts
|
|
2
|
+
// Wraps the existing server/qwen-code-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 -- qwen-code-cli.js is a top-level CLI runtime not yet classified by eslint.config.js; cleanup deferred.
|
|
8
|
+
import { abortQwenSession, spawnQwen } from '@/qwen-code-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 QwenA2AAdapter extends AbstractA2AAdapter {
|
|
38
|
+
readonly id = 'qwen';
|
|
39
|
+
|
|
40
|
+
readonly agentCard: AgentCard = {
|
|
41
|
+
name: 'pixcode-qwen',
|
|
42
|
+
description: 'Qwen Code CLI, accessed via Pixcode',
|
|
43
|
+
url: '/a2a/agents/qwen',
|
|
44
|
+
version: '1.0.0',
|
|
45
|
+
capabilities: ['streaming', 'fileEdit', 'commandExec', 'mcp'],
|
|
46
|
+
skills: [
|
|
47
|
+
{
|
|
48
|
+
id: 'rapid-prototyping',
|
|
49
|
+
description: 'Fast implementation and iteration for coding tasks',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'tool-augmented-editing',
|
|
53
|
+
description: 'Use CLI tools and MCP servers while editing code',
|
|
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 spawnQwen(
|
|
85
|
+
promptText,
|
|
86
|
+
{
|
|
87
|
+
cwd: ctx.cwd,
|
|
88
|
+
model: ctx.model,
|
|
89
|
+
permissionMode: ctx.permissionMode === 'bypassPermissions' ? 'yolo' : ctx.permissionMode,
|
|
90
|
+
toolsSettings: ctx.toolsSettings,
|
|
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
|
+
abortQwenSession(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 'stream_delta':
|
|
149
|
+
case 'text': {
|
|
150
|
+
const text = typeof message.content === 'string' ? message.content : null;
|
|
151
|
+
if (text && text.trim()) {
|
|
152
|
+
this.emitMessage(taskId, {
|
|
153
|
+
messageId: typeof message.id === 'string' ? message.id : newId('msg'),
|
|
154
|
+
role: 'agent',
|
|
155
|
+
parts: [{ kind: 'text', text }],
|
|
156
|
+
taskId,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
case 'tool_use': {
|
|
163
|
+
this.emitArtifact(taskId, {
|
|
164
|
+
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
165
|
+
type: 'command-output',
|
|
166
|
+
parts: [
|
|
167
|
+
{
|
|
168
|
+
kind: 'data',
|
|
169
|
+
data: {
|
|
170
|
+
toolName: message.toolName,
|
|
171
|
+
toolInput: message.toolInput,
|
|
172
|
+
toolId: message.toolId,
|
|
173
|
+
toolResult: message.toolResult,
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
metadata: { source: 'qwen-tool-use' },
|
|
178
|
+
});
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
case 'tool_result': {
|
|
183
|
+
this.emitArtifact(taskId, {
|
|
184
|
+
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
185
|
+
type: 'command-output',
|
|
186
|
+
parts: [
|
|
187
|
+
{
|
|
188
|
+
kind: 'data',
|
|
189
|
+
data: {
|
|
190
|
+
toolId: message.toolId,
|
|
191
|
+
content: message.content,
|
|
192
|
+
isError: message.isError,
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
metadata: { source: 'qwen-tool-result' },
|
|
197
|
+
});
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
case 'status': {
|
|
202
|
+
this.emitArtifact(taskId, {
|
|
203
|
+
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
204
|
+
type: 'data',
|
|
205
|
+
parts: [
|
|
206
|
+
{
|
|
207
|
+
kind: 'data',
|
|
208
|
+
data: {
|
|
209
|
+
kind: 'status',
|
|
210
|
+
text: message.text,
|
|
211
|
+
tokens: message.tokens,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
metadata: { source: 'qwen-status' },
|
|
216
|
+
});
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
case 'stream_end':
|
|
221
|
+
case 'complete':
|
|
222
|
+
case 'session_created':
|
|
223
|
+
return;
|
|
224
|
+
|
|
225
|
+
case 'error': {
|
|
226
|
+
const text =
|
|
227
|
+
typeof message.content === 'string' && message.content.length > 0
|
|
228
|
+
? message.content
|
|
229
|
+
: 'Qwen reported an error';
|
|
230
|
+
this.emitState(taskId, 'failed', {
|
|
231
|
+
code: 'ADAPTER_RUNTIME_ERROR',
|
|
232
|
+
message: text,
|
|
233
|
+
});
|
|
234
|
+
this.active.delete(taskId);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
default: {
|
|
239
|
+
this.emitArtifact(taskId, {
|
|
240
|
+
artifactId: typeof message.id === 'string' ? message.id : newId('art'),
|
|
241
|
+
type: 'data',
|
|
242
|
+
parts: [{ kind: 'data', data: message as Record<string, unknown> }],
|
|
243
|
+
metadata: { source: `qwen-${String(message.kind ?? 'event')}` },
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
// server/modules/orchestration/a2a/agent-card.ts
|
|
2
|
-
// Pixcode advertises itself as one A2A agent at /a2a/.well-known/agent-card.json.
|
|
3
|
-
// Per-CLI adapters publish their own cards under /a2a/agents/:id/agent-card.
|
|
4
|
-
|
|
5
|
-
import { readFileSync } from 'node:fs';
|
|
6
|
-
import { dirname, resolve } from 'node:path';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
|
|
9
|
-
import { adapterRegistry } from '@/modules/orchestration/a2a/adapter-registry.js';
|
|
10
|
-
import type { AgentCard } from '@/modules/orchestration/a2a/types.js';
|
|
11
|
-
|
|
12
|
-
// Resolve <repo-root>/package.json from this file's location.
|
|
13
|
-
// Source layout: server/modules/orchestration/a2a/agent-card.ts (4 levels deep from repo root)
|
|
14
|
-
// Built layout: dist-server/server/modules/orchestration/a2a/agent-card.js (5 levels deep)
|
|
15
|
-
// Walk up until a package.json containing "name":"@pixelbyte-software/pixcode" is found.
|
|
16
|
-
function readPixcodeVersion(): string {
|
|
17
|
-
let dir = dirname(fileURLToPath(import.meta.url));
|
|
18
|
-
for (let i = 0; i < 8; i++) {
|
|
19
|
-
try {
|
|
20
|
-
const candidate = resolve(dir, 'package.json');
|
|
21
|
-
const raw = readFileSync(candidate, 'utf8');
|
|
22
|
-
const pkg = JSON.parse(raw) as { name?: string; version?: string };
|
|
23
|
-
if (pkg.name === '@pixelbyte-software/pixcode' && typeof pkg.version === 'string') {
|
|
24
|
-
return pkg.version;
|
|
25
|
-
}
|
|
26
|
-
} catch {
|
|
27
|
-
// not here, walk up
|
|
28
|
-
}
|
|
29
|
-
const parent = dirname(dir);
|
|
30
|
-
if (parent === dir) break;
|
|
31
|
-
dir = parent;
|
|
32
|
-
}
|
|
33
|
-
return '0.0.0-dev';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const VERSION: string = readPixcodeVersion();
|
|
37
|
-
|
|
38
|
-
export function buildPixcodeAgentCard(baseUrl: string): AgentCard {
|
|
39
|
-
const skills = adapterRegistry
|
|
40
|
-
.agentCards()
|
|
41
|
-
.flatMap((card) => card.skills)
|
|
42
|
-
.filter((skill, idx, arr) => arr.findIndex((s) => s.id === skill.id) === idx);
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
name: 'pixcode',
|
|
46
|
-
description:
|
|
47
|
-
'Pixcode multi-CLI orchestration platform. Routes A2A tasks to ' +
|
|
48
|
-
'Claude Code, Codex, Cursor, Gemini, Qwen, or OpenCode adapters.',
|
|
49
|
-
url: `${baseUrl.replace(/\/$/, '')}/a2a`,
|
|
50
|
-
version: VERSION,
|
|
51
|
-
capabilities: ['streaming', 'taskRouting'],
|
|
52
|
-
skills,
|
|
53
|
-
authentication: { type: 'bearer' },
|
|
54
|
-
};
|
|
55
|
-
}
|
|
1
|
+
// server/modules/orchestration/a2a/agent-card.ts
|
|
2
|
+
// Pixcode advertises itself as one A2A agent at /a2a/.well-known/agent-card.json.
|
|
3
|
+
// Per-CLI adapters publish their own cards under /a2a/agents/:id/agent-card.
|
|
4
|
+
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { dirname, resolve } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
|
|
9
|
+
import { adapterRegistry } from '@/modules/orchestration/a2a/adapter-registry.js';
|
|
10
|
+
import type { AgentCard } from '@/modules/orchestration/a2a/types.js';
|
|
11
|
+
|
|
12
|
+
// Resolve <repo-root>/package.json from this file's location.
|
|
13
|
+
// Source layout: server/modules/orchestration/a2a/agent-card.ts (4 levels deep from repo root)
|
|
14
|
+
// Built layout: dist-server/server/modules/orchestration/a2a/agent-card.js (5 levels deep)
|
|
15
|
+
// Walk up until a package.json containing "name":"@pixelbyte-software/pixcode" is found.
|
|
16
|
+
function readPixcodeVersion(): string {
|
|
17
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
for (let i = 0; i < 8; i++) {
|
|
19
|
+
try {
|
|
20
|
+
const candidate = resolve(dir, 'package.json');
|
|
21
|
+
const raw = readFileSync(candidate, 'utf8');
|
|
22
|
+
const pkg = JSON.parse(raw) as { name?: string; version?: string };
|
|
23
|
+
if (pkg.name === '@pixelbyte-software/pixcode' && typeof pkg.version === 'string') {
|
|
24
|
+
return pkg.version;
|
|
25
|
+
}
|
|
26
|
+
} catch {
|
|
27
|
+
// not here, walk up
|
|
28
|
+
}
|
|
29
|
+
const parent = dirname(dir);
|
|
30
|
+
if (parent === dir) break;
|
|
31
|
+
dir = parent;
|
|
32
|
+
}
|
|
33
|
+
return '0.0.0-dev';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const VERSION: string = readPixcodeVersion();
|
|
37
|
+
|
|
38
|
+
export function buildPixcodeAgentCard(baseUrl: string): AgentCard {
|
|
39
|
+
const skills = adapterRegistry
|
|
40
|
+
.agentCards()
|
|
41
|
+
.flatMap((card) => card.skills)
|
|
42
|
+
.filter((skill, idx, arr) => arr.findIndex((s) => s.id === skill.id) === idx);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
name: 'pixcode',
|
|
46
|
+
description:
|
|
47
|
+
'Pixcode multi-CLI orchestration platform. Routes A2A tasks to ' +
|
|
48
|
+
'Claude Code, Codex, Cursor, Gemini, Qwen, or OpenCode adapters.',
|
|
49
|
+
url: `${baseUrl.replace(/\/$/, '')}/a2a`,
|
|
50
|
+
version: VERSION,
|
|
51
|
+
capabilities: ['streaming', 'taskRouting'],
|
|
52
|
+
skills,
|
|
53
|
+
authentication: { type: 'bearer' },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
// server/modules/orchestration/a2a/auth.middleware.ts
|
|
2
|
-
// Localhost callers bypass auth; everyone else needs a Bearer JWT
|
|
3
|
-
// validated by pixcode's existing auth stack.
|
|
4
|
-
|
|
5
|
-
import type { NextFunction, Request, Response } from 'express';
|
|
6
|
-
|
|
7
|
-
// @ts-ignore — plain-JS module without type declarations
|
|
8
|
-
// eslint-disable-next-line boundaries/no-unknown -- server/middleware/auth.js is a top-level auth runtime not yet classified by eslint.config.js; cleanup deferred.
|
|
9
|
-
import { authenticateToken } from '@/middleware/auth.js';
|
|
10
|
-
|
|
11
|
-
const LOCAL_HOSTS = new Set(['127.0.0.1', '::1', 'localhost', '::ffff:127.0.0.1']);
|
|
12
|
-
|
|
13
|
-
function isLocalRequest(req: Request): boolean {
|
|
14
|
-
const remote = req.socket.remoteAddress ?? '';
|
|
15
|
-
if (LOCAL_HOSTS.has(remote)) return true;
|
|
16
|
-
// Trust the X-Forwarded-For header only when the inbound socket is local
|
|
17
|
-
// (i.e. the reverse proxy itself is on the same host).
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function a2aAuth(req: Request, res: Response, next: NextFunction): void {
|
|
22
|
-
if (isLocalRequest(req)) {
|
|
23
|
-
next();
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
// Delegate to existing pixcode JWT middleware. authenticateToken
|
|
27
|
-
// populates req.user on success and 401s on failure.
|
|
28
|
-
authenticateToken(req, res, next);
|
|
29
|
-
}
|
|
1
|
+
// server/modules/orchestration/a2a/auth.middleware.ts
|
|
2
|
+
// Localhost callers bypass auth; everyone else needs a Bearer JWT
|
|
3
|
+
// validated by pixcode's existing auth stack.
|
|
4
|
+
|
|
5
|
+
import type { NextFunction, Request, Response } from 'express';
|
|
6
|
+
|
|
7
|
+
// @ts-ignore — plain-JS module without type declarations
|
|
8
|
+
// eslint-disable-next-line boundaries/no-unknown -- server/middleware/auth.js is a top-level auth runtime not yet classified by eslint.config.js; cleanup deferred.
|
|
9
|
+
import { authenticateToken } from '@/middleware/auth.js';
|
|
10
|
+
|
|
11
|
+
const LOCAL_HOSTS = new Set(['127.0.0.1', '::1', 'localhost', '::ffff:127.0.0.1']);
|
|
12
|
+
|
|
13
|
+
function isLocalRequest(req: Request): boolean {
|
|
14
|
+
const remote = req.socket.remoteAddress ?? '';
|
|
15
|
+
if (LOCAL_HOSTS.has(remote)) return true;
|
|
16
|
+
// Trust the X-Forwarded-For header only when the inbound socket is local
|
|
17
|
+
// (i.e. the reverse proxy itself is on the same host).
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function a2aAuth(req: Request, res: Response, next: NextFunction): void {
|
|
22
|
+
if (isLocalRequest(req)) {
|
|
23
|
+
next();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// Delegate to existing pixcode JWT middleware. authenticateToken
|
|
27
|
+
// populates req.user on success and 401s on failure.
|
|
28
|
+
authenticateToken(req, res, next);
|
|
29
|
+
}
|