agent

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderKeySourceNone     = "none"
	ProviderKeySourceKeyless  = "keyless"
	ProviderKeySourceManaged  = "managed"
	ProviderKeySourceExternal = "external"
)
View Source
const (
	TurnActionRevertCode    = "revert_code"
	TurnActionRevertHistory = "revert_history"
	TurnActionFork          = "fork"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

Agent is the shared core used by all adapters (Wails, HTTP, ACP).

func New

func New(c Config) (*Agent, error)

New constructs an Agent from the given config. It creates the provider client, tool registry, permission gate, snapshot store, and loop. Call Init after setting up the event handler.

func (*Agent) AddCustomProvider added in v0.0.2

func (a *Agent) AddCustomProvider(req CustomProviderRequest) error

AddCustomProvider persists a user-defined provider and selected model entries.

func (*Agent) AllModelList

func (a *Agent) AllModelList() []ModelListEntry

func (*Agent) AppendUserMessage

func (a *Agent) AppendUserMessage(content string) (int, error)

AppendUserMessage persists a user message as its own complete turn WITHOUT running the model. It is a history-seeding primitive (used to script/seed conversation state), not a user-input path — live input goes through Submit. It still routes through the loop's emit chokepoint, so it is display-ordered. Not exposed in the Wails layer.

func (*Agent) ApplyTurnAction

func (a *Agent) ApplyTurnAction(turn int, action string, alsoRevertCode bool) (TurnActionResult, error)

ApplyTurnAction applies a revert/fork action selected from a user message. The turn argument is the clicked user turn; this method owns the conversion to the lower-level snapshot/history cut points so adapters do not duplicate it.

func (*Agent) BeforeModelRequest

func (a *Agent) BeforeModelRequest(ctx context.Context, checkpoint loop.ContextTransformCheckpoint) (loop.ContextTransformResult, error)

BeforeModelRequest implements the loop context-transform checkpoint.

func (*Agent) Busy

func (a *Agent) Busy() bool

Busy reports whether a turn is in progress.

func (*Agent) Cancel

func (a *Agent) Cancel() error

Cancel aborts the current turn.

func (*Agent) CloseForProjectSwitch

func (a *Agent) CloseForProjectSwitch() error

CloseForProjectSwitch cancels any active turn, closes the current session, and clears queued input under the backend transition guard before adapters relaunch the process in another project.

func (*Agent) CompactNow

func (a *Agent) CompactNow(ctx context.Context) error

CompactNow triggers manual compaction. Must not be called while busy.

func (*Agent) CompleteModelEntry

func (a *Agent) CompleteModelEntry(refStr string, completion ModelCompletion) error

func (*Agent) ConnectProvider added in v0.0.2

func (a *Agent) ConnectProvider(providerID, apiKey string) error

ConnectProvider connects an existing catalog provider. Providers that already have usable models only need credential persistence; empty discovery-backed providers run a one-shot connect-time discovery before any secret is persisted. The network fetch runs outside runtime.mu so a stalled endpoint cannot block other adapter calls.

func (*Agent) CurrentModel

func (a *Agent) CurrentModel() ModelInfo

CurrentModel returns the active model identity and catalog metadata.

func (*Agent) CurrentWarnings

func (a *Agent) CurrentWarnings() []PromptWarning

CurrentWarnings returns the current warning snapshot for adapters that need to hydrate UI state after startup events may already have fired.

func (*Agent) DeleteModel added in v0.0.2

func (a *Agent) DeleteModel(providerID, modelID string) error

DeleteModel removes a user-added model from config. Bundled/discovered models cannot be deleted (the merge would re-add them); hide or reset them instead.

func (*Agent) DisconnectProvider added in v0.0.2

func (a *Agent) DisconnectProvider(providerID string) error

DisconnectProvider removes only a Lightcode-managed key. External/shell keys are deliberately left alone and reported as not disconnectable.

func (*Agent) DiscoverCustomProvider added in v0.0.2

func (a *Agent) DiscoverCustomProvider(req CustomProviderRequest) ([]DiscoveryModelCandidate, error)

DiscoverCustomProvider runs one-shot discovery for an unsaved custom provider. It persists nothing. The network fetch runs outside runtime.mu so a stalled endpoint cannot block other adapter calls.

func (*Agent) DiscoverableModels added in v0.0.2

func (a *Agent) DiscoverableModels(providerID string) ([]DiscoveryModelCandidate, error)

DiscoverableModels returns the provider's models that exist at its /models endpoint but are not currently included (usable) in the catalog — the pool the user picks from in "Add model". Runs live discovery against the connected provider.

func (*Agent) ForkSession

func (a *Agent) ForkSession(turn int) error

ForkSession creates a new session branched from the given turn.

func (*Agent) GenerateAPIKeyEnvName added in v0.0.2

func (a *Agent) GenerateAPIKeyEnvName(providerID string) string

GenerateAPIKeyEnvName returns a stable, unique env var name derived from providerID.

func (*Agent) GetProviderConfig added in v0.0.2

func (a *Agent) GetProviderConfig(providerID string) (ProviderConfigView, error)

GetProviderConfig returns the merged effective config of a provider and its models for the config editor. Read-only.

func (*Agent) GetRuntimeConfig added in v0.0.2

func (a *Agent) GetRuntimeConfig() RuntimeConfigSettings

func (*Agent) Init

func (a *Agent) Init(ctx context.Context)

Init starts background goroutines, runs the session sweep, and resumes the most recent session if one exists. ctx controls the agent's lifetime.

func (*Agent) ManagedEnv added in v0.0.2

func (a *Agent) ManagedEnv() *config.ManagedEnv

ManagedEnv returns the live .env state for this agent. It is safe for concurrent use. May return nil in tests that did not wire one up.

func (*Agent) ModelList

func (a *Agent) ModelList() []ModelListEntry

ModelList returns all visible catalog models as flat enriched entries.

func (*Agent) PermissionSuggest

func (a *Agent) PermissionSuggest(toolName, arg string) []PermissionSuggestion

PermissionSuggest returns pattern suggestions for the "Allow for project" UI.

func (*Agent) ProjectCurrent

func (a *Agent) ProjectCurrent() ProjectSummary

ProjectCurrent returns the project record for the current cwd.

func (*Agent) ProjectList

func (a *Agent) ProjectList() ([]ProjectSummary, error)

ProjectList returns every known project sorted by last activity.

func (*Agent) ProjectName

func (a *Agent) ProjectName() string

ProjectName returns the basename of the project directory.

func (*Agent) ProjectRoot

func (a *Agent) ProjectRoot() string

ProjectRoot returns the absolute project directory path.

func (*Agent) Projects

func (a *Agent) Projects() *project.Resolver

Projects returns the project resolver (needed by Wails adapter for project switching).

func (*Agent) ProviderList added in v0.0.2

func (a *Agent) ProviderList() []ProviderStatus

ProviderList returns all effective providers with live connection/key-source status.

func (*Agent) QueueSnapshot

func (a *Agent) QueueSnapshot() QueueState

QueueSnapshot returns a versioned copy of the current queue, for adapter hydration (subscribe-then-GET: register the queue_changed handler first).

func (*Agent) ReadFileContent

func (a *Agent) ReadFileContent(path string) (string, error)

ReadFileContent reads a file for the inline viewer. Enforces the viewer file-read boundary: paths outside canonical project root, escaping symlinks, hardlinks to outside-boundary inodes, and sensitive-name leaves are refused before any byte is read.

func (*Agent) RefreshDiscovery

func (a *Agent) RefreshDiscovery(provider string) error

RefreshDiscovery refreshes live model discovery for one enabled provider.

func (*Agent) Reload

func (a *Agent) Reload() error

Reload reloads config and catalog state for future turns.

func (*Agent) RemoveProvider added in v0.0.2

func (a *Agent) RemoveProvider(providerID string) error

RemoveProvider deletes a custom provider entry from config.json.

func (*Agent) ResetModelField added in v0.0.2

func (a *Agent) ResetModelField(providerID, modelID, field string) error

ResetModelField deletes a single user-layer override on a model, reverting it to the bundled/discovery value. No-op (no write) when no override exists.

func (*Agent) ResetProviderField added in v0.0.2

func (a *Agent) ResetProviderField(providerID, field string) error

ResetProviderField deletes a single user-layer override on a provider, reverting it to the bundled value. No-op (no write) when no override exists.

func (*Agent) RespondPermission

func (a *Agent) RespondPermission(id string, allow bool) error

RespondPermission answers a pending permission prompt.

func (*Agent) RespondPermissionAction

func (a *Agent) RespondPermissionAction(id string, action string) error

RespondPermissionAction answers a pending permission prompt with an action.

func (*Agent) RevertCode

func (a *Agent) RevertCode(turn int) error

RevertCode restores files to their state at the given turn. After the store revert lands the file tracker is repopulated from conversation history: stale per-path identities are cleared while paths visible in messages keep their "read happened" marker, forcing a re-read on the next edit until read_file observes the current disk state. Symmetric with RevertHistory.

func (*Agent) RevertHistory

func (a *Agent) RevertHistory(turn int) error

RevertHistory truncates conversation after the given turn.

func (*Agent) SaveModel added in v0.0.2

func (a *Agent) SaveModel(providerID, modelID string, cfg ModelConfigInput) error

SaveModel adds or edits one model's fields under a provider (user-layer overrides). Used for both editing and "add model".

func (*Agent) SaveProjectPermission

func (a *Agent) SaveProjectPermission(id string, patterns []string) error

SaveProjectPermission appends patterns to the project's local permissions.json, then allows the pending request.

func (*Agent) SessionArchive

func (a *Agent) SessionArchive(id string) (bool, error)

SessionArchive archives a session. If it's the current session, close first. Returns true if the current session was closed.

func (*Agent) SessionCurrent

func (a *Agent) SessionCurrent() SessionSummary

SessionCurrent returns the active session, or zero-value if none is open.

func (*Agent) SessionDelete

func (a *Agent) SessionDelete(id string) (bool, error)

SessionDelete removes a session from disk. Returns true if the current session was closed.

func (*Agent) SessionList

func (a *Agent) SessionList(state string) ([]SessionSummary, error)

SessionList returns sessions for the current project filtered by state.

func (*Agent) SessionMessages

func (a *Agent) SessionMessages() []DisplayMessage

SessionMessages returns the persisted messages for the current session.

func (*Agent) SessionMessagesFor

func (a *Agent) SessionMessagesFor(id string) ([]DisplayMessage, error)

SessionMessagesFor returns persisted messages for a session without switching the active session.

func (*Agent) SessionNew

func (a *Agent) SessionNew() error

SessionNew closes the current session and starts fresh.

func (*Agent) SessionSwitch

func (a *Agent) SessionSwitch(id string) error

SessionSwitch closes the current session and loads another.

func (*Agent) SetDefaultModel added in v0.0.2

func (a *Agent) SetDefaultModel(refStr string) error

func (*Agent) SetEventHandler

func (a *Agent) SetEventHandler(fn func(Event))

SetEventHandler sets the callback for agent events. Must be called before Init.

func (*Agent) SetModelHidden

func (a *Agent) SetModelHidden(refStr string, hidden bool) error

func (*Agent) SetProviderConfig added in v0.0.2

func (a *Agent) SetProviderConfig(providerID string, cfg ProviderConfigInput) error

SetProviderConfig edits an existing provider's transport and provider-level fields (user-layer overrides). The API key value is never written here.

func (*Agent) SetProviderHidden

func (a *Agent) SetProviderHidden(providerID string, hidden bool) error

func (*Agent) SetRuntimeConfig added in v0.0.2

func (a *Agent) SetRuntimeConfig(settings RuntimeConfigSettings) error

func (*Agent) SnapshotList

func (a *Agent) SnapshotList() ([]Snapshot, error)

SnapshotList returns the timeline of all snapshots in the session.

func (*Agent) Store

func (a *Agent) Store() *snapshot.Store

Store returns the snapshot store (needed by Wails adapter for session-changed events).

func (*Agent) Submit

func (a *Agent) Submit(ctx context.Context, content string) (SubmitResult, error)

Submit is the single entry point for new user input. If the agent is idle with an empty queue it starts a turn immediately; otherwise it appends to the backend-owned in-memory queue (drained automatically after the active turn ends). It rejects with an error while a session change is in flight rather than accepting input it would then discard. Any queue mutation emits a versioned EventQueueChanged.

func (*Agent) SwitchModel

func (a *Agent) SwitchModel(refStr string) error

SwitchModel changes the active model by provider-prefixed catalog ref.

func (*Agent) TokenUsage

func (a *Agent) TokenUsage() TokenReport

TokenUsage returns cumulative token usage for the session.

type BackgroundProcessDisplay

type BackgroundProcessDisplay struct {
	ID       string `json:"id"`
	Command  string `json:"command"`
	Reason   string `json:"reason"`
	ExitCode int    `json:"exitCode"`
	Output   string `json:"output"`
}

BackgroundProcessDisplay is the adapter-facing display payload for a background process completion delivered as model input.

type Config

type Config struct {
	Cfg         *config.Config
	ConfigPath  string // absolute path the config was loaded from; used for reloads and writes
	ProjectRoot string
	Home        string
	Env         *config.ManagedEnv // live .env state; may be nil in tests
}

Config carries constructor parameters for New.

type CustomProviderModelInput added in v0.0.2

type CustomProviderModelInput struct {
	ID               string                    `json:"id"`
	Name             string                    `json:"name"`
	ContextWindow    int                       `json:"contextWindow"`
	MaxOutputTokens  int                       `json:"maxOutputTokens"`
	InputModalities  []catalog.Modality        `json:"inputModalities,omitempty"`
	SystemRole       catalog.SystemRole        `json:"systemRole,omitempty"`
	UsageInStream    *bool                     `json:"usageInStream,omitempty"`
	ExtraBody        map[string]any            `json:"extraBody,omitempty"`
	Cost             *catalog.Cost             `json:"cost,omitempty"`
	ProtocolMetadata *catalog.ProtocolMetadata `json:"protocolMetadata,omitempty"`
	Hidden           bool                      `json:"hidden,omitempty"`
}

CustomProviderModelInput is one model selected by the user for a custom provider.

type CustomProviderRequest added in v0.0.2

type CustomProviderRequest struct {
	ID               string                     `json:"id"`
	Name             string                     `json:"name"`
	BaseURL          string                     `json:"baseURL"`
	APIKeyEnv        string                     `json:"apiKeyEnv"`
	APIKey           string                     `json:"apiKey"`
	Headers          map[string]string          `json:"headers,omitempty"`
	Options          map[string]any             `json:"options,omitempty"`
	SystemRole       catalog.SystemRole         `json:"systemRole,omitempty"`
	UsageInStream    *bool                      `json:"usageInStream,omitempty"`
	MaxTokensField   string                     `json:"maxTokensField,omitempty"`
	ExtraBody        map[string]any             `json:"extraBody,omitempty"`
	ProtocolMetadata *catalog.ProtocolMetadata  `json:"protocolMetadata,omitempty"`
	Hidden           bool                       `json:"hidden,omitempty"`
	Discovery        bool                       `json:"discovery"`
	Models           []CustomProviderModelInput `json:"models"`
}

CustomProviderRequest is the adapter-neutral payload for adding a custom provider.

type DiscoveryModelCandidate added in v0.0.2

type DiscoveryModelCandidate struct {
	ID              string        `json:"id"`
	Name            string        `json:"name"`
	ContextWindow   int           `json:"contextWindow"`
	MaxOutputTokens int           `json:"maxOutputTokens"`
	Cost            *catalog.Cost `json:"cost,omitempty"`
	Usable          bool          `json:"usable"`
}

DiscoveryModelCandidate is model metadata returned by connect-time discovery.

type DisplayMessage

type DisplayMessage struct {
	Type    string `json:"type"`
	Content string `json:"content,omitempty"`
	Turn    int    `json:"turn,omitempty"`

	ID       string         `json:"id,omitempty"`
	Name     string         `json:"name,omitempty"`
	Args     string         `json:"args,omitempty"`
	Done     bool           `json:"done,omitempty"`
	Success  bool           `json:"success,omitempty"`
	Result   string         `json:"result,omitempty"`
	Metadata map[string]any `json:"metadata,omitempty"`

	SubagentSessionIDs []SubagentSessionLink     `json:"subagentSessionIds,omitempty"`
	BackgroundProcess  *BackgroundProcessDisplay `json:"backgroundProcess,omitempty"`
}

DisplayMessage is the pre-assembled, display-ready message returned by SessionMessages. Type is the discriminator: "user", "assistant", "tool", "system".

type Event

type Event struct {
	Kind EventKind

	// Loop-level fields (forwarded from loop.Event):
	ToolName   string
	ToolCallID string
	Args       string
	Result     string
	IsError    bool
	Model      string
	Cache      int
	Input      int
	Output     int
	UsageKnown bool
	Metadata   map[string]any

	// Agent-level fields:
	Turn              int
	Cancelled         bool
	Error             string
	RefreshSession    bool
	PermReq           *PermissionRequest
	Warnings          []PromptWarning
	SubagentSessionID string
	TaskIndex         int
	BackgroundProcess *BackgroundProcessDisplay

	// Queue fields (EventQueueChanged): a versioned snapshot of the input queue.
	Queue        []QueuedItem
	QueueVersion int
}

Event is the unified event type emitted by the Agent to adapters.

type EventKind

type EventKind int

EventKind identifies the type of agent event.

const (
	EventTextDelta                 EventKind = iota // Streamed text chunk from the model.
	EventToolCallStart                              // Tool call begins.
	EventToolCallEnd                                // Tool call completes.
	EventUsage                                      // Token usage report from the model.
	EventTurnStart                                  // Agent starts processing a turn.
	EventTurnEnd                                    // Agent finished processing a turn.
	EventError                                      // The agentic loop returned an error.
	EventPermissionRequest                          // A tool needs user approval.
	EventCompactionStart                            // Compaction beginning.
	EventCompactionEnd                              // Compaction finished.
	EventWarning                                    // Current warning snapshot changed.
	EventSubagentStart                              // A subagent session started.
	EventBackgroundProcessComplete                  // A background process completion was delivered to the model.
	EventUserMessageDisplay                         // A user-role message was appended to history.
	EventGenericSystemSignal                        // A non-background <system-signal> was appended to history.
	EventQueueChanged                               // The backend-owned input queue changed; carries a versioned snapshot.
)

type ModelCompletion

type ModelCompletion struct {
	ContextWindow   int `json:"context_window"`
	MaxOutputTokens int `json:"max_output_tokens"`
}

type ModelConfigInput added in v0.0.2

type ModelConfigInput struct {
	Name             string                    `json:"name"`
	ContextWindow    int                       `json:"contextWindow"`
	MaxOutputTokens  int                       `json:"maxOutputTokens"`
	InputModalities  []catalog.Modality        `json:"inputModalities,omitempty"`
	SystemRole       catalog.SystemRole        `json:"systemRole,omitempty"`
	UsageInStream    *bool                     `json:"usageInStream,omitempty"`
	ExtraBody        map[string]any            `json:"extraBody,omitempty"`
	Cost             *catalog.Cost             `json:"cost,omitempty"`
	ProtocolMetadata *catalog.ProtocolMetadata `json:"protocolMetadata,omitempty"`
}

ModelConfigInput is the adapter-neutral payload for adding or editing one model's fields under a provider. Only set fields are written; absent fields are left untouched (use ResetModelField to drop an override).

type ModelConfigView added in v0.0.2

type ModelConfigView struct {
	ID               string                    `json:"id"`
	Name             string                    `json:"name"`
	ContextWindow    int                       `json:"contextWindow"`
	MaxOutputTokens  int                       `json:"maxOutputTokens"`
	InputModalities  []catalog.Modality        `json:"inputModalities"`
	SystemRole       string                    `json:"systemRole"`
	UsageInStream    bool                      `json:"usageInStream"`
	ExtraBody        map[string]any            `json:"extraBody"`
	Cost             *catalog.Cost             `json:"cost"`
	ProtocolMetadata *catalog.ProtocolMetadata `json:"protocolMetadata"`
	Hidden           bool                      `json:"hidden"`
	Source           string                    `json:"source"`
}

ModelConfigView is the merged, effective config of one model for the editor.

type ModelInfo

type ModelInfo struct {
	Ref           string        `json:"ref"`
	Provider      string        `json:"provider"`
	Model         string        `json:"model"`
	DisplayName   string        `json:"displayName"`
	ContextWindow int           `json:"contextWindow"`
	Cost          *catalog.Cost `json:"cost,omitempty"`
	Incomplete    bool          `json:"incomplete"`
}

ModelInfo holds the active model identity and catalog metadata.

type ModelListEntry

type ModelListEntry struct {
	Ref             string        `json:"ref"`
	Provider        string        `json:"provider"`
	ProviderName    string        `json:"providerName"`
	Model           string        `json:"model"`
	DisplayName     string        `json:"displayName"`
	ContextWindow   int           `json:"contextWindow"`
	MaxOutputTokens int           `json:"maxOutputTokens"`
	Cost            *catalog.Cost `json:"cost,omitempty"`
	Hidden          bool          `json:"hidden"`
	ProviderHidden  bool          `json:"providerHidden"`
	Incomplete      bool          `json:"incomplete"`
	Default         bool          `json:"default"`
	// Source is the model's provenance: "bundled", "discovered", or "user".
	// Only "user" models can be truly deleted from config; the others can be
	// hidden or have individual field overrides reset.
	Source string `json:"source"`
}

ModelListEntry is one flat picker/list entry from the catalog.

type PermissionRequest

type PermissionRequest struct {
	ID          string
	ToolName    string
	Arg         string
	ResolvedArg string
	CanAllowAll bool
	BatchIndex  int
	BatchTotal  int
	BatchFiles  []string
}

PermissionRequest is sent to adapters when a tool needs user approval.

type PermissionSuggestion

type PermissionSuggestion = permission.Suggestion

PermissionSuggestion re-exports permission.Suggestion so adapters don't need to import the permission package.

type ProjectSummary

type ProjectSummary struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Path         string `json:"path"`
	CreatedAt    string `json:"createdAt"`
	LastActivity int64  `json:"lastActivity"`
}

