Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

This repository is the Proof of Work OpenCode monorepo. It contains three independent public packages:

Current prerelease: **`0.2.0-alpha.0`** for all three packages. The alpha has
been built and exercised against OpenCode **1.18.15**. Keep the npm `alpha`
dist-tag explicit until the APIs graduate from prerelease.

| Package | Purpose | Alpha install |
| --- | --- | --- |
| [`opencode-multimodel`](./packages/opencode-multimodel) | Multi-model fleets, collaboration modes, and declarative workflows for OpenCode. | `bun add opencode-multimodel@alpha` |
| [`codex-delegator`](./packages/codex-delegator) | Reusable Bun library for driving a locally authenticated Codex CLI. | `bun add codex-delegator@alpha` |
| [`opencode-codex-delegate`](./packages/opencode-codex-delegate) | OpenCode plugin and provider backed by `codex-delegator`. | `bun add opencode-codex-delegate@alpha` |
| [`opencode-multimodel`](./packages/opencode-multimodel) | Durable TEAM/WORKFLOW fleets, collaboration modes, dashboards, and workflows for OpenCode. | `bun add opencode-multimodel@alpha` |
| [`codex-delegator`](./packages/codex-delegator) | Reusable Bun library for driving a locally authenticated Codex CLI; this is the shared runtime, not an OpenCode plugin. | `bun add codex-delegator@alpha` |
| [`opencode-codex-delegate`](./packages/opencode-codex-delegate) | OpenCode plugin, tools, and selectable AI SDK provider backed by `codex-delegator`. | `bun add opencode-codex-delegate@alpha` |

All packages are configured to publish on npm under the `alpha` dist-tag. Once released, OpenCode plugin configuration should keep that tag explicit while the APIs are pre-release:

Expand All @@ -20,15 +24,27 @@ All packages are configured to publish on npm under the `alpha` dist-tag. Once r
}
```

OpenCode discovers separate `./server` and `./tui` entrypoints for both plugin
packages. `opencode-codex-delegate` registers `codex-delegate/<model>` selections;
`opencode-multimodel` can use those models as ordinary fleet seats without
creating a second nested worktree.

The Codex packages use the locally installed Codex CLI. Authentication remains owned by that CLI; this repository does not contain, copy, or publish Codex credentials.

## Alpha validation

The `0.2.0-alpha.0` release gate covers unit and integration tests, package
typechecks and builds, npm tarball inspection, SQLite recovery/concurrency,
composer routing, workflow sandbox boundaries, worktree fail-closed behavior,
real Codex app-server delegation, and a combined OpenCode 1.18.15 TEAM run with
child-session and Codex-thread reuse after restart. Live Codex tests remain
opt-in because they consume an authenticated local account.

## Development

```sh
bun install
bun run typecheck
bun run test
bun run build
bun run verify
```

Run `bun run publish:alpha` only after the full verification succeeds and npm authentication is configured. The script publishes `codex-delegator` first so the dependent OpenCode plugin can resolve it.
23 changes: 12 additions & 11 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions packages/codex-delegator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

`codex-delegator` is a reusable Bun library for running bounded tasks through a locally installed and authenticated OpenAI Codex CLI. It prefers one persistent `codex app-server` process per delegate seat and falls back to `codex exec --json` when app-server is unavailable.

Current prerelease: **`0.2.0-alpha.0`**. This is the reusable runtime library,
not an OpenCode plugin; install `opencode-codex-delegate@alpha` when OpenCode
plugin/provider integration is required.

## Install

```sh
Expand Down Expand Up @@ -60,3 +64,8 @@ await delegate.closeAll();
`CodexDelegator` accepts `executable`, `stateDir`, `serviceName`, and `appServerArgv` overrides. `TurnInput.reasoningEffort` maps to app-server's per-turn `effort` override. The remaining constructor hooks are intended for alternate transports and deterministic testing.

Set `CODEX_DELEGATOR_LIVE=1` to enable read-only live tests. Write, review, and scale live tests have separate opt-in flags in `tests/live.test.ts`.

The `0.2.0-alpha.0` gate was exercised with the locally authenticated Codex CLI,
including app-server probe, persistent delegation, restart/resume, native review,
steering, cancellation, concurrency, and multiple seats. These live checks remain
explicit opt-ins for downstream development environments.
2 changes: 1 addition & 1 deletion packages/codex-delegator/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "codex-delegator",
"version": "0.1.0",
"version": "0.2.0-alpha.0",
"description": "A reusable Bun library for delegating work to a local OpenAI Codex CLI",
"type": "module",
"license": "MIT",
Expand Down
13 changes: 13 additions & 0 deletions packages/opencode-codex-delegate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

An OpenCode plugin that registers the locally authenticated OpenAI Codex CLI as a selectable provider and also exposes bounded delegation and native-review tools. It is a host adapter over [`codex-delegator`](../codex-delegator).

Current prerelease: **`0.2.0-alpha.0`**, validated with OpenCode **1.18.15**.
The package retains separate `./server` and `./tui` exports so OpenCode can load
both plugin surfaces through one installation.

## Install

