Skip to content

Instantly share code, notes, and snippets.

@IntegralPilot
Last active November 16, 2026 06:28
Show Gist options
  • Select an option

  • Save IntegralPilot/1040fe5697f05b8eb9d5e3256fb02de9 to your computer and use it in GitHub Desktop.

Select an option

Save IntegralPilot/1040fe5697f05b8eb9d5e3256fb02de9 to your computer and use it in GitHub Desktop.
Asahi Linux WebSocket Install API

Asahi Linux Installer API v1

In this document:

  • MB means decimal megabytes (10^6 bytes).
  • Fields are required unless specified otherwise.
    • Fields typed X or null may either be null or omitted.
  • User-facing text uses Message objects ({key, vars}) for i18n.
    • The log lines not considered user facing, so are plain text.
  • Unless specified otherwise, an RPC is allowed in all phases.

Connection

Uses JSON-RPC 2.0 over WebSocket at localhost:7782/api/ws, with subprotocol jsonrpc2.0. If port 7782 is already binded, to avoid conflicting install servers running at the same time, the server must refuse to start. The server must only bind to loopback.

The server should reject attempted connections from remote addresses or with invalid Host/Origin headers.

Parameters must be passed as JSON Objects, and batch requests are not supported.

The frontend is provided a crytographic token (128 alphanumeric characters) as a URL fragment (if no URL fragment is provided, it should check in LocalStorage for a saved token). This must be used to send a hello as the first message, within 5 seconds or else the connection will close. Clients should call get_logs after hello and deduplicate incoming log notifications by seq.

Only one authenticated connection can be active at a time. If there is a new hello with the correct token, then the old socket must be closed with code 4001.

JSON-RPC errors are used for both protocol violations and application rejections. Application errors should include a Message object in error.data.

If a blocking RPC is in-flight and a socket closes for any reason, the server finishes the operation normally.

Message

Field Type Contents
key String Translation key, e.g. plan.size_too_small.
vars String[] Values for {0}, {1}, etc. in key. May be empty.

Error Codes

Protocol errors

Code Name Meaning error.data
-32700 Parse error Malformed JSON received by the server. None
-32600 Invalid request Not a valid JSON-RPC 2.0 request object (e.g. non-object params). None
-32601 Method not found Unknown RPC method name. None
-32602 Invalid params Missing/invalid parameter types, or invalid parameter combinations (e.g. only one of username/password in start_install, reboot when nextStep != "direct"). Optional Message
-32603 Internal error Unexpected internal server error. Optional Message

Session / state errors

Code Name Meaning error.data Side Effect
-32001 Not authenticated Any RPC called before hello succeeds. None Closes connection
-32002 Invalid session token Missing or incorrect token in hello. None (or Message) Closes connection
-32003 Already authenticated hello called more than once on the same connection. None None
-32010 Invalid phase RPC not allowed in the current state.phase. Message None
-32011 Not cancellable cancel called while state.cancellable is not true. If the state.phase isn't right for cancellation, -32010 should be returned instead. Message None
-32012 Not retryable retry called while state.retryable is not true. If the state.phase isn't right for retry, -32010 should be returned instead. Message None
-32013 Authentication attempts expended state.authAttemptsRemaining is 0, and the requested operation requires attempting an authentication, so cannot be completed. Message None

Application errors

Code Name Meaning error.data Side Effect
-32020 Invalid plan Unknown edition/target, invalid volumeName, or start_install failed plan validation. Message phase stays ready
-32030 Invalid credentials Unknown username or wrong password in start_install or authenticate. Message In start_install, stays ready. In authenticate, returns to awaiting_auth (retryable).
-32031 Auth attempts exceeded Maximum authenticate retries reached. Message phase becomes failed
-32032 Privileged op failed Non-credential error running bputil or bless during authenticate. Message phase becomes failed
-32040 Cancellation failed cancel was permitted (cancellable was true), but aborting failed. Message None

Close codes

