multiclaws 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -89,7 +89,7 @@ function createTools(getService) {
89
89
  };
90
90
  const multiclawsDelegate = {
91
91
  name: "multiclaws_delegate",
92
- description: "Delegate a task to a remote A2A agent.",
92
+ description: "Delegate a task to a remote A2A agent. Returns immediately with a taskId (async). The result will be pushed as a message when the task completes. Use multiclaws_task_status to poll progress.",
93
93
  parameters: {
94
94
  type: "object",
95
95
  additionalProperties: false,
@@ -193,7 +193,7 @@ function createTools(getService) {
193
193
  };
194
194
  const multiclawsTeamMembers = {
195
195
  name: "multiclaws_team_members",
196
- description: "List all members of a team.",
196
+ description: "List all members of a team. If teamId is omitted, returns all teams and their members.",
197
197
  parameters: {
198
198
  type: "object",
199
199
  additionalProperties: false,
@@ -51,6 +51,8 @@ export declare class MulticlawsService extends EventEmitter {
51
51
  agentUrl: string;
52
52
  task: string;
53
53
  }): Promise<DelegateTaskResult>;
54
+ private runDelegatedTask;
55
+ private notifyTaskCompletion;
54
56
  getTaskStatus(taskId: string): import("../task/tracker").TaskRecord | null;
55
57
  getProfile(): Promise<AgentProfile>;
56
58
  setProfile(patch: {
@@ -73,6 +75,11 @@ export declare class MulticlawsService extends EventEmitter {
73
75
  listTeamMembers(teamId?: string): Promise<{
74
76
  team: TeamRecord;
75
77
  members: TeamMember[];
78
+ } | {
79
+ teams: Array<{
80
+ team: TeamRecord;
81
+ members: TeamMember[];
82
+ }>;
76
83
  } | null>;
77
84
  private mountTeamRoutes;
78
85
  private broadcastProfileToTeams;
@@ -205,22 +205,63 @@ class MulticlawsService extends node_events_1.EventEmitter {
205
205
  task: params.task,
206
206
  });
207
207
  this.taskTracker.update(track.taskId, { status: "running" });
208
+ // Fire-and-forget: run in background, notify user when done
209
+ void this.runDelegatedTask({
210
+ taskId: track.taskId,
211
+ agentRecord,
212
+ task: params.task,
213
+ });
214
+ return { taskId: track.taskId, status: "running" };
215
+ }
216
+ async runDelegatedTask(params) {
208
217
  try {
209
- const client = await this.createA2AClient(agentRecord);
218
+ const client = await this.createA2AClient(params.agentRecord);
210
219
  const result = await client.sendMessage({
211
220
  message: {
212
221
  kind: "message",
213
222
  role: "user",
214
223
  parts: [{ kind: "text", text: params.task }],
215
- messageId: track.taskId,
224
+ messageId: params.taskId,
216
225
  },
217
226
  });
218
- return this.processTaskResult(track.taskId, result);
227
+ const taskResult = this.processTaskResult(params.taskId, result);
228
+ await this.notifyTaskCompletion(taskResult);
219
229
  }
220
230
  catch (err) {
221
231
  const errorMsg = err instanceof Error ? err.message : String(err);
222
- this.taskTracker.update(track.taskId, { status: "failed", error: errorMsg });
223
- return { taskId: track.taskId, status: "failed", error: errorMsg };
232
+ this.taskTracker.update(params.taskId, { status: "failed", error: errorMsg });
233
+ await this.notifyTaskCompletion({ taskId: params.taskId, status: "failed", error: errorMsg });
234
+ }
235
+ }
236
+ async notifyTaskCompletion(result) {
237
+ if (!this.options.gatewayConfig)
238
+ return;
239
+ let message;
240
+ if (result.status === "completed") {
241
+ const resultText = typeof result.output === "string" ? result.output : JSON.stringify(result.output ?? "");
242
+ message = [
243
+ `✅ **任务完成** (taskId: \`${result.taskId}\`)`,
244
+ "",
245
+ resultText,
246
+ ].join("\n");
247
+ }
248
+ else {
249
+ message = [
250
+ `❌ **任务失败** (taskId: \`${result.taskId}\`)`,
251
+ "",
252
+ result.error ?? "unknown error",
253
+ ].join("\n");
254
+ }
255
+ try {
256
+ await (0, gateway_client_1.invokeGatewayTool)({
257
+ gateway: this.options.gatewayConfig,
258
+ tool: "message",
259
+ args: { action: "send", message },
260
+ timeoutMs: 5_000,
261
+ });
262
+ }
263
+ catch {
264
+ this.log("warn", `[multiclaws] failed to notify task completion: ${result.taskId}`);
224
265
  }
225
266
  }
226
267
  getTaskStatus(taskId) {
@@ -385,12 +426,18 @@ class MulticlawsService extends node_events_1.EventEmitter {
385
426
  this.log("info", `left team ${team.teamId}`);
386
427
  }
387
428
  async listTeamMembers(teamId) {
388
- const team = teamId
389
- ? await this.teamStore.getTeam(teamId)
390
- : await this.teamStore.getFirstTeam();
391
- if (!team)
429
+ if (teamId) {
430
+ const team = await this.teamStore.getTeam(teamId);
431
+ if (!team)
432
+ return null;
433
+ return { team, members: team.members };
434
+ }
435
+ const all = await this.teamStore.listTeams();
436
+ if (all.length === 0)
392
437
  return null;
393
- return { team, members: team.members };
438
+ if (all.length === 1)
439
+ return { team: all[0], members: all[0].members };
440
+ return { teams: all.map((team) => ({ team, members: team.members })) };
394
441
  }
395
442
  /* ---------------------------------------------------------------- */
396
443
  /* Team REST routes */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multiclaws",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "MultiClaws plugin for OpenClaw collaboration via A2A protocol",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",