@airtop/sdk 1.0.0-alpha2.11 → 1.0.0-alpha2.13

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.d.cts CHANGED
@@ -4,14 +4,14 @@ import { AirtopJsonSchemaAdapter } from '@airtop/json-schema-adapter';
4
4
  export { AirtopJsonSchemaAdapter } from '@airtop/json-schema-adapter';
5
5
  import { ILogLayer } from 'loglayer';
6
6
  export { ILogLayer } from 'loglayer';
7
+ import * as _airtop_core_resources_shared_js from '@airtop/core/resources/shared.js';
8
+ import { Issue, SessionConfigV1, GetFileResponse, FilesResponse, ListAutomationsOutput, AutomationData, ExternalSessionWithConnectionInfo, EnvelopeDefaultMeta, AIPromptResponse as AIPromptResponse$1, WindowIDDataResponse, OperationOutcomeResponse } from '@airtop/core/resources/shared.js';
9
+ export { AIResponseEnvelope, AirtopPagination, ExternalSessionAIResponseMetadata, ExternalSessionWithConnectionInfo, Issue, OperationOutcomeResponse, WindowIDDataResponse } from '@airtop/core/resources/shared.js';
7
10
  import * as _airtop_core_resources_shared_mjs from '@airtop/core/resources/shared.mjs';
8
11
  import { AutomationUpdateDescriptionParams } from '@airtop/core/resources/automations.js';
9
12
  import { SessionListParams, ProfileOutput, FileListParams, FileCreateFileParams, WindowIDData, EnvelopeDefaultMeta as EnvelopeDefaultMeta$1, Issue as Issue$1, WindowInfo, WindowGetParams, AIPromptResponse, ScrapeResponse } from '@airtop/core/resources/index.js';
10
- import * as _airtop_core_resources_shared_js from '@airtop/core/resources/shared.js';
11
- import { SessionConfigV1, GetFileResponse, FilesResponse, ListAutomationsOutput, AutomationData, ExternalSessionWithConnectionInfo, EnvelopeDefaultMeta, Issue, AIPromptResponse as AIPromptResponse$1, WindowIDDataResponse, OperationOutcomeResponse } from '@airtop/core/resources/shared.js';
12
- export { AIResponseEnvelope, AirtopPagination, ExternalSessionAIResponseMetadata, ExternalSessionWithConnectionInfo, Issue, OperationOutcomeResponse, WindowIDDataResponse } from '@airtop/core/resources/shared.js';
13
13
  import * as _airtop_core_resources_sessions_mjs from '@airtop/core/resources/sessions.mjs';
14
- import { WindowClickParams, WindowHoverParams, WindowLoadURLParams, WindowMonitorParams, WindowScrapeParams, WindowScreenshotParams, WindowScrollParams, WindowTypeParams, WindowExtractParams, WindowActParams, WindowLlmParams, WindowFindOneParams, WindowFindManyParams, WindowWaitForPageParams } from '@airtop/core/resources/windows.js';
14
+ import { WindowClickParams, WindowHoverParams, WindowLoadURLParams, WindowMonitorParams, WindowScrapeParams, WindowScreenshotParams, WindowScrollParams, WindowTypeParams, WindowExtractParams, WindowActParams, WindowLlmParams, WindowFindOneParams, WindowFindManyParams, WindowWaitForPageParams, WindowNavigateParams } from '@airtop/core/resources/windows.js';
15
15
 
16
16
  /**
17
17
  * Shared configuration between Airtop classes.
@@ -79,6 +79,14 @@ interface CommonResponse {
79
79
  warnings?: unknown;
80
80
  errors?: unknown;
81
81
  }
82
+ /**
83
+ * Custom error class that implements the Issue interface.
84
+ * Extends the native Error class to provide a more structured error handling mechanism.
85
+ */
86
+ declare class AirtopError extends Error {
87
+ issues: Issue[];
88
+ constructor(issues: Issue[]);
89
+ }
82
90
 
83
91
  /**
84
92
  * Base class for Airtop SDK implementation
@@ -482,6 +490,18 @@ interface WindowFindManyConfig extends Omit<WindowFindManyParams, "sessionId" |
482
490
  */
