Skip to content

Run any agent CLI in Solenta as a best-effort custom provider - #1676

Merged
currentbits merged 4 commits into
mainfrom
coder/generic-cli-provider-drop-in-any-agent-b-0a863f
Oct 18, 2026
Merged

currentbits merged 4 commits into
mainfrom
coder/generic-cli-provider-drop-in-any-agent-b-0a863f

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Users can now point Solenta at any agent CLI (Goose, Hermes, Qwen Code, Amp, …) without waiting for a first-class adapter. Settings › Agents › Add instance has a Custom CLI (best effort) option, and the CLI shows up in the model picker, labelled "Best effort: plain text output, no work log, usage or resume". Closes #458.

Changes

  • Define a CLI once, pick it anywhere. Each custom CLI is a row in the existing provider-instance list (Named provider instances: work/personal accounts, isolated config dirs, OpenRouter #453) under ref generic:<id>: name, command, environment, optional full-access flags, working folder, and output mode. It reuses the instance ref plumbing, so defaults, profiles, routing and quota failover accept it, and its env values are sealed at rest like other provider keys.
  • Runs through the existing raw-stdout runner. The command runs with the prompt appended as the last argument, and its output becomes the reply. A custom CLI can't resume a session, so each follow-up turn is sent the recent transcript tail instead of starting blind.
  • Working folder and output mode. A relative working folder resolves inside the thread's worktree. Output can be plain pipes or a pseudo-terminal (PTY), for CLIs that hold output or refuse to run without one. PTY output has colours and spinner redraws stripped before it lands in the reply.
  • Permissions stay least-privilege. Full-access flags are added only after an explicit Full access pick. With no flags set, the permission picker is hidden and the CLI decides. A thread switched in from acceptEdits, auto or plan drops to default instead of picking up --yolo-style flags.
  • Built-in names stay reserved. A custom CLI can't be named after a first-class provider (e.g. "Claude Code", "codex"). A bare generic ref is never runnable.
  • Clear failures. A removed custom CLI, a missing binary, a missing working folder or a remote (ssh/WSL) project each stops the send with a plain message, before any thread state changes.

Verification

  • New electron/test/custom-cli-provider.test.js (8 tests) spawns a real fake binary. It checks argument order, that env doesn't leak into the app's own process, flags only after Full access, transcript replay on turn two, working folder (relative, missing), a real PTY run with escape codes stripped, the failure messages, and no snap-up to full access. I mutation-checked it: removing the flag append, the replay flag or the PTY branch each fails a test.
  • New renderer tests: picker collapse and trigger label (modelPicker.test.ts), plus the Settings form round-trip including a path with a space (settingsModal.test.tsx).
  • npm run typecheck and npx vite build are clean. Composer, modelPicker and settingsModal renderer tests pass.
  • Full npm run test:electron on the branch merged with current main, CI-like env (no inherited CODER_*, node-only PATH): 4907 pass, 0 fail, 3 skipped.
  • Not tested: the PTY path on Windows (that test is skipped on win32), and a real third-party CLI end to end.

Notes for reviewers

  • getProvider("generic") used to return null and now returns a registry entry. I audited every call site: print-mode helpers (ask, commit message) have no args for it, an empty binary reads as not installed, steering is refused, and workflow template phases reject it explicitly.
  • Shared memory (Orchestrator-owned guardrails: protected config, spawn-time hook packs, memory-write scanning #409): a custom CLI gets the same scanned memory note in its prompt as every provider. It's given no MCP config, so it has no way to write to shared memory.
  • Governance (Governance layer: per-agent permission matrix, OS sandbox profiles, audit trail #262) policies on a profile that targets a custom CLI are stored and shown but not enforced. That's the same as every other non-Claude provider, per the v1 spec.
  • Known gaps, left out on purpose:
    • The command line is stored in plain text; only env values are sealed. The form tells users to put keys in Environment.
    • Automations still reject every instance ref, the same as claude:work today.
    • PTY output has no cursor-movement emulation, so a full-screen TUI comes out as its last-drawn lines.
    • On Windows, a PTY command needs the real .exe, not a .cmd shim.

🤖 Generated with Claude Code

Solenta and others added 4 commits October 18, 2026 21:46
Solenta-Message-Id: fe87c414-4351-4340-ad10-06f44860abcf
Settings > Agents > Add instance gains a "Custom CLI (best effort)" base:
name, argv, env, optional full-access flags, working folder, and plain
pipes or a PTY for output. Each row is a providerInstances entry under
the "generic" base (ref generic:<id>), so it reuses instance refs, env
sealing and the picker; runs go through the raw-stdout generic runner
with the prompt appended last and the transcript tail replayed on each
follow-up turn.

Built-in provider names stay reserved, a bare "generic" ref is never
runnable, and an unmapped permission mode snaps down to default so
--yolo-style flags only apply after an explicit Full access pick.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…vider-drop-in-any-agent-b-0a863f

# Conflicts:
#	src/components/settings/AgentsPane.tsx
#	test/settingsModal.test.tsx
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T21:06:17.059768Z cacdc3d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@currentbits
currentbits enabled auto-merge (squash) October 18, 2026 21:02

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cacdc3d848

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +239 to +240
if (!fs.existsSync(cwd)) {
throw new Error(`Custom CLI working folder not found: ${cwd}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate the custom working folder before accepting the turn

When the configured working folder is missing, this check runs only inside startGenericRun, after startRun has already appended the user message, changed the thread to working, and cleared replayContext. The catch then marks the thread failed, so fixing the folder and retrying leaves a duplicate failed prompt in the transcript and, on follow-up turns, starts the stateless CLI without the prior transcript. Move this validation into the pre-mutation custom-CLI gate or restore the consumed replay state on this failure.

Useful? React with 👍 / 👎.

Comment thread electron/runner.js
Comment on lines +575 to +577
const bin = (inst.command || [])[0];
if (!isBinAvailable(bin)) {
throw new Error(`Custom CLI binary not found: ${bin}. Fix the command in Settings › Agents.`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve the binary using its actual spawn environment

For a command supplied as ./agent in the configured working folder, or a bare command found through a PATH supplied in the instance/project Environment, this preflight reports “binary not found” even though the later spawn would resolve it: isBinAvailable uses the Electron process's cwd and process.env, while the child uses the custom cwd and merged environment. Check availability against the resolved working directory and the same merged environment used by runAgent.

Useful? React with 👍 / 👎.

});
}
}
list.push(...generic);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Teach worker-pool availability checks about custom refs

Appending generic:<id> rows makes custom CLIs selectable in the existing worker-pool editor, but the local pool checks pass that full ref to getProvider, which only recognizes the bare generic id. Consequently subagentPoolNoteFor omits the configured alias from the pool menu and nextPoolEntry skips it during failover, even when its binary exists. Parse the ref and resolve the instance command in the pool availability callbacks, as routing now does.

Useful? React with 👍 / 👎.

@currentbits
currentbits merged commit 1ae4a9a into main Oct 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generic CLI provider: drop in any agent binary

1 participant