asteroid-odyssey 1.0.24 → 1.1.2

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.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Client } from '@hey-api/client-fetch';
2
- import type { CreateWorkflowRequest, WorkflowExecutionRequest, Execution, BrowserSession } from './generated/agents/types.gen';
2
+ import type { StructuredAgentExecutionRequest, ExecutionStatusResponse, BrowserSessionRecordingResponse } from './generated/agents/types.gen';
3
3
  /**
4
4
  * Create an API client with a provided API key.
5
5
  *
@@ -13,97 +13,88 @@ export declare const AsteroidClient: (apiKey: string, options?: {
13
13
  baseUrl?: string;
14
14
  }) => Client;
15
15
  /**
16
- * Create a new workflow for a given agent.
16
+ * Execute an agent with parameters including optional agent profile ID.
17
17
  *
18
18
  * @param client - The API client.
19
- * @param agentName - The name of the agent.
20
- * @param workflowDetails - The workflow details.
21
- * @returns The ID of the created workflow.
19
+ * @param agentId - The ID of the agent to execute.
20
+ * @param executionData - The structured execution parameters.
21
+ * @returns The execution ID.
22
22
  *
23
23
  * @example
24
- * const workflowId = await createNewWorkflow(client, 'my-agent', {
25
- * name: "Example Workflow",
26
- * start_url: "https://google.com",
27
- * prompts: ["On Google, search for {{.website}} and sign in with {{.credentials}}"],
28
- * result_schema: {},
29
- * provider: 'openai'
24
+ * const executionId = await executeAgent(client, 'my-agent-id', {
25
+ * agent_profile_id: 'profile-123',
26
+ * dynamic_data: { input: "some dynamic value" }
30
27
  * });
31
28
  */
32
- export declare const createNewWorkflow: (client: Client, agentName: string, workflowDetails: CreateWorkflowRequest) => Promise<string>;
29
+ export declare const executeAgent: (client: Client, agentId: string, executionData: StructuredAgentExecutionRequest) => Promise<string>;
33
30
  /**
34
- * Execute an existing workflow.
31
+ * Get the current status for an execution.
35
32
  *
36
33
  * @param client - The API client.
37
- * @param workflowId - The workflow identifier.
38
- * @param executionData - The dynamic data to merge with the workflow.
39
- * @returns The execution ID.
34
+ * @param executionId - The execution identifier.
35
+ * @returns The execution status details.
40
36
  *
41
37
  * @example
42
- * const executionId = await executeWorkflowById(client, workflowId, { input: "some dynamic value" });
38
+ * const status = await getExecutionStatus(client, executionId);
39
+ * console.log(status.status);
43
40
  */
44
- export declare const executeWorkflowById: (client: Client, workflowId: string, executionData: WorkflowExecutionRequest) => Promise<string>;
41
+ export declare const getExecutionStatus: (client: Client, executionId: string) => Promise<ExecutionStatusResponse>;
45
42
  /**
46
- * Get the current status and details for a workflow execution.
43
+ * Get the final result of an execution.
47
44
  *
48
45
  * @param client - The API client.
49
46
  * @param executionId - The execution identifier.
50
- * @returns The execution details.
47
+ * @returns The result object of the execution.
51
48
  *
52
49
  * @example
53
- * const execution = await getExecutionStatus(client, executionId);
54
- * console.log(execution.status);
50
+ * const result = await getExecutionResult(client, executionId);
51
+ * console.log(result);
55
52
  */
56
- export declare const getExecutionStatus: (client: Client, executionId: string) => Promise<Execution>;
53
+ export declare const getExecutionResult: (client: Client, executionId: string) => Promise<Record<string, unknown>>;
57
54
  /**
58
- * Get the progress updates for an execution.
55
+ * Waits for an execution to reach a terminal state and returns the result.
56
+ * Continuously polls the execution status until it's either "completed", "cancelled", or "failed".
59
57
  *
60
58
  * @param client - The API client.
61
59
  * @param executionId - The execution identifier.
62
- * @returns Array of progress update objects.
60
+ * @param interval - Polling interval in milliseconds (default is 1000ms).
61
+ * @returns A promise that resolves with the execution result if completed.
62
+ * @throws An error if the execution ends as "cancelled" or "failed".
63
63
  *
64
64
  * @example
65
- * const progressUpdates = await getWorkflowExecutionProgress(client, executionId);
66
- * console.log(progressUpdates);
65
+ * const result = await waitForExecutionResult(client, executionId, 2000);
67
66
  */
