agents-relay 2.0.216 → 2.0.217
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/agent-shortcut.js +26 -11
- package/package.json +1 -1
package/dist/agent-shortcut.js
CHANGED
|
@@ -414,21 +414,36 @@ export async function runAgentShortcut(options) {
|
|
|
414
414
|
if (task.output?.kind === 'file')
|
|
415
415
|
await validateShortcutStageGate({ projectPath: projectReal, agent: node.agent, runPath: dirname(task.output.path), execute: trackedRunCommand });
|
|
416
416
|
const artifactHashes = {};
|
|
417
|
+
// Project-local Shortcut nodes use project-relative paths. Managed
|
|
418
|
+
// Project Run Workers may instead return paths relative to their
|
|
419
|
+
// canonical Run; both must stay inside the Project and remain
|
|
420
|
+
// unambiguous before hashing bytes.
|
|
421
|
+
const runRoot = task.output?.kind === 'file' ? await realpath(dirname(task.output.path)) : null;
|
|
422
|
+
const checkedRunRoot = runRoot && inside(projectReal, runRoot) ? runRoot : null;
|
|
417
423
|
for (const artifact of artifactPaths) {
|
|
418
|
-
if (!artifact)
|
|
424
|
+
if (!artifact || typeof artifact !== 'string')
|
|
419
425
|
throw new Error('shortcut artifact path cannot be empty');
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
426
|
+
const candidates = isAbsolute(artifact)
|
|
427
|
+
? [resolve(artifact)]
|
|
428
|
+
: [...new Set([resolve(projectReal, artifact), ...(checkedRunRoot ? [resolve(checkedRunRoot, artifact)] : [])])];
|
|
429
|
+
const found = [];
|
|
430
|
+
for (const candidate of candidates) {
|
|
431
|
+
// Never follow a symlink from outside the Project into it.
|
|
432
|
+
if (!inside(projectReal, candidate))
|
|
433
|
+
continue;
|
|
434
|
+
try {
|
|
435
|
+
const actual = await realpath(candidate);
|
|
436
|
+
if (inside(projectReal, actual) && !found.includes(actual))
|
|
437
|
+
found.push(actual);
|
|
438
|
+
}
|
|
439
|
+
catch { /* Check the alternate canonical Run location. */ }
|
|
424
440
|
}
|
|
425
|
-
|
|
426
|
-
throw new Error(`shortcut artifact missing: ${artifact}`);
|
|
427
|
-
}
|
|
428
|
-
if (!inside(projectReal, actual))
|
|
441
|
+
if (found.length === 0)
|
|
429
442
|
throw new Error(`shortcut artifact missing or outside project: ${artifact}`);
|
|
430
|
-
|
|
431
|
-
|
|
443
|
+
if (found.length > 1)
|
|
444
|
+
throw new Error(`shortcut artifact ambiguous between project and run: ${artifact}`);
|
|
445
|
+
const relativePath = relative(projectReal, found[0]);
|
|
446
|
+
artifactHashes[relativePath] = digestBytes(await readFile(found[0]));
|
|
432
447
|
}
|
|
433
448
|
return { id, value: result, artifactHashes };
|
|
434
449
|
}
|