w-dispatch-ai 1.0.35 → 1.0.37

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 (63) hide show
  1. package/README.md +13 -7
  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 +2 -2
  5. package/docs/adapters.mjs.html +2 -2
  6. package/docs/budgetFor.mjs.html +2 -2
  7. package/docs/buildValidator.mjs.html +2 -2
  8. package/docs/castPintOr.mjs.html +2 -2
  9. package/docs/checkTruncation.mjs.html +199 -0
  10. package/docs/dfTimeoutMs.mjs.html +2 -2
  11. package/docs/dispatchAi.mjs.html +2 -2
  12. package/docs/dispatchAiFallback.mjs.html +33 -8
  13. package/docs/dispatchAiWkf.mjs.html +2 -2
  14. package/docs/dispatchAntigravity.mjs.html +2 -2
  15. package/docs/dispatchApiOpenaiCompat.mjs.html +98 -30
  16. package/docs/dispatchApiOpenaiResponses.mjs.html +102 -25
  17. package/docs/dispatchApiTypesafeSystemone.mjs.html +23 -15
  18. package/docs/dispatchClaude.mjs.html +2 -2
  19. package/docs/dispatchCodex.mjs.html +2 -2
  20. package/docs/dispatchOpencode.mjs.html +2 -2
  21. package/docs/getCliArgs.mjs.html +2 -2
  22. package/docs/getErrorResult.mjs.html +2 -2
  23. package/docs/getErrorType.mjs.html +6 -4
  24. package/docs/global.html +1237 -117
  25. package/docs/index.html +2 -2
  26. package/docs/quota_dfQuotaTimeoutMs.mjs.html +2 -2
  27. package/docs/quota_fetchQuotaJson.mjs.html +2 -2
  28. package/docs/quota_fromCodexUsageHttp.mjs.html +2 -2
  29. package/docs/quota_getQuotaAntigravity.mjs.html +2 -2
  30. package/docs/quota_getQuotaClaude.mjs.html +2 -2
  31. package/docs/quota_getQuotaCodex.mjs.html +2 -2
  32. package/docs/quota_readJsonOrNull.mjs.html +2 -2
  33. package/docs/quota_toQuotaLabel.mjs.html +2 -2
  34. package/docs/quota_toQuotaResult.mjs.html +2 -2
  35. package/docs/quota_toQuotaScopedLabel.mjs.html +2 -2
  36. package/docs/quota_toQuotaWindow.mjs.html +2 -2
  37. package/docs/readEnvFile.mjs.html +2 -2
  38. package/docs/resolveProviders.mjs.html +3 -3
  39. package/docs/wkf_callAiWithFallback.mjs.html +63 -20
  40. package/docs/wkf_createFileStore.mjs.html +2 -2
  41. package/docs/wkf_createUsageCounter.mjs.html +2 -2
  42. package/docs/wkf_extractJsonLoose.mjs.html +2 -2
  43. package/docs/wkf_noSideEffectPrefix.mjs.html +2 -2
  44. package/docs/wkf_runFanout.mjs.html +4 -2
  45. package/docs/wkf_runFanoutPipeline.mjs.html +2 -2
  46. package/docs/wkf_runRolePipeline.mjs.html +2 -2
  47. package/docs/wkf_salvageTruncatedArray.mjs.html +11 -2
  48. package/package.json +1 -1
  49. package/src/checkTruncation.mjs +127 -0
  50. package/src/dispatchAiFallback.mjs +31 -6
  51. package/src/dispatchApiOpenaiCompat.mjs +96 -28
  52. package/src/dispatchApiOpenaiResponses.mjs +100 -23
  53. package/src/dispatchApiTypesafeSystemone.mjs +21 -13
  54. package/src/getErrorType.mjs +4 -2
  55. package/src/providers.mjs +41 -8
  56. package/src/resolveProviders.mjs +1 -1
  57. package/src/wkf/callAiWithFallback.mjs +61 -18
  58. package/src/wkf/runFanout.mjs +2 -0
  59. package/src/wkf/salvageTruncatedArray.mjs +9 -0
  60. package/test/tools/fakeServerForApiTest.mjs +79 -2
  61. package/test/unit-dispatchApiOpenaiCompat.test.mjs +169 -1
  62. package/test/unit-dispatchApiOpenaiResponses.test.mjs +63 -5
  63. package/test/unit-dispatchApiTypesafeSystemone.test.mjs +17 -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#NO_SIDE_EFFECT">NO_SIDE_EFFECT</a></li><li><a href="global.html#WDispatchAi">WDispatchAi</a></li><li><a href="global.html#adapters">adapters</a></li><li><a href="global.html#agyPrint">agyPrint</a></li><li><a href="global.html#attachErrorType">attachErrorType</a></li><li><a href="global.html#budgetFor">budgetFor</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#castPintOr">castPintOr</a></li><li><a href="global.html#collectAdditional">collectAdditional</a></li><li><a href="global.html#createFileStore">createFileStore</a></li><li><a href="global.html#createUsageCounter">createUsageCounter</a></li><li><a href="global.html#decodeJwtPayload">decodeJwtPayload</a></li><li><a href="global.html#defaultIntegratePrompt">defaultIntegratePrompt</a></li><li><a href="global.html#dfQuotaTimeoutMs">dfQuotaTimeoutMs</a></li><li><a href="global.html#dfTimeoutMs">dfTimeoutMs</a></li><li><a href="global.html#directWindow">directWindow</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#dispatchApiOpenaiResponses">dispatchApiOpenaiResponses</a></li><li><a href="global.html#dispatchApiTypesafeSystemone">dispatchApiTypesafeSystemone</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#extractOutputText">extractOutputText</a></li><li><a href="global.html#fetchQuotaJson">fetchQuotaJson</a></li><li><a href="global.html#firstStr">firstStr</a></li><li><a href="global.html#fromBucket">fromBucket</a></li><li><a href="global.html#fromCodexUsageHttp">fromCodexUsageHttp</a></li><li><a href="global.html#fromLimitItem">fromLimitItem</a></li><li><a href="global.html#fromRpcWindow">fromRpcWindow</a></li><li><a href="global.html#fromTopField">fromTopField</a></li><li><a href="global.html#fromWindow">fromWindow</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#getErrorType">getErrorType</a></li><li><a href="global.html#getQuotaAntigravity">getQuotaAntigravity</a></li><li><a href="global.html#getQuotaClaude">getQuotaClaude</a></li><li><a href="global.html#getQuotaCodex">getQuotaCodex</a></li><li><a href="global.html#initState">initState</a></li><li><a href="global.html#isKeyIndependentFail">isKeyIndependentFail</a></li><li><a href="global.html#pickWindow">pickWindow</a></li><li><a href="global.html#readBodyCapped">readBodyCapped</a></li><li><a href="global.html#readEnvFile">readEnvFile</a></li><li><a href="global.html#readJsonOrNull">readJsonOrNull</a></li><li><a href="global.html#redactText">redactText</a></li><li><a href="global.html#reorderByCooling">reorderByCooling</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><li><a href="global.html#salvageTruncatedArray">salvageTruncatedArray</a></li><li><a href="global.html#toQuotaLabel">toQuotaLabel</a></li><li><a href="global.html#toQuotaResult">toQuotaResult</a></li><li><a href="global.html#toQuotaScopedLabel">toQuotaScopedLabel</a></li><li><a href="global.html#toQuotaWindow">toQuotaWindow</a></li><li><a href="global.html#viaAppServer">viaAppServer</a></li><li><a href="global.html#viaHttp">viaHttp</a></li><li><a href="global.html#windowToSeconds">windowToSeconds</a></li></ul>
32
+ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#NO_SIDE_EFFECT">NO_SIDE_EFFECT</a></li><li><a href="global.html#WDispatchAi">WDispatchAi</a></li><li><a href="global.html#adapters">adapters</a></li><li><a href="global.html#agyPrint">agyPrint</a></li><li><a href="global.html#attachErrorType">attachErrorType</a></li><li><a href="global.html#budgetFor">budgetFor</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#castPintOr">castPintOr</a></li><li><a href="global.html#collectAdditional">collectAdditional</a></li><li><a href="global.html#createFileStore">createFileStore</a></li><li><a href="global.html#createUsageCounter">createUsageCounter</a></li><li><a href="global.html#decodeJwtPayload">decodeJwtPayload</a></li><li><a href="global.html#defaultIntegratePrompt">defaultIntegratePrompt</a></li><li><a href="global.html#dfQuotaTimeoutMs">dfQuotaTimeoutMs</a></li><li><a href="global.html#dfTimeoutMs">dfTimeoutMs</a></li><li><a href="global.html#directWindow">directWindow</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#dispatchApiOpenaiResponses">dispatchApiOpenaiResponses</a></li><li><a href="global.html#dispatchApiTypesafeSystemone">dispatchApiTypesafeSystemone</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#extractOutputText">extractOutputText</a></li><li><a href="global.html#fetchQuotaJson">fetchQuotaJson</a></li><li><a href="global.html#finOf">finOf</a></li><li><a href="global.html#firstStr">firstStr</a></li><li><a href="global.html#fromBucket">fromBucket</a></li><li><a href="global.html#fromCodexUsageHttp">fromCodexUsageHttp</a></li><li><a href="global.html#fromLimitItem">fromLimitItem</a></li><li><a href="global.html#fromRpcWindow">fromRpcWindow</a></li><li><a href="global.html#fromTopField">fromTopField</a></li><li><a href="global.html#fromWindow">fromWindow</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#getErrorType">getErrorType</a></li><li><a href="global.html#getQuotaAntigravity">getQuotaAntigravity</a></li><li><a href="global.html#getQuotaClaude">getQuotaClaude</a></li><li><a href="global.html#getQuotaCodex">getQuotaCodex</a></li><li><a href="global.html#initState">initState</a></li><li><a href="global.html#isKeyIndependentFail">isKeyIndependentFail</a></li><li><a href="global.html#judgeTruncated">judgeTruncated</a></li><li><a href="global.html#normalizeFinishReason">normalizeFinishReason</a></li><li><a href="global.html#pickWindow">pickWindow</a></li><li><a href="global.html#readBodyCapped">readBodyCapped</a></li><li><a href="global.html#readEnvFile">readEnvFile</a></li><li><a href="global.html#readJsonOrNull">readJsonOrNull</a></li><li><a href="global.html#redactText">redactText</a></li><li><a href="global.html#reorderByCooling">reorderByCooling</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><li><a href="global.html#safeValidate">safeValidate</a></li><li><a href="global.html#salvageTruncatedArray">salvageTruncatedArray</a></li><li><a href="global.html#toQuotaLabel">toQuotaLabel</a></li><li><a href="global.html#toQuotaResult">toQuotaResult</a></li><li><a href="global.html#toQuotaScopedLabel">toQuotaScopedLabel</a></li><li><a href="global.html#toQuotaWindow">toQuotaWindow</a></li><li><a href="global.html#viaAppServer">viaAppServer</a></li><li><a href="global.html#viaHttp">viaHttp</a></li><li><a href="global.html#windowToSeconds">windowToSeconds</a></li></ul>
33
33
 
