@node9/proxy 1.0.13 → 1.0.15

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.
Files changed (6) hide show
  1. package/README.md +188 -119
  2. package/dist/cli.js +2335 -1097
  3. package/dist/cli.mjs +2315 -1075
  4. package/dist/index.js +500 -125
  5. package/dist/index.mjs +500 -125
  6. package/package.json +1 -1
package/README.md CHANGED
@@ -29,7 +29,7 @@ While others try to _guess_ if a prompt is malicious (Semantic Security), Node9
29
29
 
30
30
  ---
31
31
 
32
- ## ⚡ Key Architectural Upgrades
32
+ ## ⚡ Key Features
33
33
 
34
34
  ### 🏁 The Multi-Channel Race Engine
35
35
 
@@ -40,9 +40,39 @@ Node9 initiates a **Concurrent Race** across all enabled channels. The first cha
40
40
  - **Cloud (Slack):** Remote asynchronous approval for team governance.
41
41
  - **Terminal:** Classic `[Y/n]` prompt for manual proxy usage and SSH sessions.
42
42
 
43
+ ### 🛰️ Flight Recorder — See Everything, Instantly
44
+
45
+ Node9 records every tool call your AI agent makes in real-time — no polling, no log files, no refresh. Two ways to watch:
46
+
47
+ **Browser Dashboard** (`node9 daemon start` → `localhost:7391`)
48
+
49
+ 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.
50
+
51
+ **Terminal** (`node9 tail`)
52
+
53
+ A split-pane friendly stream for terminal-first developers and SSH sessions:
54
+
55
+ ```bash
56
+ node9 tail # live events only
57
+ node9 tail --history # replay recent history then go live
58
+ node9 tail | grep DLP # filter to DLP blocks only
59
+ ```
60
+
61
+ ```
62
+ 🛰️ Node9 tail → localhost:7391
63
+ Showing live events. Press Ctrl+C to exit.
64
+
65
+ 21:06:58 📖 Read {"file_path":"src/core.ts"} ✓ ALLOW
66
+ 21:06:59 🔍 Grep {"pattern":"authorizeHeadless"} ✓ ALLOW
67
+ 21:07:01 💻 Bash {"command":"npm run build"} ✓ ALLOW
68
+ 21:07:04 💻 Bash {"command":"curl … Bearer sk-ant-…"} ✗ BLOCK 🛡️ DLP
69
+ ```
70
+
71
+ `node9 tail` auto-starts the daemon if it isn't running — no setup step needed.
72
+
43
73
  ### 🧠 AI Negotiation Loop
44
74
 
45
- Node9 doesn't just "cut the wire." When a command is blocked, it injects a **Structured Negotiation Prompt** back into the AIs context window. This teaches the AI why it was stopped and instructs it to pivot to a safer alternative or apologize to the human.
75
+ 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.
46
76
 
47
77
  ### ⏪ Shadow Git Snapshots (Auto-Undo)
48
78
 
@@ -56,41 +86,11 @@ node9 undo
56
86
  node9 undo --steps 3