ProjectSummary is the payload for project queries.

type PromptWarning

type PromptWarning struct {
	Kind    string `json:"kind"`
	Message string `json:"message"`
}

PromptWarning is a user-visible warning from prompt, catalog, LSP, or related systems.

type ProviderConfigInput added in v0.0.2

type ProviderConfigInput struct {
	Name             string                    `json:"name"`
	BaseURL          string                    `json:"baseURL"`
	APIKeyEnv        string                    `json:"apiKeyEnv"`
	Headers          map[string]string         `json:"headers,omitempty"`
	Options          map[string]any            `json:"options,omitempty"`
	SystemRole       catalog.SystemRole        `json:"systemRole,omitempty"`
	UsageInStream    *bool                     `json:"usageInStream,omitempty"`
	MaxTokensField   string                    `json:"maxTokensField,omitempty"`
	ExtraBody        map[string]any            `json:"extraBody,omitempty"`
	Discovery        *bool                     `json:"discovery,omitempty"`
	ProtocolMetadata *catalog.ProtocolMetadata `json:"protocolMetadata,omitempty"`
}

ProviderConfigInput is the adapter-neutral payload for editing an existing provider's config (transport + provider-level fields). It carries only set fields; absent fields are left untouched. The API key value is never carried here — secrets flow through ConnectProvider, write-only.

