Build an interactive mascot
This guide is for an AI agent working with Masko's MCP tools; read_docs reads the other guides and docs pages it names. A mascot that reacts to an app or website, is interactive, or changes between animations is a canvas, never separate animations switched by code you write. The Masko player plays a release of the canvas in the app and runs all its rules.
The steps
- Make the mascot and one finished picture of it (
ai-agents/create-mascot). Reuse what exists:get_mascotlists a mascot's canvases. create_canvaswith its graph: the poses, each pose's loop, the moves between poses and the inputs the app sets. To change a canvas, read it withget_canvasand save the whole graph withsave_canvasand theexpected_graph_hashyou read.estimate_canvas_generationprices what is missing. Tell the user the price and get a yes.generate_canvaswith the estimate'splan_id, themax_creditsthe user agreed to and anoperation_id.- When every clip is ready,
release_canvasmakes a playable release and returns the app's link for each platform. get_release_deliveryreturns its files, the player to install, the app's link and the code that plays it, ready to paste. Then readai-agents/integrate-mascot.
The graph
- Nodes are poses:
assetIdfor a finished picture, orimagePromptfor a still moment to draw ($0.125). A label alone draws nothing. - Edges are animations. An edge from a node to itself is that pose's animation, and the first one without conditions is its loop. An edge between two nodes is a transition, played when its conditions on inputs hold;
prioritydecides between them (highest wins). - Any State: an edge with source
*fires from any node and needs duration 0. - Reverse edges (
reversetrue withreverseOfEdgeId) play another edge backwards for free; never point one at its forward video. - Inputs: the app holds a behavior such as
behavior::celebratewithset(name, true), and sends one-off events withfire('<event>')toaction::<event>.initialNodeis the start.
Build what the user asked: a sensible starting pose, the actions, their conditions and a way back. Never add a large default graph or behaviors nobody asked for.
Keep node and edge IDs when you save. Masko keeps the media of unchanged poses and animations; a changed prompt, duration or pose drops that clip, and the next generation makes it again. To reuse a clip the mascot already has, set videoAssetId to one the estimate lists under reusable (free). On a stale hash, read the canvas again and merge the changes instead of overwriting them.
Write each clip
An edge's description is one action, with how big, how fast and the mood, never the mascot's look. A loop keeps the action going and never lowers, returns or settles at its end. Each clip is made at its edge's own duration (whole seconds, Standard 2 to 15) when set, else at the estimate's.
Masko times each clip from its pictures when it is generated. When the user wants to see or change how the clips will move before paying, call save_canvas with improve set to true (the graph can be left out): it writes each unmade clip's improved, timed prompt into the canvas and returns them, free. Each is one range per line, to the hundredth of a second, from 0.00 to the clip's real length, which its seconds gives, as in ai-agents/animate-mascot. Show the user each clip's motion and save their changes to its text, keeping the ranges one after another from 0.00 to that end; then estimate and generate, and Masko keeps those ranges.
Validation
create_canvas, get_canvas and save_canvas return the validation. valid means the graph is sound. clips_to_generate and pictures_to_generate count what generating will make; they are not errors to fix. Fix an invalid graph before generating.
Estimate and generate
- Check the estimate's
planned_nodes,planned_edgesandcost_credits_usdagainst what the user asked before asking to spend. - Pass the estimate's
plan_idtogenerate_canvaswith the agreedmax_credits. A later round of work needs a fresh estimate and a fresh yes. - Never edit the graph while its generation runs. Follow the run with
get_job, then readget_canvasuntil its media is ready. generate_canvasalso repairs missing playback files of existing clips, for free: never make a clip again to fix a file.
Release and ship
release_canvasneeds the current graph hash and anoperation_id. A release is not a marketplace listing and does not change a mascot in Masko for Mac.get_release_deliverytakes the target:webfor websites and Electron,applefor iPhone, iPad and Mac,android; React Native and Flutter useappleon iOS andandroidon Android.desktopis only for Masko for Mac. Use itscodefield: never guess the player API. Itsapp_inputssay which inputs to set and which to fire.- The app's link comes with the release: it reads the canvas's newest release with the mascot's app key inside, and the code
get_release_deliveryreturns already holds that key. Give the app that link, never the account key. There is nothing to make or ask about: the key can only play this mascot's released canvases, so it is safe in the app. The user sees its use in App keys on the mascot's page in Studio. - A canvas needs no publishing.
Jobs, retries and failures
get_jobwaits up to 40 seconds per call; call it again until the run is completed or failed. Never start the same work again while it runs; after an interruption,get_accountlists the work still running.operation_idmakes a call safe to retry: the same ID returns the first answer and never charges twice.- Failed clips give back their credits;
get_canvaslists which, and a new estimate retries them. - When something looks like a Masko problem, offer to tell the Masko team with
send_feedback, quoting the tool, the error and itsrequest_id.
Prices and credits
Say prices and balances in dollars, from the fields ending in _usd. Inputs such as max_credits stay in credits, at $0.125 each. When credits run short, stop paid work and tell the user what the work costs and what the workspace has. No tool takes a payment.
More detail: canvas/build (every graph field), canvas/generate-all, player/canvas (inputs and behaviors) and player/app-keys.
