sekia Documentation

Complete reference for sekia, a multi-agent event bus for automating workflows across GitHub and Gmail, built on embedded NATS with JetStream.

What is sekia?

sekia is an event bus that connects external services (GitHub, Gmail) to Lua workflows via embedded NATS messaging with JetStream. Events from agents flow into the bus, Lua handlers react to them, and commands flow back out to agents.

The system follows Unix philosophy: small, composable tools. Four standalone binaries communicate over NATS:

  • sekiad — the daemon (embedded NATS + JetStream, agent registry, workflow engine, API)
  • sekiactl — CLI to inspect and control the daemon
  • sekia-github — GitHub agent (webhooks + polling)
  • sekia-google — Google agent (Gmail)

Installation

Homebrew

Each component is a separate formula. Add the tap, then install the daemon/CLI and any agents you need:

brew tap sekia-ai/tap

# Daemon + CLI (required) plus the agents you need
brew install sekia sekia-github sekia-google

Each formula includes a launchd service definition. Use brew services to run them as background services:

# Start the daemon and agents as background services
brew services start sekia
brew services start sekia-github
brew services start sekia-google

# Check running services
brew services list

# Stop a service
brew services stop sekia-github

Logs are written to $(brew --prefix)/var/log/<formula>.log (e.g. sekiad.log, sekia-github.log).

Go

go install github.com/sekia-ai/sekia/cmd/sekiad@latest
go install github.com/sekia-ai/sekia/cmd/sekiactl@latest
go install github.com/sekia-ai/sekia/cmd/sekia-github@latest
go install github.com/sekia-ai/sekia/cmd/sekia-google@latest

Docker

git clone https://github.com/sekia-ai/sekia.git
cd sekia
docker compose up

The Dockerfile has three targets (sekiad, sekia-github, sekia-google) and the compose file runs them as three services. Only sekiad publishes a port: NATS on 127.0.0.1:4222 (loopback only).

Build from source

Requires Go 1.27.

git clone https://github.com/sekia-ai/sekia.git
cd sekia
go build ./cmd/sekiad ./cmd/sekiactl ./cmd/sekia-github ./cmd/sekia-google

Quick Start

Get sekia running in four steps.

1. Start the daemon

sekiad

This starts the embedded NATS server, workflow engine, and Unix socket API. No configuration file needed for defaults.

Or run it as a background service with Homebrew:

brew services start sekia

2. Write a workflow

Create a Lua file in ~/.config/sekia/workflows/:

-- ~/.config/sekia/workflows/auto-label.lua

sekia.on("sekia.events.github", function(event)
    if event.type ~= "github.issue.opened" then return end

    local title = string.lower(event.payload.title or "")

    if string.find(title, "bug") then
        sekia.command("github-agent", "add_label", {
            owner  = event.payload.owner,
            repo   = event.payload.repo,
            number = event.payload.number,
            label  = "bug",
        })
    end
end)

3. Connect an agent

export GITHUB_TOKEN=ghp_...
sekia-github

4. Check status

sekiactl status
sekiactl agents
sekiactl workflows

Architecture

Event flow

The core pattern is: Agent → NATS event → Lua workflow → NATS command → Agent

External Service (GitHub, Gmail)
    |
    v
Agent binary (sekia-github, sekia-google)
    |  publishes to sekia.events.<source>
    v
Embedded NATS (inside sekiad)
    |
    v
Lua workflow engine (pattern matching)
    |  sekia.command("agent-name", "cmd", payload)
    v
NATS sekia.commands.<agent-name>
    |
    v
Agent binary executes command via external API

NATS runs in-process

By default, NATS is embedded inside sekiad with DontListen: true — no TCP port is opened. Agents connect using nats.InProcessServer() when running locally, or via a NATS URL when running remotely.

Config file search paths

All binaries search for their config file in this order:

  1. /etc/sekia/
  2. ~/.config/sekia/
  3. Current directory (./)

Override with the --config flag on any binary. Environment variables always take precedence over config file values.

sekiad (Daemon)

The daemon is the central process. It runs the embedded NATS server with JetStream, the agent registry, the Lua workflow engine, and the control API over a Unix socket.

Usage

sekiad [--config /path/to/sekia.toml]

Flags

FlagDescription
--configPath to config file (overrides search paths)
--versionShow version and exit

Startup sequence

  1. Start embedded NATS with JetStream
  2. Create agent registry (subscribes to sekia.registry and sekia.heartbeat.>)
  3. Start workflow engine, load .lua files, optionally start the fsnotify file watcher
  4. Subscribe to config-reload requests
  5. Start the API server on the Unix socket
  6. Block on OS signal or Stop()

Shutdown runs in reverse order: API server → workflow engine → registry → NATS.

Daemon Configuration

Config file: sekia.toml. Environment variable prefix: SEKIA_.

[server]

OptionTypeDefaultEnv VarDescription
socketstring$XDG_RUNTIME_DIR/sekia/sekiad.sockSEKIA_SERVER_SOCKETUnix socket path for the API. Without XDG_RUNTIME_DIR the daemon uses /run/user/<uid>/sekia/sekiad.sock when that directory exists, else ~/.config/sekia/sekiad.sock; sekiactl applies the same rule

[nats]

OptionTypeDefaultEnv VarDescription
embeddedbooltrueSEKIA_NATS_EMBEDDEDRun embedded NATS server (vs connecting to remote)
data_dirstring~/.local/share/sekia/natsSEKIA_NATS_DATA_DIRJetStream data directory
hoststring—SEKIA_NATS_HOSTNATS hostname (if not embedded)
portint—SEKIA_NATS_PORTNATS port (if not embedded)
tokenstring—SEKIA_NATS_TOKENNATS authentication token

[workflows]

OptionTypeDefaultEnv VarDescription
dirstring~/.config/sekia/workflowsSEKIA_WORKFLOWS_DIRDirectory containing .lua workflow files
hot_reloadbooltrueSEKIA_WORKFLOWS_HOT_RELOADWatch for file changes and auto-reload
handler_timeoutduration30sSEKIA_WORKFLOWS_HANDLER_TIMEOUTMax execution time for a Lua handler
verify_integrityboolfalseSEKIA_WORKFLOWS_VERIFY_INTEGRITYVerify .lua files against SHA256 manifest before loading

[security]

OptionTypeDefaultEnv VarDescription
command_secretstring—SEKIA_COMMAND_SECRETHMAC-SHA256 secret for command authentication

[log]

OptionTypeDefaultEnv VarDescription
levelstringinfoSEKIA_LOG_LEVELLog level: trace, debug, info, warn, error. The --log-level flag overrides it. Every binary has the same section

[secrets]

OptionTypeDefaultEnv VarDescription
aws_regionstring——AWS region override for KMS[...] resolution
kms_key_idstring—SEKIA_KMS_KEY_IDDefault KMS key ID/ARN/alias for sekiactl secrets kms-encrypt

KMS[...] values are resolved at startup. AWS credentials use the standard SDK v2 default chain (env vars, shared credentials file, IAM instance role, ECS task role).

Example config file

# ~/.config/sekia/sekia.toml

[server]
# socket defaults to $XDG_RUNTIME_DIR/sekia/sekiad.sock, /run/user/<uid>/sekia/sekiad.sock or ~/.config/sekia/sekiad.sock
# socket = "/tmp/sekiad.sock"  # override for Docker or custom setups

[nats]
embedded = true
data_dir = "~/.local/share/sekia/nats"

[workflows]
dir = "~/.config/sekia/workflows"
hot_reload = true
handler_timeout = "30s"
verify_integrity = false

[log]
level = "info"  # or SEKIA_LOG_LEVEL / --log-level

# [security]
# command_secret = "your-shared-secret"      # or SEKIA_COMMAND_SECRET

# [secrets]
# aws_region = "us-east-1"                   # for KMS[...] values
# kms_key_id = "alias/sekia"                 # default KMS key for CLI encrypt

sekiactl (CLI)

Command-line tool to inspect and control the sekiad daemon via Unix socket.

Global flags

FlagDefaultDescription
--socket$XDG_RUNTIME_DIR/sekia/sekiad.sockPath to sekiad Unix socket; falls back to /run/user/<uid>/sekia/sekiad.sock, then ~/.config/sekia/sekiad.sock
--version—Show version and exit

sekiactl status

Show daemon health and uptime.

$ sekiactl status
Status:       ok
Uptime:       15m30s
NATS Running: true
Started At:   2026-02-15 10:30:45
Agents:       2

sekiactl agents

List all registered agents.

$ sekiactl agents
NAME            VERSION   STATUS   EVENTS   ERRORS   LAST HEARTBEAT
github-agent    v0.3.0   alive    42       0        2s ago
google-agent    v0.3.0   alive    18       0        5s ago

sekiactl workflows

List loaded workflows. Alias for sekiactl workflows list.

$ sekiactl workflows
NAME                HANDLERS   PATTERNS               EVENTS   ERRORS   LOADED AT
github-auto-label   1          sekia.events.github     15       0        10m ago
gmail-auto-reply    1          sekia.events.google     8        0        10m ago

sekiactl workflows reload

Trigger hot-reload of all .lua workflow files from disk.

$ sekiactl workflows reload
Workflows reloaded successfully

sekiactl workflows sign

Generate or update the SHA256 manifest (workflows.sha256) for workflow files. Required when verify_integrity is enabled.

$ sekiactl workflows sign
Signed 2 workflow(s) in /Users/me/.config/sekia/workflows
a1b2c3d4e5...  github-auto-label.lua
f6a7b8c9d0...  gmail-auto-reply.lua

# Custom directory
$ sekiactl workflows sign --dir /path/to/workflows

sekiactl config reload

Broadcast a config reload signal via NATS. All agents re-read their config files and apply settings that are safe to change at runtime. Credentials and connection settings (tokens, API keys, listen addresses) require a restart.

# Reload all agents and daemon
$ sekiactl config reload

# Reload a specific agent
$ sekiactl config reload --target github-agent

# Reload daemon only
$ sekiactl config reload --target sekiad

Hot-reloadable settings per agent

AgentReloadable settingsRequires restart
github-agentpoll.interval, poll.sweep_interval, poll.repos, poll.labels, poll.state, poll.match_prsgithub.token, webhook.listen, webhook.secret
google-agentgmail.poll_interval, gmail.query, gmail.max_messagesgoogle.client_id, google.client_secret, google.token_path

Both agents also hot-reload security.command_secret. A reload re-reads the config file the component started with (--config and --name are honored).

Secret value formats

