w-dispatch-ai 1.0.3 → 1.0.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/README.md +153 -43
- package/dist/w-dispatch-ai.umd.js +2 -2
- package/dist/w-dispatch-ai.umd.js.map +1 -1
- package/docs/WDispatchAi.mjs.html +8 -4
- package/docs/adapters.mjs.html +36 -2
- package/docs/dfTimeoutMs.mjs.html +98 -0
- package/docs/dispatchAi.mjs.html +2 -2
- package/docs/dispatchAiFallback.mjs.html +55 -16
- package/docs/dispatchAiWkf.mjs.html +42 -8
- package/docs/dispatchAntigravity.mjs.html +23 -12
- package/docs/dispatchApiOpenaiCompat.mjs.html +40 -6
- package/docs/dispatchClaude.mjs.html +17 -4
- package/docs/dispatchCodex.mjs.html +16 -3
- package/docs/dispatchOpencode.mjs.html +16 -3
- package/docs/getCliArgs.mjs.html +2 -2
- package/docs/getErrorResult.mjs.html +2 -2
- package/docs/global.html +511 -66
- package/docs/index.html +2 -2
- package/docs/resolveProviders.mjs.html +189 -0
- package/docs/wkf_callAiWithFallback.mjs.html +22 -11
- package/docs/wkf_extractJsonLoose.mjs.html +2 -2
- package/docs/wkf_runFanout.mjs.html +7 -7
- package/docs/wkf_runFanoutPipeline.mjs.html +7 -7
- package/docs/wkf_runRolePipeline.mjs.html +6 -6
- package/g.mjs +30 -23
- package/package.json +1 -1
- package/src/WDispatchAi.mjs +6 -2
- package/src/adapters.mjs +34 -0
- package/src/dfTimeoutMs.mjs +26 -0
- package/src/dispatchAiFallback.mjs +53 -14
- package/src/dispatchAiWkf.mjs +40 -6
- package/src/dispatchAntigravity.mjs +21 -10
- package/src/dispatchApiOpenaiCompat.mjs +38 -4
- package/src/dispatchClaude.mjs +15 -2
- package/src/dispatchCodex.mjs +14 -1
- package/src/dispatchOpencode.mjs +14 -1
- package/src/providers.mjs +133 -0
- package/src/resolveProviders.mjs +117 -0
- package/src/wkf/callAiWithFallback.mjs +20 -9
- package/src/wkf/runFanout.mjs +5 -5
- package/src/wkf/runFanoutPipeline.mjs +5 -5
- package/src/wkf/runRolePipeline.mjs +4 -4
- package/test/tools/fakeServerForApiTest.mjs +14 -0
- package/test/unit-WDispatchAi.test.mjs +9 -3
- package/test/unit-dispatchAi.test.mjs +1 -1
- package/test/unit-dispatchAiFallback.test.mjs +25 -0
- package/test/unit-dispatchAntigravity.test.mjs +25 -5
- package/test/unit-dispatchApiOpenaiCompat.test.mjs +31 -0
- package/test/unit-providers.test.mjs +66 -0
- package/test/unit-resolveProviders.test.mjs +85 -0
package/docs/global.html
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<nav >
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#WDispatchAi">WDispatchAi</a></li><li><a href="global.html#adapters">adapters</a></li><li><a href="global.html#buildChain">buildChain</a></li><li><a href="global.html#buildValidator">buildValidator</a></li><li><a href="global.html#callAiWithFallback">callAiWithFallback</a></li><li><a href="global.html#callOnce">callOnce</a></li><li><a href="global.html#defaultIntegratePrompt">defaultIntegratePrompt</a></li><li><a href="global.html#dispatchAi">dispatchAi</a></li><li><a href="global.html#dispatchAiFallback">dispatchAiFallback</a></li><li><a href="global.html#dispatchAiWkf">dispatchAiWkf</a></li><li><a href="global.html#dispatchAntigravity">dispatchAntigravity</a></li><li><a href="global.html#dispatchApiOpenaiCompat">dispatchApiOpenaiCompat</a></li><li><a href="global.html#dispatchClaude">dispatchClaude</a></li><li><a href="global.html#dispatchCodex">dispatchCodex</a></li><li><a href="global.html#dispatchOpencode">dispatchOpencode</a></li><li><a href="global.html#extractJsonLoose">extractJsonLoose</a></li><li><a href="global.html#getCliArgs">getCliArgs</a></li><li><a href="global.html#getErrorResult">getErrorResult</a></li><li><a href="global.html#isKeyIndependentFail">isKeyIndependentFail</a></li><li><a href="global.html#runFanout">runFanout</a></li><li><a href="global.html#runFanoutPipeline">runFanoutPipeline</a></li><li><a href="global.html#runRolePipeline">runRolePipeline</a></li></ul>
|
|
32
|
+
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#WDispatchAi">WDispatchAi</a></li><li><a href="global.html#adapters">adapters</a></li><li><a href="global.html#buildChain">buildChain</a></li><li><a href="global.html#buildValidator">buildValidator</a></li><li><a href="global.html#callAiWithFallback">callAiWithFallback</a></li><li><a href="global.html#callOnce">callOnce</a></li><li><a href="global.html#defaultIntegratePrompt">defaultIntegratePrompt</a></li><li><a href="global.html#dfTimeoutMs">dfTimeoutMs</a></li><li><a href="global.html#dispatchAi">dispatchAi</a></li><li><a href="global.html#dispatchAiFallback">dispatchAiFallback</a></li><li><a href="global.html#dispatchAiWkf">dispatchAiWkf</a></li><li><a href="global.html#dispatchAntigravity">dispatchAntigravity</a></li><li><a href="global.html#dispatchApiOpenaiCompat">dispatchApiOpenaiCompat</a></li><li><a href="global.html#dispatchClaude">dispatchClaude</a></li><li><a href="global.html#dispatchCodex">dispatchCodex</a></li><li><a href="global.html#dispatchOpencode">dispatchOpencode</a></li><li><a href="global.html#extractJsonLoose">extractJsonLoose</a></li><li><a href="global.html#getCliArgs">getCliArgs</a></li><li><a href="global.html#getErrorResult">getErrorResult</a></li><li><a href="global.html#isKeyIndependentFail">isKeyIndependentFail</a></li><li><a href="global.html#resolveProviders">resolveProviders</a></li><li><a href="global.html#runFanout">runFanout</a></li><li><a href="global.html#runFanoutPipeline">runFanoutPipeline</a></li><li><a href="global.html#runRolePipeline">runRolePipeline</a></li></ul>
|
|
33
33
|
|
|
34
34
|
</nav>
|
|
35
35
|
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
|
|
141
141
|
<dt class="tag-source">Source:</dt>
|
|
142
142
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
143
|
-
<a href="WDispatchAi.mjs.html">WDispatchAi.mjs</a>, <a href="WDispatchAi.mjs.html#
|
|
143
|
+
<a href="WDispatchAi.mjs.html">WDispatchAi.mjs</a>, <a href="WDispatchAi.mjs.html#line35">line 35</a>
|
|
144
144
|
</li></ul></dd>
|
|
145
145
|
|
|
146
146
|
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
|
|
192
192
|
<h5 class="h5-examples">Example</h5>
|
|
193
193
|
|
|
194
|
-
<pre class="prettyprint"><code>詳見dispatchAi、dispatchAiFallback、dispatchAiWkf、dispatchOpencode、dispatchClaude、dispatchCodex、dispatchAntigravity、dispatchApiOpenaiCompat範例</code></pre>
|
|
194
|
+
<pre class="prettyprint"><code>詳見dispatchAi、dispatchAiFallback、dispatchAiWkf、dispatchOpencode、dispatchClaude、dispatchCodex、dispatchAntigravity、dispatchApiOpenaiCompat、resolveProviders範例</code></pre>
|
|
195
195
|
|
|
196
196
|
|
|
197
197
|
|
|
@@ -214,7 +214,7 @@
|
|
|
214
214
|
|
|
215
215
|
<dt class="tag-source">Source:</dt>
|
|
216
216
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
217
|
-
<a href="adapters.mjs.html">adapters.mjs</a>, <a href="adapters.mjs.html#
|
|
217
|
+
<a href="adapters.mjs.html">adapters.mjs</a>, <a href="adapters.mjs.html#line57">line 57</a>
|
|
218
218
|
</li></ul></dd>
|
|
219
219
|
|
|
220
220
|
|
|
@@ -275,6 +275,81 @@ console.log(Object.keys(adapters))
|
|
|
275
275
|
|
|
276
276
|
|
|
277
277
|
|
|
278
|
+
|
|
279
|
+
<h4 class="name" id="dfTimeoutMs"><span class="type-signature"></span>dfTimeoutMs<span class="type-signature"></span></h4>
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
<dl class="details">
|
|
286
|
+
|
|
287
|
+
<dt class="tag-description">Description:</dt>
|
|
288
|
+
<dd class="tag-description"><ul class="dummy"><li><p>全套件統一之預設逾時毫秒</p></li></ul></dd>
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
<dt class="tag-source">Source:</dt>
|
|
293
|
+
<dd class="tag-source"><ul class="dummy"><li>
|
|
294
|
+
<a href="dfTimeoutMs.mjs.html">dfTimeoutMs.mjs</a>, <a href="dfTimeoutMs.mjs.html#line23">line 23</a>
|
|
295
|
+
</li></ul></dd>
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
</dl>
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
<div class="description usertext">
|
|
334
|
+
<p>全套件統一之預設逾時毫秒</p>
|
|
335
|
+
</div>
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
<h5 class="h5-examples">Example</h5>
|
|
344
|
+
|
|
345
|
+
<pre class="prettyprint"><code>import dfTimeoutMs from './src/dfTimeoutMs.mjs'
|
|
346
|
+
|
|
347
|
+
console.log(dfTimeoutMs)
|
|
348
|
+
// => 300000</code></pre>
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
278
353
|
|
|
279
354
|
|
|
280
355
|
|
|
@@ -301,7 +376,7 @@ console.log(Object.keys(adapters))
|
|
|
301
376
|
|
|
302
377
|
<dt class="tag-source">Source:</dt>
|
|
303
378
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
304
|
-
<a href="wkf_callAiWithFallback.mjs.html">wkf/callAiWithFallback.mjs</a>, <a href="wkf_callAiWithFallback.mjs.html#
|
|
379
|
+
<a href="wkf_callAiWithFallback.mjs.html">wkf/callAiWithFallback.mjs</a>, <a href="wkf_callAiWithFallback.mjs.html#line62">line 62</a>
|
|
305
380
|
</li></ul></dd>
|
|
306
381
|
|
|
307
382
|
|
|
@@ -492,7 +567,7 @@ console.log(buildChain(providers, { use: 'a', fallback: ['b', 'c'] }))
|
|
|
492
567
|
|
|
493
568
|
<dt class="tag-source">Source:</dt>
|
|
494
569
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
495
|
-
<a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#
|
|
570
|
+
<a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#line71">line 71</a>
|
|
496
571
|
</li></ul></dd>
|
|
497
572
|
|
|
498
573
|
|
|
@@ -661,7 +736,7 @@ parse+check接進遞補層之validate——非法回覆視為該家失敗而
|
|
|
661
736
|
|
|
662
737
|
<dt class="tag-source">Source:</dt>
|
|
663
738
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
664
|
-
<a href="wkf_callAiWithFallback.mjs.html">wkf/callAiWithFallback.mjs</a>, <a href="wkf_callAiWithFallback.mjs.html#
|
|
739
|
+
<a href="wkf_callAiWithFallback.mjs.html">wkf/callAiWithFallback.mjs</a>, <a href="wkf_callAiWithFallback.mjs.html#line135">line 135</a>
|
|
665
740
|
</li></ul></dd>
|
|
666
741
|
|
|
667
742
|
|
|
@@ -712,20 +787,21 @@ parse+check接進遞補層之validate——非法回覆視為該家失敗而
|
|
|
712
787
|
|
|
713
788
|
import callAiWithFallback from './src/wkf/callAiWithFallback.mjs'
|
|
714
789
|
|
|
790
|
+
//鍵名須區分到模型並帶上路徑, 詳見dispatchAiFallback.mjs檔頭之id設計規則
|
|
715
791
|
let providers = {
|
|
716
|
-
'deepseek': { kind: 'opencode', model: '
|
|
717
|
-
'sonnet': { kind: 'claude', model: 'sonnet' },
|
|
792
|
+
'zen:deepseek-v4-flash-free': { kind: 'api-openai-compat', baseURL: 'https://opencode.ai/zen/v1', model: 'deepseek-v4-flash-free', keys: ['sk-xxx'] },
|
|
793
|
+
'claude:sonnet': { kind: 'claude', model: 'sonnet' },
|
|
718
794
|
}
|
|
719
795
|
|
|
720
796
|
let test = async () => {
|
|
721
797
|
|
|
722
798
|
let r = await callAiWithFallback('只回覆JSON: {"a":1}', {
|
|
723
799
|
providers,
|
|
724
|
-
spec: { use: 'deepseek', fallback: ['sonnet'] },
|
|
800
|
+
spec: { use: 'zen:deepseek-v4-flash-free', fallback: ['claude:sonnet'] },
|
|
725
801
|
check: (j) => j.a === 1,
|
|
726
802
|
})
|
|
727
803
|
console.log(r.ok, r.json, r.providerId)
|
|
728
|
-
// => true { a: 1 } 'deepseek'
|
|
804
|
+
// => true { a: 1 } 'zen:deepseek-v4-flash-free'
|
|
729
805
|
|
|
730
806
|
}
|
|
731
807
|
await test()
|
|
@@ -1129,7 +1205,7 @@ await test()
|
|
|
1129
1205
|
</td>
|
|
1130
1206
|
|
|
1131
1207
|
|
|
1132
|
-
<td class="description last"><p
|
|
1208
|
+
<td class="description last"><p>輸入單次嘗試逾時毫秒正整數,全套件統一預設300000</p></td>
|
|
1133
1209
|
</tr>
|
|
1134
1210
|
|
|
1135
1211
|
|
|
@@ -1405,7 +1481,7 @@ await test()
|
|
|
1405
1481
|
|
|
1406
1482
|
<dt class="tag-source">Source:</dt>
|
|
1407
1483
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
1408
|
-
<a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#
|
|
1484
|
+
<a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#line137">line 137</a>
|
|
1409
1485
|
</li></ul></dd>
|
|
1410
1486
|
|
|
1411
1487
|
|
|
@@ -2162,7 +2238,7 @@ providers陣列順序即優先序,排前面的先用;
|
|
|
2162
2238
|
|
|
2163
2239
|
<dt class="tag-source">Source:</dt>
|
|
2164
2240
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2165
|
-
<a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#
|
|
2241
|
+
<a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line189">line 189</a>
|
|
2166
2242
|
</li></ul></dd>
|
|
2167
2243
|
|
|
2168
2244
|
|
|
@@ -2218,21 +2294,29 @@ let test = async () => {
|
|
|
2218
2294
|
let r = await dispatchAiFallback('請只回覆兩個字:完成', {
|
|
2219
2295
|
providers: [
|
|
2220
2296
|
{
|
|
2221
|
-
id
|
|
2297
|
+
//id區分到模型且帶路徑: 同一模型經REST與CLI取得屬兩個供應商
|
|
2298
|
+
id: 'zen:deepseek-v4-flash-free',
|
|
2299
|
+
kind: 'api-openai-compat',
|
|
2300
|
+
baseURL: 'https://opencode.ai/zen/v1',
|
|
2301
|
+
model: 'deepseek-v4-flash-free',
|
|
2302
|
+
keys: ['sk-aaa', 'sk-bbb'], //多把金鑰, 某把失敗自動換下一把
|
|
2303
|
+
},
|
|
2304
|
+
{
|
|
2305
|
+
id: 'oc:opencode/deepseek-v4-flash-free', //同一模型之CLI版(有工具, 較慢)
|
|
2222
2306
|
kind: 'opencode',
|
|
2223
2307
|
model: 'opencode/deepseek-v4-flash-free',
|
|
2224
2308
|
provider: 'opencode',
|
|
2225
|
-
keys: ['sk-aaa', 'sk-bbb'],
|
|
2309
|
+
keys: ['sk-aaa', 'sk-bbb'],
|
|
2226
2310
|
timeoutMs: 180000,
|
|
2227
2311
|
},
|
|
2228
|
-
{ id: 'claude', kind: 'claude', model: 'sonnet' },
|
|
2229
|
-
{ id: 'codex', kind: 'codex', model: 'gpt-5.6-luna', sandbox: 'read-only' },
|
|
2312
|
+
{ id: 'claude:sonnet', kind: 'claude', model: 'sonnet' }, //以上全敗時遞補
|
|
2313
|
+
{ id: 'codex:gpt-5.6-luna', kind: 'codex', model: 'gpt-5.6-luna', sandbox: 'read-only' },
|
|
2230
2314
|
],
|
|
2231
2315
|
budgetMs: 600000,
|
|
2232
2316
|
onEvent: (ev) => console.log(ev.type, ev.providerId, ev.keyIndex),
|
|
2233
2317
|
})
|
|
2234
2318
|
console.log(r.ok, r.providerId, r.keyIndex, r.tried.length)
|
|
2235
|
-
// => true 'deepseek' 0 1
|
|
2319
|
+
// => true 'zen:deepseek-v4-flash-free' 0 1
|
|
2236
2320
|
|
|
2237
2321
|
}
|
|
2238
2322
|
await test()
|
|
@@ -2463,7 +2547,7 @@ await test()
|
|
|
2463
2547
|
</td>
|
|
2464
2548
|
|
|
2465
2549
|
|
|
2466
|
-
<td class="description last"><p
|
|
2550
|
+
<td class="description last"><p>輸入群組識別字串,游標以此為鍵、亦為日誌標籤,本套件不解讀其內容。須區分到「模型」而非只到「廠商」(如'claude:sonnet'而非'claude'),同一模型經不同路徑取得時須帶上路徑(如'poolside:laguna-s-2.1'與'or:poolside/laguna-s-2.1:free'),且務必唯一。省略時回退為陣列索引字串——索引是位置不是身分,日後插入條目會令後續條目繼承他人游標進度,故正式設定一律明給。詳見本檔檔頭之id設計規則</p></td>
|
|
2467
2551
|
</tr>
|
|
2468
2552
|
|
|
2469
2553
|
|
|
@@ -2670,7 +2754,7 @@ await test()
|
|
|
2670
2754
|
</td>
|
|
2671
2755
|
|
|
2672
2756
|
|
|
2673
|
-
<td class="description last"><p>輸入事件回調函數(ev)=>{},ev.type可為'try'、'ok'、'next-key'、'skip-group'、'budget-out'
|
|
2757
|
+
<td class="description last"><p>輸入事件回調函數(ev)=>{},ev.type可為'try'、'ok'、'next-key'、'skip-group'、'budget-out';失敗事件(next-key/skip-group)另帶stdout(被拒回覆)與stderr(錯誤輸出)供診斷,兩者於失敗路徑已由轉接器截斷;回調拋出例外不影響主流程,預設null</p></td>
|
|
2674
2758
|
</tr>
|
|
2675
2759
|
|
|
2676
2760
|
|
|
@@ -2705,12 +2789,12 @@ await test()
|
|
|
2705
2789
|
|
|
2706
2790
|
<td class="default">
|
|
2707
2791
|
|
|
2708
|
-
<code>
|
|
2792
|
+
<code>300000</code>
|
|
2709
2793
|
|
|
2710
2794
|
</td>
|
|
2711
2795
|
|
|
2712
2796
|
|
|
2713
|
-
<td class="description last"><p>輸入各attempt
|
|
2797
|
+
<td class="description last"><p>輸入各attempt共用之逾時毫秒正整數,條目可覆寫,全套件統一預設300000</p></td>
|
|
2714
2798
|
</tr>
|
|
2715
2799
|
|
|
2716
2800
|
|
|
@@ -2824,7 +2908,7 @@ await test()
|
|
|
2824
2908
|
|
|
2825
2909
|
|
|
2826
2910
|
<div class="param-desc">
|
|
2827
|
-
<p>回傳Promise,resolve回傳結果物件,除execCli既有欄位(ok、stdout、stderr、code、error、durationMs、attempts、pid)外,追加providerId(實際使用之群組)、keyIndex(實際使用之金鑰索引,無keys時為null)、kind、model、tried(
|
|
2911
|
+
<p>回傳Promise,resolve回傳結果物件,除execCli既有欄位(ok、stdout、stderr、code、error、durationMs、attempts、pid)外,追加providerId(實際使用之群組)、keyIndex(實際使用之金鑰索引,無keys時為null)、kind、model、tried(全部嘗試歷程陣列,成功時亦回傳;失敗項含stdout與stderr供診斷被拒原因),本函數不會reject</p>
|
|
2828
2912
|
</div>
|
|
2829
2913
|
|
|
2830
2914
|
|
|
@@ -2871,7 +2955,7 @@ defaults為共用呼叫設定,各工作流之callOpt與名額規格可逐項
|
|
|
2871
2955
|
|
|
2872
2956
|
<dt class="tag-source">Source:</dt>
|
|
2873
2957
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2874
|
-
<a href="dispatchAiWkf.mjs.html">dispatchAiWkf.mjs</a>, <a href="dispatchAiWkf.mjs.html#
|
|
2958
|
+
<a href="dispatchAiWkf.mjs.html">dispatchAiWkf.mjs</a>, <a href="dispatchAiWkf.mjs.html#line106">line 106</a>
|
|
2875
2959
|
</li></ul></dd>
|
|
2876
2960
|
|
|
2877
2961
|
|
|
@@ -2922,11 +3006,15 @@ defaults為共用呼叫設定,各工作流之callOpt與名額規格可逐項
|
|
|
2922
3006
|
|
|
2923
3007
|
import dispatchAiWkf from './src/dispatchAiWkf.mjs'
|
|
2924
3008
|
|
|
3009
|
+
//定義表之鍵名即dispatchAiFallback之條目id, 須區分到模型而非只到廠商,
|
|
3010
|
+
//同一模型經不同路徑取得時須帶上路徑(REST與CLI屬兩個供應商, 能力與速度皆不同)
|
|
2925
3011
|
let wkf = dispatchAiWkf({
|
|
2926
3012
|
providers: {
|
|
2927
|
-
'deepseek': { kind: 'opencode', model: '
|
|
2928
|
-
'
|
|
2929
|
-
'
|
|
3013
|
+
'zen:deepseek-v4-flash-free': { kind: 'api-openai-compat', baseURL: 'https://opencode.ai/zen/v1', model: 'deepseek-v4-flash-free', keys: ['sk-xxx'] },
|
|
3014
|
+
'oc:opencode/deepseek-v4-flash-free': { kind: 'opencode', model: 'opencode/deepseek-v4-flash-free', provider: 'opencode', keys: ['sk-xxx'] },
|
|
3015
|
+
'claude:sonnet': { kind: 'claude', model: 'sonnet' },
|
|
3016
|
+
'claude:opus': { kind: 'claude', model: 'opus' },
|
|
3017
|
+
'codex:gpt-5.6-luna': { kind: 'codex', model: 'gpt-5.6-luna' },
|
|
2930
3018
|
},
|
|
2931
3019
|
defaults: { timeoutMs: 300000 },
|
|
2932
3020
|
})
|
|
@@ -2934,15 +3022,19 @@ let wkf = dispatchAiWkf({
|
|
|
2934
3022
|
let test = async () => {
|
|
2935
3023
|
|
|
2936
3024
|
//單一名額: 主模型+遞補鏈
|
|
2937
|
-
let r1 = await wkf.callAi('只回覆JSON: {"a":1}', { spec: { use: 'deepseek', fallback: ['sonnet'] }, check: (j) => j.a === 1 })
|
|
3025
|
+
let r1 = await wkf.callAi('只回覆JSON: {"a":1}', { spec: { use: 'zen:deepseek-v4-flash-free', fallback: ['claude:sonnet'] }, check: (j) => j.a === 1 })
|
|
2938
3026
|
console.log(r1.ok, r1.json)
|
|
2939
3027
|
// => true { a: 1 }
|
|
2940
3028
|
|
|
2941
3029
|
//Fanout工作流: 多開執行+單點整合
|
|
3030
|
+
//純文字階段用REST(快), 需要讀專案檔案之階段才用CLI(有工具)
|
|
2942
3031
|
let r2 = await wkf.runFanout({
|
|
2943
3032
|
task: '分析並只回覆JSON: {"essence":"..."}',
|
|
2944
|
-
agents: [
|
|
2945
|
-
|
|
3033
|
+
agents: [
|
|
3034
|
+
{ use: 'zen:deepseek-v4-flash-free', fallback: ['claude:sonnet'] },
|
|
3035
|
+
{ use: 'claude:sonnet' },
|
|
3036
|
+
],
|
|
3037
|
+
integrate: { use: 'codex:gpt-5.6-luna' },
|
|
2946
3038
|
check: (j) => !!j.essence,
|
|
2947
3039
|
})
|
|
2948
3040
|
console.log(r2.ok, r2.integrated)
|
|
@@ -3184,7 +3276,7 @@ agy自身之--print-timeout未給時由timeoutMs推導並預留30秒緩衝,令
|
|
|
3184
3276
|
|
|
3185
3277
|
<dt class="tag-source">Source:</dt>
|
|
3186
3278
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
3187
|
-
<a href="dispatchAntigravity.mjs.html">dispatchAntigravity.mjs</a>, <a href="dispatchAntigravity.mjs.html#
|
|
3279
|
+
<a href="dispatchAntigravity.mjs.html">dispatchAntigravity.mjs</a>, <a href="dispatchAntigravity.mjs.html#line106">line 106</a>
|
|
3188
3280
|
</li></ul></dd>
|
|
3189
3281
|
|
|
3190
3282
|
|
|
@@ -3615,12 +3707,12 @@ await test()
|
|
|
3615
3707
|
|
|
3616
3708
|
<td class="default">
|
|
3617
3709
|
|
|
3618
|
-
<code
|
|
3710
|
+
<code>自動納入cwd</code>
|
|
3619
3711
|
|
|
3620
3712
|
</td>
|
|
3621
3713
|
|
|
3622
3714
|
|
|
3623
|
-
<td class="description last"><p>輸入加入workspace之目錄字串陣列,逐項展開為<code>--add-dir</code
|
|
3715
|
+
<td class="description last"><p>輸入加入workspace之目錄字串陣列,逐項展開為<code>--add-dir</code>。agy以自身scratch目錄為工作區而不採子進程cwd,故未給本參數時自動納入有效cwd令檔案可視範圍與其他CLI轉接器一致;明示給陣列(含空陣列[]代表不揭露任何目錄)則完全尊重呼叫端</p></td>
|
|
3624
3716
|
</tr>
|
|
3625
3717
|
|
|
3626
3718
|
|
|
@@ -3700,7 +3792,7 @@ await test()
|
|
|
3700
3792
|
</td>
|
|
3701
3793
|
|
|
3702
3794
|
|
|
3703
|
-
<td class="description last"><p
|
|
3795
|
+
<td class="description last"><p>輸入逾時毫秒正整數,逾時將強制關閉子進程及其子孫程序,全套件統一預設300000(恰對齊agy自身print-timeout預設5m0s)</p></td>
|
|
3704
3796
|
</tr>
|
|
3705
3797
|
|
|
3706
3798
|
|
|
@@ -3740,7 +3832,7 @@ await test()
|
|
|
3740
3832
|
</td>
|
|
3741
3833
|
|
|
3742
3834
|
|
|
3743
|
-
<td class="description last"><p>輸入子進程工作目錄字串,預設process.cwd()</p></td>
|
|
3835
|
+
<td class="description last"><p>輸入子進程工作目錄字串,預設process.cwd()。注意本參數不影響agy之檔案可視範圍(agy以自身scratch目錄為工作區),可視範圍由addDirs決定(未給addDirs時自動納入本目錄)</p></td>
|
|
3744
3836
|
</tr>
|
|
3745
3837
|
|
|
3746
3838
|
|
|
@@ -3894,6 +3986,8 @@ await test()
|
|
|
3894
3986
|
<dd class="tag-description"><ul class="dummy"><li><p>以fetch直呼OpenAI相容API(chat/completions)呼叫AI模型</p>
|
|
3895
3987
|
<p>特點:
|
|
3896
3988
|
免安裝CLI、免預先登入,給baseURL+key+model即可呼叫(如OpenCode Zen、Agnes等OpenAI相容閘道);
|
|
3989
|
+
僅供純文字生成(摘要、分析、改寫、產出JSON等素材已在prompt內之任務)——
|
|
3990
|
+
需要讀本機檔案、grep、執行指令、抓網頁等工具能力時,請改用CLI類kind(opencode/claude/codex/antigravity);
|
|
3897
3991
|
prompt走HTTP body,無命令列長度限制;
|
|
3898
3992
|
錯誤依HTTP狀態碼分流:4xx(429除外)為客戶端錯誤不重試,429/5xx/網路錯誤/逾時依maxRetries線性退避重試;
|
|
3899
3993
|
結果結構與逾時/驗證失敗之error字樣對齊execCli,可直接作為dispatchAi與dispatchAiFallback之kind('api-openai-compat')使用;
|
|
@@ -3903,7 +3997,7 @@ prompt走HTTP body,無命令列長度限制;
|
|
|
3903
3997
|
|
|
3904
3998
|
<dt class="tag-source">Source:</dt>
|
|
3905
3999
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
3906
|
-
<a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#
|
|
4000
|
+
<a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#line327">line 327</a>
|
|
3907
4001
|
</li></ul></dd>
|
|
3908
4002
|
|
|
3909
4003
|
|
|
@@ -4300,7 +4394,7 @@ await test()
|
|
|
4300
4394
|
</td>
|
|
4301
4395
|
|
|
4302
4396
|
|
|
4303
|
-
<td class="description last"><p>輸入額外請求本體物件(如temperature、max_tokens、response_format),將併入預設body(同名鍵以此為準),預設{}</p></td>
|
|
4397
|
+
<td class="description last"><p>輸入額外請求本體物件(如temperature、max_tokens、response_format),將併入預設body(同名鍵以此為準),預設{}。注意本轉接器不支援工具,帶入tools而模型回tool_calls時一律以TOOL_CALLS_UNSUPPORTED回報失敗,需要工具請改用CLI類kind</p></td>
|
|
4304
4398
|
</tr>
|
|
4305
4399
|
|
|
4306
4400
|
|
|
@@ -4375,12 +4469,12 @@ await test()
|
|
|
4375
4469
|
|
|
4376
4470
|
<td class="default">
|
|
4377
4471
|
|
|
4378
|
-
<code>
|
|
4472
|
+
<code>300000</code>
|
|
4379
4473
|
|
|
4380
4474
|
</td>
|
|
4381
4475
|
|
|
4382
4476
|
|
|
4383
|
-
<td class="description last"><p>輸入逾時毫秒正整數,逾時將中止請求(含回應串流讀取)
|
|
4477
|
+
<td class="description last"><p>輸入逾時毫秒正整數,逾時將中止請求(含回應串流讀取),全套件統一預設300000</p></td>
|
|
4384
4478
|
</tr>
|
|
4385
4479
|
|
|
4386
4480
|
|
|
@@ -4585,7 +4679,7 @@ prompt一律走stdin而非位置參數,因摘要內文可達數萬字,當命
|
|
|
4585
4679
|
|
|
4586
4680
|
<dt class="tag-source">Source:</dt>
|
|
4587
4681
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
4588
|
-
<a href="dispatchClaude.mjs.html">dispatchClaude.mjs</a>, <a href="dispatchClaude.mjs.html#
|
|
4682
|
+
<a href="dispatchClaude.mjs.html">dispatchClaude.mjs</a>, <a href="dispatchClaude.mjs.html#line77">line 77</a>
|
|
4589
4683
|
</li></ul></dd>
|
|
4590
4684
|
|
|
4591
4685
|
|
|
@@ -4638,7 +4732,7 @@ import dispatchClaude from './src/dispatchClaude.mjs'
|
|
|
4638
4732
|
|
|
4639
4733
|
let test = async () => {
|
|
4640
4734
|
|
|
4641
|
-
let r = await dispatchClaude('請只回覆兩個字:完成', { model: 'sonnet'
|
|
4735
|
+
let r = await dispatchClaude('請只回覆兩個字:完成', { model: 'sonnet' })
|
|
4642
4736
|
console.log(r.ok, r.stdout.trim())
|
|
4643
4737
|
// => true '完成'
|
|
4644
4738
|
|
|
@@ -4971,12 +5065,12 @@ await test()
|
|
|
4971
5065
|
|
|
4972
5066
|
<td class="default">
|
|
4973
5067
|
|
|
4974
|
-
<code>
|
|
5068
|
+
<code>300000</code>
|
|
4975
5069
|
|
|
4976
5070
|
</td>
|
|
4977
5071
|
|
|
4978
5072
|
|
|
4979
|
-
<td class="description last"><p
|
|
5073
|
+
<td class="description last"><p>輸入逾時毫秒正整數,逾時將強制關閉子進程及其子孫程序,全套件統一預設300000</p></td>
|
|
4980
5074
|
</tr>
|
|
4981
5075
|
|
|
4982
5076
|
|
|
@@ -5179,7 +5273,7 @@ prompt一律走stdin而非位置參數,因摘要內文可達數萬字,當命
|
|
|
5179
5273
|
|
|
5180
5274
|
<dt class="tag-source">Source:</dt>
|
|
5181
5275
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
5182
|
-
<a href="dispatchCodex.mjs.html">dispatchCodex.mjs</a>, <a href="dispatchCodex.mjs.html#
|
|
5276
|
+
<a href="dispatchCodex.mjs.html">dispatchCodex.mjs</a>, <a href="dispatchCodex.mjs.html#line77">line 77</a>
|
|
5183
5277
|
</li></ul></dd>
|
|
5184
5278
|
|
|
5185
5279
|
|
|
@@ -5565,12 +5659,12 @@ await test()
|
|
|
5565
5659
|
|
|
5566
5660
|
<td class="default">
|
|
5567
5661
|
|
|
5568
|
-
<code>
|
|
5662
|
+
<code>300000</code>
|
|
5569
5663
|
|
|
5570
5664
|
</td>
|
|
5571
5665
|
|
|
5572
5666
|
|
|
5573
|
-
<td class="description last"><p
|
|
5667
|
+
<td class="description last"><p>輸入逾時毫秒正整數,逾時將強制關閉子進程及其子孫程序,全套件統一預設300000</p></td>
|
|
5574
5668
|
</tr>
|
|
5575
5669
|
|
|
5576
5670
|
|
|
@@ -5775,7 +5869,7 @@ prompt一律走stdin而非位置參數,因摘要內文可達數萬字,當命
|
|
|
5775
5869
|
|
|
5776
5870
|
<dt class="tag-source">Source:</dt>
|
|
5777
5871
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
5778
|
-
<a href="dispatchOpencode.mjs.html">dispatchOpencode.mjs</a>, <a href="dispatchOpencode.mjs.html#
|
|
5872
|
+
<a href="dispatchOpencode.mjs.html">dispatchOpencode.mjs</a>, <a href="dispatchOpencode.mjs.html#line118">line 118</a>
|
|
5779
5873
|
</li></ul></dd>
|
|
5780
5874
|
|
|
5781
5875
|
|
|
@@ -6347,12 +6441,12 @@ await test()
|
|
|
6347
6441
|
|
|
6348
6442
|
<td class="default">
|
|
6349
6443
|
|
|
6350
|
-
<code>
|
|
6444
|
+
<code>300000</code>
|
|
6351
6445
|
|
|
6352
6446
|
</td>
|
|
6353
6447
|
|
|
6354
6448
|
|
|
6355
|
-
<td class="description last"><p
|
|
6449
|
+
<td class="description last"><p>輸入逾時毫秒正整數,逾時將強制關閉子進程及其子孫程序,全套件統一預設300000</p></td>
|
|
6356
6450
|
</tr>
|
|
6357
6451
|
|
|
6358
6452
|
|
|
@@ -7096,7 +7190,7 @@ console.log(getErrorResult(null).error)
|
|
|
7096
7190
|
|
|
7097
7191
|
<dt class="tag-source">Source:</dt>
|
|
7098
7192
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
7099
|
-
<a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#
|
|
7193
|
+
<a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line85">line 85</a>
|
|
7100
7194
|
</li></ul></dd>
|
|
7101
7195
|
|
|
7102
7196
|
|
|
@@ -7238,6 +7332,357 @@ console.log(getErrorResult(null).error)
|
|
|
7238
7332
|
|
|
7239
7333
|
|
|
7240
7334
|
|
|
7335
|
+
<h4 class="name" id="resolveProviders"><span class="type-signature"></span>resolveProviders<span class="signature">(providers, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Object}</span></h4>
|
|
7336
|
+
|
|
7337
|
+
|
|
7338
|
+
|
|
7339
|
+
|
|
7340
|
+
|
|
7341
|
+
|
|
7342
|
+
<dl class="details">
|
|
7343
|
+
|
|
7344
|
+
<dt class="tag-description">Description:</dt>
|
|
7345
|
+
<dd class="tag-description"><ul class="dummy"><li><p>展開providers定義條目:envVar → keys,並可依id自選子集</p>
|
|
7346
|
+
<p>特點:
|
|
7347
|
+
條目之envVar依env來源(預設process.env)展開為keys陣列(變數值以逗號分隔多把),envVar欄位自輸出移除;
|
|
7348
|
+
缺對應環境變數(或值為空)之條目停用並列入skipped,不中斷不throw;
|
|
7349
|
+
無envVar之條目(訂閱登入態CLI)原樣通過;條目已自帶有效keys者以keys為準;
|
|
7350
|
+
opt.pick可依id自選子集並以pick順序回傳(順序即遞補優先序);
|
|
7351
|
+
輸入陣列與條目皆不被改動(輸出為淺拷貝)</p></li></ul></dd>
|
|
7352
|
+
|
|
7353
|
+
|
|
7354
|
+
|
|
7355
|
+
<dt class="tag-source">Source:</dt>
|
|
7356
|
+
<dd class="tag-source"><ul class="dummy"><li>
|
|
7357
|
+
<a href="resolveProviders.mjs.html">resolveProviders.mjs</a>, <a href="resolveProviders.mjs.html#line56">line 56</a>
|
|
7358
|
+
</li></ul></dd>
|
|
7359
|
+
|
|
7360
|
+
|
|
7361
|
+
|
|
7362
|
+
|
|
7363
|
+
|
|
7364
|
+
|
|
7365
|
+
|
|
7366
|
+
|
|
7367
|
+
|
|
7368
|
+
|
|
7369
|
+
|
|
7370
|
+
|
|
7371
|
+
|
|
7372
|
+
|
|
7373
|
+
|
|
7374
|
+
|
|
7375
|
+
|
|
7376
|
+
|
|
7377
|
+
|
|
7378
|
+
|
|
7379
|
+
|
|
7380
|
+
|
|
7381
|
+
|
|
7382
|
+
|
|
7383
|
+
|
|
7384
|
+
|
|
7385
|
+
|
|
7386
|
+
|
|
7387
|
+
|
|
7388
|
+
|
|
7389
|
+
|
|
7390
|
+
</dl>
|
|
7391
|
+
|
|
7392
|
+
|
|
7393
|
+
|
|
7394
|
+
|
|
7395
|
+
|
|
7396
|
+
|
|
7397
|
+
|
|
7398
|
+
|
|
7399
|
+
|
|
7400
|
+
|
|
7401
|
+
|
|
7402
|
+
<h5 class="h5-examples">Example</h5>
|
|
7403
|
+
|
|
7404
|
+
<pre class="prettyprint"><code>import resolveProviders from './src/resolveProviders.mjs'
|
|
7405
|
+
import providersAll from './src/providers.mjs'
|
|
7406
|
+
|
|
7407
|
+
process.loadEnvFile('./.env') //金鑰放.env, 變數值以逗號分隔多把
|
|
7408
|
+
|
|
7409
|
+
//全取: envVar展開為keys, 缺環境變數者列入skipped
|
|
7410
|
+
let { providers, table, skipped } = resolveProviders(providersAll)
|
|
7411
|
+
console.log(providers.length, skipped)
|
|
7412
|
+
// => 10 []
|
|
7413
|
+
|
|
7414
|
+
//自選: 依pick順序回傳(順序即遞補優先序), 可直接餵dispatchAiFallback
|
|
7415
|
+
let r2 = resolveProviders(providersAll, { pick: ['agnes:agnes-2.5-flash', 'claude:sonnet'] })
|
|
7416
|
+
console.log(r2.providers.map((p) => p.id))
|
|
7417
|
+
// => [ 'agnes:agnes-2.5-flash', 'claude:sonnet' ]
|
|
7418
|
+
|
|
7419
|
+
//table可直接餵dispatchAiWkf之providers定義表
|
|
7420
|
+
//let wkf = dispatchAiWkf({ providers: r2.table, defaults: { timeoutMs: 1200000 } })</code></pre>
|
|
7421
|
+
|
|
7422
|
+
|
|
7423
|
+
|
|
7424
|
+
|
|
7425
|
+
<h5 class="h5-parameters">Parameters:</h5>
|
|
7426
|
+
|
|
7427
|
+
|
|
7428
|
+
<table class="params">
|
|
7429
|
+
<thead>
|
|
7430
|
+
<tr>
|
|
7431
|
+
|
|
7432
|
+
<th>Name</th>
|
|
7433
|
+
|
|
7434
|
+
|
|
7435
|
+
<th>Type</th>
|
|
7436
|
+
|
|
7437
|
+
|
|
7438
|
+
<th>Attributes</th>
|
|
7439
|
+
|
|
7440
|
+
|
|
7441
|
+
|
|
7442
|
+
<th>Default</th>
|
|
7443
|
+
|
|
7444
|
+
|
|
7445
|
+
<th class="last">Description</th>
|
|
7446
|
+
</tr>
|
|
7447
|
+
</thead>
|
|
7448
|
+
|
|
7449
|
+
<tbody>
|
|
7450
|
+
|
|
7451
|
+
|
|
7452
|
+
<tr>
|
|
7453
|
+
|
|
7454
|
+
<td class="name"><code>providers</code></td>
|
|
7455
|
+
|
|
7456
|
+
|
|
7457
|
+
<td class="type">
|
|
7458
|
+
|
|
7459
|
+
|
|
7460
|
+
<span class="param-type">Array</span>
|
|
7461
|
+
|
|
7462
|
+
|
|
7463
|
+
|
|
7464
|
+
|
|
7465
|
+
</td>
|
|
7466
|
+
|
|
7467
|
+
|
|
7468
|
+
<td class="attributes">
|
|
7469
|
+
|
|
7470
|
+
|
|
7471
|
+
|
|
7472
|
+
|
|
7473
|
+
|
|
7474
|
+
</td>
|
|
7475
|
+
|
|
7476
|
+
|
|
7477
|
+
|
|
7478
|
+
<td class="default">
|
|
7479
|
+
|
|
7480
|
+
</td>
|
|
7481
|
+
|
|
7482
|
+
|
|
7483
|
+
<td class="description last"><p>輸入providers條目物件陣列(如providers.mjs之預設匯出)</p></td>
|
|
7484
|
+
</tr>
|
|
7485
|
+
|
|
7486
|
+
|
|
7487
|
+
|
|
7488
|
+
<tr>
|
|
7489
|
+
|
|
7490
|
+
<td class="name"><code>opt</code></td>
|
|
7491
|
+
|
|
7492
|
+
|
|
7493
|
+
<td class="type">
|
|
7494
|
+
|
|
7495
|
+
|
|
7496
|
+
<span class="param-type">Object</span>
|
|
7497
|
+
|
|
7498
|
+
|
|
7499
|
+
|
|
7500
|
+
|
|
7501
|
+
</td>
|
|
7502
|
+
|
|
7503
|
+
|
|
7504
|
+
<td class="attributes">
|
|
7505
|
+
|
|
7506
|
+
<optional><br>
|
|
7507
|
+
|
|
7508
|
+
|
|
7509
|
+
|
|
7510
|
+
|
|
7511
|
+
|
|
7512
|
+
</td>
|
|
7513
|
+
|
|
7514
|
+
|
|
7515
|
+
|
|
7516
|
+
<td class="default">
|
|
7517
|
+
|
|
7518
|
+
<code>{}</code>
|
|
7519
|
+
|
|
7520
|
+
</td>
|
|
7521
|
+
|
|
7522
|
+
|
|
7523
|
+
<td class="description last"><p>輸入設定物件,預設{}</p>
|
|
7524
|
+
<h6>Properties</h6>
|
|
7525
|
+
|
|
7526
|
+
|
|
7527
|
+
<table class="params">
|
|
7528
|
+
<thead>
|
|
7529
|
+
<tr>
|
|
7530
|
+
|
|
7531
|
+
<th>Name</th>
|
|
7532
|
+
|
|
7533
|
+
|
|
7534
|
+
<th>Type</th>
|
|
7535
|
+
|
|
7536
|
+
|
|
7537
|
+
<th>Attributes</th>
|
|
7538
|
+
|
|
7539
|
+
|
|
7540
|
+
|
|
7541
|
+
<th>Default</th>
|
|
7542
|
+
|
|
7543
|
+
|
|
7544
|
+
<th class="last">Description</th>
|
|
7545
|
+
</tr>
|
|
7546
|
+
</thead>
|
|
7547
|
+
|
|
7548
|
+
<tbody>
|
|
7549
|
+
|
|
7550
|
+
|
|
7551
|
+
<tr>
|
|
7552
|
+
|
|
7553
|
+
<td class="name"><code>env</code></td>
|
|
7554
|
+
|
|
7555
|
+
|
|
7556
|
+
<td class="type">
|
|
7557
|
+
|
|
7558
|
+
|
|
7559
|
+
<span class="param-type">Object</span>
|
|
7560
|
+
|
|
7561
|
+
|
|
7562
|
+
|
|
7563
|
+
|
|
7564
|
+
</td>
|
|
7565
|
+
|
|
7566
|
+
|
|
7567
|
+
<td class="attributes">
|
|
7568
|
+
|
|
7569
|
+
<optional><br>
|
|
7570
|
+
|
|
7571
|
+
|
|
7572
|
+
|
|
7573
|
+
|
|
7574
|
+
|
|
7575
|
+
</td>
|
|
7576
|
+
|
|
7577
|
+
|
|
7578
|
+
|
|
7579
|
+
<td class="default">
|
|
7580
|
+
|
|
7581
|
+
<code>process.env</code>
|
|
7582
|
+
|
|
7583
|
+
</td>
|
|
7584
|
+
|
|
7585
|
+
|
|
7586
|
+
<td class="description last"><p>輸入金鑰來源物件(變數名 → 逗號分隔之金鑰字串),預設process.env</p></td>
|
|
7587
|
+
</tr>
|
|
7588
|
+
|
|
7589
|
+
|
|
7590
|
+
|
|
7591
|
+
<tr>
|
|
7592
|
+
|
|
7593
|
+
<td class="name"><code>pick</code></td>
|
|
7594
|
+
|
|
7595
|
+
|
|
7596
|
+
<td class="type">
|
|
7597
|
+
|
|
7598
|
+
|
|
7599
|
+
<span class="param-type">Array</span>
|
|
7600
|
+
|
|
7601
|
+
|
|
7602
|
+
|
|
7603
|
+
|
|
7604
|
+
</td>
|
|
7605
|
+
|
|
7606
|
+
|
|
7607
|
+
<td class="attributes">
|
|
7608
|
+
|
|
7609
|
+
<optional><br>
|
|
7610
|
+
|
|
7611
|
+
|
|
7612
|
+
|
|
7613
|
+
|
|
7614
|
+
|
|
7615
|
+
</td>
|
|
7616
|
+
|
|
7617
|
+
|
|
7618
|
+
|
|
7619
|
+
<td class="default">
|
|
7620
|
+
|
|
7621
|
+
<code>null</code>
|
|
7622
|
+
|
|
7623
|
+
</td>
|
|
7624
|
+
|
|
7625
|
+
|
|
7626
|
+
<td class="description last"><p>輸入自選id字串陣列,依此順序回傳對應條目,查無之id列入missing,預設null代表全取(依原順序)</p></td>
|
|
7627
|
+
</tr>
|
|
7628
|
+
|
|
7629
|
+
|
|
7630
|
+
</tbody>
|
|
7631
|
+
</table>
|
|
7632
|
+
|
|
7633
|
+
</td>
|
|
7634
|
+
</tr>
|
|
7635
|
+
|
|
7636
|
+
|
|
7637
|
+
</tbody>
|
|
7638
|
+
</table>
|
|
7639
|
+
|
|
7640
|
+
|
|
7641
|
+
|
|
7642
|
+
|
|
7643
|
+
|
|
7644
|
+
|
|
7645
|
+
|
|
7646
|
+
|
|
7647
|
+
|
|
7648
|
+
|
|
7649
|
+
|
|
7650
|
+
|
|
7651
|
+
|
|
7652
|
+
|
|
7653
|
+
|
|
7654
|
+
|
|
7655
|
+
<h5 class="h5-returns">Returns:</h5>
|
|
7656
|
+
|
|
7657
|
+
|
|
7658
|
+
<div class="param-desc">
|
|
7659
|
+
<p>回傳物件,內含providers(可直接餵dispatchAiFallback之條目陣列)、table(id對條目之物件,可直接餵dispatchAiWkf)、skipped(缺環境變數而停用之{id,envVar}陣列)、missing(pick查無之id字串陣列)</p>
|
|
7660
|
+
</div>
|
|
7661
|
+
|
|
7662
|
+
|
|
7663
|
+
|
|
7664
|
+
<dl class="param-type">
|
|
7665
|
+
<dt>
|
|
7666
|
+
Type
|
|
7667
|
+
</dt>
|
|
7668
|
+
<dd>
|
|
7669
|
+
|
|
7670
|
+
<span class="param-type">Object</span>
|
|
7671
|
+
|
|
7672
|
+
|
|
7673
|
+
|
|
7674
|
+
</dd>
|
|
7675
|
+
</dl>
|
|
7676
|
+
|
|
7677
|
+
|
|
7678
|
+
|
|
7679
|
+
|
|
7680
|
+
|
|
7681
|
+
|
|
7682
|
+
|
|
7683
|
+
|
|
7684
|
+
|
|
7685
|
+
|
|
7241
7686
|
<h4 class="name" id="runFanout"><span class="type-signature type-signature-async">(async) </span>runFanout<span class="signature">(opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
|
|
7242
7687
|
|
|
7243
7688
|
|
|
@@ -7312,8 +7757,8 @@ console.log(getErrorResult(null).error)
|
|
|
7312
7757
|
import runFanout from './src/wkf/runFanout.mjs'
|
|
7313
7758
|
|
|
7314
7759
|
let providers = {
|
|
7315
|
-
'deepseek': { kind: 'opencode', model: '
|
|
7316
|
-
'sonnet': { kind: 'claude', model: 'sonnet' },
|
|
7760
|
+
'zen:deepseek-v4-flash-free': { kind: 'api-openai-compat', baseURL: 'https://opencode.ai/zen/v1', model: 'deepseek-v4-flash-free', keys: ['sk-xxx'] },
|
|
7761
|
+
'claude:sonnet': { kind: 'claude', model: 'sonnet' },
|
|
7317
7762
|
}
|
|
7318
7763
|
|
|
7319
7764
|
let test = async () => {
|
|
@@ -7322,10 +7767,10 @@ let test = async () => {
|
|
|
7322
7767
|
providers,
|
|
7323
7768
|
task: '分析並只回覆JSON: {"essence":"..."}',
|
|
7324
7769
|
agents: [
|
|
7325
|
-
{ use: 'deepseek', fallback: ['sonnet'] },
|
|
7326
|
-
{ use: 'sonnet' },
|
|
7770
|
+
{ use: 'zen:deepseek-v4-flash-free', fallback: ['claude:sonnet'] },
|
|
7771
|
+
{ use: 'claude:sonnet' },
|
|
7327
7772
|
],
|
|
7328
|
-
integrate: { use: 'sonnet' },
|
|
7773
|
+
integrate: { use: 'claude:sonnet' },
|
|
7329
7774
|
check: (j) => !!j.essence,
|
|
7330
7775
|
})
|
|
7331
7776
|
console.log(r.ok, r.integrated, r.candidates.length)
|
|
@@ -7861,8 +8306,8 @@ await test()
|
|
|
7861
8306
|
import runFanoutPipeline from './src/wkf/runFanoutPipeline.mjs'
|
|
7862
8307
|
|
|
7863
8308
|
let providers = {
|
|
7864
|
-
'sonnet': { kind: 'claude', model: 'sonnet' },
|
|
7865
|
-
'luna': { kind: 'codex', model: 'gpt-5.6-luna' },
|
|
8309
|
+
'claude:sonnet': { kind: 'claude', model: 'sonnet' },
|
|
8310
|
+
'codex:gpt-5.6-luna': { kind: 'codex', model: 'gpt-5.6-luna' },
|
|
7866
8311
|
}
|
|
7867
8312
|
|
|
7868
8313
|
let test = async () => {
|
|
@@ -7870,10 +8315,10 @@ let test = async () => {
|
|
|
7870
8315
|
let r = await runFanoutPipeline({
|
|
7871
8316
|
providers,
|
|
7872
8317
|
task: '分析並只回覆JSON: {"essence":"..."}',
|
|
7873
|
-
agents: [{ use: 'sonnet' }, { use: 'luna' }],
|
|
7874
|
-
integrate: { use: 'sonnet' },
|
|
8318
|
+
agents: [{ use: 'claude:sonnet' }, { use: 'codex:gpt-5.6-luna' }],
|
|
8319
|
+
integrate: { use: 'claude:sonnet' },
|
|
7875
8320
|
stages: [
|
|
7876
|
-
{ id: 'audit', use: 'luna', prompt: (ctx) => `審計此稿並修訂, 只回覆同格式JSON: ${JSON.stringify(ctx.input)}` },
|
|
8321
|
+
{ id: 'audit', use: 'codex:gpt-5.6-luna', prompt: (ctx) => `審計此稿並修訂, 只回覆同格式JSON: ${JSON.stringify(ctx.input)}` },
|
|
7877
8322
|
],
|
|
7878
8323
|
check: (j) => !!j.essence,
|
|
7879
8324
|
})
|
|
@@ -8447,8 +8892,8 @@ await test()
|
|
|
8447
8892
|
import runRolePipeline from './src/wkf/runRolePipeline.mjs'
|
|
8448
8893
|
|
|
8449
8894
|
let providers = {
|
|
8450
|
-
'sonnet': { kind: 'claude', model: 'sonnet' },
|
|
8451
|
-
'luna': { kind: 'codex', model: 'gpt-5.6-luna' },
|
|
8895
|
+
'claude:sonnet': { kind: 'claude', model: 'sonnet' },
|
|
8896
|
+
'codex:gpt-5.6-luna': { kind: 'codex', model: 'gpt-5.6-luna' },
|
|
8452
8897
|
}
|
|
8453
8898
|
|
|
8454
8899
|
let test = async () => {
|
|
@@ -8457,8 +8902,8 @@ let test = async () => {
|
|
|
8457
8902
|
providers,
|
|
8458
8903
|
input: '原始任務',
|
|
8459
8904
|
stages: [
|
|
8460
|
-
{ id: 'draft', use: 'sonnet', prompt: (ctx) => `就「${ctx.input}」寫初稿, 只回覆JSON: {"text":"..."}` },
|
|
8461
|
-
{ id: 'review', use: 'luna', prompt: (ctx) => `審閱並修訂, 只回覆同格式JSON: ${JSON.stringify(ctx.prev)}` },
|
|
8905
|
+
{ id: 'draft', use: 'claude:sonnet', prompt: (ctx) => `就「${ctx.input}」寫初稿, 只回覆JSON: {"text":"..."}` },
|
|
8906
|
+
{ id: 'review', use: 'codex:gpt-5.6-luna', prompt: (ctx) => `審閱並修訂, 只回覆同格式JSON: ${JSON.stringify(ctx.prev)}` },
|
|
8462
8907
|
],
|
|
8463
8908
|
})
|
|
8464
8909
|
console.log(r.ok, r.order, r.failedStage)
|
|
@@ -8785,7 +9230,7 @@ await test()
|
|
|
8785
9230
|
<br class="clear">
|
|
8786
9231
|
|
|
8787
9232
|
<footer>
|
|
8788
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
9233
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Aug 14 2026 12:01:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
8789
9234
|
</footer>
|
|
8790
9235
|
|
|
8791
9236
|
<script>prettyPrint();</script>
|