@ai-matrx/desktop-protocol 0.17.2 → 0.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts","../src/client/client.ts","../src/error.ts","../src/frame.ts","../src/schema/envelope.ts","../src/schema/errors.ts","../src/schema/primitives.ts","../src/close-policy.ts","../src/schema/frame.ts","../src/schema/sysinfo.ts","../src/schema/fs.ts","../src/schema/exec.ts","../src/schema/session.ts","../src/schema/models.ts","../src/schema/relay.ts","../src/schema/clipboard.ts","../src/schema/proc.ts","../src/schema/system.ts","../src/schema/screen.ts","../src/schema/window.ts","../src/schema/input.ts","../src/schema/power.ts","../src/schema/audio.ts","../src/schema/resources.ts","../src/schema/fs-watch.ts","../src/schema/exec-job.ts","../src/schema/coding.ts","../src/schema/apps.ts","../src/schema/registry.ts","../src/client/wake.ts","../src/client/transcribe.ts"],"sourcesContent":["/**\n * `@ai-matrx/desktop-protocol/client` — the reconnecting client every TypeScript surface uses to\n * drive a Matrx 2 device (phone console, web app, extension): typed requests by op name, byte\n * streams with credit backpressure, transparent terminal reattach (since_seq replay / gap +\n * snapshot), events, heartbeat, relay reauth. Reconnect uses `createBackoff` from\n * `@ai-matrx/realtime` — the one backoff ladder on the platform.\n */\nexport { createDesktopClient, RECONNECT_ALARM_ATTEMPTS } from \"./client/client\";\nexport { bindDesktopWake } from \"./client/wake\";\nexport { createDesktopTranscriber, DESKTOP_TRANSCRIBE_MAX_BYTES } from \"./client/transcribe\";\nexport type { DesktopTranscriber, DesktopTranscriberOptions, DesktopTranscript } from \"./client/transcribe\";\nexport type { WakeTargets } from \"./client/wake\";\nexport type {\n ClientTimers,\n DesktopClient,\n DesktopClientDiagnostic,\n DesktopClientOptions,\n DesktopClientState,\n DesktopClientStatus,\n DesktopStream,\n EventHandler,\n EventName,\n EventPayload,\n RequestOptions,\n StreamHandlers,\n StreamOpName,\n StreamOptions,\n WebSocketFactory,\n WebSocketLike,\n WakeOptions,\n} from \"./client/types\";\nexport { DesktopProtocolError, isDesktopProtocolError } from \"./error\";\nexport type { OpName, OpParams, OpResult } from \"./schema/registry\";\n","/**\n * The reconnecting desktop-protocol client: hello → requests, streams with credit-based\n * backpressure, events, transparent reattach of resource streams (terminals, watches) after a\n * drop, heartbeat, and relay reauth. One instance per device connection. All state lives in the\n * closure — no module-level state (dual ESM/CJS graphs would split it).\n */\nimport { RECONNECT_ALARM_ATTEMPTS, createBackoff } from \"@ai-matrx/realtime\";\nimport { DesktopProtocolError } from \"../error\";\nimport { FRAME_VERSION, FrameChannel, decodeFrame, encodeFrame } from \"../frame\";\nimport type { FrameHeader } from \"../frame\";\nimport { closeRule } from \"../close-policy\";\nimport { CloseCode, CoreToClientMsg, PING_TEXT, PONG_TEXT, Welcome } from \"../schema/envelope\";\nimport type { EndReason, StreamMeta } from \"../schema/envelope\";\nimport type { ProtocolErrorBody } from \"../schema/errors\";\nimport { DEFAULT_MAX_FRAME_PAYLOAD_BYTES, DEFAULT_WINDOW_BYTES } from \"../schema/frame\";\nimport { PROTOCOL_MAJOR, PROTOCOL_MINOR } from \"../schema/primitives\";\nimport { EVENTS, OPS } from \"../schema/registry\";\nimport type { OpName, OpParams, OpResult } from \"../schema/registry\";\nimport type {\n ClientTimers,\n DesktopClient,\n DesktopClientDiagnostic,\n DesktopClientOptions,\n DesktopClientState,\n DesktopStream,\n EventHandler,\n EventName,\n RequestOptions,\n StreamHandlers,\n StreamOpName,\n StreamOptions,\n WakeOptions,\n WebSocketFactory,\n WebSocketLike,\n} from \"./types\";\n\nconst WS_OPEN = 1;\ntype Pending = {\n kind: \"unary\";\n op: string;\n resolve: (value: unknown) => void;\n reject: (error: DesktopProtocolError) => void;\n cleanup: () => void;\n};\n\ninterface StreamState {\n op: string;\n handlers: StreamHandlers;\n options: StreamOptions;\n id: string;\n sid: number | null;\n resourceId: string | null;\n /** Last inbound DATA seq delivered to the consumer. */\n lastSeq: number;\n /** Expected next inbound seq, or null right after a gap/snapshot (resync on next frame). */\n expectSeq: number | null;\n windowBytes: number;\n /** Consumed bytes not yet credited back. */\n consumedUncredited: number;\n /** Outbound (STDIN) credit granted by the core. */\n sendWindow: number;\n sendSeq: number;\n sendQueue: Uint8Array[];\n /** Serializes consumer callbacks so credits follow consumption order. */\n chain: Promise<void>;\n resultSettled: boolean;\n resolveResult: (value: unknown) => void;\n rejectResult: (error: DesktopProtocolError) => void;\n resolveDone: (reason: EndReason) => void;\n rejectDone: (error: DesktopProtocolError) => void;\n ended: boolean;\n /** True while a reattach request is in flight for it. */\n reattaching: boolean;\n}\n\nconst defaultTimers: ClientTimers = {\n setTimeout: (fn, ms) => globalThis.setTimeout(fn, ms),\n clearTimeout: (handle) => globalThis.clearTimeout(handle as ReturnType<typeof globalThis.setTimeout>),\n now: () => Date.now(),\n};\n\nfunction defaultWebSocket(): WebSocketFactory {\n return (url, protocols) => {\n const Ctor = (globalThis as { WebSocket?: new (url: string, protocols?: string[]) => WebSocketLike }).WebSocket;\n if (!Ctor) {\n throw new DesktopProtocolError(\"PLATFORM_UNSUPPORTED\", \"No global WebSocket — pass options.webSocket\");\n }\n return new Ctor(url, protocols);\n };\n}\n\nfunction capOf(op: string): { cap: string; op: string } {\n const dot = op.indexOf(\".\");\n return { cap: op.slice(0, dot), op: op.slice(dot + 1) };\n}\n\nfunction fromBody(body: ProtocolErrorBody): DesktopProtocolError {\n return body.data === undefined\n ? new DesktopProtocolError(body.code, body.message, { retryable: body.retryable })\n : new DesktopProtocolError(body.code, body.message, { retryable: body.retryable, data: body.data });\n}\n\nfunction toBytes(data: unknown): Uint8Array | null {\n if (data instanceof ArrayBuffer) return new Uint8Array(data);\n if (ArrayBuffer.isView(data)) return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n return null;\n}\n\nexport function createDesktopClient(options: DesktopClientOptions): DesktopClient {\n const timers = options.timers ?? defaultTimers;\n const makeSocket = options.webSocket ?? defaultWebSocket();\n const heartbeatMs = options.heartbeatMs ?? 25_000;\n const requestTimeoutMs = options.requestTimeoutMs ?? 70_000;\n const protocolVersion = options.protocolVersion ?? `${PROTOCOL_MAJOR}.${PROTOCOL_MINOR}`;\n const backoff = createBackoff({ ...options.backoff, now: timers.now });\n const diagnose =\n options.onDiagnostic ??\n ((d: DesktopClientDiagnostic) => {\n console.warn(\"[desktop-protocol]\", d.kind, d);\n });\n\n let state: DesktopClientState = {\n status: \"idle\",\n welcome: null,\n attempts: 0,\n retryInMs: null,\n lastError: null,\n lastCloseCode: null,\n outcome: null,\n };\n /** Token refusals (4001/4008) since the last welcome; the second in a row is terminal. */\n let authRefusals = 0;\n const listeners = new Set<() => void>();\n const readyWaiters = new Set<{ resolve: (w: Welcome) => void; reject: (e: DesktopProtocolError) => void }>();\n const pending = new Map<string, Pending>();\n const streams = new Map<string, StreamState>(); // by current request id\n const bySid = new Map<number, StreamState>();\n const eventHandlers = new Map<string, Set<EventHandler<EventName>>>();\n let socket: WebSocketLike | null = null;\n let socketGeneration = 0;\n let nextId = 0;\n let helloId: string | null = null;\n let reconnectTimer: unknown = null;\n let heartbeatTimer: unknown = null;\n let probeTimer: unknown = null;\n let lastHeardAt = 0;\n /** Inbound messages on the current socket — the wake probe's \"was anything heard since?\" */\n let heardCount = 0;\n let closedByUser = false;\n\n const newId = (prefix: string) => `${prefix}${(++nextId).toString(36)}`;\n\n function setState(patch: Partial<DesktopClientState>): void {\n state = { ...state, ...patch };\n for (const listener of [...listeners]) {\n try {\n listener();\n } catch (error) {\n diagnose({ kind: \"handler_threw\", where: \"subscribe listener\", error });\n }\n }\n }\n\n function sendJson(message: unknown): boolean {\n if (!socket || socket.readyState !== WS_OPEN) return false;\n socket.send(JSON.stringify(message));\n return true;\n }\n\n // ── connection lifecycle ────────────────────────────────────────────────────\n\n function connect(): void {\n if (state.status === \"connecting\" || state.status === \"handshaking\" || state.status === \"open\") return;\n if (state.status === \"closed\" || state.status === \"idle\") authRefusals = 0; // a deliberate (re)start\n closedByUser = false;\n if (reconnectTimer !== null) {\n timers.clearTimeout(reconnectTimer);\n reconnectTimer = null;\n }\n void openSocket();\n }\n\n async function openSocket(): Promise<void> {\n const generation = ++socketGeneration;\n setState({ status: \"connecting\", retryInMs: null });\n let ws: WebSocketLike;\n try {\n const url = typeof options.url === \"function\" ? await options.url() : options.url;\n const protocols = options.protocols ? await options.protocols() : [];\n if (generation !== socketGeneration || closedByUser) return;\n ws = makeSocket(url, protocols);\n } catch (error) {\n if (generation !== socketGeneration) return;\n const err =\n error instanceof DesktopProtocolError\n ? error\n : new DesktopProtocolError(\"INTERNAL\", \"Could not open the connection\", { retryable: true, cause: error });\n onSocketGone(generation, null, err);\n return;\n }\n socket = ws;\n ws.binaryType = \"arraybuffer\";\n ws.onopen = () => {\n if (generation !== socketGeneration) return;\n lastHeardAt = timers.now();\n helloId = newId(\"h\");\n setState({ status: \"handshaking\" });\n sendJson({ type: \"hello\", id: helloId, protocolVersion, clientType: options.clientType, clientVersion: options.clientVersion });\n scheduleHeartbeat(generation);\n };\n ws.onmessage = (event) => {\n if (generation !== socketGeneration) return;\n lastHeardAt = timers.now();\n heardCount++;\n onMessage(event.data);\n };\n ws.onerror = () => {\n // The close event that always follows carries the code; nothing to do here.\n };\n ws.onclose = (event) => {\n if (generation !== socketGeneration) return;\n onSocketGone(generation, event.code, null);\n };\n }\n\n function scheduleHeartbeat(generation: number): void {\n if (heartbeatTimer !== null) timers.clearTimeout(heartbeatTimer);\n heartbeatTimer = timers.setTimeout(() => {\n heartbeatTimer = null;\n if (generation !== socketGeneration || !socket) return;\n const silentMs = timers.now() - lastHeardAt;\n if (silentMs >= heartbeatMs * 2) {\n diagnose({ kind: \"heartbeat_timeout\", silentMs });\n const dead = socket;\n onSocketGone(generation, null, new DesktopProtocolError(\"TIMEOUT\", \"Connection went silent\", { retryable: true }));\n try {\n dead.close(CloseCode.NORMAL, \"heartbeat timeout\");\n } catch {\n // already closing\n }\n return;\n }\n if (socket.readyState === WS_OPEN) socket.send(PING_TEXT);\n scheduleHeartbeat(generation);\n }, heartbeatMs);\n }\n\n /** The socket is gone (close event, open failure or heartbeat death). */\n function onSocketGone(generation: number, code: number | null, error: DesktopProtocolError | null): void {\n if (generation !== socketGeneration) return;\n socketGeneration++; // ignore anything the dead socket still emits\n if (socket) {\n socket.onopen = socket.onmessage = socket.onclose = socket.onerror = null;\n }\n socket = null;\n helloId = null;\n if (heartbeatTimer !== null) {\n timers.clearTimeout(heartbeatTimer);\n heartbeatTimer = null;\n }\n if (probeTimer !== null) {\n timers.clearTimeout(probeTimer);\n probeTimer = null;\n }\n // The one close table (close-policy.ts) decides: retry, retry with a fresh token, or stop.\n const rule = code === null ? null : closeRule(code);\n if (rule?.action === \"reauth\") authRefusals++;\n const stopped = rule !== null && (rule.action === \"stop\" || (rule.action === \"reauth\" && authRefusals >= 2));\n const terminal = stopped && rule ? rule : undefined;\n const lost =\n error ??\n (terminal\n ? new DesktopProtocolError(terminal.error[0], terminal.error[1])\n : rule && rule.action === \"reauth\"\n ? new DesktopProtocolError(rule.error[0], rule.error[1], { retryable: true })\n : new DesktopProtocolError(\"DEVICE_OFFLINE\", \"Connection lost\", { retryable: true }));\n\n // Unary requests cannot survive a drop: the caller decides whether to retry.\n for (const [id, p] of pending) {\n pending.delete(id);\n p.cleanup();\n p.reject(lost);\n }\n // Resource streams survive (reattach on reconnect); everything else ends now.\n bySid.clear();\n for (const [id, s] of streams) {\n if (s.resourceId !== null && terminal === undefined && !closedByUser) {\n s.sid = null;\n s.reattaching = false;\n continue;\n }\n streams.delete(id);\n endStream(s, null, lost);\n }\n\n if (closedByUser || terminal) {\n setState({\n status: \"closed\",\n welcome: null,\n lastError: closedByUser ? state.lastError : lost,\n lastCloseCode: code,\n retryInMs: null,\n outcome: closedByUser ? null : (terminal?.outcome ?? null),\n });\n rejectReadyWaiters(lost);\n return;\n }\n const delay = backoff.nextDelayMs();\n if (backoff.isAlarming()) diagnose({ kind: \"reconnect_alarm\", attempts: backoff.attempts() });\n setState({ status: \"reconnecting\", welcome: null, attempts: backoff.attempts(), retryInMs: delay, lastError: lost, lastCloseCode: code });\n reconnectTimer = timers.setTimeout(() => {\n reconnectTimer = null;\n if (!closedByUser) void openSocket();\n }, delay);\n }\n\n function rejectReadyWaiters(error: DesktopProtocolError): void {\n for (const w of [...readyWaiters]) {\n readyWaiters.delete(w);\n w.reject(error);\n }\n }\n\n function close(): void {\n closedByUser = true;\n if (reconnectTimer !== null) {\n timers.clearTimeout(reconnectTimer);\n reconnectTimer = null;\n }\n const cancelled = new DesktopProtocolError(\"CANCELLED\", \"Client closed\");\n const ws = socket;\n if (ws) {\n onSocketGone(socketGeneration, CloseCode.NORMAL, cancelled);\n try {\n ws.close(CloseCode.NORMAL, \"client closed\");\n } catch {\n // already closed\n }\n } else {\n for (const [id, s] of streams) {\n streams.delete(id);\n endStream(s, null, cancelled);\n }\n setState({ status: \"closed\", retryInMs: null });\n rejectReadyWaiters(cancelled);\n }\n }\n\n // ── inbound ────────────────────────────────────────────────────────────────\n\n function onMessage(data: unknown): void {\n if (typeof data === \"string\") {\n if (data === PONG_TEXT) return;\n let json: unknown;\n try {\n json = JSON.parse(data);\n } catch {\n diagnose({ kind: \"malformed_message\", detail: \"not JSON\" });\n return;\n }\n const parsed = CoreToClientMsg.safeParse(json);\n if (!parsed.success) {\n diagnose({ kind: \"malformed_message\", detail: parsed.error.issues.map((i) => `${i.path.join(\".\")}: ${i.message}`).join(\"; \") });\n return;\n }\n onEnvelope(parsed.data);\n return;\n }\n const bytes = toBytes(data);\n if (bytes === null) {\n diagnose({ kind: \"malformed_message\", detail: \"binary message is not an ArrayBuffer/view (set binaryType)\" });\n return;\n }\n let frame: ReturnType<typeof decodeFrame>;\n try {\n frame = decodeFrame(bytes);\n } catch (error) {\n diagnose({ kind: \"malformed_message\", detail: error instanceof Error ? error.message : String(error) });\n return;\n }\n onFrame(frame.header, frame.payload);\n }\n\n function onEnvelope(msg: CoreToClientMsg): void {\n switch (msg.type) {\n case \"response\": {\n if (msg.id === helloId) return onWelcome(msg.result);\n const s = streams.get(msg.id);\n if (s) return onStreamResult(s, msg.result);\n const p = pending.get(msg.id);\n if (!p) return diagnose({ kind: \"unknown_request\", id: msg.id, type: msg.type });\n pending.delete(msg.id);\n p.cleanup();\n p.resolve(msg.result);\n return;\n }\n case \"error\": {\n const error = fromBody(msg.error);\n if (msg.id === helloId) return onHelloRefused(error);\n const s = streams.get(msg.id);\n if (s) {\n if (s.reattaching && s.resourceId !== null) diagnose({ kind: \"reattach_failed\", resourceId: s.resourceId, error });\n streams.delete(msg.id);\n if (s.sid !== null) bySid.delete(s.sid);\n return endStream(s, null, error);\n }\n const p = pending.get(msg.id);\n if (!p) return diagnose({ kind: \"unknown_request\", id: msg.id, type: msg.type });\n pending.delete(msg.id);\n p.cleanup();\n p.reject(error);\n return;\n }\n case \"stream\": {\n const s = streams.get(msg.id);\n if (!s) return diagnose({ kind: \"unknown_request\", id: msg.id, type: msg.type });\n onStreamMeta(s, msg.meta);\n return;\n }\n case \"end\": {\n const s = streams.get(msg.id);\n if (!s) return diagnose({ kind: \"unknown_request\", id: msg.id, type: msg.type });\n // Deliver everything already queued before announcing the end.\n void s.chain.then(() => {\n streams.delete(s.id);\n if (s.sid !== null) bySid.delete(s.sid);\n endStream(s, msg.reason ?? \"completed\", null);\n });\n return;\n }\n case \"credit\": {\n const s = streams.get(msg.id);\n if (!s) return diagnose({ kind: \"unknown_request\", id: msg.id, type: msg.type });\n s.sendWindow += msg.n;\n flushSend(s);\n return;\n }\n case \"event\": {\n const key = `${msg.cap}.${msg.name}`;\n const schema = (EVENTS as Record<string, (typeof EVENTS)[EventName]>)[key];\n if (!schema) return diagnose({ kind: \"malformed_message\", detail: `unknown event ${key}` });\n const payload = schema.safeParse(msg.payload);\n if (!payload.success) return diagnose({ kind: \"malformed_message\", detail: `event ${key}: invalid payload` });\n if (key === \"relay.auth_expiring\" && options.getToken) {\n options.getToken().then(reauth, (error: unknown) => diagnose({ kind: \"reauth_failed\", error }));\n }\n for (const handler of [...(eventHandlers.get(key) ?? [])]) {\n try {\n handler(payload.data as never, msg.resourceId);\n } catch (error) {\n diagnose({ kind: \"handler_threw\", where: `event ${key}`, error });\n }\n }\n return;\n }\n }\n }\n\n function onWelcome(result: unknown): void {\n const welcome = Welcome.safeParse(result);\n if (!welcome.success) {\n onHelloRefused(new DesktopProtocolError(\"PROTOCOL_ERROR\", \"Malformed welcome\"));\n return;\n }\n helloId = null;\n backoff.markConnected();\n authRefusals = 0;\n setState({ status: \"open\", welcome: welcome.data, attempts: 0, retryInMs: null, lastError: null, outcome: null });\n for (const w of [...readyWaiters]) {\n readyWaiters.delete(w);\n w.resolve(welcome.data);\n }\n // Transparent reattach: every surviving resource stream continues where its consumer stopped.\n for (const s of [...streams.values()]) {\n if (s.sid === null && s.resourceId !== null && !s.ended) reattach(s, welcome.data);\n }\n }\n\n function onHelloRefused(error: DesktopProtocolError): void {\n // An unsupported version will not fix itself on retry: UPGRADE_REQUIRED is a terminal close.\n const ws = socket;\n onSocketGone(socketGeneration, error.code === \"PROTOCOL_VERSION_UNSUPPORTED\" ? CloseCode.UPGRADE_REQUIRED : null, error);\n try {\n ws?.close(CloseCode.NORMAL, \"hello refused\");\n } catch {\n // already closed\n }\n }\n\n // ── streams ────────────────────────────────────────────────────────────────\n\n function onStreamResult(s: StreamState, result: unknown): void {\n if (s.reattaching) {\n // session.attach result = ResourceInfo; the stream continues on the new id.\n s.reattaching = false;\n safeCall(\"onReattached\", () => s.handlers.onReattached?.());\n return;\n }\n const rid = (result as { resource_id?: unknown } | null)?.resource_id;\n if (typeof rid === \"string\") s.resourceId = rid;\n if (!s.resultSettled) {\n s.resultSettled = true;\n s.resolveResult(result);\n }\n }\n\n function onStreamMeta(s: StreamState, meta: StreamMeta): void {\n if (meta.kind === \"open\") {\n if (s.sid !== null) bySid.delete(s.sid);\n s.sid = meta.sid;\n s.windowBytes = meta.window_bytes;\n if (meta.resource_id !== undefined) s.resourceId = meta.resource_id;\n bySid.set(meta.sid, s);\n flushSend(s);\n } else {\n // gap or snapshot: the next DATA frame re-establishes the sequence.\n s.expectSeq = null;\n }\n safeCall(\"onMeta\", () => s.handlers.onMeta?.(meta));\n }\n\n function onFrame(header: FrameHeader, payload: Uint8Array): void {\n const s = bySid.get(header.sid);\n if (!s) {\n diagnose({ kind: \"unknown_stream\", sid: header.sid });\n return;\n }\n const isData = header.channel === FrameChannel.DATA || header.channel === FrameChannel.STDERR;\n const isSnapshot = header.channel === FrameChannel.SNAPSHOT;\n if (!isData && !isSnapshot) {\n diagnose({ kind: \"malformed_message\", detail: `channel ${header.channel} is not client-bound` });\n return;\n }\n if (isData) {\n if (s.expectSeq !== null && header.seq !== s.expectSeq) {\n diagnose({ kind: \"seq_gap\", id: s.id, expected: s.expectSeq, received: header.seq });\n }\n s.expectSeq = header.seq + 1;\n }\n // Copy: the payload is a view into a buffer the transport may reuse.\n const bytes = payload.slice();\n const handler = isData ? s.handlers.onData : s.handlers.onSnapshot;\n s.chain = s.chain.then(async () => {\n if (s.ended) return;\n try {\n await handler?.(bytes, header);\n } catch (error) {\n diagnose({ kind: \"handler_threw\", where: isData ? \"onData\" : \"onSnapshot\", error });\n }\n if (isData) s.lastSeq = header.seq;\n grantCredit(s, bytes.byteLength);\n });\n }\n\n function grantCredit(s: StreamState, consumed: number): void {\n s.consumedUncredited += consumed;\n // Batch: one credit per quarter window keeps the pipe full without a message per frame.\n if (s.consumedUncredited >= Math.max(1, Math.floor(s.windowBytes / 4))) {\n if (sendJson({ type: \"credit\", id: s.id, n: s.consumedUncredited })) s.consumedUncredited = 0;\n }\n }\n\n function flushSend(s: StreamState): void {\n if (s.sid === null || !socket || socket.readyState !== WS_OPEN) return;\n const maxPayload = state.welcome?.limits.max_frame_payload_bytes ?? DEFAULT_MAX_FRAME_PAYLOAD_BYTES;\n while (s.sendQueue.length > 0 && s.sendWindow > 0) {\n const head = s.sendQueue[0]!;\n const n = Math.min(head.byteLength, s.sendWindow, maxPayload);\n const chunk = head.subarray(0, n);\n if (n === head.byteLength) s.sendQueue.shift();\n else s.sendQueue[0] = head.subarray(n);\n s.sendWindow -= n;\n s.sendSeq += 1;\n socket.send(encodeFrame({ version: FRAME_VERSION, flags: 0, channel: FrameChannel.STDIN, cid: 0, sid: s.sid, seq: s.sendSeq }, chunk));\n }\n }\n\n function endStream(s: StreamState, reason: EndReason | null, error: DesktopProtocolError | null): void {\n if (s.ended) return;\n s.ended = true;\n s.sendQueue = [];\n if (!s.resultSettled) {\n s.resultSettled = true;\n s.rejectResult(error ?? new DesktopProtocolError(\"INTERNAL\", \"Stream ended before its result\"));\n }\n if (error) s.rejectDone(error);\n else s.resolveDone(reason ?? \"completed\");\n }\n\n function reattach(s: StreamState, welcome: Welcome): void {\n const id = newId(\"a\");\n streams.delete(s.id);\n s.id = id;\n s.reattaching = true;\n s.expectSeq = s.lastSeq > 0 ? s.lastSeq + 1 : null;\n s.consumedUncredited = 0;\n s.sendWindow = welcome.limits.default_window_bytes;\n s.sendSeq = 0;\n streams.set(id, s);\n const params: Record<string, unknown> = { resource_id: s.resourceId, mode: s.options.mode ?? \"control\" };\n if (s.lastSeq > 0) params.since_seq = s.lastSeq;\n if (s.options.windowBytes !== undefined) params.window_bytes = s.options.windowBytes;\n sendJson({ id, type: \"request\", cap: \"session\", op: \"attach\", params });\n }\n\n function safeCall(where: string, fn: () => void): void {\n try {\n fn();\n } catch (error) {\n diagnose({ kind: \"handler_threw\", where, error });\n }\n }\n\n // ── public API ─────────────────────────────────────────────────────────────\n\n function ready(opts: RequestOptions = {}): Promise<Welcome> {\n if (state.status === \"open\" && state.welcome) return Promise.resolve(state.welcome);\n if (state.status === \"closed\") {\n return Promise.reject(state.lastError ?? new DesktopProtocolError(\"CANCELLED\", \"Client is closed\"));\n }\n if (state.status === \"idle\") connect();\n return new Promise((resolve, reject) => {\n const waiter = {\n resolve: (w: Welcome) => {\n done();\n resolve(w);\n },\n reject: (e: DesktopProtocolError) => {\n done();\n reject(e);\n },\n };\n const timeoutMs = opts.timeoutMs ?? requestTimeoutMs;\n const timer = timers.setTimeout(() => waiter.reject(new DesktopProtocolError(\"DEVICE_OFFLINE\", \"Device not reachable\", { retryable: true })), timeoutMs);\n const onAbort = () => waiter.reject(new DesktopProtocolError(\"CANCELLED\", \"Aborted\"));\n opts.signal?.addEventListener(\"abort\", onAbort, { once: true });\n function done() {\n readyWaiters.delete(waiter);\n timers.clearTimeout(timer);\n opts.signal?.removeEventListener(\"abort\", onAbort);\n }\n readyWaiters.add(waiter);\n });\n }\n\n async function request<N extends OpName>(op: N, params: OpParams<N>, opts: RequestOptions = {}): Promise<OpResult<N>> {\n if (OPS[op].kind !== \"unary\") {\n throw new DesktopProtocolError(\"INVALID_PARAMS\", `${op} is a ${OPS[op].kind} op — use stream()`);\n }\n await ready(opts);\n const id = newId(\"r\");\n if (opts.onRequestId) safeCall(\"onRequestId\", () => opts.onRequestId?.(id));\n return new Promise<OpResult<N>>((resolve, reject) => {\n const timeoutMs = opts.timeoutMs ?? requestTimeoutMs;\n const timer = timers.setTimeout(() => {\n pending.delete(id);\n cleanup();\n sendJson({ id, type: \"cancel\" });\n reject(new DesktopProtocolError(\"TIMEOUT\", `${op} timed out`, { retryable: true }));\n }, timeoutMs);\n const onAbort = () => {\n pending.delete(id);\n cleanup();\n sendJson({ id, type: \"cancel\" });\n reject(new DesktopProtocolError(\"CANCELLED\", \"Aborted\"));\n };\n function cleanup() {\n timers.clearTimeout(timer);\n opts.signal?.removeEventListener(\"abort\", onAbort);\n }\n opts.signal?.addEventListener(\"abort\", onAbort, { once: true });\n pending.set(id, { kind: \"unary\", op, resolve: resolve as (v: unknown) => void, reject, cleanup });\n if (!sendJson({ id, type: \"request\", ...capOf(op), params })) {\n pending.delete(id);\n cleanup();\n reject(new DesktopProtocolError(\"DEVICE_OFFLINE\", \"Connection lost\", { retryable: true }));\n }\n });\n }\n\n function stream<N extends StreamOpName>(\n op: N,\n params: OpParams<N>,\n handlers: StreamHandlers = {},\n opts: StreamOptions = {},\n ): DesktopStream<N> {\n let resolveResult!: (v: unknown) => void;\n let rejectResult!: (e: DesktopProtocolError) => void;\n let resolveDone!: (r: EndReason) => void;\n let rejectDone!: (e: DesktopProtocolError) => void;\n const result = new Promise<OpResult<N>>((res, rej) => {\n resolveResult = res as (v: unknown) => void;\n rejectResult = rej;\n });\n const done = new Promise<EndReason>((res, rej) => {\n resolveDone = res;\n rejectDone = rej;\n });\n // Consumers often await only one of the two; never leave the other as an unhandled rejection.\n result.catch(() => undefined);\n done.catch(() => undefined);\n\n // A caller-started session.attach (a page reload reattaching by the resource id it kept in its\n // URL) is a resource stream from its first byte: it survives drops like the stream that created\n // the resource, and its sequence continues from since_seq rather than from 1.\n const attach = op === \"session.attach\" ? (params as { resource_id: string; since_seq?: number }) : null;\n const s: StreamState = {\n op,\n handlers,\n options: opts,\n id: newId(\"s\"),\n sid: null,\n resourceId: attach ? attach.resource_id : null,\n lastSeq: attach?.since_seq ?? 0,\n expectSeq: attach ? (attach.since_seq === undefined ? null : attach.since_seq + 1) : 1,\n windowBytes: opts.windowBytes ?? DEFAULT_WINDOW_BYTES,\n consumedUncredited: 0,\n sendWindow: DEFAULT_WINDOW_BYTES,\n sendSeq: 0,\n sendQueue: [],\n chain: Promise.resolve(),\n resultSettled: false,\n resolveResult,\n rejectResult,\n resolveDone,\n rejectDone,\n ended: false,\n reattaching: false,\n };\n\n const start = async () => {\n let welcome: Welcome;\n try {\n welcome = await ready(opts);\n } catch (error) {\n endStream(s, null, error as DesktopProtocolError);\n return;\n }\n if (s.ended) return;\n s.sendWindow = welcome.limits.default_window_bytes;\n if (opts.windowBytes === undefined) s.windowBytes = welcome.limits.default_window_bytes;\n streams.set(s.id, s);\n const wire: Record<string, unknown> = { ...(params as Record<string, unknown>) };\n if (opts.windowBytes !== undefined && \"window_bytes\" in OPS[op].params.shape) wire.window_bytes = opts.windowBytes;\n if (!sendJson({ id: s.id, type: \"request\", ...capOf(op), params: wire })) {\n streams.delete(s.id);\n endStream(s, null, new DesktopProtocolError(\"DEVICE_OFFLINE\", \"Connection lost\", { retryable: true }));\n }\n };\n void start();\n opts.signal?.addEventListener(\"abort\", () => handle.cancel(), { once: true });\n\n const encoder = new TextEncoder();\n const handle: DesktopStream<N> = {\n get id() {\n return s.id;\n },\n result,\n done,\n get resourceId() {\n return s.resourceId;\n },\n get lastSeq() {\n return s.lastSeq;\n },\n write(data) {\n if (s.ended) throw new DesktopProtocolError(\"RESOURCE_GONE\", \"Stream has ended\");\n const bytes = typeof data === \"string\" ? encoder.encode(data) : data;\n if (bytes.byteLength === 0) return;\n s.sendQueue.push(bytes);\n flushSend(s);\n },\n cancel() {\n if (s.ended) return;\n if (!sendJson({ id: s.id, type: \"cancel\" })) {\n streams.delete(s.id);\n endStream(s, \"cancelled\", null);\n }\n },\n async detach() {\n if (s.ended) return;\n if (s.resourceId === null) throw new DesktopProtocolError(\"INVALID_PARAMS\", \"Only resource streams can be detached\");\n const resourceId = s.resourceId;\n streams.delete(s.id);\n if (s.sid !== null) bySid.delete(s.sid);\n endStream(s, \"detached\", null);\n await request(\"session.detach\", { resource_id: resourceId });\n },\n };\n return handle;\n }\n\n function on<E extends EventName>(name: E, handler: EventHandler<E>): () => void {\n let set = eventHandlers.get(name);\n if (!set) {\n set = new Set();\n eventHandlers.set(name, set);\n }\n set.add(handler as EventHandler<EventName>);\n return () => {\n set.delete(handler as EventHandler<EventName>);\n };\n }\n\n function reauth(token: string): void {\n sendJson({ type: \"relay\", op: \"reauth\", token });\n }\n\n function wake(opts: WakeOptions = {}): void {\n if (closedByUser || state.status === \"closed\") return;\n if (state.status === \"idle\" || state.status === \"reconnecting\") {\n connect(); // dial now; connect() cancels the scheduled backoff timer\n return;\n }\n if (state.status === \"connecting\" || !socket || probeTimer !== null) return;\n const generation = socketGeneration;\n const heardBefore = heardCount;\n try {\n socket.send(PING_TEXT);\n } catch {\n // A socket that cannot even send is dead: fall through to the probe verdict.\n }\n probeTimer = timers.setTimeout(() => {\n probeTimer = null;\n if (generation !== socketGeneration || !socket) return;\n if (heardCount > heardBefore) return; // answered: the socket is alive\n const silentMs = timers.now() - lastHeardAt;\n diagnose({ kind: \"heartbeat_timeout\", silentMs });\n const dead = socket;\n onSocketGone(generation, null, new DesktopProtocolError(\"TIMEOUT\", \"Connection went silent\", { retryable: true }));\n try {\n dead.close(CloseCode.NORMAL, \"wake probe timeout\");\n } catch {\n // already closing\n }\n if (state.status === \"reconnecting\") connect(); // the person is looking: no backoff wait\n }, opts.probeMs ?? 4000);\n }\n\n return {\n connect,\n close,\n getState: () => state,\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n ready,\n request,\n stream,\n on,\n reauth,\n wake,\n };\n}\n\nexport { RECONNECT_ALARM_ATTEMPTS };\n","/**\n * The one error type every package entry throws. It carries the wire ErrorCode (SPEC §5), so a\n * caller branches on `code`/`retryable`/`data.reason` and never parses a message. Zod-free on\n * purpose: `./frame` (the relay hot path) throws it without pulling the schema graph.\n */\nimport type { ErrorCodeName, ErrorData } from \"./types\";\n\nexport class DesktopProtocolError extends Error {\n readonly code: ErrorCodeName;\n readonly retryable: boolean;\n readonly data: ErrorData | undefined;\n\n constructor(code: ErrorCodeName, message: string, options: { retryable?: boolean; data?: ErrorData; cause?: unknown } = {}) {\n super(message, options.cause === undefined ? undefined : { cause: options.cause });\n this.name = \"DesktopProtocolError\";\n this.code = code;\n this.retryable = options.retryable ?? false;\n this.data = options.data;\n }\n\n /**\n * Any thrown value as a DesktopProtocolError, keeping its code, message and data. Each built entry\n * (`.`, `./client`, `./react`) carries its own copy of this class, so `instanceof` alone misses an\n * error thrown by a sibling entry and reports a real NOT_FOUND as INTERNAL; this checks the shape.\n */\n static from(caught: unknown): DesktopProtocolError {\n if (caught instanceof DesktopProtocolError) return caught;\n const e = caught as { name?: unknown; code?: unknown; message?: unknown; retryable?: unknown; data?: unknown } | null;\n if (e && typeof e === \"object\" && e.name === \"DesktopProtocolError\" && typeof e.code === \"string\") {\n return new DesktopProtocolError(e.code as ErrorCodeName, typeof e.message === \"string\" ? e.message : String(e.code), {\n retryable: e.retryable === true,\n ...(e.data && typeof e.data === \"object\" ? { data: e.data as ErrorData } : {}),\n cause: caught,\n });\n }\n return new DesktopProtocolError(\"INTERNAL\", caught instanceof Error ? caught.message : String(caught), { cause: caught });\n }\n\n /** The wire body (ProtocolErrorBody) — what a core or relay sends for this error. */\n toBody(): { code: ErrorCodeName; message: string; retryable: boolean; data?: ErrorData } {\n return this.data === undefined\n ? { code: this.code, message: this.message, retryable: this.retryable }\n : { code: this.code, message: this.message, retryable: this.retryable, data: this.data };\n }\n}\n\nexport function isDesktopProtocolError(value: unknown): value is DesktopProtocolError {\n return value instanceof DesktopProtocolError || (value instanceof Error && value.name === \"DesktopProtocolError\" && \"code\" in value);\n}\n","/**\n * `@ai-matrx/desktop-protocol/frame` — the 16-byte binary frame codec. ZOD-FREE by design: the\n * relay Worker's hot path imports only this entry and must stay tiny.\n *\n * off size field notes\n * 0 u8 version = 1\n * 1 u8 flags bit0 FIN (last frame of this stream), bit1 REPLAY (from ring buffer),\n * bits2-7 reserved = 0\n * 2 u8 channel see FrameChannel\n * 3 u8 reserved = 0\n * 4 u32 cid relay connection id. 0 on every client↔relay hop; the relay stamps it on\n * the relay→device hop and strips it on the way back (rewrites 4 bytes in\n * place — the relay never parses payloads).\n * 8 u32 sid stream id, announced by the core in stream{meta:{kind:\"open\",sid}}\n * 12 u32 seq per-stream frame sequence, starts at 1, strictly +1\n *\n * Big-endian. Payload length = message length − 16 (one frame = one WS binary message).\n * Python struct format: \">BBBBIII\". The zod twin (FrameHeader in the root entry, and so the JSON\n * Schema and Pydantic model) is checked against this file by src/frame.test.ts.\n */\nimport { DesktopProtocolError } from \"./error\";\n\nexport const FRAME_HEADER_BYTES = 16 as const;\nexport const FRAME_VERSION = 1 as const;\nexport const FRAME_STRUCT_FORMAT = \">BBBBIII\" as const;\nexport const FrameFlag = { FIN: 0b01, REPLAY: 0b10 } as const;\nexport const FrameChannel = {\n /** core→client: pty output, fs.read_stream bytes */\n DATA: 0,\n /** core→client: stderr of a non-pty process (reserved for exec.spawn in v1.1) */\n STDERR: 1,\n /** client→core: keystrokes / stdin to sid */\n STDIN: 2,\n /** core→client: serialized terminal screen (attach when since_seq is outside the ring) */\n SNAPSHOT: 3,\n /** relay↔device hop only: a JSON envelope carried inside a binary frame so the relay can route\n * by cid without parsing JSON. Never seen by clients. */\n ENVELOPE: 255,\n} as const;\n\nexport type FrameChannelValue = (typeof FrameChannel)[keyof typeof FrameChannel];\n\nexport interface FrameHeader {\n version: typeof FRAME_VERSION;\n /** 0..3 — FrameFlag bits. */\n flags: number;\n channel: FrameChannelValue;\n cid: number;\n sid: number;\n seq: number;\n}\n\nexport interface DecodedFrame {\n header: FrameHeader;\n /** A VIEW into the input buffer (no copy). Copy it if you keep it past the input's lifetime. */\n payload: Uint8Array;\n}\n\nconst U32_MAX = 4_294_967_295;\nconst CHANNELS: ReadonlySet<number> = new Set(Object.values(FrameChannel));\n\nfunction frameError(message: string): DesktopProtocolError {\n return new DesktopProtocolError(\"PROTOCOL_ERROR\", message);\n}\n\nfunction checkU32(name: string, value: number): void {\n if (!Number.isInteger(value) || value < 0 || value > U32_MAX) throw frameError(`frame ${name} is not a u32: ${value}`);\n}\n\n/** Validate a header without zod. Throws DesktopProtocolError(PROTOCOL_ERROR). */\nexport function assertFrameHeader(h: FrameHeader): void {\n if (h.version !== FRAME_VERSION) throw frameError(`unsupported frame version ${String(h.version)}`);\n if (!Number.isInteger(h.flags) || h.flags < 0 || h.flags > 3) throw frameError(`reserved frame flag bits set: ${h.flags}`);\n if (!CHANNELS.has(h.channel)) throw frameError(`unknown frame channel ${String(h.channel)}`);\n checkU32(\"cid\", h.cid);\n checkU32(\"sid\", h.sid);\n checkU32(\"seq\", h.seq);\n}\n\nexport function encodeFrame(h: FrameHeader, payload: Uint8Array): Uint8Array {\n assertFrameHeader(h);\n const out = new Uint8Array(FRAME_HEADER_BYTES + payload.byteLength);\n const v = new DataView(out.buffer);\n v.setUint8(0, h.version);\n v.setUint8(1, h.flags);\n v.setUint8(2, h.channel);\n v.setUint8(3, 0);\n v.setUint32(4, h.cid);\n v.setUint32(8, h.sid);\n v.setUint32(12, h.seq);\n out.set(payload, FRAME_HEADER_BYTES);\n return out;\n}\n\nexport function decodeFrame(buf: ArrayBuffer | Uint8Array): DecodedFrame {\n const bytes = buf instanceof Uint8Array ? buf : new Uint8Array(buf);\n if (bytes.byteLength < FRAME_HEADER_BYTES) throw frameError(`short frame: ${bytes.byteLength} bytes`);\n const v = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n if (v.getUint8(3) !== 0) throw frameError(\"reserved frame byte 3 is not 0\");\n const header = {\n version: v.getUint8(0),\n flags: v.getUint8(1),\n channel: v.getUint8(2),\n cid: v.getUint32(4),\n sid: v.getUint32(8),\n seq: v.getUint32(12),\n } as FrameHeader;\n assertFrameHeader(header);\n return { header, payload: bytes.subarray(FRAME_HEADER_BYTES) };\n}\n\n/** Read only the 4-byte cid (relay routing) without decoding the rest. */\nexport function readCid(frame: Uint8Array): number {\n if (frame.byteLength < FRAME_HEADER_BYTES) throw frameError(`short frame: ${frame.byteLength} bytes`);\n return new DataView(frame.buffer, frame.byteOffset, frame.byteLength).getUint32(4);\n}\n\n/** Relay hot path: rewrite only the cid IN PLACE, never touch the payload. Returns the same array. */\nexport function stampCid(frame: Uint8Array, cid: number): Uint8Array {\n if (frame.byteLength < FRAME_HEADER_BYTES) throw frameError(`short frame: ${frame.byteLength} bytes`);\n checkU32(\"cid\", cid);\n new DataView(frame.buffer, frame.byteOffset, frame.byteLength).setUint32(4, cid);\n return frame;\n}\n\nexport function hasFlag(header: FrameHeader, flag: (typeof FrameFlag)[keyof typeof FrameFlag]): boolean {\n return (header.flags & flag) !== 0;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Relay ↔ device hop (never seen by clients). Every JSON envelope rides an ENVELOPE frame with\n// flags 0, sid 0, seq 0 and the client's cid; byte frames carry that cid too.\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** cid 0 on an ENVELOPE frame from the device: the relay delivers it to every client. */\nexport const BROADCAST_CID = 0 as const;\n\n/**\n * Connection end: an ENVELOPE frame with FIN, sid 0, seq 0 and NO payload, for connection `cid`.\n * Relay → device: client `cid` is gone — cancel its streams, detach its sessions (idempotent; it\n * may arrive more than once). Device → relay: close client `cid`.\n */\nexport function connectionEndFrame(cid: number): Uint8Array {\n if (cid === BROADCAST_CID) throw frameError(\"a connection end needs a client cid, not the broadcast cid 0\");\n return encodeFrame({ version: FRAME_VERSION, flags: FrameFlag.FIN, channel: FrameChannel.ENVELOPE, cid, sid: 0, seq: 0 }, new Uint8Array(0));\n}\n\n/** True for a decoded connection-end frame (see connectionEndFrame). */\nexport function isConnectionEnd(frame: DecodedFrame): boolean {\n const h = frame.header;\n return h.channel === FrameChannel.ENVELOPE && hasFlag(h, FrameFlag.FIN) && frame.payload.byteLength === 0 && h.cid !== BROADCAST_CID;\n}\n","/** @ai-matrx/desktop-protocol — the JSON envelope (SPEC §4). Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport { ProtocolErrorBody } from \"./errors\";\nimport { DeviceId, ProtocolVersion, RequestId, ResourceId, epochMs, u32 } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Client types and hello\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const ClientType = z\n .enum([\"screen\", \"web\", \"extension\", \"server\", \"test\"]);\n\nexport const Limits = z\n .strictObject({\n max_message_bytes: z.int().min(65_536),\n max_frame_payload_bytes: z.int().min(4096),\n default_window_bytes: z.int().min(4096),\n max_streams_per_client: z.int().min(1),\n max_resources_per_user: z.int().min(1),\n });\n\nexport const OpDescriptor = z\n .strictObject({ cap: z.string().max(32), op: z.string().max(64), since: ProtocolVersion });\n\nexport const Welcome = z\n .strictObject({\n protocol_version: ProtocolVersion, // negotiated = min(client, core) within the same major\n session_id: z.string().min(8).max(64),\n client_id: z.string().min(8).max(64), // this connection's identity in the Session Manager\n device_id: DeviceId,\n device_name: z.string().max(128),\n app_version: z.string().max(32),\n platform: z.enum([\"darwin\", \"win32\", \"linux\"]),\n ops: z.array(OpDescriptor),\n limits: Limits,\n server_time_ms: epochMs,\n });\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Envelope (SPEC §4). Text WS messages carry exactly one of these as JSON.\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const HelloMsg = z\n .strictObject({\n type: z.literal(\"hello\"),\n id: RequestId, // answered by response{id, result: Welcome} or error{id}\n protocolVersion: ProtocolVersion,\n clientType: ClientType,\n clientVersion: z.string().min(1).max(32),\n });\n\nexport const RequestMsg = z\n .strictObject({\n id: RequestId,\n type: z.literal(\"request\"),\n cap: z.string().min(1).max(32),\n op: z.string().min(1).max(64),\n params: z.unknown(), // validated by the Router against OPS[cap.op].params — once, there\n });\n\nexport const ResponseMsg = z\n .strictObject({ id: RequestId, type: z.literal(\"response\"), result: z.unknown() });\n\nexport const ErrorMsg = z\n .strictObject({ id: RequestId, type: z.literal(\"error\"), error: ProtocolErrorBody });\n\nexport const StreamMeta = z\n .discriminatedUnion(\"kind\", [\n /** Binds request id → numeric sid; binary frames for this stream follow. */\n z.strictObject({\n kind: z.literal(\"open\"),\n sid: u32,\n window_bytes: z.int().min(4096),\n resource_id: ResourceId.optional(),\n }),\n /** Frames after this (channel SNAPSHOT) are a serialized screen; live DATA resumes after. */\n z.strictObject({ kind: z.literal(\"snapshot\"), cols: z.int().min(1), rows: z.int().min(1) }),\n /** Frames [from_seq, to_seq] are gone from the ring; a snapshot follows. */\n z.strictObject({ kind: z.literal(\"gap\"), from_seq: u32, to_seq: u32 }),\n ]);\n\nexport const StreamMsg = z\n .strictObject({ id: RequestId, type: z.literal(\"stream\"), seq: u32, meta: StreamMeta });\n\nexport const EndReason = z\n .enum([\"completed\", \"cancelled\", \"detached\", \"resource_exited\", \"error\"]);\n\nexport const EndMsg = z\n .strictObject({ id: RequestId, type: z.literal(\"end\"), seq: u32, reason: EndReason.optional() });\n\nexport const CancelMsg = z\n .strictObject({ id: RequestId, type: z.literal(\"cancel\") });\n\n/** Grant n more payload bytes for the stream opened by request `id` (either direction). */\nexport const CreditMsg = z\n .strictObject({ id: RequestId, type: z.literal(\"credit\"), n: z.int().min(1).max(2_147_483_647) });\n\nexport const EventMsg = z\n .strictObject({\n type: z.literal(\"event\"),\n cap: z.string().min(1).max(32),\n name: z.string().min(1).max(64),\n payload: z.unknown(), // validated against EVENTS[cap.name]\n resourceId: ResourceId.optional(),\n });\n\n/** Client↔relay only; the relay consumes these and never forwards them to the core. */\nexport const RelayMsg = z\n .discriminatedUnion(\"op\", [\n /** Fresh access token before the current one expires (relay closes 4008 at exp + 60 s). */\n z.strictObject({ type: z.literal(\"relay\"), op: z.literal(\"reauth\"), token: z.string().min(16).max(8192) }),\n ]);\n\n/**\n * Heartbeat. Sent as these EXACT bytes; the relay answers via the Durable Object\n * setWebSocketAutoResponse pair, so a heartbeat never wakes a hibernated object.\n * Interval 25 s (device and clients); 2 missed pongs = reconnect.\n */\nexport const PING_TEXT = '{\"type\":\"ping\"}' as const;\nexport const PONG_TEXT = '{\"type\":\"pong\"}' as const;\n\n/**\n * Every WebSocket (device, phone, browser, localhost) offers this subprotocol; the access token\n * rides beside it as `${BEARER_PREFIX}<token>`, never in the URL. The server echoes only SUBPROTOCOL.\n */\nexport const SUBPROTOCOL = \"matrx.v1\" as const;\nexport const BEARER_PREFIX = \"bearer.\" as const;\n\nexport const ClientToCoreMsg = z\n .discriminatedUnion(\"type\", [HelloMsg, RequestMsg, CancelMsg, CreditMsg]);\n\nexport const CoreToClientMsg = z\n .discriminatedUnion(\"type\", [ResponseMsg, ErrorMsg, StreamMsg, EndMsg, CreditMsg, EventMsg]);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// WebSocket close codes (relay and localhost transport alike)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const CloseCode = {\n NORMAL: 1000,\n GOING_AWAY: 1001, // app quit; relay: the device was silent for 75 s — reconnect\n /** Never sent by anyone: what a socket reports when it drops without a close frame. A relay\n * deploy (every Durable Object restarts) arrives as this — reconnect immediately. */\n ABNORMAL: 1006,\n /** Relay → clients: the device (re)connected, so the core session they spoke to is gone —\n * reconnect, hello, and reattach with since_seq. */\n DEVICE_RECONNECTED: 1012,\n TRY_AGAIN_LATER: 1013, // relay: signing keys or the device registry unreachable — retry\n AUTH_INVALID: 4001,\n AUTH_FORBIDDEN: 4003,\n DEVICE_NOT_FOUND: 4004,\n AUTH_EXPIRED: 4008, // no reauth before exp + 60 s\n REPLACED: 4009, // a newer device socket for the same device took over\n DEVICE_REVOKED: 4010, // kill switch — do NOT reconnect\n PROTOCOL_ERROR: 4400,\n UPGRADE_REQUIRED: 4426,\n} as const;\n\n/** Every close code above, as a schema (so Python sees the same table). */\nexport const CloseCodeValue = z.literal([1000, 1001, 1006, 1012, 1013, 4001, 4003, 4004, 4008, 4009, 4010, 4400, 4426]);\nexport type CloseCodeValue = z.output<typeof CloseCodeValue>;\n\n// Compile-time proof the schema lists exactly the CloseCode table.\ntype SameCodes<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;\ntype AssertCodes<T extends true> = T;\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype CloseCodeTableCheck = AssertCodes<SameCodes<CloseCodeValue, (typeof CloseCode)[keyof typeof CloseCode]>>;\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type ClientType = z.output<typeof ClientType>;\nexport type Limits = z.output<typeof Limits>;\nexport type OpDescriptor = z.output<typeof OpDescriptor>;\nexport type Welcome = z.output<typeof Welcome>;\nexport type HelloMsg = z.output<typeof HelloMsg>;\nexport type RequestMsg = z.output<typeof RequestMsg>;\nexport type ResponseMsg = z.output<typeof ResponseMsg>;\nexport type ErrorMsg = z.output<typeof ErrorMsg>;\nexport type StreamMeta = z.output<typeof StreamMeta>;\nexport type StreamMsg = z.output<typeof StreamMsg>;\nexport type EndReason = z.output<typeof EndReason>;\nexport type EndMsg = z.output<typeof EndMsg>;\nexport type CancelMsg = z.output<typeof CancelMsg>;\nexport type CreditMsg = z.output<typeof CreditMsg>;\nexport type EventMsg = z.output<typeof EventMsg>;\nexport type RelayMsg = z.output<typeof RelayMsg>;\nexport type ClientToCoreMsg = z.output<typeof ClientToCoreMsg>;\nexport type CoreToClientMsg = z.output<typeof CoreToClientMsg>;\n","/** @ai-matrx/desktop-protocol — error model (SPEC §5). Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport type { ErrorCodeName, ErrorData, ErrorReasonName } from \"../types\";\nimport { AbsPath, ProtocolVersion, nonNegInt } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Errors (SPEC §5, plus the five additions marked NEW)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const ErrorCode = z\n .enum([\n \"AUTH_REQUIRED\",\n \"AUTH_INVALID\",\n \"AUTH_EXPIRED\",\n \"AUTH_FORBIDDEN\", // signed in, but not this device's owner\n \"AUTH_DEVICE_REVOKED\", // kill switch\n \"PERMISSION_DENIED_OS\",\n \"NOT_FOUND\",\n \"CONFLICT\",\n \"INVALID_PARAMS\",\n \"RESOURCE_BUSY\",\n \"RESOURCE_GONE\",\n \"CANCELLED\",\n \"TIMEOUT\",\n \"PLATFORM_UNSUPPORTED\",\n \"RATE_LIMITED\",\n \"INTERNAL\",\n \"PROTOCOL_VERSION_UNSUPPORTED\", // NEW: hello refused, carries data.upgrade\n \"PROTOCOL_ERROR\", // NEW: malformed envelope/frame, credit overrun, unknown sid\n \"UNKNOWN_OPERATION\", // NEW: cap.op not served by this core version\n \"DEVICE_OFFLINE\", // NEW: relay has no live device socket (retryable)\n \"PAYLOAD_TOO_LARGE\", // NEW: message or frame above limits.max_*_bytes\n ]);\n\n/** Machine reason under a code, so clients branch without parsing messages. */\nexport const ErrorReason = z\n .enum([\n \"not_a_directory\",\n \"is_a_directory\",\n \"directory_not_empty\",\n \"already_exists\",\n \"stale_write\", // fs.write if_match_mtime_ms mismatch → CONFLICT\n \"binary_content\", // utf8 read of non-UTF-8 bytes → INVALID_PARAMS\n \"not_utf8_boundary\",\n \"patch_no_match\",\n \"patch_ambiguous\",\n \"resource_exited\",\n \"resource_expired\",\n \"control_taken\", // another client of the same user took control\n \"window_exhausted\",\n // 1.2 (REASONS_SINCE): the `models` capability and its supervised Python service\n \"runtime_not_installed\", // NOT_FOUND: install the inference runtime first (models.install)\n \"model_not_installed\", // NOT_FOUND: that model's weights are not on the device\n \"unsupported_media\", // INVALID_PARAMS: the file is not audio or video the decoder reads\n \"download_failed\", // install could not fetch a package or model file\n \"service_starting\", // RESOURCE_BUSY (retryable): the service is starting or restarting\n \"service_restarted\", // RESOURCE_GONE: the service died while this request ran\n \"service_failed\", // INTERNAL: the service could not be started (see models.status)\n ]);\n\n/**\n * One edit fs.patch could not apply — the daemon's `edits_failed[]` entry, verbatim: the edit's\n * index and the daemon's own reason text (\"old_text not found\", or \"old_text matches N locations —\n * add context or set replace_all=True\").\n */\nexport const FsPatchEditFailure = z.strictObject({ edit_index: nonNegInt, reason: z.string().max(300) });\n\nexport const ProtocolErrorBody = z\n .strictObject({\n code: ErrorCode,\n message: z.string().max(300), // short, human, never a stack trace or a token\n retryable: z.boolean(),\n data: z\n .strictObject({\n reason: ErrorReason.optional(),\n cap: z.string().max(32).optional(),\n op: z.string().max(64).optional(),\n path: AbsPath.optional(),\n settings_url: z.string().max(512).optional(), // PERMISSION_DENIED_OS deep link\n retry_after_ms: nonNegInt.optional(),\n limit_bytes: nonNegInt.optional(),\n /** fs.patch when every edit failed (CONFLICT, patch_no_match / patch_ambiguous): the daemon's 422 `failures`. */\n edits_failed: z.array(FsPatchEditFailure).max(256).optional(),\n upgrade: z\n .strictObject({\n min_version: ProtocolVersion,\n max_version: ProtocolVersion,\n download_url: z.url().optional(),\n })\n .optional(),\n })\n .optional(),\n });\n\n\n// Compile-time proof the zod-free twins in ../types.ts equal these schemas.\ntype Same<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;\ntype AssertTrue<T extends true> = T;\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype ErrorTwinCheck = [\n AssertTrue<Same<z.infer<typeof ErrorCode>, ErrorCodeName>>,\n AssertTrue<Same<z.infer<typeof ErrorReason>, ErrorReasonName>>,\n AssertTrue<Same<NonNullable<z.input<typeof ProtocolErrorBody>[\"data\"]>, ErrorData>>,\n];\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type ErrorCode = z.output<typeof ErrorCode>;\nexport type ErrorReason = z.output<typeof ErrorReason>;\nexport type ProtocolErrorBody = z.output<typeof ProtocolErrorBody>;\nexport type FsPatchEditFailure = z.output<typeof FsPatchEditFailure>;\n","/** @ai-matrx/desktop-protocol — version and primitive schemas. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Version\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const PROTOCOL_MAJOR = 1 as const;\n/**\n * Minor history (same major = compatible; see src/versioning.ts for the rule and FIELDS_SINCE):\n * 1.0 — the first contract.\n * 1.1 — fs.patch per-edit results; /call reports the negotiated version;\n * device status since_ms is null for a device that never connected.\n * 1.2 — the `models` capability (local transcription) and its error reasons (REASONS_SINCE);\n * the `apps` capability (desktop apps, their profiles and usage).\n * 1.3 — the `proc` capability (processes, listening ports, stopping one) and `clipboard`.\n * 1.4 — computer control: `system`, `screen`, `window`, `input`, `power`, `resources`; polled\n * folder watches (fs.watch.start/events/stop) and background jobs (exec.job.*).\n * 1.5 — `coding.history.import_missing`: Claude Code history the platform lacks, imported by the\n * `coding` Python service.\n * 1.6 — the `audio` capability: devices, record a clip to a WAV file, play a file.\n */\nexport const PROTOCOL_MINOR = 6 as const;\n/** This package's version as the wire spells it (\"major.minor\"): hello, welcome, relay status. */\nexport const PROTOCOL_VERSION = `${PROTOCOL_MAJOR}.${PROTOCOL_MINOR}` as const;\n/** \"major.minor\". Same major = compatible (minor adds optional fields/ops only). */\nexport const ProtocolVersion = z\n .string()\n .regex(/^[1-9][0-9]{0,2}\\.[0-9]{1,3}$/);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Primitives\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** Client-generated request id, unique per session. */\nexport const RequestId = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[A-Za-z0-9_-]+$/);\n\n/** Long-lived resource handle minted by the core: \"<kind>_<base62>\" (pty_…, watch_…). */\nexport const ResourceId = z\n .string()\n .regex(/^(pty|watch)_[A-Za-z0-9]{16,40}$/);\n\n/**\n * = app_instances.id. A plain pattern, NOT z.uuid(): z.uuid() emits `format: uuid` + `pattern`,\n * which datamodel-codegen renders as `Annotated[UUID, Field(pattern=...)]` — a model Pydantic can\n * never validate (\"Unable to apply constraint 'pattern' … of type 'uuid'\"). generate.ts now\n * refuses format+pattern on one node so this class cannot come back.\n */\nexport const DeviceId = z\n .string()\n .regex(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/);\n\n/**\n * Absolute, normalized path: forward slashes on every OS, NFC. POSIX \"/...\" or Windows \"C:/...\".\n * Normalization happens once, in the fs owner (SPEC §9); the wire never carries backslashes.\n */\nexport const AbsPath = z\n .string()\n .min(1)\n .max(4096)\n .regex(/^(\\/|[A-Za-z]:\\/)[^\\\\\\u0000]*$/);\n\n/** Internal building blocks — deliberately unnamed in $defs (inlined wherever used). */\nexport const u32 = z.int().min(0).max(4_294_967_295);\nexport const nonNegInt = z.int().min(0);\n/** Unix epoch milliseconds. */\nexport const epochMs = z.int().min(0);\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type ProtocolVersion = z.output<typeof ProtocolVersion>;\nexport type RequestId = z.output<typeof RequestId>;\nexport type ResourceId = z.output<typeof ResourceId>;\nexport type DeviceId = z.output<typeof DeviceId>;\nexport type AbsPath = z.output<typeof AbsPath>;\n","/**\n * What a connecting side does after each WebSocket close — the ONE table every client reads (the\n * package client, the desktop's relay transport, any other dialer). Never keep a local list of\n * \"terminal\" codes: a code added to CloseCode without a rule here fails to compile.\n *\n * reconnect_now the far side went away on purpose or the socket died; dial again at once if the\n * connection had opened, with backoff otherwise (a dead network never spins).\n * reconnect transient refusal; dial again with backoff.\n * reauth the token was refused; get a FRESH token and dial once more. A second refusal in\n * a row (no successful open between) is terminal with outcome \"signed_out\".\n * stop retrying cannot help: stop dialing until something changes (a new sign-in, a\n * new device, an update) and show the outcome.\n */\nimport type { ErrorCodeName } from \"./types\";\nimport { CloseCode, type CloseCodeValue } from \"./schema/envelope\";\n\nexport type CloseAction = \"reconnect_now\" | \"reconnect\" | \"reauth\" | \"stop\";\n\n/** The one state a person is shown when dialing stops. */\nexport type CloseOutcome = \"signed_out\" | \"not_owned\" | \"removed\" | \"revoked\" | \"replaced\" | \"upgrade_required\";\n\nexport interface CloseRule {\n readonly action: CloseAction;\n /** Set for `stop` and `reauth` (the outcome when the fresh token is refused too). */\n readonly outcome?: CloseOutcome;\n /** The error a caller's pending work is failed with. */\n readonly error: readonly [ErrorCodeName, string];\n}\n\nexport const CLOSE_RULES = {\n [CloseCode.NORMAL]: { action: \"reconnect\", error: [\"DEVICE_OFFLINE\", \"Connection closed\"] },\n [CloseCode.GOING_AWAY]: { action: \"reconnect_now\", error: [\"DEVICE_OFFLINE\", \"Connection lost\"] },\n [CloseCode.ABNORMAL]: { action: \"reconnect_now\", error: [\"DEVICE_OFFLINE\", \"Connection lost\"] },\n [CloseCode.DEVICE_RECONNECTED]: { action: \"reconnect_now\", error: [\"DEVICE_OFFLINE\", \"Device reconnected\"] },\n [CloseCode.TRY_AGAIN_LATER]: { action: \"reconnect\", error: [\"DEVICE_OFFLINE\", \"Relay busy; retrying\"] },\n [CloseCode.AUTH_INVALID]: { action: \"reauth\", outcome: \"signed_out\", error: [\"AUTH_INVALID\", \"Sign-in was not accepted\"] },\n [CloseCode.AUTH_FORBIDDEN]: { action: \"stop\", outcome: \"not_owned\", error: [\"AUTH_FORBIDDEN\", \"Not this device's owner\"] },\n [CloseCode.DEVICE_NOT_FOUND]: { action: \"stop\", outcome: \"removed\", error: [\"NOT_FOUND\", \"Device not found\"] },\n [CloseCode.AUTH_EXPIRED]: { action: \"reauth\", outcome: \"signed_out\", error: [\"AUTH_EXPIRED\", \"Sign-in expired\"] },\n [CloseCode.REPLACED]: { action: \"stop\", outcome: \"replaced\", error: [\"CONFLICT\", \"Replaced by a newer connection\"] },\n [CloseCode.DEVICE_REVOKED]: { action: \"stop\", outcome: \"revoked\", error: [\"AUTH_DEVICE_REVOKED\", \"This device was revoked\"] },\n // A malformed message, or a connection the relay lost track of: a fresh socket starts clean.\n [CloseCode.PROTOCOL_ERROR]: { action: \"reconnect\", error: [\"PROTOCOL_ERROR\", \"Connection reset by the relay\"] },\n [CloseCode.UPGRADE_REQUIRED]: { action: \"stop\", outcome: \"upgrade_required\", error: [\"PROTOCOL_VERSION_UNSUPPORTED\", \"Protocol upgrade required\"] },\n} as const satisfies Record<CloseCodeValue, CloseRule>;\n\nconst UNKNOWN: CloseRule = { action: \"reconnect\", error: [\"DEVICE_OFFLINE\", \"Connection lost\"] };\n\n/** The rule for any close code; one this table does not know (or null: no close frame) reconnects with backoff. */\nexport function closeRule(code: number | null | undefined): CloseRule {\n if (code === null || code === undefined) return CLOSE_RULES[CloseCode.ABNORMAL];\n return (CLOSE_RULES as Record<number, CloseRule>)[code] ?? UNKNOWN;\n}\n\n/** True when dialing must stop after this close (no retry will help). */\nexport function isTerminalClose(code: number | null | undefined): boolean {\n return closeRule(code).action === \"stop\";\n}\n","/** @ai-matrx/desktop-protocol — binary frame header and flow-control constants. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport { FRAME_VERSION } from \"../frame\";\nimport type { FrameHeader as FrameHeaderShape } from \"../frame\";\nimport { u32 } from \"./primitives\";\n\n/** Zod twin of the codec's FrameHeader (layout documented in src/frame.ts) — for $defs and Pydantic. */\nexport const FrameHeader = z\n .strictObject({\n version: z.literal(FRAME_VERSION),\n flags: z.int().min(0).max(3),\n channel: z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3), z.literal(255)]),\n cid: u32,\n sid: u32,\n seq: u32,\n });\nexport type FrameHeader = z.infer<typeof FrameHeader>;\n\n/** Relay ↔ device hop: the header of a frame carrying one JSON envelope. cid 0 = broadcast (device → relay). */\nexport const RelayHopEnvelopeHeader = z\n .strictObject({\n version: z.literal(FRAME_VERSION),\n flags: z.literal(0),\n channel: z.literal(255),\n cid: u32,\n sid: z.literal(0),\n seq: z.literal(0),\n });\nexport type RelayHopEnvelopeHeader = z.infer<typeof RelayHopEnvelopeHeader>;\n\n/** Relay ↔ device hop: the header of a connection-end frame (FIN, empty payload; see connectionEndFrame). */\nexport const RelayHopConnectionEnd = z\n .strictObject({\n version: z.literal(FRAME_VERSION),\n flags: z.literal(1),\n channel: z.literal(255),\n cid: z.int().min(1).max(4_294_967_295),\n sid: z.literal(0),\n seq: z.literal(0),\n });\nexport type RelayHopConnectionEnd = z.infer<typeof RelayHopConnectionEnd>;\n\n// Compile-time proof the zod twin and the zod-free codec type are the same shape.\ntype Same<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;\ntype AssertTrue<T extends true> = T;\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype FrameHeaderTwinCheck = AssertTrue<Same<z.infer<typeof FrameHeader>, FrameHeaderShape>>;\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Flow control (credits)\n//\n// The RECEIVER of a byte stream grants the SENDER a window in payload bytes. The sender may have at\n// most `window` un-credited payload bytes in flight per sid; it pauses its source (node-pty\n// pause(), file read loop) at zero and resumes on credit. Initial window = request's\n// `window_bytes` or limits.default_window_bytes. The receiver sends credit{n} after it has\n// CONSUMED n bytes (xterm write callback fired, file chunk persisted). Overrun → PROTOCOL_ERROR\n// and the stream is ended. Credits are end-to-end (client↔core), so the relay holds at most\n// sum(windows) per device and never buffers without bound. Unary JSON ops are not credited.\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const DEFAULT_WINDOW_BYTES = 262_144 as const; // 256 KiB\nexport const DEFAULT_MAX_FRAME_PAYLOAD_BYTES = 65_536 as const; // 64 KiB\nexport const DEFAULT_MAX_MESSAGE_BYTES = 8_388_608 as const; // 8 MiB JSON message cap\n\n","/** @ai-matrx/desktop-protocol — cap sysinfo. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport { AbsPath, DeviceId, ProtocolVersion, nonNegInt } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// sysinfo\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const OsPermissionName = z\n .enum([\n \"full_disk_access\",\n \"accessibility\",\n \"screen_recording\",\n \"microphone\",\n \"camera\",\n \"automation\",\n \"contacts\",\n \"calendars\",\n \"photos\",\n \"location\",\n \"local_network\",\n \"bluetooth\",\n \"notifications\",\n ]);\n\nexport const SysinfoGetParams = z.strictObject({});\nexport const SysinfoGetResult = z\n .strictObject({\n device_id: DeviceId,\n device_name: z.string().max(128),\n hostname: z.string().max(255),\n platform: z.enum([\"darwin\", \"win32\", \"linux\"]),\n os_version: z.string().max(64),\n arch: z.enum([\"arm64\", \"x64\"]),\n app_version: z.string().max(32),\n protocol_version: ProtocolVersion,\n user: z.strictObject({ username: z.string().max(128), shell: z.string().max(512) }),\n paths: z.strictObject({\n home: AbsPath,\n desktop: AbsPath,\n documents: AbsPath,\n downloads: AbsPath,\n app_data: AbsPath,\n temp: AbsPath,\n }),\n cpu: z.strictObject({ model: z.string().max(128), cores: z.int().min(1) }),\n memory: z.strictObject({ total_bytes: nonNegInt, free_bytes: nonNegInt }),\n uptime_seconds: nonNegInt,\n on_battery: z.boolean().nullable(),\n sleep_prevented: z.boolean(), // true while any remote session holds the power blocker\n permissions: z.array(\n z.strictObject({\n name: OsPermissionName,\n state: z.enum([\"granted\", \"denied\", \"not_determined\", \"not_applicable\"]),\n settings_url: z.string().max(512).nullable(),\n }),\n ),\n });\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type OsPermissionName = z.output<typeof OsPermissionName>;\nexport type SysinfoGetParams = z.output<typeof SysinfoGetParams>;\nexport type SysinfoGetResult = z.output<typeof SysinfoGetResult>;\n","/** @ai-matrx/desktop-protocol — cap fs. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport { FsPatchEditFailure } from \"./errors\";\nimport { AbsPath, ResourceId, epochMs, nonNegInt } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// fs — mirrors matrx_agent daemon /fs/* field names (SPEC §6.1)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const FsKind = z.enum([\"file\", \"dir\", \"symlink\"]);\n\n/**\n * = daemon get_stat_dict(), field for field (SPEC 6.1): what /fs/stat and every /fs/list entry\n * answer in the cloud sandbox. Never follows symlinks; `target` is the fully resolved target.\n */\nexport const FsEntry = z\n .strictObject({\n name: z.string().max(1024),\n path: AbsPath,\n kind: FsKind,\n size: nonNegInt,\n mtime: z.number().min(0), // seconds, float\n mode: z.int().min(0).max(0o7777),\n target: AbsPath.nullable(),\n });\n\nexport const FsListParams = z\n .strictObject({\n path: AbsPath,\n recursive: z.boolean().default(false),\n depth: z.int().min(1).max(32).default(1),\n pattern: z.string().max(256).optional(), // glob on name\n limit: z.int().min(1).max(5000).default(1000),\n page_token: z.string().max(256).optional(),\n // Desktop additions; their defaults ARE the daemon's behaviour: dotfiles listed, siblings in\n // binary (byte) order of name, depth-first.\n show_hidden: z.boolean().default(true),\n sort: z.enum([\"name\", \"mtime\", \"size\", \"kind\"]).default(\"name\"),\n });\nexport const FsListResult = z\n .strictObject({\n entries: z.array(FsEntry),\n truncated: z.boolean(),\n next_page_token: z.string().max(256).nullable(),\n scanned: nonNegInt,\n });\n\nexport const FsStatParams = z.strictObject({ path: AbsPath });\nexport const FsStatResult = FsEntry;\n\nexport const FsEncoding = z.enum([\"utf8\", \"base64\"]);\n\n/** Bounded read. offset = byte offset; limit = chars (utf8) or bytes (base64), as the daemon. */\nexport const FsReadParams = z\n .strictObject({\n path: AbsPath,\n encoding: FsEncoding.default(\"utf8\"),\n offset: nonNegInt.default(0),\n limit: z.int().min(1).max(4_194_304).default(262_144),\n });\nexport const FsReadResult = z\n .strictObject({\n content: z.string(),\n encoding: FsEncoding,\n size: nonNegInt,\n offset: nonNegInt,\n next_offset: nonNegInt,\n truncated: z.boolean(),\n mime: z.string().max(128).nullable(),\n mtime_ms: epochMs, // pass back as if_match_mtime_ms to guard a later write\n });\n\n/** Whole-file or ranged download as binary frames (channel DATA, credited). */\nexport const FsReadStreamParams = z\n .strictObject({\n path: AbsPath,\n offset: nonNegInt.default(0),\n length: nonNegInt.optional(), // absent = to EOF\n window_bytes: z.int().min(4096).max(16_777_216).optional(),\n });\n/** Unary result arrives first (size/mime), then stream{open} + DATA frames + end. */\nexport const FsReadStreamResult = z\n .strictObject({ size: nonNegInt, mime: z.string().max(128).nullable(), mtime_ms: epochMs });\n\nexport const FsWriteParams = z\n .strictObject({\n path: AbsPath,\n content: z.string().max(5_592_406), // ≤ 4 MiB of bytes after base64 decode\n encoding: FsEncoding.default(\"utf8\"),\n mode: z.int().min(0).max(0o7777).optional(),\n create_parents: z.boolean().default(false),\n /** Optimistic concurrency: CONFLICT/stale_write if the file changed since this mtime. */\n if_match_mtime_ms: epochMs.optional(),\n /** Refuse to replace an existing file (CONFLICT/already_exists). */\n exclusive: z.boolean().default(false),\n });\n/** Writes are atomic: temp file in the same directory + rename (daemon parity). */\nexport const FsWriteResult = z\n .strictObject({ path: AbsPath, size: nonNegInt, mtime_ms: epochMs, created: z.boolean() });\n\nexport const FsMkdirParams = z\n .strictObject({ path: AbsPath, parents: z.boolean().default(false) });\nexport const FsMkdirResult = z\n .strictObject({ path: AbsPath, created: z.boolean() });\n\n/** = daemon RenameRequest (/fs/rename). */\nexport const FsMoveParams = z\n .strictObject({ from_path: AbsPath, to_path: AbsPath, overwrite: z.boolean().default(false) });\nexport const FsMoveResult = z\n .strictObject({ from_path: AbsPath, to_path: AbsPath });\n\n/**\n * Delete. Default goes to the OS Trash (Finder/Explorer semantics: undoable from the phone's\n * \"Undo\" toast via fs.move back). to_trash:false is a permanent delete — the daemon's behaviour,\n * used by agents through _sandbox_proxy.\n */\nexport const FsDeleteParams = z\n .strictObject({\n path: AbsPath,\n recursive: z.boolean().default(false),\n to_trash: z.boolean().default(true),\n });\nexport const FsDeleteResult = z\n .strictObject({ deleted: z.literal(true), trashed_to: AbsPath.nullable() });\n\n/** Opens a watch resource; changes arrive as event fs.changed with resourceId. */\nexport const FsWatchParams = z\n .strictObject({\n path: AbsPath,\n recursive: z.boolean().default(false),\n ignore: z.array(z.string().max(256)).max(64).default([]),\n debounce_ms: z.int().min(0).max(5000).default(50),\n });\nexport const FsWatchResult = z\n .strictObject({ resource_id: ResourceId, path: AbsPath });\n\n// — Required by lane F (SPEC §6.1 parity sequence and every existing _sandbox_proxy call) —\n\n/** = daemon EditChunk / PatchRequest (/fs/patch). */\nexport const FsPatchParams = z\n .strictObject({\n path: AbsPath,\n edits: z\n .array(\n z.strictObject({\n old_text: z.string(),\n new_text: z.string(),\n replace_all: z.boolean().default(false),\n }),\n )\n .min(1)\n .max(256),\n create_if_missing: z.boolean().default(false),\n });\n/** One edit fs.patch applied — the daemon's `edits_applied[]` entry, verbatim. */\nexport const FsPatchEditApplied = z.strictObject({\n edit_index: nonNegInt,\n mode: z.enum([\"create\", \"replace\", \"replace_all\"]),\n /** Present for replace_all only, as the daemon sends it. */\n matches_replaced: nonNegInt.optional(),\n});\n\n/**\n * = the daemon's /fs/patch answer per edit: edits apply in order, each sees the previous result; an\n * edit whose old_text is missing, or matches more than once without replace_all, is skipped and\n * listed in edits_failed with the daemon's reason; the file is written when at least one applied.\n * (Every edit failing is a CONFLICT whose data.edits_failed lists them — the daemon's 422.)\n */\nexport const FsPatchResult = z.strictObject({\n path: AbsPath,\n applied: nonNegInt,\n size: nonNegInt,\n mtime_ms: epochMs,\n /** Since 1.1 (FIELDS_SINCE): a 1.0 app sends only `applied`. Always sent to a ≥1.1 peer. */\n edits_applied: z.array(FsPatchEditApplied).max(256).optional(),\n /** Since 1.1 (FIELDS_SINCE). */\n edits_failed: z.array(FsPatchEditFailure).max(256).optional(),\n});\n\n/** = daemon SearchPathRequest (/search/paths). */\nexport const FsSearchPathsParams = z\n .strictObject({\n pattern: z.string().min(1).max(512),\n cwd: AbsPath,\n hidden: z.boolean().default(false),\n max_results: z.int().min(1).max(5000).default(100),\n });\n/**\n * = the daemon's /search/paths answer (fd 8.3.1 in the sandbox image): paths RELATIVE to `cwd`, each\n * prefixed \"./\", sorted, cut to max_results. No truncation flag (the daemon has none).\n */\nexport const FsSearchPathsResult = z\n .strictObject({ paths: z.array(z.string().min(3).max(4096).regex(/^\\.\\/[^\\\\\\u0000]+$/)) });\n\n/** = daemon SearchContentRequest (/search/content). */\nexport const FsSearchContentParams = z\n .strictObject({\n query: z.string().min(1).max(1024),\n cwd: AbsPath,\n regex: z.boolean().default(true),\n case_sensitive: z.boolean().default(false),\n include: z.array(z.string().max(256)).max(64).optional(),\n exclude: z.array(z.string().max(256)).max(64).optional(),\n max_results: z.int().min(1).max(5000).default(100),\n });\n/**\n * = the daemon's /search/content answer (ripgrep 13 --json run in `cwd`): `path` RELATIVE to `cwd`\n * with no \"./\"; `lines` is the matching line with its newline; submatches are ripgrep's, byte\n * offsets within the line. max_results is per FILE (rg -m), as the daemon passes it. No truncation\n * flag (the daemon has none).\n */\nexport const FsSearchContentResult = z\n .strictObject({\n results: z.array(\n z.strictObject({\n path: z.string().min(1).max(4096).regex(/^[^/\\\\\\u0000][^\\\\\\u0000]*$/),\n lines: z.string(),\n line_number: z.int().min(1),\n submatches: z.array(\n z.strictObject({ match: z.strictObject({ text: z.string() }), start: nonNegInt, end: nonNegInt }),\n ),\n }),\n ),\n });\n\nexport const FsChange = z\n .strictObject({\n type: z.enum([\"created\", \"modified\", \"deleted\", \"moved\"]),\n path: AbsPath,\n to_path: AbsPath.optional(),\n kind: z.enum([\"file\", \"dir\", \"symlink\", \"unknown\"]),\n });\nexport const FsChangedEvent = z\n .strictObject({ changes: z.array(FsChange).min(1).max(1000), overflow: z.boolean() }); // overflow:true = events dropped; client re-lists\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type FsKind = z.output<typeof FsKind>;\nexport type FsEntry = z.output<typeof FsEntry>;\nexport type FsListParams = z.output<typeof FsListParams>;\nexport type FsListResult = z.output<typeof FsListResult>;\nexport type FsStatParams = z.output<typeof FsStatParams>;\nexport type FsStatResult = z.output<typeof FsStatResult>;\nexport type FsEncoding = z.output<typeof FsEncoding>;\nexport type FsReadParams = z.output<typeof FsReadParams>;\nexport type FsReadResult = z.output<typeof FsReadResult>;\nexport type FsReadStreamParams = z.output<typeof FsReadStreamParams>;\nexport type FsReadStreamResult = z.output<typeof FsReadStreamResult>;\nexport type FsWriteParams = z.output<typeof FsWriteParams>;\nexport type FsWriteResult = z.output<typeof FsWriteResult>;\nexport type FsMkdirParams = z.output<typeof FsMkdirParams>;\nexport type FsMkdirResult = z.output<typeof FsMkdirResult>;\nexport type FsMoveParams = z.output<typeof FsMoveParams>;\nexport type FsMoveResult = z.output<typeof FsMoveResult>;\nexport type FsDeleteParams = z.output<typeof FsDeleteParams>;\nexport type FsDeleteResult = z.output<typeof FsDeleteResult>;\nexport type FsWatchParams = z.output<typeof FsWatchParams>;\nexport type FsWatchResult = z.output<typeof FsWatchResult>;\nexport type FsPatchParams = z.output<typeof FsPatchParams>;\nexport type FsPatchResult = z.output<typeof FsPatchResult>;\nexport type FsPatchEditApplied = z.output<typeof FsPatchEditApplied>;\nexport type FsSearchPathsParams = z.output<typeof FsSearchPathsParams>;\nexport type FsSearchPathsResult = z.output<typeof FsSearchPathsResult>;\nexport type FsSearchContentParams = z.output<typeof FsSearchContentParams>;\nexport type FsSearchContentResult = z.output<typeof FsSearchContentResult>;\nexport type FsChange = z.output<typeof FsChange>;\nexport type FsChangedEvent = z.output<typeof FsChangedEvent>;\n","/** @ai-matrx/desktop-protocol — cap exec. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport { AbsPath, ResourceId, epochMs, nonNegInt, u32 } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// exec — PTY sessions (resources) + one-shot run\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const Signal = z\n .enum([\"SIGINT\", \"SIGTERM\", \"SIGKILL\", \"SIGHUP\", \"SIGQUIT\", \"SIGTSTP\", \"SIGCONT\", \"SIGUSR1\", \"SIGUSR2\"]); // Windows: SIGINT→Ctrl-C event, SIGTERM/SIGKILL/SIGHUP→terminate, others PLATFORM_UNSUPPORTED\n\nconst cols = z.int().min(2).max(1000);\nconst rows = z.int().min(1).max(500);\n\n/**\n * Start a PTY. Response result = PtyInfo; the same request id then carries the output stream:\n * stream{meta:{kind:\"open\",sid,resource_id}} → DATA frames (credited) → end{reason}.\n * Input goes as STDIN frames on that sid (cheap per keystroke) or via exec.pty.write.\n */\nexport const ExecPtyStartParams = z\n .strictObject({\n cols,\n rows,\n cwd: AbsPath.optional(), // default: home\n shell: z.string().max(512).optional(), // default: user's login shell (PowerShell on Windows)\n args: z.array(z.string().max(4096)).max(64).optional(),\n env: z.record(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).max(128), z.string().max(32_768)).optional(),\n name: z.string().max(64).optional(), // tab label\n window_bytes: z.int().min(4096).max(16_777_216).optional(),\n });\n\nexport const PtyInfo = z\n .strictObject({\n resource_id: ResourceId,\n pid: z.int().min(1),\n shell: z.string().max(512),\n cwd: AbsPath, // live, from OSC 7 / process cwd\n title: z.string().max(256),\n name: z.string().max(64).nullable(),\n cols,\n rows,\n state: z.enum([\"running\", \"exited\"]),\n exit_code: z.int().nullable(),\n exit_signal: Signal.nullable(),\n last_seq: u32,\n created_at_ms: epochMs,\n controller_client_id: z.string().max(64).nullable(), // null = orphaned (in grace period)\n attached_clients: nonNegInt,\n orphan_expires_at_ms: epochMs.nullable(),\n });\n\nexport const ExecPtyStartResult = PtyInfo;\n\nexport const ExecPtyWriteParams = z\n .strictObject({ resource_id: ResourceId, data: z.string().min(1).max(65_536) });\nexport const ExecPtyWriteResult = z.strictObject({ written: nonNegInt });\n\nexport const ExecPtyResizeParams = z\n .strictObject({ resource_id: ResourceId, cols, rows });\nexport const ExecPtyResizeResult = z.strictObject({ cols, rows });\n\n/** Delivered to the PTY's foreground process group (daemon parity: tcgetpgrp + killpg). */\nexport const ExecPtySignalParams = z\n .strictObject({ resource_id: ResourceId, signal: Signal });\nexport const ExecPtySignalResult = z.strictObject({ delivered: z.boolean() });\n\n/** SIGHUP the session, SIGKILL after grace_ms, reap, free the resource. Idempotent. */\nexport const ExecPtyKillParams = z\n .strictObject({ resource_id: ResourceId, grace_ms: z.int().min(0).max(30_000).default(2000) });\nexport const ExecPtyKillResult = z\n .strictObject({ exit_code: z.int().nullable(), exit_signal: Signal.nullable() });\n\nexport const ExecListParams = z.strictObject({});\nexport const ExecListResult = z.strictObject({ sessions: z.array(PtyInfo) });\n\n/**\n * One-shot command (agents, via _sandbox_proxy → /exec). Timeout ENFORCED (exit 124, daemon\n * convention). cwd is sticky per cwd_key: a later run with the same key and no cwd starts where\n * the last one ended (SPEC §6.1: \"cd sub && pwd\" then \"pwd\").\n */\nexport const ExecRunParams = z\n .strictObject({\n command: z.string().min(1).max(131_072),\n cwd: AbsPath.optional(),\n cwd_key: z.string().max(128).optional(),\n env: z.record(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).max(128), z.string().max(32_768)).optional(),\n stdin: z.string().max(1_048_576).optional(),\n timeout: z.int().min(1).max(3600).default(60), // seconds, daemon parity\n max_output_bytes: z.int().min(1024).max(8_388_608).default(1_048_576),\n });\nexport const ExecRunResult = z\n .strictObject({\n exit_code: z.int(),\n stdout: z.string(),\n stderr: z.string(),\n cwd: AbsPath,\n duration_ms: nonNegInt,\n timed_out: z.boolean(),\n output_truncated: z.boolean(),\n });\n\nexport const ExecExitedEvent = z\n .strictObject({ exit_code: z.int().nullable(), exit_signal: Signal.nullable() });\nexport const ExecTitleEvent = z.strictObject({ title: z.string().max(256) });\nexport const ExecCwdEvent = z.strictObject({ cwd: AbsPath });\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type Signal = z.output<typeof Signal>;\nexport type ExecPtyStartParams = z.output<typeof ExecPtyStartParams>;\nexport type PtyInfo = z.output<typeof PtyInfo>;\nexport type ExecPtyStartResult = z.output<typeof ExecPtyStartResult>;\nexport type ExecPtyWriteParams = z.output<typeof ExecPtyWriteParams>;\nexport type ExecPtyWriteResult = z.output<typeof ExecPtyWriteResult>;\nexport type ExecPtyResizeParams = z.output<typeof ExecPtyResizeParams>;\nexport type ExecPtyResizeResult = z.output<typeof ExecPtyResizeResult>;\nexport type ExecPtySignalParams = z.output<typeof ExecPtySignalParams>;\nexport type ExecPtySignalResult = z.output<typeof ExecPtySignalResult>;\nexport type ExecPtyKillParams = z.output<typeof ExecPtyKillParams>;\nexport type ExecPtyKillResult = z.output<typeof ExecPtyKillResult>;\nexport type ExecListParams = z.output<typeof ExecListParams>;\nexport type ExecListResult = z.output<typeof ExecListResult>;\nexport type ExecRunParams = z.output<typeof ExecRunParams>;\nexport type ExecRunResult = z.output<typeof ExecRunResult>;\nexport type ExecExitedEvent = z.output<typeof ExecExitedEvent>;\nexport type ExecTitleEvent = z.output<typeof ExecTitleEvent>;\nexport type ExecCwdEvent = z.output<typeof ExecCwdEvent>;\n","/** @ai-matrx/desktop-protocol — cap session. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport { PtyInfo } from \"./exec\";\nimport { AbsPath, ResourceId, epochMs, u32 } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// session — generic resource ownership (SPEC §3.3). One attach/detach for EVERY resource kind.\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Reattach after a drop. mode \"control\" by the same user takes control (previous controller is\n * demoted to read_only and gets session.control_changed). since_seq = last seq the client\n * rendered: frames (since_seq, last_seq] are replayed from the ring with the REPLAY flag; if they\n * have left the ring, stream{gap} + stream{snapshot} + SNAPSHOT frames come first.\n * Response = PtyInfo|FsWatchResult-shaped ResourceInfo; then the stream continues on a new sid.\n */\nexport const SessionAttachParams = z\n .strictObject({\n resource_id: ResourceId,\n mode: z.enum([\"control\", \"read_only\"]).default(\"control\"),\n since_seq: u32.optional(),\n window_bytes: z.int().min(4096).max(16_777_216).optional(),\n });\n\nexport const ResourceInfo = z\n .discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"pty\"), pty: PtyInfo }),\n z.strictObject({\n kind: z.literal(\"watch\"),\n resource_id: ResourceId,\n path: AbsPath,\n orphan_expires_at_ms: epochMs.nullable(),\n }),\n ]);\nexport const SessionAttachResult = ResourceInfo;\n\n/** Leave the resource running (orphan grace starts if no other client controls it). */\nexport const SessionDetachParams = z.strictObject({ resource_id: ResourceId });\nexport const SessionDetachResult = z\n .strictObject({ orphan_expires_at_ms: epochMs.nullable() });\n\n/** Free a resource through its owner's cancel path (watch → unwatch; pty → exec.pty.kill). */\nexport const SessionReleaseParams = z.strictObject({ resource_id: ResourceId });\nexport const SessionReleaseResult = z.strictObject({ released: z.literal(true) });\n\nexport const SessionListParams = z.strictObject({});\nexport const SessionListResult = z.strictObject({ resources: z.array(ResourceInfo) });\n\nexport const SessionControlChangedEvent = z\n .strictObject({ controller_client_id: z.string().max(64).nullable(), your_mode: z.enum([\"control\", \"read_only\"]) });\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type SessionAttachParams = z.output<typeof SessionAttachParams>;\nexport type ResourceInfo = z.output<typeof ResourceInfo>;\nexport type SessionAttachResult = z.output<typeof SessionAttachResult>;\nexport type SessionDetachParams = z.output<typeof SessionDetachParams>;\nexport type SessionDetachResult = z.output<typeof SessionDetachResult>;\nexport type SessionReleaseParams = z.output<typeof SessionReleaseParams>;\nexport type SessionReleaseResult = z.output<typeof SessionReleaseResult>;\nexport type SessionListParams = z.output<typeof SessionListParams>;\nexport type SessionListResult = z.output<typeof SessionListResult>;\nexport type SessionControlChangedEvent = z.output<typeof SessionControlChangedEvent>;\n","/**\n * @ai-matrx/desktop-protocol — the `models` capability (SPEC §6): local AI models on the device,\n * served by Matrx 2's `ml` Python service (SPEC §3.10). Schema source: lint-enforced rules in\n * scripts/check-schema-source.mjs.\n *\n * Two contracts share these shapes, both generated from this file (SPEC P11):\n * - the Router ops `models.*` (every transport: relay, localhost, extension, the app's screen);\n * - the internal service ops `ml.*` between the desktop core and the Python service\n * (src/schema/service.ts, `SERVICES` in registry.ts). A forwarded op uses the SAME named\n * schema on both hops, so the two can never disagree.\n */\nimport { z } from \"zod\";\nimport { AbsPath, RequestId, nonNegInt } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Transcription (local Whisper)\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** Whisper sizes the device can run (CTranslate2 weights). Larger = slower, more accurate. */\nexport const TranscriptionModelId = z.enum([\"tiny\", \"base\", \"small\", \"large-v3-turbo\"]);\n\n/** The heavy runtime (inference packages) is installed on first use, never shipped in the app. */\nexport const MlRuntimeState = z.enum([\"not_installed\", \"installing\", \"installed\", \"failed\"]);\n\n/** `packages`: the locked inference wheels; `model`: one model's weights; `verifying`: hashes and a load test. */\nexport const MlInstallPhase = z.enum([\"packages\", \"model\", \"verifying\"]);\n\nexport const MlInstallProgress = z.strictObject({\n phase: MlInstallPhase,\n /** What is being fetched now: a package or a model file name. */\n item: z.string().max(200),\n bytes_done: nonNegInt,\n /** Null while the total is not known yet. */\n bytes_total: nonNegInt.nullable(),\n});\n\nexport const TranscriptionModelInfo = z.strictObject({\n id: TranscriptionModelId,\n /** Download size of the weights. */\n size_bytes: nonNegInt,\n multilingual: z.boolean(),\n installed: z.boolean(),\n});\n\nexport const TranscriptSegment = z.strictObject({\n start_s: z.number().min(0),\n end_s: z.number().min(0),\n text: z.string().max(4000),\n});\n\n/** What the `ml` service itself reports (the core adds the supervisor's view in ModelsStatusResult). */\nexport const MlStatusParams = z.strictObject({});\nexport const MlStatusResult = z.strictObject({\n runtime: MlRuntimeState,\n /** Non-null while runtime or model files are being installed. */\n install: MlInstallProgress.nullable(),\n /** The last install failure, one human line; null when the last install succeeded or none ran. */\n error: z.string().max(300).nullable(),\n /** Where inference runs once the runtime is installed: `cuda` only when a usable GPU is present. */\n accelerator: z.enum([\"cpu\", \"cuda\"]),\n models: z.array(TranscriptionModelInfo).max(16),\n default_model: TranscriptionModelId,\n});\n\n/** Install the runtime (if missing) and one model's weights (default: the default model). */\nexport const ModelsInstallParams = z.strictObject({ model: TranscriptionModelId.optional() });\nexport const ModelsInstallResult = z.strictObject({ model: TranscriptionModelId, elapsed_ms: nonNegInt });\n\n/**\n * Transcribe an audio or video file on the device. Any format the bundled decoder reads (wav, mp3,\n * m4a, webm/opus, mp4…). `language` is ISO 639-1; omitted = detect. `translate` = into English.\n */\nexport const ModelsTranscribeParams = z.strictObject({\n path: AbsPath,\n model: TranscriptionModelId.optional(),\n language: z\n .string()\n .regex(/^[a-z]{2,3}$/)\n .optional(),\n task: z.enum([\"transcribe\", \"translate\"]).default(\"transcribe\"),\n});\nexport const ModelsTranscribeResult = z.strictObject({\n text: z.string().max(400_000),\n language: z.string().max(8),\n language_probability: z.number().min(0).max(1),\n duration_s: z.number().min(0),\n model: TranscriptionModelId,\n segments: z.array(TranscriptSegment).max(20_000),\n elapsed_ms: nonNegInt,\n});\n\n/** A progress report while `ml.install` / `ml.transcribe` runs. */\nexport const MlProgress = z.strictObject({\n kind: z.enum([\"install\", \"transcribe\"]),\n /** 0–1 when known (transcribe: audio covered so far; install: bytes so far). */\n fraction: z.number().min(0).max(1).nullable(),\n install: MlInstallProgress.nullable(),\n /** The segment just transcribed (transcribe only): text appears as it is recognised. */\n segment: TranscriptSegment.nullable(),\n});\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Router ops (`models.*`)\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** The supervisor's view of the `ml` service process. */\nexport const MlServiceState = z.enum([\"starting\", \"ready\", \"restarting\", \"failed\", \"stopped\"]);\n\nexport const MlServiceStatus = z.strictObject({\n state: MlServiceState,\n pid: nonNegInt.nullable(),\n /** Restarts since the app started (crashes, missed health checks). */\n restarts: nonNegInt,\n /** The bundled interpreter's version once the service has answered, e.g. \"3.13.15\". */\n python: z.string().max(32).nullable(),\n /** Why the service is restarting or failed, one human line. */\n error: z.string().max(300).nullable(),\n});\n\nexport const ModelsStatusParams = z.strictObject({});\nexport const ModelsStatusResult = z.strictObject({\n service: MlServiceStatus,\n /** Null until the service has answered (starting, restarting, failed). */\n transcription: MlStatusResult.nullable(),\n});\n\n/** Sent to the client that started a `models.install` or `models.transcribe`, for that request. */\nexport const ModelsProgressEvent = z.strictObject({ request_id: RequestId, progress: MlProgress });\n\nexport type TranscriptionModelId = z.output<typeof TranscriptionModelId>;\nexport type MlStatusResult = z.output<typeof MlStatusResult>;\nexport type MlProgress = z.output<typeof MlProgress>;\nexport type ModelsStatusResult = z.output<typeof ModelsStatusResult>;\nexport type ModelsTranscribeParams = z.output<typeof ModelsTranscribeParams>;\nexport type ModelsTranscribeResult = z.output<typeof ModelsTranscribeResult>;\nexport type ModelsInstallParams = z.output<typeof ModelsInstallParams>;\nexport type ModelsInstallResult = z.output<typeof ModelsInstallResult>;\nexport type ModelsProgressEvent = z.output<typeof ModelsProgressEvent>;\nexport type TranscriptSegment = z.output<typeof TranscriptSegment>;\n","/** @ai-matrx/desktop-protocol — cap relay. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport { ProtocolErrorBody } from \"./errors\";\nimport { ProtocolVersion, epochMs } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// relay — events the relay itself emits to clients (cap \"relay\")\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const RelayDeviceStatusEvent = z\n .strictObject({\n online: z.boolean(),\n /**\n * When the device last went online/offline; null = it has never connected (since 1.1 —\n * NULL_SINCE: a 1.0 reader is sent 0, its old meaning).\n */\n since_ms: epochMs.nullable(),\n app_version: z.string().max(32).nullable(),\n protocol_version: ProtocolVersion.nullable(),\n });\nexport const RelayAuthExpiringEvent = z\n .strictObject({ expires_at_ms: epochMs });\n\n/** HTTP POST https://relay.matrxserver.com/v1/devices/{device_id}/call — unary ops only (lane F). */\nexport const RelayCallRequest = z\n .strictObject({\n cap: z.string().min(1).max(32),\n op: z.string().min(1).max(64),\n params: z.unknown(),\n timeout_ms: z.int().min(100).max(3_700_000).default(70_000),\n });\n/**\n * The caller of /call announces the newest protocol it reads in this request header; the relay\n * includes fields newer than 1.0 only when the announced version knows them (src/versioning.ts).\n */\nexport const RELAY_CALL_VERSION_HEADER = \"x-matrx-protocol-version\" as const;\n\nexport const RelayCallResponse = z\n .discriminatedUnion(\"ok\", [\n z.strictObject({\n ok: z.literal(true),\n result: z.unknown(),\n /** Since 1.1: the version the device negotiated for this call (its welcome). */\n protocol_version: ProtocolVersion.optional(),\n }),\n z.strictObject({\n ok: z.literal(false),\n error: ProtocolErrorBody,\n /** Since 1.1, as above (absent when the device never answered hello). */\n protocol_version: ProtocolVersion.optional(),\n }),\n ]);\n\n/**\n * How the relay runs one /call on the device: a fresh cid (its own connection) carrying exactly\n * RelayCallHello then RelayCallEnvelope, answered on that cid by response/error with id \"call\"\n * (an error on id \"hello\" also ends it), then a connection-end frame. A stream answer is refused.\n */\nexport const RELAY_CALL_HELLO_ID = \"hello\" as const;\nexport const RELAY_CALL_REQUEST_ID = \"call\" as const;\n\nexport const RelayCallHello = z\n .strictObject({\n type: z.literal(\"hello\"),\n id: z.literal(RELAY_CALL_HELLO_ID),\n protocolVersion: ProtocolVersion,\n clientType: z.literal(\"server\"),\n clientVersion: z.string().min(1).max(32),\n });\nexport const RelayCallEnvelope = z\n .strictObject({\n id: z.literal(RELAY_CALL_REQUEST_ID),\n type: z.literal(\"request\"),\n cap: z.string().min(1).max(32),\n op: z.string().min(1).max(64),\n params: z.unknown(),\n });\n\n/** HTTP GET /v1/devices/{device_id}/status (owner JWT). */\nexport const RelayStatusResponse = RelayDeviceStatusEvent;\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type RelayDeviceStatusEvent = z.output<typeof RelayDeviceStatusEvent>;\nexport type RelayAuthExpiringEvent = z.output<typeof RelayAuthExpiringEvent>;\nexport type RelayCallRequest = z.output<typeof RelayCallRequest>;\nexport type RelayCallResponse = z.output<typeof RelayCallResponse>;\nexport type RelayStatusResponse = z.output<typeof RelayStatusResponse>;\nexport type RelayCallHello = z.output<typeof RelayCallHello>;\nexport type RelayCallEnvelope = z.output<typeof RelayCallEnvelope>;\n","/**\n * @ai-matrx/desktop-protocol — cap clipboard (SPEC §6): the system clipboard's text. Schema source:\n * lint-enforced rules in scripts/check-schema-source.mjs. Added in protocol 1.3.\n */\nimport { z } from \"zod\";\nimport { nonNegInt } from \"./primitives\";\n\nexport const ClipboardReadParams = z.strictObject({});\nexport const ClipboardReadResult = z.strictObject({\n /** The clipboard's text (\"\" when it holds none), cut to 1 MiB. */\n text: z.string().max(1_048_576),\n truncated: z.boolean(),\n});\n\nexport const ClipboardWriteParams = z.strictObject({ text: z.string().max(1_048_576) });\nexport const ClipboardWriteResult = z.strictObject({ bytes: nonNegInt });\n\nexport type ClipboardReadResult = z.output<typeof ClipboardReadResult>;\nexport type ClipboardWriteParams = z.output<typeof ClipboardWriteParams>;\nexport type ClipboardWriteResult = z.output<typeof ClipboardWriteResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap proc (SPEC §6): the processes running on the person's computer,\n * the ports they listen on, and stopping one. Schema source: lint-enforced rules in\n * scripts/check-schema-source.mjs. Added in protocol 1.3.\n */\nimport { z } from \"zod\";\nimport { nonNegInt } from \"./primitives\";\n\nexport const ProcSort = z.enum([\"cpu\", \"memory\", \"pid\", \"name\"]);\n\nexport const ProcListParams = z.strictObject({\n /** Case-insensitive substring of the process name or its command line. */\n name: z.string().min(1).max(128).optional(),\n sort: ProcSort.default(\"cpu\"),\n limit: z.int().min(1).max(500).default(50),\n});\n\nexport const ProcInfo = z.strictObject({\n pid: z.int().min(0),\n /** Parent process id; null where the OS does not report it. */\n ppid: z.int().min(0).nullable(),\n name: z.string().max(256),\n /** The command line, cut to 1024 characters. */\n command: z.string().max(1024),\n /** Share of one core, as `ps` and Task Manager report it; null where the OS does not say. */\n cpu_percent: z.number().min(0).nullable(),\n memory_bytes: nonNegInt.nullable(),\n user: z.string().max(128).nullable(),\n});\n\nexport const ProcListResult = z.strictObject({\n processes: z.array(ProcInfo).max(500),\n /** Processes that matched before `limit`. */\n total: nonNegInt,\n truncated: z.boolean(),\n});\n\nexport const ProcPortsParams = z.strictObject({\n /** Only this port. */\n port: z.int().min(1).max(65535).optional(),\n});\n\nexport const ProcPort = z.strictObject({\n port: z.int().min(1).max(65535),\n protocol: z.enum([\"tcp\", \"udp\"]),\n /** The local address it listens on (\"127.0.0.1\", \"*\", \"::\"). */\n address: z.string().max(64),\n pid: z.int().min(0).nullable(),\n process: z.string().max(256).nullable(),\n});\n\nexport const ProcPortsResult = z.strictObject({ ports: z.array(ProcPort).max(4000) });\n\nexport const ProcKillParams = z.strictObject({\n pid: z.int().min(1),\n /** Kill outright (SIGKILL; on Windows the same /F) instead of asking it to quit. */\n force: z.boolean().default(false),\n});\n\nexport const ProcKillResult = z.strictObject({\n pid: z.int().min(1),\n signal: z.enum([\"SIGTERM\", \"SIGKILL\"]),\n /** True when the process was gone within 3 s. */\n exited: z.boolean(),\n});\n\nexport type ProcListParams = z.output<typeof ProcListParams>;\nexport type ProcListResult = z.output<typeof ProcListResult>;\nexport type ProcInfo = z.output<typeof ProcInfo>;\nexport type ProcPortsParams = z.output<typeof ProcPortsParams>;\nexport type ProcPortsResult = z.output<typeof ProcPortsResult>;\nexport type ProcPort = z.output<typeof ProcPort>;\nexport type ProcKillParams = z.output<typeof ProcKillParams>;\nexport type ProcKillResult = z.output<typeof ProcKillResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap system (SPEC §6): open a link or a file the way the person's\n * computer would, and show a notification. Schema source: lint-enforced rules in\n * scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\nimport { AbsPath } from \"./primitives\";\n\nexport const SystemOpenUrlParams = z.strictObject({\n /** http, https or mailto; opened in the person's default app for it. */\n url: z.string().min(1).max(4096),\n});\nexport const SystemOpenUrlResult = z.strictObject({ url: z.string().max(4096) });\n\nexport const SystemOpenPathParams = z.strictObject({\n path: AbsPath,\n /** Show it in the file manager (Finder, Explorer) instead of opening it. */\n reveal: z.boolean().default(false),\n});\nexport const SystemOpenPathResult = z.strictObject({ path: AbsPath, revealed: z.boolean() });\n\nexport const SystemNotifyParams = z.strictObject({\n title: z.string().min(1).max(128),\n body: z.string().max(1024).default(\"\"),\n});\nexport const SystemNotifyResult = z.strictObject({\n /** False when this computer has no notification service to show it (a bare Linux box). */\n shown: z.boolean(),\n});\n\nexport type SystemOpenUrlParams = z.output<typeof SystemOpenUrlParams>;\nexport type SystemOpenUrlResult = z.output<typeof SystemOpenUrlResult>;\nexport type SystemOpenPathParams = z.output<typeof SystemOpenPathParams>;\nexport type SystemOpenPathResult = z.output<typeof SystemOpenPathResult>;\nexport type SystemNotifyParams = z.output<typeof SystemNotifyParams>;\nexport type SystemNotifyResult = z.output<typeof SystemNotifyResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap screen (SPEC §6): the person's displays and a picture of one.\n * Schema source: lint-enforced rules in scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\nimport { nonNegInt } from \"./primitives\";\n\nexport const ScreenDisplay = z.strictObject({\n /** The OS's display id; pass it to screen.capture. */\n id: nonNegInt,\n name: z.string().max(128),\n /** Position and size in the OS's logical points (x and y may be negative left of or above the main display). */\n x: z.int(),\n y: z.int(),\n width: z.int().min(1),\n height: z.int().min(1),\n /** Pixels per point (2 on a Retina display). */\n scale: z.number().min(0.1).max(8),\n primary: z.boolean(),\n});\n\nexport const ScreenListParams = z.strictObject({});\nexport const ScreenListResult = z.strictObject({ displays: z.array(ScreenDisplay).max(32) });\n\nexport const ScreenCaptureParams = z.strictObject({\n /** The display (from screen.list); the primary display when absent. */\n display_id: nonNegInt.optional(),\n format: z.enum([\"jpeg\", \"png\"]).default(\"jpeg\"),\n /** Scale the picture down to at most this width in pixels (kept when already smaller). */\n max_width: z.int().min(160).max(7680).default(1600),\n});\nexport const ScreenCaptureResult = z.strictObject({\n display_id: nonNegInt,\n mime_type: z.enum([\"image/jpeg\", \"image/png\"]),\n width: z.int().min(1),\n height: z.int().min(1),\n /** The display's full resolution in pixels, before scaling. */\n source_width: z.int().min(1),\n source_height: z.int().min(1),\n /** The image, base64 (at most 6 MiB of text). */\n data_base64: z.string().max(6_291_456),\n});\n\nexport type ScreenDisplay = z.output<typeof ScreenDisplay>;\nexport type ScreenListResult = z.output<typeof ScreenListResult>;\nexport type ScreenCaptureParams = z.output<typeof ScreenCaptureParams>;\nexport type ScreenCaptureResult = z.output<typeof ScreenCaptureResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap window (SPEC §6): the windows on the person's screen; focus,\n * move or resize, and minimize one. Schema source: lint-enforced rules in\n * scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\nimport { nonNegInt } from \"./primitives\";\n\nexport const WindowInfo = z.strictObject({\n /** The OS's window handle (macOS window number, Windows HWND, X11 window id). */\n id: nonNegInt,\n title: z.string().max(512),\n /** Position and size in logical points. */\n x: z.int(),\n y: z.int(),\n width: z.int().min(0),\n height: z.int().min(0),\n});\n\nexport const WindowListParams = z.strictObject({\n /** Case-insensitive substring of the window title. */\n title: z.string().min(1).max(256).optional(),\n limit: z.int().min(1).max(500).default(100),\n});\nexport const WindowListResult = z.strictObject({\n windows: z.array(WindowInfo).max(500),\n total: nonNegInt,\n truncated: z.boolean(),\n});\n\nexport const WindowFocusParams = z.strictObject({ id: nonNegInt });\nexport const WindowFocusResult = z.strictObject({ window: WindowInfo });\n\nexport const WindowMoveParams = z.strictObject({\n id: nonNegInt,\n /** New top-left corner; unchanged when absent. */\n x: z.int().optional(),\n y: z.int().optional(),\n /** New size; unchanged when absent. */\n width: z.int().min(50).max(16_384).optional(),\n height: z.int().min(50).max(16_384).optional(),\n});\nexport const WindowMoveResult = z.strictObject({ window: WindowInfo });\n\nexport const WindowMinimizeParams = z.strictObject({ id: nonNegInt });\nexport const WindowMinimizeResult = z.strictObject({ id: nonNegInt });\n\nexport type WindowInfo = z.output<typeof WindowInfo>;\nexport type WindowListParams = z.output<typeof WindowListParams>;\nexport type WindowListResult = z.output<typeof WindowListResult>;\nexport type WindowFocusParams = z.output<typeof WindowFocusParams>;\nexport type WindowFocusResult = z.output<typeof WindowFocusResult>;\nexport type WindowMoveParams = z.output<typeof WindowMoveParams>;\nexport type WindowMoveResult = z.output<typeof WindowMoveResult>;\nexport type WindowMinimizeParams = z.output<typeof WindowMinimizeParams>;\nexport type WindowMinimizeResult = z.output<typeof WindowMinimizeResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap input (SPEC §6): the keyboard and mouse, as if the person used\n * them. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\n\n/** Key names for input.hotkey. `cmd` is Command on a Mac and Ctrl elsewhere; `meta` is the Windows/Super key. */\nexport const InputKey = z.enum([\n \"cmd\", \"ctrl\", \"alt\", \"shift\", \"meta\",\n \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\",\n \"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\",\n \"f1\", \"f2\", \"f3\", \"f4\", \"f5\", \"f6\", \"f7\", \"f8\", \"f9\", \"f10\", \"f11\", \"f12\",\n \"enter\", \"tab\", \"escape\", \"space\", \"backspace\", \"delete\",\n \"up\", \"down\", \"left\", \"right\", \"home\", \"end\", \"pageup\", \"pagedown\",\n \"minus\", \"equal\", \"comma\", \"period\", \"slash\", \"semicolon\", \"quote\", \"bracketleft\", \"bracketright\", \"backslash\", \"grave\",\n]);\n\nexport const InputTypeTextParams = z.strictObject({ text: z.string().min(1).max(10_000) });\nexport const InputTypeTextResult = z.strictObject({ characters: z.int().min(1) });\n\nexport const InputHotkeyParams = z.strictObject({\n /** Pressed together in order and released in reverse: [\"cmd\", \"shift\", \"t\"]. */\n keys: z.array(InputKey).min(1).max(6),\n});\nexport const InputHotkeyResult = z.strictObject({ keys: z.array(InputKey) });\n\nexport const InputPoint = z.strictObject({ x: z.int(), y: z.int() });\n\nexport const InputMouseMoveParams = z.strictObject({\n /** Screen position in logical points (the coordinates screen.list and window.list report). */\n x: z.int(),\n y: z.int(),\n});\nexport const InputMouseMoveResult = z.strictObject({\n /** Where the pointer is now, read back from the OS. */\n position: InputPoint,\n});\n\nexport const InputMouseClickParams = z.strictObject({\n /** Move here first; clicks where the pointer is when absent. */\n x: z.int().optional(),\n y: z.int().optional(),\n button: z.enum([\"left\", \"right\", \"middle\"]).default(\"left\"),\n double: z.boolean().default(false),\n});\nexport const InputMouseClickResult = z.strictObject({\n position: InputPoint,\n button: z.enum([\"left\", \"right\", \"middle\"]),\n double: z.boolean(),\n});\n\nexport type InputKey = z.output<typeof InputKey>;\nexport type InputPoint = z.output<typeof InputPoint>;\nexport type InputTypeTextParams = z.output<typeof InputTypeTextParams>;\nexport type InputTypeTextResult = z.output<typeof InputTypeTextResult>;\nexport type InputHotkeyParams = z.output<typeof InputHotkeyParams>;\nexport type InputHotkeyResult = z.output<typeof InputHotkeyResult>;\nexport type InputMouseMoveParams = z.output<typeof InputMouseMoveParams>;\nexport type InputMouseMoveResult = z.output<typeof InputMouseMoveResult>;\nexport type InputMouseClickParams = z.output<typeof InputMouseClickParams>;\nexport type InputMouseClickResult = z.output<typeof InputMouseClickResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap power (SPEC §6): the battery and keeping the computer awake.\n * Schema source: lint-enforced rules in scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\nimport { epochMs, nonNegInt } from \"./primitives\";\n\nexport const PowerStatusParams = z.strictObject({});\nexport const PowerStatusResult = z.strictObject({\n has_battery: z.boolean(),\n /** 0–100; null without a battery. */\n percent: z.number().min(0).max(100).nullable(),\n charging: z.boolean().nullable(),\n /** On wall power; null where the OS does not say. */\n plugged_in: z.boolean().nullable(),\n /** Minutes of battery left; null when charging, unknown or without a battery. */\n minutes_left: nonNegInt.nullable(),\n /** Matrx 2 is keeping the computer awake (power.prevent_sleep) until this time; null when it is not. */\n awake_until_ms: epochMs.nullable(),\n});\n\nexport const PowerPreventSleepParams = z.strictObject({\n /** Keep the computer awake this long; 0 lets it sleep again now. */\n seconds: z.int().min(0).max(86_400),\n /** Shown where the OS lists what keeps it awake. */\n reason: z.string().min(1).max(128).default(\"Matrx 2 is working\"),\n});\nexport const PowerPreventSleepResult = z.strictObject({\n /** When it may sleep again; null after seconds 0. */\n awake_until_ms: epochMs.nullable(),\n});\n\nexport type PowerStatusResult = z.output<typeof PowerStatusResult>;\nexport type PowerPreventSleepParams = z.output<typeof PowerPreventSleepParams>;\nexport type PowerPreventSleepResult = z.output<typeof PowerPreventSleepResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap audio (SPEC §6): the person's microphones and speakers; record a\n * clip to a file, play a file. Speech to text is models.transcribe. Schema source: lint-enforced\n * rules in scripts/check-schema-source.mjs. Added in protocol 1.6.\n */\nimport { z } from \"zod\";\nimport { AbsPath, nonNegInt } from \"./primitives\";\n\nexport const AudioDevice = z.strictObject({\n /** The OS's name for it, as audio.record takes it. */\n id: z.string().min(1).max(256),\n name: z.string().max(256),\n default: z.boolean(),\n});\n\nexport const AudioDevicesParams = z.strictObject({});\nexport const AudioDevicesResult = z.strictObject({\n inputs: z.array(AudioDevice).max(64),\n outputs: z.array(AudioDevice).max(64),\n});\n\nexport const AudioRecordParams = z.strictObject({\n seconds: z.number().min(0.5).max(600),\n /** The microphone (from audio.devices); the default input when absent. */\n device_id: z.string().min(1).max(256).optional(),\n /** Where the WAV file goes; a new file in the temp folder when absent. */\n path: AbsPath.optional(),\n});\nexport const AudioRecordResult = z.strictObject({\n path: AbsPath,\n seconds: z.number().min(0),\n bytes: nonNegInt,\n /** Loudest sample, 0–1: 0 means the device gave silence. */\n peak: z.number().min(0).max(1),\n});\n\nexport const AudioPlayParams = z.strictObject({ path: AbsPath });\nexport const AudioPlayResult = z.strictObject({ path: AbsPath, seconds: z.number().min(0) });\n\nexport type AudioDevice = z.output<typeof AudioDevice>;\nexport type AudioDevicesResult = z.output<typeof AudioDevicesResult>;\nexport type AudioRecordParams = z.output<typeof AudioRecordParams>;\nexport type AudioRecordResult = z.output<typeof AudioRecordResult>;\nexport type AudioPlayParams = z.output<typeof AudioPlayParams>;\nexport type AudioPlayResult = z.output<typeof AudioPlayResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap resources (SPEC §6): how busy the computer is — CPU, memory and\n * disks. The busiest processes are proc.list. Schema source: lint-enforced rules in\n * scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\nimport { nonNegInt } from \"./primitives\";\n\nexport const ResourcesDisk = z.strictObject({\n /** Where it is mounted (\"/\", \"C:\"). */\n mount: z.string().max(512),\n /** The file system (\"apfs\", \"NTFS\", \"ext4\"). */\n fs: z.string().max(64),\n size_bytes: nonNegInt,\n used_bytes: nonNegInt,\n available_bytes: nonNegInt,\n});\n\nexport const ResourcesSnapshotParams = z.strictObject({});\nexport const ResourcesSnapshotResult = z.strictObject({\n cpu: z.strictObject({\n /** Busy share of all cores, 0–100, measured now. */\n percent: z.number().min(0).max(100),\n cores: z.int().min(1),\n /** 1, 5 and 15 minute load averages; null on Windows. */\n load: z.array(z.number().min(0)).length(3).nullable(),\n }),\n memory: z.strictObject({ total_bytes: nonNegInt, used_bytes: nonNegInt, available_bytes: nonNegInt }),\n swap: z.strictObject({ total_bytes: nonNegInt, used_bytes: nonNegInt }),\n disks: z.array(ResourcesDisk).max(64),\n uptime_seconds: nonNegInt,\n});\n\nexport type ResourcesDisk = z.output<typeof ResourcesDisk>;\nexport type ResourcesSnapshotResult = z.output<typeof ResourcesSnapshotResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap fs, polled watches (SPEC §6): watch a folder and read what\n * changed since the last read, for callers that ask rather than hold a stream (an agent's tool\n * call through the relay's /call). The streamed `fs.watch` resource stays for live clients. Schema\n * source: lint-enforced rules in scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\nimport { FsChange } from \"./fs\";\nimport { AbsPath, epochMs } from \"./primitives\";\n\nexport const FsWatchId = z.string().regex(/^fw_[A-Za-z0-9]{12,40}$/);\n\nexport const FsWatchStartParams = z.strictObject({\n path: AbsPath,\n recursive: z.boolean().default(true),\n /** Globs relative to `path` whose changes are not reported (\".git/**\", \"node_modules/**\"). */\n ignore: z.array(z.string().max(256)).max(64).default([]),\n});\nexport const FsWatchStartResult = z.strictObject({\n watch_id: FsWatchId,\n path: AbsPath,\n /** The watch ends by itself if nobody reads it for 30 minutes. */\n expires_at_ms: epochMs,\n});\n\nexport const FsWatchEventsParams = z.strictObject({\n watch_id: FsWatchId,\n /** Wait up to this long for a first change when none is waiting (0 answers at once). */\n wait_ms: z.int().min(0).max(25_000).default(0),\n});\nexport const FsWatchEventsResult = z.strictObject({\n /** What changed since the last read, oldest first; re-checked against the disk when read. */\n changes: z.array(FsChange).max(1000),\n /** Changes were dropped (more than 1000 waited): list the folder again. */\n overflow: z.boolean(),\n expires_at_ms: epochMs,\n});\n\nexport const FsWatchStopParams = z.strictObject({ watch_id: FsWatchId });\nexport const FsWatchStopResult = z.strictObject({ watch_id: FsWatchId });\n\nexport type FsWatchId = z.output<typeof FsWatchId>;\nexport type FsWatchStartParams = z.output<typeof FsWatchStartParams>;\nexport type FsWatchStartResult = z.output<typeof FsWatchStartResult>;\nexport type FsWatchEventsParams = z.output<typeof FsWatchEventsParams>;\nexport type FsWatchEventsResult = z.output<typeof FsWatchEventsResult>;\nexport type FsWatchStopParams = z.output<typeof FsWatchStopParams>;\nexport type FsWatchStopResult = z.output<typeof FsWatchStopResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap exec, background jobs (SPEC §6): start a command that keeps\n * running (a dev server, a long build), read its output later, stop it. Schema source:\n * lint-enforced rules in scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\nimport { AbsPath, epochMs, nonNegInt } from \"./primitives\";\n\nexport const ExecJobId = z.string().regex(/^job_[A-Za-z0-9]{12,40}$/);\n\nexport const ExecJobStartParams = z.strictObject({\n command: z.string().min(1).max(131_072),\n /** The folder it runs in; the home folder when absent. */\n cwd: AbsPath.optional(),\n env: z.record(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).max(128), z.string().max(32_768)).optional(),\n});\nexport const ExecJobStartResult = z.strictObject({ job_id: ExecJobId, pid: z.int().min(1), cwd: AbsPath });\n\nexport const ExecJobOutputParams = z.strictObject({\n job_id: ExecJobId,\n /** Byte offset into the job's output to read from (next_offset of the last read; 0 = the start). */\n offset: nonNegInt.default(0),\n /** Wait up to this long for new output or the exit when none is waiting (0 answers at once). */\n wait_ms: z.int().min(0).max(25_000).default(0),\n max_bytes: z.int().min(1024).max(1_048_576).default(65_536),\n});\nexport const ExecJobOutputResult = z.strictObject({\n /** stdout and stderr interleaved as they arrived (UTF-8). */\n output: z.string(),\n next_offset: nonNegInt,\n /** Bytes before `offset` that are gone (the job keeps its last 4 MiB). */\n dropped_bytes: nonNegInt,\n running: z.boolean(),\n exit_code: z.int().nullable(),\n});\n\nexport const ExecJobStopParams = z.strictObject({\n job_id: ExecJobId,\n /** End it at once (SIGKILL; on Windows the whole tree with /F) instead of asking it to quit. */\n force: z.boolean().default(false),\n});\nexport const ExecJobStopResult = z.strictObject({ job_id: ExecJobId, exited: z.boolean(), exit_code: z.int().nullable() });\n\nexport const ExecJobInfo = z.strictObject({\n job_id: ExecJobId,\n command: z.string().max(1024),\n pid: z.int().min(1),\n cwd: AbsPath,\n running: z.boolean(),\n exit_code: z.int().nullable(),\n started_at_ms: epochMs,\n output_bytes: nonNegInt,\n});\nexport const ExecJobListParams = z.strictObject({});\nexport const ExecJobListResult = z.strictObject({ jobs: z.array(ExecJobInfo).max(64) });\n\nexport type ExecJobId = z.output<typeof ExecJobId>;\nexport type ExecJobStartParams = z.output<typeof ExecJobStartParams>;\nexport type ExecJobStartResult = z.output<typeof ExecJobStartResult>;\nexport type ExecJobOutputParams = z.output<typeof ExecJobOutputParams>;\nexport type ExecJobOutputResult = z.output<typeof ExecJobOutputResult>;\nexport type ExecJobStopParams = z.output<typeof ExecJobStopParams>;\nexport type ExecJobStopResult = z.output<typeof ExecJobStopResult>;\nexport type ExecJobInfo = z.output<typeof ExecJobInfo>;\nexport type ExecJobListResult = z.output<typeof ExecJobListResult>;\n","/**\n * @ai-matrx/desktop-protocol — the `coding` capability's Claude Code history (SPEC §6 `coding`):\n * \"Import missing history\" — every Claude Code session on this computer that AI Matrx lacks, or is\n * behind on, imported through the shared importer (matrx-coding-history, the same code Matrx Local\n * runs) in Matrx 2's `coding` Python service (SPEC §3.10). Schema source: lint-enforced rules in\n * scripts/check-schema-source.mjs.\n *\n * Two contracts, both generated from this file (SPEC P11):\n * - the Router op `coding.history.import_missing` (every transport) and its progress event;\n * - the internal service ops `coding.plan_missing` / `coding.import_next` between the core and\n * the Python service. The core runs the loop: each service call is one bounded batch carrying\n * a fresh access token, so a long run never outlives its credential.\n */\nimport { z } from \"zod\";\nimport { RequestId, nonNegInt } from \"./primitives\";\n\n/** What the core adds to every coding service op from its own sign-in (never sent by a client). */\nexport const CodingServiceCredentials = z.strictObject({\n access_token: z.string().min(16).max(16_384),\n user_id: z.string().regex(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/),\n /** The AI Matrx server this app talks to (production, or a local server on the nightly copy). */\n server_url: z\n .string()\n .min(1)\n .max(2048)\n .regex(/^https?:\\/\\/[^\\s/?#]+(\\/[^\\s?#]*)?$/),\n});\n\n/**\n * Why a run stopped before it was done, as a state the screen can name:\n * signed_out — no usable AI Matrx sign-in (or it expired mid-run);\n * offline — the AI Matrx server did not answer;\n * organization_required — AI Matrx needs to know which organization files coding sessions;\n * claude_unavailable — Claude Code's account on this computer cannot be read;\n * cloud_list_unavailable — the server's list of sessions could not be proven complete;\n * history_too_large — more local sessions than the importer reads in one run.\n */\nexport const CodingHistoryBlocked = z.enum([\n \"signed_out\",\n \"offline\",\n \"organization_required\",\n \"claude_unavailable\",\n \"cloud_list_unavailable\",\n \"history_too_large\",\n]);\n\nexport const CodingHistoryFailure = z.strictObject({\n session_id: z.string().max(64),\n reason: z.string().max(300),\n});\n\n/** A run's counts so far, and its one honest line. */\nexport const CodingHistoryRun = z.strictObject({\n /** Claude Code sessions found on this computer. */\n local_sessions: nonNegInt,\n /** Of those, already complete in AI Matrx. */\n in_cloud: nonNegInt,\n /** In AI Matrx under neither of its identities. */\n missing: nonNegInt,\n /** In AI Matrx, but changed here after the last turn AI Matrx received (turns the hook lost). */\n behind: nonNegInt,\n /** Over the importer's size cap; never imported. */\n too_large: nonNegInt,\n imported: nonNegInt,\n /** Changed while being read; a later run takes them. */\n changed: nonNegInt,\n failed: nonNegInt,\n failures: z.array(CodingHistoryFailure).max(20),\n /** Candidates not reached yet. */\n remaining: nonNegInt,\n /** The one line a person reads, e.g. \"Imported 12 of 14 sessions. 140 already in AI Matrx.\" */\n summary: z.string().max(400),\n});\n\n/** The answer to each service op: where the run stands. */\nexport const CodingHistoryStep = z.strictObject({\n /** Null when the run could not start (blocked before a plan existed). */\n plan_id: z.string().regex(/^[0-9a-f]{32}$/).nullable(),\n finished: z.boolean(),\n blocked: CodingHistoryBlocked.nullable(),\n run: CodingHistoryRun,\n});\n\n/**\n * Service op `coding.plan_missing`: read the cloud's list and this computer's history (stat only).\n * `credentials` is null when nobody is signed in: the service answers `blocked: signed_out` with\n * its own line, so every sentence the person reads comes from one place.\n */\nexport const CodingPlanMissingParams = z.strictObject({ credentials: CodingServiceCredentials.nullable() });\n/** Service op `coding.import_next`: import the plan's next bounded batch (null credentials: as above). */\nexport const CodingImportNextParams = z.strictObject({\n plan_id: z.string().regex(/^[0-9a-f]{32}$/),\n credentials: CodingServiceCredentials.nullable(),\n});\n\n/** The coding service's progress messages (sent while it reads a large history). */\nexport const CodingServiceProgress = z.strictObject({\n phase: z.enum([\"checking\", \"importing\"]),\n done: nonNegInt,\n total: nonNegInt,\n});\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Router op (`coding.history.*`)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const CodingHistoryImportMissingParams = z.strictObject({});\nexport const CodingHistoryImportMissingResult = z.strictObject({\n state: z.enum([\"done\", \"blocked\", \"cancelled\"]),\n blocked: CodingHistoryBlocked.nullable(),\n run: CodingHistoryRun,\n elapsed_ms: nonNegInt,\n});\n\n/** Sent to the client that started `coding.history.import_missing`, for that request. */\nexport const CodingHistoryProgressEvent = z.strictObject({\n request_id: RequestId,\n phase: z.enum([\"checking\", \"importing\"]),\n /** Sessions settled so far, of `total` candidates (0 of 0 while checking). */\n done: nonNegInt,\n total: nonNegInt,\n imported: nonNegInt,\n failed: nonNegInt,\n});\n\nexport type CodingServiceCredentials = z.output<typeof CodingServiceCredentials>;\nexport type CodingHistoryBlocked = z.output<typeof CodingHistoryBlocked>;\nexport type CodingHistoryRun = z.output<typeof CodingHistoryRun>;\nexport type CodingHistoryStep = z.output<typeof CodingHistoryStep>;\nexport type CodingServiceProgress = z.output<typeof CodingServiceProgress>;\nexport type CodingHistoryImportMissingResult = z.output<typeof CodingHistoryImportMissingResult>;\nexport type CodingHistoryProgressEvent = z.output<typeof CodingHistoryProgressEvent>;\n","/**\n * @ai-matrx/desktop-protocol — cap apps (SPEC §6): the desktop apps a person uses (Claude, Codex,\n * Cursor, VS Code, Antigravity, and any app a later adapter adds), their profiles and usage.\n * Schema source: lint-enforced rules in scripts/check-schema-source.mjs.\n *\n * A profile is one data folder of one app on one device, so several accounts of the same app run\n * side by side. Profiles are the person's own rows in `users.desktop_app_profile` (the one\n * database); folders found on disk that no row names yet are listed with `id: null` so they can be\n * added. Nothing here is ever a credential: signing in happens inside the app.\n */\nimport { z } from \"zod\";\nimport { AbsPath, DeviceId, epochMs } from \"./primitives\";\n\n/** An adapter key: lowercase, open-ended (a new app needs only a new adapter). */\nexport const AppKey = z\n .string()\n .regex(/^[a-z][a-z0-9_-]{0,39}$/);\n\n/** A users.desktop_app_profile id. Plain pattern (see DeviceId for why not z.uuid()). */\nexport const AppProfileId = z\n .string()\n .regex(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/);\n\n/**\n * Where a profile's folder lives, RELATIVE to the app adapter's data root on that device: one or\n * more plain names joined by \"/\" (none starting with a dot, so never \".\" or \"..\"), never absolute.\n * Null on a profile means the app's own default profile. No lookaround: Pydantic's regex engine\n * has none.\n */\nexport const AppProfileLocator = z\n .string()\n .min(1)\n .max(512)\n .regex(/^[A-Za-z0-9 _()+@,-][A-Za-z0-9 ._()+@,-]{0,127}(\\/[A-Za-z0-9 _()+@,-][A-Za-z0-9 ._()+@,-]{0,127}){0,7}$/);\n\n/** supported: proven here; partial: works with a stated gap; unsupported: not on this OS. */\nexport const AppSupport = z.enum([\"supported\", \"partial\", \"unsupported\"]);\n\nexport const AppFeatureStatus = z.strictObject({\n status: AppSupport,\n /** One line, set whenever status is not \"supported\". */\n reason: z.string().max(140).nullable(),\n});\n\nexport const AppInfo = z.strictObject({\n app_key: AppKey,\n name: z.string().max(64),\n installed: z.boolean(),\n /** The app's own version string, or null when it is not installed or does not say. */\n version: z.string().max(64).nullable(),\n /** The install found (an .app bundle, an .exe, a binary), or null. */\n location: AbsPath.nullable(),\n /** Open the app at all on this OS. */\n open: AppFeatureStatus,\n /** Separate profiles (one account each) on this OS. */\n profiles: AppFeatureStatus,\n /** Plan usage read from the app's own files on this OS. */\n usage: AppFeatureStatus,\n});\n\n/** One plan-usage figure, as the app itself last recorded it. */\nexport const AppUsageReading = z.strictObject({\n window: z.enum([\"five_hour\", \"weekly\", \"extra\"]),\n /** 0–100 for five_hour and weekly; extra-usage spend as a percent of its cap (may pass 100). */\n percent: z.number().min(0).max(10_000),\n /** When the app recorded it. */\n sampled_at_ms: epochMs,\n /** True when the window has rolled over since the sample, so the figure has reset. */\n reset_since: z.boolean(),\n});\n\nexport const AppProfile = z.strictObject({\n /** The row's id; null for a folder found on disk that no row names yet. */\n id: AppProfileId.nullable(),\n app_key: AppKey,\n display_name: z.string().min(1).max(120),\n /** The account the person means to be signed in here; null when not stated (never guessed). */\n account_identity: z.string().min(3).max(320).nullable(),\n profile_locator: AppProfileLocator.nullable(),\n /** The device the row is tied to; null when the row names none. */\n device_id: DeviceId.nullable(),\n /** The folder this profile resolves to on this device; null for a row tied to another device. */\n folder: AbsPath.nullable(),\n /** The folder exists on this device. */\n on_disk: z.boolean(),\n /** An instance with this profile is running; null when it could not be determined. */\n running: z.boolean().nullable(),\n /** Usage the app recorded for this profile; null when the app exposes none here. */\n usage: z.array(AppUsageReading).nullable(),\n last_opened_ms: epochMs.nullable(),\n});\n\nexport const AppsListParams = z.strictObject({});\nexport const AppsListResult = z.strictObject({ apps: z.array(AppInfo) });\n\nexport const AppsProfilesListParams = z.strictObject({\n /** Only this app's profiles; every app's when absent. */\n app_key: AppKey.optional(),\n});\nexport const AppsProfilesListResult = z.strictObject({\n profiles: z.array(AppProfile),\n /**\n * Whether the saved rows could be read: false while signed out or offline, when only folders\n * found on disk are listed.\n */\n registry: z.enum([\"ok\", \"signed_out\", \"unavailable\"]),\n});\n\n/** Create (no id) or update (id) the person's own profile row. */\nexport const AppsProfilesSaveParams = z.strictObject({\n id: AppProfileId.optional(),\n app_key: AppKey,\n display_name: z.string().min(1).max(120),\n account_identity: z.string().min(3).max(320).nullable(),\n /** On create: the folder to use (one found on disk), or null for the app's default profile. Ignored on update. */\n profile_locator: AppProfileLocator.nullable(),\n /** On create with profile_locator null: make a new folder named after display_name instead. */\n new_folder: z.boolean().default(false),\n});\nexport const AppsProfilesSaveResult = AppProfile;\n\n/** Remove the row (soft delete). The folder on disk is never touched. */\nexport const AppsProfilesRemoveParams = z.strictObject({ id: AppProfileId });\nexport const AppsProfilesRemoveResult = z.strictObject({ removed: z.boolean() });\n\n/** Open the app with a profile (its default profile when profile_id is absent). */\nexport const AppsOpenParams = z.strictObject({\n app_key: AppKey,\n profile_id: AppProfileId.optional(),\n});\nexport const AppsOpenResult = z.strictObject({\n /** True when an instance with this profile was already running; it is brought forward. */\n already_running: z.boolean(),\n folder: AbsPath.nullable(),\n});\n\n// Inferred (output) types — same name as the schema, so `AppInfo` is both the validator and its type.\nexport type AppKey = z.output<typeof AppKey>;\nexport type AppProfileId = z.output<typeof AppProfileId>;\nexport type AppProfileLocator = z.output<typeof AppProfileLocator>;\nexport type AppSupport = z.output<typeof AppSupport>;\nexport type AppFeatureStatus = z.output<typeof AppFeatureStatus>;\nexport type AppInfo = z.output<typeof AppInfo>;\nexport type AppUsageReading = z.output<typeof AppUsageReading>;\nexport type AppProfile = z.output<typeof AppProfile>;\nexport type AppsListParams = z.output<typeof AppsListParams>;\nexport type AppsListResult = z.output<typeof AppsListResult>;\nexport type AppsProfilesListParams = z.output<typeof AppsProfilesListParams>;\nexport type AppsProfilesListResult = z.output<typeof AppsProfilesListResult>;\nexport type AppsProfilesSaveParams = z.output<typeof AppsProfilesSaveParams>;\nexport type AppsProfilesSaveResult = z.output<typeof AppsProfilesSaveResult>;\nexport type AppsProfilesRemoveParams = z.output<typeof AppsProfilesRemoveParams>;\nexport type AppsProfilesRemoveResult = z.output<typeof AppsProfilesRemoveResult>;\nexport type AppsOpenParams = z.output<typeof AppsOpenParams>;\nexport type AppsOpenResult = z.output<typeof AppsOpenResult>;\n","/** @ai-matrx/desktop-protocol — the op and event registries (Router, client and Python are generated from these). */\nimport { z } from \"zod\";\nimport {\n AbsPath,\n DeviceId,\n ProtocolVersion,\n RequestId,\n ResourceId,\n} from \"./primitives\";\nimport {\n ErrorCode,\n ErrorReason,\n FsPatchEditFailure,\n ProtocolErrorBody,\n} from \"./errors\";\nimport {\n FrameHeader,\n RelayHopEnvelopeHeader,\n RelayHopConnectionEnd,\n} from \"./frame\";\nimport {\n CancelMsg,\n ClientToCoreMsg,\n ClientType,\n CoreToClientMsg,\n CreditMsg,\n EndMsg,\n EndReason,\n ErrorMsg,\n EventMsg,\n HelloMsg,\n Limits,\n OpDescriptor,\n RelayMsg,\n RequestMsg,\n ResponseMsg,\n StreamMeta,\n StreamMsg,\n Welcome,\n CloseCodeValue,\n} from \"./envelope\";\nimport {\n OsPermissionName,\n SysinfoGetParams,\n SysinfoGetResult,\n} from \"./sysinfo\";\nimport {\n FsChange,\n FsChangedEvent,\n FsDeleteParams,\n FsDeleteResult,\n FsEncoding,\n FsEntry,\n FsKind,\n FsListParams,\n FsListResult,\n FsMkdirParams,\n FsMkdirResult,\n FsMoveParams,\n FsMoveResult,\n FsPatchEditApplied,\n FsPatchParams,\n FsPatchResult,\n FsReadParams,\n FsReadResult,\n FsReadStreamParams,\n FsReadStreamResult,\n FsSearchContentParams,\n FsSearchContentResult,\n FsSearchPathsParams,\n FsSearchPathsResult,\n FsStatParams,\n FsStatResult,\n FsWatchParams,\n FsWatchResult,\n FsWriteParams,\n FsWriteResult,\n} from \"./fs\";\nimport {\n ExecCwdEvent,\n ExecExitedEvent,\n ExecListParams,\n ExecListResult,\n ExecPtyKillParams,\n ExecPtyKillResult,\n ExecPtyResizeParams,\n ExecPtyResizeResult,\n ExecPtySignalParams,\n ExecPtySignalResult,\n ExecPtyStartParams,\n ExecPtyStartResult,\n ExecPtyWriteParams,\n ExecPtyWriteResult,\n ExecRunParams,\n ExecRunResult,\n ExecTitleEvent,\n PtyInfo,\n Signal,\n} from \"./exec\";\nimport {\n ResourceInfo,\n SessionAttachParams,\n SessionAttachResult,\n SessionControlChangedEvent,\n SessionDetachParams,\n SessionDetachResult,\n SessionListParams,\n SessionListResult,\n SessionReleaseParams,\n SessionReleaseResult,\n} from \"./session\";\nimport {\n MlInstallPhase,\n MlInstallProgress,\n MlProgress,\n MlRuntimeState,\n MlServiceState,\n MlServiceStatus,\n MlStatusParams,\n MlStatusResult,\n ModelsInstallParams,\n ModelsInstallResult,\n ModelsProgressEvent,\n ModelsStatusParams,\n ModelsStatusResult,\n ModelsTranscribeParams,\n ModelsTranscribeResult,\n TranscriptionModelId,\n TranscriptionModelInfo,\n TranscriptSegment,\n} from \"./models\";\nimport {\n ContractHash,\n CoreToServiceMsg,\n ServiceCancel,\n ServiceErrorMsg,\n ServiceHello,\n ServiceName,\n ServicePing,\n ServicePong,\n ServiceProgressMsg,\n ServiceRequest,\n ServiceResponse,\n ServiceShutdown,\n ServiceToCoreMsg,\n ServiceToken,\n ServiceWelcome,\n} from \"./service\";\nimport {\n RelayAuthExpiringEvent,\n RelayCallRequest,\n RelayCallResponse,\n RelayDeviceStatusEvent,\n RelayCallHello,\n RelayCallEnvelope,\n} from \"./relay\";\nimport { ClipboardReadParams, ClipboardReadResult, ClipboardWriteParams, ClipboardWriteResult } from \"./clipboard\";\nimport { ProcInfo, ProcKillParams, ProcKillResult, ProcListParams, ProcListResult, ProcPort, ProcPortsParams, ProcPortsResult, ProcSort } from \"./proc\";\nimport { SystemNotifyParams, SystemNotifyResult, SystemOpenPathParams, SystemOpenPathResult, SystemOpenUrlParams, SystemOpenUrlResult } from \"./system\";\nimport { ScreenCaptureParams, ScreenCaptureResult, ScreenDisplay, ScreenListParams, ScreenListResult } from \"./screen\";\nimport { WindowFocusParams, WindowFocusResult, WindowInfo, WindowListParams, WindowListResult, WindowMinimizeParams, WindowMinimizeResult, WindowMoveParams, WindowMoveResult } from \"./window\";\nimport { InputHotkeyParams, InputHotkeyResult, InputKey, InputMouseClickParams, InputMouseClickResult, InputMouseMoveParams, InputMouseMoveResult, InputPoint, InputTypeTextParams, InputTypeTextResult } from \"./input\";\nimport { PowerPreventSleepParams, PowerPreventSleepResult, PowerStatusParams, PowerStatusResult } from \"./power\";\nimport { AudioDevice, AudioDevicesParams, AudioDevicesResult, AudioPlayParams, AudioPlayResult, AudioRecordParams, AudioRecordResult } from \"./audio\";\nimport { ResourcesDisk, ResourcesSnapshotParams, ResourcesSnapshotResult } from \"./resources\";\nimport { FsWatchEventsParams, FsWatchEventsResult, FsWatchId, FsWatchStartParams, FsWatchStartResult, FsWatchStopParams, FsWatchStopResult } from \"./fs-watch\";\nimport { ExecJobId, ExecJobInfo, ExecJobListParams, ExecJobListResult, ExecJobOutputParams, ExecJobOutputResult, ExecJobStartParams, ExecJobStartResult, ExecJobStopParams, ExecJobStopResult } from \"./exec-job\";\nimport { ToolLevel, ToolLevelResult, ToolName, ToolOutcome, ToolPlatform, ToolResultsFile, ToolTransport } from \"./tools\";\nimport {\n CodingHistoryBlocked,\n CodingHistoryFailure,\n CodingHistoryImportMissingParams,\n CodingHistoryImportMissingResult,\n CodingHistoryProgressEvent,\n CodingHistoryRun,\n CodingHistoryStep,\n CodingImportNextParams,\n CodingPlanMissingParams,\n CodingServiceCredentials,\n CodingServiceProgress,\n} from \"./coding\";\n\nimport {\n AppFeatureStatus,\n AppInfo,\n AppKey,\n AppProfile,\n AppProfileId,\n AppProfileLocator,\n AppSupport,\n AppUsageReading,\n AppsListParams,\n AppsListResult,\n AppsOpenParams,\n AppsOpenResult,\n AppsProfilesListParams,\n AppsProfilesListResult,\n AppsProfilesRemoveParams,\n AppsProfilesRemoveResult,\n AppsProfilesSaveParams,\n AppsProfilesSaveResult,\n} from \"./apps\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Registries — the Router, the client and the Python side are all generated from these.\n// kind: unary = response only; stream = response, then stream/end on the same id;\n// resource = like stream and the result carries a resource_id the Session Manager owns.\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type OpSpec = {\n readonly params: z.ZodType;\n readonly result: z.ZodType;\n readonly kind: \"unary\" | \"stream\" | \"resource\";\n readonly since: \"1.0\" | \"1.2\" | \"1.3\" | \"1.4\" | \"1.5\" | \"1.6\";\n readonly errors: readonly z.infer<typeof ErrorCode>[];\n};\n\nconst FS_ERR = [\"NOT_FOUND\", \"PERMISSION_DENIED_OS\", \"INVALID_PARAMS\", \"RESOURCE_BUSY\", \"INTERNAL\"] as const;\n\nexport const OPS = {\n \"sysinfo.get\": { params: SysinfoGetParams, result: SysinfoGetResult, kind: \"unary\", since: \"1.0\", errors: [\"INTERNAL\"] },\n\n \"fs.list\": { params: FsListParams, result: FsListResult, kind: \"unary\", since: \"1.0\", errors: FS_ERR },\n \"fs.stat\": { params: FsStatParams, result: FsStatResult, kind: \"unary\", since: \"1.0\", errors: FS_ERR },\n \"fs.read\": { params: FsReadParams, result: FsReadResult, kind: \"unary\", since: \"1.0\", errors: [...FS_ERR, \"PAYLOAD_TOO_LARGE\"] },\n \"fs.read_stream\": { params: FsReadStreamParams, result: FsReadStreamResult, kind: \"stream\", since: \"1.0\", errors: [...FS_ERR, \"CANCELLED\"] },\n \"fs.write\": { params: FsWriteParams, result: FsWriteResult, kind: \"unary\", since: \"1.0\", errors: [...FS_ERR, \"CONFLICT\", \"PAYLOAD_TOO_LARGE\"] },\n \"fs.mkdir\": { params: FsMkdirParams, result: FsMkdirResult, kind: \"unary\", since: \"1.0\", errors: [...FS_ERR, \"CONFLICT\"] },\n \"fs.move\": { params: FsMoveParams, result: FsMoveResult, kind: \"unary\", since: \"1.0\", errors: [...FS_ERR, \"CONFLICT\"] },\n \"fs.delete\": { params: FsDeleteParams, result: FsDeleteResult, kind: \"unary\", since: \"1.0\", errors: FS_ERR },\n \"fs.watch\": { params: FsWatchParams, result: FsWatchResult, kind: \"resource\", since: \"1.0\", errors: [...FS_ERR, \"RATE_LIMITED\"] },\n \"fs.patch\": { params: FsPatchParams, result: FsPatchResult, kind: \"unary\", since: \"1.0\", errors: [...FS_ERR, \"CONFLICT\"] },\n \"fs.search_paths\": { params: FsSearchPathsParams, result: FsSearchPathsResult, kind: \"unary\", since: \"1.0\", errors: [...FS_ERR, \"TIMEOUT\"] },\n \"fs.search_content\": { params: FsSearchContentParams, result: FsSearchContentResult, kind: \"unary\", since: \"1.0\", errors: [...FS_ERR, \"TIMEOUT\"] },\n\n \"exec.pty.start\": { params: ExecPtyStartParams, result: ExecPtyStartResult, kind: \"resource\", since: \"1.0\", errors: [\"INVALID_PARAMS\", \"NOT_FOUND\", \"RATE_LIMITED\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"exec.pty.write\": { params: ExecPtyWriteParams, result: ExecPtyWriteResult, kind: \"unary\", since: \"1.0\", errors: [\"RESOURCE_GONE\", \"AUTH_FORBIDDEN\", \"INVALID_PARAMS\"] },\n \"exec.pty.resize\": { params: ExecPtyResizeParams, result: ExecPtyResizeResult, kind: \"unary\", since: \"1.0\", errors: [\"RESOURCE_GONE\", \"AUTH_FORBIDDEN\"] },\n \"exec.pty.signal\": { params: ExecPtySignalParams, result: ExecPtySignalResult, kind: \"unary\", since: \"1.0\", errors: [\"RESOURCE_GONE\", \"AUTH_FORBIDDEN\", \"PLATFORM_UNSUPPORTED\"] },\n \"exec.pty.kill\": { params: ExecPtyKillParams, result: ExecPtyKillResult, kind: \"unary\", since: \"1.0\", errors: [\"RESOURCE_GONE\", \"AUTH_FORBIDDEN\"] },\n \"exec.list\": { params: ExecListParams, result: ExecListResult, kind: \"unary\", since: \"1.0\", errors: [\"INTERNAL\"] },\n \"exec.run\": { params: ExecRunParams, result: ExecRunResult, kind: \"unary\", since: \"1.0\", errors: [\"INVALID_PARAMS\", \"NOT_FOUND\", \"TIMEOUT\", \"CANCELLED\", \"INTERNAL\"] },\n\n \"session.attach\": { params: SessionAttachParams, result: SessionAttachResult, kind: \"stream\", since: \"1.0\", errors: [\"RESOURCE_GONE\", \"AUTH_FORBIDDEN\", \"RESOURCE_BUSY\"] },\n \"session.detach\": { params: SessionDetachParams, result: SessionDetachResult, kind: \"unary\", since: \"1.0\", errors: [\"RESOURCE_GONE\"] },\n \"session.release\": { params: SessionReleaseParams, result: SessionReleaseResult, kind: \"unary\", since: \"1.0\", errors: [\"RESOURCE_GONE\", \"AUTH_FORBIDDEN\"] },\n \"session.list\": { params: SessionListParams, result: SessionListResult, kind: \"unary\", since: \"1.0\", errors: [\"INTERNAL\"] },\n\n // Local models (SPEC §6), served by the `ml` Python service through SERVICES below.\n \"models.status\": { params: ModelsStatusParams, result: ModelsStatusResult, kind: \"unary\", since: \"1.2\", errors: [\"INTERNAL\"] },\n \"models.install\": { params: ModelsInstallParams, result: ModelsInstallResult, kind: \"unary\", since: \"1.2\", errors: [\"RESOURCE_BUSY\", \"RESOURCE_GONE\", \"TIMEOUT\", \"CANCELLED\", \"INTERNAL\"] },\n \"models.transcribe\": { params: ModelsTranscribeParams, result: ModelsTranscribeResult, kind: \"unary\", since: \"1.2\", errors: [\"NOT_FOUND\", \"INVALID_PARAMS\", \"PERMISSION_DENIED_OS\", \"RESOURCE_BUSY\", \"RESOURCE_GONE\", \"CANCELLED\", \"PAYLOAD_TOO_LARGE\", \"INTERNAL\"] },\n\n // Desktop apps and their profiles (SPEC §6 apps); profiles are rows in users.desktop_app_profile.\n \"apps.list\": { params: AppsListParams, result: AppsListResult, kind: \"unary\", since: \"1.2\", errors: [\"INTERNAL\"] },\n \"apps.profiles.list\": { params: AppsProfilesListParams, result: AppsProfilesListResult, kind: \"unary\", since: \"1.2\", errors: [\"NOT_FOUND\", \"INVALID_PARAMS\", \"INTERNAL\"] },\n \"apps.profiles.save\": { params: AppsProfilesSaveParams, result: AppsProfilesSaveResult, kind: \"unary\", since: \"1.2\", errors: [\"AUTH_REQUIRED\", \"AUTH_FORBIDDEN\", \"NOT_FOUND\", \"INVALID_PARAMS\", \"CONFLICT\", \"PLATFORM_UNSUPPORTED\", \"DEVICE_OFFLINE\", \"INTERNAL\"] },\n \"apps.profiles.remove\": { params: AppsProfilesRemoveParams, result: AppsProfilesRemoveResult, kind: \"unary\", since: \"1.2\", errors: [\"AUTH_REQUIRED\", \"AUTH_FORBIDDEN\", \"NOT_FOUND\", \"DEVICE_OFFLINE\", \"INTERNAL\"] },\n \"apps.open\": { params: AppsOpenParams, result: AppsOpenResult, kind: \"unary\", since: \"1.2\", errors: [\"NOT_FOUND\", \"PLATFORM_UNSUPPORTED\", \"AUTH_REQUIRED\", \"DEVICE_OFFLINE\", \"INTERNAL\"] },\n\n \"proc.list\": { params: ProcListParams, result: ProcListResult, kind: \"unary\", since: \"1.3\", errors: [\"INVALID_PARAMS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"proc.ports\": { params: ProcPortsParams, result: ProcPortsResult, kind: \"unary\", since: \"1.3\", errors: [\"INVALID_PARAMS\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"proc.kill\": { params: ProcKillParams, result: ProcKillResult, kind: \"unary\", since: \"1.3\", errors: [\"NOT_FOUND\", \"AUTH_FORBIDDEN\", \"PERMISSION_DENIED_OS\", \"INVALID_PARAMS\", \"INTERNAL\"] },\n\n \"clipboard.read\": { params: ClipboardReadParams, result: ClipboardReadResult, kind: \"unary\", since: \"1.3\", errors: [\"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"clipboard.write\": { params: ClipboardWriteParams, result: ClipboardWriteResult, kind: \"unary\", since: \"1.3\", errors: [\"PLATFORM_UNSUPPORTED\", \"PAYLOAD_TOO_LARGE\", \"INTERNAL\"] },\n \"fs.watch.start\": { params: FsWatchStartParams, result: FsWatchStartResult, kind: \"unary\", since: \"1.4\", errors: [...FS_ERR, \"RATE_LIMITED\"] },\n \"fs.watch.events\": { params: FsWatchEventsParams, result: FsWatchEventsResult, kind: \"unary\", since: \"1.4\", errors: [\"RESOURCE_GONE\", \"INVALID_PARAMS\", \"INTERNAL\"] },\n \"fs.watch.stop\": { params: FsWatchStopParams, result: FsWatchStopResult, kind: \"unary\", since: \"1.4\", errors: [\"RESOURCE_GONE\", \"INVALID_PARAMS\"] },\n\n \"exec.job.start\": { params: ExecJobStartParams, result: ExecJobStartResult, kind: \"unary\", since: \"1.4\", errors: [\"INVALID_PARAMS\", \"NOT_FOUND\", \"RATE_LIMITED\", \"INTERNAL\"] },\n \"exec.job.output\": { params: ExecJobOutputParams, result: ExecJobOutputResult, kind: \"unary\", since: \"1.4\", errors: [\"RESOURCE_GONE\", \"INVALID_PARAMS\"] },\n \"exec.job.stop\": { params: ExecJobStopParams, result: ExecJobStopResult, kind: \"unary\", since: \"1.4\", errors: [\"RESOURCE_GONE\", \"INVALID_PARAMS\", \"INTERNAL\"] },\n \"exec.job.list\": { params: ExecJobListParams, result: ExecJobListResult, kind: \"unary\", since: \"1.4\", errors: [\"INTERNAL\"] },\n\n \"system.open_url\": { params: SystemOpenUrlParams, result: SystemOpenUrlResult, kind: \"unary\", since: \"1.4\", errors: [\"INVALID_PARAMS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"system.open_path\": { params: SystemOpenPathParams, result: SystemOpenPathResult, kind: \"unary\", since: \"1.4\", errors: [\"NOT_FOUND\", \"INVALID_PARAMS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"system.notify\": { params: SystemNotifyParams, result: SystemNotifyResult, kind: \"unary\", since: \"1.4\", errors: [\"PERMISSION_DENIED_OS\", \"INTERNAL\"] },\n\n \"screen.list\": { params: ScreenListParams, result: ScreenListResult, kind: \"unary\", since: \"1.4\", errors: [\"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"screen.capture\": { params: ScreenCaptureParams, result: ScreenCaptureResult, kind: \"unary\", since: \"1.4\", errors: [\"NOT_FOUND\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"PAYLOAD_TOO_LARGE\", \"INTERNAL\"] },\n\n \"window.list\": { params: WindowListParams, result: WindowListResult, kind: \"unary\", since: \"1.4\", errors: [\"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"window.focus\": { params: WindowFocusParams, result: WindowFocusResult, kind: \"unary\", since: \"1.4\", errors: [\"NOT_FOUND\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"window.move\": { params: WindowMoveParams, result: WindowMoveResult, kind: \"unary\", since: \"1.4\", errors: [\"NOT_FOUND\", \"INVALID_PARAMS\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"window.minimize\": { params: WindowMinimizeParams, result: WindowMinimizeResult, kind: \"unary\", since: \"1.4\", errors: [\"NOT_FOUND\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n\n \"input.type_text\": { params: InputTypeTextParams, result: InputTypeTextResult, kind: \"unary\", since: \"1.4\", errors: [\"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"input.hotkey\": { params: InputHotkeyParams, result: InputHotkeyResult, kind: \"unary\", since: \"1.4\", errors: [\"INVALID_PARAMS\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"input.mouse_move\": { params: InputMouseMoveParams, result: InputMouseMoveResult, kind: \"unary\", since: \"1.4\", errors: [\"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"input.mouse_click\": { params: InputMouseClickParams, result: InputMouseClickResult, kind: \"unary\", since: \"1.4\", errors: [\"INVALID_PARAMS\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n\n \"power.status\": { params: PowerStatusParams, result: PowerStatusResult, kind: \"unary\", since: \"1.4\", errors: [\"INTERNAL\"] },\n \"power.prevent_sleep\": { params: PowerPreventSleepParams, result: PowerPreventSleepResult, kind: \"unary\", since: \"1.4\", errors: [\"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n\n \"resources.snapshot\": { params: ResourcesSnapshotParams, result: ResourcesSnapshotResult, kind: \"unary\", since: \"1.4\", errors: [\"INTERNAL\"] },\n\n \"audio.devices\": { params: AudioDevicesParams, result: AudioDevicesResult, kind: \"unary\", since: \"1.6\", errors: [\"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"audio.record\": { params: AudioRecordParams, result: AudioRecordResult, kind: \"unary\", since: \"1.6\", errors: [\"NOT_FOUND\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"RESOURCE_BUSY\", \"INTERNAL\"] },\n \"audio.play\": { params: AudioPlayParams, result: AudioPlayResult, kind: \"unary\", since: \"1.6\", errors: [\"NOT_FOUND\", \"INVALID_PARAMS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n\n // Claude Code history (SPEC §6 coding): served by the `coding` Python service through SERVICES below.\n \"coding.history.import_missing\": { params: CodingHistoryImportMissingParams, result: CodingHistoryImportMissingResult, kind: \"unary\", since: \"1.5\", errors: [\"RESOURCE_BUSY\", \"RESOURCE_GONE\", \"CANCELLED\", \"INTERNAL\"] },\n} as const satisfies Record<string, OpSpec>;\n\nexport type OpName = keyof typeof OPS;\nexport type OpParams<N extends OpName> = z.input<(typeof OPS)[N][\"params\"]>;\nexport type OpResult<N extends OpName> = z.output<(typeof OPS)[N][\"result\"]>;\n\nexport const EVENTS = {\n \"fs.changed\": FsChangedEvent,\n \"exec.exited\": ExecExitedEvent,\n \"exec.title\": ExecTitleEvent,\n \"exec.cwd\": ExecCwdEvent,\n \"session.control_changed\": SessionControlChangedEvent,\n \"models.progress\": ModelsProgressEvent,\n \"coding.history.progress\": CodingHistoryProgressEvent,\n \"relay.device_status\": RelayDeviceStatusEvent,\n \"relay.auth_expiring\": RelayAuthExpiringEvent,\n} as const satisfies Record<string, z.ZodType>;\n\nexport type EventName = keyof typeof EVENTS;\n\n/**\n * Supervised Python services (SPEC §3.10) and the ops each serves over its local socket\n * (src/schema/service.ts). The Python side's handler protocol, op table and models are generated\n * from this table (scripts/gen_pydantic.py); the core's service client is typed by it. A Router\n * op that a capability owner forwards uses the same params/result schemas as its service op.\n */\nexport type ServiceOpSpec = { readonly params: z.ZodType; readonly result: z.ZodType };\nexport type ServiceSpec = { readonly progress: z.ZodType; readonly ops: Readonly<Record<string, ServiceOpSpec>> };\n\nexport const SERVICES = {\n ml: {\n progress: MlProgress,\n ops: {\n \"ml.status\": { params: MlStatusParams, result: MlStatusResult },\n \"ml.install\": { params: ModelsInstallParams, result: ModelsInstallResult },\n \"ml.transcribe\": { params: ModelsTranscribeParams, result: ModelsTranscribeResult },\n },\n },\n coding: {\n progress: CodingServiceProgress,\n ops: {\n \"coding.plan_missing\": { params: CodingPlanMissingParams, result: CodingHistoryStep },\n \"coding.import_next\": { params: CodingImportNextParams, result: CodingHistoryStep },\n },\n },\n} as const satisfies Record<z.infer<typeof ServiceName>, ServiceSpec>;\n\nexport type ServiceId = keyof typeof SERVICES;\nexport type ServiceOpName<S extends ServiceId> = keyof (typeof SERVICES)[S][\"ops\"] & string;\n\n/**\n * Every schema that lands in the generated JSON Schema `$defs` under a stable name (and so becomes a\n * named Pydantic model). Order is the emission order. A test asserts every exported schema of\n * src/schema/* is either listed here or is a documented alias of a listed one.\n * Registered into a PRIVATE zod registry by scripts/generate.ts — never `.meta()`/`.describe()`,\n * which write zod's process-global registry as an import side effect.\n */\nexport const NAMED_SCHEMAS = {\n ProtocolVersion,\n RequestId,\n ResourceId,\n DeviceId,\n AbsPath,\n ErrorCode,\n ErrorReason,\n FsPatchEditFailure,\n ProtocolErrorBody,\n FrameHeader,\n ClientType,\n Limits,\n OpDescriptor,\n Welcome,\n HelloMsg,\n RequestMsg,\n ResponseMsg,\n ErrorMsg,\n StreamMeta,\n StreamMsg,\n EndReason,\n EndMsg,\n CancelMsg,\n CreditMsg,\n EventMsg,\n RelayMsg,\n ClientToCoreMsg,\n CoreToClientMsg,\n OsPermissionName,\n SysinfoGetParams,\n SysinfoGetResult,\n FsKind,\n FsEntry,\n FsListParams,\n FsListResult,\n FsStatParams,\n FsEncoding,\n FsReadParams,\n FsReadResult,\n FsReadStreamParams,\n FsReadStreamResult,\n FsWriteParams,\n FsWriteResult,\n FsMkdirParams,\n FsMkdirResult,\n FsMoveParams,\n FsMoveResult,\n FsDeleteParams,\n FsDeleteResult,\n FsWatchParams,\n FsWatchResult,\n FsPatchEditApplied,\n FsPatchParams,\n FsPatchResult,\n FsSearchPathsParams,\n FsSearchPathsResult,\n FsSearchContentParams,\n FsSearchContentResult,\n FsChange,\n FsChangedEvent,\n Signal,\n ExecPtyStartParams,\n PtyInfo,\n ExecPtyWriteParams,\n ExecPtyWriteResult,\n ExecPtyResizeParams,\n ExecPtyResizeResult,\n ExecPtySignalParams,\n ExecPtySignalResult,\n ExecPtyKillParams,\n ExecPtyKillResult,\n ExecListParams,\n ExecListResult,\n ExecRunParams,\n ExecRunResult,\n ExecExitedEvent,\n ExecTitleEvent,\n ExecCwdEvent,\n SessionAttachParams,\n ResourceInfo,\n SessionDetachParams,\n SessionDetachResult,\n SessionReleaseParams,\n SessionReleaseResult,\n SessionListParams,\n SessionListResult,\n SessionControlChangedEvent,\n TranscriptionModelId,\n MlRuntimeState,\n MlInstallPhase,\n MlInstallProgress,\n TranscriptionModelInfo,\n TranscriptSegment,\n MlStatusParams,\n MlStatusResult,\n ModelsInstallParams,\n ModelsInstallResult,\n ModelsTranscribeParams,\n ModelsTranscribeResult,\n MlProgress,\n MlServiceState,\n MlServiceStatus,\n ModelsStatusParams,\n ModelsStatusResult,\n ModelsProgressEvent,\n CodingServiceCredentials,\n CodingHistoryBlocked,\n CodingHistoryFailure,\n CodingHistoryRun,\n CodingHistoryStep,\n CodingPlanMissingParams,\n CodingImportNextParams,\n CodingServiceProgress,\n CodingHistoryImportMissingParams,\n CodingHistoryImportMissingResult,\n CodingHistoryProgressEvent,\n ServiceName,\n ContractHash,\n ServiceToken,\n ServiceHello,\n ServiceWelcome,\n ServiceRequest,\n ServiceResponse,\n ServiceErrorMsg,\n ServiceProgressMsg,\n ServiceCancel,\n ServicePing,\n ServicePong,\n ServiceShutdown,\n CoreToServiceMsg,\n ServiceToCoreMsg,\n RelayDeviceStatusEvent,\n RelayAuthExpiringEvent,\n RelayCallRequest,\n RelayCallResponse,\n RelayCallHello,\n RelayCallEnvelope,\n RelayHopEnvelopeHeader,\n RelayHopConnectionEnd,\n CloseCodeValue,\n ProcSort,\n ProcListParams,\n ProcInfo,\n ProcListResult,\n ProcPortsParams,\n ProcPort,\n ProcPortsResult,\n ProcKillParams,\n ProcKillResult,\n ClipboardReadParams,\n ClipboardReadResult,\n ClipboardWriteParams,\n ClipboardWriteResult,\n SystemOpenUrlParams,\n SystemOpenUrlResult,\n SystemOpenPathParams,\n SystemOpenPathResult,\n SystemNotifyParams,\n SystemNotifyResult,\n ScreenDisplay,\n ScreenListParams,\n ScreenListResult,\n ScreenCaptureParams,\n ScreenCaptureResult,\n WindowInfo,\n WindowListParams,\n WindowListResult,\n WindowFocusParams,\n WindowFocusResult,\n WindowMoveParams,\n WindowMoveResult,\n WindowMinimizeParams,\n WindowMinimizeResult,\n InputKey,\n InputPoint,\n InputTypeTextParams,\n InputTypeTextResult,\n InputHotkeyParams,\n InputHotkeyResult,\n InputMouseMoveParams,\n InputMouseMoveResult,\n InputMouseClickParams,\n InputMouseClickResult,\n PowerStatusParams,\n PowerStatusResult,\n PowerPreventSleepParams,\n PowerPreventSleepResult,\n ResourcesDisk,\n ResourcesSnapshotParams,\n ResourcesSnapshotResult,\n AudioDevice,\n AudioDevicesParams,\n AudioDevicesResult,\n AudioRecordParams,\n AudioRecordResult,\n AudioPlayParams,\n AudioPlayResult,\n FsWatchId,\n FsWatchStartParams,\n FsWatchStartResult,\n FsWatchEventsParams,\n FsWatchEventsResult,\n FsWatchStopParams,\n FsWatchStopResult,\n ExecJobId,\n ExecJobStartParams,\n ExecJobStartResult,\n ExecJobOutputParams,\n ExecJobOutputResult,\n ExecJobStopParams,\n ExecJobStopResult,\n ExecJobInfo,\n ExecJobListParams,\n ExecJobListResult,\n ToolLevel,\n ToolOutcome,\n ToolPlatform,\n ToolTransport,\n ToolName,\n ToolLevelResult,\n ToolResultsFile,\n AppKey,\n AppProfileId,\n AppProfileLocator,\n AppSupport,\n AppFeatureStatus,\n AppInfo,\n AppUsageReading,\n AppProfile,\n AppsListParams,\n AppsListResult,\n AppsProfilesListParams,\n AppsProfilesListResult,\n AppsProfilesSaveParams,\n AppsProfilesRemoveParams,\n AppsProfilesRemoveResult,\n AppsOpenParams,\n AppsOpenResult,\n} as const satisfies Record<string, z.ZodType>;\n\nexport type NamedSchemaId = keyof typeof NAMED_SCHEMAS;\n","/**\n * Wire a client's wake() to the browser events that mean \"the person is back\": the page becomes\n * visible again (iOS Safari suspends a background tab's sockets), a back/forward-cache restore\n * (`pageshow` with persisted), and the network returning (`online`). Framework-free; the React\n * binding is `useDesktopWake` in `./react`.\n */\nimport type { DesktopClient, WakeOptions } from \"./types\";\n\n/** The subset of window/document the binding listens on — injectable for tests and non-DOM hosts. */\nexport interface WakeTargets {\n window: Pick<Window, \"addEventListener\" | \"removeEventListener\">;\n document: Pick<Document, \"addEventListener\" | \"removeEventListener\" | \"visibilityState\">;\n}\n\nexport function bindDesktopWake(client: Pick<DesktopClient, \"wake\">, options: WakeOptions & { targets?: WakeTargets } = {}): () => void {\n const targets: WakeTargets | null =\n options.targets ?? (typeof window !== \"undefined\" && typeof document !== \"undefined\" ? { window, document } : null);\n if (!targets) return () => undefined;\n const wakeOptions: WakeOptions = options.probeMs === undefined ? {} : { probeMs: options.probeMs };\n const onVisibility = () => {\n if (targets.document.visibilityState === \"visible\") client.wake(wakeOptions);\n };\n const onWake = () => client.wake(wakeOptions);\n targets.document.addEventListener(\"visibilitychange\", onVisibility);\n targets.window.addEventListener(\"pageshow\", onWake);\n targets.window.addEventListener(\"online\", onWake);\n targets.window.addEventListener(\"focus\", onWake);\n return () => {\n targets.document.removeEventListener(\"visibilitychange\", onVisibility);\n targets.window.removeEventListener(\"pageshow\", onWake);\n targets.window.removeEventListener(\"online\", onWake);\n targets.window.removeEventListener(\"focus\", onWake);\n };\n}\n","import { DesktopProtocolError } from \"../error\";\nimport type { MlProgress, ModelsTranscribeResult, TranscriptionModelId } from \"../schema/models\";\nimport type { DesktopClient } from \"./types\";\n\n/** fs.write carries at most 4 MiB of bytes (base64 in one message). */\nexport const DESKTOP_TRANSCRIBE_MAX_BYTES = 4 * 1024 * 1024;\n\nexport interface DesktopTranscriberOptions {\n /** Whisper size; omitted = the device's default. */\n model?: TranscriptionModelId;\n /** ISO 639-1; omitted = detect. */\n language?: string;\n /** Per call (first use installs the runtime and a model): default 15 minutes. */\n timeoutMs?: number;\n /** Progress for each call (install steps, then each segment as it is recognised). */\n onProgress?: (progress: MlProgress) => void;\n}\n\n/** What a transcription returns: the shape `@ai-matrx/browser-audio`'s TranscriptionTransport expects. */\nexport interface DesktopTranscript {\n text: string;\n language: string;\n duration: number;\n segments: Array<{ start: number; end: number; text: string }>;\n result: ModelsTranscribeResult;\n}\n\nexport interface DesktopTranscriber {\n /** Transcribe recorded audio on the device: written to its temp folder, transcribed, removed. */\n transcribe(file: Blob, signal?: AbortSignal): Promise<DesktopTranscript>;\n}\n\nconst EXT: Record<string, string> = {\n \"audio/webm\": \"webm\",\n \"audio/ogg\": \"ogg\",\n \"audio/mp4\": \"m4a\",\n \"audio/mpeg\": \"mp3\",\n \"audio/wav\": \"wav\",\n \"audio/x-wav\": \"wav\",\n \"video/webm\": \"webm\",\n \"video/mp4\": \"mp4\",\n};\n\nfunction base64(bytes: Uint8Array): string {\n let binary = \"\";\n for (let i = 0; i < bytes.length; i += 0x8000) binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000));\n return btoa(binary);\n}\n\n/**\n * Speech to text on the person's own computer, from any surface connected to it (the app's\n * screen, the web app or the phone through the relay). Structurally a\n * `@ai-matrx/browser-audio` TranscriptionTransport, so every voice input on the platform can\n * transcribe locally: `new BrowserAudioKernel({ transport: createDesktopTranscriber(client) })`.\n *\n * Audio travels as one `fs.write` into the device's temp folder (at most 4 MiB; longer\n * recordings are chunked by the kernel), then `models.transcribe`, then `fs.delete` — every step\n * an ordinary op, so this works through every transport with no special path.\n */\nexport function createDesktopTranscriber(client: DesktopClient, options: DesktopTranscriberOptions = {}): DesktopTranscriber {\n let temp: Promise<string> | null = null;\n const tempDir = () => (temp ??= client.request(\"sysinfo.get\", {}).then((s) => s.paths.temp.replace(/\\/$/, \"\")));\n\n return {\n async transcribe(file, signal) {\n if (file.size > DESKTOP_TRANSCRIBE_MAX_BYTES) {\n throw new DesktopProtocolError(\"PAYLOAD_TOO_LARGE\", \"Recording is larger than 4 MB\", { retryable: false, data: { limit_bytes: DESKTOP_TRANSCRIBE_MAX_BYTES } });\n }\n const type = file.type.split(\";\")[0]?.trim() ?? \"\";\n const name = `matrx-transcribe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}.${EXT[type] ?? \"webm\"}`;\n const path = `${await tempDir()}/${name}`;\n const bytes = new Uint8Array(await file.arrayBuffer());\n await client.request(\"fs.write\", { path, content: base64(bytes), encoding: \"base64\", mode: 0o600 }, signal ? { signal } : {});\n let requestId = \"\";\n const off = options.onProgress\n ? client.on(\"models.progress\", (payload) => {\n if (payload.request_id === requestId) options.onProgress?.(payload.progress);\n })\n : () => undefined;\n try {\n const result = await client.request(\n \"models.transcribe\",\n { path, ...(options.model ? { model: options.model } : {}), ...(options.language ? { language: options.language } : {}) },\n { timeoutMs: options.timeoutMs ?? 15 * 60_000, onRequestId: (id) => (requestId = id), ...(signal ? { signal } : {}) },\n );\n return {\n text: result.text,\n language: result.language,\n duration: result.duration_s,\n segments: result.segments.map((s) => ({ start: s.start_s, end: s.end_s, text: s.text })),\n result,\n };\n } finally {\n off();\n void client.request(\"fs.delete\", { path, to_trash: false }).catch(() => undefined);\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,sBAAwD;;;ACCjD,IAAM,uBAAN,MAAM,8BAA6B,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,MAAqB,SAAiB,UAAsE,CAAC,GAAG;AAC1H,UAAM,SAAS,QAAQ,UAAU,SAAY,SAAY,EAAE,OAAO,QAAQ,MAAM,CAAC;AACjF,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,YAAY,QAAQ,aAAa;AACtC,SAAK,OAAO,QAAQ;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,KAAK,QAAuC;AACjD,QAAI,kBAAkB,sBAAsB,QAAO;AACnD,UAAM,IAAI;AACV,QAAI,KAAK,OAAO,MAAM,YAAY,EAAE,SAAS,0BAA0B,OAAO,EAAE,SAAS,UAAU;AACjG,aAAO,IAAI,sBAAqB,EAAE,MAAuB,OAAO,EAAE,YAAY,WAAW,EAAE,UAAU,OAAO,EAAE,IAAI,GAAG;AAAA,QACnH,WAAW,EAAE,cAAc;AAAA,QAC3B,GAAI,EAAE,QAAQ,OAAO,EAAE,SAAS,WAAW,EAAE,MAAM,EAAE,KAAkB,IAAI,CAAC;AAAA,QAC5E,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AACA,WAAO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UAC1B;AAAA,UACA,EAAE,MAAM,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC,GAAI,GAAI,QAAQ,WAAW,EAAE,UAAU,QAAQ,SAAS,IAAI,CAAC,EAAG;AAAA,UACxH,EAAE,WAAW,QAAQ,aAAa,KAAK,KAAQ,aAAa,CAAC,OAAQ,YAAY,IAAK,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC,EAAG;AAAA,QACtH;AACA,eAAO;AAAA,UACL,MAAM,OAAO;AAAA,UACb,UAAU,OAAO;AAAA,UACjB,UAAU,OAAO;AAAA,UACjB,UAAU,OAAO,SAAS,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,KAAK,EAAE,OAAO,MAAM,EAAE,KAAK,EAAE;AAAA,UACvF;AAAA,QACF;AAAA,MACF,UAAE;AACA,YAAI;AACJ,aAAK,OAAO,QAAQ,aAAa,EAAE,MAAM,UAAU,MAAM,CAAC,EAAE,MAAM,MAAM,MAAS;AAAA,MACnF;AAAA,IACF;AAAA,EACF;AACF;","names":["import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod"]}
1
+ {"version":3,"sources":["../src/client.ts","../src/client/client.ts","../src/error.ts","../src/frame.ts","../src/schema/envelope.ts","../src/schema/errors.ts","../src/schema/primitives.ts","../src/close-policy.ts","../src/schema/frame.ts","../src/schema/sysinfo.ts","../src/schema/fs.ts","../src/schema/exec.ts","../src/schema/session.ts","../src/schema/models.ts","../src/schema/relay.ts","../src/schema/clipboard.ts","../src/schema/proc.ts","../src/schema/system.ts","../src/schema/screen.ts","../src/schema/window.ts","../src/schema/input.ts","../src/schema/power.ts","../src/schema/audio.ts","../src/schema/resources.ts","../src/schema/fs-watch.ts","../src/schema/exec-job.ts","../src/schema/coding.ts","../src/schema/apps.ts","../src/schema/registry.ts","../src/client/wake.ts","../src/client/transcribe.ts"],"sourcesContent":["/**\n * `@ai-matrx/desktop-protocol/client` — the reconnecting client every TypeScript surface uses to\n * drive a Matrx 2 device (phone console, web app, extension): typed requests by op name, byte\n * streams with credit backpressure, transparent terminal reattach (since_seq replay / gap +\n * snapshot), events, heartbeat, relay reauth. Reconnect uses `createBackoff` from\n * `@ai-matrx/realtime` — the one backoff ladder on the platform.\n */\nexport { createDesktopClient, RECONNECT_ALARM_ATTEMPTS } from \"./client/client\";\nexport { bindDesktopWake } from \"./client/wake\";\nexport { createDesktopTranscriber, DESKTOP_TRANSCRIBE_MAX_BYTES } from \"./client/transcribe\";\nexport type { DesktopTranscriber, DesktopTranscriberOptions, DesktopTranscript } from \"./client/transcribe\";\nexport type { WakeTargets } from \"./client/wake\";\nexport type {\n ClientTimers,\n DesktopClient,\n DesktopClientDiagnostic,\n DesktopClientOptions,\n DesktopClientState,\n DesktopClientStatus,\n DesktopStream,\n EventHandler,\n EventName,\n EventPayload,\n RequestOptions,\n StreamHandlers,\n StreamOpName,\n StreamOptions,\n WebSocketFactory,\n WebSocketLike,\n WakeOptions,\n} from \"./client/types\";\nexport { DesktopProtocolError, isDesktopProtocolError } from \"./error\";\nexport type { OpName, OpParams, OpResult } from \"./schema/registry\";\n","/**\n * The reconnecting desktop-protocol client: hello → requests, streams with credit-based\n * backpressure, events, transparent reattach of resource streams (terminals, watches) after a\n * drop, heartbeat, and relay reauth. One instance per device connection. All state lives in the\n * closure — no module-level state (dual ESM/CJS graphs would split it).\n */\nimport { RECONNECT_ALARM_ATTEMPTS, createBackoff } from \"@ai-matrx/realtime\";\nimport { DesktopProtocolError } from \"../error\";\nimport { FRAME_VERSION, FrameChannel, decodeFrame, encodeFrame } from \"../frame\";\nimport type { FrameHeader } from \"../frame\";\nimport { closeRule } from \"../close-policy\";\nimport { CloseCode, CoreToClientMsg, PING_TEXT, PONG_TEXT, Welcome } from \"../schema/envelope\";\nimport type { EndReason, StreamMeta } from \"../schema/envelope\";\nimport type { ProtocolErrorBody } from \"../schema/errors\";\nimport { DEFAULT_MAX_FRAME_PAYLOAD_BYTES, DEFAULT_WINDOW_BYTES } from \"../schema/frame\";\nimport { PROTOCOL_MAJOR, PROTOCOL_MINOR } from \"../schema/primitives\";\nimport { EVENTS, OPS } from \"../schema/registry\";\nimport type { OpName, OpParams, OpResult } from \"../schema/registry\";\nimport type {\n ClientTimers,\n DesktopClient,\n DesktopClientDiagnostic,\n DesktopClientOptions,\n DesktopClientState,\n DesktopStream,\n EventHandler,\n EventName,\n RequestOptions,\n StreamHandlers,\n StreamOpName,\n StreamOptions,\n WakeOptions,\n WebSocketFactory,\n WebSocketLike,\n} from \"./types\";\n\nconst WS_OPEN = 1;\ntype Pending = {\n kind: \"unary\";\n op: string;\n resolve: (value: unknown) => void;\n reject: (error: DesktopProtocolError) => void;\n cleanup: () => void;\n};\n\ninterface StreamState {\n op: string;\n handlers: StreamHandlers;\n options: StreamOptions;\n id: string;\n sid: number | null;\n resourceId: string | null;\n /** Last inbound DATA seq delivered to the consumer. */\n lastSeq: number;\n /** Expected next inbound seq, or null right after a gap/snapshot (resync on next frame). */\n expectSeq: number | null;\n windowBytes: number;\n /** Consumed bytes not yet credited back. */\n consumedUncredited: number;\n /** Outbound (STDIN) credit granted by the core. */\n sendWindow: number;\n sendSeq: number;\n sendQueue: Uint8Array[];\n /** Serializes consumer callbacks so credits follow consumption order. */\n chain: Promise<void>;\n resultSettled: boolean;\n resolveResult: (value: unknown) => void;\n rejectResult: (error: DesktopProtocolError) => void;\n resolveDone: (reason: EndReason) => void;\n rejectDone: (error: DesktopProtocolError) => void;\n ended: boolean;\n /** True while a reattach request is in flight for it. */\n reattaching: boolean;\n}\n\nconst defaultTimers: ClientTimers = {\n setTimeout: (fn, ms) => globalThis.setTimeout(fn, ms),\n clearTimeout: (handle) => globalThis.clearTimeout(handle as ReturnType<typeof globalThis.setTimeout>),\n now: () => Date.now(),\n};\n\nfunction defaultWebSocket(): WebSocketFactory {\n return (url, protocols) => {\n const Ctor = (globalThis as { WebSocket?: new (url: string, protocols?: string[]) => WebSocketLike }).WebSocket;\n if (!Ctor) {\n throw new DesktopProtocolError(\"PLATFORM_UNSUPPORTED\", \"No global WebSocket — pass options.webSocket\");\n }\n return new Ctor(url, protocols);\n };\n}\n\nfunction capOf(op: string): { cap: string; op: string } {\n const dot = op.indexOf(\".\");\n return { cap: op.slice(0, dot), op: op.slice(dot + 1) };\n}\n\nfunction fromBody(body: ProtocolErrorBody): DesktopProtocolError {\n return body.data === undefined\n ? new DesktopProtocolError(body.code, body.message, { retryable: body.retryable })\n : new DesktopProtocolError(body.code, body.message, { retryable: body.retryable, data: body.data });\n}\n\nfunction toBytes(data: unknown): Uint8Array | null {\n if (data instanceof ArrayBuffer) return new Uint8Array(data);\n if (ArrayBuffer.isView(data)) return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n return null;\n}\n\nexport function createDesktopClient(options: DesktopClientOptions): DesktopClient {\n const timers = options.timers ?? defaultTimers;\n const makeSocket = options.webSocket ?? defaultWebSocket();\n const heartbeatMs = options.heartbeatMs ?? 25_000;\n const requestTimeoutMs = options.requestTimeoutMs ?? 70_000;\n const protocolVersion = options.protocolVersion ?? `${PROTOCOL_MAJOR}.${PROTOCOL_MINOR}`;\n const backoff = createBackoff({ ...options.backoff, now: timers.now });\n const diagnose =\n options.onDiagnostic ??\n ((d: DesktopClientDiagnostic) => {\n console.warn(\"[desktop-protocol]\", d.kind, d);\n });\n\n let state: DesktopClientState = {\n status: \"idle\",\n welcome: null,\n attempts: 0,\n retryInMs: null,\n lastError: null,\n lastCloseCode: null,\n outcome: null,\n };\n /** Token refusals (4001/4008) since the last welcome; the second in a row is terminal. */\n let authRefusals = 0;\n const listeners = new Set<() => void>();\n const readyWaiters = new Set<{ resolve: (w: Welcome) => void; reject: (e: DesktopProtocolError) => void }>();\n const pending = new Map<string, Pending>();\n const streams = new Map<string, StreamState>(); // by current request id\n const bySid = new Map<number, StreamState>();\n const eventHandlers = new Map<string, Set<EventHandler<EventName>>>();\n let socket: WebSocketLike | null = null;\n let socketGeneration = 0;\n let nextId = 0;\n let helloId: string | null = null;\n let reconnectTimer: unknown = null;\n let heartbeatTimer: unknown = null;\n let probeTimer: unknown = null;\n let lastHeardAt = 0;\n /** Inbound messages on the current socket — the wake probe's \"was anything heard since?\" */\n let heardCount = 0;\n let closedByUser = false;\n\n const newId = (prefix: string) => `${prefix}${(++nextId).toString(36)}`;\n\n function setState(patch: Partial<DesktopClientState>): void {\n state = { ...state, ...patch };\n for (const listener of [...listeners]) {\n try {\n listener();\n } catch (error) {\n diagnose({ kind: \"handler_threw\", where: \"subscribe listener\", error });\n }\n }\n }\n\n function sendJson(message: unknown): boolean {\n if (!socket || socket.readyState !== WS_OPEN) return false;\n socket.send(JSON.stringify(message));\n return true;\n }\n\n // ── connection lifecycle ────────────────────────────────────────────────────\n\n function connect(): void {\n if (state.status === \"connecting\" || state.status === \"handshaking\" || state.status === \"open\") return;\n if (state.status === \"closed\" || state.status === \"idle\") authRefusals = 0; // a deliberate (re)start\n closedByUser = false;\n if (reconnectTimer !== null) {\n timers.clearTimeout(reconnectTimer);\n reconnectTimer = null;\n }\n void openSocket();\n }\n\n async function openSocket(): Promise<void> {\n const generation = ++socketGeneration;\n setState({ status: \"connecting\", retryInMs: null });\n let ws: WebSocketLike;\n try {\n const url = typeof options.url === \"function\" ? await options.url() : options.url;\n const protocols = options.protocols ? await options.protocols() : [];\n if (generation !== socketGeneration || closedByUser) return;\n ws = makeSocket(url, protocols);\n } catch (error) {\n if (generation !== socketGeneration) return;\n const err =\n error instanceof DesktopProtocolError\n ? error\n : new DesktopProtocolError(\"INTERNAL\", \"Could not open the connection\", { retryable: true, cause: error });\n onSocketGone(generation, null, err);\n return;\n }\n socket = ws;\n ws.binaryType = \"arraybuffer\";\n ws.onopen = () => {\n if (generation !== socketGeneration) return;\n lastHeardAt = timers.now();\n helloId = newId(\"h\");\n setState({ status: \"handshaking\" });\n sendJson({ type: \"hello\", id: helloId, protocolVersion, clientType: options.clientType, clientVersion: options.clientVersion });\n scheduleHeartbeat(generation);\n };\n ws.onmessage = (event) => {\n if (generation !== socketGeneration) return;\n lastHeardAt = timers.now();\n heardCount++;\n onMessage(event.data);\n };\n ws.onerror = () => {\n // The close event that always follows carries the code; nothing to do here.\n };\n ws.onclose = (event) => {\n if (generation !== socketGeneration) return;\n onSocketGone(generation, event.code, null);\n };\n }\n\n function scheduleHeartbeat(generation: number): void {\n if (heartbeatTimer !== null) timers.clearTimeout(heartbeatTimer);\n heartbeatTimer = timers.setTimeout(() => {\n heartbeatTimer = null;\n if (generation !== socketGeneration || !socket) return;\n const silentMs = timers.now() - lastHeardAt;\n if (silentMs >= heartbeatMs * 2) {\n diagnose({ kind: \"heartbeat_timeout\", silentMs });\n const dead = socket;\n onSocketGone(generation, null, new DesktopProtocolError(\"TIMEOUT\", \"Connection went silent\", { retryable: true }));\n try {\n dead.close(CloseCode.NORMAL, \"heartbeat timeout\");\n } catch {\n // already closing\n }\n return;\n }\n if (socket.readyState === WS_OPEN) socket.send(PING_TEXT);\n scheduleHeartbeat(generation);\n }, heartbeatMs);\n }\n\n /** The socket is gone (close event, open failure or heartbeat death). */\n function onSocketGone(generation: number, code: number | null, error: DesktopProtocolError | null): void {\n if (generation !== socketGeneration) return;\n socketGeneration++; // ignore anything the dead socket still emits\n if (socket) {\n socket.onopen = socket.onmessage = socket.onclose = socket.onerror = null;\n }\n socket = null;\n helloId = null;\n if (heartbeatTimer !== null) {\n timers.clearTimeout(heartbeatTimer);\n heartbeatTimer = null;\n }\n if (probeTimer !== null) {\n timers.clearTimeout(probeTimer);\n probeTimer = null;\n }\n // The one close table (close-policy.ts) decides: retry, retry with a fresh token, or stop.\n const rule = code === null ? null : closeRule(code);\n if (rule?.action === \"reauth\") authRefusals++;\n const stopped = rule !== null && (rule.action === \"stop\" || (rule.action === \"reauth\" && authRefusals >= 2));\n const terminal = stopped && rule ? rule : undefined;\n const lost =\n error ??\n (terminal\n ? new DesktopProtocolError(terminal.error[0], terminal.error[1])\n : rule && rule.action === \"reauth\"\n ? new DesktopProtocolError(rule.error[0], rule.error[1], { retryable: true })\n : new DesktopProtocolError(\"DEVICE_OFFLINE\", \"Connection lost\", { retryable: true }));\n\n // Unary requests cannot survive a drop: the caller decides whether to retry.\n for (const [id, p] of pending) {\n pending.delete(id);\n p.cleanup();\n p.reject(lost);\n }\n // Resource streams survive (reattach on reconnect); everything else ends now.\n bySid.clear();\n for (const [id, s] of streams) {\n if (s.resourceId !== null && terminal === undefined && !closedByUser) {\n s.sid = null;\n s.reattaching = false;\n continue;\n }\n streams.delete(id);\n endStream(s, null, lost);\n }\n\n if (closedByUser || terminal) {\n setState({\n status: \"closed\",\n welcome: null,\n lastError: closedByUser ? state.lastError : lost,\n lastCloseCode: code,\n retryInMs: null,\n outcome: closedByUser ? null : (terminal?.outcome ?? null),\n });\n rejectReadyWaiters(lost);\n return;\n }\n const delay = backoff.nextDelayMs();\n if (backoff.isAlarming()) diagnose({ kind: \"reconnect_alarm\", attempts: backoff.attempts() });\n setState({ status: \"reconnecting\", welcome: null, attempts: backoff.attempts(), retryInMs: delay, lastError: lost, lastCloseCode: code });\n reconnectTimer = timers.setTimeout(() => {\n reconnectTimer = null;\n if (!closedByUser) void openSocket();\n }, delay);\n }\n\n function rejectReadyWaiters(error: DesktopProtocolError): void {\n for (const w of [...readyWaiters]) {\n readyWaiters.delete(w);\n w.reject(error);\n }\n }\n\n function close(): void {\n closedByUser = true;\n if (reconnectTimer !== null) {\n timers.clearTimeout(reconnectTimer);\n reconnectTimer = null;\n }\n const cancelled = new DesktopProtocolError(\"CANCELLED\", \"Client closed\");\n const ws = socket;\n if (ws) {\n onSocketGone(socketGeneration, CloseCode.NORMAL, cancelled);\n try {\n ws.close(CloseCode.NORMAL, \"client closed\");\n } catch {\n // already closed\n }\n } else {\n for (const [id, s] of streams) {\n streams.delete(id);\n endStream(s, null, cancelled);\n }\n setState({ status: \"closed\", retryInMs: null });\n rejectReadyWaiters(cancelled);\n }\n }\n\n // ── inbound ────────────────────────────────────────────────────────────────\n\n function onMessage(data: unknown): void {\n if (typeof data === \"string\") {\n if (data === PONG_TEXT) return;\n let json: unknown;\n try {\n json = JSON.parse(data);\n } catch {\n diagnose({ kind: \"malformed_message\", detail: \"not JSON\" });\n return;\n }\n const parsed = CoreToClientMsg.safeParse(json);\n if (!parsed.success) {\n diagnose({ kind: \"malformed_message\", detail: parsed.error.issues.map((i) => `${i.path.join(\".\")}: ${i.message}`).join(\"; \") });\n return;\n }\n onEnvelope(parsed.data);\n return;\n }\n const bytes = toBytes(data);\n if (bytes === null) {\n diagnose({ kind: \"malformed_message\", detail: \"binary message is not an ArrayBuffer/view (set binaryType)\" });\n return;\n }\n let frame: ReturnType<typeof decodeFrame>;\n try {\n frame = decodeFrame(bytes);\n } catch (error) {\n diagnose({ kind: \"malformed_message\", detail: error instanceof Error ? error.message : String(error) });\n return;\n }\n onFrame(frame.header, frame.payload);\n }\n\n function onEnvelope(msg: CoreToClientMsg): void {\n switch (msg.type) {\n case \"response\": {\n if (msg.id === helloId) return onWelcome(msg.result);\n const s = streams.get(msg.id);\n if (s) return onStreamResult(s, msg.result);\n const p = pending.get(msg.id);\n if (!p) return diagnose({ kind: \"unknown_request\", id: msg.id, type: msg.type });\n pending.delete(msg.id);\n p.cleanup();\n p.resolve(msg.result);\n return;\n }\n case \"error\": {\n const error = fromBody(msg.error);\n if (msg.id === helloId) return onHelloRefused(error);\n const s = streams.get(msg.id);\n if (s) {\n if (s.reattaching && s.resourceId !== null) diagnose({ kind: \"reattach_failed\", resourceId: s.resourceId, error });\n streams.delete(msg.id);\n if (s.sid !== null) bySid.delete(s.sid);\n return endStream(s, null, error);\n }\n const p = pending.get(msg.id);\n if (!p) return diagnose({ kind: \"unknown_request\", id: msg.id, type: msg.type });\n pending.delete(msg.id);\n p.cleanup();\n p.reject(error);\n return;\n }\n case \"stream\": {\n const s = streams.get(msg.id);\n if (!s) return diagnose({ kind: \"unknown_request\", id: msg.id, type: msg.type });\n onStreamMeta(s, msg.meta);\n return;\n }\n case \"end\": {\n const s = streams.get(msg.id);\n if (!s) return diagnose({ kind: \"unknown_request\", id: msg.id, type: msg.type });\n // Deliver everything already queued before announcing the end.\n void s.chain.then(() => {\n streams.delete(s.id);\n if (s.sid !== null) bySid.delete(s.sid);\n endStream(s, msg.reason ?? \"completed\", null);\n });\n return;\n }\n case \"credit\": {\n const s = streams.get(msg.id);\n if (!s) return diagnose({ kind: \"unknown_request\", id: msg.id, type: msg.type });\n s.sendWindow += msg.n;\n flushSend(s);\n return;\n }\n case \"event\": {\n const key = `${msg.cap}.${msg.name}`;\n const schema = (EVENTS as Record<string, (typeof EVENTS)[EventName]>)[key];\n if (!schema) return diagnose({ kind: \"malformed_message\", detail: `unknown event ${key}` });\n const payload = schema.safeParse(msg.payload);\n if (!payload.success) return diagnose({ kind: \"malformed_message\", detail: `event ${key}: invalid payload` });\n if (key === \"relay.auth_expiring\" && options.getToken) {\n options.getToken().then(reauth, (error: unknown) => diagnose({ kind: \"reauth_failed\", error }));\n }\n for (const handler of [...(eventHandlers.get(key) ?? [])]) {\n try {\n handler(payload.data as never, msg.resourceId);\n } catch (error) {\n diagnose({ kind: \"handler_threw\", where: `event ${key}`, error });\n }\n }\n return;\n }\n }\n }\n\n function onWelcome(result: unknown): void {\n const welcome = Welcome.safeParse(result);\n if (!welcome.success) {\n onHelloRefused(new DesktopProtocolError(\"PROTOCOL_ERROR\", \"Malformed welcome\"));\n return;\n }\n helloId = null;\n backoff.markConnected();\n authRefusals = 0;\n setState({ status: \"open\", welcome: welcome.data, attempts: 0, retryInMs: null, lastError: null, outcome: null });\n for (const w of [...readyWaiters]) {\n readyWaiters.delete(w);\n w.resolve(welcome.data);\n }\n // Transparent reattach: every surviving resource stream continues where its consumer stopped.\n for (const s of [...streams.values()]) {\n if (s.sid === null && s.resourceId !== null && !s.ended) reattach(s, welcome.data);\n }\n }\n\n function onHelloRefused(error: DesktopProtocolError): void {\n // An unsupported version will not fix itself on retry: UPGRADE_REQUIRED is a terminal close.\n const ws = socket;\n onSocketGone(socketGeneration, error.code === \"PROTOCOL_VERSION_UNSUPPORTED\" ? CloseCode.UPGRADE_REQUIRED : null, error);\n try {\n ws?.close(CloseCode.NORMAL, \"hello refused\");\n } catch {\n // already closed\n }\n }\n\n // ── streams ────────────────────────────────────────────────────────────────\n\n function onStreamResult(s: StreamState, result: unknown): void {\n if (s.reattaching) {\n // session.attach result = ResourceInfo; the stream continues on the new id.\n s.reattaching = false;\n safeCall(\"onReattached\", () => s.handlers.onReattached?.());\n return;\n }\n const rid = (result as { resource_id?: unknown } | null)?.resource_id;\n if (typeof rid === \"string\") s.resourceId = rid;\n if (!s.resultSettled) {\n s.resultSettled = true;\n s.resolveResult(result);\n }\n }\n\n function onStreamMeta(s: StreamState, meta: StreamMeta): void {\n if (meta.kind === \"open\") {\n if (s.sid !== null) bySid.delete(s.sid);\n s.sid = meta.sid;\n s.windowBytes = meta.window_bytes;\n if (meta.resource_id !== undefined) s.resourceId = meta.resource_id;\n bySid.set(meta.sid, s);\n flushSend(s);\n } else {\n // gap or snapshot: the next DATA frame re-establishes the sequence.\n s.expectSeq = null;\n }\n safeCall(\"onMeta\", () => s.handlers.onMeta?.(meta));\n }\n\n function onFrame(header: FrameHeader, payload: Uint8Array): void {\n const s = bySid.get(header.sid);\n if (!s) {\n diagnose({ kind: \"unknown_stream\", sid: header.sid });\n return;\n }\n const isData = header.channel === FrameChannel.DATA || header.channel === FrameChannel.STDERR;\n const isSnapshot = header.channel === FrameChannel.SNAPSHOT;\n if (!isData && !isSnapshot) {\n diagnose({ kind: \"malformed_message\", detail: `channel ${header.channel} is not client-bound` });\n return;\n }\n if (isData) {\n if (s.expectSeq !== null && header.seq !== s.expectSeq) {\n diagnose({ kind: \"seq_gap\", id: s.id, expected: s.expectSeq, received: header.seq });\n }\n s.expectSeq = header.seq + 1;\n }\n // Copy: the payload is a view into a buffer the transport may reuse.\n const bytes = payload.slice();\n const handler = isData ? s.handlers.onData : s.handlers.onSnapshot;\n s.chain = s.chain.then(async () => {\n if (s.ended) return;\n try {\n await handler?.(bytes, header);\n } catch (error) {\n diagnose({ kind: \"handler_threw\", where: isData ? \"onData\" : \"onSnapshot\", error });\n }\n if (isData) s.lastSeq = header.seq;\n grantCredit(s, bytes.byteLength);\n });\n }\n\n function grantCredit(s: StreamState, consumed: number): void {\n s.consumedUncredited += consumed;\n // Batch: one credit per quarter window keeps the pipe full without a message per frame.\n if (s.consumedUncredited >= Math.max(1, Math.floor(s.windowBytes / 4))) {\n if (sendJson({ type: \"credit\", id: s.id, n: s.consumedUncredited })) s.consumedUncredited = 0;\n }\n }\n\n function flushSend(s: StreamState): void {\n if (s.sid === null || !socket || socket.readyState !== WS_OPEN) return;\n const maxPayload = state.welcome?.limits.max_frame_payload_bytes ?? DEFAULT_MAX_FRAME_PAYLOAD_BYTES;\n while (s.sendQueue.length > 0 && s.sendWindow > 0) {\n const head = s.sendQueue[0]!;\n const n = Math.min(head.byteLength, s.sendWindow, maxPayload);\n const chunk = head.subarray(0, n);\n if (n === head.byteLength) s.sendQueue.shift();\n else s.sendQueue[0] = head.subarray(n);\n s.sendWindow -= n;\n s.sendSeq += 1;\n socket.send(encodeFrame({ version: FRAME_VERSION, flags: 0, channel: FrameChannel.STDIN, cid: 0, sid: s.sid, seq: s.sendSeq }, chunk));\n }\n }\n\n function endStream(s: StreamState, reason: EndReason | null, error: DesktopProtocolError | null): void {\n if (s.ended) return;\n s.ended = true;\n s.sendQueue = [];\n if (!s.resultSettled) {\n s.resultSettled = true;\n s.rejectResult(error ?? new DesktopProtocolError(\"INTERNAL\", \"Stream ended before its result\"));\n }\n if (error) s.rejectDone(error);\n else s.resolveDone(reason ?? \"completed\");\n }\n\n function reattach(s: StreamState, welcome: Welcome): void {\n const id = newId(\"a\");\n streams.delete(s.id);\n s.id = id;\n s.reattaching = true;\n s.expectSeq = s.lastSeq > 0 ? s.lastSeq + 1 : null;\n s.consumedUncredited = 0;\n s.sendWindow = welcome.limits.default_window_bytes;\n s.sendSeq = 0;\n streams.set(id, s);\n const params: Record<string, unknown> = { resource_id: s.resourceId, mode: s.options.mode ?? \"control\" };\n if (s.lastSeq > 0) params.since_seq = s.lastSeq;\n if (s.options.windowBytes !== undefined) params.window_bytes = s.options.windowBytes;\n sendJson({ id, type: \"request\", cap: \"session\", op: \"attach\", params });\n }\n\n function safeCall(where: string, fn: () => void): void {\n try {\n fn();\n } catch (error) {\n diagnose({ kind: \"handler_threw\", where, error });\n }\n }\n\n // ── public API ─────────────────────────────────────────────────────────────\n\n function ready(opts: RequestOptions = {}): Promise<Welcome> {\n if (state.status === \"open\" && state.welcome) return Promise.resolve(state.welcome);\n if (state.status === \"closed\") {\n return Promise.reject(state.lastError ?? new DesktopProtocolError(\"CANCELLED\", \"Client is closed\"));\n }\n if (state.status === \"idle\") connect();\n return new Promise((resolve, reject) => {\n const waiter = {\n resolve: (w: Welcome) => {\n done();\n resolve(w);\n },\n reject: (e: DesktopProtocolError) => {\n done();\n reject(e);\n },\n };\n const timeoutMs = opts.timeoutMs ?? requestTimeoutMs;\n const timer = timers.setTimeout(() => waiter.reject(new DesktopProtocolError(\"DEVICE_OFFLINE\", \"Device not reachable\", { retryable: true })), timeoutMs);\n const onAbort = () => waiter.reject(new DesktopProtocolError(\"CANCELLED\", \"Aborted\"));\n opts.signal?.addEventListener(\"abort\", onAbort, { once: true });\n function done() {\n readyWaiters.delete(waiter);\n timers.clearTimeout(timer);\n opts.signal?.removeEventListener(\"abort\", onAbort);\n }\n readyWaiters.add(waiter);\n });\n }\n\n async function request<N extends OpName>(op: N, params: OpParams<N>, opts: RequestOptions = {}): Promise<OpResult<N>> {\n if (OPS[op].kind !== \"unary\") {\n throw new DesktopProtocolError(\"INVALID_PARAMS\", `${op} is a ${OPS[op].kind} op — use stream()`);\n }\n await ready(opts);\n const id = newId(\"r\");\n if (opts.onRequestId) safeCall(\"onRequestId\", () => opts.onRequestId?.(id));\n return new Promise<OpResult<N>>((resolve, reject) => {\n const timeoutMs = opts.timeoutMs ?? requestTimeoutMs;\n const timer = timers.setTimeout(() => {\n pending.delete(id);\n cleanup();\n sendJson({ id, type: \"cancel\" });\n reject(new DesktopProtocolError(\"TIMEOUT\", `${op} timed out`, { retryable: true }));\n }, timeoutMs);\n const onAbort = () => {\n pending.delete(id);\n cleanup();\n sendJson({ id, type: \"cancel\" });\n reject(new DesktopProtocolError(\"CANCELLED\", \"Aborted\"));\n };\n function cleanup() {\n timers.clearTimeout(timer);\n opts.signal?.removeEventListener(\"abort\", onAbort);\n }\n opts.signal?.addEventListener(\"abort\", onAbort, { once: true });\n pending.set(id, { kind: \"unary\", op, resolve: resolve as (v: unknown) => void, reject, cleanup });\n if (!sendJson({ id, type: \"request\", ...capOf(op), params })) {\n pending.delete(id);\n cleanup();\n reject(new DesktopProtocolError(\"DEVICE_OFFLINE\", \"Connection lost\", { retryable: true }));\n }\n });\n }\n\n function stream<N extends StreamOpName>(\n op: N,\n params: OpParams<N>,\n handlers: StreamHandlers = {},\n opts: StreamOptions = {},\n ): DesktopStream<N> {\n let resolveResult!: (v: unknown) => void;\n let rejectResult!: (e: DesktopProtocolError) => void;\n let resolveDone!: (r: EndReason) => void;\n let rejectDone!: (e: DesktopProtocolError) => void;\n const result = new Promise<OpResult<N>>((res, rej) => {\n resolveResult = res as (v: unknown) => void;\n rejectResult = rej;\n });\n const done = new Promise<EndReason>((res, rej) => {\n resolveDone = res;\n rejectDone = rej;\n });\n // Consumers often await only one of the two; never leave the other as an unhandled rejection.\n result.catch(() => undefined);\n done.catch(() => undefined);\n\n // A caller-started session.attach (a page reload reattaching by the resource id it kept in its\n // URL) is a resource stream from its first byte: it survives drops like the stream that created\n // the resource, and its sequence continues from since_seq rather than from 1.\n const attach = op === \"session.attach\" ? (params as { resource_id: string; since_seq?: number }) : null;\n const s: StreamState = {\n op,\n handlers,\n options: opts,\n id: newId(\"s\"),\n sid: null,\n resourceId: attach ? attach.resource_id : null,\n lastSeq: attach?.since_seq ?? 0,\n expectSeq: attach ? (attach.since_seq === undefined ? null : attach.since_seq + 1) : 1,\n windowBytes: opts.windowBytes ?? DEFAULT_WINDOW_BYTES,\n consumedUncredited: 0,\n sendWindow: DEFAULT_WINDOW_BYTES,\n sendSeq: 0,\n sendQueue: [],\n chain: Promise.resolve(),\n resultSettled: false,\n resolveResult,\n rejectResult,\n resolveDone,\n rejectDone,\n ended: false,\n reattaching: false,\n };\n\n const start = async () => {\n let welcome: Welcome;\n try {\n welcome = await ready(opts);\n } catch (error) {\n endStream(s, null, error as DesktopProtocolError);\n return;\n }\n if (s.ended) return;\n s.sendWindow = welcome.limits.default_window_bytes;\n if (opts.windowBytes === undefined) s.windowBytes = welcome.limits.default_window_bytes;\n streams.set(s.id, s);\n const wire: Record<string, unknown> = { ...(params as Record<string, unknown>) };\n if (opts.windowBytes !== undefined && \"window_bytes\" in OPS[op].params.shape) wire.window_bytes = opts.windowBytes;\n if (!sendJson({ id: s.id, type: \"request\", ...capOf(op), params: wire })) {\n streams.delete(s.id);\n endStream(s, null, new DesktopProtocolError(\"DEVICE_OFFLINE\", \"Connection lost\", { retryable: true }));\n }\n };\n void start();\n opts.signal?.addEventListener(\"abort\", () => handle.cancel(), { once: true });\n\n const encoder = new TextEncoder();\n const handle: DesktopStream<N> = {\n get id() {\n return s.id;\n },\n result,\n done,\n get resourceId() {\n return s.resourceId;\n },\n get lastSeq() {\n return s.lastSeq;\n },\n write(data) {\n if (s.ended) throw new DesktopProtocolError(\"RESOURCE_GONE\", \"Stream has ended\");\n const bytes = typeof data === \"string\" ? encoder.encode(data) : data;\n if (bytes.byteLength === 0) return;\n s.sendQueue.push(bytes);\n flushSend(s);\n },\n cancel() {\n if (s.ended) return;\n if (!sendJson({ id: s.id, type: \"cancel\" })) {\n streams.delete(s.id);\n endStream(s, \"cancelled\", null);\n }\n },\n async detach() {\n if (s.ended) return;\n if (s.resourceId === null) throw new DesktopProtocolError(\"INVALID_PARAMS\", \"Only resource streams can be detached\");\n const resourceId = s.resourceId;\n streams.delete(s.id);\n if (s.sid !== null) bySid.delete(s.sid);\n endStream(s, \"detached\", null);\n await request(\"session.detach\", { resource_id: resourceId });\n },\n };\n return handle;\n }\n\n function on<E extends EventName>(name: E, handler: EventHandler<E>): () => void {\n let set = eventHandlers.get(name);\n if (!set) {\n set = new Set();\n eventHandlers.set(name, set);\n }\n set.add(handler as EventHandler<EventName>);\n return () => {\n set.delete(handler as EventHandler<EventName>);\n };\n }\n\n function reauth(token: string): void {\n sendJson({ type: \"relay\", op: \"reauth\", token });\n }\n\n function wake(opts: WakeOptions = {}): void {\n if (closedByUser || state.status === \"closed\") return;\n if (state.status === \"idle\" || state.status === \"reconnecting\") {\n connect(); // dial now; connect() cancels the scheduled backoff timer\n return;\n }\n if (state.status === \"connecting\" || !socket || probeTimer !== null) return;\n const generation = socketGeneration;\n const heardBefore = heardCount;\n try {\n socket.send(PING_TEXT);\n } catch {\n // A socket that cannot even send is dead: fall through to the probe verdict.\n }\n probeTimer = timers.setTimeout(() => {\n probeTimer = null;\n if (generation !== socketGeneration || !socket) return;\n if (heardCount > heardBefore) return; // answered: the socket is alive\n const silentMs = timers.now() - lastHeardAt;\n diagnose({ kind: \"heartbeat_timeout\", silentMs });\n const dead = socket;\n onSocketGone(generation, null, new DesktopProtocolError(\"TIMEOUT\", \"Connection went silent\", { retryable: true }));\n try {\n dead.close(CloseCode.NORMAL, \"wake probe timeout\");\n } catch {\n // already closing\n }\n if (state.status === \"reconnecting\") connect(); // the person is looking: no backoff wait\n }, opts.probeMs ?? 4000);\n }\n\n return {\n connect,\n close,\n getState: () => state,\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n ready,\n request,\n stream,\n on,\n reauth,\n wake,\n };\n}\n\nexport { RECONNECT_ALARM_ATTEMPTS };\n","/**\n * The one error type every package entry throws. It carries the wire ErrorCode (SPEC §5), so a\n * caller branches on `code`/`retryable`/`data.reason` and never parses a message. Zod-free on\n * purpose: `./frame` (the relay hot path) throws it without pulling the schema graph.\n */\nimport type { ErrorCodeName, ErrorData } from \"./types\";\n\nexport class DesktopProtocolError extends Error {\n readonly code: ErrorCodeName;\n readonly retryable: boolean;\n readonly data: ErrorData | undefined;\n\n constructor(code: ErrorCodeName, message: string, options: { retryable?: boolean; data?: ErrorData; cause?: unknown } = {}) {\n super(message, options.cause === undefined ? undefined : { cause: options.cause });\n this.name = \"DesktopProtocolError\";\n this.code = code;\n this.retryable = options.retryable ?? false;\n this.data = options.data;\n }\n\n /**\n * Any thrown value as a DesktopProtocolError, keeping its code, message and data. Each built entry\n * (`.`, `./client`, `./react`) carries its own copy of this class, so `instanceof` alone misses an\n * error thrown by a sibling entry and reports a real NOT_FOUND as INTERNAL; this checks the shape.\n */\n static from(caught: unknown): DesktopProtocolError {\n if (caught instanceof DesktopProtocolError) return caught;\n const e = caught as { name?: unknown; code?: unknown; message?: unknown; retryable?: unknown; data?: unknown } | null;\n if (e && typeof e === \"object\" && e.name === \"DesktopProtocolError\" && typeof e.code === \"string\") {\n return new DesktopProtocolError(e.code as ErrorCodeName, typeof e.message === \"string\" ? e.message : String(e.code), {\n retryable: e.retryable === true,\n ...(e.data && typeof e.data === \"object\" ? { data: e.data as ErrorData } : {}),\n cause: caught,\n });\n }\n return new DesktopProtocolError(\"INTERNAL\", caught instanceof Error ? caught.message : String(caught), { cause: caught });\n }\n\n /** The wire body (ProtocolErrorBody) — what a core or relay sends for this error. */\n toBody(): { code: ErrorCodeName; message: string; retryable: boolean; data?: ErrorData } {\n return this.data === undefined\n ? { code: this.code, message: this.message, retryable: this.retryable }\n : { code: this.code, message: this.message, retryable: this.retryable, data: this.data };\n }\n}\n\nexport function isDesktopProtocolError(value: unknown): value is DesktopProtocolError {\n return value instanceof DesktopProtocolError || (value instanceof Error && value.name === \"DesktopProtocolError\" && \"code\" in value);\n}\n","/**\n * `@ai-matrx/desktop-protocol/frame` — the 16-byte binary frame codec. ZOD-FREE by design: the\n * relay Worker's hot path imports only this entry and must stay tiny.\n *\n * off size field notes\n * 0 u8 version = 1\n * 1 u8 flags bit0 FIN (last frame of this stream), bit1 REPLAY (from ring buffer),\n * bits2-7 reserved = 0\n * 2 u8 channel see FrameChannel\n * 3 u8 reserved = 0\n * 4 u32 cid relay connection id. 0 on every client↔relay hop; the relay stamps it on\n * the relay→device hop and strips it on the way back (rewrites 4 bytes in\n * place — the relay never parses payloads).\n * 8 u32 sid stream id, announced by the core in stream{meta:{kind:\"open\",sid}}\n * 12 u32 seq per-stream frame sequence, starts at 1, strictly +1\n *\n * Big-endian. Payload length = message length − 16 (one frame = one WS binary message).\n * Python struct format: \">BBBBIII\". The zod twin (FrameHeader in the root entry, and so the JSON\n * Schema and Pydantic model) is checked against this file by src/frame.test.ts.\n */\nimport { DesktopProtocolError } from \"./error\";\n\nexport const FRAME_HEADER_BYTES = 16 as const;\nexport const FRAME_VERSION = 1 as const;\nexport const FRAME_STRUCT_FORMAT = \">BBBBIII\" as const;\nexport const FrameFlag = { FIN: 0b01, REPLAY: 0b10 } as const;\nexport const FrameChannel = {\n /** core→client: pty output, fs.read_stream bytes */\n DATA: 0,\n /** core→client: stderr of a non-pty process (reserved for exec.spawn in v1.1) */\n STDERR: 1,\n /** client→core: keystrokes / stdin to sid */\n STDIN: 2,\n /** core→client: serialized terminal screen (attach when since_seq is outside the ring) */\n SNAPSHOT: 3,\n /** relay↔device hop only: a JSON envelope carried inside a binary frame so the relay can route\n * by cid without parsing JSON. Never seen by clients. */\n ENVELOPE: 255,\n} as const;\n\nexport type FrameChannelValue = (typeof FrameChannel)[keyof typeof FrameChannel];\n\nexport interface FrameHeader {\n version: typeof FRAME_VERSION;\n /** 0..3 — FrameFlag bits. */\n flags: number;\n channel: FrameChannelValue;\n cid: number;\n sid: number;\n seq: number;\n}\n\nexport interface DecodedFrame {\n header: FrameHeader;\n /** A VIEW into the input buffer (no copy). Copy it if you keep it past the input's lifetime. */\n payload: Uint8Array;\n}\n\nconst U32_MAX = 4_294_967_295;\nconst CHANNELS: ReadonlySet<number> = new Set(Object.values(FrameChannel));\n\nfunction frameError(message: string): DesktopProtocolError {\n return new DesktopProtocolError(\"PROTOCOL_ERROR\", message);\n}\n\nfunction checkU32(name: string, value: number): void {\n if (!Number.isInteger(value) || value < 0 || value > U32_MAX) throw frameError(`frame ${name} is not a u32: ${value}`);\n}\n\n/** Validate a header without zod. Throws DesktopProtocolError(PROTOCOL_ERROR). */\nexport function assertFrameHeader(h: FrameHeader): void {\n if (h.version !== FRAME_VERSION) throw frameError(`unsupported frame version ${String(h.version)}`);\n if (!Number.isInteger(h.flags) || h.flags < 0 || h.flags > 3) throw frameError(`reserved frame flag bits set: ${h.flags}`);\n if (!CHANNELS.has(h.channel)) throw frameError(`unknown frame channel ${String(h.channel)}`);\n checkU32(\"cid\", h.cid);\n checkU32(\"sid\", h.sid);\n checkU32(\"seq\", h.seq);\n}\n\nexport function encodeFrame(h: FrameHeader, payload: Uint8Array): Uint8Array {\n assertFrameHeader(h);\n const out = new Uint8Array(FRAME_HEADER_BYTES + payload.byteLength);\n const v = new DataView(out.buffer);\n v.setUint8(0, h.version);\n v.setUint8(1, h.flags);\n v.setUint8(2, h.channel);\n v.setUint8(3, 0);\n v.setUint32(4, h.cid);\n v.setUint32(8, h.sid);\n v.setUint32(12, h.seq);\n out.set(payload, FRAME_HEADER_BYTES);\n return out;\n}\n\nexport function decodeFrame(buf: ArrayBuffer | Uint8Array): DecodedFrame {\n const bytes = buf instanceof Uint8Array ? buf : new Uint8Array(buf);\n if (bytes.byteLength < FRAME_HEADER_BYTES) throw frameError(`short frame: ${bytes.byteLength} bytes`);\n const v = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n if (v.getUint8(3) !== 0) throw frameError(\"reserved frame byte 3 is not 0\");\n const header = {\n version: v.getUint8(0),\n flags: v.getUint8(1),\n channel: v.getUint8(2),\n cid: v.getUint32(4),\n sid: v.getUint32(8),\n seq: v.getUint32(12),\n } as FrameHeader;\n assertFrameHeader(header);\n return { header, payload: bytes.subarray(FRAME_HEADER_BYTES) };\n}\n\n/** Read only the 4-byte cid (relay routing) without decoding the rest. */\nexport function readCid(frame: Uint8Array): number {\n if (frame.byteLength < FRAME_HEADER_BYTES) throw frameError(`short frame: ${frame.byteLength} bytes`);\n return new DataView(frame.buffer, frame.byteOffset, frame.byteLength).getUint32(4);\n}\n\n/** Relay hot path: rewrite only the cid IN PLACE, never touch the payload. Returns the same array. */\nexport function stampCid(frame: Uint8Array, cid: number): Uint8Array {\n if (frame.byteLength < FRAME_HEADER_BYTES) throw frameError(`short frame: ${frame.byteLength} bytes`);\n checkU32(\"cid\", cid);\n new DataView(frame.buffer, frame.byteOffset, frame.byteLength).setUint32(4, cid);\n return frame;\n}\n\nexport function hasFlag(header: FrameHeader, flag: (typeof FrameFlag)[keyof typeof FrameFlag]): boolean {\n return (header.flags & flag) !== 0;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Relay ↔ device hop (never seen by clients). Every JSON envelope rides an ENVELOPE frame with\n// flags 0, sid 0, seq 0 and the client's cid; byte frames carry that cid too.\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** cid 0 on an ENVELOPE frame from the device: the relay delivers it to every client. */\nexport const BROADCAST_CID = 0 as const;\n\n/**\n * Connection end: an ENVELOPE frame with FIN, sid 0, seq 0 and NO payload, for connection `cid`.\n * Relay → device: client `cid` is gone — cancel its streams, detach its sessions (idempotent; it\n * may arrive more than once). Device → relay: close client `cid`.\n */\nexport function connectionEndFrame(cid: number): Uint8Array {\n if (cid === BROADCAST_CID) throw frameError(\"a connection end needs a client cid, not the broadcast cid 0\");\n return encodeFrame({ version: FRAME_VERSION, flags: FrameFlag.FIN, channel: FrameChannel.ENVELOPE, cid, sid: 0, seq: 0 }, new Uint8Array(0));\n}\n\n/** True for a decoded connection-end frame (see connectionEndFrame). */\nexport function isConnectionEnd(frame: DecodedFrame): boolean {\n const h = frame.header;\n return h.channel === FrameChannel.ENVELOPE && hasFlag(h, FrameFlag.FIN) && frame.payload.byteLength === 0 && h.cid !== BROADCAST_CID;\n}\n","/** @ai-matrx/desktop-protocol — the JSON envelope (SPEC §4). Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport { ProtocolErrorBody } from \"./errors\";\nimport { DeviceId, ProtocolVersion, RequestId, ResourceId, epochMs, u32 } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Client types and hello\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const ClientType = z\n .enum([\"screen\", \"web\", \"extension\", \"server\", \"test\"]);\n\nexport const Limits = z\n .strictObject({\n max_message_bytes: z.int().min(65_536),\n max_frame_payload_bytes: z.int().min(4096),\n default_window_bytes: z.int().min(4096),\n max_streams_per_client: z.int().min(1),\n max_resources_per_user: z.int().min(1),\n });\n\nexport const OpDescriptor = z\n .strictObject({ cap: z.string().max(32), op: z.string().max(64), since: ProtocolVersion });\n\nexport const Welcome = z\n .strictObject({\n protocol_version: ProtocolVersion, // negotiated = min(client, core) within the same major\n session_id: z.string().min(8).max(64),\n client_id: z.string().min(8).max(64), // this connection's identity in the Session Manager\n device_id: DeviceId,\n device_name: z.string().max(128),\n app_version: z.string().max(32),\n platform: z.enum([\"darwin\", \"win32\", \"linux\"]),\n ops: z.array(OpDescriptor),\n limits: Limits,\n server_time_ms: epochMs,\n });\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Envelope (SPEC §4). Text WS messages carry exactly one of these as JSON.\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const HelloMsg = z\n .strictObject({\n type: z.literal(\"hello\"),\n id: RequestId, // answered by response{id, result: Welcome} or error{id}\n protocolVersion: ProtocolVersion,\n clientType: ClientType,\n clientVersion: z.string().min(1).max(32),\n });\n\nexport const RequestMsg = z\n .strictObject({\n id: RequestId,\n type: z.literal(\"request\"),\n cap: z.string().min(1).max(32),\n op: z.string().min(1).max(64),\n params: z.unknown(), // validated by the Router against OPS[cap.op].params — once, there\n });\n\nexport const ResponseMsg = z\n .strictObject({ id: RequestId, type: z.literal(\"response\"), result: z.unknown() });\n\nexport const ErrorMsg = z\n .strictObject({ id: RequestId, type: z.literal(\"error\"), error: ProtocolErrorBody });\n\nexport const StreamMeta = z\n .discriminatedUnion(\"kind\", [\n /** Binds request id → numeric sid; binary frames for this stream follow. */\n z.strictObject({\n kind: z.literal(\"open\"),\n sid: u32,\n window_bytes: z.int().min(4096),\n resource_id: ResourceId.optional(),\n }),\n /** Frames after this (channel SNAPSHOT) are a serialized screen; live DATA resumes after. */\n z.strictObject({ kind: z.literal(\"snapshot\"), cols: z.int().min(1), rows: z.int().min(1) }),\n /** Frames [from_seq, to_seq] are gone from the ring; a snapshot follows. */\n z.strictObject({ kind: z.literal(\"gap\"), from_seq: u32, to_seq: u32 }),\n ]);\n\nexport const StreamMsg = z\n .strictObject({ id: RequestId, type: z.literal(\"stream\"), seq: u32, meta: StreamMeta });\n\nexport const EndReason = z\n .enum([\"completed\", \"cancelled\", \"detached\", \"resource_exited\", \"error\"]);\n\nexport const EndMsg = z\n .strictObject({ id: RequestId, type: z.literal(\"end\"), seq: u32, reason: EndReason.optional() });\n\nexport const CancelMsg = z\n .strictObject({ id: RequestId, type: z.literal(\"cancel\") });\n\n/** Grant n more payload bytes for the stream opened by request `id` (either direction). */\nexport const CreditMsg = z\n .strictObject({ id: RequestId, type: z.literal(\"credit\"), n: z.int().min(1).max(2_147_483_647) });\n\nexport const EventMsg = z\n .strictObject({\n type: z.literal(\"event\"),\n cap: z.string().min(1).max(32),\n name: z.string().min(1).max(64),\n payload: z.unknown(), // validated against EVENTS[cap.name]\n resourceId: ResourceId.optional(),\n });\n\n/** Client↔relay only; the relay consumes these and never forwards them to the core. */\nexport const RelayMsg = z\n .discriminatedUnion(\"op\", [\n /** Fresh access token before the current one expires (relay closes 4008 at exp + 60 s). */\n z.strictObject({ type: z.literal(\"relay\"), op: z.literal(\"reauth\"), token: z.string().min(16).max(8192) }),\n ]);\n\n/**\n * Heartbeat. Sent as these EXACT bytes; the relay answers via the Durable Object\n * setWebSocketAutoResponse pair, so a heartbeat never wakes a hibernated object.\n * Interval 25 s (device and clients); 2 missed pongs = reconnect.\n */\nexport const PING_TEXT = '{\"type\":\"ping\"}' as const;\nexport const PONG_TEXT = '{\"type\":\"pong\"}' as const;\n\n/**\n * Every WebSocket (device, phone, browser, localhost) offers this subprotocol; the access token\n * rides beside it as `${BEARER_PREFIX}<token>`, never in the URL. The server echoes only SUBPROTOCOL.\n */\nexport const SUBPROTOCOL = \"matrx.v1\" as const;\nexport const BEARER_PREFIX = \"bearer.\" as const;\n\nexport const ClientToCoreMsg = z\n .discriminatedUnion(\"type\", [HelloMsg, RequestMsg, CancelMsg, CreditMsg]);\n\nexport const CoreToClientMsg = z\n .discriminatedUnion(\"type\", [ResponseMsg, ErrorMsg, StreamMsg, EndMsg, CreditMsg, EventMsg]);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// WebSocket close codes (relay and localhost transport alike)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const CloseCode = {\n NORMAL: 1000,\n GOING_AWAY: 1001, // app quit; relay: the device was silent for 75 s — reconnect\n /** Never sent by anyone: what a socket reports when it drops without a close frame. A relay\n * deploy (every Durable Object restarts) arrives as this — reconnect immediately. */\n ABNORMAL: 1006,\n /** Relay → clients: the device (re)connected, so the core session they spoke to is gone —\n * reconnect, hello, and reattach with since_seq. */\n DEVICE_RECONNECTED: 1012,\n TRY_AGAIN_LATER: 1013, // relay: signing keys or the device registry unreachable — retry\n AUTH_INVALID: 4001,\n AUTH_FORBIDDEN: 4003,\n DEVICE_NOT_FOUND: 4004,\n AUTH_EXPIRED: 4008, // no reauth before exp + 60 s\n REPLACED: 4009, // a newer device socket for the same device took over\n DEVICE_REVOKED: 4010, // kill switch — do NOT reconnect\n PROTOCOL_ERROR: 4400,\n UPGRADE_REQUIRED: 4426,\n} as const;\n\n/** Every close code above, as a schema (so Python sees the same table). */\nexport const CloseCodeValue = z.literal([1000, 1001, 1006, 1012, 1013, 4001, 4003, 4004, 4008, 4009, 4010, 4400, 4426]);\nexport type CloseCodeValue = z.output<typeof CloseCodeValue>;\n\n// Compile-time proof the schema lists exactly the CloseCode table.\ntype SameCodes<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;\ntype AssertCodes<T extends true> = T;\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype CloseCodeTableCheck = AssertCodes<SameCodes<CloseCodeValue, (typeof CloseCode)[keyof typeof CloseCode]>>;\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type ClientType = z.output<typeof ClientType>;\nexport type Limits = z.output<typeof Limits>;\nexport type OpDescriptor = z.output<typeof OpDescriptor>;\nexport type Welcome = z.output<typeof Welcome>;\nexport type HelloMsg = z.output<typeof HelloMsg>;\nexport type RequestMsg = z.output<typeof RequestMsg>;\nexport type ResponseMsg = z.output<typeof ResponseMsg>;\nexport type ErrorMsg = z.output<typeof ErrorMsg>;\nexport type StreamMeta = z.output<typeof StreamMeta>;\nexport type StreamMsg = z.output<typeof StreamMsg>;\nexport type EndReason = z.output<typeof EndReason>;\nexport type EndMsg = z.output<typeof EndMsg>;\nexport type CancelMsg = z.output<typeof CancelMsg>;\nexport type CreditMsg = z.output<typeof CreditMsg>;\nexport type EventMsg = z.output<typeof EventMsg>;\nexport type RelayMsg = z.output<typeof RelayMsg>;\nexport type ClientToCoreMsg = z.output<typeof ClientToCoreMsg>;\nexport type CoreToClientMsg = z.output<typeof CoreToClientMsg>;\n","/** @ai-matrx/desktop-protocol — error model (SPEC §5). Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport type { ErrorCodeName, ErrorData, ErrorReasonName } from \"../types\";\nimport { AbsPath, ProtocolVersion, nonNegInt } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Errors (SPEC §5, plus the five additions marked NEW)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const ErrorCode = z\n .enum([\n \"AUTH_REQUIRED\",\n \"AUTH_INVALID\",\n \"AUTH_EXPIRED\",\n \"AUTH_FORBIDDEN\", // signed in, but not this device's owner\n \"AUTH_DEVICE_REVOKED\", // kill switch\n \"PERMISSION_DENIED_OS\",\n \"NOT_FOUND\",\n \"CONFLICT\",\n \"INVALID_PARAMS\",\n \"RESOURCE_BUSY\",\n \"RESOURCE_GONE\",\n \"CANCELLED\",\n \"TIMEOUT\",\n \"PLATFORM_UNSUPPORTED\",\n \"RATE_LIMITED\",\n \"INTERNAL\",\n \"PROTOCOL_VERSION_UNSUPPORTED\", // NEW: hello refused, carries data.upgrade\n \"PROTOCOL_ERROR\", // NEW: malformed envelope/frame, credit overrun, unknown sid\n \"UNKNOWN_OPERATION\", // NEW: cap.op not served by this core version\n \"DEVICE_OFFLINE\", // NEW: relay has no live device socket (retryable)\n \"PAYLOAD_TOO_LARGE\", // NEW: message or frame above limits.max_*_bytes\n ]);\n\n/** Machine reason under a code, so clients branch without parsing messages. */\nexport const ErrorReason = z\n .enum([\n \"not_a_directory\",\n \"is_a_directory\",\n \"directory_not_empty\",\n \"already_exists\",\n \"stale_write\", // fs.write if_match_mtime_ms mismatch → CONFLICT\n \"binary_content\", // utf8 read of non-UTF-8 bytes → INVALID_PARAMS\n \"not_utf8_boundary\",\n \"patch_no_match\",\n \"patch_ambiguous\",\n \"resource_exited\",\n \"resource_expired\",\n \"control_taken\", // another client of the same user took control\n \"window_exhausted\",\n // 1.2 (REASONS_SINCE): the `models` capability and its supervised Python service\n \"runtime_not_installed\", // NOT_FOUND: install the inference runtime first (models.install)\n \"model_not_installed\", // NOT_FOUND: that model's weights are not on the device\n \"unsupported_media\", // INVALID_PARAMS: the file is not audio or video the decoder reads\n \"download_failed\", // install could not fetch a package or model file\n \"service_starting\", // RESOURCE_BUSY (retryable): the service is starting or restarting\n \"service_restarted\", // RESOURCE_GONE: the service died while this request ran\n \"service_failed\", // INTERNAL: the service could not be started (see models.status)\n ]);\n\n/**\n * One edit fs.patch could not apply — the daemon's `edits_failed[]` entry, verbatim: the edit's\n * index and the daemon's own reason text (\"old_text not found\", or \"old_text matches N locations —\n * add context or set replace_all=True\").\n */\nexport const FsPatchEditFailure = z.strictObject({ edit_index: nonNegInt, reason: z.string().max(300) });\n\nexport const ProtocolErrorBody = z\n .strictObject({\n code: ErrorCode,\n message: z.string().max(300), // short, human, never a stack trace or a token\n retryable: z.boolean(),\n data: z\n .strictObject({\n reason: ErrorReason.optional(),\n cap: z.string().max(32).optional(),\n op: z.string().max(64).optional(),\n path: AbsPath.optional(),\n settings_url: z.string().max(512).optional(), // PERMISSION_DENIED_OS deep link\n retry_after_ms: nonNegInt.optional(),\n limit_bytes: nonNegInt.optional(),\n /** fs.patch when every edit failed (CONFLICT, patch_no_match / patch_ambiguous): the daemon's 422 `failures`. */\n edits_failed: z.array(FsPatchEditFailure).max(256).optional(),\n upgrade: z\n .strictObject({\n min_version: ProtocolVersion,\n max_version: ProtocolVersion,\n download_url: z.url().optional(),\n })\n .optional(),\n })\n .optional(),\n });\n\n\n// Compile-time proof the zod-free twins in ../types.ts equal these schemas.\ntype Same<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;\ntype AssertTrue<T extends true> = T;\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype ErrorTwinCheck = [\n AssertTrue<Same<z.infer<typeof ErrorCode>, ErrorCodeName>>,\n AssertTrue<Same<z.infer<typeof ErrorReason>, ErrorReasonName>>,\n AssertTrue<Same<NonNullable<z.input<typeof ProtocolErrorBody>[\"data\"]>, ErrorData>>,\n];\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type ErrorCode = z.output<typeof ErrorCode>;\nexport type ErrorReason = z.output<typeof ErrorReason>;\nexport type ProtocolErrorBody = z.output<typeof ProtocolErrorBody>;\nexport type FsPatchEditFailure = z.output<typeof FsPatchEditFailure>;\n","/** @ai-matrx/desktop-protocol — version and primitive schemas. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Version\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const PROTOCOL_MAJOR = 1 as const;\n/**\n * Minor history (same major = compatible; see src/versioning.ts for the rule and FIELDS_SINCE):\n * 1.0 — the first contract.\n * 1.1 — fs.patch per-edit results; /call reports the negotiated version;\n * device status since_ms is null for a device that never connected.\n * 1.2 — the `models` capability (local transcription) and its error reasons (REASONS_SINCE);\n * the `apps` capability (desktop apps, their profiles and usage).\n * 1.3 — the `proc` capability (processes, listening ports, stopping one) and `clipboard`.\n * 1.4 — computer control: `system`, `screen`, `window`, `input`, `power`, `resources`; polled\n * folder watches (fs.watch.start/events/stop) and background jobs (exec.job.*).\n * 1.5 — `coding.history.import_missing`: Claude Code history the platform lacks, imported by the\n * `coding` Python service.\n * 1.6 — the `audio` capability: devices, record a clip to a WAV file, play a file.\n * 1.7 — a window names its owning application and process (WindowInfo `app`, `pid`).\n */\nexport const PROTOCOL_MINOR = 7 as const;\n/** This package's version as the wire spells it (\"major.minor\"): hello, welcome, relay status. */\nexport const PROTOCOL_VERSION = `${PROTOCOL_MAJOR}.${PROTOCOL_MINOR}` as const;\n/** \"major.minor\". Same major = compatible (minor adds optional fields/ops only). */\nexport const ProtocolVersion = z\n .string()\n .regex(/^[1-9][0-9]{0,2}\\.[0-9]{1,3}$/);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Primitives\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** Client-generated request id, unique per session. */\nexport const RequestId = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[A-Za-z0-9_-]+$/);\n\n/** Long-lived resource handle minted by the core: \"<kind>_<base62>\" (pty_…, watch_…). */\nexport const ResourceId = z\n .string()\n .regex(/^(pty|watch)_[A-Za-z0-9]{16,40}$/);\n\n/**\n * = app_instances.id. A plain pattern, NOT z.uuid(): z.uuid() emits `format: uuid` + `pattern`,\n * which datamodel-codegen renders as `Annotated[UUID, Field(pattern=...)]` — a model Pydantic can\n * never validate (\"Unable to apply constraint 'pattern' … of type 'uuid'\"). generate.ts now\n * refuses format+pattern on one node so this class cannot come back.\n */\nexport const DeviceId = z\n .string()\n .regex(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/);\n\n/**\n * Absolute, normalized path: forward slashes on every OS, NFC. POSIX \"/...\" or Windows \"C:/...\".\n * Normalization happens once, in the fs owner (SPEC §9); the wire never carries backslashes.\n */\nexport const AbsPath = z\n .string()\n .min(1)\n .max(4096)\n .regex(/^(\\/|[A-Za-z]:\\/)[^\\\\\\u0000]*$/);\n\n/** Internal building blocks — deliberately unnamed in $defs (inlined wherever used). */\nexport const u32 = z.int().min(0).max(4_294_967_295);\nexport const nonNegInt = z.int().min(0);\n/** Unix epoch milliseconds. */\nexport const epochMs = z.int().min(0);\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type ProtocolVersion = z.output<typeof ProtocolVersion>;\nexport type RequestId = z.output<typeof RequestId>;\nexport type ResourceId = z.output<typeof ResourceId>;\nexport type DeviceId = z.output<typeof DeviceId>;\nexport type AbsPath = z.output<typeof AbsPath>;\n","/**\n * What a connecting side does after each WebSocket close — the ONE table every client reads (the\n * package client, the desktop's relay transport, any other dialer). Never keep a local list of\n * \"terminal\" codes: a code added to CloseCode without a rule here fails to compile.\n *\n * reconnect_now the far side went away on purpose or the socket died; dial again at once if the\n * connection had opened, with backoff otherwise (a dead network never spins).\n * reconnect transient refusal; dial again with backoff.\n * reauth the token was refused; get a FRESH token and dial once more. A second refusal in\n * a row (no successful open between) is terminal with outcome \"signed_out\".\n * stop retrying cannot help: stop dialing until something changes (a new sign-in, a\n * new device, an update) and show the outcome.\n */\nimport type { ErrorCodeName } from \"./types\";\nimport { CloseCode, type CloseCodeValue } from \"./schema/envelope\";\n\nexport type CloseAction = \"reconnect_now\" | \"reconnect\" | \"reauth\" | \"stop\";\n\n/** The one state a person is shown when dialing stops. */\nexport type CloseOutcome = \"signed_out\" | \"not_owned\" | \"removed\" | \"revoked\" | \"replaced\" | \"upgrade_required\";\n\nexport interface CloseRule {\n readonly action: CloseAction;\n /** Set for `stop` and `reauth` (the outcome when the fresh token is refused too). */\n readonly outcome?: CloseOutcome;\n /** The error a caller's pending work is failed with. */\n readonly error: readonly [ErrorCodeName, string];\n}\n\nexport const CLOSE_RULES = {\n [CloseCode.NORMAL]: { action: \"reconnect\", error: [\"DEVICE_OFFLINE\", \"Connection closed\"] },\n [CloseCode.GOING_AWAY]: { action: \"reconnect_now\", error: [\"DEVICE_OFFLINE\", \"Connection lost\"] },\n [CloseCode.ABNORMAL]: { action: \"reconnect_now\", error: [\"DEVICE_OFFLINE\", \"Connection lost\"] },\n [CloseCode.DEVICE_RECONNECTED]: { action: \"reconnect_now\", error: [\"DEVICE_OFFLINE\", \"Device reconnected\"] },\n [CloseCode.TRY_AGAIN_LATER]: { action: \"reconnect\", error: [\"DEVICE_OFFLINE\", \"Relay busy; retrying\"] },\n [CloseCode.AUTH_INVALID]: { action: \"reauth\", outcome: \"signed_out\", error: [\"AUTH_INVALID\", \"Sign-in was not accepted\"] },\n [CloseCode.AUTH_FORBIDDEN]: { action: \"stop\", outcome: \"not_owned\", error: [\"AUTH_FORBIDDEN\", \"Not this device's owner\"] },\n [CloseCode.DEVICE_NOT_FOUND]: { action: \"stop\", outcome: \"removed\", error: [\"NOT_FOUND\", \"Device not found\"] },\n [CloseCode.AUTH_EXPIRED]: { action: \"reauth\", outcome: \"signed_out\", error: [\"AUTH_EXPIRED\", \"Sign-in expired\"] },\n [CloseCode.REPLACED]: { action: \"stop\", outcome: \"replaced\", error: [\"CONFLICT\", \"Replaced by a newer connection\"] },\n [CloseCode.DEVICE_REVOKED]: { action: \"stop\", outcome: \"revoked\", error: [\"AUTH_DEVICE_REVOKED\", \"This device was revoked\"] },\n // A malformed message, or a connection the relay lost track of: a fresh socket starts clean.\n [CloseCode.PROTOCOL_ERROR]: { action: \"reconnect\", error: [\"PROTOCOL_ERROR\", \"Connection reset by the relay\"] },\n [CloseCode.UPGRADE_REQUIRED]: { action: \"stop\", outcome: \"upgrade_required\", error: [\"PROTOCOL_VERSION_UNSUPPORTED\", \"Protocol upgrade required\"] },\n} as const satisfies Record<CloseCodeValue, CloseRule>;\n\nconst UNKNOWN: CloseRule = { action: \"reconnect\", error: [\"DEVICE_OFFLINE\", \"Connection lost\"] };\n\n/** The rule for any close code; one this table does not know (or null: no close frame) reconnects with backoff. */\nexport function closeRule(code: number | null | undefined): CloseRule {\n if (code === null || code === undefined) return CLOSE_RULES[CloseCode.ABNORMAL];\n return (CLOSE_RULES as Record<number, CloseRule>)[code] ?? UNKNOWN;\n}\n\n/** True when dialing must stop after this close (no retry will help). */\nexport function isTerminalClose(code: number | null | undefined): boolean {\n return closeRule(code).action === \"stop\";\n}\n","/** @ai-matrx/desktop-protocol — binary frame header and flow-control constants. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport { FRAME_VERSION } from \"../frame\";\nimport type { FrameHeader as FrameHeaderShape } from \"../frame\";\nimport { u32 } from \"./primitives\";\n\n/** Zod twin of the codec's FrameHeader (layout documented in src/frame.ts) — for $defs and Pydantic. */\nexport const FrameHeader = z\n .strictObject({\n version: z.literal(FRAME_VERSION),\n flags: z.int().min(0).max(3),\n channel: z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3), z.literal(255)]),\n cid: u32,\n sid: u32,\n seq: u32,\n });\nexport type FrameHeader = z.infer<typeof FrameHeader>;\n\n/** Relay ↔ device hop: the header of a frame carrying one JSON envelope. cid 0 = broadcast (device → relay). */\nexport const RelayHopEnvelopeHeader = z\n .strictObject({\n version: z.literal(FRAME_VERSION),\n flags: z.literal(0),\n channel: z.literal(255),\n cid: u32,\n sid: z.literal(0),\n seq: z.literal(0),\n });\nexport type RelayHopEnvelopeHeader = z.infer<typeof RelayHopEnvelopeHeader>;\n\n/** Relay ↔ device hop: the header of a connection-end frame (FIN, empty payload; see connectionEndFrame). */\nexport const RelayHopConnectionEnd = z\n .strictObject({\n version: z.literal(FRAME_VERSION),\n flags: z.literal(1),\n channel: z.literal(255),\n cid: z.int().min(1).max(4_294_967_295),\n sid: z.literal(0),\n seq: z.literal(0),\n });\nexport type RelayHopConnectionEnd = z.infer<typeof RelayHopConnectionEnd>;\n\n// Compile-time proof the zod twin and the zod-free codec type are the same shape.\ntype Same<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;\ntype AssertTrue<T extends true> = T;\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype FrameHeaderTwinCheck = AssertTrue<Same<z.infer<typeof FrameHeader>, FrameHeaderShape>>;\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Flow control (credits)\n//\n// The RECEIVER of a byte stream grants the SENDER a window in payload bytes. The sender may have at\n// most `window` un-credited payload bytes in flight per sid; it pauses its source (node-pty\n// pause(), file read loop) at zero and resumes on credit. Initial window = request's\n// `window_bytes` or limits.default_window_bytes. The receiver sends credit{n} after it has\n// CONSUMED n bytes (xterm write callback fired, file chunk persisted). Overrun → PROTOCOL_ERROR\n// and the stream is ended. Credits are end-to-end (client↔core), so the relay holds at most\n// sum(windows) per device and never buffers without bound. Unary JSON ops are not credited.\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const DEFAULT_WINDOW_BYTES = 262_144 as const; // 256 KiB\nexport const DEFAULT_MAX_FRAME_PAYLOAD_BYTES = 65_536 as const; // 64 KiB\nexport const DEFAULT_MAX_MESSAGE_BYTES = 8_388_608 as const; // 8 MiB JSON message cap\n\n","/** @ai-matrx/desktop-protocol — cap sysinfo. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport { AbsPath, DeviceId, ProtocolVersion, nonNegInt } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// sysinfo\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const OsPermissionName = z\n .enum([\n \"full_disk_access\",\n \"accessibility\",\n \"screen_recording\",\n \"microphone\",\n \"camera\",\n \"automation\",\n \"contacts\",\n \"calendars\",\n \"photos\",\n \"location\",\n \"local_network\",\n \"bluetooth\",\n \"notifications\",\n ]);\n\nexport const SysinfoGetParams = z.strictObject({});\nexport const SysinfoGetResult = z\n .strictObject({\n device_id: DeviceId,\n device_name: z.string().max(128),\n hostname: z.string().max(255),\n platform: z.enum([\"darwin\", \"win32\", \"linux\"]),\n os_version: z.string().max(64),\n arch: z.enum([\"arm64\", \"x64\"]),\n app_version: z.string().max(32),\n protocol_version: ProtocolVersion,\n user: z.strictObject({ username: z.string().max(128), shell: z.string().max(512) }),\n paths: z.strictObject({\n home: AbsPath,\n desktop: AbsPath,\n documents: AbsPath,\n downloads: AbsPath,\n app_data: AbsPath,\n temp: AbsPath,\n }),\n cpu: z.strictObject({ model: z.string().max(128), cores: z.int().min(1) }),\n memory: z.strictObject({ total_bytes: nonNegInt, free_bytes: nonNegInt }),\n uptime_seconds: nonNegInt,\n on_battery: z.boolean().nullable(),\n sleep_prevented: z.boolean(), // true while any remote session holds the power blocker\n permissions: z.array(\n z.strictObject({\n name: OsPermissionName,\n state: z.enum([\"granted\", \"denied\", \"not_determined\", \"not_applicable\"]),\n settings_url: z.string().max(512).nullable(),\n }),\n ),\n });\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type OsPermissionName = z.output<typeof OsPermissionName>;\nexport type SysinfoGetParams = z.output<typeof SysinfoGetParams>;\nexport type SysinfoGetResult = z.output<typeof SysinfoGetResult>;\n","/** @ai-matrx/desktop-protocol — cap fs. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport { FsPatchEditFailure } from \"./errors\";\nimport { AbsPath, ResourceId, epochMs, nonNegInt } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// fs — mirrors matrx_agent daemon /fs/* field names (SPEC §6.1)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const FsKind = z.enum([\"file\", \"dir\", \"symlink\"]);\n\n/**\n * = daemon get_stat_dict(), field for field (SPEC 6.1): what /fs/stat and every /fs/list entry\n * answer in the cloud sandbox. Never follows symlinks; `target` is the fully resolved target.\n */\nexport const FsEntry = z\n .strictObject({\n name: z.string().max(1024),\n path: AbsPath,\n kind: FsKind,\n size: nonNegInt,\n mtime: z.number().min(0), // seconds, float\n mode: z.int().min(0).max(0o7777),\n target: AbsPath.nullable(),\n });\n\nexport const FsListParams = z\n .strictObject({\n path: AbsPath,\n recursive: z.boolean().default(false),\n depth: z.int().min(1).max(32).default(1),\n pattern: z.string().max(256).optional(), // glob on name\n limit: z.int().min(1).max(5000).default(1000),\n page_token: z.string().max(256).optional(),\n // Desktop additions; their defaults ARE the daemon's behaviour: dotfiles listed, siblings in\n // binary (byte) order of name, depth-first.\n show_hidden: z.boolean().default(true),\n sort: z.enum([\"name\", \"mtime\", \"size\", \"kind\"]).default(\"name\"),\n });\nexport const FsListResult = z\n .strictObject({\n entries: z.array(FsEntry),\n truncated: z.boolean(),\n next_page_token: z.string().max(256).nullable(),\n scanned: nonNegInt,\n });\n\nexport const FsStatParams = z.strictObject({ path: AbsPath });\nexport const FsStatResult = FsEntry;\n\nexport const FsEncoding = z.enum([\"utf8\", \"base64\"]);\n\n/** Bounded read. offset = byte offset; limit = chars (utf8) or bytes (base64), as the daemon. */\nexport const FsReadParams = z\n .strictObject({\n path: AbsPath,\n encoding: FsEncoding.default(\"utf8\"),\n offset: nonNegInt.default(0),\n limit: z.int().min(1).max(4_194_304).default(262_144),\n });\nexport const FsReadResult = z\n .strictObject({\n content: z.string(),\n encoding: FsEncoding,\n size: nonNegInt,\n offset: nonNegInt,\n next_offset: nonNegInt,\n truncated: z.boolean(),\n mime: z.string().max(128).nullable(),\n mtime_ms: epochMs, // pass back as if_match_mtime_ms to guard a later write\n });\n\n/** Whole-file or ranged download as binary frames (channel DATA, credited). */\nexport const FsReadStreamParams = z\n .strictObject({\n path: AbsPath,\n offset: nonNegInt.default(0),\n length: nonNegInt.optional(), // absent = to EOF\n window_bytes: z.int().min(4096).max(16_777_216).optional(),\n });\n/** Unary result arrives first (size/mime), then stream{open} + DATA frames + end. */\nexport const FsReadStreamResult = z\n .strictObject({ size: nonNegInt, mime: z.string().max(128).nullable(), mtime_ms: epochMs });\n\nexport const FsWriteParams = z\n .strictObject({\n path: AbsPath,\n content: z.string().max(5_592_406), // ≤ 4 MiB of bytes after base64 decode\n encoding: FsEncoding.default(\"utf8\"),\n mode: z.int().min(0).max(0o7777).optional(),\n create_parents: z.boolean().default(false),\n /** Optimistic concurrency: CONFLICT/stale_write if the file changed since this mtime. */\n if_match_mtime_ms: epochMs.optional(),\n /** Refuse to replace an existing file (CONFLICT/already_exists). */\n exclusive: z.boolean().default(false),\n });\n/** Writes are atomic: temp file in the same directory + rename (daemon parity). */\nexport const FsWriteResult = z\n .strictObject({ path: AbsPath, size: nonNegInt, mtime_ms: epochMs, created: z.boolean() });\n\nexport const FsMkdirParams = z\n .strictObject({ path: AbsPath, parents: z.boolean().default(false) });\nexport const FsMkdirResult = z\n .strictObject({ path: AbsPath, created: z.boolean() });\n\n/** = daemon RenameRequest (/fs/rename). */\nexport const FsMoveParams = z\n .strictObject({ from_path: AbsPath, to_path: AbsPath, overwrite: z.boolean().default(false) });\nexport const FsMoveResult = z\n .strictObject({ from_path: AbsPath, to_path: AbsPath });\n\n/**\n * Delete. Default goes to the OS Trash (Finder/Explorer semantics: undoable from the phone's\n * \"Undo\" toast via fs.move back). to_trash:false is a permanent delete — the daemon's behaviour,\n * used by agents through _sandbox_proxy.\n */\nexport const FsDeleteParams = z\n .strictObject({\n path: AbsPath,\n recursive: z.boolean().default(false),\n to_trash: z.boolean().default(true),\n });\nexport const FsDeleteResult = z\n .strictObject({ deleted: z.literal(true), trashed_to: AbsPath.nullable() });\n\n/** Opens a watch resource; changes arrive as event fs.changed with resourceId. */\nexport const FsWatchParams = z\n .strictObject({\n path: AbsPath,\n recursive: z.boolean().default(false),\n ignore: z.array(z.string().max(256)).max(64).default([]),\n debounce_ms: z.int().min(0).max(5000).default(50),\n });\nexport const FsWatchResult = z\n .strictObject({ resource_id: ResourceId, path: AbsPath });\n\n// — Required by lane F (SPEC §6.1 parity sequence and every existing _sandbox_proxy call) —\n\n/** = daemon EditChunk / PatchRequest (/fs/patch). */\nexport const FsPatchParams = z\n .strictObject({\n path: AbsPath,\n edits: z\n .array(\n z.strictObject({\n old_text: z.string(),\n new_text: z.string(),\n replace_all: z.boolean().default(false),\n }),\n )\n .min(1)\n .max(256),\n create_if_missing: z.boolean().default(false),\n });\n/** One edit fs.patch applied — the daemon's `edits_applied[]` entry, verbatim. */\nexport const FsPatchEditApplied = z.strictObject({\n edit_index: nonNegInt,\n mode: z.enum([\"create\", \"replace\", \"replace_all\"]),\n /** Present for replace_all only, as the daemon sends it. */\n matches_replaced: nonNegInt.optional(),\n});\n\n/**\n * = the daemon's /fs/patch answer per edit: edits apply in order, each sees the previous result; an\n * edit whose old_text is missing, or matches more than once without replace_all, is skipped and\n * listed in edits_failed with the daemon's reason; the file is written when at least one applied.\n * (Every edit failing is a CONFLICT whose data.edits_failed lists them — the daemon's 422.)\n */\nexport const FsPatchResult = z.strictObject({\n path: AbsPath,\n applied: nonNegInt,\n size: nonNegInt,\n mtime_ms: epochMs,\n /** Since 1.1 (FIELDS_SINCE): a 1.0 app sends only `applied`. Always sent to a ≥1.1 peer. */\n edits_applied: z.array(FsPatchEditApplied).max(256).optional(),\n /** Since 1.1 (FIELDS_SINCE). */\n edits_failed: z.array(FsPatchEditFailure).max(256).optional(),\n});\n\n/** = daemon SearchPathRequest (/search/paths). */\nexport const FsSearchPathsParams = z\n .strictObject({\n pattern: z.string().min(1).max(512),\n cwd: AbsPath,\n hidden: z.boolean().default(false),\n max_results: z.int().min(1).max(5000).default(100),\n });\n/**\n * = the daemon's /search/paths answer (fd 8.3.1 in the sandbox image): paths RELATIVE to `cwd`, each\n * prefixed \"./\", sorted, cut to max_results. No truncation flag (the daemon has none).\n */\nexport const FsSearchPathsResult = z\n .strictObject({ paths: z.array(z.string().min(3).max(4096).regex(/^\\.\\/[^\\\\\\u0000]+$/)) });\n\n/** = daemon SearchContentRequest (/search/content). */\nexport const FsSearchContentParams = z\n .strictObject({\n query: z.string().min(1).max(1024),\n cwd: AbsPath,\n regex: z.boolean().default(true),\n case_sensitive: z.boolean().default(false),\n include: z.array(z.string().max(256)).max(64).optional(),\n exclude: z.array(z.string().max(256)).max(64).optional(),\n max_results: z.int().min(1).max(5000).default(100),\n });\n/**\n * = the daemon's /search/content answer (ripgrep 13 --json run in `cwd`): `path` RELATIVE to `cwd`\n * with no \"./\"; `lines` is the matching line with its newline; submatches are ripgrep's, byte\n * offsets within the line. max_results is per FILE (rg -m), as the daemon passes it. No truncation\n * flag (the daemon has none).\n */\nexport const FsSearchContentResult = z\n .strictObject({\n results: z.array(\n z.strictObject({\n path: z.string().min(1).max(4096).regex(/^[^/\\\\\\u0000][^\\\\\\u0000]*$/),\n lines: z.string(),\n line_number: z.int().min(1),\n submatches: z.array(\n z.strictObject({ match: z.strictObject({ text: z.string() }), start: nonNegInt, end: nonNegInt }),\n ),\n }),\n ),\n });\n\nexport const FsChange = z\n .strictObject({\n type: z.enum([\"created\", \"modified\", \"deleted\", \"moved\"]),\n path: AbsPath,\n to_path: AbsPath.optional(),\n kind: z.enum([\"file\", \"dir\", \"symlink\", \"unknown\"]),\n });\nexport const FsChangedEvent = z\n .strictObject({ changes: z.array(FsChange).min(1).max(1000), overflow: z.boolean() }); // overflow:true = events dropped; client re-lists\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type FsKind = z.output<typeof FsKind>;\nexport type FsEntry = z.output<typeof FsEntry>;\nexport type FsListParams = z.output<typeof FsListParams>;\nexport type FsListResult = z.output<typeof FsListResult>;\nexport type FsStatParams = z.output<typeof FsStatParams>;\nexport type FsStatResult = z.output<typeof FsStatResult>;\nexport type FsEncoding = z.output<typeof FsEncoding>;\nexport type FsReadParams = z.output<typeof FsReadParams>;\nexport type FsReadResult = z.output<typeof FsReadResult>;\nexport type FsReadStreamParams = z.output<typeof FsReadStreamParams>;\nexport type FsReadStreamResult = z.output<typeof FsReadStreamResult>;\nexport type FsWriteParams = z.output<typeof FsWriteParams>;\nexport type FsWriteResult = z.output<typeof FsWriteResult>;\nexport type FsMkdirParams = z.output<typeof FsMkdirParams>;\nexport type FsMkdirResult = z.output<typeof FsMkdirResult>;\nexport type FsMoveParams = z.output<typeof FsMoveParams>;\nexport type FsMoveResult = z.output<typeof FsMoveResult>;\nexport type FsDeleteParams = z.output<typeof FsDeleteParams>;\nexport type FsDeleteResult = z.output<typeof FsDeleteResult>;\nexport type FsWatchParams = z.output<typeof FsWatchParams>;\nexport type FsWatchResult = z.output<typeof FsWatchResult>;\nexport type FsPatchParams = z.output<typeof FsPatchParams>;\nexport type FsPatchResult = z.output<typeof FsPatchResult>;\nexport type FsPatchEditApplied = z.output<typeof FsPatchEditApplied>;\nexport type FsSearchPathsParams = z.output<typeof FsSearchPathsParams>;\nexport type FsSearchPathsResult = z.output<typeof FsSearchPathsResult>;\nexport type FsSearchContentParams = z.output<typeof FsSearchContentParams>;\nexport type FsSearchContentResult = z.output<typeof FsSearchContentResult>;\nexport type FsChange = z.output<typeof FsChange>;\nexport type FsChangedEvent = z.output<typeof FsChangedEvent>;\n","/** @ai-matrx/desktop-protocol — cap exec. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport { AbsPath, ResourceId, epochMs, nonNegInt, u32 } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// exec — PTY sessions (resources) + one-shot run\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const Signal = z\n .enum([\"SIGINT\", \"SIGTERM\", \"SIGKILL\", \"SIGHUP\", \"SIGQUIT\", \"SIGTSTP\", \"SIGCONT\", \"SIGUSR1\", \"SIGUSR2\"]); // Windows: SIGINT→Ctrl-C event, SIGTERM/SIGKILL/SIGHUP→terminate, others PLATFORM_UNSUPPORTED\n\nconst cols = z.int().min(2).max(1000);\nconst rows = z.int().min(1).max(500);\n\n/**\n * Start a PTY. Response result = PtyInfo; the same request id then carries the output stream:\n * stream{meta:{kind:\"open\",sid,resource_id}} → DATA frames (credited) → end{reason}.\n * Input goes as STDIN frames on that sid (cheap per keystroke) or via exec.pty.write.\n */\nexport const ExecPtyStartParams = z\n .strictObject({\n cols,\n rows,\n cwd: AbsPath.optional(), // default: home\n shell: z.string().max(512).optional(), // default: user's login shell (PowerShell on Windows)\n args: z.array(z.string().max(4096)).max(64).optional(),\n env: z.record(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).max(128), z.string().max(32_768)).optional(),\n name: z.string().max(64).optional(), // tab label\n window_bytes: z.int().min(4096).max(16_777_216).optional(),\n });\n\nexport const PtyInfo = z\n .strictObject({\n resource_id: ResourceId,\n pid: z.int().min(1),\n shell: z.string().max(512),\n cwd: AbsPath, // live, from OSC 7 / process cwd\n title: z.string().max(256),\n name: z.string().max(64).nullable(),\n cols,\n rows,\n state: z.enum([\"running\", \"exited\"]),\n exit_code: z.int().nullable(),\n exit_signal: Signal.nullable(),\n last_seq: u32,\n created_at_ms: epochMs,\n controller_client_id: z.string().max(64).nullable(), // null = orphaned (in grace period)\n attached_clients: nonNegInt,\n orphan_expires_at_ms: epochMs.nullable(),\n });\n\nexport const ExecPtyStartResult = PtyInfo;\n\nexport const ExecPtyWriteParams = z\n .strictObject({ resource_id: ResourceId, data: z.string().min(1).max(65_536) });\nexport const ExecPtyWriteResult = z.strictObject({ written: nonNegInt });\n\nexport const ExecPtyResizeParams = z\n .strictObject({ resource_id: ResourceId, cols, rows });\nexport const ExecPtyResizeResult = z.strictObject({ cols, rows });\n\n/** Delivered to the PTY's foreground process group (daemon parity: tcgetpgrp + killpg). */\nexport const ExecPtySignalParams = z\n .strictObject({ resource_id: ResourceId, signal: Signal });\nexport const ExecPtySignalResult = z.strictObject({ delivered: z.boolean() });\n\n/** SIGHUP the session, SIGKILL after grace_ms, reap, free the resource. Idempotent. */\nexport const ExecPtyKillParams = z\n .strictObject({ resource_id: ResourceId, grace_ms: z.int().min(0).max(30_000).default(2000) });\nexport const ExecPtyKillResult = z\n .strictObject({ exit_code: z.int().nullable(), exit_signal: Signal.nullable() });\n\nexport const ExecListParams = z.strictObject({});\nexport const ExecListResult = z.strictObject({ sessions: z.array(PtyInfo) });\n\n/**\n * One-shot command (agents, via _sandbox_proxy → /exec). Timeout ENFORCED (exit 124, daemon\n * convention). cwd is sticky per cwd_key: a later run with the same key and no cwd starts where\n * the last one ended (SPEC §6.1: \"cd sub && pwd\" then \"pwd\").\n */\nexport const ExecRunParams = z\n .strictObject({\n command: z.string().min(1).max(131_072),\n cwd: AbsPath.optional(),\n cwd_key: z.string().max(128).optional(),\n env: z.record(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).max(128), z.string().max(32_768)).optional(),\n stdin: z.string().max(1_048_576).optional(),\n timeout: z.int().min(1).max(3600).default(60), // seconds, daemon parity\n max_output_bytes: z.int().min(1024).max(8_388_608).default(1_048_576),\n });\nexport const ExecRunResult = z\n .strictObject({\n exit_code: z.int(),\n stdout: z.string(),\n stderr: z.string(),\n cwd: AbsPath,\n duration_ms: nonNegInt,\n timed_out: z.boolean(),\n output_truncated: z.boolean(),\n });\n\nexport const ExecExitedEvent = z\n .strictObject({ exit_code: z.int().nullable(), exit_signal: Signal.nullable() });\nexport const ExecTitleEvent = z.strictObject({ title: z.string().max(256) });\nexport const ExecCwdEvent = z.strictObject({ cwd: AbsPath });\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type Signal = z.output<typeof Signal>;\nexport type ExecPtyStartParams = z.output<typeof ExecPtyStartParams>;\nexport type PtyInfo = z.output<typeof PtyInfo>;\nexport type ExecPtyStartResult = z.output<typeof ExecPtyStartResult>;\nexport type ExecPtyWriteParams = z.output<typeof ExecPtyWriteParams>;\nexport type ExecPtyWriteResult = z.output<typeof ExecPtyWriteResult>;\nexport type ExecPtyResizeParams = z.output<typeof ExecPtyResizeParams>;\nexport type ExecPtyResizeResult = z.output<typeof ExecPtyResizeResult>;\nexport type ExecPtySignalParams = z.output<typeof ExecPtySignalParams>;\nexport type ExecPtySignalResult = z.output<typeof ExecPtySignalResult>;\nexport type ExecPtyKillParams = z.output<typeof ExecPtyKillParams>;\nexport type ExecPtyKillResult = z.output<typeof ExecPtyKillResult>;\nexport type ExecListParams = z.output<typeof ExecListParams>;\nexport type ExecListResult = z.output<typeof ExecListResult>;\nexport type ExecRunParams = z.output<typeof ExecRunParams>;\nexport type ExecRunResult = z.output<typeof ExecRunResult>;\nexport type ExecExitedEvent = z.output<typeof ExecExitedEvent>;\nexport type ExecTitleEvent = z.output<typeof ExecTitleEvent>;\nexport type ExecCwdEvent = z.output<typeof ExecCwdEvent>;\n","/** @ai-matrx/desktop-protocol — cap session. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport { PtyInfo } from \"./exec\";\nimport { AbsPath, ResourceId, epochMs, u32 } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// session — generic resource ownership (SPEC §3.3). One attach/detach for EVERY resource kind.\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Reattach after a drop. mode \"control\" by the same user takes control (previous controller is\n * demoted to read_only and gets session.control_changed). since_seq = last seq the client\n * rendered: frames (since_seq, last_seq] are replayed from the ring with the REPLAY flag; if they\n * have left the ring, stream{gap} + stream{snapshot} + SNAPSHOT frames come first.\n * Response = PtyInfo|FsWatchResult-shaped ResourceInfo; then the stream continues on a new sid.\n */\nexport const SessionAttachParams = z\n .strictObject({\n resource_id: ResourceId,\n mode: z.enum([\"control\", \"read_only\"]).default(\"control\"),\n since_seq: u32.optional(),\n window_bytes: z.int().min(4096).max(16_777_216).optional(),\n });\n\nexport const ResourceInfo = z\n .discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"pty\"), pty: PtyInfo }),\n z.strictObject({\n kind: z.literal(\"watch\"),\n resource_id: ResourceId,\n path: AbsPath,\n orphan_expires_at_ms: epochMs.nullable(),\n }),\n ]);\nexport const SessionAttachResult = ResourceInfo;\n\n/** Leave the resource running (orphan grace starts if no other client controls it). */\nexport const SessionDetachParams = z.strictObject({ resource_id: ResourceId });\nexport const SessionDetachResult = z\n .strictObject({ orphan_expires_at_ms: epochMs.nullable() });\n\n/** Free a resource through its owner's cancel path (watch → unwatch; pty → exec.pty.kill). */\nexport const SessionReleaseParams = z.strictObject({ resource_id: ResourceId });\nexport const SessionReleaseResult = z.strictObject({ released: z.literal(true) });\n\nexport const SessionListParams = z.strictObject({});\nexport const SessionListResult = z.strictObject({ resources: z.array(ResourceInfo) });\n\nexport const SessionControlChangedEvent = z\n .strictObject({ controller_client_id: z.string().max(64).nullable(), your_mode: z.enum([\"control\", \"read_only\"]) });\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type SessionAttachParams = z.output<typeof SessionAttachParams>;\nexport type ResourceInfo = z.output<typeof ResourceInfo>;\nexport type SessionAttachResult = z.output<typeof SessionAttachResult>;\nexport type SessionDetachParams = z.output<typeof SessionDetachParams>;\nexport type SessionDetachResult = z.output<typeof SessionDetachResult>;\nexport type SessionReleaseParams = z.output<typeof SessionReleaseParams>;\nexport type SessionReleaseResult = z.output<typeof SessionReleaseResult>;\nexport type SessionListParams = z.output<typeof SessionListParams>;\nexport type SessionListResult = z.output<typeof SessionListResult>;\nexport type SessionControlChangedEvent = z.output<typeof SessionControlChangedEvent>;\n","/**\n * @ai-matrx/desktop-protocol — the `models` capability (SPEC §6): local AI models on the device,\n * served by Matrx 2's `ml` Python service (SPEC §3.10). Schema source: lint-enforced rules in\n * scripts/check-schema-source.mjs.\n *\n * Two contracts share these shapes, both generated from this file (SPEC P11):\n * - the Router ops `models.*` (every transport: relay, localhost, extension, the app's screen);\n * - the internal service ops `ml.*` between the desktop core and the Python service\n * (src/schema/service.ts, `SERVICES` in registry.ts). A forwarded op uses the SAME named\n * schema on both hops, so the two can never disagree.\n */\nimport { z } from \"zod\";\nimport { AbsPath, RequestId, nonNegInt } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Transcription (local Whisper)\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** Whisper sizes the device can run (CTranslate2 weights). Larger = slower, more accurate. */\nexport const TranscriptionModelId = z.enum([\"tiny\", \"base\", \"small\", \"large-v3-turbo\"]);\n\n/** The heavy runtime (inference packages) is installed on first use, never shipped in the app. */\nexport const MlRuntimeState = z.enum([\"not_installed\", \"installing\", \"installed\", \"failed\"]);\n\n/** `packages`: the locked inference wheels; `model`: one model's weights; `verifying`: hashes and a load test. */\nexport const MlInstallPhase = z.enum([\"packages\", \"model\", \"verifying\"]);\n\nexport const MlInstallProgress = z.strictObject({\n phase: MlInstallPhase,\n /** What is being fetched now: a package or a model file name. */\n item: z.string().max(200),\n bytes_done: nonNegInt,\n /** Null while the total is not known yet. */\n bytes_total: nonNegInt.nullable(),\n});\n\nexport const TranscriptionModelInfo = z.strictObject({\n id: TranscriptionModelId,\n /** Download size of the weights. */\n size_bytes: nonNegInt,\n multilingual: z.boolean(),\n installed: z.boolean(),\n});\n\nexport const TranscriptSegment = z.strictObject({\n start_s: z.number().min(0),\n end_s: z.number().min(0),\n text: z.string().max(4000),\n});\n\n/** What the `ml` service itself reports (the core adds the supervisor's view in ModelsStatusResult). */\nexport const MlStatusParams = z.strictObject({});\nexport const MlStatusResult = z.strictObject({\n runtime: MlRuntimeState,\n /** Non-null while runtime or model files are being installed. */\n install: MlInstallProgress.nullable(),\n /** The last install failure, one human line; null when the last install succeeded or none ran. */\n error: z.string().max(300).nullable(),\n /** Where inference runs once the runtime is installed: `cuda` only when a usable GPU is present. */\n accelerator: z.enum([\"cpu\", \"cuda\"]),\n models: z.array(TranscriptionModelInfo).max(16),\n default_model: TranscriptionModelId,\n});\n\n/** Install the runtime (if missing) and one model's weights (default: the default model). */\nexport const ModelsInstallParams = z.strictObject({ model: TranscriptionModelId.optional() });\nexport const ModelsInstallResult = z.strictObject({ model: TranscriptionModelId, elapsed_ms: nonNegInt });\n\n/**\n * Transcribe an audio or video file on the device. Any format the bundled decoder reads (wav, mp3,\n * m4a, webm/opus, mp4…). `language` is ISO 639-1; omitted = detect. `translate` = into English.\n */\nexport const ModelsTranscribeParams = z.strictObject({\n path: AbsPath,\n model: TranscriptionModelId.optional(),\n language: z\n .string()\n .regex(/^[a-z]{2,3}$/)\n .optional(),\n task: z.enum([\"transcribe\", \"translate\"]).default(\"transcribe\"),\n});\nexport const ModelsTranscribeResult = z.strictObject({\n text: z.string().max(400_000),\n language: z.string().max(8),\n language_probability: z.number().min(0).max(1),\n duration_s: z.number().min(0),\n model: TranscriptionModelId,\n segments: z.array(TranscriptSegment).max(20_000),\n elapsed_ms: nonNegInt,\n});\n\n/** A progress report while `ml.install` / `ml.transcribe` runs. */\nexport const MlProgress = z.strictObject({\n kind: z.enum([\"install\", \"transcribe\"]),\n /** 0–1 when known (transcribe: audio covered so far; install: bytes so far). */\n fraction: z.number().min(0).max(1).nullable(),\n install: MlInstallProgress.nullable(),\n /** The segment just transcribed (transcribe only): text appears as it is recognised. */\n segment: TranscriptSegment.nullable(),\n});\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Router ops (`models.*`)\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** The supervisor's view of the `ml` service process. */\nexport const MlServiceState = z.enum([\"starting\", \"ready\", \"restarting\", \"failed\", \"stopped\"]);\n\nexport const MlServiceStatus = z.strictObject({\n state: MlServiceState,\n pid: nonNegInt.nullable(),\n /** Restarts since the app started (crashes, missed health checks). */\n restarts: nonNegInt,\n /** The bundled interpreter's version once the service has answered, e.g. \"3.13.15\". */\n python: z.string().max(32).nullable(),\n /** Why the service is restarting or failed, one human line. */\n error: z.string().max(300).nullable(),\n});\n\nexport const ModelsStatusParams = z.strictObject({});\nexport const ModelsStatusResult = z.strictObject({\n service: MlServiceStatus,\n /** Null until the service has answered (starting, restarting, failed). */\n transcription: MlStatusResult.nullable(),\n});\n\n/** Sent to the client that started a `models.install` or `models.transcribe`, for that request. */\nexport const ModelsProgressEvent = z.strictObject({ request_id: RequestId, progress: MlProgress });\n\nexport type TranscriptionModelId = z.output<typeof TranscriptionModelId>;\nexport type MlStatusResult = z.output<typeof MlStatusResult>;\nexport type MlProgress = z.output<typeof MlProgress>;\nexport type ModelsStatusResult = z.output<typeof ModelsStatusResult>;\nexport type ModelsTranscribeParams = z.output<typeof ModelsTranscribeParams>;\nexport type ModelsTranscribeResult = z.output<typeof ModelsTranscribeResult>;\nexport type ModelsInstallParams = z.output<typeof ModelsInstallParams>;\nexport type ModelsInstallResult = z.output<typeof ModelsInstallResult>;\nexport type ModelsProgressEvent = z.output<typeof ModelsProgressEvent>;\nexport type TranscriptSegment = z.output<typeof TranscriptSegment>;\n","/** @ai-matrx/desktop-protocol — cap relay. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */\nimport { z } from \"zod\";\nimport { ProtocolErrorBody } from \"./errors\";\nimport { ProtocolVersion, epochMs } from \"./primitives\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// relay — events the relay itself emits to clients (cap \"relay\")\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const RelayDeviceStatusEvent = z\n .strictObject({\n online: z.boolean(),\n /**\n * When the device last went online/offline; null = it has never connected (since 1.1 —\n * NULL_SINCE: a 1.0 reader is sent 0, its old meaning).\n */\n since_ms: epochMs.nullable(),\n app_version: z.string().max(32).nullable(),\n protocol_version: ProtocolVersion.nullable(),\n });\nexport const RelayAuthExpiringEvent = z\n .strictObject({ expires_at_ms: epochMs });\n\n/** HTTP POST https://relay.matrxserver.com/v1/devices/{device_id}/call — unary ops only (lane F). */\nexport const RelayCallRequest = z\n .strictObject({\n cap: z.string().min(1).max(32),\n op: z.string().min(1).max(64),\n params: z.unknown(),\n timeout_ms: z.int().min(100).max(3_700_000).default(70_000),\n });\n/**\n * The caller of /call announces the newest protocol it reads in this request header; the relay\n * includes fields newer than 1.0 only when the announced version knows them (src/versioning.ts).\n */\nexport const RELAY_CALL_VERSION_HEADER = \"x-matrx-protocol-version\" as const;\n\nexport const RelayCallResponse = z\n .discriminatedUnion(\"ok\", [\n z.strictObject({\n ok: z.literal(true),\n result: z.unknown(),\n /** Since 1.1: the version the device negotiated for this call (its welcome). */\n protocol_version: ProtocolVersion.optional(),\n }),\n z.strictObject({\n ok: z.literal(false),\n error: ProtocolErrorBody,\n /** Since 1.1, as above (absent when the device never answered hello). */\n protocol_version: ProtocolVersion.optional(),\n }),\n ]);\n\n/**\n * How the relay runs one /call on the device: a fresh cid (its own connection) carrying exactly\n * RelayCallHello then RelayCallEnvelope, answered on that cid by response/error with id \"call\"\n * (an error on id \"hello\" also ends it), then a connection-end frame. A stream answer is refused.\n */\nexport const RELAY_CALL_HELLO_ID = \"hello\" as const;\nexport const RELAY_CALL_REQUEST_ID = \"call\" as const;\n\nexport const RelayCallHello = z\n .strictObject({\n type: z.literal(\"hello\"),\n id: z.literal(RELAY_CALL_HELLO_ID),\n protocolVersion: ProtocolVersion,\n clientType: z.literal(\"server\"),\n clientVersion: z.string().min(1).max(32),\n });\nexport const RelayCallEnvelope = z\n .strictObject({\n id: z.literal(RELAY_CALL_REQUEST_ID),\n type: z.literal(\"request\"),\n cap: z.string().min(1).max(32),\n op: z.string().min(1).max(64),\n params: z.unknown(),\n });\n\n/** HTTP GET /v1/devices/{device_id}/status (owner JWT). */\nexport const RelayStatusResponse = RelayDeviceStatusEvent;\n\n// Inferred (output) types — same name as the schema, so `FsEntry` is both the validator and its type.\nexport type RelayDeviceStatusEvent = z.output<typeof RelayDeviceStatusEvent>;\nexport type RelayAuthExpiringEvent = z.output<typeof RelayAuthExpiringEvent>;\nexport type RelayCallRequest = z.output<typeof RelayCallRequest>;\nexport type RelayCallResponse = z.output<typeof RelayCallResponse>;\nexport type RelayStatusResponse = z.output<typeof RelayStatusResponse>;\nexport type RelayCallHello = z.output<typeof RelayCallHello>;\nexport type RelayCallEnvelope = z.output<typeof RelayCallEnvelope>;\n","/**\n * @ai-matrx/desktop-protocol — cap clipboard (SPEC §6): the system clipboard's text. Schema source:\n * lint-enforced rules in scripts/check-schema-source.mjs. Added in protocol 1.3.\n */\nimport { z } from \"zod\";\nimport { nonNegInt } from \"./primitives\";\n\nexport const ClipboardReadParams = z.strictObject({});\nexport const ClipboardReadResult = z.strictObject({\n /** The clipboard's text (\"\" when it holds none), cut to 1 MiB. */\n text: z.string().max(1_048_576),\n truncated: z.boolean(),\n});\n\nexport const ClipboardWriteParams = z.strictObject({ text: z.string().max(1_048_576) });\nexport const ClipboardWriteResult = z.strictObject({ bytes: nonNegInt });\n\nexport type ClipboardReadResult = z.output<typeof ClipboardReadResult>;\nexport type ClipboardWriteParams = z.output<typeof ClipboardWriteParams>;\nexport type ClipboardWriteResult = z.output<typeof ClipboardWriteResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap proc (SPEC §6): the processes running on the person's computer,\n * the ports they listen on, and stopping one. Schema source: lint-enforced rules in\n * scripts/check-schema-source.mjs. Added in protocol 1.3.\n */\nimport { z } from \"zod\";\nimport { nonNegInt } from \"./primitives\";\n\nexport const ProcSort = z.enum([\"cpu\", \"memory\", \"pid\", \"name\"]);\n\nexport const ProcListParams = z.strictObject({\n /** Case-insensitive substring of the process name or its command line. */\n name: z.string().min(1).max(128).optional(),\n sort: ProcSort.default(\"cpu\"),\n limit: z.int().min(1).max(500).default(50),\n});\n\nexport const ProcInfo = z.strictObject({\n pid: z.int().min(0),\n /** Parent process id; null where the OS does not report it. */\n ppid: z.int().min(0).nullable(),\n name: z.string().max(256),\n /** The command line, cut to 1024 characters. */\n command: z.string().max(1024),\n /** Share of one core, as `ps` and Task Manager report it; null where the OS does not say. */\n cpu_percent: z.number().min(0).nullable(),\n memory_bytes: nonNegInt.nullable(),\n user: z.string().max(128).nullable(),\n});\n\nexport const ProcListResult = z.strictObject({\n processes: z.array(ProcInfo).max(500),\n /** Processes that matched before `limit`. */\n total: nonNegInt,\n truncated: z.boolean(),\n});\n\nexport const ProcPortsParams = z.strictObject({\n /** Only this port. */\n port: z.int().min(1).max(65535).optional(),\n});\n\nexport const ProcPort = z.strictObject({\n port: z.int().min(1).max(65535),\n protocol: z.enum([\"tcp\", \"udp\"]),\n /** The local address it listens on (\"127.0.0.1\", \"*\", \"::\"). */\n address: z.string().max(64),\n pid: z.int().min(0).nullable(),\n process: z.string().max(256).nullable(),\n});\n\nexport const ProcPortsResult = z.strictObject({ ports: z.array(ProcPort).max(4000) });\n\nexport const ProcKillParams = z.strictObject({\n pid: z.int().min(1),\n /** Kill outright (SIGKILL; on Windows the same /F) instead of asking it to quit. */\n force: z.boolean().default(false),\n});\n\nexport const ProcKillResult = z.strictObject({\n pid: z.int().min(1),\n signal: z.enum([\"SIGTERM\", \"SIGKILL\"]),\n /** True when the process was gone within 3 s. */\n exited: z.boolean(),\n});\n\nexport type ProcListParams = z.output<typeof ProcListParams>;\nexport type ProcListResult = z.output<typeof ProcListResult>;\nexport type ProcInfo = z.output<typeof ProcInfo>;\nexport type ProcPortsParams = z.output<typeof ProcPortsParams>;\nexport type ProcPortsResult = z.output<typeof ProcPortsResult>;\nexport type ProcPort = z.output<typeof ProcPort>;\nexport type ProcKillParams = z.output<typeof ProcKillParams>;\nexport type ProcKillResult = z.output<typeof ProcKillResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap system (SPEC §6): open a link or a file the way the person's\n * computer would, and show a notification. Schema source: lint-enforced rules in\n * scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\nimport { AbsPath } from \"./primitives\";\n\nexport const SystemOpenUrlParams = z.strictObject({\n /** http, https or mailto; opened in the person's default app for it. */\n url: z.string().min(1).max(4096),\n});\nexport const SystemOpenUrlResult = z.strictObject({ url: z.string().max(4096) });\n\nexport const SystemOpenPathParams = z.strictObject({\n path: AbsPath,\n /** Show it in the file manager (Finder, Explorer) instead of opening it. */\n reveal: z.boolean().default(false),\n});\nexport const SystemOpenPathResult = z.strictObject({ path: AbsPath, revealed: z.boolean() });\n\nexport const SystemNotifyParams = z.strictObject({\n title: z.string().min(1).max(128),\n body: z.string().max(1024).default(\"\"),\n});\nexport const SystemNotifyResult = z.strictObject({\n /** False when this computer has no notification service to show it (a bare Linux box). */\n shown: z.boolean(),\n});\n\nexport type SystemOpenUrlParams = z.output<typeof SystemOpenUrlParams>;\nexport type SystemOpenUrlResult = z.output<typeof SystemOpenUrlResult>;\nexport type SystemOpenPathParams = z.output<typeof SystemOpenPathParams>;\nexport type SystemOpenPathResult = z.output<typeof SystemOpenPathResult>;\nexport type SystemNotifyParams = z.output<typeof SystemNotifyParams>;\nexport type SystemNotifyResult = z.output<typeof SystemNotifyResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap screen (SPEC §6): the person's displays and a picture of one.\n * Schema source: lint-enforced rules in scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\nimport { nonNegInt } from \"./primitives\";\n\nexport const ScreenDisplay = z.strictObject({\n /** The OS's display id; pass it to screen.capture. */\n id: nonNegInt,\n name: z.string().max(128),\n /** Position and size in the OS's logical points (x and y may be negative left of or above the main display). */\n x: z.int(),\n y: z.int(),\n width: z.int().min(1),\n height: z.int().min(1),\n /** Pixels per point (2 on a Retina display). */\n scale: z.number().min(0.1).max(8),\n primary: z.boolean(),\n});\n\nexport const ScreenListParams = z.strictObject({});\nexport const ScreenListResult = z.strictObject({ displays: z.array(ScreenDisplay).max(32) });\n\nexport const ScreenCaptureParams = z.strictObject({\n /** The display (from screen.list); the primary display when absent. */\n display_id: nonNegInt.optional(),\n format: z.enum([\"jpeg\", \"png\"]).default(\"jpeg\"),\n /** Scale the picture down to at most this width in pixels (kept when already smaller). */\n max_width: z.int().min(160).max(7680).default(1600),\n});\nexport const ScreenCaptureResult = z.strictObject({\n display_id: nonNegInt,\n mime_type: z.enum([\"image/jpeg\", \"image/png\"]),\n width: z.int().min(1),\n height: z.int().min(1),\n /** The display's full resolution in pixels, before scaling. */\n source_width: z.int().min(1),\n source_height: z.int().min(1),\n /** The image, base64 (at most 6 MiB of text). */\n data_base64: z.string().max(6_291_456),\n});\n\nexport type ScreenDisplay = z.output<typeof ScreenDisplay>;\nexport type ScreenListResult = z.output<typeof ScreenListResult>;\nexport type ScreenCaptureParams = z.output<typeof ScreenCaptureParams>;\nexport type ScreenCaptureResult = z.output<typeof ScreenCaptureResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap window (SPEC §6): the windows on the person's screen; focus,\n * move or resize, and minimize one. Schema source: lint-enforced rules in\n * scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\nimport { nonNegInt } from \"./primitives\";\n\nexport const WindowInfo = z.strictObject({\n /** The OS's window handle (macOS window number, Windows HWND, X11 window id). */\n id: nonNegInt,\n title: z.string().max(512),\n /** Position and size in logical points. */\n x: z.int(),\n y: z.int(),\n width: z.int().min(0),\n height: z.int().min(0),\n /**\n * The application that owns the window, by the name the OS shows people; absent when the OS does\n * not say. Optional (never null, the schema rule) because it was added in protocol 1.7: an older\n * app's answer has no such field (FIELDS_SINCE).\n */\n app: z.string().max(256).optional(),\n /** The owning process id; absent when the OS does not say. Added in protocol 1.7. */\n pid: z.int().min(0).optional(),\n});\n\nexport const WindowListParams = z.strictObject({\n /** Case-insensitive substring of the window title. */\n title: z.string().min(1).max(256).optional(),\n limit: z.int().min(1).max(500).default(100),\n});\nexport const WindowListResult = z.strictObject({\n windows: z.array(WindowInfo).max(500),\n total: nonNegInt,\n truncated: z.boolean(),\n});\n\nexport const WindowFocusParams = z.strictObject({ id: nonNegInt });\nexport const WindowFocusResult = z.strictObject({ window: WindowInfo });\n\nexport const WindowMoveParams = z.strictObject({\n id: nonNegInt,\n /** New top-left corner; unchanged when absent. */\n x: z.int().optional(),\n y: z.int().optional(),\n /** New size; unchanged when absent. */\n width: z.int().min(50).max(16_384).optional(),\n height: z.int().min(50).max(16_384).optional(),\n});\nexport const WindowMoveResult = z.strictObject({ window: WindowInfo });\n\nexport const WindowMinimizeParams = z.strictObject({ id: nonNegInt });\nexport const WindowMinimizeResult = z.strictObject({ id: nonNegInt });\n\nexport type WindowInfo = z.output<typeof WindowInfo>;\nexport type WindowListParams = z.output<typeof WindowListParams>;\nexport type WindowListResult = z.output<typeof WindowListResult>;\nexport type WindowFocusParams = z.output<typeof WindowFocusParams>;\nexport type WindowFocusResult = z.output<typeof WindowFocusResult>;\nexport type WindowMoveParams = z.output<typeof WindowMoveParams>;\nexport type WindowMoveResult = z.output<typeof WindowMoveResult>;\nexport type WindowMinimizeParams = z.output<typeof WindowMinimizeParams>;\nexport type WindowMinimizeResult = z.output<typeof WindowMinimizeResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap input (SPEC §6): the keyboard and mouse, as if the person used\n * them. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\n\n/** Key names for input.hotkey. `cmd` is Command on a Mac and Ctrl elsewhere; `meta` is the Windows/Super key. */\nexport const InputKey = z.enum([\n \"cmd\", \"ctrl\", \"alt\", \"shift\", \"meta\",\n \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\",\n \"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\",\n \"f1\", \"f2\", \"f3\", \"f4\", \"f5\", \"f6\", \"f7\", \"f8\", \"f9\", \"f10\", \"f11\", \"f12\",\n \"enter\", \"tab\", \"escape\", \"space\", \"backspace\", \"delete\",\n \"up\", \"down\", \"left\", \"right\", \"home\", \"end\", \"pageup\", \"pagedown\",\n \"minus\", \"equal\", \"comma\", \"period\", \"slash\", \"semicolon\", \"quote\", \"bracketleft\", \"bracketright\", \"backslash\", \"grave\",\n]);\n\nexport const InputTypeTextParams = z.strictObject({ text: z.string().min(1).max(10_000) });\nexport const InputTypeTextResult = z.strictObject({ characters: z.int().min(1) });\n\nexport const InputHotkeyParams = z.strictObject({\n /** Pressed together in order and released in reverse: [\"cmd\", \"shift\", \"t\"]. */\n keys: z.array(InputKey).min(1).max(6),\n});\nexport const InputHotkeyResult = z.strictObject({ keys: z.array(InputKey) });\n\nexport const InputPoint = z.strictObject({ x: z.int(), y: z.int() });\n\nexport const InputMouseMoveParams = z.strictObject({\n /** Screen position in logical points (the coordinates screen.list and window.list report). */\n x: z.int(),\n y: z.int(),\n});\nexport const InputMouseMoveResult = z.strictObject({\n /** Where the pointer is now, read back from the OS. */\n position: InputPoint,\n});\n\nexport const InputMouseClickParams = z.strictObject({\n /** Move here first; clicks where the pointer is when absent. */\n x: z.int().optional(),\n y: z.int().optional(),\n button: z.enum([\"left\", \"right\", \"middle\"]).default(\"left\"),\n double: z.boolean().default(false),\n});\nexport const InputMouseClickResult = z.strictObject({\n position: InputPoint,\n button: z.enum([\"left\", \"right\", \"middle\"]),\n double: z.boolean(),\n});\n\nexport type InputKey = z.output<typeof InputKey>;\nexport type InputPoint = z.output<typeof InputPoint>;\nexport type InputTypeTextParams = z.output<typeof InputTypeTextParams>;\nexport type InputTypeTextResult = z.output<typeof InputTypeTextResult>;\nexport type InputHotkeyParams = z.output<typeof InputHotkeyParams>;\nexport type InputHotkeyResult = z.output<typeof InputHotkeyResult>;\nexport type InputMouseMoveParams = z.output<typeof InputMouseMoveParams>;\nexport type InputMouseMoveResult = z.output<typeof InputMouseMoveResult>;\nexport type InputMouseClickParams = z.output<typeof InputMouseClickParams>;\nexport type InputMouseClickResult = z.output<typeof InputMouseClickResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap power (SPEC §6): the battery and keeping the computer awake.\n * Schema source: lint-enforced rules in scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\nimport { epochMs, nonNegInt } from \"./primitives\";\n\nexport const PowerStatusParams = z.strictObject({});\nexport const PowerStatusResult = z.strictObject({\n has_battery: z.boolean(),\n /** 0–100; null without a battery. */\n percent: z.number().min(0).max(100).nullable(),\n charging: z.boolean().nullable(),\n /** On wall power; null where the OS does not say. */\n plugged_in: z.boolean().nullable(),\n /** Minutes of battery left; null when charging, unknown or without a battery. */\n minutes_left: nonNegInt.nullable(),\n /** Matrx 2 is keeping the computer awake (power.prevent_sleep) until this time; null when it is not. */\n awake_until_ms: epochMs.nullable(),\n});\n\nexport const PowerPreventSleepParams = z.strictObject({\n /** Keep the computer awake this long; 0 lets it sleep again now. */\n seconds: z.int().min(0).max(86_400),\n /** Shown where the OS lists what keeps it awake. */\n reason: z.string().min(1).max(128).default(\"Matrx 2 is working\"),\n});\nexport const PowerPreventSleepResult = z.strictObject({\n /** When it may sleep again; null after seconds 0. */\n awake_until_ms: epochMs.nullable(),\n});\n\nexport type PowerStatusResult = z.output<typeof PowerStatusResult>;\nexport type PowerPreventSleepParams = z.output<typeof PowerPreventSleepParams>;\nexport type PowerPreventSleepResult = z.output<typeof PowerPreventSleepResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap audio (SPEC §6): the person's microphones and speakers; record a\n * clip to a file, play a file. Speech to text is models.transcribe. Schema source: lint-enforced\n * rules in scripts/check-schema-source.mjs. Added in protocol 1.6.\n */\nimport { z } from \"zod\";\nimport { AbsPath, nonNegInt } from \"./primitives\";\n\nexport const AudioDevice = z.strictObject({\n /** The OS's name for it, as audio.record takes it. */\n id: z.string().min(1).max(256),\n name: z.string().max(256),\n default: z.boolean(),\n});\n\nexport const AudioDevicesParams = z.strictObject({});\nexport const AudioDevicesResult = z.strictObject({\n inputs: z.array(AudioDevice).max(64),\n outputs: z.array(AudioDevice).max(64),\n});\n\nexport const AudioRecordParams = z.strictObject({\n seconds: z.number().min(0.5).max(600),\n /** The microphone (from audio.devices); the default input when absent. */\n device_id: z.string().min(1).max(256).optional(),\n /** Where the WAV file goes; a new file in the temp folder when absent. */\n path: AbsPath.optional(),\n});\nexport const AudioRecordResult = z.strictObject({\n path: AbsPath,\n seconds: z.number().min(0),\n bytes: nonNegInt,\n /** Loudest sample, 0–1: 0 means the device gave silence. */\n peak: z.number().min(0).max(1),\n});\n\nexport const AudioPlayParams = z.strictObject({ path: AbsPath });\nexport const AudioPlayResult = z.strictObject({ path: AbsPath, seconds: z.number().min(0) });\n\nexport type AudioDevice = z.output<typeof AudioDevice>;\nexport type AudioDevicesResult = z.output<typeof AudioDevicesResult>;\nexport type AudioRecordParams = z.output<typeof AudioRecordParams>;\nexport type AudioRecordResult = z.output<typeof AudioRecordResult>;\nexport type AudioPlayParams = z.output<typeof AudioPlayParams>;\nexport type AudioPlayResult = z.output<typeof AudioPlayResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap resources (SPEC §6): how busy the computer is — CPU, memory and\n * disks. The busiest processes are proc.list. Schema source: lint-enforced rules in\n * scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\nimport { nonNegInt } from \"./primitives\";\n\nexport const ResourcesDisk = z.strictObject({\n /** Where it is mounted (\"/\", \"C:\"). */\n mount: z.string().max(512),\n /** The file system (\"apfs\", \"NTFS\", \"ext4\"). */\n fs: z.string().max(64),\n size_bytes: nonNegInt,\n used_bytes: nonNegInt,\n available_bytes: nonNegInt,\n});\n\nexport const ResourcesSnapshotParams = z.strictObject({});\nexport const ResourcesSnapshotResult = z.strictObject({\n cpu: z.strictObject({\n /** Busy share of all cores, 0–100, measured now. */\n percent: z.number().min(0).max(100),\n cores: z.int().min(1),\n /** 1, 5 and 15 minute load averages; null on Windows. */\n load: z.array(z.number().min(0)).length(3).nullable(),\n }),\n memory: z.strictObject({ total_bytes: nonNegInt, used_bytes: nonNegInt, available_bytes: nonNegInt }),\n swap: z.strictObject({ total_bytes: nonNegInt, used_bytes: nonNegInt }),\n disks: z.array(ResourcesDisk).max(64),\n uptime_seconds: nonNegInt,\n});\n\nexport type ResourcesDisk = z.output<typeof ResourcesDisk>;\nexport type ResourcesSnapshotResult = z.output<typeof ResourcesSnapshotResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap fs, polled watches (SPEC §6): watch a folder and read what\n * changed since the last read, for callers that ask rather than hold a stream (an agent's tool\n * call through the relay's /call). The streamed `fs.watch` resource stays for live clients. Schema\n * source: lint-enforced rules in scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\nimport { FsChange } from \"./fs\";\nimport { AbsPath, epochMs } from \"./primitives\";\n\nexport const FsWatchId = z.string().regex(/^fw_[A-Za-z0-9]{12,40}$/);\n\nexport const FsWatchStartParams = z.strictObject({\n path: AbsPath,\n recursive: z.boolean().default(true),\n /** Globs relative to `path` whose changes are not reported (\".git/**\", \"node_modules/**\"). */\n ignore: z.array(z.string().max(256)).max(64).default([]),\n});\nexport const FsWatchStartResult = z.strictObject({\n watch_id: FsWatchId,\n path: AbsPath,\n /** The watch ends by itself if nobody reads it for 30 minutes. */\n expires_at_ms: epochMs,\n});\n\nexport const FsWatchEventsParams = z.strictObject({\n watch_id: FsWatchId,\n /** Wait up to this long for a first change when none is waiting (0 answers at once). */\n wait_ms: z.int().min(0).max(25_000).default(0),\n});\nexport const FsWatchEventsResult = z.strictObject({\n /** What changed since the last read, oldest first; re-checked against the disk when read. */\n changes: z.array(FsChange).max(1000),\n /** Changes were dropped (more than 1000 waited): list the folder again. */\n overflow: z.boolean(),\n expires_at_ms: epochMs,\n});\n\nexport const FsWatchStopParams = z.strictObject({ watch_id: FsWatchId });\nexport const FsWatchStopResult = z.strictObject({ watch_id: FsWatchId });\n\nexport type FsWatchId = z.output<typeof FsWatchId>;\nexport type FsWatchStartParams = z.output<typeof FsWatchStartParams>;\nexport type FsWatchStartResult = z.output<typeof FsWatchStartResult>;\nexport type FsWatchEventsParams = z.output<typeof FsWatchEventsParams>;\nexport type FsWatchEventsResult = z.output<typeof FsWatchEventsResult>;\nexport type FsWatchStopParams = z.output<typeof FsWatchStopParams>;\nexport type FsWatchStopResult = z.output<typeof FsWatchStopResult>;\n","/**\n * @ai-matrx/desktop-protocol — cap exec, background jobs (SPEC §6): start a command that keeps\n * running (a dev server, a long build), read its output later, stop it. Schema source:\n * lint-enforced rules in scripts/check-schema-source.mjs. Added in protocol 1.4.\n */\nimport { z } from \"zod\";\nimport { AbsPath, epochMs, nonNegInt } from \"./primitives\";\n\nexport const ExecJobId = z.string().regex(/^job_[A-Za-z0-9]{12,40}$/);\n\nexport const ExecJobStartParams = z.strictObject({\n command: z.string().min(1).max(131_072),\n /** The folder it runs in; the home folder when absent. */\n cwd: AbsPath.optional(),\n env: z.record(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).max(128), z.string().max(32_768)).optional(),\n});\nexport const ExecJobStartResult = z.strictObject({ job_id: ExecJobId, pid: z.int().min(1), cwd: AbsPath });\n\nexport const ExecJobOutputParams = z.strictObject({\n job_id: ExecJobId,\n /** Byte offset into the job's output to read from (next_offset of the last read; 0 = the start). */\n offset: nonNegInt.default(0),\n /** Wait up to this long for new output or the exit when none is waiting (0 answers at once). */\n wait_ms: z.int().min(0).max(25_000).default(0),\n max_bytes: z.int().min(1024).max(1_048_576).default(65_536),\n});\nexport const ExecJobOutputResult = z.strictObject({\n /** stdout and stderr interleaved as they arrived (UTF-8). */\n output: z.string(),\n next_offset: nonNegInt,\n /** Bytes before `offset` that are gone (the job keeps its last 4 MiB). */\n dropped_bytes: nonNegInt,\n running: z.boolean(),\n exit_code: z.int().nullable(),\n});\n\nexport const ExecJobStopParams = z.strictObject({\n job_id: ExecJobId,\n /** End it at once (SIGKILL; on Windows the whole tree with /F) instead of asking it to quit. */\n force: z.boolean().default(false),\n});\nexport const ExecJobStopResult = z.strictObject({ job_id: ExecJobId, exited: z.boolean(), exit_code: z.int().nullable() });\n\nexport const ExecJobInfo = z.strictObject({\n job_id: ExecJobId,\n command: z.string().max(1024),\n pid: z.int().min(1),\n cwd: AbsPath,\n running: z.boolean(),\n exit_code: z.int().nullable(),\n started_at_ms: epochMs,\n output_bytes: nonNegInt,\n});\nexport const ExecJobListParams = z.strictObject({});\nexport const ExecJobListResult = z.strictObject({ jobs: z.array(ExecJobInfo).max(64) });\n\nexport type ExecJobId = z.output<typeof ExecJobId>;\nexport type ExecJobStartParams = z.output<typeof ExecJobStartParams>;\nexport type ExecJobStartResult = z.output<typeof ExecJobStartResult>;\nexport type ExecJobOutputParams = z.output<typeof ExecJobOutputParams>;\nexport type ExecJobOutputResult = z.output<typeof ExecJobOutputResult>;\nexport type ExecJobStopParams = z.output<typeof ExecJobStopParams>;\nexport type ExecJobStopResult = z.output<typeof ExecJobStopResult>;\nexport type ExecJobInfo = z.output<typeof ExecJobInfo>;\nexport type ExecJobListResult = z.output<typeof ExecJobListResult>;\n","/**\n * @ai-matrx/desktop-protocol — the `coding` capability's Claude Code history (SPEC §6 `coding`):\n * \"Import missing history\" — every Claude Code session on this computer that AI Matrx lacks, or is\n * behind on, imported through the shared importer (matrx-coding-history, the same code Matrx Local\n * runs) in Matrx 2's `coding` Python service (SPEC §3.10). Schema source: lint-enforced rules in\n * scripts/check-schema-source.mjs.\n *\n * Two contracts, both generated from this file (SPEC P11):\n * - the Router op `coding.history.import_missing` (every transport) and its progress event;\n * - the internal service ops `coding.plan_missing` / `coding.import_next` between the core and\n * the Python service. The core runs the loop: each service call is one bounded batch carrying\n * a fresh access token, so a long run never outlives its credential.\n */\nimport { z } from \"zod\";\nimport { RequestId, nonNegInt } from \"./primitives\";\n\n/** What the core adds to every coding service op from its own sign-in (never sent by a client). */\nexport const CodingServiceCredentials = z.strictObject({\n access_token: z.string().min(16).max(16_384),\n user_id: z.string().regex(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/),\n /** The AI Matrx server this app talks to (production, or a local server on the nightly copy). */\n server_url: z\n .string()\n .min(1)\n .max(2048)\n .regex(/^https?:\\/\\/[^\\s/?#]+(\\/[^\\s?#]*)?$/),\n});\n\n/**\n * Why a run stopped before it was done, as a state the screen can name:\n * signed_out — no usable AI Matrx sign-in (or it expired mid-run);\n * offline — the AI Matrx server did not answer;\n * organization_required — AI Matrx needs to know which organization files coding sessions;\n * claude_unavailable — Claude Code's account on this computer cannot be read;\n * cloud_list_unavailable — the server's list of sessions could not be proven complete;\n * history_too_large — more local sessions than the importer reads in one run.\n */\nexport const CodingHistoryBlocked = z.enum([\n \"signed_out\",\n \"offline\",\n \"organization_required\",\n \"claude_unavailable\",\n \"cloud_list_unavailable\",\n \"history_too_large\",\n]);\n\nexport const CodingHistoryFailure = z.strictObject({\n session_id: z.string().max(64),\n reason: z.string().max(300),\n});\n\n/** A run's counts so far, and its one honest line. */\nexport const CodingHistoryRun = z.strictObject({\n /** Claude Code sessions found on this computer. */\n local_sessions: nonNegInt,\n /** Of those, already complete in AI Matrx. */\n in_cloud: nonNegInt,\n /** In AI Matrx under neither of its identities. */\n missing: nonNegInt,\n /** In AI Matrx, but changed here after the last turn AI Matrx received (turns the hook lost). */\n behind: nonNegInt,\n /** Over the importer's size cap; never imported. */\n too_large: nonNegInt,\n imported: nonNegInt,\n /** Changed while being read; a later run takes them. */\n changed: nonNegInt,\n failed: nonNegInt,\n failures: z.array(CodingHistoryFailure).max(20),\n /** Candidates not reached yet. */\n remaining: nonNegInt,\n /** The one line a person reads, e.g. \"Imported 12 of 14 sessions. 140 already in AI Matrx.\" */\n summary: z.string().max(400),\n});\n\n/** The answer to each service op: where the run stands. */\nexport const CodingHistoryStep = z.strictObject({\n /** Null when the run could not start (blocked before a plan existed). */\n plan_id: z.string().regex(/^[0-9a-f]{32}$/).nullable(),\n finished: z.boolean(),\n blocked: CodingHistoryBlocked.nullable(),\n run: CodingHistoryRun,\n});\n\n/**\n * Service op `coding.plan_missing`: read the cloud's list and this computer's history (stat only).\n * `credentials` is null when nobody is signed in: the service answers `blocked: signed_out` with\n * its own line, so every sentence the person reads comes from one place.\n */\nexport const CodingPlanMissingParams = z.strictObject({ credentials: CodingServiceCredentials.nullable() });\n/** Service op `coding.import_next`: import the plan's next bounded batch (null credentials: as above). */\nexport const CodingImportNextParams = z.strictObject({\n plan_id: z.string().regex(/^[0-9a-f]{32}$/),\n credentials: CodingServiceCredentials.nullable(),\n});\n\n/** The coding service's progress messages (sent while it reads a large history). */\nexport const CodingServiceProgress = z.strictObject({\n phase: z.enum([\"checking\", \"importing\"]),\n done: nonNegInt,\n total: nonNegInt,\n});\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Router op (`coding.history.*`)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const CodingHistoryImportMissingParams = z.strictObject({});\nexport const CodingHistoryImportMissingResult = z.strictObject({\n state: z.enum([\"done\", \"blocked\", \"cancelled\"]),\n blocked: CodingHistoryBlocked.nullable(),\n run: CodingHistoryRun,\n elapsed_ms: nonNegInt,\n});\n\n/** Sent to the client that started `coding.history.import_missing`, for that request. */\nexport const CodingHistoryProgressEvent = z.strictObject({\n request_id: RequestId,\n phase: z.enum([\"checking\", \"importing\"]),\n /** Sessions settled so far, of `total` candidates (0 of 0 while checking). */\n done: nonNegInt,\n total: nonNegInt,\n imported: nonNegInt,\n failed: nonNegInt,\n});\n\nexport type CodingServiceCredentials = z.output<typeof CodingServiceCredentials>;\nexport type CodingHistoryBlocked = z.output<typeof CodingHistoryBlocked>;\nexport type CodingHistoryRun = z.output<typeof CodingHistoryRun>;\nexport type CodingHistoryStep = z.output<typeof CodingHistoryStep>;\nexport type CodingServiceProgress = z.output<typeof CodingServiceProgress>;\nexport type CodingHistoryImportMissingResult = z.output<typeof CodingHistoryImportMissingResult>;\nexport type CodingHistoryProgressEvent = z.output<typeof CodingHistoryProgressEvent>;\n","/**\n * @ai-matrx/desktop-protocol — cap apps (SPEC §6): the desktop apps a person uses (Claude, Codex,\n * Cursor, VS Code, Antigravity, and any app a later adapter adds), their profiles and usage.\n * Schema source: lint-enforced rules in scripts/check-schema-source.mjs.\n *\n * A profile is one data folder of one app on one device, so several accounts of the same app run\n * side by side. Profiles are the person's own rows in `users.desktop_app_profile` (the one\n * database); folders found on disk that no row names yet are listed with `id: null` so they can be\n * added. Nothing here is ever a credential: signing in happens inside the app.\n */\nimport { z } from \"zod\";\nimport { AbsPath, DeviceId, epochMs } from \"./primitives\";\n\n/** An adapter key: lowercase, open-ended (a new app needs only a new adapter). */\nexport const AppKey = z\n .string()\n .regex(/^[a-z][a-z0-9_-]{0,39}$/);\n\n/** A users.desktop_app_profile id. Plain pattern (see DeviceId for why not z.uuid()). */\nexport const AppProfileId = z\n .string()\n .regex(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/);\n\n/**\n * Where a profile's folder lives, RELATIVE to the app adapter's data root on that device: one or\n * more plain names joined by \"/\" (none starting with a dot, so never \".\" or \"..\"), never absolute.\n * Null on a profile means the app's own default profile. No lookaround: Pydantic's regex engine\n * has none.\n */\nexport const AppProfileLocator = z\n .string()\n .min(1)\n .max(512)\n .regex(/^[A-Za-z0-9 _()+@,-][A-Za-z0-9 ._()+@,-]{0,127}(\\/[A-Za-z0-9 _()+@,-][A-Za-z0-9 ._()+@,-]{0,127}){0,7}$/);\n\n/** supported: proven here; partial: works with a stated gap; unsupported: not on this OS. */\nexport const AppSupport = z.enum([\"supported\", \"partial\", \"unsupported\"]);\n\nexport const AppFeatureStatus = z.strictObject({\n status: AppSupport,\n /** One line, set whenever status is not \"supported\". */\n reason: z.string().max(140).nullable(),\n});\n\nexport const AppInfo = z.strictObject({\n app_key: AppKey,\n name: z.string().max(64),\n installed: z.boolean(),\n /** The app's own version string, or null when it is not installed or does not say. */\n version: z.string().max(64).nullable(),\n /** The install found (an .app bundle, an .exe, a binary), or null. */\n location: AbsPath.nullable(),\n /** Open the app at all on this OS. */\n open: AppFeatureStatus,\n /** Separate profiles (one account each) on this OS. */\n profiles: AppFeatureStatus,\n /** Plan usage read from the app's own files on this OS. */\n usage: AppFeatureStatus,\n});\n\n/** One plan-usage figure, as the app itself last recorded it. */\nexport const AppUsageReading = z.strictObject({\n window: z.enum([\"five_hour\", \"weekly\", \"extra\"]),\n /** 0–100 for five_hour and weekly; extra-usage spend as a percent of its cap (may pass 100). */\n percent: z.number().min(0).max(10_000),\n /** When the app recorded it. */\n sampled_at_ms: epochMs,\n /** True when the window has rolled over since the sample, so the figure has reset. */\n reset_since: z.boolean(),\n});\n\nexport const AppProfile = z.strictObject({\n /** The row's id; null for a folder found on disk that no row names yet. */\n id: AppProfileId.nullable(),\n app_key: AppKey,\n display_name: z.string().min(1).max(120),\n /** The account the person means to be signed in here; null when not stated (never guessed). */\n account_identity: z.string().min(3).max(320).nullable(),\n profile_locator: AppProfileLocator.nullable(),\n /** The device the row is tied to; null when the row names none. */\n device_id: DeviceId.nullable(),\n /** The folder this profile resolves to on this device; null for a row tied to another device. */\n folder: AbsPath.nullable(),\n /** The folder exists on this device. */\n on_disk: z.boolean(),\n /** An instance with this profile is running; null when it could not be determined. */\n running: z.boolean().nullable(),\n /** Usage the app recorded for this profile; null when the app exposes none here. */\n usage: z.array(AppUsageReading).nullable(),\n last_opened_ms: epochMs.nullable(),\n});\n\nexport const AppsListParams = z.strictObject({});\nexport const AppsListResult = z.strictObject({ apps: z.array(AppInfo) });\n\nexport const AppsProfilesListParams = z.strictObject({\n /** Only this app's profiles; every app's when absent. */\n app_key: AppKey.optional(),\n});\nexport const AppsProfilesListResult = z.strictObject({\n profiles: z.array(AppProfile),\n /**\n * Whether the saved rows could be read: false while signed out or offline, when only folders\n * found on disk are listed.\n */\n registry: z.enum([\"ok\", \"signed_out\", \"unavailable\"]),\n});\n\n/** Create (no id) or update (id) the person's own profile row. */\nexport const AppsProfilesSaveParams = z.strictObject({\n id: AppProfileId.optional(),\n app_key: AppKey,\n display_name: z.string().min(1).max(120),\n account_identity: z.string().min(3).max(320).nullable(),\n /** On create: the folder to use (one found on disk), or null for the app's default profile. Ignored on update. */\n profile_locator: AppProfileLocator.nullable(),\n /** On create with profile_locator null: make a new folder named after display_name instead. */\n new_folder: z.boolean().default(false),\n});\nexport const AppsProfilesSaveResult = AppProfile;\n\n/** Remove the row (soft delete). The folder on disk is never touched. */\nexport const AppsProfilesRemoveParams = z.strictObject({ id: AppProfileId });\nexport const AppsProfilesRemoveResult = z.strictObject({ removed: z.boolean() });\n\n/** Open the app with a profile (its default profile when profile_id is absent). */\nexport const AppsOpenParams = z.strictObject({\n app_key: AppKey,\n profile_id: AppProfileId.optional(),\n});\nexport const AppsOpenResult = z.strictObject({\n /** True when an instance with this profile was already running; it is brought forward. */\n already_running: z.boolean(),\n folder: AbsPath.nullable(),\n});\n\n// Inferred (output) types — same name as the schema, so `AppInfo` is both the validator and its type.\nexport type AppKey = z.output<typeof AppKey>;\nexport type AppProfileId = z.output<typeof AppProfileId>;\nexport type AppProfileLocator = z.output<typeof AppProfileLocator>;\nexport type AppSupport = z.output<typeof AppSupport>;\nexport type AppFeatureStatus = z.output<typeof AppFeatureStatus>;\nexport type AppInfo = z.output<typeof AppInfo>;\nexport type AppUsageReading = z.output<typeof AppUsageReading>;\nexport type AppProfile = z.output<typeof AppProfile>;\nexport type AppsListParams = z.output<typeof AppsListParams>;\nexport type AppsListResult = z.output<typeof AppsListResult>;\nexport type AppsProfilesListParams = z.output<typeof AppsProfilesListParams>;\nexport type AppsProfilesListResult = z.output<typeof AppsProfilesListResult>;\nexport type AppsProfilesSaveParams = z.output<typeof AppsProfilesSaveParams>;\nexport type AppsProfilesSaveResult = z.output<typeof AppsProfilesSaveResult>;\nexport type AppsProfilesRemoveParams = z.output<typeof AppsProfilesRemoveParams>;\nexport type AppsProfilesRemoveResult = z.output<typeof AppsProfilesRemoveResult>;\nexport type AppsOpenParams = z.output<typeof AppsOpenParams>;\nexport type AppsOpenResult = z.output<typeof AppsOpenResult>;\n","/** @ai-matrx/desktop-protocol — the op and event registries (Router, client and Python are generated from these). */\nimport { z } from \"zod\";\nimport {\n AbsPath,\n DeviceId,\n ProtocolVersion,\n RequestId,\n ResourceId,\n} from \"./primitives\";\nimport {\n ErrorCode,\n ErrorReason,\n FsPatchEditFailure,\n ProtocolErrorBody,\n} from \"./errors\";\nimport {\n FrameHeader,\n RelayHopEnvelopeHeader,\n RelayHopConnectionEnd,\n} from \"./frame\";\nimport {\n CancelMsg,\n ClientToCoreMsg,\n ClientType,\n CoreToClientMsg,\n CreditMsg,\n EndMsg,\n EndReason,\n ErrorMsg,\n EventMsg,\n HelloMsg,\n Limits,\n OpDescriptor,\n RelayMsg,\n RequestMsg,\n ResponseMsg,\n StreamMeta,\n StreamMsg,\n Welcome,\n CloseCodeValue,\n} from \"./envelope\";\nimport {\n OsPermissionName,\n SysinfoGetParams,\n SysinfoGetResult,\n} from \"./sysinfo\";\nimport {\n FsChange,\n FsChangedEvent,\n FsDeleteParams,\n FsDeleteResult,\n FsEncoding,\n FsEntry,\n FsKind,\n FsListParams,\n FsListResult,\n FsMkdirParams,\n FsMkdirResult,\n FsMoveParams,\n FsMoveResult,\n FsPatchEditApplied,\n FsPatchParams,\n FsPatchResult,\n FsReadParams,\n FsReadResult,\n FsReadStreamParams,\n FsReadStreamResult,\n FsSearchContentParams,\n FsSearchContentResult,\n FsSearchPathsParams,\n FsSearchPathsResult,\n FsStatParams,\n FsStatResult,\n FsWatchParams,\n FsWatchResult,\n FsWriteParams,\n FsWriteResult,\n} from \"./fs\";\nimport {\n ExecCwdEvent,\n ExecExitedEvent,\n ExecListParams,\n ExecListResult,\n ExecPtyKillParams,\n ExecPtyKillResult,\n ExecPtyResizeParams,\n ExecPtyResizeResult,\n ExecPtySignalParams,\n ExecPtySignalResult,\n ExecPtyStartParams,\n ExecPtyStartResult,\n ExecPtyWriteParams,\n ExecPtyWriteResult,\n ExecRunParams,\n ExecRunResult,\n ExecTitleEvent,\n PtyInfo,\n Signal,\n} from \"./exec\";\nimport {\n ResourceInfo,\n SessionAttachParams,\n SessionAttachResult,\n SessionControlChangedEvent,\n SessionDetachParams,\n SessionDetachResult,\n SessionListParams,\n SessionListResult,\n SessionReleaseParams,\n SessionReleaseResult,\n} from \"./session\";\nimport {\n MlInstallPhase,\n MlInstallProgress,\n MlProgress,\n MlRuntimeState,\n MlServiceState,\n MlServiceStatus,\n MlStatusParams,\n MlStatusResult,\n ModelsInstallParams,\n ModelsInstallResult,\n ModelsProgressEvent,\n ModelsStatusParams,\n ModelsStatusResult,\n ModelsTranscribeParams,\n ModelsTranscribeResult,\n TranscriptionModelId,\n TranscriptionModelInfo,\n TranscriptSegment,\n} from \"./models\";\nimport {\n ContractHash,\n CoreToServiceMsg,\n ServiceCancel,\n ServiceErrorMsg,\n ServiceHello,\n ServiceName,\n ServicePing,\n ServicePong,\n ServiceProgressMsg,\n ServiceRequest,\n ServiceResponse,\n ServiceShutdown,\n ServiceToCoreMsg,\n ServiceToken,\n ServiceWelcome,\n} from \"./service\";\nimport {\n RelayAuthExpiringEvent,\n RelayCallRequest,\n RelayCallResponse,\n RelayDeviceStatusEvent,\n RelayCallHello,\n RelayCallEnvelope,\n} from \"./relay\";\nimport { ClipboardReadParams, ClipboardReadResult, ClipboardWriteParams, ClipboardWriteResult } from \"./clipboard\";\nimport { ProcInfo, ProcKillParams, ProcKillResult, ProcListParams, ProcListResult, ProcPort, ProcPortsParams, ProcPortsResult, ProcSort } from \"./proc\";\nimport { SystemNotifyParams, SystemNotifyResult, SystemOpenPathParams, SystemOpenPathResult, SystemOpenUrlParams, SystemOpenUrlResult } from \"./system\";\nimport { ScreenCaptureParams, ScreenCaptureResult, ScreenDisplay, ScreenListParams, ScreenListResult } from \"./screen\";\nimport { WindowFocusParams, WindowFocusResult, WindowInfo, WindowListParams, WindowListResult, WindowMinimizeParams, WindowMinimizeResult, WindowMoveParams, WindowMoveResult } from \"./window\";\nimport { InputHotkeyParams, InputHotkeyResult, InputKey, InputMouseClickParams, InputMouseClickResult, InputMouseMoveParams, InputMouseMoveResult, InputPoint, InputTypeTextParams, InputTypeTextResult } from \"./input\";\nimport { PowerPreventSleepParams, PowerPreventSleepResult, PowerStatusParams, PowerStatusResult } from \"./power\";\nimport { AudioDevice, AudioDevicesParams, AudioDevicesResult, AudioPlayParams, AudioPlayResult, AudioRecordParams, AudioRecordResult } from \"./audio\";\nimport { ResourcesDisk, ResourcesSnapshotParams, ResourcesSnapshotResult } from \"./resources\";\nimport { FsWatchEventsParams, FsWatchEventsResult, FsWatchId, FsWatchStartParams, FsWatchStartResult, FsWatchStopParams, FsWatchStopResult } from \"./fs-watch\";\nimport { ExecJobId, ExecJobInfo, ExecJobListParams, ExecJobListResult, ExecJobOutputParams, ExecJobOutputResult, ExecJobStartParams, ExecJobStartResult, ExecJobStopParams, ExecJobStopResult } from \"./exec-job\";\nimport { ToolLevel, ToolLevelResult, ToolName, ToolOutcome, ToolPlatform, ToolResultsFile, ToolTransport } from \"./tools\";\nimport {\n CodingHistoryBlocked,\n CodingHistoryFailure,\n CodingHistoryImportMissingParams,\n CodingHistoryImportMissingResult,\n CodingHistoryProgressEvent,\n CodingHistoryRun,\n CodingHistoryStep,\n CodingImportNextParams,\n CodingPlanMissingParams,\n CodingServiceCredentials,\n CodingServiceProgress,\n} from \"./coding\";\n\nimport {\n AppFeatureStatus,\n AppInfo,\n AppKey,\n AppProfile,\n AppProfileId,\n AppProfileLocator,\n AppSupport,\n AppUsageReading,\n AppsListParams,\n AppsListResult,\n AppsOpenParams,\n AppsOpenResult,\n AppsProfilesListParams,\n AppsProfilesListResult,\n AppsProfilesRemoveParams,\n AppsProfilesRemoveResult,\n AppsProfilesSaveParams,\n AppsProfilesSaveResult,\n} from \"./apps\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Registries — the Router, the client and the Python side are all generated from these.\n// kind: unary = response only; stream = response, then stream/end on the same id;\n// resource = like stream and the result carries a resource_id the Session Manager owns.\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type OpSpec = {\n readonly params: z.ZodType;\n readonly result: z.ZodType;\n readonly kind: \"unary\" | \"stream\" | \"resource\";\n readonly since: \"1.0\" | \"1.2\" | \"1.3\" | \"1.4\" | \"1.5\" | \"1.6\";\n readonly errors: readonly z.infer<typeof ErrorCode>[];\n};\n\nconst FS_ERR = [\"NOT_FOUND\", \"PERMISSION_DENIED_OS\", \"INVALID_PARAMS\", \"RESOURCE_BUSY\", \"INTERNAL\"] as const;\n\nexport const OPS = {\n \"sysinfo.get\": { params: SysinfoGetParams, result: SysinfoGetResult, kind: \"unary\", since: \"1.0\", errors: [\"INTERNAL\"] },\n\n \"fs.list\": { params: FsListParams, result: FsListResult, kind: \"unary\", since: \"1.0\", errors: FS_ERR },\n \"fs.stat\": { params: FsStatParams, result: FsStatResult, kind: \"unary\", since: \"1.0\", errors: FS_ERR },\n \"fs.read\": { params: FsReadParams, result: FsReadResult, kind: \"unary\", since: \"1.0\", errors: [...FS_ERR, \"PAYLOAD_TOO_LARGE\"] },\n \"fs.read_stream\": { params: FsReadStreamParams, result: FsReadStreamResult, kind: \"stream\", since: \"1.0\", errors: [...FS_ERR, \"CANCELLED\"] },\n \"fs.write\": { params: FsWriteParams, result: FsWriteResult, kind: \"unary\", since: \"1.0\", errors: [...FS_ERR, \"CONFLICT\", \"PAYLOAD_TOO_LARGE\"] },\n \"fs.mkdir\": { params: FsMkdirParams, result: FsMkdirResult, kind: \"unary\", since: \"1.0\", errors: [...FS_ERR, \"CONFLICT\"] },\n \"fs.move\": { params: FsMoveParams, result: FsMoveResult, kind: \"unary\", since: \"1.0\", errors: [...FS_ERR, \"CONFLICT\"] },\n \"fs.delete\": { params: FsDeleteParams, result: FsDeleteResult, kind: \"unary\", since: \"1.0\", errors: FS_ERR },\n \"fs.watch\": { params: FsWatchParams, result: FsWatchResult, kind: \"resource\", since: \"1.0\", errors: [...FS_ERR, \"RATE_LIMITED\"] },\n \"fs.patch\": { params: FsPatchParams, result: FsPatchResult, kind: \"unary\", since: \"1.0\", errors: [...FS_ERR, \"CONFLICT\"] },\n \"fs.search_paths\": { params: FsSearchPathsParams, result: FsSearchPathsResult, kind: \"unary\", since: \"1.0\", errors: [...FS_ERR, \"TIMEOUT\"] },\n \"fs.search_content\": { params: FsSearchContentParams, result: FsSearchContentResult, kind: \"unary\", since: \"1.0\", errors: [...FS_ERR, \"TIMEOUT\"] },\n\n \"exec.pty.start\": { params: ExecPtyStartParams, result: ExecPtyStartResult, kind: \"resource\", since: \"1.0\", errors: [\"INVALID_PARAMS\", \"NOT_FOUND\", \"RATE_LIMITED\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"exec.pty.write\": { params: ExecPtyWriteParams, result: ExecPtyWriteResult, kind: \"unary\", since: \"1.0\", errors: [\"RESOURCE_GONE\", \"AUTH_FORBIDDEN\", \"INVALID_PARAMS\"] },\n \"exec.pty.resize\": { params: ExecPtyResizeParams, result: ExecPtyResizeResult, kind: \"unary\", since: \"1.0\", errors: [\"RESOURCE_GONE\", \"AUTH_FORBIDDEN\"] },\n \"exec.pty.signal\": { params: ExecPtySignalParams, result: ExecPtySignalResult, kind: \"unary\", since: \"1.0\", errors: [\"RESOURCE_GONE\", \"AUTH_FORBIDDEN\", \"PLATFORM_UNSUPPORTED\"] },\n \"exec.pty.kill\": { params: ExecPtyKillParams, result: ExecPtyKillResult, kind: \"unary\", since: \"1.0\", errors: [\"RESOURCE_GONE\", \"AUTH_FORBIDDEN\"] },\n \"exec.list\": { params: ExecListParams, result: ExecListResult, kind: \"unary\", since: \"1.0\", errors: [\"INTERNAL\"] },\n \"exec.run\": { params: ExecRunParams, result: ExecRunResult, kind: \"unary\", since: \"1.0\", errors: [\"INVALID_PARAMS\", \"NOT_FOUND\", \"TIMEOUT\", \"CANCELLED\", \"INTERNAL\"] },\n\n \"session.attach\": { params: SessionAttachParams, result: SessionAttachResult, kind: \"stream\", since: \"1.0\", errors: [\"RESOURCE_GONE\", \"AUTH_FORBIDDEN\", \"RESOURCE_BUSY\"] },\n \"session.detach\": { params: SessionDetachParams, result: SessionDetachResult, kind: \"unary\", since: \"1.0\", errors: [\"RESOURCE_GONE\"] },\n \"session.release\": { params: SessionReleaseParams, result: SessionReleaseResult, kind: \"unary\", since: \"1.0\", errors: [\"RESOURCE_GONE\", \"AUTH_FORBIDDEN\"] },\n \"session.list\": { params: SessionListParams, result: SessionListResult, kind: \"unary\", since: \"1.0\", errors: [\"INTERNAL\"] },\n\n // Local models (SPEC §6), served by the `ml` Python service through SERVICES below.\n \"models.status\": { params: ModelsStatusParams, result: ModelsStatusResult, kind: \"unary\", since: \"1.2\", errors: [\"INTERNAL\"] },\n \"models.install\": { params: ModelsInstallParams, result: ModelsInstallResult, kind: \"unary\", since: \"1.2\", errors: [\"RESOURCE_BUSY\", \"RESOURCE_GONE\", \"TIMEOUT\", \"CANCELLED\", \"INTERNAL\"] },\n \"models.transcribe\": { params: ModelsTranscribeParams, result: ModelsTranscribeResult, kind: \"unary\", since: \"1.2\", errors: [\"NOT_FOUND\", \"INVALID_PARAMS\", \"PERMISSION_DENIED_OS\", \"RESOURCE_BUSY\", \"RESOURCE_GONE\", \"CANCELLED\", \"PAYLOAD_TOO_LARGE\", \"INTERNAL\"] },\n\n // Desktop apps and their profiles (SPEC §6 apps); profiles are rows in users.desktop_app_profile.\n \"apps.list\": { params: AppsListParams, result: AppsListResult, kind: \"unary\", since: \"1.2\", errors: [\"INTERNAL\"] },\n \"apps.profiles.list\": { params: AppsProfilesListParams, result: AppsProfilesListResult, kind: \"unary\", since: \"1.2\", errors: [\"NOT_FOUND\", \"INVALID_PARAMS\", \"INTERNAL\"] },\n \"apps.profiles.save\": { params: AppsProfilesSaveParams, result: AppsProfilesSaveResult, kind: \"unary\", since: \"1.2\", errors: [\"AUTH_REQUIRED\", \"AUTH_FORBIDDEN\", \"NOT_FOUND\", \"INVALID_PARAMS\", \"CONFLICT\", \"PLATFORM_UNSUPPORTED\", \"DEVICE_OFFLINE\", \"INTERNAL\"] },\n \"apps.profiles.remove\": { params: AppsProfilesRemoveParams, result: AppsProfilesRemoveResult, kind: \"unary\", since: \"1.2\", errors: [\"AUTH_REQUIRED\", \"AUTH_FORBIDDEN\", \"NOT_FOUND\", \"DEVICE_OFFLINE\", \"INTERNAL\"] },\n \"apps.open\": { params: AppsOpenParams, result: AppsOpenResult, kind: \"unary\", since: \"1.2\", errors: [\"NOT_FOUND\", \"PLATFORM_UNSUPPORTED\", \"AUTH_REQUIRED\", \"DEVICE_OFFLINE\", \"INTERNAL\"] },\n\n \"proc.list\": { params: ProcListParams, result: ProcListResult, kind: \"unary\", since: \"1.3\", errors: [\"INVALID_PARAMS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"proc.ports\": { params: ProcPortsParams, result: ProcPortsResult, kind: \"unary\", since: \"1.3\", errors: [\"INVALID_PARAMS\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"proc.kill\": { params: ProcKillParams, result: ProcKillResult, kind: \"unary\", since: \"1.3\", errors: [\"NOT_FOUND\", \"AUTH_FORBIDDEN\", \"PERMISSION_DENIED_OS\", \"INVALID_PARAMS\", \"INTERNAL\"] },\n\n \"clipboard.read\": { params: ClipboardReadParams, result: ClipboardReadResult, kind: \"unary\", since: \"1.3\", errors: [\"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"clipboard.write\": { params: ClipboardWriteParams, result: ClipboardWriteResult, kind: \"unary\", since: \"1.3\", errors: [\"PLATFORM_UNSUPPORTED\", \"PAYLOAD_TOO_LARGE\", \"INTERNAL\"] },\n \"fs.watch.start\": { params: FsWatchStartParams, result: FsWatchStartResult, kind: \"unary\", since: \"1.4\", errors: [...FS_ERR, \"RATE_LIMITED\"] },\n \"fs.watch.events\": { params: FsWatchEventsParams, result: FsWatchEventsResult, kind: \"unary\", since: \"1.4\", errors: [\"RESOURCE_GONE\", \"INVALID_PARAMS\", \"INTERNAL\"] },\n \"fs.watch.stop\": { params: FsWatchStopParams, result: FsWatchStopResult, kind: \"unary\", since: \"1.4\", errors: [\"RESOURCE_GONE\", \"INVALID_PARAMS\"] },\n\n \"exec.job.start\": { params: ExecJobStartParams, result: ExecJobStartResult, kind: \"unary\", since: \"1.4\", errors: [\"INVALID_PARAMS\", \"NOT_FOUND\", \"RATE_LIMITED\", \"INTERNAL\"] },\n \"exec.job.output\": { params: ExecJobOutputParams, result: ExecJobOutputResult, kind: \"unary\", since: \"1.4\", errors: [\"RESOURCE_GONE\", \"INVALID_PARAMS\"] },\n \"exec.job.stop\": { params: ExecJobStopParams, result: ExecJobStopResult, kind: \"unary\", since: \"1.4\", errors: [\"RESOURCE_GONE\", \"INVALID_PARAMS\", \"INTERNAL\"] },\n \"exec.job.list\": { params: ExecJobListParams, result: ExecJobListResult, kind: \"unary\", since: \"1.4\", errors: [\"INTERNAL\"] },\n\n \"system.open_url\": { params: SystemOpenUrlParams, result: SystemOpenUrlResult, kind: \"unary\", since: \"1.4\", errors: [\"INVALID_PARAMS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"system.open_path\": { params: SystemOpenPathParams, result: SystemOpenPathResult, kind: \"unary\", since: \"1.4\", errors: [\"NOT_FOUND\", \"INVALID_PARAMS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"system.notify\": { params: SystemNotifyParams, result: SystemNotifyResult, kind: \"unary\", since: \"1.4\", errors: [\"PERMISSION_DENIED_OS\", \"INTERNAL\"] },\n\n \"screen.list\": { params: ScreenListParams, result: ScreenListResult, kind: \"unary\", since: \"1.4\", errors: [\"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"screen.capture\": { params: ScreenCaptureParams, result: ScreenCaptureResult, kind: \"unary\", since: \"1.4\", errors: [\"NOT_FOUND\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"PAYLOAD_TOO_LARGE\", \"INTERNAL\"] },\n\n \"window.list\": { params: WindowListParams, result: WindowListResult, kind: \"unary\", since: \"1.4\", errors: [\"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"window.focus\": { params: WindowFocusParams, result: WindowFocusResult, kind: \"unary\", since: \"1.4\", errors: [\"NOT_FOUND\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"window.move\": { params: WindowMoveParams, result: WindowMoveResult, kind: \"unary\", since: \"1.4\", errors: [\"NOT_FOUND\", \"INVALID_PARAMS\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"window.minimize\": { params: WindowMinimizeParams, result: WindowMinimizeResult, kind: \"unary\", since: \"1.4\", errors: [\"NOT_FOUND\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n\n \"input.type_text\": { params: InputTypeTextParams, result: InputTypeTextResult, kind: \"unary\", since: \"1.4\", errors: [\"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"input.hotkey\": { params: InputHotkeyParams, result: InputHotkeyResult, kind: \"unary\", since: \"1.4\", errors: [\"INVALID_PARAMS\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"input.mouse_move\": { params: InputMouseMoveParams, result: InputMouseMoveResult, kind: \"unary\", since: \"1.4\", errors: [\"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"input.mouse_click\": { params: InputMouseClickParams, result: InputMouseClickResult, kind: \"unary\", since: \"1.4\", errors: [\"INVALID_PARAMS\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n\n \"power.status\": { params: PowerStatusParams, result: PowerStatusResult, kind: \"unary\", since: \"1.4\", errors: [\"INTERNAL\"] },\n \"power.prevent_sleep\": { params: PowerPreventSleepParams, result: PowerPreventSleepResult, kind: \"unary\", since: \"1.4\", errors: [\"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n\n \"resources.snapshot\": { params: ResourcesSnapshotParams, result: ResourcesSnapshotResult, kind: \"unary\", since: \"1.4\", errors: [\"INTERNAL\"] },\n\n \"audio.devices\": { params: AudioDevicesParams, result: AudioDevicesResult, kind: \"unary\", since: \"1.6\", errors: [\"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n \"audio.record\": { params: AudioRecordParams, result: AudioRecordResult, kind: \"unary\", since: \"1.6\", errors: [\"NOT_FOUND\", \"PERMISSION_DENIED_OS\", \"PLATFORM_UNSUPPORTED\", \"RESOURCE_BUSY\", \"INTERNAL\"] },\n \"audio.play\": { params: AudioPlayParams, result: AudioPlayResult, kind: \"unary\", since: \"1.6\", errors: [\"NOT_FOUND\", \"INVALID_PARAMS\", \"PLATFORM_UNSUPPORTED\", \"INTERNAL\"] },\n\n // Claude Code history (SPEC §6 coding): served by the `coding` Python service through SERVICES below.\n \"coding.history.import_missing\": { params: CodingHistoryImportMissingParams, result: CodingHistoryImportMissingResult, kind: \"unary\", since: \"1.5\", errors: [\"RESOURCE_BUSY\", \"RESOURCE_GONE\", \"CANCELLED\", \"INTERNAL\"] },\n} as const satisfies Record<string, OpSpec>;\n\nexport type OpName = keyof typeof OPS;\nexport type OpParams<N extends OpName> = z.input<(typeof OPS)[N][\"params\"]>;\nexport type OpResult<N extends OpName> = z.output<(typeof OPS)[N][\"result\"]>;\n\nexport const EVENTS = {\n \"fs.changed\": FsChangedEvent,\n \"exec.exited\": ExecExitedEvent,\n \"exec.title\": ExecTitleEvent,\n \"exec.cwd\": ExecCwdEvent,\n \"session.control_changed\": SessionControlChangedEvent,\n \"models.progress\": ModelsProgressEvent,\n \"coding.history.progress\": CodingHistoryProgressEvent,\n \"relay.device_status\": RelayDeviceStatusEvent,\n \"relay.auth_expiring\": RelayAuthExpiringEvent,\n} as const satisfies Record<string, z.ZodType>;\n\nexport type EventName = keyof typeof EVENTS;\n\n/**\n * Supervised Python services (SPEC §3.10) and the ops each serves over its local socket\n * (src/schema/service.ts). The Python side's handler protocol, op table and models are generated\n * from this table (scripts/gen_pydantic.py); the core's service client is typed by it. A Router\n * op that a capability owner forwards uses the same params/result schemas as its service op.\n */\nexport type ServiceOpSpec = { readonly params: z.ZodType; readonly result: z.ZodType };\nexport type ServiceSpec = { readonly progress: z.ZodType; readonly ops: Readonly<Record<string, ServiceOpSpec>> };\n\nexport const SERVICES = {\n ml: {\n progress: MlProgress,\n ops: {\n \"ml.status\": { params: MlStatusParams, result: MlStatusResult },\n \"ml.install\": { params: ModelsInstallParams, result: ModelsInstallResult },\n \"ml.transcribe\": { params: ModelsTranscribeParams, result: ModelsTranscribeResult },\n },\n },\n coding: {\n progress: CodingServiceProgress,\n ops: {\n \"coding.plan_missing\": { params: CodingPlanMissingParams, result: CodingHistoryStep },\n \"coding.import_next\": { params: CodingImportNextParams, result: CodingHistoryStep },\n },\n },\n} as const satisfies Record<z.infer<typeof ServiceName>, ServiceSpec>;\n\nexport type ServiceId = keyof typeof SERVICES;\nexport type ServiceOpName<S extends ServiceId> = keyof (typeof SERVICES)[S][\"ops\"] & string;\n\n/**\n * Every schema that lands in the generated JSON Schema `$defs` under a stable name (and so becomes a\n * named Pydantic model). Order is the emission order. A test asserts every exported schema of\n * src/schema/* is either listed here or is a documented alias of a listed one.\n * Registered into a PRIVATE zod registry by scripts/generate.ts — never `.meta()`/`.describe()`,\n * which write zod's process-global registry as an import side effect.\n */\nexport const NAMED_SCHEMAS = {\n ProtocolVersion,\n RequestId,\n ResourceId,\n DeviceId,\n AbsPath,\n ErrorCode,\n ErrorReason,\n FsPatchEditFailure,\n ProtocolErrorBody,\n FrameHeader,\n ClientType,\n Limits,\n OpDescriptor,\n Welcome,\n HelloMsg,\n RequestMsg,\n ResponseMsg,\n ErrorMsg,\n StreamMeta,\n StreamMsg,\n EndReason,\n EndMsg,\n CancelMsg,\n CreditMsg,\n EventMsg,\n RelayMsg,\n ClientToCoreMsg,\n CoreToClientMsg,\n OsPermissionName,\n SysinfoGetParams,\n SysinfoGetResult,\n FsKind,\n FsEntry,\n FsListParams,\n FsListResult,\n FsStatParams,\n FsEncoding,\n FsReadParams,\n FsReadResult,\n FsReadStreamParams,\n FsReadStreamResult,\n FsWriteParams,\n FsWriteResult,\n FsMkdirParams,\n FsMkdirResult,\n FsMoveParams,\n FsMoveResult,\n FsDeleteParams,\n FsDeleteResult,\n FsWatchParams,\n FsWatchResult,\n FsPatchEditApplied,\n FsPatchParams,\n FsPatchResult,\n FsSearchPathsParams,\n FsSearchPathsResult,\n FsSearchContentParams,\n FsSearchContentResult,\n FsChange,\n FsChangedEvent,\n Signal,\n ExecPtyStartParams,\n PtyInfo,\n ExecPtyWriteParams,\n ExecPtyWriteResult,\n ExecPtyResizeParams,\n ExecPtyResizeResult,\n ExecPtySignalParams,\n ExecPtySignalResult,\n ExecPtyKillParams,\n ExecPtyKillResult,\n ExecListParams,\n ExecListResult,\n ExecRunParams,\n ExecRunResult,\n ExecExitedEvent,\n ExecTitleEvent,\n ExecCwdEvent,\n SessionAttachParams,\n ResourceInfo,\n SessionDetachParams,\n SessionDetachResult,\n SessionReleaseParams,\n SessionReleaseResult,\n SessionListParams,\n SessionListResult,\n SessionControlChangedEvent,\n TranscriptionModelId,\n MlRuntimeState,\n MlInstallPhase,\n MlInstallProgress,\n TranscriptionModelInfo,\n TranscriptSegment,\n MlStatusParams,\n MlStatusResult,\n ModelsInstallParams,\n ModelsInstallResult,\n ModelsTranscribeParams,\n ModelsTranscribeResult,\n MlProgress,\n MlServiceState,\n MlServiceStatus,\n ModelsStatusParams,\n ModelsStatusResult,\n ModelsProgressEvent,\n CodingServiceCredentials,\n CodingHistoryBlocked,\n CodingHistoryFailure,\n CodingHistoryRun,\n CodingHistoryStep,\n CodingPlanMissingParams,\n CodingImportNextParams,\n CodingServiceProgress,\n CodingHistoryImportMissingParams,\n CodingHistoryImportMissingResult,\n CodingHistoryProgressEvent,\n ServiceName,\n ContractHash,\n ServiceToken,\n ServiceHello,\n ServiceWelcome,\n ServiceRequest,\n ServiceResponse,\n ServiceErrorMsg,\n ServiceProgressMsg,\n ServiceCancel,\n ServicePing,\n ServicePong,\n ServiceShutdown,\n CoreToServiceMsg,\n ServiceToCoreMsg,\n RelayDeviceStatusEvent,\n RelayAuthExpiringEvent,\n RelayCallRequest,\n RelayCallResponse,\n RelayCallHello,\n RelayCallEnvelope,\n RelayHopEnvelopeHeader,\n RelayHopConnectionEnd,\n CloseCodeValue,\n ProcSort,\n ProcListParams,\n ProcInfo,\n ProcListResult,\n ProcPortsParams,\n ProcPort,\n ProcPortsResult,\n ProcKillParams,\n ProcKillResult,\n ClipboardReadParams,\n ClipboardReadResult,\n ClipboardWriteParams,\n ClipboardWriteResult,\n SystemOpenUrlParams,\n SystemOpenUrlResult,\n SystemOpenPathParams,\n SystemOpenPathResult,\n SystemNotifyParams,\n SystemNotifyResult,\n ScreenDisplay,\n ScreenListParams,\n ScreenListResult,\n ScreenCaptureParams,\n ScreenCaptureResult,\n WindowInfo,\n WindowListParams,\n WindowListResult,\n WindowFocusParams,\n WindowFocusResult,\n WindowMoveParams,\n WindowMoveResult,\n WindowMinimizeParams,\n WindowMinimizeResult,\n InputKey,\n InputPoint,\n InputTypeTextParams,\n InputTypeTextResult,\n InputHotkeyParams,\n InputHotkeyResult,\n InputMouseMoveParams,\n InputMouseMoveResult,\n InputMouseClickParams,\n InputMouseClickResult,\n PowerStatusParams,\n PowerStatusResult,\n PowerPreventSleepParams,\n PowerPreventSleepResult,\n ResourcesDisk,\n ResourcesSnapshotParams,\n ResourcesSnapshotResult,\n AudioDevice,\n AudioDevicesParams,\n AudioDevicesResult,\n AudioRecordParams,\n AudioRecordResult,\n AudioPlayParams,\n AudioPlayResult,\n FsWatchId,\n FsWatchStartParams,\n FsWatchStartResult,\n FsWatchEventsParams,\n FsWatchEventsResult,\n FsWatchStopParams,\n FsWatchStopResult,\n ExecJobId,\n ExecJobStartParams,\n ExecJobStartResult,\n ExecJobOutputParams,\n ExecJobOutputResult,\n ExecJobStopParams,\n ExecJobStopResult,\n ExecJobInfo,\n ExecJobListParams,\n ExecJobListResult,\n ToolLevel,\n ToolOutcome,\n ToolPlatform,\n ToolTransport,\n ToolName,\n ToolLevelResult,\n ToolResultsFile,\n AppKey,\n AppProfileId,\n AppProfileLocator,\n AppSupport,\n AppFeatureStatus,\n AppInfo,\n AppUsageReading,\n AppProfile,\n AppsListParams,\n AppsListResult,\n AppsProfilesListParams,\n AppsProfilesListResult,\n AppsProfilesSaveParams,\n AppsProfilesRemoveParams,\n AppsProfilesRemoveResult,\n AppsOpenParams,\n AppsOpenResult,\n} as const satisfies Record<string, z.ZodType>;\n\nexport type NamedSchemaId = keyof typeof NAMED_SCHEMAS;\n","/**\n * Wire a client's wake() to the browser events that mean \"the person is back\": the page becomes\n * visible again (iOS Safari suspends a background tab's sockets), a back/forward-cache restore\n * (`pageshow` with persisted), and the network returning (`online`). Framework-free; the React\n * binding is `useDesktopWake` in `./react`.\n */\nimport type { DesktopClient, WakeOptions } from \"./types\";\n\n/** The subset of window/document the binding listens on — injectable for tests and non-DOM hosts. */\nexport interface WakeTargets {\n window: Pick<Window, \"addEventListener\" | \"removeEventListener\">;\n document: Pick<Document, \"addEventListener\" | \"removeEventListener\" | \"visibilityState\">;\n}\n\nexport function bindDesktopWake(client: Pick<DesktopClient, \"wake\">, options: WakeOptions & { targets?: WakeTargets } = {}): () => void {\n const targets: WakeTargets | null =\n options.targets ?? (typeof window !== \"undefined\" && typeof document !== \"undefined\" ? { window, document } : null);\n if (!targets) return () => undefined;\n const wakeOptions: WakeOptions = options.probeMs === undefined ? {} : { probeMs: options.probeMs };\n const onVisibility = () => {\n if (targets.document.visibilityState === \"visible\") client.wake(wakeOptions);\n };\n const onWake = () => client.wake(wakeOptions);\n targets.document.addEventListener(\"visibilitychange\", onVisibility);\n targets.window.addEventListener(\"pageshow\", onWake);\n targets.window.addEventListener(\"online\", onWake);\n targets.window.addEventListener(\"focus\", onWake);\n return () => {\n targets.document.removeEventListener(\"visibilitychange\", onVisibility);\n targets.window.removeEventListener(\"pageshow\", onWake);\n targets.window.removeEventListener(\"online\", onWake);\n targets.window.removeEventListener(\"focus\", onWake);\n };\n}\n","import { DesktopProtocolError } from \"../error\";\nimport type { MlProgress, ModelsTranscribeResult, TranscriptionModelId } from \"../schema/models\";\nimport type { DesktopClient } from \"./types\";\n\n/** fs.write carries at most 4 MiB of bytes (base64 in one message). */\nexport const DESKTOP_TRANSCRIBE_MAX_BYTES = 4 * 1024 * 1024;\n\nexport interface DesktopTranscriberOptions {\n /** Whisper size; omitted = the device's default. */\n model?: TranscriptionModelId;\n /** ISO 639-1; omitted = detect. */\n language?: string;\n /** Per call (first use installs the runtime and a model): default 15 minutes. */\n timeoutMs?: number;\n /** Progress for each call (install steps, then each segment as it is recognised). */\n onProgress?: (progress: MlProgress) => void;\n}\n\n/** What a transcription returns: the shape `@ai-matrx/browser-audio`'s TranscriptionTransport expects. */\nexport interface DesktopTranscript {\n text: string;\n language: string;\n duration: number;\n segments: Array<{ start: number; end: number; text: string }>;\n result: ModelsTranscribeResult;\n}\n\nexport interface DesktopTranscriber {\n /** Transcribe recorded audio on the device: written to its temp folder, transcribed, removed. */\n transcribe(file: Blob, signal?: AbortSignal): Promise<DesktopTranscript>;\n}\n\nconst EXT: Record<string, string> = {\n \"audio/webm\": \"webm\",\n \"audio/ogg\": \"ogg\",\n \"audio/mp4\": \"m4a\",\n \"audio/mpeg\": \"mp3\",\n \"audio/wav\": \"wav\",\n \"audio/x-wav\": \"wav\",\n \"video/webm\": \"webm\",\n \"video/mp4\": \"mp4\",\n};\n\nfunction base64(bytes: Uint8Array): string {\n let binary = \"\";\n for (let i = 0; i < bytes.length; i += 0x8000) binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000));\n return btoa(binary);\n}\n\n/**\n * Speech to text on the person's own computer, from any surface connected to it (the app's\n * screen, the web app or the phone through the relay). Structurally a\n * `@ai-matrx/browser-audio` TranscriptionTransport, so every voice input on the platform can\n * transcribe locally: `new BrowserAudioKernel({ transport: createDesktopTranscriber(client) })`.\n *\n * Audio travels as one `fs.write` into the device's temp folder (at most 4 MiB; longer\n * recordings are chunked by the kernel), then `models.transcribe`, then `fs.delete` — every step\n * an ordinary op, so this works through every transport with no special path.\n */\nexport function createDesktopTranscriber(client: DesktopClient, options: DesktopTranscriberOptions = {}): DesktopTranscriber {\n let temp: Promise<string> | null = null;\n const tempDir = () => (temp ??= client.request(\"sysinfo.get\", {}).then((s) => s.paths.temp.replace(/\\/$/, \"\")));\n\n return {\n async transcribe(file, signal) {\n if (file.size > DESKTOP_TRANSCRIBE_MAX_BYTES) {\n throw new DesktopProtocolError(\"PAYLOAD_TOO_LARGE\", \"Recording is larger than 4 MB\", { retryable: false, data: { limit_bytes: DESKTOP_TRANSCRIBE_MAX_BYTES } });\n }\n const type = file.type.split(\";\")[0]?.trim() ?? \"\";\n const name = `matrx-transcribe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}.${EXT[type] ?? \"webm\"}`;\n const path = `${await tempDir()}/${name}`;\n const bytes = new Uint8Array(await file.arrayBuffer());\n await client.request(\"fs.write\", { path, content: base64(bytes), encoding: \"base64\", mode: 0o600 }, signal ? { signal } : {});\n let requestId = \"\";\n const off = options.onProgress\n ? client.on(\"models.progress\", (payload) => {\n if (payload.request_id === requestId) options.onProgress?.(payload.progress);\n })\n : () => undefined;\n try {\n const result = await client.request(\n \"models.transcribe\",\n { path, ...(options.model ? { model: options.model } : {}), ...(options.language ? { language: options.language } : {}) },\n { timeoutMs: options.timeoutMs ?? 15 * 60_000, onRequestId: (id) => (requestId = id), ...(signal ? { signal } : {}) },\n );\n return {\n text: result.text,\n language: result.language,\n duration: result.duration_s,\n segments: result.segments.map((s) => ({ start: s.start_s, end: s.end_s, text: s.text })),\n result,\n };\n } finally {\n off();\n void client.request(\"fs.delete\", { path, to_trash: false }).catch(() => undefined);\n }\n },\n };\n}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AE,WAAW,QAAQ,aAAa,KAAK,KAAQ,aAAa,CAAC,OAAQ,YAAY,IAAK,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC,EAAG;AAAA,QACtH;AACA,eAAO;AAAA,UACL,MAAM,OAAO;AAAA,UACb,UAAU,OAAO;AAAA,UACjB,UAAU,OAAO;AAAA,UACjB,UAAU,OAAO,SAAS,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,KAAK,EAAE,OAAO,MAAM,EAAE,KAAK,EAAE;AAAA,UACvF;AAAA,QACF;AAAA,MACF,UAAE;AACA,YAAI;AACJ,aAAK,OAAO,QAAQ,aAAa,EAAE,MAAM,UAAU,MAAM,CAAC,EAAE,MAAM,MAAM,MAAS;AAAA,MACnF;AAAA,IACF;AAAA,EACF;AACF;","names":["import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod"]}