agent-permission 0.1.1 → 0.1.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 +28 -6
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +15 -2
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +23 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,21 +1,43 @@
|
|
|
1
1
|
# Agent Permission CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Give AI agents a permission gate before they touch external URLs.
|
|
4
4
|
|
|
5
5
|
## Quickstart
|
|
6
6
|
|
|
7
|
+
```bash
|
|
8
|
+
npx agent-permission install --adapter auto
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This adds an Agent Permission block to the local agent instruction file, such as `AGENTS.md`, `CLAUDE.md`, or `agent-permission.chatgpt.md`, depending on the selected adapter.
|
|
12
|
+
|
|
13
|
+
To install instructions and configure live checks in one step:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx agent-permission install --adapter auto --api-key <YOUR_API_KEY>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Add an API key when you want live checks from the command line, CI, or agent runs:
|
|
20
|
+
|
|
7
21
|
```bash
|
|
8
22
|
npx agent-permission config set api-key <YOUR_API_KEY>
|
|
9
|
-
npx agent-permission check https://example.com/blog-post --action summarize --exit-code
|
|
23
|
+
npx -y agent-permission@latest check https://example.com/blog-post --action summarize --exit-code
|
|
10
24
|
```
|
|
11
25
|
|
|
12
|
-
##
|
|
26
|
+
## What the Agent Runs
|
|
27
|
+
|
|
28
|
+
After install, project instructions tell compatible agents to run:
|
|
13
29
|
|
|
14
30
|
```bash
|
|
15
|
-
npx agent-permission
|
|
31
|
+
npx -y agent-permission@latest check <url> --action <crawl|summarize|extract|train|transact|post> --exit-code
|
|
16
32
|
```
|
|
17
33
|
|
|
18
|
-
|
|
34
|
+
The first run may need npm registry network access; later runs can use the local npm cache.
|
|
35
|
+
|
|
36
|
+
If the binary is already available in the agent shell, the same check can also run as:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
agent-permission check <url> --action <crawl|summarize|extract|train|transact|post> --exit-code
|
|
40
|
+
```
|
|
19
41
|
|
|
20
42
|
## Commands
|
|
21
43
|
|
|
@@ -23,7 +45,7 @@ This adds an Agent Permission block to the local agent instruction file, such as
|
|
|
23
45
|
agent-permission check <url> --action <crawl|summarize|extract|train|transact|post>
|
|
24
46
|
agent-permission batch --file checks.json
|
|
25
47
|
agent-permission verify-receipt --file receipt.json
|
|
26
|
-
agent-permission install --adapter auto|codex|claude|chatgpt|openclaw
|
|
48
|
+
agent-permission install --adapter auto|codex|claude|chatgpt|openclaw [--api-key <key>]
|
|
27
49
|
agent-permission config set api-key <key>
|
|
28
50
|
agent-permission config doctor
|
|
29
51
|
```
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAKA,OAAO,EAAyD,KAAK,EAAuD,OAAO,EAAE,MAAM,YAAY,CAAC;AAExJ,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IACxC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CA6BzF;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAKA,OAAO,EAAyD,KAAK,EAAuD,OAAO,EAAE,MAAM,YAAY,CAAC;AAExJ,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IACxC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CA6BzF;AAgID,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW,CA2BtD"}
|
package/dist/cli.js
CHANGED
|
@@ -100,7 +100,20 @@ async function runInstall(args, runtime, io) {
|
|
|
100
100
|
const adapter = parseAdapter(stringFlag(parsed, 'adapter') || parsed.positionals[0] || 'auto');
|
|
101
101
|
const scope = parseScope(stringFlag(parsed, 'scope') || 'project');
|
|
102
102
|
const result = await installAgentInstructions(adapter, scope, runtime);
|
|
103
|
-
|
|
103
|
+
const messages = [`Installed Agent Permission instructions for ${result.adapter} at ${result.path}`];
|
|
104
|
+
const apiKey = stringFlag(parsed, 'api-key');
|
|
105
|
+
if (apiKey) {
|
|
106
|
+
const current = await readConfig(runtime);
|
|
107
|
+
const path = await writeConfig(runtime, { ...current, apiKey });
|
|
108
|
+
messages.push(`Saved API key to ${path}`);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const config = await resolveConfig(runtime);
|
|
112
|
+
if (!config.apiKey) {
|
|
113
|
+
messages.push('API key is not configured. Live checks will fail until you run `npx agent-permission config set api-key <YOUR_API_KEY>` or set AGENT_PERMISSION_API_KEY.', 'Verify setup with `npx -y agent-permission@latest config doctor`.');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
io.stdout(messages.join('\n'));
|
|
104
117
|
return 0;
|
|
105
118
|
}
|
|
106
119
|
async function runConfig(args, runtime, io) {
|
|
@@ -192,7 +205,7 @@ Usage:
|
|
|
192
205
|
agent-permission check <url> --action <action> [--json] [--exit-code]
|
|
193
206
|
agent-permission batch --file checks.json [--json]
|
|
194
207
|
agent-permission verify-receipt --file receipt.json
|
|
195
|
-
agent-permission install --adapter auto|codex|claude|chatgpt|openclaw [--scope project|user]
|
|
208
|
+
agent-permission install --adapter auto|codex|claude|chatgpt|openclaw [--scope project|user] [--api-key <key>]
|
|
196
209
|
agent-permission config set api-key <key>
|
|
197
210
|
agent-permission config doctor
|
|
198
211
|
|
package/dist/install.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAK5D,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAa9H;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAU9D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAK5D,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAa9H;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAU9D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,UA2BtE"}
|
package/dist/install.js
CHANGED
|
@@ -37,6 +37,12 @@ These instructions equip ${agentName} with Agent Permission preflight checks.
|
|
|
37
37
|
|
|
38
38
|
Before crawling, summarizing, extracting, training on, transacting with, or posting to a URL, run:
|
|
39
39
|
|
|
40
|
+
\`\`\`bash
|
|
41
|
+
npx -y agent-permission@latest check <url> --action <crawl|summarize|extract|train|transact|post> --exit-code
|
|
42
|
+
\`\`\`
|
|
43
|
+
|
|
44
|
+
If the \`agent-permission\` binary is available in the agent shell, the same check can also run as:
|
|
45
|
+
|
|
40
46
|
\`\`\`bash
|
|
41
47
|
agent-permission check <url> --action <crawl|summarize|extract|train|transact|post> --exit-code
|
|
42
48
|
\`\`\`
|
|
@@ -47,11 +53,15 @@ Treat \`allow\` as permitted, \`deny\` as blocked, and \`escalate\` as requiring
|
|
|
47
53
|
}
|
|
48
54
|
async function detectAdapter(runtime) {
|
|
49
55
|
const claudePath = join(runtime.cwd, 'CLAUDE.md');
|
|
56
|
+
const chatgptPath = join(runtime.cwd, 'agent-permission.chatgpt.md');
|
|
50
57
|
const agentsPath = join(runtime.cwd, 'AGENTS.md');
|
|
51
58
|
if (await fileExists(claudePath))
|
|
52
59
|
return 'claude';
|
|
53
|
-
if (await fileExists(
|
|
54
|
-
return '
|
|
60
|
+
if (await fileExists(chatgptPath))
|
|
61
|
+
return 'chatgpt';
|
|
62
|
+
const agents = await readFileIfExists(agentsPath);
|
|
63
|
+
if (agents !== undefined)
|
|
64
|
+
return isOpenClawInstructions(agents) ? 'openclaw' : 'codex';
|
|
55
65
|
return 'codex';
|
|
56
66
|
}
|
|
57
67
|
function getInstructionPath(adapter, scope, runtime) {
|
|
@@ -69,14 +79,21 @@ function getInstructionPath(adapter, scope, runtime) {
|
|
|
69
79
|
return join(runtime.cwd, 'AGENTS.md');
|
|
70
80
|
}
|
|
71
81
|
async function fileExists(path) {
|
|
82
|
+
return (await readFileIfExists(path)) !== undefined;
|
|
83
|
+
}
|
|
84
|
+
async function readFileIfExists(path) {
|
|
72
85
|
try {
|
|
73
|
-
await readFile(path, 'utf8');
|
|
74
|
-
return true;
|
|
86
|
+
return await readFile(path, 'utf8');
|
|
75
87
|
}
|
|
76
|
-
catch {
|
|
77
|
-
|
|
88
|
+
catch (err) {
|
|
89
|
+
if (err && typeof err === 'object' && 'code' in err && err.code === 'ENOENT')
|
|
90
|
+
return undefined;
|
|
91
|
+
throw err;
|
|
78
92
|
}
|
|
79
93
|
}
|
|
94
|
+
function isOpenClawInstructions(content) {
|
|
95
|
+
return /\bOpenClaw\b/i.test(content);
|
|
96
|
+
}
|
|
80
97
|
function escapeRegExp(value) {
|
|
81
98
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
82
99
|
}
|