claudesignin

package
v0.6.1005-dev.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package claudesignin is "Use your Claude subscription (runs Claude Code)": Claude Code's own sign-in into a config directory of Agentry's, and its removal. The CLI (`agentry model-signins add|remove claude`, `agentry setup`) and the desktop's model setup both call it, so there is one implementation per machine.

Anthropic forbids a third party to "collect, store, or intermediate Claude.ai credentials or session tokens", so Agentry never runs this sign-in: it starts the unmodified Claude Code's own `claude auth login` against a config directory of Agentry's own, never the person's ~/.claude, and Claude Code keeps and refreshes its credentials there. Agentry never reads that directory. Each Claude Code signs in where it runs: the image (the default) in its docker volume, through the person's browser with Claude Code's callback relayed into the container (browser.go), pasting the code Anthropic's page shows only where that cannot work; the installed Claude Code in a directory under the model sign-in store, with its own browser and callback.

Index

Constants

View Source
const Timeout = 15 * time.Minute

Timeout bounds one sign-in, browser included.

View Source
const Volume = "agentry-claude-signin"

Volume is the Claude Code image's config directory: a docker volume of Agentry's own (engine.OwnSignInDir), labelled as the sign-in's.

Variables

This section is empty.

Functions

func AnthropicSignInURL

func AnthropicSignInURL(raw string) bool

AnthropicSignInURL reports whether raw is a sign-in page of Anthropic's own, the only kind of address Agentry opens from Claude Code's output.

func DefaultPolicy

func DefaultPolicy() (*policy.Policy, error)

DefaultPolicy is the operator policy a sign-in prepares its image under when none is given: the default file, written from defaults when absent.

func HostDir

func HostDir(home string) string

HostDir is the installed Claude Code's config directory: under the model sign-in store, so the engine admits it (engine.OwnSignInDir).

func Kept

func Kept(home string) string

Kept is the account the image's sign-in names, for "Signed in as …": "" when there is none (the image's sign-in is the default adapter's).

Types

type Person

type Person struct {
	// In is what Claude Code's prompt reads: the code the person pastes
	// from Anthropic's page, passed to Claude Code unread, where the
	// browser cannot hand the sign-in back (the fallback). nil gives it no
	// input, and a sign-in that would need a paste ends instead.
	In io.Reader
	// Out receives Claude Code's output and the sign-in's own sentences.
	Out io.Writer
	// Open opens an address in the person's browser. It is only ever
	// handed one of Anthropic's own sign-in pages (AnthropicSignInURL);
	// nil opens nothing, and the person opens the printed address.
	// Through the image, the page's answer comes back to this computer and
	// is relayed into the container (browser.go).
	Open func(url string)
}

Person is the person's side of a sign-in.

type SignIn

type SignIn struct {
	// Home is the runner home (the model sign-in store's parent).
	Home string
	// Policy is the operator policy the image is prepared under; nil
	// resolves the default policy file, writing it from defaults when
	// absent.
	Policy *policy.Policy
	// Docker is the daemon the image's sign-in runs on; nil is dockerx.New.
	Docker func() dockerx.Client
	// Keys is the keychain the sign-in store uses; nil keeps nothing there.
	Keys connection.Keychain
}

SignIn signs a Claude Code in for this machine.

func (SignIn) End

func (s SignIn) End(out io.Writer) func(context.Context, modelsignin.Record) (string, error)

End is the store's EndClaude: Claude Code's own logout in each of the sign-in's directories, then the directory deleted. A logout that cannot run (no image, no installed Claude Code, no network) does not keep the sign-in here: deleting the directory ends it on this computer, and the outcome says what Anthropic still holds. Only the volume and directory this package makes are ever deleted, whatever a record says.

func (SignIn) Run

func (s SignIn) Run(ctx context.Context, p Person, installed bool) (*modelsignin.Record, error)

Run signs in the image's Claude Code, or the installed one, and keeps the record beside the other's sign-in if there is one. A failed first sign-in leaves nothing behind; a failed sign-in again leaves the kept one alone.

Jump to

Keyboard shortcuts

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