personal-bot 0.2.20 → 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.
Files changed (343) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +2 -5
  3. package/.mcp.json +11 -0
  4. package/CONTEXT.md +17 -73
  5. package/README.md +41 -120
  6. package/README.zh-CN.md +41 -120
  7. package/docs/README.md +31 -23
  8. package/docs/architecture/design.md +74 -0
  9. package/docs/architecture/extensibility.md +78 -0
  10. package/docs/architecture/model-context.md +31 -0
  11. package/docs/architecture/model-instruction-guidelines.md +34 -0
  12. package/docs/architecture/principles.md +33 -0
  13. package/docs/guides/capabilities.md +36 -0
  14. package/docs/guides/cross-harness-workers.md +83 -0
  15. package/docs/guides/history.md +25 -0
  16. package/docs/guides/workspace-configuration.md +102 -0
  17. package/docs/hosts/antigravity.md +52 -0
  18. package/docs/hosts/claude-code.md +47 -0
  19. package/docs/hosts/dsh.md +67 -0
  20. package/docs/hosts/pi.md +49 -0
  21. package/docs/maintainers/release.md +59 -0
  22. package/hooks/hooks.json +0 -3
  23. package/lib/antigravity-plugin/hooks.json +23 -0
  24. package/lib/antigravity-plugin/lib/claude.d.ts +1 -0
  25. package/lib/antigravity-plugin/lib/claude.js +13 -0
  26. package/lib/antigravity-plugin/lib/common/json.d.ts +6 -0
  27. package/lib/antigravity-plugin/lib/common/json.js +16 -0
  28. package/lib/antigravity-plugin/lib/common/paths.d.ts +1 -0
  29. package/lib/antigravity-plugin/lib/common/paths.js +2 -0
  30. package/lib/antigravity-plugin/lib/common/validation.d.ts +3 -0
  31. package/lib/antigravity-plugin/lib/common/validation.js +8 -0
  32. package/lib/antigravity-plugin/lib/common/version.d.ts +3 -0
  33. package/lib/antigravity-plugin/lib/common/version.js +13 -0
  34. package/lib/antigravity-plugin/lib/extension/acp-worker.js +11597 -0
  35. package/lib/antigravity-plugin/lib/extension/mcp.js +2715 -0
  36. package/lib/antigravity-plugin/lib/extension/plugin-runtime.d.ts +10 -0
  37. package/lib/antigravity-plugin/lib/extension/plugin-runtime.js +67 -0
  38. package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +16 -0
  39. package/lib/antigravity-plugin/lib/integrations/agent-resources.js +56 -0
  40. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.d.ts +4 -0
  41. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.js +79 -0
  42. package/lib/antigravity-plugin/lib/integrations/hosts/claude.d.ts +3 -0
  43. package/lib/antigravity-plugin/lib/integrations/hosts/claude.js +60 -0
  44. package/lib/antigravity-plugin/lib/integrations/hosts/registry.d.ts +15 -0
  45. package/lib/antigravity-plugin/lib/integrations/hosts/registry.js +34 -0
  46. package/lib/antigravity-plugin/lib/model/acp.d.ts +164 -0
  47. package/lib/antigravity-plugin/lib/model/acp.js +12 -0
  48. package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +48 -0
  49. package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +24 -0
  50. package/lib/antigravity-plugin/lib/model/workspace-config.js +1 -0
  51. package/lib/antigravity-plugin/lib/model/workspace-mcp.d.ts +51 -0
  52. package/lib/antigravity-plugin/lib/model/workspace-mcp.js +4 -0
  53. package/lib/antigravity-plugin/lib/plugin.d.ts +1 -0
  54. package/lib/antigravity-plugin/lib/plugin.js +17 -0
  55. package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +8 -0
  56. package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +93 -0
  57. package/lib/antigravity-plugin/lib/services/workspace/workspace-preparation.d.ts +3 -0
  58. package/lib/antigravity-plugin/lib/services/workspace/workspace-preparation.js +26 -0
  59. package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.d.ts +8 -0
  60. package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.js +91 -0
  61. package/lib/antigravity-plugin/lib/storage/atomic-json.d.ts +11 -0
  62. package/lib/antigravity-plugin/lib/storage/atomic-json.js +101 -0
  63. package/lib/antigravity-plugin/mcp_config.json +13 -0
  64. package/lib/antigravity-plugin/package.json +6 -0
  65. package/lib/antigravity-plugin/plugin.json +7 -0
  66. package/lib/antigravity-plugin/resources/agents/coordinator.md +11 -0
  67. package/{resources/claude → lib/antigravity-plugin/resources}/agents/general-purpose.md +0 -5
  68. package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -0
  69. package/lib/antigravity-plugin/resources/prompts/workspace.md +31 -0
  70. package/lib/antigravity-plugin/resources/references/compute-finance.md +22 -0
  71. package/lib/antigravity-plugin/resources/references/compute.md +16 -0
  72. package/lib/antigravity-plugin/resources/references/task-conductor.md +25 -0
  73. package/lib/antigravity-plugin/resources/templates/workspace-agents.md +21 -0
  74. package/lib/antigravity-plugin/skills/pbot/SKILL.md +16 -0
  75. package/lib/antigravity-plugin/skills/project-maintenance/SKILL.md +35 -0
  76. package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +42 -0
  77. package/lib/claude.js +4 -11
  78. package/lib/client.js +14 -531
  79. package/lib/common/markdown.js +2 -3
  80. package/lib/common/validation.d.ts +2 -0
  81. package/lib/common/validation.js +4 -0
  82. package/lib/extension/acp-member.d.ts +2 -0
  83. package/lib/extension/acp-member.js +9 -8
  84. package/lib/extension/acp-worker.js +11578 -121
  85. package/lib/extension/dsh/acp-member.js +26 -2
  86. package/lib/extension/dsh/command.js +19 -57
  87. package/lib/extension/dsh/history.js +2 -4
  88. package/lib/extension/dsh/management.d.ts +0 -2
  89. package/lib/extension/dsh/management.js +27 -126
  90. package/lib/extension/dsh/workspace.d.ts +5 -47
  91. package/lib/extension/dsh/workspace.js +76 -108
  92. package/lib/extension/mcp-bridge.d.ts +41 -0
  93. package/lib/extension/mcp-bridge.js +412 -0
  94. package/lib/extension/mcp-workers.d.ts +980 -0
  95. package/lib/extension/mcp-workers.js +882 -0
  96. package/lib/extension/mcp.js +2715 -0
  97. package/lib/extension/plugin-runtime.d.ts +10 -0
  98. package/lib/extension/plugin-runtime.js +67 -0
  99. package/lib/extension/setup-cli.js +215 -2
  100. package/lib/integrations/acp/agents.d.ts +10 -11
  101. package/lib/integrations/acp/agents.js +65 -33
  102. package/lib/integrations/acp/claude.d.ts +2 -2
  103. package/lib/integrations/acp/claude.js +5 -3
  104. package/lib/integrations/acp/connection.d.ts +17 -4
  105. package/lib/integrations/acp/connection.js +53 -27
  106. package/lib/integrations/acp/executable.d.ts +3 -0
  107. package/lib/integrations/acp/executable.js +42 -0
  108. package/lib/integrations/acp/harnesses/claude.d.ts +2 -0
  109. package/lib/integrations/acp/harnesses/claude.js +49 -0
  110. package/lib/integrations/acp/harnesses/dsh.d.ts +2 -0
  111. package/lib/integrations/acp/harnesses/dsh.js +35 -0
  112. package/lib/integrations/acp/harnesses/generic.d.ts +13 -0
  113. package/lib/integrations/acp/harnesses/generic.js +37 -0
  114. package/lib/integrations/acp/harnesses/pi.d.ts +2 -0
  115. package/lib/integrations/acp/harnesses/pi.js +34 -0
  116. package/lib/integrations/acp/harnesses/presets.d.ts +3 -0
  117. package/lib/integrations/acp/harnesses/presets.js +20 -0
  118. package/lib/integrations/acp/launch.d.ts +33 -4
  119. package/lib/integrations/acp/launch.js +60 -48
  120. package/lib/integrations/acp/mcp.d.ts +6 -0
  121. package/lib/integrations/acp/mcp.js +40 -0
  122. package/lib/integrations/acp/model-selection.d.ts +9 -2
  123. package/lib/integrations/acp/model-selection.js +73 -27
  124. package/lib/integrations/acp/registry.d.ts +18 -0
  125. package/lib/integrations/acp/registry.js +50 -0
  126. package/lib/integrations/agent-resources.d.ts +16 -1
  127. package/lib/integrations/agent-resources.js +45 -9
  128. package/lib/integrations/dsh/mcp.d.ts +4 -0
  129. package/lib/integrations/dsh/mcp.js +28 -0
  130. package/lib/integrations/dsh/resources.d.ts +3 -3
  131. package/lib/integrations/dsh/resources.js +21 -12
  132. package/lib/integrations/dsh/skills.d.ts +5 -1
  133. package/lib/integrations/dsh/skills.js +10 -6
  134. package/lib/integrations/hosts/antigravity.d.ts +4 -0
  135. package/lib/integrations/hosts/antigravity.js +79 -0
  136. package/lib/integrations/hosts/claude.d.ts +3 -0
  137. package/lib/integrations/hosts/claude.js +60 -0
  138. package/lib/integrations/hosts/registry.d.ts +15 -0
  139. package/lib/integrations/hosts/registry.js +34 -0
  140. package/lib/model/acp.d.ts +107 -2
  141. package/lib/model/acp.js +12 -1
  142. package/lib/model/agent.d.ts +35 -33
  143. package/lib/model/plugin-host.d.ts +48 -0
  144. package/lib/model/plugin-host.js +1 -0
  145. package/lib/model/workspace-config.d.ts +12 -0
  146. package/lib/model/workspace-mcp.d.ts +51 -0
  147. package/lib/model/workspace-mcp.js +4 -0
  148. package/lib/plugin.d.ts +1 -0
  149. package/lib/plugin.js +17 -0
  150. package/lib/services/agents/acp-run.d.ts +13 -1
  151. package/lib/services/agents/acp-run.js +30 -2
  152. package/lib/services/agents/agent-service.d.ts +35 -120
  153. package/lib/services/agents/agent-service.js +156 -160
  154. package/lib/services/installation/setup-service.js +17 -1
  155. package/lib/services/workspace/workspace-config.d.ts +2 -1
  156. package/lib/services/workspace/workspace-config.js +39 -7
  157. package/lib/services/workspace/workspace-mcp.d.ts +14 -0
  158. package/lib/services/workspace/workspace-mcp.js +200 -0
  159. package/lib/services/workspace/workspace-skills.d.ts +8 -0
  160. package/lib/services/workspace/workspace-skills.js +91 -0
  161. package/lib/storage/acp-files.d.ts +3 -1
  162. package/lib/storage/acp-files.js +32 -2
  163. package/lib/storage/acp-history.d.ts +3 -2
  164. package/lib/storage/acp-history.js +19 -7
  165. package/lib/storage/agent-files.d.ts +8 -8
  166. package/lib/storage/agent-files.js +27 -47
  167. package/lib/tools/history/contract.d.ts +1 -1
  168. package/lib/tools/history/contract.js +17 -11
  169. package/lib/ui/dsh/index.js +8 -3
  170. package/lib/ui/dsh/management.d.ts +1 -1
  171. package/lib/ui/dsh/management.js +24 -456
  172. package/lib/ui/dsh/remote.d.ts +0 -2
  173. package/lib/ui/dsh/remote.js +1 -1
  174. package/package.json +12 -7
  175. package/resources/agents/coordinator.md +2 -2
  176. package/resources/antigravity/skills/pbot/SKILL.md +16 -0
  177. package/resources/claude/skills/pbot/SKILL.md +1 -1
  178. package/resources/prompts/history-coordinator.md +1 -0
  179. package/resources/prompts/plugin-coordinator.md +1 -0
  180. package/resources/prompts/workspace.md +9 -8
  181. package/resources/references/compute.md +9 -11
  182. package/resources/references/task-conductor.md +12 -26
  183. package/resources/skills/project-maintenance/SKILL.md +16 -21
  184. package/resources/skills/provider-connections/SKILL.md +24 -40
  185. package/resources/templates/workspace-agents.md +4 -0
  186. package/scripts/README.md +17 -34
  187. package/src/claude.ts +4 -8
  188. package/src/common/markdown.ts +2 -3
  189. package/src/common/validation.ts +6 -0
  190. package/src/extension/acp-member.ts +9 -8
  191. package/src/extension/acp-worker.ts +239 -97
  192. package/src/extension/command.ts +38 -36
  193. package/src/extension/dsh/acp-member.ts +21 -2
  194. package/src/extension/dsh/command.ts +21 -51
  195. package/src/extension/dsh/files.ts +1 -0
  196. package/src/extension/dsh/history.ts +9 -6
  197. package/src/extension/dsh/management.ts +27 -58
  198. package/src/extension/dsh/workspace.ts +88 -99
  199. package/src/extension/events.ts +13 -10
  200. package/src/extension/history.ts +2 -50
  201. package/src/extension/lifecycle.ts +37 -22
  202. package/src/extension/mcp-bridge.ts +412 -0
  203. package/src/extension/mcp-workers.ts +941 -0
  204. package/src/extension/pi-acp-member.ts +29 -5
  205. package/src/extension/plugin-runtime.ts +63 -0
  206. package/src/extension/setup-cli.ts +186 -2
  207. package/src/integrations/acp/agents.ts +70 -24
  208. package/src/integrations/acp/claude.ts +11 -4
  209. package/src/integrations/acp/connection.ts +63 -25
  210. package/src/integrations/acp/executable.ts +41 -0
  211. package/src/integrations/acp/harnesses/claude.ts +50 -0
  212. package/src/integrations/acp/harnesses/dsh.ts +40 -0
  213. package/src/integrations/acp/harnesses/generic.ts +52 -0
  214. package/src/integrations/acp/harnesses/pi.ts +35 -0
  215. package/src/integrations/acp/harnesses/presets.ts +22 -0
  216. package/src/integrations/acp/launch.ts +69 -47
  217. package/src/integrations/acp/mcp.ts +43 -0
  218. package/src/integrations/acp/model-selection.ts +68 -25
  219. package/src/integrations/acp/registry.ts +60 -0
  220. package/src/integrations/agent-resources.ts +70 -6
  221. package/src/integrations/dsh/mcp.ts +30 -0
  222. package/src/integrations/dsh/resources.ts +28 -13
  223. package/src/integrations/dsh/skills.ts +16 -6
  224. package/src/integrations/hosts/antigravity.ts +83 -0
  225. package/src/integrations/hosts/claude.ts +62 -0
  226. package/src/integrations/hosts/registry.ts +42 -0
  227. package/src/integrations/pi/mcp.ts +26 -0
  228. package/src/mcp.ts +14 -0
  229. package/src/model/acp.ts +113 -3
  230. package/src/model/agent.ts +18 -14
  231. package/src/model/plugin-host.ts +39 -0
  232. package/src/model/workspace-config.ts +14 -0
  233. package/src/model/workspace-mcp.ts +64 -0
  234. package/src/pbot.ts +69 -20
  235. package/src/plugin.ts +19 -0
  236. package/src/services/agents/acp-run.ts +35 -3
  237. package/src/services/agents/agent-service.ts +180 -160
  238. package/src/services/installation/setup-service.ts +17 -2
  239. package/src/services/workspace/workspace-config.ts +42 -6
  240. package/src/services/workspace/workspace-mcp.ts +242 -0
  241. package/src/services/workspace/workspace-skills.ts +78 -0
  242. package/src/storage/acp-files.ts +32 -3
  243. package/src/storage/acp-history.ts +18 -7
  244. package/src/storage/agent-files.ts +27 -41
  245. package/src/tools/history/contract.ts +17 -11
  246. package/src/tools/register.ts +4 -8
  247. package/src/ui/dsh/index.ts +8 -3
  248. package/src/ui/dsh/management.ts +40 -282
  249. package/src/ui/dsh/remote.ts +2 -2
  250. package/docs/adr/0001-claude-skill-discovery.md +0 -3
  251. package/docs/adr/0002-claude-native-collaboration.md +0 -3
  252. package/docs/agent-collaboration.md +0 -190
  253. package/docs/architecture-guidelines.md +0 -37
  254. package/docs/capability-design.md +0 -55
  255. package/docs/claude-code-design.md +0 -44
  256. package/docs/claude-code.md +0 -57
  257. package/docs/dsh.md +0 -337
  258. package/docs/file-storage.md +0 -97
  259. package/docs/history.md +0 -54
  260. package/docs/installation-design.md +0 -86
  261. package/docs/interaction-design.md +0 -21
  262. package/docs/model-context.md +0 -76
  263. package/docs/model-instruction-guidelines.md +0 -51
  264. package/docs/release.md +0 -108
  265. package/docs/technical-design.md +0 -163
  266. package/docs/workspace-configuration.md +0 -79
  267. package/lib/extension/claude-hooks.d.ts +0 -9
  268. package/lib/extension/claude-hooks.js +0 -78
  269. package/lib/extension/dsh/agent-events.d.ts +0 -24
  270. package/lib/extension/dsh/agent-events.js +0 -242
  271. package/lib/extension/dsh/agent-runtime.d.ts +0 -49
  272. package/lib/extension/dsh/agent-runtime.js +0 -351
  273. package/lib/integrations/dsh/dsh-agents.d.ts +0 -30
  274. package/lib/integrations/dsh/dsh-agents.js +0 -104
  275. package/lib/integrations/dsh/input.d.ts +0 -21
  276. package/lib/integrations/dsh/input.js +0 -62
  277. package/lib/integrations/dsh/notifications.d.ts +0 -8
  278. package/lib/integrations/dsh/notifications.js +0 -55
  279. package/lib/integrations/dsh/session.d.ts +0 -14
  280. package/lib/integrations/dsh/session.js +0 -60
  281. package/lib/integrations/team-context.d.ts +0 -18
  282. package/lib/integrations/team-context.js +0 -61
  283. package/lib/model/team.d.ts +0 -85
  284. package/lib/services/agents/agent-notices.d.ts +0 -13
  285. package/lib/services/agents/agent-notices.js +0 -25
  286. package/lib/services/agents/start-options.d.ts +0 -4
  287. package/lib/services/agents/start-options.js +0 -20
  288. package/lib/services/agents/team-service.d.ts +0 -168
  289. package/lib/services/agents/team-service.js +0 -345
  290. package/lib/storage/team-files.d.ts +0 -16
  291. package/lib/storage/team-files.js +0 -111
  292. package/lib/tools/agents/actions.d.ts +0 -62
  293. package/lib/tools/agents/actions.js +0 -62
  294. package/lib/tools/agents/contract.d.ts +0 -181
  295. package/lib/tools/agents/contract.js +0 -84
  296. package/lib/tools/agents/dsh-tool.d.ts +0 -5
  297. package/lib/tools/agents/dsh-tool.js +0 -34
  298. package/lib/tools/result.d.ts +0 -18
  299. package/lib/tools/result.js +0 -10
  300. package/lib/tools/teams/actions.d.ts +0 -23
  301. package/lib/tools/teams/actions.js +0 -40
  302. package/lib/tools/teams/contract.d.ts +0 -201
  303. package/lib/tools/teams/contract.js +0 -91
  304. package/lib/tools/teams/dsh-tool.d.ts +0 -8
  305. package/lib/tools/teams/dsh-tool.js +0 -39
  306. package/lib/ui/dsh/attachments.d.ts +0 -5
  307. package/lib/ui/dsh/attachments.js +0 -39
  308. package/resources/prompts/claude-coordinator.md +0 -1
  309. package/resources/prompts/native-coordinator.md +0 -1
  310. package/resources/prompts/team-member.md +0 -7
  311. package/src/extension/agent-events.ts +0 -210
  312. package/src/extension/agents-command.ts +0 -89
  313. package/src/extension/claude-hooks.ts +0 -74
  314. package/src/extension/dsh/agent-events.ts +0 -148
  315. package/src/extension/dsh/agent-runtime.ts +0 -252
  316. package/src/extension/subagent-entry.ts +0 -270
  317. package/src/extension/teams-command.ts +0 -67
  318. package/src/integrations/dsh/dsh-agents.ts +0 -97
  319. package/src/integrations/dsh/input.ts +0 -66
  320. package/src/integrations/dsh/notifications.ts +0 -46
  321. package/src/integrations/pi/agent-context.ts +0 -18
  322. package/src/integrations/pi/agent-input.ts +0 -19
  323. package/src/integrations/pi/pi-agents.ts +0 -84
  324. package/src/integrations/pi/team-context.ts +0 -26
  325. package/src/integrations/team-context.ts +0 -64
  326. package/src/model/team.ts +0 -29
  327. package/src/services/agents/agent-notices.ts +0 -28
  328. package/src/services/agents/start-options.ts +0 -19
  329. package/src/services/agents/team-service.ts +0 -275
  330. package/src/storage/team-files.ts +0 -93
  331. package/src/tools/agents/actions.ts +0 -57
  332. package/src/tools/agents/contract.ts +0 -101
  333. package/src/tools/agents/dsh-tool.ts +0 -37
  334. package/src/tools/agents/tool.ts +0 -20
  335. package/src/tools/teams/actions.ts +0 -34
  336. package/src/tools/teams/contract.ts +0 -109
  337. package/src/tools/teams/dsh-tool.ts +0 -45
  338. package/src/tools/teams/tool.ts +0 -29
  339. package/src/ui/agent-display.ts +0 -14
  340. package/src/ui/dsh/attachments.ts +0 -42
  341. package/src/ui/pi/menu.ts +0 -37
  342. package/src/ui/pi/reader.ts +0 -46
  343. /package/lib/{model/team.js → antigravity-plugin/lib/model/plugin-host.js} +0 -0
