Files
orca/src/main/ipc/runtime-environment-status-diagnostics.ts
T
Brennan BensonandMerge Sim 91cc834584 fix(remote): preserve standing host reconnect intent (#17067)
* fix(remote): preserve standing host reconnect intent

* chore(lint): merge duplicate imports flagged by the native code-quality audit

* fix(remote): fence stale capability runtime identities

* fix(remote): release capability evidence on host removal

---------

Co-authored-by: Merge Sim <sim@local>
2026-08-30 21:17:06 -07:00

31 lines
1.1 KiB
TypeScript

import type { RuntimeRpcResponse } from '../../shared/runtime-rpc-envelope'
import { REMOTE_RUNTIME_SHARED_CONTROL_CAPABILITY } from '../../shared/protocol-version'
import { getRemoteRuntimeSharedControlDiagnostics } from './runtime-environment-request-connections'
export function attachRemoteControlDiagnostics<TResult extends object>(
response: RuntimeRpcResponse<TResult>,
environmentId: string
): RuntimeRpcResponse<TResult> {
const remoteControl = getRemoteRuntimeSharedControlDiagnostics(environmentId)
if (!remoteControl) {
return response
}
if (response.ok) {
const capabilities = (response.result as { capabilities?: readonly string[] }).capabilities
if (!capabilities?.includes(REMOTE_RUNTIME_SHARED_CONTROL_CAPABILITY)) {
return response
}
return { ...response, result: { ...(response.result as object), remoteControl } as TResult }
}
return {
...response,
error: {
...response.error,
data:
typeof response.error.data === 'object' && response.error.data !== null
? { ...response.error.data, remoteControl }
: { remoteControl }
}
}
}