@openbone/mcp 0.4.3 → 0.4.4
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.js +15 -7
- package/dist/server.js +1 -1
- package/dist/session.d.ts +4 -0
- package/dist/session.js +10 -0
- package/package.json +7 -7
package/dist/bridge.js
CHANGED
|
@@ -8,13 +8,17 @@ import { isLocalRequest } from "./local-only.js";
|
|
|
8
8
|
* agent appear instantly in the editor, and edits made in the editor are visible to the agent.
|
|
9
9
|
*
|
|
10
10
|
* Messages (JSON):
|
|
11
|
-
* editor → server: {type:"hello"} | {type:"op", op, args} | {type:"undo"} | {type:"redo"} | {type:"load", doc}
|
|
11
|
+
* editor → server: {type:"hello", doc?} | {type:"op", op, args} | {type:"undo"} | {type:"redo"} | {type:"load", doc}
|
|
12
12
|
* server → editor: {type:"load", doc, path} | {type:"ops", ops} | {type:"error", message}
|
|
13
13
|
* | {type:"files", files:[{src, kind, mime, base64}]}
|
|
14
14
|
*
|
|
15
15
|
* The server stores imported art and sound as paths relative to the project file, which the editor (a web page, or
|
|
16
16
|
* the desktop app without that project open) can't read. So before the document or ops that use such a path, the
|
|
17
17
|
* server sends the file's bytes ("files"), and the editor shows and plays them from memory.
|
|
18
|
+
*
|
|
19
|
+
* Connecting never replaces the editor's scene with an empty one: the editor's hello carries its document, and a
|
|
20
|
+
* server that has no project yet (nothing created, opened or edited) takes it over and waits for the agent. A server
|
|
21
|
+
* already working on a project sends that project instead.
|
|
18
22
|
*/
|
|
19
23
|
const MEDIA = {
|
|
20
24
|
ttf: { kind: "font", mime: "font/ttf" },
|
|
@@ -108,13 +112,11 @@ export function startBridge(session, port, log) {
|
|
|
108
112
|
if (e.kind === "op" || e.kind === "transaction")
|
|
109
113
|
broadcast({ type: "ops", ops: e.ops }, except);
|
|
110
114
|
else
|
|
111
|
-
broadcast({ type: "load", doc, path: session.filePath });
|
|
115
|
+
broadcast({ type: "load", doc, path: session.filePath }, except);
|
|
112
116
|
});
|
|
113
117
|
wss.on("connection", (ws) => {
|
|
114
118
|
clients.add(ws);
|
|
115
119
|
log(`editor connected (${clients.size})`);
|
|
116
|
-
sendFiles(ws);
|
|
117
|
-
send(ws, { type: "load", doc: session.doc, path: session.filePath });
|
|
118
120
|
ws.on("close", () => clients.delete(ws));
|
|
119
121
|
ws.on("message", async (raw) => {
|
|
120
122
|
let msg;
|
|
@@ -128,8 +130,14 @@ export function startBridge(session, port, log) {
|
|
|
128
130
|
try {
|
|
129
131
|
if (msg.type === "hello") {
|
|
130
132
|
sentFiles.delete(ws); // a fresh editor page: send every file again
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
if (msg.doc && session.pristine) {
|
|
134
|
+
session.store.load(msg.doc, "bridge");
|
|
135
|
+
log("bridge: took over the editor's open project");
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
sendFiles(ws);
|
|
139
|
+
send(ws, { type: "load", doc: session.doc, path: session.filePath });
|
|
140
|
+
}
|
|
133
141
|
}
|
|
134
142
|
else if (msg.type === "op" && msg.op)
|
|
135
143
|
session.store.apply(msg.op, msg.args ?? {}, "bridge");
|
|
@@ -138,7 +146,7 @@ export function startBridge(session, port, log) {
|
|
|
138
146
|
else if (msg.type === "redo")
|
|
139
147
|
session.store.redo();
|
|
140
148
|
else if (msg.type === "load" && msg.doc)
|
|
141
|
-
session.store.load(msg.doc);
|
|
149
|
+
session.store.load(msg.doc, "bridge");
|
|
142
150
|
await session.maybeAutosave();
|
|
143
151
|
}
|
|
144
152
|
catch (e) {
|
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.4.
|
|
33
|
+
const server = new McpServer({ name: "openbone", version: "0.4.4" }, {
|
|
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/dist/session.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ export declare class ProjectSession {
|
|
|
5
5
|
store: DocumentStore;
|
|
6
6
|
filePath: string | null;
|
|
7
7
|
autosave: boolean;
|
|
8
|
+
/** Nothing has happened yet: no project created or opened, no edit. An editor that connects now keeps its scene. */
|
|
9
|
+
private touched;
|
|
10
|
+
constructor();
|
|
11
|
+
get pristine(): boolean;
|
|
8
12
|
get doc(): OpenBoneDocument;
|
|
9
13
|
get baseDir(): string;
|
|
10
14
|
newProject(name: string, filePath: string | null, opts?: Partial<OpenBoneDocument>): void;
|
package/dist/session.js
CHANGED
|
@@ -6,6 +6,16 @@ export class ProjectSession {
|
|
|
6
6
|
store = new DocumentStore(createDocument("Untitled"));
|
|
7
7
|
filePath = null;
|
|
8
8
|
autosave = true;
|
|
9
|
+
/** Nothing has happened yet: no project created or opened, no edit. An editor that connects now keeps its scene. */
|
|
10
|
+
touched = false;
|
|
11
|
+
constructor() {
|
|
12
|
+
this.store.subscribe(() => {
|
|
13
|
+
this.touched = true;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
get pristine() {
|
|
17
|
+
return !this.touched && this.filePath === null;
|
|
18
|
+
}
|
|
9
19
|
get doc() {
|
|
10
20
|
return this.store.doc;
|
|
11
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openbone/mcp",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
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/core": "0.4.
|
|
56
|
-
"@openbone/export": "0.4.
|
|
57
|
-
"@openbone/
|
|
58
|
-
"@openbone/
|
|
59
|
-
"@openbone/
|
|
60
|
-
"@openbone/
|
|
55
|
+
"@openbone/core": "0.4.4",
|
|
56
|
+
"@openbone/export": "0.4.4",
|
|
57
|
+
"@openbone/render-canvas": "0.4.4",
|
|
58
|
+
"@openbone/runtime": "0.4.4",
|
|
59
|
+
"@openbone/player": "0.4.4",
|
|
60
|
+
"@openbone/scripting": "0.4.4"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/ws": "^8.18.1"
|