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

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.js CHANGED
@@ -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.21",
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",
46
- "verify-types": "tsc --noEmit"
45
+ lint: "biome check --no-errors-on-unmatched --write --unsafe src",
46
+ "lint:staged": "biome check --no-errors-on-unmatched --write --unsafe --staged src",
47
+ "verify-types": "tsc --noEmit && tsc --noEmit --project tsconfig.e2e.json"
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.37",
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.3",
59
+ "@dotenvx/dotenvx": "1.48.4",
59
60
  "@internal/tsconfig": "workspace:*",
60
61
  "deep-utility-types": "1.3.1",
61
62
  "env-var": "7.5.0",
62
- "hash-runner": "2.0.1",
63
+ "hash-runner": "3.1.0",
63
64
  nanoid: "5.1.5",
64
- tsup: "8.4.0",
65
- typescript: "5.8.2",
65
+ tsup: "8.5.0",
66
+ typescript: "5.9.2",
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
  import { secondsToMilliseconds } from "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
  outputJsonAdapter;
112
+ /**
113
+ * The job id for the ongoing automation
114
+ * @internal
115
+ */
116
+ jobId;
117
+ /**
118
+ * Instance for sending agent events
119
+ * @internal
120
+ */
121
+ agentEventPublisher;
122
+ /**
123
+ * The default timeout in seconds for API requests.
124
+ * @internal
125
+ */
126
+ defaultTimeoutInSeconds;
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 = 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: secondsToMilliseconds(options.timeoutInSeconds || 60),
225
+ timeout: secondsToMilliseconds(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
  import { Airtop as AirtopCore } from "@airtop/core";
186
- import { minutesToMilliseconds } from "date-fns/minutesToMilliseconds";
234
+ import { secondsToMilliseconds as secondsToMilliseconds3 } from "date-fns/secondsToMilliseconds";
187
235
  import { ConsoleTransport, LogLayer } from "loglayer";
188
236
  import { serializeError } from "serialize-error";
189
237
 
@@ -234,9 +282,166 @@ var processLogMessage = (log, logLevel, ...args) => {
234
282
  // src/session/AirtopSessionClient.ts
235
283
  import { NotFoundError } from "@airtop/core";
236
284
 
237
- // src/window/AirtopWindowClient.ts
285
+ // src/async-utils.ts
238
286
  import { secondsToMilliseconds as secondsToMilliseconds2 } from "date-fns";
239
287
 
288
+ // src/types.ts
289
+ var AirtopError = class extends Error {
290
+ issues;
291
+ metadata;
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 = secondsToMilliseconds2(requestOptions?.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 (thrownError.error?.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
+ windowClient;
338
+ /**
339
+ * The node handle id to use for all requests
340
+ */
341
+ nodeHandleId;
342
+ /**
343
+ * The xpath selector of the node
344
+ */
345
+ selector;
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: secondsToMilliseconds2(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: secondsToMilliseconds2(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: secondsToMilliseconds2(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: secondsToMilliseconds2(600),
467
- ...this.resolveRequestOptions(requestOptions)
679
+ if (!config?.configuration?.interval?.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 (!config?.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
  /**
@@ -483,17 +718,19 @@ var AirtopWindowClient = class extends AirtopBase {
483
718
  if (config?.configuration.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: secondsToMilliseconds2(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
  /**
@@ -511,17 +748,19 @@ var AirtopWindowClient = class extends AirtopBase {
511
748
  if (config?.configuration.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: secondsToMilliseconds2(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: secondsToMilliseconds2(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: secondsToMilliseconds2(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: secondsToMilliseconds2(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: secondsToMilliseconds2(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: config?.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: config?.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,67 @@ 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: config?.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
+ }
1276
+ /**
1277
+ * Retrieves the list of connected services available for the current session.
1278
+ * @param requestOptions - Request options
1279
+ * @returns A promise that resolves to the connected services response containing service details
1280
+ */
1281
+ async getConnectedServices(requestOptions = {}) {
1282
+ return withRequestCompletionPolling(
1283
+ this.client,
1284
+ () => this.client.sessions.getConnectedServices(this.sessionId),
1285
+ requestOptions
1286
+ );
1287
+ }
790
1288
  };
791
1289
 
792
1290
  // src/session/AirtopSession.ts
@@ -848,7 +1346,7 @@ var AirtopClient = class extends AirtopBase {
848
1346
  logLevel: config?.logLevel,
849
1347
  client: new AirtopCore({
850
1348
  maxRetries: 0,
851
- timeout: minutesToMilliseconds(1),
1349
+ timeout: secondsToMilliseconds3(config.defaultTimeoutInSeconds ?? TIMEOUT_SECONDS_DEFAULT_VALUE),
852
1350
  apiKey: config.apiKey,
853
1351
  baseURL: config?.airtopUrl,
854
1352
  logLevel: config?.logLevel || "off",
@@ -868,7 +1366,10 @@ var AirtopClient = class extends AirtopBase {
868
1366
  contextFieldName: "context",
869
1367
  metadataFieldName: "metadata"
870
1368
  }),
871
- outputSchemaAdapter: config.outputSchemaAdapter
1369
+ outputSchemaAdapter: config.outputSchemaAdapter,
1370
+ jobId: config.jobId,
1371
+ agentEventPublisher: config.agentEventPublisher,
1372
+ defaultTimeoutInSeconds: config.defaultTimeoutInSeconds ?? TIMEOUT_SECONDS_DEFAULT_VALUE
872
1373
  });
873
1374
  this.log.withPrefix("[Airtop SDK]");
874
1375
  this.client.logLevel = config.logLevel;
@@ -894,8 +1395,8 @@ var AirtopClient = class extends AirtopBase {
894
1395
  * @returns A new AirtopSession instance
895
1396
  */
896
1397
  async createSession(config, options = {}) {
897
- const skipWaitSessionReady = config.skipWaitSessionReady ?? false;
898
- delete config.skipWaitSessionReady;
1398
+ const skipWaitSessionReady = config?.skipWaitSessionReady ?? false;
1399
+ delete config?.skipWaitSessionReady;
899
1400
  const sessionResponse = await this.client.sessions.create(
900
1401
  {
901
1402
  configuration: config
@@ -1003,23 +1504,6 @@ var AirtopClient = class extends AirtopBase {
1003
1504
  async getFile(fileId, requestOptions = {}) {
1004
1505
  return this.client.files.get(fileId, this.resolveRequestOptions(requestOptions));
1005
1506
  }
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
1507
  /**
1024
1508
  * Removes a file by ID.
1025
1509
  * @param fileId - ID of the file to remove
@@ -1028,6 +1512,14 @@ var AirtopClient = class extends AirtopBase {
1028
1512
  async removeFile(fileId, requestOptions = {}) {
1029
1513
  return this.client.files.delete(fileId, this.resolveRequestOptions(requestOptions));
1030
1514
  }
1515
+ /**
1516
+ * List files
1517
+ * @param query
1518
+ * @param requestOptions
1519
+ */
1520
+ async listFiles(query, requestOptions = {}) {
1521
+ return this.client.files.list(query, this.resolveRequestOptions(requestOptions));
1522
+ }
1031
1523
  /**
1032
1524
  * List all automations
1033
1525
  * @param requestOptions - Request options
@@ -1053,43 +1545,6 @@ var AirtopClient = class extends AirtopBase {
1053
1545
  }
1054
1546
  };
1055
1547
 
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
1548
  // src/AirtopMocks.ts
1094
1549
  import { Airtop as AirtopCore2 } from "@airtop/core";
1095
1550
  import { MockLogLayer } from "loglayer";
@@ -1180,16 +1635,246 @@ var AirtopMocks = class {
1180
1635
  });
1181
1636
  }
1182
1637
  };
1638
+
1639
+ // src/agent/AirtopAgentClient.ts
1640
+ import { version as version2 } from "process";
1641
+ import { Airtop as AirtopCore3 } from "@airtop/core";
1642
+ import { minutesToMilliseconds } from "date-fns";
1643
+ import { ConsoleTransport as ConsoleTransport2, LogLayer as LogLayer2 } from "loglayer";
1644
+ import { serializeError as serializeError2 } from "serialize-error";
1645
+ var AirtopAgentClient = class extends AirtopBase {
1646
+ /**
1647
+ * Creates a new instance of the Airtop SDK.
1648
+ * @param config - Configuration options for the Airtop SDK
1649
+ */
1650
+ constructor(config) {
1651
+ super({
1652
+ logLevel: config?.logLevel,
1653
+ client: new AirtopCore3({
1654
+ maxRetries: 0,
1655
+ timeout: minutesToMilliseconds(1),
1656
+ apiKey: config.apiKey,
1657
+ baseURL: config?.airtopUrl,
1658
+ logLevel: config?.logLevel || "off",
1659
+ defaultHeaders: {
1660
+ "x-airtop-sdk-source": "typescript",
1661
+ "x-airtop-sdk-version": version2
1662
+ }
1663
+ }),
1664
+ log: config?.logger || new LogLayer2({
1665
+ errorSerializer: serializeError2,
1666
+ transport: new ConsoleTransport2({
1667
+ logger: console,
1668
+ messageField: "message",
1669
+ enabled: config.logLevel !== "off",
1670
+ level: config.logLevel === "off" ? "error" : config.logLevel || "error"
1671
+ }),
1672
+ contextFieldName: "context",
1673
+ metadataFieldName: "metadata"
1674
+ }),
1675
+ outputSchemaAdapter: config.outputSchemaAdapter,
1676
+ jobId: config.jobId
1677
+ });
1678
+ this.log.withPrefix("[Airtop SDK]");
1679
+ this.client.logLevel = config.logLevel;
1680
+ this.client.logger = {
1681
+ debug: (message, ...rest) => {
1682
+ processLogMessage(this.log, "debug", message, rest);
1683
+ },
1684
+ error: (message, ...rest) => {
1685
+ processLogMessage(this.log, "error", message, rest);
1686
+ },
1687
+ info: (message, ...rest) => {
1688
+ processLogMessage(this.log, "info", message, rest);
1689
+ },
1690
+ warn: (message, ...rest) => {
1691
+ processLogMessage(this.log, "warn", message, rest);
1692
+ }
1693
+ };
1694
+ }
1695
+ /**
1696
+ * Creates a new agent.
1697
+ * @param params - Parameters for creating the agent. Corresponds to `AirtopAgentCreateAgentParams`.
1698
+ * @param requestOptions - Request options.
1699
+ * @returns The created agent data, `AirtopCreateAgentResponse`.
1700
+ */
1701
+ async createAgent(params, requestOptions = {}) {
1702
+ this.log.info("Creating agent");
1703
+ return this.client.agents.createAgent(params, this.resolveRequestOptions(requestOptions));
1704
+ }
1705
+ /**
1706
+ * Retrieves a specific agent by its ID.
1707
+ * @param agentId - The ID of the agent to retrieve.
1708
+ * @param requestOptions - Request options.
1709
+ * @returns The agent data, `AirtopGetAgentResponse`.
1710
+ */
1711
+ async getAgent(agentId, requestOptions = {}) {
1712
+ this.log.withMetadata({ agentId }).info("Retrieving agent");
1713
+ return this.client.agents.getAgent(agentId, this.resolveRequestOptions(requestOptions));
1714
+ }
1715
+ /**
1716
+ * Lists agents.
1717
+ * @param params - Optional parameters for listing agents (e.g., pagination). Corresponds to `AirtopAgentGetAgentsParams`.
1718
+ * @param requestOptions - Request options.
1719
+ * @returns A list of agents, `AirtopGetAgentsResponse`.
1720
+ */
1721
+ async listAgents(params, requestOptions = {}) {
1722
+ this.log.info("Listing agents");
1723
+ return this.client.agents.getAgents(params, this.resolveRequestOptions(requestOptions));
1724
+ }
1725
+ /**
1726
+ * Updates an existing agent.
1727
+ * @param agentId - The ID of the agent to update.
1728
+ * @param params - The new data for the agent. Corresponds to `AirtopAgentUpdateAgentParams`.
1729
+ * @param requestOptions - Request options.
1730
+ * @returns The updated agent data, `AirtopUpdateAgentResponse`.
1731
+ */
1732
+ async updateAgent(agentId, params, requestOptions = {}) {
1733
+ this.log.withMetadata({ agentId }).info("Updating agent");
1734
+ return this.client.agents.updateAgent(agentId, params, this.resolveRequestOptions(requestOptions));
1735
+ }
1736
+ /**
1737
+ * Deletes one or more agents.
1738
+ * @param params - Parameters for deleting agents. Corresponds to `AirtopAgentDeleteAgentsParams`.
1739
+ * @param requestOptions - Request options.
1740
+ * @returns A response confirming the deletion, `AirtopDeleteAgentsResponse`.
1741
+ */
1742
+ async deleteAgents(params, requestOptions = {}) {
1743
+ this.log.info("Deleting agent(s)");
1744
+ return this.client.agents.deleteAgents(params, this.resolveRequestOptions(requestOptions));
1745
+ }
1746
+ /**
1747
+ * Duplicates an agent.
1748
+ * @param agentId - The ID of the agent to duplicate.
1749
+ * @param params - Parameters for duplicating the agent (e.g., new name). Corresponds to `AirtopAgentDuplicateAgentParams`.
1750
+ * @param requestOptions - Request options.
1751
+ * @returns The duplicated agent data, `AirtopDuplicateAgentResponse`.
1752
+ */
1753
+ async duplicateAgent(agentId, params, requestOptions = {}) {
1754
+ this.log.withMetadata({ agentId }).info("Duplicating agent");
1755
+ return this.client.agents.duplicateAgent(agentId, params, this.resolveRequestOptions(requestOptions));
1756
+ }
1757
+ /**
1758
+ * Creates a new version for an agent.
1759
+ * @param agentId - The ID of the agent for which to create a version.
1760
+ * @param params - Parameters for creating the agent version. Corresponds to `AirtopAgentCreateVersionParams`.
1761
+ * @param requestOptions - Request options.
1762
+ * @returns The created agent version data, `AirtopCreateAgentVersionResponse`.
1763
+ */
1764
+ async createAgentVersion(agentId, params, requestOptions = {}) {
1765
+ this.log.withMetadata({ agentId }).info("Creating agent version");
1766
+ return this.client.agents.createVersion(agentId, params, this.resolveRequestOptions(requestOptions));
1767
+ }
1768
+ /**
1769
+ * Lists versions of an agent.
1770
+ * @param agentId - The ID of the agent whose versions to list.
1771
+ * @param params - Optional parameters for listing agent versions. Corresponds to `AirtopAgentGetVersionsParams`.
1772
+ * @param requestOptions - Request options.
1773
+ * @returns A list of agent versions, `AirtopGetAgentVersionsResponse`.
1774
+ */
1775
+ async listAgentVersions(agentId, params, requestOptions = {}) {
1776
+ this.log.withMetadata({ agentId }).info("Listing agent versions");
1777
+ return this.client.agents.getVersions(agentId, params, this.resolveRequestOptions(requestOptions));
1778
+ }
1779
+ /**
1780
+ * Creates an invocation for an agent.
1781
+ * @param agentId - The ID of the agent for which to create an invocation.
1782
+ * @param params - Parameters for creating the agent invocation. Corresponds to `AirtopAgentCreateInvocationParams`.
1783
+ * @param requestOptions - Request options.
1784
+ * @returns The created agent invocation data, `AirtopCreateAgentInvocationResponse`.
1785
+ */
1786
+ async createAgentInvocation(agentId, params, requestOptions = {}) {
1787
+ this.log.withMetadata({ agentId }).info("Creating agent invocation");
1788
+ return this.client.agents.createInvocation(agentId, params, this.resolveRequestOptions(requestOptions));
1789
+ }
1790
+ /**
1791
+ * Lists invocations of an agent.
1792
+ * @param agentIds - The ID of the agent whose invocations to list.
1793
+ * @param params - Optional parameters for listing agent invocations. Corresponds to `AirtopAgentGetInvocationsParams`.
1794
+ * @param requestOptions - Request options.
1795
+ * @returns A list of agent invocations, `AirtopGetAgentInvocationsResponse`.
1796
+ */
1797
+ async listAgentInvocations(agentIds, params, requestOptions = {}) {
1798
+ this.log.withMetadata({ agentId: agentIds }).info("Listing agent invocations");
1799
+ return this.client.agents.getInvocations(agentIds, params, this.resolveRequestOptions(requestOptions));
1800
+ }
1801
+ /**
1802
+ * Cancels a specific invocation of an agent.
1803
+ * @param agentId - The ID of the agent.
1804
+ * @param invocationId - The ID of the invocation to cancel.
1805
+ * @param paramsBody - Optional body parameters for cancelling the invocation. Corresponds to `AirtopAgentCancelInvocationParams`.
1806
+ * @param requestOptions - Request options.
1807
+ * @returns A promise that resolves when the operation is complete.
1808
+ */
1809
+ async cancelAgentInvocation(agentId, invocationId, paramsBody, requestOptions = {}) {
1810
+ this.log.withMetadata({ agentId, invocationId }).info("Cancelling agent invocation");
1811
+ const resolvedOptions = this.resolveRequestOptions(requestOptions);
1812
+ const finalOptions = { ...resolvedOptions };
1813
+ const params = { id: agentId, ...paramsBody };
1814
+ if (paramsBody) {
1815
+ finalOptions.body = paramsBody;
1816
+ }
1817
+ await this.client.agents.cancelInvocation(invocationId, params, finalOptions);
1818
+ }
1819
+ };
1820
+
1821
+ // src/window/AirtopWindowClient.types.ts
1822
+ var WindowNavigateDirection = /* @__PURE__ */ ((WindowNavigateDirection2) => {
1823
+ WindowNavigateDirection2["BACK"] = "backward";
1824
+ WindowNavigateDirection2["FORWARD"] = "forward";
1825
+ return WindowNavigateDirection2;
1826
+ })(WindowNavigateDirection || {});
1827
+
1828
+ // src/plugin/AirtopPlugin.types.ts
1829
+ var AirtopPluginAugmentationType = /* @__PURE__ */ ((AirtopPluginAugmentationType2) => {
1830
+ AirtopPluginAugmentationType2["AirtopClient"] = "AirtopClient";
1831
+ AirtopPluginAugmentationType2["AirtopWindowClient"] = "AirtopWindowClient";
1832
+ AirtopPluginAugmentationType2["AirtopWindow"] = "AirtopWindow";
1833
+ AirtopPluginAugmentationType2["AirtopSessionClient"] = "AirtopSessionClient";
1834
+ AirtopPluginAugmentationType2["AirtopSession"] = "AirtopSession";
1835
+ AirtopPluginAugmentationType2["AirtopWindowScreenshot"] = "AirtopWindowScreenshot";
1836
+ return AirtopPluginAugmentationType2;
1837
+ })(AirtopPluginAugmentationType || {});
1838
+
1839
+ // src/plugin/AirtopPlugin.ts
1840
+ function registerAirtopPlugin(plugin) {
1841
+ for (const pluginToAdd of plugin.pluginsToAdd) {
1842
+ switch (pluginToAdd.augmentationType) {
1843
+ case "AirtopClient" /* AirtopClient */:
1844
+ pluginToAdd.augment(AirtopClient.prototype);
1845
+ break;
1846
+ case "AirtopSessionClient" /* AirtopSessionClient */:
1847
+ pluginToAdd.augment(AirtopSessionClient.prototype);
1848
+ break;
1849
+ case "AirtopSession" /* AirtopSession */:
1850
+ pluginToAdd.augment(AirtopSession.prototype);
1851
+ break;
1852
+ case "AirtopWindowClient" /* AirtopWindowClient */:
1853
+ pluginToAdd.augment(AirtopWindowClient.prototype);
1854
+ break;
1855
+ case "AirtopWindow" /* AirtopWindow */:
1856
+ pluginToAdd.augment(AirtopWindow.prototype);
1857
+ break;
1858
+ case "AirtopWindowScreenshot" /* AirtopWindowScreenshot */:
1859
+ pluginToAdd.augment(AirtopWindowScreenshot.prototype);
1860
+ break;
1861
+ }
1862
+ }
1863
+ }
1183
1864
  export {
1865
+ AirtopAgentClient,
1184
1866
  AirtopBase,
1185
1867
  AirtopClient,
1868
+ AirtopError,
1186
1869
  AirtopMocks,
1870
+ AirtopNode,
1187
1871
  AirtopPluginAugmentationType,
1188
1872
  AirtopSession,
1189
1873
  AirtopSessionClient,
1190
1874
  AirtopWindow,
1191
1875
  AirtopWindowClient,
1192
1876
  AirtopWindowScreenshot,
1877
+ WindowNavigateDirection,
1193
1878
  registerAirtopPlugin
1194
1879
  };
1195
1880
  //# sourceMappingURL=index.js.map