Skip to content

Latest commit

 

History

History
396 lines (339 loc) · 24.3 KB

package-contract.md

File metadata and controls

396 lines (339 loc) · 24.3 KB

Mini App package contract

Verified against MiniMax Code 3.1.21. The mcpEndpoints rule was read off the 3.1.14 reader; the 3.1.4 reader is identical.

A Mini App is a MiniMax Plugin whose package.json declares a Mini App payload. MiniMax Code enforces the manifest, payload, and path rules below when the package is installed. npm run check enforces the same rules here, plus this repository's own requirements: README.md and LICENSE, a real image file behind icon, lifecycle limited to on-demand, no hard links, no committed node_modules, routes outside the Host-reserved /__mavis/ prefix, the Node entry conventions in docs/runtime.md, a stated minimum client version for newer features (see Minimum client version), and code that matches the declared permissions and target version (see Declared access must match the code).

Layout

<plugin-id>/
  .minimax-plugin/plugin.json   Plugin manifest: identity, icon, category, declared capabilities
  package.json                  Mini App declaration (see below)
  icon.png                      Plugin icon (PNG, JPEG, or WebP)
  miniapp/
    miniapp.json                Payload roots, Node entry, page route, permissions
    client/                     Runtime payload: files served to the page
    node/                       Runtime payload: the Node entry and what it imports
  README.md                     Required by this repository
  LICENSE                       Required by this repository
  README.zh-CN.md               Optional
  tests/                        Optional; keep outside miniapp/
  skills/<name>/SKILL.md        Optional plugin capability
  agents/<name>.md              Optional plugin capability (MiniMax Code 3.1.2 or later)
  *.mcp.json                    Optional plugin capability
  bindings/<name>.binding.json  Optional plugin capability

The directory name, plugin.json.name, and the installed plugin ID are the same string. It must be unique across this repository because the author directory is dropped at install time.

Git does not keep empty directories. Every path listed under artifacts must contain at least one committed file.

.minimax-plugin/plugin.json

Field Rule
$schema Optional string.
schemaVersion The number 1.
name At most 80 characters, matches ^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$, equals the directory name.
displayName Optional non-empty string.
version SemVer 2.0, at most 128 characters.
description, author Non-empty strings.
icon Relative path with a lowercase .png, .jpg, .jpeg, or .webp extension; the file must exist and be a real image.
darkIcon Optional; same rules as icon.
category One of Office, Studio, Design & Sites, Code, Business, Sales, Productivity, Science & Healthcare, Education, Other.
exampleQueries Array of non-empty strings. Provide at least one; the Agent uses them to open the Mini App by name.
apps Array of *.app.json paths; each file must exist and be { "schemaVersion": 1, "provider": "<id>" } (plus an optional $schema), with provider matching ^[a-z0-9_-]{1,64}$ and unique across the files. Each names a Connector app the plugin works with. From MiniMax Code 3.1.9 the plugin details list them with their connection status, and the client skips an entry that is missing, invalid, or repeats a provider instead of refusing the package; earlier clients ignore the field.
mcpServers Array of *.mcp.json paths; each file must exist. These are MCP servers the plugin offers to the Agent, distinct from mcpEndpoints in miniapp.json. The server names come from each file's mcpServers map.
skills Array of skills/<name>/SKILL.md paths; each file must exist.
hooks Optional array of *.json paths; each file must exist. Contents are validated by MiniMax Code at install time.
hostBindings Optional array of bindings/<name>.binding.json paths; each file must exist. Contents are validated at install time.
agents Optional array of agents/<name>.md paths (<name> matches ^[a-z][a-z0-9_-]*$); each file must exist. Subagents the plugin adds; contents are validated at install time. Requires MiniMax Code 3.1.2 or later.
hostCapabilities Rejected. Host capabilities come only from Host Bindings.
Any other field Rejected. MiniMax Code 3.1.2 and later ignore unknown fields, but earlier clients reject the whole package.

Use [] for apps, mcpServers, and skills when the package has none.

package.json

The mcode field must be exactly:

{
  "mcode": {
    "schemaVersion": 2,
    "miniApp": "./miniapp/miniapp.json"
  }
}

No other keys are allowed inside mcode. Other top-level keys (name, type, scripts) are fine.

miniapp/miniapp.json

