Repository avatar
Databases
v0.0.11
active

agent-steward

io.github.DeadSno/agent-steward

Local-first MCP server for agent orchestration: cron, DAG, matrix and SQLite history.

Documentation

agent-steward

Local-first agent orchestration framework with an OpenCode V1 (≥ 1.18.29)/V2 plugin as its current entry point — cron, one-shot runs, DAG pipelines, matrix builds, quality gates, SQLite history and a local web dashboard. The same core is also available via MCP, CLI and standalone mode. Runs on Windows, macOS and Linux. Free and open source (MIT).

CI npm npm downloads license node

Translations: Russian · 中文.


Quickstart

  1. Install the plugin (see Install) and restart OpenCode.

  2. Ask the agent to schedule your first job — one call is enough:

    Schedule a task "morning-report" that runs every day at 09:00 with the prompt: "Summarize yesterday's git commits and write the report to ~/reports/".

  3. Open the dashboard to watch it run: the agent prints the URL when the task is created (default http://localhost:3782), or ask for it later with the get_dashboard_info tool. Prefer a preview without installing anything? node scripts/demo-dashboard.mjs starts a demo dashboard at http://localhost:3782.

Why

Most schedulers for AI agents are cron wrappers: they run a prompt on a timer and write a log file. This plugin treats agent jobs as workflows:

  • DAG pipelines — a job waits for its dependencies, chains on success/error.
  • Matrix builds — one template, N repositories, parallel or sequential, with concurrency limits and per-workspace overrides.
  • Quality gates — a job is marked successful only if npm test (or any command) passes.
  • Observability — SQLite history, metrics, logs, and a local web dashboard.
  • Runs without OpenCode open - cron and one-shot jobs are registered with the native OS scheduler (Windows Task Scheduler, launchd, crontab) and survive reboots. File, git and MCP-event triggers are watched inside the plugin process, so they need OpenCode running.

Everything runs on your machine. No SaaS, no telemetry, no accounts.

Local web dashboard: matrix builds, DAG graph, metrics and run history

Want to see it without installing OpenCode? node scripts/demo-dashboard.mjs starts the dashboard with demo data at http://localhost:3782.

Features

AreaWhat you get
Schedulingcron expressions, one-shot runs via runAt / delaySeconds, native OS scheduler (Windows / macOS / Linux), IANA timezones (native where possible, minute-poll + gate otherwise), pause/resume, session continuity (new / reuse / last with sessionMaxRuns cleanup)
Reliabilitylock-file no-overlap protection, timeouts with hard kill, retries with delay, crash recovery
QualityQuality Gate command, before/after hooks, per-task allowed/denied tool lists
OrchestrationdependsOn DAG, nextTaskOnSuccess / nextTaskOnError chains, matrix fan-out (parallel/sequential, continue/stop, concurrency, per-workspace overrides, aggregator task)
Triggerscron, one-shot (triggerType: "once"), git commits (triggerType: "git", branch/path/ignore filters), file change (chokidar, with glob masks watchGlobs/watchIgnore), MCP events, incoming webhooks (POST /api/hooks/:task with HMAC)
Multi-repoworkspaces with path validation, per-workspace runs, matrix over one parent task
ObservabilitySQLite history (success / error / timeout / partial / running), metrics (duration, tokens, cost), JSONL run logs with /api/logs, Prometheus /metrics, OTLP export, per-task logs, local web dashboard with 14-day analytics, history retention and CSV/JSON export
Operationsdry-run preview, export/import JSON, templates, multi-channel notifications (webhook, Telegram, native OS toasts), quiet hours, digest, encrypted secrets (${secret:NAME}), audit log, settings
InterfacesOpenCode GUI panel, web dashboard, 34 agent tools, built-in agent skill

Language

The interface ships in Russian, English, Simplified Chinese and Turkish. By default the language selector is set to Auto — like OpenCode, it follows the OpenCode interface language; Russian, English, Chinese and Turkish can be chosen explicitly. The selector sits in the scheduler panel header (🌐 Auto / Русский / English / 中文 / Türkçe) and is also available through the manage_settings tool (action: "update", locale: "zh"). locale: "auto" (the "Auto" option, used by default) follows the OpenCode interface language: the panel reacts to language changes immediately, and the resolved locale is sent to the server so notifications, digests and the dashboard use the same language. The switch applies without a restart. The dashboard follows the resolved locale: Russian and English are fully localized (its screenshot in docs/dashboard.png is the English variant); Chinese and Turkish currently fall back to English for dashboard chrome until their catalogs are ready. Agent tool descriptions and schemas stay English by design, and diagnostics printed to the console stay Russian.

Catalogs live in locales/ru.json, locales/en.json, locales/zh.json and locales/tr.json; every key must exist in all four, otherwise CI fails.

Documentation is separate from the interface locale: the English docs are the primary source, with Russian (docs/README.ru.md) and Simplified Chinese (docs/README.zh.md, docs/FEATURES.zh.md, docs/FAQ.zh.md, docs/SAVINGS.zh.md, docs/CROSS_PLATFORM.zh.md) translations. Translations may lag behind the English originals.

Install

Requires OpenCode V1 ≥ 1.18.29 or V2, and Node.js 26.4+ (the @opentui/core 0.9.0 dev dependency requires Node.js 26.4+; node:sqlite and chokidar 6 need 22.22+). See docs/COMPATIBILITY.md for version support and the V1/V2 surface (GUI and RPC are V2-only; TUI works on both).

The config key differs between lines:

OpenCode lineKey in opencode.jsonc
V1 (1.18.29–1.19.x)"plugin": ["agent-steward"]
V2 (≥ 2.2.7)"plugins": ["agent-steward"]

Use the key of your line; there is no need to add both. On V2 the CLI does it for you:

opencode plugin add agent-steward

V1 — manual config:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["agent-steward"]
}

