valta-sdk 2.1.7 → 2.2.2

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/index.js CHANGED
@@ -1,299 +1,97 @@
1
- import {
2
- ValtaClient
3
- } from "../chunk-LBY67QV7.js";
4
-
5
- // src/cli/commands/login.ts
6
- import { createInterface } from "readline";
7
-
8
- // src/cli/config.ts
9
- import { homedir } from "os";
10
- import { join } from "path";
11
- import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
12
- var CONFIG_DIR = join(homedir(), ".valta");
13
- var CONFIG_FILE = join(CONFIG_DIR, "config.json");
14
- function saveConfig(config) {
15
- if (!existsSync(CONFIG_DIR)) mkdirSync(CONFIG_DIR, { recursive: true });
16
- writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
17
- }
18
- function loadConfig() {
19
- if (!existsSync(CONFIG_FILE)) return null;
20
- try {
21
- return JSON.parse(readFileSync(CONFIG_FILE, "utf-8"));
22
- } catch {
23
- return null;
24
- }
25
- }
26
- function clearConfig() {
27
- if (existsSync(CONFIG_FILE)) writeFileSync(CONFIG_FILE, "{}");
28
- }
29
- function getApiKey() {
30
- return loadConfig()?.apiKey ?? null;
31
- }
32
-
33
- // src/cli/commands/login.ts
34
- var BASE_URL = "https://valta.co/api/v1";
35
- function prompt(question, hidden = false) {
36
- const rl = createInterface({ input: process.stdin, output: process.stdout });
37
- return new Promise((resolve) => {
38
- if (hidden) {
39
- process.stdout.write(question);
40
- process.stdin.setRawMode?.(true);
41
- let input = "";
42
- process.stdin.resume();
43
- process.stdin.setEncoding("utf8");
44
- process.stdin.on("data", function handler(char) {
45
- if (char === "\n" || char === "\r" || char === "") {
46
- process.stdin.setRawMode?.(false);
47
- process.stdin.pause();
48
- process.stdin.removeListener("data", handler);
49
- process.stdout.write("\n");
50
- rl.close();
51
- resolve(input);
52
- } else if (char === "") {
53
- process.exit();
54
- } else if (char === "\x7F") {
55
- if (input.length > 0) {
56
- input = input.slice(0, -1);
57
- process.stdout.clearLine?.(0);
58
- process.stdout.cursorTo?.(0);
59
- process.stdout.write(question + "\u2022".repeat(input.length));
60
- }
61
- } else {
62
- input += char;
63
- process.stdout.write("\u2022");
64
- }
65
- });
66
- } else {
67
- rl.question(question, (answer) => {
68
- rl.close();
69
- resolve(answer.trim());
70
- });
71
- }
72
- });
73
- }
74
- async function loginCommand() {
75
- console.log("\n Valta Login\n");
76
- const email = await prompt(" Email: ");
77
- const password = await prompt(" Password: ", true);
78
- if (!email || !password) {
79
- console.error("\n \u2716 Email and password are required.\n");
80
- process.exit(1);
81
- }
82
- try {
83
- const res = await fetch(`${BASE_URL}/auth/login`, {
84
- method: "POST",
85
- headers: { "Content-Type": "application/json" },
86
- body: JSON.stringify({ email, password })
87
- });
88
- const data = await res.json();
89
- if (!res.ok || !data.success) {
90
- console.error(`
91
- \u2716 ${data.error || "Login failed"}
92
- `);
93
- process.exit(1);
94
- }
95
- const tier = data.tier || "free";
96
- if (data.hasExistingKey) {
97
- saveConfig({ apiKey: "", email: data.email, tier });
98
- console.log(`
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");
102
- } else {
103
- saveConfig({ apiKey: data.apiKey, email: data.email, tier });
104
- console.log(`
105
- \u2714 Authenticated as ${data.email} (${tier} tier)`);
106
- console.log(`
107
- API Key: ${data.apiKey}`);
108
- console.log(" (Saved to ~/.valta/config.json \u2014 shown once)\n");
109
- }
110
- } catch {
111
- console.error("\n \u2716 Could not connect to Valta. Check your internet connection.\n");
112
- process.exit(1);
113
- }
114
- }
115
-
116
- // src/cli/commands/agents.ts
117
- function getClient() {
118
- const apiKey = getApiKey();
119
- if (!apiKey) {
120
- console.error("\n \u2716 Not logged in. Run: valta login\n");
121
- process.exit(1);
122
- }
123
- return new ValtaClient(apiKey);
124
- }
125
- async function agentsListCommand() {
126
- const client = getClient();
127
- try {
128
- const result = await client.agents.list();
129
- const agents = result.agents;
130
- if (!agents.length) {
131
- console.log("\n No agents found. Create one at https://valta.co/dashboard\n");
132
- return;
133
- }
134
- console.log("\n ID NAME STATUS");
135
- 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\u2500\u2500\u2500");
136
- for (const agent of agents) {
137
- const id = (agent.id || "").padEnd(24);
138
- const name = (agent.name || "").padEnd(23);
139
- const status = agent.status || "";
140
- console.log(` ${id} ${name} ${status}`);
141
- }
142
- console.log();
143
- } catch (err) {
144
- console.error(`
145
- \u2716 ${err instanceof Error ? err.message : "Unknown error"}
146
- `);
147
- process.exit(1);
148
- }
149
- }
150
- async function agentsFreezeCommand(agentId) {
151
- const client = getClient();
152
- try {
153
- await client.agents.freeze(agentId);
154
- console.log(`
155
- \u2714 Agent ${agentId} frozen.
156
- `);
157
- } catch (err) {
158
- console.error(`
159
- \u2716 ${err instanceof Error ? err.message : "Unknown error"}
160
- `);
161
- process.exit(1);
162
- }
163
- }
164
-
165
- // src/cli/commands/keys.ts
166
- function getClient2() {
167
- const apiKey = getApiKey();
168
- if (!apiKey) {
169
- console.error("\n \u2716 Not logged in. Run: valta login\n");
170
- process.exit(1);
171
- }
172
- return new ValtaClient(apiKey);
173
- }
174
- async function keysListCommand() {
175
- const client = getClient2();
176
- try {
177
- const keys = await client.keys.list();
178
- if (!keys.length) {
179
- console.log("\n No API keys found.\n");
180
- return;
181
- }
182
- console.log("\n PREFIX NAME CREATED");
183
- 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");
184
- for (const key of keys) {
185
- const prefix = (key.prefix || "").padEnd(15);
186
- const name = (key.name || "").padEnd(23);
187
- const created = key.createdAt ? new Date(key.createdAt).toLocaleDateString() : "";
188
- console.log(` ${prefix} ${name} ${created}`);
189
- }
190
- console.log();
191
- } catch (err) {
192
- console.error(`
193
- \u2716 ${err instanceof Error ? err.message : "Unknown error"}
194
- `);
195
- process.exit(1);
196
- }
197
- }
198
- async function keysCreateCommand(name) {
199
- const client = getClient2();
200
- try {
201
- const result = await client.keys.create(name || "CLI Key");
202
- console.log(`
203
- \u2714 API key created`);
204
- console.log(`
205
- Key: ${result.key}`);
206
- console.log(` Name: ${result.name}`);
207
- console.log(` Tier: ${result.tier}`);
208
- console.log("\n (Shown once \u2014 copy it now and save it securely)\n");
209
- } catch (err) {
210
- console.error(`
211
- \u2716 ${err instanceof Error ? err.message : "Unknown error"}
212
- `);
213
- process.exit(1);
214
- }
215
- }
216
- async function keysRevokeCommand(keyId) {
217
- const client = getClient2();
218
- try {
219
- await client.keys.revoke(keyId);
220
- console.log(`
221
- \u2714 Key ${keyId} revoked.
222
- `);
223
- } catch (err) {
224
- console.error(`
225
- \u2716 ${err instanceof Error ? err.message : "Unknown error"}
226
- `);
227
- process.exit(1);
228
- }
229
- }
230
-
231
- // src/cli/index.ts
232
- var [, , command, sub, ...args] = process.argv;
233
- async function main() {
234
- switch (command) {
235
- case "login":
236
- await loginCommand();
237
- break;
238
- case "logout":
239
- clearConfig();
240
- console.log("\n \u2714 Logged out.\n");
241
- break;
242
- case "whoami": {
243
- const config = loadConfig();
244
- if (!config?.email) {
245
- console.log("\n Not logged in. Run: valta login\n");
246
- } else {
247
- console.log(`
248
- ${config.email} (${config.tier || "free"} tier)
249
- `);
250
- }
251
- break;
252
- }
253
- case "agents":
254
- if (!sub || sub === "list") {
255
- await agentsListCommand();
256
- } else if (sub === "freeze" && args[0]) {
257
- await agentsFreezeCommand(args[0]);
258
- } else {
259
- console.log("\n Usage:");
260
- console.log(" valta agents list");
261
- console.log(" valta agents freeze [id]\n");
262
- }
263
- break;
264
- case "keys":
265
- if (!sub || sub === "list") {
266
- await keysListCommand();
267
- } else if (sub === "create") {
268
- await keysCreateCommand(args[0] || "");
269
- } else if (sub === "revoke" && args[0]) {
270
- await keysRevokeCommand(args[0]);
271
- } else {
272
- console.log("\n Usage:");
273
- console.log(" valta keys list");
274
- console.log(" valta keys create [name]");
275
- console.log(" valta keys revoke [id]\n");
276
- }
277
- break;
278
- default:
279
- console.log(`
1
+ import {homedir}from'os';import {join}from'path';import {existsSync,readFileSync,writeFileSync,mkdirSync}from'fs';import {createInterface}from'readline';var A=class{constructor(e){this.http=e;}async login(e,n){return this.http.post("/auth/login",{email:e,password:n},false)}async logout(){await this.http.post("/auth/logout");}async whoami(){return this.http.get("/auth/whoami")}async refreshToken(){return this.http.post("/auth/refresh-token")}};var R=class{constructor(e){this.http=e;}async create(e){return this.http.post("/agents",e)}async list(e){return this.http.get("/agents",e)}async get(e){return this.http.get(`/agents/${encodeURIComponent(e)}`)}async update(e,n){return this.http.patch(`/agents/${encodeURIComponent(e)}`,n)}async delete(e){return this.http.delete(`/agents/${encodeURIComponent(e)}`)}async freeze(e){return this.http.post(`/agents/${encodeURIComponent(e)}/freeze`)}async unfreeze(e){return this.http.post(`/agents/${encodeURIComponent(e)}/unfreeze`)}async run(e,n){return this.http.post(`/agents/${encodeURIComponent(e)}/run`,n)}async getRun(e,n){return this.http.get(`/agents/${encodeURIComponent(e)}/runs/${encodeURIComponent(n)}`)}async listRuns(e,n){return this.http.get(`/agents/${encodeURIComponent(e)}/runs`,n)}};var w=class{constructor(e){this.http=e;}async list(e){return this.http.get("/audit",e)}async get(e){return this.http.get(`/audit/${encodeURIComponent(e)}`)}async export(e){let n=[],s=1,r=true;for(;r;){let l=await this.list({...e,page:s,limit:100});n.push(...l.data),r=l.pagination.hasMore,s+=1;}return n}async verify(e){return this.http.get(`/audit/verify/${encodeURIComponent(e)}`)}};var C=class{constructor(e){this.http=e;}async create(e){return this.http.post("/keys",e)}async list(){return this.http.get("/keys")}async revoke(e){return this.http.delete(`/keys/${encodeURIComponent(e)}`)}};var d=class extends Error{constructor(e){super(e.message),this.name="ValtaError",this.code=e.code,this.status=e.status??null,this.details=e.details??null;}isRateLimit(){return this.code==="RATE_LIMIT_EXCEEDED"}isAuth(){return this.code==="UNAUTHORISED"||this.code==="FORBIDDEN"}requiresApproval(){return this.code==="APPROVAL_REQUIRED"}};var I=class{constructor(e){this.http=e;}async create(e){return this.http.post("/policies",e)}async get(e){try{return await this.http.get(`/policies/${encodeURIComponent(e)}`)}catch(n){if(n instanceof d&&n.code==="NOT_FOUND")return null;throw n}}async update(e,n){return this.http.patch(`/policies/${encodeURIComponent(e)}`,n)}async delete(e){return this.http.delete(`/policies/${encodeURIComponent(e)}`)}async list(){return this.http.get("/policies")}};var P=class{constructor(e){this.http=e;}async get(e){return this.http.get(`/wallets/${encodeURIComponent(e)}`)}async getBalance(e){return (await this.get(e)).balance}async getDepositAddress(e){return this.http.get(`/wallets/${encodeURIComponent(e)}/deposit-address`)}async listTransactions(e,n){return this.http.get(`/wallets/${encodeURIComponent(e)}/transactions`,n)}async transfer(e){return this.http.post("/wallets/transfer",e)}};var x="2.2.0",T=class{constructor(e){this.apiKey=e.apiKey,this.baseUrl=(e.baseUrl??"https://valta.co/api/v1").replace(/\/$/,""),this.timeout=e.timeout??3e4;}async request(e){let n=`${this.baseUrl}${e.path}`;if(e.query){let o=new URLSearchParams;for(let[E,p]of Object.entries(e.query))p!==void 0&&o.set(E,String(p));let f=o.toString();f&&(n+=`?${f}`);}let s=new AbortController,r=setTimeout(()=>s.abort(),this.timeout),l={"Content-Type":"application/json","User-Agent":`valta-sdk/${x}`,"X-Valta-SDK":x};e.authenticated!==false&&(l["x-api-key"]=this.apiKey);try{let o=await fetch(n,{method:e.method,headers:l,body:e.body===void 0?void 0:JSON.stringify(e.body),signal:s.signal});clearTimeout(r);let f=await o.text(),E=f?ee(f,o.status):null;if(!o.ok){let p=E??{};throw new d({message:p.message??p.error??`HTTP ${o.status}`,code:te(p.code,o.status),status:o.status,details:p})}return E}catch(o){throw clearTimeout(r),o instanceof d?o:o instanceof Error&&o.name==="AbortError"?new d({message:`Request timed out after ${this.timeout}ms`,code:"TIMEOUT"}):new d({message:o instanceof Error?o.message:"An unknown network error occurred",code:"NETWORK_ERROR"})}}get(e,n){return this.request({method:"GET",path:e,query:n})}post(e,n,s=true){return this.request({method:"POST",path:e,body:n,authenticated:s})}patch(e,n){return this.request({method:"PATCH",path:e,body:n})}delete(e){return this.request({method:"DELETE",path:e})}};function ee(t,e){try{return JSON.parse(t)}catch{throw new d({message:"Invalid JSON response from server",code:"SERVER_ERROR",status:e})}}function te(t,e){let n=String(t||"").toUpperCase();if(n==="UNAUTHORIZED"||n==="API_KEY_REQUIRED"||n==="INVALID_API_KEY")return "UNAUTHORISED";if(n==="RATE_LIMIT"||n==="API_KEY_RATE_LIMITED")return "RATE_LIMIT_EXCEEDED";if(n==="TIER_LIMIT")return "TIER_LIMIT_EXCEEDED";if(ne(n))return n;switch(e){case 400:return "INVALID_REQUEST";case 401:return "UNAUTHORISED";case 403:return "FORBIDDEN";case 404:return "NOT_FOUND";case 429:return "RATE_LIMIT_EXCEEDED";default:return "SERVER_ERROR"}}function ne(t){return ["UNAUTHORISED","FORBIDDEN","NOT_FOUND","RATE_LIMIT_EXCEEDED","TIER_LIMIT_EXCEEDED","AGENT_FROZEN","POLICY_VIOLATION","INSUFFICIENT_BALANCE","APPROVAL_REQUIRED","INVALID_REQUEST","SERVER_ERROR","NETWORK_ERROR","TIMEOUT"].includes(t)}var c=class{constructor(e){let n=typeof e=="string"?{apiKey:e}:e;if(!n.apiKey)throw new Error("Valta API key is required. Get one at https://valta.co/dashboard/api-keys");this.http=new T(n),this.auth=new A(this.http),this.agents=new R(this.http),this.wallets=new P(this.http),this.policies=new I(this.http),this.audit=new w(this.http),this.keys=new C(this.http);}};var U=join(homedir(),".valta"),y=join(U,"config.json");function N(t){existsSync(U)||mkdirSync(U,{recursive:true}),writeFileSync(y,JSON.stringify(t,null,2));}function v(){if(!existsSync(y))return null;try{return JSON.parse(readFileSync(y,"utf-8"))}catch{return null}}function _(){existsSync(y)&&writeFileSync(y,"{}");}function g(){return v()?.apiKey??null}function u(){return v()}function re(){let t=g();t||(console.error(`
2
+ Not logged in. Run: valta login
3
+ `),process.exit(1));let e=u()?.baseUrl??process.env.VALTA_BASE_URL;return new c({apiKey:t,baseUrl:e})}async function S(t){let e=await re().audit.list({agentId:t,limit:20}),n=Array.isArray(e)?e:e?.data??[];if(!n.length){console.log(`
4
+ No audit entries found.
5
+ `);return}console.log(`
6
+ TIME ACTION STATUS AGENT`),console.log(" ------------------------------------------------------------------");for(let s of n){let r=new Date(s.createdAt).toLocaleString().padEnd(24);console.log(` ${r} ${s.action.padEnd(19)} ${s.status.padEnd(10)} ${s.agentId}`);}console.log();}function m(){let t=g();t||(console.error(`
7
+ Not logged in. Run: valta login
8
+ `),process.exit(1));let e=u()?.baseUrl??process.env.VALTA_BASE_URL;return new c({apiKey:t,baseUrl:e})}async function O(){let t=await m().agents.list({limit:20}),e=Array.isArray(t)?t:t?.data??[];if(!e.length){console.log(`
9
+ No agents found.
10
+ `);return}console.log(`
11
+ ID NAME STATUS BALANCE`),console.log(" -------------------------------------------------------------------");for(let n of e)console.log(` ${n.id.padEnd(24)} ${n.name.padEnd(23)} ${n.status.padEnd(11)} $${n.wallet.balance.toFixed(2)}`);console.log();}async function V(t){let e=t.join(" ").trim();e||(console.error(`
12
+ Usage: valta agents create "Agent Name"
13
+ `),process.exit(1));let n=await m().agents.create({name:e});console.log(`
14
+ Agent created: ${n.id}`),console.log(` Name: ${n.name}`),console.log(` Balance: $${n.wallet.balance.toFixed(2)}
15
+ `);}async function K(t){let e=await m().agents.get(t);console.log(`
16
+ ${e.name}`),console.log(` ID: ${e.id}`),console.log(` Status: ${e.status}`),console.log(` Wallet: ${e.walletAddress}`),console.log(` Balance: $${e.wallet.balance.toFixed(2)}
17
+ `);}async function F(t,e){e.trim()||(console.error(`
18
+ Usage: valta agents run [agentId] "task"
19
+ `),process.exit(1));let n=await m().agents.run(t,{task:e});console.log(`
20
+ Run started: ${n.id}`),console.log(` Status: ${n.status}`),console.log(` Started: ${n.startedAt}
21
+ `);}async function B(t){let e=await m().agents.freeze(t);console.log(`
22
+ Agent ${e.agentId} frozen.
23
+ `);}async function M(t){let e=await m().agents.unfreeze(t);console.log(`
24
+ Agent ${e.agentId} active.
25
+ `);}async function j(t){await m().agents.delete(t),console.log(`
26
+ Agent ${t} deleted.
27
+ `);}function k(){let t=g();t||(console.error(`
28
+ Not logged in. Run: valta login
29
+ `),process.exit(1));let e=u()?.baseUrl??process.env.VALTA_BASE_URL;return new c({apiKey:t,baseUrl:e})}async function H(){let t=await k().keys.list();if(!t.length){console.log(`
30
+ No API keys found.
31
+ `);return}console.log(`
32
+ ID PREFIX NAME CREATED`),console.log(" --------------------------------------------------------------------------");for(let e of t){let n=e.createdAt?new Date(e.createdAt).toLocaleDateString():"";console.log(` ${e.id.padEnd(24)} ${e.keyPrefix.padEnd(15)} ${e.name.padEnd(23)} ${n}`);}console.log();}async function z(t){let e=await k().keys.create({name:t});console.log(`
33
+ API key created`),console.log(` Key: ${e.fullKey}`),console.log(` Name: ${e.name}`),console.log(` Prefix: ${e.keyPrefix}`),console.log(`
34
+ Save this key now. It will not be shown again.
35
+ `);}async function W(t){await k().keys.revoke(t),console.log(`
36
+ Key ${t} revoked.
37
+ `);}function q(t,e=false){let n=createInterface({input:process.stdin,output:process.stdout});return new Promise(s=>{if(!e){n.question(t,o=>{n.close(),s(o.trim());});return}process.stdout.write(t),process.stdin.setRawMode?.(true),process.stdin.resume(),process.stdin.setEncoding("utf8");let r="",l=o=>{o===`
38
+ `||o==="\r"||o===""?(process.stdin.setRawMode?.(false),process.stdin.pause(),process.stdin.removeListener("data",l),process.stdout.write(`
39
+ `),n.close(),s(r)):o===""?process.exit():o==="\x7F"?r=r.slice(0,-1):(r+=o,process.stdout.write("*"));};process.stdin.on("data",l);})}async function G(){console.log(`
40
+ Valta Login
41
+ `);let t=await q(" Email: "),e=await q(" Password: ",true);(!t||!e)&&(console.error(`
42
+ Email and password are required.
43
+ `),process.exit(1));let s=await new c({apiKey:"login",baseUrl:process.env.VALTA_BASE_URL}).auth.login(t,e),r=s?.user;if(!s?.token||!r?.email)throw new Error("Login response was missing token or user details. Check VALTA_BASE_URL and try again.");N({apiKey:s.token,email:r.email,tier:r.plan,baseUrl:process.env.VALTA_BASE_URL}),console.log(`
44
+ Authenticated as ${r.email} (${r.plan} plan)`),console.log(` API Key: ${s.token}`),console.log(` Saved to ~/.valta/config.json. The key is shown once.
45
+ `);}function h(){let t=g();t||(console.error(`
46
+ Not logged in. Run: valta login
47
+ `),process.exit(1));let e=u()?.baseUrl??process.env.VALTA_BASE_URL;return new c({apiKey:t,baseUrl:e})}async function X(t){t||(console.error(`
48
+ Usage: valta wallets get [agentId]
49
+ `),process.exit(1));let e=await h().wallets.get(t);console.log(`
50
+ Wallet: ${e.agentId}`),console.log(` Balance: $${e.balance.toFixed(2)} ${e.currency}`),console.log(` Daily spent: $${e.dailySpent.toFixed(2)}`),console.log(` Monthly spent: $${e.monthlySpent.toFixed(2)}`),console.log(` Daily limit: ${e.dailyLimit==null?"unlimited":`$${e.dailyLimit.toFixed(2)}`}`),console.log(` Monthly limit: ${e.monthlyLimit==null?"unlimited":`$${e.monthlyLimit.toFixed(2)}`}`),console.log(` Address: ${e.walletAddress}
51
+ `);}async function Q(t){let e=await h().wallets.getBalance(t);console.log(`
52
+ $${e.toFixed(2)} USDC
53
+ `);}async function J(t){let e=await h().wallets.getDepositAddress(t);console.log(`
54
+ Address: ${e.address}`),console.log(` Network: ${e.network}`),console.log(` Currency: ${e.currency}
55
+ `);}async function Y(t){let e=await h().wallets.listTransactions(t,{limit:20}),n=Array.isArray(e)?e:e?.data??[];if(!n.length){console.log(`
56
+ No transactions found.
57
+ `);return}console.log(`
58
+ ID TYPE AMOUNT STATUS`),console.log(" --------------------------------------------------------------");for(let s of n)console.log(` ${s.id.padEnd(24)} ${s.type.padEnd(16)} $${s.amount.toFixed(2).padEnd(10)} ${s.status}`);console.log();}async function Z(t){let[e,n,s,...r]=t,l=Number(s);(!e||!n||!Number.isFinite(l)||l<=0)&&(console.error(`
59
+ Usage: valta wallets transfer [fromAgentId] [toAgentId] [amount] [description]
60
+ `),process.exit(1));let o=await h().wallets.transfer({fromAgentId:e,toAgentId:n,amount:l,description:r.join(" ")||void 0});console.log(`
61
+ Transfer complete: ${o.transactionId}`),console.log(` From balance: $${o.fromBalance.toFixed(2)}`),console.log(` To balance: $${o.toBalance.toFixed(2)}
62
+ `);}var[,,le,i,...a]=process.argv;async function ce(){switch(le){case "login":await G();break;case "logout":_(),console.log(`
63
+ Logged out.
64
+ `);break;case "whoami":{let t=v();t?.email?console.log(`
65
+ ${t.email} (${t.tier||"free"} plan)
66
+ `):console.log(`
67
+ Not logged in. Run: valta login
68
+ `);break}case "agents":!i||i==="list"?await O():i==="create"?await V(a):i==="get"&&a[0]?await K(a[0]):i==="run"&&a[0]?await F(a[0],a.slice(1).join(" ")):i==="freeze"&&a[0]?await B(a[0]):i==="unfreeze"&&a[0]?await M(a[0]):i==="delete"&&a[0]?await j(a[0]):$();break;case "wallets":case "wallet":!i||i==="get"?await X(a[0]):i==="balance"&&a[0]?await Q(a[0]):i==="deposit-address"&&a[0]?await J(a[0]):i==="transactions"&&a[0]?await Y(a[0]):i==="transfer"?await Z(a):$();break;case "keys":!i||i==="list"?await H():i==="create"?await z(a.join(" ")||"CLI Key"):i==="revoke"&&a[0]?await W(a[0]):$();break;case "audit":await S(i);break;default:$();}}function $(){console.log(`
280
69
  Valta CLI
281
70
 
282
71
  Commands:
283
- valta login Authenticate with email + password
284
- valta logout Clear credentials
285
- valta whoami Show current user
72
+ valta login Authenticate and create an API key
73
+ valta logout Clear local credentials
74
+ valta whoami Show the stored account
75
+
76
+ valta agents list List agents
77
+ valta agents create "Name" Create an agent
78
+ valta agents get [agentId] Get one agent
79
+ valta agents run [agentId] "task" Start an agent run
80
+ valta agents freeze [agentId] Freeze an agent
81
+ valta agents unfreeze [agentId] Unfreeze an agent
82
+ valta agents delete [agentId] Delete an agent
83
+
84
+ valta wallets get [agentId] Show wallet details
85
+ valta wallets balance [agentId] Show wallet balance
86
+ valta wallets deposit-address [id] Show deposit address
87
+ valta wallets transactions [id] List wallet transactions
88
+ valta wallets transfer [from] [to] [amount] [description]
286
89
 
287
- valta agents list List all agents
288
- valta agents freeze [id] Freeze an agent
90
+ valta keys list List API keys
91
+ valta keys create [name] Generate a new API key
92
+ valta keys revoke [keyId] Revoke an API key
289
93
 
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
293
- `);
294
- }
295
- }
296
- main().catch((err) => {
297
- console.error("\n \u2716 Unexpected error:", err.message, "\n");
298
- process.exit(1);
299
- });
94
+ valta audit [agentId] Show audit entries
95
+ `);}ce().catch(t=>{console.error(`
96
+ Unexpected error: ${t instanceof Error?t.message:"Unknown error"}
97
+ `),process.exit(1);});