mirror of
https://github.com/stablyai/orca.git
synced 2026-11-02 18:17:36 +00:00
fix(cli): check the runtime source before sending (#27206)
* fix(cli): check the runtime source before sending A terminal Orca launches now carries which Orca launched it (ORCA_RUNTIME_SOURCE_ID = the profile's installation id, ORCA_RUNTIME_SOURCE_INCARNATION = the launching runtime id). Before a request is sent, the CLI compares that with the runtime the profile's runtime record names. Same runtime: sent as before. Different runtime: a read-only status.get asks which profile it serves; the same profile (a restart or update) is accepted, anything else is refused before the request reaches it. The vars cross into WSL through WSLENV. The SSH bridge stamps the bridging runtime itself rather than trusting the remote env. The existing orchestration compatibility stamp is untouched. * fix(orcad): drop an inherited runtime source at startup * fix(cli): an explicit switch to another profile is not fenced The stamp also carries the launching runtime's userData path. A CLI that dials a different profile than the one that launched its terminal, and not the platform default an unpinned terminal falls back to, was pointed there on purpose (orca-dev from a packaged Orca's terminal), so the fence does not apply. * refactor(cli): reuse the shared userData path comparison --------- Co-authored-by: m4air <m4air@Mac.localdomain>
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
import { ORCA_AGENT_SESSION_ID_ENV } from '../../shared/agent-session-caller-env'
|
||||
import { ORCA_STRUCTURED_SESSION_ENV } from '../../shared/structured-session-marker'
|
||||
import { ORCA_SSH_BRIDGE_CREDENTIAL_ENV } from '../../shared/ssh-bridge-credential-env'
|
||||
import { stampRuntimeSourceEnv, type RuntimeSourceStamp } from '../../shared/runtime-source-env'
|
||||
import {
|
||||
sshBridgeCredentials,
|
||||
type SshBridgeCallerScope,
|
||||
@@ -75,6 +76,8 @@ export type HostCliPassthroughOptions = {
|
||||
entryExists?: (path: string) => boolean
|
||||
killTimeoutMs?: number
|
||||
credentials?: SshBridgeCredentialRegistry
|
||||
/** The runtime this bridge belongs to; the host CLI must reach exactly that one. */
|
||||
runtimeSource?: RuntimeSourceStamp | null
|
||||
}
|
||||
|
||||
/** Thrown when the host CLI entry cannot be launched at all; callers fall back
|
||||
@@ -115,6 +118,7 @@ export function buildHostCliEnv(args: {
|
||||
bridgeCredential: string
|
||||
runtimeAuthority?: SshCliRuntimeAuthority
|
||||
artifactInput?: RemoteArtifactInput
|
||||
runtimeSource?: RuntimeSourceStamp | null
|
||||
}): NodeJS.ProcessEnv {
|
||||
const env: NodeJS.ProcessEnv = { ...args.hostEnv }
|
||||
for (const key of REMOTE_CONTEXT_ENV_VARS) {
|
||||
@@ -152,6 +156,12 @@ export function buildHostCliEnv(args: {
|
||||
delete env.ORCA_REMOTE_PAIRING
|
||||
delete env.ORCA_ENVIRONMENT
|
||||
env[ORCA_SSH_BRIDGE_CREDENTIAL_ENV] = args.bridgeCredential
|
||||
// Why: stamped from this process, never from the remote env, so remote input cannot pick the runtime.
|
||||
// The host CLI dials exactly this profile, so the stamp names the same one.
|
||||
stampRuntimeSourceEnv(
|
||||
env,
|
||||
args.runtimeSource ? { ...args.runtimeSource, profilePath: args.userDataPath } : null
|
||||
)
|
||||
if (args.runtimeAuthority) {
|
||||
env[ORCHESTRATION_COMPATIBILITY_HOST_KIND_ENV] = 'ssh'
|
||||
env[ORCHESTRATION_COMPATIBILITY_HOST_ID_ENV] = args.runtimeAuthority.targetId
|
||||
@@ -219,7 +229,8 @@ export async function runHostOrcaCliPassthrough(
|
||||
remoteCwd: request.cwd,
|
||||
bridgeCredential: credential.token,
|
||||
runtimeAuthority: request.runtimeAuthority,
|
||||
artifactInput: request.artifactInput
|
||||
artifactInput: request.artifactInput,
|
||||
runtimeSource: options.runtimeSource
|
||||
})
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user