@axtary/cli 0.1.0 → 0.2.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 (48) hide show
  1. package/README.md +122 -12
  2. package/dist/bin.js +10 -0
  3. package/dist/bin.js.map +1 -1
  4. package/dist/claude-code-hook.d.ts +20 -0
  5. package/dist/claude-code-hook.d.ts.map +1 -1
  6. package/dist/claude-code-hook.js +114 -34
  7. package/dist/claude-code-hook.js.map +1 -1
  8. package/dist/codex-hook.d.ts +48 -0
  9. package/dist/codex-hook.d.ts.map +1 -0
  10. package/dist/codex-hook.js +259 -0
  11. package/dist/codex-hook.js.map +1 -0
  12. package/dist/credentials.d.ts +101 -0
  13. package/dist/credentials.d.ts.map +1 -0
  14. package/dist/credentials.js +277 -0
  15. package/dist/credentials.js.map +1 -0
  16. package/dist/cursor-hook.d.ts +51 -0
  17. package/dist/cursor-hook.d.ts.map +1 -0
  18. package/dist/cursor-hook.js +214 -0
  19. package/dist/cursor-hook.js.map +1 -0
  20. package/dist/hook-install.d.ts +21 -0
  21. package/dist/hook-install.d.ts.map +1 -0
  22. package/dist/hook-install.js +179 -0
  23. package/dist/hook-install.js.map +1 -0
  24. package/dist/index.d.ts +768 -7
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +6132 -1050
  27. package/dist/index.js.map +1 -1
  28. package/dist/mcp-fs-normalize.d.ts +18 -0
  29. package/dist/mcp-fs-normalize.d.ts.map +1 -0
  30. package/dist/mcp-fs-normalize.js +39 -0
  31. package/dist/mcp-fs-normalize.js.map +1 -0
  32. package/dist/mcp-oauth.d.ts +67 -0
  33. package/dist/mcp-oauth.d.ts.map +1 -0
  34. package/dist/mcp-oauth.js +242 -0
  35. package/dist/mcp-oauth.js.map +1 -0
  36. package/dist/oauth.d.ts +90 -0
  37. package/dist/oauth.d.ts.map +1 -0
  38. package/dist/oauth.js +339 -0
  39. package/dist/oauth.js.map +1 -0
  40. package/dist/render.d.ts +103 -0
  41. package/dist/render.d.ts.map +1 -0
  42. package/dist/render.js +172 -0
  43. package/dist/render.js.map +1 -0
  44. package/dist/shell-file-normalize.d.ts +21 -0
  45. package/dist/shell-file-normalize.d.ts.map +1 -0
  46. package/dist/shell-file-normalize.js +269 -0
  47. package/dist/shell-file-normalize.js.map +1 -0
  48. package/package.json +14 -9
package/README.md CHANGED
@@ -13,34 +13,144 @@ axtary init # scaffold a starter axtary.yml
13
13
  axtary demo # run fake GitHub/Slack/Linear actions through the proxy + ledger
14
14
  ```
15
15
 
16
- `init` then `demo` reaches a first blocked action in under a minute with no credentials. The full rail — proxy, gating a real agent via the Claude Code hook or the MCP wrapper — is in [docs/quickstart.md](https://github.com/axtary/axtary/blob/main/docs/quickstart.md).
16
+ `init` then `demo` reaches a first blocked action in under a minute with no credentials. The full rail — proxy, gating a real agent via the Claude Code hook or the MCP wrapper — is in the [Quickstart](https://www.axtary.com/docs/quickstart).
17
+
18
+ To start from a scoped policy, use one of the PRD templates:
19
+
20
+ ```sh
21
+ axtary init --template repo-only-coding
22
+ axtary policy test .axtary/policy-tests/repo-only-coding.policies.test.yml --config axtary.yml
23
+ axtary demo --config axtary.yml --template repo-only-coding
24
+ ```
25
+
26
+ Available templates: `repo-only-coding`, `staging-reads`, `incident-investigation`, `ticket-updates`, `doc-search`, and `guarded-prod`.
17
27
 
18
28
  ## Commands
19
29
 
20
30
  ```sh
