mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 16:02:32 +00:00
* chore(dead-code): drop 2k lines of unreachable exports and orphan modules Ran knip across every build entry (main, preload, renderer, popout, web, cli, relay, workers, forked sidecars, config scripts) and removed what no entry graph can reach. - 11 orphan modules nothing imported, plus one test that only covered them - 159 unused exports/types, with their now-dead helpers, imports and tests Each candidate was verified against dynamic references before deletion. 42 knip hits were false positives and are kept: shared modules consumed by the mobile/ workspace, the src/shared/plugins/** public API, vendored shadcn primitives, and relay wire-protocol constants held for compatibility. Adds knip.json + `pnpm audit:dead-code` so this stays measurable. Verified: pnpm typecheck, pnpm lint, and 2081 tests across the 73 affected test files all pass. * chore(dead-code): move knip config under config/ Root-level additions are blocked by the root directory guard. Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { join } from 'node:path'
|
|
|
|
export type RuntimeTransportMetadata =
|
|
| {
|
|
kind: 'unix'
|
|
endpoint: string
|
|
}
|
|
| {
|
|
kind: 'named-pipe'
|
|
endpoint: string
|
|
}
|
|
| {
|
|
kind: 'websocket'
|
|
endpoint: string
|
|
}
|
|
|
|
export type RuntimeMetadata = {
|
|
runtimeId: string
|
|
pid: number
|
|
transports: RuntimeTransportMetadata[]
|
|
authToken: string | null
|
|
startedAt: number
|
|
}
|
|
|
|
// Why: the CLI must handle metadata files written by older Orca versions that
|
|
// used a singular `transport` field. This helper extracts the first transport
|
|
// matching the given kinds from either the new `transports` array or the
|
|
// legacy `transport` field.
|
|
export function findTransport(
|
|
metadata: RuntimeMetadata,
|
|
...kinds: RuntimeTransportMetadata['kind'][]
|
|
): RuntimeTransportMetadata | null {
|
|
const transports = metadata.transports
|
|
if (transports && Array.isArray(transports)) {
|
|
return transports.find((t) => kinds.includes(t.kind)) ?? null
|
|
}
|
|
// Why: backward compatibility with pre-transports-array metadata files.
|
|
const legacy = (metadata as Record<string, unknown>).transport as RuntimeTransportMetadata | null
|
|
if (legacy && kinds.includes(legacy.kind)) {
|
|
return legacy
|
|
}
|
|
return null
|
|
}
|
|
|
|
const PRIMARY_RUNTIME_METADATA_FILE = 'orca-runtime.json'
|
|
|
|
export function getRuntimeMetadataPath(userDataPath: string): string {
|
|
return join(userDataPath, PRIMARY_RUNTIME_METADATA_FILE)
|
|
}
|