@lightcone-ai/daemon 0.14.10 → 0.14.11
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 +1 -1
- package/src/publish-job-runner.js +24 -16
package/package.json
CHANGED
|
@@ -92,19 +92,20 @@ function decodeWorkspaceContent(content) {
|
|
|
92
92
|
return Buffer.from(decodeURIComponent(body), 'utf8');
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
async function
|
|
96
|
-
const
|
|
95
|
+
export async function fetchPublishJobWorkspaceFile({ serverUrl, machineApiKey, jobId, relPath }) {
|
|
96
|
+
const normalizedJobId = String(jobId ?? '').trim();
|
|
97
|
+
if (!normalizedJobId) {
|
|
98
|
+
throw new Error('publish job id is required to fetch workspace files');
|
|
99
|
+
}
|
|
100
|
+
const url = `${String(serverUrl).replace(/\/$/, '')}/internal/agent/publish-jobs/${encodeURIComponent(normalizedJobId)}/workspace-files?path=${encodeURIComponent(relPath)}`;
|
|
97
101
|
const res = await fetch(url, {
|
|
98
|
-
method,
|
|
99
102
|
headers: {
|
|
100
|
-
'Content-Type': 'application/json',
|
|
101
103
|
Authorization: `Bearer ${machineApiKey}`,
|
|
102
104
|
},
|
|
103
|
-
body: body != null ? JSON.stringify(body) : undefined,
|
|
104
105
|
});
|
|
105
106
|
if (!res.ok) {
|
|
106
107
|
const text = await res.text();
|
|
107
|
-
throw new Error(`
|
|
108
|
+
throw new Error(`publish-jobs workspace-files GET failed (${res.status}): ${text}`);
|
|
108
109
|
}
|
|
109
110
|
return res.json();
|
|
110
111
|
}
|
|
@@ -135,7 +136,15 @@ export function workspacePathFromMediaPath(filePath, workspaceId) {
|
|
|
135
136
|
return null;
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
async function materializeWorkspaceMedia({
|
|
139
|
+
export async function materializeWorkspaceMedia({
|
|
140
|
+
filePath,
|
|
141
|
+
workspaceId,
|
|
142
|
+
workspaceRootDir,
|
|
143
|
+
serverUrl,
|
|
144
|
+
machineApiKey,
|
|
145
|
+
jobId,
|
|
146
|
+
fetchWorkspaceFile = fetchPublishJobWorkspaceFile,
|
|
147
|
+
}) {
|
|
139
148
|
if (!filePath || existsSync(filePath)) return filePath;
|
|
140
149
|
|
|
141
150
|
const workspacePath = workspacePathFromMediaPath(filePath, workspaceId);
|
|
@@ -149,12 +158,11 @@ async function materializeWorkspaceMedia({ filePath, workspaceId, workspaceRootD
|
|
|
149
158
|
|
|
150
159
|
if (existsSync(localPath)) return localPath;
|
|
151
160
|
|
|
152
|
-
const data = await
|
|
161
|
+
const data = await fetchWorkspaceFile({
|
|
153
162
|
serverUrl,
|
|
154
163
|
machineApiKey,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
endpoint: `/workspace-memory?path=${encodeURIComponent(workspacePath.relPath)}&workspaceId=${encodeURIComponent(workspacePath.workspaceId)}`,
|
|
164
|
+
jobId,
|
|
165
|
+
relPath: workspacePath.relPath,
|
|
158
166
|
});
|
|
159
167
|
mkdirSync(path.dirname(localPath), { recursive: true });
|
|
160
168
|
writeFileSync(localPath, decodeWorkspaceContent(data.content));
|
|
@@ -169,7 +177,7 @@ async function materializeMedia({
|
|
|
169
177
|
workspaceRootDir,
|
|
170
178
|
serverUrl,
|
|
171
179
|
machineApiKey,
|
|
172
|
-
|
|
180
|
+
jobId,
|
|
173
181
|
}) {
|
|
174
182
|
return {
|
|
175
183
|
images: await Promise.all(images.map(filePath => materializeWorkspaceMedia({
|
|
@@ -178,7 +186,7 @@ async function materializeMedia({
|
|
|
178
186
|
workspaceRootDir,
|
|
179
187
|
serverUrl,
|
|
180
188
|
machineApiKey,
|
|
181
|
-
|
|
189
|
+
jobId,
|
|
182
190
|
}))),
|
|
183
191
|
video: video ? await materializeWorkspaceMedia({
|
|
184
192
|
filePath: video,
|
|
@@ -186,7 +194,7 @@ async function materializeMedia({
|
|
|
186
194
|
workspaceRootDir,
|
|
187
195
|
serverUrl,
|
|
188
196
|
machineApiKey,
|
|
189
|
-
|
|
197
|
+
jobId,
|
|
190
198
|
}) : video,
|
|
191
199
|
cover: cover ? await materializeWorkspaceMedia({
|
|
192
200
|
filePath: cover,
|
|
@@ -194,7 +202,7 @@ async function materializeMedia({
|
|
|
194
202
|
workspaceRootDir,
|
|
195
203
|
serverUrl,
|
|
196
204
|
machineApiKey,
|
|
197
|
-
|
|
205
|
+
jobId,
|
|
198
206
|
}) : cover,
|
|
199
207
|
};
|
|
200
208
|
}
|
|
@@ -404,7 +412,7 @@ export async function runPublishJob({ serverUrl, machineApiKey, agentId, workspa
|
|
|
404
412
|
workspaceRootDir,
|
|
405
413
|
serverUrl,
|
|
406
414
|
machineApiKey,
|
|
407
|
-
|
|
415
|
+
jobId: job?.id,
|
|
408
416
|
});
|
|
409
417
|
const staticAdapter = createStaticAdapter(platform);
|
|
410
418
|
const req = staticAdapter.getRequirements(contentType);
|