Skip to content

Commit eb4e63d

Browse files
nadavisclaude
andcommitted
docs: update demo.ts with correct import and usage explanation
- Use @node9/proxy import instead of relative src path - Add comment explaining CLI proxy vs SDK protect() use cases - Clarify error message: "blocked" instead of "caught" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3f5f5b1 commit eb4e63d

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

examples/demo.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,40 @@
1-
import { protect } from '../src/index';
1+
/**
2+
* Node9 SDK — protect() example
3+
*
4+
* There are two ways Node9 protects you:
5+
*
6+
* 1. CLI Proxy (automatic) — Node9 wraps Claude Code / Gemini CLI at the
7+
* process level and intercepts every tool call automatically. No code needed.
8+
*
9+
* 2. SDK / protect() (manual) — for developers building their own Node.js apps
10+
* with an AI SDK (Anthropic, LangChain, etc.). Wrap any dangerous function
11+
* with `protect()` and Node9 will intercept it before execution, showing a
12+
* native approval popup and applying your security policy.
13+
*
14+
* Usage:
15+
* npm install @node9/proxy
16+
* npx ts-node examples/demo.ts
17+
*/
18+
import { protect } from '@node9/proxy';
219
import chalk from 'chalk';
320

421
async function main() {
522
const deleteDatabase = async (name: string) => {
623
console.log(chalk.green(`✅ Success: Database ${name} has been deleted.`));
724
};
825

9-
// Wrap the dangerous function
26+
// Wrap the dangerous function — Node9 will intercept it before it runs
1027
const secureDelete = protect('aws.rds.delete_database', deleteDatabase);
1128

1229
console.log(chalk.cyan("🤖 AI Agent: 'I am going to clean up the production DB...'"));
1330

1431
try {
32+
// Node9 will show a native popup asking you to Allow / Block this action.
33+
// If you click Block (or the policy denies it), an error is thrown.
1534
await secureDelete('production-db-v1');
1635
} catch (err: unknown) {
1736
const msg = err instanceof Error ? err.message : String(err);
18-
console.log(chalk.yellow(`\n🛡️ Node9 caught it: ${msg}`));
37+
console.log(chalk.yellow(`\n🛡️ Node9 blocked it: ${msg}`));
1938
}
2039
}
2140

0 commit comments

Comments
 (0)