@project-ava-supernova/core 0.2.185 → 0.2.187

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.
Files changed (191) hide show
  1. package/dist/agent/agent.d.ts +1 -6
  2. package/dist/agent/agent.d.ts.map +1 -1
  3. package/dist/agent/agent.js +11 -58
  4. package/dist/agent/agent.js.map +1 -1
  5. package/dist/agent/system-prompt.d.ts.map +1 -1
  6. package/dist/agent/system-prompt.js +13 -1
  7. package/dist/agent/system-prompt.js.map +1 -1
  8. package/dist/auto/auto-coordinator.d.ts.map +1 -1
  9. package/dist/auto/auto-coordinator.js +4 -17
  10. package/dist/auto/auto-coordinator.js.map +1 -1
  11. package/dist/brand/brand-kits.d.ts.map +1 -1
  12. package/dist/brand/brand-kits.js +18 -6
  13. package/dist/brand/brand-kits.js.map +1 -1
  14. package/dist/briefing/briefing-engine.d.ts +4 -3
  15. package/dist/briefing/briefing-engine.d.ts.map +1 -1
  16. package/dist/briefing/briefing-engine.js +16 -18
  17. package/dist/briefing/briefing-engine.js.map +1 -1
  18. package/dist/briefing/types.d.ts +4 -2
  19. package/dist/briefing/types.d.ts.map +1 -1
  20. package/dist/desktop/index.d.ts +2 -0
  21. package/dist/desktop/index.d.ts.map +1 -1
  22. package/dist/desktop/index.js +2 -0
  23. package/dist/desktop/index.js.map +1 -1
  24. package/dist/desktop/learned-steps.d.ts +39 -0
  25. package/dist/desktop/learned-steps.d.ts.map +1 -0
  26. package/dist/desktop/learned-steps.js +108 -0
  27. package/dist/desktop/learned-steps.js.map +1 -0
  28. package/dist/docs/content/concepts.d.ts.map +1 -1
  29. package/dist/docs/content/concepts.js +15 -13
  30. package/dist/docs/content/concepts.js.map +1 -1
  31. package/dist/docs/content/features.d.ts.map +1 -1
  32. package/dist/docs/content/features.js +2 -1
  33. package/dist/docs/content/features.js.map +1 -1
  34. package/dist/docs/content/reference.d.ts.map +1 -1
  35. package/dist/docs/content/reference.js +3 -5
  36. package/dist/docs/content/reference.js.map +1 -1
  37. package/dist/docs/content/troubleshooting.js +1 -1
  38. package/dist/docs/content/troubleshooting.js.map +1 -1
  39. package/dist/docs/data/tools.js +4 -4
  40. package/dist/docs/data/tools.js.map +1 -1
  41. package/dist/docs/i18n/translations.d.ts.map +1 -1
  42. package/dist/docs/i18n/translations.js +1 -1
  43. package/dist/docs/i18n/translations.js.map +1 -1
  44. package/dist/events/event-detector.d.ts +0 -3
  45. package/dist/events/event-detector.d.ts.map +1 -1
  46. package/dist/events/event-detector.js +0 -27
  47. package/dist/events/event-detector.js.map +1 -1
  48. package/dist/i18n/locales/ar.d.ts.map +1 -1
  49. package/dist/i18n/locales/ar.js +87 -0
  50. package/dist/i18n/locales/ar.js.map +1 -1
  51. package/dist/i18n/locales/de.d.ts.map +1 -1
  52. package/dist/i18n/locales/de.js +87 -0
  53. package/dist/i18n/locales/de.js.map +1 -1
  54. package/dist/i18n/locales/en.d.ts +87 -0
  55. package/dist/i18n/locales/en.d.ts.map +1 -1
  56. package/dist/i18n/locales/en.js +89 -0
  57. package/dist/i18n/locales/en.js.map +1 -1
  58. package/dist/i18n/locales/es.d.ts.map +1 -1
  59. package/dist/i18n/locales/es.js +87 -0
  60. package/dist/i18n/locales/es.js.map +1 -1
  61. package/dist/i18n/locales/fr.d.ts.map +1 -1
  62. package/dist/i18n/locales/fr.js +87 -0
  63. package/dist/i18n/locales/fr.js.map +1 -1
  64. package/dist/i18n/locales/hi.d.ts.map +1 -1
  65. package/dist/i18n/locales/hi.js +87 -0
  66. package/dist/i18n/locales/hi.js.map +1 -1
  67. package/dist/i18n/locales/id.d.ts.map +1 -1
  68. package/dist/i18n/locales/id.js +87 -0
  69. package/dist/i18n/locales/id.js.map +1 -1
  70. package/dist/i18n/locales/it.d.ts.map +1 -1
  71. package/dist/i18n/locales/it.js +87 -0
  72. package/dist/i18n/locales/it.js.map +1 -1
  73. package/dist/i18n/locales/ja.d.ts.map +1 -1
  74. package/dist/i18n/locales/ja.js +87 -0
  75. package/dist/i18n/locales/ja.js.map +1 -1
  76. package/dist/i18n/locales/ko.d.ts.map +1 -1
  77. package/dist/i18n/locales/ko.js +87 -0
  78. package/dist/i18n/locales/ko.js.map +1 -1
  79. package/dist/i18n/locales/nl.d.ts.map +1 -1
  80. package/dist/i18n/locales/nl.js +87 -0
  81. package/dist/i18n/locales/nl.js.map +1 -1
  82. package/dist/i18n/locales/pl.d.ts.map +1 -1
  83. package/dist/i18n/locales/pl.js +87 -0
  84. package/dist/i18n/locales/pl.js.map +1 -1
  85. package/dist/i18n/locales/pt.d.ts.map +1 -1
  86. package/dist/i18n/locales/pt.js +87 -0
  87. package/dist/i18n/locales/pt.js.map +1 -1
  88. package/dist/i18n/locales/ru.d.ts.map +1 -1
  89. package/dist/i18n/locales/ru.js +87 -0
  90. package/dist/i18n/locales/ru.js.map +1 -1
  91. package/dist/i18n/locales/th.d.ts.map +1 -1
  92. package/dist/i18n/locales/th.js +87 -0
  93. package/dist/i18n/locales/th.js.map +1 -1
  94. package/dist/i18n/locales/tr.d.ts.map +1 -1
  95. package/dist/i18n/locales/tr.js +87 -0
  96. package/dist/i18n/locales/tr.js.map +1 -1
  97. package/dist/i18n/locales/uk.d.ts.map +1 -1
  98. package/dist/i18n/locales/uk.js +87 -0
  99. package/dist/i18n/locales/uk.js.map +1 -1
  100. package/dist/i18n/locales/vi.d.ts.map +1 -1
  101. package/dist/i18n/locales/vi.js +87 -0
  102. package/dist/i18n/locales/vi.js.map +1 -1
  103. package/dist/i18n/locales/zh-CN.d.ts.map +1 -1
  104. package/dist/i18n/locales/zh-CN.js +87 -0
  105. package/dist/i18n/locales/zh-CN.js.map +1 -1
  106. package/dist/i18n/locales/zh-TW.d.ts.map +1 -1
  107. package/dist/i18n/locales/zh-TW.js +87 -0
  108. package/dist/i18n/locales/zh-TW.js.map +1 -1
  109. package/dist/index.d.ts +8 -2
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +9 -3
  112. package/dist/index.js.map +1 -1
  113. package/dist/mcp/connection.d.ts +98 -0
  114. package/dist/mcp/connection.d.ts.map +1 -0
  115. package/dist/mcp/connection.js +182 -0
  116. package/dist/mcp/connection.js.map +1 -0
  117. package/dist/mcp/index.d.ts +5 -0
  118. package/dist/mcp/index.d.ts.map +1 -0
  119. package/dist/mcp/index.js +3 -0
  120. package/dist/mcp/index.js.map +1 -0
  121. package/dist/mcp/tools.d.ts +30 -0
  122. package/dist/mcp/tools.d.ts.map +1 -0
  123. package/dist/mcp/tools.js +83 -0
  124. package/dist/mcp/tools.js.map +1 -0
  125. package/dist/memory-v4/import-v3.d.ts +6 -0
  126. package/dist/memory-v4/import-v3.d.ts.map +1 -1
  127. package/dist/memory-v4/import-v3.js +30 -2
  128. package/dist/memory-v4/import-v3.js.map +1 -1
  129. package/dist/memory-v4/index.d.ts +1 -1
  130. package/dist/memory-v4/index.d.ts.map +1 -1
  131. package/dist/memory-v4/index.js +1 -1
  132. package/dist/memory-v4/index.js.map +1 -1
  133. package/dist/memory-v4/model.d.ts +13 -1
  134. package/dist/memory-v4/model.d.ts.map +1 -1
  135. package/dist/memory-v4/model.js +13 -3
  136. package/dist/memory-v4/model.js.map +1 -1
  137. package/dist/memory-v4/page.d.ts +2 -1
  138. package/dist/memory-v4/page.d.ts.map +1 -1
  139. package/dist/memory-v4/page.js +13 -2
  140. package/dist/memory-v4/page.js.map +1 -1
  141. package/dist/memory-v4/projects.d.ts +2 -0
  142. package/dist/memory-v4/projects.d.ts.map +1 -1
  143. package/dist/memory-v4/projects.js +7 -0
  144. package/dist/memory-v4/projects.js.map +1 -1
  145. package/dist/memory-v4/reader.d.ts +3 -3
  146. package/dist/memory-v4/reader.d.ts.map +1 -1
  147. package/dist/memory-v4/reader.js +2 -4
  148. package/dist/memory-v4/reader.js.map +1 -1
  149. package/dist/memory-v4/store.d.ts +24 -0
  150. package/dist/memory-v4/store.d.ts.map +1 -1
  151. package/dist/memory-v4/store.js +74 -1
  152. package/dist/memory-v4/store.js.map +1 -1
  153. package/dist/tools/benchmark.d.ts.map +1 -1
  154. package/dist/tools/benchmark.js +21 -25
  155. package/dist/tools/benchmark.js.map +1 -1
  156. package/dist/tools/blender/build-model.d.ts +10 -0
  157. package/dist/tools/blender/build-model.d.ts.map +1 -1
  158. package/dist/tools/blender/build-model.js +11 -2
  159. package/dist/tools/blender/build-model.js.map +1 -1
  160. package/dist/tools/blender/live-setup.d.ts +63 -0
  161. package/dist/tools/blender/live-setup.d.ts.map +1 -0
  162. package/dist/tools/blender/live-setup.js +281 -0
  163. package/dist/tools/blender/live-setup.js.map +1 -0
  164. package/dist/tools/blender/live-tools.d.ts +83 -0
  165. package/dist/tools/blender/live-tools.d.ts.map +1 -0
  166. package/dist/tools/blender/live-tools.js +402 -0
  167. package/dist/tools/blender/live-tools.js.map +1 -0
  168. package/dist/tools/blender/live.d.ts +88 -0
  169. package/dist/tools/blender/live.d.ts.map +1 -0
  170. package/dist/tools/blender/live.js +285 -0
  171. package/dist/tools/blender/live.js.map +1 -0
  172. package/dist/tools/blender/runner-py.d.ts +7 -0
  173. package/dist/tools/blender/runner-py.d.ts.map +1 -1
  174. package/dist/tools/blender/runner-py.js +108 -100
  175. package/dist/tools/blender/runner-py.js.map +1 -1
  176. package/dist/tools/design-fonts.d.ts +3 -2
  177. package/dist/tools/design-fonts.d.ts.map +1 -1
  178. package/dist/tools/design-fonts.js +16 -2
  179. package/dist/tools/design-fonts.js.map +1 -1
  180. package/dist/tools/learning.d.ts.map +1 -1
  181. package/dist/tools/learning.js +4 -16
  182. package/dist/tools/learning.js.map +1 -1
  183. package/dist/tools/report-generate.d.ts +1 -0
  184. package/dist/tools/report-generate.d.ts.map +1 -1
  185. package/dist/tools/report-generate.js +10 -9
  186. package/dist/tools/report-generate.js.map +1 -1
  187. package/dist/tools/tool-registry.d.ts +2 -0
  188. package/dist/tools/tool-registry.d.ts.map +1 -1
  189. package/dist/tools/tool-registry.js +20 -8
  190. package/dist/tools/tool-registry.js.map +1 -1
  191. package/package.json +2 -1