34
34
  </nav>
35
35
 
@@ -737,7 +737,7 @@ console.log(dfTimeoutMs)
737
737
 
738
738
  <dt class="tag-source">Source:</dt>
739
739
  <dd class="tag-source"><ul class="dummy"><li>
740
- <a href="getErrorType.mjs.html">getErrorType.mjs</a>, <a href="getErrorType.mjs.html#line90">line 90</a>
740
+ <a href="getErrorType.mjs.html">getErrorType.mjs</a>, <a href="getErrorType.mjs.html#line92">line 92</a>
741
741
  </li></ul></dd>
742
742
 
743
743
 
@@ -1079,7 +1079,7 @@ console.log(budgetFor([{ timeoutMs: 180000 }, {}])) //未帶者以套件統一
1079
1079
 
1080
1080
  <dt class="tag-source">Source:</dt>
1081
1081
  <dd class="tag-source"><ul class="dummy"><li>
1082
- <a href="wkf_callAiWithFallback.mjs.html">wkf/callAiWithFallback.mjs</a>, <a href="wkf_callAiWithFallback.mjs.html#line56">line 56</a>
1082
+ <a href="wkf_callAiWithFallback.mjs.html">wkf/callAiWithFallback.mjs</a>, <a href="wkf_callAiWithFallback.mjs.html#line68">line 68</a>
1083
1083
  </li></ul></dd>
1084
1084
 
1085
1085
 
@@ -1455,7 +1455,7 @@ parse+check接進遞補層之validate——非法回覆視為該家失敗而
1455
1455
 
1456
1456
  <dt class="tag-source">Source:</dt>
1457
1457
  <dd class="tag-source"><ul class="dummy"><li>
1458
- <a href="wkf_callAiWithFallback.mjs.html">wkf/callAiWithFallback.mjs</a>, <a href="wkf_callAiWithFallback.mjs.html#line131">line 131</a>
1458
+ <a href="wkf_callAiWithFallback.mjs.html">wkf/callAiWithFallback.mjs</a>, <a href="wkf_callAiWithFallback.mjs.html#line144">line 144</a>
1459
1459
  </li></ul></dd>
1460
1460
 
1461
1461
 
@@ -1849,6 +1849,44 @@ await test()
1849
1849
 
1850
1850
 
1851
1851
 
1852
+ <tr>
1853
+
1854
+ <td class="name"><code>acceptTruncated</code></td>
1855
+
1856
+
1857
+ <td class="type">
1858
+
1859
+
1860
+ <span class="param-type">Boolean</span>
1861
+
1862
+
1863
+
1864
+
1865
+ </td>
1866
+
1867
+
1868
+ <td class="attributes">
1869
+
1870
+ &lt;optional><br>
1871
+
1872
+
1873
+
1874
+
1875
+
1876
+ </td>
1877
+
1878
+
1879
+
1880
+ <td class="default">
1881
+
1882
+ </td>
1883
+
1884
+
1885
+ <td class="description last"><p>輸入是否接受REST文字類轉接器回報之截斷內容(交parse+check裁決)布林值,預設為「有給自訂parse且非rawText」(自訂parse即搶救策略之同意訊號,見salvageTruncatedArray.mjs),其餘情況截斷一律判失敗換家</p></td>
1886
+ </tr>
1887
+
1888
+
1889
+
1852
1890
  <tr>
1853
1891
 
1854
1892
  <td class="name"><code>promptPrefix</code></td>
@@ -2044,7 +2082,7 @@ await test()
2044
2082
  </td>
2045
2083
 
2046
2084
 
2047
- <td class="description last"><p>輸入同家重試次數非負整數,預設0(韌性交給遞補;端點不穩偶發空回之模型可調高令同鍵重試)</p></td>
2085
+ <td class="description last"><p>輸入同家重試次數非負整數,預設0(韌性交給遞補;端點不穩偶發空回之模型可調高令同鍵重試;截斷不重試)</p></td>
2048
2086
  </tr>
2049
2087
 
2050
2088
 
@@ -2235,7 +2273,7 @@ await test()
2235
2273
 
2236
2274
 
2237
2275
  <div class="param-desc">
2238
- <p>回傳Promise,resolve回傳結果物件,內含ok(是否取得可用結果布林值)、json(解析後物件,rawText模式下為文字)、providerId(實際使用之名稱)、keyIndex、keyId、ms(總耗時毫秒)、tried(遞補嘗試歷程陣列)、usage(api類之token用量原樣透傳,CLI類為null)、error(錯誤訊息字串)、errorType(僅失敗時,機器可讀錯誤類別字串,一覽見getErrorType.mjs檔頭),本函數不會reject</p>
2276
+ <p>回傳Promise,resolve回傳結果物件,內含ok(是否取得可用結果布林值)、json(解析後物件,rawText模式下為文字)、providerId(實際使用之名稱)、keyIndex、keyId、ms(總耗時毫秒)、tried(遞補嘗試歷程陣列)、usage(api類之token用量原樣透傳,CLI類為null)、finishReason(REST文字類之正規化終止原因字串,CLI類為'')、truncated(是否為截斷內容布林值,接受搶救時ok亦可能為true)、error(錯誤訊息字串)、errorType(僅失敗時,機器可讀錯誤類別字串,一覽見getErrorType.mjs檔頭),本函數不會reject</p>
2239
2277
  </div>
2240
2278
 
2241
2279
 
@@ -2262,7 +2300,7 @@ await test()
2262
2300
 
2263
2301
 
2264
2302
 
2265
- <h4 class="name" id="callOnce"><span class="type-signature type-signature-async">(async) </span>callOnce<span class="signature">(url, headers, body, timeoutMs, validator)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
2303
+ <h4 class="name" id="callOnce"><span class="type-signature type-signature-async">(async) </span>callOnce<span class="signature">(url, headers, body, timeoutMs, validator, acceptTruncated)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
2266
2304
 
2267
2305
 
2268
2306
 
@@ -2278,7 +2316,7 @@ await test()
2278
2316
 
2279
2317
  <dt class="tag-source">Source:</dt>
2280
2318
  <dd class="tag-source"><ul class="dummy"><li>
2281
- <a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#line77">line 77</a>
2319
+ <a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#line94">line 94</a>
2282
2320
  </li></ul></dd>
2283
2321
 
2284
2322
 
@@ -2470,6 +2508,30 @@ await test()
2470
2508
  </tr>
2471
2509
 
2472
2510
 
2511
+
2512
+ <tr>
2513
+
2514
+ <td class="name"><code>acceptTruncated</code></td>
2515
+
2516
+
2517
+ <td class="type">
2518
+
2519
+
2520
+ <span class="param-type">Boolean</span>
2521
+
2522
+
2523
+
2524
+
2525
+ </td>
2526
+
2527
+
2528
+
2529
+
2530
+
2531
+ <td class="description last"><p>輸入是否明示接受截斷內容</p></td>
2532
+ </tr>
2533
+
2534
+
2473
2535
  </tbody>
2474
2536
  </table>
2475
2537
 
@@ -2519,7 +2581,7 @@ await test()
2519
2581
 
2520
2582
 
2521
2583
 
2522
- <h4 class="name" id="callOnce"><span class="type-signature type-signature-async">(async) </span>callOnce<span class="signature">(url, headers, body, timeoutMs, validator)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
2584
+ <h4 class="name" id="callOnce"><span class="type-signature type-signature-async">(async) </span>callOnce<span class="signature">(url, headers, body, timeoutMs, validator, acceptTruncated)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
2523
2585
 
2524
2586
 
2525
2587
 
@@ -2535,7 +2597,7 @@ await test()
2535
2597
 
2536
2598
  <dt class="tag-source">Source:</dt>
2537
2599
  <dd class="tag-source"><ul class="dummy"><li>
2538
- <a href="dispatchApiOpenaiResponses.mjs.html">dispatchApiOpenaiResponses.mjs</a>, <a href="dispatchApiOpenaiResponses.mjs.html#line120">line 120</a>
2600
+ <a href="dispatchApiOpenaiResponses.mjs.html">dispatchApiOpenaiResponses.mjs</a>, <a href="dispatchApiOpenaiResponses.mjs.html#line129">line 129</a>
2539
2601
  </li></ul></dd>
2540
2602
 
2541
2603
 
@@ -2727,6 +2789,30 @@ await test()
2727
2789
  </tr>
2728
2790
 
2729
2791
 
2792
+
2793
+ <tr>
2794
+
2795
+ <td class="name"><code>acceptTruncated</code></td>
2796
+
2797
+
2798
+ <td class="type">
2799
+
2800
+
2801
+ <span class="param-type">Boolean</span>
2802
+
2803
+
2804
+
2805
+
2806
+ </td>
2807
+
2808
+
2809
+
2810
+
2811
+
2812
+ <td class="description last"><p>輸入是否明示接受截斷內容</p></td>
2813
+ </tr>
2814
+
2815
+
2730
2816
  </tbody>
2731
2817
  </table>
2732
2818
 
@@ -2792,7 +2878,7 @@ await test()
2792
2878
 
2793
2879
  <dt class="tag-source">Source:</dt>
2794
2880
  <dd class="tag-source"><ul class="dummy"><li>
2795
- <a href="dispatchApiTypesafeSystemone.mjs.html">dispatchApiTypesafeSystemone.mjs</a>, <a href="dispatchApiTypesafeSystemone.mjs.html#line78">line 78</a>
2881
+ <a href="dispatchApiTypesafeSystemone.mjs.html">dispatchApiTypesafeSystemone.mjs</a>, <a href="dispatchApiTypesafeSystemone.mjs.html#line82">line 82</a>
2796
2882
  </li></ul></dd>
