@agnic/wallet-skills 1.3.3 → 2.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+
3
+ ## [2.0.0] - 2026-04-12
4
+
5
+ ### Breaking Changes
6
+ - Removed `agnic` unified meta-skill. Use individual skills instead.
7
+ - `pay-for-service` now requires explicit user invocation (`disable-model-invocation: true`). Claude will no longer auto-invoke payments.
8
+ - Removed all deprecated root-level `.md` skill files. Only `skills/*/SKILL.md` format is supported.
9
+ - `agent-email` migrated from legacy `.md` format to `agent-email/SKILL.md`.
10
+
11
+ ### Added
12
+ - **Headless authentication** via `AGNIC_TOKEN` env var and `--token` flag. AI agents, CI pipelines, and servers can now authenticate without a browser.
13
+ - `agent-email/SKILL.md` — full production-quality skill with proper frontmatter, input validation, and error handling.
14
+ - `context: fork` on `pay-for-service` and `ai-gateway` for execution isolation.
15
+ - Progressive disclosure: `reference/` directories for `ai-gateway` and `pay-for-service` with extracted reference material.
16
+
17
+ ### Changed
18
+ - All skills: standardized authentication section with dual-mode support (browser OAuth + headless token).
19
+ - All skills: optimized descriptions for Claude discovery with front-loaded trigger keywords.
20
+ - All skills: scoped `allowed-tools` patterns (no wildcards).
21
+ - Rebranded "AgnicPay" references to "Agnic" throughout.
22
+ - Updated install command from `agnicpay/` to `agnic-protocol/` org.
23
+ - Updated npm keywords: added `claude-code`, `erc-8004`, `headless-auth`; removed `agnicpay`, `vercel-ai`.
24
+
25
+ ### Fixed
26
+ - **Security**: `pay-for-service` could be auto-invoked by Claude, spending real USDC without explicit user consent.
27
+ - **Headless auth**: AI agents in non-interactive environments now have a working authentication path.
28
+ - `agent-email` had no proper `SKILL.md` — only a deprecated `.md` file with no `allowed-tools` or frontmatter fields.
package/README.md CHANGED
@@ -1,32 +1,54 @@
1
- # AgnicPay Agentic Wallet Skills
1
+ # Agnic Wallet Skills for Claude Code
2
2
 
3
- Agent Skills for crypto wallet operations. These skills enable AI agents to authenticate, check balances, make x402 payments, access 340+ AI models, generate images, and verify on-chain identity using the `agnic` CLI.
3
+ Give your AI agent a crypto wallet, payments, email, and on-chain identity.
4
+
5
+ These skills enable AI agents to authenticate, check balances, make x402 payments, access 340+ AI models, generate images, manage agent email, and verify on-chain identity using the `agnic` CLI.
4
6
 
5
7
  ## Available Skills
6
8
 
7
- | Skill | Description |
8
- |-------|-------------|
9
- | **authenticate-wallet** | Sign in to the wallet via browser OAuth |
10
- | **check-balance** | Check USDC balance across networks (Base, Solana) |
11
- | **search-for-service** | Search for paid API services via x402 |
12
- | **pay-for-service** | Make paid API requests via x402 |
13
- | **fund-wallet** | Get instructions for adding funds to the wallet |
14
- | **get-agent-identity** | Check on-chain ERC-8004 identity and trust score |
15
- | **agent-email** | Manage agent email send, receive, check inbox |
16
- | **ai-gateway** | Access 340+ AI models chat, image generation (GPT, Claude, Gemini, Llama, Flux) |
17
- | **agnic** | Unified skill — all wallet, payment, email, identity, and AI gateway capabilities |
9
+ | Skill | Description | Side Effects |
10
+ |-------|-------------|--------------|
11
+ | **authenticate-wallet** | Sign in via browser OAuth or headless API token | None |
12
+ | **check-balance** | Check USDC balance across networks (Base, Solana) | None |
13
+ | **search-for-service** | Search for paid API services via x402 bazaar | None |
14
+ | **pay-for-service** | Make paid API requests via x402 (USDC) | Spends USDC |
15
+ | **fund-wallet** | Get instructions for adding funds to the wallet | None |
16
+ | **get-agent-identity** | Check on-chain ERC-8004 identity and trust score | None |
17
+ | **agent-email** | Send, receive, and manage agent email | Sends email |
18
+ | **ai-gateway** | Access 340+ AI models -- chat and image generation | Spends USDC |
18
19
 