@@ -0,0 +1,402 @@
1
+ /**
2
+ * Blender Live — Ava's tools for working in the person's open Blender.
3
+ * Plan: Decisions/plans/2026-11-16-blender-mcp.md (private), Phase 2.
4
+ *
5
+ * Live work lands exactly where headless work does — the model's own folder
6
+ * (~/.ava/creative/blender/<slug>/): its .blend, .glb (+ .fbx), preview.png,
7
+ * history steps, Library entry and making record — so the Library, versions,
8
+ * Duplicate and Restore don't care which way a model was made.
9
+ *
10
+ * design_live_open_model — open (or start) the model's .blend in their Blender
11
+ * design_live_step — one small step of her Python, checked first, then a look
12
+ * design_live_save — save, export, preview, record a step, update the Library
13
+ *
14
+ * Plus Blender's own tools from the server (scene summaries, screenshots,
15
+ * jumping the view, API/manual search), minus the background "_for_cli" ones
16
+ * (that's Headless) and raw code-running (which goes through design_live_step).
17
+ *
18
+ * Safety (his call, 17 Nov: "Ava is safe by design … dont need to be very
19
+ * heavy"): the same script check as Headless before every step, running code
20
+ * asks first through the normal approval, renders stay inside the model folder.
21
+ * The brief comes first, as in Headless.
22
+ */
23
+ import { existsSync } from 'node:fs';
24
+ import { copyFile, mkdir, readFile, writeFile } from 'node:fs/promises';
25
+ import { join, resolve } from 'node:path';
26
+ import { mcpToolsForAva } from '../../mcp/tools.js';
27
+ import { BlenderLive } from './live.js';
28
+ import { BLENDER_HELPERS_PY } from './runner-py.js';
29
+ import { KIT_PY } from '../../brand/kit-py.js';
30
+ import { kitForScripts } from '../../brand/brand-kits.js';
31
+ import { modelsDir, modelSlug } from './paths.js';
32
+ import { readModelBrief } from './model-brief.js';
33
+ import { checkBlenderScript, upsertLibraryEntry } from './build-model.js';
34
+ import { recordModelStep } from './model-history.js';
35
+ import { appendMaking, avaContext, beforeChange, sourcesNow } from '../making-record.js';
36
+ import { fileLinkedWork } from '../../creative/library-folders.js';
37
+ /** The model open in their Blender right now (kept on BlenderLive, so Headless can see it). */
38
+ export const liveModelNow = () => BlenderLive.current().openModel;
39
+ const py = (s) => JSON.stringify(s); // a JSON string is a valid Python string literal
40
+ /** Run code in their Blender through the server; read Blender's {status, result | message, stdout}. */
41
+ async function runPy(conn, code, signal) {
42
+ const r = await conn.call('execute_blender_code', { code }, { signal, timeoutMs: 300_000 });
43
+ let body = {};
44
+ try {
45
+ body = JSON.parse(r.text);
46
+ }
47
+ catch { /* not JSON: report the text */ }
48
+ const stdout = typeof body.stdout === 'string' ? body.stdout.trim() : '';
49
+ if (r.isError || body.status === 'error' || (!('status' in body) && r.isError)) {
50
+ return { ok: false, message: String(body.message ?? r.text ?? 'Blender reported an error.').trim(), stdout };
51
+ }
52
+ const result = (body.result && typeof body.result === 'object' ? body.result : {});
53
+ return { ok: true, result, message: '', stdout };
54
+ }
55
+ async function readyConnection() {
56
+ const live = BlenderLive.current();
57
+ if (!live.connection) {
58
+ return { success: false, output: `MCP isn't connected (${live.lastStatus.message}). Work headless with design_build_model, or ask them to switch the room to MCP.` };
59
+ }
60
+ const s = await live.refresh();
61
+ if (s.state !== 'ready')
62
+ return { success: false, output: `${s.message} Tell them, and wait — or work headless.` };
63
+ return live.connection;
64
+ }
65
+ async function agreedBrief(name, slug) {
66
+ const brief = await readModelBrief(slug);
67
+ if (!brief)
68
+ return { success: false, output: `"${name}" has no brief yet. Research it, then propose the brief with design_propose_model_brief — they agree it on the card first, Live or not.` };
69
+ if (brief.status !== 'agreed')
70
+ return { success: false, output: `The brief for "${name}" is still waiting for them to agree it on the card.` };
71
+ return null;
72
+ }
73
+ function schema(name, description, properties, required) {
74
+ return { name, description, parameters: { type: 'object', properties, required } };
75
+ }
76
+ // ── Looking ──────────────────────────────────────────────────────────────────
77
+ // Tested on his Blender 5.2.2 (17 Nov): the server's screenshot tools came back
78
+ // pure black (window and area), while an OFF-SCREEN render of the 3D view gave
79
+ // exactly what he sees, in half a second. So Ava looks with that, falling back
80
+ // to Blender's thumbnail render (the camera view), then a screenshot.
81
+ const LOOK_PY = (out) => `import bpy, os
82
+ out = ${py(out)}
83
+ os.makedirs(os.path.dirname(out), exist_ok=True)
84
+ win = area = None
85
+ for w in bpy.context.window_manager.windows:
86
+ for a in w.screen.areas:
87
+ if a.type == "VIEW_3D":
88
+ win, area = w, a
89
+ break
90
+ if area:
91
+ break
92
+ if area is None:
93
+ result = {"ok": False, "why": "no 3D viewport is open"}
94
+ else:
95
+ region = next(r for r in area.regions if r.type == "WINDOW")
96
+ with bpy.context.temp_override(window=win, area=area, region=region):
97
+ bpy.ops.render.opengl(view_context=True)
98
+ bpy.data.images["Render Result"].save_render(out)
99
+ result = {"ok": os.path.exists(out)}
100
+ `;
101
+ /** Copy the file a render-to-path tool reports (the add-on writes in its own temp folder). */
102
+ async function copyReported(text, to) {
103
+ try {
104
+ const body = JSON.parse(text);
105
+ const from = body.result?.filepath ?? body.result?.path ?? body.filepath;
106
+ if (!from || !existsSync(from))
107
+ return false;
108
+ await copyFile(from, to);
109
+ return true;
110
+ }
111
+ catch {
112
+ return false;
113
+ }
114
+ }
115
+ /** A picture of the model as it is now, as base64 PNG — or null. */
116
+ export async function liveLook(conn, modelDir) {
117
+ const out = join(modelDir, '.live', 'view.png');
118
+ const view = await runPy(conn, LOOK_PY(out)).catch(() => null);
119
+ if (view?.ok && view.result?.ok && existsSync(out))
120
+ return (await readFile(out)).toString('base64');
121
+ const thumb = await conn.call('render_thumbnail_to_path', { output_path: out }, { timeoutMs: 120_000 }).catch(() => null);
122
+ if (thumb && !thumb.isError && (await copyReported(thumb.text, out)))
123
+ return (await readFile(out)).toString('base64');
124
+ const shot = await conn.call('get_screenshot_of_area_as_image', { area_ui_type: 'VIEW_3D' }, { timeoutMs: 30_000 }).catch(() => null);
125
+ return shot?.images[0]?.data ?? null;
126
+ }
127
+ // ── design_live_open_model ───────────────────────────────────────────────────
128
+ export class DesignLiveOpenModelTool {
129
+ name = 'design_live_open_model';
130
+ description = 'Open a model in their open Blender (Live), or start it there if it is new.';
131
+ riskLevel = 'write';
132
+ requiresConfirmation = false;
133
+ schema = schema(this.name, 'Open the model\'s own .blend in THEIR open Blender so you can work on it Live, or start it on an empty scene if it is new. ' +
134
+ 'Do this before design_live_step. If their Blender has unsaved work in another file, nothing is opened — ask them to save it first. Needs an agreed brief.', { name: { type: 'string', description: 'The model\'s name, e.g. "Worn Supply Crate".' } }, ['name']);
135
+ async execute(args, context) {
136
+ const name = String(args.name ?? '').trim();
137
+ const slug = modelSlug(name);
138
+ if (!slug)
139
+ return { success: false, output: 'Missing `name`.' };
140
+ const brief = await agreedBrief(name, slug);
141
+ if (brief)
142
+ return brief;
143
+ const conn = await readyConnection();
144
+ if (!('call' in conn))
145
+ return conn;
146
+ const dir = join(modelsDir(), slug);
147
+ const blend = join(dir, `${slug}.blend`);
148
+ await mkdir(dir, { recursive: true });
149
+ await beforeChange(dir, 'blender');
150
+ const isNew = !existsSync(blend);
151
+ // Opening a file inside the add-on's own request is avoided: it is scheduled
152
+ // for just after Blender answers, then checked.
153
+ const check = await runPy(conn, `import bpy, os
154
+ target = ${py(blend)}
155
+ cur = bpy.data.filepath
156
+ same = bool(cur) and os.path.normcase(os.path.abspath(cur)) == os.path.normcase(os.path.abspath(target))
157
+ if same:
158
+ result = {"state": "already"}
159
+ elif bpy.data.is_dirty:
160
+ result = {"state": "unsaved", "file": cur or "a new file that was never saved"}
161
+ else:
162
+ def _ava_open():
163
+ if os.path.exists(target):
164
+ bpy.ops.wm.open_mainfile(filepath=target)
165
+ else:
166
+ bpy.ops.wm.read_homefile(use_empty=True)
167
+ bpy.ops.wm.save_as_mainfile(filepath=target)
168
+ return None
169
+ bpy.app.timers.register(_ava_open, first_interval=0.2)
170
+ result = {"state": "opening"}
171
+ `, context.signal);
172
+ if (!check.ok)
173
+ return { success: false, output: `Blender couldn't open "${name}": ${check.message}` };
174
+ if (check.result?.state === 'unsaved') {
175
+ return { success: false, output: `Nothing was opened: their Blender has unsaved work in ${String(check.result.file)}. Ask them to save it (or close it without saving, their choice), then try again. Never discard it yourself.` };
176
+ }
177
+ if (check.result?.state === 'opening') {
178
+ let opened = false;
179
+ for (let i = 0; i < 20 && !opened; i++) {
180
+ await new Promise((r) => setTimeout(r, 500));
181
+ const now = await runPy(conn, `import bpy, os\nresult = {"file": bpy.data.filepath}`).catch(() => null);
182
+ const f = String(now?.result?.file ?? '');
183
+ opened = !!f && resolve(f).toLowerCase() === resolve(blend).toLowerCase();
184
+ }
185
+ if (!opened)
186
+ return { success: false, output: `Blender didn't open "${name}" in time. Ask them to look at Blender, then try again.` };
187
+ }
188
+ BlenderLive.current().openModel = { slug, name, dir, blend };
189
+ return {
190
+ success: true,
191
+ output: `"${name}" is open in their Blender${isNew ? ' on an empty scene (no default cube, camera or light)' : ''}. ` +
192
+ 'Work in small steps with design_live_step, talk them through each one, and design_live_save when a step is worth keeping. They can take the mouse at any time.',
193
+ };
194
+ }
195
+ }
196
+ // ── design_live_step ─────────────────────────────────────────────────────────
197
+ export class DesignLiveStepTool {
198
+ name = 'design_live_step';
199
+ description = 'Run one small step of Blender Python in their open Blender, then see the viewport.';
200
+ riskLevel = 'dangerous';
201
+ requiresConfirmation = true;
202
+ schema = schema(this.name, 'Run ONE small step of your Blender Python (bpy) in THEIR open Blender, on the model opened with design_live_open_model, then get a picture of the 3D viewport so you SEE the result. ' +
203
+ 'They watch it happen and may have changed things by hand since your last step — read the scene first when unsure (blender_live_get_objects_summary). ' +
204
+ 'ASSET_DIR (the model\'s folder), KIT (the brand kit) and the helpers ava_unwrap() and ava_bake() are predefined, exactly as in Headless — bake here when the look is right; Blender is busy while it bakes, so tell them first. Write files only inside ASSET_DIR. Don\'t save, open or reset files yourself — design_live_save does that. ' +
205
+ 'To return values, set `result` to a JSON-serialisable dict. Units are metres, Z is up.', {
206
+ script: { type: 'string', description: 'The Blender Python for this one step.' },
207
+ description: { type: 'string', description: 'What this step does, in a few words (shown to them and kept with the script).' },
208
+ }, ['script']);
209
+ async execute(args, context) {
210
+ const script = String(args.script ?? '');
211
+ if (!script.trim())
212
+ return { success: false, output: 'Missing `script`.' };
213
+ const model = liveModelNow();
214
+ if (!model)
215
+ return { success: false, output: 'No model is open Live. Open one with design_live_open_model first.' };
216
+ const refused = checkBlenderScript(script);
217
+ if (refused)
218
+ return { success: false, output: refused };
219
+ const conn = await readyConnection();
220
+ if (!('call' in conn))
221
+ return conn;
222
+ // Keep every step's script beside the model, as Headless does.
223
+ const scriptsDir = join(model.dir, 'scripts');
224
+ await mkdir(scriptsDir, { recursive: true });
225
+ await writeFile(join(scriptsDir, `${new Date().toISOString().replace(/[:.]/g, '-')}-live.py`), script, 'utf-8');
226
+ // The same helpers and brand kit as Headless: KIT, ava_unwrap(), ava_bake().
227
+ const kit = await kitForScripts(context.sharedState?.designProject?.()).catch(() => null);
228
+ const prelude = `import bpy, os, json, math
229
+ ASSET_DIR = ${py(model.dir)}
230
+ JOB = json.loads(${py(JSON.stringify({ kit: kit ?? null }))})
231
+ ${KIT_PY}
232
+ ${BLENDER_HELPERS_PY}
233
+ if os.path.normcase(os.path.abspath(bpy.data.filepath or "")) != os.path.normcase(os.path.abspath(${py(model.blend)})):
234
+ raise RuntimeError("The file open in Blender isn't the model any more (they may have opened another). Open it again with design_live_open_model.")
235
+ `;
236
+ const run = await runPy(conn, `${prelude}\n${script}`, context.signal);
237
+ const picture = await liveLook(conn, model.dir);
238
+ const image = picture ? { data: picture, mimeType: 'image/png' } : undefined;
239
+ const said = [run.stdout && `What the script printed:\n${run.stdout.slice(-4000)}`].filter(Boolean).join('\n');
240
+ if (!run.ok) {
241
+ return {
242
+ success: false,
243
+ output: `The step stopped with an error in their Blender — anything it did before the error is still in the scene (Ctrl+Z in Blender undoes it). Nothing was saved.\n\n${run.message.slice(-4000)}${said ? `\n\n${said}` : ''}`,
244
+ metadata: image ? { base64_image: image.data, mime_type: image.mimeType } : undefined,
245
+ };
246
+ }
247
+ const result = run.result && Object.keys(run.result).length ? `\nresult: ${JSON.stringify(run.result).slice(0, 4000)}` : '';
248
+ return {
249
+ success: true,
250
+ output: `Step done in their Blender${typeof args.description === 'string' ? ` (${args.description})` : ''}.${result}${said ? `\n${said}` : ''}\n` +
251
+ (image ? 'Here is the 3D view now — check it against the brief before you say anything about it.' : 'No picture could be taken of the 3D view (is a 3D viewport open?). Read the scene with blender_live_get_objects_summary instead.'),
252
+ metadata: image ? { base64_image: image.data, mime_type: image.mimeType } : undefined,
253
+ };
254
+ }
255
+ }
256
+ // ── design_live_save ─────────────────────────────────────────────────────────
257
+ export class DesignLiveSaveTool {
258
+ name = 'design_live_save';
259
+ description = 'Save the Live model: its .blend, a .glb (and .fbx if asked), a preview, a history step and the Library entry.';
260
+ riskLevel = 'write';
261
+ requiresConfirmation = false;
262
+ schema = schema(this.name, 'Save the model open Live in their Blender — the .blend, a .glb for the Library viewer (and an .fbx if asked), a preview picture — and keep it as a history step they can go back to. ' +
263
+ 'Do this when a step is worth keeping, and always before stopping. Their own changes in Blender are saved with it.', {
264
+ description: { type: 'string', description: 'What this saved step is, in a few words.' },
265
+ fbx: { type: 'boolean', description: 'Also export an .fbx (for Unreal and other engines).' },
266
+ }, []);
267
+ async execute(args, context) {
268
+ const model = liveModelNow();
269
+ if (!model)
270
+ return { success: false, output: 'No model is open Live.' };
271
+ const conn = await readyConnection();
272
+ if (!('call' in conn))
273
+ return conn;
274
+ const live = BlenderLive.current();
275
+ const glb = join(model.dir, `${model.slug}.glb`);
276
+ const fbx = join(model.dir, `${model.slug}.fbx`);
277
+ const saved = await runPy(conn, `import bpy, os
278
+ from mathutils import Vector
279
+ target = ${py(model.blend)}
280
+ if os.path.normcase(os.path.abspath(bpy.data.filepath or "")) != os.path.normcase(os.path.abspath(target)):
281
+ raise RuntimeError("The file open in Blender isn't the model any more. Open it again with design_live_open_model.")
282
+ bpy.ops.wm.save_mainfile()
283
+ bpy.ops.export_scene.gltf(filepath=${py(glb)}, export_format="GLB", use_selection=False)
284
+ ${args.fbx === true ? `bpy.ops.export_scene.fbx(filepath=${py(fbx)}, use_selection=False)` : 'pass'}
285
+ tris = 0
286
+ lo = [1e18] * 3
287
+ hi = [-1e18] * 3
288
+ dg = bpy.context.evaluated_depsgraph_get()
289
+ for ob in bpy.context.scene.objects:
290
+ if ob.type != "MESH":
291
+ continue
292
+ me = ob.evaluated_get(dg).to_mesh()
293
+ tris += sum(len(p.vertices) - 2 for p in me.polygons)
294
+ for v in me.vertices:
295
+ w = ob.matrix_world @ v.co
296
+ for i in range(3):
297
+ lo[i] = min(lo[i], w[i]); hi[i] = max(hi[i], w[i])
298
+ ob.evaluated_get(dg).to_mesh_clear()
299
+ size = [round(hi[i] - lo[i], 3) for i in range(3)] if tris else [0, 0, 0]
300
+ result = {"triangles": tris, "size_m": size, "version": bpy.app.version_string}
301
+ `, context.signal);
302
+ if (!saved.ok)
303
+ return { success: false, output: `Saving didn't finish: ${saved.message.slice(-3000)}` };
304
+ // The preview: Blender's own thumbnail render (the camera view). The add-on
305
+ // writes it in its own temp folder and reports the path, so copy it in. No
306
+ // camera, or no luck: the 3D view as it is.
307
+ const previewPath = join(model.dir, 'preview.png');
308
+ const thumb = await conn.call('render_thumbnail_to_path', { output_path: previewPath }, { timeoutMs: 120_000 }).catch(() => null);
309
+ if (!(thumb && !thumb.isError && (await copyReported(thumb.text, previewPath)))) {
310
+ const view = await liveLook(conn, model.dir);
311
+ if (view)
312
+ await writeFile(previewPath, Buffer.from(view, 'base64'));
313
+ }
314
+ const files = [`${model.slug}.blend`, `${model.slug}.glb`, ...(args.fbx === true ? [`${model.slug}.fbx`] : []), 'preview.png']
315
+ .filter((f) => existsSync(join(model.dir, f)));
316
+ const version = String(saved.result?.version ?? live.lastStatus.blenderVersion ?? '?');
317
+ const description = typeof args.description === 'string' ? args.description : undefined;
318
+ await upsertLibraryEntry({
319
+ slug: model.slug, name: model.name, description, files, blenderVersion: version,
320
+ triangles: Number(saved.result?.triangles) || undefined, sizeM: saved.result?.size_m,
321
+ }).catch(() => { });
322
+ const step = await recordModelStep(model.slug, description ?? '').catch(() => null);
323
+ await fileLinkedWork('blender', model.slug).catch(() => { });
324
+ const who = avaContext(context);
325
+ await appendMaking(model.dir, {
326
+ event: 'step', by: 'ava', ai: who.ai, ask: who.ask, tool: 'blender', app: `Blender ${version} (Live)`,
327
+ description: description ?? null, live: true, historyStep: step?.number ?? null, files,
328
+ sources: await sourcesNow(model.dir, 'blender'),
329
+ }).catch(() => { });
330
+ let preview;
331
+ try {
332
+ preview = (await readFile(join(model.dir, 'preview.png'))).toString('base64');
333
+ }
334
+ catch { /* none */ }
335
+ return {
336
+ success: true,
337
+ output: `Saved "${model.name}"${step ? ` as step ${step.number}` : ''}: ${files.join(', ')}. ` +
338
+ `${saved.result?.triangles ?? 0} triangles, size ${saved.result?.size_m?.join(' × ') ?? '?'} m (X × Y × Z). It's in the Library.`,
339
+ metadata: preview ? { base64_image: preview, mime_type: 'image/png' } : undefined,
340
+ };
341
+ }
342
+ }
343
+ // ── design_live_look ─────────────────────────────────────────────────────────
344
+ export class DesignLiveLookTool {
345
+ name = 'design_live_look';
346
+ description = 'See the 3D view of their open Blender right now.';
347
+ riskLevel = 'safe';
348
+ requiresConfirmation = false;
349
+ schema = schema(this.name, 'Get a picture of the 3D view in THEIR open Blender, as they see it — after they change something by hand, or before you decide the next step.', {}, []);
350
+ async execute() {
351
+ const conn = await readyConnection();
352
+ if (!('call' in conn))
353
+ return conn;
354
+ const dir = liveModelNow()?.dir ?? join(modelsDir(), '.live');
355
+ const picture = await liveLook(conn, dir);
356
+ if (!picture)
357
+ return { success: false, output: 'No picture could be taken of the 3D view (is a 3D viewport open in Blender?).' };
358
+ return { success: true, output: 'Here is their 3D view now.', metadata: { base64_image: picture, mime_type: 'image/png' } };
359
+ }
360
+ }
361
+ // ── Blender's own tools, as Ava's ────────────────────────────────────────────
362
+ /**
363
+ * Blender's server tools for Live, minus: the background "_for_cli" ones
364
+ * (that's Headless), raw code-running (design_live_step), and the image
365
+ * screenshots and render-to-path tools (black / written to the add-on's temp
366
+ * folder on his machine — design_live_look and design_live_save cover them).
367
+ */
368
+ export function blenderLiveServerTools(conn) {
369
+ const keep = conn.tools().map((t) => t.name).filter((n) => !n.endsWith('_for_cli') && n !== 'execute_blender_code' && !n.startsWith('render_') && !/^get_screenshot_.*_as_image$/.test(n));
370
+ return mcpToolsForAva(conn, {
371
+ only: keep,
372
+ // Moving the view or switching a tab changes nothing in their work.
373
+ risk: (t) => (t.name.startsWith('jump_to_') ? 'safe' : undefined),
374
+ });
375
+ }
376
+ /** Ava's Live tool names, and Blender's (for taking them away again). */
377
+ export const isBlenderLiveTool = (name) => name.startsWith('design_live_') || name.startsWith('blender_live_');
378
+ /**
379
+ * Put Ava's Live tools in a registry, or take them away: call on start and on
380
+ * every BlenderLive change. Live tools exist only while Blender is ready.
381
+ */
382
+ export function syncBlenderLiveTools(registry) {
383
+ registry.unregisterWhere(isBlenderLiveTool);
384
+ if (BlenderLive.current().lastStatus.state !== 'ready')
385
+ return 0;
386
+ const tools = blenderLiveTools();
387
+ for (const t of tools)
388
+ registry.register(t);
389
+ return tools.length;
390
+ }
391
+ /** Ava's own MCP tools (Blender's come from the server once connected). */
392
+ export function blenderLiveOwnTools() {
393
+ return [new DesignLiveOpenModelTool(), new DesignLiveStepTool(), new DesignLiveLookTool(), new DesignLiveSaveTool()];
394
+ }
395
+ /** Everything Ava gets while Live is connected. */
396
+ export function blenderLiveTools() {
397
+ const conn = BlenderLive.current().connection;
398
+ if (!conn)
399
+ return [];
400
+ return [...blenderLiveOwnTools(), ...blenderLiveServerTools(conn)];
401
+ }
402
+ //# sourceMappingURL=live-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-tools.js","sourceRoot":"","sources":["../../../src/tools/blender/live-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,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AAC;AAED,mDAAmD;AACnD,MAAM,UAAU,gBAAgB;IAC9B,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC;IAC9C,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,OAAO,CAAC,GAAG,mBAAmB,EAAE,EAAE,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC;AACrE,CAAC"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Blender Live — Ava working in the person's OPEN Blender through Blender
3
+ * Lab's official MCP server. Plan: Decisions/plans/2026-11-16-blender-mcp.md
4
+ * (private), Phase 2: the connection.
5
+ *
6
+ * Ava ⇄ (stdio) ⇄ blender-mcp [uv run, in ~/.ava/mcp/blender/<version>/]
7
+ * ⇄ (TCP, localhost:9876) ⇄ the "MCP" add-on inside Blender
8
+ *
9
+ * The server is Blender's own file (GPL-3.0) — never shipped with Ava; the
10
+ * person's copy, fetched from Blender's release page on their yes (Phase 4).
11
+ * It opens a fresh socket to Blender for every request, so it starts fine with
12
+ * Blender closed; whether Blender is ready is a separate check of the add-on's
13
+ * port.
14
+ */
15
+ import { McpConnection } from '../../mcp/connection.js';
16
+ export declare const BLENDER_MCP_HOST = "127.0.0.1";
17
+ export declare const BLENDER_MCP_PORT = 9876;
18
+ /** Live needs the add-on, which needs Blender 5.1 or newer. */
19
+ export declare const BLENDER_LIVE_MIN = "5.1.0";
20
+ export declare const blenderMcpRoot: () => string;
21
+ export type LiveState = 'needs-uv' | 'needs-server' | 'off' | 'blender-closed' | 'ready' | 'error';
22
+ export interface LiveStatus {
23
+ state: LiveState;
24
+ /** The open Blender's version, when it answered. */
25
+ blenderVersion?: string;
26
+ /** The server bundle's version (e.g. "1.0.3"). */
27
+ serverVersion?: string;
28
+ /** Plain words for the room, and for Ava. */
29
+ message: string;
30
+ }
31
+ /** uv, from PATH or where its own installer puts it (which isn't always on an app's PATH). */
32
+ export declare function findUv(): Promise<string | null>;
33
+ export declare const versionAtLeast: (v: string, min: string) => boolean;
34
+ /** The newest unpacked server bundle: ~/.ava/mcp/blender/<version>/ with Blender's manifest. */
35
+ export declare function installedServer(): Promise<{
36
+ dir: string;
37
+ version: string;
38
+ } | null>;
39
+ /** Is a Blender with the add-on's server running? (Its port answers.) */
40
+ export declare function addonListening(port?: number, timeoutMs?: number): Promise<boolean>;
41
+ export declare function blenderLiveWanted(): Promise<boolean>;
42
+ export declare function setBlenderLiveWanted(on: boolean): Promise<void>;
43
+ /** The model open Live in their Blender (one model, one place: Headless won't touch it). */
44
+ export interface LiveModel {
45
+ slug: string;
46
+ name: string;
47
+ dir: string;
48
+ blend: string;
49
+ }
50
+ type Listener = (s: LiveStatus) => void;
51
+ export declare class BlenderLive {
52
+ private static instance;
53
+ static current(): BlenderLive;
54
+ private conn;
55
+ private connecting;
56
+ private last;
57
+ private readonly listeners;
58
+ private watcher;
59
+ /** The model open Live right now (set by design_live_open_model). */
60
+ openModel: LiveModel | null;
61
+ /** For tests: start a different server than Blender's bundle. */
62
+ launch?: (env: Record<string, string>) => Promise<McpConnection>;
63
+ get connection(): McpConnection | null;
64
+ get lastStatus(): LiveStatus;
65
+ onChange(listener: Listener): () => void;
66
+ private set;
67
+ /** What's missing before Live can connect, without connecting. */
68
+ prerequisites(): Promise<LiveStatus | {
69
+ uv: string;
70
+ server: {
71
+ dir: string;
72
+ version: string;
73
+ };
74
+ }>;
75
+ /** Switch Live on: start the server and see whether Blender answers. */
76
+ connect(): Promise<LiveStatus>;
77
+ /**
78
+ * While Live is on, notice Blender opening and closing: a cheap port check
79
+ * every few seconds, and one question to Blender only when that changes.
80
+ */
81
+ private watch;
82
+ /** Re-check Blender (opened or closed since). Cheap: a port check, then one question to Blender. */
83
+ refresh(serverVersion?: string | undefined): Promise<LiveStatus>;
84
+ /** Switch Live off. */
85
+ disconnect(): Promise<LiveStatus>;
86
+ }
87
+ export {};
88
+ //# sourceMappingURL=live.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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