@vulcan-energy/mcp-helper 0.2.4 → 0.3.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/LICENSE +9 -0
- package/README.md +75 -67
- package/THIRD_PARTY_NOTICES.md +10 -1
- package/dist/bin/vulcan-mcp-helper.js +50 -116
- package/dist/hem-target-runtime/browser-adapter.mjs +83 -21
- package/dist/hem-target-runtime/host.mjs +216 -17173
- package/dist/hem-target-runtime/preparation.mjs +18497 -0
- package/dist/hem-target-runtime/python-worker.mjs +5 -3
- package/dist/hem-target-runtime/rust-worker.mjs +5 -3
- package/dist/hem-target-runtime/wasm-loader.mjs +1 -0
- package/dist/server.d.ts +26 -6
- package/dist/server.js +38 -106
- package/package.json +18 -12
- package/schemas/core-input.schema.json +8020 -0
- package/schemas/input_fhs.schema.json +4728 -0
- package/wasm/THIRD_PARTY_RUST_CRATES.md +5693 -0
- package/wasm/wasm_version.json +9 -9
- package/wasm/wasm_wrapper.js +6 -6
- package/wasm/wasm_wrapper_bg.wasm +0 -0
|
@@ -673,7 +673,9 @@ function resolveHemTarget(id) {
|
|
|
673
673
|
return target;
|
|
674
674
|
}
|
|
675
675
|
function modelArtifacts(manifest2) {
|
|
676
|
-
|
|
676
|
+
const runtime2 = [manifest2.runtime.javascript, manifest2.runtime.wasm];
|
|
677
|
+
const converter = [manifest2.preparation.javascript, manifest2.preparation.wasm].filter((path) => !runtime2.includes(path));
|
|
678
|
+
return manifest2.artifacts.filter((artifact) => !artifact.path.startsWith("source/") && !artifact.path.startsWith("notices/") && !converter.includes(artifact.path));
|
|
677
679
|
}
|
|
678
680
|
function validateTargetManifest(manifest2, target) {
|
|
679
681
|
if (manifest2.bundleId !== target.id || manifest2.protocol !== 1 || manifest2.engineCommit !== target.engineCommit || manifest2.wrapperCommit !== target.wrapperCommit || manifest2.conversionProfile !== target.conversionProfile) {
|
|
@@ -691,7 +693,7 @@ function validateTargetManifest(manifest2, target) {
|
|
|
691
693
|
sizesByHash.set(artifact.sha256, artifact.bytes);
|
|
692
694
|
paths.add(artifact.path);
|
|
693
695
|
}
|
|
694
|
-
for (const path of [
|
|
696
|
+
for (const path of [manifest2.preparation.schema, manifest2.preparation.defaults, manifest2.runtime.javascript, ...manifest2.runtime.wasm ? [manifest2.runtime.wasm] : [], ...manifest2.runtime.wheels ?? []]) {
|
|
695
697
|
if (path.startsWith("source/") || path.startsWith("notices/")) throw new Error(`Runtime/preparation cannot reference reserved source/notice material: ${path}`);
|
|
696
698
|
if (!paths.has(path)) throw new Error(`Target manifest is missing required artifact ${path}`);
|
|
697
699
|
}
|
|
@@ -1020,7 +1022,7 @@ async function executePreparedJobs(manifest2, bundleId, jobId, jobs, execute, wr
|
|
|
1020
1022
|
const archive = job.archiveDirectory ?? job.outputDirectory;
|
|
1021
1023
|
const inputSha256 = await sha256(new TextEncoder().encode(job.input));
|
|
1022
1024
|
if (job.weather && (!job.weather.epw.trim() || await sha256(new TextEncoder().encode(job.weather.epw)) !== job.weather.sha256)) throw new Error("Prepared weather hash mismatch or empty EPW");
|
|
1023
|
-
const provenance = { ...job.weather ? { weather: { path: job.weather.path, sha256: job.weather.sha256 } } : {}, ...job.heatingProfile ? { calculationKind: "operating-sensitivity", heatingProfile: job.heatingProfile } : {}, target: manifest2, inputSha256, modes: job.modes, jobId, ...job.startedAt ? { startedAt: job.startedAt } : {}, name: job.name, ...job.warnings?.length ? { warnings: job.warnings } : {} };
|
|
1025
|
+
const provenance = { ...job.weather ? { weather: { path: job.weather.path, sha256: job.weather.sha256 } } : {}, ...job.heatingProfile ? { calculationKind: "operating-sensitivity", heatingProfile: job.heatingProfile } : {}, target: manifest2, inputSha256, ...job.preparedBy ? { preparedBy: job.preparedBy } : {}, modes: job.modes, jobId, ...job.startedAt ? { startedAt: job.startedAt } : {}, name: job.name, ...job.warnings?.length ? { warnings: job.warnings } : {} };
|
|
1024
1026
|
try {
|
|
1025
1027
|
await write2(`${archive}/target-run.json`, JSON.stringify({ ...provenance, status: "running" }));
|
|
1026
1028
|
if (archive !== job.outputDirectory) await write2(`${job.outputDirectory}/target-run.json`, JSON.stringify({ ...provenance, status: "running", archive }));
|
|
@@ -242,7 +242,9 @@ function resolveHemTarget(id) {
|
|
|
242
242
|
return target;
|
|
243
243
|
}
|
|
244
244
|
function modelArtifacts(manifest2) {
|
|
245
|
-
|
|
245
|
+
const runtime = [manifest2.runtime.javascript, manifest2.runtime.wasm];
|
|
246
|
+
const converter = [manifest2.preparation.javascript, manifest2.preparation.wasm].filter((path) => !runtime.includes(path));
|
|
247
|
+
return manifest2.artifacts.filter((artifact) => !artifact.path.startsWith("source/") && !artifact.path.startsWith("notices/") && !converter.includes(artifact.path));
|
|
246
248
|
}
|
|
247
249
|
function validateTargetManifest(manifest2, target) {
|
|
248
250
|
if (manifest2.bundleId !== target.id || manifest2.protocol !== 1 || manifest2.engineCommit !== target.engineCommit || manifest2.wrapperCommit !== target.wrapperCommit || manifest2.conversionProfile !== target.conversionProfile) {
|
|
@@ -260,7 +262,7 @@ function validateTargetManifest(manifest2, target) {
|
|
|
260
262
|
sizesByHash.set(artifact.sha256, artifact.bytes);
|
|
261
263
|
paths.add(artifact.path);
|
|
262
264
|
}
|
|
263
|
-
for (const path of [
|
|
265
|
+
for (const path of [manifest2.preparation.schema, manifest2.preparation.defaults, manifest2.runtime.javascript, ...manifest2.runtime.wasm ? [manifest2.runtime.wasm] : [], ...manifest2.runtime.wheels ?? []]) {
|
|
264
266
|
if (path.startsWith("source/") || path.startsWith("notices/")) throw new Error(`Runtime/preparation cannot reference reserved source/notice material: ${path}`);
|
|
265
267
|
if (!paths.has(path)) throw new Error(`Target manifest is missing required artifact ${path}`);
|
|
266
268
|
}
|
|
@@ -436,7 +438,7 @@ async function executePreparedJobs(manifest2, bundleId, jobId, jobs, execute, wr
|
|
|
436
438
|
const archive = job.archiveDirectory ?? job.outputDirectory;
|
|
437
439
|
const inputSha256 = await sha256(new TextEncoder().encode(job.input));
|
|
438
440
|
if (job.weather && (!job.weather.epw.trim() || await sha256(new TextEncoder().encode(job.weather.epw)) !== job.weather.sha256)) throw new Error("Prepared weather hash mismatch or empty EPW");
|
|
439
|
-
const provenance = { ...job.weather ? { weather: { path: job.weather.path, sha256: job.weather.sha256 } } : {}, ...job.heatingProfile ? { calculationKind: "operating-sensitivity", heatingProfile: job.heatingProfile } : {}, target: manifest2, inputSha256, modes: job.modes, jobId, ...job.startedAt ? { startedAt: job.startedAt } : {}, name: job.name, ...job.warnings?.length ? { warnings: job.warnings } : {} };
|
|
441
|
+
const provenance = { ...job.weather ? { weather: { path: job.weather.path, sha256: job.weather.sha256 } } : {}, ...job.heatingProfile ? { calculationKind: "operating-sensitivity", heatingProfile: job.heatingProfile } : {}, target: manifest2, inputSha256, ...job.preparedBy ? { preparedBy: job.preparedBy } : {}, modes: job.modes, jobId, ...job.startedAt ? { startedAt: job.startedAt } : {}, name: job.name, ...job.warnings?.length ? { warnings: job.warnings } : {} };
|
|
440
442
|
try {
|
|
441
443
|
await write2(`${archive}/target-run.json`, JSON.stringify({ ...provenance, status: "running" }));
|
|
442
444
|
if (archive !== job.outputDirectory) await write2(`${job.outputDirectory}/target-run.json`, JSON.stringify({ ...provenance, status: "running", archive }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHash as W}from"node:crypto";import l from"node:fs";import f from"node:path";import{fileURLToPath as S}from"node:url";function _(e=process.cwd()){let r=f.resolve(e);for(l.existsSync(r)&&l.statSync(r).isFile()&&(r=f.dirname(r));;){if(l.existsSync(f.join(r,"package.json"))&&l.existsSync(f.join(r,"hem-batch-core"))&&l.existsSync(f.join(r,"web")))return r;let n=f.dirname(r);if(n===r)break;r=n}let t=f.dirname(S(import.meta.url));return f.resolve(t,"..","..","..")}import a from"node:fs";import o from"node:path";import{fileURLToPath as k,pathToFileURL as J}from"node:url";var h=new Map,v=!1,m=process.cwd(),b=!1;function G(e){let r=[o.join(_(e),"web","pkg"),...["../wasm/","../../wasm/"].map(n=>k(new URL(n,import.meta.url)))],t=r.find(n=>a.existsSync(o.join(n,"wasm_wrapper.js")));if(!t)throw new Error(`The Vulcan engine WASM is not installed (looked in ${r.join(", ")}). Reinstall the package.`);return t}async function j(e,r){let t=r?`${e}?verified`:e,n=h.get(t);if(n)return n;T();let i=o.join(e,"wasm_wrapper.js"),g=o.join(e,"wasm_wrapper_bg.wasm"),p=o.join(e,"wasm_version.json");if(!a.existsSync(i)||!a.existsSync(g))throw new Error(`Browser WASM artifact not found in ${e}`);let s=await import(J(i).href+(r?"?verified":""));if(typeof s.initSync!="function")throw new Error("WASM module is missing initSync");if(s.initSync({module:r??a.readFileSync(g)}),s.setup_panic_hook?.(),typeof s.convert_geometry_csv_to_json!="function")throw new Error("WASM module is missing convert_geometry_csv_to_json");let c={convertGeometryCsvToJson:s.convert_geometry_csv_to_json.bind(s),validateSnippetJs:s.validate_snippet_js?.bind(s),processBatchConfig:s.process_batch_config?.bind(s),calculateMetricsFromParsedData:s.calculate_metrics_from_parsed_data?.bind(s),setWorkspace:M,prepareTargetScenario:s.prepare_target_scenario?.bind(s),metadata:{source:i,wasm_path:g,wasm_version:x(p),build_stamp:u(s.build_stamp),build_info:E(s.get_build_info),runtime_origin_descriptor:u(s.runtime_origin_descriptor),hem_core_version:u(s.metadata_hem_core_version),fhs_wrapper_version:u(s.metadata_fhs_wrapper_version)}};return h.set(t,c),c}var w=new Map;async function q(e,r){let t=w.get(e);if(t)return t;let n=c=>{try{return a.readFileSync(o.join(e,c))}catch{throw new Error(`The package WASM is incomplete: ${o.join(e,c)} is missing. ${r}`)}},i=JSON.parse(n("wasm_version.json").toString("utf8"));for(let c of["js_sha256","sha256"])if(!i[c])throw new Error(`${o.join(e,"wasm_version.json")} has no ${c}. ${r}`);let g=c=>W("sha256").update(c).digest("hex"),p=n("wasm_wrapper_bg.wasm");if(g(n("wasm_wrapper.js"))!==i.js_sha256||g(p)!==i.sha256)throw new Error(`The WASM in ${e} does not match its wasm_version.json. ${r}`);let s={...await j(e,p),versionInfo:i};return w.set(e,s),s}function M(e,r={}){m=o.resolve(e),b=r.confineToWorkspace===!0}function T(){P(),R();let e=globalThis;e.self||(e.self=globalThis),e.window||(e.window=globalThis),typeof e.addEventListener!="function"&&(e.addEventListener=()=>{}),typeof e.postMessage!="function"&&(e.postMessage=()=>{});let r=e.self;typeof r.addEventListener!="function"&&(r.addEventListener=()=>{}),typeof r.postMessage!="function"&&(r.postMessage=()=>{}),typeof e.Worker!="function"&&(e.Worker=class{addEventListener(){}postMessage(){}terminate(){}}),e.write_file=(t,n)=>{let i=d(t);try{return a.mkdirSync(o.dirname(i),{recursive:!0}),a.writeFileSync(i,n),!0}catch(g){return console.error(`[FS Bridge] write_file failed for ${i}:`,g.message),!1}},e.read_file=t=>{let n=d(t);return a.readFileSync(n,"utf8")},e.file_exists=t=>{let n=d(t);return a.existsSync(n)},e.create_dir_all=t=>{let n=d(t);try{return a.mkdirSync(n,{recursive:!0}),!0}catch(i){return console.error(`[FS Bridge] create_dir_all failed for ${n}:`,i.message),!1}},e.list_dir=t=>{let n=d(t);try{return a.readdirSync(n)}catch{return[]}}}function d(e){let r=o.isAbsolute(e)?o.resolve(e):o.resolve(m,e);if(b){let t=o.relative(m,r);if(t===".."||t.startsWith(`..${o.sep}`)||o.isAbsolute(t))throw new Error(`WASM file access escaped the active Vulcan workspace: ${e}`)}return r}function P(){if(v)return;let e=console.error.bind(console);console.log=(...r)=>{let t=r[0];typeof t=="string"&&t.startsWith("[WASM]")||e(...r)},v=!0}var y=!1;function R(){if(y)return;let e=globalThis.fetch?.bind(globalThis);globalThis.fetch=(r,t)=>{let n=typeof r=="string"?r:r instanceof URL?r.href:typeof r?.url=="string"?r.url:String(r);if(n.startsWith("file:")&&n.includes("wasm-bindgen-rayon"))return new Promise(()=>{});if(!e)throw new Error("global fetch is unavailable for WASM bridge requests");return e(r,t)},y=!0}function x(e){try{return JSON.parse(a.readFileSync(e,"utf8"))}catch{return}}function u(e){return typeof e!="function"?void 0:e()||void 0}function E(e){let r=u(e);if(r)try{return JSON.parse(r)}catch{return r}}export{j as loadBrowserWasm,q as loadPackageWasm,G as resolveLegacyWasmDir,M as setBrowserWasmWorkspace};
|
package/dist/server.d.ts
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
|
|
3
|
+
interface MCPConfig {
|
|
4
|
+
workspace: string;
|
|
5
|
+
/** A Vulcan Pro access token. Absent for Free use: Free tools need no account. */
|
|
6
|
+
license_token?: string;
|
|
7
|
+
/** The config file read, when there was one. */
|
|
8
|
+
configPath?: string;
|
|
9
|
+
}
|
|
10
|
+
interface ResolveConfigOptions {
|
|
11
|
+
/** Explicit vulcan-mcp-config.json. */
|
|
12
|
+
configPath?: string;
|
|
13
|
+
/** Workspace folder, for use without a config file (Free). */
|
|
14
|
+
workspace?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare const HELPER_VERSION: string;
|
|
18
|
+
/** One server per connection: tools are stateless and a fresh instance keeps requests independent. */
|
|
19
|
+
declare function createVulcanMcpServer(config: MCPConfig): McpServer;
|
|
20
|
+
/** stdio: launched by the MCP client (Claude Code, Codex, Claude Desktop, Cursor). Free or Pro. */
|
|
21
|
+
declare function startStdioServer(options?: ResolveConfigOptions): Promise<void>;
|
|
1
22
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @param port Optional port number (defaults to 5000)
|
|
23
|
+
* Local HTTP on 127.0.0.1. Requests must carry the configured Pro token as a Bearer
|
|
24
|
+
* credential: without it any web page could call the helper through the browser.
|
|
25
|
+
* Free use goes through stdio, which has no such exposure.
|
|
6
26
|
*/
|
|
7
|
-
declare function startServer(
|
|
27
|
+
declare function startServer(options?: ResolveConfigOptions, port?: number): Promise<void>;
|
|
8
28
|
|
|
9
|
-
export { startServer };
|
|
29
|
+
export { HELPER_VERSION, createVulcanMcpServer, startServer, startStdioServer };
|