@pixelbyte-software/pixcode 1.54.11 → 1.55.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.
Files changed (165) hide show
  1. package/dist/assets/{index-Bcqs_1vc.js → index-B-ySsQqi.js} +147 -147
  2. package/dist/assets/index-CWO38aJI.css +32 -0
  3. package/dist/index.html +2 -2
  4. package/dist-server/server/claude-sdk.js +1 -1
  5. package/dist-server/server/claude-sdk.js.map +1 -1
  6. package/dist-server/server/index.js +6 -11
  7. package/dist-server/server/index.js.map +1 -1
  8. package/dist-server/server/modules/security/permission-policy.js.map +1 -0
  9. package/dist-server/server/services/control-room.js +9 -1
  10. package/dist-server/server/services/control-room.js.map +1 -1
  11. package/dist-server/server/services/public-api-manifest.js +5 -5
  12. package/dist-server/server/services/public-api-manifest.js.map +1 -1
  13. package/dist-server/server/services/telegram/control-center.js +10 -10
  14. package/dist-server/server/services/telegram/control-center.js.map +1 -1
  15. package/dist-server/server/services/telegram/telegram-gateway.js +2 -2
  16. package/dist-server/server/services/telegram/telegram-gateway.js.map +1 -1
  17. package/dist-server/server/services/telegram/translations.js +5 -5
  18. package/dist-server/server/services/telegram/translations.js.map +1 -1
  19. package/package.json +1 -1
  20. package/server/claude-sdk.js +1 -1
  21. package/server/index.js +6 -23
  22. package/server/services/control-room.js +10 -1
  23. package/server/services/public-api-manifest.js +5 -5
  24. package/server/services/telegram/control-center.js +10 -10
  25. package/server/services/telegram/telegram-gateway.js +2 -2
  26. package/server/services/telegram/translations.js +5 -5
  27. package/dist/assets/index-Dz1luE0u.css +0 -32
  28. package/dist-server/server/modules/orchestration/a2a/adapter-registry.js +0 -73
  29. package/dist-server/server/modules/orchestration/a2a/adapter-registry.js.map +0 -1
  30. package/dist-server/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js +0 -17
  31. package/dist-server/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js.map +0 -1
  32. package/dist-server/server/modules/orchestration/a2a/adapters/claude-code.adapter.js +0 -236
  33. package/dist-server/server/modules/orchestration/a2a/adapters/claude-code.adapter.js.map +0 -1
  34. package/dist-server/server/modules/orchestration/a2a/adapters/codex.adapter.js +0 -202
  35. package/dist-server/server/modules/orchestration/a2a/adapters/codex.adapter.js.map +0 -1
  36. package/dist-server/server/modules/orchestration/a2a/adapters/cursor.adapter.js +0 -205
  37. package/dist-server/server/modules/orchestration/a2a/adapters/cursor.adapter.js.map +0 -1
  38. package/dist-server/server/modules/orchestration/a2a/adapters/gemini.adapter.js +0 -205
  39. package/dist-server/server/modules/orchestration/a2a/adapters/gemini.adapter.js.map +0 -1
  40. package/dist-server/server/modules/orchestration/a2a/adapters/json-event.adapter.js +0 -84
  41. package/dist-server/server/modules/orchestration/a2a/adapters/json-event.adapter.js.map +0 -1
  42. package/dist-server/server/modules/orchestration/a2a/adapters/json-event.adapter.test.js +0 -43
  43. package/dist-server/server/modules/orchestration/a2a/adapters/json-event.adapter.test.js.map +0 -1
  44. package/dist-server/server/modules/orchestration/a2a/adapters/opencode.adapter.js +0 -205
  45. package/dist-server/server/modules/orchestration/a2a/adapters/opencode.adapter.js.map +0 -1
  46. package/dist-server/server/modules/orchestration/a2a/adapters/qwen.adapter.js +0 -205
  47. package/dist-server/server/modules/orchestration/a2a/adapters/qwen.adapter.js.map +0 -1
  48. package/dist-server/server/modules/orchestration/a2a/agent-card.js +0 -50
  49. package/dist-server/server/modules/orchestration/a2a/agent-card.js.map +0 -1
  50. package/dist-server/server/modules/orchestration/a2a/auth.middleware.js +0 -25
  51. package/dist-server/server/modules/orchestration/a2a/auth.middleware.js.map +0 -1
  52. package/dist-server/server/modules/orchestration/a2a/bus.js +0 -34
  53. package/dist-server/server/modules/orchestration/a2a/bus.js.map +0 -1
  54. package/dist-server/server/modules/orchestration/a2a/routes.js +0 -502
  55. package/dist-server/server/modules/orchestration/a2a/routes.js.map +0 -1
  56. package/dist-server/server/modules/orchestration/a2a/task-dispatcher.js +0 -295
  57. package/dist-server/server/modules/orchestration/a2a/task-dispatcher.js.map +0 -1
  58. package/dist-server/server/modules/orchestration/a2a/task-store.js +0 -144
  59. package/dist-server/server/modules/orchestration/a2a/task-store.js.map +0 -1
  60. package/dist-server/server/modules/orchestration/a2a/types.js +0 -6
  61. package/dist-server/server/modules/orchestration/a2a/types.js.map +0 -1
  62. package/dist-server/server/modules/orchestration/a2a/validator.js +0 -101
  63. package/dist-server/server/modules/orchestration/a2a/validator.js.map +0 -1
  64. package/dist-server/server/modules/orchestration/index.js +0 -27
  65. package/dist-server/server/modules/orchestration/index.js.map +0 -1
  66. package/dist-server/server/modules/orchestration/preview/port-watcher.js +0 -90
  67. package/dist-server/server/modules/orchestration/preview/port-watcher.js.map +0 -1
  68. package/dist-server/server/modules/orchestration/preview/preview-proxy.js +0 -58
  69. package/dist-server/server/modules/orchestration/preview/preview-proxy.js.map +0 -1
  70. package/dist-server/server/modules/orchestration/preview/types.js +0 -2
  71. package/dist-server/server/modules/orchestration/preview/types.js.map +0 -1
  72. package/dist-server/server/modules/orchestration/security/permission-policy.js.map +0 -1
  73. package/dist-server/server/modules/orchestration/tasks/orchestration-task-store.js +0 -34
  74. package/dist-server/server/modules/orchestration/tasks/orchestration-task-store.js.map +0 -1
  75. package/dist-server/server/modules/orchestration/tasks/orchestration-task.routes.js +0 -70
  76. package/dist-server/server/modules/orchestration/tasks/orchestration-task.routes.js.map +0 -1
  77. package/dist-server/server/modules/orchestration/tasks/orchestration-task.service.js +0 -181
  78. package/dist-server/server/modules/orchestration/tasks/orchestration-task.service.js.map +0 -1
  79. package/dist-server/server/modules/orchestration/tasks/orchestration-task.types.js +0 -2
  80. package/dist-server/server/modules/orchestration/tasks/orchestration-task.types.js.map +0 -1
  81. package/dist-server/server/modules/orchestration/tasks/task-run-graph.js +0 -100
  82. package/dist-server/server/modules/orchestration/tasks/task-run-graph.js.map +0 -1
  83. package/dist-server/server/modules/orchestration/workflows/approval-queue.js +0 -72
  84. package/dist-server/server/modules/orchestration/workflows/approval-queue.js.map +0 -1
  85. package/dist-server/server/modules/orchestration/workflows/built-in-workflows.js +0 -126
  86. package/dist-server/server/modules/orchestration/workflows/built-in-workflows.js.map +0 -1
  87. package/dist-server/server/modules/orchestration/workflows/context-packet.js +0 -89
  88. package/dist-server/server/modules/orchestration/workflows/context-packet.js.map +0 -1
  89. package/dist-server/server/modules/orchestration/workflows/handoff-artifact.js +0 -123
  90. package/dist-server/server/modules/orchestration/workflows/handoff-artifact.js.map +0 -1
  91. package/dist-server/server/modules/orchestration/workflows/workflow-fallback-policy.js +0 -114
  92. package/dist-server/server/modules/orchestration/workflows/workflow-fallback-policy.js.map +0 -1
  93. package/dist-server/server/modules/orchestration/workflows/workflow-replay.js +0 -177
  94. package/dist-server/server/modules/orchestration/workflows/workflow-replay.js.map +0 -1
  95. package/dist-server/server/modules/orchestration/workflows/workflow-runner.js +0 -1718
  96. package/dist-server/server/modules/orchestration/workflows/workflow-runner.js.map +0 -1
  97. package/dist-server/server/modules/orchestration/workflows/workflow-store.js +0 -76
  98. package/dist-server/server/modules/orchestration/workflows/workflow-store.js.map +0 -1
  99. package/dist-server/server/modules/orchestration/workflows/workflow-templates.js +0 -242
  100. package/dist-server/server/modules/orchestration/workflows/workflow-templates.js.map +0 -1
  101. package/dist-server/server/modules/orchestration/workflows/workflow-trace.js +0 -388
  102. package/dist-server/server/modules/orchestration/workflows/workflow-trace.js.map +0 -1
  103. package/dist-server/server/modules/orchestration/workflows/workflow.routes.js +0 -508
  104. package/dist-server/server/modules/orchestration/workflows/workflow.routes.js.map +0 -1
  105. package/dist-server/server/modules/orchestration/workflows/workflow.types.js +0 -2
  106. package/dist-server/server/modules/orchestration/workflows/workflow.types.js.map +0 -1
  107. package/dist-server/server/modules/orchestration/workflows/workspace-target.js +0 -100
  108. package/dist-server/server/modules/orchestration/workflows/workspace-target.js.map +0 -1
  109. package/dist-server/server/modules/orchestration/workspace/docker-workspace.js +0 -123
  110. package/dist-server/server/modules/orchestration/workspace/docker-workspace.js.map +0 -1
  111. package/dist-server/server/modules/orchestration/workspace/path-safety.js +0 -48
  112. package/dist-server/server/modules/orchestration/workspace/path-safety.js.map +0 -1
  113. package/dist-server/server/modules/orchestration/workspace/types.js +0 -11
  114. package/dist-server/server/modules/orchestration/workspace/types.js.map +0 -1
  115. package/dist-server/server/modules/orchestration/workspace/workspace-manager.js +0 -84
  116. package/dist-server/server/modules/orchestration/workspace/workspace-manager.js.map +0 -1
  117. package/dist-server/server/modules/orchestration/workspace/worktree-workspace.js +0 -97
  118. package/dist-server/server/modules/orchestration/workspace/worktree-workspace.js.map +0 -1
  119. package/server/modules/orchestration/a2a/adapter-registry.ts +0 -108
  120. package/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.ts +0 -63
  121. package/server/modules/orchestration/a2a/adapters/claude-code.adapter.ts +0 -286
  122. package/server/modules/orchestration/a2a/adapters/codex.adapter.ts +0 -244
  123. package/server/modules/orchestration/a2a/adapters/cursor.adapter.ts +0 -249
  124. package/server/modules/orchestration/a2a/adapters/gemini.adapter.ts +0 -248
  125. package/server/modules/orchestration/a2a/adapters/json-event.adapter.test.ts +0 -60
  126. package/server/modules/orchestration/a2a/adapters/json-event.adapter.ts +0 -101
  127. package/server/modules/orchestration/a2a/adapters/opencode.adapter.ts +0 -248
  128. package/server/modules/orchestration/a2a/adapters/qwen.adapter.ts +0 -248
  129. package/server/modules/orchestration/a2a/agent-card.ts +0 -55
  130. package/server/modules/orchestration/a2a/auth.middleware.ts +0 -29
  131. package/server/modules/orchestration/a2a/bus.ts +0 -46
  132. package/server/modules/orchestration/a2a/routes.ts +0 -586
  133. package/server/modules/orchestration/a2a/task-dispatcher.ts +0 -345
  134. package/server/modules/orchestration/a2a/task-store.ts +0 -178
  135. package/server/modules/orchestration/a2a/types.ts +0 -126
  136. package/server/modules/orchestration/a2a/validator.ts +0 -113
  137. package/server/modules/orchestration/index.ts +0 -99
  138. package/server/modules/orchestration/preview/port-watcher.ts +0 -112
  139. package/server/modules/orchestration/preview/preview-proxy.ts +0 -60
  140. package/server/modules/orchestration/preview/types.ts +0 -19
  141. package/server/modules/orchestration/tasks/orchestration-task-store.ts +0 -41
  142. package/server/modules/orchestration/tasks/orchestration-task.routes.ts +0 -81
  143. package/server/modules/orchestration/tasks/orchestration-task.service.ts +0 -201
  144. package/server/modules/orchestration/tasks/orchestration-task.types.ts +0 -40
  145. package/server/modules/orchestration/tasks/task-run-graph.ts +0 -155
  146. package/server/modules/orchestration/workflows/approval-queue.ts +0 -106
  147. package/server/modules/orchestration/workflows/built-in-workflows.ts +0 -127
  148. package/server/modules/orchestration/workflows/context-packet.ts +0 -186
  149. package/server/modules/orchestration/workflows/handoff-artifact.ts +0 -175
  150. package/server/modules/orchestration/workflows/workflow-fallback-policy.ts +0 -161
  151. package/server/modules/orchestration/workflows/workflow-replay.ts +0 -254
  152. package/server/modules/orchestration/workflows/workflow-runner.ts +0 -2062
  153. package/server/modules/orchestration/workflows/workflow-store.ts +0 -97
  154. package/server/modules/orchestration/workflows/workflow-templates.ts +0 -272
  155. package/server/modules/orchestration/workflows/workflow-trace.ts +0 -424
  156. package/server/modules/orchestration/workflows/workflow.routes.ts +0 -586
  157. package/server/modules/orchestration/workflows/workflow.types.ts +0 -111
  158. package/server/modules/orchestration/workflows/workspace-target.ts +0 -122
  159. package/server/modules/orchestration/workspace/docker-workspace.ts +0 -136
  160. package/server/modules/orchestration/workspace/path-safety.ts +0 -55
  161. package/server/modules/orchestration/workspace/types.ts +0 -52
  162. package/server/modules/orchestration/workspace/workspace-manager.ts +0 -102
  163. package/server/modules/orchestration/workspace/worktree-workspace.ts +0 -126
  164. /package/dist-server/server/modules/{orchestration/security → security}/permission-policy.js +0 -0
  165. /package/server/modules/{orchestration/security → security}/permission-policy.ts +0 -0
