@autenai/sdk 0.4.0 → 0.5.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.
Files changed (88) hide show
  1. package/README.md +154 -0
  2. package/bin/auten.js +2 -0
  3. package/dist/cli/add-phone.d.ts +2 -0
  4. package/dist/cli/add-phone.d.ts.map +1 -0
  5. package/dist/cli/add-phone.js +254 -0
  6. package/dist/cli/add-phone.js.map +1 -0
  7. package/dist/cli/autocomplete.d.ts +31 -0
  8. package/dist/cli/autocomplete.d.ts.map +1 -0
  9. package/dist/cli/autocomplete.js +438 -0
  10. package/dist/cli/autocomplete.js.map +1 -0
  11. package/dist/cli/build-apk.d.ts +2 -0
  12. package/dist/cli/build-apk.d.ts.map +1 -0
  13. package/dist/cli/build-apk.js +97 -0
  14. package/dist/cli/build-apk.js.map +1 -0
  15. package/dist/cli/creds.d.ts +2 -0
  16. package/dist/cli/creds.d.ts.map +1 -0
  17. package/dist/cli/creds.js +147 -0
  18. package/dist/cli/creds.js.map +1 -0
  19. package/dist/cli/devices.d.ts +2 -0
  20. package/dist/cli/devices.d.ts.map +1 -0
  21. package/dist/cli/devices.js +38 -0
  22. package/dist/cli/devices.js.map +1 -0
  23. package/dist/cli/index.d.ts +2 -0
  24. package/dist/cli/index.d.ts.map +1 -0
  25. package/dist/cli/index.js +111 -0
  26. package/dist/cli/index.js.map +1 -0
  27. package/dist/cli/keys.d.ts +2 -0
  28. package/dist/cli/keys.d.ts.map +1 -0
  29. package/dist/cli/keys.js +88 -0
  30. package/dist/cli/keys.js.map +1 -0
  31. package/dist/cli/login.d.ts +2 -0
  32. package/dist/cli/login.d.ts.map +1 -0
  33. package/dist/cli/login.js +35 -0
  34. package/dist/cli/login.js.map +1 -0
  35. package/dist/cli/logo.d.ts +2 -0
  36. package/dist/cli/logo.d.ts.map +1 -0
  37. package/dist/cli/logo.js +11 -0
  38. package/dist/cli/logo.js.map +1 -0
  39. package/dist/cli/me.d.ts +2 -0
  40. package/dist/cli/me.d.ts.map +1 -0
  41. package/dist/cli/me.js +19 -0
  42. package/dist/cli/me.js.map +1 -0
  43. package/dist/cli/shell.d.ts +2 -0
  44. package/dist/cli/shell.d.ts.map +1 -0
  45. package/dist/cli/shell.js +22 -0
  46. package/dist/cli/shell.js.map +1 -0
  47. package/dist/cli/task.d.ts +2 -0
  48. package/dist/cli/task.d.ts.map +1 -0
  49. package/dist/cli/task.js +148 -0
  50. package/dist/cli/task.js.map +1 -0
  51. package/dist/cli/tasks.d.ts +2 -0
  52. package/dist/cli/tasks.d.ts.map +1 -0
  53. package/dist/cli/tasks.js +76 -0
  54. package/dist/cli/tasks.js.map +1 -0
  55. package/dist/cli/util.d.ts +46 -0
  56. package/dist/cli/util.d.ts.map +1 -0
  57. package/dist/cli/util.js +134 -0
  58. package/dist/cli/util.js.map +1 -0
  59. package/dist/package.json +56 -0
  60. package/dist/src/client.d.ts +81 -0
  61. package/dist/src/client.d.ts.map +1 -0
  62. package/dist/src/client.js +116 -0
  63. package/dist/src/client.js.map +1 -0
  64. package/dist/src/errors.d.ts +16 -0
  65. package/dist/src/errors.d.ts.map +1 -0
  66. package/dist/src/errors.js +31 -0
  67. package/dist/src/errors.js.map +1 -0
  68. package/dist/src/index.d.ts +7 -0
  69. package/dist/src/index.d.ts.map +1 -0
  70. package/dist/src/index.js +5 -0
  71. package/dist/src/index.js.map +1 -0
  72. package/dist/src/phone.d.ts +115 -0
  73. package/dist/src/phone.d.ts.map +1 -0
  74. package/dist/src/phone.js +123 -0
  75. package/dist/src/phone.js.map +1 -0
  76. package/dist/src/transport.d.ts +14 -0
  77. package/dist/src/transport.d.ts.map +1 -0
  78. package/dist/src/transport.js +71 -0
  79. package/dist/src/transport.js.map +1 -0
  80. package/dist/src/types.d.ts +138 -0
  81. package/dist/src/types.d.ts.map +1 -0
  82. package/dist/src/types.js +2 -0
  83. package/dist/src/types.js.map +1 -0
  84. package/package.json +43 -26
  85. package/dist/index.d.mts +0 -500
  86. package/dist/index.d.ts +0 -500
  87. package/dist/index.js +0 -450
  88. package/dist/index.mjs +0 -418
