personal-bot 0.2.20 → 0.3.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.
- package/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +2 -5
- package/.mcp.json +11 -0
- package/CONTEXT.md +17 -73
- package/README.md +41 -120
- package/README.zh-CN.md +41 -120
- package/docs/README.md +31 -23
- package/docs/architecture/design.md +74 -0
- package/docs/architecture/extensibility.md +78 -0
- package/docs/architecture/model-context.md +31 -0
- package/docs/architecture/model-instruction-guidelines.md +34 -0
- package/docs/architecture/principles.md +33 -0
- package/docs/guides/capabilities.md +36 -0
- package/docs/guides/cross-harness-workers.md +83 -0
- package/docs/guides/history.md +25 -0
- package/docs/guides/workspace-configuration.md +102 -0
- package/docs/hosts/antigravity.md +52 -0
- package/docs/hosts/claude-code.md +47 -0
- package/docs/hosts/dsh.md +67 -0
- package/docs/hosts/pi.md +49 -0
- package/docs/maintainers/release.md +59 -0
- package/hooks/hooks.json +0 -3
- package/lib/antigravity-plugin/hooks.json +23 -0
- package/lib/antigravity-plugin/lib/claude.d.ts +1 -0
- package/lib/antigravity-plugin/lib/claude.js +13 -0
- package/lib/antigravity-plugin/lib/common/json.d.ts +6 -0
- package/lib/antigravity-plugin/lib/common/json.js +16 -0
- package/lib/antigravity-plugin/lib/common/paths.d.ts +1 -0
- package/lib/antigravity-plugin/lib/common/paths.js +2 -0
- package/lib/antigravity-plugin/lib/common/validation.d.ts +3 -0
- package/lib/antigravity-plugin/lib/common/validation.js +8 -0
- package/lib/antigravity-plugin/lib/common/version.d.ts +3 -0
- package/lib/antigravity-plugin/lib/common/version.js +13 -0
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +11597 -0
- package/lib/antigravity-plugin/lib/extension/mcp.js +2715 -0
- package/lib/antigravity-plugin/lib/extension/plugin-runtime.d.ts +10 -0
- package/lib/antigravity-plugin/lib/extension/plugin-runtime.js +67 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +16 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +56 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.d.ts +4 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.js +79 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/claude.d.ts +3 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/claude.js +60 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/registry.d.ts +15 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/registry.js +34 -0
- package/lib/antigravity-plugin/lib/model/acp.d.ts +164 -0
- package/lib/antigravity-plugin/lib/model/acp.js +12 -0
- package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +48 -0
- package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +24 -0
- package/lib/antigravity-plugin/lib/model/workspace-config.js +1 -0
- package/lib/antigravity-plugin/lib/model/workspace-mcp.d.ts +51 -0
- package/lib/antigravity-plugin/lib/model/workspace-mcp.js +4 -0
- package/lib/antigravity-plugin/lib/plugin.d.ts +1 -0
- package/lib/antigravity-plugin/lib/plugin.js +17 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +8 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +95 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-preparation.d.ts +3 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-preparation.js +26 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.d.ts +8 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.js +91 -0
- package/lib/antigravity-plugin/lib/storage/atomic-json.d.ts +11 -0
- package/lib/antigravity-plugin/lib/storage/atomic-json.js +101 -0
- package/lib/antigravity-plugin/mcp_config.json +13 -0
- package/lib/antigravity-plugin/package.json +6 -0
- package/lib/antigravity-plugin/plugin.json +7 -0
- package/lib/antigravity-plugin/resources/agents/coordinator.md +11 -0
- package/{resources/claude → lib/antigravity-plugin/resources}/agents/general-purpose.md +0 -5
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -0
- package/lib/antigravity-plugin/resources/prompts/workspace.md +31 -0
- package/lib/antigravity-plugin/resources/references/compute-finance.md +22 -0
- package/lib/antigravity-plugin/resources/references/compute.md +16 -0
- package/lib/antigravity-plugin/resources/references/task-conductor.md +25 -0
- package/lib/antigravity-plugin/resources/templates/workspace-agents.md +21 -0
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +16 -0
- package/lib/antigravity-plugin/skills/project-maintenance/SKILL.md +35 -0
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +42 -0
- package/lib/claude.js +4 -11
- package/lib/client.js +14 -531
- package/lib/common/markdown.js +2 -3
- package/lib/common/validation.d.ts +2 -0
- package/lib/common/validation.js +4 -0
- package/lib/extension/acp-member.d.ts +2 -0
- package/lib/extension/acp-member.js +9 -8
- package/lib/extension/acp-worker.js +11578 -121
- package/lib/extension/dsh/acp-member.js +26 -2
- package/lib/extension/dsh/command.js +19 -57
- package/lib/extension/dsh/history.js +2 -4
- package/lib/extension/dsh/management.d.ts +0 -2
- package/lib/extension/dsh/management.js +27 -126
- package/lib/extension/dsh/workspace.d.ts +5 -47
- package/lib/extension/dsh/workspace.js +76 -108
- package/lib/extension/mcp-bridge.d.ts +41 -0
- package/lib/extension/mcp-bridge.js +412 -0
- package/lib/extension/mcp-workers.d.ts +980 -0
- package/lib/extension/mcp-workers.js +882 -0
- package/lib/extension/mcp.js +2715 -0
- package/lib/extension/plugin-runtime.d.ts +10 -0
- package/lib/extension/plugin-runtime.js +67 -0
- package/lib/extension/setup-cli.js +215 -2
- package/lib/integrations/acp/agents.d.ts +10 -11
- package/lib/integrations/acp/agents.js +65 -33
- package/lib/integrations/acp/claude.d.ts +2 -2
- package/lib/integrations/acp/claude.js +5 -3
- package/lib/integrations/acp/connection.d.ts +17 -4
- package/lib/integrations/acp/connection.js +53 -27
- package/lib/integrations/acp/executable.d.ts +3 -0
- package/lib/integrations/acp/executable.js +42 -0
- package/lib/integrations/acp/harnesses/claude.d.ts +2 -0
- package/lib/integrations/acp/harnesses/claude.js +49 -0
- package/lib/integrations/acp/harnesses/dsh.d.ts +2 -0
- package/lib/integrations/acp/harnesses/dsh.js +35 -0
- package/lib/integrations/acp/harnesses/generic.d.ts +13 -0
- package/lib/integrations/acp/harnesses/generic.js +37 -0
- package/lib/integrations/acp/harnesses/pi.d.ts +2 -0
- package/lib/integrations/acp/harnesses/pi.js +34 -0
- package/lib/integrations/acp/harnesses/presets.d.ts +3 -0
- package/lib/integrations/acp/harnesses/presets.js +20 -0
- package/lib/integrations/acp/launch.d.ts +33 -4
- package/lib/integrations/acp/launch.js +60 -48
- package/lib/integrations/acp/mcp.d.ts +6 -0
- package/lib/integrations/acp/mcp.js +40 -0
- package/lib/integrations/acp/model-selection.d.ts +9 -2
- package/lib/integrations/acp/model-selection.js +73 -27
- package/lib/integrations/acp/registry.d.ts +18 -0
- package/lib/integrations/acp/registry.js +50 -0
- package/lib/integrations/agent-resources.d.ts +16 -1
- package/lib/integrations/agent-resources.js +45 -9
- package/lib/integrations/dsh/mcp.d.ts +4 -0
- package/lib/integrations/dsh/mcp.js +28 -0
- package/lib/integrations/dsh/resources.d.ts +3 -3
- package/lib/integrations/dsh/resources.js +21 -12
- package/lib/integrations/dsh/skills.d.ts +5 -1
- package/lib/integrations/dsh/skills.js +10 -6
- package/lib/integrations/hosts/antigravity.d.ts +4 -0
- package/lib/integrations/hosts/antigravity.js +79 -0
- package/lib/integrations/hosts/claude.d.ts +3 -0
- package/lib/integrations/hosts/claude.js +60 -0
- package/lib/integrations/hosts/registry.d.ts +15 -0
- package/lib/integrations/hosts/registry.js +34 -0
- package/lib/model/acp.d.ts +107 -2
- package/lib/model/acp.js +12 -1
- package/lib/model/agent.d.ts +35 -33
- package/lib/model/plugin-host.d.ts +48 -0
- package/lib/model/plugin-host.js +1 -0
- package/lib/model/workspace-config.d.ts +12 -0
- package/lib/model/workspace-mcp.d.ts +51 -0
- package/lib/model/workspace-mcp.js +4 -0
- package/lib/plugin.d.ts +1 -0
- package/lib/plugin.js +17 -0
- package/lib/services/agents/acp-run.d.ts +13 -1
- package/lib/services/agents/acp-run.js +30 -2
- package/lib/services/agents/agent-service.d.ts +35 -120
- package/lib/services/agents/agent-service.js +156 -160
- package/lib/services/installation/setup-service.js +17 -1
- package/lib/services/workspace/workspace-config.d.ts +2 -1
- package/lib/services/workspace/workspace-config.js +43 -9
- package/lib/services/workspace/workspace-mcp.d.ts +14 -0
- package/lib/services/workspace/workspace-mcp.js +200 -0
- package/lib/services/workspace/workspace-skills.d.ts +8 -0
- package/lib/services/workspace/workspace-skills.js +91 -0
- package/lib/storage/acp-files.d.ts +3 -1
- package/lib/storage/acp-files.js +32 -2
- package/lib/storage/acp-history.d.ts +3 -2
- package/lib/storage/acp-history.js +19 -7
- package/lib/storage/agent-files.d.ts +8 -8
- package/lib/storage/agent-files.js +27 -47
- package/lib/tools/history/contract.d.ts +1 -1
- package/lib/tools/history/contract.js +17 -11
- package/lib/ui/dsh/index.js +8 -3
- package/lib/ui/dsh/management.d.ts +1 -1
- package/lib/ui/dsh/management.js +24 -456
- package/lib/ui/dsh/remote.d.ts +0 -2
- package/lib/ui/dsh/remote.js +1 -1
- package/package.json +12 -7
- package/resources/agents/coordinator.md +2 -2
- package/resources/antigravity/skills/pbot/SKILL.md +16 -0
- package/resources/claude/skills/pbot/SKILL.md +1 -1
- package/resources/prompts/history-coordinator.md +1 -0
- package/resources/prompts/plugin-coordinator.md +1 -0
- package/resources/prompts/workspace.md +9 -8
- package/resources/references/compute.md +9 -11
- package/resources/references/task-conductor.md +12 -26
- package/resources/skills/project-maintenance/SKILL.md +16 -21
- package/resources/skills/provider-connections/SKILL.md +24 -40
- package/resources/templates/workspace-agents.md +4 -0
- package/scripts/README.md +17 -34
- package/src/claude.ts +4 -8
- package/src/common/markdown.ts +2 -3
- package/src/common/validation.ts +6 -0
- package/src/extension/acp-member.ts +9 -8
- package/src/extension/acp-worker.ts +239 -97
- package/src/extension/command.ts +38 -36
- package/src/extension/dsh/acp-member.ts +21 -2
- package/src/extension/dsh/command.ts +21 -51
- package/src/extension/dsh/files.ts +1 -0
- package/src/extension/dsh/history.ts +9 -6
- package/src/extension/dsh/management.ts +27 -58
- package/src/extension/dsh/workspace.ts +88 -99
- package/src/extension/events.ts +13 -10
- package/src/extension/history.ts +2 -50
- package/src/extension/lifecycle.ts +37 -22
- package/src/extension/mcp-bridge.ts +412 -0
- package/src/extension/mcp-workers.ts +941 -0
- package/src/extension/pi-acp-member.ts +29 -5
- package/src/extension/plugin-runtime.ts +63 -0
- package/src/extension/setup-cli.ts +186 -2
- package/src/integrations/acp/agents.ts +70 -24
- package/src/integrations/acp/claude.ts +11 -4
- package/src/integrations/acp/connection.ts +63 -25
- package/src/integrations/acp/executable.ts +41 -0
- package/src/integrations/acp/harnesses/claude.ts +50 -0
- package/src/integrations/acp/harnesses/dsh.ts +40 -0
- package/src/integrations/acp/harnesses/generic.ts +52 -0
- package/src/integrations/acp/harnesses/pi.ts +35 -0
- package/src/integrations/acp/harnesses/presets.ts +22 -0
- package/src/integrations/acp/launch.ts +69 -47
- package/src/integrations/acp/mcp.ts +43 -0
- package/src/integrations/acp/model-selection.ts +68 -25
- package/src/integrations/acp/registry.ts +60 -0
- package/src/integrations/agent-resources.ts +70 -6
- package/src/integrations/dsh/mcp.ts +30 -0
- package/src/integrations/dsh/resources.ts +28 -13
- package/src/integrations/dsh/skills.ts +16 -6
- package/src/integrations/hosts/antigravity.ts +83 -0
- package/src/integrations/hosts/claude.ts +62 -0
- package/src/integrations/hosts/registry.ts +42 -0
- package/src/integrations/pi/mcp.ts +26 -0
- package/src/mcp.ts +14 -0
- package/src/model/acp.ts +113 -3
- package/src/model/agent.ts +18 -14
- package/src/model/plugin-host.ts +39 -0
- package/src/model/workspace-config.ts +14 -0
- package/src/model/workspace-mcp.ts +64 -0
- package/src/pbot.ts +69 -20
- package/src/plugin.ts +19 -0
- package/src/services/agents/acp-run.ts +35 -3
- package/src/services/agents/agent-service.ts +180 -160
- package/src/services/installation/setup-service.ts +17 -2
- package/src/services/workspace/workspace-config.ts +46 -8
- package/src/services/workspace/workspace-mcp.ts +242 -0
- package/src/services/workspace/workspace-skills.ts +78 -0
- package/src/storage/acp-files.ts +32 -3
- package/src/storage/acp-history.ts +18 -7
- package/src/storage/agent-files.ts +27 -41
- package/src/tools/history/contract.ts +17 -11
- package/src/tools/register.ts +4 -8
- package/src/ui/dsh/index.ts +8 -3
- package/src/ui/dsh/management.ts +40 -282
- package/src/ui/dsh/remote.ts +2 -2
- package/docs/adr/0001-claude-skill-discovery.md +0 -3
- package/docs/adr/0002-claude-native-collaboration.md +0 -3
- package/docs/agent-collaboration.md +0 -190
- package/docs/architecture-guidelines.md +0 -37
- package/docs/capability-design.md +0 -55
- package/docs/claude-code-design.md +0 -44
- package/docs/claude-code.md +0 -57
- package/docs/dsh.md +0 -337
- package/docs/file-storage.md +0 -97
- package/docs/history.md +0 -54
- package/docs/installation-design.md +0 -86
- package/docs/interaction-design.md +0 -21
- package/docs/model-context.md +0 -76
- package/docs/model-instruction-guidelines.md +0 -51
- package/docs/release.md +0 -108
- package/docs/technical-design.md +0 -163
- package/docs/workspace-configuration.md +0 -79
- package/lib/extension/claude-hooks.d.ts +0 -9
- package/lib/extension/claude-hooks.js +0 -78
- package/lib/extension/dsh/agent-events.d.ts +0 -24
- package/lib/extension/dsh/agent-events.js +0 -242
- package/lib/extension/dsh/agent-runtime.d.ts +0 -49
- package/lib/extension/dsh/agent-runtime.js +0 -351
- package/lib/integrations/dsh/dsh-agents.d.ts +0 -30
- package/lib/integrations/dsh/dsh-agents.js +0 -104
- package/lib/integrations/dsh/input.d.ts +0 -21
- package/lib/integrations/dsh/input.js +0 -62
- package/lib/integrations/dsh/notifications.d.ts +0 -8
- package/lib/integrations/dsh/notifications.js +0 -55
- package/lib/integrations/dsh/session.d.ts +0 -14
- package/lib/integrations/dsh/session.js +0 -60
- package/lib/integrations/team-context.d.ts +0 -18
- package/lib/integrations/team-context.js +0 -61
- package/lib/model/team.d.ts +0 -85
- package/lib/services/agents/agent-notices.d.ts +0 -13
- package/lib/services/agents/agent-notices.js +0 -25
- package/lib/services/agents/start-options.d.ts +0 -4
- package/lib/services/agents/start-options.js +0 -20
- package/lib/services/agents/team-service.d.ts +0 -168
- package/lib/services/agents/team-service.js +0 -345
- package/lib/storage/team-files.d.ts +0 -16
- package/lib/storage/team-files.js +0 -111
- package/lib/tools/agents/actions.d.ts +0 -62
- package/lib/tools/agents/actions.js +0 -62
- package/lib/tools/agents/contract.d.ts +0 -181
- package/lib/tools/agents/contract.js +0 -84
- package/lib/tools/agents/dsh-tool.d.ts +0 -5
- package/lib/tools/agents/dsh-tool.js +0 -34
- package/lib/tools/result.d.ts +0 -18
- package/lib/tools/result.js +0 -10
- package/lib/tools/teams/actions.d.ts +0 -23
- package/lib/tools/teams/actions.js +0 -40
- package/lib/tools/teams/contract.d.ts +0 -201
- package/lib/tools/teams/contract.js +0 -91
- package/lib/tools/teams/dsh-tool.d.ts +0 -8
- package/lib/tools/teams/dsh-tool.js +0 -39
- package/lib/ui/dsh/attachments.d.ts +0 -5
- package/lib/ui/dsh/attachments.js +0 -39
- package/resources/prompts/claude-coordinator.md +0 -1
- package/resources/prompts/native-coordinator.md +0 -1
- package/resources/prompts/team-member.md +0 -7
- package/src/extension/agent-events.ts +0 -210
- package/src/extension/agents-command.ts +0 -89
- package/src/extension/claude-hooks.ts +0 -74
- package/src/extension/dsh/agent-events.ts +0 -148
- package/src/extension/dsh/agent-runtime.ts +0 -252
- package/src/extension/subagent-entry.ts +0 -270
- package/src/extension/teams-command.ts +0 -67
- package/src/integrations/dsh/dsh-agents.ts +0 -97
- package/src/integrations/dsh/input.ts +0 -66
- package/src/integrations/dsh/notifications.ts +0 -46
- package/src/integrations/pi/agent-context.ts +0 -18
- package/src/integrations/pi/agent-input.ts +0 -19
- package/src/integrations/pi/pi-agents.ts +0 -84
- package/src/integrations/pi/team-context.ts +0 -26
- package/src/integrations/team-context.ts +0 -64
- package/src/model/team.ts +0 -29
- package/src/services/agents/agent-notices.ts +0 -28
- package/src/services/agents/start-options.ts +0 -19
- package/src/services/agents/team-service.ts +0 -275
- package/src/storage/team-files.ts +0 -93
- package/src/tools/agents/actions.ts +0 -57
- package/src/tools/agents/contract.ts +0 -101
- package/src/tools/agents/dsh-tool.ts +0 -37
- package/src/tools/agents/tool.ts +0 -20
- package/src/tools/teams/actions.ts +0 -34
- package/src/tools/teams/contract.ts +0 -109
- package/src/tools/teams/dsh-tool.ts +0 -45
- package/src/tools/teams/tool.ts +0 -29
- package/src/ui/agent-display.ts +0 -14
- package/src/ui/dsh/attachments.ts +0 -42
- package/src/ui/pi/menu.ts +0 -37
- package/src/ui/pi/reader.ts +0 -46
- /package/lib/{model/team.js → antigravity-plugin/lib/model/plugin-host.js} +0 -0
package/lib/client.js
CHANGED
|
@@ -48,7 +48,7 @@ function json(value2) {
|
|
|
48
48
|
var value = { mode: "strict", typeSymbol: "personal-bot#Json", create: () => ({ parse: json }) };
|
|
49
49
|
var pbotReadRemote = {
|
|
50
50
|
package: "personal-bot",
|
|
51
|
-
descriptors: ["snapshot", "
|
|
51
|
+
descriptors: ["snapshot", "history"].map((method) => ({
|
|
52
52
|
id: "personal-bot#PbotManagement." + method,
|
|
53
53
|
service: "pbotManagement",
|
|
54
54
|
namespace: "pbot",
|
|
@@ -60,67 +60,6 @@ var pbotReadRemote = {
|
|
|
60
60
|
}))
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
// src/ui/dsh/attachments.ts
|
|
64
|
-
var images = /* @__PURE__ */ new Set(["image/png", "image/jpeg", "image/webp", "image/gif"]);
|
|
65
|
-
function encodedImage(file, signal) {
|
|
66
|
-
signal.throwIfAborted();
|
|
67
|
-
return new Promise((resolve, reject) => {
|
|
68
|
-
const reader = new FileReader(), abort = () => reader.abort();
|
|
69
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
70
|
-
reader.onloadend = () => signal.removeEventListener("abort", abort);
|
|
71
|
-
reader.onerror = () => reject(reader.error ?? new Error("\u56FE\u7247\u8BFB\u53D6\u5931\u8D25\u3002"));
|
|
72
|
-
reader.onabort = () => reject(signal.reason ?? new DOMException("\u56FE\u7247\u8BFB\u53D6\u5DF2\u53D6\u6D88\u3002", "AbortError"));
|
|
73
|
-
reader.onload = () => {
|
|
74
|
-
if (typeof reader.result !== "string") reject(new Error("\u56FE\u7247\u8BFB\u53D6\u5931\u8D25\u3002"));
|
|
75
|
-
else resolve(reader.result.slice(reader.result.indexOf(",") + 1));
|
|
76
|
-
};
|
|
77
|
-
reader.readAsDataURL(file);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
async function commandAttachments(ctx, sessionId, files, signal, progress) {
|
|
81
|
-
if (files.length > 32) throw new Error("\u4E00\u6B21\u6700\u591A\u9644\u52A0 32 \u4E2A\u6587\u4EF6\u3002");
|
|
82
|
-
const attachments = [];
|
|
83
|
-
for (const file of files) {
|
|
84
|
-
signal.throwIfAborted();
|
|
85
|
-
progress("\u6B63\u5728\u51C6\u5907\u9644\u4EF6\uFF1A" + file.name);
|
|
86
|
-
if (images.has(file.type)) {
|
|
87
|
-
attachments.push({ type: "image", mediaType: file.type, name: file.name, data: await encodedImage(file, signal) });
|
|
88
|
-
} else {
|
|
89
|
-
const result = await ctx.fileUpload.upload(
|
|
90
|
-
sessionId,
|
|
91
|
-
file,
|
|
92
|
-
file.name,
|
|
93
|
-
signal,
|
|
94
|
-
(value2) => progress(`\u6B63\u5728\u4E0A\u4F20 ${file.name}\uFF1A${value2.loaded} / ${value2.total ?? file.size} \u5B57\u8282`)
|
|
95
|
-
);
|
|
96
|
-
if (!result.ok) throw new Error(result.error.message);
|
|
97
|
-
attachments.push({ type: "file", receiptId: result.value.receiptId });
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
signal.throwIfAborted();
|
|
101
|
-
return attachments;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// src/ui/presentation.ts
|
|
105
|
-
var states = {
|
|
106
|
-
starting: "\u542F\u52A8\u4E2D",
|
|
107
|
-
busy: "\u6267\u884C\u4E2D",
|
|
108
|
-
idle: "\u5F85\u547D",
|
|
109
|
-
stopping: "\u505C\u6B62\u4E2D",
|
|
110
|
-
stopped: "\u5DF2\u505C\u6B62",
|
|
111
|
-
error: "\u9700\u8981\u5904\u7406",
|
|
112
|
-
running: "\u8FDB\u884C\u4E2D",
|
|
113
|
-
paused: "\u5DF2\u6682\u505C",
|
|
114
|
-
finished: "\u5DF2\u7ED3\u675F",
|
|
115
|
-
completed: "\u5DF2\u5B8C\u6210",
|
|
116
|
-
failed: "\u5931\u8D25",
|
|
117
|
-
cancelled: "\u5DF2\u53D6\u6D88",
|
|
118
|
-
interrupted: "\u5DF2\u4E2D\u65AD",
|
|
119
|
-
open: "\u5F85\u5B89\u6392",
|
|
120
|
-
closed: "\u5DF2\u5173\u95ED"
|
|
121
|
-
};
|
|
122
|
-
var stateLabel = (state) => states[String(state)] ?? String(state ?? "\u672A\u77E5");
|
|
123
|
-
|
|
124
63
|
// src/ui/dsh/elements.ts
|
|
125
64
|
var record = (value2) => {
|
|
126
65
|
if (!object(value2)) throw new Error("\u7BA1\u7406\u6570\u636E\u65E0\u6548\u3002");
|
|
@@ -128,8 +67,6 @@ var record = (value2) => {
|
|
|
128
67
|
};
|
|
129
68
|
var rows = (value2) => Array.isArray(value2) ? value2.map(record) : [];
|
|
130
69
|
var text = (value2) => value2 === null || value2 === void 0 ? "" : String(value2);
|
|
131
|
-
var objectInput = (value2) => record(JSON.parse(value2 || "{}"));
|
|
132
|
-
var lines = (value2) => value2.split(/\r?\n/).map((item) => item.trim()).filter(Boolean);
|
|
133
70
|
function element(tag, content = "", className = "") {
|
|
134
71
|
const node = document.createElement(tag);
|
|
135
72
|
node.textContent = content;
|
|
@@ -176,11 +113,6 @@ function select(parent, label, values) {
|
|
|
176
113
|
parent.append(wrapper);
|
|
177
114
|
return input;
|
|
178
115
|
}
|
|
179
|
-
function badge(state) {
|
|
180
|
-
const node = element("span", stateLabel(state), "pbot-badge");
|
|
181
|
-
node.dataset.state = text(state);
|
|
182
|
-
return node;
|
|
183
|
-
}
|
|
184
116
|
function facts(values) {
|
|
185
117
|
const node = element("dl", "", "pbot-facts");
|
|
186
118
|
for (const [label, value2] of values) node.append(element("dt", label), element("dd", text(value2) || "\u2014"));
|
|
@@ -360,10 +292,9 @@ function showManagement(ctx, parentSessionId) {
|
|
|
360
292
|
dialog.prepend(style);
|
|
361
293
|
const lifetime = new AbortController();
|
|
362
294
|
let closed = false, timer, tab = "status";
|
|
363
|
-
let snapshot
|
|
364
|
-
let snapshotRevision = 0,
|
|
365
|
-
|
|
366
|
-
const sections = /* @__PURE__ */ new Map(), tabs = /* @__PURE__ */ new Map(), tabCounts = /* @__PURE__ */ new Map();
|
|
295
|
+
let snapshot;
|
|
296
|
+
let snapshotRevision = 0, historyRevision = 0, pollError = false;
|
|
297
|
+
const sections = /* @__PURE__ */ new Map(), tabs = /* @__PURE__ */ new Map();
|
|
367
298
|
function inform(message, tone = "info") {
|
|
368
299
|
if (closed) return;
|
|
369
300
|
notice.textContent = message;
|
|
@@ -439,10 +370,6 @@ function showManagement(ctx, parentSessionId) {
|
|
|
439
370
|
control.setAttribute("aria-controls", node.id);
|
|
440
371
|
control.setAttribute("aria-selected", String(id === tab));
|
|
441
372
|
control.tabIndex = id === tab ? 0 : -1;
|
|
442
|
-
const count = element("small");
|
|
443
|
-
count.setAttribute("aria-hidden", "true");
|
|
444
|
-
control.append(count);
|
|
445
|
-
tabCounts.set(id, count);
|
|
446
373
|
tabs.set(id, control);
|
|
447
374
|
return node;
|
|
448
375
|
}
|
|
@@ -463,8 +390,8 @@ function showManagement(ctx, parentSessionId) {
|
|
|
463
390
|
lifetime.signal.throwIfAborted();
|
|
464
391
|
return record(result.value);
|
|
465
392
|
}
|
|
466
|
-
async function command(verb, input, message = "\u64CD\u4F5C\u5DF2\u63A5\u7EB3\u3002"
|
|
467
|
-
const result = await ctx.remote.commands.execute(parentSessionId, "/pbot " + verb + (input === void 0 ? "" : " " + JSON.stringify(input)),
|
|
393
|
+
async function command(verb, input, message = "\u64CD\u4F5C\u5DF2\u63A5\u7EB3\u3002") {
|
|
394
|
+
const result = await ctx.remote.commands.execute(parentSessionId, "/pbot " + verb + (input === void 0 ? "" : " " + JSON.stringify(input)), []);
|
|
468
395
|
if (!result.ok) throw new Error(result.error.message + "\uFF1B\u5982\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u8BF7\u5148\u5237\u65B0\u8BB0\u5F55\u786E\u8BA4\u64CD\u4F5C\u662F\u5426\u5DF2\u63A5\u7EB3\u3002");
|
|
469
396
|
if (!result.value) throw new Error("\u7BA1\u7406\u547D\u4EE4\u672A\u88AB\u63A5\u7EB3\u3002");
|
|
470
397
|
if (result.value.result.kind === "error") throw new Error(result.value.result.text);
|
|
@@ -491,373 +418,6 @@ function showManagement(ctx, parentSessionId) {
|
|
|
491
418
|
const diagnostic = details(status, "\u73AF\u5883\u8BE6\u60C5"), statusBody = block("");
|
|
492
419
|
statusBody.classList.add("pbot-raw");
|
|
493
420
|
diagnostic.append(statusBody);
|
|
494
|
-
const permissions = group(status, "pbot-setting");
|
|
495
|
-
permissions.hidden = true;
|
|
496
|
-
let permissionKey = "";
|
|
497
|
-
const experts = section("experts", "\u4E13\u5BB6");
|
|
498
|
-
pageTitle(experts, "\u4E13\u5BB6", "");
|
|
499
|
-
const create = details(experts, "\u521B\u5EFA\u4E13\u5BB6"), createForm = form(create), newName = field(createForm, "\u540D\u79F0"), initial = field(createForm, "\u4EFB\u52A1\uFF08\u53EF\u9009\uFF09", true);
|
|
500
|
-
newName.placeholder = "\u4F8B\u5982\uFF1A\u7814\u7A76\u5458";
|
|
501
|
-
initial.placeholder = "\u4EFB\u52A1\u76EE\u6807\u4E0E\u4EA4\u4ED8\u8981\u6C42";
|
|
502
|
-
const backend = select(createForm, "\u8FD0\u884C\u5BBF\u4E3B", [["", "\u5F53\u524D\u5BBF\u4E3B"], ["pi", "Pi"], ["dsh", "dsh"], ["claude", "Claude Code"]]);
|
|
503
|
-
const options = details(createForm, "\u6A21\u578B\u4E0E\u9009\u9879"), modelFields = group(options, "pbot-grid");
|
|
504
|
-
options.querySelector("summary").after(note("\u5F53\u524D\u5BBF\u4E3B\u7559\u7A7A\u6CBF\u7528\u4E3B\u4F1A\u8BDD\uFF1B\u5176\u4ED6\u5BBF\u4E3B\u7559\u7A7A\u4F7F\u7528\u76EE\u6807\u914D\u7F6E\u3002"));
|
|
505
|
-
const provider = field(modelFields, "Provider"), model = field(modelFields, "\u6A21\u578B");
|
|
506
|
-
const effort = field(options, "Reasoning effort"), cwd = field(options, "\u5DE5\u4F5C\u76EE\u5F55");
|
|
507
|
-
const files = field(options, "\u6587\u4EF6\u8DEF\u5F84\uFF08\u6BCF\u884C\u4E00\u4E2A\uFF09", true);
|
|
508
|
-
const advanced = field(details(options, "\u5176\u4ED6\u9009\u9879"), "JSON", true, "{}");
|
|
509
|
-
submit(createForm, "\u521B\u5EFA", async () => {
|
|
510
|
-
const args = {
|
|
511
|
-
...objectInput(advanced.value),
|
|
512
|
-
action: "start",
|
|
513
|
-
...backend.value ? { backend: backend.value } : {},
|
|
514
|
-
...newName.value ? { name: newName.value } : {},
|
|
515
|
-
...initial.value ? { message: initial.value } : {},
|
|
516
|
-
...provider.value ? { provider: provider.value } : {},
|
|
517
|
-
...model.value ? { model: model.value } : {},
|
|
518
|
-
...effort.value ? { thinking: effort.value } : {},
|
|
519
|
-
...cwd.value ? { cwd: cwd.value } : {},
|
|
520
|
-
...lines(files.value).length ? { files: lines(files.value) } : {}
|
|
521
|
-
};
|
|
522
|
-
const output = objectInput(await command("agent", args, "\u4E13\u5BB6\u5DF2\u521B\u5EFA\u3002"));
|
|
523
|
-
if (initial.value === (args.message ?? "")) initial.value = "";
|
|
524
|
-
create.open = false;
|
|
525
|
-
await chooseExpert(text(output.agentId));
|
|
526
|
-
});
|
|
527
|
-
const expertSplit = group(experts, "pbot-split"), expertAside = group(expertSplit), expertFilter = field(expertAside, "\u7B5B\u9009\u4E13\u5BB6");
|
|
528
|
-
expertFilter.placeholder = "\u540D\u79F0\u6216\u72B6\u6001";
|
|
529
|
-
const expertList = group(expertAside, "pbot-list");
|
|
530
|
-
expertList.setAttribute("aria-label", "\u4E13\u5BB6\u5217\u8868");
|
|
531
|
-
const expertDetail = group(expertSplit, "pbot-detail"), expertEmpty = empty("\u9009\u62E9\u4E13\u5BB6", "\u67E5\u770B\u8BB0\u5F55\u6216\u53D1\u9001\u6D88\u606F\u3002");
|
|
532
|
-
expertDetail.append(expertEmpty);
|
|
533
|
-
const expertPanel = group(expertDetail);
|
|
534
|
-
expertPanel.hidden = true;
|
|
535
|
-
const expertHeading = group(expertPanel, "pbot-detail-title"), expertTitle = element("h3"), expertBadge = element("span");
|
|
536
|
-
expertHeading.append(expertTitle, expertBadge);
|
|
537
|
-
const expertInfo = group(expertPanel), expertError = element("p", "", "pbot-warning");
|
|
538
|
-
expertPanel.append(expertError);
|
|
539
|
-
expertError.hidden = true;
|
|
540
|
-
const expertControls = group(expertPanel, "pbot-row"), requireExpert = () => {
|
|
541
|
-
if (!expertId) throw new Error("\u8BF7\u5148\u9009\u62E9\u4E13\u5BB6\u3002");
|
|
542
|
-
return expertId;
|
|
543
|
-
};
|
|
544
|
-
const stopButton = button(expertControls, "\u505C\u6B62\u4E13\u5BB6", async () => {
|
|
545
|
-
await command("agent", { action: "stop", agentId: requireExpert() }, "\u5DF2\u8BF7\u6C42\u505C\u6B62\u4E13\u5BB6\u3002");
|
|
546
|
-
await loadExpert();
|
|
547
|
-
}, "pbot-danger");
|
|
548
|
-
const editExpert = details(expertPanel, "\u540D\u79F0\u4E0E\u4F1A\u8BDD\u8BE6\u60C5"), renameForm = form(editExpert), rename = field(renameForm, "\u65B0\u540D\u79F0");
|
|
549
|
-
rename.required = true;
|
|
550
|
-
submit(renameForm, "\u91CD\u547D\u540D", async () => {
|
|
551
|
-
await command("agent", { action: "rename", agentId: requireExpert(), name: rename.value }, "\u4E13\u5BB6\u540D\u79F0\u5DF2\u66F4\u65B0\u3002");
|
|
552
|
-
await loadExpert();
|
|
553
|
-
});
|
|
554
|
-
const expertState = block("");
|
|
555
|
-
expertState.classList.add("pbot-raw");
|
|
556
|
-
editExpert.append(expertState);
|
|
557
|
-
const resume = details(expertPanel, "\u6062\u590D\u4E13\u5BB6"), resumeForm = form(resume), resumeText = field(resumeForm, "\u65B0\u4EFB\u52A1", true);
|
|
558
|
-
resumeText.required = true;
|
|
559
|
-
const resumeButton = submit(resumeForm, "\u6062\u590D\u5E76\u53D1\u9001\u65B0\u4EFB\u52A1", async () => {
|
|
560
|
-
const message = resumeText.value;
|
|
561
|
-
await command("agent", { action: "resume", agentId: requireExpert(), message }, "\u4E13\u5BB6\u5DF2\u6062\u590D\uFF0C\u65B0\u4EFB\u52A1\u5DF2\u6392\u961F\u3002");
|
|
562
|
-
if (resumeText.value === message) resumeText.value = "";
|
|
563
|
-
await loadExpert();
|
|
564
|
-
});
|
|
565
|
-
const chatCard = group(expertPanel, "pbot-card");
|
|
566
|
-
chatCard.append(element("h3", "\u4EBA\u5DE5\u5BF9\u8BDD"), note("\u53D1\u9001\u524D\u6682\u505C\u56E2\u961F\u65B0\u5B89\u6392\u3002"));
|
|
567
|
-
const chatForm = form(chatCard), chat = field(chatForm, "\u6D88\u606F", true);
|
|
568
|
-
chat.maxLength = 24e3;
|
|
569
|
-
chat.placeholder = "\u8865\u5145\u8D44\u6599\u3001\u8C03\u6574\u65B9\u5411\uFF0C\u6216\u63D0\u51FA\u65B0\u95EE\u9898\u2026";
|
|
570
|
-
const delivery = select(chatForm, "\u6295\u9012\u65F6\u673A", [["steer", "\u4E0B\u4E00\u4E2A\u5B89\u5168\u6B65\u9AA4"], ["followUp", "\u4E0B\u4E00\u8F6E"]]);
|
|
571
|
-
const localFiles = field(chatForm, "\u9644\u4EF6");
|
|
572
|
-
localFiles.type = "file";
|
|
573
|
-
localFiles.multiple = true;
|
|
574
|
-
const chatFiles = field(details(chatForm, "\u670D\u52A1\u5668\u6587\u4EF6"), "\u8DEF\u5F84\uFF08\u6BCF\u884C\u4E00\u4E2A\uFF09", true);
|
|
575
|
-
const expertDrafts = /* @__PURE__ */ new Map();
|
|
576
|
-
function clearSentDraft(id, input, paths, chosen) {
|
|
577
|
-
const draft = expertDrafts.get(id);
|
|
578
|
-
if (draft) {
|
|
579
|
-
if (draft.text === input.text) draft.text = "";
|
|
580
|
-
if (draft.paths === paths) draft.paths = "";
|
|
581
|
-
if (draft.files.length === chosen.length && draft.files.every((file, index) => file === chosen[index])) draft.files = [];
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
const sendButton = submit(chatForm, "\u53D1\u9001\u4EBA\u5DE5\u6D88\u606F", async () => {
|
|
585
|
-
const id = requireExpert(), fileText = chatFiles.value, files2 = lines(fileText), chosen = Array.from(localFiles.files ?? []);
|
|
586
|
-
if (files2.length && chosen.length) throw new Error("\u4E00\u6B21\u5BF9\u8BDD\u8BF7\u9009\u62E9\u670D\u52A1\u5668\u6587\u4EF6\u6216\u672C\u673A\u9644\u4EF6\uFF0C\u4E0D\u80FD\u540C\u65F6\u4F7F\u7528\u3002");
|
|
587
|
-
if (!chat.value.trim() && !files2.length && !chosen.length) {
|
|
588
|
-
chat.focus();
|
|
589
|
-
throw new Error("\u8BF7\u8F93\u5165\u6D88\u606F\u6216\u6DFB\u52A0\u9644\u4EF6\u3002");
|
|
590
|
-
}
|
|
591
|
-
const input = { agentId: id, text: chat.value, delivery: delivery.value, files: files2 };
|
|
592
|
-
const attachments = await commandAttachments(ctx, parentSessionId, chosen, lifetime.signal, inform);
|
|
593
|
-
lifetime.signal.throwIfAborted();
|
|
594
|
-
await command("chat", input, "\u6D88\u606F\u5DF2\u6392\u961F\uFF0C\u4E13\u5BB6\u4F1A\u5728\u6240\u9009\u65F6\u673A\u63A5\u6536\u3002", attachments);
|
|
595
|
-
clearSentDraft(id, input, fileText, chosen);
|
|
596
|
-
if (expertId === id) {
|
|
597
|
-
if (chat.value === input.text) chat.value = "";
|
|
598
|
-
if (chatFiles.value === fileText) chatFiles.value = "";
|
|
599
|
-
const current = Array.from(localFiles.files ?? []);
|
|
600
|
-
if (current.length === chosen.length && current.every((file, index) => file === chosen[index])) localFiles.value = "";
|
|
601
|
-
await loadExpert();
|
|
602
|
-
}
|
|
603
|
-
});
|
|
604
|
-
const transcript = group(expertPanel, "pbot-transcript");
|
|
605
|
-
transcript.append(element("h3", "\u5BF9\u8BDD\u4E0E\u6D3B\u52A8"));
|
|
606
|
-
const recordControls = group(transcript, "pbot-pagination"), eventList = group(transcript), rawEvents = details(transcript, "\u5168\u90E8\u539F\u751F\u4E8B\u4EF6"), rawEventList = group(rawEvents);
|
|
607
|
-
const eventDetail = details(transcript, "\u5B8C\u6574\u8BB0\u5F55"), eventBody = block(""), eventPaging = element("div", "", "pbot-pagination");
|
|
608
|
-
eventDetail.append(eventBody, eventPaging);
|
|
609
|
-
eventDetail.hidden = true;
|
|
610
|
-
async function chooseExpert(id) {
|
|
611
|
-
if (id !== expertId) {
|
|
612
|
-
if (expertId) expertDrafts.set(expertId, { text: chat.value, delivery: delivery.value, paths: chatFiles.value, files: Array.from(localFiles.files ?? []) });
|
|
613
|
-
const draft = expertDrafts.get(id);
|
|
614
|
-
chat.value = draft?.text ?? "";
|
|
615
|
-
delivery.value = draft?.delivery ?? "steer";
|
|
616
|
-
chatFiles.value = draft?.paths ?? "";
|
|
617
|
-
const transfer = new DataTransfer();
|
|
618
|
-
for (const file of draft?.files ?? []) transfer.items.add(file);
|
|
619
|
-
localFiles.files = transfer.files;
|
|
620
|
-
rename.value = "";
|
|
621
|
-
resumeText.value = "";
|
|
622
|
-
}
|
|
623
|
-
expertId = id;
|
|
624
|
-
expertOffset = void 0;
|
|
625
|
-
expertPageKey = "";
|
|
626
|
-
++recordRevision;
|
|
627
|
-
++expertRevision;
|
|
628
|
-
eventBody.textContent = "";
|
|
629
|
-
eventDetail.hidden = true;
|
|
630
|
-
eventPaging.replaceChildren();
|
|
631
|
-
expertPanel.hidden = true;
|
|
632
|
-
expertEmpty.hidden = false;
|
|
633
|
-
expertEmpty.replaceChildren(note("\u6B63\u5728\u8BFB\u53D6\u4E13\u5BB6\u8BB0\u5F55\u2026"));
|
|
634
|
-
renderLists();
|
|
635
|
-
await loadExpert();
|
|
636
|
-
}
|
|
637
|
-
function showExpert(agent) {
|
|
638
|
-
expertTitle.textContent = text(agent.name);
|
|
639
|
-
expertBadge.replaceChildren(badge(agent.state));
|
|
640
|
-
expertPanel.hidden = false;
|
|
641
|
-
expertEmpty.hidden = true;
|
|
642
|
-
const config = object(agent.options) ? agent.options : {}, selected = record(agent.selection);
|
|
643
|
-
const configuredModel = [selected.provider ?? config.provider, selected.model ?? config.model].filter(Boolean).join("/");
|
|
644
|
-
const chosenModel = selected.resolvedModel && selected.resolvedModel !== configuredModel ? `${configuredModel} \u2192 ${text(selected.resolvedModel)}` : configuredModel;
|
|
645
|
-
expertInfo.replaceChildren(note(text(agent.activity) || "\u7B49\u5F85\u65B0\u7684\u4EFB\u52A1\u3002"), facts([
|
|
646
|
-
["\u5BBF\u4E3B", agent.backend || "\u5F53\u524D\u5BBF\u4E3B"],
|
|
647
|
-
["\u6A21\u578B", chosenModel || (agent.transport === "acp" ? "\u76EE\u6807\u5BBF\u4E3B\u914D\u7F6E" : "\u7EE7\u627F\u7236\u4F1A\u8BDD")],
|
|
648
|
-
["\u601D\u8003\u7B49\u7EA7", selected.thinking || config.thinking || "\u5BBF\u4E3B\u9ED8\u8BA4"],
|
|
649
|
-
["\u5DE5\u4F5C\u76EE\u5F55", agent.cwd]
|
|
650
|
-
]));
|
|
651
|
-
const steering = delivery.querySelector('option[value="steer"]');
|
|
652
|
-
steering.disabled = agent.transport === "acp";
|
|
653
|
-
if (steering.disabled && delivery.value === "steer") delivery.value = "followUp";
|
|
654
|
-
expertState.textContent = JSON.stringify(agent, null, 2);
|
|
655
|
-
expertError.textContent = text(agent.error);
|
|
656
|
-
expertError.hidden = !agent.error;
|
|
657
|
-
const alive = agent.alive === true, owned = agent.owned === true;
|
|
658
|
-
enabled(stopButton, owned && alive && agent.state !== "stopping");
|
|
659
|
-
enabled(sendButton, owned && alive && !["starting", "stopping"].includes(text(agent.state)));
|
|
660
|
-
enabled(resumeButton, owned && !alive);
|
|
661
|
-
resume.hidden = alive;
|
|
662
|
-
}
|
|
663
|
-
async function loadRecord(seq, offset = 0, format = "text") {
|
|
664
|
-
const revision = ++recordRevision, id = requireExpert(), data = await query("expert", { agentId: id, seq, textOffset: offset, format });
|
|
665
|
-
if (id !== expertId || revision !== recordRevision) return;
|
|
666
|
-
eventDetail.hidden = false;
|
|
667
|
-
eventDetail.open = true;
|
|
668
|
-
eventBody.textContent = text(data.text);
|
|
669
|
-
eventBody.classList.toggle("pbot-raw", format === "json");
|
|
670
|
-
eventPaging.replaceChildren(element("span", `\u8BB0\u5F55 ${seq} \xB7 ${offset + 1}\u2013${offset + text(data.text).length} / ${data.totalLength}`));
|
|
671
|
-
button(eventPaging, format === "text" ? data.kind === "acp" ? "\u67E5\u770B\u8BB0\u5F55\u8BE6\u60C5" : "\u67E5\u770B\u539F\u59CB\u4E8B\u4EF6" : "\u67E5\u770B\u6B63\u6587", () => loadRecord(seq, 0, format === "text" ? "json" : "text"));
|
|
672
|
-
if (offset) button(eventPaging, "\u4ECE\u5934\u8BFB\u53D6", () => loadRecord(seq, 0, format));
|
|
673
|
-
if (typeof data.nextOffset === "number") button(eventPaging, "\u7EE7\u7EED\u8BFB\u53D6", () => loadRecord(seq, data.nextOffset, format));
|
|
674
|
-
}
|
|
675
|
-
async function loadExpert() {
|
|
676
|
-
if (!expertId) return;
|
|
677
|
-
const revision = ++expertRevision, id = expertId, data = await query("expert", { agentId: id, ...expertOffset === void 0 ? {} : { offset: expertOffset } });
|
|
678
|
-
if (id !== expertId || revision !== expertRevision) return;
|
|
679
|
-
showExpert(record(data.agent));
|
|
680
|
-
const actualOffset = Number(data.offset), key = `${id}:${data.cursor}:${actualOffset}`;
|
|
681
|
-
if (key === expertPageKey) return;
|
|
682
|
-
expertPageKey = key;
|
|
683
|
-
recordControls.replaceChildren();
|
|
684
|
-
button(recordControls, "\u6700\u65B0\u8BB0\u5F55", async () => {
|
|
685
|
-
expertOffset = void 0;
|
|
686
|
-
await loadExpert();
|
|
687
|
-
});
|
|
688
|
-
if (actualOffset > 0) button(recordControls, "\u4E0A\u4E00\u9875", async () => {
|
|
689
|
-
expertOffset = Math.max(0, actualOffset - 30);
|
|
690
|
-
await loadExpert();
|
|
691
|
-
});
|
|
692
|
-
if (typeof data.nextOffset === "number") button(recordControls, "\u4E0B\u4E00\u9875", async () => {
|
|
693
|
-
expertOffset = data.nextOffset;
|
|
694
|
-
await loadExpert();
|
|
695
|
-
});
|
|
696
|
-
recordControls.append(element("span", `${data.total} \u6761\u8BB0\u5F55 \xB7 \u4ECE ${actualOffset + 1} \u5F00\u59CB`));
|
|
697
|
-
const expanded = new Set(Array.from(rawEventList.querySelectorAll("details[open]")).map((item) => item.dataset.seq));
|
|
698
|
-
eventList.replaceChildren();
|
|
699
|
-
rawEventList.replaceChildren();
|
|
700
|
-
rawEvents.querySelector("summary").textContent = data.kind === "acp" ? "\u5168\u90E8\u4EFB\u52A1\u4E0E\u62A5\u544A" : "\u5168\u90E8\u539F\u751F\u4E8B\u4EF6";
|
|
701
|
-
const labels = { "user/message": "\u8F93\u5165", "assistant/message": "\u4E13\u5BB6\u56DE\u590D", "tool/result": "\u5DE5\u5177\u7ED3\u679C", "turn/end": "\u672C\u8F6E\u7ED3\u675F", "acp/input": "\u4EFB\u52A1", "acp/report": "\u4E13\u5BB6\u62A5\u544A" };
|
|
702
|
-
for (const event of rows(data.kind === "acp" ? data.records : data.events)) {
|
|
703
|
-
const seq = Number(event.seq), label = event.type === "user/message" ? event.source === "user" ? "\u8F93\u5165" : event.source === "pbot-input" ? "\u4EFB\u52A1" : void 0 : labels[text(event.type)];
|
|
704
|
-
if (label && text(event.preview)) {
|
|
705
|
-
const item2 = element("article", "", "pbot-event"), meta = group(item2, "pbot-row");
|
|
706
|
-
meta.append(element("h4", label), note(time(event.time)));
|
|
707
|
-
item2.append(block(event.preview));
|
|
708
|
-
button(item2, "\u9605\u8BFB\u5168\u6587", () => loadRecord(seq), "pbot-quiet");
|
|
709
|
-
eventList.append(item2);
|
|
710
|
-
}
|
|
711
|
-
const item = details(rawEventList, `${seq} \xB7 ${event.type} \xB7 ${time(event.time)}`);
|
|
712
|
-
item.dataset.seq = text(seq);
|
|
713
|
-
item.open = expanded.has(text(seq));
|
|
714
|
-
item.append(block(event.preview));
|
|
715
|
-
button(item, "\u8BFB\u53D6\u4E8B\u4EF6", () => loadRecord(seq, 0, "json"));
|
|
716
|
-
}
|
|
717
|
-
if (!eventList.childElementCount) eventList.append(empty("\u8FD8\u6CA1\u6709\u5BF9\u8BDD\u5185\u5BB9", "\u53D1\u9001\u4EFB\u52A1\u540E\uFF0C\u53EF\u5728\u8FD9\u91CC\u67E5\u770B\u4E13\u5BB6\u7684\u56DE\u590D\u4E0E\u5DE5\u5177\u7ED3\u679C\u3002"));
|
|
718
|
-
}
|
|
719
|
-
const teams = section("teams", "\u56E2\u961F");
|
|
720
|
-
pageTitle(teams, "\u56E2\u961F", "");
|
|
721
|
-
const createTeam = details(teams, "\u521B\u5EFA\u56E2\u961F"), teamForm = form(createTeam), teamName = field(teamForm, "\u56E2\u961F\u540D\u79F0"), brief = field(teamForm, "\u5171\u540C\u76EE\u6807", true);
|
|
722
|
-
teamName.required = true;
|
|
723
|
-
brief.required = true;
|
|
724
|
-
teamName.placeholder = "\u4F8B\u5982\uFF1A\u6295\u8D44\u7814\u7A76\u5C0F\u7EC4";
|
|
725
|
-
teamForm.append(note("\u4E3A\u6210\u5458\u586B\u5199\u804C\u8D23\uFF0C\u7559\u7A7A\u5219\u4E0D\u52A0\u5165\u3002"));
|
|
726
|
-
const memberFields = group(teamForm);
|
|
727
|
-
submit(teamForm, "\u521B\u5EFA\u56E2\u961F", async () => {
|
|
728
|
-
const members = Array.from(memberFields.querySelectorAll("input[data-agent-id]")).filter((input) => input.value.trim()).map((input) => ({ agentId: input.dataset.agentId, role: input.value }));
|
|
729
|
-
const value2 = objectInput(await command("team", { action: "create", name: teamName.value, brief: brief.value, members }, "\u56E2\u961F\u5DF2\u521B\u5EFA\uFF0C\u53EF\u4EE5\u5B89\u6392\u9996\u4E2A\u6279\u6B21\u3002"));
|
|
730
|
-
createTeam.open = false;
|
|
731
|
-
await chooseTeam(text(value2.teamId));
|
|
732
|
-
});
|
|
733
|
-
const teamSplit = group(teams, "pbot-split"), teamList = group(teamSplit, "pbot-list"), teamDetail = group(teamSplit, "pbot-detail");
|
|
734
|
-
teamList.setAttribute("aria-label", "\u56E2\u961F\u5217\u8868");
|
|
735
|
-
const teamEmpty = empty("\u9009\u62E9\u56E2\u961F", "\u67E5\u770B\u8FDB\u5C55\u4E0E\u516C\u5171\u6D88\u606F\u3002"), teamPanel = group(teamDetail);
|
|
736
|
-
teamDetail.prepend(teamEmpty);
|
|
737
|
-
teamPanel.hidden = true;
|
|
738
|
-
const teamHeading = group(teamPanel, "pbot-detail-title"), teamTitle = element("h3"), teamBadge = element("span");
|
|
739
|
-
teamHeading.append(teamTitle, teamBadge);
|
|
740
|
-
const teamInfo = group(teamPanel), teamState = block("");
|
|
741
|
-
teamState.classList.add("pbot-raw");
|
|
742
|
-
const teamControls = group(teamPanel, "pbot-row"), requireTeam = () => {
|
|
743
|
-
if (!teamId) throw new Error("\u8BF7\u5148\u9009\u62E9\u56E2\u961F\u3002");
|
|
744
|
-
return teamId;
|
|
745
|
-
};
|
|
746
|
-
const pauseButton = button(teamControls, "\u6682\u505C\u65B0\u5B89\u6392", async () => {
|
|
747
|
-
await command("team", { action: "pause", teamId: requireTeam() }, "\u5DF2\u6682\u505C\u65B0\u5B89\u6392\uFF1B\u5728\u9014\u4EFB\u52A1\u4ECD\u53EF\u80FD\u5B8C\u6210\u3002");
|
|
748
|
-
await loadTeam();
|
|
749
|
-
});
|
|
750
|
-
const teamConfig = details(teamPanel, "\u6210\u5458\u4E0E\u56E2\u961F\u8BE6\u60C5");
|
|
751
|
-
teamConfig.append(teamState);
|
|
752
|
-
const closeTeamButton = button(teamConfig, "\u5173\u95ED\u56E2\u961F", async () => {
|
|
753
|
-
await command("team", { action: "close", teamId: requireTeam() }, "\u56E2\u961F\u5DF2\u5173\u95ED\uFF0C\u6210\u5458\u4E13\u5BB6\u4ECD\u53EF\u72EC\u7ACB\u4F7F\u7528\u3002");
|
|
754
|
-
await loadTeam();
|
|
755
|
-
}, "pbot-danger");
|
|
756
|
-
const batch = details(teamPanel, "\u65B0\u6279\u6B21"), batchForm = form(batch), instruction = field(batchForm, "\u4EFB\u52A1\u4E0E\u4EA4\u4ED8\u8981\u6C42", true);
|
|
757
|
-
instruction.required = true;
|
|
758
|
-
const batchOptions = group(batchForm, "pbot-grid"), mode = select(batchOptions, "\u8BA8\u8BBA\u6A21\u5F0F", [["roundRobin", "\u8F6E\u6D41\u8BA8\u8BBA"], ["parallel", "\u5E76\u884C\u8F6E\u6B21"]]);
|
|
759
|
-
const rounds = field(batchOptions, "\u6BCF\u4F4D\u6210\u5458\u8F6E\u6570", false, "2"), concurrency = field(batchOptions, "\u5E76\u53D1\u4E0A\u9650", false, "1"), timeout = field(batchOptions, "\u6574\u6279\u671F\u9650\uFF08\u79D2\uFF09", false, "900");
|
|
760
|
-
for (const [input, max] of [[rounds, 10], [concurrency, 50], [timeout, 86400]]) {
|
|
761
|
-
input.setAttribute("type", "number");
|
|
762
|
-
input.setAttribute("min", "1");
|
|
763
|
-
input.setAttribute("max", text(max));
|
|
764
|
-
input.required = true;
|
|
765
|
-
}
|
|
766
|
-
const runButton = submit(batchForm, "\u5F00\u59CB\u65B0\u6279\u6B21", async () => {
|
|
767
|
-
await command("team", {
|
|
768
|
-
action: "run",
|
|
769
|
-
teamId: requireTeam(),
|
|
770
|
-
instruction: instruction.value,
|
|
771
|
-
mode: mode.value,
|
|
772
|
-
rounds: Number(rounds.value),
|
|
773
|
-
maxConcurrent: Number(concurrency.value),
|
|
774
|
-
timeoutSeconds: Number(timeout.value)
|
|
775
|
-
}, "\u65B0\u6279\u6B21\u5DF2\u5F00\u59CB\u3002");
|
|
776
|
-
await loadTeam();
|
|
777
|
-
});
|
|
778
|
-
const publicCard = group(teamPanel, "pbot-card");
|
|
779
|
-
const postForm = form(publicCard), post = field(postForm, "\u516C\u5171\u6D88\u606F", true);
|
|
780
|
-
post.required = true;
|
|
781
|
-
const replyTo = field(details(postForm, "\u56DE\u590D\u6D88\u606F"), "\u56DE\u590D\u5E8F\u53F7");
|
|
782
|
-
replyTo.setAttribute("type", "number");
|
|
783
|
-
replyTo.setAttribute("min", "1");
|
|
784
|
-
const postButton = submit(postForm, "\u53D1\u5E03\u516C\u5171\u6D88\u606F", async () => {
|
|
785
|
-
const id = requireTeam(), message = post.value;
|
|
786
|
-
await command("post", { teamId: id, text: message, ...replyTo.value ? { replyTo: Number(replyTo.value) } : {} }, "\u516C\u5171\u6D88\u606F\u5DF2\u53D1\u5E03\u3002");
|
|
787
|
-
if (teamId === id && post.value === message) post.value = "";
|
|
788
|
-
const draft = teamDrafts.get(id);
|
|
789
|
-
if (draft?.text === message) draft.text = "";
|
|
790
|
-
await loadTeam();
|
|
791
|
-
});
|
|
792
|
-
const teamMessages = group(teamPanel), teamPaging = group(teamPanel, "pbot-pagination");
|
|
793
|
-
let teamAfter = 0, teamPage = { afterSeq: 0 };
|
|
794
|
-
const teamDrafts = /* @__PURE__ */ new Map();
|
|
795
|
-
async function chooseTeam(id) {
|
|
796
|
-
if (id !== teamId) {
|
|
797
|
-
if (teamId) teamDrafts.set(teamId, { text: post.value, reply: replyTo.value, instruction: instruction.value, mode: mode.value, rounds: rounds.value, concurrency: concurrency.value, timeout: timeout.value });
|
|
798
|
-
const draft = teamDrafts.get(id);
|
|
799
|
-
post.value = draft?.text ?? "";
|
|
800
|
-
replyTo.value = draft?.reply ?? "";
|
|
801
|
-
instruction.value = draft?.instruction ?? "";
|
|
802
|
-
mode.value = draft?.mode ?? "roundRobin";
|
|
803
|
-
rounds.value = draft?.rounds ?? "2";
|
|
804
|
-
concurrency.value = draft?.concurrency ?? "1";
|
|
805
|
-
timeout.value = draft?.timeout ?? "900";
|
|
806
|
-
}
|
|
807
|
-
teamId = id;
|
|
808
|
-
teamAfter = 0;
|
|
809
|
-
teamPageKey = "";
|
|
810
|
-
++teamRevision;
|
|
811
|
-
teamPanel.hidden = true;
|
|
812
|
-
teamEmpty.hidden = false;
|
|
813
|
-
teamEmpty.replaceChildren(note("\u6B63\u5728\u8BFB\u53D6\u56E2\u961F\u8BB0\u5F55\u2026"));
|
|
814
|
-
renderLists();
|
|
815
|
-
await loadTeam({ afterSeq: 0 });
|
|
816
|
-
}
|
|
817
|
-
async function loadTeam(nextPage) {
|
|
818
|
-
if (!teamId) return;
|
|
819
|
-
if (nextPage) teamPage = nextPage;
|
|
820
|
-
const page = teamPage, id = teamId;
|
|
821
|
-
const revision = ++teamRevision, data = await query("team", { teamId: id, ...page });
|
|
822
|
-
if (id !== teamId || revision !== teamRevision) return;
|
|
823
|
-
const team = record(data.team), messages = record(data.page), run = object(team.run) ? team.run : void 0;
|
|
824
|
-
teamPanel.hidden = false;
|
|
825
|
-
teamEmpty.hidden = true;
|
|
826
|
-
teamTitle.textContent = text(team.name);
|
|
827
|
-
teamBadge.replaceChildren(badge(team.closed ? "closed" : run?.state ?? "open"));
|
|
828
|
-
teamInfo.replaceChildren(block(team.brief), facts([
|
|
829
|
-
["\u6210\u5458", rows(team.members).map((member) => `${member.name} \xB7 ${member.role}`).join("\n")],
|
|
830
|
-
["\u6279\u6B21\u8FDB\u5C55", run ? `\u5DF2\u5B89\u6392 ${run.scheduled} \xB7 \u5DF2\u4EA4\u4ED8 ${run.published} \xB7 \u5728\u9014 ${team.activeCount}` : "\u5C1A\u672A\u5F00\u59CB"],
|
|
831
|
-
...run?.reason ? [["\u6682\u505C\u539F\u56E0", run.reason]] : []
|
|
832
|
-
]));
|
|
833
|
-
teamState.textContent = JSON.stringify(team, null, 2);
|
|
834
|
-
enabled(pauseButton, !team.closed && run?.state === "running");
|
|
835
|
-
enabled(closeTeamButton, !team.closed);
|
|
836
|
-
enabled(runButton, !team.closed && run?.state !== "running" && Number(team.activeCount) === 0);
|
|
837
|
-
enabled(postButton, !team.closed);
|
|
838
|
-
const key = JSON.stringify([id, page, messages]);
|
|
839
|
-
if (key === teamPageKey) return;
|
|
840
|
-
teamPageKey = key;
|
|
841
|
-
teamMessages.replaceChildren();
|
|
842
|
-
teamPaging.replaceChildren();
|
|
843
|
-
for (const message of rows(messages.messages)) {
|
|
844
|
-
const author = record(message.author), item = element("article", "", "pbot-message"), meta = group(item, "pbot-row");
|
|
845
|
-
meta.append(element("h4", text(author.name)), note(`#${message.seq}${message.replyTo ? ` \xB7 \u56DE\u590D #${message.replyTo}` : ""}`));
|
|
846
|
-
item.append(block(message.text));
|
|
847
|
-
if (typeof message.nextOffset === "number") button(item, "\u7EE7\u7EED\u8BFB\u53D6\u8FD9\u6761\u6D88\u606F", () => loadTeam({ seq: message.seq, offset: message.nextOffset }), "pbot-quiet");
|
|
848
|
-
teamMessages.append(item);
|
|
849
|
-
}
|
|
850
|
-
if (!teamMessages.childElementCount) teamMessages.append(empty("\u8FD8\u6CA1\u6709\u516C\u5171\u6D88\u606F", "\u53D1\u5E03\u8D44\u6599\u6216\u5F00\u542F\u6279\u6B21\u540E\uFF0C\u6210\u5458\u4F1A\u5728\u8FD9\u91CC\u5171\u4EAB\u7ED3\u679C\u3002"));
|
|
851
|
-
button(teamPaging, "\u4ECE\u7B2C\u4E00\u6761\u8BFB\u53D6", async () => {
|
|
852
|
-
teamAfter = 0;
|
|
853
|
-
await loadTeam({ afterSeq: 0 });
|
|
854
|
-
});
|
|
855
|
-
if (typeof messages.nextAfterSeq === "number") button(teamPaging, "\u540E\u7EED\u6D88\u606F", async () => {
|
|
856
|
-
teamAfter = messages.nextAfterSeq;
|
|
857
|
-
await loadTeam({ afterSeq: teamAfter });
|
|
858
|
-
});
|
|
859
|
-
if (page.seq !== void 0) button(teamPaging, "\u8FD4\u56DE\u6D88\u606F\u5217\u8868", () => loadTeam({ afterSeq: teamAfter }));
|
|
860
|
-
}
|
|
861
421
|
const history = section("history", "\u5386\u53F2");
|
|
862
422
|
pageTitle(history, "\u5386\u53F2", "");
|
|
863
423
|
const searchForm = form(history);
|
|
@@ -931,43 +491,6 @@ function showManagement(ctx, parentSessionId) {
|
|
|
931
491
|
details(historyNode, "\u539F\u59CB\u6765\u6E90\u4F4D\u7F6E").append(provenance);
|
|
932
492
|
historyNode.scrollIntoView({ block: "start" });
|
|
933
493
|
}
|
|
934
|
-
const expertButtons = /* @__PURE__ */ new Map(), teamButtons = /* @__PURE__ */ new Map();
|
|
935
|
-
function syncList(container, buttons, values, kind) {
|
|
936
|
-
const ids = new Set(values.map((value2) => text(value2[kind + "Id"])));
|
|
937
|
-
for (const [id, node] of buttons) if (!ids.has(id)) {
|
|
938
|
-
node.remove();
|
|
939
|
-
buttons.delete(id);
|
|
940
|
-
}
|
|
941
|
-
container.querySelector(":scope > .pbot-empty")?.remove();
|
|
942
|
-
for (const value2 of values) {
|
|
943
|
-
const id = text(value2[kind + "Id"]), state = kind === "agent" ? value2.state : value2.closed ? "closed" : object(value2.run) ? value2.run.state : "open";
|
|
944
|
-
let node = buttons.get(id);
|
|
945
|
-
if (!node) {
|
|
946
|
-
node = button(container, "", () => kind === "agent" ? chooseExpert(id) : chooseTeam(id), "pbot-list-item");
|
|
947
|
-
buttons.set(id, node);
|
|
948
|
-
}
|
|
949
|
-
node.setAttribute("aria-label", text(value2.name));
|
|
950
|
-
node.setAttribute("aria-pressed", String(id === (kind === "agent" ? expertId : teamId)));
|
|
951
|
-
const signature = JSON.stringify([value2.name, state, value2.activity, value2.brief]);
|
|
952
|
-
if (node.dataset.content !== signature) {
|
|
953
|
-
node.dataset.content = signature;
|
|
954
|
-
node.replaceChildren();
|
|
955
|
-
const row = group(node, "pbot-between");
|
|
956
|
-
row.append(element("strong", text(value2.name)), badge(state));
|
|
957
|
-
if (kind === "team" || !["idle", "stopped"].includes(text(state))) node.append(note(text(kind === "agent" ? value2.activity : value2.brief)));
|
|
958
|
-
}
|
|
959
|
-
node.hidden = kind === "agent" && !`${value2.name} ${stateLabel(state)}`.toLowerCase().includes(expertFilter.value.trim().toLowerCase());
|
|
960
|
-
}
|
|
961
|
-
if (!values.length || [...buttons.values()].every((node) => node.hidden)) {
|
|
962
|
-
container.append(empty(values.length ? "\u6CA1\u6709\u5339\u914D\u7684\u4E13\u5BB6" : kind === "agent" ? "\u8FD8\u6CA1\u6709\u4E13\u5BB6" : "\u8FD8\u6CA1\u6709\u56E2\u961F", values.length ? "\u8C03\u6574\u540D\u79F0\u6216\u72B6\u6001\u5173\u952E\u8BCD\u3002" : kind === "agent" ? "\u5C55\u5F00\u4E0A\u65B9\u201C\u521B\u5EFA\u4E13\u5BB6\u201D\u5F00\u59CB\u3002" : "\u5148\u521B\u5EFA\u4E13\u5BB6\uFF0C\u518D\u4E3A\u6210\u5458\u5206\u914D\u804C\u8D23\u3002"));
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
function renderLists() {
|
|
966
|
-
if (!snapshot) return;
|
|
967
|
-
syncList(expertList, expertButtons, rows(snapshot.agents), "agent");
|
|
968
|
-
syncList(teamList, teamButtons, rows(snapshot.teams), "team");
|
|
969
|
-
}
|
|
970
|
-
expertFilter.addEventListener("input", renderLists);
|
|
971
494
|
function renderSnapshot() {
|
|
972
495
|
if (!snapshot) return;
|
|
973
496
|
location.textContent = text(snapshot.workspaceRoot).split(/[\\/]/).filter(Boolean).at(-1) ?? "";
|
|
@@ -992,56 +515,18 @@ function showManagement(ctx, parentSessionId) {
|
|
|
992
515
|
materials.hidden = false;
|
|
993
516
|
initializeButton.textContent = "\u51C6\u5907\u76EE\u5F55";
|
|
994
517
|
enabled(initializeButton, true);
|
|
995
|
-
const
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
const active = agents.filter((agent) => ["starting", "busy", "stopping"].includes(text(agent.state))).length;
|
|
999
|
-
counts.textContent = `Personal Bot \u5DF2\u542F\u52A8 \xB7 \u4E13\u5BB6 ${agents.length} \xB7 \u6267\u884C\u4E2D ${active} \xB7 \u56E2\u961F ${teams2.length}`;
|
|
1000
|
-
const model2 = object(snapshot.model) ? snapshot.model : {};
|
|
518
|
+
const historyState = record(snapshot.history);
|
|
519
|
+
counts.textContent = "Personal Bot \u5DF2\u542F\u52A8 \xB7 \u8DE8 Harness \u8C03\u5EA6\u901A\u8FC7 MCP worker_* \u63D0\u4F9B";
|
|
520
|
+
const model = object(snapshot.model) ? snapshot.model : {};
|
|
1001
521
|
workspaceInfo.replaceChildren(facts([
|
|
1002
522
|
["\u72B6\u6001", "\u5DF2\u542F\u52A8"],
|
|
1003
523
|
["\u5DE5\u4F5C\u533A", snapshot.workspaceRoot],
|
|
1004
524
|
["\u914D\u7F6E\u6587\u4EF6", record(snapshot.configuration).path],
|
|
1005
|
-
["\u6A21\u578B",
|
|
1006
|
-
["Provider",
|
|
1007
|
-
["\u5386\u53F2",
|
|
525
|
+
["\u6A21\u578B", model.model || "\u5C1A\u672A\u9009\u62E9"],
|
|
526
|
+
["Provider", model.provider || "\u2014"],
|
|
527
|
+
["\u5386\u53F2", historyState.organizing ? "\u6574\u7406\u4E2D" : historyState.pending === null ? "\u67E5\u8BE2\u65F6\u66F4\u65B0\u7D22\u5F15" : `${historyState.pending} \u9879\u5F85\u6574\u7406`]
|
|
1008
528
|
]));
|
|
1009
|
-
|
|
1010
|
-
statusBody.textContent = JSON.stringify(summary, null, 2);
|
|
1011
|
-
const pending = rows(snapshot.permissions), nextPermissionKey = pending.map((request) => text(request.agentId) + ":" + text(request.requestId)).join(",");
|
|
1012
|
-
permissions.hidden = !pending.length;
|
|
1013
|
-
if (nextPermissionKey !== permissionKey) {
|
|
1014
|
-
permissionKey = nextPermissionKey;
|
|
1015
|
-
permissions.replaceChildren(element("h3", "\u4E13\u5BB6\u8BF7\u6C42\u786E\u8BA4"));
|
|
1016
|
-
for (const request of pending) {
|
|
1017
|
-
const card = group(permissions, "pbot-card");
|
|
1018
|
-
card.append(element("h4", text(request.name)), block(request.description));
|
|
1019
|
-
const choices = group(card, "pbot-row");
|
|
1020
|
-
for (const option of rows(request.options)) button(choices, text(option.name), async () => {
|
|
1021
|
-
await command("approval", { agentId: request.agentId, requestId: request.requestId, optionId: option.optionId }, "\u786E\u8BA4\u7B54\u590D\u5DF2\u63D0\u4EA4\u3002");
|
|
1022
|
-
});
|
|
1023
|
-
button(choices, "\u53D6\u6D88", async () => {
|
|
1024
|
-
await command("approval", { agentId: request.agentId, requestId: request.requestId, optionId: null }, "\u5DF2\u53D6\u6D88\u8BE5\u8BF7\u6C42\u3002");
|
|
1025
|
-
});
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
if (snapshot.controlError) inform(text(snapshot.controlError), "error");
|
|
1029
|
-
renderLists();
|
|
1030
|
-
const owned = agents.filter((value2) => value2.owned && record(value2.capabilities).team !== false), ids = new Set(owned.map((agent) => text(agent.agentId)));
|
|
1031
|
-
for (const input of memberFields.querySelectorAll("input[data-agent-id]")) if (!ids.has(input.dataset.agentId)) input.parentElement?.remove();
|
|
1032
|
-
memberFields.querySelector(":scope > p")?.remove();
|
|
1033
|
-
for (const agent of owned) {
|
|
1034
|
-
const id = text(agent.agentId);
|
|
1035
|
-
let input = Array.from(memberFields.querySelectorAll("input[data-agent-id]")).find((input2) => input2.dataset.agentId === id);
|
|
1036
|
-
if (!input) {
|
|
1037
|
-
input = field(memberFields, `${agent.name} \xB7 \u804C\u8D23`);
|
|
1038
|
-
input.dataset.agentId = id;
|
|
1039
|
-
}
|
|
1040
|
-
const label = `${agent.name} \xB7 \u804C\u8D23`;
|
|
1041
|
-
input.setAttribute("aria-label", label);
|
|
1042
|
-
input.parentElement.querySelector("span").textContent = label;
|
|
1043
|
-
}
|
|
1044
|
-
if (!owned.length) memberFields.append(note("\u8FD8\u6CA1\u6709\u53EF\u52A0\u5165\u7684\u4E13\u5BB6\uFF0C\u8BF7\u5148\u5728\u4E13\u5BB6\u9875\u521B\u5EFA\u3002"));
|
|
529
|
+
statusBody.textContent = JSON.stringify(snapshot, null, 2);
|
|
1045
530
|
}
|
|
1046
531
|
async function refresh() {
|
|
1047
532
|
const revision = ++snapshotRevision, value2 = await query("snapshot");
|
|
@@ -1074,8 +559,6 @@ function showManagement(ctx, parentSessionId) {
|
|
|
1074
559
|
async function poll() {
|
|
1075
560
|
try {
|
|
1076
561
|
await refresh();
|
|
1077
|
-
if (tab === "experts" && expertId) await loadExpert();
|
|
1078
|
-
if (tab === "teams" && teamId) await loadTeam();
|
|
1079
562
|
if (pollError) {
|
|
1080
563
|
inform("\u8FDE\u63A5\u5DF2\u6062\u590D\uFF0C\u72B6\u6001\u5DF2\u66F4\u65B0\u3002");
|
|
1081
564
|
pollError = false;
|
|
@@ -1102,7 +585,7 @@ async function apply(ctx) {
|
|
|
1102
585
|
ctx.remote.$mount(pbotReadRemote);
|
|
1103
586
|
await ctx.plugin({
|
|
1104
587
|
name: "pbot-management-view",
|
|
1105
|
-
inject: ["commandUi", "remote", "remote.commands", "remote.pbot"
|
|
588
|
+
inject: ["commandUi", "remote", "remote.commands", "remote.pbot"],
|
|
1106
589
|
apply(view) {
|
|
1107
590
|
view.commandUi.decorate({
|
|
1108
591
|
name: "pbot",
|
package/lib/common/markdown.js
CHANGED
|
@@ -14,12 +14,11 @@ export function markdownFields(value, level = 2) {
|
|
|
14
14
|
return value.length ? value.map((item, index) => "#".repeat(level) + " " + (index + 1) + "\n\n" + markdownFields(item, level + 1)).join("\n\n") : "(空)";
|
|
15
15
|
const fields = [], sections = [];
|
|
16
16
|
for (const [key, item] of Object.entries(value)) {
|
|
17
|
-
if ((item !== null && typeof item === "object") || (typeof item === "string" && (item.includes("\n") || key === "report" || key === "text"))) {
|
|
17
|
+
if ((item !== null && typeof item === "object") || (typeof item === "string" && (item.includes("\n") || item.includes("\r") || key === "report" || key === "text"))) {
|
|
18
18
|
sections.push("#".repeat(level) + " " + key + "\n\n" + markdownFields(item, level + 1));
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
|
-
|
|
22
|
-
fields.push("- " + key + ": " + text);
|
|
21
|
+
fields.push("- " + key + ": " + String(item));
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
return [fields.join("\n"), ...sections].filter(Boolean).join("\n\n");
|