@lumoauth/agent 1.3.0 → 1.4.1
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 +2 -1
- package/dist/index.d.mts +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -357,6 +357,22 @@ var LumoAgent = class {
|
|
|
357
357
|
async budget() {
|
|
358
358
|
return this.agents.budget();
|
|
359
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Report the model tokens and cost that the agent just used, for example
|
|
362
|
+
* the `usage` that the model provider returned. LumoAuth does not see
|
|
363
|
+
* model calls, so token and cost limits count only reported usage. The
|
|
364
|
+
* result's `budget.exhausted` says whether the next metered call (Ask,
|
|
365
|
+
* token or JIT request) will get 429.
|
|
366
|
+
*
|
|
367
|
+
* ```ts
|
|
368
|
+
* const resp = await llm.chat(...);
|
|
369
|
+
* const { budget } = await agent.reportUsage({ tokens: resp.usage.total_tokens, costUsd: 0.0042 });
|
|
370
|
+
* if (budget.exhausted) throw new Error('budget spent');
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
async reportUsage(report) {
|
|
374
|
+
return this.agents.reportUsage(report);
|
|
375
|
+
}
|
|
360
376
|
// ── Internal ──────────────────────────────────────────────────────
|
|
361
377
|
requireOrgId() {
|
|
362
378
|
if (!this.orgId) {
|