@muyichengshayu/promptx 0.2.14 → 0.2.16

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 (50) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/apps/web/dist/assets/{CodexSessionManagerDialog-DD2XtFAl.js → CodexSessionManagerDialog-D1PwOD4T.js} +1 -1
  3. package/apps/web/dist/assets/{TaskDiffReviewDialog-CGLpQQ97.js → TaskDiffReviewDialog-GKKv-IkZ.js} +1 -1
  4. package/apps/web/dist/assets/{WorkbenchSettingsDialog-DxU55X3l.js → WorkbenchSettingsDialog-IWlkg3kU.js} +1 -1
  5. package/apps/web/dist/assets/{WorkbenchView-D1oxqNr4.css → WorkbenchView-CK1snPBz.css} +1 -1
  6. package/apps/web/dist/assets/WorkbenchView-dXHPTH_M.js +58 -0
  7. package/apps/web/dist/assets/{index-BLxPFky8.js → index-DaIoquOV.js} +2 -2
  8. package/apps/web/dist/index.html +1 -1
  9. package/package.json +21 -14
  10. package/apps/runner/src/engines/claudeCodeRunner.test.js +0 -467
  11. package/apps/runner/src/engines/kimiCodeRunner.test.js +0 -127
  12. package/apps/runner/src/engines/openCodeRunner.test.js +0 -236
  13. package/apps/runner/src/engines/runnerContract.test.js +0 -449
  14. package/apps/runner/src/engines/shellRunner.test.js +0 -46
  15. package/apps/runner/src/runManager.test.js +0 -913
  16. package/apps/runner/src/serverClient.test.js +0 -93
  17. package/apps/server/src/agentSessionDiscovery.test.js +0 -572
  18. package/apps/server/src/appPaths.test.js +0 -52
  19. package/apps/server/src/assetRoutes.test.js +0 -168
  20. package/apps/server/src/codex.test.js +0 -518
  21. package/apps/server/src/codexRoutes.test.js +0 -376
  22. package/apps/server/src/codexRuns.test.js +0 -160
  23. package/apps/server/src/codexSessions.test.js +0 -369
  24. package/apps/server/src/db.test.js +0 -182
  25. package/apps/server/src/gitDiff.test.js +0 -542
  26. package/apps/server/src/gitDiffClient.test.js +0 -140
  27. package/apps/server/src/internalRoutes.test.js +0 -134
  28. package/apps/server/src/maintenance.test.js +0 -154
  29. package/apps/server/src/processControl.test.js +0 -147
  30. package/apps/server/src/relayClient.test.js +0 -478
  31. package/apps/server/src/relayConfig.test.js +0 -73
  32. package/apps/server/src/relayProtocol.test.js +0 -49
  33. package/apps/server/src/relayServer.test.js +0 -798
  34. package/apps/server/src/relayTenants.test.js +0 -137
  35. package/apps/server/src/relayUsageStore.test.js +0 -65
  36. package/apps/server/src/repository.test.js +0 -150
  37. package/apps/server/src/runDispatchService.test.js +0 -563
  38. package/apps/server/src/runEventIngest.test.js +0 -225
  39. package/apps/server/src/runRecovery.test.js +0 -73
  40. package/apps/server/src/runnerClient.test.js +0 -80
  41. package/apps/server/src/runnerDispatch.test.js +0 -136
  42. package/apps/server/src/systemConfig.test.js +0 -112
  43. package/apps/server/src/systemRoutes.test.js +0 -319
  44. package/apps/server/src/taskRoutes.test.js +0 -775
  45. package/apps/server/src/upload.test.js +0 -30
  46. package/apps/server/src/webAppRoutes.test.js +0 -67
  47. package/apps/server/src/workspaceFiles.test.js +0 -279
  48. package/apps/web/dist/assets/WorkbenchView-DnrN_wUG.js +0 -60
  49. package/packages/shared/src/dailyLogStream.test.js +0 -29
  50. package/packages/shared/src/shellCommands.test.js +0 -45
