w-dispatch-ai 1.0.4 → 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.
Files changed (44) hide show
  1. package/README.md +94 -17
  2. package/dist/w-dispatch-ai.umd.js +2 -2
  3. package/dist/w-dispatch-ai.umd.js.map +1 -1
  4. package/docs/WDispatchAi.mjs.html +8 -4
  5. package/docs/adapters.mjs.html +2 -2
  6. package/docs/dfTimeoutMs.mjs.html +98 -0
  7. package/docs/dispatchAi.mjs.html +2 -2
  8. package/docs/dispatchAiFallback.mjs.html +16 -11
  9. package/docs/dispatchAiWkf.mjs.html +11 -2
  10. package/docs/dispatchAntigravity.mjs.html +23 -12
  11. package/docs/dispatchApiOpenaiCompat.mjs.html +5 -4
  12. package/docs/dispatchClaude.mjs.html +17 -4
  13. package/docs/dispatchCodex.mjs.html +16 -3
  14. package/docs/dispatchOpencode.mjs.html +16 -3
  15. package/docs/getCliArgs.mjs.html +2 -2
  16. package/docs/getErrorResult.mjs.html +2 -2
  17. package/docs/global.html +460 -34
  18. package/docs/index.html +2 -2
  19. package/docs/resolveProviders.mjs.html +189 -0
  20. package/docs/wkf_callAiWithFallback.mjs.html +17 -7
  21. package/docs/wkf_extractJsonLoose.mjs.html +2 -2
  22. package/docs/wkf_runFanout.mjs.html +2 -2
  23. package/docs/wkf_runFanoutPipeline.mjs.html +2 -2
  24. package/docs/wkf_runRolePipeline.mjs.html +2 -2
  25. package/g.mjs +7 -7
  26. package/package.json +1 -1
  27. package/src/WDispatchAi.mjs +6 -2
  28. package/src/dfTimeoutMs.mjs +26 -0
  29. package/src/dispatchAiFallback.mjs +14 -9
  30. package/src/dispatchAiWkf.mjs +9 -0
  31. package/src/dispatchAntigravity.mjs +21 -10
  32. package/src/dispatchApiOpenaiCompat.mjs +3 -2
  33. package/src/dispatchClaude.mjs +15 -2
  34. package/src/dispatchCodex.mjs +14 -1
  35. package/src/dispatchOpencode.mjs +14 -1
  36. package/src/providers.mjs +133 -0
  37. package/src/resolveProviders.mjs +117 -0
  38. package/src/wkf/callAiWithFallback.mjs +15 -5
  39. package/test/unit-WDispatchAi.test.mjs +9 -3
  40. package/test/unit-dispatchAi.test.mjs +1 -1
  41. package/test/unit-dispatchAiFallback.test.mjs +25 -0
  42. package/test/unit-dispatchAntigravity.test.mjs +25 -5
  43. package/test/unit-providers.test.mjs +66 -0
  44. 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#line33">line 33</a>
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
 
@@ -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#line52">line 52</a>
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#line70">line 70</a>
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#line125">line 125</a>
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
 
@@ -1130,7 +1205,7 @@ await test()
1130
1205
  </td>
1131
1206
 
1132
1207
 
1133
- <td class="description last"><p>輸入單次嘗試逾時毫秒正整數,預設300000</p></td>
1208
+ <td class="description last"><p>輸入單次嘗試逾時毫秒正整數,全套件統一預設300000</p></td>
1134
1209
  </tr>
1135
1210
 
1136
1211
 
@@ -1406,7 +1481,7 @@ await test()
1406
1481
 
1407
1482
  <dt class="tag-source">Source:</dt>
1408
1483
  <dd class="tag-source"><ul class="dummy"><li>
1409
- <a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#line136">line 136</a>
1484
+ <a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#line137">line 137</a>
1410
1485
  </li></ul></dd>
1411
1486
 
1412
1487
 
@@ -2163,7 +2238,7 @@ providers陣列順序即優先序,排前面的先用;
2163
2238
 
2164
2239
  <dt class="tag-source">Source:</dt>
2165
2240
  <dd class="tag-source"><ul class="dummy"><li>
2166
- <a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line186">line 186</a>
2241
+ <a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line189">line 189</a>
2167
2242
  </li></ul></dd>
