Extending Indaba
A runner, a guard type, an arbiter, an event listener, a log sink or a workflow store is added from outside
Indaba, as a plugin. A plugin is a
module that default-exports an object with a name and a register(host) function. The contracts it
implements (Runner, Guard, Plugin, PluginHost, the events) are defined in @indaba/core, so
adding one never edits core, the engine or the runners.
The built-in runners, the git_diff_empty and diff_within_scope guards, the human arbiter and the
OpenAI-compatible endpoints configured in the environment are registered through the same registries a plugin
reaches. A plugin therefore has no less access than a built-in, and no more.
The contract#
interface Plugin {
readonly name: string;
readonly logSinks?: readonly LogSink[]; // optional; see Logging from a plugin
register(host: PluginHost): void | Promise<void>;
}
interface PluginHost {
registerRunner(runner: Runner): void;
registerGuard(guard: Guard): void;
registerAdjudicator(name: string, adjudicator: Adjudicator): void; // what a step's `arbiter:` names
registerNegotiationDecider(decider: NegotiationDecider): void; // who decides when steps running side by side cannot agree on a split (the last one wins; none means one after another)
addListener<E extends object>(
type: abstract new (...args: never[]) => E,
listener: (event: E) => unknown,
): void;
readonly logger?: Logger; // optional; see Logging from a plugin
registerLogSink?(sink: LogSink): void; // optional; see Logging from a plugin
registerRegistry?(registry: WorkflowRegistry): void; // optional; see Replacing the workflow registry
}
interface Runner {
readonly name: string; // what a workflow file writes in `runner:`
readonly description?: string; // one line, shown by `indaba catalog` and an editor
run(request: RunRequest, signal?: AbortSignal): Promise<RunResult>;
}
interface Guard {
readonly type: string; // what a workflow file writes in a guard's `type:`
readonly description?: string;
check(guard: GuardDefinition, workdir: string): Promise<GuardResult>;
}
interface Adjudicator {
readonly description?: string;
rule(request: RulingRequest, signal?: AbortSignal): Promise<Ruling | null>;
}
Behaviour worth knowing:
- A
Runnerreturns aRunResultfor a command that ran, even if it failed (a non-zeroexitCode); the step'son_failuredecides what happens. Throw aRunnerUnavailableError(aRunnerError) only when the runner could not run at all and nothing has been sent to the agent yet: no key, program not found, endpoint unreachable. A workflow that lists several runners then tries the next one. Once the agent has been given the prompt it may have changed files, so from then on return aRunResult(a failed one if need be) and throw nothing that a fallback could mistake for "nothing happened". Any otherRunnerErrorfails the step. Honourrequest.timeoutSeconds(default 900) and theAbortSignal, and do not leave a child process behind. - A
GuardreturnsGuardResult.pass()orGuardResult.fail(message). It decides; it does not act. Resolveguard.pathsagainstworkdirand refuse any path that leaves it. - Registering a runner name or guard type that already exists replaces the earlier one. An adjudicator name cannot
be registered twice:
registerthrowsAn adjudicator named "<name>" is already registered., so a plugin cannot replacehuman. - Guard types and runner names are checked when a workflow is validated, against what is registered, so a
plugin's guard type or runner name is valid in
workflow.ai.ymlonly once the plugin is loaded (otherwise:$.roles.speaker.runner "echo" is not a known runner). Load the plugin forvalidateandplantoo. - Listeners run in registration order, one at a time. A listener that throws is isolated: the run
continues, and the error goes to the command line's listener-error handler, which prints
Listener failed: <message>to stderr. A listener may be async. - A plugin whose
registerthrows stops the command withPlugin "<name>" failed to register: .... - Give each runner, guard and adjudicator a
description: one plain sentence of what it is, whichindaba catalog --plugin <yours>lists and an editor shows next to the name. It is optional; without one the catalog lists the name alone. The catalog cuts it at 200 characters and drops control sequences, and it never goes into a trace.
Events you can listen to, all exported from @indaba/core: StepStatusChanged (taskId, stepId,
from, to, optional reason), SpanStarted and SpanEnded (each carries a span), and StepOutput (traceId, spanId, seq, text: a
chunk a runner streamed, not yet redacted), and BoardRecorded (traceId and record: every record the run's board
makes, in order, already cleaned and redacted; a board start record, a post, a settle or a truncated). The built-in
board file writer is a listener of BoardRecorded like any other, so a plugin sees exactly what it sees; for the notes
between steps see the board. Names and payloads are public surface.
A complete plugin#
This plugin adds a runner called echo, a guard type called file_exists and a listener that logs
step transitions. It lives in your own project, for example plugins/demo.ts compiled to
plugins/demo.js.
import { access } from 'node:fs/promises';
import { isAbsolute, relative, resolve } from 'node:path';
import {
type Guard,
type GuardDefinition,
GuardResult,
type Plugin,
type PluginHost,
RunResult,
type Runner,
type RunRequest,
StepStatusChanged,
} from '@indaba/core';
// A runner: answers every prompt by echoing it back. Never starts a process.
const echo: Runner = {
name: 'echo',
description: 'Answers every prompt by echoing it back.',
async run(request: RunRequest, signal?: AbortSignal): Promise<RunResult> {
if (signal?.aborted === true) {
return new RunResult({ exitCode: 1, output: '', errorOutput: 'aborted' });
}
request.onOutput?.(request.prompt);
// A runner whose transport streams the model's reasoning separately sends it here, never to onOutput:
// it reaches `watch --thoughts`, the dashboard and the web view, but no parser and no prompt.
request.onThought?.('echoing the prompt');
return new RunResult({ exitCode: 0, output: request.prompt });
},
};
// A guard: every path listed under the guard must exist in the step's working directory.
const fileExists: Guard = {
type: 'file_exists',
async check(guard: GuardDefinition, workdir: string): Promise<GuardResult> {
const missing: string[] = [];
for (const path of guard.paths) {
const target = resolve(workdir, path);
const escapes = isAbsolute(relative(workdir, target)) || relative(workdir, target).startsWith('..');
if (escapes) {
return GuardResult.fail(`Path "${path}" leaves the working directory.`);
}
try {
await access(target);
} catch {
missing.push(path);
}
}
return missing.length === 0 ? GuardResult.pass() : GuardResult.fail(`Missing: ${missing.join(', ')}`);
},
};
const plugin: Plugin = {
name: 'demo',
register(host: PluginHost): void {
host.registerRunner(echo);
host.registerGuard(fileExists);
host.addListener(StepStatusChanged, (event) => {
process.stderr.write(`[demo] ${event.stepId}: ${event.from} -> ${event.to}\n`);
});
},
};
export default plugin;
A workflow that uses all three:
version: "1.0"
name: "plugin-demo"
roles:
speaker:
runner: "echo"
steps:
- id: "say"
role: "speaker"
goal: "Hello from a plugin runner."
outputs: ["hello.txt"]
guards:
- type: "file_exists"
paths: ["hello.txt"]
(That workflow fails at the outputs check, because the echo runner writes no file; it is there to show
the three names in use. Add a shell step before it that creates hello.txt to make it pass.)
Logging from a plugin#
host.logger is the logger of the command, the one the built-ins write through: same file, same level, same
redaction. Pass a component name of your own, a fixed sentence, and anything from outside as fields:
register(host) {
host.logger?.info('plugin.demo', 'the plugin registered', { version: '1.2.0' });
}
It is optional in the type so a host written before it existed still type-checks; the indaba command line always
provides one. To log what a run does, listen to an event (StepStatusChanged, SpanEnded) with host.addListener
rather than logging the same thing twice: the command line already records those.
A plugin can also add a sink, a place records go, with logSinks on the plugin or host.registerLogSink(sink); it
receives the same redacted records as the built-in file and terminal sinks, and one that throws is dropped after one
warning. See logging.md.
Replacing the workflow registry#
indaba workflows keeps its list in a JSON file per folder (FileWorkflowRegistry of @indaba/engine). A plugin can
put another store behind the same contract, WorkflowRegistry of @indaba/core: a database, or a service shared by a
team.
register(host) {
host.registerRegistry?.(myRegistry); // list, get, scan, add, annotate, remove, copy, roots
}
The last one registered is used for that command (indaba workflows ... --plugin <yours>). It gets the same contract
and nothing the built-in store lacks. A store that throws fails the command with its message; Indaba does not fall
back to the file store. Refuse with RegistryError and one of its codes (not_found, ambiguous, outside_roots,
not_a_workflow, exists, would_return, store_failed) so the command line can say what happened. The method is
optional on PluginHost, so a host written before it existed still type-checks.
Running with a plugin#
Pass --plugin to validate, plan, run, catalog and workflows; indaba ui loads no plugins. The option repeats, and the value is a file path
(relative paths resolve against the directory you run in) or an installed package name:
npx indaba validate workflow.ai.yml --plugin ./plugins/demo.js
npx indaba run workflow.ai.yml --plugin ./plugins/demo.js --plugin my-indaba-plugin
The module must default-export a Plugin. If it does not, or cannot be imported, the command stops with
a message naming the specifier. Node loads the file as an ES module, so a TypeScript plugin has to be
compiled first (or run under a loader you provide).
Using the engine without the command line#
indaba exports createEngine({ projectDir, env, plugins }), which wires the registries, the tracer and
the engine, and registers the plugins you pass. Its result gives you the engine, the parser
(validating against the same registries, so plugin guard types and runner names are valid), the runners and
guards registries, the adjudicators, the MCP planner, the events dispatcher, and workflowRegistry when a
plugin registered one. Pass logger (built with createLogger from @indaba/core, with
your own sinks, or with FileLogSink from @indaba/engine) and the engine's events are logged through it and plugins
receive it as host.logger; without one nothing is logged. Parsing a file and running it:
import { createEngine } from 'indaba';
const { engine, parser } = await createEngine({
projectDir: process.cwd(),
env: process.env,
plugins: [plugin],
});
const workflow = await parser.parseFile('workflow.ai.yml');
const result = await engine.run(workflow);
console.log(result.status);
Rules for extensions#
- Depend on
@indaba/corefor the contracts. Do not import from another package's internals. - Do not hand a string composed from model output to a shell. Start processes with an argument array.
- Keep secrets out of what you return, trace or log.
- Any new name a workflow can use (a runner, a guard type) is public surface of your plugin: version it.
- A runner takes part in a priority list (
runner: [yours, "claude-code"]) the same way a built-in does.RunRequest.permissionsandagentare hints you may ignore (thediff_within_scopeguard still applies). Report what is worth recording throughrequest.onEvent(name, attributes): names and counts only, never prompts, paths, file content or secrets. - A step that writes
permissions.levelis refused byvalidate,planand the start of a run if a runner of its chain does not implementPermissionCapableand declare that level (see below). - To add an OpenAI-compatible API you do not need a plugin: set
INDABA_OPENAI_COMPAT_<NAME>_BASE_URL(see getting-started.md). In code,new OpenAiCompatibleRunner({ name, baseUrl, apiKey, ... })from@indaba/runners, registered withhost.registerRunner.
Saying what a runner supports#
A runner says what it supports by implementing optional interfaces from @indaba/core. McpCapable.mcpCapability()
returns injected, agent_managed or none; a runner without it has no MCP, so a step that names servers is refused
under mcp_policy: required. PermissionCapable has permissionCapabilities(), which lists for read, edit and
full a mode (native, acp, after, none, unsupported), a scope (acp, guard, none) and a note id,
plus permissionDenied(output) and canRecogniseDenial. A runner without it supports no level. indaba catalog
lists each runner's levels, and indaba plan prints the MCP findings.
StallCapable has one member, canReportActivity: boolean. A runner that sets it to true promises: when
RunRequest.stallSeconds is set, it stops the attempt after that many seconds without activity (the whole process tree,
if it started one) and returns a result with stalled: true and a non-zero exit code; STALL_EXIT_CODE (125) from
@indaba/runners is the one the built-ins use. What counts as activity is yours to define and to document: output on a
stream, a protocol update, a progress event. It must not be something that stays quiet while the agent is working, or a
healthy call will be stopped. Say false when your runner is configured so that it cannot tell (the built-in
claude-code does in its plain-output mode). A runner without the interface, or saying false, is refused by
validate, plan and the start of a run, by name, in any step that sets stall; it keeps working in every other step.
See Stalls.