V2 — equivalent manual config:

{
  "$schema": "https://opencode.ai/config.json",
  "plugins": ["agent-steward"],
  "experimental": {
    "schedules": false
  }
}

experimental.schedules: false disables the built-in OpenCode scheduler so the agent does not confuse built-in job tools with this plugin's tools. In OpenCode 2.x, config changes reload automatically; use /reload if the change is not picked up. On 1.x, restart OpenCode after editing the config. The TUI panel is part of the same package (exports["./tui"]), so it is enabled by the same entry on both lines.

From source:

git clone https://github.com/DeadSno/agent-steward.git
cd agent-steward
npm install
npm run build && npm run build:gui

Agent tools

The agent gets the full feature set — 34 tools covering scheduling, pipelines, operations, observability and administration:

ToolArgumentsWhat it does
schedule_taskname, prompt, schedule for cron or runAt / delaySeconds for one-shot, optional session / sessionMaxRuns, timeoutSeconds, model, priority, beforeScript, afterScript, qualityGate, dependsOn, retryCount, retryDelay, nextTaskOnSuccess, nextTaskOnError, triggerType (cron/file/git/mcp-event/once), mcpEvent, watchPath, watchGlobs, watchIgnore, gitBranch, gitPaths, gitIgnore, gitPollSeconds, activeDays, windowPolicy (skip/postpone/run), workingDirectory, workspaceId, allowedTools, deniedTools, legacyShell, matrixRegisters a job with the OS scheduler (cron, one-shot, file, git or MCP-event trigger)
schedule_advancedfull schedule_task schema: matrix, DAG, retry, launch windows and all trigger typesAdvanced scheduling in the admin profile
list_tasks—Returns jobs with schedule, status, next run, chains, workspace and matrix summary
update_taskname + any field to changePartial update; omitted fields keep their values, empty values clear them, matrix: null removes the matrix
update_advancedfull update_task schemaAdvanced task updates in the admin profile
delete_tasknameDeletes a job (a matrix parent deletes clones and aggregator)
run_task_nownameRuns a job immediately (matrix parent starts the fan-out)
pause_tasknamePauses a job (matrix parent pauses every clone)
resume_tasknameResumes a paused job
get_historytaskName?, status?, limit?Recent runs with duration, tokens, cost, model, quality gate and hooks
get_task_logsname or taskName, lines?Tail of the run log
dry_runname?Simulates a pipeline (or every task): order, DAG, matrix fan-out, estimates
backup_dbfile?Online SQLite snapshot to <db>.backup with SHA-256 checksum and size
restore_dbfile, sha256?Restores a verified snapshot in place without closing the dashboard connection
manage_workspacesaction, id?, name?, path?, color?Multi-repo workspaces: list, add, update, delete
matrix_controlaction, name?Matrix results, cancel pending clones, clean up orphans, preview clones
get_metrics—Aggregate runs, successes and failures
get_analyticsdays?, topLimit?Period report: counts, success rate, duration, tokens, cost, top tasks
self_analysisdays?, topLimit?, includeAnomalies?Self-analysis report over a period: health score, anomaly detection, trends and optimisation recommendations
manage_settingsaction, maxConcurrent?, winterMode?, notifications?, history?Read/update global settings (concurrency, notifications, retention)
manage_local_aiaction (get/update/test), mode?, baseUrl?, model?, timeoutMs?, fallback?, confidenceThreshold?, shadow?Read, update or test the local triage assistant; test sends one synthetic notification and reports latency and verdict
manage_templatesaction, template fieldsList, save or delete reusable task templates
manage_profilesaction, name?, port?List, create, switch or delete isolated profiles
transfer_tasksaction, data?Export all tasks to JSON or import them back
send_notificationaction (test/digest), channel? (all/webhook/telegram/native)Test the notification channels or send the digest
get_dashboard_info—Dashboard port/URL, platform, title, active profile
cleanup_historyretentionDays?, maxRecords?Delete old history by age and/or record cap
manage_secretsaction, name?, value?Create, list or delete AES-256-GCM encrypted secrets used in task env
get_audit_logaction?, target?, actor?, since?, until?, limit?Mutation audit journal: who changed what, when and via which interface
emit_eventeventName, payload?Start tasks subscribed to an MCP event
pipeline_validatepath?, source?Validates opencode.pipeline.yaml without changing tasks
pipeline_applypath?, source?, dryRun?Idempotently creates or updates pipeline tasks; dryRun only reports the diff
pipeline_exportpipelineExports a pipeline's tasks back to YAML
report_bugdescription, taskName?, includeLogs?, includeAnalytics?, channel?Reports an agent-steward issue with diagnostics and optional reproduction context

