import type { HttpClient } from '../http.js'; import { type DecisionAction } from '../decisions/action.js'; import { type DecisionGrantSet } from '../decisions/verify.js'; /** The issuer's record that decision grants were consumed for one action. */ export interface ConsumedDecision { requestId: string; jtis: string[]; actionHash: string; approvers: Record[]; } /** * Consumes decision grants atomically at their issuer. `enforce()` passes the * caller's grant token, which it verified (`grantToken`), and the agent DID * and grant it carries (`agentDid`, `grantId`); an issuer that binds decision * grants to the requesting agent establishes the agent from that token and * refuses a decision requested for another agent or grant (`wrong_agent`). */ export interface DecisionConsumer { consume(grants: DecisionGrantSet, options?: ConsumeDecisionParams): Promise; } export interface CreateDecisionRequestParams { action: DecisionAction; connector: string; caseVersion: string; /** The manifest's `four_eyes_on`; two approvals are required when it lists the decision. */ /** The memo the approver reviews (text). Stored with its hash and bound into the grant. */ memo: { content: string; ref?: string; }; /** The policy score the approver reviews (a JSON object). Stored with its hash and bound into the grant. */ policyScore: { content: Record; ref?: string; }; fourEyesOn?: string[]; approvalsRequired?: 1 | 2; expiresInSeconds?: number; /** * The Grantex agent id (`ag_...`) of the agent the decision is for. With the * binding on, only that agent's grant token can fetch the grants, and they * are consumed only for that agent. */ agentId?: string; /** The grant the decision is for; with the binding on, consumed only under that grant. */ grantId?: string; } export interface ConsumeDecisionParams { /** * The DID of the agent the call is made for, from its verified grant token * (what `enforce()` passes). Sent as `agentDid`, which an auth service that * does not bind decision grants to the requesting agent ignores, so it is * safe to send to any version. */ agentDid?: string; /** The Grantex agent id (`ag_...`) of the agent the call is made for, when the platform knows it. */ agentId?: string; /** The grant the call is made under, from the same token. */ grantId?: string; /** * The grant token of the agent the call is made for (what `enforce()` * passes, after verifying it). Sent as `grantToken`: an auth service that * binds decision grants to the requesting agent verifies it and takes the * agent and grant from it, never from `agentDid`, `agentId` or `grantId`, * which must then match it; the grants of a decision requested for an agent * are consumed only with that agent's live grant token. An auth service * with the binding off, or from before it, ignores the member. */ grantToken?: string; } export declare class DecisionsClient { #private; constructor(http: HttpClient); /** Register the case's current version; unconsumed grants for other versions are revoked. */ setCaseVersion(caseId: string, caseVersion: string): Promise>; /** Ask a person to decide one semantic action. Idempotent while the request is open. */ createRequest(params: CreateDecisionRequestParams): Promise>; /** * Status and approvals (by `jti`). With the binding on, also * `decisionGrantsReady` and never the decision grants themselves: use * `getGrants` with the requesting agent's grant token. With it off, also * `decisionGrants` once fully approved and still usable. */ getRequest(requestId: string): Promise>; /** * The request with `decisionGrantsReady`, plus `decisionGrants` once fully * approved and still usable. Released only for a request that names an * agent, and only against a live grant token of that agent and grant: * anything else is refused with `wrong_agent`. Every hand-out and refusal is * recorded in the audit chain. */ getGrants(requestId: string, grantToken: string): Promise>; cancelRequest(requestId: string): Promise>; /** * Consume decision grants atomically at the auth service. Pass a verified * `DecisionGrantSet`, or the tokens with the action and case version. * Throws `DecisionGrantError` with the issuer's sub-reason when refused and * `consume_unavailable` when the issuer cannot be reached or answers * unexpectedly: an unconfirmed consumption is never treated as success. * * Consumption spends the grants. If the response is lost after the auth * service consumed them, or the tool call fails afterwards, they stay spent * and a person has to approve again. */ consume(grants: DecisionGrantSet | readonly string[], options?: ConsumeDecisionParams & { action?: DecisionAction; caseVersion?: string; }): Promise; /** * Consume the grants of a decision request that names no agent, by its id: * the platform that asked for the decision spends it without ever holding * the tokens. A request that names an agent is refused (`wrong_agent`); its * grants are consumed only as that agent presents them. Errors and the * no-retry rule are as for `consume`. */ consumeRequest(requestId: string, options: { action: DecisionAction; caseVersion: string; }): Promise; } //# sourceMappingURL=decisions.d.ts.map