cladogram 0.6.0-beta.1 → 0.6.0-beta.2
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/docs/release.md +8 -0
- package/package.json +1 -1
- package/plugins/agent/index.js +801 -104
- package/plugins/agent/style.css +449 -56
- package/plugins/view-controls/style.css +7 -7
- package/src/agent/pi-bridge.js +187 -53
- package/src/html/plugin-ui.css +1 -1
- package/src/server/agent.js +6 -0
- package/src/server/assets/library.css +12 -12
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
.clado-view-bar::after {
|
|
19
19
|
content: "";
|
|
20
20
|
position: absolute;
|
|
21
|
-
left:
|
|
22
|
-
right:
|
|
23
|
-
bottom: -
|
|
24
|
-
height:
|
|
21
|
+
left: 14px;
|
|
22
|
+
right: 14px;
|
|
23
|
+
bottom: -5px;
|
|
24
|
+
height: 14px;
|
|
25
25
|
border-radius: 999px;
|
|
26
|
-
background: linear-gradient(90deg, rgba(56, 189, 248, 0.
|
|
27
|
-
filter: blur(
|
|
28
|
-
opacity: 0.
|
|
26
|
+
background: linear-gradient(90deg, rgba(56, 189, 248, 0.42), rgba(167, 139, 250, 0.34), rgba(244, 114, 182, 0.24));
|
|
27
|
+
filter: blur(15px);
|
|
28
|
+
opacity: 0.28;
|
|
29
29
|
pointer-events: none;
|
|
30
30
|
z-index: -2;
|
|
31
31
|
}
|
package/src/agent/pi-bridge.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Clado Pi 1.x Bridge
|
|
3
3
|
*
|
|
4
|
-
* 极薄桥接层:把 Clado
|
|
5
|
-
*
|
|
4
|
+
* 极薄桥接层:把 Clado 的多角色多会话管理、Pi 原生 JSONL 持久化、
|
|
5
|
+
* 画布快照回退、中断保留上下文与设计→交付单向交接绑定在一起。
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { randomUUID } from 'node:crypto';
|
|
@@ -24,7 +24,7 @@ import { workspacePath } from '../workspace/documents.js';
|
|
|
24
24
|
|
|
25
25
|
export function safeSessionId(raw) {
|
|
26
26
|
const s = String(raw || '').trim().replace(/[^a-zA-Z0-9_-]/g, '');
|
|
27
|
-
return s.length >= 4 ? s.slice(0, 80) : ('
|
|
27
|
+
return s.length >= 4 ? s.slice(0, 80) : ('sess_' + randomUUID().replace(/-/g, '').slice(0, 12));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function sessionsDir(stateDir) {
|
|
@@ -65,6 +65,7 @@ export function ensureDefaultSessions(stateDir, agentDir = resolvePiAgentDir())
|
|
|
65
65
|
phase: role.phase,
|
|
66
66
|
tone: role.tone,
|
|
67
67
|
model: role.model || '',
|
|
68
|
+
piSessionFile: '',
|
|
68
69
|
archived: false,
|
|
69
70
|
status: 'idle',
|
|
70
71
|
summaryBadge: '',
|
|
@@ -90,7 +91,7 @@ export function getSessionMeta(stateDir, id, agentDir = resolvePiAgentDir()) {
|
|
|
90
91
|
|
|
91
92
|
export function upsertSessionMeta(stateDir, patch, agentDir = resolvePiAgentDir()) {
|
|
92
93
|
const list = ensureDefaultSessions(stateDir, agentDir);
|
|
93
|
-
const id = safeSessionId(patch.id);
|
|
94
|
+
const id = patch.id ? safeSessionId(patch.id) : ('sess_' + randomUUID().replace(/-/g, '').slice(0, 12));
|
|
94
95
|
const idx = list.findIndex(s => s.id === id);
|
|
95
96
|
const role = resolveRole(patch.roleId || list[idx]?.roleId || 'architect', agentDir);
|
|
96
97
|
const now = new Date().toISOString();
|
|
@@ -111,6 +112,7 @@ export function upsertSessionMeta(stateDir, patch, agentDir = resolvePiAgentDir(
|
|
|
111
112
|
phase: role.phase,
|
|
112
113
|
tone: role.tone,
|
|
113
114
|
model: String(patch.model || role.model || ''),
|
|
115
|
+
piSessionFile: String(patch.piSessionFile || ''),
|
|
114
116
|
archived: false,
|
|
115
117
|
status: 'idle',
|
|
116
118
|
summaryBadge: '',
|
|
@@ -125,6 +127,18 @@ export function upsertSessionMeta(stateDir, patch, agentDir = resolvePiAgentDir(
|
|
|
125
127
|
return next;
|
|
126
128
|
}
|
|
127
129
|
|
|
130
|
+
export function renameSession(stateDir, id, title, agentDir = resolvePiAgentDir()) {
|
|
131
|
+
const cleanTitle = String(title || '').trim().slice(0, 60);
|
|
132
|
+
if (!cleanTitle) throw new Error('会话名称不能为空。');
|
|
133
|
+
const list = ensureDefaultSessions(stateDir, agentDir);
|
|
134
|
+
const item = list.find(s => s.id === id);
|
|
135
|
+
if (!item) throw new Error('找不到该会话。');
|
|
136
|
+
item.title = cleanTitle;
|
|
137
|
+
item.updatedAt = new Date().toISOString();
|
|
138
|
+
writeIndex(stateDir, list);
|
|
139
|
+
return item;
|
|
140
|
+
}
|
|
141
|
+
|
|
128
142
|
export function archiveSession(stateDir, id, archived = true, agentDir = resolvePiAgentDir()) {
|
|
129
143
|
const list = ensureDefaultSessions(stateDir, agentDir);
|
|
130
144
|
const item = list.find(s => s.id === id);
|
|
@@ -137,11 +151,13 @@ export function archiveSession(stateDir, id, archived = true, agentDir = resolve
|
|
|
137
151
|
|
|
138
152
|
export function deleteSession(stateDir, id, agentDir = resolvePiAgentDir()) {
|
|
139
153
|
const list = ensureDefaultSessions(stateDir, agentDir);
|
|
154
|
+
const target = list.find(s => s.id === id);
|
|
140
155
|
const next = list.filter(s => s.id !== id);
|
|
141
156
|
writeIndex(stateDir, next);
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
157
|
+
for (const candidate of [target?.piSessionFile, join(sessionsDir(stateDir), safeSessionId(id) + '.jsonl')]) {
|
|
158
|
+
if (candidate && existsSync(candidate)) {
|
|
159
|
+
try { rmSync(candidate, { force: true }); } catch {}
|
|
160
|
+
}
|
|
145
161
|
}
|
|
146
162
|
return { deleted: next.length !== list.length, id };
|
|
147
163
|
}
|
|
@@ -268,12 +284,14 @@ export function createPiBridge({
|
|
|
268
284
|
}, agentDir);
|
|
269
285
|
const role = resolveRole(meta.roleId, agentDir);
|
|
270
286
|
|
|
287
|
+
// Auto-title brand-new custom sessions on their first message
|
|
288
|
+
const existingMessages = Array.isArray(meta.messages) ? meta.messages : [];
|
|
289
|
+
const shouldAutoTitle = existingMessages.length === 0 && !cleanId.startsWith('role_') && (meta.title === role.name || meta.title.startsWith(role.name + ' · 新会话'));
|
|
290
|
+
const autoTitle = shouldAutoTitle ? text.replace(/\s+/g, ' ').trim().slice(0, 22) : undefined;
|
|
291
|
+
|
|
271
292
|
// Capture pre-turn canvas snapshot for 1-click rollback
|
|
272
293
|
const snap = captureCanvasSnapshot(documentRoot, canvas?.file);
|
|
273
|
-
|
|
274
|
-
const nextSnaps = [...(meta.snapshots || []).slice(-11), snap];
|
|
275
|
-
upsertSessionMeta(stateDir, { id: cleanId, snapshots: nextSnaps }, agentDir);
|
|
276
|
-
}
|
|
294
|
+
const nextSnaps = snap ? [...(meta.snapshots || []).slice(-11), snap] : (meta.snapshots || []);
|
|
277
295
|
|
|
278
296
|
const userMsg = {
|
|
279
297
|
id: 'm_' + randomUUID().replace(/-/g, '').slice(0, 10),
|
|
@@ -284,20 +302,28 @@ export function createPiBridge({
|
|
|
284
302
|
handoffFrom,
|
|
285
303
|
timestamp: new Date().toISOString(),
|
|
286
304
|
};
|
|
287
|
-
const nextMessages = [...
|
|
288
|
-
upsertSessionMeta(stateDir, {
|
|
305
|
+
const nextMessages = [...existingMessages.slice(-60), userMsg];
|
|
306
|
+
upsertSessionMeta(stateDir, {
|
|
307
|
+
id: cleanId,
|
|
308
|
+
...(autoTitle ? { title: autoTitle } : {}),
|
|
309
|
+
snapshots: nextSnaps,
|
|
310
|
+
messages: nextMessages,
|
|
311
|
+
}, agentDir);
|
|
289
312
|
|
|
290
313
|
const pendingQuestions = new Map();
|
|
314
|
+
const recordedQuestions = [];
|
|
291
315
|
const waitForUserAnswer = (questionId, signal) => new Promise((resolveAnswer, rejectAnswer) => {
|
|
292
316
|
const onAbort = () => {
|
|
293
317
|
pendingQuestions.delete(questionId);
|
|
294
|
-
rejectAnswer(new Error('
|
|
318
|
+
rejectAnswer(new Error('已停止生成'));
|
|
295
319
|
};
|
|
296
320
|
signal?.addEventListener('abort', onAbort, { once: true });
|
|
297
321
|
pendingQuestions.set(questionId, {
|
|
298
322
|
resolve(ans) {
|
|
299
323
|
signal?.removeEventListener('abort', onAbort);
|
|
300
324
|
pendingQuestions.delete(questionId);
|
|
325
|
+
const rec = recordedQuestions.find(q => q.questionId === questionId);
|
|
326
|
+
if (rec) { rec.answered = true; rec.answer = ans; }
|
|
301
327
|
resolveAnswer(ans);
|
|
302
328
|
},
|
|
303
329
|
reject(err) {
|
|
@@ -308,12 +334,25 @@ export function createPiBridge({
|
|
|
308
334
|
});
|
|
309
335
|
});
|
|
310
336
|
|
|
337
|
+
const emitWrapped = ev => {
|
|
338
|
+
if (ev?.type === 'ask_user') {
|
|
339
|
+
recordedQuestions.push({
|
|
340
|
+
questionId: ev.questionId,
|
|
341
|
+
question: ev.question,
|
|
342
|
+
options: ev.options || [],
|
|
343
|
+
answered: false,
|
|
344
|
+
answer: '',
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
emit(ev);
|
|
348
|
+
};
|
|
349
|
+
|
|
311
350
|
const cladoTools = createCladoPiTools({
|
|
312
351
|
workspace,
|
|
313
352
|
stateDir,
|
|
314
353
|
workspaceService,
|
|
315
354
|
events,
|
|
316
|
-
emit,
|
|
355
|
+
emit: emitWrapped,
|
|
317
356
|
waitForUserAnswer,
|
|
318
357
|
});
|
|
319
358
|
|
|
@@ -321,6 +360,10 @@ export function createPiBridge({
|
|
|
321
360
|
const toolLog = [];
|
|
322
361
|
let session = null;
|
|
323
362
|
let unsub = null;
|
|
363
|
+
let abortedByUser = false;
|
|
364
|
+
let piSessionFile = meta.piSessionFile || '';
|
|
365
|
+
|
|
366
|
+
const turnAbort = new AbortController();
|
|
324
367
|
|
|
325
368
|
const runState = {
|
|
326
369
|
sessionId: cleanId,
|
|
@@ -338,22 +381,78 @@ export function createPiBridge({
|
|
|
338
381
|
return false;
|
|
339
382
|
},
|
|
340
383
|
async abort() {
|
|
341
|
-
|
|
384
|
+
abortedByUser = true;
|
|
385
|
+
turnAbort.abort();
|
|
386
|
+
for (const w of pendingQuestions.values()) w.reject(new Error('用户已停止生成'));
|
|
342
387
|
pendingQuestions.clear();
|
|
343
388
|
if (session?.abort) await session.abort();
|
|
344
389
|
},
|
|
345
390
|
};
|
|
346
391
|
liveRuns.set(`${workspace}::${cleanId}`, runState);
|
|
347
392
|
|
|
393
|
+
const persistAssistantTurn = ({ stopped = false, errorMsg = '' } = {}) => {
|
|
394
|
+
const finalText = assistantText
|
|
395
|
+
+ (stopped ? (assistantText ? '\n\n' : '') + '_(已手动停止,以上内容已保留)_' : '')
|
|
396
|
+
+ (errorMsg ? (assistantText ? '\n\n' : '') + '提示:' + errorMsg : '');
|
|
397
|
+
const curMeta = getSessionMeta(stateDir, cleanId, agentDir);
|
|
398
|
+
const baseMsgs = Array.isArray(curMeta?.messages) && curMeta.messages.length ? curMeta.messages : nextMessages;
|
|
399
|
+
const assistantMsg = {
|
|
400
|
+
id: 'm_' + randomUUID().replace(/-/g, '').slice(0, 10),
|
|
401
|
+
role: 'assistant',
|
|
402
|
+
text: finalText,
|
|
403
|
+
tools: toolLog,
|
|
404
|
+
questions: recordedQuestions,
|
|
405
|
+
stopped: Boolean(stopped),
|
|
406
|
+
snapshotId: snap?.id || '',
|
|
407
|
+
timestamp: new Date().toISOString(),
|
|
408
|
+
};
|
|
409
|
+
const badge = toolLog.length ? `${toolLog.length} tools` : (curMeta?.summaryBadge || '');
|
|
410
|
+
upsertSessionMeta(stateDir, {
|
|
411
|
+
id: cleanId,
|
|
412
|
+
status: 'idle',
|
|
413
|
+
...(piSessionFile ? { piSessionFile } : {}),
|
|
414
|
+
summaryBadge: badge,
|
|
415
|
+
messages: [...baseMsgs, assistantMsg].slice(-80),
|
|
416
|
+
}, agentDir);
|
|
417
|
+
};
|
|
418
|
+
|
|
348
419
|
try {
|
|
349
|
-
|
|
420
|
+
emitWrapped({ type: 'session', sessionId: cleanId, roleId: role.id, roleName: role.name, snapshotId: snap?.id || '' });
|
|
350
421
|
|
|
351
422
|
if (sessionFactory) {
|
|
352
|
-
|
|
423
|
+
const factoryEmit = ev => {
|
|
424
|
+
if (ev?.type === 'text' && ev.text) assistantText += ev.text;
|
|
425
|
+
if (ev?.type === 'tool') {
|
|
426
|
+
const existing = toolLog.find(t => t.id === ev.id);
|
|
427
|
+
if (existing) {
|
|
428
|
+
existing.status = ev.status || existing.status;
|
|
429
|
+
if (ev.resultPreview !== undefined) existing.resultPreview = ev.resultPreview;
|
|
430
|
+
} else {
|
|
431
|
+
toolLog.push({
|
|
432
|
+
id: ev.id,
|
|
433
|
+
name: ev.name || ev.title || 'tool',
|
|
434
|
+
argsSummary: ev.argsSummary || '',
|
|
435
|
+
status: ev.status || 'running',
|
|
436
|
+
resultPreview: ev.resultPreview || '',
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
emitWrapped(ev);
|
|
441
|
+
};
|
|
353
442
|
const result = await sessionFactory({
|
|
354
|
-
workspace,
|
|
443
|
+
workspace,
|
|
444
|
+
stateDir,
|
|
445
|
+
documentRoot,
|
|
446
|
+
sessionId: cleanId,
|
|
447
|
+
role,
|
|
448
|
+
text,
|
|
449
|
+
canvas,
|
|
450
|
+
cladoTools,
|
|
451
|
+
emit: factoryEmit,
|
|
452
|
+
waitForUserAnswer,
|
|
453
|
+
signal: turnAbort.signal,
|
|
355
454
|
});
|
|
356
|
-
assistantText = String(result
|
|
455
|
+
if (!assistantText && result?.text) assistantText = String(result.text);
|
|
357
456
|
} else {
|
|
358
457
|
const sm = SettingsManager.create(workspace, agentDir);
|
|
359
458
|
const mr = await createCladoModelRuntime(agentDir);
|
|
@@ -371,14 +470,19 @@ export function createPiBridge({
|
|
|
371
470
|
appendSystemPrompt: [
|
|
372
471
|
role.systemPrompt,
|
|
373
472
|
'工作区规范:你可以通过 clado_* 工具读写空间画布,也可以直接使用 read/edit/write/bash 工具分析或修改代码。无需向用户弹窗请求命令权限。',
|
|
473
|
+
'提问规范:如果你需要向用户确认方案或提问,请先完整阐述你的分析与建议,再在最后一步调用 ask_user 工具,避免在回答中途插入问题。',
|
|
374
474
|
],
|
|
375
475
|
});
|
|
376
476
|
await loader.reload();
|
|
377
477
|
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
? SessionManager.open(jsonlFile)
|
|
478
|
+
const sessionManager = (piSessionFile && existsSync(piSessionFile))
|
|
479
|
+
? SessionManager.open(piSessionFile)
|
|
381
480
|
: SessionManager.create(workspace, sessionsDir(stateDir));
|
|
481
|
+
const resolvedFile = sessionManager.getSessionFile?.() || '';
|
|
482
|
+
if (resolvedFile) {
|
|
483
|
+
piSessionFile = resolvedFile;
|
|
484
|
+
upsertSessionMeta(stateDir, { id: cleanId, piSessionFile }, agentDir);
|
|
485
|
+
}
|
|
382
486
|
|
|
383
487
|
const created = await createAgentSession({
|
|
384
488
|
cwd: workspace,
|
|
@@ -392,39 +496,79 @@ export function createPiBridge({
|
|
|
392
496
|
});
|
|
393
497
|
session = created.session;
|
|
394
498
|
|
|
395
|
-
|
|
499
|
+
emitWrapped({
|
|
396
500
|
type: 'model',
|
|
397
501
|
provider: chosenModel.provider,
|
|
398
502
|
model: chosenModel.id,
|
|
399
503
|
});
|
|
400
504
|
|
|
505
|
+
const summarizeToolArgs = (name, args) => {
|
|
506
|
+
if (!args || typeof args !== 'object') return '';
|
|
507
|
+
const pick = args.path || args.file_path || args.file || args.command || args.cmd || args.query || args.pattern || args.title || args.heading || '';
|
|
508
|
+
if (pick) return String(pick).replace(/\s+/g, ' ').trim().slice(0, 110);
|
|
509
|
+
const keys = Object.keys(args);
|
|
510
|
+
if (!keys.length) return '';
|
|
511
|
+
try {
|
|
512
|
+
return JSON.stringify(args).slice(0, 100);
|
|
513
|
+
} catch {
|
|
514
|
+
return '';
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
const summarizeToolResult = result => {
|
|
518
|
+
if (!result) return '';
|
|
519
|
+
if (typeof result === 'string') return result.trim().slice(0, 220);
|
|
520
|
+
const blocks = Array.isArray(result.content) ? result.content : [];
|
|
521
|
+
const txt = blocks.filter(b => b?.type === 'text' && b.text).map(b => b.text).join('\n').trim();
|
|
522
|
+
return txt.slice(0, 220);
|
|
523
|
+
};
|
|
524
|
+
|
|
401
525
|
unsub = session.subscribe(ev => {
|
|
402
526
|
if (ev.type === 'message_update') {
|
|
403
527
|
const ae = ev.assistantMessageEvent;
|
|
404
528
|
if (ae?.type === 'text_delta' && ae.delta) {
|
|
405
529
|
assistantText += ae.delta;
|
|
406
|
-
|
|
530
|
+
emitWrapped({ type: 'text', text: ae.delta });
|
|
407
531
|
} else if (ae?.type === 'thinking_delta' && ae.delta) {
|
|
408
|
-
|
|
532
|
+
emitWrapped({ type: 'thinking', text: ae.delta });
|
|
409
533
|
}
|
|
410
534
|
} else if (ev.type === 'tool_execution_start') {
|
|
411
|
-
const
|
|
535
|
+
const argsSummary = summarizeToolArgs(ev.toolName, ev.args);
|
|
536
|
+
const entry = {
|
|
537
|
+
id: ev.toolCallId,
|
|
538
|
+
name: ev.toolName,
|
|
539
|
+
argsSummary,
|
|
540
|
+
status: 'running',
|
|
541
|
+
resultPreview: '',
|
|
542
|
+
};
|
|
412
543
|
toolLog.push(entry);
|
|
413
|
-
|
|
544
|
+
emitWrapped({
|
|
545
|
+
type: 'tool',
|
|
546
|
+
id: ev.toolCallId,
|
|
547
|
+
name: ev.toolName,
|
|
548
|
+
argsSummary,
|
|
549
|
+
title: argsSummary ? `${ev.toolName} ${argsSummary}` : ev.toolName,
|
|
550
|
+
status: 'running',
|
|
551
|
+
});
|
|
414
552
|
} else if (ev.type === 'tool_execution_end') {
|
|
553
|
+
const resultPreview = summarizeToolResult(ev.result);
|
|
415
554
|
const existing = toolLog.find(t => t.id === ev.toolCallId);
|
|
416
|
-
if (existing)
|
|
417
|
-
|
|
555
|
+
if (existing) {
|
|
556
|
+
existing.status = ev.isError ? 'failed' : 'completed';
|
|
557
|
+
existing.resultPreview = resultPreview;
|
|
558
|
+
}
|
|
559
|
+
emitWrapped({
|
|
418
560
|
type: 'tool',
|
|
419
561
|
id: ev.toolCallId,
|
|
420
562
|
name: ev.toolName,
|
|
421
|
-
|
|
563
|
+
argsSummary: existing?.argsSummary || '',
|
|
564
|
+
resultPreview,
|
|
565
|
+
title: existing?.argsSummary ? `${ev.toolName} ${existing.argsSummary}` : ev.toolName,
|
|
422
566
|
status: ev.isError ? 'failed' : 'completed',
|
|
423
567
|
});
|
|
424
568
|
} else if (ev.type === 'compaction_start') {
|
|
425
|
-
|
|
569
|
+
emitWrapped({ type: 'status', text: 'Pi 正在自动压缩长上下文…' });
|
|
426
570
|
} else if (ev.type === 'auto_retry_start') {
|
|
427
|
-
|
|
571
|
+
emitWrapped({ type: 'status', text: `网络波动,正在自动重试 (${ev.attempt}/${ev.maxAttempts})…` });
|
|
428
572
|
}
|
|
429
573
|
});
|
|
430
574
|
|
|
@@ -432,27 +576,17 @@ export function createPiBridge({
|
|
|
432
576
|
await session.prompt(promptText);
|
|
433
577
|
}
|
|
434
578
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
role: 'assistant',
|
|
438
|
-
text: assistantText,
|
|
439
|
-
tools: toolLog,
|
|
440
|
-
snapshotId: snap?.id || '',
|
|
441
|
-
timestamp: new Date().toISOString(),
|
|
442
|
-
};
|
|
443
|
-
const curMeta = getSessionMeta(stateDir, cleanId, agentDir);
|
|
444
|
-
const badge = toolLog.length ? `${toolLog.length} tools` : '';
|
|
445
|
-
upsertSessionMeta(stateDir, {
|
|
446
|
-
id: cleanId,
|
|
447
|
-
status: 'idle',
|
|
448
|
-
summaryBadge: badge || curMeta?.summaryBadge || '',
|
|
449
|
-
messages: [...(curMeta?.messages || nextMessages), assistantMsg].slice(-80),
|
|
450
|
-
}, agentDir);
|
|
451
|
-
|
|
452
|
-
emit({ type: 'done', sessionId: cleanId, snapshotId: snap?.id || '' });
|
|
579
|
+
persistAssistantTurn({ stopped: abortedByUser });
|
|
580
|
+
emitWrapped({ type: 'done', sessionId: cleanId, snapshotId: snap?.id || '', stopped: abortedByUser });
|
|
453
581
|
} catch (err) {
|
|
454
|
-
|
|
455
|
-
|
|
582
|
+
if (abortedByUser) {
|
|
583
|
+
persistAssistantTurn({ stopped: true });
|
|
584
|
+
emitWrapped({ type: 'done', sessionId: cleanId, snapshotId: snap?.id || '', stopped: true });
|
|
585
|
+
} else {
|
|
586
|
+
const msg = err?.message || 'Pi 执行失败';
|
|
587
|
+
persistAssistantTurn({ errorMsg: msg });
|
|
588
|
+
emitWrapped({ type: 'error', message: msg });
|
|
589
|
+
}
|
|
456
590
|
} finally {
|
|
457
591
|
liveRuns.delete(`${workspace}::${cleanId}`);
|
|
458
592
|
try { unsub?.(); } catch {}
|
package/src/html/plugin-ui.css
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
--clado-ui-prism-bg: linear-gradient(135deg, rgba(224, 242, 254, 0.86) 0%, rgba(232, 236, 255, 0.84) 55%, rgba(243, 232, 255, 0.78) 100%);
|
|
22
22
|
--clado-ui-prism-border: rgba(147, 197, 253, 0.90);
|
|
23
23
|
--clado-ui-prism-text: #1e3a5f;
|
|
24
|
-
--clado-ui-prism-shadow: 0
|
|
24
|
+
--clado-ui-prism-shadow: 0 6px 18px -6px rgba(99, 102, 241, 0.16), 0 2px 5px -1px rgba(56, 189, 248, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.96);
|
|
25
25
|
--clado-ui-decision-bg: linear-gradient(155deg, rgba(255, 251, 235, 0.84), rgba(254, 243, 199, 0.46));
|
|
26
26
|
--clado-ui-decision-border: rgba(245, 158, 11, 0.44);
|
|
27
27
|
--clado-ui-decision-shadow: 0 12px 32px -10px rgba(245, 158, 11, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.88);
|
package/src/server/agent.js
CHANGED
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
deleteSession,
|
|
44
44
|
getSessionMeta,
|
|
45
45
|
listSessions,
|
|
46
|
+
renameSession,
|
|
46
47
|
restoreCanvasSnapshot,
|
|
47
48
|
safeSessionId,
|
|
48
49
|
upsertSessionMeta,
|
|
@@ -207,6 +208,11 @@ export function createAgentHandler({
|
|
|
207
208
|
if (req.method === 'POST') {
|
|
208
209
|
assertSameOriginPost(req);
|
|
209
210
|
const body = await readJsonBody(req);
|
|
211
|
+
if (body?.action === 'rename') {
|
|
212
|
+
const updated = renameSession(rt.stateDir, body.id, body.title, agentDir);
|
|
213
|
+
sendJson(res, 200, { ok: true, session: updated });
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
210
216
|
if (body?.action === 'archive') {
|
|
211
217
|
const updated = archiveSession(rt.stateDir, body.id, body.archived !== false, agentDir);
|
|
212
218
|
sendJson(res, 200, { ok: Boolean(updated), session: updated });
|
|
@@ -71,10 +71,10 @@ html, body {
|
|
|
71
71
|
.clado-ambient-blob {
|
|
72
72
|
position: absolute;
|
|
73
73
|
border-radius: 50%;
|
|
74
|
-
filter: blur(
|
|
75
|
-
opacity: 0.
|
|
74
|
+
filter: blur(84px);
|
|
75
|
+
opacity: 0.22;
|
|
76
76
|
}
|
|
77
|
-
[data-theme="dark"] .clado-ambient-blob { opacity: 0.
|
|
77
|
+
[data-theme="dark"] .clado-ambient-blob { opacity: 0.12; }
|
|
78
78
|
.clado-ambient-blob.b1 {
|
|
79
79
|
width: 520px; height: 420px; top: -120px; right: 6%;
|
|
80
80
|
background: radial-gradient(circle, rgba(125, 211, 252, 0.42), rgba(196, 181, 253, 0.22) 55%, transparent 75%);
|
|
@@ -244,9 +244,9 @@ iframe { height: 100%; width: 100%; display: block; border: 0; background: trans
|
|
|
244
244
|
.clado-ws-card:hover {
|
|
245
245
|
transform: translateY(-3px);
|
|
246
246
|
border-color: var(--clado-ui-hover-border);
|
|
247
|
-
box-shadow: 0
|
|
247
|
+
box-shadow: 0 22px 46px -16px rgba(56, 189, 248, 0.11), var(--clado-ui-glass-shadow);
|
|
248
248
|
}
|
|
249
|
-
.clado-ws-card:hover::after { opacity: 0.
|
|
249
|
+
.clado-ws-card:hover::after { opacity: 0.42; }
|
|
250
250
|
.clado-ws-mono {
|
|
251
251
|
width: 34px;
|
|
252
252
|
height: 34px;
|
|
@@ -288,14 +288,14 @@ iframe { height: 100%; width: 100%; display: block; border: 0; background: trans
|
|
|
288
288
|
}
|
|
289
289
|
.clado-prism-aura-under {
|
|
290
290
|
position: absolute;
|
|
291
|
-
left:
|
|
292
|
-
right:
|
|
293
|
-
bottom: -
|
|
294
|
-
height:
|
|
291
|
+
left: 14%;
|
|
292
|
+
right: 14%;
|
|
293
|
+
bottom: -22px;
|
|
294
|
+
height: 40px;
|
|
295
295
|
border-radius: 999px;
|
|
296
|
-
background: linear-gradient(90deg, rgba(56, 189, 248, 0.
|
|
297
|
-
filter: blur(
|
|
298
|
-
opacity: 0.
|
|
296
|
+
background: linear-gradient(90deg, rgba(56, 189, 248, 0.46), rgba(167, 139, 250, 0.44), rgba(244, 114, 182, 0.34), rgba(251, 191, 36, 0.28));
|
|
297
|
+
filter: blur(30px);
|
|
298
|
+
opacity: 0.24;
|
|
299
299
|
pointer-events: none;
|
|
300
300
|
z-index: -1;
|
|
301
301
|
}
|