agentbox-flight-recorder 0.2.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AGENTBOX contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,306 @@
1
+ <div align="center">
2
+
3
+ # ⬢ AGENTBOX
4
+
5
+ ### The black-box flight recorder for AI agents
6
+
7
+ **Your agents have root. Who's watching?**
8
+
9
+ `npm test` for your agent's behavior · tamper-evident · 100% local · zero dependencies
10
+
11
+ [![CI](https://github.com/arunsoman/agentbox/actions/workflows/ci.yml/badge.svg)](https://github.com/arunsoman/agentbox/actions/workflows/ci.yml)
12
+ ![zero dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)
13
+ ![node](https://img.shields.io/badge/node-%E2%89%A518-blue)
14
+ ![license](https://img.shields.io/badge/license-MIT-black)
15
+ ![telemetry](https://img.shields.io/badge/telemetry-none-success)
16
+
17
+ </div>
18
+
19
+ ---
20
+
21
+ AI agents now run your shell, edit your files, and ship to prod — often with zero humans in the loop. The tooling explosion of 2026 made software *agent-native*… and produced exactly one new question:
22
+
23
+ > **"What did my agent actually do while I was away?"**
24
+
25
+ AGENTBOX is the answer. Strap a flight recorder to **any** command or agent — no SDK, no code changes, no cloud — and get a tamper-evident tape of everything it did: every tool call, every file touched, every URL hit. Scrub through it like security footage when (not if) something goes wrong.
26
+
27
+ ```bash
28
+ npx agentbox-flight-recorder demo # see it in 10 seconds — no install, no config
29
+ ```
30
+
31
+ Or wrap your own agent:
32
+
33
+ ```bash
34
+ agentbox wrap --name prod-deploy -- node agent.js "deploy the release"
35
+ ⬢ agentbox: black box on → recording to .agentbox/sessions/2026-09-25T…-prod-deploy.jsonl
36
+ ```
37
+
38
+ ## 🧾 The receipt
39
+
40
+ Every session ends with a one-page flight receipt. This is **real output** from `agentbox demo`:
41
+
42
+ ```
43
+ ⬢ A G E N T B O X R E C E I P T
44
+ ┌──────────────────────────────────────────────────┐
45
+ │ session demo-deploy │
46
+ │ command node examples/fake-agen… │
47
+ │ started 2026-09-24 18:40:52 │
48
+ │ duration 5.4s │
49
+ │ exit code 0 (clean landing) │
50
+ ├──────────────────────────────────────────────────┤
51
+ │ tool calls 7 │
52
+ │ · bash("git status --s… │
53
+ │ · write(src/deploy.sh … │
54
+ │ · bash("./deploy.sh --… │
55
+ │ … +4 more │
56
+ │ shell commands 1 │
57
+ │ · rm -rf /tmp/old-buil… │
58
+ │ files touched 2 · 1 written · 1 edited │
59
+ │ · src/deploy.sh wrote │
60
+ │ · config.yaml edited │
61
+ │ urls hit 1 │
62
+ │ output volume 808 B across 17 lines │
63
+ │ stderr lines 0 │
64
+ │ humans consulted 0 (unsupervised flight) │
65
+ ├──────────────────────────────────────────────────┤
66
+ │ events recorded 19 │
67
+ │ tamper chain sha256 · intact │
68
+ └──────────────────────────────────────────────────┘
69
+ uneventful flight. the best kind.
70
+ ```
71
+
72
+ ## 📼 The replay
73
+
74
+ `agentbox replay <file>` opens an interactive scrubber — security footage for your terminal:
75
+
76
+ - **Timeline bar** with markers: `▲` tool call · `$` shell · `✎` file op · `i` human input
77
+ - **Play / pause / speed** (1×–64×) — skip to `00:47.2`, the moment it dropped the table
78
+ - **Every keystroke the human typed** is on the tape (`HUMAN` lines)
79
+ - `--headless` renders a static frame for CI, GIFs, and GitHub
80
+
81
+ Keys: `[space]` play/pause · `[←/→]` step event · `[j/k]` ±10s · `[[/]]` speed · `[g/G]` start/end · `[q]` quit
82
+
83
+ ## 🔐 Tamper-evident tapes
84
+
85
+ Every event is hash-chained — each line commits to the previous one, Genesis to tip:
86
+
87
+ ```
88
+ { i, t, type, data, prev, hash } hash = sha256(prev ‖ i ‖ t ‖ type ‖ data)
89
+ ```
90
+
91
+ Edit one line — even a single character — and `agentbox verify` pins the exact event:
92
+
93
+ ```
94
+ $ agentbox verify
95
+ ✗ hash mismatch at event 7 — event was tampered with or forged
96
+ ```
97
+
98
+ This detects accidental corruption and edits that do not rebuild the chain. Because the chain is not signed or externally anchored, someone who can rewrite the whole file can also recompute its hashes. Treat it as an integrity check and audit aid—not cryptographic proof of origin.
99
+
100
+ ## 🛡️ Security & privacy
101
+
102
+ **Secrets never land on the tape.** Every string written to a session file is scrubbed *before* it is hashed and appended. The chain commits to the redacted form, so the original secret is not recoverable from the file, the receipt, or a shared clip.
103
+
104
+ Default patterns catch:
105
+
106
+ | Family | Examples |
107
+ |--------|----------|
108
+ | API tokens | OpenAI `sk-…`, Anthropic `sk-ant-…`, GitHub `ghp_…`, Stripe `sk_live_…`, Slack `xoxb-…`, Google `AIza…` |
109
+ | Cloud keys | AWS `AKIA…` / secret-access-key assignments |
110
+ | Auth headers | `Bearer …`, JWTs |
111
+ | Private keys | `-----BEGIN … PRIVATE KEY-----` |
112
+ | Assignments | `password=…`, `api_key=…`, `"client_secret": "…"` |
113
+ | Connection strings | `postgres://user:pass@host/db` |
114
+
115
+ **Controls**
116
+
117
+ ```bash
118
+ AGENTBOX_REDACT=0 # disable (not recommended)
119
+ AGENTBOX_REDACT_EXTRA='myco-.*|internal-token-\w+' # extra JS regexes, | -separated
120
+ ```
121
+
122
+ Or project-local config:
123
+
124
+ ```json
125
+ // .agentbox/config.json
126
+ {
127
+ "redact": true,
128
+ "redactPatterns": ["my-internal-secret-[A-Z0-9]+"]
129
+ }
130
+ ```
131
+
132
+ The session meta event records `redact: true|false` so the policy is visible on the tape. Redaction is deterministic — same input always yields the same placeholder — which keeps the hash chain stable.
133
+
134
+ > Still treat session files as sensitive. Redaction is best-effort pattern matching; novel secret formats can slip through. Do not commit `.agentbox/` to public repos without review.
135
+
136
+ ## 🚀 Quickstart
137
+
138
+ ```bash
139
+ # 1. Watch a scripted agent get recorded (10 seconds)
140
+ npx agentbox-flight-recorder demo
141
+
142
+ # 2. Wrap anything — your agent, a script, any CLI
143
+ agentbox wrap -- claude "refactor auth.js"
144
+ agentbox wrap --name eval-run -- python evaluate.py --suite prod
145
+
146
+ # 3. Read the tape
147
+ agentbox list # all sessions
148
+ agentbox receipt # newest session, one page
149
+ agentbox replay <file> # scrub the footage
150
+ agentbox verify # tamper check
151
+
152
+ # 4. Share a moment, not a dump
153
+ agentbox clip <file> --from 30 --to 75 # → self-contained .clip.html
154
+
155
+ # 5. Or skip the wrapper entirely — passive mode
156
+ agentbox init claude # hooks → every claude session, recorded
157
+ agentbox mcp -- npx -y @modelcontextprotocol/server-everything # wire tap
158
+ ```
159
+
160
+ No install, no config, no accounts. Sessions land in `./.agentbox/sessions/` next to your repo — commit them if you want receipts in git history.
161
+
162
+ ## 👻 Passive mode — no wrapper needed
163
+
164
+ Wrapping is for flights you know about in advance. Adapters are for the ones you don't.
165
+
166
+ ### Claude Code hooks — one command, then forget about it
167
+
168
+ ```bash
169
+ agentbox init claude # merges hooks into .claude/settings.json (idempotent, backs up first)
170
+ agentbox init claude --local # .claude/settings.local.json instead (gitignored by default)
171
+ agentbox init claude --remove # clean uninstall
172
+ ```
173
+
174
+ From the next session on, Claude Code quietly feeds every event to `agentbox hook claude`:
175
+
176
+ | hook event | what lands on the tape |
177
+ |---|---|
178
+ | `SessionStart` | flight opened |
179
+ | `UserPromptSubmit` | every prompt you type |
180
+ | `PreToolUse` | every tool call **before it runs** — name + full arguments |
181
+ | `PostToolUse` | every result — ok / error |
182
+ | `Notification` | agent pings ("needs your permission to run `rm -rf`") |
183
+ | `Stop` | turn boundaries |
184
+ | `SessionEnd` | flight closed + **auto receipt** → `.agentbox/receipts/` |
185
+
186
+ The hook handler is engineered to be invisible: exits 0 even when agentbox itself fails, never prints to stdout, drops an event under contention rather than corrupt the chain. **If recording ever breaks, the agent doesn't.** And because tool calls are captured *structured* — not scraped off a TUI — receipts for passive sessions read better than wrapped ones:
187
+
188
+ ```
189
+ │ recorded via claude code hooks │
190
+ │ tool calls 12 │
191
+ │ · Bash(npm test -- --ci) │
192
+ │ · Edit(src/auth.js — session rotation) │
193
+ │ files touched 3 · 2 edited · 1 written │
194
+ ```
195
+
196
+ ### MCP — the wire tap between agent and tools
197
+
198
+ An agent's *real* capability boundary is its MCP servers. Agentbox runs any server behind a recording proxy:
199
+
200
+ ```
201
+ ┌────────┐ JSON-RPC ┌─────────────┐ JSON-RPC ┌──────────────┐
202
+ │ agent │ ──────────► │ agentbox mcp │ ──────────► │ real server │
203
+ │ client │ ◄────────── │ (records) │ ◄────────── │ (unchanged) │
204
+ └────────┘ └─────────────┘ └──────────────┘
205
+ ```
206
+
207
+ ```bash
208
+ agentbox mcp -- npx -y @modelcontextprotocol/server-everything
209
+ agentbox init mcp -- npx -y @modelcontextprotocol/server-everything # prints config blocks
210
+ ```
211
+
212
+ Point any MCP client at agentbox instead of the server — Claude Desktop, Cursor, Claude Code (`.mcp.json`), any harness. The proxy forwards messages verbatim (zero protocol awareness needed by the server) and hash-chains every `tools/call`: arguments before, result after, duration between, error status included. `agentbox verify` works on wire taps exactly like wrapped flights.
213
+
214
+ > Wrap = capture the terminal. Hooks = capture the session. Wire tap = capture the protocol. Same tape, same receipts, same integrity checks.
215
+
216
+ ## 🤖 The GitHub Action
217
+
218
+ Post a flight receipt on every PR an agent touches:
219
+
220
+ ```yaml
221
+ permissions:
222
+ issues: write
223
+
224
+ steps:
225
+ - uses: arunsoman/agentbox@v1
226
+ if: always()
227
+ with:
228
+ session: .agentbox/sessions/deploy.jsonl # optional, defaults to newest
229
+ ```
230
+
231
+ The PR gets a markdown receipt — tool calls, files touched, exit code, chain status. Reviewers see what the agent did *before* they read a single diff. Workflows triggered from forks normally receive a read-only token and cannot post comments; use a separately reviewed workflow if fork comments are required.
232
+
233
+ ## 🧠 How it works
234
+
235
+ ```
236
+ ┌──────────────────────────────────────┐
237
+ │ agentbox wrap -- <any command> │
238
+ └───────────────┬──────────────────────┘
239
+ │ spawn (zero code changes)
240
+ ┌───────────┬───────────┼───────────┬──────────────┐
241
+ ▼ ▼ ▼ ▼ ▼
242
+ stdout stderr stdin exit signals
243
+ │ │ │ │ │
244
+ └───────────┴─────┬─────┴───────────┴──────────────┘
245
+ ▼
246
+ line classifier (heuristics)
247
+ tool · shell · file · net · human
248
+ │
249
+ ▼
250
+ ┌─────────────────────────────────┐
251
+ │ hash-chained JSONL tape │ ← tamper-evident
252
+ │ .agentbox/sessions/*.jsonl │ ← 100% local
253
+ └─────────────────────────────────┘
254
+ │ │ │
255
+ ▼ ▼ ▼
256
+ replay receipt clip
257
+ (TUI) (text/md/json) (HTML)
258
+ ```
259
+
260
+ AGENTBOX records the *terminal truth* — everything the process actually emitted — then classifies lines with transparent heuristics (`[TOOL] name(args)` convention, shell-command patterns, file-op verbs, URLs). Bring-your-own parser plugins are on the roadmap; the tape stays raw either way.
261
+
262
+ ## ⚡ Zero dependencies. Literally.
263
+
264
+ The entire runtime is Node built-ins — `crypto`, `fs`, `child_process`. No `node_modules`. No supply chain. No phone-home. A flight recorder you can't audit would be a joke, so agentbox is ~1,000 lines of auditable code.
265
+
266
+ ```bash
267
+ git clone https://github.com/arunsoman/agentbox && cd agentbox
268
+ node --test # nothing to install. there is nothing to install.
269
+ ```
270
+
271
+ ## 🗺️ Roadmap
272
+
273
+ - [x] ~~MCP / Claude Code hook adapters (record without wrapping)~~ — **shipped in 0.2.0**: `agentbox init claude`, `agentbox hook`, `agentbox mcp`
274
+ - [ ] `agentbox diff <a> <b>` — compare two runs of the same task
275
+ - [ ] `agentbox guard` — replay a session against rules, fail CI on violations
276
+ - [ ] Parser plugins for popular agent frameworks
277
+ - [ ] Windows raw-mode polish (works via WSL today)
278
+ - [ ] `agentbox canary` — crash-only checkpoints + resume
279
+
280
+ ## 🤝 Contributing
281
+
282
+ Three hard rules: **zero runtime deps**, **100% local**, **never silently weaken tape integrity**. Everything else is negotiable. See [CONTRIBUTING.md](CONTRIBUTING.md).
283
+
284
+ ## FAQ
285
+
286
+ **Does this work with Claude Code / Cursor / OpenClaw / my framework?**
287
+ Three ways, all first-class: `agentbox wrap -- <your agent command>` for anything in a terminal, `agentbox init claude` for passive Claude Code capture, and `agentbox mcp -- <server>` for any MCP client. Same tape underneath.
288
+
289
+ **Isn't this just logging?**
290
+ Logging is usually unstructured text. AGENTBOX adds a hash-linked integrity check, classification, replay, and shareable clips. It is universal—one recorder for every agent, not one per framework—but an unsigned local tape is not independently authenticated.
291
+
292
+ **Why not a SaaS dashboard?**
293
+ Because the answer to "can I trust my agent" should not be "trust this vendor too." Your black box lives in your repo, works offline forever, and can be audited in an afternoon.
294
+
295
+ **Where do sessions go?**
296
+ `./.agentbox/sessions/` — plain JSONL, commit-able, grep-able, yours.
297
+
298
+ ---
299
+
300
+ <div align="center">
301
+
302
+ **If your agent has ever scared you at 2am, you need a black box.** ⭐
303
+
304
+ MIT © 2026 AGENTBOX contributors — *fly safe.*
305
+
306
+ </div>
package/action.yml ADDED
@@ -0,0 +1,52 @@
1
+ name: 'AGENTBOX receipt'
2
+ description: 'Post a AGENTBOX flight receipt as a PR comment for every AI-agent session recorded during the workflow.'
3
+ branding:
4
+ icon: 'radio'
5
+ color: 'green'
6
+
7
+ inputs:
8
+ session:
9
+ description: 'Path to a .jsonl session file. Defaults to newest in ./.agentbox/sessions.'
10
+ required: false
11
+ header:
12
+ description: 'Comment header'
13
+ required: false
14
+ default: '⬢ Agent flight receipt (recorded by [agentbox](https://github.com/arunsoman/agentbox))'
15
+
16
+ runs:
17
+ using: 'composite'
18
+ steps:
19
+ - uses: actions/setup-node@v4
20
+ with:
21
+ node-version: 20
22
+
23
+ - name: Build receipt
24
+ shell: bash
25
+ env:
26
+ INPUT_SESSION: ${{ inputs.session }}
27
+ run: |
28
+ SESSION="$INPUT_SESSION"
29
+ if [ -z "$SESSION" ]; then
30
+ SESSION=$(ls -t .agentbox/sessions/*.jsonl 2>/dev/null | head -1 || true)
31
+ fi
32
+ if [ -z "$SESSION" ]; then
33
+ echo "no session found — did your agent run under 'agentbox wrap'?" >&2
34
+ exit 1
35
+ fi
36
+ node "${{ github.action_path }}/bin/agentbox.js" receipt "$SESSION" --md > agentbox-receipt.md
37
+
38
+ - name: Comment on PR
39
+ if: github.event_name == 'pull_request'
40
+ uses: actions/github-script@v7
41
+ env:
42
+ INPUT_HEADER: ${{ inputs.header }}
43
+ with:
44
+ script: |
45
+ const fs = require('fs');
46
+ const body = process.env.INPUT_HEADER + '\n\n' + fs.readFileSync('agentbox-receipt.md', 'utf8');
47
+ await github.rest.issues.createComment({
48
+ owner: context.repo.owner,
49
+ repo: context.repo.repo,
50
+ issue_number: context.issue.number,
51
+ body
52
+ });
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ require('../src/cli.js')();