korvun

module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: Apache-2.0

README

Korvun logo

Korvun

Kernel for Orchestrated Routing — Versatile Unified Nodes
A self-hosted AI messaging gateway, multi-model router, and multi-brain orchestrator in a single Go binary.

Quality Gate CodeQL OpenSSF Scorecard Latest release

Korvun Desktop — the same core, in a native window. Downloads ↓


What is Korvun?

Korvun is one self-hosted Go binary that is a messaging gateway, a multi-model router, and a multi-brain orchestrator at once. A real message enters a channel, is routed to a brain, one or more models answer, a policy decides the reply, and it goes back — all in a single process. The same static binary runs on a Raspberry Pi and scales in the cloud; only I/O pieces change by configuration.

The differentiator is the dispatch policy engine. Routing is privacy- and cost-aware, with opt-in consensus, as policies of one engine:

  • Privacy — a brain marked private never sends its payload to a cloud model; the privacy selector drops cloud providers before they are called. What is sensitive does not leave the machine.
  • Cost — everything else is routed to the cheapest capable model, with a sequential fail-over that pays a cloud provider only when the local one fails.
  • Consensus (opt-in) — critical brains can fan out to several models and pick the reply by agreement.

Features

Everything below is on master today — no roadmap item is counted as present.

  • Channels — Telegram (polling), Discord (Gateway WebSocket inbound with a resume/reconnect supervisor, REST outbound with mentions blocked by default — see DISCORD-SETUP.md), and a generic Webhook channel, behind one normalized message shape (Envelope).

  • Multi-brain orchestration — several brains coexist; each coordinates multiple models in parallel fan-out or cost-saving sequential fail-over, from config.

  • Model providers — local Ollama and cloud Groq, behind one Model interface and a shared sentinel-error grammar.

  • Policy engine — the privacy / cost / consensus routing above (PriorityReducer, ConsensusReducer, and the pre-dispatch privacy SelectModels).

  • Resilience (ADR-0031) — two-layer per-attempt timeouts, retry with differentiated fallback, and an optional boot warmup that resolves the cold-start model-load stall.

  • No-code builder — configure brains, models, and routes visually in the browser, no JSON by hand (BUILDER.md).

  • Observability — structured slog, a Prometheus /metrics endpoint, and a /healthz liveness probe on a loopback admin server.

  • Durable memory — per-conversation history that survives restarts, graceful shutdown included (SQLite by default, behind a Store seam).

  • Cross-platform — one static, pure-Go binary (no cgo) for Linux, macOS, and Windows on x86-64 and ARM64.

  • Signed releases — each release ships cosign keyless signatures over the checksums and a per-artifact SBOM (SPDX via Syft).

  • First-class CLIserve, config check, status, version, help:

    korvun serve --config korvun.json            # load config, wire, serve
    korvun config check --preflight korvun.json  # validate offline (+ online checks)
    korvun status                                # live wiring of a running instance
    korvun version                               # build identity
    korvun help                                  # usage
    

Korvun Desktop

Since v0.4.0 the same core also ships as a native desktop app. The full Go gateway runs in-process — one binary, one version, one release — behind a native window: first-run onboarding, an assistant that stores every secret in your OS keychain, and the visual builder embedded. Double-click, no terminal. The headless binary is unchanged and is still the way to run Korvun on a server.

Activity feed with expandable decision badges for each routed message. Channels list with a Telegram channel in polling mode, healthy, routed to the asistente brain.
Activity — every routing decision, explained where it happens. Keychain assistant — tokens go to the OS keychain, never to the config. Channels — each channel with its mode, health and brain.

Download v0.4.0 · macOS — universal .dmg · Windows x64 — installer · Linux x64 — tar.gz

Builds are unsigned: the first launch needs right-click → Open on macOS and "More info → Run anyway" on Windows — see Install & run. Built with Wails on the system WebView, so there is no bundled browser. Prefer the terminal? The headless binary ships in the same release.

Quick start

Prefer a window to a terminal? Korvun Desktop is the same gateway with a UI — download, double-click, done. The steps below are the headless path, still the way to run Korvun on a server.

Grab a signed binary from releases, then:

