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
|
@@ -4,8 +4,11 @@ import { schema } from "../../common/schema.js";
|
|
|
4
4
|
import { inputObject, need, nullable, pick } from "../input.js";
|
|
5
5
|
const host = Type.Union([Type.Literal("pi"), Type.Literal("dsh"), Type.Literal("claude")]);
|
|
6
6
|
const nullableOffset = Type.Union([Type.Integer(), Type.Null()]);
|
|
7
|
-
const node = Type.Object({ host, id: Type.String(),
|
|
8
|
-
|
|
7
|
+
const node = Type.Object({ host, id: Type.String(),
|
|
8
|
+
kind: Type.Union([Type.Literal("session"), Type.Literal("exchange"), Type.Literal("summary")], { description: "session=会话根;summary=摘要;exchange=单轮问答原文。" }),
|
|
9
|
+
sessionId: Type.String(), name: Type.String(), preview: Type.String(), from: Type.String(), to: Type.String(),
|
|
10
|
+
ready: Type.Boolean({ description: "正文或摘要是否已生成。" }),
|
|
11
|
+
completed: Type.Boolean({ description: "该对话或问答是否正常结束(false 表示中断或未完)。" }) });
|
|
9
12
|
export const historyResultSchema = Type.Object({
|
|
10
13
|
matches: Type.Optional(Type.Array(Type.Object({ ...node.properties, snippet: Type.String(), parents: Type.Array(Type.String()) }))),
|
|
11
14
|
total: Type.Optional(Type.Integer()), nextOffset: Type.Optional(nullableOffset),
|
|
@@ -14,15 +17,18 @@ export const historyResultSchema = Type.Object({
|
|
|
14
17
|
source: Type.Object({ host, sessionId: Type.String({ description: "原始宿主会话 ID。" }), entryIds: Type.Array(Type.String()) }), warnings: Type.Array(Type.String()) })),
|
|
15
18
|
warnings: Type.Array(Type.String()),
|
|
16
19
|
});
|
|
17
|
-
export const historyDescription = "
|
|
18
|
-
export const historyParameters = Type.Object({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
export const historyDescription = "查询当前工作区的历史问答与归档,host 可筛选来源(pi/dsh/claude)。search 按不区分大小写的连续关键词匹配原文和摘要,省略 query 列出各会话;无匹配时换词。read 按节点 id 展开正文与上下级,nextOffset 续读正文,nextChildrenOffset 续读子节点;需要细节时读取 exchange 原文。归档不含工具调用日志。";
|
|
21
|
+
export const historyParameters = Type.Object({
|
|
22
|
+
action: Type.Union([Type.Literal("search"), Type.Literal("read")], { description: "search 搜索或列会话;read 读取指定节点正文与上下级。各动作仅读取自身字段,其余字段忽略。" }),
|
|
23
|
+
host: nullable(Type.Union([Type.Literal("pi"), Type.Literal("dsh"), Type.Literal("claude")], { description: "可选来源筛选:pi、dsh 或 claude。" })),
|
|
24
|
+
query: nullable(Type.String({ description: "仅 search:不区分大小写的连续关键词;省略时列出各会话。" })),
|
|
25
|
+
sessionId: nullable(Type.String({ description: "仅 search:限定在指定会话 ID 内搜索。" })),
|
|
26
|
+
from: nullable(Type.String({ description: "仅 search:ISO 日期或时间下界。" })),
|
|
27
|
+
to: nullable(Type.String({ description: "仅 search:ISO 日期或时间上界。" })),
|
|
28
|
+
id: nullable(Type.String({ description: "仅 read,必填:search 或上下级返回的节点 id。" })),
|
|
29
|
+
offset: nullable(Type.Integer({ minimum: 0, description: "search:匹配结果偏移;read:正文字符偏移。默认 0。" })),
|
|
30
|
+
limit: nullable(Type.Integer({ minimum: 1, maximum: 24000, description: "search:最多返回条数(默认 20,上限 50);read:正文字符数(默认 12000)。" })),
|
|
31
|
+
childrenOffset: nullable(Type.Integer({ minimum: 0, description: "仅 read:子节点列表偏移,默认 0;续读传上页 nextChildrenOffset。" })),
|
|
26
32
|
}, { additionalProperties: false });
|
|
27
33
|
const valid = schema(historyParameters);
|
|
28
34
|
export function historyInput(value) {
|
package/lib/ui/dsh/index.js
CHANGED
|
@@ -4,10 +4,15 @@ export const name = "personal-bot";
|
|
|
4
4
|
export const inject = ["remote"];
|
|
5
5
|
export async function apply(ctx) {
|
|
6
6
|
ctx.remote.$mount(pbotReadRemote);
|
|
7
|
-
await ctx.plugin({
|
|
7
|
+
await ctx.plugin({
|
|
8
|
+
name: "pbot-management-view",
|
|
9
|
+
inject: ["commandUi", "remote", "remote.commands", "remote.pbot"],
|
|
8
10
|
apply(view) {
|
|
9
|
-
view.commandUi.decorate({
|
|
10
|
-
|
|
11
|
+
view.commandUi.decorate({
|
|
12
|
+
name: "pbot",
|
|
13
|
+
available: () => true,
|
|
14
|
+
ui: { kind: "action", run: session => { showManagement(view, session.sessionId); } },
|
|
15
|
+
});
|
|
11
16
|
},
|
|
12
17
|
});
|
|
13
18
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Context } from "@deepseek-ai/cordis";
|
|
2
2
|
import type { SessionId } from "@deepseek-ai/dsh-session/types";
|
|
3
|
-
/** The view owns
|
|
3
|
+
/** The view owns workspace and history queries. Accepted commands belong to the server workspace. */
|
|
4
4
|
export declare function showManagement(ctx: Context, parentSessionId: SessionId): void;
|
package/lib/ui/dsh/management.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { commandAttachments } from "./attachments.js";
|
|
2
1
|
import { object, json } from "../../common/json.js";
|
|
3
|
-
import {
|
|
4
|
-
import { badge, block, details, element, empty, facts, field, group, lines, note, objectInput, pageTitle, record, rows, select, text, time } from "./elements.js";
|
|
2
|
+
import { block, details, element, empty, facts, field, group, note, pageTitle, record, rows, select, text, time } from "./elements.js";
|
|
5
3
|
import { managementStyles } from "./styles.js";
|
|
6
|
-
/** The view owns
|
|
4
|
+
/** The view owns workspace and history queries. Accepted commands belong to the server workspace. */
|
|
7
5
|
export function showManagement(ctx, parentSessionId) {
|
|
8
6
|
const opener = document.activeElement, dialog = element("dialog"), style = element("style");
|
|
9
7
|
dialog.className = "pbot-management";
|
|
@@ -26,10 +24,9 @@ export function showManagement(ctx, parentSessionId) {
|
|
|
26
24
|
dialog.prepend(style);
|
|
27
25
|
const lifetime = new AbortController();
|
|
28
26
|
let closed = false, timer, tab = "status";
|
|
29
|
-
let snapshot
|
|
30
|
-
let snapshotRevision = 0,
|
|
31
|
-
|
|
32
|
-
const sections = new Map(), tabs = new Map(), tabCounts = new Map();
|
|
27
|
+
let snapshot;
|
|
28
|
+
let snapshotRevision = 0, historyRevision = 0, pollError = false;
|
|
29
|
+
const sections = new Map(), tabs = new Map();
|
|
33
30
|
function inform(message, tone = "info") {
|
|
34
31
|
if (closed)
|
|
35
32
|
return;
|
|
@@ -103,10 +100,6 @@ export function showManagement(ctx, parentSessionId) {
|
|
|
103
100
|
control.setAttribute("aria-controls", node.id);
|
|
104
101
|
control.setAttribute("aria-selected", String(id === tab));
|
|
105
102
|
control.tabIndex = id === tab ? 0 : -1;
|
|
106
|
-
const count = element("small");
|
|
107
|
-
count.setAttribute("aria-hidden", "true");
|
|
108
|
-
control.append(count);
|
|
109
|
-
tabCounts.set(id, count);
|
|
110
103
|
tabs.set(id, control);
|
|
111
104
|
return node;
|
|
112
105
|
}
|
|
@@ -132,9 +125,8 @@ export function showManagement(ctx, parentSessionId) {
|
|
|
132
125
|
lifetime.signal.throwIfAborted();
|
|
133
126
|
return record(result.value);
|
|
134
127
|
}
|
|
135
|
-
async function command(verb, input, message = "操作已接纳。"
|
|
136
|
-
|
|
137
|
-
const result = await ctx.remote.commands.execute(parentSessionId, "/pbot " + verb + (input === undefined ? "" : " " + JSON.stringify(input)), attachments);
|
|
128
|
+
async function command(verb, input, message = "操作已接纳。") {
|
|
129
|
+
const result = await ctx.remote.commands.execute(parentSessionId, "/pbot " + verb + (input === undefined ? "" : " " + JSON.stringify(input)), []);
|
|
138
130
|
if (!result.ok)
|
|
139
131
|
throw new Error(result.error.message + ";如连接中断,请先刷新记录确认操作是否已接纳。");
|
|
140
132
|
if (!result.value)
|
|
@@ -163,355 +155,6 @@ export function showManagement(ctx, parentSessionId) {
|
|
|
163
155
|
const diagnostic = details(status, "环境详情"), statusBody = block("");
|
|
164
156
|
statusBody.classList.add("pbot-raw");
|
|
165
157
|
diagnostic.append(statusBody);
|
|
166
|
-
const permissions = group(status, "pbot-setting");
|
|
167
|
-
permissions.hidden = true;
|
|
168
|
-
let permissionKey = "";
|
|
169
|
-
const experts = section("experts", "专家");
|
|
170
|
-
pageTitle(experts, "专家", "");
|
|
171
|
-
const create = details(experts, "创建专家"), createForm = form(create), newName = field(createForm, "名称"), initial = field(createForm, "任务(可选)", true);
|
|
172
|
-
newName.placeholder = "例如:研究员";
|
|
173
|
-
initial.placeholder = "任务目标与交付要求";
|
|
174
|
-
const backend = select(createForm, "运行宿主", [["", "当前宿主"], ["pi", "Pi"], ["dsh", "dsh"], ["claude", "Claude Code"]]);
|
|
175
|
-
const options = details(createForm, "模型与选项"), modelFields = group(options, "pbot-grid");
|
|
176
|
-
options.querySelector("summary").after(note("当前宿主留空沿用主会话;其他宿主留空使用目标配置。"));
|
|
177
|
-
const provider = field(modelFields, "Provider"), model = field(modelFields, "模型");
|
|
178
|
-
const effort = field(options, "Reasoning effort"), cwd = field(options, "工作目录");
|
|
179
|
-
const files = field(options, "文件路径(每行一个)", true);
|
|
180
|
-
const advanced = field(details(options, "其他选项"), "JSON", true, "{}");
|
|
181
|
-
submit(createForm, "创建", async () => {
|
|
182
|
-
const args = { ...objectInput(advanced.value), action: "start", ...(backend.value ? { backend: backend.value } : {}), ...(newName.value ? { name: newName.value } : {}),
|
|
183
|
-
...(initial.value ? { message: initial.value } : {}), ...(provider.value ? { provider: provider.value } : {}),
|
|
184
|
-
...(model.value ? { model: model.value } : {}), ...(effort.value ? { thinking: effort.value } : {}),
|
|
185
|
-
...(cwd.value ? { cwd: cwd.value } : {}), ...(lines(files.value).length ? { files: lines(files.value) } : {}) };
|
|
186
|
-
const output = objectInput(await command("agent", args, "专家已创建。"));
|
|
187
|
-
if (initial.value === (args.message ?? ""))
|
|
188
|
-
initial.value = "";
|
|
189
|
-
create.open = false;
|
|
190
|
-
await chooseExpert(text(output.agentId));
|
|
191
|
-
});
|
|
192
|
-
const expertSplit = group(experts, "pbot-split"), expertAside = group(expertSplit), expertFilter = field(expertAside, "筛选专家");
|
|
193
|
-
expertFilter.placeholder = "名称或状态";
|
|
194
|
-
const expertList = group(expertAside, "pbot-list");
|
|
195
|
-
expertList.setAttribute("aria-label", "专家列表");
|
|
196
|
-
const expertDetail = group(expertSplit, "pbot-detail"), expertEmpty = empty("选择专家", "查看记录或发送消息。");
|
|
197
|
-
expertDetail.append(expertEmpty);
|
|
198
|
-
const expertPanel = group(expertDetail);
|
|
199
|
-
expertPanel.hidden = true;
|
|
200
|
-
const expertHeading = group(expertPanel, "pbot-detail-title"), expertTitle = element("h3"), expertBadge = element("span");
|
|
201
|
-
expertHeading.append(expertTitle, expertBadge);
|
|
202
|
-
const expertInfo = group(expertPanel), expertError = element("p", "", "pbot-warning");
|
|
203
|
-
expertPanel.append(expertError);
|
|
204
|
-
expertError.hidden = true;
|
|
205
|
-
const expertControls = group(expertPanel, "pbot-row"), requireExpert = () => { if (!expertId)
|
|
206
|
-
throw new Error("请先选择专家。"); return expertId; };
|
|
207
|
-
const stopButton = button(expertControls, "停止专家", async () => { await command("agent", { action: "stop", agentId: requireExpert() }, "已请求停止专家。"); await loadExpert(); }, "pbot-danger");
|
|
208
|
-
const editExpert = details(expertPanel, "名称与会话详情"), renameForm = form(editExpert), rename = field(renameForm, "新名称");
|
|
209
|
-
rename.required = true;
|
|
210
|
-
submit(renameForm, "重命名", async () => { await command("agent", { action: "rename", agentId: requireExpert(), name: rename.value }, "专家名称已更新。"); await loadExpert(); });
|
|
211
|
-
const expertState = block("");
|
|
212
|
-
expertState.classList.add("pbot-raw");
|
|
213
|
-
editExpert.append(expertState);
|
|
214
|
-
const resume = details(expertPanel, "恢复专家"), resumeForm = form(resume), resumeText = field(resumeForm, "新任务", true);
|
|
215
|
-
resumeText.required = true;
|
|
216
|
-
const resumeButton = submit(resumeForm, "恢复并发送新任务", async () => {
|
|
217
|
-
const message = resumeText.value;
|
|
218
|
-
await command("agent", { action: "resume", agentId: requireExpert(), message }, "专家已恢复,新任务已排队。");
|
|
219
|
-
if (resumeText.value === message)
|
|
220
|
-
resumeText.value = "";
|
|
221
|
-
await loadExpert();
|
|
222
|
-
});
|
|
223
|
-
const chatCard = group(expertPanel, "pbot-card");
|
|
224
|
-
chatCard.append(element("h3", "人工对话"), note("发送前暂停团队新安排。"));
|
|
225
|
-
const chatForm = form(chatCard), chat = field(chatForm, "消息", true);
|
|
226
|
-
chat.maxLength = 24000;
|
|
227
|
-
chat.placeholder = "补充资料、调整方向,或提出新问题…";
|
|
228
|
-
const delivery = select(chatForm, "投递时机", [["steer", "下一个安全步骤"], ["followUp", "下一轮"]]);
|
|
229
|
-
const localFiles = field(chatForm, "附件");
|
|
230
|
-
localFiles.type = "file";
|
|
231
|
-
localFiles.multiple = true;
|
|
232
|
-
const chatFiles = field(details(chatForm, "服务器文件"), "路径(每行一个)", true);
|
|
233
|
-
const expertDrafts = new Map();
|
|
234
|
-
function clearSentDraft(id, input, paths, chosen) {
|
|
235
|
-
const draft = expertDrafts.get(id);
|
|
236
|
-
if (draft) {
|
|
237
|
-
if (draft.text === input.text)
|
|
238
|
-
draft.text = "";
|
|
239
|
-
if (draft.paths === paths)
|
|
240
|
-
draft.paths = "";
|
|
241
|
-
if (draft.files.length === chosen.length && draft.files.every((file, index) => file === chosen[index]))
|
|
242
|
-
draft.files = [];
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
const sendButton = submit(chatForm, "发送人工消息", async () => {
|
|
246
|
-
const id = requireExpert(), fileText = chatFiles.value, files = lines(fileText), chosen = Array.from(localFiles.files ?? []);
|
|
247
|
-
if (files.length && chosen.length)
|
|
248
|
-
throw new Error("一次对话请选择服务器文件或本机附件,不能同时使用。");
|
|
249
|
-
if (!chat.value.trim() && !files.length && !chosen.length) {
|
|
250
|
-
chat.focus();
|
|
251
|
-
throw new Error("请输入消息或添加附件。");
|
|
252
|
-
}
|
|
253
|
-
const input = { agentId: id, text: chat.value, delivery: delivery.value, files };
|
|
254
|
-
const attachments = await commandAttachments(ctx, parentSessionId, chosen, lifetime.signal, inform);
|
|
255
|
-
lifetime.signal.throwIfAborted();
|
|
256
|
-
await command("chat", input, "消息已排队,专家会在所选时机接收。", attachments);
|
|
257
|
-
clearSentDraft(id, input, fileText, chosen);
|
|
258
|
-
if (expertId === id) {
|
|
259
|
-
if (chat.value === input.text)
|
|
260
|
-
chat.value = "";
|
|
261
|
-
if (chatFiles.value === fileText)
|
|
262
|
-
chatFiles.value = "";
|
|
263
|
-
const current = Array.from(localFiles.files ?? []);
|
|
264
|
-
if (current.length === chosen.length && current.every((file, index) => file === chosen[index]))
|
|
265
|
-
localFiles.value = "";
|
|
266
|
-
await loadExpert();
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
const transcript = group(expertPanel, "pbot-transcript");
|
|
270
|
-
transcript.append(element("h3", "对话与活动"));
|
|
271
|
-
const recordControls = group(transcript, "pbot-pagination"), eventList = group(transcript), rawEvents = details(transcript, "全部原生事件"), rawEventList = group(rawEvents);
|
|
272
|
-
const eventDetail = details(transcript, "完整记录"), eventBody = block(""), eventPaging = element("div", "", "pbot-pagination");
|
|
273
|
-
eventDetail.append(eventBody, eventPaging);
|
|
274
|
-
eventDetail.hidden = true;
|
|
275
|
-
async function chooseExpert(id) {
|
|
276
|
-
if (id !== expertId) {
|
|
277
|
-
if (expertId)
|
|
278
|
-
expertDrafts.set(expertId, { text: chat.value, delivery: delivery.value, paths: chatFiles.value, files: Array.from(localFiles.files ?? []) });
|
|
279
|
-
const draft = expertDrafts.get(id);
|
|
280
|
-
chat.value = draft?.text ?? "";
|
|
281
|
-
delivery.value = draft?.delivery ?? "steer";
|
|
282
|
-
chatFiles.value = draft?.paths ?? "";
|
|
283
|
-
const transfer = new DataTransfer();
|
|
284
|
-
for (const file of draft?.files ?? [])
|
|
285
|
-
transfer.items.add(file);
|
|
286
|
-
localFiles.files = transfer.files;
|
|
287
|
-
rename.value = "";
|
|
288
|
-
resumeText.value = "";
|
|
289
|
-
}
|
|
290
|
-
expertId = id;
|
|
291
|
-
expertOffset = undefined;
|
|
292
|
-
expertPageKey = "";
|
|
293
|
-
++recordRevision;
|
|
294
|
-
++expertRevision;
|
|
295
|
-
eventBody.textContent = "";
|
|
296
|
-
eventDetail.hidden = true;
|
|
297
|
-
eventPaging.replaceChildren();
|
|
298
|
-
expertPanel.hidden = true;
|
|
299
|
-
expertEmpty.hidden = false;
|
|
300
|
-
expertEmpty.replaceChildren(note("正在读取专家记录…"));
|
|
301
|
-
renderLists();
|
|
302
|
-
await loadExpert();
|
|
303
|
-
}
|
|
304
|
-
function showExpert(agent) {
|
|
305
|
-
expertTitle.textContent = text(agent.name);
|
|
306
|
-
expertBadge.replaceChildren(badge(agent.state));
|
|
307
|
-
expertPanel.hidden = false;
|
|
308
|
-
expertEmpty.hidden = true;
|
|
309
|
-
const config = object(agent.options) ? agent.options : {}, selected = record(agent.selection);
|
|
310
|
-
const configuredModel = [selected.provider ?? config.provider, selected.model ?? config.model].filter(Boolean).join("/");
|
|
311
|
-
const chosenModel = selected.resolvedModel && selected.resolvedModel !== configuredModel ? `${configuredModel} → ${text(selected.resolvedModel)}` : configuredModel;
|
|
312
|
-
expertInfo.replaceChildren(note(text(agent.activity) || "等待新的任务。"), facts([["宿主", agent.backend || "当前宿主"], ["模型", chosenModel || (agent.transport === "acp" ? "目标宿主配置" : "继承父会话")],
|
|
313
|
-
["思考等级", selected.thinking || config.thinking || "宿主默认"], ["工作目录", agent.cwd]]));
|
|
314
|
-
const steering = delivery.querySelector('option[value="steer"]');
|
|
315
|
-
steering.disabled = agent.transport === "acp";
|
|
316
|
-
if (steering.disabled && delivery.value === "steer")
|
|
317
|
-
delivery.value = "followUp";
|
|
318
|
-
expertState.textContent = JSON.stringify(agent, null, 2);
|
|
319
|
-
expertError.textContent = text(agent.error);
|
|
320
|
-
expertError.hidden = !agent.error;
|
|
321
|
-
const alive = agent.alive === true, owned = agent.owned === true;
|
|
322
|
-
enabled(stopButton, owned && alive && agent.state !== "stopping");
|
|
323
|
-
enabled(sendButton, owned && alive && !["starting", "stopping"].includes(text(agent.state)));
|
|
324
|
-
enabled(resumeButton, owned && !alive);
|
|
325
|
-
resume.hidden = alive;
|
|
326
|
-
}
|
|
327
|
-
async function loadRecord(seq, offset = 0, format = "text") {
|
|
328
|
-
const revision = ++recordRevision, id = requireExpert(), data = await query("expert", { agentId: id, seq, textOffset: offset, format });
|
|
329
|
-
if (id !== expertId || revision !== recordRevision)
|
|
330
|
-
return;
|
|
331
|
-
eventDetail.hidden = false;
|
|
332
|
-
eventDetail.open = true;
|
|
333
|
-
eventBody.textContent = text(data.text);
|
|
334
|
-
eventBody.classList.toggle("pbot-raw", format === "json");
|
|
335
|
-
eventPaging.replaceChildren(element("span", `记录 ${seq} · ${offset + 1}–${offset + text(data.text).length} / ${data.totalLength}`));
|
|
336
|
-
button(eventPaging, format === "text" ? data.kind === "acp" ? "查看记录详情" : "查看原始事件" : "查看正文", () => loadRecord(seq, 0, format === "text" ? "json" : "text"));
|
|
337
|
-
if (offset)
|
|
338
|
-
button(eventPaging, "从头读取", () => loadRecord(seq, 0, format));
|
|
339
|
-
if (typeof data.nextOffset === "number")
|
|
340
|
-
button(eventPaging, "继续读取", () => loadRecord(seq, data.nextOffset, format));
|
|
341
|
-
}
|
|
342
|
-
async function loadExpert() {
|
|
343
|
-
if (!expertId)
|
|
344
|
-
return;
|
|
345
|
-
const revision = ++expertRevision, id = expertId, data = await query("expert", { agentId: id, ...(expertOffset === undefined ? {} : { offset: expertOffset }) });
|
|
346
|
-
if (id !== expertId || revision !== expertRevision)
|
|
347
|
-
return;
|
|
348
|
-
showExpert(record(data.agent));
|
|
349
|
-
const actualOffset = Number(data.offset), key = `${id}:${data.cursor}:${actualOffset}`;
|
|
350
|
-
if (key === expertPageKey)
|
|
351
|
-
return;
|
|
352
|
-
expertPageKey = key;
|
|
353
|
-
recordControls.replaceChildren();
|
|
354
|
-
button(recordControls, "最新记录", async () => { expertOffset = undefined; await loadExpert(); });
|
|
355
|
-
if (actualOffset > 0)
|
|
356
|
-
button(recordControls, "上一页", async () => { expertOffset = Math.max(0, actualOffset - 30); await loadExpert(); });
|
|
357
|
-
if (typeof data.nextOffset === "number")
|
|
358
|
-
button(recordControls, "下一页", async () => { expertOffset = data.nextOffset; await loadExpert(); });
|
|
359
|
-
recordControls.append(element("span", `${data.total} 条记录 · 从 ${actualOffset + 1} 开始`));
|
|
360
|
-
const expanded = new Set(Array.from(rawEventList.querySelectorAll("details[open]")).map(item => item.dataset.seq));
|
|
361
|
-
eventList.replaceChildren();
|
|
362
|
-
rawEventList.replaceChildren();
|
|
363
|
-
rawEvents.querySelector("summary").textContent = data.kind === "acp" ? "全部任务与报告" : "全部原生事件";
|
|
364
|
-
const labels = { "user/message": "输入", "assistant/message": "专家回复", "tool/result": "工具结果", "turn/end": "本轮结束", "acp/input": "任务", "acp/report": "专家报告" };
|
|
365
|
-
for (const event of rows(data.kind === "acp" ? data.records : data.events)) {
|
|
366
|
-
const seq = Number(event.seq), label = event.type === "user/message"
|
|
367
|
-
? event.source === "user" ? "输入" : event.source === "pbot-input" ? "任务" : undefined : labels[text(event.type)];
|
|
368
|
-
if (label && text(event.preview)) {
|
|
369
|
-
const item = element("article", "", "pbot-event"), meta = group(item, "pbot-row");
|
|
370
|
-
meta.append(element("h4", label), note(time(event.time)));
|
|
371
|
-
item.append(block(event.preview));
|
|
372
|
-
button(item, "阅读全文", () => loadRecord(seq), "pbot-quiet");
|
|
373
|
-
eventList.append(item);
|
|
374
|
-
}
|
|
375
|
-
const item = details(rawEventList, `${seq} · ${event.type} · ${time(event.time)}`);
|
|
376
|
-
item.dataset.seq = text(seq);
|
|
377
|
-
item.open = expanded.has(text(seq));
|
|
378
|
-
item.append(block(event.preview));
|
|
379
|
-
button(item, "读取事件", () => loadRecord(seq, 0, "json"));
|
|
380
|
-
}
|
|
381
|
-
if (!eventList.childElementCount)
|
|
382
|
-
eventList.append(empty("还没有对话内容", "发送任务后,可在这里查看专家的回复与工具结果。"));
|
|
383
|
-
}
|
|
384
|
-
const teams = section("teams", "团队");
|
|
385
|
-
pageTitle(teams, "团队", "");
|
|
386
|
-
const createTeam = details(teams, "创建团队"), teamForm = form(createTeam), teamName = field(teamForm, "团队名称"), brief = field(teamForm, "共同目标", true);
|
|
387
|
-
teamName.required = true;
|
|
388
|
-
brief.required = true;
|
|
389
|
-
teamName.placeholder = "例如:投资研究小组";
|
|
390
|
-
teamForm.append(note("为成员填写职责,留空则不加入。"));
|
|
391
|
-
const memberFields = group(teamForm);
|
|
392
|
-
submit(teamForm, "创建团队", async () => {
|
|
393
|
-
const members = Array.from(memberFields.querySelectorAll("input[data-agent-id]")).filter(input => input.value.trim())
|
|
394
|
-
.map(input => ({ agentId: input.dataset.agentId, role: input.value }));
|
|
395
|
-
const value = objectInput(await command("team", { action: "create", name: teamName.value, brief: brief.value, members }, "团队已创建,可以安排首个批次。"));
|
|
396
|
-
createTeam.open = false;
|
|
397
|
-
await chooseTeam(text(value.teamId));
|
|
398
|
-
});
|
|
399
|
-
const teamSplit = group(teams, "pbot-split"), teamList = group(teamSplit, "pbot-list"), teamDetail = group(teamSplit, "pbot-detail");
|
|
400
|
-
teamList.setAttribute("aria-label", "团队列表");
|
|
401
|
-
const teamEmpty = empty("选择团队", "查看进展与公共消息。"), teamPanel = group(teamDetail);
|
|
402
|
-
teamDetail.prepend(teamEmpty);
|
|
403
|
-
teamPanel.hidden = true;
|
|
404
|
-
const teamHeading = group(teamPanel, "pbot-detail-title"), teamTitle = element("h3"), teamBadge = element("span");
|
|
405
|
-
teamHeading.append(teamTitle, teamBadge);
|
|
406
|
-
const teamInfo = group(teamPanel), teamState = block("");
|
|
407
|
-
teamState.classList.add("pbot-raw");
|
|
408
|
-
const teamControls = group(teamPanel, "pbot-row"), requireTeam = () => { if (!teamId)
|
|
409
|
-
throw new Error("请先选择团队。"); return teamId; };
|
|
410
|
-
const pauseButton = button(teamControls, "暂停新安排", async () => { await command("team", { action: "pause", teamId: requireTeam() }, "已暂停新安排;在途任务仍可能完成。"); await loadTeam(); });
|
|
411
|
-
const teamConfig = details(teamPanel, "成员与团队详情");
|
|
412
|
-
teamConfig.append(teamState);
|
|
413
|
-
const closeTeamButton = button(teamConfig, "关闭团队", async () => { await command("team", { action: "close", teamId: requireTeam() }, "团队已关闭,成员专家仍可独立使用。"); await loadTeam(); }, "pbot-danger");
|
|
414
|
-
const batch = details(teamPanel, "新批次"), batchForm = form(batch), instruction = field(batchForm, "任务与交付要求", true);
|
|
415
|
-
instruction.required = true;
|
|
416
|
-
const batchOptions = group(batchForm, "pbot-grid"), mode = select(batchOptions, "讨论模式", [["roundRobin", "轮流讨论"], ["parallel", "并行轮次"]]);
|
|
417
|
-
const rounds = field(batchOptions, "每位成员轮数", false, "2"), concurrency = field(batchOptions, "并发上限", false, "1"), timeout = field(batchOptions, "整批期限(秒)", false, "900");
|
|
418
|
-
for (const [input, max] of [[rounds, 10], [concurrency, 50], [timeout, 86400]]) {
|
|
419
|
-
input.setAttribute("type", "number");
|
|
420
|
-
input.setAttribute("min", "1");
|
|
421
|
-
input.setAttribute("max", text(max));
|
|
422
|
-
input.required = true;
|
|
423
|
-
}
|
|
424
|
-
const runButton = submit(batchForm, "开始新批次", async () => {
|
|
425
|
-
await command("team", { action: "run", teamId: requireTeam(), instruction: instruction.value,
|
|
426
|
-
mode: mode.value, rounds: Number(rounds.value), maxConcurrent: Number(concurrency.value), timeoutSeconds: Number(timeout.value) }, "新批次已开始。");
|
|
427
|
-
await loadTeam();
|
|
428
|
-
});
|
|
429
|
-
const publicCard = group(teamPanel, "pbot-card");
|
|
430
|
-
const postForm = form(publicCard), post = field(postForm, "公共消息", true);
|
|
431
|
-
post.required = true;
|
|
432
|
-
const replyTo = field(details(postForm, "回复消息"), "回复序号");
|
|
433
|
-
replyTo.setAttribute("type", "number");
|
|
434
|
-
replyTo.setAttribute("min", "1");
|
|
435
|
-
const postButton = submit(postForm, "发布公共消息", async () => {
|
|
436
|
-
const id = requireTeam(), message = post.value;
|
|
437
|
-
await command("post", { teamId: id, text: message, ...(replyTo.value ? { replyTo: Number(replyTo.value) } : {}) }, "公共消息已发布。");
|
|
438
|
-
if (teamId === id && post.value === message)
|
|
439
|
-
post.value = "";
|
|
440
|
-
const draft = teamDrafts.get(id);
|
|
441
|
-
if (draft?.text === message)
|
|
442
|
-
draft.text = "";
|
|
443
|
-
await loadTeam();
|
|
444
|
-
});
|
|
445
|
-
const teamMessages = group(teamPanel), teamPaging = group(teamPanel, "pbot-pagination");
|
|
446
|
-
let teamAfter = 0, teamPage = { afterSeq: 0 };
|
|
447
|
-
const teamDrafts = new Map();
|
|
448
|
-
async function chooseTeam(id) {
|
|
449
|
-
if (id !== teamId) {
|
|
450
|
-
if (teamId)
|
|
451
|
-
teamDrafts.set(teamId, { text: post.value, reply: replyTo.value, instruction: instruction.value, mode: mode.value, rounds: rounds.value, concurrency: concurrency.value, timeout: timeout.value });
|
|
452
|
-
const draft = teamDrafts.get(id);
|
|
453
|
-
post.value = draft?.text ?? "";
|
|
454
|
-
replyTo.value = draft?.reply ?? "";
|
|
455
|
-
instruction.value = draft?.instruction ?? "";
|
|
456
|
-
mode.value = draft?.mode ?? "roundRobin";
|
|
457
|
-
rounds.value = draft?.rounds ?? "2";
|
|
458
|
-
concurrency.value = draft?.concurrency ?? "1";
|
|
459
|
-
timeout.value = draft?.timeout ?? "900";
|
|
460
|
-
}
|
|
461
|
-
teamId = id;
|
|
462
|
-
teamAfter = 0;
|
|
463
|
-
teamPageKey = "";
|
|
464
|
-
++teamRevision;
|
|
465
|
-
teamPanel.hidden = true;
|
|
466
|
-
teamEmpty.hidden = false;
|
|
467
|
-
teamEmpty.replaceChildren(note("正在读取团队记录…"));
|
|
468
|
-
renderLists();
|
|
469
|
-
await loadTeam({ afterSeq: 0 });
|
|
470
|
-
}
|
|
471
|
-
async function loadTeam(nextPage) {
|
|
472
|
-
if (!teamId)
|
|
473
|
-
return;
|
|
474
|
-
if (nextPage)
|
|
475
|
-
teamPage = nextPage;
|
|
476
|
-
const page = teamPage, id = teamId;
|
|
477
|
-
const revision = ++teamRevision, data = await query("team", { teamId: id, ...page });
|
|
478
|
-
if (id !== teamId || revision !== teamRevision)
|
|
479
|
-
return;
|
|
480
|
-
const team = record(data.team), messages = record(data.page), run = object(team.run) ? team.run : undefined;
|
|
481
|
-
teamPanel.hidden = false;
|
|
482
|
-
teamEmpty.hidden = true;
|
|
483
|
-
teamTitle.textContent = text(team.name);
|
|
484
|
-
teamBadge.replaceChildren(badge(team.closed ? "closed" : run?.state ?? "open"));
|
|
485
|
-
teamInfo.replaceChildren(block(team.brief), facts([["成员", rows(team.members).map(member => `${member.name} · ${member.role}`).join("\n")],
|
|
486
|
-
["批次进展", run ? `已安排 ${run.scheduled} · 已交付 ${run.published} · 在途 ${team.activeCount}` : "尚未开始"],
|
|
487
|
-
...(run?.reason ? [["暂停原因", run.reason]] : [])]));
|
|
488
|
-
teamState.textContent = JSON.stringify(team, null, 2);
|
|
489
|
-
enabled(pauseButton, !team.closed && run?.state === "running");
|
|
490
|
-
enabled(closeTeamButton, !team.closed);
|
|
491
|
-
enabled(runButton, !team.closed && run?.state !== "running" && Number(team.activeCount) === 0);
|
|
492
|
-
enabled(postButton, !team.closed);
|
|
493
|
-
const key = JSON.stringify([id, page, messages]);
|
|
494
|
-
if (key === teamPageKey)
|
|
495
|
-
return;
|
|
496
|
-
teamPageKey = key;
|
|
497
|
-
teamMessages.replaceChildren();
|
|
498
|
-
teamPaging.replaceChildren();
|
|
499
|
-
for (const message of rows(messages.messages)) {
|
|
500
|
-
const author = record(message.author), item = element("article", "", "pbot-message"), meta = group(item, "pbot-row");
|
|
501
|
-
meta.append(element("h4", text(author.name)), note(`#${message.seq}${message.replyTo ? ` · 回复 #${message.replyTo}` : ""}`));
|
|
502
|
-
item.append(block(message.text));
|
|
503
|
-
if (typeof message.nextOffset === "number")
|
|
504
|
-
button(item, "继续读取这条消息", () => loadTeam({ seq: message.seq, offset: message.nextOffset }), "pbot-quiet");
|
|
505
|
-
teamMessages.append(item);
|
|
506
|
-
}
|
|
507
|
-
if (!teamMessages.childElementCount)
|
|
508
|
-
teamMessages.append(empty("还没有公共消息", "发布资料或开启批次后,成员会在这里共享结果。"));
|
|
509
|
-
button(teamPaging, "从第一条读取", async () => { teamAfter = 0; await loadTeam({ afterSeq: 0 }); });
|
|
510
|
-
if (typeof messages.nextAfterSeq === "number")
|
|
511
|
-
button(teamPaging, "后续消息", async () => { teamAfter = messages.nextAfterSeq; await loadTeam({ afterSeq: teamAfter }); });
|
|
512
|
-
if (page.seq !== undefined)
|
|
513
|
-
button(teamPaging, "返回消息列表", () => loadTeam({ afterSeq: teamAfter }));
|
|
514
|
-
}
|
|
515
158
|
const history = section("history", "历史");
|
|
516
159
|
pageTitle(history, "历史", "");
|
|
517
160
|
const searchForm = form(history);
|
|
@@ -535,8 +178,12 @@ export function showManagement(ctx, parentSessionId) {
|
|
|
535
178
|
}
|
|
536
179
|
async function searchHistory(offset = 0, keepFilters = false) {
|
|
537
180
|
if (!keepFilters)
|
|
538
|
-
historySearch = {
|
|
539
|
-
|
|
181
|
+
historySearch = {
|
|
182
|
+
query: historyQuery.value,
|
|
183
|
+
...(host.value ? { host: host.value } : {}),
|
|
184
|
+
...(historyFrom.value ? { from: new Date(historyFrom.value).toISOString() } : {}),
|
|
185
|
+
...(historyTo.value ? { to: new Date(historyTo.value).toISOString() } : {}),
|
|
186
|
+
};
|
|
540
187
|
const revision = ++historyRevision, data = await query("history", { action: "search", ...historySearch, offset });
|
|
541
188
|
if (revision !== historyRevision)
|
|
542
189
|
return;
|
|
@@ -592,46 +239,6 @@ export function showManagement(ctx, parentSessionId) {
|
|
|
592
239
|
details(historyNode, "原始来源位置").append(provenance);
|
|
593
240
|
historyNode.scrollIntoView({ block: "start" });
|
|
594
241
|
}
|
|
595
|
-
const expertButtons = new Map(), teamButtons = new Map();
|
|
596
|
-
function syncList(container, buttons, values, kind) {
|
|
597
|
-
const ids = new Set(values.map(value => text(value[kind + "Id"])));
|
|
598
|
-
for (const [id, node] of buttons)
|
|
599
|
-
if (!ids.has(id)) {
|
|
600
|
-
node.remove();
|
|
601
|
-
buttons.delete(id);
|
|
602
|
-
}
|
|
603
|
-
container.querySelector(":scope > .pbot-empty")?.remove();
|
|
604
|
-
for (const value of values) {
|
|
605
|
-
const id = text(value[kind + "Id"]), state = kind === "agent" ? value.state : value.closed ? "closed" : object(value.run) ? value.run.state : "open";
|
|
606
|
-
let node = buttons.get(id);
|
|
607
|
-
if (!node) {
|
|
608
|
-
node = button(container, "", () => kind === "agent" ? chooseExpert(id) : chooseTeam(id), "pbot-list-item");
|
|
609
|
-
buttons.set(id, node);
|
|
610
|
-
}
|
|
611
|
-
node.setAttribute("aria-label", text(value.name));
|
|
612
|
-
node.setAttribute("aria-pressed", String(id === (kind === "agent" ? expertId : teamId)));
|
|
613
|
-
const signature = JSON.stringify([value.name, state, value.activity, value.brief]);
|
|
614
|
-
if (node.dataset.content !== signature) {
|
|
615
|
-
node.dataset.content = signature;
|
|
616
|
-
node.replaceChildren();
|
|
617
|
-
const row = group(node, "pbot-between");
|
|
618
|
-
row.append(element("strong", text(value.name)), badge(state));
|
|
619
|
-
if (kind === "team" || !["idle", "stopped"].includes(text(state)))
|
|
620
|
-
node.append(note(text(kind === "agent" ? value.activity : value.brief)));
|
|
621
|
-
}
|
|
622
|
-
node.hidden = kind === "agent" && !`${value.name} ${stateLabel(state)}`.toLowerCase().includes(expertFilter.value.trim().toLowerCase());
|
|
623
|
-
}
|
|
624
|
-
if (!values.length || [...buttons.values()].every(node => node.hidden)) {
|
|
625
|
-
container.append(empty(values.length ? "没有匹配的专家" : kind === "agent" ? "还没有专家" : "还没有团队", values.length ? "调整名称或状态关键词。" : kind === "agent" ? "展开上方“创建专家”开始。" : "先创建专家,再为成员分配职责。"));
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
function renderLists() {
|
|
629
|
-
if (!snapshot)
|
|
630
|
-
return;
|
|
631
|
-
syncList(expertList, expertButtons, rows(snapshot.agents), "agent");
|
|
632
|
-
syncList(teamList, teamButtons, rows(snapshot.teams), "team");
|
|
633
|
-
}
|
|
634
|
-
expertFilter.addEventListener("input", renderLists);
|
|
635
242
|
function renderSnapshot() {
|
|
636
243
|
if (!snapshot)
|
|
637
244
|
return;
|
|
@@ -657,53 +264,18 @@ export function showManagement(ctx, parentSessionId) {
|
|
|
657
264
|
materials.hidden = false;
|
|
658
265
|
initializeButton.textContent = "准备目录";
|
|
659
266
|
enabled(initializeButton, true);
|
|
660
|
-
const
|
|
661
|
-
|
|
662
|
-
tabCounts.get("teams").textContent = text(teams.length);
|
|
663
|
-
const active = agents.filter(agent => ["starting", "busy", "stopping"].includes(text(agent.state))).length;
|
|
664
|
-
counts.textContent = `Personal Bot 已启动 · 专家 ${agents.length} · 执行中 ${active} · 团队 ${teams.length}`;
|
|
267
|
+
const historyState = record(snapshot.history);
|
|
268
|
+
counts.textContent = "Personal Bot 已启动 · 跨 Harness 调度通过 MCP worker_* 提供";
|
|
665
269
|
const model = object(snapshot.model) ? snapshot.model : {};
|
|
666
|
-
workspaceInfo.replaceChildren(facts([
|
|
667
|
-
["
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
for (const request of pending) {
|
|
676
|
-
const card = group(permissions, "pbot-card");
|
|
677
|
-
card.append(element("h4", text(request.name)), block(request.description));
|
|
678
|
-
const choices = group(card, "pbot-row");
|
|
679
|
-
for (const option of rows(request.options))
|
|
680
|
-
button(choices, text(option.name), async () => {
|
|
681
|
-
await command("approval", { agentId: request.agentId, requestId: request.requestId, optionId: option.optionId }, "确认答复已提交。");
|
|
682
|
-
});
|
|
683
|
-
button(choices, "取消", async () => { await command("approval", { agentId: request.agentId, requestId: request.requestId, optionId: null }, "已取消该请求。"); });
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
if (snapshot.controlError)
|
|
687
|
-
inform(text(snapshot.controlError), "error");
|
|
688
|
-
renderLists();
|
|
689
|
-
const owned = agents.filter(value => value.owned && record(value.capabilities).team !== false), ids = new Set(owned.map(agent => text(agent.agentId)));
|
|
690
|
-
for (const input of memberFields.querySelectorAll("input[data-agent-id]"))
|
|
691
|
-
if (!ids.has(input.dataset.agentId))
|
|
692
|
-
input.parentElement?.remove();
|
|
693
|
-
memberFields.querySelector(":scope > p")?.remove();
|
|
694
|
-
for (const agent of owned) {
|
|
695
|
-
const id = text(agent.agentId);
|
|
696
|
-
let input = Array.from(memberFields.querySelectorAll("input[data-agent-id]")).find(input => input.dataset.agentId === id);
|
|
697
|
-
if (!input) {
|
|
698
|
-
input = field(memberFields, `${agent.name} · 职责`);
|
|
699
|
-
input.dataset.agentId = id;
|
|
700
|
-
}
|
|
701
|
-
const label = `${agent.name} · 职责`;
|
|
702
|
-
input.setAttribute("aria-label", label);
|
|
703
|
-
input.parentElement.querySelector("span").textContent = label;
|
|
704
|
-
}
|
|
705
|
-
if (!owned.length)
|
|
706
|
-
memberFields.append(note("还没有可加入的专家,请先在专家页创建。"));
|
|
270
|
+
workspaceInfo.replaceChildren(facts([
|
|
271
|
+
["状态", "已启动"],
|
|
272
|
+
["工作区", snapshot.workspaceRoot],
|
|
273
|
+
["配置文件", record(snapshot.configuration).path],
|
|
274
|
+
["模型", model.model || "尚未选择"],
|
|
275
|
+
["Provider", model.provider || "—"],
|
|
276
|
+
["历史", historyState.organizing ? "整理中" : historyState.pending === null ? "查询时更新索引" : `${historyState.pending} 项待整理`],
|
|
277
|
+
]));
|
|
278
|
+
statusBody.textContent = JSON.stringify(snapshot, null, 2);
|
|
707
279
|
}
|
|
708
280
|
async function refresh() {
|
|
709
281
|
const revision = ++snapshotRevision, value = await query("snapshot");
|
|
@@ -729,10 +301,6 @@ export function showManagement(ctx, parentSessionId) {
|
|
|
729
301
|
async function poll() {
|
|
730
302
|
try {
|
|
731
303
|
await refresh();
|
|
732
|
-
if (tab === "experts" && expertId)
|
|
733
|
-
await loadExpert();
|
|
734
|
-
if (tab === "teams" && teamId)
|
|
735
|
-
await loadTeam();
|
|
736
304
|
if (pollError) {
|
|
737
305
|
inform("连接已恢复,状态已更新。");
|
|
738
306
|
pollError = false;
|
package/lib/ui/dsh/remote.d.ts
CHANGED
package/lib/ui/dsh/remote.js
CHANGED
|
@@ -3,7 +3,7 @@ import { json } from "../../common/json.js";
|
|
|
3
3
|
const value = { mode: "strict", typeSymbol: "personal-bot#Json", create: () => ({ parse: json }) };
|
|
4
4
|
export const pbotReadRemote = {
|
|
5
5
|
package: "personal-bot",
|
|
6
|
-
descriptors: ["snapshot", "
|
|
6
|
+
descriptors: ["snapshot", "history"].map((method) => ({
|
|
7
7
|
id: "personal-bot#PbotManagement." + method, service: "pbotManagement", namespace: "pbot", method,
|
|
8
8
|
invocation: { kind: "direct" }, parameters: [{ name: "request", wire: "request", source: "json", codec: value }],
|
|
9
9
|
cancellation: { parameter: "signal" }, result: value,
|