type ProviderConfigView added in v0.0.2

type ProviderConfigView struct {
	ID               string                    `json:"id"`
	Name             string                    `json:"name"`
	Builtin          bool                      `json:"builtin"`
	Connected        bool                      `json:"connected"`
	BaseURL          string                    `json:"baseURL"`
	APIKeyEnv        string                    `json:"apiKeyEnv"`
	GeneratedKeyEnv  string                    `json:"generatedKeyEnv"`
	Headers          map[string]string         `json:"headers"`
	UserHeaders      map[string]string         `json:"userHeaders"`
	Options          map[string]any            `json:"options"`
	SystemRole       string                    `json:"systemRole"`
	UsageInStream    bool                      `json:"usageInStream"`
	MaxTokensField   string                    `json:"maxTokensField"`
	ExtraBody        map[string]any            `json:"extraBody"`
	Discovery        bool                      `json:"discovery"`
	ProtocolMetadata *catalog.ProtocolMetadata `json:"protocolMetadata"`
	Models           []ModelConfigView         `json:"models"`
}

ProviderConfigView is the merged, effective config of one provider for the config editor. Values reflect bundled+user+discovery; edits write overrides.

type ProviderStatus added in v0.0.2

type ProviderStatus struct {
	ID              string `json:"id"`
	Name            string `json:"name"`
	Builtin         bool   `json:"builtin"`
	Connected       bool   `json:"connected"`
	KeySource       string `json:"keySource"`
	Disconnectable  bool   `json:"disconnectable"`
	Removable       bool   `json:"removable"`
	APIKeyEnv       string `json:"apiKeyEnv"`
	GeneratedKeyEnv string `json:"generatedKeyEnv,omitempty"`
	BaseURL         string `json:"baseURL"`
	Discovery       bool   `json:"discovery"`
	ModelCount      int    `json:"modelCount"`
	UsableModels    int    `json:"usableModels"`
}

