@axtary/cli 0.0.1 → 0.1.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/LICENSE +202 -0
- package/README.md +27 -3
- package/dist/claude-code-hook.d.ts +45 -0
- package/dist/claude-code-hook.d.ts.map +1 -0
- package/dist/claude-code-hook.js +246 -0
- package/dist/claude-code-hook.js.map +1 -0
- package/dist/index.d.ts +133 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1166 -11
- package/dist/index.js.map +1 -1
- package/package.json +11 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,22 +1,46 @@
|
|
|
1
1
|
# @axtary/cli
|
|
2
2
|
|
|
3
|
-
Axtary local CLI
|
|
3
|
+
Axtary local CLI: the fail-closed runtime proxy, agent hooks, MCP wrapper, policy testing, and ledger tooling in one binary.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Early `0.x` release: the runtime path is real and tested, but the API is not stable yet and may change between minor versions.
|
|
6
|
+
|
|
7
|
+
## Quickstart
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -g @axtary/cli # or: npx @axtary/cli <command>
|
|
11
|
+
|
|
12
|
+
axtary init # scaffold a starter axtary.yml
|
|
13
|
+
axtary demo # run fake GitHub/Slack/Linear actions through the proxy + ledger
|
|
14
|
+
```
|
|
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).
|
|
6
17
|
|
|
7
18
|
## Commands
|
|
8
19
|
|
|
9
20
|
```sh
|
|
21
|
+
axtary init
|
|
10
22
|
axtary demo --config axtary.yml --json
|
|
23
|
+
axtary doctor connectors --config axtary.yml --json
|
|
11
24
|
axtary proxy --config axtary.yml
|
|
12
25
|
axtary smoke --config axtary.yml
|
|
13
26
|
axtary test-policy --config axtary.yml --fixtures examples/policy-fixtures
|
|
27
|
+
axtary run workflow github-pr-review --real --config examples/axtary.real.yml [--tamper]
|
|
28
|
+
axtary hook claude-code --proxy http://127.0.0.1:7331
|
|
29
|
+
axtary mcp serve --config axtary.yml [--wrap '<upstream mcp command>']
|
|
30
|
+
axtary export-ledger --format siem-jsonl
|
|
31
|
+
axtary sync-ledger --endpoint https://app.example/api/ledger/sync
|
|
14
32
|
```
|
|
15
33
|
|
|
34
|
+
- `init` scaffolds a starter `axtary.yml` and prints the quickstart rail (`docs/quickstart.md`).
|
|
16
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.
|
|
17
|
-
- `
|
|
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.
|
|
18
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.
|
|
19
39
|
- `test-policy` evaluates JSON fixtures against the loaded YAML policy and fails when an expected decision or reason differs.
|
|
40
|
+
- `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.
|
|
20
44
|
|
|
21
45
|
## Real Provider Smoke Test
|
|
22
46
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type JsonValue, type NormalizedAction } from "@axtary/actionpass";
|
|
2
|
+
export declare const CLAUDE_CODE_HOOK_SCHEMA_VERSION = "axtary.claude_code_hook.v0";
|
|
3
|
+
export declare const DEFAULT_PROXY_URL = "http://127.0.0.1:7331";
|
|
4
|
+
export declare const DEFAULT_HOOK_TIMEOUT_MS = 5000;
|
|
5
|
+
export type ClaudeCodeHookPayload = {
|
|
6
|
+
sessionId: string | null;
|
|
7
|
+
cwd: string | null;
|
|
8
|
+
toolName: string;
|
|
9
|
+
toolInput: Record<string, JsonValue>;
|
|
10
|
+
};
|
|
11
|
+
export type ClaudeCodeNormalization = {
|
|
12
|
+
mapped: true;
|
|
13
|
+
action: NormalizedAction;
|
|
14
|
+
} | {
|
|
15
|
+
mapped: false;
|
|
16
|
+
reason: string;
|
|
17
|
+
};
|
|
18
|
+
export type ClaudeCodeNormalizeOptions = {
|
|
19
|
+
repoResource?: string;
|
|
20
|
+
humanOwner?: string;
|
|
21
|
+
branch?: string;
|
|
22
|
+
};
|
|
23
|
+
export type ClaudeCodeHookStatus = "allow" | "ask" | "deny" | "no_opinion";
|
|
24
|
+
export type ClaudeCodeHookRunInput = {
|
|
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 ClaudeCodeHookRunResult = {
|
|
34
|
+
schemaVersion: typeof CLAUDE_CODE_HOOK_SCHEMA_VERSION;
|
|
35
|
+
status: ClaudeCodeHookStatus;
|
|
36
|
+
tool: string | null;
|
|
37
|
+
normalizedTool: string | null;
|
|
38
|
+
reason: string | null;
|
|
39
|
+
output: string | null;
|
|
40
|
+
exitCode: number;
|
|
41
|
+
};
|
|
42
|
+
export declare function parseClaudeCodeHookPayload(payloadText: string): ClaudeCodeHookPayload;
|
|
43
|
+
export declare function normalizeClaudeCodeToolCall(payload: ClaudeCodeHookPayload, options?: ClaudeCodeNormalizeOptions): ClaudeCodeNormalization;
|
|
44
|
+
export declare function runClaudeCodeHook(input: ClaudeCodeHookRunInput): Promise<ClaudeCodeHookRunResult>;
|
|
45
|
+
//# sourceMappingURL=claude-code-hook.d.ts.map
|
|
@@ -0,0 +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,CAA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,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,uBAAuB,CAAC,CA2ElC"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
3
|
+
import { parseNormalizedAction, } from "@axtary/actionpass";
|
|
4
|
+
export const CLAUDE_CODE_HOOK_SCHEMA_VERSION = "axtary.claude_code_hook.v0";
|
|
5
|
+
export const DEFAULT_PROXY_URL = "http://127.0.0.1:7331";
|
|
6
|
+
export const DEFAULT_HOOK_TIMEOUT_MS = 5_000;
|
|
7
|
+
export function parseClaudeCodeHookPayload(payloadText) {
|
|
8
|
+
let raw;
|
|
9
|
+
try {
|
|
10
|
+
raw = JSON.parse(payloadText);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
throw new Error("claude_code_hook_payload_invalid_json");
|
|
14
|
+
}
|
|
15
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
16
|
+
throw new Error("claude_code_hook_payload_not_object");
|
|
17
|
+
}
|
|
18
|
+
const record = raw;
|
|
19
|
+
const toolName = record.tool_name;
|
|
20
|
+
if (typeof toolName !== "string" || toolName.length === 0) {
|
|
21
|
+
throw new Error("claude_code_hook_tool_name_required");
|
|
22
|
+
}
|
|
23
|
+
const toolInput = record.tool_input && typeof record.tool_input === "object" && !Array.isArray(record.tool_input)
|
|
24
|
+
? record.tool_input
|
|
25
|
+
: {};
|
|
26
|
+
return {
|
|
27
|
+
sessionId: typeof record.session_id === "string" ? record.session_id : null,
|
|
28
|
+
cwd: typeof record.cwd === "string" ? record.cwd : null,
|
|
29
|
+
toolName,
|
|
30
|
+
toolInput,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const READ_TOOLS = {
|
|
34
|
+
Read: "file_path",
|
|
35
|
+
Glob: "path",
|
|
36
|
+
Grep: "path",
|
|
37
|
+
};
|
|
38
|
+
const WRITE_TOOLS = {
|
|
39
|
+
Write: "file_path",
|
|
40
|
+
Edit: "file_path",
|
|
41
|
+
NotebookEdit: "notebook_path",
|
|
42
|
+
};
|
|
43
|
+
export function normalizeClaudeCodeToolCall(payload, options = {}) {
|
|
44
|
+
const readPathField = READ_TOOLS[payload.toolName];
|
|
45
|
+
const writePathField = WRITE_TOOLS[payload.toolName];
|
|
46
|
+
if (!readPathField && !writePathField) {
|
|
47
|
+
return {
|
|
48
|
+
mapped: false,
|
|
49
|
+
reason: `claude_code_tool_unmapped:${payload.toolName}`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const pathField = readPathField ?? writePathField;
|
|
53
|
+
const rawPath = payload.toolInput[pathField];
|
|
54
|
+
const path = workspaceRelativePath(typeof rawPath === "string" && rawPath.length > 0 ? rawPath : ".", payload.cwd);
|
|
55
|
+
const repoResource = options.repoResource ?? "repo:local/workspace";
|
|
56
|
+
const taskId = payload.sessionId
|
|
57
|
+
? `claude-code:${payload.sessionId.slice(0, 12)}`
|
|
58
|
+
: "claude-code:session";
|
|
59
|
+
const base = {
|
|
60
|
+
actor: {
|
|
61
|
+
agentId: "agent:claude-code",
|
|
62
|
+
humanOwner: options.humanOwner ?? "user:local-developer",
|
|
63
|
+
runtime: "claude-code",
|
|
64
|
+
},
|
|
65
|
+
intent: {
|
|
66
|
+
taskId,
|
|
67
|
+
declaredGoal: `Claude Code ${payload.toolName} tool call`,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
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
|
+
},
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
mapped: true,
|
|
89
|
+
action: parseNormalizedAction({
|
|
90
|
+
...base,
|
|
91
|
+
capability: {
|
|
92
|
+
tool: "github.contents.write",
|
|
93
|
+
resource: repoResource,
|
|
94
|
+
payload: {
|
|
95
|
+
path,
|
|
96
|
+
branch: options.branch ?? "workspace",
|
|
97
|
+
source: "claude-code-hook",
|
|
98
|
+
claudeCodeTool: payload.toolName,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
}),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export async function runClaudeCodeHook(input) {
|
|
105
|
+
let payload;
|
|
106
|
+
try {
|
|
107
|
+
payload = parseClaudeCodeHookPayload(input.payloadText);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
return decisionResult(null, null, "deny", [
|
|
111
|
+
`Axtary blocked this tool call: hook payload could not be parsed (${errorReason(error)}). Protected actions fail closed.`,
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
const normalization = normalizeClaudeCodeToolCall(payload, {
|
|
115
|
+
repoResource: input.repoResource,
|
|
116
|
+
humanOwner: input.humanOwner,
|
|
117
|
+
branch: input.branch,
|
|
118
|
+
});
|
|
119
|
+
if (!normalization.mapped) {
|
|
120
|
+
return {
|
|
121
|
+
schemaVersion: CLAUDE_CODE_HOOK_SCHEMA_VERSION,
|
|
122
|
+
status: "no_opinion",
|
|
123
|
+
tool: payload.toolName,
|
|
124
|
+
normalizedTool: null,
|
|
125
|
+
reason: normalization.reason,
|
|
126
|
+
output: null,
|
|
127
|
+
exitCode: 0,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const proxyUrl = (input.proxyUrl ?? DEFAULT_PROXY_URL).replace(/\/$/, "");
|
|
131
|
+
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
|
+
]);
|
|
142
|
+
}
|
|
143
|
+
const reasons = response.decision?.reasons ?? [];
|
|
144
|
+
const hints = response.hints ?? [];
|
|
145
|
+
const summary = response.explanation?.summary ?? reasons.join(", ");
|
|
146
|
+
const ledgerLine = typeof response.ledger?.lineNumber === "number"
|
|
147
|
+
? ` Ledger line ${response.ledger.lineNumber}.`
|
|
148
|
+
: "";
|
|
149
|
+
if (response.status === "authorized") {
|
|
150
|
+
return decisionResult(payload.toolName, normalizedTool, "allow", [
|
|
151
|
+
`Axtary authorized ${normalizedTool}: ${summary}${ledgerLine}`,
|
|
152
|
+
]);
|
|
153
|
+
}
|
|
154
|
+
if (response.status === "step_up") {
|
|
155
|
+
return decisionResult(payload.toolName, normalizedTool, "ask", [
|
|
156
|
+
`Axtary requires step-up review for ${normalizedTool}: ${summary}`,
|
|
157
|
+
...hints,
|
|
158
|
+
ledgerLine.trim(),
|
|
159
|
+
]);
|
|
160
|
+
}
|
|
161
|
+
return decisionResult(payload.toolName, normalizedTool, "deny", [
|
|
162
|
+
`Axtary blocked ${normalizedTool}: ${summary}`,
|
|
163
|
+
...hints,
|
|
164
|
+
ledgerLine.trim(),
|
|
165
|
+
]);
|
|
166
|
+
}
|
|
167
|
+
async function postAuthorize(fetchImpl, url, action, timeoutMs) {
|
|
168
|
+
if (!fetchImpl) {
|
|
169
|
+
throw new Error("fetch_unavailable");
|
|
170
|
+
}
|
|
171
|
+
const response = await fetchImpl(url, {
|
|
172
|
+
method: "POST",
|
|
173
|
+
headers: { "content-type": "application/json" },
|
|
174
|
+
body: JSON.stringify(action),
|
|
175
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
176
|
+
});
|
|
177
|
+
const body = (await response.json());
|
|
178
|
+
if (!response.ok && response.status !== 400) {
|
|
179
|
+
throw new Error(`proxy_authorize_http_${response.status}`);
|
|
180
|
+
}
|
|
181
|
+
if (body.status !== "authorized" &&
|
|
182
|
+
body.status !== "step_up" &&
|
|
183
|
+
body.status !== "blocked" &&
|
|
184
|
+
body.status !== "malformed") {
|
|
185
|
+
throw new Error("proxy_authorize_response_invalid");
|
|
186
|
+
}
|
|
187
|
+
return body;
|
|
188
|
+
}
|
|
189
|
+
function decisionResult(tool, normalizedTool, decision, reasonParts) {
|
|
190
|
+
const reason = reasonParts.filter((part) => part.length > 0).join(" ");
|
|
191
|
+
return {
|
|
192
|
+
schemaVersion: CLAUDE_CODE_HOOK_SCHEMA_VERSION,
|
|
193
|
+
status: decision,
|
|
194
|
+
tool,
|
|
195
|
+
normalizedTool,
|
|
196
|
+
reason,
|
|
197
|
+
output: JSON.stringify({
|
|
198
|
+
hookSpecificOutput: {
|
|
199
|
+
hookEventName: "PreToolUse",
|
|
200
|
+
permissionDecision: decision,
|
|
201
|
+
permissionDecisionReason: reason,
|
|
202
|
+
},
|
|
203
|
+
}),
|
|
204
|
+
exitCode: 0,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function workspaceRelativePath(path, cwd) {
|
|
208
|
+
if (!isAbsolute(path)) {
|
|
209
|
+
return path;
|
|
210
|
+
}
|
|
211
|
+
const base = resolve(cwd ?? process.cwd());
|
|
212
|
+
const bases = unique([base, resolveSymlinks(base)]);
|
|
213
|
+
const candidates = unique([path, resolveSymlinks(path)]);
|
|
214
|
+
for (const candidatePath of candidates) {
|
|
215
|
+
for (const candidateBase of bases) {
|
|
216
|
+
const relativePath = relative(candidateBase, candidatePath);
|
|
217
|
+
if (relativePath.length === 0) {
|
|
218
|
+
return ".";
|
|
219
|
+
}
|
|
220
|
+
if (!relativePath.startsWith("..")) {
|
|
221
|
+
return relativePath;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return path;
|
|
226
|
+
}
|
|
227
|
+
function resolveSymlinks(path) {
|
|
228
|
+
try {
|
|
229
|
+
return realpathSync(path);
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
try {
|
|
233
|
+
return join(realpathSync(dirname(path)), basename(path));
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
return path;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function unique(values) {
|
|
241
|
+
return [...new Set(values)];
|
|
242
|
+
}
|
|
243
|
+
function errorReason(error) {
|
|
244
|
+
return error instanceof Error ? error.message : "unknown_error";
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=claude-code-hook.js.map
|
|
@@ -0,0 +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;AAEnF,OAAO,EACL,qBAAqB,GAGtB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,CAAC,MAAM,+BAA+B,GAAG,4BAA4B,CAAC;AAC5E,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AACzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAyC7C,MAAM,UAAU,0BAA0B,CAAC,WAAmB;IAC5D,IAAI,GAAY,CAAC;IAEjB,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,C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