agents-relay 2.0.215 → 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/dist/shortcut-node-worker.js +7 -1
- 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
|
}
|
|
@@ -101,12 +101,18 @@ export async function runShortcutModelNode(options) {
|
|
|
101
101
|
if (item && typeof item === 'object' && !Array.isArray(item)) {
|
|
102
102
|
const ref = item;
|
|
103
103
|
const fields = Object.keys(ref);
|
|
104
|
+
// A Worker may naturally produce a path-only file record. Accept
|
|
105
|
+
// EXACTLY {path} (no unrecognized metadata), then let the Graph
|
|
106
|
+
// executor verify realpath confinement and SHA-256 as usual.
|
|
107
|
+
if (fields.length === 1 && fields[0] === 'path'
|
|
108
|
+
&& typeof ref.path === 'string' && ref.path.trim())
|
|
109
|
+
return ref.path;
|
|
104
110
|
if (fields.length === 2 && fields.includes('path')
|
|
105
111
|
&& ((fields.includes('type') && ref.type === 'file') || (fields.includes('kind') && ref.kind === 'file'))
|
|
106
112
|
&& typeof ref.path === 'string' && ref.path.trim())
|
|
107
113
|
return ref.path;
|
|
108
114
|
}
|
|
109
|
-
throw new Error('Worker node returned unsupported artifact entry; expected a file path, {type:"file",path} or {kind:"file",path}');
|
|
115
|
+
throw new Error('Worker node returned unsupported artifact entry; expected a file path, {path}, {type:"file",path} or {kind:"file",path}');
|
|
110
116
|
});
|
|
111
117
|
return { ...record, artifacts: files };
|
|
112
118
|
}
|