2797
2883
 
2798
2884
 
@@ -4480,7 +4566,7 @@ let usage = createUsageCounter({ dir: './state' })
4480
4566
 
4481
4567
  <dt class="tag-source">Source:</dt>
4482
4568
  <dd class="tag-source"><ul class="dummy"><li>
4483
- <a href="wkf_runFanout.mjs.html">wkf/runFanout.mjs</a>, <a href="wkf_runFanout.mjs.html#line31">line 31</a>
4569
+ <a href="wkf_runFanout.mjs.html">wkf/runFanout.mjs</a>, <a href="wkf_runFanout.mjs.html#line33">line 33</a>
4484
4570
  </li></ul></dd>
4485
4571
 
4486
4572
 
@@ -5133,7 +5219,7 @@ await test()
5133
5219
  providers陣列順序即優先序,排前面的先用;
5134
5220
  條目本身即該次調用之opt(除id與keys外原樣透傳對應轉接器),與dispatchAi「條目直接當opt」同一約定;
5135
5221
  條目給予keys(多把金鑰)時以游標輪替,某把失敗自動換下一把,全數失敗才遞補下一組;
5136
- 與金鑰無關之失敗(逾時/執行檔不存在/參數錯誤/輸出未過驗證/未知kind)直接整組跳過,不逐把空耗;
5222
+ 與金鑰無關之失敗(逾時/執行檔不存在/參數錯誤/輸出未過驗證/未知kind/截斷/工具不支援)直接整組跳過,不逐把空耗;
5137
5223
  跨次執行僅記憶游標(經store注入持久化),不設金鑰停用清單——額度視窗形態多樣(5小時滾動/逐時/逐日),
5138
5224
  停用會把已恢復的金鑰閒置,而重探的代價僅一次快速失敗;
5139
5225
  本函數不會reject,一律以結果物件之ok與error欄位回報成敗</p></li></ul></dd>
@@ -5142,7 +5228,7 @@ providers陣列順序即優先序,排前面的先用;
5142
5228
 
5143
5229
  <dt class="tag-source">Source:</dt>
5144
5230
  <dd class="tag-source"><ul class="dummy"><li>
5145
- <a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line291">line 291</a>
5231
+ <a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line316">line 316</a>
5146
5232
  </li></ul></dd>
5147
5233
 
5148
5234
 
@@ -6007,7 +6093,7 @@ await test()
6007
6093
 
6008
6094
 
6009
6095
  <div class="param-desc">
6010
- <p>回傳Promise,resolve回傳結果物件,除execCli既有欄位(ok、stdout、stderr、code、error、durationMs、attempts、pid)外,追加providerId(實際使用之群組)、keyIndex(實際使用之金鑰索引,無keys時為null)、kind、model、tried(全部嘗試歷程陣列,成功時亦回傳;失敗項含errorType、stdout與stderr供診斷被拒原因);失敗結果帶機器可讀之errorType(一覽見getErrorType.mjs檔頭);api類轉接器提供usage(token用量)時原樣流出於結果與tried各項,CLI類無此欄;本函數不會reject</p>
6096
+ <p>回傳Promise,resolve回傳結果物件,除execCli既有欄位(ok、stdout、stderr、code、error、durationMs、attempts、pid)外,追加providerId(實際使用之群組)、keyIndex(實際使用之金鑰索引,無keys時為null)、kind、model、tried(全部嘗試歷程陣列,成功時亦回傳;失敗項含errorType、stdout與stderr供診斷被拒原因);失敗結果帶機器可讀之errorType(一覽見getErrorType.mjs檔頭);api類轉接器提供usage(token用量)時原樣流出於結果與tried各項,CLI類無此欄;REST文字類轉接器另帶finishReason與truncated(是否截斷),同樣流出於結果與tried各項;本函數不會reject</p>
6011
6097
  </div>
6012
6098
 
6013
6099
 
@@ -7096,7 +7182,7 @@ prompt走HTTP body,無命令列長度限制;
7096
7182
 
7097
7183
  <dt class="tag-source">Source:</dt>
7098
7184
  <dd class="tag-source"><ul class="dummy"><li>
7099
- <a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#line262">line 262</a>
7185
+ <a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#line322">line 322</a>
7100
7186
  </li></ul></dd>
7101
7187
 
7102
7188
 
