agents-relay 2.0.216 → 2.0.218
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 +6 -3
- 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
|
}
|
|
@@ -91,7 +91,9 @@ export async function runShortcutModelNode(options) {
|
|
|
91
91
|
const record = value;
|
|
92
92
|
if (record.status !== 'COMPLETED' || !record.output || typeof record.output !== 'object' || Array.isArray(record.output))
|
|
93
93
|
throw new Error('Worker Task reported success without contract-valid node output');
|
|
94
|
-
// Some
|
|
94
|
+
// Some Workers report {path,kind:"human-readable description"}.
|
|
95
|
+
// Only the checked on-disk path is an artifact identity; `kind` is not
|
|
96
|
+
// a declared filesystem type or authorization claim.
|
|
95
97
|
// Convert ONLY exact file records to the Shortcut contract's path list;
|
|
96
98
|
// the Graph executor still verifies realpath containment and SHA-256.
|
|
97
99
|
if (Array.isArray(record.artifacts)) {
|
|
@@ -108,11 +110,12 @@ export async function runShortcutModelNode(options) {
|
|
|
108
110
|
&& typeof ref.path === 'string' && ref.path.trim())
|
|
109
111
|
return ref.path;
|
|
110
112
|
if (fields.length === 2 && fields.includes('path')
|
|
111
|
-
&& ((fields.includes('type') && ref.type === 'file') ||
|
|
113
|
+
&& ((fields.includes('type') && ref.type === 'file') ||
|
|
114
|
+
(fields.includes('kind') && typeof ref.kind === 'string' && ref.kind.trim()))
|
|
112
115
|
&& typeof ref.path === 'string' && ref.path.trim())
|
|
113
116
|
return ref.path;
|
|
114
117
|
}
|
|
115
|
-
throw new Error('Worker node returned unsupported artifact entry; expected a file path, {path}, {type:"file",path} or {kind:"
|
|
118
|
+
throw new Error('Worker node returned unsupported artifact entry; expected a file path, {path}, {type:"file",path} or {kind:"description",path}');
|
|
116
119
|
});
|
|
117
120
|
return { ...record, artifacts: files };
|
|
118
121
|
}
|