@lumoauth/agent 1.3.0 → 1.4.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 +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/README.md
CHANGED
|
@@ -231,13 +231,14 @@ consent steps. The token types and the `resource` option are explained in the
|
|
|
231
231
|
| `getCurrentAgent()` | `Promise<AgentIdentity>` | The agent's identity, capabilities and workspace |
|
|
232
232
|
| `capabilities()` | `Promise<string[]>` | The agent's capabilities |
|
|
233
233
|
| `budget()` | `Promise<AgentBudget>` | The agent's budget policy, or `{}` when none is set |
|
|
234
|
+
| `reportUsage({ tokens, costUsd })` | `Promise<UsageReportResult>` | Report model tokens and cost; token and cost limits count only reported usage |
|
|
234
235
|
| `baseUrl`, `orgId`, `clientId` | `string` | The resolved configuration |
|
|
235
236
|
|
|
236
237
|
### Namespaces
|
|
237
238
|
|
|
238
239
|
| Namespace | What it does | Methods |
|
|
239
240
|
|---|---|---|
|
|
240
|
-
| `agents` | Agent identity | `ask`, `isAllowed`, `me`, `getCurrentAgent`, `capabilities`, `budget`, `register`, `authorizeMcpTool(serverId, tool)` |
|
|
241
|
+
| `agents` | Agent identity | `ask`, `isAllowed`, `me`, `getCurrentAgent`, `capabilities`, `budget`, `reportUsage`, `register`, `authorizeMcpTool(serverId, tool)` |
|
|
241
242
|
| `approvals` | Push approval for agent actions | `require`, `create`, `getStatus`, `wait` |
|
|
242
243
|
| `jit` | Just-in-time permissions | `createTask`, `requestPermission`, `getRequestStatus`, `getToken`, `evaluateTask`, `completeTask`. `listPendingRequests` is the human reviewer's view. It needs a user token with `jit:approve`, so the server rejects an agent's own token |
|
|
243
244
|
| `delegation` | Act for a user, or hand work to a sub-agent, with RFC 8693 token exchange | `getConsentUrl`, `handleConsentCallback`, `setUserToken`, `exchange`, `request`, `delegateToSubAgent`, `revoke`, `revokeAll`, `hasDelegation`, `activeSessions` |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AgentsModule, JitModule, DelegationModule, ApprovalsModule, McpModule, DpopProofProvider, AgentAskResult, AgentMcpToolDecision, AgentIdentity, AgentBudget, DpopProofRequest, LumoAuthError } from '@lumoauth/shared';
|
|
2
|
-
export { AgentMcpToolDecision, ApprovalNotDeliveredReason, ApprovalRequestResult, ApprovalResult, CreateApprovalRequest, DPOP_NONCE_HEADER, DPOP_SCHEME, DpopHeadersInput, DpopProofProvider, DpopProofRequest, FetchWithDpopOptions, LumoAuthApiError, LumoAuthApprovalDeniedError, LumoAuthApprovalNotDeliveredError, LumoAuthApprovalTimeoutError, LumoAuthAuthenticationError, LumoAuthBudgetExceededError, LumoAuthConfigError, LumoAuthError, LumoAuthNetworkError, LumoAuthNotFoundError, LumoAuthPermissionDeniedError, LumoAuthRateLimitError, LumoAuthValidationError, McpAuthorizeToolOptions, McpSubject, McpSubjectType, McpToolDecision, McpToolResource, RequireApprovalRequest, USE_DPOP_NONCE, buildDpopHeaders, dpopHtu, fetchWithDpop } from '@lumoauth/shared';
|
|
1
|
+
import { AgentsModule, JitModule, DelegationModule, ApprovalsModule, McpModule, DpopProofProvider, AgentAskResult, AgentMcpToolDecision, AgentIdentity, AgentBudget, UsageReport, UsageReportResult, DpopProofRequest, LumoAuthError } from '@lumoauth/shared';
|
|
2
|
+
export { AgentBudget, AgentMcpToolDecision, ApprovalNotDeliveredReason, ApprovalRequestResult, ApprovalResult, CreateApprovalRequest, DPOP_NONCE_HEADER, DPOP_SCHEME, DpopHeadersInput, DpopProofProvider, DpopProofRequest, FetchWithDpopOptions, LumoAuthApiError, LumoAuthApprovalDeniedError, LumoAuthApprovalNotDeliveredError, LumoAuthApprovalTimeoutError, LumoAuthAuthenticationError, LumoAuthBudgetExceededError, LumoAuthConfigError, LumoAuthError, LumoAuthNetworkError, LumoAuthNotFoundError, LumoAuthPermissionDeniedError, LumoAuthRateLimitError, LumoAuthValidationError, McpAuthorizeToolOptions, McpSubject, McpSubjectType, McpToolDecision, McpToolResource, RequireApprovalRequest, USE_DPOP_NONCE, UsageReport, UsageReportResult, buildDpopHeaders, dpopHtu, fetchWithDpop } from '@lumoauth/shared';
|
|
3
3
|
import { KeyObject } from 'node:crypto';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -233,6 +233,20 @@ declare class LumoAgent {
|
|
|
233
233
|
capabilities(): Promise<string[]>;
|
|
234
234
|
/** The agent's budget policy (empty object when no policy is set). */
|
|
235
235
|
budget(): Promise<AgentBudget>;
|
|
236
|
+
/**
|
|
237
|
+
* Report the model tokens and cost that the agent just used, for example
|
|
238
|
+
* the `usage` that the model provider returned. LumoAuth does not see
|
|
239
|
+
* model calls, so token and cost limits count only reported usage. The
|
|
240
|
+
* result's `budget.exhausted` says whether the next metered call (Ask,
|
|
241
|
+
* token or JIT request) will get 429.
|
|
242
|
+
*
|
|
243
|
+
* ```ts
|
|
244
|
+
* const resp = await llm.chat(...);
|
|
245
|
+
* const { budget } = await agent.reportUsage({ tokens: resp.usage.total_tokens, costUsd: 0.0042 });
|
|
246
|
+
* if (budget.exhausted) throw new Error('budget spent');
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
reportUsage(report: UsageReport): Promise<UsageReportResult>;
|
|
236
250
|
private requireOrgId;
|
|
237
251
|
}
|
|
238
252
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AgentsModule, JitModule, DelegationModule, ApprovalsModule, McpModule, DpopProofProvider, AgentAskResult, AgentMcpToolDecision, AgentIdentity, AgentBudget, DpopProofRequest, LumoAuthError } from '@lumoauth/shared';
|
|
2
|
-
export { AgentMcpToolDecision, ApprovalNotDeliveredReason, ApprovalRequestResult, ApprovalResult, CreateApprovalRequest, DPOP_NONCE_HEADER, DPOP_SCHEME, DpopHeadersInput, DpopProofProvider, DpopProofRequest, FetchWithDpopOptions, LumoAuthApiError, LumoAuthApprovalDeniedError, LumoAuthApprovalNotDeliveredError, LumoAuthApprovalTimeoutError, LumoAuthAuthenticationError, LumoAuthBudgetExceededError, LumoAuthConfigError, LumoAuthError, LumoAuthNetworkError, LumoAuthNotFoundError, LumoAuthPermissionDeniedError, LumoAuthRateLimitError, LumoAuthValidationError, McpAuthorizeToolOptions, McpSubject, McpSubjectType, McpToolDecision, McpToolResource, RequireApprovalRequest, USE_DPOP_NONCE, buildDpopHeaders, dpopHtu, fetchWithDpop } from '@lumoauth/shared';
|
|
1
|
+
import { AgentsModule, JitModule, DelegationModule, ApprovalsModule, McpModule, DpopProofProvider, AgentAskResult, AgentMcpToolDecision, AgentIdentity, AgentBudget, UsageReport, UsageReportResult, DpopProofRequest, LumoAuthError } from '@lumoauth/shared';
|
|
2
|
+
export { AgentBudget, AgentMcpToolDecision, ApprovalNotDeliveredReason, ApprovalRequestResult, ApprovalResult, CreateApprovalRequest, DPOP_NONCE_HEADER, DPOP_SCHEME, DpopHeadersInput, DpopProofProvider, DpopProofRequest, FetchWithDpopOptions, LumoAuthApiError, LumoAuthApprovalDeniedError, LumoAuthApprovalNotDeliveredError, LumoAuthApprovalTimeoutError, LumoAuthAuthenticationError, LumoAuthBudgetExceededError, LumoAuthConfigError, LumoAuthError, LumoAuthNetworkError, LumoAuthNotFoundError, LumoAuthPermissionDeniedError, LumoAuthRateLimitError, LumoAuthValidationError, McpAuthorizeToolOptions, McpSubject, McpSubjectType, McpToolDecision, McpToolResource, RequireApprovalRequest, USE_DPOP_NONCE, UsageReport, UsageReportResult, buildDpopHeaders, dpopHtu, fetchWithDpop } from '@lumoauth/shared';
|
|
3
3
|
import { KeyObject } from 'node:crypto';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -233,6 +233,20 @@ declare class LumoAgent {
|
|
|
233
233
|
capabilities(): Promise<string[]>;
|
|
234
234
|
/** The agent's budget policy (empty object when no policy is set). */
|
|
235
235
|
budget(): Promise<AgentBudget>;
|
|
236
|
+
/**
|
|
237
|
+
* Report the model tokens and cost that the agent just used, for example
|
|
238
|
+
* the `usage` that the model provider returned. LumoAuth does not see
|
|
239
|
+
* model calls, so token and cost limits count only reported usage. The
|
|
240
|
+
* result's `budget.exhausted` says whether the next metered call (Ask,
|
|
241
|
+
* token or JIT request) will get 429.
|
|
242
|
+
*
|
|
243
|
+
* ```ts
|
|
244
|
+
* const resp = await llm.chat(...);
|
|
245
|
+
* const { budget } = await agent.reportUsage({ tokens: resp.usage.total_tokens, costUsd: 0.0042 });
|
|
246
|
+
* if (budget.exhausted) throw new Error('budget spent');
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
reportUsage(report: UsageReport): Promise<UsageReportResult>;
|
|
236
250
|
private requireOrgId;
|
|
237
251
|
}
|
|
238
252
|
|
package/dist/index.js
CHANGED
|
@@ -413,6 +413,22 @@ var LumoAgent = class {
|
|
|
413
413
|
async budget() {
|
|
414
414
|
return this.agents.budget();
|
|
415
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* Report the model tokens and cost that the agent just used, for example
|
|
418
|
+
* the `usage` that the model provider returned. LumoAuth does not see
|
|
419
|
+
* model calls, so token and cost limits count only reported usage. The
|
|
420
|
+
* result's `budget.exhausted` says whether the next metered call (Ask,
|
|
421
|
+
* token or JIT request) will get 429.
|
|
422
|
+
*
|
|
423
|
+
* ```ts
|
|
424
|
+
* const resp = await llm.chat(...);
|
|
425
|
+
* const { budget } = await agent.reportUsage({ tokens: resp.usage.total_tokens, costUsd: 0.0042 });
|
|
426
|
+
* if (budget.exhausted) throw new Error('budget spent');
|
|
427
|
+
* ```
|
|
428
|
+
*/
|
|
429
|
+
async reportUsage(report) {
|
|
430
|
+
return this.agents.reportUsage(report);
|
|
431
|
+
}
|
|
416
432
|
// ── Internal ──────────────────────────────────────────────────────
|
|
417
433
|
requireOrgId() {
|
|
418
434
|
if (!this.orgId) {
|