57
87
  ```
58
88
 
59
- Example output:
60
-
61
- ```
62
- ⏪ Node9 Undo
63
- Tool: str_replace_based_edit_tool → src/app.ts
64
- When: 2m ago
65
- Dir: /home/user/my-project
66
-
67
- --- src/app.ts (snapshot)
68
- +++ src/app.ts (current)
69
- @@ -1,4 +1,6 @@
70
- -const x = 1;
71
- +const x = 99;
72
- +const y = "hello";
73
-
74
- Revert to this snapshot? [y/N]
75
- ```
76
-
77
- Node9 keeps the last 10 snapshots. Snapshots are only taken for file-writing tools (`write_file`, `edit_file`, `str_replace_based_edit_tool`, `create_file`) — not for read-only or shell commands.
78
-
79
- ### 🌊 The Resolution Waterfall
80
-
81
- Security posture is resolved using a strict 5-tier waterfall:
82
-
83
- 1. **Env Vars:** Session-level overrides (e.g., `NODE9_PAUSED=1`).
84
- 2. **Cloud (SaaS):** Global organization "Locks" that cannot be bypassed locally.
85
- 3. **Project Config:** Repository-specific rules (`node9.config.json`).
86
- 4. **Global Config:** Personal UI preferences (`~/.node9/config.json`).
87
- 5. **Defaults:** The built-in safety net.
88
-
89
89
  ---
90
90
 
91
91
  ## 🎮 Try it Live
92
92
 
93
- No install needed — test Node9's AST parser against real commands in the browser:
93
+ No install needed — test Node9's policy engine against real commands in the browser:
94
94
 
95
95
  [![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)
96
96
 
@@ -106,19 +106,91 @@ brew install node9
106
106
  # Or via npm
107
107
  npm install -g @node9/proxy
108
108
 
109
- # 1. Setup protection for your favorite agent
109
+ # 1. Wire Node9 to your agent
110
110
  node9 setup # interactive menu — picks the right agent for you
111
111
  node9 addto claude # or wire directly
112
112
  node9 addto gemini
113
113
 
114
- # 2. Initialize your local safety net
115
- node9 init
114
+ # 2. Enable shields for the services you use
115
+ node9 shield enable postgres
116
+ node9 shield enable aws
116
117
 
117
118
  # 3. Verify everything is wired correctly
118
119
  node9 doctor
120
+ ```
121
+
122
+ ---
123
+
124
+ ## 🛡️ How Protection Works
125
+
126
+ Node9 has two layers of protection. You get Layer 1 automatically. Layer 2 is one command per service.
127
+
128
+ ### Layer 1 — Core Protection (Always On)
129
+
130
+ Built into the binary. Zero configuration required. Protects the tools every developer uses.
119
131
 
120
- # 4. Check your status
121
- node9 status
132
+ | What it protects | Example blocked action |
133
+ | :---------------- | :------------------------------------------------------ |
134
+ | **Git** | `git push --force`, `git reset --hard`, `git clean -fd` |
135
+ | **Shell** | `curl ... \| bash`, `sudo` commands |
136
+ | **SQL** | `DELETE` / `UPDATE` without a `WHERE` clause |
137
+ | **Filesystem** | `rm -rf` targeting home directory |
138
+ | **Secrets (DLP)** | AWS keys, GitHub tokens, Stripe keys, PEM private keys |
139
+
140
+ ### 🔍 DLP — Content Scanner (Always On)
141
+
142
+ 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.
143
+
144
+ **Built-in patterns:**
145
+
146
+ | Pattern | Severity | Prefix format |
147
+ | :---------------- | :------- | :-------------------------- |
148
+ | AWS Access Key ID | `block` | `AKIA` + 16 chars |
149
+ | GitHub Token | `block` | `ghp_`, `gho_`, `ghs_` |
150
+ | Slack Bot Token | `block` | `xoxb-` |
151
+ | OpenAI API Key | `block` | `sk-` + 20+ chars |
152
+ | Stripe Secret Key | `block` | `sk_live_` / `sk_test_` |
153
+ | PEM Private Key | `block` | `-----BEGIN PRIVATE KEY---` |
154
+ | Bearer Token | `review` | `Authorization: Bearer ...` |
155
+
156
+ `block` = hard deny, no approval prompt. `review` = routed through the normal race engine for human approval.
157
+
158
+ Secrets are **never logged in full** — the audit trail stores only a redacted sample (`AKIA****MPLE`).
159
+
160
+ **Config knobs** (in `node9.config.json` or `~/.node9/config.json`):
161
+
162
+ ```json
163
+ {
164
+ "policy": {
165
+ "dlp": {
166
+ "enabled": true,
167
+ "scanIgnoredTools": true
168
+ }
169
+ }
170
+ }
171
+ ```
172
+
173
+ | Key | Default | Description |
174
+ | :--------------------- | :------ | :----------------------------------------------------------------- |
175
+ | `dlp.enabled` | `true` | Master switch — disable to turn off all DLP scanning |
176
+ | `dlp.scanIgnoredTools` | `true` | Also scan tools in `ignoredTools` (e.g. `web_search`, `read_file`) |
177
+
178
+ ### Layer 2 — Shields (Opt-in, Per Service)
179
+
180
+ Shields add protection for specific infrastructure and services — only relevant if you actually use them.
181
+
182
+ | Shield | What it protects |
183
+ | :----------- | :---------------------------------------------------------------------------- |
184
+ | `postgres` | Blocks `DROP TABLE`, `TRUNCATE`, `DROP COLUMN`; reviews `GRANT`/`REVOKE` |
185
+ | `github` | Blocks `gh repo delete`; reviews remote branch deletion |
186
+ | `aws` | Blocks S3 bucket deletion, EC2 termination; reviews IAM changes, RDS deletion |
187
+ | `filesystem` | Reviews `chmod 777`, writes to `/etc/` |
188
+
189
+ ```bash
190
+ node9 shield enable postgres # protect your database
191
+ node9 shield enable aws # protect your cloud infrastructure
192
+ node9 shield list # see all available shields
193
+ node9 shield status # see what's currently active
122
194
  ```
