agent-relay 17.2.1 → 18.0.0

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.
Files changed (243) hide show
  1. package/README.md +45 -270
  2. package/dist/cli/agent-relay-mcp.d.ts.map +1 -1
  3. package/dist/cli/agent-relay-mcp.js +6 -5
  4. package/dist/cli/agent-relay-mcp.js.map +1 -1
  5. package/dist/cli/bootstrap.d.ts +1 -1
  6. package/dist/cli/bootstrap.d.ts.map +1 -1
  7. package/dist/cli/bootstrap.js +11 -29
  8. package/dist/cli/bootstrap.js.map +1 -1
  9. package/dist/cli/commands/agent.d.ts.map +1 -1
  10. package/dist/cli/commands/agent.js +3 -2
  11. package/dist/cli/commands/agent.js.map +1 -1
  12. package/dist/cli/commands/cloud-integration.d.ts.map +1 -1
  13. package/dist/cli/commands/cloud-integration.js +2 -1
  14. package/dist/cli/commands/cloud-integration.js.map +1 -1
  15. package/dist/cli/commands/cloud-room.d.ts.map +1 -1
  16. package/dist/cli/commands/cloud-room.js +2 -1
  17. package/dist/cli/commands/cloud-room.js.map +1 -1
  18. package/dist/cli/commands/cloud-v1-deprecations.d.ts +4 -6
  19. package/dist/cli/commands/cloud-v1-deprecations.d.ts.map +1 -1
  20. package/dist/cli/commands/cloud-v1-deprecations.js +4 -6
  21. package/dist/cli/commands/cloud-v1-deprecations.js.map +1 -1
  22. package/dist/cli/commands/cloud-worker.d.ts +1 -1
  23. package/dist/cli/commands/cloud-worker.d.ts.map +1 -1
  24. package/dist/cli/commands/cloud-worker.js +42 -31
  25. package/dist/cli/commands/cloud-worker.js.map +1 -1
  26. package/dist/cli/commands/cloud.d.ts.map +1 -1
  27. package/dist/cli/commands/cloud.js +6 -7
  28. package/dist/cli/commands/cloud.js.map +1 -1
  29. package/dist/cli/commands/core.d.ts +3 -91
  30. package/dist/cli/commands/core.d.ts.map +1 -1
  31. package/dist/cli/commands/core.js +5 -254
  32. package/dist/cli/commands/core.js.map +1 -1
  33. package/dist/cli/commands/fleet-agent.d.ts +9 -54
  34. package/dist/cli/commands/fleet-agent.d.ts.map +1 -1
  35. package/dist/cli/commands/fleet-agent.js +105 -314
  36. package/dist/cli/commands/fleet-agent.js.map +1 -1
  37. package/dist/cli/commands/fleet.d.ts +0 -3
  38. package/dist/cli/commands/fleet.d.ts.map +1 -1
  39. package/dist/cli/commands/fleet.js +48 -267
  40. package/dist/cli/commands/fleet.js.map +1 -1
  41. package/dist/cli/commands/init.js +1 -1
  42. package/dist/cli/commands/init.js.map +1 -1
  43. package/dist/cli/commands/integration-cleanup-journal.d.ts +6 -2
  44. package/dist/cli/commands/integration-cleanup-journal.d.ts.map +1 -1
  45. package/dist/cli/commands/integration-cleanup-journal.js +611 -134
  46. package/dist/cli/commands/integration-cleanup-journal.js.map +1 -1
  47. package/dist/cli/commands/integration-recipient.d.ts +0 -17
  48. package/dist/cli/commands/integration-recipient.d.ts.map +1 -1
  49. package/dist/cli/commands/integration-recipient.js +1 -104
  50. package/dist/cli/commands/integration-recipient.js.map +1 -1
  51. package/dist/cli/commands/integration.d.ts +7 -3
  52. package/dist/cli/commands/integration.d.ts.map +1 -1
  53. package/dist/cli/commands/integration.js +37 -82
  54. package/dist/cli/commands/integration.js.map +1 -1
  55. package/dist/cli/commands/local-workflow.d.ts +1 -1
  56. package/dist/cli/commands/local-workflow.d.ts.map +1 -1
  57. package/dist/cli/commands/local-workflow.js +20 -6
  58. package/dist/cli/commands/local-workflow.js.map +1 -1
  59. package/dist/cli/commands/node.d.ts +18 -20
  60. package/dist/cli/commands/node.d.ts.map +1 -1
  61. package/dist/cli/commands/node.js +42 -272
  62. package/dist/cli/commands/node.js.map +1 -1
  63. package/dist/cli/commands/product-surfaces.js +2 -2
  64. package/dist/cli/commands/session.d.ts.map +1 -1
  65. package/dist/cli/commands/session.js +2 -1
  66. package/dist/cli/commands/session.js.map +1 -1
  67. package/dist/cli/commands/skills.d.ts.map +1 -1
  68. package/dist/cli/commands/skills.js +2 -1
  69. package/dist/cli/commands/skills.js.map +1 -1
  70. package/dist/cli/commands/status.d.ts +1 -7
  71. package/dist/cli/commands/status.d.ts.map +1 -1
  72. package/dist/cli/commands/status.js +2 -28
  73. package/dist/cli/commands/status.js.map +1 -1
  74. package/dist/cli/commands/workspace.d.ts.map +1 -1
  75. package/dist/cli/commands/workspace.js +2 -2
  76. package/dist/cli/commands/workspace.js.map +1 -1
  77. package/dist/cli/index.d.ts.map +1 -1
  78. package/dist/cli/index.js +1 -3
  79. package/dist/cli/index.js.map +1 -1
  80. package/dist/cli/lib/agent-relay-cli-reentry.d.ts +37 -0
  81. package/dist/cli/lib/agent-relay-cli-reentry.d.ts.map +1 -0
  82. package/dist/cli/lib/agent-relay-cli-reentry.js +40 -0
  83. package/dist/cli/lib/agent-relay-cli-reentry.js.map +1 -0
  84. package/dist/cli/lib/agent-tools-mcp.d.ts.map +1 -1
  85. package/dist/cli/lib/agent-tools-mcp.js +3 -2
  86. package/dist/cli/lib/agent-tools-mcp.js.map +1 -1
  87. package/dist/cli/lib/core-maintenance.d.ts +2 -3
  88. package/dist/cli/lib/core-maintenance.d.ts.map +1 -1
  89. package/dist/cli/lib/core-maintenance.js +3 -37
  90. package/dist/cli/lib/core-maintenance.js.map +1 -1
  91. package/dist/cli/lib/desktop-presence.js +1 -1
  92. package/dist/cli/lib/desktop-presence.js.map +1 -1
  93. package/dist/cli/lib/install-paths.d.ts +100 -0
  94. package/dist/cli/lib/install-paths.d.ts.map +1 -0
  95. package/dist/cli/lib/install-paths.js +157 -0
  96. package/dist/cli/lib/install-paths.js.map +1 -0
  97. package/dist/cli/lib/product-surface-store.d.ts.map +1 -1
  98. package/dist/cli/lib/product-surface-store.js +4 -1
  99. package/dist/cli/lib/product-surface-store.js.map +1 -1
  100. package/dist/cli/lib/relay-node.d.ts +7 -34
  101. package/dist/cli/lib/relay-node.d.ts.map +1 -1
  102. package/dist/cli/lib/relay-node.js +7 -182
  103. package/dist/cli/lib/relay-node.js.map +1 -1
  104. package/dist/cli/lib/removed-broker-command.d.ts +7 -0
  105. package/dist/cli/lib/removed-broker-command.d.ts.map +1 -0
  106. package/dist/cli/lib/removed-broker-command.js +13 -0
  107. package/dist/cli/lib/removed-broker-command.js.map +1 -0
  108. package/dist/cli/lib/sdk-client.d.ts +4 -4
  109. package/dist/cli/lib/sdk-client.js +4 -4
  110. package/dist/cli/lib/self-update.d.ts +8 -19
  111. package/dist/cli/lib/self-update.d.ts.map +1 -1
  112. package/dist/cli/lib/self-update.js +14 -28
  113. package/dist/cli/lib/self-update.js.map +1 -1
  114. package/dist/cli/lib/skills-install.d.ts.map +1 -1
  115. package/dist/cli/lib/skills-install.js +3 -2
  116. package/dist/cli/lib/skills-install.js.map +1 -1
  117. package/dist/cli/telemetry/events.d.ts +4 -1
  118. package/dist/cli/telemetry/events.d.ts.map +1 -1
  119. package/package.json +9 -14
  120. package/dist/auto/classifier.d.ts +0 -29
  121. package/dist/auto/classifier.d.ts.map +0 -1
  122. package/dist/auto/classifier.js +0 -126
  123. package/dist/auto/classifier.js.map +0 -1
  124. package/dist/auto/composer.d.ts +0 -105
  125. package/dist/auto/composer.d.ts.map +0 -1
  126. package/dist/auto/composer.js +0 -454
  127. package/dist/auto/composer.js.map +0 -1
  128. package/dist/auto/director-prompt.d.ts +0 -25
  129. package/dist/auto/director-prompt.d.ts.map +0 -1
  130. package/dist/auto/director-prompt.js +0 -53
  131. package/dist/auto/director-prompt.js.map +0 -1
  132. package/dist/auto/index.d.ts +0 -15
  133. package/dist/auto/index.d.ts.map +0 -1
  134. package/dist/auto/index.js +0 -13
  135. package/dist/auto/index.js.map +0 -1
  136. package/dist/cli/commands/local-agent.d.ts +0 -74
  137. package/dist/cli/commands/local-agent.d.ts.map +0 -1
  138. package/dist/cli/commands/local-agent.js +0 -969
  139. package/dist/cli/commands/local-agent.js.map +0 -1
  140. package/dist/cli/lib/attach-broker.d.ts +0 -17
  141. package/dist/cli/lib/attach-broker.d.ts.map +0 -1
  142. package/dist/cli/lib/attach-broker.js +0 -27
  143. package/dist/cli/lib/attach-broker.js.map +0 -1
  144. package/dist/cli/lib/attach-drive.d.ts +0 -376
  145. package/dist/cli/lib/attach-drive.d.ts.map +0 -1
  146. package/dist/cli/lib/attach-drive.js +0 -1212
  147. package/dist/cli/lib/attach-drive.js.map +0 -1
  148. package/dist/cli/lib/attach-fleet-node.d.ts +0 -85
  149. package/dist/cli/lib/attach-fleet-node.d.ts.map +0 -1
  150. package/dist/cli/lib/attach-fleet-node.js +0 -1347
  151. package/dist/cli/lib/attach-fleet-node.js.map +0 -1
  152. package/dist/cli/lib/attach-input-recovery.d.ts +0 -190
  153. package/dist/cli/lib/attach-input-recovery.d.ts.map +0 -1
  154. package/dist/cli/lib/attach-input-recovery.js +0 -559
  155. package/dist/cli/lib/attach-input-recovery.js.map +0 -1
  156. package/dist/cli/lib/attach-mode.d.ts +0 -2
  157. package/dist/cli/lib/attach-mode.d.ts.map +0 -1
  158. package/dist/cli/lib/attach-mode.js +0 -2
  159. package/dist/cli/lib/attach-mode.js.map +0 -1
  160. package/dist/cli/lib/attach-native.d.ts +0 -27
  161. package/dist/cli/lib/attach-native.d.ts.map +0 -1
  162. package/dist/cli/lib/attach-native.js +0 -267
  163. package/dist/cli/lib/attach-native.js.map +0 -1
  164. package/dist/cli/lib/attach-passthrough.d.ts +0 -193
  165. package/dist/cli/lib/attach-passthrough.d.ts.map +0 -1
  166. package/dist/cli/lib/attach-passthrough.js +0 -778
  167. package/dist/cli/lib/attach-passthrough.js.map +0 -1
  168. package/dist/cli/lib/attach-remote-node.d.ts +0 -21
  169. package/dist/cli/lib/attach-remote-node.d.ts.map +0 -1
  170. package/dist/cli/lib/attach-remote-node.js +0 -133
  171. package/dist/cli/lib/attach-remote-node.js.map +0 -1
  172. package/dist/cli/lib/attach-view.d.ts +0 -177
  173. package/dist/cli/lib/attach-view.d.ts.map +0 -1
  174. package/dist/cli/lib/attach-view.js +0 -455
  175. package/dist/cli/lib/attach-view.js.map +0 -1
  176. package/dist/cli/lib/attach.d.ts +0 -555
  177. package/dist/cli/lib/attach.d.ts.map +0 -1
  178. package/dist/cli/lib/attach.js +0 -1180
  179. package/dist/cli/lib/attach.js.map +0 -1
  180. package/dist/cli/lib/broker-connection.d.ts +0 -65
  181. package/dist/cli/lib/broker-connection.d.ts.map +0 -1
  182. package/dist/cli/lib/broker-connection.js +0 -144
  183. package/dist/cli/lib/broker-connection.js.map +0 -1
  184. package/dist/cli/lib/broker-lifecycle.d.ts +0 -220
  185. package/dist/cli/lib/broker-lifecycle.d.ts.map +0 -1
  186. package/dist/cli/lib/broker-lifecycle.js +0 -2290
  187. package/dist/cli/lib/broker-lifecycle.js.map +0 -1
  188. package/dist/cli/lib/broker-process-identity.d.ts +0 -38
  189. package/dist/cli/lib/broker-process-identity.d.ts.map +0 -1
  190. package/dist/cli/lib/broker-process-identity.js +0 -304
  191. package/dist/cli/lib/broker-process-identity.js.map +0 -1
  192. package/dist/cli/lib/client-factory.d.ts +0 -44
  193. package/dist/cli/lib/client-factory.d.ts.map +0 -1
  194. package/dist/cli/lib/client-factory.js +0 -64
  195. package/dist/cli/lib/client-factory.js.map +0 -1
  196. package/dist/cli/lib/collect-with-retry.d.ts +0 -24
  197. package/dist/cli/lib/collect-with-retry.d.ts.map +0 -1
  198. package/dist/cli/lib/collect-with-retry.js +0 -33
  199. package/dist/cli/lib/collect-with-retry.js.map +0 -1
  200. package/dist/cli/lib/fleet-attach-target.d.ts +0 -18
  201. package/dist/cli/lib/fleet-attach-target.d.ts.map +0 -1
  202. package/dist/cli/lib/fleet-attach-target.js +0 -57
  203. package/dist/cli/lib/fleet-attach-target.js.map +0 -1
  204. package/dist/cli/lib/fleet-hint.d.ts +0 -49
  205. package/dist/cli/lib/fleet-hint.d.ts.map +0 -1
  206. package/dist/cli/lib/fleet-hint.js +0 -113
  207. package/dist/cli/lib/fleet-hint.js.map +0 -1
  208. package/dist/cli/lib/fleet-sidecar.d.ts +0 -43
  209. package/dist/cli/lib/fleet-sidecar.d.ts.map +0 -1
  210. package/dist/cli/lib/fleet-sidecar.js +0 -84
  211. package/dist/cli/lib/fleet-sidecar.js.map +0 -1
  212. package/dist/cli/lib/join-ticket.d.ts +0 -22
  213. package/dist/cli/lib/join-ticket.d.ts.map +0 -1
  214. package/dist/cli/lib/join-ticket.js +0 -96
  215. package/dist/cli/lib/join-ticket.js.map +0 -1
  216. package/dist/cli/lib/node-claim.d.ts +0 -468
  217. package/dist/cli/lib/node-claim.d.ts.map +0 -1
  218. package/dist/cli/lib/node-claim.js +0 -1349
  219. package/dist/cli/lib/node-claim.js.map +0 -1
  220. package/dist/cli/lib/node-definition-loader.d.ts +0 -19
  221. package/dist/cli/lib/node-definition-loader.d.ts.map +0 -1
  222. package/dist/cli/lib/node-definition-loader.js +0 -143
  223. package/dist/cli/lib/node-definition-loader.js.map +0 -1
  224. package/dist/cli/lib/node-provider-child.d.ts +0 -129
  225. package/dist/cli/lib/node-provider-child.d.ts.map +0 -1
  226. package/dist/cli/lib/node-provider-child.js +0 -755
  227. package/dist/cli/lib/node-provider-child.js.map +0 -1
  228. package/dist/cli/lib/predictive-echo-screen.d.ts +0 -48
  229. package/dist/cli/lib/predictive-echo-screen.d.ts.map +0 -1
  230. package/dist/cli/lib/predictive-echo-screen.js +0 -74
  231. package/dist/cli/lib/predictive-echo-screen.js.map +0 -1
  232. package/dist/cli/lib/project-broker-client.d.ts +0 -4
  233. package/dist/cli/lib/project-broker-client.d.ts.map +0 -1
  234. package/dist/cli/lib/project-broker-client.js +0 -12
  235. package/dist/cli/lib/project-broker-client.js.map +0 -1
  236. package/dist/cli/lib/reflex-capture.d.ts +0 -41
  237. package/dist/cli/lib/reflex-capture.d.ts.map +0 -1
  238. package/dist/cli/lib/reflex-capture.js +0 -128
  239. package/dist/cli/lib/reflex-capture.js.map +0 -1
  240. package/dist/cli/lib/workspace-env.d.ts +0 -8
  241. package/dist/cli/lib/workspace-env.d.ts.map +0 -1
  242. package/dist/cli/lib/workspace-env.js +0 -16
  243. package/dist/cli/lib/workspace-env.js.map +0 -1
