@ai-matrx/desktop-protocol 0.5.0 → 0.7.0

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/index.ts","../src/schema/primitives.ts","../src/schema/errors.ts","../src/schema/frame.ts","../src/error.ts","../src/frame.ts","../src/schema/envelope.ts","../src/schema/sysinfo.ts","../src/schema/fs.ts","../src/schema/exec.ts","../src/schema/session.ts","../src/schema/relay.ts","../src/schema/registry.ts","../src/versioning.ts"],"sourcesContent":["/**\n * `@ai-matrx/desktop-protocol` — the one wire contract between Matrx 2 (the desktop core) and every\n * client (phone, web app, extension, server). SPEC P11: this zod source is THE source; the JSON\n * Schema in generated/ and the Pydantic models in aidream/_generated/desktop_protocol.py are\n * generated from it and CI fails on any drift (`pnpm generate --check`).\n *\n * Entries: `.` (schemas, OPS, EVENTS, error codes) · `./frame` (binary frame codec, zod-free)\n * · `./client` (reconnecting request/stream/credit/reattach client) · `./react` (hooks).\n */\nexport * from \"./schema/primitives\";\nexport * from \"./schema/errors\";\nexport * from \"./schema/frame\";\nexport * from \"./schema/envelope\";\nexport * from \"./schema/sysinfo\";\nexport * from \"./schema/fs\";\nexport * from \"./schema/exec\";\nexport * from \"./schema/session\";\nexport * from \"./schema/relay\";\nexport * from \"./schema/registry\";\nexport * from \"./versioning\";\nexport {\n FRAME_HEADER_BYTES,\n FRAME_STRUCT_FORMAT,\n FRAME_VERSION,\n FrameChannel,\n FrameFlag,\n decodeFrame,\n encodeFrame,\n stampCid,\n readCid,\n hasFlag,\n assertFrameHeader,\n BROADCAST_CID,\n connectionEndFrame,\n isConnectionEnd,\n} from \"./frame\";\nexport type { DecodedFrame, FrameChannelValue } from \"./frame\";\nexport { DesktopProtocolError, isDesktopProtocolError } from \"./error\";\nexport type { ErrorCodeName, ErrorData, ErrorReasonName } from \"./types\";\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 */\nexport const PROTOCOL_MINOR = 1 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","/** @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 ]);\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 — 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","/**\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 /** 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 — 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","/** @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 since_ms: epochMs,\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","/** @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 RelayAuthExpiringEvent,\n RelayCallRequest,\n RelayCallResponse,\n RelayDeviceStatusEvent,\n RelayCallHello,\n RelayCallEnvelope,\n} from \"./relay\";\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\";\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} 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 \"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 * 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 RelayDeviceStatusEvent,\n RelayAuthExpiringEvent,\n RelayCallRequest,\n RelayCallResponse,\n RelayCallHello,\n RelayCallEnvelope,\n RelayHopEnvelopeHeader,\n RelayHopConnectionEnd,\n CloseCodeValue,\n} as const satisfies Record<string, z.ZodType>;\n\nexport type NamedSchemaId = keyof typeof NAMED_SCHEMAS;\n","/**\n * Version skew is the normal state: a phone, the server and a desktop app in the field run\n * different package versions, and a minor protocol bump must never make any of them fail.\n *\n * THE RULE (enforced by src/versioning.test.ts against generated/baseline-1.0.json):\n * 1. Within a major, a minor may only ADD. A field added after x.0 is OPTIONAL in the schema\n * (an older peer omits it) and is listed in FIELDS_SINCE with the minor that added it.\n * 2. A writer never sends a field newer than the version its peer negotiated (hello/welcome, or\n * the /call version header): older peers' strict schemas refuse unknown keys. `forPeer`\n * does the stripping; the core's Router applies it to every result and error it sends.\n * 3. A reader that needs a newer field checks the peer's version and says so loudly when the\n * peer is older (e.g. aidream's local_proxy marks a patch answer from a 1.0 app).\n */\nimport type { OpName } from \"./schema/registry\";\nimport { PROTOCOL_MAJOR, PROTOCOL_MINOR } from \"./schema/primitives\";\n\n/**\n * Fields added after x.0, by schema location: a named schema (`FsPatchResult`), a property path\n * inside one (`ProtocolErrorBody.data`), or a union branch (`RelayCallResponse|0`).\n */\nexport const FIELDS_SINCE = {\n FsPatchResult: { edits_applied: \"1.1\", edits_failed: \"1.1\" },\n \"ProtocolErrorBody.data\": { edits_failed: \"1.1\" },\n \"RelayCallResponse|0\": { protocol_version: \"1.1\" },\n \"RelayCallResponse|1\": { protocol_version: \"1.1\" },\n} as const satisfies Record<string, Record<string, `${number}.${number}`>>;\n\nexport type FieldsSincePath = keyof typeof FIELDS_SINCE;\n\n/** \"1.10\" > \"1.9\". Same-major comparison of \"major.minor\" strings. */\nexport function compareVersions(a: string, b: string): number {\n const [am = 0, an = 0] = a.split(\".\").map(Number);\n const [bm = 0, bn = 0] = b.split(\".\").map(Number);\n return am - bm || an - bn;\n}\n\n/** True when a peer at `version` knows a field added in `since`. */\nexport function knows(version: string, since: string): boolean {\n return compareVersions(version, since) >= 0;\n}\n\n/** The version two peers speak: the lower minor within this major. */\nexport function negotiate(peerVersion: string): string {\n const [major = 0, minor = 0] = peerVersion.split(\".\").map(Number);\n if (major !== PROTOCOL_MAJOR) return `${PROTOCOL_MAJOR}.0`;\n return `${PROTOCOL_MAJOR}.${Math.min(minor, PROTOCOL_MINOR)}`;\n}\n\nfunction strip(value: unknown, fields: Record<string, string> | undefined, version: string): unknown {\n if (!fields || value === null || typeof value !== \"object\" || Array.isArray(value)) return value;\n let out: Record<string, unknown> | null = null;\n for (const [field, since] of Object.entries(fields)) {\n if (field in (value as object) && !knows(version, since)) {\n out ??= { ...(value as Record<string, unknown>) };\n delete out[field];\n }\n }\n return out ?? value;\n}\n\nconst RESULT_PATH = new Map<OpName, FieldsSincePath>([[\"fs.patch\", \"FsPatchResult\"]]);\n\n/**\n * What to send a peer that negotiated `version`: `result` of `op`, or an error body, with every\n * field newer than that version removed (rule 2). Unchanged for a current peer.\n */\nexport function forPeer(op: OpName, part: \"result\", value: unknown, version: string): unknown;\nexport function forPeer(op: OpName | null, part: \"error\", value: unknown, version: string): unknown;\nexport function forPeer(op: OpName | null, part: \"result\" | \"error\", value: unknown, version: string): unknown {\n if (part === \"result\") {\n const path = op ? RESULT_PATH.get(op) : undefined;\n return path ? strip(value, FIELDS_SINCE[path], version) : value;\n }\n if (value === null || typeof value !== \"object\") return value;\n const body = value as { data?: unknown };\n if (body.data === undefined) return value;\n const data = strip(body.data, FIELDS_SINCE[\"ProtocolErrorBody.data\"], version);\n return data === body.data ? value : { ...body, data };\n}\n\n/** Every op whose result has a versioned field is wired into forPeer (checked by the test). */\nexport const VERSIONED_RESULT_OPS: readonly OpName[] = [...RESULT_PATH.keys()];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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UAAU,SAAU,QAAO;AACxD,QAAM,OAAO;AACb,MAAI,KAAK,SAAS,OAAW,QAAO;AACpC,QAAM,OAAO,MAAM,KAAK,MAAM,aAAa,wBAAwB,GAAG,OAAO;AAC7E,SAAO,SAAS,KAAK,OAAO,QAAQ,EAAE,GAAG,MAAM,KAAK;AACtD;AAGO,IAAM,uBAA0C,CAAC,GAAG,YAAY,KAAK,CAAC;","names":["import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/schema/primitives.ts","../src/schema/errors.ts","../src/schema/frame.ts","../src/error.ts","../src/frame.ts","../src/schema/envelope.ts","../src/schema/sysinfo.ts","../src/schema/fs.ts","../src/schema/exec.ts","../src/schema/session.ts","../src/schema/relay.ts","../src/schema/registry.ts","../src/versioning.ts","../src/close-policy.ts"],"sourcesContent":["/**\n * `@ai-matrx/desktop-protocol` — the one wire contract between Matrx 2 (the desktop core) and every\n * client (phone, web app, extension, server). SPEC P11: this zod source is THE source; the JSON\n * Schema in generated/ and the Pydantic models in aidream/_generated/desktop_protocol.py are\n * generated from it and CI fails on any drift (`pnpm generate --check`).\n *\n * Entries: `.` (schemas, OPS, EVENTS, error codes) · `./frame` (binary frame codec, zod-free)\n * · `./client` (reconnecting request/stream/credit/reattach client) · `./react` (hooks).\n */\nexport * from \"./schema/primitives\";\nexport * from \"./schema/errors\";\nexport * from \"./schema/frame\";\nexport * from \"./schema/envelope\";\nexport * from \"./schema/sysinfo\";\nexport * from \"./schema/fs\";\nexport * from \"./schema/exec\";\nexport * from \"./schema/session\";\nexport * from \"./schema/relay\";\nexport * from \"./schema/registry\";\nexport * from \"./versioning\";\nexport * from \"./close-policy\";\nexport {\n FRAME_HEADER_BYTES,\n FRAME_STRUCT_FORMAT,\n FRAME_VERSION,\n FrameChannel,\n FrameFlag,\n decodeFrame,\n encodeFrame,\n stampCid,\n readCid,\n hasFlag,\n assertFrameHeader,\n BROADCAST_CID,\n connectionEndFrame,\n isConnectionEnd,\n} from \"./frame\";\nexport type { DecodedFrame, FrameChannelValue } from \"./frame\";\nexport { DesktopProtocolError, isDesktopProtocolError } from \"./error\";\nexport type { ErrorCodeName, ErrorData, ErrorReasonName } from \"./types\";\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 */\nexport const PROTOCOL_MINOR = 1 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","/** @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 ]);\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 — 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","/**\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 /** 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 — 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","/** @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","/** @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 RelayAuthExpiringEvent,\n RelayCallRequest,\n RelayCallResponse,\n RelayDeviceStatusEvent,\n RelayCallHello,\n RelayCallEnvelope,\n} from \"./relay\";\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\";\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} 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 \"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 * 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 RelayDeviceStatusEvent,\n RelayAuthExpiringEvent,\n RelayCallRequest,\n RelayCallResponse,\n RelayCallHello,\n RelayCallEnvelope,\n RelayHopEnvelopeHeader,\n RelayHopConnectionEnd,\n CloseCodeValue,\n} as const satisfies Record<string, z.ZodType>;\n\nexport type NamedSchemaId = keyof typeof NAMED_SCHEMAS;\n","/**\n * Version skew is the normal state: a phone, the server and a desktop app in the field run\n * different package versions, and a minor protocol bump must never make any of them fail.\n *\n * THE RULE (enforced by src/versioning.test.ts against generated/baseline-1.0.json):\n * 1. Within a major, a minor may only ADD. A field added after x.0 is OPTIONAL in the schema\n * (an older peer omits it) and is listed in FIELDS_SINCE with the minor that added it.\n * 2. A writer never sends a field newer than the version its peer negotiated (hello/welcome, or\n * the /call version header): older peers' strict schemas refuse unknown keys. `forPeer`\n * does the stripping; the core's Router applies it to every result and error it sends.\n * 3. A reader that needs a newer field checks the peer's version and says so loudly when the\n * peer is older (e.g. aidream's local_proxy marks a patch answer from a 1.0 app).\n */\nimport type { OpName } from \"./schema/registry\";\nimport { PROTOCOL_MAJOR, PROTOCOL_MINOR } from \"./schema/primitives\";\n\n/**\n * Fields added after x.0, by schema location: a named schema (`FsPatchResult`), a property path\n * inside one (`ProtocolErrorBody.data`), or a union branch (`RelayCallResponse|0`).\n */\nexport const FIELDS_SINCE = {\n FsPatchResult: { edits_applied: \"1.1\", edits_failed: \"1.1\" },\n \"ProtocolErrorBody.data\": { edits_failed: \"1.1\" },\n \"RelayCallResponse|0\": { protocol_version: \"1.1\" },\n \"RelayCallResponse|1\": { protocol_version: \"1.1\" },\n} as const satisfies Record<string, Record<string, `${number}.${number}`>>;\n\nexport type FieldsSincePath = keyof typeof FIELDS_SINCE;\n\n/**\n * 1.0 fields that a later minor lets be null, and what a peer older than that minor is sent\n * instead (the value that meant the same thing before). Widening a field any other way is a major.\n */\nexport const NULL_SINCE = {\n \"RelayDeviceStatusEvent.since_ms\": { since: \"1.1\", olderPeersGet: 0 },\n} as const satisfies Record<string, { since: `${number}.${number}`; olderPeersGet: unknown }>;\n\n/** A device status for a reader at `version`: `since_ms` null (\"never\") becomes 0 before 1.1. */\nexport function statusForPeer<T extends { since_ms: number | null }>(status: T, version: string): T {\n const rule = NULL_SINCE[\"RelayDeviceStatusEvent.since_ms\"];\n return status.since_ms === null && !knows(version, rule.since) ? { ...status, since_ms: rule.olderPeersGet } : status;\n}\n\n/**\n * A WebSocket client announces the newest minor it reads at connect time by also offering\n * `matrx.v<major>.<minor>` beside SUBPROTOCOL (servers still answer SUBPROTOCOL). Before hello is\n * possible, this is how the relay picks the right shape for its greeting.\n */\nexport function versionSubprotocol(version: string): string {\n return `matrx.v${version}`;\n}\n\n/** The version a client announced in its offered subprotocols; \"1.0\" when it did not. */\nexport function announcedVersion(offered: readonly string[]): string {\n let best = `${PROTOCOL_MAJOR}.0`;\n for (const p of offered) {\n const m = /^matrx\\.v(\\d+\\.\\d+)$/.exec(p.trim());\n if (m?.[1] && compareVersions(m[1], best) > 0 && m[1].startsWith(`${PROTOCOL_MAJOR}.`)) best = m[1];\n }\n return best;\n}\n\n/** \"1.10\" > \"1.9\". Same-major comparison of \"major.minor\" strings. */\nexport function compareVersions(a: string, b: string): number {\n const [am = 0, an = 0] = a.split(\".\").map(Number);\n const [bm = 0, bn = 0] = b.split(\".\").map(Number);\n return am - bm || an - bn;\n}\n\n/** True when a peer at `version` knows a field added in `since`. */\nexport function knows(version: string, since: string): boolean {\n return compareVersions(version, since) >= 0;\n}\n\n/** The version two peers speak: the lower minor within this major. */\nexport function negotiate(peerVersion: string): string {\n const [major = 0, minor = 0] = peerVersion.split(\".\").map(Number);\n if (major !== PROTOCOL_MAJOR) return `${PROTOCOL_MAJOR}.0`;\n return `${PROTOCOL_MAJOR}.${Math.min(minor, PROTOCOL_MINOR)}`;\n}\n\nfunction strip(value: unknown, fields: Record<string, string> | undefined, version: string): unknown {\n if (!fields || value === null || typeof value !== \"object\" || Array.isArray(value)) return value;\n let out: Record<string, unknown> | null = null;\n for (const [field, since] of Object.entries(fields)) {\n if (field in (value as object) && !knows(version, since)) {\n out ??= { ...(value as Record<string, unknown>) };\n delete out[field];\n }\n }\n return out ?? value;\n}\n\nconst RESULT_PATH = new Map<OpName, FieldsSincePath>([[\"fs.patch\", \"FsPatchResult\"]]);\n\n/**\n * What to send a peer that negotiated `version`: `result` of `op`, or an error body, with every\n * field newer than that version removed (rule 2). Unchanged for a current peer.\n */\nexport function forPeer(op: OpName, part: \"result\", value: unknown, version: string): unknown;\nexport function forPeer(op: OpName | null, part: \"error\", value: unknown, version: string): unknown;\nexport function forPeer(op: OpName | null, part: \"result\" | \"error\", value: unknown, version: string): unknown {\n if (part === \"result\") {\n const path = op ? RESULT_PATH.get(op) : undefined;\n return path ? strip(value, FIELDS_SINCE[path], version) : value;\n }\n if (value === null || typeof value !== \"object\") return value;\n const body = value as { data?: unknown };\n if (body.data === undefined) return value;\n const data = strip(body.data, FIELDS_SINCE[\"ProtocolErrorBody.data\"], version);\n return data === body.data ? value : { ...body, data };\n}\n\n/** Every op whose result has a versioned field is wired into forPeer (checked by the test). */\nexport const VERSIONED_RESULT_OPS: readonly OpName[] = [...RESULT_PATH.keys()];\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,iBAAkB;AAMX,IAAM,iBAAiB;AAOvB,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O,CAAC,gBAAgB,0BAA0B,EAAE;AAAA,EACzH,CAAC,UAAU,cAAc,GAAG,EAAE,QAAQ,QAAQ,SAAS,aAAa,OAAO,CAAC,kBAAkB,yBAAyB,EAAE;AAAA,EACzH,CAAC,UAAU,gBAAgB,GAAG,EAAE,QAAQ,QAAQ,SAAS,WAAW,OAAO,CAAC,aAAa,kBAAkB,EAAE;AAAA,EAC7G,CAAC,UAAU,YAAY,GAAG,EAAE,QAAQ,UAAU,SAAS,cAAc,OAAO,CAAC,gBAAgB,iBAAiB,EAAE;AAAA,EAChH,CAAC,UAAU,QAAQ,GAAG,EAAE,QAAQ,QAAQ,SAAS,YAAY,OAAO,CAAC,YAAY,gCAAgC,EAAE;AAAA,EACnH,CAAC,UAAU,cAAc,GAAG,EAAE,QAAQ,QAAQ,SAAS,WAAW,OAAO,CAAC,uBAAuB,yBAAyB,EAAE;AAAA;AAAA,EAE5H,CAAC,UAAU,cAAc,GAAG,EAAE,QAAQ,aAAa,OAAO,CAAC,kBAAkB,+BAA+B,EAAE;AAAA,EAC9G,CAAC,UAAU,gBAAgB,GAAG,EAAE,QAAQ,QAAQ,SAAS,oBAAoB,OAAO,CAAC,gCAAgC,2BAA2B,EAAE;AACpJ;AAEA,IAAM,UAAqB,EAAE,QAAQ,aAAa,OAAO,CAAC,kBAAkB,iBAAiB,EAAE;AAGxF,SAAS,UAAU,MAA4C;AACpE,MAAI,SAAS,QAAQ,SAAS,OAAW,QAAO,YAAY,UAAU,QAAQ;AAC9E,SAAQ,YAA0C,IAAI,KAAK;AAC7D;AAGO,SAAS,gBAAgB,MAA0C;AACxE,SAAO,UAAU,IAAI,EAAE,WAAW;AACpC;","names":["import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod"]}
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { O as OpName } from './registry-BeY9D7h0.cjs';
3
- export { B as BEARER_PREFIX, e as CancelMsg, f as ClientToCoreMsg, C as ClientType, g as CloseCode, h as CloseCodeValue, j as CoreToClientMsg, k as CreditMsg, D as DesktopProtocolError, d as EVENTS, l as EndMsg, E as EndReason, m as ErrorCode, n as ErrorCodeName, o as ErrorData, p as ErrorMsg, q as ErrorReason, r as ErrorReasonName, s as EventMsg, t as EventName, F as FsPatchEditFailure, H as HelloMsg, L as Limits, N as NAMED_SCHEMAS, u as NamedSchemaId, c as OPS, v as OpDescriptor, a as OpParams, b as OpResult, w as OpSpec, P as PING_TEXT, x as PONG_TEXT, y as ProtocolErrorBody, R as RelayMsg, z as RequestMsg, A as ResponseMsg, G as SUBPROTOCOL, S as StreamMeta, I as StreamMsg, W as Welcome, i as isDesktopProtocolError } from './registry-BeY9D7h0.cjs';
2
+ import { O as OpName } from './registry-Duc_VFN8.cjs';
3
+ export { B as BEARER_PREFIX, f as CLOSE_RULES, g as CancelMsg, h as ClientToCoreMsg, e as ClientType, j as CloseAction, k as CloseCode, l as CloseCodeValue, C as CloseOutcome, m as CloseRule, n as CoreToClientMsg, o as CreditMsg, D as DesktopProtocolError, d as EVENTS, p as EndMsg, E as EndReason, q as ErrorCode, r as ErrorCodeName, s as ErrorData, t as ErrorMsg, u as ErrorReason, v as ErrorReasonName, w as EventMsg, x as EventName, F as FsPatchEditFailure, H as HelloMsg, L as Limits, N as NAMED_SCHEMAS, y as NamedSchemaId, c as OPS, z as OpDescriptor, a as OpParams, b as OpResult, A as OpSpec, P as PING_TEXT, G as PONG_TEXT, I as ProtocolErrorBody, R as RelayMsg, J as RequestMsg, K as ResponseMsg, M as SUBPROTOCOL, S as StreamMeta, Q as StreamMsg, W as Welcome, T as closeRule, i as isDesktopProtocolError, U as isTerminalClose } from './registry-Duc_VFN8.cjs';
4
4
  export { BROADCAST_CID, DecodedFrame, FRAME_HEADER_BYTES, FRAME_STRUCT_FORMAT, FRAME_VERSION, FrameChannel, FrameChannelValue, FrameFlag, assertFrameHeader, connectionEndFrame, decodeFrame, encodeFrame, hasFlag, isConnectionEnd, readCid, stampCid } from './frame.cjs';