123
195
 
124
196
  ---
@@ -133,78 +205,55 @@ node9 status
133
205
 
134
206
  ---
135
207
 
136
- ## ⚙️ Configuration (`node9.config.json`)
208
+ ## 🔗 Configuration Precedence
209
+
210
+ Node9 merges configuration from multiple sources in priority order. Higher tiers win:
211
+
212
+ | Tier | Source | Notes |
213
+ | :--- | :------------------------ | :-------------------------------------------------------- |
214
+ | 1 | **Environment variables** | `NODE9_MODE=strict` overrides everything |
215
+ | 2 | **Cloud / Org policy** | Set in the Node9 dashboard — cannot be overridden locally |
216
+ | 3 | **Project config** | `node9.config.json` in the working directory |
217
+ | 4 | **Global config** | `~/.node9/config.json` |
218
+ | 5 | **Built-in defaults** | Always active, no config needed |
219
+
220
+ **Settings** (mode, approvers, timeouts) follow the table above — higher tier wins. A project config overrides a global config.
221
+
222
+ **Smart rules** work differently. All layers are concatenated into a single ordered list and evaluated first-match-wins:
223
+
224
+ ```
225
+ built-in defaults → global config → project config → shields → advisory defaults
226
+ ```
227
+
228
+ 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.
229
+
230
+ ---
231
+
232
+ ## ⚙️ Custom Rules (Advanced)
137
233
 
138
- Rules are **merged additive**—you cannot "un-danger" a word locally if it was defined as dangerous by a higher authority (like the Cloud).
234
+ 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.
235
+
236
+ Smart Rules match on **raw tool arguments** using structured conditions:
139
237
 
140
238
  ```json
141
239
  {
142
- "settings": {
143
- "mode": "standard",
144
- "enableUndo": true,
145
- "approvalTimeoutMs": 30000,
146
- "approvers": {
147
- "native": true,
148
- "browser": true,
149
- "cloud": true,
150
- "terminal": true
151
- }
152
- },
153
240
  "policy": {
154
- "sandboxPaths": ["/tmp/**", "**/test-results/**"],
155
- "dangerousWords": ["drop", "destroy", "purge", "push --force"],
156
- "ignoredTools": ["list_*", "get_*", "read_*"],
157
- "toolInspection": {
158
- "bash": "command",
159
- "postgres:query": "sql"
160
- },
161
- "rules": [
162
- { "action": "rm", "allowPaths": ["**/node_modules/**", "dist/**"] },
163
- { "action": "push", "blockPaths": ["**"] }
164
- ],
165
241
  "smartRules": [
166
242
  {
167
- "name": "no-delete-without-where",
168
- "tool": "*",
243
+ "name": "block-prod-deploy",
244
+ "tool": "bash",
169
245
  "conditions": [
170
- { "field": "sql", "op": "matches", "value": "^(DELETE|UPDATE)\\s", "flags": "i" },
171
- { "field": "sql", "op": "notMatches", "value": "\\bWHERE\\b", "flags": "i" }
246
+ { "field": "command", "op": "matches", "value": "kubectl.*--namespace=production" }
172
247
  ],
173
- "verdict": "review",
174
- "reason": "DELETE/UPDATE without WHERE would affect every row"
248
+ "verdict": "block",
249
+ "reason": "Deploying to production requires a manual release process"
175
250
  }
176
251
  ]
177
252
  }
178
253
  }
179
254
  ```
180
255
 
