@nnsk/tap 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/bin/setup.mjs ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { cpSync, mkdirSync, existsSync, readdirSync, readFileSync, writeFileSync } from "fs";
4
+ import { resolve, dirname, join, basename } from "path";
5
+ import { fileURLToPath } from "url";
6
+ import { homedir } from "os";
7
+
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+ const commandsSource = resolve(__dirname, "..", "commands");
10
+ const cwd = process.cwd();
11
+
12
+ const files = readdirSync(commandsSource).filter((f) => f.endsWith(".md"));
13
+
14
+ if (files.length === 0) {
15
+ console.error("Error: no command files found in package.");
16
+ process.exit(1);
17
+ }
18
+
19
+ // 1. Claude Code / NanoClaw / Cursor / Gemini CLI — .claude/commands/*.md
20
+ const claudeTarget = resolve(cwd, ".claude", "commands");
21
+ mkdirSync(claudeTarget, { recursive: true });
22
+ for (const f of files) {
23
+ cpSync(join(commandsSource, f), join(claudeTarget, f));
24
+ }
25
+ console.log(` ✓ .claude/commands/ (Claude Code, NanoClaw, Cursor, Gemini CLI)`);
26
+
27
+ // Strip $ARGUMENTS (Claude Code-specific) for AgentSkills format
28
+ function copyAsSkill(src, destDir) {
29
+ mkdirSync(destDir, { recursive: true });
30
+ let content = readFileSync(src, "utf8");
31
+ content = content.replace(/^\$ARGUMENTS\s*$/m, "").trimEnd() + "\n";
32
+ writeFileSync(join(destDir, "SKILL.md"), content);
33
+ }
34
+
35
+ // 2. OpenClaw / Hermes — ~/.agents/skills/*/SKILL.md (shared convention)
36
+ const agentsTarget = resolve(homedir(), ".agents", "skills");
37
+ for (const f of files) {
38
+ copyAsSkill(join(commandsSource, f), join(agentsTarget, basename(f, ".md")));
39
+ }
40
+ console.log(` ✓ ~/.agents/skills/ (OpenClaw, Hermes)`);
41
+
42
+ // 3. If SOUL.md exists (OpenClaw project), also install to project skills/ dir
43
+ if (existsSync(resolve(cwd, "SOUL.md")) || existsSync(resolve(cwd, "soul.md"))) {
44
+ const projSkills = resolve(cwd, "skills");
45
+ for (const f of files) {
46
+ copyAsSkill(join(commandsSource, f), join(projSkills, basename(f, ".md")));
47
+ }
48
+ console.log(` ✓ skills/ (OpenClaw project skills)`);
49
+ }
50
+
51
+ console.log(
52
+ `\nDone! Tell your agent: /setup-tap\n` +
53
+ `It will ask for your agent API key and proxy URL.\n`
54
+ );
@@ -0,0 +1,28 @@
1
+ ---
2
+ description: Walk through Google OAuth setup to get a refresh token for TAP
3
+ ---
4
+
5
+ Help the user get a Google OAuth refresh token and add it as a credential in the TAP dashboard. TAP already has a shared OAuth client — the user only needs a refresh token.
6
+
7
+ Follow these steps exactly:
8
+
9
+ 1. Tell the user to open the Google OAuth Playground:
10
+ https://developers.google.com/oauthplayground/
11
+
12
+ 2. Tell them to click the **gear icon** (top right) and check **"Use your own OAuth credentials"**, then enter the Client ID and Client Secret shown in the TAP dashboard (visible when adding a Google credential).
13
+
14
+ 3. Ask what Google APIs they need. Help them select the right scopes in the left panel:
15
+ - Gmail: `https://mail.google.com/`
16
+ - Calendar: `https://www.googleapis.com/auth/calendar`
17
+ - Drive: `https://www.googleapis.com/auth/drive`
18
+ - Sheets: `https://www.googleapis.com/auth/spreadsheets`
19
+
20
+ 4. Tell them to click **"Authorize APIs"**, sign in with their Google account, and grant access.
21
+
22
+ 5. Tell them to click **"Exchange authorization code for tokens"** and copy the **Refresh Token** from the response.
23
+
24
+ 6. Tell them to go to the TAP dashboard → Credentials → **+ Add Credential** → select **Google Workspace** → paste the refresh token → click **Create**.
25
+
26
+ That's it. TAP handles token refresh automatically using the shared OAuth client.
27
+
28
+ $ARGUMENTS
@@ -0,0 +1,62 @@
1
+ ---
2
+ description: Configure TAP credential proxy — gives this agent secure access to any API without exposing credentials
3
+ ---
4
+
5
+ Set up TAP (Tool Authorization Protocol) so this agent can make authenticated API calls without ever seeing credential values. A proxy injects credentials after policy checks.
6
+
7
+ Do the following steps in order:
8
+
9
+ 1. Ask the user for two values:
10
+ - **Proxy URL** — suggest the default `https://agentsec.app-dfe7954892b5.enclave.evervault.com`
11
+ - **Agent API key** — from the TAP dashboard (Agents page)
12
+
13
+ 2. Write both to `.env` (create if missing, append if exists — do not duplicate keys):
14
+ ```
15
+ TAP_PROXY_URL=<url>
16
+ TAP_AGENT_KEY=<key>
17
+ ```
18
+
19
+ 3. Make sure `.env` is in `.gitignore`. Add it if not.
20
+
21
+ 4. Find the project instruction file — check for `SOUL.md` first, then `CLAUDE.md`. If neither exists, create `CLAUDE.md`. Append this section (if a `## TAP Credential Proxy` section already exists, replace it):
22
+
23
+ ```
24
+ ## TAP Credential Proxy
25
+
26
+ All authenticated API requests MUST go through the TAP proxy. Never store, log, or hardcode credentials. Do not search for alternative ways to authenticate — always use the proxy.
27
+
28
+ **Making a request:**
29
+ ```bash
30
+ curl -X POST "$TAP_PROXY_URL/forward" \
31
+ -H "X-TAP-Key: $TAP_AGENT_KEY" \
32
+ -H "X-TAP-Credential: <service-name>" \
33
+ -H "X-TAP-Target: <real-api-url>" \
34
+ -H "X-TAP-Method: GET" \
35
+ -H "Content-Type: application/json" \
36
+ -d '{ ... }'
37
+ ```
38
+
39
+ - `X-TAP-Credential` — the service name from the dashboard (e.g. `openai`, `github`, `slack`)
40
+ - `X-TAP-Target` — the actual upstream URL
41
+ - `X-TAP-Method` — HTTP method (GET, POST, PUT, DELETE). GET is auto-approved by default; writes need human approval
42
+ - The proxy injects the real credential and scrubs secrets from the response
43
+
44
+ **Listing available services:**
45
+ ```bash
46
+ curl "$TAP_PROXY_URL/agent/services" -H "X-TAP-Key: $TAP_AGENT_KEY"
47
+ ```
48
+ ```
49
+
50
+ 5. Test the connection:
51
+ ```bash
52
+ source .env && curl -sf "$TAP_PROXY_URL/health"
53
+ ```
54
+ If it returns OK, print "Proxy is reachable." If it fails, warn the user.
55
+
56
+ 6. List available services:
57
+ ```bash
58
+ source .env && curl -s "$TAP_PROXY_URL/agent/services" -H "X-TAP-Key: $TAP_AGENT_KEY"
59
+ ```
60
+ Show the user which credentials are available. If none, tell them to add credentials in the dashboard first.
61
+
62
+ $ARGUMENTS
@@ -0,0 +1,29 @@
1
+ ---
2
+ description: Walk through Telegram credential setup for TAP
3
+ ---
4
+
5
+ Help the user set up a Telegram personal account credential so their agent can interact with Telegram through TAP. This is for the agent to act as the user on Telegram — the approval bot is already running on the platform.
6
+
7
+ Follow these steps exactly:
8
+
9
+ 1. Tell the user to go to https://my.telegram.org/apps and log in with their phone number.
10
+
11
+ 2. Tell them to create a new application (or use an existing one) and note the **API ID** (a number) and **API Hash** (a hex string).
12
+
13
+ 3. Tell them to run this command in their terminal to generate a session string (requires Python 3.8+):
14
+
15
+ ```bash
16
+ pip install telethon -q && python3 -c "
17
+ from telethon.sync import TelegramClient; from telethon.sessions import StringSession
18
+ c = TelegramClient(StringSession(), int(input('API ID: ')), input('API Hash: '))
19
+ c.start(); print('\nSession string:\n' + c.session.save())
20
+ "
21
+ ```
22
+
23
+ It will prompt for their API ID, API Hash, phone number, and a verification code from Telegram. They should copy the session string it prints at the end.
24
+
25
+ 4. Warn them: **keep this session string safe** — anyone with it can access their Telegram account.
26
+
27
+ 5. Tell them to go to the TAP dashboard → Credentials → **+ Add Credential** → select **Telegram** → enter the API ID, API Hash, and Session String → click **Create**.
28
+
29
+ $ARGUMENTS
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@nnsk/tap",
3
+ "version": "0.1.0",
4
+ "description": "Set up Tool Authorization Protocol (TAP) for your AI agent in one command",
5
+ "bin": {
6
+ "toolauthz": "./bin/setup.mjs"
7
+ },
8
+ "scripts": {
9
+ "test": "node test/setup.test.mjs"
10
+ },
11
+ "files": [
12
+ "bin",
13
+ "commands"
14
+ ],
15
+ "keywords": [
16
+ "claude-code",
17
+ "tap",
18
+ "agentsec",
19
+ "credential-proxy",
20
+ "ai-agent"
21
+ ],
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/nanaknihal/agentsec.git",
26
+ "directory": "packages/toolauthz"
27
+ }
28
+ }