Documentation
¶
Overview ¶
Package einoacp provides an ACP-backed chat model implementation for Eino.
Index ¶
- func ClaudeCommand() []string
- func CodexCommand() []string
- func CopilotCommand() []string
- func GeminiCommand() []stringdeprecated
- func UserMessages(content string) []*schema.Message
- type ChatModel
- func (cm *ChatModel) BindTools(_ []*schema.ToolInfo) error
- func (cm *ChatModel) Generate(_ context.Context, _ []*schema.Message, _ ...model.Option) (*schema.Message, error)
- func (cm *ChatModel) GetType() string
- func (cm *ChatModel) IsCallbacksEnabled() bool
- func (cm *ChatModel) Stream(ctx context.Context, input []*schema.Message, _ ...model.Option) (outStream *schema.StreamReader[*schema.Message], err error)
- func (cm *ChatModel) WithTools(_ []*schema.ToolInfo) (model.ToolCallingChatModel, error)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClaudeCommand ¶
func ClaudeCommand() []string
ClaudeCommand returns the command to launch Claude Code via ACP.
func CodexCommand ¶
func CodexCommand() []string
CodexCommand returns the command to launch OpenAI Codex CLI via ACP. Uses the dedicated ACP adapter package from the ACP registry.
func CopilotCommand ¶
func CopilotCommand() []string
CopilotCommand returns the command to launch GitHub Copilot via ACP.
func GeminiCommand
deprecated
func GeminiCommand() []string
GeminiCommand returns the command to launch Google Gemini CLI via ACP.
NOTE: Gemini CLI in ACP mode currently does not work with OAuth authentication when launched as a subprocess. See upstream issue: https://github.com/google-gemini/gemini-cli/issues/12042
Deprecated: Use ClaudeCommand or CodexCommand instead until this is resolved.
func UserMessages ¶
UserMessages is a convenience function to create a single user message slice.
Types ¶
type ChatModel ¶
type ChatModel struct {
// contains filtered or unexported fields
}
ChatModel implements eino's model.ChatModel by communicating with any ACP-compatible coding agent (Claude Code, Codex CLI, etc.) over the Agent Client Protocol.
func NewChatModel ¶
NewChatModel creates a new ACP chat model.
func (*ChatModel) Generate ¶
func (cm *ChatModel) Generate(_ context.Context, _ []*schema.Message, _ ...model.Option) (*schema.Message, error)
Generate is not supported for ACP-based chat models.
ACP is a streaming-only protocol: the agent emits ordered session updates (tool_call → tool_call_update → agent_message_chunk) that must be consumed in real time. Collapsing them into a single *schema.Message via Generate destroys event ordering and streaming granularity.
Use Stream instead.
func (*ChatModel) IsCallbacksEnabled ¶
IsCallbacksEnabled reports whether callback hooks are enabled for this model.
type Config ¶
type Config struct {
// Command is the full command to launch the ACP agent.
// The first element is the binary, the rest are arguments.
// Use the provided helpers: ClaudeCommand(), CodexCommand().
// Required, must have at least one element.
Command []string
// Cwd is the working directory for the agent session.
// Defaults to the current working directory.
Cwd string
// Env sets additional environment variables for the agent subprocess.
// These are merged with the current process environment.
Env []string
// AutoApprove automatically approves all permission requests from the agent.
// When false, permission requests are denied.
AutoApprove bool
// OnPermission is called for every ACP permission request. When set, it
// takes precedence over AutoApprove.
OnPermission func(context.Context, acp.RequestPermissionRequest) (acp.RequestPermissionResponse, error)
// OnSessionUpdate is called for every ACP SessionUpdate received during
// execution. This fires in real-time regardless of whether Generate() or
// Stream() is used, giving consumers access to tool calls, text chunks,
// and other ACP events as they happen.
OnSessionUpdate func(acp.SessionUpdate)
// SelectModel is the ACP model id to switch to via SetSessionModel
// after each NewSession (the protocol-native way to pick a model
// for a session). Empty = use the agent's default. Pass --model
// on the spawn command line is unreliable: Claude Code ignores it
// in --acp mode and currentModelId stays "default" regardless;
// SetSessionModel is the only way to actually switch.
//
// Per-CLI valid ids:
// Claude Code: "default" / "sonnet" / "haiku"
// GitHub Copilot: "auto" / "gpt-5.4" / "gpt-5.3-codex" / ...
// Discoverable via the OnSessionInfo callback below.
SelectModel string
// OnSessionInfo fires once per NewSession with the model + session
// id information the agent reports back. The SessionModelState
// contains the *resolved* currentModelId (e.g. after applying
// SelectModel, or whatever the agent's default was) and the full
// list of availableModels with human-readable names + descriptions.
//
// Use this to (a) surface the actual running model to a UI rather
// than the alias the user picked, and (b) populate a model picker
// dynamically without hardcoding a per-CLI list.
//
// Called BEFORE the first prompt is sent on the new session, so
// callers can react to the model state synchronously if needed.
OnSessionInfo func(sessionId acp.SessionId, models *acp.SessionModelState)
// McpServers is the list of MCP servers to attach to each ACP session.
// Claude Code will discover and use tools from these servers.
McpServers []acp.McpServer
}
Config for the ACP-based chat model.