Secret values in TOML config files can be stored inline as KMS[<base64>] strings encrypted with AWS KMS. Every binary resolves them at startup, so the rest of the process only ever sees plaintext. Plaintext values continue to work — encryption is opt-in per value.

FormatBackendDescription
KMS[<base64>]AWS KMSDecrypt via KMS API (key ID embedded in cipherblob)

For example:

# sekia-github.toml
[github]
token = "KMS[AQIDAHhB...]"                  # KMS-encrypted

[webhook]
secret = "KMS[AQIDAHhC...]"

sekiactl secrets kms-encrypt

Encrypt a plaintext value using an AWS KMS key and output a KMS[...] string. The key ID can be an ARN, alias, or key ID.

# Explicit key ID
$ sekiactl secrets kms-encrypt --key-id alias/sekia-config "ghp_mytoken123"
KMS[AQIDAHhBm4p0...]

# Key ID from env or config
$ export SEKIA_KMS_KEY_ID="arn:aws:kms:us-east-1:123456789:key/abc-def"
$ sekiactl secrets kms-encrypt "my-webhook-secret"

sekiactl secrets kms-decrypt

Decrypt a KMS[...] value using the AWS KMS API. No key ID needed — it is embedded in the ciphertext blob.

$ sekiactl secrets kms-decrypt "KMS[AQIDAHhBm4p0...]"
ghp_mytoken123

AWS configuration

AWS credentials are resolved via the standard SDK v2 default chain (environment variables, shared credentials file, IAM instance role, ECS task role, etc.). An optional region override can be set:

# In sekia.toml (or any agent config)
[secrets]
aws_region = "us-east-1"     # optional region override
kms_key_id = "alias/sekia"   # default KMS key for kms-encrypt CLI

KMS auto-rotation is fully supported — AWS preserves all previous key material versions, so existing ciphertexts remain decryptable after rotation.

sekiactl service

Manage named agent instances as background services (launchd on macOS, systemd on Linux). See Named Instances for full documentation.

$ sekiactl service create sekia-github --name github-work
$ sekiactl service start github-work
$ sekiactl service stop github-work
$ sekiactl service restart github-work
$ sekiactl service remove github-work
$ sekiactl service list

Workflows

Workflows are Lua scripts that react to events and send commands. They live in the workflows directory (default: ~/.config/sekia/workflows/) and are loaded automatically when the daemon starts.

How it works

  1. The daemon loads every .lua file from the workflows directory
  2. Each workflow gets its own Lua state and goroutine (thread-safe)
  3. Workflows register handlers with sekia.on(pattern, fn)
  4. When an event matches a pattern, the handler function is called
  5. Handlers can send commands to agents or publish new events

Sandboxing

Workflows run in a restricted Lua environment. Only these standard libraries are available:

  • base — core functions (minus dofile, loadfile, load)
  • table — table manipulation
  • string — string operations
  • math — math functions

The os, io, and debug libraries are not available.

Self-event guard

When a workflow publishes an event, the event source is set to workflow:<name>. Events from workflow:<name> are automatically skipped by handlers in the same workflow, preventing infinite loops.

Hot-reload

When hot_reload = true (the default), the daemon uses fsnotify to watch the workflows directory. File changes trigger a full reload with a 500ms debounce. You can also trigger a manual reload via sekiactl workflows reload or the HTTP API.

Integrity verification

When verify_integrity = true, the daemon verifies each .lua file against a SHA256 manifest (workflows.sha256) before loading it. Files not in the manifest or with a hash mismatch are rejected.

Generate the manifest with the CLI:

sekiactl workflows sign [--dir <path>]

The manifest uses sha256sum-compatible format (<64-hex> <filename>). When hot-reload is enabled, changes to workflows.sha256 automatically trigger a full reload of all workflows.

Workflow: edit .lua file → load rejected (hash mismatch) → run sekiactl workflows sign → manifest updated → fsnotify triggers reload → all files pass verification.

Lua API Reference

The sekia global table is available in all workflows.

sekia.on(pattern, handler)

Register an event handler for a NATS subject pattern.

ParameterTypeDescription
patternstringNATS subject pattern. Supports * (single segment) and > (all remaining segments)
handlerfunctionCallback receiving an event table
-- Match all GitHub events
sekia.on("sekia.events.github", function(event)
    sekia.log("info", "Got event: " .. event.type)
end)

-- Match all events from any source
sekia.on("sekia.events.>", function(event)
    -- handles github, google, and custom events
end)

-- Match events from a specific wildcard source
sekia.on("sekia.events.*", function(event)
    -- matches sekia.events.github, sekia.events.google, etc.
end)

Event object shape

The event table passed to handlers has these fields:

FieldTypeDescription
idstringUnique event ID (UUID)
typestringEvent type (e.g. "github.issue.opened")
sourcestringEvent source (e.g. "github", "workflow:my-flow")
timestampnumberUnix timestamp
payloadtableEvent-specific data (varies by event type)

sekia.publish(subject, event_type, payload)

Emit a new event onto the NATS bus.

ParameterTypeDescription
subjectstringNATS subject (e.g. "sekia.events.custom")
event_typestringEvent type string
payloadtableArbitrary event data

Raises a Lua error on failure.

sekia.publish("sekia.events.custom", "deploy.started", {
    environment = "production",
    version = "v1.2.3",
})

sekia.command(agent, command, payload)

Send a command to a connected agent. The command is published to sekia.commands.<agent>.

ParameterTypeDescription
agentstringTarget agent name (e.g. "github-agent", "google-agent")
commandstringCommand name (e.g. "add_label", "send_email")
payloadtableCommand-specific data

Raises a Lua error on failure.

sekia.command("github-agent", "create_comment", {
    owner  = "myorg",
    repo   = "myrepo",
    number = 42,
    body   = "Automated comment from sekia",
})

sekia.log(level, message)

Log a message via zerolog.

ParameterTypeDescription
levelstringLog level: "debug", "info", "warn", "error"
messagestringLog message
sekia.log("info", "Processing issue #" .. num)

sekia.name

A string containing the current workflow's name (derived from the filename without .lua extension).

sekia.log("info", "Running workflow: " .. sekia.name)

Workflow Examples

Auto-label GitHub issues

Labels issues based on keywords in the title and posts a welcome comment.

-- github-auto-label.lua

sekia.on("sekia.events.github", function(event)
    if event.type ~= "github.issue.opened" then return end

    local title = string.lower(event.payload.title or "")
    local owner = event.payload.owner
    local repo  = event.payload.repo
    local num   = event.payload.number

    if string.find(title, "bug") or string.find(title, "crash") then
        sekia.command("github-agent", "add_label", {
            owner = owner, repo = repo, number = num, label = "bug",
        })
    end

    if string.find(title, "feature") or string.find(title, "request") then
        sekia.command("github-agent", "add_label", {
            owner = owner, repo = repo, number = num, label = "enhancement",
        })
    end

    sekia.command("github-agent", "create_comment", {
        owner = owner, repo = repo, number = num,
        body  = "Thanks for opening this issue! A maintainer will review it shortly.",
    })
end)

Auto-reply to urgent emails

-- gmail-auto-reply.lua
-- Requires: sekia-google with gmail.enabled = true

sekia.on("sekia.events.google", function(event)
    if event.type ~= "gmail.message.received" then return end

    local subject = string.lower(event.payload.subject or "")

    if string.find(subject, "urgent") or string.find(subject, "critical") then
        sekia.command("google-agent", "reply_email", {
            thread_id   = event.payload.thread_id,
            in_reply_to = event.payload.message_id,
            to          = event.payload.from,
            subject     = "Re: " .. (event.payload.subject or ""),
            body        = "Thank you. This has been flagged as urgent and will be reviewed promptly.",
        })
    end
end)

Email a notification for new issues

Cross-agent workflow: a GitHub event triggers a Gmail command.

-- github-issue-email.lua
-- Requires: sekia-github and sekia-google

sekia.on("sekia.events.github", function(event)
    if event.type ~= "github.issue.opened" then return end

    sekia.command("google-agent", "send_email", {
        to      = "team@example.com",
        subject = "New issue: " .. (event.payload.title or "untitled"),
        body    = (event.payload.author or "Someone") .. " opened " .. event.payload.url,
    })
end)

Named Instances (Multi-Tenancy)

Both agent binaries (sekia-github, sekia-google) support a --name flag for running multiple instances of the same agent type with different configurations.

# Two GitHub agents for different accounts
sekia-github --name github-personal   # reads sekia-github-personal.toml
sekia-github --name github-work       # reads sekia-github-work.toml

When --name is set:

  • Config file becomes sekia-{agent}-{name}.toml (unless --config overrides)
  • NATS registration uses the instance name (e.g., github-work instead of github-agent)
  • Command subject becomes sekia.commands.{name} — target instances from workflows via sekia.command("github-work", "add_label", payload)

Without --name, behavior is unchanged (default names: github-agent, google-agent).

Background Services

Use sekiactl service to manage named instances as background services (launchd on macOS, systemd on Linux):

# Create a service
sekiactl service create sekia-github --name github-work

# Start / stop / restart
sekiactl service start github-work
sekiactl service stop github-work
sekiactl service restart github-work

# List all managed services
sekiactl service list

# Remove (stops and deletes the service file)
sekiactl service remove github-work

CLI Reference

CommandDescription
sekiactl service create <binary> --name <instance>Generate a service file for a named instance
sekiactl service start <name>Start a named service
sekiactl service stop <name>Stop a named service
sekiactl service restart <name>Restart a named service
sekiactl service remove <name>Stop and delete the service file
sekiactl service listList all managed sekia services

Create flags

FlagDescription
--name <instance>Instance name (required)
--config <path>Explicit config file path (optional)
--env KEY=VALUEEnvironment variable (optional, repeatable). Stored in plaintext — prefer KMS[...] config values

Platform details

PlatformService file locationBackend
macOS~/Library/LaunchAgents/com.sekia.{name}.plistlaunchd
Linux~/.config/systemd/user/sekia-{name}.servicesystemd (user units)

Logs are written to ~/.config/sekia/logs/{name}.log. The default brew services-managed instance is not affected.

GitHub Agent

Standalone binary (sekia-github) that bridges GitHub to the NATS event bus via webhooks and/or REST API polling.

Usage

sekia-github [--name <instance>] [--config /path/to/sekia-github.toml]

Configuration

Config file: sekia-github.toml. At least one of webhook or polling must be enabled.

[nats]

OptionTypeDefaultEnv VarDescription
urlstringnats://127.0.0.1:4222SEKIA_NATS_URLNATS server URL
tokenstring—SEKIA_NATS_TOKENNATS auth token

[github]

OptionTypeDefaultEnv VarDescription
tokenstring—GITHUB_TOKENGitHub Personal Access Token (required)

[webhook]

OptionTypeDefaultEnv VarDescription
listenstring:8080SEKIA_WEBHOOK_LISTENHTTP listen address. Empty = disabled
secretstring—GITHUB_WEBHOOK_SECRETHMAC-SHA256 secret for webhook verification
pathstring/webhookSEKIA_WEBHOOK_PATHHTTP path for the webhook endpoint

[poll]

OptionTypeDefaultEnv VarDescription
enabledboolfalseSEKIA_POLL_ENABLEDEnable REST API polling
intervalduration30sSEKIA_POLL_INTERVALPolling interval
repos[]string—SEKIA_POLL_REPOSList of "owner/repo" to poll (required when enabled)
sweep_intervalduration1hSEKIA_POLL_SWEEP_INTERVALLabel and PR-match modes: how often every matching item is emitted again. 0 never sweeps
state_filestring~/.local/share/sekia/poll-<agent>.jsonSEKIA_POLL_STATE_FILEWhere the poller saves its watermark after every tick so a restart resumes instead of sweeping. Empty disables persistence
labels[]string—SEKIA_POLL_LABELSFilter issues by labels (enables label-filtered mode)
statestringopenSEKIA_POLL_STATEIssue state filter: open, closed, or all
match_prsboolfalseSEKIA_POLL_MATCH_PRSPR-match mode: emit github.pr.matched for PRs in state

[security]

OptionTypeDefaultEnv VarDescription
command_secretstring—SEKIA_COMMAND_SECRETHMAC-SHA256 secret for command auth

[log]

OptionTypeDefaultEnv VarDescription
levelstringinfoSEKIA_LOG_LEVELLog level: trace, debug, info, warn, error. The --log-level flag overrides it. Every binary has the same section

Webhook vs Polling

Webhooks provide real-time, fine-grained events (labeled, assigned, reopened) but require a publicly accessible URL. Polling works behind firewalls but can only detect opened/closed/updated states. Both can run simultaneously; polled events include payload.polled = true.

How polling works

Every tick fetches only the items updated since the previous successful tick, 100 per page and sorted by updated time, so a steady-state tick costs one API call per repo (and per label). Errors leave the watermark untouched and back off exponentially; a GitHub rate-limit response pauses polling until the reset time GitHub reports, and Retry-After on secondary limits is honored. Every API call has a 30-second timeout.

Label-filtered mode

When poll.labels is set (and match_prs is false), the poller runs one since-filtered query per label (OR semantics, deduplicated across labels), skips PRs and comments, and emits github.issue.matched for each issue instead of the time-based events.

PR-match mode

When poll.match_prs = true, the poller lists PRs in state (optionally carrying all of labels) sorted by updated time, stops at the first PR older than its watermark, and emits github.pr.matched with full PR metadata including author, draft status, labels and branches. Useful for auto-approval or triage workflows.

Sweeps

In both matched modes the first run is a full sweep that emits every matching item, and a sweep repeats every poll.sweep_interval (default 1h). This replays events that were lost while the daemon or an agent was down. The poller saves its watermark to poll.state_file after every tick and resumes from it on restart, so restarts do not sweep. With sweep_interval = "0" it never sweeps: a first run without saved state starts one hour back. Between sweeps an item is emitted again only when its GitHub updated time changes, for example after new commits or a dismissed review. Matched events carry payload.sweep (true during a sweep), and workflows acting on them should be idempotent: approve_pr already is.

Rate limits

At startup, the agent logs a warning if the estimated steady-state call rate (repos × labels per tick, or repos × 3 in time mode) exceeds 80% of GitHub's 5,000 requests/hour limit.

Event types

All events are published to sekia.events.github. Filter by event.type in your workflow.

Event TypeSourcePayload Fields
github.issue.openedWebhook + Pollingowner, repo, number, title, body, author, url, labels
github.issue.closedWebhook + Pollingowner, repo, number, title, body, author, url, labels
github.issue.reopenedWebhook onlyowner, repo, number, title, body, author, url, labels
github.issue.labeledWebhook onlyowner, repo, number, title, body, author, url, labels, label
github.issue.assignedWebhook onlyowner, repo, number, title, body, author, url, labels, assignee
github.issue.updatedPolling onlyowner, repo, number, title, body, author, url, labels
github.issue.matchedLabel-filtered pollingowner, repo, number, title, body, author, url, state, labels, sweep
github.pr.openedWebhook + Pollingowner, repo, number, title, body, author, head_branch, base_branch, url
github.pr.closedWebhook + Pollingowner, repo, number, title, body, author, head_branch, base_branch, url
github.pr.mergedWebhook + Pollingowner, repo, number, title, body, author, head_branch, base_branch, url, merge_commit
github.pr.review_requestedWebhook onlyowner, repo, number, title, body, author, head_branch, base_branch, url, reviewer
github.pr.updatedPolling onlyowner, repo, number, title, body, author, head_branch, base_branch, url
github.pr.matchedPR-match modeowner, repo, number, title, body, author, state, head_branch, base_branch, url, draft, labels, sweep
github.pushWebhook onlyowner, repo, ref, before, after, commits_count, pusher, head_commit_message
github.comment.createdWebhook onlyowner, repo, issue_number, comment_id, body, author, url

Commands

Send commands to "github-agent" via sekia.command().

CommandRequired PayloadDescription
add_labelowner, repo, number, labelAdd a label to an issue or PR
remove_labelowner, repo, number, labelRemove a label from an issue or PR
create_commentowner, repo, number, bodyCreate a comment on an issue or PR
close_issueowner, repo, numberClose an issue
reopen_issueowner, repo, numberReopen an issue
approve_prowner, repo, numberSubmit an approving review on a PR (optional: body)
add_to_projectowner, repo, number, project_idAdd PR/issue to a Projects v2 board (optional: fields array with field_id + value)

Example config

# sekia-github.toml

[github]
token = "ghp_..."  # or set GITHUB_TOKEN env var

[webhook]
listen = ":8080"
secret = "my-webhook-secret"

[poll]
enabled        = true
interval       = "30s"
sweep_interval = "1h"
repos          = ["myorg/myrepo", "myorg/other-repo"]

[log]
level = "info"

Google Agent

Standalone binary (sekia-google) that bridges Gmail to the NATS event bus via the OAuth2-authenticated Gmail REST API.

Usage

# Authorize (one-time setup)
sekia-google auth [--name <instance>] [--config /path/to/sekia-google.toml]

# Run the agent
sekia-google [--name <instance>] [--config /path/to/sekia-google.toml]

OAuth2 Setup

  1. Create a project in Google Cloud Console
  2. Enable the Gmail API
  3. Create OAuth2 credentials (Desktop application type)
  4. Set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET
  5. Run sekia-google auth — this opens your browser, you grant permissions, and the token is saved to disk
  6. Run sekia-google to start the agent (token auto-refreshes)

Remote auth via SSH

When running sekia-google auth on a headless server (e.g. EC2), the OAuth2 callback needs to reach the remote machine from your local browser. Set a fixed callback port and use SSH port forwarding:

# In sekia-google.toml on the remote machine
[google]
auth_port = 44557

# From your local machine, forward the callback port
ssh -L 44557:localhost:44557 your-server

# Then run auth on the remote machine (via the SSH session)
sekia-google auth

The auth URL will open in your local browser. After granting permissions, the callback redirects to localhost:44557, which SSH tunnels back to the remote server. Without auth_port, the callback port is random and changes each run.

Configuration

Config file: sekia-google.toml. sekiactl config reload hot-applies gmail.poll_interval, gmail.query, gmail.max_messages and security.command_secret; OAuth2 credentials require a restart.

[nats]

OptionTypeDefaultEnv VarDescription
urlstringnats://127.0.0.1:4222SEKIA_NATS_URLNATS server URL
tokenstring—SEKIA_NATS_TOKENNATS auth token

[google]

OptionTypeDefaultEnv VarDescription
client_idstring—GOOGLE_CLIENT_IDOAuth2 client ID (required)
client_secretstring—GOOGLE_CLIENT_SECRETOAuth2 client secret (required)
token_pathstring~/.config/sekia/google-token.jsonGOOGLE_TOKEN_PATHPath to store the OAuth2 token
auth_portint0 (random)—Fixed port for OAuth2 callback server. Useful for SSH port forwarding when running sekia-google auth on a remote machine

[gmail]

OptionTypeDefaultEnv VarDescription
enabledbooltrueSEKIA_GMAIL_ENABLEDEnable Gmail polling
poll_intervalduration30sSEKIA_GMAIL_POLL_INTERVALGmail polling interval
user_idstringmeSEKIA_GMAIL_USER_IDGmail user ID
querystring—SEKIA_GMAIL_QUERYGmail search query filter (e.g. "is:unread")
max_messagesint20SEKIA_GMAIL_MAX_MESSAGESMax messages to fetch per poll

[security]

OptionTypeDefaultEnv VarDescription
command_secretstring—SEKIA_COMMAND_SECRETHMAC-SHA256 secret for command auth

Gmail event types

Published to sekia.events.google. Uses the Gmail History API for efficient incremental sync via historyId.

Event TypePayload Fields
gmail.message.receivedid, thread_id, message_id, from, to, subject, body, date, labels

Gmail commands

Send commands to "google-agent".

CommandRequired PayloadOptional PayloadDescription
send_emailto, subject, body—Send a new email
reply_emailthread_id, to, subject, bodyin_reply_toReply to an email thread
add_labelmessage_id, label—Add label to a message
remove_labelmessage_id, label—Remove label from a message
archivemessage_id—Archive a message
trashmessage_id—Move message to trash
untrashmessage_id—Move a trashed message back to inbox
deletemessage_id—Permanently delete a message

Example config

# sekia-google.toml

[google]
client_id     = "..."  # or GOOGLE_CLIENT_ID
client_secret = "..."  # or GOOGLE_CLIENT_SECRET
token_path    = "~/.config/sekia/google-token.json"

[gmail]
enabled       = true
poll_interval = "30s"
query         = "is:unread"

HTTP API

The daemon serves a JSON API over a Unix socket (default: $XDG_RUNTIME_DIR/sekia/sekiad.sock, falling back to /run/user/<uid>/sekia/sekiad.sock or ~/.config/sekia/sekiad.sock). No authentication is required — the socket file permissions (0600) and parent directory ownership verification provide implicit security.

