mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-03 09:37:19 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Paperclip Runner provides a durable execution boundary for supported providers. > - The current production runtime supports Codex but cannot execute OpenCode sessions. > - OpenCode needs a qualified transport, strict input mapping, and normalized events. > - This pull request adds the OpenCode runtime as one isolated provider unit. > - The benefit is a reviewable provider expansion that does not weaken the existing Codex path. ## Linked Issues or Issue Description **Subsystem affected** Cross-cutting: packages/paperclip-runner and the Codex-local adapter configuration contract. **Problem or motivation** Paperclip Runner has provider-neutral contracts, but the production backend factory cannot start a qualified OpenCode session. This blocks OpenCode from using the durable runner path. **Proposed solution** Add the qualified OpenCode app-server proxy, driver, MCP bridge, backend, fixtures, and factory wiring. Keep existing Codex behavior unchanged. **Alternatives considered** Keeping OpenCode only on the direct adapter path would avoid this runtime work, but it would not provide durable runner recovery or normalized provider events. **Roadmap alignment** ROADMAP.md does not list a conflicting provider-runtime project. This change extends the existing Paperclip Runner architecture. ## What Changed - Added the qualified OpenCode app-server proxy and input queue. - Added collaboration-mode and provider-event normalization. - Added the OpenCode MCP bridge and native session backend. - Added strict fixtures and focused unit coverage. - Added only the package exports and adapter configuration required by this runtime. - Kept deferred SDK, lab, eval, and public package surfaces out of this change. ## Verification - GitHub Actions is the authoritative verification environment for this PR. - Run the package type checks and focused OpenCode tests in CI. - Run repository typecheck, test, build, security, and policy gates through the stack-aware workflow. - Local tests were not run because this checkout is resource constrained. ## Risks - OpenCode protocol changes could affect event normalization or recovery. - The driver fails closed on malformed input and unsupported runtime behavior. - Existing Codex selection remains unchanged unless the stored provider is OpenCode. > For core feature work, check [ROADMAP.md](ROADMAP.md) first and discuss it in #dev before opening the PR. Feature PRs that overlap with planned core work may need to be redirected. ## Model Used OpenAI Codex, GPT-5.6, with repository tools, code execution, and parallel agent review. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either linked existing issues or described the issue in-PR following the relevant issue template - [x] I have not referenced internal or instance-local Paperclip issues or links - [x] My branch name describes the change and contains no internal Paperclip ticket id - [ ] I have run tests locally and they pass — GitHub Actions is authoritative for this resource-constrained checkout - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge ## Stack - Position: 1 of 4 - Base: master - Next: additional qualified provider runtimes
33 lines
1.6 KiB
TypeScript
33 lines
1.6 KiB
TypeScript
import { createCodexTaskEnvelope } from "../contracts/codex.js";
|
|
import type { NativeExecutionInput } from "../contracts/native-execution.js";
|
|
import type { NativeSessionBackend } from "../contracts/native-session-backend.js";
|
|
import { OpenCodeServerDriver, type OpenCodeServerDriverOptions } from "../drivers/opencode/opencode-server-driver.js";
|
|
import { HarnessDriverBackend } from "./harness-driver-backend.js";
|
|
import { nativeSystemInstructions, nativeTaskConstraints } from "./runtime-context.js";
|
|
|
|
export function createOpenCodeNativeSessionBackend(
|
|
input: NativeExecutionInput,
|
|
options: Omit<OpenCodeServerDriverOptions, "model" | "taskEnvelope">,
|
|
): NativeSessionBackend {
|
|
if (input.provider.kind !== "opencode" || !input.provider.model) {
|
|
throw new Error("OpenCode native backend requires a persisted OpenCode provider/model selection");
|
|
}
|
|
return new HarnessDriverBackend(new OpenCodeServerDriver({
|
|
...options,
|
|
systemInstructions: nativeSystemInstructions(input),
|
|
runtimeContext: "runtimeContext" in input ? input.runtimeContext : null,
|
|
model: input.provider.model,
|
|
permissionMode: input.provider.permissionMode ?? "allow",
|
|
taskEnvelope: createCodexTaskEnvelope({
|
|
objective: input.completionContract.contract.objective,
|
|
contractRevision: input.completionContract.contract.revision,
|
|
criteria: input.completionContract.contract.criteria,
|
|
constraints: [
|
|
"Work only inside the supplied working directory.",
|
|
...nativeTaskConstraints(input),
|
|
"Return one semantic completion result through paperclip_finish or paperclip_block.",
|
|
],
|
|
}),
|
|
}));
|
|
}
|