Shared utility modules providing low-level services: TMUX orchestration, environment variables, polling, logging, ZIP extraction, agent variant resolution, and internal agent marker handling.
/health endpoint validation with retry logic and result cachingprocess.env.TMUX check for tmux context, process.platform for OS-specific extraction strategytmux.ts:
spawnTmuxPane() → validate config.enabled → check tmux context → probe server health → discover tmux binary → split pane with opencode attach <url> --session <id> → rename pane → apply layout → return paneIdcloseTmuxPane() → send Ctrl+C → wait 250ms → kill-pane → reapply layout to rebalanceisServerRunning() → GET /health with 3s timeout → retry up to 2 times → cache resultenv.ts:
getEnv(name) → check Bun.env first → fallback to process.env → filter empty stringsinternal-initiator.ts:
createInternalAgentTextPart() → append marker to texthasInternalInitiatorMarker() → check if part.type === 'text' and contains markerpolling.ts:
pollUntilStable() → loop with configurable interval → call fetchFn → check stability predicate → increment stable count on match → reset on failure → return on threshold or timeoutdelay(ms) → Promise-wrapped setTimeoutzip-extractor.ts:
extractZip() → detect platform → Windows: check build number for tar support, fallback to pwsh/powershell → Unix: use unzip → spawn process → await exit code → throw on failurelogger.ts:
log() → construct timestamp → serialize data to JSON → append to temp log file → catch and ignore errorsagent-variant.ts:
normalizeAgentName() → trim whitespace → strip @ prefixresolveAgentVariant() → normalize name → lookup in config.agents → validate type and non-empty → return trimmed variantapplyAgentVariant() → return original body if variant falsy or body already has variant → spread merge variant into bodyTmuxConfig, TmuxLayout from ../config/schema, constants from ../config (POLL_INTERVAL_MS, MAX_POLL_TIME_MS, STABLE_POLLS_THRESHOLD), logging from ./logger, PluginConfig type from ../configsrc/utils/index.ts barrel file