arispay 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/dist/cli-b.js ADDED
@@ -0,0 +1,277 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ bold,
4
+ cmdAgents,
5
+ cmdPay,
6
+ cmdPaymentGet,
7
+ cmdStatus,
8
+ cmdTransactions,
9
+ cmdUsers,
10
+ cmdWebhooks,
11
+ configFile,
12
+ createBrand,
13
+ cyan,
14
+ dim,
15
+ error,
16
+ getVersion,
17
+ loadConfig,
18
+ parseFlags,
19
+ saveConfig,
20
+ success
21
+ } from "./chunk-4ON4ZXR3.js";
22
+
23
+ // src/cli-b.ts
24
+ import { randomBytes } from "crypto";
25
+ var BRAND = createBrand("payagent", "payagent login");
26
+ function getApiUrl(config) {
27
+ if (config.baseUrl) return config.baseUrl;
28
+ return config.environment === "production" ? "https://api.arispay.app" : "https://sandbox.api.arispay.app";
29
+ }
30
+ function getDeviceUrl(config) {
31
+ if (config.baseUrl) {
32
+ return config.baseUrl.replace("://api.", "://app.").replace("://sandbox.api.", "://app.");
33
+ }
34
+ return config.environment === "production" ? "https://app.arispay.app" : "https://app.sandbox.arispay.app";
35
+ }
36
+ async function requestDeviceCode(apiUrl) {
37
+ const res = await fetch(`${apiUrl}/v1/auth/device/code`, {
38
+ method: "POST",
39
+ headers: { "Content-Type": "application/json" },
40
+ body: JSON.stringify({ clientId: "payagent-cli" }),
41
+ signal: AbortSignal.timeout(15e3)
42
+ });
43
+ if (!res.ok) {
44
+ const body = await res.json().catch(() => ({}));
45
+ throw new Error(body.error?.message || `Device code request failed (HTTP ${res.status})`);
46
+ }
47
+ return res.json();
48
+ }
49
+ async function pollForToken(apiUrl, deviceCode, intervalSec, expiresIn) {
50
+ const deadline = Date.now() + expiresIn * 1e3;
51
+ while (Date.now() < deadline) {
52
+ await sleep(intervalSec * 1e3);
53
+ const res = await fetch(`${apiUrl}/v1/auth/device/token`, {
54
+ method: "POST",
55
+ headers: { "Content-Type": "application/json" },
56
+ body: JSON.stringify({ deviceCode, clientId: "payagent-cli" }),
57
+ signal: AbortSignal.timeout(15e3)
58
+ });
59
+ const body = await res.json();
60
+ if (res.ok && body.accessToken) {
61
+ return body;
62
+ }
63
+ const errorCode = body.error?.code || body.error;
64
+ if (errorCode === "authorization_pending") {
65
+ continue;
66
+ } else if (errorCode === "slow_down") {
67
+ intervalSec = Math.min(intervalSec + 1, 10);
68
+ continue;
69
+ } else if (errorCode === "expired_token") {
70
+ throw new Error("Login expired. Run `payagent login` to try again.");
71
+ } else if (errorCode === "access_denied") {
72
+ throw new Error("Login was denied.");
73
+ } else {
74
+ throw new Error(body.error?.message || `Token request failed (HTTP ${res.status})`);
75
+ }
76
+ }
77
+ throw new Error("Login timed out. Run `payagent login` to try again.");
78
+ }
79
+ function sleep(ms) {
80
+ return new Promise((resolve) => setTimeout(resolve, ms));
81
+ }
82
+ async function cmdLogin(args) {
83
+ const { flags } = parseFlags(args);
84
+ const config = loadConfig(BRAND);
85
+ if (flags["api-key"]) {
86
+ saveConfig(BRAND, {
87
+ ...config,
88
+ apiKey: flags["api-key"],
89
+ environment: flags["env"] || config.environment
90
+ });
91
+ success("API key saved");
92
+ return;
93
+ }
94
+ const apiUrl = getApiUrl(config);
95
+ const dashboardUrl = getDeviceUrl(config);
96
+ console.log(`
97
+ ${bold("PayAgent Login")}
98
+ `);
99
+ let device;
100
+ try {
101
+ device = await requestDeviceCode(apiUrl);
102
+ } catch (e) {
103
+ error(e.message || "Could not initiate login");
104
+ }
105
+ const verificationUrl = device.verificationUrl || `${dashboardUrl}/device`;
106
+ console.log(` Open this URL on any device:
107
+ `);
108
+ console.log(` ${cyan(verificationUrl)}
109
+ `);
110
+ console.log(` Then enter this code:
111
+ `);
112
+ console.log(` ${bold(device.userCode)}
113
+ `);
114
+ const spinner = startSpinner(" Waiting for confirmation");
115
+ try {
116
+ const token = await pollForToken(
117
+ apiUrl,
118
+ device.deviceCode,
119
+ device.interval || 5,
120
+ device.expiresIn || 300
121
+ );
122
+ spinner.stop();
123
+ saveConfig(BRAND, {
124
+ ...config,
125
+ accessToken: token.accessToken,
126
+ refreshToken: token.refreshToken,
127
+ expiresAt: token.expiresAt,
128
+ email: token.email,
129
+ environment: token.environment || config.environment
130
+ });
131
+ console.log();
132
+ success(`Logged in as ${bold(token.email || "developer")}`);
133
+ if (token.environment) {
134
+ console.log(` ${bold("Environment:")} ${token.environment}`);
135
+ }
136
+ console.log(` ${bold("Config:")} ${dim(configFile(BRAND))}`);
137
+ console.log();
138
+ } catch (e) {
139
+ spinner.stop();
140
+ console.log();
141
+ error(e.message || "Authentication failed");
142
+ }
143
+ }
144
+ async function cmdLogout() {
145
+ const config = loadConfig(BRAND);
146
+ if (!config.accessToken && !config.apiKey && !config.email) {
147
+ console.log(dim("\n Not logged in.\n"));
148
+ return;
149
+ }
150
+ saveConfig(BRAND, {
151
+ environment: config.environment,
152
+ baseUrl: config.baseUrl
153
+ });
154
+ success("Logged out");
155
+ console.log(` ${dim("Cleared credentials from")} ${configFile(BRAND)}
156
+ `);
157
+ }
158
+ function startSpinner(message) {
159
+ const frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
160
+ let i = 0;
161
+ const interval = setInterval(() => {
162
+ process.stdout.write(`\r${frames[i++ % frames.length]} ${message}`);
163
+ }, 80);
164
+ return {
165
+ stop() {
166
+ clearInterval(interval);
167
+ process.stdout.write("\r" + " ".repeat(message.length + 4) + "\r");
168
+ }
169
+ };
170
+ }
171
+ async function cmdWhoami() {
172
+ const config = loadConfig(BRAND);
173
+ if (config.email) {
174
+ console.log(config.email);
175
+ } else if (config.apiKey || config.accessToken) {
176
+ const key = config.apiKey || config.accessToken;
177
+ console.log(`api-key: ${key.slice(0, 12)}\u2026${key.slice(-4)}`);
178
+ } else {
179
+ error("Not logged in. Run: payagent login");
180
+ }
181
+ }
182
+ var HELP = `
183
+ ${bold("payagent")} \u2014 Agentic payment infrastructure CLI
184
+
185
+ ${bold("Usage:")}
186
+ payagent <command> [options]
187
+
188
+ ${bold("Auth:")}
189
+ ${cyan("login")} Authenticate via device code
190
+ ${cyan("logout")} Clear stored credentials
191
+ ${cyan("whoami")} Show current identity
192
+
193
+ ${bold("Commands:")}
194
+ ${cyan("status")} Show config & connection status
195
+ ${cyan("agents")} Manage AI payment agents
196
+ ${cyan("users")} Manage end users & payment methods
197
+ ${cyan("pay")} Create a payment
198
+ ${cyan("payment <id>")} Get payment details
199
+ ${cyan("transactions")} List transactions
200
+ ${cyan("webhooks")} Manage webhook endpoints
201
+
202
+ ${bold("Examples:")}
203
+ payagent login
204
+ payagent agents create --name "BookingBot" --mode autonomous
205
+ payagent agents list
206
+ payagent pay --agent <id> --amount 2000 --memo "Dinner for 2"
207
+ payagent transactions --agent <id> --from 2025-01-01
208
+
209
+ ${bold("Environment:")}
210
+ PAYAGENT_API_KEY Override auth (CI/scripting)
211
+ PAYAGENT_ENV Override environment (sandbox|production)
212
+ PAYAGENT_BASE_URL Override API base URL
213
+
214
+ ${bold("Config:")} ~/.payagent/config.json
215
+ `;
216
+ async function main() {
217
+ const args = process.argv.slice(2);
218
+ const command = args[0];
219
+ const rest = args.slice(1);
220
+ if (!command || command === "help" || command === "--help" || command === "-h") {
221
+ console.log(HELP);
222
+ return;
223
+ }
224
+ if (command === "--version" || command === "-v") {
225
+ console.log(getVersion());
226
+ return;
227
+ }
228
+ try {
229
+ switch (command) {
230
+ case "login":
231
+ await cmdLogin(rest);
232
+ break;
233
+ case "logout":
234
+ await cmdLogout();
235
+ break;
236
+ case "whoami":
237
+ await cmdWhoami();
238
+ break;
239
+ case "status":
240
+ await cmdStatus(BRAND);
241
+ break;
242
+ case "agents":
243
+ case "agent":
244
+ await cmdAgents(rest, BRAND);
245
+ break;
246
+ case "users":
247
+ case "user":
248
+ await cmdUsers(rest, BRAND);
249
+ break;
250
+ case "pay":
251
+ await cmdPay(rest, BRAND);
252
+ break;
253
+ case "payment":
254
+ await cmdPaymentGet(rest, BRAND);
255
+ break;
256
+ case "transactions":
257
+ case "txs":
258
+ await cmdTransactions(rest, BRAND);
259
+ break;
260
+ case "webhooks":
261
+ case "webhook":
262
+ await cmdWebhooks(rest, BRAND);
263
+ break;
264
+ default:
265
+ console.error(`Unknown command: ${command}`);
266
+ console.log(HELP);
267
+ process.exit(1);
268
+ }
269
+ } catch (e) {
270
+ if (e.code && e.message && e.statusCode) {
271
+ error(`[${e.code}] ${e.message} (HTTP ${e.statusCode})`);
272
+ } else {
273
+ error(e.message || String(e));
274
+ }
275
+ }
276
+ }
277
+ main();
package/dist/cli.js ADDED
@@ -0,0 +1,426 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ ArisPay,
4
+ bold,
5
+ cmdAgents,
6
+ cmdPay,
7
+ cmdPaymentGet,
8
+ cmdStatus,
9
+ cmdTransactions,
10
+ cmdUsers,
11
+ cmdWebhooks,
12
+ configFile,
13
+ createBrand,
14
+ cyan,
15
+ dim,
16
+ error,
17
+ getVersion,
18
+ loadConfig,
19
+ parseFlags,
20
+ prompt,
21
+ promptSecret,
22
+ saveConfig,
23
+ success,
24
+ table
25
+ } from "./chunk-4ON4ZXR3.js";
26
+
27
+ // src/cli.ts
28
+ import { readFileSync, existsSync } from "fs";
29
+ var BRAND = createBrand("arispay", "arispay init");
30
+ async function cmdInit(args) {
31
+ const { flags } = parseFlags(args);
32
+ const file = configFile(BRAND);
33
+ console.log(`
34
+ ${bold("ArisPay CLI Setup")}
35
+ `);
36
+ console.log(` ${dim("Get your API key from the ArisPay dashboard:")}`);
37
+ console.log(` ${dim("\u2192 Dashboard \u2192 API Keys \u2192 Create Key")}
38
+ `);
39
+ const existing = existsSync(file) ? JSON.parse(readFileSync(file, "utf-8")) : {};
40
+ const apiKey = flags["api-key"] || await promptSecret(` API key${existing.apiKey ? ` ${dim(`[${existing.apiKey.slice(0, 12)}...]`)}` : ""}: `);
41
+ if (!apiKey && !existing.apiKey) error("API key is required");
42
+ console.log(`
43
+ ${dim("Choose your environment:")}`);
44
+ console.log(` ${dim(" sandbox \u2014 Test payments, no real money (recommended to start)")}`);
45
+ console.log(` ${dim(" production \u2014 Live payments via Fiserv")}
46
+ `);
47
+ const envChoice = flags["env"] || await prompt(` Environment ${dim(`[${existing.environment || "sandbox"}]`)}: `);
48
+ const baseUrl = flags["base-url"] || void 0;
49
+ const config = {
50
+ apiKey: apiKey || existing.apiKey,
51
+ environment: envChoice || existing.environment || "sandbox",
52
+ ...baseUrl ? { baseUrl } : {}
53
+ };
54
+ saveConfig(BRAND, config);
55
+ try {
56
+ const client = ArisPay.init({
57
+ apiKey: config.apiKey,
58
+ environment: config.environment,
59
+ baseUrl: config.baseUrl
60
+ });
61
+ await client.transactions?.list?.({ limit: 1 }).catch(() => {
62
+ });
63
+ console.log();
64
+ success("Connected to ArisPay API");
65
+ } catch {
66
+ console.log();
67
+ console.log(` ${dim("Could not connect \u2014 check your API key and try again.")}`);
68
+ }
69
+ await postInitMenu(config);
70
+ }
71
+ async function postInitMenu(config) {
72
+ const client = ArisPay.init({
73
+ apiKey: config.apiKey,
74
+ environment: config.environment,
75
+ baseUrl: config.baseUrl
76
+ });
77
+ while (true) {
78
+ console.log(`
79
+ ${bold("Get started")}
80
+ `);
81
+ console.log(` ${cyan("[1]")} Connect your agent to ArisPay`);
82
+ console.log(` ${cyan("[2]")} Add a payment method`);
83
+ console.log(` ${cyan("[3]")} Make a test payment`);
84
+ console.log(` ${cyan("[4]")} View transactions`);
85
+ console.log(` ${cyan("[q]")} Quit
86
+ `);
87
+ const choice = await prompt(" Enter choice: ");
88
+ switch (choice) {
89
+ case "1":
90
+ await wizardConnectAgent(client);
91
+ break;
92
+ case "2":
93
+ await wizardAddPaymentMethod(client);
94
+ break;
95
+ case "3":
96
+ await wizardTestPayment(client);
97
+ break;
98
+ case "4":
99
+ await wizardTransactions(client);
100
+ break;
101
+ case "q":
102
+ case "quit":
103
+ case "exit":
104
+ console.log(`
105
+ ${dim("Run")} ${bold("arispay --help")} ${dim("to see all commands.")}
106
+ `);
107
+ return;
108
+ default:
109
+ console.log(` ${dim("Enter 1, 2, 3, 4, or q")}`);
110
+ }
111
+ }
112
+ }
113
+ async function wizardConnectAgent(client) {
114
+ console.log(`
115
+ ${bold("Connect your agent to ArisPay")}`);
116
+ console.log(` ${dim("Register your existing AI agent so it can send and receive payments.")}`);
117
+ console.log(` ${dim("This gives your agent a cryptographic identity on the ArisPay network.")}
118
+ `);
119
+ const name = await prompt(` What is your agent called? `);
120
+ if (!name) {
121
+ console.log(dim(" Cancelled."));
122
+ return;
123
+ }
124
+ console.log(`
125
+ ${dim("How does your agent make payments?")}`);
126
+ console.log(` ${dim(" platform \u2014 Your app triggers payments on behalf of the agent (default)")}`);
127
+ console.log(` ${dim(" autonomous \u2014 The agent decides when to pay, within spend limits you set")}
128
+ `);
129
+ const modeInput = await prompt(` Mode ${dim("[platform]")}: `);
130
+ const mode = modeInput === "autonomous" ? "autonomous" : "platform";
131
+ console.log(`
132
+ ${dim("Connecting agent...")}`);
133
+ try {
134
+ const agent = await client.agents.register({
135
+ name,
136
+ mode,
137
+ permissions: ["browse", "payment"]
138
+ });
139
+ const a = agent;
140
+ const config = loadConfig(BRAND);
141
+ saveConfig(BRAND, { ...config, agentId: a.id });
142
+ console.log();
143
+ success(`Agent connected!
144
+ `);
145
+ console.log(` ${bold("Agent ID:")} ${a.id}`);
146
+ console.log(` ${bold("Name:")} ${a.name}`);
147
+ console.log(` ${bold("Mode:")} ${a.mode || mode}`);
148
+ console.log(` ${bold("Status:")} ${a.status}
149
+ `);
150
+ } catch (e) {
151
+ console.log();
152
+ console.error(` \x1B[31m\u2717\x1B[0m ${e.message || "Failed to connect agent"}`);
153
+ }
154
+ }
155
+ async function wizardAddPaymentMethod(client) {
156
+ console.log(`
157
+ ${bold("Add a payment method")}`);
158
+ console.log(` ${dim("Before your agent can spend, you need a funding source.")}
159
+ `);
160
+ const config = loadConfig(BRAND);
161
+ let userId = config.endUserId;
162
+ if (!userId) {
163
+ const email = await prompt(` Your email ${dim("(for payment receipts)")}: `);
164
+ console.log(`
165
+ ${dim("Setting up your account...")}`);
166
+ try {
167
+ const user = await client.users.create({
168
+ externalId: `cli_${Date.now()}`,
169
+ email: email || void 0
170
+ });
171
+ userId = user.id;
172
+ saveConfig(BRAND, { ...config, endUserId: userId });
173
+ success("Account ready");
174
+ } catch (e) {
175
+ console.log();
176
+ console.error(` \x1B[31m\u2717\x1B[0m ${e.message || "Failed to set up account"}`);
177
+ return;
178
+ }
179
+ }
180
+ console.log(`
181
+ ${dim("How would you like to fund your agent?")}
182
+ `);
183
+ console.log(` ${cyan("[1]")} Card ${dim("\u2014 Visa, Mastercard")}`);
184
+ console.log(` ${cyan("[2]")} Crypto wallet ${dim("\u2014 USDC on Ethereum, Base, Polygon, or Solana")}
185
+ `);
186
+ const methodChoice = await prompt(` Enter choice: `);
187
+ if (methodChoice === "1") {
188
+ console.log(`
189
+ ${dim("Starting card setup...")}`);
190
+ try {
191
+ const result = await client.users.addPaymentMethod({
192
+ userId,
193
+ type: "card",
194
+ returnUrl: "https://app.arispay.app/card-setup/complete"
195
+ });
196
+ const r = result;
197
+ console.log();
198
+ success(`Card setup ready!
199
+ `);
200
+ console.log(` ${bold("Open this URL to securely enter your card details:")}
201
+ `);
202
+ console.log(` ${cyan(r.setupUrl)}
203
+ `);
204
+ console.log(` ${dim("Your card is tokenized \u2014 ArisPay never sees or stores the full number.")}
205
+ `);
206
+ } catch (e) {
207
+ console.log();
208
+ console.error(` \x1B[31m\u2717\x1B[0m ${e.message || "Failed to start card setup"}`);
209
+ }
210
+ } else if (methodChoice === "2") {
211
+ console.log();
212
+ const chain = await prompt(` Chain ${dim("(ethereum, base, polygon, solana)")}: `);
213
+ if (!chain) {
214
+ console.log(dim(" Cancelled."));
215
+ return;
216
+ }
217
+ const address = await prompt(` Wallet address: `);
218
+ if (!address) {
219
+ console.log(dim(" Cancelled."));
220
+ return;
221
+ }
222
+ console.log(`
223
+ ${dim("Registering wallet...")}`);
224
+ try {
225
+ const result = await client.users.addPaymentMethod({
226
+ userId,
227
+ type: "wallet",
228
+ walletAddress: address,
229
+ chain
230
+ });
231
+ const r = result;
232
+ console.log();
233
+ success(`Wallet registered!
234
+ `);
235
+ console.log(` ${bold("Next step:")} Approve ArisPay to spend USDC from your wallet.
236
+ `);
237
+ console.log(` ${bold("Spender:")} ${r.spenderAddress}`);
238
+ console.log(` ${bold("USDC:")} ${r.usdcContractAddress}`);
239
+ console.log(`
240
+ ${dim("Call approve() on the USDC contract with the spender address above.")}
241
+ `);
242
+ } catch (e) {
243
+ console.log();
244
+ console.error(` \x1B[31m\u2717\x1B[0m ${e.message || "Failed to register wallet"}`);
245
+ }
246
+ } else {
247
+ console.log(dim(" Cancelled."));
248
+ }
249
+ }
250
+ async function wizardTestPayment(client) {
251
+ console.log(`
252
+ ${bold("Make a test payment")}`);
253
+ console.log(` ${dim("Verify your integration works by sending a test payment.")}
254
+ `);
255
+ const config = loadConfig(BRAND);
256
+ const storedAgentId = config.agentId;
257
+ let agentId;
258
+ if (storedAgentId) {
259
+ const useStored = await prompt(` Use agent ${dim(storedAgentId.slice(0, 12) + "...")}? ${dim("(Y/n)")}: `);
260
+ if (useStored.toLowerCase() === "n") {
261
+ agentId = await prompt(` Agent ID: `);
262
+ if (!agentId) {
263
+ console.log(dim(" Cancelled."));
264
+ return;
265
+ }
266
+ } else {
267
+ agentId = storedAgentId;
268
+ }
269
+ } else {
270
+ agentId = await prompt(` Agent ID: `);
271
+ if (!agentId) {
272
+ console.log(dim(" Cancelled."));
273
+ return;
274
+ }
275
+ }
276
+ const amountStr = await prompt(` Amount in cents ${dim("(e.g. 500 = $5.00)")}: `);
277
+ const amount = Number(amountStr);
278
+ if (!amount || isNaN(amount)) {
279
+ console.log(dim(" Invalid amount. Cancelled."));
280
+ return;
281
+ }
282
+ const memo = await prompt(` What is this payment for? `);
283
+ if (!memo) {
284
+ console.log(dim(" Cancelled."));
285
+ return;
286
+ }
287
+ console.log(`
288
+ ${dim(`Sending $${(amount / 100).toFixed(2)} test payment...`)}`);
289
+ try {
290
+ const payment = await client.payments.create({
291
+ agentId,
292
+ amount,
293
+ currency: "USD",
294
+ memo,
295
+ idempotencyKey: `cli_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`
296
+ });
297
+ const p = payment;
298
+ console.log();
299
+ if (p.status === "succeeded") {
300
+ success(`Payment successful!
301
+ `);
302
+ } else {
303
+ console.log(` ${bold("Status:")} ${p.status}
304
+ `);
305
+ }
306
+ console.log(` ${bold("Payment ID:")} ${p.id}`);
307
+ console.log(` ${bold("Amount:")} $${(amount / 100).toFixed(2)} USD`);
308
+ console.log(` ${bold("Status:")} ${p.status}`);
309
+ console.log();
310
+ } catch (e) {
311
+ console.log();
312
+ console.error(` \x1B[31m\u2717\x1B[0m ${e.message || "Payment failed"}`);
313
+ }
314
+ }
315
+ async function wizardTransactions(client) {
316
+ console.log(`
317
+ ${bold("Recent Transactions")}
318
+ `);
319
+ try {
320
+ const result = await client.transactions.list({ limit: 10 });
321
+ const payments = result.payments ?? result.transactions ?? [];
322
+ if (payments.length === 0) {
323
+ console.log(` ${dim("No transactions yet. Connect an agent and make a test payment to get started.")}
324
+ `);
325
+ return;
326
+ }
327
+ table(
328
+ payments.map((p) => ({
329
+ id: p.id.slice(0, 12) + "\u2026",
330
+ amount: "$" + (p.amount / 100).toFixed(2),
331
+ status: p.status,
332
+ memo: (p.memo || "").slice(0, 25),
333
+ date: p.createdAt?.slice(0, 10)
334
+ }))
335
+ );
336
+ console.log();
337
+ } catch (e) {
338
+ console.error(` \x1B[31m\u2717\x1B[0m ${e.message || "Failed to fetch transactions"}`);
339
+ }
340
+ }
341
+ var HELP = `
342
+ ${bold("arispay")} \u2014 Agentic payment infrastructure CLI
343
+
344
+ ${bold("Usage:")}
345
+ arispay <command> [options]
346
+
347
+ ${bold("Commands:")}
348
+ ${cyan("init")} Configure API key & environment
349
+ ${cyan("status")} Show config & connection status
350
+ ${cyan("agents")} Manage AI payment agents
351
+ ${cyan("users")} Manage end users & payment methods
352
+ ${cyan("pay")} Create a payment
353
+ ${cyan("payment <id>")} Get payment details
354
+ ${cyan("transactions")} List transactions
355
+ ${cyan("webhooks")} Manage webhook endpoints
356
+
357
+ ${bold("Examples:")}
358
+ arispay init
359
+ arispay agents create --name "BookingBot" --mode autonomous
360
+ arispay agents list
361
+ arispay pay --agent <id> --amount 2000 --memo "Dinner for 2"
362
+ arispay transactions --agent <id> --from 2025-01-01
363
+
364
+ ${bold("Environment:")}
365
+ ARISPAY_API_KEY Override API key
366
+ ARISPAY_ENV Override environment (sandbox|production)
367
+ ARISPAY_BASE_URL Override API base URL
368
+
369
+ ${bold("Config:")} ~/.arispay/config.json
370
+ `;
371
+ async function main() {
372
+ const args = process.argv.slice(2);
373
+ const command = args[0];
374
+ const rest = args.slice(1);
375
+ if (!command || command === "help" || command === "--help" || command === "-h") {
376
+ console.log(HELP);
377
+ return;
378
+ }
379
+ if (command === "--version" || command === "-v") {
380
+ console.log(getVersion());
381
+ return;
382
+ }
383
+ try {
384
+ switch (command) {
385
+ case "init":
386
+ await cmdInit(rest);
387
+ break;
388
+ case "status":
389
+ await cmdStatus(BRAND);
390
+ break;
391
+ case "agents":
392
+ case "agent":
393
+ await cmdAgents(rest, BRAND);
394
+ break;
395
+ case "users":
396
+ case "user":
397
+ await cmdUsers(rest, BRAND);
398
+ break;
399
+ case "pay":
400
+ await cmdPay(rest, BRAND);
401
+ break;
402
+ case "payment":
403
+ await cmdPaymentGet(rest, BRAND);
404
+ break;
405
+ case "transactions":
406
+ case "txs":
407
+ await cmdTransactions(rest, BRAND);
408
+ break;
409
+ case "webhooks":
410
+ case "webhook":
411
+ await cmdWebhooks(rest, BRAND);
412
+ break;
413
+ default:
414
+ console.error(`Unknown command: ${command}`);
415
+ console.log(HELP);
416
+ process.exit(1);
417
+ }
418
+ } catch (e) {
419
+ if (e.code && e.message && e.statusCode) {
420
+ error(`[${e.code}] ${e.message} (HTTP ${e.statusCode})`);
421
+ } else {
422
+ error(e.message || String(e));
423
+ }
424
+ }
425
+ }
426
+ main();