Documentation
¶
Overview ¶
Package domain defines the core domain models and interfaces for the AutoCmd system.
Index ¶
- Constants
- func GetSessionID(ctx context.Context) (string, bool)
- func WithSessionID(ctx context.Context, sessionID string) context.Context
- type APIKeyAuthMethod
- type Action
- type AuthErrorEvent
- type AuthField
- type AuthMethod
- type AuthMethodEvent
- type AuthProviderListEvent
- type BashDisplay
- type CallIDer
- type ConnectingEvent
- type CreateSessionAction
- type Credential
- type CredentialFieldEvent
- type DeleteSessionAction
- type DiffDisplay
- type DoneEvent
- type EnvVarAuthMethod
- type EnvVarInstructionEvent
- type File
- type HistoryEvent
- type InfoEvent
- type LLM
- type LLMInfo
- type MCPLoadingEvent
- type ModelListEvent
- type OAuthDeviceFlowEvent
- type OAuthMethod
- type PermissionDecisionAction
- type Provider
- type ProviderInfo
- type ProviderSummary
- type QuestionAnswerAction
- type QuestionDisplay
- type QuestionInfo
- type RemoveAuthAction
- type RenameSessionAction
- type SavedCommand
- type SelectAuthMethodAction
- type SelectModelAction
- type SelectProviderAction
- type SelectSessionAction
- type Session
- type SessionDisplays
- type SessionListEvent
- type SessionMessages
- type SessionMetadata
- type SessionSelectedEvent
- type State
- type StopAction
- type StringDisplay
- type SubmitCredentialAction
- type SubmitFieldAction
- type SummaryCompactionEndEvent
- type SummaryCompactionStartEvent
- type SystemNotificationEvent
- type TaskResult
- type TextEvent
- type ToolApprovalRequestEvent
- type ToolDisplay
- type ToolEndEvent
- type ToolStartEvent
- type ToolStreamEvent
- type UIUpdate
- type WaitingForNamingEvent
Constants ¶
const ( ProviderGoogle = "google" ProviderGitHub = "github" ProviderOpenCode = "opencode" )
Provider IDs.
const ( ShortIDLength = 8 MaxCollisionRetries = 100 )
ID Generation Constants.
const ( AuthMethodAPIKey = "api_key" AuthMethodEnv = "env" AuthFieldAPIKey = "api_key" )
Auth Method and Field IDs.
const ( NotificationMessageExtraKey = "autocmd/is_notification" // ThoughtDurationMsExtraKey is Message.Extra: ms from first reasoning chunk to stream end (persisted for history UI). ThoughtDurationMsExtraKey = "autocmd/reasoning_phase_duration_ms" )
Message metadata keys.
const ( AppName = "autocmd" ConfigBaseDir = ".config" )
Application Metadata.
const ( DefaultDirPerm = 0o755 DefaultFilePerm = 0o644 PrivateFilePerm = 0o600 )
Standard Permissions (Unix).
const ToolErrorCancelled = "execution cancelled"
ToolErrorCancelled is ToolDisplay.Error when Execute returns because the context was cancelled.
const ToolErrorFailed = "execution failed"
ToolErrorFailed is the generic ToolDisplay.Error for any non-cancellation failures.
const ToolErrorTimedOut = "execution timed out"
ToolErrorTimedOut is ToolDisplay.Error when Execute returns because the operation took too long.
Variables ¶
This section is empty.
Functions ¶
func GetSessionID ¶
GetSessionID returns the session ID from the context if it exists.
Types ¶
type APIKeyAuthMethod ¶
APIKeyAuthMethod represents an authentication method that requires user input of text fields.
func (APIKeyAuthMethod) IsAuthMethod ¶
func (APIKeyAuthMethod) IsAuthMethod()
IsAuthMethod marks APIKeyAuthMethod as an implementation of the AuthMethod interface.
type Action ¶
type Action interface {
// contains filtered or unexported methods
}
Action is the interface for all intents flowing from UI to Workflow.
type AuthErrorEvent ¶
type AuthErrorEvent struct {
Error string
}
AuthErrorEvent signals an error that occurred during the authentication workflow.
type AuthField ¶
type AuthField struct {
ID string `json:"id"`
Label string `json:"label"`
Placeholder string `json:"placeholder"`
EnvVar string `json:"env_var,omitempty"` // Fallback environment variable name
IsSecret bool `json:"is_secret"`
}
AuthField defines a single input field required for an authentication method.
type AuthMethod ¶
type AuthMethod interface {
IsAuthMethod()
}
AuthMethod is a marker interface for authentication data descriptors.
type AuthMethodEvent ¶
type AuthMethodEvent struct {
ProviderID string
Methods []AuthMethod
}
AuthMethodEvent signals that the user needs to select an authentication method from the given list.
type AuthProviderListEvent ¶
type AuthProviderListEvent struct {
Providers []ProviderSummary
}
AuthProviderListEvent contains the data needed for the auth management UI.
type BashDisplay ¶
type BashDisplay struct {
TypeField string `json:"type"`
Description string `json:"description"` // Description from tool (e.g. "Installing dependencies")
Command string `json:"command"` // The command being run (e.g. "npm install")
Cwd string `json:"cwd,omitempty"` // Command working directory
CapturedOutput string `json:"captured_output"` // Raw output captured after execution (baked)
Error string `json:"error,omitempty"`
}
BashDisplay is for bash command execution with streaming output.
func NewBashDisplay ¶
func NewBashDisplay(description, command, cwd, capturedOutput string) BashDisplay
NewBashDisplay creates a new BashDisplay with correct type.
func (BashDisplay) GetError ¶
func (s BashDisplay) GetError() string
GetError returns the error message associated with the display, if any.
func (BashDisplay) Type ¶
func (s BashDisplay) Type() string
Type returns the unique identifier for the bash display type.
func (BashDisplay) WithError ¶
func (s BashDisplay) WithError(err string) ToolDisplay
WithError returns a copy of the display with the specified error message.
type CallIDer ¶
CallIDer is implemented by actions correlated to a tool call (e.g. question answers).
type ConnectingEvent ¶
type ConnectingEvent struct{}
ConnectingEvent is emitted when the app is connecting to the provider.
type CreateSessionAction ¶
type CreateSessionAction struct{}
CreateSessionAction is a user intent to start a brand new conversation.
type Credential ¶
type Credential struct {
Type string `json:"type"` // e.g., "api_key"
APIKey string `json:"api_key,omitempty"`
// Future-proofing for OAuth device flow
OAuthToken string `json:"oauth_token,omitempty"`
}
Credential represents a stored or resolved credential for an LLM provider.
type CredentialFieldEvent ¶
type CredentialFieldEvent struct {
Method AuthMethod
FieldIndex int
}
CredentialFieldEvent signals that the user needs to provide a value for a specific field in an authentication method.
type DeleteSessionAction ¶
type DeleteSessionAction struct {
ID string
}
DeleteSessionAction is a user intent to remove a session permanently.
type DiffDisplay ¶
type DiffDisplay struct {
TypeField string `json:"type"`
Description string `json:"description"`
Target string `json:"target"`
Diff string `json:"diff"`
Error string `json:"error,omitempty"`
Added int `json:"added"`
Removed int `json:"removed"`
}
DiffDisplay is for file edit operations with unified diff content.
func NewDiffDisplay ¶
func NewDiffDisplay(description, target string, added, removed int, diff string) DiffDisplay
NewDiffDisplay creates a new DiffDisplay with correct type.
func (DiffDisplay) GetError ¶
func (d DiffDisplay) GetError() string
GetError returns the error message associated with the display, if any.
func (DiffDisplay) Type ¶
func (d DiffDisplay) Type() string
Type returns the unique identifier for the diff display type.
func (DiffDisplay) WithError ¶
func (d DiffDisplay) WithError(err string) ToolDisplay
WithError returns a copy of the display with the specified error message.
type EnvVarAuthMethod ¶
EnvVarAuthMethod represents an authentication method that relies purely on environment variables.
func (EnvVarAuthMethod) IsAuthMethod ¶
func (EnvVarAuthMethod) IsAuthMethod()
IsAuthMethod marks EnvVarAuthMethod as an implementation of the AuthMethod interface.
type EnvVarInstructionEvent ¶
type EnvVarInstructionEvent struct {
EnvVars []string
}
EnvVarInstructionEvent provides instructions on which environment variables are needed for authentication.
type HistoryEvent ¶
type HistoryEvent struct {
ToolDisplays map[string]ToolDisplay
Messages []*schema.Message
}
HistoryEvent contains the full conversation history for a session.
type InfoEvent ¶
type InfoEvent struct {
Model string
SessionDisplay string
Authorized []string
SessionTokens int
ContextWindow int
}
InfoEvent contains gathered data for UI display of configuration and state.
type LLM ¶
type LLM interface {
ID() string
DisplayName() string
ContextWindow() int
Model() model.ToolCallingChatModel
}
LLM is a language model instance powered by Eino.
type MCPLoadingEvent ¶
type MCPLoadingEvent struct{}
MCPLoadingEvent is emitted when MCP servers are being loaded.
type ModelListEvent ¶
ModelListEvent contains the data needed for model selection UI.
type OAuthDeviceFlowEvent ¶
OAuthDeviceFlowEvent provides the verification URI and user code for OAuth Device Flow authentication.
type OAuthMethod ¶
type OAuthMethod struct {
ID string
Name string
ClientID string
DeviceAuthURL string
TokenURL string
Scopes []string
}
OAuthMethod represents an authentication method that follows the OAuth Device Flow.
func (OAuthMethod) IsAuthMethod ¶
func (OAuthMethod) IsAuthMethod()
IsAuthMethod marks OAuthMethod as an implementation of the AuthMethod interface.
type PermissionDecisionAction ¶
PermissionDecisionAction is sent by the prompt UI to approve or deny a tool permission request.
func (PermissionDecisionAction) GetCallID ¶
func (a PermissionDecisionAction) GetCallID() string
GetCallID implements CallIDer for action routing.
type Provider ¶
type Provider interface {
ID() string
SupportedAuthMethods() []AuthMethod
List() []LLMInfo
GetLLM(ctx context.Context, cred *Credential, info LLMInfo) (LLM, error)
}
Provider represents an LLM service (e.g., Google, OpenAI). It acts as a factory and metadata source for authentication and model listing.
type ProviderInfo ¶
type ProviderInfo struct {
Credential *Credential
ID string
}
ProviderInfo contains a provider's ID and its resolved credential (if any).
type ProviderSummary ¶
ProviderSummary provides a snapshot of a provider's auth status.
type QuestionAnswerAction ¶
type QuestionAnswerAction struct {
CallID string
Answers [][]string // per-question selected labels and/or custom text; order matches Questions
}
QuestionAnswerAction is sent by the prompt UI after the user submits or cancels the question toolbox.
func (QuestionAnswerAction) GetCallID ¶
func (a QuestionAnswerAction) GetCallID() string
GetCallID implements CallIDer for action routing.
type QuestionDisplay ¶
type QuestionDisplay struct {
TypeField string `json:"type"`
Error string `json:"error,omitempty"`
Questions []QuestionInfo `json:"questions"`
}
QuestionDisplay is the tool UI payload for the question tool (preview and final baked state).
func NewQuestionDisplay ¶
func NewQuestionDisplay(questions []QuestionInfo) QuestionDisplay
NewQuestionDisplay returns a QuestionDisplay with type "question".
func (QuestionDisplay) GetError ¶
func (d QuestionDisplay) GetError() string
GetError returns the error message associated with the display, if any.
func (QuestionDisplay) Type ¶
func (d QuestionDisplay) Type() string
Type returns the unique identifier for the question display type.
func (QuestionDisplay) WithError ¶
func (d QuestionDisplay) WithError(err string) ToolDisplay
WithError returns a copy of the display with the specified error message.
type QuestionInfo ¶
type QuestionInfo struct {
Question string `json:"question"`
Options []string `json:"options"`
MultiSelect bool `json:"multiSelect,omitempty"`
}
QuestionInfo describes one question in the question toolbox. Free-text answers are always offered by the UI (not part of this payload).
type RemoveAuthAction ¶
type RemoveAuthAction struct {
ProviderID string
}
RemoveAuthAction is a user intent to remove authentication for a provider.
type RenameSessionAction ¶
RenameSessionAction is a user intent to change a session's title.
type SavedCommand ¶
type SavedCommand struct {
Name string `json:"name"`
Command string `json:"command"`
Description string `json:"description,omitempty"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
}
SavedCommand represents a command saved by the AI agent for later reuse.
type SelectAuthMethodAction ¶
type SelectAuthMethodAction struct {
ID string
}
SelectAuthMethodAction is a user intent to select a specific authentication method for a provider.
type SelectModelAction ¶
type SelectModelAction struct {
ID string
}
SelectModelAction is a user intent to switch the current model.
type SelectProviderAction ¶
type SelectProviderAction struct {
ID string
}
SelectProviderAction is a user intent to select an LLM provider for authentication.
type SelectSessionAction ¶
type SelectSessionAction struct {
ID string
}
SelectSessionAction is a user intent to choose a session from the list.
type Session ¶
type Session struct {
SessionMetadata
SessionMessages
SessionDisplays
}
Session is the composite session type that bundles all three parts. Use Store.GetSession() to load a full session.
func (*Session) TotalTokens ¶
TotalTokens returns the factual total tokens in the session as of the last model response.
type SessionDisplays ¶
type SessionDisplays struct {
ToolDisplays map[string]ToolDisplay
}
SessionDisplays contains the tool displays stored in displays.json.
func (*SessionDisplays) UnmarshalJSON ¶
func (d *SessionDisplays) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for the polymorphic ToolDisplay map.
type SessionListEvent ¶
type SessionListEvent struct {
CurrentSessionID string
Sessions []SessionMetadata
WorkingDir string
}
SessionListEvent contains the data needed for session selection UI.
type SessionMessages ¶
SessionMessages contains the messages stored in messages.json.
type SessionMetadata ¶
type SessionMetadata struct {
ID string
Name string
MessageCount int
TokenCount int
Created time.Time
Updated time.Time
WorkingDir string
Active bool
}
SessionMetadata contains the metadata fields stored in metadata.json.
type SessionSelectedEvent ¶
SessionSelectedEvent is emitted when a session is chosen, indicating if a directory switch is required.
type State ¶
type State struct {
Model string `json:"model"`
}
State holds application persistent state loaded from disk.
type StopAction ¶
type StopAction struct{}
StopAction is a user intent to cancel the current workflow.
type StringDisplay ¶
type StringDisplay struct {
TypeField string `json:"type"`
Description string `json:"description"`
Content string `json:"content"`
Error string `json:"error,omitempty"`
}
StringDisplay is for simple text output (most tools).
func NewStringDisplay ¶
func NewStringDisplay(description, content string) StringDisplay
NewStringDisplay creates a new StringDisplay with correct type.
func (StringDisplay) GetError ¶
func (s StringDisplay) GetError() string
GetError returns the error message associated with the display, if any.
func (StringDisplay) Type ¶
func (s StringDisplay) Type() string
Type returns the unique identifier for the string display type.
func (StringDisplay) WithError ¶
func (s StringDisplay) WithError(err string) ToolDisplay
WithError returns a copy of the display with the specified error message.
type SubmitCredentialAction ¶
type SubmitCredentialAction struct {
Credential Credential
}
SubmitCredentialAction is a user intent to submit a complete set of credentials.
type SubmitFieldAction ¶
type SubmitFieldAction struct {
Value string
}
SubmitFieldAction is a user intent to submit a value for a single authentication field.
type SummaryCompactionEndEvent ¶
type SummaryCompactionEndEvent struct {
Error string
}
SummaryCompactionEndEvent is emitted when context compaction completes. Error is empty on success.
type SummaryCompactionStartEvent ¶
type SummaryCompactionStartEvent struct{}
SummaryCompactionStartEvent is emitted when context compaction begins.
type SystemNotificationEvent ¶
type SystemNotificationEvent struct {
Content string
}
SystemNotificationEvent is emitted when a system notification is injected.
type TaskResult ¶
type TaskResult struct {
ID string `xml:"task-id"`
Status string `xml:"status"`
Description string `xml:"description"`
Command string `xml:"command"`
ExitCode int `xml:"exit-code"`
Error string `xml:"error,omitempty"`
LogPath string `xml:"log-file"`
Cwd string `xml:"cwd"`
}
TaskResult represents the result of a completed background task.
type ToolApprovalRequestEvent ¶
type ToolApprovalRequestEvent struct {
CallID string
}
ToolApprovalRequestEvent marks a running tool as awaiting explicit user approval.
type ToolDisplay ¶
type ToolDisplay interface {
Type() string
GetError() string
WithError(err string) ToolDisplay
// contains filtered or unexported methods
}
ToolDisplay is implemented by all display types returned from tools. The UI uses type switches to render each type appropriately. Must be in domain so tools can implement without importing workflow.
type ToolEndEvent ¶
type ToolEndEvent struct {
Display ToolDisplay
CallID string
}
ToolEndEvent is emitted when tool execution completes with the final baked ToolDisplay.
type ToolStartEvent ¶
type ToolStartEvent struct {
Display ToolDisplay
CallID string
}
ToolStartEvent is sent by preview middleware using the ToolDisplay returned from tool Preview.
type ToolStreamEvent ¶
ToolStreamEvent is emitted for streaming tool output (bash.commands).
type UIUpdate ¶
type UIUpdate interface {
// contains filtered or unexported methods
}
UIUpdate is the interface for all events flowing from Workflow to UI.
type WaitingForNamingEvent ¶
type WaitingForNamingEvent struct{}
WaitingForNamingEvent is emitted when the app is waiting for auto session naming.