valta-sdk 2.1.6 → 2.1.8

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/valta.js CHANGED
@@ -6,7 +6,7 @@ import { fileURLToPath } from 'url';
6
6
  const __filename = fileURLToPath(import.meta.url);
7
7
  const __dirname = dirname(__filename);
8
8
 
9
- const cliPath = join(__dirname, '..', 'dist', 'cli', 'index.mjs');
9
+ const cliPath = join(__dirname, '..', 'dist', 'cli', 'index.js');
10
10
 
11
11
  import(pathToFileURL(cliPath).href).catch((err) => {
12
12
  console.error('Valta CLI failed to start:', err.message);
@@ -92,11 +92,11 @@ async function loginCommand() {
92
92
  }
93
93
  const tier = data.tier || "free";
94
94
  if (data.hasExistingKey) {
95
- saveConfig({ apiKey: "", email: data.email, tier });
95
+ saveConfig({ apiKey: data.apiKey, email: data.email, tier });
96
96
  console.log(`
97
97
  \u2714 Authenticated as ${data.email} (${tier} tier)`);
98
- console.log(` You already have an API key (${data.apiKeyPrefix}...)`);
99
- console.log(" Run: valta keys create [name] to generate a new key\n");
98
+ console.log(` API Key: ${data.apiKey}`);
99
+ console.log(" (Saved automatically \u2014 shown once)\n");
100
100
  } else {
101
101
  saveConfig({ apiKey: data.apiKey, email: data.email, tier });
102
102
  console.log(`
@@ -395,6 +395,20 @@ async function agentsFreezeCommand(agentId) {
395
395
  process.exit(1);
396
396
  }
397
397
  }
398
+ async function agentsUnfreezeCommand(agentId) {
399
+ const client = getClient();
400
+ try {
401
+ await client.agents.unfreeze(agentId);
402
+ console.log(`
403
+ \u2714 Agent ${agentId} unfrozen.
404
+ `);
405
+ } catch (err) {
406
+ console.error(`
407
+ \u2716 ${err instanceof Error ? err.message : "Unknown error"}
408
+ `);
409
+ process.exit(1);
410
+ }
411
+ }
398
412
 
399
413
  // src/cli/commands/keys.ts
400
414
  function getClient2() {
@@ -462,6 +476,114 @@ async function keysRevokeCommand(keyId) {
462
476
  }
463
477
  }
464
478
 
479
+ // src/cli/commands/wallet.ts
480
+ var BASE_URL2 = "https://valta.co/api/v1";
481
+ function getKey() {
482
+ const key = getApiKey();
483
+ if (!key) {
484
+ console.error("\n \u2716 Not logged in. Run: valta login\n");
485
+ process.exit(1);
486
+ }
487
+ return key;
488
+ }
489
+ async function walletCommand() {
490
+ const apiKey = getKey();
491
+ try {
492
+ const res = await fetch(`${BASE_URL2}/wallet`, {
493
+ headers: { "x-api-key": apiKey }
494
+ });
495
+ const data = await res.json();
496
+ if (!res.ok || !data.success) {
497
+ console.error(`
498
+ \u2716 ${data.error || "Failed to fetch wallet"}
499
+ `);
500
+ process.exit(1);
501
+ }
502
+ const m = data.mainWallet;
503
+ const a = data.agentWallet;
504
+ console.log("\n \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");
505
+ console.log(" \u2502 Your Wallets \u2502");
506
+ console.log(" \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
507
+ console.log(` \u2502 Main Wallet \u2502`);
508
+ console.log(` \u2502 Balance: $${String(m.balance.toFixed(2)).padEnd(23)} \u2502`);
509
+ console.log(` \u2502 Locked: $${String(m.lockedBalance.toFixed(2)).padEnd(23)} \u2502`);
510
+ console.log(` \u2502 Currency: ${String(m.currency).padEnd(24)} \u2502`);
511
+ console.log(` \u2502 Mode: ${String(m.mode).padEnd(24)} \u2502`);
512
+ console.log(" \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
513
+ console.log(` \u2502 Agent Wallet \u2502`);
514
+ console.log(` \u2502 Balance: $${String(Number(a.balance).toFixed(2)).padEnd(23)} \u2502`);
515
+ console.log(` \u2502 Used for per-message chat costs \u2502`);
516
+ console.log(" \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n");
517
+ } catch {
518
+ console.error("\n \u2716 Could not connect to Valta.\n");
519
+ process.exit(1);
520
+ }
521
+ }
522
+ async function walletAgentBalanceCommand(agentId) {
523
+ if (!agentId) {
524
+ console.error("\n \u2716 Agent ID required. Usage: valta wallet agent [agentId]\n");
525
+ process.exit(1);
526
+ }
527
+ const apiKey = getKey();
528
+ try {
529
+ const res = await fetch(`${BASE_URL2}/agents/${agentId}/wallet`, {
530
+ headers: { "x-api-key": apiKey }
531
+ });
532
+ const data = await res.json();
533
+ if (!res.ok || !data.success) {
534
+ console.error(`
535
+ \u2716 ${data.error || "Failed to fetch agent wallet"}
536
+ `);
537
+ process.exit(1);
538
+ }
539
+ const w = data.wallet;
540
+ console.log(`
541
+ Custom Agent Wallet \u2014 ${agentId}`);
542
+ console.log(` \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
543
+ console.log(` Balance: ${w.usdc} USDC`);
544
+ console.log(` Pending: ${w.usdcPending} USDC`);
545
+ console.log(` Status: ${w.status}
546
+ `);
547
+ } catch {
548
+ console.error("\n \u2716 Could not connect to Valta.\n");
549
+ process.exit(1);
550
+ }
551
+ }
552
+
553
+ // src/cli/commands/audit.ts
554
+ function getClient3() {
555
+ const apiKey = getApiKey();
556
+ if (!apiKey) {
557
+ console.error("\n \u2716 Not logged in. Run: valta login\n");
558
+ process.exit(1);
559
+ }
560
+ return new ValtaClient(apiKey);
561
+ }
562
+ async function auditCommand(agentId) {
563
+ const client = getClient3();
564
+ try {
565
+ const { logs } = await client.audit.list({ agentId, limit: 20 });
566
+ if (!logs.length) {
567
+ console.log("\n No audit logs found.\n");
568
+ return;
569
+ }
570
+ console.log("\n TIME ACTION AGENT");
571
+ console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
572
+ for (const log of logs) {
573
+ const time = new Date(log.createdAt).toLocaleString().padEnd(24);
574
+ const action = (log.action || "").padEnd(19);
575
+ const agent = log.agentId || "";
576
+ console.log(` ${time} ${action} ${agent}`);
577
+ }
578
+ console.log();
579
+ } catch (err) {
580
+ console.error(`
581
+ \u2716 ${err instanceof Error ? err.message : "Unknown error"}
582
+ `);
583
+ process.exit(1);
584
+ }
585
+ }
586
+
465
587
  // src/cli/index.ts
466
588
  var [, , command, sub, ...args] = process.argv;
467
589
  async function main() {
@@ -489,10 +611,24 @@ async function main() {
489
611
  await agentsListCommand();
490
612
  } else if (sub === "freeze" && args[0]) {
491
613
  await agentsFreezeCommand(args[0]);
614
+ } else if (sub === "unfreeze" && args[0]) {
615
+ await agentsUnfreezeCommand(args[0]);
492
616
  } else {
493
617
  console.log("\n Usage:");
494
618
  console.log(" valta agents list");
495
- console.log(" valta agents freeze [id]\n");
619
+ console.log(" valta agents freeze [id]");
620
+ console.log(" valta agents unfreeze [id]\n");
621
+ }
622
+ break;
623
+ case "wallet":
624
+ if (!sub || sub === "balance") {
625
+ await walletCommand();
626
+ } else if (sub === "agent" && args[0]) {
627
+ await walletAgentBalanceCommand(args[0]);
628
+ } else {
629
+ console.log("\n Usage:");
630
+ console.log(" valta wallet Show main + agent wallet balances");
631
+ console.log(" valta wallet agent [agentId] Show custom agent wallet balance\n");
496
632
  }
497
633
  break;
498
634
  case "keys":
@@ -509,21 +645,30 @@ async function main() {
509
645
  console.log(" valta keys revoke [id]\n");
510
646
  }
511
647
  break;
648
+ case "audit":
649
+ await auditCommand(sub);
650
+ break;
512
651
  default:
513
652
  console.log(`
514
653
  Valta CLI
515
654
 
516
655
  Commands:
517
- valta login Authenticate with email + password
518
- valta logout Clear credentials
519
- valta whoami Show current user
656
+ valta login Authenticate with email + password
657
+ valta logout Clear credentials
658
+ valta whoami Show current user
659
+
660
+ valta agents list List all your agents
661
+ valta agents freeze [id] Freeze an agent
662
+ valta agents unfreeze [id] Unfreeze an agent
663
+
664
+ valta wallet Show main wallet + agent wallet balances
665
+ valta wallet agent [agentId] Show custom agent wallet balance
520
666
 
521
- valta agents list List all agents
522
- valta agents freeze [id] Freeze an agent
667
+ valta keys list List API keys
668
+ valta keys create [name] Generate a new API key
669
+ valta keys revoke [id] Revoke a key
523
670
 
524
- valta keys list List API keys
525
- valta keys create [name] Generate a new API key
526
- valta keys revoke [id] Revoke a key
671
+ valta audit [agentId] Show audit log
527
672
  `);
528
673
  }
529
674
  }
package/dist/cli/index.js CHANGED
@@ -94,11 +94,11 @@ async function loginCommand() {
94
94
  }
95
95
  const tier = data.tier || "free";
96
96
  if (data.hasExistingKey) {
97
- saveConfig({ apiKey: "", email: data.email, tier });
97
+ saveConfig({ apiKey: data.apiKey, email: data.email, tier });
98
98
  console.log(`
99
99
  \u2714 Authenticated as ${data.email} (${tier} tier)`);
100
- console.log(` You already have an API key (${data.apiKeyPrefix}...)`);
101
- console.log(" Run: valta keys create [name] to generate a new key\n");
100
+ console.log(` API Key: ${data.apiKey}`);
101
+ console.log(" (Saved automatically \u2014 shown once)\n");
102
102
  } else {
103
103
  saveConfig({ apiKey: data.apiKey, email: data.email, tier });
104
104
  console.log(`
@@ -161,6 +161,20 @@ async function agentsFreezeCommand(agentId) {
161
161
  process.exit(1);
162
162
  }
163
163
  }
164
+ async function agentsUnfreezeCommand(agentId) {
165
+ const client = getClient();
166
+ try {
167
+ await client.agents.unfreeze(agentId);
168
+ console.log(`
169
+ \u2714 Agent ${agentId} unfrozen.
170
+ `);
171
+ } catch (err) {
172
+ console.error(`
173
+ \u2716 ${err instanceof Error ? err.message : "Unknown error"}
174
+ `);
175
+ process.exit(1);
176
+ }
177
+ }
164
178
 
165
179
  // src/cli/commands/keys.ts
166
180
  function getClient2() {
@@ -228,6 +242,114 @@ async function keysRevokeCommand(keyId) {
228
242
  }
229
243
  }
230
244
 
245
+ // src/cli/commands/wallet.ts
246
+ var BASE_URL2 = "https://valta.co/api/v1";
247
+ function getKey() {
248
+ const key = getApiKey();
249
+ if (!key) {
250
+ console.error("\n \u2716 Not logged in. Run: valta login\n");
251
+ process.exit(1);
252
+ }
253
+ return key;
254
+ }
255
+ async function walletCommand() {
256
+ const apiKey = getKey();
257
+ try {
258
+ const res = await fetch(`${BASE_URL2}/wallet`, {
259
+ headers: { "x-api-key": apiKey }
260
+ });
261
+ const data = await res.json();
262
+ if (!res.ok || !data.success) {
263
+ console.error(`
264
+ \u2716 ${data.error || "Failed to fetch wallet"}
265
+ `);
266
+ process.exit(1);
267
+ }
268
+ const m = data.mainWallet;
269
+ const a = data.agentWallet;
270
+ console.log("\n \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");
271
+ console.log(" \u2502 Your Wallets \u2502");
272
+ console.log(" \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
273
+ console.log(` \u2502 Main Wallet \u2502`);
274
+ console.log(` \u2502 Balance: $${String(m.balance.toFixed(2)).padEnd(23)} \u2502`);
275
+ console.log(` \u2502 Locked: $${String(m.lockedBalance.toFixed(2)).padEnd(23)} \u2502`);
276
+ console.log(` \u2502 Currency: ${String(m.currency).padEnd(24)} \u2502`);
277
+ console.log(` \u2502 Mode: ${String(m.mode).padEnd(24)} \u2502`);
278
+ console.log(" \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
279
+ console.log(` \u2502 Agent Wallet \u2502`);
280
+ console.log(` \u2502 Balance: $${String(Number(a.balance).toFixed(2)).padEnd(23)} \u2502`);
281
+ console.log(` \u2502 Used for per-message chat costs \u2502`);
282
+ console.log(" \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n");
283
+ } catch {
284
+ console.error("\n \u2716 Could not connect to Valta.\n");
285
+ process.exit(1);
286
+ }
287
+ }
288
+ async function walletAgentBalanceCommand(agentId) {
289
+ if (!agentId) {
290
+ console.error("\n \u2716 Agent ID required. Usage: valta wallet agent [agentId]\n");
291
+ process.exit(1);
292
+ }
293
+ const apiKey = getKey();
294
+ try {
295
+ const res = await fetch(`${BASE_URL2}/agents/${agentId}/wallet`, {
296
+ headers: { "x-api-key": apiKey }
297
+ });
298
+ const data = await res.json();
299
+ if (!res.ok || !data.success) {
300
+ console.error(`
301
+ \u2716 ${data.error || "Failed to fetch agent wallet"}
302
+ `);
303
+ process.exit(1);
304
+ }
305
+ const w = data.wallet;
306
+ console.log(`
307
+ Custom Agent Wallet \u2014 ${agentId}`);
308
+ console.log(` \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
309
+ console.log(` Balance: ${w.usdc} USDC`);
310
+ console.log(` Pending: ${w.usdcPending} USDC`);
311
+ console.log(` Status: ${w.status}
312
+ `);
313
+ } catch {
314
+ console.error("\n \u2716 Could not connect to Valta.\n");
315
+ process.exit(1);
316
+ }
317
+ }
318
+
319
+ // src/cli/commands/audit.ts
320
+ function getClient3() {
321
+ const apiKey = getApiKey();
322
+ if (!apiKey) {
323
+ console.error("\n \u2716 Not logged in. Run: valta login\n");
324
+ process.exit(1);
325
+ }
326
+ return new ValtaClient(apiKey);
327
+ }
328
+ async function auditCommand(agentId) {
329
+ const client = getClient3();
330
+ try {
331
+ const { logs } = await client.audit.list({ agentId, limit: 20 });
332
+ if (!logs.length) {
333
+ console.log("\n No audit logs found.\n");
334
+ return;
335
+ }
336
+ console.log("\n TIME ACTION AGENT");
337
+ console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
338
+ for (const log of logs) {
339
+ const time = new Date(log.createdAt).toLocaleString().padEnd(24);
340
+ const action = (log.action || "").padEnd(19);
341
+ const agent = log.agentId || "";
342
+ console.log(` ${time} ${action} ${agent}`);
343
+ }
344
+ console.log();
345
+ } catch (err) {
346
+ console.error(`
347
+ \u2716 ${err instanceof Error ? err.message : "Unknown error"}
348
+ `);
349
+ process.exit(1);
350
+ }
351
+ }
352
+
231
353
  // src/cli/index.ts
232
354
  var [, , command, sub, ...args] = process.argv;
233
355
  async function main() {
@@ -255,10 +377,24 @@ async function main() {
255
377
  await agentsListCommand();
256
378
  } else if (sub === "freeze" && args[0]) {
257
379
  await agentsFreezeCommand(args[0]);
380
+ } else if (sub === "unfreeze" && args[0]) {
381
+ await agentsUnfreezeCommand(args[0]);
258
382
  } else {
259
383
  console.log("\n Usage:");
260
384
  console.log(" valta agents list");
261
- console.log(" valta agents freeze [id]\n");
385
+ console.log(" valta agents freeze [id]");
386
+ console.log(" valta agents unfreeze [id]\n");
387
+ }
388
+ break;
389
+ case "wallet":
390
+ if (!sub || sub === "balance") {
391
+ await walletCommand();
392
+ } else if (sub === "agent" && args[0]) {
393
+ await walletAgentBalanceCommand(args[0]);
394
+ } else {
395
+ console.log("\n Usage:");
396
+ console.log(" valta wallet Show main + agent wallet balances");
397
+ console.log(" valta wallet agent [agentId] Show custom agent wallet balance\n");
262
398
  }
263
399
  break;
264
400
  case "keys":
@@ -275,21 +411,30 @@ async function main() {
275
411
  console.log(" valta keys revoke [id]\n");
276
412
  }
277
413
  break;
414
+ case "audit":
415
+ await auditCommand(sub);
416
+ break;
278
417
  default:
279
418
  console.log(`
280
419
  Valta CLI
281
420
 
282
421
  Commands:
283
- valta login Authenticate with email + password
284
- valta logout Clear credentials
285
- valta whoami Show current user
422
+ valta login Authenticate with email + password
423
+ valta logout Clear credentials
424
+ valta whoami Show current user
425
+
426
+ valta agents list List all your agents
427
+ valta agents freeze [id] Freeze an agent
428
+ valta agents unfreeze [id] Unfreeze an agent
429
+
430
+ valta wallet Show main wallet + agent wallet balances
431
+ valta wallet agent [agentId] Show custom agent wallet balance
286
432
 
287
- valta agents list List all agents
288
- valta agents freeze [id] Freeze an agent
433
+ valta keys list List API keys
434
+ valta keys create [name] Generate a new API key
435
+ valta keys revoke [id] Revoke a key
289
436
 
290
- valta keys list List API keys
291
- valta keys create [name] Generate a new API key
292
- valta keys revoke [id] Revoke a key
437
+ valta audit [agentId] Show audit log
293
438
  `);
294
439
  }
295
440
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valta-sdk",
3
- "version": "2.1.6",
3
+ "version": "2.1.8",
4
4
  "description": "Official SDK for Valta — AI agent financial infrastructure",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -14,8 +14,8 @@
14
14
  }
15
15
  },
16
16
  "bin": {
17
- "valta": "./bin/valta.js"
18
- },
17
+ "valta": "bin/valta.js"
18
+ },
19
19
  "files": [
20
20
  "dist",
21
21
  "bin"