@vertesia/client 0.61.0 → 0.62.0

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.
@@ -38,8 +38,9 @@ export class WorkflowsApi extends ApiTopic {
38
38
  return this.post(`/runs/${workflowId}/${runId}/signal/${signal}`, { payload });
39
39
  }
40
40
 
41
- getRunDetails(runId: string, workflowId: string): Promise<WorkflowRunWithDetails> {
42
- return this.get(`/runs/${workflowId}/${runId}`);
41
+ getRunDetails(runId: string, workflowId: string, includeHistory: boolean = false): Promise<WorkflowRunWithDetails> {
42
+ const query = { include_history: includeHistory };
43
+ return this.get(`/runs/${workflowId}/${runId}`, { query });
43
44
  }
44
45
 
45
46
  terminate(workflowId: string, runId: string, reason?: string): Promise<{ message: string }> {
@@ -116,31 +117,31 @@ export class WorkflowsApi extends ApiTopic {
116
117
  const EventSourceImpl = await EventSourceProvider();
117
118
  const client = this.client as VertesiaClient;
118
119
  const streamUrl = new URL(client.workflows.baseUrl + "/runs/" + runId + "/stream");
119
-
120
+
120
121
  // Use the timestamp of the last received message for reconnection
121
122
  if (lastMessageTimestamp > 0) {
122
123
  streamUrl.searchParams.set("since", lastMessageTimestamp.toString());
123
124
  }
124
-
125
+
125
126
  const bearerToken = client._auth ? await client._auth() : undefined;
126
127
  if (!bearerToken) {
127
128
  reject(new Error("No auth token available"));
128
129
  return;
129
130
  }
130
-
131
+
131
132
  const token = bearerToken.split(" ")[1];
132
133
  streamUrl.searchParams.set("access_token", token);
133
134
 
134
135
  if (isReconnect) {
135
136
  console.log(`Reconnecting to SSE stream for run ${runId} (attempt ${reconnectAttempts + 1}/${maxReconnectAttempts})`);
136
137
  }
137
-
138
+
138
139
  const sse = new EventSourceImpl(streamUrl.href);
139
140
  currentSse = sse;
140
-
141
+
141
142
  // Prevent Node from exiting prematurely
142
- interval = setInterval(() => {}, 1000);
143
-
143
+ interval = setInterval(() => { }, 1000);
144
+
144
145
  sse.onopen = () => {
145
146
  if (isReconnect) {
146
147
  console.log(`Successfully reconnected to SSE stream for run ${runId}`);
@@ -154,17 +155,17 @@ export class WorkflowsApi extends ApiTopic {
154
155
  console.log("Received comment or heartbeat; ignoring it.: ", ev.data);
155
156
  return;
156
157
  }
157
-
158
+
158
159
  try {
159
160
  const message = JSON.parse(ev.data) as AgentMessage;
160
-
161
+
161
162
  // Update last message timestamp for reconnection
162
163
  if (message.timestamp) {
163
164
  lastMessageTimestamp = Math.max(lastMessageTimestamp, message.timestamp);
164
165
  }
165
166
 
166
167
  if (onMessage) onMessage(message, exit);
167
-
168
+
168
169
  // Only close the stream when the main workstream completes
169
170
  if (message.type === AgentMessageType.COMPLETE && (!message.workstream_id || message.workstream_id === 'main')) {
170
171
  console.log("Closing stream due to COMPLETE message from main workstream");
@@ -180,7 +181,7 @@ export class WorkflowsApi extends ApiTopic {
180
181
  console.error("Failed to parse SSE message:", err, ev.data);
181
182
  }
182
183
  };
183
-
184
+
184
185
  sse.onerror = (err: any) => {
185
186
  if (isClosed) return;
186
187
 
@@ -191,7 +192,7 @@ export class WorkflowsApi extends ApiTopic {
191
192
  if (reconnectAttempts < maxReconnectAttempts) {
192
193
  const delay = calculateBackoffDelay(reconnectAttempts);
193
194
  console.log(`Attempting to reconnect in ${delay}ms (attempt ${reconnectAttempts + 1}/${maxReconnectAttempts})`);
194
-
195
+
195
196
  reconnectAttempts++;
196
197
  setTimeout(() => {
197
198
  if (!isClosed) {
@@ -219,7 +220,7 @@ export class WorkflowsApi extends ApiTopic {
219
220
  }
220
221
  }
221
222
  };
222
-
223
+
223
224
  // Start the async setup process
224
225
  setupStream(false);
225
226