valta-sdk 2.0.0 → 2.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/index.d.mts CHANGED
@@ -1,167 +1,197 @@
1
- interface ValtaConfig {
2
- /** Your Valta API key get it from /dashboard/api-keys */
3
- apiKey: string;
4
- /** Base URL. Defaults to https://valta.co */
5
- baseUrl?: string;
6
- /** Optional timeout in milliseconds. Default: 30000 */
7
- timeout?: number;
1
+ interface RequestOptions {
2
+ method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
3
+ body?: unknown;
4
+ }
5
+ declare class Requester {
6
+ private apiKey;
7
+ private baseUrl;
8
+ constructor(apiKey: string, baseUrl?: string);
9
+ request<T>(path: string, options?: RequestOptions): Promise<T>;
8
10
  }
9
11
 
10
- type AgentCategory = "finance" | "trading" | "analytics" | "development" | "marketing" | "compliance" | "research" | "general";
11
- type PlanType = "FREE" | "PRO" | "ENTERPRISE";
12
- interface AgentConfig {
13
- agentId: string;
12
+ interface Agent {
13
+ id: string;
14
14
  name: string;
15
- category: AgentCategory;
15
+ type: string;
16
+ status: 'active' | 'frozen' | 'paused';
17
+ walletAddress?: string;
18
+ createdAt: string;
19
+ updatedAt: string;
20
+ }
21
+ interface CreateAgentParams {
22
+ name: string;
23
+ type: string;
16
24
  description?: string;
17
- planRequired?: PlanType;
18
- isLive?: boolean;
19
25
  }
20
- interface ChatMessage {
21
- role: "user" | "assistant" | "system";
22
- content: string;
26
+ interface ListAgentsParams {
27
+ limit?: number;
28
+ offset?: number;
29
+ status?: 'active' | 'frozen' | 'paused';
30
+ }
31
+ interface ListAgentsResponse {
32
+ agents: Agent[];
33
+ total: number;
34
+ limit: number;
35
+ offset: number;
36
+ }
37
+ declare class AgentsResource {
38
+ private requester;
39
+ constructor(requester: Requester);
40
+ list(params?: ListAgentsParams): Promise<ListAgentsResponse>;
41
+ get(agentId: string): Promise<Agent>;
42
+ create(params: CreateAgentParams): Promise<Agent>;
43
+ update(agentId: string, params: Partial<CreateAgentParams>): Promise<Agent>;
44
+ freeze(agentId: string): Promise<Agent>;
45
+ unfreeze(agentId: string): Promise<Agent>;
46
+ delete(agentId: string): Promise<{
47
+ deleted: boolean;
48
+ id: string;
49
+ }>;
23
50
  }
24
- interface ChatResponse {
25
- message: string;
26
- agentId: string;
27
- tokens?: number;
28
- provider?: string;
51
+
52
+ interface WalletBalance {
53
+ usdc: string;
54
+ usdcPending: string;
55
+ lastUpdated: string;
56
+ }
57
+ interface WalletTransferParams {
58
+ toAgentId?: string;
59
+ toAddress?: string;
60
+ amount: string;
61
+ currency: 'USDC';
62
+ note?: string;
63
+ }
64
+ interface WalletTransfer {
65
+ id: string;
66
+ fromAgentId: string;
67
+ toAgentId?: string;
68
+ toAddress?: string;
69
+ amount: string;
70
+ currency: string;
71
+ status: 'pending' | 'completed' | 'failed';
72
+ createdAt: string;
29
73
  }
30
- interface AutomationConfig {
31
- name: string;
32
- agentId: string;
33
- task: string;
34
- schedule: "daily" | "every:30m" | "every:1h" | "every:6h" | "every:12h" | "every:168h";
35
- enabled?: boolean;
74
+ declare class WalletsResource {
75
+ private requester;
76
+ constructor(requester: Requester);
77
+ get(agentId: string): Promise<WalletBalance>;
78
+ transfer(agentId: string, params: WalletTransferParams): Promise<WalletTransfer>;
36
79
  }
37
- interface Automation {
38
- automationId: string;
39
- name: string;
80
+
81
+ interface Policy {
82
+ id: string;
40
83
  agentId: string;
41
- schedule: string;
42
- enabled: boolean;
43
- runCount: number;
44
- lastRunAt: string | null;
45
- nextRunAt: string | null;
84
+ name: string;
85
+ maxSpendPerDay?: number;
86
+ maxSpendPerTransaction?: number;
87
+ allowedRecipients?: string[];
88
+ currency: string;
89
+ active: boolean;
90
+ createdAt: string;
46
91
  }
47
- interface PipelineStep {
92
+ interface CreatePolicyParams {
48
93
  agentId: string;
49
- task: string;
50
- }
51
- interface PipelineConfig {
52
94
  name: string;
53
- description?: string;
54
- steps: PipelineStep[];
95
+ maxSpendPerDay?: number;
96
+ maxSpendPerTransaction?: number;
97
+ allowedRecipients?: string[];
98
+ currency?: string;
99
+ }
100
+ declare class PoliciesResource {
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
+ }>;
55
109
  }
56
- interface PipelineResult {
110
+
111
+ interface AuditLog {
112
+ id: string;
57
113
  agentId: string;
58
- agentName: string;
59
- response: string;
60
- durationMs: number;
114
+ action: string;
115
+ amount?: string;
116
+ currency?: string;
117
+ metadata?: Record<string, unknown>;
118
+ hash: string;
119
+ previousHash: string;
120
+ createdAt: string;
61
121
  }
62
- interface WalletBalance {
63
- balance: number;
64
- currency: string;
122
+ interface ListAuditParams {
123
+ agentId?: string;
124
+ limit?: number;
125
+ offset?: number;
126
+ from?: string;
127
+ to?: string;
65
128
  }
66
- interface Transaction {
67
- txnId: string;
68
- type: string;
69
- amount: number;
70
- status: string;
71
- createdAt: string;
129
+ interface ListAuditResponse {
130
+ logs: AuditLog[];
131
+ total: number;
72
132
  }
73
-
74
- declare class WalletTool {
75
- private apiKey;
76
- private baseUrl;
77
- constructor(apiKey: string, baseUrl: string);
78
- getBalance(): Promise<WalletBalance>;
79
- getTransactions(limit?: number): Promise<Transaction[]>;
80
- getAddress(): Promise<string>;
133
+ declare class AuditResource {
134
+ private requester;
135
+ constructor(requester: Requester);
136
+ list(params?: ListAuditParams): Promise<ListAuditResponse>;
81
137
  }
82
138
 
83
- interface AnalyticsSummary {
84
- totalSpend: number;
85
- topAgents: Array<{
86
- agentId: string;
87
- name: string;
88
- spend: number;
89
- }>;
90
- spendByDay: Array<{
91
- date: string;
92
- amount: number;
93
- }>;
139
+ interface ApiKey {
140
+ id: string;
141
+ name: string;
142
+ prefix: string;
143
+ tier: 'free' | 'builder' | 'startup' | 'enterprise';
144
+ lastUsed?: string;
145
+ createdAt: string;
94
146
  }
95
- declare class AnalyticsTool {
96
- private apiKey;
97
- private baseUrl;
98
- constructor(apiKey: string, baseUrl: string);
99
- getSummary(): Promise<AnalyticsSummary>;
100
- getAuditTrail(limit?: number): Promise<unknown[]>;
147
+ interface CreateKeyResponse {
148
+ id: string;
149
+ name: string;
150
+ key: string;
151
+ tier: string;
152
+ createdAt: string;
101
153
  }
102
-
103
- declare class TradingAgent {
104
- private apiKey;
105
- private baseUrl;
106
- constructor(apiKey: string, baseUrl: string);
107
- analyze(question: string): Promise<ChatResponse>;
108
- getMarketBrief(): Promise<string>;
109
- getSignals(assets: string[]): Promise<string>;
154
+ declare class KeysResource {
155
+ private requester;
156
+ constructor(requester: Requester);
157
+ list(): Promise<ApiKey[]>;
158
+ create(name: string): Promise<CreateKeyResponse>;
159
+ revoke(keyId: string): Promise<{
160
+ deleted: boolean;
161
+ }>;
110
162
  }
111
163
 
112
- declare class PortfolioAgent {
113
- private apiKey;
114
- private baseUrl;
115
- constructor(apiKey: string, baseUrl: string);
116
- analyze(question: string): Promise<ChatResponse>;
117
- getReport(): Promise<string>;
118
- getRebalancingSuggestions(targetAllocation: Record<string, number>): Promise<string>;
164
+ interface ValtaConfig {
165
+ apiKey: string;
166
+ baseUrl?: string;
119
167
  }
120
-
121
- type Plugin = (client: ValtaClient) => void;
122
168
  declare class ValtaClient {
123
- readonly apiKey: string;
124
- readonly baseUrl: string;
125
- readonly wallet: WalletTool;
126
- readonly analytics: AnalyticsTool;
127
- readonly trading: TradingAgent;
128
- readonly portfolio: PortfolioAgent;
129
- private plugins;
130
- constructor(config: ValtaConfig);
131
- use(plugin: Plugin): this;
132
- listAgents(): Promise<AgentConfig[]>;
133
- createAgent(agentId: string): AgentHandle;
134
- createAutomation(config: AutomationConfig): Promise<Automation>;
135
- listAutomations(): Promise<Automation[]>;
136
- runAutomation(automationId: string): Promise<{
137
- response: string | null;
138
- }>;
139
- createPipeline(config: PipelineConfig): Promise<string>;
140
- runPipeline(pipelineId: string): Promise<PipelineResult[]>;
141
- }
142
- declare class AgentHandle {
143
- private apiKey;
144
- private baseUrl;
145
- readonly agentId: string;
146
- constructor(apiKey: string, baseUrl: string, agentId: string);
147
- chat(message: string, conversationId?: string): Promise<ChatResponse>;
148
- run(): this;
169
+ agents: AgentsResource;
170
+ wallets: WalletsResource;
171
+ policies: PoliciesResource;
172
+ audit: AuditResource;
173
+ keys: KeysResource;
174
+ constructor(config: ValtaConfig | string);
149
175
  }
150
176
 
151
177
  declare class ValtaError extends Error {
178
+ code: string;
152
179
  status: number;
153
- code?: string;
154
- constructor(message: string, status?: number, code?: string);
180
+ constructor(message: string, code: string, status: number);
155
181
  }
156
- declare class ValtaAuthError extends ValtaError {
182
+ declare class AuthError extends ValtaError {
157
183
  constructor(message?: string);
158
184
  }
159
- declare class ValtaRateLimitError extends ValtaError {
160
- retryAfter?: number;
161
- constructor(message?: string, retryAfter?: number);
185
+ declare class TierError extends ValtaError {
186
+ requiredTier: string;
187
+ upgradeUrl: string;
188
+ constructor(message: string, requiredTier: string);
162
189
  }
163
- declare class ValtaUpgradeError extends ValtaError {
190
+ declare class RateLimitError extends ValtaError {
164
191
  constructor(message?: string);
165
192
  }
193
+ declare class NotFoundError extends ValtaError {
194
+ constructor(resource: string);
195
+ }
166
196
 
167
- export { type AgentCategory, type AgentConfig, AgentHandle, AnalyticsTool, type Automation, type AutomationConfig, type ChatMessage, type ChatResponse, type PipelineConfig, type PipelineResult, type PipelineStep, type PlanType, PortfolioAgent, TradingAgent, type Transaction, ValtaAuthError, ValtaClient, type ValtaConfig, ValtaError, ValtaRateLimitError, ValtaUpgradeError, type WalletBalance, WalletTool, ValtaClient as default };
197
+ export { type Agent, type ApiKey, type AuditLog, AuthError, type CreateAgentParams, type CreateKeyResponse, type CreatePolicyParams, type ListAgentsParams, type ListAuditParams, NotFoundError, type Policy, RateLimitError, TierError, ValtaClient, ValtaError, type WalletBalance, type WalletTransfer, type WalletTransferParams, ValtaClient as default };
package/dist/index.d.ts CHANGED
@@ -1,167 +1,197 @@
1
- interface ValtaConfig {
2
- /** Your Valta API key get it from /dashboard/api-keys */
3
- apiKey: string;
4
- /** Base URL. Defaults to https://valta.co */
5
- baseUrl?: string;
6
- /** Optional timeout in milliseconds. Default: 30000 */
7
- timeout?: number;
1
+ interface RequestOptions {
2
+ method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
3
+ body?: unknown;
4
+ }
5
+ declare class Requester {
6
+ private apiKey;
7
+ private baseUrl;
8
+ constructor(apiKey: string, baseUrl?: string);
9
+ request<T>(path: string, options?: RequestOptions): Promise<T>;
8
10
  }
9
11
 
10
- type AgentCategory = "finance" | "trading" | "analytics" | "development" | "marketing" | "compliance" | "research" | "general";
11
- type PlanType = "FREE" | "PRO" | "ENTERPRISE";
12
- interface AgentConfig {
13
- agentId: string;
12
+ interface Agent {
13
+ id: string;
14
14
  name: string;
15
- category: AgentCategory;
15
+ type: string;
16
+ status: 'active' | 'frozen' | 'paused';
17
+ walletAddress?: string;
18
+ createdAt: string;
19
+ updatedAt: string;
20
+ }
21
+ interface CreateAgentParams {
22
+ name: string;
23
+ type: string;
16
24
  description?: string;
17
- planRequired?: PlanType;
18
- isLive?: boolean;
19
25
  }
20
- interface ChatMessage {
21
- role: "user" | "assistant" | "system";
22
- content: string;
26
+ interface ListAgentsParams {
27
+ limit?: number;
28
+ offset?: number;
29
+ status?: 'active' | 'frozen' | 'paused';
30
+ }
31
+ interface ListAgentsResponse {
32
+ agents: Agent[];
33
+ total: number;
34
+ limit: number;
35
+ offset: number;
36
+ }
37
+ declare class AgentsResource {
38
+ private requester;
39
+ constructor(requester: Requester);
40
+ list(params?: ListAgentsParams): Promise<ListAgentsResponse>;
41
+ get(agentId: string): Promise<Agent>;
42
+ create(params: CreateAgentParams): Promise<Agent>;
43
+ update(agentId: string, params: Partial<CreateAgentParams>): Promise<Agent>;
44
+ freeze(agentId: string): Promise<Agent>;
45
+ unfreeze(agentId: string): Promise<Agent>;
46
+ delete(agentId: string): Promise<{
47
+ deleted: boolean;
48
+ id: string;
49
+ }>;
23
50
  }
24
- interface ChatResponse {
25
- message: string;
26
- agentId: string;
27
- tokens?: number;
28
- provider?: string;
51
+
52
+ interface WalletBalance {
53
+ usdc: string;
54
+ usdcPending: string;
55
+ lastUpdated: string;
56
+ }
57
+ interface WalletTransferParams {
58
+ toAgentId?: string;
59
+ toAddress?: string;
60
+ amount: string;
61
+ currency: 'USDC';
62
+ note?: string;
63
+ }
64
+ interface WalletTransfer {
65
+ id: string;
66
+ fromAgentId: string;
67
+ toAgentId?: string;
68
+ toAddress?: string;
69
+ amount: string;
70
+ currency: string;
71
+ status: 'pending' | 'completed' | 'failed';
72
+ createdAt: string;
29
73
  }
30
- interface AutomationConfig {
31
- name: string;
32
- agentId: string;
33
- task: string;
34
- schedule: "daily" | "every:30m" | "every:1h" | "every:6h" | "every:12h" | "every:168h";
35
- enabled?: boolean;
74
+ declare class WalletsResource {
75
+ private requester;
76
+ constructor(requester: Requester);
77
+ get(agentId: string): Promise<WalletBalance>;
78
+ transfer(agentId: string, params: WalletTransferParams): Promise<WalletTransfer>;
36
79
  }
37
- interface Automation {
38
- automationId: string;
39
- name: string;
80
+
81
+ interface Policy {
82
+ id: string;
40
83
  agentId: string;
41
- schedule: string;
42
- enabled: boolean;
43
- runCount: number;
44
- lastRunAt: string | null;
45
- nextRunAt: string | null;
84
+ name: string;
85
+ maxSpendPerDay?: number;
86
+ maxSpendPerTransaction?: number;
87
+ allowedRecipients?: string[];
88
+ currency: string;
89
+ active: boolean;
90
+ createdAt: string;
46
91
  }
47
- interface PipelineStep {
92
+ interface CreatePolicyParams {
48
93
  agentId: string;
49
- task: string;
50
- }
51
- interface PipelineConfig {
52
94
  name: string;
53
- description?: string;
54
- steps: PipelineStep[];
95
+ maxSpendPerDay?: number;
96
+ maxSpendPerTransaction?: number;
97
+ allowedRecipients?: string[];
98
+ currency?: string;
99
+ }
100
+ declare class PoliciesResource {
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
+ }>;
55
109
  }
56
- interface PipelineResult {
110
+
111
+ interface AuditLog {
112
+ id: string;
57
113
  agentId: string;
58
- agentName: string;
59
- response: string;
60
- durationMs: number;
114
+ action: string;
115
+ amount?: string;
116
+ currency?: string;
117
+ metadata?: Record<string, unknown>;
118
+ hash: string;
119
+ previousHash: string;
120
+ createdAt: string;
61
121
  }
62
- interface WalletBalance {
63
- balance: number;
64
- currency: string;
122
+ interface ListAuditParams {
123
+ agentId?: string;
124
+ limit?: number;
125
+ offset?: number;
126
+ from?: string;
127
+ to?: string;
65
128
  }
66
- interface Transaction {
67
- txnId: string;
68
- type: string;
69
- amount: number;
70
- status: string;
71
- createdAt: string;
129
+ interface ListAuditResponse {
130
+ logs: AuditLog[];
131
+ total: number;
72
132
  }
73
-
74
- declare class WalletTool {
75
- private apiKey;
76
- private baseUrl;
77
- constructor(apiKey: string, baseUrl: string);
78
- getBalance(): Promise<WalletBalance>;
79
- getTransactions(limit?: number): Promise<Transaction[]>;
80
- getAddress(): Promise<string>;
133
+ declare class AuditResource {
134
+ private requester;
135
+ constructor(requester: Requester);
136
+ list(params?: ListAuditParams): Promise<ListAuditResponse>;
81
137
  }
82
138
 
83
- interface AnalyticsSummary {
84
- totalSpend: number;
85
- topAgents: Array<{
86
- agentId: string;
87
- name: string;
88
- spend: number;
89
- }>;
90
- spendByDay: Array<{
91
- date: string;
92
- amount: number;
93
- }>;
139
+ interface ApiKey {
140
+ id: string;
141
+ name: string;
142
+ prefix: string;
143
+ tier: 'free' | 'builder' | 'startup' | 'enterprise';
144
+ lastUsed?: string;
145
+ createdAt: string;
94
146
  }
95
- declare class AnalyticsTool {
96
- private apiKey;
97
- private baseUrl;
98
- constructor(apiKey: string, baseUrl: string);
99
- getSummary(): Promise<AnalyticsSummary>;
100
- getAuditTrail(limit?: number): Promise<unknown[]>;
147
+ interface CreateKeyResponse {
148
+ id: string;
149
+ name: string;
150
+ key: string;
151
+ tier: string;
152
+ createdAt: string;
101
153
  }
102
-
103
- declare class TradingAgent {
104
- private apiKey;
105
- private baseUrl;
106
- constructor(apiKey: string, baseUrl: string);
107
- analyze(question: string): Promise<ChatResponse>;
108
- getMarketBrief(): Promise<string>;
109
- getSignals(assets: string[]): Promise<string>;
154
+ declare class KeysResource {
155
+ private requester;
156
+ constructor(requester: Requester);
157
+ list(): Promise<ApiKey[]>;
158
+ create(name: string): Promise<CreateKeyResponse>;
159
+ revoke(keyId: string): Promise<{
160
+ deleted: boolean;
161
+ }>;
110
162
  }
111
163
 
112
- declare class PortfolioAgent {
113
- private apiKey;
114
- private baseUrl;
115
- constructor(apiKey: string, baseUrl: string);
116
- analyze(question: string): Promise<ChatResponse>;
117
- getReport(): Promise<string>;
118
- getRebalancingSuggestions(targetAllocation: Record<string, number>): Promise<string>;
164
+ interface ValtaConfig {
165
+ apiKey: string;
166
+ baseUrl?: string;
119
167
  }
120
-
121
- type Plugin = (client: ValtaClient) => void;
122
168
  declare class ValtaClient {
123
- readonly apiKey: string;
124
- readonly baseUrl: string;
125
- readonly wallet: WalletTool;
126
- readonly analytics: AnalyticsTool;
127
- readonly trading: TradingAgent;
128
- readonly portfolio: PortfolioAgent;
129
- private plugins;
130
- constructor(config: ValtaConfig);
131
- use(plugin: Plugin): this;
132
- listAgents(): Promise<AgentConfig[]>;
133
- createAgent(agentId: string): AgentHandle;
134
- createAutomation(config: AutomationConfig): Promise<Automation>;
135
- listAutomations(): Promise<Automation[]>;
136
- runAutomation(automationId: string): Promise<{
137
- response: string | null;
138
- }>;
139
- createPipeline(config: PipelineConfig): Promise<string>;
140
- runPipeline(pipelineId: string): Promise<PipelineResult[]>;
141
- }
142
- declare class AgentHandle {
143
- private apiKey;
144
- private baseUrl;
145
- readonly agentId: string;
146
- constructor(apiKey: string, baseUrl: string, agentId: string);
147
- chat(message: string, conversationId?: string): Promise<ChatResponse>;
148
- run(): this;
169
+ agents: AgentsResource;
170
+ wallets: WalletsResource;
171
+ policies: PoliciesResource;
172
+ audit: AuditResource;
173
+ keys: KeysResource;
174
+ constructor(config: ValtaConfig | string);
149
175
  }
150
176
 
151
177
  declare class ValtaError extends Error {
178
+ code: string;
152
179
  status: number;
153
- code?: string;
154
- constructor(message: string, status?: number, code?: string);
180
+ constructor(message: string, code: string, status: number);
155
181
  }
156
- declare class ValtaAuthError extends ValtaError {
182
+ declare class AuthError extends ValtaError {
157
183
  constructor(message?: string);
158
184
  }
159
- declare class ValtaRateLimitError extends ValtaError {
160
- retryAfter?: number;
161
- constructor(message?: string, retryAfter?: number);
185
+ declare class TierError extends ValtaError {
186
+ requiredTier: string;
187
+ upgradeUrl: string;
188
+ constructor(message: string, requiredTier: string);
162
189
  }
163
- declare class ValtaUpgradeError extends ValtaError {
190
+ declare class RateLimitError extends ValtaError {
164
191
  constructor(message?: string);
165
192
  }
193
+ declare class NotFoundError extends ValtaError {
194
+ constructor(resource: string);
195
+ }
166
196
 
167
- export { type AgentCategory, type AgentConfig, AgentHandle, AnalyticsTool, type Automation, type AutomationConfig, type ChatMessage, type ChatResponse, type PipelineConfig, type PipelineResult, type PipelineStep, type PlanType, PortfolioAgent, TradingAgent, type Transaction, ValtaAuthError, ValtaClient, type ValtaConfig, ValtaError, ValtaRateLimitError, ValtaUpgradeError, type WalletBalance, WalletTool, ValtaClient as default };
197
+ export { type Agent, type ApiKey, type AuditLog, AuthError, type CreateAgentParams, type CreateKeyResponse, type CreatePolicyParams, type ListAgentsParams, type ListAuditParams, NotFoundError, type Policy, RateLimitError, TierError, ValtaClient, ValtaError, type WalletBalance, type WalletTransfer, type WalletTransferParams, ValtaClient as default };