@@ -4,14 +4,11 @@ import path from 'node:path';
4
4
  import { InvalidArgumentError } from 'commander';
5
5
  import { findProjectRoot } from '@agent-relay/config';
6
6
  import { CloudFleetSandboxProvisionError, DEV_CLOUD_API_URL, DEV_RELAYCAST_ORIGIN, deleteCloudFleetSandbox, attachCloudFleetSandboxRelayfile, ensureCloudFleetSandbox, materializeCloudRelayfileRepository, resolveWorkspaceByKey, } from '@agent-relay/cloud';
7
- import { HarnessDriverClient } from '@agent-relay/harness-driver';
8
7
  import { createWorkspaceClient, RelayPlacementError, } from '@agent-relay/sdk';
9
8
  import { withDefaults } from './core.js';
10
- import { buildRows, collectWithRetry, formatPretty, readRemoteLiveAgents, readLocalBrokerMaps, } from './fleet-agent.js';
11
- import { readBrokerConnection } from '../lib/broker-lifecycle.js';
12
- import { spawnAgentWithClient } from '../lib/client-factory.js';
9
+ import { buildRows, formatPretty, readRemoteLiveAgents, } from './fleet-agent.js';
13
10
  import { formatRelativeTime, sanitizeForTerminalLine } from '../lib/formatting.js';
