@agenttrail/cli 0.2.8 → 0.2.12
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 +579 -317
- package/dist/{chunk-XLIZZ2BX.js → chunk-RV57MPTW.js} +65 -62
- package/dist/cli/index.cjs +63 -60
- package/dist/cli/index.js +1 -1
- package/dist/cursor/capture-hook.mjs +7 -7
- package/dist/cursor/flush.mjs +11 -11
- package/dist/index.cjs +65 -62
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/plugin/.claude-plugin/marketplace.json +2 -2
- package/plugin/.claude-plugin/plugin.json +1 -1
package/README.md
CHANGED
|
@@ -1,340 +1,602 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
npx -y @agenttrail/cli@latest
|
|
1
|
+
<!-- cspell:words agenttrailhq jsonl unregister reimport freshens -->
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
<a href="https://www.agenttrail.sh">
|
|
6
|
+
<picture>
|
|
7
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://www.agenttrail.sh/brand/agenttrail_logo_white.svg" />
|
|
8
|
+
<img src="https://www.agenttrail.sh/brand/agenttrail_logo.svg" alt="AgentTrail" width="220" />
|
|
9
|
+
</picture>
|
|
10
|
+
</a>
|
|
11
|
+
|
|
12
|
+
# AgentTrail CLI: connect your coding agent to AgentTrail OS
|
|
13
|
+
|
|
14
|
+
**One command records your AI coding agent's sessions and enforces your team's policies.**<br />
|
|
15
|
+
Works with **Claude Code** and **Cursor**. Signs in through your browser, with no API key to copy.
|
|
16
|
+
|
|
17
|
+
[](https://www.npmjs.com/package/@agenttrail/cli)
|
|
18
|
+
[](https://www.apache.org/licenses/LICENSE-2.0)
|
|
19
|
+
[](https://nodejs.org/)
|
|
20
|
+
|
|
21
|
+
[Quick start](#quick-start) ·
|
|
22
|
+
[How it works](#how-the-cli-works) ·
|
|
23
|
+
[Privacy](#privacy-at-a-glance) ·
|
|
24
|
+
[Reference](#reference)
|
|
25
|
+
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
`agenttrail` is the command-line tool for
|
|
29
|
+
[AgentTrail OS](https://www.agenttrail.sh/agenttrail-os). Run it once in a project and it signs
|
|
30
|
+
the device in, sends each agent session to AgentTrail after every turn, and installs real-time
|
|
31
|
+
enforcement: before your agent runs a command or edits a file, the call is checked against your
|
|
32
|
+
organization's policies and can be allowed, held for a person to approve, or blocked.
|
|
33
|
+
|
|
34
|
+

|
|
35
|
+
|
|
36
|
+
<sub>Abridged: setup's content-capture warning is shortened, and the ids are examples.</sub>
|
|
37
|
+
|
|
38
|
+
## Quick start
|
|
39
|
+
|
|
40
|
+
**You need:** Node.js 18 or newer, an [AgentTrail account](https://www.agenttrail.sh/signup)
|
|
41
|
+
(the Free plan works), and Claude Code 2.1.211 or newer, or Cursor.
|
|
42
|
+
|
|
43
|
+
### 1. Connect a project
|
|
44
|
+
|
|
45
|
+
Run this in the project folder, in an interactive terminal:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npx -y @agenttrail/cli@latest setup --agent claude # Claude Code
|
|
49
|
+
npx -y @agenttrail/cli@latest setup --agent cursor # Cursor
|
|
49
50
|
```
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
user + active org; no API key to generate, copy, or paste. The credential lives
|
|
57
|
-
in `~/.agenttrail/credentials.json` (mode 0600) and its ingest token is mirrored
|
|
58
|
-
into `.claude/settings.local.json`; a registered `SessionStart` hook
|
|
59
|
-
transparently refreshes it between sessions. Re-running `setup` with a valid
|
|
60
|
-
credential reuses it (no browser) and just (re)writes this project's config.
|
|
52
|
+
`setup` opens a sign-in link (`https://www.agenttrail.sh/device?code=…`) in your browser and
|
|
53
|
+
prints the same link with a short code. If the browser doesn't open, paste the printed link into
|
|
54
|
+
one. Check that the page shows the same code, approve it while signed in to AgentTrail, and setup
|
|
55
|
+
finishes on its own. It then names the device, connects this project, and installs real-time
|
|
56
|
+
enforcement.
|
|
61
57
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
device-auths for you when needed.)
|
|
58
|
+
Each project is connected separately. Run `setup` again in every repository you want recorded.
|
|
59
|
+
A second project on the same machine reuses the sign-in, with no browser.
|
|
65
60
|
|
|
66
|
-
|
|
61
|
+
Using [AgentTrail Guard](https://github.com/agenttrailhq/guard)? Keep it installed: setup
|
|
62
|
+
checks it first and can stand it down in this project. See
|
|
63
|
+
[Moving from AgentTrail Guard](#moving-from-agenttrail-guard).
|
|
67
64
|
|
|
68
|
-
|
|
65
|
+
### 2. Check that it worked
|
|
69
66
|
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
npx -y @agenttrail/cli@latest
|
|
73
|
-
npx -y @agenttrail/cli@latest status --agent claude
|
|
67
|
+
```sh
|
|
68
|
+
npx -y @agenttrail/cli@latest status --agent claude # AgentTrail exporter: ACTIVE
|
|
69
|
+
npx -y @agenttrail/cli@latest status --agent cursor # Capture: ON for <folder>
|
|
74
70
|
```
|
|
75
71
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
-
|
|
89
|
-
still go into `.claude/settings.json`, which is usually committed. Apart from moving an
|
|
90
|
-
older install's enforcement keys out of that file (below), that is the only tracked change
|
|
91
|
-
setup makes today. A `.agenttrail.json` the repo already tracks is left as it is.
|
|
92
|
-
|
|
93
|
-
If the repo **already tracks** `.claude/settings.local.json` (or a `.gitignore` rule
|
|
94
|
-
re-includes it), that file would carry your credential into git, so setup **writes nothing**
|
|
95
|
-
and stops with the reason and the fix: `git rm --cached .claude/settings.local.json` and
|
|
96
|
-
commit (or remove the re-including rule), then run setup again. AgentTrail is not connected in
|
|
97
|
-
that repo until then. The same applies to `.agenttrail.json` when it would hold an API key.
|
|
98
|
-
|
|
99
|
-
`--team` is the explicit "write committable config" path: key-free settings meant to be
|
|
100
|
-
committed, and never the `AGENTTRAIL_PEP_ENFORCE` switch or a token.
|
|
101
|
-
|
|
102
|
-
An older version wrote the enforcement settings into `.claude/settings.json` and appended
|
|
103
|
-
lines to `.gitignore`. Running `setup` again moves the settings to
|
|
104
|
-
`.claude/settings.local.json` once enforcement is verified again (if `settings.json` is
|
|
105
|
-
committed, commit that change), and removes the `.gitignore` lines it added if they were never
|
|
106
|
-
committed. `logout` removes the enforcement settings from both files; the
|
|
107
|
-
`.git/info/exclude` lines stay, because the files they hide can still hold your own settings.
|
|
108
|
-
|
|
109
|
-
## Already using AgentTrail Guard?
|
|
110
|
-
|
|
111
|
-
You don't need to uninstall it. Run `setup --agent claude` in each project you want AgentTrail OS
|
|
112
|
-
to decide in; AgentTrail Guard keeps protecting every other project.
|
|
113
|
-
|
|
114
|
-
1. **Setup checks your AgentTrail Guard first, before writing anything.** If your version can't
|
|
115
|
-
stand down for AgentTrail OS, setup stops and prints how to update it (or to uninstall it, or to
|
|
116
|
-
use `--global`, which offers to remove it).
|
|
117
|
-
2. **It shows what AgentTrail OS won't enforce yet**, after enforcement is verified: your own rules,
|
|
118
|
-
library rules your organization turned off, and stricter actions. With nothing missing, AgentTrail
|
|
119
|
-
Guard stands down in this project. Otherwise setup asks (default no); without a terminal, pass
|
|
120
|
-
`--accept-guard-gap`. An organization with no enabled policies never gets AgentTrail Guard stood
|
|
121
|
-
down. After you apply the import, `setup --stand-down-guard` stands it down.
|
|
122
|
-
3. **Standing down is recorded only on this machine**, in `~/.agenttrail/os/enforced-projects.json`
|
|
123
|
-
(mode 0600). AgentTrail Guard steps aside in a project only when that record, the enforcement
|
|
124
|
-
settings, the credential and the enabled plugin all agree, so a repository's own settings can't
|
|
125
|
-
make it stand down. When anything disagrees, both run: two prompts, never none.
|
|
126
|
-
4. **Your settings come with you through a file.** Setup writes `~/.agenttrail/os/guard-import.json`
|
|
127
|
-
(mode 0600, no token in it) and prints its SHA-256. In the app, **Governance → Import from Guard**
|
|
128
|
-
reads it in your browser, shows every change in full, and applies the ones you tick. Your
|
|
129
|
-
allowlist and any action you made weaker don't carry over.
|
|
130
|
-
5. **What changes:** setup prints it, computed from your settings: what happens when AgentTrail can't
|
|
131
|
-
be reached, `ask` rules becoming holds in the approval queue, and that your `permissions.allow`
|
|
132
|
-
rules can't skip an approval while a reviewer can still answer it.
|
|
133
|
-
|
|
134
|
-
`status` says whether AgentTrail Guard stands down in the current project, and lists what isn't
|
|
135
|
-
enforced until your import is applied. `logout` takes the project out of the record, and AgentTrail
|
|
136
|
-
Guard enforces there again from the next tool call.
|
|
137
|
-
|
|
138
|
-
For Cursor, setup stops while AgentTrail Guard's Cursor hooks are installed: remove them with
|
|
139
|
-
`npx -y @agenttrail/guard@latest uninstall --agent cursor` first.
|
|
140
|
-
|
|
141
|
-
## Cursor (`--agent cursor`)
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
npx -y @agenttrail/cli@latest setup --agent cursor # in the folder you open in Cursor
|
|
145
|
-
npx -y @agenttrail/cli@latest status --agent cursor # → Capture: ON for <folder>
|
|
72
|
+
`status` reads only local files and makes no network call.
|
|
73
|
+
|
|
74
|
+
### 3. Finish agent setup
|
|
75
|
+
|
|
76
|
+
- **Claude Code:** start a new session in the project. The first upload happens after your
|
|
77
|
+
first turn, and `status` then shows when it succeeded.
|
|
78
|
+
- **Cursor:** open the same folder in Cursor, trust the workspace when Cursor asks, and use
|
|
79
|
+
the agent in an editor window. Cursor runs a project's hooks only in a trusted workspace.
|
|
80
|
+
|
|
81
|
+
### Sign out
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
npx -y @agenttrail/cli@latest logout --agent claude # or: --agent cursor
|
|
146
85
|
```
|
|
147
86
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
87
|
+
`logout` revokes this device's sign-in and removes enforcement. What it keeps and removes is
|
|
88
|
+
in [Disconnecting](#disconnecting).
|
|
89
|
+
|
|
90
|
+
Prefer a guided walkthrough? See [Get started](https://www.agenttrail.sh/get-started).
|
|
91
|
+
|
|
92
|
+
## Why the AgentTrail CLI?
|
|
93
|
+
|
|
94
|
+
Your coding agent runs commands and edits files faster than anyone can review each one, and
|
|
95
|
+
most of what it does is never recorded anywhere you can search later. The CLI connects that
|
|
96
|
+
work to AgentTrail OS, so you and your team can:
|
|
151
97
|
|
|
152
|
-
|
|
98
|
+
- **See every session.** Prompts, commands, file changes, tokens and cost for each turn, in
|
|
99
|
+
one searchable history per project.
|
|
100
|
+
- **Enforce policies before a call runs.** Your organization's policies are checked on every
|
|
101
|
+
tool call, with approvals routed to a person when a policy asks for one.
|
|
102
|
+
- **Start with history.** `backfill` imports the sessions already on your disk, so the
|
|
103
|
+
dashboard has data on day one.
|
|
104
|
+
- **Keep secrets out.** Content is scrubbed for secret-shaped values before it leaves the
|
|
105
|
+
machine, and again when AgentTrail receives it. You can turn content capture off entirely.
|
|
106
|
+
- **No key handling.** Device sign-in issues a short-lived, refreshable credential for this
|
|
107
|
+
device alone, kept in your home folder rather than the repository. Revoke a device from the
|
|
108
|
+
AgentTrail app at any time.
|
|
153
109
|
|
|
154
|
-
|
|
155
|
-
|---|---|---|
|
|
156
|
-
| How spans are produced | per project: our `Stop` / `SessionEnd` hooks upload each session from its transcript; `--global`: Claude Code's own exporter, configured by us | our capture hook + a detached sender, both under `~/.agenttrail/cursor/runtime/` |
|
|
157
|
-
| What is written in the repo | the capture hooks and resource attributes in `.claude/settings.json`; everything per-machine in `.claude/settings.local.json`, kept out of git via `.git/info/exclude` | `.cursor/hooks.json`, kept out of git via `.git/info/exclude` |
|
|
158
|
-
| State | `~/.agenttrail/credentials.json` | `~/.agenttrail/cursor/` (its own credential, registry, queue and checkpoint) |
|
|
159
|
-
| Auth | device login, or `--key` / `--team` for CI | device login only — `--key`, `--team` and `--global` are refused |
|
|
160
|
-
| Content capture | **on by default** (`--no-capture-content` opts out); scrubbed at ingest | off by default (`--capture-content` turns it on); scrubbed **on this machine** before it is queued, then server-side as well |
|
|
161
|
-
| Cost | tokens × the provider's list price | not computed: Cursor sessions read "Not reported by Cursor" |
|
|
162
|
-
| Real-time blocking | the enforcement plugin | from Cursor 3.21.16, installed by `setup`; an older Cursor is captured only |
|
|
110
|
+
## How the CLI works
|
|
163
111
|
|
|
164
|
-
|
|
112
|
+
**Claude Code**
|
|
165
113
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
114
|
+
1. **`setup` registers hooks in the project's `.claude/settings.json`.** At the end of each
|
|
115
|
+
turn, a `Stop` hook runs `agenttrail capture` in the background.
|
|
116
|
+
2. **`capture` reads the session from Claude Code's local transcript**, scrubs it, and sends
|
|
117
|
+
the new turns to AgentTrail. A turn already sent is not sent again.
|
|
118
|
+
3. **An enforcement plugin checks each tool call.** Before Claude Code runs a command, an
|
|
119
|
+
edit, a read or an MCP call, the plugin's `PreToolUse` hook asks AgentTrail for a
|
|
120
|
+
decision. A policy can block the call or hold it until a person approves it in the app.
|
|
121
|
+
4. **A `SessionStart` hook keeps the sign-in fresh.** It refreshes the credential only when
|
|
122
|
+
it is about to expire, so a normal session start does nothing.
|
|
172
123
|
|
|
173
|
-
|
|
174
|
-
removes this machine's Cursor state and revokes the device.
|
|
124
|
+
**Cursor**
|
|
175
125
|
|
|
176
|
-
|
|
126
|
+
1. **`setup` writes hook entries into the project's `.cursor/hooks.json`.** They run a small
|
|
127
|
+
capture hook that queues each step on disk and exits at once.
|
|
128
|
+
2. **A detached sender uploads finished steps**, so the agent never waits on the network.
|
|
129
|
+
3. **On Cursor 3.21.16 or later, enforcement entries are added** next to the capture ones and
|
|
130
|
+
check each tool call against your policies.
|
|
177
131
|
|
|
178
|
-
|
|
179
|
-
|
|
132
|
+
When enforcement is on and AgentTrail cannot be reached, the call is checked against the
|
|
133
|
+
last policy snapshot cached on your machine. With no snapshot, the call is **blocked**:
|
|
134
|
+
enforcement fails closed, unlike [AgentTrail Guard](#agenttrail-cli-and-agenttrail-guard).
|
|
135
|
+
Read [what the CLI does not do](#what-the-cli-does-not-do) before relying on it.
|
|
136
|
+
|
|
137
|
+
## The commands
|
|
138
|
+
|
|
139
|
+
Every command runs as `npx -y @agenttrail/cli@latest <command> --agent <claude|cursor>`.
|
|
180
140
|
|
|
181
141
|
| Command | What it does |
|
|
182
|
-
|
|
183
|
-
| `
|
|
184
|
-
| `
|
|
185
|
-
| `
|
|
186
|
-
| `
|
|
187
|
-
| `
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
|
197
|
-
|
|
|
198
|
-
|
|
|
199
|
-
|
|
|
200
|
-
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
- **
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
142
|
+
| --- | --- |
|
|
143
|
+
| `setup` | Sign in through the browser if needed, connect this project, and install enforcement. Safe to re-run. |
|
|
144
|
+
| `status` | Show what is connected here, the last upload, and the enforcement state. Local only. `doctor` is the same command. |
|
|
145
|
+
| `backfill` | Import the sessions already on your disk for this project. See [Backfill](#backfill). |
|
|
146
|
+
| `device rename "<name>"` | Change the name your organization's admins see for this device. |
|
|
147
|
+
| `login` | Sign the device in without connecting a project. `login --refresh` is what the `SessionStart` hook runs. |
|
|
148
|
+
| `logout` | Revoke this device's sign-in and remove enforcement. |
|
|
149
|
+
|
|
150
|
+
`--agent` is required on every command. Without it, the command prints
|
|
151
|
+
`error: choose --agent claude, --agent cursor or --agent codex`, exits 1, and changes nothing.
|
|
152
|
+
Run `npx -y @agenttrail/cli@latest --help` for every option.
|
|
153
|
+
|
|
154
|
+
## Agent support
|
|
155
|
+
|
|
156
|
+
| Agent | Status |
|
|
157
|
+
| --- | --- |
|
|
158
|
+
| Claude Code | Supported. Session upload, enforcement (Claude Code 2.1.211 or newer), backfill. Per project, or machine-wide with `--global`. |
|
|
159
|
+
| Cursor | Supported. Session upload and backfill per project. Enforcement needs Cursor 3.21.16 or later; see [Cursor's limits](#cursors-limits). Cursor's cloud agents are not covered. |
|
|
160
|
+
| Codex CLI | Not yet available. Every command refuses `--agent codex`, prints ``error: `<command> --agent codex` is not yet available.``, and changes nothing. |
|
|
161
|
+
|
|
162
|
+
## Privacy at a glance
|
|
163
|
+
|
|
164
|
+
- **Reads:** the agent's local session files (Claude Code's transcripts, or Cursor's hook
|
|
165
|
+
events), and the tool call your agent is about to make when enforcement is on.
|
|
166
|
+
- **Sends:** to `ingest.agenttrail.sh`, each session's turns: timings, tool names, models,
|
|
167
|
+
token counts, and, when content capture is on, prompts, commands, file paths and tool
|
|
168
|
+
output. To `api.agenttrail.sh`, sign-in, policy checks, and whether enforcement is on for
|
|
169
|
+
this device. Nothing is sent before you sign in.
|
|
170
|
+
- **Keeps:** a credential and small state files under `~/.agenttrail/`, written at mode `0600`.
|
|
171
|
+
See [Files it keeps](#files-it-keeps).
|
|
172
|
+
|
|
173
|
+
**Content capture is on by default for Claude Code and Cursor.** Pass `--no-capture-content`
|
|
174
|
+
to `setup` to send metadata and token counts only, and a later `setup` keeps that choice. For
|
|
175
|
+
Claude Code, a content setting of off in its own managed, user or local settings, or in the
|
|
176
|
+
environment, turns it off for the CLI too. For Cursor, a project `.agenttrail.json` that sets
|
|
177
|
+
`captureContent` to `false` keeps it off.
|
|
178
|
+
|
|
179
|
+
**Scrubbing is shape-based and not exhaustive.** Values that look like secrets (API keys,
|
|
180
|
+
tokens, connection strings, JWTs, private keys, `.env`-style assignments) and the output of
|
|
181
|
+
known secret-manager commands such as `op read` are replaced before content leaves your
|
|
182
|
+
machine, then scrubbed again at ingest under your organization's settings. A secret with no
|
|
183
|
+
recognizable shape, or one printed by a command the scrubber does not know, can still be
|
|
184
|
+
stored. If that is a risk for a project, turn content capture off there. The AgentTrail
|
|
185
|
+
website describes [how data is handled](https://www.agenttrail.sh/security).
|
|
186
|
+
|
|
187
|
+
## What the CLI does not do
|
|
188
|
+
|
|
189
|
+
- **It cannot check what never reaches a hook.** Enforcement sees the tool calls each agent
|
|
190
|
+
sends to its hooks, and nothing the agent does outside them.
|
|
191
|
+
- **Some failures let a call through.** Enforcement fails closed on a network or policy
|
|
192
|
+
error, but if `node` is not on your `PATH`, or the plugin is uninstalled or disabled, the
|
|
193
|
+
hook cannot run and Claude Code's normal permission flow decides on its own.
|
|
194
|
+
- **It does not inspect file contents.** A policy on an edit decides by the file's path and
|
|
195
|
+
the tool, not by what the edit writes.
|
|
196
|
+
- **It is not real-time for history.** Sessions are uploaded after each turn, not while the
|
|
197
|
+
turn runs, and `backfill` imports only the project you run it in.
|
|
198
|
+
- **Hooks fetch the latest release.** The hooks run `npx -y @agenttrail/cli@latest`, so each
|
|
199
|
+
session start and turn end contacts the npm registry and uses the newest published
|
|
200
|
+
version. When the registry cannot be reached, that run is skipped, and a later run sends
|
|
201
|
+
the turns it missed.
|
|
202
|
+
|
|
203
|
+
### Cursor's limits
|
|
204
|
+
|
|
205
|
+
- **Enforcement turns on only when the CLI can read Cursor's version.** Today it reads it
|
|
206
|
+
from `/Applications/Cursor.app` on macOS. Elsewhere, `status` reports `Enforcement: OFF`
|
|
207
|
+
and asks for Cursor 3.21.16 or later even when it is installed; capture keeps working.
|
|
208
|
+
- **An older Cursor is captured only.** Below 3.21.16, no enforcement entries are written.
|
|
209
|
+
- **Cursor's Agent Window can skip hooks** on versions older than 3.21.16. Use the agent in
|
|
210
|
+
an editor window.
|
|
211
|
+
- **Workspace trust cannot be checked from the CLI.** If capture shows nothing, confirm that
|
|
212
|
+
Cursor trusts the folder.
|
|
213
|
+
- **No model, tokens or cost.** Cursor's hook events and session files do not carry them, so
|
|
214
|
+
Cursor sessions show none.
|
|
215
|
+
- **Only the opened folder's hooks load.** If you open a subfolder in Cursor, run `setup` in
|
|
216
|
+
that subfolder too; it joins the same project.
|
|
217
|
+
|
|
218
|
+
## AgentTrail CLI and AgentTrail Guard
|
|
219
|
+
|
|
220
|
+
[AgentTrail Guard](https://github.com/agenttrailhq/guard) is AgentTrail's free, open-source,
|
|
221
|
+
local-only guardrail tool. It needs no account and sends nothing. The CLI is for teams who also
|
|
222
|
+
want a searchable record of every session and policies managed in one place. Both use the same
|
|
223
|
+
open rule library, [agenttrailhq/guardrails](https://github.com/agenttrailhq/guardrails).
|
|
224
|
+
|
|
225
|
+
| | [AgentTrail Guard](https://www.agenttrail.sh/agenttrail-guard) | AgentTrail CLI, with [AgentTrail OS](https://www.agenttrail.sh/agenttrail-os) |
|
|
226
|
+
| --- | --- | --- |
|
|
227
|
+
| Where decisions are made | On your machine, from the bundled library | On AgentTrail's servers, from your organization's policies |
|
|
228
|
+
| Account | None | Required |
|
|
229
|
+
| Agents | Claude Code, Cursor, Codex CLI | Claude Code, Cursor |
|
|
230
|
+
| History | A capped local log, plus on-demand scan reports | Searchable session history |
|
|
231
|
+
| For teams | One developer, one machine | Shared policies, approvals and an audit trail, depending on plan |
|
|
232
|
+
| When something breaks | Fails open: your agent's normal permission flow continues | Fails closed: the action does not proceed |
|
|
233
|
+
|
|
234
|
+
**Already using AgentTrail Guard?** You don't need to uninstall it. In Claude Code, `setup`
|
|
235
|
+
can stand Guard down in each project you connect, so AgentTrail OS decides there and Guard
|
|
236
|
+
keeps protecting every other project. Guard 0.4.14 or newer is needed. See
|
|
237
|
+
[Moving from AgentTrail Guard](#moving-from-agenttrail-guard), and the step-by-step guide in
|
|
238
|
+
[AgentTrail Guard vs AgentTrail OS](https://www.agenttrail.sh/guard-vs-os#moving).
|
|
239
|
+
|
|
240
|
+
## Troubleshooting
|
|
241
|
+
|
|
242
|
+
| What you see | What to check |
|
|
243
|
+
| --- | --- |
|
|
244
|
+
| `device login needs a browser to authorize` | Run `setup` in an interactive terminal. For CI, see [API keys](#api-keys-for-ci-and-headless-machines). |
|
|
245
|
+
| `AgentTrail exporter: INACTIVE` | This folder has not been set up. Run `setup` in the project root. |
|
|
246
|
+
| `Last session upload: none yet` | Take one turn in Claude Code in this project. The upload runs when the turn ends. |
|
|
247
|
+
| Setup says enforcement stayed off | Read the reason it prints. Capture keeps working; re-run `setup` once it is fixed. A `401` means the sign-in was rejected: run `logout`, then `setup`. |
|
|
248
|
+
| `Claude Code (claude) was not found on your PATH` | Install Claude Code, or open a terminal where `claude` runs, then re-run `setup`. |
|
|
249
|
+
| `Upgrade Claude Code to 2.1.211 or newer` | The enforcement plugin needs it. Update Claude Code and re-run `setup`. |
|
|
250
|
+
| Setup refuses because the repo tracks `.claude/settings.local.json` | That file would carry your credential into git. Run `git rm --cached .claude/settings.local.json`, commit, and run `setup` again. |
|
|
251
|
+
| Cursor shows `Capture: BROKEN` | Read the listed problem and re-run `setup --agent cursor` in that folder. |
|
|
252
|
+
| `status` says `API key: MISSING` after a browser sign-in | Expected: device sign-in uses no API key. |
|
|
253
|
+
| Setup stops because AgentTrail Guard can't stand down | Update Guard to 0.4.14 or newer with `npx -y @agenttrail/guard@latest init --agent claude`, then re-run `setup`. |
|
|
254
|
+
| Cursor setup stops because Guard's Cursor hooks are installed | Remove them with `npx -y @agenttrail/guard@latest uninstall --agent cursor`; your Guard settings stay. Then re-run `setup --agent cursor`. |
|
|
255
|
+
|
|
256
|
+
Security issue? Email [security@agenttrail.sh](mailto:security@agenttrail.sh) rather than
|
|
257
|
+
posting it publicly.
|
|
258
|
+
|
|
259
|
+
## Reference
|
|
260
|
+
|
|
261
|
+
The sections below are collapsed so you can open just the one you need.
|
|
262
|
+
|
|
263
|
+
- **Setting up:** [what setup changes](#what-setup-changes), [API keys](#api-keys-for-ci-and-headless-machines),
|
|
264
|
+
[machine-wide and team installs](#machine-wide-and-team-installs),
|
|
265
|
+
[moving from AgentTrail Guard](#moving-from-agenttrail-guard), and [disconnecting](#disconnecting).
|
|
266
|
+
- **Day to day:** [backfill](#backfill), [device names](#device-names), and [options](#options).
|
|
267
|
+
- **Under the hood:** [enforcement](#enforcement), [network](#network), and [files it keeps](#files-it-keeps).
|
|
268
|
+
|
|
269
|
+
## What setup changes
|
|
270
|
+
|
|
271
|
+
<details>
|
|
272
|
+
<summary>Claude Code (<code>setup --agent claude</code>)</summary>
|
|
273
|
+
|
|
274
|
+
<br />
|
|
275
|
+
|
|
276
|
+
Setup keeps everything about **this machine** out of git, so a trial run leaves no change for
|
|
277
|
+
you to commit:
|
|
278
|
+
|
|
279
|
+
- **`.claude/settings.json`**, usually committed, gets the capture hooks (`SessionStart`,
|
|
280
|
+
`Stop`, `SessionEnd`) and `OTEL_RESOURCE_ATTRIBUTES`, which names your organization, project
|
|
281
|
+
and agent by id. These are the only tracked changes setup makes.
|
|
282
|
+
- **`.claude/settings.local.json`**, never committed, gets the enforcement settings: the policy
|
|
283
|
+
endpoints, this device's token, a 3-second policy timeout and the `AGENTTRAIL_PEP_ENFORCE`
|
|
284
|
+
switch, written last and only once enforcement has been verified.
|
|
285
|
+
- **`.agenttrail.json`** records the organization, project, agent and the content-capture
|
|
286
|
+
choice. With device sign-in it holds no key.
|
|
287
|
+
- **`.git/info/exclude`** gets lines that keep `.claude/settings.local.json` and
|
|
288
|
+
`.agenttrail.json` out of git. Git reads it like `.gitignore` but never tracks it; setup
|
|
289
|
+
checks with git that the files are ignored, and never edits `.gitignore`.
|
|
290
|
+
- **The enforcement plugin** is installed for your user with Claude Code's own
|
|
291
|
+
`claude plugin` commands, from a local marketplace shipped inside this package.
|
|
292
|
+
|
|
293
|
+
If the repository **already tracks** `.claude/settings.local.json`, setup writes nothing and
|
|
294
|
+
stops with the fix. An `.agenttrail.json` the repository tracks is left as it is.
|
|
295
|
+
|
|
296
|
+
The project's identity comes from its `origin` git remote. With no remote, setup falls back to
|
|
297
|
+
the folder name and warns that the same repository at another path would become a different
|
|
298
|
+
project.
|
|
299
|
+
|
|
300
|
+
</details>
|
|
301
|
+
|
|
302
|
+
<details>
|
|
303
|
+
<summary>Cursor (<code>setup --agent cursor</code>)</summary>
|
|
304
|
+
|
|
305
|
+
<br />
|
|
306
|
+
|
|
307
|
+
- **`.cursor/hooks.json`** in the project gets nine capture entries, each with a short timeout,
|
|
308
|
+
and on Cursor 3.21.16 or later three fail-closed enforcement entries. Every other entry is
|
|
309
|
+
kept. The file is kept out of git with a line in `.git/info/exclude`.
|
|
310
|
+
- **A repository that already tracks `.cursor/hooks.json`** gets its entries in your user-level
|
|
311
|
+
`~/.cursor/hooks.json` instead, behind a small shell gate that answers only for your connected
|
|
312
|
+
folders. This needs `/bin/sh`, so it is not available on Windows.
|
|
313
|
+
- **`~/.agenttrail/cursor/`** holds the hook runtime, the queue, the list of connected
|
|
314
|
+
projects, and this machine's Cursor credential.
|
|
315
|
+
|
|
316
|
+
Cursor setup always signs in through the browser and connects one project at a time.
|
|
317
|
+
`--key`, `--team` and `--global` are refused. Setup also refuses a folder that contains your
|
|
318
|
+
home folder.
|
|
319
|
+
|
|
320
|
+
</details>
|
|
321
|
+
|
|
322
|
+
## API keys for CI and headless machines
|
|
323
|
+
|
|
324
|
+
<details>
|
|
325
|
+
<summary>Set up Claude Code without a browser</summary>
|
|
326
|
+
|
|
327
|
+
<br />
|
|
328
|
+
|
|
329
|
+
Device sign-in needs a browser. On a machine without one, use an API key from the AgentTrail
|
|
330
|
+
app with your organization's id:
|
|
331
|
+
|
|
332
|
+
```sh
|
|
333
|
+
export AGENTTRAIL_API_KEY="<your API key>"
|
|
334
|
+
npx -y @agenttrail/cli@latest setup --agent claude --org <your-org-uuid>
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
`--key` passes the key on the command line instead of the environment, and
|
|
338
|
+
`$AGENTTRAIL_ORG_ID` can stand in for `--org`. With an API key, `.agenttrail.json` holds the
|
|
339
|
+
key, so it is written at mode `0600` and kept out of git like the other per-machine files.
|
|
340
|
+
API keys work with Claude Code only.
|
|
341
|
+
|
|
342
|
+
</details>
|
|
343
|
+
|
|
344
|
+
## Machine-wide and team installs
|
|
345
|
+
|
|
346
|
+
<details>
|
|
347
|
+
<summary><code>--global</code> and <code>--team</code> (Claude Code only)</summary>
|
|
348
|
+
|
|
349
|
+
<br />
|
|
350
|
+
|
|
351
|
+
- **`--global`** connects every Claude Code session on this machine, in every folder, by
|
|
352
|
+
pointing Claude Code's own OpenTelemetry exporter at AgentTrail from `~/.claude/settings.json`.
|
|
353
|
+
It prints a warning first. Setup refuses if that file is inside a git or dotfiles repository,
|
|
354
|
+
because it would hold your credential. In this mode Claude Code sends the content itself, so
|
|
355
|
+
it is scrubbed at ingest only, not on your machine.
|
|
356
|
+
- **`--team`** writes key-free settings to `.claude/settings.json` that are meant to be
|
|
357
|
+
committed. Each developer supplies their own key through the environment. It never writes
|
|
358
|
+
the enforcement switch or a token.
|
|
359
|
+
|
|
360
|
+
On a machine with a `--global` install, a project connected afterwards leaves session upload
|
|
361
|
+
to the global exporter.
|
|
362
|
+
|
|
363
|
+
</details>
|
|
364
|
+
|
|
365
|
+
## Moving from AgentTrail Guard
|
|
366
|
+
|
|
367
|
+
<details>
|
|
368
|
+
<summary>How setup stands AgentTrail Guard down, project by project</summary>
|
|
369
|
+
|
|
370
|
+
<br />
|
|
371
|
+
|
|
372
|
+
You don't need to uninstall [AgentTrail Guard](https://github.com/agenttrailhq/guard). Run
|
|
373
|
+
`setup --agent claude` in each project you want AgentTrail OS to decide in; Guard keeps
|
|
374
|
+
protecting every other project.
|
|
375
|
+
|
|
376
|
+
1. **Setup checks Guard first, before writing anything.** If your Guard is older than 0.4.14
|
|
377
|
+
and can't stand down, setup stops and prints how to update it, or to uninstall it. With
|
|
378
|
+
`--global`, setup offers to remove Guard instead.
|
|
379
|
+
2. **After enforcement is verified, it shows what AgentTrail OS won't enforce yet:** your own
|
|
380
|
+
Guard rules, library rules your organization turned off, and actions you made stricter.
|
|
381
|
+
With nothing missing, Guard stands down in this project. Otherwise setup asks, and the
|
|
382
|
+
default is no; without a terminal, pass `--accept-guard-gap`. An organization with no
|
|
383
|
+
enabled policies never gets Guard stood down.
|
|
384
|
+
3. **Standing down is recorded only on this machine**, in
|
|
385
|
+
`~/.agenttrail/os/enforced-projects.json`. Guard steps aside in a project only when that
|
|
386
|
+
record, the enforcement settings, the credential and the enabled plugin all agree, so a
|
|
387
|
+
repository's own settings can't make it stand down. When anything disagrees, both run: two
|
|
388
|
+
prompts, never none.
|
|
389
|
+
4. **Your settings come with you through a file.** Setup writes
|
|
390
|
+
`~/.agenttrail/os/guard-import.json`, with no token in it, and prints its SHA-256. In the
|
|
391
|
+
app, **Governance ▸ Import from Guard** reads it in your browser, shows every change, and
|
|
392
|
+
applies the ones you tick. Your allowlist and any action you made weaker don't carry over.
|
|
393
|
+
Once the import is applied, `setup --stand-down-guard` stands Guard down.
|
|
394
|
+
5. **Setup prints what changes**, computed from your settings: what happens when AgentTrail
|
|
395
|
+
can't be reached, `ask` rules becoming holds in the approval queue, and that your
|
|
396
|
+
`permissions.allow` rules can't skip an approval while a reviewer can still answer it.
|
|
397
|
+
|
|
398
|
+
`status` says whether Guard stands down in the current project, and lists what isn't enforced
|
|
399
|
+
until your import is applied. `logout` takes the project out of the record, and Guard
|
|
400
|
+
enforces there again from the next tool call.
|
|
401
|
+
|
|
402
|
+
For Cursor, setup stops while Guard's Cursor hooks are installed, because Guard can't yet
|
|
403
|
+
stand down in Cursor. Remove them with
|
|
404
|
+
`npx -y @agenttrail/guard@latest uninstall --agent cursor` first; your Guard settings stay.
|
|
405
|
+
|
|
406
|
+
</details>
|
|
407
|
+
|
|
408
|
+
## Disconnecting
|
|
409
|
+
|
|
410
|
+
<details>
|
|
411
|
+
<summary>What <code>logout</code> and <code>--unregister</code> remove</summary>
|
|
412
|
+
|
|
413
|
+
<br />
|
|
414
|
+
|
|
415
|
+
**Claude Code: `logout --agent claude`** revokes this device's sign-in, deletes
|
|
416
|
+
`~/.agenttrail/credentials.json`, removes the enforcement plugin and its marketplace, and
|
|
417
|
+
strips the enforcement settings from your settings files. It keeps the capture hooks in
|
|
418
|
+
`.claude/settings.json`, `.agenttrail.json`, and the `.git/info/exclude` lines. With no
|
|
419
|
+
credential the hooks upload nothing; delete them from `.claude/settings.json` to remove them
|
|
420
|
+
completely.
|
|
421
|
+
|
|
422
|
+
**Cursor: `logout --agent cursor`** sends what is still queued, removes the CLI's entries from
|
|
423
|
+
every connected folder and from `~/.cursor/hooks.json`, deletes this machine's Cursor state,
|
|
424
|
+
including the import checkpoint, and revokes the device.
|
|
425
|
+
|
|
426
|
+
**Cursor: `setup --agent cursor --unregister`** disconnects just this project and keeps the
|
|
427
|
+
device signed in.
|
|
428
|
+
|
|
429
|
+
You can also revoke a device from the AgentTrail app, under Governance ▸ Devices.
|
|
430
|
+
|
|
431
|
+
</details>
|
|
432
|
+
|
|
433
|
+
## Backfill
|
|
434
|
+
|
|
435
|
+
<details>
|
|
436
|
+
<summary>Import the sessions already on your disk</summary>
|
|
437
|
+
|
|
438
|
+
<br />
|
|
439
|
+
|
|
440
|
+
```sh
|
|
441
|
+
npx -y @agenttrail/cli@latest backfill --agent claude --scan # list; uploads nothing
|
|
442
|
+
npx -y @agenttrail/cli@latest backfill --agent claude --import --dry-run # preview
|
|
443
|
+
npx -y @agenttrail/cli@latest backfill --agent claude --import --since 7d # import the last week
|
|
444
|
+
npx -y @agenttrail/cli@latest backfill --agent claude --status # the checkpoint
|
|
445
|
+
npx -y @agenttrail/cli@latest backfill --agent claude --resume # skip done, retry failed
|
|
269
446
|
```
|
|
270
447
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
- **
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
448
|
+
- **One project at a time.** `--scan` and `--import` cover only the project you run them in,
|
|
449
|
+
matched on each session's recorded working directory. Other projects' sessions are counted,
|
|
450
|
+
never named. To import another project, run it there. `--status` is machine-wide.
|
|
451
|
+
- **Metadata and tokens by default.** `--content` adds prompts and tool content, scrubbed on
|
|
452
|
+
your machine before upload and again at ingest. `--dry-run --content` shows what would be
|
|
453
|
+
redacted before anything leaves the machine.
|
|
454
|
+
- **Safe to re-run.** Ids are derived from each session, so an import never double-counts.
|
|
455
|
+
Sessions AgentTrail already holds, captured live or imported before, are skipped; pass
|
|
456
|
+
`--reimport` to send them again.
|
|
457
|
+
- **Resumable.** Progress is kept in `~/.agenttrail/backfill-state.json`.
|
|
458
|
+
|
|
459
|
+
**Cursor** (`--agent cursor`) takes the same verbs, with these differences, each because of
|
|
460
|
+
what Cursor's session files record:
|
|
461
|
+
|
|
462
|
+
- No prompt or reply text, even with `--content`; content mode adds commands and paths only.
|
|
463
|
+
- Content follows the project's `setup` choice: a project with content capture on imports
|
|
464
|
+
commands and paths without `--content`, and one set up with `--no-capture-content` does not.
|
|
465
|
+
- No model, tokens or cost.
|
|
466
|
+
- Times are approximate, taken from the file's timestamps, and marked as such.
|
|
467
|
+
- `--since` is refused, because a Cursor session file has no time of its own.
|
|
468
|
+
- A conversation that records a path outside the project is skipped whole.
|
|
469
|
+
|
|
470
|
+
Run `setup --agent cursor` in the project first.
|
|
471
|
+
|
|
472
|
+
</details>
|
|
473
|
+
|
|
474
|
+
## Device names
|
|
475
|
+
|
|
476
|
+
<details>
|
|
477
|
+
<summary>How a device is named</summary>
|
|
478
|
+
|
|
479
|
+
<br />
|
|
480
|
+
|
|
481
|
+
Claude Code setup suggests a name built from your first name and the computer's model, such as
|
|
482
|
+
"Sam's MacBook Pro", and you can press Enter to keep it or type your own. With `--yes`, in CI,
|
|
483
|
+
or without a terminal, the suggestion is used. Your organization's admins see the name beside
|
|
484
|
+
yours. Rename it at any time:
|
|
485
|
+
|
|
486
|
+
```sh
|
|
487
|
+
npx -y @agenttrail/cli@latest device rename --agent claude "Work laptop"
|
|
307
488
|
```
|
|
308
489
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
490
|
+
A name can be up to 64 characters. One that starts with `-` goes after `--`.
|
|
491
|
+
|
|
492
|
+
</details>
|
|
493
|
+
|
|
494
|
+
## Options
|
|
495
|
+
|
|
496
|
+
<details>
|
|
497
|
+
<summary>Every option</summary>
|
|
498
|
+
|
|
499
|
+
<br />
|
|
500
|
+
|
|
501
|
+
| Option | Effect |
|
|
502
|
+
| --- | --- |
|
|
503
|
+
| `--agent <claude\|cursor\|codex>` | Required on every command. `codex` is refused for now. |
|
|
504
|
+
| `--no-capture-content` | Claude Code and Cursor: send metadata and token counts only. A later `setup` keeps this choice. |
|
|
505
|
+
| `--capture-content` | Claude Code and Cursor: turn content capture back on. |
|
|
506
|
+
| `--project <slug>` | Override the project name, which defaults to the git remote, then the folder name. |
|
|
507
|
+
| `-y`, `--yes` | Accept the suggested device name without asking. |
|
|
508
|
+
| `--key <key>` | Claude Code: API key for CI. Defaults to `$AGENTTRAIL_API_KEY`. |
|
|
509
|
+
| `--org <uuid>` | The organization the API key belongs to. Defaults to `$AGENTTRAIL_ORG_ID`. Device sign-in takes it from your account. |
|
|
510
|
+
| `--team` | Claude Code: write key-free settings meant to be committed. |
|
|
511
|
+
| `--global` | Claude Code: connect every session on this machine. |
|
|
512
|
+
| `--accept-guard-gap` | `setup --agent claude` with AgentTrail Guard installed: stand Guard down here even though it enforces rules your organization doesn't. Setup lists them. |
|
|
513
|
+
| `--stand-down-guard` | `setup --agent claude`: stand Guard down here now, after you have applied your import in the app. |
|
|
514
|
+
| `--unregister` | `setup --agent cursor` only: disconnect this project. |
|
|
515
|
+
| `--endpoint <url>` | Session upload address. Defaults to `$AGENTTRAIL_INGEST_ENDPOINT`, then `https://ingest.agenttrail.sh`. |
|
|
516
|
+
| `--api-endpoint <url>` | Sign-in and policy address. Defaults to `$AGENTTRAIL_API_ENDPOINT`, then `https://api.agenttrail.sh`. |
|
|
517
|
+
| `--refresh` | `login` only: refresh the credential if it expires within a day; otherwise do nothing. |
|
|
518
|
+
|
|
519
|
+
Backfill options are in [Backfill](#backfill), and `--help` lists them all.
|
|
520
|
+
|
|
521
|
+
</details>
|
|
522
|
+
|
|
523
|
+
## Enforcement
|
|
524
|
+
|
|
525
|
+
<details>
|
|
526
|
+
<summary>How decisions are made, and what happens when something fails</summary>
|
|
527
|
+
|
|
528
|
+
<br />
|
|
529
|
+
|
|
530
|
+
Enforcement is on by default on every plan, Free included. Setup turns it on only after it
|
|
531
|
+
has written the settings, confirmed that AgentTrail accepts this device's credential, and
|
|
532
|
+
confirmed that the plugin is installed. If any step fails, setup says why, enforcement stays
|
|
533
|
+
off, and session upload keeps working.
|
|
534
|
+
|
|
535
|
+
On each tool call the hook asks AgentTrail for a decision, with a 3-second timeout.
|
|
536
|
+
|
|
537
|
+
- **Allowed:** the hook says nothing, and Claude Code's normal permission flow continues.
|
|
538
|
+
The hook never pre-approves a call.
|
|
539
|
+
- **Blocked:** the call does not run, and the agent is told which policy stopped it.
|
|
540
|
+
- **Held:** the call waits for a person to approve or deny it in the AgentTrail app, for up to
|
|
541
|
+
about ten minutes. Approved, it goes on to Claude Code's normal permission flow; denied, it
|
|
542
|
+
is blocked. If nobody answers in time, Claude Code asks you itself, and a session with no
|
|
543
|
+
one at the terminal cannot proceed. In Cursor, an unanswered shell command is handed back
|
|
544
|
+
to Cursor to ask you, and any other tool is refused.
|
|
545
|
+
- **AgentTrail unreachable:** the call is checked against the policy snapshot cached on your
|
|
546
|
+
machine. With no snapshot, it is blocked.
|
|
547
|
+
- **Credential rejected:** the call is blocked. At the next session start, enforcement turns
|
|
548
|
+
itself off until you run `setup` again, and capture continues.
|
|
549
|
+
|
|
550
|
+
Inside Cursor, the Claude Code plugin stays silent and leaves decisions to Cursor's own
|
|
551
|
+
entries.
|
|
552
|
+
|
|
553
|
+
</details>
|
|
554
|
+
|
|
555
|
+
## Network
|
|
556
|
+
|
|
557
|
+
<details>
|
|
558
|
+
<summary>Every address the CLI contacts</summary>
|
|
559
|
+
|
|
560
|
+
<br />
|
|
561
|
+
|
|
562
|
+
| Address | When |
|
|
563
|
+
| --- | --- |
|
|
564
|
+
| `https://api.agenttrail.sh` | Sign-in and refresh; fetching the policy snapshot at setup and session start; each policy check when enforcement is on; reporting at session start whether enforcement is on for this device. |
|
|
565
|
+
| `https://ingest.agenttrail.sh` | Uploading sessions after each turn, from the Cursor sender, and from `backfill`; checking which sessions AgentTrail already holds before an import. |
|
|
566
|
+
| The npm registry | The hooks run `npx -y @agenttrail/cli@latest`. |
|
|
567
|
+
| `https://www.agenttrail.sh/device` | Opened in your browser during sign-in. |
|
|
568
|
+
|
|
569
|
+
`status`, `backfill --scan` and `backfill --status` make no network calls, and nothing is sent
|
|
570
|
+
before you sign in. Point the CLI at your own deployment with `--endpoint` and
|
|
571
|
+
`--api-endpoint`.
|
|
572
|
+
|
|
573
|
+
</details>
|
|
574
|
+
|
|
575
|
+
## Files it keeps
|
|
576
|
+
|
|
577
|
+
<details>
|
|
578
|
+
<summary>Everything under <code>~/.agenttrail/</code></summary>
|
|
579
|
+
|
|
580
|
+
<br />
|
|
581
|
+
|
|
582
|
+
Folders are created at mode `0700` and files at `0600`.
|
|
583
|
+
|
|
584
|
+
| File | What it is |
|
|
585
|
+
| --- | --- |
|
|
586
|
+
| `credentials.json` | Claude Code's device credential. Deleted by `logout`. |
|
|
587
|
+
| `cursor/` | Cursor's credential, hook runtime, queue, connected projects and import checkpoint. Cleared by `logout --agent cursor`. |
|
|
588
|
+
| `device.json` | This device's model and name. Never your computer's hostname. |
|
|
589
|
+
| `machine-id`, `installs.json` | Random ids, so the app can show which devices have enforcement on. |
|
|
590
|
+
| `pep-snapshot.json` | The cached policy snapshot used when AgentTrail is unreachable. |
|
|
591
|
+
| `session-upload/` | Which turns of each session were sent, so none is sent twice. Pruned after 30 days. |
|
|
592
|
+
| `session-upload.log` | One line per upload, with no content or secrets. Rotated past 512 KiB. |
|
|
593
|
+
| `backfill-state.json` | The Claude Code import checkpoint. |
|
|
594
|
+
| `config.json` | Settings for a `--global` install. |
|
|
595
|
+
| `os/enforced-projects.json` | The projects where AgentTrail Guard stands down for AgentTrail OS. |
|
|
596
|
+
| `os/guard-import.json` | Your Guard settings, for **Import from Guard** in the app. Holds no token. |
|
|
597
|
+
|
|
598
|
+
</details>
|
|
599
|
+
|
|
600
|
+
## License
|
|
601
|
+
|
|
602
|
+
Apache-2.0. See [LICENSE](https://www.apache.org/licenses/LICENSE-2.0).
|