19
20
  ## Installation
20
21
 
21
- Install with Vercel's [Skills CLI](https://github.com/vercel/skills):
22
+ Install with the [Skills CLI](https://github.com/vercel/skills):
23
+
24
+ ```bash
25
+ npx skills add agnic-protocol/agnic-wallet-skills
26
+ ```
27
+
28
+ ## Authentication
29
+
30
+ ### Interactive (browser available)
31
+
32
+ ```bash
33
+ npx agnic@latest auth login
34
+ ```
35
+
36
+ Opens a browser for OAuth sign-in. Best for local development.
37
+
38
+ ### Headless (CI, servers, AI agents)
39
+
40
+ Generate an API token at [app.agnic.ai](https://app.agnic.ai) > Settings > API Tokens, then:
22
41
 
23
42
  ```bash
24
- npx skills add agnicpay/agnic-wallet-skills
43
+ export AGNIC_TOKEN=<your-api-token>
44
+ npx agnic@latest status --json
25
45
  ```
26
46
 
47
+ All commands in the session will authenticate automatically. No browser required.
48
+
27
49
  ## Usage
28
50
 
29
- Skills are automatically available once installed. The agent will use them when relevant tasks are detected.
51
+ Skills are automatically available once installed. The agent uses them when relevant tasks are detected.
30
52
 
31
53
  Examples:
32
54
 
@@ -38,6 +60,18 @@ Examples:
38
60
  - `List available AI models`
39
61
  - `Ask GPT-4o to explain quantum computing`
40
62
  - `Generate an image of a sunset over mountains`
63
+ - `Check my agent email inbox`
64
+ - `Send an email to user@example.com`
65
+
66
+ ## Performance
67
+
68
+ For faster CLI invocations (avoids downloading on every call):
69
+
70
+ ```bash
71
+ npm install -g agnic
72
+ ```
73
+
74
+ Then all `npx agnic@latest` commands run instantly from the global install.
41
75
 
42
76
  ## Contributing
43
77
 
@@ -45,20 +79,12 @@ To add a new skill:
45
79
 
46
80
  1. Create a folder in `./skills/` with a lowercase, hyphenated name
47
81
  2. Add a `SKILL.md` file with YAML frontmatter and instructions
48
- 3. See the [Agent Skills specification](https://github.com/vercel/skills) for the complete format
49
-
50
- ### Updating the agnic version
51
-
52
- All skills pin `agnic@latest` via `npx agnic@latest`. When testing against a specific version:
53
-
54
- ```bash
55
- # Install a specific version
56
- npm install -g agnic@2.0.0
57
- ```
82
+ 3. Optionally add a `reference/` directory for detailed documentation
83
+ 4. See the [Skills specification](https://github.com/vercel/skills) for the complete format
58
84
 
59
85
  ## Documentation
60
86
 
61
- Full docs at [docs.agnic.ai/docs/agnicpay-features/skills](https://docs.agnic.ai/docs/agnicpay-features/skills)
87
+ Full docs at [docs.agnic.ai](https://docs.agnic.ai)
62
88
 
63
89
  ## License
64
90
 
package/package.json CHANGED
@@ -1,20 +1,22 @@
1
1
  {
2
2
  "name": "@agnic/wallet-skills",
3
- "version": "1.3.3",
4
- "description": "Vercel AI SDK skills for AgnicPay wallet — balance, x402, agent identity, and AI gateway",
3
+ "version": "2.0.0",
4
+ "description": "Claude Code skills for the Agnic wallet — payments, x402, AI gateway, agent email, and on-chain identity",
5
5
  "keywords": [
6
6
  "agnic",
7
- "agnicpay",
7
+ "claude-code",
8
8
  "skills",
9
- "vercel-ai",
10
9
  "x402",
11
10
  "wallet",
12
- "ai-agent"
11
+ "ai-agent",
12
+ "erc-8004",
13
+ "usdc",
14
+ "headless-auth"
13
15
  ],
14
16
  "license": "MIT",
15
17
  "repository": {
16
18
  "type": "git",
17
19
  "url": "https://github.com/agnic-protocol/agnic-wallet-skills"
18
20
  },
19
- "homepage": "https://docs.agnic.ai/docs/agnicpay-features/skills"
21
+ "homepage": "https://docs.agnic.ai/docs/agnic-features/skills"
20
22
  }
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: agent-email
3
+ description: >
4
+ Send and receive email as your AI agent. Use when the user wants to
5
+ check inbox, send email, reply to messages, set up an email alias,
6
+ or manage agent email. Covers "check my email", "send an email",
7
+ "what's my agent email", "set up email", "inbox".
8
+ user-invocable: true
9
+ disable-model-invocation: false
10
+ allowed-tools:
11
+ - "Bash(npx agnic@latest status*)"
12
+ - "Bash(npx agnic@latest email *)"
13
+ ---
14
+
15
+ # Agent Email
16
+
17
+ Each agent gets a unique email address in the format `agent-<id>@agnic.ai`. Use `npx agnic@latest email` commands to manage it.
18
+
19
+ ## Authentication
20
+
21
+ Run `npx agnic@latest status --json` to verify. If not authenticated:
22
+ - **Headless (CI/server/agent)**: Set `AGNIC_TOKEN` env var or pass `--token <token>`
23
+ - **Interactive (has browser)**: Run `npx agnic@latest auth login`
24
+
25
+ See the `authenticate-wallet` skill for details.
26
+
27
+ ## Commands
28
+
29
+ ### Set up email alias
30
+
31
+ ```bash
32
+ npx agnic@latest email setup --display-name "My Agent" --json
33
+ ```
34
+
35
+ ### Check email address
36
+
37
+ ```bash
38
+ npx agnic@latest email address --json
39
+ ```
40
+
41
+ ### Check inbox
42
+
43
+ ```bash
44
+ npx agnic@latest email inbox --limit 10 --json
45
+ ```
46
+
47
+ ### Send email
48
+
49
+ ```bash
50
+ npx agnic@latest email send --to <address> --subject "<subject>" --body "<body>"
51
+ ```
52
+
53
+ ### Reply to a message
54
+
55
+ ```bash
56
+ npx agnic@latest email reply --message-id <id> --body "<reply text>"
57
+ ```
58
+
59
+ ## Input Validation
60
+
61
+ Before constructing commands, validate user-provided values:
62
+
63
+ - **--to**: Must be a valid email address. Reject if it contains spaces, semicolons, pipes, or backticks.
64
+ - **--subject**: Single-quote the value. Escape internal single quotes.
65
+ - **--body**: Single-quote the value. Escape internal single quotes.
66
+ - **--message-id**: Must be alphanumeric or UUID format.
67
+
68
+ Do not pass unvalidated user input into the command.
69
+
70
+ ## Important Notes
71
+
72
+ - Emails are stored with **30-day retention**
73
+ - Display name can be set once during setup
74
+ - Inbox returns most recent messages first
75
+
76
+ ## Prerequisites
77
+
78
+ - Must be authenticated (`npx agnic@latest status` to check)
79
+ - Agent identity must exist (created automatically during sign-up)
80
+
81
+ ## Error Handling
82
+
83
+ Common errors:
84
+
85
+ - "Not authenticated" -- Run `npx agnic@latest auth login` or set `AGNIC_TOKEN`
86
+ - "No email alias found" -- Run `npx agnic@latest email setup` first
87
+ - "Agent not found" -- The user may not have an agent registered; sign up at [app.agnic.ai](https://app.agnic.ai)
88
+ - "Message not found" -- Check the message ID with `email inbox` first
@@ -1,119 +1,63 @@
1
1
  ---
2
2
  name: ai-gateway
3
- description: Access 340+ AI models through the Agnic AI Gateway. Use when the user wants to chat with an AI model, generate images with AI, list available models, delegate a task to another LLM, or get a second opinion. Covers phrases like "ask GPT", "use Claude", "generate an image", "list AI models", "chat with AI", "call a model", "what models are available".
3
+ description: >
4
+ Access 340+ AI models via the Agnic AI Gateway -- chat, image generation,
5
+ model listing. Use when the user wants to chat with AI, generate images,
6
+ ask GPT, use Claude, list models, delegate to another LLM, or get a
7
+ second opinion. Covers "ask GPT", "use Claude", "generate an image",
8
+ "list AI models", "call a model".
4
9
  user-invocable: true
5
10
  disable-model-invocation: false
6
- allowed-tools: ["Bash(npx agnic@latest status*)", "Bash(npx agnic@latest ai *)"]
11
+ context: fork
12
+ allowed-tools:
13
+ - "Bash(npx agnic@latest status*)"
14
+ - "Bash(npx agnic@latest ai *)"
7
15
  ---
8
16
 
9
17
  # AI Gateway
10
18
 
11
- Use `npx agnic@latest ai` commands to access 340+ AI models (OpenAI, Anthropic, Google, Meta, Mistral, DeepSeek, and more) through the Agnic AI Gateway. Costs are deducted from your USDC balance per token. Free models available for development.
19
+ Access 340+ AI models (OpenAI, Anthropic, Google, Meta, Mistral, DeepSeek, and more) through the Agnic AI Gateway. Costs are deducted from your USDC balance per token. Free models available for development.
12
20
 
13
- ## Confirm wallet is initialized and authed
21
+ ## Authentication
14
22
 
15
- ```bash
16
- npx agnic@latest status
17
- ```
23
+ Run `npx agnic@latest status --json` to verify. If not authenticated:
24
+ - **Headless (CI/server/agent)**: Set `AGNIC_TOKEN` env var or pass `--token <token>`
25
+ - **Interactive (has browser)**: Run `npx agnic@latest auth login`
18
26
 
19
- If not authenticated, refer to the `authenticate-wallet` skill.
27
+ See the `authenticate-wallet` skill for details.
20
28
 
21
- ## Command Syntax
29
+ ## Commands
22
30
 
23
31
  ### List models
24
32
 
25
33
  ```bash
26
- npx agnic@latest ai models [options]
34
+ npx agnic@latest ai models [--provider <name>] [--search <term>] [--json]
27
35
  ```
28
36
 
29
37
  ### Chat with a model
30
38
 
31
39
  ```bash
32
- npx agnic@latest ai chat --model <id> --prompt "<text>" [options]
40
+ npx agnic@latest ai chat --model <provider/model-name> --prompt "<text>" [--system "<text>"] [--json]
33
41
  ```
34
42
 
35
43
  ### Generate an image
36
44
 
37
45
  ```bash
38
- npx agnic@latest ai image --prompt "<text>" [options]
46
+ npx agnic@latest ai image --prompt "<text>" [--aspect-ratio 16:9] [--output file.png] [--json]
39
47
  ```
40
48
 
41
- ## Model Format
42
-
43
- Models use `provider/model-name` format:
44
-
45
- | Provider | Example Models |
46
- | ----------- | ----------------------------------------- |
47
- | openai | `openai/gpt-4o`, `openai/gpt-4-turbo` |
48
- | anthropic | `anthropic/claude-3.5-sonnet` |
49
- | google | `google/gemini-2.5-flash-image`, `google/gemma-*` |
50
- | meta-llama | `meta-llama/llama-3.3-70b` |
51
- | mistralai | `mistralai/mistral-large-latest` |
52
- | deepseek | `deepseek/deepseek-chat` |
53
-
54
- Free models: `meta-llama/*`, `google/gemma-*`, `mistralai/*`
55
-
56
- ## Options
57
-
58
- ### ai models
59
-
60
- | Option | Description |
61
- | -------------------- | ---------------------------------------- |
62
- | `--provider <name>` | Filter by provider (e.g., openai) |
63
- | `--search <term>` | Search in model name |
64
- | `--json` | Output as JSON |
65
-
66
- ### ai chat
67
-
68
- | Option | Description |
69
- | ----------------------- | ---------------------------------------- |
70
- | `--model <id>` | Model ID (required) |
71
- | `--prompt <text>` | User message (required) |
72
- | `--system <text>` | System prompt |
73
- | `--temperature <n>` | Temperature 0-2 (default: 0.7) |
74
- | `--max-tokens <n>` | Max tokens in response |
75
- | `--json` | Output as JSON |
76
-
77
- ### ai image
78
-
79
- | Option | Description |
80
- | ------------------------- | ---------------------------------------- |
81
- | `--prompt <text>` | Image description (required) |
82
- | `--model <id>` | Model (default: google/gemini-2.5-flash-image) |
83
- | `--aspect-ratio <ratio>` | 1:1, 16:9, 9:16, 4:3, 3:2 (default: 1:1)|
84
- | `--output <path>` | Save image to file |
85
- | `--json` | Output as JSON |
86
-
87
- ## Input Validation
88
-
89
- Before constructing the command, validate all user-provided values:
90
-
91
- - **model**: Must match `^[a-zA-Z0-9_-]+/[a-zA-Z0-9._-]+$` (provider/model format). Reject if it contains spaces, semicolons, pipes, or backticks.
92
- - **prompt**: Single-quote the value to prevent shell expansion. Escape internal single quotes.
93
- - **temperature**: Must be a number between 0 and 2 (`^[0-2](\.\d+)?$`).
94
- - **aspect-ratio**: Must be one of: `1:1`, `16:9`, `9:16`, `4:3`, `3:2`.
95
- - **output**: Must be a valid file path. Reject if it contains shell metacharacters.
96
-
97
- Do not pass unvalidated user input into the command.
49
+ Models use `provider/model-name` format (e.g., `openai/gpt-4o`, `meta-llama/llama-3.3-70b`).
50
+ See `reference/models-and-options.md` for full model list, all options, and input validation rules.
98
51
 
99
52
  ## Examples
100
53
 
101
54
  ```bash
102
- # List all available models
103
- npx agnic@latest ai models --json
104
-
105
- # List only OpenAI models
106
- npx agnic@latest ai models --provider openai
107
-
108
- # Search for GPT models
109
- npx agnic@latest ai models --search gpt
55
+ # List OpenAI models
56
+ npx agnic@latest ai models --provider openai --json
110
57
 
111
58
  # Chat with GPT-4o
112
59
  npx agnic@latest ai chat --model openai/gpt-4o --prompt 'Explain quantum computing in one sentence'
113
60
 
114
- # Chat with system prompt
115
- npx agnic@latest ai chat --model anthropic/claude-3.5-sonnet --system 'You are a helpful coding assistant' --prompt 'Write a Python hello world'
116
-
117
61
  # Use a free model
118
62
  npx agnic@latest ai chat --model meta-llama/llama-3.3-70b --prompt 'What is 2+2?' --json
119
63
 
@@ -122,33 +66,19 @@ npx agnic@latest ai image --prompt 'A sunset over mountains' --output sunset.png
122
66
 
123
67
  # Generate widescreen image
124
68
  npx agnic@latest ai image --prompt 'Cyberpunk cityscape' --aspect-ratio 16:9 --output city.png
125
-
126
- # Use a specific image model
127
- npx agnic@latest ai image --prompt 'A portrait painting' --model openai/gpt-5-image --output portrait.png
128
- npx agnic@latest ai image --prompt 'Abstract art' --model black-forest-labs/flux.2-max --output art.png
129
-
130
- # Get image as JSON (base64)
131
- npx agnic@latest ai image --prompt 'Logo design for a tech startup' --json
132
69
  ```
133
70
 
134
71
  ## Prerequisites
135
72
 
136
73
  - Must be authenticated (`npx agnic@latest status` to check)
137
74
  - Wallet must have USDC balance (free models available for testing)
138
- - Image generation models:
139
- - `google/gemini-2.5-flash-image` (default) — fast, good quality
140
- - `google/gemini-3-pro-image-preview` — highest quality Google model
141
- - `google/gemini-3.1-flash-image-preview` — latest flash preview
142
- - `openai/gpt-5-image` — OpenAI image generation
143
- - `black-forest-labs/flux.2-max` — Flux high quality
144
- - `black-forest-labs/flux.2-klein-4b` — Flux lightweight/fast
145
75
 
146
76
  ## Error Handling
147
77
 
148
78
  Common errors:
149
79
 
150
- - "Not authenticated" Run `npx agnic@latest auth login` first
151
- - "Insufficient balance" Fund wallet at https://app.agnic.ai
152
- - "Model not found" Check available models with `npx agnic@latest ai models`
153
- - "No image returned" Try a different model or rephrase the prompt
154
- - "Rate limit exceeded" Wait a moment and retry
80
+ - "Not authenticated" -- Run `npx agnic@latest auth login` or set `AGNIC_TOKEN`
81
+ - "Insufficient balance" -- Fund wallet at [app.agnic.ai](https://app.agnic.ai)
82
+ - "Model not found" -- Check available models with `npx agnic@latest ai models`
83
+ - "No image returned" -- Try a different model or rephrase the prompt
84
+ - "Rate limit exceeded" -- Wait a moment and retry
@@ -0,0 +1,68 @@
1
+ # AI Gateway — Models & Options Reference
2
+
3
+ ## Model Format
4
+
5
+ Models use `provider/model-name` format:
6
+
7
+ | Provider | Example Models |
8
+ | ----------- | ------------------------------------------------- |
9
+ | openai | `openai/gpt-4o`, `openai/gpt-4-turbo` |
10
+ | anthropic | `anthropic/claude-3.5-sonnet` |
11
+ | google | `google/gemini-2.5-flash-image`, `google/gemma-*` |
12
+ | meta-llama | `meta-llama/llama-3.3-70b` |
13
+ | mistralai | `mistralai/mistral-large-latest` |
14
+ | deepseek | `deepseek/deepseek-chat` |
15
+
16
+ Free models: `meta-llama/*`, `google/gemma-*`, `mistralai/*`
17
+
18
+ ## ai models Options
19
+
20
+ | Option | Description |
21
+ | ------------------ | ---------------------------------- |
22
+ | `--provider <name>`| Filter by provider (e.g., openai) |
23
+ | `--search <term>` | Search in model name |
24
+ | `--json` | Output as JSON |
25
+
26
+ ## ai chat Options
27
+
28
+ | Option | Description |
29
+ | ---------------------- | ---------------------------------- |
30
+ | `--model <id>` | Model ID (required) |
31
+ | `--prompt <text>` | User message (required) |
32
+ | `--system <text>` | System prompt |
33
+ | `--temperature <n>` | Temperature 0-2 (default: 0.7) |
34
+ | `--max-tokens <n>` | Max tokens in response |
35
+ | `--json` | Output as JSON |
36
+
37
+ ## ai image Options
38
+
39
+ | Option | Description |
40
+ | ----------------------- | --------------------------------------------------- |
41
+ | `--prompt <text>` | Image description (required) |
42
+ | `--model <id>` | Model (default: google/gemini-2.5-flash-image) |
43
+ | `--aspect-ratio <ratio>`| 1:1, 16:9, 9:16, 4:3, 3:2 (default: 1:1) |
44
+ | `--output <path>` | Save image to file |
45
+ | `--json` | Output as JSON |
46
+
47
+ ## Image Generation Models
48
+
49
+ | Model | Notes |
50
+ | ---------------------------------------- | ---------------------------- |
51
+ | `google/gemini-2.5-flash-image` (default)| Fast, good quality |
52
+ | `google/gemini-3-pro-image-preview` | Highest quality Google model |
53
+ | `google/gemini-3.1-flash-image-preview` | Latest flash preview |
54
+ | `openai/gpt-5-image` | OpenAI image generation |
55
+ | `black-forest-labs/flux.2-max` | Flux high quality |
56
+ | `black-forest-labs/flux.2-klein-4b` | Flux lightweight/fast |
57
+
58
+ ## Input Validation
59
+
60
+ Before constructing the command, validate all user-provided values:
61
+
62
+ - **model**: Must match `^[a-zA-Z0-9_-]+/[a-zA-Z0-9._-]+$` (provider/model format). Reject if it contains spaces, semicolons, pipes, or backticks.
63
+ - **prompt**: Single-quote the value to prevent shell expansion. Escape internal single quotes.
64
+ - **temperature**: Must be a number between 0 and 2 (`^[0-2](\.\d+)?$`).
65
+ - **aspect-ratio**: Must be one of: `1:1`, `16:9`, `9:16`, `4:3`, `3:2`.
66
+ - **output**: Must be a valid file path. Reject if it contains shell metacharacters.
67
+
68
+ Do not pass unvalidated user input into the command.
@@ -1,24 +1,47 @@
1
1
  ---
2
2
  name: authenticate-wallet
3
- description: Sign in to AgnicPay wallet via browser-based OAuth. Use when you or the user want to authenticate, sign in, log in, connect wallet, or set up the CLI. Covers phrases like "sign in", "log in", "authenticate", "connect my wallet", "set up agnic".
3
+ description: >
4
+ Authenticate Agnic wallet via browser OAuth or headless API token.
5
+ Use when the user wants to sign in, log in, authenticate, connect wallet,
6
+ set up CLI, or resolve "Not authenticated" errors.
7
+ Supports AGNIC_TOKEN env var for CI/server/agent environments.
4
8
  user-invocable: true
5
9
  disable-model-invocation: false
6
- allowed-tools: ["Bash(npx agnic@latest status*)", "Bash(npx agnic@latest auth *)"]
10
+ allowed-tools:
11
+ - "Bash(npx agnic@latest status*)"
12
+ - "Bash(npx agnic@latest auth *)"
7
13
  ---
8
14
 
9
- # Authenticating the AgnicPay Wallet
15
+ # Authenticating the Agnic Wallet
10
16
 
11
- Use `npx agnic@latest auth login` to authenticate via browser-based OAuth. This opens the user's default browser to AgnicPay where they sign in and set spending limits for the CLI session.
17
+ ## Check Current Status
12
18
 
13
- ## Confirm wallet is initialized and authed
19
+ ```bash
20
+ npx agnic@latest status --json
21
+ ```
22
+
23
+ If already authenticated, no further action needed. If not, choose the appropriate mode below.
24
+
25
+ ## Mode 1: Headless / Token Auth (CI, servers, agents)
14
26
 
27
+ Preferred when no browser is available. Generate an API token at [app.agnic.ai](https://app.agnic.ai) > Settings > API Tokens.
28
+
29
+ **Option A -- Environment variable** (recommended for automation):
15
30
  ```bash
16
- npx agnic@latest status
31
+ export AGNIC_TOKEN=<your-api-token>
32
+ npx agnic@latest status --json
17
33
  ```
18
34
 
19
- If already authenticated, no further action is needed. If not authenticated, proceed with login.
35
+ The CLI reads `AGNIC_TOKEN` automatically. All subsequent commands in the same shell session use it without extra flags.
20
36
 
21
- ## Login Flow
37
+ **Option B -- Inline flag** (one-off commands):
38
+ ```bash
39
+ npx agnic@latest --token <your-api-token> status --json
40
+ ```
41
+
42
+ ## Mode 2: Browser OAuth (interactive terminals)
43
+
44
+ Use when a browser is available:
22
45
 
23
46
  ```bash
24
47
  npx agnic@latest auth login
@@ -26,30 +49,29 @@ npx agnic@latest auth login
26
49
 
27
50
  This command:
28
51
  1. Starts a temporary local server on a random port
29
- 2. Opens the user's default browser to AgnicPay's OAuth consent screen
52
+ 2. Opens the default browser to the Agnic OAuth consent screen
30
53
  3. The user signs in (email, Google, or wallet) and approves spending limits
31
54
  4. The browser redirects back to `http://localhost:<port>/callback`
32
55
  5. The CLI exchanges the authorization code for tokens and saves them locally
33
56
 
34
- Wait for the CLI to print `✓ Authenticated!` before proceeding.
57
+ Wait for the CLI to print `Authenticated!` before proceeding.
35
58
 
36
59
  ## Verify Authentication
37
60
 
38
- After login, confirm the session is active:
39
-
40
61
  ```bash
41
- npx agnic@latest status
62
+ npx agnic@latest status --json
42
63
  ```
43
64
 
44
65
  Expected output:
45
66
 
46
- ```
47
- Wallet Status
48
- Authenticated
49
-
50
- Email: user@example.com
51
- Wallet: 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7
52
- Expires: 2026-05-22 14:30:00 UTC
67
+ ```json
68
+ {
69
+ "authenticated": true,
70
+ "userId": "did:privy:...",
71
+ "email": "user@example.com",
72
+ "walletAddress": "0x...",
73
+ "tokenExpiry": "2026-05-22T14:30:00Z"
74
+ }
53
75
  ```
54
76
 
55
77
  ## Logout
@@ -62,13 +84,13 @@ npx agnic@latest auth logout
62
84
 
63
85
  ## Token Storage
64
86
 
65
- Credentials are stored in `~/.agnic/config.json` with restricted permissions (`0600`). Tokens auto-refresh on 401 responses no manual re-authentication needed until the refresh token expires (90 days).
87
+ - Browser mode: credentials stored in `~/.agnic/config.json` with `0600` permissions. Tokens auto-refresh on 401 responses. Refresh token expires after 90 days.
88
+ - Token mode: no local storage. The token is read from `AGNIC_TOKEN` env var or `--token` flag per invocation.
66
89
 
67
90
  ## Error Handling
68
91
 
69
- Common errors:
70
-
71
- - "Not authenticated" Run `npx agnic@latest auth login`
72
- - "Authentication failed" User cancelled the browser flow or the timeout (5 min) expired
73
- - "Could not open browser" The CLI prints a URL to copy and open manually
74
- - "Token expired" — Tokens auto-refresh; if refresh also fails, re-run `npx agnic@latest auth login`
92
+ - "Not authenticated" -- Set `AGNIC_TOKEN` env var, pass `--token`, or run `auth login`
93
+ - "Authentication failed" -- User cancelled the browser flow or the 5-min timeout expired
94
+ - "Could not open browser" -- The CLI prints a URL to copy and open manually
95
+ - "Token expired" -- Browser tokens auto-refresh; API tokens must be regenerated at app.agnic.ai
96
+ - "Invalid token" -- Check the token value; it may have been revoked or malformed