@agent-spaces/server 0.2.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/agent-message-parts.js +1 -1
- package/dist/app.js +17 -1
- package/dist/package.json +1 -1
- package/dist/routes/file.js +38 -0
- package/dist/services/message.js +25 -0
- package/dist/services/pty.js +10 -2
- package/dist/services/workflow.js +1 -1
- package/dist/storage/user-settings-store.js +17 -0
- package/dist/web/404.html +1 -1
- package/dist/web/__next.__PAGE__.txt +4 -4
- package/dist/web/__next._full.txt +20 -20
- package/dist/web/__next._head.txt +4 -4
- package/dist/web/__next._index.txt +13 -13
- package/dist/web/__next._tree.txt +2 -2
- package/dist/web/_next/static/chunks/{0n0j7tw_y1qk2.js → 00fu7sjtftd3f.js} +1 -1
- package/dist/web/_next/static/chunks/00s_1ft2-qz0r.js +1 -0
- package/dist/web/_next/static/chunks/{0-vgd3j-zh3m8.js → 05iy4.c-1cfhd.js} +1 -1
- package/dist/web/_next/static/chunks/0b1w9_ne4c2ez.js +1 -0
- package/dist/web/_next/static/chunks/0bzechrx76-ix.js +1 -0
- package/dist/web/_next/static/chunks/0fxdvo63ywaa~.js +1 -0
- package/dist/web/_next/static/chunks/0k5bmi-es-2nj.js +1 -0
- package/dist/web/_next/static/chunks/0tqwdxb-8t_n1.js +1 -0
- package/dist/web/_next/static/chunks/0yc41k980zabo.js +1 -0
- package/dist/web/_next/static/chunks/0zhhkzv4.0koq.js +183 -0
- package/dist/web/_next/static/chunks/102lz3yanx8i~.css +1 -0
- package/dist/web/_next/static/chunks/13wm9.vry~.lh.js +5 -0
- package/dist/web/_not-found/__next._full.txt +19 -19
- package/dist/web/_not-found/__next._head.txt +4 -4
- package/dist/web/_not-found/__next._index.txt +13 -13
- package/dist/web/_not-found/__next._not-found.__PAGE__.txt +2 -2
- package/dist/web/_not-found/__next._not-found.txt +3 -3
- package/dist/web/_not-found/__next._tree.txt +2 -2
- package/dist/web/_not-found.html +1 -1
- package/dist/web/_not-found.txt +19 -19
- package/dist/web/index.html +1 -1
- package/dist/web/index.txt +20 -20
- package/dist/web/login/__next._full.txt +21 -21
- package/dist/web/login/__next._head.txt +4 -4
- package/dist/web/login/__next._index.txt +13 -13
- package/dist/web/login/__next._tree.txt +2 -2
- package/dist/web/login/__next.login.__PAGE__.txt +4 -4
- package/dist/web/login/__next.login.txt +3 -3
- package/dist/web/login.html +1 -1
- package/dist/web/login.txt +21 -21
- package/dist/web/settings/__next._full.txt +23 -23
- package/dist/web/settings/__next._head.txt +4 -4
- package/dist/web/settings/__next._index.txt +13 -13
- package/dist/web/settings/__next._tree.txt +2 -2
- package/dist/web/settings/__next.settings.__PAGE__.txt +4 -4
- package/dist/web/settings/__next.settings.txt +5 -5
- package/dist/web/settings/agents/__next._full.txt +23 -23
- package/dist/web/settings/agents/__next._head.txt +4 -4
- package/dist/web/settings/agents/__next._index.txt +13 -13
- package/dist/web/settings/agents/__next._tree.txt +2 -2
- package/dist/web/settings/agents/__next.settings.agents.__PAGE__.txt +4 -4
- package/dist/web/settings/agents/__next.settings.agents.txt +3 -3
- package/dist/web/settings/agents/__next.settings.txt +5 -5
- package/dist/web/settings/agents.html +1 -1
- package/dist/web/settings/agents.txt +23 -23
- package/dist/web/settings/mcps/__next._full.txt +23 -23
- package/dist/web/settings/mcps/__next._head.txt +4 -4
- package/dist/web/settings/mcps/__next._index.txt +13 -13
- package/dist/web/settings/mcps/__next._tree.txt +2 -2
- package/dist/web/settings/mcps/__next.settings.mcps.__PAGE__.txt +4 -4
- package/dist/web/settings/mcps/__next.settings.mcps.txt +3 -3
- package/dist/web/settings/mcps/__next.settings.txt +5 -5
- package/dist/web/settings/mcps.html +1 -1
- package/dist/web/settings/mcps.txt +23 -23
- package/dist/web/settings/models/__next._full.txt +23 -23
- package/dist/web/settings/models/__next._head.txt +4 -4
- package/dist/web/settings/models/__next._index.txt +13 -13
- package/dist/web/settings/models/__next._tree.txt +2 -2
- package/dist/web/settings/models/__next.settings.models.__PAGE__.txt +4 -4
- package/dist/web/settings/models/__next.settings.models.txt +3 -3
- package/dist/web/settings/models/__next.settings.txt +5 -5
- package/dist/web/settings/models.html +1 -1
- package/dist/web/settings/models.txt +23 -23
- package/dist/web/settings/providers/__next._full.txt +23 -23
- package/dist/web/settings/providers/__next._head.txt +4 -4
- package/dist/web/settings/providers/__next._index.txt +13 -13
- package/dist/web/settings/providers/__next._tree.txt +2 -2
- package/dist/web/settings/providers/__next.settings.providers.__PAGE__.txt +4 -4
- package/dist/web/settings/providers/__next.settings.providers.txt +3 -3
- package/dist/web/settings/providers/__next.settings.txt +5 -5
- package/dist/web/settings/providers.html +1 -1
- package/dist/web/settings/providers.txt +23 -23
- package/dist/web/settings/skills/__next._full.txt +23 -23
- package/dist/web/settings/skills/__next._head.txt +4 -4
- package/dist/web/settings/skills/__next._index.txt +13 -13
- package/dist/web/settings/skills/__next._tree.txt +2 -2
- package/dist/web/settings/skills/__next.settings.skills.__PAGE__.txt +4 -4
- package/dist/web/settings/skills/__next.settings.skills.txt +3 -3
- package/dist/web/settings/skills/__next.settings.txt +5 -5
- package/dist/web/settings/skills.html +1 -1
- package/dist/web/settings/skills.txt +23 -23
- package/dist/web/settings.html +1 -1
- package/dist/web/settings.txt +23 -23
- package/dist/web/workflows/__next._full.txt +21 -21
- package/dist/web/workflows/__next._head.txt +4 -4
- package/dist/web/workflows/__next._index.txt +13 -13
- package/dist/web/workflows/__next._tree.txt +2 -2
- package/dist/web/workflows/__next.workflows.__PAGE__.txt +4 -4
- package/dist/web/workflows/__next.workflows.txt +3 -3
- package/dist/web/workflows.html +1 -1
- package/dist/web/workflows.txt +21 -21
- package/dist/web/workspace/_/__next._full.txt +22 -22
- package/dist/web/workspace/_/__next._head.txt +4 -4
- package/dist/web/workspace/_/__next._index.txt +13 -13
- package/dist/web/workspace/_/__next._tree.txt +2 -2
- package/dist/web/workspace/_/__next.workspace.$d$id.__PAGE__.txt +3 -3
- package/dist/web/workspace/_/__next.workspace.$d$id.txt +3 -3
- package/dist/web/workspace/_/__next.workspace.txt +3 -3
- package/dist/web/workspace/_.html +1 -1
- package/dist/web/workspace/_.txt +22 -22
- package/dist/web/workspaces/__next._full.txt +21 -21
- package/dist/web/workspaces/__next._head.txt +4 -4
- package/dist/web/workspaces/__next._index.txt +13 -13
- package/dist/web/workspaces/__next._tree.txt +2 -2
- package/dist/web/workspaces/__next.workspaces.__PAGE__.txt +4 -4
- package/dist/web/workspaces/__next.workspaces.txt +3 -3
- package/dist/web/workspaces.html +1 -1
- package/dist/web/workspaces.txt +21 -21
- package/dist/ws/agent-prompt.js +19 -0
- package/dist/ws/agent-runner.js +67 -52
- package/dist/ws/handler.js +31 -2
- package/dist/ws/message-parts.js +1 -1
- package/package.json +1 -1
- package/dist/web/_next/static/chunks/0.~n0s82y4zh_.css +0 -1
- package/dist/web/_next/static/chunks/02duknlg3rgjp.js +0 -1
- package/dist/web/_next/static/chunks/04zxh2e-4~-xs.js +0 -1
- package/dist/web/_next/static/chunks/082lp-xqv7r.-.js +0 -183
- package/dist/web/_next/static/chunks/0b2tump5duj9j.js +0 -1
- package/dist/web/_next/static/chunks/0tkii3.lkbu3u.js +0 -1
- package/dist/web/_next/static/chunks/0wz8~mvztv-vq.js +0 -1
- package/dist/web/_next/static/chunks/0zxtxecpqyoeh.js +0 -1
- package/dist/web/_next/static/chunks/12sucjx_z8ftc.js +0 -1
- package/dist/web/_next/static/chunks/15_n_khh8cuax.js +0 -5
- /package/dist/web/_next/static/{hGfVPALj5nbwettayL9DY → XzP71HbFE1fuE_bLT-x7i}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{hGfVPALj5nbwettayL9DY → XzP71HbFE1fuE_bLT-x7i}/_clientMiddlewareManifest.js +0 -0
- /package/dist/web/_next/static/{hGfVPALj5nbwettayL9DY → XzP71HbFE1fuE_bLT-x7i}/_ssgManifest.js +0 -0
package/dist/ws/agent-runner.js
CHANGED
|
@@ -239,13 +239,14 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
239
239
|
askUserQuestions,
|
|
240
240
|
success: true,
|
|
241
241
|
});
|
|
242
|
-
|
|
242
|
+
const displayParts = buildContinuationParts(existingMessage?.parts, session.id, options.appendUserMessage, parts);
|
|
243
|
+
if (displayParts.length === 0)
|
|
243
244
|
return;
|
|
244
245
|
const status = askUserQuestions.some((question) => !question.answer) ? 'waiting_for_user' : 'streaming';
|
|
245
246
|
const live = updateMessage(workspaceId, channelId, pending.id, {
|
|
246
247
|
content: liveOutput.join('\n') || pending.content,
|
|
247
248
|
status,
|
|
248
|
-
parts,
|
|
249
|
+
parts: displayParts,
|
|
249
250
|
metadata: {
|
|
250
251
|
...pending.metadata,
|
|
251
252
|
duration: Date.now() - startTime,
|
|
@@ -354,6 +355,21 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
354
355
|
const displayOutput = mergeRuntimeOutput(liveOutput, result.output);
|
|
355
356
|
if (shouldWaitForUserAnswer(askUserQuestions, result.summary, result.error, displayOutput)) {
|
|
356
357
|
const waitingOutput = stripAskUserQuestionErrorLines(liveOutput);
|
|
358
|
+
const waitingParts = buildContinuationParts(existingMessage?.parts, session.id, options.appendUserMessage, buildAgentMessageParts({
|
|
359
|
+
sessionId: session.id,
|
|
360
|
+
workspaceRoot: workspace?.boundDirs?.[0],
|
|
361
|
+
presetName: preset.name || preset.role,
|
|
362
|
+
role: preset.role,
|
|
363
|
+
model: preset.modelId,
|
|
364
|
+
systemPrompt: preset.systemPrompt,
|
|
365
|
+
mcpServers: Object.keys(mcpServers ?? {}),
|
|
366
|
+
skills,
|
|
367
|
+
output: waitingOutput,
|
|
368
|
+
reasoning: liveReasoning,
|
|
369
|
+
toolDetails,
|
|
370
|
+
askUserQuestions,
|
|
371
|
+
success: true,
|
|
372
|
+
}));
|
|
357
373
|
const waiting = updateMessage(workspaceId, channelId, pending.id, {
|
|
358
374
|
content: waitingOutput.join('\n') || pending.content,
|
|
359
375
|
type: 'text',
|
|
@@ -365,21 +381,7 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
365
381
|
summary: 'Waiting for user answer',
|
|
366
382
|
duration: Date.now() - startTime,
|
|
367
383
|
},
|
|
368
|
-
parts:
|
|
369
|
-
sessionId: session.id,
|
|
370
|
-
workspaceRoot: workspace?.boundDirs?.[0],
|
|
371
|
-
presetName: preset.name || preset.role,
|
|
372
|
-
role: preset.role,
|
|
373
|
-
model: preset.modelId,
|
|
374
|
-
systemPrompt: preset.systemPrompt,
|
|
375
|
-
mcpServers: Object.keys(mcpServers ?? {}),
|
|
376
|
-
skills,
|
|
377
|
-
output: waitingOutput,
|
|
378
|
-
reasoning: liveReasoning,
|
|
379
|
-
toolDetails,
|
|
380
|
-
askUserQuestions,
|
|
381
|
-
success: true,
|
|
382
|
-
}),
|
|
384
|
+
parts: waitingParts,
|
|
383
385
|
});
|
|
384
386
|
if (waiting)
|
|
385
387
|
broadcastToWorkspace(workspaceId, 'channel.message.updated', waiting);
|
|
@@ -415,6 +417,24 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
415
417
|
},
|
|
416
418
|
error: result.error,
|
|
417
419
|
});
|
|
420
|
+
const replyParts = buildContinuationParts(existingMessage?.parts, session.id, options.appendUserMessage, buildAgentMessageParts({
|
|
421
|
+
sessionId: session.id,
|
|
422
|
+
workspaceRoot: workspace?.boundDirs?.[0],
|
|
423
|
+
presetName: preset.name || preset.role,
|
|
424
|
+
role: preset.role,
|
|
425
|
+
model: preset.modelId,
|
|
426
|
+
usage: result.usage,
|
|
427
|
+
systemPrompt: preset.systemPrompt,
|
|
428
|
+
mcpServers: Object.keys(mcpServers ?? {}),
|
|
429
|
+
skills,
|
|
430
|
+
builtInTools: buildBuiltInTools(functionTools, channel, issue),
|
|
431
|
+
output: displayOutput,
|
|
432
|
+
reasoning: liveReasoning,
|
|
433
|
+
toolDetails,
|
|
434
|
+
askUserQuestions,
|
|
435
|
+
success: result.success,
|
|
436
|
+
error: result.error,
|
|
437
|
+
}));
|
|
418
438
|
const reply = updateMessage(workspaceId, channelId, pending.id, {
|
|
419
439
|
content: result.success ? displayOutput.join('\n') : result.error || displayOutput.join('\n'),
|
|
420
440
|
type: 'text',
|
|
@@ -426,24 +446,7 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
426
446
|
summary: result.summary,
|
|
427
447
|
duration: Date.now() - startTime,
|
|
428
448
|
},
|
|
429
|
-
parts:
|
|
430
|
-
sessionId: session.id,
|
|
431
|
-
workspaceRoot: workspace?.boundDirs?.[0],
|
|
432
|
-
presetName: preset.name || preset.role,
|
|
433
|
-
role: preset.role,
|
|
434
|
-
model: preset.modelId,
|
|
435
|
-
usage: result.usage,
|
|
436
|
-
systemPrompt: preset.systemPrompt,
|
|
437
|
-
mcpServers: Object.keys(mcpServers ?? {}),
|
|
438
|
-
skills,
|
|
439
|
-
builtInTools: buildBuiltInTools(functionTools, channel, issue),
|
|
440
|
-
output: displayOutput,
|
|
441
|
-
reasoning: liveReasoning,
|
|
442
|
-
toolDetails,
|
|
443
|
-
askUserQuestions,
|
|
444
|
-
success: result.success,
|
|
445
|
-
error: result.error,
|
|
446
|
-
}),
|
|
449
|
+
parts: replyParts,
|
|
447
450
|
});
|
|
448
451
|
if (reply)
|
|
449
452
|
broadcastToWorkspace(workspaceId, 'channel.message.updated', reply);
|
|
@@ -460,6 +463,23 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
460
463
|
durationMs: Date.now() - startTime,
|
|
461
464
|
});
|
|
462
465
|
broadcastToWorkspace(workspaceId, 'agent.error', { agentId: session.id, error });
|
|
466
|
+
const errorParts = buildContinuationParts(existingMessage?.parts, session.id, options.appendUserMessage, buildAgentMessageParts({
|
|
467
|
+
sessionId: session.id,
|
|
468
|
+
workspaceRoot: workspace?.boundDirs?.[0],
|
|
469
|
+
presetName: preset.name || preset.role,
|
|
470
|
+
role: preset.role,
|
|
471
|
+
model: preset.modelId,
|
|
472
|
+
systemPrompt: preset.systemPrompt,
|
|
473
|
+
mcpServers: Object.keys(mcpServers ?? {}),
|
|
474
|
+
skills,
|
|
475
|
+
builtInTools: buildBuiltInTools(functionTools, channel, issue),
|
|
476
|
+
output: [error],
|
|
477
|
+
reasoning: liveReasoning,
|
|
478
|
+
toolDetails: new Map(),
|
|
479
|
+
askUserQuestions: [],
|
|
480
|
+
success: false,
|
|
481
|
+
error,
|
|
482
|
+
}));
|
|
463
483
|
const reply = updateMessage(workspaceId, channelId, pending.id, {
|
|
464
484
|
content: error,
|
|
465
485
|
type: 'text',
|
|
@@ -470,23 +490,7 @@ export async function runMentionedAgent(workspaceId, channelId, agentConfigId, p
|
|
|
470
490
|
model: preset.modelId,
|
|
471
491
|
duration: Date.now() - startTime,
|
|
472
492
|
},
|
|
473
|
-
parts:
|
|
474
|
-
sessionId: session.id,
|
|
475
|
-
workspaceRoot: workspace?.boundDirs?.[0],
|
|
476
|
-
presetName: preset.name || preset.role,
|
|
477
|
-
role: preset.role,
|
|
478
|
-
model: preset.modelId,
|
|
479
|
-
systemPrompt: preset.systemPrompt,
|
|
480
|
-
mcpServers: Object.keys(mcpServers ?? {}),
|
|
481
|
-
skills,
|
|
482
|
-
builtInTools: buildBuiltInTools(functionTools, channel, issue),
|
|
483
|
-
output: [error],
|
|
484
|
-
reasoning: liveReasoning,
|
|
485
|
-
toolDetails: new Map(),
|
|
486
|
-
askUserQuestions: [],
|
|
487
|
-
success: false,
|
|
488
|
-
error,
|
|
489
|
-
}),
|
|
493
|
+
parts: errorParts,
|
|
490
494
|
});
|
|
491
495
|
if (reply)
|
|
492
496
|
broadcastToWorkspace(workspaceId, 'channel.message.updated', reply);
|
|
@@ -535,6 +539,17 @@ function untrackChannelRun(workspaceId, channelId, agentId) {
|
|
|
535
539
|
if (runs.size === 0)
|
|
536
540
|
activeChannelRuns.delete(key);
|
|
537
541
|
}
|
|
542
|
+
function buildContinuationParts(previousParts, sessionId, userMessage, nextParts) {
|
|
543
|
+
if (!userMessage)
|
|
544
|
+
return nextParts;
|
|
545
|
+
const appended = [{
|
|
546
|
+
id: `user-message-${sessionId}`,
|
|
547
|
+
type: 'user_message',
|
|
548
|
+
text: userMessage,
|
|
549
|
+
senderName: '用户',
|
|
550
|
+
}, ...nextParts];
|
|
551
|
+
return [...(previousParts ?? []), ...appended];
|
|
552
|
+
}
|
|
538
553
|
function questionRunKey(workspaceId, channelId, messageId, questionId) {
|
|
539
554
|
return `${workspaceId}:${channelId}:${messageId}:${questionId}`;
|
|
540
555
|
}
|
package/dist/ws/handler.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { addConnection, broadcastToWorkspace } from './connection-manager.js';
|
|
2
2
|
import { handleTerminalEvent } from './terminal-handler.js';
|
|
3
|
-
import
|
|
3
|
+
import * as ptyService from '../services/pty.js';
|
|
4
|
+
import { appendMessageReply, createMessage } from '../services/message.js';
|
|
4
5
|
import { getChannel } from '../services/channel.js';
|
|
5
6
|
import * as agentService from '../services/agent.js';
|
|
6
7
|
import { runMentionedAgent, stopChannelRuns, handleAnswerQuestion, ensureScheduler, makeContext } from './agent-runner.js';
|
|
@@ -19,6 +20,16 @@ export function handleConnection(ws, workspaceId) {
|
|
|
19
20
|
timestamp: new Date().toISOString(),
|
|
20
21
|
data: { workspaceId },
|
|
21
22
|
}));
|
|
23
|
+
// Send existing terminal sessions for reconnection
|
|
24
|
+
const existingSessions = ptyService.getSessionsByWorkspace(workspaceId);
|
|
25
|
+
ws.send(JSON.stringify({
|
|
26
|
+
event: 'terminal.sessions',
|
|
27
|
+
workspaceId,
|
|
28
|
+
timestamp: new Date().toISOString(),
|
|
29
|
+
data: {
|
|
30
|
+
sessions: existingSessions.map(s => ({ sessionId: s.id, cwd: s.cwd, buffer: s.buffer.join('') })),
|
|
31
|
+
},
|
|
32
|
+
}));
|
|
22
33
|
ws.on('message', (raw) => {
|
|
23
34
|
try {
|
|
24
35
|
const msg = JSON.parse(raw.toString());
|
|
@@ -49,11 +60,29 @@ for (const evt of terminalEvents) {
|
|
|
49
60
|
}
|
|
50
61
|
// Register channel handlers
|
|
51
62
|
registerHandler('channel.message', (_ws, workspaceId, data) => {
|
|
52
|
-
const { channelId, content, type, mentions, attachments } = data;
|
|
63
|
+
const { channelId, content, type, mentions, attachments, replyToMessageId } = data;
|
|
53
64
|
if (!channelId || (!content && !attachments?.length))
|
|
54
65
|
return;
|
|
55
66
|
if (!getChannel(workspaceId, channelId))
|
|
56
67
|
return;
|
|
68
|
+
if (replyToMessageId) {
|
|
69
|
+
const updated = appendMessageReply(workspaceId, channelId, replyToMessageId, {
|
|
70
|
+
senderId: 'user',
|
|
71
|
+
content,
|
|
72
|
+
attachments,
|
|
73
|
+
});
|
|
74
|
+
if (!updated)
|
|
75
|
+
return;
|
|
76
|
+
broadcastToWorkspace(workspaceId, 'channel.message.updated', updated);
|
|
77
|
+
const agentId = updated.senderId !== 'user' ? updated.senderId : undefined;
|
|
78
|
+
if (agentId) {
|
|
79
|
+
void runMentionedAgent(workspaceId, channelId, agentId, stripHtml(content), {
|
|
80
|
+
messageId: updated.id,
|
|
81
|
+
appendUserMessage: stripHtml(content),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
57
86
|
const message = createMessage(workspaceId, channelId, {
|
|
58
87
|
senderId: 'user',
|
|
59
88
|
content,
|
package/dist/ws/message-parts.js
CHANGED
|
@@ -254,7 +254,7 @@ function buildChainItems(lines, finalTextRange, finalText, workspaceRoot, toolDe
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
flushMessageBuffer();
|
|
257
|
-
return items
|
|
257
|
+
return items;
|
|
258
258
|
}
|
|
259
259
|
function buildToolTodo(line, index, workspaceRoot, toolDetails, toolDetailMatchCounts) {
|
|
260
260
|
const summary = summarizeToolLine(line, workspaceRoot);
|