14
- import { connectProjectBrokerClient } from '../lib/project-broker-client.js';
11
+ import { removedBrokerCommandMessage } from '../lib/removed-broker-command.js';
15
12
  import { AgentRemovalPendingError, parseRemovalWaitTimeout, waitForAgentRemoval, } from '../lib/agent-removal.js';
16
13
  import { classifySpawnFailure, mayStillBeRunning, nameTakenSpawnError, pendingSpawnError, probeSpawnLiveness, terminalSpawnOutcome, } from '../lib/spawn-liveness.js';
17
14
  import { heartbeatAgeMs, MAX_LIVE_HEARTBEAT_AGE_MS, isAvailableFleetNode } from '../lib/fleet-live-agents.js';
@@ -23,9 +20,11 @@ import { resolveSandboxRepository } from '../lib/sandbox-repo.js';
23
20
  import { sanitizedSpawnReceipt, spawnPlacementReceipt } from '../lib/spawn-lifecycle.js';
24
21
  import { resolveAgentToken, resolveWorkspaceSelection, persistWorkspaceRelaycastTarget, resolveWorkspaceKeyWithSource, resolveWorkspaceTransport, } from '../lib/sdk-client.js';
25
22
  import { addSdkOptions, printJson, runSdk, sdkOptionsFromOpts, withSdkDefaults, } from '../lib/sdk-command.js';