# 1. korvun.example.json — a minimal, valid starting config. It lives in this repo,
#    and is bundled in the release archive from v0.2.0 onward.
korvun config check korvun.example.json      # validate it (offline, no secrets)

# 2. Provide the bot token by environment (never in the config file)
export TELEGRAM_BOT_TOKEN=<your-bot-token>

# 3. Run
korvun serve --config korvun.example.json

Full walkthrough — install and verify, configure, message the bot — in QUICKSTART.md. The legacy korvun -config <path> invocation still works via a retrocompat shim; korvun serve --config … is canonical.

Documentation

Guide What it covers
Quickstart Zero to a running bot.
Discord bot setup Create the bot, the Message Content intent, invite, round-trip.
Configuration Every config field, from the schema and ADRs.
No-code builder Configure Korvun visually in the browser.
Install & run as a service Download, verify, hardened systemd unit.
Korvun Desktop The native app: download, first launch on each OS, verify the desktop artifacts.
Architecture Decision Records Why each piece is built the way it is (incl. ADR-0032, the CLI contract).
Stage closure docs What is closed, stage by stage.

Verifying a release

Releases are signed keyless with cosign (Sigstore) and ship an SBOM. Verify the checksums signature, then check your archive against the verified checksums.txt:

cosign verify-blob checksums.txt \
  --signature checksums.txt.sig \
  --certificate checksums.txt.pem \
  --certificate-identity-regexp 'https://github.com/Sebastian197/korvun/.*' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com

Status

v0.4.0 is the current release. It ships Korvun Desktop — the same in-process core as a native, double-click app (first-run onboarding, OS-keychain secrets, the embedded builder) on macOS, Windows, and Linux, cosign-signed on the free chain — alongside the unchanged headless binary, which is still the way to run Korvun on a server. Validated end to end on real hardware — see the release notes. master builds on toward a production beta; see ROADMAP-V1.md and ROAD-TO-BETA.md for what is closed and what comes next.

Contributing

Contributions follow strict, non-negotiable conventions (TDD first, Context7 before any external library, Conventional Commits, make quality green with -race before every commit). Read CONTRIBUTING.md first.

Security

Please do not open public issues for vulnerabilities. See SECURITY.md for the private reporting channel and supported versions.

License

Licensed under the Apache License 2.0 — see LICENSE.

Directories

