# TeamsPeach core bridge — protocol v1 Contract between the Electron **main** process and the native protocol core (`teamspeach-core`, Rust, built on ReSpeak tsclientlib). The renderer never talks to the core directly: main forwards only the commands listed here, after checking `cmd` against this allowlist and argument shapes. ## 1. Process model ``` teamspeach-core --data-dir [--connection-dir ] ``` - `--data-dir` is resolved and passed **only by main** (e.g. `/core`). The core creates it if missing. A standalone core locks it exclusively. Multi-server main starts one core per server, sharing the vault lock and exclusively locking each distinct connection dir. A conflicting instance fails with exit code 3; connection IDs/epochs remain main-owned. - **stdin**: UTF-8, one JSON object per line (`\n`, `\r\n` tolerated). Max line **256 KiB**; a longer line is discarded up to its newline and answered with an `error` event `bad_request` (no `id` can be recovered). - **stdout**: UTF-8, one JSON object per line. Nothing else is ever written to stdout. - **stderr**: human-readable logs only (never parse). Verbosity: env `TEAMSPEACH_LOG` (`error|warn|info|debug|trace`, tracing filter syntax), default `info`. - **stdin EOF** or `shutdown` command → graceful disconnect (if connected), then exit 0. - Exit codes: `0` clean, `2` bad CLI arguments, `3` data dir locked/unusable, `1` fatal internal error. - Windows dev binary: `core/target/release/teamspeach-core.exe` (debug: `core/target/debug/teamspeach-core.exe`). Packaged: `resources/core/teamspeach-core[.exe]`. The first stdout line is always: ```json {"event":"ready","protocol":1,"core_version":"0.1.0"} ``` ## 2. Framing Request (stdin): ```json {"id":"r1","cmd":"connect","args":{"address":"10.10.10.160:9987"}} ``` - `id`: string, 1–64 chars, chosen by main; echoed in the response. Required for every command **except** `audio_frame` and `audio_end` (high-rate, never answered; an `id` there is ignored). - `cmd`: one of the commands in §4. Unknown `cmd` → `unknown_command`. - `args`: object; may be omitted when a command takes no arguments. Unknown argument keys are rejected (`bad_request`). Response (stdout), exactly one per request with `id`: ```json {"id":"r1","ok":true,"result":{}} {"id":"r1","ok":false,"error":{"code":"not_connected","message":"..."}} ``` Event (stdout), no `id`, discriminated by `event`: ```json {"event":"state","state":"connected", ...} ``` A line is a response iff it has an `id` key; otherwise it is an event. Events may be emitted before the response of the command that caused them (e.g. `state: connecting` precedes the `connect` response). ## 3. Error object `{"code": string, "message": string, "ts_error"?: {"id": number, "name": string, "missing_permission"?: number}, "detail"?: object}` `ts_error` is present when the TeamSpeak server rejected a command: numeric TeamSpeak error id and tsclientlib's name for it (live example: send_text to a channel without permission → `{"id":2568,"name":"PermissionsClientInsufficient","missing_permission":224}`). `detail` carries structured extra state where stated (e.g. `rename`). Repository-authored `message` text and stderr diagnostics are English technical details, not UI translation keys. The renderer selects a localized explanation by stable `code` and may append the technical detail. Do not translate protocol tokens, server-supplied text or user content, and do not branch on human-readable message wording. | code | meaning | |---|---| | `bad_request` | malformed JSON, missing/unknown/invalid argument, bad `id` | | `unknown_command` | `cmd` not in allowlist | | `profile_missing` | no identity yet → call `profile_create` | | `profile_exists` | `profile_create` when an identity already exists (never overwritten) | | `identity_corrupt` | identity file unreadable/invalid/UID mismatch. Core **never** regenerates; user/main must resolve (restore backup / import) | | `profile_corrupt` | profile (nickname) file unreadable/invalid | | `invalid_nickname` | nickname rule violated (§4.3) | | `nickname_required` | identity exists but no nickname saved (connect refused) | | `not_connected` | command needs an active connection | | `already_connected` | `connect` while connecting/connected | | `connect_failed` | could not connect (resolve, timeout, server refused …; `ts_error` when the server sent one) | | `server_error` | server answered a command with an error (`ts_error` set) | | `audio_format` | `audio_frame.pcm` not 1920 bytes after base64 decode | | `audio_overflow` | outgoing PCM queue full, oldest frames dropped (event, throttled ≤1/s) | | `audio_muted` | `audio_frame` while input or output muted; frames discarded (event, once per burst) | | `audio_codec` | Opus encode/decode failure (event) | | `audio_codec_unsupported` | current channel codec is not Opus (legacy Speex/CELT): we cannot transmit there (event, once per burst); received non-Opus voice is reported once per speaker | | `rename_not_persisted` | server accepted the new nickname but saving it failed; see §4.3 | | `not_found` | requested icon/avatar/banner does not exist (`detail.builtin:true` for built-in icon ids) | | `target_changed` | private message/client target disappeared or numeric ID now refers to a different UID | | `media_too_large` | file exceeds the size limit of its kind (§4.17) | | `media_unsupported` | file is not a recognized image, or a banner reference the core cannot fetch | | `external_media` | banner or avatar lives at an `https://` URL (`detail.url` for banners, `detail.urls` for avatars); main may fetch it itself | | `io` | data dir I/O failure | | `internal` | bug; message has details | Asynchronous failures (not tied to a request) are emitted as `{"event":"error","error":{...}}`. ## 4. Commands ### 4.1 `profile_get` — no args Result = profile object: ```json {"exists":true,"uid":"Zx1...base64...=","nickname":"Alice","security_level":8} {"exists":false,"uid":null,"nickname":null,"security_level":null} ``` `uid` is the permanent public TeamSpeak unique identifier (base64 SHA-1 of the public key). The private key is **never** sent over the bridge. If the identity exists but no nickname is saved: `exists:true, nickname:null` (UI should prompt and call `rename`). Corrupt files → error `identity_corrupt` / `profile_corrupt`. ### 4.2 `profile_create` — `{nickname: string}` Generates a new P-256 identity (security level ≥ 8), persists it privately, saves the nickname. Fails with `profile_exists` if any identity exists. Result = profile object. Also emits `{"event":"profile", ...profile object}`. ### 4.3 `rename` — `{nickname: string}` Persists the nickname. **UID never changes.** - Disconnected: validate → atomically save `profile.json` → result. - Connected: send `clientupdate client_nickname` and wait for the server's answer. Server rejects (e.g. nickname in use) → `server_error`, nothing saved, nothing changed. Server accepts → save atomically. If saving fails, the core immediately sends `clientupdate` back to the saved nickname and answers `rename_not_persisted` with `detail: {"saved_nickname": "", "server_nickname": "", "reverted": bool}` (`reverted:false` = revert also failed; the server keeps the new name for this session only). Result = profile object; emits `profile` event. Nickname rules: after trimming, 3–30 Unicode scalar values, no control characters. ### 4.4 `connect` — `{address, server_password?, channel?, channel_password?, identity_id?, nickname?}` - `address`: `host`, `host:port`, `[v6]:port` (default port 9987). Not a path. - `server_password`: optional string. - `channel`: optional initial channel, either numeric channel id string `"cid:12"` or a path `"Parent/Child"`. - `identity_id`: selected vault UID; omitted selects the default. Server-demanded proof-of-work is handled by the bounded identity CLI, not automatically during connect. - Uses the persisted identity and nickname (`profile_missing` / `nickname_required` otherwise). An optional `nickname` overrides the name for this connection only, without changing the saved identity, name, nickname or UID. At connect time the core trims and validates 3–30 Unicode scalar values with no control characters; an invalid override returns `invalid_nickname`, never a fallback to the saved name. If the nickname is taken on the server, the server appends digits (e.g. `Name1`); the snapshot shows the server-side name, the profile keeps the saved one. - After connecting the core subscribes to all channels (`channelsubscribeall`), so the snapshot lists clients in every channel. Emits `state: connecting`, then on success `snapshot`, `audio_state`, `state: connected`, then the response `{"ok":true,"result":{"own_client_id":7}}`. On failure the response is `connect_failed` and `state: disconnected` with `reason`. #### Desktop bookmark orchestration (Electron IPC, not native commands) Main resolves saved bookmarks before dispatching `connect`; the renderer never passes a saved password as a native argument. These IPC handlers require the trusted application top frame: - `bookmarks:password-state(id)` returns availability and saved/not-saved flags, never plaintext. - `bookmarks:password-set(id, expectedAddress, kind, value)` saves or clears (`value: ""`) the server or channel password. `kind` is `server` or `channel`; nonempty values use OS `safeStorage` encryption. - `bookmarks:password-reveal(id, expectedAddress, kind)` returns plaintext only for an explicit Reveal action. Changing the window, target or credential during native storage interaction invalidates it. - `bookmarks:connect(connectionId, bookmarkId, startup)` reads current metadata and decrypts in main. A failed decrypt/binding check stops the operation; it never substitutes an empty password. Automatic startup with `auto_connect_muted` sends `set_audio {input_muted:true}` before `connect`, rechecking the captured connection/session and bookmark after the acknowledgement. Output mute is never changed. - `bookmarks:startup()` returns enabled bookmark metadata in tree order once per main-process lifetime. Renderer reloads cannot issue a second startup batch. Offscreen runs return an empty list and refuse bookmark connects with `test_safety` before dispatching a core command. Passwords live only as `server_password_encrypted` / `channel_password_encrypted` in the atomic prefs record. Each envelope binds its purpose and exact trimmed address. Generic prefs writes preserve the current ciphertext for unchanged targets, clear it on address changes, and permit new-ID copies only from a same-address bookmark. Clearing remains possible without an available key store. Linux `basic_text`, unknown backends and legacy hardcoded-key `v10` ciphertext are rejected. Platform semantics: [Electron safeStorage](https://www.electronjs.org/docs/latest/api/safe-storage); the legacy Linux format is documented in [Chromium OSCrypt](https://chromium.googlesource.com/chromium/src/+/2d15a8eb787a31d5bbab0ff4a6a539a0df7c99dc/components/os_crypt/os_crypt_linux.cc). Windows DPAPI does not protect against other software running as the same OS user. Actual keyring/Keychain operation and portability are not established by Windows or simulated-backend tests. ### 4.5 `disconnect` — `{message?: string}` Sends a clean `clientdisconnect` and waits (≤ 3 s) for the server. Result `{"clean": true}` when the server confirmed, `{"clean": false}` on timeout or when a pending connect attempt was abandoned. `not_connected` if idle. Emits `state: disconnecting` → `state: disconnected`. ### 4.6 `join_channel` — `{channel_id: number, password?: string}` Moves self (`clientmove`). Result `{}` after the server confirms; snapshot follows. ### 4.7 `send_text` — `{target: "channel"|"server"|"client", client_id?: number, expected_client_uid?: string, message: string}` `client_id` and `expected_client_uid` are required iff `target = "client"`. Native rechecks the UID immediately before sending, otherwise `target_changed`. Message 1–8192 bytes UTF-8; TeamSpeak escaping is done by the core. Result `{}` after server confirmation. The server echoes our own messages as `text` events (verified live for private messages: the sender receives exactly one `text` with `to_client_id` = recipient); the core adds no synthetic echo. ### 4.8 `set_audio` — `{input_muted?: bool, output_muted?: bool}` `input_muted` = mute microphone, `output_muted` = deafen. Updates the server-visible flags (`client_input_muted` / `client_output_muted`) when connected, and the core-side gates: while `input_muted || output_muted` outgoing frames are discarded; while `output_muted` no `audio` events are emitted. Allowed when disconnected (applied at next connect). Result = audio state object; emits `audio_state`. Initial state at process start: both `false`. ### 4.9 `audio_frame` — `{pcm: string, whisper?: u32}` (no `id`, no response) One 20 ms microphone frame: base64 (standard alphabet, padded) of **960 signed 16-bit little-endian mono samples at 48 kHz = 1920 bytes** (2560 base64 chars). In transmit mode `direct` (see 4.11) the renderer decides: it sends frames only while push-to-talk is held or the open microphone is on, and `audio_end` when it stops; the core sends every frame. In mode `vad` the renderer sends frames continuously while connected and not muted, and the core's voice detector decides which are sent. The core Opus-encodes 20 ms frames with the **current channel's codec**: Opus Voice (mono) or Opus Music (stereo — the mono frame is duplicated to both channels). Legacy Speex/CELT channels → `audio_codec_unsupported` event and nothing is sent. Outgoing queue bound: 10 frames (200 ms); on overflow the oldest frames are dropped (`audio_overflow` event). If no frame arrives for 200 ms during a burst the core ends the burst itself. Not connected → frames dropped with one `not_connected` error event per burst. Muted, deafened, or not allowed to talk by the server → frames dropped with one `audio_muted` event per burst; in mode `vad` the detector state and preroll are discarded as well. Before IPC, the capture worklet stamps each frame's final sample with its own AudioContext time. The engine drops messages older than 200 ms in that same clock; a busy renderer must not replay a long MessagePort backlog. This is separate from the native queue bound and does not shorten VAD's intentional 100–300 ms preroll. Normal delivery, DSP preferences, privacy gates, native worklet shutdown and output/per-peer gains are unchanged. Channel quality `q` remains clamped to 0–10: Voice targets `8000 + 4000*q` bps with `OPUS_APPLICATION_VOIP`; Music targets `24000 + 8000*q` bps with `OPUS_APPLICATION_AUDIO`. These are TeamsPeach's existing targets, not a claim of TeamSpeak's proprietary encoder configuration. The installed official UI contains a different bandwidth-estimate table; that display code alone does not justify lowering encoder targets. Evidence and the exact source hash are in `docs/evidence/voice-official-source-20261029.json`. No real server's bitrate cap was queried or changed in this offline audit. `scripts/audit-voice-timed.mjs --seconds 190 --verify` captures only a licensed fake WAV through real Chromium into PCM, disconnected and with sink `none`. `--stall --seconds 12 --verify` exercises a bounded 600 ms renderer stall; `--exe ` uses the guarded packaged launcher. The ignored Rust test `captured_speech_quality_matrix` accepts `TEAMSPEACH_AUDIT_PCM` and `TEAMSPEACH_AUDIT_OUT` and runs the real encoder/receiver at qualities 0/6/10, both codecs, including a synthetic channel-context reset at 90 seconds. Timed metrics are in `docs/evidence/voice-timed-20261029.json`. They do not establish natural-microphone quality, proprietary DSP equivalence or native Linux/ARM behavior. ### 4.10 `audio_end` — no args (no `id`, no response) Ends the current transmission burst (core sends the TeamSpeak end-of-voice packet). In mode `vad` it also discards the detector state and preroll (capture stopped or the renderer stopped forwarding). ### 4.11 `set_transmit` — `{mode: "direct"|"vad", detector?: "automatic"|"volume_gate"|"hybrid", sensitivity?: "high"|"normal"|"low", level_db?: number}` Selects who decides when voice is sent. `direct` (initial state at process start): every forwarded frame is sent. `vad`: voice activation in the core (`core/src/vad.rs`) with the official TS6 VAD modes (our own implementations, not TS6's native code): - `automatic` (default; TS6 "Automatic"/`Likelihood`): frames are decimated to 16 kHz and scored by the earshot voice detector (embedded model, 16 ms windows, probability 0–1). The gate opens after 3 consecutive windows at or above the threshold (`high` 0.45, `normal` 0.6 — default, `low` 0.75). While open, a window counts as voiced down to 0.15 below the threshold. It cannot open during the first 10 frames after a reset. `sensitivity` is a TeamsPeach extension. - `volume_gate` (TS6 "Volume Gate"/`Power`): `level_db` is required (−50..=50, TS6 slider range, default −30 in the app). A frame opens the gate when its RMS level in dBFS is ≥ `level_db`; while open it counts as voiced down to 3 dB below. No warm-up. TS6's native level reference is not visible: here 0 dB is digital full scale, so positive levels can never open the gate. `sensitivity` is rejected. - `hybrid` (TS6 "Hybrid"/`LikelihoodAndPower`): `level_db` required; the detector onset AND the current frame's level must both pass; while open, a frame must be voiced and within 3 dB of the level. `sensitivity` applies to the detector. The gate sends the 5 frames (100 ms) held before the onset, then the current frame, and closes 20 frames (400 ms) after the last voiced frame. Until the first spurt after a reset all frames since it are held (at most 15 = 300 ms) and sent before the current one, later spurts send 5. Detector, filter history and preroll are reset on `audio_end`, mute/deafen, disconnect, channel or codec change, when the server does not allow talking, and on every `set_transmit` that changes between `direct`/`vad` or to another detector: before answering such a change the core discards frames still queued from the previous mode and ends any open burst, and the renderer forwards nothing until it has this answer. A `set_transmit` that only changes `sensitivity` or `level_db` of the active detector (the user moving the VAD level slider) applies from the next frame without discarding audio or ending the spurt. Result `{"mode":"direct"}`, `{"mode":"vad","detector":"automatic","sensitivity":"normal"}`, `{"mode":"vad","detector":"volume_gate","level_db":-30}` or `{"mode":"vad","detector":"hybrid","sensitivity":"normal","level_db":-30}`. `audio_state.transmitting` is true only while voice packets are actually being sent. ### 4.11a `set_local_volumes` — `{replace: bool, volumes: [{uid: string, db: number}]}` Persisted local per-user volume modifiers pushed by main (`app/main/client-volumes.js`): `uid` is the client's base64 unique identifier (1–128 chars), `db` −200..=10 in 0.5 dB steps (−200 = silence, gain 10^(dB/20)). `replace:true` swaps the whole map (sent whenever a core becomes ready), `false` upserts; a 0 dB entry removes the UID. At most 4096 entries per request. The map lives for the core process and applies to every connection it makes; a live `client_action volume` on the current connection takes precedence until disconnect. Result `{"count": }`. ### 4.11b `set_playback_dsp` — `{agc: bool}` Playback automatic gain control of the current output device profile (TS6 "Automatic Gain Control — Automatically level the volume of other users"; our own algorithm in `core/src/voice_dsp.rs`, not TS6's): every speaker's decoded 20 ms (before local volume) updates a smoothed speech level (frames below −50 dBFS are ignored); the speaker's gain moves toward −20 dBFS RMS within ±12 dB, rising at most 0.25 dB and falling at most 3 dB per 20 ms, and applies from the next tick multiplied with the user modifier. Off (process default) = gain exactly 1. Multitrack recording taps stay pre-AGC; the mix is still hard-clipped at full scale (no limiter). Result `{"agc": bool}`. ### 4.12 `stream_list` — `{client_id?: number}` TS6 screenshare discovery. Sends `requeststreaminfo clid=` for `client_id`, or for every other client in our current channel when omitted. Result: ```json {"results":[{"client_id":5,"ok":true},{"client_id":9,"ok":false,"ts_error":{"id":...}}]} ``` Live behaviour (TS6 6.0.0-beta13.1): every `requeststreaminfo` is answered `ok`, plus one `stream` event `notifystreaminfo` per request. For a streaming client the item carries `id` (stream UUID), `clid`, `name`, `type`, `mode`, `accessibility`, `audio`, `bitrate`, `viewer`, `viewer_limit`; for a non-streaming client the item has only `return_code`. So: "is streaming" ⇔ the `notifystreaminfo` item has `id`. ### 4.13 `stream_join` — `{stream_id: string, client_id: number, message?: string}` Sends `joinstreamrequest id= clid= msg= is_remove=0`. Result `{}` (or `server_error`). The SDP offer arrives as `stream` event `notifyrespondjoinstreamrequest` (`decision=1`, `offer=`). ### 4.14 `stream_signal` — `{stream_id: string, client_id: number, json: object}` Sends `streamsignaling id= clid= json=`. Examples of `json`: `{"cmd":"answer","args":{"answer":""}}`, `{"cmd":"iceCandidate","args":{"mLine":0,"mid":"0","sdp":"candidate:..."}}`. Publisher ICE restart responses use `{"cmd":"reconnectOffer","args":{"offer":""}}`. The renderer allowlist accepts only `answer`, `iceCandidate`, and `reconnectOffer`, not arbitrary signaling commands. Max serialized `json` size 60 KiB (the whole stdin line is capped at 256 KiB). Result `{}` or `server_error`. ### 4.15 `stream_leave` — `{stream_id: string, client_id: number}` Sends `joinstreamrequest id=… clid=… msg= is_remove=1`. Result `{}`. ### 4.15a Publishing: `stream_setup`, `stream_update`, `stream_stop`, `stream_respond`, `stream_remove` Metadata arguments: `{name, type, accessibility, mode, bitrate, viewer_limit, audio}`. `type` is camera `1`, screen `2`, window `3`; `accessibility` is public `1`, official contacts-only `2`, private/by-approval `3`; only P2P `mode:1` is accepted. `bitrate` is an integer target in Kbps (`100..100000`), `viewer_limit` is `0..65535` (`0` means unlimited), and `audio` is boolean, serialized as `1`/`0`. | Bridge command | Additional arguments | Legacy wire | |---|---|---| | `stream_setup` | none | `setupstream name type bitrate accessibility mode viewer_limit audio` | | `stream_update` | `stream_id` (required) | `updatestream id name type bitrate accessibility mode viewer_limit audio` | | `stream_stop` | only `stream_id` | `stopstream id` | | `stream_respond` | only `stream_id, client_id, decision, offer, message` | `respondjoinstreamrequest id clid decision offer msg` | | `stream_remove` | only `stream_id, client_id` | `removeclientfromstream id clid reason=4` | `stream_respond.decision` is boolean; acceptance requires nonempty SDP (`offer`, max 60000 UTF-8 bytes); denial requires an empty offer. `message` is at most 200 characters. Eviction reason `4` is the official `KICKED` enum and cannot be chosen by the renderer. All commands use the existing escaped `OutCommand` and server-acknowledgement path; they do not synthesize successful server responses. A successful setup command is not the stream ID: wait for our `notifystreamstarted` notification. Stopping while that notification is pending retains the session solely to unregister its late ID. The renderer publisher owns one peer per authorized UID and source tracks, and reconciles client-ID reuse on every snapshot. Selected participants are a **local UID allowlist**, not myTeamSpeak contacts: this mode advertises public metadata (`accessibility=1`) but never sends an offer/media to an unlisted UID. The stream may appear in the channel list. By-approval uses private metadata (`3`) and queues requests until explicit acceptance. Reducing access/limits closes revoked peers before waiting for server eviction responses. A kicked UID cannot rejoin that share. Resolution/FPS/bitrate options apply capture-track constraints and actual per-peer RTP sender parameters; they are targets/ceilings, not claims of achieved resolution, throughput or frame rate. Presets fit the source aspect ratio without upscaling; presentation uses 5 FPS. Sender codecs intentionally offer only H264 High and VP8 based on the desktop decoder compatibility evidence; AV1/VP9 are not offered by this sender. SFU publication is unsupported, never relabeled P2P. Evidence: `docs/evidence/ts6-publisher-native.json` (DLL hash and legacy argument assembly addresses), `ts6-publisher-ui-enums.json` (official JS enums/limit logic), and `ts6-official-client.md`. Static reverse engineering is not live server proof. `node scripts/smoke-stream-publish.cjs --out ` runs an always-hidden/offscreen production publisher-to-viewer test using generated canvas and tone only; no capture device or server is opened. Rust unit tests check exact serialization and the real stdio smoke checks parser/dispatch rejection offline. A controlled TS6 server and official viewer are still required for live interoperability verification. ### 4.16 `shutdown` — no args Disconnects cleanly if needed, responds `{}`, exits 0. ### 4.17 Media: `fetch_icon`, `fetch_avatar`, `fetch_banner`, `fetch_server_banner` Read-only downloads over TeamSpeak file transfer from the connected server. No paths cross the bridge: the core derives the server file from ids it already knows. | command | args | server file | limit | |---|---|---|---| | `fetch_icon` | `{icon_id: number}` (u32, non-zero) | `/icon_` in the server root | 256 KiB | | `fetch_avatar` | `{client_id: number}` | `/avatar_` of that visible client (needs `avatar_hash`); myTeamSpeak-only avatar → `external_media` with `detail.urls:[{variant,url}]` | 1 MiB | | `fetch_banner` | `{channel_id: number}` | file referenced by the channel's `banner_url` | 4 MiB | | `fetch_server_banner` | — | file referenced by `server.hostbanner_gfx_url` | 4 MiB | Result: `{"mime":"image/png","bytes":108726,"data":""}`. `mime` is sniffed from the bytes (`image/png|jpeg|gif|webp|x-icon|svg+xml`); anything else → `media_unsupported`. Render only via ``/canvas (SVG included). Cache by `icon_id` / `avatar_hash` / URL. - Icon ids 100, 200, 300, 500, 600 are TeamSpeak's default group icons that clients ship; servers have no file for them (verified live for each: error 2054 `FileInvalidPath`), so the core answers `not_found` with `detail.builtin:true` without asking. Draw built-in glyphs. Every other id is requested from the server. - Banners: `ts3image://?port=