Code Meaning Should try to reconnect?
1000 Normal closure (e.g. server shutting down after finish). No
4001 Session superseded by a newer connection with a valid hello. No
4002 Invalid or missing session token in hello (-32002). No
4003 Authentication timeout (hello not received within 5 seconds). Yes
4004 Protocol violation: RPC sent before hello (-32001). No
Any other Unexpected disconnect (e.g. 1001, 1006). Yes

hello

Authenticate the WebSocket session. Must be the first request on the connection.

After the request, the client must then remove the URL fragment from the URL.

If the request suceeded, the client should save the token in LocalStorage so the session can be restored if the user closes the page or reloads. If the request failed with -32002, the client should clear the token from LocalStorage if it was sourced from there, and report a fatal startup error to the user.

If an incorrect or missing token is provided tohello, it will be rejected and the connection closed. If the client attempts any other calls before hello, they likewise should be rejected and the connection closed.

Parameters:

Field Type Contents
token String Session token from the URL fragment.

Result:

Field Type Contents
apiVersion Integer Protocol version (1).
serverVersion String Installer version without “v”, e.g. 0.9.4.

Immediately after replying, the server sends a state notification with the current snapshot.

get_system

Retrieve device information, boot mode, startup blockers, and warnings.

Parameters: None.

Result:

Field Type Contents
expertMode Boolean Whether expert mode is enabled on the server.
device DeviceInfo Device running the installer.
blockers Message[] Fatal startup blockers preventing installation. Empty if ready.
warnings Message[] Non-fatal system warnings, e.g. 128GB education model notice.

DeviceInfo

All fields except productName are optional and may be null.

Field Type Contents
productName String Apple's full product name, e.g. MacBook Air (13-inch, M3, 2024).
soc String SoC name, e.g. Apple M3.
osVersion String macOS version and build.
bootMode String Current boot environment, e.g. macOS.
deviceClass String Internal device class, e.g. j613ap.
productType String Model identifier, e.g. Mac15,12.
boardId String Board identifier, e.g. 0x30.
chipId String Chip identifier, e.g. 0x8122.
systemFirmware String System firmware version.
bootUuid String Current boot UUID.
bootVgid String Current boot VGID.
defaultBootVgid String Default boot VGID.
osRestoreVersion String OS restore version.
mainFirmwareVersion String Main firmware version.
fallbackSystemFirmware String Fallback system firmware version.
sfrVersion String SFR version.
systemRecoveryVersion String SystemRecovery version.
loginUser String Logged-in account name.

list_editions

Retrieve available OS editions and their firmware compatibility.

Parameters: None.

Result:

Field Type Contents
editions Edition[] Available editions from installer_data.json.

Edition

Field Type Contents
id String Stable edition identifier, e.g. fedora-kde.
name String Display name (only acts as a fallback if there is not a translation key associated with id)
minMB Integer Minimum total space required, including the macOS stub.
available Boolean Whether this edition is supported on the current device and firmware.
unavailableReason Message or null Reason available is false, null otherwise.

get_disk

Retrieve the target disk layout. Only available when state.phase is ready.

Parameters: None.

Result:

Field Type Contents
sizeMB Integer Total disk capacity.
isGpt Boolean Whether the disk uses a GPT partition table.
partitions Partition[] All partitions in disk order, including free space and unsuitable partitions.

Partition

Field Type Contents
id String Partition UUID, or hash of byte offset and size.
kind String free (unallocated), apfs (APFS container), or other (unsuitable).
label String or null Display name, e.g. Macintosh HD, or null if none (e.g. free).
sizeMB Integer Current partition size.
maxMB Integer Maximum space this target can provide for Linux (0 if unusable or unresizable).
reason Message or null Explanation when maxMB is 0, null otherwise.
isCurrentSystem Boolean Whether this partition hosts the currently booted macOS / active system.
osLabels String[] Summary labels of OSes detected in this partition, if any.

plan_install

