agents-relay 2.0.222 → 2.0.223
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 +20 -35
- package/dist/cli-help.js +4 -5
- 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 {
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
import { resolve, relative, isAbsolute, sep, dirname } from 'node:path';
|
|
5
|
+
import { realpath } from 'node:fs/promises';
|
|
4
6
|
import { once } from 'node:events';
|
|
5
7
|
import { pathToFileURL } from 'node:url';
|
|
6
8
|
import { spawnOwnedProcess } from './owned-process.js';
|
|
7
9
|
import { validateShortcutStageGate } from './shortcut-stage-contract.js';
|
|
8
10
|
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,39 +98,24 @@ 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. */
|
|
104
101
|
async function discoverShortcut(agent, projectPath, neoRoot) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (
|
|
111
|
-
|
|
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}`);
|
|
102
|
+
const file = `${agent}.agent.mjs`;
|
|
103
|
+
const root = await realpath(projectPath);
|
|
104
|
+
const project = resolve(root, 'agents', '.shortcut', file);
|
|
105
|
+
if (existsSync(project)) {
|
|
106
|
+
const actual = await realpath(project);
|
|
107
|
+
if (!inside(root, actual))
|
|
108
|
+
throw new Error('Project shortcut symlink escapes project root');
|
|
131
109
|
return actual;
|
|
132
110
|
}
|
|
133
|
-
|
|
111
|
+
const shared = neoRoot ? resolve(neoRoot, 'agents', '.shortcut', file) : null;
|
|
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;
|
|
134
119
|
}
|
|
135
120
|
export async function missingShortcutNodes(agentGraph, projectPath, neoRoot) {
|
|
136
121
|
const graph = parseAgentGraph(agentGraph);
|
|
@@ -212,7 +197,7 @@ export async function runAgentShortcut(options) {
|
|
|
212
197
|
const path = await discoverShortcut(node.agent, projectReal, neoRoot);
|
|
213
198
|
return { nodeId: node.id, path, hash: path ? digestBytes(await readFile(path)) : 'missing' };
|
|
214
199
|
}));
|
|
215
|
-
const shortcutHash = digest(canonical(shortcuts.map(item => [item.nodeId, item.
|
|
200
|
+
const shortcutHash = digest(canonical(shortcuts.map(item => [item.nodeId, item.hash])));
|
|
216
201
|
const transitions = new DurableTaskTransitionRuntime(store);
|
|
217
202
|
const owner = `shortcut-${process.pid}-${randomUUID()}`;
|
|
218
203
|
let currentJob = await store.load(job.id);
|
package/dist/cli-help.js
CHANGED
|
@@ -59,11 +59,10 @@ 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/<agent>.agent.mjs
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
follow the existing recovery lifecycle without automatic replay of effects. Nonhuman waits resume only from a matching SQLite Task receipt; EventBus
|
|
62
|
+
agents/.shortcut/<agent>.agent.mjs override Neo shared shortcuts. A Graph
|
|
63
|
+
with any missing shortcut falls back to the normal durable Worker before
|
|
64
|
+
executing any module; mixing shortcut and Worker nodes in one Graph is unsupported.
|
|
65
|
+
Shortcuts that fail before effects also return to the Worker queue. Nonhuman waits resume only from a matching SQLite Task receipt; EventBus
|
|
67
66
|
events are wake signals. Human approval remains hostInvocation-only.
|
|
68
67
|
Shortcut Job completion requires durable contentOnly=true and no PR, merge, or review gates.
|
|
69
68
|
|