app

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package app is the public entry point for downstream projects that want to embed wick as a library. A typical main looks like:

package main

import "github.com/yogasw/wick/app"

func main() {
    app.RegisterTool(toolMeta, toolCfg, mytool.Register)
    app.RegisterJob(jobMeta, jobCfg, myjob.Run)
    app.Run()
}

Navbar, admin, auth, rendering, and the cron scheduler are handled by wick; downstream only supplies per-instance meta, a typed config value, and a RegisterFunc / RunFunc that does the work.

Index

Constants

This section is empty.

Variables

View Source
var (
	BuildVersion = "dev"
	BuildCommit  = "unknown"
	BuildTime    = "unknown"
)

BuildVersion, BuildCommit, and BuildTime are injected via -ldflags at build time. wick mcp serve reads VERSION from the project root and injects it automatically. When used as a library dependency, init() fills these from the embedded module build info.

Functions

func RegisterConnector added in v0.4.0

func RegisterConnector[C any](meta connector.Meta, creds C, ops []connector.Operation)

RegisterConnector adds a connector definition to the registry. One call = one Go module wired up to wick's MCP layer; per-instance rows (credentials, labels, tags) are created later from the admin UI and stored in the connector_instances table.

app.RegisterConnector(
    loki.Meta(),
    loki.Creds{},        // typed credential struct, reflected for the form
    loki.Operations(),   // []connector.Operation, one per LLM-callable action
)

creds is a typed struct whose exported fields carry `wick:"..."` tags and represent per-instance credential / endpoint values shared across every operation of this connector. ops is the list of named actions (one MCP tool per op per instance); each carries its own input schema and ExecuteFunc. Pass an empty struct{}{} for creds when the connector has no credentials.

func RegisterJob

func RegisterJob[C any](meta job.Meta, cfg C, run job.RunFunc)

RegisterJob adds a downstream background job to the registry. One call = one row in the jobs table; call again with a different meta.Key (and, if you want, a different cfg) to register a second scheduled instance backed by the same RunFunc. The job is seeded on first boot with meta.DefaultCron; admins override from /manager/jobs.

app.RegisterJob(
    job.Meta{Key: "auto-get-data", Name: "Auto Get Data", Icon: "🌐", DefaultCron: "*/30 * * * *"},
    autogetdata.Config{Endpoint: "https://api.example.com"},
    autogetdata.Run,
)

cfg is a typed struct whose exported fields carry `wick:"..."` tags. Wick reflects it once here into `configs` rows scoped to meta.Key — Run reads live values via job.FromContext(ctx).Cfg(...). Pass an empty struct{}{} when the job has no runtime-editable knobs.

func RegisterJobNoConfig

func RegisterJobNoConfig(meta job.Meta, run job.RunFunc)

RegisterJobNoConfig is the variant for jobs that have nothing to configure at runtime. Equivalent to RegisterJob with an empty struct{} cfg.

func RegisterTool

func RegisterTool[C any](meta tool.Tool, cfg C, register tool.RegisterFunc)

RegisterTool adds a tool instance to the registry. One call = one card on the home grid; call again with a different meta.Key (and, if you want, a different cfg) to register a second instance backed by the same RegisterFunc.

app.RegisterTool(
    tool.Tool{Key: "convert-text", Name: "Convert Text", Icon: "Aa"},
    converttext.Config{InitText: "hello world"},
    converttext.Register,
)

cfg is a typed struct whose exported fields carry `wick:"..."` tags. Wick reflects it once here into `configs` rows scoped to meta.Key — handlers read the live values via c.Cfg(...) at request time.

func RegisterToolNoConfig

func RegisterToolNoConfig(meta tool.Tool, register tool.RegisterFunc)

RegisterToolNoConfig is the variant for tools that have nothing to configure at runtime — e.g. external redirect links. Equivalent to RegisterTool with an empty struct{} cfg.

func Run

func Run()

Run parses the command-line flags and starts either the HTTP server or the background worker. Subcommands:

server   — run the HTTP server (default)
worker   — run the background job worker
mcp serve — run MCP server over stdio

Blocks until shutdown.

Types

This section is empty.

Jump to

Keyboard shortcuts

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