Skip to content

Commit a7f9c85

Browse files
authored
feat: add OpenCode adapter and V2 orchestration support (#49)
This adds `entrust:opencode` as an external worker adapter backed by one shared OpenCode server and independent worker sessions. It carries model selection, continuation, typed questions/permissions, Stop, reports, and explicit V2 selection into orchestration. ## Changes - Add the OpenCode skill, host wrapper, V1 compatibility client, and explicit native V2 client/driver. - Add typed immutable callback handling, session ownership, native profile verification, durable attribution, and bounded pagination. - Allow orchestrate plans and swarm batches to select `opencode`; preserve Codex as the existing default. - Default discovery to the first two recent models in saved order; pin the selected model for registered plans and continuation. - Document measured transport behavior, restoration, and unsupported capabilities. ## Validation - OpenCode adapter suite: 65/65 passed after the final native contract correction. - Real V2 launcher gate: question, permission-controlled `printf`, wrapper Stop during a running tool, then same-session continuation; each completed invocation had a valid schema receipt. Six admissions across retained attempts took 254.016 seconds; the original singleton was restored. - `git diff --check` passed. The broader suite was 22/23 green before the final native contract correction; `orchestrate-live` was not run. ## Active steer limitation Steer itself is available at a safe provider-turn boundary, and the live probe observed that behavior. The strict guarantee we need for Codex parity is missing: the pinned V2 prompt schema accepts `delivery: "steer"` but has no expected active turn/generation ID. A client-side GET followed by POST cannot atomically ensure the same invocation is still active at admission; another prompt, client, or state transition can race between them. This is a delivery-fencing gap, not a consequence of `/wait` returning 503. See the [pinned V2 session schema](https://github.com/anomalyco/opencode/blob/aec0b9a6d8898f68f923aaf08b7306d931fd9d76/packages/protocol/src/groups/session.ts) and the open [upstream request for distinct queue/steer/break semantics](anomalyco/opencode#32157). Options: 1. **Preferred for strict parity:** add an upstream expected-turn/generation token, validate it atomically with prompt admission, return a stale-target conflict, and expose the accepted target in durable events. Add race tests for simultaneous prompts, tool boundaries, Stop, and turn completion. 2. **Best effort:** keep next-boundary steer and state that it may land after the observed turn changes. Polling narrows the race window but does not close it. 3. **Queue:** submit a separate next task. This preserves order but does not guide the active task. 4. **Stop and reissue:** use break/abort followed by a new prompt. This is cancellation with possible partial side effects or unknown outcome, not steer. This PR implements explicit V2 boundary delivery and reports the strict steer gap. It does not claim full interaction parity or change the server's global/default API family.
1 parent 58bd0b0 commit a7f9c85

24 files changed

Lines changed: 3591 additions & 28 deletions

File tree

‎.claude-plugin/marketplace.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"plugins": [
1010
{
1111
"name": "entrust",
12-
"description": "Orchestrate native subagents in Codex or Claude with scoped tasks, independent verification and attributable results. In Claude, the codex adapter also launches external Codex agents with per-call rights, worktrees, evidence gates and receipts. External-run helpers include cleanup, experiments, an advisor, swarms and feedback reports.",
12+
"description": "Orchestrate native subagents in Codex or Claude with scoped tasks, independent verification and attributable results. External Codex and OpenCode adapters provide sessions, scoped worktrees, evidence gates and receipts; OpenCode uses one existing server and recent router models. Helpers include cleanup, experiments, an advisor, swarms and feedback reports.",
1313
"author": {
1414
"name": "Nowely"
1515
},

‎plugins/entrust/evals/fake-opencode.mjs‎

Lines changed: 271 additions & 0 deletions
Large diffs are not rendered by default.

‎plugins/entrust/evals/opencode.test.mjs‎

Lines changed: 583 additions & 0 deletions
Large diffs are not rendered by default.

‎plugins/entrust/evals/run-all.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { measured, parseCount } from "./lib/counts.mjs";
2020
const HERE = path.dirname(fileURLToPath(import.meta.url));
2121
// Hand-ordered, because the order is information (cheapest first), and checked against the directory,
2222
// because a suite file nobody listed here would otherwise never run.
23-
const SUITES = ["orchestrate", "advisor", "fragments", "lint-draft", "gate-checks", "package", "capture-check", "agent-contract", "agent-run", "swarm", "attach-pasted", "experiment", "status", "prepare-feedback", "cleanup", "worktree", "cli", "conformance", "lock", "protocol", "fidelity", "orchestrate-live"];
23+
const SUITES = ["orchestrate", "advisor", "fragments", "lint-draft", "gate-checks", "package", "capture-check", "agent-contract", "agent-run", "opencode", "swarm", "attach-pasted", "experiment", "status", "prepare-feedback", "cleanup", "worktree", "cli", "conformance", "lock", "protocol", "fidelity", "orchestrate-live"];
2424
const onDisk = fs.readdirSync(HERE).filter((f) => f.endsWith(".test.mjs")).map((f) => f.slice(0, -".test.mjs".length));
2525
const unlisted = onDisk.filter((n) => !SUITES.includes(n)), missing = SUITES.filter((n) => !onDisk.includes(n));
2626
if (unlisted.length || missing.length) {

‎plugins/entrust/evals/status.test.mjs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ test("the codex page injects the line, it runs this script, its allowed-tools co
110110
for (const skill of fs.readdirSync(path.join(ROOT, "skills")).filter((s) => s !== "codex")) {
111111
let other = "";
112112
try { other = fs.readFileSync(path.join(ROOT, "skills", skill, "SKILL.md"), "utf8"); } catch { continue; }
113-
if (/status\.mjs/.test(other)) problems.push(`${skill}/SKILL.md runs or names status.mjs`);
113+
if (/status\.mjs/.test(other) && skill !== "opencode") problems.push(`${skill}/SKILL.md runs or names Codex status.mjs`);
114+
if (skill === "opencode" && /(?:\.\.\/codex|skills\/codex)\/scripts\/status\.mjs/.test(other))
115+
problems.push("opencode/SKILL.md must use its own discovery, not Codex status.mjs");
114116
}
115117
return problems.length === 0 || problems.join("; ");
116118
});

‎plugins/entrust/plugin/.claude-plugin/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "entrust",
33
"version": "0.23.0",
4-
"description": "Orchestrate native subagents in Codex or Claude with scoped tasks, independent verification and attributable results. In Claude, the codex adapter also launches external Codex agents with per-call rights, worktrees, evidence gates and receipts. External-run helpers include cleanup, experiments, an advisor, swarms and feedback reports.",
4+
"description": "Orchestrate native subagents in Codex or Claude with scoped tasks, independent verification and attributable results. External Codex and OpenCode adapters provide sessions, scoped worktrees, evidence gates and receipts; OpenCode uses one existing server and recent router models. Helpers include cleanup, experiments, an advisor, swarms and feedback reports.",
55
"author": {
66
"name": "Nowely"
77
},

‎plugins/entrust/plugin/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ Canonical homes for repeated stories:
348348
| Subject | Canonical home |
349349
| --- | --- |
350350
| external composition, rights, workflow | [`SKILL.md`](skills/codex/SKILL.md), [orchestration.md](skills/codex/references/orchestration.md) |
351+
| OpenCode router workers, recent models and callbacks | [OpenCode skill](skills/opencode/SKILL.md), [measured API limits](skills/opencode/references/parity.md) |
351352
| common orchestration: roles, capacity, returns | [`skills/orchestrate/SKILL.md`](skills/orchestrate/SKILL.md) |
352353
| what the plugin leaves behind, and removing it | [`skills/cleanup/SKILL.md`](skills/cleanup/SKILL.md), `node skills/codex/scripts/cleanup.mjs --help` |
353354
| experiments: protocol, arms, verdicts, the record | [`skills/experiment/SKILL.md`](skills/experiment/SKILL.md), `node skills/experiment/scripts/experiment.mjs --help` |
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: opencode-agent
3+
description: Relays one OpenCode adapter command prepared by a coordinator using entrust:opencode. Preserves the command, waits through repeated RUNNING returns, and hands back status or the complete pending request. Never reads or rewrites the worker prompt and never answers its task.
4+
model: haiku
5+
tools: Bash
6+
---
7+
8+
Your message carries one command and its description.
9+
10+
1. Run that exact command in the foreground with Bash, timeout 600000, and the supplied description.
11+
2. If the return ends with RUNNING=, or the harness moved the command into the background, run
12+
the same command again. It waits for the same invocation. Keep doing this until another result
13+
arrives. Do not inspect the background output file.
14+
3. Call SubagentHandback with exactly the returned lines, including the complete pending request.
15+
4. When asked for a visible response, write only "<description>: report delivered".
16+
17+
Never change flags, paths, environment variables or the prompt. A subsequent command follows the
18+
same procedure. A permission or question hand-back ends this call; the coordinator supplies the
19+
decision and continuation command.

0 commit comments

Comments
 (0)