feat(backends): add prime-agent as a first-class backend - #122
Merged
Conversation
prime/<provider>/<model> drives the pi fork's --mode rpc inside its owned in-process worker (PRIME_AGENT_INTERNAL_LEGACY_OWNED_WORKER_FRONTEND=1), so no shared per-uid daemon ever boots; a per-run --daemon-socket path backstops any future daemon reach. Event parsing is shared with pi.ts — the fork emits the same AgentEvent lineage — so the two backends cannot drift. Fail-closed state isolation: every run gets a bridge-owned HOME + agent dir, keeping the fork's persistent self-modification store (harness/harness_state.json, which rides every future system prompt) from crossing runs. PRIME_PERSISTENT_AGENT_DIR is the explicit shared-state opt-in and cannot be combined with PRIME_MODELS_JSON. Credentials: the operator models.json (PRIME_MODELS_JSON) is materialized into each isolated agent dir — or read from the persistent dir — and only the apiKey env vars it names are forwarded over a neutral allowlist, so ambient provider keys never reach the CLI or its tools. Request images ride the rpc prompt's native images field; profile prompt intents bind to --system-prompt/--append-system-prompt; a profile pinned to another harness or a conflicting model is refused; request-scoped MCP is refused loudly; kernel death and provider failures surface as typed errors, never silent empty completions. agent-interface moves to 0.44.0 for agent_profile.prompt.appendSystemPrompt, which the profile schema otherwise rejects at the wire.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
src/backends/prime.ts(+740): prime-agent as a first-class bridge backend, non-interactive and interactive.--mode rpc, chosen with fork-source evidence. The fork's rpc commands/responses (rpc-types.ts:{type:'prompt', message, images?}/{type:'response', command, success, data|error}) match what the backend speaks; the daemon-free owned-worker path is real, and stdin-EOF safely completes the turn (onInputEndawaits pending handlers +waitForIdle). ACP rejected: the fork's owned-worker classifier doesn't cover acp (daemon-only there) and ACP's update stream collapses the tool/usage detail rpc carries. Per-run--daemon-sockettmp path kept as fail-closed backstop.PRIME_AGENT_CODING_AGENT_DIR;PRIME_PERSISTENT_AGENT_DIRis the explicit opt-in, and its ownmodels.jsonis parsed so named apiKey env vars are forwarded (an env-var NAME read as a literal credential was a gap in the draft — fixed).assertPrimeProfileBindingrefuses a profile pinnedharness:'pi'or a conflicting model (structural comparison so a future'prime'enum id needs no code change).--thinking off…max(one rung above upstream pi; ultracode→max).468e748: the net-jail refusal message suggestedPRIME_EXECUTOR=docker, which is never parsed for prime — executor-less backends now get an actionable remedy (drop fromBRIDGE_BACKENDS) instead of a loop.Proof
tests/prime-backend.test.ts: 27 passed | 1 skipped (the skip is the gated real-binary smoke;prime-agentis not installed on this host — only upstream pi 0.83.0).d1b615e(appendSystemPromptgap from PR feat(backends): honor replace-vs-append prompt intent, or refuse it loudly #120; main CI run 31033023506 is already red with the same errors). Zero errors introduced by this branch (verified by diff-revert and by an independent verifier).git merge-treeclean into main.