@openbone/mcp 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bridge.d.ts CHANGED
@@ -1,12 +1,16 @@
1
+ import { type OpenBoneDocument } from "@openbone/core";
1
2
  import type { IncomingMessage } from "node:http";
2
3
  import { type WebSocket } from "ws";
3
4
  import type { ProjectSession } from "./session.js";
5
+ export interface BridgeFile {
6
+ src: string;
7
+ kind: "image" | "audio";
8
+ mime: string;
9
+ base64: string;
10
+ }
4
11
  /**
5
- * Live bridge: the OpenBone editor connects here (ws://localhost:PORT) so changes made by the
6
- * agent appear instantly in the editor, and edits made in the editor are visible to the agent.
7
- *
8
- * Messages (JSON):
9
- * editor → server: {type:"hello"} | {type:"op", op, args} | {type:"undo"} | {type:"redo"} | {type:"load", doc}
10
- * server → editor: {type:"load", doc, path} | {type:"ops", ops} | {type:"error", message}
12
+ * Files the document refers to by a relative path that `sent` (src → modification time) hasn't had yet, or that
13
+ * changed on disk since. Only image and audio files, read from `baseDir`. Missing files are skipped.
11
14
  */
15
+ export declare function pendingFiles(doc: OpenBoneDocument, baseDir: string, sent: Map<string, number>): BridgeFile[];
12
16
  export declare function startBridge(session: ProjectSession, port: number, log: (m: string) => void): import("ws").Server<typeof WebSocket, typeof IncomingMessage>;
package/dist/bridge.js CHANGED
@@ -1,3 +1,6 @@
1
+ import { textureAssets } from "@openbone/core";
2
+ import { readFileSync, statSync } from "node:fs";
3
+ import path from "node:path";
1
4
  import { WebSocketServer } from "ws";
2
5
  import { isLocalRequest } from "./local-only.js";
3
6
  /**
@@ -7,7 +10,58 @@ import { isLocalRequest } from "./local-only.js";
7
10
  * Messages (JSON):
8
11
  * editor → server: {type:"hello"} | {type:"op", op, args} | {type:"undo"} | {type:"redo"} | {type:"load", doc}
9
12
  * server → editor: {type:"load", doc, path} | {type:"ops", ops} | {type:"error", message}
13
+ * | {type:"files", files:[{src, kind, mime, base64}]}
14
+ *
15
+ * The server stores imported art and sound as paths relative to the project file, which the editor (a web page, or
16
+ * the desktop app without that project open) can't read. So before the document or ops that use such a path, the
17
+ * server sends the file's bytes ("files"), and the editor shows and plays them from memory.
18
+ */
19
+ const MEDIA = {
20
+ png: { kind: "image", mime: "image/png" },
21
+ jpg: { kind: "image", mime: "image/jpeg" },
22
+ jpeg: { kind: "image", mime: "image/jpeg" },
23
+ webp: { kind: "image", mime: "image/webp" },
24
+ gif: { kind: "image", mime: "image/gif" },
25
+ wav: { kind: "audio", mime: "audio/wav" },
26
+ mp3: { kind: "audio", mime: "audio/mpeg" },
27
+ ogg: { kind: "audio", mime: "audio/ogg" },
28
+ oga: { kind: "audio", mime: "audio/ogg" },
29
+ flac: { kind: "audio", mime: "audio/flac" },
30
+ m4a: { kind: "audio", mime: "audio/mp4" },
31
+ };
32
+ /**
33
+ * Files the document refers to by a relative path that `sent` (src → modification time) hasn't had yet, or that
34
+ * changed on disk since. Only image and audio files, read from `baseDir`. Missing files are skipped.
10
35
  */
