Documentation
¶
Overview ¶
Package chatagent wires the chat assistant agent into direct message handling.
Index ¶
- Constants
- Variables
- func AbortSessionHarness(sessionID string)
- func ActiveToolNames() []string
- func BindRunCancel(sessionID string, cancel context.CancelFunc)
- func BuildSystemPrompt(options BuildSystemPromptOptions) string
- func CachedSystemPrompt(ctx context.Context, ws coding.Workspace) string
- func CancelSessionRun(sessionID string)
- func ClearAPIRunState(sessionID string, expected *APIRunState)
- func ClearSessionPermissionGrants(sessionID string)
- func CloseSession(ctx context.Context, sessionID string) error
- func CreateSession(ctx context.Context, uid types.Uid, sessionID string) error
- func DefaultToolSnippets() map[string]string
- func DeleteUserPermissions(ctx context.Context, uid types.Uid) error
- func EstimateTextTokens(text string) int
- func EvictHarnessPool(sessionID string)
- func FormatSSEData(event StreamEvent) (string, error)
- func FormatSkillsForPrompt(skills []Skill) string
- func FormatSubagentsForPrompt(subagents []Subagent) string
- func GetSubagentDefinition(ctx context.Context, name string) (subagent.Definition, error)
- func InvalidatePromptCache()
- func IsChatControlCommand(text string) bool
- func LoadUserPermissions(ctx context.Context, uid types.Uid) (permission.Config, error)
- func MarshalStreamEvent(event StreamEvent) (string, error)
- func NewRegistry(ws coding.Workspace, taskDeps *TaskToolDeps) (*tool.Registry, error)
- func ParsePermissionsBody(raw []byte) (permission.Config, error)
- func PromptCacheVersion() uint64
- func PublishUsageEvent(publisher EventPublisher, prompt, completion, total, window int, ...)
- func RegisterHooks(reg *hooks.Registry, deps ChatHookDeps)
- func ResetHarnessPoolForTest()
- func ResetPermissionCacheForTest()
- func ResetPermissionSessionsForTest()
- func ResetPromptCacheForTest()
- func ResetSessionEventHubsForTest()
- func ResolveConfirm(sessionID, confirmID string, approved bool, mode ConfirmMode, pattern string, ...) (bool, error)
- func RunTimeout() time.Duration
- func SaveUserPermissions(ctx context.Context, uid types.Uid, cfg permission.Config) error
- func SeedDefaultSubagents(ctx context.Context) error
- func SessionOwnerUID(ctx context.Context, sessionID string) (types.Uid, error)
- func SystemPrompt(ctx context.Context, ws coding.Workspace) string
- func TrySetAPIRunState(sessionID string, state *APIRunState) error
- func UnbindRunCancel(sessionID string)
- func WorkspaceFromConfig() (coding.Workspace, error)
- type APIRunOptions
- type APIRunState
- type AgentInfo
- type BuildSystemPromptOptions
- type ChannelPublisher
- type ChatHookDeps
- type ConfirmGate
- type ConfirmMode
- type ConfirmReason
- type ConfirmResponse
- type ContextCategoryInfo
- type ContextFile
- type ContextSkillTokenInfo
- type ContextUsageReport
- type DBStorage
- func (s *DBStorage) Append(ctx context.Context, entry session.TreeEntry) error
- func (s *DBStorage) GetBranch(ctx context.Context, leafID string) ([]session.TreeEntry, error)
- func (s *DBStorage) GetLeafID(ctx context.Context) (string, error)
- func (s *DBStorage) ListEntries(ctx context.Context) ([]session.TreeEntry, error)
- func (s *DBStorage) SetLeafID(ctx context.Context, id string) error
- type EventPublisher
- type HistoryMessage
- type ManualCompactionResult
- type PermissionSessionManager
- type PermissionsView
- type ReadSkillTool
- type RunRequest
- type Service
- type SessionEventHub
- type SessionExport
- type SessionSummary
- type Skill
- type SkillContent
- type SkillInfo
- type StreamEvent
- type StreamSink
- type Subagent
- type SubagentInfo
- type TaskTool
- type TaskToolDeps
- type ToolInfo
Constants ¶
const ( // PermissionTopic is the ConfigData topic for chat agent permissions. PermissionTopic = "chatagent" // PermissionKey is the ConfigData key for chat agent permissions. PermissionKey = "permission" )
const ( EventTypeDelta = "delta" EventTypeTool = "tool" EventTypeUsage = "usage" EventTypeConfirm = "confirm" EventTypeConfirmResolved = "confirm_resolved" EventTypeCanceled = "canceled" EventTypeDone = "done" EventTypeError = "error" )
Stream event type constants for Chat Agent SSE clients.
const DefaultRunTimeout = 10 * time.Minute
DefaultRunTimeout is the maximum duration for one assistant turn when not configured.
Variables ¶
var ( // ErrConfirmNotFound means no pending confirmation exists for the session. ErrConfirmNotFound = errors.New("confirm not found") // ErrConfirmResolved means the confirmation was already resolved. ErrConfirmResolved = errors.New("confirm already resolved") // ErrChatAgentDisabled means chat agent is not configured. ErrChatAgentDisabled = errors.New("chat agent disabled") // ErrRunInFlight means the session already has an active SSE run. ErrRunInFlight = errors.New("run already in progress") )
API error sentinels for Chat Agent HTTP handlers.
var NewModelForTest = agentllm.GetOrCreateModel
NewModelForTest overrides model creation in unit tests.
Functions ¶
func AbortSessionHarness ¶
func AbortSessionHarness(sessionID string)
AbortSessionHarness cooperatively cancels the agent loop for a pooled session harness.
func ActiveToolNames ¶
func ActiveToolNames() []string
ActiveToolNames returns the default active tool names for the chat assistant.
func BindRunCancel ¶
func BindRunCancel(sessionID string, cancel context.CancelFunc)
BindRunCancel ties an agent run cancel function to a session for cooperative cancellation.
func BuildSystemPrompt ¶
func BuildSystemPrompt(options BuildSystemPromptOptions) string
BuildSystemPrompt constructs the chat assistant system prompt.
func CachedSystemPrompt ¶
CachedSystemPrompt returns the chat assistant system prompt, reusing a process cache when inputs are unchanged.
func CancelSessionRun ¶
func CancelSessionRun(sessionID string)
CancelSessionRun aborts the in-flight agent run for a session.
func ClearAPIRunState ¶
func ClearAPIRunState(sessionID string, expected *APIRunState)
ClearAPIRunState removes run state only when it matches the active connection.
func ClearSessionPermissionGrants ¶
func ClearSessionPermissionGrants(sessionID string)
ClearSessionPermissionGrants resets always grants and doom-loop counters for one session.
func CloseSession ¶
CloseSession marks a chat session as closed, cancels in-flight runs, and releases locks. The ordering (cancel -> close DB -> release lock) ensures no new run can start on a closing session.
func CreateSession ¶
CreateSession persists a new chat session row for the user.
func DefaultToolSnippets ¶
DefaultToolSnippets returns one-line tool descriptions for the chat assistant.
func DeleteUserPermissions ¶
DeleteUserPermissions removes user permission overrides.
func EstimateTextTokens ¶
EstimateTextTokens conservatively estimates token count for raw text.
func EvictHarnessPool ¶
func EvictHarnessPool(sessionID string)
EvictHarnessPool removes a cached harness for the given session.
func FormatSSEData ¶
func FormatSSEData(event StreamEvent) (string, error)
FormatSSEData returns a complete SSE data line payload for writing to the stream.
func FormatSkillsForPrompt ¶
FormatSkillsForPrompt renders skills in XML for the system prompt.
func FormatSubagentsForPrompt ¶
FormatSubagentsForPrompt renders the available subagents in XML for the system prompt.
func GetSubagentDefinition ¶
GetSubagentDefinition loads one enabled subagent by name as a runnable definition.
func InvalidatePromptCache ¶
func InvalidatePromptCache()
InvalidatePromptCache clears the cached system prompt so the next request rebuilds it.
func IsChatControlCommand ¶
IsChatControlCommand reports whether the message is a chat session control command.
func LoadUserPermissions ¶
LoadUserPermissions reads merged effective permission config for one user.
func MarshalStreamEvent ¶
func MarshalStreamEvent(event StreamEvent) (string, error)
MarshalStreamEvent serializes one SSE data frame body.
func NewRegistry ¶
NewRegistry registers assistant tools including DB-backed skills support. When taskDeps is non-nil, the subagent delegation task tool is registered and activated.
func ParsePermissionsBody ¶
func ParsePermissionsBody(raw []byte) (permission.Config, error)
ParsePermissionsBody unmarshals a PUT /chatagent/permissions request body.
func PromptCacheVersion ¶
func PromptCacheVersion() uint64
PromptCacheVersion returns a monotonic version token for prompt cache invalidation.
func PublishUsageEvent ¶
func PublishUsageEvent(publisher EventPublisher, prompt, completion, total, window int, percent float64)
PublishUsageEvent emits a context usage snapshot to the client.
func RegisterHooks ¶
func RegisterHooks(reg *hooks.Registry, deps ChatHookDeps)
RegisterHooks wires observational and API hooks for one chat agent harness run.
func ResetHarnessPoolForTest ¶
func ResetHarnessPoolForTest()
ResetHarnessPoolForTest clears all pooled harnesses.
func ResetPermissionCacheForTest ¶
func ResetPermissionCacheForTest()
ResetPermissionCacheForTest clears the in-memory permission cache.
func ResetPermissionSessionsForTest ¶
func ResetPermissionSessionsForTest()
ResetPermissionSessionsForTest clears all in-memory permission session state.
func ResetPromptCacheForTest ¶
func ResetPromptCacheForTest()
ResetPromptCacheForTest clears the in-process system prompt cache.
func ResetSessionEventHubsForTest ¶
func ResetSessionEventHubsForTest()
ResetSessionEventHubsForTest clears all session event hubs.
func ResolveConfirm ¶
func ResolveConfirm(sessionID, confirmID string, approved bool, mode ConfirmMode, pattern string, reason ConfirmReason) (bool, error)
ResolveConfirm applies a client confirmation for the active gate on a session.
func RunTimeout ¶
RunTimeout returns the configured per-turn timeout for the chat assistant.
func SaveUserPermissions ¶
SaveUserPermissions persists one user's permission overrides.
func SeedDefaultSubagents ¶
SeedDefaultSubagents inserts built-in subagent definitions when none exist yet. It is a best-effort startup helper and never overwrites user-managed rows.
func SessionOwnerUID ¶
SessionOwnerUID resolves the owning user for one chat session.
func SystemPrompt ¶
SystemPrompt builds the default chat assistant prompt from workspace, config, and DB skills.
func TrySetAPIRunState ¶
func TrySetAPIRunState(sessionID string, state *APIRunState) error
TrySetAPIRunState registers run state when no other run is active for the session.
func UnbindRunCancel ¶
func UnbindRunCancel(sessionID string)
UnbindRunCancel removes the run cancel function for a session.
func WorkspaceFromConfig ¶
WorkspaceFromConfig resolves workspace settings from application config.
Types ¶
type APIRunOptions ¶
type APIRunOptions struct {
Publisher EventPublisher
Confirm *ConfirmGate
}
APIRunOptions configures an HTTP Chat Agent run with SSE publishing and confirmations.
type APIRunState ¶
type APIRunState struct {
// contains filtered or unexported fields
}
APIRunState tracks one in-flight HTTP run for cancel and confirm routing.
func GetAPIRunState ¶
func GetAPIRunState(sessionID string) (*APIRunState, bool)
GetAPIRunState returns the active HTTP run state when present.
func NewAPIRunState ¶
func NewAPIRunState(publisher *ChannelPublisher, gate *ConfirmGate) *APIRunState
NewAPIRunState builds run state for an active SSE connection.
func (*APIRunState) Publisher ¶
func (s *APIRunState) Publisher() EventPublisher
Publisher returns the SSE publisher when present.
type AgentInfo ¶
type AgentInfo struct {
Version string `json:"version"`
ChatModel string `json:"chat_model"`
ToolModel string `json:"tool_model"`
Provider string `json:"provider"`
Workspace string `json:"workspace"`
Tools []ToolInfo `json:"tools"`
Skills []SkillInfo `json:"skills"`
Subagents []SubagentInfo `json:"subagents"`
ToolCount int `json:"tool_count"`
SkillCount int `json:"skill_count"`
SubagentCount int `json:"subagent_count"`
}
AgentInfo is startup metadata for the Chat Agent HTTP client.
type BuildSystemPromptOptions ¶
type BuildSystemPromptOptions struct {
// CustomPrompt replaces the default prompt body when non-empty.
CustomPrompt string
// SelectedTools limits which tools appear in the Available tools section.
SelectedTools []string
// ToolSnippets provides one-line descriptions keyed by tool name.
ToolSnippets map[string]string
// PromptGuidelines adds extra guideline bullets after tool-specific defaults.
PromptGuidelines []string
// AppendSystemPrompt is appended after the main body and before project context.
AppendSystemPrompt string
// CWD is the sandbox workspace root shown to the model.
CWD string
// ContextFiles are pre-loaded project instruction files.
ContextFiles []ContextFile
// Skills are agent skills injected into the prompt; nil loads from the database.
Skills []Skill
// Subagents are delegation targets injected into the prompt for the task tool.
Subagents []Subagent
}
BuildSystemPromptOptions configures system prompt construction.
type ChannelPublisher ¶
type ChannelPublisher struct {
// contains filtered or unexported fields
}
ChannelPublisher sends stream events to a buffered channel for SSE writers.
func NewChannelPublisher ¶
func NewChannelPublisher(buffer int) *ChannelPublisher
NewChannelPublisher creates a publisher backed by a buffered event channel.
func (*ChannelPublisher) Close ¶
func (p *ChannelPublisher) Close()
Close marks the publisher done and closes the channel.
func (*ChannelPublisher) Events ¶
func (p *ChannelPublisher) Events() <-chan StreamEvent
Events returns the readable event channel.
func (*ChannelPublisher) Publish ¶
func (p *ChannelPublisher) Publish(event StreamEvent) error
Publish enqueues one stream event for the SSE writer goroutine.
type ChatHookDeps ¶
ChatHookDeps carries per-run metadata for chat agent hook handlers.
type ConfirmGate ¶
type ConfirmGate struct {
// contains filtered or unexported fields
}
ConfirmGate blocks tool execution until the client approves or denies.
func NewConfirmGate ¶
func NewConfirmGate(sessionID string, publisher EventPublisher) *ConfirmGate
NewConfirmGate creates a gate that publishes confirm events to session subscribers.
func (*ConfirmGate) Cancel ¶
func (g *ConfirmGate) Cancel()
Cancel closes the gate without approving, used when the run is aborted.
func (*ConfirmGate) ID ¶
func (g *ConfirmGate) ID() string
ID returns the confirmation request identifier shared with the client.
func (*ConfirmGate) Resolve ¶
func (g *ConfirmGate) Resolve(resp ConfirmResponse) bool
Resolve applies the client decision. Returns false when the gate is already resolved.
func (*ConfirmGate) Wait ¶
func (g *ConfirmGate) Wait(ctx context.Context, event hooks.ToolCallEvent, eval permission.Result) (ConfirmResponse, error)
Wait publishes a confirm event and blocks until the client responds or times out.
type ConfirmMode ¶
type ConfirmMode string
ConfirmMode is how the user resolved an approval prompt.
const ( ConfirmModeOnce ConfirmMode = "once" ConfirmModeAlways ConfirmMode = "always" ConfirmModeReject ConfirmMode = "reject" )
type ConfirmReason ¶
type ConfirmReason string
ConfirmReason describes how a tool confirmation was resolved.
const ( ConfirmReasonApproved ConfirmReason = "approved" ConfirmReasonDenied ConfirmReason = "denied" ConfirmReasonTimeout ConfirmReason = "timeout" )
type ConfirmResponse ¶
type ConfirmResponse struct {
Approved bool
Reason ConfirmReason
Mode ConfirmMode
Pattern string
}
ConfirmResponse is the user's answer to a pending tool confirmation.
type ContextCategoryInfo ¶
type ContextCategoryInfo struct {
ID string `json:"id"`
Label string `json:"label"`
Tokens int `json:"tokens"`
Percent float64 `json:"percent"`
}
ContextCategoryInfo is one row in the context usage breakdown.
type ContextFile ¶
ContextFile holds project-specific instructions injected into the system prompt.
func LoadDefaultContextFiles ¶
func LoadDefaultContextFiles(cwd string) []ContextFile
LoadDefaultContextFiles discovers common project instruction files under cwd.
type ContextSkillTokenInfo ¶
ContextSkillTokenInfo reports estimated prompt tokens for one skill entry.
type ContextUsageReport ¶
type ContextUsageReport struct {
Model string `json:"model"`
ToolModel string `json:"tool_model,omitempty"`
ContextWindow int `json:"context_window"`
TotalTokens int `json:"total_tokens"`
TotalPercent float64 `json:"total_percent"`
CompactionEnabled bool `json:"compaction_enabled"`
Categories []ContextCategoryInfo `json:"categories"`
Skills []ContextSkillTokenInfo `json:"skills"`
}
ContextUsageReport is the full context budget snapshot for a chat session.
func BuildContextUsageReport ¶
func BuildContextUsageReport(ctx context.Context, sessionID string) (ContextUsageReport, error)
BuildContextUsageReport assembles a context budget breakdown for the terminal client.
type DBStorage ¶
type DBStorage struct {
// contains filtered or unexported fields
}
DBStorage persists agent session trees in PostgreSQL.
func NewDBStorage ¶
NewDBStorage creates a session storage adapter for the given session flag.
func (*DBStorage) ListEntries ¶
ListEntries returns all entries for the session in storage order.
type EventPublisher ¶
type EventPublisher interface {
Publish(event StreamEvent) error
}
EventPublisher delivers stream events to an active HTTP SSE connection.
type HistoryMessage ¶
type HistoryMessage struct {
Role string `json:"role"`
Text string `json:"text"`
CreatedAt time.Time `json:"created_at"`
}
HistoryMessage is one persisted chat turn exposed to HTTP clients.
func ListSessionMessages ¶
func ListSessionMessages(ctx context.Context, sessionID string) ([]HistoryMessage, error)
ListSessionMessages returns user and assistant messages for a session branch.
type ManualCompactionResult ¶
ManualCompactionResult reports the outcome of a user-triggered compaction run.
type PermissionSessionManager ¶
type PermissionSessionManager struct {
// contains filtered or unexported fields
}
PermissionSessionManager keeps permission session state across runs for one chat session.
func (*PermissionSessionManager) ClearPermissionSession ¶
func (m *PermissionSessionManager) ClearPermissionSession(sessionID string)
ClearPermissionSession removes session permission state.
func (*PermissionSessionManager) GetPermissionSession ¶
func (m *PermissionSessionManager) GetPermissionSession(sessionID string) *permission.SessionState
GetPermissionSession returns or creates session-scoped permission state.
type PermissionsView ¶
type PermissionsView struct {
Defaults permission.Config `json:"defaults"`
User permission.Config `json:"user"`
Effective permission.Config `json:"effective"`
SessionGrants map[string][]string `json:"session_grants,omitempty"`
}
PermissionsView is the API payload for permission configuration.
func BuildPermissionsView ¶
func BuildPermissionsView(ctx context.Context, uid types.Uid, sessionID string) (PermissionsView, error)
BuildPermissionsView assembles permission state for one user and optional session.
type ReadSkillTool ¶
type ReadSkillTool struct{}
ReadSkillTool loads skill instructions from the database by name.
func (ReadSkillTool) Description ¶
func (ReadSkillTool) Description() string
Description explains the tool to the model.
func (ReadSkillTool) Execute ¶
func (ReadSkillTool) Execute(ctx context.Context, id string, args map[string]any, _ tool.UpdateHandler) (msg.ToolResultMessage, error)
Execute returns the stored skill content.
func (ReadSkillTool) Parameters ¶
func (ReadSkillTool) Parameters() map[string]any
Parameters returns the JSON schema for tool arguments.
type RunRequest ¶
type RunRequest struct {
SessionID string
Text string
API *APIRunOptions
}
RunRequest carries one user turn for the chat assistant.
type Service ¶
type Service struct{}
Service orchestrates chat assistant agent runs for direct chat sessions.
func NewService ¶
func NewService() *Service
NewService creates a chat agent service using current application config.
func (*Service) CompactSession ¶
func (*Service) CompactSession(ctx context.Context, sessionID string) (*ManualCompactionResult, error)
CompactSession force-compacts the current session branch without sending a user turn.
func (*Service) Run ¶
func (*Service) Run(ctx context.Context, req RunRequest, sink StreamSink) (string, error)
Run executes one agent turn and returns the assistant reply text.
func (*Service) RunAPI ¶
func (s *Service) RunAPI(ctx context.Context, req RunRequest, opts *APIRunOptions) error
RunAPI executes one agent turn for HTTP clients with SSE event publishing.
type SessionEventHub ¶
type SessionEventHub struct {
// contains filtered or unexported fields
}
SessionEventHub fans out stream events to multiple SSE subscribers for one session.
func GetSessionEventHub ¶
func GetSessionEventHub(sessionID string) *SessionEventHub
GetSessionEventHub returns the event hub for one session.
func (*SessionEventHub) Subscribe ¶
func (h *SessionEventHub) Subscribe(id string, buffer int) *ChannelPublisher
Subscribe registers one SSE consumer on the session hub.
func (*SessionEventHub) Unsubscribe ¶
func (h *SessionEventHub) Unsubscribe(id string)
Unsubscribe removes one SSE consumer from the session hub.
type SessionExport ¶
type SessionExport struct {
SessionID string `json:"session_id"`
UID string `json:"uid"`
LeafID string `json:"leaf_id"`
State string `json:"state"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ExportedAt time.Time `json:"exported_at"`
EntryCount int `json:"entry_count"`
Entries []map[string]any `json:"entries"`
}
SessionExport is the full session snapshot returned by the export API.
func ExportSession ¶
func ExportSession(ctx context.Context, sessionID string) (*SessionExport, error)
ExportSession loads session metadata and all persisted tree entries.
type SessionSummary ¶
type SessionSummary struct {
SessionID string `json:"session_id"`
State string `json:"state"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
SessionSummary is a lightweight view of one chat session for list APIs.
type Skill ¶
type Skill struct {
Name string
Description string
Location string
BaseDir string
DisableModelInvocation bool
}
Skill is a prompt-visible agent skill loaded from storage.
type SkillContent ¶
SkillContent is the full skill body returned by read_skill.
func GetSkillContent ¶
func GetSkillContent(ctx context.Context, name string) (SkillContent, error)
GetSkillContent loads one enabled skill body by name.
type StreamEvent ¶
type StreamEvent struct {
Type string `json:"type"`
// delta / done
Text string `json:"text,omitempty"`
// tool
Name string `json:"name,omitempty"`
Subagent string `json:"subagent,omitempty"`
Status string `json:"status,omitempty"`
Stdout string `json:"stdout,omitempty"`
Stderr string `json:"stderr,omitempty"`
// usage
PromptTokens int `json:"prompt_tokens,omitempty"`
CompletionTokens int `json:"completion_tokens,omitempty"`
TotalTokens int `json:"total_tokens,omitempty"`
ContextPercent float64 `json:"context_percent,omitempty"`
ContextWindow int `json:"context_window,omitempty"`
// confirm / confirm_resolved
ID string `json:"id,omitempty"`
Tool string `json:"tool,omitempty"`
Summary string `json:"summary,omitempty"`
Permission string `json:"permission,omitempty"`
Pattern string `json:"pattern,omitempty"`
SuggestedPattern string `json:"suggested_pattern,omitempty"`
SuggestAlways bool `json:"suggest_always,omitempty"`
Approved bool `json:"approved,omitempty"`
Reason string `json:"reason,omitempty"`
Mode string `json:"mode,omitempty"`
Message string `json:"message,omitempty"`
}
StreamEvent is one SSE payload emitted to Chat Agent HTTP clients.
type StreamSink ¶
type StreamSink interface {
// OnDelta delivers throttled snapshot text for in-progress updates.
OnDelta(ctx context.Context, text string) error
// Flush writes the final reply text to the platform message.
Flush(ctx context.Context, final string) error
}
StreamSink receives incremental assistant text during a streaming platform reply.
func NewSlackStreamSink ¶
func NewSlackStreamSink(caller *platforms.Caller, topic, messageID string) StreamSink
NewSlackStreamSink creates a sink that edits an existing Slack message.
type Subagent ¶
type Subagent struct {
Flag string
Name string
Description string
SystemPrompt string
Tools []string
Model string
}
Subagent is a prompt-visible subagent definition loaded from storage.
type SubagentInfo ¶
SubagentInfo describes one enabled subagent for the splash panel.
type TaskTool ¶
type TaskTool struct {
// contains filtered or unexported fields
}
TaskTool delegates a self-contained task to an isolated subagent loop.
func NewTaskTool ¶
func NewTaskTool(ws coding.Workspace, deps TaskToolDeps) TaskTool
NewTaskTool creates a task tool bound to a workspace and per-run delegation metadata.
func (TaskTool) Description ¶
Description explains the tool to the model.
func (TaskTool) Execute ¶
func (t TaskTool) Execute(ctx context.Context, id string, args map[string]any, onUpdate tool.UpdateHandler) (msg.ToolResultMessage, error)
Execute resolves the subagent definition, runs it in isolation, and returns the final result.
func (TaskTool) Parameters ¶
Parameters returns the JSON schema for tool arguments.
type TaskToolDeps ¶
type TaskToolDeps struct {
// SessionID is the owning chat session, used to reuse permission gates.
SessionID string
// UID is the session owner, used to evaluate tool permissions in the subagent.
UID types.Uid
// Depth is the delegation depth of the caller (0 for the primary agent).
Depth int
}
TaskToolDeps carries the per-run metadata needed to delegate to a subagent.
Source Files
¶
- api_errors.go
- api_run.go
- confirm.go
- context_usage.go
- doc.go
- event_sink.go
- event_stream.go
- export.go
- harness_pool.go
- history.go
- hooks.go
- info.go
- models.go
- permission_api.go
- permission_session.go
- permission_store.go
- prompt_cache.go
- protocol.go
- registry.go
- run_control.go
- run_timeout.go
- service.go
- session.go
- session_events.go
- sink.go
- skill_tool.go
- skills.go
- slack_sink.go
- storage.go
- stream_coalescer.go
- subagent_progress.go
- subagent_tool.go
- subagents.go
- system_prompt.go