@catp-protocol/cli 0.2.1 → 0.3.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/dist/adapters/claude-code.d.ts +3 -0
- package/dist/adapters/claude-code.d.ts.map +1 -0
- package/dist/adapters/claude-code.js +36 -0
- package/dist/adapters/claude-code.js.map +1 -0
- package/dist/adapters/index.d.ts +5 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +15 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/registry.d.ts +5 -0
- package/dist/adapters/registry.d.ts.map +1 -0
- package/dist/adapters/registry.js +18 -0
- package/dist/adapters/registry.js.map +1 -0
- package/dist/audit/logger.d.ts +5 -4
- package/dist/audit/logger.d.ts.map +1 -1
- package/dist/audit/logger.js +6 -6
- package/dist/audit/logger.js.map +1 -1
- package/dist/cli.js +67 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/anchor.js +8 -8
- package/dist/commands/authorization.d.ts +5 -0
- package/dist/commands/authorization.d.ts.map +1 -1
- package/dist/commands/authorization.js +167 -10
- package/dist/commands/authorization.js.map +1 -1
- package/dist/commands/event.d.ts +18 -0
- package/dist/commands/event.d.ts.map +1 -0
- package/dist/commands/event.js +78 -0
- package/dist/commands/event.js.map +1 -0
- package/dist/commands/init.d.ts +6 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +20 -3
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/log.d.ts +23 -0
- package/dist/commands/log.d.ts.map +1 -1
- package/dist/commands/log.js +83 -8
- package/dist/commands/log.js.map +1 -1
- package/dist/commands/receipt.d.ts +52 -0
- package/dist/commands/receipt.d.ts.map +1 -0
- package/dist/commands/receipt.js +255 -0
- package/dist/commands/receipt.js.map +1 -0
- package/dist/commands/validate.d.ts +2 -0
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +12 -1
- package/dist/commands/validate.js.map +1 -1
- package/dist/commands/witness.d.ts +8 -0
- package/dist/commands/witness.d.ts.map +1 -1
- package/dist/commands/witness.js +49 -0
- package/dist/commands/witness.js.map +1 -1
- package/dist/enforcement/core.d.ts +11 -0
- package/dist/enforcement/core.d.ts.map +1 -0
- package/dist/enforcement/core.js +21 -0
- package/dist/enforcement/core.js.map +1 -0
- package/dist/hook/post.d.ts +5 -1
- package/dist/hook/post.d.ts.map +1 -1
- package/dist/hook/post.js +10 -18
- package/dist/hook/post.js.map +1 -1
- package/dist/hook/pre.d.ts +5 -1
- package/dist/hook/pre.d.ts.map +1 -1
- package/dist/hook/pre.js +12 -25
- package/dist/hook/pre.js.map +1 -1
- package/dist/hook/runtime.d.ts +4 -0
- package/dist/hook/runtime.d.ts.map +1 -0
- package/dist/hook/runtime.js +22 -0
- package/dist/hook/runtime.js.map +1 -0
- package/dist/policy/engine.d.ts +3 -2
- package/dist/policy/engine.d.ts.map +1 -1
- package/dist/policy/engine.js +3 -3
- package/dist/policy/engine.js.map +1 -1
- package/dist/policy/types.d.ts +0 -5
- package/dist/policy/types.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +35 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +2 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/runtime/validate.d.ts +8 -0
- package/dist/runtime/validate.d.ts.map +1 -0
- package/dist/runtime/validate.js +43 -0
- package/dist/runtime/validate.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code.d.ts","sourceRoot":"","sources":["../../src/adapters/claude-code.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA4B,MAAM,qBAAqB,CAAC;AAQpF,eAAO,MAAM,iBAAiB,EAAE,cAQ/B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const claudeCodeAdapter = {
|
|
2
|
+
runtime: "claude-code",
|
|
3
|
+
fromPreToolUse(input) {
|
|
4
|
+
return toToolAction(input, "pre");
|
|
5
|
+
},
|
|
6
|
+
fromPostToolUse(input) {
|
|
7
|
+
return toToolAction(input, "post");
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
function toToolAction(input, phase) {
|
|
11
|
+
if (!isClaudeCodeHookInput(input)) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
runtime: claudeCodeAdapter.runtime,
|
|
16
|
+
phase,
|
|
17
|
+
sessionId: input.session_id,
|
|
18
|
+
toolName: input.tool_name,
|
|
19
|
+
toolInput: input.tool_input,
|
|
20
|
+
raw: input,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function isClaudeCodeHookInput(input) {
|
|
24
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const value = input;
|
|
28
|
+
return (typeof value.tool_name === "string" &&
|
|
29
|
+
!!value.tool_name &&
|
|
30
|
+
isRecord(value.tool_input) &&
|
|
31
|
+
(value.session_id === undefined || typeof value.session_id === "string"));
|
|
32
|
+
}
|
|
33
|
+
function isRecord(value) {
|
|
34
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=claude-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/adapters/claude-code.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,iBAAiB,GAAmB;IAC/C,OAAO,EAAE,aAAa;IACtB,cAAc,CAAC,KAAc;QAC3B,OAAO,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IACD,eAAe,CAAC,KAAc;QAC5B,OAAO,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;CACF,CAAC;AAEF,SAAS,YAAY,CAAC,KAAc,EAAE,KAAmB;IACvD,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,OAAO,EAAE,iBAAiB,CAAC,OAAO;QAClC,KAAK;QACL,SAAS,EAAE,KAAK,CAAC,UAAU;QAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS;QACzB,SAAS,EAAE,KAAK,CAAC,UAAU;QAC3B,GAAG,EAAE,KAAK;KACX,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc;IAC3C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,KAAgC,CAAC;IAC/C,OAAO,CACL,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ;QACnC,CAAC,CAAC,KAAK,CAAC,SAAS;QACjB,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;QAC1B,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ,CAAC,CACzE,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RuntimeAdapter } from "../runtime/types.js";
|
|
2
|
+
export declare function getRuntimeAdapter(runtime: string): RuntimeAdapter | null;
|
|
3
|
+
export declare function supportedRuntimeAdapters(): string[];
|
|
4
|
+
export declare function formatSupportedRuntimeAdapters(): string;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAExE;AAED,wBAAgB,wBAAwB,IAAI,MAAM,EAAE,CAEnD;AAED,wBAAgB,8BAA8B,IAAI,MAAM,CAKvD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { claudeCodeAdapter } from "./claude-code.js";
|
|
2
|
+
const ADAPTERS = [claudeCodeAdapter];
|
|
3
|
+
export function getRuntimeAdapter(runtime) {
|
|
4
|
+
return ADAPTERS.find((adapter) => adapter.runtime === runtime) ?? null;
|
|
5
|
+
}
|
|
6
|
+
export function supportedRuntimeAdapters() {
|
|
7
|
+
return ADAPTERS.map((adapter) => adapter.runtime);
|
|
8
|
+
}
|
|
9
|
+
export function formatSupportedRuntimeAdapters() {
|
|
10
|
+
return [
|
|
11
|
+
"Supported runtime adapters:",
|
|
12
|
+
...supportedRuntimeAdapters().map((runtime) => `- ${runtime}`),
|
|
13
|
+
].join("\n") + "\n";
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,QAAQ,GAAG,CAAC,iBAAiB,CAAU,CAAC;AAE9C,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,IAAI,IAAI,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,wBAAwB;IACtC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,OAAO;QACL,6BAA6B;QAC7B,GAAG,wBAAwB,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,OAAO,EAAE,CAAC;KAC/D,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RuntimeAdapter, RuntimePhase, ToolAction } from "../runtime/types.js";
|
|
2
|
+
export declare function listRuntimeAdapters(): string[];
|
|
3
|
+
export declare function getRuntimeAdapter(name: string): RuntimeAdapter | null;
|
|
4
|
+
export declare function adaptRuntimePayload(adapterName: string, phase: RuntimePhase, payload: unknown): ToolAction | null;
|
|
5
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/adapters/registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIpF,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAErE;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,OAAO,GACf,UAAU,GAAG,IAAI,CAQnB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { claudeCodeAdapter } from "./claude-code.js";
|
|
2
|
+
const adapters = [claudeCodeAdapter];
|
|
3
|
+
export function listRuntimeAdapters() {
|
|
4
|
+
return adapters.map((adapter) => adapter.runtime);
|
|
5
|
+
}
|
|
6
|
+
export function getRuntimeAdapter(name) {
|
|
7
|
+
return adapters.find((adapter) => adapter.runtime === name) ?? null;
|
|
8
|
+
}
|
|
9
|
+
export function adaptRuntimePayload(adapterName, phase, payload) {
|
|
10
|
+
const adapter = getRuntimeAdapter(adapterName);
|
|
11
|
+
if (!adapter) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return phase === "post"
|
|
15
|
+
? adapter.fromPostToolUse(payload)
|
|
16
|
+
: adapter.fromPreToolUse(payload);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/adapters/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,QAAQ,GAAqB,CAAC,iBAAiB,CAAC,CAAC;AAEvD,MAAM,UAAU,mBAAmB;IACjC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,WAAmB,EACnB,KAAmB,EACnB,OAAgB;IAEhB,MAAM,OAAO,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAC/C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,KAAK,MAAM;QACrB,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC;QAClC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC"}
|
package/dist/audit/logger.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { AuditEntry, AuthorizationAction
|
|
1
|
+
import type { AuditEntry, AuthorizationAction } from "../policy/types.js";
|
|
2
|
+
import type { ToolAction } from "../runtime/types.js";
|
|
2
3
|
export declare function computeCommitment(tool: string, decision: "allow" | "deny", ts: string, prev?: string, ruleMatched?: string | null, inputSummary?: string): string;
|
|
3
|
-
export declare function summarizeInput(input:
|
|
4
|
+
export declare function summarizeInput(input: ToolAction): string;
|
|
4
5
|
export declare function auditDir(agentId: string): string;
|
|
5
6
|
export declare function getLastCommitment(agentId: string): string;
|
|
6
7
|
export declare function appendAuditEntry(agentId: string, entry: AuditEntry): void;
|
|
7
|
-
export declare function buildEntry(input:
|
|
8
|
-
export declare function extractAuthorizationAction(input:
|
|
8
|
+
export declare function buildEntry(input: ToolAction, decision: "allow" | "deny", ruleMatched: string | null, prevCommitment?: string): AuditEntry;
|
|
9
|
+
export declare function extractAuthorizationAction(input: ToolAction): AuthorizationAction | undefined;
|
|
9
10
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/audit/logger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/audit/logger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMtD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,OAAO,GAAG,MAAM,EAC1B,EAAE,EAAE,MAAM,EACV,IAAI,GAAE,MAAY,EAClB,WAAW,GAAE,MAAM,GAAG,IAAW,EACjC,YAAY,GAAE,MAAW,GACxB,MAAM,CAIR;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAGxD;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGhD;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAYzD;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAIzE;AAED,wBAAgB,UAAU,CACxB,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,OAAO,GAAG,MAAM,EAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,cAAc,GAAE,MAAY,GAC3B,UAAU,CAgBZ;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,UAAU,GAAG,mBAAmB,GAAG,SAAS,CAsB7F"}
|
package/dist/audit/logger.js
CHANGED
|
@@ -2,17 +2,17 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { appendFileSync, mkdirSync, readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { auditDirForDate } from "./paths.js";
|
|
5
|
-
// Phase 0: SHA-256 commitment
|
|
5
|
+
// Phase 0: SHA-256 audit commitment.
|
|
6
6
|
// Chains on fields stored in the log (tool, decision, ts, prev) so the chain
|
|
7
7
|
// is verifiable from the JSONL file alone without replaying tool_input.
|
|
8
|
-
//
|
|
8
|
+
// A future proof bridge can add Poseidon commitments over the full action witness.
|
|
9
9
|
export function computeCommitment(tool, decision, ts, prev = "0", ruleMatched = null, inputSummary = "") {
|
|
10
10
|
return createHash("sha256")
|
|
11
11
|
.update(JSON.stringify({ tool, decision, ts, ruleMatched, inputSummary, prev }))
|
|
12
12
|
.digest("hex");
|
|
13
13
|
}
|
|
14
14
|
export function summarizeInput(input) {
|
|
15
|
-
const raw = JSON.stringify(input.
|
|
15
|
+
const raw = JSON.stringify(input.toolInput);
|
|
16
16
|
return raw.length > 200 ? raw.slice(0, 200) + "…" : raw;
|
|
17
17
|
}
|
|
18
18
|
export function auditDir(agentId) {
|
|
@@ -44,10 +44,10 @@ export function buildEntry(input, decision, ruleMatched, prevCommitment = "0") {
|
|
|
44
44
|
const inputSummary = summarizeInput(input);
|
|
45
45
|
const entry = {
|
|
46
46
|
ts,
|
|
47
|
-
tool: input.
|
|
47
|
+
tool: input.toolName,
|
|
48
48
|
decision,
|
|
49
49
|
rule_matched: ruleMatched,
|
|
50
|
-
commitment: computeCommitment(input.
|
|
50
|
+
commitment: computeCommitment(input.toolName, decision, ts, prevCommitment, ruleMatched, inputSummary),
|
|
51
51
|
input_summary: inputSummary,
|
|
52
52
|
};
|
|
53
53
|
const authorization = extractAuthorizationAction(input);
|
|
@@ -57,7 +57,7 @@ export function buildEntry(input, decision, ruleMatched, prevCommitment = "0") {
|
|
|
57
57
|
return entry;
|
|
58
58
|
}
|
|
59
59
|
export function extractAuthorizationAction(input) {
|
|
60
|
-
const candidate = input.
|
|
60
|
+
const candidate = input.toolInput.catp_authorization ?? input.toolInput.authorization;
|
|
61
61
|
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) {
|
|
62
62
|
return undefined;
|
|
63
63
|
}
|
package/dist/audit/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/audit/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/audit/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClE,OA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E,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -3,12 +3,14 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import { runPreHook } from "./hook/pre.js";
|
|
5
5
|
import { runPostHook } from "./hook/post.js";
|
|
6
|
+
import { formatSupportedRuntimeAdapters, getRuntimeAdapter, supportedRuntimeAdapters } from "./adapters/index.js";
|
|
6
7
|
import { cmdInit } from "./commands/init.js";
|
|
7
8
|
import { cmdValidate } from "./commands/validate.js";
|
|
8
|
-
import { cmdLogShow, cmdLogVerify } from "./commands/log.js";
|
|
9
|
+
import { cmdLogExport, cmdLogShow, cmdLogVerify } from "./commands/log.js";
|
|
9
10
|
import { cmdAnchor } from "./commands/anchor.js";
|
|
10
11
|
import { cmdWitness } from "./commands/witness.js";
|
|
11
12
|
import { cmdProveAuthorization, cmdVerifyAuthorization } from "./commands/authorization.js";
|
|
13
|
+
import { cmdReceiptIssue, cmdReceiptKeygen, cmdReceiptSign, cmdReceiptVerify } from "./commands/receipt.js";
|
|
12
14
|
const require = createRequire(import.meta.url);
|
|
13
15
|
const { version } = require("../package.json");
|
|
14
16
|
const program = new Command();
|
|
@@ -19,6 +21,7 @@ program
|
|
|
19
21
|
program
|
|
20
22
|
.command("init")
|
|
21
23
|
.description("Scaffold a catp-policy.toml in the current directory")
|
|
24
|
+
.option("--authorization", "include example authorization_groth16_v1 policy fields")
|
|
22
25
|
.action(cmdInit);
|
|
23
26
|
program
|
|
24
27
|
.command("validate")
|
|
@@ -26,26 +29,54 @@ program
|
|
|
26
29
|
.option("-f, --file <path>", "path to policy file (default: auto-discover)")
|
|
27
30
|
.action(cmdValidate);
|
|
28
31
|
const hook = program.command("hook").description("Hook handlers called by agent frameworks");
|
|
32
|
+
function resolveHookAdapter(runtime) {
|
|
33
|
+
const adapter = getRuntimeAdapter(runtime);
|
|
34
|
+
if (!adapter) {
|
|
35
|
+
process.stderr.write(`catp: unsupported runtime adapter "${runtime}". Supported: ${supportedRuntimeAdapters().join(", ")}\n`);
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
return adapter;
|
|
39
|
+
}
|
|
40
|
+
hook
|
|
41
|
+
.command("runtimes")
|
|
42
|
+
.description("List supported runtime adapter ids")
|
|
43
|
+
.action(() => {
|
|
44
|
+
process.stdout.write(formatSupportedRuntimeAdapters());
|
|
45
|
+
});
|
|
29
46
|
hook
|
|
30
47
|
.command("pre")
|
|
31
48
|
.description("PreToolUse handler — reads stdin JSON, allows or blocks")
|
|
32
|
-
.
|
|
49
|
+
.option("--runtime <id>", "runtime adapter id", "claude-code")
|
|
50
|
+
.action((opts) => {
|
|
51
|
+
runPreHook({ adapter: resolveHookAdapter(opts.runtime) }).catch(() => process.exit(0));
|
|
52
|
+
});
|
|
33
53
|
hook
|
|
34
54
|
.command("post")
|
|
35
55
|
.description("PostToolUse handler — reads stdin JSON, records to audit log")
|
|
36
|
-
.
|
|
56
|
+
.option("--runtime <id>", "runtime adapter id", "claude-code")
|
|
57
|
+
.action((opts) => {
|
|
58
|
+
runPostHook({ adapter: resolveHookAdapter(opts.runtime) }).catch(() => process.exit(0));
|
|
59
|
+
});
|
|
37
60
|
const log = program.command("log").description("Audit log commands");
|
|
38
61
|
log
|
|
39
62
|
.command("show")
|
|
40
63
|
.description("Display recent audit log entries")
|
|
41
64
|
.option("-n, --lines <n>", "number of lines to show", "50")
|
|
42
65
|
.option("--agent <id>", "agent id (default: from policy file)")
|
|
66
|
+
.option("--commitments", "show full audit entry commitments")
|
|
43
67
|
.action(cmdLogShow);
|
|
44
68
|
log
|
|
45
69
|
.command("verify")
|
|
46
70
|
.description("Verify commitment chain integrity")
|
|
47
71
|
.option("--agent <id>", "agent id (default: from policy file)")
|
|
48
72
|
.action(cmdLogVerify);
|
|
73
|
+
log
|
|
74
|
+
.command("export")
|
|
75
|
+
.description("Export a deterministic audit entry bundle by commitment")
|
|
76
|
+
.requiredOption("--commitment <hex>", "audit entry commitment to export")
|
|
77
|
+
.option("--agent <id>", "agent id (default: from policy file)")
|
|
78
|
+
.option("--out <path>", "write audit export JSON to file instead of stdout")
|
|
79
|
+
.action(cmdLogExport);
|
|
49
80
|
program
|
|
50
81
|
.command("anchor")
|
|
51
82
|
.description("Batch audit commitments into a Merkle root and submit on-chain")
|
|
@@ -92,6 +123,39 @@ verify
|
|
|
92
123
|
.option("--check-audit", "check that auditCommitment exists in the local audit log")
|
|
93
124
|
.option("--audit-agent <id>", "agent id to use for --check-audit")
|
|
94
125
|
.action(cmdVerifyAuthorization);
|
|
126
|
+
const receipt = program.command("receipt").description("Signed authorization receipt commands");
|
|
127
|
+
receipt
|
|
128
|
+
.command("keygen")
|
|
129
|
+
.description("Generate an Ed25519 key pair for signing CATP receipts")
|
|
130
|
+
.option("--private-key <path>", "private key output path", "catp-receipt-private.pem")
|
|
131
|
+
.option("--public-key <path>", "public key output path", "catp-receipt-public.pem")
|
|
132
|
+
.action(cmdReceiptKeygen);
|
|
133
|
+
receipt
|
|
134
|
+
.command("sign")
|
|
135
|
+
.description("Sign a CATP audit export as an authorization receipt")
|
|
136
|
+
.requiredOption("--audit-export <path>", "catp_audit_export_v1 JSON from catp log export")
|
|
137
|
+
.requiredOption("--private-key <path>", "Ed25519 private key PEM")
|
|
138
|
+
.option("-f, --file <path>", "path to catp-policy.toml to bind into the receipt")
|
|
139
|
+
.option("--out <path>", "write receipt JSON to file instead of stdout")
|
|
140
|
+
.action(cmdReceiptSign);
|
|
141
|
+
receipt
|
|
142
|
+
.command("issue")
|
|
143
|
+
.description("Export an audit entry by commitment and sign it as an authorization receipt")
|
|
144
|
+
.requiredOption("--commitment <hex>", "audit entry commitment to issue a receipt for")
|
|
145
|
+
.requiredOption("--private-key <path>", "Ed25519 private key PEM")
|
|
146
|
+
.option("--agent <id>", "agent id (default: from policy file)")
|
|
147
|
+
.option("-f, --file <path>", "path to catp-policy.toml to bind into the receipt")
|
|
148
|
+
.option("--audit-export-out <path>", "also write the generated catp_audit_export_v1 JSON")
|
|
149
|
+
.option("--out <path>", "write receipt JSON to file instead of stdout")
|
|
150
|
+
.action(cmdReceiptIssue);
|
|
151
|
+
receipt
|
|
152
|
+
.command("verify")
|
|
153
|
+
.description("Verify a signed CATP authorization receipt")
|
|
154
|
+
.requiredOption("--receipt <path>", "catp_authorization_receipt_v1 JSON")
|
|
155
|
+
.option("--public-key <path>", "Ed25519 public key PEM; defaults to publicKeyPem embedded in the receipt")
|
|
156
|
+
.option("--audit-export <path>", "also check the receipt against a catp_audit_export_v1 JSON bundle")
|
|
157
|
+
.option("-f, --file <path>", "also check the receipt against a catp-policy.toml commitment")
|
|
158
|
+
.action(cmdReceiptVerify);
|
|
95
159
|
program.parseAsync(process.argv).catch((err) => {
|
|
96
160
|
process.stderr.write(`catp: ${err.message}\n`);
|
|
97
161
|
process.exit(1);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE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,EAAE,mDAAmD,CAAC;KAChF,MAAM,CAAC,2BAA2B,EAAE,oDAAoD,CAAC;KACzF,MAAM,CAAC,cAAc,EAAE,8CAA8C,CAAC;KACtE,MAAM,CAAC,eAAe,CAAC,CAAC;AAE3B,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,4CAA4C,CAAC;KACzD,cAAc,CAAC,kBAAkB,EAAE,oCAAoC,CAAC;KACxE,MAAM,CAAC,qBAAqB,EAAE,0EAA0E,CAAC;KACzG,MAAM,CAAC,uBAAuB,EAAE,mEAAmE,CAAC;KACpG,MAAM,CAAC,mBAAmB,EAAE,8DAA8D,CAAC;KAC3F,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE5B,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC7C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,SAAU,GAAa,CAAC,OAAO,IAAI,CAAC,CAAC;IAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/commands/anchor.js
CHANGED
|
@@ -54,21 +54,21 @@ export function merkleRoot(commitments) {
|
|
|
54
54
|
if (commitments.length === 0) {
|
|
55
55
|
return `0x${"00".repeat(32)}`;
|
|
56
56
|
}
|
|
57
|
-
let
|
|
57
|
+
let level = commitments.map((c) => {
|
|
58
58
|
const b = Buffer.from(c, "hex");
|
|
59
59
|
return b.length === 32 ? b : createHash("sha256").update(c).digest();
|
|
60
60
|
});
|
|
61
|
-
while (
|
|
62
|
-
if (
|
|
63
|
-
|
|
61
|
+
while (level.length > 1) {
|
|
62
|
+
if (level.length % 2 !== 0) {
|
|
63
|
+
level.push(level[level.length - 1]);
|
|
64
64
|
}
|
|
65
65
|
const next = [];
|
|
66
|
-
for (let i = 0; i <
|
|
67
|
-
next.push(createHash("sha256").update(
|
|
66
|
+
for (let i = 0; i < level.length; i += 2) {
|
|
67
|
+
next.push(createHash("sha256").update(level[i]).update(level[i + 1]).digest());
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
level = next;
|
|
70
70
|
}
|
|
71
|
-
return `0x${
|
|
71
|
+
return `0x${level[0].toString("hex")}`;
|
|
72
72
|
}
|
|
73
73
|
async function submitOnChain(root, rpcUrl, privateKey, contractAddress) {
|
|
74
74
|
const { createPublicClient, createWalletClient, http, defineChain } = await import("viem");
|
|
@@ -65,4 +65,9 @@ export declare function cmdVerifyAuthorization(opts: {
|
|
|
65
65
|
checkAudit?: boolean;
|
|
66
66
|
auditAgent?: string;
|
|
67
67
|
}): void;
|
|
68
|
+
export declare function formatAuthorizationManifestSummary(manifest: AuthorizationProofManifest, opts?: {
|
|
69
|
+
extraLines?: string[];
|
|
70
|
+
includeStatus?: boolean;
|
|
71
|
+
manifestPath?: string;
|
|
72
|
+
}): string;
|
|
68
73
|
//# sourceMappingURL=authorization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../../src/commands/authorization.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../../src/commands/authorization.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,0BAA0B;IACzC,eAAe,EAAE,sCAAsC,CAAC;IACxD,YAAY,EAAE,0BA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