2168
2243
 
2169
2244
 
@@ -2679,7 +2754,7 @@ await test()
2679
2754
  </td>
2680
2755
 
2681
2756
 
2682
- <td class="description last"><p>輸入事件回調函數(ev)=&gt;{},ev.type可為'try'、'ok'、'next-key'、'skip-group'、'budget-out',回調拋出例外不影響主流程,預設null</p></td>
2757
+ <td class="description last"><p>輸入事件回調函數(ev)=&gt;{},ev.type可為'try'、'ok'、'next-key'、'skip-group'、'budget-out';失敗事件(next-key/skip-group)另帶stdout(被拒回覆)與stderr(錯誤輸出)供診斷,兩者於失敗路徑已由轉接器截斷;回調拋出例外不影響主流程,預設null</p></td>
2683
2758
  </tr>
2684
2759
 
2685
2760
 
@@ -2714,12 +2789,12 @@ await test()
2714
2789
 
2715
2790
  <td class="default">
2716
2791
 
2717
- <code>120000</code>
2792
+ <code>300000</code>
2718
2793
 
2719
2794
  </td>
2720
2795
 
2721
2796
 
2722
- <td class="description last"><p>輸入各attempt共用之逾時毫秒正整數,條目可覆寫,預設120000</p></td>
2797
+ <td class="description last"><p>輸入各attempt共用之逾時毫秒正整數,條目可覆寫,全套件統一預設300000</p></td>
2723
2798
  </tr>
2724
2799
 
2725
2800
 
@@ -2833,7 +2908,7 @@ await test()
2833
2908
 
2834
2909
 
2835
2910
  <div class="param-desc">
2836
- <p>回傳Promise,resolve回傳結果物件,除execCli既有欄位(ok、stdout、stderr、code、error、durationMs、attempts、pid)外,追加providerId(實際使用之群組)、keyIndex(實際使用之金鑰索引,無keys時為null)、kind、model、tried(全部嘗試歷程陣列,成功時亦回傳),本函數不會reject</p>
2911
+ <p>回傳Promise,resolve回傳結果物件,除execCli既有欄位(ok、stdout、stderr、code、error、durationMs、attempts、pid)外,追加providerId(實際使用之群組)、keyIndex(實際使用之金鑰索引,無keys時為null)、kind、model、tried(全部嘗試歷程陣列,成功時亦回傳;失敗項含stdout與stderr供診斷被拒原因),本函數不會reject</p>
2837
2912
  </div>
2838
2913
 
2839
2914
 
@@ -2880,7 +2955,7 @@ defaults為共用呼叫設定,各工作流之callOpt與名額規格可逐項
2880
2955
 
2881
2956
  <dt class="tag-source">Source:</dt>
2882
2957
  <dd class="tag-source"><ul class="dummy"><li>
2883
- <a href="dispatchAiWkf.mjs.html">dispatchAiWkf.mjs</a>, <a href="dispatchAiWkf.mjs.html#line97">line 97</a>
2958
+ <a href="dispatchAiWkf.mjs.html">dispatchAiWkf.mjs</a>, <a href="dispatchAiWkf.mjs.html#line106">line 106</a>
2884
2959
  </li></ul></dd>
2885
2960
 
2886
2961
 
@@ -3201,7 +3276,7 @@ agy自身之--print-timeout未給時由timeoutMs推導並預留30秒緩衝,令
3201
3276
 
3202
3277
  <dt class="tag-source">Source:</dt>
3203
3278
  <dd class="tag-source"><ul class="dummy"><li>
3204
- <a href="dispatchAntigravity.mjs.html">dispatchAntigravity.mjs</a>, <a href="dispatchAntigravity.mjs.html#line105">line 105</a>
3279
+ <a href="dispatchAntigravity.mjs.html">dispatchAntigravity.mjs</a>, <a href="dispatchAntigravity.mjs.html#line106">line 106</a>
3205
3280
  </li></ul></dd>
3206
3281
 
3207
3282
 
@@ -3632,12 +3707,12 @@ await test()
3632
3707
 
3633
3708
  <td class="default">
3634
3709
 
3635
- <code>[]</code>
3710
+ <code>自動納入cwd</code>
3636
3711
 
3637
3712
  </td>
3638
3713
 
3639
3714
 
