use serde_json::{Map, Value};
pub struct Op {
pub name: &'static str,
pub owner: &'static str,
pub payload: &'static [&'static str],
pub reply: &'static [&'static str],
}
const fn op(
name: &'static str,
owner: &'static str,
payload: &'static [&'static str],
reply: &'static [&'static str],
) -> Op {
Op {
name,
owner,
payload,
reply,
}
}
pub const OPS: &[Op] = &[
op(
"bash",
"host",
&["command", "timeout", "yield_after"],
&[
"cancelled",
"exit_code",
"full_output_path",
"job",
"output",
"partial_file",
"running",
"timed_out",
"truncated",
],
),
op("files.before_write", "host", &["writes"], &["results"]),
op("shell.cancel", "host", &["id"], &[]),
op("shell.get", "host", &["id"], &[]),
op("shell.list", "host", &[], &[]),
op("shell.read", "host", &["cursor", "id", "max_bytes"], &[]),
op("shell.result", "host", &["id", "wait"], &[]),
op("shell.run", "host", &["command", "timeout", "yield_after"], &[]),
op(
"rlm.view_image",
"host::view_image",
&["detail", "path"],
&["description", "note"],
),
op("ctx.forget", "kernel_apis::context_control", &["ids", "reason"], &[]),
op("ctx.get", "kernel_apis::context_control", &["id"], &[]),
op("ctx.history", "kernel_apis::context_control", &["kinds", "limit"], &[]),
op("ctx.note", "kernel_apis::context_control", &["text"], &[]),
op("ctx.pin", "kernel_apis::context_control", &["id"], &[]),
op("ctx.summarize", "kernel_apis::context_control", &["ids", "text"], &[]),
op("ctx.unpin", "kernel_apis::context_control", &["id"], &[]),
op(
"diagram.mermaid",
"diagram",
&["path", "show", "text", "theme", "to_model"],
&[],
),
op("agent_message.list", "kernel_apis::family", &[], &[]),
op("agent_message.receive", "kernel_apis::family", &["limit"], &[]),
op(
"agent_message.send",
"kernel_apis::family",
&[
"key",
"message",
"receiver_id",
"receiver_name",
"receiver_role",
"steer",
"ttl_ms",
],
&[],
),
op("goal.blocked", "kernel_apis::goal", &["reason", "revision"], &[]),
op("goal.check", "kernel_apis::goal", &[], &[]),
op(
"goal.complete",
"kernel_apis::goal",
&["evidence", "revision", "summary"],
&[],
),
op("goal.get", "kernel_apis::goal", &[], &[]),
op(
"sessions.list",
"kernel_apis::sessions",
&["cwd", "days", "limit"],
&["sessions"],
),
op(
"sessions.read",
"kernel_apis::sessions",
&[
"around",
"branch",
"from_entry",
"limit",
"session",
"span",
"to_entry",
"tool_chars",
],
&[],
),
op(
"sessions.search",
"kernel_apis::sessions",
&[
"branch",
"cwd",
"days",
"ignore_case",
"limit",
"pattern",
"per_session",
"roles",
"sessions",
"snippet",
"terms",
],
&[],
),
op("hints.mute", "kernel_apis::hints", &["tags"], &["muted"]),
op("hints.muted", "kernel_apis::hints", &[], &["muted"]),
op("hints.unmute", "kernel_apis::hints", &["tags"], &["muted"]),
op(
"images.generate",
"kernel_apis::images",
&["model", "n", "out", "prompt", "size"],
&[],
),
op("images.models", "kernel_apis::images", &[], &[]),
op("instances.close", "kernel_apis::instances", &["id"], &[]),
op("instances.get", "kernel_apis::instances", &["id"], &[]),
op(
"instances.invoke",
"kernel_apis::instances",
&["id", "input", "key"],
&[],
),
op("instances.list", "kernel_apis::instances", &[], &[]),
op("instances.retain", "kernel_apis::instances", &["task_id"], &[]),
op(
"memory.brief",
"kernel_apis::memory",
&["text", "scope", "topic", "project"],
&[],
),
op(
"memory.correct",
"kernel_apis::memory",
&["id", "text", "evidence", "evidenceClass"],
&[],
),
op(
"memory.dream",
"kernel_apis::memory",
&["days", "limit", "project"],
&[],
),
op("memory.forget", "kernel_apis::memory", &["id"], &[]),
op("memory.get", "kernel_apis::memory", &["id"], &[]),
op("memory.invalidate", "kernel_apis::memory", &["id", "reason"], &[]),
op("memory.list", "kernel_apis::memory", &[], &[]),
op(
"memory.prepare",
"kernel_apis::memory",
&["query", "taskId", "scope", "refresh"],
&["results"],
),
op(
"memory.propose",
"kernel_apis::memory",
&[
"text",
"evidence",
"scope",
"evidenceClass",
"type",
"key",
"situation",
"pathGlobs",
],
&[],
),
op("memory.reflect", "kernel_apis::memory", &["query", "scope"], &[]),
op(
"memory.topic",
"kernel_apis::memory",
&["topic", "scope", "project"],
&[],
),
op("memory.why", "kernel_apis::memory", &["taskId"], &[]),
op("procedure.abort", "delegation::skill_runs", &["reason", "run"], &[]),
op("procedure.coverage", "delegation::skill_runs", &["name"], &[]),
op(
"procedure.propose",
"delegation::skill_runs",
&["content", "evidence", "name"],
&[],
),
op(
"procedure.start",
"delegation::skill_runs",
&["input", "name", "version"],
&[],
),
op(
"procedure.step",
"delegation::skill_runs",
&["run", "segment", "state"],
&[],
),
op("progress.assess", "kernel_apis::progress", &["task_id"], &[]),
op("progress.history", "kernel_apis::progress", &["task_id"], &[]),
op(
"progress.reassess",
"kernel_apis::progress",
&["claim", "extend_budget", "task_id", "verifier", "verifier_input"],
&[],
),
op(
"progress.report",
"kernel_apis::progress",
&["evidence", "metrics", "summary", "task_id"],
&[],
),
op(
"schedule.at",
"kernel_apis::prompt_schedule",
&["when_ms", "when_in_ms", "prompt", "name"],
&["id"],
),
op("schedule.cancel", "kernel_apis::prompt_schedule", &["id"], &[]),
op(
"schedule.every",
"kernel_apis::prompt_schedule",
&["interval", "prompt", "name", "until_ms", "until_in_ms", "max_runs"],
&["id"],
),
op(
"schedule.loop",
"kernel_apis::prompt_schedule",
&["interval", "prompt", "name", "until_ms", "until_in_ms", "max_runs"],
&["id"],
),
op(
"schedule.watch_pr",
"kernel_apis::prompt_schedule",
&[
"repo",
"pr",
"mode",
"interval",
"prompt",
"name",
"until_ms",
"until_in_ms",
"max_runs",
],
&["id"],
),
op("schedule.list", "kernel_apis::prompt_schedule", &[], &[]),
op("goals.attach", "kernel_apis::schedules", &["id", "task_id"], &[]),
op(
"goals.create",
"kernel_apis::schedules",
&["max_tasks", "required_checks", "title"],
&[],
),
op("goals.get", "kernel_apis::schedules", &["id"], &[]),
op("goals.list", "kernel_apis::schedules", &[], &[]),
op("goals.pause", "kernel_apis::schedules", &["id"], &[]),
op("goals.resume", "kernel_apis::schedules", &["id"], &[]),
op("goals.verify", "kernel_apis::schedules", &["id", "input"], &[]),
op(
"schedules.create",
"kernel_apis::schedules",
&[
"definition",
"every_ms",
"goal_id",
"input",
"max_runs",
"model",
"start_at",
],
&[],
),
op("schedules.delete", "kernel_apis::schedules", &["id"], &[]),
op("schedules.list", "kernel_apis::schedules", &[], &[]),
op("schedules.pause", "kernel_apis::schedules", &["id"], &[]),
op("schedules.resume", "kernel_apis::schedules", &["id"], &[]),
op("schedules.tick", "kernel_apis::schedules", &[], &[]),
op("skills.code_history", "kernel_apis::skills", &["name"], &[]),
op("skills.code_list", "kernel_apis::skills", &["family", "kind"], &[]),
op(
"skills.invoke",
"kernel_apis::skills",
&["input", "name", "version"],
&[],
),
op("skills.list", "kernel_apis::skills", &[], &[]),
op("skills.load", "kernel_apis::skills", &["name", "version"], &[]),
op(
"skills.propose_code",
"kernel_apis::skills",
&["evidence", "name", "source", "test_source"],
&[],
),
op(
"skills.propose_policy",
"kernel_apis::skills",
&["evidence", "family", "name", "source", "test_source"],
&[],
),
op("skills.refresh", "kernel_apis::skills", &[], &[]),
op("skills.rollback", "kernel_apis::skills", &["name", "version"], &[]),
op("skills.select", "kernel_apis::skills", &["limit", "query"], &[]),
op("skills.why", "kernel_apis::skills", &["decision_id"], &[]),
op(
"tools.call",
"kernel_apis::tool_calls",
&["detach", "name", "params", "yield_after"],
&[],
),
op("tools.calls", "kernel_apis::tool_calls", &[], &[]),
op("tools.cancel", "kernel_apis::tool_calls", &["id"], &[]),
op("tools.describe", "kernel_apis::tool_calls", &["name"], &[]),
op("tools.get", "kernel_apis::tool_calls", &["id"], &[]),
op("tools.list", "kernel_apis::tool_calls", &[], &[]),
op("tools.result", "kernel_apis::tool_calls", &["id", "wait"], &[]),
op("agents.cancel", "delegation::agents", &["id"], &[]),
op("agents.inspect", "delegation::agents", &["id"], &[]),
op(
"agents.invoke",
"delegation::agents",
&["definition", "input", "key", "model", "timeout_ms"],
&["error", "status", "value"],
),
op("agents.list", "delegation::agents", &[], &[]),
op("agents.register", "delegation::agents", &["definition"], &[]),
op("agents.result", "delegation::agents", &["id"], &[]),
op(
"agents.spawn",
"delegation::agents",
&["definition", "input", "key", "model"],
&["id"],
),
op("agents.status", "delegation::agents", &[], &[]),
op("agents.tasks", "delegation::agents", &[], &[]),
op("background.inspect", "delegation::agents", &["id"], &[]),
op("background.list", "delegation::agents", &[], &[]),
op("background.result", "delegation::agents", &["id"], &[]),
op(
"background.start",
"delegation::agents",
&["key", "model", "prompt", "timeout_ms"],
&[],
),
op("background.stop", "delegation::agents", &["id"], &[]),
op("workflows.run", "delegation::agents", &["key", "nodes"], &[]),
op("budget.estimate", "delegation::agents", &["plan", "workflow"], &[]),
op(
"rlm.collect",
"delegation::host, harness::chat::host_ops",
&["selectors", "timeout_ms"],
&["results"],
),
op(
"rlm.delete_subagent",
"delegation::host, harness::chat::host_ops",
&["selector"],
&[],
),
op(
"rlm.finish",
"delegation::host",
&["changed_files", "evidence", "left", "outputs", "status", "summary"],
&[],
),
op(
"rlm.list_subagents",
"delegation::host, harness::chat::host_ops",
&[],
&["subagents"],
),
op(
"rlm.merge",
"delegation::host",
&["include_failed", "on_conflict", "selectors"],
&[],
),
op("rlm.progress", "delegation::host", &["selectors"], &["subagents"]),
op(
"rlm.results",
"delegation::host, harness::chat::host_ops",
&["selectors"],
&["results", "running"],
),
op(
"rlm.spawn",
"delegation::host, harness::chat::host_ops",
&["kwargs", "prompt"],
&[],
),
op("rlm.worktrees.cleanup", "delegation::host", &["branches"], &[]),
op("rlm.worktrees.list", "delegation::host", &["all"], &["worktrees"]),
op("board.add", "harness::chat::host_ops", &["detail", "title"], &[]),
op("board.claim", "harness::chat::host_ops", &["id"], &[]),
op("board.list", "harness::chat::host_ops", &["status"], &[]),
op(
"board.update",
"harness::chat::host_ops",
&["id", "note", "status"],
&[],
),
op("notes.append", "harness::chat::host_ops", &["text"], &[]),
op("notes.read", "harness::chat::host_ops", &[], &[]),
op(
"notes.write",
"harness::chat::host_ops",
&["expect_version", "text"],
&[],
),
op(
"rlm.ask",
"harness::chat::host_ops",
&["child", "question", "timeout_ms"],
&[],
),
op("swarm.agents", "harness::chat::host_ops", &[], &[]),
op("swarm.inbox", "harness::chat::host_ops", &["all", "mark"], &[]),
op(
"swarm.register",
"harness::chat::host_ops",
&["files", "name", "summary", "topics", "work"],
&[],
),
op("swarm.route", "harness::chat::host_ops", &["query"], &[]),
op("swarm.send", "harness::chat::host_ops", &["text", "to", "wake"], &[]),
op("rlm.frames", "inference", &["id", "limit"], &[]),
op(
"rlm.infer",
"inference",
&[
"budget",
"context",
"contract",
"max_repairs",
"model",
"task",
"thinking",
"timeout_ms",
],
&[],
),
op(
"rlm.load",
"inference",
&["chars", "digest", "label", "size", "source"],
&["label", "path", "stored"],
),
op(
"rlm.map",
"inference::map",
&[
"budget",
"concurrency",
"contract",
"frames",
"max_repairs",
"model",
"prefix",
"thinking",
"timeout_ms",
],
&["budget", "results", "usage"],
),
op("rlm.models", "inference::map", &[], &[]),
op("rlm.cancel", "lanes, harness::chat::host_ops", &["cell"], &[]),
op("rlm.cell.cancel", "lanes", &["cell"], &[]),
op("rlm.cells", "lanes", &[], &["cells"]),
op("rlm.lane.close", "lanes", &["lane"], &[]),
op("rlm.lane.open", "lanes", &["lane"], &[]),
op("rlm.lanes", "lanes", &[], &["lanes"]),
op("rlm.recovery", "lanes", &[], &[]),
op(
"gates.compare",
"services::gates",
&["baseline", "candidate", "gate_id"],
&[],
),
op(
"gates.define",
"services::gates",
&["checks", "fixture_hash", "id"],
&[],
),
op("gates.history", "services::gates", &["gate_id"], &[]),
op("gates.list", "services::gates", &[], &[]),
op("refinements.activate", "services::local", &["id"], &[]),
op("refinements.list", "services::local", &[], &[]),
op(
"refinements.propose",
"services::local",
&["baseVersion", "content", "evidence", "kind", "scope", "target"],
&[],
),
op("refinements.reject", "services::local", &["id"], &[]),
op("refinements.rollback", "services::local", &["id"], &[]),
op(
"ext.call",
"session_core::compose",
&["arguments", "extension", "function"],
&[],
),
op("ext.list", "session_core::compose", &[], &[]),
op("judge.decide", "judge", &["expect", "kind", "questions", "state"], &[]),
op("knowledge.mirror", "graph", &[], &[]),
op(
"knowledge.relations",
"graph",
&["kinds", "paths"],
&[
"files",
"mirror",
"pending",
"pruned",
"read",
"relations",
"rev",
"truncated",
],
),
op("knowledge.settle", "graph", &["rev", "verdicts"], &["mirror"]),
op("rlm.find_models", "session_core::compose", &["limit", "query"], &[]),
op("rlm.race_models", "session_core::compose", &[], &[]),
op("cell.output", "session_core::turns", &["text"], &[]),
];
pub fn not_wired(kind: &str) -> String {
format!("Ultron RLM host request is not wired: {kind}")
}
pub fn find(name: &str) -> Option<&'static Op> {
OPS.iter().find(|op| op.name == name)
}
pub fn fields(name: &str, payload: &Map<String, Value>) -> Result<(), String> {
let op = find(name).unwrap_or_else(|| panic!("{name} is not in kernel::ops::OPS"));
jsrt::payload::fields(payload, op.payload)
}