Perform a dry run of an installation configuration. Only available when state.phase is ready.

Parameters:

Field Type Contents
edition String Edition identifier.
target String Identifier of a partition from get_disk.
sizeMB Integer or null Requested total Linux allocation (space to use in free, or space to reclaim from apfs). If null, uses the server's recommended default.

Result:

Field Type Contents
valid Boolean true if problems is empty.
limits InstallLimits Server-computed bounds for size selection.
normalised NormalisedSizes Exact sizes after partition alignment.
warnings Message[] Non-blocking warnings (e.g. large APFS overhead, resizing current system).
problems Message[] Validation errors preventing installation with these parameters.

InstallLimits

Field Type Contents
minMB Integer Minimum valid Linux allocation.
maxMB Integer Maximum valid Linux allocation for this target.
stepMB Integer Alignment step size for UI controls.
defaultMB Integer Recommended default Linux allocation.

NormalisedSizes

Field Type Contents
linuxMB Integer Total aligned space allocated to the install (stub + OS).
stubMB Integer Aligned space used by the macOS stub container.
osMB Integer Aligned space available to the target OS partitions.
macosAfterMB Integer or null Resulting APFS container size after shrink, null if target is free.
freeAfterMB Integer or null Remaining unallocated space in the gap, null if target is apfs.

start_install

Validate the plan using the same rules as plan_install and begin installation.

Only available if state.phase is ready.

Username & password

An optional username and password can be provided to be used for priviledged operations (i.e. bless).

If one of username and password is provided but not the other (providing "" is considered not providing anything at all), that is considered a malformed request.

Before start, it will be validated if the account exists and has the right password, and an error will be returned if not. However, it isn't possible to confirm if the account has the priviledges required for the operations until we actually try, later in the install.

When performing the operations, if there is no provided account/password, or the provided account does not have the right permissions, the server will set state.phase to awaiting_auth.

If a non-empty username and password are provided but state.authAttemptsRemaining is 0, error -32013 will be reutrned.

If a failure occurs before install starts due to providing the incorrect password, state.authAttemptsRemaining will be decreased by 1.

Parameters:

Field Type Contents
edition String Edition identifier.
target String Identifier of a usable disk partition.
sizeMB Integer Requested total Linux allocation.
volumeName String Volume name shown in Startup Options.
username String or null Optional account to use for privileged operations.
password String or null Optional password to use for privileged operations.

Result:

Field Type Contents
accepted Boolean true if installation started. Otherwise a JSON-RPC error is returned with error.data set to a Message.

authenticate

Submit macOS admin credentials. Only available when state.phase is awaiting_auth. Blocks until the credentialed operation (bputil or bless) completes, but changes the state.phase to running and state.cancellable to false as soon as recieved.

If it fails, the original state.phase and state.cancellable will be restored. If the failure was due to providing the incorrect password, state.authAttemptsRemaining will be decreased by 1.

If the server's attempt limit is reached, or if another error occurs when running the credentialed operation that is not related to credentials, an error will be returned and state.phase will become failed.

Parameters:

Field Type Contents
username String Account from state.authUsers.
password String Account password.

Result:

Field Type Contents
authenticated Boolean true if authentication succeeded. Failed attempts return a JSON-RPC error with error.data set to a Message, and may be retried up to the server's attempt limit.

get_logs

Retrieve buffered plain-text log lines for initial load or reconnect catch-up.

Parameters:

Field Type Contents
after Integer Return entries with seq > after. Optional, defaults to 0.

Result:

Field Type Contents
nextSeq Integer Next sequence number expected after the returned entries.
entries LogEntry[] Buffered log entries. May be empty.

LogEntry

Field Type Contents
seq Integer Monotonically increasing, 1-based sequence number.
level String debug, info, warning, error, or success.
line String Plain-text log line.

get_telemetry

Retrieve the anonymous installation statistics payload that would be sent. Requires state.phase to be complete.

Parameters: None.

Result:

Field Type Contents
enabled Boolean Whether telemetry reporting is configured in this build/environment.
payload Object or null Exact JSON object that will be reported, or null if enabled is false.

finish

Record the statistics consent and optionally reboot or shut down the Mac. Requires state.phase to be complete.

The server should upload the stats (if accepted and enabled), and then return the result, before terminating the connection (with code 1000), closing itself down, and taking the provided action.

If there is an upload error for stats, the server should just swallow the error and continue.

Parameters:

Field Type Contents
shareAnonymousStatistics Boolean Whether the user granted or declined stats consent.
action String shutdown, reboot, or none (reboot is valid only when result.nextStep is direct).

Result:

Field Type Contents
accepted Boolean true if the command was accepted. Otherwise a JSON-RPC error is returned.

cancel

Cancel the installation. Only permitted when state.cancellable is true. Blocks until attempted cancellation completes, but sets state.cancellable to false while running.

If the cancellation fails, state.cancellable will be restored to true to permit retries. If the cancellation is sucessful, the phase will become failed (with the reason being user cancellation).

Parameters: None.

Result:

Field Type Contents
cancelled Boolean true if cancellation succeeded. Failed attempts return a JSON-RPC error with error.data set to a Message.

retry

Retry the installation from where things went wrong. Only permitted when state.phase is failed and state.retryable is true. Uses the same plan as before, it isn't possible to change it, and continues from where things left off. Returns immediately (unlike cancel) after updating internal state.

Parameters: None.

Result:

Field Type Contents
success Boolean true if starting the retry succeeded. It might still fail later and set state.phase back to failed

reset

Forget everything ever happened, except for remembering the failed auth count and current log seq. Effectively returns to clean state as if after first hello. Sends a new state notification immediately, with the new clean state (state.phase = ready etc.).

Only permitted when state.phase is ready, complete or failed.

Parameters: None.

Result:

Field Type Contents
success Boolean true if the reset suceeeded.

Notifications

state

Sent after hello and whenever the installation state changes (throttled for byte-copy progress, flushed immediately on phase or stage transitions).

Field Type Contents
phase String blocked, ready, running, awaiting_auth, complete, or failed.
stage String or null preparing, resizing, installing, finalising, or null when idle/complete/blocked.
step Integer Current stage index, from 1 to total (0 if not started).
total Integer Total number of planned stages (0 if not started).
operation Operation or null Current sub-operation and progress, or null when not running.
cancellable Boolean or null If running or awaiting_auth, is it allowed to cancel the install at this time?
retryable Bolean or null If failed, can we try again (i.e, the download was what failed)?
authUsers String[] Eligible macOS admin accounts when phase is awaiting_auth, empty otherwise.
authAttemptsRemaining Integer The number of authentication attempts remaining before the server will no longer permit any attempts. Globally remebered across the runtime of the server. If it is 0, attempting to install will fail at the bless stage.
failure Failure or null Failure details when phase is failed, null otherwise.
result InstallResult or null Completion details when phase is complete, null otherwise.

Operation

Field Type Contents
key String Translation key for the current operation.
vars String[] Substitution values for key. May be empty.
percent Number or null Completion from 0 to 100, or null if indeterminate.

Failure

Field Type Contents
key String Translation key describing the failure.
vars String[] Substitution values for key. May be empty.
diskState String unchanged, resized_not_installed, partial_install, or unknown.

InstallResult

Field Type Contents
nextStep String direct (1TR paired, reboot directly), recovery (shut down and enter Startup Options), or macos (shut down, enter Startup Options, and run Finish Installation).
volumeName String Configured Startup Options volume name.
vgid String APFS volume group ID of the new stub install.
efiPartuuid String or null Lowercase PARTUUID of the EFI system partition, if created.

log

Sent after hello as plain-text log entries are emitted and flushed before terminal state updates on complete or failed. Params match LogEntry.

Trivia

The port is 7782 because that is my initials (MR) as ASCII.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment