feat(service): reach a Manager's followers' Macs

Merged
DA
3d ago
+25157-35

PR 2 of the Manager settings plan (STAG-4014, STAG-4025). PR 1 (#10769) added agent_follower. This PR makes the Mac tools read it, adds the procedures and a live read over it, and makes messaging a Manager follow it.

What changes

  • Routing

    • findMacOwner now answers managerId, the agent itself, where the agent stands on no task. It reads through a worker's conversation to its Manager, as it already did for tasks.
    • peopleOf reads the Manager's followers (listAgentFollowers) in place of a task's.
    • routeOf, defaultMachinesOf (the composer's machine list) and list_machines then reach a follower's Mac while their switch is on. They needed no changes of their own.
    • Refusals now say "this task's or Manager's agents", in the service's words and on the panel's refusal card. list_machines's description names a Manager's followers.
  • Hosted procedures (agentFollowers), additive only:

    • list: GET /api/agents/{id}/followers
    • follow / unfollow: PUT / DELETE …/following
    • setMachines: PUT …/following/machines
    • add: POST …/followers
    • remove: DELETE …/followers/{userId}

    Each answers { agentId, followers: [{ userId, owner, machines }], txid? }. An agent the caller doesn't reach, or one on a task, answers not-found. Unfollowing or removing the owner, or switching the owner's machines, answers not-permitted. No floor or version change. In the member MCP coverage, list is SCREEN_ONLY and the writes are MEMBER_ONLY, as the task follower procedures are.

  • Live read agentFollowers (/api/live/agent-followers?id=) has two parts:

    • owner: one row while the owner is a member of the workspace;
    • followers: the other followers who are still members, with their switch.

    It is gated like the store (agentReachableBy, agent on no task, the reader's membership joined) and woken on the agent's topic. agent_follower is now synced (migration sync_agent_follower, rendered by sync:render).

  • Follow on message: followAsMessaged now takes the agent. On no task, it follows the Manager with machines on (followAgentAsMessaged), and an existing follower keeps their switch. Both the typed and the queued paths go through it.

"Who asked" routing (sending a call to the Mac of the member whose line opened the turn) is not here. That is PR 3, STAG-4028.

Tests

  • machine-routing.test.ts, new case: a Manager's pick of a teammate's Mac is refused before they follow, refused as not-let while their switch is off, and taken once it's on. A follower row naming someone outside the workspace never reaches their Mac. The composer's list offers only the follower's machine. I saw it fail with the Manager branch of peopleOf turned off.
  • agents-app-messages.test.ts, new case: a teammate who messages a Manager follows it with their machines on. I saw it fail without the change.
  • live-procedures.test.ts, new case: a member reads the owner and a follower. A member of another workspace, and a read of an agent on a task, answer not-found.
  • I ran these three files whole, plus agent-queue-app.test.ts, sync/live-query.test.ts, database/sync/__tests__/capture.test.ts, orpc/handler.test.ts, orpc/base.test.ts, apps/web/tests/orpc-route.test.ts and storage-schema.test.ts. All pass.
  • tsc -b for the service, repository-checks.sh, oxlint, biome and the style guard pass. Knip reports nothing for these files. CI runs the rest.

šŸ¤– Generated with Claude Code