Gas City runtime for headless Claude Code wrapped into ACP, with an MCP server that gives remote agents an interface to Gas City and Beads
This repository has been archived on 2026-11-20. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • Go 98.9%
  • Dockerfile 0.8%
  • Shell 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Mikhail Lukianchenko 3843d30bf9
All checks were successful
test / changelog (push) Successful in 4s
release / plan (push) Successful in 7s
release / image (push) Successful in 30s
release / release (push) Successful in 1s
test / go (push) Successful in 1m25s
Job names: the scope and the agent; the bead as a label; release 0.11.0 (#26)
The session's own bead told nothing a reader wanted and made every name start alike; the work bead is not known when the Job is made, so it shows as a label instead. The city's name is read from its pack.toml, since gc gives a city session no variable naming the city.

Reviewed-on: #26
2026-11-20 18:09:13 +00:00
.forgejo/workflows Keep changelog notes as fragments in .changelog/ (#15) 2026-11-19 19:15:43 +00:00
apt Add the akephalos pack, roomcity's runtime without chat (#1) 2026-11-17 13:21:10 +00:00
cmd/ak6s Per-agent service_account; release 0.10.0 (#22) 2026-11-20 10:12:17 +00:00
examples/minimal Release 0.9.0 (#21) 2026-11-19 23:46:40 +00:00
internal Job names: the scope and the agent; the bead as a label; release 0.11.0 (#26) 2026-11-20 18:09:13 +00:00
proto/ak6s/v1 Release 0.4.0: rename the pack akephalos to ak6s (#8) 2026-11-18 20:32:57 +00:00
scripts Release 0.4.0: rename the pack akephalos to ak6s (#8) 2026-11-18 20:32:57 +00:00
.dockerignore Add the akephalos pack, roomcity's runtime without chat (#1) 2026-11-17 13:21:10 +00:00
.gitignore Keep changelog notes as fragments in .changelog/ (#15) 2026-11-19 19:15:43 +00:00
buf.gen.yaml Release 0.4.0: rename the pack akephalos to ak6s (#8) 2026-11-18 20:32:57 +00:00
buf.yaml Add the akephalos pack, roomcity's runtime without chat (#1) 2026-11-17 13:21:10 +00:00
CHANGELOG.md Job names: the scope and the agent; the bead as a label; release 0.11.0 (#26) 2026-11-20 18:09:13 +00:00
Dockerfile Release 0.4.0: rename the pack akephalos to ak6s (#8) 2026-11-18 20:32:57 +00:00
go.mod Answer gc's read-only probes from a watch-backed cache of the Jobs (#19) 2026-11-19 23:37:29 +00:00
go.sum Answer gc's read-only probes from a watch-backed cache of the Jobs (#19) 2026-11-19 23:37:29 +00:00
Makefile Add the akephalos pack, roomcity's runtime without chat (#1) 2026-11-17 13:21:10 +00:00
pack.toml Release 0.4.0: rename the pack akephalos to ak6s (#8) 2026-11-18 20:32:57 +00:00
README.md Job names: the scope and the agent; the bead as a label; release 0.11.0 (#26) 2026-11-20 18:09:13 +00:00
renovate.json Add the akephalos pack, roomcity's runtime without chat (#1) 2026-11-17 13:21:10 +00:00

ak6s

Ak6s is a Gas City pack for headless Claude Code sessions over the Agent Client Protocol (ACP). Its pack.toml declares the runtime ak6s, with protocol 0 and the executable gc-runtime-ak6s.

Contents

One binary, ak6s, provides the five process entrypoints:

Command Also runs as Purpose
ak6s runtime gc-runtime-ak6s Executes one Gas City Runtime Provider Protocol operation through the server.
ak6s server Runs beside gc's supervisor and owns session state and Kubernetes execution.
ak6s host Stages and drives one session's ACP agent in its pod.
ak6s gc gc Proxies a session's gc invocations to the real gc in the city directory.
ak6s transcript Prints a session's transcript, read on stdin, as its narrative.

The ConnectRPC contracts are in proto/ak6s/v1: RuntimeService, HostService, and GcService. Generated Go code is in internal/gen/ak6s/v1.

The retained runtime is split into these packages:

  • internal/operate and internal/runtimecmd: start, stop, liveness, inventory, nudge, metadata, observation, screen, interruption, and process operations.
  • internal/kube: one Kubernetes Job and one environment Secret per session, with configured mounts, annotations, placement, resources, and lifecycle inspection.
  • internal/host: working-directory staging, Claude Code through claudeacp, ACP process execution, prompting, cancellation, and ordered frame reporting.
  • internal/gchandler and internal/standin: the authenticated in-pod gc proxy. The server supplies the recorded session identity rather than trusting identity variables sent by the pod.
  • internal/session: the durable SQLite registry of sessions, starts, raw ACP events, nudges, instruction queues, bundles, token hashes, and activity. The server stores it as ak6s.db under [server] data.
  • internal/screen: the text screen used by gc's peek and idle-boundary operations.
  • internal/procs: configured service processes that do not have an ACP host.

examples/minimal contains an example city and Kubernetes deployment. The Dockerfile builds the image sarak.sh/mikluko/gascity-ak6s-pack, which carries ak6s, gc, bd, Dolt, Git, Claude Code, and goose, and runs as uid 1000. The CI workflows test the Go tree and generated protobufs, build the image's smoke stage, and publish releases.

Configuration

ak6s server reads the file named by -config or AK6S_CONFIG. Without either, it tries ./ak6s.toml, then /etc/ak6s/ak6s.toml. Unknown keys are errors. The required keys are:

[server]
data = "/absolute/path/to/state"
city_dir = "/path/to/city"
url = "https://ak6s.example.internal"

[kube]
namespace = "ak6s-example"
image = "sarak.sh/mikluko/gascity-ak6s-pack:latest"

server.gc defaults to gc; server.listen to :8080; and server.runtime_listen to the loopback address 127.0.0.1:8082. server.start_timeout and server.stop_grace accept Go duration strings. Agent tables support always_on, process, secrets, pod_annotations, claude_claim, and service_account. The [kube] table holds the shared Job, Secret, annotation, placement, and resource settings. A [perplexity] table turns the optional Perplexity tools on for every session, or for the sessions of the agents it names; Perplexity tools gives it key by key. kube.service_account names a Kubernetes service account that every session's pod runs as, with the account's token mounted; unset, the pod names no service account and mounts no token. An agent table's service_account replaces it for that agent's sessions, with the token mounted either way, so each agent can run as an account with an identity of its own. For secrets, pod_annotations, claude_claim, and service_account the table that serves an agent is the one named exactly as the agent, else the first table, in name order, whose name matches the agent's name as a pattern, as process does, and that sets the field; so [agents."*/argos.researcher"] covers that agent in every rig. The agent's service_account replaces [kube]'s, and an agent's secret replaces a [kube] secret with the same env, path_env, or mount_path. A process table takes none. Each [[kube.forwards]] entry has listen and target, both host:port; the session host relays connections made to listen in the pod to target for as long as it runs, and listens before the agent starts. It lets a program in the session find a service on the pod's loopback where its configuration names one:

[[kube.forwards]]
listen = "127.0.0.1:3306"
target = "dolt.gascity-argos.svc.cluster.local:3306"

The pod environment is held in a Secret owned by its Job and loaded with envFrom; it is not written directly into the Job spec. Configured Secret mounts can inject file contents or paths into the agent environment. Pod annotation values support {agent} and {session} substitution.

The Job carries the annotations ak6s.sarak.sh/session and ak6s.sarak.sh/agent, and its pod the configured ones. The annotation ak6s.sarak.sh/bead names the bead the session works, and so does the label of that name wherever the id is a valid label value, so that kubectl get pods -L ak6s.sarak.sh/bead shows it in a column. A Job is named after the session's rig, else the city's name in its pack.toml, else nothing, then the agent's own name and a hash of the session, as gascity-ak6s-pack-referee-0e5d3e76. A session claims its bead after the server made the Job — GC_SESSION_ID names the session's own bead, not the work — so the Job is made with the annotation absent and the server sets it from gc's event stream, gc events --follow --type bead.updated, when a claim's assignee is the session's GC_SESSION_ID: the bead's id replaces the value the annotation holds, so a session that claimed twice names its latest and a session whose bead closed keeps the last id. A bead of the type session is never the value.

Session continuity

A session whose Job is replaced continues its Claude Code conversation when its agent's table names a claim:

[agents.foreman]
claude_claim = "claude-{agent}"

claude_claim is the name of a PersistentVolumeClaim in kube.namespace; {agent} and {session} in it are replaced. The city creates the claim, and a name made with {session} must be a valid claim name. The server does not create or delete claims.

The Job mounts the claim at /var/lib/ak6s/claude, sets the pod's fsGroup to the pod's user, and tells the host to use that directory as Claude's config directory. The host stores the session's ACP session id in a file there.

When gc continues a session and the host finds the id, it calls ACP session/resume, or session/load when the agent does not offer resume, with the id and the working directory gc gave the session. A gc fresh start calls session/new and replaces the saved id. A continuation also calls session/new when there is no id, when the agent has no conversation for it, or when the agent offers neither resume nor load. Without claude_claim, every start is new. Claude's project folder derives from the working directory, so a resumed session needs the same one at each start.

OpenTelemetry

With an endpoint, every session's Claude Code exports metrics, logs, and traces over OTLP:

[telemetry]
endpoint = "https://collector.example.internal:4318"
resource_attributes = { "service.name" = "city-{agent}", "ak6s.session" = "{session}" }

endpoint is the collector's base URL, an http or https URL. protocol is http/protobuf, http/json, or grpc, and defaults to http/protobuf. resource_attributes are added to every signal's resource; {agent} and {session} in a value are replaced. Without endpoint, the table takes no other key and nothing is exported.

The Job gives the pod OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL, and OTEL_RESOURCE_ATTRIBUTES. In a pod whose environment names an OTLP endpoint, the host starts Claude Code with the metrics and logs exporters that claudeacp's ExportTelemetry sets, and with CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 and OTEL_TRACES_EXPORTER=otlp for traces. A value the pod's environment already has is kept.

MCP servers

The city lists the MCP servers its sessions connect to; the pack names none:

[[mcp_servers]]
name = "tools"
transport = "http"
url = "https://tools.example.internal/mcp"
agents = ["foreman"]

[[mcp_servers.headers]]
name = "Authorization"
file = "/run/ak6s/secrets/tools/token"

transport is http or sse, and name is unique. agents limits the server to those agents' sessions; without it every session gets the server. A header takes its value from file, a path in the pod, or from env, a variable of the host's environment, and from one of them; the configuration has no inline value. Mount a file with a Secret in secrets, and have a Secret's env set a variable. A header whose file cannot be read, or whose value is empty, ends the host before the session starts, naming the server and the header.

The Job gives the pod the servers of its agent in AK6S_MCP_SERVERS, which holds the file paths and variable names and no value. The host adds them to the mcpServers of ACP session/new, session/resume, and session/load. claudeacp writes the resolved configuration to a temporary file with mode 0600 and passes its path to Claude with --mcp-config; header values do not appear in Claude's process arguments. The file is removed when Claude exits. The agent receives the original ACP request, but the host replaces every MCP header value with [redacted] in the frames it reports and the server stores. A server whose transport the agent does not offer is left out, and the host's log names it.

Perplexity tools

With a [perplexity] table, the server serves two optional tools to a session's harness over MCP: search ranks pages of the web for one to five queries in one call, and decide puts questions to a decision model about a piece of content and answers with probabilities instead of prose.

[perplexity]
api_key_file = "/run/ak6s/secrets/perplexity/token"
agents = ["foreman"]
search_type = "web"
decision_model = "pplx-decider-latest"

api_key_file names a file on the server that holds the Perplexity API token, and api_key_env a variable of the server's environment that does; one and not both is required, and neither holds the token itself. The token is read anew at each call, less the whitespace around it, and the server refuses to start when the file or the variable is missing or empty, naming the key and never the token. The token stays on the server and enters no pod; a session's pod is authorized with its own session token, as HostService and GcService authorize it, and the header's value reads [redacted] in the frames the host reports, as every MCP header's does. agents limits the tools to these agents' sessions, matched as a [[mcp_servers]] entry's agents is; without it every session gets them. search_type is the Search API's search_type, web or fast, and defaults to web. decision_model is the Decisions API's model and defaults to pplx-decider-latest. With [perplexity] set, the server refuses a [[mcp_servers]] entry named perplexity, since that name is the pack's own server's.

The endpoint is /mcp/perplexity on the server's pod-facing listener, and the host adds it to the mcpServers of the session's session/new, session/resume, and session/load requests as an HTTP MCP server named perplexity. A harness that offers no HTTP MCP transport is left without the server, and the host's log names it, as it does for a city's server.

In Claude Code, the host passes --allowedTools mcp__perplexity to claude: the rule is checked before the permission callback, so a call to either tool runs unprompted and no request reaches the host. In goose, both tools carry readOnlyHint, which goose runs unprompted under smart_approve, and under auto it never asks; under approve goose asks for every call, and the host's answer to a permission request stays reject_once, so the tools do not run in that mode.

A call Perplexity does not answer comes back to the model as a tool error that says what to do: a 401 tells it not to retry and to report the tool misconfigured, a 429 tells it to retry after the named number of seconds, a 5xx tells it to retry once and then send less content or go on without it, and any other refusal carries Perplexity's own message. The server logs one line a call — the session, its agent, the tool, Perplexity's status, and the call's duration.

Session transcript

The host writes each frame it reports to its standard output as one JSON line, after the redaction above, so kubectl logs and a cluster log collector carry the session's transcript. A line has seq, time, direction (to_agent or from_agent), and message, the ACP message as JSON; a message that is not JSON is a string. Messages are written whole, whatever their size.

Reading a transcript

ak6s transcript reads a session's transcript on stdin and prints it as the session's narrative: the agent's sentences, its thinking dimmed, its tool calls with their inputs, gc's prompts, the permissions it was asked for and the answers it gave.

kubectl logs -f job/<job> | ak6s transcript
ak6s transcript < saved.log

kubectl logs also carries the lines of the host's own log; each is printed as it is, dimmed, between the transcript's entries.

The narrative is coloured on a terminal only: --color always colours it anyway, --color never never does, and NO_COLOR and TERM=dumb say no as well. Lines longer than the terminal's width are cut with …; --width N sets the width by hand, COLUMNS when the output is not a terminal.

ACP permissions

The host selects reject_once for every ACP permission request that offers it and cancels a request that does not. No permission request is queued for an external answer. An agent's provider configuration controls which operations it can perform autonomously.

Develop

Go 1.27.4 and buf are required.

Command Action
make generate Regenerates internal/gen from proto/.
make lint Runs buf lint, checks protobuf formatting, and runs go vet ./....
make test Runs go test ./....
make image Builds the image through its smoke stage with Apple's container.

Release

A pull request's note goes in a fragment, a file .changelog/<change>.md of its own holding the ### Added-style headings with their bullets, exactly as they would read under ## [Unreleased], and nothing else; the release folds the fragments into the changelog beside any note already there. A note is optional: a pull request without one passes the changelog check with a warning.

A release is a pull request made with go run sarak.sh/mikluko/changelog/v2/cmd/changelog@latest release, which folds the fragments into the next version. On a push to main, the release workflow acts when the newest version in CHANGELOG.md has no tag. It builds and pushes the amd64 and arm64 image as X.Y.Z, X.Y, and latest, then creates the vX.Y.Z release.