23
+ import { describeError } from '../lib/describe-error.js';
26
24
  const FLEET_NODES_ALWAYS_ON_MESSAGE = 'Fleet nodes need no per-workspace enablement; this command is a no-op.';
27
- const SERVE_REPLACEMENT_MESSAGE = "'fleet serve' has been replaced. Run 'relay node up' (with an optional --config <file>); " +
28
- "for Cloud-managed nodes run 'relay cloud enroll --token <token>' first.";
25
+ const LOCAL_SPAWN_REMOVED_MESSAGE = 'Spawning on this machine without a target was removed together with the local broker. ' +
26
+ "Run 'relay init' and spawn through the Agent Relay core (the Agent Relay MCP spawn tools or the " +
27
+ 'desktop app), or pass --node <name>, --auto-place or --sandbox to place the worker on the fleet.';
29
28
  const FLEET_CLIS = new Set([
30
29
  'claude',
31
30
  'codex',
@@ -40,15 +39,15 @@ const FLEET_CLIS = new Set([
40
39
  /**
41
40
  * Floor for `--confirm-timeout` on a verified targeted spawn.
42
41
  *
43
- * The broker holds a verified spawn open for its 90s
44
- * `VERIFIED_SPAWN_READY_TIMEOUT` (`crates/broker/src/runtime/fleet.rs`), but
42
+ * A fleet node holds a verified spawn open for its 90s readiness window
43
+ * (`VERIFIED_SPAWN_READY_TIMEOUT` on broker-backed nodes), but
45
44
  * starts that clock only after `spawn_worker_from_request` returns — i.e. after
46
45
  * process creation, the stability window, agent registration and token minting.
47
46
  * The requester's budget starts earlier, at the dispatch ack, so the two
48
47
  * windows only nest when the requester's is strictly larger. The 5s margin
49
48
  * covers the invoke round-trip, that launch work, and one
50
49
  * `DEFAULT_CONFIRM_POLL_MS` (500ms) confirmation poll. Below this floor a worker
51
- * the broker already released with `spawn_readiness_timeout` is reported as
50
+ * the node already released with `spawn_readiness_timeout` is reported as
52
51
  * `spawn_unconfirmed` — the failure shape this confirmation exists to remove.
53
52
  */
54
53
  const MIN_VERIFIED_CONFIRM_TIMEOUT_MS = 95_000;
@@ -185,8 +184,6 @@ function withFleetDefaults(overrides = {}) {
185
184
  return {
186
185
  core,
187
186
  sdk,
188
- cwd: () => process.cwd(),
189
- connectLocalBroker: async (cwd) => connectProjectBrokerClient(cwd),
190
187
  createFleetWorkspaceClient: (options) => {
191
188
  const { workspaceKey, baseUrl } = resolveWorkspaceTransport(options);
192
189
  return createWorkspaceClient({ workspaceKey, baseUrl });
@@ -295,18 +292,22 @@ function mergeFleetNodeListOptions(parentOptions, childOptions) {
295
292
  export function registerFleetCommands(program, overrides = {}) {
296
293
  const deps = withFleetDefaults(overrides);
297
294
  const group = program.command('fleet').description('Inspect and manage Agent Relay fleet nodes');
298
- // `fleet serve` has moved to `relay node up`. Keep a hidden stub so existing
299
- // invocations fail loudly with migration guidance instead of an "unknown
300
- // command" error. `allowUnknownOption` lets it swallow the old serve flags.
301
- group
302
- .command('serve', { hidden: true })
303
- .argument('[file]')
304
- .allowUnknownOption(true)
305
- .allowExcessArguments(true)
306
- .action(() => {
307
- deps.error(SERVE_REPLACEMENT_MESSAGE);
308
- deps.exit(1);
309
- });
295
+ // `fleet serve` and `fleet status` drove the local broker, which was retired.
296
+ // Keep hidden stubs so existing invocations fail loudly with migration
297
+ // guidance instead of an "unknown command" error. `allowUnknownOption` lets
298
+ // them swallow the old flags.
299
+ for (const command of ['serve', 'status']) {
300
+ group
301
+ .command(command, { hidden: true })
302
+ .argument('[args...]')
303
+ .allowUnknownOption(true)
304
+ .allowExcessArguments(true)
305
+ .helpOption(false)
306
+ .action(() => {
307
+ deps.error(removedBrokerCommandMessage(`fleet ${command}`));
308
+ deps.exit(1);
309
+ });
310
+ }
310
311
  const nodes = group
311
312
  .command('nodes')
312
313
  .description('List fleet nodes in the workspace')
@@ -344,7 +345,7 @@ export function registerFleetCommands(program, overrides = {}) {
344
345
  printJson(deps.sdk, result);
345
346
  });
346
347
  });
347
- // `fleet agent list` — the fleet-wide answer to `node agent list --pretty`.
348
+ // `fleet agent list` — which agents run on which fleet node.
348
349
  // See relay#1553 for the gap this fills and packages/cli/src/cli/commands/
349
350
  // fleet-agent.ts for the join logic (three name spaces, per-node contributions).
350
351
  const agent = group.command('agent').description('Inspect agents across the fleet');
@@ -353,7 +354,7 @@ export function registerFleetCommands(program, overrides = {}) {
353
354
  .description('List agents on every reachable fleet node, joined against the workspace roster')
354
355
  .option('--pretty', 'Render as a human-readable table')
355
356
  .option('--json', 'Render JSON output (default; explicit so the flag advertised in --help works)')
356
- .option('--node <name>', 'Return only this node and its live broker agents')
357
+ .option('--node <name>', 'Return only this node and its live agents')
357
358
  .option('--all', 'Include offline/history nodes the way `fleet nodes --all` does')).action(async (options) => {
358
359
  await runFleetAgentList(deps, options);
359
360
  });
@@ -411,7 +412,7 @@ export function registerFleetCommands(program, overrides = {}) {
411
412
  });
412
413
  addSdkOptions(group
413
414
  .command('spawn')
414
- .description('Spawn locally by default, or select a fleet node or Cloud sandbox explicitly')
415
+ .description('Spawn on a fleet node (--node or --auto-place) or a fresh Cloud sandbox (--sandbox)')
415
416
  .argument('<cli>', 'AI CLI to launch', parseFleetCli)
416
417
  .requiredOption('--name <name>', 'Worker agent name')
417
418
  .option('--task <text>', 'Initial task instructions')
@@ -431,7 +432,7 @@ export function registerFleetCommands(program, overrides = {}) {
431
432
  .option('--channel <name>', 'Channel for the worker to join')
432
433
  .option('--persona <persona>', 'Worker persona (automatic placement)')
433
434
  .option('--model <model>', 'Model powering the worker')
434
- .option('--cwd <path>', 'Working directory: defaults to the caller directory for local spawn; maps a local repo-relative path with --sandbox; otherwise selects a path on the remote node')
435
+ .option('--cwd <path>', 'Working directory: maps a local repo-relative path with --sandbox; otherwise selects a path on the remote node')
435
436
  .option('--organization <organization>', 'Declared organization for workforce reporting')
436
437
  .option('--project <project>', 'Declared project for workforce reporting')
437
438
  .option('--workstream <workstream>', 'Declared workstream for workforce reporting')
@@ -536,7 +537,6 @@ export function registerFleetCommands(program, overrides = {}) {
536
537
  let sandboxRepository;
537
538
  let liveRepository;
538
539
  let sandboxMountPaths;
539
- let attachProjectRoot;
540
540
  let workspaceRelay;
541
541
  let relaycastClientOptions = clientOptions;
542
542
  let legacyWorkspaceClientOptions = clientOptions;
@@ -599,9 +599,6 @@ export function registerFleetCommands(program, overrides = {}) {
599
599
  : sandboxRepository && pathContains(sandboxRepository.projectRoot, coreProjectRoot)
600
600
  ? coreProjectRoot
601
601
  : (sandboxRepository?.projectRoot ?? coreProjectRoot);
602
- if (path.resolve(workspaceProjectRoot) !== path.resolve(coreProjectRoot)) {
603
- attachProjectRoot = workspaceProjectRoot;
604
- }
605
602
  const sandboxClientOptions = {
606
603
  ...clientOptions,
607
604
  projectRoot: workspaceProjectRoot,
@@ -765,7 +762,7 @@ export function registerFleetCommands(program, overrides = {}) {
765
762
  ...(error.providerId === undefined ? {} : { providerId: error.providerId }),
766
763
  })
767
764
  .catch((cleanupError) => {
768
- deps.warn(`Provisioning failed after Cloud confirmed sandbox '${error.sandboxId}', and automatic cleanup failed: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
765
+ deps.warn(`Provisioning failed after Cloud confirmed sandbox '${error.sandboxId}', and automatic cleanup failed: ${describeError(cleanupError)}`);
769
766
  });
770
767
  }
771
768
  else if (error instanceof CloudFleetSandboxProvisionError && error.noSandboxCreated) {
@@ -785,7 +782,7 @@ export function registerFleetCommands(program, overrides = {}) {
785
782
  ...(error.providerId === undefined ? {} : { providerId: error.providerId }),
786
783
  })
787
784
  .catch((cleanupError) => {
788
- deps.warn(`Provisioning failed after Cloud created sandbox '${error.sandboxId}', and automatic cleanup failed: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
785
+ deps.warn(`Provisioning failed after Cloud created sandbox '${error.sandboxId}', and automatic cleanup failed: ${describeError(cleanupError)}`);
789
786
  });
790
787
  }
791
788
  if (shouldCleanupSandbox && sandbox && sandbox.outcome !== 'reused') {
@@ -796,7 +793,7 @@ export function registerFleetCommands(program, overrides = {}) {
796
793
  ...(sandbox.providerId === undefined ? {} : { providerId: sandbox.providerId }),
797
794
  })
798
795
  .catch((cleanupError) => {
799
- deps.warn(`Sandbox repository verification failed and cleanup also failed: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
796
+ deps.warn(`Sandbox repository verification failed and cleanup also failed: ${describeError(cleanupError)}`);
800
797
  });
801
798
  }
802
799
  throw error;
@@ -849,7 +846,7 @@ export function registerFleetCommands(program, overrides = {}) {
849
846
  ...(sandbox.providerId === undefined ? {} : { providerId: sandbox.providerId }),
850
847
  })
851
848
  .catch((cleanupError) => {
852
- deps.warn(`Relaycast workspace verification failed and sandbox cleanup also failed: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
849
+ deps.warn(`Relaycast workspace verification failed and sandbox cleanup also failed: ${describeError(cleanupError)}`);
853
850
  });
854
851
  }
855
852
  throw error;
@@ -871,7 +868,7 @@ export function registerFleetCommands(program, overrides = {}) {
871
868
  ...(sandbox.providerId === undefined ? {} : { providerId: sandbox.providerId }),
872
869
  })
873
870
  .catch((error) => {
874
- deps.warn(`The timed-out sandbox could not be cleaned up automatically: ${error instanceof Error ? error.message : String(error)}`);
871
+ deps.warn(`The timed-out sandbox could not be cleaned up automatically: ${describeError(error)}`);
875
872
  });
876
873
  }
877
874
  throw new Error(`Sandbox node '${sandbox.nodeName}' did not become ready within ${sandbox.waitedMs}ms.`);
@@ -886,7 +883,7 @@ export function registerFleetCommands(program, overrides = {}) {
886
883
  ...(sandbox.providerId === undefined ? {} : { providerId: sandbox.providerId }),
887
884
  })
888
885
  .catch((error) => {
889
- deps.warn(`The unmounted sandbox could not be cleaned up automatically and may still be running: ${error instanceof Error ? error.message : String(error)}`);
886
+ deps.warn(`The unmounted sandbox could not be cleaned up automatically and may still be running: ${describeError(error)}`);
890
887
  });
891
888
  }
892
889
  throw new Error('Cloud returned a sandbox node without the required Relayfile mount.');
@@ -1034,12 +1031,7 @@ export function registerFleetCommands(program, overrides = {}) {
1034
1031
  }
1035
1032
  : sandbox;
1036
1033
  printJson(deps.sdk, {
1037
- ...(sandbox
1038
- ? {
1039
- sandbox: printableSandbox,
1040
- attachCommand: sandboxAttachCommand(name, attachProjectRoot),
1041
- }
1042
- : {}),
1034
+ ...(sandbox ? { sandbox: printableSandbox } : {}),
1043
1035
  invocation: spawnInvocationWithMergedPlacement(invocation),
1044
1036
  });
1045
1037
  }
@@ -1052,7 +1044,7 @@ export function registerFleetCommands(program, overrides = {}) {
1052
1044
  ...(sandbox.providerId === undefined ? {} : { providerId: sandbox.providerId }),
1053
1045
  })
1054
1046
  .catch((cleanupError) => {
1055
- deps.warn(`Spawn failed and the sandbox could not be cleaned up automatically: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
1047
+ deps.warn(`Spawn failed and the sandbox could not be cleaned up automatically: ${describeError(cleanupError)}`);
1056
1048
  });
1057
1049
  }
1058
1050
  throw error;
@@ -1066,7 +1058,7 @@ export function registerFleetCommands(program, overrides = {}) {
1066
1058
  deleteAgent: true,
1067
1059
  })
1068
1060
  .catch((error) => {
1069
- deps.warn(`Temporary launcher cleanup failed: ${error instanceof Error ? error.message : String(error)}`);
1061
+ deps.warn(`Temporary launcher cleanup failed: ${describeError(error)}`);
1070
1062
  });
1071
1063
  }
1072
1064
  }
@@ -1077,29 +1069,7 @@ export function registerFleetCommands(program, overrides = {}) {
1077
1069
  }
1078
1070
  const persona = optionalText(options.persona, 'Persona');
1079
1071
  if (!automaticPlacement) {
1080
- if (organization || project || workstream || role || objective) {
1081
- throw new Error('Workforce metadata requires --auto-place, --node, or --sandbox.');
1082
- }
1083
- const callerCwd = deps.cwd();
1084
- const localCwd = path.resolve(callerCwd, requestedCwd ?? '.');
1085
- const local = await deps.connectLocalBroker(deps.findProjectRoot(callerCwd));
1086
- try {
1087
- await spawnAgentWithClient(local, {
1088
- name,
1089
- cli,
1090
- task,
1091
- channels: [channel ?? 'general'],
1092
- ...(model ? { model } : {}),
1093
- // A broker can be shared by nested packages. Never inherit its
1094
- // startup directory when the caller requested a local checkout.
1095
- cwd: localCwd,
1096
- });
1097
- printJson(deps.sdk, { local: { name, cli, cwd: localCwd } });
1098
- }
1099
- finally {
1100
- local.disconnect();
1101
- }
1102
- return;
1072
+ throw new Error(LOCAL_SPAWN_REMOVED_MESSAGE);
1103
1073
  }
1104
1074
  const workspace = deps.createFleetWorkspaceClient(clientOptions);
1105
1075
  const invocation = await workspace.agents.spawn({
@@ -1138,9 +1108,8 @@ export function registerFleetCommands(program, overrides = {}) {
1138
1108
  const deleteAgent = options.deleteAgent === true;
1139
1109
  const waitTimeoutMs = deleteAgent && options.wait === true ? parseRemovalWaitTimeout(options.waitTimeout) : undefined;
1140
1110
  const sdkOpts = sdkOptionsFromOpts(options);
1141
- // One transport for both cleanup and release. Cleanup otherwise
1142
- // substitutes the local broker session whenever --workspace-key is
1143
- // omitted, even if RELAY_WORKSPACE_KEY selected a different workspace.
1111
+ // One transport for both cleanup and release, so cleanup can never
1112
+ // retire bindings in a different workspace than the one released from.
1144
1113
  const transport = resolveWorkspaceTransport(sdkOpts);
1145
1114
  const cleanupOpts = {
1146
1115
  ...options,
@@ -1167,7 +1136,7 @@ export function registerFleetCommands(program, overrides = {}) {
1167
1136
  });
1168
1137
  }
1169
1138
  catch (error) {
1170
- const message = error instanceof Error ? error.message : String(error);
1139
+ const message = describeError(error);
1171
1140
  if (deleteAgent) {
1172
1141
  throw new Error(`Refusing to delete @${workerName}: could not retire provider bindings (${message}). Identity kept so \`agent-relay integration unsubscribe <provider> --owned-by @${workerName}\` can retry.`);
1173
1142
  }
@@ -1218,15 +1187,6 @@ export function registerFleetCommands(program, overrides = {}) {
1218
1187
  }
1219
1188
  });
1220
1189
  }
1221
- addSdkOptions(group.command('status').description('Show local broker status and this node’s provider attachment')).action(async (options) => {
1222
- try {
1223
- await runFleetStatus(deps, options);
1224
- }
1225
- catch (error) {
1226
- deps.error(error instanceof Error ? error.message : String(error));
1227
- deps.exit(1);
1228
- }
1229
- });
1230
1190
  }
