mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-16 05:17:41 +02:00
## Thinking Path > - Paperclip manages agents that use different model providers and adapters. > - Paperclip must keep agent execution rules clear and predictable. > - The cheap-model profile added a second execution mode across adapters, task recovery, APIs, and the UI. > - That mode increased configuration and recovery complexity. > - This pull request removes the cheap-model profile as a product feature. > - The benefit is one model-selection path for normal work and recovery work. ## Linked Issues or Issue Description **What existing behavior does this improve?** This change simplifies model selection across agent configuration, task execution, recovery, and adapter capabilities. **Current behavior** Paperclip exposes cheap-model profiles in adapter metadata, agent runtime configuration, task overrides, recovery rules, APIs, and the board UI. Recovery work can select a different model profile from the agent's configured model. **Proposed behavior** Paperclip uses the agent's configured model for normal work and recovery work. Status-only recovery stays limited to coordination work. The API rejects legacy model-profile configuration. A migration removes stored model-profile values from existing agent, issue, and historical revision records. **Reason and benefit** One model path reduces configuration, API, UI, and recovery complexity. It also prevents status recovery from becoming a separate product-level model-routing feature. **Breaking changes** This change removes model-profile fields and adapter capability metadata. Existing stored model-profile values are removed by an idempotent migration. The validators reject new legacy profile values with clear errors. ## What Changed - Removed model-profile types, adapter capabilities, API fields, and model selection logic. - Removed cheap-model controls from agent and task UI surfaces. - Kept status-only recovery limited to coordination context while normal continuations use the configured agent model. - Added an idempotent migration that removes stored model-profile values from agents, issues, and configuration revisions without changing issue update timestamps. - Updated tests and product documentation for the single-model behavior. ## Verification - `pnpm check:token-gates` passes. - `pnpm -r typecheck` passes. - `pnpm build` passes. - `pnpm test:run` completed with 5,607 passing tests and 8 environment-sensitive failures in unrelated fixed-port and database-deadlock suites. The same failures repeated in an isolated rerun. CI is the final clean-room result. ## Risks - This is an intentional breaking change for clients that send model-profile fields. - The migration changes legacy agent, issue, and configuration-revision JSON. It is idempotent and preserves unrelated fields and issue update timestamps. - The change is cross-cutting because the removed feature existed in adapters, shared contracts, the server, plugins, and the UI. > 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 — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - OpenAI Codex with `gpt-5`. Reasoning and tool use were enabled. The runtime did not expose the context-window size. ## 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 (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [ ] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [ ] I have run tests locally and they pass - [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 - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
106 lines
5.7 KiB
TypeScript
106 lines
5.7 KiB
TypeScript
export const type = "opencode_local";
|
|
export const label = "OpenCode";
|
|
|
|
// Use OpenCode's official installer instead of `npm install -g opencode-ai`.
|
|
// The npm package reifies four large Linux x64 prebuilt-binary subpackages
|
|
// (linux-x64, linux-x64-musl, linux-x64-baseline, linux-x64-baseline-musl) in
|
|
// parallel even though only one matches the sandbox; on bandwidth-constrained
|
|
// sandboxes (e.g. Cloudflare) that exceeded the 240s install budget. The
|
|
// official installer fetches a single arch-specific binary into
|
|
// `$HOME/.opencode/bin` and tries to add it to PATH via `~/.bashrc`. That
|
|
// rc-file path is only sourced by interactive/login shells, so non-login
|
|
// `sh -c` probe invocations (used by the runtime PATH check) cannot find the
|
|
// binary. We fix that by symlinking the installed binary into a directory on
|
|
// the non-login `sh -c` PATH: prefer `/usr/local/bin` (universally on the
|
|
// default PATH on Linux distros) when root or passwordless sudo is available,
|
|
// otherwise fall back to `$HOME/.local/bin` (which is on the default PATH on
|
|
// the exe.dev sandbox image and most modern home-managed Linux images).
|
|
//
|
|
// Security tradeoff: this is `curl | bash` without a SHA-256 verification of
|
|
// the install script. We accept this because:
|
|
// 1. The install runs inside an isolated, ephemeral sandbox — blast radius
|
|
// is bounded to that sandbox's secrets and disk.
|
|
// 2. The prior `npm install -g opencode-ai` is also unverified code
|
|
// execution from a third-party registry; this is not strictly worse.
|
|
// 3. OpenCode does not publish per-release SHA-256 checksums in a stable
|
|
// location, and pinning a version + hash here would require manual
|
|
// version bumps on every OpenCode release.
|
|
// The `set -e` (implied by Bash's default with `-fsSL` upstream of a piped
|
|
// shell) and `curl -fsSL` give us fail-fast behavior on HTTP errors. If
|
|
// OpenCode starts publishing a stable checksum/signature, switch to fetching
|
|
// a versioned tarball + verifying the digest before exec.
|
|
export const SANDBOX_INSTALL_COMMAND =
|
|
'curl -fsSL https://opencode.ai/install | bash && ' +
|
|
'if [ -x "$HOME/.opencode/bin/opencode" ]; then ' +
|
|
'if [ "$(id -u)" -eq 0 ]; then ' +
|
|
'ln -sf "$HOME/.opencode/bin/opencode" /usr/local/bin/opencode; ' +
|
|
'elif command -v sudo >/dev/null 2>&1 && sudo -n true >/dev/null 2>&1; then ' +
|
|
'sudo ln -sf "$HOME/.opencode/bin/opencode" /usr/local/bin/opencode; ' +
|
|
'else ' +
|
|
'mkdir -p "$HOME/.local/bin" && ' +
|
|
'ln -sf "$HOME/.opencode/bin/opencode" "$HOME/.local/bin/opencode"; ' +
|
|
'fi; ' +
|
|
'fi';
|
|
|
|
export const DEFAULT_OPENCODE_LOCAL_MODEL = "openai/gpt-5.2-codex";
|
|
|
|
export function isValidOpenCodeModelId(value: unknown): value is string {
|
|
if (typeof value !== "string") return false;
|
|
const trimmed = value.trim();
|
|
const slashIndex = trimmed.indexOf("/");
|
|
return Boolean(trimmed) && slashIndex > 0 && slashIndex !== trimmed.length - 1;
|
|
}
|
|
|
|
export const models: Array<{ id: string; label: string }> = [
|
|
{ id: DEFAULT_OPENCODE_LOCAL_MODEL, label: DEFAULT_OPENCODE_LOCAL_MODEL },
|
|
{ id: "openai/gpt-5.5", label: "openai/gpt-5.5" },
|
|
{ id: "openai/gpt-5.4", label: "openai/gpt-5.4" },
|
|
{ id: "openai/gpt-5.4-mini", label: "openai/gpt-5.4-mini" },
|
|
{ id: "openai/gpt-5.2", label: "openai/gpt-5.2" },
|
|
{ id: "openai/gpt-5.1-codex-max", label: "openai/gpt-5.1-codex-max" },
|
|
{ id: "openai/gpt-5.1-codex-mini", label: "openai/gpt-5.1-codex-mini" },
|
|
];
|
|
|
|
export const agentConfigurationDoc = `# opencode_local agent configuration
|
|
|
|
Adapter: opencode_local
|
|
|
|
Use when:
|
|
- You want Paperclip to run OpenCode locally as the agent runtime
|
|
- You want provider/model routing in OpenCode format (provider/model)
|
|
- You want OpenCode session resume across heartbeats via --session
|
|
|
|
Don't use when:
|
|
- You need webhook-style external invocation (use openclaw_gateway or http)
|
|
- You only need one-shot shell commands (use process)
|
|
- OpenCode CLI is not installed on the machine
|
|
|
|
Core fields:
|
|
- cwd (string, optional): default absolute working directory fallback for the agent process (created if missing when possible)
|
|
- instructionsFilePath (string, optional): absolute path to a markdown instructions file prepended to the run prompt
|
|
- model (string, required): OpenCode model id in provider/model format (for example anthropic/claude-sonnet-4-5)
|
|
- variant (string, optional): provider-specific reasoning/profile variant passed as --variant (for example minimal|low|medium|high|xhigh|max)
|
|
- dangerouslySkipPermissions (boolean, optional): inject a runtime OpenCode config that allows \`external_directory\` access without interactive prompts; defaults to true for unattended Paperclip runs
|
|
- promptTemplate (string, optional): run prompt template
|
|
- command (string, optional): defaults to "opencode"
|
|
- extraArgs (string[], optional): additional CLI args
|
|
- env (object, optional): KEY=VALUE environment variables
|
|
|
|
Operational fields:
|
|
- timeoutSec (number, optional): run timeout in seconds
|
|
- graceSec (number, optional): SIGTERM grace period in seconds
|
|
|
|
Notes:
|
|
- OpenCode supports multiple providers and models. Use \
|
|
\`opencode models\` to list available options in provider/model format.
|
|
- Paperclip requires an explicit \`model\` value for \`opencode_local\` agents.
|
|
- Runs are executed with: opencode run --format json ...
|
|
- Sessions are resumed with --session when stored session cwd matches current cwd.
|
|
- The adapter sets OPENCODE_DISABLE_PROJECT_CONFIG=true to prevent OpenCode from \
|
|
writing an opencode.json config file into the project working directory. Model \
|
|
selection is passed via the --model CLI flag instead.
|
|
- When \`dangerouslySkipPermissions\` is enabled, Paperclip injects a temporary \
|
|
runtime config with \`permission.external_directory=allow\` so headless runs do \
|
|
not stall on approval prompts.
|
|
`;
|