w-dispatch-ai 1.0.23 → 1.0.25

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 (49) hide show
  1. package/README.md +1 -1
  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 +1 -1
  5. package/docs/adapters.mjs.html +1 -1
  6. package/docs/budgetFor.mjs.html +1 -1
  7. package/docs/buildValidator.mjs.html +1 -1
  8. package/docs/castPintOr.mjs.html +1 -1
  9. package/docs/dfTimeoutMs.mjs.html +1 -1
  10. package/docs/dispatchAi.mjs.html +1 -1
  11. package/docs/dispatchAiFallback.mjs.html +1 -1
  12. package/docs/dispatchAiWkf.mjs.html +1 -1
  13. package/docs/dispatchAntigravity.mjs.html +1 -1
  14. package/docs/dispatchApiOpenaiCompat.mjs.html +1 -1
  15. package/docs/dispatchApiOpenaiResponses.mjs.html +1 -1
  16. package/docs/dispatchClaude.mjs.html +1 -1
  17. package/docs/dispatchCodex.mjs.html +1 -1
  18. package/docs/dispatchOpencode.mjs.html +1 -1
  19. package/docs/getCliArgs.mjs.html +1 -1
  20. package/docs/getErrorResult.mjs.html +1 -1
  21. package/docs/getErrorType.mjs.html +1 -1
  22. package/docs/global.html +3 -42
  23. package/docs/index.html +1 -1
  24. package/docs/quota_dfQuotaTimeoutMs.mjs.html +1 -1
  25. package/docs/quota_fetchQuotaJson.mjs.html +1 -1
  26. package/docs/quota_fromCodexUsageHttp.mjs.html +1 -1
  27. package/docs/quota_getQuotaAntigravity.mjs.html +1 -1
  28. package/docs/quota_getQuotaClaude.mjs.html +1 -1
  29. package/docs/quota_getQuotaCodex.mjs.html +1 -1
  30. package/docs/quota_readJsonOrNull.mjs.html +1 -1
  31. package/docs/quota_toQuotaLabel.mjs.html +1 -1
  32. package/docs/quota_toQuotaResult.mjs.html +1 -1
  33. package/docs/quota_toQuotaScopedLabel.mjs.html +1 -1
  34. package/docs/quota_toQuotaWindow.mjs.html +1 -1
  35. package/docs/readEnvFile.mjs.html +61 -61
  36. package/docs/resolveProviders.mjs.html +182 -182
  37. package/docs/wkf_callAiWithFallback.mjs.html +1 -1
  38. package/docs/wkf_createFileStore.mjs.html +1 -1
  39. package/docs/wkf_createUsageCounter.mjs.html +1 -1
  40. package/docs/wkf_extractJsonLoose.mjs.html +1 -1
  41. package/docs/wkf_noSideEffectPrefix.mjs.html +1 -1
  42. package/docs/wkf_runFanout.mjs.html +1 -1
  43. package/docs/wkf_runFanoutPipeline.mjs.html +1 -1
  44. package/docs/wkf_runRolePipeline.mjs.html +1 -1
  45. package/docs/wkf_salvageTruncatedArray.mjs.html +1 -1
  46. package/package.json +4 -9
  47. package/src/providers.mjs +305 -303
  48. package/src/readEnvFile.mjs +60 -60
  49. package/src/resolveProviders.mjs +181 -181
@@ -130,7 +130,7 @@ export default WDispatchAi
130
130
  <br class="clear">
131
131
 
132
132
  <footer>
133
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
133
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
134
134
  </footer>
135
135
 
136
136
  <script>prettyPrint();</script>
@@ -127,7 +127,7 @@ export default adapters
127
127
  <br class="clear">
128
128
 
129
129
  <footer>
130
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
130
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
131
131
  </footer>
132
132
 
133
133
  <script>prettyPrint();</script>
@@ -111,7 +111,7 @@ export default budgetFor
111
111
  <br class="clear">
112
112
 
113
113
  <footer>
114
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
114
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
115
115
  </footer>
116
116
 
117
117
  <script>prettyPrint();</script>
@@ -153,7 +153,7 @@ export default buildValidator
153
153
  <br class="clear">
154
154
 
155
155
  <footer>
156
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
156
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
157
157
  </footer>
158
158
 
159
159
  <script>prettyPrint();</script>
@@ -96,7 +96,7 @@ export default castPintOr
96
96
  <br class="clear">
97
97
 
98
98
  <footer>