21
- axtary init
31
+ axtary init [--template repo-only-coding|staging-reads|incident-investigation|ticket-updates|doc-search|guarded-prod]
22
32
  axtary demo --config axtary.yml --json
33
+ axtary demo --config axtary.yml --template repo-only-coding
23
34
  axtary doctor connectors --config axtary.yml --json
24
35
  axtary proxy --config axtary.yml
36
+ axtary revoke ap_<id> [--reason "..."] [--by user:operator]
37
+ axtary revocations [--json]
38
+ axtary issuer-keys [--rotate] [--retire-after 1200]
39
+ axtary status [--json]
40
+ axtary caep-map --issuer https://idp.example --subject '{"format":"opaque","id":"session"}' --root ap_<id>
25
41
  axtary smoke --config axtary.yml
42
+ axtary policy simulate action.json --config examples/axtary.policies.yml
43
+ axtary policy test examples/policies.test.yml --config examples/axtary.policies.yml
26
44
  axtary test-policy --config axtary.yml --fixtures examples/policy-fixtures
27
45
  axtary run workflow github-pr-review --real --config examples/axtary.real.yml [--tamper]
46
+ axtary run workflow github-depth --real --config examples/axtary.real.yml --repo org/repo
47
+ axtary run workflow postgres-read --real --config examples/axtary.postgres.yml --database appdb --statement 'SELECT id FROM public.items WHERE tenant_id = $1' --parameters '["tenant-a"]'
48
+ axtary hook install claude --owner user:operator --repo org/repo
49
+ axtary hook install cursor --owner user:operator --repo org/repo
50
+ axtary hook install codex --owner user:operator --repo org/repo
28
51
  axtary hook claude-code --proxy http://127.0.0.1:7331