@@ -1,62 +0,0 @@
1
- import type { AgentService } from "../../services/agents/agent-service.js";
2
- import type { AgentOptions, AgentOwner } from "../../model/agent.js";
3
- import type { AgentInput } from "./contract.js";
4
- export declare function executeAgent(service: AgentService, input: AgentInput, owner: AgentOwner, defaults?: AgentOptions): Promise<{
5
- isError?: boolean;
6
- content: {
7
- type: "text";
8
- text: string;
9
- }[];
10
- details: import("../../common/json.js").Json;
11
- structuredContent: import("../../common/json.js").Json;
12
- } | {
13
- details: {
14
- agentReadKeys?: string[];
15
- backend?: "pi" | "dsh" | "claude";
16
- error?: string;
17
- capabilities?: {
18
- steer: boolean;
19
- resume: boolean;
20
- team: boolean;
21
- transcript: boolean;
22
- };
23
- requestId?: string;
24
- cycle?: {
25
- error?: string;
26
- finishedAt?: number;
27
- state: "completed" | "failed" | "cancelled" | "running" | "interrupted";
28
- startedAt: number;
29
- cycleId: string;
30
- requestIds: string[];
31
- source: "parent" | "interactive" | "mixed";
32
- };
33
- selection?: {
34
- provider?: string;
35
- model?: string;
36
- resolvedModel?: string;
37
- thinking?: string;
38
- };
39
- report?: string;
40
- transport?: "acp" | "native";
41
- messageStatus?: "queued";
42
- cycles?: {
43
- state: string;
44
- cycleId: string;
45
- }[];
46
- totalLength?: number;
47
- nextOffset?: number | null;
48
- state: "starting" | "busy" | "idle" | "stopping" | "stopped" | "error";
49
- name: string;
50
- agentId: string;
51
- cwd: string;
52
- createdAt: number;
53
- activity: string;
54
- owned: boolean;
55
- };
56
- isError?: boolean;
57
- content: {
58
- type: "text";
59
- text: string;
60
- }[];
61
- structuredContent: import("../../common/json.js").Json;
62
- }>;
@@ -1,62 +0,0 @@
1
- import { markdownResult } from "../result.js";
2
- function agentOutput(view) {
3
- const c = view.cycle;
4
- return {
5
- agentId: view.agentId, name: view.name, cwd: view.cwd, createdAt: view.createdAt,
6
- owned: view.owned, state: view.state, activity: view.activity,
7
- ...(view.backend ? { backend: view.backend, transport: view.transport, capabilities: view.capabilities } : {}),
8
- ...(view.selection ? { selection: view.selection } : {}),
9
- ...(c ? { cycle: { cycleId: c.cycleId, startedAt: c.startedAt, state: c.state, requestIds: c.requestIds, source: c.source,
10
- ...(c.finishedAt === undefined ? {} : { finishedAt: c.finishedAt }), ...(c.error === undefined ? {} : { error: c.error }) } } : {}),
11
- ...(view.error === undefined ? {} : { error: view.error }),
12
- ...(view.requestId === undefined ? {} : { requestId: view.requestId }),
13
- ...(view.messageStatus === undefined ? {} : { messageStatus: view.messageStatus }),
14
- ...(view.cycles === undefined ? {} : { cycles: view.cycles }),
15
- ...(view.report === undefined ? {} : { report: view.report }),
16
- ...(view.totalLength === undefined ? {} : { totalLength: view.totalLength }),
17
- ...(view.nextOffset === undefined ? {} : { nextOffset: view.nextOffset }),
18
- };
19
- }
20
- /** Parent selection is inherited only for a native expert; a chosen model drops the thinking default. */
21
- function inherited(input, defaults) {
22
- if (input.action !== "start" || input.backend)
23
- return {};
24
- const changed = Boolean(input.provider && defaults.provider && input.provider !== defaults.provider) ||
25
- Boolean(input.model && defaults.model && input.model !== defaults.model);
26
- const options = { ...defaults };
27
- if (changed)
28
- delete options.thinking;
29
- return options;
30
- }
31
- export async function executeAgent(service, input, owner, defaults = {}) {
32
- let value;
33
- switch (input.action) {
34
- case "start": {
35
- const { action: _action, ...supplied } = input;
36
- value = await service.start({ ...inherited(input, defaults), ...supplied }, owner);
37
- break;
38
- }
39
- case "list": return markdownResult({ agents: service.list(owner).map(agentOutput) }, "子会话列表");
40
- case "send":
41
- value = service.send(input.agentId, input.message, input.delivery ?? "steer", owner);
42
- break;
43
- case "rename":
44
- value = service.rename(input.agentId, input.name, owner);
45
- break;
46
- case "resume":
47
- value = await service.resume(input.agentId, input.message, owner);
48
- break;
49
- case "stop":
50
- value = service.stop(input.agentId, owner);
51
- break;
52
- case "status":
53
- value = service.status(input.agentId, owner);
54
- break;
55
- case "read": {
56
- const page = await service.read(input.agentId, owner, input.cycleId, input.offset, input.limit);
57
- const data = agentOutput(page), output = markdownResult(data, "子会话报告");
58
- return { ...output, details: { ...data, ...(page.cycle && page.cycle.state !== "running" ? { agentReadKeys: [page.agentId + ":" + page.cycle.cycleId] } : {}) } };
59
- }
60
- }
61
- return markdownResult(agentOutput(value), "子会话状态");
62
- }
@@ -1,181 +0,0 @@
1
- import { Type } from "typebox";
2
- import type { AgentStartOptions } from "../../model/agent.js";
3
- export declare const agentDescription = "\u59D4\u6D3E\u4E13\u5BB6\u5E76\u7EE7\u7EED\u5BF9\u8BDD\u3002start \u542F\u52A8\u540E\u5373\u8FD4\u56DE\uFF0C\u5B8C\u6210\u81EA\u52A8\u901A\u77E5\uFF0C\u65E0\u9700\u8F6E\u8BE2\uFF1B\u7701\u7565\u521D\u59CB\u8F93\u5165\u65F6\u5F85\u547D\u3002send \u7EE7\u7EED\u5BF9\u8BDD\uFF0C\u56E2\u961F\u5360\u7528\u671F\u95F4\u4E0D\u53EF\u79C1\u4EBA send\u3002status \u67E5\u770B\u72B6\u6001\uFF0Cread \u8BFB\u53D6\u62A5\u544A\uFF1B\u8BFB\u53D6\u5DF2\u7ED3\u675F\u5468\u671F\u5373\u9886\u53D6\u5176\u901A\u77E5\uFF0C\u5305\u62EC\u90E8\u5206\u8BFB\u53D6\u3002\u7EED\u8BFB\u56FA\u5B9A cycle.cycleId \u5E76\u4F7F\u7528 nextOffset\u3002state \u8868\u793A\u6267\u884C\u72B6\u6001\uFF0Ccycle.state \u8868\u793A\u5DE5\u4F5C\u7ED3\u679C\uFF0Cqueued \u53EA\u8868\u793A\u5165\u961F\u3002stop \u4FDD\u7559\u5386\u53F2\uFF0Cresume \u643A\u65B0 message \u7EE7\u7EED\u3002\u6BCF\u4E2A\u7236\u4F1A\u8BDD\u6700\u591A 50 \u4E2A\u5B58\u6D3B\u4E13\u5BB6\uFF0C\u7A7A\u95F2\u4E5F\u8BA1\u5165\u3002\u52A8\u4F5C\u53EA\u8BFB\u53D6\u81EA\u5DF1\u7684\u5B57\u6BB5\uFF1B\u5176\u4ED6\u5DF2\u58F0\u660E\u5B57\u6BB5\u5FFD\u7565\u3002";
4
- export declare const agentParametersSchema: Type.TObject<{
5
- cycleId: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
6
- offset: Type.TOptional<Type.TUnion<[Type.TInteger, Type.TNull]>>;
7
- limit: Type.TOptional<Type.TUnion<[Type.TInteger, Type.TNull]>>;
8
- delivery: Type.TOptional<Type.TUnion<[Type.TUnion<[Type.TLiteral<"steer">, Type.TLiteral<"followUp">]>, Type.TNull]>>;
9
- backend: Type.TOptional<Type.TUnion<[Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>, Type.TNull]>>;
10
- name: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
11
- message: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
12
- files: Type.TOptional<Type.TUnion<[Type.TArray<Type.TString>, Type.TNull]>>;
13
- provider: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
14
- model: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
15
- thinking: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
16
- cwd: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
17
- tools: Type.TOptional<Type.TUnion<[Type.TArray<Type.TString>, Type.TNull]>>;
18
- noExtensions: Type.TOptional<Type.TUnion<[Type.TBoolean, Type.TNull]>>;
19
- noSkills: Type.TOptional<Type.TUnion<[Type.TBoolean, Type.TNull]>>;
20
- noPromptTemplates: Type.TOptional<Type.TUnion<[Type.TBoolean, Type.TNull]>>;
21
- noContextFiles: Type.TOptional<Type.TUnion<[Type.TBoolean, Type.TNull]>>;
22
- action: Type.TUnion<[Type.TLiteral<"start">, Type.TLiteral<"send">, Type.TLiteral<"rename">, Type.TLiteral<"status">, Type.TLiteral<"list">, Type.TLiteral<"read">, Type.TLiteral<"stop">, Type.TLiteral<"resume">]>;
23
- agentId: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
24
- }>;
25
- export type AgentAction = "start" | "send" | "rename" | "status" | "list" | "read" | "stop" | "resume";
26
- export type AgentInput = ({
27
- action: "start";
28
- } & AgentStartOptions) | {
29
- action: "send";
30
- agentId: string;
31
- message: string;
32
- delivery?: "steer" | "followUp";
33
- } | {
34
- action: "resume";
35
- agentId: string;
36
- message: string;
37
- } | {
38
- action: "rename";
39
- agentId: string;
40
- name: string;
41
- } | {
42
- action: "stop" | "status";
43
- agentId: string;
44
- } | {
45
- action: "list";
46
- } | {
47
- action: "read";
48
- agentId: string;
49
- cycleId?: string;
50
- offset?: number;
51
- limit?: number;
52
- };
53
- /** One flat record, one interpreter. Fields outside the selected action are inert. */
54
- export declare function agentInput(value: unknown): AgentInput;
55
- export declare const agentViewSchema: Type.TObject<{
56
- agentId: Type.TString;
57
- name: Type.TString;
58
- cwd: Type.TString;
59
- createdAt: Type.TNumber;
60
- backend: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>>;
61
- transport: Type.TOptional<Type.TUnion<[Type.TLiteral<"native">, Type.TLiteral<"acp">]>>;
62
- selection: Type.TOptional<Type.TObject<{
63
- provider: Type.TOptional<Type.TString>;
64
- model: Type.TOptional<Type.TString>;
65
- resolvedModel: Type.TOptional<Type.TString>;
66
- thinking: Type.TOptional<Type.TString>;
67
- }>>;
68
- capabilities: Type.TOptional<Type.TObject<{
69
- steer: Type.TBoolean;
70
- resume: Type.TBoolean;
71
- team: Type.TBoolean;
72
- transcript: Type.TBoolean;
73
- }>>;
74
- owned: Type.TBoolean;
75
- state: Type.TUnion<[Type.TLiteral<"starting">, Type.TLiteral<"busy">, Type.TLiteral<"idle">, Type.TLiteral<"stopping">, Type.TLiteral<"stopped">, Type.TLiteral<"error">]>;
76
- activity: Type.TString;
77
- cycle: Type.TOptional<Type.TObject<{
78
- cycleId: Type.TString;
79
- startedAt: Type.TNumber;
80
- finishedAt: Type.TOptional<Type.TNumber>;
81
- state: Type.TUnion<[Type.TLiteral<"running">, Type.TLiteral<"completed">, Type.TLiteral<"failed">, Type.TLiteral<"cancelled">, Type.TLiteral<"interrupted">]>;
82
- requestIds: Type.TArray<Type.TString>;
83
- source: Type.TUnion<[Type.TLiteral<"parent">, Type.TLiteral<"interactive">, Type.TLiteral<"mixed">]>;
84
- error: Type.TOptional<Type.TString>;
85
- }>>;
86
- error: Type.TOptional<Type.TString>;
87
- requestId: Type.TOptional<Type.TString>;
88
- messageStatus: Type.TOptional<Type.TLiteral<"queued">>;
89
- cycles: Type.TOptional<Type.TArray<Type.TObject<{
90
- cycleId: Type.TString;
91
- state: Type.TString;
92
- }>>>;
93
- report: Type.TOptional<Type.TString>;
94
- totalLength: Type.TOptional<Type.TInteger>;
95
- nextOffset: Type.TOptional<Type.TUnion<[Type.TInteger, Type.TNull]>>;
96
- }>;
97
- export declare const agentResultSchema: Type.TUnion<[Type.TObject<{
98
- agentId: Type.TString;
99
- name: Type.TString;
100
- cwd: Type.TString;
101
- createdAt: Type.TNumber;
102
- backend: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>>;
103
- transport: Type.TOptional<Type.TUnion<[Type.TLiteral<"native">, Type.TLiteral<"acp">]>>;
104
- selection: Type.TOptional<Type.TObject<{
105
- provider: Type.TOptional<Type.TString>;
106
- model: Type.TOptional<Type.TString>;
107
- resolvedModel: Type.TOptional<Type.TString>;
108
- thinking: Type.TOptional<Type.TString>;
109
- }>>;
110
- capabilities: Type.TOptional<Type.TObject<{
111
- steer: Type.TBoolean;
112
- resume: Type.TBoolean;
113
- team: Type.TBoolean;
114
- transcript: Type.TBoolean;
115
- }>>;
116
- owned: Type.TBoolean;
117
- state: Type.TUnion<[Type.TLiteral<"starting">, Type.TLiteral<"busy">, Type.TLiteral<"idle">, Type.TLiteral<"stopping">, Type.TLiteral<"stopped">, Type.TLiteral<"error">]>;
118
- activity: Type.TString;
119
- cycle: Type.TOptional<Type.TObject<{
120
- cycleId: Type.TString;
121
- startedAt: Type.TNumber;
122
- finishedAt: Type.TOptional<Type.TNumber>;
123
- state: Type.TUnion<[Type.TLiteral<"running">, Type.TLiteral<"completed">, Type.TLiteral<"failed">, Type.TLiteral<"cancelled">, Type.TLiteral<"interrupted">]>;
124
- requestIds: Type.TArray<Type.TString>;
125
- source: Type.TUnion<[Type.TLiteral<"parent">, Type.TLiteral<"interactive">, Type.TLiteral<"mixed">]>;
126
- error: Type.TOptional<Type.TString>;
127
- }>>;
128
- error: Type.TOptional<Type.TString>;
129
- requestId: Type.TOptional<Type.TString>;
130
- messageStatus: Type.TOptional<Type.TLiteral<"queued">>;
131
- cycles: Type.TOptional<Type.TArray<Type.TObject<{
132
- cycleId: Type.TString;
133
- state: Type.TString;
134
- }>>>;
135
- report: Type.TOptional<Type.TString>;
136
- totalLength: Type.TOptional<Type.TInteger>;
137
- nextOffset: Type.TOptional<Type.TUnion<[Type.TInteger, Type.TNull]>>;
138
- }>, Type.TObject<{
139
- agents: Type.TArray<Type.TObject<{
140
- agentId: Type.TString;
141
- name: Type.TString;
142
- cwd: Type.TString;
143
- createdAt: Type.TNumber;
144
- backend: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>>;
145
- transport: Type.TOptional<Type.TUnion<[Type.TLiteral<"native">, Type.TLiteral<"acp">]>>;
146
- selection: Type.TOptional<Type.TObject<{
147
- provider: Type.TOptional<Type.TString>;
148
- model: Type.TOptional<Type.TString>;
149
- resolvedModel: Type.TOptional<Type.TString>;
150
- thinking: Type.TOptional<Type.TString>;
151
- }>>;
152
- capabilities: Type.TOptional<Type.TObject<{
153
- steer: Type.TBoolean;
154
- resume: Type.TBoolean;
155
- team: Type.TBoolean;
156
- transcript: Type.TBoolean;
157
- }>>;
158
- owned: Type.TBoolean;
159
- state: Type.TUnion<[Type.TLiteral<"starting">, Type.TLiteral<"busy">, Type.TLiteral<"idle">, Type.TLiteral<"stopping">, Type.TLiteral<"stopped">, Type.TLiteral<"error">]>;
160
- activity: Type.TString;
161
- cycle: Type.TOptional<Type.TObject<{
162
- cycleId: Type.TString;
163
- startedAt: Type.TNumber;
164
- finishedAt: Type.TOptional<Type.TNumber>;
165
- state: Type.TUnion<[Type.TLiteral<"running">, Type.TLiteral<"completed">, Type.TLiteral<"failed">, Type.TLiteral<"cancelled">, Type.TLiteral<"interrupted">]>;
166
- requestIds: Type.TArray<Type.TString>;
167
- source: Type.TUnion<[Type.TLiteral<"parent">, Type.TLiteral<"interactive">, Type.TLiteral<"mixed">]>;
168
- error: Type.TOptional<Type.TString>;
169
- }>>;
170
- error: Type.TOptional<Type.TString>;
171
- requestId: Type.TOptional<Type.TString>;
172
- messageStatus: Type.TOptional<Type.TLiteral<"queued">>;
173
- cycles: Type.TOptional<Type.TArray<Type.TObject<{
174
- cycleId: Type.TString;
175
- state: Type.TString;
176
- }>>>;
177
- report: Type.TOptional<Type.TString>;
178
- totalLength: Type.TOptional<Type.TInteger>;
179
- nextOffset: Type.TOptional<Type.TUnion<[Type.TInteger, Type.TNull]>>;
180
- }>>;
181
- }>]>;
@@ -1,84 +0,0 @@
1
- import { Type } from "../../common/typebox.js";
2
- import { requireThat } from "../../common/validation.js";
3
- import { schema } from "../../common/schema.js";
4
- import { inputObject, need, nullable, pick } from "../input.js";
5
- export const agentDescription = "委派专家并继续对话。start 启动后即返回,完成自动通知,无需轮询;省略初始输入时待命。send 继续对话,团队占用期间不可私人 send。status 查看状态,read 读取报告;读取已结束周期即领取其通知,包括部分读取。续读固定 cycle.cycleId 并使用 nextOffset。state 表示执行状态,cycle.state 表示工作结果,queued 只表示入队。stop 保留历史,resume 携新 message 继续。每个父会话最多 50 个存活专家,空闲也计入。动作只读取自己的字段;其他已声明字段忽略。";
6
- const id = Type.String({ minLength: 1, maxLength: 128 });
7
- const message = Type.String({ minLength: 1, maxLength: 24000, description: "本次目标、相关资料、约束和交付要求。" });
8
- const name = Type.String({ minLength: 1, maxLength: 64, pattern: "^[^\\r\\n\\x00-\\x1f]+$" });
9
- const startFields = {
10
- backend: nullable(Type.Union([Type.Literal("pi"), Type.Literal("dsh"), Type.Literal("claude")], { description: "选择 ACP 子代理程序:pi、dsh 或 claude(Claude Code)。省略时使用当前宿主的原生专家;指定时使用目标程序自己的配置。" })),
11
- name: nullable(name), message: nullable(message),
12
- files: nullable(Type.Array(Type.String({ minLength: 1 }), { maxItems: 32, description: "随初始消息读取的文件;相对路径基于原工作区根目录。" })),
13
- provider: nullable(Type.String({ ...id, description: "模型提供方覆盖项;省略时继承主会话或使用 ACP 目标配置。指定时须同时指定 model。" })),
14
- model: nullable(Type.String({ ...id, description: "模型 ID 覆盖项;省略时继承主会话或使用 ACP 目标配置。Pi/dsh 同名模型可用 provider 区分。" })),
15
- thinking: nullable(Type.String({ minLength: 1, maxLength: 128, description: "思考等级覆盖项;省略时继承主会话或使用 ACP 目标配置。Pi 使用 off/minimal/low/medium/high/xhigh/max,其他程序使用其原生等级 ID。" })),
16
- cwd: nullable(Type.String({ minLength: 1, description: "执行目录,相对原工作区根目录;省略时使用工作区根目录。" })),
17
- tools: nullable(Type.Array(id, { minItems: 1, description: "Pi/dsh 子代理的工具名;省略时使用所选程序默认工具。Claude 子代理忽略此项并沿用原生配置。" })),
18
- noExtensions: nullable(Type.Boolean({ description: "仅用于 Pi 子代理:关闭其他扩展的自动发现,默认 true。" })),
19
- noSkills: nullable(Type.Boolean({ description: "Pi/dsh 子代理关闭技能发现,默认 false;Claude 子代理忽略此项并沿用原生配置。" })),
20
- noPromptTemplates: nullable(Type.Boolean({ description: "仅用于 Pi 子代理:关闭提示模板发现,默认 false。" })),
21
- noContextFiles: nullable(Type.Boolean({ description: "仅用于 Pi 子代理:关闭原生上下文文件加载,默认 false。" })),
22
- };
23
- export const agentParametersSchema = Type.Object({
24
- action: Type.Union([Type.Literal("start"), Type.Literal("send"), Type.Literal("rename"), Type.Literal("status"), Type.Literal("list"), Type.Literal("read"), Type.Literal("stop"), Type.Literal("resume")], {
25
- description: "start 创建专家;省略 message/files 即待命。send 必填 agentId/message,可选 delivery。resume 必填 agentId/message。stop/status 必填 agentId。rename 必填 agentId/name。read 必填 agentId,可选 cycleId/offset/limit。list 只需 action。动作只读取自己的字段;其他已声明字段忽略。",
26
- }),
27
- agentId: nullable(id), ...startFields,
28
- cycleId: nullable(Type.String({ ...id, description: "仅 read:省略时读取最近周期;按 nextOffset 续读时须固定为上页返回的 cycle.cycleId,避免切换到新周期。" })),
29
- offset: nullable(Type.Integer({ minimum: 0, description: "仅 read:报告正文的 UTF-16 字符偏移,默认 0;续读使用上页 nextOffset。" })),
30
- limit: nullable(Type.Integer({ minimum: 1, maximum: 16000, description: "仅 read:最多返回的正文 UTF-16 字符数,默认 16000,不是消息数或 token 数。" })),
31
- delivery: nullable(Type.Union([Type.Literal("steer"), Type.Literal("followUp")], { description: "仅 send:默认 steer 补充当前工作;followUp 排到当前工作之后。capabilities.steer 为 false 的成员运行中使用 followUp。" })),
32
- }, { additionalProperties: false });
33
- const startKeys = Object.keys(startFields);
34
- const valid = schema(agentParametersSchema);
35
- /** One flat record, one interpreter. Fields outside the selected action are inert. */
36
- export function agentInput(value) {
37
- const args = inputObject(value, valid, "专家参数格式无效");
38
- const action = args.action;
39
- switch (action) {
40
- case "start":
41
- requireThat(!args.provider || args.model !== undefined, "start 需要同时提供 provider 与 model。");
42
- return { action, ...pick(args, startKeys) };
43
- case "send":
44
- return { action, agentId: need("send", args, "agentId"), message: need("send", args, "message"),
45
- ...(args.delivery === undefined ? {} : { delivery: args.delivery }) };
46
- case "resume":
47
- return { action, agentId: need("resume", args, "agentId"), message: need("resume", args, "message") };
48
- case "rename":
49
- return { action, agentId: need("rename", args, "agentId"), name: need("rename", args, "name") };
50
- case "stop":
51
- case "status":
52
- return { action, agentId: need(action, args, "agentId") };
53
- case "list":
54
- return { action };
55
- case "read":
56
- return { action, agentId: need("read", args, "agentId"),
57
- ...(args.cycleId === undefined ? {} : { cycleId: args.cycleId }),
58
- ...(args.offset === undefined ? {} : { offset: args.offset }),
59
- ...(args.limit === undefined ? {} : { limit: args.limit }) };
60
- default:
61
- throw new Error("未知的专家 action。");
62
- }
63
- }
64
- const cycle = Type.Object({ cycleId: Type.String(), startedAt: Type.Number(), finishedAt: Type.Optional(Type.Number()),
65
- state: Type.Union([Type.Literal("running"), Type.Literal("completed"), Type.Literal("failed"), Type.Literal("cancelled"), Type.Literal("interrupted")], { description: "本周期的工作结果,正文用 read 读取。" }),
66
- requestIds: Type.Array(Type.String()),
67
- source: Type.Union([Type.Literal("parent"), Type.Literal("interactive"), Type.Literal("mixed")]), error: Type.Optional(Type.String()),
68
- }, { additionalProperties: false });
69
- export const agentViewSchema = Type.Object({ agentId: Type.String(), name: Type.String(), cwd: Type.String(), createdAt: Type.Number(),
70
- backend: Type.Optional(Type.Union([Type.Literal("pi"), Type.Literal("dsh"), Type.Literal("claude")])),
71
- transport: Type.Optional(Type.Union([Type.Literal("native"), Type.Literal("acp")])),
72
- selection: Type.Optional(Type.Object({ provider: Type.Optional(Type.String()), model: Type.Optional(Type.String()),
73
- resolvedModel: Type.Optional(Type.String({ description: "目标原生会话报告的模型 ID,可用于识别配置别名。" })), thinking: Type.Optional(Type.String()) }, { additionalProperties: false, description: "子代理实际模型配置与有效思考等级,包含默认值。" })),
74
- capabilities: Type.Optional(Type.Object({ steer: Type.Boolean(), resume: Type.Boolean(), team: Type.Boolean(), transcript: Type.Boolean() }, { additionalProperties: false })),
75
- owned: Type.Boolean({ description: "是否属于当前父会话分支;false 时须回到所属分支操作。" }),
76
- state: Type.Union([Type.Literal("starting"), Type.Literal("busy"), Type.Literal("idle"), Type.Literal("stopping"), Type.Literal("stopped"), Type.Literal("error")], { description: "执行状态;idle 不代表上轮工作成功,结果见 cycle.state。" }),
77
- activity: Type.String(), cycle: Type.Optional(cycle), error: Type.Optional(Type.String()),
78
- requestId: Type.Optional(Type.String()), messageStatus: Type.Optional(Type.Literal("queued", { description: "消息已入队,不代表模型已阅读或完成。" })),
79
- cycles: Type.Optional(Type.Array(Type.Object({ cycleId: Type.String(), state: Type.String() }), { description: "仅 read 返回:可读取的周期索引。" })),
80
- report: Type.Optional(Type.String({ description: "仅 read 返回:选定周期的报告正文片段。" })),
81
- totalLength: Type.Optional(Type.Integer({ description: "仅 read 返回:完整报告的 UTF-16 字符数。" })),
82
- nextOffset: Type.Optional(Type.Union([Type.Integer(), Type.Null()], { description: "仅 read 返回:null 表示本报告已读完;否则以相同 agentId、cycle.cycleId 和此 offset 继续。" })),
83
- }, { additionalProperties: false });
84
- export const agentResultSchema = Type.Union([agentViewSchema, Type.Object({ agents: Type.Array(agentViewSchema) }, { additionalProperties: false })]);
@@ -1,5 +0,0 @@
1
- import type { Context } from "@deepseek-ai/cordis";
2
- import type { Agent } from "@deepseek-ai/dsh-agent";
3
- import type { AgentService } from "../../services/agents/agent-service.js";
4
- import type { AgentOwner } from "../../model/agent.js";
5
- export declare function registerDshAgentTool(ctx: Context, agent: Agent, service: AgentService, owner: AgentOwner, check: () => void): void;
@@ -1,34 +0,0 @@
1
- import { dshParameters, dshOutputSchema } from "../../integrations/dsh/schema.js";
2
- import { object, json } from "../../common/json.js";
3
- import { requireThat } from "../../common/validation.js";
4
- import { schema } from "../../common/schema.js";
5
- import { markdownFields } from "../../common/markdown.js";
6
- import { executeAgent } from "./actions.js";
7
- import { agentDescription, agentInput, agentParametersSchema, agentResultSchema } from "./contract.js";
8
- export function registerDshAgentTool(ctx, agent, service, owner, check) {
9
- const validOutput = schema(agentResultSchema);
10
- ctx.tools.register({ name: "pbot_agent", description: agentDescription,
11
- parameters: dshParameters(agentParametersSchema),
12
- output: {
13
- schema: dshOutputSchema(agentResultSchema),
14
- render: (_args, value) => [{ type: "text", text: "# 专家\n\n" + markdownFields(value) }],
15
- presentationMeta: (args, value) => {
16
- if (!object(args) || args.action !== "read" || !object(value) || !object(value.cycle) || value.cycle.state === "running")
17
- return {};
18
- return json({ pbotAgentReadKeys: [String(value.agentId) + ":" + String(value.cycle.cycleId)] });
19
- },
20
- },
21
- async execute(args, exec) {
22
- check();
23
- exec.signal.throwIfAborted();
24
- requireThat(exec.agent === agent, "专家工具不属于当前会话。");
25
- const input = agentInput(args), selection = agent.model.current();
26
- const output = await executeAgent(service, input, owner, selection ? {
27
- provider: selection.provider, model: selection.model,
28
- ...(selection.reasoningEffort ? { thinking: selection.reasoningEffort } : {}),
29
- } : {});
30
- requireThat(validOutput(output.structuredContent), "专家输出不符合契约。");
31
- return output.structuredContent;
32
- },
33
- });
34
- }
@@ -1,18 +0,0 @@
1
- export declare function markdownResult(value: unknown, title: string): {
2
- isError?: boolean;
3
- content: {
4
- type: "text";
5
- text: string;
6
- }[];
7
- details: import("../common/json.js").Json;
8
- structuredContent: import("../common/json.js").Json;
9
- };
10
- export declare function result(value: unknown, isError?: boolean, text?: string): {
11
- isError?: boolean;
12
- content: {
13
- type: "text";
14
- text: string;
15
- }[];
16
- details: import("../common/json.js").Json;
17
- structuredContent: import("../common/json.js").Json;
18
- };
@@ -1,10 +0,0 @@
1
- import { json } from "../common/json.js";
2
- import { markdownFields } from "../common/markdown.js";
3
- export function markdownResult(value, title) {
4
- return result(value, false, "# " + title + "\n\n" + markdownFields(json(value)));
5
- }
6
- export function result(value, isError = false, text) {
7
- const data = json(value);
8
- return { content: [{ type: "text", text: text ?? JSON.stringify(data) }],
9
- details: data, structuredContent: data, ...(isError ? { isError: true } : {}) };
10
- }
@@ -1,23 +0,0 @@
1
- import type { TeamService } from "../../services/agents/team-service.js";
2
- import type { AgentService } from "../../services/agents/agent-service.js";
3
- import type { TeamActor } from "../../model/team.js";
4
- import type { AgentOwner } from "../../model/agent.js";
5
- import type { TeamInput, TeamMessageInput } from "./contract.js";
6
- export declare function executeTeam(service: TeamService, agents: AgentService, input: TeamInput, owner: AgentOwner): {
7
- isError?: boolean;
8
- content: {
9
- type: "text";
10
- text: string;
11
- }[];
12
- details: import("../../common/json.js").Json;
13
- structuredContent: import("../../common/json.js").Json;
14
- };
15
- export declare function executeTeamMessage(service: TeamService, input: TeamMessageInput, actor: TeamActor, requestId: string): {
16
- isError?: boolean;
17
- content: {
18
- type: "text";
19
- text: string;
20
- }[];
21
- details: import("../../common/json.js").Json;
22
- structuredContent: import("../../common/json.js").Json;
23
- };
@@ -1,40 +0,0 @@
1
- import { teamMessagesMarkdown } from "../../integrations/team-context.js";
2
- import { markdownResult, result } from "../result.js";
3
- export function executeTeam(service, agents, input, owner) {
4
- const views = agents.list(owner);
5
- service.recover(owner);
6
- let id = "";
7
- switch (input.action) {
8
- case "create":
9
- id = service.create(owner, { name: input.name, brief: input.brief, members: input.members }, views).teamId;
10
- break;
11
- case "list": return markdownResult({ teams: service.list(owner, views) }, "团队列表");
12
- case "run":
13
- id = input.teamId;
14
- service.run(id, owner, { instruction: input.instruction, mode: input.mode,
15
- ...(input.rounds === undefined ? {} : { rounds: input.rounds }),
16
- ...(input.maxConcurrent === undefined ? {} : { maxConcurrent: input.maxConcurrent }),
17
- ...(input.timeoutSeconds === undefined ? {} : { timeoutSeconds: input.timeoutSeconds }) }, views);
18
- break;
19
- case "pause":
20
- id = input.teamId;
21
- service.pause(id, owner);
22
- break;
23
- case "close":
24
- id = input.teamId;
25
- service.close(id, owner, views);
26
- break;
27
- case "status":
28
- id = input.teamId;
29
- break;
30
- }
31
- return markdownResult(service.status(id, owner, views), "团队状态");
32
- }
33
- export function executeTeamMessage(service, input, actor, requestId) {
34
- if (input.action === "read") {
35
- const page = service.read(input.teamId, actor, input);
36
- return result(page, false, teamMessagesMarkdown(page));
37
- }
38
- const message = service.post(input.teamId, actor, requestId, input.text, input.replyTo);
39
- return markdownResult({ teamId: input.teamId, seq: message.seq, status: "stored" }, "团队消息已保存");
40
- }