@conto_finance/sdk 0.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/README.md +107 -0
- package/dist/index.d.mts +753 -0
- package/dist/index.d.ts +753 -0
- package/dist/index.js +697 -0
- package/dist/index.mjs +683 -0
- package/package.json +60 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,753 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conto Admin SDK
|
|
3
|
+
*
|
|
4
|
+
* Organization-level admin client for managing agents, wallets, and policies.
|
|
5
|
+
* Requires an organization API key (conto_xxx...) with appropriate scopes.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { ContoAdmin } from '@conto_finance/sdk';
|
|
10
|
+
*
|
|
11
|
+
* const admin = new ContoAdmin({
|
|
12
|
+
* orgApiKey: 'conto_xxx...',
|
|
13
|
+
* baseUrl: 'https://conto.finance'
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Create a policy with spend limits
|
|
17
|
+
* const policy = await admin.policies.create({
|
|
18
|
+
* name: 'Daily limit',
|
|
19
|
+
* policyType: 'SPEND_LIMIT',
|
|
20
|
+
* rules: [{ ruleType: 'DAILY_LIMIT', operator: 'LTE', value: '1000' }],
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Assign it to an agent
|
|
24
|
+
* await admin.agents.assignPolicy(agentId, policy.id);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
interface ContoAdminConfig {
|
|
28
|
+
/** Your organization API key (conto_xxx...) */
|
|
29
|
+
orgApiKey: string;
|
|
30
|
+
/** Base URL of the Conto API. Defaults to https://conto.finance */
|
|
31
|
+
baseUrl?: string;
|
|
32
|
+
/** Request timeout in milliseconds. Defaults to 30000 */
|
|
33
|
+
timeout?: number;
|
|
34
|
+
}
|
|
35
|
+
interface ContoAdminError extends Error {
|
|
36
|
+
code: string;
|
|
37
|
+
status: number;
|
|
38
|
+
}
|
|
39
|
+
interface PaginationParams {
|
|
40
|
+
limit?: number;
|
|
41
|
+
offset?: number;
|
|
42
|
+
}
|
|
43
|
+
interface PaginatedResponse<T> {
|
|
44
|
+
items: T[];
|
|
45
|
+
total: number;
|
|
46
|
+
limit: number;
|
|
47
|
+
offset: number;
|
|
48
|
+
}
|
|
49
|
+
type AgentType = 'OPENAI_ASSISTANT' | 'ANTHROPIC_CLAUDE' | 'LANGCHAIN' | 'AUTOGPT' | 'CUSTOM';
|
|
50
|
+
type AgentStatus = 'ACTIVE' | 'PAUSED' | 'SUSPENDED' | 'REVOKED' | 'FROZEN' | 'DELETED';
|
|
51
|
+
type AgentEnvironment = 'DEV' | 'STAGING' | 'PROD';
|
|
52
|
+
type AgentRiskTier = 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
|
|
53
|
+
type AgentAttestationMode = 'KEY_ONLY' | 'SIGNED_REQUEST' | 'SIGNED_REQUEST_WITH_CONTEXT';
|
|
54
|
+
type DelegationType = 'FULL' | 'LIMITED' | 'VIEW_ONLY' | 'PREAPPROVED' | 'ALLOWLIST';
|
|
55
|
+
type ChainType = 'EVM' | 'SOLANA';
|
|
56
|
+
type CustodyType = 'PRIVY' | 'SPONGE' | 'EXTERNAL' | 'SMART_CONTRACT';
|
|
57
|
+
type WalletType = 'EOA' | 'SMART_WALLET' | 'MULTISIG';
|
|
58
|
+
type WalletStatus = 'ACTIVE' | 'FROZEN' | 'CLOSED' | 'ARCHIVED';
|
|
59
|
+
type PolicyType = 'SPEND_LIMIT' | 'MERCHANT' | 'TIME_WINDOW' | 'CATEGORY' | 'VELOCITY' | 'COMPOSITE' | 'GEOGRAPHIC' | 'APPROVAL_THRESHOLD' | 'COUNTERPARTY' | 'BUDGET_ALLOCATION' | 'WHITELIST' | 'EXPIRATION' | 'CONTRACT_ALLOWLIST' | 'BLACKOUT_PERIOD';
|
|
60
|
+
type RuleType = 'MAX_AMOUNT' | 'DAILY_LIMIT' | 'WEEKLY_LIMIT' | 'MONTHLY_LIMIT' | 'ALLOWED_CATEGORIES' | 'BLOCKED_CATEGORIES' | 'ALLOWED_COUNTERPARTIES' | 'BLOCKED_COUNTERPARTIES' | 'TIME_WINDOW' | 'DAY_OF_WEEK' | 'VELOCITY_LIMIT' | 'REQUIRE_APPROVAL_ABOVE' | 'GEOGRAPHIC_RESTRICTION' | 'TRUST_SCORE' | 'COUNTERPARTY_STATUS' | 'BUDGET_CAP' | 'DATE_RANGE' | 'CONTRACT_ALLOWLIST' | 'ALLOWED_CONTRACTS' | 'PROTOCOL_ALLOWLIST' | 'BLACKOUT_PERIOD' | 'MAINTENANCE_WINDOW' | 'BLOCKED_TIME_WINDOW';
|
|
61
|
+
type RuleOperator = 'EQUALS' | 'NOT_EQUALS' | 'GREATER_THAN' | 'LESS_THAN' | 'GTE' | 'LTE' | 'IN' | 'NOT_IN' | 'IN_LIST' | 'NOT_IN_LIST' | 'BETWEEN' | 'NOT_BETWEEN' | 'DENY';
|
|
62
|
+
type RuleAction = 'ALLOW' | 'DENY' | 'REQUIRE_APPROVAL';
|
|
63
|
+
type SdkKeyType = 'standard' | 'admin';
|
|
64
|
+
interface Agent {
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
description: string | null;
|
|
68
|
+
agentIdSlug?: string | null;
|
|
69
|
+
purpose?: string | null;
|
|
70
|
+
agentType: AgentType;
|
|
71
|
+
environment?: AgentEnvironment;
|
|
72
|
+
riskTier?: AgentRiskTier;
|
|
73
|
+
publicKey: string;
|
|
74
|
+
status: AgentStatus;
|
|
75
|
+
externalId: string | null;
|
|
76
|
+
attestationMode?: AgentAttestationMode;
|
|
77
|
+
identityTags?: string[];
|
|
78
|
+
ownerMembershipId?: string | null;
|
|
79
|
+
owner?: {
|
|
80
|
+
membershipId: string;
|
|
81
|
+
role: string;
|
|
82
|
+
userId?: string | null;
|
|
83
|
+
name?: string | null;
|
|
84
|
+
email?: string | null;
|
|
85
|
+
} | null;
|
|
86
|
+
allowedContexts: string | null;
|
|
87
|
+
organizationId: string;
|
|
88
|
+
createdAt: string;
|
|
89
|
+
updatedAt: string;
|
|
90
|
+
wallets?: AgentWalletLink[];
|
|
91
|
+
_count?: {
|
|
92
|
+
sentTransactions: number;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
interface CreateAgentInput {
|
|
96
|
+
name: string;
|
|
97
|
+
agentType: AgentType;
|
|
98
|
+
description?: string;
|
|
99
|
+
publicKey?: string;
|
|
100
|
+
agentIdSlug?: string;
|
|
101
|
+
purpose?: string;
|
|
102
|
+
externalId?: string;
|
|
103
|
+
environment?: AgentEnvironment;
|
|
104
|
+
riskTier?: AgentRiskTier;
|
|
105
|
+
ownerMembershipId?: string;
|
|
106
|
+
attestationMode?: AgentAttestationMode;
|
|
107
|
+
identityTags?: string[];
|
|
108
|
+
allowedContexts?: string[];
|
|
109
|
+
}
|
|
110
|
+
interface UpdateAgentInput {
|
|
111
|
+
name?: string;
|
|
112
|
+
description?: string;
|
|
113
|
+
status?: 'ACTIVE' | 'PAUSED' | 'SUSPENDED' | 'REVOKED';
|
|
114
|
+
agentIdSlug?: string;
|
|
115
|
+
purpose?: string | null;
|
|
116
|
+
externalId?: string;
|
|
117
|
+
environment?: AgentEnvironment;
|
|
118
|
+
riskTier?: AgentRiskTier;
|
|
119
|
+
ownerMembershipId?: string | null;
|
|
120
|
+
attestationMode?: AgentAttestationMode;
|
|
121
|
+
identityTags?: string[] | null;
|
|
122
|
+
allowedContexts?: string[];
|
|
123
|
+
}
|
|
124
|
+
interface ListAgentsParams extends PaginationParams {
|
|
125
|
+
status?: string;
|
|
126
|
+
search?: string;
|
|
127
|
+
}
|
|
128
|
+
interface ListAgentsResponse {
|
|
129
|
+
agents: Agent[];
|
|
130
|
+
total: number;
|
|
131
|
+
limit: number;
|
|
132
|
+
offset: number;
|
|
133
|
+
}
|
|
134
|
+
interface FreezeAgentInput {
|
|
135
|
+
reason: string;
|
|
136
|
+
freezeWallets?: boolean;
|
|
137
|
+
}
|
|
138
|
+
interface UnfreezeAgentInput {
|
|
139
|
+
reason: string;
|
|
140
|
+
unfreezeWallets?: boolean;
|
|
141
|
+
resetCounters?: boolean;
|
|
142
|
+
}
|
|
143
|
+
interface AgentWalletLink {
|
|
144
|
+
id: string;
|
|
145
|
+
agentId: string;
|
|
146
|
+
walletId: string;
|
|
147
|
+
delegationType: DelegationType;
|
|
148
|
+
spendLimitPerTx: number;
|
|
149
|
+
spendLimitDaily: number;
|
|
150
|
+
spendLimitWeekly: number | null;
|
|
151
|
+
spendLimitMonthly: number | null;
|
|
152
|
+
isActive: boolean;
|
|
153
|
+
wallet?: {
|
|
154
|
+
id: string;
|
|
155
|
+
name: string;
|
|
156
|
+
address: string;
|
|
157
|
+
usdcBalance: number;
|
|
158
|
+
status: string;
|
|
159
|
+
custodyType?: string;
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
interface OrganizationMember {
|
|
163
|
+
id: string;
|
|
164
|
+
organizationId: string;
|
|
165
|
+
userId: string;
|
|
166
|
+
role: 'OWNER' | 'ADMIN' | 'MANAGER' | 'VIEWER' | 'MEMBER';
|
|
167
|
+
createdAt: string;
|
|
168
|
+
updatedAt: string;
|
|
169
|
+
user: {
|
|
170
|
+
id: string;
|
|
171
|
+
name: string | null;
|
|
172
|
+
email: string | null;
|
|
173
|
+
image?: string | null;
|
|
174
|
+
} | null;
|
|
175
|
+
}
|
|
176
|
+
interface LinkWalletInput {
|
|
177
|
+
walletId: string;
|
|
178
|
+
delegationType?: DelegationType;
|
|
179
|
+
spendLimitPerTx?: number;
|
|
180
|
+
spendLimitDaily?: number;
|
|
181
|
+
spendLimitWeekly?: number;
|
|
182
|
+
spendLimitMonthly?: number;
|
|
183
|
+
allowedHoursStart?: number;
|
|
184
|
+
allowedHoursEnd?: number;
|
|
185
|
+
allowedDays?: string[];
|
|
186
|
+
}
|
|
187
|
+
interface SdkKey {
|
|
188
|
+
id: string;
|
|
189
|
+
name: string;
|
|
190
|
+
keyPrefix: string;
|
|
191
|
+
keyType: SdkKeyType;
|
|
192
|
+
isActive: boolean;
|
|
193
|
+
lastUsedAt: string | null;
|
|
194
|
+
usageCount: number;
|
|
195
|
+
expiresAt: string | null;
|
|
196
|
+
createdAt: string;
|
|
197
|
+
revokedAt: string | null;
|
|
198
|
+
}
|
|
199
|
+
interface CreateSdkKeyInput {
|
|
200
|
+
name: string;
|
|
201
|
+
keyType?: SdkKeyType;
|
|
202
|
+
expiresInDays?: number;
|
|
203
|
+
}
|
|
204
|
+
interface CreateSdkKeyResult {
|
|
205
|
+
id: string;
|
|
206
|
+
key: string;
|
|
207
|
+
name: string;
|
|
208
|
+
keyType: SdkKeyType;
|
|
209
|
+
message: string;
|
|
210
|
+
}
|
|
211
|
+
interface Wallet {
|
|
212
|
+
id: string;
|
|
213
|
+
name: string;
|
|
214
|
+
address: string;
|
|
215
|
+
chainType: ChainType;
|
|
216
|
+
chainId: string;
|
|
217
|
+
walletType: WalletType;
|
|
218
|
+
custodyType: CustodyType;
|
|
219
|
+
usdcBalance: number;
|
|
220
|
+
status: WalletStatus;
|
|
221
|
+
externalWalletId: string | null;
|
|
222
|
+
organizationId: string;
|
|
223
|
+
createdAt: string;
|
|
224
|
+
updatedAt: string;
|
|
225
|
+
}
|
|
226
|
+
interface CreateWalletInput {
|
|
227
|
+
name: string;
|
|
228
|
+
chainType?: ChainType;
|
|
229
|
+
chainId?: string;
|
|
230
|
+
custodyType?: CustodyType;
|
|
231
|
+
walletType?: WalletType;
|
|
232
|
+
address?: string;
|
|
233
|
+
externalWalletId?: string;
|
|
234
|
+
importAddress?: string;
|
|
235
|
+
isWatchOnly?: boolean;
|
|
236
|
+
}
|
|
237
|
+
interface UpdateWalletInput {
|
|
238
|
+
name?: string;
|
|
239
|
+
status?: WalletStatus;
|
|
240
|
+
}
|
|
241
|
+
interface ListWalletsParams extends PaginationParams {
|
|
242
|
+
status?: string;
|
|
243
|
+
chainType?: ChainType;
|
|
244
|
+
chainId?: string;
|
|
245
|
+
}
|
|
246
|
+
interface ListWalletsResponse {
|
|
247
|
+
wallets: Wallet[];
|
|
248
|
+
total: number;
|
|
249
|
+
limit: number;
|
|
250
|
+
offset: number;
|
|
251
|
+
}
|
|
252
|
+
interface ProvisionWalletResult {
|
|
253
|
+
wallet: {
|
|
254
|
+
id: string;
|
|
255
|
+
name: string;
|
|
256
|
+
address: string;
|
|
257
|
+
chainId: string;
|
|
258
|
+
chainType: string;
|
|
259
|
+
custodyType: string;
|
|
260
|
+
balance: number;
|
|
261
|
+
currency: string;
|
|
262
|
+
};
|
|
263
|
+
chain: {
|
|
264
|
+
name: string;
|
|
265
|
+
chainId: string;
|
|
266
|
+
explorer: string;
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
interface WalletChainBalanceSnapshot {
|
|
270
|
+
chainId: string;
|
|
271
|
+
chainName: string;
|
|
272
|
+
balance: number;
|
|
273
|
+
symbol: string;
|
|
274
|
+
isTestnet: boolean;
|
|
275
|
+
}
|
|
276
|
+
interface RefreshBalanceResult {
|
|
277
|
+
totalBalance: number;
|
|
278
|
+
balances: WalletChainBalanceSnapshot[];
|
|
279
|
+
lastRefreshed: string;
|
|
280
|
+
}
|
|
281
|
+
interface PolicyRule {
|
|
282
|
+
id: string;
|
|
283
|
+
policyId: string;
|
|
284
|
+
ruleType: string;
|
|
285
|
+
operator: string;
|
|
286
|
+
value: string;
|
|
287
|
+
action: RuleAction;
|
|
288
|
+
createdAt: string;
|
|
289
|
+
}
|
|
290
|
+
interface Policy {
|
|
291
|
+
id: string;
|
|
292
|
+
name: string;
|
|
293
|
+
description: string | null;
|
|
294
|
+
policyType: PolicyType;
|
|
295
|
+
priority: number;
|
|
296
|
+
isActive: boolean;
|
|
297
|
+
organizationId: string;
|
|
298
|
+
rules?: PolicyRule[];
|
|
299
|
+
createdAt: string;
|
|
300
|
+
updatedAt: string;
|
|
301
|
+
_count?: {
|
|
302
|
+
agentPolicies: number;
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
interface CreatePolicyInput {
|
|
306
|
+
name: string;
|
|
307
|
+
policyType: PolicyType;
|
|
308
|
+
description?: string;
|
|
309
|
+
priority?: number;
|
|
310
|
+
isActive?: boolean;
|
|
311
|
+
rules?: CreatePolicyRuleInput[];
|
|
312
|
+
agentIds?: string[];
|
|
313
|
+
}
|
|
314
|
+
interface UpdatePolicyInput {
|
|
315
|
+
name?: string;
|
|
316
|
+
description?: string;
|
|
317
|
+
priority?: number;
|
|
318
|
+
isActive?: boolean;
|
|
319
|
+
}
|
|
320
|
+
interface ListPoliciesParams extends PaginationParams {
|
|
321
|
+
}
|
|
322
|
+
interface ListPoliciesResponse {
|
|
323
|
+
policies: Policy[];
|
|
324
|
+
total: number;
|
|
325
|
+
limit: number;
|
|
326
|
+
offset: number;
|
|
327
|
+
}
|
|
328
|
+
interface CreatePolicyRuleInput {
|
|
329
|
+
ruleType: RuleType;
|
|
330
|
+
operator: RuleOperator;
|
|
331
|
+
value: string;
|
|
332
|
+
action?: RuleAction;
|
|
333
|
+
}
|
|
334
|
+
interface UpdatePolicyRuleInput {
|
|
335
|
+
ruleType?: RuleType;
|
|
336
|
+
operator?: RuleOperator;
|
|
337
|
+
value?: string;
|
|
338
|
+
action?: RuleAction;
|
|
339
|
+
}
|
|
340
|
+
declare class ContoAdmin {
|
|
341
|
+
private orgApiKey;
|
|
342
|
+
private baseUrl;
|
|
343
|
+
private timeout;
|
|
344
|
+
agents: AgentsClient;
|
|
345
|
+
wallets: WalletsClient;
|
|
346
|
+
policies: PoliciesClient;
|
|
347
|
+
team: TeamClient;
|
|
348
|
+
constructor(config: ContoAdminConfig);
|
|
349
|
+
private fetchWithRetry;
|
|
350
|
+
/** Make an authenticated request to the Conto API */
|
|
351
|
+
request<T>(method: string, path: string, body?: Record<string, unknown>): Promise<T>;
|
|
352
|
+
}
|
|
353
|
+
declare class AgentsClient {
|
|
354
|
+
private client;
|
|
355
|
+
constructor(client: ContoAdmin);
|
|
356
|
+
/** List agents in the organization */
|
|
357
|
+
list(params?: ListAgentsParams): Promise<ListAgentsResponse>;
|
|
358
|
+
/** Create a new agent */
|
|
359
|
+
create(input: CreateAgentInput): Promise<Agent>;
|
|
360
|
+
/** Get a single agent by ID */
|
|
361
|
+
get(agentId: string): Promise<Agent>;
|
|
362
|
+
/** Update an agent */
|
|
363
|
+
update(agentId: string, input: UpdateAgentInput): Promise<Agent>;
|
|
364
|
+
/** Delete an agent (soft delete) */
|
|
365
|
+
delete(agentId: string): Promise<{
|
|
366
|
+
message: string;
|
|
367
|
+
}>;
|
|
368
|
+
/** Freeze an agent, blocking all transactions */
|
|
369
|
+
freeze(agentId: string, input: FreezeAgentInput): Promise<Record<string, unknown>>;
|
|
370
|
+
/** Unfreeze an agent, restoring transaction ability */
|
|
371
|
+
unfreeze(agentId: string, input: UnfreezeAgentInput): Promise<Record<string, unknown>>;
|
|
372
|
+
/** List wallets linked to an agent */
|
|
373
|
+
listWallets(agentId: string): Promise<{
|
|
374
|
+
wallets: AgentWalletLink[];
|
|
375
|
+
}>;
|
|
376
|
+
/** Link a wallet to an agent with spending limits */
|
|
377
|
+
linkWallet(agentId: string, input: LinkWalletInput): Promise<AgentWalletLink>;
|
|
378
|
+
/** Unlink a wallet from an agent */
|
|
379
|
+
unlinkWallet(agentId: string, walletId: string): Promise<{
|
|
380
|
+
success: boolean;
|
|
381
|
+
}>;
|
|
382
|
+
/** List policies assigned to an agent */
|
|
383
|
+
listPolicies(agentId: string): Promise<{
|
|
384
|
+
policies: Array<Record<string, unknown>>;
|
|
385
|
+
}>;
|
|
386
|
+
/** Assign a policy to an agent */
|
|
387
|
+
assignPolicy(agentId: string, policyId: string, overrides?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
388
|
+
/** Unassign a policy from an agent */
|
|
389
|
+
unassignPolicy(agentId: string, policyId: string): Promise<{
|
|
390
|
+
success: boolean;
|
|
391
|
+
}>;
|
|
392
|
+
/** List SDK keys for an agent */
|
|
393
|
+
listSdkKeys(agentId: string): Promise<SdkKey[]>;
|
|
394
|
+
/** Create an SDK key for an agent (key value is returned only once) */
|
|
395
|
+
createSdkKey(agentId: string, input: CreateSdkKeyInput): Promise<CreateSdkKeyResult>;
|
|
396
|
+
/** Revoke an SDK key */
|
|
397
|
+
revokeSdkKey(agentId: string, keyId: string): Promise<{
|
|
398
|
+
success: boolean;
|
|
399
|
+
}>;
|
|
400
|
+
}
|
|
401
|
+
declare class WalletsClient {
|
|
402
|
+
private client;
|
|
403
|
+
constructor(client: ContoAdmin);
|
|
404
|
+
/** List wallets in the organization */
|
|
405
|
+
list(params?: ListWalletsParams): Promise<ListWalletsResponse>;
|
|
406
|
+
/** Create a new wallet or attach an existing provider/self-custodied wallet */
|
|
407
|
+
create(input: CreateWalletInput): Promise<Wallet>;
|
|
408
|
+
/** Get a single wallet by ID */
|
|
409
|
+
get(walletId: string): Promise<Wallet>;
|
|
410
|
+
/** Update a wallet */
|
|
411
|
+
update(walletId: string, input: UpdateWalletInput): Promise<Wallet>;
|
|
412
|
+
/** Delete a wallet (cannot delete if linked to agents) */
|
|
413
|
+
delete(walletId: string): Promise<{
|
|
414
|
+
success: boolean;
|
|
415
|
+
}>;
|
|
416
|
+
/** Provision a wallet for onchain transactions */
|
|
417
|
+
provision(walletId: string): Promise<ProvisionWalletResult>;
|
|
418
|
+
/** Refresh a wallet's balance from the chain */
|
|
419
|
+
refreshBalance(walletId: string): Promise<RefreshBalanceResult>;
|
|
420
|
+
}
|
|
421
|
+
declare class PoliciesClient {
|
|
422
|
+
private client;
|
|
423
|
+
constructor(client: ContoAdmin);
|
|
424
|
+
/** List policies in the organization */
|
|
425
|
+
list(params?: ListPoliciesParams): Promise<ListPoliciesResponse>;
|
|
426
|
+
/** Create a new policy (optionally with rules and agent assignments) */
|
|
427
|
+
create(input: CreatePolicyInput): Promise<Policy>;
|
|
428
|
+
/** Get a single policy by ID */
|
|
429
|
+
get(policyId: string): Promise<Policy>;
|
|
430
|
+
/** Update a policy */
|
|
431
|
+
update(policyId: string, input: UpdatePolicyInput): Promise<Policy>;
|
|
432
|
+
/** Delete a policy */
|
|
433
|
+
delete(policyId: string): Promise<{
|
|
434
|
+
success: boolean;
|
|
435
|
+
}>;
|
|
436
|
+
/** List rules for a policy */
|
|
437
|
+
listRules(policyId: string): Promise<{
|
|
438
|
+
rules: PolicyRule[];
|
|
439
|
+
}>;
|
|
440
|
+
/** Add a single rule to a policy */
|
|
441
|
+
addRule(policyId: string, rule: CreatePolicyRuleInput): Promise<{
|
|
442
|
+
rules: PolicyRule[];
|
|
443
|
+
}>;
|
|
444
|
+
/** Add multiple rules to a policy */
|
|
445
|
+
addRules(policyId: string, rules: CreatePolicyRuleInput[]): Promise<{
|
|
446
|
+
rules: PolicyRule[];
|
|
447
|
+
}>;
|
|
448
|
+
/** Update a single rule */
|
|
449
|
+
updateRule(policyId: string, ruleId: string, input: UpdatePolicyRuleInput): Promise<PolicyRule>;
|
|
450
|
+
/** Delete a single rule */
|
|
451
|
+
deleteRule(policyId: string, ruleId: string): Promise<{
|
|
452
|
+
success: boolean;
|
|
453
|
+
}>;
|
|
454
|
+
/** Delete all rules for a policy */
|
|
455
|
+
deleteAllRules(policyId: string): Promise<{
|
|
456
|
+
success: boolean;
|
|
457
|
+
deletedCount: number;
|
|
458
|
+
}>;
|
|
459
|
+
}
|
|
460
|
+
declare class TeamClient {
|
|
461
|
+
private client;
|
|
462
|
+
constructor(client: ContoAdmin);
|
|
463
|
+
/** List organization memberships for the authenticated organization */
|
|
464
|
+
listMembers(): Promise<{
|
|
465
|
+
organizationId: string;
|
|
466
|
+
members: OrganizationMember[];
|
|
467
|
+
}>;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Conto SDK
|
|
472
|
+
*
|
|
473
|
+
* SDK for AI agents to request and execute payments through Conto.
|
|
474
|
+
*
|
|
475
|
+
* Usage:
|
|
476
|
+
* ```typescript
|
|
477
|
+
* import { Conto } from '@conto_finance/sdk';
|
|
478
|
+
*
|
|
479
|
+
* const conto = new Conto({
|
|
480
|
+
* apiKey: 'conto_agent_xxx...',
|
|
481
|
+
* baseUrl: 'https://conto.finance' // or your self-hosted URL
|
|
482
|
+
* });
|
|
483
|
+
*
|
|
484
|
+
* // Request a payment
|
|
485
|
+
* const request = await conto.payments.request({
|
|
486
|
+
* amount: 10.00,
|
|
487
|
+
* recipientAddress: '0x...',
|
|
488
|
+
* purpose: 'API usage fee'
|
|
489
|
+
* });
|
|
490
|
+
*
|
|
491
|
+
* // Execute if approved
|
|
492
|
+
* if (request.status === 'APPROVED') {
|
|
493
|
+
* const result = await conto.payments.execute(request.requestId);
|
|
494
|
+
* console.log(`Payment sent: ${result.txHash}`);
|
|
495
|
+
* }
|
|
496
|
+
* ```
|
|
497
|
+
*/
|
|
498
|
+
interface ContoConfig {
|
|
499
|
+
/** Your agent's SDK API key (conto_agent_xxx...) */
|
|
500
|
+
apiKey: string;
|
|
501
|
+
/** Base URL of the Conto API. Defaults to https://conto.finance */
|
|
502
|
+
baseUrl?: string;
|
|
503
|
+
/** Request timeout in milliseconds. Defaults to 30000 */
|
|
504
|
+
timeout?: number;
|
|
505
|
+
}
|
|
506
|
+
interface PaymentRequestInput {
|
|
507
|
+
/** Amount in the wallet chain stablecoin */
|
|
508
|
+
amount: number;
|
|
509
|
+
/** Recipient wallet address (0x...) */
|
|
510
|
+
recipientAddress: string;
|
|
511
|
+
/** Human-readable recipient name */
|
|
512
|
+
recipientName?: string;
|
|
513
|
+
/** Why this payment is needed */
|
|
514
|
+
purpose?: string;
|
|
515
|
+
/** Spend category for analytics */
|
|
516
|
+
category?: string;
|
|
517
|
+
/** Additional context (will be stored) */
|
|
518
|
+
context?: Record<string, unknown>;
|
|
519
|
+
/** Specific wallet ID to use (optional) */
|
|
520
|
+
walletId?: string;
|
|
521
|
+
/** Payment urgency */
|
|
522
|
+
urgency?: 'LOW' | 'NORMAL' | 'HIGH' | 'CRITICAL';
|
|
523
|
+
/** If true, automatically execute the payment if approved (skip separate execute call) */
|
|
524
|
+
autoExecute?: boolean;
|
|
525
|
+
/** Contract address for contract-aware policy evaluation */
|
|
526
|
+
targetContractAddress?: string;
|
|
527
|
+
/** 4-byte function selector for contract allowlist checks */
|
|
528
|
+
functionSelector?: string;
|
|
529
|
+
/** Client-supplied key for idempotent retries */
|
|
530
|
+
idempotencyKey?: string;
|
|
531
|
+
}
|
|
532
|
+
interface PaymentRequestResult {
|
|
533
|
+
/** Unique request ID - use this to execute or check status */
|
|
534
|
+
requestId: string;
|
|
535
|
+
/** Current status */
|
|
536
|
+
status: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL' | 'EXECUTED';
|
|
537
|
+
/** True when the server returned a previously-created request for the same idempotency key */
|
|
538
|
+
idempotent?: boolean;
|
|
539
|
+
/** Wallet that will be used for payment (if approved) */
|
|
540
|
+
wallet?: {
|
|
541
|
+
id: string;
|
|
542
|
+
address: string;
|
|
543
|
+
chainId: string;
|
|
544
|
+
custodyType: string;
|
|
545
|
+
availableBalance: number;
|
|
546
|
+
};
|
|
547
|
+
/** When the approval expires (ISO timestamp) */
|
|
548
|
+
expiresAt?: string;
|
|
549
|
+
/** Explanation of the decision */
|
|
550
|
+
reasons: string[];
|
|
551
|
+
/** Policy violations (if denied) */
|
|
552
|
+
violations?: PolicyViolation[];
|
|
553
|
+
/** Currency used for the payment (e.g., 'USDC', 'USDC.e', 'pathUSD') */
|
|
554
|
+
currency?: string;
|
|
555
|
+
/** Chain information for the selected wallet */
|
|
556
|
+
chain?: {
|
|
557
|
+
chainId: string;
|
|
558
|
+
chainName: string;
|
|
559
|
+
chainType: string;
|
|
560
|
+
explorerUrl: string;
|
|
561
|
+
};
|
|
562
|
+
/** URL to execute this payment (convenience) */
|
|
563
|
+
executeUrl?: string;
|
|
564
|
+
/** Session ID for tracking (used in x402/MPP flows) */
|
|
565
|
+
sessionId?: string | null;
|
|
566
|
+
/** Explanation of why this wallet was selected */
|
|
567
|
+
walletSelectionReason?: string;
|
|
568
|
+
/** If autoExecute was true and approved, contains the execution result */
|
|
569
|
+
execution?: {
|
|
570
|
+
transactionId: string;
|
|
571
|
+
txHash: string;
|
|
572
|
+
explorerUrl: string;
|
|
573
|
+
status: string;
|
|
574
|
+
};
|
|
575
|
+
/** If autoExecute failed, the payment is still approved and can be executed manually */
|
|
576
|
+
autoExecuteError?: {
|
|
577
|
+
error: string;
|
|
578
|
+
code?: string;
|
|
579
|
+
};
|
|
580
|
+
/** Human-readable recovery hint for denied requests */
|
|
581
|
+
hint?: string;
|
|
582
|
+
/** Additional structured context for recovery or debugging */
|
|
583
|
+
context?: {
|
|
584
|
+
wallets?: Array<{
|
|
585
|
+
id: string;
|
|
586
|
+
address: string;
|
|
587
|
+
chainId?: string | null;
|
|
588
|
+
custodyType?: string | null;
|
|
589
|
+
balance: number;
|
|
590
|
+
}>;
|
|
591
|
+
nextSteps?: string[];
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
interface PolicyViolation {
|
|
595
|
+
type: string;
|
|
596
|
+
limit: number;
|
|
597
|
+
current: number;
|
|
598
|
+
message: string;
|
|
599
|
+
}
|
|
600
|
+
interface PaymentExecuteResult {
|
|
601
|
+
/** Internal transaction ID */
|
|
602
|
+
transactionId: string;
|
|
603
|
+
/** Onchain transaction hash */
|
|
604
|
+
txHash: string;
|
|
605
|
+
/** Transaction status */
|
|
606
|
+
status: 'CONFIRMING' | 'CONFIRMED' | 'FAILED';
|
|
607
|
+
/** Amount sent */
|
|
608
|
+
amount: number;
|
|
609
|
+
/** Currency (USDC) */
|
|
610
|
+
currency: string;
|
|
611
|
+
/** Recipient address */
|
|
612
|
+
recipient: string;
|
|
613
|
+
/** Recipient name if provided */
|
|
614
|
+
recipientName?: string;
|
|
615
|
+
/** Wallet used */
|
|
616
|
+
wallet: {
|
|
617
|
+
address: string;
|
|
618
|
+
};
|
|
619
|
+
/** Block explorer URL */
|
|
620
|
+
explorerUrl: string;
|
|
621
|
+
}
|
|
622
|
+
interface PaymentStatusResult {
|
|
623
|
+
requestId: string;
|
|
624
|
+
status: string;
|
|
625
|
+
policyResult: string;
|
|
626
|
+
amount: number;
|
|
627
|
+
currency: string;
|
|
628
|
+
recipient: string;
|
|
629
|
+
recipientName?: string;
|
|
630
|
+
purpose?: string;
|
|
631
|
+
category?: string;
|
|
632
|
+
wallet?: {
|
|
633
|
+
address: string;
|
|
634
|
+
};
|
|
635
|
+
requiresApproval: boolean;
|
|
636
|
+
approvedAt?: string;
|
|
637
|
+
deniedAt?: string;
|
|
638
|
+
denialReason?: string;
|
|
639
|
+
expiresAt?: string;
|
|
640
|
+
createdAt: string;
|
|
641
|
+
transaction?: {
|
|
642
|
+
id: string;
|
|
643
|
+
txHash: string;
|
|
644
|
+
status: string;
|
|
645
|
+
confirmedAt?: string;
|
|
646
|
+
blockNumber?: number;
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
interface ContoError extends Error {
|
|
650
|
+
code: string;
|
|
651
|
+
status: number;
|
|
652
|
+
}
|
|
653
|
+
declare class Conto {
|
|
654
|
+
private apiKey;
|
|
655
|
+
private baseUrl;
|
|
656
|
+
private timeout;
|
|
657
|
+
payments: PaymentsClient;
|
|
658
|
+
constructor(config: ContoConfig);
|
|
659
|
+
private fetchWithRetry;
|
|
660
|
+
/** Make an authenticated request to the Giro API */
|
|
661
|
+
request<T>(method: string, path: string, body?: Record<string, unknown>): Promise<T>;
|
|
662
|
+
}
|
|
663
|
+
/** Client for payment operations */
|
|
664
|
+
declare class PaymentsClient {
|
|
665
|
+
private client;
|
|
666
|
+
constructor(client: Conto);
|
|
667
|
+
/**
|
|
668
|
+
* Request authorization for a payment.
|
|
669
|
+
*
|
|
670
|
+
* This evaluates spending policies and returns whether the payment
|
|
671
|
+
* is approved, denied, or requires manual approval.
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* ```typescript
|
|
675
|
+
* const request = await conto.payments.request({
|
|
676
|
+
* amount: 25.00,
|
|
677
|
+
* recipientAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f...',
|
|
678
|
+
* recipientName: 'OpenAI',
|
|
679
|
+
* purpose: 'GPT-4 API credits',
|
|
680
|
+
* category: 'API_PROVIDER'
|
|
681
|
+
* });
|
|
682
|
+
*
|
|
683
|
+
* if (request.status === 'APPROVED') {
|
|
684
|
+
* // Payment is pre-authorized, execute it
|
|
685
|
+
* const result = await conto.payments.execute(request.requestId);
|
|
686
|
+
* } else if (request.status === 'REQUIRES_APPROVAL') {
|
|
687
|
+
* // Wait for human approval
|
|
688
|
+
* console.log('Payment requires manual approval');
|
|
689
|
+
* } else {
|
|
690
|
+
* // Payment was denied
|
|
691
|
+
* console.log('Denied:', request.reasons.join(', '));
|
|
692
|
+
* }
|
|
693
|
+
* ```
|
|
694
|
+
*/
|
|
695
|
+
request(input: PaymentRequestInput): Promise<PaymentRequestResult>;
|
|
696
|
+
/**
|
|
697
|
+
* Execute an approved payment.
|
|
698
|
+
*
|
|
699
|
+
* This sends the onchain transaction. Only works for payments
|
|
700
|
+
* with status 'APPROVED'.
|
|
701
|
+
*
|
|
702
|
+
* @param requestId - The requestId from a successful payment request
|
|
703
|
+
*
|
|
704
|
+
* @example
|
|
705
|
+
* ```typescript
|
|
706
|
+
* const result = await conto.payments.execute(request.requestId);
|
|
707
|
+
* console.log(`Transaction: ${result.txHash}`);
|
|
708
|
+
* console.log(`Explorer: ${result.explorerUrl}`);
|
|
709
|
+
* ```
|
|
710
|
+
*/
|
|
711
|
+
execute(requestId: string): Promise<PaymentExecuteResult>;
|
|
712
|
+
/**
|
|
713
|
+
* Get the status of a payment request.
|
|
714
|
+
*
|
|
715
|
+
* @param requestId - The requestId to check
|
|
716
|
+
*
|
|
717
|
+
* @example
|
|
718
|
+
* ```typescript
|
|
719
|
+
* const status = await conto.payments.status(requestId);
|
|
720
|
+
* if (status.transaction?.status === 'CONFIRMED') {
|
|
721
|
+
* console.log('Payment confirmed at block', status.transaction.blockNumber);
|
|
722
|
+
* }
|
|
723
|
+
* ```
|
|
724
|
+
*/
|
|
725
|
+
status(requestId: string): Promise<PaymentStatusResult>;
|
|
726
|
+
/**
|
|
727
|
+
* Request and execute a payment in one call.
|
|
728
|
+
*
|
|
729
|
+
* Convenience method that requests authorization and immediately
|
|
730
|
+
* executes if approved. Throws if denied or requires approval.
|
|
731
|
+
*
|
|
732
|
+
* @example
|
|
733
|
+
* ```typescript
|
|
734
|
+
* try {
|
|
735
|
+
* const result = await conto.payments.pay({
|
|
736
|
+
* amount: 10.00,
|
|
737
|
+
* recipientAddress: '0x...',
|
|
738
|
+
* purpose: 'Service fee'
|
|
739
|
+
* });
|
|
740
|
+
* console.log(`Paid! TX: ${result.txHash}`);
|
|
741
|
+
* } catch (error) {
|
|
742
|
+
* if (error.code === 'REQUIRES_APPROVAL') {
|
|
743
|
+
* console.log('Payment needs human approval');
|
|
744
|
+
* } else {
|
|
745
|
+
* console.log('Payment denied:', error.message);
|
|
746
|
+
* }
|
|
747
|
+
* }
|
|
748
|
+
* ```
|
|
749
|
+
*/
|
|
750
|
+
pay(input: PaymentRequestInput): Promise<PaymentExecuteResult>;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
export { type Agent, type AgentStatus, type AgentType, type AgentWalletLink, type ChainType, Conto, ContoAdmin, type ContoAdminConfig, type ContoAdminError, type ContoConfig, type ContoError, type CreateAgentInput, type CreatePolicyInput, type CreatePolicyRuleInput, type CreateSdkKeyInput, type CreateSdkKeyResult, type CreateWalletInput, type CustodyType, type DelegationType, type FreezeAgentInput, Conto as Giro, type ContoConfig as GiroConfig, type ContoError as GiroError, type LinkWalletInput, type ListAgentsParams, type ListAgentsResponse, type ListPoliciesParams, type ListPoliciesResponse, type ListWalletsParams, type ListWalletsResponse, type PaginatedResponse, type PaginationParams, type PaymentExecuteResult, type PaymentRequestInput, type PaymentRequestResult, type PaymentStatusResult, type Policy, type PolicyRule, type PolicyType, type PolicyViolation, type ProvisionWalletResult, type RefreshBalanceResult, type RuleAction, type RuleOperator, type RuleType, type SdkKey, type SdkKeyType, type UnfreezeAgentInput, type UpdateAgentInput, type UpdatePolicyInput, type UpdatePolicyRuleInput, type UpdateWalletInput, type Wallet, type WalletChainBalanceSnapshot, type WalletStatus, type WalletType, Conto as default };
|