99
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
99
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
100
100
  </footer>
101
101
 
102
102
  <script>prettyPrint();</script>
@@ -85,7 +85,7 @@ export default dfTimeoutMs
85
85
  <br class="clear">
86
86
 
87
87
  <footer>
88
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
88
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
89
89
  </footer>
90
90
 
91
91
  <script>prettyPrint();</script>
@@ -121,7 +121,7 @@ export default dispatchAi
121
121
  <br class="clear">
122
122
 
123
123
  <footer>
124
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
124
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
125
125
  </footer>
126
126
 
127
127
  <script>prettyPrint();</script>
@@ -556,7 +556,7 @@ export default dispatchAiFallback
556
556
  <br class="clear">
557
557
 
558
558
  <footer>
559
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
559
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
560
560
  </footer>
561
561
 
562
562
  <script>prettyPrint();</script>
@@ -193,7 +193,7 @@ export default dispatchAiWkf
193
193
  <br class="clear">
194
194
 
195
195
  <footer>
196
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
196
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
197
197
  </footer>
198
198
 
199
199
  <script>prettyPrint();</script>
@@ -258,7 +258,7 @@ export default dispatchAntigravity
258
258
  <br class="clear">
259
259
 
260
260
  <footer>
261
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
261
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
262
262
  </footer>
263
263
 
264
264
  <script>prettyPrint();</script>
@@ -426,7 +426,7 @@ export default dispatchApiOpenaiCompat
426
426
  <br class="clear">
427
427
 
428
428
  <footer>
429
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
429
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
430
430
  </footer>
431
431
 
432
432
  <script>prettyPrint();</script>
@@ -485,7 +485,7 @@ export { extractOutputText }
485
485
  <br class="clear">
486
486
 
487
487
  <footer>
488
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
488
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
489
489
  </footer>
490
490
 
491
491
  <script>prettyPrint();</script>
@@ -185,7 +185,7 @@ export default dispatchClaude
185
185
  <br class="clear">
186
186
 
187
187
  <footer>
188
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
188
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
189
189
  </footer>
190
190
 
191
191
  <script>prettyPrint();</script>
@@ -196,7 +196,7 @@ export default dispatchCodex
196
196
  <br class="clear">
197
197
 
198
198
  <footer>
199
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
199
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
200
200
  </footer>
201
201
 
202
202
  <script>prettyPrint();</script>
@@ -255,7 +255,7 @@ export default dispatchOpencode
255
255
  <br class="clear">
256
256
 
257
257
  <footer>
258
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
258
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
259
259
  </footer>
260
260
 
261
261
  <script>prettyPrint();</script>
@@ -113,7 +113,7 @@ export default getCliArgs
113
113
  <br class="clear">
114
114
 
115
115
  <footer>
116
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
116
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
117
117
  </footer>
118
118
 
119
119
  <script>prettyPrint();</script>
@@ -109,7 +109,7 @@ export default getErrorResult
109
109
  <br class="clear">
110
110
 
111
111
  <footer>
112
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
112
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
113
113
  </footer>
114
114
 
115
115
  <script>prettyPrint();</script>
@@ -160,7 +160,7 @@ export { attachErrorType }
160
160
  <br class="clear">
161
161
 
162
162
  <footer>
163
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
163
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
164
164
  </footer>
165
165
 
166
166
  <script>prettyPrint();</script>
package/docs/global.html CHANGED
@@ -15399,13 +15399,7 @@ value修剪空白並剝除成對之首尾引號(單雙引號皆可);
15399
15399
 
15400
15400
  <h5 class="h5-examples">Example</h5>
15401
15401
 
15402
- <pre class="prettyprint"><code>import readEnvFile from './src/readEnvFile.mjs'
15403
- import resolveProviders from './src/resolveProviders.mjs'
15404
- import providersAll from './src/providers.mjs'
15405
-
15406
- //金鑰放.env(變數值以逗號分隔多把), 讀成物件交resolveProviders, 不污染process.env
15407
- let env = readEnvFile('./.env')
15408
- let { providers, skipped } = resolveProviders(providersAll, { env, pick: ['agnes:agnes-2.5-flash'] })</code></pre>
15402
+ <pre class="prettyprint"><code>import readEnvFile from './src/readEnvFile.mjs'
15409
15403
 
15410
15404
 
15411
15405
 
@@ -16167,40 +16161,7 @@ providers與table同源產出故必然一致;
16167
16161
 
