Skip to content

feat(setup-repo): run claude in a container when the host has no CLI#312

Draft
tildesrc wants to merge 3 commits into
mainfrom
panopticon/setup-repo-container-fallback
Draft

feat(setup-repo): run claude in a container when the host has no CLI#312
tildesrc wants to merge 3 commits into
mainfrom
panopticon/setup-repo-container-fallback

Conversation

@tildesrc

Copy link
Copy Markdown
Contributor

Summary

The setup-repo workflow (runner_type = "shell") mints a Claude auth token by running claude setup-token on the host, assuming the CLI is on $PATH. On a host without it, the command failed with a vague "'claude setup-token' failed or was cancelled" — no hint that the CLI was missing or that there was an alternative.

Now, when claude isn't installed on the host, the workflow falls back to running claude setup-token in the base task-container image (panopticon-base, which ships the CLI) via Docker, and is explicit to the operator that it's doing so. If the base image isn't built yet, it make builds it first (best-effort — needs Docker + a source checkout on the host; on a wheel-only host it explains it can't auto-build and points at the manual path). If neither a host claude nor Docker is available, it fails with a clear, actionable message instead of the old opaque one.

Changes

  • setup_repo_lib.sh — new pure, unit-tested helpers: setup_token_command (resolves host claude vs the docker fallback, echoing the command) and base_image_present (a docker image inspect wrapper).
  • setup_repo.shcollect_token resolves the run command, announces the container fallback, auto-builds the base image if missing, then runs the resolved command (host claude or the container).
  • shell_runner.py — exports PANOPTICON_BASE_IMAGE (from DEFAULT_IMAGE) and, when a source checkout is present, PANOPTICON_REPO_ROOT (via a new panopticon_repo_root() helper) so the script can make build.
  • docs/container-auth.md — documents the fallback + auto-build.

Full plan: the task's plan.md artifact.

panopticon-agent and others added 3 commits July 13, 2026 18:57
The setup-repo workflow mints a Claude token by running `claude
setup-token` on the host, assuming the CLI is on `$PATH`. On a host
without it, the command failed with a vague "failed or was cancelled".

Fall back to running `claude setup-token` in the base task-container
image (which ships the CLI) via Docker, announced explicitly. If the
base image isn't built, `make build` it first (best-effort — needs
Docker + a source checkout; on a wheel-only host it says it can't and
points at the manual path). If neither a host `claude` nor Docker is
available, fail with a clear, actionable message.

- setup_repo_lib.sh: pure `setup_token_command` (host claude vs docker
  fallback) + `base_image_present` helpers.
- setup_repo.sh: collect_token resolves the command, announces the
  fallback, auto-builds, then runs the resolved command.
- shell_runner.py: export PANOPTICON_BASE_IMAGE + (when a source
  checkout is present) PANOPTICON_REPO_ROOT via a new
  panopticon_repo_root() helper.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The container fallback built a missing base image with `make build` from
the repo, gated on PANOPTICON_REPO_ROOT — which only exists for a source
checkout, not a pip/wheel install. Build it from the package's bundled
Dockerfile instead (the same checkout-free path the spawner uses via
ImageBuilder.build_base_if_missing), so it works for pip users.

- images.py: `python -m panopticon.sessionservice.images [IMAGE]` builds
  the base image if missing.
- shell_runner.py: drop panopticon_repo_root/PANOPTICON_REPO_ROOT; export
  PANOPTICON_BUILD_BASE_CMD built from sys.executable (the interpreter
  that has panopticon + its bundled Dockerfile importable).
- setup_repo.sh: run the injected build command instead of `make build`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… CLI

Reuse the existing `build` subcommand instead of a separate images module
entry point. The injected build command is `<sys.executable> -m
panopticon.terminal build` — the existing `panopticon build`, run with
this process's interpreter so it doesn't depend on a venv's bin/ being on
the tmux pane's PATH. Drops the images.py __main__ added earlier.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant