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 daemonsekia-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:
/etc/sekia/~/.config/sekia/- 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
| Flag | Description |
|---|---|
--config | Path to config file (overrides search paths) |
--version | Show version and exit |
Startup sequence
- Start embedded NATS with JetStream
- Create agent registry (subscribes to
sekia.registryandsekia.heartbeat.>) - Start workflow engine, load
.luafiles, optionally start the fsnotify file watcher - Subscribe to config-reload requests
- Start the API server on the Unix socket
- 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]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| socket | string | $XDG_RUNTIME_DIR/sekia/sekiad.sock | SEKIA_SERVER_SOCKET | Unix 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]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| embedded | bool | true | SEKIA_NATS_EMBEDDED | Run embedded NATS server (vs connecting to remote) |
| data_dir | string | ~/.local/share/sekia/nats | SEKIA_NATS_DATA_DIR | JetStream data directory |
| host | string | — | SEKIA_NATS_HOST | NATS hostname (if not embedded) |
| port | int | — | SEKIA_NATS_PORT | NATS port (if not embedded) |
| token | string | — | SEKIA_NATS_TOKEN | NATS authentication token |
[workflows]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| dir | string | ~/.config/sekia/workflows | SEKIA_WORKFLOWS_DIR | Directory containing .lua workflow files |
| hot_reload | bool | true | SEKIA_WORKFLOWS_HOT_RELOAD | Watch for file changes and auto-reload |
| handler_timeout | duration | 30s | SEKIA_WORKFLOWS_HANDLER_TIMEOUT | Max execution time for a Lua handler |
| verify_integrity | bool | false | SEKIA_WORKFLOWS_VERIFY_INTEGRITY | Verify .lua files against SHA256 manifest before loading |
[security]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| command_secret | string | — | SEKIA_COMMAND_SECRET | HMAC-SHA256 secret for command authentication |
[log]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| level | string | info | SEKIA_LOG_LEVEL | Log level: trace, debug, info, warn, error. The --log-level flag overrides it. Every binary has the same section |
[secrets]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| aws_region | string | — | — | AWS region override for KMS[...] resolution |
| kms_key_id | string | — | SEKIA_KMS_KEY_ID | Default 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
| Flag | Default | Description |
|---|---|---|
--socket | $XDG_RUNTIME_DIR/sekia/sekiad.sock | Path 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
| Agent | Reloadable settings | Requires restart |
|---|---|---|
| github-agent | poll.interval, poll.sweep_interval, poll.repos, poll.labels, poll.state, poll.match_prs | github.token, webhook.listen, webhook.secret |
| google-agent | gmail.poll_interval, gmail.query, gmail.max_messages | google.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.
| Format | Backend | Description |
|---|---|---|
KMS[<base64>] | AWS KMS | Decrypt 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
- The daemon loads every
.luafile from the workflows directory - Each workflow gets its own Lua state and goroutine (thread-safe)
- Workflows register handlers with
sekia.on(pattern, fn) - When an event matches a pattern, the handler function is called
- 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 (minusdofile,loadfile,load)table— table manipulationstring— string operationsmath— 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.
| Parameter | Type | Description |
|---|---|---|
| pattern | string | NATS subject pattern. Supports * (single segment) and > (all remaining segments) |
| handler | function | Callback 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:
| Field | Type | Description |
|---|---|---|
| id | string | Unique event ID (UUID) |
| type | string | Event type (e.g. "github.issue.opened") |
| source | string | Event source (e.g. "github", "workflow:my-flow") |
| timestamp | number | Unix timestamp |
| payload | table | Event-specific data (varies by event type) |
sekia.publish(subject, event_type, payload)
Emit a new event onto the NATS bus.
| Parameter | Type | Description |
|---|---|---|
| subject | string | NATS subject (e.g. "sekia.events.custom") |
| event_type | string | Event type string |
| payload | table | Arbitrary 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>.
| Parameter | Type | Description |
|---|---|---|
| agent | string | Target agent name (e.g. "github-agent", "google-agent") |
| command | string | Command name (e.g. "add_label", "send_email") |
| payload | table | Command-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.
| Parameter | Type | Description |
|---|---|---|
| level | string | Log level: "debug", "info", "warn", "error" |
| message | string | Log 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--configoverrides) - NATS registration uses the instance name (e.g.,
github-workinstead ofgithub-agent) - Command subject becomes
sekia.commands.{name}— target instances from workflows viasekia.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
| Command | Description |
|---|---|
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 list | List all managed sekia services |
Create flags
| Flag | Description |
|---|---|
--name <instance> | Instance name (required) |
--config <path> | Explicit config file path (optional) |
--env KEY=VALUE | Environment variable (optional, repeatable). Stored in plaintext — prefer KMS[...] config values |
Platform details
| Platform | Service file location | Backend |
|---|---|---|
| macOS | ~/Library/LaunchAgents/com.sekia.{name}.plist | launchd |
| Linux | ~/.config/systemd/user/sekia-{name}.service | systemd (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]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| url | string | nats://127.0.0.1:4222 | SEKIA_NATS_URL | NATS server URL |
| token | string | — | SEKIA_NATS_TOKEN | NATS auth token |
[github]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| token | string | — | GITHUB_TOKEN | GitHub Personal Access Token (required) |
[webhook]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| listen | string | :8080 | SEKIA_WEBHOOK_LISTEN | HTTP listen address. Empty = disabled |
| secret | string | — | GITHUB_WEBHOOK_SECRET | HMAC-SHA256 secret for webhook verification |
| path | string | /webhook | SEKIA_WEBHOOK_PATH | HTTP path for the webhook endpoint |
[poll]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| enabled | bool | false | SEKIA_POLL_ENABLED | Enable REST API polling |
| interval | duration | 30s | SEKIA_POLL_INTERVAL | Polling interval |
| repos | []string | — | SEKIA_POLL_REPOS | List of "owner/repo" to poll (required when enabled) |
| sweep_interval | duration | 1h | SEKIA_POLL_SWEEP_INTERVAL | Label and PR-match modes: how often every matching item is emitted again. 0 never sweeps |
| state_file | string | ~/.local/share/sekia/poll-<agent>.json | SEKIA_POLL_STATE_FILE | Where the poller saves its watermark after every tick so a restart resumes instead of sweeping. Empty disables persistence |
| labels | []string | — | SEKIA_POLL_LABELS | Filter issues by labels (enables label-filtered mode) |
| state | string | open | SEKIA_POLL_STATE | Issue state filter: open, closed, or all |
| match_prs | bool | false | SEKIA_POLL_MATCH_PRS | PR-match mode: emit github.pr.matched for PRs in state |
[security]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| command_secret | string | — | SEKIA_COMMAND_SECRET | HMAC-SHA256 secret for command auth |
[log]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| level | string | info | SEKIA_LOG_LEVEL | Log 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 Type | Source | Payload Fields |
|---|---|---|
github.issue.opened | Webhook + Polling | owner, repo, number, title, body, author, url, labels |
github.issue.closed | Webhook + Polling | owner, repo, number, title, body, author, url, labels |
github.issue.reopened | Webhook only | owner, repo, number, title, body, author, url, labels |
github.issue.labeled | Webhook only | owner, repo, number, title, body, author, url, labels, label |
github.issue.assigned | Webhook only | owner, repo, number, title, body, author, url, labels, assignee |
github.issue.updated | Polling only | owner, repo, number, title, body, author, url, labels |
github.issue.matched | Label-filtered polling | owner, repo, number, title, body, author, url, state, labels, sweep |
github.pr.opened | Webhook + Polling | owner, repo, number, title, body, author, head_branch, base_branch, url |
github.pr.closed | Webhook + Polling | owner, repo, number, title, body, author, head_branch, base_branch, url |
github.pr.merged | Webhook + Polling | owner, repo, number, title, body, author, head_branch, base_branch, url, merge_commit |
github.pr.review_requested | Webhook only | owner, repo, number, title, body, author, head_branch, base_branch, url, reviewer |
github.pr.updated | Polling only | owner, repo, number, title, body, author, head_branch, base_branch, url |
github.pr.matched | PR-match mode | owner, repo, number, title, body, author, state, head_branch, base_branch, url, draft, labels, sweep |
github.push | Webhook only | owner, repo, ref, before, after, commits_count, pusher, head_commit_message |
github.comment.created | Webhook only | owner, repo, issue_number, comment_id, body, author, url |
Commands
Send commands to "github-agent" via sekia.command().
| Command | Required Payload | Description |
|---|---|---|
add_label | owner, repo, number, label | Add a label to an issue or PR |
remove_label | owner, repo, number, label | Remove a label from an issue or PR |
create_comment | owner, repo, number, body | Create a comment on an issue or PR |
close_issue | owner, repo, number | Close an issue |
reopen_issue | owner, repo, number | Reopen an issue |
approve_pr | owner, repo, number | Submit an approving review on a PR (optional: body) |
add_to_project | owner, repo, number, project_id | Add 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
- Create a project in Google Cloud Console
- Enable the Gmail API
- Create OAuth2 credentials (Desktop application type)
- Set
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET - Run
sekia-google auth— this opens your browser, you grant permissions, and the token is saved to disk - Run
sekia-googleto 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]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| url | string | nats://127.0.0.1:4222 | SEKIA_NATS_URL | NATS server URL |
| token | string | — | SEKIA_NATS_TOKEN | NATS auth token |
[google]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| client_id | string | — | GOOGLE_CLIENT_ID | OAuth2 client ID (required) |
| client_secret | string | — | GOOGLE_CLIENT_SECRET | OAuth2 client secret (required) |
| token_path | string | ~/.config/sekia/google-token.json | GOOGLE_TOKEN_PATH | Path to store the OAuth2 token |
| auth_port | int | 0 (random) | — | Fixed port for OAuth2 callback server. Useful for SSH port forwarding when running sekia-google auth on a remote machine |
[gmail]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| enabled | bool | true | SEKIA_GMAIL_ENABLED | Enable Gmail polling |
| poll_interval | duration | 30s | SEKIA_GMAIL_POLL_INTERVAL | Gmail polling interval |
| user_id | string | me | SEKIA_GMAIL_USER_ID | Gmail user ID |
| query | string | — | SEKIA_GMAIL_QUERY | Gmail search query filter (e.g. "is:unread") |
| max_messages | int | 20 | SEKIA_GMAIL_MAX_MESSAGES | Max messages to fetch per poll |
[security]
| Option | Type | Default | Env Var | Description |
|---|---|---|---|---|
| command_secret | string | — | SEKIA_COMMAND_SECRET | HMAC-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 Type | Payload Fields |
|---|---|
gmail.message.received | id, thread_id, message_id, from, to, subject, body, date, labels |
Gmail commands
Send commands to "google-agent".
| Command | Required Payload | Optional Payload | Description |
|---|---|---|---|
send_email | to, subject, body | — | Send a new email |
reply_email | thread_id, to, subject, body | in_reply_to | Reply to an email thread |
add_label | message_id, label | — | Add label to a message |
remove_label | message_id, label | — | Remove label from a message |
archive | message_id | — | Archive a message |
trash | message_id | — | Move message to trash |
untrash | message_id | — | Move a trashed message back to inbox |
delete | message_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.
| Subject | Purpose | Publisher |
|---|---|---|
sekia.registry | Agent registration announcements | Agents (on startup) |
sekia.heartbeat.<name> | Agent heartbeats (30s interval) | Agents (periodic) |
sekia.events.github | GitHub events | sekia-github |
sekia.events.google | Gmail events | sekia-google |
sekia.events.<custom> | Custom events from workflows | Workflows |
sekia.commands.github-agent | Commands for GitHub agent | Workflows |
sekia.commands.google-agent | Commands for Google agent | Workflows |
Pattern matching
NATS supports two wildcard tokens for subscriptions:
*— matches a single token. Example:sekia.events.*matchessekia.events.githubbut notsekia.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
ReadHeaderTimeoutto prevent slow-read denial-of-service attacks. - Tight directory permissions — the workflow directory is created with mode
0750and the socket directory with0700, 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:
| Removed | File | Was |
|---|---|---|
[ai], SEKIA_AI_API_KEY | sekia.toml | Anthropic client behind sekia.ai(), persona.md |
[sentinel] | sekia.toml | Proactive AI checks from sentinel.md |
[skills] | sekia.toml | Skill definitions, sekiactl skills list, GET /api/v1/skills |
[conversation] | sekia.toml | Multi-turn conversation store |
[web], SEKIA_WEB_* | sekia.toml | Web dashboard and the /web routes |
server.listen | sekia.toml | [server] now has only socket |
[calendar] | sekia-google.toml | Google 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 everyENC[...]value has been re-encrypted)sekia-slack.toml,sekia-linear.toml,sekia-mcp.toml