agency-orchestrator 0.4.1 → 0.4.2

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.
@@ -2,7 +2,7 @@ import type { LLMConnector, LLMResult, LLMConfig } from '../types.js';
2
2
  export interface CLIConnectorConfig {
3
3
  /** CLI 命令名 */
4
4
  command: string;
5
- /** 显示名称(用于错误消���) */
5
+ /** 显示名称(用于错误消息) */
6
6
  displayName: string;
7
7
  /** 构建命令行参数 */
8
8
  buildArgs: (fullPrompt: string, config: LLMConfig) => string[];
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * CLI Connector 通用基类
3
- * 通过本地 AI CLI 工具调用,使用用户的订阅���度,无需 API key
3
+ * 通过本地 AI CLI 工具调用,使用用户的订阅额度,无需 API key
4
4
  *
5
- * 支持: Claude Code / Gemini CLI / Copilot CLI / Codex CLI
5
+ * 支持: Claude Code / Gemini CLI / Copilot CLI / Codex CLI / OpenClaw CLI
6
6
  */
7
7
  import { execFile } from 'node:child_process';
8
8
  import { promisify } from 'node:util';
@@ -19,7 +19,7 @@ export class CLIBaseConnector {
19
19
  const args = this.cfg.buildArgs(fullPrompt, config);
20
20
  const timeout = config.timeout || 180000;
21
21
  try {
22
- const { stdout } = await execFileAsync(this.cfg.command, args, {
22
+ const { stdout, stderr } = await execFileAsync(this.cfg.command, args, {
23
23
  timeout,
24
24
  maxBuffer: 10 * 1024 * 1024,
25
25
  env: { ...process.env },
@@ -27,6 +27,9 @@ export class CLIBaseConnector {
27
27
  const content = this.cfg.parseOutput
28
28
  ? this.cfg.parseOutput(stdout)
29
29
  : stdout.trim();
30
+ if (!content && stderr) {
31
+ throw new Error(`${this.cfg.displayName} 返回空内容,stderr: ${stderr.slice(0, 500)}`);
32
+ }
30
33
  return {
31
34
  content,
32
35
  usage: {
@@ -37,7 +40,12 @@ export class CLIBaseConnector {
37
40
  }
38
41
  catch (err) {
39
42
  if (err.killed || err.signal === 'SIGTERM') {
40
- throw new Error(`${this.cfg.displayName} 超时 (${timeout}ms)`);
43
+ throw new Error(`${this.cfg.displayName} 超时 (${timeout / 1000}s),可在 YAML 中设置 timeout 增加等待时间`);
44
+ }
45
+ // 区分"未安装"和"执行失败"
46
+ if (err.code === 'ENOENT') {
47
+ throw new Error(`找不到 ${this.cfg.command} 命令,请先安装 ${this.cfg.displayName}\n` +
48
+ `参考: https://github.com/jnMetaCode/agency-orchestrator#llm-配置`);
41
49
  }
42
50
  throw new Error(`${this.cfg.displayName} 调用失败: ${err.message}`);
43
51
  }
@@ -4,6 +4,10 @@
4
4
  *
5
5
  * 安装: npm install -g openclaw@latest
6
6
  * 认证: openclaw onboard --install-daemon(引导配置)
7
+ *
8
+ * 注意: openclaw agent 必须指定 --agent <id>,否则会报
9
+ * "Pass --to <E.164>, --session-id, or --agent to choose a session"
10
+ * 默认使用 "main" agent,可通过 YAML model 字段或 OPENCLAW_AGENT 环境变量覆盖
7
11
  */
8
12
  import { CLIBaseConnector } from './cli-base.js';
9
13
  export declare class OpenClawCLIConnector extends CLIBaseConnector {
@@ -4,6 +4,10 @@
4
4
  *
5
5
  * 安装: npm install -g openclaw@latest
6
6
  * 认证: openclaw onboard --install-daemon(引导配置)
7
+ *
8
+ * 注意: openclaw agent 必须指定 --agent <id>,否则会报
9
+ * "Pass --to <E.164>, --session-id, or --agent to choose a session"
10
+ * 默认使用 "main" agent,可通过 YAML model 字段或 OPENCLAW_AGENT 环境变量覆盖
7
11
  */
8
12
  import { CLIBaseConnector } from './cli-base.js';
9
13
  export class OpenClawCLIConnector extends CLIBaseConnector {
@@ -11,8 +15,22 @@ export class OpenClawCLIConnector extends CLIBaseConnector {
11
15
  super({
12
16
  command: 'openclaw',
13
17
  displayName: 'OpenClaw CLI',
14
- buildArgs: (prompt, _config) => {
15
- return ['agent', '--message', prompt];
18
+ buildArgs: (prompt, config) => {
19
+ // model 字段复用为 agent id,例如 model: "my-agent"
20
+ const agentId = config.model || process.env.OPENCLAW_AGENT || 'main';
21
+ return ['agent', '--agent', agentId, '--message', prompt];
22
+ },
23
+ parseOutput: (stdout) => {
24
+ // OpenClaw 的 stdout 可能混入插件日志(如 ShellWard 的 ANSI 彩色输出)
25
+ // 过滤掉 [plugins] 前缀行和 ANSI 控制码行
26
+ return stdout
27
+ .split('\n')
28
+ .filter(line => {
29
+ const clean = line.replace(/\x1b\[[0-9;]*m/g, '').trim();
30
+ return clean && !clean.startsWith('[plugins]');
31
+ })
32
+ .join('\n')
33
+ .trim();
16
34
  },
17
35
  });
18
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agency-orchestrator",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Multi-agent YAML workflow engine — 186 AI roles, auto DAG parallelism, zero code. Use your existing subscription (Claude Max / ChatGPT Plus / Copilot / Gemini free) — no API key needed. Industry first.",
5
5
  "keywords": [
6
6
  "multi-agent",
@@ -5,7 +5,7 @@ agents_dir: "agency-agents-zh"
5
5
 
6
6
  llm:
7
7
  provider: "claude"
8
- model: "claude-sonnet-4-6"
8
+ model: "claude-sonnet-4-20250514"
9
9
  max_tokens: 4096
10
10
 
11
11
  concurrency: 2