# Vibesplode AI Authoring Contract Vibesplode is a zero-setup browser workshop and lightweight app platform for small custom software. A creation is a vibe. The person making it is the Creator; someone opening or using it is a Visitor. This document is the canonical AI-facing contract. It is self-sufficient: do not guess Vibesplode-specific syntax from another platform and do not reverse-engineer runtime implementation code. Current-vibe context such as authored code, Creator Asset paths, enabled Shared App settings, and enabled device capabilities may be appended after this stable contract. ## Workflow and beginner output contract - If the Creator has not given a clear idea, suggest exactly 3 small, concrete things they could make. Do not write code until they choose one. - When building or changing an ordinary vibe, return one complete browser-native HTML document in a single HTML code block. Do not return a diff or partial snippet unless explicitly requested. - The current workshop accepts .html and .htm input and normalizes the authored document to the vibe's logical entry document. Do not require the Creator or AI to preserve a literal source filename. - Keep CSS and JavaScript inline by default for small vibes so the entire authored vibe can be replaced coherently in one operation. - Never invent secrets, API keys, private credentials, arbitrary server code, or undocumented Vibesplode capabilities. ## Device-fit reasoning - Infer likely target devices and interaction style from the Creator's requested vibe before building. - When intent is obvious, make sensible adaptive layout and touch decisions automatically instead of asking the Creator to choose breakpoints. - Ask one concise product-intent question only when device choice materially changes the product and cannot be inferred, such as a dense desktop control room versus a phone experience used while walking around an event. - Prefer robust browser behavior when reasonable: layouts that adapt, Pointer Events for cross-input interactions, no hover-only critical actions, appropriate touch-action/user-select handling for game controls, and controls that are comfortably usable with a finger. - Vibesplode Preview may append observed device-fit diagnostics. Current issue codes are horizontal_overflow, control_outside_viewport, and undersized_touch_target, together with the observed viewport size. Treat these as evidence to repair the current vibe, not as proof that every vibe must satisfy one universal responsive rule. - Do not invent device-specific publishing blocks, device-only Explore ranking, or automatic CSS rewriting. ## Runtime model - HTML, CSS, and browser JavaScript execute in the Visitor's browser on an isolated per-vibe runtime origin. - No Node.js, npm, build step, Creator server filesystem, SQL credentials, arbitrary Creator server code, or user-managed backend is exposed to vibe code. - Public HTTPS scripts, styles, fonts, images, media, APIs, secure WebSockets, and EventSource may be used when the remote service permits normal browser access/CORS. - localStorage and IndexedDB are available inside the individual vibe origin. - HTTPS forms, downloads, external links, fullscreen, and clipboard-write may be used where the browser permits them. - Treat all authored vibe code as public client-side code. Never place credentials or secrets in it. - Do not hardcode vibesplode.com or the runtime hostname; relative same-origin Vibesplode platform paths are the stable integration surface. ## Device capabilities The currently validated capability registry is camera, microphone, and geolocation. - To request capabilities, include an HTML meta element in the entry page, for example . These hints are advisory and do NOT grant permissions. - The Creator can review detected code needs and authorize only the appropriate capabilities from Vibe settings. An account-holding Creator is required for device access. - Vibesplode shows Visitors a capability preflight before user code loads. The browser/device permission prompt remains authoritative afterward. - Handle denial and unsupported devices gracefully. - Preview and Live use the same declared capability policy. If code tries to use a supported capability that is not enabled, Vibesplode blocks it and surfaces a Creator-facing explanation. - USB, Bluetooth, Serial, HID, MIDI, clipboard-read, Payment Request, accelerometer/gyroscope/magnetometer, workers, service workers, and native-only/health data are not currently supported platform capabilities. ## Shared App: load and identity Shared App is an account-gated Creator capability for server-backed multi-Visitor application state. To request it, put in the authored HTML. Use "shared,visitor-uploads" when the app needs guest uploads. The Creator then reviews the requested access in Vibe settings; code cannot authorize itself. For most games and events, allow anonymous Visitors by default. If the app explicitly needs verified participant accounts, ask the human to approve that exceptional restriction. New guest uploads default to pending Creator review. When current-vibe context confirms Shared App is enabled, load the same-origin SDK: The public global is window.Vibesplode with version 1. Exact methods: - await window.Vibesplode.ready() Resolves when the runtime bootstrap is ready. It has no useful return value. - await window.Vibesplode.identity() Returns: { version: 1, publicId: string, participant: { id: string, role: "creator" | "participant", signedIn: boolean }, settings: { enabled: true, visitorIdentityMode: "anonymous" | "account", visitorUploadsEnabled: boolean, visitorUploadMode: "pending" | "approved" }, limits: { maxDocuments: number, maxDocumentBytes: number, maxTotalDocumentBytes: number, maxTransactionOperations: number, maxVisitorUploadBytes: number, maxVisitorUploadTotalBytes: number, maxVisitorUploads: number, maxVisitorUploadsPerParticipant: number, maxPresenceParticipants: number, maxTransientEventBytes: number } } Identity rules: - Anonymous participant IDs are random and scoped to one vibe; do not use them as cross-vibe identities. - Signed-in accounts map to a vibe-scoped participant identity. Vibe code never receives the trusted account cookie. - The vibe owner is role "creator" when participating through a signed-in runtime handoff. Other Visitors are role "participant". - Shared participation may allow anonymous Visitors or require signed-in Visitors. If sign-in is required, SDK requests fail with VISITOR_SIGN_IN_REQUIRED until the trusted join flow completes. ## Shared App: documents and collections Collections are normalized lowercase names matching: start with a letter, then at most 39 additional lowercase letters, numbers, underscores, or hyphens. Document IDs are opaque server-generated UUIDs; do not construct them. Shared document data must be one JSON-compatible object, not an array or primitive. A SharedDocument has this shape: { id: string, collection: string, data: object, ownerParticipantId: string, readScope: "public" | "participants" | "owner", writeScope: "creator" | "owner" | "participants", version: number, createdAt: ISO timestamp string, updatedAt: ISO timestamp string } Exact data methods: - await Vibesplode.data.list(collection, options?) options: { mine?: boolean, limit?: number, cursor?: string } Default limit is 50; server maximum is 100. Use nextCursor exactly as returned rather than inventing cursors. Returns { items: SharedDocument[], nextCursor: string | null }. - await Vibesplode.data.get(collection, id) Returns { document: SharedDocument }. A document the participant cannot read is exposed as not found. - await Vibesplode.data.create(collection, data, options?) options: { readScope?: "public" | "participants" | "owner", writeScope?: "creator" | "owner" | "participants" } Defaults are readScope "participants" and writeScope "owner". The current participant becomes ownerParticipantId; the caller cannot choose a custom document ID or transfer ownership. Returns { document: SharedDocument } with version 1. - await Vibesplode.data.update(collection, id, data, expectedVersion) expectedVersion is required and must be a positive integer. data replaces the entire document data object; it is not a merge/patch. Returns { document: SharedDocument } with version incremented by 1. - await Vibesplode.data.remove(collection, id, expectedVersion?) expectedVersion is optional. Success returns null because the HTTP result is 204. - await Vibesplode.data.transact(operations) Runs 1 through the current maxTransactionOperations operations atomically. Any failure rolls the whole transaction back. Returns { results: Array<{ document: SharedDocument } | { deleted: true, id: string, collection: string }> }. Transaction operation shapes: - Create: { type: "create", collection, data, readScope?, writeScope? } ID is generated by Vibesplode. - Update: { type: "update", collection, id, data, expectedVersion } Replaces the entire data object; expectedVersion is required. - Increment: { type: "increment", collection, id, field, amount, expectedVersion? } field must match a simple identifier and currently addresses one top-level finite numeric field. - Delete: { type: "delete", collection, id, expectedVersion? } ## Shared App: authorization scopes and private per-player data Server authorization is authoritative on every read, write, realtime delivery, and upload operation. Read scopes: - owner: readable by the owning participant and the Creator. - participants: readable by any authorized vibe participant and the Creator. - public: in the current runtime, readable by any authorized vibe participant and the Creator, just like participants. It does not bypass vibe access control or participant/session establishment. Treat the label as broader intent, not as anonymous unauthenticated HTTP access. Write scopes: - creator: only the Creator can update/delete after creation. - owner: the owning participant and the Creator can update/delete. - participants: any authorized participant and the Creator can update/delete. The Creator can read and write all shared documents regardless of document scopes. Ordinary participants cannot read another participant's owner-only document. Canonical private-per-player pattern: 1. Each Visitor calls identity() to learn their participant ID. 2. Each Visitor creates their own owner-only document, for example in collection player_secrets, using { readScope: "owner", writeScope: "owner" }. 3. The Creator can list those documents, correlate ownerParticipantId with a shared/public roster record, and fill the secret using update(..., document.version). 4. The owning Visitor can read their own secret; other participants receive not-found and do not receive realtime document events for that owner-only record. This pattern supports games where each player has private instructions while the Creator/admin can still manage the game. ## Shared App: versions, conflicts, and SDK errors - Every document response includes version. - update always requires the exact current expectedVersion. - remove and transaction increment/delete accept optional expectedVersion. - On a stale version, the SDK throws an Error with code "SHARED_CONFLICT" and status 409. Refetch current state and retry intentionally; do not blindly loop forever. SDK request errors expose at least: error.message: string error.code: string error.status: number JSON-backed SDK requests also expose error.details containing the parsed platform payload when one was returned. uploads.create exposes message/code/status but does not currently guarantee details. Important error families: - SHARED_APP_DISABLED (404): Shared App is not enabled. - VIBE_ACCESS_REQUIRED (401): the Visitor has not completed required vibe access. - VISITOR_SIGN_IN_REQUIRED (401): signed-in participation is required; JSON-backed SDK errors include a trusted signInUrl in details.error.signInUrl. - INVALID_SHARED_COLLECTION, INVALID_SHARED_CHANNEL, INVALID_SHARED_DATA, INVALID_SHARED_READ_SCOPE, INVALID_SHARED_WRITE_SCOPE, INVALID_SHARED_VERSION, INVALID_SHARED_TRANSACTION, INVALID_SHARED_INCREMENT (400): invalid caller input. - SHARED_DOCUMENT_NOT_FOUND (404): missing or unreadable document. - SHARED_FORBIDDEN (403): participant lacks write/moderation authority. - SHARED_CONFLICT (409): optimistic concurrency failure. - SHARED_DOCUMENT_TOO_LARGE, SHARED_DOCUMENT_LIMIT, SHARED_STORAGE_LIMIT and other quota codes (413): configured limit exceeded. - SHARED_RATE_LIMITED or other rate/connection limit codes (429): back off; respect Retry-After when available. Do not key application logic on error.message text; prefer code/status. ## Shared App: realtime Exact method: - const subscription = Vibesplode.realtime.subscribe(options, onEvent) options must choose exactly one of { collection: string } or { channel: string }. Optional fields: after: non-negative sequence number, onError: function. Returns synchronously: { close() }. Call subscription.close() when the view/component no longer needs updates; this also prevents future reconnect after the SDK has not yet opened the stream. Collection event shape: { seq, kind: "created" | "updated" | "deleted", collection, documentId, createdAt } Channel/transient event shape: { seq, kind: "transient", channel, data, participantId, createdAt } Realtime events are authorized notifications, not complete document snapshots. For document changes, use documentId to refetch/list authoritative state. Handlers must tolerate replay/duplicates and should be idempotent. If after is omitted, retained events may be delivered; do not assume the first callback happened after the subscription was created. Native EventSource reconnect behavior may also replay retained notifications. Owner-only document events are filtered from non-owners just like direct reads. Current retention: document-change events are retained for 24 hours; transient channel events for 2 minutes. These are bounded notification histories, not durable application history. ## Shared App: presence and transient events Presence methods: - await Vibesplode.presence.set(data) data must be a JSON-compatible object within maxTransientEventBytes. Returns { presence: { participantId, data, updatedAt, expiresAt } }. - await Vibesplode.presence.list() Returns { items: Array<{ participantId, data, updatedAt, expiresAt }> } for currently unexpired presence. Presence expires about 45 seconds after the last set. Refresh it periodically if the application needs ongoing presence. There is no explicit remove method; presence naturally expires. Presence is best-effort, not durable history. Transient event method: - await Vibesplode.events.emit(channel, data) channel follows the same naming rule as collections and data must be a JSON object within maxTransientEventBytes. Returns { seq: number }. Receive these with realtime.subscribe({ channel }, handler). Transient events expire after about 2 minutes and should not be used as durable state. ## Shared App: Visitor uploads and moderation These methods are relevant only when current-vibe context says Visitor uploads are enabled. Upload view shape: { id, participantId, originalName, mediaType, byteSize, status, createdAt, updatedAt, contentUrl } status is "pending" | "approved" | "rejected" | "hidden". Exact methods: - await Vibesplode.uploads.create(file) file is a browser File. Returns { upload }. - await Vibesplode.uploads.list(options?) options: { mine?: boolean, status?: moderationStatus, limit?: number }. Default limit 50; maximum 100. Returns { items: upload[] }. - await Vibesplode.uploads.moderate(id, status) Creator-only. status must be pending, approved, rejected, or hidden. Returns { upload }. - await Vibesplode.uploads.remove(id) Allowed for the Creator or the participant who uploaded the file. Success returns null. Visibility rules: - Creator can list all uploads and filter by any moderation status. - A participant using mine:true can list their own uploads including pending/rejected/hidden. - Other participant lists expose only approved uploads. - Upload contentUrl follows the same rule: Creator, owner, or anyone when approved. Visitor uploads are separate from Creator Assets, authored Undo/Redo, Export, and Template Mode. They persist until explicit shared-data reset/deletion/cleanup policy removes them. ## Shared App: current limits and safe coding identity().limits is the authoritative per-vibe limit source for generated code. Current entitlements expose: - maxDocuments: 500 - maxDocumentBytes: 32768 bytes - maxTotalDocumentBytes: 5000000 bytes - maxTransactionOperations: 20 - maxVisitorUploadBytes: 10000000 bytes - maxVisitorUploadTotalBytes: 100000000 bytes - maxVisitorUploads: 200 - maxVisitorUploadsPerParticipant: 50 - maxPresenceParticipants: 100 - maxTransientEventBytes: 4096 bytes Realtime connections, request rates, write rates, and upload rates are also bounded server-side and can be tuned operationally. Generated code must handle 429 responses and reconnect/backoff gracefully rather than assuming unlimited capacity. ## Shared App: canonical minimal examples Shared counter with optimistic versioning: await Vibesplode.ready(); const created = await Vibesplode.data.create( "counters", { value: 0 }, { readScope: "participants", writeScope: "participants" } ); let counter = created.document; const sub = Vibesplode.realtime.subscribe({ collection: "counters" }, async (event) => { if (event.documentId !== counter.id || event.kind === "deleted") return; const latest = await Vibesplode.data.get("counters", counter.id); counter = latest.document; render(counter.data.value); }); async function increment() { try { const result = await Vibesplode.data.transact([ { type: "increment", collection: "counters", id: counter.id, field: "value", amount: 1, expectedVersion: counter.version } ]); counter = result.results[0].document; render(counter.data.value); } catch (error) { if (error.code !== "SHARED_CONFLICT") throw error; counter = (await Vibesplode.data.get("counters", counter.id)).document; render(counter.data.value); } } window.addEventListener("pagehide", () => sub.close(), { once: true }); Private owner-readable document: const me = await Vibesplode.identity(); const secret = await Vibesplode.data.create( "player_secrets", { participantId: me.participant.id, state: "waiting" }, { readScope: "owner", writeScope: "owner" } ); // The Creator can later update this document; other participants cannot read it. Presence refresh: await Vibesplode.presence.set({ screen: "lobby" }); const presenceTimer = setInterval(() => { void Vibesplode.presence.set({ screen: "lobby" }); }, 20000); window.addEventListener("pagehide", () => clearInterval(presenceTimer), { once: true }); ## Authored HTML and Creator Assets - The ordinary beginner vibe is one complete browser-native HTML document. Vibesplode currently stores that document as the logical entry document; .html and .htm inputs work. - Creator Assets are separate files with stable relative paths such as assets/photo.png and assets/music.mp3. Use only paths the Creator has actually supplied. - Current authored-code byte limit is 1000000 bytes total. - Creator Assets: 15000000 bytes per file, 25000000 bytes total. - Vibes are currently bounded to 100 total authored code files plus Creator Assets; ordinary workshop authoring uses one authored HTML document. - Supported Creator Asset types: JPEG, PNG, WebP, GIF, MP3, OGG, WAV, M4A/MP4 audio, MP4/WebM video/audio, JSON, CSV, and TXT. SVG and PDF are not currently accepted Creator Asset types. - Shared/Visitor runtime state is not a Creator Asset and is never copied through Template Mode. ## Sharing, portability, and safety - Vibesplode gives the vibe a branded human share URL, but user code executes on an isolated runtime origin. Generated code must not depend on either hostname being hardcoded. - Preview and Live should be treated as the same authored browser app under equivalent supported capability policy. - Keep the first version small, usable, understandable, and easy for a human or another AI to replace coherently. - When shared behavior, guest uploads or device access are required, include containing only the actual needs. Then ask the Creator to review the requested access in Vibe settings. This is a request, not permission. Wait for an enabled current-vibe context before relying on platform features. - Use Vibesplode Shared App APIs only when current-vibe context says the feature is enabled. Otherwise keep state browser-local or use explicitly permitted public HTTPS services. - Do not attempt to bypass Vibesplode access controls, capability preflights, browser permissions, moderation, quotas, or runtime isolation.