@kivel.io/sdk 0.0.0-stage → 0.6.1

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,358 @@
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
+ createEmailInbox(settings?: import('./types.js').EmailInboxSettings): Promise<EmailInbox>;
127
+ emailInboxes(): Promise<{
128
+ inboxes: EmailInbox[];
129
+ }>;
130
+ clearEmails(id: string, token?: string): Promise<void>;
131
+ sendEmail(id: string, input: import('./types.js').SendEmailInput): Promise<{
132
+ id: string;
133
+ status: 'sent';
134
+ providerIds: string[];
135
+ }>;
136
+ emailThreads(id?: string, settings?: {
137
+ cursor?: string | undefined;
138
+ limit?: number | undefined;
139
+ }): Promise<EmailThreadsPage>;
140
+ emailThread(id: string, threadId: string): Promise<EmailThread>;
141
+ createEmailDraft(id: string, content: EmailContent): Promise<EmailDraft & {
142
+ content: EmailContent;
143
+ }>;
144
+ emailDrafts(id: string): Promise<{
145
+ drafts: EmailDraft[];
146
+ }>;
147
+ emailDraft(id: string): Promise<EmailDraft & {
148
+ content: EmailContent;
149
+ }>;
150
+ submitEmailDraft(id: string, settings?: {
151
+ approval?: boolean;
152
+ sendAt?: string;
153
+ }): Promise<EmailDraft & {
154
+ content: EmailContent;
155
+ }>;
156
+ deleteEmailDraft(id: string): Promise<void>;
157
+ emailInboxRules(id: string): Promise<{
158
+ rules: EmailRules;
159
+ }>;
160
+ waitForEvent(sources: import('./types.js').SocketEventSource[], timeoutSeconds?: number): Promise<{
161
+ timedOut: boolean;
162
+ events: import('./types.js').SocketEvent[];
163
+ }>;
164
+ emailForwarding(id: string, url: string | null, token?: string): Promise<{
165
+ forwardingUrl: string | null;
166
+ }>;
167
+ emailInbox(id: string, token?: string): Promise<EmailInbox>;
168
+ emails(id: string, token?: string): Promise<{
169
+ messages: EmailMessage[];
170
+ }>;
171
+ waitForEmail(id: string, options?: WaitOptions): Promise<{
172
+ timedOut: boolean;
173
+ messages: EmailMessage[];
174
+ }>;
175
+ memorySet<T>(namespace: string, key: string, value: T, ttlSeconds?: number): Promise<Omit<MemoryEntry<T>, "value">>;
176
+ memoryGet<T = unknown>(namespace: string, key: string): Promise<MemoryEntry<T>>;
177
+ memoryList(namespace: string, prefix?: string): Promise<{
178
+ keys: Omit<MemoryEntry, 'value'>[];
179
+ usedBytes: number;
180
+ limitBytes: number;
181
+ }>;
182
+ memoryDelete(namespace: string, key: string): Promise<void>;
183
+ availablePhoneNumbers(areaCode?: string): Promise<{
184
+ numbers: {
185
+ number: string;
186
+ monthlyCost: string;
187
+ upfrontCost: string;
188
+ currency: string;
189
+ }[];
190
+ }>;
191
+ createPhoneNumber(number: string, idempotencyKey: string): Promise<{
192
+ number: Record<string, unknown>;
193
+ }>;
194
+ listPhoneNumbers(): Promise<{
195
+ enabled: boolean;
196
+ numbers: Record<string, unknown>[];
197
+ }>;
198
+ releasePhoneNumber(id: string): Promise<void>;
199
+ listSms(id: string): Promise<{
200
+ messages: Record<string, unknown>[];
201
+ }>;
202
+ waitForSms(id: string, options?: {
203
+ after?: string;
204
+ timeoutSeconds?: number;
205
+ }): Promise<{
206
+ timedOut: boolean;
207
+ messages: Record<string, unknown>[];
208
+ }>;
209
+ createSmtpInbox(settings?: ResourceSettings): Promise<{
210
+ id: string;
211
+ expiresAt: string;
212
+ smtp: {
213
+ host: string;
214
+ port: number;
215
+ secure: boolean;
216
+ username: string;
217
+ password: string;
218
+ };
219
+ }>;
220
+ smtpInbox(id: string): Promise<{
221
+ id: string;
222
+ expiresAt: string;
223
+ smtp: {
224
+ host: string;
225
+ port: number;
226
+ secure: boolean;
227
+ username: string;
228
+ };
229
+ enabled: boolean;
230
+ }>;
231
+ rotateSmtpPassword(id: string): Promise<{
232
+ smtp: {
233
+ host: string;
234
+ port: number;
235
+ secure: boolean;
236
+ username: string;
237
+ password: string;
238
+ };
239
+ }>;
240
+ createScheduledJob(config: {
241
+ name: string;
242
+ url: string;
243
+ body?: unknown;
244
+ delaySeconds?: number;
245
+ startAt?: string;
246
+ intervalSeconds?: number;
247
+ maxRuns?: number;
248
+ }, settings?: ResourceSettings): Promise<{
249
+ id: string;
250
+ status: string;
251
+ nextRunAt: string;
252
+ }>;
253
+ scheduledJobs(): Promise<{
254
+ jobs: Record<string, unknown>[];
255
+ }>;
256
+ scheduledJob(id: string): Promise<Record<string, unknown>>;
257
+ cancelScheduledJob(id: string): Promise<void>;
258
+ createStatusPage(config: {
259
+ name: string;
260
+ description?: string;
261
+ monitorIds: string[];
262
+ }, settings?: ResourceSettings): Promise<{
263
+ id: string;
264
+ pageUrl: string;
265
+ expiresAt: string;
266
+ accessToken?: string;
267
+ }>;
268
+ updateStatusPage(id: string, config: {
269
+ name: string;
270
+ description?: string;
271
+ monitorIds: string[];
272
+ }): Promise<unknown>;
273
+ acceptDnsChanges(id: string): Promise<{
274
+ accepted: boolean;
275
+ }>;
276
+ createMonitor(settings: MonitorInput): Promise<Monitor>;
277
+ monitors(): Promise<{
278
+ monitors: Monitor[];
279
+ limit: number;
280
+ minIntervalSeconds: number;
281
+ }>;
282
+ monitor(id: string): Promise<Monitor>;
283
+ pingMonitor(token: string, failed?: boolean): Promise<{
284
+ ok: true;
285
+ status: 'up' | 'down';
286
+ }>;
287
+ pauseMonitor(id: string, paused?: boolean): Promise<{
288
+ paused: boolean;
289
+ }>;
290
+ deleteMonitor(id: string): Promise<void>;
291
+ askHuman(input: ApprovalInput): Promise<Approval>;
292
+ approvals(pendingOnly?: boolean): Promise<{
293
+ approvals: Approval[];
294
+ }>;
295
+ approval(id: string): Promise<Approval>;
296
+ waitForApproval(id: string, timeoutSeconds?: number): Promise<Approval & {
297
+ timedOut: boolean;
298
+ }>;
299
+ inspectResource(kind: 'inboxes' | 'mocks' | 'files' | 'mcp-servers' | 'email-inboxes' | 'status-pages', id: string, token?: string): Promise<unknown>;
300
+ updateMock(id: string, config: unknown, token?: string): Promise<unknown>;
301
+ resetMock(id: string, token?: string): Promise<unknown>;
302
+ mockCalls(id: string, token?: string): Promise<unknown>;
303
+ setInboxForward(id: string, url: string | null, token?: string): Promise<unknown>;
304
+ inboxDeliveries(id: string, token?: string): Promise<unknown>;
305
+ private waitTimeout;
306
+ private waitQuery;
307
+ usage(): Promise<unknown>;
308
+ resources(): Promise<unknown>;
309
+ /** Senders can POST to webhookUrl without credentials by default. Inspection stays private.
310
+ * Set visibility to private to require X-Access-Token on incoming webhooks. */
311
+ createInbox(settings?: ResourceSettings): Promise<ResourceCredentials & {
312
+ webhookUrl: string;
313
+ }>;
314
+ inspectInbox(id: string, token?: string): Promise<unknown>;
315
+ /**
316
+ * Long-polls until the inbox captures a request newer than `after` (any request when omitted).
317
+ * Resolves with `timedOut: true` when nothing arrives; call again to keep waiting.
318
+ */
319
+ waitForRequests(id: string, options?: {
320
+ token?: string;
321
+ after?: string;
322
+ timeoutSeconds?: number;
323
+ }): Promise<{
324
+ timedOut: boolean;
325
+ requests: CapturedRequest[];
326
+ }>;
327
+ setInboxResponse(id: string, response: InboxResponse | null, token?: string): Promise<unknown>;
328
+ createOAuthProvider(config: OAuthProviderInput, settings?: Omit<ResourceSettings, 'visibility'>): Promise<CreatedOAuthProvider>;
329
+ oauthProvider(id: string): Promise<OAuthProvider>;
330
+ oauthProviders(): Promise<{
331
+ providers: OAuthProvider[];
332
+ }>;
333
+ updateOAuthProvider(id: string, config: OAuthProviderInput): Promise<void>;
334
+ deleteOAuthProvider(id: string): Promise<void>;
335
+ createMock(config: unknown, settings?: ResourceSettings): Promise<ResourceCredentials & {
336
+ endpointUrl: string;
337
+ }>;
338
+ createMcpServer(config: unknown, settings?: ResourceSettings): Promise<ResourceCredentials & {
339
+ endpointUrl: string;
340
+ }>;
341
+ upload(name: string, data: Uint8Array, settings?: UploadSettings): Promise<ResourceCredentials & {
342
+ downloadUrl: string;
343
+ }>;
344
+ sharing(kind: 'inboxes' | 'mocks' | 'files' | 'mcp-servers' | 'status-pages', id: string, visibility: 'public' | 'private', token?: string): Promise<{
345
+ visibility: 'public' | 'private';
346
+ accessVersion: string;
347
+ accessToken?: string;
348
+ }>;
349
+ downloadFile(id: string, accessToken?: string): Promise<Uint8Array>;
350
+ remove(kind: 'inboxes' | 'mocks' | 'files' | 'mcp-servers' | 'email-inboxes' | 'status-pages', id: string, token?: string): Promise<void>;
351
+ renew(kind: 'inboxes' | 'mocks' | 'files' | 'mcp-servers' | 'email-inboxes' | 'status-pages', id: string, settings?: {
352
+ persistent?: boolean;
353
+ }, token?: string): Promise<{
354
+ id: string;
355
+ expiresAt: string;
356
+ persistent: boolean;
357
+ }>;
358
+ }