5
5
 
6
6
  /** @ai-matrx/desktop-protocol — version and primitive schemas. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */
@@ -9,7 +9,8 @@ declare const PROTOCOL_MAJOR: 1;
9
9
  /**
10
10
  * Minor history (same major = compatible; see src/versioning.ts for the rule and FIELDS_SINCE):
11
11
  * 1.0 — the first contract.
12
- * 1.1 — fs.patch per-edit results; /call reports the negotiated version.
12
+ * 1.1 — fs.patch per-edit results; /call reports the negotiated version;
13
+ * device status since_ms is null for a device that never connected.
13
14
  */
14
15
  declare const PROTOCOL_MINOR: 1;
15
16
  /** This package's version as the wire spells it ("major.minor"): hello, welcome, relay status. */
@@ -921,7 +922,7 @@ declare const RELAY_CALL_HELLO_ID: "hello";
921
922
  declare const RELAY_CALL_REQUEST_ID: "call";
922
923
  declare const RelayDeviceStatusEvent: z.ZodObject<{
923
924
  online: z.ZodBoolean;
924
- since_ms: z.ZodInt;
925
+ since_ms: z.ZodNullable<z.ZodInt>;
925
926
  app_version: z.ZodNullable<z.ZodString>;
926
927
  protocol_version: z.ZodNullable<z.ZodString>;
927
928
  }, z.core.$strict>;
