@ricsam/r5d-worker 0.0.44 → 0.0.45
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/cjs/main.cjs +53 -13
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/main.mjs +53 -13
- package/dist/mjs/package.json +1 -1
- package/package.json +1 -1
package/dist/cjs/main.cjs
CHANGED
|
@@ -431,21 +431,32 @@ async function fetchSessionArtifactManifest(input) {
|
|
|
431
431
|
label: "artifact"
|
|
432
432
|
});
|
|
433
433
|
}
|
|
434
|
+
const sessionArtifactSyncQueues = /* @__PURE__ */ new Map();
|
|
434
435
|
async function syncSessionArtifacts(input) {
|
|
435
|
-
const
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
targetDir,
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
download: (artifact) => downloadRemoteSyncedFile({
|
|
442
|
-
url: artifactDownloadUrl(input.baseUrl, input.projectId, input.branchName, input.sessionId, artifact.filename),
|
|
443
|
-
token: input.token,
|
|
436
|
+
const queueKey = `${import_node_path.default.resolve(input.artifactRoot)}\0${input.sessionId}`;
|
|
437
|
+
const previous = sessionArtifactSyncQueues.get(queueKey);
|
|
438
|
+
const queued = (previous ? previous.catch(() => "") : Promise.resolve("")).then(async () => {
|
|
439
|
+
const targetDir = sessionArtifactDir(input.artifactRoot, input.sessionId);
|
|
440
|
+
const artifacts = await fetchSessionArtifactManifest(input);
|
|
441
|
+
return syncRemoteFileSet({
|
|
444
442
|
targetDir,
|
|
445
|
-
|
|
446
|
-
label: "
|
|
447
|
-
|
|
443
|
+
files: artifacts,
|
|
444
|
+
label: "Artifact path",
|
|
445
|
+
download: (artifact) => downloadRemoteSyncedFile({
|
|
446
|
+
url: artifactDownloadUrl(input.baseUrl, input.projectId, input.branchName, input.sessionId, artifact.filename),
|
|
447
|
+
token: input.token,
|
|
448
|
+
targetDir,
|
|
449
|
+
file: artifact,
|
|
450
|
+
label: "artifact"
|
|
451
|
+
})
|
|
452
|
+
});
|
|
448
453
|
});
|
|
454
|
+
sessionArtifactSyncQueues.set(queueKey, queued);
|
|
455
|
+
const release = () => {
|
|
456
|
+
if (sessionArtifactSyncQueues.get(queueKey) === queued) sessionArtifactSyncQueues.delete(queueKey);
|
|
457
|
+
};
|
|
458
|
+
void queued.then(release, release);
|
|
459
|
+
return queued;
|
|
449
460
|
}
|
|
450
461
|
async function resolveArtifactEnvFilePath(input) {
|
|
451
462
|
if (!isArtifactEnvPath(input.filePath)) {
|
|
@@ -2091,6 +2102,7 @@ async function startWorker(options) {
|
|
|
2091
2102
|
let periodicWorkspaceScanInFlight = false;
|
|
2092
2103
|
let terminalReplayTimer;
|
|
2093
2104
|
let workspaceSyncRequestsInFlight = 0;
|
|
2105
|
+
let sessionArtifactSyncRequestsInFlight = 0;
|
|
2094
2106
|
let cliUpdateInProgress = false;
|
|
2095
2107
|
let reloadAfterClose = false;
|
|
2096
2108
|
const workspaceSyncInput = (trigger, overrides = {}) => {
|
|
@@ -2287,6 +2299,34 @@ async function startWorker(options) {
|
|
|
2287
2299
|
}
|
|
2288
2300
|
return;
|
|
2289
2301
|
}
|
|
2302
|
+
if (message.type === "sync_session_artifacts") {
|
|
2303
|
+
sessionArtifactSyncRequestsInFlight += 1;
|
|
2304
|
+
try {
|
|
2305
|
+
await syncSessionArtifacts({
|
|
2306
|
+
baseUrl,
|
|
2307
|
+
token,
|
|
2308
|
+
projectId: message.projectId,
|
|
2309
|
+
branchName: message.branchName,
|
|
2310
|
+
sessionId: message.sessionId,
|
|
2311
|
+
artifactRoot
|
|
2312
|
+
});
|
|
2313
|
+
sendWorkerMessage(ws, {
|
|
2314
|
+
type: "session_artifacts_sync_result",
|
|
2315
|
+
requestId: message.requestId,
|
|
2316
|
+
sessionId: message.sessionId
|
|
2317
|
+
});
|
|
2318
|
+
} catch (error) {
|
|
2319
|
+
sendWorkerMessage(ws, {
|
|
2320
|
+
type: "session_artifacts_sync_result",
|
|
2321
|
+
requestId: message.requestId,
|
|
2322
|
+
sessionId: message.sessionId,
|
|
2323
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2324
|
+
});
|
|
2325
|
+
} finally {
|
|
2326
|
+
sessionArtifactSyncRequestsInFlight -= 1;
|
|
2327
|
+
}
|
|
2328
|
+
return;
|
|
2329
|
+
}
|
|
2290
2330
|
if (message.type === "workspace_incident_updated") {
|
|
2291
2331
|
activeWorkspaceIncidentId = message.status === "remediating" || message.status === "waiting_for_worker" ? message.incidentId : null;
|
|
2292
2332
|
previousPeriodicFingerprint = null;
|
|
@@ -2305,7 +2345,7 @@ async function startWorker(options) {
|
|
|
2305
2345
|
});
|
|
2306
2346
|
return;
|
|
2307
2347
|
}
|
|
2308
|
-
if (activeProcesses.size > 0 || activePtys.size > 0 || workspaceSyncRequestsInFlight > 0) {
|
|
2348
|
+
if (activeProcesses.size > 0 || activePtys.size > 0 || workspaceSyncRequestsInFlight > 0 || sessionArtifactSyncRequestsInFlight > 0) {
|
|
2309
2349
|
sendWorkerMessage(ws, {
|
|
2310
2350
|
type: "update_clis_result",
|
|
2311
2351
|
requestId: message.requestId,
|
package/dist/cjs/package.json
CHANGED
package/dist/mjs/main.mjs
CHANGED
|
@@ -395,21 +395,32 @@ async function fetchSessionArtifactManifest(input) {
|
|
|
395
395
|
label: "artifact"
|
|
396
396
|
});
|
|
397
397
|
}
|
|
398
|
+
const sessionArtifactSyncQueues = /* @__PURE__ */ new Map();
|
|
398
399
|
async function syncSessionArtifacts(input) {
|
|
399
|
-
const
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
targetDir,
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
download: (artifact) => downloadRemoteSyncedFile({
|
|
406
|
-
url: artifactDownloadUrl(input.baseUrl, input.projectId, input.branchName, input.sessionId, artifact.filename),
|
|
407
|
-
token: input.token,
|
|
400
|
+
const queueKey = `${path.resolve(input.artifactRoot)}\0${input.sessionId}`;
|
|
401
|
+
const previous = sessionArtifactSyncQueues.get(queueKey);
|
|
402
|
+
const queued = (previous ? previous.catch(() => "") : Promise.resolve("")).then(async () => {
|
|
403
|
+
const targetDir = sessionArtifactDir(input.artifactRoot, input.sessionId);
|
|
404
|
+
const artifacts = await fetchSessionArtifactManifest(input);
|
|
405
|
+
return syncRemoteFileSet({
|
|
408
406
|
targetDir,
|
|
409
|
-
|
|
410
|
-
label: "
|
|
411
|
-
|
|
407
|
+
files: artifacts,
|
|
408
|
+
label: "Artifact path",
|
|
409
|
+
download: (artifact) => downloadRemoteSyncedFile({
|
|
410
|
+
url: artifactDownloadUrl(input.baseUrl, input.projectId, input.branchName, input.sessionId, artifact.filename),
|
|
411
|
+
token: input.token,
|
|
412
|
+
targetDir,
|
|
413
|
+
file: artifact,
|
|
414
|
+
label: "artifact"
|
|
415
|
+
})
|
|
416
|
+
});
|
|
412
417
|
});
|
|
418
|
+
sessionArtifactSyncQueues.set(queueKey, queued);
|
|
419
|
+
const release = () => {
|
|
420
|
+
if (sessionArtifactSyncQueues.get(queueKey) === queued) sessionArtifactSyncQueues.delete(queueKey);
|
|
421
|
+
};
|
|
422
|
+
void queued.then(release, release);
|
|
423
|
+
return queued;
|
|
413
424
|
}
|
|
414
425
|
async function resolveArtifactEnvFilePath(input) {
|
|
415
426
|
if (!isArtifactEnvPath(input.filePath)) {
|
|
@@ -2055,6 +2066,7 @@ async function startWorker(options) {
|
|
|
2055
2066
|
let periodicWorkspaceScanInFlight = false;
|
|
2056
2067
|
let terminalReplayTimer;
|
|
2057
2068
|
let workspaceSyncRequestsInFlight = 0;
|
|
2069
|
+
let sessionArtifactSyncRequestsInFlight = 0;
|
|
2058
2070
|
let cliUpdateInProgress = false;
|
|
2059
2071
|
let reloadAfterClose = false;
|
|
2060
2072
|
const workspaceSyncInput = (trigger, overrides = {}) => {
|
|
@@ -2251,6 +2263,34 @@ async function startWorker(options) {
|
|
|
2251
2263
|
}
|
|
2252
2264
|
return;
|
|
2253
2265
|
}
|
|
2266
|
+
if (message.type === "sync_session_artifacts") {
|
|
2267
|
+
sessionArtifactSyncRequestsInFlight += 1;
|
|
2268
|
+
try {
|
|
2269
|
+
await syncSessionArtifacts({
|
|
2270
|
+
baseUrl,
|
|
2271
|
+
token,
|
|
2272
|
+
projectId: message.projectId,
|
|
2273
|
+
branchName: message.branchName,
|
|
2274
|
+
sessionId: message.sessionId,
|
|
2275
|
+
artifactRoot
|
|
2276
|
+
});
|
|
2277
|
+
sendWorkerMessage(ws, {
|
|
2278
|
+
type: "session_artifacts_sync_result",
|
|
2279
|
+
requestId: message.requestId,
|
|
2280
|
+
sessionId: message.sessionId
|
|
2281
|
+
});
|
|
2282
|
+
} catch (error) {
|
|
2283
|
+
sendWorkerMessage(ws, {
|
|
2284
|
+
type: "session_artifacts_sync_result",
|
|
2285
|
+
requestId: message.requestId,
|
|
2286
|
+
sessionId: message.sessionId,
|
|
2287
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2288
|
+
});
|
|
2289
|
+
} finally {
|
|
2290
|
+
sessionArtifactSyncRequestsInFlight -= 1;
|
|
2291
|
+
}
|
|
2292
|
+
return;
|
|
2293
|
+
}
|
|
2254
2294
|
if (message.type === "workspace_incident_updated") {
|
|
2255
2295
|
activeWorkspaceIncidentId = message.status === "remediating" || message.status === "waiting_for_worker" ? message.incidentId : null;
|
|
2256
2296
|
previousPeriodicFingerprint = null;
|
|
@@ -2269,7 +2309,7 @@ async function startWorker(options) {
|
|
|
2269
2309
|
});
|
|
2270
2310
|
return;
|
|
2271
2311
|
}
|
|
2272
|
-
if (activeProcesses.size > 0 || activePtys.size > 0 || workspaceSyncRequestsInFlight > 0) {
|
|
2312
|
+
if (activeProcesses.size > 0 || activePtys.size > 0 || workspaceSyncRequestsInFlight > 0 || sessionArtifactSyncRequestsInFlight > 0) {
|
|
2273
2313
|
sendWorkerMessage(ws, {
|
|
2274
2314
|
type: "update_clis_result",
|
|
2275
2315
|
requestId: message.requestId,
|
package/dist/mjs/package.json
CHANGED