&channel=&path=

&filename=` references are fetched from that channel's file area on the connected server (port must match; `..`/backslashes/control characters rejected). `http(s)://` → `external_media` with `detail.url` for main to fetch (untrusted URL). - At most 3 transfers run at once (the rest queue); each has a 20 s deadline (`io` error). Server refusals surface as `server_error` with `ts_error`. ### 4.18 User context and target-bound actions `client_context {client_id, uid}` requests the connected server's permission catalog and returns `{generation,client_id,uid,is_self,channel_id,is_channel_commander,volume_db, volume_muted,capabilities,server_groups,channel_groups,permissions}`. The UID must match the currently visible client. `generation` changes on reconnect; reuse of a numeric client ID cannot redirect a stale menu operation to another identity. Each capability is `{allowed:true|false|null,reason,source}`. `null` means the server must decide, **not** administrator permission or success. Source evidence is target-specific `notifyclientpermhints`, effective `notifyclientneededpermissions`, and group membership power requirements. No role name, icon or “admin” label grants a capability. Reasons are `server_hint`, `permission_denied`, `server_decides`, `self_only`, `other_only`, or `local`. If catalog retrieval is refused, context still returns known hints with `permission_error`; unknown metadata remains unknown. The server rechecks every protocol mutation. Group rows contain `{id,name,member,can_add,can_remove}`; channel rows additionally contain `can_set`, combining the current group's removal requirement with the new group's add requirement. These fields are capability objects. Only regular server-provided groups are offered. Permission metadata is `{id,name,description}` from `permissionlist`, not a hardcoded server-version-specific numeric table. `client_action` always requires `{client_id,uid,generation,action,...}`. Unknown fields, missing required values and invalid ranges are rejected in both IPC and Rust. | action | additional fields | behavior | |---|---|---| | `poke` | `message` (1–1024 UTF-8 bytes) | `clientpoke`; other clients only | | `connection_info` | none | `getconnectioninfo`; result `{rows:[...]}` | | `commander` | `enabled:bool` | self `clientupdate client_is_channel_commander` | | `server_group` | `group_id,enabled` | `servergroupaddclient` / `servergroupdelclient` | | `channel_group` | `group_id,channel_id` | `setclientchannelgroup`; channel must still match target | | `client_permissions` | none | `clientpermlist`; result `{rows:[...]}` | | `channel_permissions` | `channel_id` | `channelclientpermlist`; result `{rows:[...]}` | | `set_client_permission` | `permission_id,value:i32|null,skip:bool` | explicit value adds/updates; explicit null deletes | | `set_channel_permission` | `channel_id,permission_id,value:i32|null` | channel-client permission add/update/delete | | `kick_channel`, `kick_server` | `reason` (0–1024 bytes) | `clientkick`, reason IDs 4 / 5 | | `ban` | `reason,duration:u32` | `banclient`; duration is seconds (0 permanent) | | `volume` | `db:-200..10 (0.5 steps),muted:bool` | local pre-mix gain 10^(db/20) (−200 = silence), no server mutation | | `avatar` | `data:base64` | self PNG/JPEG, at most 128 KiB decoded | | `move_to_own_channel` | `password?` | target-bound `clientmove` to current own channel; password encoded | | `delete_avatar` | none | target-bound `clientavatardeleted cluid=…`, after explicit UI confirmation | Volume retains the modifier while muted; reset is `{db:0,muted:false}`. It is keyed by native UID bytes for the connection lifetime, not a recycled client ID. Result echoes `{volume_db,volume_muted}`. Persisted modifiers are pushed with `set_local_volumes`; mute is not persisted. Read rows contain source key/value strings; render as text, not markup. Only one client information/permission read is in flight because these notifications are not tagged with the bridge request ID. Connection reads expose `connection_*` fields, not login tokens. Avatar bytes upload through `ftinitupload /avatar`; only after TCP upload completion does the core send `clientupdate client_flag_avatar=`. Success requires the server's command acknowledgement; file-transfer and command errors remain visible. Uploads have a bounded deadline and are canceled on disconnect. File-transfer keys never cross IPC. Protocol mutation results are `{}` only after server acknowledgement. Server refusals include the existing numeric `ts_error` and `missing_permission`; preflight hints cannot override a server rejection. Destructive confirmations belong to the renderer. Tests use escaped protocol fixtures and disconnected subprocess requests, never real participant kicks, bans or permission/group mutations. ### 4.19 Channel file browser: `file_list`, `file_mkdir`, `file_rename`, `file_delete`, `file_download`, `file_upload`, `file_cancel`, `file_transfers`, `file_fetch_image` Legacy TeamSpeak file transfer (`ftgetfilelist`, `ftcreatedir`, `ftrenamefile`, `ftdeletefile`, `ftinitdownload`, `ftinitupload`, `ftstop`), implemented in `core/src/file_transfer.rs` and `core/src/files_session.rs`. Every command needs an established connection (`not_connected` otherwise) and a channel the client can see (`not_found`). The main-only snapshot exception permits `channel_id:0` for listing `/icons/` and transferring `/icons/icon_`; renderer file operations still require a nonzero channel. `channel_password` is optional; it travels as base64(SHA-1), like tsclientlib's own transfers, and an empty one is sent as the bare `cpw` flag. Remote paths are UTF-8, start with `/`, are at most 512 characters, and every component is non-empty, not `.` or `..`, and contains no control character or backslash. A folder path (`file_list`) is normalized to `/` or `/a/b/`. A file or folder path (`file_mkdir`, `file_rename`, `file_delete`, `file_download`, `file_upload`, `file_fetch_image`) has no trailing slash and is not the root. | Command | Args | Result | |---|---|---| | `file_list` | `{channel_id, path, channel_password?}` | `{channel_id, path, entries:[{name, type:"file"\|"folder", size, datetime, incomplete_size?}], malformed, capabilities, storage}` | | `file_mkdir` | `{channel_id, path, channel_password?}` | `{}` | | `file_rename` | `{channel_id, from, to, channel_password?, target_channel_id?, target_channel_password?}` | `{}` (a target channel moves the item between channels) | | `file_delete` | `{channel_id, paths:[1..100], channel_password?}` | `{}` (one `ftdeletefile`, one `name` per entry) | | `file_download` | `{channel_id, path, channel_password?, dest_dir, subdirs?:[..32], overwrite}` | transfer record, `state:"queued"` | | `file_upload` | `{channel_id, path, channel_password?, source, overwrite}` | transfer record, `state:"queued"` | | `file_cancel` | `{transfer_id}` | `{transfer_id, cancelled:true}` | | `file_transfers` | `{}` | `{transfers:[record…], storage}` | | `file_fetch_image` | `{channel_id, path}` | `{mime, bytes, data}` (base64; same pipeline and limits as §4.17 channel banners) | **`file_list` details** - The server's empty-folder answer (error 0x0501 "database empty result set") becomes an empty `entries`. - Rows of `notifyfilelist` are matched by the echoed `return_code`, or else by channel and path. Only one listing per folder may be pending; a second one is `bad_request`. - Arguments sent once for all `|`-joined entries are inherited by the later entries. - A row is counted in `malformed` instead of being returned if any of these hold: the name is invalid, `type` is not `0` (folder) or `1` (file), or size/datetime are not numbers. - More than 10 000 rows is an error, never a truncated list. - The listing fails if the server does not complete it within 20 s. **`capabilities`** are the full-width `u64` channel permission hints (`notifychannelpermhints`): `{known, upload, download, delete, rename, browse, create_directory}`. Unknown hints count as allowed, as in the official client; the server decides. No narrowing cast discards high bits. **`storage`** is `{capability_extensions, httpft, s3, supported}`. It is computed from `virtualserver_capability_extensions` (tapped from `initserver`/`notifyserverupdated`/`notifyserveredited`) using the official substring test. Known `HTTPFT` or `s3` advertisements cause every file operation except transfer inspection/cancellation to fail with `media_unsupported` and storage detail **before any legacy command or local disk side effect**. No UI override falls back to a different store. Unknown/unannounced capability flags retain legacy requests and authoritative server errors; they do not prove newer-storage support. **`file_download` and `file_upload` carry host paths. Only the Electron main process sends them**, built from native dialog results (`app/main/files-main.js`). They are absent from the renderer allowlist. - `dest_dir` is an absolute, existing folder. - `subdirs` are created inside it, never through an existing non-directory or symlink. - Every created name, and the downloaded file name, must be storable on every supported OS. Refused: `/ \ : * ? " < > |`, control characters, a trailing dot or space, and Windows device names such as `CON` or `COM1.txt`. - A download streams into `.teamspeach---….part` in the target folder, is fsynced, and then moved into place. - With `overwrite:false` it never replaces an existing name: it uses an atomic hard link, which fails if the name exists. File systems without hard links fail safely; there is no racy check-then-rename fallback. A conflict is `file_exists` (`detail.name`), both before the transfer and at commit. - With `overwrite:true` (the user confirmed) the move replaces the target. - Any failure or cancel deletes the temporary file. - `source` must be a regular file. Its size is measured once and sent in `ftinitupload`. Exactly that many bytes are streamed; a file that shrinks fails the upload. - With `overwrite:false` a server-side "file already exists" (0x0802) fails the transfer with code `file_exists`. **Transfers** - Main allocates app-global directional slots (default two each, configurable combined maximum ten); at most 512 native records per connection. - Transfer ids are bridge-visible `u32` values, unique per connection. - Lifecycle: `queued` → `starting` (`ftinit*` sent) → `running` (stream granted) → [`confirming`, upload only] → `done` | `failed` | `cancelled`. - A transfer fails with an explicit error in these cases: - no grant within 30 s; - no byte moved for 30 s (`file transfer stalled`); - the connection closes; - a non-success `notifystatusfiletransfer`. - An upload is `done` when either of these happens after the last byte and the write-half shutdown: - the server closes the stream; - status 0x0811 "file transfer complete" arrives. Otherwise it fails after 15 s ("server did not confirm the upload"). - `file_cancel` is refused with `bad_request` in upload `confirming` or once atomic download publication has won the cancellation/commit gate. - Accepted cancellation wins the gate before reporting `cancelled:true`, aborts the stream task, closes the TCP connection, and prevents a queued disk commit from publishing. The blocking disk worker owns temporary-file creation and cleanup; it closes its handle before deleting on Windows. - When the `serverftfid` is known (tapped from `notifystartdownload`/`notifystartupload`; the `ftkey` is never stored or logged), it sends `ftstop serverftfid=… delete=1` for uploads and `delete=0` for downloads. - A grant that arrives after the cancel is dropped and stopped. - Progress is emitted at most every 250 ms while bytes move. Not implemented (explicit limits): - The TeamSpeak 6 `HTTPFT` and `s3` branches. Exact recovered constructor arguments, bounded RIP-relative/native-function continuation, and unresolved endpoint/payload semantics are in `docs/evidence/ts6-filetransfer-native.json` and `docs/evidence/ts6-filetransfer-native-continuation.json`. These are static interoperability evidence, not server acknowledgements. - Resume/pause. - Drag-and-drop upload, because the renderer never holds host paths. ### `file_transfer` (event) `{event:"file_transfer", transfer_id, direction:"download"|"upload", channel_id, path, name, state, bytes, total, error?}`. `state` is one of `queued|starting|running|confirming|done|failed|cancelled`; `error` is an error object (§3), e.g. code `file_exists`, `transfer_cancelled`, `io`, `server_error` with `ts_error`. Records never contain host paths. `total` is 0 for a download until the server reports the size. New error codes (§3): `file_exists` (target name exists and replacing it was not confirmed; `detail.name`), `transfer_cancelled`. Main chooser APIs take the originating `connectionId`, capture its session epoch, and reject delayed chooser completion after a connection change. Renderer chooser and overwrite-confirmation continuations also capture/recheck the originating connection/session before starting an operation. Tokens remain opaque local-path capabilities; deliberate reuse is not prohibited. Offscreen tests use disposable-profile fixture paths and never invoke a native dialog or OS folder opener. Offline regression sources: `test/files-main.test.mjs`, `test/files-renderer.test.mjs`, and `core/src/file_transfer.rs` tests (real loopback TCP transferred bytes/hash, upload/download cancellation, Unicode, empty/short/conflicting files and deterministic cancellation/publication gate). Their existence is not an execution result; final QA records execution after the global freeze. ### File Transfer preferences and app-wide scheduling Official source: installed `html/client_ui/main.js` module `87209` (`SettingsFileTransfer`). It reads singleton workflow settings `alwaysAskForDownload`, `ft_max_parallel_downloads/uploads`, and global native `getTransferSpeedLimit`/`setTransferSpeedLimit`/`updateConcurrentTransferLimits` calls without a connection ID. This supports app-global, not multiplied per-tab, semantics. Source control values: speed 1–25600 MiB/s with 0.5 steps; concurrency at least one each, combined at most ten. Implemented main-owned `files-settings.json` persists `alwaysAsk`, `downloadSlots`, `uploadSlots`, rate toggles and remembered rate values, plus `approvedDownloadDir`. The absolute folder never comes from renderer arguments or generic preference updates: only an explicit main native chooser (or disposable-profile offscreen fixture) writes it. The renderer receives a display basename. Choosing/copying is user-invoked; clipboard and native dialogs are disabled in offscreen tests. An unavailable saved folder fails explicitly instead of switching destinations. If no folder has been approved yet, downloading still asks. IPC: `files:settings/get`, `files:settings/set`, `files:settings/choose-default`, `files:settings/copy-default`. Set accepts only public booleans/numeric controls; unknown fields and out-of-range values fail. Default: always ask, two uploads/two downloads, rate limits disabled, remembered rates 10 MiB/s. Updates persist via temporary-file rename. `TransferScheduler` in `app/main/files-settings.js` tracks native transfer IDs across server cores and allocates directional start slots globally. Native queues retain progress and cancellation while waiting. Start reservations survive event latency, preventing transient duplicate slots. Lowering concurrency does not abort existing/reserved work; those transfers drain before new starts. Closed/reconnected sessions discard obsolete scheduler records. Snapshot upload/download requests pass the same broker. Main-only native `file_config` accepts `{download_slots,upload_slots,download_limit,upload_limit}`. Slot zero pauses new starts; CLI/default core behavior remains two per direction until configured. Rates are integer bytes/second; zero means unlimited. Config requires a connected native session and is absent from the renderer command allowlist. Changing rates updates the shared pacing limiter for already-running transfers; no streams are restarted. Each direction's global byte ceiling is divided conservatively across currently demanded server cores. Every stream in a core shares one async pacing mutex; each TCP read/write chunk acquires a pacing turn (up to 64 KiB). Config decreases apply before increases. The aggregate rate is not multiplied by tabs; bounded bursts are one chunk per participating core, and already-scheduled chunks finish under their prior pacing interval. Unused per-core bandwidth is not borrowed until allocation changes, so this is a conservative ceiling rather than a work-conserving bandwidth optimizer. Downloads with short reads may be slower than the configured maximum, never faster because of short-read accounting. These user file/snapshot transfer limits do not throttle unrelated cached icon/avatar preview fetches. Regression sources: `test/files-main.test.mjs` covers persisted approved destinations and illegal renderer path injection; `test/files-settings.test.mjs` covers cross-core aggregate slots/rates, delayed events, drain-on-reduction and cancellation; `core/src/file_transfer.rs::tests::download_rate_limit_paces_real_bytes_and_can_be_disabled` streams and hashes real loopback TCP bytes and asserts pacing at 1 MiB/s. These tests are prepared; only final QA execution establishes pass status. ### 4.20 Server/channel administration Every mutation below is answered only after its real server command result. Permission hints never manufacture success. Requests capture a server connection ID in main and its native `generation`; stale mutations fail. Read replies are `{rows:[wire-key/string-value objects]}`, not HTML. Only one reader per notification type is allowed in flight; over 10,000 rows fails rather than silently truncating. Empty database/permission-list replies become empty rows. `admin_context {}` returns `{generation,server_uid,own_client_id,catalog_received,permissions,permissions_catalog,permission_error?}`. Permissions are the official named hint values (null if unknown); catalog entries are `{id,name,description}`. | Command | Arguments / result | |---|---| | `channel_create` | `{generation,parent_id,properties}` → `{channel_id}` from own channel-created event | | `channel_edit` | `{generation,channel_id,properties}` | | `channel_move` | `{generation,channel_id,parent_id,order?}` | | `channel_delete` | `{generation,channel_id,force,confirm}`; confirm exact current channel name | | `channel_subscribe` / `channel_subscribe_all` | `{channel_id,subscribe}` / `{subscribe}` | | `channel_description` | `{channel_id}` → `{description}` | | `channel_list` / `channel_info` | `{}` / `{channel_id}`; observed channel wire properties, info refreshes description | | `client_info` | `{client_id,uid}`; checks current UID, requests `clientgetvariables` | | `set_away` | `{away,message?}`; message only when away, ≤80 characters | | `talk_request` | `{request,message?}`; message only when requesting, ≤50 characters | | `talk_power` | `{generation,client_id,uid,grant}`; UID checked against live target | | `server_info` | `{}`; `servergetvariables`/`notifyserverupdated` | | `server_edit` | `{generation,confirm,properties}`; confirm exact server UID | | `ban_list` | `{}` | | `ban_add` | `{generation,ip?,name?,uid?,duration_s,reason?}`; at least one target; 0 seconds permanent | | `ban_delete` / `ban_delete_all` | `{generation,ban_id,confirm}` / `{generation,confirm}`; confirm decimal ID / `all_bans` | | `privilege_key_list` | `{}` | | `privilege_key_add` | `{generation,kind:"server_group"|"channel_group",group_id,channel_id?,description?}`; channel ID iff channel group; → `{token}` | | `privilege_key_use` / `privilege_key_delete` | `{generation,token}` / `{generation,token,confirm}`; confirm exact token | | `temp_password_list` | `{}` | | `temp_password_add` | `{generation,password,description?,duration_s,channel_id?,channel_password?}`; positive duration | | `temp_password_delete` | `{generation,password,confirm}`; confirm exact password | | `server_log` | `{lines:1..1000,reverse,instance,begin_pos}`; `logview` → source rows including `last_pos/file_size/l` | | `client_database_list` | `{start:u32,duration:1..200}` | | `client_database_find` | `{pattern,uid:bool}`; `clientdbfind -details [-uid]` | | `client_database_delete` | `{generation,client_database_id,confirm}`; confirm decimal database ID | | `client_database_id` | `{uid}`; rows with `cluid/cldbid` | | `server_group_list` / `channel_group_list` | `{}` | | `server_group_perm_list` / `channel_group_perm_list` | `{group_id}` | | `channel_perm_list` | `{channel_id}` | | `server_group_client_list` | `{group_id}`; sends `-names` to include UID/nickname | | `group_add` | `{generation,kind:"server"|"channel",name,type:0|1|2}` → `{group_id}`; missing/ambiguous resulting ID fails with created detail | | `group_rename` | `{generation,kind,group_id,name}` | | `group_set_permissions` | `{generation,kind,group_id,permissions:[{id:string,value:i32,negate?,skip?}]}`; 1..512 rows; negate/skip only server group | | `channel_set_permissions` | `{generation,channel_id,permissions:[{id:string,value:i32}]}` | | `server_group_add_client` | `{generation,group_id,client_database_id}` | | `server_group_member_add_uid` | `{generation,group_id,uid}`; official TS6 `vsgroupassignbyids json={version:1,add:[…]}`; short UID uses `migration`, long UID `client_uid`, group ID string | Property allowlists and exact bounds are `core/src/admin.rs` and `app/main/admin-validate.js`: no arbitrary wire fields. Channel passwords are SHA-1/base64 encoded and flag derived; codecs 0..5, quality 0..10; permanence flags mutually exclusive. Main exposes only safe JS integers. Snapshot import reports unrepresentable large integers rather than rounding them. UI `admin.js` supplies Away/status controls, channel and server menus, information views, talk-power queue, changed-only channel/server edit forms, bans/keys/temporary passwords and database/log dialogs. Connection/session/generation are captured before asynchronous work. Destructive actions need explicit confirmation; failed acknowledgements keep the form and error. Database pages are 100 entries; log offsets are explicit. Local server-event history is separate from server log retrieval. ### 4.21 Client-built server JSON snapshots Snapshot export/import is main-owned orchestration in `server-snapshots.js` / `server-snapshot-codec.js`, never a fictitious `serversnapshotcreate` or ServerQuery command. It uses ordinary commands above and confirmed local file dialogs. Exact official schema 0.0.1, options, remapping, confirmations and evidence: [ts6spec-snapshots.md](evidence/official-parity/ts6spec-snapshots.md). Server/channel settings, groups, named permissions, members and icons are independently selected. Import is non-atomic: cancellation and per-item/property errors preserve a truthful partial report, not rollback or complete success. Source-backed modern channel banners, SFU endpoint and storage quota are typed mutations; HTTP/S3 icon transfer failures remain explicit, not silently omitted content. ### 4.22 Whisper routes `whisper_start {epoch:u32,target}` resolves a route against the live connection; epoch must be nonzero. Target is `{kind:"list",entries:[{type:1|2,uuid,name}]}`, `{kind:"group",group_type:0..3,target_mode:0..6,group_id,server_uuid}`, or `{kind:"ids",clients:[{id,uid}],channel_ids:[…]}`. At most 255 resolved clients and channels. `whisper_stop {epoch}` stops that route; `set_whisper_receive {mode:"allow_all"|"deny_all"}` controls incoming whispers. `audio_frame` accepts optional `whisper:epoch`; stale/stopped/other-generation tags drop, never fall back to ordinary voice. Untagged queued frames also drop while a whisper route is held. Transitions end the previous spurt and discard capture queued before the transition. Incoming `whisper_received {client_id}` feeds reply history; receive deny mode removes queued whispers. This is real TeamSpeak whisper packet routing, not local recipient filtering. ### Local recording (`recording_*`) One recorder per core (= per server connection). Nothing is recorded until `recording_start`; recording stops on `recording_stop`, disconnect (`reason: "disconnected"`), a write failure (`"write_failed"`) or core shutdown. While recording, the core sends `clientupdate client_is_recording=1` (others see REC, like the official client) and `=0` when it stops; failures of that update arrive as `error` events (`client_is_recording: …`). | Command | Args | Result | |---|---|---| | `recording_start` | `directory` (absolute, ≤1024 chars, no control chars; created if missing), `mode` 1 Multitrack / 2 Master / 3 Both (official values), `label` optional `YYYY-MM-DD_HH-MM-SS` (session folder name, caller's local time; default UTC with `Z`) | `recording_info` object. Errors: `bad_request` (already recording, bad args), `not_connected`, `recording_failed` (folder/manifest/thread). | | `recording_stop` | — | `{outputPath, finalizing: true}`; files are finalized on a writer thread, then `recording_finalized`. | | `recording_pause` / `recording_resume` | — | `{isRecording: true, isPaused}`. Paused time is not on the timeline. | | `recording_status` | — | `{isRecording, isPaused}` | | `recording_info` | — | official `getRecordingInfo` fields: `isRecording, isPaused, mode, startTimeEpochMs, outputPath, sampleRate (48000), peakBucketFrames (960), timelineFrames, droppedChunks, droppedCaptureFrames, totalBytes, error, tracks[{id, kind: client\|capture\|master, uid (base64), name, instance, file, startOffsetFrames, timelineFrames, audioFrames, bytes}]`; `{isRecording:false}` when idle. | | `recording_waveform` | `track_id`, `from_bucket` | `{trackId, fromBucket, nextBucket, totalBuckets, bucketFrames, peaks[0..1000]}` (≤2000 per call, last 6000 kept). | Events: `recording_state {isRecording, isPaused, outputDirectory, mode, reason?, error?}`, `recording_dropped {droppedChunks}` (first dropped tick after a good one), `recording_finalized {outputPath, ok, error, totalBytes}`. Files (`/