w-dispatch-ai 1.0.25 → 1.0.26
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 +56 -4
- package/dist/w-dispatch-ai.umd.js +2 -2
- package/dist/w-dispatch-ai.umd.js.map +1 -1
- package/docs/WDispatchAi.mjs.html +6 -4
- package/docs/adapters.mjs.html +10 -3
- package/docs/budgetFor.mjs.html +2 -2
- package/docs/buildValidator.mjs.html +2 -2
- package/docs/castPintOr.mjs.html +2 -2
- package/docs/dfTimeoutMs.mjs.html +2 -2
- package/docs/dispatchAi.mjs.html +2 -2
- package/docs/dispatchAiFallback.mjs.html +2 -2
- package/docs/dispatchAiWkf.mjs.html +2 -2
- package/docs/dispatchAntigravity.mjs.html +2 -2
- package/docs/dispatchApiOpenaiCompat.mjs.html +2 -2
- package/docs/dispatchApiOpenaiResponses.mjs.html +2 -2
- package/docs/dispatchApiTypesafeSystemone.mjs.html +447 -0
- package/docs/dispatchClaude.mjs.html +2 -2
- package/docs/dispatchCodex.mjs.html +2 -2
- package/docs/dispatchOpencode.mjs.html +2 -2
- package/docs/getCliArgs.mjs.html +2 -2
- package/docs/getErrorResult.mjs.html +2 -2
- package/docs/getErrorType.mjs.html +4 -3
- package/docs/global.html +1221 -254
- package/docs/index.html +2 -2
- package/docs/quota_dfQuotaTimeoutMs.mjs.html +2 -2
- package/docs/quota_fetchQuotaJson.mjs.html +2 -2
- package/docs/quota_fromCodexUsageHttp.mjs.html +2 -2
- package/docs/quota_getQuotaAntigravity.mjs.html +2 -2
- package/docs/quota_getQuotaClaude.mjs.html +2 -2
- package/docs/quota_getQuotaCodex.mjs.html +2 -2
- package/docs/quota_readJsonOrNull.mjs.html +2 -2
- package/docs/quota_toQuotaLabel.mjs.html +2 -2
- package/docs/quota_toQuotaResult.mjs.html +2 -2
- package/docs/quota_toQuotaScopedLabel.mjs.html +2 -2
- package/docs/quota_toQuotaWindow.mjs.html +2 -2
- package/docs/readEnvFile.mjs.html +2 -2
- package/docs/resolveProviders.mjs.html +2 -2
- package/docs/wkf_callAiWithFallback.mjs.html +2 -2
- package/docs/wkf_createFileStore.mjs.html +2 -2
- package/docs/wkf_createUsageCounter.mjs.html +2 -2
- package/docs/wkf_extractJsonLoose.mjs.html +2 -2
- package/docs/wkf_noSideEffectPrefix.mjs.html +2 -2
- package/docs/wkf_runFanout.mjs.html +2 -2
- package/docs/wkf_runFanoutPipeline.mjs.html +2 -2
- package/docs/wkf_runRolePipeline.mjs.html +2 -2
- package/docs/wkf_salvageTruncatedArray.mjs.html +2 -2
- package/g.mjs +2 -2
- package/package.json +1 -1
- package/src/WDispatchAi.mjs +4 -2
- package/src/adapters.mjs +8 -1
- package/src/dispatchApiTypesafeSystemone.mjs +375 -0
- package/src/getErrorType.mjs +2 -1
- package/src/providers.mjs +32 -1
- package/test/tools/fakeServerForApiTest.mjs +75 -5
- package/test/unit-WDispatchAi.test.mjs +10 -6
- package/test/unit-adapters.test.mjs +5 -3
- package/test/unit-dispatchAi.test.mjs +1 -1
- package/test/unit-dispatchApiTypesafeSystemone.test.mjs +159 -0
- package/test/unit-providers.test.mjs +7 -0
- package/test/unit-resolveProviders.test.mjs +2 -2
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#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#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>
|
|
33
33
|
|
|
34
34
|
</nav>
|
|
35
35
|
|
|
@@ -220,7 +220,7 @@ callAiWithFallback預設自動掛上(傳promptPrefix:''關閉),
|
|
|
220
220
|
|
|
221
221
|
<dt class="tag-source">Source:</dt>
|
|
222
222
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
223
|
-
<a href="WDispatchAi.mjs.html">WDispatchAi.mjs</a>, <a href="WDispatchAi.mjs.html#
|
|
223
|
+
<a href="WDispatchAi.mjs.html">WDispatchAi.mjs</a>, <a href="WDispatchAi.mjs.html#line47">line 47</a>
|
|
224
224
|
</li></ul></dd>
|
|
225
225
|
|
|
226
226
|
|
|
@@ -271,7 +271,7 @@ callAiWithFallback預設自動掛上(傳promptPrefix:''關閉),
|
|
|
271
271
|
|
|
272
272
|
<h5 class="h5-examples">Example</h5>
|
|
273
273
|
|
|
274
|
-
<pre class="prettyprint"><code>詳見dispatchAi、dispatchAiFallback、dispatchAiWkf、dispatchOpencode、dispatchClaude、dispatchCodex、dispatchAntigravity、dispatchApiOpenaiCompat、dispatchApiOpenaiResponses、resolveProviders、getQuotaClaude、getQuotaCodex、getQuotaAntigravity範例</code></pre>
|
|
274
|
+
<pre class="prettyprint"><code>詳見dispatchAi、dispatchAiFallback、dispatchAiWkf、dispatchOpencode、dispatchClaude、dispatchCodex、dispatchAntigravity、dispatchApiOpenaiCompat、dispatchApiOpenaiResponses、dispatchApiTypesafeSystemone、resolveProviders、getQuotaClaude、getQuotaCodex、getQuotaAntigravity範例</code></pre>
|
|
275
275
|
|
|
276
276
|
|
|
277
277
|
|
|
@@ -294,7 +294,7 @@ callAiWithFallback預設自動掛上(傳promptPrefix:''關閉),
|
|
|
294
294
|
|
|
295
295
|
<dt class="tag-source">Source:</dt>
|
|
296
296
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
297
|
-
<a href="adapters.mjs.html">adapters.mjs</a>, <a href="adapters.mjs.html#
|
|
297
|
+
<a href="adapters.mjs.html">adapters.mjs</a>, <a href="adapters.mjs.html#line64">line 64</a>
|
|
298
298
|
</li></ul></dd>
|
|
299
299
|
|
|
300
300
|
|
|
@@ -350,7 +350,7 @@ callAiWithFallback預設自動掛上(傳promptPrefix:''關閉),
|
|
|
350
350
|
<pre class="prettyprint"><code>import adapters from './src/adapters.mjs'
|
|
351
351
|
|
|
352
352
|
console.log(Object.keys(adapters))
|
|
353
|
-
// => ['opencode', 'claude', 'codex', 'antigravity', 'api-openai-compat', 'api-openai-responses']</code></pre>
|
|
353
|
+
// => ['opencode', 'claude', 'codex', 'antigravity', 'api-openai-compat', 'api-openai-responses', 'api-typesafe-systemone']</code></pre>
|
|
354
354
|
|
|
355
355
|
|
|
356
356
|
|
|
@@ -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#
|
|
740
|
+
<a href="getErrorType.mjs.html">getErrorType.mjs</a>, <a href="getErrorType.mjs.html#line90">line 90</a>
|
|
741
741
|
</li></ul></dd>
|
|
742
742
|
|
|
743
743
|
|
|
@@ -2776,7 +2776,7 @@ await test()
|
|
|
2776
2776
|
|
|
2777
2777
|
|
|
2778
2778
|
|
|
2779
|
-
<h4 class="name" id="
|
|
2779
|
+
<h4 class="name" id="callOnce"><span class="type-signature type-signature-async">(async) </span>callOnce<span class="signature">(url, headers, body, ids, timeoutMs, validator)</span><span class="type-signature"> → {Promise}</span></h4>
|
|
2780
2780
|
|
|
2781
2781
|
|
|
2782
2782
|
|
|
@@ -2786,16 +2786,13 @@ await test()
|
|
|
2786
2786
|
<dl class="details">
|
|
2787
2787
|
|
|
2788
2788
|
<dt class="tag-description">Description:</dt>
|
|
2789
|
-
<dd class="tag-description"><ul class="dummy"><li><p
|
|
2790
|
-
<p>本套件各層之數值設定(timeoutMs、budgetMs、minAttemptMs、cooldownMs、retryDelayMs等)
|
|
2791
|
-
皆採同一寬容策略「無效即靜默回退預設」,統一收斂於此,
|
|
2792
|
-
避免同一7行判斷區塊散落各轉接器(曾重複6處)</p></li></ul></dd>
|
|
2789
|
+
<dd class="tag-description"><ul class="dummy"><li><p>單次HTTP呼叫(內部使用, 不含重試邏輯)</p></li></ul></dd>
|
|
2793
2790
|
|
|
2794
2791
|
|
|
2795
2792
|
|
|
2796
2793
|
<dt class="tag-source">Source:</dt>
|
|
2797
2794
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2798
|
-
<a href="
|
|
2795
|
+
<a href="dispatchApiTypesafeSystemone.mjs.html">dispatchApiTypesafeSystemone.mjs</a>, <a href="dispatchApiTypesafeSystemone.mjs.html#line78">line 78</a>
|
|
2799
2796
|
</li></ul></dd>
|
|
2800
2797
|
|
|
2801
2798
|
|
|
@@ -2840,20 +2837,6 @@ await test()
|
|
|
2840
2837
|
|
|
2841
2838
|
|
|
2842
2839
|
|
|
2843
|
-
<h5 class="h5-examples">Example</h5>
|
|
2844
|
-
|
|
2845
|
-
<pre class="prettyprint"><code>import castPintOr from './src/castPintOr.mjs'
|
|
2846
|
-
|
|
2847
|
-
console.log(castPintOr(5000, 300000))
|
|
2848
|
-
// => 5000
|
|
2849
|
-
|
|
2850
|
-
console.log(castPintOr('abc', 300000))
|
|
2851
|
-
// => 300000
|
|
2852
|
-
|
|
2853
|
-
console.log(castPintOr(undefined, null))
|
|
2854
|
-
// => null</code></pre>
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
2840
|
|
|
2858
2841
|
|
|
2859
2842
|
<h5 class="h5-parameters">Parameters:</h5>
|
|
@@ -2881,13 +2864,13 @@ console.log(castPintOr(undefined, null))
|
|
|
2881
2864
|
|
|
2882
2865
|
<tr>
|
|
2883
2866
|
|
|
2884
|
-
<td class="name"><code>
|
|
2867
|
+
<td class="name"><code>url</code></td>
|
|
2885
2868
|
|
|
2886
2869
|
|
|
2887
2870
|
<td class="type">
|
|
2888
2871
|
|
|
2889
2872
|
|
|
2890
|
-
<span class="param-type"
|
|
2873
|
+
<span class="param-type">String</span>
|
|
2891
2874
|
|
|
2892
2875
|
|
|
2893
2876
|
|
|
@@ -2898,20 +2881,20 @@ console.log(castPintOr(undefined, null))
|
|
|
2898
2881
|
|
|
2899
2882
|
|
|
2900
2883
|
|
|
2901
|
-
<td class="description last"><p
|
|
2884
|
+
<td class="description last"><p>輸入完整端點網址字串</p></td>
|
|
2902
2885
|
</tr>
|
|
2903
2886
|
|
|
2904
2887
|
|
|
2905
2888
|
|
|
2906
2889
|
<tr>
|
|
2907
2890
|
|
|
2908
|
-
<td class="name"><code>
|
|
2891
|
+
<td class="name"><code>headers</code></td>
|
|
2909
2892
|
|
|
2910
2893
|
|
|
2911
2894
|
<td class="type">
|
|
2912
2895
|
|
|
2913
2896
|
|
|
2914
|
-
<span class="param-type"
|
|
2897
|
+
<span class="param-type">Object</span>
|
|
2915
2898
|
|
|
2916
2899
|
|
|
2917
2900
|
|
|
@@ -2922,7 +2905,106 @@ console.log(castPintOr(undefined, null))
|
|
|
2922
2905
|
|
|
2923
2906
|
|
|
2924
2907
|
|
|
2925
|
-
<td class="description last"><p
|
|
2908
|
+
<td class="description last"><p>輸入請求標頭物件</p></td>
|
|
2909
|
+
</tr>
|
|
2910
|
+
|
|
2911
|
+
|
|
2912
|
+
|
|
2913
|
+
<tr>
|
|
2914
|
+
|
|
2915
|
+
<td class="name"><code>body</code></td>
|
|
2916
|
+
|
|
2917
|
+
|
|
2918
|
+
<td class="type">
|
|
2919
|
+
|
|
2920
|
+
|
|
2921
|
+
<span class="param-type">Object</span>
|
|
2922
|
+
|
|
2923
|
+
|
|
2924
|
+
|
|
2925
|
+
|
|
2926
|
+
</td>
|
|
2927
|
+
|
|
2928
|
+
|
|
2929
|
+
|
|
2930
|
+
|
|
2931
|
+
|
|
2932
|
+
<td class="description last"><p>輸入請求本體物件</p></td>
|
|
2933
|
+
</tr>
|
|
2934
|
+
|
|
2935
|
+
|
|
2936
|
+
|
|
2937
|
+
<tr>
|
|
2938
|
+
|
|
2939
|
+
<td class="name"><code>ids</code></td>
|
|
2940
|
+
|
|
2941
|
+
|
|
2942
|
+
<td class="type">
|
|
2943
|
+
|
|
2944
|
+
|
|
2945
|
+
<span class="param-type">Array</span>
|
|
2946
|
+
|
|
2947
|
+
|
|
2948
|
+
|
|
2949
|
+
|
|
2950
|
+
</td>
|
|
2951
|
+
|
|
2952
|
+
|
|
2953
|
+
|
|
2954
|
+
|
|
2955
|
+
|
|
2956
|
+
<td class="description last"><p>輸入請求之題目id陣列,用於檢核回應是否每題皆有答案</p></td>
|
|
2957
|
+
</tr>
|
|
2958
|
+
|
|
2959
|
+
|
|
2960
|
+
|
|
2961
|
+
<tr>
|
|
2962
|
+
|
|
2963
|
+
<td class="name"><code>timeoutMs</code></td>
|
|
2964
|
+
|
|
2965
|
+
|
|
2966
|
+
<td class="type">
|
|
2967
|
+
|
|
2968
|
+
|
|
2969
|
+
<span class="param-type">Number</span>
|
|
2970
|
+
|
|
2971
|
+
|
|
2972
|
+
|
|
2973
|
+
|
|
2974
|
+
</td>
|
|
2975
|
+
|
|
2976
|
+
|
|
2977
|
+
|
|
2978
|
+
|
|
2979
|
+
|
|
2980
|
+
<td class="description last"><p>輸入逾時毫秒</p></td>
|
|
2981
|
+
</tr>
|
|
2982
|
+
|
|
2983
|
+
|
|
2984
|
+
|
|
2985
|
+
<tr>
|
|
2986
|
+
|
|
2987
|
+
<td class="name"><code>validator</code></td>
|
|
2988
|
+
|
|
2989
|
+
|
|
2990
|
+
<td class="type">
|
|
2991
|
+
|
|
2992
|
+
|
|
2993
|
+
<span class="param-type">function</span>
|
|
2994
|
+
|
|
|
2995
|
+
|
|
2996
|
+
<span class="param-type">null</span>
|
|
2997
|
+
|
|
2998
|
+
|
|
2999
|
+
|
|
3000
|
+
|
|
3001
|
+
</td>
|
|
3002
|
+
|
|
3003
|
+
|
|
3004
|
+
|
|
3005
|
+
|
|
3006
|
+
|
|
3007
|
+
<td class="description last"><p>輸入驗證函式</p></td>
|
|
2926
3008
|
</tr>
|
|
2927
3009
|
|
|
2928
3010
|
|
|
@@ -2948,7 +3030,7 @@ console.log(castPintOr(undefined, null))
|
|
|
2948
3030
|
|
|
2949
3031
|
|
|
2950
3032
|
<div class="param-desc">
|
|
2951
|
-
<p
|
|
3033
|
+
<p>回傳Promise,resolve回傳結果物件</p>
|
|
2952
3034
|
</div>
|
|
2953
3035
|
|
|
2954
3036
|
|
|
@@ -2959,10 +3041,7 @@ console.log(castPintOr(undefined, null))
|
|
|
2959
3041
|
</dt>
|
|
2960
3042
|
<dd>
|
|
2961
3043
|
|
|
2962
|
-
<span class="param-type">
|
|
2963
|
-
|
|
|
2964
|
-
|
|
2965
|
-
<span class="param-type">*</span>
|
|
3044
|
+
<span class="param-type">Promise</span>
|
|
2966
3045
|
|
|
2967
3046
|
|
|
2968
3047
|
|
|
@@ -2978,7 +3057,7 @@ console.log(castPintOr(undefined, null))
|
|
|
2978
3057
|
|
|
2979
3058
|
|
|
2980
3059
|
|
|
2981
|
-
<h4 class="name" id="
|
|
3060
|
+
<h4 class="name" id="castPintOr"><span class="type-signature"></span>castPintOr<span class="signature">(v, df)</span><span class="type-signature"> → {Number|*}</span></h4>
|
|
2982
3061
|
|
|
2983
3062
|
|
|
2984
3063
|
|
|
@@ -2988,13 +3067,16 @@ console.log(castPintOr(undefined, null))
|
|
|
2988
3067
|
<dl class="details">
|
|
2989
3068
|
|
|
2990
3069
|
<dt class="tag-description">Description:</dt>
|
|
2991
|
-
<dd class="tag-description"><ul class="dummy"><li><p
|
|
3070
|
+
<dd class="tag-description"><ul class="dummy"><li><p>正整數正規化:有效正整數即轉整數回傳,否則回傳預設值</p>
|
|
3071
|
+
<p>本套件各層之數值設定(timeoutMs、budgetMs、minAttemptMs、cooldownMs、retryDelayMs等)
|
|
3072
|
+
皆採同一寬容策略「無效即靜默回退預設」,統一收斂於此,
|
|
3073
|
+
避免同一7行判斷區塊散落各轉接器(曾重複6處)</p></li></ul></dd>
|
|
2992
3074
|
|
|
2993
3075
|
|
|
2994
3076
|
|
|
2995
3077
|
<dt class="tag-source">Source:</dt>
|
|
2996
3078
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2997
|
-
<a href="
|
|
3079
|
+
<a href="castPintOr.mjs.html">castPintOr.mjs</a>, <a href="castPintOr.mjs.html#line29">line 29</a>
|
|
2998
3080
|
</li></ul></dd>
|
|
2999
3081
|
|
|
3000
3082
|
|
|
@@ -3039,6 +3121,20 @@ console.log(castPintOr(undefined, null))
|
|
|
3039
3121
|
|
|
3040
3122
|
|
|
3041
3123
|
|
|
3124
|
+
<h5 class="h5-examples">Example</h5>
|
|
3125
|
+
|
|
3126
|
+
<pre class="prettyprint"><code>import castPintOr from './src/castPintOr.mjs'
|
|
3127
|
+
|
|
3128
|
+
console.log(castPintOr(5000, 300000))
|
|
3129
|
+
// => 5000
|
|
3130
|
+
|
|
3131
|
+
console.log(castPintOr('abc', 300000))
|
|
3132
|
+
// => 300000
|
|
3133
|
+
|
|
3134
|
+
console.log(castPintOr(undefined, null))
|
|
3135
|
+
// => null</code></pre>
|
|
3136
|
+
|
|
3137
|
+
|
|
3042
3138
|
|
|
3043
3139
|
|
|
3044
3140
|
<h5 class="h5-parameters">Parameters:</h5>
|
|
@@ -3066,13 +3162,13 @@ console.log(castPintOr(undefined, null))
|
|
|
3066
3162
|
|
|
3067
3163
|
<tr>
|
|
3068
3164
|
|
|
3069
|
-
<td class="name"><code>
|
|
3165
|
+
<td class="name"><code>v</code></td>
|
|
3070
3166
|
|
|
3071
3167
|
|
|
3072
3168
|
<td class="type">
|
|
3073
3169
|
|
|
3074
3170
|
|
|
3075
|
-
<span class="param-type"
|
|
3171
|
+
<span class="param-type">*</span>
|
|
3076
3172
|
|
|
3077
3173
|
|
|
3078
3174
|
|
|
@@ -3083,7 +3179,31 @@ console.log(castPintOr(undefined, null))
|
|
|
3083
3179
|
|
|
3084
3180
|
|
|
3085
3181
|
|
|
3086
|
-
<td class="description last"><p
|
|
3182
|
+
<td class="description last"><p>輸入待正規化之值</p></td>
|
|
3183
|
+
</tr>
|
|
3184
|
+
|
|
3185
|
+
|
|
3186
|
+
|
|
3187
|
+
<tr>
|
|
3188
|
+
|
|
3189
|
+
<td class="name"><code>df</code></td>
|
|
3190
|
+
|
|
3191
|
+
|
|
3192
|
+
<td class="type">
|
|
3193
|
+
|
|
3194
|
+
|
|
3195
|
+
<span class="param-type">*</span>
|
|
3196
|
+
|
|
3197
|
+
|
|
3198
|
+
|
|
3199
|
+
|
|
3200
|
+
</td>
|
|
3201
|
+
|
|
3202
|
+
|
|
3203
|
+
|
|
3204
|
+
|
|
3205
|
+
|
|
3206
|
+
<td class="description last"><p>輸入無效時之預設值(可為null代表不限)</p></td>
|
|
3087
3207
|
</tr>
|
|
3088
3208
|
|
|
3089
3209
|
|
|
@@ -3109,7 +3229,7 @@ console.log(castPintOr(undefined, null))
|
|
|
3109
3229
|
|
|
3110
3230
|
|
|
3111
3231
|
<div class="param-desc">
|
|
3112
|
-
<p
|
|
3232
|
+
<p>回傳正規化後之正整數,v非有效正整數時回傳df</p>
|
|
3113
3233
|
</div>
|
|
3114
3234
|
|
|
3115
3235
|
|
|
@@ -3120,7 +3240,10 @@ console.log(castPintOr(undefined, null))
|
|
|
3120
3240
|
</dt>
|
|
3121
3241
|
<dd>
|
|
3122
3242
|
|
|
3123
|
-
<span class="param-type">
|
|
3243
|
+
<span class="param-type">Number</span>
|
|
3244
|
+
|
|
|
3245
|
+
|
|
3246
|
+
<span class="param-type">*</span>
|
|
3124
3247
|
|
|
3125
3248
|
|
|
3126
3249
|
|
|
@@ -3136,7 +3259,7 @@ console.log(castPintOr(undefined, null))
|
|
|
3136
3259
|
|
|
3137
3260
|
|
|
3138
3261
|
|
|
3139
|
-
<h4 class="name" id="
|
|
3262
|
+
<h4 class="name" id="collectAdditional"><span class="type-signature"></span>collectAdditional<span class="signature">(data)</span><span class="type-signature"> → {Array}</span></h4>
|
|
3140
3263
|
|
|
3141
3264
|
|
|
3142
3265
|
|
|
@@ -3146,18 +3269,13 @@ console.log(castPintOr(undefined, null))
|
|
|
3146
3269
|
<dl class="details">
|
|
3147
3270
|
|
|
3148
3271
|
<dt class="tag-description">Description:</dt>
|
|
3149
|
-
<dd class="tag-description"><ul class="dummy"><li><p
|
|
3150
|
-
<p>特點:
|
|
3151
|
-
採排除式passthrough——state原封存還,僅剔除本層自用欄位(預設只有at:人讀的最後更新時間戳),
|
|
3152
|
-
日後套件擴充state欄位(如cooling)即自動相容,不需改本函數;
|
|
3153
|
-
檔案不存在或非法JSON時get回空物件(套件視為全新狀態);
|
|
3154
|
-
stamp可注入時間戳函數(排程環境建議注入時區錨定者),寫入時補進at欄位供人工debug</p></li></ul></dd>
|
|
3272
|
+
<dd class="tag-description"><ul class="dummy"><li><p>取出additional_rate_limits之集合並統一為陣列</p></li></ul></dd>
|
|
3155
3273
|
|
|
3156
3274
|
|
|
3157
3275
|
|
|
3158
3276
|
<dt class="tag-source">Source:</dt>
|
|
3159
3277
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
3160
|
-
<a href="
|
|
3278
|
+
<a href="quota_fromCodexUsageHttp.mjs.html">quota/fromCodexUsageHttp.mjs</a>, <a href="quota_fromCodexUsageHttp.mjs.html#line79">line 79</a>
|
|
3161
3279
|
</li></ul></dd>
|
|
3162
3280
|
|
|
3163
3281
|
|
|
@@ -3202,15 +3320,6 @@ stamp可注入時間戳函數(排程環境建議注入時區錨定者),寫入
|
|
|
3202
3320
|
|
|
3203
3321
|
|
|
3204
3322
|
|
|
3205
|
-
<h5 class="h5-examples">Example</h5>
|
|
3206
|
-
|
|
3207
|
-
<pre class="prettyprint"><code>import createFileStore from './src/wkf/createFileStore.mjs'
|
|
3208
|
-
import dispatchAiFallback from './src/dispatchAiFallback.mjs'
|
|
3209
|
-
|
|
3210
|
-
let store = createFileStore({ dir: './state' })
|
|
3211
|
-
//let r = await dispatchAiFallback(prompt, { providers, store, cooldownMs: 3600000 })</code></pre>
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
3323
|
|
|
3215
3324
|
|
|
3216
3325
|
<h5 class="h5-parameters">Parameters:</h5>
|
|
@@ -3226,12 +3335,8 @@ let store = createFileStore({ dir: './state' })
|
|
|
3226
3335
|
<th>Type</th>
|
|
3227
3336
|
|
|
3228
3337
|
|
|
3229
|
-
<th>Attributes</th>
|
|
3230
|
-
|
|
3231
3338
|
|
|
3232
3339
|
|
|
3233
|
-
<th>Default</th>
|
|
3234
|
-
|
|
3235
3340
|
|
|
3236
3341
|
<th class="last">Description</th>
|
|
3237
3342
|
</tr>
|
|
@@ -3242,7 +3347,7 @@ let store = createFileStore({ dir: './state' })
|
|
|
3242
3347
|
|
|
3243
3348
|
<tr>
|
|
3244
3349
|
|
|
3245
|
-
<td class="name"><code>
|
|
3350
|
+
<td class="name"><code>data</code></td>
|
|
3246
3351
|
|
|
3247
3352
|
|
|
3248
3353
|
<td class="type">
|
|
@@ -3256,41 +3361,217 @@ let store = createFileStore({ dir: './state' })
|
|
|
3256
3361
|
</td>
|
|
3257
3362
|
|
|
3258
3363
|
|
|
3259
|
-
<td class="attributes">
|
|
3260
|
-
|
|
3261
|
-
<optional><br>
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
3364
|
|
|
3266
|
-
|
|
3267
|
-
</td>
|
|
3268
3365
|
|
|
3269
3366
|
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
<code>{}</code>
|
|
3274
|
-
|
|
3275
|
-
</td>
|
|
3276
|
-
|
|
3367
|
+
<td class="description last"><p>輸入回應物件</p></td>
|
|
3368
|
+
</tr>
|
|
3277
3369
|
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3370
|
+
|
|
3371
|
+
</tbody>
|
|
3372
|
+
</table>
|
|
3281
3373
|
|
|
3282
|
-
<table class="params">
|
|
3283
|
-
<thead>
|
|
3284
|
-
<tr>
|
|
3285
|
-
|
|
3286
|
-
<th>Name</th>
|
|
3287
|
-
|
|
3288
3374
|
|
|
3289
|
-
<th>Type</th>
|
|
3290
3375
|
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3376
|
+
|
|
3377
|
+
|
|
3378
|
+
|
|
3379
|
+
|
|
3380
|
+
|
|
3381
|
+
|
|
3382
|
+
|
|
3383
|
+
|
|
3384
|
+
|
|
3385
|
+
|
|
3386
|
+
|
|
3387
|
+
|
|
3388
|
+
|
|
3389
|
+
<h5 class="h5-returns">Returns:</h5>
|
|
3390
|
+
|
|
3391
|
+
|
|
3392
|
+
<div class="param-desc">
|
|
3393
|
+
<p>回傳單筆物件陣列, 無則[]</p>
|
|
3394
|
+
</div>
|
|
3395
|
+
|
|
3396
|
+
|
|
3397
|
+
|
|
3398
|
+
<dl class="param-type">
|
|
3399
|
+
<dt>
|
|
3400
|
+
Type
|
|
3401
|
+
</dt>
|
|
3402
|
+
<dd>
|
|
3403
|
+
|
|
3404
|
+
<span class="param-type">Array</span>
|
|
3405
|
+
|
|
3406
|
+
|
|
3407
|
+
|
|
3408
|
+
</dd>
|
|
3409
|
+
</dl>
|
|
3410
|
+
|
|
3411
|
+
|
|
3412
|
+
|
|
3413
|
+
|
|
3414
|
+
|
|
3415
|
+
|
|
3416
|
+
|
|
3417
|
+
|
|
3418
|
+
|
|
3419
|
+
|
|
3420
|
+
<h4 class="name" id="createFileStore"><span class="type-signature"></span>createFileStore<span class="signature">(opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Object}</span></h4>
|
|
3421
|
+
|
|
3422
|
+
|
|
3423
|
+
|
|
3424
|
+
|
|
3425
|
+
|
|
3426
|
+
|
|
3427
|
+
<dl class="details">
|
|
3428
|
+
|
|
3429
|
+
<dt class="tag-description">Description:</dt>
|
|
3430
|
+
<dd class="tag-description"><ul class="dummy"><li><p>建立dispatchAiFallback之store的檔案持久化(游標與冷卻跨行程有效)</p>
|
|
3431
|
+
<p>特點:
|
|
3432
|
+
採排除式passthrough——state原封存還,僅剔除本層自用欄位(預設只有at:人讀的最後更新時間戳),
|
|
3433
|
+
日後套件擴充state欄位(如cooling)即自動相容,不需改本函數;
|
|
3434
|
+
檔案不存在或非法JSON時get回空物件(套件視為全新狀態);
|
|
3435
|
+
stamp可注入時間戳函數(排程環境建議注入時區錨定者),寫入時補進at欄位供人工debug</p></li></ul></dd>
|
|
3436
|
+
|
|
3437
|
+
|
|
3438
|
+
|
|
3439
|
+
<dt class="tag-source">Source:</dt>
|
|
3440
|
+
<dd class="tag-source"><ul class="dummy"><li>
|
|
3441
|
+
<a href="wkf_createFileStore.mjs.html">wkf/createFileStore.mjs</a>, <a href="wkf_createFileStore.mjs.html#line56">line 56</a>
|
|
3442
|
+
</li></ul></dd>
|
|
3443
|
+
|
|
3444
|
+
|
|
3445
|
+
|
|
3446
|
+
|
|
3447
|
+
|
|
3448
|
+
|
|
3449
|
+
|
|
3450
|
+
|
|
3451
|
+
|
|
3452
|
+
|
|
3453
|
+
|
|
3454
|
+
|
|
3455
|
+
|
|
3456
|
+
|
|
3457
|
+
|
|
3458
|
+
|
|
3459
|
+
|
|
3460
|
+
|
|
3461
|
+
|
|
3462
|
+
|
|
3463
|
+
|
|
3464
|
+
|
|
3465
|
+
|
|
3466
|
+
|
|
3467
|
+
|
|
3468
|
+
|
|
3469
|
+
|
|
3470
|
+
|
|
3471
|
+
|
|
3472
|
+
|
|
3473
|
+
|
|
3474
|
+
</dl>
|
|
3475
|
+
|
|
3476
|
+
|
|
3477
|
+
|
|
3478
|
+
|
|
3479
|
+
|
|
3480
|
+
|
|
3481
|
+
|
|
3482
|
+
|
|
3483
|
+
|
|
3484
|
+
|
|
3485
|
+
|
|
3486
|
+
<h5 class="h5-examples">Example</h5>
|
|
3487
|
+
|
|
3488
|
+
<pre class="prettyprint"><code>import createFileStore from './src/wkf/createFileStore.mjs'
|
|
3489
|
+
import dispatchAiFallback from './src/dispatchAiFallback.mjs'
|
|
3490
|
+
|
|
3491
|
+
let store = createFileStore({ dir: './state' })
|
|
3492
|
+
//let r = await dispatchAiFallback(prompt, { providers, store, cooldownMs: 3600000 })</code></pre>
|
|
3493
|
+
|
|
3494
|
+
|
|
3495
|
+
|
|
3496
|
+
|
|
3497
|
+
<h5 class="h5-parameters">Parameters:</h5>
|
|
3498
|
+
|
|
3499
|
+
|
|
3500
|
+
<table class="params">
|
|
3501
|
+
<thead>
|
|
3502
|
+
<tr>
|
|
3503
|
+
|
|
3504
|
+
<th>Name</th>
|
|
3505
|
+
|
|
3506
|
+
|
|
3507
|
+
<th>Type</th>
|
|
3508
|
+
|
|
3509
|
+
|
|
3510
|
+
<th>Attributes</th>
|
|
3511
|
+
|
|
3512
|
+
|
|
3513
|
+
|
|
3514
|
+
<th>Default</th>
|
|
3515
|
+
|
|
3516
|
+
|
|
3517
|
+
<th class="last">Description</th>
|
|
3518
|
+
</tr>
|
|
3519
|
+
</thead>
|
|
3520
|
+
|
|
3521
|
+
<tbody>
|
|
3522
|
+
|
|
3523
|
+
|
|
3524
|
+
<tr>
|
|
3525
|
+
|
|
3526
|
+
<td class="name"><code>opt</code></td>
|
|
3527
|
+
|
|
3528
|
+
|
|
3529
|
+
<td class="type">
|
|
3530
|
+
|
|
3531
|
+
|
|
3532
|
+
<span class="param-type">Object</span>
|
|
3533
|
+
|
|
3534
|
+
|
|
3535
|
+
|
|
3536
|
+
|
|
3537
|
+
</td>
|
|
3538
|
+
|
|
3539
|
+
|
|
3540
|
+
<td class="attributes">
|
|
3541
|
+
|
|
3542
|
+
<optional><br>
|
|
3543
|
+
|
|
3544
|
+
|
|
3545
|
+
|
|
3546
|
+
|
|
3547
|
+
|
|
3548
|
+
</td>
|
|
3549
|
+
|
|
3550
|
+
|
|
3551
|
+
|
|
3552
|
+
<td class="default">
|
|
3553
|
+
|
|
3554
|
+
<code>{}</code>
|
|
3555
|
+
|
|
3556
|
+
</td>
|
|
3557
|
+
|
|
3558
|
+
|
|
3559
|
+
<td class="description last"><p>輸入設定物件,預設{}</p>
|
|
3560
|
+
<h6>Properties</h6>
|
|
3561
|
+
|
|
3562
|
+
|
|
3563
|
+
<table class="params">
|
|
3564
|
+
<thead>
|
|
3565
|
+
<tr>
|
|
3566
|
+
|
|
3567
|
+
<th>Name</th>
|
|
3568
|
+
|
|
3569
|
+
|
|
3570
|
+
<th>Type</th>
|
|
3571
|
+
|
|
3572
|
+
|
|
3573
|
+
<th>Attributes</th>
|
|
3574
|
+
|
|
3294
3575
|
|
|
3295
3576
|
|
|
3296
3577
|
<th>Default</th>
|
|
@@ -6095,7 +6376,728 @@ agy自身之--print-timeout未給時由timeoutMs推導並預留30秒緩衝,令
|
|
|
6095
6376
|
|
|
6096
6377
|
<dt class="tag-source">Source:</dt>
|
|
6097
6378
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
6098
|
-
<a href="dispatchAntigravity.mjs.html">dispatchAntigravity.mjs</a>, <a href="dispatchAntigravity.mjs.html#line106">line 106</a>
|
|
6379
|
+
<a href="dispatchAntigravity.mjs.html">dispatchAntigravity.mjs</a>, <a href="dispatchAntigravity.mjs.html#line106">line 106</a>
|
|
6380
|
+
</li></ul></dd>
|
|
6381
|
+
|
|
6382
|
+
|
|
6383
|
+
|
|
6384
|
+
|
|
6385
|
+
|
|
6386
|
+
|
|
6387
|
+
|
|
6388
|
+
|
|
6389
|
+
|
|
6390
|
+
|
|
6391
|
+
|
|
6392
|
+
|
|
6393
|
+
|
|
6394
|
+
|
|
6395
|
+
|
|
6396
|
+
|
|
6397
|
+
|
|
6398
|
+
|
|
6399
|
+
|
|
6400
|
+
|
|
6401
|
+
|
|
6402
|
+
|
|
6403
|
+
|
|
6404
|
+
|
|
6405
|
+
|
|
6406
|
+
|
|
6407
|
+
|
|
6408
|
+
|
|
6409
|
+
|
|
6410
|
+
|
|
6411
|
+
|
|
6412
|
+
</dl>
|
|
6413
|
+
|
|
6414
|
+
|
|
6415
|
+
|
|
6416
|
+
|
|
6417
|
+
|
|
6418
|
+
|
|
6419
|
+
|
|
6420
|
+
|
|
6421
|
+
|
|
6422
|
+
|
|
6423
|
+
|
|
6424
|
+
<h5 class="h5-examples">Example</h5>
|
|
6425
|
+
|
|
6426
|
+
<pre class="prettyprint"><code>//need agy cli in system PATH, and OAuth login completed
|
|
6427
|
+
|
|
6428
|
+
import dispatchAntigravity from './src/dispatchAntigravity.mjs'
|
|
6429
|
+
|
|
6430
|
+
let test = async () => {
|
|
6431
|
+
|
|
6432
|
+
let r = await dispatchAntigravity('請只回覆兩個字:完成', { model: 'gemini-3.6-flash-low' })
|
|
6433
|
+
console.log(r.ok, r.stdout.trim())
|
|
6434
|
+
// => true 完成
|
|
6435
|
+
|
|
6436
|
+
//基礎slug搭配effort(不可用帶檔位之slug併用effort)
|
|
6437
|
+
let r2 = await dispatchAntigravity('請只回覆兩個字:完成', { model: 'gemini-3.1-pro', effort: 'low' })
|
|
6438
|
+
console.log(r2.ok)
|
|
6439
|
+
// => true
|
|
6440
|
+
|
|
6441
|
+
let re = await dispatchAntigravity('')
|
|
6442
|
+
console.log(re.ok, re.error)
|
|
6443
|
+
// => false 'prompt must be a non-empty string'
|
|
6444
|
+
|
|
6445
|
+
}
|
|
6446
|
+
await test()
|
|
6447
|
+
.catch((err) => {
|
|
6448
|
+
console.log(err)
|
|
6449
|
+
})</code></pre>
|
|
6450
|
+
|
|
6451
|
+
|
|
6452
|
+
|
|
6453
|
+
|
|
6454
|
+
<h5 class="h5-parameters">Parameters:</h5>
|
|
6455
|
+
|
|
6456
|
+
|
|
6457
|
+
<table class="params">
|
|
6458
|
+
<thead>
|
|
6459
|
+
<tr>
|
|
6460
|
+
|
|
6461
|
+
<th>Name</th>
|
|
6462
|
+
|
|
6463
|
+
|
|
6464
|
+
<th>Type</th>
|
|
6465
|
+
|
|
6466
|
+
|
|
6467
|
+
<th>Attributes</th>
|
|
6468
|
+
|
|
6469
|
+
|
|
6470
|
+
|
|
6471
|
+
<th>Default</th>
|
|
6472
|
+
|
|
6473
|
+
|
|
6474
|
+
<th class="last">Description</th>
|
|
6475
|
+
</tr>
|
|
6476
|
+
</thead>
|
|
6477
|
+
|
|
6478
|
+
<tbody>
|
|
6479
|
+
|
|
6480
|
+
|
|
6481
|
+
<tr>
|
|
6482
|
+
|
|
6483
|
+
<td class="name"><code>prompt</code></td>
|
|
6484
|
+
|
|
6485
|
+
|
|
6486
|
+
<td class="type">
|
|
6487
|
+
|
|
6488
|
+
|
|
6489
|
+
<span class="param-type">String</span>
|
|
6490
|
+
|
|
6491
|
+
|
|
6492
|
+
|
|
6493
|
+
|
|
6494
|
+
</td>
|
|
6495
|
+
|
|
6496
|
+
|
|
6497
|
+
<td class="attributes">
|
|
6498
|
+
|
|
6499
|
+
|
|
6500
|
+
|
|
6501
|
+
|
|
6502
|
+
|
|
6503
|
+
</td>
|
|
6504
|
+
|
|
6505
|
+
|
|
6506
|
+
|
|
6507
|
+
<td class="default">
|
|
6508
|
+
|
|
6509
|
+
</td>
|
|
6510
|
+
|
|
6511
|
+
|
|
6512
|
+
<td class="description last"><p>輸入提示詞字串,作為<code>--print</code>旗標之值傳遞,長度上限30000字元</p></td>
|
|
6513
|
+
</tr>
|
|
6514
|
+
|
|
6515
|
+
|
|
6516
|
+
|
|
6517
|
+
<tr>
|
|
6518
|
+
|
|
6519
|
+
<td class="name"><code>opt</code></td>
|
|
6520
|
+
|
|
6521
|
+
|
|
6522
|
+
<td class="type">
|
|
6523
|
+
|
|
6524
|
+
|
|
6525
|
+
<span class="param-type">Object</span>
|
|
6526
|
+
|
|
6527
|
+
|
|
6528
|
+
|
|
6529
|
+
|
|
6530
|
+
</td>
|
|
6531
|
+
|
|
6532
|
+
|
|
6533
|
+
<td class="attributes">
|
|
6534
|
+
|
|
6535
|
+
<optional><br>
|
|
6536
|
+
|
|
6537
|
+
|
|
6538
|
+
|
|
6539
|
+
|
|
6540
|
+
|
|
6541
|
+
</td>
|
|
6542
|
+
|
|
6543
|
+
|
|
6544
|
+
|
|
6545
|
+
<td class="default">
|
|
6546
|
+
|
|
6547
|
+
<code>{}</code>
|
|
6548
|
+
|
|
6549
|
+
</td>
|
|
6550
|
+
|
|
6551
|
+
|
|
6552
|
+
<td class="description last"><p>輸入設定物件,預設{}</p>
|
|
6553
|
+
<h6>Properties</h6>
|
|
6554
|
+
|
|
6555
|
+
|
|
6556
|
+
<table class="params">
|
|
6557
|
+
<thead>
|
|
6558
|
+
<tr>
|
|
6559
|
+
|
|
6560
|
+
<th>Name</th>
|
|
6561
|
+
|
|
6562
|
+
|
|
6563
|
+
<th>Type</th>
|
|
6564
|
+
|
|
6565
|
+
|
|
6566
|
+
<th>Attributes</th>
|
|
6567
|
+
|
|
6568
|
+
|
|
6569
|
+
|
|
6570
|
+
<th>Default</th>
|
|
6571
|
+
|
|
6572
|
+
|
|
6573
|
+
<th class="last">Description</th>
|
|
6574
|
+
</tr>
|
|
6575
|
+
</thead>
|
|
6576
|
+
|
|
6577
|
+
<tbody>
|
|
6578
|
+
|
|
6579
|
+
|
|
6580
|
+
<tr>
|
|
6581
|
+
|
|
6582
|
+
<td class="name"><code>exe</code></td>
|
|
6583
|
+
|
|
6584
|
+
|
|
6585
|
+
<td class="type">
|
|
6586
|
+
|
|
6587
|
+
|
|
6588
|
+
<span class="param-type">String</span>
|
|
6589
|
+
|
|
6590
|
+
|
|
6591
|
+
|
|
6592
|
+
|
|
6593
|
+
</td>
|
|
6594
|
+
|
|
6595
|
+
|
|
6596
|
+
<td class="attributes">
|
|
6597
|
+
|
|
6598
|
+
<optional><br>
|
|
6599
|
+
|
|
6600
|
+
|
|
6601
|
+
|
|
6602
|
+
|
|
6603
|
+
|
|
6604
|
+
</td>
|
|
6605
|
+
|
|
6606
|
+
|
|
6607
|
+
|
|
6608
|
+
<td class="default">
|
|
6609
|
+
|
|
6610
|
+
<code>'agy'</code>
|
|
6611
|
+
|
|
6612
|
+
</td>
|
|
6613
|
+
|
|
6614
|
+
|
|
6615
|
+
<td class="description last"><p>輸入agy執行檔名稱或絕對路徑字串,命令名為agy非antigravity,給予名稱時由execCli自系統PATH解析,預設'agy'</p></td>
|
|
6616
|
+
</tr>
|
|
6617
|
+
|
|
6618
|
+
|
|
6619
|
+
|
|
6620
|
+
<tr>
|
|
6621
|
+
|
|
6622
|
+
<td class="name"><code>model</code></td>
|
|
6623
|
+
|
|
6624
|
+
|
|
6625
|
+
<td class="type">
|
|
6626
|
+
|
|
6627
|
+
|
|
6628
|
+
<span class="param-type">String</span>
|
|
6629
|
+
|
|
6630
|
+
|
|
6631
|
+
|
|
6632
|
+
|
|
6633
|
+
</td>
|
|
6634
|
+
|
|
6635
|
+
|
|
6636
|
+
<td class="attributes">
|
|
6637
|
+
|
|
6638
|
+
<optional><br>
|
|
6639
|
+
|
|
6640
|
+
|
|
6641
|
+
|
|
6642
|
+
|
|
6643
|
+
|
|
6644
|
+
</td>
|
|
6645
|
+
|
|
6646
|
+
|
|
6647
|
+
|
|
6648
|
+
<td class="default">
|
|
6649
|
+
|
|
6650
|
+
<code>''</code>
|
|
6651
|
+
|
|
6652
|
+
</td>
|
|
6653
|
+
|
|
6654
|
+
|
|
6655
|
+
<td class="description last"><p>輸入模型slug字串,須為<code>agy models</code>第一欄之slug,例如'gemini-3.6-flash-low'、'gemini-3.1-pro-high',預設''代表不帶<code>--model</code>旗標由agy自行決定</p></td>
|
|
6656
|
+
</tr>
|
|
6657
|
+
|
|
6658
|
+
|
|
6659
|
+
|
|
6660
|
+
<tr>
|
|
6661
|
+
|
|
6662
|
+
<td class="name"><code>effort</code></td>
|
|
6663
|
+
|
|
6664
|
+
|
|
6665
|
+
<td class="type">
|
|
6666
|
+
|
|
6667
|
+
|
|
6668
|
+
<span class="param-type">String</span>
|
|
6669
|
+
|
|
6670
|
+
|
|
6671
|
+
|
|
6672
|
+
|
|
6673
|
+
</td>
|
|
6674
|
+
|
|
6675
|
+
|
|
6676
|
+
<td class="attributes">
|
|
6677
|
+
|
|
6678
|
+
<optional><br>
|
|
6679
|
+
|
|
6680
|
+
|
|
6681
|
+
|
|
6682
|
+
|
|
6683
|
+
|
|
6684
|
+
</td>
|
|
6685
|
+
|
|
6686
|
+
|
|
6687
|
+
|
|
6688
|
+
<td class="default">
|
|
6689
|
+
|
|
6690
|
+
<code>''</code>
|
|
6691
|
+
|
|
6692
|
+
</td>
|
|
6693
|
+
|
|
6694
|
+
|
|
6695
|
+
<td class="description last"><p>輸入推理深度字串,可選'low'、'medium'、'high',需agy>=1.1.11,建議搭配不帶檔位之基礎slug;與帶檔位slug併用且檔位不一致時agy回conflicts錯誤,預設''代表不帶</p></td>
|
|
6696
|
+
</tr>
|
|
6697
|
+
|
|
6698
|
+
|
|
6699
|
+
|
|
6700
|
+
<tr>
|
|
6701
|
+
|
|
6702
|
+
<td class="name"><code>skipPermissions</code></td>
|
|
6703
|
+
|
|
6704
|
+
|
|
6705
|
+
<td class="type">
|
|
6706
|
+
|
|
6707
|
+
|
|
6708
|
+
<span class="param-type">Boolean</span>
|
|
6709
|
+
|
|
6710
|
+
|
|
6711
|
+
|
|
6712
|
+
|
|
6713
|
+
</td>
|
|
6714
|
+
|
|
6715
|
+
|
|
6716
|
+
<td class="attributes">
|
|
6717
|
+
|
|
6718
|
+
<optional><br>
|
|
6719
|
+
|
|
6720
|
+
|
|
6721
|
+
|
|
6722
|
+
|
|
6723
|
+
|
|
6724
|
+
</td>
|
|
6725
|
+
|
|
6726
|
+
|
|
6727
|
+
|
|
6728
|
+
<td class="default">
|
|
6729
|
+
|
|
6730
|
+
<code>true</code>
|
|
6731
|
+
|
|
6732
|
+
</td>
|
|
6733
|
+
|
|
6734
|
+
|
|
6735
|
+
<td class="description last"><p>輸入是否帶<code>--dangerously-skip-permissions</code>旗標布林值,false代表保留CLI權限閘門,預設true</p></td>
|
|
6736
|
+
</tr>
|
|
6737
|
+
|
|
6738
|
+
|
|
6739
|
+
|
|
6740
|
+
<tr>
|
|
6741
|
+
|
|
6742
|
+
<td class="name"><code>printTimeout</code></td>
|
|
6743
|
+
|
|
6744
|
+
|
|
6745
|
+
<td class="type">
|
|
6746
|
+
|
|
6747
|
+
|
|
6748
|
+
<span class="param-type">String</span>
|
|
6749
|
+
|
|
6750
|
+
|
|
6751
|
+
|
|
6752
|
+
|
|
6753
|
+
</td>
|
|
6754
|
+
|
|
6755
|
+
|
|
6756
|
+
<td class="attributes">
|
|
6757
|
+
|
|
6758
|
+
<optional><br>
|
|
6759
|
+
|
|
6760
|
+
|
|
6761
|
+
|
|
6762
|
+
|
|
6763
|
+
|
|
6764
|
+
</td>
|
|
6765
|
+
|
|
6766
|
+
|
|
6767
|
+
|
|
6768
|
+
<td class="default">
|
|
6769
|
+
|
|
6770
|
+
<code>''</code>
|
|
6771
|
+
|
|
6772
|
+
</td>
|
|
6773
|
+
|
|
6774
|
+
|
|
6775
|
+
<td class="description last"><p>輸入agy自身等待上限字串(如'10m'、'570s'),預設''代表由timeoutMs推導(扣30秒緩衝,下限30秒)</p></td>
|
|
6776
|
+
</tr>
|
|
6777
|
+
|
|
6778
|
+
|
|
6779
|
+
|
|
6780
|
+
<tr>
|
|
6781
|
+
|
|
6782
|
+
<td class="name"><code>addDirs</code></td>
|
|
6783
|
+
|
|
6784
|
+
|
|
6785
|
+
<td class="type">
|
|
6786
|
+
|
|
6787
|
+
|
|
6788
|
+
<span class="param-type">Array</span>
|
|
6789
|
+
|
|
6790
|
+
|
|
6791
|
+
|
|
6792
|
+
|
|
6793
|
+
</td>
|
|
6794
|
+
|
|
6795
|
+
|
|
6796
|
+
<td class="attributes">
|
|
6797
|
+
|
|
6798
|
+
<optional><br>
|
|
6799
|
+
|
|
6800
|
+
|
|
6801
|
+
|
|
6802
|
+
|
|
6803
|
+
|
|
6804
|
+
</td>
|
|
6805
|
+
|
|
6806
|
+
|
|
6807
|
+
|
|
6808
|
+
<td class="default">
|
|
6809
|
+
|
|
6810
|
+
<code>自動納入cwd</code>
|
|
6811
|
+
|
|
6812
|
+
</td>
|
|
6813
|
+
|
|
6814
|
+
|
|
6815
|
+
<td class="description last"><p>輸入加入workspace之目錄字串陣列,逐項展開為<code>--add-dir</code>。agy以自身scratch目錄為工作區而不採子進程cwd,故未給本參數時自動納入有效cwd令檔案可視範圍與其他CLI轉接器一致;明示給陣列(含空陣列[]代表不揭露任何目錄)則完全尊重呼叫端</p></td>
|
|
6816
|
+
</tr>
|
|
6817
|
+
|
|
6818
|
+
|
|
6819
|
+
|
|
6820
|
+
<tr>
|
|
6821
|
+
|
|
6822
|
+
<td class="name"><code>extraArgs</code></td>
|
|
6823
|
+
|
|
6824
|
+
|
|
6825
|
+
<td class="type">
|
|
6826
|
+
|
|
6827
|
+
|
|
6828
|
+
<span class="param-type">Array</span>
|
|
6829
|
+
|
|
6830
|
+
|
|
6831
|
+
|
|
6832
|
+
|
|
6833
|
+
</td>
|
|
6834
|
+
|
|
6835
|
+
|
|
6836
|
+
<td class="attributes">
|
|
6837
|
+
|
|
6838
|
+
<optional><br>
|
|
6839
|
+
|
|
6840
|
+
|
|
6841
|
+
|
|
6842
|
+
|
|
6843
|
+
|
|
6844
|
+
</td>
|
|
6845
|
+
|
|
6846
|
+
|
|
6847
|
+
|
|
6848
|
+
<td class="default">
|
|
6849
|
+
|
|
6850
|
+
<code>[]</code>
|
|
6851
|
+
|
|
6852
|
+
</td>
|
|
6853
|
+
|
|
6854
|
+
|
|
6855
|
+
<td class="description last"><p>輸入額外命令列旗標字串陣列(如--output-format、--json-schema、--mode),將接於固定旗標之後、<code>--print</code>之前,預設[]</p></td>
|
|
6856
|
+
</tr>
|
|
6857
|
+
|
|
6858
|
+
|
|
6859
|
+
|
|
6860
|
+
<tr>
|
|
6861
|
+
|
|
6862
|
+
<td class="name"><code>timeoutMs</code></td>
|
|
6863
|
+
|
|
6864
|
+
|
|
6865
|
+
<td class="type">
|
|
6866
|
+
|
|
6867
|
+
|
|
6868
|
+
<span class="param-type">Number</span>
|
|
6869
|
+
|
|
6870
|
+
|
|
6871
|
+
|
|
6872
|
+
|
|
6873
|
+
</td>
|
|
6874
|
+
|
|
6875
|
+
|
|
6876
|
+
<td class="attributes">
|
|
6877
|
+
|
|
6878
|
+
<optional><br>
|
|
6879
|
+
|
|
6880
|
+
|
|
6881
|
+
|
|
6882
|
+
|
|
6883
|
+
|
|
6884
|
+
</td>
|
|
6885
|
+
|
|
6886
|
+
|
|
6887
|
+
|
|
6888
|
+
<td class="default">
|
|
6889
|
+
|
|
6890
|
+
<code>300000</code>
|
|
6891
|
+
|
|
6892
|
+
</td>
|
|
6893
|
+
|
|
6894
|
+
|
|
6895
|
+
<td class="description last"><p>輸入逾時毫秒正整數,逾時將強制關閉子進程及其子孫程序,全套件統一預設300000(恰對齊agy自身print-timeout預設5m0s)</p></td>
|
|
6896
|
+
</tr>
|
|
6897
|
+
|
|
6898
|
+
|
|
6899
|
+
|
|
6900
|
+
<tr>
|
|
6901
|
+
|
|
6902
|
+
<td class="name"><code>cwd</code></td>
|
|
6903
|
+
|
|
6904
|
+
|
|
6905
|
+
<td class="type">
|
|
6906
|
+
|
|
6907
|
+
|
|
6908
|
+
<span class="param-type">String</span>
|
|
6909
|
+
|
|
6910
|
+
|
|
6911
|
+
|
|
6912
|
+
|
|
6913
|
+
</td>
|
|
6914
|
+
|
|
6915
|
+
|
|
6916
|
+
<td class="attributes">
|
|
6917
|
+
|
|
6918
|
+
<optional><br>
|
|
6919
|
+
|
|
6920
|
+
|
|
6921
|
+
|
|
6922
|
+
|
|
6923
|
+
|
|
6924
|
+
</td>
|
|
6925
|
+
|
|
6926
|
+
|
|
6927
|
+
|
|
6928
|
+
<td class="default">
|
|
6929
|
+
|
|
6930
|
+
<code>process.cwd()</code>
|
|
6931
|
+
|
|
6932
|
+
</td>
|
|
6933
|
+
|
|
6934
|
+
|
|
6935
|
+
<td class="description last"><p>輸入子進程工作目錄字串,預設process.cwd()。注意本參數不影響agy之檔案可視範圍(agy以自身scratch目錄為工作區),可視範圍由addDirs決定(未給addDirs時自動納入本目錄)</p></td>
|
|
6936
|
+
</tr>
|
|
6937
|
+
|
|
6938
|
+
|
|
6939
|
+
|
|
6940
|
+
<tr>
|
|
6941
|
+
|
|
6942
|
+
<td class="name"><code>validate</code></td>
|
|
6943
|
+
|
|
6944
|
+
|
|
6945
|
+
<td class="type">
|
|
6946
|
+
|
|
6947
|
+
|
|
6948
|
+
<span class="param-type">String</span>
|
|
6949
|
+
|
|
|
6950
|
+
|
|
6951
|
+
<span class="param-type">function</span>
|
|
6952
|
+
|
|
6953
|
+
|
|
6954
|
+
|
|
6955
|
+
|
|
6956
|
+
</td>
|
|
6957
|
+
|
|
6958
|
+
|
|
6959
|
+
<td class="attributes">
|
|
6960
|
+
|
|
6961
|
+
<optional><br>
|
|
6962
|
+
|
|
6963
|
+
|
|
6964
|
+
|
|
6965
|
+
|
|
6966
|
+
|
|
6967
|
+
</td>
|
|
6968
|
+
|
|
6969
|
+
|
|
6970
|
+
|
|
6971
|
+
<td class="default">
|
|
6972
|
+
|
|
6973
|
+
</td>
|
|
6974
|
+
|
|
6975
|
+
|
|
6976
|
+
<td class="description last"><p>輸入stdout驗證規則字串或自訂驗證函數,規則字串支援'nonempty'、'json'、'min:100',多規則可用逗號串接,預設undefined代表不驗證</p></td>
|
|
6977
|
+
</tr>
|
|
6978
|
+
|
|
6979
|
+
|
|
6980
|
+
|
|
6981
|
+
<tr>
|
|
6982
|
+
|
|
6983
|
+
<td class="name"><code>maxRetries</code></td>
|
|
6984
|
+
|
|
6985
|
+
|
|
6986
|
+
<td class="type">
|
|
6987
|
+
|
|
6988
|
+
|
|
6989
|
+
<span class="param-type">Number</span>
|
|
6990
|
+
|
|
6991
|
+
|
|
6992
|
+
|
|
6993
|
+
|
|
6994
|
+
</td>
|
|
6995
|
+
|
|
6996
|
+
|
|
6997
|
+
<td class="attributes">
|
|
6998
|
+
|
|
6999
|
+
<optional><br>
|
|
7000
|
+
|
|
7001
|
+
|
|
7002
|
+
|
|
7003
|
+
|
|
7004
|
+
|
|
7005
|
+
</td>
|
|
7006
|
+
|
|
7007
|
+
|
|
7008
|
+
|
|
7009
|
+
<td class="default">
|
|
7010
|
+
|
|
7011
|
+
<code>0</code>
|
|
7012
|
+
|
|
7013
|
+
</td>
|
|
7014
|
+
|
|
7015
|
+
|
|
7016
|
+
<td class="description last"><p>輸入失敗後最大重試次數非負整數,預設0</p></td>
|
|
7017
|
+
</tr>
|
|
7018
|
+
|
|
7019
|
+
|
|
7020
|
+
</tbody>
|
|
7021
|
+
</table>
|
|
7022
|
+
|
|
7023
|
+
</td>
|
|
7024
|
+
</tr>
|
|
7025
|
+
|
|
7026
|
+
|
|
7027
|
+
</tbody>
|
|
7028
|
+
</table>
|
|
7029
|
+
|
|
7030
|
+
|
|
7031
|
+
|
|
7032
|
+
|
|
7033
|
+
|
|
7034
|
+
|
|
7035
|
+
|
|
7036
|
+
|
|
7037
|
+
|
|
7038
|
+
|
|
7039
|
+
|
|
7040
|
+
|
|
7041
|
+
|
|
7042
|
+
|
|
7043
|
+
|
|
7044
|
+
|
|
7045
|
+
<h5 class="h5-returns">Returns:</h5>
|
|
7046
|
+
|
|
7047
|
+
|
|
7048
|
+
<div class="param-desc">
|
|
7049
|
+
<p>回傳Promise,resolve回傳結果物件,內含ok(是否成功布林值)、stdout(標準輸出字串)、stderr(標準錯誤字串)、code(離開碼)、error(錯誤訊息字串,成功時為空字串)、durationMs(耗時毫秒)、attempts(實際嘗試次數),本函數不會reject</p>
|
|
7050
|
+
</div>
|
|
7051
|
+
|
|
7052
|
+
|
|
7053
|
+
|
|
7054
|
+
<dl class="param-type">
|
|
7055
|
+
<dt>
|
|
7056
|
+
Type
|
|
7057
|
+
</dt>
|
|
7058
|
+
<dd>
|
|
7059
|
+
|
|
7060
|
+
<span class="param-type">Promise</span>
|
|
7061
|
+
|
|
7062
|
+
|
|
7063
|
+
|
|
7064
|
+
</dd>
|
|
7065
|
+
</dl>
|
|
7066
|
+
|
|
7067
|
+
|
|
7068
|
+
|
|
7069
|
+
|
|
7070
|
+
|
|
7071
|
+
|
|
7072
|
+
|
|
7073
|
+
|
|
7074
|
+
|
|
7075
|
+
|
|
7076
|
+
<h4 class="name" id="dispatchApiOpenaiCompat"><span class="type-signature type-signature-async">(async) </span>dispatchApiOpenaiCompat<span class="signature">(prompt, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
|
|
7077
|
+
|
|
7078
|
+
|
|
7079
|
+
|
|
7080
|
+
|
|
7081
|
+
|
|
7082
|
+
|
|
7083
|
+
<dl class="details">
|
|
7084
|
+
|
|
7085
|
+
<dt class="tag-description">Description:</dt>
|
|
7086
|
+
<dd class="tag-description"><ul class="dummy"><li><p>以fetch直呼OpenAI相容API(chat/completions)呼叫AI模型</p>
|
|
7087
|
+
<p>特點:
|
|
7088
|
+
免安裝CLI、免預先登入,給baseURL+key+model即可呼叫(如OpenCode Zen、Agnes等OpenAI相容閘道);
|
|
7089
|
+
僅供純文字生成(摘要、分析、改寫、產出JSON等素材已在prompt內之任務)——
|
|
7090
|
+
需要讀本機檔案、grep、執行指令、抓網頁等工具能力時,請改用CLI類kind(opencode/claude/codex/antigravity);
|
|
7091
|
+
prompt走HTTP body,無命令列長度限制;
|
|
7092
|
+
錯誤依HTTP狀態碼分流:4xx(429除外)為客戶端錯誤不重試,429/5xx/網路錯誤/逾時依maxRetries線性退避重試;
|
|
7093
|
+
結果結構與逾時/驗證失敗之error字樣對齊execCli,可直接作為dispatchAi與dispatchAiFallback之kind('api-openai-compat')使用;
|
|
7094
|
+
本函數不會reject,一律以結果物件之ok與error欄位回報成敗</p></li></ul></dd>
|
|
7095
|
+
|
|
7096
|
+
|
|
7097
|
+
|
|
7098
|
+
<dt class="tag-source">Source:</dt>
|
|
7099
|
+
<dd class="tag-source"><ul class="dummy"><li>
|
|
7100
|
+
<a href="dispatchApiOpenaiCompat.mjs.html">dispatchApiOpenaiCompat.mjs</a>, <a href="dispatchApiOpenaiCompat.mjs.html#line261">line 261</a>
|
|
6099
7101
|
</li></ul></dd>
|
|
6100
7102
|
|
|
6101
7103
|
|
|
@@ -6142,24 +7144,33 @@ agy自身之--print-timeout未給時由timeoutMs推導並預留30秒緩衝,令
|
|
|
6142
7144
|
|
|
6143
7145
|
<h5 class="h5-examples">Example</h5>
|
|
6144
7146
|
|
|
6145
|
-
<pre class="prettyprint"><code>//need
|
|
7147
|
+
<pre class="prettyprint"><code>//need network, no cli required
|
|
6146
7148
|
|
|
6147
|
-
import
|
|
7149
|
+
import dispatchApiOpenaiCompat from './src/dispatchApiOpenaiCompat.mjs'
|
|
6148
7150
|
|
|
6149
7151
|
let test = async () => {
|
|
6150
7152
|
|
|
6151
|
-
|
|
6152
|
-
|
|
7153
|
+
//OpenCode Zen(即opencode CLI之自家閘道), 模型名不帶opencode/前綴
|
|
7154
|
+
let r1 = await dispatchApiOpenaiCompat('請只回覆兩個字:完成', {
|
|
7155
|
+
baseURL: 'https://opencode.ai/zen/v1',
|
|
7156
|
+
key: 'sk-xxxxxx',
|
|
7157
|
+
model: 'deepseek-v4-flash-free',
|
|
7158
|
+
})
|
|
7159
|
+
console.log(r1.ok, r1.stdout.trim())
|
|
6153
7160
|
// => true 完成
|
|
6154
7161
|
|
|
6155
|
-
|
|
6156
|
-
let r2 = await
|
|
6157
|
-
|
|
6158
|
-
|
|
7162
|
+
//Agnes
|
|
7163
|
+
let r2 = await dispatchApiOpenaiCompat('請只回覆兩個字:完成', {
|
|
7164
|
+
baseURL: 'https://apihub.agnes-ai.com/v1',
|
|
7165
|
+
key: 'sk-xxxxxx',
|
|
7166
|
+
model: 'agnes-2.0-flash',
|
|
7167
|
+
})
|
|
7168
|
+
console.log(r2.ok, r2.stdout.trim())
|
|
7169
|
+
// => true 完成
|
|
6159
7170
|
|
|
6160
|
-
let re = await
|
|
6161
|
-
console.log(re.ok, re.error)
|
|
6162
|
-
// => false
|
|
7171
|
+
let re = await dispatchApiOpenaiCompat('abc', { baseURL: 'https://opencode.ai/zen/v1', key: 'sk-bad', model: 'deepseek-v4-flash-free' })
|
|
7172
|
+
console.log(re.ok, re.code, re.error)
|
|
7173
|
+
// => false 401 HTTP 401
|
|
6163
7174
|
|
|
6164
7175
|
}
|
|
6165
7176
|
await test()
|
|
@@ -6228,7 +7239,7 @@ await test()
|
|
|
6228
7239
|
</td>
|
|
6229
7240
|
|
|
6230
7241
|
|
|
6231
|
-
<td class="description last"><p
|
|
7242
|
+
<td class="description last"><p>輸入提示詞字串,作為user訊息置於HTTP body</p></td>
|
|
6232
7243
|
</tr>
|
|
6233
7244
|
|
|
6234
7245
|
|
|
@@ -6298,7 +7309,7 @@ await test()
|
|
|
6298
7309
|
|
|
6299
7310
|
<tr>
|
|
6300
7311
|
|
|
6301
|
-
<td class="name"><code>
|
|
7312
|
+
<td class="name"><code>baseURL</code></td>
|
|
6302
7313
|
|
|
6303
7314
|
|
|
6304
7315
|
<td class="type">
|
|
@@ -6314,8 +7325,6 @@ await test()
|
|
|
6314
7325
|
|
|
6315
7326
|
<td class="attributes">
|
|
6316
7327
|
|
|
6317
|
-
<optional><br>
|
|
6318
|
-
|
|
6319
7328
|
|
|
6320
7329
|
|
|
6321
7330
|
|
|
@@ -6326,12 +7335,10 @@ await test()
|
|
|
6326
7335
|
|
|
6327
7336
|
<td class="default">
|
|
6328
7337
|
|
|
6329
|
-
<code>'agy'</code>
|
|
6330
|
-
|
|
6331
7338
|
</td>
|
|
6332
7339
|
|
|
6333
7340
|
|
|
6334
|
-
<td class="description last"><p>輸入
|
|
7341
|
+
<td class="description last"><p>輸入API基底網址字串,例如'https://opencode.ai/zen/v1'、'https://apihub.agnes-ai.com/v1',將於尾端接上/chat/completions</p></td>
|
|
6335
7342
|
</tr>
|
|
6336
7343
|
|
|
6337
7344
|
|
|
@@ -6354,8 +7361,6 @@ await test()
|
|
|
6354
7361
|
|
|
6355
7362
|
<td class="attributes">
|
|
6356
7363
|
|
|
6357
|
-
<optional><br>
|
|
6358
|
-
|
|
6359
7364
|
|
|
6360
7365
|
|
|
6361
7366
|
|
|
@@ -6366,19 +7371,17 @@ await test()
|
|
|
6366
7371
|
|
|
6367
7372
|
<td class="default">
|
|
6368
7373
|
|
|
6369
|
-
<code>''</code>
|
|
6370
|
-
|
|
6371
7374
|
</td>
|
|
6372
7375
|
|
|
6373
7376
|
|
|
6374
|
-
<td class="description last"><p>輸入模型
|
|
7377
|
+
<td class="description last"><p>輸入模型ID字串,例如'deepseek-v4-flash-free'(Zen之模型名不帶opencode/前綴)、'agnes-2.0-flash'</p></td>
|
|
6375
7378
|
</tr>
|
|
6376
7379
|
|
|
6377
7380
|
|
|
6378
7381
|
|
|
6379
7382
|
<tr>
|
|
6380
7383
|
|
|
6381
|
-
<td class="name"><code>
|
|
7384
|
+
<td class="name"><code>key</code></td>
|
|
6382
7385
|
|
|
6383
7386
|
|
|
6384
7387
|
<td class="type">
|
|
@@ -6411,54 +7414,14 @@ await test()
|
|
|
6411
7414
|
</td>
|
|
6412
7415
|
|
|
6413
7416
|
|
|
6414
|
-
<td class="description last"><p
|
|
6415
|
-
</tr>
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
<tr>
|
|
6420
|
-
|
|
6421
|
-
<td class="name"><code>skipPermissions</code></td>
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
<td class="type">
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
<span class="param-type">Boolean</span>
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
</td>
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
<td class="attributes">
|
|
6436
|
-
|
|
6437
|
-
<optional><br>
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
</td>
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
<td class="default">
|
|
6448
|
-
|
|
6449
|
-
<code>true</code>
|
|
6450
|
-
|
|
6451
|
-
</td>
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
<td class="description last"><p>輸入是否帶<code>--dangerously-skip-permissions</code>旗標布林值,false代表保留CLI權限閘門,預設true</p></td>
|
|
7417
|
+
<td class="description last"><p>輸入API key字串,以Bearer置於Authorization標頭,預設''代表不帶認證標頭</p></td>
|
|
6455
7418
|
</tr>
|
|
6456
7419
|
|
|
6457
7420
|
|
|
6458
7421
|
|
|
6459
7422
|
<tr>
|
|
6460
7423
|
|
|
6461
|
-
<td class="name"><code>
|
|
7424
|
+
<td class="name"><code>system</code></td>
|
|
6462
7425
|
|
|
6463
7426
|
|
|
6464
7427
|
<td class="type">
|
|
@@ -6491,20 +7454,20 @@ await test()
|
|
|
6491
7454
|
</td>
|
|
6492
7455
|
|
|
6493
7456
|
|
|
6494
|
-
<td class="description last"><p>輸入
|
|
7457
|
+
<td class="description last"><p>輸入system提示詞字串,將以system角色置於messages首位,預設''代表不帶</p></td>
|
|
6495
7458
|
</tr>
|
|
6496
7459
|
|
|
6497
7460
|
|
|
6498
7461
|
|
|
6499
7462
|
<tr>
|
|
6500
7463
|
|
|
6501
|
-
<td class="name"><code>
|
|
7464
|
+
<td class="name"><code>body</code></td>
|
|
6502
7465
|
|
|
6503
7466
|
|
|
6504
7467
|
<td class="type">
|
|
6505
7468
|
|
|
6506
7469
|
|
|
6507
|
-
<span class="param-type">
|
|
7470
|
+
<span class="param-type">Object</span>
|
|
6508
7471
|
|
|
6509
7472
|
|
|
6510
7473
|
|
|
@@ -6526,25 +7489,25 @@ await test()
|
|
|
6526
7489
|
|
|
6527
7490
|
<td class="default">
|
|
6528
7491
|
|
|
6529
|
-
<code
|
|
7492
|
+
<code>{}</code>
|
|
6530
7493
|
|
|
6531
7494
|
</td>
|
|
6532
7495
|
|
|
6533
7496
|
|
|
6534
|
-
<td class="description last"><p
|
|
7497
|
+
<td class="description last"><p>輸入額外請求本體物件(如temperature、max_tokens、response_format),將併入預設body(同名鍵以此為準),預設{}。注意本轉接器不支援工具,帶入tools而模型回tool_calls時一律以TOOL_CALLS_UNSUPPORTED回報失敗,需要工具請改用CLI類kind</p></td>
|
|
6535
7498
|
</tr>
|
|
6536
7499
|
|
|
6537
7500
|
|
|
6538
7501
|
|
|
6539
7502
|
<tr>
|
|
6540
7503
|
|
|
6541
|
-
<td class="name"><code>
|
|
7504
|
+
<td class="name"><code>headers</code></td>
|
|
6542
7505
|
|
|
6543
7506
|
|
|
6544
7507
|
<td class="type">
|
|
6545
7508
|
|
|
6546
7509
|
|
|
6547
|
-
<span class="param-type">
|
|
7510
|
+
<span class="param-type">Object</span>
|
|
6548
7511
|
|
|
6549
7512
|
|
|
6550
7513
|
|
|
@@ -6566,12 +7529,12 @@ await test()
|
|
|
6566
7529
|
|
|
6567
7530
|
<td class="default">
|
|
6568
7531
|
|
|
6569
|
-
<code>
|
|
7532
|
+
<code>{}</code>
|
|
6570
7533
|
|
|
6571
7534
|
</td>
|
|
6572
7535
|
|
|
6573
7536
|
|
|
6574
|
-
<td class="description last"><p
|
|
7537
|
+
<td class="description last"><p>輸入額外請求標頭物件,預設{}</p></td>
|
|
6575
7538
|
</tr>
|
|
6576
7539
|
|
|
6577
7540
|
|
|
@@ -6611,20 +7574,23 @@ await test()
|
|
|
6611
7574
|
</td>
|
|
6612
7575
|
|
|
6613
7576
|
|
|
6614
|
-
<td class="description last"><p
|
|
7577
|
+
<td class="description last"><p>輸入逾時毫秒正整數,逾時將中止請求(含回應串流讀取),全套件統一預設300000</p></td>
|
|
6615
7578
|
</tr>
|
|
6616
7579
|
|
|
6617
7580
|
|
|
6618
7581
|
|
|
6619
7582
|
<tr>
|
|
6620
7583
|
|
|
6621
|
-
<td class="name"><code>
|
|
7584
|
+
<td class="name"><code>validate</code></td>
|
|
6622
7585
|
|
|
6623
7586
|
|
|
6624
7587
|
<td class="type">
|
|
6625
7588
|
|
|
6626
7589
|
|
|
6627
7590
|
<span class="param-type">String</span>
|
|
7591
|
+
|
|
|
7592
|
+
|
|
7593
|
+
<span class="param-type">function</span>
|
|
6628
7594
|
|
|
6629
7595
|
|
|
6630
7596
|
|
|
@@ -6646,28 +7612,23 @@ await test()
|
|
|
6646
7612
|
|
|
6647
7613
|
<td class="default">
|
|
6648
7614
|
|
|
6649
|
-
<code>process.cwd()</code>
|
|
6650
|
-
|
|
6651
7615
|
</td>
|
|
6652
7616
|
|
|
6653
7617
|
|
|
6654
|
-
<td class="description last"><p
|
|
7618
|
+
<td class="description last"><p>輸入回覆內容驗證規則字串或自訂驗證函數,規則字串支援'nonempty'、'json'、'min:100',多規則可用逗號串接,預設undefined代表不驗證</p></td>
|
|
6655
7619
|
</tr>
|
|
6656
7620
|
|
|
6657
7621
|
|
|
6658
7622
|
|
|
6659
7623
|
<tr>
|
|
6660
7624
|
|
|
6661
|
-
<td class="name"><code>
|
|
7625
|
+
<td class="name"><code>maxRetries</code></td>
|
|
6662
7626
|
|
|
6663
7627
|
|
|
6664
7628
|
<td class="type">
|
|
6665
7629
|
|
|
6666
7630
|
|
|
6667
|
-
<span class="param-type">
|
|
6668
|
-
|
|
|
6669
|
-
|
|
6670
|
-
<span class="param-type">function</span>
|
|
7631
|
+
<span class="param-type">Number</span>
|
|
6671
7632
|
|
|
6672
7633
|
|
|
6673
7634
|
|
|
@@ -6689,17 +7650,19 @@ await test()
|
|
|
6689
7650
|
|
|
6690
7651
|
<td class="default">
|
|
6691
7652
|
|
|
7653
|
+
<code>0</code>
|
|
7654
|
+
|
|
6692
7655
|
</td>
|
|
6693
7656
|
|
|
6694
7657
|
|
|
6695
|
-
<td class="description last"><p
|
|
7658
|
+
<td class="description last"><p>輸入失敗後最大重試次數非負整數,4xx(429除外)不重試,預設0</p></td>
|
|
6696
7659
|
</tr>
|
|
6697
7660
|
|
|
6698
7661
|
|
|
6699
7662
|
|
|
6700
7663
|
<tr>
|
|
6701
7664
|
|
|
6702
|
-
<td class="name"><code>
|
|
7665
|
+
<td class="name"><code>retryDelayMs</code></td>
|
|
6703
7666
|
|
|
6704
7667
|
|
|
6705
7668
|
<td class="type">
|
|
@@ -6727,12 +7690,12 @@ await test()
|
|
|
6727
7690
|
|
|
6728
7691
|
<td class="default">
|
|
6729
7692
|
|
|
6730
|
-
<code>
|
|
7693
|
+
<code>5000</code>
|
|
6731
7694
|
|
|
6732
7695
|
</td>
|
|
6733
7696
|
|
|
6734
7697
|
|
|
6735
|
-
<td class="description last"><p
|
|
7698
|
+
<td class="description last"><p>輸入重試間隔毫秒正整數,實際間隔為retryDelayMs乘以重試次數且上限15000ms,預設5000</p></td>
|
|
6736
7699
|
</tr>
|
|
6737
7700
|
|
|
6738
7701
|
|
|
@@ -6765,7 +7728,7 @@ await test()
|
|
|
6765
7728
|
|
|
6766
7729
|
|
|
6767
7730
|
<div class="param-desc">
|
|
6768
|
-
<p>回傳Promise,resolve回傳結果物件,內含ok(是否成功布林值)、stdout(
|
|
7731
|
+
<p>回傳Promise,resolve回傳結果物件,內含ok(是否成功布林值)、stdout(回覆內容字串)、stderr(失敗時之原始回應本體)、code(HTTP狀態碼,網路錯誤與逾時為null)、error(錯誤訊息字串,成功時為空字串)、errorType(僅失敗時,機器可讀錯誤類別字串,一覽見getErrorType.mjs檔頭)、durationMs(耗時毫秒)、attempts(實際嘗試次數)、usage(原始回應之token用量物件原樣透傳,無則null),本函數不會reject</p>
|
|
6769
7732
|
</div>
|
|
6770
7733
|
|
|
6771
7734
|
|
|
@@ -6792,7 +7755,7 @@ await test()
|
|
|
6792
7755
|
|
|
6793
7756
|
|
|
6794
7757
|
|
|
6795
|
-
<h4 class="name" id="
|
|
7758
|
+
<h4 class="name" id="dispatchApiOpenaiResponses"><span class="type-signature type-signature-async">(async) </span>dispatchApiOpenaiResponses<span class="signature">(prompt, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
|
|
6796
7759
|
|
|
6797
7760
|
|
|
6798
7761
|
|
|
@@ -6802,21 +7765,21 @@ await test()
|
|
|
6802
7765
|
<dl class="details">
|
|
6803
7766
|
|
|
6804
7767
|
<dt class="tag-description">Description:</dt>
|
|
6805
|
-
<dd class="tag-description"><ul class="dummy"><li><p>以fetch直呼OpenAI
|
|
7768
|
+
<dd class="tag-description"><ul class="dummy"><li><p>以fetch直呼OpenAI Responses API(/responses)呼叫AI模型</p>
|
|
6806
7769
|
<p>特點:
|
|
6807
|
-
免安裝CLI、免預先登入,給baseURL+key+model即可呼叫(如OpenCode Zen
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
7770
|
+
免安裝CLI、免預先登入,給baseURL+key+model即可呼叫(如OpenCode Zen之muse-spark系與GPT系);
|
|
7771
|
+
端點型別與dispatchApiOpenaiCompat不同——Zen之端點依模型家族而異,收錄前須查官方文件端點欄
|
|
7772
|
+
(https://opencode.ai/docs/zh-tw/zen/),打錯端點會得到HTTP 500而非404,詳見providers.mjs檔頭;
|
|
7773
|
+
僅供純文字生成,需要工具能力請改用CLI類kind(opencode/claude/codex/antigravity);
|
|
7774
|
+
status非completed(如max_output_tokens耗盡)一律以INCOMPLETE_RESPONSE回報,不回半截內容;
|
|
7775
|
+
結果結構與dispatchApiOpenaiCompat完全一致,可直接作為dispatchAi與dispatchAiFallback之kind('api-openai-responses')使用;
|
|
6813
7776
|
本函數不會reject,一律以結果物件之ok與error欄位回報成敗</p></li></ul></dd>
|
|
6814
7777
|
|
|
6815
7778
|
|
|
6816
7779
|
|
|
6817
7780
|
<dt class="tag-source">Source:</dt>
|
|
6818
7781
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
6819
|
-
<a href="
|
|
7782
|
+
<a href="dispatchApiOpenaiResponses.mjs.html">dispatchApiOpenaiResponses.mjs</a>, <a href="dispatchApiOpenaiResponses.mjs.html#line322">line 322</a>
|
|
6820
7783
|
</li></ul></dd>
|
|
6821
7784
|
|
|
6822
7785
|
|
|
@@ -6865,31 +7828,22 @@ prompt走HTTP body,無命令列長度限制;
|
|
|
6865
7828
|
|
|
6866
7829
|
<pre class="prettyprint"><code>//need network, no cli required
|
|
6867
7830
|
|
|
6868
|
-
import
|
|
7831
|
+
import dispatchApiOpenaiResponses from './src/dispatchApiOpenaiResponses.mjs'
|
|
6869
7832
|
|
|
6870
7833
|
let test = async () => {
|
|
6871
7834
|
|
|
6872
|
-
//OpenCode Zen(
|
|
6873
|
-
let
|
|
7835
|
+
//OpenCode Zen之muse-spark系走/responses(非chat/completions), 詳見providers.mjs檔頭
|
|
7836
|
+
let r = await dispatchApiOpenaiResponses('請只回覆兩個字:完成', {
|
|
6874
7837
|
baseURL: 'https://opencode.ai/zen/v1',
|
|
6875
7838
|
key: 'sk-xxxxxx',
|
|
6876
|
-
model: '
|
|
6877
|
-
})
|
|
6878
|
-
console.log(r1.ok, r1.stdout.trim())
|
|
6879
|
-
// => true 完成
|
|
6880
|
-
|
|
6881
|
-
//Agnes
|
|
6882
|
-
let r2 = await dispatchApiOpenaiCompat('請只回覆兩個字:完成', {
|
|
6883
|
-
baseURL: 'https://apihub.agnes-ai.com/v1',
|
|
6884
|
-
key: 'sk-xxxxxx',
|
|
6885
|
-
model: 'agnes-2.0-flash',
|
|
7839
|
+
model: 'muse-spark-1.3-contributor-free',
|
|
6886
7840
|
})
|
|
6887
|
-
console.log(
|
|
7841
|
+
console.log(r.ok, r.stdout.trim())
|
|
6888
7842
|
// => true 完成
|
|
6889
7843
|
|
|
6890
|
-
let re = await
|
|
6891
|
-
console.log(re.ok, re.code, re.
|
|
6892
|
-
// => false 401
|
|
7844
|
+
let re = await dispatchApiOpenaiResponses('abc', { baseURL: 'https://opencode.ai/zen/v1', key: 'sk-bad', model: 'muse-spark-1.3-contributor-free' })
|
|
7845
|
+
console.log(re.ok, re.code, re.errorType)
|
|
7846
|
+
// => false 401 http
|
|
6893
7847
|
|
|
6894
7848
|
}
|
|
6895
7849
|
await test()
|
|
@@ -6958,7 +7912,7 @@ await test()
|
|
|
6958
7912
|
</td>
|
|
6959
7913
|
|
|
6960
7914
|
|
|
6961
|
-
<td class="description last"><p>輸入提示詞字串,作為
|
|
7915
|
+
<td class="description last"><p>輸入提示詞字串,作為input置於HTTP body</p></td>
|
|
6962
7916
|
</tr>
|
|
6963
7917
|
|
|
6964
7918
|
|
|
@@ -7057,7 +8011,7 @@ await test()
|
|
|
7057
8011
|
</td>
|
|
7058
8012
|
|
|
7059
8013
|
|
|
7060
|
-
<td class="description last"><p>輸入API基底網址字串,例如'https://opencode.ai/zen/v1'
|
|
8014
|
+
<td class="description last"><p>輸入API基底網址字串,例如'https://opencode.ai/zen/v1',將於尾端接上/responses</p></td>
|
|
7061
8015
|
</tr>
|
|
7062
8016
|
|
|
7063
8017
|
|
|
@@ -7093,7 +8047,7 @@ await test()
|
|
|
7093
8047
|
</td>
|
|
7094
8048
|
|
|
7095
8049
|
|
|
7096
|
-
<td class="description last"><p>輸入模型ID字串,例如'
|
|
8050
|
+
<td class="description last"><p>輸入模型ID字串,例如'muse-spark-1.3-contributor-free'</p></td>
|
|
7097
8051
|
</tr>
|
|
7098
8052
|
|
|
7099
8053
|
|
|
@@ -7173,7 +8127,7 @@ await test()
|
|
|
7173
8127
|
</td>
|
|
7174
8128
|
|
|
7175
8129
|
|
|
7176
|
-
<td class="description last"><p>輸入system
|
|
8130
|
+
<td class="description last"><p>輸入system提示詞字串,將置於instructions欄位(Responses API之system管道),預設''代表不帶</p></td>
|
|
7177
8131
|
</tr>
|
|
7178
8132
|
|
|
7179
8133
|
|
|
@@ -7213,7 +8167,7 @@ await test()
|
|
|
7213
8167
|
</td>
|
|
7214
8168
|
|
|
7215
8169
|
|
|
7216
|
-
<td class="description last"><p>輸入額外請求本體物件(如temperature、
|
|
8170
|
+
<td class="description last"><p>輸入額外請求本體物件(如temperature、max_output_tokens、reasoning),將併入預設body(同名鍵以此為準),預設{}。注意輸出上限欄位名為max_output_tokens而非max_tokens;本轉接器不支援工具,帶入tools而模型回function_call時一律以TOOL_CALLS_UNSUPPORTED回報失敗</p></td>
|
|
7217
8171
|
</tr>
|
|
7218
8172
|
|
|
7219
8173
|
|
|
@@ -7447,7 +8401,7 @@ await test()
|
|
|
7447
8401
|
|
|
7448
8402
|
|
|
7449
8403
|
<div class="param-desc">
|
|
7450
|
-
<p>回傳Promise,resolve回傳結果物件,內含ok(是否成功布林值)、stdout(回覆內容字串)、stderr(失敗時之原始回應本體)、code(HTTP狀態碼,網路錯誤與逾時為null)、error(錯誤訊息字串,成功時為空字串)、errorType(僅失敗時,機器可讀錯誤類別字串,一覽見getErrorType.mjs檔頭)、durationMs(耗時毫秒)、attempts(實際嘗試次數)、usage(原始回應之token
|
|
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>
|
|
7451
8405
|
</div>
|
|
7452
8406
|
|
|
7453
8407
|
|
|
@@ -7474,7 +8428,7 @@ await test()
|
|
|
7474
8428
|
|
|
7475
8429
|
|
|
7476
8430
|
|
|
7477
|
-
<h4 class="name" id="
|
|
8431
|
+
<h4 class="name" id="dispatchApiTypesafeSystemone"><span class="type-signature type-signature-async">(async) </span>dispatchApiTypesafeSystemone<span class="signature">(prompt, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
|
|
7478
8432
|
|
|
7479
8433
|
|
|
7480
8434
|
|
|
@@ -7484,21 +8438,21 @@ await test()
|
|
|
7484
8438
|
<dl class="details">
|
|
7485
8439
|
|
|
7486
8440
|
<dt class="tag-description">Description:</dt>
|
|
7487
|
-
<dd class="tag-description"><ul class="dummy"><li><p>以fetch直呼
|
|
8441
|
+
<dd class="tag-description"><ul class="dummy"><li><p>以fetch直呼TypeSafe AI之System One API(POST /v1/systemone),對prompt(即state)回答型別化問題</p>
|
|
7488
8442
|
<p>特點:
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
(
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
8443
|
+
非文字生成——jev等System One模型對state回答呼叫端定義之questions(noul是非題、choice單選題、score量表),
|
|
8444
|
+
每題回傳受限於選項之答案與機率;官方無CLI,僅此API路徑;
|
|
8445
|
+
prompt即state,結構化內容以JSON.stringify(物件)傳入(實測答案與物件state一致);
|
|
8446
|
+
stdout為answers之JSON字串,另於結果追加answers(已解析物件)與modelResolved(實際模型版本);
|
|
8447
|
+
請求之題目id於回應缺任一即以INVALID_RESPONSE回報;
|
|
8448
|
+
不可與文字生成條目混在同一條遞補鏈,經工作流callAi呼叫時須傳promptPrefix:''(理由見檔頭);
|
|
7495
8449
|
本函數不會reject,一律以結果物件之ok與error欄位回報成敗</p></li></ul></dd>
|
|
7496
8450
|
|
|
7497
8451
|
|
|
7498
8452
|
|
|
7499
8453
|
<dt class="tag-source">Source:</dt>
|
|
7500
8454
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
7501
|
-
<a href="
|
|
8455
|
+
<a href="dispatchApiTypesafeSystemone.mjs.html">dispatchApiTypesafeSystemone.mjs</a>, <a href="dispatchApiTypesafeSystemone.mjs.html#line270">line 270</a>
|
|
7502
8456
|
</li></ul></dd>
|
|
7503
8457
|
|
|
7504
8458
|
|
|
@@ -7545,22 +8499,31 @@ status非completed(如max_output_tokens耗盡)一律以INCOMPLETE_RESPONSE回報
|
|
|
7545
8499
|
|
|
7546
8500
|
<h5 class="h5-examples">Example</h5>
|
|
7547
8501
|
|
|
7548
|
-
<pre class="prettyprint"><code>//need network, no cli required
|
|
8502
|
+
<pre class="prettyprint"><code>//need network and a TypeSafe api key, no cli required
|
|
7549
8503
|
|
|
7550
|
-
import
|
|
8504
|
+
import dispatchApiTypesafeSystemone from './src/dispatchApiTypesafeSystemone.mjs'
|
|
7551
8505
|
|
|
7552
8506
|
let test = async () => {
|
|
7553
8507
|
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
8508
|
+
let r = await dispatchApiTypesafeSystemone('房間浴室水龍頭一直滴水,吵到睡不著', {
|
|
8509
|
+
key: 'apikey_xxxxxx',
|
|
8510
|
+
questions: {
|
|
8511
|
+
category: {
|
|
8512
|
+
type: 'choice',
|
|
8513
|
+
instructions: '這則客房訊息屬於哪一類?',
|
|
8514
|
+
criteria: {
|
|
8515
|
+
'設備故障報修': '客人回報房間硬體設備損壞、水電問題或故障',
|
|
8516
|
+
'索取備品': '客人需要毛巾、牙刷、礦泉水等客房備品',
|
|
8517
|
+
'其他': null,
|
|
8518
|
+
},
|
|
8519
|
+
},
|
|
8520
|
+
urgent: { type: 'noul', instructions: '客人是否表達急迫性?' },
|
|
8521
|
+
},
|
|
7559
8522
|
})
|
|
7560
|
-
console.log(r.ok, r.
|
|
7561
|
-
// => true
|
|
8523
|
+
console.log(r.ok, r.answers.category.choice, r.answers.urgent.noul)
|
|
8524
|
+
// => true 設備故障報修 0.86 (2026-09-17實測; noul為機率, 每次可能差0.01)
|
|
7562
8525
|
|
|
7563
|
-
let re = await
|
|
8526
|
+
let re = await dispatchApiTypesafeSystemone('abc', { key: 'apikey_bad', questions: { a: { type: 'noul', instructions: 'x?' } } })
|
|
7564
8527
|
console.log(re.ok, re.code, re.errorType)
|
|
7565
8528
|
// => false 401 http
|
|
7566
8529
|
|
|
@@ -7631,7 +8594,7 @@ await test()
|
|
|
7631
8594
|
</td>
|
|
7632
8595
|
|
|
7633
8596
|
|
|
7634
|
-
<td class="description last"><p
|
|
8597
|
+
<td class="description last"><p>輸入被評估之內容字串,作為state置於HTTP body,結構化內容請先JSON.stringify</p></td>
|
|
7635
8598
|
</tr>
|
|
7636
8599
|
|
|
7637
8600
|
|
|
@@ -7701,13 +8664,13 @@ await test()
|
|
|
7701
8664
|
|
|
7702
8665
|
<tr>
|
|
7703
8666
|
|
|
7704
|
-
<td class="name"><code>
|
|
8667
|
+
<td class="name"><code>questions</code></td>
|
|
7705
8668
|
|
|
7706
8669
|
|
|
7707
8670
|
<td class="type">
|
|
7708
8671
|
|
|
7709
8672
|
|
|
7710
|
-
<span class="param-type">
|
|
8673
|
+
<span class="param-type">Object</span>
|
|
7711
8674
|
|
|
7712
8675
|
|
|
7713
8676
|
|
|
@@ -7730,14 +8693,14 @@ await test()
|
|
|
7730
8693
|
</td>
|
|
7731
8694
|
|
|
7732
8695
|
|
|
7733
|
-
<td class="description last"><p
|
|
8696
|
+
<td class="description last"><p>輸入題目物件(必填且非空),鍵為自訂題目id,值為{type:'noul'|'choice'|'score', instructions, criteria},格式見檔頭與https://docs.typesafe.ai/api</p></td>
|
|
7734
8697
|
</tr>
|
|
7735
8698
|
|
|
7736
8699
|
|
|
7737
8700
|
|
|
7738
8701
|
<tr>
|
|
7739
8702
|
|
|
7740
|
-
<td class="name"><code>
|
|
8703
|
+
<td class="name"><code>baseURL</code></td>
|
|
7741
8704
|
|
|
7742
8705
|
|
|
7743
8706
|
<td class="type">
|
|
@@ -7753,6 +8716,8 @@ await test()
|
|
|
7753
8716
|
|
|
7754
8717
|
<td class="attributes">
|
|
7755
8718
|
|
|
8719
|
+
<optional><br>
|
|
8720
|
+
|
|
7756
8721
|
|
|
7757
8722
|
|
|
7758
8723
|
|
|
@@ -7763,17 +8728,19 @@ await test()
|
|
|
7763
8728
|
|
|
7764
8729
|
<td class="default">
|
|
7765
8730
|
|
|
8731
|
+
<code>'https://api.typesafe.ai/v1'</code>
|
|
8732
|
+
|
|
7766
8733
|
</td>
|
|
7767
8734
|
|
|
7768
8735
|
|
|
7769
|
-
<td class="description last"><p
|
|
8736
|
+
<td class="description last"><p>輸入API基底網址字串,將於尾端接上/systemone,預設官方端點</p></td>
|
|
7770
8737
|
</tr>
|
|
7771
8738
|
|
|
7772
8739
|
|
|
7773
8740
|
|
|
7774
8741
|
<tr>
|
|
7775
8742
|
|
|
7776
|
-
<td class="name"><code>
|
|
8743
|
+
<td class="name"><code>model</code></td>
|
|
7777
8744
|
|
|
7778
8745
|
|
|
7779
8746
|
<td class="type">
|
|
@@ -7801,19 +8768,19 @@ await test()
|
|
|
7801
8768
|
|
|
7802
8769
|
<td class="default">
|
|
7803
8770
|
|
|
7804
|
-
<code>''</code>
|
|
8771
|
+
<code>'jev-latest'</code>
|
|
7805
8772
|
|
|
7806
8773
|
</td>
|
|
7807
8774
|
|
|
7808
8775
|
|
|
7809
|
-
<td class="description last"><p
|
|
8776
|
+
<td class="description last"><p>輸入模型名稱字串,預設'jev-latest'(另有'jev-preview')</p></td>
|
|
7810
8777
|
</tr>
|
|
7811
8778
|
|
|
7812
8779
|
|
|
7813
8780
|
|
|
7814
8781
|
<tr>
|
|
7815
8782
|
|
|
7816
|
-
<td class="name"><code>
|
|
8783
|
+
<td class="name"><code>key</code></td>
|
|
7817
8784
|
|
|
7818
8785
|
|
|
7819
8786
|
<td class="type">
|
|
@@ -7846,7 +8813,7 @@ await test()
|
|
|
7846
8813
|
</td>
|
|
7847
8814
|
|
|
7848
8815
|
|
|
7849
|
-
<td class="description last"><p>輸入
|
|
8816
|
+
<td class="description last"><p>輸入API key字串,以Bearer置於Authorization標頭,預設''代表不帶認證標頭</p></td>
|
|
7850
8817
|
</tr>
|
|
7851
8818
|
|
|
7852
8819
|
|
|
@@ -7886,7 +8853,7 @@ await test()
|
|
|
7886
8853
|
</td>
|
|
7887
8854
|
|
|
7888
8855
|
|
|
7889
|
-
<td class="description last"><p
|
|
8856
|
+
<td class="description last"><p>輸入額外請求本體物件,將併入預設body(同名鍵以此為準),預設{}</p></td>
|
|
7890
8857
|
</tr>
|
|
7891
8858
|
|
|
7892
8859
|
|
|
@@ -7966,7 +8933,7 @@ await test()
|
|
|
7966
8933
|
</td>
|
|
7967
8934
|
|
|
7968
8935
|
|
|
7969
|
-
<td class="description last"><p
|
|
8936
|
+
<td class="description last"><p>輸入逾時毫秒正整數,逾時將中止請求,全套件統一預設300000</p></td>
|
|
7970
8937
|
</tr>
|
|
7971
8938
|
|
|
7972
8939
|
|
|
@@ -8007,7 +8974,7 @@ await test()
|
|
|
8007
8974
|
</td>
|
|
8008
8975
|
|
|
8009
8976
|
|
|
8010
|
-
<td class="description last"><p
|
|
8977
|
+
<td class="description last"><p>輸入stdout(answers之JSON字串)驗證規則字串或自訂驗證函數,規則字串支援'nonempty'、'json'、'min:100',多規則可用逗號串接,預設undefined代表不驗證</p></td>
|
|
8011
8978
|
</tr>
|
|
8012
8979
|
|
|
8013
8980
|
|
|
@@ -8120,7 +9087,7 @@ await test()
|
|
|
8120
9087
|
|
|
8121
9088
|
|
|
8122
9089
|
<div class="param-desc">
|
|
8123
|
-
<p>回傳Promise,resolve回傳結果物件,內含ok(是否成功布林值)、stdout(
|
|
9090
|
+
<p>回傳Promise,resolve回傳結果物件,內含ok(是否成功布林值)、stdout(answers之JSON字串)、stderr(失敗時之原始回應本體)、code(HTTP狀態碼,網路錯誤與逾時為null)、error(錯誤訊息字串,成功時為空字串)、errorType(僅失敗時,機器可讀錯誤類別字串,一覽見getErrorType.mjs檔頭)、durationMs(耗時毫秒)、attempts(實際嘗試次數)、usage(原始回應之token用量物件原樣透傳,欄位名為input_tokens/output_tokens,無則null)、answers(成功時為已解析之答案物件,否則null)、modelResolved(回應所載之實際模型版本字串,如'jev-1.13.0',無則''),本函數不會reject</p>
|
|
8124
9091
|
</div>
|
|
8125
9092
|
|
|
8126
9093
|
|
|
@@ -12769,7 +13736,7 @@ console.log(getErrorResult(null).error)
|
|
|
12769
13736
|
|
|
12770
13737
|
<dt class="tag-source">Source:</dt>
|
|
12771
13738
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
12772
|
-
<a href="getErrorType.mjs.html">getErrorType.mjs</a>, <a href="getErrorType.mjs.html#
|
|
13739
|
+
<a href="getErrorType.mjs.html">getErrorType.mjs</a>, <a href="getErrorType.mjs.html#line56">line 56</a>
|
|
12773
13740
|
</li></ul></dd>
|
|
12774
13741
|
|
|
12775
13742
|
|
|
@@ -20411,7 +21378,7 @@ console.log(w.label, w.remainingPercent)
|
|
|
20411
21378
|
<br class="clear">
|
|
20412
21379
|
|
|
20413
21380
|
<footer>
|
|
20414
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
21381
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Thu Sep 17 2026 13:48:00 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
20415
21382
|
</footer>
|
|
20416
21383
|
|
|
20417
21384
|
<script>prettyPrint();</script>
|