A page artifact with runtime_version: 2 runs as an app. This page covers what the page can call, how it declares what it needs, the sandbox it runs in and the routes behind it. For the artifact record itself see the Artifacts v2 API.

Sandbox

The page’s HTML runs in an iframe inside the MCP sandbox proxy (mcp-sandbox-proxy/sandbox.html), served from a different origin than the app (VITE_MCP_SANDBOX_ORIGIN). If that origin is missing, or is the same as the app’s, the page does not run and the viewer shows an error. There is no fallback to the app’s own origin. The host accepts a message only when it comes from the iframe it created and from the sandbox origin, validates its shape, and drops anything else without a reply. At most 32 requests per page are in flight at once.

Declaring what the page needs

A page declares its capabilities with a meta tag:
connector is the connector id. A page can only call tools it declared. Calls to allternit.storage.* and allternit.ai.complete in the page’s own script also count as use, so leaving the tag out doesn’t hide them from the sharing rule. Connector tools can only be declared. The record’s capabilities is what the server and the share dialog read. It is set when the artifact is created (from capabilities, or from meta.capabilities when only that is given) and kept in step by the owner’s copy of the page when it opens. Editors and viewers never change it. Because capabilities.ai or a non-empty capabilities.connectors marks a page as unsharable by link, the link visibility is refused for it (422 link_not_allowed), on the server and in the share dialog.

window.allternit

Version 1. The object is frozen. All calls return promises and reject with an Error whose name is AllternitError and whose code is one of the codes below.

Errors

Wire format

The client script (src/lib/artifacts/runtime/client-script.ts) and the host (host.ts) speak this over postMessage:
Methods: storage.get, storage.set, storage.delete, storage.list, ai.complete, connectors.list, connectors.call. The page replies are accepted only from the page’s parent window.

Routes

All routes sit under /api/v2/artifact-runtime/{id} and need a signed-in caller with at least view access to the artifact. No access answers 404. Only page and card artifacts at runtime_version 2 run apps; anything else is 409 with legacy_artifact or not_a_page. The storage routes also serve image (and video) artifacts that declare storage: true — the craft editors keep their layered source documents there; for those kinds storage is allowed but AI and connectors stay 409 not_a_page. Rules the server enforces:
  • A capability must be declared on the record, or the call is 409 capability_not_declared.
  • Storage is 20 MB of text per artifact across both scopes and all viewers. Writes take a per-artifact lock so concurrent writes can’t pass the cap. Personal keys are per viewer. Shared keys are visible to everyone who can open the artifact.
  • A shared write or delete needs the viewer’s storage_shared consent first (403 consent_required, with capability).
  • AI needs ai consent. It goes through the hosted model router with the viewer’s credits or free allowance, with the same checks as /v1/chat/completions. The owner is never charged. Prompts are limited to 100,000 characters and 40 messages, and output to 4,096 tokens. The model is chosen by Allternit (ARTIFACT_RUNTIME_MODEL), not by the page.
  • AI and connectors are refused for viewers outside the artifact’s org (403 outside_invitee) and when the org turned them off (403 org_disabled). Signed-out callers get 401.
  • Connector calls don’t pass through cloud-api. They run in the app through the MCP Apps bridge with the viewer’s connector credentials, after the host checks the declaration, the viewer’s consent and per-tool switches, and that the tool doesn’t ask for approval each time.

Org settings that apply

enabled off stops pages running for that org’s artifacts. connectors off stops connector calls in pages. external_sharing and allowed_external decide link sharing. See Organization settings.

Code

  • App: allternit-ai/src/lib/artifacts/runtime/ (protocol, client script, host, capabilities, API client) and src/components/artifacts/runtime/ (PageRuntimeFrame, ConsentSheet).
  • Org admin: src/components/settings/OrgArtifactsSettings.tsx.
  • Server: cmd/allternit-cloud-api/src/artifacts/runtime.rs (rules) and src/routes/artifact_runtime.rs (routes).