/** * Unified MIK Protocol — TLV-framed messaging between CLI and device. * * Frame format: [type: u8][length: u32le][payload: bytes] (5-byte header) * * Replaces the previous separate REPL, deploy, and config protocols with * a single framing scheme. On connect the CLI sends CMD_HELLO; the device * replies with MSG_READY containing its identity. The device never sends * MSG_READY unprompted, which keeps the wire silent for passive viewers * (e.g. idf.py monitor). */ export declare const CTRL_R = 18; export declare const MSG_READY = 1; export declare const MSG_LOG = 2; export declare const MSG_WARN = 3; export declare const MSG_ERROR = 4; export declare const MSG_RESULT = 5; export declare const MSG_INFO = 6; export declare const MSG_COMPLETIONS = 7; export declare const MSG_EVAL_ERROR = 8; export declare const MSG_PROMPT = 9; export declare const MSG_TEST = 11; export declare const MSG_DEBUG = 12; /** Emitted once after the last test file's run_done when the device drove * a supervisor-mode manifest. Signals "no more tests coming" to the CLI. */ export declare const MSG_MANIFEST_DONE = 13; export declare const MSG_OK = 128; export declare const MSG_ERR = 129; export declare const MSG_CHECKSUM_RESULT = 130; export declare const MSG_CONFIG_ENTRIES = 131; /** Chunk of file bytes streamed in response to CMD_FS_GET. Repeated * zero-or-more times before a terminal MSG_OK. */ export declare const MSG_FS_CHUNK = 132; export declare const CMD_EVAL = 16; export declare const CMD_COMPLETE = 17; export declare const CMD_DIRECTIVE = 19; export declare const CMD_EXIT = 20; export declare const CMD_HELLO = 21; /** Begins a streaming file PUT. Payload: u16le name_len | name | u32le total_size. * Device opens the staged file and replies OK; body arrives in one or more * CMD_DEPLOY_PUT_CHUNK frames so no single TLV frame ever exceeds the USJ * RX ring. */ export declare const CMD_DEPLOY_PUT = 32; export declare const CMD_DEPLOY_DONE = 33; export declare const CMD_DEPLOY_ABORT = 34; export declare const CMD_DEPLOY_ERASE = 35; /** Appends body bytes to the file opened by the preceding CMD_DEPLOY_PUT. * Payload is raw file data; device fwrites + replies OK per chunk and * closes the file when total_remaining reaches zero. */ export declare const CMD_DEPLOY_PUT_CHUNK = 36; export declare const CMD_DEPLOY_KEEP = 38; export declare const CMD_DEPLOY_CHECKSUM = 39; export declare const CMD_RESTART = 40; export declare const CMD_RUNTIME_PAUSE = 41; export declare const CMD_RUNTIME_RESUME = 42; /** Pull a file off the device. Payload: u16le path_len | path. * Device streams MSG_FS_CHUNK frames followed by a terminating MSG_OK, * or MSG_ERR on failure. */ export declare const CMD_FS_GET = 43; /** Clear the on-device log files (log.txt + log.txt.1). No payload. * Device suspends the logger, deletes both files, reopens a fresh * log.txt, and replies MSG_OK. No-op (still OK) when file logging is * disabled. */ export declare const CMD_LOG_RESET = 44; export declare const CMD_CONFIG_LIST = 64; export declare const CMD_CONFIG_SET = 65; export declare const CMD_CONFIG_DELETE = 66; /** Env entry flags */ export declare const ENV_FLAG_SECRET = 1; /** Header size: 1 byte type + 4 bytes u32le length */ export declare const HEADER_SIZE = 5; /** Sane ceiling on frame payload size. The wire format allows up to 4 GB, but * any MIK frame the CLI receives in practice is at most a few KB. This guards * against false-positive frame starts when the byte stream contains raw * boot-log text that happens to coincide with a valid message-type byte — * e.g. the banner's trailing `\r\n` is `0d 0a`, and `0x0d` (MSG_MANIFEST_DONE) * would otherwise have the parser read `0a 31 38 36` ("\n186") as a * ~907 MB length and stall forever waiting for the payload. */ export declare const MAX_FRAME_PAYLOAD: number; export interface Frame { type: number; payload: Buffer; } /** Build a TLV frame: [type: u8][length: u32le][payload] */ export declare function buildFrame(type: number, payload?: string | Buffer): Buffer; /** Parse a single TLV frame from a buffer at the given offset. * Returns null if the buffer doesn't contain a complete frame. */ export declare function parseFrame(buf: Buffer, offset?: number): { frame: Frame; bytesConsumed: number; } | null; export declare function buildEvalCommand(code: string): Buffer; export declare function buildCompleteCommand(partial: string): Buffer; export declare function buildDirectiveCommand(directive: string): Buffer; export declare function buildExitCommand(): Buffer; export declare function buildHelloCommand(): Buffer; export declare function buildRestartCommand(): Buffer; export declare function buildRuntimePauseCommand(): Buffer; export declare function buildRuntimeResumeCommand(): Buffer; /** Build CMD_FS_GET payload: u16le path_len | path */ export declare function buildFsGetCommand(path: string): Buffer; /** Build CMD_LOG_RESET (no payload). */ export declare function buildLogResetCommand(): Buffer; /** Build a DEPLOY_PUT (begin) payload: u16le name_len | name | u32le total_size. * The file body itself is NOT included — it follows in CMD_DEPLOY_PUT_CHUNK * frames built via {@link buildDeployPutChunkCommand}. Splitting the body * across multiple commands keeps any single TLV frame well under the * device's USJ RX ring, regardless of file size. */ export declare function buildDeployPutCommand(filename: string, totalSize: number): Buffer; /** Build a DEPLOY_PUT_CHUNK frame: payload is raw body bytes (slice of file * data). The host sends one CHUNK per ~2 KB of body and awaits MSG_OK * between frames so the device's RX ring can never overrun. */ export declare function buildDeployPutChunkCommand(data: Buffer): Buffer; export declare function buildDeployDoneCommand(): Buffer; export declare function buildDeployAbortCommand(): Buffer; export declare function buildDeployEraseCommand(): Buffer; /** Build DEPLOY_KEEP payload: u16le name_len | name */ export declare function buildDeployKeepCommand(filename: string): Buffer; /** Build DEPLOY_CHECKSUM payload: u16le name_len | name | sha256[32] */ export declare function buildDeployChecksumCommand(filename: string, hash: Buffer): Buffer; export declare function buildConfigListCommand(): Buffer; /** Build CONFIG_SET payload: u8 flags | u16le key_len | key | u16le val_len | value */ export declare function buildConfigSetCommand(key: string, value: string, secret: boolean): Buffer; /** Build CONFIG_DELETE payload: u16le key_len | key */ export declare function buildConfigDeleteCommand(key: string): Buffer; export type MessageType = 'ready' | 'log' | 'warn' | 'error' | 'result' | 'info' | 'debug' | 'completions' | 'eval_error' | 'prompt' | 'ok' | 'err' | 'checksum_result' | 'config_entries' | 'fs_chunk' | 'test' | 'manifest_done'; export interface Message { type: MessageType; payload: Buffer; } /** Parse a frame into a typed message. Returns null for unknown types. */ export declare function frameToMessage(frame: Frame): Message | null; export interface CompletionResult { prefix: string; items: string[]; } /** Parse a CBOR-encoded completions message payload */ export declare function parseCompletions(data: Uint8Array): CompletionResult | null; /** Result of feeding data to the FrameParser: complete frames + any raw bytes */ export interface ParseResult { frames: Frame[]; /** Raw bytes skipped before valid frames (boot logs, stray bytes) */ raw: Buffer | null; } /** Accumulates incoming data and yields complete frames. * Bytes with unknown type values are collected as raw output. */ export declare class FrameParser { private buf; private rawAccum; /** Feed data and return complete frames + any raw bytes that were skipped */ feed(data: Buffer | Uint8Array): ParseResult; /** Drain and return the internal buffer (for displaying stale data) */ flush(): Buffer; /** Reset internal buffer */ reset(): void; } /** Returns true if the code has unmatched brackets/parens/braces, * unterminated strings, or template literals. */ export declare function isIncomplete(code: string): boolean; //# sourceMappingURL=protocol.d.ts.map