ProviderStatus describes a provider's setup state for adapter-neutral settings surfaces.

type QueueState

type QueueState struct {
	Items   []QueuedItem `json:"items"`
	Version int          `json:"version"`
}

QueueState is a versioned snapshot of the input queue, returned by QueueSnapshot for hydration. Version is monotonic for the agent's lifetime; adapters drop snapshots whose version <= the last they applied.

type QueuedItem

type QueuedItem struct {
	ID      string `json:"id"`
	Content string `json:"content"`
}

QueuedItem is one user message awaiting backend drain. ID is stable per session (for keyed rendering); the queue is in-memory and volatile.

type RuntimeCompactionConfig added in v0.0.2

type RuntimeCompactionConfig struct {
	ThresholdPct    float64 `json:"threshold_pct"`
	SummarizerModel string  `json:"summarizer_model"`
}

type RuntimeConfigSettings added in v0.0.2

type RuntimeConfigSettings struct {
	Sessions   RuntimeSessionsConfig   `json:"sessions"`
	Compaction RuntimeCompactionConfig `json:"compaction"`
	Subagents  RuntimeSubagentsConfig  `json:"subagents"`
	Tools      RuntimeToolsConfig      `json:"tools"`
}

type RuntimeSessionsConfig added in v0.0.2

type RuntimeSessionsConfig struct {
	ArchiveAfterDays       int `json:"archive_after_days"`
	DeleteAfterArchiveDays int `json:"delete_after_archive_days"`
}