@@ -1,467 +0,0 @@
1
- import test from 'node:test'
2
- import assert from 'node:assert/strict'
3
-
4
- import {
5
- createClaudeNormalizationState,
6
- extractClaudeAssistantText,
7
- extractClaudeResultText,
8
- extractClaudeSessionId,
9
- normalizeClaudeEvent,
10
- normalizeClaudeEvents,
11
- } from './claudeCodeRunner.js'
12
-
13
- test('runner claudeCodeRunner maps fatal auth api_retry to error event', () => {
14
- assert.deepEqual(
15
- normalizeClaudeEvents({
16
- type: 'system',
17
- subtype: 'api_retry',
18
- attempt: 1,
19
- max_retries: 10,
20
- error_status: 401,
21
- error: 'authentication_failed',
22
- }),
23
- [{
24
- type: 'error',
25
- message: 'Claude Code 认证失败(HTTP 401 authentication_failed)。请重新登录 Claude Code,或检查当前环境中的认证令牌配置。',
26
- }]
27
- )
28
- })
29
-
30
- test('runner claudeCodeRunner maps transient api_retry to reconnecting error event', () => {
31
- assert.deepEqual(
32
- normalizeClaudeEvents({
33
- type: 'system',
34
- subtype: 'api_retry',
35
- attempt: 2,
36
- max_retries: 10,
37
- error_status: 503,
38
- error: 'overloaded',
39
- }),
40
- [{
41
- type: 'error',
42
- message: 'Reconnecting... 2/10 (HTTP 503 overloaded)',
43
- }]
44
- )
45
- })
46
-
47
- test('runner claudeCodeRunner maps Agent sub-agents into collaboration events', () => {
48
- const state = createClaudeNormalizationState()
49
-
50
- assert.deepEqual(
51
- normalizeClaudeEvents({
52
- type: 'assistant',
53
- message: {
54
- content: [
55
- {
56
- type: 'tool_use',
57
- id: 'agent-tool-1',
58
- name: 'Agent',
59
- input: {
60
- description: 'Analyze a.js exports',
61
- subagent_type: 'general-purpose',
62
- prompt: 'Analyze a.js in the current directory.',
63
- model: 'sonnet',
64
- },
65
- },
66
- ],
67
- },
68
- }, state),
69
- [{
70
- type: 'item.started',
71
- item: {
72
- type: 'collab_tool_call',
73
- tool: 'spawn_agent',
74
- receiver_thread_ids: [],
75
- prompt: 'Analyze a.js in the current directory.',
76
- agents_states: {},
77
- },
78
- }]
79
- )
80
-
81
- assert.deepEqual(
82
- normalizeClaudeEvents({
83
- type: 'system',
84
- subtype: 'task_started',
85
- tool_use_id: 'agent-tool-1',
86
- task_id: 'task-a',
87
- description: 'Analyze a.js exports',
88
- }, state),
89
- [{
90
- type: 'item.completed',
91
- item: {
92
- type: 'collab_tool_call',
93
- tool: 'spawn_agent',
94
- receiver_thread_ids: ['task-a'],
95
- prompt: 'Analyze a.js in the current directory.',
96
- agents_states: {
97
- 'task-a': {
98
- status: 'running',
99
- message: '',
100
- title: 'Analyze a.js exports',
101
- role: 'general-purpose',
102
- target: 'a.js',
103
- model: 'sonnet',
104
- task_id: 'task-a',
105
- },
106
- },
107
- },
108
- }]
109
- )
110
- })
111
-
112
- test('runner claudeCodeRunner maps task_completed and ignores duplicate tool_result for Agent sub-agents', () => {
113
- const state = createClaudeNormalizationState()
114
-
115
- normalizeClaudeEvents({
116
- type: 'assistant',
117
- message: {
118
- content: [
119
- {
120
- type: 'tool_use',
121
- id: 'agent-tool-2',
122
- name: 'Agent',
123
- input: {
124
- description: 'Analyze b.js exports',
125
- subagent_type: 'general-purpose',
126
- prompt: 'Analyze b.js in the current directory.',
127
- model: 'sonnet',
128
- },
129
- },
130
- ],
131
- },
132
- }, state)
133
-
134
- normalizeClaudeEvents({
135
- type: 'system',
136
- subtype: 'task_started',
137
- tool_use_id: 'agent-tool-2',
138
- task_id: 'task-b',
139
- description: 'Analyze b.js exports',
140
- }, state)
141
-
142
- assert.deepEqual(
143
- normalizeClaudeEvents({
144
- type: 'system',
145
- subtype: 'task_completed',
146
- task_id: 'task-b',
147
- result: 'found 2 exports',
148
- description: 'Analyze b.js exports',
149
- }, state),
150
- [{
151
- type: 'item.completed',
152
- item: {
153
- type: 'collab_tool_call',
154
- tool: 'wait',
155
- receiver_thread_ids: ['task-b'],
156
- prompt: 'Analyze b.js in the current directory.',
157
- agents_states: {
158
- 'task-b': {
159
- status: 'completed',
160
- message: 'found 2 exports',
161
- title: 'Analyze b.js exports',
162
- role: 'general-purpose',
163
- target: 'b.js',
164
- model: 'sonnet',
165
- task_id: 'task-b',
166
- },
167
- },
168
- },
169
- }]
170
- )
171
-
172
- assert.deepEqual(
173
- normalizeClaudeEvents({
174
- type: 'user',
175
- message: {
176
- content: [
177
- {
178
- type: 'tool_result',
179
- tool_use_id: 'agent-tool-2',
180
- content: 'duplicate result',
181
- is_error: false,
182
- },
183
- ],
184
- },
185
- }, state),
186
- []
187
- )
188
- })
189
-
190
- test('runner claudeCodeRunner maps TodoWrite into todo_list events', () => {
191
- const state = createClaudeNormalizationState()
192
-
193
- assert.deepEqual(
194
- normalizeClaudeEvents({
195
- type: 'assistant',
196
- message: {
197
- content: [
198
- {
199
- type: 'tool_use',
200
- id: 'todo-tool-1',
201
- name: 'TodoWrite',
202
- input: {
203
- todos: [
204
- {
205
- content: 'Inspect relevant backend and admin codepaths',
206
- activeForm: 'Inspecting relevant backend and admin codepaths',
207
- status: 'in_progress',
208
- },
209
- {
210
- content: 'Implement hospital database model and admin APIs',
211
- status: 'pending',
212
- },
213
- {
214
- content: 'Add tests',
215
- status: 'completed',
216
- },
217
- ],
218
- },
219
- },
220
- ],
221
- },
222
- }, state),
223
- [{
224
- type: 'item.started',
225
- item: {
226
- type: 'todo_list',
227
- items: [
228
- {
229
- text: 'Inspecting relevant backend and admin codepaths',
230
- status: 'in_progress',
231
- completed: false,
232
- },
233
- {
234
- text: 'Implement hospital database model and admin APIs',
235
- status: 'pending',
236
- completed: false,
237
- },
238
- {
239
- text: 'Add tests',
240
- status: 'completed',
241
- completed: true,
242
- },
243
- ],
244
- },
245
- }]
246
- )
247
-
248
- assert.deepEqual(
249
- normalizeClaudeEvents({
250
- type: 'user',
251
- message: {
252
- content: [
253
- {
254
- type: 'tool_result',
255
- tool_use_id: 'todo-tool-1',
256
- content: 'Todos have been modified successfully.',
257
- is_error: false,
258
- },
259
- ],
260
- },
261
- }, state),
262
- [{
263
- type: 'item.completed',
264
- item: {
265
- type: 'todo_list',
266
- items: [
267
- {
268
- text: 'Inspecting relevant backend and admin codepaths',
269
- status: 'in_progress',
270
- completed: false,
271
- },
272
- {
273
- text: 'Implement hospital database model and admin APIs',
274
- status: 'pending',
275
- completed: false,
276
- },
277
- {
278
- text: 'Add tests',
279
- status: 'completed',
280
- completed: true,
281
- },
282
- ],
283
- },
284
- }]
285
- )
286
- })
287
-
288
- test('extractClaudeAssistantText joins nested text parts', () => {
289
- const text = extractClaudeAssistantText({
290
- type: 'assistant',
291
- message: {
292
- content: [
293
- { type: 'text', text: '第一段' },
294
- { type: 'text', text: '第二段' },
295
- ],
296
- },
297
- })
298
-
299
- assert.equal(text, '第一段\n第二段')
300
- })
301
-
302
- test('extractClaudeSessionId reads common session id fields', () => {
303
- assert.equal(extractClaudeSessionId({ session_id: 'claude-session-1' }), 'claude-session-1')
304
- assert.equal(extractClaudeSessionId({ result: { session_id: 'claude-session-2' } }), 'claude-session-2')
305
- })
306
-
307
- test('normalizeClaudeEvent maps assistant output to agent message', () => {
308
- assert.deepEqual(
309
- normalizeClaudeEvent({
310
- type: 'assistant',
311
- message: {
312
- content: [{ type: 'text', text: '已完成修改' }],
313
- },
314
- }),
315
- {
316
- type: 'item.completed',
317
- item: {
318
- type: 'agent_message',
319
- text: '已完成修改',
320
- },
321
- }
322
- )
323
- })
324
-
325
- test('normalizeClaudeEvent maps result output to turn completion', () => {
326
- assert.deepEqual(
327
- normalizeClaudeEvent({
328
- type: 'result',
329
- result: '最终回复',
330
- }),
331
- {
332
- type: 'turn.completed',
333
- result: '最终回复',
334
- }
335
- )
336
-
337
- assert.equal(extractClaudeResultText({ result: '最终回复' }), '最终回复')
338
- })
339
-
340
- test('normalizeClaudeEvents maps system init to thread start', () => {
341
- assert.deepEqual(
342
- normalizeClaudeEvents({
343
- type: 'system',
344
- subtype: 'init',
345
- session_id: 'claude-session-init',
346
- }),
347
- [{
348
- type: 'thread.started',
349
- thread_id: 'claude-session-init',
350
- }]
351
- )
352
- })
353
-
354
- test('normalizeClaudeEvents maps thinking, tool use and text blocks', () => {
355
- const state = createClaudeNormalizationState()
356
-
357
- assert.deepEqual(
358
- normalizeClaudeEvents({
359
- type: 'assistant',
360
- message: {
361
- content: [
362
- { type: 'thinking', thinking: '先看看目录结构' },
363
- { type: 'tool_use', id: 'tool-1', name: 'Bash', input: { command: 'ls -1' } },
364
- { type: 'text', text: '已查看完成' },
365
- ],
366
- },
367
- }, state),
368
- [
369
- {
370
- type: 'item.started',
371
- item: {
372
- type: 'reasoning',
373
- text: '先看看目录结构',
374
- },
375
- },
376
- {
377
- type: 'item.started',
378
- item: {
379
- type: 'command_execution',
380
- command: 'Bash: ls -1',
381
- status: 'in_progress',
382
- },
383
- },
384
- {
385
- type: 'item.completed',
386
- item: {
387
- type: 'agent_message',
388
- text: '已查看完成',
389
- },
390
- },
391
- ]
392
- )
393
- })
394
-
395
- test('normalizeClaudeEvents maps tool results back to remembered tool call', () => {
396
- const state = createClaudeNormalizationState()
397
- normalizeClaudeEvents({
398
- type: 'assistant',
399
- message: {
400
- content: [
401
- { type: 'tool_use', id: 'tool-2', name: 'Bash', input: { command: 'pwd' } },
402
- ],
403
- },
404
- }, state)
405
-
406
- assert.deepEqual(
407
- normalizeClaudeEvents({
408
- type: 'user',
409
- message: {
410
- content: [
411
- { type: 'tool_result', tool_use_id: 'tool-2', content: '/tmp/demo', is_error: false },
412
- ],
413
- },
414
- }, state),
415
- [{
416
- type: 'item.completed',
417
- item: {
418
- type: 'command_execution',
419
- command: 'Bash: pwd',
420
- status: 'completed',
421
- exit_code: 0,
422
- aggregated_output: '/tmp/demo',
423
- },
424
- }]
425
- )
426
- })
427
-
428
- test('normalizeClaudeEvents stringifies structured tool results', () => {
429
- const state = createClaudeNormalizationState()
430
- normalizeClaudeEvents({
431
- type: 'assistant',
432
- message: {
433
- content: [
434
- { type: 'tool_use', id: 'tool-3', name: 'Read', input: { file_path: '/tmp/demo.txt' } },
435
- ],
436
- },
437
- }, state)
438
-
439
- assert.deepEqual(
440
- normalizeClaudeEvents({
441
- type: 'user',
442
- message: {
443
- content: [
444
- {
445
- type: 'tool_result',
446
- tool_use_id: 'tool-3',
447
- content: [
448
- { type: 'text', text: '<path>/tmp/demo.txt</path>' },
449
- { type: 'text', text: '<type>file</type>' },
450
- ],
451
- },
452
- ],
453
- },
454
- },
455
- state),
456
- [{
457
- type: 'item.completed',
458
- item: {
459
- type: 'command_execution',
460
- command: 'Read: /tmp/demo.txt',
461
- status: 'completed',
462
- exit_code: 0,
463
- aggregated_output: '<path>/tmp/demo.txt</path>\n<type>file</type>',
464
- },
465
- }]
466
- )
467
- })
@@ -1,127 +0,0 @@
1
- import assert from 'node:assert/strict'
2
- import test from 'node:test'
3
-
4
- import {
5
- isKimiInfoStderrLine,
6
- normalizeKimiEvents,
7
- createKimiNormalizationState,
8
- } from './kimiCodeRunner.js'
9
- import { AGENT_RUN_ITEM_TYPES } from '@promptx/shared'
10
-
11
- test('isKimiInfoStderrLine treats resume hints as non-error metadata', () => {
12
- assert.equal(
13
- isKimiInfoStderrLine('To resume this session: kimi -r ffb2f903-1173-4f8a-a49a-c8b0deae3e2d'),
14
- true
15
- )
16
- assert.equal(
17
- isKimiInfoStderrLine('To resume this session: kimi --session ffb2f903-1173-4f8a-a49a-c8b0deae3e2d'),
18
- true
19
- )
20
- })
21
-
22
- test('isKimiInfoStderrLine keeps real stderr visible', () => {
23
- assert.equal(isKimiInfoStderrLine('Error: authentication failed'), false)
24
- })
25
-
26
- test('normalizeKimiEvents maps SetTodoList tool_call to todo_list events', () => {
27
- const state = createKimiNormalizationState()
28
-
29
- const assistantEvent = {
30
- role: 'assistant',
31
- content: [],
32
- tool_calls: [{
33
- id: 'call-1',
34
- function: {
35
- name: 'SetTodoList',
36
- arguments: JSON.stringify({
37
- todos: [
38
- { title: 'Task A', status: 'in_progress' },
39
- { title: 'Task B', status: 'done' },
40
- { title: 'Task C', status: 'pending' },
41
- ],
42
- }),
43
- },
44
- }],
45
- }
46
-
47
- const startedEvents = normalizeKimiEvents(assistantEvent, state)
48
- assert.equal(startedEvents.length, 2)
49
- assert.equal(startedEvents[0].type, 'turn.started')
50
-
51
- const todoStarted = startedEvents[1]
52
- assert.equal(todoStarted.type, 'item.started')
53
- assert.equal(todoStarted.item.type, AGENT_RUN_ITEM_TYPES.TODO_LIST)
54
- assert.equal(todoStarted.item.items.length, 3)
55
- assert.deepEqual(todoStarted.item.items[0], { text: 'Task A', status: 'in_progress', completed: false })
56
- assert.deepEqual(todoStarted.item.items[1], { text: 'Task B', status: 'completed', completed: true })
57
- assert.deepEqual(todoStarted.item.items[2], { text: 'Task C', status: 'pending', completed: false })
58
-
59
- const toolEvent = {
60
- role: 'tool',
61
- tool_call_id: 'call-1',
62
- content: 'Todo list updated',
63
- }
64
-
65
- const completedEvents = normalizeKimiEvents(toolEvent, state)
66
- assert.equal(completedEvents.length, 1)
67
- assert.equal(completedEvents[0].type, 'item.completed')
68
- assert.equal(completedEvents[0].item.type, AGENT_RUN_ITEM_TYPES.TODO_LIST)
69
- assert.equal(completedEvents[0].item.items.length, 3)
70
- })
71
-
72
- test('normalizeKimiEvents keeps regular tool_calls as command_execution', () => {
73
- const state = createKimiNormalizationState()
74
-
75
- const assistantEvent = {
76
- role: 'assistant',
77
- content: [],
78
- tool_calls: [{
79
- id: 'call-2',
80
- function: {
81
- name: 'Shell',
82
- arguments: JSON.stringify({ command: 'ls' }),
83
- },
84
- }],
85
- }
86
-
87
- const startedEvents = normalizeKimiEvents(assistantEvent, state)
88
- assert.equal(startedEvents.length, 2)
89
- assert.equal(startedEvents[0].type, 'turn.started')
90
-
91
- const cmdStarted = startedEvents[1]
92
- assert.equal(cmdStarted.type, 'item.started')
93
- assert.equal(cmdStarted.item.type, AGENT_RUN_ITEM_TYPES.COMMAND_EXECUTION)
94
-
95
- const toolEvent = {
96
- role: 'tool',
97
- tool_call_id: 'call-2',
98
- content: 'file.txt',
99
- }
100
-
101
- const completedEvents = normalizeKimiEvents(toolEvent, state)
102
- assert.equal(completedEvents.length, 1)
103
- assert.equal(completedEvents[0].type, 'item.completed')
104
- assert.equal(completedEvents[0].item.type, AGENT_RUN_ITEM_TYPES.COMMAND_EXECUTION)
105
- })
106
-
107
- test('normalizeKimiEvents handles SetTodoList with empty or malformed todos', () => {
108
- const state = createKimiNormalizationState()
109
-
110
- const assistantEvent = {
111
- role: 'assistant',
112
- content: [],
113
- tool_calls: [{
114
- id: 'call-3',
115
- function: {
116
- name: 'SetTodoList',
117
- arguments: JSON.stringify({ todos: [] }),
118
- },
119
- }],
120
- }
121
-
122
- const events = normalizeKimiEvents(assistantEvent, state)
123
- assert.equal(events.length, 2)
124
- assert.equal(events[1].type, 'item.started')
125
- assert.equal(events[1].item.type, AGENT_RUN_ITEM_TYPES.TODO_LIST)
126
- assert.equal(events[1].item.items.length, 0)
127
- })