@@ -1009,7 +1010,7 @@ type RelayCallResponse = z.output<typeof RelayCallResponse>;
1009
1010
  /** HTTP GET /v1/devices/{device_id}/status (owner JWT). */
1010
1011
  declare const RelayStatusResponse: z.ZodObject<{
1011
1012
  online: z.ZodBoolean;
1012
- since_ms: z.ZodInt;
1013
+ since_ms: z.ZodNullable<z.ZodInt>;
1013
1014
  app_version: z.ZodNullable<z.ZodString>;
1014
1015
  protocol_version: z.ZodNullable<z.ZodString>;
1015
1016
  }, z.core.$strict>;
@@ -1065,6 +1066,28 @@ declare const FIELDS_SINCE: {
1065
1066
  };
1066
1067
  };
1067
1068
  type FieldsSincePath = keyof typeof FIELDS_SINCE;
1069
+ /**
1070
+ * 1.0 fields that a later minor lets be null, and what a peer older than that minor is sent
1071
+ * instead (the value that meant the same thing before). Widening a field any other way is a major.
1072
+ */
1073
+ declare const NULL_SINCE: {
1074
+ readonly "RelayDeviceStatusEvent.since_ms": {
1075
+ readonly since: "1.1";
1076
+ readonly olderPeersGet: 0;
1077
+ };
1078
+ };
1079
+ /** A device status for a reader at `version`: `since_ms` null ("never") becomes 0 before 1.1. */
1080
+ declare function statusForPeer<T extends {
1081
+ since_ms: number | null;
1082
+ }>(status: T, version: string): T;
1083
+ /**
1084
+ * A WebSocket client announces the newest minor it reads at connect time by also offering
1085
+ * `matrx.v<major>.<minor>` beside SUBPROTOCOL (servers still answer SUBPROTOCOL). Before hello is
1086
+ * possible, this is how the relay picks the right shape for its greeting.
1087
+ */
1088
+ declare function versionSubprotocol(version: string): string;
1089
+ /** The version a client announced in its offered subprotocols; "1.0" when it did not. */
1090
+ declare function announcedVersion(offered: readonly string[]): string;
1068
1091
  /** "1.10" > "1.9". Same-major comparison of "major.minor" strings. */