3640
- <td class="description last"><p>輸入加入workspace之目錄字串陣列,逐項展開為<code>--add-dir</code>,預設[]</p></td>
3715
+ <td class="description last"><p>輸入加入workspace之目錄字串陣列,逐項展開為<code>--add-dir</code>。agy以自身scratch目錄為工作區而不採子進程cwd,故未給本參數時自動納入有效cwd令檔案可視範圍與其他CLI轉接器一致;明示給陣列(含空陣列[]代表不揭露任何目錄)則完全尊重呼叫端</p></td>
3641
3716
  </tr>
3642
3717
 
3643
3718
 
@@ -3717,7 +3792,7 @@ await test()
3717
3792
  </td>
3718
3793
 
3719
3794
 
3720
- <td class="description last"><p>輸入逾時毫秒正整數,逾時將強制關閉子進程及其子孫程序,agy為agent型CLI故預設較長之300000,預設300000</p></td>
3795
+ <td class="description last"><p>輸入逾時毫秒正整數,逾時將強制關閉子進程及其子孫程序,全套件統一預設300000(恰對齊agy自身print-timeout預設5m0s)</p></td>
3721
3796
  </tr>
3722
3797
 
3723
3798
 
@@ -3757,7 +3832,7 @@ await test()
3757
3832
  </td>
3758
3833
 
3759
3834
 
3760
- <td class="description last"><p>輸入子進程工作目錄字串,預設process.cwd()</p></td>
3835
+ <td class="description last"><p>輸入子進程工作目錄字串,預設process.cwd()。注意本參數不影響agy之檔案可視範圍(agy以自身scratch目錄為工作區),可視範圍由addDirs決定(未給addDirs時自動納入本目錄)</p></td>
3761
3836
  </tr>
3762
3837
 
3763
3838
 
@@ -3922,7 +3997,7 @@ prompt走HTTP body,無命令列長度限制;
3922
3997
 
3923
3998
  <dt class="tag-source">Source:</dt>
3924
3999
  <dd class="tag-source"><ul class="dummy"><li>
3925
- <a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#line326">line 326</a>
4000
+ <a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#line327">line 327</a>
3926
4001
  </li></ul></dd>
3927
4002
 
3928
4003
 
@@ -4394,12 +4469,12 @@ await test()
4394
4469
 
4395
4470
  <td class="default">
4396
4471
 
4397
- <code>120000</code>
4472
+ <code>300000</code>
4398
4473
 
4399
4474
  </td>
4400
4475
 
4401
4476
 
4402
- <td class="description last"><p>輸入逾時毫秒正整數,逾時將中止請求(含回應串流讀取),預設120000</p></td>
4477
+ <td class="description last"><p>輸入逾時毫秒正整數,逾時將中止請求(含回應串流讀取),全套件統一預設300000</p></td>
4403
4478
  </tr>
4404
4479
 
4405
4480
 
@@ -4604,7 +4679,7 @@ prompt一律走stdin而非位置參數,因摘要內文可達數萬字,當命
4604
4679
 
4605
4680
  <dt class="tag-source">Source:</dt>
4606
4681
  <dd class="tag-source"><ul class="dummy"><li>
4607
- <a href="dispatchClaude.mjs.html">dispatchClaude.mjs</a>, <a href="dispatchClaude.mjs.html#line74">line 74</a>
4682
+ <a href="dispatchClaude.mjs.html">dispatchClaude.mjs</a>, <a href="dispatchClaude.mjs.html#line77">line 77</a>
4608
4683
  </li></ul></dd>
4609
4684
 
4610
4685
 
@@ -4657,7 +4732,7 @@ import dispatchClaude from './src/dispatchClaude.mjs'
4657
4732
 