@@ -1,249 +0,0 @@
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: '/api/orchestration/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
- }
@@ -1,248 +0,0 @@
1
- // server/modules/orchestration/a2a/adapters/gemini.adapter.ts
2
- // Wraps the existing server/gemini-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 -- gemini-cli.js is a top-level CLI runtime not yet classified by eslint.config.js; cleanup deferred.
8
- import { abortGeminiSession, spawnGemini } from '@/gemini-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 GeminiA2AAdapter extends AbstractA2AAdapter {
38
- readonly id = 'gemini';
39
-
40
- readonly agentCard: AgentCard = {
41
- name: 'pixcode-gemini',
42
- description: 'Google Gemini CLI, accessed via Pixcode',
43
- url: '/api/orchestration/agents/gemini',
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 spawnGemini(
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
- abortGeminiSession(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: 'gemini-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: 'gemini-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: 'gemini-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
- : 'Gemini 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: `gemini-${String(message.kind ?? 'event')}` },
244
- });
245
- }
246
- }
247
- }
248
- }
@@ -1,60 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import test, { beforeEach } from 'node:test';
3
-
4
- import { a2aBus } from '@/modules/orchestration/a2a/bus.js';
5
- import type { Task } from '@/modules/orchestration/a2a/types.js';
6
-
7
- import { JsonEventA2AAdapter } from './json-event.adapter.js';
8
- import type { AdapterContext } from './abstract-a2a.adapter.js';
9
-
10
- // Capture bus events by monkeypatching publish — the repo has no test runner
11
- // with module mocking (node:test style, see providers/tests/mcp.test.ts).
12
- const publishedEvents: any[] = [];
13
- const originalPublish = a2aBus.publish.bind(a2aBus);
14
- (a2aBus as any).publish = (event: any) => {
15
- publishedEvents.push(event);
16
- };
17
-
18
- void originalPublish; // retained for symmetry; process exits after tests
19
-
20
- beforeEach(() => {
21
- publishedEvents.length = 0;
22
- });
23
-
24
- const makeTask = (id: string): Task => ({ id, history: [], artifacts: [] } as any);
25
- const ctx = { cwd: '/tmp' } as unknown as AdapterContext;
26
-
27
- test('JsonEventA2AAdapter initializes task state to working', async () => {
28
- const adapter = new JsonEventA2AAdapter();
29
- await adapter.submitTask(makeTask('test-task'), ctx);
30
-
31
- const stateEvent = publishedEvents.find((event) => event.kind === 'task-state');
32
- assert.ok(stateEvent, 'expected a task-state event');
33
- assert.equal(stateEvent.taskId, 'test-task');
34
- assert.equal(stateEvent.state, 'working');
35
- });
36
-
37
- test('JsonEventA2AAdapter handles external text events', async () => {
38
- const adapter = new JsonEventA2AAdapter();
39
- await adapter.submitTask(makeTask('test-task'), ctx);
40
-
41
- adapter.handleExternalEvent('test-task', { kind: 'text', text: 'Hello World' });
42
-
43
- const messageEvent = publishedEvents.find((event) => event.kind === 'message');
44
- assert.ok(messageEvent, 'expected a message event');
45
- assert.equal(messageEvent.taskId, 'test-task');
46
- assert.deepEqual(messageEvent.message.parts, [{ kind: 'text', text: 'Hello World' }]);
47
- });
48
-
49
- test('JsonEventA2AAdapter transitions to completed on terminal event', async () => {
50
- const adapter = new JsonEventA2AAdapter();
51
- await adapter.submitTask(makeTask('test-task'), ctx);
52
-
53
- adapter.handleExternalEvent('test-task', { kind: 'completed' });
54
-
55
- const completedEvent = publishedEvents.find(
56
- (event) => event.kind === 'task-state' && event.state === 'completed',
57
- );
58
- assert.ok(completedEvent, 'expected a completed task-state event');
59
- assert.equal(completedEvent.taskId, 'test-task');
60
- });
@@ -1,101 +0,0 @@
1
- // server/modules/orchestration/a2a/adapters/json-event.adapter.ts
2
- // A specialty adapter that consumes JSON event streams from external providers
3
- // and translates them into the A2A bus protocol.
4
-
5
- import crypto from 'node:crypto';
6
-
7
- import { AbstractA2AAdapter } from '@/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js';
8
- import type {
9
- AdapterContext,
10
- TaskHandle,
11
- } from '@/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js';
12
- import type { AgentCard, Task } from '@/modules/orchestration/a2a/types.js';
13
-
14
- function newId(prefix: string): string {
15
- return `${prefix}_${crypto.randomBytes(8).toString('hex')}`;
16
- }
17
-
18
- export class JsonEventA2AAdapter extends AbstractA2AAdapter {
19
- readonly id = 'json-event';
20
-
21
- readonly agentCard: AgentCard = {
22
- name: 'pixcode-json-event',
23
- description: 'JSON Event Stream Adapter for Pixcode Orchestration',
24
- url: '/api/orchestration/agents/json-event',
25
- version: '1.0.0',
26
- capabilities: ['streaming', 'event-driven'],
27
- skills: [
28
- {
29
- id: 'event-processing',
30
- description: 'Process external JSON event streams and map them to task progress',
31
- },
32
- ],
33
- authentication: { type: 'bearer' },
34
- };
35
-
36
- private readonly active = new Set<string>();
37
-
38
- async submitTask(task: Task, _ctx: AdapterContext): Promise<TaskHandle> {
39
- this.active.add(task.id);
40
- this.emitState(task.id, 'working');
41
-
42
- // This is a specialty adapter; the actual event ingestion happens
43
- // externally (e.g. via an ingest endpoint) which publishes to the bus.
44
-
45
- const finished = (async () => {
46
- // Lifecycle managed by external events
47
- })();
48
-
49
- return {
50
- cancel: () => this.cancelTask(task.id),
51
- finished,
52
- };
53
- }
54
-
55
- async cancelTask(taskId: string): Promise<void> {
56
- if (this.active.has(taskId)) {
57
- this.active.delete(taskId);
58
- this.emitState(taskId, 'canceled');
59
- }
60
- }
61
-
62
- /**
63
- * External event handlers call this to bridge native JSON events to A2A.
64
- */
65
- handleExternalEvent(taskId: string, event: Record<string, unknown>): void {
66
- if (!this.active.has(taskId)) return;
67
-
68
- const kind = event.kind || event.type;
69
-
70
- switch (kind) {
71
- case 'message':
72
- case 'text':
73
- this.emitMessage(taskId, {
74
- messageId: newId('msg'),
75
- role: 'agent',
76
- parts: [{ kind: 'text', text: String(event.text || event.content || '') }],
77
- taskId,
78
- });
79
- break;
80
- case 'artifact':
81
- this.emitArtifact(taskId, {
82
- artifactId: newId('art'),
83
- type: (event.artifactType as any) || 'data',
84
- parts: [{ kind: 'data', data: event.data as Record<string, unknown> }],
85
- metadata: { source: 'external-json-event' },
86
- });
87
- break;
88
- case 'completed':
89
- this.emitState(taskId, 'completed');
90
- this.active.delete(taskId);
91
- break;
92
- case 'failed':
93
- this.emitState(taskId, 'failed', {
94
- code: String(event.errorCode || 'EXTERNAL_ERROR'),
95
- message: String(event.errorMessage || 'External event reported failure'),
96
- });
97
- this.active.delete(taskId);
98
- break;
99
- }
100
- }
101
- }