agent-permission 0.1.0 → 0.1.2

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 ADDED
@@ -0,0 +1,66 @@
1
+ # Agent Permission CLI
2
+
3
+ Give AI agents a permission gate before they touch external URLs.
4
+
5
+ ## Quickstart
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
+
21
+ ```bash
22
+ npx agent-permission config set api-key <YOUR_API_KEY>
23
+ npx agent-permission check https://example.com/blog-post --action summarize --exit-code
24
+ ```
25
+
26
+ ## What the Agent Runs
27
+
28
+ After install, project instructions tell compatible agents to run:
29
+
30
+ ```bash
31
+ agent-permission check <url> --action <crawl|summarize|extract|train|transact|post> --exit-code
32
+ ```
33
+
34
+ If the binary is unavailable in the agent shell, the installed instructions tell the agent to use:
35
+
36
+ ```bash
37
+ npx -y agent-permission@latest check <url> --action <crawl|summarize|extract|train|transact|post> --exit-code
38
+ ```
39
+
40
+ ## Commands
41
+
42
+ ```bash
43
+ agent-permission check <url> --action <crawl|summarize|extract|train|transact|post>
44
+ agent-permission batch --file checks.json
45
+ agent-permission verify-receipt --file receipt.json
46
+ agent-permission install --adapter auto|codex|claude|chatgpt|openclaw [--api-key <key>]
47
+ agent-permission config set api-key <key>
48
+ agent-permission config doctor
49
+ ```
50
+
51
+ Use `--json` for machine-readable output and `--exit-code` to map decisions to process status:
52
+
53
+ - `0`: allow
54
+ - `2`: escalate
55
+ - `3`: deny
56
+ - `1`: CLI or API error
57
+
58
+ ## Environment
59
+
60
+ ```bash
61
+ AGENT_PERMISSION_API_KEY=<key>
62
+ AGENT_PERMISSION_API_URL=<url>
63
+ AGENT_PERMISSION_DEFAULT_MODE=strict
64
+ ```
65
+
66
+ Agent Permission evaluates URL access signals from `robots.txt`, `llms.txt`, and OpenTerms, then returns a signed receipt for auditability.
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;AA+GD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW,CA2BtD"}
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
- io.stdout(`Installed Agent Permission instructions for ${result.adapter} at ${result.path}`);
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 agent-permission 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/index.js CHANGED
File without changes
@@ -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,UAqBtE"}
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
@@ -41,17 +41,27 @@ Before crawling, summarizing, extracting, training on, transacting with, or post
41
41
  agent-permission check <url> --action <crawl|summarize|extract|train|transact|post> --exit-code
42
42
  \`\`\`
43
43
 
44
+ If the \`agent-permission\` binary is not available in the agent shell, run the same check through npm:
45
+
46
+ \`\`\`bash
47
+ npx -y agent-permission@latest check <url> --action <crawl|summarize|extract|train|transact|post> --exit-code
48
+ \`\`\`
49
+
44
50
  Use \`crawl\` for fetching or indexing pages, \`summarize\` for compacting page content, \`extract\` for structured data pulls, \`train\` for model training or dataset creation, \`transact\` for purchase/account-changing actions, and \`post\` for creating or modifying remote content.
45
51
 
46
52
  Treat \`allow\` as permitted, \`deny\` as blocked, and \`escalate\` as requiring human approval before continuing. Preserve the returned receipt ID in task notes when a permission decision affects user-visible work.`;
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(agentsPath))
54
- return 'codex';
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
- return false;
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
  }
package/package.json CHANGED
@@ -1,17 +1,24 @@
1
1
  {
2
2
  "name": "agent-permission",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Public CLI for Agent Permission checks and agent workspace installation.",
5
5
  "type": "module",
6
- "bin": {
7
- "agent-permission": "dist/index.js",
8
- "skills": "dist/index.js"
9
- },
6
+ "bin": "./dist/index.js",
10
7
  "files": [
11
8
  "dist"
12
9
  ],
10
+ "keywords": [
11
+ "ai",
12
+ "agents",
13
+ "permissions",
14
+ "robots.txt",
15
+ "llms.txt",
16
+ "openterms",
17
+ "cli"
18
+ ],
19
+ "license": "MIT",
13
20
  "scripts": {
14
- "build": "tsc -p tsconfig.json",
21
+ "build": "tsc -p tsconfig.json && node -e \"require('fs').chmodSync('dist/index.js', 0o755)\"",
15
22
  "prepack": "npm run build"
16
23
  },
17
24
  "engines": {