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 ¶
const Timeout = 15 * time.Minute
Timeout bounds one sign-in, browser included.
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 ¶
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 ¶
DefaultPolicy is the operator policy a sign-in prepares its image under when none is given: the default file, written from defaults when absent.
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)
// Step, when set, is told each step of the sign-in as it starts, so a
// person waiting on it can be shown where it is; detail is the Claude
// Code version for StepBuild and "" otherwise.
Step func(step Step, detail 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
// PolicyPath is the file Policy was read from, beside which the image
// built from Claude Code's newest release is recorded; "" with a Policy
// given records nothing and takes the tested image.
PolicyPath string
// 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 ¶
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.
type Step ¶ added in v0.7.4
type Step string
Step is one step of a sign-in, in the order they come. A sign-in through the installed Claude Code has no image, so it starts at StepStart.
const ( // StepImage: looking for the Claude Code image on the docker daemon. StepImage Step = "image" // StepBuild: building the Claude Code image on this computer, which // downloads Claude Code and takes a few minutes. StepBuild Step = "build" // StepStart: starting Claude Code's own sign-in. StepStart Step = "start" // StepBrowser: Anthropic's page is open in the person's browser, and the // sign-in waits for them there. StepBrowser Step = "browser" // StepKeep: asking Claude Code who signed in, and keeping the sign-in. StepKeep Step = "keep" )