asteroid-odyssey 1.3.1 → 1.3.3

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.mts CHANGED
@@ -554,6 +554,48 @@ type StructuredAgentExecutionRequest = {
554
554
  [key: string]: unknown;
555
555
  };
556
556
  };
557
+ type Cookie = {
558
+ /**
559
+ * Unique identifier for the cookie
560
+ */
561
+ id?: string;
562
+ /**
563
+ * Display name for the cookie
564
+ */
565
+ name: string;
566
+ /**
567
+ * The cookie name/key
568
+ */
569
+ key: string;
570
+ /**
571
+ * The cookie value
572
+ */
573
+ value: string;
574
+ /**
575
+ * When the cookie expires (optional)
576
+ */
577
+ expiry?: string;
578
+ /**
579
+ * The domain for which the cookie is valid
580
+ */
581
+ domain: string;
582
+ /**
583
+ * Whether the cookie should only be sent over HTTPS
584
+ */
585
+ secure: boolean;
586
+ /**
587
+ * SameSite attribute for the cookie
588
+ */
589
+ same_site: 'Strict' | 'Lax' | 'None';
590
+ /**
591
+ * Whether the cookie should be accessible only via HTTP(S)
592
+ */
593
+ http_only: boolean;
594
+ /**
595
+ * When the cookie was created
596
+ */
597
+ created_at: string;
598
+ };
557
599
  type AgentProfile = {
558
600
  /**
559
601
  * Unique identifier for the agent profile
@@ -585,6 +627,10 @@ type AgentProfile = {
585
627
  * List of credentials associated with this agent profile
586
628
  */
587
629
  credentials: Array<Credential>;
630
+ /**
631
+ * List of cookies associated with this agent profile
632
+ */
633
+ cookies: Array<Cookie>;
588
634
  /**
589
635
  * The date and time the agent profile was created
590
636
  */
@@ -621,6 +667,10 @@ type CreateAgentProfileRequest = {
621
667
  * Optional list of credentials to create with the profile
622
668
  */
623
669
  credentials: Array<Credential>;
670
+ /**
671
+ * Optional list of cookies to create with the profile
672
+ */
673
+ cookies: Array<Cookie>;
624
674
  };
625
675
  type UpdateAgentProfileRequest = {
626
676
  /**
@@ -649,6 +699,14 @@ type UpdateAgentProfileRequest = {
649
699
  * List of credential IDs to delete from the profile
650
700
  */
651
701
  credentials_to_delete?: Array<string>;
702
+ /**
703
+ * List of cookies to add to the profile
704
+ */
705
+ cookies_to_add?: Array<Cookie>;
706
+ /**
707
+ * List of cookie IDs to delete from the profile
708
+ */
709
+ cookies_to_delete?: Array<string>;
652
710
  };
653
711
  /**
654
712
  * Two-letter country code for proxy location
@@ -1126,6 +1184,7 @@ type ClientOptions$1 = {
1126
1184
  type types_gen$1_AgentExecutionRequest = AgentExecutionRequest;
1127
1185
  type types_gen$1_AgentProfile = AgentProfile;
1128
1186
  type types_gen$1_BrowserSessionRecordingResponse = BrowserSessionRecordingResponse;
1187
+ type types_gen$1_Cookie = Cookie;
1129
1188
  type types_gen$1_CountryCode = CountryCode;
1130
1189
  type types_gen$1_CreateAgentProfileData = CreateAgentProfileData;
1131
1190
  type types_gen$1_CreateAgentProfileError = CreateAgentProfileError;
@@ -1205,7 +1264,7 @@ type types_gen$1_UploadExecutionFilesErrors = UploadExecutionFilesErrors;
1205
1264
  type types_gen$1_UploadExecutionFilesResponse = UploadExecutionFilesResponse;
1206
1265
  type types_gen$1_UploadExecutionFilesResponses = UploadExecutionFilesResponses;
1207
1266
  declare namespace types_gen$1 {
1208
- export type { types_gen$1_AgentExecutionRequest as AgentExecutionRequest, types_gen$1_AgentProfile as AgentProfile, types_gen$1_BrowserSessionRecordingResponse as BrowserSessionRecordingResponse, ClientOptions$1 as ClientOptions, types_gen$1_CountryCode as CountryCode, types_gen$1_CreateAgentProfileData as CreateAgentProfileData, types_gen$1_CreateAgentProfileError as CreateAgentProfileError, types_gen$1_CreateAgentProfileErrors as CreateAgentProfileErrors, types_gen$1_CreateAgentProfileRequest as CreateAgentProfileRequest, types_gen$1_CreateAgentProfileResponse as CreateAgentProfileResponse, types_gen$1_CreateAgentProfileResponses as CreateAgentProfileResponses, types_gen$1_Credential as Credential, types_gen$1_DeleteAgentProfileData as DeleteAgentProfileData, types_gen$1_DeleteAgentProfileError as DeleteAgentProfileError, types_gen$1_DeleteAgentProfileErrors as DeleteAgentProfileErrors, types_gen$1_DeleteAgentProfileResponse as DeleteAgentProfileResponse, types_gen$1_DeleteAgentProfileResponses as DeleteAgentProfileResponses, types_gen$1_ErrorResponse as ErrorResponse, types_gen$1_ExecuteAgentData as ExecuteAgentData, types_gen$1_ExecuteAgentError as ExecuteAgentError, types_gen$1_ExecuteAgentErrors as ExecuteAgentErrors, types_gen$1_ExecuteAgentResponse as ExecuteAgentResponse, types_gen$1_ExecuteAgentResponses as ExecuteAgentResponses, types_gen$1_ExecuteAgentStructuredData as ExecuteAgentStructuredData, types_gen$1_ExecuteAgentStructuredError as ExecuteAgentStructuredError, types_gen$1_ExecuteAgentStructuredErrors as ExecuteAgentStructuredErrors, types_gen$1_ExecuteAgentStructuredResponse as ExecuteAgentStructuredResponse, types_gen$1_ExecuteAgentStructuredResponses as ExecuteAgentStructuredResponses, types_gen$1_ExecutionResponse as ExecutionResponse, types_gen$1_ExecutionResult as ExecutionResult, types_gen$1_ExecutionResultResponse as ExecutionResultResponse, types_gen$1_ExecutionStatusResponse as ExecutionStatusResponse, types_gen$1_GetAgentProfileData as GetAgentProfileData, types_gen$1_GetAgentProfileError as GetAgentProfileError, types_gen$1_GetAgentProfileErrors as GetAgentProfileErrors, types_gen$1_GetAgentProfileResponse as GetAgentProfileResponse, types_gen$1_GetAgentProfileResponses as GetAgentProfileResponses, types_gen$1_GetAgentProfilesData as GetAgentProfilesData, types_gen$1_GetAgentProfilesError as GetAgentProfilesError, types_gen$1_GetAgentProfilesErrors as GetAgentProfilesErrors, types_gen$1_GetAgentProfilesResponse as GetAgentProfilesResponse, types_gen$1_GetAgentProfilesResponses as GetAgentProfilesResponses, types_gen$1_GetBrowserSessionRecordingData as GetBrowserSessionRecordingData, types_gen$1_GetBrowserSessionRecordingError as GetBrowserSessionRecordingError, types_gen$1_GetBrowserSessionRecordingErrors as GetBrowserSessionRecordingErrors, types_gen$1_GetBrowserSessionRecordingResponse as GetBrowserSessionRecordingResponse, types_gen$1_GetBrowserSessionRecordingResponses as GetBrowserSessionRecordingResponses, types_gen$1_GetCredentialsPublicKeyData as GetCredentialsPublicKeyData, types_gen$1_GetCredentialsPublicKeyErrors as GetCredentialsPublicKeyErrors, types_gen$1_GetCredentialsPublicKeyResponse as GetCredentialsPublicKeyResponse, types_gen$1_GetCredentialsPublicKeyResponses as GetCredentialsPublicKeyResponses, types_gen$1_GetExecutionResultData as GetExecutionResultData, types_gen$1_GetExecutionResultError as GetExecutionResultError, types_gen$1_GetExecutionResultErrors as GetExecutionResultErrors, types_gen$1_GetExecutionResultResponse as GetExecutionResultResponse, types_gen$1_GetExecutionResultResponses as GetExecutionResultResponses, types_gen$1_GetExecutionStatusData as GetExecutionStatusData, types_gen$1_GetExecutionStatusError as GetExecutionStatusError, types_gen$1_GetExecutionStatusErrors as GetExecutionStatusErrors, types_gen$1_GetExecutionStatusResponse as GetExecutionStatusResponse, types_gen$1_GetExecutionStatusResponses as GetExecutionStatusResponses, types_gen$1_GetOpenApiData as GetOpenApiData, types_gen$1_GetOpenApiResponses as GetOpenApiResponses, types_gen$1_HealthCheckData as HealthCheckData, types_gen$1_HealthCheckError as HealthCheckError, types_gen$1_HealthCheckErrors as HealthCheckErrors, types_gen$1_HealthCheckResponse as HealthCheckResponse, types_gen$1_HealthCheckResponses as HealthCheckResponses, types_gen$1_ProxyType as ProxyType, types_gen$1_Status as Status, types_gen$1_StructuredAgentExecutionRequest as StructuredAgentExecutionRequest, types_gen$1_UpdateAgentProfileData as UpdateAgentProfileData, types_gen$1_UpdateAgentProfileError as UpdateAgentProfileError, types_gen$1_UpdateAgentProfileErrors as UpdateAgentProfileErrors, types_gen$1_UpdateAgentProfileRequest as UpdateAgentProfileRequest, types_gen$1_UpdateAgentProfileResponse as UpdateAgentProfileResponse, types_gen$1_UpdateAgentProfileResponses as UpdateAgentProfileResponses, types_gen$1_UploadExecutionFilesData as UploadExecutionFilesData, types_gen$1_UploadExecutionFilesError as UploadExecutionFilesError, types_gen$1_UploadExecutionFilesErrors as UploadExecutionFilesErrors, types_gen$1_UploadExecutionFilesResponse as UploadExecutionFilesResponse, types_gen$1_UploadExecutionFilesResponses as UploadExecutionFilesResponses };
1267
+ export type { types_gen$1_AgentExecutionRequest as AgentExecutionRequest, types_gen$1_AgentProfile as AgentProfile, types_gen$1_BrowserSessionRecordingResponse as BrowserSessionRecordingResponse, ClientOptions$1 as ClientOptions, types_gen$1_Cookie as Cookie, types_gen$1_CountryCode as CountryCode, types_gen$1_CreateAgentProfileData as CreateAgentProfileData, types_gen$1_CreateAgentProfileError as CreateAgentProfileError, types_gen$1_CreateAgentProfileErrors as CreateAgentProfileErrors, types_gen$1_CreateAgentProfileRequest as CreateAgentProfileRequest, types_gen$1_CreateAgentProfileResponse as CreateAgentProfileResponse, types_gen$1_CreateAgentProfileResponses as CreateAgentProfileResponses, types_gen$1_Credential as Credential, types_gen$1_DeleteAgentProfileData as DeleteAgentProfileData, types_gen$1_DeleteAgentProfileError as DeleteAgentProfileError, types_gen$1_DeleteAgentProfileErrors as DeleteAgentProfileErrors, types_gen$1_DeleteAgentProfileResponse as DeleteAgentProfileResponse, types_gen$1_DeleteAgentProfileResponses as DeleteAgentProfileResponses, types_gen$1_ErrorResponse as ErrorResponse, types_gen$1_ExecuteAgentData as ExecuteAgentData, types_gen$1_ExecuteAgentError as ExecuteAgentError, types_gen$1_ExecuteAgentErrors as ExecuteAgentErrors, types_gen$1_ExecuteAgentResponse as ExecuteAgentResponse, types_gen$1_ExecuteAgentResponses as ExecuteAgentResponses, types_gen$1_ExecuteAgentStructuredData as ExecuteAgentStructuredData, types_gen$1_ExecuteAgentStructuredError as ExecuteAgentStructuredError, types_gen$1_ExecuteAgentStructuredErrors as ExecuteAgentStructuredErrors, types_gen$1_ExecuteAgentStructuredResponse as ExecuteAgentStructuredResponse, types_gen$1_ExecuteAgentStructuredResponses as ExecuteAgentStructuredResponses, types_gen$1_ExecutionResponse as ExecutionResponse, types_gen$1_ExecutionResult as ExecutionResult, types_gen$1_ExecutionResultResponse as ExecutionResultResponse, types_gen$1_ExecutionStatusResponse as ExecutionStatusResponse, types_gen$1_GetAgentProfileData as GetAgentProfileData, types_gen$1_GetAgentProfileError as GetAgentProfileError, types_gen$1_GetAgentProfileErrors as GetAgentProfileErrors, types_gen$1_GetAgentProfileResponse as GetAgentProfileResponse, types_gen$1_GetAgentProfileResponses as GetAgentProfileResponses, types_gen$1_GetAgentProfilesData as GetAgentProfilesData, types_gen$1_GetAgentProfilesError as GetAgentProfilesError, types_gen$1_GetAgentProfilesErrors as GetAgentProfilesErrors, types_gen$1_GetAgentProfilesResponse as GetAgentProfilesResponse, types_gen$1_GetAgentProfilesResponses as GetAgentProfilesResponses, types_gen$1_GetBrowserSessionRecordingData as GetBrowserSessionRecordingData, types_gen$1_GetBrowserSessionRecordingError as GetBrowserSessionRecordingError, types_gen$1_GetBrowserSessionRecordingErrors as GetBrowserSessionRecordingErrors, types_gen$1_GetBrowserSessionRecordingResponse as GetBrowserSessionRecordingResponse, types_gen$1_GetBrowserSessionRecordingResponses as GetBrowserSessionRecordingResponses, types_gen$1_GetCredentialsPublicKeyData as GetCredentialsPublicKeyData, types_gen$1_GetCredentialsPublicKeyErrors as GetCredentialsPublicKeyErrors, types_gen$1_GetCredentialsPublicKeyResponse as GetCredentialsPublicKeyResponse, types_gen$1_GetCredentialsPublicKeyResponses as GetCredentialsPublicKeyResponses, types_gen$1_GetExecutionResultData as GetExecutionResultData, types_gen$1_GetExecutionResultError as GetExecutionResultError, types_gen$1_GetExecutionResultErrors as GetExecutionResultErrors, types_gen$1_GetExecutionResultResponse as GetExecutionResultResponse, types_gen$1_GetExecutionResultResponses as GetExecutionResultResponses, types_gen$1_GetExecutionStatusData as GetExecutionStatusData, types_gen$1_GetExecutionStatusError as GetExecutionStatusError, types_gen$1_GetExecutionStatusErrors as GetExecutionStatusErrors, types_gen$1_GetExecutionStatusResponse as GetExecutionStatusResponse, types_gen$1_GetExecutionStatusResponses as GetExecutionStatusResponses, types_gen$1_GetOpenApiData as GetOpenApiData, types_gen$1_GetOpenApiResponses as GetOpenApiResponses, types_gen$1_HealthCheckData as HealthCheckData, types_gen$1_HealthCheckError as HealthCheckError, types_gen$1_HealthCheckErrors as HealthCheckErrors, types_gen$1_HealthCheckResponse as HealthCheckResponse, types_gen$1_HealthCheckResponses as HealthCheckResponses, types_gen$1_ProxyType as ProxyType, types_gen$1_Status as Status, types_gen$1_StructuredAgentExecutionRequest as StructuredAgentExecutionRequest, types_gen$1_UpdateAgentProfileData as UpdateAgentProfileData, types_gen$1_UpdateAgentProfileError as UpdateAgentProfileError, types_gen$1_UpdateAgentProfileErrors as UpdateAgentProfileErrors, types_gen$1_UpdateAgentProfileRequest as UpdateAgentProfileRequest, types_gen$1_UpdateAgentProfileResponse as UpdateAgentProfileResponse, types_gen$1_UpdateAgentProfileResponses as UpdateAgentProfileResponses, types_gen$1_UploadExecutionFilesData as UploadExecutionFilesData, types_gen$1_UploadExecutionFilesError as UploadExecutionFilesError, types_gen$1_UploadExecutionFilesErrors as UploadExecutionFilesErrors, types_gen$1_UploadExecutionFilesResponse as UploadExecutionFilesResponse, types_gen$1_UploadExecutionFilesResponses as UploadExecutionFilesResponses };
1209
1268
  }
1210
1269
 
1211
1270
  type ActivityPayloadUnionActionCompleted = {
@@ -1293,6 +1352,10 @@ type ExecutionActivityPayloadUnion = ({
1293
1352
  } & ActivityPayloadUnionUserMessageReceived);
1294
1353
  type ExecutionActivityStatusChangedPayload = {
1295
1354
  status: ExecutionStatus;
1355
+ completedPayload?: ExecutionCompletedPayload;
1356
+ failedPayload?: ExecutionFailedPayload;
1357
+ pausedPayload?: ExecutionPausedPayload;
1358
+ awaitingConfirmationPayload?: ExecutionAwaitingConfirmationPayload;
1296
1359
  };
1297
1360
  type ExecutionActivityStepCompletedPayload = {
1298
1361
  stepNumber: number;
@@ -1308,6 +1371,21 @@ type ExecutionActivityUserMessageReceivedPayload = {
1308
1371
  message: string;
1309
1372
  userUUID: Uuid;
1310
1373
  };
1374
+ type ExecutionAwaitingConfirmationPayload = {
1375
+ reason: string;
1376
+ };
1377
+ type ExecutionCompletedPayload = {
1378
+ outcome: 'success' | 'failure';
1379
+ reasoning: string;
1380
+ final_answer?: string;
1381
+ result: unknown;
1382
+ };
1383
+ type ExecutionFailedPayload = {
1384
+ reason: string;
1385
+ };
1386
+ type ExecutionPausedPayload = {
1387
+ reason: string;
1388
+ };
1311
1389
  type ExecutionStatus = 'starting' | 'running' | 'paused' | 'awaiting_confirmation' | 'completed' | 'cancelled' | 'failed' | 'paused_by_agent';
1312
1390
  type ExecutionTerminalPayload = {
1313
1391
  reason: 'unsubscribe' | 'complete' | 'error';
@@ -1412,6 +1490,10 @@ type types_gen_ExecutionActivityStepCompletedPayload = ExecutionActivityStepComp
1412
1490
  type types_gen_ExecutionActivityStepStartedPayload = ExecutionActivityStepStartedPayload;
1413
1491
  type types_gen_ExecutionActivityTransitionedNodePayload = ExecutionActivityTransitionedNodePayload;
1414
1492
  type types_gen_ExecutionActivityUserMessageReceivedPayload = ExecutionActivityUserMessageReceivedPayload;
1493
+ type types_gen_ExecutionAwaitingConfirmationPayload = ExecutionAwaitingConfirmationPayload;
1494
+ type types_gen_ExecutionCompletedPayload = ExecutionCompletedPayload;
1495
+ type types_gen_ExecutionFailedPayload = ExecutionFailedPayload;
1496
+ type types_gen_ExecutionPausedPayload = ExecutionPausedPayload;
1415
1497
  type types_gen_ExecutionStatus = ExecutionStatus;
1416
1498
  type types_gen_ExecutionTerminalPayload = ExecutionTerminalPayload;
1417
1499
  type types_gen_ExecutionUserMessagesAddTextBody = ExecutionUserMessagesAddTextBody;
@@ -1425,7 +1507,7 @@ type types_gen_Uuid = Uuid;
1425
1507
  type types_gen_Versions = Versions;
1426
1508
  type types_gen__Error = _Error;
1427
1509
  declare namespace types_gen {
1428
- export type { types_gen_ActivitiesGetData as ActivitiesGetData, types_gen_ActivitiesGetError as ActivitiesGetError, types_gen_ActivitiesGetErrors as ActivitiesGetErrors, types_gen_ActivitiesGetResponse as ActivitiesGetResponse, types_gen_ActivitiesGetResponses as ActivitiesGetResponses, types_gen_ActivityPayloadUnionActionCompleted as ActivityPayloadUnionActionCompleted, types_gen_ActivityPayloadUnionActionFailed as ActivityPayloadUnionActionFailed, types_gen_ActivityPayloadUnionActionStarted as ActivityPayloadUnionActionStarted, types_gen_ActivityPayloadUnionGeneric as ActivityPayloadUnionGeneric, types_gen_ActivityPayloadUnionStatusChanged as ActivityPayloadUnionStatusChanged, types_gen_ActivityPayloadUnionStepCompleted as ActivityPayloadUnionStepCompleted, types_gen_ActivityPayloadUnionStepStarted as ActivityPayloadUnionStepStarted, types_gen_ActivityPayloadUnionTerminal as ActivityPayloadUnionTerminal, types_gen_ActivityPayloadUnionTransitionedNode as ActivityPayloadUnionTransitionedNode, types_gen_ActivityPayloadUnionUserMessageReceived as ActivityPayloadUnionUserMessageReceived, types_gen_ClientOptions as ClientOptions, types_gen_ExecutionActivity as ExecutionActivity, types_gen_ExecutionActivityActionCompletedPayload as ExecutionActivityActionCompletedPayload, types_gen_ExecutionActivityActionFailedPayload as ExecutionActivityActionFailedPayload, types_gen_ExecutionActivityActionStartedPayload as ExecutionActivityActionStartedPayload, types_gen_ExecutionActivityGenericPayload as ExecutionActivityGenericPayload, types_gen_ExecutionActivityPayloadUnion as ExecutionActivityPayloadUnion, types_gen_ExecutionActivityStatusChangedPayload as ExecutionActivityStatusChangedPayload, types_gen_ExecutionActivityStepCompletedPayload as ExecutionActivityStepCompletedPayload, types_gen_ExecutionActivityStepStartedPayload as ExecutionActivityStepStartedPayload, types_gen_ExecutionActivityTransitionedNodePayload as ExecutionActivityTransitionedNodePayload, types_gen_ExecutionActivityUserMessageReceivedPayload as ExecutionActivityUserMessageReceivedPayload, types_gen_ExecutionStatus as ExecutionStatus, types_gen_ExecutionTerminalPayload as ExecutionTerminalPayload, types_gen_ExecutionUserMessagesAddTextBody as ExecutionUserMessagesAddTextBody, types_gen_FilePart as FilePart, types_gen_UserMessagesAddData as UserMessagesAddData, types_gen_UserMessagesAddError as UserMessagesAddError, types_gen_UserMessagesAddErrors as UserMessagesAddErrors, types_gen_UserMessagesAddResponse as UserMessagesAddResponse, types_gen_UserMessagesAddResponses as UserMessagesAddResponses, types_gen_Uuid as Uuid, types_gen_Versions as Versions, types_gen__Error as _Error };
1510
+ export type { types_gen_ActivitiesGetData as ActivitiesGetData, types_gen_ActivitiesGetError as ActivitiesGetError, types_gen_ActivitiesGetErrors as ActivitiesGetErrors, types_gen_ActivitiesGetResponse as ActivitiesGetResponse, types_gen_ActivitiesGetResponses as ActivitiesGetResponses, types_gen_ActivityPayloadUnionActionCompleted as ActivityPayloadUnionActionCompleted, types_gen_ActivityPayloadUnionActionFailed as ActivityPayloadUnionActionFailed, types_gen_ActivityPayloadUnionActionStarted as ActivityPayloadUnionActionStarted, types_gen_ActivityPayloadUnionGeneric as ActivityPayloadUnionGeneric, types_gen_ActivityPayloadUnionStatusChanged as ActivityPayloadUnionStatusChanged, types_gen_ActivityPayloadUnionStepCompleted as ActivityPayloadUnionStepCompleted, types_gen_ActivityPayloadUnionStepStarted as ActivityPayloadUnionStepStarted, types_gen_ActivityPayloadUnionTerminal as ActivityPayloadUnionTerminal, types_gen_ActivityPayloadUnionTransitionedNode as ActivityPayloadUnionTransitionedNode, types_gen_ActivityPayloadUnionUserMessageReceived as ActivityPayloadUnionUserMessageReceived, types_gen_ClientOptions as ClientOptions, types_gen_ExecutionActivity as ExecutionActivity, types_gen_ExecutionActivityActionCompletedPayload as ExecutionActivityActionCompletedPayload, types_gen_ExecutionActivityActionFailedPayload as ExecutionActivityActionFailedPayload, types_gen_ExecutionActivityActionStartedPayload as ExecutionActivityActionStartedPayload, types_gen_ExecutionActivityGenericPayload as ExecutionActivityGenericPayload, types_gen_ExecutionActivityPayloadUnion as ExecutionActivityPayloadUnion, types_gen_ExecutionActivityStatusChangedPayload as ExecutionActivityStatusChangedPayload, types_gen_ExecutionActivityStepCompletedPayload as ExecutionActivityStepCompletedPayload, types_gen_ExecutionActivityStepStartedPayload as ExecutionActivityStepStartedPayload, types_gen_ExecutionActivityTransitionedNodePayload as ExecutionActivityTransitionedNodePayload, types_gen_ExecutionActivityUserMessageReceivedPayload as ExecutionActivityUserMessageReceivedPayload, types_gen_ExecutionAwaitingConfirmationPayload as ExecutionAwaitingConfirmationPayload, types_gen_ExecutionCompletedPayload as ExecutionCompletedPayload, types_gen_ExecutionFailedPayload as ExecutionFailedPayload, types_gen_ExecutionPausedPayload as ExecutionPausedPayload, types_gen_ExecutionStatus as ExecutionStatus, types_gen_ExecutionTerminalPayload as ExecutionTerminalPayload, types_gen_ExecutionUserMessagesAddTextBody as ExecutionUserMessagesAddTextBody, types_gen_FilePart as FilePart, types_gen_UserMessagesAddData as UserMessagesAddData, types_gen_UserMessagesAddError as UserMessagesAddError, types_gen_UserMessagesAddErrors as UserMessagesAddErrors, types_gen_UserMessagesAddResponse as UserMessagesAddResponse, types_gen_UserMessagesAddResponses as UserMessagesAddResponses, types_gen_Uuid as Uuid, types_gen_Versions as Versions, types_gen__Error as _Error };
1429
1511
  }
1430
1512
 
1431
1513
  type Options$1<TData extends TDataShape$1 = TDataShape$1, ThrowOnError extends boolean = boolean> = Options$3<TData, ThrowOnError> & {
@@ -1655,7 +1737,7 @@ declare const uploadExecutionFiles: (client: AsteroidClient, executionId: string
1655
1737
  *
1656
1738
  * @param client - The API client.
1657
1739
  * @param organizationId - Optional organization ID to filter by.
1658
- * @returns The list of agent profiles.
1740
+ * @returns []AgentProfile - List of agent profiles.
1659
1741
  *
1660
1742
  * @example
1661
1743
  * const profiles = await getAgentProfiles(client, 'org_123');
@@ -1688,6 +1770,7 @@ declare const getCredentialsPublicKey: (client: AsteroidClient) => Promise<strin
1688
1770
  * captcha_solver_active: false,
1689
1771
  * sticky_ip: false,
1690
1772
  * credentials: []
1773
+ * cookies: []
1691
1774
  * });
1692
1775
  */
1693
1776
  declare const createAgentProfile: (client: AsteroidClient, payload: CreateAgentProfileRequest) => Promise<AgentProfile>;
package/dist/index.d.ts CHANGED
@@ -554,6 +554,48 @@ type StructuredAgentExecutionRequest = {
554
554
  [key: string]: unknown;
555
555
  };
556
556
  };
