personal-bot 0.2.19 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.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 +93 -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 +39 -7
- 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 +17 -22
- package/resources/skills/provider-connections/SKILL.md +24 -40
- package/resources/templates/workspace-agents.md +8 -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 +42 -6
- 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
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
2
|
-
import { requireThat } from "../../common/validation.js";
|
|
3
|
-
import { openDshAgent, readDshAgentSession, readDshReport } from "./session.js";
|
|
4
|
-
/** Native handles belong to the execution component, independently of browser observers. */
|
|
5
|
-
export class DshAgents {
|
|
6
|
-
ctx;
|
|
7
|
-
parent;
|
|
8
|
-
composition;
|
|
9
|
-
lifetime;
|
|
10
|
-
kind = "dsh";
|
|
11
|
-
#runs = new Map();
|
|
12
|
-
#closed = false;
|
|
13
|
-
constructor(ctx, parent, composition, lifetime) {
|
|
14
|
-
this.ctx = ctx;
|
|
15
|
-
this.parent = parent;
|
|
16
|
-
this.composition = composition;
|
|
17
|
-
this.lifetime = lifetime;
|
|
18
|
-
}
|
|
19
|
-
available() {
|
|
20
|
-
this.lifetime.throwIfAborted();
|
|
21
|
-
requireThat(!this.#closed && this.ctx.agents.get(this.parent.id) === this.parent, "dsh 父会话或执行组件已关闭。");
|
|
22
|
-
}
|
|
23
|
-
alive(id) {
|
|
24
|
-
const run = this.#runs.get(id);
|
|
25
|
-
return Boolean(this.ctx.agents.get(SessionId(id))) || Boolean(run && (run.closing || !run.handle));
|
|
26
|
-
}
|
|
27
|
-
reference(d, reference) {
|
|
28
|
-
requireThat(reference.host === "dsh" && reference.sessionId === d.agentId, "不能接管其他宿主或其他身份的原生会话。");
|
|
29
|
-
}
|
|
30
|
-
async validateSession(d, reference) {
|
|
31
|
-
this.available();
|
|
32
|
-
this.reference(d, reference);
|
|
33
|
-
requireThat(!this.alive(d.agentId), "原生专家仍被占用,不能恢复。");
|
|
34
|
-
await readDshAgentSession(this.ctx, d);
|
|
35
|
-
requireThat(!this.alive(d.agentId), "原生专家仍被占用,不能恢复。");
|
|
36
|
-
}
|
|
37
|
-
async launch(d, directory, generation, reference, resume, signal) {
|
|
38
|
-
this.available();
|
|
39
|
-
this.reference(d, reference);
|
|
40
|
-
requireThat(!this.alive(d.agentId), "dsh 专家仍在运行或释放中。");
|
|
41
|
-
const previous = this.#runs.get(d.agentId);
|
|
42
|
-
if (previous)
|
|
43
|
-
await this.release(d.agentId, previous.generation);
|
|
44
|
-
signal.throwIfAborted();
|
|
45
|
-
this.available();
|
|
46
|
-
const controller = new AbortController();
|
|
47
|
-
const combined = AbortSignal.any([signal, this.lifetime, controller.signal]);
|
|
48
|
-
const opening = Promise.resolve().then(() => openDshAgent(this.ctx, d, this.parent, resume, this.composition.setup(d, directory, generation), combined));
|
|
49
|
-
const run = { generation, controller, opening };
|
|
50
|
-
this.#runs.set(d.agentId, run);
|
|
51
|
-
try {
|
|
52
|
-
run.handle = await opening;
|
|
53
|
-
if (combined.aborted) {
|
|
54
|
-
await this.release(d.agentId, generation);
|
|
55
|
-
combined.throwIfAborted();
|
|
56
|
-
}
|
|
57
|
-
this.composition.ready(run.handle.agent, generation);
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
if (!run.handle && this.#runs.get(d.agentId) === run)
|
|
61
|
-
this.#runs.delete(d.agentId);
|
|
62
|
-
throw error;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
release(id, generation) {
|
|
66
|
-
const run = this.#runs.get(id);
|
|
67
|
-
if (!run)
|
|
68
|
-
return this.ctx.agents.get(SessionId(id)) ? Promise.reject(new Error("原生专家仍由其他执行实例持有;当前组件不能释放。")) : Promise.resolve();
|
|
69
|
-
if (run.generation !== generation)
|
|
70
|
-
return Promise.resolve();
|
|
71
|
-
if (run.closing)
|
|
72
|
-
return run.closing;
|
|
73
|
-
run.controller.abort();
|
|
74
|
-
run.closing = (async () => {
|
|
75
|
-
const handle = run.handle ?? await run.opening.catch(() => undefined);
|
|
76
|
-
let failure;
|
|
77
|
-
if (handle) {
|
|
78
|
-
try {
|
|
79
|
-
await this.composition.stopping(handle.agent, generation);
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
failure = error;
|
|
83
|
-
}
|
|
84
|
-
await handle.dispose();
|
|
85
|
-
}
|
|
86
|
-
if (this.#runs.get(id) === run)
|
|
87
|
-
this.#runs.delete(id);
|
|
88
|
-
if (failure)
|
|
89
|
-
throw failure;
|
|
90
|
-
})();
|
|
91
|
-
return run.closing;
|
|
92
|
-
}
|
|
93
|
-
report(d, reference, position) {
|
|
94
|
-
this.reference(d, reference);
|
|
95
|
-
return readDshReport(this.ctx, d, position);
|
|
96
|
-
}
|
|
97
|
-
async close() {
|
|
98
|
-
this.#closed = true;
|
|
99
|
-
const results = await Promise.allSettled([...this.#runs].map(([id, run]) => this.release(id, run.generation)));
|
|
100
|
-
const errors = results.flatMap(r => r.status === "rejected" ? [r.reason] : []);
|
|
101
|
-
if (errors.length)
|
|
102
|
-
throw new AggregateError(errors, "dsh 专家仍有未释放的执行资源。");
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import { type FileBlock, type ImageBlock } from "@deepseek-ai/dsh-llm";
|
|
3
|
-
import type { AgentDescriptor, AgentMessage } from "../../model/agent.js";
|
|
4
|
-
import "./messages.js";
|
|
5
|
-
export declare function dshInput(ctx: Context, d: AgentDescriptor, request: AgentMessage, signal: AbortSignal): Promise<{
|
|
6
|
-
content: import("@deepseek-ai/dsh-attachment").AdmittedPromptContentPart[];
|
|
7
|
-
source: {
|
|
8
|
-
kind: "pbot-input";
|
|
9
|
-
form: "relay";
|
|
10
|
-
requestId: string;
|
|
11
|
-
generation: string;
|
|
12
|
-
parentSessionId: string;
|
|
13
|
-
};
|
|
14
|
-
} & Pick<import("@deepseek-ai/dsh-llm").UserMessage, "role" | "id">>;
|
|
15
|
-
/** Command attachments have already passed native upload admission; the caller never supplies arbitrary references. */
|
|
16
|
-
export declare function dshHumanInput(ctx: Context, cwd: string, text: string, files: readonly string[], attachments: readonly (ImageBlock | FileBlock)[], signal: AbortSignal): Promise<{
|
|
17
|
-
content: import("@deepseek-ai/dsh-attachment").AdmittedPromptContentPart[];
|
|
18
|
-
source: {
|
|
19
|
-
kind: "user";
|
|
20
|
-
};
|
|
21
|
-
} & Pick<import("@deepseek-ai/dsh-llm").UserMessage, "role" | "id">>;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { basename, extname } from "node:path";
|
|
2
|
-
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
3
|
-
import { requireThat } from "../../common/validation.js";
|
|
4
|
-
import "./messages.js";
|
|
5
|
-
const imageTypes = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp", ".gif": "image/gif" };
|
|
6
|
-
/** Native file attachments remain verbatim; image admission uses the host's policy. */
|
|
7
|
-
async function contentFor(ctx, cwd, message, files, signal) {
|
|
8
|
-
const content = [];
|
|
9
|
-
let imageCount = 0, imageBytes = 0;
|
|
10
|
-
for (const path of files) {
|
|
11
|
-
signal.throwIfAborted();
|
|
12
|
-
const target = await ctx.fs.resolve(path, { cwd, signal });
|
|
13
|
-
const before = await ctx.fs.stat(target, signal);
|
|
14
|
-
requireThat(before?.type === "file", "附件必须是普通文件:" + path);
|
|
15
|
-
const name = basename(path), mediaType = imageTypes[extname(path).toLowerCase()];
|
|
16
|
-
if (mediaType) {
|
|
17
|
-
const limits = ctx.attachments.imageLimits;
|
|
18
|
-
requireThat(++imageCount <= limits.maxImagesPerMessage &&
|
|
19
|
-
(before.size === undefined || imageBytes + before.size <= limits.maxMessageImageBytes), "图片附件超过宿主消息准入上限。");
|
|
20
|
-
const data = await ctx.fs.readBytes(target, signal, limits.maxImageBytes);
|
|
21
|
-
imageBytes += data.byteLength;
|
|
22
|
-
requireThat(imageBytes <= limits.maxMessageImageBytes, "图片附件超过宿主消息准入上限。");
|
|
23
|
-
content.push({ type: "image", mediaType, name, data: Buffer.from(data).toString("base64") });
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
async function* bytes(file) {
|
|
27
|
-
let offset = 0;
|
|
28
|
-
for (;;) {
|
|
29
|
-
signal.throwIfAborted();
|
|
30
|
-
const chunk = await ctx.fs.readByteRange(file, { offset, length: 256 * 1024 }, signal);
|
|
31
|
-
if (!chunk.length)
|
|
32
|
-
break;
|
|
33
|
-
yield chunk;
|
|
34
|
-
offset += chunk.length;
|
|
35
|
-
}
|
|
36
|
-
requireThat((await ctx.fs.stat(file, signal))?.version === before?.version, "读取期间附件已变化:" + path);
|
|
37
|
-
}
|
|
38
|
-
content.push({ type: "file", attachment: await ctx.attachments.saveFileStream({ data: bytes(target), name, signal }) });
|
|
39
|
-
}
|
|
40
|
-
requireThat((await ctx.fs.stat(target, signal))?.version === before.version, "读取期间附件已变化:" + path);
|
|
41
|
-
content.push({ type: "text", text: "附件原始路径:" + JSON.stringify(path) + "。原生附件保留本次文件内容;需要查看时使用宿主提供的附件路径。" });
|
|
42
|
-
}
|
|
43
|
-
content.push({ type: "text", text: message || "请处理所附文件。" });
|
|
44
|
-
const admitted = await ctx.attachments.admitPromptContent(content);
|
|
45
|
-
signal.throwIfAborted();
|
|
46
|
-
return admitted;
|
|
47
|
-
}
|
|
48
|
-
export async function dshInput(ctx, d, request, signal) {
|
|
49
|
-
const content = await contentFor(ctx, d.cwd, request.message, request.files, signal);
|
|
50
|
-
return createUserMessage({ content, source: { kind: "pbot-input", form: "relay",
|
|
51
|
-
requestId: request.requestId, generation: request.generation, parentSessionId: d.parentSessionId } });
|
|
52
|
-
}
|
|
53
|
-
/** Command attachments have already passed native upload admission; the caller never supplies arbitrary references. */
|
|
54
|
-
export async function dshHumanInput(ctx, cwd, text, files, attachments, signal) {
|
|
55
|
-
requireThat(files.length + attachments.length <= 32, "一次最多附加 32 个文件。");
|
|
56
|
-
requireThat(!files.length || !attachments.length, "一次对话请选择服务器文件或输入框附件,不能同时使用。");
|
|
57
|
-
signal.throwIfAborted();
|
|
58
|
-
const content = attachments.length ? [...attachments, { type: "text", text: text || "请处理所附文件。" }] :
|
|
59
|
-
await contentFor(ctx, cwd, text, files, signal);
|
|
60
|
-
signal.throwIfAborted();
|
|
61
|
-
return createUserMessage({ content, source: { kind: "user" } });
|
|
62
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { SessionEvent } from "@deepseek-ai/dsh-session";
|
|
2
|
-
import type { UserMessage } from "@deepseek-ai/dsh-llm";
|
|
3
|
-
import "./messages.js";
|
|
4
|
-
/** Only committed native context or successful model tool results claim notices.
|
|
5
|
-
* PTC inner reads require their enclosing transport to have committed success. */
|
|
6
|
-
export declare function deliveredDshNotices(events: readonly SessionEvent[]): Set<string>;
|
|
7
|
-
/** Pending inbox entries prevent duplicate submission, but are not delivery receipts. */
|
|
8
|
-
export declare function pendingDshNotices(messages: readonly UserMessage[]): string[];
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { object } from "../../common/json.js";
|
|
2
|
-
import "./messages.js";
|
|
3
|
-
function keys(value, field) {
|
|
4
|
-
if (!object(value))
|
|
5
|
-
return [];
|
|
6
|
-
const items = value[field];
|
|
7
|
-
return Array.isArray(items) && items.every(item => typeof item === "string") ? items : [];
|
|
8
|
-
}
|
|
9
|
-
/** Only committed native context or successful model tool results claim notices.
|
|
10
|
-
* PTC inner reads require their enclosing transport to have committed success. */
|
|
11
|
-
export function deliveredDshNotices(events) {
|
|
12
|
-
const delivered = new Set();
|
|
13
|
-
const reads = new Set(), nested = new Map();
|
|
14
|
-
for (const event of events) {
|
|
15
|
-
if (event.type === "turn/start" || event.type === "step/start" || event.type === "turn/end") {
|
|
16
|
-
reads.clear();
|
|
17
|
-
nested.clear();
|
|
18
|
-
}
|
|
19
|
-
if (event.type === "user/message" && event.data.source.kind === "pbot-results") {
|
|
20
|
-
for (const key of keys(event.data.source, "keys"))
|
|
21
|
-
delivered.add(key);
|
|
22
|
-
}
|
|
23
|
-
if (event.type === "tool/call" && event.data.name === "pbot_agent") {
|
|
24
|
-
try {
|
|
25
|
-
const args = JSON.parse(event.data.arguments);
|
|
26
|
-
if (object(args) && args.action === "read")
|
|
27
|
-
reads.add(event.data.callId);
|
|
28
|
-
}
|
|
29
|
-
catch { /* An invalid call cannot claim a report. */ }
|
|
30
|
-
}
|
|
31
|
-
if (event.type === "tool/ptc-dispatch" && event.data.name === "pbot_agent" && !event.data.isError &&
|
|
32
|
-
object(event.data.arguments) && event.data.arguments.action === "read") {
|
|
33
|
-
const values = nested.get(event.data.rootCallId) ?? [];
|
|
34
|
-
values.push(...keys(event.data.meta, "pbotAgentReadKeys"));
|
|
35
|
-
nested.set(event.data.rootCallId, values);
|
|
36
|
-
}
|
|
37
|
-
if (event.type === "tool/result") {
|
|
38
|
-
const message = event.data.message;
|
|
39
|
-
if (!message.isError) {
|
|
40
|
-
if (reads.has(message.toolCallId))
|
|
41
|
-
for (const key of keys(event.data.meta, "pbotAgentReadKeys"))
|
|
42
|
-
delivered.add(key);
|
|
43
|
-
for (const key of nested.get(message.toolCallId) ?? [])
|
|
44
|
-
delivered.add(key);
|
|
45
|
-
}
|
|
46
|
-
reads.delete(message.toolCallId);
|
|
47
|
-
nested.delete(message.toolCallId);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return delivered;
|
|
51
|
-
}
|
|
52
|
-
/** Pending inbox entries prevent duplicate submission, but are not delivery receipts. */
|
|
53
|
-
export function pendingDshNotices(messages) {
|
|
54
|
-
return messages.flatMap(message => message.source.kind === "pbot-results" ? keys(message.source, "keys") : []);
|
|
55
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import type { Agent, AgentHandle, AgentSetup } from "@deepseek-ai/dsh-agent";
|
|
3
|
-
import type { SessionHeader } from "@deepseek-ai/dsh-session";
|
|
4
|
-
import type { AgentDescriptor } from "../../model/agent.js";
|
|
5
|
-
/** Read access must neither claim a writer nor activate an Agent. */
|
|
6
|
-
export declare function readDshAgentSession(ctx: Context, d: AgentDescriptor): Promise<{
|
|
7
|
-
header: SessionHeader;
|
|
8
|
-
events: readonly import("@deepseek-ai/dsh-session").SessionEvent[];
|
|
9
|
-
}>;
|
|
10
|
-
/** An empty Agent is not recoverable until this native barrier has materialized it. */
|
|
11
|
-
export declare function flushDshAgent(agent: Agent): Promise<void>;
|
|
12
|
-
export declare function openDshAgent(ctx: Context, d: AgentDescriptor, parent: Agent, resume: boolean, setup: AgentSetup, signal: AbortSignal): Promise<AgentHandle>;
|
|
13
|
-
/** A report refers to one durable turn boundary, never the latest answer. */
|
|
14
|
-
export declare function readDshReport(ctx: Context, d: AgentDescriptor, reference: string): Promise<string>;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
2
|
-
import { ReasoningEffortId } from "@deepseek-ai/dsh-llm";
|
|
3
|
-
import { requireThat } from "../../common/validation.js";
|
|
4
|
-
function validateHeader(d, header) {
|
|
5
|
-
requireThat(header.id === d.agentId && header.cwd === d.cwd && header.parentSession === d.parentSessionId &&
|
|
6
|
-
header.origin === "subagent" && !header.isSeeded, "dsh 专家会话身份、父会话或工作目录不匹配。");
|
|
7
|
-
}
|
|
8
|
-
/** Read access must neither claim a writer nor activate an Agent. */
|
|
9
|
-
export async function readDshAgentSession(ctx, d) {
|
|
10
|
-
const reader = await ctx.sessionPersistence.open(SessionId(d.agentId), "read");
|
|
11
|
-
try {
|
|
12
|
-
validateHeader(d, reader.header);
|
|
13
|
-
return { header: reader.header, events: (await reader.read()).events };
|
|
14
|
-
}
|
|
15
|
-
finally {
|
|
16
|
-
await reader.close();
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
/** An empty Agent is not recoverable until this native barrier has materialized it. */
|
|
20
|
-
export async function flushDshAgent(agent) {
|
|
21
|
-
requireThat(await agent.ctx.sessions.flush(agent.session), "dsh 会话没有持久化屏障。");
|
|
22
|
-
}
|
|
23
|
-
export async function openDshAgent(ctx, d, parent, resume, setup, signal) {
|
|
24
|
-
signal.throwIfAborted();
|
|
25
|
-
requireThat(parent.id === d.parentSessionId && ctx.agents.get(parent.id) === parent, "dsh 父会话已失效。");
|
|
26
|
-
if (resume)
|
|
27
|
-
await readDshAgentSession(ctx, d);
|
|
28
|
-
await flushDshAgent(parent);
|
|
29
|
-
signal.throwIfAborted();
|
|
30
|
-
const compose = async (agentCtx, agent) => {
|
|
31
|
-
validateHeader(d, agent.session.header);
|
|
32
|
-
agentCtx.get("agentPresets")?.composeFrom(agentCtx, parent.ctx);
|
|
33
|
-
if (resume)
|
|
34
|
-
agent.inbox.clear();
|
|
35
|
-
const commit = await setup(agentCtx, agent);
|
|
36
|
-
await flushDshAgent(agent);
|
|
37
|
-
return commit;
|
|
38
|
-
};
|
|
39
|
-
const agentOptions = { ...(d.options.provider ? { provider: d.options.provider } : {}),
|
|
40
|
-
...(d.options.model ? { model: d.options.model } : {}),
|
|
41
|
-
...(d.options.thinking ? { reasoningEffort: ReasoningEffortId(d.options.thinking) } : {}) };
|
|
42
|
-
return resume
|
|
43
|
-
? ctx.agents.resume({ resumeSessionId: SessionId(d.agentId), parentAgent: parent, agentOptions, setup: compose, signal })
|
|
44
|
-
: ctx.agents.create({ sessionId: SessionId(d.agentId), parentAgent: parent,
|
|
45
|
-
meta: { cwd: d.cwd, parentSession: parent.id, origin: "subagent", delegationDepth: 1 },
|
|
46
|
-
agentOptions, setup: compose, signal });
|
|
47
|
-
}
|
|
48
|
-
/** A report refers to one durable turn boundary, never the latest answer. */
|
|
49
|
-
export async function readDshReport(ctx, d, reference) {
|
|
50
|
-
const match = /^dsh:(0|[1-9]\d*)$/.exec(reference);
|
|
51
|
-
requireThat(match, "dsh 报告位置无效。");
|
|
52
|
-
const end = Number(match[1]);
|
|
53
|
-
requireThat(Number.isSafeInteger(end), "dsh 报告位置无效。");
|
|
54
|
-
const { events } = await readDshAgentSession(ctx, d);
|
|
55
|
-
const boundary = events[end];
|
|
56
|
-
requireThat(boundary?.type === "turn/end", "dsh 报告结束位置不存在。");
|
|
57
|
-
const last = events.slice(0, end).findLast(event => event.type === "assistant/message" && event.data.turn === boundary.data.turn);
|
|
58
|
-
return last?.type === "assistant/message"
|
|
59
|
-
? last.data.message.content.filter(block => block.type === "text").map(block => block.text).join("\n") : "";
|
|
60
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { TeamLink, TeamMessage } from "../model/team.js";
|
|
2
|
-
type MessagePage = Pick<TeamMessage, "seq" | "author" | "text" | "replyTo" | "runId" | "source"> & {
|
|
3
|
-
offset: number;
|
|
4
|
-
totalLength: number;
|
|
5
|
-
nextOffset: number | null;
|
|
6
|
-
};
|
|
7
|
-
export declare function teamMessagesMarkdown(page: {
|
|
8
|
-
teamId: string;
|
|
9
|
-
messages: MessagePage[];
|
|
10
|
-
lastSeq: number;
|
|
11
|
-
nextAfterSeq: number | null;
|
|
12
|
-
}): string;
|
|
13
|
-
export declare function teamBrief(link: TeamLink): string;
|
|
14
|
-
export declare function createTeamContext(link: TeamLink, seen: ReadonlySet<number>, throughSeq?: number): {
|
|
15
|
-
content: string;
|
|
16
|
-
seqs: number[];
|
|
17
|
-
} | undefined;
|
|
18
|
-
export {};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { markdownBlock } from "../common/markdown.js";
|
|
4
|
-
import { resourceRoot } from "../common/paths.js";
|
|
5
|
-
function messageMarkdown(message) {
|
|
6
|
-
return [
|
|
7
|
-
"## 消息 " + message.seq, "",
|
|
8
|
-
"- 作者:" + message.author.name + "(" + message.author.kind + ")",
|
|
9
|
-
...(message.author.agentId ? ["- `agentId`: `" + message.author.agentId + "`"] : []),
|
|
10
|
-
...(message.replyTo === undefined ? [] : ["- `replyTo`: `" + message.replyTo + "`"]),
|
|
11
|
-
...(message.runId ? ["- `runId`: `" + message.runId + "`"] : []),
|
|
12
|
-
...(message.source ? ["- `requestId`: `" + message.source.requestId + "`", "- `cycleId`: `" + message.source.cycleId + "`"] : []),
|
|
13
|
-
"- `offset`: `" + message.offset + "`;`totalLength`: `" + message.totalLength + "`;`nextOffset`: `" + message.nextOffset + "`",
|
|
14
|
-
"", markdownBlock(message.text),
|
|
15
|
-
...(message.nextOffset === null ? [] : ["", "正文未完。用 pbot_team_message read 续读:`seq: " + message.seq + ", offset: " + message.nextOffset + "`。"]),
|
|
16
|
-
].join("\n");
|
|
17
|
-
}
|
|
18
|
-
export function teamMessagesMarkdown(page) {
|
|
19
|
-
return ["# 团队公共消息", "", "- `teamId`: `" + page.teamId + "`", "- `lastSeq`: `" + page.lastSeq + "`",
|
|
20
|
-
"- `nextAfterSeq`: `" + page.nextAfterSeq + "`", "",
|
|
21
|
-
"nextOffset 非空时先续读该条正文,再读取后续消息。", "",
|
|
22
|
-
page.messages.map(messageMarkdown).join("\n\n")].join("\n");
|
|
23
|
-
}
|
|
24
|
-
export function teamBrief(link) {
|
|
25
|
-
return ["# 团队协作", "", "- 团队:" + link.team.name, "- `teamId`: `" + link.team.teamId + "`",
|
|
26
|
-
"- 当前成员 `agentId`: `" + link.request.agentId + "`", "- `runId`: `" + link.run.runId + "`",
|
|
27
|
-
"- 轮次:" + link.request.round + " / " + link.run.rounds, "", "## 共同目标", "", link.team.brief,
|
|
28
|
-
"", "## 成员职责", "", ...link.team.members.flatMap(member => ["### " + member.agentId, "", member.role, ""]),
|
|
29
|
-
readFileSync(join(resourceRoot, "prompts/team-member.md"), "utf8").trim()].join("\n");
|
|
30
|
-
}
|
|
31
|
-
export function createTeamContext(link, seen, throughSeq = link.team.messages.length) {
|
|
32
|
-
const pending = link.team.messages.filter(m => m.seq <= throughSeq && !seen.has(m.seq));
|
|
33
|
-
if (!pending.length)
|
|
34
|
-
return;
|
|
35
|
-
// Count rendered Markdown, including fences and read positions; reserve room for the document header.
|
|
36
|
-
let budget = 15000;
|
|
37
|
-
const messages = [];
|
|
38
|
-
for (const m of pending) {
|
|
39
|
-
const part = (length) => ({ ...m, text: m.text.slice(0, length),
|
|
40
|
-
offset: 0, totalLength: m.text.length, nextOffset: length < m.text.length ? length : null });
|
|
41
|
-
let low = 0, high = Math.min(m.text.length, budget);
|
|
42
|
-
while (low < high) {
|
|
43
|
-
const mid = Math.ceil((low + high) / 2);
|
|
44
|
-
if (messageMarkdown(part(mid)).length + 2 <= budget)
|
|
45
|
-
low = mid;
|
|
46
|
-
else
|
|
47
|
-
high = mid - 1;
|
|
48
|
-
}
|
|
49
|
-
const value = part(low), size = messageMarkdown(value).length + 2;
|
|
50
|
-
if (size > budget || (!low && m.text.length))
|
|
51
|
-
break;
|
|
52
|
-
messages.push(value);
|
|
53
|
-
budget -= size;
|
|
54
|
-
}
|
|
55
|
-
const seqs = messages.map(m => m.seq);
|
|
56
|
-
return { content: ["# 团队公共上下文", "", "- `teamId`: `" + link.team.teamId + "`", "- `throughSeq`: `" + throughSeq + "`",
|
|
57
|
-
"- `remainingFromSeq`: `" + (pending[messages.length]?.seq ?? null) + "`", "",
|
|
58
|
-
"未包含或被截断的正文用 pbot_team_message read 读取。remainingFromSeq 非空时,用 afterSeq: remainingFromSeq - 1 读取未包含的消息。", "",
|
|
59
|
-
messages.map(messageMarkdown).join("\n\n")].join("\n"),
|
|
60
|
-
seqs };
|
|
61
|
-
}
|
package/lib/model/team.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import type { AgentOwner, AgentView } from "./agent.js";
|
|
2
|
-
export interface TeamRequest {
|
|
3
|
-
requestId: string;
|
|
4
|
-
agentId: string;
|
|
5
|
-
generation: string;
|
|
6
|
-
round: number;
|
|
7
|
-
throughSeq: number;
|
|
8
|
-
}
|
|
9
|
-
export interface TeamRun {
|
|
10
|
-
runId: string;
|
|
11
|
-
instruction: string;
|
|
12
|
-
mode: "roundRobin" | "parallel";
|
|
13
|
-
rounds: number;
|
|
14
|
-
maxConcurrent: number;
|
|
15
|
-
deadlineAt: number;
|
|
16
|
-
generations: Record<string, string>;
|
|
17
|
-
state: "running" | "paused" | "finished";
|
|
18
|
-
reason?: string;
|
|
19
|
-
issued: TeamRequest[];
|
|
20
|
-
}
|
|
21
|
-
export interface TeamMessage {
|
|
22
|
-
seq: number;
|
|
23
|
-
operationId: string;
|
|
24
|
-
author: {
|
|
25
|
-
kind: "user" | "coordinator" | "member";
|
|
26
|
-
agentId?: string;
|
|
27
|
-
name: string;
|
|
28
|
-
};
|
|
29
|
-
text: string;
|
|
30
|
-
replyTo?: number;
|
|
31
|
-
runId?: string;
|
|
32
|
-
source?: {
|
|
33
|
-
requestId: string;
|
|
34
|
-
cycleId: string;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
export interface TeamRecord {
|
|
38
|
-
teamId: string;
|
|
39
|
-
release: string;
|
|
40
|
-
workspace: string;
|
|
41
|
-
parentSessionId: string;
|
|
42
|
-
parentLeaf: string | null;
|
|
43
|
-
name: string;
|
|
44
|
-
brief: string;
|
|
45
|
-
closed: boolean;
|
|
46
|
-
members: {
|
|
47
|
-
agentId: string;
|
|
48
|
-
role: string;
|
|
49
|
-
}[];
|
|
50
|
-
runs: TeamRun[];
|
|
51
|
-
messages: TeamMessage[];
|
|
52
|
-
}
|
|
53
|
-
export interface TeamReady {
|
|
54
|
-
generation: string;
|
|
55
|
-
ready: boolean;
|
|
56
|
-
}
|
|
57
|
-
export type TeamAgent = AgentView & {
|
|
58
|
-
alive: boolean;
|
|
59
|
-
};
|
|
60
|
-
export type TeamActor = {
|
|
61
|
-
kind: "user" | "coordinator";
|
|
62
|
-
owner: AgentOwner;
|
|
63
|
-
} | {
|
|
64
|
-
kind: "member";
|
|
65
|
-
agentId: string;
|
|
66
|
-
generation: string;
|
|
67
|
-
requestId?: string;
|
|
68
|
-
};
|
|
69
|
-
export interface TeamInput extends TeamRequest {
|
|
70
|
-
teamId: string;
|
|
71
|
-
runId: string;
|
|
72
|
-
message: string;
|
|
73
|
-
}
|
|
74
|
-
export interface TeamLink {
|
|
75
|
-
team: TeamRecord;
|
|
76
|
-
run: TeamRun;
|
|
77
|
-
request: TeamRequest;
|
|
78
|
-
}
|
|
79
|
-
export interface TeamRunOptions {
|
|
80
|
-
instruction: string;
|
|
81
|
-
mode: TeamRun["mode"];
|
|
82
|
-
rounds?: number;
|
|
83
|
-
maxConcurrent?: number;
|
|
84
|
-
timeoutSeconds?: number;
|
|
85
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { AgentCompletion } from "../../model/agent.js";
|
|
2
|
-
import type { TeamLink } from "../../model/team.js";
|
|
3
|
-
import type { TeamService } from "./team-service.js";
|
|
4
|
-
export declare function teamNotice(values: ReturnType<TeamService["notifications"]>, known: ReadonlySet<string>): {
|
|
5
|
-
kind: "teams";
|
|
6
|
-
keys: string[];
|
|
7
|
-
content: string;
|
|
8
|
-
} | undefined;
|
|
9
|
-
export declare function agentNotice(values: AgentCompletion[], links: ReadonlyMap<string, TeamLink>, known: ReadonlySet<string>): {
|
|
10
|
-
kind: "agents";
|
|
11
|
-
keys: string[];
|
|
12
|
-
content: string;
|
|
13
|
-
} | undefined;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { json } from "../../common/json.js";
|
|
2
|
-
import { markdownFields } from "../../common/markdown.js";
|
|
3
|
-
export function teamNotice(values, known) {
|
|
4
|
-
const notes = values.filter(value => !known.has(value.key)).slice(0, 8);
|
|
5
|
-
if (!notes.length)
|
|
6
|
-
return;
|
|
7
|
-
return { kind: "teams", keys: notes.map(value => value.key), content: ["# 团队批次状态", "",
|
|
8
|
-
"团队批次状态已变化,用 pbot_team status 与 pbot_team_message read 查看状态和结果。暂停时可能仍有在途工作,重跑前先查看原请求结果。", "",
|
|
9
|
-
notes.map(value => ["## " + value.name, "", "- `teamId`: `" + value.teamId + "`", "- `runId`: `" + value.runId + "`",
|
|
10
|
-
"- 状态:" + value.state, "- 在途工作:" + value.activeCount, ...(value.reason ? ["", "### 原因", "", value.reason] : [])].join("\n")).join("\n\n")].join("\n") };
|
|
11
|
-
}
|
|
12
|
-
export function agentNotice(values, links, known) {
|
|
13
|
-
const batch = values.filter(value => !value.cycle.requestIds.some(id => links.has(id)) &&
|
|
14
|
-
!(value.cycle.cycleId === value.cycle.generation && [...links.values()].some(link => link.request.agentId === value.agentId && link.request.generation === value.cycle.generation)) &&
|
|
15
|
-
!known.has(value.agentId + ":" + value.cycle.cycleId)).slice(0, 8);
|
|
16
|
-
if (!batch.length)
|
|
17
|
-
return;
|
|
18
|
-
return { kind: "agents", keys: batch.map(value => value.agentId + ":" + value.cycle.cycleId),
|
|
19
|
-
content: "# 子会话工作结果\n\n子会话工作已结束。完整报告用 pbot_agent read 读取,指定对应 agentId 和 cycle.cycleId;nextOffset 非空时沿用该 cycleId 续读。\n\n" +
|
|
20
|
-
(batch.some(value => value.cycle.source !== "parent") ? "部分结果包含人工子会话输入,来源见 cycle.source。\n\n" : "") +
|
|
21
|
-
batch.map(value => "## " + value.name + "\n\n" + markdownFields(json({ agentId: value.agentId,
|
|
22
|
-
cycle: { cycleId: value.cycle.cycleId, state: value.cycle.state, source: value.cycle.source, requestIds: value.cycle.requestIds,
|
|
23
|
-
...(value.cycle.error === undefined ? {} : { error: value.cycle.error }) },
|
|
24
|
-
report: value.report.slice(0, 2000), truncated: value.report.length > 2000 }), 3)).join("\n\n") };
|
|
25
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { AcpBackend } from "../../model/acp.js";
|
|
2
|
-
import type { AgentOptions, NativeAgentHost } from "../../model/agent.js";
|
|
3
|
-
/** Keep only options the effective target can use; declared-but-inapplicable fields are inert. */
|
|
4
|
-
export declare function applicableStartOptions(kind: NativeAgentHost, backend: AcpBackend | undefined, options: AgentOptions): AgentOptions;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const piOnly = ["noExtensions", "noPromptTemplates", "noContextFiles"];
|
|
2
|
-
/** Keep only options the effective target can use; declared-but-inapplicable fields are inert. */
|
|
3
|
-
export function applicableStartOptions(kind, backend, options) {
|
|
4
|
-
const result = { ...options };
|
|
5
|
-
if (backend) {
|
|
6
|
-
if (backend !== "pi") {
|
|
7
|
-
for (const key of piOnly)
|
|
8
|
-
delete result[key];
|
|
9
|
-
delete result.noSkills;
|
|
10
|
-
delete result.tools;
|
|
11
|
-
}
|
|
12
|
-
if (backend === "claude")
|
|
13
|
-
delete result.provider;
|
|
14
|
-
}
|
|
15
|
-
else if (kind !== "pi") {
|
|
16
|
-
for (const key of piOnly)
|
|
17
|
-
delete result[key];
|
|
18
|
-
}
|
|
19
|
-
return result;
|
|
20
|
-
}
|