@airtop/sdk 1.0.0-alpha2.17 → 1.0.0-alpha2.18

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
@@ -11,7 +11,7 @@ import * as _airtop_core_resources_shared_mjs from '@airtop/core/resources/share
11
11
  import { AutomationUpdateDescriptionParams } from '@airtop/core/resources/automations.js';
12
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';
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, WindowNavigateParams } from '@airtop/core/resources/windows.js';
14
+ import { WindowClickParams, WindowHoverParams, WindowLoadURLParams, WindowMonitorParams, WindowScrapeParams, WindowScreenshotParams, WindowScrollParams, WindowTypeParams, WindowExtractParams, WindowActParams, WindowLlmParams, WindowFindOneParams, WindowFindManyParams, WindowWaitForPageParams, WindowNavigateParams, WindowFillFormParams } from '@airtop/core/resources/windows.js';
15
15
 
16
16
  /**
17
17
  * Shared configuration between Airtop classes.
@@ -90,7 +90,8 @@ interface CommonResponse {
90
90
  */
91
91
  declare class AirtopError extends Error {
92
92
  issues: Issue[];
93
- constructor(issues: Issue[]);
93
+ metadata?: Record<string, unknown>;
94
+ constructor(issues: Issue[], metadata?: Record<string, unknown>);
94
95
  }
95
96
 
96
97
  /**
@@ -430,7 +431,7 @@ interface WindowLoadUrlConfig extends Omit<WindowLoadURLParams, "sessionId" | "u
430
431
  * Configuration parameters for monitoring window events.
431
432
  * Excludes session ID which is provided by the parent session.
432
433
  */