4658
4733
  let test = async () => {
4659
4734
 
4660
- let r = await dispatchClaude('請只回覆兩個字:完成', { model: 'sonnet', timeoutMs: 120000 })
4735
+ let r = await dispatchClaude('請只回覆兩個字:完成', { model: 'sonnet' })
4661
4736
  console.log(r.ok, r.stdout.trim())
4662
4737
  // => true '完成'
4663
4738
 
@@ -4990,12 +5065,12 @@ await test()
4990
5065
 
4991
5066
  <td class="default">
4992
5067
 
4993
- <code>120000</code>
5068
+ <code>300000</code>
4994
5069
 
4995
5070
  </td>
4996
5071
 
4997
5072
 
4998
- <td class="description last"><p>輸入逾時毫秒正整數,逾時將強制關閉子進程及其子孫程序,預設120000</p></td>
5073
+ <td class="description last"><p>輸入逾時毫秒正整數,逾時將強制關閉子進程及其子孫程序,全套件統一預設300000</p></td>
4999
5074
  </tr>
5000
5075
 
5001
5076
 
@@ -5198,7 +5273,7 @@ prompt一律走stdin而非位置參數,因摘要內文可達數萬字,當命
5198
5273
 
5199
5274
  <dt class="tag-source">Source:</dt>
5200
5275
  <dd class="tag-source"><ul class="dummy"><li>
5201
- <a href="dispatchCodex.mjs.html">dispatchCodex.mjs</a>, <a href="dispatchCodex.mjs.html#line74">line 74</a>
5276
+ <a href="dispatchCodex.mjs.html">dispatchCodex.mjs</a>, <a href="dispatchCodex.mjs.html#line77">line 77</a>
5202
5277
  </li></ul></dd>
5203
5278
 
5204
5279
 
@@ -5584,12 +5659,12 @@ await test()
5584
5659
 
5585
5660
  <td class="default">
5586
5661
 
5587
- <code>120000</code>
5662
+ <code>300000</code>
5588
5663
 
5589
5664
  </td>
5590
5665
 
5591
5666
 
5592
- <td class="description last"><p>輸入逾時毫秒正整數,逾時將強制關閉子進程及其子孫程序,預設120000</p></td>
5667
+ <td class="description last"><p>輸入逾時毫秒正整數,逾時將強制關閉子進程及其子孫程序,全套件統一預設300000</p></td>
5593
5668
  </tr>
5594
5669
 
5595
5670
 
@@ -5794,7 +5869,7 @@ prompt一律走stdin而非位置參數,因摘要內文可達數萬字,當命
5794
5869
 
5795
5870
  <dt class="tag-source">Source:</dt>
5796
5871
  <dd class="tag-source"><ul class="dummy"><li>
5797
- <a href="dispatchOpencode.mjs.html">dispatchOpencode.mjs</a>, <a href="dispatchOpencode.mjs.html#line115">line 115</a>
5872
+ <a href="dispatchOpencode.mjs.html">dispatchOpencode.mjs</a>, <a href="dispatchOpencode.mjs.html#line118">line 118</a>
5798
5873
  </li></ul></dd>
5799
5874
 
5800
5875
 
@@ -6366,12 +6441,12 @@ await test()
6366
6441
 
6367
6442
  <td class="default">
6368
6443
 
6369
- <code>120000</code>
6444
+ <code>300000</code>
6370
6445
 
6371
6446
  </td>
6372
6447
 
6373
6448
 
6374
- <td class="description last"><p>輸入逾時毫秒正整數,逾時將強制關閉子進程及其子孫程序,預設120000</p></td>
6449
+ <td class="description last"><p>輸入逾時毫秒正整數,逾時將強制關閉子進程及其子孫程序,全套件統一預設300000</p></td>
6375
6450
  </tr>
6376
6451
 
6377
6452
 
@@ -7115,7 +7190,7 @@ console.log(getErrorResult(null).error)
7115
7190
 
7116
7191
  <dt class="tag-source">Source:</dt>
7117
7192
  <dd class="tag-source"><ul class="dummy"><li>
7118
- <a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line82">line 82</a>
7193
+ <a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line85">line 85</a>
7119
7194
  </li></ul></dd>
7120
7195
 
7121
7196
 
@@ -7257,6 +7332,357 @@ console.log(getErrorResult(null).error)
7257
7332
 
7258
7333
 
7259
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"> &rarr; {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
+ &lt;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
+ &lt;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
+ &lt;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
+
7260
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"> &rarr; {Promise}</span></h4>
7261
7687
 
7262
7688
 
@@ -8804,7 +9230,7 @@ await test()
8804
9230
  <br class="clear">
8805
9231
 
8806
9232
  <footer>
8807
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Thu Aug 13 2026 21:57:54 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
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.
8808
9234
  </footer>
8809
9235
 
8810
9236
  <script>prettyPrint();</script>