mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
fix(cloud): remember only a host's 'cloud' answer; ask again after 'not cloud' (re-review LOW)
This commit is contained in:
@@ -213,3 +213,34 @@ describe('withHostAgentApiKeyEnv asks the host', () => {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('host answer cache', () => {
|
||||
it('asks again after a "not cloud" answer, so a re-paired id that is now a cloud VM gets no keys', async () => {
|
||||
const { setCloudDesktopKeysUserDataPath, withHostAgentApiKeyEnv } =
|
||||
await import('./cloud-desktop-keys')
|
||||
setCloudDesktopKeysUserDataPath('/u')
|
||||
environments.set('env-repaired', {
|
||||
source: 'manual',
|
||||
endpoints: [{ endpoint: 'wss://10.0.0.9:6768' }]
|
||||
})
|
||||
launchEnv = { CODEX_API_KEY: 'custom-name-real-key' }
|
||||
const params = { launchAgent: 'codex', command: 'codex', env: {} }
|
||||
const answer = (caps: string[]) => async () => ({
|
||||
ok: true as const,
|
||||
id: 's',
|
||||
result: { capabilities: caps },
|
||||
_meta: { runtimeId: 'r' }
|
||||
})
|
||||
expect(
|
||||
await withHostAgentApiKeyEnv('env-repaired', 'terminal.create', params, answer([]))
|
||||
).not.toBe(params)
|
||||
expect(
|
||||
await withHostAgentApiKeyEnv(
|
||||
'env-repaired',
|
||||
'terminal.create',
|
||||
params,
|
||||
answer(['host.orca-cloud.v1'])
|
||||
)
|
||||
).toBe(params)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -127,7 +127,11 @@ async function hostSaysOrcaCloud(
|
||||
return null
|
||||
}
|
||||
const cloud = capabilities.includes(ORCA_CLOUD_HOST_RUNTIME_CAPABILITY)
|
||||
hostKinds.set(environmentId, { cloud, at: Date.now() })
|
||||
// Only "cloud" is remembered: it can only withhold keys. A "not cloud" answer is asked again on
|
||||
// the next launch, so a re-paired id that now points at a cloud VM is never sent keys from cache.
|
||||
if (cloud) {
|
||||
hostKinds.set(environmentId, { cloud, at: Date.now() })
|
||||
}
|
||||
return cloud
|
||||
} catch {
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user