@lleverage-ai/agent-sdk 0.0.3 → 0.0.4

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 (71) hide show
  1. package/README.md +87 -0
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +441 -36
  4. package/dist/agent.js.map +1 -1
  5. package/dist/hooks.d.ts +28 -1
  6. package/dist/hooks.d.ts.map +1 -1
  7. package/dist/hooks.js +40 -0
  8. package/dist/hooks.js.map +1 -1
  9. package/dist/index.d.ts +4 -2
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +3 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/middleware/apply.d.ts.map +1 -1
  14. package/dist/middleware/apply.js +8 -0
  15. package/dist/middleware/apply.js.map +1 -1
  16. package/dist/middleware/context.d.ts.map +1 -1
  17. package/dist/middleware/context.js +11 -0
  18. package/dist/middleware/context.js.map +1 -1
  19. package/dist/middleware/types.d.ts +8 -0
  20. package/dist/middleware/types.d.ts.map +1 -1
  21. package/dist/plugins/agent-teams/coordinator.d.ts +46 -0
  22. package/dist/plugins/agent-teams/coordinator.d.ts.map +1 -0
  23. package/dist/plugins/agent-teams/coordinator.js +255 -0
  24. package/dist/plugins/agent-teams/coordinator.js.map +1 -0
  25. package/dist/plugins/agent-teams/hooks.d.ts +29 -0
  26. package/dist/plugins/agent-teams/hooks.d.ts.map +1 -0
  27. package/dist/plugins/agent-teams/hooks.js +29 -0
  28. package/dist/plugins/agent-teams/hooks.js.map +1 -0
  29. package/dist/plugins/agent-teams/index.d.ts +59 -0
  30. package/dist/plugins/agent-teams/index.d.ts.map +1 -0
  31. package/dist/plugins/agent-teams/index.js +313 -0
  32. package/dist/plugins/agent-teams/index.js.map +1 -0
  33. package/dist/plugins/agent-teams/mermaid.d.ts +32 -0
  34. package/dist/plugins/agent-teams/mermaid.d.ts.map +1 -0
  35. package/dist/plugins/agent-teams/mermaid.js +66 -0
  36. package/dist/plugins/agent-teams/mermaid.js.map +1 -0
  37. package/dist/plugins/agent-teams/session-runner.d.ts +92 -0
  38. package/dist/plugins/agent-teams/session-runner.d.ts.map +1 -0
  39. package/dist/plugins/agent-teams/session-runner.js +166 -0
  40. package/dist/plugins/agent-teams/session-runner.js.map +1 -0
  41. package/dist/plugins/agent-teams/tools.d.ts +41 -0
  42. package/dist/plugins/agent-teams/tools.d.ts.map +1 -0
  43. package/dist/plugins/agent-teams/tools.js +289 -0
  44. package/dist/plugins/agent-teams/tools.js.map +1 -0
  45. package/dist/plugins/agent-teams/types.d.ts +164 -0
  46. package/dist/plugins/agent-teams/types.d.ts.map +1 -0
  47. package/dist/plugins/agent-teams/types.js +7 -0
  48. package/dist/plugins/agent-teams/types.js.map +1 -0
  49. package/dist/plugins.d.ts.map +1 -1
  50. package/dist/plugins.js +1 -0
  51. package/dist/plugins.js.map +1 -1
  52. package/dist/presets/production.d.ts.map +1 -1
  53. package/dist/presets/production.js +7 -7
  54. package/dist/presets/production.js.map +1 -1
  55. package/dist/task-manager.d.ts +15 -0
  56. package/dist/task-manager.d.ts.map +1 -1
  57. package/dist/task-manager.js +36 -0
  58. package/dist/task-manager.js.map +1 -1
  59. package/dist/testing/mock-agent.d.ts.map +1 -1
  60. package/dist/testing/mock-agent.js +6 -0
  61. package/dist/testing/mock-agent.js.map +1 -1
  62. package/dist/testing/recorder.d.ts.map +1 -1
  63. package/dist/testing/recorder.js +6 -0
  64. package/dist/testing/recorder.js.map +1 -1
  65. package/dist/tools/task.d.ts.map +1 -1
  66. package/dist/tools/task.js +6 -2
  67. package/dist/tools/task.js.map +1 -1
  68. package/dist/types.d.ts +103 -3
  69. package/dist/types.d.ts.map +1 -1
  70. package/dist/types.js.map +1 -1
  71. package/package.json +1 -1
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Headless session runner for teammate agents.
3
+ *
4
+ * Runs an AgentSession in the background without a human operator.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ import { invokeCustomHook } from "../../hooks.js";
9
+ import { AgentSession } from "../../session.js";
10
+ import { TEAM_HOOKS } from "./hooks.js";
11
+ /**
12
+ * Runs a teammate's AgentSession in the background without a human operator.
13
+ *
14
+ * The runner:
15
+ * 1. Creates an AgentSession with the agent
16
+ * 2. Sends the initial prompt
17
+ * 3. When the session waits for input, checks the coordinator mailbox
18
+ * 4. Injects messages as new prompts or waits for messages
19
+ *
20
+ * @category Agent Teams
21
+ */
22
+ export class HeadlessSessionRunner {
23
+ session;
24
+ running = false;
25
+ stopped = false;
26
+ teammateId;
27
+ coordinator;
28
+ initialPrompt;
29
+ hooks;
30
+ agent;
31
+ maxTurns;
32
+ onOutput;
33
+ onIdle;
34
+ idleTimeoutMs;
35
+ onError;
36
+ constructor(options) {
37
+ this.teammateId = options.teammateId;
38
+ this.coordinator = options.coordinator;
39
+ this.initialPrompt = options.initialPrompt;
40
+ this.hooks = options.hooks;
41
+ this.agent = options.agent;
42
+ this.maxTurns = options.maxTurns ?? 50;
43
+ this.onOutput = options.onOutput;
44
+ this.onIdle = options.onIdle;
45
+ this.idleTimeoutMs = options.idleTimeoutMs ?? 30000;
46
+ this.onError = options.onError;
47
+ this.session = new AgentSession({
48
+ agent: options.agent,
49
+ maxTurns: this.maxTurns,
50
+ });
51
+ }
52
+ /**
53
+ * Start the headless session runner.
54
+ *
55
+ * This runs the session loop, sending the initial prompt and then
56
+ * processing messages from the coordinator mailbox.
57
+ */
58
+ async start() {
59
+ if (this.running)
60
+ return;
61
+ this.running = true;
62
+ this.stopped = false;
63
+ // Send initial prompt
64
+ this.session.sendMessage(this.initialPrompt);
65
+ try {
66
+ for await (const output of this.session.run()) {
67
+ if (this.stopped)
68
+ break;
69
+ switch (output.type) {
70
+ case "text_delta":
71
+ this.onOutput?.(output.text);
72
+ break;
73
+ case "generation_complete":
74
+ this.coordinator.updateTeammateStatus(this.teammateId, "working");
75
+ break;
76
+ case "waiting_for_input": {
77
+ // Check for unread messages
78
+ const messages = this.coordinator.getMessages(this.teammateId, true);
79
+ if (messages.length > 0) {
80
+ this.session.sendMessage(this.formatMessages(messages));
81
+ }
82
+ else {
83
+ // Update status to idle
84
+ this.coordinator.updateTeammateStatus(this.teammateId, "idle");
85
+ // Fire idle hook
86
+ await invokeCustomHook(this.hooks, TEAM_HOOKS.TeammateIdle, { teammateId: this.teammateId }, this.agent);
87
+ // Wait for messages with configurable timeout
88
+ const newMessages = await this.coordinator.waitForMessage(this.teammateId, this.idleTimeoutMs);
89
+ if (this.stopped)
90
+ break;
91
+ if (newMessages && newMessages.length > 0) {
92
+ this.session.sendMessage(this.formatMessages(newMessages));
93
+ }
94
+ else {
95
+ // No messages after timeout - notify idle callback
96
+ this.onIdle?.(this.teammateId);
97
+ // Stop the session if truly idle
98
+ this.session.stop();
99
+ }
100
+ }
101
+ break;
102
+ }
103
+ case "interrupt": {
104
+ // Teammates run with bypassPermissions — interrupts are unexpected
105
+ const interruptError = new Error(`Unexpected interrupt in headless mode: ${output.interrupt.type}`);
106
+ this.reportError(interruptError);
107
+ this.session.stop();
108
+ break;
109
+ }
110
+ case "error":
111
+ this.reportError(output.error);
112
+ break;
113
+ }
114
+ }
115
+ }
116
+ finally {
117
+ this.running = false;
118
+ this.coordinator.updateTeammateStatus(this.teammateId, "stopped");
119
+ }
120
+ }
121
+ /**
122
+ * Send a message to the teammate by injecting it into the session.
123
+ */
124
+ sendMessage(content) {
125
+ if (!this.running)
126
+ return;
127
+ this.session.sendMessage(`[Message from lead]: ${content}`);
128
+ }
129
+ /**
130
+ * Stop the headless session runner.
131
+ */
132
+ stop() {
133
+ this.stopped = true;
134
+ this.session.stop();
135
+ }
136
+ /**
137
+ * Check if the runner is currently active.
138
+ */
139
+ isRunning() {
140
+ return this.running;
141
+ }
142
+ /**
143
+ * Format team messages for injection into the session.
144
+ * Marks each message as read and formats with sender info.
145
+ */
146
+ formatMessages(messages) {
147
+ return messages
148
+ .map((m) => {
149
+ this.coordinator.markRead(m.id);
150
+ return `[Message from ${m.from}]: ${m.content}`;
151
+ })
152
+ .join("\n");
153
+ }
154
+ /**
155
+ * Report an error via the onError callback, falling back to console.error.
156
+ */
157
+ reportError(error) {
158
+ if (this.onError) {
159
+ this.onError(this.teammateId, error);
160
+ }
161
+ else {
162
+ console.error(`[team:${this.teammateId}] Error:`, error);
163
+ }
164
+ }
165
+ }
166
+ //# sourceMappingURL=session-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-runner.js","sourceRoot":"","sources":["../../../src/plugins/agent-teams/session-runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA+BxC;;;;;;;;;;GAUG;AACH,MAAM,OAAO,qBAAqB;IACxB,OAAO,CAAe;IACtB,OAAO,GAAG,KAAK,CAAC;IAChB,OAAO,GAAG,KAAK,CAAC;IAChB,UAAU,CAAS;IACnB,WAAW,CAAkB;IAC7B,aAAa,CAAS;IACtB,KAAK,CAAoB;IACzB,KAAK,CAAQ;IACb,QAAQ,CAAS;IACjB,QAAQ,CAA0B;IAClC,MAAM,CAAgC;IACtC,aAAa,CAAS;IACtB,OAAO,CAA8C;IAE7D,YAAY,OAAqC;QAC/C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,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IACH,CAAC;CACF"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Team tools for lead and teammate agents.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import type { ToolSet } from "ai";
7
+ import type { Agent, HookRegistration } from "../../types.js";
8
+ import type { HeadlessSessionRunner } from "./session-runner.js";
9
+ import type { AgentRef, TeamCoordinator, TeammateDefinition } from "./types.js";
10
+ /**
11
+ * Creates the team management tools available to the team leader.
12
+ *
13
+ * These tools are dynamically added to the primary agent via
14
+ * `addRuntimeTools()` when `start_team` is called, and removed
15
+ * when `end_team` is called.
16
+ *
17
+ * @category Agent Teams
18
+ * @internal
19
+ */
20
+ export declare function createLeadTools(options: {
21
+ coordinator: TeamCoordinator;
22
+ runners: Map<string, HeadlessSessionRunner>;
23
+ teammates: TeammateDefinition[];
24
+ hooks?: HookRegistration;
25
+ agent: Agent;
26
+ spawnTeammate: (role: string, initialPrompt: string) => Promise<string>;
27
+ maxConcurrentTeammates: number;
28
+ }): ToolSet;
29
+ /**
30
+ * Creates tools available to teammates for task management and communication.
31
+ *
32
+ * @category Agent Teams
33
+ * @internal
34
+ */
35
+ export declare function createTeammateTools(options: {
36
+ teammateId: string;
37
+ coordinator: TeamCoordinator;
38
+ hooks?: HookRegistration;
39
+ agentRef: AgentRef;
40
+ }): ToolSet;
41
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/plugins/agent-teams/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAIlC,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAmBhF;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE;IACvC,WAAW,EAAE,eAAe,CAAC;IAC7B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAC5C,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACxE,sBAAsB,EAAE,MAAM,CAAC;CAChC,GAAG,OAAO,CAoLV;AAMD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,eAAe,CAAC;IAC7B,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;CACpB,GAAG,OAAO,CA8IV"}
@@ -0,0 +1,289 @@
1
+ /**
2
+ * Team tools for lead and teammate agents.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import { tool } from "ai";
7
+ import { z } from "zod";
8
+ import { invokeCustomHook } from "../../hooks.js";
9
+ import { TEAM_HOOKS } from "./hooks.js";
10
+ /**
11
+ * Resolve the agent from an AgentRef, throwing a descriptive error if unset.
12
+ * Used by teammate tools where the agent is created after tools are defined.
13
+ */
14
+ function resolveAgent(agentRef) {
15
+ if (!agentRef.current) {
16
+ throw new Error("Agent reference is not set. This is a bug in agent-teams plugin initialization.");
17
+ }
18
+ return agentRef.current;
19
+ }
20
+ // =============================================================================
21
+ // Lead Tools
22
+ // =============================================================================
23
+ /**
24
+ * Creates the team management tools available to the team leader.
25
+ *
26
+ * These tools are dynamically added to the primary agent via
27
+ * `addRuntimeTools()` when `start_team` is called, and removed
28
+ * when `end_team` is called.
29
+ *
30
+ * @category Agent Teams
31
+ * @internal
32
+ */
33
+ export function createLeadTools(options) {
34
+ const { coordinator, runners, hooks, agent } = options;
35
+ return {
36
+ team_spawn: tool({
37
+ description: "Spawn a teammate by role to work on tasks.",
38
+ inputSchema: z.object({
39
+ role: z.string().describe("The role of the teammate to spawn"),
40
+ initial_prompt: z.string().describe("Initial instructions for the teammate"),
41
+ }),
42
+ execute: async ({ role, initial_prompt }) => {
43
+ const activeCount = Array.from(runners.values()).filter((r) => r.isRunning()).length;
44
+ if (activeCount >= options.maxConcurrentTeammates) {
45
+ return `Cannot spawn: maximum concurrent teammates (${options.maxConcurrentTeammates}) reached`;
46
+ }
47
+ const def = options.teammates.find((t) => t.role === role);
48
+ if (!def) {
49
+ return `Unknown role "${role}". Available roles: ${options.teammates.map((t) => t.role).join(", ")}`;
50
+ }
51
+ const teammateId = await options.spawnTeammate(role, initial_prompt);
52
+ await invokeCustomHook(hooks, TEAM_HOOKS.TeammateSpawned, { teammateId, role }, agent);
53
+ return `Teammate "${teammateId}" (${role}) spawned and working.`;
54
+ },
55
+ }),
56
+ team_message: tool({
57
+ description: "Send a message to a specific teammate or broadcast to all teammates.",
58
+ inputSchema: z.object({
59
+ to: z.string().nullable().describe("Teammate ID to send to, or null for broadcast"),
60
+ content: z.string().describe("Message content"),
61
+ }),
62
+ execute: async ({ to, content }) => {
63
+ const msg = coordinator.sendMessage({
64
+ from: "lead",
65
+ to,
66
+ content,
67
+ });
68
+ await invokeCustomHook(hooks, TEAM_HOOKS.TeamMessageSent, { messageId: msg.id, from: "lead", to, content }, agent);
69
+ return `Message sent (${msg.id})`;
70
+ },
71
+ }),
72
+ team_shutdown: tool({
73
+ description: "Stop a specific teammate.",
74
+ inputSchema: z.object({
75
+ teammate_id: z.string().describe("ID of the teammate to stop"),
76
+ }),
77
+ execute: async ({ teammate_id }) => {
78
+ const runner = runners.get(teammate_id);
79
+ if (!runner) {
80
+ return `Teammate "${teammate_id}" not found`;
81
+ }
82
+ runner.stop();
83
+ runners.delete(teammate_id);
84
+ await invokeCustomHook(hooks, TEAM_HOOKS.TeammateStopped, { teammateId: teammate_id }, agent);
85
+ return `Teammate "${teammate_id}" stopped`;
86
+ },
87
+ }),
88
+ team_list_teammates: tool({
89
+ description: "List all teammates and their current status.",
90
+ inputSchema: z.object({}),
91
+ execute: async () => {
92
+ const teammates = coordinator.listTeammates();
93
+ if (teammates.length === 0) {
94
+ return "No active teammates";
95
+ }
96
+ return teammates
97
+ .map((t) => `${t.id} (${t.role}): ${t.status}${t.currentTaskId ? ` [task: ${t.currentTaskId}]` : ""}`)
98
+ .join("\n");
99
+ },
100
+ }),
101
+ team_task_create: tool({
102
+ description: "Create a new task for the team.",
103
+ inputSchema: z.object({
104
+ subject: z.string().describe("Brief task title"),
105
+ description: z.string().describe("Detailed task description"),
106
+ blocked_by: z
107
+ .array(z.string())
108
+ .optional()
109
+ .describe("Task IDs that must complete before this task can start"),
110
+ }),
111
+ execute: async ({ subject, description, blocked_by }) => {
112
+ const task = coordinator.createTask({
113
+ subject,
114
+ description,
115
+ status: "pending",
116
+ createdBy: "lead",
117
+ blockedBy: blocked_by ?? [],
118
+ });
119
+ await invokeCustomHook(hooks, TEAM_HOOKS.TeamTaskCreated, { taskId: task.id, subject, createdBy: "lead" }, agent);
120
+ return `Task created: ${task.id} - ${subject}`;
121
+ },
122
+ }),
123
+ team_task_list: tool({
124
+ description: "List all team tasks with optional filters.",
125
+ inputSchema: z.object({
126
+ status: z
127
+ .enum(["pending", "in_progress", "completed"])
128
+ .optional()
129
+ .describe("Filter by status"),
130
+ assignee: z.string().optional().describe("Filter by assignee teammate ID"),
131
+ }),
132
+ execute: async ({ status, assignee }) => {
133
+ const tasks = coordinator.listTasks({ status, assignee });
134
+ if (tasks.length === 0) {
135
+ return "No tasks found";
136
+ }
137
+ return tasks
138
+ .map((t) => `${t.id}: [${t.status}] ${t.subject}${t.assignee ? ` (assigned: ${t.assignee})` : ""}${t.blockedBy.length > 0 ? ` [blocked by: ${t.blockedBy.join(", ")}]` : ""}`)
139
+ .join("\n");
140
+ },
141
+ }),
142
+ team_task_get: tool({
143
+ description: "Get detailed information about a specific task.",
144
+ inputSchema: z.object({
145
+ task_id: z.string().describe("Task ID to look up"),
146
+ }),
147
+ execute: async ({ task_id }) => {
148
+ const task = coordinator.getTask(task_id);
149
+ if (!task) {
150
+ return `Task "${task_id}" not found`;
151
+ }
152
+ return JSON.stringify(task, null, 2);
153
+ },
154
+ }),
155
+ team_read_messages: tool({
156
+ description: "Read unread messages sent to the lead.",
157
+ inputSchema: z.object({}),
158
+ execute: async () => {
159
+ const messages = coordinator.getMessages("lead", true);
160
+ if (messages.length === 0) {
161
+ return "No unread messages";
162
+ }
163
+ // Mark all as read
164
+ for (const msg of messages) {
165
+ coordinator.markRead(msg.id);
166
+ }
167
+ return messages.map((m) => `[${m.from}]: ${m.content}`).join("\n");
168
+ },
169
+ }),
170
+ };
171
+ }
172
+ // =============================================================================
173
+ // Teammate Tools
174
+ // =============================================================================
175
+ /**
176
+ * Creates tools available to teammates for task management and communication.
177
+ *
178
+ * @category Agent Teams
179
+ * @internal
180
+ */
181
+ export function createTeammateTools(options) {
182
+ const { teammateId, coordinator, hooks, agentRef } = options;
183
+ return {
184
+ team_message: tool({
185
+ description: "Send a message to the lead or another teammate.",
186
+ inputSchema: z.object({
187
+ to: z
188
+ .string()
189
+ .nullable()
190
+ .describe("Recipient ID ('lead' or teammate ID, null for broadcast)"),
191
+ content: z.string().describe("Message content"),
192
+ }),
193
+ execute: async ({ to, content }) => {
194
+ const msg = coordinator.sendMessage({
195
+ from: teammateId,
196
+ to,
197
+ content,
198
+ });
199
+ await invokeCustomHook(hooks, TEAM_HOOKS.TeamMessageSent, { messageId: msg.id, from: teammateId, to, content }, resolveAgent(agentRef));
200
+ return `Message sent (${msg.id})`;
201
+ },
202
+ }),
203
+ team_list_teammates: tool({
204
+ description: "List all team members and their status.",
205
+ inputSchema: z.object({}),
206
+ execute: async () => {
207
+ const teammates = coordinator.listTeammates();
208
+ if (teammates.length === 0) {
209
+ return "No active teammates";
210
+ }
211
+ return teammates
212
+ .map((t) => `${t.id} (${t.role}): ${t.status}${t.currentTaskId ? ` [task: ${t.currentTaskId}]` : ""}`)
213
+ .join("\n");
214
+ },
215
+ }),
216
+ team_task_list: tool({
217
+ description: "List available tasks.",
218
+ inputSchema: z.object({
219
+ status: z
220
+ .enum(["pending", "in_progress", "completed"])
221
+ .optional()
222
+ .describe("Filter by status"),
223
+ }),
224
+ execute: async ({ status }) => {
225
+ const tasks = coordinator.listTasks({ status });
226
+ if (tasks.length === 0) {
227
+ return "No tasks found";
228
+ }
229
+ return tasks
230
+ .map((t) => `${t.id}: [${t.status}] ${t.subject}${t.assignee ? ` (${t.assignee})` : ""}${coordinator.isTaskBlocked(t.id) ? " [BLOCKED]" : ""}`)
231
+ .join("\n");
232
+ },
233
+ }),
234
+ team_task_claim: tool({
235
+ description: "Claim a pending unblocked task to work on.",
236
+ inputSchema: z.object({
237
+ task_id: z.string().describe("ID of the task to claim"),
238
+ }),
239
+ execute: async ({ task_id }) => {
240
+ const claimed = coordinator.claimTask(task_id, teammateId);
241
+ if (!claimed) {
242
+ const task = coordinator.getTask(task_id);
243
+ if (!task)
244
+ return `Task "${task_id}" not found`;
245
+ if (task.assignee)
246
+ return `Task "${task_id}" is already claimed by ${task.assignee}`;
247
+ if (coordinator.isTaskBlocked(task_id))
248
+ return `Task "${task_id}" is blocked by: ${task.blockedBy.join(", ")}`;
249
+ return `Cannot claim task "${task_id}"`;
250
+ }
251
+ coordinator.updateTeammateStatus(teammateId, "working", task_id);
252
+ await invokeCustomHook(hooks, TEAM_HOOKS.TeamTaskClaimed, { taskId: task_id, teammateId }, resolveAgent(agentRef));
253
+ const task = coordinator.getTask(task_id);
254
+ return `Claimed task ${task_id}: ${task?.subject}\nDescription: ${task?.description}`;
255
+ },
256
+ }),
257
+ team_task_complete: tool({
258
+ description: "Mark a claimed task as completed with results.",
259
+ inputSchema: z.object({
260
+ task_id: z.string().describe("ID of the task to complete"),
261
+ result: z.string().optional().describe("Result or output of the completed task"),
262
+ }),
263
+ execute: async ({ task_id, result }) => {
264
+ const completed = coordinator.completeTask(task_id, result);
265
+ if (!completed) {
266
+ return `Cannot complete task "${task_id}" - may not exist or already completed`;
267
+ }
268
+ coordinator.updateTeammateStatus(teammateId, "idle");
269
+ await invokeCustomHook(hooks, TEAM_HOOKS.TeamTaskCompleted, { taskId: task_id, teammateId, result }, resolveAgent(agentRef));
270
+ return `Task ${task_id} completed${result ? `: ${result}` : ""}`;
271
+ },
272
+ }),
273
+ team_read_messages: tool({
274
+ description: "Read unread messages.",
275
+ inputSchema: z.object({}),
276
+ execute: async () => {
277
+ const messages = coordinator.getMessages(teammateId, true);
278
+ if (messages.length === 0) {
279
+ return "No unread messages";
280
+ }
281
+ for (const msg of messages) {
282
+ coordinator.markRead(msg.id);
283
+ }
284
+ return messages.map((m) => `[${m.from}]: ${m.content}`).join("\n");
285
+ },
286
+ }),
287
+ };
288
+ }
289
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/plugins/agent-teams/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIxC;;;GAGG;AACH,SAAS,YAAY,CAAC,QAAkB;IACtC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC,OAAO,CAAC;AAC1B,CAAC;AAED,gFAAgF;AAChF,aAAa;AACb,gFAAgF;AAEhF;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,OAQ/B;IACC,MAAM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