Skip to content

Machines: provider protocol, argv runner, and argv on plugin consent - #30670

Open
nwparker wants to merge 8 commits into
mainfrom
nwparker/machines-p0-1-protocol
Open

nwparker wants to merge 8 commits into
mainfrom
nwparker/machines-p0-1-protocol

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​768 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​766
Prod 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​855 $\color{#cf222e}{\Huge{\mathbf{−}}}$​65 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​790

ELI5

A "machine" is a computer that a plugin can create, put to sleep, wake up and delete for you, such as a container on a home server. This PR teaches Orca how to talk to those plugins: what Orca sends them, what it accepts back, and how it runs them safely. The only thing a user can see yet is the plugin consent dialog. It now shows the exact command a machine plugin will run.

What Changed

Before: a plugin could contribute only per-workspace VM recipes. Those are shell command strings that Orca runs through a shell. Nothing described a long-lived machine, and nothing let a plugin list machines, wake them or report their state.

After:

  • Plugin declaration. A plugin can declare a machine provider through its existing contributes.vmRecipes entry, using an artifact with schemaVersion: 2. The artifact names { id, name, machines: { command: [...] } }, an argument list that is never run through a shell.
  • Consent dialog. The dialog shows that argument list verbatim, each word quoted, with the note "Orca appends <verb> --json [--id <machine>]".
  • Older paired clients. Older clients that only understand the old command list get the same quoted text as a "Create" command, so nobody approves a command they cannot see.

Mechanism:

  • Runner and request (machine-provider-command.ts, machine-provider-process.ts):
    • Orca runs [...command, verb, '--json', '--id', machineId] through @orca/process-host with no shell. The working directory is never a repository.
    • $orca-node runs Orca's own executable as Node, so providers never depend on a node on PATH.
    • $plugin/<path> resolves inside the plugin folder, and symlink escapes are refused.
    • Everything except the verb and the id goes as one JSON request on stdin.
  • Machine ids. The id must match ^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$ before anything is spawned. The reason is that ssh joins its arguments into a remote shell line. We confirmed live that an id like x;touch /tmp/pwn runs on the remote host if it is not checked.
  • Responses (machine-provider-protocol.ts): responses are validated with zod.
    • SSH fields may not start with - and may not contain whitespace. The project root must be absolute. There is no proxyCommand.
    • Access details are only allowed while a machine is running.
    • Ids must be unique and the operationId must be echoed back.
    • Verbs, lifetimes and error codes this build does not know are ignored rather than rejected, so newer providers keep working.
  • Account context. When a provider declares an account (contextId), every answer must come from that account, except "sign in needed" and "unavailable" errors. A not-found from a different account is treated as a mismatch, never as "the machine is gone".
  • Host keys. Providers may report host key fingerprints and full host public keys (hostKeys), which the next PR uses to pin the machine's SSH identity.
  • Failures:
    • A rejected ssh login is reported as "sign in needed" at once instead of waiting out a timeout. Hidden ssh prompts are disabled with SSH_ASKPASS_REQUIRE=never and DISPLAY unset.
    • Output is capped at 512 KiB.
    • Each verb has its own timeout (reads 20 s, lifecycle verbs 180 s, create 15 min).
    • Actions that change a machine are never retried automatically.

Why

  • An argument list instead of a shell string. A machine id is the only value that changes between calls, so it can be validated strictly. Everything else travels as JSON, so nothing user-supplied is ever parsed by a shell.
  • A new artifact version instead of a new manifest key. The manifest's contributes block is strict. A new key there would make older Orca builds reject the whole plugin, while a new artifact schemaVersion makes them refuse just that artifact.
  • A separate artifact kind instead of making create optional on the old recipe type. Making it optional would have touched the existing recipe runner, the composer and the consent preview. With a separate kind, the legacy shell-recipe path is unchanged.

Linked Issue

Fixes #

Visual Proof

The only visible change is in the plugin consent dialog. A machine-provider plugin now gets its own "Machine provider command" section, with a "Machine provider · Orca appends --json [--id ]" label above a code block, for example "ssh" "-o" "BatchMode=yes" "omarchy" "orca-sandbox". Before this PR, a schemaVersion 2 artifact was rejected and the plugin failed to load.

  • Before: the plugin fails to load (its schemaVersion 2 artifact is rejected), so no consent dialog opens.
  • After: the consent dialog shows the exact command Orca will run:

machines-consent-after.png

Testing

  • machine-provider-protocol.test.ts rejects:

    • a -host, whitespace in a user, or control characters in a jump host;
    • a relative project root, a proxyCommand, or access while sleeping;
    • an unknown lifetime, duplicate ids, oversize inventories or deep JSON;
    • a missing operationId echo, a wrong machine, or the wrong response kind;
    • an account mismatch, including a not-found from another account.
  • machine-provider-process.test.ts spawns a fake provider through $orca-node and covers:

    • stdin request shape;
    • the live-proven x;touch /tmp/pwn id never spawning;
    • immediate auth-required classification;
    • timeouts (reads report unavailable, actions report unknown outcome);
    • cancellation, the output cap, and $plugin/ symlink escape.
  • Artifact, registry, list-projection and consent-dialog tests cover v2 parsing, the argv preview, and the older-client command copy.

  • Live check against a real provider on a home server (ssh omarchy orca-sandbox …), run through this runner:

    • capabilities, list, create (repeated create returns the same machine), sleep, get, wake and delete;
    • a wrong-account request;
    • an injected id refused before spawn.
  • Platforms: macOS, with a Linux provider host over SSH. Windows .cmd launch goes through @orca/process-host's existing handling.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: no shell, strict ids, a userData working directory, bounded output, and account context that fails closed.
  • Backwards compatibility: older Orca builds refuse v2 artifacts cleanly, and older paired clients still see the command on consent.
  • Feature flag: all of this sits behind experimentalEphemeralVms; nothing runs a provider yet.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@nwparker
nwparker force-pushed the nwparker/machines-p0-1-protocol branch 2 times, most recently from 60a5765 to 7713801 Compare October 19, 2026 10:45
This was referenced Oct 20, 2026
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a4209b53-4a56-4a7c-8a69-79293fd08e28
📥 Commits

Reviewing files that changed from the base of the PR and between 619711e and 4ec6213.

📒 Files selected for processing: 6
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes: 6
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

The changes add versioned machine-provider artifacts, shared command and protocol validation, and a process interface for provider requests. The plugin registry tracks providers separately from lifecycle recipes and includes them in plugin projections. Consent previews display provider commands with localized labels. Tests cover artifact parsing, protocol responses, process execution, registry behavior, and command display.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 4ec62

The provider preview translations do not reveal a new blocker, but the open cancellation and Windows test concerns warrant owner follow-up before merge.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the implementation, motivation, testing, security, compatibility, and UI change in detail. However, the required Linked Issue section is incomplete because it contains only `F… Replace Fixes # with a valid linked issue reference. Complete the AI Disclosure section if the contributor is external to the organization.
Docstring Coverage Warning Docstring coverage is 19.44% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 36 functions across 16 files. (6 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main changes: machine-provider protocol support, the argv runner, and consent command previews.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the implementation, motivation, testing, security, compatibility, and UI change in detail. However, the required Linked Issue section is incomplete because it contains only Fixes #.

Resolution

Replace Fixes # with a valid linked issue reference. Complete the AI Disclosure section if the contributor is external to the organization.

Full details: Docstring Coverage

Explanation

Docstring coverage is 19.44% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 36 functions across 16 files. (6 skipped: 6 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a422d799-a233-4b0b-b3c9-9effafe6586a
📥 Commits

Reviewing files that changed from the base of the PR and between 218b9a7 and 7713801.

📒 Files selected for processing: 22
  • src/main/machines/__fixtures__/fake-machine-provider.mjs
  • src/main/machines/machine-provider-process.test.ts
  • src/main/machines/machine-provider-process.ts
  • src/main/plugins/plugin-artifact-validation.ts
  • src/main/plugins/plugin-list-projection.test.ts
  • src/main/plugins/plugin-list-projection.ts
  • src/main/plugins/plugin-vm-recipe-registry.test.ts
  • src/main/plugins/plugin-vm-recipe-registry.ts
  • src/preload/api/plugin-host-api.ts
  • src/renderer/src/components/settings/PluginConsentDialog.test.tsx
  • src/renderer/src/components/settings/PluginVmRecipeConsentPreview.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/machine-provider-command.ts
  • src/shared/machine-provider-protocol.test.ts
  • src/shared/machine-provider-protocol.ts
  • src/shared/plugins/plugin-vm-recipe-artifact.test.ts
  • src/shared/plugins/plugin-vm-recipe-artifact.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

Comment on lines +118 to +123
case 'delete':
if (!machine) {
return notFound()
}
state.machines = state.machines.filter((entry) => entry !== machine)
return respond(state, { kind: 'error', code: 'not-found', message: 'deleted' }, 4)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
rg -nP -C4 "verb:\s*'delete'|'delete'" src/main/machines --type=ts

Repository: stablyai/orca

Length of output: 151


🏁 Script executed:

set -u
printf '%s\n' '--- fixture delete and surrounding declarations ---'
nl -ba src/main/machines/__fixtures__/fake-machine-provider.mjs | sed -n '1,180p'
printf '%s\n' '--- machine files ---'
rg --files src/main/machines
printf '%s\n' '--- delete and protocol references ---'
rg -n -F --glob '*.{ts,tsx,mjs,js}' -e 'EXPECTED_KIND' -e 'isConfirmedMachineTransition' -e 'runMachineProviderVerb' -e "'delete'" -e '"delete"' src/main/machines src/main | sed -n '1,260p'

Repository: stablyai/orca

Length of output: 25153


🏁 Script executed:

set -u
printf '%s\n' '--- process runner ---'
nl -ba src/main/machines/machine-provider-process.ts | sed -n '1,280p'
printf '%s\n' '--- process tests ---'
nl -ba src/main/machines/machine-provider-process.test.ts | sed -n '1,230p'
printf '%s\n' '--- repository-wide cited symbols and consumers ---'
rg -n -F --glob '*.{ts,tsx,mjs,js}' \
  -e 'EXPECTED_KIND' \
  -e 'isConfirmedMachineTransition' \
  -e 'runMachineProviderVerb' \
  -e 'machineProvider' \
  -e 'machine-provider' \
  src | sed -n '1,360p'

Repository: stablyai/orca

Length of output: 27082


🏁 Script executed:

set -u
printf '%s\n' '--- protocol response contract ---'
nl -ba src/shared/machine-provider-protocol.ts | sed -n '190,330p'
printf '%s\n' '--- transition contract tests ---'
nl -ba src/shared/machine-provider-protocol.test.ts | sed -n '205,240p'

Repository: stablyai/orca

Length of output: 6414


Return a machine response for an existing delete.

When a machine exists, the fixture removes it and then returns an error response. The runner surfaces that response as MachineProviderError, so the delete cannot complete as a successful transition. EXPECTED_KIND.delete requires a machine response, and unknown is an accepted delete state.

🐛 Suggested fix
       if (!machine) {
         return notFound()
       }
+      const deleted = { ...machine, state: 'unknown' }
       state.machines = state.machines.filter((entry) => entry !== machine)
-      return respond(state, { kind: 'error', code: 'not-found', message: 'deleted' }, 4)
+      return respond(state, { kind: 'machine', machine: view(deleted) })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case 'delete':
if (!machine) {
return notFound()
}
state.machines = state.machines.filter((entry) => entry !== machine)
return respond(state, { kind: 'error', code: 'not-found', message: 'deleted' }, 4)
case 'delete':
if (!machine) {
return notFound()
}
const deleted = { ...machine, state: 'unknown' }
state.machines = state.machines.filter((entry) => entry !== machine)
return respond(state, { kind: 'machine', machine: view(deleted) })

Comment on lines +236 to +247
it('refuses a $plugin path that escapes the plugin root through a symlink', async () => {
const root = await tempDir()
const outside = await tempDir()
await writeFile(join(outside, 'evil.sh'), '')
await symlink(join(outside, 'evil.sh'), join(root, 'provider.sh'))
await expect(
resolveMachineProviderInvocation(root, ['$plugin/provider.sh', 'list', '--json'], {
execPath: '/x',
env: {}
})
).rejects.toThrow('outside the plugin directory')
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add a Windows skip guard to the symlink test.

This test calls symlink. Ordinary Windows CI runners often do not have the privilege to create symlinks, so the test fails there for an environment reason. Add a skip guard.

💚 Proposed fix
--- "a/src/main/machines/machine-provider-process.test.ts"
+++ "b/src/main/machines/machine-provider-process.test.ts"
@@ -233,7 +233,9 @@
     expect(invocation.program).toMatch(/provider\.cmd$/)
   })
 
-  it('refuses a $plugin path that escapes the plugin root through a symlink', async () => {
+  it.skipIf(process.platform === 'win32')(
+    'refuses a $plugin path that escapes the plugin root through a symlink',
+    async () => {
     const root = await tempDir()
     const outside = await tempDir()
     await writeFile(join(outside, 'evil.sh'), '')

Based on learnings: "any test that creates filesystem symlinks … should be guarded with it.skipIf(process.platform === 'win32')".

Source: Learnings

Comment on lines +123 to +131
} catch (error) {
throw new MachineProviderError(
'unavailable',
`Could not start ${args.source.command[0]}: ${error instanceof Error ? error.message : String(error)}`
)
}
if (args.signal?.aborted) {
throw new MachineProviderError('cancelled', `${args.verb} was cancelled.`)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Classify a start failure caused by an already-aborted signal as cancelled.

The code checks args.signal?.aborted only after runProcess resolves. Assume that runProcess rejects because the signal is already aborted, or aborts during spawn. The catch block then throws unavailable with "Could not start …". The cancelled code is never set in that case.

Callers that treat unavailable as "provider unreachable" then report the wrong state for a user cancellation. Check the signal inside the catch block as well.

🐛 Proposed fix
--- "a/src/main/machines/machine-provider-process.ts"
+++ "b/src/main/machines/machine-provider-process.ts"
@@ -120,9 +120,12 @@
       killOnOutputLimit: true,
       signal: args.signal
     })
   } catch (error) {
+    if (args.signal?.aborted) {
+      throw new MachineProviderError('cancelled', `${args.verb} was cancelled.`)
+    }
     throw new MachineProviderError(
       'unavailable',
       `Could not start ${args.source.command[0]}: ${error instanceof Error ? error.message : String(error)}`
     )
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch (error) {
throw new MachineProviderError(
'unavailable',
`Could not start ${args.source.command[0]}: ${error instanceof Error ? error.message : String(error)}`
)
}
if (args.signal?.aborted) {
throw new MachineProviderError('cancelled', `${args.verb} was cancelled.`)
}
} catch (error) {
if (args.signal?.aborted) {
throw new MachineProviderError('cancelled', `${args.verb} was cancelled.`)
}
throw new MachineProviderError(
'unavailable',
`Could not start ${args.source.command[0]}: ${error instanceof Error ? error.message : String(error)}`
)
}
if (args.signal?.aborted) {
throw new MachineProviderError('cancelled', `${args.verb} was cancelled.`)
}

@nwparker
nwparker force-pushed the nwparker/machines-p0-1-protocol branch from 7713801 to 619711e Compare October 20, 2026 09:52
@nwparker
nwparker marked this pull request as draft October 20, 2026 20:59
@nwparker
nwparker marked this pull request as ready for review October 20, 2026 20:59

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 Major · Connect approved machine providers to machine-operation… · plugin-vm-recipe-registry.ts:156-158

src/main/plugins/plugin-vm-recipe-registry.ts:156-158
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Connect approved machine providers to machine-operation dispatch.

activeMachineProviders stores approved providers, but no production path consumes it. listMachineProviders and runMachineProviderVerb occur only in declarations and tests. The existing machine-provider process helper is therefore never reached by a machine operation. A provider can appear as approved in the consent UI, but provider-backed machine operations cannot run. Wire the active provider collection into the machine-operation dispatcher and invoke the existing provider runner there.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b420bb15-ba3a-4ea3-88e3-c503a10fb696
📥 Commits

Reviewing files that changed from the base of the PR and between 7713801 and 619711e.

📒 Files selected for processing: 7
  • src/main/plugins/plugin-artifact-validation.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes: 6
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

@nwparker
nwparker force-pushed the nwparker/machines-p0-1-protocol branch 2 times, most recently from 6dd7c77 to 4300831 Compare October 21, 2026 03:55
Machine providers are argv commands (never a shell) that take one JSON
request on stdin and print one JSON response. The runner resolves
$orca-node and contained $plugin/ paths, disables hidden ssh prompts,
classifies auth failures immediately, bounds output and per-verb
timeouts, and never retries a mutation.
A v2 artifact carries a nested machines.command argv instead of shell
lifecycle commands. The registry keeps providers apart from legacy
recipes, and the consent preview shows the argv verbatim.
The projection also publishes the quoted argv as a create command, which
is all an older paired client renders; newer clients show the argv entry
and skip that copy.
A not-found from a provider now signed in as another account would mark
machines gone and drop their SSH targets. Every other answer must echo
the requested contextId or it is a context mismatch.
System OpenSSH can pin a host only from a known_hosts line, so an ssh
access may carry hostKeys ("<type> <base64>") next to its fingerprints.
Optional, so older providers still validate.
…smatch

Providers exit non-zero on errors, and that path fell back to stderr
classification, turning a not-found from another account into a generic
unavailable.
The section header said "VM recipe commands" for machine providers too.
Lifecycle recipes and machine providers now get their own sections, with
the new label translated in every locale.
@nwparker
nwparker force-pushed the nwparker/machines-p0-1-protocol branch from 4300831 to 4ec6213 Compare October 21, 2026 19:00

This branch has not been deployed

No deployments
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.

1 participant