agents-relay 1.0.135 → 1.0.137

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/cli.js CHANGED
@@ -23,6 +23,7 @@ import { resolveExecutionContext } from './execution-context.js';
23
23
  import { defaultWorkspaceRoot, resolveManagedProjectPath, resolveRepositoryProjectPath } from './workspace.js';
24
24
  import { runBlockerCommand } from './cli-blocker.js';
25
25
  import { helpText, usage } from './cli-help.js';
26
+ import { parseAgentGraph } from './agent-graph.js';
26
27
  export { helpText } from './cli-help.js';
27
28
  import { SERVICE_DEFAULTS, ServiceEventBus, arg, hasArg, textOption, integerArg, repository, storeFor, saveLocal, githubStore, eventBus, publishWake, priority, storySize, executionMode, chatGptTabClosePolicy, requestedExecutionMode, continuation, scheduleFromArgs, requestManagedReconciliation, } from './cli-support.js';
28
29
  export { SERVICE_DEFAULTS, eventBus, executionMode, chatGptTabClosePolicy } from './cli-support.js';
@@ -75,6 +76,8 @@ async function workerTaskFromArgs(job, args, now) {
75
76
  const outputPath = arg(args, '--output-path');
76
77
  const input = await textOption(args, '--input', '--input-file');
77
78
  const agentGraph = hasArg(args, '--agent-graph') || hasArg(args, '--agent-graph-file') ? await textOption(args, '--agent-graph', '--agent-graph-file') : undefined;
79
+ if (agentGraph)
80
+ parseAgentGraph(agentGraph);
78
81
  if (!input.trim())
79
82
  throw new Error('task create requires --input-file PATH|- or --input MARKDOWN');
80
83
  if (!['codex', 'chatgpt', 'orchestrator'].includes(adapter))
@@ -225,8 +228,12 @@ async function runTaskCommand(action, args) {
225
228
  task.projectName = arg(args, '--project') || undefined;
226
229
  if (hasArg(args, '--agent'))
227
230
  task.agentName = arg(args, '--agent') || undefined;
228
- if (hasArg(args, '--agent-graph') || hasArg(args, '--agent-graph-file'))
229
- task.agentGraph = await textOption(args, '--agent-graph', '--agent-graph-file');
231
+ if (hasArg(args, '--agent-graph') || hasArg(args, '--agent-graph-file')) {
232
+ const agentGraph = await textOption(args, '--agent-graph', '--agent-graph-file');
233
+ if (agentGraph)
234
+ parseAgentGraph(agentGraph);
235
+ task.agentGraph = agentGraph || undefined;
236
+ }
230
237
  if (hasArg(args, '--parent'))
231
238
  task.parentTaskId = arg(args, '--parent') || null;
232
239
  if (hasArg(args, '--deps'))
package/dist/planner.js CHANGED
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url';
4
4
  import { dirname, join } from 'node:path';
5
5
  import { storySizeTimeoutMs, taskOverallTimeoutMs } from './types.js';
6
6
  import { executionContextPrompt } from './execution-context.js';
7
+ import { parseAgentGraph } from './agent-graph.js';
7
8
  export function plannerRoundNumber(task) {
8
9
  if (task.kind !== 'planner')
9
10
  return null;
@@ -183,6 +184,15 @@ export function parsePlannerResult(value) {
183
184
  const maxAttempts = task.maxAttempts === undefined ? 3 : task.maxAttempts;
184
185
  const route = routing(task.routing, 'next_tasks[' + index + '].routing');
185
186
  const requirements = workerRequirements(task.workerRequirements ?? task.requirements, 'next_tasks[' + index + '].workerRequirements');
187
+ const agentGraph = optionalString(task.agentGraph, `next_tasks[${index}].agentGraph`);
188
+ if (agentGraph) {
189
+ try {
190
+ parseAgentGraph(agentGraph);
191
+ }
192
+ catch (error) {
193
+ throw new Error(`Planner next_tasks[${index}].agentGraph is invalid: ${error instanceof Error ? error.message : String(error)}`);
194
+ }
195
+ }
186
196
  const timeoutMs = task.timeoutMs === undefined ? taskOverallTimeoutMs(storySize, route?.reasoning) : task.timeoutMs;
187
197
  if (typeof maxAttempts !== 'number' || !Number.isInteger(maxAttempts) || maxAttempts < 1)
188
198
  throw new Error(`Planner next_tasks[${index}].maxAttempts is invalid`);
@@ -190,7 +200,7 @@ export function parsePlannerResult(value) {
190
200
  throw new Error(`Planner next_tasks[${index}].timeoutMs is invalid`);
191
201
  return {
192
202
  id, input: task.input, priority, storySize,
193
- projectName: optionalString(task.projectName, 'projectName'), agentName: optionalString(task.agentName, 'agentName'), agentGraph: optionalString(task.agentGraph, 'agentGraph'),
203
+ projectName: optionalString(task.projectName, 'projectName'), agentName: optionalString(task.agentName, 'agentName'), agentGraph,
194
204
  dependencies: stringArray(task.dependencies, 'dependencies'), capabilities: stringArray(task.capabilities, 'capabilities'), workerRequirements: requirements,
195
205
  adapter: adapter, output: output, routing: route,
196
206
  continuation: task.continuation, maxAttempts, timeoutMs
package/dist/usage.js CHANGED
@@ -51,7 +51,11 @@ export class BrowserWorkspaceUsageReader {
51
51
  const idle = numberOrNull(raw.idle);
52
52
  const leased = numberOrNull(raw.leased);
53
53
  const poolSize = numberOrNull(raw.poolSize);
54
- const available = typeof raw.available === 'boolean' ? raw.available : idle === null ? null : idle > 0;
54
+ // `available` is allocatable capacity, not the number of currently idle tabs.
55
+ // Keep accepting the old boolean probe shape while callers transition.
56
+ const available = typeof raw.available === 'number' && Number.isFinite(raw.available) && raw.available >= 0
57
+ ? raw.available
58
+ : typeof raw.available === 'boolean' ? (raw.available ? 1 : 0) : null;
55
59
  if (idle !== null || leased !== null || poolSize !== null || available !== null) {
56
60
  finish({ name, poolSize, idle, leased, available, observedAt: rawObservedAt, reason: null });
57
61
  return;
@@ -83,7 +83,7 @@ export function satisfiesWorker(candidate, requirements) {
83
83
  return false;
84
84
  if (requirements.runtime && candidate.runtime !== requirements.runtime)
85
85
  return false;
86
- if (candidate.adapter === 'chatgpt' && candidate.browserWorkspaceCapacity?.idle === 0)
86
+ if (candidate.adapter === 'chatgpt' && candidate.browserWorkspaceCapacity?.available === 0)
87
87
  return false;
88
88
  return true;
89
89
  }
@@ -120,8 +120,8 @@ export function selectWorker(candidates, requirements) {
120
120
  return { candidate: selected, selection: selection(selected, 'worker-router:fallback') };
121
121
  }
122
122
  function noEligibleWorkerReason(candidates) {
123
- if (candidates.some(candidate => candidate.adapter === 'chatgpt' && candidate.browserWorkspaceCapacity?.idle === 0)) {
124
- return 'No eligible worker: ChatGPT Browser Workspace has no idle capacity.';
123
+ if (candidates.some(candidate => candidate.adapter === 'chatgpt' && candidate.browserWorkspaceCapacity?.available === 0)) {
124
+ return 'No eligible worker: ChatGPT Browser Workspace has no allocatable capacity.';
125
125
  }
126
126
  return 'No eligible worker satisfies the authoritative worker constraints';
127
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-relay",
3
- "version": "1.0.135",
3
+ "version": "1.0.137",
4
4
  "description": "Durable async agent jobs coordinated through GitHub pull requests",
5
5
  "type": "module",
6
6
  "bin": {
@@ -96,7 +96,7 @@ Use these exact serialized forms:
96
96
  - `output` is always an object, never a string:
97
97
  - PR-backed work: `{"kind":"task_pr"}`
98
98
  - File artifact: `{"kind":"file","path":"runs/2026-09-26/example/output.md"}`
99
- - `agentGraph`, when present, is one Mermaid graph **string**, for example `"graph LR\n build-log-editor --> build-log-producer"`. Do not emit an object with `nodes` or `edges`.
99
+ - `agentGraph`, when present, is one executable Mermaid Agent Graph **string** using `flowchart TD|TB|LR|RL`, for example `"flowchart LR\n build-log-editor --> build-log-producer"`. Do not emit `graph LR`, and do not emit an object with `nodes` or `edges`.
100
100
  - `priority`, when present, is exactly `"P0"`, `"P1"`, `"P2"`, or `"P3"`; otherwise omit it.
101
101
  - `storySize` is exactly `"S"`, `"M"`, or `"L"`.
102
102
 
@@ -115,7 +115,7 @@ A valid non-satisfied response:
115
115
  "storySize": "L",
116
116
  "priority": "P1",
117
117
  "agentName": "build-log-editor",
118
- "agentGraph": "graph LR\n build-log-editor --> build-log-producer"
118
+ "agentGraph": "flowchart LR\n build-log-editor --> build-log-producer"
119
119
  }
120
120
  ]
121
121
  }