@brglng/pi-currency-cost 0.2.0 → 0.3.0

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 CHANGED
@@ -28,7 +28,7 @@ and in `models.json`.
28
28
  "currencies": {
29
29
  "CNY": { "usdRate": 0.147 }
30
30
  },
31
- "currencyExchangeRateSource": { "type": "frankfurter" }
31
+ "exchangeRateSource": { "type": "frankfurter" }
32
32
  }
33
33
  }
34
34
  ```
@@ -36,6 +36,9 @@ and in `models.json`.
36
36
  Valid rates and rate-source settings here take precedence over the merged
37
37
  legacy configuration.
38
38
 
39
+ Upgrading from 0.2.0: rename `currencyExchangeRateSource` to
40
+ `exchangeRateSource` in `settings.json`. The old key is ignored.
41
+
39
42
  ### Provider and model currencies in Pi's models.json
40
43
 
41
44
  Declare `currency` beside the provider or model definition in Pi's global
package/README.zh.md CHANGED
@@ -26,13 +26,16 @@ pi install npm:@brglng/pi-currency-cost
26
26
  "currencies": {
27
27
  "CNY": { "usdRate": 0.147 }
28
28
  },
29
- "currencyExchangeRateSource": { "type": "frankfurter" }
29
+ "exchangeRateSource": { "type": "frankfurter" }
30
30
  }
31
31
  }
32
32
  ```
33
33
 
34
34
  此处有效的汇率及汇率来源设置优先于合并后的旧版配置。
35
35
 
36
+ 从 0.2.0 升级时,请在 `settings.json` 中将 `currencyExchangeRateSource`
37
+ 改为 `exchangeRateSource`。扩展会忽略旧键。
38
+
36
39
  ### 在 Pi 的 models.json 中声明 Provider 和模型的币种
37
40
 
38
41
  在 Pi 的全局 `<agentDir>/models.json` 中,将 `currency` 写在对应的 Provider
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brglng/pi-currency-cost",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Convert configured provider/model usage costs to USD for Pi sessions",
5
5
  "type": "module",
6
6
  "exports": {
package/src/config.ts CHANGED
@@ -499,12 +499,12 @@ export async function loadConfigWithSources(agentDir: string, cwd: string) {
499
499
  );
500
500
  }
501
501
 
502
- const source = settings.currencyExchangeRateSource;
502
+ const source = settings.exchangeRateSource;
503
503
  if (isRecord(source)) {
504
504
  const type = source.type;
505
505
  if (type !== undefined && type !== "boc" && type !== "frankfurter") {
506
506
  inlineWarnings.push(
507
- 'settings.json: currencyExchangeRateSource.type must be "boc" or "frankfurter"; keeping previous',
507
+ 'settings.json: exchangeRateSource.type must be "boc" or "frankfurter"; keeping previous',
508
508
  );
509
509
  }
510
510
  config.rateSource = {
@@ -516,14 +516,14 @@ export async function loadConfigWithSources(agentDir: string, cwd: string) {
516
516
  source,
517
517
  config.rateSource.timeoutMs,
518
518
  inlineWarnings,
519
- "settings.json: currencyExchangeRateSource",
519
+ "settings.json: exchangeRateSource",
520
520
  ),
521
521
  };
522
522
  } else if (source === "boc" || source === "frankfurter") {
523
523
  config.rateSource = { ...config.rateSource, type: source };
524
524
  } else if (source !== undefined) {
525
525
  inlineWarnings.push(
526
- "settings.json: invalid currencyExchangeRateSource; keeping previous",
526
+ "settings.json: invalid exchangeRateSource; keeping previous",
527
527
  );
528
528
  }
529
529
  } else if (settings !== undefined) {