feat: promote archie-agent to NATS-connected per-task worker

Replaces stdin/stdout subprocess transport with NATS JetStream
request-reply pattern. The Runner interface and workflow orchestration
are unchanged.

New NATSRunner (implements Runner):
- Publishes AgentRequestMessage to JetStream with X-Archie-Reply header
- Blocks on core NATS inbox subscription for response
- Same Run(ctx, workspace, req) (Result, error) contract

Rewritten archie-agent (cmd/archie-agent):
- Long-running NATS-connected process (was 28-line stdin/stdout)
- Pull-consumes from ARCHIE_TASKS with archie.agent.> filter
- Builds InProcessRunner, executes agent loop, replies to inbox
- Graceful shutdown via signal handling

Extended internal/nats:
- SubjectAgentWildcard, SubjectForAgentRequest, ReplyHeader
- Conn() accessor, NewReplyInbox(), PublishMsg() for JetStream
- Stream subjects extended to ["archie.task.>", "archie.agent.>"]

Config: "nats" added as valid agent.mode alongside inprocess/subprocess
Tests: NATSRunner round-trip with embedded NATS server + handler
This commit is contained in:
sam committed 2026-07-22 02:13:01 +10:00
1 parent bb2193e5e4
commit 8c4bb1ef1d
11 files changed
+1309 -18

No files matched your search

+2 -2
View File
@@ -37,8 +37,8 @@ api_key_env = "OPENAI_API_KEY"
class = "ollama"
[agent]
mode = "inprocess" # "subprocess" runs each autonomous stage through archie-agent
command = "archie-agent" # executable path for subprocess mode
mode = "inprocess" # "subprocess" runs each stage through archie-agent (stdin/stdout); "nats" sends stages over NATS
command = "archie-agent" # executable path for subprocess mode (not used in nats mode)
# Subprocess mode isolates the protocol and process lifecycle, not OS privileges.
# The worker still runs as the daemon user until the Docker sandbox phase lands.
# env = ["GOCACHE"] # extra environment variable names forwarded to the worker