@agent-custody/receipts 0.6.19 → 0.8.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.
Files changed (50) hide show
  1. package/README.md +20 -11
  2. package/dist/a2a.js +19 -7
  3. package/dist/approval.d.ts +74 -0
  4. package/dist/approval.js +196 -0
  5. package/dist/capture.d.ts +153 -0
  6. package/dist/capture.js +607 -0
  7. package/dist/cli.js +221 -6
  8. package/dist/config.d.ts +144 -0
  9. package/dist/config.js +92 -3
  10. package/dist/crypto.d.ts +2 -2
  11. package/dist/crypto.js +7 -4
  12. package/dist/delegation.d.ts +7 -0
  13. package/dist/delegation.js +15 -1
  14. package/dist/gateway-http.js +13 -1
  15. package/dist/gateway.d.ts +15 -0
  16. package/dist/gateway.js +414 -27
  17. package/dist/index.d.ts +4 -0
  18. package/dist/index.js +4 -0
  19. package/dist/issue.d.ts +20 -5
  20. package/dist/issue.js +76 -8
  21. package/dist/log-sink.d.ts +11 -1
  22. package/dist/log-sink.js +24 -5
  23. package/dist/operations.d.ts +101 -0
  24. package/dist/operations.js +239 -0
  25. package/dist/otel.js +16 -8
  26. package/dist/portal.d.ts +23 -2
  27. package/dist/portal.js +181 -36
  28. package/dist/receipt.d.ts +54 -8
  29. package/dist/rest.js +14 -1
  30. package/dist/retention.d.ts +8 -1
  31. package/dist/retention.js +21 -2
  32. package/dist/sdk/index.js +10 -1
  33. package/dist/simulate.d.ts +58 -0
  34. package/dist/simulate.js +204 -0
  35. package/dist/splunk.js +17 -8
  36. package/dist/upstream.d.ts +9 -7
  37. package/dist/upstream.js +16 -8
  38. package/dist/verify.d.ts +18 -0
  39. package/dist/verify.js +405 -15
  40. package/docs/approvals.md +107 -0
  41. package/docs/compliance.md +1 -1
  42. package/docs/financial-operations.md +99 -0
  43. package/docs/policies.md +22 -0
  44. package/docs/tutorials.md +7 -0
  45. package/docs/usage.md +71 -5
  46. package/docs/verification.md +35 -10
  47. package/package.json +1 -1
  48. package/vectors/audit.json +27 -27
  49. package/vectors/canonical.json +5 -5
  50. package/vectors/receipts.json +3612 -292
package/dist/config.js CHANGED
@@ -2,12 +2,16 @@ import { z } from "zod";
2
2
  import { readFileSync } from "node:fs";
3
3
  import { dirname, resolve } from "node:path";
4
4
  /** Where receipts are logged: a local file, or a log reached over HTTP whose bearer token comes from an environment variable. */
5
- const LogSchema = z.object({ url: z.string().url(), tokenEnv: z.string().min(1).optional(), /** send leaf hashes only; the log never holds the receipt. Use it for any log run by someone else */ hashOnly: z.boolean().optional(), /** milliseconds one append may take before the log counts as unreachable; default 10000 */ timeoutMs: z.number().int().positive().optional() });
5
+ const LogSchema = z.object({ url: z.string().url(), tokenEnv: z.string().min(1).optional(), /** send leaf hashes only; the log never holds the receipt. Use it for any log run by someone else */ hashOnly: z.boolean().optional(), /** milliseconds one append may take before the log counts as unreachable; default 10000 */ timeoutMs: z.number().int().positive().optional(), /** the log's public key files; every append's answer is checked against them before a call is forwarded. Without them the log's key document is fetched from the log itself on first use and pinned, which catches a log that turns dishonest later but not one dishonest from the start; required with precommit. */ keys: z.array(z.string().min(1)).optional(), /** the id the log must write into every tree head; an answer for another log is refused */ logId: z.string().min(1).optional() });
6
6
  const oneLog = { message: "exactly one of logFile or log is required" };
