Help us shape the future of Go! Take the 2026 Go Developer Survey

anthropic

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package anthropic screens deployment plans with Claude (design 10 §6).

The first AI adapter, and the one the interface in adapter/api was shaped against. It talks to the Messages API through the official Go SDK, reads the repository through the SourceView it is handed, and returns amendments drawn from the closed set — which core then validates again, because an adapter proposes and core decides (R-027).

Nothing here writes. SourceView has no write method, and the tools this adapter exposes to the model are a listing and a read.

Index

Constants

View Source
const (
	DefaultMaxFiles = 40
	DefaultMaxBytes = 256 << 10
)

Budget ceilings this adapter will not exceed regardless of what it is asked for. Core lowers them further; neither side raises the other's.

View Source
const DefaultModel = "claude-opus-5-5"

DefaultModel is what an install gets without choosing.

[P] It runs at most once per detection, and only when detection failed or asked something (R-336), on a repository somebody is about to deploy — what is being bought is whether the app comes up without a person stepping in. This is not a high-volume path where a cheaper model pays for itself, and the cost of a wrong amendment is a person's afternoon. Opus 5.5 rather than Opus 5: newer, and cheaper per token besides.

View Source
const Kind = "anthropic"

Kind is what adapter_configs stores.

Variables

This section is empty.

Functions

func Info

func Info() api.KindInfo

Info describes this kind of adapter for the forms that configure one (api.KindInfo, R-261).

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter is the AI adapter.

func New

func New() *Adapter

New returns an unconfigured adapter.

func (*Adapter) AnswerQuestions

func (a *Adapter) AnswerQuestions(ctx context.Context, req api.ScreenRequest) (api.ScreenResult, error)

AnswerQuestions answers detection's outstanding questions from the repository (R-338). Core calls it only when there are some.

func (*Adapter) AnswerReference

func (a *Adapter) AnswerReference(ctx context.Context, req api.ReferenceRequest) (api.ReferenceAnswer, error)

AnswerReference answers from the generated reference (R-346).

func (*Adapter) Capabilities

func (a *Adapter) Capabilities(_ context.Context) (api.AICapabilities, error)

Capabilities reports what this adapter does, as data (R-254, R-259).

func (*Adapter) Category

func (a *Adapter) Category() api.Category

func (*Adapter) Configure

func (a *Adapter) Configure(_ context.Context, raw json.RawMessage) error

Configure reads the adapter's row from adapter_configs.

func (*Adapter) DraftAccess

func (a *Adapter) DraftAccess(ctx context.Context, req api.AccessRequest) (api.AccessDraft, error)

DraftAccess drafts a role and, optionally, a group (R-343).

func (*Adapter) DraftPolicy

func (a *Adapter) DraftPolicy(ctx context.Context, req api.PolicyRequest) (api.PolicyDraft, error)

DraftPolicy proposes changes to host policy (R-344).

func (*Adapter) HealthCheck

func (a *Adapter) HealthCheck(ctx context.Context) error

HealthCheck asks the API whether the configured model exists.

A real call rather than a ping, because the failure this has to catch is a credential that does not work or a model name nobody can serve — and both answer a models lookup the same way they would answer a screening. It costs no tokens.

func (*Adapter) Kind

func (a *Adapter) Kind() string

func (*Adapter) RepairPlan

func (a *Adapter) RepairPlan(ctx context.Context, req api.ScreenRequest) (api.ScreenResult, error)

RepairPlan reads a failed proposal and proposes amendments that might make it work (R-106, R-336). Core calls it only when the trial run crashed or no detector could read the repository.

func (*Adapter) RevisePlan

func (a *Adapter) RevisePlan(ctx context.Context, req api.ScreenRequest) (api.ScreenResult, error)

RevisePlan acts on what a person reviewing the plan asked for, checking it against the repository first (R-336). Core calls it only when somebody asks.

func (*Adapter) SearchAudit

func (a *Adapter) SearchAudit(ctx context.Context, req api.AuditSearchRequest) (api.AuditSearch, error)

SearchAudit turns a question into one audit filter (R-345).

func (*Adapter) SummarizeAudit

func (a *Adapter) SummarizeAudit(ctx context.Context, req api.AuditSummaryRequest) (api.AuditSummary, error)

SummarizeAudit summarizes the records core found (R-345).

type Config

type Config struct {
	// Credentials are supplied by core, decrypted from adapter_credentials at
	// startup (O-20). They are never part of the stored configuration: the
	// database refuses a `credentials` key in adapter_configs.config, so a value
	// here can only have come from encrypted storage.
	Credentials Credentials `json:"credentials,omitzero"`

	// APIKeyEnv names an environment variable holding the key, for an operator
	// who keeps credentials in the environment. When neither this nor a stored
	// credential is set, ANTHROPIC_API_KEY is read — the SDK's own convention.
	APIKeyEnv string `json:"api_key_env,omitempty"`

	Model string `json:"model,omitempty"`

	// BaseURL points at a gateway or a proxy. Empty is the Anthropic API.
	BaseURL string `json:"base_url,omitempty"`

	// WorkspaceID is sent as the anthropic-workspace-id header on every
	// request. The API refuses a key created for several workspaces without
	// it; a key created for one workspace needs nothing, so empty sends no
	// header at all.
	WorkspaceID string `json:"workspace_id,omitempty"`

	// ScreenPlans defaults to true (R-336): configuring this adapter meant
	// supplying a credential, and that was the decision. False turns off both
	// functions — repairing a failed plan and answering questions — for an
	// install that wants the adapter for something else. The key keeps its
	// original name so existing configurations still read.
	ScreenPlans *bool `json:"screen_plans,omitempty"`

	MaxFiles int   `json:"max_files,omitempty"`
	MaxBytes int64 `json:"max_bytes,omitempty"`

	TimeoutSeconds int `json:"timeout_seconds,omitempty"`
}

Config is the adapter's own configuration (design 10 §7).

type Credentials

type Credentials struct {
	APIKey secret.Value `json:"api_key,omitzero"`
}

Credentials is what this adapter needs kept secret.

A secret.Value, so it renders [redacted] in every marshaler and cannot reach a log line (R-194).

Jump to

Keyboard shortcuts

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