Repository navigation
Conversation
60a5765 to
7713801
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a422d799-a233-4b0b-b3c9-9effafe6586a
📒 Files selected for processing: 22
src/main/machines/__fixtures__/fake-machine-provider.mjssrc/main/machines/machine-provider-process.test.tssrc/main/machines/machine-provider-process.tssrc/main/plugins/plugin-artifact-validation.tssrc/main/plugins/plugin-list-projection.test.tssrc/main/plugins/plugin-list-projection.tssrc/main/plugins/plugin-vm-recipe-registry.test.tssrc/main/plugins/plugin-vm-recipe-registry.tssrc/preload/api/plugin-host-api.tssrc/renderer/src/components/settings/PluginConsentDialog.test.tsxsrc/renderer/src/components/settings/PluginVmRecipeConsentPreview.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/shared/machine-provider-command.tssrc/shared/machine-provider-protocol.test.tssrc/shared/machine-provider-protocol.tssrc/shared/plugins/plugin-vm-recipe-artifact.test.tssrc/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.
| 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) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C4 "verb:\s*'delete'|'delete'" src/main/machines --type=tsRepository: 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.
| 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) }) |
| 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') | ||
| }) |
There was a problem hiding this comment.
📐 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
| } 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.`) | ||
| } |
There was a problem hiding this comment.
🎯 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.
| } 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.`) | |
| } |
7713801 to
619711e
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 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 liftConnect approved machine providers to machine-operation dispatch.
activeMachineProvidersstores approved providers, but no production path consumes it.listMachineProvidersandrunMachineProviderVerboccur 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
📒 Files selected for processing: 7
src/main/plugins/plugin-artifact-validation.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/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.
6dd7c77 to
4300831
Compare
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.
4300831 to
4ec6213
Compare
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:
contributes.vmRecipesentry, using an artifact withschemaVersion: 2. The artifact names{ id, name, machines: { command: [...] } }, an argument list that is never run through a shell.<verb> --json [--id <machine>]".Mechanism:
machine-provider-command.ts,machine-provider-process.ts):[...command, verb, '--json', '--id', machineId]through@orca/process-hostwith no shell. The working directory is never a repository.$orca-noderuns Orca's own executable as Node, so providers never depend on anodeon PATH.$plugin/<path>resolves inside the plugin folder, and symlink escapes are refused.^[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 likex;touch /tmp/pwnruns on the remote host if it is not checked.machine-provider-protocol.ts): responses are validated with zod.-and may not contain whitespace. The project root must be absolute. There is noproxyCommand.operationIdmust be echoed back.contextId), every answer must come from that account, except "sign in needed" and "unavailable" errors. Anot-foundfrom a different account is treated as a mismatch, never as "the machine is gone".hostKeys), which the next PR uses to pin the machine's SSH identity.SSH_ASKPASS_REQUIRE=neverandDISPLAYunset.Why
contributesblock is strict. A new key there would make older Orca builds reject the whole plugin, while a new artifactschemaVersionmakes them refuse just that artifact.createoptional 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.Testing
machine-provider-protocol.test.tsrejects:-host, whitespace in a user, or control characters in a jump host;proxyCommand, or access while sleeping;operationIdecho, a wrong machine, or the wrong response kind;not-foundfrom another account.machine-provider-process.test.tsspawns a fake provider through$orca-nodeand covers:x;touch /tmp/pwnid never spawning;$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:Platforms: macOS, with a Linux provider host over SSH. Windows
.cmdlaunch 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
Notes
experimentalEphemeralVms; nothing runs a provider yet.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)