@agent-custody/receipts 0.16.5 → 0.16.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 +7 -4
- package/dist/cli.js +50 -7
- package/dist/console-page.js +144 -50
- package/dist/deny-report.d.ts +7 -0
- package/dist/deny-report.js +8 -3
- package/dist/design.d.ts +11 -0
- package/dist/design.js +91 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/log-admin.js +100 -59
- package/dist/log-store.d.ts +8 -2
- package/dist/log-store.js +22 -12
- package/dist/perathos.d.ts +50 -0
- package/dist/perathos.js +187 -0
- package/dist/portal.d.ts +66 -5
- package/dist/portal.js +895 -242
- package/dist/session-audit.d.ts +46 -0
- package/dist/session-audit.js +150 -0
- package/dist/site-links.d.ts +23 -0
- package/dist/site-links.js +29 -0
- package/docs/acs.md +2 -0
- package/docs/approvals.md +1 -1
- package/docs/completeness.md +1 -1
- package/docs/configuration.md +2 -0
- package/docs/console.md +11 -2
- package/docs/door-signals.md +1 -1
- package/docs/door.md +4 -16
- package/docs/egress.md +3 -1
- package/docs/github-action.md +2 -2
- package/docs/mandates.md +1 -1
- package/docs/perathos.md +97 -0
- package/docs/sdk.md +32 -1
- package/docs/threat-model.md +2 -1
- package/docs/tutorials.md +2 -0
- package/docs/usage.md +3 -1
- package/docs/verification.md +1 -1
- package/package.json +1 -1
- package/vectors/interop/perathos/LICENSE +21 -0
- package/vectors/interop/perathos/README.md +17 -0
- package/vectors/interop/perathos/pocketos-replay/session.head.json +11 -0
- package/vectors/interop/perathos/pocketos-replay/session.jsonl +8 -0
- package/vectors/interop/perathos/pocketos-replay/verification.json +65 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface AuditedCall {
|
|
2
|
+
session: string;
|
|
3
|
+
/** the last part of the working directory the session ran in */
|
|
4
|
+
project: string;
|
|
5
|
+
timestamp: string;
|
|
6
|
+
tool: string;
|
|
7
|
+
target: string;
|
|
8
|
+
policyIds: string[];
|
|
9
|
+
reasons: string[];
|
|
10
|
+
rules: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface SessionAudit {
|
|
13
|
+
dir: string;
|
|
14
|
+
since: string | null;
|
|
15
|
+
policy: string;
|
|
16
|
+
policyDigest: string;
|
|
17
|
+
transcripts: number;
|
|
18
|
+
sessions: number;
|
|
19
|
+
calls: number;
|
|
20
|
+
denied: AuditedCall[];
|
|
21
|
+
/** calls that no forbid matched but on which a rule errored (a value Cedar cannot hold, an attribute the call lacks); the hook denies these, and they are listed apart because no rule decided them. A call a forbid matched is in `denied` even when another rule errored on it */
|
|
22
|
+
unevaluated: {
|
|
23
|
+
tool: string;
|
|
24
|
+
target: string;
|
|
25
|
+
errors: string[];
|
|
26
|
+
}[];
|
|
27
|
+
/** lines that were not JSON; a transcript being written can end in a partial line */
|
|
28
|
+
unreadable: number;
|
|
29
|
+
}
|
|
30
|
+
export interface SessionAuditOptions {
|
|
31
|
+
/** the directory of Claude Code's per-project transcripts */
|
|
32
|
+
dir: string;
|
|
33
|
+
policyText: string;
|
|
34
|
+
/** shown in the result; the policy file's path, or "the init claude-code template" */
|
|
35
|
+
policyName: string;
|
|
36
|
+
since?: Date;
|
|
37
|
+
}
|
|
38
|
+
/** Claude Code's transcripts: `$CLAUDE_CONFIG_DIR/projects` when that is set, else `~/.claude/projects`. */
|
|
39
|
+
export declare function defaultTranscriptDir(env?: NodeJS.ProcessEnv): string;
|
|
40
|
+
/** `7d`, `24h`, `30m`, or a date or date-time that Date can read. */
|
|
41
|
+
export declare function parseSince(text: string, now?: Date): Date;
|
|
42
|
+
export declare function auditSessions(o: SessionAuditOptions): SessionAudit;
|
|
43
|
+
/** The audit as text. `counts` leaves out every command, path, session, and project, so the output can be shared. */
|
|
44
|
+
export declare function formatSessionAudit(a: SessionAudit, opts?: {
|
|
45
|
+
counts?: boolean;
|
|
46
|
+
}): string;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agent-custody audit-sessions`: which of a developer's past Claude Code tool calls a Cedar policy would have denied,
|
|
3
|
+
* read from the session transcripts Claude Code keeps on the machine. It installs nothing, writes nothing, and makes no
|
|
4
|
+
* network request, so it can run before anyone decides to install the hooks.
|
|
5
|
+
*
|
|
6
|
+
* A transcript is the agent host's own account and anyone with the files can edit it: the result is a preview of what
|
|
7
|
+
* the policy would catch, not evidence. Receipts come from the hooks that `init claude-code` installs.
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
10
|
+
import { homedir } from "node:os";
|
|
11
|
+
import { basename, join } from "node:path";
|
|
12
|
+
import { ruleTexts, targetOf } from "./deny-report.js";
|
|
13
|
+
import { evaluate, policyDigest, policyParseErrors, policyReasons, policyRules } from "./policy.js";
|
|
14
|
+
/** Claude Code's transcripts: `$CLAUDE_CONFIG_DIR/projects` when that is set, else `~/.claude/projects`. */
|
|
15
|
+
export function defaultTranscriptDir(env = process.env) {
|
|
16
|
+
return env.CLAUDE_CONFIG_DIR ? join(env.CLAUDE_CONFIG_DIR, "projects") : join(homedir(), ".claude", "projects");
|
|
17
|
+
}
|
|
18
|
+
/** `7d`, `24h`, `30m`, or a date or date-time that Date can read. */
|
|
19
|
+
export function parseSince(text, now = new Date()) {
|
|
20
|
+
const rel = /^(\d+)([dhm])$/.exec(text.trim());
|
|
21
|
+
if (rel)
|
|
22
|
+
return new Date(now.getTime() - Number(rel[1]) * { d: 86_400_000, h: 3_600_000, m: 60_000 }[rel[2]]);
|
|
23
|
+
const t = Date.parse(text);
|
|
24
|
+
if (Number.isNaN(t))
|
|
25
|
+
throw new Error(`--since takes 7d, 24h, 30m, or a date; got "${text}"`);
|
|
26
|
+
return new Date(t);
|
|
27
|
+
}
|
|
28
|
+
function transcriptsUnder(dir) {
|
|
29
|
+
const out = [];
|
|
30
|
+
const walk = (d) => {
|
|
31
|
+
for (const e of readdirSync(d, { withFileTypes: true })) {
|
|
32
|
+
const p = join(d, e.name);
|
|
33
|
+
if (e.isDirectory())
|
|
34
|
+
walk(p);
|
|
35
|
+
else if (e.isFile() && e.name.endsWith(".jsonl"))
|
|
36
|
+
out.push(p);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
walk(dir);
|
|
40
|
+
return out.sort();
|
|
41
|
+
}
|
|
42
|
+
export function auditSessions(o) {
|
|
43
|
+
if (!existsSync(o.dir))
|
|
44
|
+
throw new Error(`no Claude Code transcripts at ${o.dir}; give another directory with --dir`);
|
|
45
|
+
// a policy that does not parse denies every call with the parse error, which would read as "it catches nothing"
|
|
46
|
+
const parseErrors = policyParseErrors(o.policyText);
|
|
47
|
+
if (parseErrors.length)
|
|
48
|
+
throw new Error(`${o.policyName} does not parse: ${parseErrors.join("; ")}`);
|
|
49
|
+
const rules = policyRules(o.policyText);
|
|
50
|
+
const reasons = policyReasons(o.policyText);
|
|
51
|
+
const since = o.since?.getTime();
|
|
52
|
+
const result = { dir: o.dir, since: o.since?.toISOString() ?? null, policy: o.policyName, policyDigest: policyDigest(o.policyText), transcripts: 0, sessions: 0, calls: 0, denied: [], unevaluated: [], unreadable: 0 };
|
|
53
|
+
const sessions = new Set();
|
|
54
|
+
const seen = new Set();
|
|
55
|
+
for (const file of transcriptsUnder(o.dir)) {
|
|
56
|
+
// a transcript last written before the window holds nothing inside it
|
|
57
|
+
if (since !== undefined && statSync(file).mtimeMs < since)
|
|
58
|
+
continue;
|
|
59
|
+
result.transcripts++;
|
|
60
|
+
for (const line of readFileSync(file, "utf8").split("\n")) {
|
|
61
|
+
if (!line.trim())
|
|
62
|
+
continue;
|
|
63
|
+
let entry;
|
|
64
|
+
try {
|
|
65
|
+
entry = JSON.parse(line);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
result.unreadable++;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (entry.type !== "assistant")
|
|
72
|
+
continue;
|
|
73
|
+
const timestamp = typeof entry.timestamp === "string" ? entry.timestamp : "";
|
|
74
|
+
if (since !== undefined && !(Date.parse(timestamp) >= since))
|
|
75
|
+
continue;
|
|
76
|
+
const content = entry.message?.content;
|
|
77
|
+
if (!Array.isArray(content))
|
|
78
|
+
continue;
|
|
79
|
+
for (const c of content) {
|
|
80
|
+
if (c?.type !== "tool_use" || typeof c.name !== "string")
|
|
81
|
+
continue;
|
|
82
|
+
const id = typeof c.id === "string" ? c.id : `${file}:${timestamp}:${c.name}`;
|
|
83
|
+
if (seen.has(id))
|
|
84
|
+
continue;
|
|
85
|
+
seen.add(id);
|
|
86
|
+
const session = typeof entry.sessionId === "string" ? entry.sessionId : basename(file, ".jsonl");
|
|
87
|
+
sessions.add(session);
|
|
88
|
+
result.calls++;
|
|
89
|
+
const args = c.input && typeof c.input === "object" ? c.input : {};
|
|
90
|
+
const d = evaluate(o.policyText, { agentId: "claude-code", tool: c.name, context: { args, facts: {} } });
|
|
91
|
+
// A rule error turns the decision into deny but keeps Cedar's own reasons, which for an allowed call are permits.
|
|
92
|
+
// So a call is a rule's denial when a forbid matched it, whatever else errored, and unevaluated otherwise.
|
|
93
|
+
const forbids = d.reasons.filter((id) => ruleTexts([id], rules, reasons).rules[0]?.startsWith("forbid"));
|
|
94
|
+
if (d.errors.length && !forbids.length) {
|
|
95
|
+
result.unevaluated.push({ tool: c.name, target: targetOf(args), errors: d.errors });
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (d.decision !== "deny")
|
|
99
|
+
continue;
|
|
100
|
+
const ids = d.errors.length ? forbids : d.reasons;
|
|
101
|
+
result.denied.push({ session, project: typeof entry.cwd === "string" ? basename(entry.cwd) : "", timestamp, tool: c.name, target: targetOf(args), policyIds: ids, ...ruleTexts(ids, rules, reasons) });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
result.sessions = sessions.size;
|
|
106
|
+
result.denied.sort((a, b) => (a.timestamp < b.timestamp ? -1 : a.timestamp > b.timestamp ? 1 : 0));
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
const plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
110
|
+
const clip = (s, n = 160) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);
|
|
111
|
+
const NO_PERMIT = "no permit matched (default deny)";
|
|
112
|
+
const PREVIEW = "PREVIEW: these are the agent host's own transcripts, not receipts. Nothing here is signed or logged, and a transcript can be edited. For a receipt of each call, signed and logged, run: agent-custody init claude-code";
|
|
113
|
+
/** The audit as text. `counts` leaves out every command, path, session, and project, so the output can be shared. */
|
|
114
|
+
export function formatSessionAudit(a, opts = {}) {
|
|
115
|
+
const window = a.since ? ` since ${a.since}` : "";
|
|
116
|
+
// --counts is the output people share: the policy's file name, not the path to it
|
|
117
|
+
const policy = opts.counts && a.policy.includes("/") ? basename(a.policy) : a.policy;
|
|
118
|
+
const lines = [`Read ${plural(a.calls, "tool call")} in ${plural(a.sessions, "session")}${window}.`, `Policy: ${policy}.`, ""];
|
|
119
|
+
lines.push(`The policy would have denied ${plural(a.denied.length, "call")}${a.denied.length ? ":" : "."}`);
|
|
120
|
+
if (opts.counts) {
|
|
121
|
+
const byRule = new Map();
|
|
122
|
+
for (const c of a.denied) {
|
|
123
|
+
const key = c.policyIds.join(", ");
|
|
124
|
+
const r = byRule.get(key) ?? { n: 0, reason: c.reasons.join("; ") };
|
|
125
|
+
r.n++;
|
|
126
|
+
byRule.set(key, r);
|
|
127
|
+
}
|
|
128
|
+
for (const [ids, r] of [...byRule].sort((x, y) => y[1].n - x[1].n))
|
|
129
|
+
lines.push(` ${String(r.n).padStart(4)} ${ids || NO_PERMIT}${r.reason ? ` ${r.reason}` : ""}`);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
for (const c of a.denied) {
|
|
133
|
+
lines.push("", ` ${c.tool}: ${clip(c.target)}`);
|
|
134
|
+
if (c.reasons.length)
|
|
135
|
+
lines.push(` reason: ${c.reasons.join("; ")}`);
|
|
136
|
+
lines.push(` rule: ${!c.policyIds.length ? NO_PERMIT : c.rules.length ? `${clip(c.rules.join(" | "))} [${c.policyIds.join(", ")}]` : c.policyIds.join(", ")}`);
|
|
137
|
+
lines.push(` when: ${c.timestamp} session ${c.session.slice(0, 8)}${c.project ? ` in ${c.project}` : ""}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (a.unevaluated.length) {
|
|
141
|
+
lines.push("", `${plural(a.unevaluated.length, "more call")} matched no forbid rule, but a rule errored on ${a.unevaluated.length === 1 ? "it" : "them"}, for example on a value Cedar cannot hold (a float) or an attribute the call does not have. The hook denies a call like this; no rule decided it, so it is listed apart:`);
|
|
142
|
+
if (!opts.counts)
|
|
143
|
+
for (const u of a.unevaluated)
|
|
144
|
+
lines.push(` ${u.tool}: ${clip(u.target, 80)} (${clip(u.errors[0] ?? "", 80)})`);
|
|
145
|
+
}
|
|
146
|
+
if (a.unreadable)
|
|
147
|
+
lines.push(`${plural(a.unreadable, "transcript line")} could not be read.`);
|
|
148
|
+
lines.push("", PREVIEW);
|
|
149
|
+
return lines.join("\n");
|
|
150
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The website's top nav and footer, in one place. The landing page, the docs pages (site/.vitepress), and the
|
|
3
|
+
* dashboard (portal.ts) all read these lists, so a page cannot carry a menu of its own. Links are site paths; the
|
|
4
|
+
* dashboard runs on another host and prefixes them with SITE_URL. Labels follow site/guide/glossary.md.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SITE_URL = "https://agent-custody.dev";
|
|
7
|
+
export declare const DASHBOARD_URL = "https://app.agent-custody.dev/";
|
|
8
|
+
export interface SiteLink {
|
|
9
|
+
text: string;
|
|
10
|
+
link: string;
|
|
11
|
+
/** a regular expression over the path: the nav item is highlighted on every page it matches */
|
|
12
|
+
activeMatch?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const SITE_NAV: SiteLink[];
|
|
15
|
+
export declare const SIGN_IN: SiteLink;
|
|
16
|
+
export declare const GET_STARTED: SiteLink;
|
|
17
|
+
export declare const SITE_FOOTER: {
|
|
18
|
+
title: string;
|
|
19
|
+
links: SiteLink[];
|
|
20
|
+
}[];
|
|
21
|
+
export declare const SITE_LEGAL_LINKS: SiteLink[];
|
|
22
|
+
/** A site path as an absolute URL, for pages on another host. External links pass through. */
|
|
23
|
+
export declare const siteUrl: (link: string) => string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The website's top nav and footer, in one place. The landing page, the docs pages (site/.vitepress), and the
|
|
3
|
+
* dashboard (portal.ts) all read these lists, so a page cannot carry a menu of its own. Links are site paths; the
|
|
4
|
+
* dashboard runs on another host and prefixes them with SITE_URL. Labels follow site/guide/glossary.md.
|
|
5
|
+
*/
|
|
6
|
+
export const SITE_URL = "https://agent-custody.dev";
|
|
7
|
+
export const DASHBOARD_URL = "https://app.agent-custody.dev/";
|
|
8
|
+
export const SITE_NAV = [
|
|
9
|
+
{ text: "Product", link: "/" },
|
|
10
|
+
{ text: "Docs", link: "/guide/getting-started", activeMatch: "^/(guide|receipts|state|python|reference|receipt)/" },
|
|
11
|
+
{ text: "Pricing", link: "/pricing" },
|
|
12
|
+
{ text: "Blog", link: "/blog/", activeMatch: "^/blog/" },
|
|
13
|
+
{ text: "Verify a receipt", link: "/verify" },
|
|
14
|
+
];
|
|
15
|
+
export const SIGN_IN = { text: "Sign in", link: DASHBOARD_URL };
|
|
16
|
+
export const GET_STARTED = { text: "Get started", link: "/guide/getting-started" };
|
|
17
|
+
export const SITE_FOOTER = [
|
|
18
|
+
{ title: "Product", links: [{ text: "How it works", link: "/how-it-works" }, { text: "Use cases", link: "/use-cases" }, { text: "Pricing", link: "/pricing" }, { text: "Hosted log", link: "/hosted-log" }, { text: "Verify a receipt", link: "/verify" }] },
|
|
19
|
+
{ title: "Docs", links: [{ text: "Getting started", link: "/guide/getting-started" }, { text: "Incident replay", link: "/guide/incident-replay" }, { text: "Reference", link: "/reference/" }, { text: "Receipt specification", link: "/receipt/v0.2" }, { text: "Glossary", link: "/guide/glossary" }, { text: "Roadmap", link: "/roadmap" }, { text: "Changelog", link: "/changelog" }] },
|
|
20
|
+
{ title: "Trust", links: [{ text: "Status and limits", link: "/status" }, { text: "Security", link: "/security" }, { text: "Where data goes", link: "/faq" }, { text: "Threat model", link: "/receipts/threat-model" }, { text: "This repository", link: "/custody" }] },
|
|
21
|
+
{ title: "Company", links: [{ text: "Blog", link: "/blog/" }, { text: "Contact", link: "/contact" }, { text: "Privacy", link: "/privacy" }, { text: "Terms", link: "/terms" }] },
|
|
22
|
+
];
|
|
23
|
+
export const SITE_LEGAL_LINKS = [
|
|
24
|
+
{ text: "GitHub", link: "https://github.com/svayatta/agent-custody" },
|
|
25
|
+
{ text: "npm", link: "https://www.npmjs.com/org/agent-custody" },
|
|
26
|
+
{ text: "PyPI", link: "https://pypi.org/project/agent-custody/" },
|
|
27
|
+
];
|
|
28
|
+
/** A site path as an absolute URL, for pages on another host. External links pass through. */
|
|
29
|
+
export const siteUrl = (link) => (/^https?:/.test(link) ? link : SITE_URL + link);
|
package/docs/acs.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# The ACS Guardian
|
|
2
2
|
|
|
3
|
+
> How it works and when to use it. Every field, route, and flag is in [the reference](../../../site/reference/acs.md).
|
|
4
|
+
|
|
3
5
|
The [OWASP Agent Control Standard](https://github.com/GenAI-Security-Project/agent-control-standard) (ACS) is a wire contract between an agent and a separate policy point. Before the agent acts, its instrumentation sends a JSON-RPC 2.0 hook, such as `steps/toolCallRequest`, to a **Guardian**. The Guardian answers `allow`, `deny`, `modify`, `ask`, or `defer`, and the agent is expected to honor the answer. `agent-custody acs` is a Guardian for two of those hooks. It decides each one with a Cedar policy and returns the decision with a signed, logged receipt (`issuer.kind: "guardian"`). A third party can check that receipt with the Guardian's public key alone.
|
|
4
6
|
|
|
5
7
|
This is a spike: enough to show the two fit together. It is not an ACS-Core conformant Guardian. The list of what it leaves out is [below](#what-it-does-not-implement). It was written against the ACS repository at commit `db457a8` (`version.txt` 0.1.4, schemas under `specification/v0.1.0/`).
|
package/docs/approvals.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Human approvals
|
|
2
2
|
|
|
3
3
|
A delegation lets an agent use a tool. A human approval authorizes one exact call: this principal, this agent, this tool, and every argument, until a short expiry. The gateway requires the signed approval before forwarding a protected call. A flag such as `approved: true` in the arguments has no authority.
|
|
4
4
|
|
package/docs/completeness.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Completeness
|
|
1
|
+
# Completeness
|
|
2
2
|
|
|
3
3
|
A verified receipt proves what went through the gateway. Nothing on the gateway's side can see an action that never went through it: whoever holds the Stripe key can issue a refund straight through Stripe's API. The provider's own record is the only place that action shows. `agent-custody completeness` lets an auditor check it, with a read-only key of their own.
|
|
4
4
|
|
package/docs/configuration.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Configuring the gateway
|
|
2
2
|
|
|
3
|
+
> A walk through the gateway's config files. Every field, with its type, is in [the gateway reference](../../../site/reference/gateway.md).
|
|
4
|
+
|
|
3
5
|
Who may use which tools, and where those tools live, is set in three files and a few environment variables. This page is the map: what each one decides, how they fit together, a worked example with two agents on one shared gateway, how it all works in the Docker image, and how to check a config before you start. The full list of config keys is in [the gateway reference](/reference/gateway); the Cedar and Rego languages are in [policies.md](policies.md).
|
|
4
6
|
|
|
5
7
|
## What you configure, and where
|
package/docs/console.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Gateway console
|
|
2
2
|
|
|
3
3
|
A small admin service for the person who runs a gateway. It shows what the gateway is configured to do and what it has done, validates and replays a policy change before it is saved, and revokes a grant. It is a separate process from the gateway, behind a token, so the gateway never serves an admin page next to the agents' credentials.
|
|
4
4
|
|
|
@@ -32,9 +32,18 @@ It listens on `127.0.0.1:8795` and prints the URL. Open it and sign in with the
|
|
|
32
32
|
| **Check** | the same checks as `agent-custody check`, except that the credential variables are **not** checked: the console deliberately does not hold the gateway's credentials, so it cannot tell whether they are set where the gateway runs. "Connect" starts the upstreams and lists their tools only for a config that names no credentials; otherwise it says to run `agent-custody check --connect` where the gateway runs, for example `docker compose exec gateway agent-custody check --config /config/gateway.json --connect`. A connect check that does not finish in 60 seconds is stopped and the upstreams it started are closed ([configuration.md](configuration.md#check-it-before-you-start-it)) |
|
|
33
33
|
| **Policy** | the policy file in an editor. *Validate* asks Cedar to parse it. *Replay recorded calls* runs it against the verified receipts, using each call's own arguments and facts, and lists the decisions that would change, with their receipts. **A replay only re-decides calls that already happened**: a limit that no recorded call reached, or removing one, can show no change, so it is not a test of what a policy allows. *Save* writes it, keeping the previous version and recording the change |
|
|
34
34
|
| **Grants** | paste a grant to see whether the gateway would accept it (valid, expired, revoked, signed by a key it does not trust) and what it allows; *Revoke* adds its digest to the revocation file, and the gateway refuses it, and every grant delegated from it, on its next call. Lists the revoked digests |
|
|
35
|
-
| **Receipts** | the newest receipts with their agent, tool, decision, and outcome, each verified against the gateway key, the trusted principals, and the local log; a receipt that does not verify says which checks failed; a row opens the full statement |
|
|
35
|
+
| **Receipts** | the newest receipts with their agent, tool, decision, and outcome, each verified against the gateway key, the trusted principals, and the local log; a receipt that does not verify says which checks failed; the id in a row opens a summary of the statement, with the full statement behind *Raw JSON* |
|
|
36
36
|
| **Audit** | every change made through the console: who, when, and what, with the policy's digest before and after |
|
|
37
37
|
|
|
38
|
+
## Use the page
|
|
39
|
+
|
|
40
|
+
- **The tab is in the URL.** The hash is `#tab=policy`, `#tab=receipts`, and so on. Copy the URL to link to a tab. Back and Forward move between the tabs that you opened.
|
|
41
|
+
- **Results show beside the button.** The result of *Save* shows beside *Save*. The result of *Revoke* shows beside *Revoke*. Both are announced to a screen reader.
|
|
42
|
+
- **Unsaved policy edits are not lost without a warning.** A tab change with unsaved edits opens a dialog that asks you to discard them or to keep editing. Closing or reloading the page shows the browser's own warning.
|
|
43
|
+
- **Save and Revoke ask in the page.** The dialog names the policy file or the grant (the agent and the digest). Escape and *Cancel* do nothing. For *Revoke*, the focus starts on *Cancel*.
|
|
44
|
+
- **A receipt opens from its id.** The id in each row is a button, so the keyboard and a screen reader can open it. The detail shows the tool, the decision, the status, the time, the agent, the principal, whether a grant was presented, the digests, and whether the receipt verifies. The full statement is behind *Raw JSON*. The focus moves to the detail when it opens and returns to the id when you press *Close*.
|
|
45
|
+
- **Times show in your local time.** The UTC value shows when you hold the pointer over a time.
|
|
46
|
+
|
|
38
47
|
## What a saved policy does
|
|
39
48
|
|
|
40
49
|
A running gateway re-reads `policy.cedar` when it changes, so **a saved policy applies from the gateway's next call**, with no restart, and the gateway records the change in `receipts/policy-reloads.jsonl`. The save is guarded: Cedar must parse the text; and the operator must confirm a policy that has no `permit` rule (a `permit(` in a comment does not count), because every call would be denied, or a `permit` rule with **no action and no condition**, which allows every tool in a grant's scopes and which a replay cannot show. A save made from a copy that is no longer the file on disk is refused with `409`. The digest check, the history copy, and the write happen under one lock, in this process and, through a lock file in the state directory, across consoles that share it, so two administrators cannot overwrite each other. The previous version is kept under `console/policy-history/` and the change goes in the audit trail.
|
package/docs/door-signals.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Door signals
|
|
1
|
+
# Door signals
|
|
2
2
|
|
|
3
3
|
The door records one fact for every arrival, `arrival`, and gives it to the policy as `context.facts.arrival`. Every field in it is a signal: something the door observed, labelled by how far it was checked. None of them is a verdict. This page says, for each signal, what it establishes, what it does not, and how a policy should read it. The door's guide is [the door](door.md); the contract is the [reference](https://agent-custody.dev/reference/door).
|
|
4
4
|
|
package/docs/door.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
# The door
|
|
1
|
+
# The door
|
|
2
|
+
|
|
3
|
+
> How it works and when to use it. Every field, route, and flag is in [the reference](../../../site/reference/door.md).
|
|
2
4
|
|
|
3
5
|
The gateway stands between an agent and the tools it uses. The door stands between the world and your own HTTP surface: a website, an API, a form. Every arrival, a browser, an API client, a crawler, or an agent acting for someone, is classified by what it presented, decided by a Cedar policy for the route it hit, relayed to your origin or refused, and receipted either way. The receipt is the same signed, logged, independently verifiable receipt the gateway issues, with `issuer.kind: "door"`.
|
|
4
6
|
|
|
@@ -33,21 +35,7 @@ agent-custody door --config door.json --port 8780
|
|
|
33
35
|
}
|
|
34
36
|
```
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
| --- | --- |
|
|
38
|
-
| `identity.keyFile` | the door's Ed25519 key; signs every receipt. From `agent-custody keygen` |
|
|
39
|
-
| `origin.url` | where allowed arrivals are relayed: the site or API behind the door. `headers` and `headerEnv` add headers to every relayed request, the latter from the environment, so the origin can require a secret only the door holds. `timeoutMs` bounds one relayed request, default 30 s. A path in the URL (`https://host/api/v1`) is kept: the arrival's path goes under it, and a redirect from the origin to a place under it comes back as a door path |
|
|
40
|
-
| `routes` | what the policy sees as the action. `path` is exact (`/refunds`), a prefix (`/api/*`), or `*`; `methods` narrows it, default every method. The first route that matches wins; an arrival no route matches is the action `unmatchedRoute`, default `other`. The match reads the path as the origin will: percent-decoded once, so `/%61dmin` falls under `/admin/*`, and with empty segments merged, so `//admin/users` and `/admin//users` fall under it too (nginx, Apache, and many frameworks merge them). A trailing slash matches as none: `/refunds/` falls under `/refunds`. The origin is sent that merged, decoded form, trailing slash kept, so the door and the origin read one path. A path with a segment that does not decode, or decodes to a slash or a backslash, falls under `unmatchedRoute` and is never relayed |
|
|
41
|
-
| `trustedPrincipalKeys` | public keys of principals whose signed grants the door accepts as a passport. Without any, no arrival can be `verified` |
|
|
42
|
-
| `policyFile` | the Cedar policy, re-read when the file changes; one that does not parse is refused and the policy in force stays |
|
|
43
|
-
| `mode` | `enforce` (default) refuses what the policy denies. `observe` relays everything and records the decision with `enforced: false` |
|
|
44
|
-
| `trustProxy` | behind one reverse proxy you run: the arrival's address is the last in `X-Forwarded-For`, the one your proxy appended; everything before it is what the client sent. The proxy's `X-Forwarded-For`, `-Proto`, and `-Host` are kept on the relay, with the door's own socket address appended, and the other client-address headers (`Forwarded`, `X-Real-IP`, `True-Client-IP`, `CF-Connecting-IP`, every `X-Forwarded-*`) are relayed as the proxy sent them. Without `trustProxy` the client wrote all of these: the door drops them and sets `X-Forwarded-For`, `-Host`, `-Proto`, and `X-Real-IP` itself |
|
|
45
|
-
| `maxBodyBytes` | the largest request body the door relays; a larger one gets 413 and a `withheld` receipt once the policy has allowed it. Default 1 MiB |
|
|
46
|
-
| `maxResponseBytes` | the largest origin response the door relays; see [what the arrival gets back](#what-the-arrival-gets-back). Default 32 MiB |
|
|
47
|
-
| `maxInFlight` | arrivals handled at once. Each holds its body and the origin's answer in memory until it is answered, so this bounds the door's memory at about `maxInFlight × (maxBodyBytes + maxResponseBytes)`. Past it the next arrival gets 503 with `Retry-After: 1` before its body is read: it is not decided, relayed, or receipted. Default 256 |
|
|
48
|
-
| `precommit` | route names whose arrivals are committed to the log before they are relayed whatever their method, or `["*"]`. Every arrival whose method is not GET, HEAD, or OPTIONS is committed regardless; see [before the origin hears of it](#before-the-origin-hears-of-it). Default `[]` |
|
|
49
|
-
| `challenge` | the human branch: `{ provider: "turnstile" or "hcaptcha", siteKey, secretEnv, hostnames, action?, header?, timeoutMs?, maxInFlight? }`. `hostnames` lists the hosts of the pages that render the widget, `action` (Turnstile only) the widget's action, and `maxInFlight` (default 64) how many checks may wait on the provider at once. A token an arrival sends in `header` (default `x-agent-custody-challenge`) is verified with the provider, and the outcome is the arrival's `challenge` signal; see [challenging a human](#challenging-a-human). The secret comes from the environment variable, read at startup; missing is a startup error |
|
|
50
|
-
| `receiptsDir`, `logFile` or `log`, `otel`, `splunk`, `capture`, `captureKeyEnv` | as for the [gateway](configuration.md): where receipts and the log go, exporters, and private evidence per route. A remote `log` needs `log.keys`, because its answer is checked before a request is relayed. Unlike the gateway, the door withholds by default: see [what a receipt records](#what-a-receipt-records-of-the-query-and-the-body) |
|
|
38
|
+
Every field of the config, with its type and default, is in [the door reference](../../../site/reference/door.md#config).
|
|
51
39
|
|
|
52
40
|
`agent-custody check --config door.json` reads a door config the way the door would: unknown keys, the key, the principal keys, the policy (including a permit that names an agent without requiring a verified arrival, see below), the routes, what is precommitted, the challenge provider or its absence, the origin's scheme, every credential variable the door reads at startup (origin headers, the log, Splunk, OTel, the capture key, the challenge secret), and the paths. It exits 1 on an error.
|
|
53
41
|
|
package/docs/egress.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
# The egress witness
|
|
1
|
+
# The egress witness
|
|
2
|
+
|
|
3
|
+
> How it works and when to use it. Every field, route, and flag is in [the reference](../../../site/reference/egress.md).
|
|
2
4
|
|
|
3
5
|
The gateway holds an agent's tool credentials and receipts every call made through it. An agent that has a credential of its own, or that calls a public API with none, can go around it. The egress witness is for those connections. It is an HTTP forward proxy in the agent's network path, the [door](door.md) turned around to face outbound traffic. For each connection that does not go to the gateway, it:
|
|
4
6
|
|
package/docs/github-action.md
CHANGED
|
@@ -20,7 +20,7 @@ jobs:
|
|
|
20
20
|
runs-on: ubuntu-latest
|
|
21
21
|
steps:
|
|
22
22
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
23
|
-
- uses: svayatta/agent-custody@<commit sha of the release> # 0.16.
|
|
23
|
+
- uses: svayatta/agent-custody@<commit sha of the release> # 0.16.6
|
|
24
24
|
with:
|
|
25
25
|
path: .custody/receipts
|
|
26
26
|
issuer-key: .custody/keys/agent.pub
|
|
@@ -37,7 +37,7 @@ Pin the action to the commit of a release, as you pin every other action. A movi
|
|
|
37
37
|
| `principal-key` | the public key files of the principals whose grants a gateway receipt carries, one path on each line; SDK and Claude Code hook receipts need none | |
|
|
38
38
|
| `log-url` | the URL of the log; the action fetches the log key from it (`verify --log-url`) | |
|
|
39
39
|
| `log-id` | the id that every tree head must name (`verify --log-id`) | |
|
|
40
|
-
| `version` | the `@agent-custody/receipts` version that `npx` runs | `0.16.
|
|
40
|
+
| `version` | the `@agent-custody/receipts` version that `npx` runs | `0.16.6` |
|
|
41
41
|
| `github-token` | a token that can write pull request comments; an empty value writes the job summary only | `github.token` |
|
|
42
42
|
| `comment-author` | the login of the account that `github-token` posts as; the action edits only a comment from this account | `github-actions[bot]` |
|
|
43
43
|
|
package/docs/mandates.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Payment mandates and agent identity
|
|
1
|
+
# Payment mandates and agent identity (planned)
|
|
2
2
|
|
|
3
3
|
Design, not yet built. It tracks issues #185 and #186: fitting the grant and the receipt to the payment networks' standards, so that the networks define the authority and agent-custody keeps the evidence of what was done under it.
|
|
4
4
|
|
package/docs/perathos.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Reading a Perathos log
|
|
2
|
+
|
|
3
|
+
[Perathos](https://github.com/perathos-protocol/perathos) records an agent's tool calls from hooks inside the agent's host (Claude Code, Cursor, or its MCP proxy), hash-chains them into a session log, and seals turns with Ed25519 checkpoints. `agent-custody verify-perathos` checks such a log against the verification rules of the Perathos receipt spec (`docs/specs/RECEIPT_V1.md` in their repository), so an auditor can check either project's records with one tool. The reader was written from that spec alone, not from Perathos code.
|
|
4
|
+
|
|
5
|
+
The two formats record different things, and the report says which one it read. This page lists what the reader checks, what a valid log proves, and how the fields of the two formats correspond.
|
|
6
|
+
|
|
7
|
+
## Run it
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
agent-custody verify-perathos .perathos/sessions/<session>.jsonl \
|
|
11
|
+
--key <recorder public key, 64 hex> \
|
|
12
|
+
--head .perathos/sessions/<session>.head.json
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
PASS every line is a JSON object
|
|
17
|
+
PASS format is perathos.receipt/v1 with a known kind
|
|
18
|
+
PASS seq is 1, 2, 3, ... in file order
|
|
19
|
+
PASS prev_hash chains each receipt to the one before
|
|
20
|
+
PASS receipt_hash recomputes
|
|
21
|
+
PASS one session, and time never goes back
|
|
22
|
+
PASS checkpoint signatures verify
|
|
23
|
+
PASS every checkpoint is signed
|
|
24
|
+
PASS every signer is a trusted key
|
|
25
|
+
PASS the head witness's checkpoint is in the log
|
|
26
|
+
|
|
27
|
+
RESULT: VALID
|
|
28
|
+
|
|
29
|
+
session replay
|
|
30
|
+
receipts 7 (3 tool calls, 2 checkpoints)
|
|
31
|
+
sealed through seq 7
|
|
32
|
+
signers be58168fa007
|
|
33
|
+
time 2026-11-04T08:19:00.000000Z to 2026-11-04T08:19:06.000000Z (host clock)
|
|
34
|
+
denied 1 call(s) stopped by the guard
|
|
35
|
+
|
|
36
|
+
PROVENANCE: perathos.receipt/v1, recorded by hooks inside the agent's host (claude-code); the checkpoint key is held on that host, so a valid log shows that the key holder sealed this sequence, not that an enforcement point outside the agent saw each call; times are the host's clock, and RFC 3161 anchors were not checked
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
| flag | effect |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| `--key <hex>` | pins the recorder's Ed25519 public key (repeatable); a checkpoint signed by any other key fails. Without it, a session sealed by more than one key fails, and the report warns that no key was pinned |
|
|
42
|
+
| `--head <file>` | the head witness, `{ "seq", "receipt_hash" }` of the latest checkpoint; a log cut back to an earlier checkpoint fails |
|
|
43
|
+
| `--allow-unsigned` | accepts a log with no checkpoint, or an unsigned one, and reports each as a warning |
|
|
44
|
+
| `--json` | the report as JSON |
|
|
45
|
+
|
|
46
|
+
It exits 0 when the log is valid and 1 when it is not. Receipts after the last checkpoint whose signature verified are reported as an unsealed tail, not an error, because the session may still be running; an unsigned checkpoint, one whose signature fails, or, with `--key`, one signed by a key that is not pinned, seals nothing. The head witness file is checked for shape first. From code: `verifyPerathosLog(text, { trustedKeys?, allowUnsigned?, head? })` and `formatPerathosReport(report)`.
|
|
47
|
+
|
|
48
|
+
## What it checks
|
|
49
|
+
|
|
50
|
+
Rules 1 to 9 of the spec:
|
|
51
|
+
|
|
52
|
+
1. Every line is a JSON object, `v` is `perathos.receipt/v1`, and `kind` is `pre`, `post`, or `checkpoint`.
|
|
53
|
+
2. `seq` runs 1, 2, 3, and so on in file order.
|
|
54
|
+
3. Each `prev_hash` is the previous receipt's `receipt_hash`, and the first is 64 zeros.
|
|
55
|
+
4. Each `receipt_hash` recomputes: SHA-256 of the canonical JSON of every field except `receipt_hash` and `signature`, known fields or not.
|
|
56
|
+
5. One `session_id` throughout, and `ts` never goes back. Every `ts` must be in the spec's form, `YYYY-MM-DDTHH:MM:SS.mmmmmmZ`: in that fixed-width UTC form, string order is time order. A `ts` without the microseconds or with an offset could be an earlier instant that sorts as later, and a receipt after the last checkpoint has no signature to stop it, so any other form fails.
|
|
57
|
+
6. Every checkpoint signature verifies: Ed25519 over the 32 raw bytes of `receipt_hash`, by the key in `signer`, which `signature.verify_key` must equal.
|
|
58
|
+
7. At least one checkpoint, and every checkpoint signed. A checkpoint with `signer_error` is named as a signer failure, which explains a missing signature and does not excuse it.
|
|
59
|
+
8. With `--key`, every signer is a pinned key. Without it, one key must seal the whole session: someone without the recorder's key could otherwise append receipts after its last checkpoint and seal them with a key of their own. Pin two keys for a rotation you vouch for. Without `--key` the report also warns that a valid result shows only that the log is consistent with itself, not who sealed it, as our own `verify` requires `--issuer-key` for the same reason.
|
|
60
|
+
9. With `--head`, the log holds the head witness's checkpoint.
|
|
61
|
+
|
|
62
|
+
## What a valid log proves
|
|
63
|
+
|
|
64
|
+
The holder of the checkpoint key sealed this exact sequence, and nothing up to the last checkpoint was edited, removed, inserted, or reordered since. Whoever holds a call's arguments or result can show that they match the recorded hash.
|
|
65
|
+
|
|
66
|
+
It does not prove that an enforcement point outside the agent saw each call. The recorder runs in the agent's host and the key sits there, so the log is as trustworthy as that host. Times are the host's clock. The `model` field is self-reported. The spec lists the rest, including a recorder that was not running for part of a session.
|
|
67
|
+
|
|
68
|
+
## How the two formats correspond
|
|
69
|
+
|
|
70
|
+
| Perathos `receipt/v1` | agent-custody receipt | note |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
| `agent` | `issuer.kind` | Perathos names the recording integration; agent-custody names the issuer kind and what it is worth ([verification](verification.md)) |
|
|
73
|
+
| `session_id`, `tool_use_id` | `session.id`, `session.toolUseId` | both are the host's correlation ids; agent-custody marks them `claimed` |
|
|
74
|
+
| `seq`, `prev_hash` | leaf index in the RFC 9162 log | a per-session hash chain against one Merkle log; agent-custody proves inclusion with an inclusion proof, Perathos by walking the chain |
|
|
75
|
+
| `receipt_hash` | the leaf hash of the DSSE envelope | both SHA-256 over canonical JSON |
|
|
76
|
+
| `checkpoint` with `signature` | the signed tree head in each bundle | Perathos signs checkpoints only; agent-custody signs every receipt and every tree head |
|
|
77
|
+
| `pre` / `post` | one receipt with `request` and `outcome` | Perathos writes a call as two receipts linked by `tool_use_id` |
|
|
78
|
+
| `tool`, `args_hash`, `result_hash` | `tool.name`, `request.argsDigest`, `outcome.resultDigest` | agent-custody can also carry the arguments, or withhold a field behind a salted commitment or an encrypted value ([private evidence](usage.md#private-evidence)) |
|
|
79
|
+
| `status` | `outcome.status` | `ok` or `error` against `executed`, `failed`, `denied`, `error`, or `withheld` |
|
|
80
|
+
| `model` | `model.id` | self-reported in both; agent-custody marks it `claimed` |
|
|
81
|
+
| `guard.decision`, `guard.rule` | `policy.decision`, `policy.reasons`, `policy.policyDigest` | a guard rule against a Cedar or Rego policy pinned by its digest |
|
|
82
|
+
| `guard.precondition` (a person-signed safety check) | `delegation` (a principal-signed grant) and `approval` (a payload-bound approval) | both are authority signed by someone other than the agent |
|
|
83
|
+
| `perathos.anchor/v1` (RFC 3161) | the log's checkpoints, witness, and chain anchor ([anchoring](anchoring.md)) | independent time against an independent copy of the log head |
|
|
84
|
+
|
|
85
|
+
Both use Ed25519, SHA-256, and canonical JSON with sorted keys that matches RFC 8785 for these bodies. The structures differ, so a shared schema would lose detail on both sides. The common ground both can map to is IETF SCITT ([aligning with SCITT](scitt.md)).
|
|
86
|
+
|
|
87
|
+
## Not read yet
|
|
88
|
+
|
|
89
|
+
- RFC 3161 anchors (`perathos.anchor/v1`): verifying a timestamp token means parsing the authority's signed response and chaining it to a pinned root certificate.
|
|
90
|
+
- The rest of a Perathos evidence pack: its signed manifest, anchors, and preconditions. The session log inside a pack is read as above. The head witness file also carries a signature that the spec does not define, which is not checked.
|
|
91
|
+
- Signed preconditions (`perathos.precondition/v1`) and Gate approvals.
|
|
92
|
+
|
|
93
|
+
## Tested against a log Perathos wrote
|
|
94
|
+
|
|
95
|
+
`vectors/interop/perathos/pocketos-replay/` holds the session log, head witness, and verifier report from the sample evidence pack in the Perathos repository, copied byte for byte with their licence ([the vector's README](../vectors/interop/perathos/README.md)). `verify-perathos` verifies that log with the recorder's key and the head witness, and agrees with Perathos's own verifier on the session, the receipt, call, and checkpoint counts, the sealed range, the signer, the times, and the two calls the guard blocked. The same log with one receipt edited, cut back to its first checkpoint against the head witness, or checked against another key, fails. So our canonical JSON matches their writer's, and their signatures are hex.
|
|
96
|
+
|
|
97
|
+
The other tests in `test/perathos.test.ts` write logs from the spec, to reach each rule. Example 45 does the same and shows a cut log caught by its head witness and an edited guard decision caught by the chain.
|
package/docs/sdk.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SDK and framework hooks
|
|
2
2
|
|
|
3
3
|
The gateway sees only MCP traffic. The SDK sees whatever the agent framework lets it hook, from inside the agent's own process. It issues the same receipt format, verified by the same command, with one difference a verifier cannot miss: the receipt names its issuer as `sdk`, and every field is `claimed`.
|
|
4
4
|
|
|
@@ -122,6 +122,37 @@ The receipt does not change. It keeps the policy ids and the policy digest, and
|
|
|
122
122
|
|
|
123
123
|
When the denial receipt cannot be issued, the call is blocked all the same, and the reason ends with `(no receipt: <why>)` in place of the receipt id. `<why>` names the kind of failure and nothing more. In TypeScript it is `the receipt could not be recorded`. In Python it is `the sidecar could not be reached`, `the sidecar answered HTTP <status>`, `the sidecar refused the request`, `the sidecar's answer was malformed`, or `an unexpected <exception type>`. The reason goes into the model's context, and the error behind it can carry a log or sidecar URL with credentials in it, or the text of an upstream answer. So the error itself goes to stderr in TypeScript and to the `agent_custody` logger at `WARNING` in Python, never into the reason, and the URL in it is shown without its user, password, or query string. Every adapter that answers a deny with text works this way: Claude Code, the Claude Agent SDK and OpenAI Agents in both languages, OpenClaw, DeepSeek Harness, Hermes, Google ADK, and CrewAI. OpenAI Agents in both languages and CrewAI used to raise the error when the denial receipt failed; they now return the denial text, as the others do, and the tool still does not run. The Vercel AI `wrapTools` and `issuer.wrap` throw `PolicyDeniedError`, which needs a receipt id, so there a failed denial receipt still rejects with the log's error.
|
|
124
124
|
|
|
125
|
+
### Before you install: your past sessions
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
npx -y @agent-custody/receipts audit-sessions --since 7d
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
This reads the transcripts Claude Code already keeps on the machine (`~/.claude/projects`, or `$CLAUDE_CONFIG_DIR/projects`), takes every tool call in the window, and evaluates it against the starter policy that `init claude-code` installs, or `--policy <file.cedar>`. It installs no hook, writes no file, and makes no network request, so you can see what the policy would have caught before you decide to install anything.
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
Read 4 tool calls in 1 session.
|
|
135
|
+
Policy: the init claude-code template.
|
|
136
|
+
|
|
137
|
+
The policy would have denied 2 calls:
|
|
138
|
+
|
|
139
|
+
Bash: git push --force origin main
|
|
140
|
+
reason: force push rewrites shared history (git push --force-with-lease is allowed)
|
|
141
|
+
rule: forbid(principal, action == Action::"Bash", resource) when { context.args has command && ( context.args.command like "*git push --force *" || context.args.comm… [policy1]
|
|
142
|
+
when: 2026-11-09T10:04:52.000Z session 4f3a91c2 in shop
|
|
143
|
+
|
|
144
|
+
Bash: terraform destroy -auto-approve
|
|
145
|
+
reason: terraform destroy deletes infrastructure
|
|
146
|
+
rule: forbid(principal, action == Action::"Bash", resource) when { context.args has command && context.args.command like "*terraform destroy*" } [policy5]
|
|
147
|
+
when: 2026-11-10T16:20:40.000Z session 4f3a91c2 in shop
|
|
148
|
+
|
|
149
|
+
PREVIEW: these are the agent host's own transcripts, not receipts. Nothing here is signed or logged, and a transcript can be edited. For a receipt of each call, signed and logged, run: agent-custody init claude-code
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`--since` takes `7d`, `24h`, `30m`, a date, or `all`. `--counts` prints only the numbers per rule, with no command, path, session, or project, so the output can be shared. `--json` gives the whole result. A call that a forbid rule matched is counted as that rule's denial, even when another rule errored on the same call. A call that no forbid matched, but on which a rule errored (a value Cedar cannot hold, such as a float, or an attribute the call does not have), is listed apart: the hook denies such a call, but no rule decided it. A policy that does not parse is refused with the parse error and exit 1, since otherwise every call would be denied by the error and nothing by a rule. Under a default-deny policy, a call no permit matched is shown as `no permit matched (default deny)`. `--counts` names the policy by its file name only. A Rego policy is refused, because compiling one runs `opa`, which writes files.
|
|
153
|
+
|
|
154
|
+
A transcript is the agent host's own account and can be edited, so this is a preview of what the policy catches, not evidence. The hooks that `init claude-code` installs make a signed receipt of each call.
|
|
155
|
+
|
|
125
156
|
### The report
|
|
126
157
|
|
|
127
158
|
```bash
|
package/docs/threat-model.md
CHANGED
|
@@ -121,7 +121,8 @@ The portal is not part of the evidence: it publishes policy names and mints log
|
|
|
121
121
|
|
|
122
122
|
| attack | defence | kind |
|
|
123
123
|
| --- | --- | --- |
|
|
124
|
-
| Guess or steal a member's password | Optional TOTP MFA on the account. A code works once, wrong codes are throttled per address and per account, and the half-signed-in cookie is never a session. A GitHub or Google sign-in goes through the same code step. | deployment |
|
|
124
|
+
| Guess or steal a member's password | Optional TOTP MFA on the account. A code works once, wrong codes are throttled per address and per account, and the half-signed-in cookie is never a session. A GitHub or Google sign-in goes through the same code step. A recovery code works once in place of a code, counts against the same limit, and is stored only as a hash. New recovery codes need a current code, so a stolen session cannot take them. A password change needs the current password and ends every other session. | deployment |
|
|
125
|
+
| Take over an account through the password reset | The reset request answers the same for every address and looks the address up after it answers. Requests are limited per client and per address. The token is 256 random bits, works once, expires after one hour, and is stored only as a hash. A reset ends every session and does not sign in, so two-step sign-in still applies. A reset of an unverified account removes the providers linked before the address was proved. A member of a tenant that enforces single sign-on gets no reset. | deployment |
|
|
125
126
|
| A member acts beyond their job | Four roles: `readonly` reads, `reviewer` also publishes policy versions, `admin` also manages keys and members below owner, `owner` also manages billing and owners. A new write route needs `admin` unless it is listed. The last owner cannot be removed or demoted. | deployment |
|
|
126
127
|
| Claim an invited address to join a tenant | An invite is accepted only by an account with a verified address, and an account belongs to one tenant. | deployment |
|
|
127
128
|
| Sign in through an IdP the tenant does not own | The operator sets single sign-on, never the tenant. An IdP is trusted only for the email domains of its tenant, and a domain belongs to one tenant. The portal checks the OIDC `id_token` signature against the IdP's key set, or the signed SAML assertion through a maintained library, and ties the sign-in to the request that started it. | deployment |
|
package/docs/tutorials.md
CHANGED
|
@@ -54,6 +54,8 @@ Suggested reading order is the numbering. Output lands in `examples-out/`, which
|
|
|
54
54
|
| 42 | a first egress policy from what the agents did in observe mode | [42-egress-draft.ts](../examples/42-egress-draft.ts) | the witness observes an agent reach a docs mirror three times and a paste site once; `egress draft-policy` verifies the receipts and drafts one permit with a count and first and last time per destination, under a warning that it permits everything the agent did; the review deletes the paste site, and the enforced policy relays the mirror and refuses the paste site | `src/egress-draft.ts` |
|
|
55
55
|
| 43 | an OWASP ACS Guardian whose decisions land in a transparency log | [43-acs-guardian.ts](../examples/43-acs-guardian.ts) | a log runs under a key of its own; the ACS README's sample `steps/toolCallRequest` piped through `agent-custody acs` is allowed, its receipt carries the session's `chain_hash`, and it verifies offline with only the Guardian's and the log's public keys; in one session a read outside `/reports` is denied, a result for an allowed request passes, and a result for an unknown request is denied; a consistency proof shows the log after the deny extends the log that held the first decision (ACS issue #18, directions 1 and 3) | `src/acs.ts`, `src/config.ts` |
|
|
56
56
|
| 44 | the egress witness deciding by Rego | [44-egress-rego.ts](../examples/44-egress-rego.ts) | `policyFile: "policy.rego"`: the witness compiles it with `opa build`; a Rego `deny` refuses CONNECT api.stripe.com:443 with its string as the reason, an `allow` relays the docs mirror for the agent the credential proved, a guessed secret naming that agent is the principal `"unknown"` and gets 407, and an edit that does not compile leaves the policy in force; the refusal verifies | `src/egress.ts`, `src/policy-rego.ts` |
|
|
57
|
+
| 45 | reading another project's records: a Perathos session log | [45-perathos-log.ts](../examples/45-perathos-log.ts) | a session written to the Perathos receipt spec (two calls, one denied by its guard, two signed checkpoints) verifies with the recorder's key pinned and its head witness; the report labels it as recorded inside the agent's host; a log cut back to the first checkpoint still chains but fails against the head witness; a denied delete edited to allow, hash recomputed, breaks the next `prev_hash` | `src/perathos.ts` |
|
|
58
|
+
| 46 | what the policy would have denied in past Claude Code sessions, read-only | [46-audit-sessions.ts](../examples/46-audit-sessions.ts) | three Claude Code transcripts written the way Claude Code writes them (two projects, a subagent, a repeated call); `audit-sessions` reads them against the starter policy and lists a force push and a `terraform destroy` with their rules and reasons; `--counts` shows numbers only; a stale transcript outside `--since 7d` is skipped; the output says a transcript is not a receipt | `src/session-audit.ts`, `src/deny-report.ts` |
|
|
57
59
|
|
|
58
60
|
## How policies are defined, in one paragraph
|
|
59
61
|
|
package/docs/usage.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Running the gateway
|
|
2
|
+
|
|
3
|
+
> How it works and when to use it. Every field, route, and flag is in [the reference](../../../site/reference/gateway.md).
|
|
2
4
|
|
|
3
5
|
This page covers the gateway, the out-of-process producer. For the in-process interceptor that hooks Claude Code, the Claude Agent SDK, or any framework's tool functions, see [sdk.md](sdk.md).
|
|
4
6
|
|
package/docs/verification.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-custody/receipts",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.6",
|
|
4
4
|
"mcpName": "io.github.svayatta/agent-custody",
|
|
5
5
|
"description": "Proof of what your AI agents did. Give your agents real power, without losing control of them: signed, verifiable receipts for tool calls, an MCP gateway with Cedar or Rego policy, and a Merkle transparency log.",
|
|
6
6
|
"license": "Apache-2.0",
|