Documentation
¶
Overview ¶
Package codingagent provides the high-level SDK for embedding pi's agent capabilities in Go programs.
The primary entry point is NewAgentSession, which creates a fully configured AgentSession from an AgentSessionOptions struct. The returned session supports [AgentSession.Prompt], [AgentSession.Subscribe], and [AgentSession.SubscribeChan] for event-driven interaction with the underlying agent.
See docs/sdk.md for usage patterns and the examples/ directory for runnable programs covering minimal, custom-model, tools, settings, session management, and full-control configurations.
Index ¶
- Constants
- Variables
- func AuthGuidanceDocPaths() (providersDoc, modelsDoc string)
- func BuildSystemPrompt(options SystemPromptOptions) string
- func BuiltInToolPromptData(toolNames []string) (map[string]string, []string)
- func ConvertToLLM(_ context.Context, messages agent.AgentMessages) (ai.MessageList, error)
- func ConvertToLLMWithBlockImages(blockImages func() bool) agent.ConvertToLLMFunc
- func DefaultAgentDir() string
- func DefaultAvailableModel(provider string, available []ai.Model) *ai.Model
- func DefaultModelIDForProvider(provider string) (string, bool)
- func ExpandPromptTemplate(text string, templates []PromptTemplate) string
- func ExpandSkillCommand(text string, skills []Skill) (string, error)
- func FormatChangelog(content string) string
- func FormatNoModelsAvailableMessage() string
- func FormatSkillInvocation(skill Skill, additionalInstructions string) string
- func FormatSkillsForPrompt(skills []Skill) string
- func GetExtensionTempFolder(agentDir string) (string, error)
- func IsUnknownModel(model *ai.Model) bool
- func LoadProjectContextFiles(cwd, agentDir string) ([]ContextFile, []ResourceDiagnostic)
- func MarshalSessionEvent(event any) ([]byte, error)
- func OpenBrowser(target string)
- func ParseCommandArgs(argsString string) []string
- func PreferredAvailableModel(available []ai.Model) *ai.Model
- func ResolveModelScope(patterns []string, available []ai.Model) ([]ScopedModel, []ModelDiagnostic)
- func ResolveProjectTrusted(ctx context.Context, options ResolveProjectTrustedOptions) (bool, error)
- func SubstituteArgs(content string, args []string) string
- type AgentSession
- type AgentSessionOptions
- type AgentSessionResult
- type AgentSessionRuntime
- func (runtime *AgentSessionRuntime) CWD() string
- func (runtime *AgentSessionRuntime) Diagnostics() []AgentSessionRuntimeDiagnostic
- func (runtime *AgentSessionRuntime) Dispose(ctx context.Context)
- func (runtime *AgentSessionRuntime) Fork(ctx context.Context, entryID string, options *extensions.ForkOptions) (AgentSessionRuntimeForkResult, error)
- func (runtime *AgentSessionRuntime) ImportFromJSONL(ctx context.Context, inputPath string, cwdOverride string) (extensions.SessionReplacementResult, error)
- func (runtime *AgentSessionRuntime) ModelFallbackMessage() string
- func (runtime *AgentSessionRuntime) NewSession(ctx context.Context, options *extensions.NewSessionOptions) (extensions.SessionReplacementResult, error)
- func (runtime *AgentSessionRuntime) Services() *AgentSessionServices
- func (runtime *AgentSessionRuntime) Session() *AgentSession
- func (runtime *AgentSessionRuntime) SetBeforeSessionInvalidate(callback func())
- func (runtime *AgentSessionRuntime) SetRebindSession(rebind func(*AgentSession) error)
- func (runtime *AgentSessionRuntime) SwitchSession(ctx context.Context, path string, options *AgentSessionRuntimeSwitchOptions) (extensions.SessionReplacementResult, error)
- type AgentSessionRuntimeDiagnostic
- type AgentSessionRuntimeForkResult
- type AgentSessionRuntimeSwitchOptions
- type AgentSessionServices
- type AgentSettledEvent
- type AutoRetryEndEvent
- type AutoRetryStartEvent
- type BuiltinSlashCommand
- type CLIModelResult
- type CompactionEndEvent
- type CompactionStartEvent
- type ConfiguredPackage
- type ContextFile
- type CreateAgentSessionFromServicesOptions
- type CreateAgentSessionRuntimeFactory
- type CreateAgentSessionServicesOptions
- type CustomMessage
- type DefaultResourceLoader
- func (loader *DefaultResourceLoader) ExtendResources(paths ResourceExtensionPaths)
- func (loader *DefaultResourceLoader) GetAgentsFiles() ResourceAgentsFilesResult
- func (loader *DefaultResourceLoader) GetAppendSystemPrompt() []string
- func (loader *DefaultResourceLoader) GetExtensions() *extensions.Registry
- func (loader *DefaultResourceLoader) GetPrompts() ResourcePromptsResult
- func (loader *DefaultResourceLoader) GetSkills() ResourceSkillsResult
- func (loader *DefaultResourceLoader) GetSystemPrompt() *string
- func (loader *DefaultResourceLoader) GetThemes() ResourceThemesResult
- func (loader *DefaultResourceLoader) Reload(ctx context.Context, reloadOptions *ResourceLoaderReloadOptions) error
- type DefaultResourceLoaderOptions
- type EntryAppendedEvent
- type GitSource
- type InputAction
- type InputResult
- type InteractiveModeSettings
- type InteractiveSettings
- type LoadPromptTemplatesOptions
- type LoadSkillsFromDirOptions
- type LoadSkillsOptions
- type LoadSkillsResult
- type MissingSessionCWDError
- type MissingSourceAction
- type ModelCycleResult
- type ModelDiagnostic
- type NavigateTreeOptions
- type NavigateTreeResult
- type PackageManager
- func (manager *PackageManager) AddSourceToSettings(source string, local bool) (bool, error)
- func (manager *PackageManager) CheckForAvailableUpdates() []PackageUpdate
- func (manager *PackageManager) GetInstalledPath(source, scope string) string
- func (manager *PackageManager) Install(source string, local bool) error
- func (manager *PackageManager) InstallAndPersist(source string, local bool) error
- func (manager *PackageManager) ListConfiguredPackages() []ConfiguredPackage
- func (manager *PackageManager) Remove(source string, local bool) error
- func (manager *PackageManager) RemoveAndPersist(source string, local bool) (bool, error)
- func (manager *PackageManager) RemoveSourceFromSettings(source string, local bool) (bool, error)
- func (manager *PackageManager) Resolve(onMissing func(source string) (MissingSourceAction, error)) (*ResolvedPaths, error)
- func (manager *PackageManager) ResolveExtensionSources(sources []string, local, temporary bool) (*ResolvedPaths, error)
- func (manager *PackageManager) SetProgressCallback(callback ProgressCallback)
- func (manager *PackageManager) Update(source string) error
- type PackageManagerOptions
- type PackageUpdate
- type ParsedModel
- type ParsedSkillBlock
- type PathMetadata
- type ProgressCallback
- type ProgressEvent
- type PromptOptions
- type PromptTemplate
- type QueueUpdateEvent
- type ResolveProjectTrustedOptions
- type ResolvedPaths
- type ResolvedResource
- type ResourceAgentsFilesResult
- type ResourceCollision
- type ResourceDiagnostic
- type ResourceExtensionPaths
- type ResourceLoader
- type ResourceLoaderReloadOptions
- type ResourceOptions
- type ResourcePath
- type ResourcePromptsResult
- type ResourceSkillsResult
- type ResourceThemesResult
- type Resources
- type ScopedModel
- type SendCustomMessageOptions
- type SendUserMessageOptions
- type SessionAgentEndEvent
- type SessionEventType
- type SessionImportFileNotFoundError
- type SessionInfoChangedEvent
- type SessionRuntime
- func (runtime *SessionRuntime) Abort()
- func (runtime *SessionRuntime) AbortBash()
- func (runtime *SessionRuntime) AbortBranchSummary()
- func (runtime *SessionRuntime) AbortCompaction()
- func (runtime *SessionRuntime) AbortRetry()
- func (runtime *SessionRuntime) Agent() *agent.Agent
- func (runtime *SessionRuntime) AutoCompactionEnabled() bool
- func (runtime *SessionRuntime) AutoRetryEnabled() bool
- func (runtime *SessionRuntime) AvailableModels() []ai.Model
- func (runtime *SessionRuntime) AvailableThinkingLevels() []ai.ModelThinkingLevel
- func (runtime *SessionRuntime) BindExtensionUI(ui extensions.UI, mode extensions.Mode)
- func (runtime *SessionRuntime) BindExtensions(ctx context.Context) error
- func (runtime *SessionRuntime) BindHostCommandActions(actions extensions.CommandActions)
- func (runtime *SessionRuntime) ClearQueue() QueueUpdateEvent
- func (runtime *SessionRuntime) Commands() []SlashCommandInfo
- func (runtime *SessionRuntime) Compact(ctx context.Context, customInstructions string) (*sessionstore.CompactionResult, error)
- func (runtime *SessionRuntime) Continue(ctx context.Context) error
- func (runtime *SessionRuntime) CycleModel(ctx context.Context) (*ModelCycleResult, error)
- func (runtime *SessionRuntime) CycleModelBackward(ctx context.Context) (*ModelCycleResult, error)
- func (runtime *SessionRuntime) CycleThinkingLevel() (*ai.ModelThinkingLevel, error)
- func (runtime *SessionRuntime) DequeueMessages() []string
- func (runtime *SessionRuntime) Dispose()
- func (runtime *SessionRuntime) ExecuteBash(ctx context.Context, command string, excludeFromContext *bool) (tools.BashResult, error)
- func (runtime *SessionRuntime) ExecuteUserBash(ctx context.Context, command string, excludeFromContext bool, ...) (extensions.BashResult, error)
- func (runtime *SessionRuntime) ExportHTML(outputPath string) (string, error)
- func (runtime *SessionRuntime) ExportJSONL(outputPath string) (string, error)
- func (runtime *SessionRuntime) ExtensionResources() extensions.DiscoveredResources
- func (runtime *SessionRuntime) ExtensionRunner() *extensions.Runner
- func (runtime *SessionRuntime) FollowUp(text string) error
- func (runtime *SessionRuntime) FollowUpImages(text string, images []*ai.ImageContent) error
- func (runtime *SessionRuntime) FollowUpMode() agent.QueueMode
- func (runtime *SessionRuntime) GetActiveToolNames() []string
- func (runtime *SessionRuntime) GetContextUsage() *harness.ContextUsage
- func (runtime *SessionRuntime) GetLastAssistantText() *string
- func (runtime *SessionRuntime) GetSessionStats() SessionStats
- func (runtime *SessionRuntime) GetToolDefinition(name string) *extensions.ToolDefinition
- func (runtime *SessionRuntime) GetUserMessagesForForking() []struct{ ... }
- func (runtime *SessionRuntime) InteractiveModeSettings() InteractiveModeSettings
- func (runtime *SessionRuntime) InteractiveSettings() InteractiveSettings
- func (runtime *SessionRuntime) IsCompacting() bool
- func (runtime *SessionRuntime) IsIdle() bool
- func (runtime *SessionRuntime) Manager() *sessionstore.SessionManager
- func (runtime *SessionRuntime) NavigateTree(ctx context.Context, targetID string, options NavigateTreeOptions) (NavigateTreeResult, error)
- func (runtime *SessionRuntime) PendingMessageCount() int
- func (runtime *SessionRuntime) PendingMessages() QueueUpdateEvent
- func (runtime *SessionRuntime) Prompt(ctx context.Context, input any, images ...*ai.ImageContent) error
- func (runtime *SessionRuntime) PromptAfterPreflight(ctx context.Context, input any, images ...*ai.ImageContent) error
- func (runtime *SessionRuntime) PromptPreflight(ctx context.Context) error
- func (runtime *SessionRuntime) PromptSync(ctx context.Context, text string) error
- func (runtime *SessionRuntime) PromptWithOptions(ctx context.Context, text string, options *PromptOptions) error
- func (runtime *SessionRuntime) ProviderAPIKey(ctx context.Context, provider ai.ProviderID) (string, error)
- func (runtime *SessionRuntime) QueueInteractive(ctx context.Context, text string, images []*ai.ImageContent, ...) error
- func (runtime *SessionRuntime) RefreshCurrentModelFromRegistry(registry extensions.ModelRegistry)
- func (runtime *SessionRuntime) RegisteredTool(name string) agent.AgentTool
- func (runtime *SessionRuntime) Reload(ctx context.Context) error
- func (runtime *SessionRuntime) ResourceLoader() ResourceLoader
- func (runtime *SessionRuntime) ScopedModels() []ScopedModel
- func (runtime *SessionRuntime) SendCustomMessage(ctx context.Context, message CustomMessage, options *SendCustomMessageOptions) error
- func (runtime *SessionRuntime) SendUserMessage(ctx context.Context, content ai.UserContent, options *SendUserMessageOptions) error
- func (runtime *SessionRuntime) SetActiveToolsByName(names []string) error
- func (runtime *SessionRuntime) SetAutoCompactionEnabled(enabled bool)
- func (runtime *SessionRuntime) SetAutoRetryEnabled(enabled bool)
- func (runtime *SessionRuntime) SetAutocompleteMaxVisible(visible int)
- func (runtime *SessionRuntime) SetBlockImages(blocked bool)
- func (runtime *SessionRuntime) SetClearOnShrink(enabled bool)
- func (runtime *SessionRuntime) SetDefaultProjectTrust(value string)
- func (runtime *SessionRuntime) SetDoubleEscapeAction(action string)
- func (runtime *SessionRuntime) SetEditorPaddingX(padding int)
- func (runtime *SessionRuntime) SetEnableSkillCommands(enabled bool)
- func (runtime *SessionRuntime) SetEnabledModels(models []string)
- func (runtime *SessionRuntime) SetFollowUpMode(mode agent.QueueMode)
- func (runtime *SessionRuntime) SetHTTPIdleTimeoutMS(timeoutMS int64)
- func (runtime *SessionRuntime) SetHideThinkingBlock(hidden bool)
- func (runtime *SessionRuntime) SetImageAutoResize(enabled bool)
- func (runtime *SessionRuntime) SetImageWidthCells(width int)
- func (runtime *SessionRuntime) SetModel(ctx context.Context, model ai.Model) error
- func (runtime *SessionRuntime) SetOutputPad(padding int)
- func (runtime *SessionRuntime) SetQuietStartup(enabled bool)
- func (runtime *SessionRuntime) SetScopedModels(models []ScopedModel)
- func (runtime *SessionRuntime) SetSessionName(name string) error
- func (runtime *SessionRuntime) SetShowCacheMissNotices(show bool)
- func (runtime *SessionRuntime) SetShowHardwareCursor(enabled bool)
- func (runtime *SessionRuntime) SetShowImages(show bool)
- func (runtime *SessionRuntime) SetShowTerminalProgress(enabled bool)
- func (runtime *SessionRuntime) SetSteeringMode(mode agent.QueueMode)
- func (runtime *SessionRuntime) SetTheme(name string) error
- func (runtime *SessionRuntime) SetThinkingLevel(level ai.ModelThinkingLevel) error
- func (runtime *SessionRuntime) SetTransport(transport ai.Transport)
- func (runtime *SessionRuntime) SetTreeFilterMode(value string)
- func (runtime *SessionRuntime) ShutdownExtensions(reason extensions.SessionShutdownReason, target *string)
- func (runtime *SessionRuntime) StartExtensions()
- func (runtime *SessionRuntime) State() agent.AgentState
- func (runtime *SessionRuntime) Steer(text string) error
- func (runtime *SessionRuntime) SteerImages(text string, images []*ai.ImageContent) error
- func (runtime *SessionRuntime) SteeringMode() agent.QueueMode
- func (runtime *SessionRuntime) String() string
- func (runtime *SessionRuntime) SubmitInteractive(ctx context.Context, text string, images []*ai.ImageContent, ...) error
- func (runtime *SessionRuntime) Subscribe(listener func(any)) func()
- func (runtime *SessionRuntime) SubscribeChan(bufferSize int) (<-chan any, func())
- func (runtime *SessionRuntime) SyncMessagesFromSession()
- func (runtime *SessionRuntime) WaitForIdle(ctx context.Context) error
- func (runtime *SessionRuntime) WarnAnthropicExtraUsage() bool
- type SessionRuntimeConfig
- type SessionStats
- type SessionTokenTotals
- type Skill
- type SlashCommandInfo
- type SlashCommandSource
- type SlashResolver
- type SourceInfo
- type SummarizationRetryAttemptStartEvent
- type SummarizationRetryFinishedEvent
- type SummarizationRetryScheduledEvent
- type SystemPromptOptions
- type ThinkingLevelChangedEvent
- type UsageCostBreakdownEntry
Constants ¶
const ( CompactionSummaryPrefix = "The conversation history before this point was compacted into the following summary:\n\n<summary>\n" CompactionSummarySuffix = "\n</summary>" BranchSummaryPrefix = "The following is a summary of a branch that this conversation came back from:\n\n<summary>\n" BranchSummarySuffix = "</summary>" )
Variables ¶
var BuiltinSlashCommands = []BuiltinSlashCommand{
{Name: "settings", Description: "Open settings menu"},
{Name: "model", Description: "Select model (opens selector UI)", ArgumentHint: "<provider/model>"},
{Name: "scoped-models", Description: "Enable/disable models for Ctrl+P cycling"},
{Name: "export", Description: "Export session (HTML default, or specify path: .html/.jsonl)"},
{Name: "import", Description: "Import and resume a session from a JSONL file"},
{Name: "share", Description: "Share session as a secret GitHub gist"},
{Name: "copy", Description: "Copy last agent message to clipboard"},
{Name: "name", Description: "Set session display name"},
{Name: "session", Description: "Show session info and stats"},
{Name: "changelog", Description: "Show changelog entries"},
{Name: "hotkeys", Description: "Show all keyboard shortcuts"},
{Name: "fork", Description: "Create a new fork from a previous user message"},
{Name: "clone", Description: "Duplicate the current session at the current position"},
{Name: "tree", Description: "Navigate session tree (switch branches)"},
{Name: "trust", Description: "Save project trust decision for future sessions"},
{Name: "login", Description: "Configure provider authentication", ArgumentHint: "<provider>"},
{Name: "logout", Description: "Remove provider authentication"},
{Name: "new", Description: "Start a new session"},
{Name: "compact", Description: "Manually compact the session context"},
{Name: "resume", Description: "Resume a different session"},
{Name: "reload", Description: "Reload keybindings, extensions, skills, prompts, themes, and context files"},
{Name: "quit", Description: "Quit pigo"},
}
var DefaultActiveToolNames = []string{"read", "bash", "edit", "write"}
DefaultActiveToolNames is the upstream default tool set.
Functions ¶
func AuthGuidanceDocPaths ¶
func AuthGuidanceDocPaths() (providersDoc, modelsDoc string)
AuthGuidanceDocPaths exposes the auth-guidance doc pointers to the CLI and TUI so every login/model hint resolves docs the same way (upstream getDocsPath consumers in auth-guidance.ts and interactive-mode.ts).
func BuildSystemPrompt ¶
func BuildSystemPrompt(options SystemPromptOptions) string
BuildSystemPrompt assembles the system prompt in upstream byte order.
func BuiltInToolPromptData ¶
BuiltInToolPromptData returns the prompt snippets and guidelines contributed by built-in tools, in active-tool order.
func ConvertToLLM ¶
func ConvertToLLM(_ context.Context, messages agent.AgentMessages) (ai.MessageList, error)
ConvertToLLM preserves coding-agent messages in runtime state and projects them to provider messages only at the agent-loop boundary.
func ConvertToLLMWithBlockImages ¶
func ConvertToLLMWithBlockImages(blockImages func() bool) agent.ConvertToLLMFunc
ConvertToLLMWithBlockImages projects coding-agent messages and dynamically applies the upstream images.blockImages setting at the provider boundary.
func DefaultAgentDir ¶
func DefaultAgentDir() string
DefaultAgentDir returns the upstream global resource directory.
func DefaultAvailableModel ¶
DefaultAvailableModel returns the provider's pinned upstream default only when that exact model is available after authentication.
func DefaultModelIDForProvider ¶
DefaultModelIDForProvider reports the upstream defaultModelPerProvider entry for a provider so the interactive login completion can name the missing default in its diagnostics (upstream interactive-mode.ts completeProviderAuthentication). It lives here only because this is the package-internal seam owned by the login work; model_resolver.go owns the table itself.
func ExpandPromptTemplate ¶
func ExpandPromptTemplate(text string, templates []PromptTemplate) string
ExpandPromptTemplate expands a matching slash template or returns text unchanged.
func ExpandSkillCommand ¶
ExpandSkillCommand reads a skill on invocation so edits are visible without resource reload.
func FormatChangelog ¶
FormatChangelog parses, oldest-first reverses, and tag-pins links exactly as the interactive upstream changelog command does.
func FormatNoModelsAvailableMessage ¶
func FormatNoModelsAvailableMessage() string
FormatNoModelsAvailableMessage exposes upstream formatNoModelsAvailableMessage (auth-guidance.ts:14-16) to CLI callers.
func FormatSkillInvocation ¶
FormatSkillInvocation formats an already-loaded harness skill.
func FormatSkillsForPrompt ¶
FormatSkillsForPrompt emits the Agent Skills progressive-disclosure XML block.
func GetExtensionTempFolder ¶
GetExtensionTempFolder creates the 0700 temp extension folder.
func IsUnknownModel ¶
IsUnknownModel reports the Agent sentinel used when no model is selected.
func LoadProjectContextFiles ¶
func LoadProjectContextFiles(cwd, agentDir string) ([]ContextFile, []ResourceDiagnostic)
LoadProjectContextFiles loads the global context file followed by one file per directory from the filesystem root through cwd.
func MarshalSessionEvent ¶
func OpenBrowser ¶
func OpenBrowser(target string)
OpenBrowser opens a URL or file in the platform browser/default handler (upstream utils/open-browser.ts openBrowser). The launch is non-blocking and best-effort: callers still present the target to the user, so launcher failures (for example a missing xdg-open) are swallowed rather than surfaced.
func ParseCommandArgs ¶
ParseCommandArgs tokenizes template arguments with upstream's deliberately small quote grammar.
func ResolveModelScope ¶
func ResolveModelScope(patterns []string, available []ai.Model) ([]ScopedModel, []ModelDiagnostic)
func ResolveProjectTrusted ¶
func ResolveProjectTrusted(ctx context.Context, options ResolveProjectTrustedOptions) (bool, error)
ResolveProjectTrusted decides project trust: CLI override, then a decisive project_trust extension, then the saved store, then defaultProjectTrust, then the interactive prompt (untrusted when no UI is available).
func SubstituteArgs ¶
SubstituteArgs replaces all placeholders in one pass, so inserted values are never re-expanded.
Types ¶
type AgentSession ¶
type AgentSession = SessionRuntime
AgentSession is the public embedding type. It wraps the internal SessionRuntime and exposes the full agent lifecycle: prompting, event subscription, model/thinking management, compaction, and tree navigation.
type AgentSessionOptions ¶
type AgentSessionOptions struct {
// CWD is the working directory for tool execution and resource discovery.
// Defaults to the SessionManager's CWD if set, else ".".
CWD string
// AgentDir is the global config directory (auth.json, models.json, skills,
// extensions). Defaults to ~/.pi/agent.
AgentDir string
// Model selects the initial model. When nil, NewAgentSession restores the
// session model, then tries the settings default and available models.
Model *ai.Model
// ThinkingLevel sets the initial thinking budget. Clamped to the model's
// supported range. Zero value defaults to "medium" for reasoning models
// or "off" otherwise.
ThinkingLevel ai.ModelThinkingLevel
// ScopedModels restricts model cycling (CycleModel) to this set.
ScopedModels []ScopedModel
// StreamFn provides the LLM streaming backend. Defaults to the built-in
// provider dispatcher when nil.
StreamFn agent.StreamFn
// GetAPIKey resolves API keys at request time. With the default StreamFn,
// a nil resolver is derived from ModelRegistry.
GetAPIKey agent.GetAPIKeyFunc
// GetRequestAuth resolves request-time auth (OAuth tokens, Copilot baseURL).
// When set, takes precedence over GetAPIKey for API key resolution; with
// the default StreamFn, a nil resolver is derived from ModelRegistry.
GetRequestAuth agent.GetRequestAuthFunc
// GetModelHeaders provides per-request headers (e.g. attribution).
GetModelHeaders agent.GetModelHeadersFunc
// AvailableModels returns all models the host considers available.
// Used by CycleModel when ScopedModels is empty.
AvailableModels func() []ai.Model
// ModelRegistry provides model resolution, auth checking, available-model
// discovery, and session model restoration. Created from AgentDir when nil.
ModelRegistry *config.ModelRegistry
// NoTools suppresses default tool construction:
// "all" — start with no tools at all
// "builtin" — disable default built-ins but keep extension/custom tools
NoTools string
// Tools is an allowlist of tool names. When provided, only listed tools
// are enabled. Applies to built-in, extension, and custom tools.
// When nil, the default set (read, bash, edit, write) is used unless
// NoTools changes that.
Tools []string
// ExcludeTools is a denylist of tool names. Applied after Tools.
ExcludeTools []string
// CustomTools registers additional tool definitions alongside built-ins.
CustomTools []extensions.ToolDefinition
// ToolOptions overrides per-tool construction options for built-in tools.
// Nil fields keep local defaults; settings-derived fields (AutoResizeImages,
// ShellPath, CommandPrefix) are still applied when unset on the override.
//
// The options — including the nested per-tool structs — are captured by
// the session and re-read whenever tools are rebuilt (also by
// extension-driven tool rebuilds); they must not be mutated after
// NewAgentSession returns.
ToolOptions *tools.ToolsOptions
// SessionManager controls session persistence. When nil a persistent
// session is created for CWD (matching upstream default).
SessionManager *sessionstore.SessionManager
// Settings controls compaction, retry, and other runtime behavior.
// When nil a default SettingsManager is created for CWD.
Settings *config.SettingsManager
// Resources supplies context files, skills, prompt templates, and the
// system prompt. ResourceLoader takes precedence when both are provided.
Resources *Resources
// ResourceLoader supplies reloadable resources and native extensions. When
// nil with no Resources override, DefaultResourceLoader is used.
ResourceLoader ResourceLoader
// ExtensionRegistry holds registered extensions. When non-nil and
// non-empty, extensions are bound to the session runtime.
ExtensionRegistry *extensions.Registry
// SessionStartEvent metadata emitted when extensions bind.
SessionStartEvent *extensions.SessionStartEvent
// DeferExtensionStart leaves session_start activation to
// [SessionRuntime.BindExtensions]. Runtime hosts use it so setup and host
// rebinding finish before extensions observe the new session.
DeferExtensionStart bool
// ProjectTrustContext is supplied by replacement hosts for the effective
// CWD so a custom runtime factory can resolve project trust before loading
// project-scoped services.
ProjectTrustContext extensions.ProjectTrustContext
// SlashResolver handles /command and /skill expansion. When nil it is
// derived from discovered skills and prompt templates.
SlashResolver *SlashResolver
}
AgentSessionOptions configures NewAgentSession. Fields mirror upstream createAgentSession options; zero values select sensible defaults.
type AgentSessionResult ¶
type AgentSessionResult struct {
// Session is the created agent session, ready for prompting.
Session *AgentSession
// ExtensionRegistry is the extension registry used (may be nil if no
// extensions were configured).
ExtensionRegistry *extensions.Registry
// ModelFallbackMessage is set when no model can be selected or when a
// continued session's saved model cannot be restored.
ModelFallbackMessage string
// Services contains the cwd-bound services used to build Session.
Services *AgentSessionServices
// Diagnostics contains non-fatal creation issues for the host to present.
Diagnostics []AgentSessionRuntimeDiagnostic
}
AgentSessionResult is returned by NewAgentSession.
func CreateAgentSessionFromServices ¶
func CreateAgentSessionFromServices(options CreateAgentSessionFromServicesOptions) (*AgentSessionResult, error)
func NewAgentSession ¶
func NewAgentSession(opts AgentSessionOptions) (*AgentSessionResult, error)
NewAgentSession creates a fully configured AgentSession. It mirrors upstream's createAgentSession: it creates the internal Agent, wires streaming, resolves model and thinking-level defaults from any existing session state, constructs built-in tools, and returns a ready-to-prompt session.
result, err := codingagent.NewAgentSession(codingagent.AgentSessionOptions{
StreamFn: provider.StreamSimple,
SessionManager: sessionMgr,
Model: &model,
})
if err != nil { ... }
defer result.Session.Dispose()
result.Session.Prompt(ctx, "Hello")
type AgentSessionRuntime ¶
type AgentSessionRuntime struct {
// contains filtered or unexported fields
}
AgentSessionRuntime owns the active AgentSession and replaces it for session lifecycle operations.
func NewAgentSessionRuntime ¶
func NewAgentSessionRuntime( ctx context.Context, options AgentSessionOptions, factory ...CreateAgentSessionRuntimeFactory, ) (*AgentSessionRuntime, error)
NewAgentSessionRuntime creates a replaceable session host. The optional factory is reused so embedders can recreate cwd-bound services.
func (*AgentSessionRuntime) CWD ¶
func (runtime *AgentSessionRuntime) CWD() string
CWD returns the effective working directory of the active session.
func (*AgentSessionRuntime) Diagnostics ¶
func (runtime *AgentSessionRuntime) Diagnostics() []AgentSessionRuntimeDiagnostic
Diagnostics returns a snapshot of the active runtime's non-fatal issues.
func (*AgentSessionRuntime) Dispose ¶
func (runtime *AgentSessionRuntime) Dispose(ctx context.Context)
Dispose emits the quit lifecycle event and tears down the active session.
func (*AgentSessionRuntime) Fork ¶
func (runtime *AgentSessionRuntime) Fork( ctx context.Context, entryID string, options *extensions.ForkOptions, ) (AgentSessionRuntimeForkResult, error)
Fork replaces the active session with a branch rooted before or at entryID.
func (*AgentSessionRuntime) ImportFromJSONL ¶
func (runtime *AgentSessionRuntime) ImportFromJSONL( ctx context.Context, inputPath string, cwdOverride string, ) (extensions.SessionReplacementResult, error)
ImportFromJSONL copies a session JSONL file into the active session directory and resumes it.
func (*AgentSessionRuntime) ModelFallbackMessage ¶
func (runtime *AgentSessionRuntime) ModelFallbackMessage() string
ModelFallbackMessage returns the current session's model-restoration warning.
func (*AgentSessionRuntime) NewSession ¶
func (runtime *AgentSessionRuntime) NewSession( ctx context.Context, options *extensions.NewSessionOptions, ) (extensions.SessionReplacementResult, error)
NewSession replaces the active session with a fresh persisted or in-memory session.
func (*AgentSessionRuntime) Services ¶
func (runtime *AgentSessionRuntime) Services() *AgentSessionServices
Services returns the active session's cwd-bound services.
func (*AgentSessionRuntime) Session ¶
func (runtime *AgentSessionRuntime) Session() *AgentSession
Session returns the active session.
func (*AgentSessionRuntime) SetBeforeSessionInvalidate ¶
func (runtime *AgentSessionRuntime) SetBeforeSessionInvalidate(callback func())
SetBeforeSessionInvalidate sets the synchronous callback run after session_shutdown and before the old extension context becomes stale.
func (*AgentSessionRuntime) SetRebindSession ¶
func (runtime *AgentSessionRuntime) SetRebindSession(rebind func(*AgentSession) error)
SetRebindSession sets the callback run after each replacement is installed.
func (*AgentSessionRuntime) SwitchSession ¶
func (runtime *AgentSessionRuntime) SwitchSession( ctx context.Context, path string, options *AgentSessionRuntimeSwitchOptions, ) (extensions.SessionReplacementResult, error)
SwitchSession resumes a JSONL session and replaces the active session.
type AgentSessionRuntimeDiagnostic ¶
AgentSessionRuntimeDiagnostic is a non-fatal issue collected while creating cwd-bound SDK services.
type AgentSessionRuntimeForkResult ¶
AgentSessionRuntimeForkResult describes a fork result.
type AgentSessionRuntimeSwitchOptions ¶
type AgentSessionRuntimeSwitchOptions struct {
CWDOverride string
WithSession func(context.Context, extensions.ReplacedSessionContext) error
ProjectTrustContextFactory func(string) extensions.ProjectTrustContext
}
AgentSessionRuntimeSwitchOptions configures AgentSessionRuntime.SwitchSession.
type AgentSessionServices ¶
type AgentSessionServices struct {
CWD string
AgentDir string
SettingsManager *config.SettingsManager
ModelRegistry *config.ModelRegistry
Resources *Resources
ResourceLoader ResourceLoader
ExtensionRegistry *extensions.Registry
Diagnostics []AgentSessionRuntimeDiagnostic
}
AgentSessionServices are the cwd-bound services used by one session instance. A replacement runtime exposes the newly resolved set after every switch, fork, or new-session operation.
func CreateAgentSessionServices ¶
func CreateAgentSessionServices(options CreateAgentSessionServicesOptions) (*AgentSessionServices, error)
type AgentSettledEvent ¶
type AgentSettledEvent struct{}
type AutoRetryEndEvent ¶
type AutoRetryStartEvent ¶
type BuiltinSlashCommand ¶
type CLIModelResult ¶
type CLIModelResult struct {
Model *ai.Model
ThinkingLevel *ai.ModelThinkingLevel
Warning, Error string
}
func ResolveCLIModel ¶
func ResolveCLIModel(provider, pattern string, cliThinking *ai.ModelThinkingLevel, available []ai.Model, authChecks ...func(string) bool) CLIModelResult
ResolveCLIModel implements provider/id inference, fuzzy matching, and custom-id fallback.
type CompactionEndEvent ¶
type CompactionEndEvent struct {
Reason string `json:"reason"`
Result *sessionstore.CompactionResult `json:"result,omitempty"`
Aborted bool `json:"aborted"`
WillRetry bool `json:"willRetry"`
ErrorMessage *string `json:"errorMessage,omitempty"`
}
type CompactionStartEvent ¶
type CompactionStartEvent struct {
Reason string `json:"reason"`
}
type ConfiguredPackage ¶
type ContextFile ¶
ContextFile is inserted verbatim into the project_context prompt block.
type CreateAgentSessionFromServicesOptions ¶
type CreateAgentSessionFromServicesOptions struct {
Services *AgentSessionServices
SessionManager *sessionstore.SessionManager
SessionStartEvent *extensions.SessionStartEvent
Model *ai.Model
ThinkingLevel ai.ModelThinkingLevel
ScopedModels []ScopedModel
Tools []string
ExcludeTools []string
NoTools string
CustomTools []extensions.ToolDefinition
ToolOptions *tools.ToolsOptions
}
type CreateAgentSessionRuntimeFactory ¶
type CreateAgentSessionRuntimeFactory func(context.Context, AgentSessionOptions) (*AgentSessionResult, error)
CreateAgentSessionRuntimeFactory recreates a session after new, resume, fork, and import operations. A nil factory uses NewAgentSession.
type CreateAgentSessionServicesOptions ¶
type CreateAgentSessionServicesOptions struct {
CWD string
AgentDir string
SettingsManager *config.SettingsManager
ModelRegistry *config.ModelRegistry
ResourceOptions *ResourceOptions
ResourceLoaderOptions *DefaultResourceLoaderOptions
ResourceLoaderReloadOptions *ResourceLoaderReloadOptions
ExtensionRegistry *extensions.Registry
ExtensionFlagValues map[string]any
}
type CustomMessage ¶
type CustomMessage = extensions.CustomMessage
type DefaultResourceLoader ¶
type DefaultResourceLoader struct {
// contains filtered or unexported fields
}
func NewDefaultResourceLoader ¶
func NewDefaultResourceLoader(options DefaultResourceLoaderOptions) (*DefaultResourceLoader, error)
func (*DefaultResourceLoader) ExtendResources ¶
func (loader *DefaultResourceLoader) ExtendResources(paths ResourceExtensionPaths)
func (*DefaultResourceLoader) GetAgentsFiles ¶
func (loader *DefaultResourceLoader) GetAgentsFiles() ResourceAgentsFilesResult
func (*DefaultResourceLoader) GetAppendSystemPrompt ¶
func (loader *DefaultResourceLoader) GetAppendSystemPrompt() []string
func (*DefaultResourceLoader) GetExtensions ¶
func (loader *DefaultResourceLoader) GetExtensions() *extensions.Registry
func (*DefaultResourceLoader) GetPrompts ¶
func (loader *DefaultResourceLoader) GetPrompts() ResourcePromptsResult
func (*DefaultResourceLoader) GetSkills ¶
func (loader *DefaultResourceLoader) GetSkills() ResourceSkillsResult
func (*DefaultResourceLoader) GetSystemPrompt ¶
func (loader *DefaultResourceLoader) GetSystemPrompt() *string
func (*DefaultResourceLoader) GetThemes ¶
func (loader *DefaultResourceLoader) GetThemes() ResourceThemesResult
func (*DefaultResourceLoader) Reload ¶
func (loader *DefaultResourceLoader) Reload(ctx context.Context, reloadOptions *ResourceLoaderReloadOptions) error
type DefaultResourceLoaderOptions ¶
type DefaultResourceLoaderOptions struct {
CWD string
AgentDir string
SettingsManager *config.SettingsManager
AdditionalSkillPaths []string
AdditionalPromptTemplatePaths []string
AdditionalThemePaths []string
PackageSkillPaths []string
PackagePromptTemplatePaths []string
PackageThemePaths []ResourcePath
ExtensionFactories []extensions.Factory
ExtensionRegistry *extensions.Registry
NoExtensions bool
NoSkills bool
NoPromptTemplates bool
NoThemes bool
NoContextFiles bool
SystemPrompt *string
AppendSystemPrompt []string
SkillsOverride func(ResourceSkillsResult) ResourceSkillsResult
PromptsOverride func(ResourcePromptsResult) ResourcePromptsResult
ThemesOverride func(ResourceThemesResult) ResourceThemesResult
AgentsFilesOverride func(ResourceAgentsFilesResult) ResourceAgentsFilesResult
SystemPromptOverride func(*string) *string
AppendSystemPromptOverride func([]string) []string
}
type EntryAppendedEvent ¶
type EntryAppendedEvent struct {
Entry sessionstore.SessionEntry `json:"entry"`
}
type GitSource ¶
type GitSource struct {
Repo string `json:"repo"`
Host string `json:"host"`
Path string `json:"path"`
Ref string `json:"ref,omitempty"`
Pinned bool `json:"pinned"`
}
GitSource is a parsed git package source.
func ParseGitURL ¶
ParseGitURL parses a git source.
Rules:
- With git: prefix, all historical shorthand forms are accepted.
- Without git: prefix, only explicit protocol URLs are accepted.
type InputAction ¶
type InputAction string
const ( InputPass InputAction = "pass" InputHandled InputAction = "handled" InputTransform InputAction = "transform" )
type InputResult ¶
type InputResult struct {
Action InputAction
Text string
}
type InteractiveModeSettings ¶
type InteractiveModeSettings struct {
InteractiveSettings
AgentDir string
ProjectTrusted bool
GlobalThemePaths []string
ProjectThemePaths []string
ThemeSetting string
ImageAutoResize bool
BlockImages bool
EnableSkillCommands bool
Transport ai.Transport
HTTPIdleTimeoutMS int64
OutputPad int
ExternalEditor string
TreeFilterMode string
DefaultProjectTrust string
ShowTerminalProgress bool
}
InteractiveModeSettings is the immutable startup/runtime configuration the TUI consumes in addition to the frequently read InteractiveSettings values.
type InteractiveSettings ¶
type InteractiveSettings struct {
QuietStartup bool
DoubleEscapeAction string
ClearOnShrink bool
HideThinkingBlock bool
ShowCacheMissNotices bool
ShowImages bool
ImageWidthCells int
ShowHardwareCursor bool
EditorPaddingX int
AutocompleteMaxVisible int
SteeringMode agent.QueueMode
FollowUpMode agent.QueueMode
}
InteractiveSettings is an immutable snapshot of the documented UI settings interactive mode reads (upstream docs/settings.md UI keys); the mutable SettingsManager itself is never exposed.
type LoadSkillsOptions ¶
type LoadSkillsResult ¶
type LoadSkillsResult struct {
Skills []Skill
Diagnostics []ResourceDiagnostic
}
func LoadSkills ¶
func LoadSkills(options LoadSkillsOptions) LoadSkillsResult
LoadSkills loads default and explicit locations, keeping the first name collision.
func LoadSkillsFromDir ¶
func LoadSkillsFromDir(options LoadSkillsFromDirOptions) LoadSkillsResult
LoadSkillsFromDir follows upstream's root-file and recursive SKILL.md discovery rules.
type MissingSessionCWDError ¶
MissingSessionCWDError reports a persisted session whose working directory no longer exists.
func (*MissingSessionCWDError) Error ¶
func (failure *MissingSessionCWDError) Error() string
type MissingSourceAction ¶
type MissingSourceAction string
MissingSourceAction answers the resolve-time "install missing?" prompt.
const ( MissingSourceInstall MissingSourceAction = "install" MissingSourceSkip MissingSourceAction = "skip" MissingSourceError MissingSourceAction = "error" )
type ModelCycleResult ¶
type ModelCycleResult struct {
Model ai.Model `json:"model"`
ThinkingLevel ai.ModelThinkingLevel `json:"thinkingLevel"`
IsScoped bool `json:"isScoped"`
}
type ModelDiagnostic ¶
type ModelDiagnostic struct {
Type, Message, Pattern string
}
type NavigateTreeOptions ¶
type NavigateTreeOptions struct {
}
type NavigateTreeResult ¶
type NavigateTreeResult struct {
}
type PackageManager ¶
type PackageManager struct {
// contains filtered or unexported fields
}
func NewPackageManager ¶
func NewPackageManager(options PackageManagerOptions) *PackageManager
func (*PackageManager) AddSourceToSettings ¶
func (manager *PackageManager) AddSourceToSettings(source string, local bool) (bool, error)
AddSourceToSettings adds or updates the package entry; reports change.
func (*PackageManager) CheckForAvailableUpdates ¶
func (manager *PackageManager) CheckForAvailableUpdates() []PackageUpdate
CheckForAvailableUpdates reports installed, unpinned packages with a newer version available.
func (*PackageManager) GetInstalledPath ¶
func (manager *PackageManager) GetInstalledPath(source, scope string) string
GetInstalledPath reports where the source is installed, or "".
func (*PackageManager) Install ¶
func (manager *PackageManager) Install(source string, local bool) error
Install installs without persisting to settings.
func (*PackageManager) InstallAndPersist ¶
func (manager *PackageManager) InstallAndPersist(source string, local bool) error
func (*PackageManager) ListConfiguredPackages ¶
func (manager *PackageManager) ListConfiguredPackages() []ConfiguredPackage
func (*PackageManager) Remove ¶
func (manager *PackageManager) Remove(source string, local bool) error
func (*PackageManager) RemoveAndPersist ¶
func (manager *PackageManager) RemoveAndPersist(source string, local bool) (bool, error)
func (*PackageManager) RemoveSourceFromSettings ¶
func (manager *PackageManager) RemoveSourceFromSettings(source string, local bool) (bool, error)
RemoveSourceFromSettings removes matching entries; reports change.
func (*PackageManager) Resolve ¶
func (manager *PackageManager) Resolve(onMissing func(source string) (MissingSourceAction, error)) (*ResolvedPaths, error)
Resolve resolves all configured packages, settings entries, and auto-discovered resources. onMissing (nil = install) answers what to do for configured-but-uninstalled sources.
func (*PackageManager) ResolveExtensionSources ¶
func (manager *PackageManager) ResolveExtensionSources(sources []string, local, temporary bool) (*ResolvedPaths, error)
ResolveExtensionSources resolves ad-hoc sources (the -e flag path).
func (*PackageManager) SetProgressCallback ¶
func (manager *PackageManager) SetProgressCallback(callback ProgressCallback)
func (*PackageManager) Update ¶
func (manager *PackageManager) Update(source string) error
Update updates all configured packages, or only those matching source.
type PackageManagerOptions ¶
type PackageManagerOptions struct {
CWD string
AgentDir string
Settings *config.SettingsManager
}
type PackageUpdate ¶
type ParsedModel ¶
type ParsedModel struct {
Model *ai.Model
ThinkingLevel *ai.ModelThinkingLevel
Warning string
}
func ParseModelPattern ¶
func ParseModelPattern(pattern string, available []ai.Model, allowInvalidFallback ...bool) ParsedModel
ParseModelPattern matches the complete id first so colons inside model ids remain literal.
type ParsedSkillBlock ¶
type ParsedSkillBlock = exporthtml.ParsedSkillBlock
ParsedSkillBlock is an upstream skill invocation embedded in a user message.
func ParseSkillBlock ¶
func ParseSkillBlock(text string) (ParsedSkillBlock, bool)
ParseSkillBlock parses the exact upstream skill-message envelope.
type PathMetadata ¶
type PathMetadata struct {
Source string `json:"source"`
Scope string `json:"scope"`
Origin string `json:"origin"`
BaseDir string `json:"baseDir,omitempty"`
}
PathMetadata mirrors upstream's resolved-resource metadata shape.
type ProgressCallback ¶
type ProgressCallback func(ProgressEvent)
type ProgressEvent ¶
type PromptOptions ¶
type PromptOptions struct {
ExpandPromptTemplates *bool
Images []*ai.ImageContent
StreamingBehavior extensions.DeliveryMode
Source extensions.InputSource
PreflightResult func(bool)
}
type PromptTemplate ¶
type PromptTemplate struct {
Name string
Description string
ArgumentHint string
Content string
SourceInfo SourceInfo
FilePath string
}
PromptTemplate is a file-backed slash command expanded before a prompt is sent.
func LoadPromptTemplates ¶
func LoadPromptTemplates(options LoadPromptTemplatesOptions) []PromptTemplate
LoadPromptTemplates discovers non-recursive markdown templates from default and explicit paths.
type QueueUpdateEvent ¶
type ResolveProjectTrustedOptions ¶
type ResolveProjectTrustedOptions struct {
CWD string
TrustStore *config.ProjectTrustStore
TrustOverride *bool
// "ask" (default), "always", or "never".
DefaultProjectTrust string
// Optional extension runner whose project_trust handlers may decide.
Runner *extensions.Runner
TrustContext extensions.Context
HasUI bool
// SelectOption shows the trust prompt and returns the chosen label; the
// second result is false when the user dismissed the prompt.
SelectOption func(title string, options []string) (string, bool)
OnExtensionError func(message string)
}
type ResolvedPaths ¶
type ResolvedPaths struct {
Extensions []ResolvedResource `json:"extensions"`
Skills []ResolvedResource `json:"skills"`
Prompts []ResolvedResource `json:"prompts"`
Themes []ResolvedResource `json:"themes"`
}
type ResolvedResource ¶
type ResolvedResource struct {
Path string `json:"path"`
Enabled bool `json:"enabled"`
Metadata PathMetadata `json:"metadata"`
}
type ResourceAgentsFilesResult ¶
type ResourceAgentsFilesResult struct {
AgentsFiles []ContextFile
}
type ResourceCollision ¶
type ResourceDiagnostic ¶
type ResourceDiagnostic struct {
Type string
Message string
Path string
Collision *ResourceCollision
}
type ResourceExtensionPaths ¶
type ResourceExtensionPaths struct {
SkillPaths []ResourcePath
PromptPaths []ResourcePath
ThemePaths []ResourcePath
}
type ResourceLoader ¶
type ResourceLoader interface {
GetExtensions() *extensions.Registry
GetSkills() ResourceSkillsResult
GetPrompts() ResourcePromptsResult
GetThemes() ResourceThemesResult
GetAgentsFiles() ResourceAgentsFilesResult
GetSystemPrompt() *string
GetAppendSystemPrompt() []string
ExtendResources(ResourceExtensionPaths)
Reload(context.Context, *ResourceLoaderReloadOptions) error
}
ResourceLoader is the replaceable SDK resource seam used by AgentSession. Its method set mirrors upstream's ResourceLoader while keeping cancellation explicit for reloads.
type ResourceOptions ¶
type ResourceOptions struct {
CWD string
AgentDir string
ProjectTrusted *bool
NoContextFiles bool
NoSkills bool
NoPromptTemplates bool
SystemPrompt *string
// Nil means discover APPEND_SYSTEM.md; a non-nil empty slice disables discovery.
AppendSystemPrompt []string
SkillPaths []string
PromptTemplatePaths []string
GlobalSkillPaths []string
ProjectSkillPaths []string
GlobalPromptTemplatePaths []string
ProjectPromptTemplatePaths []string
PackageSkillPaths []string
PackagePromptTemplatePaths []string
SkillPathMetadata map[string]PathMetadata
PromptPathMetadata map[string]PathMetadata
}
type ResourcePath ¶
type ResourcePath struct {
Path string
Metadata PathMetadata
}
type ResourcePromptsResult ¶
type ResourcePromptsResult struct {
Prompts []PromptTemplate
Diagnostics []ResourceDiagnostic
}
type ResourceSkillsResult ¶
type ResourceSkillsResult struct {
Skills []Skill
Diagnostics []ResourceDiagnostic
}
type ResourceThemesResult ¶
type ResourceThemesResult struct {
Themes []*modetheme.Theme
Diagnostics []ResourceDiagnostic
}
type Resources ¶
type Resources struct {
ContextFiles []ContextFile
SystemPrompt *string
AppendSystemPrompt []string
Skills []Skill
PromptTemplates []PromptTemplate
Diagnostics []ResourceDiagnostic
// contains filtered or unexported fields
}
func LoadResources ¶
func LoadResources(options ResourceOptions) Resources
LoadResources discovers context and prompt files, then applies CLI overrides.
func (Resources) JoinedAppendSystemPrompt ¶
JoinedAppendSystemPrompt applies the separator used before prompt assembly.
type ScopedModel ¶
type ScopedModel struct {
Model ai.Model
ThinkingLevel *ai.ModelThinkingLevel
}
type SendCustomMessageOptions ¶
type SendCustomMessageOptions = extensions.SendMessageOptions
type SendUserMessageOptions ¶
type SendUserMessageOptions = extensions.SendUserMessageOptions
type SessionAgentEndEvent ¶
type SessionAgentEndEvent struct {
Messages agent.AgentMessages `json:"messages"`
WillRetry bool `json:"willRetry"`
}
type SessionEventType ¶
type SessionEventType string
const ( EventAgentSettled SessionEventType = "agent_settled" EventQueueUpdate SessionEventType = "queue_update" EventCompactionStart SessionEventType = "compaction_start" EventCompactionEnd SessionEventType = "compaction_end" EventAutoRetryStart SessionEventType = "auto_retry_start" EventAutoRetryEnd SessionEventType = "auto_retry_end" EventSummarizationRetryScheduled SessionEventType = "summarization_retry_scheduled" EventSummarizationRetryAttemptStart SessionEventType = "summarization_retry_attempt_start" EventSummarizationRetryFinished SessionEventType = "summarization_retry_finished" EventEntryAppended SessionEventType = "entry_appended" EventSessionInfo SessionEventType = "session_info_changed" EventThinkingLevel SessionEventType = "thinking_level_changed" )
type SessionImportFileNotFoundError ¶
type SessionImportFileNotFoundError struct {
FilePath string
}
SessionImportFileNotFoundError reports a missing JSONL import source.
func (*SessionImportFileNotFoundError) Error ¶
func (failure *SessionImportFileNotFoundError) Error() string
type SessionInfoChangedEvent ¶
type SessionInfoChangedEvent struct {
Name *string `json:"name,omitempty"`
}
type SessionRuntime ¶
type SessionRuntime struct {
// contains filtered or unexported fields
}
func NewSessionRuntime ¶
func NewSessionRuntime(runtimeConfig SessionRuntimeConfig) (*SessionRuntime, error)
func (*SessionRuntime) Abort ¶
func (runtime *SessionRuntime) Abort()
func (*SessionRuntime) AbortBash ¶
func (runtime *SessionRuntime) AbortBash()
func (*SessionRuntime) AbortBranchSummary ¶
func (runtime *SessionRuntime) AbortBranchSummary()
func (*SessionRuntime) AbortCompaction ¶
func (runtime *SessionRuntime) AbortCompaction()
func (*SessionRuntime) AbortRetry ¶
func (runtime *SessionRuntime) AbortRetry()
func (*SessionRuntime) Agent ¶
func (runtime *SessionRuntime) Agent() *agent.Agent
func (*SessionRuntime) AutoCompactionEnabled ¶
func (runtime *SessionRuntime) AutoCompactionEnabled() bool
func (*SessionRuntime) AutoRetryEnabled ¶
func (runtime *SessionRuntime) AutoRetryEnabled() bool
func (*SessionRuntime) AvailableModels ¶
func (runtime *SessionRuntime) AvailableModels() []ai.Model
func (*SessionRuntime) AvailableThinkingLevels ¶
func (runtime *SessionRuntime) AvailableThinkingLevels() []ai.ModelThinkingLevel
func (*SessionRuntime) BindExtensionUI ¶
func (runtime *SessionRuntime) BindExtensionUI(ui extensions.UI, mode extensions.Mode)
BindExtensionUI installs the extension UI seam on the active runner and in the stored runner configuration, so /reload rebuilds keep it. Upstream rpc-mode rebindSession passes its uiContext into bindExtensions on every rebind (rpc-mode.ts:311-320); this is the equivalent seam for Go hosts.
func (*SessionRuntime) BindExtensions ¶
func (runtime *SessionRuntime) BindExtensions(ctx context.Context) error
BindExtensions activates the session's extension instance and emits its configured session_start event once.
func (*SessionRuntime) BindHostCommandActions ¶
func (runtime *SessionRuntime) BindHostCommandActions(actions extensions.CommandActions)
func (*SessionRuntime) ClearQueue ¶
func (runtime *SessionRuntime) ClearQueue() QueueUpdateEvent
func (*SessionRuntime) Commands ¶
func (runtime *SessionRuntime) Commands() []SlashCommandInfo
func (*SessionRuntime) Compact ¶
func (runtime *SessionRuntime) Compact(ctx context.Context, customInstructions string) (*sessionstore.CompactionResult, error)
func (*SessionRuntime) Continue ¶
func (runtime *SessionRuntime) Continue(ctx context.Context) error
func (*SessionRuntime) CycleModel ¶
func (runtime *SessionRuntime) CycleModel(ctx context.Context) (*ModelCycleResult, error)
func (*SessionRuntime) CycleModelBackward ¶
func (runtime *SessionRuntime) CycleModelBackward(ctx context.Context) (*ModelCycleResult, error)
CycleModelBackward is upstream cycleModel("backward"): same scope selection, auth filtering, and thinking-level handling as CycleModel, stepping in reverse.
func (*SessionRuntime) CycleThinkingLevel ¶
func (runtime *SessionRuntime) CycleThinkingLevel() (*ai.ModelThinkingLevel, error)
func (*SessionRuntime) DequeueMessages ¶
func (runtime *SessionRuntime) DequeueMessages() []string
func (*SessionRuntime) Dispose ¶
func (runtime *SessionRuntime) Dispose()
func (*SessionRuntime) ExecuteBash ¶
func (runtime *SessionRuntime) ExecuteBash(ctx context.Context, command string, excludeFromContext *bool) (tools.BashResult, error)
func (*SessionRuntime) ExecuteUserBash ¶
func (runtime *SessionRuntime) ExecuteUserBash( ctx context.Context, command string, excludeFromContext bool, onChunk func(string), ) (extensions.BashResult, error)
func (*SessionRuntime) ExportHTML ¶
func (runtime *SessionRuntime) ExportHTML(outputPath string) (string, error)
func (*SessionRuntime) ExportJSONL ¶
func (runtime *SessionRuntime) ExportJSONL(outputPath string) (string, error)
ExportJSONL writes the current root-to-leaf branch as a standalone upstream session file, re-chaining parentId values into a linear sequence.
func (*SessionRuntime) ExtensionResources ¶
func (runtime *SessionRuntime) ExtensionResources() extensions.DiscoveredResources
func (*SessionRuntime) ExtensionRunner ¶
func (runtime *SessionRuntime) ExtensionRunner() *extensions.Runner
func (*SessionRuntime) FollowUp ¶
func (runtime *SessionRuntime) FollowUp(text string) error
func (*SessionRuntime) FollowUpImages ¶
func (runtime *SessionRuntime) FollowUpImages(text string, images []*ai.ImageContent) error
func (*SessionRuntime) FollowUpMode ¶
func (runtime *SessionRuntime) FollowUpMode() agent.QueueMode
func (*SessionRuntime) GetActiveToolNames ¶
func (runtime *SessionRuntime) GetActiveToolNames() []string
func (*SessionRuntime) GetContextUsage ¶
func (runtime *SessionRuntime) GetContextUsage() *harness.ContextUsage
func (*SessionRuntime) GetLastAssistantText ¶
func (runtime *SessionRuntime) GetLastAssistantText() *string
func (*SessionRuntime) GetSessionStats ¶
func (runtime *SessionRuntime) GetSessionStats() SessionStats
func (*SessionRuntime) GetToolDefinition ¶
func (runtime *SessionRuntime) GetToolDefinition(name string) *extensions.ToolDefinition
GetToolDefinition mirrors upstream AgentSession.getToolDefinition for extension tools: the registered ToolDefinition (including renderCall and renderResult) for name, or nil for built-in, unknown, or disallowed tools.
func (*SessionRuntime) GetUserMessagesForForking ¶
func (runtime *SessionRuntime) GetUserMessagesForForking() []struct { EntryID string `json:"entryId"` Text string `json:"text"` }
func (*SessionRuntime) InteractiveModeSettings ¶
func (runtime *SessionRuntime) InteractiveModeSettings() InteractiveModeSettings
func (*SessionRuntime) InteractiveSettings ¶
func (runtime *SessionRuntime) InteractiveSettings() InteractiveSettings
func (*SessionRuntime) IsCompacting ¶
func (runtime *SessionRuntime) IsCompacting() bool
func (*SessionRuntime) IsIdle ¶
func (runtime *SessionRuntime) IsIdle() bool
func (*SessionRuntime) Manager ¶
func (runtime *SessionRuntime) Manager() *sessionstore.SessionManager
func (*SessionRuntime) NavigateTree ¶
func (runtime *SessionRuntime) NavigateTree(ctx context.Context, targetID string, options NavigateTreeOptions) (NavigateTreeResult, error)
func (*SessionRuntime) PendingMessageCount ¶
func (runtime *SessionRuntime) PendingMessageCount() int
func (*SessionRuntime) PendingMessages ¶
func (runtime *SessionRuntime) PendingMessages() QueueUpdateEvent
PendingMessages returns the queued steering and follow-up texts in queue order as copied slices — the pull-based counterpart of QueueUpdateEvent, so the TUI can render queue contents without racing delivery removal.
func (*SessionRuntime) Prompt ¶
func (runtime *SessionRuntime) Prompt(ctx context.Context, input any, images ...*ai.ImageContent) error
func (*SessionRuntime) PromptAfterPreflight ¶
func (runtime *SessionRuntime) PromptAfterPreflight(ctx context.Context, input any, images ...*ai.ImageContent) error
func (*SessionRuntime) PromptPreflight ¶
func (runtime *SessionRuntime) PromptPreflight(ctx context.Context) error
func (*SessionRuntime) PromptSync ¶
func (runtime *SessionRuntime) PromptSync(ctx context.Context, text string) error
PromptSync sends a prompt and blocks until the agent settles. It is a convenience wrapper combining Prompt + WaitForIdle.
func (*SessionRuntime) PromptWithOptions ¶
func (runtime *SessionRuntime) PromptWithOptions(ctx context.Context, text string, options *PromptOptions) error
func (*SessionRuntime) ProviderAPIKey ¶
func (runtime *SessionRuntime) ProviderAPIKey(ctx context.Context, provider ai.ProviderID) (string, error)
ProviderAPIKey resolves the API key the runtime would send for provider, the seam behind the TUI's Anthropic subscription-auth warning (upstream modelRuntime.getAuth(...)?.auth.apiKey in maybeWarnAboutAnthropicSubscriptionAuth). It lives here with the other login-flow seams owned by this work.
func (*SessionRuntime) QueueInteractive ¶
func (runtime *SessionRuntime) QueueInteractive(ctx context.Context, text string, images []*ai.ImageContent, delivery extensions.DeliveryMode) error
QueueInteractive performs extension command/input handling and then queues the resolved message without consulting idle state. Interactive mode uses it after reserving an active prompt slot, closing the rapid-submit race before Agent.Prompt has installed its active run.
func (*SessionRuntime) RefreshCurrentModelFromRegistry ¶
func (runtime *SessionRuntime) RefreshCurrentModelFromRegistry(registry extensions.ModelRegistry)
RefreshCurrentModelFromRegistry applies provider-dependent model projection changes after an in-place auth refresh without recording a model switch.
func (*SessionRuntime) RegisteredTool ¶
func (runtime *SessionRuntime) RegisteredTool(name string) agent.AgentTool
RegisteredTool returns the configured agent.AgentTool for name — built-in or extension-wrapped, active or not. Renderers type-assert built-ins for their render seams (tools.PlainTextRenderer) instead of duplicating definitions.
func (*SessionRuntime) Reload ¶
func (runtime *SessionRuntime) Reload(ctx context.Context) error
Reload rebuilds the session's native extension instance from its registered factories, then emits the reload lifecycle on the fresh context.
func (*SessionRuntime) ResourceLoader ¶
func (runtime *SessionRuntime) ResourceLoader() ResourceLoader
ResourceLoader returns the resource instance that owns this session's skills, prompts, and theme objects.
func (*SessionRuntime) ScopedModels ¶
func (runtime *SessionRuntime) ScopedModels() []ScopedModel
func (*SessionRuntime) SendCustomMessage ¶
func (runtime *SessionRuntime) SendCustomMessage(ctx context.Context, message CustomMessage, options *SendCustomMessageOptions) error
func (*SessionRuntime) SendUserMessage ¶
func (runtime *SessionRuntime) SendUserMessage(ctx context.Context, content ai.UserContent, options *SendUserMessageOptions) error
func (*SessionRuntime) SetActiveToolsByName ¶
func (runtime *SessionRuntime) SetActiveToolsByName(names []string) error
func (*SessionRuntime) SetAutoCompactionEnabled ¶
func (runtime *SessionRuntime) SetAutoCompactionEnabled(enabled bool)
func (*SessionRuntime) SetAutoRetryEnabled ¶
func (runtime *SessionRuntime) SetAutoRetryEnabled(enabled bool)
func (*SessionRuntime) SetAutocompleteMaxVisible ¶
func (runtime *SessionRuntime) SetAutocompleteMaxVisible(visible int)
func (*SessionRuntime) SetBlockImages ¶
func (runtime *SessionRuntime) SetBlockImages(blocked bool)
func (*SessionRuntime) SetClearOnShrink ¶
func (runtime *SessionRuntime) SetClearOnShrink(enabled bool)
func (*SessionRuntime) SetDefaultProjectTrust ¶
func (runtime *SessionRuntime) SetDefaultProjectTrust(value string)
func (*SessionRuntime) SetDoubleEscapeAction ¶
func (runtime *SessionRuntime) SetDoubleEscapeAction(action string)
func (*SessionRuntime) SetEditorPaddingX ¶
func (runtime *SessionRuntime) SetEditorPaddingX(padding int)
func (*SessionRuntime) SetEnableSkillCommands ¶
func (runtime *SessionRuntime) SetEnableSkillCommands(enabled bool)
func (*SessionRuntime) SetEnabledModels ¶
func (runtime *SessionRuntime) SetEnabledModels(models []string)
func (*SessionRuntime) SetFollowUpMode ¶
func (runtime *SessionRuntime) SetFollowUpMode(mode agent.QueueMode)
func (*SessionRuntime) SetHTTPIdleTimeoutMS ¶
func (runtime *SessionRuntime) SetHTTPIdleTimeoutMS(timeoutMS int64)
func (*SessionRuntime) SetHideThinkingBlock ¶
func (runtime *SessionRuntime) SetHideThinkingBlock(hidden bool)
func (*SessionRuntime) SetImageAutoResize ¶
func (runtime *SessionRuntime) SetImageAutoResize(enabled bool)
func (*SessionRuntime) SetImageWidthCells ¶
func (runtime *SessionRuntime) SetImageWidthCells(width int)
func (*SessionRuntime) SetOutputPad ¶
func (runtime *SessionRuntime) SetOutputPad(padding int)
func (*SessionRuntime) SetQuietStartup ¶
func (runtime *SessionRuntime) SetQuietStartup(enabled bool)
func (*SessionRuntime) SetScopedModels ¶
func (runtime *SessionRuntime) SetScopedModels(models []ScopedModel)
func (*SessionRuntime) SetSessionName ¶
func (runtime *SessionRuntime) SetSessionName(name string) error
func (*SessionRuntime) SetShowCacheMissNotices ¶
func (runtime *SessionRuntime) SetShowCacheMissNotices(show bool)
func (*SessionRuntime) SetShowHardwareCursor ¶
func (runtime *SessionRuntime) SetShowHardwareCursor(enabled bool)
func (*SessionRuntime) SetShowImages ¶
func (runtime *SessionRuntime) SetShowImages(show bool)
func (*SessionRuntime) SetShowTerminalProgress ¶
func (runtime *SessionRuntime) SetShowTerminalProgress(enabled bool)
func (*SessionRuntime) SetSteeringMode ¶
func (runtime *SessionRuntime) SetSteeringMode(mode agent.QueueMode)
func (*SessionRuntime) SetTheme ¶
func (runtime *SessionRuntime) SetTheme(name string) error
func (*SessionRuntime) SetThinkingLevel ¶
func (runtime *SessionRuntime) SetThinkingLevel(level ai.ModelThinkingLevel) error
func (*SessionRuntime) SetTransport ¶
func (runtime *SessionRuntime) SetTransport(transport ai.Transport)
func (*SessionRuntime) SetTreeFilterMode ¶
func (runtime *SessionRuntime) SetTreeFilterMode(value string)
func (*SessionRuntime) ShutdownExtensions ¶
func (runtime *SessionRuntime) ShutdownExtensions(reason extensions.SessionShutdownReason, target *string)
func (*SessionRuntime) StartExtensions ¶
func (runtime *SessionRuntime) StartExtensions()
StartExtensions activates a deferred session after the TUI has attached its UI implementation and event subscription.
func (*SessionRuntime) State ¶
func (runtime *SessionRuntime) State() agent.AgentState
func (*SessionRuntime) Steer ¶
func (runtime *SessionRuntime) Steer(text string) error
func (*SessionRuntime) SteerImages ¶
func (runtime *SessionRuntime) SteerImages(text string, images []*ai.ImageContent) error
func (*SessionRuntime) SteeringMode ¶
func (runtime *SessionRuntime) SteeringMode() agent.QueueMode
func (*SessionRuntime) String ¶
func (runtime *SessionRuntime) String() string
func (*SessionRuntime) SubmitInteractive ¶
func (runtime *SessionRuntime) SubmitInteractive(ctx context.Context, text string, images []*ai.ImageContent, delivery extensions.DeliveryMode) error
SubmitInteractive matches the interactive-mode delivery contract: an idle submission starts a turn, while a submission during streaming is queued as steer or follow-up without waiting for the active turn.
func (*SessionRuntime) Subscribe ¶
func (runtime *SessionRuntime) Subscribe(listener func(any)) func()
func (*SessionRuntime) SubscribeChan ¶
func (runtime *SessionRuntime) SubscribeChan(bufferSize int) (<-chan any, func())
SubscribeChan returns a buffered channel of session events and a cancel function. Events are the same types delivered to [AgentSession.Subscribe] callbacks: agent.AgentEvent variants and session-level event structs (AgentSettledEvent, QueueUpdateEvent, etc.).
Delivery is ordered and lossless while the subscription is active. The channel is closed promptly when cancel is called; events still queued at cancellation are discarded so cancellation never waits for a consumer.
func (*SessionRuntime) SyncMessagesFromSession ¶
func (runtime *SessionRuntime) SyncMessagesFromSession()
SyncMessagesFromSession reloads agent messages after a host-side setup callback mutates a replacement session.
func (*SessionRuntime) WaitForIdle ¶
func (runtime *SessionRuntime) WaitForIdle(ctx context.Context) error
func (*SessionRuntime) WarnAnthropicExtraUsage ¶
func (runtime *SessionRuntime) WarnAnthropicExtraUsage() bool
WarnAnthropicExtraUsage reads the warnings.anthropicExtraUsage settings gate for the Anthropic subscription-auth warning (upstream settingsManager.getWarnings().anthropicExtraUsage; default true).
type SessionRuntimeConfig ¶
type SessionRuntimeConfig struct {
Agent *agent.Agent
SessionManager *sessionstore.SessionManager
Settings *config.SettingsManager
StreamFn agent.StreamFn
GetAPIKey agent.GetAPIKeyFunc
GetRequestAuth agent.GetRequestAuthFunc
GetModelHeaders agent.GetModelHeadersFunc
AvailableModels func() []ai.Model
ScopedModels []ScopedModel
Complete harness.CompleteFunc
Sleep func(context.Context, time.Duration) error
Clock func() int64
SlashResolver *SlashResolver
ExtensionRegistry *extensions.Registry
ExtensionMode extensions.Mode
ExtensionUI extensions.UI
ExtensionErrorHandler func(extensions.ExtensionError)
ModelRegistry extensions.ModelRegistry
RegisterProvider func(extensions.Provider) error
RegisterProviderConfig func(string, extensions.ProviderConfig) error
UnregisterProvider func(string) error
BaseTools []agent.AgentTool
InitialActiveToolNames []string
AllowedToolNames *[]string
ExcludedToolNames []string
RebuildBaseTools func() ([]agent.AgentTool, error)
SystemPromptOptions *SystemPromptOptions
ResourceLoader ResourceLoader
SessionStartEvent *extensions.SessionStartEvent
DeferExtensionStart bool
SessionStart *extensions.SessionStartEvent
DeferSessionStart bool
}
type SessionStats ¶
type SessionStats struct {
SessionFile string `json:"sessionFile,omitempty"`
SessionID string `json:"sessionId"`
UserMessages int `json:"userMessages"`
AssistantMessages int `json:"assistantMessages"`
ToolCalls int `json:"toolCalls"`
ToolResults int `json:"toolResults"`
TotalMessages int `json:"totalMessages"`
Tokens SessionTokenTotals `json:"tokens"`
Cost float64 `json:"cost"`
ContextUsage *harness.ContextUsage `json:"contextUsage,omitempty"`
}
type SessionTokenTotals ¶
type Skill ¶
type Skill struct {
Name string
Description string
Content string
FilePath string
BaseDir string
AllowedTools string
SourceInfo SourceInfo
DisableModelInvocation bool
}
Skill is the progressively-disclosed metadata for one Agent Skills file.
type SlashCommandInfo ¶
type SlashCommandInfo struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Source SlashCommandSource `json:"source"`
SourceInfo SourceInfo `json:"sourceInfo"`
}
type SlashCommandSource ¶
type SlashCommandSource string
const ( SlashCommandExtension SlashCommandSource = "extension" SlashCommandPrompt SlashCommandSource = "prompt" SlashCommandSkill SlashCommandSource = "skill" )
type SlashResolver ¶
type SlashResolver struct {
Skills []Skill
PromptTemplates []PromptTemplate
ExtensionCommands []SlashCommandInfo
ExecuteExtension func(name, args string) (bool, error)
InterceptInput func(text string) (InputResult, error)
OnError func(error)
}
SlashResolver preserves the extension, input, skill, then template resolution order.
func (*SlashResolver) Commands ¶
func (resolver *SlashResolver) Commands(_ bool) []SlashCommandInfo
Commands returns the core/RPC command-list order: extension, prompt, then skill. enableSkillCommands is an interactive autocomplete setting and does not hide commands from the session API.
func (*SlashResolver) Expand ¶
func (resolver *SlashResolver) Expand(text string) string
Expand applies skill expansion before prompt-template expansion.
func (*SlashResolver) ExpandQueued ¶
func (resolver *SlashResolver) ExpandQueued(text string) (string, error)
ExpandQueued rejects extension commands because their handlers must run synchronously through Prompt.
func (*SlashResolver) ResolvePrompt ¶
func (resolver *SlashResolver) ResolvePrompt(text string) (string, bool)
ResolvePrompt applies every prompt-stage resolver and reports whether an extension consumed input.
type SourceInfo ¶
type SourceInfo struct {
Path string `json:"path"`
Source string `json:"source"`
Scope string `json:"scope"`
Origin string `json:"origin"`
BaseDir string `json:"baseDir,omitempty"`
}
SourceInfo identifies where a discovered slash-command resource came from.
type SummarizationRetryAttemptStartEvent ¶ added in v0.1.2
type SummarizationRetryFinishedEvent ¶ added in v0.1.2
type SummarizationRetryFinishedEvent struct{}
type SummarizationRetryScheduledEvent ¶ added in v0.1.2
type SystemPromptOptions ¶
type SystemPromptOptions struct {
CustomPrompt *string
SelectedTools []string
ToolSnippets map[string]string
PromptGuidelines []string
AppendSystemPrompt *string
CWD string
ContextFiles []ContextFile
Skills []Skill
PackageDir string
}
SystemPromptOptions contains the already-resolved inputs to the upstream prompt builder. Nil SelectedTools means the upstream default tool set; a non-nil empty slice means no tools.
type ThinkingLevelChangedEvent ¶
type ThinkingLevelChangedEvent struct {
Level ai.ModelThinkingLevel `json:"level"`
}
type UsageCostBreakdownEntry ¶
type UsageCostBreakdownEntry struct {
Key string `json:"key"`
Cost float64 `json:"cost"`
Tokens int64 `json:"tokens"`
}
func GetUsageCostBreakdown ¶
func GetUsageCostBreakdown(entries []sessionstore.SessionEntry) []UsageCostBreakdownEntry
GetUsageCostBreakdown groups model-attributed usage and auxiliary tool/summary usage.
Source Files
¶
- agent_session_runtime.go
- agent_session_services.go
- changelog.go
- default_stream.go
- doc.go
- extension_runtime.go
- git_url.go
- messages.go
- model_resolver.go
- npm_registry.go
- open_browser.go
- open_browser_launch.go
- open_browser_unix.go
- package_manager.go
- package_resolve.go
- project_trust.go
- prompt_templates.go
- provider_attribution.go
- resource_loader.go
- resources.go
- sdk.go
- sdk_session_controls.go
- session_events.go
- session_rpc.go
- session_runtime.go
- skills.go
- slash_commands.go
- system_prompt.go
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
01_minimal
command
Minimal SDK usage with all defaults.
|
Minimal SDK usage with all defaults. |
|
02_custom_model
command
Custom model selection and thinking level.
|
Custom model selection and thinking level. |
|
03_custom_prompt
command
Custom system prompt replacement and extension through DefaultResourceLoader.
|
Custom system prompt replacement and extension through DefaultResourceLoader. |
|
04_skills
command
Skills configuration through DefaultResourceLoader discovery and overrides.
|
Skills configuration through DefaultResourceLoader discovery and overrides. |
|
05_tools
command
Tools configuration: tool allowlists and denylists.
|
Tools configuration: tool allowlists and denylists. |
|
06_extensions
command
Extensions configuration through DefaultResourceLoader inline factories.
|
Extensions configuration through DefaultResourceLoader inline factories. |
|
07_context_files
command
Context files discovered and extended through DefaultResourceLoader.
|
Context files discovered and extended through DefaultResourceLoader. |
|
08_prompt_templates
command
Prompt templates discovered and extended through DefaultResourceLoader.
|
Prompt templates discovered and extended through DefaultResourceLoader. |
|
09_api_keys
command
API key and OAuth configuration through ModelRegistry and runtime callbacks.
|
API key and OAuth configuration through ModelRegistry and runtime callbacks. |
|
10_settings
command
Settings configuration through SettingsManager.
|
Settings configuration through SettingsManager. |
|
11_sessions
command
Session management: in-memory, persistent, continue, list, and open.
|
Session management: in-memory, persistent, continue, list, and open. |
|
12_full_control
command
Full control: explicit model, settings, session, ResourceLoader, and tools.
|
Full control: explicit model, settings, session, ResourceLoader, and tools. |
|
13_session_runtime
command
Session runtime demonstrates recreating cwd-bound services when the active AgentSession is replaced and rebinding session-local host state.
|
Session runtime demonstrates recreating cwd-bound services when the active AgentSession is replaced and rebinding session-local host state. |
|
Package extensions provides the Go-native extension registry, API surface, and ordered event runner used by the coding agent.
|
Package extensions provides the Go-native extension registry, API surface, and ordered event runner used by the coding agent. |
|
jsbridge
Package jsbridge discovers, bundles, and runs TypeScript extensions in isolated Sobek runtimes backed by the Go-native extension API.
|
Package jsbridge discovers, bundles, and runs TypeScript extensions in isolated Sobek runtimes backed by the Go-native extension API. |
|
Package mcp implements pigo's bundled, settings-driven MCP extension.
|
Package mcp implements pigo's bundled, settings-driven MCP extension. |
|
Package modes contains coding-agent run-mode orchestration.
|
Package modes contains coding-agent run-mode orchestration. |
|
Package session stores coding-agent conversations as pi-compatible JSONL trees.
|
Package session stores coding-agent conversations as pi-compatible JSONL trees. |