personal-bot 0.3.6 → 0.4.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.
Files changed (143) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +5 -8
  4. package/README.zh-CN.md +5 -8
  5. package/bin/pbot-pi-acp.mjs +1 -1
  6. package/docs/README.md +1 -1
  7. package/docs/architecture/design.md +2 -2
  8. package/docs/architecture/extensibility.md +1 -1
  9. package/docs/architecture/model-context.md +1 -2
  10. package/docs/guides/capabilities.md +4 -8
  11. package/docs/guides/cross-harness-workers.md +4 -4
  12. package/docs/guides/history.md +1 -3
  13. package/docs/guides/workspace-configuration.md +4 -4
  14. package/docs/hosts/claude-code.md +2 -2
  15. package/docs/hosts/codex-qoder.md +1 -1
  16. package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +1 -1
  17. package/lib/antigravity-plugin/lib/extension/acp/member.d.ts +1 -1
  18. package/lib/antigravity-plugin/lib/extension/acp/member.js +11 -10
  19. package/lib/antigravity-plugin/lib/extension/acp-worker.js +348 -203
  20. package/lib/antigravity-plugin/lib/extension/cli.js +574 -549
  21. package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.js +1 -1
  22. package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +3 -4
  23. package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +0 -11
  24. package/lib/antigravity-plugin/lib/extension/mcp.js +462 -326
  25. package/lib/antigravity-plugin/lib/integrations/agent-resources.js +2 -2
  26. package/lib/antigravity-plugin/lib/model/acp.d.ts +29 -35
  27. package/lib/antigravity-plugin/lib/model/agent.d.ts +33 -17
  28. package/lib/antigravity-plugin/lib/model/agent.js +0 -1
  29. package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +5 -8
  30. package/lib/antigravity-plugin/lib/storage/acp-files.js +34 -40
  31. package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +19 -10
  32. package/lib/antigravity-plugin/lib/storage/agent-files.js +147 -43
  33. package/lib/antigravity-plugin/package.json +1 -1
  34. package/lib/antigravity-plugin/plugin.json +1 -1
  35. package/lib/antigravity-plugin/resources/agents/coordinator.md +3 -7
  36. package/lib/antigravity-plugin/resources/agents/general-purpose.md +3 -3
  37. package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -2
  38. package/lib/antigravity-plugin/resources/prompts/workspace.md +12 -16
  39. package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +7 -6
  40. package/lib/antigravity-plugin/resources/templates/workspace-agents.md +0 -4
  41. package/lib/antigravity-plugin/skills/pbot/SKILL.md +14 -6
  42. package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +7 -6
  43. package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +1 -1
  44. package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
  45. package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
  46. package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +2 -2
  47. package/lib/extension/acp/member.d.ts +1 -1
  48. package/lib/extension/acp/member.js +11 -10
  49. package/lib/extension/acp/worker.js +34 -33
  50. package/lib/extension/acp-worker.js +348 -203
  51. package/lib/extension/cli.js +574 -549
  52. package/lib/extension/hosts/dsh/acp-member.js +1 -1
  53. package/lib/extension/hosts/dsh/command.js +1 -1
  54. package/lib/extension/hosts/dsh/workspace.js +1 -3
  55. package/lib/extension/hosts/pi/acp-member.js +3 -4
  56. package/lib/extension/hosts/plugin-runtime.js +0 -11
  57. package/lib/extension/mcp/tool-contract.d.ts +8 -50
  58. package/lib/extension/mcp/tool-contract.js +48 -62
  59. package/lib/extension/mcp/workers.d.ts +13 -27
  60. package/lib/extension/mcp/workers.js +60 -25
  61. package/lib/extension/mcp.js +462 -326
  62. package/lib/integrations/acp/agents.d.ts +2 -3
  63. package/lib/integrations/acp/agents.js +22 -22
  64. package/lib/integrations/acp/harnesses/claude.js +1 -1
  65. package/lib/integrations/agent-resources.js +2 -2
  66. package/lib/model/acp.d.ts +29 -35
  67. package/lib/model/agent.d.ts +33 -17
  68. package/lib/model/agent.js +0 -1
  69. package/lib/qoder-plugin/.mcp.json +2 -2
  70. package/lib/qoder-plugin/.qoder-plugin/plugin.json +1 -1
  71. package/lib/qoder-plugin/hooks/hooks.json +3 -3
  72. package/lib/qoder-plugin/skills/pbot/SKILL.md +2 -2
  73. package/lib/services/agents/acp-run.d.ts +6 -4
  74. package/lib/services/agents/acp-run.js +62 -43
  75. package/lib/services/agents/agent-run.d.ts +10 -6
  76. package/lib/services/agents/agent-run.js +142 -65
  77. package/lib/services/agents/agent-service.d.ts +3 -21
  78. package/lib/services/agents/agent-service.js +180 -126
  79. package/lib/storage/acp-files.d.ts +5 -8
  80. package/lib/storage/acp-files.js +34 -40
  81. package/lib/storage/agent-files.d.ts +19 -10
  82. package/lib/storage/agent-files.js +147 -43
  83. package/lib/tools/history/contract.js +12 -12
  84. package/package.json +1 -1
  85. package/resources/agents/coordinator.md +3 -7
  86. package/resources/agents/general-purpose.md +3 -3
  87. package/resources/antigravity/skills/pbot/SKILL.md +14 -6
  88. package/resources/claude/skills/pbot/SKILL.md +14 -6
  89. package/resources/plugin/skills/pbot/SKILL.md +2 -2
  90. package/resources/prompts/history-coordinator.md +1 -2
  91. package/resources/prompts/plugin-coordinator.md +1 -2
  92. package/resources/prompts/workspace.md +12 -16
  93. package/resources/skills/provider-connections/SKILL.md +7 -6
  94. package/resources/templates/workspace-agents.md +0 -4
  95. package/src/extension/acp/member.ts +14 -11
  96. package/src/extension/acp/worker.ts +31 -28
  97. package/src/extension/cli/commands/upgrade.ts +8 -36
  98. package/src/extension/cli/commands/workspace.ts +3 -8
  99. package/src/extension/cli/index.ts +1 -2
  100. package/src/extension/hosts/dsh/acp-member.ts +1 -1
  101. package/src/extension/hosts/dsh/command.ts +1 -1
  102. package/src/extension/hosts/dsh/workspace.ts +1 -3
  103. package/src/extension/hosts/pi/acp-member.ts +3 -4
  104. package/src/extension/hosts/pi/command.ts +1 -1
  105. package/src/extension/hosts/pi/lifecycle.ts +0 -2
  106. package/src/extension/hosts/plugin-runtime.ts +0 -10
  107. package/src/extension/mcp/tool-contract.ts +48 -62
  108. package/src/extension/mcp/workers.ts +66 -27
  109. package/src/integrations/acp/agents.ts +28 -27
  110. package/src/integrations/acp/harnesses/claude.ts +1 -1
  111. package/src/integrations/agent-resources.ts +2 -2
  112. package/src/integrations/hosts/dsh/session.ts +2 -2
  113. package/src/integrations/installation/cli-update.ts +2 -2
  114. package/src/integrations/installation/installers/claude.ts +4 -4
  115. package/src/integrations/installation/installers/qoder.ts +5 -5
  116. package/src/integrations/installation/upgraders/antigravity.ts +57 -15
  117. package/src/integrations/installation/upgraders/claude.ts +1 -4
  118. package/src/integrations/installation/upgraders/codex.ts +85 -15
  119. package/src/integrations/installation/upgraders/dsh.ts +46 -24
  120. package/src/integrations/installation/upgraders/pi.ts +18 -11
  121. package/src/integrations/installation/upgraders/qoder.ts +95 -20
  122. package/src/model/acp.ts +27 -29
  123. package/src/model/agent.ts +80 -16
  124. package/src/model/installation.ts +0 -2
  125. package/src/pbot.ts +2 -2
  126. package/src/services/agents/acp-run.ts +81 -49
  127. package/src/services/agents/agent-run.ts +154 -56
  128. package/src/services/agents/agent-service.ts +204 -133
  129. package/src/services/installation/upgrade-service.ts +1 -5
  130. package/src/storage/acp-files.ts +50 -45
  131. package/src/storage/agent-files.ts +159 -46
  132. package/src/tools/history/contract.ts +12 -12
  133. package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +0 -15
  134. package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +0 -126
  135. package/lib/antigravity-plugin/resources/references/compute-finance.md +0 -22
  136. package/lib/antigravity-plugin/resources/references/compute.md +0 -16
  137. package/lib/antigravity-plugin/resources/references/task-conductor.md +0 -25
  138. package/lib/services/workspace/plugin-releases.d.ts +0 -15
  139. package/lib/services/workspace/plugin-releases.js +0 -126
  140. package/resources/references/compute-finance.md +0 -22
  141. package/resources/references/compute.md +0 -16
  142. package/resources/references/task-conductor.md +0 -25
  143. package/src/services/workspace/plugin-releases.ts +0 -121