type RuntimeSubagentsConfig added in v0.0.2

type RuntimeSubagentsConfig struct {
	MaxConcurrent int    `json:"max_concurrent"`
	Model         string `json:"model"`
}

type RuntimeToolsConfig added in v0.0.2

type RuntimeToolsConfig struct {
	MaxOutputBytes         int `json:"max_output_bytes"`
	ReadMaxLines           int `json:"read_max_lines"`
	ReadLineMaxChars       int `json:"read_line_max_chars"`
	CommandTimeout         int `json:"command_timeout"`
	MaxBackgroundProcesses int `json:"max_background_processes"`
}

type SessionSummary

type SessionSummary struct {
	ID              string `json:"id"`
	CreatedAt       string `json:"createdAt"`
	LastActivity    int64  `json:"lastActivity"`
	State           string `json:"state"`
	ArchivedAt      int64  `json:"archivedAt"`
	ProjectPath     string `json:"projectPath"`
	ParentSessionID string `json:"parentSessionId,omitempty"`
}

SessionSummary is the payload for session queries.

type Snapshot

type Snapshot struct {
	Turn  int            `json:"turn"`
	Files []SnapshotFile `json:"files"`
}

Snapshot describes one turn's snapshots.

type SnapshotFile

type SnapshotFile struct {
	Path    string `json:"path"`
	Existed bool   `json:"existed"`
}