181
- ### ⚙️ `settings` options
182
-
183
- | Key | Default | Description |
184
- | :------------------- | :----------- | :----------------------------------------------------------- |
185
- | `mode` | `"standard"` | `standard` \| `strict` \| `audit` |
186
- | `enableUndo` | `true` | Take git snapshots before every AI file edit |
187
- | `approvalTimeoutMs` | `0` | Auto-deny after N ms if no human responds (0 = wait forever) |
188
- | `approvers.native` | `true` | OS-native popup |
189
- | `approvers.browser` | `true` | Browser dashboard (`node9 daemon`) |
190
- | `approvers.cloud` | `true` | Slack / SaaS approval |
191
- | `approvers.terminal` | `true` | `[Y/n]` prompt in terminal |
192
-
193
- ### 🧠 Smart Rules
194
-
195
- Smart rules match on **raw tool arguments** using structured conditions — more powerful than `dangerousWords` or `rules`, which only see extracted tokens.
196
-
197
- ```json
198
- {
199
- "name": "curl-pipe-to-shell",
200
- "tool": "bash",
201
- "conditions": [{ "field": "command", "op": "matches", "value": "curl.+\\|.*(bash|sh)" }],
202
- "verdict": "block",
203
- "reason": "curl piped to shell — remote code execution risk"
204
- }
205
- ```
206
-
207
- **Fields:**
256
+ **Smart Rule fields:**
208
257
 
209
258
  | Field | Description |
210
259
  | :-------------- | :----------------------------------------------------------------------------------- |
@@ -216,33 +265,50 @@ Smart rules match on **raw tool arguments** using structured conditions — more
216
265
 
217
266
  **Condition operators:**
218
267
 
219
- | `op` | Meaning |
220
- | :------------ | :------------------------------------------------------------------ |
221
- | `matches` | Field value matches regex (`value` = pattern, `flags` = e.g. `"i"`) |
222
- | `notMatches` | Field value does not match regex |
223
- | `contains` | Field value contains substring |
224
- | `notContains` | Field value does not contain substring |
225
- | `exists` | Field is present and non-empty |
226
- | `notExists` | Field is absent or empty |
268
+ | `op` | Meaning |
269
+ | :--------------- | :------------------------------------------------------------------------- |
270
+ | `matches` | Field value matches regex (`value` = pattern, `flags` = e.g. `"i"`) |
271
+ | `notMatches` | Field value does not match regex (`value` = pattern, `flags` optional) |
272
+ | `contains` | Field value contains substring |
273
+ | `notContains` | Field value does not contain substring |
274
+ | `exists` | Field is present and non-empty |
275
+ | `notExists` | Field is absent or empty |
276
+ | `matchesGlob` | Field value matches a glob pattern (`value` = e.g. `"**/node_modules/**"`) |
277
+ | `notMatchesGlob` | Field value does not match a glob pattern |
227
278
 
228
279
  The `field` key supports dot-notation for nested args: `"params.query.sql"`.
229
280
 
230
- **Built-in default smart rule** (always active, no config needed):
281
+ Use `node9 explain <tool> <args>` to dry-run any tool call and see exactly which rule would trigger.
282
+
283
+ ### Settings
231
284
 
232
285
  ```json
233
286
  {
234
- "name": "no-delete-without-where",
235
- "tool": "*",
236
- "conditions": [
237
- { "field": "sql", "op": "matches", "value": "^(DELETE|UPDATE)\\s", "flags": "i" },
238
- { "field": "sql", "op": "notMatches", "value": "\\bWHERE\\b", "flags": "i" }
239
- ],
240
- "verdict": "review",
241
- "reason": "DELETE/UPDATE without WHERE clause — would affect every row in the table"
287
+ "settings": {
288
+ "mode": "standard",
289
+ "enableUndo": true,
290
+ "approvalTimeoutMs": 30000,
291
+ "approvers": {
292
+ "native": true,
293
+ "browser": true,
294
+ "cloud": true,
295
+ "terminal": true
296
+ }
297
+ }
242
298
  }
243
299
  ```
244
300
 
