@web42/w42 0.1.17 → 0.1.18

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 CHANGED
@@ -47,6 +47,7 @@ web42 send http://localhost:3001 "Hello"
47
47
  | `--new` | Start a new conversation (clears saved context) |
48
48
  | `--context <id>` | Use a specific context ID |
49
49
  | `--task-id <id>` | Reply to a specific task (e.g. one in `input-required` state) |
50
+ | `--pay <token>` | Attach AP2 payment token as PaymentMandate data part |
50
51
 
51
52
  ---
52
53
 
@@ -92,6 +93,108 @@ web42 register https://my-agent.example.com --visibility private --tags "nlp,sum
92
93
 
93
94
  ---
94
95
 
96
+ ### `web42 pay`
97
+
98
+ AP2 payment commands — wallet management, payment intents, checkout, and human signing.
99
+
100
+ #### `web42 pay wallet`
101
+
102
+ View your wallet balance.
103
+
104
+ ```bash
105
+ web42 pay wallet
106
+ ```
107
+
108
+ #### `web42 pay wallet topup <amount>`
109
+
110
+ Add funds to your wallet. Amount is in dollars.
111
+
112
+ ```bash
113
+ web42 pay wallet topup 50.00
114
+ ```
115
+
116
+ #### `web42 pay intent propose`
117
+
118
+ Generate an intent creation URL for the user to authorize in the browser.
119
+
120
+ ```bash
121
+ web42 pay intent propose --nick starbucks-daily --agents @x~starbucks --max-amount 5.00 --prompt-playback "Spend up to $5/day at Starbucks" --recurring daily
122
+ ```
123
+
124
+ | Option | Description |
125
+ |---|---|
126
+ | `--nick <nick>` | Short identifier for the intent (required) |
127
+ | `--agents <slugs>` | Comma-separated merchant agent slugs (required) |
128
+ | `--max-amount <dollars>` | Max amount per transaction (required) |
129
+ | `--prompt-playback <text>` | Human-readable description (required) |
130
+ | `--currency <code>` | Currency code (default: `USD`) |
131
+ | `--recurring <type>` | `once`, `daily`, `weekly`, or `monthly` (default: `once`) |
132
+ | `--budget <dollars>` | Lifetime budget |
133
+ | `--expires <date>` | Expiry date (ISO 8601) |
134
+
135
+ #### `web42 pay intent get --nick <nick>`
136
+
137
+ Fetch an intent by nick. Caches locally if active.
138
+
139
+ #### `web42 pay intent list`
140
+
141
+ List all your payment intents.
142
+
143
+ #### `web42 pay intent revoke --nick <nick>`
144
+
145
+ Revoke an active intent.
146
+
147
+ #### `web42 pay checkout`
148
+
149
+ Execute a payment against a matching intent (no human approval needed).
150
+
151
+ ```bash
152
+ web42 pay checkout --cart '<json>' --agent @x~starbucks --intent starbucks-daily
153
+ ```
154
+
155
+ | Option | Description |
156
+ |---|---|
157
+ | `--cart <json>` | CartMandate JSON (required) |
158
+ | `--agent <slug>` | Merchant agent slug (required) |
159
+ | `--intent <nick>` | Intent nick to use (required) |
160
+
161
+ #### `web42 pay sign create`
162
+
163
+ Create a payment session for human approval (when no matching intent exists).
164
+
165
+ ```bash
166
+ web42 pay sign create --cart '<json>' --agent @x~bookstore
167
+ ```
168
+
169
+ | Option | Description |
170
+ |---|---|
171
+ | `--cart <json>` | CartMandate JSON (required) |
172
+ | `--agent <slug>` | Merchant agent slug (required) |
173
+
174
+ Returns `{ code, signing_url }`. Present the URL to the user.
175
+
176
+ #### `web42 pay sign get <code>`
177
+
178
+ Check the status of a payment session.
179
+
180
+ ```bash
181
+ web42 pay sign get a1b2c3d4e5f6g7h8
182
+ ```
183
+
184
+ ---
185
+
186
+ ### `web42 telemetry`
187
+
188
+ Control usage telemetry.
189
+
190
+ ```bash
191
+ web42 telemetry # Show current state
192
+ web42 telemetry on # Enable
193
+ web42 telemetry off # Disable
194
+ ```
195
+
196
+ ---
197
+
95
198
  ## Environment variables
96
199
 
