ai

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 68 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AskUserReasonUserDecisionRequired = "user_decision_required"
	AskUserReasonPermissionBlocked    = "permission_blocked"
	AskUserReasonMissingExternalInput = "missing_external_input"
	AskUserReasonConflictingWork      = "conflicting_constraints"
	AskUserReasonSafetyConfirmation   = "safety_confirmation"
)
View Source
const (
	DesktopModelSourceProviderType    = "desktop_model_source"
	DesktopModelSourceProtocolVersion = "redeven-desktop-model-source-rpc-v1"
	DesktopModelSourceDefaultSource   = "desktop_local_environment"
)
View Source
const (
	// Type IDs must stay in sync with
	// internal/envapp/ui_src/src/ui/protocol/redeven_v1/typeIds.ts.
	TypeID_AI_SEND_USER_TURN                     uint32 = 6001
	TypeID_AI_SUBSCRIBE_SUMMARY                  uint32 = 6003
	TypeID_AI_EVENT_NOTIFY                       uint32 = 6004 // notify (agent -> client)
	TypeID_AI_MESSAGES_LIST                      uint32 = 6006
	TypeID_AI_SUBSCRIBE_THREAD                   uint32 = 6009
	TypeID_AI_STOP_THREAD                        uint32 = 6011
	TypeID_AI_SUBMIT_REQUEST_USER_INPUT_RESPONSE uint32 = 6012
	TypeID_AI_COMPACT_THREAD_CONTEXT             uint32 = 6013
)
View Source
const (
	ErrCodeAISkillsInvalidScope      = "AI_SKILLS_INVALID_SCOPE"
	ErrCodeAISkillsInvalidSource     = "AI_SKILLS_INVALID_SOURCE"
	ErrCodeAISkillsInvalidPath       = "AI_SKILLS_INVALID_PATH"
	ErrCodeAISkillsPathEscape        = "AI_SKILLS_PATH_ESCAPE"
	ErrCodeAISkillsSkillExists       = "AI_SKILLS_SKILL_EXISTS"
	ErrCodeAISkillsSkillNotFound     = "AI_SKILLS_SKILL_NOT_FOUND"
	ErrCodeAISkillsFrontmatterBad    = "AI_SKILLS_FRONTMATTER_INVALID"
	ErrCodeAISkillsGitHubFetchFailed = "AI_SKILLS_GITHUB_FETCH_FAILED"
	ErrCodeAISkillsGitFallbackFailed = "AI_SKILLS_GIT_FALLBACK_FAILED"
	ErrCodeAISkillsArchiveInvalid    = "AI_SKILLS_ARCHIVE_INVALID"
	ErrCodeAISkillsBrowseForbidden   = "AI_SKILLS_BROWSE_FORBIDDEN"
	ErrCodeAISkillsFileTooLarge      = "AI_SKILLS_FILE_TOO_LARGE"
	ErrCodeAISkillsInternal          = "AI_SKILLS_INTERNAL_ERROR"
)
View Source
const (
	ToolTargetModeLocalRuntime   = "local_runtime"
	ToolTargetModeExplicitTarget = "explicit_target"
)
View Source
const (
	TaskComplexitySimple   = "simple"
	TaskComplexityStandard = "standard"
	TaskComplexityComplex  = "complex"
)
View Source
const (
	TodoStatusPending    = "pending"
	TodoStatusInProgress = "in_progress"
	TodoStatusCompleted  = "completed"
	TodoStatusCancelled  = "cancelled"
)
View Source
const ContextActionSchemaVersion = 2
View Source
const FlowerLiveSchemaVersion int64 = 1

Variables

View Source
var (
	ErrFlowerFileActionInvalid  = errors.New("flower file action is invalid")
	ErrFlowerFileActionNotFound = errors.New("flower file action was not found")
)
View Source
var (
	ErrNotConfigured         = errors.New("ai not configured")
	ErrRunActive             = errors.New("run already active")
	ErrThreadBusy            = errors.New("thread already active")
	ErrThreadForkUnavailable = errors.New("thread cannot be forked while active or waiting")
)
View Source
var ErrCompactAlreadyPending = errors.New("context compaction already pending")
View Source
var ErrFollowupsRevisionChanged = errors.New("followups revision changed")
View Source
var ErrInvalidContextAction = errors.New("invalid context action")
View Source
var ErrInvalidFollowupLane = errors.New("invalid followup lane")
View Source
var ErrNoCompactableContext = errors.New("no compactable context")
View Source
var ErrReadOnlyThread = errors.New("thread is read only")
View Source
var ErrRunChanged = errors.New("run changed")
View Source
var ErrWaitingPromptChanged = errors.New("waiting prompt changed")
View Source
var ErrWaitingUserQueueConflict = errors.New("waiting-user queue request conflicts with waiting response")

Functions

func IsActiveRunState

func IsActiveRunState(raw string) bool

func NewQueuedTurnID

func NewQueuedTurnID() (string, error)

func NewRunID

func NewRunID() (string, error)

NewRunID generates a cryptographically random run id.

func NewThreadID

func NewThreadID() (string, error)

NewThreadID generates a cryptographically random thread id.

func RunDesktopModelSourceConnector added in v0.6.8

func RunDesktopModelSourceConnector(ctx context.Context, opts DesktopModelSourceConnectorOptions) error

func SanitizeActivityTimelineBlockJSON added in v0.7.1

func SanitizeActivityTimelineBlockJSON(raw json.RawMessage) (json.RawMessage, error)

func SanitizeActivityTimelineBlockValue added in v0.7.1

func SanitizeActivityTimelineBlockValue(value any) (any, error)

func SanitizeActivityTimelineMessageJSON added in v0.7.1

func SanitizeActivityTimelineMessageJSON(raw string) (json.RawMessage, error)

func SkillErrorCode

func SkillErrorCode(err error) string

func SkillErrorStatus

func SkillErrorStatus(err error) int

func StripTargetToolArgs added in v0.7.1

func StripTargetToolArgs(args map[string]any) map[string]any

Types

type AIRuntimeStatus added in v0.6.4

type AIRuntimeStatus struct {
	RemoteConfigured   bool                      `json:"remote_configured"`
	DesktopModelSource *DesktopModelSourceStatus `json:"desktop_model_source,omitempty"`
}

type ActiveThreadRun

type ActiveThreadRun struct {
	ThreadID string `json:"thread_id"`
	RunID    string `json:"run_id"`
}

ActiveThreadRun is returned in subscribe snapshots so late subscribers can discover currently running threads before live events arrive.

type ActivityTimelineBlock added in v0.6.10

type ActivityTimelineBlock struct {
	Type        string                              `json:"type"`
	FileActions map[string]FlowerActivityFileAction `json:"file_actions,omitempty"`
	observation.ActivityTimeline
}

type AppendThreadMessageRequest

type AppendThreadMessageRequest struct {
	Role   string `json:"role"`
	Text   string `json:"text"`
	Format string `json:"format,omitempty"` // markdown|text (defaults to markdown for now)
}

type ApplyPatchResult added in v0.7.1

type ApplyPatchResult struct {
	FilesChanged     int                  `json:"files_changed"`
	Hunks            int                  `json:"hunks"`
	Additions        int                  `json:"additions"`
	Deletions        int                  `json:"deletions"`
	InputFormat      string               `json:"input_format"`
	NormalizedFormat string               `json:"normalized_format"`
	Files            []patchFileSummary   `json:"files"`
	Mutations        []FileMutationResult `json:"mutations"`
}

type ApprovalDecisionKind added in v0.7.2

type ApprovalDecisionKind string
const (
	ApprovalDecisionAllow ApprovalDecisionKind = "allow"
	ApprovalDecisionAsk   ApprovalDecisionKind = "ask"
	ApprovalDecisionDeny  ApprovalDecisionKind = "deny"
)

type CompactThreadContextRequest added in v0.7.2

type CompactThreadContextRequest struct {
	ThreadID    string `json:"thread_id"`
	ActiveRunID string `json:"active_run_id,omitempty"`
}

type CompactThreadContextResponse added in v0.7.2

type CompactThreadContextResponse struct {
	OperationID string `json:"operation_id,omitempty"`
	Kind        string `json:"kind"`
	ErrorCode   string `json:"error_code,omitempty"`
}

type ContentPart

type ContentPart struct {
	Type       string `json:"type"`
	Text       string `json:"text,omitempty"`
	FileURI    string `json:"file_uri,omitempty"`
	MimeType   string `json:"mime_type,omitempty"`
	ToolCallID string `json:"tool_call_id,omitempty"`
	ToolUseID  string `json:"tool_use_id,omitempty"`
	ToolName   string `json:"tool_name,omitempty"`
	ArgsJSON   string `json:"args_json,omitempty"`
	JSON       []byte `json:"json,omitempty"`
}

type ContextActionContextItem added in v0.7.1

type ContextActionContextItem struct {
	Kind           string  `json:"kind"`
	Path           string  `json:"path,omitempty"`
	IsDirectory    bool    `json:"is_directory,omitempty"`
	RootLabel      string  `json:"root_label,omitempty"`
	Selection      string  `json:"selection,omitempty"`
	SelectionChars int     `json:"selection_chars,omitempty"`
	WorkingDir     string  `json:"working_dir,omitempty"`
	PID            int     `json:"pid,omitempty"`
	Name           string  `json:"name,omitempty"`
	Username       string  `json:"username,omitempty"`
	CPUPercent     float64 `json:"cpu_percent,omitempty"`
	MemoryBytes    int64   `json:"memory_bytes,omitempty"`
	Platform       string  `json:"platform,omitempty"`
	CapturedAtMs   int64   `json:"captured_at_ms,omitempty"`
	Title          string  `json:"title,omitempty"`
	Detail         string  `json:"detail,omitempty"`
	Content        string  `json:"content,omitempty"`
}

func (ContextActionContextItem) MarshalJSON added in v0.7.2

func (item ContextActionContextItem) MarshalJSON() ([]byte, error)

type ContextActionEnvelope added in v0.7.1

type ContextActionEnvelope struct {
	SchemaVersion       int                         `json:"schema_version"`
	ActionID            string                      `json:"action_id"`
	Provider            string                      `json:"provider,omitempty"`
	Target              ContextActionTarget         `json:"target"`
	Source              ContextActionSource         `json:"source"`
	ExecutionContext    *ContextActionExecutionHint `json:"execution_context,omitempty"`
	Context             []ContextActionContextItem  `json:"context"`
	Presentation        ContextActionPresentation   `json:"presentation"`
	SuggestedWorkingDir string                      `json:"suggested_working_dir_abs,omitempty"`
}

type ContextActionExecutionHint added in v0.7.1

type ContextActionExecutionHint struct {
	CurrentTargetID   string `json:"current_target_id,omitempty"`
	SourceEnvPublicID string `json:"source_env_public_id,omitempty"`
	RuntimeHint       string `json:"runtime_hint,omitempty"`
	SessionSource     string `json:"session_source,omitempty"`
}

type ContextActionPresentation added in v0.7.1

type ContextActionPresentation struct {
	Label          string `json:"label"`
	Priority       int    `json:"priority"`
	StatusLabel    string `json:"status_label,omitempty"`
	DisabledReason string `json:"disabled_reason,omitempty"`
}

type ContextActionSource added in v0.7.1

type ContextActionSource struct {
	Surface   string `json:"surface"`
	SurfaceID string `json:"surface_id,omitempty"`
}

type ContextActionTarget added in v0.7.1

type ContextActionTarget struct {
	TargetID string `json:"target_id"`
	Locality string `json:"locality"`
}

type CreateThreadRequest

type CreateThreadRequest struct {
	Title              string                      `json:"title"`
	ModelID            string                      `json:"model_id,omitempty"`
	PermissionType     string                      `json:"permission_type,omitempty"`
	WorkingDir         string                      `json:"working_dir,omitempty"`
	ReasoningSelection config.AIReasoningSelection `json:"reasoning_selection,omitempty"`
}

type CreateThreadResponse

type CreateThreadResponse struct {
	Thread ThreadView `json:"thread"`
}

type DefaultPermissionToolFilter added in v0.7.2

type DefaultPermissionToolFilter struct{}

func (DefaultPermissionToolFilter) FilterTools added in v0.7.2

func (f DefaultPermissionToolFilter) FilterTools(permissionType FlowerPermissionType, all []ToolDef) []ToolDef

type DelegatedApprovalRef added in v0.7.2

type DelegatedApprovalRef struct {
	ParentThreadID  string `json:"parent_thread_id"`
	ParentRunID     string `json:"parent_run_id"`
	ParentTurnID    string `json:"parent_turn_id,omitempty"`
	SubagentID      string `json:"subagent_id"`
	ChildThreadID   string `json:"child_thread_id"`
	ChildRunID      string `json:"child_run_id"`
	ChildTurnID     string `json:"child_turn_id,omitempty"`
	ChildToolCallID string `json:"child_tool_call_id"`
	ApprovalID      string `json:"approval_id"`
}

type DesktopModelSourceConnectorOptions added in v0.6.8

type DesktopModelSourceConnectorOptions struct {
	Logger                *slog.Logger
	ConfigPath            string
	SecretsPath           string
	RuntimeControlBaseURL string
	RuntimeControlToken   string
	DesktopOwnerID        string
	SessionID             string
	Source                string
	ExpiresAtUnixMS       int64
	StartupReportFile     string
	HTTPClient            *http.Client
}

type DesktopModelSourceModel added in v0.6.8