245
- Use `node9 explain <tool> <args>` to dry-run any tool call and see exactly which smart rule (or other policy tier) would trigger.
301
+ | Key | Default | Description |
302
+ | :------------------- | :----------- | :----------------------------------------------------------- |
303
+ | `mode` | `"standard"` | `standard` \| `strict` \| `audit` |
304
+ | `enableUndo` | `true` | Take git snapshots before every AI file edit |
305
+ | `approvalTimeoutMs` | `0` | Auto-deny after N ms if no human responds (0 = wait forever) |
306
+ | `approvers.native` | `true` | OS-native popup |
307
+ | `approvers.browser` | `true` | Browser dashboard (`node9 daemon`) |
308
+ | `approvers.cloud` | `true` | Slack / SaaS approval |
309
+ | `approvers.terminal` | `true` | `[Y/n]` prompt in terminal |
310
+
311
+ ---
246
312
 
247
313
  ## 🖥️ CLI Reference
248
314
 
@@ -253,14 +319,14 @@ Use `node9 explain <tool> <args>` to dry-run any tool call and see exactly which
253
319
  | `node9 init` | Create default `~/.node9/config.json` |
254
320
  | `node9 status` | Show current protection status and active rules |
255
321
  | `node9 doctor` | Health check — verifies binaries, config, credentials, and all agent hooks |
322
+ | `node9 shield <cmd>` | Manage shields (`enable`, `disable`, `list`, `status`) |
323
+ | `node9 tail [--history]` | Stream live agent activity to the terminal (auto-starts daemon if needed) |
256
324
  | `node9 explain <tool> [args]` | Trace the policy waterfall for a given tool call (dry-run, no approval prompt) |
257
325
  | `node9 undo [--steps N]` | Revert the last N AI file edits using shadow Git snapshots |
258
326
  | `node9 check` | Called by agent hooks; evaluates a pending tool call and exits 0 (allow) or 1 (block) |
259
327
 
260
328
  ### `node9 doctor`
261
329
 
262
- Runs a full self-test and exits 1 if any required check fails:
263
-
264
330
  ```
265
331
  Node9 Doctor v1.2.0
266
332
  ────────────────────────────────────────
@@ -283,7 +349,7 @@ All checks passed ✅
283
349
 
284
350
  ### `node9 explain`
285
351
 
286
- Dry-runs the policy engine and prints exactly which rule (or waterfall tier) would block or allow a given tool call — useful for debugging your config:
352
+ Dry-runs the policy engine and prints exactly which rule would fire — useful for debugging:
287
353
 
288
354
  ```bash
289
355
  node9 explain bash '{"command":"rm -rf /tmp/build"}'
@@ -294,9 +360,6 @@ Policy Waterfall for: bash
294
360
  ──────────────────────────────────────────────
295
361
  Tier 1 · Cloud Org Policy SKIP (no org policy loaded)
296
362
  Tier 2 · Dangerous Words BLOCK ← matched "rm -rf"
297
- Tier 3 · Path Block –
298
- Tier 4 · Inline Exec –
299
- Tier 5 · Rule Match –
300
363
  ──────────────────────────────────────────────
301
364
  Verdict: BLOCK (dangerous word: rm -rf)
302
365
  ```
@@ -324,6 +387,12 @@ A corporate policy has locked this action. You must click the "Approve" button i
324
387
  - [x] **Native OS Dialogs** (Sub-second approval via Mac/Win/Linux system windows)
325
388
  - [x] **Shadow Git Snapshots** (1-click Undo for AI hallucinations)
326
389
  - [x] **Identity-Aware Execution** (Differentiates between Human vs. AI risk levels)
390
+ - [x] **Shield Templates** (`node9 shield enable <service>` — one-click protection for Postgres, GitHub, AWS)
391
+ - [x] **Content Scanner / DLP** (Detect and block secrets like AWS keys and Bearer tokens in-flight)
392
+ - [x] **Flight Recorder** (Real-time activity stream in browser dashboard and `node9 tail` terminal view)
393
+ - [ ] **Universal MCP Gateway** (Standalone security tunnel for LangChain, CrewAI, and any agent without native hooks)
394
+ - [ ] **Cursor & Windsurf Hook** (Native hook support for AI-first IDEs)
395
+ - [ ] **VS Code Extension** (Approval requests in a native sidebar — no more OS popups)
327
396
  - [ ] **Execution Sandboxing** (Simulate dangerous commands in a virtual FS before applying)
328
397
  - [ ] **Multi-Admin Quorum** (Require 2+ human signatures for high-stakes production actions)
329
398
  - [ ] **SOC2 Tamper-proof Audit Trail** (Cryptographically signed, cloud-managed logs)