Gas City’s exec session provider delegates eachDocumentation Index
Fetch the complete documentation index at: https://docs.gascityhall.com/llms.txt
Use this file to discover all available pages before exploring further.
runtime.Provider operation
to a user-supplied script. This allows any terminal multiplexer or process
manager to be used as a session backend without writing Go code.
Usage
Set theGC_SESSION environment variable to exec:<script>:
Calling Convention
The script receives the operation name as its first argument:Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Failure (stderr contains error message) |
| 2 | Unknown operation (treated as success — forward compatible) |
Operations
| Operation | Invocation | Stdin | Stdout |
|---|---|---|---|
start | script start <name> | JSON config | — |
stop | script stop <name> | — | — |
interrupt | script interrupt <name> | — | — |
is-running | script is-running <name> | — | true or false |
attach | script attach <name> | tty passthrough | tty passthrough |
process-alive | script process-alive <name> | process names (1/line) | true or false |
nudge | script nudge <name> | message text | — |
set-meta | script set-meta <name> <key> | value on stdin | — |
get-meta | script get-meta <name> <key> | — | value (empty = not set) |
remove-meta | script remove-meta <name> <key> | — | — |
peek | script peek <name> <lines> | — | captured text |
list-running | script list-running <prefix> | — | one name per line |
get-last-activity | script get-last-activity <name> | — | RFC3339 or empty |
Start Config (JSON on stdin)
Thestart operation receives a JSON object on stdin:
Startup Hints
The JSON config contains fields that the tmux provider uses for multi-step startup orchestration. The exec provider itself is fire-and-forget — it callsscript start and returns immediately. Scripts may handle these
hints or ignore them:
-
process_names— the tmux adapter polls for these process names to appear in the session’s process tree (30s timeout) before considering the agent “started.” A script can implement this by polling its backend’s process tree after session creation, or ignore it for fire-and-forget behavior (like the subprocess provider does). -
nudge— text that the tmux adapter types into the session after the agent is ready. Scripts that support interactive input can handle this instart(type the text after session creation) or leave it to the separatenudgeoperation which gc calls afterstartreturns. -
pre_start— array of shell commands to run on the target filesystem before the session is created. Used for directory preparation, worktree creation, or other setup that must exist before the agent starts. Scripts should execute each command in the target environment before creating the tmux session. Non-fatal: warn on stderr if a command fails, but don’t abort start. -
session_setup— array of shell commands to run on the target filesystem after the session is created and ready, before returning. Scripts should execute each command inside the session environment (e.g.kubectl exec -- sh -c '<cmd>'for K8s,docker exec -- sh -c '<cmd>'for Docker, or plainsh -c '<cmd>'for local providers). Non-fatal: warn on stderr if a command fails, but don’t abort start. -
session_setup_script— path to a script on the controller filesystem, run aftersession_setupcommands. For remote providers (K8s, Docker), read the file locally and pipe its contents into the session (e.g.kubectl exec -i -- sh < script). For local providers, run directly viash -c. Non-fatal likesession_setup.
ready_prompt_prefix— prompt prefix for readiness detection (gc polls viapeekafterstartreturns)ready_delay_ms— fixed delay fallback (gc sleeps afterstartreturns)emits_permission_warning— bypass-permissions dialog handlingfingerprint_extra— config change detection metadata
Conventions
- stdin for values:
set-meta,nudge, andstartpass data on stdin to avoid shell quoting and argument length limits. - stdout for results:
is-running,process-alivereturntrue/false.get-metareturns the value or empty for unset.list-runningreturns one name per line. - Idempotent stop:
stopmust succeed (exit 0) even if the session doesn’t exist. - Best-effort interrupt/nudge: Return 0 even if the session doesn’t exist.
- Empty = unsupported:
get-last-activityreturning empty stdout means the backend doesn’t support activity tracking (zero time in Go).
Writing Your Own Script
- Start with
contrib/session-scripts/gc-session-screenas a template. - Implement the operations your backend supports.
- Return exit 2 for operations you don’t support.
- Test with
GC_SESSION=exec:./your-script gc start <city>.
Minimal script (start/stop/is-running only)
Environment Variables
Scripts can useGC_EXEC_STATE_DIR (if set) as a directory for sidecar
state files (metadata, wrappers). If not set, scripts should use a
reasonable default under $TMPDIR or /tmp.
Shipped Scripts
Seecontrib/session-scripts/ for maintained implementations:
- gc-session-screen — GNU screen backend. Dependencies:
screen,jq,bash.