mirror of
https://github.com/stablyai/orca.git
synced 2026-09-24 00:02:24 +00:00
* feat(terminal): report execution host and listing scope in terminal list `orca terminal list` returned rows with no host identity and no statement of what the listing covered, so a scoped listing that saw nothing read as "nothing exists anywhere" — an agent reported a live remote worker dead. Each row now carries an optional `executionHostId` derived from the PTY id (SSH and paired-runtime ids embed their owner), and the result carries an optional `hostScope` naming the hosts covered and the known hosts skipped. Both are surfaced in `--json` and in the human-readable CLI output, where an absent field renders as `unknown` rather than `local`. Both row builders route through one resolver, so the rule lives in one place. * fix(terminal): preserve unverifiable host scope * fix(terminal): fail closed on unverifiable hosts * test(terminal): name unverifiable scope explicitly * perf(terminal): keep graph hydration host scans narrow * fix(terminal): reject blank foreign host owners * fix(terminal): validate inferred inventory hosts * fix(terminal): preserve paired folder host scope * fix(terminal): keep inventory host inference typed * fix(terminal): disclose paired folder hosts
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
// Why: shared so main can name the paired runtime a mirrored PTY belongs to;
|
|
// the encoding lives here rather than in the renderer transport that mints it.
|
|
const REMOTE_PTY_ID_PREFIX = 'remote:'
|
|
const REMOTE_PTY_OWNER_SEPARATOR = '@@'
|
|
|
|
export type RemoteRuntimePtyIdParts = {
|
|
environmentId: string | null
|
|
handle: string
|
|
}
|
|
|
|
export function toRemoteRuntimePtyId(handle: string, environmentId?: string | null): string {
|
|
const owner = environmentId?.trim()
|
|
if (!owner) {
|
|
return `${REMOTE_PTY_ID_PREFIX}${handle}`
|
|
}
|
|
return `${REMOTE_PTY_ID_PREFIX}${encodeURIComponent(owner)}${REMOTE_PTY_OWNER_SEPARATOR}${encodeURIComponent(handle)}`
|
|
}
|
|
|
|
export function parseRemoteRuntimePtyId(ptyId: string): RemoteRuntimePtyIdParts | null {
|
|
if (!ptyId.startsWith(REMOTE_PTY_ID_PREFIX)) {
|
|
return null
|
|
}
|
|
const rest = ptyId.slice(REMOTE_PTY_ID_PREFIX.length)
|
|
const separatorIndex = rest.indexOf(REMOTE_PTY_OWNER_SEPARATOR)
|
|
if (separatorIndex === -1) {
|
|
return { environmentId: null, handle: rest }
|
|
}
|
|
try {
|
|
return {
|
|
environmentId: decodeURIComponent(rest.slice(0, separatorIndex)),
|
|
handle: decodeURIComponent(rest.slice(separatorIndex + REMOTE_PTY_OWNER_SEPARATOR.length))
|
|
}
|
|
} catch {
|
|
return null
|
|
}
|
|
}
|