483
491
  interface WindowWaitForPageConfig extends Omit<WindowWaitForPageParams, "sessionId"> {
484
492
  }
493
+ /**
494
+ * Configuration parameters for navigating browser history in a window.
495
+ */
496
+ interface WindowNavigateConfig extends Omit<WindowNavigateParams, "sessionId"> {
497
+ }
498
+ /**
499
+ * The direction to navigate in browser history.
500
+ */
501
+ declare enum WindowNavigateDirection {
502
+ BACK = "backward",
503
+ FORWARD = "forward"
504
+ }
485
505
  /**
486
506
  * Data object representing a node returned from the Airtop API.
487
507
  */
@@ -540,6 +560,13 @@ declare class AirtopNode {
540
560
  * @param requestOptions - The request options to use for the find one
541
561
  */
542
562
  findOne(prompt: string, config?: WindowFindOneConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode>;
563
+ /**
564
+ * Find one element in the node
565
+ * @param prompt - The prompt to use for the find one
566
+ * @param config - The configuration to use for the find one
567
+ * @param requestOptions - The request options to use for the find one
568
+ */
569
+ findOneOptional(prompt: string, config?: WindowFindOneConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode>;
543
570
  /**
544
571
  * Find many elements in the node
545
572
  * @param prompt - The prompt to use for the find many
@@ -547,6 +574,13 @@ declare class AirtopNode {
547
574
  * @param requestOptions - The request options to use for the find many
548
575
  */
549
576
  findMany(prompt: string, config?: WindowFindManyConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
577
+ /**
578
+ * Find many elements in the node
579
+ * @param prompt - The prompt to use for the find many
580
+ * @param config - The configuration to use for the find many
581
+ * @param requestOptions - The request options to use for the find many
582
+ */
583
+ findManyOptional(prompt: string, config?: WindowFindManyConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
550
584
  }
551
585
 
552
586
  /**
@@ -714,9 +748,14 @@ declare class AirtopWindowClient extends AirtopBase {
714
748
  extract(prompt: string, config?: WindowExtractConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
715
749
  act(prompt: string, config?: WindowActConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
716
750
  llm(prompt: string, config?: WindowLlmConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
717
- findOne(prompt: string, config?: WindowFindOneConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode>;
718
- findMany(prompt: string, config?: WindowFindManyConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
751
+ private findOnePrivate;
752
+ findOne(prompt: string, config?: Omit<WindowFindOneConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode>;
753
+ findOneOptional(prompt: string, config?: Omit<WindowFindOneConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode | null>;
754
+ private findManyPrivate;
755
+ findMany(prompt: string, config?: Omit<WindowFindManyConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
756
+ findManyOptional(prompt: string, config?: Omit<WindowFindManyConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
719
757
  waitForPage(config?: WindowWaitForPageConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
758
+ navigate(direction: WindowNavigateDirection, config?: WindowNavigateConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
720
759
  }
721
760
 
722
761
  /**
@@ -1157,4 +1196,4 @@ declare class AirtopMocks {
1157
1196
  }): AirtopWindow<AirtopWindowGetInfoResponse>;
1158
1197
  }
1159
1198
 
1160
- export { type AirtopAutomationData, type AirtopAutomationListResponse, type AirtopAutomationUpdateDescriptionConfig, AirtopBase, AirtopClient, type AirtopClientPlugin, type AirtopConstructorConfig, type AirtopFileListParams, type AirtopFileResponse, type AirtopFilesResponse, AirtopMocks, AirtopNode, type AirtopNodeApiResponseData, AirtopPluginAugmentationType, type AirtopPluginRegistration, type AirtopPluginType, type AirtopProfile, type AirtopRequestOptions, AirtopSession, AirtopSessionClient, type AirtopSessionClientPlugin, type AirtopSessionPlugin, type AirtopSessionResponse, AirtopWindow, AirtopWindowClient, type AirtopWindowClientPlugin, type AirtopWindowCreateResponse, type AirtopWindowGetInfoResponse, type AirtopWindowPlugin, AirtopWindowScreenshot, type AirtopWindowScreenshotPlugin, type AirtopWindowScreenshotResponse, type CommonAirtopConfig, type CommonResponse, type CommonWindowResponse, type CreateFileConfig, type CreateSessionConfig, type GetFilesConfig, type GetSessionsConfig, type OutputJsonSchemaConfig, type ScreenshotData, type SessionData, type SessionError, type SessionMetadata, type SessionWarning, type WindowActConfig, type WindowClickConfig, type WindowCreateData, type WindowError, type WindowExtractConfig, type WindowFindManyConfig, type WindowFindOneConfig, type WindowGetConfig, type WindowHoverConfig, type WindowInfoData, type WindowLlmConfig, type WindowLoadUrlConfig, type WindowMetadata, type WindowMonitorConfig, type WindowPageQueryConfig, type WindowPaginatedExtractionConfig, type WindowPromptResponse, type WindowScrapeConfig, type WindowScrapeResponse, type WindowScreenshotConfig, type WindowScrollConfig, type WindowTypeConfig, type WindowWaitForPageConfig, type WindowWarning, registerAirtopPlugin };
1199
+ export { type AirtopAutomationData, type AirtopAutomationListResponse, type AirtopAutomationUpdateDescriptionConfig, AirtopBase, AirtopClient, type AirtopClientPlugin, type AirtopConstructorConfig, AirtopError, type AirtopFileListParams, type AirtopFileResponse, type AirtopFilesResponse, AirtopMocks, AirtopNode, type AirtopNodeApiResponseData, AirtopPluginAugmentationType, type AirtopPluginRegistration, type AirtopPluginType, type AirtopProfile, type AirtopRequestOptions, AirtopSession, AirtopSessionClient, type AirtopSessionClientPlugin, type AirtopSessionPlugin, type AirtopSessionResponse, AirtopWindow, AirtopWindowClient, type AirtopWindowClientPlugin, type AirtopWindowCreateResponse, type AirtopWindowGetInfoResponse, type AirtopWindowPlugin, AirtopWindowScreenshot, type AirtopWindowScreenshotPlugin, type AirtopWindowScreenshotResponse, type CommonAirtopConfig, type CommonResponse, type CommonWindowResponse, type CreateFileConfig, type CreateSessionConfig, type GetFilesConfig, type GetSessionsConfig, type OutputJsonSchemaConfig, type ScreenshotData, type SessionData, type SessionError, type SessionMetadata, type SessionWarning, type WindowActConfig, type WindowClickConfig, type WindowCreateData, type WindowError, type WindowExtractConfig, type WindowFindManyConfig, type WindowFindOneConfig, type WindowGetConfig, type WindowHoverConfig, type WindowInfoData, type WindowLlmConfig, type WindowLoadUrlConfig, type WindowMetadata, type WindowMonitorConfig, type WindowNavigateConfig, WindowNavigateDirection, type WindowPageQueryConfig, type WindowPaginatedExtractionConfig, type WindowPromptResponse, type WindowScrapeConfig, type WindowScrapeResponse, type WindowScreenshotConfig, type WindowScrollConfig, type WindowTypeConfig, type WindowWaitForPageConfig, type WindowWarning, registerAirtopPlugin };
package/dist/index.d.ts CHANGED
@@ -4,14 +4,14 @@ import { AirtopJsonSchemaAdapter } from '@airtop/json-schema-adapter';
4
4
  export { AirtopJsonSchemaAdapter } from '@airtop/json-schema-adapter';
5
5
  import { ILogLayer } from 'loglayer';
6
6
  export { ILogLayer } from 'loglayer';
7
+ import * as _airtop_core_resources_shared_js from '@airtop/core/resources/shared.js';
8
+ import { Issue, SessionConfigV1, GetFileResponse, FilesResponse, ListAutomationsOutput, AutomationData, ExternalSessionWithConnectionInfo, EnvelopeDefaultMeta, AIPromptResponse as AIPromptResponse$1, WindowIDDataResponse, OperationOutcomeResponse } from '@airtop/core/resources/shared.js';
9
+ export { AIResponseEnvelope, AirtopPagination, ExternalSessionAIResponseMetadata, ExternalSessionWithConnectionInfo, Issue, OperationOutcomeResponse, WindowIDDataResponse } from '@airtop/core/resources/shared.js';
7
10
  import * as _airtop_core_resources_shared_mjs from '@airtop/core/resources/shared.mjs';
8
11
  import { AutomationUpdateDescriptionParams } from '@airtop/core/resources/automations.js';
9
12
  import { SessionListParams, ProfileOutput, FileListParams, FileCreateFileParams, WindowIDData, EnvelopeDefaultMeta as EnvelopeDefaultMeta$1, Issue as Issue$1, WindowInfo, WindowGetParams, AIPromptResponse, ScrapeResponse } from '@airtop/core/resources/index.js';
10
- import * as _airtop_core_resources_shared_js from '@airtop/core/resources/shared.js';
11
- import { SessionConfigV1, GetFileResponse, FilesResponse, ListAutomationsOutput, AutomationData, ExternalSessionWithConnectionInfo, EnvelopeDefaultMeta, Issue, AIPromptResponse as AIPromptResponse$1, WindowIDDataResponse, OperationOutcomeResponse } from '@airtop/core/resources/shared.js';
12
- export { AIResponseEnvelope, AirtopPagination, ExternalSessionAIResponseMetadata, ExternalSessionWithConnectionInfo, Issue, OperationOutcomeResponse, WindowIDDataResponse } from '@airtop/core/resources/shared.js';
13
13
  import * as _airtop_core_resources_sessions_mjs from '@airtop/core/resources/sessions.mjs';
14
- import { WindowClickParams, WindowHoverParams, WindowLoadURLParams, WindowMonitorParams, WindowScrapeParams, WindowScreenshotParams, WindowScrollParams, WindowTypeParams, WindowExtractParams, WindowActParams, WindowLlmParams, WindowFindOneParams, WindowFindManyParams, WindowWaitForPageParams } from '@airtop/core/resources/windows.js';
14
+ import { WindowClickParams, WindowHoverParams, WindowLoadURLParams, WindowMonitorParams, WindowScrapeParams, WindowScreenshotParams, WindowScrollParams, WindowTypeParams, WindowExtractParams, WindowActParams, WindowLlmParams, WindowFindOneParams, WindowFindManyParams, WindowWaitForPageParams, WindowNavigateParams } from '@airtop/core/resources/windows.js';
15
15
 
16
16
  /**
17
17
  * Shared configuration between Airtop classes.
@@ -79,6 +79,14 @@ interface CommonResponse {
79
79
  warnings?: unknown;
80
80
  errors?: unknown;
81
81
  }
82
+ /**
83
+ * Custom error class that implements the Issue interface.
84
+ * Extends the native Error class to provide a more structured error handling mechanism.
85
+ */
86
+ declare class AirtopError extends Error {
87
+ issues: Issue[];
88
+ constructor(issues: Issue[]);
89
+ }
82
90
 
83
91
  /**
84
92
  * Base class for Airtop SDK implementation
@@ -482,6 +490,18 @@ interface WindowFindManyConfig extends Omit<WindowFindManyParams, "sessionId" |
482
490
  */
483
491
  interface WindowWaitForPageConfig extends Omit<WindowWaitForPageParams, "sessionId"> {
484
492
  }
493
+ /**
494
+ * Configuration parameters for navigating browser history in a window.
495
+ */
496
+ interface WindowNavigateConfig extends Omit<WindowNavigateParams, "sessionId"> {
497
+ }
498
+ /**
499
+ * The direction to navigate in browser history.
500
+ */
501
+ declare enum WindowNavigateDirection {
502
+ BACK = "backward",
503
+ FORWARD = "forward"
504
+ }
485
505
  /**
486
506
  * Data object representing a node returned from the Airtop API.
487
507
  */
@@ -540,6 +560,13 @@ declare class AirtopNode {
540
560
  * @param requestOptions - The request options to use for the find one
541
561
  */
542
562
  findOne(prompt: string, config?: WindowFindOneConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode>;
563
+ /**
564
+ * Find one element in the node
565
+ * @param prompt - The prompt to use for the find one
566
+ * @param config - The configuration to use for the find one
567
+ * @param requestOptions - The request options to use for the find one
568
+ */
569
+ findOneOptional(prompt: string, config?: WindowFindOneConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode>;
543
570
  /**
544
571
  * Find many elements in the node
545
572
  * @param prompt - The prompt to use for the find many
@@ -547,6 +574,13 @@ declare class AirtopNode {
547
574
  * @param requestOptions - The request options to use for the find many
548
575
  */
549
576
  findMany(prompt: string, config?: WindowFindManyConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
577
+ /**
578
+ * Find many elements in the node
579
+ * @param prompt - The prompt to use for the find many
580
+ * @param config - The configuration to use for the find many
581
+ * @param requestOptions - The request options to use for the find many
582
+ */
583
+ findManyOptional(prompt: string, config?: WindowFindManyConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
550
584
  }
551
585
 
552
586
  /**
@@ -714,9 +748,14 @@ declare class AirtopWindowClient extends AirtopBase {
714
748
  extract(prompt: string, config?: WindowExtractConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
715
749
  act(prompt: string, config?: WindowActConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
716
750
  llm(prompt: string, config?: WindowLlmConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
717
- findOne(prompt: string, config?: WindowFindOneConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode>;
718
- findMany(prompt: string, config?: WindowFindManyConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
751
+ private findOnePrivate;
752
+ findOne(prompt: string, config?: Omit<WindowFindOneConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode>;
753
+ findOneOptional(prompt: string, config?: Omit<WindowFindOneConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode | null>;
754
+ private findManyPrivate;
755
+ findMany(prompt: string, config?: Omit<WindowFindManyConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
756
+ findManyOptional(prompt: string, config?: Omit<WindowFindManyConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
719
757
  waitForPage(config?: WindowWaitForPageConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
758
+ navigate(direction: WindowNavigateDirection, config?: WindowNavigateConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
720
759
  }
721
760
 
722
761
  /**
@@ -1157,4 +1196,4 @@ declare class AirtopMocks {
1157
1196
  }): AirtopWindow<AirtopWindowGetInfoResponse>;
1158
1197
  }
1159
1198
 
1160
- export { type AirtopAutomationData, type AirtopAutomationListResponse, type AirtopAutomationUpdateDescriptionConfig, AirtopBase, AirtopClient, type AirtopClientPlugin, type AirtopConstructorConfig, type AirtopFileListParams, type AirtopFileResponse, type AirtopFilesResponse, AirtopMocks, AirtopNode, type AirtopNodeApiResponseData, AirtopPluginAugmentationType, type AirtopPluginRegistration, type AirtopPluginType, type AirtopProfile, type AirtopRequestOptions, AirtopSession, AirtopSessionClient, type AirtopSessionClientPlugin, type AirtopSessionPlugin, type AirtopSessionResponse, AirtopWindow, AirtopWindowClient, type AirtopWindowClientPlugin, type AirtopWindowCreateResponse, type AirtopWindowGetInfoResponse, type AirtopWindowPlugin, AirtopWindowScreenshot, type AirtopWindowScreenshotPlugin, type AirtopWindowScreenshotResponse, type CommonAirtopConfig, type CommonResponse, type CommonWindowResponse, type CreateFileConfig, type CreateSessionConfig, type GetFilesConfig, type GetSessionsConfig, type OutputJsonSchemaConfig, type ScreenshotData, type SessionData, type SessionError, type SessionMetadata, type SessionWarning, type WindowActConfig, type WindowClickConfig, type WindowCreateData, type WindowError, type WindowExtractConfig, type WindowFindManyConfig, type WindowFindOneConfig, type WindowGetConfig, type WindowHoverConfig, type WindowInfoData, type WindowLlmConfig, type WindowLoadUrlConfig, type WindowMetadata, type WindowMonitorConfig, type WindowPageQueryConfig, type WindowPaginatedExtractionConfig, type WindowPromptResponse, type WindowScrapeConfig, type WindowScrapeResponse, type WindowScreenshotConfig, type WindowScrollConfig, type WindowTypeConfig, type WindowWaitForPageConfig, type WindowWarning, registerAirtopPlugin };
1199
+ export { type AirtopAutomationData, type AirtopAutomationListResponse, type AirtopAutomationUpdateDescriptionConfig, AirtopBase, AirtopClient, type AirtopClientPlugin, type AirtopConstructorConfig, AirtopError, type AirtopFileListParams, type AirtopFileResponse, type AirtopFilesResponse, AirtopMocks, AirtopNode, type AirtopNodeApiResponseData, AirtopPluginAugmentationType, type AirtopPluginRegistration, type AirtopPluginType, type AirtopProfile, type AirtopRequestOptions, AirtopSession, AirtopSessionClient, type AirtopSessionClientPlugin, type AirtopSessionPlugin, type AirtopSessionResponse, AirtopWindow, AirtopWindowClient, type AirtopWindowClientPlugin, type AirtopWindowCreateResponse, type AirtopWindowGetInfoResponse, type AirtopWindowPlugin, AirtopWindowScreenshot, type AirtopWindowScreenshotPlugin, type AirtopWindowScreenshotResponse, type CommonAirtopConfig, type CommonResponse, type CommonWindowResponse, type CreateFileConfig, type CreateSessionConfig, type GetFilesConfig, type GetSessionsConfig, type OutputJsonSchemaConfig, type ScreenshotData, type SessionData, type SessionError, type SessionMetadata, type SessionWarning, type WindowActConfig, type WindowClickConfig, type WindowCreateData, type WindowError, type WindowExtractConfig, type WindowFindManyConfig, type WindowFindOneConfig, type WindowGetConfig, type WindowHoverConfig, type WindowInfoData, type WindowLlmConfig, type WindowLoadUrlConfig, type WindowMetadata, type WindowMonitorConfig, type WindowNavigateConfig, WindowNavigateDirection, type WindowPageQueryConfig, type WindowPaginatedExtractionConfig, type WindowPromptResponse, type WindowScrapeConfig, type WindowScrapeResponse, type WindowScreenshotConfig, type WindowScrollConfig, type WindowTypeConfig, type WindowWaitForPageConfig, type WindowWarning, registerAirtopPlugin };
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.11",
12
+ version: "1.0.0-alpha2.13",
13
13
  type: "module",
14
14
  main: "./dist/index.cjs",
15
15
  module: "./dist/index.js",
@@ -47,7 +47,7 @@ var require_package = __commonJS({
47
47
  },
48
48
  dependencies: {
49
49
  "@airtop/json-schema-adapter": "workspace:*",
50
- "@airtop/core": "0.1.0-alpha.27",
50
+ "@airtop/core": "0.1.0-alpha.28",
51
51
  "date-fns": "4.1.0",
52
52
  loglayer: "6.3.3",
53
53
  "serialize-error": "12.0.0",
@@ -264,13 +264,23 @@ var processLogMessage = (log, logLevel, ...args) => {
264
264
  // src/session/AirtopSessionClient.ts
265
265
  import { NotFoundError } from "@airtop/core";
266
266
 
267
+ // src/types.ts
268
+ var AirtopError = class extends Error {
269
+ issues;
270
+ constructor(issues) {
271
+ const errorMessage = issues.map((issue) => issue.message).join("\n");
272
+ super(errorMessage);
273
+ this.issues = issues;
274
+ }
275
+ };
276
+
267
277
  // src/window/AirtopWindowClient.ts
268
278
  import { secondsToMilliseconds as secondsToMilliseconds3 } from "date-fns";
269
279
 
270
280
  // src/async-utils.ts
271
281
  import { secondsToMilliseconds as secondsToMilliseconds2 } from "date-fns";
272
282
  var DEFAULT_TIMEOUT_SECONDS = 300;
273
- var DEFAULT_POLLING_INTERVAL_SECONDS = 2;
283
+ var DEFAULT_POLLING_INTERVAL_MS = 500;
274
284
  async function waitForRequestCompletion(client, requestId, requestOptions) {
275
285
  const startTime = Date.now();
276
286
  const timeoutMs = secondsToMilliseconds2(requestOptions?.timeoutInSeconds || DEFAULT_TIMEOUT_SECONDS);
@@ -282,7 +292,7 @@ async function waitForRequestCompletion(client, requestId, requestOptions) {
282
292
  if (apiResponse.status === "error") {
283
293
  throw new Error(apiResponse.error);
284
294
  }
285
- await new Promise((resolve) => setTimeout(resolve, secondsToMilliseconds2(DEFAULT_POLLING_INTERVAL_SECONDS)));
295
+ await new Promise((resolve) => setTimeout(resolve, DEFAULT_POLLING_INTERVAL_MS));
286
296
  }
287
297
  throw new Error("Waiting for request timed out");
288
298
  }
@@ -363,6 +373,19 @@ var AirtopNode = class {
363
373
  };
364
374
  return this.windowClient.findOne(prompt, augmentedConfig, requestOptions);
365
375
  }
376
+ /**
377
+ * Find one element in the node
378
+ * @param prompt - The prompt to use for the find one
379
+ * @param config - The configuration to use for the find one
380
+ * @param requestOptions - The request options to use for the find one
381
+ */
382
+ async findOneOptional(prompt, config, requestOptions = {}) {
383
+ const augmentedConfig = {
384
+ ...config,
385
+ nodeHandleId: this.nodeHandleId
386
+ };
387
+ return this.windowClient.findOneOptional(prompt, augmentedConfig, requestOptions);
388
+ }
366
389
  /**
367
390
  * Find many elements in the node
368
391
  * @param prompt - The prompt to use for the find many
@@ -376,6 +399,19 @@ var AirtopNode = class {
376
399
  };
377
400
  return this.windowClient.findMany(prompt, augmentedConfig, requestOptions);
378
401
  }
402
+ /**
403
+ * Find many elements in the node
404
+ * @param prompt - The prompt to use for the find many
405
+ * @param config - The configuration to use for the find many
406
+ * @param requestOptions - The request options to use for the find many
407
+ */
408
+ async findManyOptional(prompt, config, requestOptions = {}) {
409
+ const augmentedConfig = {
410
+ ...config,
411
+ nodeHandleId: this.nodeHandleId
412
+ };
413
+ return this.windowClient.findManyOptional(prompt, augmentedConfig, requestOptions);
414
+ }
379
415
  };
380
416
 
381
417
  // src/window/AirtopWindowScreenshot.ts
@@ -811,7 +847,7 @@ var AirtopWindowClient = class extends AirtopBase {
811
847
  )
812
848
  );
813
849
  }
814
- async findOne(prompt, config, requestOptions = {}) {
850
+ async findOnePrivate(prompt, config, requestOptions = {}) {
815
851
  this.log.withMetadata({ prompt }).info("Executing LLM call");
816
852
  const apiResponse = await withRequestCompletionPolling(
817
853
  this.client,
@@ -829,15 +865,32 @@ var AirtopWindowClient = class extends AirtopBase {
829
865
  }
830
866
  )
831
867
  );
868
+ if (apiResponse.errors.length > 0) {
869
+ throw new AirtopError(apiResponse.errors);
870
+ }
832
871
  try {
872
+ if (!apiResponse.data.modelResponse) {
873
+ return null;
874
+ }
833
875
  const nodeData = JSON.parse(apiResponse.data.modelResponse);
876
+ if (Object.keys(nodeData).length === 0) {
877
+ return null;
878
+ }
834
879
  return new AirtopNode(this, nodeData);
835
880
  } catch (error) {
836
881
  this.log.withMetadata({ nodeDataStr: apiResponse.data.modelResponse }).withError(error).error("Error parsing node data");
837
882
  throw error;
838
883
  }
839
884
  }
840
- async findMany(prompt, config, requestOptions = {}) {
885
+ async findOne(prompt, config, requestOptions = {}) {
886
+ const configOverride = { ...config, optional: false };
887
+ return await this.findOnePrivate(prompt, configOverride, requestOptions);
888
+ }
889
+ async findOneOptional(prompt, config, requestOptions = {}) {
890
+ const configOverride = { ...config, optional: true };
891
+ return await this.findOnePrivate(prompt, configOverride, requestOptions);
892
+ }
893
+ async findManyPrivate(prompt, config, requestOptions = {}) {
841
894
  this.log.withMetadata({ prompt }).info("Executing LLM call");
842
895
  const apiResponse = await withRequestCompletionPolling(
843
896
  this.client,
@@ -855,15 +908,32 @@ var AirtopWindowClient = class extends AirtopBase {
855
908
  }
856
909
  )
857
910
  );
911
+ if (apiResponse.errors.length > 0) {
912
+ throw new AirtopError(apiResponse.errors);
913
+ }
858
914
  const nodeHandles = apiResponse.data.modelResponse.split("___DELIM___");
859
915
  return nodeHandles.map((nodeDataStr) => {
860
916
  try {
917
+ if (!nodeDataStr) {
918
+ return null;
919
+ }
861
920
  const nodeData = JSON.parse(nodeDataStr);
921
+ if (Object.keys(nodeData).length === 0) {
922
+ return null;
923
+ }
862
924
  return new AirtopNode(this, nodeData);
863
925
  } catch (error) {
864
926
  this.log.withMetadata({ nodeDataStr }).withError(error).error("Error parsing node data");
865
927
  }
866
- });
928
+ }).filter((node) => !!node);
929
+ }
930
+ async findMany(prompt, config, requestOptions = {}) {
931
+ const configOverride = { ...config, optional: false };
932
+ return await this.findManyPrivate(prompt, configOverride, requestOptions);
933
+ }
934
+ async findManyOptional(prompt, config, requestOptions = {}) {
935
+ const configOverride = { ...config, optional: true };
936
+ return await this.findManyPrivate(prompt, configOverride, requestOptions);
867
937
  }
868
938
  async waitForPage(config, requestOptions = {}) {
869
939
  return await withRequestCompletionPolling(
@@ -881,6 +951,23 @@ var AirtopWindowClient = class extends AirtopBase {
881
951
  )
882
952
  );
883
953
  }
954
+ async navigate(direction, config, requestOptions = {}) {
955
+ return await withRequestCompletionPolling(
956
+ this.client,
957
+ () => this.client.windows.navigate(
958
+ this.getWindowId(),
959
+ {
960
+ direction,
961
+ sessionId: this.sessionId,
962
+ ...config || {}
963
+ },
964
+ {
965
+ timeout: secondsToMilliseconds3(600),
966
+ ...this.resolveRequestOptions(requestOptions)
967
+ }
968
+ )
969
+ );
970
+ }
884
971
  };
885
972
 
886
973
  // src/window/AirtopWindow.ts
@@ -1317,6 +1404,13 @@ var AirtopClient = class extends AirtopBase {
1317
1404
  }
1318
1405
  };
1319
1406
 
1407
+ // src/window/AirtopWindowClient.types.ts
1408
+ var WindowNavigateDirection = /* @__PURE__ */ ((WindowNavigateDirection2) => {
1409
+ WindowNavigateDirection2["BACK"] = "backward";
1410
+ WindowNavigateDirection2["FORWARD"] = "forward";
1411
+ return WindowNavigateDirection2;
1412
+ })(WindowNavigateDirection || {});
1413
+
1320
1414
  // src/plugin/AirtopPlugin.types.ts
1321
1415
  var AirtopPluginAugmentationType = /* @__PURE__ */ ((AirtopPluginAugmentationType2) => {
1322
1416
  AirtopPluginAugmentationType2["AirtopClient"] = "AirtopClient";
@@ -1447,6 +1541,7 @@ var AirtopMocks = class {
1447
1541
  export {
1448
1542
  AirtopBase,
1449
1543
  AirtopClient,
1544
+ AirtopError,
1450
1545
  AirtopMocks,
1451
1546
  AirtopNode,
1452
1547
  AirtopPluginAugmentationType,
@@ -1455,6 +1550,7 @@ export {
1455
1550
  AirtopWindow,
1456
1551
  AirtopWindowClient,
1457
1552
  AirtopWindowScreenshot,
1553
+ WindowNavigateDirection,
1458
1554
  registerAirtopPlugin
1459
1555
  };
1460
1556
  //# sourceMappingURL=index.js.map