asteroid-odyssey 1.2.2 → 1.2.4

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.
@@ -1,5 +1,5 @@
1
1
  import { type Options as ClientOptions, type TDataShape, type Client } from '@hey-api/client-fetch';
2
- import type { GetOpenApiData, UploadExecutionFilesData, HealthCheckData, ExecuteAgentData, ExecuteAgentStructuredData, GetExecutionStatusData, GetExecutionResultData, GetBrowserSessionRecordingData } from './types.gen';
2
+ import type { GetOpenApiData, UploadExecutionFilesData, HealthCheckData, ExecuteAgentData, ExecuteAgentStructuredData, GetExecutionStatusData, GetExecutionResultData, GetBrowserSessionRecordingData, GetAgentProfilesData, CreateAgentProfileData, DeleteAgentProfileData, GetAgentProfileData, UpdateAgentProfileData, GetCredentialsPublicKeyData } from './types.gen';
3
3
  export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
4
4
  /**
5
5
  * You can provide a client instance returned by `createClient()` instead of
@@ -33,6 +33,7 @@ export declare const healthCheck: <ThrowOnError extends boolean = false>(options
33
33
  error?: string;
34
34
  }, ThrowOnError>;
35
35
  /**
36
+ * @deprecated
36
37
  * Execute an agent
37
38
  * Executes an agent with the provided parameters
38
39
  */