36
+ export function pendingFiles(doc, baseDir, sent) {
37
+ const srcs = new Set();
38
+ for (const a of textureAssets(doc))
39
+ if (a.src)
40
+ srcs.add(a.src);
41
+ for (const a of doc.audio?.assets ?? [])
42
+ if (a.src)
43
+ srcs.add(a.src);
44
+ const out = [];
45
+ for (const src of srcs) {
46
+ if (/^(data:|https?:|blob:)/i.test(src))
47
+ continue;
48
+ const media = MEDIA[src.split(/[?#]/)[0].split(".").pop()?.toLowerCase() ?? ""];
49
+ if (!media)
50
+ continue;
51
+ const file = path.resolve(baseDir, src);
52
+ try {
53
+ const mtime = statSync(file).mtimeMs;
54
+ if (sent.get(src) === mtime)
55
+ continue;
56
+ out.push({ src, ...media, base64: readFileSync(file).toString("base64") });
57
+ sent.set(src, mtime);
58
+ }
59
+ catch {
60
+ /* not there (yet) */
61
+ }
62
+ }
63
+ return out;
64
+ }
11
65
  export function startBridge(session, port, log) {
12
66
  const wss = new WebSocketServer({
13
67
  port,
@@ -21,11 +75,24 @@ export function startBridge(session, port, log) {
21
75
  },
22
76
  });
23
77
  const clients = new Set();
78
+ /** Per editor: files already sent (src → modification time). */
79
+ const sentFiles = new WeakMap();
24
80
  const send = (ws, msg) => ws.readyState === ws.OPEN && ws.send(JSON.stringify(msg));
81
+ const sendFiles = (ws) => {
82
+ let sent = sentFiles.get(ws);
83
+ if (!sent)
84
+ sentFiles.set(ws, (sent = new Map()));
85
+ const files = pendingFiles(session.doc, session.baseDir, sent);
86
+ if (files.length)
87
+ send(ws, { type: "files", files });
88
+ };
25
89
  const broadcast = (msg, except) => {
26
- for (const c of clients)
27
- if (c !== except)
28
- send(c, msg);
90
+ for (const c of clients) {
91
+ if (c === except)
92
+ continue;
93
+ sendFiles(c);
94
+ send(c, msg);
95
+ }
29
96
  };
30
97
  let current;
31
98
  session.store.subscribe((doc, e) => {
@@ -39,6 +106,7 @@ export function startBridge(session, port, log) {
39
106
  wss.on("connection", (ws) => {
40
107
  clients.add(ws);
41
108
  log(`editor connected (${clients.size})`);
109
+ sendFiles(ws);
42
110
  send(ws, { type: "load", doc: session.doc, path: session.filePath });
43
111
  ws.on("close", () => clients.delete(ws));
44
112
  ws.on("message", async (raw) => {
@@ -51,8 +119,11 @@ export function startBridge(session, port, log) {
51
119
  }
52
120
  current = ws;
53
121
  try {
54
- if (msg.type === "hello")
122
+ if (msg.type === "hello") {
123
+ sentFiles.delete(ws); // a fresh editor page: send every file again
124
+ sendFiles(ws);
55
125
  send(ws, { type: "load", doc: session.doc, path: session.filePath });
126
+ }
56
127
  else if (msg.type === "op" && msg.op)
57
128
  session.store.apply(msg.op, msg.args ?? {}, "bridge");
58
129
  else if (msg.type === "undo")
@@ -66,6 +137,7 @@ export function startBridge(session, port, log) {
66
137
  catch (e) {
67
138
  send(ws, { type: "error", message: e.message });
68
139
  // Resync the editor so it does not drift from the server copy.
140
+ sendFiles(ws);
69
141
  send(ws, { type: "load", doc: session.doc, path: session.filePath });
70
142
  }
71
143
  finally {
package/dist/export.js CHANGED
@@ -238,6 +238,7 @@ export async function exportFile(session, a, scriptHost) {
238
238
  inputs: sm?.inputs.map((i) => ({ name: i.name, type: i.type })) ?? [],
239
239
  hasScripts,
240
240
  hasAudio: !!d.audio?.assets.length,
241
+ buses: d.audio?.buses.map((b) => b.name) ?? [],
241
242
  };
242
243
  return done(a.singleFile ? new TextEncoder().encode(webIndexHtml(pack)) : webPackZip(pack));
243
244
  }
package/dist/guide.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const GUIDE = "# OpenBone authoring guide (for agents)\n\nCoordinate system: skeleton space is y-UP, rotations in degrees counter-clockwise. The skeleton origin (0,0)\nsits at (originX, originY) pixels in the artboard (artboard pixels are y-down). Default artboard 800x600,\norigin (400,450) \u2014 so y=0 is near the bottom, positive y goes up.\n\nEverything can be referenced by **name or id**. Every edit tool validates its input and returns ids.\n\n## Typical workflow\n1. new_project {name, path} (autosaves to path) \u2014 or open_project.\n2. Rig: add_bone (parent defaults to root; x/y/rotation are LOCAL to the parent). A bone points along its local +x.\n E.g. an upright torso: add_bone {name:\"torso\", y:100, rotation:90, length:120}.\n Children of a rotated parent use the parent's frame: a head on top of that torso is add_bone {name:\"head\", parent:\"torso\", x:120}.\n3. Visuals: add_slot {bone} then add_shape (no art needed) or import_image + add_region / add_mesh.\n Art prep: process_image {input, out, ops:[...], importAs | replace} keys out flat backgrounds (keyColor), cuts an object\n out by comparing with a painted-out copy (differenceMatte), trims, crops, resizes, flips and feathers edges; its \"box\"\n says where the result sat in the input picture, so a layer cut from a full scene can be placed exactly where it was.\n Attachments are positioned in the slot BONE's local frame (x along the bone).\n Draw order = slot order (first is back). Use update_slot {index} to reorder.\n4. Deformation: add_mesh {cols, rows} (or trace_mesh on a region) then auto_weights {bones:[...]} so the mesh bends with bones.\n trace_mesh on a mesh re-traces it in place and rebinds the same bones (tolerance 1\u20132 for detailed edges such as feet).\n set_weights_in_area {slot, attachment, area:{yMax:...} | polygon, influences, blend} pins every vertex in an area\n to bones (e.g. everything below the knees to the legs bone) without listing vertex indices.\n5. Constraints (solved every frame in one list; default order IK, transform, path, physics \u2014 set_constraint_order\n {constraints:[every constraint, first applied first]} changes it, [] restores the default):\n add_ik_constraint {bones:[\"thigh\",\"shin\"], target:\"foot-target\"} (target must not be a child of the chain);\n optional softness (2-bone), stretch, compress (1-bone).\n add_transform_constraint {bones, target, mixRotate, mixTranslate, mixScale, mixShear, local?, relative?}.\n Path: add_path {slot, anchors:[x0,y0,x1,y1,...]} (smooth bezier in the slot bone's frame; bind it to control bones\n with auto_weights or set_weights so moving them bends it), then add_path_constraint {bones:[parent..child], target:slot,\n positionMode:\"fixed\"|\"percent\", spacingMode:\"length\"|\"fixed\"|\"percent\"|\"proportional\", rotateMode:\"tangent\"|\"chain\"|\"chainScale\"}.\n Physics: add_physics_constraint {bone, inertia, strength, damping, mass, gravity, wind, mix} per bone (parent first)\n for hair/cloth/tails. It simulates over time, so check it with render_gif rather than a single frame.\n Physics gravity/wind and IK softness scale with the skeleton's size relative to set_document {referenceScale} (default 100 %).\n6. Animate: create_animation {name}, then set_keys with absolute values:\n set_keys {animation:\"walk\", target:\"bone\", id:\"thigh\", property:\"rotation\", keys:[{time:0,value:-20},{time:0.5,value:20,curve:\"easeInOut\"},{time:1,value:-20}]}\n Properties: bone rotation|x|y|scaleX|scaleY|shearX|shearY|inherit (stepped string: normal|onlyTranslation|noRotation|noScale), slot color (\"#rrggbbaa\") | dark (two-colour tint \"#rrggbb\") | attachment (name or null),\n ik mix|softness, transform mix|mixRotate|mixTranslate|mixScale|mixShear, path position|spacing|mixRotate|mixX|mixY,\n physics mix|inertia|strength|damping|mass|gravity|wind, deform offsets (mesh or path), sequence frame (with attachment), drawOrder. Curves: linear, stepped, easeIn, easeOut, easeInOut, backOut or [cx1,cy1,cx2,cy2].\n set_keys merges into the timeline; pass replace:true to set the whole timeline (e.g. when redoing a motion path).\n Loop cleanly by making the last key equal the first. add_event_key fires events (footsteps, sounds).\n7. Interactivity (Rive-style): create_state_machine \u2192 add_input (bool/number/trigger) \u2192 add_state {animation}\n (first state = entry) \u2192 add_transition {from, to, conditions:[{input, op, value}], duration, exitTime}.\n Transition with no conditions waits for the source animation to finish (exitTime 1).\n from:\"@any\" fires from any state. blend1d states blend animations by a number input.\n Pointer: add_bounding_box on a slot, then add_listener {slot, event:\"click\"|\"down\"|\"up\"|\"enter\"|\"exit\"|\"move\", actions:[...]}.\n Staged flows: add_state {..., loop:false, onComplete:\"next\"} plays once then moves on (its own transitions can still interrupt).\n Live data: add_input {type:\"string\"} or number inputs; add_text {slot, text:\"{multiplier:0.00}x\", size, weight, color, outline}\n shows inputs (number patterns: 0.00, #,##0, +0, 0%); add_binding {input, target:\"bone\"|\"slot\"|\"ik\"|..., object, property,\n inMin, inMax, outMin, outMax} drives a property from a number input every frame (slot color takes hex outMin/outMax).\n simulate_state_machine / render_frame steps accept setInputs with strings too.\n Scripts: add_script {code} + attach_script. Script API (global ob): ob.input(n), ob.setInput(n,v), ob.fire(n),\n ob.emit(event,{int,float,string}), ob.bone(n), ob.setBone(n,{rotation,...}) (per-frame override), ob.slot(n,{color,attachment}),\n ob.pointer(), ob.time(), ob.log(...). Hooks: onStart(), onUpdate(dt), onEvent(e), onPointer(p), or named fns for runScript actions.\n8. Particles: add_particles {slot, preset:\"fire\"|\"smoke\"|\"sparks\"|\"confetti\"|\"exhaust\"|\"coins\", ...overrides} emits from the\n slot bone (rotation = emission direction in the bone's frame, e.g. -90 for exhaust under an upright rocket bone; space\n \"world\" leaves trails). update_particles changes settings. Key it with set_keys {target:\"particles\", id:slot,\n property:\"emitting\" (true/false) | \"rate\"}. State machines: set_state_emitter {state, slot, emitting} and listener actions\n {type:\"setEmitter\", slot, emitting} / {type:\"emitParticles\", slot, count}. Seeded and deterministic; check with render_gif.\n9. Skins (outfits): the first skin is the default skin, shared by all. add_skin {name}, then either pass skin:\"<name>\" to\n add_shape/add_region/... or copy_attachment {slot, attachment, toSkin} and update_attachment {..., skin} to override a\n default attachment under the same name. rename_skin, duplicate_skin, delete_skin manage them; render_frame {skin} previews one.\n Skin bones/constraints: add_to_skin {skin, bones?, constraints?} makes them skin-only (active only while a skin listing\n them is set; inactive bones and their children aren't posed and their slots aren't drawn); remove_from_skin undoes it.\n10. Audio: import_audio {path} (or add_audio {name, src:data:/path, duration}) creates an asset and a same-named sound on the\n sfx bus. Play it with add_audio_key {animation, sound, time, volume?, rate?, loop?}, set_event_sound {event, sound} (plays\n whenever the event fires), set_state_sound {stateMachine, state, sound, on:\"enter\"|\"exit\", action:\"play\"|\"stop\"} or a\n listener action {type:\"playSound\", sound} / {type:\"stopSound\", sound, fade?}. Mute buttons: listener action\n {type:\"setMute\", bus:\"music\"|\"sfx\"|... (null = everything), muted:true|false|\"toggle\"} (pair it with toggleInput on a bool\n input and a slot color binding to show the state). Looping sounds stop when their state or\n animation ends. Mix with update_sound {volume, rate, loop, fadeIn, fadeOut, bus}, add_bus/update_bus {volume, muted},\n set_audio_mix {master, muted}. simulate_state_machine lists the audio commands.\n11. Sprite sequences (frame-by-frame, e.g. fire or explosions): add_image for each frame (or one sheet image), then\n add_sequence {slot, frames:[\"fire_0001\",\"fire_0002\",...], fps, mode:\"loop\"|\"once\"|\"pingPong\"|\"holdLast\", offset}\n or add_sequence {slot, grid:{image:\"sheet\", cols, rows}}. Bind input (a number input) to pick the frame from a state\n machine, or set_keys target:\"sequence\" {id:slot, attachment, property:\"frame\"}. set_sequence_frames replaces/reorders frames.\n12. Check your work: render_frame (returns a PNG; bones are drawn as blue wedges) and simulate_state_machine (text log of\n state changes/events). render_gif for motion. get_summary for an outline, validate for problems.\n\nTips: keep bones' length meaningful (used by IK and auto weights). Use update_* tools to fix mistakes, undo to revert.\n";
1
+ export declare const GUIDE = "# OpenBone authoring guide (for agents)\n\nCoordinate system: skeleton space is y-UP, rotations in degrees counter-clockwise. The skeleton origin (0,0)\nsits at (originX, originY) pixels in the artboard (artboard pixels are y-down). Default artboard 800x600,\norigin (400,450) \u2014 so y=0 is near the bottom, positive y goes up.\n\nEverything can be referenced by **name or id**. Every edit tool validates its input and returns ids.\n\n## Typical workflow\n1. new_project {name, path} (autosaves to path) \u2014 or open_project.\n2. Rig: add_bone (parent defaults to root; x/y/rotation are LOCAL to the parent). A bone points along its local +x.\n E.g. an upright torso: add_bone {name:\"torso\", y:100, rotation:90, length:120}.\n Children of a rotated parent use the parent's frame: a head on top of that torso is add_bone {name:\"head\", parent:\"torso\", x:120}.\n3. Visuals: add_slot {bone} then add_shape (no art needed) or import_image + add_region / add_mesh.\n Art prep: process_image {input, out, ops:[...], importAs | replace} keys out flat backgrounds (keyColor), cuts an object\n out by comparing with a painted-out copy (differenceMatte), trims, crops, resizes, flips and feathers edges; its \"box\"\n says where the result sat in the input picture, so a layer cut from a full scene can be placed exactly where it was.\n Attachments are positioned in the slot BONE's local frame (x along the bone).\n Draw order = slot order (first is back). Use update_slot {index} to reorder.\n4. Deformation: add_mesh {cols, rows} (or trace_mesh on a region) then auto_weights {bones:[...]} so the mesh bends with bones.\n trace_mesh on a mesh re-traces it in place and rebinds the same bones (tolerance 1\u20132 for detailed edges such as feet).\n set_weights_in_area {slot, attachment, area:{yMax:...} | polygon, influences, blend} pins every vertex in an area\n to bones (e.g. everything below the knees to the legs bone) without listing vertex indices.\n5. Constraints (solved every frame in one list; default order IK, transform, path, physics \u2014 set_constraint_order\n {constraints:[every constraint, first applied first]} changes it, [] restores the default):\n add_ik_constraint {bones:[\"thigh\",\"shin\"], target:\"foot-target\"} (target must not be a child of the chain);\n optional softness (2-bone), stretch, compress (1-bone).\n add_transform_constraint {bones, target, mixRotate, mixTranslate, mixScale, mixShear, local?, relative?}.\n Path: add_path {slot, anchors:[x0,y0,x1,y1,...]} (smooth bezier in the slot bone's frame; bind it to control bones\n with auto_weights or set_weights so moving them bends it), then add_path_constraint {bones:[parent..child], target:slot,\n positionMode:\"fixed\"|\"percent\", spacingMode:\"length\"|\"fixed\"|\"percent\"|\"proportional\", rotateMode:\"tangent\"|\"chain\"|\"chainScale\"}.\n Physics: add_physics_constraint {bone, inertia, strength, damping, mass, gravity, wind, mix} per bone (parent first)\n for hair/cloth/tails. It simulates over time, so check it with render_gif rather than a single frame.\n Physics gravity/wind and IK softness scale with the skeleton's size relative to set_document {referenceScale} (default 100 %).\n6. Animate: create_animation {name}, then set_keys with absolute values:\n set_keys {animation:\"walk\", target:\"bone\", id:\"thigh\", property:\"rotation\", keys:[{time:0,value:-20},{time:0.5,value:20,curve:\"easeInOut\"},{time:1,value:-20}]}\n Properties: bone rotation|x|y|scaleX|scaleY|shearX|shearY|inherit (stepped string: normal|onlyTranslation|noRotation|noScale), slot color (\"#rrggbbaa\") | dark (two-colour tint \"#rrggbb\") | attachment (name or null),\n ik mix|softness, transform mix|mixRotate|mixTranslate|mixScale|mixShear, path position|spacing|mixRotate|mixX|mixY,\n physics mix|inertia|strength|damping|mass|gravity|wind, deform offsets (mesh or path), sequence frame (with attachment), drawOrder. Curves: linear, stepped, easeIn, easeOut, easeInOut, backOut or [cx1,cy1,cx2,cy2].\n set_keys merges into the timeline; pass replace:true to set the whole timeline (e.g. when redoing a motion path).\n Loop cleanly by making the last key equal the first. add_event_key fires events (footsteps, sounds).\n7. Interactivity (Rive-style): create_state_machine \u2192 add_input (bool/number/trigger) \u2192 add_state {animation}\n (first state = entry) \u2192 add_transition {from, to, conditions:[{input, op, value}], duration, exitTime}.\n Transition with no conditions waits for the source animation to finish (exitTime 1).\n from:\"@any\" fires from any state. blend1d states blend animations by a number input.\n Pointer: add_bounding_box on a slot, then add_listener {slot, event:\"click\"|\"down\"|\"up\"|\"enter\"|\"exit\"|\"move\", actions:[...]}.\n Staged flows: add_state {..., loop:false, onComplete:\"next\"} plays once then moves on (its own transitions can still interrupt).\n Live data: add_input {type:\"string\"} or number inputs; add_text {slot, text:\"{multiplier:0.00}x\", size, weight, color, outline}\n shows inputs (number patterns: 0.00, #,##0, +0, 0%); add_binding {input, target:\"bone\"|\"slot\"|\"ik\"|..., object, property,\n inMin, inMax, outMin, outMax} drives a property from a number input every frame (slot color takes hex outMin/outMax).\n simulate_state_machine / render_frame steps accept setInputs with strings too.\n Scripts: add_script {code} + attach_script. Script API (global ob): ob.input(n), ob.setInput(n,v), ob.fire(n),\n ob.emit(event,{int,float,string}), ob.bone(n), ob.setBone(n,{rotation,...}) (per-frame override), ob.slot(n,{color,attachment}),\n ob.pointer(), ob.time(), ob.log(...). Hooks: onStart(), onUpdate(dt), onEvent(e), onPointer(p), or named fns for runScript actions.\n8. Particles: add_particles {slot, preset:\"fire\"|\"smoke\"|\"sparks\"|\"confetti\"|\"exhaust\"|\"coins\", ...overrides} emits from the\n slot bone (rotation = emission direction in the bone's frame, e.g. -90 for exhaust under an upright rocket bone; space\n \"world\" leaves trails). update_particles changes settings. Key it with set_keys {target:\"particles\", id:slot,\n property:\"emitting\" (true/false) | \"rate\"}. State machines: set_state_emitter {state, slot, emitting} and listener actions\n {type:\"setEmitter\", slot, emitting} / {type:\"emitParticles\", slot, count}. Seeded and deterministic; check with render_gif.\n9. Skins (outfits): the first skin is the default skin, shared by all. add_skin {name}, then either pass skin:\"<name>\" to\n add_shape/add_region/... or copy_attachment {slot, attachment, toSkin} and update_attachment {..., skin} to override a\n default attachment under the same name. rename_skin, duplicate_skin, delete_skin manage them; render_frame {skin} previews one.\n Skin bones/constraints: add_to_skin {skin, bones?, constraints?} makes them skin-only (active only while a skin listing\n them is set; inactive bones and their children aren't posed and their slots aren't drawn); remove_from_skin undoes it.\n10. Audio: import_audio {path} (or add_audio {name, src:data:/path, duration}) creates an asset and a same-named sound on the\n sfx bus. Play it with add_audio_key {animation, sound, time, volume?, rate?, loop?}, set_event_sound {event, sound} (plays\n whenever the event fires), set_state_sound {stateMachine, state, sound, on:\"enter\"|\"exit\", action:\"play\"|\"stop\"} or a\n listener action {type:\"playSound\", sound} / {type:\"stopSound\", sound, fade?}. Mute buttons: give a bool input the bus it\n mutes (add_input / update_input {mutes:\"music\"|\"sfx\"|... or \"master\" for everything}), then a listener {type:\"setMute\",\n bus:\"music\", muted:\"toggle\"} (or toggleInput on that input; not both) and a slot color binding to show the state. The\n app embedding the animation mutes it the same way (setInput(\"musicOff\", true), or player.setBusMuted(\"music\", true)).\n Looping sounds stop when their state or\n animation ends. Mix with update_sound {volume, rate, loop, fadeIn, fadeOut, bus}, add_bus/update_bus {volume, muted},\n set_audio_mix {master, muted}. simulate_state_machine lists the audio commands.\n11. Sprite sequences (frame-by-frame, e.g. fire or explosions): add_image for each frame (or one sheet image), then\n add_sequence {slot, frames:[\"fire_0001\",\"fire_0002\",...], fps, mode:\"loop\"|\"once\"|\"pingPong\"|\"holdLast\", offset}\n or add_sequence {slot, grid:{image:\"sheet\", cols, rows}}. Bind input (a number input) to pick the frame from a state\n machine, or set_keys target:\"sequence\" {id:slot, attachment, property:\"frame\"}. set_sequence_frames replaces/reorders frames.\n12. Check your work: render_frame (returns a PNG; bones are drawn as blue wedges) and simulate_state_machine (text log of\n state changes/events). render_gif for motion. get_summary for an outline, validate for problems.\n\nTips: keep bones' length meaningful (used by IK and auto weights). Use update_* tools to fix mistakes, undo to revert.\n";
package/dist/guide.js CHANGED
@@ -65,9 +65,11 @@ Everything can be referenced by **name or id**. Every edit tool validates its in
65
65
  10. Audio: import_audio {path} (or add_audio {name, src:data:/path, duration}) creates an asset and a same-named sound on the
66
66
  sfx bus. Play it with add_audio_key {animation, sound, time, volume?, rate?, loop?}, set_event_sound {event, sound} (plays
67
67
  whenever the event fires), set_state_sound {stateMachine, state, sound, on:"enter"|"exit", action:"play"|"stop"} or a
68
- listener action {type:"playSound", sound} / {type:"stopSound", sound, fade?}. Mute buttons: listener action
69
- {type:"setMute", bus:"music"|"sfx"|... (null = everything), muted:true|false|"toggle"} (pair it with toggleInput on a bool
70
- input and a slot color binding to show the state). Looping sounds stop when their state or
68
+ listener action {type:"playSound", sound} / {type:"stopSound", sound, fade?}. Mute buttons: give a bool input the bus it
69
+ mutes (add_input / update_input {mutes:"music"|"sfx"|... or "master" for everything}), then a listener {type:"setMute",
70
+ bus:"music", muted:"toggle"} (or toggleInput on that input; not both) and a slot color binding to show the state. The
71
+ app embedding the animation mutes it the same way (setInput("musicOff", true), or player.setBusMuted("music", true)).
72
+ Looping sounds stop when their state or
71
73
  animation ends. Mix with update_sound {volume, rate, loop, fadeIn, fadeOut, bus}, add_bus/update_bus {volume, muted},
72
74
  set_audio_mix {master, muted}. simulate_state_machine lists the audio commands.
73
75
  11. Sprite sequences (frame-by-frame, e.g. fire or explosions): add_image for each frame (or one sheet image), then
package/dist/server.js CHANGED
@@ -30,7 +30,7 @@ export function createServer(opts = {}) {
30
30
  const session = opts.session ?? new ProjectSession();
31
31
  let host = opts.scriptHost;
32
32
  const scriptHost = async () => (host ??= await createQuickJsHost({ timeoutMs: 50 }));
33
- const server = new McpServer({ name: "openbone", version: "0.3.0" }, {
33
+ const server = new McpServer({ name: "openbone", version: "0.4.0" }, {
34
34
  instructions: "OpenBone: 2D skeletal animation + interactive state machines. Read the openbone://guide resource (or call get_guide) first. Start with new_project or open_project; edit with the add_*/update_*/set_keys tools; verify with render_frame and simulate_state_machine.",
35
35
  });
36
36
  // ---------- Generated edit tools (one per core op) ----------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openbone/mcp",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "MCP server for OpenBone: let AI agents rig, animate and wire up interactive skeletal animations",
5
5
  "keywords": [
6
6
  "openbone",
@@ -52,12 +52,12 @@
52
52
  "gifenc": "^1.0.3",
53
53
  "ws": "^8.18.0",
54
54
  "zod": "^4.1.0",
55
- "@openbone/player": "0.3.0",
56
- "@openbone/export": "0.3.0",
57
- "@openbone/core": "0.3.0",
58
- "@openbone/render-canvas": "0.3.0",
59
- "@openbone/scripting": "0.3.0",
60
- "@openbone/runtime": "0.3.0"
55
+ "@openbone/core": "0.4.0",
56
+ "@openbone/player": "0.4.0",
57
+ "@openbone/export": "0.4.0",
58
+ "@openbone/render-canvas": "0.4.0",
59
+ "@openbone/scripting": "0.4.0",
60
+ "@openbone/runtime": "0.4.0"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/ws": "^8.18.1"