@vulcan-energy/mcp-helper 0.3.0 → 0.3.2
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/README.md +1 -1
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/dist/bin/vulcan-mcp-helper.js +36 -34
- package/dist/hem-target-runtime/browser-adapter.mjs +49 -10
- package/dist/hem-target-runtime/host.mjs +124 -32
- package/dist/hem-target-runtime/preparation.mjs +19241 -11263
- package/dist/hem-target-runtime/python-worker.mjs +3192 -689
- package/dist/hem-target-runtime/release-manifests.mjs +73 -29
- package/dist/hem-target-runtime/rust-worker.mjs +2939 -51
- package/dist/server.js +35 -33
- package/package.json +1 -1
- package/wasm/wasm_version.json +9 -9
- package/wasm/wasm_wrapper.js +6 -6
- package/wasm/wasm_wrapper_bg.wasm +0 -0
|
@@ -9,13 +9,16 @@ import { fileURLToPath } from 'node:url';
|
|
|
9
9
|
|
|
10
10
|
const hash = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
11
11
|
const RELEASE_ORIGIN = 'https://usevulcan.app';
|
|
12
|
+
// Catalogue ids: lower-case words joined by '-' or '.' (the EPC id carries its version, 0.13.2); never '..'.
|
|
13
|
+
const BUNDLE_ID = /^[a-z0-9]+(?:[.-][a-z0-9]+)*$/;
|
|
12
14
|
// As targets.ts:modelArtifacts: not source archives or notices, and not a pinned converter
|
|
13
15
|
// that is not also the runtime. The host converts with the package's own WASM.
|
|
14
16
|
const isModelArtifact = (manifest, path) => !path.startsWith('source/') && !path.startsWith('notices/')
|
|
15
17
|
&& !([manifest.preparation?.javascript, manifest.preparation?.wasm].includes(path) && ![manifest.runtime?.javascript, manifest.runtime?.wasm].includes(path));
|
|
16
|
-
// Preparation reads only the pinned schema and
|
|
18
|
+
// Preparation reads only the pinned schema, defaults and product data (targetPreparation.ts:preparationManifest).
|
|
17
19
|
const isSelected = (manifest, path, preparationOnly) => preparationOnly
|
|
18
|
-
? [manifest.preparation?.schema, manifest.preparation?.defaults].includes(path)
|
|
20
|
+
? [manifest.preparation?.schema, manifest.preparation?.defaults].includes(path) || (!!manifest.runtime?.data && path.startsWith(manifest.runtime.data))
|
|
21
|
+
: isModelArtifact(manifest, path);
|
|
19
22
|
function assertArtifactPath(path) {
|
|
20
23
|
if (!path || path.includes('\\') || path.startsWith('/') || path.split('/').some(part => !part || part === '..' || part === '.')) throw new Error('Invalid target artifact path');
|
|
21
24
|
}
|
|
@@ -24,7 +27,7 @@ export async function readVerifiedBundle(manifestPath, expectedHash, { preparati
|
|
|
24
27
|
const bytes = await readFile(manifestPath);
|
|
25
28
|
if (hash(bytes) !== expectedHash) throw new Error('Target manifest hash mismatch');
|
|
26
29
|
const manifest = JSON.parse(bytes);
|
|
27
|
-
if (
|
|
30
|
+
if (!BUNDLE_ID.test(manifest.bundleId ?? '') || !Array.isArray(manifest.artifacts)) throw new Error('Invalid target manifest');
|
|
28
31
|
const root = await realpath(dirname(manifestPath));
|
|
29
32
|
const routes = new Map();
|
|
30
33
|
for (const artifact of manifest.artifacts) {
|
|
@@ -39,12 +42,40 @@ export async function readVerifiedBundle(manifestPath, expectedHash, { preparati
|
|
|
39
42
|
return { manifest, routes };
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
const NOT_AVAILABLE = 'Heating sizing is not available for this target: design-heat-loss.mjs runs Rust HEM:FHS targets only';
|
|
46
|
+
/** The target module, loaded from the verified bundle bytes, or why it cannot be used. */
|
|
47
|
+
export async function loadDesignHeatLossTarget(manifestPath, manifestSha256) {
|
|
48
|
+
let bundle;
|
|
49
|
+
try { bundle = await readVerifiedBundle(manifestPath, manifestSha256); }
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (error.code === 'ENOENT') return { reason: `The HEM target is not downloaded: ${error.path} is missing. Run a model on it once in Vulcan, or stage it.` };
|
|
52
|
+
throw error;
|
|
46
53
|
}
|
|
47
|
-
|
|
54
|
+
// From the manifest bytes whose hash was checked: a second read could see another file.
|
|
55
|
+
const { bundleId, runtime } = bundle.manifest;
|
|
56
|
+
if (!bundleId.startsWith('rust-fhs-') || !runtime?.javascript || !runtime.wasm) return { reason: `${NOT_AVAILABLE}. This manifest is ${bundleId}.` };
|
|
57
|
+
const bytes = path => bundle.routes.get(`/hem-targets/${bundleId}/${path}`);
|
|
58
|
+
// The glue's rayon worker helper listens on `self` when it loads; Node has none, and no workers,
|
|
59
|
+
// so the thread pool is never initialised and the target runs on this thread.
|
|
60
|
+
globalThis.self ??= new EventTarget();
|
|
61
|
+
// The verified bytes are what runs: no second read of the file.
|
|
62
|
+
const module = await import(`data:text/javascript;base64,${Buffer.from(bytes(runtime.javascript)).toString('base64')}`);
|
|
63
|
+
await module.default({ module_or_path: bytes(runtime.wasm) });
|
|
64
|
+
return { module, bundleId };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function releaseTables() {
|
|
68
|
+
try { return await import('./release-manifests.mjs'); }
|
|
69
|
+
catch { throw new Error('HEM target release pins are missing. Build the target CLI assets with node scripts/hem-targets/build-cli-runtime.mjs, or install a helper release that includes them.'); }
|
|
70
|
+
}
|
|
71
|
+
/** The target a saved pin runs on: the replacement of a retired pin (targets.ts RETIRED_HEM_TARGETS), else the pin. */
|
|
72
|
+
export async function currentBundleId(bundleId, retired) {
|
|
73
|
+
retired ??= (await releaseTables()).RETIRED_HEM_TARGETS;
|
|
74
|
+
return Object.hasOwn(retired, bundleId) ? retired[bundleId].replacement : bundleId;
|
|
75
|
+
}
|
|
76
|
+
async function releasePin(bundleId, pins) {
|
|
77
|
+
pins ??= (await releaseTables()).RELEASE_MANIFEST_HASHES;
|
|
78
|
+
const expected = BUNDLE_ID.test(bundleId ?? '') && Object.hasOwn(pins, bundleId) && pins[bundleId];
|
|
48
79
|
if (!expected) throw new Error(`HEM target '${bundleId}' is not supported by this version; update @vulcan-energy/mcp-helper or @vulcan-energy/analyst, whichever you are running`);
|
|
49
80
|
return expected;
|
|
50
81
|
}
|
|
@@ -74,7 +105,9 @@ async function fetchBytes(fetcher, bundleId, url, timeoutMs, root) {
|
|
|
74
105
|
|
|
75
106
|
/** Resolve a released bundle into a local cache, verified against the pins compiled into this helper. */
|
|
76
107
|
// The user cache (XDG_CACHE_HOME, as other tools read it); a host whose home is read-only sets it.
|
|
77
|
-
export async function resolveReleaseBundle(
|
|
108
|
+
export async function resolveReleaseBundle(savedBundleId, { cacheDir = join(process.env.XDG_CACHE_HOME || join(homedir(), '.cache'), 'vulcan/hem-targets'), fetch: fetcher = globalThis.fetch, pins, retired, onProgress, timeoutMs = DOWNLOAD_TIMEOUT_MS, preparationOnly = false } = {}) {
|
|
109
|
+
// A test that supplies pins supplies the retired table with them, or none.
|
|
110
|
+
const bundleId = await currentBundleId(savedBundleId, retired ?? (pins ? {} : undefined));
|
|
78
111
|
const expected = await releasePin(bundleId, pins);
|
|
79
112
|
const root = join(cacheDir, bundleId);
|
|
80
113
|
const manifestPath = join(root, 'manifest.json');
|
|
@@ -194,7 +227,13 @@ export async function runTargetBrowser(options, dependencies = {}) {
|
|
|
194
227
|
const jobId = options.jobId ?? `target_${randomUUID()}`;
|
|
195
228
|
// Every record this run writes carries its start: status readers order runs by it, not by file times.
|
|
196
229
|
const startedAt = new Date().toISOString();
|
|
197
|
-
|
|
230
|
+
// A config name is the user's (the app saves "My house (free copy)"). The same rule as isWorkspaceName
|
|
231
|
+
// (hem-target-runtime/src/hem/workspaceName.ts); containment rests on `contained` below, not on this check.
|
|
232
|
+
const configName = options.configName;
|
|
233
|
+
const userName = configName === undefined || (typeof configName === 'string' && configName.trim() !== '' && !/[\\/<>:"|?*]/.test(configName)
|
|
234
|
+
&& ![...configName].some(character => character.charCodeAt(0) < 0x20)
|
|
235
|
+
&& !configName.startsWith('.') && !/[. ]$/.test(configName));
|
|
236
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(jobId) || !userName) throw new Error('Invalid target job/config name');
|
|
198
237
|
const contained = path => {
|
|
199
238
|
if (typeof path !== 'string' || path.includes('\\')) throw new Error('Invalid workspace path');
|
|
200
239
|
const file = resolve(workspace, path);
|
|
@@ -1,15 +1,61 @@
|
|
|
1
1
|
// ../hem-target-runtime/src/hem/targets.ts
|
|
2
2
|
var WRAPPERS = {
|
|
3
3
|
fhs: {
|
|
4
|
+
/** Wire name the target preparation artifacts accept. */
|
|
4
5
|
profile: "fhs",
|
|
6
|
+
/** Community defaults template the family's bundles pin for preparation. */
|
|
7
|
+
preparationDefaults: "defaults_template.json",
|
|
8
|
+
/** Schema dialect the editor reads; separate from the wire profile. */
|
|
9
|
+
schemaMode: "fhs",
|
|
5
10
|
modes: ["actual", "actual-fee", "notional", "notional-fee"],
|
|
11
|
+
/** Modes of a scenario that selects no model wrapper. */
|
|
12
|
+
defaultModes: ["actual"],
|
|
6
13
|
scenarioModes: {
|
|
7
14
|
fhs_assumptions: ["actual"],
|
|
8
15
|
fhs_compliance: ["actual", "actual-fee", "notional", "notional-fee"]
|
|
9
16
|
},
|
|
10
|
-
|
|
17
|
+
/** The run-mode name users see, per scenario wrapper. */
|
|
18
|
+
scenarioLabels: { fhs_assumptions: "Single run", fhs_compliance: "Compliance" },
|
|
19
|
+
/** How the run's results are read; written to target-run.json. */
|
|
20
|
+
resultsKind: "fhs",
|
|
11
21
|
coreDistribution: "hem-core",
|
|
12
|
-
wrapperDistribution: "hem-fhs-wrapper"
|
|
22
|
+
wrapperDistribution: "hem-fhs-wrapper",
|
|
23
|
+
/** Further pinned distributions; each target pins their version and commit in `components`. */
|
|
24
|
+
componentDistributions: [],
|
|
25
|
+
/** Systems take HEM Database products, picked in the editor's product slots. */
|
|
26
|
+
hemDatabaseProducts: false,
|
|
27
|
+
/** The scenario wrapper an agent's single-model run uses when the caller names none. */
|
|
28
|
+
singleRunWrapper: "fhs_compliance",
|
|
29
|
+
/** Fabric from construction bands on an existing building (the editor's `constructionBands` rule). */
|
|
30
|
+
constructionBands: false,
|
|
31
|
+
/** A scenario may pick its own weather file. */
|
|
32
|
+
customWeather: true
|
|
33
|
+
},
|
|
34
|
+
epc: {
|
|
35
|
+
/** vulcan-model-transform `ModelProfile::Epc`. */
|
|
36
|
+
profile: "epc",
|
|
37
|
+
/** The shared template plus the HEM:EPC fields with no Vulcan source. */
|
|
38
|
+
preparationDefaults: "defaults_template_epc.json",
|
|
39
|
+
/** The full-input schema is a Core-shaped input (pydantic unions), not the FHS dialect. */
|
|
40
|
+
schemaMode: "core",
|
|
41
|
+
/** `quick` is the main EPC run only (upstream --skip-smart-metric --skip-fees-metric); `full` adds the smart and FEES runs. */
|
|
42
|
+
modes: ["quick", "full"],
|
|
43
|
+
defaultModes: ["quick"],
|
|
44
|
+
scenarioModes: {
|
|
45
|
+
epc_quick: ["quick"],
|
|
46
|
+
epc_full: ["full"]
|
|
47
|
+
},
|
|
48
|
+
scenarioLabels: { epc_quick: "Rating and energy", epc_full: "Full EPC" },
|
|
49
|
+
resultsKind: "epc",
|
|
50
|
+
coreDistribution: "hem-core",
|
|
51
|
+
wrapperDistribution: "hem-epc-wrapper",
|
|
52
|
+
componentDistributions: ["hem-epc-orchestrator", "hemie", "hem-db-client"],
|
|
53
|
+
hemDatabaseProducts: true,
|
|
54
|
+
singleRunWrapper: "epc_quick",
|
|
55
|
+
// An existing building converts to HEMIE, whose fabric is the age band and constructions.
|
|
56
|
+
constructionBands: true,
|
|
57
|
+
// The Orchestrator runs on its pinned weather (pythonTarget.ts).
|
|
58
|
+
customWeather: false
|
|
13
59
|
}
|
|
14
60
|
};
|
|
15
61
|
function targetWrapper(target) {
|
|
@@ -18,46 +64,83 @@ function targetWrapper(target) {
|
|
|
18
64
|
return wrapper;
|
|
19
65
|
}
|
|
20
66
|
var HEM_TARGETS = [
|
|
67
|
+
// The Rust a9 that ECaaS runs in production (epb-ecaas-api e1c090e, lambda/Cargo.lock). Its wrapper
|
|
68
|
+
// schema equals the Python a9 one, so it keeps that conversion profile's wire name. It is built
|
|
69
|
+
// with the carried patch set fhs-a9-schema-v1 (targetSchemaCorrections.ts); build and parity:
|
|
70
|
+
// docs/development/HEM_Rust_A9_Target.md. v2: v1's pins and patch set plus the design_heat_loss export.
|
|
21
71
|
{
|
|
22
|
-
id: "rust-fhs-
|
|
23
|
-
label: "
|
|
72
|
+
id: "rust-fhs-a9-9e41af89-f2c2425f-v2",
|
|
73
|
+
label: "HEM:FHS 1.0.0a9",
|
|
24
74
|
runtime: "rust",
|
|
25
|
-
version: "1.0.0a7",
|
|
26
|
-
engineVersion: "1.0.0a7",
|
|
27
|
-
wrapperVersion: "1.0.0a7",
|
|
28
|
-
wrapper: "fhs",
|
|
29
|
-
engineCommit: "62d3df705690f33b3fc3e905c9971d4f3743bf2e",
|
|
30
|
-
wrapperCommit: "c5ba2673fbd886cfe4fb528f61b376bdf406ebbd",
|
|
31
|
-
conversionProfile: "current_rust_fhs"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
id: "python-fhs-a9-918addad-b9b90138-v1",
|
|
35
|
-
label: "Python HEM:FHS 1.0.0a9",
|
|
36
|
-
runtime: "python",
|
|
37
75
|
version: "1.0.0a9",
|
|
38
76
|
engineVersion: "1.0.0a9",
|
|
39
77
|
wrapperVersion: "1.0.0a9",
|
|
40
78
|
wrapper: "fhs",
|
|
41
|
-
engineCommit: "
|
|
42
|
-
wrapperCommit: "
|
|
43
|
-
conversionProfile: "python_fhs_a9"
|
|
79
|
+
engineCommit: "9e41af890cc62a1cec08957340231c3591956dac",
|
|
80
|
+
wrapperCommit: "f2c2425f00870e1611750bd2ac1be20132301e0d",
|
|
81
|
+
conversionProfile: "python_fhs_a9",
|
|
82
|
+
arealHeatCapacity: { classes: "full_depth", numberTypes: ["BuildingElementAdjacentConditionedSpace", "BuildingElementAdjacentUnconditionedSpace_Simple"] },
|
|
83
|
+
// Measured, example_semi_detached at load 15-21 (15 November): Quick sim click to headline in
|
|
84
|
+
// the app 7.1-8.6 s (engine 4.9 s, results write 0.7 s); wasm-browser-cli 5.2-7.1 s.
|
|
85
|
+
// Compliance, all four modes: 48.3-48.6 s in wasm-browser-cli at load 13-19 (13 November).
|
|
86
|
+
// Method: docs/development/HEM_Rust_A9_Target.md, "Run time".
|
|
87
|
+
status: "provisional",
|
|
88
|
+
typicalRunMinutes: { fhs_assumptions: 0.15, fhs_compliance: 0.8 }
|
|
44
89
|
},
|
|
45
90
|
{
|
|
46
|
-
id: "
|
|
47
|
-
label: "
|
|
48
|
-
runtime: "
|
|
49
|
-
version: "1.0.
|
|
50
|
-
engineVersion: "1.0.
|
|
51
|
-
wrapperVersion: "1.0.
|
|
91
|
+
id: "rust-fhs-a7-62d3df70-c5ba2673-v1",
|
|
92
|
+
label: "HEM:FHS 1.0.0a7",
|
|
93
|
+
runtime: "rust",
|
|
94
|
+
version: "1.0.0a7",
|
|
95
|
+
engineVersion: "1.0.0a7",
|
|
96
|
+
wrapperVersion: "1.0.0a7",
|
|
52
97
|
wrapper: "fhs",
|
|
53
|
-
engineCommit: "
|
|
54
|
-
wrapperCommit: "
|
|
55
|
-
conversionProfile: "
|
|
98
|
+
engineCommit: "62d3df705690f33b3fc3e905c9971d4f3743bf2e",
|
|
99
|
+
wrapperCommit: "c5ba2673fbd886cfe4fb528f61b376bdf406ebbd",
|
|
100
|
+
conversionProfile: "current_rust_fhs",
|
|
101
|
+
arealHeatCapacity: { classes: "surface", numberTypes: [] },
|
|
102
|
+
// Actual mode, example_semi_detached at load 17-22 (15 November): Quick sim click to headline in
|
|
103
|
+
// the app 7.9-8.7 s; wasm-browser-cli 6.1-7.1 s. Compliance not measured.
|
|
104
|
+
status: "legacy",
|
|
105
|
+
typicalRunMinutes: { fhs_assumptions: 0.12 }
|
|
56
106
|
}
|
|
57
107
|
];
|
|
58
108
|
var RECOMMENDED_HEM_TARGET = HEM_TARGETS[0].id;
|
|
109
|
+
var HEM_EPC_0_13_2 = {
|
|
110
|
+
id: "python-epc-0.13.2-6367f1ec-18032feb-v1",
|
|
111
|
+
label: "HEM:EPC 0.13.2",
|
|
112
|
+
runtime: "python",
|
|
113
|
+
version: "0.13.2",
|
|
114
|
+
engineVersion: "2.0.0a4",
|
|
115
|
+
wrapperVersion: "0.13.2",
|
|
116
|
+
wrapper: "epc",
|
|
117
|
+
engineCommit: "6367f1ecb101c7f72a2006a921c732c790b0d338",
|
|
118
|
+
wrapperCommit: "18032feb59294b323fc28af4fb032d34bd44bf67",
|
|
119
|
+
conversionProfile: "epc_full_input_v1",
|
|
120
|
+
arealHeatCapacity: { classes: "full_depth", numberTypes: "all" },
|
|
121
|
+
components: {
|
|
122
|
+
"hem-epc-orchestrator": { version: "0.13.2a0", commit: "993463233ad0c416e83c4de3b84889280d3c4619" },
|
|
123
|
+
hemie: { version: "0.18.1", commit: "2876e2ec1c7bad2b738c9c3b3685d86860a91f41" },
|
|
124
|
+
"hem-db-client": { version: "1.0.0a10", commit: "9eeb026dd52a612197b5552ca113d8121fa72679" }
|
|
125
|
+
},
|
|
126
|
+
// db-client/data/*.csv at the hem-db-client commit.
|
|
127
|
+
productDataSha256: "d0acf4ebf050e80f3dc576ffbb1295ebeb1176e9fd4a9ec1d151a9e8f4df7457",
|
|
128
|
+
// Quick, measured in wasm-browser-cli at load 9-20 (15 November, UAT bundle on main): house_two_storey
|
|
129
|
+
// new build 473 s, as an existing building 365 s (HEM_EPC_Integration_Plan.md, Status).
|
|
130
|
+
// Full, estimated: 35 min natively at the measured 2.4-2.6x browser ratio (same plan, Measured).
|
|
131
|
+
status: "preview",
|
|
132
|
+
typicalRunMinutes: { epc_quick: 8, epc_full: 90 },
|
|
133
|
+
estimatedRunMinutes: ["epc_full"]
|
|
134
|
+
};
|
|
135
|
+
var UNRELEASED_HEM_TARGETS = [
|
|
136
|
+
HEM_EPC_0_13_2,
|
|
137
|
+
// The same pins with the HEM Core engine patch set (scripts/hem-targets/stage-python-core.mjs):
|
|
138
|
+
// byte-identical outputs, faster passive-duct runs. A short-term fix; not the default until the owner's UAT.
|
|
139
|
+
{ ...HEM_EPC_0_13_2, id: "python-epc-0.13.2-6367f1ec-18032feb-v2", label: "HEM:EPC 0.13.2 (faster)" }
|
|
140
|
+
];
|
|
141
|
+
var findHemTarget = (id) => [...HEM_TARGETS, ...UNRELEASED_HEM_TARGETS].find((target) => target.id === id);
|
|
59
142
|
function resolveHemTarget(id) {
|
|
60
|
-
const target =
|
|
143
|
+
const target = findHemTarget(id);
|
|
61
144
|
if (!target) throw new Error(`HEM target '${id}' is unavailable. Select a supported target explicitly; saved runs are never upgraded automatically.`);
|
|
62
145
|
return target;
|
|
63
146
|
}
|
|
@@ -67,9 +150,11 @@ function modelArtifacts(manifest) {
|
|
|
67
150
|
return manifest.artifacts.filter((artifact) => !artifact.path.startsWith("source/") && !artifact.path.startsWith("notices/") && !converter.includes(artifact.path));
|
|
68
151
|
}
|
|
69
152
|
function validateTargetManifest(manifest, target) {
|
|
70
|
-
if (manifest.bundleId !== target.id || manifest.protocol !== 1 || manifest.engineCommit !== target.engineCommit || manifest.wrapperCommit !== target.wrapperCommit || manifest.conversionProfile !== target.conversionProfile) {
|
|
153
|
+
if (manifest.bundleId !== target.id || manifest.protocol !== 1 || manifest.engineCommit !== target.engineCommit || manifest.wrapperCommit !== target.wrapperCommit || manifest.conversionProfile !== target.conversionProfile || JSON.stringify(sortedComponents(manifest.components)) !== JSON.stringify(sortedComponents(target.components)) || manifest.productDataSha256 !== target.productDataSha256) {
|
|
71
154
|
throw new Error(`Target manifest identity mismatch for ${target.id}`);
|
|
72
155
|
}
|
|
156
|
+
const wrapper = targetWrapper(target);
|
|
157
|
+
if (JSON.stringify(Object.keys(target.components ?? {}).sort()) !== JSON.stringify([...wrapper.componentDistributions].sort())) throw new Error(`${target.id} must pin exactly the ${target.wrapper.toUpperCase()} component distributions`);
|
|
73
158
|
const paths = /* @__PURE__ */ new Set();
|
|
74
159
|
const sizesByHash = /* @__PURE__ */ new Map();
|
|
75
160
|
const isRelativePath = (path) => typeof path === "string" && /^[a-zA-Z0-9_./+-]+$/.test(path) && path.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
@@ -86,7 +171,10 @@ function validateTargetManifest(manifest, target) {
|
|
|
86
171
|
if (path.startsWith("source/") || path.startsWith("notices/")) throw new Error(`Runtime/preparation cannot reference reserved source/notice material: ${path}`);
|
|
87
172
|
if (!paths.has(path)) throw new Error(`Target manifest is missing required artifact ${path}`);
|
|
88
173
|
}
|
|
89
|
-
if (!manifest.modes.length || new Set(manifest.modes).size !== manifest.modes.length || manifest.modes.some((mode) => !
|
|
174
|
+
if (!manifest.modes.length || new Set(manifest.modes).size !== manifest.modes.length || manifest.modes.some((mode) => !wrapper.modes.includes(mode))) throw new Error(`Unsupported or duplicate ${target.wrapper.toUpperCase()} calculation modes`);
|
|
175
|
+
const { data } = manifest.runtime;
|
|
176
|
+
if (!!data !== !!target.productDataSha256) throw new Error("Runtime product data and its pinned hash must be declared together");
|
|
177
|
+
if (data && (target.runtime !== "python" || data.startsWith("source/") || data.startsWith("notices/") || !data.endsWith("/") || !isRelativePath(data.slice(0, -1)) || !manifest.artifacts.some((artifact) => artifact.path.startsWith(data)))) throw new Error("Runtime product data must be a non-empty relative Python bundle directory ending in /");
|
|
90
178
|
if (target.runtime === "rust") {
|
|
91
179
|
if (!manifest.runtime.wasm) throw new Error("Rust target manifest is missing its runtime WASM artifact");
|
|
92
180
|
if (manifest.modes.some((mode) => mode !== "actual") && manifest.modes.length !== targetWrapper(target).modes.length) throw new Error("Rust target modes require actual alone or the complete compliance set");
|
|
@@ -98,11 +186,15 @@ function validateTargetManifest(manifest, target) {
|
|
|
98
186
|
for (const file of ["pyodide.asm.js", "pyodide.asm.wasm", "pyodide-lock.json", "python_stdlib.zip"]) {
|
|
99
187
|
if (!paths.has(`${index}${file}`)) throw new Error(`Python runtime is missing pinned artifact ${index}${file}`);
|
|
100
188
|
}
|
|
101
|
-
if (requiredVersions?.[
|
|
189
|
+
if (requiredVersions?.[wrapper.coreDistribution] !== target.engineVersion || requiredVersions?.[wrapper.wrapperDistribution] !== target.wrapperVersion) {
|
|
102
190
|
throw new Error(`Python runtime must pin matching engine ${target.engineVersion} and wrapper ${target.wrapperVersion} distributions`);
|
|
103
191
|
}
|
|
192
|
+
for (const [distribution, { version }] of Object.entries(target.components ?? {})) {
|
|
193
|
+
if (requiredVersions?.[distribution] !== version) throw new Error(`Python runtime must pin ${distribution} ${version}`);
|
|
194
|
+
}
|
|
104
195
|
}
|
|
105
196
|
}
|
|
197
|
+
var sortedComponents = (components) => Object.entries(components ?? {}).sort(([a], [b]) => a.localeCompare(b));
|
|
106
198
|
|
|
107
199
|
// ../hem-target-runtime/src/hem/targetAssets.ts
|
|
108
200
|
var CACHE = "vulcan-hem-artifacts-v1";
|