Documentation
¶
Index ¶
- Constants
- func NormalizeWorkspaceID(workspaceID string) string
- func WithPromptExecution(ctx context.Context, override *ProviderOverride, source string, ...) context.Context
- type AgentExecutor
- type AgentInfo
- type ChannelMessage
- type CommandExecutor
- type CommandExecutorOptions
- type ConsensusSpec
- type ConsensusVariantRecord
- type ExecuteRequest
- type GatewayStatus
- type PromptExecutionContext
- type PromptExecutionMetadata
- type PromptExecutor
- type PromptExecutorOptions
- type ProviderOverride
- type ReportChannels
- type ReportRuns
- type ReportSummary
- type ResolvedProviderOverride
- type Run
- type RunEvent
- type RunStatus
- type Runtime
- func (r *Runtime) Agents() []map[string]any
- func (r *Runtime) Cancel(runID string) (Run, error)
- func (r *Runtime) CancelByWorkspace(workspaceID, runID string) (Run, error)
- func (r *Runtime) Close(ctx context.Context) error
- func (r *Runtime) Enabled() bool
- func (r *Runtime) Get(runID string) (Run, bool)
- func (r *Runtime) GetByWorkspace(workspaceID, runID string) (Run, bool)
- func (r *Runtime) GetOrZero(runID string) Run
- func (r *Runtime) InboundTelegram(botID, threadID, text string, payload map[string]any) (ChannelMessage, error)
- func (r *Runtime) InboundTelegramByWorkspace(workspaceID, botID, threadID, text string, payload map[string]any) (ChannelMessage, error)
- func (r *Runtime) InboundWebhook(channelID, threadID, text string, payload map[string]any) (ChannelMessage, error)
- func (r *Runtime) InboundWebhookByWorkspace(workspaceID, channelID, threadID, text string, payload map[string]any) (ChannelMessage, error)
- func (r *Runtime) List(limit int) []Run
- func (r *Runtime) ListByWorkspace(workspaceID string, limit int) []Run
- func (r *Runtime) LookupAgent(name string) (AgentInfo, bool)
- func (r *Runtime) MessageRead(channelID string, limit int) ([]ChannelMessage, error)
- func (r *Runtime) MessageReadByWorkspace(workspaceID, channelID string, limit int) ([]ChannelMessage, error)
- func (r *Runtime) MessageSend(channelID, threadID, text string) (ChannelMessage, error)
- func (r *Runtime) MessageSendByWorkspace(workspaceID, channelID, threadID, text string) (ChannelMessage, error)
- func (r *Runtime) OutboundTelegram(botID, chatID, threadID, text string, payload map[string]any) (ChannelMessage, error)
- func (r *Runtime) OutboundTelegramByWorkspace(workspaceID, botID, chatID, threadID, text string, payload map[string]any) (ChannelMessage, error)
- func (r *Runtime) Reload() GatewayStatus
- func (r *Runtime) ReportsChannels(limit int) (ReportChannels, error)
- func (r *Runtime) ReportsChannelsByWorkspace(workspaceID string, limit int) (ReportChannels, error)
- func (r *Runtime) ReportsRuns(limit int) (ReportRuns, error)
- func (r *Runtime) ReportsRunsByWorkspace(workspaceID string, limit int) (ReportRuns, error)
- func (r *Runtime) ReportsSummary() (ReportSummary, error)
- func (r *Runtime) ReportsSummaryByWorkspace(workspaceID string) (ReportSummary, error)
- func (r *Runtime) Restart() GatewayStatus
- func (r *Runtime) SetAgentsWatchEnabled(enabled bool)
- func (r *Runtime) SetExecutors(executors []AgentExecutor, defaultAgent string)
- func (r *Runtime) Spawn(ctx context.Context, req SpawnRequest) (Run, error)
- func (r *Runtime) Status() GatewayStatus
- func (r *Runtime) SubagentLimits() (maxThreads int, maxDepth int)
- func (r *Runtime) SubscribeRunEvents(runID string) (<-chan RunEvent, func())
- func (r *Runtime) ThreadReply(channelID, threadID, text string) (ChannelMessage, error)
- func (r *Runtime) ThreadReplyByWorkspace(workspaceID, channelID, threadID, text string) (ChannelMessage, error)
- func (r *Runtime) Wait(ctx context.Context, runID string) (Run, error)
- type RuntimeOptions
- type SpawnRequest
Constants ¶
const DefaultWorkspaceID = "default"
Variables ¶
This section is empty.
Functions ¶
func NormalizeWorkspaceID ¶
func WithPromptExecution ¶ added in v0.25.0
func WithPromptExecution(ctx context.Context, override *ProviderOverride, source string, metadata *PromptExecutionMetadata) context.Context
Types ¶
type AgentExecutor ¶
type AgentInfo ¶
type AgentInfo struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Enabled bool `json:"enabled"`
Kind string `json:"kind,omitempty"`
Source string `json:"source,omitempty"`
Entry string `json:"entry,omitempty"`
PolicyMode string `json:"policy_mode"`
ToolsAllow []string `json:"tools_allow,omitempty"`
ToolsAllowCount int `json:"tools_allow_count"`
ToolsDeny []string `json:"tools_deny,omitempty"`
ToolsDenyCount int `json:"tools_deny_count"`
ToolsRiskMax string `json:"tools_risk_max,omitempty"`
ToolsAllowGroups []string `json:"tools_allow_groups,omitempty"`
ToolsDenyGroups []string `json:"tools_deny_groups,omitempty"`
ToolsAllowPatterns []string `json:"tools_allow_patterns,omitempty"`
SessionRoutingMode string `json:"session_routing_mode,omitempty"`
SessionFixedID string `json:"session_fixed_id,omitempty"`
Tier string `json:"tier,omitempty"`
ProviderOverride *ProviderOverride `json:"provider_override,omitempty"`
}
type ChannelMessage ¶
type ChannelMessage struct {
ID string `json:"id"`
WorkspaceID string `json:"-"`
ChannelID string `json:"channel_id"`
ThreadID string `json:"thread_id,omitempty"`
Direction string `json:"direction"`
Source string `json:"source"`
Text string `json:"text"`
Payload map[string]any `json:"payload,omitempty"`
Timestamp string `json:"timestamp"`
}
type CommandExecutor ¶
type CommandExecutor struct {
// contains filtered or unexported fields
}
func NewCommandExecutor ¶
func NewCommandExecutor(opts CommandExecutorOptions) (*CommandExecutor, error)
func (*CommandExecutor) Execute ¶
func (e *CommandExecutor) Execute(ctx context.Context, req ExecuteRequest) (string, error)
func (*CommandExecutor) Info ¶
func (e *CommandExecutor) Info() AgentInfo
type CommandExecutorOptions ¶
type ConsensusSpec ¶ added in v0.25.0
type ConsensusSpec struct {
Strategy string `json:"strategy,omitempty"`
Variants []ProviderOverride `json:"variants,omitempty"`
Aggregator *ProviderOverride `json:"aggregator,omitempty"`
}
type ConsensusVariantRecord ¶ added in v0.25.0
type ConsensusVariantRecord struct {
VariantIdx int `json:"variant_idx"`
Alias string `json:"alias,omitempty"`
Kind string `json:"kind,omitempty"`
Model string `json:"model,omitempty"`
Status string `json:"status,omitempty"`
Response string `json:"response,omitempty"`
Error string `json:"error,omitempty"`
TokensIn int `json:"tokens_in,omitempty"`
TokensOut int `json:"tokens_out,omitempty"`
CostUSD float64 `json:"cost_usd,omitempty"`
StartedAt string `json:"started_at,omitempty"`
FinishedAt string `json:"finished_at,omitempty"`
}
type ExecuteRequest ¶
type ExecuteRequest struct {
RunID string
WorkspaceID string
SessionID string
Prompt string
AllowedTools []string
Tier string
ProviderOverride *ProviderOverride
OverrideSource string
Metadata *PromptExecutionMetadata
}
type GatewayStatus ¶
type GatewayStatus struct {
Enabled bool `json:"enabled"`
Version int64 `json:"version"`
RunsTotal int `json:"runs_total"`
RunsActive int `json:"runs_active"`
AgentsCount int `json:"agents_count"`
AgentsWatchEnabled bool `json:"agents_watch_enabled"`
AgentsReloadVersion int64 `json:"agents_reload_version"`
AgentsLastReloadAt string `json:"agents_last_reload_at,omitempty"`
ChannelsLocal bool `json:"channels_local_enabled"`
ChannelsWebhook bool `json:"channels_webhook_enabled"`
ChannelsTelegram bool `json:"channels_telegram_enabled"`
PersistenceEnabled bool `json:"persistence_enabled"`
RunsPersistenceEnabled bool `json:"runs_persistence_enabled"`
ChannelsPersistenceEnabled bool `json:"channels_persistence_enabled"`
RestoreOnStartup bool `json:"restore_on_startup"`
PersistenceDir string `json:"persistence_dir,omitempty"`
RunsRestored int `json:"runs_restored"`
ChannelsRestored int `json:"channels_restored"`
LastPersistAt string `json:"last_persist_at,omitempty"`
LastRestoreAt string `json:"last_restore_at,omitempty"`
LastRestoreError string `json:"last_restore_error,omitempty"`
LastReloadAt string `json:"last_reload_at,omitempty"`
LastRestartAt string `json:"last_restart_at,omitempty"`
}
type PromptExecutionContext ¶ added in v0.25.0
type PromptExecutionContext struct {
ProviderOverride *ProviderOverride
OverrideSource string
Metadata *PromptExecutionMetadata
}
func PromptExecutionFromContext ¶ added in v0.25.0
func PromptExecutionFromContext(ctx context.Context) PromptExecutionContext
type PromptExecutionMetadata ¶ added in v0.25.0
type PromptExecutionMetadata struct {
ResolvedAlias string
ResolvedKind string
ResolvedModel string
OverrideSource string
}
func ResolveOverride ¶ added in v0.25.0
func ResolveOverride(cfg *config.Config, tier string, override *ProviderOverride, overrideSource string) (config.ResolvedLLMTier, PromptExecutionMetadata, error)
type PromptExecutor ¶
type PromptExecutor struct {
// contains filtered or unexported fields
}
func NewPromptExecutor ¶
func NewPromptExecutorWithOptions ¶
func NewPromptExecutorWithOptions(opts PromptExecutorOptions) (*PromptExecutor, error)
func (*PromptExecutor) Execute ¶
func (e *PromptExecutor) Execute(ctx context.Context, req ExecuteRequest) (string, error)
func (*PromptExecutor) Info ¶
func (e *PromptExecutor) Info() AgentInfo
type PromptExecutorOptions ¶
type PromptExecutorOptions struct {
Name string
Description string
Source string
Entry string
PolicyMode string
ToolsAllow []string
ToolsDeny []string
ToolsRiskMax string
ToolsAllowGroups []string
ToolsDenyGroups []string
ToolsAllowPatterns []string
SessionRoutingMode string
SessionFixedID string
Tier string
ProviderOverride *ProviderOverride
RunPrompt func(ctx context.Context, runLabel string, prompt string, allowedTools []string, tier string, providerOverride *ProviderOverride) (string, error)
}
type ProviderOverride ¶ added in v0.25.0
type ProviderOverride struct {
Alias string `json:"alias,omitempty" yaml:"alias,omitempty"`
Model string `json:"model,omitempty" yaml:"model,omitempty"`
}
func CloneProviderOverride ¶ added in v0.25.0
func CloneProviderOverride(value *ProviderOverride) *ProviderOverride
type ReportChannels ¶
type ReportChannels struct {
GeneratedAt string `json:"generated_at"`
ArchiveEnabled bool `json:"archive_enabled"`
Count int `json:"count"`
Messages map[string][]ChannelMessage `json:"messages"`
}
type ReportRuns ¶
type ReportSummary ¶
type ReportSummary struct {
GeneratedAt string `json:"generated_at"`
SummaryEnabled bool `json:"summary_enabled"`
ArchiveEnabled bool `json:"archive_enabled"`
RunsTotal int `json:"runs_total"`
RunsActive int `json:"runs_active"`
RunsByStatus map[string]int `json:"runs_by_status"`
ChannelsTotal int `json:"channels_total"`
MessagesTotal int `json:"messages_total"`
MessagesBySource map[string]int `json:"messages_by_source"`
}
type ResolvedProviderOverride ¶ added in v0.25.0
type Run ¶
type Run struct {
ID string `json:"run_id"`
WorkspaceID string `json:"-"`
SessionID string `json:"session_id,omitempty"`
SessionKind string `json:"session_kind,omitempty"`
Agent string `json:"agent,omitempty"`
Prompt string `json:"prompt,omitempty"`
ParentRunID string `json:"parent_run_id,omitempty"`
RootRunID string `json:"root_run_id,omitempty"`
ParentSessionID string `json:"parent_session_id,omitempty"`
Depth int `json:"depth,omitempty"`
Status RunStatus `json:"status"`
Accepted bool `json:"accepted"`
Response string `json:"response,omitempty"`
Error string `json:"error,omitempty"`
DiagnosticCode string `json:"diagnostic_code,omitempty"`
DiagnosticReason string `json:"diagnostic_reason,omitempty"`
PolicyBlockedTool string `json:"policy_blocked_tool,omitempty"`
PolicyBlockedRule string `json:"policy_blocked_rule,omitempty"`
PolicyBlockedGroup string `json:"policy_blocked_group,omitempty"`
PolicyBlockedSource string `json:"policy_blocked_source,omitempty"`
PolicyAllowedTools []string `json:"policy_allowed_tools,omitempty"`
PolicyDeniedTools []string `json:"policy_denied_tools,omitempty"`
PolicyRiskMax string `json:"policy_risk_max,omitempty"`
FlowID string `json:"flow_id,omitempty"`
StepID string `json:"step_id,omitempty"`
Tier string `json:"tier,omitempty"`
ConsensusMode string `json:"consensus_mode,omitempty"`
ConsensusVariants []ConsensusVariantRecord `json:"consensus_variants,omitempty"`
ConsensusCostUSD float64 `json:"consensus_cost_usd,omitempty"`
ConsensusBudgetUSD float64 `json:"consensus_budget_usd,omitempty"`
ProviderOverride *ProviderOverride `json:"provider_override,omitempty"`
ResolvedAlias string `json:"resolved_alias,omitempty"`
ResolvedKind string `json:"resolved_kind,omitempty"`
ResolvedModel string `json:"resolved_model,omitempty"`
OverrideSource string `json:"override_source,omitempty"`
CreatedAt string `json:"created_at"`
StartedAt string `json:"started_at,omitempty"`
CompletedAt string `json:"completed_at,omitempty"`
UpdatedAt string `json:"updated_at"`
}
type RunEvent ¶ added in v0.25.0
type RunEvent struct {
Type string `json:"type"`
RunID string `json:"run_id"`
Timestamp string `json:"timestamp,omitempty"`
Agent string `json:"agent,omitempty"`
Status string `json:"status,omitempty"`
Tier string `json:"tier,omitempty"`
ResolvedAlias string `json:"resolved_alias,omitempty"`
ResolvedKind string `json:"resolved_kind,omitempty"`
ResolvedModel string `json:"resolved_model,omitempty"`
Error string `json:"error,omitempty"`
Message string `json:"message,omitempty"`
Response string `json:"response,omitempty"`
VariantCount int `json:"variant_count,omitempty"`
VariantIdx int `json:"variant_idx,omitempty"`
Alias string `json:"alias,omitempty"`
Kind string `json:"kind,omitempty"`
Model string `json:"model,omitempty"`
Strategy string `json:"strategy,omitempty"`
TokenBudget int `json:"token_budget,omitempty"`
TokensIn int `json:"tokens_in,omitempty"`
TokensOut int `json:"tokens_out,omitempty"`
FinalTokens int `json:"final_tokens,omitempty"`
CostUSDEstimate float64 `json:"cost_usd_estimate,omitempty"`
CostUSDActual float64 `json:"cost_usd_actual,omitempty"`
}
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func NewRuntime ¶
func NewRuntime(opts RuntimeOptions) *Runtime
func (*Runtime) CancelByWorkspace ¶
func (*Runtime) GetByWorkspace ¶
func (*Runtime) InboundTelegram ¶
func (*Runtime) InboundTelegramByWorkspace ¶
func (*Runtime) InboundWebhook ¶
func (*Runtime) InboundWebhookByWorkspace ¶
func (*Runtime) ListByWorkspace ¶
func (*Runtime) LookupAgent ¶ added in v0.10.0
func (*Runtime) MessageRead ¶
func (r *Runtime) MessageRead(channelID string, limit int) ([]ChannelMessage, error)
func (*Runtime) MessageReadByWorkspace ¶
func (r *Runtime) MessageReadByWorkspace(workspaceID, channelID string, limit int) ([]ChannelMessage, error)
func (*Runtime) MessageSend ¶
func (r *Runtime) MessageSend(channelID, threadID, text string) (ChannelMessage, error)
func (*Runtime) MessageSendByWorkspace ¶
func (r *Runtime) MessageSendByWorkspace(workspaceID, channelID, threadID, text string) (ChannelMessage, error)
func (*Runtime) OutboundTelegram ¶
func (*Runtime) OutboundTelegramByWorkspace ¶
func (*Runtime) Reload ¶
func (r *Runtime) Reload() GatewayStatus
func (*Runtime) ReportsChannels ¶
func (r *Runtime) ReportsChannels(limit int) (ReportChannels, error)
func (*Runtime) ReportsChannelsByWorkspace ¶
func (r *Runtime) ReportsChannelsByWorkspace(workspaceID string, limit int) (ReportChannels, error)
ReportsChannelsByWorkspace returns recent in-memory channel messages. See ReportsRunsByWorkspace for why GatewayArchiveEnabled also gates this endpoint despite reading from in-memory state (RF-057, ID-005).
func (*Runtime) ReportsRuns ¶
func (r *Runtime) ReportsRuns(limit int) (ReportRuns, error)
func (*Runtime) ReportsRunsByWorkspace ¶
func (r *Runtime) ReportsRunsByWorkspace(workspaceID string, limit int) (ReportRuns, error)
ReportsRunsByWorkspace returns recent in-memory run summaries.
Despite the name, the gating flag GatewayArchiveEnabled doubles as the "report endpoint visibility" switch — it controls both on-disk archive writes and whether this in-memory report endpoint serves data, even though the data itself is from r.runs (memory) and never touches the archive directory. Operators who want only the report endpoint without disk archives still have to enable archive_enabled. Splitting this into a dedicated GatewayReportEnabled flag is tracked in RF-057 as part of the broader config namespace migration (ID-005).
func (*Runtime) ReportsSummary ¶
func (r *Runtime) ReportsSummary() (ReportSummary, error)
func (*Runtime) ReportsSummaryByWorkspace ¶
func (r *Runtime) ReportsSummaryByWorkspace(workspaceID string) (ReportSummary, error)
func (*Runtime) Restart ¶
func (r *Runtime) Restart() GatewayStatus
func (*Runtime) SetAgentsWatchEnabled ¶
func (*Runtime) SetExecutors ¶
func (r *Runtime) SetExecutors(executors []AgentExecutor, defaultAgent string)
func (*Runtime) Status ¶
func (r *Runtime) Status() GatewayStatus
func (*Runtime) SubagentLimits ¶ added in v0.10.0
func (*Runtime) SubscribeRunEvents ¶ added in v0.25.0
func (*Runtime) ThreadReply ¶
func (r *Runtime) ThreadReply(channelID, threadID, text string) (ChannelMessage, error)
func (*Runtime) ThreadReplyByWorkspace ¶
func (r *Runtime) ThreadReplyByWorkspace(workspaceID, channelID, threadID, text string) (ChannelMessage, error)
type RuntimeOptions ¶
type RuntimeOptions struct {
Enabled bool
WorkspaceDir string
SessionStore *session.Store
SessionStoreForWorkspace func(workspaceID string) *session.Store
RunPrompt func(ctx context.Context, runLabel string, prompt string) (string, error)
Executors []AgentExecutor
DefaultAgent string
GatewayAgentsWatchEnabled bool
ChannelsLocalEnabled bool
ChannelsWebhookEnabled bool
ChannelsTelegramEnabled bool
GatewayPersistenceEnabled bool
GatewayRunsPersistenceEnabled bool
GatewayChannelsPersistenceEnabled bool
GatewayRunsMaxRecords int
GatewayChannelsMaxMessagesPerChannel int
GatewaySubagentsMaxThreads int
GatewaySubagentsMaxDepth int
GatewayConsensusEnabled bool
GatewayConsensusMaxFanout int
GatewayConsensusBudgetTokens int
GatewayConsensusBudgetUSD float64
GatewayConsensusTimeoutSeconds int
GatewayConsensusAllowedAliases []string
GatewayConsensusConcurrentRuns int
GatewayPersistenceDir string
GatewayRestoreOnStartup bool
GatewayReportSummaryEnabled bool
GatewayArchiveEnabled bool
GatewayArchiveDir string
GatewayArchiveRetentionDays int
GatewayArchiveMaxFileBytes int
ResolveProviderOverride func(tier string, override *ProviderOverride) (ResolvedProviderOverride, error)
EstimateTokensCost func(provider, model string, inputTokens, outputTokens int) (float64, bool)
Now func() time.Time
}
type SpawnRequest ¶
type SpawnRequest struct {
WorkspaceID string
SessionID string
Title string
Prompt string
Agent string
ParentRunID string
RootRunID string
ParentSessionID string
Depth int
SessionKind string
SessionHidden bool
FlowID string
StepID string
Tier string
Mode string
Consensus *ConsensusSpec
ProviderOverride *ProviderOverride
}