schedule_task also accepts the full matrix configuration (workspaceIds, strategy, failureMode, aggregation, concurrency, overrides, createAggregator).

Permissions

Agent jobs run with opencode run --auto, so their tool policy must be explicit. The global permissions.defaultPolicy setting (GUI → Settings, or manage_settings) chooses the baseline:

PolicyAllowed by defaultDenied by default
hybrid (default)read, edit, glob, grep, subagent, skill, webfetch, websearchshell, question
secureread, glob, grep, skilledit, shell, question, webfetch, websearch, subagent
legacyall ten actions—

deniedTools always wins. A non-empty allowedTools is an allowlist for non-read-only actions: read, glob, grep and skill are added automatically (PL-133), so to forbid them you must list them explicitly in deniedTools. It can also explicitly re-enable an action denied by the policy (for example shell). legacyShell: true re-enables shell only under hybrid, for tasks migrated from older versions.

Scope: the table above governs the scheduled agent run. The plugin's own tools (schedule_task, run_task_now, …) are not covered by defaultPolicy — qualityGate, beforeScript and afterScript run as shell commands in the wrapper whatever the policy says. A no-shell setup therefore has to restrict the plugin tools themselves through OpenCode tool permissions, not only the policy.

Blocked actions are written to the audit journal as tool.blocked with reason: "default-policy" and a hint, and each run logs the active policy.

Recommended pattern: keep git commit/push, builds and tests outside the agent, in qualityGate or afterScript (the wrapper runs them with bash -c), and leave the agent with read/edit. Most jobs then need no shell at all.

Agent skill

The plugin registers a built-in skill, scheduled-job-best-practices, so the agent loads guidance only when it is relevant: cron design, self-contained prompts, Quality Gates, matrix concurrency, DAG rules and post-incident diagnosis. No manual .opencode/skills setup is needed. The skill ships with references/recipes.md — eight copy-ready configurations.

Matrix builds

{
  "name": "deploy",
  "schedule": "0 3 * * *",
  "prompt": "Build, test and deploy",
  "matrix": {
    "workspaceIds": ["frontend-id", "backend-id", "mobile-id"],
    "strategy": "parallel",
    "failureMode": "continue",
    "aggregation": "summary",
    "concurrency": 2,
    "createAggregator": true,
    "overrides": {
      "mobile-id": { "qualityGate": "npm run test:mobile" }
    }
  }
}

