@kivel.io/sdk 0.0.0-stage → 0.8.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.
@@ -0,0 +1,409 @@
1
+ export * from './types.js';
2
+ import type { Authenticator, AuthenticatorInput, TotpCode, EmailAttachmentLink, OAuthProviderInput, OAuthProvider, CreatedOAuthProvider, AgentLogin, AgentToken, AgentTrial, Approval, ApprovalInput, EmailInbox, EmailMessage, EmailContent, EmailThread, EmailThreadsPage, EmailDraft, EmailRules, MemoryEntry, Monitor, MonitorInput, WaitOptions } from './types.js';
3
+ export interface ClientOptions {
4
+ baseUrl?: string | undefined;
5
+ apiKey?: string | undefined;
6
+ fetch?: typeof fetch | undefined;
7
+ timeoutMs?: number | undefined;
8
+ }
9
+ export interface ResourceSettings {
10
+ ttlSeconds?: number | undefined;
11
+ persistent?: boolean | undefined;
12
+ visibility?: 'public' | 'private' | undefined;
13
+ }
14
+ export interface UploadSettings extends ResourceSettings {
15
+ maxDownloads?: number | undefined;
16
+ }
17
+ export interface ResourceCredentials {
18
+ visibility: 'public' | 'private';
19
+ accessVersion: string;
20
+ accessToken?: string;
21
+ id: string;
22
+ expiresAt: string;
23
+ managementToken?: string;
24
+ inspectionToken?: string;
25
+ }
26
+ export interface CapturedRequest {
27
+ id: string;
28
+ method: string;
29
+ path: string;
30
+ rawQuery?: string;
31
+ headers: Record<string, string | string[]>;
32
+ query: Record<string, string | string[]>;
33
+ body: string;
34
+ bodyEncoding: 'utf8' | 'base64';
35
+ bodySize: number;
36
+ timestamp: string;
37
+ }
38
+ export interface InboxResponse {
39
+ status?: number;
40
+ contentType?: 'application/json' | 'text/plain' | 'application/xml' | 'text/xml';
41
+ body?: string;
42
+ headers?: Record<string, string>;
43
+ delayMs?: number;
44
+ }
45
+ export interface Execution {
46
+ toolId: string;
47
+ output: string;
48
+ usage: {
49
+ used: number;
50
+ limit: number;
51
+ resetsAt: string;
52
+ };
53
+ }
54
+ export declare class KivelError extends Error {
55
+ readonly status: number;
56
+ readonly requestId?: string | undefined;
57
+ readonly retryAfter?: number | undefined;
58
+ readonly requiredPlan?: string | undefined;
59
+ readonly upgradeUrl?: string | undefined;
60
+ constructor(message: string, status: number, requestId?: string | undefined, retryAfter?: number | undefined, requiredPlan?: string | undefined, upgradeUrl?: string | undefined);
61
+ }
62
+ export declare class Kivel {
63
+ private options;
64
+ readonly baseUrl: string;
65
+ private fetcher;
66
+ private timeoutMs;
67
+ constructor(options?: ClientOptions);
68
+ request<T = unknown>(method: string, path: string, body?: unknown, resourceToken?: string, headers?: Record<string, string>): Promise<T>;
69
+ tools(): Promise<{
70
+ tools: {
71
+ id: string;
72
+ name: string;
73
+ status: 'available' | 'coming-soon';
74
+ minimumPlan?: 'free' | 'pro' | 'team' | null;
75
+ execution: string | null;
76
+ description?: string;
77
+ guide?: {
78
+ action: string;
79
+ acceptsText: boolean;
80
+ acceptsFile: boolean;
81
+ inputLabel?: string;
82
+ inputExample?: string;
83
+ options: {
84
+ key: string;
85
+ label: string;
86
+ defaultValue: string;
87
+ choices?: [string, string][];
88
+ min?: number;
89
+ max?: number;
90
+ }[];
91
+ description?: string;
92
+ limits?: string;
93
+ steps?: string[];
94
+ example?: string;
95
+ };
96
+ }[];
97
+ }>;
98
+ tool(id: string): Promise<Record<string, unknown>>;
99
+ run(toolId: string, input?: string, options?: Record<string, string>, file?: {
100
+ name: string;
101
+ base64: string;
102
+ } | {
103
+ name: string;
104
+ base64: string;
105
+ }[]): Promise<Execution>;
106
+ plans(): Promise<unknown>;
107
+ activity(): Promise<unknown>;
108
+ startLogin(name: string, client?: string): Promise<AgentLogin>;
109
+ finishLogin(deviceCode: string): Promise<AgentToken>;
110
+ startTrial(name: string, humanEmail?: string, client?: string): Promise<AgentTrial>;
111
+ agents(): Promise<unknown>;
112
+ /** Only for accounts your human asked you to create or operate. */
113
+ addAuthenticator(input: AuthenticatorInput): Promise<Authenticator>;
114
+ listAuthenticators(): Promise<{
115
+ authenticators: Authenticator[];
116
+ limit: number;
117
+ }>;
118
+ getTotpCode(id: string): Promise<TotpCode>;
119
+ renameAuthenticator(id: string, name: string): Promise<{
120
+ id: string;
121
+ name: string;
122
+ }>;
123
+ deleteAuthenticator(id: string): Promise<void>;
124
+ getEmailAttachment(id: string, messageId: string, attachmentId: string): Promise<EmailAttachmentLink>;
125
+ downloadEmailAttachment(id: string, messageId: string, attachmentId: string): Promise<Uint8Array>;
126
+ createTestWallet(input: import('./types.js').TestWalletInput): Promise<import("./types.js").TestPaymentResource>;
127
+ createTestPaywall(input: import('./types.js').TestPaywallInput): Promise<import("./types.js").TestPaymentResource>;
128
+ createTestCheckout(input: import('./types.js').TestCheckoutInput): Promise<import("./types.js").TestPaymentResource & {
129
+ webhookSecret: string;
130
+ }>;
131
+ testPayments(kind: 'wallets' | 'paywalls' | 'checkouts'): Promise<{
132
+ testMode: true;
133
+ resources: import('./types.js').TestPaymentResource[];
134
+ }>;
135
+ testPayment(kind: 'wallets' | 'paywalls' | 'checkouts', id: string): Promise<import("./types.js").TestPaymentResource>;
136
+ updateTestPayment(kind: 'wallets' | 'paywalls' | 'checkouts', id: string, input: Partial<import('./types.js').TestWalletInput | import('./types.js').TestPaywallInput | import('./types.js').TestCheckoutInput>): Promise<import("./types.js").TestPaymentResource>;
137
+ deleteTestPayment(kind: 'wallets' | 'paywalls' | 'checkouts', id: string): Promise<void>;
138
+ walletBalance(id: string): Promise<import("./types.js").TestPaymentResource>;
139
+ topUpTestWallet(id: string, amount: number): Promise<{
140
+ testMode: true;
141
+ balance: number;
142
+ transaction: import('./types.js').TestTransaction;
143
+ }>;
144
+ walletPay(id: string, input: import('./types.js').TestPaymentInput): Promise<import("./types.js").TestPaymentResult>;
145
+ listWalletTransactions(id: string, options?: {
146
+ cursor?: string;
147
+ limit?: number;
148
+ }): Promise<{
149
+ testMode: true;
150
+ transactions: import('./types.js').TestTransaction[];
151
+ nextCursor?: string;
152
+ }>;
153
+ completeTestCheckout(id: string, input: {
154
+ idempotencyKey: string;
155
+ card: {
156
+ number: string;
157
+ expiry?: string;
158
+ cvc?: string;
159
+ };
160
+ }): Promise<import("./types.js").TestCheckoutAttempt>;
161
+ confirmTestCheckout(id: string, confirmationToken: string): Promise<import("./types.js").TestCheckoutAttempt>;
162
+ saveCredential(input: import('./types.js').CredentialInput): Promise<{
163
+ credential: import('./types.js').Credential;
164
+ password?: string;
165
+ }>;
166
+ credentials(): Promise<{
167
+ credentials: import('./types.js').Credential[];
168
+ limit: number;
169
+ }>;
170
+ credential(id: string): Promise<import("./types.js").Credential>;
171
+ updateCredential(id: string, input: Partial<import('./types.js').CredentialInput>): Promise<import("./types.js").Credential>;
172
+ deleteCredential(id: string): Promise<void>;
173
+ revealCredential(id: string, approvalId?: string): Promise<import("./types.js").CredentialReveal>;
174
+ generatePassword(length?: number): Promise<{
175
+ password: string;
176
+ }>;
177
+ createEmailInbox(settings?: import('./types.js').EmailInboxSettings): Promise<EmailInbox>;
178
+ emailInboxes(): Promise<{
179
+ inboxes: EmailInbox[];
180
+ }>;
181
+ clearEmails(id: string, token?: string): Promise<void>;
182
+ sendEmail(id: string, input: import('./types.js').SendEmailInput): Promise<{
183
+ id: string;
184
+ status: 'sent';
185
+ providerIds: string[];
186
+ }>;
187
+ emailThreads(id?: string, settings?: {
188
+ cursor?: string | undefined;
189
+ limit?: number | undefined;
190
+ }): Promise<EmailThreadsPage>;
191
+ emailThread(id: string, threadId: string): Promise<EmailThread>;
192
+ createEmailDraft(id: string, content: EmailContent): Promise<EmailDraft & {
193
+ content: EmailContent;
194
+ }>;
195
+ emailDrafts(id: string): Promise<{
196
+ drafts: EmailDraft[];
197
+ }>;
198
+ emailDraft(id: string): Promise<EmailDraft & {
199
+ content: EmailContent;
200
+ }>;
201
+ submitEmailDraft(id: string, settings?: {
202
+ approval?: boolean;
203
+ sendAt?: string;
204
+ }): Promise<EmailDraft & {
205
+ content: EmailContent;
206
+ }>;
207
+ deleteEmailDraft(id: string): Promise<void>;
208
+ emailInboxRules(id: string): Promise<{
209
+ rules: EmailRules;
210
+ }>;
211
+ waitForEvent(sources: import('./types.js').SocketEventSource[], timeoutSeconds?: number): Promise<{
212
+ timedOut: boolean;
213
+ events: import('./types.js').SocketEvent[];
214
+ }>;
215
+ emailForwarding(id: string, url: string | null, token?: string): Promise<{
216
+ forwardingUrl: string | null;
217
+ }>;
218
+ emailInbox(id: string, token?: string): Promise<EmailInbox>;
219
+ emails(id: string, token?: string): Promise<{
220
+ messages: EmailMessage[];
221
+ }>;
222
+ waitForEmail(id: string, options?: WaitOptions): Promise<{
223
+ timedOut: boolean;
224
+ messages: EmailMessage[];
225
+ }>;
226
+ memorySet<T>(namespace: string, key: string, value: T, ttlSeconds?: number): Promise<Omit<MemoryEntry<T>, "value">>;
227
+ memoryGet<T = unknown>(namespace: string, key: string): Promise<MemoryEntry<T>>;
228
+ memoryList(namespace: string, prefix?: string): Promise<{
229
+ keys: Omit<MemoryEntry, 'value'>[];
230
+ usedBytes: number;
231
+ limitBytes: number;
232
+ }>;
233
+ memoryDelete(namespace: string, key: string): Promise<void>;
234
+ availablePhoneNumbers(areaCode?: string): Promise<{
235
+ numbers: {
236
+ number: string;
237
+ monthlyCost: string;
238
+ upfrontCost: string;
239
+ currency: string;
240
+ }[];
241
+ }>;
242
+ createPhoneNumber(number: string, idempotencyKey: string): Promise<{
243
+ number: Record<string, unknown>;
244
+ }>;
245
+ listPhoneNumbers(): Promise<{
246
+ enabled: boolean;
247
+ numbers: Record<string, unknown>[];
248
+ }>;
249
+ releasePhoneNumber(id: string): Promise<void>;
250
+ listSms(id: string): Promise<{
251
+ messages: Record<string, unknown>[];
252
+ }>;
253
+ waitForSms(id: string, options?: {
254
+ after?: string;
255
+ timeoutSeconds?: number;
256
+ }): Promise<{
257
+ timedOut: boolean;
258
+ messages: Record<string, unknown>[];
259
+ }>;
260
+ createSmtpInbox(settings?: ResourceSettings): Promise<{
261
+ id: string;
262
+ expiresAt: string;
263
+ smtp: {
264
+ host: string;
265
+ port: number;
266
+ secure: boolean;
267
+ username: string;
268
+ password: string;
269
+ };
270
+ }>;
271
+ smtpInbox(id: string): Promise<{
272
+ id: string;
273
+ expiresAt: string;
274
+ smtp: {
275
+ host: string;
276
+ port: number;
277
+ secure: boolean;
278
+ username: string;
279
+ };
280
+ enabled: boolean;
281
+ }>;
282
+ rotateSmtpPassword(id: string): Promise<{
283
+ smtp: {
284
+ host: string;
285
+ port: number;
286
+ secure: boolean;
287
+ username: string;
288
+ password: string;
289
+ };
290
+ }>;
291
+ createScheduledJob(config: {
292
+ name: string;
293
+ url: string;
294
+ body?: unknown;
295
+ delaySeconds?: number;
296
+ startAt?: string;
297
+ intervalSeconds?: number;
298
+ maxRuns?: number;
299
+ }, settings?: ResourceSettings): Promise<{
300
+ id: string;
301
+ status: string;
302
+ nextRunAt: string;
303
+ }>;
304
+ scheduledJobs(): Promise<{
305
+ jobs: Record<string, unknown>[];
306
+ }>;
307
+ scheduledJob(id: string): Promise<Record<string, unknown>>;
308
+ cancelScheduledJob(id: string): Promise<void>;
309
+ createStatusPage(config: {
310
+ name: string;
311
+ description?: string;
312
+ monitorIds: string[];
313
+ }, settings?: ResourceSettings): Promise<{
314
+ id: string;
315
+ pageUrl: string;
316
+ expiresAt: string;
317
+ accessToken?: string;
318
+ }>;
319
+ updateStatusPage(id: string, config: {
320
+ name: string;
321
+ description?: string;
322
+ monitorIds: string[];
323
+ }): Promise<unknown>;
324
+ acceptDnsChanges(id: string): Promise<{
325
+ accepted: boolean;
326
+ }>;
327
+ createMonitor(settings: MonitorInput): Promise<Monitor>;
328
+ monitors(): Promise<{
329
+ monitors: Monitor[];
330
+ limit: number;
331
+ minIntervalSeconds: number;
332
+ }>;
333
+ monitor(id: string): Promise<Monitor>;
334
+ pingMonitor(token: string, failed?: boolean): Promise<{
335
+ ok: true;
336
+ status: 'up' | 'down';
337
+ }>;
338
+ pauseMonitor(id: string, paused?: boolean): Promise<{
339
+ paused: boolean;
340
+ }>;
341
+ deleteMonitor(id: string): Promise<void>;
342
+ askHuman(input: ApprovalInput): Promise<Approval>;
343
+ approvals(pendingOnly?: boolean): Promise<{
344
+ approvals: Approval[];
345
+ }>;
346
+ approval(id: string): Promise<Approval>;
347
+ waitForApproval(id: string, timeoutSeconds?: number): Promise<Approval & {
348
+ timedOut: boolean;
349
+ }>;
350
+ inspectResource(kind: 'inboxes' | 'mocks' | 'files' | 'mcp-servers' | 'email-inboxes' | 'status-pages', id: string, token?: string): Promise<unknown>;
351
+ updateMock(id: string, config: unknown, token?: string): Promise<unknown>;
352
+ resetMock(id: string, token?: string): Promise<unknown>;
353
+ mockCalls(id: string, token?: string): Promise<unknown>;
354
+ setInboxForward(id: string, url: string | null, token?: string): Promise<unknown>;
355
+ inboxDeliveries(id: string, token?: string): Promise<unknown>;
356
+ private waitTimeout;
357
+ private waitQuery;
358
+ usage(): Promise<unknown>;
359
+ resources(): Promise<unknown>;
360
+ /** Senders can POST to webhookUrl without credentials by default. Inspection stays private.
361
+ * Set visibility to private to require X-Access-Token on incoming webhooks. */
362
+ createInbox(settings?: ResourceSettings): Promise<ResourceCredentials & {
363
+ webhookUrl: string;
364
+ }>;
365
+ inspectInbox(id: string, token?: string): Promise<unknown>;
366
+ /**
367
+ * Long-polls until the inbox captures a request newer than `after` (any request when omitted).
368
+ * Resolves with `timedOut: true` when nothing arrives; call again to keep waiting.
369
+ */
370
+ waitForRequests(id: string, options?: {
371
+ token?: string;
372
+ after?: string;
373
+ timeoutSeconds?: number;
374
+ }): Promise<{
375
+ timedOut: boolean;
376
+ requests: CapturedRequest[];
377
+ }>;
378
+ setInboxResponse(id: string, response: InboxResponse | null, token?: string): Promise<unknown>;
379
+ createOAuthProvider(config: OAuthProviderInput, settings?: Omit<ResourceSettings, 'visibility'>): Promise<CreatedOAuthProvider>;
380
+ oauthProvider(id: string): Promise<OAuthProvider>;
381
+ oauthProviders(): Promise<{
382
+ providers: OAuthProvider[];
383
+ }>;
384
+ updateOAuthProvider(id: string, config: OAuthProviderInput): Promise<void>;
385
+ deleteOAuthProvider(id: string): Promise<void>;
386
+ createMock(config: unknown, settings?: ResourceSettings): Promise<ResourceCredentials & {
387
+ endpointUrl: string;
388
+ }>;
389
+ createMcpServer(config: unknown, settings?: ResourceSettings): Promise<ResourceCredentials & {
390
+ endpointUrl: string;
391
+ }>;
392
+ upload(name: string, data: Uint8Array, settings?: UploadSettings): Promise<ResourceCredentials & {
393
+ downloadUrl: string;
394
+ }>;
395
+ sharing(kind: 'inboxes' | 'mocks' | 'files' | 'mcp-servers' | 'status-pages', id: string, visibility: 'public' | 'private', token?: string): Promise<{
396
+ visibility: 'public' | 'private';
397
+ accessVersion: string;
398
+ accessToken?: string;
399
+ }>;
400
+ downloadFile(id: string, accessToken?: string): Promise<Uint8Array>;
401
+ remove(kind: 'inboxes' | 'mocks' | 'files' | 'mcp-servers' | 'email-inboxes' | 'status-pages', id: string, token?: string): Promise<void>;
402
+ renew(kind: 'inboxes' | 'mocks' | 'files' | 'mcp-servers' | 'email-inboxes' | 'status-pages', id: string, settings?: {
403
+ persistent?: boolean;
404
+ }, token?: string): Promise<{
405
+ id: string;
406
+ expiresAt: string;
407
+ persistent: boolean;
408
+ }>;
409
+ }