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/README.md
CHANGED
|
@@ -1,236 +1,127 @@
|
|
|
1
1
|
# valta-sdk
|
|
2
2
|
|
|
3
|
-
Official
|
|
3
|
+
Official TypeScript SDK for [Valta](https://valta.co), financial governance infrastructure for autonomous AI agents.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
4
6
|
|
|
5
|
-
Give your AI agents their own wallets, spending policies, kill switches, and audit logs.
|
|
6
7
|
```bash
|
|
7
8
|
npm install valta-sdk
|
|
8
9
|
```
|
|
9
10
|
|
|
10
|
-
---
|
|
11
|
-
|
|
12
11
|
## Quick Start
|
|
13
|
-
```typescript
|
|
14
|
-
import Valta from 'valta-sdk';
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
```ts
|
|
14
|
+
import { Valta } from 'valta-sdk'
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
type: 'trading',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// Assign a spend policy
|
|
25
|
-
await valta.policies.create({
|
|
26
|
-
agentId: agent.id,
|
|
27
|
-
name: 'Daily limit',
|
|
28
|
-
maxSpendPerDay: 500,
|
|
29
|
-
currency: 'USDC',
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Check wallet balance
|
|
33
|
-
const wallet = await valta.wallets.get(agent.id);
|
|
34
|
-
console.log(wallet.balance); // { usdc: '245.00' }
|
|
35
|
-
|
|
36
|
-
// Freeze agent instantly
|
|
37
|
-
await valta.agents.freeze(agent.id);
|
|
38
|
-
|
|
39
|
-
// Pull immutable audit log
|
|
40
|
-
const logs = await valta.audit.list({ agentId: agent.id });
|
|
41
|
-
```
|
|
16
|
+
const valta = new Valta({
|
|
17
|
+
apiKey: process.env.VALTA_API_KEY!
|
|
18
|
+
})
|
|
42
19
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
20
|
+
const agent = await valta.agents.create({
|
|
21
|
+
name: 'Research Agent',
|
|
22
|
+
wallet: {
|
|
23
|
+
initialBalance: 100,
|
|
24
|
+
dailyLimit: 50
|
|
25
|
+
},
|
|
26
|
+
policy: {
|
|
27
|
+
requireApprovalAbove: 25,
|
|
28
|
+
blockedCategories: ['gambling']
|
|
29
|
+
}
|
|
30
|
+
})
|
|
46
31
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
3. Click Generate Key
|
|
32
|
+
const run = await valta.agents.run(agent.id, {
|
|
33
|
+
task: 'Analyse last month spend and identify top cost drivers'
|
|
34
|
+
})
|
|
51
35
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
npx valta-sdk login
|
|
36
|
+
const { data: entries } = await valta.audit.list({ agentId: agent.id })
|
|
37
|
+
console.log(agent.id, run.status, entries.length)
|
|
55
38
|
```
|
|
56
39
|
|
|
57
|
-
---
|
|
58
|
-
|
|
59
40
|
## CLI
|
|
60
41
|
|
|
61
|
-
The SDK ships with a terminal CLI. Use Valta entirely without a browser.
|
|
62
42
|
```bash
|
|
63
|
-
# Authenticate
|
|
64
43
|
valta login
|
|
65
|
-
|
|
66
|
-
# List your agents
|
|
67
44
|
valta agents list
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
valta
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
valta
|
|
45
|
+
valta agents create "Research Agent"
|
|
46
|
+
valta agents run agent_123 "Review Q4 vendor spend"
|
|
47
|
+
valta wallets get agent_123
|
|
48
|
+
valta wallets balance agent_123
|
|
49
|
+
valta wallets transactions agent_123
|
|
50
|
+
valta keys create "Production Server"
|
|
51
|
+
valta audit agent_123
|
|
74
52
|
```
|
|
75
53
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
## Agents
|
|
79
|
-
```typescript
|
|
80
|
-
// List all agents
|
|
81
|
-
const { agents } = await valta.agents.list();
|
|
82
|
-
|
|
83
|
-
// Get one agent
|
|
84
|
-
const agent = await valta.agents.get('ag_abc123');
|
|
54
|
+
## API Reference
|
|
85
55
|
|
|
86
|
-
|
|
87
|
-
const agent = await valta.agents.create({
|
|
88
|
-
name: 'Portfolio Watcher',
|
|
89
|
-
type: 'analytics',
|
|
90
|
-
});
|
|
56
|
+
### `valta.auth`
|
|
91
57
|
|
|
92
|
-
|
|
93
|
-
|
|
58
|
+
- `login(email, password)` returns `{ token, user }`
|
|
59
|
+
- `logout()` clears the server session when supported
|
|
60
|
+
- `whoami()` returns the authenticated user profile
|
|
61
|
+
- `refreshToken()` returns a fresh API token
|
|
94
62
|
|
|
95
|
-
|
|
96
|
-
await valta.agents.unfreeze('ag_abc123');
|
|
63
|
+
### `valta.agents`
|
|
97
64
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
65
|
+
- `create(params)` creates a governed agent
|
|
66
|
+
- `list(params?)` lists agents with `{ data, pagination }`
|
|
67
|
+
- `get(agentId)` fetches one agent with wallet and policy
|
|
68
|
+
- `update(agentId, params)` updates metadata
|
|
69
|
+
- `delete(agentId)` deletes an agent
|
|
70
|
+
- `freeze(agentId)` blocks runs and transactions
|
|
71
|
+
- `unfreeze(agentId)` restores active status
|
|
72
|
+
- `run(agentId, params)` starts a run
|
|
73
|
+
- `getRun(agentId, runId)` fetches a run
|
|
74
|
+
- `listRuns(agentId, params?)` lists runs
|
|
101
75
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
## Wallets
|
|
105
|
-
```typescript
|
|
106
|
-
// Get wallet balance
|
|
107
|
-
const wallet = await valta.wallets.get('ag_abc123');
|
|
108
|
-
// { usdc: '500.00', usdcPending: '0.00' }
|
|
109
|
-
|
|
110
|
-
// Transfer funds between agents
|
|
111
|
-
await valta.wallets.transfer('ag_abc123', {
|
|
112
|
-
toAgentId: 'ag_def456',
|
|
113
|
-
amount: '100.00',
|
|
114
|
-
currency: 'USDC',
|
|
115
|
-
note: 'Fund allocation',
|
|
116
|
-
});
|
|
117
|
-
```
|
|
76
|
+
### `valta.wallets`
|
|
118
77
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
await valta.policies.create({
|
|
125
|
-
agentId: 'ag_abc123',
|
|
126
|
-
name: 'Conservative limit',
|
|
127
|
-
maxSpendPerDay: 200,
|
|
128
|
-
maxSpendPerTransaction: 50,
|
|
129
|
-
currency: 'USDC',
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
// List policies for an agent
|
|
133
|
-
const policies = await valta.policies.list('ag_abc123');
|
|
134
|
-
|
|
135
|
-
// Update a policy
|
|
136
|
-
await valta.policies.update('pol_xyz', {
|
|
137
|
-
maxSpendPerDay: 500,
|
|
138
|
-
});
|
|
139
|
-
```
|
|
78
|
+
- `get(agentId)` returns balance, spend, limits, and address
|
|
79
|
+
- `getBalance(agentId)` returns the USDC balance as a number
|
|
80
|
+
- `getDepositAddress(agentId)` returns a Base USDC address and QR data URL
|
|
81
|
+
- `listTransactions(agentId, params?)` lists wallet transactions
|
|
82
|
+
- `transfer(params)` transfers funds between agent wallets
|
|
140
83
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
## Audit Logs
|
|
144
|
-
```typescript
|
|
145
|
-
// Get full audit trail for an agent
|
|
146
|
-
const { logs } = await valta.audit.list({
|
|
147
|
-
agentId: 'ag_abc123',
|
|
148
|
-
limit: 50,
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
// Each log entry is immutable and hash-chained
|
|
152
|
-
console.log(logs[0]);
|
|
153
|
-
// {
|
|
154
|
-
// id: 'log_001',
|
|
155
|
-
// action: 'transfer',
|
|
156
|
-
// amount: '100.00',
|
|
157
|
-
// hash: '0xabc...',
|
|
158
|
-
// previousHash: '0xdef...',
|
|
159
|
-
// createdAt: '2026-03-21T...'
|
|
160
|
-
// }
|
|
161
|
-
```
|
|
84
|
+
### `valta.policies`
|
|
162
85
|
|
|
163
|
-
|
|
86
|
+
- `create(params)` creates a spending policy
|
|
87
|
+
- `get(agentId)` returns a policy or `null`
|
|
88
|
+
- `update(agentId, params)` updates a policy
|
|
89
|
+
- `delete(agentId)` removes a policy
|
|
90
|
+
- `list()` lists policies
|
|
164
91
|
|
|
165
|
-
|
|
166
|
-
```typescript
|
|
167
|
-
// List your API keys
|
|
168
|
-
const keys = await valta.keys.list();
|
|
92
|
+
### `valta.audit`
|
|
169
93
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
94
|
+
- `list(params?)` lists audit entries
|
|
95
|
+
- `get(entryId)` fetches one entry
|
|
96
|
+
- `export(params?)` auto-paginates all matching entries
|
|
97
|
+
- `verify(agentId)` verifies audit chain integrity
|
|
173
98
|
|
|
174
|
-
|
|
175
|
-
await valta.keys.revoke('key_abc123');
|
|
176
|
-
```
|
|
99
|
+
### `valta.keys`
|
|
177
100
|
|
|
178
|
-
|
|
101
|
+
- `create({ name })` creates an API key and returns `fullKey` once
|
|
102
|
+
- `list()` lists key metadata
|
|
103
|
+
- `revoke(keyId)` revokes a key
|
|
179
104
|
|
|
180
105
|
## Error Handling
|
|
181
106
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
import Valta, { AuthError, TierError, RateLimitError } from 'valta-sdk';
|
|
107
|
+
```ts
|
|
108
|
+
import { Valta, ValtaError } from 'valta-sdk'
|
|
185
109
|
|
|
186
110
|
try {
|
|
187
|
-
await valta.agents.
|
|
111
|
+
await valta.agents.get('missing')
|
|
188
112
|
} catch (err) {
|
|
189
|
-
if (err instanceof
|
|
190
|
-
console.log(
|
|
191
|
-
console.log(
|
|
192
|
-
|
|
193
|
-
console.log('Invalid API key');
|
|
194
|
-
} else if (err instanceof RateLimitError) {
|
|
195
|
-
console.log('Slow down — rate limit hit');
|
|
113
|
+
if (err instanceof ValtaError) {
|
|
114
|
+
console.log(err.code)
|
|
115
|
+
console.log(err.status)
|
|
116
|
+
console.log(err.message)
|
|
196
117
|
}
|
|
197
118
|
}
|
|
198
119
|
```
|
|
199
120
|
|
|
200
|
-
|
|
201
|
-
|---|---|---|
|
|
202
|
-
| `AuthError` | 401 | Invalid or missing API key |
|
|
203
|
-
| `TierError` | 403 | Feature requires a higher tier |
|
|
204
|
-
| `RateLimitError` | 429 | Too many requests |
|
|
205
|
-
| `NotFoundError` | 404 | Agent/resource not found |
|
|
206
|
-
| `ValtaError` | 5xx | Server error |
|
|
207
|
-
|
|
208
|
-
---
|
|
209
|
-
|
|
210
|
-
## Tier Limits
|
|
211
|
-
|
|
212
|
-
| Feature | Free | Builder | Startup | Enterprise |
|
|
213
|
-
|---|---|---|---|---|
|
|
214
|
-
| Agent wallets | 1 | 10 | Unlimited | Unlimited |
|
|
215
|
-
| Policies | 1 | Unlimited | Unlimited | Unlimited |
|
|
216
|
-
| API calls/day | 100 | 1,000 | Unlimited | Unlimited |
|
|
217
|
-
| Audit export | ✗ | ✗ | ✓ | ✓ |
|
|
218
|
-
| Team members | 1 | 1 | 5 | Unlimited |
|
|
219
|
-
|
|
220
|
-
---
|
|
221
|
-
|
|
222
|
-
## TypeScript
|
|
223
|
-
|
|
224
|
-
The SDK is written in TypeScript. All types are included — no `@types` package needed.
|
|
225
|
-
```typescript
|
|
226
|
-
import Valta, { Agent, Policy, WalletBalance } from 'valta-sdk';
|
|
227
|
-
|
|
228
|
-
const agent: Agent = await valta.agents.get('ag_abc123');
|
|
229
|
-
const wallet: WalletBalance = await valta.wallets.get(agent.id);
|
|
230
|
-
```
|
|
121
|
+
## Documentation
|
|
231
122
|
|
|
232
|
-
|
|
123
|
+
[valta.co/docs](https://valta.co/docs)
|
|
233
124
|
|
|
234
125
|
## License
|
|
235
126
|
|
|
236
|
-
MIT
|
|
127
|
+
MIT
|
package/bin/valta.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { pathToFileURL } from 'url';
|
|
3
|
-
import { join, dirname } from 'path';
|
|
4
|
-
import { fileURLToPath } from 'url';
|
|
5
|
-
|
|
6
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
-
const __dirname = dirname(__filename);
|
|
8
|
-
|
|
9
|
-
const cliPath = join(__dirname, '..', 'dist', 'cli', 'index.
|
|
10
|
-
|
|
11
|
-
import(pathToFileURL(cliPath).href).catch((err) => {
|
|
12
|
-
console.error('Valta CLI failed to start:', err.message);
|
|
13
|
-
process.exit(1);
|
|
2
|
+
import { pathToFileURL } from 'url';
|
|
3
|
+
import { join, dirname } from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
|
|
9
|
+
const cliPath = join(__dirname, '..', 'dist', 'cli', 'index.js');
|
|
10
|
+
|
|
11
|
+
import(pathToFileURL(cliPath).href).catch((err) => {
|
|
12
|
+
console.error('Valta CLI failed to start:', err.message);
|
|
13
|
+
process.exit(1);
|
|
14
14
|
});
|