1069
1092
  declare function compareVersions(a: string, b: string): number;
1070
1093
  /** True when a peer at `version` knows a field added in `since`. */
@@ -1080,4 +1103,4 @@ declare function forPeer(op: OpName | null, part: "error", value: unknown, versi
1080
1103
  /** Every op whose result has a versioned field is wired into forPeer (checked by the test). */
1081
1104
  declare const VERSIONED_RESULT_OPS: readonly OpName[];
1082
1105
 
1083
- export { AbsPath, DEFAULT_MAX_FRAME_PAYLOAD_BYTES, DEFAULT_MAX_MESSAGE_BYTES, DEFAULT_WINDOW_BYTES, DeviceId, ExecCwdEvent, ExecExitedEvent, ExecListParams, ExecListResult, ExecPtyKillParams, ExecPtyKillResult, ExecPtyResizeParams, ExecPtyResizeResult, ExecPtySignalParams, ExecPtySignalResult, ExecPtyStartParams, ExecPtyStartResult, ExecPtyWriteParams, ExecPtyWriteResult, ExecRunParams, ExecRunResult, ExecTitleEvent, FIELDS_SINCE, type FieldsSincePath, FrameHeader, FsChange, FsChangedEvent, FsDeleteParams, FsDeleteResult, FsEncoding, FsEntry, FsKind, FsListParams, FsListResult, FsMkdirParams, FsMkdirResult, FsMoveParams, FsMoveResult, FsPatchEditApplied, FsPatchParams, FsPatchResult, FsReadParams, FsReadResult, FsReadStreamParams, FsReadStreamResult, FsSearchContentParams, FsSearchContentResult, FsSearchPathsParams, FsSearchPathsResult, FsStatParams, FsStatResult, FsWatchParams, FsWatchResult, FsWriteParams, FsWriteResult, OpName, OsPermissionName, PROTOCOL_MAJOR, PROTOCOL_MINOR, PROTOCOL_VERSION, ProtocolVersion, PtyInfo, RELAY_CALL_HELLO_ID, RELAY_CALL_REQUEST_ID, RELAY_CALL_VERSION_HEADER, RelayAuthExpiringEvent, RelayCallEnvelope, RelayCallHello, RelayCallRequest, RelayCallResponse, RelayDeviceStatusEvent, RelayHopConnectionEnd, RelayHopEnvelopeHeader, RelayStatusResponse, RequestId, ResourceId, ResourceInfo, SessionAttachParams, SessionAttachResult, SessionControlChangedEvent, SessionDetachParams, SessionDetachResult, SessionListParams, SessionListResult, SessionReleaseParams, SessionReleaseResult, Signal, SysinfoGetParams, SysinfoGetResult, VERSIONED_RESULT_OPS, compareVersions, epochMs, forPeer, knows, negotiate, nonNegInt, u32 };
1106
+ export { AbsPath, DEFAULT_MAX_FRAME_PAYLOAD_BYTES, DEFAULT_MAX_MESSAGE_BYTES, DEFAULT_WINDOW_BYTES, DeviceId, ExecCwdEvent, ExecExitedEvent, ExecListParams, ExecListResult, ExecPtyKillParams, ExecPtyKillResult, ExecPtyResizeParams, ExecPtyResizeResult, ExecPtySignalParams, ExecPtySignalResult, ExecPtyStartParams, ExecPtyStartResult, ExecPtyWriteParams, ExecPtyWriteResult, ExecRunParams, ExecRunResult, ExecTitleEvent, FIELDS_SINCE, type FieldsSincePath, FrameHeader, FsChange, FsChangedEvent, FsDeleteParams, FsDeleteResult, FsEncoding, FsEntry, FsKind, FsListParams, FsListResult, FsMkdirParams, FsMkdirResult, FsMoveParams, FsMoveResult, FsPatchEditApplied, FsPatchParams, FsPatchResult, FsReadParams, FsReadResult, FsReadStreamParams, FsReadStreamResult, FsSearchContentParams, FsSearchContentResult, FsSearchPathsParams, FsSearchPathsResult, FsStatParams, FsStatResult, FsWatchParams, FsWatchResult, FsWriteParams, FsWriteResult, NULL_SINCE, OpName, OsPermissionName, PROTOCOL_MAJOR, PROTOCOL_MINOR, PROTOCOL_VERSION, ProtocolVersion, PtyInfo, RELAY_CALL_HELLO_ID, RELAY_CALL_REQUEST_ID, RELAY_CALL_VERSION_HEADER, RelayAuthExpiringEvent, RelayCallEnvelope, RelayCallHello, RelayCallRequest, RelayCallResponse, RelayDeviceStatusEvent, RelayHopConnectionEnd, RelayHopEnvelopeHeader, RelayStatusResponse, RequestId, ResourceId, ResourceInfo, SessionAttachParams, SessionAttachResult, SessionControlChangedEvent, SessionDetachParams, SessionDetachResult, SessionListParams, SessionListResult, SessionReleaseParams, SessionReleaseResult, Signal, SysinfoGetParams, SysinfoGetResult, VERSIONED_RESULT_OPS, announcedVersion, compareVersions, epochMs, forPeer, knows, negotiate, nonNegInt, statusForPeer, u32, versionSubprotocol };