mirror of
https://github.com/stablyai/orca.git
synced 2026-09-21 16:02:20 +00:00
`src/preload/api-types.ts` was 3,752 raw lines (3,533 counted, 11.8x the 300-line budget) behind an `eslint-disable max-lines`. Almost all of it was a single `PreloadApi` object type whose ~83 namespace properties were declared inline, so any IPC surface change meant editing one 2,600-line type. Give each namespace a named type in its own module under `src/preload/api/` (`pty-api.ts`, `filesystem-api.ts`, `github-pull-request-api.ts`, ...) and recompose `PreloadApi` from those names. `api-types.ts` keeps the `declare global` Window augmentation and re-exports every moved name, so all 52 import sites are untouched. Two shapes needed care to stay type-identical rather than merely compatible: - Three keys (`gh`, `git`, `ui`) are composed from two modules each. A plain intersection is NOT identical to the original flat object literal, so those use a `Merged<T>` mapped type; a negative control confirmed that dropping it fails the parity assertion. - Keys whose module groups several namespaces use indexed access (`fs: FilesystemApi['fs']`) to preserve exact identity and source order. `config/tsconfig.web.json` and `tsconfig.tc.web.json` enumerate files by path, so they need `src/preload/api/**/*` alongside the existing `api-types.ts` seed or the web projects fail TS6307. Verified by exact type identity, not assignability: 41 assertions of the form `Equals<Now.X, Before.X>` against a frozen pre-split snapshot, covering every exported name, plus a per-key pass over all 83 `PreloadApi` keys. All three projects typecheck clean with those assertions active. Verification note: these tsconfigs are `composite: true`, and `tsc --noEmit` will reuse a stale `.tsbuildinfo` and report clean for a state that genuinely fails. Every result above was produced after deleting the buildinfo, including a negative control confirming the gate still fails on deliberate drift. Drops the `max-lines` bypass and its baseline entry (ratchet 346 -> 345).
79 lines
3.1 KiB
TypeScript
79 lines
3.1 KiB
TypeScript
import type {
|
|
EnrichedDetectedPort,
|
|
PortForwardEntry,
|
|
SshConfigHostListArgs,
|
|
SshConfigHostListResult,
|
|
SshConfigHostResolution,
|
|
SshConfigImportResult,
|
|
SshConnectionState,
|
|
SshTarget,
|
|
SshTargetAddResult
|
|
} from '../../shared/ssh-types'
|
|
import type { FilesystemPathFlavor } from '../../shared/types'
|
|
|
|
export type SshApi = {
|
|
listTargets: () => Promise<SshTarget[]>
|
|
// Removed-target id → last known label, for a friendly host name on workspaces still pinned to a removed target.
|
|
listRemovedTargetLabels: () => Promise<Record<string, string>>
|
|
addTarget: (args: { target: Omit<SshTarget, 'id'> }) => Promise<SshTargetAddResult>
|
|
updateTarget: (args: {
|
|
id: string
|
|
updates: Partial<Omit<SshTarget, 'id'>>
|
|
}) => Promise<SshTarget>
|
|
removeTarget: (args: { id: string }) => Promise<void>
|
|
importConfig: (args?: { reAdopt?: boolean }) => Promise<SshConfigImportResult>
|
|
listConfigHosts: (args?: SshConfigHostListArgs) => Promise<SshConfigHostListResult>
|
|
resolveConfigHost: (args: { alias: string }) => Promise<SshConfigHostResolution | null>
|
|
connect: (args: { targetId: string }) => Promise<SshConnectionState | null>
|
|
disconnect: (args: { targetId: string }) => Promise<void>
|
|
terminateSessions: (args: { targetId: string }) => Promise<void>
|
|
resetRelay: (args: { targetId: string }) => Promise<void>
|
|
getState: (args: { targetId: string }) => Promise<SshConnectionState | null>
|
|
needsPassphrasePrompt: (args: { targetId: string }) => Promise<boolean>
|
|
testConnection: (args: {
|
|
targetId: string
|
|
}) => Promise<{ success: boolean; error?: string; state?: SshConnectionState }>
|
|
onStateChanged: (
|
|
callback: (data: { targetId: string; state: SshConnectionState }) => void
|
|
) => () => void
|
|
addPortForward: (args: {
|
|
targetId: string
|
|
localPort: number
|
|
remoteHost: string
|
|
remotePort: number
|
|
label?: string
|
|
}) => Promise<PortForwardEntry>
|
|
updatePortForward: (args: {
|
|
id: string
|
|
targetId: string
|
|
localPort: number
|
|
remoteHost: string
|
|
remotePort: number
|
|
label?: string
|
|
}) => Promise<PortForwardEntry>
|
|
removePortForward: (args: { id: string }) => Promise<PortForwardEntry | null>
|
|
listPortForwards: (args?: { targetId?: string }) => Promise<PortForwardEntry[]>
|
|
listDetectedPorts: (args: { targetId: string }) => Promise<EnrichedDetectedPort[]>
|
|
onPortForwardsChanged: (
|
|
callback: (data: { targetId: string; forwards: PortForwardEntry[] }) => void
|
|
) => () => void
|
|
onDetectedPortsChanged: (
|
|
callback: (data: { targetId: string; ports: EnrichedDetectedPort[] }) => void
|
|
) => () => void
|
|
browseDir: (args: { targetId: string; dirPath: string }) => Promise<{
|
|
entries: { name: string; isDirectory: boolean }[]
|
|
resolvedPath: string
|
|
pathFlavor: FilesystemPathFlavor
|
|
}>
|
|
onCredentialRequest: (
|
|
callback: (data: {
|
|
requestId: string
|
|
targetId: string
|
|
kind: 'passphrase' | 'password'
|
|
detail: string
|
|
}) => void
|
|
) => () => void
|
|
onCredentialResolved: (callback: (data: { requestId: string }) => void) => () => void
|
|
submitCredential: (args: { requestId: string; value: string | null }) => Promise<void>
|
|
}
|