1231
1191
  function parseFleetCli(value) {
1232
1192
  const cli = value.trim().toLowerCase();
@@ -1256,14 +1216,6 @@ function optionalTextList(value, label) {
1256
1216
  const normalized = value.map((entry) => requiredText(entry, label));
1257
1217
  return [...new Set(normalized)];
1258
1218
  }
1259
- /** Quote untrusted names in the copy-pasteable attach command printed on success. */
1260
- function shellQuote(value) {
1261
- return `'${value.replace(/'/g, `'\\''`)}'`;
1262
- }
1263
- function sandboxAttachCommand(name, projectRoot) {
1264
- const attach = `agent-relay node agent attach ${shellQuote(name)} --mode drive`;
1265
- return projectRoot ? `cd ${shellQuote(projectRoot)} && ${attach}` : attach;
1266
- }
1267
1219
  /**
1268
1220
  * Warn (on stderr, so it never pollutes the JSON on stdout) when the workspace
1269
1221
  * key was inferred from the project's persisted session rather than named
@@ -1284,40 +1236,11 @@ function warnIfInferredFromProjectSession(options, warn) {
1284
1236
  'Pass --workspace-key/--wk or set RELAY_WORKSPACE_KEY to override for this command.');
1285
1237
  }
1286
1238
  }
1287
- /**
1288
- * Assemble the local broker's contribution from the raw per-half results.
1289
- * `sessionError` is a hard failure (broker session lookup blew up) — it
1290
- * degrades to a full ERROR row so the operator can see the local machine
1291
- * itself is unreachable. `liveError` / `inventoryError` are partial and are
1292
- * preserved into the contribution so `buildRows` can render one map with a
1293
- * `(?)` marker on the missing half instead of dropping both.
1294
- */
1295
- function buildLocalContribution(node, input) {
1296
- if (input.sessionError) {
1297
- return {
1298
- node,
1299
- isLocal: true,
1300
- error: input.note ? `${input.note}: ${input.sessionError}` : input.sessionError,
1301
- ...(input.retried ? { retried: true } : {}),
1302
- };
1303
- }
1304
- return {
1305
- node,
1306
- isLocal: true,
1307
- ...(input.liveAgents !== undefined ? { liveAgents: input.liveAgents } : {}),
1308
- ...(input.liveError ? { liveError: input.liveError } : {}),
1309
- ...(input.inventoryAgents !== undefined ? { inventoryAgents: input.inventoryAgents } : {}),
1310
- ...(input.inventoryError ? { inventoryError: input.inventoryError } : {}),
1311
- ...(input.retried ? { retried: true } : {}),
1312
- };
1313
- }
1314
1239
  /**
1315
1240
  * Fan-out for `fleet agent list`. Reads `nodes.list()` for the roster of
1316
- * reachable fleet nodes, `agents.list()` for the workspace agent registry,
1317
- * and — when this machine has a running local broker — both the live worker
1318
- * map and the fleet_inventory snapshot from it. Remote live names arrive in
1319
- * the node heartbeat capabilities returned by the same `nodes.list()` call.
1320
- * A node is never dropped from the output.
1241
+ * reachable fleet nodes and `agents.list()` for the workspace agent registry.
1242
+ * Live names arrive in the node heartbeat capabilities returned by the same
1243
+ * `nodes.list()` call. A node is never dropped from the output.
1321
1244
  *
1322
1245
  * The pure join lives in {@link ./fleet-agent.ts} so it can be tested against
1323
1246
  * fixtures without wiring up the SDK.
@@ -1357,7 +1280,7 @@ async function runFleetAgentList(deps, options) {
1357
1280
  }));
1358
1281
  }
1359
1282
  catch (error) {
1360
- deps.warn(`roster unavailable (${error instanceof Error ? error.message : String(error)}); ` +
1283
+ deps.warn(`roster unavailable (${describeError(error)}); ` +
1361
1284
  'PRESENCE column will not report roster membership.');
1362
1285
  }
1363
1286
  }
@@ -1370,72 +1293,16 @@ async function runFleetAgentList(deps, options) {
1370
1293
  deps.warn('roster not queried for a targeted --node listing; PRESENCE reports node-local liveness only ' +
1371
1294
  'and does not prove absence from the workspace roster.');
1372
1295
  }
1373
- // Local broker (this machine): read /api/spawned and /api/fleet-inventory.
1374
- // The broker's node_name identifies which entry in `visibleNodes` is us.
1375
- const paths = deps.core.getProjectPaths();
1376
- const conn = readBrokerConnection(paths.dataDir);
1377
- let localNodeName;
1378
- let localLive;
1379
- let localInventory;
1380
- let localLiveError;
1381
- let localInventoryError;
1382
- /** Whole-session failure (session lookup blew up before either map ran). */
1383
- let localSessionError;
1384
- let localRetried = false;
1385
- if (conn) {
1386
- const client = new HarnessDriverClient({ baseUrl: conn.url, apiKey: conn.api_key });
1387
- try {
1388
- const session = await client.getSession();
1389
- localNodeName = session.node_name ?? undefined;
1390
- // `readLocalBrokerMaps` uses Promise.allSettled so a failure in one
1391
- // half never discards the other. `collectWithRetry` retries the pair
1392
- // once as a unit; a per-half retry policy is more code for no
1393
- // observable win when both halves hit the same broker.
1394
- const result = await collectWithRetry('local broker', () => readLocalBrokerMaps(client));
1395
- if (result.ok) {
1396
- localLive = result.value.liveAgents;
1397
- localLiveError = result.value.liveError;
1398
- localInventory = result.value.inventoryAgents;
1399
- localInventoryError = result.value.inventoryError;
1400
- localRetried = result.retried;
1401
- }
1402
- else {
1403
- // Both halves failed as a unit — record it as a session error so
1404
- // the contribution below renders an explicit ERROR row rather than
1405
- // silently pretending both maps were empty.
1406
- localSessionError = result.error;
1407
- localRetried = result.retried;
1408
- }
1409
- }
1410
- catch (error) {
1411
- localSessionError = `local broker: ${error instanceof Error ? error.message : String(error)}`;
1412
- }
1413
- finally {
1414
- client.disconnect();
1415
- }
1416
- }
1417
- // Assemble per-node contributions. Brokers encode the live WorkerName set
1296
+ // Assemble per-node contributions. Nodes encode the live WorkerName set
1418
1297
  // in reserved heartbeat capabilities. This path is independent of agent
1419
1298
  // registration and adds no API call beyond nodes.list(): no workspace
1420
1299
  // roster and no node-binding read.
1421
1300
  const contributions = [];
1422
1301
  for (const node of visibleNodes) {
1423
- if (localNodeName && node.name === localNodeName) {
1424
- contributions.push(buildLocalContribution(node, {
1425
- liveAgents: localLive,
1426
- liveError: localLiveError,
1427
- inventoryAgents: localInventory,
1428
- inventoryError: localInventoryError,
1429
- sessionError: localSessionError,
1430
- retried: localRetried,
1431
- }));
1432
- continue;
1433
- }
1434
1302
  const remote = readRemoteLiveAgents(node);
1435
1303
  if (remote.supported) {
1436
1304
  contributions.push({
1437
1305
  node,
1438
- isLocal: false,
1439
1306
  remoteAgents: remote.agents,
1440
1307
  ...(remote.warning ? { remoteWarning: remote.warning } : {}),
1441
1308
  });
@@ -1443,40 +1310,10 @@ async function runFleetAgentList(deps, options) {
1443
1310
  else {
1444
1311
  contributions.push({
1445
1312
  node,
1446
- isLocal: false,
1447
- remoteError: 'broker heartbeat does not publish live agent names',
1313
+ remoteError: 'node heartbeat does not publish live agent names',
1448
1314
  });
1449
1315
  }
1450
1316
  }
1451
- // Guarantee the local machine appears somewhere in the output even if
1452
- // `nodes.list()` filtered its record out or the workspace never saw it.
1453
- // Dropping the local machine's contribution silently was one of the
1454
- // review findings on the first pass — this is the third-state discipline
1455
- // applied to the local node itself, not just to per-agent rows.
1456
- const localNodeIsInScope = requestedNodeName === undefined || (localNodeName !== undefined && requestedNodeName === localNodeName);
1457
- if (localNodeIsInScope &&
1458
- (localNodeName || localSessionError || conn) &&
1459
- !contributions.some((c) => c.isLocal)) {
1460
- const syntheticNodeName = localNodeName ?? (process.env.AGENT_RELAY_BROKER_NAME?.trim() || undefined) ?? '(local broker)';
1461
- // Keep the authoritative roster metadata when the node was filtered from
1462
- // the default visible set. This preserves a known offline/degraded
1463
- // control-plane state while still showing node-local workers.
1464
- const knownLocalNode = nodes.find((node) => node.name === syntheticNodeName);
1465
- const syntheticNode = knownLocalNode ?? {
1466
- name: syntheticNodeName,
1467
- status: 'unknown',
1468
- capabilities: [],
1469
- };
1470
- contributions.unshift(buildLocalContribution(syntheticNode, {
1471
- liveAgents: localLive,
1472
- liveError: localLiveError,
1473
- inventoryAgents: localInventory,
1474
- inventoryError: localInventoryError,
1475
- sessionError: localSessionError,
1476
- retried: localRetried,
1477
- note: 'local broker not in visible node list',
1478
- }));
1479
- }
1480
1317
  const now = new Date();
1481
1318
  const output = buildRows({ contributions, roster }, now);
1482
1319
  const heartbeatNodes = contributions.map(({ node }) => ({
@@ -1494,66 +1331,10 @@ async function runFleetAgentList(deps, options) {
1494
1331
  printJson(deps.sdk, {
1495
1332
  generatedAt: now.toISOString(),
1496
1333
  nodes: heartbeatNodes,
1497
- localNode: localNodeName ?? null,
1498
1334
  perNode: output.perNode,
1499
1335
  unplacedRoster: output.unplacedRoster,
1500
1336
  errors: output.errors,
1501
1337
  });
1502
1338
  });
1503
1339
  }
1504
- async function runFleetStatus(deps, options) {
1505
- const paths = deps.core.getProjectPaths();
1506
- const conn = readBrokerConnection(paths.dataDir);
1507
- let broker = { running: false };
1508
- let nodeName;
1509
- if (conn) {
1510
- const client = new HarnessDriverClient({ baseUrl: conn.url, apiKey: conn.api_key });
1511
- try {
1512
- const session = await client.getSession();
1513
- nodeName = session.node_name;
1514
- broker = {
1515
- running: true,
1516
- url: conn.url,
1517
- pid: conn.pid,
1518
- workspaceKey: session.workspace_key,
1519
- brokerVersion: session.broker_version,
1520
- protocolVersion: session.protocol_version,
1521
- nodeId: session.node_id,
1522
- nodeName: session.node_name,
1523
- };
1524
- }
1525
- catch (error) {
1526
- broker = {
1527
- running: false,
1528
- url: conn.url,
1529
- pid: conn.pid,
1530
- error: error instanceof Error ? error.message : String(error),
1531
- };
1532
- }
1533
- finally {
1534
- client.disconnect();
1535
- }
1536
- }
1537
- // Provider attachment (per-provider liveness) is owned by the engine now, not a
1538
- // local status file; read this node's record from the nodes API.
1539
- let node;
1540
- if (nodeName) {
1541
- try {
1542
- const relay = deps.sdk.createWorkspaceRelay(sdkOptionsFromOpts(options));
1543
- const nodes = await relay.nodes.list({ name: nodeName });
1544
- node = nodes[0] ?? { available: false, reason: `no node named "${nodeName}" in the workspace` };
1545
- }
1546
- catch (error) {
1547
- node = { error: error instanceof Error ? error.message : String(error) };
1548
- }
1549
- }
1550
- else {
1551
- // A running broker that never reported a node name means the engine lookup
1552
- // was skipped — say so rather than looking fully checked.
1553
- node = { available: false, reason: 'broker did not report a node name' };
1554
- }
1555
- // Redact the node token / workspace key structurally so status output (which a
1556
- // user may paste into a bug report) never carries a live credential.
1557
- deps.log(JSON.stringify(redactSecrets({ broker, node }), null, 2));
1558
- }
1559
1340
  //# sourceMappingURL=fleet.js.map