@project-ava-supernova/core 0.2.186 → 0.2.188
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/agent/agent.d.ts +2 -1
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.js +22 -4
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/system-prompt.d.ts.map +1 -1
- package/dist/agent/system-prompt.js +13 -1
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/docs/content/features.d.ts.map +1 -1
- package/dist/docs/content/features.js +2 -1
- package/dist/docs/content/features.js.map +1 -1
- package/dist/docs/i18n/translations.d.ts.map +1 -1
- package/dist/docs/i18n/translations.js +1 -1
- package/dist/docs/i18n/translations.js.map +1 -1
- package/dist/i18n/keep-english.d.ts.map +1 -1
- package/dist/i18n/keep-english.js +0 -4
- package/dist/i18n/keep-english.js.map +1 -1
- package/dist/i18n/locales/ar.d.ts.map +1 -1
- package/dist/i18n/locales/ar.js +169 -33
- package/dist/i18n/locales/ar.js.map +1 -1
- package/dist/i18n/locales/de.d.ts.map +1 -1
- package/dist/i18n/locales/de.js +169 -33
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/en.d.ts +167 -32
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +170 -33
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts.map +1 -1
- package/dist/i18n/locales/es.js +169 -33
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts.map +1 -1
- package/dist/i18n/locales/fr.js +169 -33
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hi.d.ts.map +1 -1
- package/dist/i18n/locales/hi.js +169 -33
- package/dist/i18n/locales/hi.js.map +1 -1
- package/dist/i18n/locales/id.d.ts.map +1 -1
- package/dist/i18n/locales/id.js +169 -33
- package/dist/i18n/locales/id.js.map +1 -1
- package/dist/i18n/locales/it.d.ts.map +1 -1
- package/dist/i18n/locales/it.js +169 -33
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/ja.d.ts.map +1 -1
- package/dist/i18n/locales/ja.js +169 -33
- package/dist/i18n/locales/ja.js.map +1 -1
- package/dist/i18n/locales/ko.d.ts.map +1 -1
- package/dist/i18n/locales/ko.js +169 -33
- package/dist/i18n/locales/ko.js.map +1 -1
- package/dist/i18n/locales/nl.d.ts.map +1 -1
- package/dist/i18n/locales/nl.js +169 -33
- package/dist/i18n/locales/nl.js.map +1 -1
- package/dist/i18n/locales/pl.d.ts.map +1 -1
- package/dist/i18n/locales/pl.js +169 -33
- package/dist/i18n/locales/pl.js.map +1 -1
- package/dist/i18n/locales/pt.d.ts.map +1 -1
- package/dist/i18n/locales/pt.js +169 -33
- package/dist/i18n/locales/pt.js.map +1 -1
- package/dist/i18n/locales/ru.d.ts.map +1 -1
- package/dist/i18n/locales/ru.js +169 -33
- package/dist/i18n/locales/ru.js.map +1 -1
- package/dist/i18n/locales/th.d.ts.map +1 -1
- package/dist/i18n/locales/th.js +169 -33
- package/dist/i18n/locales/th.js.map +1 -1
- package/dist/i18n/locales/tr.d.ts.map +1 -1
- package/dist/i18n/locales/tr.js +169 -33
- package/dist/i18n/locales/tr.js.map +1 -1
- package/dist/i18n/locales/uk.d.ts.map +1 -1
- package/dist/i18n/locales/uk.js +169 -33
- package/dist/i18n/locales/uk.js.map +1 -1
- package/dist/i18n/locales/vi.d.ts.map +1 -1
- package/dist/i18n/locales/vi.js +169 -33
- package/dist/i18n/locales/vi.js.map +1 -1
- package/dist/i18n/locales/zh-CN.d.ts.map +1 -1
- package/dist/i18n/locales/zh-CN.js +169 -33
- package/dist/i18n/locales/zh-CN.js.map +1 -1
- package/dist/i18n/locales/zh-TW.d.ts.map +1 -1
- package/dist/i18n/locales/zh-TW.js +169 -33
- package/dist/i18n/locales/zh-TW.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/connection.d.ts +125 -0
- package/dist/mcp/connection.d.ts.map +1 -0
- package/dist/mcp/connection.js +249 -0
- package/dist/mcp/connection.js.map +1 -0
- package/dist/mcp/import.d.ts +47 -0
- package/dist/mcp/import.d.ts.map +1 -0
- package/dist/mcp/import.js +157 -0
- package/dist/mcp/import.js.map +1 -0
- package/dist/mcp/index.d.ts +30 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +17 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/manager.d.ts +144 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/manager.js +550 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/oauth.d.ts +117 -0
- package/dist/mcp/oauth.d.ts.map +1 -0
- package/dist/mcp/oauth.js +382 -0
- package/dist/mcp/oauth.js.map +1 -0
- package/dist/mcp/page.d.ts +99 -0
- package/dist/mcp/page.d.ts.map +1 -0
- package/dist/mcp/page.js +287 -0
- package/dist/mcp/page.js.map +1 -0
- package/dist/mcp/permissions.d.ts +22 -0
- package/dist/mcp/permissions.d.ts.map +1 -0
- package/dist/mcp/permissions.js +35 -0
- package/dist/mcp/permissions.js.map +1 -0
- package/dist/mcp/registry.d.ts +63 -0
- package/dist/mcp/registry.d.ts.map +1 -0
- package/dist/mcp/registry.js +106 -0
- package/dist/mcp/registry.js.map +1 -0
- package/dist/mcp/risk.d.ts +23 -0
- package/dist/mcp/risk.d.ts.map +1 -0
- package/dist/mcp/risk.js +98 -0
- package/dist/mcp/risk.js.map +1 -0
- package/dist/mcp/secrets.d.ts +38 -0
- package/dist/mcp/secrets.d.ts.map +1 -0
- package/dist/mcp/secrets.js +82 -0
- package/dist/mcp/secrets.js.map +1 -0
- package/dist/mcp/servers-config.d.ts +107 -0
- package/dist/mcp/servers-config.d.ts.map +1 -0
- package/dist/mcp/servers-config.js +243 -0
- package/dist/mcp/servers-config.js.map +1 -0
- package/dist/mcp/setup.d.ts +75 -0
- package/dist/mcp/setup.d.ts.map +1 -0
- package/dist/mcp/setup.js +150 -0
- package/dist/mcp/setup.js.map +1 -0
- package/dist/mcp/suggested.d.ts +47 -0
- package/dist/mcp/suggested.d.ts.map +1 -0
- package/dist/mcp/suggested.js +91 -0
- package/dist/mcp/suggested.js.map +1 -0
- package/dist/mcp/tools.d.ts +30 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +83 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/tools/blender/build-model.d.ts +10 -0
- package/dist/tools/blender/build-model.d.ts.map +1 -1
- package/dist/tools/blender/build-model.js +11 -2
- package/dist/tools/blender/build-model.js.map +1 -1
- package/dist/tools/blender/live-setup.d.ts +63 -0
- package/dist/tools/blender/live-setup.d.ts.map +1 -0
- package/dist/tools/blender/live-setup.js +281 -0
- package/dist/tools/blender/live-setup.js.map +1 -0
- package/dist/tools/blender/live-tools.d.ts +83 -0
- package/dist/tools/blender/live-tools.d.ts.map +1 -0
- package/dist/tools/blender/live-tools.js +402 -0
- package/dist/tools/blender/live-tools.js.map +1 -0
- package/dist/tools/blender/live.d.ts +88 -0
- package/dist/tools/blender/live.d.ts.map +1 -0
- package/dist/tools/blender/live.js +285 -0
- package/dist/tools/blender/live.js.map +1 -0
- package/dist/tools/blender/runner-py.d.ts +7 -0
- package/dist/tools/blender/runner-py.d.ts.map +1 -1
- package/dist/tools/blender/runner-py.js +108 -100
- package/dist/tools/blender/runner-py.js.map +1 -1
- package/dist/tools/connection-tools.d.ts +61 -0
- package/dist/tools/connection-tools.d.ts.map +1 -0
- package/dist/tools/connection-tools.js +271 -0
- package/dist/tools/connection-tools.js.map +1 -0
- package/dist/tools/tool-registry.d.ts +2 -0
- package/dist/tools/tool-registry.d.ts.map +1 -1
- package/dist/tools/tool-registry.js +35 -1
- package/dist/tools/tool-registry.js.map +1 -1
- package/dist/tools/tool-request-words.d.ts.map +1 -1
- package/dist/tools/tool-request-words.js +34 -0
- package/dist/tools/tool-request-words.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,285 @@
|
|
|
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 { existsSync } from 'node:fs';
|
|
16
|
+
import { mkdir, readdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
17
|
+
import { connect as netConnect } from 'node:net';
|
|
18
|
+
import { dirname, join } from 'node:path';
|
|
19
|
+
import { execFile } from 'node:child_process';
|
|
20
|
+
import { AVA_HOME, CONFIG_PATH } from '../../core/constants.js';
|
|
21
|
+
import { McpConnection } from '../../mcp/connection.js';
|
|
22
|
+
import { findBlender } from './find-blender.js';
|
|
23
|
+
export const BLENDER_MCP_HOST = '127.0.0.1';
|
|
24
|
+
export const BLENDER_MCP_PORT = 9876;
|
|
25
|
+
/** Live needs the add-on, which needs Blender 5.1 or newer. */
|
|
26
|
+
export const BLENDER_LIVE_MIN = '5.1.0';
|
|
27
|
+
export const blenderMcpRoot = () => process.env.AVA_BLENDER_MCP_DIR || join(AVA_HOME, 'mcp', 'blender');
|
|
28
|
+
// ── What's on the machine ───────────────────────────────────────────────────
|
|
29
|
+
function onPath(cmd) {
|
|
30
|
+
return new Promise((resolve) => {
|
|
31
|
+
execFile(process.platform === 'win32' ? 'where.exe' : 'which', [cmd], { windowsHide: true, timeout: 5000 }, (err, out) => {
|
|
32
|
+
const first = String(out ?? '').split(/\r?\n/).map((l) => l.trim()).find(Boolean);
|
|
33
|
+
resolve(err || !first ? null : first);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/** uv, from PATH or where its own installer puts it (which isn't always on an app's PATH). */
|
|
38
|
+
export async function findUv() {
|
|
39
|
+
if (process.env.AVA_UV_PATH && existsSync(process.env.AVA_UV_PATH))
|
|
40
|
+
return process.env.AVA_UV_PATH;
|
|
41
|
+
const found = await onPath('uv');
|
|
42
|
+
if (found)
|
|
43
|
+
return found;
|
|
44
|
+
const home = process.env.USERPROFILE || process.env.HOME || '';
|
|
45
|
+
const exe = process.platform === 'win32' ? 'uv.exe' : 'uv';
|
|
46
|
+
for (const dir of [join(home, '.local', 'bin'), join(home, '.cargo', 'bin')]) {
|
|
47
|
+
if (home && existsSync(join(dir, exe)))
|
|
48
|
+
return join(dir, exe);
|
|
49
|
+
}
|
|
50
|
+
// WinGet (uv's documented Windows route): a running app doesn't see the PATH
|
|
51
|
+
// change until it restarts, so look where WinGet puts it.
|
|
52
|
+
const local = process.env.LOCALAPPDATA;
|
|
53
|
+
if (process.platform === 'win32' && local) {
|
|
54
|
+
const links = join(local, 'Microsoft', 'WinGet', 'Links', exe);
|
|
55
|
+
if (existsSync(links))
|
|
56
|
+
return links;
|
|
57
|
+
const pkgs = join(local, 'Microsoft', 'WinGet', 'Packages');
|
|
58
|
+
for (const entry of await readdir(pkgs, { withFileTypes: true }).catch(() => [])) {
|
|
59
|
+
if (entry.isDirectory() && entry.name.startsWith('astral-sh.uv_') && existsSync(join(pkgs, entry.name, exe)))
|
|
60
|
+
return join(pkgs, entry.name, exe);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const versionKey = (v) => v.split(/[.-]/).map((n) => Number(n) || 0);
|
|
66
|
+
function newer(a, b) {
|
|
67
|
+
const x = versionKey(a), y = versionKey(b);
|
|
68
|
+
for (let i = 0; i < Math.max(x.length, y.length); i++) {
|
|
69
|
+
if ((x[i] ?? 0) !== (y[i] ?? 0))
|
|
70
|
+
return (x[i] ?? 0) > (y[i] ?? 0);
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
export const versionAtLeast = (v, min) => v === min || newer(v, min);
|
|
75
|
+
/** The newest unpacked server bundle: ~/.ava/mcp/blender/<version>/ with Blender's manifest. */
|
|
76
|
+
export async function installedServer() {
|
|
77
|
+
let best = null;
|
|
78
|
+
for (const entry of await readdir(blenderMcpRoot(), { withFileTypes: true }).catch(() => [])) {
|
|
79
|
+
if (!entry.isDirectory())
|
|
80
|
+
continue;
|
|
81
|
+
const dir = join(blenderMcpRoot(), entry.name);
|
|
82
|
+
try {
|
|
83
|
+
const m = JSON.parse(await readFile(join(dir, 'manifest.json'), 'utf-8'));
|
|
84
|
+
if (m.server?.type !== 'uv' || !m.version)
|
|
85
|
+
continue;
|
|
86
|
+
if (!best || newer(m.version, best.version))
|
|
87
|
+
best = { dir, version: m.version };
|
|
88
|
+
}
|
|
89
|
+
catch { /* not a bundle */ }
|
|
90
|
+
}
|
|
91
|
+
return best;
|
|
92
|
+
}
|
|
93
|
+
/** Is a Blender with the add-on's server running? (Its port answers.) */
|
|
94
|
+
export function addonListening(port = BLENDER_MCP_PORT, timeoutMs = 800) {
|
|
95
|
+
return new Promise((resolve) => {
|
|
96
|
+
const sock = netConnect({ host: BLENDER_MCP_HOST, port });
|
|
97
|
+
const done = (ok) => { sock.destroy(); resolve(ok); };
|
|
98
|
+
sock.setTimeout(timeoutMs, () => done(false));
|
|
99
|
+
sock.once('connect', () => done(true));
|
|
100
|
+
sock.once('error', () => done(false));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// ── The room's setting (his call, 16 Nov: one setting for the room) ─────────
|
|
104
|
+
// In ~/.ava/config.json beside the Blender path, so the extension and the IDE
|
|
105
|
+
// share it: switch Live on in one, it's on in the other.
|
|
106
|
+
const configPath = () => process.env.AVA_CONFIG_PATH || CONFIG_PATH;
|
|
107
|
+
export async function blenderLiveWanted() {
|
|
108
|
+
try {
|
|
109
|
+
const cfg = JSON.parse(await readFile(configPath(), 'utf-8'));
|
|
110
|
+
return cfg.preferences?.blenderLive === true;
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export async function setBlenderLiveWanted(on) {
|
|
117
|
+
let cfg = {};
|
|
118
|
+
try {
|
|
119
|
+
cfg = JSON.parse(await readFile(configPath(), 'utf-8'));
|
|
120
|
+
}
|
|
121
|
+
catch { /* none yet */ }
|
|
122
|
+
const prefs = { ...(cfg.preferences ?? {}) };
|
|
123
|
+
if (on)
|
|
124
|
+
prefs.blenderLive = true;
|
|
125
|
+
else
|
|
126
|
+
delete prefs.blenderLive;
|
|
127
|
+
cfg.preferences = prefs;
|
|
128
|
+
await mkdir(dirname(configPath()), { recursive: true });
|
|
129
|
+
const tmp = `${configPath()}.${process.pid}.tmp`;
|
|
130
|
+
await writeFile(tmp, JSON.stringify(cfg, null, 2), 'utf-8');
|
|
131
|
+
await rename(tmp, configPath());
|
|
132
|
+
}
|
|
133
|
+
// ── The connection ──────────────────────────────────────────────────────────
|
|
134
|
+
const MESSAGES = {
|
|
135
|
+
'needs-uv': 'MCP needs uv (a small tool that runs Blender\'s MCP server). I can install it for you.',
|
|
136
|
+
'needs-server': 'MCP needs Blender\'s official MCP server. I can fetch it from Blender\'s release page for you.',
|
|
137
|
+
off: 'MCP is off — Ava works headless.',
|
|
138
|
+
'blender-closed': 'Blender isn\'t open with the MCP add-on running. Open Blender 5.1 or newer and start the add-on.',
|
|
139
|
+
ready: 'Connected to your Blender.',
|
|
140
|
+
error: 'MCP hit a problem connecting to Blender.',
|
|
141
|
+
};
|
|
142
|
+
export class BlenderLive {
|
|
143
|
+
static instance = null;
|
|
144
|
+
static current() {
|
|
145
|
+
if (!BlenderLive.instance)
|
|
146
|
+
BlenderLive.instance = new BlenderLive();
|
|
147
|
+
return BlenderLive.instance;
|
|
148
|
+
}
|
|
149
|
+
conn = null;
|
|
150
|
+
connecting = null;
|
|
151
|
+
last = { state: 'off', message: MESSAGES.off };
|
|
152
|
+
listeners = [];
|
|
153
|
+
watcher = null;
|
|
154
|
+
/** The model open Live right now (set by design_live_open_model). */
|
|
155
|
+
openModel = null;
|
|
156
|
+
/** For tests: start a different server than Blender's bundle. */
|
|
157
|
+
launch;
|
|
158
|
+
get connection() {
|
|
159
|
+
return this.conn?.isOpen ? this.conn : null;
|
|
160
|
+
}
|
|
161
|
+
get lastStatus() {
|
|
162
|
+
return this.last;
|
|
163
|
+
}
|
|
164
|
+
onChange(listener) {
|
|
165
|
+
this.listeners.push(listener);
|
|
166
|
+
return () => { const i = this.listeners.indexOf(listener); if (i >= 0)
|
|
167
|
+
this.listeners.splice(i, 1); };
|
|
168
|
+
}
|
|
169
|
+
set(s) {
|
|
170
|
+
const changed = s.state !== this.last.state || s.blenderVersion !== this.last.blenderVersion || s.message !== this.last.message;
|
|
171
|
+
this.last = s;
|
|
172
|
+
if (changed)
|
|
173
|
+
for (const l of this.listeners) {
|
|
174
|
+
try {
|
|
175
|
+
l(s);
|
|
176
|
+
}
|
|
177
|
+
catch { /* not ours */ }
|
|
178
|
+
}
|
|
179
|
+
return s;
|
|
180
|
+
}
|
|
181
|
+
/** What's missing before Live can connect, without connecting. */
|
|
182
|
+
async prerequisites() {
|
|
183
|
+
if (this.launch)
|
|
184
|
+
return { uv: 'test', server: { dir: '.', version: 'test' } };
|
|
185
|
+
const uv = await findUv();
|
|
186
|
+
if (!uv)
|
|
187
|
+
return { state: 'needs-uv', message: MESSAGES['needs-uv'] };
|
|
188
|
+
const server = await installedServer();
|
|
189
|
+
if (!server)
|
|
190
|
+
return { state: 'needs-server', message: MESSAGES['needs-server'] };
|
|
191
|
+
return { uv, server };
|
|
192
|
+
}
|
|
193
|
+
/** Switch Live on: start the server and see whether Blender answers. */
|
|
194
|
+
async connect() {
|
|
195
|
+
if (this.connection)
|
|
196
|
+
return this.refresh();
|
|
197
|
+
if (this.connecting)
|
|
198
|
+
return this.connecting;
|
|
199
|
+
this.connecting = (async () => {
|
|
200
|
+
const pre = await this.prerequisites();
|
|
201
|
+
if ('state' in pre)
|
|
202
|
+
return this.set(pre);
|
|
203
|
+
const env = { BLENDER_MCP_HOST: BLENDER_MCP_HOST, BLENDER_MCP_PORT: String(BLENDER_MCP_PORT) };
|
|
204
|
+
const blender = await findBlender().catch(() => null);
|
|
205
|
+
if (blender?.path)
|
|
206
|
+
env.BLENDER_PATH = blender.path;
|
|
207
|
+
try {
|
|
208
|
+
this.conn = this.launch
|
|
209
|
+
? await this.launch(env)
|
|
210
|
+
: await McpConnection.open({
|
|
211
|
+
id: 'blender_live', name: 'Blender',
|
|
212
|
+
transport: { kind: 'program', command: pre.uv, args: ['run', '--quiet', 'blender-mcp'], cwd: pre.server.dir, env },
|
|
213
|
+
}, { timeoutMs: 120_000 }); // the first start sets up Python and the server's libraries
|
|
214
|
+
this.conn.onClose(() => {
|
|
215
|
+
this.conn = null;
|
|
216
|
+
this.set({ state: 'error', serverVersion: pre.server.version, message: 'Blender\'s MCP server stopped. Switch the room to Headless and back to MCP to restart it.' });
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
catch (err) {
|
|
220
|
+
return this.set({ state: 'error', message: `${MESSAGES.error} ${err instanceof Error ? err.message : String(err)}` });
|
|
221
|
+
}
|
|
222
|
+
this.watch();
|
|
223
|
+
return this.refresh(pre.server.version);
|
|
224
|
+
})().finally(() => { this.connecting = null; });
|
|
225
|
+
return this.connecting;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* While Live is on, notice Blender opening and closing: a cheap port check
|
|
229
|
+
* every few seconds, and one question to Blender only when that changes.
|
|
230
|
+
*/
|
|
231
|
+
watch() {
|
|
232
|
+
if (this.watcher || this.launch)
|
|
233
|
+
return;
|
|
234
|
+
this.watcher = setInterval(() => {
|
|
235
|
+
if (!this.connection)
|
|
236
|
+
return;
|
|
237
|
+
void addonListening().then((up) => {
|
|
238
|
+
const ready = this.last.state === 'ready';
|
|
239
|
+
if (up && !ready)
|
|
240
|
+
void this.refresh();
|
|
241
|
+
if (!up && ready) {
|
|
242
|
+
this.openModel = null;
|
|
243
|
+
this.set({ state: 'blender-closed', serverVersion: this.last.serverVersion, message: MESSAGES['blender-closed'] });
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}, 4000);
|
|
247
|
+
this.watcher.unref?.();
|
|
248
|
+
}
|
|
249
|
+
/** Re-check Blender (opened or closed since). Cheap: a port check, then one question to Blender. */
|
|
250
|
+
async refresh(serverVersion = this.last.serverVersion) {
|
|
251
|
+
const conn = this.connection;
|
|
252
|
+
if (!conn)
|
|
253
|
+
return this.set({ state: 'off', message: MESSAGES.off });
|
|
254
|
+
if (!this.launch && !(await addonListening())) {
|
|
255
|
+
return this.set({ state: 'blender-closed', serverVersion, message: MESSAGES['blender-closed'] });
|
|
256
|
+
}
|
|
257
|
+
try {
|
|
258
|
+
const r = await conn.call('execute_blender_code', { code: 'import bpy\nresult = {"version": bpy.app.version_string}' }, { timeoutMs: 15_000 });
|
|
259
|
+
const version = /"version"\s*:\s*"([^"]+)"/.exec(r.text)?.[1] ?? /\b(\d+\.\d+(?:\.\d+)?)\b/.exec(r.text)?.[1];
|
|
260
|
+
if (r.isError || !version)
|
|
261
|
+
return this.set({ state: 'blender-closed', serverVersion, message: MESSAGES['blender-closed'] });
|
|
262
|
+
if (!versionAtLeast(version, BLENDER_LIVE_MIN)) {
|
|
263
|
+
return this.set({ state: 'error', serverVersion, blenderVersion: version, message: `This is Blender ${version}; MCP needs ${BLENDER_LIVE_MIN} or newer. Headless works with any version.` });
|
|
264
|
+
}
|
|
265
|
+
return this.set({ state: 'ready', serverVersion, blenderVersion: version, message: `Connected to Blender ${version} · ready` });
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
return this.set({ state: 'blender-closed', serverVersion, message: MESSAGES['blender-closed'] });
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/** Switch Live off. */
|
|
272
|
+
async disconnect() {
|
|
273
|
+
const c = this.conn;
|
|
274
|
+
this.conn = null;
|
|
275
|
+
this.openModel = null;
|
|
276
|
+
if (this.watcher) {
|
|
277
|
+
clearInterval(this.watcher);
|
|
278
|
+
this.watcher = null;
|
|
279
|
+
}
|
|
280
|
+
if (c)
|
|
281
|
+
await c.close();
|
|
282
|
+
return this.set({ state: 'off', message: MESSAGES.off });
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
//# sourceMappingURL=live.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live.js","sourceRoot":"","sources":["../../../src/tools/blender/live.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAC5C,MAAM,CAAC,MAAM,gB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OAAO,CAAC,CAAC;YAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QAAC,CAAC;QACvE,IAAI,CAAC;YAAE,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;IAC3D,CAAC"}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The helpers Ava calls from her scripts (ava_unwrap, ava_bake). Shared by
|
|
3
|
+
* Headless (this runner) and MCP (sent ahead of each step to the open
|
|
4
|
+
* Blender), so baking works the same either way — his question, 17 Nov.
|
|
5
|
+
* Needs: bpy, os, ASSET_DIR in scope.
|
|
6
|
+
*/
|
|
7
|
+
export declare const BLENDER_HELPERS_PY: string;
|
|
1
8
|
export declare const BLENDER_RUNNER_PY: string;
|
|
2
9
|
//# sourceMappingURL=runner-py.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner-py.d.ts","sourceRoot":"","sources":["../../../src/tools/blender/runner-py.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runner-py.d.ts","sourceRoot":"","sources":["../../../src/tools/blender/runner-py.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AAEH,eAAO,MAAM,kBAAkB,QAqN9B,CAAC;AAGF,eAAO,MAAM,iBAAiB,QAoO7B,CAAC"}
|
|
@@ -9,107 +9,14 @@
|
|
|
9
9
|
* the model folder.
|
|
10
10
|
*/
|
|
11
11
|
import { KIT_PY } from '../../brand/kit-py.js';
|
|
12
|
+
/**
|
|
13
|
+
* The helpers Ava calls from her scripts (ava_unwrap, ava_bake). Shared by
|
|
14
|
+
* Headless (this runner) and MCP (sent ahead of each step to the open
|
|
15
|
+
* Blender), so baking works the same either way — his question, 17 Nov.
|
|
16
|
+
* Needs: bpy, os, ASSET_DIR in scope.
|
|
17
|
+
*/
|
|
12
18
|
// prettier-ignore
|
|
13
|
-
export const
|
|
14
|
-
# blender -b [model.blend] --factory-startup --disable-autoexec --python runner.py -- job.json
|
|
15
|
-
# It prepares the scene, installs the guard, runs Ava's script, then saves,
|
|
16
|
-
# exports and renders a preview. The last line it prints is the result.
|
|
17
|
-
import sys, os, json, time, traceback, tempfile, shutil, math
|
|
18
|
-
|
|
19
|
-
JOB = json.load(open(sys.argv[sys.argv.index('--') + 1], encoding='utf-8'))
|
|
20
|
-
ASSET_DIR = os.path.realpath(JOB['assetDir'])
|
|
21
|
-
NAME = JOB['name']
|
|
22
|
-
BLEND = os.path.join(ASSET_DIR, NAME + '.blend')
|
|
23
|
-
STARTED = time.time()
|
|
24
|
-
result = {'ok': False, 'files': [], 'warnings': []}
|
|
25
|
-
${KIT_PY}
|
|
26
|
-
|
|
27
|
-
def emit():
|
|
28
|
-
sys.stdout.write('\n@@AVA_RESULT@@' + json.dumps(result) + '\n')
|
|
29
|
-
sys.stdout.flush()
|
|
30
|
-
|
|
31
|
-
import bpy
|
|
32
|
-
sys.dont_write_bytecode = True
|
|
33
|
-
bpy.context.preferences.filepaths.save_version = 0 # no .blend1 clutter beside the model
|
|
34
|
-
|
|
35
|
-
if not JOB['continue']:
|
|
36
|
-
bpy.ops.wm.read_factory_settings(use_empty=True) # a new canvas: nothing in it
|
|
37
|
-
for sc in bpy.data.scenes:
|
|
38
|
-
sc.render.filepath = os.path.join(ASSET_DIR, 'render_')
|
|
39
|
-
|
|
40
|
-
# ── The guard ────────────────────────────────────────────────────────────────
|
|
41
|
-
# Python audit hooks see every file write, process start and network call made
|
|
42
|
-
# from Python, and cannot be removed once installed. A guard, not a sandbox:
|
|
43
|
-
# Blender's own C code (saving a .blend, writing a render) is not seen here,
|
|
44
|
-
# which is why the tool also refuses absolute paths in the script itself.
|
|
45
|
-
# Writes are allowed in the model folder and in Blender's OWN per-run temp
|
|
46
|
-
# folder (blender_xxxx), not the whole system temp. Python's tempfile is
|
|
47
|
-
# pointed there too, so any library that needs scratch space stays inside it.
|
|
48
|
-
_BTMP = bpy.app.tempdir or os.path.join(ASSET_DIR, '.tmp')
|
|
49
|
-
os.makedirs(_BTMP, exist_ok=True)
|
|
50
|
-
tempfile.tempdir = _BTMP
|
|
51
|
-
_ALLOWED = [os.path.normcase(os.path.realpath(p)) for p in {ASSET_DIR, _BTMP}]
|
|
52
|
-
|
|
53
|
-
def _inside(p):
|
|
54
|
-
try:
|
|
55
|
-
rp = os.path.normcase(os.path.realpath(os.fsdecode(p)))
|
|
56
|
-
except Exception:
|
|
57
|
-
return False
|
|
58
|
-
return any(rp == a or rp.startswith(a.rstrip(os.sep) + os.sep) for a in _ALLOWED)
|
|
59
|
-
|
|
60
|
-
_BLOCKED = {
|
|
61
|
-
'subprocess.Popen': 'starting other programs', 'os.system': 'starting other programs',
|
|
62
|
-
'os.exec': 'starting other programs', 'os.posix_spawn': 'starting other programs',
|
|
63
|
-
'os.spawn': 'starting other programs', 'os.startfile': 'opening files in other programs',
|
|
64
|
-
'os.kill': 'stopping other programs', 'webbrowser.open': 'opening a browser',
|
|
65
|
-
'socket.connect': 'network access', 'socket.bind': 'network access',
|
|
66
|
-
'socket.getaddrinfo': 'network access', 'socket.gethostbyname': 'network access',
|
|
67
|
-
'urllib.Request': 'network access', 'ctypes.dlopen': 'loading native code',
|
|
68
|
-
'ctypes.dlsym': 'calling native code', 'ctypes.call_function': 'calling native code',
|
|
69
|
-
'winreg.CreateKey': 'changing the registry', 'winreg.SetValue': 'changing the registry',
|
|
70
|
-
'winreg.DeleteKey': 'changing the registry', 'winreg.DeleteValue': 'changing the registry',
|
|
71
|
-
}
|
|
72
|
-
_WRITE_ARGS = { # event -> indexes of the paths it writes or removes
|
|
73
|
-
'os.remove': (0,), 'os.rmdir': (0,), 'os.mkdir': (0,), 'os.chmod': (0,),
|
|
74
|
-
'os.truncate': (0,), 'os.utime': (0,), 'shutil.rmtree': (0,),
|
|
75
|
-
'os.rename': (0, 1), 'shutil.move': (0, 1), 'shutil.copyfile': (1,),
|
|
76
|
-
'shutil.copytree': (1,), 'os.symlink': (1,), 'os.link': (1,),
|
|
77
|
-
}
|
|
78
|
-
_WRITE_FLAGS = os.O_WRONLY | os.O_RDWR | os.O_CREAT | os.O_APPEND | os.O_TRUNC
|
|
79
|
-
|
|
80
|
-
def _refuse(why):
|
|
81
|
-
raise PermissionError(f'Blocked by the Design Studio guard: {why}. '
|
|
82
|
-
f'Scripts here may only build the model and write inside its own folder (ASSET_DIR).')
|
|
83
|
-
|
|
84
|
-
def _hook(event, args):
|
|
85
|
-
if event in _BLOCKED:
|
|
86
|
-
_refuse(_BLOCKED[event])
|
|
87
|
-
if event == 'open':
|
|
88
|
-
path, mode, flags = (list(args) + [None, None, 0])[:3]
|
|
89
|
-
if path is None or isinstance(path, int):
|
|
90
|
-
return
|
|
91
|
-
writing = (isinstance(mode, str) and any(c in mode for c in 'wax+')) or \
|
|
92
|
-
(mode is None and isinstance(flags, int) and flags & _WRITE_FLAGS)
|
|
93
|
-
if writing and not _inside(path):
|
|
94
|
-
_refuse(f'writing outside the model folder ({os.fsdecode(path)})')
|
|
95
|
-
elif event in _WRITE_ARGS:
|
|
96
|
-
for i in _WRITE_ARGS[event]:
|
|
97
|
-
if i < len(args) and args[i] is not None and not isinstance(args[i], int) and not _inside(args[i]):
|
|
98
|
-
_refuse(f'changing files outside the model folder ({os.fsdecode(args[i])})')
|
|
99
|
-
|
|
100
|
-
# Blender's own exporters load native code when first imported (the glTF one
|
|
101
|
-
# pulls in ctypes for Draco). Import them BEFORE the guard goes up, so the guard
|
|
102
|
-
# only ever sees what Ava's script does.
|
|
103
|
-
import ctypes # noqa: F401
|
|
104
|
-
for _mod in ('io_scene_gltf2.blender.exp.export', 'io_scene_fbx.export_fbx_bin'):
|
|
105
|
-
try:
|
|
106
|
-
__import__(_mod)
|
|
107
|
-
except Exception as e:
|
|
108
|
-
result['warnings'].append(f'Could not preload {_mod}: {e}')
|
|
109
|
-
|
|
110
|
-
sys.addaudithook(_hook)
|
|
111
|
-
|
|
112
|
-
# ── Helpers Ava calls from her script ────────────────────────────────────────
|
|
19
|
+
export const BLENDER_HELPERS_PY = String.raw `# ── Helpers Ava calls from her script ────────────────────────────────────────
|
|
113
20
|
# Texturing is where she lost twenty minutes on the first real model (3 Nov
|
|
114
21
|
# 2026): a beautiful live shader that exports as nothing, a dozen runs on UV
|
|
115
22
|
# layout, and Blender reporting only EEVEE when asked which engines exist —
|
|
@@ -322,7 +229,108 @@ def ava_bake(objects=None, size=2048, maps=('base_color', 'roughness', 'metallic
|
|
|
322
229
|
files = [f'textures/{_os.path.basename(i.filepath_raw)}' for i in images.values()]
|
|
323
230
|
print(f'AVA_BAKE: {len(obs)} objects, {len(mats)} live material(s) -> {", ".join(files)} on {baked.name}')
|
|
324
231
|
return files
|
|
232
|
+
`;
|
|
233
|
+
// prettier-ignore
|
|
234
|
+
export const BLENDER_RUNNER_PY = String.raw `# Ava's Blender runner. Started by design_build_model as:
|
|
235
|
+
# blender -b [model.blend] --factory-startup --disable-autoexec --python runner.py -- job.json
|
|
236
|
+
# It prepares the scene, installs the guard, runs Ava's script, then saves,
|
|
237
|
+
# exports and renders a preview. The last line it prints is the result.
|
|
238
|
+
import sys, os, json, time, traceback, tempfile, shutil, math
|
|
239
|
+
|
|
240
|
+
JOB = json.load(open(sys.argv[sys.argv.index('--') + 1], encoding='utf-8'))
|
|
241
|
+
ASSET_DIR = os.path.realpath(JOB['assetDir'])
|
|
242
|
+
NAME = JOB['name']
|
|
243
|
+
BLEND = os.path.join(ASSET_DIR, NAME + '.blend')
|
|
244
|
+
STARTED = time.time()
|
|
245
|
+
result = {'ok': False, 'files': [], 'warnings': []}
|
|
246
|
+
${KIT_PY}
|
|
247
|
+
|
|
248
|
+
def emit():
|
|
249
|
+
sys.stdout.write('\n@@AVA_RESULT@@' + json.dumps(result) + '\n')
|
|
250
|
+
sys.stdout.flush()
|
|
251
|
+
|
|
252
|
+
import bpy
|
|
253
|
+
sys.dont_write_bytecode = True
|
|
254
|
+
bpy.context.preferences.filepaths.save_version = 0 # no .blend1 clutter beside the model
|
|
255
|
+
|
|
256
|
+
if not JOB['continue']:
|
|
257
|
+
bpy.ops.wm.read_factory_settings(use_empty=True) # a new canvas: nothing in it
|
|
258
|
+
for sc in bpy.data.scenes:
|
|
259
|
+
sc.render.filepath = os.path.join(ASSET_DIR, 'render_')
|
|
260
|
+
|
|
261
|
+
# ── The guard ────────────────────────────────────────────────────────────────
|
|
262
|
+
# Python audit hooks see every file write, process start and network call made
|
|
263
|
+
# from Python, and cannot be removed once installed. A guard, not a sandbox:
|
|
264
|
+
# Blender's own C code (saving a .blend, writing a render) is not seen here,
|
|
265
|
+
# which is why the tool also refuses absolute paths in the script itself.
|
|
266
|
+
# Writes are allowed in the model folder and in Blender's OWN per-run temp
|
|
267
|
+
# folder (blender_xxxx), not the whole system temp. Python's tempfile is
|
|
268
|
+
# pointed there too, so any library that needs scratch space stays inside it.
|
|
269
|
+
_BTMP = bpy.app.tempdir or os.path.join(ASSET_DIR, '.tmp')
|
|
270
|
+
os.makedirs(_BTMP, exist_ok=True)
|
|
271
|
+
tempfile.tempdir = _BTMP
|
|
272
|
+
_ALLOWED = [os.path.normcase(os.path.realpath(p)) for p in {ASSET_DIR, _BTMP}]
|
|
273
|
+
|
|
274
|
+
def _inside(p):
|
|
275
|
+
try:
|
|
276
|
+
rp = os.path.normcase(os.path.realpath(os.fsdecode(p)))
|
|
277
|
+
except Exception:
|
|
278
|
+
return False
|
|
279
|
+
return any(rp == a or rp.startswith(a.rstrip(os.sep) + os.sep) for a in _ALLOWED)
|
|
280
|
+
|
|
281
|
+
_BLOCKED = {
|
|
282
|
+
'subprocess.Popen': 'starting other programs', 'os.system': 'starting other programs',
|
|
283
|
+
'os.exec': 'starting other programs', 'os.posix_spawn': 'starting other programs',
|
|
284
|
+
'os.spawn': 'starting other programs', 'os.startfile': 'opening files in other programs',
|
|
285
|
+
'os.kill': 'stopping other programs', 'webbrowser.open': 'opening a browser',
|
|
286
|
+
'socket.connect': 'network access', 'socket.bind': 'network access',
|
|
287
|
+
'socket.getaddrinfo': 'network access', 'socket.gethostbyname': 'network access',
|
|
288
|
+
'urllib.Request': 'network access', 'ctypes.dlopen': 'loading native code',
|
|
289
|
+
'ctypes.dlsym': 'calling native code', 'ctypes.call_function': 'calling native code',
|
|
290
|
+
'winreg.CreateKey': 'changing the registry', 'winreg.SetValue': 'changing the registry',
|
|
291
|
+
'winreg.DeleteKey': 'changing the registry', 'winreg.DeleteValue': 'changing the registry',
|
|
292
|
+
}
|
|
293
|
+
_WRITE_ARGS = { # event -> indexes of the paths it writes or removes
|
|
294
|
+
'os.remove': (0,), 'os.rmdir': (0,), 'os.mkdir': (0,), 'os.chmod': (0,),
|
|
295
|
+
'os.truncate': (0,), 'os.utime': (0,), 'shutil.rmtree': (0,),
|
|
296
|
+
'os.rename': (0, 1), 'shutil.move': (0, 1), 'shutil.copyfile': (1,),
|
|
297
|
+
'shutil.copytree': (1,), 'os.symlink': (1,), 'os.link': (1,),
|
|
298
|
+
}
|
|
299
|
+
_WRITE_FLAGS = os.O_WRONLY | os.O_RDWR | os.O_CREAT | os.O_APPEND | os.O_TRUNC
|
|
300
|
+
|
|
301
|
+
def _refuse(why):
|
|
302
|
+
raise PermissionError(f'Blocked by the Design Studio guard: {why}. '
|
|
303
|
+
f'Scripts here may only build the model and write inside its own folder (ASSET_DIR).')
|
|
304
|
+
|
|
305
|
+
def _hook(event, args):
|
|
306
|
+
if event in _BLOCKED:
|
|
307
|
+
_refuse(_BLOCKED[event])
|
|
308
|
+
if event == 'open':
|
|
309
|
+
path, mode, flags = (list(args) + [None, None, 0])[:3]
|
|
310
|
+
if path is None or isinstance(path, int):
|
|
311
|
+
return
|
|
312
|
+
writing = (isinstance(mode, str) and any(c in mode for c in 'wax+')) or \
|
|
313
|
+
(mode is None and isinstance(flags, int) and flags & _WRITE_FLAGS)
|
|
314
|
+
if writing and not _inside(path):
|
|
315
|
+
_refuse(f'writing outside the model folder ({os.fsdecode(path)})')
|
|
316
|
+
elif event in _WRITE_ARGS:
|
|
317
|
+
for i in _WRITE_ARGS[event]:
|
|
318
|
+
if i < len(args) and args[i] is not None and not isinstance(args[i], int) and not _inside(args[i]):
|
|
319
|
+
_refuse(f'changing files outside the model folder ({os.fsdecode(args[i])})')
|
|
320
|
+
|
|
321
|
+
# Blender's own exporters load native code when first imported (the glTF one
|
|
322
|
+
# pulls in ctypes for Draco). Import them BEFORE the guard goes up, so the guard
|
|
323
|
+
# only ever sees what Ava's script does.
|
|
324
|
+
import ctypes # noqa: F401
|
|
325
|
+
for _mod in ('io_scene_gltf2.blender.exp.export', 'io_scene_fbx.export_fbx_bin'):
|
|
326
|
+
try:
|
|
327
|
+
__import__(_mod)
|
|
328
|
+
except Exception as e:
|
|
329
|
+
result['warnings'].append(f'Could not preload {_mod}: {e}')
|
|
330
|
+
|
|
331
|
+
sys.addaudithook(_hook)
|
|
325
332
|
|
|
333
|
+
${BLENDER_HELPERS_PY}
|
|
326
334
|
# ── Ava's script ─────────────────────────────────────────────────────────────
|
|
327
335
|
script_path = os.path.join(ASSET_DIR, 'script.py')
|
|
328
336
|
ns = {'__name__': '__main__', '__file__': script_path, 'ASSET_DIR': ASSET_DIR, 'bpy': bpy, 'KIT': KIT,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner-py.js","sourceRoot":"","sources":["../../../src/tools/blender/runner-py.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,kBAAkB;AAClB,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;EAYzC,MAAM
|
|
1
|
+
{"version":3,"file":"runner-py.js","sourceRoot":"","sources":["../../../src/tools/blender/runner-py.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C;;;;;GAKG;AACH,kBAAkB;AAClB,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqN3C,CAAC;AAEF,kBAAkB;AAClB,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;EAYzC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuFN,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiInB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ava sets up his MCP servers (plan 2026-11-17-mcp-servers, Phase 4).
|
|
3
|
+
*
|
|
4
|
+
* connection_search the official MCP Registry: who publishes a server (verified
|
|
5
|
+
* namespace), its repository, the exact package and version,
|
|
6
|
+
* which keys it needs — the core of her research
|
|
7
|
+
* connection_list his servers and where each one is
|
|
8
|
+
* connection_add add one, with her view — ALWAYS shows him the card first
|
|
9
|
+
* connection_import what Claude Desktop, Cursor and VS Code have (scan), and
|
|
10
|
+
* bringing in the ones he picks (always asks)
|
|
11
|
+
*
|
|
12
|
+
* Not named mcp_*: that prefix is the servers' OWN tools (permissions.ts).
|
|
13
|
+
* Keys are never taken in the chat (mcp/setup.ts): she names them, he types
|
|
14
|
+
* them on the Connections page.
|
|
15
|
+
*/
|
|
16
|
+
import type { FunctionSchema } from '../providers/types.js';
|
|
17
|
+
import type { Tool, ToolExecutionContext, ToolResult, ToolRiskLevel } from './types.js';
|
|
18
|
+
import { type McpRiskNote } from '../mcp/risk.js';
|
|
19
|
+
/** The risk notes in words (the page says them in his language; the card and Ava read these). */
|
|
20
|
+
export declare function riskNoteInWords(n: McpRiskNote): string;
|
|
21
|
+
export declare class ConnectionSearchTool implements Tool {
|
|
22
|
+
readonly name = "connection_search";
|
|
23
|
+
readonly description = "Look a server up in the official MCP Registry";
|
|
24
|
+
readonly riskLevel: ToolRiskLevel;
|
|
25
|
+
readonly outputTrust: "untrusted";
|
|
26
|
+
readonly requiresConfirmation = false;
|
|
27
|
+
readonly schema: FunctionSchema;
|
|
28
|
+
execute(args: Record<string, unknown>): Promise<ToolResult>;
|
|
29
|
+
}
|
|
30
|
+
export declare class ConnectionListTool implements Tool {
|
|
31
|
+
readonly name = "connection_list";
|
|
32
|
+
readonly description = "List his MCP servers and how each is doing";
|
|
33
|
+
readonly riskLevel: ToolRiskLevel;
|
|
34
|
+
readonly requiresConfirmation = false;
|
|
35
|
+
readonly schema: FunctionSchema;
|
|
36
|
+
execute(): Promise<ToolResult>;
|
|
37
|
+
}
|
|
38
|
+
export declare class ConnectionAddTool implements Tool {
|
|
39
|
+
readonly name = "connection_add";
|
|
40
|
+
readonly description = "Add an MCP server to his list (he sees it first)";
|
|
41
|
+
readonly riskLevel: ToolRiskLevel;
|
|
42
|
+
readonly requiresConfirmation = true;
|
|
43
|
+
readonly schema: FunctionSchema;
|
|
44
|
+
precheck(args: Record<string, unknown>): Promise<{
|
|
45
|
+
ok: true;
|
|
46
|
+
} | {
|
|
47
|
+
ok: false;
|
|
48
|
+
output: string;
|
|
49
|
+
}>;
|
|
50
|
+
deniedMessage(reason: string | null): string;
|
|
51
|
+
execute(args: Record<string, unknown>): Promise<ToolResult>;
|
|
52
|
+
}
|
|
53
|
+
export declare class ConnectionImportTool implements Tool {
|
|
54
|
+
readonly name = "connection_import";
|
|
55
|
+
readonly description = "Bring in his servers from Claude Desktop, Cursor or VS Code";
|
|
56
|
+
readonly riskLevel: ToolRiskLevel;
|
|
57
|
+
readonly requiresConfirmation = false;
|
|
58
|
+
readonly schema: FunctionSchema;
|
|
59
|
+
execute(args: Record<string, unknown>, _context: ToolExecutionContext): Promise<ToolResult>;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=connection-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-tools.d.ts","sourceRoot":"","sources":["../../src/tools/connection-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,oBAAoB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAQxF,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAajE,iGAAiG;AACjG,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CActD;AAsBD,qBAAa,oBAAqB,YAAW,IAAI;IAC/C,QAAQ,CAAC,IAAI,uBAAuB;IACpC,QAAQ,CAAC,WAAW,mDAAmD;IACvE,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAU;IAC3C,QAAQ,CAAC,WAAW,EAAG,WAAW,CAAU;IAC5C,QAAQ,CAAC,oBAAoB,SAAS;IACtC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAe7B;IAEI,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;CAyBlE;AAID,qBAAa,kBAAmB,YAAW,IAAI;IAC7C,QAAQ,CAAC,IAAI,qBAAqB;IAClC,QAAQ,CAAC,WAAW,gDAAgD;IACp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