Accessing the API

# Using curl
curl --unix-socket ~/.config/sekia/sekiad.sock http://localhost/api/v1/status

# Using sekiactl (recommended)
sekiactl status

GET /api/v1/status

Returns daemon health and metadata.

{
  "status": "ok",
  "uptime": "15m30s",
  "nats_running": true,
  "started_at": "2026-02-15T10:30:45Z",
  "agent_count": 2,
  "workflow_count": 2
}

GET /api/v1/agents

Returns all registered agents.

{
  "agents": [
    {
      "name": "github-agent",
      "version": "v0.3.0",
      "status": "alive",
      "commands": ["add_label", "remove_label", "create_comment", "close_issue", "reopen_issue", "approve_pr", "add_to_project"],
      "events_processed": 42,
      "errors": 0,
      "last_heartbeat": "2026-02-15T10:45:30Z"
    }
  ]
}

GET /api/v1/workflows

Returns all loaded workflows.

{
  "workflows": [
    {
      "name": "github-auto-label",
      "file_path": "/home/user/.config/sekia/workflows/github-auto-label.lua",
      "handlers": 1,
      "patterns": ["sekia.events.github"],
      "events": 15,
      "errors": 0,
      "loaded_at": "2026-02-15T10:30:50Z"
    }
  ]
}

POST /api/v1/workflows/reload

Triggers hot-reload of all workflow files.

{"status": "reloaded"}

POST /api/v1/config/reload

Broadcasts a config reload signal via NATS. Optional query parameter: target (agent name, "sekiad", or "*" for all).

# Reload all
curl --unix-socket ~/.config/sekia/sekiad.sock -X POST http://localhost/api/v1/config/reload

# Reload specific agent
curl --unix-socket ~/.config/sekia/sekiad.sock -X POST "http://localhost/api/v1/config/reload?target=github-agent"
{"status": "reload_requested", "target": "*"}

NATS Subjects

All communication between the daemon, agents, and workflows uses these NATS subject patterns.

SubjectPurposePublisher
sekia.registryAgent registration announcementsAgents (on startup)
sekia.heartbeat.<name>Agent heartbeats (30s interval)Agents (periodic)
sekia.events.githubGitHub eventssekia-github
sekia.events.googleGmail eventssekia-google
sekia.events.<custom>Custom events from workflowsWorkflows
sekia.commands.github-agentCommands for GitHub agentWorkflows
sekia.commands.google-agentCommands for Google agentWorkflows

Pattern matching

NATS supports two wildcard tokens for subscriptions:

  • * — matches a single token. Example: sekia.events.* matches sekia.events.github but not sekia.events.github.sub
  • > — matches one or more tokens (must be last). Example: sekia.events.> matches all events from any source

Security

Command authentication

When command_secret is set on both the daemon and an agent, commands are signed with HMAC-SHA256. The agent verifies the signature before executing any command. This prevents unauthorized command injection via NATS.

Set the same secret on the daemon and all agents:

# In sekia.toml, sekia-github.toml and sekia-google.toml
[security]
command_secret = "your-shared-secret"

# Or via environment
export SEKIA_COMMAND_SECRET=your-shared-secret

NATS authentication

When using a remote NATS server (not embedded), you can configure a token:

[nats]
token = "your-nats-token"

GitHub webhook verification

When webhook.secret is configured, the GitHub agent verifies X-Hub-Signature-256 headers using HMAC-SHA256.

Secrets encryption

sekia supports encrypting secret values in config files with AWS KMS. Encrypted values are stored inline as KMS[...] strings and decrypted transparently at startup by every binary. AWS credentials come from the SDK default credential chain; the KMS key ID is embedded in the ciphertext, so decryption needs no key configuration.

# Encrypt a secret
sekiactl secrets kms-encrypt --key-id alias/sekia "ghp_mytoken123"
# KMS[AQIDAHhBm4p0...]

Use the KMS[...] value in any config file:

[github]
token = "KMS[AQIDAHhBm4p0...]"

Set secrets.aws_region to override the AWS region, and secrets.kms_key_id (or SEKIA_KMS_KEY_ID) to pick the default key for sekiactl secrets kms-encrypt. KMS key rotation is safe: AWS keeps previous key material, so existing ciphertexts remain decryptable.

Unix socket security

The daemon API uses a Unix socket (default: $XDG_RUNTIME_DIR/sekia/sekiad.sock, falling back to /run/user/<uid>/sekia/sekiad.sock or ~/.config/sekia/sekiad.sock), which inherits file system permissions. The daemon creates the parent directory with mode 0700, verifies it is owned by the current user, rejects symlinks at the socket path, and sets the socket file to mode 0600. This prevents symlink attacks that could occur with world-writable directories like /tmp.

CI security scanning

Every push and pull request runs three layers of automated security analysis:

  • govulncheck — the official Go vulnerability checker. Scans all dependencies against the Go vulnerability database and reports only vulnerabilities that affect code paths actually used by sekia.
  • gosec — static analysis for Go security issues. Detects common mistakes like SQL injection, command injection, hardcoded credentials, weak crypto, and unhandled errors in security-sensitive code.
  • Trivy — container image vulnerability scanner. Scans the Docker image for known CVEs in OS packages and application dependencies. The CI pipeline fails on any CRITICAL or HIGH severity finding.