package/dist/index.mjs DELETED
@@ -1,418 +0,0 @@
1
- // src/errors.ts
2
- var AutenError = class extends Error {
3
- constructor(message) {
4
- super(message);
5
- this.name = "AutenError";
6
- }
7
- };
8
- var AutenApiError = class extends AutenError {
9
- code;
10
- statusCode;
11
- details;
12
- constructor(code, message, statusCode, details) {
13
- super(message);
14
- this.name = "AutenApiError";
15
- this.code = code;
16
- this.statusCode = statusCode;
17
- this.details = details;
18
- }
19
- };
20
- var AutenAuthError = class extends AutenApiError {
21
- constructor(message, code = "UNAUTHORIZED") {
22
- super(code, message, 401);
23
- this.name = "AutenAuthError";
24
- }
25
- };
26
- var AutenRateLimitError = class extends AutenApiError {
27
- retryAfter;
28
- constructor(message, retryAfter) {
29
- super("RATE_LIMIT_EXCEEDED", message, 429, { retryAfter });
30
- this.name = "AutenRateLimitError";
31
- this.retryAfter = retryAfter;
32
- }
33
- };
34
- var AutenNotFoundError = class extends AutenApiError {
35
- constructor(message) {
36
- super("RESOURCE_NOT_FOUND", message, 404);
37
- this.name = "AutenNotFoundError";
38
- }
39
- };
40
-
41
- // src/client.ts
42
- var HttpClient = class {
43
- config;
44
- constructor(config) {
45
- this.config = config;
46
- }
47
- async get(path) {
48
- return this.request("GET", path);
49
- }
50
- async post(path, body) {
51
- return this.request("POST", path, body);
52
- }
53
- async del(path) {
54
- return this.request("DELETE", path);
55
- }
56
- async request(method, path, body) {
57
- const url = `${this.config.baseUrl}${path}`;
58
- let lastError = null;
59
- for (let attempt = 0; attempt <= this.config.retries; attempt++) {
60
- try {
61
- const controller = new AbortController();
62
- const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
63
- const response = await fetch(url, {
64
- method,
65
- headers: {
66
- "Authorization": `Bearer ${this.config.apiKey}`,
67
- "Content-Type": "application/json",
68
- "User-Agent": "@auten/sdk"
69
- },
70
- body: body ? JSON.stringify(body) : void 0,
71
- signal: controller.signal
72
- });
73
- clearTimeout(timeoutId);
74
- if (response.status === 204) {
75
- return void 0;
76
- }
77
- const data = await response.json();
78
- if (response.ok && data.success) {
79
- return data.data;
80
- }
81
- const errorData = data;
82
- const errorCode = errorData.error?.code || "UNKNOWN";
83
- const errorMessage = errorData.error?.message || "Unknown error";
84
- const errorDetails = errorData.error?.details;
85
- if (response.status === 429) {
86
- const retryAfter = errorDetails?.retryAfter || 5;
87
- if (attempt < this.config.retries) {
88
- await this.sleep(retryAfter * 1e3);
89
- continue;
90
- }
91
- throw new AutenRateLimitError(errorMessage, retryAfter);
92
- }
93
- if (response.status === 401) {
94
- throw new AutenAuthError(errorMessage, errorCode);
95
- }
96
- if (response.status === 404) {
97
- throw new AutenNotFoundError(errorMessage);
98
- }
99
- if (response.status >= 500 && attempt < this.config.retries) {
100
- lastError = new AutenApiError(errorCode, errorMessage, response.status, errorDetails);
101
- await this.sleep(Math.pow(2, attempt) * 1e3);
102
- continue;
103
- }
104
- throw new AutenApiError(errorCode, errorMessage, response.status, errorDetails);
105
- } catch (error) {
106
- if (error instanceof AutenApiError) {
107
- throw error;
108
- }
109
- if (error instanceof Error && error.name === "AbortError") {
110
- lastError = new AutenError(`Request timed out after ${this.config.timeout}ms`);
111
- } else {
112
- lastError = error;
113
- }
114
- if (attempt < this.config.retries) {
115
- await this.sleep(Math.pow(2, attempt) * 1e3);
116
- continue;
117
- }
118
- }
119
- }
120
- throw lastError || new AutenError("Request failed after retries");
121
- }
122
- sleep(ms) {
123
- return new Promise((resolve) => setTimeout(resolve, ms));
124
- }
125
- };
126
-
127
- // src/providers.ts
128
- var ProviderClient = class {
129
- constructor(client) {
130
- this.client = client;
131
- }
132
- /**
133
- * List all connected providers for the authenticated user.
134
- */
135
- async list() {
136
- return this.client.get("/api/v1/sdk/providers");
137
- }
138
- /**
139
- * Execute an action on a provider.
140
- *
141
- * @example
142
- * const result = await auten.providers.execute('google-gmail', 'listEmails', { query: 'is:unread' });
143
- */
144
- async execute(slug, action, params) {
145
- return this.client.post(`/api/v1/sdk/providers/${slug}/execute`, {
146
- action,
147
- params
148
- });
149
- }
150
- /**
151
- * Get a valid access token for a provider.
152
- * Token is automatically refreshed if expired.
153
- *
154
- * @example
155
- * const { accessToken } = await auten.providers.getCredentials('google-gmail');
156
- */
157
- async getCredentials(slug) {
158
- return this.client.get(`/api/v1/sdk/providers/${slug}/credentials`);
159
- }
160
- };
161
-
162
- // src/agents.ts
163
- var AgentClient = class {
164
- constructor(client) {
165
- this.client = client;
166
- }
167
- /**
168
- * List all agents for the authenticated user.
169
- */
170
- async list() {
171
- return this.client.get("/api/v1/sdk/agents");
172
- }
173
- /**
174
- * Get agent details including tools and schedule.
175
- */
176
- async get(id) {
177
- return this.client.get(`/api/v1/sdk/agents/${id}`);
178
- }
179
- /**
180
- * Create a new agent.
181
- *
182
- * @example
183
- * const agent = await auten.agents.create({
184
- * name: 'Invoice Processor',
185
- * tools: [{ name: 'process-invoice', code: '...' }],
186
- * schedule: { cron: '0 9 * * *', timezone: 'Europe/Vilnius' },
187
- * });
188
- */
189
- async create(options) {
190
- return this.client.post("/api/v1/sdk/agents", options);
191
- }
192
- /**
193
- * Deploy tools to an existing agent.
194
- * Upserts tool code and updates the agent configuration.
195
- *
196
- * @example
197
- * await auten.agents.deploy('agent-id', {
198
- * tools: [{ name: 'fetch-data', code: '...' }],
199
- * });
200
- */
201
- async deploy(id, options) {
202
- return this.client.post(`/api/v1/sdk/agents/${id}/deploy`, options);
203
- }
204
- /**
205
- * Trigger an agent run.
206
- *
207
- * @example
208
- * const { executionId } = await auten.agents.run('agent-id', { inputData: '...' });
209
- */
210
- async run(id, data) {
211
- return this.client.post(`/api/v1/agents/${id}/run`, data);
212
- }
213
- /**
214
- * Get agent status.
215
- */
216
- async status(id) {
217
- return this.client.get(`/api/v1/agents/${id}/status`);
218
- }
219
- /**
220
- * Get agent run history.
221
- */
222
- async history(id) {
223
- return this.client.get(`/api/v1/agents/${id}/history`);
224
- }
225
- /**
226
- * Delete an agent and all its knowledge/tools.
227
- */
228
- async delete(id) {
229
- await this.client.del(`/api/v1/sdk/agents/${id}`);
230
- }
231
- };
232
-
233
- // src/ai.ts
234
- var AIClient = class {
235
- constructor(client) {
236
- this.client = client;
237
- }
238
- /**
239
- * Execute a task using AI to interpret and call the right provider APIs.
240
- *
241
- * @example
242
- * const result = await auten.ai.execute(
243
- * 'google-sheets',
244
- * 'Find Q1 revenue totals and create a summary row'
245
- * );
246
- *
247
- * @example
248
- * const result = await auten.ai.execute(
249
- * 'zoho-crm',
250
- * 'Find all deals closing this month worth over $10k',
251
- * { currency: 'USD' }
252
- * );
253
- */
254
- async execute(provider, task, context) {
255
- return this.client.post("/api/v1/sdk/ai/execute", {
256
- provider,
257
- task,
258
- context
259
- });
260
- }
261
- /**
262
- * Execute a cross-provider task using natural language.
263
- * AI breaks the task into steps, executes each with the right provider,
264
- * and transforms data between them automatically.
265
- *
266
- * @example
267
- * const result = await auten.ai.chain(
268
- * 'Paimk Shopify užsakymus ir sudėk į Google Sheets'
269
- * );
270
- *
271
- * @example
272
- * const result = await auten.ai.chain(
273
- * 'Find Jira bugs from this week, group by severity, and post summary to Slack #dev'
274
- * );
275
- */
276
- async chain(task, context) {
277
- return this.client.post("/api/v1/sdk/ai/chain", {
278
- task,
279
- context
280
- });
281
- }
282
- };
283
-
284
- // src/webhooks.ts
285
- var WebhookClient = class {
286
- constructor(client) {
287
- this.client = client;
288
- }
289
- /**
290
- * List all registered webhooks.
291
- */
292
- async list() {
293
- return this.client.get("/api/v1/sdk/webhooks");
294
- }
295
- /**
296
- * Register a webhook to receive provider events.
297
- *
298
- * @example
299
- * await auten.webhooks.register({
300
- * event: 'slack:message:thread',
301
- * callbackUrl: 'https://myapp.com/api/auten-webhook',
302
- * provider: 'slack',
303
- * });
304
- */
305
- async register(options) {
306
- return this.client.post("/api/v1/sdk/webhooks", options);
307
- }
308
- /**
309
- * Delete a webhook.
310
- */
311
- async delete(id) {
312
- await this.client.del(`/api/v1/sdk/webhooks?id=${id}`);
313
- }
314
- };
315
- var EventClient = class {
316
- constructor(client) {
317
- this.client = client;
318
- }
319
- /**
320
- * Poll for new events since a timestamp.
321
- * Alternative to webhooks for serverless environments.
322
- *
323
- * @example
324
- * const { events } = await auten.events.poll({
325
- * since: new Date(Date.now() - 60000).toISOString(), // last minute
326
- * provider: 'slack',
327
- * });
328
- */
329
- async poll(options) {
330
- const params = new URLSearchParams();
331
- if (options?.since) params.set("since", options.since);
332
- if (options?.provider) params.set("provider", options.provider);
333
- if (options?.limit) params.set("limit", String(options.limit));
334
- const query = params.toString();
335
- return this.client.get(`/api/v1/sdk/events${query ? "?" + query : ""}`);
336
- }
337
- };
338
-
339
- // src/conversations.ts
340
- var ConversationClient = class {
341
- constructor(client) {
342
- this.client = client;
343
- }
344
- /**
345
- * Create a new conversation bridge.
346
- *
347
- * This posts to Slack and sets up the full bridge:
348
- * - You reply in Slack thread → AI generates professional email → sends to customer
349
- * - Customer replies to email → appears in Slack thread
350
- * - Repeat — full conversation via Slack
351
- *
352
- * @example
353
- * // From a contact form handler:
354
- * const conv = await auten.conversations.create({
355
- * customerName: 'Jonas Jonaitis',
356
- * customerEmail: 'jonas@test.lt',
357
- * message: 'Norėčiau sužinoti apie jūsų paslaugas',
358
- * channel: '#sales',
359
- * brandName: 'My Company',
360
- * brandSignOff: 'Pagarbiai,\nMy Company komanda\n+370 600 00000',
361
- * });
362
- * // That's it. Reply in Slack — AI handles the rest.
363
- */
364
- async create(options) {
365
- return this.client.post("/api/v1/sdk/conversations", options);
366
- }
367
- /**
368
- * List all conversations.
369
- */
370
- async list() {
371
- return this.client.get("/api/v1/sdk/conversations");
372
- }
373
- };
374
-
375
- // src/index.ts
376
- var DEFAULT_BASE_URL = "https://auten.ai";
377
- var DEFAULT_TIMEOUT = 3e4;
378
- var DEFAULT_RETRIES = 3;
379
- var Auten = class {
380
- /** Provider connections and execution */
381
- providers;
382
- /** Agent management */
383
- agents;
384
- /** AI-powered execution */
385
- ai;
386
- /** Webhook registration */
387
- webhooks;
388
- /** Event polling */
389
- events;
390
- /** Conversation bridges (Slack ↔ Email) */
391
- conversations;
392
- client;
393
- constructor(config) {
394
- if (!config.apiKey) {
395
- throw new AutenError("apiKey is required. Get one at https://auten.ai/settings \u2192 API Keys");
396
- }
397
- this.client = new HttpClient({
398
- apiKey: config.apiKey,
399
- baseUrl: (config.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, ""),
400
- timeout: config.timeout || DEFAULT_TIMEOUT,
401
- retries: config.retries ?? DEFAULT_RETRIES
402
- });
403
- this.providers = new ProviderClient(this.client);
404
- this.agents = new AgentClient(this.client);
405
- this.ai = new AIClient(this.client);
406
- this.webhooks = new WebhookClient(this.client);
407
- this.events = new EventClient(this.client);
408
- this.conversations = new ConversationClient(this.client);
409
- }
410
- };
411
- export {
412
- Auten,
413
- AutenApiError,
414
- AutenAuthError,
415
- AutenError,
416
- AutenNotFoundError,
417
- AutenRateLimitError
418
- };