Each workspace gets a clone named <parent>-matrix-<workspace>. The parent never runs itself: it aggregates clone results into success, error or partial. Clones stay in sync with the parent when you edit it; running clones are never touched.

Pipeline as code

Declare the whole workflow in one opencode.pipeline.yaml file instead of creating tasks one by one:

version: 1
name: nightly-release
defaults:
  retryCount: 1
  retryDelay: 120
steps:
  - id: lint
    schedule: "0 2 * * *"
    prompt: Run the linter and fix what it reports.
    qualityGate: npm run lint
  - id: test
    needs: [lint]
    trigger: dag
    prompt: Run the tests and fix failures.
    qualityGate: npm test

needs becomes a DAG dependency, a step with trigger: dag runs only after its dependencies succeed, and defaults are inherited by every step. Each step becomes a task named <pipeline> <step>.

agent-steward pipeline validate opencode.pipeline.yaml
agent-steward pipeline apply opencode.pipeline.yaml --dry-run
agent-steward pipeline apply opencode.pipeline.yaml
agent-steward apply -f opencode.pipeline.yaml          # GitOps-алиас
agent-steward pipeline export --pipeline nightly-release --out opencode.pipeline.yaml

Apply is idempotent: unchanged steps are skipped, edited steps are updated, and tasks outside the pipeline are never touched. Steps removed from the file are reported as stale, not deleted. The agent gets the same operations through pipeline_validate, pipeline_apply and pipeline_export.

See docs/PIPELINE.md for the full format, matrix fan-out, validation rules and limitations, and the ready-to-copy example.

GUI and dashboard

The OpenCode sidebar shows jobs, history, logs, dry-run, templates, import/export, concurrency limit and matrix grouping. The local web dashboard adds per-workspace summaries, matrix tabs, a pipeline view and metrics.

npm run build:gui   # produces gui-experimental.cjs
npm run build:debug # separate gui-experimental.debug.cjs + source map (release bundle untouched)
agent-steward pipeline validate opencode.pipeline.yaml --debug  # verbose stderr logs, secrets redacted

How it works

src/
  index.ts              plugin lifecycle, agent tools, RPC
  gui.tsx               OpenCode sidebar panel
  server.ts             local web dashboard
  core/
    scheduler/          Windows / Linux / macOS backends
    matrix.ts           fan-out, aggregation, sync, cancel
    record-history.ts   history, retries, chains, matrix continuation
    dry-run.ts          pipeline simulation
    lock.ts             no-overlap protection
    file-watcher.ts     chokidar triggers
    telegram.ts         Telegram Bot API delivery
    native-notify.ts    Windows Toast / macOS / Linux notifications
  db/                   SQLite: tasks, history, metrics, settings
  task-transfer.ts      export / import / validation

Job wrappers run opencode run in the task working directory, so project MCP servers are picked up automatically.

Logon mode (Windows)

Tasks are interactive only by default: Task Scheduler starts them only while the user who created them is logged on, with the normal profile, drives and saved credentials. Pass runWhenLoggedOff: true to run a job without a logged-on user (schtasks /ru SYSTEM). Such a task runs in session 0 — no user profile, mapped drives, network shares or saved credentials — so jobs that need your environment may fail; test them with dry_run first. On Linux crontab already runs without a login, and a macOS launchd agent runs only inside a user session.

Development

npm install
npm run build        # tsc
npm run build:gui    # vite
npm test             # 131 test suites, 600+ checks
npm run test:en      # same suites with the English locale

npm run test:chaos runs test-chaos-dag.mjs separately; test-prod-install.mjs is likewise invoked through its own script. The 121 in npm test counts exactly the suites listed in that script; every test-*.mjs file on disk is reachable through at least one npm script.

npm run test:en sets OPENCODE_SCHEDULER_LOCALE=en for every suite; the variable is a service hook, not a user setting.

See CONTRIBUTING.md for details.

Documentation

Translations: Русский · 中文.

FAQ

Does it work when OpenCode is closed? Yes, for cron and one-shot jobs. They are registered with the native OS scheduler, so they run without an open OpenCode window.

File (file), git (git) and MCP-event (mcp-event) triggers are watched by the plugin process (chokidar / git polling / the MCP event bus), so OpenCode must be running for those triggers to fire.

