@lightcone-ai/daemon 0.14.12 → 0.14.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightcone-ai/daemon",
3
- "version": "0.14.12",
3
+ "version": "0.14.13",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -148,6 +148,31 @@ export async function fetchPublishJobWorkspaceFile({ serverUrl, machineApiKey, j
148
148
  return res.json();
149
149
  }
150
150
 
151
+ export async function streamPublishJobVideo({ serverUrl, machineApiKey, jobId, videoId, localPath }) {
152
+ const normalizedJobId = String(jobId ?? '').trim();
153
+ if (!normalizedJobId) {
154
+ throw new Error('publish job id is required to fetch video files');
155
+ }
156
+ const normalizedVideoId = String(videoId ?? '').trim();
157
+ if (!normalizedVideoId) {
158
+ throw new Error('video id is required to fetch video files');
159
+ }
160
+ const url = `${String(serverUrl).replace(/\/$/, '')}/internal/agent/publish-jobs/${encodeURIComponent(normalizedJobId)}/video-files/${encodeURIComponent(normalizedVideoId)}`;
161
+ const res = await fetch(url, {
162
+ headers: {
163
+ Authorization: `Bearer ${machineApiKey}`,
164
+ },
165
+ });
166
+ if (!res.ok) {
167
+ const text = await res.text().catch(() => '');
168
+ throw new Error(`publish-jobs video-files GET failed (${res.status}): ${text}`);
169
+ }
170
+ const data = Buffer.from(await res.arrayBuffer());
171
+ mkdirSync(path.dirname(localPath), { recursive: true });
172
+ writeFileSync(localPath, data);
173
+ return localPath;
174
+ }
175
+
151
176
  export function workspacePathFromMediaPath(filePath, workspaceId) {
152
177
  if (!filePath) return null;
153
178
 
@@ -182,6 +207,7 @@ export async function materializeWorkspaceMedia({
182
207
  machineApiKey,
183
208
  jobId,
184
209
  fetchWorkspaceFile = fetchPublishJobWorkspaceFile,
210
+ streamVideoFile = streamPublishJobVideo,
185
211
  }) {
186
212
  if (!filePath || existsSync(filePath)) return filePath;
187
213
 
@@ -202,8 +228,18 @@ export async function materializeWorkspaceMedia({
202
228
  jobId,
203
229
  relPath: workspacePath.relPath,
204
230
  });
205
- mkdirSync(path.dirname(localPath), { recursive: true });
206
- writeFileSync(localPath, decodeWorkspaceContent(data.content));
231
+ if (data?.videoId) {
232
+ await streamVideoFile({
233
+ serverUrl,
234
+ machineApiKey,
235
+ jobId,
236
+ videoId: data.videoId,
237
+ localPath,
238
+ });
239
+ } else {
240
+ mkdirSync(path.dirname(localPath), { recursive: true });
241
+ writeFileSync(localPath, decodeWorkspaceContent(data.content));
242
+ }
207
243
  return localPath;
208
244
  }
209
245