@agent-wall/cli 0.1.0
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/.turbo/turbo-build.log +18 -0
- package/.turbo/turbo-test.log +19 -0
- package/LICENSE +21 -0
- package/README.md +79 -0
- package/dist/dashboard/assets/index-BOAuOkd7.css +1 -0
- package/dist/dashboard/assets/index-_Zwjwdf_.js +50 -0
- package/dist/dashboard/assets/index-_Zwjwdf_.js.map +1 -0
- package/dist/dashboard/favicon.svg +5 -0
- package/dist/dashboard/index.html +14 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1074 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
- package/src/commands/audit.test.ts +175 -0
- package/src/commands/audit.ts +158 -0
- package/src/commands/doctor.test.ts +108 -0
- package/src/commands/doctor.ts +146 -0
- package/src/commands/init.test.ts +85 -0
- package/src/commands/init.ts +52 -0
- package/src/commands/scan.test.ts +279 -0
- package/src/commands/scan.ts +338 -0
- package/src/commands/test.test.ts +152 -0
- package/src/commands/test.ts +108 -0
- package/src/commands/validate.test.ts +104 -0
- package/src/commands/validate.ts +181 -0
- package/src/commands/wrap.ts +420 -0
- package/src/index.ts +151 -0
- package/tsconfig.json +8 -0
- package/tsup.config.ts +12 -0
- package/vitest.config.ts +8 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Wall CLI
|
|
3
|
+
*
|
|
4
|
+
* Security firewall for AI agents.
|
|
5
|
+
* Intercepts MCP tool calls, enforces policies, blocks attacks.
|
|
6
|
+
*
|
|
7
|
+
* Commands:
|
|
8
|
+
* wrap — Wrap an MCP server with Agent Wall protection
|
|
9
|
+
* init — Generate a starter agent-wall.yaml config
|
|
10
|
+
* test — Dry-run a tool call against your policy rules
|
|
11
|
+
* audit — Display and analyze audit logs
|
|
12
|
+
* scan — Scan your MCP config for security risks
|
|
13
|
+
* validate — Validate your policy configuration file
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { Command } from "commander";
|
|
17
|
+
import { wrapCommand } from "./commands/wrap.js";
|
|
18
|
+
import { initCommand } from "./commands/init.js";
|
|
19
|
+
import { testCommand } from "./commands/test.js";
|
|
20
|
+
import { auditCommand } from "./commands/audit.js";
|
|
21
|
+
import { scanCommand } from "./commands/scan.js";
|
|
22
|
+
import { validateCommand } from "./commands/validate.js";
|
|
23
|
+
import { doctorCommand } from "./commands/doctor.js";
|
|
24
|
+
|
|
25
|
+
/** Resolve env-var fallback for config path. */
|
|
26
|
+
function envConfig(explicit?: string): string | undefined {
|
|
27
|
+
return explicit ?? process.env.AGENT_WALL_CONFIG ?? undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Resolve env-var fallback for log file path. */
|
|
31
|
+
function envLogFile(explicit?: string): string | undefined {
|
|
32
|
+
return explicit ?? process.env.AGENT_WALL_LOG ?? undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const program = new Command();
|
|
36
|
+
|
|
37
|
+
program
|
|
38
|
+
.name("agent-wall")
|
|
39
|
+
.description(
|
|
40
|
+
"Security firewall for AI agents — intercept MCP tool calls, enforce policies, block attacks."
|
|
41
|
+
)
|
|
42
|
+
.version("0.1.0");
|
|
43
|
+
|
|
44
|
+
// ── wrap ─────────────────────────────────────────────────────────────
|
|
45
|
+
|
|
46
|
+
program
|
|
47
|
+
.command("wrap")
|
|
48
|
+
.description("Wrap an MCP server with Agent Wall policy enforcement")
|
|
49
|
+
.option("-c, --config <path>", "Path to agent-wall.yaml config file")
|
|
50
|
+
.option("-l, --log-file <path>", "Path to write audit log (JSON lines)")
|
|
51
|
+
.option("-s, --silent", "Suppress Agent Wall output (only MCP protocol on stdout)")
|
|
52
|
+
.option("--dry-run", "Preview policy evaluation without starting the server")
|
|
53
|
+
.option("-d, --dashboard", "Launch real-time security dashboard")
|
|
54
|
+
.option("--dashboard-port <port>", "Dashboard port (default: 61100)", parseInt)
|
|
55
|
+
.argument("[serverArgs...]", "Server command and arguments (after --)")
|
|
56
|
+
.allowUnknownOption(true)
|
|
57
|
+
.action((serverArgs: string[], opts) => {
|
|
58
|
+
wrapCommand(serverArgs, {
|
|
59
|
+
config: envConfig(opts.config),
|
|
60
|
+
logFile: envLogFile(opts.logFile),
|
|
61
|
+
silent: opts.silent,
|
|
62
|
+
dryRun: opts.dryRun,
|
|
63
|
+
dashboard: opts.dashboard,
|
|
64
|
+
dashboardPort: opts.dashboardPort,
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// ── init ─────────────────────────────────────────────────────────────
|
|
69
|
+
|
|
70
|
+
program
|
|
71
|
+
.command("init")
|
|
72
|
+
.description("Generate a starter agent-wall.yaml configuration file")
|
|
73
|
+
.option("-p, --path <path>", "Output path (default: ./agent-wall.yaml)")
|
|
74
|
+
.option("-f, --force", "Overwrite existing file")
|
|
75
|
+
.action((opts) => {
|
|
76
|
+
initCommand({ path: opts.path, force: opts.force });
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// ── test ─────────────────────────────────────────────────────────────
|
|
80
|
+
|
|
81
|
+
program
|
|
82
|
+
.command("test")
|
|
83
|
+
.description("Dry-run a tool call against your policy rules")
|
|
84
|
+
.option("-c, --config <path>", "Path to agent-wall.yaml config file")
|
|
85
|
+
.requiredOption("-t, --tool <name>", "Tool name to test")
|
|
86
|
+
.option(
|
|
87
|
+
"-a, --arg <key=value>",
|
|
88
|
+
"Tool argument (repeatable)",
|
|
89
|
+
(val: string, prev: string[]) => [...prev, val],
|
|
90
|
+
[] as string[]
|
|
91
|
+
)
|
|
92
|
+
.action((opts) => {
|
|
93
|
+
testCommand({ config: envConfig(opts.config), tool: opts.tool, arg: opts.arg });
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// ── audit ────────────────────────────────────────────────────────────
|
|
97
|
+
|
|
98
|
+
program
|
|
99
|
+
.command("audit")
|
|
100
|
+
.description("Display and analyze audit logs")
|
|
101
|
+
.requiredOption("-l, --log <path>", "Path to the audit log file")
|
|
102
|
+
.option(
|
|
103
|
+
"-f, --filter <action>",
|
|
104
|
+
"Filter by action: allowed, denied, prompted, all",
|
|
105
|
+
"all"
|
|
106
|
+
)
|
|
107
|
+
.option("-n, --last <count>", "Show only the last N entries", parseInt)
|
|
108
|
+
.option("--json", "Output raw JSON")
|
|
109
|
+
.action((opts) => {
|
|
110
|
+
auditCommand({
|
|
111
|
+
log: opts.log,
|
|
112
|
+
filter: opts.filter,
|
|
113
|
+
last: opts.last,
|
|
114
|
+
json: opts.json,
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// ── scan ─────────────────────────────────────────────────────────────
|
|
119
|
+
|
|
120
|
+
program
|
|
121
|
+
.command("scan")
|
|
122
|
+
.description("Scan your MCP configuration for security risks")
|
|
123
|
+
.option("-c, --config <path>", "Path to MCP config file")
|
|
124
|
+
.option("--json", "Output results as JSON")
|
|
125
|
+
.action((opts) => {
|
|
126
|
+
scanCommand({ config: opts.config, json: opts.json });
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// ── validate ─────────────────────────────────────────────────────────
|
|
130
|
+
|
|
131
|
+
program
|
|
132
|
+
.command("validate")
|
|
133
|
+
.description("Validate your policy configuration file")
|
|
134
|
+
.option("-c, --config <path>", "Path to agent-wall.yaml config file")
|
|
135
|
+
.action((opts) => {
|
|
136
|
+
validateCommand({ config: envConfig(opts.config) });
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// ── doctor ───────────────────────────────────────────────────────────
|
|
140
|
+
|
|
141
|
+
program
|
|
142
|
+
.command("doctor")
|
|
143
|
+
.description("Health check — verify config, environment, and MCP setup")
|
|
144
|
+
.option("-c, --config <path>", "Path to agent-wall.yaml config file")
|
|
145
|
+
.action((opts) => {
|
|
146
|
+
doctorCommand({ config: envConfig(opts.config) });
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// ── Parse ────────────────────────────────────────────────────────────
|
|
150
|
+
|
|
151
|
+
program.parse();
|
package/tsconfig.json
ADDED
package/tsup.config.ts
ADDED