mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 00:02:31 +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).
53 lines
2.6 KiB
TypeScript
53 lines
2.6 KiB
TypeScript
import type {
|
|
AgentStatusClearIpcPayload,
|
|
AgentStatusIpcPayload,
|
|
MigrationUnsupportedPtyEntry
|
|
} from '../../shared/agent-status-types'
|
|
import type { AgentInterruptInferenceRequest } from '../../shared/agent-interrupt-intent'
|
|
import type { AgentQuestionAnsweredInferenceRequest } from '../../shared/agent-question-answered-intent'
|
|
import type { ComputerAwakeStatus } from '../../shared/computer-awake-mode'
|
|
|
|
export type AgentStatusApi = {
|
|
/** Listen for agent status updates forwarded from native hook receivers. */
|
|
onSet: (callback: (data: AgentStatusIpcPayload) => void) => () => void
|
|
/** Listen for main-process cleanup that evicted cached hook status. */
|
|
onClear: (callback: (data: AgentStatusClearIpcPayload) => void) => () => void
|
|
/** Return the current main-process hook cache after renderer hydration. */
|
|
getSnapshot: () => Promise<AgentStatusIpcPayload[]>
|
|
inferInterrupt: (request: AgentInterruptInferenceRequest) => Promise<boolean>
|
|
/** Guarded clear for an answered AskUserQuestion wait — the CLI emits no hook at answer time, so the renderer reports the submit keystroke. */
|
|
inferQuestionAnswered: (request: AgentQuestionAnsweredInferenceRequest) => Promise<boolean>
|
|
/** Listen for PTYs on a legacy numeric pane key that have registry-backed UUID pane proof. */
|
|
onMigrationUnsupported: (callback: (entry: MigrationUnsupportedPtyEntry) => void) => () => void
|
|
onMigrationUnsupportedClear: (callback: (data: { ptyId: string }) => void) => () => void
|
|
onLegacyWorkerTerminalRecovery: (
|
|
callback: (data: {
|
|
paneKey: string
|
|
resolution: 'adopted' | 'exited' | 'rolled_back'
|
|
ptyId?: string
|
|
}) => void
|
|
) => () => void
|
|
getMigrationUnsupportedSnapshot: () => Promise<MigrationUnsupportedPtyEntry[]>
|
|
/** Drop a paneKey from the main-process hook cache and on-disk last-status file. Fire-and-forget. */
|
|
drop: (paneKey: string) => void
|
|
/** Drop every cached hook status under one terminal tab prefix. Fire-and-forget. */
|
|
dropByTabPrefix: (tabId: string) => void
|
|
/** Permanently retire one pane's hook authority while siblings stay live. */
|
|
retirePaneAuthority: (paneKey: string) => void
|
|
/** Move hook authority when a live pane is detached into another tab. */
|
|
transferPaneAuthority: (args: { fromPaneKey: string; toPaneKey: string; ptyId?: string }) => void
|
|
}
|
|
|
|
export type AgentTrustApi = {
|
|
markTrusted: (args: {
|
|
preset: 'cursor' | 'copilot' | 'codex'
|
|
workspacePath: string
|
|
connectionId?: string
|
|
}) => Promise<void>
|
|
}
|
|
|
|
export type AgentAwakeApi = {
|
|
getStatus: () => Promise<ComputerAwakeStatus>
|
|
onChanged: (callback: (status: ComputerAwakeStatus) => void) => () => void
|
|
}
|