export type RnxBackendKind = 'node' | 'browser' export interface CommandWriter { stdout(text: string): void stderr(text: string): void } export interface SemanticInvocation { tool: string input: unknown success: boolean details?: unknown } export interface ImageCommandArtifact { kind: 'image' name: string mediaType: string data: Uint8Array | string runtimeClaim?: unknown } export interface FileCommandArtifact { kind: 'file' path: string mediaType?: string runtimeClaim?: unknown } export interface RuntimeCommandArtifact { kind: 'runtime' runtimeClaim: unknown } export interface UrlCommandArtifact { kind: 'url' url: string label?: string runtimeClaim?: unknown } export type CommandArtifact = | ImageCommandArtifact | FileCommandArtifact | RuntimeCommandArtifact | UrlCommandArtifact export interface CommandExecutionResult { exitCode: number stdout: string stderr: string invocations: SemanticInvocation[] artifacts: CommandArtifact[] } export interface RnxInvocationBase { command: string args: string[] globalFlags: Record } export interface RnxParsedCommandInput { command: string args: string[] globalFlags: Record } export interface RnxPreviewInvocation extends RnxInvocationBase { family: 'preview' command: 'web' | 'ios' | 'android' platform: 'web' | 'ios' | 'android' selection: 'select-or-ensure-existing' } export interface RnxRuntimeInvocation extends RnxInvocationBase { family: 'runtime' } export interface RnxTreeInvocation extends RnxInvocationBase { family: 'tree' } export interface RnxLayoutInvocation extends RnxInvocationBase { family: 'layout' } export interface RnxFindInvocation extends RnxInvocationBase { family: 'find' command: 'find' } export interface RnxWaitInvocation extends RnxInvocationBase { family: 'wait' command: 'wait' } export interface RnxActionInvocation extends RnxInvocationBase { family: 'action' } export interface RnxScreenshotInvocation extends RnxInvocationBase { family: 'screenshot' command: 'screenshot' } export interface RnxLogsInvocation extends RnxInvocationBase { family: 'logs' } export interface RnxNetworkInvocation extends RnxInvocationBase { family: 'network' } export interface RnxStorageInvocation extends RnxInvocationBase { family: 'storage' command: 'storage' } export interface RnxHistoryInvocation extends RnxInvocationBase { family: 'history' command: 'timeline' | 'what-happened' } export interface RnxEvidenceInvocation extends RnxInvocationBase { family: 'evidence' } export type RnxCommandInvocation = | RnxPreviewInvocation | RnxRuntimeInvocation | RnxTreeInvocation | RnxLayoutInvocation | RnxFindInvocation | RnxWaitInvocation | RnxActionInvocation | RnxScreenshotInvocation | RnxLogsInvocation | RnxNetworkInvocation | RnxStorageInvocation | RnxHistoryInvocation | RnxEvidenceInvocation export interface RnxExecutionContext { writer: CommandWriter signal: AbortSignal } export interface RnxBackendExecution { exitCode: number invocations: SemanticInvocation[] artifacts: CommandArtifact[] } export interface RnxCommandBackend { readonly kind: RnxBackendKind execute( invocation: RnxCommandInvocation, context: RnxExecutionContext, ): Promise } export interface RnxBrowserOperations { selectPreview( invocation: RnxPreviewInvocation, context: RnxExecutionContext, ): Promise readRuntime( invocation: RnxRuntimeInvocation, context: RnxExecutionContext, ): Promise inspectTree( invocation: RnxTreeInvocation, context: RnxExecutionContext, ): Promise inspectLayout( invocation: RnxLayoutInvocation, context: RnxExecutionContext, ): Promise find( invocation: RnxFindInvocation, context: RnxExecutionContext, ): Promise wait( invocation: RnxWaitInvocation, context: RnxExecutionContext, ): Promise act( invocation: RnxActionInvocation, context: RnxExecutionContext, ): Promise screenshot( invocation: RnxScreenshotInvocation, context: RnxExecutionContext, ): Promise readLogs( invocation: RnxLogsInvocation, context: RnxExecutionContext, ): Promise readNetwork( invocation: RnxNetworkInvocation, context: RnxExecutionContext, ): Promise accessStorage( invocation: RnxStorageInvocation, context: RnxExecutionContext, ): Promise readHistory( invocation: RnxHistoryInvocation, context: RnxExecutionContext, ): Promise collectEvidence( invocation: RnxEvidenceInvocation, context: RnxExecutionContext, ): Promise } export interface RunRnxCoreOptions { backend: RnxCommandBackend signal?: AbortSignal writer?: CommandWriter }