Host tools — an agent's buttons: publish_action and remove_action, stop and command actions, presses in chats and team runs. A repository rule for apps/daemon/src/v1/agents/**/action-*, apps/daemon/src/v1/agents/**/action.broker*, apps/daemon/src/v1/agents/**/chat-actions*, apps/daemon/src/v1/agents/**/host-action*, apps/daemon/src/v1/teams/**/team-actions*, apps/daemon/src/v1/mcp/tools/publish-action/**, apps/daemon/src/v1/mcp/tools/remove-action/**; read it before editing a file there.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Rule Daemon Host Tools Actions?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/geniro-io-rule-daemon-host-tools-actions)
---
name: rule-daemon-host-tools-actions
description: "Host tools — an agent's buttons: publish_action and remove_action, stop and command actions, presses in chats and team runs. A repository rule for apps/daemon/src/v1/agents/**/action-*, apps/daemon/src/v1/agents/**/action.broker*, apps/daemon/src/v1/agents/**/chat-actions*, apps/daemon/src/v1/agents/**/host-action*, apps/daemon/src/v1/teams/**/team-actions*, apps/daemon/src/v1/mcp/tools/publish-action/**, apps/daemon/src/v1/mcp/tools/remove-action/**; read it before editing a file there."
---
<!-- GENERATED by scripts/sync-agent-rules.mjs from .claude/rules/daemon-host-tools-actions.md. DO NOT EDIT: edit the source, then run `pnpm sync:agent-rules`. -->
# Host tools — agent buttons
- `publish_action` / `remove_action` (an agent's buttons, `ActionBroker` → `ActionPublishService`): append-only `action` / `action_outcome` rows, never edited. `ChatActionsService` is their one writer and holds the per-run lock every publish, press and dismissal takes; the live set is folded from the whole run (`utils/action-fold.ts`) and served as run state's `actions`, never folded by a client. An outcome counts only against the publish seq it names, so a press of a republished button is refused `409 ACTION_CHANGED`. An id is scoped to its publishing conversation; 20 live per run, the 21st refused. Labels refuse controls, format characters and line separators; the card and tooltip show a message's exact text before it is pressed. Press and dismiss (`ActionPressService`, chat routes `:runId/actions/:seq/press|dismiss`) carry no desktop-only guard; `via` comes from `cameViaRemote`. A message press on a busy chat answers the chat's own `RUN_BUSY` with nothing written, and the renderer presses the same seq again with the same `clientMessageId` when the turn settles.
- Team members publish too (`TeamExecutorService.registerActionPublishers`, every call-capable member, dropped with the run): the publisher is built per call from the MCP `caller` — `conversationId` and the `callId` it answers (`CallBroker.callAnsweredBy`) sit inside `publisher`, never at the row's top level, so the rows stay in the run's own flow (`CALLER_FLOW_KINDS`). `agentLabel` is stamped on every publisher but the run's lead in its own conversation. A button published inside a call — or after it settled, starting from `CallBroker.callToNoteOn` as for pages — is named in that call's and every running ancestor's envelope under `actions` (`CallBroker.notePublishedAction`, noted after the live cap and before the write, undone if the row fails; a republish also refreshes every running call already naming its key, and a removal drops the key from every running call — `forgetPublishedAction`).
- A stop action (`stop: {shell}` or `{pid}`) is resolved at publish by `ActionStopService` and always one-shot: a shell id (its `workId` or launching call id) names one of the publishing MEMBER's open `shell_open` rows (a member's conversations share them, so a refusal lists their ids, never their commands), whose launching call's command (`launchingCallOf`, never a delegate's call; an id naming shells of more than one conversation is refused) is matched (`commandTargets`) among the run's `RunProcessReaper.stopCandidates`; a command matching more than one separate process is refused, the agent pointed to `stop.pid`; a pid must itself be a candidate. Only the named process (or the command's top match) is recorded: what it starts is stopped at the press, never refused for having left the run, so a lost untagged worker cannot disable the button. Known limit: the command text is all that ties a shell to a process, so if the shell's own process has already exited while its row still reads open, a single other process whose command contains it is taken for it — the card shows its command line before the press. Never `ChatShellsService.kill`'s machine-wide match. Each target's `{pid, startedAt (ISO), command}` is recorded, the command one line, masked (`maskedCommand`: env assignment values and registered secrets). A press claims the button under the lock (`ACTION_BUSY` to a second press or a dismissal, held in memory so a daemon dying mid-stop leaves nothing pending), stops OUTSIDE the lock through `stopRecorded`, and records `stopped` (`alreadyStopped` when every target had exited) or `failed` with the refusal, which keeps the button live — unless the agent removed or republished the button meanwhile, when a failure answers `ACTION_GONE` / `ACTION_CHANGED` and writes nothing, so the removal or the newer publish stands.
- A command action (`command: {argv, cwd?, timeout_minutes?, notify_agent?}`) is checked at publish: argv non-empty tokens with no control, invisible or bidi characters, at most `ACTION_COMMAND_MAX` characters; `cwd` an existing absolute directory, canonicalized, else the run's own folder (`ActionCommandService.resolveCwd`, run again at the press: a folder now leading elsewhere fails the run); 1–60 minutes, default 10, over 60 refused. The renderer runs nothing until the user confirms a dialog showing the exact argv and cwd (desktop and phone alike). A press writes `running` under the lock (a second press answers `ACTION_BUSY`), then runs OUTSIDE it through `runManagedCommand`: argv only, `buildChildEnv`, `runTagEnv`, `endGroupOnExit` (what the command backgrounded does not outlive it; a setsid'd process escapes to the run-tag reaper) and a settle on the exit after `EXIT_DRAIN_MS` even when a descendant holds the pipes. The output tail (both streams in arrival order) is masked (`redactSecrets`) before it is cut to `ACTION_OUTPUT_TAIL_MAX`. The finish row (`succeeded` / `failed` with `exitCode`, `outputTail`, `error`) is written whenever the run still exists, also after the agent removed or replaced the button (the fold never revives a retired publish). Each running command holds a slot in `ActionCommandRegistry`: `RunTeardownService.endProcesses` aborts them (archive and delete), a slot started within `ABORTED_RUN_MS` of that starts already aborted (`RunTeardownService.resumeProcesses` lifts it on unarchive), and `beforeApplicationShutdown` aborts every slot, and any started later, ahead of `ProcessRegistry`'s drain. A press reaching the lock while the run's commands are being ended is refused `RUN_ARCHIVED`; otherwise its slot is started before the `running` row is written. An aborted command ends `interrupted` and the agent is not told; `purge` waits (bounded) for its last row. `interrupted` retires a one-shot button only; a reusable one stays to be run again. `notify_agent` then delivers `[Action "<label>" finished: exit N]` and the last `ACTION_NOTIFY_TAIL_MAX` of output inside a fence tagged with a random id per message (`<command-output-<id>>`, which the output cannot print), after a line saying it is the command's output and not the user's words, through the press's own delivery (a team's goes to the run's lead), re-sent under one `clientMessageId` every `ACTION_NOTIFY_RETRY_MS` while the run answers `RUN_BUSY`, dropped on any other refusal, and lost if the daemon stops first. `ActionOutcomeSweep` (boot, after `reconcileStrandedShells`) writes `interrupted` for every publish whose newest outcome is `running` — live, removed or replaced — that a prior daemon left; its child was ended by the stranded-child reaper.
- A team press (`TeamActionsService`, `POST /v1/teams/runs/:runId/actions/:seq/press|dismiss`) delivers through `TeamExecutorService.sendMessage` — to the run's lead (the trigger's member), never the publisher's own conversation — prefixed `From <agentLabel> (action "<label>"):` when the publisher carries a label. The chat routes refuse a team run (`NOT_A_CHAT_RUN`) and these a chat run (`NOT_A_TEAM_RUN`), checked in `ActionPressService.assertPressable` by the route's `ActionRunKind`.