@astrosheep/pi-quota 0.5.5 → 0.5.6

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
@@ -36,7 +36,7 @@ Add bindings in global `~/.pi/agent/settings.json` under `quotaUsage` (not proje
36
36
  }
37
37
  ```
38
38
 
39
- Use the **exact Pi provider ID**. Built-in providers and explicitly bound providers are queried; explicit bindings replace a built-in adapter with the same ID. Unknown keys or adapter options are rejected. The API key and model `baseUrl` come from Pi's active provider auth; do not put model API keys in `quotaUsage`.
39
+ Use the **exact Pi provider ID**. Built-in providers and explicitly bound providers are queried; explicit bindings replace a built-in adapter with the same ID. Unknown keys or adapter options are rejected. The API key comes from Pi's provider auth, and the endpoint comes from the provider's registered model; do not put model API keys in `quotaUsage`.
40
40
 
41
41
  | Adapter | Endpoint | Result |
42
42
  |---|---|---|
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrosheep/pi-quota",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/extension.ts CHANGED
@@ -85,8 +85,11 @@ export function createQuotaExtension(options: QuotaExtensionOptions = {}) {
85
85
  if (typeof value === 'string') headers[name] = value;
86
86
  }
87
87
  const auth: ProviderAuth = { ...resolved.auth, headers };
88
- // A model-level custom endpoint must not be mistaken for an official account.
89
- if (ctx.model?.provider === provider && ctx.model.baseUrl) auth.baseUrl = ctx.model.baseUrl;
88
+ // Provider auth often has no endpoint. /usage also queries providers other
89
+ // than the selected model, so resolve their configured model URL as well.
90
+ const model = ctx.model?.provider === provider ? ctx.model
91
+ : ctx.modelRegistry.getAll().find(model => model.provider === provider);
92
+ if (model?.baseUrl) auth.baseUrl = model.baseUrl;
90
93
  return auth;
91
94
  };
92
95