Documentation
¶
Overview ¶
Package setup wires every workflow subpkg together. Server code instantiates one Manager via New and calls Start to boot the engine, router, and all registered workflows.
Index ¶
- func Bootstrap(ctx context.Context, svc service.Service, router *trigger.Router, ...) error
- func CleanupRuns(layout config.Layout, opts CleanupOptions) (removed int, err error)
- func ConnectorsCredsAdapter(svc *connectorsvc.Service) func(module, row string) (map[string]string, error)
- func HotReload(ctx context.Context, svc service.Service, router *trigger.Router, ...) error
- func NewCLIProviders() ([]provider.Provider, error)
- func RegisterLiveChannels(wfReg *channel.Registry, base *agentchannels.Registry)
- func RegisterLiveConnectors(reg *connector.Registry)
- func RegisterSlackIntegration(intReg *integration.Registry, base *agentchannels.Registry, ...)
- func WatchWorkflows(ctx context.Context, workflowsDir string, svc service.Service, ...)
- type CleanupOptions
- type Manager
- func (m *Manager) Start(ctx context.Context) error
- func (m *Manager) Stop()
- func (m *Manager) WithAgentRuntime(p *pool.Pool, sub nodes.AgentSubscribeFn) *Manager
- func (m *Manager) WithChannels(chs ...channel.Channel) *Manager
- func (m *Manager) WithGuardConfig(cfg guard.Config) *Manager
- func (m *Manager) WithProvider(p provider.Provider) *Manager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bootstrap ¶
func Bootstrap(ctx context.Context, svc service.Service, router *trigger.Router, cron *trigger.CronScheduler, schedAt *trigger.ScheduleAtScheduler) error
Bootstrap wires every workflow folder found at startup into the router + cron scheduler. Called once from server startup after Service + Router are constructed.
func CleanupRuns ¶
func CleanupRuns(layout config.Layout, opts CleanupOptions) (removed int, err error)
CleanupRuns walks runs/ and removes old ones per policy.
func ConnectorsCredsAdapter ¶
func ConnectorsCredsAdapter(svc *connectorsvc.Service) func(module, row string) (map[string]string, error)
ConnectorsCredsAdapter wraps the connectors service to expose a connector.RowCredsFn for the workflow registry. Lookup is by (module key, row label) — first matching label wins; empty row falls back to the first instance for that Key.
func HotReload ¶
func HotReload(ctx context.Context, svc service.Service, router *trigger.Router, cron *trigger.CronScheduler, schedAt *trigger.ScheduleAtScheduler, id string) error
HotReload reloads + re-registers (or unregisters) one id. Used by fsnotify watcher in production.
func NewCLIProviders ¶
NewCLIProviders returns one workflow.Provider per healthy CLI runtime declared by the agent provider package. Caller registers each into the workflow Manager.
func RegisterLiveChannels ¶
func RegisterLiveChannels(wfReg *channel.Registry, base *agentchannels.Registry)
RegisterLiveChannels rewires the workflow channel registry to use the live agentchannels.Registry as its backing source. Channels become workflow-visible automatically once they implement agentchannels.WorkflowTriggerProvider or WorkflowActionProvider — channels without either (UI, API, REST one-shot) stay invisible to the workflow editor.
Call after the base channel registry has its channels added (after channels/setup constructs them in server.go) and before wfMgr.Start(ctx).
func RegisterLiveConnectors ¶
RegisterLiveConnectors copies every connector module currently registered in internal/connectors/ into the workflow connector registry. Call after connectors.RegisterBuiltins() has populated the global registry — otherwise the workflow registry is empty and `type: connector` nodes fail with "module not registered".
func RegisterSlackIntegration ¶
func RegisterSlackIntegration(intReg *integration.Registry, base *agentchannels.Registry, router *trigger.Router, pickers *wfmcp.PickerRegistry)
RegisterSlackIntegration wires the Slack channel into the workflow integration surface. Two pieces, both required for end-to-end:
ActionDescriptor / EventDescriptor registration — slackwf.RegisterAll pushes every per-event + per-action descriptor (send_message, open_modal, on_message, on_block_action, …) into intReg so the palette + the engine see them.
Inbound event sink — wires slack.Channel.SetWorkflowEventSink so every Slack callback (message, block_action, view_submission, slash command, …) fires router.Dispatch with a normalised workflow.Event.
No-op if Slack isn't registered or the channel isn't the expected type — callers can call this unconditionally regardless of which channels are configured.
func WatchWorkflows ¶
func WatchWorkflows(ctx context.Context, workflowsDir string, svc service.Service, router *trigger.Router, cron *trigger.CronScheduler, schedAt *trigger.ScheduleAtScheduler)
WatchWorkflows polls <workflowsDir>/*/workflow.yaml every 3 seconds and calls HotReload on any id whose mtime changed since the last poll. New files trigger a load; removed files trigger an unregister. Blocks until ctx is cancelled — run in a goroutine.
Types ¶
type CleanupOptions ¶
type CleanupOptions struct {
SuccessTTL time.Duration
FailedTTL time.Duration
KeepMax int
Now func() time.Time
}
CleanupOptions tunes the daily run-retention pass.
type Manager ¶
type Manager struct {
Layout config.Layout
Service *service.FileService
StateStore *state.FileStore
Engine *engine.Engine
Router *trigger.Router
Cron *trigger.CronScheduler
ScheduleAt *trigger.ScheduleAtScheduler
Canvas *canvas.Canvas
Channels *channel.Registry
Integration *integration.Registry
Connectors *connector.Registry
Providers *provider.Registry
Datasets dataset.Service
Guard *guard.Guard
Cost *cost.Tracker
MCP *mcp.Ops
// AgentPool + AgentSubscribe route the `agent` + `session_init`
// node types through the shared agent pool. Nil = engine still
// runs (codex/gemini via cliProvider), but claude path skips the
// queue/sidebar/session-reuse benefits. See workflow/pool.md.
AgentPool *pool.Pool
AgentSubscribe nodes.AgentSubscribeFn
}
Manager bundles every wired piece so server.go can hand one struct to consumers (UI handlers, MCP transport, jobs).
func New ¶
New constructs every dependency wired to a single Layout. Channels, connectors, providers, and guard start empty — caller plugs them in via With* before Start.
func (*Manager) Start ¶
Start ensures layout, bootstraps router with current workflows, and kicks off the cron scheduler. Idempotent — safe to call from main.go on every boot.
func (*Manager) WithAgentRuntime ¶
WithAgentRuntime wires the shared agent pool + a subscribe adapter into the workflow engine so `agent` and `session_init` nodes route through the queue/session machinery. The subscribe function is the thin adapter around tools/agents.Broadcaster (kept out of this package to avoid an import cycle).
Calling re-registers the agent + session_init executors so the dependency takes effect immediately. Idempotent; nil arguments disable the pool path (engine reverts to the cliProvider one-shot).
func (*Manager) WithChannels ¶
WithChannels registers one or more channels.
func (*Manager) WithGuardConfig ¶
WithGuardConfig replaces the guard configuration.