@airtop/sdk 1.0.0-alpha2.2 → 1.0.0-alpha2.20

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/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __getOwnPropNames = Object.getOwnPropertyNames;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var __getOwnPropNames = Object.getOwnPropertyNames;
2
2
  var __commonJS = (cb, mod) => function __require() {
3
3
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
4
  };
@@ -9,7 +9,7 @@ var require_package = __commonJS({
9
9
  module.exports = {
10
10
  name: "@airtop/sdk",
11
11
  description: "Airtop SDK for TypeScript",
12
- version: "1.0.0-alpha2.2",
12
+ version: "1.0.0-alpha2.20",
13
13
  type: "module",
14
14
  main: "./dist/index.cjs",
15
15
  module: "./dist/index.js",
@@ -38,34 +38,35 @@ var require_package = __commonJS({
38
38
  "agentic"
39
39
  ],
40
40
  scripts: {
41
- "build:second-stage": "tsup src/index.ts",
42
41
  "test:e2e": "vitest --run",
43
42
  "build:dev": "node_modules/.bin/hash-runner",
43
+ build: "tsup src/index.ts",
44
44
  clean: "rm -rf .turbo node_modules dist",
45
- lint: "biome check --write --unsafe src && biome format src --write && biome lint src --fix",
45
+ lint: "biome check --no-errors-on-unmatched --write --unsafe src",
46
+ "lint:staged": "biome check --no-errors-on-unmatched --write --unsafe --staged src",
46
47
  "verify-types": "tsc --noEmit"
47
48
  },
48
49
  dependencies: {
49
50
  "@airtop/json-schema-adapter": "workspace:*",
50
- "@airtop/core": "0.1.0-alpha.17",
51
+ "@airtop/core": "0.1.0-alpha.36",
51
52
  "date-fns": "4.1.0",
52
- loglayer: "6.3.3",
53
+ loglayer: "6.6.0",
53
54
  "serialize-error": "12.0.0",
54
55
  uuid: "11.1.0"
55
56
  },
56
57
  devDependencies: {
57
- "@biomejs/biome": "1.9.4",
58
- "@dotenvx/dotenvx": "1.39.0",
58
+ "@biomejs/biome": "2.1.2",
59
+ "@dotenvx/dotenvx": "1.48.0",
59
60
  "@internal/tsconfig": "workspace:*",
60
61
  "deep-utility-types": "1.3.1",
61
62
  "env-var": "7.5.0",
62
63
  "hash-runner": "2.0.1",
63
64
  nanoid: "5.1.5",
64
- tsup: "8.4.0",
65
- typescript: "5.8.2",
65
+ tsup: "8.5.0",
66
+ typescript: "5.8.3",
66
67
  "utility-types": "3.11.0",
67
68
  uuid: "11.1.0",
68
- vitest: "3.1.1",
69
+ vitest: "3.2.4",
69
70
  zod: "*"
70
71
  },
71
72
  bugs: "https://github.com/airtop-ai/airtop-sdk/issues",
@@ -79,13 +80,19 @@ var require_package = __commonJS({
79
80
  optionalDependencies: {
80
81
  "@airtop/json-schema-adapter-zod": "workspace:*"
81
82
  },
82
- packageManager: "pnpm@10.5.0"
83
+ packageManager: "pnpm@10.12.4"
83
84
  };
84
85
  }
85
86
  });
86
87
 
87
88
  // src/AirtopBase.ts
88
89
  var _datefns = require('date-fns');
90
+
91
+ // src/constants.ts
92
+ var TIMEOUT_SECONDS_DEFAULT_VALUE = 300;
93
+ var DEFAULT_POLLING_INTERVAL_MS = 500;
94
+
95
+ // src/AirtopBase.ts
89
96
  var AirtopBase = class {
90
97
  /**
91
98
  * Logger instance for the SDK
@@ -102,6 +109,21 @@ var AirtopBase = class {
102
109
  * @internal
103
110
  **/
104
111
 
112
+ /**
113
+ * The job id for the ongoing automation
114
+ * @internal
115
+ */
116
+
117
+ /**
118
+ * Instance for sending agent events
119
+ * @internal
120
+ */
121
+
122
+ /**
123
+ * The default timeout in seconds for API requests.
124
+ * @internal
125
+ */
126
+
105
127
  /**
106
128
  * Creates a new instance of AirtopBase
107
129
  * @param config - Configuration options for the SDK
@@ -110,6 +132,29 @@ var AirtopBase = class {
110
132
  this.log = config.log.withPrefix("[Airtop]");
111
133
  this.client = config.client;
112
134
  this.outputJsonAdapter = config.outputSchemaAdapter;
135
+ this.jobId = config.jobId;
136
+ this.defaultTimeoutInSeconds = _nullishCoalesce(config.defaultTimeoutInSeconds, () => ( TIMEOUT_SECONDS_DEFAULT_VALUE));
137
+ if (config.agentEventPublisher) {
138
+ this.agentEventPublisher = config.agentEventPublisher;
139
+ }
140
+ }
141
+ /**
142
+ * Sets the publisher for sending agent events. Internal use only.
143
+ * @internal
144
+ */
145
+ _setAgentEventPublisher(logger) {
146
+ this.agentEventPublisher = logger;
147
+ }
148
+ /**
149
+ * Sends a payload to the agent with the specified event name.
150
+ * @param eventName The name of the event
151
+ * @param payload The payload to send to the agent
152
+ * @internal
153
+ */
154
+ _sendAgentPayload(eventName, payload) {
155
+ if (this.agentEventPublisher) {
156
+ this.agentEventPublisher.withMetadata(payload).info(eventName);
157
+ }
113
158
  }
114
159
  /**
115
160
  * Returns the API key used by the SDK
@@ -163,7 +208,10 @@ var AirtopBase = class {
163
208
  getCommonConfig() {
164
209
  return {
165
210
  client: this.client,
166
- log: this.log
211
+ log: this.log,
212
+ jobId: this.jobId,
213
+ outputSchemaAdapter: this.outputJsonAdapter,
214
+ agentEventPublisher: this.agentEventPublisher
167
215
  };
168
216
  }
169
217
  /**
@@ -174,7 +222,7 @@ var AirtopBase = class {
174
222
  */
175
223
  resolveRequestOptions(options = {}) {
176
224
  return {
177
- timeout: _datefns.secondsToMilliseconds.call(void 0, options.timeoutInSeconds || 60),
225
+ timeout: _datefns.secondsToMilliseconds.call(void 0, options.timeoutInSeconds || this.defaultTimeoutInSeconds),
178
226
  maxRetries: options.maxRetries || 0,
179
227
  signal: options.abortSignal
180
228
  };
@@ -183,7 +231,7 @@ var AirtopBase = class {
183
231
 
184
232
  // src/AirtopClient.ts
185
233
  var _core = require('@airtop/core');
186
- var _minutesToMilliseconds = require('date-fns/minutesToMilliseconds');
234
+ var _secondsToMilliseconds = require('date-fns/secondsToMilliseconds');
187
235
  var _loglayer = require('loglayer');
188
236
  var _serializeerror = require('serialize-error');
189
237
 
@@ -234,9 +282,166 @@ var processLogMessage = (log, logLevel, ...args) => {
234
282
  // src/session/AirtopSessionClient.ts
235
283
 
236
284
 
237
- // src/window/AirtopWindowClient.ts
285
+ // src/async-utils.ts
238
286
 
239
287
 
288
+ // src/types.ts
289
+ var AirtopError = class extends Error {
290
+
291
+
292
+ constructor(issues, metadata) {
293
+ const errorMessage = issues.map((issue) => issue.message).join("\n");
294
+ const errorMessageWithMetadata = metadata ? `${errorMessage}
295
+ ${JSON.stringify(metadata)}` : errorMessage;
296
+ super(errorMessageWithMetadata);
297
+ this.issues = issues;
298
+ this.metadata = metadata;
299
+ }
300
+ };
301
+
302
+ // src/async-utils.ts
303
+ async function waitForRequestCompletion(client, requestId, requestOptions) {
304
+ const startTime = Date.now();
305
+ const timeoutMs = _datefns.secondsToMilliseconds.call(void 0, _optionalChain([requestOptions, 'optionalAccess', _5 => _5.timeoutInSeconds]) || TIMEOUT_SECONDS_DEFAULT_VALUE);
306
+ while (Date.now() - startTime < timeoutMs) {
307
+ const apiResponse = await client.requests.getRequestStatusV2(requestId, requestOptions);
308
+ if (apiResponse.status === "completed") {
309
+ return apiResponse.response;
310
+ }
311
+ if (apiResponse.status === "error") {
312
+ throw new Error(apiResponse.error);
313
+ }
314
+ await new Promise((resolve) => setTimeout(resolve, DEFAULT_POLLING_INTERVAL_MS));
315
+ }
316
+ throw new Error("Waiting for request timed out");
317
+ }
318
+ async function withRequestCompletionPolling(client, fn, requestOptions) {
319
+ try {
320
+ const response = await fn();
321
+ return waitForRequestCompletion(client, response.requestId, requestOptions);
322
+ } catch (thrownError) {
323
+ if (_optionalChain([thrownError, 'access', _6 => _6.error, 'optionalAccess', _7 => _7.errors])) {
324
+ throw new AirtopError(thrownError.error.errors, {
325
+ requestId: thrownError.error.requestId
326
+ });
327
+ }
328
+ throw thrownError;
329
+ }
330
+ }
331
+
332
+ // src/window/AirtopNode.ts
333
+ var AirtopNode = class {
334
+ /**
335
+ * The window client
336
+ */
337
+
338
+ /**
339
+ * The node handle id to use for all requests
340
+ */
341
+
342
+ /**
343
+ * The xpath selector of the node
344
+ */
345
+
346
+ /**
347
+ * Constructor
348
+ * @param client - The window client
349
+ * @param nodeData - The node data to use for all requests
350
+ */
351
+ constructor(client, nodeData) {
352
+ this.windowClient = client;
353
+ this.nodeHandleId = nodeData.id;
354
+ this.selector = nodeData.xpath;
355
+ }
356
+ /**
357
+ * Extract content from the node
358
+ * @param prompt - The prompt to use for the extraction
359
+ * @param config - The configuration to use for the extraction
360
+ * @param requestOptions - The request options to use for the extraction
361
+ */
362
+ async extract(prompt, config, requestOptions = {}) {
363
+ const augmentedConfig = {
364
+ ...config,
365
+ nodeHandleId: this.nodeHandleId
366
+ };
367
+ return this.windowClient.extract(prompt, augmentedConfig, requestOptions);
368
+ }
369
+ /**
370
+ * Act on the node
371
+ * @param prompt - The prompt to use for the action
372
+ * @param config - The configuration to use for the action
373
+ * @param requestOptions - The request options to use for the action
374
+ */
375
+ async act(prompt, config, requestOptions = {}) {
376
+ const augmentedConfig = {
377
+ ...config,
378
+ nodeHandleId: this.nodeHandleId
379
+ };
380
+ return this.windowClient.act(prompt, augmentedConfig, requestOptions);
381
+ }
382
+ /**
383
+ * Execute an LLM call on the node
384
+ * @param prompt - The prompt to use for the LLM call
385
+ * @param config - The configuration to use for the LLM call
386
+ * @param requestOptions - The request options to use for the LLM call
387
+ */
388
+ async llm(prompt, config, requestOptions = {}) {
389
+ return this.windowClient.llm(prompt, { ...config, nodeHandleId: this.nodeHandleId }, requestOptions);
390
+ }
391
+ /**
392
+ * Find one element in the node
393
+ * @param prompt - The prompt to use for the find one
394
+ * @param config - The configuration to use for the find one
395
+ * @param requestOptions - The request options to use for the find one
396
+ */
397
+ async findOne(prompt, config, requestOptions = {}) {
398
+ const augmentedConfig = {
399
+ ...config,
400
+ nodeHandleId: this.nodeHandleId
401
+ };
402
+ return this.windowClient.findOne(prompt, augmentedConfig, requestOptions);
403
+ }
404
+ /**
405
+ * Find one element in the node
406
+ * @param prompt - The prompt to use for the find one
407
+ * @param config - The configuration to use for the find one
408
+ * @param requestOptions - The request options to use for the find one
409
+ */
410
+ async findOneOptional(prompt, config, requestOptions = {}) {
411
+ const augmentedConfig = {
412
+ ...config,
413
+ nodeHandleId: this.nodeHandleId
414
+ };
415
+ return this.windowClient.findOneOptional(prompt, augmentedConfig, requestOptions);
416
+ }
417
+ /**
418
+ * Find many elements in the node
419
+ * @param prompt - The prompt to use for the find many
420
+ * @param config - The configuration to use for the find many
421
+ * @param requestOptions - The request options to use for the find many
422
+ */
423
+ async findMany(prompt, config, requestOptions = {}) {
424
+ const augmentedConfig = {
425
+ ...config,
426
+ nodeHandleId: this.nodeHandleId
427
+ };
428
+ return this.windowClient.findMany(prompt, augmentedConfig, requestOptions);
429
+ }
430
+ /**
431
+ * Find many elements in the node
432
+ * @param prompt - The prompt to use for the find many
433
+ * @param config - The configuration to use for the find many
434
+ * @param requestOptions - The request options to use for the find many
435
+ */
436
+ async findManyOptional(prompt, config, requestOptions = {}) {
437
+ const augmentedConfig = {
438
+ ...config,
439
+ nodeHandleId: this.nodeHandleId
440
+ };
441
+ return this.windowClient.findManyOptional(prompt, augmentedConfig, requestOptions);
442
+ }
443
+ };
444
+
240
445
  // src/window/AirtopWindowScreenshot.ts
241
446
  function extractMimeAndBase64(dataUrl) {
242
447
  const match = dataUrl.match(/^data:(image\/\w+);base64,(.+)$/);
@@ -336,6 +541,19 @@ var AirtopWindowClient = class extends AirtopBase {
336
541
  });
337
542
  this.windowId = windowId;
338
543
  this.sessionId = sessionId;
544
+ this.client.windows.get(
545
+ this.windowId,
546
+ {
547
+ sessionId: this.sessionId
548
+ },
549
+ this.resolveRequestOptions()
550
+ ).then((results) => {
551
+ this._sendAgentPayload("LiveViewUrl", {
552
+ liveViewUrl: results.data.liveViewUrl,
553
+ windowId: this.windowId,
554
+ sessionId: this.sessionId
555
+ });
556
+ });
339
557
  }
340
558
  /**
341
559
  * Gets the window ID.
@@ -377,17 +595,19 @@ var AirtopWindowClient = class extends AirtopBase {
377
595
  this.log.withMetadata({
378
596
  elementDescription
379
597
  }).info("Clicking on element");
380
- return this.client.windows.click(
381
- this.getWindowId(),
382
- {
383
- ...config,
384
- elementDescription,
385
- sessionId: this.sessionId
386
- },
387
- {
388
- timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
389
- ...this.resolveRequestOptions(requestOptions)
390
- }
598
+ return withRequestCompletionPolling(
599
+ this.client,
600
+ () => this.client.windows.clickAsync(
601
+ this.getWindowId(),
602
+ {
603
+ ...config,
604
+ elementDescription,
605
+ sessionId: this.sessionId
606
+ },
607
+ {
608
+ ...this.resolveRequestOptions(requestOptions)
609
+ }
610
+ )
391
611
  );
392
612
  }
393
613
  /**
@@ -409,17 +629,19 @@ var AirtopWindowClient = class extends AirtopBase {
409
629
  */
410
630
  async hover(elementDescription, config, requestOptions = {}) {
411
631
  this.log.withMetadata(config).info("Hovering over window");
412
- return this.client.windows.hover(
413
- this.getWindowId(),
414
- {
415
- elementDescription,
416
- sessionId: this.sessionId,
417
- ...config || {}
418
- },
419
- {
420
- timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
421
- ...this.resolveRequestOptions(requestOptions)
422
- }
632
+ return withRequestCompletionPolling(
633
+ this.client,
634
+ () => this.client.windows.hoverAsync(
635
+ this.getWindowId(),
636
+ {
637
+ elementDescription,
638
+ sessionId: this.sessionId,
639
+ ...config || {}
640
+ },
641
+ {
642
+ ...this.resolveRequestOptions(requestOptions)
643
+ }
644
+ )
423
645
  );
424
646
  }
425
647
  /**
@@ -441,7 +663,6 @@ var AirtopWindowClient = class extends AirtopBase {
441
663
  ...config
442
664
  },
443
665
  {
444
- timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
445
666
  ...this.resolveRequestOptions(requestOptions)
446
667
  }
447
668
  );
@@ -453,19 +674,33 @@ var AirtopWindowClient = class extends AirtopBase {
453
674
  * @param requestOptions - Request options
454
675
  * @returns Promise resolving to the monitoring operation result
455
676
  */
456
- async monitor(condition, config, requestOptions = {}) {
677
+ async monitor(condition, config = {}, requestOptions = {}) {
457
678
  this.log.withMetadata().info("Monitoring window");
458
- return this.client.windows.monitor(
459
- this.getWindowId(),
460
- {
461
- condition,
462
- sessionId: this.sessionId,
463
- ...config || {}
464
- },
465
- {
466
- timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
467
- ...this.resolveRequestOptions(requestOptions)
679
+ if (!_optionalChain([config, 'optionalAccess', _8 => _8.configuration, 'optionalAccess', _9 => _9.interval, 'optionalAccess', _10 => _10.timeoutSeconds])) {
680
+ if (!config.configuration) {
681
+ config.configuration = {};
682
+ }
683
+ if (!config.configuration.interval) {
684
+ config.configuration.interval = {};
468
685
  }
686
+ config.configuration.interval.timeoutSeconds = this.defaultTimeoutInSeconds;
687
+ }
688
+ if (!_optionalChain([config, 'optionalAccess', _11 => _11.timeThresholdSeconds])) {
689
+ config.timeThresholdSeconds = this.defaultTimeoutInSeconds;
690
+ }
691
+ return withRequestCompletionPolling(
692
+ this.client,
693
+ () => this.client.windows.monitorAsync(
694
+ this.getWindowId(),
695
+ {
696
+ condition,
697
+ sessionId: this.sessionId,
698
+ ...config || {}
699
+ },
700
+ {
701
+ ...this.resolveRequestOptions(requestOptions)
702
+ }
703
+ )
469
704
  );
470
705
  }
471
706
  /**
@@ -480,20 +715,22 @@ var AirtopWindowClient = class extends AirtopBase {
480
715
  prompt
481
716
  }).info("Performing a page query");
482
717
  const newConfig = config;
483
- if (_optionalChain([config, 'optionalAccess', _5 => _5.configuration, 'access', _6 => _6.outputSchema])) {
718
+ if (_optionalChain([config, 'optionalAccess', _12 => _12.configuration, 'access', _13 => _13.outputSchema])) {
484
719
  newConfig.configuration.outputSchema = this.convertToJsonSchema(config.configuration.outputSchema);
485
720
  }
486
- return this.client.windows.pageQuery(
487
- this.getWindowId(),
488
- {
489
- sessionId: this.sessionId,
490
- prompt,
491
- ...newConfig || {}
492
- },
493
- {
494
- timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
495
- ...this.resolveRequestOptions(requestOptions)
496
- }
721
+ return withRequestCompletionPolling(
722
+ this.client,
723
+ () => this.client.windows.pageQueryAsync(
724
+ this.getWindowId(),
725
+ {
726
+ sessionId: this.sessionId,
727
+ prompt,
728
+ ...newConfig || {}
729
+ },
730
+ {
731
+ ...this.resolveRequestOptions(requestOptions)
732
+ }
733
+ )
497
734
  );
498
735
  }
499
736
  /**
@@ -508,20 +745,22 @@ var AirtopWindowClient = class extends AirtopBase {
508
745
  prompt
509
746
  }).info("Performing a paginated extraction");
510
747
  const newConfig = config;
511
- if (_optionalChain([config, 'optionalAccess', _7 => _7.configuration, 'access', _8 => _8.outputSchema])) {
748
+ if (_optionalChain([config, 'optionalAccess', _14 => _14.configuration, 'access', _15 => _15.outputSchema])) {
512
749
  newConfig.configuration.outputSchema = this.convertToJsonSchema(config.configuration.outputSchema);
513
750
  }
514
- return this.client.windows.paginatedExtraction(
515
- this.getWindowId(),
516
- {
517
- prompt,
518
- sessionId: this.sessionId,
519
- ...newConfig || {}
520
- },
521
- {
522
- timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
523
- ...this.resolveRequestOptions(requestOptions)
524
- }
751
+ return withRequestCompletionPolling(
752
+ this.client,
753
+ () => this.client.windows.paginatedExtractionAsync(
754
+ this.getWindowId(),
755
+ {
756
+ prompt,
757
+ sessionId: this.sessionId,
758
+ ...newConfig || {}
759
+ },
760
+ {
761
+ ...this.resolveRequestOptions(requestOptions)
762
+ }
763
+ )
525
764
  );
526
765
  }
527
766
  /**
@@ -532,16 +771,18 @@ var AirtopWindowClient = class extends AirtopBase {
532
771
  */
533
772
  async scrape(config, requestOptions = {}) {
534
773
  this.log.info("Scraping window");
535
- return this.client.windows.scrape(
536
- this.getWindowId(),
537
- {
538
- sessionId: this.sessionId,
539
- ...config || {}
540
- },
541
- {
542
- timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
543
- ...this.resolveRequestOptions(requestOptions)
544
- }
774
+ return withRequestCompletionPolling(
775
+ this.client,
776
+ () => this.client.windows.scrapeAsync(
777
+ this.getWindowId(),
778
+ {
779
+ sessionId: this.sessionId,
780
+ ...config || {}
781
+ },
782
+ {
783
+ ...this.resolveRequestOptions(requestOptions)
784
+ }
785
+ )
545
786
  );
546
787
  }
547
788
  /**
@@ -552,16 +793,18 @@ var AirtopWindowClient = class extends AirtopBase {
552
793
  */
553
794
  async screenshot(config, requestOptions = {}) {
554
795
  this.log.info("Screenshotting window");
555
- const resp = await this.client.windows.screenshot(
556
- this.getWindowId(),
557
- {
558
- sessionId: this.sessionId,
559
- ...config || {}
560
- },
561
- {
562
- timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
563
- ...this.resolveRequestOptions(requestOptions)
564
- }
796
+ const resp = await withRequestCompletionPolling(
797
+ this.client,
798
+ () => this.client.windows.screenshotAsync(
799
+ this.getWindowId(),
800
+ {
801
+ sessionId: this.sessionId,
802
+ ...config || {}
803
+ },
804
+ {
805
+ ...this.resolveRequestOptions(requestOptions)
806
+ }
807
+ )
565
808
  );
566
809
  return new AirtopWindowScreenshot(resp);
567
810
  }
@@ -573,16 +816,18 @@ var AirtopWindowClient = class extends AirtopBase {
573
816
  */
574
817
  async scroll(config, requestOptions = {}) {
575
818
  this.log.info("Scrolling window");
576
- return this.client.windows.scroll(
577
- this.getWindowId(),
578
- {
579
- sessionId: this.sessionId,
580
- ...config || {}
581
- },
582
- {
583
- timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
584
- ...this.resolveRequestOptions(requestOptions)
585
- }
819
+ return withRequestCompletionPolling(
820
+ this.client,
821
+ () => this.client.windows.scrollAsync(
822
+ this.getWindowId(),
823
+ {
824
+ sessionId: this.sessionId,
825
+ ...config || {}
826
+ },
827
+ {
828
+ ...this.resolveRequestOptions(requestOptions)
829
+ }
830
+ )
586
831
  );
587
832
  }
588
833
  /**
@@ -596,17 +841,198 @@ var AirtopWindowClient = class extends AirtopBase {
596
841
  this.log.withMetadata({
597
842
  text
598
843
  }).info("Typing text");
599
- return this.client.windows.type(
600
- this.getWindowId(),
601
- {
602
- sessionId: this.sessionId,
603
- text,
604
- ...config || {}
605
- },
606
- {
607
- timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
608
- ...this.resolveRequestOptions(requestOptions)
844
+ return withRequestCompletionPolling(
845
+ this.client,
846
+ () => this.client.windows.typeAsync(
847
+ this.getWindowId(),
848
+ {
849
+ sessionId: this.sessionId,
850
+ text,
851
+ ...config || {}
852
+ },
853
+ {
854
+ ...this.resolveRequestOptions(requestOptions)
855
+ }
856
+ )
857
+ );
858
+ }
859
+ async extract(prompt, config, requestOptions = {}) {
860
+ this.log.withMetadata({ prompt }).info("Extracting content");
861
+ return withRequestCompletionPolling(
862
+ this.client,
863
+ () => this.client.windows.extract(
864
+ this.getWindowId(),
865
+ {
866
+ prompt,
867
+ sessionId: this.sessionId,
868
+ jobId: this.jobId,
869
+ ...config || {}
870
+ },
871
+ {
872
+ ...this.resolveRequestOptions(requestOptions)
873
+ }
874
+ )
875
+ );
876
+ }
877
+ async act(prompt, config, requestOptions = {}) {
878
+ this.log.withMetadata({ prompt }).info("Acting on content");
879
+ return withRequestCompletionPolling(
880
+ this.client,
881
+ () => this.client.windows.act(
882
+ this.getWindowId(),
883
+ {
884
+ prompt,
885
+ sessionId: this.sessionId,
886
+ jobId: this.jobId,
887
+ ...config || {}
888
+ },
889
+ {
890
+ ...this.resolveRequestOptions(requestOptions)
891
+ }
892
+ )
893
+ );
894
+ }
895
+ async llm(prompt, config, requestOptions = {}) {
896
+ this.log.withMetadata({ prompt }).info("Executing LLM call");
897
+ return withRequestCompletionPolling(
898
+ this.client,
899
+ () => this.client.windows.llm(
900
+ this.getWindowId(),
901
+ {
902
+ prompt,
903
+ sessionId: this.sessionId,
904
+ jobId: this.jobId,
905
+ ...config || {},
906
+ includeWebContext: true,
907
+ // Always include web context for window.llm() calls
908
+ outputSchema: _optionalChain([config, 'optionalAccess', _16 => _16.outputSchema]) ? this.convertToJsonSchema(config.outputSchema) : void 0
909
+ },
910
+ {
911
+ ...this.resolveRequestOptions(requestOptions)
912
+ }
913
+ )
914
+ );
915
+ }
916
+ async findOnePrivate(prompt, config, requestOptions = {}) {
917
+ this.log.withMetadata({ prompt }).info("Executing LLM call");
918
+ const apiResponse = await withRequestCompletionPolling(
919
+ this.client,
920
+ () => this.client.windows.findOne(
921
+ this.getWindowId(),
922
+ {
923
+ prompt,
924
+ sessionId: this.sessionId,
925
+ jobId: this.jobId,
926
+ ...config || {}
927
+ },
928
+ {
929
+ ...this.resolveRequestOptions(requestOptions)
930
+ }
931
+ )
932
+ );
933
+ if (apiResponse.errors.length > 0) {
934
+ throw new AirtopError(apiResponse.errors);
935
+ }
936
+ try {
937
+ if (!apiResponse.data.nodeHandle) {
938
+ return null;
609
939
  }
940
+ return new AirtopNode(this, apiResponse.data.nodeHandle);
941
+ } catch (error) {
942
+ this.log.withMetadata({ nodeDataStr: apiResponse.data.nodeHandle }).withError(error).error("Error parsing node data");
943
+ throw error;
944
+ }
945
+ }
946
+ async findOne(prompt, config, requestOptions = {}) {
947
+ const configOverride = { ...config, optional: false };
948
+ return await this.findOnePrivate(prompt, configOverride, requestOptions);
949
+ }
950
+ async findOneOptional(prompt, config, requestOptions = {}) {
951
+ const configOverride = { ...config, optional: true };
952
+ return await this.findOnePrivate(prompt, configOverride, requestOptions);
953
+ }
954
+ async findManyPrivate(prompt, config, requestOptions = {}) {
955
+ this.log.withMetadata({ prompt }).info("Executing LLM call");
956
+ const apiResponse = await withRequestCompletionPolling(
957
+ this.client,
958
+ () => this.client.windows.findMany(
959
+ this.getWindowId(),
960
+ {
961
+ prompt,
962
+ sessionId: this.sessionId,
963
+ jobId: this.jobId,
964
+ ...config || {}
965
+ },
966
+ {
967
+ ...this.resolveRequestOptions(requestOptions)
968
+ }
969
+ )
970
+ );
971
+ if (apiResponse.errors.length > 0) {
972
+ throw new AirtopError(apiResponse.errors);
973
+ }
974
+ const nodeHandleData = apiResponse.data.nodeHandles;
975
+ return nodeHandleData.map((nodeHandle) => new AirtopNode(this, nodeHandle));
976
+ }
977
+ async findMany(prompt, config, requestOptions = {}) {
978
+ const configOverride = { ...config, optional: false };
979
+ return await this.findManyPrivate(prompt, configOverride, requestOptions);
980
+ }
981
+ async findManyOptional(prompt, config, requestOptions = {}) {
982
+ const configOverride = { ...config, optional: true };
983
+ return await this.findManyPrivate(prompt, configOverride, requestOptions);
984
+ }
985
+ async waitForPage(config, requestOptions = {}) {
986
+ return await withRequestCompletionPolling(
987
+ this.client,
988
+ () => this.client.windows.waitForPage(
989
+ this.getWindowId(),
990
+ {
991
+ sessionId: this.sessionId,
992
+ jobId: this.jobId,
993
+ ...config || {}
994
+ },
995
+ {
996
+ ...this.resolveRequestOptions(requestOptions)
997
+ }
998
+ )
999
+ );
1000
+ }
1001
+ async navigate(direction, config, requestOptions = {}) {
1002
+ return await withRequestCompletionPolling(
1003
+ this.client,
1004
+ () => this.client.windows.navigate(
1005
+ this.getWindowId(),
1006
+ {
1007
+ direction,
1008
+ sessionId: this.sessionId,
1009
+ jobId: this.jobId,
1010
+ ...config || {}
1011
+ },
1012
+ {
1013
+ ...this.resolveRequestOptions(requestOptions)
1014
+ }
1015
+ )
1016
+ );
1017
+ }
1018
+ async fillForm(formData, config, requestOptions = {}) {
1019
+ return await withRequestCompletionPolling(
1020
+ this.client,
1021
+ () => this.client.windows.executeAutomation(
1022
+ this.getWindowId(),
1023
+ {
1024
+ sessionId: this.sessionId,
1025
+ ...config || {},
1026
+ automationId: _optionalChain([config, 'optionalAccess', _17 => _17.automationId]) || "auto",
1027
+ parameters: {
1028
+ customData: typeof formData === "string" ? formData : JSON.stringify(formData)
1029
+ // Will be interpreted by the LLM
1030
+ }
1031
+ },
1032
+ {
1033
+ ...this.resolveRequestOptions(requestOptions)
1034
+ }
1035
+ )
610
1036
  );
611
1037
  }
612
1038
  };
@@ -682,6 +1108,9 @@ var AirtopSessionClient = class extends AirtopBase {
682
1108
  getSessionId() {
683
1109
  return this.sessionId;
684
1110
  }
1111
+ async listWindows(requestOptions = {}) {
1112
+ return this.client.sessions.listWindows(this.sessionId, this.resolveRequestOptions(requestOptions));
1113
+ }
685
1114
  /**
686
1115
  * Gets the state of the session using the attached session id.
687
1116
  * @param requestOptions - Request options
@@ -760,6 +1189,19 @@ var AirtopSessionClient = class extends AirtopBase {
760
1189
  },
761
1190
  this.resolveRequestOptions(requestOptions)
762
1191
  );
1192
+ this.client.windows.get(
1193
+ results.data.windowId,
1194
+ {
1195
+ sessionId: this.sessionId
1196
+ },
1197
+ this.resolveRequestOptions()
1198
+ ).then((windowResults) => {
1199
+ this._sendAgentPayload("LiveViewUrl", {
1200
+ liveViewUrl: windowResults.data.liveViewUrl,
1201
+ windowId: results.data.windowId,
1202
+ sessionId: this.sessionId
1203
+ });
1204
+ });
763
1205
  return new AirtopWindow(this.getCommonConfig(), this.sessionId, results);
764
1206
  }
765
1207
  /**
@@ -782,11 +1224,55 @@ var AirtopSessionClient = class extends AirtopBase {
782
1224
  {
783
1225
  ...config,
784
1226
  fileName,
785
- sessionId: this.sessionId
1227
+ sessionIds: [this.sessionId]
786
1228
  },
787
1229
  this.resolveRequestOptions(requestOptions)
788
1230
  );
789
1231
  }
1232
+ async llm(prompt, config, requestOptions = {}) {
1233
+ this.log.withMetadata({ prompt }).info("Executing LLM call");
1234
+ const currentWindows = await this.listWindows();
1235
+ if (currentWindows.data.windows.length === 0) {
1236
+ throw new AirtopError([
1237
+ {
1238
+ message: "No windows found in the session. Please create a window before calling the llm() method."
1239
+ }
1240
+ ]);
1241
+ }
1242
+ const firstWindow = currentWindows.data.windows[0];
1243
+ return withRequestCompletionPolling(
1244
+ this.client,
1245
+ () => this.client.windows.llm(
1246
+ firstWindow.windowId,
1247
+ {
1248
+ prompt,
1249
+ sessionId: this.sessionId,
1250
+ jobId: this.jobId,
1251
+ ...config || {},
1252
+ includeWebContext: false,
1253
+ // Do not include web context for session.llm() calls
1254
+ outputSchema: _optionalChain([config, 'optionalAccess', _18 => _18.outputSchema]) ? this.convertToJsonSchema(config.outputSchema) : void 0
1255
+ },
1256
+ {
1257
+ ...this.resolveRequestOptions(requestOptions)
1258
+ }
1259
+ )
1260
+ );
1261
+ }
1262
+ /**
1263
+ * Calls the service endpoint.
1264
+ * @param prompt - The prompt to send to the service, describing the actions to take
1265
+ * @param service - The service to call, if not provided, the service will be inferred from the prompt
1266
+ * @param requestOptions - Request options
1267
+ */
1268
+ async service(prompt, service, requestOptions = {}) {
1269
+ this.log.withMetadata({ prompt }).info("Service");
1270
+ return withRequestCompletionPolling(
1271
+ this.client,
1272
+ () => this.client.sessions.service(this.sessionId, { prompt, service }),
1273
+ requestOptions
1274
+ );
1275
+ }
790
1276
  };
791
1277
 
792
1278
  // src/session/AirtopSession.ts
@@ -845,19 +1331,19 @@ var AirtopClient = class extends AirtopBase {
845
1331
  */
846
1332
  constructor(config) {
847
1333
  super({
848
- logLevel: _optionalChain([config, 'optionalAccess', _9 => _9.logLevel]),
1334
+ logLevel: _optionalChain([config, 'optionalAccess', _19 => _19.logLevel]),
849
1335
  client: new (0, _core.Airtop)({
850
1336
  maxRetries: 0,
851
- timeout: _minutesToMilliseconds.minutesToMilliseconds.call(void 0, 1),
1337
+ timeout: _secondsToMilliseconds.secondsToMilliseconds.call(void 0, _nullishCoalesce(config.defaultTimeoutInSeconds, () => ( TIMEOUT_SECONDS_DEFAULT_VALUE))),
852
1338
  apiKey: config.apiKey,
853
- baseURL: _optionalChain([config, 'optionalAccess', _10 => _10.airtopUrl]),
854
- logLevel: _optionalChain([config, 'optionalAccess', _11 => _11.logLevel]) || "off",
1339
+ baseURL: _optionalChain([config, 'optionalAccess', _20 => _20.airtopUrl]),
1340
+ logLevel: _optionalChain([config, 'optionalAccess', _21 => _21.logLevel]) || "off",
855
1341
  defaultHeaders: {
856
1342
  "x-airtop-sdk-source": "typescript",
857
1343
  "x-airtop-sdk-version": version
858
1344
  }
859
1345
  }),
860
- log: _optionalChain([config, 'optionalAccess', _12 => _12.logger]) || new (0, _loglayer.LogLayer)({
1346
+ log: _optionalChain([config, 'optionalAccess', _22 => _22.logger]) || new (0, _loglayer.LogLayer)({
861
1347
  errorSerializer: _serializeerror.serializeError,
862
1348
  transport: new (0, _loglayer.ConsoleTransport)({
863
1349
  logger: console,
@@ -868,7 +1354,10 @@ var AirtopClient = class extends AirtopBase {
868
1354
  contextFieldName: "context",
869
1355
  metadataFieldName: "metadata"
870
1356
  }),
871
- outputSchemaAdapter: config.outputSchemaAdapter
1357
+ outputSchemaAdapter: config.outputSchemaAdapter,
1358
+ jobId: config.jobId,
1359
+ agentEventPublisher: config.agentEventPublisher,
1360
+ defaultTimeoutInSeconds: _nullishCoalesce(config.defaultTimeoutInSeconds, () => ( TIMEOUT_SECONDS_DEFAULT_VALUE))
872
1361
  });
873
1362
  this.log.withPrefix("[Airtop SDK]");
874
1363
  this.client.logLevel = config.logLevel;
@@ -894,8 +1383,8 @@ var AirtopClient = class extends AirtopBase {
894
1383
  * @returns A new AirtopSession instance
895
1384
  */
896
1385
  async createSession(config, options = {}) {
897
- const skipWaitSessionReady = _nullishCoalesce(config.skipWaitSessionReady, () => ( false));
898
- delete config.skipWaitSessionReady;
1386
+ const skipWaitSessionReady = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _23 => _23.skipWaitSessionReady]), () => ( false));
1387
+ _optionalChainDelete([config, 'optionalAccess', _24 => delete _24.skipWaitSessionReady]);
899
1388
  const sessionResponse = await this.client.sessions.create(
900
1389
  {
901
1390
  configuration: config
@@ -1003,23 +1492,6 @@ var AirtopClient = class extends AirtopBase {
1003
1492
  async getFile(fileId, requestOptions = {}) {
1004
1493
  return this.client.files.get(fileId, this.resolveRequestOptions(requestOptions));
1005
1494
  }
1006
- /**
1007
- * Lists files filtered by session IDs.
1008
- * @param sessionIds - Array of session IDs to retrieve files for
1009
- * @param config - Configuration options for the request
1010
- * @param requestOptions - Request options
1011
- * @returns Object containing pagination info and array of AirtopSession instances
1012
- */
1013
- async listFiles(sessionIds, config, requestOptions = {}) {
1014
- return this.client.files.list(
1015
- {
1016
- sessionIds,
1017
- limit: config.limit,
1018
- offset: config.offset
1019
- },
1020
- this.resolveRequestOptions(requestOptions)
1021
- );
1022
- }
1023
1495
  /**
1024
1496
  * Removes a file by ID.
1025
1497
  * @param fileId - ID of the file to remove
@@ -1028,6 +1500,14 @@ var AirtopClient = class extends AirtopBase {
1028
1500
  async removeFile(fileId, requestOptions = {}) {
1029
1501
  return this.client.files.delete(fileId, this.resolveRequestOptions(requestOptions));
1030
1502
  }
1503
+ /**
1504
+ * List files
1505
+ * @param query
1506
+ * @param requestOptions
1507
+ */
1508
+ async listFiles(query, requestOptions = {}) {
1509
+ return this.client.files.list(query, this.resolveRequestOptions(requestOptions));
1510
+ }
1031
1511
  /**
1032
1512
  * List all automations
1033
1513
  * @param requestOptions - Request options
@@ -1053,43 +1533,6 @@ var AirtopClient = class extends AirtopBase {
1053
1533
  }
1054
1534
  };
1055
1535
 
1056
- // src/plugin/AirtopPlugin.types.ts
1057
- var AirtopPluginAugmentationType = /* @__PURE__ */ ((AirtopPluginAugmentationType2) => {
1058
- AirtopPluginAugmentationType2["AirtopClient"] = "AirtopClient";
1059
- AirtopPluginAugmentationType2["AirtopWindowClient"] = "AirtopWindowClient";
1060
- AirtopPluginAugmentationType2["AirtopWindow"] = "AirtopWindow";
1061
- AirtopPluginAugmentationType2["AirtopSessionClient"] = "AirtopSessionClient";
1062
- AirtopPluginAugmentationType2["AirtopSession"] = "AirtopSession";
1063
- AirtopPluginAugmentationType2["AirtopWindowScreenshot"] = "AirtopWindowScreenshot";
1064
- return AirtopPluginAugmentationType2;
1065
- })(AirtopPluginAugmentationType || {});
1066
-
1067
- // src/plugin/AirtopPlugin.ts
1068
- function registerAirtopPlugin(plugin) {
1069
- for (const pluginToAdd of plugin.pluginsToAdd) {
1070
- switch (pluginToAdd.augmentationType) {
1071
- case "AirtopClient" /* AirtopClient */:
1072
- pluginToAdd.augment(AirtopClient.prototype);
1073
- break;
1074
- case "AirtopSessionClient" /* AirtopSessionClient */:
1075
- pluginToAdd.augment(AirtopSessionClient.prototype);
1076
- break;
1077
- case "AirtopSession" /* AirtopSession */:
1078
- pluginToAdd.augment(AirtopSession.prototype);
1079
- break;
1080
- case "AirtopWindowClient" /* AirtopWindowClient */:
1081
- pluginToAdd.augment(AirtopWindowClient.prototype);
1082
- break;
1083
- case "AirtopWindow" /* AirtopWindow */:
1084
- pluginToAdd.augment(AirtopWindow.prototype);
1085
- break;
1086
- case "AirtopWindowScreenshot" /* AirtopWindowScreenshot */:
1087
- pluginToAdd.augment(AirtopWindowScreenshot.prototype);
1088
- break;
1089
- }
1090
- }
1091
- }
1092
-
1093
1536
  // src/AirtopMocks.ts
1094
1537
 
1095
1538
 
@@ -1181,6 +1624,236 @@ var AirtopMocks = class {
1181
1624
  }
1182
1625
  };
1183
1626
 
1627
+ // src/agent/AirtopAgentClient.ts
1628
+ var _process = require('process');
1629
+
1630
+
1631
+
1632
+
1633
+ var AirtopAgentClient = class extends AirtopBase {
1634
+ /**
1635
+ * Creates a new instance of the Airtop SDK.
1636
+ * @param config - Configuration options for the Airtop SDK
1637
+ */
1638
+ constructor(config) {
1639
+ super({
1640
+ logLevel: _optionalChain([config, 'optionalAccess', _25 => _25.logLevel]),
1641
+ client: new (0, _core.Airtop)({
1642
+ maxRetries: 0,
1643
+ timeout: _datefns.minutesToMilliseconds.call(void 0, 1),
1644
+ apiKey: config.apiKey,
1645
+ baseURL: _optionalChain([config, 'optionalAccess', _26 => _26.airtopUrl]),
1646
+ logLevel: _optionalChain([config, 'optionalAccess', _27 => _27.logLevel]) || "off",
1647
+ defaultHeaders: {
1648
+ "x-airtop-sdk-source": "typescript",
1649
+ "x-airtop-sdk-version": _process.version
1650
+ }
1651
+ }),
1652
+ log: _optionalChain([config, 'optionalAccess', _28 => _28.logger]) || new (0, _loglayer.LogLayer)({
1653
+ errorSerializer: _serializeerror.serializeError,
1654
+ transport: new (0, _loglayer.ConsoleTransport)({
1655
+ logger: console,
1656
+ messageField: "message",
1657
+ enabled: config.logLevel !== "off",
1658
+ level: config.logLevel === "off" ? "error" : config.logLevel || "error"
1659
+ }),
1660
+ contextFieldName: "context",
1661
+ metadataFieldName: "metadata"
1662
+ }),
1663
+ outputSchemaAdapter: config.outputSchemaAdapter,
1664
+ jobId: config.jobId
1665
+ });
1666
+ this.log.withPrefix("[Airtop SDK]");
1667
+ this.client.logLevel = config.logLevel;
1668
+ this.client.logger = {
1669
+ debug: (message, ...rest) => {
1670
+ processLogMessage(this.log, "debug", message, rest);
1671
+ },
1672
+ error: (message, ...rest) => {
1673
+ processLogMessage(this.log, "error", message, rest);
1674
+ },
1675
+ info: (message, ...rest) => {
1676
+ processLogMessage(this.log, "info", message, rest);
1677
+ },
1678
+ warn: (message, ...rest) => {
1679
+ processLogMessage(this.log, "warn", message, rest);
1680
+ }
1681
+ };
1682
+ }
1683
+ /**
1684
+ * Creates a new agent.
1685
+ * @param params - Parameters for creating the agent. Corresponds to `AirtopAgentCreateAgentParams`.
1686
+ * @param requestOptions - Request options.
1687
+ * @returns The created agent data, `AirtopCreateAgentResponse`.
1688
+ */
1689
+ async createAgent(params, requestOptions = {}) {
1690
+ this.log.info("Creating agent");
1691
+ return this.client.agents.createAgent(params, this.resolveRequestOptions(requestOptions));
1692
+ }
1693
+ /**
1694
+ * Retrieves a specific agent by its ID.
1695
+ * @param agentId - The ID of the agent to retrieve.
1696
+ * @param requestOptions - Request options.
1697
+ * @returns The agent data, `AirtopGetAgentResponse`.
1698
+ */
1699
+ async getAgent(agentId, requestOptions = {}) {
1700
+ this.log.withMetadata({ agentId }).info("Retrieving agent");
1701
+ return this.client.agents.getAgent(agentId, this.resolveRequestOptions(requestOptions));
1702
+ }
1703
+ /**
1704
+ * Lists agents.
1705
+ * @param params - Optional parameters for listing agents (e.g., pagination). Corresponds to `AirtopAgentGetAgentsParams`.
1706
+ * @param requestOptions - Request options.
1707
+ * @returns A list of agents, `AirtopGetAgentsResponse`.
1708
+ */
1709
+ async listAgents(params, requestOptions = {}) {
1710
+ this.log.info("Listing agents");
1711
+ return this.client.agents.getAgents(params, this.resolveRequestOptions(requestOptions));
1712
+ }
1713
+ /**
1714
+ * Updates an existing agent.
1715
+ * @param agentId - The ID of the agent to update.
1716
+ * @param params - The new data for the agent. Corresponds to `AirtopAgentUpdateAgentParams`.
1717
+ * @param requestOptions - Request options.
1718
+ * @returns The updated agent data, `AirtopUpdateAgentResponse`.
1719
+ */
1720
+ async updateAgent(agentId, params, requestOptions = {}) {
1721
+ this.log.withMetadata({ agentId }).info("Updating agent");
1722
+ return this.client.agents.updateAgent(agentId, params, this.resolveRequestOptions(requestOptions));
1723
+ }
1724
+ /**
1725
+ * Deletes one or more agents.
1726
+ * @param params - Parameters for deleting agents. Corresponds to `AirtopAgentDeleteAgentsParams`.
1727
+ * @param requestOptions - Request options.
1728
+ * @returns A response confirming the deletion, `AirtopDeleteAgentsResponse`.
1729
+ */
1730
+ async deleteAgents(params, requestOptions = {}) {
1731
+ this.log.info("Deleting agent(s)");
1732
+ return this.client.agents.deleteAgents(params, this.resolveRequestOptions(requestOptions));
1733
+ }
1734
+ /**
1735
+ * Duplicates an agent.
1736
+ * @param agentId - The ID of the agent to duplicate.
1737
+ * @param params - Parameters for duplicating the agent (e.g., new name). Corresponds to `AirtopAgentDuplicateAgentParams`.
1738
+ * @param requestOptions - Request options.
1739
+ * @returns The duplicated agent data, `AirtopDuplicateAgentResponse`.
1740
+ */
1741
+ async duplicateAgent(agentId, params, requestOptions = {}) {
1742
+ this.log.withMetadata({ agentId }).info("Duplicating agent");
1743
+ return this.client.agents.duplicateAgent(agentId, params, this.resolveRequestOptions(requestOptions));
1744
+ }
1745
+ /**
1746
+ * Creates a new version for an agent.
1747
+ * @param agentId - The ID of the agent for which to create a version.
1748
+ * @param params - Parameters for creating the agent version. Corresponds to `AirtopAgentCreateVersionParams`.
1749
+ * @param requestOptions - Request options.
1750
+ * @returns The created agent version data, `AirtopCreateAgentVersionResponse`.
1751
+ */
1752
+ async createAgentVersion(agentId, params, requestOptions = {}) {
1753
+ this.log.withMetadata({ agentId }).info("Creating agent version");
1754
+ return this.client.agents.createVersion(agentId, params, this.resolveRequestOptions(requestOptions));
1755
+ }
1756
+ /**
1757
+ * Lists versions of an agent.
1758
+ * @param agentId - The ID of the agent whose versions to list.
1759
+ * @param params - Optional parameters for listing agent versions. Corresponds to `AirtopAgentGetVersionsParams`.
1760
+ * @param requestOptions - Request options.
1761
+ * @returns A list of agent versions, `AirtopGetAgentVersionsResponse`.
1762
+ */
1763
+ async listAgentVersions(agentId, params, requestOptions = {}) {
1764
+ this.log.withMetadata({ agentId }).info("Listing agent versions");
1765
+ return this.client.agents.getVersions(agentId, params, this.resolveRequestOptions(requestOptions));
1766
+ }
1767
+ /**
1768
+ * Creates an invocation for an agent.
1769
+ * @param agentId - The ID of the agent for which to create an invocation.
1770
+ * @param params - Parameters for creating the agent invocation. Corresponds to `AirtopAgentCreateInvocationParams`.
1771
+ * @param requestOptions - Request options.
1772
+ * @returns The created agent invocation data, `AirtopCreateAgentInvocationResponse`.
1773
+ */
1774
+ async createAgentInvocation(agentId, params, requestOptions = {}) {
1775
+ this.log.withMetadata({ agentId }).info("Creating agent invocation");
1776
+ return this.client.agents.createInvocation(agentId, params, this.resolveRequestOptions(requestOptions));
1777
+ }
1778
+ /**
1779
+ * Lists invocations of an agent.
1780
+ * @param agentIds - The ID of the agent whose invocations to list.
1781
+ * @param params - Optional parameters for listing agent invocations. Corresponds to `AirtopAgentGetInvocationsParams`.
1782
+ * @param requestOptions - Request options.
1783
+ * @returns A list of agent invocations, `AirtopGetAgentInvocationsResponse`.
1784
+ */
1785
+ async listAgentInvocations(agentIds, params, requestOptions = {}) {
1786
+ this.log.withMetadata({ agentId: agentIds }).info("Listing agent invocations");
1787
+ return this.client.agents.getInvocations(agentIds, params, this.resolveRequestOptions(requestOptions));
1788
+ }
1789
+ /**
1790
+ * Cancels a specific invocation of an agent.
1791
+ * @param agentId - The ID of the agent.
1792
+ * @param invocationId - The ID of the invocation to cancel.
1793
+ * @param paramsBody - Optional body parameters for cancelling the invocation. Corresponds to `AirtopAgentCancelInvocationParams`.
1794
+ * @param requestOptions - Request options.
1795
+ * @returns A promise that resolves when the operation is complete.
1796
+ */
1797
+ async cancelAgentInvocation(agentId, invocationId, paramsBody, requestOptions = {}) {
1798
+ this.log.withMetadata({ agentId, invocationId }).info("Cancelling agent invocation");
1799
+ const resolvedOptions = this.resolveRequestOptions(requestOptions);
1800
+ const finalOptions = { ...resolvedOptions };
1801
+ const params = { id: agentId, ...paramsBody };
1802
+ if (paramsBody) {
1803
+ finalOptions.body = paramsBody;
1804
+ }
1805
+ await this.client.agents.cancelInvocation(invocationId, params, finalOptions);
1806
+ }
1807
+ };
1808
+
1809
+ // src/window/AirtopWindowClient.types.ts
1810
+ var WindowNavigateDirection = /* @__PURE__ */ ((WindowNavigateDirection2) => {
1811
+ WindowNavigateDirection2["BACK"] = "backward";
1812
+ WindowNavigateDirection2["FORWARD"] = "forward";
1813
+ return WindowNavigateDirection2;
1814
+ })(WindowNavigateDirection || {});
1815
+
1816
+ // src/plugin/AirtopPlugin.types.ts
1817
+ var AirtopPluginAugmentationType = /* @__PURE__ */ ((AirtopPluginAugmentationType2) => {
1818
+ AirtopPluginAugmentationType2["AirtopClient"] = "AirtopClient";
1819
+ AirtopPluginAugmentationType2["AirtopWindowClient"] = "AirtopWindowClient";
1820
+ AirtopPluginAugmentationType2["AirtopWindow"] = "AirtopWindow";
1821
+ AirtopPluginAugmentationType2["AirtopSessionClient"] = "AirtopSessionClient";
1822
+ AirtopPluginAugmentationType2["AirtopSession"] = "AirtopSession";
1823
+ AirtopPluginAugmentationType2["AirtopWindowScreenshot"] = "AirtopWindowScreenshot";
1824
+ return AirtopPluginAugmentationType2;
1825
+ })(AirtopPluginAugmentationType || {});
1826
+
1827
+ // src/plugin/AirtopPlugin.ts
1828
+ function registerAirtopPlugin(plugin) {
1829
+ for (const pluginToAdd of plugin.pluginsToAdd) {
1830
+ switch (pluginToAdd.augmentationType) {
1831
+ case "AirtopClient" /* AirtopClient */:
1832
+ pluginToAdd.augment(AirtopClient.prototype);
1833
+ break;
1834
+ case "AirtopSessionClient" /* AirtopSessionClient */:
1835
+ pluginToAdd.augment(AirtopSessionClient.prototype);
1836
+ break;
1837
+ case "AirtopSession" /* AirtopSession */:
1838
+ pluginToAdd.augment(AirtopSession.prototype);
1839
+ break;
1840
+ case "AirtopWindowClient" /* AirtopWindowClient */:
1841
+ pluginToAdd.augment(AirtopWindowClient.prototype);
1842
+ break;
1843
+ case "AirtopWindow" /* AirtopWindow */:
1844
+ pluginToAdd.augment(AirtopWindow.prototype);
1845
+ break;
1846
+ case "AirtopWindowScreenshot" /* AirtopWindowScreenshot */:
1847
+ pluginToAdd.augment(AirtopWindowScreenshot.prototype);
1848
+ break;
1849
+ }
1850
+ }
1851
+ }
1852
+
1853
+
1854
+
1855
+
1856
+
1184
1857
 
1185
1858
 
1186
1859
 
@@ -1191,5 +1864,5 @@ var AirtopMocks = class {
1191
1864
 
1192
1865
 
1193
1866
 
1194
- exports.AirtopBase = AirtopBase; exports.AirtopClient = AirtopClient; exports.AirtopMocks = AirtopMocks; exports.AirtopPluginAugmentationType = AirtopPluginAugmentationType; exports.AirtopSession = AirtopSession; exports.AirtopSessionClient = AirtopSessionClient; exports.AirtopWindow = AirtopWindow; exports.AirtopWindowClient = AirtopWindowClient; exports.AirtopWindowScreenshot = AirtopWindowScreenshot; exports.registerAirtopPlugin = registerAirtopPlugin;
1867
+ exports.AirtopAgentClient = AirtopAgentClient; exports.AirtopBase = AirtopBase; exports.AirtopClient = AirtopClient; exports.AirtopError = AirtopError; exports.AirtopMocks = AirtopMocks; exports.AirtopNode = AirtopNode; exports.AirtopPluginAugmentationType = AirtopPluginAugmentationType; exports.AirtopSession = AirtopSession; exports.AirtopSessionClient = AirtopSessionClient; exports.AirtopWindow = AirtopWindow; exports.AirtopWindowClient = AirtopWindowClient; exports.AirtopWindowScreenshot = AirtopWindowScreenshot; exports.WindowNavigateDirection = WindowNavigateDirection; exports.registerAirtopPlugin = registerAirtopPlugin;
1195
1868
  //# sourceMappingURL=index.cjs.map