7
7
  /** Optional OpenTelemetry export: every receipt also becomes a span at this OTLP/HTTP collector, after it is issued. Never on the evidence path. */
8
8
  const OtelSchema = z.object({ url: z.string().url(), headersEnv: z.record(z.string(), z.string().min(1)).optional(), serviceName: z.string().min(1).optional() });
9
9
  const SplunkSchema = z.object({ url: z.string().url(), tokenEnv: z.string().min(1), index: z.string().min(1).optional(), source: z.string().min(1).optional(), sourcetype: z.string().min(1).optional(), host: z.string().min(1).optional() });
10
10
  const hasOneLog = (c) => (c.logFile ? 1 : 0) + (c.log ? 1 : 0) === 1;
11
+ /** What a receipt carries of one side of a call: everything, commitments only, or commitments with the value encrypted under the customer's key; `clear` names the top-level fields kept in clear either way. */
12
+ const CaptureSideSchema = z.object({ mode: z.enum(["clear", "digest", "encrypted"]), clear: z.array(z.string().min(1)).optional() });
13
+ /** Per tool (or "*"): how the arguments, the result, and the facts are captured. Digests and signatures are always over the whole call. */
14
+ const CaptureSchema = z.record(z.string().min(1), z.object({ args: CaptureSideSchema.optional(), result: CaptureSideSchema.optional(), facts: CaptureSideSchema.optional() }));
11
15
  /** One REST endpoint offered to the agent as a tool. `{name}` segments in the path come from the call's arguments; the rest go to the query on GET and DELETE, or to a JSON body otherwise. */