{
  "schemaVersion": 1,
  "artifacts": {
    "client": ["./miniapp/client"],
    "node": ["./miniapp/node"]
  },
  "runtime": {
    "kind": "process",
    "entry": "./miniapp/node/server.mjs",
    "lifecycle": "on-demand"
  },
  "surface": { "path": "/dashboard" },
  "mcpEndpoints": []
}
  • schemaVersion is 1. Unknown top-level fields are rejected: MiniMax Code 3.1.6 and later report MINIAPP_MANIFEST_FIELD_UNSUPPORTED naming the field, which on an installed client means the client is older than the package; earlier clients report MINIAPP_MANIFEST_INVALID.

  • artifacts.client and artifacts.node are non-empty arrays of unique paths under miniapp/. Each path must exist. These are the runtime payload roots: exactly what MiniMax Code hashes and installs. Any node_modules directory is excluded from payloads.

  • runtime.kind is process. runtime.entry ends in .js, .mjs, or .cjs, exists, and lies inside one of artifacts.node. Use .mjs: this repository checks the entry for an ESM start export (see docs/runtime.md). runtime.lifecycle is on-demand or omitted. The Host may stop the process and reload the page while the Mini App is not visible (see "Lifecycle" in docs/runtime.md).

  • surface.path is the route the Node entry serves the page on. It is relative to the Host and must not contain an origin, query, fragment, or backslash. A missing leading / is added.

  • surface.window is optional; see surface.window. surface.widget ({ "kind": "display" | "interactive", "size": "small" | "medium" }) is accepted from MiniMax Code 3.1.15, though the desktop Mini App Pad currently opens surface.path directly and renders no compact widget view, so new packages should omit it.

  • mcpEndpoints is an array of { "server": string, "path": string }. server matches ^[a-zA-Z0-9_-]{1,128}$ and must name a server declared through plugin.json.mcpServers; npm run check reports a server that no *.mcp.json declares as MINIAPP_MCP_ENDPOINT_UNDECLARED, and MiniMax Code checks the same reference at install time. server and path are each unique. Use [] when there are none.

  • fileHandlers is optional (MiniMax Code 3.1.18 or later); see fileHandlers.

  • No route (surface.path, an MCP endpoint path, or a fileHandlers path) may be /__mavis or start with /__mavis/. The Host owns that prefix and answers some of it itself.

  • permissions is optional (MiniMax Code 3.1.20 or later) and declares every switchable grant as plain string arrays grouped by namespace:

    {
      "permissions": {
        "agent": ["run"],
        "session": ["read"],
        "tool": ["call"],
        "device": ["microphone", "camera", "notifications"],
        "host": ["navigation.read"],
        "connector": ["notion"]
      },
      "engines": { "mcode": ">=3.1.20" }
    }
    • agent: ["run"] — run Agent turns in this Mini App's own sessions through context.agent or window.miniapp.agent (see docs/agent.md).
    • session: ["read"] — list, read, and observe the user's own conversations through context.session or window.miniapp.session (see docs/agent.md). Neither grant implies the other; declare both when the Mini App needs both. Reading or observing this Mini App's own sessions works with either agent: ["run"] or session: ["read"].
    • tool: ["call"] — call installed MCP and Connector tools through context.tool, judged by the user's permission rules (see docs/tool.md).
    • device: "microphone" (getUserMedia({ audio }) and window.miniapp.speech.transcribe), "camera" (getUserMedia({ video })), and/or "notifications" (new Notification(...)). See "Browser permissions" in docs/client.md.
    • host: ["navigation.read"] — observe which public Host view the user is on through window.miniapp.host.navigation (see docs/client.md). Reading theme and language, and opening known Host entries from a user gesture, need no grant.
    • connector: unique provider IDs matching ^[a-z0-9_-]{1,64}$, granted by the Host at install time for context.connector (provider runtime details are outside this repository's docs).

    Unknown groups, unknown items, or duplicate items fail with MINIAPP_PERMISSIONS_INVALID. Declare permissions or the legacy *Access fields (see Legacy <3.1.20 compatibility), never both: mixing permissions with any legacy *Access field fails with MINIAPP_PERMISSIONS_INVALID.

  • agentConcurrency is optional: an integer from 1 to 32, default 4. It caps how many Agent turns of this Mini App run at once; it has no effect without an Agent grant. Requires MiniMax Code 3.1.2 or later.

  • engines is optional: { "mcode": ">=MAJOR.MINOR.PATCH" }, nothing else. Write "engines": { "mcode": ">=3.1.20" } whenever the manifest or code uses a 3.1.20 name (permissions, window.miniapp, session.*, agent.list, host.composer.append, context.connector); omit it when the package uses none of them or intentionally targets older clients with legacy spellings. A client that knows engines (3.1.6 or later) and can parse the rest of the manifest, but is older than the bound, keeps the plugin's standalone Skills and MCP servers, withholds the Mini App and its mcpEndpoints, and fails workspace publishing with MINIAPP_HOST_TOO_OLD. Note that unknown manifest fields such as permissions fail earlier in the reader with MINIAPP_MANIFEST_FIELD_UNSUPPORTED on clients before 3.1.20, whereas a package without 3.1.20 manifest fields that calls window.miniapp relies on engines.mcode to keep older clients from installing a broken page.

Permission switches

The user can switch off, item by item in the plugin details, every item the manifest declares: agent:run, session:read, tool:call, device:<item>, host:navigation.read, and connector:<provider>. Everything starts on, with no first-use prompt and no browser permission prompt. A switch applies at once without restarting the Mini App.

On MiniMax Code 3.1.20 and later, every namespace stays present and distinguishes undeclared grants (NOT_PERMITTED — an author-fixable packaging or call-context mistake) from switched-off or denied grants (PERMISSION_DENIED — the user's choice):

State or switched-off item What happens on 3.1.20 and later
Grant not declared in miniapp.json Node calls reject with NOT_PERMITTED; page calls reject with { code: 'NOT_PERMITTED', message: 'not_permitted' } (including tool.request()).
agent:run switched off Running turns end as aborted; run, reply, answer, open, models, list, create reject with PERMISSION_DENIED (permission_denied in message). Page agent.cancel still works.
session:read switched off Observers end; session.list(), session.observe({ all: true }), and reading or observing the user's sessions reject with PERMISSION_DENIED. Own sessions stay readable when agent:run is on.
tool:call switched off context.tool.call rejects with PERMISSION_DENIED (and so does a tool denied by a rule or prompt); list() and request() resolve with deny for every tool without prompting.
connector:<provider> switched off context.connector.list() omits that provider; call() rejects with PERMISSION_DENIED.
device:microphone switched off The next getUserMedia rejects with NotAllowedError and speech.transcribe rejects with PERMISSION_DENIED; an open stream keeps running until the page stops it.
device:camera switched off The next getUserMedia asking for video rejects with NotAllowedError; an open stream keeps running until the page stops it.
device:notifications switched off New notifications are not shown, and Notification.permission reads denied.
host:navigation.read switched off Navigation subscriptions end through onError with PERMISSION_DENIED; getState() and new subscriptions reject with PERMISSION_DENIED. Subscribe again once it is back on.

Handle PERMISSION_DENIED and NotAllowedError where the call is made and explain in the page what the user can turn back on in the plugin settings. surface.window flags are not switches.

fileHandlers

Optional (MiniMax Code 3.1.18 or later). Declares which file extensions can open in this Mini App and which route a newly opened tab starts on:

{
  "fileHandlers": [
    { "id": "model-3d", "path": "/viewer", "extensions": [".stl", ".step"] }
  ]
}
  • Non-empty array of at most 256 handlers; each entry has only id, path, and extensions (MINIAPP_FILE_HANDLERS_INVALID).
  • id matches ^[a-z0-9-]{1,32}$ and is unique across the manifest.
  • path follows the surface.path rules, is at most 4096 characters without control characters (MINIAPP_ROUTE_PATH_INVALID), and stays outside /__mavis/ (MINIAPP_ROUTE_RESERVED).
  • extensions is a non-empty array of at most 256 lowercase dotted extensions matching ^\.[a-z0-9]{1,16}$, unique across the entire manifest, with at most 512 extensions in total.
  • Files are delivered to the page through window.miniapp.files.subscribe (see docs/client.md). Code-editor extensions (.json, .yaml, .ts, Makefile, etc.) stay with the built-in editor; extensions that already have a built-in preview show an "Open with" chooser unless the user saved a default.

surface.window

Optional. It declares the window MiniMax Code opens when the user pops the page out of the side panel into its own window. Requires MiniMax Code 3.1.2 or later.

{
  "surface": {
    "path": "/dashboard",
    "window": {
      "width": 960,
      "height": 700,
      "minWidth": 480,
      "minHeight": 360,
      "resizable": true,
      "frame": true,
      "transparent": false,
      "alwaysOnTop": false,
      "skipTaskbar": false,
      "clickThrough": false
    }
  }
}
Field Rule Default when omitted
width, height Integer from 200 to 10000. The page's last size in the side panel.
minWidth, minHeight Integer from 200 to 10000; not larger than width / height when both are given. 480 / 360
resizable Boolean. true
frame Boolean. true
transparent Boolean. true requires frame: false. false
alwaysOnTop Boolean. Also the ceiling for turning it on from the page at runtime. false
skipTaskbar Boolean. false
clickThrough Boolean. Mouse events pass through to whatever is underneath; the page still receives mouse moves. Also the ceiling for turning it on from the page at runtime. false
Any other field Rejected. Title, position, parent window, and close behaviour are always set by the Host.

The window never opens at launch: it opens when the user pops the page out, or when the page switches to it from a user gesture through window.miniapp.window (see docs/client.md). Closing it, or Cmd/Ctrl+W, returns the page to the side panel.

Legacy <3.1.20 compatibility

Packages that must keep loading on MiniMax Code before 3.1.20 omit permissions and any >=3.1.20 engines.mcode bound, and use the legacy manifest fields and runtime aliases consistently:

Legacy spelling (<3.1.20) 3.1.20 replacement Minimum when using legacy field
agentAccess: ["session.run"] permissions.agent: ["run"] 3.1.2
agentAccess with "session.read" permissions.session: ["read"] 3.1.6
toolAccess: ["call"] permissions.tool: ["call"] 3.1.6
deviceAccess: ["microphone"] permissions.device: ["microphone"] 3.1.6
deviceAccess with "camera" or "notifications" permissions.device 3.1.9
hostAccess: ["navigation.read"] permissions.host: ["navigation.read"] 3.1.11
hostConnectorAccess: { "providers": [...] } permissions.connector: [...] 3.1.2
window.mcode.miniapp.* window.miniapp.* —
message.append(text) host.composer.append(text) —
agent.agents() agent.list() —
agent.sessions(), agent.session(id?), agent.observe(...) session.list(), session.get(id?), session.observe(...) 3.1.6
context.hostConnector context.connector —
TOOL_NOT_PERMITTED, CONNECTOR_NOT_PERMITTED PERMISSION_DENIED (removed without aliases in 3.1.20) —

MiniMax Code 3.1.20 and later still accept the legacy manifest fields without reader diagnostics (unless mixed with permissions), keep the legacy runtime method aliases with a one-time warning, and preserve the legacy Error / lower-case { code, message } rejection shapes behind window.mcode.miniapp. Node TOOL_NOT_PERMITTED and CONNECTOR_NOT_PERMITTED were removed in 3.1.20 in favour of PERMISSION_DENIED.

Minimum client version

Clients older than the version below reject the whole package when it declares the feature, so the package cannot be installed there at all.

Feature Declared in Minimum MiniMax Code
agents plugin.json 3.1.2
surface.window miniapp/miniapp.json 3.1.2
agentConcurrency miniapp/miniapp.json 3.1.2
agentAccess (legacy) miniapp/miniapp.json 3.1.2 (3.1.6 with "session.read")
engines miniapp/miniapp.json 3.1.6, or its own bound when higher
toolAccess (legacy) miniapp/miniapp.json 3.1.6
deviceAccess (legacy) miniapp/miniapp.json 3.1.6 (3.1.9 with "camera" or "notifications")
hostAccess (legacy) miniapp/miniapp.json 3.1.11
surface.widget miniapp/miniapp.json 3.1.15
fileHandlers miniapp/miniapp.json 3.1.18
permissions miniapp/miniapp.json 3.1.20

Each minimum is the first MiniMax Code release with installers for both macOS and Windows. 3.1.5 shipped no installers and 3.1.8 none for Windows, so neither is ever a minimum. Preview builds do not count either: they can accept a field before the release that ships it.

The package's minimum is the highest entry it declares. When it has one, name a MiniMax Code version at or above it under ## Tested environment in its README, for example - MiniMax Code 3.1.20 on macOS 15. npm run check warns until it finds one there. A pre-release such as 3.1.20-preview.1 ranks below 3.1.20.

To use a newer page or Node API only where it exists, without raising the minimum, feature-detect it: capabilities?.has('session.list'), or fall back across window.miniapp ?? window.mcode?.miniapp. A manifest field cannot be feature-detected: declaring it is what raises the minimum.

Declared access must match the code

npm run check scans the files that run in the page or in Node (.js, .mjs, .cjs, and executable <script> / on* code in .html and .htm under artifacts.client and artifacts.node, outside node_modules) and reports mismatches:

Check Diagnostic Level
agent run, answer, reply, open, models, list (agents), create without permissions.agent: ["run"] ACCESS_UNDECLARED error
session.list(), session.observe({ all: true }), page session.get() without an id (or their legacy agent.* forms) without permissions.session: ["read"] ACCESS_UNDECLARED error
session.get(id), session.observe({ sessionId }) (or legacy agent.session(id), agent.observe({ sessionId })) on own sessions with neither agent: ["run"] nor session: ["read"] ACCESS_UNDECLARED error
context.tool.*, page tool.request() without permissions.tool: ["call"] ACCESS_UNDECLARED error
context.connector.* (context.hostConnector.*) without permissions.connector ACCESS_UNDECLARED error
speech.transcribe() without permissions.device: ["microphone"] ACCESS_UNDECLARED error
page host.navigation.getState(), host.navigation.subscribe() without permissions.host: ["navigation.read"] ACCESS_UNDECLARED error
getUserMedia({ audio }), getUserMedia({ video }) without matching permissions.device ACCESS_UNDECLARED error when minimum >= 3.1.6; warning otherwise
new Notification(), Notification.requestPermission() without permissions.device: ["notifications"] ACCESS_UNDECLARED error when minimum >= 3.1.6; warning otherwise
Classic <script> (no type="module") declaring a top-level miniapp binding CLIENT_GLOBAL_MINIAPP error
Package minimum >= 3.1.20 still calling deprecated window.mcode.miniapp, message.append, agent.agents/sessions/session/observe, or context.hostConnector DEPRECATED_API warning
Package minimum >= 3.1.20 checking removed TOOL_NOT_PERMITTED or CONNECTOR_NOT_PERMITTED REMOVED_ERROR_CODE warning
Package minimum < 3.1.20 using 3.1.20 APIs (window.miniapp, session.*, agent.list, host.composer.append, context.connector) with no window.mcode or capabilities.has fallback ENGINES_MIN_VERSION_MISSING warning

Page agent.cancel(requestId) needs no grant so read-only session observers can cancel cleanly. The scan matches source text (and parses classic <script> bindings with V8 without executing code), so it misses calls through renamed variables and can flag dormant code, such as an engine's audio input that the app never turns on. Explain a warning in the pull request instead of declaring a permission the app does not use.

Portable paths

Every path inside the package, and every path written in a manifest, must be portable:

  • ASCII only; each segment matches [A-Za-z0-9._-]+ and does not end with ..
  • No . or .. segments, no backslashes, no leading or trailing /, no control characters.
  • Each segment at most 128 bytes; the whole path at most 512 bytes and at most 16 segments.
  • A segment's part before its first . must not be a Windows reserved name (con, prn, aux, nul, com1–com9, lpt1–lpt9).
  • No symbolic links or hard links anywhere in the package, and the package directory itself is not a symbolic link.
  • No two paths in the package may differ only in letter case. The Host keeps one name per path prefix, folded to lower case, and refuses a package where two of them land on the same name: README.md and Readme.md collide, and so do docs/preview.png and docs/Preview.png. npm run check reports the same pair as PATH_CASE_COLLISION.

A path in plugin.json (icon, darkIcon, apps, mcpServers, hooks, skills, hostBindings, agents) is checked with the same rules as a path in miniapp.json: sub/../icon.png and ../shared/icon.png are errors even when the file they resolve to exists. npm run check reports them as MANIFEST_FIELD_INVALID for icon and darkIcon, and as MANIFEST_REFERENCE_INVALID for the other six fields, and it checks the path before it looks for the file on disk.

Text encoding

Every file the Host reads as text must be UTF-8. The Host decodes those with a decoder that refuses anything else, so a manifest saved in another encoding is not repaired on the way in: the package does not install. npm run check decodes the manifests, and the app files they point at, the same way — MANIFEST_UNREADABLE, MCODE_UNREADABLE, MINIAPP_UNREADABLE, or MANIFEST_APP_INVALID, depending on which file it was reading.

Package limits

At most 1024 files, 16 MiB per file, and 64 MiB in total.

Runtime payload

Only artifacts.client and artifacts.node become the runtime payload. Keep tests, docs, and source-only files outside miniapp/. Vendor any third-party runtime code inside a payload root; node_modules is never committed to this repository.