68
- export declare const getWorkflowExecutionProgress: (client: Client, executionId: string) => Promise<Array<{
69
- execution_id: string;
70
- progress: string;
71
- created_at: string;
72
- }>>;
67
+ export declare const waitForExecutionResult: (client: Client, executionId: string, interval?: number, timeout?: number) => Promise<Record<string, unknown>>;
73
68
  /**
74
- * Get the final result of a workflow execution.
69
+ * Get the browser session recording URL for a completed execution.
75
70
  *
76
71
  * @param client - The API client.
77
72
  * @param executionId - The execution identifier.
78
- * @returns The result object of the execution.
73
+ * @returns The browser session recording URL.
79
74
  *
80
75
  * @example
81
- * const result = await getWorkflowResult(client, executionId);
82
- * console.log(result);
76
+ * const recording = await getBrowserSessionRecording(client, executionId);
77
+ * console.log(recording.recording_url);
83
78
  */
84
- export declare const getWorkflowResult: (client: Client, executionId: string) => Promise<Record<string, unknown>>;
79
+ export declare const getBrowserSessionRecording: (client: Client, executionId: string) => Promise<BrowserSessionRecordingResponse>;
85
80
  /**
86
- * Get the browser session for an execution.
81
+ * Upload files to an execution.
87
82
  *
88
83
  * @param client - The API client.
89
84
  * @param executionId - The execution identifier.
90
- * @returns The browser session.
91
- */
92
- export declare const getBrowserSession: (client: Client, executionId: string) => Promise<BrowserSession>;
93
- /**
94
- * Waits for a workflow execution to reach a terminal state and returns the result.
95
- * Continuously polls the execution status until it's either "completed", "cancelled", or "failed".
96
- *
97
- * @param client - The API client.
98
- * @param executionId - The execution identifier.
99
- * @param interval - Polling interval in milliseconds (default is 1000ms).
100
- * @returns A promise that resolves with the workflow execution result if completed.
101
- * @throws An error if the execution ends as "cancelled" or "failed".
85
+ * @param files - Array of files to upload.
86
+ * @returns The uploaded file IDs and success message.
102
87
  *
103
88
  * @example
104
- * const result = await waitForExecutionResult(client, executionId, 2000);
89
+ * const fileInput = document.getElementById('file-input') as HTMLInputElement;
90
+ * const files = Array.from(fileInput.files || []);
91
+ * const result = await uploadExecutionFiles(client, executionId, files);
92
+ * console.log(result.file_ids);
105
93
  */
106
- export declare const waitForExecutionResult: (client: Client, executionId: string, interval?: number, timeout?: number) => Promise<Record<string, unknown>>;
94
+ export declare const uploadExecutionFiles: (client: Client, executionId: string, files: Array<Blob | File>) => Promise<{
95
+ message?: string;
96
+ file_ids?: string[];
97
+ }>;
107
98
  /**
108
99
  * Optionally, re-export all generated functions and types.
109
100
  */
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ 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.waitForExecutionResult = exports.getBrowserSession = exports.getWorkflowResult = exports.getWorkflowExecutionProgress = exports.getExecutionStatus = exports.executeWorkflowById = exports.createNewWorkflow = exports.AsteroidClient = void 0;
39
+ 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
42
  /**
@@ -58,144 +58,86 @@ const AsteroidClient = (apiKey, options) => {
58
58
  };
59
59
  exports.AsteroidClient = AsteroidClient;
60
60
  /**
61
- * Create a new workflow for a given agent.
61
+ * Execute an agent with parameters including optional agent profile ID.
62
62
  *
63
63
  * @param client - The API client.
64
- * @param agentName - The name of the agent.
65
- * @param workflowDetails - The workflow details.
66
- * @returns The ID of the created workflow.
67
- *
68
- * @example
69
- * const workflowId = await createNewWorkflow(client, 'my-agent', {
70
- * name: "Example Workflow",
71
- * start_url: "https://google.com",
72
- * prompts: ["On Google, search for {{.website}} and sign in with {{.credentials}}"],
73
- * result_schema: {},
74
- * provider: 'openai'
75
- * });
76
- */
77
- const createNewWorkflow = async (client, agentName, workflowDetails) => {
78
- const response = await AgentsSDK.createWorkflow({
79
- client,
80
- path: { agent_name: agentName },
81
- body: workflowDetails,
82
- });
83
- if (response.error) {
84
- console.log(response.error);
85
- throw new Error(response.error);
86
- }
87
- return response.data;
88
- };
89
- exports.createNewWorkflow = createNewWorkflow;
90
- /**
91
- * Execute an existing workflow.
92
- *
93
- * @param client - The API client.
94
- * @param workflowId - The workflow identifier.
95
- * @param executionData - The dynamic data to merge with the workflow.
64
+ * @param agentId - The ID of the agent to execute.
65
+ * @param executionData - The structured execution parameters.
96
66
  * @returns The execution ID.
97
67
  *
98
68
  * @example
99
- * const executionId = await executeWorkflowById(client, workflowId, { input: "some dynamic value" });
69
+ * const executionId = await executeAgent(client, 'my-agent-id', {
70
+ * agent_profile_id: 'profile-123',
71
+ * dynamic_data: { input: "some dynamic value" }
72
+ * });
100
73
  */