SnapshotFile describes one file within a snapshot turn.

type SubagentSessionLink struct {
	Index     int    `json:"index"`
	SessionID string `json:"sessionId"`
}

type SubmitResult

type SubmitResult struct {
	Started bool         `json:"started"`
	Turn    int          `json:"turn,omitempty"`
	Queue   []QueuedItem `json:"queue"`
	Version int          `json:"version"`
}

SubmitResult reports whether submitted input started a turn or was queued.

type TaggedLoopEvent

type TaggedLoopEvent struct {
	SessionID  string
	TaskIndex  int
	ToolCallID string
	Event      loop.Event
}

type TokenEntry

type TokenEntry struct {
	Provider string `json:"provider"`
	Model    string `json:"model"`
	Cache    int    `json:"cache"`
	Input    int    `json:"input"`
	Output   int    `json:"output"`
	Known    bool   `json:"known"`
}

TokenEntry holds accumulated token counts for one {provider, model} pair.

type TokenReport

type TokenReport struct {
	Total         TokenEntry   `json:"total"`
	PerModel      []TokenEntry `json:"perModel"`
	ContextUsed   int          `json:"contextUsed"`
	ContextWindow int          `json:"contextWindow"`
}

TokenReport is the cumulative token usage for a session.

type TurnActionResult

type TurnActionResult struct {
	Action         string           `json:"action"`
	Turn           int              `json:"turn"`
	TargetTurn     int              `json:"targetTurn"`
	SessionChanged bool             `json:"sessionChanged"`
	Prefill        string           `json:"prefill,omitempty"`
	Session        SessionSummary   `json:"session"`
	Messages       []DisplayMessage `json:"messages,omitempty"`
	Tokens         TokenReport      `json:"tokens"`
}

TurnActionResult is returned after a user-message revert/fork action.

Jump to

Keyboard shortcuts

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