16168
16162
  <h5 class="h5-examples">Example</h5>
16169
16163
 
16170
- <pre class="prettyprint"><code>import resolveProviders from './src/resolveProviders.mjs'
16171
- import readEnvFile from './src/readEnvFile.mjs'
16172
- import providersAll from './src/providers.mjs'
16173
-
16174
- //金鑰放.env(變數值以逗號分隔多把), 以readEnvFile讀成物件, 不污染process.env
16175
- let env = readEnvFile('./.env')
16176
-
16177
- //全取: envVar展開為keys, 缺環境變數者列入skipped
16178
- let { providers, table, skipped } = resolveProviders(providersAll, { env })
16179
- console.log(providers.length, skipped)
16180
- // => 17 []
16181
-
16182
- //pick打錯字時, missing附拼寫提示hints(最接近之可用id)
16183
- let rm = resolveProviders(providersAll, { env, pick: ['poolside/laguna-s-2.1'] })
16184
- console.log(rm.missing, rm.hints)
16185
- // => [ 'poolside/laguna-s-2.1' ] { 'poolside/laguna-s-2.1': 'poolside:laguna-s-2.1' }
16186
-
16187
- //自選: 依pick順序回傳(順序即遞補優先序), 可直接餵dispatchAiFallback
16188
- let r2 = resolveProviders(providersAll, { env, pick: ['agnes:agnes-2.5-flash', 'claude:sonnet'] })
16189
- console.log(r2.providers.map((p) => p.id))
16190
- // => [ 'agnes:agnes-2.5-flash', 'claude:sonnet' ]
16191
-
16192
- //後處理: exes逐kind注入執行檔、patch逐id覆寫欄位, 陣列與table同步生效
16193
- let r3 = resolveProviders(providersAll, {
16194
- env,
16195
- pick: ['agnes:agnes-2.5-flash', 'claude:sonnet'],
16196
- exes: { claude: 'C:/Users/x/.local/bin/claude.exe' },
16197
- patch: { 'claude:sonnet': { timeoutMs: 360000 } },
16198
- })
16199
- console.log(r3.table['claude:sonnet'].exe, r3.table['claude:sonnet'].timeoutMs)
16200
- // => 'C:/Users/x/.local/bin/claude.exe' 360000
16201
-
16202
- //table可直接餵dispatchAiWkf之providers定義表
16203
- //let wkf = dispatchAiWkf({ providers: r2.table, defaults: { timeoutMs: 1200000 } })</code></pre>
16164
+ <pre class="prettyprint"><code>import resolveProviders from './src/resolveProviders.mjs'
16204
16165
  env,
16205
16166
  pick: ['agnes:agnes-3.0-flash', 'claude:sonnet'],
16206
16167
  exes: { claude: 'C:/Users/x/.local/bin/claude.exe' },
16207
16168
  patch: { 'claude:sonnet': { timeoutMs: 360000 } },
16208
16169
 
16209
16170
 
16210
16171
 
@@ -20450,7 +20411,7 @@ console.log(w.label, w.remainingPercent)
20450
20411
  <br class="clear">
20451
20412
 
20452
20413
  <footer>
20453
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
20414
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
20454
20415
  </footer>
20455
20416
 
20456
20417
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -71,7 +71,7 @@
71
71
  <br class="clear">
72
72
 
73
73
  <footer>
74
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
74
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
75
75
  </footer>
76
76
 
77
77
  <script>prettyPrint();</script>
@@ -86,7 +86,7 @@ export default dfQuotaTimeoutMs
86
86
  <br class="clear">
87
87
 
88
88
  <footer>
89
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
89
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
90
90
  </footer>
91
91
 
92
92
  <script>prettyPrint();</script>
@@ -335,7 +335,7 @@ export default fetchQuotaJson
335
335
  <br class="clear">
336
336
 
337
337
  <footer>
338
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
338
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
339
339
  </footer>
340
340
 
341
341
  <script>prettyPrint();</script>
@@ -322,7 +322,7 @@ export default fromCodexUsageHttp
322
322
  <br class="clear">
323
323
 
324
324
  <footer>
325
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
325
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
326
326
  </footer>
327
327
 
328
328
  <script>prettyPrint();</script>
@@ -450,7 +450,7 @@ export default getQuotaAntigravity
450
450
  <br class="clear">
451
451
 
452
452
  <footer>
453
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
453
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
454
454
  </footer>
455
455
 
