@airtop/sdk 1.0.0-alpha2.45 → 1.0.0-alpha2.47
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 +159 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +83 -2
- package/dist/index.d.ts +83 -2
- package/dist/index.js +135 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SessionListParams, ProfileOutput, FileListParams, FileCreateFileParams, WindowCreateParams, WindowIDData, EnvelopeDefaultMeta as EnvelopeDefaultMeta$1, Issue as Issue$1, WindowInfo,
|
|
1
|
+
import { SessionListParams, ProfileOutput, FileListParams, FileCreateFileParams, WindowCreateParams, WindowIDData, EnvelopeDefaultMeta as EnvelopeDefaultMeta$1, Issue as Issue$1, WindowInfo, WindowFileInputParams, AIPromptResponse, WindowGetParams, ScrapeResponse, FileContentData } from '@airtop/core/resources/index.js';
|
|
2
2
|
import * as index_js from '@airtop/core/resources/index.js';
|
|
3
3
|
export { index_js as AirtopCore };
|
|
4
4
|
export { AIPromptResponse, ScrapeResponse } from '@airtop/core/resources/index.js';
|
|
@@ -647,6 +647,30 @@ interface ExtendedServicePromptParameters extends Omit<ServicePromptParameters,
|
|
|
647
647
|
*/
|
|
648
648
|
interface SessionServiceResponse extends ServicePromptActionResponseEnvelope {
|
|
649
649
|
}
|
|
650
|
+
interface UploadFileConfig {
|
|
651
|
+
/**
|
|
652
|
+
* Name of the file, must be unique within the session the file is used with
|
|
653
|
+
*/
|
|
654
|
+
fileName?: string;
|
|
655
|
+
/**
|
|
656
|
+
* Type of the file
|
|
657
|
+
*/
|
|
658
|
+
fileType?: "browser_download" | "screenshot" | "recording" | "customer_upload" | "web_archive";
|
|
659
|
+
/**
|
|
660
|
+
* IDs of the associated sessions
|
|
661
|
+
*/
|
|
662
|
+
sessionIds?: Array<string> | null;
|
|
663
|
+
/**
|
|
664
|
+
* wait for upload to complete
|
|
665
|
+
*/
|
|
666
|
+
waitForUpload?: boolean;
|
|
667
|
+
/**
|
|
668
|
+
* push file to session
|
|
669
|
+
*/
|
|
670
|
+
pushToSession?: boolean;
|
|
671
|
+
}
|
|
672
|
+
interface WaitForUploadResult extends WaitForDownloadResult {
|
|
673
|
+
}
|
|
650
674
|
|
|
651
675
|
/**
|
|
652
676
|
* Common data found in a window API call response.
|
|
@@ -721,6 +745,25 @@ interface AirtopWindowGetInfoResponse extends AirtopWindowCreateResponse {
|
|
|
721
745
|
*/
|
|
722
746
|
data: WindowInfoData;
|
|
723
747
|
}
|
|
748
|
+
/**
|
|
749
|
+
* Configuration options for the file input operation.
|
|
750
|
+
*/
|
|
751
|
+
interface WindowFileInputConfig extends Omit<WindowFileInputParams, "sessionId"> {
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Response from a file input operation.
|
|
755
|
+
*/
|
|
756
|
+
interface WindowFileInputResponse extends AIPromptResponse {
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Configuration options for the upload file and select input operation.
|
|
760
|
+
*/
|
|
761
|
+
interface UploadFileAndSelectInputConfig {
|
|
762
|
+
/**
|
|
763
|
+
* The path to the file to upload.
|
|
764
|
+
*/
|
|
765
|
+
filePath: string;
|
|
766
|
+
}
|
|
724
767
|
|
|
725
768
|
/**
|
|
726
769
|
* Configuration parameters for typing text in a window.
|
|
@@ -1158,6 +1201,23 @@ declare class AirtopWindowClient extends AirtopBase {
|
|
|
1158
1201
|
* @returns Promise resolving to the computer use operation result
|
|
1159
1202
|
*/
|
|
1160
1203
|
computerUse(prompt: string, config?: WindowComputerUseConfig, requestOptions?: AirtopRequestOptions): Promise<WindowComputerUseResponse>;
|
|
1204
|
+
/**
|
|
1205
|
+
* fileInput fills out a file input field in the window, using a file from the session
|
|
1206
|
+
* @param fileId - The ID of the file to use
|
|
1207
|
+
* @param config - Configuration options for the file input
|
|
1208
|
+
* @param requestOptions - Request options
|
|
1209
|
+
* @returns Promise resolving to the file input operation result
|
|
1210
|
+
*/
|
|
1211
|
+
fileInput(fileId: string, config?: WindowFileInputConfig, requestOptions?: AirtopRequestOptions): Promise<AIPromptResponse>;
|
|
1212
|
+
/**
|
|
1213
|
+
* uploadFileAndSelectInput uploads a file to the session, gets it ready to upload,
|
|
1214
|
+
* and selects the file in the indicated input field
|
|
1215
|
+
* @param filePath - The path to the file to upload
|
|
1216
|
+
* @param config - Configuration options for the upload file and select input operation
|
|
1217
|
+
* @param requestOptions - Request options
|
|
1218
|
+
* @returns Promise resolving to the upload file and select input operation result
|
|
1219
|
+
*/
|
|
1220
|
+
uploadFileAndSelectInput({ filePath }: UploadFileAndSelectInputConfig, config?: WindowFileInputConfig, requestOptions?: AirtopRequestOptions): Promise<AIPromptResponse>;
|
|
1161
1221
|
}
|
|
1162
1222
|
|
|
1163
1223
|
/**
|
|
@@ -1312,6 +1372,27 @@ declare class AirtopSessionClient extends AirtopBase {
|
|
|
1312
1372
|
* @returns Object containing file's id and downloadUrl, or null if timed out
|
|
1313
1373
|
*/
|
|
1314
1374
|
waitForDownload(configuration?: WaitForDownloadConfig, requestOptions?: AirtopRequestOptions): Promise<WaitForDownloadResult | null>;
|
|
1375
|
+
/**
|
|
1376
|
+
* Uploads a file to the session and waits for it to be available.
|
|
1377
|
+
* @param filePath - The path to the file to upload
|
|
1378
|
+
* @param options - Additional configuration options for uploading the file,
|
|
1379
|
+
* @param options.fileName - The name of the file to upload, defaults to the basename of the file path
|
|
1380
|
+
* @param options.fileType - The type of the file to upload, defaults to "customer_upload"
|
|
1381
|
+
* @param options.sessionIds - The IDs of the sessions to upload the file to, defaults to the current session id
|
|
1382
|
+
* @param options.waitForUpload - Whether to wait for the upload to complete, defaults to true
|
|
1383
|
+
* @param options.pushToSession - Whether to push the file to the session, defaults to true, waits for the upload to complete regardless of waitForUpload setting
|
|
1384
|
+
* @param requestOptions - Request options
|
|
1385
|
+
* @returns the uploaded file result
|
|
1386
|
+
*/
|
|
1387
|
+
uploadFile(filePath: string, options?: UploadFileConfig, requestOptions?: AirtopRequestOptions): Promise<WaitForUploadResult>;
|
|
1388
|
+
/**
|
|
1389
|
+
* Waits for a file to be uploaded, pushed to a session, then reach 'available' status. Throws an error if the file upload fails or times out.
|
|
1390
|
+
* @param fileId - The ID of the file to wait for
|
|
1391
|
+
* @param waitType - The type of wait to perform, "uploaded": just the file being uploaded to Airtop, "pushed": the file being pushed to a session
|
|
1392
|
+
* @param timeoutSeconds - The timeout in seconds, defaults to 300
|
|
1393
|
+
* @returns void
|
|
1394
|
+
*/
|
|
1395
|
+
waitForUpload(fileId: string, waitType?: "uploaded" | "pushed", timeoutSeconds?: number): Promise<void>;
|
|
1315
1396
|
}
|
|
1316
1397
|
|
|
1317
1398
|
/**
|
|
@@ -1793,4 +1874,4 @@ interface AirtopPluginRegistration {
|
|
|
1793
1874
|
*/
|
|
1794
1875
|
declare function registerAirtopPlugin(plugin: AirtopPluginRegistration): void;
|
|
1795
1876
|
|
|
1796
|
-
export { type AirtopAgentCancelInvocationParams, AirtopAgentClient, type AirtopAgentCreateAgentParams, type AirtopAgentCreateInvocationParams, type AirtopAgentDeleteAgentsParams, type AirtopAgentGetAgentParams, type AirtopAgentGetAgentsParams, type AirtopAgentGetInvocationsParams, type AirtopAgentGetVersionDataParams, type AirtopAgentPublishAgentParams, type AirtopAgentResponse, type AirtopAgentUpdateAgentParams, type AirtopAgentUpdateVersionDataParams, type AirtopAutomationData, type AirtopAutomationListResponse, type AirtopAutomationUpdateDescriptionConfig, AirtopBase, AirtopClient, type AirtopClientPlugin, type AirtopConstructorConfig, type AirtopCreateAgentInvocationResponse, type AirtopCreateAgentResponse, type AirtopCreateNewAgentDraftResponse, type AirtopDeleteAgentsResponse, AirtopError, AirtopFile, AirtopFileClient, type AirtopFileCreateResponse, type AirtopFileGetResponse, type AirtopFileListParams, type AirtopFileListResponse, type AirtopFileListWithInstancesResponse, type AirtopFilesResponse, type AirtopGetAgentInvocationsResponse, type AirtopGetAgentResponse, type AirtopGetAgentVersionDataResponse, type AirtopGetAgentsResponse, AirtopMocks, AirtopNode, type AirtopNodeApiResponseData, AirtopPluginAugmentationType, type AirtopPluginRegistration, type AirtopPluginType, type AirtopProfile, type AirtopPublishNewAgentResponse, type AirtopRequestOptions, AirtopSession, AirtopSessionClient, type AirtopSessionClientPlugin, type AirtopSessionPlugin, type AirtopSessionResponse, type AirtopUpdateAgentResponse, type AirtopUpdateVersionDataResponse, AirtopWindow, AirtopWindowClient, type AirtopWindowClientPlugin, type AirtopWindowCreateResponse, type AirtopWindowGetInfoResponse, type AirtopWindowPlugin, AirtopWindowScreenshot, type AirtopWindowScreenshotPlugin, type AirtopWindowScreenshotResponse, type CommonAirtopConfig, type CommonFileResponse, type CommonResponse, type CommonWindowResponse, type CreateFileConfig, type CreateSessionConfig, type ExtendedServicePromptParameters, type FileCreateData, type FileData, type FileError, type FileListData, type FileMetadata, type FileStatusEvent, type FileWarning, type GetFilesConfig, type GetSessionsConfig, type OutputJsonSchemaConfig, type ScreenshotData, type SessionData, type SessionError, type SessionMetadata, type SessionServiceResponse, type SessionWarning, type WaitForDownloadConfig, type WaitForDownloadResult, type WindowActConfig, type WindowActResponse, type WindowClickConfig, type WindowComputerUseConfig, type WindowComputerUseResponse, type WindowCreateData, type WindowCreateOptions, 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 WindowLlmFileContentData, 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 };
|
|
1877
|
+
export { type AirtopAgentCancelInvocationParams, AirtopAgentClient, type AirtopAgentCreateAgentParams, type AirtopAgentCreateInvocationParams, type AirtopAgentDeleteAgentsParams, type AirtopAgentGetAgentParams, type AirtopAgentGetAgentsParams, type AirtopAgentGetInvocationsParams, type AirtopAgentGetVersionDataParams, type AirtopAgentPublishAgentParams, type AirtopAgentResponse, type AirtopAgentUpdateAgentParams, type AirtopAgentUpdateVersionDataParams, type AirtopAutomationData, type AirtopAutomationListResponse, type AirtopAutomationUpdateDescriptionConfig, AirtopBase, AirtopClient, type AirtopClientPlugin, type AirtopConstructorConfig, type AirtopCreateAgentInvocationResponse, type AirtopCreateAgentResponse, type AirtopCreateNewAgentDraftResponse, type AirtopDeleteAgentsResponse, AirtopError, AirtopFile, AirtopFileClient, type AirtopFileCreateResponse, type AirtopFileGetResponse, type AirtopFileListParams, type AirtopFileListResponse, type AirtopFileListWithInstancesResponse, type AirtopFilesResponse, type AirtopGetAgentInvocationsResponse, type AirtopGetAgentResponse, type AirtopGetAgentVersionDataResponse, type AirtopGetAgentsResponse, AirtopMocks, AirtopNode, type AirtopNodeApiResponseData, AirtopPluginAugmentationType, type AirtopPluginRegistration, type AirtopPluginType, type AirtopProfile, type AirtopPublishNewAgentResponse, type AirtopRequestOptions, AirtopSession, AirtopSessionClient, type AirtopSessionClientPlugin, type AirtopSessionPlugin, type AirtopSessionResponse, type AirtopUpdateAgentResponse, type AirtopUpdateVersionDataResponse, AirtopWindow, AirtopWindowClient, type AirtopWindowClientPlugin, type AirtopWindowCreateResponse, type AirtopWindowGetInfoResponse, type AirtopWindowPlugin, AirtopWindowScreenshot, type AirtopWindowScreenshotPlugin, type AirtopWindowScreenshotResponse, type CommonAirtopConfig, type CommonFileResponse, type CommonResponse, type CommonWindowResponse, type CreateFileConfig, type CreateSessionConfig, type ExtendedServicePromptParameters, type FileCreateData, type FileData, type FileError, type FileListData, type FileMetadata, type FileStatusEvent, type FileWarning, type GetFilesConfig, type GetSessionsConfig, type OutputJsonSchemaConfig, type ScreenshotData, type SessionData, type SessionError, type SessionMetadata, type SessionServiceResponse, type SessionWarning, type UploadFileAndSelectInputConfig, type UploadFileConfig, type WaitForDownloadConfig, type WaitForDownloadResult, type WaitForUploadResult, type WindowActConfig, type WindowActResponse, type WindowClickConfig, type WindowComputerUseConfig, type WindowComputerUseResponse, type WindowCreateData, type WindowCreateOptions, type WindowError, type WindowExtractConfig, type WindowExtractResponse, type WindowFileInputConfig, type WindowFileInputResponse, type WindowFillFormConfig, type WindowFindManyConfig, type WindowFindManyResponse, type WindowFindOneConfig, type WindowFindOneResponse, type WindowGetConfig, type WindowHoverConfig, type WindowInfoData, type WindowLlmConfig, type WindowLlmFileContentData, 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SessionListParams, ProfileOutput, FileListParams, FileCreateFileParams, WindowCreateParams, WindowIDData, EnvelopeDefaultMeta as EnvelopeDefaultMeta$1, Issue as Issue$1, WindowInfo,
|
|
1
|
+
import { SessionListParams, ProfileOutput, FileListParams, FileCreateFileParams, WindowCreateParams, WindowIDData, EnvelopeDefaultMeta as EnvelopeDefaultMeta$1, Issue as Issue$1, WindowInfo, WindowFileInputParams, AIPromptResponse, WindowGetParams, ScrapeResponse, FileContentData } from '@airtop/core/resources/index.js';
|
|
2
2
|
import * as index_js from '@airtop/core/resources/index.js';
|
|
3
3
|
export { index_js as AirtopCore };
|
|
4
4
|
export { AIPromptResponse, ScrapeResponse } from '@airtop/core/resources/index.js';
|
|
@@ -647,6 +647,30 @@ interface ExtendedServicePromptParameters extends Omit<ServicePromptParameters,
|
|
|
647
647
|
*/
|
|
648
648
|
interface SessionServiceResponse extends ServicePromptActionResponseEnvelope {
|
|
649
649
|
}
|
|
650
|
+
interface UploadFileConfig {
|
|
651
|
+
/**
|
|
652
|
+
* Name of the file, must be unique within the session the file is used with
|
|
653
|
+
*/
|
|
654
|
+
fileName?: string;
|
|
655
|
+
/**
|
|
656
|
+
* Type of the file
|
|
657
|
+
*/
|
|
658
|
+
fileType?: "browser_download" | "screenshot" | "recording" | "customer_upload" | "web_archive";
|
|
659
|
+
/**
|
|
660
|
+
* IDs of the associated sessions
|
|
661
|
+
*/
|
|
662
|
+
sessionIds?: Array<string> | null;
|
|
663
|
+
/**
|
|
664
|
+
* wait for upload to complete
|
|
665
|
+
*/
|
|
666
|
+
waitForUpload?: boolean;
|
|
667
|
+
/**
|
|
668
|
+
* push file to session
|
|
669
|
+
*/
|
|
670
|
+
pushToSession?: boolean;
|
|
671
|
+
}
|
|
672
|
+
interface WaitForUploadResult extends WaitForDownloadResult {
|
|
673
|
+
}
|
|
650
674
|
|
|
651
675
|
/**
|
|
652
676
|
* Common data found in a window API call response.
|
|
@@ -721,6 +745,25 @@ interface AirtopWindowGetInfoResponse extends AirtopWindowCreateResponse {
|
|
|
721
745
|
*/
|
|
722
746
|
data: WindowInfoData;
|
|
723
747
|
}
|
|
748
|
+
/**
|
|
749
|
+
* Configuration options for the file input operation.
|
|
750
|
+
*/
|
|
751
|
+
interface WindowFileInputConfig extends Omit<WindowFileInputParams, "sessionId"> {
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Response from a file input operation.
|
|
755
|
+
*/
|
|
756
|
+
interface WindowFileInputResponse extends AIPromptResponse {
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Configuration options for the upload file and select input operation.
|
|
760
|
+
*/
|
|
761
|
+
interface UploadFileAndSelectInputConfig {
|
|
762
|
+
/**
|
|
763
|
+
* The path to the file to upload.
|
|
764
|
+
*/
|
|
765
|
+
filePath: string;
|
|
766
|
+
}
|
|
724
767
|
|
|
725
768
|
/**
|
|
726
769
|
* Configuration parameters for typing text in a window.
|
|
@@ -1158,6 +1201,23 @@ declare class AirtopWindowClient extends AirtopBase {
|
|
|
1158
1201
|
* @returns Promise resolving to the computer use operation result
|
|
1159
1202
|
*/
|
|
1160
1203
|
computerUse(prompt: string, config?: WindowComputerUseConfig, requestOptions?: AirtopRequestOptions): Promise<WindowComputerUseResponse>;
|
|
1204
|
+
/**
|
|
1205
|
+
* fileInput fills out a file input field in the window, using a file from the session
|
|
1206
|
+
* @param fileId - The ID of the file to use
|
|
1207
|
+
* @param config - Configuration options for the file input
|
|
1208
|
+
* @param requestOptions - Request options
|
|
1209
|
+
* @returns Promise resolving to the file input operation result
|
|
1210
|
+
*/
|
|
1211
|
+
fileInput(fileId: string, config?: WindowFileInputConfig, requestOptions?: AirtopRequestOptions): Promise<AIPromptResponse>;
|
|
1212
|
+
/**
|
|
1213
|
+
* uploadFileAndSelectInput uploads a file to the session, gets it ready to upload,
|
|
1214
|
+
* and selects the file in the indicated input field
|
|
1215
|
+
* @param filePath - The path to the file to upload
|
|
1216
|
+
* @param config - Configuration options for the upload file and select input operation
|
|
1217
|
+
* @param requestOptions - Request options
|
|
1218
|
+
* @returns Promise resolving to the upload file and select input operation result
|
|
1219
|
+
*/
|
|
1220
|
+
uploadFileAndSelectInput({ filePath }: UploadFileAndSelectInputConfig, config?: WindowFileInputConfig, requestOptions?: AirtopRequestOptions): Promise<AIPromptResponse>;
|
|
1161
1221
|
}
|
|
1162
1222
|
|
|
1163
1223
|
/**
|
|
@@ -1312,6 +1372,27 @@ declare class AirtopSessionClient extends AirtopBase {
|
|
|
1312
1372
|
* @returns Object containing file's id and downloadUrl, or null if timed out
|
|
1313
1373
|
*/
|
|
1314
1374
|
waitForDownload(configuration?: WaitForDownloadConfig, requestOptions?: AirtopRequestOptions): Promise<WaitForDownloadResult | null>;
|
|
1375
|
+
/**
|
|
1376
|
+
* Uploads a file to the session and waits for it to be available.
|
|
1377
|
+
* @param filePath - The path to the file to upload
|
|
1378
|
+
* @param options - Additional configuration options for uploading the file,
|
|
1379
|
+
* @param options.fileName - The name of the file to upload, defaults to the basename of the file path
|
|
1380
|
+
* @param options.fileType - The type of the file to upload, defaults to "customer_upload"
|
|
1381
|
+
* @param options.sessionIds - The IDs of the sessions to upload the file to, defaults to the current session id
|
|
1382
|
+
* @param options.waitForUpload - Whether to wait for the upload to complete, defaults to true
|
|
1383
|
+
* @param options.pushToSession - Whether to push the file to the session, defaults to true, waits for the upload to complete regardless of waitForUpload setting
|
|
1384
|
+
* @param requestOptions - Request options
|
|
1385
|
+
* @returns the uploaded file result
|
|
1386
|
+
*/
|
|
1387
|
+
uploadFile(filePath: string, options?: UploadFileConfig, requestOptions?: AirtopRequestOptions): Promise<WaitForUploadResult>;
|
|
1388
|
+
/**
|
|
1389
|
+
* Waits for a file to be uploaded, pushed to a session, then reach 'available' status. Throws an error if the file upload fails or times out.
|
|
1390
|
+
* @param fileId - The ID of the file to wait for
|
|
1391
|
+
* @param waitType - The type of wait to perform, "uploaded": just the file being uploaded to Airtop, "pushed": the file being pushed to a session
|
|
1392
|
+
* @param timeoutSeconds - The timeout in seconds, defaults to 300
|
|
1393
|
+
* @returns void
|
|
1394
|
+
*/
|
|
1395
|
+
waitForUpload(fileId: string, waitType?: "uploaded" | "pushed", timeoutSeconds?: number): Promise<void>;
|
|
1315
1396
|
}
|
|
1316
1397
|
|
|
1317
1398
|
/**
|
|
@@ -1793,4 +1874,4 @@ interface AirtopPluginRegistration {
|
|
|
1793
1874
|
*/
|
|
1794
1875
|
declare function registerAirtopPlugin(plugin: AirtopPluginRegistration): void;
|
|
1795
1876
|
|
|
1796
|
-
export { type AirtopAgentCancelInvocationParams, AirtopAgentClient, type AirtopAgentCreateAgentParams, type AirtopAgentCreateInvocationParams, type AirtopAgentDeleteAgentsParams, type AirtopAgentGetAgentParams, type AirtopAgentGetAgentsParams, type AirtopAgentGetInvocationsParams, type AirtopAgentGetVersionDataParams, type AirtopAgentPublishAgentParams, type AirtopAgentResponse, type AirtopAgentUpdateAgentParams, type AirtopAgentUpdateVersionDataParams, type AirtopAutomationData, type AirtopAutomationListResponse, type AirtopAutomationUpdateDescriptionConfig, AirtopBase, AirtopClient, type AirtopClientPlugin, type AirtopConstructorConfig, type AirtopCreateAgentInvocationResponse, type AirtopCreateAgentResponse, type AirtopCreateNewAgentDraftResponse, type AirtopDeleteAgentsResponse, AirtopError, AirtopFile, AirtopFileClient, type AirtopFileCreateResponse, type AirtopFileGetResponse, type AirtopFileListParams, type AirtopFileListResponse, type AirtopFileListWithInstancesResponse, type AirtopFilesResponse, type AirtopGetAgentInvocationsResponse, type AirtopGetAgentResponse, type AirtopGetAgentVersionDataResponse, type AirtopGetAgentsResponse, AirtopMocks, AirtopNode, type AirtopNodeApiResponseData, AirtopPluginAugmentationType, type AirtopPluginRegistration, type AirtopPluginType, type AirtopProfile, type AirtopPublishNewAgentResponse, type AirtopRequestOptions, AirtopSession, AirtopSessionClient, type AirtopSessionClientPlugin, type AirtopSessionPlugin, type AirtopSessionResponse, type AirtopUpdateAgentResponse, type AirtopUpdateVersionDataResponse, AirtopWindow, AirtopWindowClient, type AirtopWindowClientPlugin, type AirtopWindowCreateResponse, type AirtopWindowGetInfoResponse, type AirtopWindowPlugin, AirtopWindowScreenshot, type AirtopWindowScreenshotPlugin, type AirtopWindowScreenshotResponse, type CommonAirtopConfig, type CommonFileResponse, type CommonResponse, type CommonWindowResponse, type CreateFileConfig, type CreateSessionConfig, type ExtendedServicePromptParameters, type FileCreateData, type FileData, type FileError, type FileListData, type FileMetadata, type FileStatusEvent, type FileWarning, type GetFilesConfig, type GetSessionsConfig, type OutputJsonSchemaConfig, type ScreenshotData, type SessionData, type SessionError, type SessionMetadata, type SessionServiceResponse, type SessionWarning, type WaitForDownloadConfig, type WaitForDownloadResult, type WindowActConfig, type WindowActResponse, type WindowClickConfig, type WindowComputerUseConfig, type WindowComputerUseResponse, type WindowCreateData, type WindowCreateOptions, 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 WindowLlmFileContentData, 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 };
|
|
1877
|
+
export { type AirtopAgentCancelInvocationParams, AirtopAgentClient, type AirtopAgentCreateAgentParams, type AirtopAgentCreateInvocationParams, type AirtopAgentDeleteAgentsParams, type AirtopAgentGetAgentParams, type AirtopAgentGetAgentsParams, type AirtopAgentGetInvocationsParams, type AirtopAgentGetVersionDataParams, type AirtopAgentPublishAgentParams, type AirtopAgentResponse, type AirtopAgentUpdateAgentParams, type AirtopAgentUpdateVersionDataParams, type AirtopAutomationData, type AirtopAutomationListResponse, type AirtopAutomationUpdateDescriptionConfig, AirtopBase, AirtopClient, type AirtopClientPlugin, type AirtopConstructorConfig, type AirtopCreateAgentInvocationResponse, type AirtopCreateAgentResponse, type AirtopCreateNewAgentDraftResponse, type AirtopDeleteAgentsResponse, AirtopError, AirtopFile, AirtopFileClient, type AirtopFileCreateResponse, type AirtopFileGetResponse, type AirtopFileListParams, type AirtopFileListResponse, type AirtopFileListWithInstancesResponse, type AirtopFilesResponse, type AirtopGetAgentInvocationsResponse, type AirtopGetAgentResponse, type AirtopGetAgentVersionDataResponse, type AirtopGetAgentsResponse, AirtopMocks, AirtopNode, type AirtopNodeApiResponseData, AirtopPluginAugmentationType, type AirtopPluginRegistration, type AirtopPluginType, type AirtopProfile, type AirtopPublishNewAgentResponse, type AirtopRequestOptions, AirtopSession, AirtopSessionClient, type AirtopSessionClientPlugin, type AirtopSessionPlugin, type AirtopSessionResponse, type AirtopUpdateAgentResponse, type AirtopUpdateVersionDataResponse, AirtopWindow, AirtopWindowClient, type AirtopWindowClientPlugin, type AirtopWindowCreateResponse, type AirtopWindowGetInfoResponse, type AirtopWindowPlugin, AirtopWindowScreenshot, type AirtopWindowScreenshotPlugin, type AirtopWindowScreenshotResponse, type CommonAirtopConfig, type CommonFileResponse, type CommonResponse, type CommonWindowResponse, type CreateFileConfig, type CreateSessionConfig, type ExtendedServicePromptParameters, type FileCreateData, type FileData, type FileError, type FileListData, type FileMetadata, type FileStatusEvent, type FileWarning, type GetFilesConfig, type GetSessionsConfig, type OutputJsonSchemaConfig, type ScreenshotData, type SessionData, type SessionError, type SessionMetadata, type SessionServiceResponse, type SessionWarning, type UploadFileAndSelectInputConfig, type UploadFileConfig, type WaitForDownloadConfig, type WaitForDownloadResult, type WaitForUploadResult, type WindowActConfig, type WindowActResponse, type WindowClickConfig, type WindowComputerUseConfig, type WindowComputerUseResponse, type WindowCreateData, type WindowCreateOptions, type WindowError, type WindowExtractConfig, type WindowExtractResponse, type WindowFileInputConfig, type WindowFileInputResponse, type WindowFillFormConfig, type WindowFindManyConfig, type WindowFindManyResponse, type WindowFindOneConfig, type WindowFindOneResponse, type WindowGetConfig, type WindowHoverConfig, type WindowInfoData, type WindowLlmConfig, type WindowLlmFileContentData, 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.
|
|
12
|
+
version: "1.0.0-alpha2.47",
|
|
13
13
|
type: "module",
|
|
14
14
|
main: "./dist/index.cjs",
|
|
15
15
|
module: "./dist/index.js",
|
|
@@ -51,7 +51,7 @@ var require_package = __commonJS({
|
|
|
51
51
|
"@airtop/core": "0.1.0-alpha.53",
|
|
52
52
|
"@airtop/json-schema-adapter": "workspace:*",
|
|
53
53
|
"date-fns": "4.1.0",
|
|
54
|
-
loglayer: "
|
|
54
|
+
loglayer: "9.3.0",
|
|
55
55
|
"serialize-error": "12.0.0",
|
|
56
56
|
uuid: "11.1.0"
|
|
57
57
|
},
|
|
@@ -370,6 +370,8 @@ var processLogMessage = (log, logLevel, ...args) => {
|
|
|
370
370
|
};
|
|
371
371
|
|
|
372
372
|
// src/session/AirtopSessionClient.ts
|
|
373
|
+
import fs from "fs";
|
|
374
|
+
import path from "path";
|
|
373
375
|
import { NotFoundError } from "@airtop/core";
|
|
374
376
|
|
|
375
377
|
// src/async-utils.ts
|
|
@@ -1174,6 +1176,41 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
|
1174
1176
|
requestOptions
|
|
1175
1177
|
);
|
|
1176
1178
|
}
|
|
1179
|
+
/**
|
|
1180
|
+
* fileInput fills out a file input field in the window, using a file from the session
|
|
1181
|
+
* @param fileId - The ID of the file to use
|
|
1182
|
+
* @param config - Configuration options for the file input
|
|
1183
|
+
* @param requestOptions - Request options
|
|
1184
|
+
* @returns Promise resolving to the file input operation result
|
|
1185
|
+
*/
|
|
1186
|
+
async fileInput(fileId, config, requestOptions = {}) {
|
|
1187
|
+
return await withRequestCompletionPolling(
|
|
1188
|
+
this.client,
|
|
1189
|
+
() => this.client.windows.fileInputAsync(
|
|
1190
|
+
this.getWindowId(),
|
|
1191
|
+
{ sessionId: this.sessionId, ...config || {}, fileId },
|
|
1192
|
+
{ ...this.resolveRequestOptions(requestOptions) }
|
|
1193
|
+
),
|
|
1194
|
+
requestOptions
|
|
1195
|
+
);
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* uploadFileAndSelectInput uploads a file to the session, gets it ready to upload,
|
|
1199
|
+
* and selects the file in the indicated input field
|
|
1200
|
+
* @param filePath - The path to the file to upload
|
|
1201
|
+
* @param config - Configuration options for the upload file and select input operation
|
|
1202
|
+
* @param requestOptions - Request options
|
|
1203
|
+
* @returns Promise resolving to the upload file and select input operation result
|
|
1204
|
+
*/
|
|
1205
|
+
async uploadFileAndSelectInput({ filePath }, config, requestOptions = {}) {
|
|
1206
|
+
const sessionClient = new AirtopSessionClient(this.getCommonConfig(), this.sessionId);
|
|
1207
|
+
const file = await sessionClient.uploadFile(filePath, { pushToSession: true }, requestOptions);
|
|
1208
|
+
return await this.fileInput(
|
|
1209
|
+
file.id,
|
|
1210
|
+
{ ...config, fileId: file.id },
|
|
1211
|
+
{ ...this.resolveRequestOptions(requestOptions) }
|
|
1212
|
+
);
|
|
1213
|
+
}
|
|
1177
1214
|
};
|
|
1178
1215
|
|
|
1179
1216
|
// src/window/AirtopWindow.ts
|
|
@@ -1532,6 +1569,102 @@ ${JSON.stringify(event, null, 2)}`);
|
|
|
1532
1569
|
})();
|
|
1533
1570
|
return Promise.race([timeoutPromise, processEventsPromise]);
|
|
1534
1571
|
}
|
|
1572
|
+
/**
|
|
1573
|
+
* Uploads a file to the session and waits for it to be available.
|
|
1574
|
+
* @param filePath - The path to the file to upload
|
|
1575
|
+
* @param options - Additional configuration options for uploading the file,
|
|
1576
|
+
* @param options.fileName - The name of the file to upload, defaults to the basename of the file path
|
|
1577
|
+
* @param options.fileType - The type of the file to upload, defaults to "customer_upload"
|
|
1578
|
+
* @param options.sessionIds - The IDs of the sessions to upload the file to, defaults to the current session id
|
|
1579
|
+
* @param options.waitForUpload - Whether to wait for the upload to complete, defaults to true
|
|
1580
|
+
* @param options.pushToSession - Whether to push the file to the session, defaults to true, waits for the upload to complete regardless of waitForUpload setting
|
|
1581
|
+
* @param requestOptions - Request options
|
|
1582
|
+
* @returns the uploaded file result
|
|
1583
|
+
*/
|
|
1584
|
+
async uploadFile(filePath, options = {}, requestOptions = {}) {
|
|
1585
|
+
this.log.info(`uploading file ${filePath}`);
|
|
1586
|
+
const fileName = options?.fileName ?? path.basename(filePath);
|
|
1587
|
+
const fileType = options?.fileType ?? "customer_upload";
|
|
1588
|
+
const sessionIds = options?.sessionIds ?? [this.sessionId];
|
|
1589
|
+
const waitForUpload = options?.waitForUpload ?? true;
|
|
1590
|
+
const pushToSession = options?.pushToSession ?? true;
|
|
1591
|
+
const file = await this.client.files.createFile(
|
|
1592
|
+
{
|
|
1593
|
+
sessionIds,
|
|
1594
|
+
fileName,
|
|
1595
|
+
fileType
|
|
1596
|
+
},
|
|
1597
|
+
this.resolveRequestOptions(requestOptions)
|
|
1598
|
+
);
|
|
1599
|
+
const fileContent = fs.readFileSync(filePath);
|
|
1600
|
+
if (waitForUpload || pushToSession) {
|
|
1601
|
+
const uploadWaitPromise = this.waitForUpload(file.data.id, "uploaded");
|
|
1602
|
+
fetch(file.data.uploadUrl, {
|
|
1603
|
+
method: "PUT",
|
|
1604
|
+
body: fileContent,
|
|
1605
|
+
headers: {
|
|
1606
|
+
"Content-Type": "application/octet-stream"
|
|
1607
|
+
}
|
|
1608
|
+
});
|
|
1609
|
+
await uploadWaitPromise;
|
|
1610
|
+
}
|
|
1611
|
+
if (pushToSession) {
|
|
1612
|
+
const pushWaitPromise = this.waitForUpload(file.data.id, "pushed");
|
|
1613
|
+
this.client.files.push(file.data.id, {
|
|
1614
|
+
sessionIds
|
|
1615
|
+
});
|
|
1616
|
+
await pushWaitPromise;
|
|
1617
|
+
}
|
|
1618
|
+
const fileDataResponse = await this.client.files.get(file.data.id);
|
|
1619
|
+
const fileData = fileDataResponse.data;
|
|
1620
|
+
return {
|
|
1621
|
+
id: file.data.id,
|
|
1622
|
+
downloadUrl: fileData.downloadUrl,
|
|
1623
|
+
fileName: file.data.fileName,
|
|
1624
|
+
fileType: file.data.fileType
|
|
1625
|
+
};
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* Waits for a file to be uploaded, pushed to a session, then reach 'available' status. Throws an error if the file upload fails or times out.
|
|
1629
|
+
* @param fileId - The ID of the file to wait for
|
|
1630
|
+
* @param waitType - The type of wait to perform, "uploaded": just the file being uploaded to Airtop, "pushed": the file being pushed to a session
|
|
1631
|
+
* @param timeoutSeconds - The timeout in seconds, defaults to 300
|
|
1632
|
+
* @returns void
|
|
1633
|
+
*/
|
|
1634
|
+
async waitForUpload(fileId, waitType = "uploaded", timeoutSeconds = 300) {
|
|
1635
|
+
const waitEvent = waitType === "pushed" ? "file_upload_status" : "file_status";
|
|
1636
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
1637
|
+
setTimeout(() => {
|
|
1638
|
+
reject(new Error(`waiting for file upload timed out after ${timeoutSeconds} seconds`));
|
|
1639
|
+
}, timeoutSeconds * 1e3);
|
|
1640
|
+
});
|
|
1641
|
+
const processEventsPromise = (async () => {
|
|
1642
|
+
const newEvents = await this.client.sessions.getEvents(
|
|
1643
|
+
this.sessionId,
|
|
1644
|
+
{ all: false, reverse: false },
|
|
1645
|
+
{ timeout: timeoutSeconds * 1e3 }
|
|
1646
|
+
);
|
|
1647
|
+
for await (const event of newEvents) {
|
|
1648
|
+
const e = event;
|
|
1649
|
+
this.log.info(`waitForUpload processing event:
|
|
1650
|
+
${JSON.stringify(event, null, 2)}`);
|
|
1651
|
+
if (e.event === waitEvent) {
|
|
1652
|
+
if (e.fileId === fileId) {
|
|
1653
|
+
if (e.status === "available") {
|
|
1654
|
+
this.log.info(`uploaded file is now available on session: ${fileId}`);
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
if (e.status === "upload_failed") {
|
|
1658
|
+
this.log.info(`upload failed: ${this.sessionId} ${fileId}`);
|
|
1659
|
+
throw new Error(`upload failed: ${e.eventData.error}`);
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
return null;
|
|
1665
|
+
})();
|
|
1666
|
+
return Promise.race([timeoutPromise, processEventsPromise]);
|
|
1667
|
+
}
|
|
1535
1668
|
};
|
|
1536
1669
|
|
|
1537
1670
|
// src/session/AirtopSession.ts
|