Documentation
¶
Overview ¶
Package manager — connectors_api_account.go: the per-connected-account read model and its one mutation.
Purpose: An account is its own thing to administer, not a sub-row of the instance page. It has operations that may differ from the instance's, a history of what it actually did, a Test runner pinned to its identity, and the two lifecycle actions (re-connect, disconnect). This file serves exactly that, so a person who may not configure the instance still has a page for the account that is theirs.
Caller: the manager SPA's AccountDetail page Dependencies: connectors.Service (accounts, op states, overrides) Main Functions:
- apiAccountDetail() — GET the account + its resolved operations
- apiSetAccountOpOverride() — POST one operation's inherit/on/off state
Side Effects: the POST writes the account's override map.
Package manager — connectors_api_admin.go: JSON twins of the per-row admin controls that previously lived only on the form-post templ pages (rate limit, duplicate, access policy, session config, operation toggles, and account management). Each handler reuses the same service calls + permission gates as its templ sibling in connectors.go — the only difference is JSON in/out instead of form-post + redirect, so the manager SPA can drive them without a page reload.
Package manager — oauth.go: Generic connector OAuth 2.0 flow handler.
Purpose: Implements the two-leg OAuth 2.0 flow for any connector that has Module.OAuth set to a non-nil *connector.OAuthMeta. Routes are registered under /manager/connectors/{key}/oauth/* so the Redirect URI is always /manager/connectors/{key}/oauth/callback.
Caller: Handler.connectorRoutes() (public, not behind auth middleware) Dependencies: connector.OAuthMeta, configs.Service, connectors.Service Main Functions:
- oauthRoutes() — registers start + callback routes (public)
- oauthStart() — builds state, redirects to provider consent page
- oauthCallback() — validates state, exchanges code, saves token
- oauthSaveToken() — persists xoxp/access token to connector row
- migrateOAuthAppToInstances() — one-shot boot migration: copies shared connector_oauth:{key} credentials into every instance row that has not yet been configured.
Storage:
- Per-instance OAuth credentials: connector row configs (client_id, client_secret)
- Legacy shared credentials: configs owner "connector_oauth:{key}" (migrated away)
- Pending states: Handler.oauthPending (sync.Map, 10-min TTL)
Side Effects: writes access token to connector row via connectors.Service.
Index ¶
- func InstalledHealth(probe func(kind, key string) (bool, string)) source.HealthFunc
- func SPAMount() (assetURL, base string)
- type Handler
- func (h *Handler) Register(mux *http.ServeMux, authMidd *login.Middleware)
- func (h *Handler) RegisterConfigDecorator(toolKey string, fn func([]entity.Config) []entity.Config)
- func (h *Handler) SetCustomConnectors(svc *customconn.Service)
- func (h *Handler) SetPluginResolver(r pluginIdentityResolver)
- func (h *Handler) SetToolsSource(fn func() []tool.Tool) *Handler
- func (h *Handler) SetWebhookRoutesSource(fn func() []tool.WebhookRoute) *Handler
- func (h *Handler) WithWebhookRoutes(routes []tool.WebhookRoute) *Handler
- type PluginSourcesHandler
- type PluginsHandler
- func (h *PluginsHandler) RegisterRoutes(mux *http.ServeMux, authMidd *login.Middleware)
- func (h *PluginsHandler) SetLoadState(fn func(kind, key string) (state, reason string)) *PluginsHandler
- func (h *PluginsHandler) SetReloader(r reconciler) *PluginsHandler
- func (h *PluginsHandler) SetReplaceRefresh(fn func(ctx context.Context, owner string, rows ...pkgentity.Config) error) *PluginsHandler
- func (h *PluginsHandler) SetSources(s *PluginSourcesHandler) *PluginsHandler
- func (h *PluginsHandler) SetUninstall(unload func(ctx context.Context, kind, key string), ...) *PluginsHandler
- type Service
- func (s *Service) Bootstrap(ctx context.Context, mods []job.Module) error
- func (s *Service) CancelJob(ctx context.Context, key string) error
- func (s *Service) GetJob(ctx context.Context, key string) (*entity.Job, error)
- func (s *Service) GetRun(ctx context.Context, runID string) (*entity.JobRun, error)
- func (s *Service) ListEnabledJobs(ctx context.Context) ([]entity.Job, error)
- func (s *Service) ListJobs(ctx context.Context) ([]entity.Job, error)
- func (s *Service) ListRuns(ctx context.Context, key string, limit int) ([]entity.JobRun, error)
- func (s *Service) ResetStuckForJob(ctx context.Context, j *entity.Job) (bool, error)
- func (s *Service) RunCron(ctx context.Context, key string) (string, error)
- func (s *Service) RunManual(ctx context.Context, key string, userID string) (string, error)
- func (s *Service) RunningCount() int
- func (s *Service) RunningKeys() []string
- func (s *Service) SetConfigReader(c cfgReader)
- func (s *Service) SetHidden(fn func(key string) bool)
- func (s *Service) UpdateSchedule(ctx context.Context, key string, schedule string, enabled bool, maxRuns int, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstalledHealth ¶ added in v1.2.9
func InstalledHealth(probe func(kind, key string) (bool, string)) source.HealthFunc
InstalledHealth is the default step-6 check: the installed binary still verifies against its manifest, plus whatever runtime probe the caller adds (service plugins: supervisor state).
func SPAMount ¶ added in v0.22.2
func SPAMount() (assetURL, base string)
SPAMount exposes the manager SPA's entry bundle URL and client-side route base so another host (e.g. the Agents shell) can render the same SPA inside its own chrome without duplicating the embed/asset wiring. Assets keep loading from the manager asset handler at spaAssetBase and the client router keeps its /manager base, so every in-SPA API call and internal navigation resolves against the live /manager/* routes. The host is just a different outer shell around the same #app div.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler wires the /manager/* routes. Manager owns job scheduling, runtime configs for jobs and tools, and the admin surface for connector rows.
func NewHandler ¶
func (*Handler) Register ¶
func (h *Handler) Register(mux *http.ServeMux, authMidd *login.Middleware)
Register wires /manager/* to mux. All pages require auth; admin-only actions (edits, regenerate, run) add RequireAdmin on top.
func (*Handler) RegisterConfigDecorator ¶ added in v0.9.0
RegisterConfigDecorator registers a function that is called on the config rows for toolKey just before the manager detail page is rendered. Use it to inject dynamic Options (e.g. workspace names) into specific rows.
func (*Handler) SetCustomConnectors ¶ added in v0.17.0
func (h *Handler) SetCustomConnectors(svc *customconn.Service)
SetCustomConnectors late-binds the custom-connector service. The builder routes under /manager/connectors/custom/* render only when this is non-nil; the connectors index additionally shows the "+ New connector" dropdown and the "Custom" card badges.
func (*Handler) SetPluginResolver ¶ added in v0.26.0
func (h *Handler) SetPluginResolver(r pluginIdentityResolver)
SetPluginResolver wires the connector plugin manager so the OAuth callback can resolve token owners for plugin-backed connectors. Call only with a non-nil resolver to avoid the typed-nil-interface trap.
func (*Handler) SetToolsSource ¶ added in v1.16.0
SetToolsSource makes the handler read its tool list from fn on every use instead of the slice given to NewHandler, so a tool plugin loaded or unloaded while wick runs is found (or not) without a restart.
func (*Handler) SetWebhookRoutesSource ¶ added in v1.16.0
func (h *Handler) SetWebhookRoutesSource(fn func() []tool.WebhookRoute) *Handler
SetWebhookRoutesSource adds fn's routes (tool plugins, which come and go at runtime) to the boot-time ones given to WithWebhookRoutes.
func (*Handler) WithWebhookRoutes ¶ added in v1.2.9
func (h *Handler) WithWebhookRoutes(routes []tool.WebhookRoute) *Handler
WithWebhookRoutes records the webhook endpoints tools declared at boot. Called once from server.go after the tool router has collected them; returns h so it can be chained onto NewHandler.
type PluginSourcesHandler ¶ added in v1.2.9
type PluginSourcesHandler struct {
Sources *source.Manager
// Health reports runtime health of an installed key (step 6 of Test).
Health source.HealthFunc
}
PluginSourcesHandler serves Admin → Plugins: sources (url / GitHub), the Available list they offer, zip upload, the six-step Test, Check now, and the per-plugin source status the detail pages use for the "Update available" badge. Reading is open to any logged-in user; every action is admin-only. A source's PAT is write-only — responses only say has_pat.
func (*PluginSourcesHandler) RegisterRoutes ¶ added in v1.2.9
func (h *PluginSourcesHandler) RegisterRoutes(mux *http.ServeMux, authMidd *login.Middleware)
RegisterRoutes wires /manager/api/plugin-sources and the upload endpoint.
type PluginsHandler ¶ added in v0.26.0
type PluginsHandler struct {
// contains filtered or unexported fields
}
func NewPluginsHandler ¶ added in v0.26.0
func NewPluginsHandler(db *gorm.DB) *PluginsHandler
NewPluginsHandler builds the marketplace handler. db backs the enable/disable overlay; dir is the installed-plugins directory (connplugin.DefaultDir()).
func (*PluginsHandler) RegisterRoutes ¶ added in v0.26.0
func (h *PluginsHandler) RegisterRoutes(mux *http.ServeMux, authMidd *login.Middleware)
RegisterRoutes wires the marketplace endpoints under /manager/api/plugins. Listing is readable by any logged-in user (mirrors built-in connectors: everyone can browse, only admins can act). The state-changing actions — install / update / enable / disable / remove — stay admin-only.
func (*PluginsHandler) SetLoadState ¶ added in v1.16.0
func (h *PluginsHandler) SetLoadState(fn func(kind, key string) (state, reason string)) *PluginsHandler
SetLoadState wires what the running process has loaded: for a kind it reports on, fn returns "active" (loaded), "pending" (installed, not looked at yet), "error" or "idle" (not loaded; reason says why); "" for a kind it does not report on. The Installed list uses it so Active means loaded, not just enabled.
func (*PluginsHandler) SetReloader ¶ added in v0.27.0
func (h *PluginsHandler) SetReloader(r reconciler) *PluginsHandler
SetReloader wires the hot-reload poller so state-changing actions reconcile immediately. Safe to leave unset — reload() then does nothing.
func (*PluginsHandler) SetReplaceRefresh ¶ added in v1.2.9
func (h *PluginsHandler) SetReplaceRefresh(fn func(ctx context.Context, owner string, rows ...pkgentity.Config) error) *PluginsHandler
SetReplaceRefresh wires the configs-cache refresh the replace endpoint calls after an apply, so copied values are live without a restart.
func (*PluginsHandler) SetSources ¶ added in v1.2.9
func (h *PluginsHandler) SetSources(s *PluginSourcesHandler) *PluginsHandler
SetSources routes updates of source-installed plugins to their source.
func (*PluginsHandler) SetUninstall ¶ added in v1.2.9
func (h *PluginsHandler) SetUninstall(unload func(ctx context.Context, kind, key string), builtin func(key string) bool) *PluginsHandler
SetUninstall wires what Uninstall needs beyond deleting files: unload stops the running plugin first, builtin guards built-in keys.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages job lifecycle: bootstrap from code-defined jobs, manual/scheduled execution, and result storage.
func NewService ¶
func NewService(r *repo) *Service
func NewServiceFromDB ¶
NewServiceFromDB is a convenience constructor for callers that only have a *gorm.DB (e.g. the worker process and the web server).
func (*Service) Bootstrap ¶
Bootstrap syncs code-defined jobs with the jobs table. New jobs get a row with their default cron; existing rows keep admin-managed fields. One module registration = one row.
func (*Service) CancelJob ¶ added in v0.14.0
CancelJob stops a running job by key. It cancels the in-process run when this process owns one, then closes the books either way: open run rows become "cancelled" and last_status flips to idle. Called on a job whose row is stale (DB says running, nothing actually is) it repairs the row instead of failing, so Cancel is also the operator's unstick button. Errors only when the job is idle everywhere.
The context cancel is best-effort by nature: a RunFunc that ignores its context keeps executing until its timeout, but the DB no longer calls the job running, its row can't block future triggers, and any late finalize is guarded (FinishRun / SetIdleIfNoOpenRun) so it can't resurrect the cancelled state.
func (*Service) ListEnabledJobs ¶
func (*Service) ResetStuckForJob ¶ added in v0.14.6
ResetStuckForJob exposes the per-job stuck-run sweep so the worker tick can call it inline while iterating its enabled-jobs list. See repo.ResetStuckForJob for the conditions a run must meet to be classified as stuck.
func (*Service) RunningCount ¶ added in v1.2.9
RunningCount is how many job runs this process owns right now.
func (*Service) RunningKeys ¶ added in v1.2.9
RunningKeys names the jobs currently running, so a drain log says which one is holding things up.
func (*Service) SetConfigReader ¶
func (s *Service) SetConfigReader(c cfgReader)
SetConfigReader installs the configs-service view used to build a job.Ctx on every run. Called by wick at boot after both services have been constructed. Safe to skip in tests — Run() then sees a no-op Ctx where every Cfg(...) read returns "".
Source Files
¶
- audit.go
- audit_api.go
- connectors.go
- connectors_api.go
- connectors_api_account.go
- connectors_api_admin.go
- connectors_api_detail.go
- connectors_api_history.go
- connectors_api_test_meta.go
- connectors_browser_extensions.go
- connectors_browser_proxy.go
- connectors_redirect.go
- custom_connectors.go
- custom_connectors_api.go
- custom_mcp_api.go
- handler.go
- jobs_tools_api.go
- oauth.go
- plugin_sources_api.go
- plugins_api.go
- plugins_installed_api.go
- plugins_redirect.go
- repo.go
- service.go
- spa.go
- spa_handler.go