456
456
  <script>prettyPrint();</script>
@@ -444,7 +444,7 @@ export default getQuotaClaude
444
444
  <br class="clear">
445
445
 
446
446
  <footer>
447
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
447
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
448
448
  </footer>
449
449
 
450
450
  <script>prettyPrint();</script>
@@ -502,7 +502,7 @@ export default getQuotaCodex
502
502
  <br class="clear">
503
503
 
504
504
  <footer>
505
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
505
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
506
506
  </footer>
507
507
 
508
508
  <script>prettyPrint();</script>
@@ -100,7 +100,7 @@ export default readJsonOrNull
100
100
  <br class="clear">
101
101
 
102
102
  <footer>
103
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
103
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
104
104
  </footer>
105
105
 
106
106
  <script>prettyPrint();</script>
@@ -133,7 +133,7 @@ export default toQuotaLabel
133
133
  <br class="clear">
134
134
 
135
135
  <footer>
136
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
136
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
137
137
  </footer>
138
138
 
139
139
  <script>prettyPrint();</script>
@@ -201,7 +201,7 @@ export default toQuotaResult
201
201
  <br class="clear">
202
202
 
203
203
  <footer>
204
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
204
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
205
205
  </footer>
206
206
 
207
207
  <script>prettyPrint();</script>
@@ -104,7 +104,7 @@ export default toQuotaScopedLabel
104
104
  <br class="clear">
105
105
 
106
106
  <footer>
107
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
107
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
108
108
  </footer>
109
109
 
110
110
  <script>prettyPrint();</script>
@@ -226,7 +226,7 @@ export default toQuotaWindow
226
226
  <br class="clear">
227
227
 
228
228
  <footer>
229
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
229
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
230
230
  </footer>
231
231
 
232
232
  <script>prettyPrint();</script>
@@ -45,66 +45,66 @@
45
45
 
46
46
  <section>
47
47
  <article>
