agents-relay 2.0.220 → 2.0.222
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 +64 -37
- package/dist/cli-help.js +5 -4
- package/package.json +1 -1
package/dist/agent-shortcut.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { resolve, relative, isAbsolute, sep, dirname } from 'node:path';
|
|
5
|
-
import { realpath } from 'node:fs/promises';
|
|
2
|
+
import { readFile, realpath, stat } from 'node:fs/promises';
|
|
3
|
+
import { resolve, relative, isAbsolute, sep, dirname, join, basename } from 'node:path';
|
|
6
4
|
import { once } from 'node:events';
|
|
7
5
|
import { pathToFileURL } from 'node:url';
|
|
8
6
|
import { spawnOwnedProcess } from './owned-process.js';
|
|
9
7
|
import { validateShortcutStageGate } from './shortcut-stage-contract.js';
|
|
10
8
|
import { parseAgentGraph } from './agent-graph.js';
|
|
9
|
+
import { resolveAgentMarkdown } from './agent-content-resolver.js';
|
|
10
|
+
import { BUNDLED_AGENTS_ROOT } from './execution-context.js';
|
|
11
11
|
import { DurableTaskTransitionRuntime } from './workflow/durable-transition.js';
|
|
12
12
|
import { dispatchJobLifecycleSync } from './workflow/lifecycle.js';
|
|
13
13
|
import { dependencyReady, tryTransitionTaskEvent } from './task-transitions.js';
|
|
@@ -98,24 +98,39 @@ async function runCommand(args, cwd, signal) {
|
|
|
98
98
|
const [code] = await once(child, 'close');
|
|
99
99
|
return { stdout, stderr, code: code ?? -1 };
|
|
100
100
|
}
|
|
101
|
+
/** The Markdown resolver already selects the effective Agent and its explicit
|
|
102
|
+
* inheritance chain. Inspect only those source files, most specific first;
|
|
103
|
+
* never look up an unrelated same-named shortcut in another layer. */
|
|
101
104
|
async function discoverShortcut(agent, projectPath, neoRoot) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (
|
|
108
|
-
|
|
105
|
+
let sources;
|
|
106
|
+
try {
|
|
107
|
+
({ sources } = await resolveAgentMarkdown(agent, BUNDLED_AGENTS_ROOT, projectPath, neoRoot));
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (error instanceof Error && error.message === `Unknown agent ${agent}`)
|
|
111
|
+
return null;
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
for (const source of [...sources].reverse()) {
|
|
115
|
+
const directory = dirname(source);
|
|
116
|
+
const owner = basename(source).replace(/(?:\.agent)?\.md$/, '');
|
|
117
|
+
const candidate = join(directory, `${owner}.agent.mjs`);
|
|
118
|
+
let actual;
|
|
119
|
+
try {
|
|
120
|
+
actual = await realpath(candidate);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
if (error.code === 'ENOENT')
|
|
124
|
+
continue;
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
if (dirname(actual) !== directory)
|
|
128
|
+
throw new Error(`Agent shortcut symlink escapes source directory: ${candidate}`);
|
|
129
|
+
if (!(await stat(actual)).isFile())
|
|
130
|
+
throw new Error(`Agent shortcut is not a regular file: ${candidate}`);
|
|
109
131
|
return actual;
|
|
110
132
|
}
|
|
111
|
-
|
|
112
|
-
if (!shared || !existsSync(shared))
|
|
113
|
-
return null;
|
|
114
|
-
const sharedRoot = await realpath(resolve(neoRoot, 'agents', '.shortcut'));
|
|
115
|
-
const actual = await realpath(shared);
|
|
116
|
-
if (!inside(sharedRoot, actual))
|
|
117
|
-
throw new Error('Shared shortcut symlink escapes shortcut root');
|
|
118
|
-
return actual;
|
|
133
|
+
return null;
|
|
119
134
|
}
|
|
120
135
|
export async function missingShortcutNodes(agentGraph, projectPath, neoRoot) {
|
|
121
136
|
const graph = parseAgentGraph(agentGraph);
|
|
@@ -136,37 +151,49 @@ function raceAbort(work, signal) {
|
|
|
136
151
|
return Promise.race([work, aborted]).finally(() => { if (rejectAbort)
|
|
137
152
|
signal.removeEventListener('abort', rejectAbort); });
|
|
138
153
|
}
|
|
139
|
-
//
|
|
140
|
-
//
|
|
154
|
+
// Vlog's Visioner sources actual Markcut perception and lightweight normalized
|
|
155
|
+
// media; the historical vision-segment-index.json contract was retired.
|
|
156
|
+
// Distribution Visioner has a separate domain contract.
|
|
141
157
|
function requiresVlogVisionerEvidence(agent) {
|
|
142
158
|
return agent === 'visioner' || agent === 'vlog-visioner';
|
|
143
159
|
}
|
|
144
160
|
async function validateVisionerResult(result, projectRoot) {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
161
|
+
const output = result.output;
|
|
162
|
+
const artifacts = result.artifacts;
|
|
163
|
+
const names = ['vision-evidence.json', 'vision-normalized-manifest.json', 'metadata.json'];
|
|
164
|
+
if (!output || !artifacts || Array.isArray(artifacts) || typeof artifacts !== 'object' ||
|
|
165
|
+
!names.every(name => Object.prototype.hasOwnProperty.call(artifacts, name) && typeof output[name] === 'string'))
|
|
166
|
+
throw new Error('Visioner requires source-linked evidence, normalized manifest and Markcut metadata artifacts');
|
|
148
167
|
const files = artifacts;
|
|
149
168
|
const evidence = files['vision-evidence.json'];
|
|
150
|
-
const
|
|
169
|
+
const normalized = files['vision-normalized-manifest.json'];
|
|
151
170
|
const metadata = files['metadata.json'];
|
|
152
|
-
if (!evidence || evidence.status !== 'EVIDENCE_READY_UNREVIEWED' || evidence.stage !== 'visioner' ||
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
171
|
+
if (!evidence || evidence.status !== 'EVIDENCE_READY_UNREVIEWED' || evidence.stage !== 'visioner' ||
|
|
172
|
+
!Array.isArray(evidence.sources) || !Array.isArray(evidence.observations) || !Array.isArray(evidence.summary) ||
|
|
173
|
+
!normalized || normalized.profile !== 'markcut-vision-normalized-v1' || normalized.usage !== 'vision-understanding-only' ||
|
|
174
|
+
!Array.isArray(normalized.sources) || !metadata || typeof metadata !== 'object' || Array.isArray(metadata))
|
|
175
|
+
throw new Error('Visioner artifacts do not satisfy the current source-linked evidence contract');
|
|
176
|
+
const actualFiles = new Map();
|
|
177
|
+
for (const name of names) {
|
|
157
178
|
const actual = await realpath(resolve(projectRoot, String(output[name])));
|
|
158
179
|
if (!inside(projectRoot, actual))
|
|
159
180
|
throw new Error(`Visioner artifact escapes project root: ${name}`);
|
|
160
181
|
const bytes = await readFile(actual), parsed = JSON.parse(bytes.toString('utf8'));
|
|
161
182
|
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed) || canonical(parsed) !== canonical(files[name]))
|
|
162
183
|
throw new Error(`Visioner structured artifact differs from file: ${name}`);
|
|
163
|
-
|
|
184
|
+
actualFiles.set(name, bytes);
|
|
164
185
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
186
|
+
if (evidence.markcut_metadata_sha256 !== digestBytes(actualFiles.get('metadata.json')) ||
|
|
187
|
+
normalized.sourceManifestSha256 !== evidence.manifest_hash)
|
|
188
|
+
throw new Error('Visioner normalized and Markcut source provenance does not match');
|
|
189
|
+
const originalSources = evidence.sources;
|
|
190
|
+
const normalizedSources = normalized.sources;
|
|
191
|
+
if (originalSources.length === 0 || originalSources.length !== normalizedSources.length ||
|
|
192
|
+
new Set(originalSources.map(source => source.source_id)).size !== originalSources.length ||
|
|
193
|
+
originalSources.some(source => typeof source.source_id !== 'string' || typeof source.source_sha256 !== 'string' ||
|
|
194
|
+
!(source.source_id in metadata) ||
|
|
195
|
+
!normalizedSources.some(item => item.sourceId === source.source_id && item.sourceSha256 === source.source_sha256)))
|
|
196
|
+
throw new Error('Visioner normalized manifest does not cover every original source identity');
|
|
170
197
|
}
|
|
171
198
|
export async function runAgentShortcut(options) {
|
|
172
199
|
const { store, job, task, projectPath, neoRoot } = options;
|
|
@@ -185,7 +212,7 @@ export async function runAgentShortcut(options) {
|
|
|
185
212
|
const path = await discoverShortcut(node.agent, projectReal, neoRoot);
|
|
186
213
|
return { nodeId: node.id, path, hash: path ? digestBytes(await readFile(path)) : 'missing' };
|
|
187
214
|
}));
|
|
188
|
-
const shortcutHash = digest(canonical(shortcuts.map(item => [item.nodeId, item.hash])));
|
|
215
|
+
const shortcutHash = digest(canonical(shortcuts.map(item => [item.nodeId, item.path, item.hash])));
|
|
189
216
|
const transitions = new DurableTaskTransitionRuntime(store);
|
|
190
217
|
const owner = `shortcut-${process.pid}-${randomUUID()}`;
|
|
191
218
|
let currentJob = await store.load(job.id);
|
package/dist/cli-help.js
CHANGED
|
@@ -59,10 +59,11 @@ Shortcut execution:
|
|
|
59
59
|
[--store-dir DIR] [--project-path DIR] [--neo-root DIR] [--concurrency 4]
|
|
60
60
|
|
|
61
61
|
The selected Task must have an Agent Graph. Project shortcuts at
|
|
62
|
-
agents
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
agents/<agent>.agent.mjs live beside the effective Agent Markdown.
|
|
63
|
+
Only explicit Agent inheritance permits an inherited shortcut. A Graph
|
|
64
|
+
with missing shortcuts invokes the existing durable Worker adapter for those
|
|
65
|
+
nodes while independent shortcut nodes can still execute. Shortcut failures
|
|
66
|
+
follow the existing recovery lifecycle without automatic replay of effects. Nonhuman waits resume only from a matching SQLite Task receipt; EventBus
|
|
66
67
|
events are wake signals. Human approval remains hostInvocation-only.
|
|
67
68
|
Shortcut Job completion requires durable contentOnly=true and no PR, merge, or review gates.
|
|
68
69
|
|