@@ -55,3 +56,34 @@ export declare const getExecutionResult: <ThrowOnError extends boolean = false>(
55
56
  * Retrieves the browser session recording URL for a completed execution
56
57
  */
57
58
  export declare const getBrowserSessionRecording: <ThrowOnError extends boolean = false>(options: Options<GetBrowserSessionRecordingData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").BrowserSessionRecordingResponse, import("./types.gen").ErrorResponse, ThrowOnError>;
59
+ /**
60
+ * Get agent profiles
61
+ * Returns all agent profiles for the organization. If organization_id is not provided, returns profiles for all user's organizations.
62
+ */
63
+ export declare const getAgentProfiles: <ThrowOnError extends boolean = false>(options?: Options<GetAgentProfilesData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").AgentProfile[], import("./types.gen").ErrorResponse, ThrowOnError>;
64
+ /**
65
+ * Create an agent profile
66
+ * Creates a new agent profile for the organization
67
+ */
68
+ export declare const createAgentProfile: <ThrowOnError extends boolean = false>(options: Options<CreateAgentProfileData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").AgentProfile, import("./types.gen").ErrorResponse, ThrowOnError>;
69
+ /**
70
+ * Delete an agent profile
71
+ * Deletes the specified agent profile
72
+ */
73
+ export declare const deleteAgentProfile: <ThrowOnError extends boolean = false>(options: Options<DeleteAgentProfileData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<{
74
+ message?: string;
75
+ }, import("./types.gen").ErrorResponse, ThrowOnError>;
76
+ /**
77
+ * Get an agent profile by ID
78
+ * Returns the complete agent profile including credentials
79
+ */
80
+ export declare const getAgentProfile: <ThrowOnError extends boolean = false>(options: Options<GetAgentProfileData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").AgentProfile, import("./types.gen").ErrorResponse, ThrowOnError>;
81
+ /**
82
+ * Update an agent profile
83
+ * Updates an agent profile including metadata and/or credentials
84
+ */
85
+ export declare const updateAgentProfile: <ThrowOnError extends boolean = false>(options: Options<UpdateAgentProfileData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").AgentProfile, import("./types.gen").ErrorResponse, ThrowOnError>;
86
+ /**
87
+ * Get the public key for credentials
88
+ */
89
+ export declare const getCredentialsPublicKey: <ThrowOnError extends boolean = false>(options?: Options<GetCredentialsPublicKeyData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<string, unknown, ThrowOnError>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // This file is auto-generated by @hey-api/openapi-ts
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getBrowserSessionRecording = exports.getExecutionResult = exports.getExecutionStatus = exports.executeAgentStructured = exports.executeAgent = exports.healthCheck = exports.uploadExecutionFiles = exports.getOpenApi = void 0;
4
+ exports.getCredentialsPublicKey = exports.updateAgentProfile = exports.getAgentProfile = exports.deleteAgentProfile = exports.createAgentProfile = exports.getAgentProfiles = exports.getBrowserSessionRecording = exports.getExecutionResult = exports.getExecutionStatus = exports.executeAgentStructured = exports.executeAgent = exports.healthCheck = exports.uploadExecutionFiles = exports.getOpenApi = void 0;
5
5
  const client_fetch_1 = require("@hey-api/client-fetch");
6
6
  const client_gen_1 = require("./client.gen");
7
7
  /**
@@ -46,6 +46,7 @@ const healthCheck = (options) => {
46
46
  };
47
47
  exports.healthCheck = healthCheck;
48
48
  /**
49
+ * @deprecated
49
50
  * Execute an agent
50
51
  * Executes an agent with the provided parameters
51
52
  */
@@ -136,3 +137,112 @@ const getBrowserSessionRecording = (options) => {
136
137
  });
137
138
  };
138
139
  exports.getBrowserSessionRecording = getBrowserSessionRecording;
140
+ /**
141
+ * Get agent profiles
142
+ * Returns all agent profiles for the organization. If organization_id is not provided, returns profiles for all user's organizations.
143
+ */
144
+ const getAgentProfiles = (options) => {
145
+ return (options?.client ?? client_gen_1.client).get({
146
+ security: [
147
+ {
148
+ name: 'X-Asteroid-Agents-Api-Key',
149
+ type: 'apiKey'
150
+ }
151
+ ],
152
+ url: '/agent-profiles',
153
+ ...options
154
+ });
155
+ };
156
+ exports.getAgentProfiles = getAgentProfiles;
157
+ /**
158
+ * Create an agent profile
159
+ * Creates a new agent profile for the organization
160
+ */
161
+ const createAgentProfile = (options) => {
162
+ return (options.client ?? client_gen_1.client).post({
163
+ security: [
164
+ {
165
+ name: 'X-Asteroid-Agents-Api-Key',
166
+ type: 'apiKey'
167
+ }
168
+ ],
169
+ url: '/agent-profiles',
170
+ ...options,
171
+ headers: {
172
+ 'Content-Type': 'application/json',
173
+ ...options?.headers
174
+ }
175
+ });
176
+ };
177
+ exports.createAgentProfile = createAgentProfile;
178
+ /**
179
+ * Delete an agent profile
180
+ * Deletes the specified agent profile
181
+ */
182
+ const deleteAgentProfile = (options) => {
183
+ return (options.client ?? client_gen_1.client).delete({
184
+ security: [
185
+ {
186
+ name: 'X-Asteroid-Agents-Api-Key',
187
+ type: 'apiKey'
188
+ }
189
+ ],
190
+ url: '/agent-profiles/{profile_id}',
191
+ ...options
192
+ });
193
+ };
194
+ exports.deleteAgentProfile = deleteAgentProfile;
195
+ /**
196
+ * Get an agent profile by ID
197
+ * Returns the complete agent profile including credentials
198
+ */
199
+ const getAgentProfile = (options) => {
200
+ return (options.client ?? client_gen_1.client).get({
201
+ security: [
202
+ {
203
+ name: 'X-Asteroid-Agents-Api-Key',
204
+ type: 'apiKey'
205
+ }
206
+ ],
207
+ url: '/agent-profiles/{profile_id}',
208
+ ...options
209
+ });
210
+ };
211
+ exports.getAgentProfile = getAgentProfile;
212
+ /**
213
+ * Update an agent profile
214
+ * Updates an agent profile including metadata and/or credentials
215
+ */
216
+ const updateAgentProfile = (options) => {
217
+ return (options.client ?? client_gen_1.client).patch({
218
+ security: [
219
+ {
220
+ name: 'X-Asteroid-Agents-Api-Key',
221
+ type: 'apiKey'
222
+ }
223
+ ],
224
+ url: '/agent-profiles/{profile_id}',
225
+ ...options,
226
+ headers: {
227
+ 'Content-Type': 'application/json',
228
+ ...options?.headers
229
+ }
230
+ });
231
+ };
232
+ exports.updateAgentProfile = updateAgentProfile;
233
+ /**
234
+ * Get the public key for credentials
235
+ */
236
+ const getCredentialsPublicKey = (options) => {
237
+ return (options?.client ?? client_gen_1.client).get({
238
+ security: [
239
+ {
240
+ name: 'X-Asteroid-Agents-Api-Key',
241
+ type: 'apiKey'
242
+ }
243
+ ],
244
+ url: '/credentials/public_key',
245
+ ...options
246
+ });
247
+ };
248
+ exports.getCredentialsPublicKey = getCredentialsPublicKey;
@@ -66,7 +66,7 @@ export type ExecutionResult = {
66
66
  /**
67
67
  * Status of the execution
68
68
  */
69
- export type Status = 'starting' | 'running' | 'paused' | 'completed' | 'cancelled' | 'failed' | 'awaiting_completion' | 'paused_by_agent';
69
+ export type Status = 'starting' | 'running' | 'paused' | 'completed' | 'cancelled' | 'failed' | 'awaiting_confirmation' | 'paused_by_agent';
70
70
  export type ErrorResponse = {
71
71
  /**
72
72
  * Error message
@@ -94,6 +94,128 @@ export type StructuredAgentExecutionRequest = {
94
94
  [key: string]: unknown;
95
95
  };
96
96
  };
97
+ export type AgentProfile = {
98
+ /**
99
+ * Unique identifier for the agent profile
100
+ */
101
+ id: string;
102
+ /**
103
+ * Name of the agent profile (unique within organization)
104
+ */
105
+ name: string;
106
+ /**
107
+ * Description of the agent profile
108
+ */
109
+ description: string;
110
+ /**
111
+ * The ID of the organization that the agent profile belongs to
112
+ */
113
+ organization_id: string;
114
+ proxy_cc: CountryCode;
115
+ proxy_type: ProxyType;
116
+ /**
117
+ * Whether the captcha solver is active for this profile
118
+ */
119
+ captcha_solver_active: boolean;
120
+ /**
121
+ * Whether the same IP address should be used for all executions of this profile
122
+ */
123
+ sticky_ip: boolean;
124
+ /**
125
+ * List of credentials associated with this agent profile
126
+ */
127
+ credentials: Array<Credential>;
128
+ /**
129
+ * The date and time the agent profile was created
130
+ */
131
+ created_at: string;
132
+ /**
133
+ * The last update time of the agent profile
134
+ */
135
+ updated_at: string;
136
+ };
137
+ export type CreateAgentProfileRequest = {
138
+ /**
139
+ * Name of the agent profile (must be unique within organization)
140
+ */
141
+ name: string;
142
+ /**
143
+ * Description of the agent profile
144
+ */
145
+ description: string;
146
+ /**
147
+ * The ID of the organization that the agent profile belongs to
148
+ */
149
+ organization_id: string;
150
+ proxy_cc: CountryCode;
151
+ proxy_type: ProxyType;
152
+ /**
153
+ * Whether the captcha solver should be active for this profile
154
+ */
155
+ captcha_solver_active: boolean;
156
+ /**
157
+ * Whether the same IP address should be used for all executions of this profile
158
+ */
159
+ sticky_ip: boolean;
160
+ /**
161
+ * Optional list of credentials to create with the profile
162
+ */
163
+ credentials: Array<Credential>;
164
+ };
165
+ export type UpdateAgentProfileRequest = {
166
+ /**
167
+ * The name of the agent profile
168
+ */
169
+ name?: string;
170
+ /**
171
+ * The description of the agent profile
172
+ */
173
+ description?: string;
174
+ proxy_cc?: CountryCode;
175
+ proxy_type?: ProxyType;
176
+ /**
177
+ * Whether the captcha solver should be active for this profile
178
+ */
179
+ captcha_solver_active?: boolean;
180
+ /**
181
+ * Whether the same IP address should be used for all executions of this profile
182
+ */
183
+ sticky_ip?: boolean;
184
+ /**
185
+ * List of credentials to add to the profile
186
+ */
187
+ credentials_to_add?: Array<Credential>;
188
+ /**
189
+ * List of credential IDs to delete from the profile
190
+ */
191
+ credentials_to_delete?: Array<string>;
192
+ };
193
+ /**
194
+ * Two-letter country code for proxy location
195
+ */
196
+ export type CountryCode = 'us' | 'uk' | 'fr' | 'it' | 'jp' | 'au' | 'de' | 'fi' | 'ca';
197
+ /**
198
+ * Type of proxy to use
199
+ */
200
+ export type ProxyType = 'residential' | 'mobile';
201
+ export type Credential = {
202
+ /**
203
+ * The unique identifier for this credential
204
+ */
205
+ id?: string;
206
+ /**
207
+ * The credential name
208
+ */
209
+ name: string;
210
+ /**
211
+ * The encrypted credential
212
+ */
213
+ data: string;
214
+ /**
215
+ * When the credential was created
216
+ */
217
+ created_at?: string;
218
+ };
97
219
  export type GetOpenApiData = {
98
220
  body?: never;
99
221
  path?: never;
@@ -336,6 +458,207 @@ export type GetBrowserSessionRecordingResponses = {
336
458
  200: BrowserSessionRecordingResponse;
337
459
  };
338
460
  export type GetBrowserSessionRecordingResponse = GetBrowserSessionRecordingResponses[keyof GetBrowserSessionRecordingResponses];
461
+ export type GetAgentProfilesData = {
462
+ body?: never;
463
+ path?: never;
464
+ query?: {
465
+ /**
466
+ * The ID of the organization to filter by
467
+ */
468
+ organization_id?: string;
469
+ };
470
+ url: '/agent-profiles';
471
+ };
472
+ export type GetAgentProfilesErrors = {
473
+ /**
474
+ * Unauthorized - Authentication required
475
+ */
476
+ 401: ErrorResponse;
477
+ /**
478
+ * Forbidden - Insufficient permissions
479
+ */
480
+ 403: ErrorResponse;
481
+ /**
482
+ * Internal server error
483
+ */
484
+ 500: ErrorResponse;
485
+ };
486
+ export type GetAgentProfilesError = GetAgentProfilesErrors[keyof GetAgentProfilesErrors];
487
+ export type GetAgentProfilesResponses = {
488
+ /**
489
+ * List of agent profiles
490
+ */
491
+ 200: Array<AgentProfile>;
492
+ };
493
+ export type GetAgentProfilesResponse = GetAgentProfilesResponses[keyof GetAgentProfilesResponses];
494
+ export type CreateAgentProfileData = {
495
+ body: CreateAgentProfileRequest;
496
+ path?: never;
497
+ query?: never;
498
+ url: '/agent-profiles';
499
+ };
500
+ export type CreateAgentProfileErrors = {
501
+ /**
502
+ * Bad request - Invalid input or profile name already exists
503
+ */
504
+ 400: ErrorResponse;
505
+ /**
506
+ * Unauthorized - Authentication required
507
+ */
508
+ 401: ErrorResponse;
509
+ /**
510
+ * Forbidden - Insufficient permissions
511
+ */
512
+ 403: ErrorResponse;
513
+ /**
514
+ * Internal server error
515
+ */
516
+ 500: ErrorResponse;
517
+ };
518
+ export type CreateAgentProfileError = CreateAgentProfileErrors[keyof CreateAgentProfileErrors];
519
+ export type CreateAgentProfileResponses = {
520
+ /**
521
+ * Agent profile created successfully
522
+ */
523
+ 201: AgentProfile;
524
+ };
525
+ export type CreateAgentProfileResponse = CreateAgentProfileResponses[keyof CreateAgentProfileResponses];
526
+ export type DeleteAgentProfileData = {
527
+ body?: never;
528
+ path: {
529
+ /**
530
+ * The ID of the agent profile
531
+ */
532
+ profile_id: string;
533
+ };
534
+ query?: never;
535
+ url: '/agent-profiles/{profile_id}';
536
+ };
537
+ export type DeleteAgentProfileErrors = {
538
+ /**
539
+ * Unauthorized - Authentication required
540
+ */
541
+ 401: ErrorResponse;
542
+ /**
543
+ * Forbidden - Insufficient permissions
544
+ */
545
+ 403: ErrorResponse;
546
+ /**
547
+ * Agent profile not found
548
+ */
549
+ 404: ErrorResponse;
550
+ /**
551
+ * Internal server error
552
+ */
553
+ 500: ErrorResponse;
554
+ };
555
+ export type DeleteAgentProfileError = DeleteAgentProfileErrors[keyof DeleteAgentProfileErrors];
556
+ export type DeleteAgentProfileResponses = {
557
+ /**
558
+ * Agent profile deleted successfully
559
+ */
560
+ 200: {
561
+ message?: string;
562
+ };
563
+ };
564
+ export type DeleteAgentProfileResponse = DeleteAgentProfileResponses[keyof DeleteAgentProfileResponses];
565
+ export type GetAgentProfileData = {
566
+ body?: never;
567
+ path: {
568
+ /**
569
+ * The ID of the agent profile
570
+ */
571
+ profile_id: string;
572
+ };
573
+ query?: never;
574
+ url: '/agent-profiles/{profile_id}';
575
+ };
576
+ export type GetAgentProfileErrors = {
577
+ /**
578
+ * Unauthorized - Authentication required
579
+ */
580
+ 401: ErrorResponse;
581
+ /**
582
+ * Forbidden - Insufficient permissions
583
+ */
584
+ 403: ErrorResponse;
585
+ /**
586
+ * Agent profile not found
587
+ */
588
+ 404: ErrorResponse;
589
+ /**
590
+ * Internal server error
591
+ */
592
+ 500: ErrorResponse;
593
+ };
594
+ export type GetAgentProfileError = GetAgentProfileErrors[keyof GetAgentProfileErrors];
595
+ export type GetAgentProfileResponses = {
596
+ /**
597
+ * Agent profile found
598
+ */
599
+ 200: AgentProfile;
600
+ };
601
+ export type GetAgentProfileResponse = GetAgentProfileResponses[keyof GetAgentProfileResponses];
602
+ export type UpdateAgentProfileData = {
603
+ body: UpdateAgentProfileRequest;
604
+ path: {
605
+ /**
606
+ * The ID of the agent profile
607
+ */
608
+ profile_id: string;
609
+ };
610
+ query?: never;
611
+ url: '/agent-profiles/{profile_id}';
612
+ };
613
+ export type UpdateAgentProfileErrors = {
614
+ /**
615
+ * Bad request - Invalid input
616
+ */
617
+ 400: ErrorResponse;
618
+ /**
619
+ * Unauthorized - Authentication required
620
+ */
621
+ 401: ErrorResponse;
622
+ /**
623
+ * Forbidden - Insufficient permissions
624
+ */
625
+ 403: ErrorResponse;
626
+ /**
627
+ * Agent profile not found
628
+ */
629
+ 404: ErrorResponse;
630
+ /**
631
+ * Internal server error
632
+ */
633
+ 500: ErrorResponse;
634
+ };
635
+ export type UpdateAgentProfileError = UpdateAgentProfileErrors[keyof UpdateAgentProfileErrors];
636
+ export type UpdateAgentProfileResponses = {
637
+ /**
638
+ * Agent profile updated successfully
639
+ */
640
+ 200: AgentProfile;
641
+ };
642
+ export type UpdateAgentProfileResponse = UpdateAgentProfileResponses[keyof UpdateAgentProfileResponses];
643
+ export type GetCredentialsPublicKeyData = {
644
+ body?: never;
645
+ path?: never;
646
+ query?: never;
647
+ url: '/credentials/public_key';
648
+ };
649
+ export type GetCredentialsPublicKeyErrors = {
650
+ /**
651
+ * Public key not found
652
+ */
653
+ 404: unknown;
654
+ };
655
+ export type GetCredentialsPublicKeyResponses = {
656
+ /**
657
+ * The public key for credentials
658
+ */
659
+ 200: string;
660
+ };
661
+ export type GetCredentialsPublicKeyResponse = GetCredentialsPublicKeyResponses[keyof GetCredentialsPublicKeyResponses];
339
662
  export type ClientOptions = {
340
663
  baseUrl: 'https://odyssey.asteroid.ai/api/v1' | `${string}://${string}/api/v1` | (string & {});
341
664
  };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Client } from '@hey-api/client-fetch';
2
- import type { StructuredAgentExecutionRequest, ExecutionStatusResponse, BrowserSessionRecordingResponse } from './generated/agents/types.gen';
2
+ import type { StructuredAgentExecutionRequest, ExecutionStatusResponse, BrowserSessionRecordingResponse, AgentProfile, CreateAgentProfileRequest, UpdateAgentProfileRequest } from './generated/agents/types.gen';
3
3
  /**
4
4
  * Create an API client with a provided API key.
5
5
  *
@@ -95,6 +95,87 @@ export declare const uploadExecutionFiles: (client: Client, executionId: string,
95
95
  message?: string;
96
96
  file_ids?: string[];
97
97
  }>;
98
+ /**
99
+ * Get agent profiles for an organization (or all organizations for the user if not specified).
100
+ *
101
+ * @param client - The API client.
102
+ * @param organizationId - Optional organization ID to filter by.
103
+ * @returns The list of agent profiles.
104
+ *
105
+ * @example
106
+ * const profiles = await getAgentProfiles(client, 'org_123');
107
+ */
108
+ export declare const getAgentProfiles: (client: Client, organizationId?: string) => Promise<AgentProfile[]>;
109
+ /**
110
+ * Get the public key for encrypting credentials.
111
+ *
112
+ * @param client - The API client.
113
+ * @returns The PEM-formatted public key.
114
+ *
115
+ * @example
116
+ * const publicKey = await getCredentialsPublicKey(client);
117
+ */
118
+ export declare const getCredentialsPublicKey: (client: Client) => Promise<string>;
119
+ /**
120
+ * Create a new agent profile.
121
+ *
122
+ * @param client - The API client.
123
+ * @param payload - The agent profile data.
124
+ * @returns The created agent profile.
125
+ *
126
+ * @example
127
+ * const profile = await createAgentProfile(client, {
128
+ * name: 'My Profile',
129
+ * description: 'Profile description',
130
+ * organization_id: 'org_123',
131
+ * proxy_cc: 'us',
132
+ * proxy_type: 'residential',
133
+ * captcha_solver_active: false,
134
+ * sticky_ip: false,
135
+ * credentials: []
136
+ * });
137
+ */
138
+ export declare const createAgentProfile: (client: Client, payload: CreateAgentProfileRequest) => Promise<AgentProfile>;
139
+ /**
140
+ * Get a specific agent profile by ID.
141
+ *
142
+ * @param client - The API client.
143
+ * @param profileId - The agent profile ID.
144
+ * @returns The agent profile.
145
+ *
146
+ * @example
147
+ * const profile = await getAgentProfile(client, 'profile_123');
148
+ */
149
+ export declare const getAgentProfile: (client: Client, profileId: string) => Promise<AgentProfile>;
150
+ /**
151
+ * Update an existing agent profile.
152
+ *
153
+ * @param client - The API client.
154
+ * @param profileId - The agent profile ID.
155
+ * @param payload - The update data.
156
+ * @returns The updated agent profile.
157
+ *
158
+ * @example
159
+ * const updated = await updateAgentProfile(client, 'profile_123', {
160
+ * name: 'New Name',
161
+ * credentials_to_add: [{ name: 'API_KEY', data: 'secret-key' }],
162
+ * credentials_to_delete: ['cred_456']
163
+ * });
164
+ */
165
+ export declare const updateAgentProfile: (client: Client, profileId: string, payload: UpdateAgentProfileRequest) => Promise<AgentProfile>;
166
+ /**
167
+ * Delete an agent profile by ID.
168
+ *
169
+ * @param client - The API client.
170
+ * @param profileId - The agent profile ID.
171
+ * @returns A success message.
172
+ *
173
+ * @example
174
+ * await deleteAgentProfile(client, 'profile_123');
175
+ */
176
+ export declare const deleteAgentProfile: (client: Client, profileId: string) => Promise<{
177
+ message?: string;
178
+ }>;
98
179
  /**
99
180
  * Optionally, re-export all generated functions and types.
100
181
  */
package/dist/index.js CHANGED
@@ -36,9 +36,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.uploadExecutionFiles = exports.getBrowserSessionRecording = exports.waitForExecutionResult = exports.getExecutionResult = exports.getExecutionStatus = exports.executeAgent = exports.AsteroidClient = void 0;
39
+ exports.deleteAgentProfile = exports.updateAgentProfile = exports.getAgentProfile = exports.createAgentProfile = exports.getCredentialsPublicKey = exports.getAgentProfiles = exports.uploadExecutionFiles = exports.getBrowserSessionRecording = exports.waitForExecutionResult = exports.getExecutionResult = exports.getExecutionStatus = exports.executeAgent = exports.AsteroidClient = void 0;
40
40
  const client_fetch_1 = require("@hey-api/client-fetch");
41
41
  const AgentsSDK = __importStar(require("./generated/agents/sdk.gen"));
42
+ const encryption_1 = require("./utils/encryption");
42
43
  /**
43
44
  * Create an API client with a provided API key.
44
45
  *
@@ -211,6 +212,175 @@ const uploadExecutionFiles = async (client, executionId, files) => {
211
212
  return response.data;
212
213
  };
213
214
  exports.uploadExecutionFiles = uploadExecutionFiles;
215
+ /**
216
+ * Get agent profiles for an organization (or all organizations for the user if not specified).
217
+ *
218
+ * @param client - The API client.
219
+ * @param organizationId - Optional organization ID to filter by.
220
+ * @returns The list of agent profiles.
221
+ *
222
+ * @example
223
+ * const profiles = await getAgentProfiles(client, 'org_123');
224
+ */
225
+ const getAgentProfiles = async (client, organizationId) => {
226
+ const response = await AgentsSDK.getAgentProfiles({
227
+ client,
228
+ query: organizationId ? { organization_id: organizationId } : undefined,
229
+ });
230
+ if (response.error) {
231
+ throw new Error(response.error.error);
232
+ }
233
+ return response.data;
234
+ };
235
+ exports.getAgentProfiles = getAgentProfiles;
236
+ /**
237
+ * Get the public key for encrypting credentials.
238
+ *
239
+ * @param client - The API client.
240
+ * @returns The PEM-formatted public key.
241
+ *
242
+ * @example
243
+ * const publicKey = await getCredentialsPublicKey(client);
244
+ */
245
+ const getCredentialsPublicKey = async (client) => {
246
+ const response = await AgentsSDK.getCredentialsPublicKey({
247
+ client,
248
+ });
249
+ if (response.error) {
250
+ const errorMessage = typeof response.error === 'object' && 'error' in response.error
251
+ ? response.error.error
252
+ : typeof response.error === 'string'
253
+ ? response.error
254
+ : JSON.stringify(response.error);
255
+ throw new Error(errorMessage || 'Unknown error');
256
+ }
257
+ if (!response.data) {
258
+ throw new Error('Public key not found');
259
+ }
260
+ return response.data;
261
+ };
262
+ exports.getCredentialsPublicKey = getCredentialsPublicKey;
263
+ /**
264
+ * Create a new agent profile.
265
+ *
266
+ * @param client - The API client.
267
+ * @param payload - The agent profile data.
268
+ * @returns The created agent profile.
269
+ *
270
+ * @example
271
+ * const profile = await createAgentProfile(client, {
272
+ * name: 'My Profile',
273
+ * description: 'Profile description',
274
+ * organization_id: 'org_123',
275
+ * proxy_cc: 'us',
276
+ * proxy_type: 'residential',
277
+ * captcha_solver_active: false,
278
+ * sticky_ip: false,
279
+ * credentials: []
280
+ * });
281
+ */
282
+ const createAgentProfile = async (client, payload) => {
283
+ // If credentials are provided, encrypt them before sending
284
+ let processedPayload = { ...payload };
285
+ if (payload.credentials && payload.credentials.length > 0) {
286
+ // Get the public key for encryption
287
+ const publicKey = await (0, exports.getCredentialsPublicKey)(client);
288
+ // Encrypt each credential's data field
289
+ processedPayload.credentials = payload.credentials.map(credential => ({
290
+ ...credential,
291
+ data: (0, encryption_1.encryptWithPublicKey)(credential.data, publicKey)
292
+ }));
293
+ }
294
+ const response = await AgentsSDK.createAgentProfile({
295
+ client,
296
+ body: processedPayload,
297
+ });
298
+ if (response.error) {
299
+ throw new Error(response.error.error);
300
+ }
301
+ return response.data;
302
+ };
303
+ exports.createAgentProfile = createAgentProfile;
304
+ /**
305
+ * Get a specific agent profile by ID.
306
+ *
307
+ * @param client - The API client.
308
+ * @param profileId - The agent profile ID.
309
+ * @returns The agent profile.
310
+ *
311
+ * @example
312
+ * const profile = await getAgentProfile(client, 'profile_123');
313
+ */
314
+ const getAgentProfile = async (client, profileId) => {
315
+ const response = await AgentsSDK.getAgentProfile({
316
+ client,
317
+ path: { profile_id: profileId },
318
+ });
319
+ if (response.error) {
320
+ throw new Error(response.error.error);
321
+ }
322
+ return response.data;
323
+ };
324
+ exports.getAgentProfile = getAgentProfile;
325
+ /**
326
+ * Update an existing agent profile.
327
+ *
328
+ * @param client - The API client.
329
+ * @param profileId - The agent profile ID.
330
+ * @param payload - The update data.
331
+ * @returns The updated agent profile.
332
+ *
333
+ * @example
334
+ * const updated = await updateAgentProfile(client, 'profile_123', {
335
+ * name: 'New Name',
336
+ * credentials_to_add: [{ name: 'API_KEY', data: 'secret-key' }],
337
+ * credentials_to_delete: ['cred_456']
338
+ * });
339
+ */
340
+ const updateAgentProfile = async (client, profileId, payload) => {
341
+ // If credentials_to_add are provided, encrypt them before sending
342
+ let processedPayload = { ...payload };
343
+ if (payload.credentials_to_add && payload.credentials_to_add.length > 0) {
344
+ // Get the public key for encryption
345
+ const publicKey = await (0, exports.getCredentialsPublicKey)(client);
346
+ // Encrypt the data field of each credential to add
347
+ processedPayload.credentials_to_add = payload.credentials_to_add.map(credential => ({
348
+ ...credential,
349
+ data: (0, encryption_1.encryptWithPublicKey)(credential.data, publicKey)
350
+ }));
351
+ }
352
+ const response = await AgentsSDK.updateAgentProfile({
353
+ client,
354
+ path: { profile_id: profileId },
355
+ body: processedPayload,
356
+ });
357
+ if (response.error) {
358
+ throw new Error(response.error.error);
359
+ }
360
+ return response.data;
361
+ };
362
+ exports.updateAgentProfile = updateAgentProfile;
363
+ /**
364
+ * Delete an agent profile by ID.
365
+ *
366
+ * @param client - The API client.
367
+ * @param profileId - The agent profile ID.
368
+ * @returns A success message.
369
+ *
370
+ * @example
371
+ * await deleteAgentProfile(client, 'profile_123');
372
+ */
373
+ const deleteAgentProfile = async (client, profileId) => {
374
+ const response = await AgentsSDK.deleteAgentProfile({
375
+ client,
376
+ path: { profile_id: profileId },
377
+ });
378
+ if (response.error) {
379
+ throw new Error(response.error.error);
380
+ }
381
+ return response.data;
382
+ };
383
+ exports.deleteAgentProfile = deleteAgentProfile;
214
384
  /**
215
385
  * Optionally, re-export all generated functions and types.
216
386
  */
@@ -0,0 +1 @@
1
+ export declare function encryptWithPublicKey(plaintext: string, pemPublicKey: string): string;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.encryptWithPublicKey = encryptWithPublicKey;
37
+ const forge = __importStar(require("node-forge"));
38
+ // Utility function to encrypt a plaintext value using a PEM public key
39
+ function encryptWithPublicKey(plaintext, pemPublicKey) {
40
+ try {
41
+ // The public key is already in PEM format from the API
42
+ // Parse the public key using node-forge
43
+ const publicKey = forge.pki.publicKeyFromPem(pemPublicKey);
44
+ // Encrypt the plaintext using RSA
45
+ const encrypted = publicKey.encrypt(plaintext, "RSAES-PKCS1-V1_5");
46
+ // Convert to base64 for transmission
47
+ return forge.util.encode64(encrypted);
48
+ }
49
+ catch (error) {
50
+ console.error("Encryption failed:", error);
51
+ throw new Error("Failed to encrypt: " +
52
+ (error instanceof Error ? error.message : "unknown error"));
53
+ }
54
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asteroid-odyssey",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "SDK for interacting with Asteroid Agents API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,11 +18,14 @@
18
18
  "devDependencies": {
19
19
  "@hey-api/openapi-ts": "^0.64.12",
20
20
  "@types/node": "^22.13.4",
21
+ "@types/node-forge": "^1.3.11",
21
22
  "openapi-typescript-codegen": "^0.29.0",
23
+ "ts-node": "^10.9.2",
22
24
  "typescript": "^5.7.3"
23
25
  },
24
26
  "dependencies": {
25
- "@hey-api/client-fetch": "^0.8.3"
27
+ "@hey-api/client-fetch": "^0.8.3",
28
+ "node-forge": "^1.3.1"
26
29
  },
27
30
  "scripts": {
28
31
  "build": "tsc",