These checks run as separate parallel jobs in CI, so security findings surface immediately without slowing down the test suite.

Release signing

All release checksums are signed with cosign (Sigstore) using keyless signing via GitHub Actions OIDC. This proves that artifacts were built by the official CI pipeline — no private key management required.

Each release includes checksums.txt, checksums.txt.sig (signature), and checksums.txt.pem (certificate). To verify:

# Verify the checksum signature
cosign verify-blob \
  --certificate checksums.txt.pem \
  --signature checksums.txt.sig \
  --certificate-identity-regexp "^https://github\.com/sekia-ai/sekia/" \
  --certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
  checksums.txt

# Verify your archive against the signed checksums
sha256sum --check checksums.txt --ignore-missing

SBOM generation

Every release archive includes a CycloneDX JSON Software Bill of Materials (.sbom.json) generated by syft. SBOMs list all Go module dependencies, enabling vulnerability scanning and license compliance auditing.

Hardening measures

In addition to runtime security features, the codebase includes several hardening measures identified and enforced by static analysis:

  • Slowloris protection — all HTTP servers set ReadHeaderTimeout to prevent slow-read denial-of-service attacks.
  • Tight directory permissions — the workflow directory is created with mode 0750 and the socket directory with 0700, limiting access to the owner and group.
  • Safe integer conversions — UID comparisons include bounds checks to prevent integer overflow on 32-bit platforms.

Upgrading from 0.2.x

Version 0.3.0 trims sekia to the features in use: the GitHub and Gmail agents, the Lua workflow engine, and AWS KMS for config secrets. It is a breaking release. Everything below was removed and has no replacement.

Removed binaries

sekia-slack, sekia-linear and sekia-mcp are gone, together with their Homebrew formulas, Docker targets and compose services. Stop their services and uninstall them:

brew services stop sekia-slack
brew services stop sekia-linear
brew uninstall sekia-slack sekia-linear sekia-mcp

Workflows that send commands to slack-agent or linear-agent no longer have a receiver.

Removed config sections

These sections and keys are now ignored and can be deleted from your config files:

RemovedFileWas
[ai], SEKIA_AI_API_KEYsekia.tomlAnthropic client behind sekia.ai(), persona.md
[sentinel]sekia.tomlProactive AI checks from sentinel.md
[skills]sekia.tomlSkill definitions, sekiactl skills list, GET /api/v1/skills
[conversation]sekia.tomlMulti-turn conversation store
[web], SEKIA_WEB_*sekia.tomlWeb dashboard and the /web routes
server.listensekia.toml[server] now has only socket
[calendar]sekia-google.tomlGoogle Calendar sync. The google.calendar.* events and the create_event, update_event, delete_event commands are gone; the agent is Gmail only

Removed Lua functions

sekia.ai, sekia.ai_json, sekia.skill, sekia.conversation and sekia.schedule no longer exist on the sekia table. Calling one raises a Lua error (attempt to call a nil value), so remove those calls from your workflows before upgrading. The remaining API is sekia.on, sekia.publish, sekia.command, sekia.log and sekia.name.

Re-encrypt ENC[...] and ASM[...] secrets

The age and AWS Secrets Manager backends were removed. ENC[...] and ASM[...] values are no longer resolved: 0.3.0 passes them through as literal strings, so a token stored that way no longer authenticates. Before upgrading, decrypt each value with the 0.2.x CLI and re-encrypt it with KMS:

# On 0.2.x: recover the plaintext
sekiactl secrets decrypt "ENC[YWdlLWVuY3J5cHRpb24...]"
sekiactl secrets asm-get prod/sekia/github-token

# Re-encrypt with KMS and paste the result into the config file
sekiactl secrets kms-encrypt --key-id alias/sekia "ghp_mytoken123"
# KMS[AQIDAHhBm4p0...]

sekiactl secrets keygen, encrypt, decrypt and asm-get are gone; SEKIA_AGE_KEY, SEKIA_AGE_KEY_FILE and secrets.identity are ignored. Existing KMS[...] values keep working unchanged.

GitHub polling changed

Every tick now fetches only items updated since the previous tick, 100 per page, instead of crawling one item per tick. poll.per_tick is ignored and can be deleted. Label-filtered and PR-match modes sweep every matching item at startup and every poll.sweep_interval (default 1h); matched events carry payload.sweep. Workflows that act on matched events must be idempotent, which approve_pr and label changes already are.

Quieter logs

Every binary logs at info by default. 0.2.x logged at debug level, one line per routed event; set [log] level = "debug", SEKIA_LOG_LEVEL=debug or --log-level debug to get that back.

Config reload and sekiactl

sekiactl config reload now re-reads the config file each component started with, honoring --config and --name; 0.2.x named instances reloaded the default file. Without XDG_RUNTIME_DIR, sekiactl also looks for the daemon socket in /run/user/<uid>/sekia/, so it finds a systemd-started daemon from an SSH session.

Files you can delete

  • ~/.config/sekia/persona.md
  • ~/.config/sekia/sentinel.md
  • ~/.config/sekia/skills/
  • ~/.config/sekia/age.key (once every ENC[...] value has been re-encrypted)
  • sekia-slack.toml, sekia-linear.toml, sekia-mcp.toml