557
+ type Cookie = {
558
+ /**
559
+ * Unique identifier for the cookie
560
+ */
561
+ id?: string;
562
+ /**
563
+ * Display name for the cookie
564
+ */
565
+ name: string;
566
+ /**
567
+ * The cookie name/key
568
+ */
569
+ key: string;
570
+ /**
571
+ * The cookie value
572
+ */
573
+ value: string;
574
+ /**
575
+ * When the cookie expires (optional)
576
+ */
577
+ expiry?: string;
578
+ /**
579
+ * The domain for which the cookie is valid
580
+ */
581
+ domain: string;
582
+ /**
583
+ * Whether the cookie should only be sent over HTTPS
584
+ */
585
+ secure: boolean;
586
+ /**
587
+ * SameSite attribute for the cookie
588
+ */
589
+ same_site: 'Strict' | 'Lax' | 'None';
590
+ /**
591
+ * Whether the cookie should be accessible only via HTTP(S)
592
+ */
593
+ http_only: boolean;
594
+ /**
595
+ * When the cookie was created
596
+ */
597
+ created_at: string;
598
+ };
557
599
  type AgentProfile = {
558
600
  /**
559
601
  * Unique identifier for the agent profile
@@ -585,6 +627,10 @@ type AgentProfile = {
585
627
  * List of credentials associated with this agent profile
586
628
  */
587
629
  credentials: Array<Credential>;
630
+ /**
631
+ * List of cookies associated with this agent profile
632
+ */
633
+ cookies: Array<Cookie>;
588
634
  /**
589
635
  * The date and time the agent profile was created
590
636
  */
@@ -621,6 +667,10 @@ type CreateAgentProfileRequest = {
621
667
  * Optional list of credentials to create with the profile
622
668
  */
623
669
  credentials: Array<Credential>;
670
+ /**
671
+ * Optional list of cookies to create with the profile
672
+ */
673
+ cookies: Array<Cookie>;
624
674
  };
625
675
  type UpdateAgentProfileRequest = {
626
676
  /**
@@ -649,6 +699,14 @@ type UpdateAgentProfileRequest = {
649
699
  * List of credential IDs to delete from the profile
650
700
  */
651
701
  credentials_to_delete?: Array<string>;
702
+ /**
703
+ * List of cookies to add to the profile
704
+ */
705
+ cookies_to_add?: Array<Cookie>;
706
+ /**
707
+ * List of cookie IDs to delete from the profile
708
+ */
709
+ cookies_to_delete?: Array<string>;
652
710
  };
653
711
  /**
654
712
  * Two-letter country code for proxy location
@@ -1126,6 +1184,7 @@ type ClientOptions$1 = {
1126
1184
  type types_gen$1_AgentExecutionRequest = AgentExecutionRequest;
1127
1185
  type types_gen$1_AgentProfile = AgentProfile;
1128
1186
  type types_gen$1_BrowserSessionRecordingResponse = BrowserSessionRecordingResponse;
1187
+ type types_gen$1_Cookie = Cookie;
1129
1188
  type types_gen$1_CountryCode = CountryCode;
1130
1189
  type types_gen$1_CreateAgentProfileData = CreateAgentProfileData;
1131
1190
  type types_gen$1_CreateAgentProfileError = CreateAgentProfileError;
@@ -1205,7 +1264,7 @@ type types_gen$1_UploadExecutionFilesErrors = UploadExecutionFilesErrors;
1205
1264
  type types_gen$1_UploadExecutionFilesResponse = UploadExecutionFilesResponse;
1206
1265
  type types_gen$1_UploadExecutionFilesResponses = UploadExecutionFilesResponses;
1207
1266
  declare namespace types_gen$1 {
1208
- export type { types_gen$1_AgentExecutionRequest as AgentExecutionRequest, types_gen$1_AgentProfile as AgentProfile, types_gen$1_BrowserSessionRecordingResponse as BrowserSessionRecordingResponse, ClientOptions$1 as ClientOptions, types_gen$1_CountryCode as CountryCode, types_gen$1_CreateAgentProfileData as CreateAgentProfileData, types_gen$1_CreateAgentProfileError as CreateAgentProfileError, types_gen$1_CreateAgentProfileErrors as CreateAgentProfileErrors, types_gen$1_CreateAgentProfileRequest as CreateAgentProfileRequest, types_gen$1_CreateAgentProfileResponse as CreateAgentProfileResponse, types_gen$1_CreateAgentProfileResponses as CreateAgentProfileResponses, types_gen$1_Credential as Credential, types_gen$1_DeleteAgentProfileData as DeleteAgentProfileData, types_gen$1_DeleteAgentProfileError as DeleteAgentProfileError, types_gen$1_DeleteAgentProfileErrors as DeleteAgentProfileErrors, types_gen$1_DeleteAgentProfileResponse as DeleteAgentProfileResponse, types_gen$1_DeleteAgentProfileResponses as DeleteAgentProfileResponses, types_gen$1_ErrorResponse as ErrorResponse, types_gen$1_ExecuteAgentData as ExecuteAgentData, types_gen$1_ExecuteAgentError as ExecuteAgentError, types_gen$1_ExecuteAgentErrors as ExecuteAgentErrors, types_gen$1_ExecuteAgentResponse as ExecuteAgentResponse, types_gen$1_ExecuteAgentResponses as ExecuteAgentResponses, types_gen$1_ExecuteAgentStructuredData as ExecuteAgentStructuredData, types_gen$1_ExecuteAgentStructuredError as ExecuteAgentStructuredError, types_gen$1_ExecuteAgentStructuredErrors as ExecuteAgentStructuredErrors, types_gen$1_ExecuteAgentStructuredResponse as ExecuteAgentStructuredResponse, types_gen$1_ExecuteAgentStructuredResponses as ExecuteAgentStructuredResponses, types_gen$1_ExecutionResponse as ExecutionResponse, types_gen$1_ExecutionResult as ExecutionResult, types_gen$1_ExecutionResultResponse as ExecutionResultResponse, types_gen$1_ExecutionStatusResponse as ExecutionStatusResponse, types_gen$1_GetAgentProfileData as GetAgentProfileData, types_gen$1_GetAgentProfileError as GetAgentProfileError, types_gen$1_GetAgentProfileErrors as GetAgentProfileErrors, types_gen$1_GetAgentProfileResponse as GetAgentProfileResponse, types_gen$1_GetAgentProfileResponses as GetAgentProfileResponses, types_gen$1_GetAgentProfilesData as GetAgentProfilesData, types_gen$1_GetAgentProfilesError as GetAgentProfilesError, types_gen$1_GetAgentProfilesErrors as GetAgentProfilesErrors, types_gen$1_GetAgentProfilesResponse as GetAgentProfilesResponse, types_gen$1_GetAgentProfilesResponses as GetAgentProfilesResponses, types_gen$1_GetBrowserSessionRecordingData as GetBrowserSessionRecordingData, types_gen$1_GetBrowserSessionRecordingError as GetBrowserSessionRecordingError, types_gen$1_GetBrowserSessionRecordingErrors as GetBrowserSessionRecordingErrors, types_gen$1_GetBrowserSessionRecordingResponse as GetBrowserSessionRecordingResponse, types_gen$1_GetBrowserSessionRecordingResponses as GetBrowserSessionRecordingResponses, types_gen$1_GetCredentialsPublicKeyData as GetCredentialsPublicKeyData, types_gen$1_GetCredentialsPublicKeyErrors as GetCredentialsPublicKeyErrors, types_gen$1_GetCredentialsPublicKeyResponse as GetCredentialsPublicKeyResponse, types_gen$1_GetCredentialsPublicKeyResponses as GetCredentialsPublicKeyResponses, types_gen$1_GetExecutionResultData as GetExecutionResultData, types_gen$1_GetExecutionResultError as GetExecutionResultError, types_gen$1_GetExecutionResultErrors as GetExecutionResultErrors, types_gen$1_GetExecutionResultResponse as GetExecutionResultResponse, types_gen$1_GetExecutionResultResponses as GetExecutionResultResponses, types_gen$1_GetExecutionStatusData as GetExecutionStatusData, types_gen$1_GetExecutionStatusError as GetExecutionStatusError, types_gen$1_GetExecutionStatusErrors as GetExecutionStatusErrors, types_gen$1_GetExecutionStatusResponse as GetExecutionStatusResponse, types_gen$1_GetExecutionStatusResponses as GetExecutionStatusResponses, types_gen$1_GetOpenApiData as GetOpenApiData, types_gen$1_GetOpenApiResponses as GetOpenApiResponses, types_gen$1_HealthCheckData as HealthCheckData, types_gen$1_HealthCheckError as HealthCheckError, types_gen$1_HealthCheckErrors as HealthCheckErrors, types_gen$1_HealthCheckResponse as HealthCheckResponse, types_gen$1_HealthCheckResponses as HealthCheckResponses, types_gen$1_ProxyType as ProxyType, types_gen$1_Status as Status, types_gen$1_StructuredAgentExecutionRequest as StructuredAgentExecutionRequest, types_gen$1_UpdateAgentProfileData as UpdateAgentProfileData, types_gen$1_UpdateAgentProfileError as UpdateAgentProfileError, types_gen$1_UpdateAgentProfileErrors as UpdateAgentProfileErrors, types_gen$1_UpdateAgentProfileRequest as UpdateAgentProfileRequest, types_gen$1_UpdateAgentProfileResponse as UpdateAgentProfileResponse, types_gen$1_UpdateAgentProfileResponses as UpdateAgentProfileResponses, types_gen$1_UploadExecutionFilesData as UploadExecutionFilesData, types_gen$1_UploadExecutionFilesError as UploadExecutionFilesError, types_gen$1_UploadExecutionFilesErrors as UploadExecutionFilesErrors, types_gen$1_UploadExecutionFilesResponse as UploadExecutionFilesResponse, types_gen$1_UploadExecutionFilesResponses as UploadExecutionFilesResponses };
1267
+ export type { types_gen$1_AgentExecutionRequest as AgentExecutionRequest, types_gen$1_AgentProfile as AgentProfile, types_gen$1_BrowserSessionRecordingResponse as BrowserSessionRecordingResponse, ClientOptions$1 as ClientOptions, types_gen$1_Cookie as Cookie, types_gen$1_CountryCode as CountryCode, types_gen$1_CreateAgentProfileData as CreateAgentProfileData, types_gen$1_CreateAgentProfileError as CreateAgentProfileError, types_gen$1_CreateAgentProfileErrors as CreateAgentProfileErrors, types_gen$1_CreateAgentProfileRequest as CreateAgentProfileRequest, types_gen$1_CreateAgentProfileResponse as CreateAgentProfileResponse, types_gen$1_CreateAgentProfileResponses as CreateAgentProfileResponses, types_gen$1_Credential as Credential, types_gen$1_DeleteAgentProfileData as DeleteAgentProfileData, types_gen$1_DeleteAgentProfileError as DeleteAgentProfileError, types_gen$1_DeleteAgentProfileErrors as DeleteAgentProfileErrors, types_gen$1_DeleteAgentProfileResponse as DeleteAgentProfileResponse, types_gen$1_DeleteAgentProfileResponses as DeleteAgentProfileResponses, types_gen$1_ErrorResponse as ErrorResponse, types_gen$1_ExecuteAgentData as ExecuteAgentData, types_gen$1_ExecuteAgentError as ExecuteAgentError, types_gen$1_ExecuteAgentErrors as ExecuteAgentErrors, types_gen$1_ExecuteAgentResponse as ExecuteAgentResponse, types_gen$1_ExecuteAgentResponses as ExecuteAgentResponses, types_gen$1_ExecuteAgentStructuredData as ExecuteAgentStructuredData, types_gen$1_ExecuteAgentStructuredError as ExecuteAgentStructuredError, types_gen$1_ExecuteAgentStructuredErrors as ExecuteAgentStructuredErrors, types_gen$1_ExecuteAgentStructuredResponse as ExecuteAgentStructuredResponse, types_gen$1_ExecuteAgentStructuredResponses as ExecuteAgentStructuredResponses, types_gen$1_ExecutionResponse as ExecutionResponse, types_gen$1_ExecutionResult as ExecutionResult, types_gen$1_ExecutionResultResponse as ExecutionResultResponse, types_gen$1_ExecutionStatusResponse as ExecutionStatusResponse, types_gen$1_GetAgentProfileData as GetAgentProfileData, types_gen$1_GetAgentProfileError as GetAgentProfileError, types_gen$1_GetAgentProfileErrors as GetAgentProfileErrors, types_gen$1_GetAgentProfileResponse as GetAgentProfileResponse, types_gen$1_GetAgentProfileResponses as GetAgentProfileResponses, types_gen$1_GetAgentProfilesData as GetAgentProfilesData, types_gen$1_GetAgentProfilesError as GetAgentProfilesError, types_gen$1_GetAgentProfilesErrors as GetAgentProfilesErrors, types_gen$1_GetAgentProfilesResponse as GetAgentProfilesResponse, types_gen$1_GetAgentProfilesResponses as GetAgentProfilesResponses, types_gen$1_GetBrowserSessionRecordingData as GetBrowserSessionRecordingData, types_gen$1_GetBrowserSessionRecordingError as GetBrowserSessionRecordingError, types_gen$1_GetBrowserSessionRecordingErrors as GetBrowserSessionRecordingErrors, types_gen$1_GetBrowserSessionRecordingResponse as GetBrowserSessionRecordingResponse, types_gen$1_GetBrowserSessionRecordingResponses as GetBrowserSessionRecordingResponses, types_gen$1_GetCredentialsPublicKeyData as GetCredentialsPublicKeyData, types_gen$1_GetCredentialsPublicKeyErrors as GetCredentialsPublicKeyErrors, types_gen$1_GetCredentialsPublicKeyResponse as GetCredentialsPublicKeyResponse, types_gen$1_GetCredentialsPublicKeyResponses as GetCredentialsPublicKeyResponses, types_gen$1_GetExecutionResultData as GetExecutionResultData, types_gen$1_GetExecutionResultError as GetExecutionResultError, types_gen$1_GetExecutionResultErrors as GetExecutionResultErrors, types_gen$1_GetExecutionResultResponse as GetExecutionResultResponse, types_gen$1_GetExecutionResultResponses as GetExecutionResultResponses, types_gen$1_GetExecutionStatusData as GetExecutionStatusData, types_gen$1_GetExecutionStatusError as GetExecutionStatusError, types_gen$1_GetExecutionStatusErrors as GetExecutionStatusErrors, types_gen$1_GetExecutionStatusResponse as GetExecutionStatusResponse, types_gen$1_GetExecutionStatusResponses as GetExecutionStatusResponses, types_gen$1_GetOpenApiData as GetOpenApiData, types_gen$1_GetOpenApiResponses as GetOpenApiResponses, types_gen$1_HealthCheckData as HealthCheckData, types_gen$1_HealthCheckError as HealthCheckError, types_gen$1_HealthCheckErrors as HealthCheckErrors, types_gen$1_HealthCheckResponse as HealthCheckResponse, types_gen$1_HealthCheckResponses as HealthCheckResponses, types_gen$1_ProxyType as ProxyType, types_gen$1_Status as Status, types_gen$1_StructuredAgentExecutionRequest as StructuredAgentExecutionRequest, types_gen$1_UpdateAgentProfileData as UpdateAgentProfileData, types_gen$1_UpdateAgentProfileError as UpdateAgentProfileError, types_gen$1_UpdateAgentProfileErrors as UpdateAgentProfileErrors, types_gen$1_UpdateAgentProfileRequest as UpdateAgentProfileRequest, types_gen$1_UpdateAgentProfileResponse as UpdateAgentProfileResponse, types_gen$1_UpdateAgentProfileResponses as UpdateAgentProfileResponses, types_gen$1_UploadExecutionFilesData as UploadExecutionFilesData, types_gen$1_UploadExecutionFilesError as UploadExecutionFilesError, types_gen$1_UploadExecutionFilesErrors as UploadExecutionFilesErrors, types_gen$1_UploadExecutionFilesResponse as UploadExecutionFilesResponse, types_gen$1_UploadExecutionFilesResponses as UploadExecutionFilesResponses };
1209
1268
  }
1210
1269
 
1211
1270
  type ActivityPayloadUnionActionCompleted = {
@@ -1293,6 +1352,10 @@ type ExecutionActivityPayloadUnion = ({
1293
1352
  } & ActivityPayloadUnionUserMessageReceived);
1294
1353
  type ExecutionActivityStatusChangedPayload = {
1295
1354
  status: ExecutionStatus;
1355
+ completedPayload?: ExecutionCompletedPayload;
1356
+ failedPayload?: ExecutionFailedPayload;
1357
+ pausedPayload?: ExecutionPausedPayload;
1358
+ awaitingConfirmationPayload?: ExecutionAwaitingConfirmationPayload;
1296
1359
  };
1297
1360
  type ExecutionActivityStepCompletedPayload = {
1298
1361
  stepNumber: number;
@@ -1308,6 +1371,21 @@ type ExecutionActivityUserMessageReceivedPayload = {
1308
1371
  message: string;
1309
1372
  userUUID: Uuid;
1310
1373
  };
1374
+ type ExecutionAwaitingConfirmationPayload = {
1375
+ reason: string;
1376
+ };
1377
+ type ExecutionCompletedPayload = {
1378
+ outcome: 'success' | 'failure';
1379
+ reasoning: string;
1380
+ final_answer?: string;
1381
+ result: unknown;
1382
+ };
1383
+ type ExecutionFailedPayload = {
1384
+ reason: string;
1385
+ };
1386
+ type ExecutionPausedPayload = {
1387
+ reason: string;
1388
+ };
1311
1389
  type ExecutionStatus = 'starting' | 'running' | 'paused' | 'awaiting_confirmation' | 'completed' | 'cancelled' | 'failed' | 'paused_by_agent';
1312
1390
  type ExecutionTerminalPayload = {
1313
1391
  reason: 'unsubscribe' | 'complete' | 'error';
@@ -1412,6 +1490,10 @@ type types_gen_ExecutionActivityStepCompletedPayload = ExecutionActivityStepComp
1412
1490
  type types_gen_ExecutionActivityStepStartedPayload = ExecutionActivityStepStartedPayload;
1413
1491
  type types_gen_ExecutionActivityTransitionedNodePayload = ExecutionActivityTransitionedNodePayload;
1414
1492
  type types_gen_ExecutionActivityUserMessageReceivedPayload = ExecutionActivityUserMessageReceivedPayload;
1493
+ type types_gen_ExecutionAwaitingConfirmationPayload = ExecutionAwaitingConfirmationPayload;
1494
+ type types_gen_ExecutionCompletedPayload = ExecutionCompletedPayload;
1495
+ type types_gen_ExecutionFailedPayload = ExecutionFailedPayload;
1496
+ type types_gen_ExecutionPausedPayload = ExecutionPausedPayload;
1415
1497
  type types_gen_ExecutionStatus = ExecutionStatus;
1416
1498
  type types_gen_ExecutionTerminalPayload = ExecutionTerminalPayload;
1417
1499
  type types_gen_ExecutionUserMessagesAddTextBody = ExecutionUserMessagesAddTextBody;
@@ -1425,7 +1507,7 @@ type types_gen_Uuid = Uuid;
1425
1507
  type types_gen_Versions = Versions;
1426
1508
  type types_gen__Error = _Error;
1427
1509
  declare namespace types_gen {
1428
- export type { types_gen_ActivitiesGetData as ActivitiesGetData, types_gen_ActivitiesGetError as ActivitiesGetError, types_gen_ActivitiesGetErrors as ActivitiesGetErrors, types_gen_ActivitiesGetResponse as ActivitiesGetResponse, types_gen_ActivitiesGetResponses as ActivitiesGetResponses, types_gen_ActivityPayloadUnionActionCompleted as ActivityPayloadUnionActionCompleted, types_gen_ActivityPayloadUnionActionFailed as ActivityPayloadUnionActionFailed, types_gen_ActivityPayloadUnionActionStarted as ActivityPayloadUnionActionStarted, types_gen_ActivityPayloadUnionGeneric as ActivityPayloadUnionGeneric, types_gen_ActivityPayloadUnionStatusChanged as ActivityPayloadUnionStatusChanged, types_gen_ActivityPayloadUnionStepCompleted as ActivityPayloadUnionStepCompleted, types_gen_ActivityPayloadUnionStepStarted as ActivityPayloadUnionStepStarted, types_gen_ActivityPayloadUnionTerminal as ActivityPayloadUnionTerminal, types_gen_ActivityPayloadUnionTransitionedNode as ActivityPayloadUnionTransitionedNode, types_gen_ActivityPayloadUnionUserMessageReceived as ActivityPayloadUnionUserMessageReceived, types_gen_ClientOptions as ClientOptions, types_gen_ExecutionActivity as ExecutionActivity, types_gen_ExecutionActivityActionCompletedPayload as ExecutionActivityActionCompletedPayload, types_gen_ExecutionActivityActionFailedPayload as ExecutionActivityActionFailedPayload, types_gen_ExecutionActivityActionStartedPayload as ExecutionActivityActionStartedPayload, types_gen_ExecutionActivityGenericPayload as ExecutionActivityGenericPayload, types_gen_ExecutionActivityPayloadUnion as ExecutionActivityPayloadUnion, types_gen_ExecutionActivityStatusChangedPayload as ExecutionActivityStatusChangedPayload, types_gen_ExecutionActivityStepCompletedPayload as ExecutionActivityStepCompletedPayload, types_gen_ExecutionActivityStepStartedPayload as ExecutionActivityStepStartedPayload, types_gen_ExecutionActivityTransitionedNodePayload as ExecutionActivityTransitionedNodePayload, types_gen_ExecutionActivityUserMessageReceivedPayload as ExecutionActivityUserMessageReceivedPayload, types_gen_ExecutionStatus as ExecutionStatus, types_gen_ExecutionTerminalPayload as ExecutionTerminalPayload, types_gen_ExecutionUserMessagesAddTextBody as ExecutionUserMessagesAddTextBody, types_gen_FilePart as FilePart, types_gen_UserMessagesAddData as UserMessagesAddData, types_gen_UserMessagesAddError as UserMessagesAddError, types_gen_UserMessagesAddErrors as UserMessagesAddErrors, types_gen_UserMessagesAddResponse as UserMessagesAddResponse, types_gen_UserMessagesAddResponses as UserMessagesAddResponses, types_gen_Uuid as Uuid, types_gen_Versions as Versions, types_gen__Error as _Error };
1510
+ export type { types_gen_ActivitiesGetData as ActivitiesGetData, types_gen_ActivitiesGetError as ActivitiesGetError, types_gen_ActivitiesGetErrors as ActivitiesGetErrors, types_gen_ActivitiesGetResponse as ActivitiesGetResponse, types_gen_ActivitiesGetResponses as ActivitiesGetResponses, types_gen_ActivityPayloadUnionActionCompleted as ActivityPayloadUnionActionCompleted, types_gen_ActivityPayloadUnionActionFailed as ActivityPayloadUnionActionFailed, types_gen_ActivityPayloadUnionActionStarted as ActivityPayloadUnionActionStarted, types_gen_ActivityPayloadUnionGeneric as ActivityPayloadUnionGeneric, types_gen_ActivityPayloadUnionStatusChanged as ActivityPayloadUnionStatusChanged, types_gen_ActivityPayloadUnionStepCompleted as ActivityPayloadUnionStepCompleted, types_gen_ActivityPayloadUnionStepStarted as ActivityPayloadUnionStepStarted, types_gen_ActivityPayloadUnionTerminal as ActivityPayloadUnionTerminal, types_gen_ActivityPayloadUnionTransitionedNode as ActivityPayloadUnionTransitionedNode, types_gen_ActivityPayloadUnionUserMessageReceived as ActivityPayloadUnionUserMessageReceived, types_gen_ClientOptions as ClientOptions, types_gen_ExecutionActivity as ExecutionActivity, types_gen_ExecutionActivityActionCompletedPayload as ExecutionActivityActionCompletedPayload, types_gen_ExecutionActivityActionFailedPayload as ExecutionActivityActionFailedPayload, types_gen_ExecutionActivityActionStartedPayload as ExecutionActivityActionStartedPayload, types_gen_ExecutionActivityGenericPayload as ExecutionActivityGenericPayload, types_gen_ExecutionActivityPayloadUnion as ExecutionActivityPayloadUnion, types_gen_ExecutionActivityStatusChangedPayload as ExecutionActivityStatusChangedPayload, types_gen_ExecutionActivityStepCompletedPayload as ExecutionActivityStepCompletedPayload, types_gen_ExecutionActivityStepStartedPayload as ExecutionActivityStepStartedPayload, types_gen_ExecutionActivityTransitionedNodePayload as ExecutionActivityTransitionedNodePayload, types_gen_ExecutionActivityUserMessageReceivedPayload as ExecutionActivityUserMessageReceivedPayload, types_gen_ExecutionAwaitingConfirmationPayload as ExecutionAwaitingConfirmationPayload, types_gen_ExecutionCompletedPayload as ExecutionCompletedPayload, types_gen_ExecutionFailedPayload as ExecutionFailedPayload, types_gen_ExecutionPausedPayload as ExecutionPausedPayload, types_gen_ExecutionStatus as ExecutionStatus, types_gen_ExecutionTerminalPayload as ExecutionTerminalPayload, types_gen_ExecutionUserMessagesAddTextBody as ExecutionUserMessagesAddTextBody, types_gen_FilePart as FilePart, types_gen_UserMessagesAddData as UserMessagesAddData, types_gen_UserMessagesAddError as UserMessagesAddError, types_gen_UserMessagesAddErrors as UserMessagesAddErrors, types_gen_UserMessagesAddResponse as UserMessagesAddResponse, types_gen_UserMessagesAddResponses as UserMessagesAddResponses, types_gen_Uuid as Uuid, types_gen_Versions as Versions, types_gen__Error as _Error };
1429
1511
  }
1430
1512
 
1431
1513
  type Options$1<TData extends TDataShape$1 = TDataShape$1, ThrowOnError extends boolean = boolean> = Options$3<TData, ThrowOnError> & {
@@ -1655,7 +1737,7 @@ declare const uploadExecutionFiles: (client: AsteroidClient, executionId: string
1655
1737
  *
1656
1738
  * @param client - The API client.
1657
1739
  * @param organizationId - Optional organization ID to filter by.
1658
- * @returns The list of agent profiles.
1740
+ * @returns []AgentProfile - List of agent profiles.
1659
1741
  *
1660
1742
  * @example
1661
1743
  * const profiles = await getAgentProfiles(client, 'org_123');
@@ -1688,6 +1770,7 @@ declare const getCredentialsPublicKey: (client: AsteroidClient) => Promise<strin
1688
1770
  * captcha_solver_active: false,
1689
1771
  * sticky_ip: false,
1690
1772
  * credentials: []
1773
+ * cookies: []
1691
1774
  * });
1692
1775
  */
1693
1776
  declare const createAgentProfile: (client: AsteroidClient, payload: CreateAgentProfileRequest) => Promise<AgentProfile>;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var T=require('node-forge');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var T__namespace=/*#__PURE__*/_interopNamespace(T);var me=Object.defineProperty;var se=(e,r)=>{for(var t in r)me(e,t,{get:r[t],enumerable:true});};function U(e,r){try{let s=T__namespace.pki.publicKeyFromPem(r).encrypt(e,"RSAES-PKCS1-V1_5");return T__namespace.util.encode64(s)}catch(t){throw console.error("Encryption failed:",t),new Error("Failed to encrypt: "+(t instanceof Error?t.message:"unknown error"))}}var J={};se(J,{createAgentProfile:()=>F,deleteAgentProfile:()=>N,executeAgent:()=>Ue,executeAgentStructured:()=>B,getAgentProfile:()=>W,getAgentProfiles:()=>M,getBrowserSessionRecording:()=>H,getCredentialsPublicKey:()=>X,getExecutionResult:()=>V,getExecutionStatus:()=>$,getOpenApi:()=>qe,healthCheck:()=>De,updateAgentProfile:()=>Q,uploadExecutionFiles:()=>K});var ie=(e,r,t)=>{typeof t=="string"||t instanceof Blob?e.append(r,t):t instanceof Date?e.append(r,t.toISOString()):e.append(r,JSON.stringify(t));};var k={bodySerializer:e=>{let r=new FormData;return Object.entries(e).forEach(([t,s])=>{s!=null&&(Array.isArray(s)?s.forEach(i=>ie(r,t,i)):ie(r,t,s));}),r}},z={bodySerializer:e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t)};var ae=async(e,r)=>{let t=typeof r=="function"?await r(e):r;if(t)return e.scheme==="bearer"?`Bearer ${t}`:e.scheme==="basic"?`Basic ${btoa(t)}`:t};var Ee=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},Re=e=>{switch(e){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},Se=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},v=({allowReserved:e,explode:r,name:t,style:s,value:i})=>{if(!r){let o=(e?i:i.map(p=>encodeURIComponent(p))).join(Re(s));switch(s){case "label":return `.${o}`;case "matrix":return `;${t}=${o}`;case "simple":return o;default:return `${t}=${o}`}}let a=Ee(s),n=i.map(o=>s==="label"||s==="simple"?e?o:encodeURIComponent(o):S({allowReserved:e,name:t,value:o})).join(a);return s==="label"||s==="matrix"?a+n:n},S=({allowReserved:e,name:r,value:t})=>{if(t==null)return "";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${e?t:encodeURIComponent(t)}`},_=({allowReserved:e,explode:r,name:t,style:s,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${t}=${i.toISOString()}`;if(s!=="deepObject"&&!r){let p=[];Object.entries(i).forEach(([y,x])=>{p=[...p,y,e?x:encodeURIComponent(x)];});let u=p.join(",");switch(s){case "form":return `${t}=${u}`;case "label":return `.${u}`;case "matrix":return `;${t}=${u}`;default:return u}}let n=Se(s),o=Object.entries(i).map(([p,u])=>S({allowReserved:e,name:s==="deepObject"?`${t}[${p}]`:p,value:u})).join(n);return s==="label"||s==="matrix"?n+o:o};var be=/\{[^{}]+\}/g,Pe=({path:e,url:r})=>{let t=r,s=r.match(be);if(s)for(let i of s){let a=false,n=i.substring(1,i.length-1),o="simple";n.endsWith("*")&&(a=true,n=n.substring(0,n.length-1)),n.startsWith(".")?(n=n.substring(1),o="label"):n.startsWith(";")&&(n=n.substring(1),o="matrix");let p=e[n];if(p==null)continue;if(Array.isArray(p)){t=t.replace(i,v({explode:a,name:n,style:o,value:p}));continue}if(typeof p=="object"){t=t.replace(i,_({explode:a,name:n,style:o,value:p,valueOnly:true}));continue}if(o==="matrix"){t=t.replace(i,`;${S({name:n,value:p})}`);continue}let u=encodeURIComponent(o==="label"?`.${p}`:p);t=t.replace(i,u);}return t},pe=({allowReserved:e,array:r,object:t}={})=>i=>{let a=[];if(i&&typeof i=="object")for(let n in i){let o=i[n];if(o!=null)if(Array.isArray(o)){let p=v({allowReserved:e,explode:true,name:n,style:"form",value:o,...r});p&&a.push(p);}else if(typeof o=="object"){let p=_({allowReserved:e,explode:true,name:n,style:"deepObject",value:o,...t});p&&a.push(p);}else {let p=S({allowReserved:e,name:n,value:o});p&&a.push(p);}}return a.join("&")},ce=e=>{if(!e)return "stream";let r=e.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(t=>r.startsWith(t)))return "blob";if(r.startsWith("text/"))return "text"}},Oe=(e,r)=>r?!!(e.headers.has(r)||e.query?.[r]||e.headers.get("Cookie")?.includes(`${r}=`)):false,le=async({security:e,...r})=>{for(let t of e){if(Oe(r,t.name))continue;let s=await ae(t,r.auth);if(!s)continue;let i=t.name??"Authorization";switch(t.in){case "query":r.query||(r.query={}),r.query[i]=s;break;case "cookie":r.headers.append("Cookie",`${i}=${s}`);break;case "header":default:r.headers.set(i,s);break}}},G=e=>Ce({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:pe(e.querySerializer),url:e.url}),Ce=({baseUrl:e,path:r,query:t,querySerializer:s,url:i})=>{let a=i.startsWith("/")?i:`/${i}`,n=(e??"")+a;r&&(n=Pe({path:r,url:n}));let o=t?s(t):"";return o.startsWith("?")&&(o=o.substring(1)),o&&(n+=`?${o}`),n},j=(e,r)=>{let t={...e,...r};return t.baseUrl?.endsWith("/")&&(t.baseUrl=t.baseUrl.substring(0,t.baseUrl.length-1)),t.headers=q(e.headers,r.headers),t},q=(...e)=>{let r=new Headers;for(let t of e){if(!t||typeof t!="object")continue;let s=t instanceof Headers?t.entries():Object.entries(t);for(let[i,a]of s)if(a===null)r.delete(i);else if(Array.isArray(a))for(let n of a)r.append(i,n);else a!==void 0&&r.set(i,typeof a=="object"?JSON.stringify(a):a);}return r},b=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let t=this.getInterceptorIndex(r);return !!this._fns[t]}eject(r){let t=this.getInterceptorIndex(r);this._fns[t]&&(this._fns[t]=null);}update(r,t){let s=this.getInterceptorIndex(r);return this._fns[s]?(this._fns[s]=t,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},ue=()=>({error:new b,request:new b,response:new b}),we=pe({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),Te={"Content-Type":"application/json"},P=(e={})=>({...z,headers:Te,parseAs:"auto",querySerializer:we,...e});var I=(e={})=>{let r=j(P(),e),t=()=>({...r}),s=n=>(r=j(r,n),t()),i=ue(),a=async n=>{let o={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:q(r.headers,n.headers),serializedBody:void 0};o.security&&await le({...o,security:o.security}),o.requestValidator&&await o.requestValidator(o),o.body&&o.bodySerializer&&(o.serializedBody=o.bodySerializer(o.body)),(o.serializedBody===void 0||o.serializedBody==="")&&o.headers.delete("Content-Type");let p=G(o),u={redirect:"follow",...o,body:o.serializedBody},y=new Request(p,u);for(let l of i.request._fns)l&&(y=await l(y,o));let x=o.fetch,c=await x(y);for(let l of i.response._fns)l&&(c=await l(c,y,o));let A={request:y,response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return o.responseStyle==="data"?{}:{data:{},...A};let l=(o.parseAs==="auto"?ce(c.headers.get("Content-Type")):o.parseAs)??"json",f;switch(l){case "arrayBuffer":case "blob":case "formData":case "json":case "text":f=await c[l]();break;case "stream":return o.responseStyle==="data"?c.body:{data:c.body,...A}}return l==="json"&&(o.responseValidator&&await o.responseValidator(f),o.responseTransformer&&(f=await o.responseTransformer(f))),o.responseStyle==="data"?f:{data:f,...A}}let m=await c.text(),E;try{E=JSON.parse(m);}catch{}let R=E??m,g=R;for(let l of i.error._fns)l&&(g=await l(R,c,y,o));if(g=g||{},o.throwOnError)throw g;return o.responseStyle==="data"?void 0:{error:g,...A}};return {buildUrl:G,connect:n=>a({...n,method:"CONNECT"}),delete:n=>a({...n,method:"DELETE"}),get:n=>a({...n,method:"GET"}),getConfig:t,head:n=>a({...n,method:"HEAD"}),interceptors:i,options:n=>a({...n,method:"OPTIONS"}),patch:n=>a({...n,method:"PATCH"}),post:n=>a({...n,method:"POST"}),put:n=>a({...n,method:"PUT"}),request:a,setConfig:s,trace:n=>a({...n,method:"TRACE"})}};var d=I(P({baseUrl:"https://odyssey.asteroid.ai/api/v1"}));var qe=e=>(e?.client??d).get({url:"/openapi.yaml",...e}),K=e=>(e.client??d).post({...k,security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/files",...e,headers:{"Content-Type":null,...e.headers}}),De=e=>(e?.client??d).get({url:"/health",...e}),Ue=e=>(e.client??d).post({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),B=e=>(e.client??d).post({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent/{id}/execute",...e,headers:{"Content-Type":"application/json",...e.headers}}),$=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/status",...e}),V=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/result",...e}),H=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/browser_session/recording",...e}),M=e=>(e?.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles",...e}),F=e=>(e.client??d).post({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles",...e,headers:{"Content-Type":"application/json",...e.headers}}),N=e=>(e.client??d).delete({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles/{profile_id}",...e}),W=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles/{profile_id}",...e}),Q=e=>(e.client??d).patch({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles/{profile_id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),X=e=>(e?.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/credentials/public_key",...e});var ne={};se(ne,{activitiesGet:()=>re,userMessagesAdd:()=>oe});var de={bodySerializer:e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t)};var ye=async(e,r)=>{let t=typeof r=="function"?await r(e):r;if(t)return e.scheme==="bearer"?`Bearer ${t}`:e.scheme==="basic"?`Basic ${btoa(t)}`:t};var ke=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},ze=e=>{switch(e){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},ve=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},L=({allowReserved:e,explode:r,name:t,style:s,value:i})=>{if(!r){let o=(e?i:i.map(p=>encodeURIComponent(p))).join(ze(s));switch(s){case "label":return `.${o}`;case "matrix":return `;${t}=${o}`;case "simple":return o;default:return `${t}=${o}`}}let a=ke(s),n=i.map(o=>s==="label"||s==="simple"?e?o:encodeURIComponent(o):O({allowReserved:e,name:t,value:o})).join(a);return s==="label"||s==="matrix"?a+n:n},O=({allowReserved:e,name:r,value:t})=>{if(t==null)return "";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${e?t:encodeURIComponent(t)}`},Y=({allowReserved:e,explode:r,name:t,style:s,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${t}=${i.toISOString()}`;if(s!=="deepObject"&&!r){let p=[];Object.entries(i).forEach(([y,x])=>{p=[...p,y,e?x:encodeURIComponent(x)];});let u=p.join(",");switch(s){case "form":return `${t}=${u}`;case "label":return `.${u}`;case "matrix":return `;${t}=${u}`;default:return u}}let n=ve(s),o=Object.entries(i).map(([p,u])=>O({allowReserved:e,name:s==="deepObject"?`${t}[${p}]`:p,value:u})).join(n);return s==="label"||s==="matrix"?n+o:o};var _e=/\{[^{}]+\}/g,Ge=({path:e,url:r})=>{let t=r,s=r.match(_e);if(s)for(let i of s){let a=false,n=i.substring(1,i.length-1),o="simple";n.endsWith("*")&&(a=true,n=n.substring(0,n.length-1)),n.startsWith(".")?(n=n.substring(1),o="label"):n.startsWith(";")&&(n=n.substring(1),o="matrix");let p=e[n];if(p==null)continue;if(Array.isArray(p)){t=t.replace(i,L({explode:a,name:n,style:o,value:p}));continue}if(typeof p=="object"){t=t.replace(i,Y({explode:a,name:n,style:o,value:p,valueOnly:true}));continue}if(o==="matrix"){t=t.replace(i,`;${O({name:n,value:p})}`);continue}let u=encodeURIComponent(o==="label"?`.${p}`:p);t=t.replace(i,u);}return t},fe=({allowReserved:e,array:r,object:t}={})=>i=>{let a=[];if(i&&typeof i=="object")for(let n in i){let o=i[n];if(o!=null)if(Array.isArray(o)){let p=L({allowReserved:e,explode:true,name:n,style:"form",value:o,...r});p&&a.push(p);}else if(typeof o=="object"){let p=Y({allowReserved:e,explode:true,name:n,style:"deepObject",value:o,...t});p&&a.push(p);}else {let p=O({allowReserved:e,name:n,value:o});p&&a.push(p);}}return a.join("&")},ge=e=>{if(!e)return "stream";let r=e.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(t=>r.startsWith(t)))return "blob";if(r.startsWith("text/"))return "text"}},je=(e,r)=>r?!!(e.headers.has(r)||e.query?.[r]||e.headers.get("Cookie")?.includes(`${r}=`)):false,xe=async({security:e,...r})=>{for(let t of e){if(je(r,t.name))continue;let s=await ye(t,r.auth);if(!s)continue;let i=t.name??"Authorization";switch(t.in){case "query":r.query||(r.query={}),r.query[i]=s;break;case "cookie":r.headers.append("Cookie",`${i}=${s}`);break;case "header":default:r.headers.set(i,s);break}}},Z=e=>Ie({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:fe(e.querySerializer),url:e.url}),Ie=({baseUrl:e,path:r,query:t,querySerializer:s,url:i})=>{let a=i.startsWith("/")?i:`/${i}`,n=(e??"")+a;r&&(n=Ge({path:r,url:n}));let o=t?s(t):"";return o.startsWith("?")&&(o=o.substring(1)),o&&(n+=`?${o}`),n},ee=(e,r)=>{let t={...e,...r};return t.baseUrl?.endsWith("/")&&(t.baseUrl=t.baseUrl.substring(0,t.baseUrl.length-1)),t.headers=D(e.headers,r.headers),t},D=(...e)=>{let r=new Headers;for(let t of e){if(!t||typeof t!="object")continue;let s=t instanceof Headers?t.entries():Object.entries(t);for(let[i,a]of s)if(a===null)r.delete(i);else if(Array.isArray(a))for(let n of a)r.append(i,n);else a!==void 0&&r.set(i,typeof a=="object"?JSON.stringify(a):a);}return r},C=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let t=this.getInterceptorIndex(r);return !!this._fns[t]}eject(r){let t=this.getInterceptorIndex(r);this._fns[t]&&(this._fns[t]=null);}update(r,t){let s=this.getInterceptorIndex(r);return this._fns[s]?(this._fns[s]=t,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},Ae=()=>({error:new C,request:new C,response:new C}),Ke=fe({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),Be={"Content-Type":"application/json"},w=(e={})=>({...de,headers:Be,parseAs:"auto",querySerializer:Ke,...e});var te=(e={})=>{let r=ee(w(),e),t=()=>({...r}),s=n=>(r=ee(r,n),t()),i=Ae(),a=async n=>{let o={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:D(r.headers,n.headers),serializedBody:void 0};o.security&&await xe({...o,security:o.security}),o.requestValidator&&await o.requestValidator(o),o.body&&o.bodySerializer&&(o.serializedBody=o.bodySerializer(o.body)),(o.serializedBody===void 0||o.serializedBody==="")&&o.headers.delete("Content-Type");let p=Z(o),u={redirect:"follow",...o,body:o.serializedBody},y=new Request(p,u);for(let l of i.request._fns)l&&(y=await l(y,o));let x=o.fetch,c=await x(y);for(let l of i.response._fns)l&&(c=await l(c,y,o));let A={request:y,response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return o.responseStyle==="data"?{}:{data:{},...A};let l=(o.parseAs==="auto"?ge(c.headers.get("Content-Type")):o.parseAs)??"json",f;switch(l){case "arrayBuffer":case "blob":case "formData":case "json":case "text":f=await c[l]();break;case "stream":return o.responseStyle==="data"?c.body:{data:c.body,...A}}return l==="json"&&(o.responseValidator&&await o.responseValidator(f),o.responseTransformer&&(f=await o.responseTransformer(f))),o.responseStyle==="data"?f:{data:f,...A}}let m=await c.text(),E;try{E=JSON.parse(m);}catch{}let R=E??m,g=R;for(let l of i.error._fns)l&&(g=await l(R,c,y,o));if(g=g||{},o.throwOnError)throw g;return o.responseStyle==="data"?void 0:{error:g,...A}};return {buildUrl:Z,connect:n=>a({...n,method:"CONNECT"}),delete:n=>a({...n,method:"DELETE"}),get:n=>a({...n,method:"GET"}),getConfig:t,head:n=>a({...n,method:"HEAD"}),interceptors:i,options:n=>a({...n,method:"OPTIONS"}),patch:n=>a({...n,method:"PATCH"}),post:n=>a({...n,method:"POST"}),put:n=>a({...n,method:"PUT"}),request:a,setConfig:s,trace:n=>a({...n,method:"TRACE"})}};var h=te(w());var re=e=>(e.client??h).get({url:"/executions/{executionId}/activities",...e}),oe=e=>(e.client??h).post({url:"/executions/{executionId}/user-messages",...e,headers:{"Content-Type":"application/json",...e.headers}});var $e={};var Ve={};var qt=(e,r)=>(d.setConfig({headers:{"X-Asteroid-Agents-Api-Key":e}}),h.setConfig({headers:{"X-Asteroid-Agents-Api-Key":e}}),d.setConfig({baseUrl:r?.v1?.baseUrl||"https://odyssey.asteroid.ai/api/v1"}),h.setConfig({baseUrl:r?.v2?.baseUrl||"https://odyssey.asteroid.ai/agents/v2"}),{agentsV1Client:d,agentsV2Client:h}),Dt=async(e,r,t)=>{let s=await B({client:e.agentsV1Client,path:{id:r},body:t});if(s.error)throw new Error(s.error.error);return s.data.execution_id},He=async(e,r)=>{let t=await $({client:e.agentsV1Client,path:{id:r}});if(t.error)throw new Error(t.error.error);return t.data},Me=async(e,r)=>{let t=await V({client:e.agentsV1Client,path:{id:r}});if(t.error)throw new Error(t.error.error);if(t.data.error)throw new Error(t.data.error);return t.data.execution_result||{}},Ut=async(e,r,t=1e3,s=36e5)=>{for(var i=Math.floor(s/t);i>0;){let a=await He(e,r),n=a.status;if(n==="completed")return await Me(e,r);if(n==="failed"||n==="cancelled")throw new Error(`Execution ${r} ended with status: ${n}${a.reason?" - "+a.reason:""}`);await new Promise(o=>setTimeout(o,t)),i--;}throw new Error(`Execution ${r} timed out after ${s}ms`)},kt=async(e,r)=>{let t=await H({client:e.agentsV1Client,path:{id:r}});if(t.error)throw new Error(t.error.error);return t.data},zt=async(e,r,t)=>{let s=await K({client:e.agentsV1Client,path:{id:r},body:{files:t}});if(s.error)throw new Error(s.error.error);return s.data},vt=async(e,r)=>{let t=await M({client:e.agentsV1Client,query:r?{organization_id:r}:void 0});if(t.error)throw new Error(t.error.error);return t.data},he=async e=>{let r=await X({client:e.agentsV1Client});if(r.error){let t=typeof r.error=="object"&&"error"in r.error?r.error.error:typeof r.error=="string"?r.error:JSON.stringify(r.error);throw new Error(t||"Unknown error")}if(!r.data)throw new Error("Public key not found");return r.data},_t=async(e,r)=>{let t={...r};if(r.credentials&&r.credentials.length>0){let i=await he(e);t.credentials=r.credentials.map(a=>({...a,data:U(a.data,i)}));}let s=await F({client:e.agentsV1Client,body:t});if(s.error)throw new Error(s.error.error);return s.data},Gt=async(e,r)=>{let t=await W({client:e.agentsV1Client,path:{profile_id:r}});if(t.error)throw new Error(t.error.error);return t.data},jt=async(e,r,t)=>{let s={...t};if(t.credentials_to_add&&t.credentials_to_add.length>0){let a=await he(e);s.credentials_to_add=t.credentials_to_add.map(n=>({...n,data:U(n.data,a)}));}let i=await Q({client:e.agentsV1Client,path:{profile_id:r},body:s});if(i.error)throw new Error(i.error.error);return i.data},It=async(e,r)=>{let t=await N({client:e.agentsV1Client,path:{profile_id:r}});if(t.error)throw new Error(t.error.error);return t.data},Kt=async(e,r,t)=>{let s=await re({client:e.agentsV2Client,path:{executionId:r},query:{limit:t,order:"desc"}});if(s.error)throw console.error(s.error),new Error(s.error.error);return s.data},Bt=async(e,r,t)=>{let s=await oe({client:e.agentsV2Client,path:{executionId:r},body:{message:t}});if(s.error)throw console.error(s.error),new Error(s.error.error)};
2
- exports.AgentsV1SDK=J;exports.AgentsV1Types=$e;exports.AgentsV2SDK=ne;exports.AgentsV2Types=Ve;exports.AsteroidClient=qt;exports.addMessageToExecution=Bt;exports.createAgentProfile=_t;exports.deleteAgentProfile=It;exports.executeAgent=Dt;exports.getAgentProfile=Gt;exports.getAgentProfiles=vt;exports.getBrowserSessionRecording=kt;exports.getCredentialsPublicKey=he;exports.getExecutionResult=Me;exports.getExecutionStatus=He;exports.getLastNExecutionActivities=Kt;exports.updateAgentProfile=jt;exports.uploadExecutionFiles=zt;exports.waitForExecutionResult=Ut;
1
+ 'use strict';var T=require('node-forge');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var T__namespace=/*#__PURE__*/_interopNamespace(T);var me=Object.defineProperty;var se=(e,r)=>{for(var t in r)me(e,t,{get:r[t],enumerable:true});};function D(e,r){try{let s=T__namespace.pki.publicKeyFromPem(r).encrypt(e,"RSAES-PKCS1-V1_5");return T__namespace.util.encode64(s)}catch(t){throw console.error("Encryption failed:",t),new Error("Failed to encrypt: "+(t instanceof Error?t.message:"unknown error"))}}var L={};se(L,{createAgentProfile:()=>M,deleteAgentProfile:()=>N,executeAgent:()=>De,executeAgentStructured:()=>B,getAgentProfile:()=>W,getAgentProfiles:()=>F,getBrowserSessionRecording:()=>H,getCredentialsPublicKey:()=>X,getExecutionResult:()=>V,getExecutionStatus:()=>$,getOpenApi:()=>qe,healthCheck:()=>ke,updateAgentProfile:()=>Q,uploadExecutionFiles:()=>K});var ie=(e,r,t)=>{typeof t=="string"||t instanceof Blob?e.append(r,t):t instanceof Date?e.append(r,t.toISOString()):e.append(r,JSON.stringify(t));};var U={bodySerializer:e=>{let r=new FormData;return Object.entries(e).forEach(([t,s])=>{s!=null&&(Array.isArray(s)?s.forEach(i=>ie(r,t,i)):ie(r,t,s));}),r}},v={bodySerializer:e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t)};var ae=async(e,r)=>{let t=typeof r=="function"?await r(e):r;if(t)return e.scheme==="bearer"?`Bearer ${t}`:e.scheme==="basic"?`Basic ${btoa(t)}`:t};var Ee=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},Re=e=>{switch(e){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},Se=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},z=({allowReserved:e,explode:r,name:t,style:s,value:i})=>{if(!r){let o=(e?i:i.map(p=>encodeURIComponent(p))).join(Re(s));switch(s){case "label":return `.${o}`;case "matrix":return `;${t}=${o}`;case "simple":return o;default:return `${t}=${o}`}}let a=Ee(s),n=i.map(o=>s==="label"||s==="simple"?e?o:encodeURIComponent(o):S({allowReserved:e,name:t,value:o})).join(a);return s==="label"||s==="matrix"?a+n:n},S=({allowReserved:e,name:r,value:t})=>{if(t==null)return "";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${e?t:encodeURIComponent(t)}`},_=({allowReserved:e,explode:r,name:t,style:s,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${t}=${i.toISOString()}`;if(s!=="deepObject"&&!r){let p=[];Object.entries(i).forEach(([y,x])=>{p=[...p,y,e?x:encodeURIComponent(x)];});let u=p.join(",");switch(s){case "form":return `${t}=${u}`;case "label":return `.${u}`;case "matrix":return `;${t}=${u}`;default:return u}}let n=Se(s),o=Object.entries(i).map(([p,u])=>S({allowReserved:e,name:s==="deepObject"?`${t}[${p}]`:p,value:u})).join(n);return s==="label"||s==="matrix"?n+o:o};var Pe=/\{[^{}]+\}/g,be=({path:e,url:r})=>{let t=r,s=r.match(Pe);if(s)for(let i of s){let a=false,n=i.substring(1,i.length-1),o="simple";n.endsWith("*")&&(a=true,n=n.substring(0,n.length-1)),n.startsWith(".")?(n=n.substring(1),o="label"):n.startsWith(";")&&(n=n.substring(1),o="matrix");let p=e[n];if(p==null)continue;if(Array.isArray(p)){t=t.replace(i,z({explode:a,name:n,style:o,value:p}));continue}if(typeof p=="object"){t=t.replace(i,_({explode:a,name:n,style:o,value:p,valueOnly:true}));continue}if(o==="matrix"){t=t.replace(i,`;${S({name:n,value:p})}`);continue}let u=encodeURIComponent(o==="label"?`.${p}`:p);t=t.replace(i,u);}return t},pe=({allowReserved:e,array:r,object:t}={})=>i=>{let a=[];if(i&&typeof i=="object")for(let n in i){let o=i[n];if(o!=null)if(Array.isArray(o)){let p=z({allowReserved:e,explode:true,name:n,style:"form",value:o,...r});p&&a.push(p);}else if(typeof o=="object"){let p=_({allowReserved:e,explode:true,name:n,style:"deepObject",value:o,...t});p&&a.push(p);}else {let p=S({allowReserved:e,name:n,value:o});p&&a.push(p);}}return a.join("&")},ce=e=>{if(!e)return "stream";let r=e.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(t=>r.startsWith(t)))return "blob";if(r.startsWith("text/"))return "text"}},Ce=(e,r)=>r?!!(e.headers.has(r)||e.query?.[r]||e.headers.get("Cookie")?.includes(`${r}=`)):false,le=async({security:e,...r})=>{for(let t of e){if(Ce(r,t.name))continue;let s=await ae(t,r.auth);if(!s)continue;let i=t.name??"Authorization";switch(t.in){case "query":r.query||(r.query={}),r.query[i]=s;break;case "cookie":r.headers.append("Cookie",`${i}=${s}`);break;case "header":default:r.headers.set(i,s);break}}},G=e=>Oe({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:pe(e.querySerializer),url:e.url}),Oe=({baseUrl:e,path:r,query:t,querySerializer:s,url:i})=>{let a=i.startsWith("/")?i:`/${i}`,n=(e??"")+a;r&&(n=be({path:r,url:n}));let o=t?s(t):"";return o.startsWith("?")&&(o=o.substring(1)),o&&(n+=`?${o}`),n},j=(e,r)=>{let t={...e,...r};return t.baseUrl?.endsWith("/")&&(t.baseUrl=t.baseUrl.substring(0,t.baseUrl.length-1)),t.headers=q(e.headers,r.headers),t},q=(...e)=>{let r=new Headers;for(let t of e){if(!t||typeof t!="object")continue;let s=t instanceof Headers?t.entries():Object.entries(t);for(let[i,a]of s)if(a===null)r.delete(i);else if(Array.isArray(a))for(let n of a)r.append(i,n);else a!==void 0&&r.set(i,typeof a=="object"?JSON.stringify(a):a);}return r},P=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let t=this.getInterceptorIndex(r);return !!this._fns[t]}eject(r){let t=this.getInterceptorIndex(r);this._fns[t]&&(this._fns[t]=null);}update(r,t){let s=this.getInterceptorIndex(r);return this._fns[s]?(this._fns[s]=t,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},ue=()=>({error:new P,request:new P,response:new P}),we=pe({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),Te={"Content-Type":"application/json"},b=(e={})=>({...v,headers:Te,parseAs:"auto",querySerializer:we,...e});var I=(e={})=>{let r=j(b(),e),t=()=>({...r}),s=n=>(r=j(r,n),t()),i=ue(),a=async n=>{let o={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:q(r.headers,n.headers),serializedBody:void 0};o.security&&await le({...o,security:o.security}),o.requestValidator&&await o.requestValidator(o),o.body&&o.bodySerializer&&(o.serializedBody=o.bodySerializer(o.body)),(o.serializedBody===void 0||o.serializedBody==="")&&o.headers.delete("Content-Type");let p=G(o),u={redirect:"follow",...o,body:o.serializedBody},y=new Request(p,u);for(let l of i.request._fns)l&&(y=await l(y,o));let x=o.fetch,c=await x(y);for(let l of i.response._fns)l&&(c=await l(c,y,o));let A={request:y,response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return o.responseStyle==="data"?{}:{data:{},...A};let l=(o.parseAs==="auto"?ce(c.headers.get("Content-Type")):o.parseAs)??"json",f;switch(l){case "arrayBuffer":case "blob":case "formData":case "json":case "text":f=await c[l]();break;case "stream":return o.responseStyle==="data"?c.body:{data:c.body,...A}}return l==="json"&&(o.responseValidator&&await o.responseValidator(f),o.responseTransformer&&(f=await o.responseTransformer(f))),o.responseStyle==="data"?f:{data:f,...A}}let m=await c.text(),E;try{E=JSON.parse(m);}catch{}let R=E??m,g=R;for(let l of i.error._fns)l&&(g=await l(R,c,y,o));if(g=g||{},o.throwOnError)throw g;return o.responseStyle==="data"?void 0:{error:g,...A}};return {buildUrl:G,connect:n=>a({...n,method:"CONNECT"}),delete:n=>a({...n,method:"DELETE"}),get:n=>a({...n,method:"GET"}),getConfig:t,head:n=>a({...n,method:"HEAD"}),interceptors:i,options:n=>a({...n,method:"OPTIONS"}),patch:n=>a({...n,method:"PATCH"}),post:n=>a({...n,method:"POST"}),put:n=>a({...n,method:"PUT"}),request:a,setConfig:s,trace:n=>a({...n,method:"TRACE"})}};var d=I(b({baseUrl:"https://odyssey.asteroid.ai/api/v1"}));var qe=e=>(e?.client??d).get({url:"/openapi.yaml",...e}),K=e=>(e.client??d).post({...U,security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/files",...e,headers:{"Content-Type":null,...e.headers}}),ke=e=>(e?.client??d).get({url:"/health",...e}),De=e=>(e.client??d).post({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),B=e=>(e.client??d).post({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent/{id}/execute",...e,headers:{"Content-Type":"application/json",...e.headers}}),$=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/status",...e}),V=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/result",...e}),H=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/browser_session/recording",...e}),F=e=>(e?.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles",...e}),M=e=>(e.client??d).post({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles",...e,headers:{"Content-Type":"application/json",...e.headers}}),N=e=>(e.client??d).delete({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles/{profile_id}",...e}),W=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles/{profile_id}",...e}),Q=e=>(e.client??d).patch({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles/{profile_id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),X=e=>(e?.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/credentials/public_key",...e});var ne={};se(ne,{activitiesGet:()=>re,userMessagesAdd:()=>oe});var de={bodySerializer:e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t)};var ye=async(e,r)=>{let t=typeof r=="function"?await r(e):r;if(t)return e.scheme==="bearer"?`Bearer ${t}`:e.scheme==="basic"?`Basic ${btoa(t)}`:t};var Ue=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},ve=e=>{switch(e){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},ze=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},J=({allowReserved:e,explode:r,name:t,style:s,value:i})=>{if(!r){let o=(e?i:i.map(p=>encodeURIComponent(p))).join(ve(s));switch(s){case "label":return `.${o}`;case "matrix":return `;${t}=${o}`;case "simple":return o;default:return `${t}=${o}`}}let a=Ue(s),n=i.map(o=>s==="label"||s==="simple"?e?o:encodeURIComponent(o):C({allowReserved:e,name:t,value:o})).join(a);return s==="label"||s==="matrix"?a+n:n},C=({allowReserved:e,name:r,value:t})=>{if(t==null)return "";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${e?t:encodeURIComponent(t)}`},Y=({allowReserved:e,explode:r,name:t,style:s,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${t}=${i.toISOString()}`;if(s!=="deepObject"&&!r){let p=[];Object.entries(i).forEach(([y,x])=>{p=[...p,y,e?x:encodeURIComponent(x)];});let u=p.join(",");switch(s){case "form":return `${t}=${u}`;case "label":return `.${u}`;case "matrix":return `;${t}=${u}`;default:return u}}let n=ze(s),o=Object.entries(i).map(([p,u])=>C({allowReserved:e,name:s==="deepObject"?`${t}[${p}]`:p,value:u})).join(n);return s==="label"||s==="matrix"?n+o:o};var _e=/\{[^{}]+\}/g,Ge=({path:e,url:r})=>{let t=r,s=r.match(_e);if(s)for(let i of s){let a=false,n=i.substring(1,i.length-1),o="simple";n.endsWith("*")&&(a=true,n=n.substring(0,n.length-1)),n.startsWith(".")?(n=n.substring(1),o="label"):n.startsWith(";")&&(n=n.substring(1),o="matrix");let p=e[n];if(p==null)continue;if(Array.isArray(p)){t=t.replace(i,J({explode:a,name:n,style:o,value:p}));continue}if(typeof p=="object"){t=t.replace(i,Y({explode:a,name:n,style:o,value:p,valueOnly:true}));continue}if(o==="matrix"){t=t.replace(i,`;${C({name:n,value:p})}`);continue}let u=encodeURIComponent(o==="label"?`.${p}`:p);t=t.replace(i,u);}return t},fe=({allowReserved:e,array:r,object:t}={})=>i=>{let a=[];if(i&&typeof i=="object")for(let n in i){let o=i[n];if(o!=null)if(Array.isArray(o)){let p=J({allowReserved:e,explode:true,name:n,style:"form",value:o,...r});p&&a.push(p);}else if(typeof o=="object"){let p=Y({allowReserved:e,explode:true,name:n,style:"deepObject",value:o,...t});p&&a.push(p);}else {let p=C({allowReserved:e,name:n,value:o});p&&a.push(p);}}return a.join("&")},ge=e=>{if(!e)return "stream";let r=e.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(t=>r.startsWith(t)))return "blob";if(r.startsWith("text/"))return "text"}},je=(e,r)=>r?!!(e.headers.has(r)||e.query?.[r]||e.headers.get("Cookie")?.includes(`${r}=`)):false,xe=async({security:e,...r})=>{for(let t of e){if(je(r,t.name))continue;let s=await ye(t,r.auth);if(!s)continue;let i=t.name??"Authorization";switch(t.in){case "query":r.query||(r.query={}),r.query[i]=s;break;case "cookie":r.headers.append("Cookie",`${i}=${s}`);break;case "header":default:r.headers.set(i,s);break}}},Z=e=>Ie({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:fe(e.querySerializer),url:e.url}),Ie=({baseUrl:e,path:r,query:t,querySerializer:s,url:i})=>{let a=i.startsWith("/")?i:`/${i}`,n=(e??"")+a;r&&(n=Ge({path:r,url:n}));let o=t?s(t):"";return o.startsWith("?")&&(o=o.substring(1)),o&&(n+=`?${o}`),n},ee=(e,r)=>{let t={...e,...r};return t.baseUrl?.endsWith("/")&&(t.baseUrl=t.baseUrl.substring(0,t.baseUrl.length-1)),t.headers=k(e.headers,r.headers),t},k=(...e)=>{let r=new Headers;for(let t of e){if(!t||typeof t!="object")continue;let s=t instanceof Headers?t.entries():Object.entries(t);for(let[i,a]of s)if(a===null)r.delete(i);else if(Array.isArray(a))for(let n of a)r.append(i,n);else a!==void 0&&r.set(i,typeof a=="object"?JSON.stringify(a):a);}return r},O=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let t=this.getInterceptorIndex(r);return !!this._fns[t]}eject(r){let t=this.getInterceptorIndex(r);this._fns[t]&&(this._fns[t]=null);}update(r,t){let s=this.getInterceptorIndex(r);return this._fns[s]?(this._fns[s]=t,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},Ae=()=>({error:new O,request:new O,response:new O}),Ke=fe({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),Be={"Content-Type":"application/json"},w=(e={})=>({...de,headers:Be,parseAs:"auto",querySerializer:Ke,...e});var te=(e={})=>{let r=ee(w(),e),t=()=>({...r}),s=n=>(r=ee(r,n),t()),i=Ae(),a=async n=>{let o={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:k(r.headers,n.headers),serializedBody:void 0};o.security&&await xe({...o,security:o.security}),o.requestValidator&&await o.requestValidator(o),o.body&&o.bodySerializer&&(o.serializedBody=o.bodySerializer(o.body)),(o.serializedBody===void 0||o.serializedBody==="")&&o.headers.delete("Content-Type");let p=Z(o),u={redirect:"follow",...o,body:o.serializedBody},y=new Request(p,u);for(let l of i.request._fns)l&&(y=await l(y,o));let x=o.fetch,c=await x(y);for(let l of i.response._fns)l&&(c=await l(c,y,o));let A={request:y,response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return o.responseStyle==="data"?{}:{data:{},...A};let l=(o.parseAs==="auto"?ge(c.headers.get("Content-Type")):o.parseAs)??"json",f;switch(l){case "arrayBuffer":case "blob":case "formData":case "json":case "text":f=await c[l]();break;case "stream":return o.responseStyle==="data"?c.body:{data:c.body,...A}}return l==="json"&&(o.responseValidator&&await o.responseValidator(f),o.responseTransformer&&(f=await o.responseTransformer(f))),o.responseStyle==="data"?f:{data:f,...A}}let m=await c.text(),E;try{E=JSON.parse(m);}catch{}let R=E??m,g=R;for(let l of i.error._fns)l&&(g=await l(R,c,y,o));if(g=g||{},o.throwOnError)throw g;return o.responseStyle==="data"?void 0:{error:g,...A}};return {buildUrl:Z,connect:n=>a({...n,method:"CONNECT"}),delete:n=>a({...n,method:"DELETE"}),get:n=>a({...n,method:"GET"}),getConfig:t,head:n=>a({...n,method:"HEAD"}),interceptors:i,options:n=>a({...n,method:"OPTIONS"}),patch:n=>a({...n,method:"PATCH"}),post:n=>a({...n,method:"POST"}),put:n=>a({...n,method:"PUT"}),request:a,setConfig:s,trace:n=>a({...n,method:"TRACE"})}};var h=te(w());var re=e=>(e.client??h).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/executions/{executionId}/activities",...e}),oe=e=>(e.client??h).post({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/executions/{executionId}/user-messages",...e,headers:{"Content-Type":"application/json",...e.headers}});var $e={};var Ve={};var qt=(e,r)=>(d.setConfig({headers:{"X-Asteroid-Agents-Api-Key":e}}),h.setConfig({headers:{"X-Asteroid-Agents-Api-Key":e}}),d.setConfig({baseUrl:r?.v1?.baseUrl||"https://odyssey.asteroid.ai/api/v1"}),h.setConfig({baseUrl:r?.v2?.baseUrl||"https://odyssey.asteroid.ai/agents/v2"}),{agentsV1Client:d,agentsV2Client:h}),kt=async(e,r,t)=>{let s=await B({client:e.agentsV1Client,path:{id:r},body:t});if(s.error)throw new Error(s.error.error);return s.data.execution_id},He=async(e,r)=>{let t=await $({client:e.agentsV1Client,path:{id:r}});if(t.error)throw new Error(t.error.error);return t.data},Fe=async(e,r)=>{let t=await V({client:e.agentsV1Client,path:{id:r}});if(t.error)throw new Error(t.error.error);if(t.data.error)throw new Error(t.data.error);return t.data.execution_result||{}},Dt=async(e,r,t=1e3,s=36e5)=>{for(var i=Math.floor(s/t);i>0;){let a=await He(e,r),n=a.status;if(n==="completed")return await Fe(e,r);if(n==="failed"||n==="cancelled")throw new Error(`Execution ${r} ended with status: ${n}${a.reason?" - "+a.reason:""}`);await new Promise(o=>setTimeout(o,t)),i--;}throw new Error(`Execution ${r} timed out after ${s}ms`)},Ut=async(e,r)=>{let t=await H({client:e.agentsV1Client,path:{id:r}});if(t.error)throw new Error(t.error.error);return t.data},vt=async(e,r,t)=>{let s=await K({client:e.agentsV1Client,path:{id:r},body:{files:t}});if(s.error)throw new Error(s.error.error);return s.data},zt=async(e,r)=>{let t=await F({client:e.agentsV1Client,query:r?{organization_id:r}:void 0});if(t.error)throw new Error(t.error.error);return t.data},he=async e=>{let r=await X({client:e.agentsV1Client});if(r.error){let t=typeof r.error=="object"&&"error"in r.error?r.error.error:typeof r.error=="string"?r.error:JSON.stringify(r.error);throw new Error(t||"Unknown error")}if(!r.data)throw new Error("Public key not found");return r.data},_t=async(e,r)=>{let t={...r};if(r.credentials&&r.credentials.length>0){let i=await he(e);t.credentials=r.credentials.map(a=>({...a,data:D(a.data,i)}));}let s=await M({client:e.agentsV1Client,body:t});if(s.error)throw new Error(s.error.error);return s.data},Gt=async(e,r)=>{let t=await W({client:e.agentsV1Client,path:{profile_id:r}});if(t.error)throw new Error(t.error.error);return t.data},jt=async(e,r,t)=>{let s={...t};if(t.credentials_to_add&&t.credentials_to_add.length>0){let a=await he(e);s.credentials_to_add=t.credentials_to_add.map(n=>({...n,data:D(n.data,a)}));}let i=await Q({client:e.agentsV1Client,path:{profile_id:r},body:s});if(i.error)throw new Error(i.error.error);return i.data},It=async(e,r)=>{let t=await N({client:e.agentsV1Client,path:{profile_id:r}});if(t.error)throw new Error(t.error.error);return t.data},Kt=async(e,r,t)=>{let s=await re({client:e.agentsV2Client,path:{executionId:r},query:{limit:t,order:"desc"}});if(s.error)throw console.error(s.error),new Error(s.error.error);return s.data},Bt=async(e,r,t)=>{let s=await oe({client:e.agentsV2Client,path:{executionId:r},body:{message:t}});if(s.error)throw console.error(s.error),new Error(s.error.error)};
2
+ exports.AgentsV1SDK=L;exports.AgentsV1Types=$e;exports.AgentsV2SDK=ne;exports.AgentsV2Types=Ve;exports.AsteroidClient=qt;exports.addMessageToExecution=Bt;exports.createAgentProfile=_t;exports.deleteAgentProfile=It;exports.executeAgent=kt;exports.getAgentProfile=Gt;exports.getAgentProfiles=zt;exports.getBrowserSessionRecording=Ut;exports.getCredentialsPublicKey=he;exports.getExecutionResult=Fe;exports.getExecutionStatus=He;exports.getLastNExecutionActivities=Kt;exports.updateAgentProfile=jt;exports.uploadExecutionFiles=vt;exports.waitForExecutionResult=Dt;
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import*as T from'node-forge';var me=Object.defineProperty;var se=(e,r)=>{for(var t in r)me(e,t,{get:r[t],enumerable:true});};function U(e,r){try{let s=T.pki.publicKeyFromPem(r).encrypt(e,"RSAES-PKCS1-V1_5");return T.util.encode64(s)}catch(t){throw console.error("Encryption failed:",t),new Error("Failed to encrypt: "+(t instanceof Error?t.message:"unknown error"))}}var J={};se(J,{createAgentProfile:()=>F,deleteAgentProfile:()=>N,executeAgent:()=>Ue,executeAgentStructured:()=>B,getAgentProfile:()=>W,getAgentProfiles:()=>M,getBrowserSessionRecording:()=>H,getCredentialsPublicKey:()=>X,getExecutionResult:()=>V,getExecutionStatus:()=>$,getOpenApi:()=>qe,healthCheck:()=>De,updateAgentProfile:()=>Q,uploadExecutionFiles:()=>K});var ie=(e,r,t)=>{typeof t=="string"||t instanceof Blob?e.append(r,t):t instanceof Date?e.append(r,t.toISOString()):e.append(r,JSON.stringify(t));};var k={bodySerializer:e=>{let r=new FormData;return Object.entries(e).forEach(([t,s])=>{s!=null&&(Array.isArray(s)?s.forEach(i=>ie(r,t,i)):ie(r,t,s));}),r}},z={bodySerializer:e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t)};var ae=async(e,r)=>{let t=typeof r=="function"?await r(e):r;if(t)return e.scheme==="bearer"?`Bearer ${t}`:e.scheme==="basic"?`Basic ${btoa(t)}`:t};var Ee=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},Re=e=>{switch(e){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},Se=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},v=({allowReserved:e,explode:r,name:t,style:s,value:i})=>{if(!r){let o=(e?i:i.map(p=>encodeURIComponent(p))).join(Re(s));switch(s){case "label":return `.${o}`;case "matrix":return `;${t}=${o}`;case "simple":return o;default:return `${t}=${o}`}}let a=Ee(s),n=i.map(o=>s==="label"||s==="simple"?e?o:encodeURIComponent(o):S({allowReserved:e,name:t,value:o})).join(a);return s==="label"||s==="matrix"?a+n:n},S=({allowReserved:e,name:r,value:t})=>{if(t==null)return "";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${e?t:encodeURIComponent(t)}`},_=({allowReserved:e,explode:r,name:t,style:s,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${t}=${i.toISOString()}`;if(s!=="deepObject"&&!r){let p=[];Object.entries(i).forEach(([y,x])=>{p=[...p,y,e?x:encodeURIComponent(x)];});let u=p.join(",");switch(s){case "form":return `${t}=${u}`;case "label":return `.${u}`;case "matrix":return `;${t}=${u}`;default:return u}}let n=Se(s),o=Object.entries(i).map(([p,u])=>S({allowReserved:e,name:s==="deepObject"?`${t}[${p}]`:p,value:u})).join(n);return s==="label"||s==="matrix"?n+o:o};var be=/\{[^{}]+\}/g,Pe=({path:e,url:r})=>{let t=r,s=r.match(be);if(s)for(let i of s){let a=false,n=i.substring(1,i.length-1),o="simple";n.endsWith("*")&&(a=true,n=n.substring(0,n.length-1)),n.startsWith(".")?(n=n.substring(1),o="label"):n.startsWith(";")&&(n=n.substring(1),o="matrix");let p=e[n];if(p==null)continue;if(Array.isArray(p)){t=t.replace(i,v({explode:a,name:n,style:o,value:p}));continue}if(typeof p=="object"){t=t.replace(i,_({explode:a,name:n,style:o,value:p,valueOnly:true}));continue}if(o==="matrix"){t=t.replace(i,`;${S({name:n,value:p})}`);continue}let u=encodeURIComponent(o==="label"?`.${p}`:p);t=t.replace(i,u);}return t},pe=({allowReserved:e,array:r,object:t}={})=>i=>{let a=[];if(i&&typeof i=="object")for(let n in i){let o=i[n];if(o!=null)if(Array.isArray(o)){let p=v({allowReserved:e,explode:true,name:n,style:"form",value:o,...r});p&&a.push(p);}else if(typeof o=="object"){let p=_({allowReserved:e,explode:true,name:n,style:"deepObject",value:o,...t});p&&a.push(p);}else {let p=S({allowReserved:e,name:n,value:o});p&&a.push(p);}}return a.join("&")},ce=e=>{if(!e)return "stream";let r=e.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(t=>r.startsWith(t)))return "blob";if(r.startsWith("text/"))return "text"}},Oe=(e,r)=>r?!!(e.headers.has(r)||e.query?.[r]||e.headers.get("Cookie")?.includes(`${r}=`)):false,le=async({security:e,...r})=>{for(let t of e){if(Oe(r,t.name))continue;let s=await ae(t,r.auth);if(!s)continue;let i=t.name??"Authorization";switch(t.in){case "query":r.query||(r.query={}),r.query[i]=s;break;case "cookie":r.headers.append("Cookie",`${i}=${s}`);break;case "header":default:r.headers.set(i,s);break}}},G=e=>Ce({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:pe(e.querySerializer),url:e.url}),Ce=({baseUrl:e,path:r,query:t,querySerializer:s,url:i})=>{let a=i.startsWith("/")?i:`/${i}`,n=(e??"")+a;r&&(n=Pe({path:r,url:n}));let o=t?s(t):"";return o.startsWith("?")&&(o=o.substring(1)),o&&(n+=`?${o}`),n},j=(e,r)=>{let t={...e,...r};return t.baseUrl?.endsWith("/")&&(t.baseUrl=t.baseUrl.substring(0,t.baseUrl.length-1)),t.headers=q(e.headers,r.headers),t},q=(...e)=>{let r=new Headers;for(let t of e){if(!t||typeof t!="object")continue;let s=t instanceof Headers?t.entries():Object.entries(t);for(let[i,a]of s)if(a===null)r.delete(i);else if(Array.isArray(a))for(let n of a)r.append(i,n);else a!==void 0&&r.set(i,typeof a=="object"?JSON.stringify(a):a);}return r},b=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let t=this.getInterceptorIndex(r);return !!this._fns[t]}eject(r){let t=this.getInterceptorIndex(r);this._fns[t]&&(this._fns[t]=null);}update(r,t){let s=this.getInterceptorIndex(r);return this._fns[s]?(this._fns[s]=t,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},ue=()=>({error:new b,request:new b,response:new b}),we=pe({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),Te={"Content-Type":"application/json"},P=(e={})=>({...z,headers:Te,parseAs:"auto",querySerializer:we,...e});var I=(e={})=>{let r=j(P(),e),t=()=>({...r}),s=n=>(r=j(r,n),t()),i=ue(),a=async n=>{let o={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:q(r.headers,n.headers),serializedBody:void 0};o.security&&await le({...o,security:o.security}),o.requestValidator&&await o.requestValidator(o),o.body&&o.bodySerializer&&(o.serializedBody=o.bodySerializer(o.body)),(o.serializedBody===void 0||o.serializedBody==="")&&o.headers.delete("Content-Type");let p=G(o),u={redirect:"follow",...o,body:o.serializedBody},y=new Request(p,u);for(let l of i.request._fns)l&&(y=await l(y,o));let x=o.fetch,c=await x(y);for(let l of i.response._fns)l&&(c=await l(c,y,o));let A={request:y,response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return o.responseStyle==="data"?{}:{data:{},...A};let l=(o.parseAs==="auto"?ce(c.headers.get("Content-Type")):o.parseAs)??"json",f;switch(l){case "arrayBuffer":case "blob":case "formData":case "json":case "text":f=await c[l]();break;case "stream":return o.responseStyle==="data"?c.body:{data:c.body,...A}}return l==="json"&&(o.responseValidator&&await o.responseValidator(f),o.responseTransformer&&(f=await o.responseTransformer(f))),o.responseStyle==="data"?f:{data:f,...A}}let m=await c.text(),E;try{E=JSON.parse(m);}catch{}let R=E??m,g=R;for(let l of i.error._fns)l&&(g=await l(R,c,y,o));if(g=g||{},o.throwOnError)throw g;return o.responseStyle==="data"?void 0:{error:g,...A}};return {buildUrl:G,connect:n=>a({...n,method:"CONNECT"}),delete:n=>a({...n,method:"DELETE"}),get:n=>a({...n,method:"GET"}),getConfig:t,head:n=>a({...n,method:"HEAD"}),interceptors:i,options:n=>a({...n,method:"OPTIONS"}),patch:n=>a({...n,method:"PATCH"}),post:n=>a({...n,method:"POST"}),put:n=>a({...n,method:"PUT"}),request:a,setConfig:s,trace:n=>a({...n,method:"TRACE"})}};var d=I(P({baseUrl:"https://odyssey.asteroid.ai/api/v1"}));var qe=e=>(e?.client??d).get({url:"/openapi.yaml",...e}),K=e=>(e.client??d).post({...k,security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/files",...e,headers:{"Content-Type":null,...e.headers}}),De=e=>(e?.client??d).get({url:"/health",...e}),Ue=e=>(e.client??d).post({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),B=e=>(e.client??d).post({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent/{id}/execute",...e,headers:{"Content-Type":"application/json",...e.headers}}),$=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/status",...e}),V=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/result",...e}),H=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/browser_session/recording",...e}),M=e=>(e?.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles",...e}),F=e=>(e.client??d).post({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles",...e,headers:{"Content-Type":"application/json",...e.headers}}),N=e=>(e.client??d).delete({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles/{profile_id}",...e}),W=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles/{profile_id}",...e}),Q=e=>(e.client??d).patch({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles/{profile_id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),X=e=>(e?.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/credentials/public_key",...e});var ne={};se(ne,{activitiesGet:()=>re,userMessagesAdd:()=>oe});var de={bodySerializer:e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t)};var ye=async(e,r)=>{let t=typeof r=="function"?await r(e):r;if(t)return e.scheme==="bearer"?`Bearer ${t}`:e.scheme==="basic"?`Basic ${btoa(t)}`:t};var ke=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},ze=e=>{switch(e){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},ve=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},L=({allowReserved:e,explode:r,name:t,style:s,value:i})=>{if(!r){let o=(e?i:i.map(p=>encodeURIComponent(p))).join(ze(s));switch(s){case "label":return `.${o}`;case "matrix":return `;${t}=${o}`;case "simple":return o;default:return `${t}=${o}`}}let a=ke(s),n=i.map(o=>s==="label"||s==="simple"?e?o:encodeURIComponent(o):O({allowReserved:e,name:t,value:o})).join(a);return s==="label"||s==="matrix"?a+n:n},O=({allowReserved:e,name:r,value:t})=>{if(t==null)return "";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${e?t:encodeURIComponent(t)}`},Y=({allowReserved:e,explode:r,name:t,style:s,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${t}=${i.toISOString()}`;if(s!=="deepObject"&&!r){let p=[];Object.entries(i).forEach(([y,x])=>{p=[...p,y,e?x:encodeURIComponent(x)];});let u=p.join(",");switch(s){case "form":return `${t}=${u}`;case "label":return `.${u}`;case "matrix":return `;${t}=${u}`;default:return u}}let n=ve(s),o=Object.entries(i).map(([p,u])=>O({allowReserved:e,name:s==="deepObject"?`${t}[${p}]`:p,value:u})).join(n);return s==="label"||s==="matrix"?n+o:o};var _e=/\{[^{}]+\}/g,Ge=({path:e,url:r})=>{let t=r,s=r.match(_e);if(s)for(let i of s){let a=false,n=i.substring(1,i.length-1),o="simple";n.endsWith("*")&&(a=true,n=n.substring(0,n.length-1)),n.startsWith(".")?(n=n.substring(1),o="label"):n.startsWith(";")&&(n=n.substring(1),o="matrix");let p=e[n];if(p==null)continue;if(Array.isArray(p)){t=t.replace(i,L({explode:a,name:n,style:o,value:p}));continue}if(typeof p=="object"){t=t.replace(i,Y({explode:a,name:n,style:o,value:p,valueOnly:true}));continue}if(o==="matrix"){t=t.replace(i,`;${O({name:n,value:p})}`);continue}let u=encodeURIComponent(o==="label"?`.${p}`:p);t=t.replace(i,u);}return t},fe=({allowReserved:e,array:r,object:t}={})=>i=>{let a=[];if(i&&typeof i=="object")for(let n in i){let o=i[n];if(o!=null)if(Array.isArray(o)){let p=L({allowReserved:e,explode:true,name:n,style:"form",value:o,...r});p&&a.push(p);}else if(typeof o=="object"){let p=Y({allowReserved:e,explode:true,name:n,style:"deepObject",value:o,...t});p&&a.push(p);}else {let p=O({allowReserved:e,name:n,value:o});p&&a.push(p);}}return a.join("&")},ge=e=>{if(!e)return "stream";let r=e.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(t=>r.startsWith(t)))return "blob";if(r.startsWith("text/"))return "text"}},je=(e,r)=>r?!!(e.headers.has(r)||e.query?.[r]||e.headers.get("Cookie")?.includes(`${r}=`)):false,xe=async({security:e,...r})=>{for(let t of e){if(je(r,t.name))continue;let s=await ye(t,r.auth);if(!s)continue;let i=t.name??"Authorization";switch(t.in){case "query":r.query||(r.query={}),r.query[i]=s;break;case "cookie":r.headers.append("Cookie",`${i}=${s}`);break;case "header":default:r.headers.set(i,s);break}}},Z=e=>Ie({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:fe(e.querySerializer),url:e.url}),Ie=({baseUrl:e,path:r,query:t,querySerializer:s,url:i})=>{let a=i.startsWith("/")?i:`/${i}`,n=(e??"")+a;r&&(n=Ge({path:r,url:n}));let o=t?s(t):"";return o.startsWith("?")&&(o=o.substring(1)),o&&(n+=`?${o}`),n},ee=(e,r)=>{let t={...e,...r};return t.baseUrl?.endsWith("/")&&(t.baseUrl=t.baseUrl.substring(0,t.baseUrl.length-1)),t.headers=D(e.headers,r.headers),t},D=(...e)=>{let r=new Headers;for(let t of e){if(!t||typeof t!="object")continue;let s=t instanceof Headers?t.entries():Object.entries(t);for(let[i,a]of s)if(a===null)r.delete(i);else if(Array.isArray(a))for(let n of a)r.append(i,n);else a!==void 0&&r.set(i,typeof a=="object"?JSON.stringify(a):a);}return r},C=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let t=this.getInterceptorIndex(r);return !!this._fns[t]}eject(r){let t=this.getInterceptorIndex(r);this._fns[t]&&(this._fns[t]=null);}update(r,t){let s=this.getInterceptorIndex(r);return this._fns[s]?(this._fns[s]=t,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},Ae=()=>({error:new C,request:new C,response:new C}),Ke=fe({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),Be={"Content-Type":"application/json"},w=(e={})=>({...de,headers:Be,parseAs:"auto",querySerializer:Ke,...e});var te=(e={})=>{let r=ee(w(),e),t=()=>({...r}),s=n=>(r=ee(r,n),t()),i=Ae(),a=async n=>{let o={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:D(r.headers,n.headers),serializedBody:void 0};o.security&&await xe({...o,security:o.security}),o.requestValidator&&await o.requestValidator(o),o.body&&o.bodySerializer&&(o.serializedBody=o.bodySerializer(o.body)),(o.serializedBody===void 0||o.serializedBody==="")&&o.headers.delete("Content-Type");let p=Z(o),u={redirect:"follow",...o,body:o.serializedBody},y=new Request(p,u);for(let l of i.request._fns)l&&(y=await l(y,o));let x=o.fetch,c=await x(y);for(let l of i.response._fns)l&&(c=await l(c,y,o));let A={request:y,response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return o.responseStyle==="data"?{}:{data:{},...A};let l=(o.parseAs==="auto"?ge(c.headers.get("Content-Type")):o.parseAs)??"json",f;switch(l){case "arrayBuffer":case "blob":case "formData":case "json":case "text":f=await c[l]();break;case "stream":return o.responseStyle==="data"?c.body:{data:c.body,...A}}return l==="json"&&(o.responseValidator&&await o.responseValidator(f),o.responseTransformer&&(f=await o.responseTransformer(f))),o.responseStyle==="data"?f:{data:f,...A}}let m=await c.text(),E;try{E=JSON.parse(m);}catch{}let R=E??m,g=R;for(let l of i.error._fns)l&&(g=await l(R,c,y,o));if(g=g||{},o.throwOnError)throw g;return o.responseStyle==="data"?void 0:{error:g,...A}};return {buildUrl:Z,connect:n=>a({...n,method:"CONNECT"}),delete:n=>a({...n,method:"DELETE"}),get:n=>a({...n,method:"GET"}),getConfig:t,head:n=>a({...n,method:"HEAD"}),interceptors:i,options:n=>a({...n,method:"OPTIONS"}),patch:n=>a({...n,method:"PATCH"}),post:n=>a({...n,method:"POST"}),put:n=>a({...n,method:"PUT"}),request:a,setConfig:s,trace:n=>a({...n,method:"TRACE"})}};var h=te(w());var re=e=>(e.client??h).get({url:"/executions/{executionId}/activities",...e}),oe=e=>(e.client??h).post({url:"/executions/{executionId}/user-messages",...e,headers:{"Content-Type":"application/json",...e.headers}});var $e={};var Ve={};var qt=(e,r)=>(d.setConfig({headers:{"X-Asteroid-Agents-Api-Key":e}}),h.setConfig({headers:{"X-Asteroid-Agents-Api-Key":e}}),d.setConfig({baseUrl:r?.v1?.baseUrl||"https://odyssey.asteroid.ai/api/v1"}),h.setConfig({baseUrl:r?.v2?.baseUrl||"https://odyssey.asteroid.ai/agents/v2"}),{agentsV1Client:d,agentsV2Client:h}),Dt=async(e,r,t)=>{let s=await B({client:e.agentsV1Client,path:{id:r},body:t});if(s.error)throw new Error(s.error.error);return s.data.execution_id},He=async(e,r)=>{let t=await $({client:e.agentsV1Client,path:{id:r}});if(t.error)throw new Error(t.error.error);return t.data},Me=async(e,r)=>{let t=await V({client:e.agentsV1Client,path:{id:r}});if(t.error)throw new Error(t.error.error);if(t.data.error)throw new Error(t.data.error);return t.data.execution_result||{}},Ut=async(e,r,t=1e3,s=36e5)=>{for(var i=Math.floor(s/t);i>0;){let a=await He(e,r),n=a.status;if(n==="completed")return await Me(e,r);if(n==="failed"||n==="cancelled")throw new Error(`Execution ${r} ended with status: ${n}${a.reason?" - "+a.reason:""}`);await new Promise(o=>setTimeout(o,t)),i--;}throw new Error(`Execution ${r} timed out after ${s}ms`)},kt=async(e,r)=>{let t=await H({client:e.agentsV1Client,path:{id:r}});if(t.error)throw new Error(t.error.error);return t.data},zt=async(e,r,t)=>{let s=await K({client:e.agentsV1Client,path:{id:r},body:{files:t}});if(s.error)throw new Error(s.error.error);return s.data},vt=async(e,r)=>{let t=await M({client:e.agentsV1Client,query:r?{organization_id:r}:void 0});if(t.error)throw new Error(t.error.error);return t.data},he=async e=>{let r=await X({client:e.agentsV1Client});if(r.error){let t=typeof r.error=="object"&&"error"in r.error?r.error.error:typeof r.error=="string"?r.error:JSON.stringify(r.error);throw new Error(t||"Unknown error")}if(!r.data)throw new Error("Public key not found");return r.data},_t=async(e,r)=>{let t={...r};if(r.credentials&&r.credentials.length>0){let i=await he(e);t.credentials=r.credentials.map(a=>({...a,data:U(a.data,i)}));}let s=await F({client:e.agentsV1Client,body:t});if(s.error)throw new Error(s.error.error);return s.data},Gt=async(e,r)=>{let t=await W({client:e.agentsV1Client,path:{profile_id:r}});if(t.error)throw new Error(t.error.error);return t.data},jt=async(e,r,t)=>{let s={...t};if(t.credentials_to_add&&t.credentials_to_add.length>0){let a=await he(e);s.credentials_to_add=t.credentials_to_add.map(n=>({...n,data:U(n.data,a)}));}let i=await Q({client:e.agentsV1Client,path:{profile_id:r},body:s});if(i.error)throw new Error(i.error.error);return i.data},It=async(e,r)=>{let t=await N({client:e.agentsV1Client,path:{profile_id:r}});if(t.error)throw new Error(t.error.error);return t.data},Kt=async(e,r,t)=>{let s=await re({client:e.agentsV2Client,path:{executionId:r},query:{limit:t,order:"desc"}});if(s.error)throw console.error(s.error),new Error(s.error.error);return s.data},Bt=async(e,r,t)=>{let s=await oe({client:e.agentsV2Client,path:{executionId:r},body:{message:t}});if(s.error)throw console.error(s.error),new Error(s.error.error)};
2
- export{J as AgentsV1SDK,$e as AgentsV1Types,ne as AgentsV2SDK,Ve as AgentsV2Types,qt as AsteroidClient,Bt as addMessageToExecution,_t as createAgentProfile,It as deleteAgentProfile,Dt as executeAgent,Gt as getAgentProfile,vt as getAgentProfiles,kt as getBrowserSessionRecording,he as getCredentialsPublicKey,Me as getExecutionResult,He as getExecutionStatus,Kt as getLastNExecutionActivities,jt as updateAgentProfile,zt as uploadExecutionFiles,Ut as waitForExecutionResult};
1
+ import*as T from'node-forge';var me=Object.defineProperty;var se=(e,r)=>{for(var t in r)me(e,t,{get:r[t],enumerable:true});};function D(e,r){try{let s=T.pki.publicKeyFromPem(r).encrypt(e,"RSAES-PKCS1-V1_5");return T.util.encode64(s)}catch(t){throw console.error("Encryption failed:",t),new Error("Failed to encrypt: "+(t instanceof Error?t.message:"unknown error"))}}var L={};se(L,{createAgentProfile:()=>M,deleteAgentProfile:()=>N,executeAgent:()=>De,executeAgentStructured:()=>B,getAgentProfile:()=>W,getAgentProfiles:()=>F,getBrowserSessionRecording:()=>H,getCredentialsPublicKey:()=>X,getExecutionResult:()=>V,getExecutionStatus:()=>$,getOpenApi:()=>qe,healthCheck:()=>ke,updateAgentProfile:()=>Q,uploadExecutionFiles:()=>K});var ie=(e,r,t)=>{typeof t=="string"||t instanceof Blob?e.append(r,t):t instanceof Date?e.append(r,t.toISOString()):e.append(r,JSON.stringify(t));};var U={bodySerializer:e=>{let r=new FormData;return Object.entries(e).forEach(([t,s])=>{s!=null&&(Array.isArray(s)?s.forEach(i=>ie(r,t,i)):ie(r,t,s));}),r}},v={bodySerializer:e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t)};var ae=async(e,r)=>{let t=typeof r=="function"?await r(e):r;if(t)return e.scheme==="bearer"?`Bearer ${t}`:e.scheme==="basic"?`Basic ${btoa(t)}`:t};var Ee=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},Re=e=>{switch(e){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},Se=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},z=({allowReserved:e,explode:r,name:t,style:s,value:i})=>{if(!r){let o=(e?i:i.map(p=>encodeURIComponent(p))).join(Re(s));switch(s){case "label":return `.${o}`;case "matrix":return `;${t}=${o}`;case "simple":return o;default:return `${t}=${o}`}}let a=Ee(s),n=i.map(o=>s==="label"||s==="simple"?e?o:encodeURIComponent(o):S({allowReserved:e,name:t,value:o})).join(a);return s==="label"||s==="matrix"?a+n:n},S=({allowReserved:e,name:r,value:t})=>{if(t==null)return "";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${e?t:encodeURIComponent(t)}`},_=({allowReserved:e,explode:r,name:t,style:s,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${t}=${i.toISOString()}`;if(s!=="deepObject"&&!r){let p=[];Object.entries(i).forEach(([y,x])=>{p=[...p,y,e?x:encodeURIComponent(x)];});let u=p.join(",");switch(s){case "form":return `${t}=${u}`;case "label":return `.${u}`;case "matrix":return `;${t}=${u}`;default:return u}}let n=Se(s),o=Object.entries(i).map(([p,u])=>S({allowReserved:e,name:s==="deepObject"?`${t}[${p}]`:p,value:u})).join(n);return s==="label"||s==="matrix"?n+o:o};var Pe=/\{[^{}]+\}/g,be=({path:e,url:r})=>{let t=r,s=r.match(Pe);if(s)for(let i of s){let a=false,n=i.substring(1,i.length-1),o="simple";n.endsWith("*")&&(a=true,n=n.substring(0,n.length-1)),n.startsWith(".")?(n=n.substring(1),o="label"):n.startsWith(";")&&(n=n.substring(1),o="matrix");let p=e[n];if(p==null)continue;if(Array.isArray(p)){t=t.replace(i,z({explode:a,name:n,style:o,value:p}));continue}if(typeof p=="object"){t=t.replace(i,_({explode:a,name:n,style:o,value:p,valueOnly:true}));continue}if(o==="matrix"){t=t.replace(i,`;${S({name:n,value:p})}`);continue}let u=encodeURIComponent(o==="label"?`.${p}`:p);t=t.replace(i,u);}return t},pe=({allowReserved:e,array:r,object:t}={})=>i=>{let a=[];if(i&&typeof i=="object")for(let n in i){let o=i[n];if(o!=null)if(Array.isArray(o)){let p=z({allowReserved:e,explode:true,name:n,style:"form",value:o,...r});p&&a.push(p);}else if(typeof o=="object"){let p=_({allowReserved:e,explode:true,name:n,style:"deepObject",value:o,...t});p&&a.push(p);}else {let p=S({allowReserved:e,name:n,value:o});p&&a.push(p);}}return a.join("&")},ce=e=>{if(!e)return "stream";let r=e.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(t=>r.startsWith(t)))return "blob";if(r.startsWith("text/"))return "text"}},Ce=(e,r)=>r?!!(e.headers.has(r)||e.query?.[r]||e.headers.get("Cookie")?.includes(`${r}=`)):false,le=async({security:e,...r})=>{for(let t of e){if(Ce(r,t.name))continue;let s=await ae(t,r.auth);if(!s)continue;let i=t.name??"Authorization";switch(t.in){case "query":r.query||(r.query={}),r.query[i]=s;break;case "cookie":r.headers.append("Cookie",`${i}=${s}`);break;case "header":default:r.headers.set(i,s);break}}},G=e=>Oe({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:pe(e.querySerializer),url:e.url}),Oe=({baseUrl:e,path:r,query:t,querySerializer:s,url:i})=>{let a=i.startsWith("/")?i:`/${i}`,n=(e??"")+a;r&&(n=be({path:r,url:n}));let o=t?s(t):"";return o.startsWith("?")&&(o=o.substring(1)),o&&(n+=`?${o}`),n},j=(e,r)=>{let t={...e,...r};return t.baseUrl?.endsWith("/")&&(t.baseUrl=t.baseUrl.substring(0,t.baseUrl.length-1)),t.headers=q(e.headers,r.headers),t},q=(...e)=>{let r=new Headers;for(let t of e){if(!t||typeof t!="object")continue;let s=t instanceof Headers?t.entries():Object.entries(t);for(let[i,a]of s)if(a===null)r.delete(i);else if(Array.isArray(a))for(let n of a)r.append(i,n);else a!==void 0&&r.set(i,typeof a=="object"?JSON.stringify(a):a);}return r},P=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let t=this.getInterceptorIndex(r);return !!this._fns[t]}eject(r){let t=this.getInterceptorIndex(r);this._fns[t]&&(this._fns[t]=null);}update(r,t){let s=this.getInterceptorIndex(r);return this._fns[s]?(this._fns[s]=t,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},ue=()=>({error:new P,request:new P,response:new P}),we=pe({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),Te={"Content-Type":"application/json"},b=(e={})=>({...v,headers:Te,parseAs:"auto",querySerializer:we,...e});var I=(e={})=>{let r=j(b(),e),t=()=>({...r}),s=n=>(r=j(r,n),t()),i=ue(),a=async n=>{let o={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:q(r.headers,n.headers),serializedBody:void 0};o.security&&await le({...o,security:o.security}),o.requestValidator&&await o.requestValidator(o),o.body&&o.bodySerializer&&(o.serializedBody=o.bodySerializer(o.body)),(o.serializedBody===void 0||o.serializedBody==="")&&o.headers.delete("Content-Type");let p=G(o),u={redirect:"follow",...o,body:o.serializedBody},y=new Request(p,u);for(let l of i.request._fns)l&&(y=await l(y,o));let x=o.fetch,c=await x(y);for(let l of i.response._fns)l&&(c=await l(c,y,o));let A={request:y,response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return o.responseStyle==="data"?{}:{data:{},...A};let l=(o.parseAs==="auto"?ce(c.headers.get("Content-Type")):o.parseAs)??"json",f;switch(l){case "arrayBuffer":case "blob":case "formData":case "json":case "text":f=await c[l]();break;case "stream":return o.responseStyle==="data"?c.body:{data:c.body,...A}}return l==="json"&&(o.responseValidator&&await o.responseValidator(f),o.responseTransformer&&(f=await o.responseTransformer(f))),o.responseStyle==="data"?f:{data:f,...A}}let m=await c.text(),E;try{E=JSON.parse(m);}catch{}let R=E??m,g=R;for(let l of i.error._fns)l&&(g=await l(R,c,y,o));if(g=g||{},o.throwOnError)throw g;return o.responseStyle==="data"?void 0:{error:g,...A}};return {buildUrl:G,connect:n=>a({...n,method:"CONNECT"}),delete:n=>a({...n,method:"DELETE"}),get:n=>a({...n,method:"GET"}),getConfig:t,head:n=>a({...n,method:"HEAD"}),interceptors:i,options:n=>a({...n,method:"OPTIONS"}),patch:n=>a({...n,method:"PATCH"}),post:n=>a({...n,method:"POST"}),put:n=>a({...n,method:"PUT"}),request:a,setConfig:s,trace:n=>a({...n,method:"TRACE"})}};var d=I(b({baseUrl:"https://odyssey.asteroid.ai/api/v1"}));var qe=e=>(e?.client??d).get({url:"/openapi.yaml",...e}),K=e=>(e.client??d).post({...U,security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/files",...e,headers:{"Content-Type":null,...e.headers}}),ke=e=>(e?.client??d).get({url:"/health",...e}),De=e=>(e.client??d).post({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),B=e=>(e.client??d).post({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent/{id}/execute",...e,headers:{"Content-Type":"application/json",...e.headers}}),$=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/status",...e}),V=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/result",...e}),H=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/execution/{id}/browser_session/recording",...e}),F=e=>(e?.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles",...e}),M=e=>(e.client??d).post({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles",...e,headers:{"Content-Type":"application/json",...e.headers}}),N=e=>(e.client??d).delete({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles/{profile_id}",...e}),W=e=>(e.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles/{profile_id}",...e}),Q=e=>(e.client??d).patch({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/agent-profiles/{profile_id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),X=e=>(e?.client??d).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/credentials/public_key",...e});var ne={};se(ne,{activitiesGet:()=>re,userMessagesAdd:()=>oe});var de={bodySerializer:e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t)};var ye=async(e,r)=>{let t=typeof r=="function"?await r(e):r;if(t)return e.scheme==="bearer"?`Bearer ${t}`:e.scheme==="basic"?`Basic ${btoa(t)}`:t};var Ue=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},ve=e=>{switch(e){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},ze=e=>{switch(e){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},J=({allowReserved:e,explode:r,name:t,style:s,value:i})=>{if(!r){let o=(e?i:i.map(p=>encodeURIComponent(p))).join(ve(s));switch(s){case "label":return `.${o}`;case "matrix":return `;${t}=${o}`;case "simple":return o;default:return `${t}=${o}`}}let a=Ue(s),n=i.map(o=>s==="label"||s==="simple"?e?o:encodeURIComponent(o):C({allowReserved:e,name:t,value:o})).join(a);return s==="label"||s==="matrix"?a+n:n},C=({allowReserved:e,name:r,value:t})=>{if(t==null)return "";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${e?t:encodeURIComponent(t)}`},Y=({allowReserved:e,explode:r,name:t,style:s,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${t}=${i.toISOString()}`;if(s!=="deepObject"&&!r){let p=[];Object.entries(i).forEach(([y,x])=>{p=[...p,y,e?x:encodeURIComponent(x)];});let u=p.join(",");switch(s){case "form":return `${t}=${u}`;case "label":return `.${u}`;case "matrix":return `;${t}=${u}`;default:return u}}let n=ze(s),o=Object.entries(i).map(([p,u])=>C({allowReserved:e,name:s==="deepObject"?`${t}[${p}]`:p,value:u})).join(n);return s==="label"||s==="matrix"?n+o:o};var _e=/\{[^{}]+\}/g,Ge=({path:e,url:r})=>{let t=r,s=r.match(_e);if(s)for(let i of s){let a=false,n=i.substring(1,i.length-1),o="simple";n.endsWith("*")&&(a=true,n=n.substring(0,n.length-1)),n.startsWith(".")?(n=n.substring(1),o="label"):n.startsWith(";")&&(n=n.substring(1),o="matrix");let p=e[n];if(p==null)continue;if(Array.isArray(p)){t=t.replace(i,J({explode:a,name:n,style:o,value:p}));continue}if(typeof p=="object"){t=t.replace(i,Y({explode:a,name:n,style:o,value:p,valueOnly:true}));continue}if(o==="matrix"){t=t.replace(i,`;${C({name:n,value:p})}`);continue}let u=encodeURIComponent(o==="label"?`.${p}`:p);t=t.replace(i,u);}return t},fe=({allowReserved:e,array:r,object:t}={})=>i=>{let a=[];if(i&&typeof i=="object")for(let n in i){let o=i[n];if(o!=null)if(Array.isArray(o)){let p=J({allowReserved:e,explode:true,name:n,style:"form",value:o,...r});p&&a.push(p);}else if(typeof o=="object"){let p=Y({allowReserved:e,explode:true,name:n,style:"deepObject",value:o,...t});p&&a.push(p);}else {let p=C({allowReserved:e,name:n,value:o});p&&a.push(p);}}return a.join("&")},ge=e=>{if(!e)return "stream";let r=e.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(t=>r.startsWith(t)))return "blob";if(r.startsWith("text/"))return "text"}},je=(e,r)=>r?!!(e.headers.has(r)||e.query?.[r]||e.headers.get("Cookie")?.includes(`${r}=`)):false,xe=async({security:e,...r})=>{for(let t of e){if(je(r,t.name))continue;let s=await ye(t,r.auth);if(!s)continue;let i=t.name??"Authorization";switch(t.in){case "query":r.query||(r.query={}),r.query[i]=s;break;case "cookie":r.headers.append("Cookie",`${i}=${s}`);break;case "header":default:r.headers.set(i,s);break}}},Z=e=>Ie({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:fe(e.querySerializer),url:e.url}),Ie=({baseUrl:e,path:r,query:t,querySerializer:s,url:i})=>{let a=i.startsWith("/")?i:`/${i}`,n=(e??"")+a;r&&(n=Ge({path:r,url:n}));let o=t?s(t):"";return o.startsWith("?")&&(o=o.substring(1)),o&&(n+=`?${o}`),n},ee=(e,r)=>{let t={...e,...r};return t.baseUrl?.endsWith("/")&&(t.baseUrl=t.baseUrl.substring(0,t.baseUrl.length-1)),t.headers=k(e.headers,r.headers),t},k=(...e)=>{let r=new Headers;for(let t of e){if(!t||typeof t!="object")continue;let s=t instanceof Headers?t.entries():Object.entries(t);for(let[i,a]of s)if(a===null)r.delete(i);else if(Array.isArray(a))for(let n of a)r.append(i,n);else a!==void 0&&r.set(i,typeof a=="object"?JSON.stringify(a):a);}return r},O=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let t=this.getInterceptorIndex(r);return !!this._fns[t]}eject(r){let t=this.getInterceptorIndex(r);this._fns[t]&&(this._fns[t]=null);}update(r,t){let s=this.getInterceptorIndex(r);return this._fns[s]?(this._fns[s]=t,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},Ae=()=>({error:new O,request:new O,response:new O}),Ke=fe({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),Be={"Content-Type":"application/json"},w=(e={})=>({...de,headers:Be,parseAs:"auto",querySerializer:Ke,...e});var te=(e={})=>{let r=ee(w(),e),t=()=>({...r}),s=n=>(r=ee(r,n),t()),i=Ae(),a=async n=>{let o={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:k(r.headers,n.headers),serializedBody:void 0};o.security&&await xe({...o,security:o.security}),o.requestValidator&&await o.requestValidator(o),o.body&&o.bodySerializer&&(o.serializedBody=o.bodySerializer(o.body)),(o.serializedBody===void 0||o.serializedBody==="")&&o.headers.delete("Content-Type");let p=Z(o),u={redirect:"follow",...o,body:o.serializedBody},y=new Request(p,u);for(let l of i.request._fns)l&&(y=await l(y,o));let x=o.fetch,c=await x(y);for(let l of i.response._fns)l&&(c=await l(c,y,o));let A={request:y,response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return o.responseStyle==="data"?{}:{data:{},...A};let l=(o.parseAs==="auto"?ge(c.headers.get("Content-Type")):o.parseAs)??"json",f;switch(l){case "arrayBuffer":case "blob":case "formData":case "json":case "text":f=await c[l]();break;case "stream":return o.responseStyle==="data"?c.body:{data:c.body,...A}}return l==="json"&&(o.responseValidator&&await o.responseValidator(f),o.responseTransformer&&(f=await o.responseTransformer(f))),o.responseStyle==="data"?f:{data:f,...A}}let m=await c.text(),E;try{E=JSON.parse(m);}catch{}let R=E??m,g=R;for(let l of i.error._fns)l&&(g=await l(R,c,y,o));if(g=g||{},o.throwOnError)throw g;return o.responseStyle==="data"?void 0:{error:g,...A}};return {buildUrl:Z,connect:n=>a({...n,method:"CONNECT"}),delete:n=>a({...n,method:"DELETE"}),get:n=>a({...n,method:"GET"}),getConfig:t,head:n=>a({...n,method:"HEAD"}),interceptors:i,options:n=>a({...n,method:"OPTIONS"}),patch:n=>a({...n,method:"PATCH"}),post:n=>a({...n,method:"POST"}),put:n=>a({...n,method:"PUT"}),request:a,setConfig:s,trace:n=>a({...n,method:"TRACE"})}};var h=te(w());var re=e=>(e.client??h).get({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/executions/{executionId}/activities",...e}),oe=e=>(e.client??h).post({security:[{name:"X-Asteroid-Agents-Api-Key",type:"apiKey"}],url:"/executions/{executionId}/user-messages",...e,headers:{"Content-Type":"application/json",...e.headers}});var $e={};var Ve={};var qt=(e,r)=>(d.setConfig({headers:{"X-Asteroid-Agents-Api-Key":e}}),h.setConfig({headers:{"X-Asteroid-Agents-Api-Key":e}}),d.setConfig({baseUrl:r?.v1?.baseUrl||"https://odyssey.asteroid.ai/api/v1"}),h.setConfig({baseUrl:r?.v2?.baseUrl||"https://odyssey.asteroid.ai/agents/v2"}),{agentsV1Client:d,agentsV2Client:h}),kt=async(e,r,t)=>{let s=await B({client:e.agentsV1Client,path:{id:r},body:t});if(s.error)throw new Error(s.error.error);return s.data.execution_id},He=async(e,r)=>{let t=await $({client:e.agentsV1Client,path:{id:r}});if(t.error)throw new Error(t.error.error);return t.data},Fe=async(e,r)=>{let t=await V({client:e.agentsV1Client,path:{id:r}});if(t.error)throw new Error(t.error.error);if(t.data.error)throw new Error(t.data.error);return t.data.execution_result||{}},Dt=async(e,r,t=1e3,s=36e5)=>{for(var i=Math.floor(s/t);i>0;){let a=await He(e,r),n=a.status;if(n==="completed")return await Fe(e,r);if(n==="failed"||n==="cancelled")throw new Error(`Execution ${r} ended with status: ${n}${a.reason?" - "+a.reason:""}`);await new Promise(o=>setTimeout(o,t)),i--;}throw new Error(`Execution ${r} timed out after ${s}ms`)},Ut=async(e,r)=>{let t=await H({client:e.agentsV1Client,path:{id:r}});if(t.error)throw new Error(t.error.error);return t.data},vt=async(e,r,t)=>{let s=await K({client:e.agentsV1Client,path:{id:r},body:{files:t}});if(s.error)throw new Error(s.error.error);return s.data},zt=async(e,r)=>{let t=await F({client:e.agentsV1Client,query:r?{organization_id:r}:void 0});if(t.error)throw new Error(t.error.error);return t.data},he=async e=>{let r=await X({client:e.agentsV1Client});if(r.error){let t=typeof r.error=="object"&&"error"in r.error?r.error.error:typeof r.error=="string"?r.error:JSON.stringify(r.error);throw new Error(t||"Unknown error")}if(!r.data)throw new Error("Public key not found");return r.data},_t=async(e,r)=>{let t={...r};if(r.credentials&&r.credentials.length>0){let i=await he(e);t.credentials=r.credentials.map(a=>({...a,data:D(a.data,i)}));}let s=await M({client:e.agentsV1Client,body:t});if(s.error)throw new Error(s.error.error);return s.data},Gt=async(e,r)=>{let t=await W({client:e.agentsV1Client,path:{profile_id:r}});if(t.error)throw new Error(t.error.error);return t.data},jt=async(e,r,t)=>{let s={...t};if(t.credentials_to_add&&t.credentials_to_add.length>0){let a=await he(e);s.credentials_to_add=t.credentials_to_add.map(n=>({...n,data:D(n.data,a)}));}let i=await Q({client:e.agentsV1Client,path:{profile_id:r},body:s});if(i.error)throw new Error(i.error.error);return i.data},It=async(e,r)=>{let t=await N({client:e.agentsV1Client,path:{profile_id:r}});if(t.error)throw new Error(t.error.error);return t.data},Kt=async(e,r,t)=>{let s=await re({client:e.agentsV2Client,path:{executionId:r},query:{limit:t,order:"desc"}});if(s.error)throw console.error(s.error),new Error(s.error.error);return s.data},Bt=async(e,r,t)=>{let s=await oe({client:e.agentsV2Client,path:{executionId:r},body:{message:t}});if(s.error)throw console.error(s.error),new Error(s.error.error)};
2
+ export{L as AgentsV1SDK,$e as AgentsV1Types,ne as AgentsV2SDK,Ve as AgentsV2Types,qt as AsteroidClient,Bt as addMessageToExecution,_t as createAgentProfile,It as deleteAgentProfile,kt as executeAgent,Gt as getAgentProfile,zt as getAgentProfiles,Ut as getBrowserSessionRecording,he as getCredentialsPublicKey,Fe as getExecutionResult,He as getExecutionStatus,Kt as getLastNExecutionActivities,jt as updateAgentProfile,vt as uploadExecutionFiles,Dt as waitForExecutionResult};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asteroid-odyssey",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "SDK for interacting with Asteroid Agents API",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",