multiclaws 0.4.14 → 0.4.16

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/infra/frp.js CHANGED
@@ -362,8 +362,9 @@ class FrpTunnelManager {
362
362
  (0, node_child_process_1.execSync)(`tar -xzf "${archivePath}" -C "${downloadDir}"`, { stdio: "ignore" });
363
363
  }
364
364
  else {
365
- // Windows: tar does not support .zip; use PowerShell's Expand-Archive instead
366
- (0, node_child_process_1.execSync)(`powershell -NoProfile -Command "Expand-Archive -LiteralPath '${archivePath}' -DestinationPath '${downloadDir}' -Force"`, { stdio: "ignore" });
365
+ // Windows: suppress progress bar to prevent silent failure in headless environments;
366
+ // use stdio:"pipe" so execSync captures errors if PowerShell exits non-zero
367
+ (0, node_child_process_1.execSync)(`powershell -NoProfile -Command "$ProgressPreference = 'SilentlyContinue'; Expand-Archive -LiteralPath '${archivePath}' -DestinationPath '${downloadDir}' -Force"`, { stdio: "pipe" });
367
368
  }
368
369
  // Move binary to target
369
370
  const extractedBinary = node_path_1.default.join(downloadDir, archiveName, binaryName);
@@ -27,17 +27,20 @@ export declare class OpenClawAgentExecutor implements AgentExecutor {
27
27
  constructor(options: A2AAdapterOptions);
28
28
  execute(context: RequestContext, eventBus: ExecutionEventBus): Promise<void>;
29
29
  /**
30
- * Poll sessions_history until the subagent produces a final assistant message.
31
- * Uses backoff: 2s, 3s, 4s, then 5s intervals.
30
+ * Poll sessions_history until the subagent session completes.
31
+ * Collects ALL assistant text messages and returns them joined.
32
32
  */
33
33
  private waitForCompletion;
34
34
  /**
35
- * Extract the final assistant response from session history.
35
+ * Extract all assistant text from session history once the session is complete.
36
36
  * Returns null if the session is still running.
37
+ * Returns all assistant text messages joined (not just the last one).
37
38
  *
38
39
  * Gateway /tools/invoke returns: { content: [...], details: { messages: [...], isComplete?: boolean } }
39
40
  */
40
41
  private extractCompletedResult;
42
+ /** Extract text content from a single history message. */
43
+ private extractTextFromHistoryMessage;
41
44
  cancelTask(taskId: string, eventBus: ExecutionEventBus): Promise<void>;
42
45
  updateGatewayConfig(config: GatewayConfig): void;
43
46
  private publishMessage;
@@ -103,14 +103,13 @@ class OpenClawAgentExecutor {
103
103
  eventBus.finished();
104
104
  }
105
105
  /**
106
- * Poll sessions_history until the subagent produces a final assistant message.
107
- * Uses backoff: 2s, 3s, 4s, then 5s intervals.
106
+ * Poll sessions_history until the subagent session completes.
107
+ * Collects ALL assistant text messages and returns them joined.
108
108
  */
109
109
  async waitForCompletion(sessionKey, timeoutMs) {
110
110
  const gateway = this.gatewayConfig;
111
111
  const startTime = Date.now();
112
112
  let attempt = 0;
113
- // Start aggressive, max out at 500ms to minimize result latency
114
113
  const pollDelays = [100, 200, 300, 500];
115
114
  while (Date.now() - startTime < timeoutMs) {
116
115
  const delay = pollDelays[Math.min(attempt, pollDelays.length - 1)];
@@ -122,7 +121,7 @@ class OpenClawAgentExecutor {
122
121
  tool: "sessions_history",
123
122
  args: {
124
123
  sessionKey,
125
- limit: 20,
124
+ limit: 50,
126
125
  includeTools: false,
127
126
  },
128
127
  timeoutMs: 8_000,
@@ -140,8 +139,9 @@ class OpenClawAgentExecutor {
140
139
  throw new Error(`task timed out after ${Math.round(timeoutMs / 1000)}s waiting for subagent`);
141
140
  }
142
141
  /**
143
- * Extract the final assistant response from session history.
142
+ * Extract all assistant text from session history once the session is complete.
144
143
  * Returns null if the session is still running.
144
+ * Returns all assistant text messages joined (not just the last one).
145
145
  *
146
146
  * Gateway /tools/invoke returns: { content: [...], details: { messages: [...], isComplete?: boolean } }
147
147
  */
@@ -155,34 +155,51 @@ class OpenClawAgentExecutor {
155
155
  const messages = (details.messages ?? []);
156
156
  if (messages.length === 0)
157
157
  return null;
158
- // If no explicit flag, check the last message for signs of ongoing execution
158
+ // If no explicit isComplete flag, use heuristic: check if the session is still executing
159
159
  if (details.isComplete === undefined) {
160
160
  const lastMsg = messages[messages.length - 1];
161
161
  if (lastMsg && Array.isArray(lastMsg.content)) {
162
162
  const content = lastMsg.content;
163
163
  const hasToolCalls = content.some((c) => c?.type === "toolCall" || c?.type === "tool_use");
164
+ // If the last message only has tool calls (no text), still running
164
165
  const hasText = content.some((c) => c?.type === "text" && typeof c.text === "string" && c.text.trim());
165
166
  if (hasToolCalls && !hasText)
166
167
  return null;
167
168
  }
169
+ // If the last message is a user message, the agent hasn't responded yet
170
+ const lastMsg2 = messages[messages.length - 1];
171
+ if (lastMsg2?.role === "user")
172
+ return null;
168
173
  }
169
- // Walk backwards to find the last assistant message with text content
170
- for (let i = messages.length - 1; i >= 0; i--) {
171
- const msg = messages[i];
174
+ // Session is complete collect ALL assistant text messages in order
175
+ const allTexts = [];
176
+ for (const msg of messages) {
172
177
  if (msg.role !== "assistant")
173
178
  continue;
174
- const content = msg.content;
175
- if (typeof content === "string" && content.trim()) {
176
- return content;
177
- }
178
- if (Array.isArray(content)) {
179
- const parts = content;
180
- const textParts = parts
181
- .filter((c) => c?.type === "text" && typeof c.text === "string" && c.text.trim())
182
- .map((c) => c.text);
183
- if (textParts.length > 0) {
184
- return textParts.join("\n");
185
- }
179
+ const text = this.extractTextFromHistoryMessage(msg);
180
+ if (text)
181
+ allTexts.push(text);
182
+ }
183
+ // Session completed but no text output — return a marker instead of null
184
+ // to avoid infinite polling / timeout
185
+ if (allTexts.length === 0) {
186
+ return "(task completed with no text output)";
187
+ }
188
+ return allTexts.join("\n\n");
189
+ }
190
+ /** Extract text content from a single history message. */
191
+ extractTextFromHistoryMessage(msg) {
192
+ const content = msg.content;
193
+ if (typeof content === "string" && content.trim()) {
194
+ return content;
195
+ }
196
+ if (Array.isArray(content)) {
197
+ const parts = content;
198
+ const textParts = parts
199
+ .filter((c) => c?.type === "text" && typeof c.text === "string" && c.text.trim())
200
+ .map((c) => c.text);
201
+ if (textParts.length > 0) {
202
+ return textParts.join("\n");
186
203
  }
187
204
  }
188
205
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multiclaws",
3
- "version": "0.4.14",
3
+ "version": "0.4.16",
4
4
  "description": "MultiClaws plugin for OpenClaw collaboration via A2A protocol",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -137,7 +137,9 @@ multiclaws_profile_show()
137
137
  → 自动同步所有团队成员
138
138
  ```
139
139
 
140
- ### 智能委派
140
+ ### 智能委派(单轮)
141
+
142
+ 适用于一次性任务,不需要来回沟通。
141
143
 
142
144
  ```
143
145
  1. multiclaws_agents() — 列出智能体,读 bio
@@ -151,6 +153,53 @@ multiclaws_profile_show()
151
153
  - 匹配数据需求(如「检查 API 代码」→ bio 中有该代码库的智能体)
152
154
  - 多个匹配时选最具体的
153
155
 
156
+ ### 多轮协作(需要来回沟通)
157
+
158
+ 适用于需要协商、确认、多次沟通才能完成的任务(如约会议、对需求、联合调试)。
159
+
160
+ **根据用户是否需要看到中间过程,选择以下两种模式:**
161
+
162
+ #### 模式 A:交互式多轮(推荐 — 用户能看到每一步进展)
163
+
164
+ 主 AI 直接处理多轮沟通,每轮之间向用户汇报进展。
165
+
166
+ ```
167
+ 用户: "帮我和小明约明天下午的会议"
168
+
169
+ 1. multiclaws_agents() — 找到小明
170
+ 2. multiclaws_delegate(agentUrl="小明", task="我想约明天下午开会,你什么时候有空?")
171
+ 3. → 向用户汇报: "小明说明天下午 3 点和 4 点都可以"
172
+ 4.(用户说"约 3 点"或 AI 自行判断)
173
+ 5. multiclaws_delegate(agentUrl="小明", task="确认明天下午 3 点开会")
174
+ 6. → 向用户汇报: "已和小明确认明天下午 3 点"
175
+ ```
176
+
177
+ **关键规则:**
178
+ - 每次 `multiclaws_delegate` 返回后,**立即向用户汇报结果**,不要等全部完成
179
+ - 如果能自行判断下一步(如对方给了选项,用户已表达偏好),直接继续
180
+ - 如果需要用户决策(如对方提出多个方案),暂停并询问用户
181
+ - 协商未达成一致时,继续发 `multiclaws_delegate`,最多 5 轮
182
+
183
+ #### 模式 B:自主式多轮(AI 全自动完成,只报告最终结果)
184
+
185
+ 适用于用户明确授权自主处理、不需要看中间过程的场景。使用 `sessions_spawn` 启动子 agent,子 agent 自主完成全部沟通。
186
+
187
+ ```
188
+ 用户: "帮我和小明约个会,我明天下午都行,你自己搞定"
189
+
190
+ 1. sessions_spawn(task="联系小明协商明天下午的会议时间。我这边下午都可以。
191
+ 使用 multiclaws_delegate 与小明沟通,协商确定具体时间。
192
+ 完成后汇报最终结果。", mode="run")
193
+ 2.(子 agent 自主多轮沟通)
194
+ 3. 子 agent 完成 → announce 回父 agent → 向用户报告最终结果
195
+ ```
196
+
197
+ **何时用模式 B:**
198
+ - 用户明确说「你自己搞定」「自动处理」「不用问我」
199
+ - 任务参数已完全明确,不需要用户中间决策
200
+
201
+ **默认用模式 A。** 除非用户明确要求自主处理,否则始终用交互式模式,确保用户看到每一步。
202
+
154
203
  ---
155
204
 
156
205
  ## 网络配置