433
- interface WindowMonitorConfig extends Omit<WindowMonitorParams, "sessionId"> {
434
+ interface WindowMonitorConfig extends Omit<WindowMonitorParams, "sessionId" | "condition"> {
434
435
  }
435
436
  /**
436
437
  * Configuration parameters for performing a natural language query on page content.
@@ -493,7 +494,8 @@ interface WindowActResponse extends ActActionResponseEnvelope {
493
494
  /**
494
495
  * Configuration parameters for executing an LLM call in a window.
495
496
  */
496
- interface WindowLlmConfig extends Omit<WindowLlmParams, "sessionId" | "prompt"> {
497
+ interface WindowLlmConfig extends Omit<WindowLlmParams, "sessionId" | "jobId" | "prompt" | "includeWebContext" | "outputSchema"> {
498
+ outputSchema?: string | object;
497
499
  }
498
500
  /**
499
501
  * LLM window response.
@@ -552,6 +554,11 @@ declare enum WindowNavigateDirection {
552
554
  */
553
555
  interface AirtopNodeApiResponseData extends NodeHandle {
554
556
  }
557
+ /**
558
+ * Configuration parameters for filling a form in a window.
559
+ */
560
+ interface WindowFillFormConfig extends Omit<WindowFillFormParams, "sessionId" | "parameters"> {
561
+ }
555
562
 
556
563
  /**
557
564
  * Represents a node in the DOM
@@ -787,7 +794,7 @@ declare class AirtopWindowClient extends AirtopBase {
787
794
  * @param requestOptions - Request options
788
795
  * @returns Promise resolving when the text has been typed
789
796
  */
790
- type(text: string, config?: WindowTypeConfig, requestOptions?: AirtopRequestOptions): Promise<_airtop_core_resources_shared_mjs.AIPromptResponse>;
797
+ type(text: string, config?: WindowTypeConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
791
798
  extract(prompt: string, config?: WindowExtractConfig, requestOptions?: AirtopRequestOptions): Promise<WindowExtractResponse>;
792
799
  act(prompt: string, config?: WindowActConfig, requestOptions?: AirtopRequestOptions): Promise<WindowActResponse>;
793
800
  llm(prompt: string, config?: WindowLlmConfig, requestOptions?: AirtopRequestOptions): Promise<WindowLlmResponse>;
@@ -799,6 +806,7 @@ declare class AirtopWindowClient extends AirtopBase {
799
806
  findManyOptional(prompt: string, config?: Omit<WindowFindManyConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
800
807
  waitForPage(config?: WindowWaitForPageConfig, requestOptions?: AirtopRequestOptions): Promise<WindowWaitForPageResponse>;
801
808
  navigate(direction: WindowNavigateDirection, config?: WindowNavigateConfig, requestOptions?: AirtopRequestOptions): Promise<WindowNavigateResponse>;
809
+ fillForm(formData: string | object, config?: WindowFillFormConfig, requestOptions?: AirtopRequestOptions): Promise<AIPromptResponse>;
802
810
  }
803
811
 
804
812
  /**
@@ -860,6 +868,7 @@ declare class AirtopSessionClient extends AirtopBase {
860
868
  * Returns the browser session ID.
861
869
  */
862
870
  getSessionId(): string;
871
+ listWindows(requestOptions?: AirtopRequestOptions): Promise<_airtop_core_resources_shared_mjs.WindowsResponse>;
863
872
  /**
864
873
  * Gets the state of the session using the attached session id.
865
874
  * @param requestOptions - Request options
@@ -902,6 +911,14 @@ declare class AirtopSessionClient extends AirtopBase {
902
911
  * @param requestOptions - Request options
903
912
  */
904
913
  createFile(fileName: string, config?: CreateFileConfig, requestOptions?: AirtopRequestOptions): _airtop_core.APIPromise<_airtop_core_resources_shared_mjs.CreateFileResponse>;
914
+ llm(prompt: string, config?: WindowLlmConfig, requestOptions?: AirtopRequestOptions): Promise<WindowLlmResponse>;
915
+ /**
916
+ * Calls the service endpoint.
917
+ * @param prompt - The prompt to send to the service, describing the actions to take
918
+ * @param service - The service to call, if not provided, the service will be inferred from the prompt
919
+ * @param requestOptions - Request options
920
+ */
921
+ service(prompt: string, service?: string, requestOptions?: AirtopRequestOptions): Promise<unknown>;
905
922
  }
906
923
 
907
924
  /**
@@ -1385,4 +1402,4 @@ declare class AirtopMocks {
1385
1402
  }): AirtopWindow<AirtopWindowGetInfoResponse>;
1386
1403
  }
1387
1404
 
1388
- export { type AirtopAgentCancelInvocationParams, AirtopAgentClient, type AirtopAgentCreateAgentParams, type AirtopAgentCreateInvocationParams, type AirtopAgentCreateVersionParams, type AirtopAgentDeleteAgentsParams, type AirtopAgentDuplicateAgentParams, type AirtopAgentGetAgentsParams, type AirtopAgentGetInvocationsParams, type AirtopAgentGetVersionsParams, type AirtopAgentResponse, type AirtopAgentUpdateAgentParams, type AirtopAutomationData, type AirtopAutomationListResponse, type AirtopAutomationUpdateDescriptionConfig, AirtopBase, AirtopClient, type AirtopClientPlugin, type AirtopConstructorConfig, type AirtopCreateAgentInvocationResponse, type AirtopCreateAgentResponse, type AirtopCreateAgentVersionResponse, type AirtopDeleteAgentsResponse, type AirtopDuplicateAgentResponse, AirtopError, type AirtopFileListParams, type AirtopFileResponse, type AirtopFilesResponse, type AirtopGetAgentInvocationsResponse, type AirtopGetAgentResponse, type AirtopGetAgentVersionsResponse, type AirtopGetAgentsResponse, AirtopMocks, AirtopNode, type AirtopNodeApiResponseData, AirtopPluginAugmentationType, type AirtopPluginRegistration, type AirtopPluginType, type AirtopProfile, type AirtopRequestOptions, AirtopSession, AirtopSessionClient, type AirtopSessionClientPlugin, type AirtopSessionPlugin, type AirtopSessionResponse, type AirtopUpdateAgentResponse, 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 WindowActResponse, type WindowClickConfig, type WindowCreateData, type WindowError, type WindowExtractConfig, type WindowExtractResponse, type WindowFindManyConfig, type WindowFindManyResponse, type WindowFindOneConfig, type WindowFindOneResponse, type WindowGetConfig, type WindowHoverConfig, type WindowInfoData, type WindowLlmConfig, type WindowLlmResponse, type WindowLoadUrlConfig, type WindowMetadata, type WindowMonitorConfig, type WindowNavigateConfig, WindowNavigateDirection, type WindowNavigateResponse, type WindowPageQueryConfig, type WindowPaginatedExtractionConfig, type WindowPromptResponse, type WindowScrapeConfig, type WindowScrapeResponse, type WindowScreenshotConfig, type WindowScrollConfig, type WindowTypeConfig, type WindowWaitForPageConfig, type WindowWaitForPageResponse, type WindowWarning, registerAirtopPlugin };
1405
+ export { type AirtopAgentCancelInvocationParams, AirtopAgentClient, type AirtopAgentCreateAgentParams, type AirtopAgentCreateInvocationParams, type AirtopAgentCreateVersionParams, type AirtopAgentDeleteAgentsParams, type AirtopAgentDuplicateAgentParams, type AirtopAgentGetAgentsParams, type AirtopAgentGetInvocationsParams, type AirtopAgentGetVersionsParams, type AirtopAgentResponse, type AirtopAgentUpdateAgentParams, type AirtopAutomationData, type AirtopAutomationListResponse, type AirtopAutomationUpdateDescriptionConfig, AirtopBase, AirtopClient, type AirtopClientPlugin, type AirtopConstructorConfig, type AirtopCreateAgentInvocationResponse, type AirtopCreateAgentResponse, type AirtopCreateAgentVersionResponse, type AirtopDeleteAgentsResponse, type AirtopDuplicateAgentResponse, AirtopError, type AirtopFileListParams, type AirtopFileResponse, type AirtopFilesResponse, type AirtopGetAgentInvocationsResponse, type AirtopGetAgentResponse, type AirtopGetAgentVersionsResponse, type AirtopGetAgentsResponse, AirtopMocks, AirtopNode, type AirtopNodeApiResponseData, AirtopPluginAugmentationType, type AirtopPluginRegistration, type AirtopPluginType, type AirtopProfile, type AirtopRequestOptions, AirtopSession, AirtopSessionClient, type AirtopSessionClientPlugin, type AirtopSessionPlugin, type AirtopSessionResponse, type AirtopUpdateAgentResponse, 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 WindowActResponse, type WindowClickConfig, type WindowCreateData, type WindowError, type WindowExtractConfig, type WindowExtractResponse, type WindowFillFormConfig, type WindowFindManyConfig, type WindowFindManyResponse, type WindowFindOneConfig, type WindowFindOneResponse, type WindowGetConfig, type WindowHoverConfig, type WindowInfoData, type WindowLlmConfig, type WindowLlmResponse, type WindowLoadUrlConfig, type WindowMetadata, type WindowMonitorConfig, type WindowNavigateConfig, WindowNavigateDirection, type WindowNavigateResponse, type WindowPageQueryConfig, type WindowPaginatedExtractionConfig, type WindowPromptResponse, type WindowScrapeConfig, type WindowScrapeResponse, type WindowScreenshotConfig, type WindowScrollConfig, type WindowTypeConfig, type WindowWaitForPageConfig, type WindowWaitForPageResponse, type WindowWarning, registerAirtopPlugin };
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ import * as _airtop_core_resources_shared_mjs from '@airtop/core/resources/share
11
11
  import { AutomationUpdateDescriptionParams } from '@airtop/core/resources/automations.js';
12
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';
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, WindowNavigateParams } from '@airtop/core/resources/windows.js';
14
+ import { WindowClickParams, WindowHoverParams, WindowLoadURLParams, WindowMonitorParams, WindowScrapeParams, WindowScreenshotParams, WindowScrollParams, WindowTypeParams, WindowExtractParams, WindowActParams, WindowLlmParams, WindowFindOneParams, WindowFindManyParams, WindowWaitForPageParams, WindowNavigateParams, WindowFillFormParams } from '@airtop/core/resources/windows.js';
15
15
 
16
16
  /**
17
17
  * Shared configuration between Airtop classes.
@@ -90,7 +90,8 @@ interface CommonResponse {
90
90
  */
91
91
  declare class AirtopError extends Error {
92
92
  issues: Issue[];
93
- constructor(issues: Issue[]);
93
+ metadata?: Record<string, unknown>;
94
+ constructor(issues: Issue[], metadata?: Record<string, unknown>);
94
95
  }
95
96
 
96
97
  /**
@@ -430,7 +431,7 @@ interface WindowLoadUrlConfig extends Omit<WindowLoadURLParams, "sessionId" | "u
430
431
  * Configuration parameters for monitoring window events.
431
432
  * Excludes session ID which is provided by the parent session.
432
433
  */
433
- interface WindowMonitorConfig extends Omit<WindowMonitorParams, "sessionId"> {
434
+ interface WindowMonitorConfig extends Omit<WindowMonitorParams, "sessionId" | "condition"> {
434
435
  }
435
436
  /**
436
437
  * Configuration parameters for performing a natural language query on page content.
@@ -493,7 +494,8 @@ interface WindowActResponse extends ActActionResponseEnvelope {
493
494
  /**
494
495
  * Configuration parameters for executing an LLM call in a window.
495
496
  */
496
- interface WindowLlmConfig extends Omit<WindowLlmParams, "sessionId" | "prompt"> {
497
+ interface WindowLlmConfig extends Omit<WindowLlmParams, "sessionId" | "jobId" | "prompt" | "includeWebContext" | "outputSchema"> {
498
+ outputSchema?: string | object;
497
499
  }
498
500
  /**
499
501
  * LLM window response.
@@ -552,6 +554,11 @@ declare enum WindowNavigateDirection {
552
554
  */
553
555
  interface AirtopNodeApiResponseData extends NodeHandle {
554
556
  }
557
+ /**
558
+ * Configuration parameters for filling a form in a window.
559
+ */
560
+ interface WindowFillFormConfig extends Omit<WindowFillFormParams, "sessionId" | "parameters"> {
561
+ }
555
562
 
556
563
  /**
557
564
  * Represents a node in the DOM
@@ -787,7 +794,7 @@ declare class AirtopWindowClient extends AirtopBase {
787
794
  * @param requestOptions - Request options
788
795
  * @returns Promise resolving when the text has been typed
789
796
  */
790
- type(text: string, config?: WindowTypeConfig, requestOptions?: AirtopRequestOptions): Promise<_airtop_core_resources_shared_mjs.AIPromptResponse>;
797
+ type(text: string, config?: WindowTypeConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
791
798
  extract(prompt: string, config?: WindowExtractConfig, requestOptions?: AirtopRequestOptions): Promise<WindowExtractResponse>;
792
799
  act(prompt: string, config?: WindowActConfig, requestOptions?: AirtopRequestOptions): Promise<WindowActResponse>;
793
800
  llm(prompt: string, config?: WindowLlmConfig, requestOptions?: AirtopRequestOptions): Promise<WindowLlmResponse>;
@@ -799,6 +806,7 @@ declare class AirtopWindowClient extends AirtopBase {
799
806
  findManyOptional(prompt: string, config?: Omit<WindowFindManyConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
800
807
  waitForPage(config?: WindowWaitForPageConfig, requestOptions?: AirtopRequestOptions): Promise<WindowWaitForPageResponse>;
801
808
  navigate(direction: WindowNavigateDirection, config?: WindowNavigateConfig, requestOptions?: AirtopRequestOptions): Promise<WindowNavigateResponse>;
809
+ fillForm(formData: string | object, config?: WindowFillFormConfig, requestOptions?: AirtopRequestOptions): Promise<AIPromptResponse>;
802
810
  }
803
811
 
804
812
  /**
@@ -860,6 +868,7 @@ declare class AirtopSessionClient extends AirtopBase {
860
868
  * Returns the browser session ID.
861
869
  */
862
870
  getSessionId(): string;
871
+ listWindows(requestOptions?: AirtopRequestOptions): Promise<_airtop_core_resources_shared_mjs.WindowsResponse>;
863
872
  /**
864
873
  * Gets the state of the session using the attached session id.
865
874
  * @param requestOptions - Request options
@@ -902,6 +911,14 @@ declare class AirtopSessionClient extends AirtopBase {
902
911
  * @param requestOptions - Request options
903
912
  */
904
913
  createFile(fileName: string, config?: CreateFileConfig, requestOptions?: AirtopRequestOptions): _airtop_core.APIPromise<_airtop_core_resources_shared_mjs.CreateFileResponse>;
914
+ llm(prompt: string, config?: WindowLlmConfig, requestOptions?: AirtopRequestOptions): Promise<WindowLlmResponse>;
915
+ /**
916
+ * Calls the service endpoint.
917
+ * @param prompt - The prompt to send to the service, describing the actions to take
918
+ * @param service - The service to call, if not provided, the service will be inferred from the prompt
919
+ * @param requestOptions - Request options
920
+ */
921
+ service(prompt: string, service?: string, requestOptions?: AirtopRequestOptions): Promise<unknown>;
905
922
  }
906
923
 
907
924
  /**
@@ -1385,4 +1402,4 @@ declare class AirtopMocks {
1385
1402
  }): AirtopWindow<AirtopWindowGetInfoResponse>;
1386
1403
  }
1387
1404
 
1388
- export { type AirtopAgentCancelInvocationParams, AirtopAgentClient, type AirtopAgentCreateAgentParams, type AirtopAgentCreateInvocationParams, type AirtopAgentCreateVersionParams, type AirtopAgentDeleteAgentsParams, type AirtopAgentDuplicateAgentParams, type AirtopAgentGetAgentsParams, type AirtopAgentGetInvocationsParams, type AirtopAgentGetVersionsParams, type AirtopAgentResponse, type AirtopAgentUpdateAgentParams, type AirtopAutomationData, type AirtopAutomationListResponse, type AirtopAutomationUpdateDescriptionConfig, AirtopBase, AirtopClient, type AirtopClientPlugin, type AirtopConstructorConfig, type AirtopCreateAgentInvocationResponse, type AirtopCreateAgentResponse, type AirtopCreateAgentVersionResponse, type AirtopDeleteAgentsResponse, type AirtopDuplicateAgentResponse, AirtopError, type AirtopFileListParams, type AirtopFileResponse, type AirtopFilesResponse, type AirtopGetAgentInvocationsResponse, type AirtopGetAgentResponse, type AirtopGetAgentVersionsResponse, type AirtopGetAgentsResponse, AirtopMocks, AirtopNode, type AirtopNodeApiResponseData, AirtopPluginAugmentationType, type AirtopPluginRegistration, type AirtopPluginType, type AirtopProfile, type AirtopRequestOptions, AirtopSession, AirtopSessionClient, type AirtopSessionClientPlugin, type AirtopSessionPlugin, type AirtopSessionResponse, type AirtopUpdateAgentResponse, 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 WindowActResponse, type WindowClickConfig, type WindowCreateData, type WindowError, type WindowExtractConfig, type WindowExtractResponse, type WindowFindManyConfig, type WindowFindManyResponse, type WindowFindOneConfig, type WindowFindOneResponse, type WindowGetConfig, type WindowHoverConfig, type WindowInfoData, type WindowLlmConfig, type WindowLlmResponse, type WindowLoadUrlConfig, type WindowMetadata, type WindowMonitorConfig, type WindowNavigateConfig, WindowNavigateDirection, type WindowNavigateResponse, type WindowPageQueryConfig, type WindowPaginatedExtractionConfig, type WindowPromptResponse, type WindowScrapeConfig, type WindowScrapeResponse, type WindowScreenshotConfig, type WindowScrollConfig, type WindowTypeConfig, type WindowWaitForPageConfig, type WindowWaitForPageResponse, type WindowWarning, registerAirtopPlugin };
1405
+ export { type AirtopAgentCancelInvocationParams, AirtopAgentClient, type AirtopAgentCreateAgentParams, type AirtopAgentCreateInvocationParams, type AirtopAgentCreateVersionParams, type AirtopAgentDeleteAgentsParams, type AirtopAgentDuplicateAgentParams, type AirtopAgentGetAgentsParams, type AirtopAgentGetInvocationsParams, type AirtopAgentGetVersionsParams, type AirtopAgentResponse, type AirtopAgentUpdateAgentParams, type AirtopAutomationData, type AirtopAutomationListResponse, type AirtopAutomationUpdateDescriptionConfig, AirtopBase, AirtopClient, type AirtopClientPlugin, type AirtopConstructorConfig, type AirtopCreateAgentInvocationResponse, type AirtopCreateAgentResponse, type AirtopCreateAgentVersionResponse, type AirtopDeleteAgentsResponse, type AirtopDuplicateAgentResponse, AirtopError, type AirtopFileListParams, type AirtopFileResponse, type AirtopFilesResponse, type AirtopGetAgentInvocationsResponse, type AirtopGetAgentResponse, type AirtopGetAgentVersionsResponse, type AirtopGetAgentsResponse, AirtopMocks, AirtopNode, type AirtopNodeApiResponseData, AirtopPluginAugmentationType, type AirtopPluginRegistration, type AirtopPluginType, type AirtopProfile, type AirtopRequestOptions, AirtopSession, AirtopSessionClient, type AirtopSessionClientPlugin, type AirtopSessionPlugin, type AirtopSessionResponse, type AirtopUpdateAgentResponse, 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 WindowActResponse, type WindowClickConfig, type WindowCreateData, type WindowError, type WindowExtractConfig, type WindowExtractResponse, type WindowFillFormConfig, type WindowFindManyConfig, type WindowFindManyResponse, type WindowFindOneConfig, type WindowFindOneResponse, type WindowGetConfig, type WindowHoverConfig, type WindowInfoData, type WindowLlmConfig, type WindowLlmResponse, type WindowLoadUrlConfig, type WindowMetadata, type WindowMonitorConfig, type WindowNavigateConfig, WindowNavigateDirection, type WindowNavigateResponse, type WindowPageQueryConfig, type WindowPaginatedExtractionConfig, type WindowPromptResponse, type WindowScrapeConfig, type WindowScrapeResponse, type WindowScreenshotConfig, type WindowScrollConfig, type WindowTypeConfig, type WindowWaitForPageConfig, type WindowWaitForPageResponse, 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.17",
12
+ version: "1.0.0-alpha2.18",
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.30",
50
+ "@airtop/core": "0.1.0-alpha.33",
51
51
  "date-fns": "4.1.0",
52
52
  loglayer: "6.3.3",
53
53
  "serialize-error": "12.0.0",
@@ -268,22 +268,26 @@ var processLogMessage = (log, logLevel, ...args) => {
268
268
 
269
269
  // src/session/AirtopSessionClient.ts
270
270
  import { NotFoundError } from "@airtop/core";
271
+ import { secondsToMilliseconds as secondsToMilliseconds4 } from "date-fns";
272
+
273
+ // src/async-utils.ts
274
+ import { secondsToMilliseconds as secondsToMilliseconds2 } from "date-fns";
271
275
 
272
276
  // src/types.ts
273
277
  var AirtopError = class extends Error {
274
278
  issues;
275
- constructor(issues) {
279
+ metadata;
280
+ constructor(issues, metadata) {
276
281
  const errorMessage = issues.map((issue) => issue.message).join("\n");
277
- super(errorMessage);
282
+ const errorMessageWithMetadata = metadata ? `${errorMessage}
283
+ ${JSON.stringify(metadata)}` : errorMessage;
284
+ super(errorMessageWithMetadata);
278
285
  this.issues = issues;
286
+ this.metadata = metadata;
279
287
  }
280
288
  };
281
289
 
282
- // src/window/AirtopWindowClient.ts
283
- import { secondsToMilliseconds as secondsToMilliseconds3 } from "date-fns";
284
-
285
290
  // src/async-utils.ts
286
- import { secondsToMilliseconds as secondsToMilliseconds2 } from "date-fns";
287
291
  var DEFAULT_TIMEOUT_SECONDS = 300;
288
292
  var DEFAULT_POLLING_INTERVAL_MS = 500;
289
293
  async function waitForRequestCompletion(client, requestId, requestOptions) {
@@ -307,12 +311,17 @@ async function withRequestCompletionPolling(client, fn, requestOptions) {
307
311
  return waitForRequestCompletion(client, response.requestId, requestOptions);
308
312
  } catch (thrownError) {
309
313
  if (thrownError.error?.errors) {
310
- throw new AirtopError(thrownError.error.errors);
314
+ throw new AirtopError(thrownError.error.errors, {
315
+ requestId: thrownError.error.requestId
316
+ });
311
317
  }
312
318
  throw thrownError;
313
319
  }
314
320
  }
315
321
 
322
+ // src/window/AirtopWindowClient.ts
323
+ import { secondsToMilliseconds as secondsToMilliseconds3 } from "date-fns";
324
+
316
325
  // src/window/AirtopNode.ts
317
326
  var AirtopNode = class {
318
327
  /**
@@ -370,7 +379,7 @@ var AirtopNode = class {
370
379
  * @param requestOptions - The request options to use for the LLM call
371
380
  */
372
381
  async llm(prompt, config, requestOptions = {}) {
373
- return this.windowClient.llm(prompt, config, requestOptions);
382
+ return this.windowClient.llm(prompt, { ...config, nodeHandleId: this.nodeHandleId }, requestOptions);
374
383
  }
375
384
  /**
376
385
  * Find one element in the node
@@ -579,17 +588,20 @@ var AirtopWindowClient = class extends AirtopBase {
579
588
  this.log.withMetadata({
580
589
  elementDescription
581
590
  }).info("Clicking on element");
582
- return this.client.windows.click(
583
- this.getWindowId(),
584
- {
585
- ...config,
586
- elementDescription,
587
- sessionId: this.sessionId
588
- },
589
- {
590
- timeout: secondsToMilliseconds3(600),
591
- ...this.resolveRequestOptions(requestOptions)
592
- }
591
+ return withRequestCompletionPolling(
592
+ this.client,
593
+ () => this.client.windows.clickAsync(
594
+ this.getWindowId(),
595
+ {
596
+ ...config,
597
+ elementDescription,
598
+ sessionId: this.sessionId
599
+ },
600
+ {
601
+ timeout: secondsToMilliseconds3(600),
602
+ ...this.resolveRequestOptions(requestOptions)
603
+ }
604
+ )
593
605
  );
594
606
  }
595
607
  /**
@@ -611,17 +623,20 @@ var AirtopWindowClient = class extends AirtopBase {
611
623
  */
612
624
  async hover(elementDescription, config, requestOptions = {}) {
613
625
  this.log.withMetadata(config).info("Hovering over window");
614
- return this.client.windows.hover(
615
- this.getWindowId(),
616
- {
617
- elementDescription,
618
- sessionId: this.sessionId,
619
- ...config || {}
620
- },
621
- {
622
- timeout: secondsToMilliseconds3(600),
623
- ...this.resolveRequestOptions(requestOptions)
624
- }
626
+ return withRequestCompletionPolling(
627
+ this.client,
628
+ () => this.client.windows.hoverAsync(
629
+ this.getWindowId(),
630
+ {
631
+ elementDescription,
632
+ sessionId: this.sessionId,
633
+ ...config || {}
634
+ },
635
+ {
636
+ timeout: secondsToMilliseconds3(600),
637
+ ...this.resolveRequestOptions(requestOptions)
638
+ }
639
+ )
625
640
  );
626
641
  }
627
642
  /**
@@ -657,17 +672,20 @@ var AirtopWindowClient = class extends AirtopBase {
657
672
  */
658
673
  async monitor(condition, config, requestOptions = {}) {
659
674
  this.log.withMetadata().info("Monitoring window");
660
- return this.client.windows.monitor(
661
- this.getWindowId(),
662
- {
663
- condition,
664
- sessionId: this.sessionId,
665
- ...config || {}
666
- },
667
- {
668
- timeout: secondsToMilliseconds3(600),
669
- ...this.resolveRequestOptions(requestOptions)
670
- }
675
+ return withRequestCompletionPolling(
676
+ this.client,
677
+ () => this.client.windows.monitorAsync(
678
+ this.getWindowId(),
679
+ {
680
+ condition,
681
+ sessionId: this.sessionId,
682
+ ...config || {}
683
+ },
684
+ {
685
+ timeout: secondsToMilliseconds3(600),
686
+ ...this.resolveRequestOptions(requestOptions)
687
+ }
688
+ )
671
689
  );
672
690
  }
673
691
  /**
@@ -685,17 +703,20 @@ var AirtopWindowClient = class extends AirtopBase {
685
703
  if (config?.configuration.outputSchema) {
686
704
  newConfig.configuration.outputSchema = this.convertToJsonSchema(config.configuration.outputSchema);
687
705
  }
688
- return this.client.windows.pageQuery(
689
- this.getWindowId(),
690
- {
691
- sessionId: this.sessionId,
692
- prompt,
693
- ...newConfig || {}
694
- },
695
- {
696
- timeout: secondsToMilliseconds3(600),
697
- ...this.resolveRequestOptions(requestOptions)
698
- }
706
+ return withRequestCompletionPolling(
707
+ this.client,
708
+ () => this.client.windows.pageQueryAsync(
709
+ this.getWindowId(),
710
+ {
711
+ sessionId: this.sessionId,
712
+ prompt,
713
+ ...newConfig || {}
714
+ },
715
+ {
716
+ timeout: secondsToMilliseconds3(600),
717
+ ...this.resolveRequestOptions(requestOptions)
718
+ }
719
+ )
699
720
  );
700
721
  }
701
722
  /**
@@ -713,17 +734,20 @@ var AirtopWindowClient = class extends AirtopBase {
713
734
  if (config?.configuration.outputSchema) {
714
735
  newConfig.configuration.outputSchema = this.convertToJsonSchema(config.configuration.outputSchema);
715
736
  }
716
- return this.client.windows.paginatedExtraction(
717
- this.getWindowId(),
718
- {
719
- prompt,
720
- sessionId: this.sessionId,
721
- ...newConfig || {}
722
- },
723
- {
724
- timeout: secondsToMilliseconds3(600),
725
- ...this.resolveRequestOptions(requestOptions)
726
- }
737
+ return withRequestCompletionPolling(
738
+ this.client,
739
+ () => this.client.windows.paginatedExtractionAsync(
740
+ this.getWindowId(),
741
+ {
742
+ prompt,
743
+ sessionId: this.sessionId,
744
+ ...newConfig || {}
745
+ },
746
+ {
747
+ timeout: secondsToMilliseconds3(600),
748
+ ...this.resolveRequestOptions(requestOptions)
749
+ }
750
+ )
727
751
  );
728
752
  }
729
753
  /**
@@ -754,16 +778,19 @@ var AirtopWindowClient = class extends AirtopBase {
754
778
  */
755
779
  async screenshot(config, requestOptions = {}) {
756
780
  this.log.info("Screenshotting window");
757
- const resp = await this.client.windows.screenshot(
758
- this.getWindowId(),
759
- {
760
- sessionId: this.sessionId,
761
- ...config || {}
762
- },
763
- {
764
- timeout: secondsToMilliseconds3(600),
765
- ...this.resolveRequestOptions(requestOptions)
766
- }
781
+ const resp = await withRequestCompletionPolling(
782
+ this.client,
783
+ () => this.client.windows.screenshotAsync(
784
+ this.getWindowId(),
785
+ {
786
+ sessionId: this.sessionId,
787
+ ...config || {}
788
+ },
789
+ {
790
+ timeout: secondsToMilliseconds3(600),
791
+ ...this.resolveRequestOptions(requestOptions)
792
+ }
793
+ )
767
794
  );
768
795
  return new AirtopWindowScreenshot(resp);
769
796
  }
@@ -798,17 +825,20 @@ var AirtopWindowClient = class extends AirtopBase {
798
825
  this.log.withMetadata({
799
826
  text
800
827
  }).info("Typing text");
801
- return this.client.windows.type(
802
- this.getWindowId(),
803
- {
804
- sessionId: this.sessionId,
805
- text,
806
- ...config || {}
807
- },
808
- {
809
- timeout: secondsToMilliseconds3(600),
810
- ...this.resolveRequestOptions(requestOptions)
811
- }
828
+ return withRequestCompletionPolling(
829
+ this.client,
830
+ () => this.client.windows.typeAsync(
831
+ this.getWindowId(),
832
+ {
833
+ sessionId: this.sessionId,
834
+ text,
835
+ ...config || {}
836
+ },
837
+ {
838
+ timeout: secondsToMilliseconds3(600),
839
+ ...this.resolveRequestOptions(requestOptions)
840
+ }
841
+ )
812
842
  );
813
843
  }
814
844
  async extract(prompt, config, requestOptions = {}) {
@@ -859,7 +889,10 @@ var AirtopWindowClient = class extends AirtopBase {
859
889
  prompt,
860
890
  sessionId: this.sessionId,
861
891
  jobId: this.jobId,
862
- ...config || {}
892
+ ...config || {},
893
+ includeWebContext: true,
894
+ // Always include web context for window.llm() calls
895
+ outputSchema: config?.outputSchema ? this.convertToJsonSchema(config.outputSchema) : void 0
863
896
  },
864
897
  {
865
898
  timeout: secondsToMilliseconds3(600),
@@ -974,6 +1007,27 @@ var AirtopWindowClient = class extends AirtopBase {
974
1007
  )
975
1008
  );
976
1009
  }
1010
+ async fillForm(formData, config, requestOptions = {}) {
1011
+ return await withRequestCompletionPolling(
1012
+ this.client,
1013
+ () => this.client.windows.executeAutomation(
1014
+ this.getWindowId(),
1015
+ {
1016
+ sessionId: this.sessionId,
1017
+ ...config || {},
1018
+ automationId: config?.automationId || "auto",
1019
+ parameters: {
1020
+ customData: typeof formData === "string" ? formData : JSON.stringify(formData)
1021
+ // Will be interpreted by the LLM
1022
+ }
1023
+ },
1024
+ {
1025
+ timeout: secondsToMilliseconds3(600),
1026
+ ...this.resolveRequestOptions(requestOptions)
1027
+ }
1028
+ )
1029
+ );
1030
+ }
977
1031
  };
978
1032
 
979
1033
  // src/window/AirtopWindow.ts
@@ -1047,6 +1101,9 @@ var AirtopSessionClient = class extends AirtopBase {
1047
1101
  getSessionId() {
1048
1102
  return this.sessionId;
1049
1103
  }
1104
+ async listWindows(requestOptions = {}) {
1105
+ return this.client.sessions.listWindows(this.sessionId, this.resolveRequestOptions(requestOptions));
1106
+ }
1050
1107
  /**
1051
1108
  * Gets the state of the session using the attached session id.
1052
1109
  * @param requestOptions - Request options
@@ -1165,6 +1222,51 @@ var AirtopSessionClient = class extends AirtopBase {
1165
1222
  this.resolveRequestOptions(requestOptions)
1166
1223
  );
1167
1224
  }
1225
+ async llm(prompt, config, requestOptions = {}) {
1226
+ this.log.withMetadata({ prompt }).info("Executing LLM call");
1227
+ const currentWindows = await this.listWindows();
1228
+ if (currentWindows.data.windows.length === 0) {
1229
+ throw new AirtopError([
1230
+ {
1231
+ message: "No windows found in the session. Please create a window before calling the llm() method."
1232
+ }
1233
+ ]);
1234
+ }
1235
+ const firstWindow = currentWindows.data.windows[0];
1236
+ return withRequestCompletionPolling(
1237
+ this.client,
1238
+ () => this.client.windows.llm(
1239
+ firstWindow.windowId,
1240
+ {
1241
+ prompt,
1242
+ sessionId: this.sessionId,
1243
+ jobId: this.jobId,
1244
+ ...config || {},
1245
+ includeWebContext: false,
1246
+ // Do not include web context for session.llm() calls
1247
+ outputSchema: config?.outputSchema ? this.convertToJsonSchema(config.outputSchema) : void 0
1248
+ },
1249
+ {
1250
+ timeout: secondsToMilliseconds4(600),
1251
+ ...this.resolveRequestOptions(requestOptions)
1252
+ }
1253
+ )
1254
+ );
1255
+ }
1256
+ /**
1257
+ * Calls the service endpoint.
1258
+ * @param prompt - The prompt to send to the service, describing the actions to take
1259
+ * @param service - The service to call, if not provided, the service will be inferred from the prompt
1260
+ * @param requestOptions - Request options
1261
+ */
1262
+ async service(prompt, service, requestOptions = {}) {
1263
+ this.log.withMetadata({ prompt }).info("Service");
1264
+ return withRequestCompletionPolling(
1265
+ this.client,
1266
+ () => this.client.sessions.service(this.sessionId, { prompt, service }),
1267
+ requestOptions
1268
+ );
1269
+ }
1168
1270
  };
1169
1271
 
1170
1272
  // src/session/AirtopSession.ts