agency-orchestrator 0.6.4 → 0.6.6

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/README.en.md CHANGED
@@ -211,7 +211,24 @@ analyze ──→ tech_review ──→ summary
211
211
  | Claude API | `provider: "claude"` | `ANTHROPIC_API_KEY` |
212
212
  | OpenAI | `provider: "openai"` | `OPENAI_API_KEY` |
213
213
 
214
- All API providers support custom `base_url` and `api_key`, compatible with any OpenAI-compatible API.
214
+ **Custom API (any OpenAI-compatible endpoint):**
215
+
216
+ ```bash
217
+ ao init --provider openai --model model-name \
218
+ --base-url https://your-api-endpoint/v1 \
219
+ --api-key your-key
220
+ ```
221
+
222
+ Or edit `.env` manually:
223
+
224
+ ```env
225
+ AO_PROVIDER=openai
226
+ AO_MODEL=model-name
227
+ OPENAI_BASE_URL=https://your-api-endpoint/v1
228
+ OPENAI_API_KEY=your-key
229
+ ```
230
+
231
+ > ⚠️ Use `provider: "openai"` for third-party APIs, not `provider: "ollama"`. Ollama is for local models only and does not send API keys.
215
232
 
216
233
  ## CLI Reference
217
234
 
package/README.md CHANGED
@@ -210,7 +210,33 @@ analyze ──→ tech_review ──→ summary
210
210
  | Claude API | `provider: "claude"` | `ANTHROPIC_API_KEY` |
211
211
  | OpenAI | `provider: "openai"` | `OPENAI_API_KEY` |
212
212
 
213
- 所有 API 提供商支持自定义 `base_url` 和 `api_key`,兼容智谱、月之暗面等 OpenAI 兼容 API
213
+ **自定义 API(火山引擎、智谱、月之暗面、硅基流动等 OpenAI 兼容 API):**
214
+
215
+ ```bash
216
+ ao init --provider openai --model 模型名 \
217
+ --base-url https://你的API地址/v1 \
218
+ --api-key 你的key
219
+ ```
220
+
221
+ 或手动编辑 `.env`:
222
+
223
+ ```env
224
+ AO_PROVIDER=openai
225
+ AO_MODEL=模型名
226
+ OPENAI_BASE_URL=https://你的API地址/v1
227
+ OPENAI_API_KEY=你的key
228
+ ```
229
+
230
+ 常见示例:
231
+
232
+ | 平台 | base_url | model |
233
+ |------|----------|-------|
234
+ | 火山引擎 | `https://ark.cn-beijing.volces.com/api/coding/v3` | `ark-code-latest` |
235
+ | 智谱 AI | `https://open.bigmodel.cn/api/paas/v4` | `glm-4` |
236
+ | 硅基流动 | `https://api.siliconflow.cn/v1` | `deepseek-ai/DeepSeek-V3` |
237
+ | 月之暗面 | `https://api.moonshot.cn/v1` | `moonshot-v1-8k` |
238
+
239
+ > ⚠️ 注意:这些平台请使用 `provider: "openai"`,不要用 `provider: "ollama"`。Ollama 仅用于本地模型,不发送 API Key。
214
240
 
215
241
  ## CLI 命令
216
242
 
