chatagent

package
v0.93.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: GPL-3.0 Imports: 38 Imported by: 0

Documentation

Overview

Package chatagent wires the chat assistant agent into direct message handling.

Index

Constants

View Source
const (
	// PermissionTopic is the ConfigData topic for chat agent permissions.
	PermissionTopic = "chatagent"
	// PermissionKey is the ConfigData key for chat agent permissions.
	PermissionKey = "permission"
)
View Source
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.

View Source
const DefaultRunTimeout = 10 * time.Minute

DefaultRunTimeout is the maximum duration for one assistant turn when not configured.

Variables

View Source
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.

View Source
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

func CachedSystemPrompt(ctx context.Context, ws coding.Workspace) string

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

func CloseSession(ctx context.Context, sessionID string) error

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

func CreateSession(ctx context.Context, uid types.Uid, sessionID string) error

CreateSession persists a new chat session row for the user.

func DefaultToolSnippets

func DefaultToolSnippets() map[string]string

DefaultToolSnippets returns one-line tool descriptions for the chat assistant.

func DeleteUserPermissions

func DeleteUserPermissions(ctx context.Context, uid types.Uid) error

DeleteUserPermissions removes user permission overrides.

func EstimateTextTokens

func EstimateTextTokens(text string) int

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

func FormatSkillsForPrompt(skills []Skill) string

FormatSkillsForPrompt renders skills in XML for the system prompt.

func FormatSubagentsForPrompt

func FormatSubagentsForPrompt(subagents []Subagent) string

FormatSubagentsForPrompt renders the available subagents in XML for the system prompt.

func GetSubagentDefinition

func GetSubagentDefinition(ctx context.Context, name string) (subagent.Definition, error)

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

func IsChatControlCommand(text string) bool

IsChatControlCommand reports whether the message is a chat session control command.

func LoadUserPermissions

func LoadUserPermissions(ctx context.Context, uid types.Uid) (permission.Config, error)

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

func NewRegistry(ws coding.Workspace, taskDeps *TaskToolDeps) (*tool.Registry, error)

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

func RunTimeout() time.Duration

RunTimeout returns the configured per-turn timeout for the chat assistant.

func SaveUserPermissions

func SaveUserPermissions(ctx context.Context, uid types.Uid, cfg permission.Config) error

SaveUserPermissions persists one user's permission overrides.

func SeedDefaultSubagents

func SeedDefaultSubagents(ctx context.Context) error

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

func SessionOwnerUID(ctx context.Context, sessionID string) (types.Uid, error)

SessionOwnerUID resolves the owning user for one chat session.

func SystemPrompt

func SystemPrompt(ctx context.Context, ws coding.Workspace) string

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

func WorkspaceFromConfig() (coding.Workspace, error)

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.

func BuildAgentInfo

func BuildAgentInfo(ctx context.Context) (AgentInfo, error)

BuildAgentInfo assembles splash metadata from config and storage.

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

type ChatHookDeps struct {
	SessionID string
	UID       types.Uid
}

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

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

type ContextFile struct {
	Path    string
	Content string
}

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

type ContextSkillTokenInfo struct {
	Name   string `json:"name"`
	Tokens int    `json:"tokens"`
}

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

func NewDBStorage(sessionID string) *DBStorage

NewDBStorage creates a session storage adapter for the given session flag.

func (*DBStorage) Append

func (s *DBStorage) Append(ctx context.Context, entry session.TreeEntry) error

Append stores a tree entry and updates the session leaf pointer.

func (*DBStorage) GetBranch

func (s *DBStorage) GetBranch(ctx context.Context, leafID string) ([]session.TreeEntry, error)

GetBranch returns the ordered path from root to the requested leaf.

func (*DBStorage) GetLeafID

func (s *DBStorage) GetLeafID(ctx context.Context) (string, error)

GetLeafID returns the current leaf pointer for the session.

func (*DBStorage) ListEntries

func (s *DBStorage) ListEntries(ctx context.Context) ([]session.TreeEntry, error)

ListEntries returns all entries for the session in storage order.

func (*DBStorage) SetLeafID

func (s *DBStorage) SetLeafID(ctx context.Context, id string) error

SetLeafID updates the current leaf pointer for the session.

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

type ManualCompactionResult struct {
	Compacted    bool
	TokensBefore int
	TokensAfter  int
}

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

Execute returns the stored skill content.

func (ReadSkillTool) Name

func (ReadSkillTool) Name() string

Name returns the tool identifier.

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.

func ListUserActiveSessions

func ListUserActiveSessions(ctx context.Context, uid types.Uid, limit int, cursor string) ([]SessionSummary, string, error)

ListUserActiveSessions returns active sessions owned by uid, newest first.

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.

func LoadSkillsFromStore

func LoadSkillsFromStore(ctx context.Context) ([]Skill, error)

LoadSkillsFromStore loads enabled skills from the database.

type SkillContent

type SkillContent struct {
	Name    string
	Content string
	BaseDir string
}

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 SkillInfo

type SkillInfo struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

SkillInfo describes one enabled agent skill for the splash panel.

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.

func LoadSubagentsFromStore

func LoadSubagentsFromStore(ctx context.Context) ([]Subagent, error)

LoadSubagentsFromStore loads enabled subagent definitions from the database.

type SubagentInfo

type SubagentInfo struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

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

func (TaskTool) Description() string

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) Name

func (TaskTool) Name() string

Name returns the tool identifier.

func (TaskTool) Parameters

func (TaskTool) Parameters() map[string]any

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.

type ToolInfo

type ToolInfo struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

ToolInfo describes one active chat agent tool for the splash panel.

Jump to

Keyboard shortcuts

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