agents

package
v0.3.30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

agents

The agent-type adapters: what Loomux knows about launching each supported agent CLI (design spec §6). app.DefaultAgentTypes registers them; the router only sees the resulting router.AgentType values.

Rule for every adapter: whatever the agent needs from Loomux is passed per launch (CLI flags, plus the LOOMUX_* env vars router.launchAgent sets). Never edit the target's own agent config (~/.claude/settings.json, ~/.claude.json, ~/.codex/config.toml). Targets can be shared work hosts (sc1 is one), and that config belongs to the person who uses them.

Completion hooks (LOOM-75)

Both agents are completion.TierMarker: a turn is finished when $LOOMUX_MARKER_PATH exists on the target. The adapter injects the hook that creates it:

agent-type injected args fires on side effects
claude-code --settings '{"hooks":{"Stop":[…]}}' Stop (each finished turn) Layered over the user's settings for this process only. The user's own hooks still run.
codex -c 'notify=["sh","-c","…","loomux-notify"]' notify event agent-turn-complete Replaces the user's own notify program for this process only.

The marker directory is created by the router before launch: a per-user 0700 directory on the target, or the configured LOOMUX_MARKER_DIR (see completion/README.md). The hook command (touchMarker in agents.go) re-creates it with umask 077 if it has gone missing, then touches the marker. It does nothing when LOOMUX_MARKER_PATH is unset.