@@ -66,6 +66,9 @@ function buildComposeSystemPromptEn(catalog, options) {
66
66
  const autoRun = options?.autoRun ?? false;
67
67
  const provider = options?.provider || 'deepseek';
68
68
  const model = options?.model;
69
+ const isLocal = provider === 'ollama';
70
+ const maxTokens = isLocal ? 8192 : 4096;
71
+ const timeoutMs = isLocal ? 600000 : 120000;
69
72
  const inputsSection = autoRun
70
73
  ? `
71
74
  ## Important: Direct Run Mode
@@ -109,8 +112,8 @@ agents_dir: "agency-agents"
109
112
  llm:
110
113
  provider: ${provider}
111
114
  ${model ? `model: ${model}` : ''}
112
- max_tokens: 4096
113
- timeout: 120000
115
+ max_tokens: ${maxTokens}
116
+ timeout: ${timeoutMs}
114
117
  retry: 2
115
118
 
116
119
  concurrency: 2
@@ -155,6 +158,9 @@ function buildComposeSystemPromptZh(catalog, options) {
155
158
  const autoRun = options?.autoRun ?? false;
156
159
  const provider = options?.provider || 'deepseek';
157
160
  const model = options?.model;
161
+ const isLocal = provider === 'ollama';
162
+ const maxTokens = isLocal ? 8192 : 4096;
163
+ const timeoutMs = isLocal ? 600000 : 120000;
158
164
  const inputsSection = autoRun
159
165
  ? `
160
166
  ## 重要:直接运行模式
@@ -198,8 +204,8 @@ agents_dir: "agency-agents-zh"
198
204
  llm:
199
205
  provider: ${provider}
200
206
  ${model ? `model: ${model}` : ''}
201
- max_tokens: 4096
202
- timeout: 120000
207
+ max_tokens: ${maxTokens}
208
+ timeout: ${timeoutMs}
203
209
  retry: 2
204
210
 
205
211
  concurrency: 2
@@ -5,6 +5,8 @@ export class OllamaConnector {
5
5
  this.baseUrl = raw.replace(/\/+$/, '');
6
6
  }
7
7
  async chat(systemPrompt, userMessage, config) {
8
+ const numPredict = config.max_tokens || 8192;
9
+ const numCtx = estimateNumCtx(systemPrompt, userMessage, numPredict);
8
10
  let response;
9
11
  try {
10
12
  response = await fetch(`${this.baseUrl}/api/chat`, {
@@ -18,7 +20,8 @@ export class OllamaConnector {
18
20
  ],
19
21
  stream: false,
20
22
  options: {
21
- num_predict: config.max_tokens || 2048,
23
+ num_predict: numPredict,
24
+ num_ctx: numCtx,
22
25
  },
23
26
  }),
24
27
  });
@@ -47,3 +50,20 @@ export class OllamaConnector {
47
50
  };
48
51
  }
49
52
  }
53
+ /**
54
+ * 根据实际输入长度自适应计算 num_ctx,避免 Ollama 默认 2048 截断,
55
+ * 同时小输入不分配多余显存,提升推理速度。
56
+ */
57
+ function estimateNumCtx(systemPrompt, userMessage, numPredict) {
58
+ const text = systemPrompt + userMessage;
59
+ // CJK 字符约 1.5-2 token/字,ASCII 约 0.25 token/字,按实际比例加权
60
+ let tokens = 0;
61
+ for (let i = 0; i < text.length; i++) {
62
+ tokens += text.charCodeAt(i) > 0x7F ? 1.5 : 0.3;
63
+ }
64
+ const estimatedInputTokens = Math.ceil(tokens);
65
+ const buffer = 512;
66
+ const computed = estimatedInputTokens + numPredict + buffer;
67
+ // 下限 4096(部分模型低于此值行为异常),上限 131072(主流模型极限)
68
+ return Math.min(Math.max(computed, 4096), 131072);
69
+ }
@@ -10,7 +10,8 @@ export async function executeDAG(dag, options) {
10
10
  const startTime = Date.now();
11
11
  const stepResults = [];
12
12
  const isCLI = llmConfig.provider.endsWith('-cli') || llmConfig.provider === 'claude-code';
13
- const timeout = llmConfig.timeout || (isCLI ? 600_000 : 120_000); // CLI 10分钟(gateway/MiniMax 等可能单步 5+ 分钟),API 2分钟
13
+ const isLocal = llmConfig.provider === 'ollama';
14
+ const timeout = llmConfig.timeout || (isCLI ? 600_000 : isLocal ? 600_000 : 120_000);
14
15
  const maxRetry = llmConfig.retry ?? 5;
15
16
  // CLI provider 强制串行:共享同一账户额度,并发会触发限速反而更慢
16
17
  const effectiveConcurrency = isCLI ? 1 : concurrency;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agency-orchestrator",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "description": "Multi-agent YAML workflow engine — 211 AI roles, auto DAG parallelism, zero code. One sentence → multiple AI roles collaborate → complete plan in minutes. 10 LLM providers, 7 need no API key.",
5
5
  "keywords": [
6
6
  "multi-agent",