101
- const executeWorkflowById = async (client, workflowId, executionData) => {
102
- const response = await AgentsSDK.executeWorkflow({
74
+ const executeAgent = async (client, agentId, executionData) => {
75
+ const response = await AgentsSDK.executeAgentStructured({
103
76
  client,
104
- path: { workflow_id: workflowId },
77
+ path: { id: agentId },
105
78
  body: executionData,
106
79
  });
107
80
  if (response.error) {
108
- throw new Error(response.error);
81
+ throw new Error(response.error.error);
109
82
  }
110
- return response.data;
83
+ return response.data.execution_id;
111
84
  };
112
- exports.executeWorkflowById = executeWorkflowById;
85
+ exports.executeAgent = executeAgent;
113
86
  /**
114
- * Get the current status and details for a workflow execution.
87
+ * Get the current status for an execution.
115
88
  *
116
89
  * @param client - The API client.
117
90
  * @param executionId - The execution identifier.
118
- * @returns The execution details.
91
+ * @returns The execution status details.
119
92
  *
120
93
  * @example
121
- * const execution = await getExecutionStatus(client, executionId);
122
- * console.log(execution.status);
94
+ * const status = await getExecutionStatus(client, executionId);
95
+ * console.log(status.status);
123
96
  */
124
97
  const getExecutionStatus = async (client, executionId) => {
125
- const execution = await AgentsSDK.getExecution({
98
+ const response = await AgentsSDK.getExecutionStatus({
126
99
  client,
127
100
  path: { id: executionId },
128
101
  });
129
- if (execution.error) {
130
- throw new Error(execution.error);
102
+ if (response.error) {
103
+ throw new Error(response.error.error);
131
104
  }
132
- return execution.data;
105
+ return response.data;
133
106
  };
134
107
  exports.getExecutionStatus = getExecutionStatus;
135
108
  /**
136
- * Get the progress updates for an execution.
137
- *
138
- * @param client - The API client.
139
- * @param executionId - The execution identifier.
140
- * @returns Array of progress update objects.
141
- *
142
- * @example
143
- * const progressUpdates = await getWorkflowExecutionProgress(client, executionId);
144
- * console.log(progressUpdates);
145
- */
146
- const getWorkflowExecutionProgress = async (client, executionId) => {
147
- const progressUpdates = await AgentsSDK.getExecutionProgress({
148
- client,
149
- path: { id: executionId },
150
- });
151
- if (progressUpdates.error) {
152
- throw new Error(progressUpdates.error);
153
- }
154
- return progressUpdates.data;
155
- };
156
- exports.getWorkflowExecutionProgress = getWorkflowExecutionProgress;
157
- /**
158
- * Get the final result of a workflow execution.
109
+ * Get the final result of an execution.
159
110
  *
160
111
  * @param client - The API client.
161
112
  * @param executionId - The execution identifier.
162
113
  * @returns The result object of the execution.
163
114
  *
164
115
  * @example
165
- * const result = await getWorkflowResult(client, executionId);
116
+ * const result = await getExecutionResult(client, executionId);
166
117
  * console.log(result);
167
118
  */
168
- const getWorkflowResult = async (client, executionId) => {
169
- const execution = await (0, exports.getExecutionStatus)(client, executionId);
170
- return execution.result;
171
- };
172
- exports.getWorkflowResult = getWorkflowResult;
173
- /**
174
- * Get the browser session for an execution.
175
- *
176
- * @param client - The API client.
177
- * @param executionId - The execution identifier.
178
- * @returns The browser session.
179
- */
180
- const getBrowserSession = async (client, executionId) => {
181
- const browserSession = await AgentsSDK.getBrowserSession({
119
+ const getExecutionResult = async (client, executionId) => {
120
+ const response = await AgentsSDK.getExecutionResult({
182
121
  client,
183
122
  path: { id: executionId },
184
123
  });
185
- if (browserSession.error) {
186
- throw new Error(browserSession.error);
124
+ if (response.error) {
125
+ throw new Error(response.error.error);
126
+ }
127
+ if (response.data.error) {
128
+ throw new Error(response.data.error);
187
129
  }
188
- return browserSession.data;
130
+ return response.data.result || {};
189
131
  };
190
- exports.getBrowserSession = getBrowserSession;
132
+ exports.getExecutionResult = getExecutionResult;
191
133
  /**
192
- * Waits for a workflow execution to reach a terminal state and returns the result.
134
+ * Waits for an execution to reach a terminal state and returns the result.
193
135
  * Continuously polls the execution status until it's either "completed", "cancelled", or "failed".
194
136
  *
195
137
  * @param client - The API client.
196
138
  * @param executionId - The execution identifier.
197
139
  * @param interval - Polling interval in milliseconds (default is 1000ms).
198
- * @returns A promise that resolves with the workflow execution result if completed.
140
+ * @returns A promise that resolves with the execution result if completed.
199
141
  * @throws An error if the execution ends as "cancelled" or "failed".
200
142
  *
201
143
  * @example
@@ -206,13 +148,13 @@ const waitForExecutionResult = async (client, executionId, interval = 1000, time
206
148
  var steps = Math.floor(timeout / interval);
207
149
  // Keep polling the execution status until it's either "completed", "cancelled", or "failed".
208
150
  while (steps > 0) {
209
- const execution = await (0, exports.getExecutionStatus)(client, executionId);
210
- const currentStatus = execution.status?.status;
151
+ const status = await (0, exports.getExecutionStatus)(client, executionId);
152
+ const currentStatus = status.status;
211
153
  if (currentStatus === 'completed') {
212
- return await (0, exports.getWorkflowResult)(client, executionId);
154
+ return await (0, exports.getExecutionResult)(client, executionId);
213
155
  }
214
156
  else if (currentStatus === 'failed' || currentStatus === 'cancelled') {
215
- throw new Error(`Execution ${executionId} ended with status: ${currentStatus}${execution.status?.reason ? ' - ' + execution.status.reason : ''}`);
157
+ throw new Error(`Execution ${executionId} ended with status: ${currentStatus}${status.reason ? ' - ' + status.reason : ''}`);
216
158
  }
217
159
  // Wait for the specified interval before polling again
218
160
  await new Promise(resolve => setTimeout(resolve, interval));
@@ -221,6 +163,54 @@ const waitForExecutionResult = async (client, executionId, interval = 1000, time
221
163
  throw new Error(`Execution ${executionId} timed out after ${timeout}ms`);
222
164
  };
223
165
  exports.waitForExecutionResult = waitForExecutionResult;
166
+ /**
167
+ * Get the browser session recording URL for a completed execution.
168
+ *
169
+ * @param client - The API client.
170
+ * @param executionId - The execution identifier.
171
+ * @returns The browser session recording URL.
172
+ *
173
+ * @example
174
+ * const recording = await getBrowserSessionRecording(client, executionId);
175
+ * console.log(recording.recording_url);
176
+ */
177
+ const getBrowserSessionRecording = async (client, executionId) => {
178
+ const response = await AgentsSDK.getBrowserSessionRecording({
179
+ client,
180
+ path: { id: executionId },
181
+ });
182
+ if (response.error) {
183
+ throw new Error(response.error.error);
184
+ }
185
+ return response.data;
186
+ };
187
+ exports.getBrowserSessionRecording = getBrowserSessionRecording;
188
+ /**
189
+ * Upload files to an execution.
190
+ *
191
+ * @param client - The API client.
192
+ * @param executionId - The execution identifier.
193
+ * @param files - Array of files to upload.
194
+ * @returns The uploaded file IDs and success message.
195
+ *
196
+ * @example
197
+ * const fileInput = document.getElementById('file-input') as HTMLInputElement;
198
+ * const files = Array.from(fileInput.files || []);
199
+ * const result = await uploadExecutionFiles(client, executionId, files);
200
+ * console.log(result.file_ids);
201
+ */
202
+ const uploadExecutionFiles = async (client, executionId, files) => {
203
+ const response = await AgentsSDK.uploadExecutionFiles({
204
+ client,
205
+ path: { id: executionId },
206
+ body: { files },
207
+ });
208
+ if (response.error) {
209
+ throw new Error(response.error.error);
210
+ }
211
+ return response.data;
212
+ };
213
+ exports.uploadExecutionFiles = uploadExecutionFiles;
224
214
  /**
225
215
  * Optionally, re-export all generated functions and types.
226
216
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asteroid-odyssey",
3
- "version": "v1.0.24",
3
+ "version": "v1.1.2",
4
4
  "description": "SDK for interacting with Asteroid Agents API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",