agent

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(agentType AgentType, a AgentRuntime)

func Unregister

func Unregister(agentType AgentType)

Types

type AgentRuntime

type AgentRuntime interface {
	Type() AgentType
	ValidateCredentials(rawConfig []byte) (*CredentialCheckResult, error)
	FormatProviderConfig(providers []LLMProviderData) ([]byte, error)
}

func Get

func Get(agentType AgentType) (AgentRuntime, error)

type AgentType

type AgentType string
const (
	AgentTypeOpenCode AgentType = "opencode"
)

type CredentialCheckResult

type CredentialCheckResult struct {
	State   CredentialState `json:"state"`
	Agent   AgentType       `json:"agent"`
	Message string          `json:"message,omitempty"`
}

type CredentialState

type CredentialState string
const (
	CredentialStatePresent CredentialState = "Present"
	CredentialStateMissing CredentialState = "Missing"
	CredentialStateInvalid CredentialState = "Invalid"
)

type Dialect

type Dialect interface {
	// --- Session route paths (pod-internal, relative) ---
	SessionCreatePath() string
	SessionListPath() string
	SessionMessagePath(sessionID string) string
	SessionPromptAsyncPath(sessionID string) string
	SessionAbortPath(sessionID string) string
	SessionGetPath(sessionID string) string
	EventStreamPath() string

	// --- Input request route paths ---
	QuestionListPath() string
	QuestionReplyPath(requestID string) string
	QuestionRejectPath(requestID string) string
	PermissionListPath() string
	PermissionReplyPath(requestID string) string

	// --- SSE event classification ---
	IsQuestionAsked(eventType string) bool
	IsQuestionResolved(eventType string) bool
	IsPermissionAsked(eventType string) bool
	IsPermissionResolved(eventType string) bool
	IsSessionIdle(eventType string, properties json.RawMessage) bool
	IsSessionBusy(eventType string, properties json.RawMessage) bool

	// --- Event parsing (returns nil+error if event doesn't match) ---
	ParseQuestionRequest(eventType string, properties json.RawMessage) (*QuestionRequest, error)
	ParsePermissionRequest(eventType string, properties json.RawMessage) (*PermissionRequest, error)
	ParseSessionStatus(properties json.RawMessage) (sessionID string, status string, err error)
}

Dialect encodes the HTTP API contract of the agent running inside a workspace pod. Implement this interface for each supported agent runtime.

type InputResolution

type InputResolution struct {
	RequestID string `json:"request_id"`
	SessionID string `json:"session_id"`
	Reply     string `json:"reply,omitempty"`
}

InputResolution contains the resolution data for a question or permission.

type LLMModelConfig

type LLMModelConfig struct {
	ID           string `json:"id"`
	Label        string `json:"label,omitempty"`
	ContextLimit int    `json:"contextLimit,omitempty"`
	OutputLimit  int    `json:"outputLimit,omitempty"`
}

LLMModelConfig specifies a model identifier, optional display label, and optional context/output token limits.

ContextLimit and OutputLimit MUST be set together (both > 0) to be emitted into opencode's agent-config.json — opencode's published JSON Schema (https://opencode.ai/config.json) requires both `context` and `output` when the `limit` object is present. See pkg/secrets/types.go LLMModelConfig for the authoritative documentation.

type LLMProviderData

type LLMProviderData struct {
	Kind       string           `json:"kind"`
	Slug       string           `json:"slug"`
	APIKey     string           `json:"apiKey"`
	BaseURL    string           `json:"baseURL,omitempty"`
	Models     []LLMModelConfig `json:"models,omitempty"`
	Default    string           `json:"default,omitempty"`
	SmallModel string           `json:"smallModel,omitempty"`
}

LLMProviderData is re-exported from pkg/secrets for use in the interface. This avoids a circular import between pkg/agent and pkg/secrets.

Epic 55: see pkg/secrets/types.go for the authoritative documentation. Briefly — Kind is the SDK-class enum; Slug is the per-owner unique identity that becomes the literal key in agent-config.json's provider map (opencode persists it as `providerID` on session records).

type PermissionRequest

type PermissionRequest struct {
	ID            string                 `json:"id"`
	SessionID     string                 `json:"session_id"`
	RootSessionID string                 `json:"root_session_id,omitempty"`
	Permission    string                 `json:"permission"`
	Patterns      []string               `json:"patterns"`
	Metadata      map[string]interface{} `json:"metadata,omitempty"`
	Always        []string               `json:"always,omitempty"`
	Tool          *ToolRef               `json:"tool,omitempty"`
}

PermissionRequest is the normalized, agent-agnostic representation of a pending permission.

RootSessionID — see QuestionRequest for semantics.

type QuestionInfo

type QuestionInfo struct {
	Question string           `json:"question"`
	Header   string           `json:"header"`
	Options  []QuestionOption `json:"options"`
	Multiple bool             `json:"multiple"`
	Custom   bool             `json:"custom"`
}

QuestionInfo is a single question with its options.

type QuestionOption

type QuestionOption struct {
	Label       string `json:"label"`
	Description string `json:"description"`
}

QuestionOption is a single selectable choice within a question.

type QuestionRequest

type QuestionRequest struct {
	ID            string         `json:"id"`
	SessionID     string         `json:"session_id"`
	RootSessionID string         `json:"root_session_id,omitempty"`
	Questions     []QuestionInfo `json:"questions"`
	Tool          *ToolRef       `json:"tool,omitempty"`
}

QuestionRequest is the normalized, agent-agnostic representation of a pending question.

RootSessionID is the top-level session in the parent chain. For top-level sessions it equals SessionID. For subtask/subagent sessions (e.g. opencode's `task` tool spawning child sessions) it is the ancestor session that the user is actually viewing in the chat UI. The frontend uses this to bubble subtask prompts up to the user — without it, prompts would be silently dropped because the subtask's SessionID does not match the URL session.

type ToolRef

type ToolRef struct {
	MessageID string `json:"message_id"`
	CallID    string `json:"call_id"`
}

ToolRef identifies the tool call that triggered the input request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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