libretto 0.6.20 → 0.6.21

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.
@@ -64,8 +64,11 @@ function createLibrettoCloudProvider() {
64
64
  };
65
65
  },
66
66
  async closeSession(sessionId) {
67
- const json = await closeCloudSession(endpoint, apiKey, sessionId);
68
- return { replayUrl: json.replay_url ?? void 0 };
67
+ await closeCloudSession(endpoint, apiKey, sessionId);
68
+ const replayUrl = await getCloudRecordingUrl(endpoint, apiKey, sessionId).catch(
69
+ () => void 0
70
+ );
71
+ return { replayUrl };
69
72
  }
70
73
  };
71
74
  }
@@ -153,8 +156,24 @@ async function closeCloudSession(endpoint, apiKey, sessionId) {
153
156
  `Libretto Cloud API error closing session ${sessionId} (${resp.status}): ${body}`
154
157
  );
155
158
  }
159
+ }
160
+ async function getCloudRecordingUrl(endpoint, apiKey, sessionId) {
161
+ const resp = await fetch(`${endpoint}/v1/recordings/get`, {
162
+ method: "POST",
163
+ headers: {
164
+ "x-api-key": apiKey,
165
+ "Content-Type": "application/json"
166
+ },
167
+ body: JSON.stringify({ json: { session_id: sessionId } })
168
+ });
169
+ if (!resp.ok) {
170
+ const body = await resp.text();
171
+ throw new Error(
172
+ `Libretto Cloud API error reading recording for session ${sessionId} (${resp.status}): ${body}`
173
+ );
174
+ }
156
175
  const { json } = await resp.json();
157
- return json;
176
+ return json.recording_url ?? void 0;
158
177
  }
159
178
  function createStartupSessionCleanup(endpoint, apiKey, sessionId) {
160
179
  let cancelled = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libretto",
3
- "version": "0.6.20",
3
+ "version": "0.6.21",
4
4
  "description": "AI-powered browser automation library and CLI built on Playwright",
5
5
  "license": "MIT",
6
6
  "homepage": "https://libretto.sh",
@@ -4,7 +4,7 @@ description: "Browser automation CLI for building, maintaining, and running brow
4
4
  license: MIT
5
5
  metadata:
6
6
  author: saffron-health
7
- version: "0.6.20"
7
+ version: "0.6.21"
8
8
  ---
9
9
 
10
10
  ## How Libretto Works
@@ -4,7 +4,7 @@ description: "Read-only Libretto workflow for diagnosing live browser state with
4
4
  license: MIT
5
5
  metadata:
6
6
  author: saffron-health
7
- version: "0.6.20"
7
+ version: "0.6.21"
8
8
  ---
9
9
 
10
10
  ## How Libretto Read-Only Works
@@ -6,7 +6,6 @@ type CloudSessionResponse = {
6
6
  status: string;
7
7
  cdp_url: string | null;
8
8
  live_view_url: string | null;
9
- recording_url: string | null;
10
9
  };
11
10
 
12
11
  const DEFAULT_POLL_INTERVAL_MS = 2_000;
@@ -77,8 +76,11 @@ export function createLibrettoCloudProvider(): ProviderApi {
77
76
  };
78
77
  },
79
78
  async closeSession(sessionId) {
80
- const json = await closeCloudSession(endpoint, apiKey, sessionId);
81
- return { replayUrl: json.replay_url ?? undefined };
79
+ await closeCloudSession(endpoint, apiKey, sessionId);
80
+ const replayUrl = await getCloudRecordingUrl(endpoint, apiKey, sessionId).catch(
81
+ () => undefined,
82
+ );
83
+ return { replayUrl };
82
84
  },
83
85
  };
84
86
  }
@@ -172,7 +174,7 @@ async function closeCloudSession(
172
174
  endpoint: string,
173
175
  apiKey: string,
174
176
  sessionId: string,
175
- ): Promise<{ replay_url: string | null }> {
177
+ ): Promise<void> {
176
178
  const resp = await fetch(`${endpoint}/v1/sessions/close`, {
177
179
  method: "POST",
178
180
  headers: {
@@ -187,10 +189,31 @@ async function closeCloudSession(
187
189
  `Libretto Cloud API error closing session ${sessionId} (${resp.status}): ${body}`,
188
190
  );
189
191
  }
192
+ }
193
+
194
+ async function getCloudRecordingUrl(
195
+ endpoint: string,
196
+ apiKey: string,
197
+ sessionId: string,
198
+ ): Promise<string | undefined> {
199
+ const resp = await fetch(`${endpoint}/v1/recordings/get`, {
200
+ method: "POST",
201
+ headers: {
202
+ "x-api-key": apiKey,
203
+ "Content-Type": "application/json",
204
+ },
205
+ body: JSON.stringify({ json: { session_id: sessionId } }),
206
+ });
207
+ if (!resp.ok) {
208
+ const body = await resp.text();
209
+ throw new Error(
210
+ `Libretto Cloud API error reading recording for session ${sessionId} (${resp.status}): ${body}`,
211
+ );
212
+ }
190
213
  const { json } = (await resp.json()) as {
191
- json: { replay_url: string | null };
214
+ json: { recording_url: string | null };
192
215
  };
193
- return json;
216
+ return json.recording_url ?? undefined;
194
217
  }
195
218
 
196
219
  function createStartupSessionCleanup(