48
- <pre class="prettyprint source linenums"><code>import fs from 'fs'
49
-
50
-
51
- // readEnvFile.mjs — 讀.env為金鑰來源物件(不污染process.env)
52
- //
53
- // 【為何需要】resolveProviders之opt.env本為「不用process.env」而設計——多專案並行時
54
- // 污染全域環境變數會互相覆蓋金鑰——但「env物件從哪來」套件原無答案, README舊教法
55
- // process.loadEnvFile('./.env')反而把金鑰塞進process.env, 與該設計目的自相矛盾。
56
- // 兩個消費端專案已各寫一份解析器且行為不一致(2026-08-18使用端調研), 收斂於此。
57
- //
58
- // 【為何讀不到回空物件而非拋錯】金鑰缺失由resolveProviders之skipped機制回報
59
- // (缺金鑰停用該條目、不中斷), 此處拋錯反而讓「部分供應商無金鑰」升級成整體啟動失敗;
60
- // 要fail-loud的呼叫端自行檢查回傳(如Object.keys(env).length)。
61
- //
62
- // 【只解析KEY=value最簡格式】不引入dotenv: 金鑰為單行純文字, 僅剝除成對之首尾引號,
63
- // 不做跳脫與多行處理——加解析規則只會製造與其他.env工具的行為差異。
64
-
65
-
66
- /**
67
- * 讀取.env檔為鍵值物件(金鑰來源, 不寫入process.env)
68
- *
69
- * 特點:
70
- * 只解析`KEY=value`形式(KEY限英數底線),忽略空行、註解與無效行;
71
- * value修剪空白並剝除成對之首尾引號(單雙引號皆可);
72
- * 檔案不存在或不可讀一律回空物件不throw(金鑰缺失交由resolveProviders之skipped回報)
73
- *
74
- * @param {String} file 輸入.env檔案路徑字串
75
- * @returns {Object} 回傳鍵值物件(變數名 → 字串值),讀取失敗回空物件
76
- * @example
77
- *
78
- * import readEnvFile from './src/readEnvFile.mjs'
79
- * import resolveProviders from './src/resolveProviders.mjs'
80
- * import providersAll from './src/providers.mjs'
81
- *
82
- * //金鑰放.env(變數值以逗號分隔多把), 讀成物件交resolveProviders, 不污染process.env
83
- * let env = readEnvFile('./.env')
84
- * let { providers, skipped } = resolveProviders(providersAll, { env, pick: ['agnes:agnes-2.5-flash'] })
85
- *
86
- */
87
- function readEnvFile(file) {
88
- let out = {}
89
- let text = ''
90
- try {
91
- text = fs.readFileSync(file, 'utf8')
92
- }
93
- catch (e) {
94
- return out //檔案不存在或不可讀, 回空由skipped機制回報
95
- }
96
- for (let line of text.split(/\r?\n/)) {
97
- let m = line.match(/^\s*([A-Za-z0-9_]+)\s*=\s*(.*)$/)
98
- if (!m) {
99
- continue
100
- }
101
- out[m[1]] = m[2].trim().replace(/^(["'])(.*)\1$/, '$2')
102
- }
103
- return out
104
- }
105
-
106
-
107
- export default readEnvFile
48
+ <pre class="prettyprint source linenums"><code>import fs from 'fs'
49
+
50
+
51
+ // readEnvFile.mjs — 讀.env為金鑰來源物件(不污染process.env)
52
+ //
53
+ // 【為何需要】resolveProviders之opt.env本為「不用process.env」而設計——多專案並行時
54
+ // 污染全域環境變數會互相覆蓋金鑰——但「env物件從哪來」套件原無答案, README舊教法
55
+ // process.loadEnvFile('./.env')反而把金鑰塞進process.env, 與該設計目的自相矛盾。
56
+ // 兩個消費端專案已各寫一份解析器且行為不一致(2026-08-18使用端調研), 收斂於此。
57
+ //
58
+ // 【為何讀不到回空物件而非拋錯】金鑰缺失由resolveProviders之skipped機制回報
59
+ // (缺金鑰停用該條目、不中斷), 此處拋錯反而讓「部分供應商無金鑰」升級成整體啟動失敗;
60
+ // 要fail-loud的呼叫端自行檢查回傳(如Object.keys(env).length)。
61
+ //
62
+ // 【只解析KEY=value最簡格式】不引入dotenv: 金鑰為單行純文字, 僅剝除成對之首尾引號,
63
+ // 不做跳脫與多行處理——加解析規則只會製造與其他.env工具的行為差異。
64
+
65
+
66
+ /**
67
+ * 讀取.env檔為鍵值物件(金鑰來源, 不寫入process.env)
68
+ *
69
+ * 特點:
70
+ * 只解析`KEY=value`形式(KEY限英數底線),忽略空行、註解與無效行;
71
+ * value修剪空白並剝除成對之首尾引號(單雙引號皆可);
72
+ * 檔案不存在或不可讀一律回空物件不throw(金鑰缺失交由resolveProviders之skipped回報)
73
+ *
74
+ * @param {String} file 輸入.env檔案路徑字串
75
+ * @returns {Object} 回傳鍵值物件(變數名 → 字串值),讀取失敗回空物件
76
+ * @example
77
+ *
78
+ * import readEnvFile from './src/readEnvFile.mjs'
79
+ * import resolveProviders from './src/resolveProviders.mjs'
80
+ * import providersAll from './src/providers.mjs'
81
+ *
82
+ * //金鑰放.env(變數值以逗號分隔多把), 讀成物件交resolveProviders, 不污染process.env
83
+ * let env = readEnvFile('./.env')
84
+ * let { providers, skipped } = resolveProviders(providersAll, { env, pick: ['agnes:agnes-3.0-flash'] })
85
+ *
86
+ */
87
+ function readEnvFile(file) {
88
+ let out = {}
89
+ let text = ''
90
+ try {
91
+ text = fs.readFileSync(file, 'utf8')
92
+ }
93
+ catch (e) {
94
+ return out //檔案不存在或不可讀, 回空由skipped機制回報
95
+ }
96
+ for (let line of text.split(/\r?\n/)) {
97
+ let m = line.match(/^\s*([A-Za-z0-9_]+)\s*=\s*(.*)$/)
98
+ if (!m) {
99
+ continue
100
+ }
101
+ out[m[1]] = m[2].trim().replace(/^(["'])(.*)\1$/, '$2')
102
+ }
103
+ return out
104
+ }
105
+
106
+
107
+ export default readEnvFile
108
108
  </code></pre>
109
109
  </article>
110
110
  </section>
@@ -119,7 +119,7 @@ export default readEnvFile
119
119
  <br class="clear">
120
120
 
121
121
  <footer>
122
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Sep 05 2026 22:03:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
122
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Sep 14 2026 12:59:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
123
123
  </footer>
124
124
 
125
125
  <script>prettyPrint();</script>