agents_test.go checks the generated settings and notify values, and also runs the hook commands under sh to confirm they create the marker (and ignore events that aren't a finished turn).

Version floor

Each adapter sets a VersionCheck with a Min version. A CLI below it fails the dispatch before any task is created, with the error agent version too old for completion hooks (…). The floors are the oldest releases on which a real turn was verified to write its marker (2026-10-02): claude 2.1.0 (verified 2.1.287), codex 0.150.0 (verified 0.150.1). sc1 had claude 2.1.287 and codex 0.159.3/0.154.0 on that date. Only lower a floor after verifying an older release.

The check runs claude --version / codex --version on the target's non-interactive PATH. LOOM-79 (absolute agent paths) changes how the binary is found; the check should follow it.

Launch profiles (LOOM-78)

A fresh interactive agent used to stop at its trust dialog or at a per-tool approval prompt. Its first message was typed in with send-keys before the TUI was ready: Claude Code's trust dialog has "No, exit" pre-selected, so a typed message plus Enter could quit the agent. Each adapter now carries a router.LaunchProfile. Every part of it is passed on the command line, for that launch only:

<binary> <permission args> <trust args> <completion hook args> -- '<first message>'
Defaults
claude-code codex
Permission args (mode auto) --permission-mode auto --ask-for-approval on-request --sandbox workspace-write
Runs without asking Whatever Claude Code's auto-mode classifier judges routine: edits and ordinary commands. Commands inside Codex's sandbox: read anywhere, write inside the workspace and temp dirs, no network.
Still asks a human Anything the classifier flags as risky. Anything the model wants to run outside the sandbox (network, writes elsewhere).
Workspace pre-trust Before each launch, hasTrustDialogAccepted for exactly that workspace path in ~/.claude.json (see below). -c 'projects={"<workspace>"={trust_level="trusted"}}' for this process. Nothing is written to ~/.codex/config.toml.
First message Positional argument after --. Positional argument after --.

Agents run in each CLI's own automatic mode, never the "skip everything" modes (--dangerously-skip-permissions, bypassPermissions, --dangerously-bypass-approvals-and-sandbox); user decision 2026-10-04. A target can tighten this with permission_mode (auto, accept-edits or manual; empty means the agent-type's default, auto). Each agent-type maps the modes to its own flags (LaunchProfile.PermissionModes), so per-target policy (LOOM-89) can restrict, say, a work-only host. Anything a mode still asks about stops at a prompt in the pane. LOOM-97 surfaces those in chat: DetectPrompt (prompts.go) reads the prompt off the pane, the task becomes needs-attention, and the next chat message answers it (see the design spec's failure modes). testdata/ holds the Claude Code screens it is tested against, captured from a real target. The Codex ones are reconstructed, not captured, so re-check them against a real Codex.

Claude Code workspace trust. Claude Code has no per-launch flag to trust a folder; trust lives in the user's ~/.claude.json. Before every launch Loomux runs a small Python 3 script on the target (claudeTrustCommand) that sets projects["<realpath of the workspace>"] .hasTrustDialogAccepted = true. It keeps every other key, writes atomically and keeps the file's mode. This is the one write Loomux makes to an agent's own config (approved 2026-10-04 for this narrow purpose). It is scoped to that exact path, never a global trust, and covers both directories Loomux creates and existing ones a workspace is attached to. It needs python3 on the target. If it fails, the launch goes ahead and the trust dialog shows in the pane.

First message on the command line. Passing the first message as an argument removes the send-keys race on turn 1. Turns 2 and later are still typed in, after the previous turn's completion marker. That marker shows the agent is waiting for input. Trade-off: on a shared host the first message is visible to other users. While the agent runs, the message is in its argv, which any user on the target can read with ps or /proc/<pid>/cmdline. Where that matters, set prompt_as_arg to false for that agent type in LOOMUX_AGENT_PROFILES (e.g. {"claude-code":{"prompt_as_arg":false}}), and the first message is typed into the pane like the rest.

Overrides

LOOMUX_AGENT_PROFILES (read by app.LoadConfig, applied by router.AgentTypeRegistry.ApplyProfileOverrides) is a JSON object keyed by agent type. Every field is optional; an absent field keeps the default.

{
  "claude-code": {"permission_args": ["--permission-mode", "plan"]},
  "codex": {"permission_args": ["--ask-for-approval", "untrusted", "--sandbox", "read-only"],
            "pre_trust": false,
            "prompt_as_arg": false}
}
  • permission_args: replaces the default list. [] means no flags (the CLI's own interactive default).
  • pre_trust: false: drops the trust args. true can't add a trust mechanism to an agent that has none.
  • prompt_as_arg: on or off.

Unknown keys and unknown agent types fail startup, so a typo can't leave the default posture in force. The effective profiles are logged at startup (agent launch profile). Per-target overrides (a stricter posture on a shared host than on a dedicated one) are LOOM-89.

Documentation

Overview

Package agents holds the agent-type adapters: what Loomux knows about launching each supported agent CLI (design spec §6 — "each registered agent-type supplies a launch command template and a completion-detection adapter"). app.DefaultAgentTypes registers these; router only ever sees the resulting router.AgentType values.

Everything an adapter needs on the target is passed per launch — CLI flags and the LOOMUX_* env vars router.launchAgent sets — never by editing the target's own agent config (~/.claude/settings.json, ~/.codex/config.toml). Targets can be shared work hosts whose agent config belongs to their user (LOOM-75).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaudeCode

func ClaudeCode() router.AgentType

ClaudeCode is the "claude-code" agent-type: Claude Code's interactive CLI, completion via a Stop hook.

The hook is passed with --settings, which Claude Code layers on top of the user's own settings files for this process only; hooks from all layers run, so the user's own hooks keep working and their files are never touched. Stop fires once per finished turn, which is exactly the TierMarker signal.

func Codex

func Codex() router.AgentType

Codex is the "codex" agent-type: OpenAI's Codex interactive CLI, completion via its notify program.

Codex runs the notify argv after each event with the event JSON appended as the last argument; the script touches the marker only for agent-turn-complete. The -c override applies to this process only — but it replaces, for this process, any notify the user configured themselves (Codex has one notify program, not a list).

func DetectCompaction added in v0.1.17

func DetectCompaction(screen string) bool

DetectCompaction reports whether Claude Code is compacting its context right now (LOOM-109): its status line, the last line above the input box, reads "✻ Compacting conversation…" — a spinner glyph, the words, an ellipsis. Only that line, in that shape, counts: tool output and diffs above it may quote the words (an agent working on this very file), and a finished compaction's "Conversation compacted" note doesn't count.

func DetectPrompt

func DetectPrompt(screen string) *registry.Attention

DetectPrompt reads the prompt an agent CLI is stopped at off its pane (LOOM-97): Claude Code's and Codex's permission prompts, Claude Code's AskUserQuestion, the folder-trust dialog, and either CLI asking to be signed in. nil means none is showing. Both CLIs draw prompts the same way — a heading, a question, a list of options with a cursor, a footer with the keys — which is what this parses, so it works for either.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL