This reference describes host interfaces available in official releases, with version differences noted in the relevant sections. See the Client API guide for examples and Capabilities and progress for version support.The host injects A successful reply contains the full Returns a boolean synchronously without asking for permission or making an async host call. Unknown names return
Entry and availability
window.mcode into a managed Mini App’s main page through preload. No runtime SDK or plugin ID is required. Ordinary browsers, other pages, and older hosts may omit these objects, so check before calling.The v3.1.6 main page exposes the namespaces below. Presence does not establish a manifest declaration or an enabled permission: permission-protected calls are checked against page identity, declarations, and switches. Node uses the separate Node API.Page async APIs reject with a lowercase code in
Error.message. Do not rely on Node-style code, retryable, or disposition fields; see the page error convention.message.append
Every call opens host confirmation, with no remembered choice. Even an empty string needs confirmation, but leaves the draft unchanged. After confirmation, the host preserves existing text, references, and attachments, and appends the new text. Resolution means the append completed, not that a message was sent or an Agent ran.The target is the local, writable session containing the page. An unavailable target does not fall back to another session, a home draft, or a new session. This API grants no session reads and cannot change sent messages. There is no page cancellation parameter; the user can refuse the confirmation. After
result_unknown, inspect the input before deciding to retry.Errors are user_cancelled, invalid_request, text_too_large, not_allowed, target_unavailable, and result_unknown; see Error codes.window
The window handle interface may change, so feature-detect before use. It controls only its calling page’s window.id is a stable opaque string, not a session or run ID; popping out or returning to the file panel does not change it.State fields
getState() takes no arguments. inline means the page is in the file panel, with no window field. window means a separate window, with every field below.Either state may also return a top-level modeChangeReloadsPage field indicating whether a mode change rebuilds the page; see Page rebuilds and confirmation.update(patch)
MiniAppWindowState. All fields are optional; omitted or undefined fields remain unchanged, and an empty object is valid. Unknown fields, wrong types, and non-finite numbers fail with invalid_request. In v3.1.10, cancelling window-transfer confirmation resolves with the current state and the original mode: a successful reply does not prove that the requested mode took effect. See Page rebuilds and confirmation.When updating
x, y, width, or height, the host checks the final content rectangle after rounding and applying minimum dimensions. It must overlap the same display work area by at least 40 px on both axes; otherwise the update fails with not_permitted. This rule also applies to size-only updates, not just window moves.Updates without mode in the same animation frame are merged, with later fields winning. All callers in that frame share one result or rejection. A mode update is sent immediately to preserve its user gesture.focus()
Takes no arguments and returnsPromise<void>. A user gesture is required. A separate window is restored from minimization, shown, and focused; an inline page requests host focus and selects its own tab. Do not rely on it to expand a collapsed file panel. It does not create a page or control another Mini App.onDidChangeState(listener)
Synchronously returns{ dispose() }. A non-function listener synchronously throws Error('invalid_request'). An update() delivers state if the current document remains alive and receives a successful reply. This does not prove that mode changed; inspect the delivered state. While the document remains alive, periodic checks detect external changes such as dragging a window, with no guarantee of every intermediate state. Initial subscription does not immediately deliver an initial value; call getState() for one.Call dispose() to unsubscribe; leaving the page also clears listeners. A throwing listener does not interrupt a window update. Window errors are inline_mode, not_permitted, busy, result_unknown, and invalid_request. After result_unknown, use getState() to reconcile; see Window errors.Page rebuilds and confirmation
Official releases from v3.1.9 may return the optionalmodeChangeReloadsPage?: boolean field. Check the runtime result of getState(); this field is not an update patch option. When it is true, an actual change between inline and window rebuilds the page. Hosts that move the native page do not return this flag, so not every window transfer reloads the page.A rebuild preserves the logical window ID and Node service, but the current document, JavaScript memory, media streams, page subscriptions, and pending page Promises do not survive. Save necessary state first. Do not put required work after await update({ mode }) or wait for the old document’s onDidChangeState to confirm completion. When the destination document starts, call getState(), restore saved content, and subscribe again. An absent flag does not guarantee that a host reload, crash, or another page-ending event cannot end the document.From v3.1.10, popping out or returning a page that requires rebuilding first displays the impact in the main host window and waits for user confirmation. Closing the separate window or pressing Cmd/Ctrl+W uses the same flow; the original window is not hidden or destroyed while waiting. Cancellation leaves the page, requests, and window intact. update() resolves with the current state, whose mode may still be the original value, rather than rejecting with user_cancelled. After confirmation, the old page’s requests and subscriptions are cancelled or cleaned up when the page ends. Completed operations are not undone, and requests are not replayed automatically.speech.transcribe
Declare
deviceAccess: ["microphone"] and keep its switch on. The page captures audio, chooses the utterance boundary, converts samples, and stops all media tracks. The host transcribes the complete utterance; onPartial is not live recognition while recording. Do not pass WAV, WebM, Ogg, FLAC, MP3, or MediaRecorder output directly.Only one transcription per Mini App can run at once; another gets busy. There is no page signal or cancel() parameter. Ending the page aborts the in-flight transcription, and host processing has a 180-second deadline. Switching microphone access off refuses later calls without forcibly stopping a media stream the page already owns.Errors are invalid_request, not_permitted, audio_too_large, busy, runtime_unavailable, transcription_failed, and result_unknown; see Speech errors. See the guide for recording examples.tool.request
Declare
toolAccess: ["call"], keep the Node service running, and invoke directly from a user gesture. The host asks only about tools still at ask, letting the user tick which to always allow. Leaving a box unticked or refusing does not necessarily reject the entire request: it returns actual permissions. Entries already allow or deny are not changed by this request.When the tool-calling switch is off, the method returns deny for every requested name without a prompt. Without toolAccess there is no usable tool session; an unavailable Node tool session or channel rejects with runtime_unavailable. The page has neither tool list() nor call(), nor a cancellation parameter for this method. Actual calls use the Node tool API, and the host judges permission again on every call.Errors are invalid_request, not_permitted, approval_required, runtime_unavailable, and result_unknown; see Tool permission errors. Read the rejection’s Error.message; do not rely on the permissions field attached to Node-side errors.capabilities.has
false; a non-string passed at runtime also returns false. Older hosts may omit capabilities, so use miniapp?.capabilities?.has(name).This table lists all 14 names in v3.1.6. It is fixed per host version and shared by the page and Node. true means the host implements the feature, not that the current side has that object, the manifest declared it, or the user granted it.agent.reply, agent.answer, and agent.cancel are not separate capability names; do not probe those names to infer method support. Check each API’s availability and permission requirements as well.Agent namespace
For pageminiapp.agent methods (run, reply, answer, cancel, open, catalogs, and session observation), including parameter differences from Node, see the Agent API reference.Camera and system notifications
These capabilities are supported from MiniMax Code v3.1.9. They use standard browser APIs, with no new host namespace or capability-detection name. Declare the minimum version inengines.mcode and the required items in deviceAccess; users can turn access off in plugin details.A combined audio/video request requires both
microphone and camera to be declared and enabled. Turning a permission off blocks new capture requests; the page must still stop media streams it already holds. Standard capture errors, such as NotAllowedError, come from the browser API and do not use host speech-transcription error codes.A notification click handler can call the window handle’s focus() while the original page remains alive. Do not rely on it to expand a collapsed file panel. After that page closes or reloads, an old notification cannot reopen it. This API does not provide background notifications after the page closes.See the Camera and System notifications guides for examples and limits.