Commit Graph

3 Commits

Author SHA1 Message Date
Jannes Stubbemann 6eeb8039e9 fix(opencode-local): browser-safe modelProfiles env access + note on invalid PAPERCLIP_OPENCODE_PROVIDERS
Two fixes on the gateway-routing PR:

- index.ts is shared client/server code (the UI imports it for
  DEFAULT_OPENCODE_LOCAL_MODEL et al.), but buildOpenCodeModelProfiles()
  defaulted its env parameter to a bare `process.env` evaluated at module
  load. Under the e2e lane the UI is served through Vite dev middleware,
  which does not rewrite `process.env`, so the browser threw
  "ReferenceError: process is not defined" at module evaluation and the
  entire app failed to render — breaking every UI e2e spec. Guard with
  `typeof process` and fall back to an empty env.

- parseProviderConfig() silently swallowed JSON.parse failures of
  PAPERCLIP_OPENCODE_PROVIDERS, making a misconfigured value
  undiagnosable. It now appends a note ("contains invalid JSON" /
  "is not a JSON object") so the skipped provider block is visible in the
  run notes. Tests cover both malformed-JSON and non-object values.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 11:41:57 +02:00
Jannes Stubbemann 87e8245ce9 feat(opencode-local): env-driven gateway routing (custom providers, small/cheap model, honour allow-all on remote)
Make opencode-local usable behind an LLM gateway via declarative env, without
hard-coding provider/model assumptions:

- PAPERCLIP_OPENCODE_PROVIDERS: merge custom/extended providers (OpenCode `provider`
  shape) into the runtime opencode.json. OpenCode resolves `--model provider/model`
  only if the model is in a provider's `models` map, and OPENCODE_ALLOW_ALL_MODELS
  does NOT bypass getModel() -- so gateway models must be registered. {env:VAR}
  placeholders are expanded server-side so secrets need not depend on the run env.
- PAPERCLIP_OPENCODE_SMALL_MODEL / PAPERCLIP_OPENCODE_CHEAP_MODEL: pin the auxiliary
  (title-gen) and budget (recovery) lanes to gateway-served models, else they fall
  back to built-in defaults the gateway may not serve ('no keys found that support
  model'). Defaults unchanged.
- Honour OPENCODE_ALLOW_ALL_MODELS on the REMOTE execution path too (was local-only).
- Optional PAPERCLIP_OPENCODE_PRINT_LOGS toggle to surface OpenCode logs on stderr
  for diagnosing remote/sandbox runs.

All env-driven and opt-in; defaults preserve current behaviour. +tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 22:00:54 +02:00
dotta ed62d58cb2 Fix headless OpenCode permission prompts
Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-26 11:12:35 -05:00