agents-relay 2.0.221 → 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.
@@ -1,13 +1,13 @@
1
1
  import { createHash, randomUUID } from 'node:crypto';
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';
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
- 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');
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
- 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;
133
+ return null;
119
134
  }
120
135
  export async function missingShortcutNodes(agentGraph, projectPath, neoRoot) {
121
136
  const graph = parseAgentGraph(agentGraph);
@@ -197,7 +212,7 @@ export async function runAgentShortcut(options) {
197
212
  const path = await discoverShortcut(node.agent, projectReal, neoRoot);
198
213
  return { nodeId: node.id, path, hash: path ? digestBytes(await readFile(path)) : 'missing' };
199
214
  }));
200
- 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])));
201
216
  const transitions = new DurableTaskTransitionRuntime(store);
202
217
  const owner = `shortcut-${process.pid}-${randomUUID()}`;
203
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/.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
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-relay",
3
- "version": "2.0.221",
3
+ "version": "2.0.222",
4
4
  "description": "Durable async agent jobs coordinated through GitHub pull requests",
5
5
  "repository": {
6
6
  "type": "git",