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/README.md +79 -188
- package/bin/valta.js +12 -12
- package/dist/cli/index.js +92 -294
- package/dist/index.cjs +2 -276
- package/dist/index.d.ts +285 -131
- package/dist/index.js +2 -17
- package/package.json +56 -35
- package/dist/chunk-HGO47A3L.mjs +0 -244
- package/dist/chunk-LBY67QV7.js +0 -244
- package/dist/chunk-LPBJPXJO.js +0 -244
- package/dist/cli/index.cjs +0 -533
- package/dist/cli/index.d.cts +0 -2
- package/dist/cli/index.d.mts +0 -2
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.mjs +0 -141
- package/dist/index.d.cts +0 -197
- package/dist/index.d.mts +0 -197
- package/dist/index.mjs +0 -17
package/dist/index.d.ts
CHANGED
|
@@ -1,197 +1,351 @@
|
|
|
1
|
-
interface
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
interface ValtaConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
timeout?: number;
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
interface LoginResponse {
|
|
7
|
+
token: string;
|
|
8
|
+
user: {
|
|
9
|
+
id: string;
|
|
10
|
+
email: string;
|
|
11
|
+
name?: string | null;
|
|
12
|
+
plan: string;
|
|
13
|
+
};
|
|
10
14
|
}
|
|
11
|
-
|
|
12
|
-
interface Agent {
|
|
15
|
+
interface WhoamiResponse {
|
|
13
16
|
id: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
email: string;
|
|
18
|
+
name: string | null;
|
|
19
|
+
plan: string;
|
|
20
|
+
creditsRemaining: number;
|
|
18
21
|
createdAt: string;
|
|
19
|
-
updatedAt: string;
|
|
20
22
|
}
|
|
21
23
|
interface CreateAgentParams {
|
|
22
24
|
name: string;
|
|
23
|
-
type: string;
|
|
24
25
|
description?: string;
|
|
26
|
+
wallet?: {
|
|
27
|
+
initialBalance?: number;
|
|
28
|
+
dailyLimit?: number;
|
|
29
|
+
monthlyLimit?: number;
|
|
30
|
+
currency?: string;
|
|
31
|
+
};
|
|
32
|
+
policy?: {
|
|
33
|
+
requireApprovalAbove?: number;
|
|
34
|
+
requireApproval?: {
|
|
35
|
+
above: number;
|
|
36
|
+
};
|
|
37
|
+
maxPerTransaction?: number;
|
|
38
|
+
blockedCategories?: string[];
|
|
39
|
+
allowedDomains?: string[];
|
|
40
|
+
blockedDomains?: string[];
|
|
41
|
+
};
|
|
42
|
+
autonomyLevel?: 'supervised' | 'semi_autonomous' | 'fully_autonomous';
|
|
43
|
+
agentType?: string;
|
|
44
|
+
type?: string;
|
|
25
45
|
}
|
|
26
|
-
interface
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
46
|
+
interface Agent {
|
|
47
|
+
id: string;
|
|
48
|
+
userId: string;
|
|
49
|
+
name: string;
|
|
50
|
+
description: string | null;
|
|
51
|
+
status: 'active' | 'frozen' | 'inactive';
|
|
52
|
+
autonomyLevel: 'supervised' | 'semi_autonomous' | 'fully_autonomous';
|
|
53
|
+
agentType: string | null;
|
|
54
|
+
walletAddress: string;
|
|
55
|
+
wallet: AgentWallet;
|
|
56
|
+
policy: AgentPolicy | null;
|
|
57
|
+
createdAt: string;
|
|
58
|
+
updatedAt: string;
|
|
36
59
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
delete(agentId: string): Promise<{
|
|
47
|
-
deleted: boolean;
|
|
48
|
-
id: string;
|
|
49
|
-
}>;
|
|
60
|
+
interface AgentWallet {
|
|
61
|
+
id: string;
|
|
62
|
+
agentId: string;
|
|
63
|
+
balance: number;
|
|
64
|
+
currency: string;
|
|
65
|
+
dailyLimit: number | null;
|
|
66
|
+
monthlyLimit: number | null;
|
|
67
|
+
dailySpent: number;
|
|
68
|
+
monthlySpent: number;
|
|
50
69
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
currency: 'USDC';
|
|
62
|
-
note?: string;
|
|
70
|
+
interface AgentPolicy {
|
|
71
|
+
id: string;
|
|
72
|
+
agentId: string;
|
|
73
|
+
requireApprovalAbove: number | null;
|
|
74
|
+
maxPerTransaction: number | null;
|
|
75
|
+
dailyLimit: number | null;
|
|
76
|
+
monthlyLimit: number | null;
|
|
77
|
+
blockedCategories: string[];
|
|
78
|
+
allowedDomains: string[];
|
|
79
|
+
blockedDomains: string[];
|
|
63
80
|
}
|
|
64
|
-
interface
|
|
81
|
+
interface AgentRun {
|
|
65
82
|
id: string;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
83
|
+
agentId: string;
|
|
84
|
+
status: 'running' | 'completed' | 'failed' | 'waiting_approval' | 'frozen' | 'cancelled';
|
|
85
|
+
task: string;
|
|
86
|
+
output: string | null;
|
|
87
|
+
summary?: string | null;
|
|
88
|
+
error: string | null;
|
|
89
|
+
tokensUsed: number;
|
|
90
|
+
toolCallsCount: number;
|
|
91
|
+
durationMs: number | null;
|
|
92
|
+
startedAt: string;
|
|
93
|
+
completedAt: string | null;
|
|
72
94
|
createdAt: string;
|
|
73
95
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
transfer(agentId: string, params: WalletTransferParams): Promise<WalletTransfer>;
|
|
96
|
+
interface RunAgentParams {
|
|
97
|
+
task: string;
|
|
98
|
+
context?: string;
|
|
99
|
+
timeout?: number;
|
|
79
100
|
}
|
|
80
|
-
|
|
81
|
-
|
|
101
|
+
interface WalletBalance {
|
|
102
|
+
agentId: string;
|
|
103
|
+
balance: number;
|
|
104
|
+
currency: string;
|
|
105
|
+
dailySpent: number;
|
|
106
|
+
monthlySpent: number;
|
|
107
|
+
dailyLimit: number | null;
|
|
108
|
+
monthlyLimit: number | null;
|
|
109
|
+
walletAddress: string;
|
|
110
|
+
}
|
|
111
|
+
interface WalletDepositAddress {
|
|
112
|
+
address: string;
|
|
113
|
+
qrCodeDataUrl: string;
|
|
114
|
+
network: 'Base';
|
|
115
|
+
currency: 'USDC';
|
|
116
|
+
}
|
|
117
|
+
interface WalletTransaction {
|
|
82
118
|
id: string;
|
|
83
119
|
agentId: string;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
maxSpendPerTransaction?: number;
|
|
87
|
-
allowedRecipients?: string[];
|
|
120
|
+
type: 'debit' | 'credit' | 'transfer_out' | 'transfer_in';
|
|
121
|
+
amount: number;
|
|
88
122
|
currency: string;
|
|
89
|
-
|
|
123
|
+
description: string;
|
|
124
|
+
referenceId: string | null;
|
|
125
|
+
status: 'completed' | 'pending' | 'failed' | 'blocked';
|
|
90
126
|
createdAt: string;
|
|
91
127
|
}
|
|
128
|
+
interface TransferParams {
|
|
129
|
+
fromAgentId: string;
|
|
130
|
+
toAgentId: string;
|
|
131
|
+
amount: number;
|
|
132
|
+
description?: string;
|
|
133
|
+
}
|
|
92
134
|
interface CreatePolicyParams {
|
|
93
135
|
agentId: string;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
136
|
+
requireApprovalAbove?: number;
|
|
137
|
+
maxPerTransaction?: number;
|
|
138
|
+
dailyLimit?: number;
|
|
139
|
+
monthlyLimit?: number;
|
|
140
|
+
blockedCategories?: string[];
|
|
141
|
+
allowedDomains?: string[];
|
|
142
|
+
blockedDomains?: string[];
|
|
99
143
|
}
|
|
100
|
-
|
|
101
|
-
private requester;
|
|
102
|
-
constructor(requester: Requester);
|
|
103
|
-
list(agentId?: string): Promise<Policy[]>;
|
|
104
|
-
create(params: CreatePolicyParams): Promise<Policy>;
|
|
105
|
-
update(policyId: string, params: Partial<CreatePolicyParams>): Promise<Policy>;
|
|
106
|
-
delete(policyId: string): Promise<{
|
|
107
|
-
deleted: boolean;
|
|
108
|
-
}>;
|
|
144
|
+
interface UpdatePolicyParams extends Partial<Omit<CreatePolicyParams, 'agentId'>> {
|
|
109
145
|
}
|
|
110
|
-
|
|
111
|
-
interface AuditLog {
|
|
146
|
+
interface AuditEntry {
|
|
112
147
|
id: string;
|
|
113
148
|
agentId: string;
|
|
149
|
+
userId: string;
|
|
114
150
|
action: string;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
151
|
+
details: Record<string, unknown> | null;
|
|
152
|
+
amount: number | null;
|
|
153
|
+
status: 'success' | 'blocked' | 'pending' | 'failed';
|
|
154
|
+
previousHash: string | null;
|
|
118
155
|
hash: string;
|
|
119
|
-
|
|
156
|
+
ipAddress: string | null;
|
|
120
157
|
createdAt: string;
|
|
121
158
|
}
|
|
122
159
|
interface ListAuditParams {
|
|
123
160
|
agentId?: string;
|
|
124
|
-
|
|
125
|
-
|
|
161
|
+
action?: string;
|
|
162
|
+
status?: 'success' | 'blocked' | 'pending' | 'failed';
|
|
126
163
|
from?: string;
|
|
127
164
|
to?: string;
|
|
165
|
+
page?: number;
|
|
166
|
+
limit?: number;
|
|
128
167
|
}
|
|
129
|
-
interface ListAuditResponse {
|
|
130
|
-
logs: AuditLog[];
|
|
131
|
-
total: number;
|
|
132
|
-
}
|
|
133
|
-
declare class AuditResource {
|
|
134
|
-
private requester;
|
|
135
|
-
constructor(requester: Requester);
|
|
136
|
-
list(params?: ListAuditParams): Promise<ListAuditResponse>;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
168
|
interface ApiKey {
|
|
140
169
|
id: string;
|
|
141
170
|
name: string;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
171
|
+
keyPrefix: string;
|
|
172
|
+
fullKey?: string;
|
|
173
|
+
lastUsedAt: string | null;
|
|
145
174
|
createdAt: string;
|
|
146
175
|
}
|
|
147
|
-
interface
|
|
148
|
-
id: string;
|
|
176
|
+
interface CreateApiKeyParams {
|
|
149
177
|
name: string;
|
|
150
|
-
key: string;
|
|
151
|
-
tier: string;
|
|
152
|
-
createdAt: string;
|
|
153
178
|
}
|
|
179
|
+
interface PaginatedResponse<T> {
|
|
180
|
+
data: T[];
|
|
181
|
+
pagination: {
|
|
182
|
+
total: number;
|
|
183
|
+
page: number;
|
|
184
|
+
limit: number;
|
|
185
|
+
hasMore: boolean;
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare class HttpClient {
|
|
190
|
+
private readonly apiKey;
|
|
191
|
+
private readonly baseUrl;
|
|
192
|
+
private readonly timeout;
|
|
193
|
+
constructor(config: ValtaConfig);
|
|
194
|
+
request<T>(params: {
|
|
195
|
+
method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
196
|
+
path: string;
|
|
197
|
+
body?: unknown;
|
|
198
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
199
|
+
authenticated?: boolean;
|
|
200
|
+
}): Promise<T>;
|
|
201
|
+
get<T>(path: string, query?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
202
|
+
post<T>(path: string, body?: unknown, authenticated?: boolean): Promise<T>;
|
|
203
|
+
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
204
|
+
delete<T>(path: string): Promise<T>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
declare class AuthResource {
|
|
208
|
+
private http;
|
|
209
|
+
constructor(http: HttpClient);
|
|
210
|
+
login(email: string, password: string): Promise<LoginResponse>;
|
|
211
|
+
logout(): Promise<void>;
|
|
212
|
+
whoami(): Promise<WhoamiResponse>;
|
|
213
|
+
refreshToken(): Promise<{
|
|
214
|
+
token: string;
|
|
215
|
+
}>;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
declare class AgentsResource {
|
|
219
|
+
private http;
|
|
220
|
+
constructor(http: HttpClient);
|
|
221
|
+
create(params: CreateAgentParams): Promise<Agent>;
|
|
222
|
+
list(params?: {
|
|
223
|
+
page?: number;
|
|
224
|
+
limit?: number;
|
|
225
|
+
status?: 'active' | 'frozen' | 'inactive';
|
|
226
|
+
}): Promise<PaginatedResponse<Agent>>;
|
|
227
|
+
get(agentId: string): Promise<Agent>;
|
|
228
|
+
update(agentId: string, params: {
|
|
229
|
+
name?: string;
|
|
230
|
+
description?: string;
|
|
231
|
+
autonomyLevel?: Agent['autonomyLevel'];
|
|
232
|
+
}): Promise<Agent>;
|
|
233
|
+
delete(agentId: string): Promise<{
|
|
234
|
+
success: boolean;
|
|
235
|
+
}>;
|
|
236
|
+
freeze(agentId: string): Promise<{
|
|
237
|
+
success: boolean;
|
|
238
|
+
agentId: string;
|
|
239
|
+
status: 'frozen';
|
|
240
|
+
}>;
|
|
241
|
+
unfreeze(agentId: string): Promise<{
|
|
242
|
+
success: boolean;
|
|
243
|
+
agentId: string;
|
|
244
|
+
status: 'active';
|
|
245
|
+
}>;
|
|
246
|
+
run(agentId: string, params: RunAgentParams): Promise<AgentRun>;
|
|
247
|
+
getRun(agentId: string, runId: string): Promise<AgentRun>;
|
|
248
|
+
listRuns(agentId: string, params?: {
|
|
249
|
+
page?: number;
|
|
250
|
+
limit?: number;
|
|
251
|
+
status?: AgentRun['status'];
|
|
252
|
+
}): Promise<PaginatedResponse<AgentRun>>;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
declare class AuditResource {
|
|
256
|
+
private http;
|
|
257
|
+
constructor(http: HttpClient);
|
|
258
|
+
list(params?: ListAuditParams): Promise<PaginatedResponse<AuditEntry>>;
|
|
259
|
+
get(entryId: string): Promise<AuditEntry>;
|
|
260
|
+
export(params?: ListAuditParams): Promise<AuditEntry[]>;
|
|
261
|
+
verify(agentId: string): Promise<{
|
|
262
|
+
intact: boolean;
|
|
263
|
+
entriesChecked: number;
|
|
264
|
+
}>;
|
|
265
|
+
}
|
|
266
|
+
|
|
154
267
|
declare class KeysResource {
|
|
155
|
-
private
|
|
156
|
-
constructor(
|
|
268
|
+
private http;
|
|
269
|
+
constructor(http: HttpClient);
|
|
270
|
+
create(params: CreateApiKeyParams): Promise<ApiKey & {
|
|
271
|
+
fullKey: string;
|
|
272
|
+
}>;
|
|
157
273
|
list(): Promise<ApiKey[]>;
|
|
158
|
-
create(name: string): Promise<CreateKeyResponse>;
|
|
159
274
|
revoke(keyId: string): Promise<{
|
|
160
|
-
|
|
275
|
+
success: boolean;
|
|
161
276
|
}>;
|
|
162
277
|
}
|
|
163
278
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
279
|
+
declare class PoliciesResource {
|
|
280
|
+
private http;
|
|
281
|
+
constructor(http: HttpClient);
|
|
282
|
+
create(params: CreatePolicyParams): Promise<AgentPolicy>;
|
|
283
|
+
get(agentId: string): Promise<AgentPolicy | null>;
|
|
284
|
+
update(agentId: string, params: UpdatePolicyParams): Promise<AgentPolicy>;
|
|
285
|
+
delete(agentId: string): Promise<{
|
|
286
|
+
success: boolean;
|
|
287
|
+
}>;
|
|
288
|
+
list(): Promise<AgentPolicy[]>;
|
|
167
289
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
290
|
+
|
|
291
|
+
declare class WalletsResource {
|
|
292
|
+
private http;
|
|
293
|
+
constructor(http: HttpClient);
|
|
294
|
+
get(agentId: string): Promise<WalletBalance>;
|
|
295
|
+
getBalance(agentId: string): Promise<number>;
|
|
296
|
+
getDepositAddress(agentId: string): Promise<WalletDepositAddress>;
|
|
297
|
+
listTransactions(agentId: string, params?: {
|
|
298
|
+
page?: number;
|
|
299
|
+
limit?: number;
|
|
300
|
+
type?: WalletTransaction['type'];
|
|
301
|
+
}): Promise<PaginatedResponse<WalletTransaction>>;
|
|
302
|
+
transfer(params: TransferParams): Promise<{
|
|
303
|
+
success: boolean;
|
|
304
|
+
transactionId: string;
|
|
305
|
+
fromBalance: number;
|
|
306
|
+
toBalance: number;
|
|
307
|
+
}>;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
declare class Valta {
|
|
311
|
+
readonly auth: AuthResource;
|
|
312
|
+
readonly agents: AgentsResource;
|
|
313
|
+
readonly wallets: WalletsResource;
|
|
314
|
+
readonly policies: PoliciesResource;
|
|
315
|
+
readonly audit: AuditResource;
|
|
316
|
+
readonly keys: KeysResource;
|
|
317
|
+
private readonly http;
|
|
174
318
|
constructor(config: ValtaConfig | string);
|
|
175
319
|
}
|
|
176
320
|
|
|
321
|
+
type ValtaErrorCode = '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';
|
|
177
322
|
declare class ValtaError extends Error {
|
|
178
|
-
code:
|
|
179
|
-
status: number;
|
|
180
|
-
|
|
323
|
+
readonly code: ValtaErrorCode;
|
|
324
|
+
readonly status: number | null;
|
|
325
|
+
readonly details: Record<string, unknown> | null;
|
|
326
|
+
constructor(params: {
|
|
327
|
+
message: string;
|
|
328
|
+
code: ValtaErrorCode;
|
|
329
|
+
status?: number;
|
|
330
|
+
details?: Record<string, unknown>;
|
|
331
|
+
});
|
|
332
|
+
isRateLimit(): boolean;
|
|
333
|
+
isAuth(): boolean;
|
|
334
|
+
requiresApproval(): boolean;
|
|
181
335
|
}
|
|
182
336
|
declare class AuthError extends ValtaError {
|
|
183
337
|
constructor(message?: string);
|
|
184
338
|
}
|
|
185
339
|
declare class TierError extends ValtaError {
|
|
186
|
-
requiredTier: string;
|
|
187
|
-
upgradeUrl: string;
|
|
188
|
-
constructor(message: string, requiredTier
|
|
340
|
+
readonly requiredTier: string | null;
|
|
341
|
+
readonly upgradeUrl: string;
|
|
342
|
+
constructor(message: string, requiredTier?: string);
|
|
189
343
|
}
|
|
190
344
|
declare class RateLimitError extends ValtaError {
|
|
191
345
|
constructor(message?: string);
|
|
192
346
|
}
|
|
193
347
|
declare class NotFoundError extends ValtaError {
|
|
194
|
-
constructor(
|
|
348
|
+
constructor(message?: string);
|
|
195
349
|
}
|
|
196
350
|
|
|
197
|
-
export { type Agent, type ApiKey, type
|
|
351
|
+
export { type Agent, type AgentPolicy, type AgentRun, type AgentWallet, type ApiKey, type AuditEntry, AuthError, type CreateAgentParams, type CreateApiKeyParams, type CreatePolicyParams, type ListAuditParams, type LoginResponse, NotFoundError, type PaginatedResponse, RateLimitError, type RunAgentParams, TierError, type TransferParams, type UpdatePolicyParams, Valta, Valta as ValtaClient, type ValtaConfig, ValtaError, type ValtaErrorCode, type WalletBalance, type WalletDepositAddress, type WalletTransaction, type WhoamiResponse, Valta as default };
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
NotFoundError,
|
|
4
|
-
RateLimitError,
|
|
5
|
-
TierError,
|
|
6
|
-
ValtaClient,
|
|
7
|
-
ValtaError
|
|
8
|
-
} from "./chunk-LBY67QV7.js";
|
|
9
|
-
export {
|
|
10
|
-
AuthError,
|
|
11
|
-
NotFoundError,
|
|
12
|
-
RateLimitError,
|
|
13
|
-
TierError,
|
|
14
|
-
ValtaClient,
|
|
15
|
-
ValtaError,
|
|
16
|
-
ValtaClient as default
|
|
17
|
-
};
|
|
1
|
+
var d=class{constructor(t){this.http=t;}async login(t,e){return this.http.post("/auth/login",{email:t,password:e},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 m=class{constructor(t){this.http=t;}async create(t){return this.http.post("/agents",t)}async list(t){return this.http.get("/agents",t)}async get(t){return this.http.get(`/agents/${encodeURIComponent(t)}`)}async update(t,e){return this.http.patch(`/agents/${encodeURIComponent(t)}`,e)}async delete(t){return this.http.delete(`/agents/${encodeURIComponent(t)}`)}async freeze(t){return this.http.post(`/agents/${encodeURIComponent(t)}/freeze`)}async unfreeze(t){return this.http.post(`/agents/${encodeURIComponent(t)}/unfreeze`)}async run(t,e){return this.http.post(`/agents/${encodeURIComponent(t)}/run`,e)}async getRun(t,e){return this.http.get(`/agents/${encodeURIComponent(t)}/runs/${encodeURIComponent(e)}`)}async listRuns(t,e){return this.http.get(`/agents/${encodeURIComponent(t)}/runs`,e)}};var g=class{constructor(t){this.http=t;}async list(t){return this.http.get("/audit",t)}async get(t){return this.http.get(`/audit/${encodeURIComponent(t)}`)}async export(t){let e=[],o=1,i=true;for(;i;){let p=await this.list({...t,page:o,limit:100});e.push(...p.data),i=p.pagination.hasMore,o+=1;}return e}async verify(t){return this.http.get(`/audit/verify/${encodeURIComponent(t)}`)}};var h=class{constructor(t){this.http=t;}async create(t){return this.http.post("/keys",t)}async list(){return this.http.get("/keys")}async revoke(t){return this.http.delete(`/keys/${encodeURIComponent(t)}`)}};var n=class extends Error{constructor(t){super(t.message),this.name="ValtaError",this.code=t.code,this.status=t.status??null,this.details=t.details??null;}isRateLimit(){return this.code==="RATE_LIMIT_EXCEEDED"}isAuth(){return this.code==="UNAUTHORISED"||this.code==="FORBIDDEN"}requiresApproval(){return this.code==="APPROVAL_REQUIRED"}},A=class extends n{constructor(t="Invalid or missing API key"){super({message:t,code:"UNAUTHORISED",status:401}),this.name="AuthError";}},P=class extends n{constructor(t,e){super({message:t,code:"TIER_LIMIT_EXCEEDED",status:403,details:{requiredTier:e}}),this.name="TierError",this.requiredTier=e??null,this.upgradeUrl="https://valta.co/upgrade";}},I=class extends n{constructor(t="Rate limit exceeded"){super({message:t,code:"RATE_LIMIT_EXCEEDED",status:429}),this.name="RateLimitError";}},T=class extends n{constructor(t="Resource not found"){super({message:t,code:"NOT_FOUND",status:404}),this.name="NotFoundError";}};var E=class{constructor(t){this.http=t;}async create(t){return this.http.post("/policies",t)}async get(t){try{return await this.http.get(`/policies/${encodeURIComponent(t)}`)}catch(e){if(e instanceof n&&e.code==="NOT_FOUND")return null;throw e}}async update(t,e){return this.http.patch(`/policies/${encodeURIComponent(t)}`,e)}async delete(t){return this.http.delete(`/policies/${encodeURIComponent(t)}`)}async list(){return this.http.get("/policies")}};var y=class{constructor(t){this.http=t;}async get(t){return this.http.get(`/wallets/${encodeURIComponent(t)}`)}async getBalance(t){return (await this.get(t)).balance}async getDepositAddress(t){return this.http.get(`/wallets/${encodeURIComponent(t)}/deposit-address`)}async listTransactions(t,e){return this.http.get(`/wallets/${encodeURIComponent(t)}/transactions`,e)}async transfer(t){return this.http.post("/wallets/transfer",t)}};var f="2.2.0",R=class{constructor(t){this.apiKey=t.apiKey,this.baseUrl=(t.baseUrl??"https://valta.co/api/v1").replace(/\/$/,""),this.timeout=t.timeout??3e4;}async request(t){let e=`${this.baseUrl}${t.path}`;if(t.query){let r=new URLSearchParams;for(let[u,a]of Object.entries(t.query))a!==void 0&&r.set(u,String(a));let l=r.toString();l&&(e+=`?${l}`);}let o=new AbortController,i=setTimeout(()=>o.abort(),this.timeout),p={"Content-Type":"application/json","User-Agent":`valta-sdk/${f}`,"X-Valta-SDK":f};t.authenticated!==false&&(p["x-api-key"]=this.apiKey);try{let r=await fetch(e,{method:t.method,headers:p,body:t.body===void 0?void 0:JSON.stringify(t.body),signal:o.signal});clearTimeout(i);let l=await r.text(),u=l?C(l,r.status):null;if(!r.ok){let a=u??{};throw new n({message:a.message??a.error??`HTTP ${r.status}`,code:U(a.code,r.status),status:r.status,details:a})}return u}catch(r){throw clearTimeout(i),r instanceof n?r:r instanceof Error&&r.name==="AbortError"?new n({message:`Request timed out after ${this.timeout}ms`,code:"TIMEOUT"}):new n({message:r instanceof Error?r.message:"An unknown network error occurred",code:"NETWORK_ERROR"})}}get(t,e){return this.request({method:"GET",path:t,query:e})}post(t,e,o=true){return this.request({method:"POST",path:t,body:e,authenticated:o})}patch(t,e){return this.request({method:"PATCH",path:t,body:e})}delete(t){return this.request({method:"DELETE",path:t})}};function C(s,t){try{return JSON.parse(s)}catch{throw new n({message:"Invalid JSON response from server",code:"SERVER_ERROR",status:t})}}function U(s,t){let e=String(s||"").toUpperCase();if(e==="UNAUTHORIZED"||e==="API_KEY_REQUIRED"||e==="INVALID_API_KEY")return "UNAUTHORISED";if(e==="RATE_LIMIT"||e==="API_KEY_RATE_LIMITED")return "RATE_LIMIT_EXCEEDED";if(e==="TIER_LIMIT")return "TIER_LIMIT_EXCEEDED";if(D(e))return e;switch(t){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 D(s){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(s)}var c=class{constructor(t){let e=typeof t=="string"?{apiKey:t}:t;if(!e.apiKey)throw new Error("Valta API key is required. Get one at https://valta.co/dashboard/api-keys");this.http=new R(e),this.auth=new d(this.http),this.agents=new m(this.http),this.wallets=new y(this.http),this.policies=new E(this.http),this.audit=new g(this.http),this.keys=new h(this.http);}};
|
|
2
|
+
export{A as AuthError,T as NotFoundError,I as RateLimitError,P as TierError,c as Valta,c as ValtaClient,n as ValtaError,c as default};
|
package/package.json
CHANGED
|
@@ -1,35 +1,56 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "valta-sdk",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "dist/index.
|
|
6
|
-
"module": "dist/index.
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"dist",
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "valta-sdk",
|
|
3
|
+
"version": "2.2.2",
|
|
4
|
+
"description": "Financial governance infrastructure for autonomous AI agents",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"valta": "bin/valta.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/index.js",
|
|
20
|
+
"dist/index.cjs",
|
|
21
|
+
"dist/index.d.ts",
|
|
22
|
+
"dist/cli/index.js",
|
|
23
|
+
"bin",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsup",
|
|
28
|
+
"dev": "tsup --watch",
|
|
29
|
+
"test": "vitest run --pool forks",
|
|
30
|
+
"test:watch": "vitest --pool forks",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"prepublishOnly": "npm run build && npm run test && npm run typecheck"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"ai",
|
|
36
|
+
"agents",
|
|
37
|
+
"financial",
|
|
38
|
+
"governance",
|
|
39
|
+
"wallet",
|
|
40
|
+
"valta"
|
|
41
|
+
],
|
|
42
|
+
"author": "Valta",
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"homepage": "https://valta.co/docs",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/Billionaire664/Valta.co"
|
|
48
|
+
},
|
|
49
|
+
"type": "module",
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^20.0.0",
|
|
52
|
+
"tsup": "^8.5.1",
|
|
53
|
+
"typescript": "^5.9.3",
|
|
54
|
+
"vitest": "^1.6.1"
|
|
55
|
+
}
|
|
56
|
+
}
|