Files
archie/internal/domain/messaging/commands.go
T
sam 800352a692 feat(gateway): give /status a real daemon-health surface (#892)
* feat(gateway): give /status a real daemon-health surface

Phase 2 of archie-core-wp9s. Phase 1 split the commands apart (health vs
work) but left /status with one aggregate queue line and a static runtime
block; it could not answer the questions an operator actually asks when
something feels wrong. /status now reports, between the queue line and the
runtime block:

- Broker: the live state of this process's own NATS connection
  (eventbus/nats.Client.Connected), not a fresh dial -- a probe would
  report the probe's reachability, not the daemon's.
- Containers: the pool's own active counter against the configured cap
  (Pool.Active/Cap), not a Docker listing, which would include containers
  this pool does not own. A zero cap means unlimited, so it is not shown
  as a ratio.
- Channels: the channel manager's real lifecycle state, including a
  failed adapter's reason (the documented decision: read the existing
  manager rather than re-deriving health per adapter).
- Chat model: last-known outcome of every chat-model call this process
  made, recorded once in sendChatTurn (the single choke point) and read
  back by /status. The second documented decision: never a live probe,
  so /status stays instant and reports what happened -- or says plainly
  that nothing has been attempted yet.
- Last poll: when the most recent poll pass began, stamped on both poll
  paths (Run's single-identity loop and runIdentities' per-identity
  goroutines). A pass that hangs leaves the stamp stale, which is the
  signal; stamping completion would leave a wedged poller looking
  healthy.

Truthful or absent: a section this process has no source for is omitted
rather than rendered as a zero. The standalone Gateway owns no poll loop,
pool or channel manager, so its /status reports broker and chat-model
health only; aggregating across processes would need a new daemon RPC and
is deliberately not built. Version stays out (/version owns it).

/status and /tasks descriptions now describe what each command actually
does on both published surfaces (Telegram menu/help and the shared
specs), pinned by a test that also fails if the two surfaces drift.

Sources are read through functions, not captured values: occupancy and
channel state move, and the daemon is built after the gateways, so a
source captured at construction would freeze /status on boot state.

Left in place deliberately: the Runtime (provider/model) block, which
Phase 1 flagged and which duplicates /model and /whoami. Removing it is a
product call on a command Sam uses daily, not a mechanical follow-up.

* docs(prds): record the two open /status health decisions as settled

Both were flagged in PR #892 as needing the maintainer's call; both are now
answered, and the PRD is the place a follow-up would look:

- The Runtime (provider/model) block stays. It is the one line in /status the
  ticket's own rule says should not be there, but /status is read daily to see
  the active model at a glance, so the duplication is deliberate. Recorded as a
  settled product decision so it is not removed later as an oversight.
- Health stays per-process. Pooling the daemon's and the Gateway's chat-model
  outcomes would need a new daemon<->gateway health RPC for one status line, and
  a per-process line is true where an aggregate would be a claim about a process
  the answering one cannot see.

/agents' published description is still left to archie-core-mxls, unchanged.
2026-09-20 00:30:23 +10:00

65 lines
3.8 KiB
Go

package messaging
// localCommands is the executable gateway-local command list. It lives here
// beside CommandSpec so adapter-published help surfaces cannot drift from
// the executable router surface.
var localCommands = []string{
"/status", "/tasks", "/model", "/spawn",
"/approve", "/cancel", "/start",
"/new", "/reset", "/topic", "/retry", "/undo",
"/title", "/branch", "/fork", "/compress", "/compact",
"/whoami", "/profile", "/sessions", "/resume", "/delete", "/agents",
"/personality", "/help", "/version", "/update", "/restart",
}
// CommandSpec describes a local command for adapter-provided discovery.
type CommandSpec struct {
Command string `json:"command"`
Description string `json:"description"`
Usage string `json:"usage"`
}
var localCommandSpecs = []CommandSpec{
{Command: "/status", Description: "Show daemon health: broker, workers, channels, provider", Usage: "/status"},
{Command: "/tasks", Description: "Show your tasks: state, stage, age, parked reason", Usage: "/tasks"},
{Command: "/model", Description: "Choose a provider and model", Usage: "/model [provider/model]"},
{Command: "/spawn", Description: "Create a tracked task", Usage: "/spawn <title>"},
{Command: "/approve", Description: "Approve a waiting task", Usage: "/approve <task-id>"},
{Command: "/cancel", Description: "Cancel a queued or waiting task", Usage: "/cancel <task-id>"},
{Command: "/start", Description: "Confirm that Archie is running", Usage: "/start"},
{Command: "/new", Description: "Start a fresh conversation", Usage: "/new [title]"},
{Command: "/reset", Description: "Alias for /new", Usage: "/reset [title]"},
{Command: "/topic", Description: "List or switch conversation topics", Usage: "/topic [session-id]"},
{Command: "/retry", Description: "Replay the last message", Usage: "/retry"},
{Command: "/undo", Description: "Remove recent messages", Usage: "/undo [N]"},
{Command: "/title", Description: "Show or set the conversation title", Usage: "/title [name]"},
{Command: "/branch", Description: "Create a child conversation", Usage: "/branch [name]"},
{Command: "/fork", Description: "Alias for /branch", Usage: "/fork [name]"},
{Command: "/compress", Description: "Compress conversation context", Usage: "/compress [options]"},
{Command: "/compact", Description: "Alias for /compress", Usage: "/compact [options]"},
{Command: "/whoami", Description: "Show the active identity and model", Usage: "/whoami"},
{Command: "/profile", Description: "Show the active identity profile", Usage: "/profile"},
{Command: "/sessions", Description: "List this channel's conversations", Usage: "/sessions"},
{Command: "/resume", Description: "Switch to a conversation", Usage: "/resume <session-id>"},
{Command: "/delete", Description: "Delete a conversation and its history", Usage: "/delete <session-id>"},
{Command: "/agents", Description: "List tasks currently being worked", Usage: "/agents"},
{Command: "/personality", Description: "Choose a communication style", Usage: "/personality [name]"},
{Command: "/help", Description: "See what Archie can do", Usage: "/help"},
{Command: "/version", Description: "Show installed Archie versions", Usage: "/version"},
{Command: "/update", Description: "Check for Archie updates", Usage: "/update"},
{Command: "/restart", Description: "Reload the chat adapter", Usage: "/restart"},
}
// LocalCommands returns the command names Route answers from local state.
// Gateways use this to verify that their published command surfaces match
// the executable router surface.
func LocalCommands() []string {
return append([]string(nil), localCommands...)
}
// LocalCommandSpecs returns a copy safe for adapters to enrich with their
// optional capabilities.
func LocalCommandSpecs() []CommandSpec {
return append([]CommandSpec(nil), localCommandSpecs...)
}