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