pi-web-ui 0.115.0 → 0.117.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/CHANGELOG.md +65 -2
- package/bin/device-hub-cli.mjs +26 -3
- package/bin/pi-web-ui.mjs +159 -71
- package/dist/server/agent-service-daemon.js +136 -8
- package/dist/server/agent-service.js +594 -159
- package/dist/server/canvas/canvas-workspace.js +18 -86
- package/dist/server/client-state.js +52 -8
- package/dist/server/compaction-markers.js +43 -24
- package/dist/server/dangling-tools.js +172 -16
- package/dist/server/device-center/bot-execution.js +77 -2
- package/dist/server/device-center/collab-service.js +61 -12
- package/dist/server/device-center/collab-tool.js +482 -21
- package/dist/server/device-center/connector.js +107 -37
- package/dist/server/device-center/delivery-authority.js +98 -0
- package/dist/server/device-center/delivery-subject.js +30 -0
- package/dist/server/device-center/device-integration.js +453 -183
- package/dist/server/device-center/execution-guides.js +17 -7
- package/dist/server/device-center/execution-instructions.js +2 -1
- package/dist/server/device-center/execution-settings.js +138 -25
- package/dist/server/device-center/executor.js +51 -6
- package/dist/server/device-center/file-sync.js +14 -13
- package/dist/server/device-center/group-context-message.js +3 -1
- package/dist/server/device-center/group-context.js +73 -3
- package/dist/server/device-center/hub-conversations.js +71 -6
- package/dist/server/device-center/hub-deliveries.js +120 -15
- package/dist/server/device-center/hub-integration.js +655 -334
- package/dist/server/device-center/hub-locks.js +320 -0
- package/dist/server/device-center/hub-page.js +16 -35
- package/dist/server/device-center/hub-setup.js +23 -1
- package/dist/server/device-center/hub-transaction-log.js +197 -0
- package/dist/server/device-center/hub-webhooks.js +165 -0
- package/dist/server/device-center/hub.js +1531 -305
- package/dist/server/device-center/integration-verification.js +113 -0
- package/dist/server/device-center/local-hub.js +8 -3
- package/dist/server/device-center/local-publication.js +423 -0
- package/dist/server/device-center/local-verification-job.js +97 -0
- package/dist/server/device-center/local-verification.js +274 -0
- package/dist/server/device-center/local.js +181 -13
- package/dist/server/device-center/main.js +4 -1
- package/dist/server/device-center/partition-log.js +330 -0
- package/dist/server/device-center/publication-journal.js +312 -0
- package/dist/server/device-center/publish-intent.js +379 -0
- package/dist/server/device-center/relay.js +134 -24
- package/dist/server/device-center/runtime.js +475 -42
- package/dist/server/device-center/store.js +366 -89
- package/dist/server/device-center/task-outcome.js +81 -0
- package/dist/server/device-center/task-recovery.js +603 -178
- package/dist/server/device-center/task-scheduler.js +48 -3
- package/dist/server/device-center/task-settlement.js +353 -0
- package/dist/server/device-center/task-workspace.js +443 -0
- package/dist/server/device-center/transfers.js +41 -15
- package/dist/server/device-center/verification-limits.js +10 -0
- package/dist/server/device-center/work-contract.js +995 -0
- package/dist/server/dispatch-domain-handlers.js +29 -3
- package/dist/server/dsh/dsh-agent-service.js +9 -2
- package/dist/server/engine-probe.js +112 -1
- package/dist/server/global-loader.js +119 -19
- package/dist/server/index.js +159 -17
- package/dist/server/managed.js +2 -0
- package/dist/server/model-admin.js +48 -6
- package/dist/server/model-enrich.js +10 -1
- package/dist/server/patch-node-pty.js +3 -2
- package/dist/server/patch-remote-catalog.js +3 -2
- package/dist/server/plugins.js +64 -7
- package/dist/server/preset-fields.js +17 -1
- package/dist/server/preset-share.js +1 -0
- package/dist/server/prompt-composer.js +39 -0
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/quick-ask-settings.js +28 -0
- package/dist/server/quick-ask.js +164 -0
- package/dist/server/reasoning-registry.js +207 -0
- package/dist/server/resolve-global-sdk.js +61 -11
- package/dist/server/scheduler-tasks.js +35 -8
- package/dist/server/session-list-scan.js +223 -0
- package/dist/server/session-open.js +93 -0
- package/dist/server/session-parser.js +4 -0
- package/dist/server/session-scan.js +90 -38
- package/dist/server/settings-service.js +9 -1
- package/dist/server/soft-cap.js +5 -0
- package/dist/server/startup-banner.js +35 -0
- package/dist/server/subagents.js +2 -1
- package/dist/server/tool-manager.js +17 -9
- package/dist/server/transcript-prepare.js +73 -0
- package/dist/server/unauthorized-page.js +319 -0
- package/dist/server/universal/drivers/claude-code.js +98 -34
- package/dist/server/universal/universal-session.js +4 -0
- package/dist/server/workspace-handle.js +428 -0
- package/docs/architecture-plugins.md +959 -0
- package/docs/device-center.md +34 -20
- package/package.json +4 -4
- package/plugin-sdk/README.md +16 -8
- package/plugin-sdk/client.d.ts +27 -0
- package/plugin-sdk/client.mjs +82 -0
- package/plugin-sdk/index.d.ts +10 -0
- package/plugin-sdk/index.mjs +4 -683
- package/plugin-sdk/package.json +15 -4
- package/plugin-sdk/testing.d.ts +10 -0
- package/plugin-sdk/testing.mjs +566 -0
- package/themes/flow-cristallo.css +168 -0
- package/themes/flow-ink.css +169 -0
- package/themes/flow-obsidian.css +169 -0
- package/themes/flow-zurich.css +169 -0
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BYzPgmoq.js → BgTasksModal-BjNRIUIc.js} +1 -1
- package/web/dist/assets/{BgTasksModal-ni0VTmAQ.js → BgTasksModal-C0zuU8FE.js} +1 -1
- package/web/dist/assets/{CanvasStudio-DNmDNBod.js → CanvasStudio-BWvdmJ0M.js} +3 -3
- package/web/dist/assets/{CanvasStudio-BCUeEf25.js → CanvasStudio-VQFjmTGq.js} +3 -3
- package/web/dist/assets/DeviceCenter-DI9_0aBB.js +3 -0
- package/web/dist/assets/DeviceCenter-DsNtXqzY.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-BLP1Su5G.js +1 -0
- package/web/dist/assets/DeviceGroups-2Pvk0Cds.js +1 -0
- package/web/dist/assets/DeviceGroups-CP7CcyPD.js +1 -0
- package/web/dist/assets/{Dropdown-CGXD0DfT.js → Dropdown-CQtstPGv.js} +1 -1
- package/web/dist/assets/FilePreview-BMB2tNyT.js +2 -0
- package/web/dist/assets/FilePreview-RGFQUbJo.js +2 -0
- package/web/dist/assets/{GlobalSearchModal-mevF-ySi.js → GlobalSearchModal-BM5wxiqU.js} +1 -1
- package/web/dist/assets/{GlobalSearchModal-qL99FN_F.js → GlobalSearchModal-DGv_WINq.js} +1 -1
- package/web/dist/assets/GroupConversation-B7SnuXj1.js +61 -0
- package/web/dist/assets/GroupConversation-Dda69q-2.js +61 -0
- package/web/dist/assets/{HintTip-LHwkS2jV.js → HintTip-ChTW8o1m.js} +1 -1
- package/web/dist/assets/ModelConfigModal-C-0Z4hUZ.js +2 -0
- package/web/dist/assets/ModelConfigModal-yqeadyab.js +2 -0
- package/web/dist/assets/{PiSetupModal-DE5-gEtI.js → PiSetupModal-BX5rUuoI.js} +1 -1
- package/web/dist/assets/{ProviderOAuthControls-6UMARucA.js → ProviderOAuthControls-DY4SCfXg.js} +1 -1
- package/web/dist/assets/SCMPanel-C4KbQvvK.js +2 -0
- package/web/dist/assets/SCMPanel-DPAyY2sW.js +2 -0
- package/web/dist/assets/SettingsModal-DxZp6D_g.js +32 -0
- package/web/dist/assets/SettingsModal-WhQzaOPt.js +32 -0
- package/web/dist/assets/{TerminalPanel-CTp_BZ4S.js → TerminalPanel-D4By_RVc.js} +2 -2
- package/web/dist/assets/{TerminalPanel-CkYxC-Gh.js → TerminalPanel-lZw8-i3j.js} +2 -2
- package/web/dist/assets/{TuiOverlayModal-1cRLP8IF.js → TuiOverlayModal-C3pAVuC8.js} +1 -1
- package/web/dist/assets/{TuiOverlayModal-2xlptqWX.js → TuiOverlayModal-D7_rEXcJ.js} +1 -1
- package/web/dist/assets/app-globals-KqOVtmp1.js +123 -0
- package/web/dist/assets/{canvas-client-Bye9nSFO.js → canvas-client-BY6ojmle.js} +1 -1
- package/web/dist/assets/{desktop-kjBoE3Nu.js → desktop-CV6KKp9R.js} +1 -1
- package/web/dist/assets/index-BawF7ZP5.js +397 -0
- package/web/dist/assets/index-BoGCoq5X.js +397 -0
- package/web/dist/assets/index-CVW9FoY2.css +1 -0
- package/web/dist/assets/{plugin-host-C8mNgghx.js → plugin-host-Dn8Dd6SC.js} +1 -1
- package/web/dist/assets/{remote-ssh-client-CeP3CLUW.js → remote-ssh-client-Dzi-eEyE.js} +1 -1
- package/web/dist/assets/{theme-BXGpyTMh.js → theme-D_bihpdN.js} +1 -1
- package/web/dist/index.html +11 -11
- package/web/dist/sw.js +1 -1
- package/dist/server/patch-turn-end-boundary.js +0 -77
- package/web/dist/assets/DeviceCenter-BcBhRgL6.js +0 -3
- package/web/dist/assets/DeviceCenter-CmL5FZmt.js +0 -3
- package/web/dist/assets/DeviceGroups-CLdpdnI7.js +0 -1
- package/web/dist/assets/DeviceGroups-CgBaDPrD.js +0 -1
- package/web/dist/assets/FilePreview-B8iqnBjy.js +0 -2
- package/web/dist/assets/FilePreview-BqviZKCN.js +0 -2
- package/web/dist/assets/GroupConversation-B88Yy-lt.js +0 -3
- package/web/dist/assets/GroupConversation-BwP5NVOE.js +0 -3
- package/web/dist/assets/ModelConfigModal-Do3Fe3jH.js +0 -2
- package/web/dist/assets/SCMPanel-Hi6QqC1Q.js +0 -2
- package/web/dist/assets/SCMPanel-ezY_ZtCu.js +0 -2
- package/web/dist/assets/SettingsModal-6HgeEsJ8.js +0 -20
- package/web/dist/assets/SettingsModal-CF-7MwqS.js +0 -20
- package/web/dist/assets/app-globals-DZNa9v8u.js +0 -325
- package/web/dist/assets/index-CsFs_HMb.css +0 -1
- package/web/dist/assets/index-DHeeHS_l.js +0 -85
- package/web/dist/assets/index-DTZch8uz.js +0 -85
|
@@ -39,7 +39,12 @@ export class AgentService {
|
|
|
39
39
|
const viewer = this.clients.get(viewerClientId);
|
|
40
40
|
const owner = this.clients.get(ownerClientId);
|
|
41
41
|
const conversation = owner?.getConversation(convId);
|
|
42
|
-
|
|
42
|
+
const isScheduler = ownerClientId.startsWith("scheduler:");
|
|
43
|
+
if (!viewer ||
|
|
44
|
+
!owner ||
|
|
45
|
+
!conversation ||
|
|
46
|
+
(conversation.independent !== false && !isScheduler) ||
|
|
47
|
+
conversation.isSubagent)
|
|
43
48
|
return false;
|
|
44
49
|
this.closeSharedConversation(viewerClientId);
|
|
45
50
|
const binding = { owner, conversation, ownerClientId, conversationId: convId, close: () => { }, send };
|
|
@@ -108,7 +113,7 @@ export class AgentService {
|
|
|
108
113
|
if (binding &&
|
|
109
114
|
this.clients.get(binding.ownerClientId) === binding.owner &&
|
|
110
115
|
binding.owner.getConversation(binding.conversationId) === binding.conversation &&
|
|
111
|
-
binding.conversation.independent === false)
|
|
116
|
+
(binding.conversation.independent === false || binding.ownerClientId.startsWith("scheduler:")))
|
|
112
117
|
return binding;
|
|
113
118
|
if (binding)
|
|
114
119
|
this.closeSharedConversation(viewerClientId);
|
|
@@ -353,6 +358,77 @@ export class AgentService {
|
|
|
353
358
|
return false;
|
|
354
359
|
}
|
|
355
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* 关闭对话(支持本端自身会话,或跨端关闭群组 Bot / 共享执行 / 离线残骸 / elsewhere 会话)。
|
|
363
|
+
*/
|
|
364
|
+
async dismissConversation(requesterClientId, msg) {
|
|
365
|
+
const requester = this.clients.get(requesterClientId);
|
|
366
|
+
// 1. 本客户端自己持有该会话:走当前客户端正常流程
|
|
367
|
+
if (requester?.getConversation(msg.id)) {
|
|
368
|
+
await requester.dismissConversation(msg.id, msg.withFinishedSubagents, msg.force);
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
// 2. 跨客户端定位持有该会话的 owner
|
|
372
|
+
let ownerId = msg.owner;
|
|
373
|
+
let owner = ownerId ? this.clients.get(ownerId) : undefined;
|
|
374
|
+
let conv = owner?.getConversation(msg.id);
|
|
375
|
+
if (!owner || !conv) {
|
|
376
|
+
for (const [cid, c] of this.clients) {
|
|
377
|
+
const found = c.getConversation(msg.id);
|
|
378
|
+
if (found) {
|
|
379
|
+
ownerId = cid;
|
|
380
|
+
owner = c;
|
|
381
|
+
conv = found;
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (!owner || !conv || !ownerId) {
|
|
387
|
+
requester?.sendNotice({
|
|
388
|
+
type: "notice",
|
|
389
|
+
level: "warning",
|
|
390
|
+
text: "该对话不存在或已关闭",
|
|
391
|
+
textEn: "This conversation does not exist or is already closed",
|
|
392
|
+
});
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
// 3. 针对共享执行客户端(如群组 Bot device-task-、定时任务、无头残骸)
|
|
396
|
+
const isSharedExecution = isSharedExecutionClientId(ownerId);
|
|
397
|
+
const isOffline = owner.sinkCount() === 0;
|
|
398
|
+
if (isSharedExecution || isOffline) {
|
|
399
|
+
if (owner.conversationStreaming(conv) && !msg.force) {
|
|
400
|
+
requester?.sendNotice({
|
|
401
|
+
type: "notice",
|
|
402
|
+
level: "warning",
|
|
403
|
+
text: `对话「${conv.title}」仍在运行中,请先等待结束或点击强行关闭`,
|
|
404
|
+
textEn: `Conversation "${conv.title}" is still running. Wait for it to finish or force dismiss.`,
|
|
405
|
+
});
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
if (owner.conversationStreaming(conv)) {
|
|
409
|
+
await owner.abortConversation(conv);
|
|
410
|
+
}
|
|
411
|
+
for (const [viewerId, binding] of this.sharedViewers) {
|
|
412
|
+
if (binding.owner === owner || binding.ownerClientId === ownerId) {
|
|
413
|
+
this.closeSharedConversation(viewerId);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
this.clients.delete(ownerId);
|
|
417
|
+
await owner.dispose().catch(() => { });
|
|
418
|
+
this.pokeExternalRunning(ownerId);
|
|
419
|
+
requester?.sendNotice({
|
|
420
|
+
type: "notice",
|
|
421
|
+
level: "info",
|
|
422
|
+
text: `已关闭并移出对话「${conv.title}」`,
|
|
423
|
+
textEn: `Closed and dismissed conversation "${conv.title}"`,
|
|
424
|
+
});
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
// 4. 普通在线客户端持有的 shared/可过户会话
|
|
428
|
+
await owner.dismissConversation(conv.id, msg.withFinishedSubagents, msg.force);
|
|
429
|
+
this.pokeExternalRunning(ownerId);
|
|
430
|
+
return true;
|
|
431
|
+
}
|
|
356
432
|
/** 客户端 -> 最后一个浏览器断开的时刻(离线行宽限期起点;重连/认领即删)。 */
|
|
357
433
|
offlineSince = new Map();
|
|
358
434
|
/** 客户端 -> 离线行宽限期到期定时器(到期后让其他客户端重推,行消失)。 */
|
|
@@ -629,6 +705,18 @@ export class AgentService {
|
|
|
629
705
|
}
|
|
630
706
|
return false;
|
|
631
707
|
}
|
|
708
|
+
/**
|
|
709
|
+
* 全局问卷直决:直接通过全局随机 UUID 定位持有问卷的会话并 resolve。
|
|
710
|
+
* 无需强依赖临时变更的 ownerId,跨页、重连认领与代理穿透均可直接命中。
|
|
711
|
+
*/
|
|
712
|
+
resolveGlobalQuestion(id, answers, cancelled, cancelReason) {
|
|
713
|
+
for (const client of this.clients.values()) {
|
|
714
|
+
if (client.resolveQuestion(id, answers, cancelled, cancelReason)) {
|
|
715
|
+
return true;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return false;
|
|
719
|
+
}
|
|
632
720
|
resolveSharedToolApproval(viewerId, ...args) {
|
|
633
721
|
if (!this.clients.has(viewerId) || isSharedExecutionClientId(viewerId))
|
|
634
722
|
return false;
|
|
@@ -1130,11 +1218,28 @@ export class AgentService {
|
|
|
1130
1218
|
}
|
|
1131
1219
|
}
|
|
1132
1220
|
const conversationId = cs.readConversationForPlugins()?.conversationId ?? "";
|
|
1133
|
-
|
|
1134
|
-
|
|
1221
|
+
const taskTitle = (task.name || "").trim() || (text.length > 30 ? text.slice(0, 30) : text);
|
|
1222
|
+
if (conversationId && taskTitle) {
|
|
1223
|
+
void cs.renameConversation(conversationId, taskTitle);
|
|
1224
|
+
}
|
|
1225
|
+
if (cs.readConversationForPlugins()?.isStreaming === true) {
|
|
1226
|
+
return {
|
|
1227
|
+
ok: false,
|
|
1228
|
+
conversationId: conversationId || undefined,
|
|
1229
|
+
error: "上一轮后台任务仍在执行中,跳过本次触发",
|
|
1230
|
+
};
|
|
1231
|
+
}
|
|
1232
|
+
let promptError;
|
|
1233
|
+
void cs.prompt(`[定时任务] ${text}`).catch((err) => {
|
|
1234
|
+
promptError = String(err?.message ?? err);
|
|
1235
|
+
});
|
|
1236
|
+
// 等待运行结束:每 2s 轮询,最长 10 分钟。超时按失败记录并中止运行(避免后台成为僵尸任务)。
|
|
1135
1237
|
const deadline = Date.now() + 10 * 60 * 1000;
|
|
1136
1238
|
for (;;) {
|
|
1137
1239
|
await new Promise((r) => setTimeout(r, 2000));
|
|
1240
|
+
if (promptError) {
|
|
1241
|
+
return { ok: false, conversationId: conversationId || undefined, error: promptError };
|
|
1242
|
+
}
|
|
1138
1243
|
let streaming = false;
|
|
1139
1244
|
let lastError;
|
|
1140
1245
|
try {
|
|
@@ -1159,8 +1264,19 @@ export class AgentService {
|
|
|
1159
1264
|
return { ok: false, conversationId: conversationId || undefined, error: lastError };
|
|
1160
1265
|
return { ok: true, conversationId: conversationId || undefined };
|
|
1161
1266
|
}
|
|
1162
|
-
if (Date.now() >= deadline)
|
|
1163
|
-
|
|
1267
|
+
if (Date.now() >= deadline) {
|
|
1268
|
+
try {
|
|
1269
|
+
await cs.abort();
|
|
1270
|
+
}
|
|
1271
|
+
catch {
|
|
1272
|
+
/* best-effort */
|
|
1273
|
+
}
|
|
1274
|
+
return {
|
|
1275
|
+
ok: false,
|
|
1276
|
+
conversationId: conversationId || undefined,
|
|
1277
|
+
error: "运行超时(10 分钟),已中止后台会话",
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1164
1280
|
}
|
|
1165
1281
|
}
|
|
1166
1282
|
catch (err) {
|
|
@@ -1498,8 +1614,17 @@ export class AgentService {
|
|
|
1498
1614
|
const target = this.clients.get(targetId);
|
|
1499
1615
|
if (!target)
|
|
1500
1616
|
return;
|
|
1501
|
-
|
|
1502
|
-
|
|
1617
|
+
let source = ownerId ? this.clients.get(ownerId) : undefined;
|
|
1618
|
+
let ok = source ? source.resolveQuestion(id, answers, cancelled, cancelReason) : false;
|
|
1619
|
+
if (!ok) {
|
|
1620
|
+
// 若指定的 owner 未命中或未持有该问卷(重连认领/过户导致 ownerId 变动),遍历所有 clients 寻找持有该 id 的会话
|
|
1621
|
+
for (const candidate of this.clients.values()) {
|
|
1622
|
+
if (candidate !== source && candidate.resolveQuestion(id, answers, cancelled, cancelReason)) {
|
|
1623
|
+
ok = true;
|
|
1624
|
+
break;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1503
1628
|
if (!ok) {
|
|
1504
1629
|
target.sendNotice({
|
|
1505
1630
|
type: "notice",
|
|
@@ -1560,6 +1685,7 @@ export class AgentService {
|
|
|
1560
1685
|
this.clearOfflineRows(orphan.oldId);
|
|
1561
1686
|
this.clients.set(clientId, orphan.cs);
|
|
1562
1687
|
cs = orphan.cs;
|
|
1688
|
+
orphan.cs.updateClientId?.(clientId);
|
|
1563
1689
|
// 先按新 id 重接(首帧 attachSink 的 elsewhere/self-exclusion 依赖它)。
|
|
1564
1690
|
this.wireClient(cs, clientId);
|
|
1565
1691
|
cs.noteAdopted();
|
|
@@ -1658,6 +1784,7 @@ export class AgentService {
|
|
|
1658
1784
|
if (clientId.startsWith("device-task-") && !isBotExecutionRegistered(clientId) && cs.sinkCount() === 0) {
|
|
1659
1785
|
this.clients.delete(clientId);
|
|
1660
1786
|
await cs.dispose();
|
|
1787
|
+
this.pokeExternalRunning(clientId);
|
|
1661
1788
|
return cs;
|
|
1662
1789
|
}
|
|
1663
1790
|
}
|
|
@@ -1760,6 +1887,7 @@ export class AgentService {
|
|
|
1760
1887
|
// Keep uncertain/disconnected executions owned until that confirmation.
|
|
1761
1888
|
this.clients.delete(clientId);
|
|
1762
1889
|
void cs.dispose().catch(() => { });
|
|
1890
|
+
this.pokeExternalRunning(clientId);
|
|
1763
1891
|
return;
|
|
1764
1892
|
}
|
|
1765
1893
|
// 最后一个 sink 断开 = 该客户端不再在线 → 它的行从「另一处」变成「另一处
|