Install the alpha channel by adding the tagged package to `opencode.json`:
Expand Down Expand Up @@ -108,3 +112,12 @@ OpenCode calls the plugin's `dispose` hook on shutdown, and the shared tool/prov
## Provider package entrypoint

The package exports `opencode-codex-delegate/provider` for hosts that want to configure the AI SDK provider manually. Normal OpenCode use should load the plugin: its config hook points OpenCode at the bundled provider entrypoint and supplies lifecycle-managed runtime state automatically.

## Alpha validation

The `0.2.0-alpha.0` release gate covers the server/TUI module shapes, provider
registration and streaming, idempotent retry behavior, approval bridging,
managed-worktree restart/resume, review, steering, cancellation, concurrency,
and a real combined OpenCode TEAM run. Provider-mode Codex owns its worktree;
`opencode-multimodel` intentionally does not wrap it in another OpenCode
workspace.
20 changes: 15 additions & 5 deletions packages/opencode-codex-delegate/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "opencode-codex-delegate",
"version": "0.1.0",
"version": "0.2.0-alpha.0",
"description": "Pluggable OpenCode provider and delegation tools backed by the local OpenAI Codex CLI",
"type": "module",
"license": "MIT",
"sideEffects": false,
"engines": {
"bun": ">=1.3.0"
"bun": ">=1.3.0",
"opencode": ">=1.18.15"
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./server": {
"types": "./dist/server.d.ts",
"import": "./dist/server.js"
},
"./tui": {
"types": "./dist/tui.d.ts",
"import": "./dist/tui.js"
},
"./factory": {
"types": "./dist/plugin.d.ts",
"import": "./dist/plugin.js"
Expand All @@ -34,15 +43,16 @@
},
"scripts": {
"clean": "bun -e 'import { rm } from \"node:fs/promises\"; await rm(\"dist\", { recursive: true, force: true })'",
"build": "bun run clean && bun build src/index.ts src/plugin.ts src/provider.ts --outdir dist --target bun --format esm --packages external --splitting && tsc -p tsconfig.build.json",
"build": "bun run clean && bun build src/index.ts src/server.ts src/tui.ts src/plugin.ts src/provider.ts --outdir dist --target bun --format esm --packages external --splitting && tsc -p tsconfig.build.json",
"test": "bun test",
"typecheck": "tsc --noEmit",
"prepublishOnly": "bun run test && bun run typecheck && bun run build"
},
"dependencies": {
"@ai-sdk/provider": "3.0.8",
"@opencode-ai/plugin": "^1.18.10",
"codex-delegator": "^0.1.0"
"@opencode-ai/plugin": "1.18.15",
"@opencode-ai/sdk": "1.18.15",
"codex-delegator": "^0.2.0-alpha.0"
},
"devDependencies": {
"@tsconfig/bun": "1.0.9",
Expand Down
7 changes: 7 additions & 0 deletions packages/opencode-codex-delegate/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { PluginModule } from "@opencode-ai/plugin";
import { createCodexDelegatePlugin } from "./plugin.ts";

export default {
id: "opencode-codex-delegate",
server: createCodexDelegatePlugin(),
} satisfies PluginModule;
6 changes: 6 additions & 0 deletions packages/opencode-codex-delegate/src/tui.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { TuiPluginModule } from "@opencode-ai/plugin/tui";

export default {
id: "opencode-codex-delegate",
async tui() {},
} satisfies TuiPluginModule;
11 changes: 11 additions & 0 deletions packages/opencode-codex-delegate/tests/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
} from "codex-delegator";
import { createCodexDelegatePlugin } from "../src/plugin.ts";
import { createCodexDelegateProvider } from "../src/provider.ts";
import serverModule from "../src/server.ts";
import tuiModule from "../src/tui.ts";

class FakeDelegate {
readonly creates: CreateInput[] = [];
Expand Down Expand Up @@ -153,6 +155,15 @@ class FakeDelegate {
}

describe("OpenCode Codex delegate plugin", () => {
test("publishes separate OpenCode server and TUI modules", () => {
expect(serverModule.id).toBe("opencode-codex-delegate");
expect(typeof serverModule.server).toBe("function");
expect("tui" in serverModule).toBe(false);
expect(tuiModule.id).toBe("opencode-codex-delegate");
expect(typeof tuiModule.tui).toBe("function");
expect("server" in tuiModule).toBe(false);
});

test("keeps the main entrypoint limited to one deduplicated plugin function", async () => {
const entrypoint = await import("../src/index.ts");
expect(
Expand Down
12 changes: 12 additions & 0 deletions packages/opencode-multimodel/PROVENANCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Confined interpreter provenance

The implementation in `src/script.ts` is an original, purpose-limited
tree-walking interpreter created for this plugin. Its allowed-capability model,
bounded host calls, and data-only interpreter boundary are derived from the
MIT-licensed OpenCode CodeMode design in
`packages/codemode/src/interpreter/runtime.ts` as inspected from the OpenCode
1.18.15 source tree. No source file from CodeMode is copied verbatim.

The interpreter accepts one JavaScript/TypeScript-style expression (optionally
wrapped in an `export default` arrow function) and exposes only `args`,
`agent`, `parallel`, `pipeline`, `phase`, and `log`.
Loading