Path Synopsis
cmd
demo-agent command
Command demo-agent is a disposable live skeleton for the Stage 8 tool-use AgentBrain (ADR-0021).
Command demo-agent is a disposable live skeleton for the Stage 8 tool-use AgentBrain (ADR-0021).
korvun command
Command korvun is the Korvun binary.
Command korvun is the Korvun binary.
korvun-desktop/e2e-harness command
Command e2e-harness serves the BUILT desktop chrome and the SP4 same-origin admin proxy from one loopback origin, over a REAL no-network core, mirroring the Wails AssetServer semantics — assets first, handler on miss — so Playwright drives the real pipeline without a WebView (SP6 spec: the per-cut screenshot medium; the native WKWebView ride is SP8's hardware validation).
Command e2e-harness serves the BUILT desktop chrome and the SP4 same-origin admin proxy from one loopback origin, over a REAL no-network core, mirroring the Wails AssetServer semantics — assets first, handler on miss — so Playwright drives the real pipeline without a WebView (SP6 spec: the per-cut screenshot medium; the native WKWebView ride is SP8's hardware validation).
internal
app
Package app turns a validated config.Config into a wired, ready-to-run Korvun system (ADR-0017 §0).
Package app turns a validated config.Config into a wired, ready-to-run Korvun system (ADR-0017 §0).
brain
Package brain declares the minimal contract a reasoning engine must implement to participate in Korvun's router.
Package brain declares the minimal contract a reasoning engine must implement to participate in Korvun's router.
buildinfo
Package buildinfo formats the binary's version identity for the --version flag (ADR-0025 §2).
Package buildinfo formats the binary's version identity for the --version flag (ADR-0025 §2).
bus
Package bus is Korvun's in-process event bus: a best-effort, non-blocking publish/subscribe tap over the message pipeline's lifecycle (ADR-0023, Stage 14 Phase 1a).
Package bus is Korvun's in-process event bus: a best-effort, non-blocking publish/subscribe tap over the message pipeline's lifecycle (ADR-0023, Stage 14 Phase 1a).
channel
Package channel defines the interface that every messaging adapter must implement, along with a registry for managing active channels.
Package channel defines the interface that every messaging adapter must implement, along with a registry for managing active channels.
channel/discord
Package discord is the Discord channel adapter (Piece 4, ADR-0033).
Package discord is the Discord channel adapter (Piece 4, ADR-0033).
channel/telegram
Package telegram is the Korvun channel adapter for Telegram Bot updates.
Package telegram is the Korvun channel adapter for Telegram Bot updates.
channel/webhook
Package webhook implements a generic webhook channel adapter that converts arbitrary JSON payloads into Envelopes using a configurable field mapping.
Package webhook implements a generic webhook channel adapter that converts arbitrary JSON payloads into Envelopes using a configurable field mapping.
cli
Package cli is the command-line surface of the korvun binary (Piece 3): it parses argv, dispatches the subcommands (serve / config / status / version / help), and owns the retrocompat shim so the pre-CLI invocation `korvun -config x.json` keeps behaving as an implicit `serve`.
Package cli is the command-line surface of the korvun binary (Piece 3): it parses argv, dispatches the subcommands (serve / config / status / version / help), and owns the retrocompat shim so the pre-CLI invocation `korvun -config x.json` keeps behaving as an implicit `serve`.
config
Package config parses and validates a Korvun deployment descriptor from a JSON file into a typed Config (ADR-0017 §1).
Package config parses and validates a Korvun deployment descriptor from a JSON file into a typed Config (ADR-0017 §1).
controlapi
Package controlapi serves the read-only operator control API (ADR-0022, Stage 13): two GET endpoints under /api exposing the live, resolved wiring of a running Korvun process.
Package controlapi serves the read-only operator control API (ADR-0022, Stage 13): two GET endpoints under /api exposing the live, resolved wiring of a running Korvun process.
conversation
Package conversation owns the conversation-memory domain: the canonical conversation Key, the Turn record, the Role of a turn, and the Store seam the Brain reads from before a dispatch and writes to after a reply (ADR-0018, Stage 9 ADR-A).
Package conversation owns the conversation-memory domain: the canonical conversation Key, the Turn record, the Role of a turn, and the Store seam the Brain reads from before a dispatch and writes to after a reply (ADR-0018, Stage 9 ADR-A).
conversation/sqlite
Package sqlite is the durable implementation of the conversation.Store seam (ADR-0019, Stage 9 ADR-B), backed by SQLite through the pure-Go modernc.org/sqlite driver (no cgo — decisive for the Pi/ARM cross-compile).
Package sqlite is the durable implementation of the conversation.Store seam (ADR-0019, Stage 9 ADR-B), backed by SQLite through the pure-Go modernc.org/sqlite driver (no cgo — decisive for the Pi/ARM cross-compile).
envelope
Package envelope defines the canonical message type used throughout Korvun.
Package envelope defines the canonical message type used throughout Korvun.
httpserver
Package httpserver is a small, general HTTP server with a Start/Shutdown lifecycle the app drives (ADR-0020 §4).
Package httpserver is a small, general HTTP server with a Start/Shutdown lifecycle the app drives (ADR-0020 §4).
liveview
Package liveview is Korvun's read-only live-view: a Server-Sent Events stream of the message pipeline's lifecycle (GET /api/events) plus a minimal embedded vanilla HTML/JS UI (/ui), both mounted on the existing admin httpserver (ADR-0024, Stage 14 Phase 1b).
Package liveview is Korvun's read-only live-view: a Server-Sent Events stream of the message pipeline's lifecycle (GET /api/events) plus a minimal embedded vanilla HTML/JS UI (/ui), both mounted on the existing admin httpserver (ADR-0024, Stage 14 Phase 1b).
metrics
Package metrics owns the observability seam (ADR-0020 §2): a push interface the domain records operational events through, plus a Nop default so a nil backend is never possible.
Package metrics owns the observability seam (ADR-0020 §2): a push interface the domain records operational events through, plus a Nop default so a nil backend is never possible.
metrics/prom
Package prom is the Prometheus implementation of the metrics.Metrics seam (ADR-0020 §2).
Package prom is the Prometheus implementation of the metrics.Metrics seam (ADR-0020 §2).
model
Package model defines the abstraction every reasoning provider in Korvun talks through.
Package model defines the abstraction every reasoning provider in Korvun talks through.
model/fanout
Package fanout coordinates the parallel dispatch of a single model.Request to N model.Model implementations and collects every outcome.
Package fanout coordinates the parallel dispatch of a single model.Request to N model.Model implementations and collects every outcome.
model/groq
Package groq implements internal/model.Model against the Groq cloud API.
Package groq implements internal/model.Model against the Groq cloud API.
model/ollama
Package ollama implements internal/model.Model against a local Ollama server.
Package ollama implements internal/model.Model against a local Ollama server.
model/retry
Package retry provides a per-instance decorator over model.Model that owns the per-attempt deadline for every dispatch shape and retries ONLY genuinely transient post-load errors (ADR-0031 Decisions 4 and 5).
Package retry provides a per-instance decorator over model.Model that owns the per-attempt deadline for every dispatch shape and retries ONLY genuinely transient post-load errors (ADR-0031 Decisions 4 and 5).
model/sequential
Package sequential coordinates the SERIAL dispatch of a single model.Request to N model.Model implementations, stopping at the first success.
Package sequential coordinates the SERIAL dispatch of a single model.Request to N model.Model implementations, stopping at the first success.
policy
Package policy turns the outcomes of a model fan-out into a single Decision according to a configurable dispatch policy.
Package policy turns the outcomes of a model fan-out into a single Decision according to a configurable dispatch policy.
router
Package router wires inbound Envelopes from channels to brains and outbound replies back to channels.
Package router wires inbound Envelopes from channels to brains and outbound replies back to channels.
shell
Package shell is the desktop shell's lifecycle logic (ADR-0035 §3a): plain Go functions — load a config, start/stop the in-process core under the reload supervisor, the ephemeral-port policy, per-cycle admin-bearer provisioning, secret provisioning from the OS keychain (the SecretStore seam; real backend in the keyring subpackage), status, and the same-origin admin proxy the WebView rides (ProxyHandler, ADR-0035 §3b) — with NO Wails import, so everything tests as ordinary Go with -race.
Package shell is the desktop shell's lifecycle logic (ADR-0035 §3a): plain Go functions — load a config, start/stop the in-process core under the reload supervisor, the ephemeral-port policy, per-cycle admin-bearer provisioning, secret provisioning from the OS keychain (the SecretStore seam; real backend in the keyring subpackage), status, and the same-origin admin proxy the WebView rides (ProxyHandler, ADR-0035 §3b) — with NO Wails import, so everything tests as ordinary Go with -race.
shell/keyring
Package keyring is the real OS-keychain backend behind shell.SecretStore (ADR-0035 §4, ADR-0037): Keychain Services on macOS, Credential Manager on Windows, Secret Service D-Bus on Linux — via zalando/go-keyring, the only package in the repo that imports it.
Package keyring is the real OS-keychain backend behind shell.SecretStore (ADR-0035 §4, ADR-0037): Keychain Services on macOS, Credential Manager on Windows, Secret Service D-Bus on Linux — via zalando/go-keyring, the only package in the repo that imports it.
supervisor
Package supervisor owns the Korvun app lifecycle ABOVE a single *app.App (ADR-0027).
Package supervisor owns the Korvun app lifecycle ABOVE a single *app.App (ADR-0027).
tool
Package tool owns the agent Tool seam (ADR-0021 §4): the interface an AgentBrain invokes mid-reasoning, plus the minimal, PURE built-in tools the Stage 8 seam-validation slice ships.
Package tool owns the agent Tool seam (ADR-0021 §4): the interface an AgentBrain invokes mid-reasoning, plus the minimal, PURE built-in tools the Stage 8 seam-validation slice ships.
web
builder
Package builderui embeds the built Vite bundle (web/builder/dist) and serves it at /builder with a strict same-origin Content-Security-Policy (ADR-0029 §5 / ADR-0030 §4).
Package builderui embeds the built Vite bundle (web/builder/dist) and serves it at /builder with a strict same-origin Content-Security-Policy (ADR-0029 §5 / ADR-0030 §4).

Jump to

Keyboard shortcuts

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