type DesktopModelSourceModel struct {
	ID                            string                        `json:"id"`
	Label                         string                        `json:"label,omitempty"`
	Provider                      string                        `json:"provider,omitempty"`
	ContextWindow                 int                           `json:"context_window,omitempty"`
	MaxOutputTokens               int                           `json:"max_output_tokens,omitempty"`
	EffectiveContextWindowPercent int                           `json:"effective_context_window_percent,omitempty"`
	InputModalities               []string                      `json:"input_modalities,omitempty"`
	SupportsImageInput            bool                          `json:"supports_image_input,omitempty"`
	ReasoningCapability           config.AIReasoningCapability  `json:"reasoning_capability,omitempty"`
	Capability                    *contextmodel.ModelCapability `json:"capability,omitempty"`
}

type DesktopModelSourceModelSnapshot added in v0.6.8

type DesktopModelSourceModelSnapshot struct {
	Configured            bool                      `json:"configured"`
	CurrentModel          string                    `json:"current_model"`
	Models                []DesktopModelSourceModel `json:"models"`
	MissingKeyProviderIDs []string                  `json:"missing_key_provider_ids,omitempty"`
}

type DesktopModelSourceRPCError added in v0.6.8

type DesktopModelSourceRPCError struct {
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

func (*DesktopModelSourceRPCError) Error added in v0.6.8

type DesktopModelSourceRPCFrame added in v0.6.8

type DesktopModelSourceRPCFrame struct {
	ProtocolVersion string                      `json:"protocol_version,omitempty"`
	ID              string                      `json:"id,omitempty"`
	Type            string                      `json:"type"`
	Method          string                      `json:"method,omitempty"`
	Params          json.RawMessage             `json:"params,omitempty"`
	Event           *StreamEvent                `json:"event,omitempty"`
	Result          json.RawMessage             `json:"result,omitempty"`
	Error           *DesktopModelSourceRPCError `json:"error,omitempty"`
}

type DesktopModelSourceSession added in v0.6.8

type DesktopModelSourceSession struct {
	SessionID       string
	Source          string
	ProtocolVersion string
	ExpiresAtUnixMS int64
}

type DesktopModelSourceStartupReport added in v0.6.8

type DesktopModelSourceStartupReport struct {
	Status                string   `json:"status"`
	SessionID             string   `json:"session_id"`
	PID                   int      `json:"pid"`
	Configured            bool     `json:"configured"`
	ModelCount            int      `json:"model_count"`
	MissingKeyProviderIDs []string `json:"missing_key_provider_ids,omitempty"`
}

type DesktopModelSourceStatus added in v0.6.8

type DesktopModelSourceStatus struct {
	BindingState          string   `json:"binding_state,omitempty"`
	Connected             bool     `json:"connected"`
	Available             bool     `json:"available"`
	ModelSource           string   `json:"model_source,omitempty"`
	SessionID             string   `json:"session_id,omitempty"`
	ExpiresAtUnixMS       int64    `json:"expires_at_unix_ms,omitempty"`
	ConnectedAtUnixMS     int64    `json:"connected_at_unix_ms,omitempty"`
	ModelCount            int      `json:"model_count"`
	MissingKeyProviderIDs []string `json:"missing_key_provider_ids,omitempty"`
	LastError             string   `json:"last_error,omitempty"`
}

type FileEditArgs

type FileEditArgs struct {
	FilePath   string `json:"file_path"`
	OldString  string `json:"old_string"`
	NewString  string `json:"new_string"`
	ReplaceAll bool   `json:"replace_all,omitempty"`
}

type FileMutationResult

type FileMutationResult struct {
	FilePath              string `json:"file_path"`
	DisplayName           string `json:"display_name"`
	OldPath               string `json:"old_path,omitempty"`
	NewPath               string `json:"new_path,omitempty"`
	ChangeType            string `json:"change_type"`
	Additions             int    `json:"additions,omitempty"`
	Deletions             int    `json:"deletions,omitempty"`
	UnifiedDiff           string `json:"unified_diff,omitempty"`
	DiffUnavailableReason string `json:"diff_unavailable_reason,omitempty"`
	Truncated             bool   `json:"truncated,omitempty"`
}

type FileReadArgs

type FileReadArgs struct {
	FilePath string `json:"file_path"`
	Offset   int    `json:"offset,omitempty"`
	Limit    int    `json:"limit,omitempty"`
}

type FileReadResult

type FileReadResult struct {
	FilePath    string `json:"file_path"`
	DisplayName string `json:"display_name"`
	Content     string `json:"content"`
	LineOffset  int    `json:"line_offset,omitempty"`
	LineCount   int    `json:"line_count,omitempty"`
	TotalLines  int    `json:"total_lines,omitempty"`
	Truncated   bool   `json:"truncated,omitempty"`
}

type FileWriteArgs

type FileWriteArgs struct {
	FilePath string `json:"file_path"`
	Content  string `json:"content"`
}

type FlowerActivityFileAction added in v0.7.1

type FlowerActivityFileAction struct {
	ActionID      string `json:"action_id"`
	DisplayName   string `json:"display_name"`
	PreviewPath   string `json:"preview_path,omitempty"`
	DirectoryPath string `json:"directory_path,omitempty"`
}

type FlowerApprovalAction added in v0.7.1

type FlowerApprovalAction struct {
	ActionID            string                            `json:"action_id"`
	Origin              FlowerApprovalOrigin              `json:"origin"`
	RunID               string                            `json:"run_id,omitempty"`
	TurnID              string                            `json:"turn_id,omitempty"`
	StepID              string                            `json:"step_id,omitempty"`
	ToolID              string                            `json:"tool_id,omitempty"`
	ToolName            string                            `json:"tool_name"`
	State               FlowerApprovalState               `json:"state"`
	Status              FlowerApprovalStatus              `json:"status"`
	Revision            int64                             `json:"revision"`
	Version             int64                             `json:"version"`
	SurfaceEpoch        int64                             `json:"surface_epoch,omitempty"`
	SurfaceRole         FlowerApprovalSurfaceRole         `json:"surface_role,omitempty"`
	Scope               string                            `json:"scope,omitempty"`
	RequestedAtMs       int64                             `json:"requested_at_unix_ms"`
	ResolvedAtMs        int64                             `json:"resolved_at_unix_ms,omitempty"`
	ExpiresAtMs         int64                             `json:"expires_at_unix_ms,omitempty"`
	CanApprove          bool                              `json:"can_approve"`
	ExpectedSeq         int64                             `json:"expected_seq,omitempty"`
	ReadOnlyReason      string                            `json:"read_only_reason,omitempty"`
	DelegatedRef        *DelegatedApprovalRef             `json:"delegated_ref,omitempty"`
	DeliveryState       FlowerApprovalDeliveryState       `json:"delivery_state,omitempty"`
	ChildExecutionState FlowerApprovalChildExecutionState `json:"child_execution_state,omitempty"`
	PrimaryWaitAnchor   string                            `json:"primary_wait_anchor,omitempty"`
	Summary             FlowerApprovalSummary             `json:"summary"`
}

type FlowerApprovalChildExecutionState added in v0.7.2

type FlowerApprovalChildExecutionState string
const (
	FlowerApprovalChildExecutionUnknown   FlowerApprovalChildExecutionState = "unknown"
	FlowerApprovalChildExecutionPending   FlowerApprovalChildExecutionState = "pending"
	FlowerApprovalChildExecutionRunning   FlowerApprovalChildExecutionState = "running"
	FlowerApprovalChildExecutionSucceeded FlowerApprovalChildExecutionState = "succeeded"
	FlowerApprovalChildExecutionFailed    FlowerApprovalChildExecutionState = "failed"
	FlowerApprovalChildExecutionCanceled  FlowerApprovalChildExecutionState = "canceled"
)

type FlowerApprovalDeliveryState added in v0.7.2

type FlowerApprovalDeliveryState string
const (
	FlowerApprovalDeliveryWaiting     FlowerApprovalDeliveryState = "waiting_decision"
	FlowerApprovalDeliveryPending     FlowerApprovalDeliveryState = "delivery_pending"
	FlowerApprovalDeliveryDelivered   FlowerApprovalDeliveryState = "delivery_delivered"
	FlowerApprovalDeliveryFailed      FlowerApprovalDeliveryState = "delivery_failed"
	FlowerApprovalDeliveryAckUnknown  FlowerApprovalDeliveryState = "delivery_ack_unknown"
	FlowerApprovalDeliveryUnavailable FlowerApprovalDeliveryState = "delivery_unavailable"
)

type FlowerApprovalOrigin added in v0.7.2

type FlowerApprovalOrigin string
const (
	FlowerApprovalOriginMainTool          FlowerApprovalOrigin = "main_tool"
	FlowerApprovalOriginDelegatedSubagent FlowerApprovalOrigin = "delegated_subagent"
	FlowerApprovalOriginControlConfirm    FlowerApprovalOrigin = "control_confirm"
)

type FlowerApprovalState added in v0.7.1

type FlowerApprovalState string
const (
	FlowerApprovalStateRequested   FlowerApprovalState = "requested"
	FlowerApprovalStateApproved    FlowerApprovalState = "approved"
	FlowerApprovalStateRejected    FlowerApprovalState = "rejected"
	FlowerApprovalStateTimedOut    FlowerApprovalState = "timed_out"
	FlowerApprovalStateCanceled    FlowerApprovalState = "canceled"
	FlowerApprovalStateUnavailable FlowerApprovalState = "unavailable"
)

type FlowerApprovalStatus added in v0.7.1

type FlowerApprovalStatus string
const (
	FlowerApprovalStatusPending     FlowerApprovalStatus = "pending"
	FlowerApprovalStatusResolved    FlowerApprovalStatus = "resolved"
	FlowerApprovalStatusUnavailable FlowerApprovalStatus = "unavailable"
)

type FlowerApprovalSummary added in v0.7.1

type FlowerApprovalSummary struct {
	Label       string             `json:"label"`
	Description string             `json:"description,omitempty"`
	Command     string             `json:"command,omitempty"`
	Cwd         string             `json:"cwd,omitempty"`
	Effects     []string           `json:"effects,omitempty"`
	Flags       []string           `json:"flags,omitempty"`
	Targets     []FlowerSafeTarget `json:"targets,omitempty"`
}

type FlowerApprovalSurfaceRole added in v0.7.2

type FlowerApprovalSurfaceRole string
const (
	FlowerApprovalSurfacePrimaryAction FlowerApprovalSurfaceRole = "primary_action"
	FlowerApprovalSurfaceLocator       FlowerApprovalSurfaceRole = "locator"
	FlowerApprovalSurfaceMirror        FlowerApprovalSurfaceRole = "mirror"
)

type FlowerContextCompaction added in v0.7.2

type FlowerContextCompaction struct {
	OperationID         string `json:"operation_id"`
	RunID               string `json:"run_id,omitempty"`
	StepIndex           int    `json:"step_index,omitempty"`
	Phase               string `json:"phase"`
	Status              string `json:"status"`
	Trigger             string `json:"trigger,omitempty"`
	Reason              string `json:"reason,omitempty"`
	TokensBefore        int64  `json:"tokens_before,omitempty"`
	TokensAfterEstimate int64  `json:"tokens_after_estimate,omitempty"`
	Error               string `json:"error,omitempty"`
	UpdatedAtMs         int64  `json:"updated_at_ms"`
}

type FlowerContextUsage added in v0.7.2

type FlowerContextUsage struct {
	RunID                  string  `json:"run_id,omitempty"`
	StepIndex              int     `json:"step_index,omitempty"`
	Phase                  string  `json:"phase"`
	InputTokens            int64   `json:"input_tokens,omitempty"`
	ContextWindowTokens    int64   `json:"context_window_tokens,omitempty"`
	ThresholdTokens        int64   `json:"threshold_tokens,omitempty"`
	RequestSafeLimitTokens int64   `json:"request_safe_limit_tokens,omitempty"`
	OutputHeadroomTokens   int64   `json:"output_headroom_tokens,omitempty"`
	UsedRatio              float64 `json:"used_ratio,omitempty"`
	ThresholdRatio         float64 `json:"threshold_ratio,omitempty"`
	PressureStatus         string  `json:"pressure_status"`
	Source                 string  `json:"source,omitempty"`
	UpdatedAtMs            int64   `json:"updated_at_ms"`
}

type FlowerFileActionOpenRequest added in v0.7.1

type FlowerFileActionOpenRequest struct {
	ThreadID   string `json:"thread_id,omitempty"`
	MessageID  string `json:"message_id"`
	BlockIndex int    `json:"block_index"`
	ItemID     string `json:"item_id"`
	ActionID   string `json:"action_id"`
	Action     string `json:"action"`
}

type FlowerFileActionOpenTarget added in v0.7.1

type FlowerFileActionOpenTarget struct {
	ActionID string `json:"action_id"`
	Action   string `json:"action"`
	Path     string `json:"path"`
}

func ResolveFlowerFileActionOpenTargetFromMessages added in v0.7.1

func ResolveFlowerFileActionOpenTargetFromMessages(values []any, req FlowerFileActionOpenRequest) (FlowerFileActionOpenTarget, bool, error)

type FlowerLiveApprovalPayload added in v0.7.1

type FlowerLiveApprovalPayload struct {
	Action FlowerApprovalAction `json:"action"`
}

type FlowerLiveBlock added in v0.7.1

type FlowerLiveBlock struct {
	Type    string          `json:"type"`
	Content string          `json:"content,omitempty"`
	Block   json.RawMessage `json:"block,omitempty"`
}

type FlowerLiveBootstrapResponse added in v0.7.1

type FlowerLiveBootstrapResponse struct {
	SchemaVersion    int64                       `json:"schema_version"`
	EndpointID       string                      `json:"endpoint_id"`
	ThreadID         string                      `json:"thread_id"`
	StreamGeneration int64                       `json:"stream_generation"`
	Cursor           int64                       `json:"cursor"`
	RetainedFromSeq  int64                       `json:"retained_from_seq"`
	Thread           ThreadView                  `json:"thread"`
	TimelineMessages []FlowerTimelineMessage     `json:"timeline_messages"`
	LiveState        FlowerLiveMaterializedState `json:"live_state"`
	ReadStatus       FlowerThreadReadView        `json:"read_status"`
	GeneratedAtMs    int64                       `json:"generated_at_unix_ms"`
}

type FlowerLiveContextCompactionUpdatedPayload added in v0.7.2

type FlowerLiveContextCompactionUpdatedPayload struct {
	Compaction         FlowerContextCompaction  `json:"compaction"`
	TimelineDecoration FlowerTimelineDecoration `json:"timeline_decoration"`
}

type FlowerLiveEvent added in v0.7.1

type FlowerLiveEvent struct {
	SchemaVersion int64           `json:"schema_version"`
	Seq           int64           `json:"seq"`
	EndpointID    string          `json:"endpoint_id"`
	ThreadID      string          `json:"thread_id"`
	RunID         string          `json:"run_id,omitempty"`
	TurnID        string          `json:"turn_id,omitempty"`
	TraceID       string          `json:"trace_id,omitempty"`
	Step          string          `json:"step,omitempty"`
	AtUnixMs      int64           `json:"at_unix_ms"`
	Kind          FlowerLiveKind  `json:"kind"`
	Payload       json.RawMessage `json:"payload"`
}

type FlowerLiveEventsResponse added in v0.7.1

type FlowerLiveEventsResponse struct {
	StreamGeneration int64             `json:"stream_generation"`
	Events           []FlowerLiveEvent `json:"events"`
	NextCursor       int64             `json:"next_cursor"`
	HasMore          bool              `json:"has_more,omitempty"`
	RetainedFromSeq  int64             `json:"retained_from_seq"`
}

type FlowerLiveInputRequestedPayload added in v0.7.1

type FlowerLiveInputRequestedPayload struct {
	Request RequestUserInputPrompt `json:"request"`
}

type FlowerLiveInputResolvedPayload added in v0.7.1

type FlowerLiveInputResolvedPayload struct {
	PromptID string `json:"prompt_id"`
}

type FlowerLiveKind added in v0.7.1

type FlowerLiveKind string
const (
	FlowerLiveRunStarted               FlowerLiveKind = "run.started"
	FlowerLiveRunStatusChanged         FlowerLiveKind = "run.status_changed"
	FlowerLiveThreadPatched            FlowerLiveKind = "thread.patched"
	FlowerLiveMessageStarted           FlowerLiveKind = "message.started"
	FlowerLiveMessageBlockStart        FlowerLiveKind = "message.block_started"
	FlowerLiveMessageBlockDelta        FlowerLiveKind = "message.block_delta"
	FlowerLiveMessageBlockSet          FlowerLiveKind = "message.block_set"
	FlowerLiveMessageCommitted         FlowerLiveKind = "message.committed"
	FlowerLiveMessageFailed            FlowerLiveKind = "message.failed"
	FlowerLiveApprovalRequested        FlowerLiveKind = "approval.requested"
	FlowerLiveApprovalResolved         FlowerLiveKind = "approval.resolved"
	FlowerLiveInputRequested           FlowerLiveKind = "input.requested"
	FlowerLiveInputResolved            FlowerLiveKind = "input.resolved"
	FlowerLiveModelIOUpdated           FlowerLiveKind = "model_io.updated"
	FlowerLiveContextUsageUpdated      FlowerLiveKind = "context.usage.updated"
	FlowerLiveContextCompactionUpdated FlowerLiveKind = "context.compaction.updated"
	FlowerLiveTimelineReplaced         FlowerLiveKind = "timeline.replaced"
	FlowerLiveResyncRequired           FlowerLiveKind = "stream.resync_required"
)

type FlowerLiveMaterializedState added in v0.7.1

type FlowerLiveMaterializedState struct {
	ThreadPatch         FlowerLiveThreadPatch             `json:"thread_patch"`
	Messages            map[string]FlowerLiveMessageDraft `json:"-"`
	Runs                map[string]FlowerLiveRunState     `json:"runs"`
	ModelIO             *FlowerModelIOStatus              `json:"model_io,omitempty"`
	ContextUsage        *FlowerContextUsage               `json:"context_usage,omitempty"`
	ContextCompactions  []FlowerContextCompaction         `json:"context_compactions,omitempty"`
	TimelineDecorations []FlowerTimelineDecoration        `json:"timeline_decorations,omitempty"`
	ApprovalActions     map[string]FlowerApprovalAction   `json:"approval_actions"`
	ApprovalActionsSeen bool                              `json:"-"`
	InputRequests       map[string]RequestUserInputPrompt `json:"input_requests"`
}

func (FlowerLiveMaterializedState) MarshalJSON added in v0.7.2

func (s FlowerLiveMaterializedState) MarshalJSON() ([]byte, error)

func (*FlowerLiveMaterializedState) UnmarshalJSON added in v0.7.2

func (s *FlowerLiveMaterializedState) UnmarshalJSON(data []byte) error

type FlowerLiveMessageBlockDeltaPayload added in v0.7.1

type FlowerLiveMessageBlockDeltaPayload struct {
	MessageID  string `json:"message_id"`
	BlockIndex int    `json:"block_index"`
	Delta      string `json:"delta"`
}

type FlowerLiveMessageBlockSetPayload added in v0.7.1

type FlowerLiveMessageBlockSetPayload struct {
	MessageID  string `json:"message_id"`
	BlockIndex int    `json:"block_index"`
	Block      any    `json:"block"`
}

type FlowerLiveMessageBlockStartedPayload added in v0.7.1

type FlowerLiveMessageBlockStartedPayload struct {
	MessageID  string `json:"message_id"`
	BlockIndex int    `json:"block_index"`
	BlockType  string `json:"block_type"`
}

type FlowerLiveMessageCommittedPayload added in v0.7.1

type FlowerLiveMessageCommittedPayload struct {
	MessageID string          `json:"message_id"`
	Message   json.RawMessage `json:"message"`
}

type FlowerLiveMessageDraft added in v0.7.1

type FlowerLiveMessageDraft struct {
	MessageID   string            `json:"message_id"`
	Role        string            `json:"role"`
	Status      string            `json:"status"`
	CreatedAtMs int64             `json:"created_at_ms"`
	Blocks      []FlowerLiveBlock `json:"blocks"`
}

type FlowerLiveMessageFailedPayload added in v0.7.1

type FlowerLiveMessageFailedPayload struct {
	MessageID string `json:"message_id"`
	Error     string `json:"error"`
}

type FlowerLiveMessageStartedPayload added in v0.7.1

type FlowerLiveMessageStartedPayload struct {
	MessageID   string `json:"message_id"`
	Role        string `json:"role"`
	Status      string `json:"status"`
	CreatedAtMs int64  `json:"created_at_ms"`
}

type FlowerLiveModelIOUpdatedPayload added in v0.7.2

type FlowerLiveModelIOUpdatedPayload struct {
	Status *FlowerModelIOStatus `json:"status"`
}

type FlowerLiveResyncRequiredPayload added in v0.7.1

type FlowerLiveResyncRequiredPayload struct {
	Reason string `json:"reason"`
}

type FlowerLiveRunStartedPayload added in v0.7.1

type FlowerLiveRunStartedPayload struct {
	RunID     string `json:"run_id"`
	TurnID    string `json:"turn_id,omitempty"`
	MessageID string `json:"message_id,omitempty"`
	Status    string `json:"status"`
	ModelID   string `json:"model_id,omitempty"`
}

type FlowerLiveRunState added in v0.7.1

type FlowerLiveRunState struct {
	RunID         string                  `json:"run_id"`
	Status        string                  `json:"status"`
	MessageID     string                  `json:"message_id,omitempty"`
	WaitingPrompt *RequestUserInputPrompt `json:"waiting_prompt,omitempty"`
	ErrorCode     string                  `json:"error_code,omitempty"`
	Error         string                  `json:"error,omitempty"`
}

type FlowerLiveRunStatusChangedPayload added in v0.7.1

type FlowerLiveRunStatusChangedPayload struct {
	RunID         string                  `json:"run_id"`
	Status        string                  `json:"status"`
	ErrorCode     string                  `json:"error_code,omitempty"`
	Error         string                  `json:"error,omitempty"`
	WaitingPrompt *RequestUserInputPrompt `json:"waiting_prompt,omitempty"`
}

type FlowerLiveThreadPatch added in v0.7.1

type FlowerLiveThreadPatch struct {
	ThreadID               string                        `json:"thread_id,omitempty"`
	Title                  string                        `json:"title,omitempty"`
	ModelID                string                        `json:"model_id,omitempty"`
	PermissionType         string                        `json:"permission_type,omitempty"`
	WorkingDir             string                        `json:"working_dir,omitempty"`
	QueuedTurnCount        *int                          `json:"queued_turn_count,omitempty"`
	RunStatus              string                        `json:"run_status,omitempty"`
	RunUpdatedAtUnixMs     int64                         `json:"run_updated_at_unix_ms,omitempty"`
	RunErrorCode           string                        `json:"run_error_code,omitempty"`
	RunError               string                        `json:"run_error,omitempty"`
	WaitingPrompt          *RequestUserInputPrompt       `json:"waiting_prompt,omitempty"`
	LastContextRunID       string                        `json:"last_context_run_id,omitempty"`
	PinnedAtUnixMs         int64                         `json:"pinned_at_unix_ms,omitempty"`
	CreatedAtUnixMs        int64                         `json:"created_at_unix_ms,omitempty"`
	UpdatedAtUnixMs        int64                         `json:"updated_at_unix_ms,omitempty"`
	LastMessageAtUnixMs    int64                         `json:"last_message_at_unix_ms,omitempty"`
	LastMessagePreview     string                        `json:"last_message_preview,omitempty"`
	ReasoningSelection     *config.AIReasoningSelection  `json:"reasoning_selection,omitempty"`
	ReasoningCapability    *config.AIReasoningCapability `json:"reasoning_capability,omitempty"`
	ReasoningSelectionSet  bool                          `json:"-"`
	ReasoningCapabilitySet bool                          `json:"-"`
	ReadStatus             *FlowerThreadReadView         `json:"read_status,omitempty"`
	Subagents              []FlowerSubagentSummary       `json:"subagents,omitempty"`
	SubagentsSet           bool                          `json:"-"`
}

func (FlowerLiveThreadPatch) MarshalJSON added in v0.7.2

func (p FlowerLiveThreadPatch) MarshalJSON() ([]byte, error)

func (*FlowerLiveThreadPatch) UnmarshalJSON added in v0.7.2

func (p *FlowerLiveThreadPatch) UnmarshalJSON(data []byte) error

type FlowerLiveThreadPatchedPayload added in v0.7.1

type FlowerLiveThreadPatchedPayload struct {
	Patch FlowerLiveThreadPatch `json:"patch"`
}

type FlowerLiveTimelineReplacedPayload added in v0.7.1

type FlowerLiveTimelineReplacedPayload struct {
	Messages            []FlowerTimelineMessage     `json:"messages"`
	StreamGeneration    int64                       `json:"stream_generation"`
	SnapshotThroughSeq  int64                       `json:"snapshot_through_seq"`
	ThreadPatch         FlowerLiveThreadPatch       `json:"thread_patch"`
	LiveState           FlowerLiveMaterializedState `json:"live_state"`
	ContextUsage        *FlowerContextUsage         `json:"context_usage"`
	ContextCompactions  []FlowerContextCompaction   `json:"context_compactions"`
	TimelineDecorations []FlowerTimelineDecoration  `json:"timeline_decorations"`
}

type FlowerLiveUsageUpdatedPayload added in v0.7.1

type FlowerLiveUsageUpdatedPayload struct {
	Usage FlowerContextUsage `json:"usage"`
}

type FlowerModelIOPhase added in v0.7.2

type FlowerModelIOPhase string
const (
	FlowerModelIOPhasePreparing       FlowerModelIOPhase = "preparing"
	FlowerModelIOPhaseWaitingResponse FlowerModelIOPhase = "waiting_response"
	FlowerModelIOPhaseStreaming       FlowerModelIOPhase = "streaming"
	FlowerModelIOPhaseRetrying        FlowerModelIOPhase = "retrying"
	FlowerModelIOPhaseFinalizing      FlowerModelIOPhase = "finalizing"
)

type FlowerModelIOStatus added in v0.7.2

type FlowerModelIOStatus struct {
	Phase       FlowerModelIOPhase `json:"phase"`
	RunID       string             `json:"run_id,omitempty"`
	StepIndex   int                `json:"step_index,omitempty"`
	UpdatedAtMs int64              `json:"updated_at_ms"`
}

type FlowerPermissionType added in v0.7.2

type FlowerPermissionType string
const (
	FlowerPermissionReadonly         FlowerPermissionType = "readonly"
	FlowerPermissionApprovalRequired FlowerPermissionType = "approval_required"
	FlowerPermissionFullAccess       FlowerPermissionType = "full_access"
)

type FlowerSafeTarget added in v0.7.1

type FlowerSafeTarget struct {
	Kind  string `json:"kind"`
	Label string `json:"label"`
	URI   string `json:"uri,omitempty"`
}

type FlowerSubagentApprovalView added in v0.7.2

type FlowerSubagentApprovalView struct {
	State    string            `json:"state,omitempty"`
	ToolID   string            `json:"tool_id,omitempty"`
	ToolName string            `json:"tool_name,omitempty"`
	ToolKind string            `json:"tool_kind,omitempty"`
	ArgsHash string            `json:"args_hash,omitempty"`
	Reason   string            `json:"reason,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

type FlowerSubagentCompactionView added in v0.7.2

type FlowerSubagentCompactionView struct {
	Trigger             string            `json:"trigger,omitempty"`
	Reason              string            `json:"reason,omitempty"`
	Phase               string            `json:"phase,omitempty"`
	TokensBefore        int64             `json:"tokens_before,omitempty"`
	TokensAfterEstimate int64             `json:"tokens_after_estimate,omitempty"`
	Metadata            map[string]string `json:"metadata,omitempty"`
}

type FlowerSubagentDetailMessage added in v0.7.2

type FlowerSubagentDetailMessage struct {
	Role    string `json:"role,omitempty"`
	Text    string `json:"text,omitempty"`
	Preview string `json:"preview,omitempty"`
}

type FlowerSubagentDetailResponse added in v0.7.2

type FlowerSubagentDetailResponse struct {
	Summary             FlowerSubagentSummary       `json:"summary"`
	Timeline            []FlowerSubagentTimelineRow `json:"timeline"`
	Activity            *ActivityTimelineBlock      `json:"activity,omitempty"`
	ModelIOStatus       *FlowerModelIOStatus        `json:"model_io_status,omitempty"`
	ContextUsage        *FlowerContextUsage         `json:"context_usage,omitempty"`
	ContextCompactions  []FlowerContextCompaction   `json:"context_compactions,omitempty"`
	TimelineDecorations []FlowerTimelineDecoration  `json:"timeline_decorations,omitempty"`
	NextOrdinal         int64                       `json:"next_ordinal,omitempty"`
	HasMore             bool                        `json:"has_more,omitempty"`
	RetainedFrom        int64                       `json:"retained_from,omitempty"`
	GeneratedAtMs       int64                       `json:"generated_at_ms"`
}

type FlowerSubagentGenericView added in v0.7.2

type FlowerSubagentGenericView struct {
	Title    string            `json:"title,omitempty"`
	Body     string            `json:"body,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

type FlowerSubagentSummary added in v0.7.2

type FlowerSubagentSummary struct {
	ParentThreadID  string `json:"parent_thread_id"`
	SubagentID      string `json:"subagent_id"`
	ThreadID        string `json:"thread_id"`
	TaskName        string `json:"task_name,omitempty"`
	TaskDescription string `json:"task_description,omitempty"`
	Title           string `json:"title,omitempty"`
	AgentType       string `json:"agent_type,omitempty"`
	ContextMode     string `json:"context_mode,omitempty"`
	Status          string `json:"status"`
	LastMessage     string `json:"last_message,omitempty"`
	WaitingPrompt   string `json:"waiting_prompt,omitempty"`
	QueuedInputs    int    `json:"queued_inputs,omitempty"`
	CanSendInput    bool   `json:"can_send_input"`
	CanInterrupt    bool   `json:"can_interrupt"`
	CanClose        bool   `json:"can_close"`
	CreatedAtUnixMs int64  `json:"created_at_ms,omitempty"`
	UpdatedAtUnixMs int64  `json:"updated_at_ms,omitempty"`
}

type FlowerSubagentTimelineRow added in v0.7.2

type FlowerSubagentTimelineRow struct {
	Ordinal     int64                         `json:"ordinal"`
	Kind        string                        `json:"kind"`
	Type        string                        `json:"type,omitempty"`
	CreatedAtMs int64                         `json:"created_at_ms"`
	Message     *FlowerSubagentDetailMessage  `json:"message,omitempty"`
	ToolCall    *FlowerSubagentToolCallView   `json:"tool_call,omitempty"`
	ToolResult  *FlowerSubagentToolResultView `json:"tool_result,omitempty"`
	Approval    *FlowerSubagentApprovalView   `json:"approval,omitempty"`
	TurnMarker  *FlowerSubagentTurnMarkerView `json:"turn_marker,omitempty"`
	Compaction  *FlowerSubagentCompactionView `json:"compaction,omitempty"`
	Generic     *FlowerSubagentGenericView    `json:"generic,omitempty"`
	Error       string                        `json:"error,omitempty"`
	Metadata    map[string]string             `json:"metadata,omitempty"`
}

type FlowerSubagentToolCallView added in v0.7.2

type FlowerSubagentToolCallView struct {
	ID          string `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	ArgsPreview string `json:"args_preview,omitempty"`
	ArgsHash    string `json:"args_hash,omitempty"`
}

type FlowerSubagentToolResultView added in v0.7.2

type FlowerSubagentToolResultView struct {
	CallID        string `json:"call_id,omitempty"`
	ToolName      string `json:"tool_name,omitempty"`
	Status        string `json:"status,omitempty"`
	Preview       string `json:"preview,omitempty"`
	Truncated     bool   `json:"truncated,omitempty"`
	OriginalBytes int    `json:"original_bytes,omitempty"`
	VisibleBytes  int    `json:"visible_bytes,omitempty"`
	OriginalLines int    `json:"original_lines,omitempty"`
	VisibleLines  int    `json:"visible_lines,omitempty"`
	Strategy      string `json:"strategy,omitempty"`
	ContentSHA256 string `json:"content_sha256,omitempty"`
}

type FlowerSubagentTurnMarkerView added in v0.7.2

type FlowerSubagentTurnMarkerView struct {
	Status   string            `json:"status,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

type FlowerThreadReadRecord added in v0.7.1

type FlowerThreadReadRecord struct {
	LastSeenActivityRevision  int64  `json:"last_seen_activity_revision"`
	LastReadMessageAtUnixMs   int64  `json:"last_read_message_at_unix_ms"`
	LastSeenActivitySignature string `json:"last_seen_activity_signature"`
	LastSeenWaitingPromptID   string `json:"last_seen_waiting_prompt_id,omitempty"`
}

type FlowerThreadReadSnapshot added in v0.7.1

type FlowerThreadReadSnapshot struct {
	ActivityRevision    int64  `json:"activity_revision"`
	LastMessageAtUnixMs int64  `json:"last_message_at_unix_ms"`
	ActivitySignature   string `json:"activity_signature"`
	WaitingPromptID     string `json:"waiting_prompt_id,omitempty"`
}

type FlowerThreadReadView added in v0.7.1

type FlowerThreadReadView struct {
	IsUnread  bool                     `json:"is_unread"`
	Snapshot  FlowerThreadReadSnapshot `json:"snapshot"`
	ReadState FlowerThreadReadRecord   `json:"read_state"`
}

type FlowerTimelineAnchor added in v0.7.2

type FlowerTimelineAnchor struct {
	TargetKind     string `json:"target_kind"`
	MessageID      string `json:"message_id"`
	BlockIndex     *int   `json:"block_index,omitempty"`
	ActivityItemID string `json:"activity_item_id,omitempty"`
	Edge           string `json:"edge"`
}

type FlowerTimelineDecoration added in v0.7.2

type FlowerTimelineDecoration struct {
	DecorationID string                  `json:"decoration_id"`
	Kind         string                  `json:"kind"`
	Anchor       FlowerTimelineAnchor    `json:"anchor"`
	Ordinal      int                     `json:"ordinal"`
	Compaction   FlowerContextCompaction `json:"compaction"`
}

type FlowerTimelineMessage added in v0.7.1

type FlowerTimelineMessage struct {
	MessageID     string `json:"id"`
	Role          string `json:"role"`
	Content       string `json:"content"`
	Status        string `json:"status"`
	CreatedAtMs   int64  `json:"created_at_ms"`
	Blocks        []any  `json:"blocks,omitempty"`
	ContextAction any    `json:"context_action,omitempty"`
	Live          bool   `json:"live"`
	ActiveCursor  bool   `json:"active_cursor"`
}

type FollowupAttachmentView

type FollowupAttachmentView struct {
	Name     string `json:"name"`
	MimeType string `json:"mime_type"`
	URL      string `json:"url,omitempty"`
}

type FollowupItemView

type FollowupItemView struct {
	FollowupID      string                   `json:"followup_id"`
	Lane            string                   `json:"lane"`
	MessageID       string                   `json:"message_id"`
	Text            string                   `json:"text"`
	ModelID         string                   `json:"model_id,omitempty"`
	PermissionType  string                   `json:"permission_type,omitempty"`
	Position        int                      `json:"position"`
	CreatedAtUnixMs int64                    `json:"created_at_unix_ms"`
	Attachments     []FollowupAttachmentView `json:"attachments,omitempty"`
	ContextAction   *ContextActionEnvelope   `json:"context_action,omitempty"`
}

type InMemoryToolRegistry

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

func NewInMemoryToolRegistry

func NewInMemoryToolRegistry() *InMemoryToolRegistry

func (*InMemoryToolRegistry) Register

func (r *InMemoryToolRegistry) Register(tool ToolDef, handler ToolHandler) error

func (*InMemoryToolRegistry) Snapshot

func (r *InMemoryToolRegistry) Snapshot() []ToolDef

func (*InMemoryToolRegistry) Unregister

func (r *InMemoryToolRegistry) Unregister(name string) error

type ListFollowupsResponse

type ListFollowupsResponse struct {
	Revision     int64              `json:"revision"`
	PausedReason string             `json:"paused_reason,omitempty"`
	Queued       []FollowupItemView `json:"queued"`
	Drafts       []FollowupItemView `json:"drafts"`
}

type ListRunEventsQuery

type ListRunEventsQuery struct {
	Cursor   int64
	Limit    int
	Category string
}

type ListRunEventsResponse

type ListRunEventsResponse struct {
	Events     []RunEventView `json:"events"`
	NextCursor int64          `json:"next_cursor,omitempty"`
	HasMore    bool           `json:"has_more,omitempty"`
}

type ListThreadMessagesResponse

type ListThreadMessagesResponse struct {
	Messages      []any `json:"messages"`
	NextBeforeID  int64 `json:"next_before_id,omitempty"`
	HasMore       bool  `json:"has_more,omitempty"`
	TotalReturned int   `json:"total_returned,omitempty"`
}

type ListThreadsResponse

type ListThreadsResponse struct {
	Threads    []ThreadView `json:"threads"`
	NextCursor string       `json:"next_cursor,omitempty"`
}

type LocalToolExecutionOptions added in v0.7.1

type LocalToolExecutionOptions struct {
	Logger          *slog.Logger
	StateDir        string
	AgentHomeDir    string
	WorkingDir      string
	FilesystemScope *filesystemscope.Registry
	Shell           string
	AIConfig        *config.AIConfig
	SessionMeta     *session.Meta
	ToolCallID      string
	ToolName        string
	Arguments       json.RawMessage
	Timeout         time.Duration
}

type LocalToolExecutionResult added in v0.7.1

type LocalToolExecutionResult struct {
	ToolCallID string `json:"tool_call_id"`
	ToolName   string `json:"tool_name"`
	Result     any    `json:"result,omitempty"`
}

func ExecuteLocalTool added in v0.7.1

type LoopDetector

type LoopDetector interface {
	Detect(ctx context.Context, window []TurnSnapshot) (hit bool, reason string, confidence float64)
}

type Message

type Message struct {
	Role    string        `json:"role"`
	Content []ContentPart `json:"content"`
}

type ModeFlags

type ModeFlags struct {
	ReasoningOnly bool `json:"reasoning_only,omitempty"`
}

type Model

type Model struct {
	ID                  string                       `json:"id"`
	Label               string                       `json:"label,omitempty"`
	Source              string                       `json:"source,omitempty"`
	SourceLabel         string                       `json:"source_label,omitempty"`
	ContextWindow       int                          `json:"context_window,omitempty"`
	MaxOutputTokens     int                          `json:"max_output_tokens,omitempty"`
	InputModalities     []string                     `json:"input_modalities,omitempty"`
	SupportsImageInput  bool                         `json:"supports_image_input,omitempty"`
	ReasoningCapability config.AIReasoningCapability `json:"reasoning_capability,omitempty"`
}

type ModelGateway added in v0.7.1

type ModelGateway interface {
	StreamTurn(ctx context.Context, req ModelGatewayRequest, onEvent func(StreamEvent)) (ModelGatewayResult, error)
}

ModelGateway streams one provider request for a Floret hosted turn.

type ModelGatewayRequest added in v0.7.1

type ModelGatewayRequest struct {
	Model            string           `json:"model"`
	Messages         []Message        `json:"messages"`
	Tools            []ToolDef        `json:"tools"`
	Budgets          TurnBudgets      `json:"budgets"`
	ModeFlags        ModeFlags        `json:"mode_flags"`
	ProviderControls ProviderControls `json:"provider_controls,omitempty"`
	WebSearchMode    string           `json:"web_search_mode,omitempty"`
}

type ModelGatewayResult added in v0.7.1

type ModelGatewayResult struct {
	FinishReason    string             `json:"finish_reason"`
	Text            string             `json:"text,omitempty"`
	Reasoning       string             `json:"reasoning,omitempty"`
	ToolCalls       []ToolCall         `json:"tool_calls,omitempty"`
	Sources         []SourceRef        `json:"sources,omitempty"`
	Usage           TurnUsage          `json:"usage,omitempty"`
	ProviderState   *ModelGatewayState `json:"provider_state,omitempty"`
	RawProviderDiag map[string]any     `json:"raw_provider_diag,omitempty"`
	StreamEvents    []StreamEvent      `json:"stream_events,omitempty"`
	ToolResults     []ToolResult       `json:"tool_results,omitempty"`
}

type ModelGatewayState added in v0.7.1

type ModelGatewayState struct {
	Kind       string            `json:"kind,omitempty"`
	ID         string            `json:"id,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

type ModelSelectInput

type ModelSelectInput struct {
	Mode          string
	ReasoningOnly bool
	Configured    string
}

type ModelSelector

type ModelSelector interface {
	Select(ctx context.Context, in ModelSelectInput) (provider string, model string, reason string)
}

type ModelsResponse

type ModelsResponse struct {
	CurrentModel string           `json:"current_model"`
	Models       []Model          `json:"models"`
	Runtime      *AIRuntimeStatus `json:"runtime,omitempty"`
}

func NewModelsResponse added in v0.6.10

func NewModelsResponse(runtime *AIRuntimeStatus) *ModelsResponse

NewModelsResponse keeps the public models contract stable for empty results.

type Options

type Options struct {
	Logger   *slog.Logger
	StateDir string

	AgentHomeDir    string
	Shell           string
	FilesystemScope *filesystemscope.Registry

	Config *config.AIConfig

	ToolTargetPolicy       ToolTargetPolicy
	TargetToolExecutor     TargetToolExecutor
	ToolTargetPolicyForRun func(meta *session.Meta, thread threadstore.Thread, flowerMeta *threadstore.FlowerThreadMetadata) ToolTargetPolicy

	// PersistOpTimeout is the per-operation timeout for threadstore persistence
	// (SQLite reads/writes). It must NOT be tied to a run's overall lifetime, since
	// runs can take much longer than persistence should ever be allowed to block.
	//
	// When zero, it defaults to 10 seconds.
	PersistOpTimeout time.Duration

	// RunMaxWallTime is the hard cap for a single run's lifetime.
	//
	// When zero, it defaults to 15 minutes.
	RunMaxWallTime time.Duration
	// RunIdleTimeout cancels a run if no runtime stream activity is observed for the duration.
	//
	// When zero, it defaults to 2 minutes.
	RunIdleTimeout time.Duration
	// ToolApprovalTimeout is the max time a run waits for user approval for high-risk tools.
	//
	// When zero, it defaults to 10 minutes.
	ToolApprovalTimeout time.Duration
	// StreamWriteTimeout is the best-effort per-frame write deadline for the NDJSON stream.
	//
	// When zero, it defaults to 5 seconds.
	StreamWriteTimeout time.Duration

	// ResolveProviderAPIKey returns the API key for the given provider id.
	//
	// It should read from a local secrets store, not from config.json.
	ResolveProviderAPIKey func(providerID string) (string, bool, error)

	// ResolveWebSearchProviderAPIKey returns the API key for a provider-scoped web search backend.
	//
	// It should read from a local secrets store, not from config.json.
	ResolveWebSearchProviderAPIKey func(providerID string) (string, bool, error)
}

type PartialToolCall

type PartialToolCall struct {
	ID            string         `json:"id,omitempty"`
	Name          string         `json:"name,omitempty"`
	ArgumentsJSON string         `json:"arguments_json,omitempty"`
	Arguments     map[string]any `json:"arguments,omitempty"`
}

type PartialUsage

type PartialUsage struct {
	InputTokens     int64 `json:"input_tokens,omitempty"`
	OutputTokens    int64 `json:"output_tokens,omitempty"`
	ReasoningTokens int64 `json:"reasoning_tokens,omitempty"`
}

type PatchFollowupRequest

type PatchFollowupRequest struct {
	Text *string `json:"text,omitempty"`
}

type PatchThreadRequest

type PatchThreadRequest struct {
	Title              *string         `json:"title,omitempty"`
	ModelID            *string         `json:"model_id,omitempty"`
	PermissionType     *string         `json:"permission_type,omitempty"`
	Pinned             *bool           `json:"pinned,omitempty"`
	ReasoningSelection json.RawMessage `json:"reasoning_selection,omitempty"`
}

type PendingToolResult added in v0.7.2

type PendingToolResult struct {
	Handle      string            `json:"handle"`
	Summary     string            `json:"summary"`
	Instruction string            `json:"instruction"`
	Metadata    map[string]string `json:"metadata,omitempty"`
}

type PermissionSnapshot added in v0.7.2

type PermissionSnapshot struct {
	SnapshotID            string
	PermissionType        FlowerPermissionType
	VisibleToolNames      []string
	PromptCapabilityNames []string
	FloretToolNames       []string
	ToolPolicies          map[string]ToolPermissionPolicy
	SnapshotHash          string
	RegistryHash          string
	SchemaHash            string
	PresentationHash      string
}

type PermissionToolFilter added in v0.7.2

type PermissionToolFilter interface {
	FilterTools(permissionType FlowerPermissionType, all []ToolDef) []ToolDef
}

type ProviderControls

type ProviderControls struct {
	ReasoningSelection  config.AIReasoningSelection  `json:"reasoning_selection,omitempty"`
	ReasoningCapability config.AIReasoningCapability `json:"reasoning_capability,omitempty"`
	CacheControl        string                       `json:"cache_control,omitempty"`
	ResponseFormat      string                       `json:"response_format,omitempty"`
	PreviousResponseID  string                       `json:"previous_response_id,omitempty"`
	Temperature         *float64                     `json:"temperature,omitempty"`
	TopP                *float64                     `json:"top_p,omitempty"`
}

type QueuedTurnView added in v0.7.2

type QueuedTurnView struct {
	MessageID       string                 `json:"message_id"`
	Text            string                 `json:"text"`
	CreatedAtUnixMs int64                  `json:"created_at_unix_ms"`
	ContextAction   *ContextActionEnvelope `json:"context_action,omitempty"`
}

type RealtimeEvent

type RealtimeEvent struct {
	EventType     RealtimeEventType       `json:"event_type"`
	EndpointID    string                  `json:"endpoint_id"`
	ThreadID      string                  `json:"thread_id"`
	RunID         string                  `json:"run_id"`
	AtUnixMs      int64                   `json:"at_unix_ms"`
	StreamKind    RealtimeStreamKind      `json:"stream_kind,omitempty"`
	Phase         RealtimeLifecyclePhase  `json:"phase,omitempty"`
	Diag          map[string]any          `json:"diag,omitempty"`
	StreamEvent   any                     `json:"stream_event,omitempty"`
	RunStatus     string                  `json:"run_status,omitempty"`
	RunErrorCode  string                  `json:"run_error_code,omitempty"`
	RunError      string                  `json:"run_error,omitempty"`
	WaitingPrompt *RequestUserInputPrompt `json:"waiting_prompt,omitempty"`

	// Transcript message events (EventType=transcript_message).
	MessageRowID int64           `json:"message_row_id,omitempty"`
	MessageJSON  json.RawMessage `json:"message_json,omitempty"`

	// Thread summary events (EventType=thread_summary).
	Title               string                       `json:"title,omitempty"`
	ModelID             string                       `json:"model_id,omitempty"`
	UpdatedAtUnixMs     int64                        `json:"updated_at_unix_ms,omitempty"`
	LastMessagePreview  string                       `json:"last_message_preview,omitempty"`
	LastMessageAtUnixMs int64                        `json:"last_message_at_unix_ms,omitempty"`
	ActiveRunID         string                       `json:"active_run_id,omitempty"`
	LastContextRunID    string                       `json:"last_context_run_id,omitempty"`
	PermissionType      string                       `json:"permission_type,omitempty"`
	QueuedTurnCount     int                          `json:"queued_turn_count,omitempty"`
	ReasoningSelection  config.AIReasoningSelection  `json:"reasoning_selection,omitempty"`
	ReasoningCapability config.AIReasoningCapability `json:"reasoning_capability,omitempty"`

	// Transcript reset events (EventType=transcript_reset).
	ResetReason       string `json:"reset_reason,omitempty"`
	ResetCheckpointID string `json:"reset_checkpoint_id,omitempty"`
}

RealtimeEvent is emitted by the agent for cross-session AI chat collaboration.

JSON fields use snake_case because this payload is transported over Redeven RPC wire.

type RealtimeEventType

type RealtimeEventType string

RealtimeEventType defines the high-level AI event category sent over Flowersec RPC notify.

const (
	RealtimeEventTypeStream          RealtimeEventType = "stream_event"
	RealtimeEventTypeThreadState     RealtimeEventType = "thread_state"
	RealtimeEventTypeTranscript      RealtimeEventType = "transcript_message"
	RealtimeEventTypeTranscriptReset RealtimeEventType = "transcript_reset"
	RealtimeEventTypeThreadSummary   RealtimeEventType = "thread_summary"
)

type RealtimeLifecyclePhase

type RealtimeLifecyclePhase string

RealtimeLifecyclePhase marks lifecycle transitions.

const (
	RealtimePhaseStart       RealtimeLifecyclePhase = "start"
	RealtimePhaseStateChange RealtimeLifecyclePhase = "state_change"
	RealtimePhaseEnd         RealtimeLifecyclePhase = "end"
	RealtimePhaseError       RealtimeLifecyclePhase = "error"
)

type RealtimeStreamKind

type RealtimeStreamKind string

RealtimeStreamKind is a low-cardinality stream category for diagnostics/UI routing.

const (
	RealtimeStreamKindLifecycle RealtimeStreamKind = "lifecycle"
	RealtimeStreamKindAssistant RealtimeStreamKind = "assistant"
	RealtimeStreamKindTool      RealtimeStreamKind = "tool"
	RealtimeStreamKindContext   RealtimeStreamKind = "context"
)

type ReorderFollowupsRequest

type ReorderFollowupsRequest struct {
	Lane               string   `json:"lane"`
	OrderedFollowupIDs []string `json:"ordered_followup_ids"`
	ExpectedRevision   *int64   `json:"expected_revision,omitempty"`
}

type RequestUserInputAction

type RequestUserInputAction struct {
	Type string `json:"type"`
}

type RequestUserInputAnswer

type RequestUserInputAnswer struct {
	ChoiceID string `json:"choice_id,omitempty"`
	Text     string `json:"text,omitempty"`
}

type RequestUserInputChoice

type RequestUserInputChoice struct {
	ChoiceID         string                   `json:"choice_id"`
	Label            string                   `json:"label"`
	Description      string                   `json:"description,omitempty"`
	Kind             string                   `json:"kind"`
	InputPlaceholder string                   `json:"input_placeholder,omitempty"`
	Actions          []RequestUserInputAction `json:"actions,omitempty"`
}

type RequestUserInputPrompt

type RequestUserInputPrompt struct {
	PromptID           string                      `json:"prompt_id"`
	MessageID          string                      `json:"message_id"`
	ToolID             string                      `json:"tool_id"`
	ToolName           string                      `json:"tool_name"`
	ReasonCode         string                      `json:"reason_code,omitempty"`
	ReasoningSelection config.AIReasoningSelection `json:"reasoning_selection,omitempty"`
	RequiredFromUser   []string                    `json:"required_from_user,omitempty"`
	EvidenceRefs       []string                    `json:"evidence_refs,omitempty"`
	Questions          []RequestUserInputQuestion  `json:"questions,omitempty"`
	PublicSummary      string                      `json:"public_summary,omitempty"`
	ContainsSecret     bool                        `json:"contains_secret,omitempty"`
}

type RequestUserInputQuestion

type RequestUserInputQuestion struct {
	ID                string                   `json:"id"`
	Header            string                   `json:"header"`
	Question          string                   `json:"question"`
	IsSecret          bool                     `json:"is_secret"`
	ResponseMode      string                   `json:"response_mode,omitempty"`
	ChoicesExhaustive *bool                    `json:"choices_exhaustive,omitempty"`
	WriteLabel        string                   `json:"write_label,omitempty"`
	WritePlaceholder  string                   `json:"write_placeholder,omitempty"`
	Choices           []RequestUserInputChoice `json:"choices,omitempty"`
}

type RequestUserInputResolvedQuestion

type RequestUserInputResolvedQuestion struct {
	QuestionID          string `json:"question_id"`
	Header              string `json:"header,omitempty"`
	Question            string `json:"question,omitempty"`
	SelectedChoiceID    string `json:"selected_choice_id,omitempty"`
	SelectedChoiceLabel string `json:"selected_choice_label,omitempty"`
	Text                string `json:"text,omitempty"`
	PublicSummary       string `json:"public_summary,omitempty"`
	ContainsSecret      bool   `json:"contains_secret,omitempty"`
}

type RequestUserInputResponse

type RequestUserInputResponse struct {
	PromptID string                            `json:"prompt_id"`
	Answers  map[string]RequestUserInputAnswer `json:"answers"`
}

type RequestUserInputResponseRecord

type RequestUserInputResponseRecord struct {
	PromptID          string                             `json:"prompt_id"`
	ToolID            string                             `json:"tool_id,omitempty"`
	ReasonCode        string                             `json:"reason_code,omitempty"`
	Responses         []RequestUserInputResolvedQuestion `json:"responses,omitempty"`
	PublicSummary     string                             `json:"public_summary,omitempty"`
	ContainsSecret    bool                               `json:"contains_secret,omitempty"`
	ResponseMessageID string                             `json:"response_message_id,omitempty"`
}

type RequestUserInputSecretAnswer

type RequestUserInputSecretAnswer struct {
	QuestionID string `json:"question_id"`
	Text       string `json:"text,omitempty"`
}

type RunAttachmentIn

type RunAttachmentIn struct {
	Name     string `json:"name"`
	MimeType string `json:"mime_type"`
	URL      string `json:"url"`
}

type RunEventView

type RunEventView struct {
	EventID    int64  `json:"event_id"`
	RunID      string `json:"run_id"`
	ThreadID   string `json:"thread_id"`
	StreamKind string `json:"stream_kind,omitempty"`
	EventType  string `json:"event_type"`
	AtUnixMs   int64  `json:"at_unix_ms"`
	Payload    any    `json:"payload,omitempty"`
}

type RunInput

type RunInput struct {
	// MessageID is an optional client-supplied id for the user input message persisted in the transcript.
	//
	// When set, the agent will prefer this id over generating a new one so the UI can keep a stable
	// message id across optimistic rendering, realtime events, and history backfill.
	MessageID          string                          `json:"message_id,omitempty"`
	Text               string                          `json:"text"`
	Attachments        []RunAttachmentIn               `json:"attachments"`
	ContextAction      *ContextActionEnvelope          `json:"context_action,omitempty"`
	StructuredResponse *RequestUserInputResponseRecord `json:"-"`
	SecretAnswers      []RequestUserInputSecretAnswer  `json:"-"`
}

type RunOptions

type RunOptions struct {
	// ReasoningOnly relaxes tool-pressure heuristics while preserving the same Floret turn flow.
	ReasoningOnly bool `json:"reasoning_only,omitempty"`

	// RequireUserConfirmOnTaskComplete forces explicit user confirmation when model emits task_complete.
	RequireUserConfirmOnTaskComplete bool `json:"require_user_confirm_on_task_complete,omitempty"`

	// NoUserInteraction prevents direct user-input prompts for autonomous runs.
	// Tool approval waits are governed by the explicit approver/delegation policy.
	NoUserInteraction bool `json:"no_user_interaction,omitempty"`

	// ToolAllowlist is an internal runtime guard that limits the visible tool surface
	// for the current run. It is intended for runtime-owned callers such as evals and
	// subagents rather than general user-facing requests.
	ToolAllowlist []string `json:"tool_allowlist,omitempty"`

	// PermissionType controls the run tool surface and approval policy.
	PermissionType string `json:"permission_type,omitempty"`

	// Provider controls.
	ReasoningSelection config.AIReasoningSelection `json:"reasoning_selection,omitempty"`
	CacheControl       string                      `json:"cache_control,omitempty"`
	ResponseFormat     string                      `json:"response_format,omitempty"`
	Temperature        *float64                    `json:"temperature,omitempty"`
	TopP               *float64                    `json:"top_p,omitempty"`

	// Optional hard budgets (0 means unset). Input is cumulative across one run;
	// output is the maximum for each provider request.
	MaxInputTokens  int     `json:"max_input_tokens,omitempty"`
	MaxOutputTokens int     `json:"max_output_tokens,omitempty"`
	MaxCostUSD      float64 `json:"max_cost_usd,omitempty"`

	// CompactionThreshold controls when runtime compaction is triggered.
	// Value is a fraction in range [0,1]. 0 means use runtime default.
	CompactionThreshold float64 `json:"compaction_threshold,omitempty"`
}

type RunRequest

type RunRequest struct {
	Model           string                       `json:"model"`
	Objective       string                       `json:"objective,omitempty"`
	Input           RunInput                     `json:"input"`
	Options         RunOptions                   `json:"options"`
	ModelCapability contextmodel.ModelCapability `json:"-"`
}

RunRequest is the internal run request for Go runtime execution.

type RunStartRequest

type RunStartRequest struct {
	ThreadID string     `json:"thread_id"`
	Model    string     `json:"model"`
	Input    RunInput   `json:"input"`
	Options  RunOptions `json:"options"`
}

RunStartRequest is the HTTP request body for starting an AI run.

Notes: - thread_id is mandatory; the agent builds history from the persisted thread store. - history must NOT be provided by clients (agent is the source of truth).

type RunState

type RunState string

RunState is the normalized state machine for a single AI run.

const (
	RunStateIdle            RunState = "idle"
	RunStateAccepted        RunState = "accepted"
	RunStateRunning         RunState = "running"
	RunStateWaitingApproval RunState = "waiting_approval"
	RunStateRecovering      RunState = "recovering"
	RunStateFinalizing      RunState = "finalizing"
	RunStateWaitingUser     RunState = "waiting_user"
	RunStateSuccess         RunState = "success"
	RunStateFailed          RunState = "failed"
	RunStateCanceled        RunState = "canceled"
	RunStateTimedOut        RunState = "timed_out"
)

func NormalizeRunState

func NormalizeRunState(raw string) RunState

type SendUserTurnRequest

type SendUserTurnRequest struct {
	ThreadID              string     `json:"thread_id"`
	Model                 string     `json:"model,omitempty"`
	Input                 RunInput   `json:"input"`
	Options               RunOptions `json:"options"`
	ExpectedRunID         string     `json:"expected_run_id,omitempty"`
	QueueAfterWaitingUser bool       `json:"queue_after_waiting_user,omitempty"`
	SourceFollowupID      string     `json:"source_followup_id,omitempty"`
}

type SendUserTurnResponse

type SendUserTurnResponse struct {
	RunID                   string `json:"run_id"`
	Kind                    string `json:"kind"` // "start" | "queued"
	QueueID                 string `json:"queue_id,omitempty"`
	QueuePosition           int    `json:"queue_position,omitempty"`
	ConsumedWaitingPromptID string `json:"consumed_waiting_prompt_id,omitempty"`
	AppliedPermissionType   string `json:"applied_permission_type,omitempty"`
}

type Service

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

func NewService

func NewService(opts Options) (*Service, error)

func (*Service) ActiveRunCount

func (s *Service) ActiveRunCount(endpointID string) int

ActiveRunCount returns the number of active runs for the given endpoint.

When endpointID is empty, it returns the global active run count.

func (*Service) AppendThreadMessage

func (s *Service) AppendThreadMessage(ctx context.Context, meta *session.Meta, threadID string, role string, text string, format string) error

func (*Service) BrowseSkillFile

func (s *Service) BrowseSkillFile(skillPath string, file string, encoding string, maxBytes int) (*SkillBrowseFileResult, error)

func (*Service) BrowseSkillTree

func (s *Service) BrowseSkillTree(skillPath string, dir string) (*SkillBrowseTreeResult, error)

func (*Service) CancelRun

func (s *Service) CancelRun(meta *session.Meta, runID string) error

func (*Service) CancelThread

func (s *Service) CancelThread(meta *session.Meta, threadID string) error

func (*Service) ClearThreadReasoningSelection added in v0.7.2

func (s *Service) ClearThreadReasoningSelection(ctx context.Context, meta *session.Meta, threadID string) error

func (*Service) Close

func (s *Service) Close() error

func (*Service) CompactThreadContext added in v0.7.2

func (*Service) CreateSkill

func (s *Service) CreateSkill(scope string, name string, description string, body string) (*SkillCatalog, error)

func (*Service) CreateThread

func (s *Service) CreateThread(ctx context.Context, meta *session.Meta, title string, modelID string, permissionType string, workingDir string) (*ThreadView, error)

func (*Service) CreateThreadWithOptions added in v0.7.2

func (s *Service) CreateThreadWithOptions(ctx context.Context, meta *session.Meta, req CreateThreadRequest) (*ThreadView, error)

func (*Service) DeleteFollowup

func (s *Service) DeleteFollowup(ctx context.Context, meta *session.Meta, threadID string, followupID string) error

func (*Service) DeleteSkill

func (s *Service) DeleteSkill(scope string, name string) (*SkillCatalog, error)

func (*Service) DeleteThread

func (s *Service) DeleteThread(ctx context.Context, meta *session.Meta, threadID string, force bool) error

func (*Service) DesktopModelSourceBindingSnapshot added in v0.6.8

func (s *Service) DesktopModelSourceBindingSnapshot() runtimeservice.Binding

func (*Service) DesktopModelSourceBindingStatus added in v0.6.8

func (s *Service) DesktopModelSourceBindingStatus(ctx context.Context) runtimeservice.Binding

func (*Service) DetachRealtimeSink

func (s *Service) DetachRealtimeSink(streamServer *rpc.Server)

func (*Service) DisconnectDesktopModelSource added in v0.6.8

func (s *Service) DisconnectDesktopModelSource() *AIRuntimeStatus

func (*Service) Enabled

func (s *Service) Enabled() bool

func (*Service) ForkThread added in v0.7.1

func (s *Service) ForkThread(ctx context.Context, meta *session.Meta, sourceThreadID string, title string) (*ThreadView, error)

func (*Service) GetFlowerSubagentDetail added in v0.7.2

func (s *Service) GetFlowerSubagentDetail(ctx context.Context, meta *session.Meta, parentThreadID string, childThreadID string, afterOrdinal int64, limit int) (*FlowerSubagentDetailResponse, error)

func (*Service) GetFlowerThreadLiveBootstrap added in v0.7.1

func (s *Service) GetFlowerThreadLiveBootstrap(ctx context.Context, meta *session.Meta, threadID string) (*FlowerLiveBootstrapResponse, error)

func (*Service) GetFlowerThreadMetadata added in v0.7.1

func (s *Service) GetFlowerThreadMetadata(ctx context.Context, endpointID string, threadID string) (*threadstore.FlowerThreadMetadata, error)

func (*Service) GetTerminalToolOutput

func (s *Service) GetTerminalToolOutput(ctx context.Context, meta *session.Meta, runID string, toolID string) (*TerminalToolOutput, error)

func (*Service) GetThread

func (s *Service) GetThread(ctx context.Context, meta *session.Meta, threadID string) (*ThreadView, error)

func (*Service) GetThreadTodos

func (s *Service) GetThreadTodos(ctx context.Context, meta *session.Meta, threadID string) (*ThreadTodosView, error)

func (*Service) GetToolDetail added in v0.6.10

func (s *Service) GetToolDetail(ctx context.Context, meta *session.Meta, runID string, toolID string) (*ToolDetail, error)

func (*Service) HasActiveThread

func (s *Service) HasActiveThread(threadID string) bool

func (*Service) HasActiveThreadForEndpoint

func (s *Service) HasActiveThreadForEndpoint(endpointID string, threadID string) bool

func (*Service) ImportGitHubSkills

func (s *Service) ImportGitHubSkills(req SkillGitHubImportRequest) (*SkillGitHubImportResult, error)

func (*Service) ListActiveThreadRuns

func (s *Service) ListActiveThreadRuns(endpointID string) []ActiveThreadRun

func (*Service) ListFlowerSubagents added in v0.7.2

func (s *Service) ListFlowerSubagents(ctx context.Context, meta *session.Meta, parentThreadID string) ([]FlowerSubagentSummary, error)

func (*Service) ListFlowerThreadLiveEvents added in v0.7.1

func (s *Service) ListFlowerThreadLiveEvents(ctx context.Context, meta *session.Meta, threadID string, afterSeq int64, limit int) (*FlowerLiveEventsResponse, error)

func (*Service) ListFollowups

func (s *Service) ListFollowups(ctx context.Context, meta *session.Meta, threadID string, limit int) (*ListFollowupsResponse, error)

func (*Service) ListGitHubSkillCatalog

func (s *Service) ListGitHubSkillCatalog(req SkillGitHubCatalogRequest) (*SkillGitHubCatalog, error)

func (*Service) ListModels

func (s *Service) ListModels() (*ModelsResponse, error)

func (*Service) ListRecentThreadToolCalls

func (s *Service) ListRecentThreadToolCalls(ctx context.Context, meta *session.Meta, threadID string, limit int) ([]threadstore.ToolCallRecord, error)

func (*Service) ListRunEvents

func (s *Service) ListRunEvents(ctx context.Context, meta *session.Meta, runID string, limit int) (*ListRunEventsResponse, error)

func (*Service) ListRunEventsWithQuery

func (s *Service) ListRunEventsWithQuery(ctx context.Context, meta *session.Meta, runID string, query ListRunEventsQuery) (*ListRunEventsResponse, error)

func (*Service) ListSkillSources

func (s *Service) ListSkillSources() (*SkillSourcesView, error)

func (*Service) ListSkillsCatalog

func (s *Service) ListSkillsCatalog() (*SkillCatalog, error)

func (*Service) ListThreadMessages

func (s *Service) ListThreadMessages(ctx context.Context, meta *session.Meta, threadID string, limit int, beforeID int64) (*ListThreadMessagesResponse, error)

func (*Service) ListThreads

func (s *Service) ListThreads(ctx context.Context, meta *session.Meta, limit int, cursor string) (*ListThreadsResponse, error)

func (*Service) OpenUpload

func (s *Service) OpenUpload(ctx context.Context, endpointID string, uploadID string) (*UploadResponse, string, error)

func (*Service) PatchSkillToggles

func (s *Service) PatchSkillToggles(patches []SkillTogglePatch) (*SkillCatalog, error)

func (*Service) PrepareDesktopModelSource added in v0.6.8

func (s *Service) PrepareDesktopModelSource(session DesktopModelSourceSession) (*AIRuntimeStatus, error)

func (*Service) ReadTerminalProcess added in v0.7.2

func (s *Service) ReadTerminalProcess(ctx context.Context, meta *session.Meta, runID string, processID string, afterSeq int64, waitMS int64, maxBytes int64) (*terminalProcessSnapshot, error)

func (*Service) RegisterRPC

func (s *Service) RegisterRPC(r *rpc.Router, meta *session.Meta, streamServer *rpc.Server)

func (*Service) RegisterRPCWithAccessGate

func (s *Service) RegisterRPCWithAccessGate(r *rpc.Router, meta *session.Meta, streamServer *rpc.Server, gate *accessgate.Gate)

func (*Service) ReinstallSkills

func (s *Service) ReinstallSkills(paths []string, overwrite bool) (*SkillReinstallResult, error)

func (*Service) ReloadSkillsCatalog

func (s *Service) ReloadSkillsCatalog() (*SkillCatalog, error)

func (*Service) RenameThread

func (s *Service) RenameThread(ctx context.Context, meta *session.Meta, threadID string, title string) error

func (*Service) ReorderFollowups

func (s *Service) ReorderFollowups(ctx context.Context, meta *session.Meta, threadID string, req ReorderFollowupsRequest) error

func (*Service) ResolveFlowerFileActionOpenTarget added in v0.7.1

func (s *Service) ResolveFlowerFileActionOpenTarget(ctx context.Context, meta *session.Meta, req FlowerFileActionOpenRequest) (FlowerFileActionOpenTarget, error)

func (*Service) RuntimeStatus added in v0.6.4

func (s *Service) RuntimeStatus(ctx context.Context) *AIRuntimeStatus

func (*Service) SaveUpload

func (s *Service) SaveUpload(ctx context.Context, endpointID string, r io.Reader, name string, mimeType string, maxBytes int64) (*UploadResponse, error)

func (*Service) SendUserTurn

func (s *Service) SendUserTurn(ctx context.Context, meta *session.Meta, req SendUserTurnRequest) (SendUserTurnResponse, error)

func (*Service) ServeDesktopModelSourceRPC added in v0.6.8

func (s *Service) ServeDesktopModelSourceRPC(ctx context.Context, session DesktopModelSourceSession, ws *websocket.Conn, onChange func()) error

func (*Service) SetCurrentModelID

func (s *Service) SetCurrentModelID(modelID string, persist func(next *config.AIConfig) error) error

SetCurrentModelID updates current_model_id while keeping the provider/model registry unchanged.

Unlike UpdateConfig, this method is lightweight and allowed while runs are active because it only changes the current model for future chats.

func (*Service) SetThreadModel

func (s *Service) SetThreadModel(ctx context.Context, meta *session.Meta, threadID string, modelID string) error

func (*Service) SetThreadPermissionType added in v0.7.2

func (s *Service) SetThreadPermissionType(ctx context.Context, meta *session.Meta, threadID string, permissionType string) error

func (*Service) SetThreadPinned added in v0.7.1

func (s *Service) SetThreadPinned(ctx context.Context, meta *session.Meta, threadID string, pinned bool) (*ThreadView, error)

func (*Service) SetThreadReasoningSelection added in v0.7.2

func (s *Service) SetThreadReasoningSelection(ctx context.Context, meta *session.Meta, threadID string, selection config.AIReasoningSelection) error

func (*Service) StartRun

func (s *Service) StartRun(ctx context.Context, meta *session.Meta, runID string, req RunStartRequest, w http.ResponseWriter) error

func (*Service) StartRunDetached

func (s *Service) StartRunDetached(meta *session.Meta, runID string, req RunStartRequest) error

func (*Service) StopThread

func (s *Service) StopThread(ctx context.Context, meta *session.Meta, threadID string) (StopThreadResponse, error)

func (*Service) SubmitFlowerApproval added in v0.7.1

func (s *Service) SubmitFlowerApproval(meta *session.Meta, req SubmitFlowerApprovalRequest) (*SubmitFlowerApprovalResponse, error)

func (*Service) SubmitRequestUserInputResponse added in v0.7.1

func (*Service) SubscribeSummary

func (s *Service) SubscribeSummary(endpointID string, streamServer *rpc.Server) ([]ActiveThreadRun, error)

func (*Service) SubscribeThread

func (s *Service) SubscribeThread(endpointID string, threadID string, streamServer *rpc.Server) (string, error)

func (*Service) TerminateTerminalProcess added in v0.7.2

func (s *Service) TerminateTerminalProcess(ctx context.Context, meta *session.Meta, runID string, processID string) (*terminalProcessSnapshot, error)

func (*Service) ToolTargetPolicy added in v0.7.1

func (s *Service) ToolTargetPolicy() ToolTargetPolicy

func (*Service) UpdateConfig

func (s *Service) UpdateConfig(next *config.AIConfig, persist func() error) error

UpdateConfig updates the in-memory AI config after persisting it via the provided callback.

Active runs keep their existing run-local config snapshot. The updated config applies to runs created after this method returns.

func (*Service) UpdateFilesystemScope added in v0.6.8

func (s *Service) UpdateFilesystemScope(scope *filesystemscope.Registry) error

UpdateFilesystemScope refreshes the in-memory filesystem roots for future runs.

func (*Service) UpdateFollowup

func (s *Service) UpdateFollowup(ctx context.Context, meta *session.Meta, threadID string, followupID string, req PatchFollowupRequest) error

func (*Service) UpsertFlowerThreadMetadata added in v0.7.1

func (s *Service) UpsertFlowerThreadMetadata(ctx context.Context, rec threadstore.FlowerThreadMetadata) error

func (*Service) ValidateGitHubSkillImport

func (s *Service) ValidateGitHubSkillImport(req SkillGitHubImportRequest) (*SkillGitHubValidateResult, error)

func (*Service) ValidateWorkingDir

func (s *Service) ValidateWorkingDir(workingDir string) (string, error)

func (*Service) WriteTerminalProcess added in v0.7.2

func (s *Service) WriteTerminalProcess(ctx context.Context, meta *session.Meta, runID string, processID string, input string) (*terminalProcessSnapshot, error)

type SkillActivation

type SkillActivation struct {
	ActivationID    string               `json:"activation_id"`
	Name            string               `json:"name"`
	RootDir         string               `json:"root_dir"`
	Priority        int                  `json:"priority"`
	Content         string               `json:"content"`
	ContentRef      string               `json:"content_ref"`
	PermissionHints []string             `json:"permission_hints,omitempty"`
	Dependencies    []SkillMCPDependency `json:"dependencies,omitempty"`
	ActivatedAt     int64                `json:"activated_at_unix_ms"`
}

type SkillBrowseFileResult

type SkillBrowseFileResult struct {
	Root      string `json:"root"`
	File      string `json:"file"`
	Encoding  string `json:"encoding"`
	Truncated bool   `json:"truncated"`
	Size      int64  `json:"size"`
	Content   string `json:"content"`
}

type SkillBrowseTreeEntry

type SkillBrowseTreeEntry struct {
	Name             string `json:"name"`
	Path             string `json:"path"`
	IsDir            bool   `json:"is_dir"`
	Size             int64  `json:"size"`
	ModifiedAtUnixMs int64  `json:"modified_at_unix_ms"`
}

type SkillBrowseTreeResult

type SkillBrowseTreeResult struct {
	Root    string                 `json:"root"`
	Dir     string                 `json:"dir"`
	Entries []SkillBrowseTreeEntry `json:"entries"`
}

type SkillCatalog

type SkillCatalog struct {
	CatalogVersion int64                `json:"catalog_version"`
	Skills         []SkillCatalogEntry  `json:"skills"`
	Conflicts      []SkillCatalogNotice `json:"conflicts,omitempty"`
	Errors         []SkillCatalogNotice `json:"errors,omitempty"`
}

type SkillCatalogEntry

type SkillCatalogEntry struct {
	ID                      string               `json:"id"`
	Name                    string               `json:"name"`
	Description             string               `json:"description"`
	Path                    string               `json:"path"`
	Scope                   string               `json:"scope"`
	Priority                int                  `json:"priority,omitempty"`
	PermissionHints         []string             `json:"permission_hints,omitempty"`
	AllowImplicitInvocation bool                 `json:"allow_implicit_invocation"`
	Dependencies            []SkillMCPDependency `json:"dependencies,omitempty"`
	DependencyState         string               `json:"dependency_state,omitempty"`
	Enabled                 bool                 `json:"enabled"`
	Effective               bool                 `json:"effective"`
	ShadowedBy              string               `json:"shadowed_by,omitempty"`
}

type SkillCatalogNotice

type SkillCatalogNotice struct {
	Name       string `json:"name,omitempty"`
	Path       string `json:"path,omitempty"`
	Message    string `json:"message,omitempty"`
	WinnerPath string `json:"winner_path,omitempty"`
}

type SkillError

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

func AsSkillError

func AsSkillError(err error) (*SkillError, bool)

func (*SkillError) Code

func (e *SkillError) Code() string

func (*SkillError) Error

func (e *SkillError) Error() string

func (*SkillError) HTTPStatus

func (e *SkillError) HTTPStatus() int

func (*SkillError) Unwrap

func (e *SkillError) Unwrap() error

type SkillGitHubAuth

type SkillGitHubAuth struct {
	GitHubToken            string `json:"github_token,omitempty"`
	UseLocalGitCredentials bool   `json:"use_local_git_credentials,omitempty"`
}

type SkillGitHubCatalog

type SkillGitHubCatalog struct {
	Source SkillGitHubCatalogSource `json:"source"`
	Skills []SkillGitHubCatalogItem `json:"skills"`
}

type SkillGitHubCatalogItem

type SkillGitHubCatalogItem struct {
	RemoteID       string   `json:"remote_id"`
	Name           string   `json:"name"`
	Description    string   `json:"description"`
	RepoPath       string   `json:"repo_path"`
	ExistsLocal    bool     `json:"exists_local"`
	InstalledPaths []string `json:"installed_paths,omitempty"`
}

type SkillGitHubCatalogRequest

type SkillGitHubCatalogRequest struct {
	Repo        string `json:"repo,omitempty"`
	Ref         string `json:"ref,omitempty"`
	BasePath    string `json:"base_path,omitempty"`
	ForceReload bool   `json:"force_reload,omitempty"`
}

type SkillGitHubCatalogSource

type SkillGitHubCatalogSource struct {
	Repo     string `json:"repo"`
	Ref      string `json:"ref"`
	BasePath string `json:"base_path"`
}

type SkillGitHubImportItem

type SkillGitHubImportItem struct {
	Name            string          `json:"name"`
	Scope           string          `json:"scope"`
	SkillPath       string          `json:"skill_path"`
	SourceType      SkillSourceType `json:"source_type"`
	SourceID        string          `json:"source_id"`
	InstallMode     string          `json:"install_mode"`
	InstalledCommit string          `json:"installed_commit,omitempty"`
}

type SkillGitHubImportRequest

type SkillGitHubImportRequest struct {
	Scope     string          `json:"scope"`
	Repo      string          `json:"repo,omitempty"`
	Ref       string          `json:"ref,omitempty"`
	Paths     []string        `json:"paths,omitempty"`
	URL       string          `json:"url,omitempty"`
	Overwrite bool            `json:"overwrite,omitempty"`
	Auth      SkillGitHubAuth `json:"auth,omitempty"`
}

type SkillGitHubImportResult

type SkillGitHubImportResult struct {
	Catalog SkillCatalog            `json:"catalog"`
	Imports []SkillGitHubImportItem `json:"imports"`
}

type SkillGitHubResolvedSkill

type SkillGitHubResolvedSkill struct {
	Name            string `json:"name"`
	Description     string `json:"description"`
	Scope           string `json:"scope,omitempty"`
	Repo            string `json:"repo"`
	Ref             string `json:"ref"`
	RepoPath        string `json:"repo_path"`
	TargetDir       string `json:"target_dir"`
	TargetSkillPath string `json:"target_skill_path"`
	AlreadyExists   bool   `json:"already_exists"`
}

type SkillGitHubValidateResult

type SkillGitHubValidateResult struct {
	Resolved []SkillGitHubResolvedSkill `json:"resolved"`
}

type SkillMCPDependency

type SkillMCPDependency struct {
	Name      string `json:"name,omitempty" yaml:"name"`
	Transport string `json:"transport,omitempty" yaml:"transport"`
	Command   string `json:"command,omitempty" yaml:"command"`
	URL       string `json:"url,omitempty" yaml:"url"`
}

type SkillMeta

type SkillMeta struct {
	Name                    string               `json:"name"`
	Description             string               `json:"description"`
	Path                    string               `json:"path"`
	Scope                   string               `json:"scope"`
	Priority                int                  `json:"priority,omitempty"`
	PermissionHints         []string             `json:"permission_hints,omitempty"`
	AllowImplicitInvocation bool                 `json:"allow_implicit_invocation"`
	Dependencies            []SkillMCPDependency `json:"dependencies,omitempty"`
}

type SkillReinstallItem

type SkillReinstallItem struct {
	SkillPath   string `json:"skill_path"`
	SourceID    string `json:"source_id"`
	InstallMode string `json:"install_mode"`
}

type SkillReinstallResult

type SkillReinstallResult struct {
	Catalog     SkillCatalog         `json:"catalog"`
	Reinstalled []SkillReinstallItem `json:"reinstalled"`
}

type SkillSourceRecord

type SkillSourceRecord struct {
	SkillPath           string          `json:"skill_path"`
	SourceType          SkillSourceType `json:"source_type"`
	SourceID            string          `json:"source_id"`
	Repo                string          `json:"repo,omitempty"`
	Ref                 string          `json:"ref,omitempty"`
	RepoPath            string          `json:"repo_path,omitempty"`
	InstallMode         string          `json:"install_mode,omitempty"`
	InstalledCommit     string          `json:"installed_commit,omitempty"`
	InstalledAtUnixMs   int64           `json:"installed_at_unix_ms,omitempty"`
	LastCheckedAtUnixMs int64           `json:"last_checked_at_unix_ms,omitempty"`
}

type SkillSourceType

type SkillSourceType string
const (
	SkillSourceTypeLocalManual SkillSourceType = "local_manual"
	SkillSourceTypeGitHub      SkillSourceType = "github_import"
	SkillSourceTypeSystem      SkillSourceType = "system_bundle"
)

type SkillSourcesView

type SkillSourcesView struct {
	Items []SkillSourceRecord `json:"items"`
}

type SkillTogglePatch

type SkillTogglePatch struct {
	Path    string `json:"path"`
	Enabled bool   `json:"enabled"`
}

type SourceRef

type SourceRef struct {
	Title string `json:"title,omitempty"`
	URL   string `json:"url"`
}

type StopThreadRequest

type StopThreadRequest struct {
	ThreadID string `json:"thread_id"`
}

type StopThreadResponse

type StopThreadResponse struct {
	OK                 bool               `json:"ok"`
	RecoveredFollowups []FollowupItemView `json:"recovered_followups,omitempty"`
}

type StreamEvent

type StreamEvent struct {
	Type       StreamEventType  `json:"type"`
	Text       string           `json:"text,omitempty"`
	ToolCall   *PartialToolCall `json:"tool_call,omitempty"`
	Usage      *PartialUsage    `json:"usage,omitempty"`
	FinishHint string           `json:"finish_hint,omitempty"`
}

type StreamEventType

type StreamEventType string

StreamEventType is the normalized stream event kind produced by provider adapters.

const (
	StreamEventTextDelta     StreamEventType = "text_delta"
	StreamEventToolCallStart StreamEventType = "tool_call_start"
	StreamEventToolCallDelta StreamEventType = "tool_call_delta"
	StreamEventToolCallEnd   StreamEventType = "tool_call_end"
	StreamEventThinkingDelta StreamEventType = "thinking_delta"
	StreamEventUsage         StreamEventType = "usage"
	StreamEventFinishReason  StreamEventType = "finish_reason"
)

type SubmitFlowerApprovalRequest added in v0.7.1

type SubmitFlowerApprovalRequest struct {
	ThreadID       string                `json:"thread_id"`
	Origin         FlowerApprovalOrigin  `json:"origin,omitempty"`
	RunID          string                `json:"run_id"`
	ActionID       string                `json:"action_id"`
	ToolID         string                `json:"tool_id"`
	Approved       bool                  `json:"approved"`
	ExpectedSeq    int64                 `json:"expected_seq"`
	Revision       int64                 `json:"revision"`
	Version        int64                 `json:"version,omitempty"`
	SurfaceEpoch   int64                 `json:"surface_epoch,omitempty"`
	IdempotencyKey string                `json:"idempotency_key,omitempty"`
	DelegatedRef   *DelegatedApprovalRef `json:"delegated_ref,omitempty"`
}

type SubmitFlowerApprovalResponse added in v0.7.1

type SubmitFlowerApprovalResponse struct {
	OK            bool  `json:"ok"`
	CurrentCursor int64 `json:"current_cursor"`
}

type SubmitRequestUserInputResponseRequest added in v0.7.1

type SubmitRequestUserInputResponseRequest struct {
	ThreadID         string                   `json:"thread_id"`
	Model            string                   `json:"model,omitempty"`
	Response         RequestUserInputResponse `json:"response"`
	Input            RunInput                 `json:"input"`
	Options          RunOptions               `json:"options"`
	ExpectedRunID    string                   `json:"expected_run_id,omitempty"`
	SourceFollowupID string                   `json:"source_followup_id,omitempty"`
}

type SubmitRequestUserInputResponseResponse added in v0.7.1

type SubmitRequestUserInputResponseResponse struct {
	RunID                   string `json:"run_id"`
	Kind                    string `json:"kind"`
	ConsumedWaitingPromptID string `json:"consumed_waiting_prompt_id,omitempty"`
	AppliedPermissionType   string `json:"applied_permission_type,omitempty"`
}

type TargetToolCall added in v0.7.1

type TargetToolCall struct {
	ToolCallID           string          `json:"tool_call_id"`
	TargetID             string          `json:"target_id"`
	ToolName             string          `json:"tool_name"`
	Arguments            json.RawMessage `json:"arguments"`
	RequiredCapabilities []string        `json:"required_capabilities"`
}

type TargetToolExecutor added in v0.7.1

type TargetToolExecutor interface {
	ExecuteTargetTool(ctx context.Context, call TargetToolCall) (TargetToolResult, error)
}

type TargetToolResult added in v0.7.1

type TargetToolResult struct {
	TargetID          string `json:"target_id"`
	ExecutionLocation string `json:"execution_location,omitempty"`
	Result            any    `json:"result,omitempty"`
}

type TerminalToolOutput

type TerminalToolOutput struct {
	RunID           string `json:"run_id"`
	ToolID          string `json:"tool_id"`
	ToolName        string `json:"tool_name"`
	Status          string `json:"status"`
	ProcessID       string `json:"process_id,omitempty"`
	Output          string `json:"output,omitempty"`
	LatestOutput    string `json:"latest_output,omitempty"`
	Stdout          string `json:"stdout"`
	Stderr          string `json:"stderr"`
	ExitCode        int    `json:"exit_code"`
	DurationMS      int64  `json:"duration_ms"`
	Truncated       bool   `json:"truncated"`
	Cwd             string `json:"cwd,omitempty"`
	FirstSeq        int64  `json:"first_seq,omitempty"`
	LastSeq         int64  `json:"last_seq,omitempty"`
	TotalBytes      int64  `json:"total_bytes,omitempty"`
	StartedAtUnixMs int64  `json:"started_at_ms,omitempty"`
	EndedAtUnixMs   int64  `json:"ended_at_ms,omitempty"`
	RawResult       string `json:"raw_result,omitempty"`
}

type ThreadTodosView

type ThreadTodosView struct {
	Version         int64      `json:"version"`
	UpdatedAtUnixMs int64      `json:"updated_at_unix_ms"`
	Todos           []TodoItem `json:"todos"`
}

type ThreadView

type ThreadView struct {
	ThreadID            string                       `json:"thread_id"`
	Title               string                       `json:"title"`
	ModelID             string                       `json:"model_id"`
	PermissionType      string                       `json:"permission_type"`
	WorkingDir          string                       `json:"working_dir"`
	QueuedTurnCount     int                          `json:"queued_turn_count"`
	QueuedTurns         []QueuedTurnView             `json:"queued_turns,omitempty"`
	RunStatus           string                       `json:"run_status"`
	ReadOnlyReason      string                       `json:"read_only_reason,omitempty"`
	OwnerKind           string                       `json:"owner_kind,omitempty"`
	OwnerID             string                       `json:"owner_id,omitempty"`
	ParentThreadID      string                       `json:"parent_thread_id,omitempty"`
	RunUpdatedAtUnixMs  int64                        `json:"run_updated_at_unix_ms"`
	RunErrorCode        string                       `json:"run_error_code,omitempty"`
	RunError            string                       `json:"run_error,omitempty"`
	WaitingPrompt       *RequestUserInputPrompt      `json:"waiting_prompt,omitempty"`
	LastContextRunID    string                       `json:"last_context_run_id,omitempty"`
	ReasoningSelection  config.AIReasoningSelection  `json:"reasoning_selection,omitempty"`
	ReasoningCapability config.AIReasoningCapability `json:"reasoning_capability,omitempty"`
	PinnedAtUnixMs      int64                        `json:"pinned_at_unix_ms,omitempty"`
	CreatedAtUnixMs     int64                        `json:"created_at_unix_ms"`
	UpdatedAtUnixMs     int64                        `json:"updated_at_unix_ms"`
	LastMessageAtUnixMs int64                        `json:"last_message_at_unix_ms"`
	LastMessagePreview  string                       `json:"last_message_preview"`
	Subagents           []FlowerSubagentSummary      `json:"subagents,omitempty"`
	FlowerActivity      FlowerThreadReadSnapshot     `json:"-"`
}

type TodoItem

type TodoItem struct {
	ID      string `json:"id"`
	Content string `json:"content"`
	Status  string `json:"status"`
	Note    string `json:"note,omitempty"`
}

type TodoSummary

type TodoSummary struct {
	Total      int `json:"total"`
	Pending    int `json:"pending"`
	InProgress int `json:"in_progress"`
	Completed  int `json:"completed"`
	Cancelled  int `json:"cancelled"`
}

type ToolApprovalRequest

type ToolApprovalRequest struct {
	ToolID   string `json:"tool_id"`
	Approved bool   `json:"approved"`
}

type ToolCall

type ToolCall struct {
	ID   string         `json:"id,omitempty"`
	Name string         `json:"name"`
	Args map[string]any `json:"args,omitempty"`
}

type ToolCapabilityClass added in v0.7.2

type ToolCapabilityClass string
const (
	ToolCapabilityReadonlyLocal   ToolCapabilityClass = "readonly_local"
	ToolCapabilityReadonlyNetwork ToolCapabilityClass = "readonly_network"
	ToolCapabilityInteraction     ToolCapabilityClass = "interaction"
	ToolCapabilityMutation        ToolCapabilityClass = "mutation"
	ToolCapabilityShell           ToolCapabilityClass = "shell"
	ToolCapabilityDelegation      ToolCapabilityClass = "delegation"
	ToolCapabilityOpenWorld       ToolCapabilityClass = "open_world"
)

type ToolDef

type ToolDef struct {
	Name             string                       `json:"name"`
	Description      string                       `json:"description,omitempty"`
	InputSchema      json.RawMessage              `json:"input_schema,omitempty"`
	ParallelSafe     bool                         `json:"parallel_safe,omitempty"`
	Mutating         bool                         `json:"mutating,omitempty"`
	RequiresApproval bool                         `json:"requires_approval,omitempty"`
	Visibility       ToolVisibilityClass          `json:"visibility,omitempty"`
	Capabilities     []ToolCapabilityClass        `json:"capabilities,omitempty"`
	Presentation     aitools.ToolPresentationSpec `json:"presentation,omitempty"`
	Source           string                       `json:"source,omitempty"`
	Namespace        string                       `json:"namespace,omitempty"`
	Priority         int                          `json:"priority,omitempty"`
}

func (ToolDef) HasCapability added in v0.7.2

func (d ToolDef) HasCapability(capability ToolCapabilityClass) bool

type ToolDetail added in v0.6.10

type ToolDetail struct {
	RunID           string         `json:"run_id"`
	ToolID          string         `json:"tool_id"`
	ToolName        string         `json:"tool_name"`
	Status          string         `json:"status"`
	Args            map[string]any `json:"args,omitempty"`
	Result          any            `json:"result,omitempty"`
	ErrorCode       string         `json:"error_code,omitempty"`
	ErrorMessage    string         `json:"error_message,omitempty"`
	Retryable       bool           `json:"retryable,omitempty"`
	RecoveryAction  string         `json:"recovery_action,omitempty"`
	StartedAtUnixMs int64          `json:"started_at_unix_ms,omitempty"`
	EndedAtUnixMs   int64          `json:"ended_at_unix_ms,omitempty"`
	LatencyMS       int64          `json:"latency_ms,omitempty"`
	RawArgs         string         `json:"raw_args,omitempty"`
	RawResult       string         `json:"raw_result,omitempty"`
}

type ToolHandler

type ToolHandler interface {
	Validate(ctx context.Context, call ToolCall) error
	Execute(ctx context.Context, call ToolCall) (ToolResult, error)
	HandlePartial(ctx context.Context, partial PartialToolCall) error
}

type ToolPermissionPolicy added in v0.7.2

type ToolPermissionPolicy struct {
	Visibility       ToolVisibilityClass
	Capabilities     []ToolCapabilityClass
	ResourceKinds    []string
	ApprovalDecision ApprovalDecisionKind
	ParallelSafe     bool
}

type ToolRegistry

type ToolRegistry interface {
	Register(tool ToolDef, handler ToolHandler) error
	Unregister(name string) error
	Snapshot() []ToolDef
}

type ToolResult

type ToolResult struct {
	ToolID     string             `json:"tool_id,omitempty"`
	ToolName   string             `json:"tool_name,omitempty"`
	Status     string             `json:"status"`
	Summary    string             `json:"summary,omitempty"`
	Details    string             `json:"details,omitempty"`
	Data       any                `json:"data,omitempty"`
	Pending    *PendingToolResult `json:"pending,omitempty"`
	Error      *aitools.ToolError `json:"error,omitempty"`
	Truncated  bool               `json:"truncated,omitempty"`
	ContentRef string             `json:"content_ref,omitempty"`
}

type ToolTargetPolicy added in v0.7.1

type ToolTargetPolicy struct {
	Mode             string   `json:"mode"`
	DefaultTargetID  string   `json:"default_target_id,omitempty"`
	AllowedTargetIDs []string `json:"allowed_target_ids,omitempty"`
}

type ToolVisibilityClass added in v0.7.2

type ToolVisibilityClass string
const (
	ToolVisibilityReadonlyExclusive ToolVisibilityClass = "readonly_exclusive"
	ToolVisibilityStandard          ToolVisibilityClass = "standard"
	ToolVisibilitySharedReadonly    ToolVisibilityClass = "shared_readonly"
	ToolVisibilityInteraction       ToolVisibilityClass = "interaction"
	ToolVisibilityControl           ToolVisibilityClass = "control"
	ToolVisibilityDelegationControl ToolVisibilityClass = "delegation_control"
)

type TurnBudgets

type TurnBudgets struct {
	// MaxOutputToken limits one provider request, not cumulative run output.
	MaxOutputToken int     `json:"max_output_tokens,omitempty"`
	MaxCostUSD     float64 `json:"max_cost_usd,omitempty"`
}

type TurnSnapshot

type TurnSnapshot struct {
	ToolCalls    []ToolCall
	ToolResults  []ToolResult
	FinishReason string
	Assistant    string
}

type TurnUsage

type TurnUsage struct {
	InputTokens     int64 `json:"input_tokens,omitempty"`
	OutputTokens    int64 `json:"output_tokens,omitempty"`
	ReasoningTokens int64 `json:"reasoning_tokens,omitempty"`
}

type UploadResponse

type UploadResponse struct {
	URL      string `json:"url"`
	Name     string `json:"name"`
	Size     int64  `json:"size"`
	MimeType string `json:"mime_type"`
}

Directories

Path Synopsis
context

Jump to

Keyboard shortcuts

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