@@ -7159,7 +7245,8 @@ let test = async () => {
7159
7245
  // => true 完成
7160
7246
 
7161
7247
  //OpenCode Zen(即opencode CLI之自家閘道), 模型名不帶opencode/前綴; 走此端點者見providers.mjs檔頭之端點表
7162
- //注意Zen之免費模型自2026-09-17起禁止REST直呼(403 FreeTierError), 該類模型須改走opencode CLI(kind:'opencode')
7248
+ //注意Zen之免費模型自2026-09-17起多數禁止REST直呼(403 FreeTierError), 該類模型須改走opencode CLI(kind:'opencode');
7249
+ //閘門係逐模型套用(如space-bunny-free於2026-09-24實測REST仍200), 能否走REST以實測為準, 例外見providers.mjs檔頭
7163
7250
  let r2 = await dispatchApiOpenaiCompat('請只回覆兩個字:完成', {
7164
7251
  baseURL: 'https://opencode.ai/zen/v1',
7165
7252
  key: 'sk-xxxxxx',
@@ -7534,7 +7621,7 @@ await test()
7534
7621
  </td>
7535
7622
 
7536
7623
 
7537
- <td class="description last"><p>輸入額外請求標頭物件,預設{}</p></td>
7624
+ <td class="description last"><p>輸入額外請求標頭物件,同名鍵覆寫預設標頭;預設標頭含'Accept-Encoding: identity'(防伺服器壓縮卻漏標Content-Encoding,見檔頭),要改回允許壓縮可給{'Accept-Encoding':'gzip, deflate, br'},預設{}</p></td>
7538
7625
  </tr>
7539
7626
 
7540
7627
 
@@ -7615,7 +7702,47 @@ await test()
7615
7702
  </td>
7616
7703
 
7617
7704
 
7618
- <td class="description last"><p>輸入回覆內容驗證規則字串或自訂驗證函數,規則字串支援'nonempty'、'json'、'min:100',多規則可用逗號串接,預設undefined代表不驗證</p></td>
7705
+ <td class="description last"><p>輸入回覆內容驗證規則字串或自訂驗證函數,規則字串支援'nonempty'、'json'、'min:100',多規則可用逗號串接,自訂函數拋錯視同驗證失敗,預設undefined代表不驗證</p></td>
7706
+ </tr>
7707
+
7708
+
7709
+
7710
+ <tr>
7711
+
7712
+ <td class="name"><code>acceptTruncated</code></td>
7713
+
7714
+
7715
+ <td class="type">
7716
+
7717
+
7718
+ <span class="param-type">Boolean</span>
7719
+
7720
+
7721
+
7722
+
7723
+ </td>
7724
+
7725
+
7726
+ <td class="attributes">
7727
+
7728
+ &lt;optional><br>
7729
+
7730
+
7731
+
7732
+
7733
+
7734
+ </td>
7735
+
7736
+
7737
+
7738
+ <td class="default">
7739
+
7740
+ <code>false</code>
7741
+
7742
+ </td>
7743
+
7744
+
7745
+ <td class="description last"><p>輸入是否接受被截斷(finish_reason為length)之內容布林值,true代表交validate裁決(無validate則直接接受)且結果標truncated:true;content_filter與可見輸出為空者一律失敗,預設false代表截斷一律失敗(errorType incomplete)</p></td>
7619
7746
  </tr>
7620
7747
 
7621
7748
 
@@ -7655,7 +7782,7 @@ await test()
7655
7782
  </td>
7656
7783
 
7657
7784
 
7658
- <td class="description last"><p>輸入失敗後最大重試次數非負整數,4xx(429除外)不重試,預設0</p></td>
7785
+ <td class="description last"><p>輸入失敗後最大重試次數非負整數,4xx(429除外)與截斷不重試,預設0</p></td>
7659
7786
  </tr>
7660
7787
 
7661
7788
 
@@ -7728,7 +7855,7 @@ await test()
7728
7855
 
7729
7856
 
7730
7857
  <div class="param-desc">
7731
- <p>回傳Promise,resolve回傳結果物件,內含ok(是否成功布林值)、stdout(回覆內容字串)、stderr(失敗時之原始回應本體)、code(HTTP狀態碼,網路錯誤與逾時為null)、error(錯誤訊息字串,成功時為空字串)、errorType(僅失敗時,機器可讀錯誤類別字串,一覽見getErrorType.mjs檔頭)、durationMs(耗時毫秒)、attempts(實際嘗試次數)、usage(原始回應之token用量物件原樣透傳,無則null),本函數不會reject</p>
7858
+ <p>回傳Promise,resolve回傳結果物件,內含ok(是否成功布林值)、stdout(回覆內容字串)、stderr(失敗時之原始回應本體)、code(HTTP狀態碼,網路錯誤與逾時為null)、error(錯誤訊息字串,成功時為空字串)、errorType(僅失敗時,機器可讀錯誤類別字串,一覽見getErrorType.mjs檔頭)、durationMs(耗時毫秒)、attempts(實際嘗試次數)、usage(原始回應之token用量物件原樣透傳,無則null)、finishReason(已取得回應時之正規化終止原因字串,缺值為'')、truncated(已取得回應時是否被截斷布林值),本函數不會reject</p>
7732
7859
  </div>
7733
7860
 
7734
7861
 
@@ -7779,7 +7906,7 @@ status非completed(如max_output_tokens耗盡)一律以INCOMPLETE_RESPONSE回報
7779
7906
 
7780
7907
  <dt class="tag-source">Source:</dt>
7781
7908
  <dd class="tag-source"><ul class="dummy"><li>
7782
- <a href="dispatchApiOpenaiResponses.mjs.html">dispatchApiOpenaiResponses.mjs</a>, <a href="dispatchApiOpenaiResponses.mjs.html#line322">line 322</a>
7909
+ <a href="dispatchApiOpenaiResponses.mjs.html">dispatchApiOpenaiResponses.mjs</a>, <a href="dispatchApiOpenaiResponses.mjs.html#line391">line 391</a>
7783
7910
  </li></ul></dd>
7784
7911
 
7785
7912
 
@@ -8207,7 +8334,7 @@ await test()
8207
8334
  </td>
8208
8335
 
8209
8336
 
8210
- <td class="description last"><p>輸入額外請求標頭物件,預設{}</p></td>
8337
+ <td class="description last"><p>輸入額外請求標頭物件,同名鍵覆寫預設標頭;預設標頭含'Accept-Encoding: identity'(防伺服器壓縮卻漏標Content-Encoding,見檔頭),預設{}</p></td>
8211
8338
  </tr>
8212
8339
 
8213
8340
 
@@ -8288,7 +8415,47 @@ await test()
8288
8415
  </td>
8289
8416
 
8290
8417
 
8291
- <td class="description last"><p>輸入回覆內容驗證規則字串或自訂驗證函數,規則字串支援'nonempty'、'json'、'min:100',多規則可用逗號串接,預設undefined代表不驗證</p></td>
8418
+ <td class="description last"><p>輸入回覆內容驗證規則字串或自訂驗證函數,規則字串支援'nonempty'、'json'、'min:100',多規則可用逗號串接,自訂函數拋錯視同驗證失敗,預設undefined代表不驗證</p></td>
8419
+ </tr>
8420
+
8421
+
8422
+
8423
+ <tr>
8424
+
8425
+ <td class="name"><code>acceptTruncated</code></td>
8426
+
8427
+
8428
+ <td class="type">
8429
+
8430
+
8431
+ <span class="param-type">Boolean</span>
8432
+
8433
+
8434
+
8435
+
8436
+ </td>
8437
+
8438
+
8439
+ <td class="attributes">
8440
+
8441
+ &lt;optional><br>
8442
+
8443
+
8444
+
8445
+
8446
+
8447
+ </td>
8448
+
8449
+
8450
+
8451
+ <td class="default">
8452
+
8453
+ <code>false</code>
8454
+
8455
+ </td>
8456
+
8457
+
8458
+ <td class="description last"><p>輸入是否接受被截斷(status為incomplete且reason為max_output_tokens)之內容布林值,true代表交validate裁決(無validate則直接接受)且結果標truncated:true;content_filter與可見輸出為空者一律失敗,預設false代表截斷一律失敗</p></td>
8292
8459
  </tr>
8293
8460
 
8294
8461
 
@@ -8328,7 +8495,7 @@ await test()
8328
8495
  </td>
8329
8496
 
8330
8497
 
8331
- <td class="description last"><p>輸入失敗後最大重試次數非負整數,4xx(429除外)不重試,預設0</p></td>
8498
+ <td class="description last"><p>輸入失敗後最大重試次數非負整數,4xx(429除外)與截斷不重試,預設0</p></td>
8332
8499
  </tr>
8333
8500
 
8334
8501
 
@@ -8401,7 +8568,7 @@ await test()
8401
8568
 
8402
8569
 
8403
8570
  <div class="param-desc">
8404
- <p>回傳Promise,resolve回傳結果物件,內含ok(是否成功布林值)、stdout(回覆內容字串)、stderr(失敗時之原始回應本體)、code(HTTP狀態碼,網路錯誤與逾時為null)、error(錯誤訊息字串,成功時為空字串)、errorType(僅失敗時,機器可讀錯誤類別字串,一覽見getErrorType.mjs檔頭)、durationMs(耗時毫秒)、attempts(實際嘗試次數)、usage(原始回應之token用量物件原樣透傳,欄位名為input_tokens/output_tokens/total_tokens,無則null),本函數不會reject</p>
8571
+ <p>回傳Promise,resolve回傳結果物件,內含ok(是否成功布林值)、stdout(回覆內容字串)、stderr(失敗時之原始回應本體)、code(HTTP狀態碼,網路錯誤與逾時為null)、error(錯誤訊息字串,成功時為空字串)、errorType(僅失敗時,機器可讀錯誤類別字串,一覽見getErrorType.mjs檔頭)、durationMs(耗時毫秒)、attempts(實際嘗試次數)、usage(原始回應之token用量物件原樣透傳,欄位名為input_tokens/output_tokens/total_tokens,無則null)、finishReason(已取得回應時之正規化終止原因字串,completed為'stop'、max_output_tokens為'length')、truncated(已取得回應時是否被截斷布林值,僅status為incomplete時為true),本函數不會reject</p>
8405
8572
  </div>
8406
8573
 
8407
8574
 
@@ -8452,7 +8619,7 @@ stdout為answers之JSON字串,另於結果追加answers(已解析物件)與mod
8452
8619
 
8453
8620
  <dt class="tag-source">Source:</dt>
8454
8621
  <dd class="tag-source"><ul class="dummy"><li>
8455
- <a href="dispatchApiTypesafeSystemone.mjs.html">dispatchApiTypesafeSystemone.mjs</a>, <a href="dispatchApiTypesafeSystemone.mjs.html#line270">line 270</a>
8622
+ <a href="dispatchApiTypesafeSystemone.mjs.html">dispatchApiTypesafeSystemone.mjs</a>, <a href="dispatchApiTypesafeSystemone.mjs.html#line278">line 278</a>
8456
8623
  </li></ul></dd>
8457
8624
 
8458
8625
 
@@ -8893,7 +9060,7 @@ await test()
8893
9060
  </td>
8894
9061
 
8895
9062
 
8896
- <td class="description last"><p>輸入額外請求標頭物件,預設{}</p></td>
9063
+ <td class="description last"><p>輸入額外請求標頭物件,同名鍵覆寫預設標頭;預設標頭含'Accept-Encoding: identity'(防伺服器壓縮卻漏標Content-Encoding,見檔頭),預設{}</p></td>
8897
9064
  </tr>
8898
9065
 
8899
9066
 
@@ -8974,7 +9141,7 @@ await test()
8974
9141
  </td>
8975
9142
 
8976
9143
 
8977
- <td class="description last"><p>輸入stdout(answers之JSON字串)驗證規則字串或自訂驗證函數,規則字串支援'nonempty'、'json'、'min:100',多規則可用逗號串接,預設undefined代表不驗證</p></td>
9144
+ <td class="description last"><p>輸入stdout(answers之JSON字串)驗證規則字串或自訂驗證函數,規則字串支援'nonempty'、'json'、'min:100',多規則可用逗號串接,自訂函數拋錯視同驗證失敗,預設undefined代表不驗證</p></td>
8978
9145
  </tr>
8979
9146
 
8980
9147
 
@@ -11329,7 +11496,7 @@ console.log(extractJsonLoose('純文字回覆'))
11329
11496
 
11330
11497
  <dt class="tag-source">Source:</dt>
11331
11498
  <dd class="tag-source"><ul class="dummy"><li>
11332
- <a href="dispatchApiOpenaiResponses.mjs.html">dispatchApiOpenaiResponses.mjs</a>, <a href="dispatchApiOpenaiResponses.mjs.html#line86">line 86</a>
11499
+ <a href="dispatchApiOpenaiResponses.mjs.html">dispatchApiOpenaiResponses.mjs</a>, <a href="dispatchApiOpenaiResponses.mjs.html#line94">line 94</a>
11333
11500
  </li></ul></dd>
11334
11501
 
11335
11502
 
@@ -11988,7 +12155,7 @@ test()</code></pre>
11988
12155
 
11989
12156
 
11990
12157
 
11991
- <h4 class="name" id="firstStr"><span class="type-signature"></span>firstStr<span class="signature">(o, keys)</span><span class="type-signature"> &rarr; {String}</span></h4>
12158
+ <h4 class="name" id="finOf"><span class="type-signature"></span>finOf<span class="signature">(r)</span><span class="type-signature"> &rarr; {Object}</span></h4>
11992
12159
 
11993
12160
 
11994
12161
 
@@ -11998,13 +12165,13 @@ test()</code></pre>
11998
12165
  <dl class="details">
11999
12166
 
12000
12167
  <dt class="tag-description">Description:</dt>
12001
- <dd class="tag-description"><ul class="dummy"><li><p>取第一個為非空字串之鍵值</p></li></ul></dd>
12168
+ <dd class="tag-description"><ul class="dummy"><li><p>取結果之截斷資訊供tried各項記錄(REST文字類轉接器才帶, 其餘kind回空物件)</p></li></ul></dd>
12002
12169
 
12003
12170
 
12004
12171
 
12005
12172
  <dt class="tag-source">Source:</dt>
12006
12173
  <dd class="tag-source"><ul class="dummy"><li>
12007
- <a href="quota_fromCodexUsageHttp.mjs.html">quota/fromCodexUsageHttp.mjs</a>, <a href="quota_fromCodexUsageHttp.mjs.html#line36">line 36</a>
12174
+ <a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line187">line 187</a>
12008
12175
  </li></ul></dd>
12009
12176
 
12010
12177
 
@@ -12076,7 +12243,7 @@ test()</code></pre>
12076
12243
 
12077
12244
  <tr>
12078
12245
 
12079
- <td class="name"><code>o</code></td>
12246
+ <td class="name"><code>r</code></td>
12080
12247
 
12081
12248
 
12082
12249
  <td class="type">
@@ -12093,31 +12260,7 @@ test()</code></pre>
12093
12260
 
12094
12261
 
12095
12262
 
12096
- <td class="description last"><p>輸入物件</p></td>
12097
- </tr>
12098
-
12099
-
12100
-
12101
- <tr>
12102
-
12103
- <td class="name"><code>keys</code></td>
12104
-
12105
-
12106
- <td class="type">
12107
-
12108
-
12109
- <span class="param-type">Array</span>
12110
-
12111
-
12112
-
12113
-
12114
- </td>
12115
-
12116
-
12117
-
12118
-
12119
-
12120
- <td class="description last"><p>輸入鍵陣列</p></td>
12263
+ <td class="description last"><p>輸入dispatchAi結果物件</p></td>
12121
12264
  </tr>
12122
12265
 
12123
12266
 
@@ -12143,7 +12286,7 @@ test()</code></pre>
12143
12286
 
12144
12287
 
12145
12288
  <div class="param-desc">
12146
- <p>回傳字串, 皆無回傳''</p>
12289
+ <p>回傳物件,含truncated與finishReason,或空物件</p>
12147
12290
  </div>
12148
12291
 
12149
12292
 
@@ -12154,7 +12297,7 @@ test()</code></pre>
12154
12297
  </dt>
12155
12298
  <dd>
12156
12299
 
12157
- <span class="param-type">String</span>
12300
+ <span class="param-type">Object</span>
12158
12301
 
12159
12302
 
12160
12303
 
@@ -12170,7 +12313,7 @@ test()</code></pre>
12170
12313
 
12171
12314
 
12172
12315
 
12173
- <h4 class="name" id="fromBucket"><span class="type-signature"></span>fromBucket<span class="signature">(g, b)</span><span class="type-signature"> &rarr; {Object|null}</span></h4>
12316
+ <h4 class="name" id="firstStr"><span class="type-signature"></span>firstStr<span class="signature">(o, keys)</span><span class="type-signature"> &rarr; {String}</span></h4>
12174
12317
 
12175
12318
 
12176
12319
 
@@ -12180,13 +12323,13 @@ test()</code></pre>
12180
12323
  <dl class="details">
12181
12324
 
12182
12325
  <dt class="tag-description">Description:</dt>
12183
- <dd class="tag-description"><ul class="dummy"><li><p>將群組內之單一桶正規化為統一窗口物件</p></li></ul></dd>
12326
+ <dd class="tag-description"><ul class="dummy"><li><p>取第一個為非空字串之鍵值</p></li></ul></dd>
12184
12327
 
12185
12328
 
12186
12329
 
12187
12330
  <dt class="tag-source">Source:</dt>
12188
12331
  <dd class="tag-source"><ul class="dummy"><li>
12189
- <a href="quota_getQuotaAntigravity.mjs.html">quota/getQuotaAntigravity.mjs</a>, <a href="quota_getQuotaAntigravity.mjs.html#line99">line 99</a>
12332
+ <a href="quota_fromCodexUsageHttp.mjs.html">quota/fromCodexUsageHttp.mjs</a>, <a href="quota_fromCodexUsageHttp.mjs.html#line36">line 36</a>
12190
12333
  </li></ul></dd>
12191
12334
 
12192
12335
 
@@ -12258,7 +12401,7 @@ test()</code></pre>
12258
12401
 
12259
12402
  <tr>
12260
12403
 
12261
- <td class="name"><code>g</code></td>
12404
+ <td class="name"><code>o</code></td>
12262
12405
 
12263
12406
 
12264
12407
  <td class="type">
@@ -12275,20 +12418,20 @@ test()</code></pre>
12275
12418
 
12276
12419
 
12277
12420
 
12278
- <td class="description last"><p>輸入群組物件</p></td>
12421
+ <td class="description last"><p>輸入物件</p></td>
12279
12422
  </tr>
12280
12423
 
12281
12424
 
12282
12425
 
12283
12426
  <tr>
12284
12427
 
12285
- <td class="name"><code>b</code></td>
12428
+ <td class="name"><code>keys</code></td>
12286
12429
 
12287
12430
 
12288
12431
  <td class="type">
12289
12432
 
12290
12433
 
12291
- <span class="param-type">Object</span>
12434
+ <span class="param-type">Array</span>
12292
12435
 
12293
12436
 
12294
12437
 
@@ -12299,7 +12442,7 @@ test()</code></pre>
12299
12442
 
12300
12443
 
12301
12444
 
12302
- <td class="description last"><p>輸入桶物件</p></td>
12445
+ <td class="description last"><p>輸入鍵陣列</p></td>
12303
12446
  </tr>
12304
12447
 
12305
12448
 
@@ -12325,7 +12468,7 @@ test()</code></pre>
12325
12468
 
12326
12469
 
12327
12470
  <div class="param-desc">
12328
- <p>回傳統一窗口物件, 桶無id或無剩餘比例回傳null</p>
12471
+ <p>回傳字串, 皆無回傳''</p>
12329
12472
  </div>
12330
12473
 
12331
12474
 
@@ -12336,10 +12479,7 @@ test()</code></pre>
12336
12479
  </dt>
12337
12480
  <dd>
12338
12481
 
12339
- <span class="param-type">Object</span>
12340
- |
12341
-
12342
- <span class="param-type">null</span>
12482
+ <span class="param-type">String</span>
12343
12483
 
12344
12484
 
12345
12485
 
@@ -12355,7 +12495,7 @@ test()</code></pre>
12355
12495
 
12356
12496
 
12357
12497
 
12358
- <h4 class="name" id="fromCodexUsageHttp"><span class="type-signature"></span>fromCodexUsageHttp<span class="signature">(data)</span><span class="type-signature"> &rarr; {Object}</span></h4>
12498
+ <h4 class="name" id="fromBucket"><span class="type-signature"></span>fromBucket<span class="signature">(g, b)</span><span class="type-signature"> &rarr; {Object|null}</span></h4>
12359
12499
 
12360
12500
 
12361
12501
 
@@ -12365,16 +12505,13 @@ test()</code></pre>
12365
12505
  <dl class="details">
12366
12506
 
12367
12507
  <dt class="tag-description">Description:</dt>
12368
- <dd class="tag-description"><ul class="dummy"><li><p>將chatgpt.com之/wham/usage回應對映為統一結構</p>
12369
- <p>主窗口(rate_limit.primary_window / secondary_window)、程式碼審查限額(code_review_rate_limit)、
12370
- 以及寬容解析之additional_rate_limits皆納入windows;額外限額之窗口鍵為「&lt;識別&gt;:primary|secondary」,
12371
- scope為其顯示名或識別。任何欄位缺漏皆略過該窗口而不拋錯</p></li></ul></dd>
12508
+ <dd class="tag-description"><ul class="dummy"><li><p>將群組內之單一桶正規化為統一窗口物件</p></li></ul></dd>
12372
12509
 
12373
12510
 
12374
12511
 
12375
12512
  <dt class="tag-source">Source:</dt>
12376
12513
  <dd class="tag-source"><ul class="dummy"><li>
12377
- <a href="quota_fromCodexUsageHttp.mjs.html">quota/fromCodexUsageHttp.mjs</a>, <a href="quota_fromCodexUsageHttp.mjs.html#line176">line 176</a>
12514
+ <a href="quota_getQuotaAntigravity.mjs.html">quota/getQuotaAntigravity.mjs</a>, <a href="quota_getQuotaAntigravity.mjs.html#line99">line 99</a>
12378
12515
  </li></ul></dd>
12379
12516
 
12380
12517
 
@@ -12419,20 +12556,6 @@ scope為其顯示名或識別。任何欄位缺漏皆略過該窗口而不拋錯
12419
12556
 
12420
12557
 
12421
12558
 
12422
- <h5 class="h5-examples">Example</h5>
12423
-
12424
- <pre class="prettyprint"><code>import fromCodexUsageHttp from './src/quota/fromCodexUsageHttp.mjs'
12425
-
12426
- let m = fromCodexUsageHttp({
12427
- email: 'a@b.c',
12428
- plan_type: 'plus',
12429
- rate_limit: { primary_window: { used_percent: 42, limit_window_seconds: 18000, reset_after_seconds: 100 } },
12430
- additional_rate_limits: [{ limit_name: 'codex-spark', primary_window: { used_percent: 12, limit_window_seconds: 18000 } }],
12431
- })
12432
- console.log(m.windows.map((w) => `${w.key}=${w.label}`))
12433
- // => [ 'primary=5小時', 'codex-spark:primary=5小時(codex-spark)' ]</code></pre>
12434
-
12435
-
12436
12559
 
12437
12560
 
12438
12561
  <h5 class="h5-parameters">Parameters:</h5>
@@ -12460,7 +12583,7 @@ console.log(m.windows.map((w) => `${w.key}=${w.label}`))
12460
12583
 
12461
12584
  <tr>
12462
12585
 
12463
- <td class="name"><code>data</code></td>
12586
+ <td class="name"><code>g</code></td>
12464
12587
 
12465
12588
 
12466
12589
  <td class="type">
@@ -12477,13 +12600,215 @@ console.log(m.windows.map((w) => `${w.key}=${w.label}`))
12477
12600
 
12478
12601
 
12479
12602
 
12480
- <td class="description last"><p>輸入/wham/usage之回應物件</p></td>
12603
+ <td class="description last"><p>輸入群組物件</p></td>
12481
12604
  </tr>
12482
12605
 
12483
12606
 
12484
- </tbody>
12485
- </table>
12486
-
12607
+
12608
+ <tr>
12609
+
12610
+ <td class="name"><code>b</code></td>
12611
+
12612
+
12613
+ <td class="type">
12614
+
12615
+
12616
+ <span class="param-type">Object</span>
12617
+
12618
+
12619
+
12620
+
12621
+ </td>
12622
+
12623
+
12624
+
12625
+
12626
+
12627
+ <td class="description last"><p>輸入桶物件</p></td>
12628
+ </tr>
12629
+
12630
+
12631
+ </tbody>
12632
+ </table>
12633
+
12634
+
12635
+
12636
+
12637
+
12638
+
12639
+
12640
+
12641
+
12642
+
12643
+
12644
+
12645
+
12646
+
12647
+
12648
+
12649
+ <h5 class="h5-returns">Returns:</h5>
12650
+
12651
+
12652
+ <div class="param-desc">
12653
+ <p>回傳統一窗口物件, 桶無id或無剩餘比例回傳null</p>
12654
+ </div>
12655
+
12656
+
12657
+
12658
+ <dl class="param-type">
12659
+ <dt>
12660
+ Type
12661
+ </dt>
12662
+ <dd>
12663
+
12664
+ <span class="param-type">Object</span>
12665
+ |
12666
+
12667
+ <span class="param-type">null</span>
12668
+
12669
+
12670
+
12671
+ </dd>
12672
+ </dl>
12673
+
12674
+
12675
+
12676
+
12677
+
12678
+
12679
+
12680
+
12681
+
12682
+
12683
+ <h4 class="name" id="fromCodexUsageHttp"><span class="type-signature"></span>fromCodexUsageHttp<span class="signature">(data)</span><span class="type-signature"> &rarr; {Object}</span></h4>
12684
+
12685
+
12686
+
12687
+
12688
+
12689
+
12690
+ <dl class="details">
12691
+
12692
+ <dt class="tag-description">Description:</dt>
12693
+ <dd class="tag-description"><ul class="dummy"><li><p>將chatgpt.com之/wham/usage回應對映為統一結構</p>
12694
+ <p>主窗口(rate_limit.primary_window / secondary_window)、程式碼審查限額(code_review_rate_limit)、
12695
+ 以及寬容解析之additional_rate_limits皆納入windows;額外限額之窗口鍵為「&lt;識別&gt;:primary|secondary」,
12696
+ scope為其顯示名或識別。任何欄位缺漏皆略過該窗口而不拋錯</p></li></ul></dd>
12697
+
12698
+
12699
+
12700
+ <dt class="tag-source">Source:</dt>
12701
+ <dd class="tag-source"><ul class="dummy"><li>
12702
+ <a href="quota_fromCodexUsageHttp.mjs.html">quota/fromCodexUsageHttp.mjs</a>, <a href="quota_fromCodexUsageHttp.mjs.html#line176">line 176</a>
12703
+ </li></ul></dd>
12704
+
12705
+
12706
+
12707
+
12708
+
12709
+
12710
+
12711
+
12712
+
12713
+
12714
+
12715
+
12716
+
12717
+
12718
+
12719
+
12720
+
12721
+
12722
+
12723
+
12724
+
12725
+
12726
+
12727
+
12728
+
12729
+
12730
+
12731
+
12732
+
12733
+
12734
+
12735
+ </dl>
12736
+
12737
+
12738
+
12739
+
12740
+
12741
+
12742
+
12743
+
12744
+
12745
+
12746
+
12747
+ <h5 class="h5-examples">Example</h5>
12748
+
12749
+ <pre class="prettyprint"><code>import fromCodexUsageHttp from './src/quota/fromCodexUsageHttp.mjs'
12750
+
12751
+ let m = fromCodexUsageHttp({
12752
+ email: 'a@b.c',
12753
+ plan_type: 'plus',
12754
+ rate_limit: { primary_window: { used_percent: 42, limit_window_seconds: 18000, reset_after_seconds: 100 } },
12755
+ additional_rate_limits: [{ limit_name: 'codex-spark', primary_window: { used_percent: 12, limit_window_seconds: 18000 } }],
12756
+ })
12757
+ console.log(m.windows.map((w) => `${w.key}=${w.label}`))
12758
+ // => [ 'primary=5小時', 'codex-spark:primary=5小時(codex-spark)' ]</code></pre>
12759
+
12760
+
12761
+
12762
+
12763
+ <h5 class="h5-parameters">Parameters:</h5>
12764
+
12765
+
12766
+ <table class="params">
12767
+ <thead>
12768
+ <tr>
12769
+
12770
+ <th>Name</th>
12771
+
12772
+
12773
+ <th>Type</th>
12774
+
12775
+
12776
+
12777
+
12778
+
12779
+ <th class="last">Description</th>
12780
+ </tr>
12781
+ </thead>
12782
+
12783
+ <tbody>
12784
+
12785
+
12786
+ <tr>
12787
+
12788
+ <td class="name"><code>data</code></td>
12789
+
12790
+
12791
+ <td class="type">
12792
+
12793
+
12794
+ <span class="param-type">Object</span>
12795
+
12796
+
12797
+
12798
+
12799
+ </td>
12800
+
12801
+
12802
+
12803
+
12804
+
12805
+ <td class="description last"><p>輸入/wham/usage之回應物件</p></td>
12806
+ </tr>
12807
+
12808
+
12809
+ </tbody>
12810
+ </table>
12811
+
12487
12812
 
12488
12813
 
12489
12814
 
@@ -13775,7 +14100,7 @@ console.log(getErrorResult(null).error)
13775
14100
 
13776
14101
  <dt class="tag-source">Source:</dt>
13777
14102
  <dd class="tag-source"><ul class="dummy"><li>
13778
- <a href="getErrorType.mjs.html">getErrorType.mjs</a>, <a href="getErrorType.mjs.html#line56">line 56</a>
14103
+ <a href="getErrorType.mjs.html">getErrorType.mjs</a>, <a href="getErrorType.mjs.html#line58">line 58</a>
13779
14104
  </li></ul></dd>
13780
14105
 
13781
14106
 
@@ -15647,7 +15972,7 @@ codex不存在或RPC失敗時退回直打chatgpt.com之用量端點。
15647
15972
 
15648
15973
  <dt class="tag-source">Source:</dt>
15649
15974
  <dd class="tag-source"><ul class="dummy"><li>
15650
- <a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line110">line 110</a>
15975
+ <a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line114">line 114</a>
15651
15976
  </li></ul></dd>
15652
15977
 
15653
15978
 
@@ -15805,7 +16130,7 @@ codex不存在或RPC失敗時退回直打chatgpt.com之用量端點。
15805
16130
 
15806
16131
  <dt class="tag-source">Source:</dt>
15807
16132
  <dd class="tag-source"><ul class="dummy"><li>
15808
- <a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line183">line 183</a>
16133
+ <a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line198">line 198</a>
15809
16134
  </li></ul></dd>
15810
16135
 
15811
16136
 
@@ -15947,7 +16272,7 @@ codex不存在或RPC失敗時退回直打chatgpt.com之用量端點。
15947
16272
 
15948
16273
 
15949
16274
 
15950
- <h4 class="name" id="pickWindow"><span class="type-signature"></span>pickWindow<span class="signature">(it, snake, camel)</span><span class="type-signature"> &rarr; {Object|null}</span></h4>
16275
+ <h4 class="name" id="judgeTruncated"><span class="type-signature"></span>judgeTruncated<span class="signature">(o)</span><span class="type-signature"> &rarr; {Object}</span></h4>
15951
16276
 
15952
16277
 
15953
16278
 
@@ -15957,13 +16282,13 @@ codex不存在或RPC失敗時退回直打chatgpt.com之用量端點。
15957
16282
  <dl class="details">
15958
16283
 
15959
16284
  <dt class="tag-description">Description:</dt>
15960
- <dd class="tag-description"><ul class="dummy"><li><p>自單筆取出指定窗口(頂層、rate_limit、rateLimit之下, snake或camel)</p></li></ul></dd>
16285
+ <dd class="tag-description"><ul class="dummy"><li><p>裁定一次已截斷之回應應失敗或放行(呼叫端先判定truncated為true才呼叫)</p></li></ul></dd>
15961
16286
 
15962
16287
 
15963
16288
 
15964
16289
  <dt class="tag-source">Source:</dt>
15965
16290
  <dd class="tag-source"><ul class="dummy"><li>
15966
- <a href="quota_fromCodexUsageHttp.mjs.html">quota/fromCodexUsageHttp.mjs</a>, <a href="quota_fromCodexUsageHttp.mjs.html#line111">line 111</a>
16291
+ <a href="checkTruncation.mjs.html">checkTruncation.mjs</a>, <a href="checkTruncation.mjs.html#line96">line 96</a>
15967
16292
  </li></ul></dd>
15968
16293
 
15969
16294
 
@@ -16008,6 +16333,17 @@ codex不存在或RPC失敗時退回直打chatgpt.com之用量端點。
16008
16333
 
16009
16334
 
16010
16335
 
16336
+ <h5 class="h5-examples">Example</h5>
16337
+
16338
+ <pre class="prettyprint"><code>import { judgeTruncated } from './src/checkTruncation.mjs'
16339
+
16340
+ console.log(judgeTruncated({ finishReason: 'length', content: '', reasoningTokens: 600, label: 'finish_reason=length' }).error)
16341
+ // => 'INCOMPLETE_RESPONSE: finish_reason=length; no visible output (reasoning may have used up the output token limit, reasoning_tokens=600)'
16342
+
16343
+ console.log(judgeTruncated({ finishReason: 'length', content: '[{"a":1},', acceptTruncated: true, label: 'finish_reason=length' }).accept)
16344
+ // => true</code></pre>
16345
+
16346
+
16011
16347
 
16012
16348
 
16013
16349
  <h5 class="h5-parameters">Parameters:</h5>
@@ -16035,7 +16371,7 @@ codex不存在或RPC失敗時退回直打chatgpt.com之用量端點。
16035
16371
 
16036
16372
  <tr>
16037
16373
 
16038
- <td class="name"><code>it</code></td>
16374
+ <td class="name"><code>o</code></td>
16039
16375
 
16040
16376
 
16041
16377
  <td class="type">
@@ -16052,14 +16388,37 @@ codex不存在或RPC失敗時退回直打chatgpt.com之用量端點。
16052
16388
 
16053
16389
 
16054
16390
 
16055
- <td class="description last"><p>輸入單筆物件</p></td>
16056
- </tr>
16391
+ <td class="description last"><p>輸入設定物件</p>
16392
+ <h6>Properties</h6>
16393
+
16394
+
16395
+ <table class="params">
16396
+ <thead>
16397
+ <tr>
16398
+
16399
+ <th>Name</th>
16400
+
16401
+
16402
+ <th>Type</th>
16403
+
16404
+
16405
+ <th>Attributes</th>
16406
+
16407
+
16408
+
16409
+ <th>Default</th>
16410
+
16411
+
16412
+ <th class="last">Description</th>
16413
+ </tr>
16414
+ </thead>
16057
16415
 
16416
+ <tbody>
16058
16417
 
16059
16418
 
16060
16419
  <tr>
16061
16420
 
16062
- <td class="name"><code>snake</code></td>
16421
+ <td class="name"><code>finishReason</code></td>
16063
16422
 
16064
16423
 
16065
16424
  <td class="type">
@@ -16073,23 +16432,38 @@ codex不存在或RPC失敗時退回直打chatgpt.com之用量端點。
16073
16432
  </td>
16074
16433
 
16075
16434
 
16435
+ <td class="attributes">
16436
+
16437
+
16438
+
16076
16439
 
16440
+
16441
+ </td>
16077
16442
 
16078
16443
 
16079
- <td class="description last"><p>輸入snake鍵, 例如'primary_window'</p></td>
16444
+
16445
+ <td class="default">
16446
+
16447
+ </td>
16448
+
16449
+
16450
+ <td class="description last"><p>輸入正規化後之終止原因字串,'length'才可能放行</p></td>
16080
16451
  </tr>
16081
16452
 
16082
16453
 
16083
16454
 
16084
16455
  <tr>
16085
16456
 
16086
- <td class="name"><code>camel</code></td>
16457
+ <td class="name"><code>content</code></td>
16087
16458
 
16088
16459
 
16089
16460
  <td class="type">
16090
16461
 
16091
16462
 
16092
16463
  <span class="param-type">String</span>
16464
+ |
16465
+
16466
+ <span class="param-type">null</span>
16093
16467
 
16094
16468
 
16095
16469
 
@@ -16097,10 +16471,563 @@ codex不存在或RPC失敗時退回直打chatgpt.com之用量端點。
16097
16471
  </td>
16098
16472
 
16099
16473
 
16474
+ <td class="attributes">
16475
+
16476
+
16477
+
16100
16478
 
16479
+
16480
+ </td>
16101
16481
 
16102
16482
 
16103
- <td class="description last"><p>輸入camel鍵, 例如'primaryWindow'</p></td>
16483
+
16484
+ <td class="default">
16485
+
16486
+ </td>
16487
+
16488
+
16489
+ <td class="description last"><p>輸入可見輸出文字,null代表無</p></td>
16490
+ </tr>
16491
+
16492
+
16493
+
16494
+ <tr>
16495
+
16496
+ <td class="name"><code>acceptTruncated</code></td>
16497
+
16498
+
16499
+ <td class="type">
16500
+
16501
+
16502
+ <span class="param-type">Boolean</span>
16503
+
16504
+
16505
+
16506
+
16507
+ </td>
16508
+
16509
+
16510
+ <td class="attributes">
16511
+
16512
+ &lt;optional><br>
16513
+
16514
+
16515
+
16516
+
16517
+
16518
+ </td>
16519
+
16520
+
16521
+
16522
+ <td class="default">
16523
+
16524
+ <code>false</code>
16525
+
16526
+ </td>
16527
+
16528
+
16529
+ <td class="description last"><p>輸入呼叫端是否明示接受截斷內容布林值</p></td>
16530
+ </tr>
16531
+
16532
+
16533
+
16534
+ <tr>
16535
+
16536
+ <td class="name"><code>validator</code></td>
16537
+
16538
+
16539
+ <td class="type">
16540
+
16541
+
16542
+ <span class="param-type">function</span>
16543
+ |
16544
+
16545
+ <span class="param-type">null</span>
16546
+
16547
+
16548
+
16549
+
16550
+ </td>
16551
+
16552
+
16553
+ <td class="attributes">
16554
+
16555
+ &lt;optional><br>
16556
+
16557
+
16558
+
16559
+
16560
+
16561
+ </td>
16562
+
16563
+
16564
+
16565
+ <td class="default">
16566
+
16567
+ <code>null</code>
16568
+
16569
+ </td>
16570
+
16571
+
16572
+ <td class="description last"><p>輸入驗證函式,放行時交其裁決</p></td>
16573
+ </tr>
16574
+
16575
+
16576
+
16577
+ <tr>
16578
+
16579
+ <td class="name"><code>reasoningTokens</code></td>
16580
+
16581
+
16582
+ <td class="type">
16583
+
16584
+
16585
+ <span class="param-type">Number</span>
16586
+ |
16587
+
16588
+ <span class="param-type">null</span>
16589
+
16590
+
16591
+
16592
+
16593
+ </td>
16594
+
16595
+
16596
+ <td class="attributes">
16597
+
16598
+ &lt;optional><br>
16599
+
16600
+
16601
+
16602
+
16603
+
16604
+ </td>
16605
+
16606
+
16607
+
16608
+ <td class="default">
16609
+
16610
+ <code>null</code>
16611
+
16612
+ </td>
16613
+
16614
+
16615
+ <td class="description last"><p>輸入推理token數,可見輸出為空時附於訊息</p></td>
16616
+ </tr>
16617
+
16618
+
16619
+
16620
+ <tr>
16621
+
16622
+ <td class="name"><code>label</code></td>
16623
+
16624
+
16625
+ <td class="type">
16626
+
16627
+
16628
+ <span class="param-type">String</span>
16629
+
16630
+
16631
+
16632
+
16633
+ </td>
16634
+
16635
+
16636
+ <td class="attributes">
16637
+
16638
+
16639
+
16640
+
16641
+
16642
+ </td>
16643
+
16644
+
16645
+
16646
+ <td class="default">
16647
+
16648
+ </td>
16649
+
16650
+
16651
+ <td class="description last"><p>輸入錯誤訊息主體字串,例如'finish_reason=length'或'status=incomplete (max_output_tokens)'</p></td>
16652
+ </tr>
16653
+
16654
+
16655
+ </tbody>
16656
+ </table>
16657
+
16658
+ </td>
16659
+ </tr>
16660
+
16661
+
16662
+ </tbody>
16663
+ </table>
16664
+
16665
+
16666
+
16667
+
16668
+
16669
+
16670
+
16671
+
16672
+
16673
+
16674
+
16675
+
16676
+
16677
+
16678
+
16679
+
16680
+ <h5 class="h5-returns">Returns:</h5>
16681
+
16682
+
16683
+ <div class="param-desc">
16684
+ <p>回傳物件,內含accept(是否放行布林值)、error(不放行時之錯誤訊息字串)、threw(validate拋錯訊息字串)</p>
16685
+ </div>
16686
+
16687
+
16688
+
16689
+ <dl class="param-type">
16690
+ <dt>
16691
+ Type
16692
+ </dt>
16693
+ <dd>
16694
+
16695
+ <span class="param-type">Object</span>
16696
+
16697
+
16698
+
16699
+ </dd>
16700
+ </dl>
16701
+
16702
+
16703
+
16704
+
16705
+
16706
+
16707
+
16708
+
16709
+
16710
+
16711
+ <h4 class="name" id="normalizeFinishReason"><span class="type-signature"></span>normalizeFinishReason<span class="signature">(v)</span><span class="type-signature"> &rarr; {String}</span></h4>
16712
+
16713
+
16714
+
16715
+
16716
+
16717
+
16718
+ <dl class="details">
16719
+
16720
+ <dt class="tag-description">Description:</dt>
16721
+ <dd class="tag-description"><ul class="dummy"><li><p>正規化終止原因字串(去頭尾空白、轉小寫;非字串回傳空字串)</p></li></ul></dd>
16722
+
16723
+
16724
+
16725
+ <dt class="tag-source">Source:</dt>
16726
+ <dd class="tag-source"><ul class="dummy"><li>
16727
+ <a href="checkTruncation.mjs.html">checkTruncation.mjs</a>, <a href="checkTruncation.mjs.html#line41">line 41</a>
16728
+ </li></ul></dd>
16729
+
16730
+
16731
+
16732
+
16733
+
16734
+
16735
+
16736
+
16737
+
16738
+
16739
+
16740
+
16741
+
16742
+
16743
+
16744
+
16745
+
16746
+
16747
+
16748
+
16749
+
16750
+
16751
+
16752
+
16753
+
16754
+
16755
+
16756
+
16757
+
16758
+
16759
+
16760
+ </dl>
16761
+
16762
+
16763
+
16764
+
16765
+
16766
+
16767
+
16768
+
16769
+
16770
+
16771
+
16772
+ <h5 class="h5-examples">Example</h5>
16773
+
16774
+ <pre class="prettyprint"><code>import { normalizeFinishReason } from './src/checkTruncation.mjs'
16775
+
16776
+ console.log(normalizeFinishReason(' LENGTH '), normalizeFinishReason(null))
16777
+ // => 'length' ''</code></pre>
16778
+
16779
+
16780
+
16781
+
16782
+ <h5 class="h5-parameters">Parameters:</h5>
16783
+
16784
+
16785
+ <table class="params">
16786
+ <thead>
16787
+ <tr>
16788
+
16789
+ <th>Name</th>
16790
+
16791
+
16792
+ <th>Type</th>
16793
+
16794
+
16795
+
16796
+
16797
+
16798
+ <th class="last">Description</th>
16799
+ </tr>
16800
+ </thead>
16801
+
16802
+ <tbody>
16803
+
16804
+
16805
+ <tr>
16806
+
16807
+ <td class="name"><code>v</code></td>
16808
+
16809
+
16810
+ <td class="type">
16811
+
16812
+
16813
+ <span class="param-type">*</span>
16814
+
16815
+
16816
+
16817
+
16818
+ </td>
16819
+
16820
+
16821
+
16822
+
16823
+
16824
+ <td class="description last"><p>輸入原始終止原因</p></td>
16825
+ </tr>
16826
+
16827
+
16828
+ </tbody>
16829
+ </table>
16830
+
16831
+
16832
+
16833
+
16834
+
16835
+
16836
+
16837
+
16838
+
16839
+
16840
+
16841
+
16842
+
16843
+
16844
+
16845
+
16846
+ <h5 class="h5-returns">Returns:</h5>
16847
+
16848
+
16849
+ <div class="param-desc">
16850
+ <p>回傳正規化字串</p>
16851
+ </div>
16852
+
16853
+
16854
+
16855
+ <dl class="param-type">
16856
+ <dt>
16857
+ Type
16858
+ </dt>
16859
+ <dd>
16860
+
16861
+ <span class="param-type">String</span>
16862
+
16863
+
16864
+
16865
+ </dd>
16866
+ </dl>
16867
+
16868
+
16869
+
16870
+
16871
+
16872
+
16873
+
16874
+
16875
+
16876
+
16877
+ <h4 class="name" id="pickWindow"><span class="type-signature"></span>pickWindow<span class="signature">(it, snake, camel)</span><span class="type-signature"> &rarr; {Object|null}</span></h4>
16878
+
16879
+
16880
+
16881
+
16882
+
16883
+
16884
+ <dl class="details">
16885
+
16886
+ <dt class="tag-description">Description:</dt>
16887
+ <dd class="tag-description"><ul class="dummy"><li><p>自單筆取出指定窗口(頂層、rate_limit、rateLimit之下, snake或camel)</p></li></ul></dd>
16888
+
16889
+
16890
+
16891
+ <dt class="tag-source">Source:</dt>
16892
+ <dd class="tag-source"><ul class="dummy"><li>
16893
+ <a href="quota_fromCodexUsageHttp.mjs.html">quota/fromCodexUsageHttp.mjs</a>, <a href="quota_fromCodexUsageHttp.mjs.html#line111">line 111</a>
16894
+ </li></ul></dd>
16895
+
16896
+
16897
+
16898
+
16899
+
16900
+
16901
+
16902
+
16903
+
16904
+
16905
+
16906
+
16907
+
16908
+
16909
+
16910
+
16911
+
16912
+
16913
+
16914
+
16915
+
16916
+
16917
+
16918
+
16919
+
16920
+
16921
+
16922
+
16923
+
16924
+
16925
+
16926
+ </dl>
16927
+
16928
+
16929
+
16930
+
16931
+
16932
+
16933
+
16934
+
16935
+
16936
+
16937
+
16938
+
16939
+
16940
+ <h5 class="h5-parameters">Parameters:</h5>
16941
+
16942
+
16943
+ <table class="params">
16944
+ <thead>
16945
+ <tr>
16946
+
16947
+ <th>Name</th>
16948
+
16949
+
16950
+ <th>Type</th>
16951
+
16952
+
16953
+
16954
+
16955
+
16956
+ <th class="last">Description</th>
16957
+ </tr>
16958
+ </thead>
16959
+
16960
+ <tbody>
16961
+
16962
+
16963
+ <tr>
16964
+
16965
+ <td class="name"><code>it</code></td>
16966
+
16967
+
16968
+ <td class="type">
16969
+
16970
+
16971
+ <span class="param-type">Object</span>
16972
+
16973
+
16974
+
16975
+
16976
+ </td>
16977
+
16978
+
16979
+
16980
+
16981
+
16982
+ <td class="description last"><p>輸入單筆物件</p></td>
16983
+ </tr>
16984
+
16985
+
16986
+
16987
+ <tr>
16988
+
16989
+ <td class="name"><code>snake</code></td>
16990
+
16991
+
16992
+ <td class="type">
16993
+
16994
+
16995
+ <span class="param-type">String</span>
16996
+
16997
+
16998
+
16999
+
17000
+ </td>
17001
+
17002
+
17003
+
17004
+
17005
+
17006
+ <td class="description last"><p>輸入snake鍵, 例如'primary_window'</p></td>
17007
+ </tr>
17008
+
17009
+
17010
+
17011
+ <tr>
17012
+
17013
+ <td class="name"><code>camel</code></td>
17014
+
17015
+
17016
+ <td class="type">
17017
+
17018
+
17019
+ <span class="param-type">String</span>
17020
+
17021
+
17022
+
17023
+
17024
+ </td>
17025
+
17026
+
17027
+
17028
+
17029
+
17030
+ <td class="description last"><p>輸入camel鍵, 例如'primaryWindow'</p></td>
16104
17031
  </tr>
16105
17032
 
16106
17033
 
@@ -16882,7 +17809,7 @@ console.log(readJsonOrNull('./no-such-file.json'))
16882
17809
 
16883
17810
  <dt class="tag-source">Source:</dt>
16884
17811
  <dd class="tag-source"><ul class="dummy"><li>
16885
- <a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line151">line 151</a>
17812
+ <a href="dispatchAiFallback.mjs.html">dispatchAiFallback.mjs</a>, <a href="dispatchAiFallback.mjs.html#line155">line 155</a>
16886
17813
  </li></ul></dd>
16887
17814
 
16888
17815
 
@@ -17167,7 +18094,7 @@ providers與table同源產出故必然一致;
17167
18094
 
17168
18095
  <h5 class="h5-examples">Example</h5>
17169
18096
 
17170
- <pre class="prettyprint"><code>import resolveProviders from './src/resolveProviders.mjs'
17171
18097
  env,
17172
18098
  pick: ['agnes:agnes-3.0-flash', 'claude:sonnet'],
17173
18099
  exes: { claude: 'C:/Users/x/.local/bin/claude.exe' },
17174
18100
  patch: { 'claude:sonnet': { timeoutMs: 360000 } },
18101
+ <pre class="prettyprint"><code>import resolveProviders from './src/resolveProviders.mjs'
17175
18102
  env,
17176
18103
  pick: ['agnes:agnes-3.0-flash', 'claude:sonnet'],
17177
18104
  exes: { claude: 'C:/Users/x/.local/bin/claude.exe' },
17178
18105
  patch: { 'claude:sonnet': { timeoutMs: 360000 } },
17179
18106
 
17180
18107
 
17181
18108
 
@@ -17535,7 +18462,7 @@ providers與table同源產出故必然一致;
17535
18462
 
17536
18463
  <dt class="tag-source">Source:</dt>
17537
18464
  <dd class="tag-source"><ul class="dummy"><li>
17538
- <a href="wkf_runFanout.mjs.html">wkf/runFanout.mjs</a>, <a href="wkf_runFanout.mjs.html#line92">line 92</a>
18465
+ <a href="wkf_runFanout.mjs.html">wkf/runFanout.mjs</a>, <a href="wkf_runFanout.mjs.html#line94">line 94</a>
17539
18466
  </li></ul></dd>
17540
18467
 
17541
18468
 
@@ -19045,6 +19972,199 @@ await test()
19045
19972
 
19046
19973
 
19047
19974
 
19975
+ <h4 class="name" id="safeValidate"><span class="type-signature"></span>safeValidate<span class="signature">(validator, text)</span><span class="type-signature"> &rarr; {Object}</span></h4>
19976
+
19977
+
19978
+
19979
+
19980
+
19981
+
19982
+ <dl class="details">
19983
+
19984
+ <dt class="tag-description">Description:</dt>
19985
+ <dd class="tag-description"><ul class="dummy"><li><p>以不拋錯方式執行驗證函式(拋錯視同拒絕)</p></li></ul></dd>
19986
+
19987
+
19988
+
19989
+ <dt class="tag-source">Source:</dt>
19990
+ <dd class="tag-source"><ul class="dummy"><li>
19991
+ <a href="checkTruncation.mjs.html">checkTruncation.mjs</a>, <a href="checkTruncation.mjs.html#line63">line 63</a>
19992
+ </li></ul></dd>
19993
+
19994
+
19995
+
19996
+
19997
+
19998
+
19999
+
20000
+
20001
+
20002
+
20003
+
20004
+
20005
+
20006
+
20007
+
20008
+
20009
+
20010
+
20011
+
20012
+
20013
+
20014
+
20015
+
20016
+
20017
+
20018
+
20019
+
20020
+
20021
+
20022
+
20023
+
20024
+ </dl>
20025
+
20026
+
20027
+
20028
+
20029
+
20030
+
20031
+
20032
+
20033
+
20034
+
20035
+
20036
+ <h5 class="h5-examples">Example</h5>
20037
+
20038
+ <pre class="prettyprint"><code>import { safeValidate } from './src/checkTruncation.mjs'
20039
+
20040
+ console.log(safeValidate((s) => s.length > 1, 'ab'))
20041
+ // => { pass: true, threw: '' }
20042
+
20043
+ console.log(safeValidate(() => { throw new Error('x') }, 'ab'))
20044
+ // => { pass: false, threw: 'x' }</code></pre>
20045
+
20046
+
20047
+
20048
+
20049
+ <h5 class="h5-parameters">Parameters:</h5>
20050
+
20051
+
20052
+ <table class="params">
20053
+ <thead>
20054
+ <tr>
20055
+
20056
+ <th>Name</th>
20057
+
20058
+
20059
+ <th>Type</th>
20060
+
20061
+
20062
+
20063
+
20064
+
20065
+ <th class="last">Description</th>
20066
+ </tr>
20067
+ </thead>
20068
+
20069
+ <tbody>
20070
+
20071
+
20072
+ <tr>
20073
+
20074
+ <td class="name"><code>validator</code></td>
20075
+
20076
+
20077
+ <td class="type">
20078
+
20079
+
20080
+ <span class="param-type">function</span>
20081
+
20082
+
20083
+
20084
+
20085
+ </td>
20086
+
20087
+
20088
+
20089
+
20090
+
20091
+ <td class="description last"><p>輸入驗證函式(text)=&gt;Boolean</p></td>
20092
+ </tr>
20093
+
20094
+
20095
+
20096
+ <tr>
20097
+
20098
+ <td class="name"><code>text</code></td>
20099
+
20100
+
20101
+ <td class="type">
20102
+
20103
+
20104
+ <span class="param-type">String</span>
20105
+
20106
+
20107
+
20108
+
20109
+ </td>
20110
+
20111
+
20112
+
20113
+
20114
+
20115
+ <td class="description last"><p>輸入待驗證文字</p></td>
20116
+ </tr>
20117
+
20118
+
20119
+ </tbody>
20120
+ </table>
20121
+
20122
+
20123
+
20124
+
20125
+
20126
+
20127
+
20128
+
20129
+
20130
+
20131
+
20132
+
20133
+
20134
+
20135
+
20136
+
20137
+ <h5 class="h5-returns">Returns:</h5>
20138
+
20139
+
20140
+ <div class="param-desc">
20141
+ <p>回傳物件,內含pass(是否通過布林值)與threw(拋錯訊息字串,未拋錯為空字串)</p>
20142
+ </div>
20143
+
20144
+
20145
+
20146
+ <dl class="param-type">
20147
+ <dt>
20148
+ Type
20149
+ </dt>
20150
+ <dd>
20151
+
20152
+ <span class="param-type">Object</span>
20153
+
20154
+
20155
+
20156
+ </dd>
20157
+ </dl>
20158
+
20159
+
20160
+
20161
+
20162
+
20163
+
20164
+
20165
+
20166
+
20167
+
19048
20168
  <h4 class="name" id="salvageTruncatedArray"><span class="type-signature"></span>salvageTruncatedArray<span class="signature">(text)</span><span class="type-signature"> &rarr; {Array|null}</span></h4>
19049
20169
 
19050
20170
 
@@ -19066,7 +20186,7 @@ await test()
19066
20186
 
19067
20187
  <dt class="tag-source">Source:</dt>
19068
20188
  <dd class="tag-source"><ul class="dummy"><li>
19069
- <a href="wkf_salvageTruncatedArray.mjs.html">wkf/salvageTruncatedArray.mjs</a>, <a href="wkf_salvageTruncatedArray.mjs.html#line40">line 40</a>
20189
+ <a href="wkf_salvageTruncatedArray.mjs.html">wkf/salvageTruncatedArray.mjs</a>, <a href="wkf_salvageTruncatedArray.mjs.html#line49">line 49</a>
19070
20190
  </li></ul></dd>
19071
20191
 
19072
20192
 
@@ -21417,7 +22537,7 @@ console.log(w.label, w.remainingPercent)
21417
22537
  <br class="clear">
21418
22538
 
21419
22539
  <footer>
21420
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Sep 23 2026 18:02:52 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
22540
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Thu Sep 24 2026 14:02:35 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
21421
22541
  </footer>
21422
22542
 
21423
22543
  <script>prettyPrint();</script>