29
- axtary mcp serve --config axtary.yml [--wrap '<upstream mcp command>']
52
+ axtary hook cursor --proxy http://127.0.0.1:7331
53
+ axtary hook codex --proxy http://127.0.0.1:7331
54
+ axtary mcp serve --config axtary.yml [--wrap '<upstream mcp command>' | --wrap-url https://host/mcp]
55
+ axtary mcp login --wrap-url https://host/mcp [--scope 'a b']
56
+ axtary mcp sessions [--json]
57
+ axtary mcp logout --wrap-url https://host/mcp
58
+ axtary mcp pins [--pins axtary.mcp-pins.json] [--json]
59
+ axtary mcp trust-publisher --publisher mcp-publisher://acme --jwks publisher.jwks.json
60
+ axtary mcp publishers
61
+ axtary mcp verify-definition --definition tool.json --statement tool.jwt --publisher mcp-publisher://acme
62
+ axtary mcp review --wrap-url https://host/mcp [--signed-definitions .axtary/mcp-signed-definitions.json] [--accept]
63
+ axtary mcp conformance --wrap-url https://host/mcp --tool read_tool --arguments '{}' [--accept]
64
+ axtary mcp drift-demo [--json]
65
+ axtary connect linear [--client-id <id> | --client-id-env NAME]
66
+ axtary connect slack --redirect-uri https://<tunnel>/callback
67
+ axtary connect jira --redirect-uri https://<tunnel>/callback [--cloud-id ID]
68
+ axtary connect drive --redirect-uri https://<tunnel>/callback
69
+ axtary connections [--json]
70
+ axtary disconnect <provider>
71
+ axtary run workflow drive-read --real --config examples/axtary.drive.yml
72
+ axtary attest-ledger --ledger .axtary/actions.jsonl --out attestation.json
73
+ axtary verify-export attestation.json
74
+ axtary prove-inclusion attestation.json --record ap_<jti> --out proof.json
75
+ axtary prove-consistency first.json second.json --out proof.json
76
+ axtary verify-proof proof.json --bundle attestation.json
77
+ axtary forensics attestation.json
30
78
  axtary export-ledger --format siem-jsonl
31
79
  axtary sync-ledger --endpoint https://app.example/api/ledger/sync
80
+ axtary export-otel --endpoint http://127.0.0.1:4318/v1/traces
32
81
  ```
33
82
 
34
- - `init` scaffolds a starter `axtary.yml` and prints the quickstart rail (`docs/quickstart.md`).
35
- - `demo` loads config, creates an ephemeral signing key, runs fake GitHub, Slack, Linear, and Jira actions through the proxy, writes the local JSONL ledger, and prints a structured result.
36
- - `doctor connectors` reports per-provider readiness — mode, missing env names, required scopes, smoke commands — without leaking secret values.
37
- - `proxy` starts a long-running local HTTP enforcement point with `GET /health`, `GET /state`, `POST /actions` (authorize + execute), and `POST /authorize` (decision, ActionPass, and ledger record without execution the agent-hook path). It uses fake SaaS adapters by default and can route GitHub, Slack, Linear, AWS, GCP, and local docs actions when their adapter modes are enabled. File-backed configs are cached and policy is reloaded when `axtary.yml` changes.
38
- - `smoke` validates configured providers without writes: GitHub REST calls `/user`, Slack Web calls `auth.test`, Linear GraphQL queries `viewer`, AWS calls STS `GetCallerIdentity`, GCP checks project access, and local docs checks configured roots.
39
- - `test-policy` evaluates JSON fixtures against the loaded YAML policy and fails when an expected decision or reason differs.
83
+ - `init` scaffolds a starter `axtary.yml` and prints the quickstart rail (`docs/quickstart.md`). `--template <name>` applies one of the six reusable scope templates and writes `.axtary/policy-tests/<name>.policies.test.yml` so the scaffold can be tested immediately.
84
+ - `demo` loads config, creates an ephemeral signing key, runs fake GitHub, Slack, Linear, and Jira actions through the proxy, writes the local JSONL ledger, and prints a structured result. `demo --template <name>` is policy-only: it runs the template's representative allow/deny fixtures and makes no provider calls.
85
+ - `doctor connectors` reports per-provider readiness — mode, missing env names,
86
+ required scopes, smoke commands without leaking secret values. Jira and
87
+ Linear, Postgres, and Google Drive plans are generated by their native connector descriptors; current
88
+ reported scopes are Jira `read:jira-work`/`write:jira-work` and Linear
89
+ `read`/`write`.
90
+ - `proxy` starts a long-running local HTTP enforcement point with `GET /health`, `GET /state`, `GET /revocations`, `GET /.well-known/jwks.json`, `GET /statuslists/actionpasses`, `POST /ssf/events`, `POST /actions` (authorize + execute), and `POST /authorize` (decision, ActionPass, and ledger record without execution — the agent-hook path). It uses fake SaaS adapters by default and can route GitHub, Slack, Linear, Jira Cloud, AWS, GCP, and local docs actions when their adapter modes are enabled. File-backed configs are cached and policy is reloaded when `axtary.yml` changes.
91
+ - `revoke` writes a durable local revocation for one ActionPass `jti`;
92
+ `revocations` lists that state. Both share
93
+ `.axtary/actionpass-trust-store.json` with the proxy and MCP wrapper by
94
+ default, or an explicit `--trust-store` path. Running processes re-check the
95
+ source on every pass presentation, so revocation takes effect without a
96
+ restart; unreadable or corrupt state blocks execution.
97
+ - With `runtime.status.enabled` (the default), the proxy issues ActionPass v2,
98
+ persists a private issuer keyring and status allocation store, publishes
99
+ public JWKS and a signed freshness-bounded status list, and updates that list
100
+ when `revoke` targets an allocated pass. `issuer-keys --rotate` changes the
101
+ durable active key; restart the proxy to begin issuing with it. CLI and HTTP
102
+ metadata never return private keys.
103
+ - `runtime.caep.enabled` opts into a generic final SSF/CAEP receiver. Configure
104
+ transmitter issuer, audience, and JWKS URI, then use `caep-map` to associate
105
+ an exact SSF subject with live root pass IDs. Valid `session-revoked` events
106
+ invalidate those roots; duplicate deliveries are idempotent. This is not a
107
+ claim of vendor-specific IdP support.
108
+ - `smoke` validates configured providers without writes: GitHub REST calls `/user`, Slack Web calls `auth.test`, Linear GraphQL queries `viewer`, Jira REST calls `/myself`, AWS calls STS `GetCallerIdentity`, GCP checks project access, and local docs checks configured roots.
109
+ - `policy simulate` dry-runs one normalized action and reports the selected decision, determining rule, every rule match/miss, and attached obligations.
110
+ - `policy test` runs a `policies.test.yml` fixture harness and exits non-zero on a decision, reason, or determining-rule mismatch, making the policy file directly CI-testable.
111
+ - `test-policy` evaluates JSON fixtures against the loaded YAML policy and fails when an expected decision or reason differs. `--parity` additionally runs the same fixtures through executable Cedar and OPA/Rego engines and fails on any cross-engine disagreement (see `examples/policies/README.md`).
40
112
  - `run workflow github-pr-review --real` executes the design-partner workflow (Linear read → docs search → GitHub branch/file/PR → approved Slack post) through proxy-compatible wiring; `--tamper` mutates the approved payload and proves the block (see `docs/sandbox-runbook.md`).
41
- - `hook claude-code` reads a Claude Code PreToolUse payload from stdin, normalizes file tools into content actions, and returns allow/ask/deny from the running proxy (see `docs/claude-code-hook.md`).
42
- - `mcp serve` runs a stdio MCP server whose wrapped tools are policy-gated at pinned definition hashes (see `docs/mcp-wrapper.md`).
43
- - `export-ledger` / `sync-ledger` export verified ledger records locally or upload them to the hosted control plane with signed sync tokens.
113
+ - `run workflow github-depth --real` is GitHub-only depth: it opens a draft PR,
114
+ then writes an inline review comment, a check run, and an issue comment each
115
+ step governed and ledgered. `run workflow postgres-read --real` runs one
116
+ parameterized SELECT through policy, ActionPass, a read-only transaction, and
117
+ RLS checks; writes are denied before execution.
118
+ - `connect <linear|slack|jira|drive>` runs the provider's browser OAuth flow and
119
+ stores the token in the local credential broker (macOS keychain or a `0600`
120
+ file) — tokens are never pasted or printed. `connections` lists connected
121
+ providers (metadata only); `disconnect <provider>` removes a stored credential.
122
+ - `hook install <claude|cursor|codex>` writes the project runtime hook config
123
+ (`.claude/settings.json`, `.cursor/hooks.json`, or `.codex/hooks.json`) with
124
+ the resolved local CLI path. It is idempotent and preserves unrelated hooks.
125
+ - `hook claude-code`, `hook cursor`, and `hook codex` read their runtime's
126
+ pre-tool payload from stdin, normalize supported file operations into content
127
+ actions, and return the runtime-specific decision from the running proxy.
128
+ - `mcp serve` runs a stdio MCP server whose stdio or Streamable HTTP upstream tools are policy-gated at persisted definition hashes (see `docs/mcp-wrapper.md`).
129
+ - `mcp trust-publisher` registers public JWKS in the local owner-readable
130
+ publisher trust store; `mcp publishers` lists identities and key ids;
131
+ `mcp verify-definition` verifies one statement against the exact definition.
132
+ - `mcp review` compares a live server's advertised definitions with persisted
133
+ pins and an optional signed-definition registry. It displays verified
134
+ publisher/semver evidence and the version-chain verdict (`continuous`,
135
+ `broken_chain`, or `version_not_incremented`); untrusted or invalid
136
+ signatures cannot be accepted.
137
+ - `mcp conformance` executes one explicitly selected live tool through pins → policy → ActionPass v1/DPoP → ledger, proves a labeled synthetic pin mismatch is quarantined, independently verifies a signed ledger export, and writes a secret-free per-server receipt for the dashboard.
138
+ - `mcp drift-demo` reproduces the tool-poisoning block in one command: the definition mutates after review, the hash drifts, and the identical call is denied before the upstream invoker runs — approved and attempted hashes land in the ledger.
139
+ - `mcp login` runs OAuth 2.1 discovery + PKCE consent for an OAuth-protected
140
+ remote MCP server and stores the bearer in the local broker; `mcp sessions`
141
+ lists sessions (resource/issuer/scopes/expiry, never tokens); `mcp logout`
142
+ deletes one; `mcp pins` lists the persisted tool-definition pins.
143
+ - `export-ledger` / `sync-ledger` export verified ledger records locally or upload them to the hosted control plane with signed sync tokens. `attest-ledger` / `verify-export` create and independently verify signed, self-contained ledger evidence.
144
+ - `prove-inclusion` / `prove-consistency` / `verify-proof` produce and
145
+ independently verify RFC 6962 Merkle inclusion and consistency proofs over
146
+ attested exports, so a third party can check one record or two heads without
147
+ trusting Axtary. `forensics` reconstructs an incident offline from the ledger:
148
+ authority attenuation, reconstructibility, and cascade containment.
149
+ - `export-otel` posts a verified ledger segment to an OTLP/HTTP trace endpoint
150
+ as payload-free GenAI `execute_tool` spans. `proxy --otlp-endpoint` streams
151
+ the same projection after each durable append. These spans carry decisions,
152
+ reasons, hashes, and audit dimensions, never payload bodies, tokens, file
153
+ contents, result rows, or raw shell commands.
44
154
 
45
155
  ## Real Provider Smoke Test
46
156
 
package/dist/bin.js CHANGED
@@ -1,4 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import { runAxtaryCli } from "./index.js";
3
+ function exitQuietlyOnBrokenPipe(stream) {
4
+ stream.on("error", (error) => {
5
+ if (error.code === "EPIPE") {
6
+ process.exit(0);
7
+ }
8
+ throw error;
9
+ });
10
+ }
11
+ exitQuietlyOnBrokenPipe(process.stdout);
12
+ exitQuietlyOnBrokenPipe(process.stderr);
3
13
  process.exitCode = await runAxtaryCli();
4
14
  //# sourceMappingURL=bin.js.map
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,CAAC,QAAQ,GAAG,MAAM,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,SAAS,uBAAuB,CAAC,MAA0B;IACzD,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAA4B,EAAE,EAAE;QAClD,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED,uBAAuB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACxC,uBAAuB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAExC,OAAO,CAAC,QAAQ,GAAG,MAAM,YAAY,EAAE,CAAC"}
@@ -11,6 +11,7 @@ export type ClaudeCodeHookPayload = {
11
11
  export type ClaudeCodeNormalization = {
12
12
  mapped: true;
13
13
  action: NormalizedAction;
14
+ actions: NormalizedAction[];
14
15
  } | {
15
16
  mapped: false;
16
17
  reason: string;
@@ -42,4 +43,23 @@ export type ClaudeCodeHookRunResult = {
42
43
  export declare function parseClaudeCodeHookPayload(payloadText: string): ClaudeCodeHookPayload;
43
44
  export declare function normalizeClaudeCodeToolCall(payload: ClaudeCodeHookPayload, options?: ClaudeCodeNormalizeOptions): ClaudeCodeNormalization;
44
45
  export declare function runClaudeCodeHook(input: ClaudeCodeHookRunInput): Promise<ClaudeCodeHookRunResult>;
46
+ export type ProxyAuthorizeHttpResponse = {
47
+ status: "authorized" | "step_up" | "blocked" | "malformed";
48
+ decision?: {
49
+ reasons?: string[];
50
+ };
51
+ ledger?: {
52
+ lineNumber?: number;
53
+ };
54
+ hints?: string[];
55
+ explanation?: {
56
+ summary?: string;
57
+ };
58
+ };
59
+ export declare const DENY_RANK = 3;
60
+ /** Severity rank for picking the most restrictive decision across ops. */
61
+ export declare function authorizeRank(status: ProxyAuthorizeHttpResponse["status"]): number;
62
+ export declare function postAuthorize(fetchImpl: typeof fetch | undefined, url: string, action: NormalizedAction, timeoutMs: number): Promise<ProxyAuthorizeHttpResponse>;
63
+ export declare function workspaceRelativePath(path: string, cwd: string | null): string;
64
+ export declare function errorReason(error: unknown): string;
45
65
  //# sourceMappingURL=claude-code-hook.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"claude-code-hook.d.ts","sourceRoot":"","sources":["../src/claude-code-hook.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,+BAA+B,+BAA+B,CAAC;AAC5E,eAAO,MAAM,iBAAiB,0BAA0B,CAAC;AACzD,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAE7C,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACtC,CA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K,GAAG,SAAS,EACnC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,0BAA0B,CAAC,CA2BrC;AA2BD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAwB9E;AAkBD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAElD"}
@@ -1,6 +1,7 @@
1
1
  import { realpathSync } from "node:fs";
2
2
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
3
3
  import { parseNormalizedAction, } from "@axtary/actionpass";
4
+ import { classifyShellFileOps, } from "./shell-file-normalize.js";
4
5
  export const CLAUDE_CODE_HOOK_SCHEMA_VERSION = "axtary.claude_code_hook.v0";
5
6
  export const DEFAULT_PROXY_URL = "http://127.0.0.1:7331";
6
7
  export const DEFAULT_HOOK_TIMEOUT_MS = 5_000;
@@ -40,7 +41,22 @@ const WRITE_TOOLS = {
40
41
  Edit: "file_path",
41
42
  NotebookEdit: "notebook_path",
42
43
  };
44
+ const SHELL_TOOLS = new Set(["Bash"]);
43
45
  export function normalizeClaudeCodeToolCall(payload, options = {}) {
46
+ if (SHELL_TOOLS.has(payload.toolName)) {
47
+ const command = typeof payload.toolInput.command === "string"
48
+ ? payload.toolInput.command
49
+ : "";
50
+ const ops = command ? classifyShellFileOps(command) : [];
51
+ if (ops.length === 0) {
52
+ return { mapped: false, reason: `claude_code_shell_no_file_op:${payload.toolName}` };
53
+ }
54
+ // Every file op a command performs is governed (e.g. `cp secret dest`
55
+ // governs the source read AND the destination write); the run loop denies
56
+ // if any op is denied. Fail-closed across the whole command.
57
+ const actions = ops.map((op) => buildShellContentAction(op, payload, options));
58
+ return { mapped: true, action: actions[0], actions };
59
+ }
44
60
  const readPathField = READ_TOOLS[payload.toolName];
45
61
  const writePathField = WRITE_TOOLS[payload.toolName];
46
62
  if (!readPathField && !writePathField) {
@@ -68,38 +84,79 @@ export function normalizeClaudeCodeToolCall(payload, options = {}) {
68
84
  },
69
85
  };
70
86
  if (readPathField) {
71
- return {
72
- mapped: true,
73
- action: parseNormalizedAction({
74
- ...base,
75
- capability: {
76
- tool: "github.contents.read",
77
- resource: repoResource,
78
- payload: {
79
- path,
80
- source: "claude-code-hook",
81
- claudeCodeTool: payload.toolName,
82
- },
87
+ const action = parseNormalizedAction({
88
+ ...base,
89
+ capability: {
90
+ tool: "github.contents.read",
91
+ resource: repoResource,
92
+ payload: {
93
+ path,
94
+ source: "claude-code-hook",
95
+ claudeCodeTool: payload.toolName,
83
96
  },
84
- }),
85
- };
97
+ },
98
+ });
99
+ return { mapped: true, action, actions: [action] };
86
100
  }
87
- return {
88
- mapped: true,
89
- action: parseNormalizedAction({
101
+ const action = parseNormalizedAction({
102
+ ...base,
103
+ capability: {
104
+ tool: "github.contents.write",
105
+ resource: repoResource,
106
+ payload: {
107
+ path,
108
+ branch: options.branch ?? "workspace",
109
+ source: "claude-code-hook",
110
+ claudeCodeTool: payload.toolName,
111
+ },
112
+ },
113
+ });
114
+ return { mapped: true, action, actions: [action] };
115
+ }
116
+ function buildShellContentAction(op, payload, options) {
117
+ const path = workspaceRelativePath(op.path, payload.cwd);
118
+ const repoResource = options.repoResource ?? "repo:local/workspace";
119
+ const taskId = payload.sessionId
120
+ ? `claude-code:${payload.sessionId.slice(0, 12)}`
121
+ : "claude-code:session";
122
+ const base = {
123
+ actor: {
124
+ agentId: "agent:claude-code",
125
+ humanOwner: options.humanOwner ?? "user:local-developer",
126
+ runtime: "claude-code",
127
+ },
128
+ intent: {
129
+ taskId,
130
+ declaredGoal: `Claude Code ${payload.toolName} tool call`,
131
+ },
132
+ };
133
+ if (op.kind === "read") {
134
+ return parseNormalizedAction({
90
135
  ...base,
91
136
  capability: {
92
- tool: "github.contents.write",
137
+ tool: "github.contents.read",
93
138
  resource: repoResource,
94
139
  payload: {
95
140
  path,
96
- branch: options.branch ?? "workspace",
97
141
  source: "claude-code-hook",
98
142
  claudeCodeTool: payload.toolName,
99
143
  },
100
144
  },
101
- }),
102
- };
145
+ });
146
+ }
147
+ return parseNormalizedAction({
148
+ ...base,
149
+ capability: {
150
+ tool: "github.contents.write",
151
+ resource: repoResource,
152
+ payload: {
153
+ path,
154
+ branch: options.branch ?? "workspace",
155
+ source: "claude-code-hook",
156
+ claudeCodeTool: payload.toolName,
157
+ },
158
+ },
159
+ });
103
160
  }
104
161
  export async function runClaudeCodeHook(input) {
105
162
  let payload;
@@ -129,17 +186,31 @@ export async function runClaudeCodeHook(input) {
129
186
  }
130
187
  const proxyUrl = (input.proxyUrl ?? DEFAULT_PROXY_URL).replace(/\/$/, "");
131
188
  const fetchImpl = input.fetch ?? globalThis.fetch;
132
- const normalizedTool = normalization.action.capability.tool;
133
- let response;
134
- try {
135
- response = await postAuthorize(fetchImpl, `${proxyUrl}/authorize`, normalization.action, input.timeoutMs ?? DEFAULT_HOOK_TIMEOUT_MS);
136
- }
137
- catch (error) {
138
- return decisionResult(payload.toolName, normalizedTool, "deny", [
139
- `Axtary blocked this tool call: local proxy unreachable at ${proxyUrl} (${errorReason(error)}).`,
140
- "Start it with: axtary proxy --config axtary.yml",
141
- ]);
189
+ const timeoutMs = input.timeoutMs ?? DEFAULT_HOOK_TIMEOUT_MS;
190
+ // Authorize every governed op (e.g. both the source read and destination write
191
+ // of `cp secret dest`); the most restrictive decision wins — deny > step_up >
192
+ // allow and a hard deny short-circuits the rest. Fail-closed.
193
+ let best = null;
194
+ for (const action of normalization.actions) {
195
+ let response;
196
+ try {
197
+ response = await postAuthorize(fetchImpl, `${proxyUrl}/authorize`, action, timeoutMs);
198
+ }
199
+ catch (error) {
200
+ return decisionResult(payload.toolName, action.capability.tool, "deny", [
201
+ `Axtary blocked this tool call: local proxy unreachable at ${proxyUrl} (${errorReason(error)}).`,
202
+ "Start it with: axtary proxy --config axtary.yml",
203
+ ]);
204
+ }
205
+ const rank = authorizeRank(response.status);
206
+ if (!best || rank > best.rank) {
207
+ best = { action, response, rank };
208
+ }
209
+ if (rank === DENY_RANK)
210
+ break; // hard deny is maximal
142
211
  }
212
+ const response = best.response;
213
+ const normalizedTool = best.action.capability.tool;
143
214
  const reasons = response.decision?.reasons ?? [];
144
215
  const hints = response.hints ?? [];
145
216
  const summary = response.explanation?.summary ?? reasons.join(", ");
@@ -164,7 +235,16 @@ export async function runClaudeCodeHook(input) {
164
235
  ledgerLine.trim(),
165
236
  ]);
166
237
  }
167
- async function postAuthorize(fetchImpl, url, action, timeoutMs) {
238
+ export const DENY_RANK = 3;
239
+ /** Severity rank for picking the most restrictive decision across ops. */
240
+ export function authorizeRank(status) {
241
+ if (status === "blocked" || status === "malformed")
242
+ return DENY_RANK;
243
+ if (status === "step_up")
244
+ return 2;
245
+ return 1; // authorized
246
+ }
247
+ export async function postAuthorize(fetchImpl, url, action, timeoutMs) {
168
248
  if (!fetchImpl) {
169
249
  throw new Error("fetch_unavailable");
170
250
  }
@@ -204,7 +284,7 @@ function decisionResult(tool, normalizedTool, decision, reasonParts) {
204
284
  exitCode: 0,
205
285
  };
206
286
  }
207
- function workspaceRelativePath(path, cwd) {
287
+ export function workspaceRelativePath(path, cwd) {
208
288
  if (!isAbsolute(path)) {
209
289
  return path;
210
290
  }
@@ -240,7 +320,7 @@ function resolveSymlinks(path) {
240
320
  function unique(values) {
241
321
  return [...new Set(values)];
242
322
  }
243
- function errorReason(error) {
323
+ export function errorReason(error) {
244
324
  return error instanceof Error ? error.message : "unknown_error";
245
325
  }
246
326
  //# sourceMappingURL=claude-code-hook.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"claude-code-hook.js","sourceRoot":"","sources":["../src/claude-code-hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;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alizedAction } from "@axtary/actionpass";
2
+ export { classifyShellCommand, classifyShellFileOps } from "./shell-file-normalize.js";
3
+ export declare const CODEX_HOOK_SCHEMA_VERSION = "axtary.codex_hook.v0";
4
+ export type CodexHookPayload = {
5
+ hookEventName: string | null;
6
+ sessionId: string | null;
7
+ cwd: string | null;
8
+ toolName: string;
9
+ toolInput: Record<string, JsonValue>;
10
+ };
11
+ export type CodexNormalization = {
12
+ mapped: true;
13
+ action: NormalizedAction;
14
+ actions: NormalizedAction[];
15
+ } | {
16
+ mapped: false;
17
+ reason: string;
18
+ };
19
+ export type CodexNormalizeOptions = {
20
+ repoResource?: string;
21
+ humanOwner?: string;
22
+ branch?: string;
23
+ };
24
+ export type CodexHookRunInput = {
25
+ payloadText: string;
26
+ proxyUrl?: string;
27
+ repoResource?: string;
28
+ humanOwner?: string;
29
+ branch?: string;
30
+ timeoutMs?: number;
31
+ fetch?: typeof fetch;
32
+ };
33
+ export type CodexHookRunResult = {
34
+ schemaVersion: typeof CODEX_HOOK_SCHEMA_VERSION;
35
+ /** Proxy decision semantics; `no_opinion` emits no decision. */
36
+ status: "allow" | "step_up" | "deny" | "no_opinion";
37
+ tool: string | null;
38
+ normalizedTool: string | null;
39
+ reason: string | null;
40
+ /** JSON for stdout (Codex `hookSpecificOutput`), or null for no opinion. */
41
+ output: string | null;
42
+ /** Always 0: decisions (incl. fail-closed denials) live in the JSON. */
43
+ exitCode: number;
44
+ };
45
+ export declare function parseCodexHookPayload(payloadText: string): CodexHookPayload;
46
+ export declare function normalizeCodexToolCall(payload: CodexHookPayload, options?: CodexNormalizeOptions): CodexNormalization;
47
+ export declare function runCodexHook(input: CodexHookRunInput): Promise<CodexHookRunResult>;
48
+ //# sourceMappingURL=codex-hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-hook.d.ts","sourceRoot":"","sources":["../src/codex-hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACtB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