Documentation
¶
Index ¶
- Variables
- func BoolArg(arguments map[string]any, key string) (bool, bool, error)
- func FilterSubagentTools(toolList []sdk.Tool) []sdk.Tool
- func FirstStringArg(arguments map[string]any, keys ...string) string
- func IntArg(arguments map[string]any, key string) (int, bool, error)
- func IsBuiltInToolName(name string) bool
- func LimitToolError(err error, label string, limit ToolOutputLimit) error
- func LimitToolOutput(output any, label string, limit ToolOutputLimit) any
- func StringArg(arguments map[string]any, key string) string
- func WrapToolOutputLimits(sdkTools []sdk.Tool, limit ToolOutputLimit) []sdk.Tool
- type ACPAgentsProvider
- type ACPOptionInfo
- type ACPRuntimePool
- type ACPRuntimeSummary
- type AskUserProvider
- type Attachment
- type AvailableTools
- type BackgroundProvider
- type BrowserProvider
- type ContactsProvider
- type ContainerProvider
- type EmailProvider
- type FederationProvider
- type HistoryMessageReader
- type HistoryProvider
- type ImageGenProvider
- type MemoryProvider
- type MemorySettingsReader
- type MessageProvider
- type MessageSnapshot
- type MessageSnapshotEntry
- type NativeToolApprovalService
- type NativeToolEventSink
- type NativeToolSource
- func (s *NativeToolSource) CallTool(ctx context.Context, session mcp.ToolSessionContext, toolName string, ...) (map[string]any, error)
- func (s *NativeToolSource) ListTools(ctx context.Context, session mcp.ToolSessionContext) ([]mcp.ToolDescriptor, error)
- func (s *NativeToolSource) SetProviders(providers []ToolProvider)
- type NativeToolSourceOptions
- type NativeToolUserInputService
- type ProviderLabeler
- type Reaction
- type ReadMediaToolOutput
- type ReadMediaToolResult
- type ScheduleProvider
- type Scheduler
- type SessionContext
- type SessionLister
- type SkillDetail
- type SkillProvider
- type SpawnAgent
- type SpawnAttemptDisposition
- type SpawnIdentity
- type SpawnLoopConfig
- type SpawnProvider
- func (p *SpawnProvider) SetAgent(a SpawnAgent)
- func (p *SpawnProvider) SetHookService(h *hooks.Service)
- func (p *SpawnProvider) SetMessageService(w messagepkg.Service)
- func (p *SpawnProvider) SetSubagentAdmitter(admitter SubagentAdmitter)
- func (p *SpawnProvider) SetSystemPromptFunc(fn func(sessionType string) string)
- func (p *SpawnProvider) Tools(ctx context.Context, session SessionContext) ([]sdk.Tool, error)
- func (*SpawnProvider) Usage(_ context.Context, _ SessionContext, available AvailableTools) string
- type SpawnResult
- type SpawnRunConfig
- type Speech
- type StreamEmitter
- type StreamEventType
- type SubagentAdmission
- type SubagentAdmitter
- type SubagentTerminal
- type SubagentWatchdog
- type TTSProvider
- type ToolName
- func BuiltInToolNames() []ToolName
- func ReadMediaToolName() ToolName
- func ToolApplyPatch() ToolName
- func ToolAskUser() ToolName
- func ToolBrowserAction() ToolName
- func ToolBrowserObserve() ToolName
- func ToolBrowserRemoteSession() ToolName
- func ToolComputerAction() ToolName
- func ToolComputerObserve() ToolName
- func ToolCreateSchedule() ToolName
- func ToolDeleteSchedule() ToolName
- func ToolEdit() ToolName
- func ToolExec() ToolName
- func ToolGenerateImage() ToolName
- func ToolGenerateVideo() ToolName
- func ToolGetBackgroundStatus() ToolName
- func ToolGetContacts() ToolName
- func ToolGetMessages() ToolName
- func ToolGetSchedule() ToolName
- func ToolKillBackground() ToolName
- func ToolList() ToolName
- func ToolListACPAgents() ToolName
- func ToolListAgents() ToolName
- func ToolListBackground() ToolName
- func ToolListEmail() ToolName
- func ToolListEmailAccounts() ToolName
- func ToolListExecutionLocations() ToolName
- func ToolListModels() ToolName
- func ToolListSchedule() ToolName
- func ToolListSessions() ToolName
- func ToolListSkills() ToolName
- func ToolListWorkdirs() ToolName
- func ToolReact() ToolName
- func ToolRead() ToolName
- func ToolReadEmail() ToolName
- func ToolSearchMemory() ToolName
- func ToolSearchMessages() ToolName
- func ToolSend() ToolName
- func ToolSendEmail() ToolName
- func ToolSendMessage() ToolName
- func ToolSpawnAgent() ToolName
- func ToolSpeak() ToolName
- func ToolTranscribeAudio() ToolName
- func ToolUpdateSchedule() ToolName
- func ToolUseSkill() ToolName
- func ToolWait() ToolName
- func ToolWaitUntil() ToolName
- func ToolWebFetch() ToolName
- func ToolWebSearch() ToolName
- func ToolWrite() ToolName
- type ToolOutputLimit
- type ToolProvider
- type ToolStreamEvent
- type ToolUsage
- type TranscriptionProvider
- type VideoGenProvider
- type WebFetchProvider
- type WebProvider
- type WorkdirLister
- type WorkdirProvider
Constants ¶
This section is empty.
Variables ¶
var ErrWatchdogTimedOut = errors.New("subagent watchdog: no activity within timeout")
ErrWatchdogTimedOut is returned when the subagent watchdog fires.
Functions ¶
func FilterSubagentTools ¶
FilterSubagentTools applies the small denylist for capabilities that require direct parent/user coordination. All other native and federated tools remain available and keep their existing capability/configuration gates.
func IsBuiltInToolName ¶
func LimitToolError ¶
func LimitToolError(err error, label string, limit ToolOutputLimit) error
func LimitToolOutput ¶
func LimitToolOutput(output any, label string, limit ToolOutputLimit) any
func WrapToolOutputLimits ¶
func WrapToolOutputLimits(sdkTools []sdk.Tool, limit ToolOutputLimit) []sdk.Tool
Types ¶
type ACPAgentsProvider ¶
type ACPAgentsProvider struct {
// contains filtered or unexported fields
}
ACPAgentsProvider exposes the bot's ACP agents (Codex, Claude Code, ...) so the agent can pick one — plus its model and reasoning effort — when creating scheduled tasks.
func NewACPAgentsProvider ¶
func NewACPAgentsProvider(log *slog.Logger, pool ACPRuntimePool, queries dbstore.Queries) *ACPAgentsProvider
func (*ACPAgentsProvider) Tools ¶
func (p *ACPAgentsProvider) Tools(_ context.Context, session SessionContext) ([]sdk.Tool, error)
type ACPOptionInfo ¶
ACPOptionInfo is one selectable model or reasoning effort of an ACP agent.
type ACPRuntimePool ¶
type ACPRuntimePool interface {
CreateAgentRuntime(ctx context.Context, botID, agentID, runtimeOwnerAccountID string) (ACPRuntimeSummary, error)
CloseAgentRuntime(botID, runtimeID string) error
}
ACPRuntimePool is the slice of the ACP session pool the tool needs to discover an agent's models and reasoning efforts. Those live only inside a running agent process, so the deep listing boots a temporary runtime.
type ACPRuntimeSummary ¶
type ACPRuntimeSummary struct {
RuntimeID string
DefaultModelID string
CurrentModelID string
Models []ACPOptionInfo
CurrentEffort string
Efforts []ACPOptionInfo
}
ACPRuntimeSummary is the tool-local projection of a booted ACP runtime's state. Mirrored here instead of importing the acp packages: the acp client test binary imports this package, so a real dependency would be an import cycle.
type AskUserProvider ¶
type AskUserProvider struct{}
func NewAskUserProvider ¶
func NewAskUserProvider(_ *slog.Logger) *AskUserProvider
func (*AskUserProvider) Tools ¶
func (*AskUserProvider) Tools(_ context.Context, session SessionContext) ([]sdk.Tool, error)
func (*AskUserProvider) Usage ¶
func (*AskUserProvider) Usage(_ context.Context, session SessionContext, available AvailableTools) string
type Attachment ¶
type Attachment struct {
Type string `json:"type"`
Path string `json:"path,omitempty"`
URL string `json:"url,omitempty"`
Base64 string `json:"base64,omitempty"`
PlatformKey string `json:"platform_key,omitempty"`
Mime string `json:"mime,omitempty"`
Name string `json:"name,omitempty"`
ContentHash string `json:"content_hash,omitempty"`
Size int64 `json:"size,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Attachment describes a file reference emitted by a tool.
type AvailableTools ¶
AvailableTools is the set of tool names registered for the current session.
func NewAvailableTools ¶
func NewAvailableTools(tools []sdk.Tool) AvailableTools
type BackgroundProvider ¶
type BackgroundProvider struct {
// contains filtered or unexported fields
}
BackgroundProvider exposes background task observation and control tools.
func NewBackgroundProvider ¶
func NewBackgroundProvider(_ *slog.Logger, bgManager *background.Manager) *BackgroundProvider
func (*BackgroundProvider) Tools ¶
func (p *BackgroundProvider) Tools(_ context.Context, session SessionContext) ([]sdk.Tool, error)
func (*BackgroundProvider) Usage ¶
func (*BackgroundProvider) Usage(_ context.Context, _ SessionContext, available AvailableTools) string
type BrowserProvider ¶
type BrowserProvider struct {
// contains filtered or unexported fields
}
func NewBrowserProvider ¶
func NewBrowserProvider(log *slog.Logger, settingsSvc *settings.Service, containers bridge.Provider, displayWorkspace displaypkg.Workspace, dataRoot string) *BrowserProvider
func (*BrowserProvider) Tools ¶
func (p *BrowserProvider) Tools(ctx context.Context, session SessionContext) ([]sdk.Tool, error)
func (*BrowserProvider) Usage ¶
func (*BrowserProvider) Usage(_ context.Context, session SessionContext, available AvailableTools) string
Usage frames the workspace browser/desktop tool group. Injected only when these tools are registered (display-enabled sessions).
type ContactsProvider ¶
type ContactsProvider struct {
// contains filtered or unexported fields
}
func NewContactsProvider ¶
func NewContactsProvider(log *slog.Logger, contacts messaging.ContactReader) *ContactsProvider
func (*ContactsProvider) Tools ¶
func (p *ContactsProvider) Tools(_ context.Context, session SessionContext) ([]sdk.Tool, error)
func (*ContactsProvider) Usage ¶
func (*ContactsProvider) Usage(_ context.Context, session SessionContext, available AvailableTools) string
Usage describes how get_contacts feeds other tools without restating those tools' own usage blocks.
type ContainerProvider ¶
type ContainerProvider struct {
// contains filtered or unexported fields
}
func NewContainerProvider ¶
func NewContainerProvider(log *slog.Logger, clients bridge.Provider, bgManager *background.Manager, execWorkDir string, hookServices ...*hooks.Service) *ContainerProvider
func (*ContainerProvider) SetHookService ¶
func (p *ContainerProvider) SetHookService(h *hooks.Service)
func (*ContainerProvider) Tools ¶
func (p *ContainerProvider) Tools(ctx context.Context, session SessionContext) ([]sdk.Tool, error)
func (*ContainerProvider) Usage ¶
func (*ContainerProvider) Usage(_ context.Context, session SessionContext, available AvailableTools) string
type EmailProvider ¶
type EmailProvider struct {
// contains filtered or unexported fields
}
func NewEmailProvider ¶
func (*EmailProvider) Tools ¶
func (p *EmailProvider) Tools(_ context.Context, session SessionContext) ([]sdk.Tool, error)
type FederationProvider ¶
type FederationProvider struct {
// contains filtered or unexported fields
}
FederationProvider adapts a mcp.ToolSource (federated MCP connections) into the ToolProvider interface so the agent can load external MCP tools alongside built-in tools.
func NewFederationProvider ¶
func NewFederationProvider(log *slog.Logger, source mcp.ToolSource) *FederationProvider
func (*FederationProvider) ProviderLabel ¶
func (*FederationProvider) ProviderLabel() string
func (*FederationProvider) Tools ¶
func (f *FederationProvider) Tools(ctx context.Context, session SessionContext) ([]sdk.Tool, error)
type HistoryMessageReader ¶
type HistoryMessageReader interface {
ListLatestBySession(ctx context.Context, sessionID string, limit int32) ([]messagepkg.Message, error)
ListBeforeBySession(ctx context.Context, sessionID string, before time.Time, limit int32) ([]messagepkg.Message, error)
GetByIDBySession(ctx context.Context, sessionID string, messageID string) (messagepkg.Message, error)
}
HistoryMessageReader is the minimal interface for reading persisted messages.
type HistoryProvider ¶
type HistoryProvider struct {
// contains filtered or unexported fields
}
HistoryProvider exposes list_sessions, get_messages, and search_messages tools.
func NewHistoryProvider ¶
func NewHistoryProvider(log *slog.Logger, sessions SessionLister, messages HistoryMessageReader, queries dbstore.Queries) *HistoryProvider
func (*HistoryProvider) Tools ¶
func (p *HistoryProvider) Tools(_ context.Context, sess SessionContext) ([]sdk.Tool, error)
func (*HistoryProvider) Usage ¶
func (*HistoryProvider) Usage(_ context.Context, _ SessionContext, available AvailableTools) string
type ImageGenProvider ¶
type ImageGenProvider struct {
// contains filtered or unexported fields
}
func NewImageGenProvider ¶
func (*ImageGenProvider) Tools ¶
func (p *ImageGenProvider) Tools(ctx context.Context, session SessionContext) ([]sdk.Tool, error)
func (*ImageGenProvider) Usage ¶
func (*ImageGenProvider) Usage(_ context.Context, session SessionContext, available AvailableTools) string
type MemoryProvider ¶
type MemoryProvider struct {
// contains filtered or unexported fields
}
func NewMemoryProvider ¶
func NewMemoryProvider(log *slog.Logger, registry *memprovider.Registry, settingsSvc MemorySettingsReader, sessions SessionLister) *MemoryProvider
func (*MemoryProvider) Tools ¶
func (p *MemoryProvider) Tools(ctx context.Context, session SessionContext) ([]sdk.Tool, error)
func (*MemoryProvider) Usage ¶
func (*MemoryProvider) Usage(_ context.Context, _ SessionContext, available AvailableTools) string
type MemorySettingsReader ¶
type MemorySettingsReader interface {
GetBot(ctx context.Context, botID string) (settings.Settings, error)
}
MemorySettingsReader returns bot settings for memory provider resolution.
type MessageProvider ¶
type MessageProvider struct {
// contains filtered or unexported fields
}
func NewMessageProvider ¶
func NewMessageProvider(log *slog.Logger, sender messaging.Sender, reactor messaging.Reactor, resolver messaging.ChannelTypeResolver, assetResolver messaging.AssetResolver) *MessageProvider
func (*MessageProvider) Tools ¶
func (p *MessageProvider) Tools(_ context.Context, session SessionContext) ([]sdk.Tool, error)
func (*MessageProvider) Usage ¶
func (*MessageProvider) Usage(_ context.Context, session SessionContext, available AvailableTools) string
type MessageSnapshot ¶
type MessageSnapshot struct {
// contains filtered or unexported fields
}
MessageSnapshot exposes an immutable copy of the messages currently visible to the model. Agent steps update the snapshot before each model call; tools can safely read it while sibling tool calls execute concurrently.
func NewMessageSnapshot ¶
func NewMessageSnapshot(messages []sdk.Message) *MessageSnapshot
func NewMessageSnapshotWithSources ¶
func NewMessageSnapshotWithSources(messages []sdk.Message, sourceMessageIDs []string) *MessageSnapshot
NewMessageSnapshotWithSources seeds a snapshot with the database message ID backing each message. Runtime-only messages use an empty source ID. Later Store calls preserve IDs only for unchanged messages that remain in order.
func (*MessageSnapshot) Entries ¶
func (s *MessageSnapshot) Entries() ([]MessageSnapshotEntry, error)
Entries returns the provider-neutral messages together with any persisted source message IDs retained from the resolver's initial history snapshot.
type MessageSnapshotEntry ¶
MessageSnapshotEntry describes one message in a forkable model context.
type NativeToolApprovalService ¶
type NativeToolApprovalService interface {
EvaluatePolicy(ctx context.Context, input toolapproval.CreatePendingInput) (toolapproval.Evaluation, error)
CreatePending(ctx context.Context, input toolapproval.CreatePendingInput) (toolapproval.Request, error)
Get(ctx context.Context, approvalID string) (toolapproval.Request, error)
Reject(ctx context.Context, approvalID, actorID, reason string) (toolapproval.Request, error)
WaitForDecision(ctx context.Context, approvalID string) (toolapproval.Request, error)
RegisterWaiter(approvalID string) func()
}
type NativeToolEventSink ¶
type NativeToolEventSink interface {
AppendToolEvent(session mcp.ToolSessionContext, event mcp.ToolStreamEvent) bool
}
NativeToolEventSink delivers tool lifecycle events into the live prompt stream of the calling runtime - the same channel tool_call_start travels - so attachments like pending user input land on the existing tool call block.
type NativeToolSource ¶
type NativeToolSource struct {
// contains filtered or unexported fields
}
NativeToolSource exposes Memoh-native ToolProvider tools through the MCP ToolSource interface used by ACP and external tool gateways.
func NewNativeToolSource ¶
func NewNativeToolSource(log *slog.Logger, providers []ToolProvider, opts NativeToolSourceOptions) *NativeToolSource
func (*NativeToolSource) ListTools ¶
func (s *NativeToolSource) ListTools(ctx context.Context, session mcp.ToolSessionContext) ([]mcp.ToolDescriptor, error)
func (*NativeToolSource) SetProviders ¶
func (s *NativeToolSource) SetProviders(providers []ToolProvider)
type NativeToolSourceOptions ¶
type NativeToolSourceOptions struct {
AllowAll bool
AllowTools map[string]bool
Approval NativeToolApprovalService
UserInput NativeToolUserInputService
ToolEvents NativeToolEventSink
ToolOutputLimit ToolOutputLimit
}
type NativeToolUserInputService ¶
type NativeToolUserInputService interface {
CreatePending(ctx context.Context, input userinput.CreatePendingInput) (userinput.Request, error)
Cancel(ctx context.Context, input userinput.CancelInput) (userinput.Request, error)
WaitForRegisteredResponse(ctx context.Context, requestID string) (userinput.Request, error)
// RegisterWaiter must be called before the pending request is announced
// to users, or an instant answer can be misjudged as orphaned.
RegisterWaiter(requestID string) func()
}
type ProviderLabeler ¶
type ProviderLabeler interface {
ProviderLabel() string
}
ProviderLabeler optionally names the accounting bucket a provider's tool definitions belong to. Providers without it count as native tools.
type Reaction ¶
type Reaction struct {
Emoji string `json:"emoji"`
MessageID string `json:"message_id"`
Remove bool `json:"remove,omitempty"`
}
Reaction describes an emoji reaction emitted by a tool.
type ReadMediaToolOutput ¶
type ReadMediaToolOutput struct {
Public ReadMediaToolResult
ImageBase64 string
ImageMediaType string
FileBase64 string
FileMediaType string
Filename string
}
ReadMediaToolOutput is the internal execution result used by the agent to inject the media into the next Twilight AI step while keeping the visible tool result lightweight. Exactly one of the Image/File pairs is populated: images go through ImageBase64, documents (PDF) through FileBase64.
func ReadImageFromContainer ¶
func ReadImageFromContainer(ctx context.Context, client *bridge.Client, path string, maxBytes int64) ReadMediaToolOutput
ReadImageFromContainer reads a binary file through the bridge client, validates that it is a supported image format, and returns a ReadMediaToolOutput ready for the agent decoration pipeline.
It reads only a small header first to sniff the MIME type, avoiding buffering large non-image binaries just to reject them.
type ReadMediaToolResult ¶
type ReadMediaToolResult struct {
OK bool `json:"ok"`
Path string `json:"path,omitempty"`
Mime string `json:"mime,omitempty"`
Size int `json:"size,omitempty"`
Error string `json:"error,omitempty"`
}
ReadMediaToolResult is the public result returned to the model.
type ScheduleProvider ¶
type ScheduleProvider struct {
// contains filtered or unexported fields
}
func NewScheduleProvider ¶
func NewScheduleProvider(log *slog.Logger, service Scheduler) *ScheduleProvider
func (*ScheduleProvider) Tools ¶
func (p *ScheduleProvider) Tools(_ context.Context, session SessionContext) ([]sdk.Tool, error)
func (*ScheduleProvider) Usage ¶
func (*ScheduleProvider) Usage(_ context.Context, _ SessionContext, available AvailableTools) string
Usage describes how the schedule tool group works together. Injected only when the schedule tools are registered (main-agent sessions with a schedule service); guidance is emitted only when schedule tools are actually present.
type Scheduler ¶
type Scheduler interface {
List(ctx context.Context, botID string) ([]sched.Schedule, error)
Get(ctx context.Context, id string) (sched.Schedule, error)
Create(ctx context.Context, botID string, req sched.CreateRequest) (sched.Schedule, error)
Update(ctx context.Context, id string, req sched.UpdateRequest) (sched.Schedule, error)
Delete(ctx context.Context, id string) error
}
Scheduler is the interface for schedule CRUD operations.
type SessionContext ¶
type SessionContext struct {
BotID string
ChatID string
SessionID string
SessionType string
UserID string
ChannelIdentityID string
SessionToken string //nolint:gosec // carries session credential material at runtime
CurrentPlatform string
ReplyTarget string
ConversationType string
CanRequestUserInput bool
CanListUserInput bool
SupportsImageInput bool
SupportsFileInput bool
IsSubagent bool
CurrentModelUUID string
CurrentModelID string
CurrentModelProvider string
// ReasoningStoredEffort and ReasoningRequestedEffort are the unresolved
// parent-turn inputs. A tool that selects another model must resolve them for
// that model rather than inheriting the parent's provider-specific decision.
ReasoningStoredEffort string
ReasoningRequestedEffort string
ForkContext *MessageSnapshot
// WorkspaceTargetID is the request-scoped default for file and command
// tools. An explicit tool target_id still takes precedence.
WorkspaceTargetID string
WorkspaceTargetKind string
WorkspaceTargetName string
// WorkdirPath is the session's immutable working directory. When set,
// relative tool paths resolve under it and exec defaults its cwd to it.
WorkdirPath string
Skills map[string]SkillDetail
TimezoneLocation *time.Location
Emitter StreamEmitter
LiveStream bool
ContextBudgetMaxTokens int
ContextToolExchangePolicy *contextfrag.ToolExchangePolicy
}
SessionContext carries request-scoped identity for tool execution.
func (SessionContext) CanAskUser ¶
func (s SessionContext) CanAskUser() bool
CanAskUser reports whether ask_user can be both shown to the model and delivered to the user in this run.
func (SessionContext) CanOmitMessagingTarget ¶
func (s SessionContext) CanOmitMessagingTarget() bool
CanOmitMessagingTarget reports whether messaging tools can safely default to the current conversation. Background sessions may have no live reply target, so their usage guidance should ask for explicit platform/target instead.
func (SessionContext) CanUseLocalMessagingShortcut ¶
func (s SessionContext) CanUseLocalMessagingShortcut() bool
CanUseLocalMessagingShortcut reports whether current-conversation side effects can be represented by the live agent stream instead of the channel sender. Non-interactive runs must use the real sender even when their target equals the current conversation.
func (SessionContext) FormatTime ¶
func (s SessionContext) FormatTime(t time.Time) string
FormatTime formats a time.Time using the session timezone (falls back to UTC).
func (SessionContext) IsSameConversation ¶
func (s SessionContext) IsSameConversation(platform, target string) bool
IsSameConversation reports whether the given platform+target pair refers to the conversation that the agent is currently replying to.
type SessionLister ¶
type SessionLister interface {
ListByBot(ctx context.Context, botID string) ([]session.Thread, error)
}
SessionLister is the minimal interface for listing sessions.
type SkillDetail ¶
SkillDetail holds the description and content of a loadable skill.
type SkillProvider ¶
type SkillProvider struct {
// contains filtered or unexported fields
}
func NewSkillProvider ¶
func NewSkillProvider(log *slog.Logger) *SkillProvider
func (*SkillProvider) Tools ¶
func (*SkillProvider) Tools(_ context.Context, session SessionContext) ([]sdk.Tool, error)
func (*SkillProvider) Usage ¶
func (*SkillProvider) Usage(_ context.Context, _ SessionContext, available AvailableTools) string
type SpawnAgent ¶
type SpawnAgent interface {
Generate(ctx context.Context, cfg SpawnRunConfig) (*SpawnResult, error)
GenerateWithWatchdog(ctx context.Context, cfg SpawnRunConfig, touchFn func()) (*SpawnResult, error)
}
SpawnAgent is the interface the subagent control tools use to run tasks. It is satisfied by *agent.Agent and avoids an import cycle.
type SpawnAttemptDisposition ¶
type SpawnAttemptDisposition uint8
SpawnAttemptDisposition names the authoritative outcome of one native attempt. Failed attempts can end the admitted run, retry inside it, or reflect owning cancellation; a clean end is recorded as completed.
const ( SpawnAttemptFailure SpawnAttemptDisposition = iota SpawnAttemptRetry SpawnAttemptAbort SpawnAttemptCompleted )
type SpawnIdentity ¶
type SpawnIdentity struct {
BotID string
ChatID string
SessionID string
UserID string
ChannelIdentityID string
CurrentPlatform string
ReplyTarget string
ConversationType string
SessionToken string //nolint:gosec // #nosec G117 -- session identifier, not a secret
WorkspaceTargetID string
WorkspaceTargetKind string
WorkspaceTargetName string
WorkdirPath string
TimezoneLocation *time.Location
IsSubagent bool
}
SpawnIdentity mirrors agent.SessionContext fields needed by subagent controls.
type SpawnLoopConfig ¶
type SpawnLoopConfig struct {
Enabled bool
}
SpawnLoopConfig mirrors agent.LoopDetectionConfig.
type SpawnProvider ¶
type SpawnProvider struct {
// contains filtered or unexported fields
}
SpawnProvider exposes managed subagent control tools.
func NewSpawnProvider ¶
func NewSpawnProvider( log *slog.Logger, settingsSvc *settings.Service, modelsSvc *models.Service, queries dbstore.Queries, sessionService *sessionpkg.Service, bgManager *background.Manager, ) *SpawnProvider
func (*SpawnProvider) SetAgent ¶
func (p *SpawnProvider) SetAgent(a SpawnAgent)
func (*SpawnProvider) SetHookService ¶
func (p *SpawnProvider) SetHookService(h *hooks.Service)
func (*SpawnProvider) SetMessageService ¶
func (p *SpawnProvider) SetMessageService(w messagepkg.Service)
func (*SpawnProvider) SetSubagentAdmitter ¶
func (p *SpawnProvider) SetSubagentAdmitter(admitter SubagentAdmitter)
SetSubagentAdmitter injects the admission gate. Setter injection for the same reason as the agent itself: this provider and the runtime that admits its runs are wired into one graph and each is reachable from the other's dependencies.
func (*SpawnProvider) SetSystemPromptFunc ¶
func (p *SpawnProvider) SetSystemPromptFunc(fn func(sessionType string) string)
func (*SpawnProvider) Tools ¶
func (p *SpawnProvider) Tools(ctx context.Context, session SessionContext) ([]sdk.Tool, error)
func (*SpawnProvider) Usage ¶
func (*SpawnProvider) Usage(_ context.Context, _ SessionContext, available AvailableTools) string
Usage frames how the available agent-control tools are meant to be used.
type SpawnResult ¶
type SpawnResult struct {
Messages []sdk.Message
Text string
Usage *sdk.Usage
ContextLifecycle *contextfrag.LifecycleSnapshot
// Persisted reports that incremental step persistence owned this run's
// history, so the caller must not persist the result again.
Persisted bool
}
SpawnResult mirrors agent.GenerateResult.
type SpawnRunConfig ¶
type SpawnRunConfig struct {
RunID string
Model *sdk.Model
ModelUUID string
ModelID string
ModelProvider string
System string
Query string
SessionType string
Identity SpawnIdentity
LoopDetection SpawnLoopConfig
Messages []sdk.Message
// ReasoningConfig is the thinking decision resolved for the subagent's own
// model. It replaces a lone effort string that was never assigned, which is
// how subagents came to run with no reasoning configuration at all (#983).
ReasoningConfig *models.ReasoningConfig
// Keep the unresolved parent-turn inputs as well, so a nested subagent can
// resolve the same override against its own selected model.
ReasoningStoredEffort string
ReasoningRequestedEffort string
PromptCacheTTL string
ChatCompletionsCompat string
SupportsImageInput bool
SupportsFileInput bool
SupportsToolCall bool
Skills map[string]SkillDetail
BackgroundManager *background.Manager
ContextBudgetMaxTokens int
ContextToolExchangePolicy *contextfrag.ToolExchangePolicy
// TurnRequestMessageID is the persisted task user message this run's
// assistant and tool rows bind to, so incremental step persistence files
// them into the same history turn the runtime view names.
TurnRequestMessageID string
// OnStepPersisted, if set, is called after a complete or interrupted step of
// this run has been durably persisted. The spawn provider uses it to stop
// retrying an attempt that has already produced durable output (and possibly
// real side effects): replaying the turn from the top would do that work twice.
OnStepPersisted func()
// Attempt is one-based and MaxAttempts is the total outer-attempt budget.
// ResolveAttempt is called at most once after a failed native attempt. It is
// the spawn provider's authoritative disposition: retry keeps the admitted
// run live, abort records owning cancellation, and failure ends the run.
// ResolveCompletion arbitrates a clean native end against concurrent owning
// cancellation before that end is published; it returns Completed, Abort for
// an explicit stop, or Failure for another owning-context failure.
// ReconcileTerminal applies the outcome selected by the session runtime when
// terminal publication races a routed control such as AbortControl.
Attempt int
MaxAttempts int
ResolveAttempt func(error) SpawnAttemptDisposition
ResolveCompletion func() SpawnAttemptDisposition
ReconcileTerminal func(SpawnAttemptDisposition)
}
SpawnRunConfig mirrors agent.RunConfig fields needed by subagent controls.
type Speech ¶
type Speech struct {
Text string `json:"text"`
}
Speech describes a TTS speech request emitted by a tool.
type StreamEmitter ¶
type StreamEmitter func(ToolStreamEvent)
StreamEmitter pushes a side-effect event into the current agent stream. Nil when no stream is available (e.g. subagent or non-streaming contexts where the caller collects events after generation).
type StreamEventType ¶
type StreamEventType string
StreamEventType identifies the kind of stream event emitted by tools.
const ( StreamEventAttachment StreamEventType = "attachment" StreamEventReaction StreamEventType = "reaction" StreamEventSpeech StreamEventType = "speech" StreamEventSpawnProgress StreamEventType = "spawn_progress" )
type SubagentAdmission ¶
SubagentAdmission names what admission allocated for the run. The turn identity matters to persistence: the task's user message must file as that turn's request (SR-TURN-001) so history and the live runtime view agree on which turn the run writes into — minting a second turn here would split one run across two turns in every subscriber's transcript.
type SubagentAdmitter ¶
type SubagentAdmitter interface {
// AdmitSubagentRun returns the context the run must execute in, the
// admitted identity, and the terminal write that releases the thread's
// slot, or an error naming why nothing was started. turn.ErrSessionBusy
// means the agent is already working; turn.ErrDuplicateTurn means this
// task already has a run.
AdmitSubagentRun(ctx context.Context, botID, threadID, invocationID string, submission []byte) (context.Context, SubagentAdmission, func(SubagentTerminal), error)
}
SubagentAdmitter is the durable admission gate a spawned agent's turn passes through before it executes.
A subagent occupies a thread exactly like any other turn, so it takes the same durable slot on the same terms: the run is recorded before anything runs, its owner holds a fencing token, and the returned finish closes the record. Declaring the port here rather than importing the runtime keeps the dependency pointing the one way it can — the runtime is built on top of the agent, which is built on top of these tools.
type SubagentTerminal ¶
type SubagentTerminal struct {
Cause error
ContextLifecycle *contextfrag.LifecycleSnapshot
OutcomeResolved bool
Outcome SpawnAttemptDisposition
}
SubagentTerminal is the terminal audit data returned to the application boundary after the subagent's internal retry loop has ended.
type SubagentWatchdog ¶
type SubagentWatchdog struct {
// contains filtered or unexported fields
}
SubagentWatchdog implements an activity-based timeout for subagent execution.
func NewSubagentWatchdog ¶
func (*SubagentWatchdog) Stop ¶
func (w *SubagentWatchdog) Stop()
func (*SubagentWatchdog) Touch ¶
func (w *SubagentWatchdog) Touch()
type TTSProvider ¶
type TTSProvider struct {
// contains filtered or unexported fields
}
func NewTTSProvider ¶
func (*TTSProvider) Tools ¶
func (p *TTSProvider) Tools(ctx context.Context, session SessionContext) ([]sdk.Tool, error)
func (*TTSProvider) Usage ¶
func (*TTSProvider) Usage(_ context.Context, session SessionContext, available AvailableTools) string
type ToolName ¶
ToolName identifies a built-in Memoh agent tool.
func BuiltInToolNames ¶
func BuiltInToolNames() []ToolName
func ReadMediaToolName ¶
func ReadMediaToolName() ToolName
ReadMediaToolName is the tool name that the agent decoration layer matches on to intercept image payloads. After the merge this is "read".
func ToolApplyPatch ¶
func ToolApplyPatch() ToolName
func ToolAskUser ¶
func ToolAskUser() ToolName
func ToolBrowserAction ¶
func ToolBrowserAction() ToolName
func ToolBrowserObserve ¶
func ToolBrowserObserve() ToolName
func ToolBrowserRemoteSession ¶
func ToolBrowserRemoteSession() ToolName
func ToolComputerAction ¶
func ToolComputerAction() ToolName
func ToolComputerObserve ¶
func ToolComputerObserve() ToolName
func ToolCreateSchedule ¶
func ToolCreateSchedule() ToolName
func ToolDeleteSchedule ¶
func ToolDeleteSchedule() ToolName
func ToolGenerateImage ¶
func ToolGenerateImage() ToolName
func ToolGenerateVideo ¶
func ToolGenerateVideo() ToolName
func ToolGetBackgroundStatus ¶
func ToolGetBackgroundStatus() ToolName
func ToolGetContacts ¶
func ToolGetContacts() ToolName
func ToolGetMessages ¶
func ToolGetMessages() ToolName
func ToolGetSchedule ¶
func ToolGetSchedule() ToolName
func ToolKillBackground ¶
func ToolKillBackground() ToolName
func ToolListACPAgents ¶
func ToolListACPAgents() ToolName
func ToolListAgents ¶
func ToolListAgents() ToolName
func ToolListBackground ¶
func ToolListBackground() ToolName
func ToolListEmail ¶
func ToolListEmail() ToolName
func ToolListEmailAccounts ¶
func ToolListEmailAccounts() ToolName
func ToolListExecutionLocations ¶
func ToolListExecutionLocations() ToolName
func ToolListModels ¶
func ToolListModels() ToolName
func ToolListSchedule ¶
func ToolListSchedule() ToolName
func ToolListSessions ¶
func ToolListSessions() ToolName
func ToolListSkills ¶
func ToolListSkills() ToolName
func ToolListWorkdirs ¶
func ToolListWorkdirs() ToolName
func ToolReadEmail ¶
func ToolReadEmail() ToolName
func ToolSearchMemory ¶
func ToolSearchMemory() ToolName
func ToolSearchMessages ¶
func ToolSearchMessages() ToolName
func ToolSendEmail ¶
func ToolSendEmail() ToolName
func ToolSendMessage ¶
func ToolSendMessage() ToolName
func ToolSpawnAgent ¶
func ToolSpawnAgent() ToolName
func ToolTranscribeAudio ¶
func ToolTranscribeAudio() ToolName
func ToolUpdateSchedule ¶
func ToolUpdateSchedule() ToolName
func ToolUseSkill ¶
func ToolUseSkill() ToolName
func ToolWaitUntil ¶
func ToolWaitUntil() ToolName
func ToolWebFetch ¶
func ToolWebFetch() ToolName
func ToolWebSearch ¶
func ToolWebSearch() ToolName
type ToolOutputLimit ¶
type ToolOutputLimit = contextlimit.ToolOutputLimit
type ToolProvider ¶
type ToolProvider interface {
Tools(ctx context.Context, session SessionContext) ([]sdk.Tool, error)
}
ToolProvider supplies a set of tools for the agent. Tools() is called per-request; implementations may return different tool sets based on session context (e.g. subagent restrictions, bot settings).
type ToolStreamEvent ¶
type ToolStreamEvent struct {
Type StreamEventType
// ToolCallID identifies the tool call that produced this side effect, so
// downstream persistence can anchor it to the right message (and keep the
// live ordering after a history reload). Empty when unknown.
ToolCallID string
Attachments []Attachment
Reactions []Reaction
Speeches []Speech
}
ToolStreamEvent is a side-effect event emitted by a tool targeting the current conversation (e.g. inline attachment, reaction, or TTS speech). The agent framework converts these into the appropriate wire-level events.
type ToolUsage ¶
type ToolUsage interface {
Usage(ctx context.Context, session SessionContext, available AvailableTools) string
}
ToolUsage is an optional capability a ToolProvider may also implement to contribute group-level usage guidance to the system prompt — how this set of tools is meant to be used together (e.g. "look up a target with get_contacts before messaging another conversation"). The agent injects the returned text only when the same provider actually returns tools for the session, so the guidance shares that provider's gating and stays in lockstep with the tools that provider registers. available contains the complete registered tool set for this session; use available.Ref/Refs before naming cross-provider tools. Return "" to contribute nothing.
type TranscriptionProvider ¶
type TranscriptionProvider struct {
// contains filtered or unexported fields
}
func (*TranscriptionProvider) Tools ¶
func (p *TranscriptionProvider) Tools(ctx context.Context, session SessionContext) ([]sdk.Tool, error)
type VideoGenProvider ¶
type VideoGenProvider struct {
// contains filtered or unexported fields
}
func NewVideoGenProvider ¶
func (*VideoGenProvider) Tools ¶
func (p *VideoGenProvider) Tools(ctx context.Context, session SessionContext) ([]sdk.Tool, error)
type WebFetchProvider ¶
type WebFetchProvider struct {
// contains filtered or unexported fields
}
func NewWebFetchProvider ¶
func NewWebFetchProvider(log *slog.Logger, settingsSvc *settings.Service, fetchSvc *fetchproviders.Service) *WebFetchProvider
func (*WebFetchProvider) Tools ¶
func (p *WebFetchProvider) Tools(_ context.Context, session SessionContext) ([]sdk.Tool, error)
type WebProvider ¶
type WebProvider struct {
// contains filtered or unexported fields
}
func NewWebProvider ¶
func NewWebProvider(log *slog.Logger, settingsSvc *settings.Service, searchSvc *searchproviders.Service) *WebProvider
func (*WebProvider) Tools ¶
func (p *WebProvider) Tools(_ context.Context, session SessionContext) ([]sdk.Tool, error)
type WorkdirLister ¶
type WorkdirLister interface {
List(ctx context.Context, botID string, includeArchived bool) ([]workdir.Workdir, error)
}
WorkdirLister is the slice of the workdir domain the tool needs.
type WorkdirProvider ¶
type WorkdirProvider struct {
// contains filtered or unexported fields
}
WorkdirProvider exposes the bot's named working directories so the agent can reference them by id — today that means binding a scheduled task to a workdir via create_schedule.
func NewWorkdirProvider ¶
func NewWorkdirProvider(log *slog.Logger, service WorkdirLister) *WorkdirProvider
func (*WorkdirProvider) Tools ¶
func (p *WorkdirProvider) Tools(_ context.Context, session SessionContext) ([]sdk.Tool, error)
Source Files
¶
- acp_agents.go
- apply_patch.go
- ask_user.go
- attachment_bundle.go
- background.go
- browser.go
- computer_a11y.go
- contacts.go
- container.go
- email.go
- federation.go
- fsops.go
- history.go
- history_visibility.go
- image_gen.go
- memory.go
- message.go
- names.go
- native_source.go
- output_limit.go
- prune.go
- read_media.go
- schedule.go
- skill.go
- subagent.go
- subagent_admission.go
- subagent_policy.go
- transcribe.go
- tts.go
- types.go
- video_gen.go
- web.go
- webfetch.go
- workdir.go