97
200
  ```bash
@@ -112,6 +112,40 @@ intentCommand
112
112
  process.exit(1);
113
113
  }
114
114
  });
115
+ intentCommand
116
+ .command("propose")
117
+ .description("Generate an intent creation URL for the user to authorize in the browser")
118
+ .requiredOption("--nick <nick>", "Short identifier for the intent")
119
+ .requiredOption("--agents <slugs>", "Comma-separated merchant agent slugs (e.g. @x~starbucks)")
120
+ .requiredOption("--max-amount <dollars>", "Max amount per transaction in dollars")
121
+ .requiredOption("--prompt-playback <text>", "Human-readable description of the intent")
122
+ .option("--currency <code>", "Currency code", "USD")
123
+ .option("--recurring <type>", "Recurring type: once, daily, weekly, monthly", "once")
124
+ .option("--budget <dollars>", "Lifetime budget in dollars")
125
+ .option("--expires <date>", "Expiry date (ISO 8601)")
126
+ .action(async (opts) => {
127
+ const cfg = requireAuth();
128
+ const username = cfg.username;
129
+ if (!username) {
130
+ console.error(chalk.red("No username found. Please log in again."));
131
+ process.exit(1);
132
+ }
133
+ const baseUrl = cfg.apiUrl ?? "https://web42-network.vercel.app";
134
+ const params = new URLSearchParams({
135
+ nick: opts.nick,
136
+ agents: opts.agents,
137
+ max_amount: opts.maxAmount,
138
+ currency: opts.currency,
139
+ recurring: opts.recurring,
140
+ prompt_playback: opts.promptPlayback,
141
+ });
142
+ if (opts.budget)
143
+ params.set("budget", opts.budget);
144
+ if (opts.expires)
145
+ params.set("expires_at", opts.expires);
146
+ const url = `${baseUrl}/@${username}/intents/create?${params.toString()}`;
147
+ console.log(JSON.stringify({ url }, null, 2));
148
+ });
115
149
  // ─── Checkout ─────────────────────────────────────────────
116
150
  const checkoutCommand = new Command("checkout")
117
151
  .description("Execute a payment against a matching intent (no human needed)")
@@ -195,37 +229,22 @@ signCommand
195
229
  }
196
230
  });
197
231
  signCommand
198
- .command("poll")
199
- .description("Poll a payment session until completed or expired")
232
+ .command("get")
233
+ .description("Check the status of a payment session")
200
234
  .argument("<code>", "Session code")
201
235
  .action(async (code) => {
202
236
  requireAuth();
203
- const maxAttempts = 30;
204
- const intervalMs = 2000;
205
- const spinner = ora("Waiting for approval...").start();
206
- for (let i = 0; i < maxAttempts; i++) {
207
- try {
208
- const res = await apiGet(`/api/pay/session/${encodeURIComponent(code)}`);
209
- if (res.status === "completed") {
210
- spinner.stop();
211
- console.log(JSON.stringify(res, null, 2));
212
- return;
213
- }
214
- if (res.status === "expired") {
215
- spinner.fail("Session expired");
216
- process.exit(1);
217
- }
218
- // Still pending — wait and retry
219
- await new Promise((resolve) => setTimeout(resolve, intervalMs));
220
- }
221
- catch (err) {
222
- spinner.fail("Failed to poll session");
223
- console.error(chalk.red(String(err)));
224
- process.exit(1);
225
- }
237
+ const spinner = ora("Fetching session...").start();
238
+ try {
239
+ const res = await apiGet(`/api/pay/session/${encodeURIComponent(code)}`);
240
+ spinner.stop();
241
+ console.log(JSON.stringify(res, null, 2));
242
+ }
243
+ catch (err) {
244
+ spinner.fail("Failed to fetch session");
245
+ console.error(chalk.red(String(err)));
246
+ process.exit(1);
226
247
  }
227
- spinner.fail("Session still pending. Run again to continue polling.");
228
- process.exit(1);
229
248
  });
230
249
  // ─── Root pay command ─────────────────────────────────────
231
250
  export const payCommand = new Command("pay")
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const CLI_VERSION = "0.1.17";
1
+ export declare const CLI_VERSION = "0.1.18";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.1.17";
1
+ export const CLI_VERSION = "0.1.18";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@web42/w42",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "CLI for the Web42 Agent Network — discover, register, and communicate with A2A agents",
5
5
  "type": "module",
6
6
  "bin": {