TriggerRuns without OpenCode?Mechanism
cron✅ YesNative OS scheduler (Task Scheduler / launchd / crontab)
once✅ YesNative OS scheduler, one-shot registration
file❌ Nochokidar watcher inside the plugin process
git❌ NoGit polling inside the plugin process
mcp-event❌ NoMCP event bus inside the plugin process
webhook (/api/hooks/:name)❌ NoHTTP server inside the plugin process

Do jobs run when nobody is logged on? On Windows, only if you opt in with runWhenLoggedOff: true: the task is then registered as schtasks /ru SYSTEM and runs in session 0 without your profile, mapped drives or saved credentials. The default is interactive only — the job runs while the user is logged on. Linux crontab always runs without a login; a macOS launchd agent runs only inside a user session.

Task creation fails with “Access is denied” on Windows? Some machines (hardened OEM images, a revoked “Log on as a batch job” right) refuse task registration to a non-elevated process — both schtasks.exe and the COM API. The plugin then retries the same command with a Windows elevation prompt: you confirm once per operation, and OpenCode itself keeps running without admin rights. The retry covers only commands that change the scheduler (/create, /delete, /change, /run, /end), is skipped where no prompt could be shown (services, session 0) and is switched off with AGENT_STEWARD_NO_UAC=1 (CI, headless). Declining the prompt leaves the original error text untouched. cmd.exe is not involved and the prompt is readable: it shows schtasks.exe (“Task Scheduler Command Line”) with the full arguments of the operation, so you confirm a specific scheduler change, not an opaque script. The elevated process's text output is not captured (ShellExecute has no pipes); failures are explained from the exit code. If the dialog goes unanswered for 2 minutes the retry gives up; a non-elevated process cannot close an elevated dialog, so dismiss it manually.

Which platforms are supported? Windows (Task Scheduler), macOS (launchd) and Linux (crontab). Backend differences are documented in CROSS_PLATFORM.md.

Where does my data go? Nowhere. History, logs, metrics and settings are stored locally in SQLite. No telemetry, no accounts, no cloud.

How do I get Telegram notifications? Create a bot with @BotFather, copy the token, send the bot a message and read chat_id from getUpdates (or use a group/channel ID). Paste both in the sidebar panel or run manage_settings with notifications.telegram (enabled, botToken, chatId, optional parseMode). To keep secrets out of settings.json, set OPENCODE_SCHEDULER_TELEGRAM_BOT_TOKEN and OPENCODE_SCHEDULER_TELEGRAM_CHAT_ID instead — environment values are used when the fields are empty. Use send_notification with channel: "telegram" to verify.

Do I need an extra package for desktop notifications? No. Windows Toast (PowerShell/WinRT), macOS Notification Center (osascript) and Linux notify-send are called directly, so node-notifier is not required. Enable them with notifications.native.enabled.

Can I silence notifications at night? Yes. Set notifications.quietHours (enabled, from, to in HH:MM). During the window successful and partial runs are suppressed, while failures and timeouts are always delivered.

How do I store secrets? Use manage_secrets (or the 🔐 Secrets panel in the sidebar) to create an encrypted secret. Secrets are stored in <PLUGIN_DIR>/secrets.json with AES-256-GCM and a key file (secrets.key; mode 0600 on POSIX, an ACL granting only the current Windows user on Windows). In task env, reference a secret as ${secret:NAME} — the value is substituted at run time and masked in logs, history and audit. To keep the Telegram token out of settings.json, leave notifications.telegram.botToken empty and set OPENCODE_SCHEDULER_TELEGRAM_BOT_TOKEN (and OPENCODE_SCHEDULER_TELEGRAM_CHAT_ID) as environment variables instead — see the Telegram question above.

Can I see who changed what? Yes. The audit log (get_audit_log tool, Audit log panel, GET /api/audit) records every mutation — task create/update/delete/run, settings, templates, profiles, workspaces, secrets, import, history cleanup — with actor (mcp/gui/http), source, timestamp and redacted details. Retention defaults to 90 days / 10 000 records.

How is this different from experimental.schedules? The built-in scheduler runs jobs while OpenCode is open. This plugin uses the native OS scheduler and adds DAG pipelines, matrix builds, quality gates, webhooks and observability.

Can jobs run in other repositories? Yes. Workspaces point at project paths, and a matrix build runs one template across several workspaces at once.

Roadmap

License

MIT.

NPM
agent-steward
Install Command
npm install agent-steward