@airtop/sdk 1.0.0-alpha2.10 → 1.0.0-alpha2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +106 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -7
- package/dist/index.d.ts +49 -7
- package/dist/index.js +105 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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
|
@@ -106,11 +114,28 @@ declare class AirtopBase {
|
|
106
114
|
* @internal
|
107
115
|
*/
|
108
116
|
protected jobId?: string;
|
117
|
+
/**
|
118
|
+
* Instance for sending agent events
|
119
|
+
* @internal
|
120
|
+
*/
|
121
|
+
protected agentEventPublisher?: ILogLayer;
|
109
122
|
/**
|
110
123
|
* Creates a new instance of AirtopBase
|
111
124
|
* @param config - Configuration options for the SDK
|
112
125
|
*/
|
113
126
|
constructor(config: CommonAirtopConfig);
|
127
|
+
/**
|
128
|
+
* Sets the publisher for sending agent events. Internal use only.
|
129
|
+
* @internal
|
130
|
+
*/
|
131
|
+
_setAgentEventPublisher(logger: ILogLayer): void;
|
132
|
+
/**
|
133
|
+
* Sends a payload to the agent with the specified event name.
|
134
|
+
* @param eventName The name of the event
|
135
|
+
* @param payload The payload to send to the agent
|
136
|
+
* @internal
|
137
|
+
*/
|
138
|
+
protected _sendAgentPayload(eventName: string, payload: any): void;
|
114
139
|
/**
|
115
140
|
* Returns the API key used by the SDK
|
116
141
|
* @returns API key string
|
@@ -465,6 +490,18 @@ interface WindowFindManyConfig extends Omit<WindowFindManyParams, "sessionId" |
|
|
465
490
|
*/
|
466
491
|
interface WindowWaitForPageConfig extends Omit<WindowWaitForPageParams, "sessionId"> {
|
467
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
|
+
}
|
468
505
|
/**
|
469
506
|
* Data object representing a node returned from the Airtop API.
|
470
507
|
*/
|
@@ -697,9 +734,14 @@ declare class AirtopWindowClient extends AirtopBase {
|
|
697
734
|
extract(prompt: string, config?: WindowExtractConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
698
735
|
act(prompt: string, config?: WindowActConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
699
736
|
llm(prompt: string, config?: WindowLlmConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
700
|
-
|
701
|
-
|
737
|
+
private findOnePrivate;
|
738
|
+
findOne(prompt: string, config?: Omit<WindowFindOneConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode>;
|
739
|
+
findOneOptional(prompt: string, config?: Omit<WindowFindOneConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode | null>;
|
740
|
+
private findManyPrivate;
|
741
|
+
findMany(prompt: string, config?: Omit<WindowFindManyConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
|
742
|
+
findManyOptional(prompt: string, config?: Omit<WindowFindManyConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
|
702
743
|
waitForPage(config?: WindowWaitForPageConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
744
|
+
navigate(direction: WindowNavigateDirection, config?: WindowNavigateConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
703
745
|
}
|
704
746
|
|
705
747
|
/**
|
@@ -1140,4 +1182,4 @@ declare class AirtopMocks {
|
|
1140
1182
|
}): AirtopWindow<AirtopWindowGetInfoResponse>;
|
1141
1183
|
}
|
1142
1184
|
|
1143
|
-
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 };
|
1185
|
+
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
|
@@ -106,11 +114,28 @@ declare class AirtopBase {
|
|
106
114
|
* @internal
|
107
115
|
*/
|
108
116
|
protected jobId?: string;
|
117
|
+
/**
|
118
|
+
* Instance for sending agent events
|
119
|
+
* @internal
|
120
|
+
*/
|
121
|
+
protected agentEventPublisher?: ILogLayer;
|
109
122
|
/**
|
110
123
|
* Creates a new instance of AirtopBase
|
111
124
|
* @param config - Configuration options for the SDK
|
112
125
|
*/
|
113
126
|
constructor(config: CommonAirtopConfig);
|
127
|
+
/**
|
128
|
+
* Sets the publisher for sending agent events. Internal use only.
|
129
|
+
* @internal
|
130
|
+
*/
|
131
|
+
_setAgentEventPublisher(logger: ILogLayer): void;
|
132
|
+
/**
|
133
|
+
* Sends a payload to the agent with the specified event name.
|
134
|
+
* @param eventName The name of the event
|
135
|
+
* @param payload The payload to send to the agent
|
136
|
+
* @internal
|
137
|
+
*/
|
138
|
+
protected _sendAgentPayload(eventName: string, payload: any): void;
|
114
139
|
/**
|
115
140
|
* Returns the API key used by the SDK
|
116
141
|
* @returns API key string
|
@@ -465,6 +490,18 @@ interface WindowFindManyConfig extends Omit<WindowFindManyParams, "sessionId" |
|
|
465
490
|
*/
|
466
491
|
interface WindowWaitForPageConfig extends Omit<WindowWaitForPageParams, "sessionId"> {
|
467
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
|
+
}
|
468
505
|
/**
|
469
506
|
* Data object representing a node returned from the Airtop API.
|
470
507
|
*/
|
@@ -697,9 +734,14 @@ declare class AirtopWindowClient extends AirtopBase {
|
|
697
734
|
extract(prompt: string, config?: WindowExtractConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
698
735
|
act(prompt: string, config?: WindowActConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
699
736
|
llm(prompt: string, config?: WindowLlmConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
700
|
-
|
701
|
-
|
737
|
+
private findOnePrivate;
|
738
|
+
findOne(prompt: string, config?: Omit<WindowFindOneConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode>;
|
739
|
+
findOneOptional(prompt: string, config?: Omit<WindowFindOneConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode | null>;
|
740
|
+
private findManyPrivate;
|
741
|
+
findMany(prompt: string, config?: Omit<WindowFindManyConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
|
742
|
+
findManyOptional(prompt: string, config?: Omit<WindowFindManyConfig, "optional">, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
|
702
743
|
waitForPage(config?: WindowWaitForPageConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
744
|
+
navigate(direction: WindowNavigateDirection, config?: WindowNavigateConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
703
745
|
}
|
704
746
|
|
705
747
|
/**
|
@@ -1140,4 +1182,4 @@ declare class AirtopMocks {
|
|
1140
1182
|
}): AirtopWindow<AirtopWindowGetInfoResponse>;
|
1141
1183
|
}
|
1142
1184
|
|
1143
|
-
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 };
|
1185
|
+
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.
|
12
|
+
version: "1.0.0-alpha2.12",
|
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.
|
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",
|
@@ -107,6 +107,11 @@ var AirtopBase = class {
|
|
107
107
|
* @internal
|
108
108
|
*/
|
109
109
|
jobId;
|
110
|
+
/**
|
111
|
+
* Instance for sending agent events
|
112
|
+
* @internal
|
113
|
+
*/
|
114
|
+
agentEventPublisher;
|
110
115
|
/**
|
111
116
|
* Creates a new instance of AirtopBase
|
112
117
|
* @param config - Configuration options for the SDK
|
@@ -117,6 +122,24 @@ var AirtopBase = class {
|
|
117
122
|
this.outputJsonAdapter = config.outputSchemaAdapter;
|
118
123
|
this.jobId = config.jobId;
|
119
124
|
}
|
125
|
+
/**
|
126
|
+
* Sets the publisher for sending agent events. Internal use only.
|
127
|
+
* @internal
|
128
|
+
*/
|
129
|
+
_setAgentEventPublisher(logger) {
|
130
|
+
this.agentEventPublisher = logger;
|
131
|
+
}
|
132
|
+
/**
|
133
|
+
* Sends a payload to the agent with the specified event name.
|
134
|
+
* @param eventName The name of the event
|
135
|
+
* @param payload The payload to send to the agent
|
136
|
+
* @internal
|
137
|
+
*/
|
138
|
+
_sendAgentPayload(eventName, payload) {
|
139
|
+
if (this.agentEventPublisher) {
|
140
|
+
this.agentEventPublisher.withMetadata(payload).info(eventName);
|
141
|
+
}
|
142
|
+
}
|
120
143
|
/**
|
121
144
|
* Returns the API key used by the SDK
|
122
145
|
* @returns API key string
|
@@ -241,13 +264,23 @@ var processLogMessage = (log, logLevel, ...args) => {
|
|
241
264
|
// src/session/AirtopSessionClient.ts
|
242
265
|
import { NotFoundError } from "@airtop/core";
|
243
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
|
+
|
244
277
|
// src/window/AirtopWindowClient.ts
|
245
278
|
import { secondsToMilliseconds as secondsToMilliseconds3 } from "date-fns";
|
246
279
|
|
247
280
|
// src/async-utils.ts
|
248
281
|
import { secondsToMilliseconds as secondsToMilliseconds2 } from "date-fns";
|
249
282
|
var DEFAULT_TIMEOUT_SECONDS = 300;
|
250
|
-
var
|
283
|
+
var DEFAULT_POLLING_INTERVAL_MS = 500;
|
251
284
|
async function waitForRequestCompletion(client, requestId, requestOptions) {
|
252
285
|
const startTime = Date.now();
|
253
286
|
const timeoutMs = secondsToMilliseconds2(requestOptions?.timeoutInSeconds || DEFAULT_TIMEOUT_SECONDS);
|
@@ -259,7 +292,7 @@ async function waitForRequestCompletion(client, requestId, requestOptions) {
|
|
259
292
|
if (apiResponse.status === "error") {
|
260
293
|
throw new Error(apiResponse.error);
|
261
294
|
}
|
262
|
-
await new Promise((resolve) => setTimeout(resolve,
|
295
|
+
await new Promise((resolve) => setTimeout(resolve, DEFAULT_POLLING_INTERVAL_MS));
|
263
296
|
}
|
264
297
|
throw new Error("Waiting for request timed out");
|
265
298
|
}
|
@@ -482,6 +515,11 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
482
515
|
},
|
483
516
|
this.resolveRequestOptions(requestOptions)
|
484
517
|
);
|
518
|
+
this._sendAgentPayload("LiveViewUrl", {
|
519
|
+
liveViewUrl: results.data.liveViewUrl,
|
520
|
+
windowId: this.windowId,
|
521
|
+
sessionId: this.sessionId
|
522
|
+
});
|
485
523
|
return new AirtopWindow(this.getCommonConfig(), this.sessionId, results);
|
486
524
|
}
|
487
525
|
/**
|
@@ -783,7 +821,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
783
821
|
)
|
784
822
|
);
|
785
823
|
}
|
786
|
-
async
|
824
|
+
async findOnePrivate(prompt, config, requestOptions = {}) {
|
787
825
|
this.log.withMetadata({ prompt }).info("Executing LLM call");
|
788
826
|
const apiResponse = await withRequestCompletionPolling(
|
789
827
|
this.client,
|
@@ -801,15 +839,32 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
801
839
|
}
|
802
840
|
)
|
803
841
|
);
|
842
|
+
if (apiResponse.errors.length > 0) {
|
843
|
+
throw new AirtopError(apiResponse.errors);
|
844
|
+
}
|
804
845
|
try {
|
846
|
+
if (!apiResponse.data.modelResponse) {
|
847
|
+
return null;
|
848
|
+
}
|
805
849
|
const nodeData = JSON.parse(apiResponse.data.modelResponse);
|
850
|
+
if (Object.keys(nodeData).length === 0) {
|
851
|
+
return null;
|
852
|
+
}
|
806
853
|
return new AirtopNode(this, nodeData);
|
807
854
|
} catch (error) {
|
808
855
|
this.log.withMetadata({ nodeDataStr: apiResponse.data.modelResponse }).withError(error).error("Error parsing node data");
|
809
856
|
throw error;
|
810
857
|
}
|
811
858
|
}
|
812
|
-
async
|
859
|
+
async findOne(prompt, config, requestOptions = {}) {
|
860
|
+
const configOverride = { ...config, optional: false };
|
861
|
+
return await this.findOnePrivate(prompt, configOverride, requestOptions);
|
862
|
+
}
|
863
|
+
async findOneOptional(prompt, config, requestOptions = {}) {
|
864
|
+
const configOverride = { ...config, optional: true };
|
865
|
+
return await this.findOnePrivate(prompt, configOverride, requestOptions);
|
866
|
+
}
|
867
|
+
async findManyPrivate(prompt, config, requestOptions = {}) {
|
813
868
|
this.log.withMetadata({ prompt }).info("Executing LLM call");
|
814
869
|
const apiResponse = await withRequestCompletionPolling(
|
815
870
|
this.client,
|
@@ -827,15 +882,32 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
827
882
|
}
|
828
883
|
)
|
829
884
|
);
|
885
|
+
if (apiResponse.errors.length > 0) {
|
886
|
+
throw new AirtopError(apiResponse.errors);
|
887
|
+
}
|
830
888
|
const nodeHandles = apiResponse.data.modelResponse.split("___DELIM___");
|
831
889
|
return nodeHandles.map((nodeDataStr) => {
|
832
890
|
try {
|
891
|
+
if (!nodeDataStr) {
|
892
|
+
return null;
|
893
|
+
}
|
833
894
|
const nodeData = JSON.parse(nodeDataStr);
|
895
|
+
if (Object.keys(nodeData).length === 0) {
|
896
|
+
return null;
|
897
|
+
}
|
834
898
|
return new AirtopNode(this, nodeData);
|
835
899
|
} catch (error) {
|
836
900
|
this.log.withMetadata({ nodeDataStr }).withError(error).error("Error parsing node data");
|
837
901
|
}
|
838
|
-
});
|
902
|
+
}).filter((node) => !!node);
|
903
|
+
}
|
904
|
+
async findMany(prompt, config, requestOptions = {}) {
|
905
|
+
const configOverride = { ...config, optional: false };
|
906
|
+
return await this.findManyPrivate(prompt, configOverride, requestOptions);
|
907
|
+
}
|
908
|
+
async findManyOptional(prompt, config, requestOptions = {}) {
|
909
|
+
const configOverride = { ...config, optional: true };
|
910
|
+
return await this.findManyPrivate(prompt, configOverride, requestOptions);
|
839
911
|
}
|
840
912
|
async waitForPage(config, requestOptions = {}) {
|
841
913
|
return await withRequestCompletionPolling(
|
@@ -853,6 +925,23 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
853
925
|
)
|
854
926
|
);
|
855
927
|
}
|
928
|
+
async navigate(direction, config, requestOptions = {}) {
|
929
|
+
return await withRequestCompletionPolling(
|
930
|
+
this.client,
|
931
|
+
() => this.client.windows.navigate(
|
932
|
+
this.getWindowId(),
|
933
|
+
{
|
934
|
+
direction,
|
935
|
+
sessionId: this.sessionId,
|
936
|
+
...config || {}
|
937
|
+
},
|
938
|
+
{
|
939
|
+
timeout: secondsToMilliseconds3(600),
|
940
|
+
...this.resolveRequestOptions(requestOptions)
|
941
|
+
}
|
942
|
+
)
|
943
|
+
);
|
944
|
+
}
|
856
945
|
};
|
857
946
|
|
858
947
|
// src/window/AirtopWindow.ts
|
@@ -1289,6 +1378,13 @@ var AirtopClient = class extends AirtopBase {
|
|
1289
1378
|
}
|
1290
1379
|
};
|
1291
1380
|
|
1381
|
+
// src/window/AirtopWindowClient.types.ts
|
1382
|
+
var WindowNavigateDirection = /* @__PURE__ */ ((WindowNavigateDirection2) => {
|
1383
|
+
WindowNavigateDirection2["BACK"] = "backward";
|
1384
|
+
WindowNavigateDirection2["FORWARD"] = "forward";
|
1385
|
+
return WindowNavigateDirection2;
|
1386
|
+
})(WindowNavigateDirection || {});
|
1387
|
+
|
1292
1388
|
// src/plugin/AirtopPlugin.types.ts
|
1293
1389
|
var AirtopPluginAugmentationType = /* @__PURE__ */ ((AirtopPluginAugmentationType2) => {
|
1294
1390
|
AirtopPluginAugmentationType2["AirtopClient"] = "AirtopClient";
|
@@ -1419,6 +1515,7 @@ var AirtopMocks = class {
|
|
1419
1515
|
export {
|
1420
1516
|
AirtopBase,
|
1421
1517
|
AirtopClient,
|
1518
|
+
AirtopError,
|
1422
1519
|
AirtopMocks,
|
1423
1520
|
AirtopNode,
|
1424
1521
|
AirtopPluginAugmentationType,
|
@@ -1427,6 +1524,7 @@ export {
|
|
1427
1524
|
AirtopWindow,
|
1428
1525
|
AirtopWindowClient,
|
1429
1526
|
AirtopWindowScreenshot,
|
1527
|
+
WindowNavigateDirection,
|
1430
1528
|
registerAirtopPlugin
|
1431
1529
|
};
|
1432
1530
|
//# sourceMappingURL=index.js.map
|