@@ -42,24 +42,31 @@ async function readLocalPiVersion(workspace: string): Promise<string | undefined
42
42
  export const piUpgrader: HostUpgrader = {
43
43
  host: "pi",
44
44
  async upgrade(context: HostUpgradeContext): Promise<HostUpgradeResult> {
45
- const current = await readLocalPiVersion(context.workspace) ?? context.currentVersion;
46
- if (current && valid(current) && gte(current, context.targetVersion)) {
45
+ if (await hasCustomOnlySource(context.workspace)) {
47
46
  return {
48
47
  host: this.host,
49
- state: "up-to-date",
50
- previousVersion: current,
51
- version: current,
48
+ state: "skipped",
52
49
  scope: "local",
53
- detail: "已是最新版本。",
50
+ detail: "工作区 Pi 配置中的 personal-bot 使用非 npm 自定义来源,已保留当前配置。",
54
51
  };
55
52
  }
56
- if (await hasCustomOnlySource(context.workspace)) {
53
+ const current = await readLocalPiVersion(context.workspace);
54
+ if (!current) {
57
55
  return {
58
56
  host: this.host,
59
57
  state: "skipped",
60
- ...(current ? { previousVersion: current } : {}),
61
58
  scope: "local",
62
- detail: "工作区 Pi 配置中的 personal-bot 使用非 npm 自定义来源,已保留当前配置。",
59
+ detail: "当前工作区未通过 Pi 安装 personal-bot,已跳过。",
60
+ };
61
+ }
62
+ if (gte(current, context.targetVersion)) {
63
+ return {
64
+ host: this.host,
65
+ state: "up-to-date",
66
+ previousVersion: current,
67
+ version: current,
68
+ scope: "local",
69
+ detail: "已是最新版本。",
63
70
  };
64
71
  }
65
72
  const pi = context.env.PBOT_PI_COMMAND || await context.findExecutable("pi");
@@ -67,7 +74,7 @@ export const piUpgrader: HostUpgrader = {
67
74
  return {
68
75
  host: this.host,
69
76
  state: "skipped",
70
- ...(current ? { previousVersion: current } : {}),
77
+ previousVersion: current,
71
78
  scope: "local",
72
79
  detail: "未找到 Pi CLI(pi),已跳过。",
73
80
  };
@@ -77,7 +84,7 @@ export const piUpgrader: HostUpgrader = {
77
84
  return {
78
85
  host: this.host,
79
86
  state: "updated",
80
- ...(current ? { previousVersion: current } : {}),
87
+ previousVersion: current,
81
88
  version: installed,
82
89
  scope: "local",
83
90
  detail: `已通过 pi install --local 更新工作区 personal-bot 到 ${installed}。`,
@@ -1,9 +1,17 @@
1
- import { readFile } from "node:fs/promises";
1
+ import { readFile, realpath } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { gte, lt, valid } from "semver";
4
4
  import { object } from "../../../common/json.js";
5
5
  import type { HostUpgradeContext, HostUpgradeResult, HostUpgrader } from "../../../model/installation.js";
6
6
 
7
+ interface QoderPluginEntry {
8
+ id: string;
9
+ name?: string;
10
+ version?: string;
11
+ scope?: string;
12
+ projectPath?: string;
13
+ }
14
+
7
15
  async function readManifestVersion(path: string): Promise<string | undefined> {
8
16
  try {
9
17
  const data: unknown = JSON.parse(await readFile(path, "utf8"));
@@ -14,16 +22,90 @@ async function readManifestVersion(path: string): Promise<string | undefined> {
14
22
  }
15
23
  }
16
24
 
25
+ function parsePluginList(raw: string): QoderPluginEntry[] {
26
+ const parsed: unknown = JSON.parse(raw);
27
+ const items = Array.isArray(parsed)
28
+ ? parsed
29
+ : object(parsed) && Array.isArray(parsed.plugins)
30
+ ? parsed.plugins
31
+ : [];
32
+ const entries: QoderPluginEntry[] = [];
33
+ for (const item of items) {
34
+ if (!object(item)) continue;
35
+ const id = typeof item.id === "string" ? item.id : typeof item.name === "string" ? item.name : undefined;
36
+ if (!id) continue;
37
+ entries.push({
38
+ id,
39
+ ...(typeof item.name === "string" ? { name: item.name } : {}),
40
+ ...(typeof item.version === "string" ? { version: item.version } : {}),
41
+ ...(typeof item.scope === "string" ? { scope: item.scope } : {}),
42
+ ...(typeof item.projectPath === "string" ? { projectPath: item.projectPath } : {}),
43
+ });
44
+ }
45
+ return entries;
46
+ }
47
+
48
+ async function resolvePathSafe(value: string): Promise<string> {
49
+ try { return await realpath(value); } catch { return value; }
50
+ }
51
+
52
+ async function selectMatchingEntry(entries: QoderPluginEntry[], workspace: string): Promise<QoderPluginEntry | undefined> {
53
+ const canonicalWorkspace = await resolvePathSafe(workspace);
54
+ const candidates = entries.filter(entry =>
55
+ entry.name === "personal-bot" || entry.id === "personal-bot" || entry.id.startsWith("personal-bot@"));
56
+ if (!candidates.length) return undefined;
57
+ const scopedMatches: QoderPluginEntry[] = [];
58
+ for (const entry of candidates) {
59
+ if (!entry.projectPath) {
60
+ scopedMatches.push(entry);
61
+ continue;
62
+ }
63
+ if (await resolvePathSafe(entry.projectPath) === canonicalWorkspace) scopedMatches.push(entry);
64
+ }
65
+ const priority = new Map<string, number>([["local", 0], ["project", 1], ["user", 2]]);
66
+ scopedMatches.sort((a, b) => (priority.get(a.scope ?? "") ?? 9) - (priority.get(b.scope ?? "") ?? 9));
67
+ return scopedMatches[0];
68
+ }
69
+
17
70
  export const qoderUpgrader: HostUpgrader = {
18
71
  host: "qoder",
19
72
  async upgrade(context: HostUpgradeContext): Promise<HostUpgradeResult> {
20
- if (context.currentVersion && valid(context.currentVersion) && gte(context.currentVersion, context.targetVersion)) {
73
+ const qodercli = context.env.PBOT_QODER_COMMAND || await context.findExecutable("qodercli");
74
+ if (!qodercli) {
75
+ return {
76
+ host: this.host,
77
+ state: "skipped",
78
+ detail: "未找到 Qoder CLI(qodercli),已跳过。",
79
+ };
80
+ }
81
+ let entries: QoderPluginEntry[];
82
+ try {
83
+ const raw = await context.run(qodercli, ["plugin", "list", "--json"], context.workspace);
84
+ entries = parsePluginList(raw);
85
+ } catch (error) {
86
+ return {
87
+ host: this.host,
88
+ state: "failed",
89
+ detail: `查询 Qoder CLI 插件列表失败:${error instanceof Error ? error.message : String(error)}`,
90
+ };
91
+ }
92
+ const entry = await selectMatchingEntry(entries, context.workspace);
93
+ if (!entry) {
94
+ return {
95
+ host: this.host,
96
+ state: "skipped",
97
+ detail: "未在 Qoder CLI 插件列表中找到 personal-bot,已跳过。",
98
+ };
99
+ }
100
+ const installedVersion = entry.version;
101
+ const scope = entry.scope ?? "user";
102
+ if (installedVersion && valid(installedVersion) && gte(installedVersion, context.targetVersion)) {
21
103
  return {
22
104
  host: this.host,
23
105
  state: "up-to-date",
24
- previousVersion: context.currentVersion,
25
- version: context.currentVersion,
26
- scope: "user",
106
+ previousVersion: installedVersion,
107
+ version: installedVersion,
108
+ scope,
27
109
  detail: "已是最新版本。",
28
110
  };
29
111
  }
@@ -33,7 +115,8 @@ export const qoderUpgrader: HostUpgrader = {
33
115
  return {
34
116
  host: this.host,
35
117
  state: "skipped",
36
- ...(context.currentVersion ? { previousVersion: context.currentVersion } : {}),
118
+ ...(installedVersion ? { previousVersion: installedVersion } : {}),
119
+ scope,
37
120
  detail: `缺少 Qoder CLI 插件构建产物:${pluginDir}`,
38
121
  };
39
122
  }
@@ -41,27 +124,19 @@ export const qoderUpgrader: HostUpgrader = {
41
124
  return {
42
125
  host: this.host,
43
126
  state: "skipped",
44
- ...(context.currentVersion ? { previousVersion: context.currentVersion } : {}),
127
+ ...(installedVersion ? { previousVersion: installedVersion } : {}),
128
+ scope,
45
129
  detail: `当前本地包产物版本为 ${bundledVersion},低于目标版本 ${context.targetVersion};请先更新全局 personal-bot 包。`,
46
130
  };
47
131
  }
48
- const qodercli = context.env.PBOT_QODER_COMMAND || await context.findExecutable("qodercli");
49
- if (!qodercli) {
50
- return {
51
- host: this.host,
52
- state: "skipped",
53
- ...(context.currentVersion ? { previousVersion: context.currentVersion } : {}),
54
- detail: "未找到 Qoder CLI(qodercli),已跳过。",
55
- };
56
- }
57
- await context.run(qodercli, ["plugin", "install", pluginDir], context.workspace);
132
+ await context.run(qodercli, ["plugin", "install", pluginDir, "--scope", scope], context.workspace);
58
133
  return {
59
134
  host: this.host,
60
135
  state: "updated",
61
- ...(context.currentVersion ? { previousVersion: context.currentVersion } : {}),
136
+ ...(installedVersion ? { previousVersion: installedVersion } : {}),
62
137
  version: bundledVersion,
63
- scope: "user",
64
- detail: `已通过 qodercli plugin install 更新到 ${bundledVersion}。`,
138
+ scope,
139
+ detail: `已按原有作用域(${scope})通过 qodercli plugin install 更新到 ${bundledVersion}。`,
65
140
  nextStep: "重启 Qoder CLI 会话使新版本生效。",
66
141
  };
67
142
  },
package/src/model/acp.ts CHANGED
@@ -46,8 +46,6 @@ export interface AcpModelsResult {
46
46
  currentThinking?: string;
47
47
  selection: AcpModelSelection;
48
48
  }
49
- export interface AcpModelState extends AcpModelSelection { generation: string }
50
- export interface AcpProcess { generation: string; pid: number; startedAt: number }
51
49
  export interface AcpInput { generation: string; requestId: string }
52
50
  export const acpAnswerStates = ["completed", "failed", "cancelled"] as const;
53
51
  export interface AcpAnswer extends AcpInput {
@@ -55,14 +53,6 @@ export interface AcpAnswer extends AcpInput {
55
53
  state: typeof acpAnswerStates[number];
56
54
  error?: string;
57
55
  }
58
- export interface AcpReport { generation: string; cycleId: string; text: string }
59
- export interface AcpPermission {
60
- generation: string;
61
- requestId: string;
62
- description: string;
63
- options: { optionId: string; name: string; kind: string }[];
64
- }
65
- export interface AcpPermissionReply { generation: string; requestId: string; optionId: string | null }
66
56
  export const acpElicitationActions = ["accept", "decline", "cancel"] as const;
67
57
  export type AcpElicitationAction = typeof acpElicitationActions[number];
68
58
  export type AcpElicitationValue = string | number | boolean | string[];
@@ -72,29 +62,37 @@ export function isAcpElicitationValue(value: unknown): value is AcpElicitationVa
72
62
  }
73
63
 
74
64
  export type AcpElicitationContent = Record<string, AcpElicitationValue>;
75
- export interface AcpElicitation {
76
- generation: string;
77
- requestId: string;
78
- mode: "form" | "url";
79
- message: string;
80
- schema?: Record<string, unknown>;
81
- url?: string;
82
- }
83
- export interface AcpElicitationReply {
84
- generation: string;
85
- requestId: string;
86
- action: AcpElicitationAction;
87
- content?: AcpElicitationContent;
88
- }
65
+ export type AcpInteraction =
66
+ | {
67
+ generation: string;
68
+ requestId: string;
69
+ kind: "permission";
70
+ description: string;
71
+ options: { optionId: string; name: string; kind: string }[];
72
+ }
73
+ | {
74
+ generation: string;
75
+ requestId: string;
76
+ kind: "form";
77
+ message: string;
78
+ schema: Record<string, unknown>;
79
+ }
80
+ | {
81
+ generation: string;
82
+ requestId: string;
83
+ kind: "url";
84
+ message: string;
85
+ url: string;
86
+ };
87
+ export type AcpInteractionReply =
88
+ | { generation: string; requestId: string; kind: "permission"; optionId: string | null }
89
+ | { generation: string; requestId: string; kind: "form"; action: AcpElicitationAction; content?: AcpElicitationContent }
90
+ | { generation: string; requestId: string; kind: "url"; action: AcpElicitationAction };
89
91
 
90
92
  export interface AcpStartOptions {
91
- name?: string;
92
- message?: string;
93
- files?: string[];
94
93
  provider?: string;
95
94
  model?: string;
96
95
  thinking?: string;
97
- cwd?: string;
98
96
  tools?: string[];
99
97
  noExtensions?: boolean;
100
98
  noSkills?: boolean;
@@ -104,7 +102,7 @@ export interface AcpStartOptions {
104
102
 
105
103
  export interface AcpLaunchContext {
106
104
  readonly reference: AcpSessionReference;
107
- readonly cwd: string;
105
+ readonly workspace: string;
108
106
  readonly directory: string;
109
107
  readonly packageRoot: string;
110
108
  readonly options: AcpStartOptions;
@@ -1,36 +1,102 @@
1
- import type { AcpBackend, AcpElicitationAction, AcpElicitationContent, AcpModelSelection, AcpSessionReference, AcpStartOptions } from "./acp.js";
1
+ import type {
2
+ AcpBackend,
3
+ AcpCommand,
4
+ AcpElicitationAction,
5
+ AcpElicitationContent,
6
+ AcpModelSelection,
7
+ AcpPermissionPolicy,
8
+ AcpSessionReference,
9
+ AcpStartOptions,
10
+ } from "./acp.js";
2
11
 
3
12
  export type AgentOptions = AcpStartOptions;
4
- export interface AgentStartOptions extends AgentOptions { backend: AcpBackend }
13
+ export interface AgentStartOptions extends AgentOptions {
14
+ backend: AcpBackend;
15
+ message?: string;
16
+ files?: string[];
17
+ }
5
18
  export interface AgentOwner { sessionId: string; leaf: string | null; branch: string[] }
6
19
  export interface AgentDescriptor {
7
- agentId: string; release: string; workspace: string; cwd: string; parentSessionId: string;
8
- parentLeaf: string | null; createdAt: number; options: AgentOptions;
20
+ agentId: string;
21
+ release: string;
22
+ workspace: string;
23
+ parentSessionId: string;
24
+ options: AgentOptions;
9
25
  }
10
26
  export type AgentSessionReference = AcpSessionReference;
11
- export interface AgentLaunch { generation: string; name: string; sequence: number; stop: boolean; startedAt: number }
27
+ export interface AgentAcpConfig extends AcpCommand {
28
+ backend: AcpBackend;
29
+ permission?: AcpPermissionPolicy;
30
+ }
31
+ export interface AgentWorkerRecord {
32
+ agentId: string;
33
+ release: string;
34
+ workspace: string;
35
+ parentSessionId: string;
36
+ generation: string;
37
+ sequence: number;
38
+ stop: boolean;
39
+ startedAt: number;
40
+ pid?: number;
41
+ acp: AgentAcpConfig;
42
+ options?: AgentOptions;
43
+ }
12
44
  export const messageDeliveries = ["steer", "followUp"] as const;
13
45
  export const cycleStates = ["running", "completed", "failed", "cancelled", "interrupted"] as const;
14
- export const cycleSources = ["parent", "interactive", "mixed"] as const;
15
46
  export const agentStates = ["starting", "busy", "idle", "stopping", "stopped", "error"] as const;
16
47
 
17
- export interface AgentMessage { requestId: string; generation: string; sequence: number; message: string; delivery: typeof messageDeliveries[number]; files: string[] }
48
+ export interface AgentMessage {
49
+ requestId: string;
50
+ generation: string;
51
+ sequence: number;
52
+ message: string;
53
+ delivery: typeof messageDeliveries[number];
54
+ files: string[];
55
+ }
18
56
  export interface AgentCycle {
19
- cycleId: string; generation: string; startedAt: number; finishedAt?: number;
57
+ cycleId: string;
58
+ generation: string;
59
+ startedAt: number;
60
+ finishedAt?: number;
20
61
  state: typeof cycleStates[number];
21
- leaf: string | null; requestIds: string[]; source: typeof cycleSources[number];
62
+ requestIds: string[];
22
63
  error?: string;
23
64
  }
24
65
  export interface AgentStatus {
25
- generation: string; state: typeof agentStates[number];
26
- activity: string; updatedAt: number; accepted?: string[]; cycle?: AgentCycle; error?: string;
66
+ generation: string;
67
+ state: typeof agentStates[number];
68
+ activity: string;
69
+ updatedAt: number;
70
+ sessionId?: string | null;
71
+ capabilities?: { resume: boolean; load: boolean; close: boolean };
72
+ selection?: AcpModelSelection;
73
+ activeRequestId?: string;
74
+ accepted?: string[];
75
+ cycle?: AgentCycle;
76
+ error?: string;
77
+ }
78
+ export interface AgentOutput {
79
+ cycleId: string;
80
+ generation: string;
81
+ startedAt: number;
82
+ finishedAt: number;
83
+ state: Exclude<AgentCycle["state"], "running">;
84
+ requestIds: string[];
85
+ text: string;
86
+ error?: string;
27
87
  }
28
88
  export interface AgentView extends AgentDescriptor {
29
- name: string; generation: string; state: AgentStatus["state"]; activity: string;
89
+ generation: string;
90
+ state: AgentStatus["state"];
91
+ activity: string;
30
92
  alive: boolean;
31
- backend: AcpBackend; transport: "acp"; selection?: AcpModelSelection;
93
+ backend: AcpBackend;
94
+ transport: "acp";
95
+ selection?: AcpModelSelection;
32
96
  capabilities: { steer: boolean; resume: boolean; transcript: boolean };
33
- cycle?: AgentCycle; error?: string; owned: boolean;
97
+ cycle?: AgentCycle;
98
+ error?: string;
99
+ owned: boolean;
34
100
  pendingRequests?: AgentPendingRequest[];
35
101
  }
36
102
  export type AgentPendingRequest =
@@ -43,7 +109,6 @@ export interface AgentResponseInput {
43
109
  optionId?: string;
44
110
  content?: AcpElicitationContent;
45
111
  }
46
- export interface AgentCompletion { agentId: string; name: string; cycle: AgentCycle; report: string }
47
112
 
48
113
  export interface AgentHost {
49
114
  available(backend: AcpBackend): void;
@@ -53,5 +118,4 @@ export interface AgentHost {
53
118
  validateSession(value: AgentDescriptor, reference: AgentSessionReference): void | Promise<void>;
54
119
  launch(value: AgentDescriptor, directory: string, generation: string, reference: AgentSessionReference, resume: boolean, signal: AbortSignal): void | Promise<void>;
55
120
  release(id: string, generation: string): void | Promise<void>;
56
- report(value: AgentDescriptor, reference: AgentSessionReference, leaf: string): string | Promise<string>;
57
121
  }
@@ -37,9 +37,7 @@ export type HostUpgradeState = "updated" | "up-to-date" | "skipped" | "failed";
37
37
  export interface HostUpgradeContext {
38
38
  workspace: string;
39
39
  targetVersion: string;
40
- currentVersion?: string;
41
40
  packageRoot: string;
42
- bindingPath?: string;
43
41
  env: NodeJS.ProcessEnv;
44
42
  signal: AbortSignal;
45
43
  options: Readonly<Record<string, string | undefined>>;
package/src/pbot.ts CHANGED
@@ -21,7 +21,7 @@ export default function pbot(pi: ExtensionAPI) {
21
21
 
22
22
  const lifecycle = new Lifecycle(
23
23
  (root, sessionId, configuration) => {
24
- const workerDir = defaultWorkerDirectory();
24
+ const workerDir = defaultWorkerDirectory(root);
25
25
  const workers = new McpWorkerRuntime(workerDir, sessionId, "pi");
26
26
  return new WorkspaceInstance(root, sessionId, workers, workspaceFeatures(configuration));
27
27
  },
@@ -34,7 +34,7 @@ export default function pbot(pi: ExtensionAPI) {
34
34
  ...server,
35
35
  exposure: "direct",
36
36
  timeout: 600,
37
- description: "跨代理程序委派(worker_*)",
37
+ description: "跨助手委派(worker_*)",
38
38
  });
39
39
  registeredMcpServers.push(mcpServerName);
40
40
  }