Documentation
¶
Index ¶
- Constants
- func NewClaudeModel(ctx context.Context, cfg ClaudeConfig) (model.ToolCallingChatModel, error)
- func NewClaudeModelFromEnv(ctx context.Context) (model.ToolCallingChatModel, error)
- func NewModelFromEnv(ctx context.Context) (model.ToolCallingChatModel, error)
- func NewOpenAIModel(ctx context.Context, cfg OpenAIConfig) (model.ToolCallingChatModel, error)
- func NewOpenAIModelFromEnv(ctx context.Context) (model.ToolCallingChatModel, error)
- type ClaudeConfig
- type Config
- type OpenAIConfig
- type Result
Constants ¶
const DefaultSystemPrompt = `` /* 6474-byte string literal not displayed */
DefaultSystemPrompt is used when Config.SystemPrompt is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClaudeModel ¶
func NewClaudeModel(ctx context.Context, cfg ClaudeConfig) (model.ToolCallingChatModel, error)
NewClaudeModel returns a Claude tool-calling model from the given config.
func NewClaudeModelFromEnv ¶
func NewClaudeModelFromEnv(ctx context.Context) (model.ToolCallingChatModel, error)
NewClaudeModelFromEnv reads ZBPLAN_ANTHROPIC_API_KEY, ZBPLAN_ANTHROPIC_MODEL, and ZBPLAN_ANTHROPIC_BASE_URL from the environment, matching the default cmd/zbplan behavior.
func NewModelFromEnv ¶
func NewModelFromEnv(ctx context.Context) (model.ToolCallingChatModel, error)
NewModelFromEnv reads the appropriate model configuration from the environment. ZBPLAN_MODEL defaults to "claude" when unset.
func NewOpenAIModel ¶
func NewOpenAIModel(ctx context.Context, cfg OpenAIConfig) (model.ToolCallingChatModel, error)
NewOpenAIModel returns an OpenAI tool-calling model from the given config.
func NewOpenAIModelFromEnv ¶
func NewOpenAIModelFromEnv(ctx context.Context) (model.ToolCallingChatModel, error)
NewOpenAIModelFromEnv reads ZBPLAN_OPENAI_API_KEY, ZBPLAN_OPENAI_MODEL, and ZBPLAN_OPENAI_BASE_URL from the environment, matching the default cmd/zbplan behavior.
Types ¶
type ClaudeConfig ¶
type ClaudeConfig struct {
// APIKey is the Anthropic API key. Required.
APIKey string
// Model defaults to "claude-sonnet-4-6" when empty.
Model string
// BaseURL overrides the Anthropic API endpoint when non-empty.
BaseURL string
// MaxTokens defaults to 16000 when zero. Note: with adaptive thinking
// enabled, max_tokens covers both thinking tokens and response text.
MaxTokens int
// DisableThinking disables adaptive thinking when true.
// By default, adaptive thinking is enabled.
DisableThinking bool
}
ClaudeConfig holds settings for NewClaudeModel. Zero values use the documented defaults.
type Config ¶
type Config struct {
// Model is the eino tool-calling model that drives the planning agent.
// Use NewClaudeModel or NewClaudeModelFromEnv for a Claude-backed model.
Model model.ToolCallingChatModel
// BuildKitAddr is the optional BuildKit daemon endpoint
// (e.g. "tcp://host:1234" or "docker-container://buildkitd").
// When empty, BuildKit's client falls back to the system default address.
BuildKitAddr string
// ContextDir is the source-code directory to plan for.
ContextDir string
// Variables are injected as ZEABUR_ENV_* build args into every FROM stage.
Variables map[string]string
// UserDockerfile is an existing Dockerfile to try before invoking the agent.
// If it builds successfully the agent is skipped entirely.
// If it fails, the agent receives it alongside the build error as its
// starting context. The attempt does not count toward MaxBuildAttempts.
UserDockerfile string
// OCIOutput receives the OCI image tarball on a successful build.
// When nil no OCI tarball is produced (cheaper — only a verify build runs).
//
// io.WriteCloser is required (rather than io.Writer) because BuildKit's
// session layer calls Close() as part of stream finalization: it flushes
// any trailing bytes and propagates close errors back into the solve result.
// This means Close() carries real semantics — wrapping formats such as
// gzip or zstd rely on it to write their closing blocks, and an
// io.PipeWriter relies on it to signal EOF to the reader.
//
// BuildKit calls Close() before Run returns, so callers do not need to
// close OCIOutput themselves. Closing it again after Run is harmless for
// most implementations (e.g. *os.File silently returns an error that can
// be ignored), but is unnecessary.
OCIOutput io.WriteCloser
// ExtraTools are appended to the default eight plantools tools.
ExtraTools []tool.BaseTool
// SystemPrompt overrides DefaultSystemPrompt.
SystemPrompt string
// MaxBuildAttempts is the number of agent generate→build cycles before
// Run returns an error. Defaults to 3.
MaxBuildAttempts int
// MaxAgentSteps is the maximum number of ReAct steps per Generate call.
// Defaults to 100.
MaxAgentSteps int
// Logger defaults to slog.Default() when nil.
Logger *slog.Logger
}
Config controls a single Run invocation.
type OpenAIConfig ¶
type OpenAIConfig struct {
// APIKey is the OpenAI API key. Required.
APIKey string
// Model defaults to "gpt-5.5" when empty.
Model string
// BaseURL overrides the OpenAI API endpoint when non-empty.
BaseURL string
}
OpenAIConfig holds settings for NewOpenAIModel.
type Result ¶
type Result struct {
// Dockerfile is the working Dockerfile text.
Dockerfile string
// Attempts is the number of agent generate→build cycles used.
// Zero means UserDockerfile built successfully without invoking the agent.
Attempts int
// FromUser is true when Dockerfile is the unchanged UserDockerfile.
FromUser bool
}
Result is returned by a successful Run call.