12
16
  const RestToolSchema = z.object({
13
17
  name: z.string().min(1),
@@ -18,6 +22,8 @@ const RestToolSchema = z.object({
18
22
  query: z.array(z.string().min(1)).optional(),
19
23
  /** "none" sends no body even on POST */
20
24
  body: z.enum(["json", "none"]).default("json"),
25
+ /** The gateway supplies its durable operation key in this header; callers cannot choose or override it. */
26
+ idempotencyHeader: z.string().regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/).optional(),
21
27
  /** the JSON Schema the agent sees; default accepts any object */
22
28
  inputSchema: z.record(z.string(), z.unknown()).default({ type: "object" }),
23
29
  });
@@ -60,6 +66,67 @@ const FactSchema = z.object({
60
66
  /** when true and a "$args.<key>" the template needs is absent from the call, the lookup is skipped and the fact is simply not present */
61
67
  optional: z.boolean().default(false),
62
68
  });
69
+ /** Signed human approvals are independent of Cedar: an approving artifact binds the whole call and is used once. */
70
+ const ApprovalsSchema = z.object({
71
+ trustedKeys: z.array(z.string().min(1)).min(1),
72
+ usedDir: z.string().min(1),
73
+ /** The longest lifetime (expiresAt minus issuedAt) that the gateway accepts. The signer chooses the expiry, and this caps it. Default: 3600. */
74
+ maxLifetimeSeconds: z.number().int().positive().optional(),
75
+ tools: z.array(z.object({
76
+ tool: z.string().min(1),
77
+ minApprovers: z.union([z.literal(1), z.literal(2)]).default(1),
78
+ /** Argument names carrying these values; omitted names default to amount, currency, and beneficiary. */
79
+ fields: z.object({ amount: z.string().min(1).optional(), currency: z.string().min(1).optional(), beneficiary: z.string().min(1).optional() }).optional(),
80
+ })).min(1).refine((tools) => new Set(tools.map((t) => t.tool)).size === tools.length, { message: "approval tool names must be unique" }),
81
+ });
82
+ /** Amounts and limits are integer minor units; one budget is shared by every principal and agent on this database. */
83
+ const OperationBudgetSchema = z.object({ id: z.string().min(1).max(128), currency: z.string().regex(/^[A-Z]{3}$/), limit: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER) });
84
+ const OperationReconcileSchema = z.object({
85
+ tool: z.string().min(1),
86
+ /** Only the gateway-derived idempotency key may be substituted. The agent's operation id never reaches a receipt, and reconciliation never takes new caller arguments. */
87
+ args: z.record(z.string(), z.string()).refine((args) => Object.values(args).every((v) => !v.startsWith("$") || v === "$operation.idempotencyKey"), { message: "reconciliation templates only support $operation.idempotencyKey" }),
88
+ statusPath: z.string().min(1).max(512).refine((path) => path.split(".").every((part) => part.length > 0), { message: "reconciliation statusPath must have nonempty dot-separated parts" }),
89
+ /** The provider record must echo this operation's idempotency key before it may close the reservation. */
90
+ identityPath: z.string().min(1).max(512).refine((path) => path.split(".").every((part) => part.length > 0), { message: "reconciliation identityPath must have nonempty dot-separated parts" }).default("idempotencyKey"),
91
+ confirmed: z.array(z.string().min(1).max(128)).min(1),
92
+ failed: z.array(z.string().min(1).max(128)).min(1),
93
+ pending: z.array(z.string().min(1)).default([]),
94
+ }).refine((r) => {
95
+ const statuses = [...r.confirmed, ...r.failed, ...(r.pending ?? [])];
96
+ return new Set(statuses).size === statuses.length;
97
+ }, { message: "reconciliation statuses must be distinct" });
98
+ const OperationToolSchema = z.object({
99
+ tool: z.string().min(1),
100
+ budget: z.string().min(1),
101
+ amountField: z.string().min(1).default("amount"),
102
+ currencyField: z.string().min(1).default("currency"),
103
+ idempotencyHeader: z.string().regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/).default("Idempotency-Key"),
104
+ reconcile: OperationReconcileSchema,
105
+ });
106
+ const OperationsSchema = z.object({
107
+ database: z.string().min(1),
108
+ budgets: z.array(OperationBudgetSchema).min(1),
109
+ tools: z.array(OperationToolSchema).min(1),
110
+ }).superRefine((operations, ctx) => {
111
+ const budgets = new Set();
112
+ for (const [i, budget] of operations.budgets.entries()) {
113
+ if (budgets.has(budget.id))
114
+ ctx.addIssue({ code: "custom", path: ["budgets", i, "id"], message: "duplicate operation budget" });
115
+ budgets.add(budget.id);
116
+ }
117
+ const tools = new Set();
118
+ for (const [i, tool] of operations.tools.entries()) {
119
+ if (tools.has(tool.tool))
120
+ ctx.addIssue({ code: "custom", path: ["tools", i, "tool"], message: "duplicate financial operation tool" });
121
+ tools.add(tool.tool);
122
+ if (!budgets.has(tool.budget))
123
+ ctx.addIssue({ code: "custom", path: ["tools", i, "budget"], message: "unknown operation budget" });
124
+ }
125
+ for (const [i, tool] of operations.tools.entries()) {
126
+ if (tools.has(tool.reconcile.tool))
127
+ ctx.addIssue({ code: "custom", path: ["tools", i, "reconcile", "tool"], message: "a reconciliation read cannot be a financial operation tool" });
128
+ }
129
+ });
63
130
  export const GatewayConfigSchema = z.object({
64
131
  identity: z.object({ keyFile: z.string() }),
65
132
  /** the upstream: an MCP server to spawn over stdio, an MCP URL to reach over Streamable HTTP with an optional bearer token from the environment, or a REST API described as tools */
@@ -76,8 +143,18 @@ export const GatewayConfigSchema = z.object({
76
143
  * authorization to the log and refuses the call if the log will not take it. Evidence then precedes the side effect.
77
144
  */
78
145
  precommit: z.array(z.string().min(1)).default([]),
146
+ /** Tools that require a signed, unexpired, single-use approval, in every mode; "*" covers all agent calls. */
147
+ approvals: ApprovalsSchema.optional(),
148
+ /** Durable idempotency, daily budget reservations, and provider reconciliation for financial operations. */
149
+ operations: OperationsSchema.optional(),
150
+ /** a JSON file listing digests of revoked grant envelopes (`agent-custody revoke` appends to it); re-read whenever it changes, checked on every call */
151
+ revokedGrants: z.string().min(1).optional(),
152
+ /** private evidence: what the receipt file carries of each tool's arguments, result, and facts */
153
+ capture: CaptureSchema.optional(),
154
+ /** the environment variable holding the 32-byte key (hex or base64) that encrypts withheld fields in mode encrypted; read at startup, never in the file */
155
+ captureKeyEnv: z.string().min(1).optional(),
79
156
  /**
80
- * "enforce" (the default when absent) denies what the policy denies. "observe" forwards every call the grant allows and records the
157
+ * "enforce" (the default when absent) denies what the policy denies. "observe" forwards every call the grant and required human approval allow and records the
81
158
  * decision the policy would have made, with `enforced: false` on the receipt: the way to run a new policy against
82
159
  * real traffic before turning it on. A log that refuses a consequential call's authorization does not withhold the
83
160
  * call in observe mode; it is printed.
@@ -88,7 +165,11 @@ export const GatewayConfigSchema = z.object({
88
165
  log: LogSchema.optional(),
89
166
  otel: OtelSchema.optional(),
90
167
  splunk: SplunkSchema.optional(),
91
- }).refine(hasOneLog, oneLog).refine((c) => (c.upstream ? 1 : 0) + (c.upstreams ? 1 : 0) === 1, { message: "exactly one of upstream or upstreams is required" });
168
+ }).refine(hasOneLog, oneLog).refine((c) => (c.upstream ? 1 : 0) + (c.upstreams ? 1 : 0) === 1, { message: "exactly one of upstream or upstreams is required" })
169
+ // a key fetched from the log itself proves nothing about a log that is dishonest from the start, so a remote log that
170
+ // gates consequential calls must have its keys pinned in the config (issue #99)
171
+ .refine((c) => !c.log || (!c.precommit.length && !c.operations) || !!c.log.keys?.length, { message: "precommit with a remote log needs log.keys: the log's public key files, pinned, to check its answer before a consequential call is forwarded" })
172
+ .refine((c) => !c.operations || !c.facts.some((fact) => c.operations.tools.some((tool) => tool.tool === fact.tool)), { message: "a fact lookup cannot invoke a financial operation tool" });
92
173
  /** Loads a config file and resolves every path relative to the file's directory. */
93
174
  export function loadConfig(path) {
94
175
  const cfg = GatewayConfigSchema.parse(JSON.parse(readFileSync(path, "utf8")));
@@ -102,6 +183,10 @@ export function loadConfig(path) {
102
183
  policyFile: r(cfg.policyFile),
103
184
  receiptsDir: r(cfg.receiptsDir),
104
185
  ...(cfg.logFile ? { logFile: r(cfg.logFile) } : {}),
186
+ ...(cfg.log?.keys ? { log: { ...cfg.log, keys: cfg.log.keys.map(r) } } : {}),
187
+ ...(cfg.revokedGrants ? { revokedGrants: r(cfg.revokedGrants) } : {}),
188
+ ...(cfg.approvals ? { approvals: { ...cfg.approvals, trustedKeys: cfg.approvals.trustedKeys.map(r), usedDir: r(cfg.approvals.usedDir) } } : {}),
189
+ ...(cfg.operations ? { operations: { ...cfg.operations, database: r(cfg.operations.database) } } : {}),
105
190
  };
106
191
  }
107
192
  export const SdkConfigSchema = z.object({
@@ -120,6 +205,9 @@ export const SdkConfigSchema = z.object({
120
205
  splunk: SplunkSchema.optional(),
121
206
  /** free-text label of the host framework, e.g. "claude-code", "openai-agents" */
122
207
  framework: z.string().optional(),
208
+ /** private evidence, as for the gateway */
209
+ capture: CaptureSchema.optional(),
210
+ captureKeyEnv: z.string().min(1).optional(),
123
211
  }).refine(hasOneLog, oneLog);
124
212
  export function loadSdkConfig(path) {
125
213
  const cfg = SdkConfigSchema.parse(JSON.parse(readFileSync(path, "utf8")));
@@ -131,5 +219,6 @@ export function loadSdkConfig(path) {
131
219
  ...(cfg.policyFile ? { policyFile: r(cfg.policyFile) } : {}),
132
220
  receiptsDir: r(cfg.receiptsDir),
133
221
  ...(cfg.logFile ? { logFile: r(cfg.logFile) } : {}),
222
+ ...(cfg.log?.keys ? { log: { ...cfg.log, keys: cfg.log.keys.map(r) } } : {}),
134
223
  };
135
224
  }
package/dist/crypto.d.ts CHANGED
@@ -2,8 +2,8 @@ import type { KeyObject } from "node:crypto";
2
2
  /** Deterministic JSON: sorted keys, no whitespace, undefined dropped. Not full RFC 8785, but stable across runs. */
3
3
  export declare function canonicalize(value: unknown): string;
4
4
  export declare function sha256Hex(data: string | Uint8Array): string;
5
- /** sha256 over the canonical JSON of a value. */
6
- export declare function digestOf(value: unknown): string;
5
+ /** sha256 over the canonical JSON of a value; with a salt (hex), over salt || canonical, so a digest over withheld values confirms no guess (issue #126). */
6
+ export declare function digestOf(value: unknown, salt?: string): string;
7
7
  export interface PublicKeyRef {
8
8
  publicKey: KeyObject;
9
9
  keyid: string;
package/dist/crypto.js CHANGED
@@ -10,7 +10,9 @@ function sortKeys(v) {
10
10
  if (Array.isArray(v))
11
11
  return v.map(sortKeys);
12
12
  if (v && typeof v === "object") {
13
- const out = {};
13
+ // A null-prototype object: an own property named __proto__ (which JSON.parse produces) stays a property here,
14
+ // where on a plain object the assignment would set the prototype and the key would vanish from the digest.
15
+ const out = Object.create(null);
14
16
  for (const k of Object.keys(v).sort()) {
15
17
  const x = v[k];
16
18
  if (x !== undefined)
@@ -23,9 +25,10 @@ function sortKeys(v) {
23
25
  export function sha256Hex(data) {
24
26
  return createHash("sha256").update(data).digest("hex");
25
27
  }
26
- /** sha256 over the canonical JSON of a value. */
27
- export function digestOf(value) {
28
- return sha256Hex(canonicalize(value));
28
+ /** sha256 over the canonical JSON of a value; with a salt (hex), over salt || canonical, so a digest over withheld values confirms no guess (issue #126). */
29
+ export function digestOf(value, salt) {
30
+ const canonical = Buffer.from(canonicalize(value), "utf8");
31
+ return sha256Hex(salt ? Buffer.concat([Buffer.from(salt, "hex"), canonical]) : canonical);
29
32
  }
30
33
  /** keyid = sha256 of the SPKI DER encoding of the public key. */
31
34
  export function keyidOf(publicKey) {
@@ -54,6 +54,13 @@ export type DelegationVerifyResult = {
54
54
  /** Verifies a grant, walking its chain to a grant signed by one of the trusted principal keys. */
55
55
  export declare function verifyDelegation(env: Envelope, trustedPrincipals: PublicKeyRef[], depth?: number): DelegationVerifyResult;
56
56
  /** True when `at` (ISO) lies inside the grant's validity window. */
57
+ /**
58
+ * What names a grant for revocation: sha256 over the payload its signature covers. Extra signatures or envelope fields
59
+ * leave it unchanged, so an agent cannot get a revoked grant past the list by repacking the envelope.
60
+ */
61
+ export declare function grantDigest(env: Envelope): string;
62
+ /** The digest of every link from this grant up to the principal's own, leaf first: revoking any link revokes the grants below it. */
63
+ export declare function grantChainDigests(env: Envelope): string[];
57
64
  export declare function delegationValidAt(d: Delegation, at: string): boolean;
58
65
  /** "principal → agent → sub-agent", for reports. */
59
66
  export declare function describeChain(chain: Delegation[]): string;
@@ -6,7 +6,7 @@
6
6
  // parent's, and the principal is the same throughout. The receipt then names the sub-agent as the agent and the
7
7
  // principal as the principal, exactly as with a direct grant, and the whole chain travels inside the receipt.
8
8
  import { z } from "zod";
9
- import { dsseSign, dsseVerify, publicKeyFromPem } from "./crypto.js";
9
+ import { dsseSign, dsseVerify, publicKeyFromPem, sha256Hex } from "./crypto.js";
10
10
  export const DELEGATION_TYPE = "application/vnd.agent-custody.delegation+json";
11
11
  /** the longest chain a verifier walks: the principal's grant and up to three delegations below it */
12
12
  export const MAX_DELEGATION_DEPTH = 4;
@@ -115,6 +115,20 @@ export function verifyDelegation(env, trustedPrincipals, depth = 1) {
115
115
  return { ok: true, delegation: d, keyid: up.keyid, chain: [...up.chain, d] };
116
116
  }
117
117
  /** True when `at` (ISO) lies inside the grant's validity window. */
118
+ /**
119
+ * What names a grant for revocation: sha256 over the payload its signature covers. Extra signatures or envelope fields
120
+ * leave it unchanged, so an agent cannot get a revoked grant past the list by repacking the envelope.
121
+ */
122
+ export function grantDigest(env) {
123
+ return sha256Hex(Buffer.from(env.payload, "base64"));
124
+ }
125
+ /** The digest of every link from this grant up to the principal's own, leaf first: revoking any link revokes the grants below it. */
126
+ export function grantChainDigests(env) {
127
+ const out = [];
128
+ for (let e = env; e && out.length <= MAX_DELEGATION_DEPTH; e = decodeDelegation(e)?.parent)
129
+ out.push(grantDigest(e));
130
+ return out;
131
+ }
118
132
  export function delegationValidAt(d, at) {
119
133
  const t = Date.parse(at);
120
134
  return t >= Date.parse(d.issuedAt) && t <= Date.parse(d.expiresAt);
@@ -96,6 +96,12 @@ export async function serveHttp(host, opts) {
96
96
  const sid = req.headers["mcp-session-id"];
97
97
  const existing = typeof sid === "string" ? sessions.get(sid) : undefined;
98
98
  if (existing) {
99
+ // the grant is checked again on every request of a session; an expired or revoked one ends the session here
100
+ const problem = existing.gateway.grantProblem();
101
+ if (problem) {
102
+ await closeSession(sid, `grant ${problem}`);
103
+ return rpcError(res, 403, `the grant for this session ${problem}; initialize again with a current grant`);
104
+ }
99
105
  existing.lastSeen = Date.now();
100
106
  const body = req.method === "POST" ? await readBody(req) : undefined;
101
107
  await existing.transport.handleRequest(req, res, body);
@@ -118,9 +124,15 @@ export async function serveHttp(host, opts) {
118
124
  const server = createServer((req, res) => void handler(req, res));
119
125
  const reaper = setInterval(() => {
120
126
  const cutoff = Date.now() - idleMs;
121
- for (const [id, s] of sessions)
127
+ for (const [id, s] of sessions) {
122
128
  if (s.lastSeen < cutoff)
123
129
  void closeSession(id, "idle");
130
+ else {
131
+ const problem = s.gateway.grantProblem();
132
+ if (problem)
133
+ void closeSession(id, `grant ${problem}`);
134
+ }
135
+ }
124
136
  }, Math.min(idleMs, 60_000));
125
137
  reaper.unref?.();
126
138
  await new Promise((resolve) => server.listen(opts.port, bind, resolve));
package/dist/gateway.d.ts CHANGED
@@ -4,9 +4,12 @@ import { type Envelope } from "./crypto.ts";
4
4
  import { type Delegation } from "./delegation.ts";
5
5
  import { type LogSink } from "./log-sink.ts";
6
6
  import { type ReceiptExporter } from "./otel.ts";
7
+ import type { ReceiptBundle } from "./receipt.ts";
7
8
  export declare const GATEWAY_VERSION = "0.1.0";
8
9
  export declare const RECEIPT_META_KEY = "agent-custody/receipt";
9
10
  export declare const MODEL_META_KEY = "agent-custody/model";
11
+ /** Set by the gateway on the answer to a retry of a financial operation: the receipt of the retry itself. `agent-custody/receipt` stays the receipt that holds the operation's outcome. */
12
+ export declare const RETRY_RECEIPT_META_KEY = "agent-custody/retry-receipt";
10
13
  /** Set by the gateway on the call it forwards upstream: the receipt id, and the agent and principal from the attested grant. */
11
14
  export declare const AGENT_META_KEY = "agent-custody/agent";
12
15
  export declare const PRINCIPAL_META_KEY = "agent-custody/principal";
@@ -22,6 +25,10 @@ export interface CallParams {
22
25
  export interface Gateway {
23
26
  agentId: string;
24
27
  delegation: Delegation;
28
+ /** sha256 over the grant's signed payload (`grantDigest` in delegation.ts): what `revoke` names */
29
+ grantDigest: string;
30
+ /** null while the grant is in force at `at` (default now); otherwise why it is not: "has expired", "is not yet valid", "has been revoked" */
31
+ grantProblem(at?: string): string | null;
25
32
  listTools(): Promise<Tool[]>;
26
33
  handleCall(params: CallParams): Promise<CallToolResult>;
27
34
  close(): Promise<void>;
@@ -46,9 +53,17 @@ export interface GatewayHost {
46
53
  keyid: string;
47
54
  /** a session for this grant: the grant is verified against the trusted principal keys and its validity window first */
48
55
  open(grantEnvelope: Envelope): Gateway;
56
+ /** revokes a grant by its digest: every session under it refuses its next call, and no new session opens for it. Written to the config's revokedGrants file when there is one. */
57
+ revoke(grantDigest: string): void;
58
+ /** the digests revoked so far */
59
+ revoked(): string[];
60
+ /** Operator-only provider lookup. Never exposed as an agent tool. Unknown/pending reservations remain held until a terminal reconciliation receipt is committed. */
61
+ reconcile(operationId: string): Promise<ReceiptBundle>;
49
62
  /** closes the upstreams; every session opened from this host is finished with */
50
63
  close(): Promise<void>;
51
64
  }
65
+ /** Writes the revocation list whole, by rename, so a gateway re-reading it never sees half a file. */
66
+ export declare function writeRevokedGrants(path: string, digests: string[]): void;
52
67
  export declare function createGatewayHost(cfg: GatewayConfig, options?: GatewayOptions): Promise<GatewayHost>;
53
68
  /** One gateway for the grant the config names: what `agent-custody gateway` serves over stdio. Closing it closes the host. */
54
69
  export declare function createGateway(cfg: GatewayConfig, options?: GatewayOptions): Promise<Gateway>;