Skip to content

Binary Framing Protocol ​

JetPack prohibits JSON over WebSockets for control-plane and worker data payloads. Every message uses Hybrid Binary Framing (crates/jetpack-proto/src/framing.rs) so structured metadata stays compact via MessagePack while large buffers (tensors, audio PCM, video frames, JPEG previews) remain raw zero-copy bytes.

1. Plaintext Hybrid Frame Layout ​

text
+-------------------------------+------------------------+------------------------+
| header_len: uint32 LE (4 B)   | MsgPack Header (N B)   | Raw Binary Payload (M) |
+-------------------------------+------------------------+------------------------+
|<--------- 4 bytes ----------->|<------ N bytes ------->|<------ M bytes ------->|
  • Size Limits:
    • MAX_HEADER_SIZE: 64 KiB (65,536 bytes)
    • MAX_FRAME_SIZE: 64 MiB (67,108,864 bytes)
  • Zero-Copy Slicing: On decode, jetpack-proto validates plaintext.len() >= 4 + N, deserializes the MsgPack header from &plaintext[4 .. 4 + N], and returns Bytes::slice(4 + N ..) as the payload without allocating or copying the M-byte binary body.

FrameHeader Schema (MsgPack Map) ​

Serialized with named MsgPack fields (rmp_serde::to_vec_named):

rust
pub struct FrameHeader {
    pub channel_id: u32,
    pub opcode: String,
    pub correlation_id: Option<u64>,
    pub target_worker: Option<String>,
}
FieldTypePurpose
channel_idu32Logical multiplexing stream/channel (0 for control plane, 1+ for worker channels).
opcodestringOperation identifier (e.g. "hardware.get_profile", "app.launch", "compute.tensor_op").
correlation_idu64?Optional request/response correlation ID matched by JetPackAppClient.request().
target_workerstring?None routes to the daemon control plane; Some(app_id) or Some("primary") routes to the primary worker; Some(service_name) routes to a [services.<name>] companion.

2. Encrypted WebSocket Wire Envelope ​

Over ws://127.0.0.1:9470, each plaintext HybridFrame is authenticated and encrypted using ChaCha20-Poly1305:

text
+-------------------------------+----------------------------------------+------------------------+
| seq: uint64 LE (8 B, AAD)     | Ciphertext of Plaintext Frame (4+N+M)  | Poly1305 Tag (16 B)    |
+-------------------------------+----------------------------------------+------------------------+
  • Nonce Construction (12 B):
    • Client -> Daemon: b"C2D\0" || seq.to_le_bytes()
    • Daemon -> Client: b"D2C\0" || seq.to_le_bytes()
  • Replay Protection: Both sides start seq at 0 and require incoming_seq == expected_seq strictly incrementing by +1.
  • Text Frame Rejection: Any Message::Text frame received after handshake completion triggers immediate connection termination with WebSocket close code 1003 Unsupported Data.

3. Local Kernel Worker IPC Framing ​

Between jetpack-daemon and sandboxed workers (UDS on macOS/Linux, Named Pipe on Windows), traffic crosses an OS-isolated local boundary and is not re-encrypted. Instead, stream boundaries are delimited by an outer 4-byte frame length (sdks/python/jetpack_sdk/framing.py):

text
+-------------------------------+-------------------------------+------------------------+------------------------+
| frame_len: uint32 LE (4 B)    | header_len: uint32 LE (4 B)   | MsgPack Header (N B)   | Raw Binary Payload (M) |
+-------------------------------+-------------------------------+------------------------+------------------------+

Where frame_len = 4 + N + M. This allows Python workers (memoryview) and Rust IPC readers (bytes::Bytes) to read each frame in two contiguous reads without scanning or base64 decoding.

4. Control-Plane Opcodes Summary ​

Request OpcodeResponse / Stream OpcodesPayload Direction
hardware.get_profilehardware.profileEmpty -> HardwareProfile (MsgPack)
catalog.getcatalog.okEmpty -> CatalogAppEntry[] (MsgPack)
catalog.estimate_sizescatalog.estimate_sizes.ok, app.errorCatalogEstimateSizesRequest (app_ids?) -> CatalogEstimateSizesResponse (estimates[] with install_download_bytes, cached_reused_bytes, models_total_bytes, models[])
app.listapp.list.okEmpty -> AppInfo[] (MsgPack)
app.pullapp.pull.progress, app.pull.ok, app.errorAppPullRequest -> Progress / OK (updating an existing app rejects APP_IS_RUNNING if active, swaps in the new version, cleans superseded version folders under <apps_dir>/<app_id>/, and preserves <appdata_root>/<app_id> and mounted host folders)
app.launchapp.launch.progress, app.launch.ok, app.errorAppLaunchRequest -> AppLaunchProgressFrame (stage, message, percent?, downloaded_bytes, total_bytes) / job_id
app.volumes.resetapp.volumes.reset.ok, app.errorAppVolumesResetRequest -> reset_count
app.cache.clearapp.cache.clear.ok, app.errorAppClearCacheRequest (app_id) -> AppClearCacheOkResponse (app_id, cleared_appdata, reset_volumes; Control Center origin only; rejects APP_IS_RUNNING)
app.uninstallapp.uninstall.ok, app.errorAppUninstallRequest (app_id, remove_cache) -> AppUninstallOkResponse (app_id, removed_app_dirs, cleared_appdata, reset_volumes; Control Center origin only; rejects APP_IS_RUNNING)
app.terminateapp.terminate.ok, app.errorAppTerminateRequest -> OK
client.list / client.revokeclient.list.ok / client.revoke.okClient management
settings.get / settings.setsettings.get.ok / settings.okDaemonSettings (developer_mode, open_in_app_window, open_dashboard_on_startup, daemon_version, appdata_dir, language); settings.set accepts optional reset_appdata_dir: bool and language ("en" / "uk") (loopback only)
settings.pick_appdata_dirsettings.ok, app.errorLoopback-only (127.0.0.1 / localhost). Opens native main-thread OS folder picker (rfd), creates and persists appdata_dir, and returns updated DaemonSettings
ui.open_urlui.open_url.ok, app.errorUiOpenUrlRequest -> UiOpenUrlOkResponse (opened_in_app_window; loopback origins opening loopback HTTP targets or exact SignedAppCatalog launch_url external https:// targets with ?lang=<code> propagation in dedicated wry windows or browser tabs)
diagnostics.exportdiagnostics.export.ok, app.errorDiagnosticsExportRequest -> binary [4B LE meta_len][MsgPack DiagnosticsExportMeta][raw .zip bytes] redacted bundle (loopback only)
diagnostics.senddiagnostics.send.ok, app.errorDiagnosticsSendRequest -> DiagnosticsSendOkResponse (status_code, endpoint, redactions_applied, sent_bytes) to configured [diagnostics].report_url
update.checkupdate.status, app.errorEmpty -> UpdateStatusResponse
update.applyupdate.progress, update.restarting, app.errorUpdateApplyRequest -> Progress / Restarting (Control Center origin only)
logs.subscribelogs.subscribe.ok, logs.entry, app.errorLogsSubscribeRequest? -> Replays bounded 200-entry redacted buffer and streams live LogEntryFrame (timestamp_ms, level, source, message); rejects with DEV_MODE_REQUIRED unless developer_mode == true and cancels active streams immediately if settings.set disables Developer Mode
logs.unsubscribelogs.unsubscribe.okLogsUnsubscribeRequest? -> Cancels the session's live log stream
system.echosystem.echoDiagnostic raw echo

Zero-VM Local Compute Orchestrator · Rust + WebAssembly + OS Kernel Sandboxes