@vulcan-energy/mcp-helper 0.3.1 → 0.3.3
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/bin/vulcan-mcp-helper.js +34 -32
- package/dist/hem-target-runtime/browser-adapter.mjs +29 -1
- package/dist/hem-target-runtime/host.mjs +40 -29
- package/dist/hem-target-runtime/preparation.mjs +5728 -4625
- package/dist/hem-target-runtime/python-worker.mjs +373 -75
- package/dist/hem-target-runtime/release-manifests.mjs +49 -8
- package/dist/hem-target-runtime/rust-worker.mjs +523 -60
- package/dist/server.js +33 -31
- package/package.json +1 -1
- package/wasm/wasm_version.json +10 -10
- package/wasm/wasm_wrapper.js +27 -6
- package/wasm/wasm_wrapper_bg.wasm +0 -0
|
@@ -2339,9 +2339,9 @@ var HEM_TARGETS = [
|
|
|
2339
2339
|
// The Rust a9 that ECaaS runs in production (epb-ecaas-api e1c090e, lambda/Cargo.lock). Its wrapper
|
|
2340
2340
|
// schema equals the Python a9 one, so it keeps that conversion profile's wire name. It is built
|
|
2341
2341
|
// with the carried patch set fhs-a9-schema-v1 (targetSchemaCorrections.ts); build and parity:
|
|
2342
|
-
// docs/development/HEM_Rust_A9_Target.md.
|
|
2342
|
+
// docs/development/HEM_Rust_A9_Target.md. v2: v1's pins and patch set plus the design_heat_loss export.
|
|
2343
2343
|
{
|
|
2344
|
-
id: "rust-fhs-a9-9e41af89-f2c2425f-
|
|
2344
|
+
id: "rust-fhs-a9-9e41af89-f2c2425f-v2",
|
|
2345
2345
|
label: "HEM:FHS 1.0.0a9",
|
|
2346
2346
|
runtime: "rust",
|
|
2347
2347
|
version: "1.0.0a9",
|
|
@@ -2351,8 +2351,11 @@ var HEM_TARGETS = [
|
|
|
2351
2351
|
engineCommit: "9e41af890cc62a1cec08957340231c3591956dac",
|
|
2352
2352
|
wrapperCommit: "f2c2425f00870e1611750bd2ac1be20132301e0d",
|
|
2353
2353
|
conversionProfile: "python_fhs_a9",
|
|
2354
|
-
|
|
2355
|
-
//
|
|
2354
|
+
arealHeatCapacity: { classes: "full_depth", numberTypes: ["BuildingElementAdjacentConditionedSpace", "BuildingElementAdjacentUnconditionedSpace_Simple"] },
|
|
2355
|
+
// Measured, example_semi_detached at load 15-21 (15 November): Quick sim click to headline in
|
|
2356
|
+
// the app 7.1-8.6 s (engine 4.9 s, results write 0.7 s); wasm-browser-cli 5.2-7.1 s.
|
|
2357
|
+
// Compliance, all four modes: 48.3-48.6 s in wasm-browser-cli at load 13-19 (13 November).
|
|
2358
|
+
// Method: docs/development/HEM_Rust_A9_Target.md, "Run time".
|
|
2356
2359
|
status: "provisional",
|
|
2357
2360
|
typicalRunMinutes: { fhs_assumptions: 0.15, fhs_compliance: 0.8 }
|
|
2358
2361
|
},
|
|
@@ -2367,37 +2370,45 @@ var HEM_TARGETS = [
|
|
|
2367
2370
|
engineCommit: "62d3df705690f33b3fc3e905c9971d4f3743bf2e",
|
|
2368
2371
|
wrapperCommit: "c5ba2673fbd886cfe4fb528f61b376bdf406ebbd",
|
|
2369
2372
|
conversionProfile: "current_rust_fhs",
|
|
2370
|
-
|
|
2373
|
+
arealHeatCapacity: { classes: "surface", numberTypes: [] },
|
|
2374
|
+
// Actual mode, example_semi_detached at load 17-22 (15 November): Quick sim click to headline in
|
|
2375
|
+
// the app 7.9-8.7 s; wasm-browser-cli 6.1-7.1 s. Compliance not measured.
|
|
2371
2376
|
status: "legacy",
|
|
2372
2377
|
typicalRunMinutes: { fhs_assumptions: 0.12 }
|
|
2373
2378
|
}
|
|
2374
2379
|
];
|
|
2375
2380
|
var RECOMMENDED_HEM_TARGET = HEM_TARGETS[0].id;
|
|
2381
|
+
var HEM_EPC_0_13_2 = {
|
|
2382
|
+
id: "python-epc-0.13.2-6367f1ec-18032feb-v1",
|
|
2383
|
+
label: "HEM:EPC 0.13.2",
|
|
2384
|
+
runtime: "python",
|
|
2385
|
+
version: "0.13.2",
|
|
2386
|
+
engineVersion: "2.0.0a4",
|
|
2387
|
+
wrapperVersion: "0.13.2",
|
|
2388
|
+
wrapper: "epc",
|
|
2389
|
+
engineCommit: "6367f1ecb101c7f72a2006a921c732c790b0d338",
|
|
2390
|
+
wrapperCommit: "18032feb59294b323fc28af4fb032d34bd44bf67",
|
|
2391
|
+
conversionProfile: "epc_full_input_v1",
|
|
2392
|
+
arealHeatCapacity: { classes: "full_depth", numberTypes: "all" },
|
|
2393
|
+
components: {
|
|
2394
|
+
"hem-epc-orchestrator": { version: "0.13.2a0", commit: "993463233ad0c416e83c4de3b84889280d3c4619" },
|
|
2395
|
+
hemie: { version: "0.18.1", commit: "2876e2ec1c7bad2b738c9c3b3685d86860a91f41" },
|
|
2396
|
+
"hem-db-client": { version: "1.0.0a10", commit: "9eeb026dd52a612197b5552ca113d8121fa72679" }
|
|
2397
|
+
},
|
|
2398
|
+
// db-client/data/*.csv at the hem-db-client commit.
|
|
2399
|
+
productDataSha256: "d0acf4ebf050e80f3dc576ffbb1295ebeb1176e9fd4a9ec1d151a9e8f4df7457",
|
|
2400
|
+
// Quick, measured in wasm-browser-cli at load 9-20 (15 November, UAT bundle on main): house_two_storey
|
|
2401
|
+
// new build 473 s, as an existing building 365 s (HEM_EPC_Integration_Plan.md, Status).
|
|
2402
|
+
// Full, estimated: 35 min natively at the measured 2.4-2.6x browser ratio (same plan, Measured).
|
|
2403
|
+
status: "preview",
|
|
2404
|
+
typicalRunMinutes: { epc_quick: 8, epc_full: 90 },
|
|
2405
|
+
estimatedRunMinutes: ["epc_full"]
|
|
2406
|
+
};
|
|
2376
2407
|
var UNRELEASED_HEM_TARGETS = [
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
version: "0.13.2",
|
|
2382
|
-
engineVersion: "2.0.0a4",
|
|
2383
|
-
wrapperVersion: "0.13.2",
|
|
2384
|
-
wrapper: "epc",
|
|
2385
|
-
engineCommit: "6367f1ecb101c7f72a2006a921c732c790b0d338",
|
|
2386
|
-
wrapperCommit: "18032feb59294b323fc28af4fb032d34bd44bf67",
|
|
2387
|
-
conversionProfile: "epc_full_input_v1",
|
|
2388
|
-
components: {
|
|
2389
|
-
"hem-epc-orchestrator": { version: "0.13.2a0", commit: "993463233ad0c416e83c4de3b84889280d3c4619" },
|
|
2390
|
-
hemie: { version: "0.18.1", commit: "2876e2ec1c7bad2b738c9c3b3685d86860a91f41" },
|
|
2391
|
-
"hem-db-client": { version: "1.0.0a10", commit: "9eeb026dd52a612197b5552ca113d8121fa72679" }
|
|
2392
|
-
},
|
|
2393
|
-
// db-client/data/*.csv at the hem-db-client commit.
|
|
2394
|
-
productDataSha256: "d0acf4ebf050e80f3dc576ffbb1295ebeb1176e9fd4a9ec1d151a9e8f4df7457",
|
|
2395
|
-
// Quick, measured: house_two_storey 491-535 s in wasm-browser-cli (HEM_EPC_Integration_Plan.md, Status).
|
|
2396
|
-
// Full, estimated: 35 min natively at the measured 2.4-2.6x browser ratio (same plan, Measured).
|
|
2397
|
-
status: "provisional",
|
|
2398
|
-
typicalRunMinutes: { epc_quick: 9, epc_full: 90 },
|
|
2399
|
-
estimatedRunMinutes: ["epc_full"]
|
|
2400
|
-
}
|
|
2408
|
+
HEM_EPC_0_13_2,
|
|
2409
|
+
// The same pins with the HEM Core engine patch set (scripts/hem-targets/stage-python-core.mjs):
|
|
2410
|
+
// byte-identical outputs, faster passive-duct runs. A short-term fix; not the default until the owner's UAT.
|
|
2411
|
+
{ ...HEM_EPC_0_13_2, id: "python-epc-0.13.2-6367f1ec-18032feb-v2", label: "HEM:EPC 0.13.2 (faster)" }
|
|
2401
2412
|
];
|
|
2402
2413
|
var findHemTarget = (id) => [...HEM_TARGETS, ...UNRELEASED_HEM_TARGETS].find((target) => target.id === id);
|
|
2403
2414
|
function resolveHemTarget(id) {
|
|
@@ -2594,8 +2605,76 @@ var TargetAssets = class _TargetAssets {
|
|
|
2594
2605
|
}
|
|
2595
2606
|
};
|
|
2596
2607
|
|
|
2608
|
+
// ../hem-target-runtime/src/hem/workspaceName.ts
|
|
2609
|
+
var NON_PORTABLE_NAME_CHARACTERS = /[<>:"|?*]/;
|
|
2610
|
+
var hasControlCharacter = (name) => [...name].some((character) => character.charCodeAt(0) < 32);
|
|
2611
|
+
function isWorkspaceName(name) {
|
|
2612
|
+
return typeof name === "string" && name.trim() !== "" && !/[\\/]/.test(name) && !NON_PORTABLE_NAME_CHARACTERS.test(name) && !hasControlCharacter(name) && !name.startsWith(".") && !/[. ]$/.test(name);
|
|
2613
|
+
}
|
|
2614
|
+
function isRunOutputPath(path) {
|
|
2615
|
+
const segments = path.split("/");
|
|
2616
|
+
return segments[0] === "output" && segments.length > 1 && segments.slice(1).every(isWorkspaceName);
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
// ../community/packages/geometry-editor/src/lib/issueTarget.ts
|
|
2620
|
+
var issuePathSegments = (path) => (path ?? "").split("/").filter(Boolean).map((segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
2621
|
+
|
|
2597
2622
|
// ../community/packages/geometry-editor/src/lib/hemieFabric.ts
|
|
2598
2623
|
var ENGLAND_AREAS = new Set("AL B BA BB BD BH BL BN BR BS CB CM CO CR CT CV CW DA DE DH DL DN DT DY E EC EN EX FY GL GU HA HD HG HP HU HX IG IP KT L LA LE LN LS LU M ME MK N NE NG NN NR NW OL OX PE PL PO PR RG RH RM S SE SG SK SL SM SN SO SP SR SS ST SW TA TF TN TQ TR TS TW UB W WA WC WD WF WN WR WS WV YO".split(" "));
|
|
2624
|
+
var HEMIE_NATION = "HEMIE_nation";
|
|
2625
|
+
var ROOF_DETAILS = ["ceiling_thickness", "ceiling_thermal_conductivity", "joist_depth", "percentage_area_of_timber_joists", "insulation_thermal_conductivity"];
|
|
2626
|
+
var LOFT_DETAILS = [...ROOF_DETAILS, "rafter_depth", "percentage_area_of_timber_rafters", "roof_characteristics", "air_gap_thermal_resistance"];
|
|
2627
|
+
var WALL_FINISHES = {
|
|
2628
|
+
Brick: "BrickFinish",
|
|
2629
|
+
Render: "RenderFinish",
|
|
2630
|
+
Timber: "TimberFinish",
|
|
2631
|
+
"Metal (uncoated)": "MetalUncoatedFinish",
|
|
2632
|
+
"Metal (coated)": "MetalCoatedFinish",
|
|
2633
|
+
"Fibre-cement": "FibreCementWallFinish",
|
|
2634
|
+
"Composite panels (metal skins)": "CompositePanelsFinish"
|
|
2635
|
+
};
|
|
2636
|
+
var ROOF_FINISHES = {
|
|
2637
|
+
"Concrete roof tile": "ConcreteRoofTileFinish",
|
|
2638
|
+
"Clay tile": "ClayTileFinish",
|
|
2639
|
+
Slate: "SlateFinish",
|
|
2640
|
+
Asphalt: "AsphaltFinish",
|
|
2641
|
+
Timber: "TimberFinish",
|
|
2642
|
+
"Metal (uncoated)": "MetalUncoatedFinish",
|
|
2643
|
+
"Metal (coated)": "MetalCoatedFinish",
|
|
2644
|
+
"Fibre-cement": "FibreCementRoofFinish",
|
|
2645
|
+
"Composite panels (metal skins)": "CompositePanelsFinish"
|
|
2646
|
+
};
|
|
2647
|
+
var DOOR_FINISHES = {
|
|
2648
|
+
Timber: "TimberFinish",
|
|
2649
|
+
"Metal (uncoated)": "MetalUncoatedFinish",
|
|
2650
|
+
"Metal (coated)": "MetalCoatedFinish",
|
|
2651
|
+
"Composite panels (metal skins)": "CompositePanelsFinish"
|
|
2652
|
+
};
|
|
2653
|
+
var PARK_HOME_WALL_FINISHES = {
|
|
2654
|
+
"uPVC vinyl / Plastic": "ParkHomePlasticFinish",
|
|
2655
|
+
"Stucco / Aggregate paint": "ParkHomePaintFinish",
|
|
2656
|
+
"Timber / Wood cladding": "ParkHomeTimberFinish",
|
|
2657
|
+
"CanExel / Engineered HDF": "ParkHomeHDFFinish"
|
|
2658
|
+
};
|
|
2659
|
+
var SURFACE_FINISHES = {
|
|
2660
|
+
external_wall: WALL_FINISHES,
|
|
2661
|
+
external_door: DOOR_FINISHES,
|
|
2662
|
+
park_home_wall: PARK_HOME_WALL_FINISHES,
|
|
2663
|
+
flat_roof: ROOF_FINISHES,
|
|
2664
|
+
unheated_pitched_roof: ROOF_FINISHES,
|
|
2665
|
+
heated_pitched_roof: ROOF_FINISHES,
|
|
2666
|
+
mini_flat_roof: ROOF_FINISHES,
|
|
2667
|
+
mini_pitched_roof: ROOF_FINISHES,
|
|
2668
|
+
park_home_flat_roof: ROOF_FINISHES,
|
|
2669
|
+
park_home_pitched_roof: ROOF_FINISHES
|
|
2670
|
+
};
|
|
2671
|
+
var OUTSIDE_SURFACE_TYPES = /* @__PURE__ */ new Set([...Object.keys(SURFACE_FINISHES), "above_external_area_floor", "park_home_floor", "thatched_roof"]);
|
|
2672
|
+
var words = (value) => value.charAt(0).toUpperCase() + value.slice(1).replace(/_/g, " ");
|
|
2673
|
+
var CONSTRUCTION_TYPE_LABELS = {
|
|
2674
|
+
not_edge_insulated_ground_attached_floor: "Ground floor, no edge insulation",
|
|
2675
|
+
edge_insulated_ground_attached_floor: "Ground floor, edge insulated"
|
|
2676
|
+
};
|
|
2677
|
+
var hemieConstructionTypeLabel = (type) => CONSTRUCTION_TYPE_LABELS[type] ?? words(type);
|
|
2599
2678
|
|
|
2600
2679
|
// ../community/packages/geometry-editor/src/lib/zoneDerivation.ts
|
|
2601
2680
|
var import_polygon_clipping2 = __toESM(require_polygon_clipping_umd(), 1);
|
|
@@ -2603,24 +2682,6 @@ var import_polygon_clipping2 = __toESM(require_polygon_clipping_umd(), 1);
|
|
|
2603
2682
|
// ../community/packages/geometry-editor/src/lib/polygonSync.ts
|
|
2604
2683
|
var import_polygon_clipping = __toESM(require_polygon_clipping_umd(), 1);
|
|
2605
2684
|
|
|
2606
|
-
// ../community/packages/geometry-editor-host/src/schemaPort.ts
|
|
2607
|
-
function unavailable(operation) {
|
|
2608
|
-
throw new Error(`Geometry schema ${operation} is unavailable`);
|
|
2609
|
-
}
|
|
2610
|
-
var unavailableGeometrySchemaPort = Object.freeze({
|
|
2611
|
-
availability: "unavailable",
|
|
2612
|
-
preload: async () => unavailable("preload"),
|
|
2613
|
-
getRootSchema: () => unavailable("root lookup"),
|
|
2614
|
-
getElementSubschema: () => unavailable("element lookup"),
|
|
2615
|
-
getBaseFieldsForElementType: () => unavailable("base-field lookup"),
|
|
2616
|
-
getApplianceKeys: () => unavailable("appliance-key lookup"),
|
|
2617
|
-
getStrictestIntegerKeysForElementType: () => unavailable("numeric-typing lookup"),
|
|
2618
|
-
getSchemaSubtypeForElementData: () => unavailable("subtype lookup"),
|
|
2619
|
-
getConditionalRequiredFields: () => unavailable("conditional-required lookup"),
|
|
2620
|
-
validateProperty: () => unavailable("property validation"),
|
|
2621
|
-
findParameter: () => unavailable("parameter lookup")
|
|
2622
|
-
});
|
|
2623
|
-
|
|
2624
2685
|
// ../community/packages/geometry-editor/src/lib/roofCutouts.ts
|
|
2625
2686
|
var import_polygon_clipping4 = __toESM(require_polygon_clipping_umd(), 1);
|
|
2626
2687
|
|
|
@@ -2667,6 +2728,25 @@ var FHS_MASS_CLASS_COMMENTARY = {
|
|
|
2667
2728
|
"M: Mass concentrated inside": MASS_CLASS_MEANINGS.M
|
|
2668
2729
|
};
|
|
2669
2730
|
|
|
2731
|
+
// ../community/packages/geometry-editor-host/src/schemaPort.ts
|
|
2732
|
+
var A7_AREAL_HEAT_CAPACITY_INPUT = Object.freeze({ classes: "surface", numberTypes: Object.freeze([]) });
|
|
2733
|
+
function unavailable(operation) {
|
|
2734
|
+
throw new Error(`Geometry schema ${operation} is unavailable`);
|
|
2735
|
+
}
|
|
2736
|
+
var unavailableGeometrySchemaPort = Object.freeze({
|
|
2737
|
+
availability: "unavailable",
|
|
2738
|
+
preload: async () => unavailable("preload"),
|
|
2739
|
+
getRootSchema: () => unavailable("root lookup"),
|
|
2740
|
+
getElementSubschema: () => unavailable("element lookup"),
|
|
2741
|
+
getBaseFieldsForElementType: () => unavailable("base-field lookup"),
|
|
2742
|
+
getApplianceKeys: () => unavailable("appliance-key lookup"),
|
|
2743
|
+
getStrictestIntegerKeysForElementType: () => unavailable("numeric-typing lookup"),
|
|
2744
|
+
getSchemaSubtypeForElementData: () => unavailable("subtype lookup"),
|
|
2745
|
+
getConditionalRequiredFields: () => unavailable("conditional-required lookup"),
|
|
2746
|
+
validateProperty: () => unavailable("property validation"),
|
|
2747
|
+
findParameter: () => unavailable("parameter lookup")
|
|
2748
|
+
});
|
|
2749
|
+
|
|
2670
2750
|
// ../community/packages/geometry-editor/src/lib/overrideProvenance.ts
|
|
2671
2751
|
var SLOPED_WIDTH_OVERRIDE_DESCRIPTOR = {
|
|
2672
2752
|
flag: "_widthUserOverride",
|
|
@@ -2776,6 +2856,64 @@ var EXTRA_JSON_OVERRIDE_MARKER_KEYS = [
|
|
|
2776
2856
|
// ../community/packages/geometry-editor/src/lib/globalSettingsValidation.ts
|
|
2777
2857
|
var R_SI_UPWARDS2 = 1 / (5.13 + 5);
|
|
2778
2858
|
var R_SE2 = 1 / (20 + 4.14);
|
|
2859
|
+
var DWELLING_FIELD_KEYS = /* @__PURE__ */ new Set([
|
|
2860
|
+
"Postcode",
|
|
2861
|
+
"PartO_active_cooling_required",
|
|
2862
|
+
"GroundFloorArea",
|
|
2863
|
+
"HeatingControlType",
|
|
2864
|
+
"PartGcompliance",
|
|
2865
|
+
"ColdWaterSource",
|
|
2866
|
+
"BuildingLength",
|
|
2867
|
+
"BuildingWidth",
|
|
2868
|
+
"KitchenExtractorHoodExternal",
|
|
2869
|
+
"HasElectricitySmartMeter",
|
|
2870
|
+
"ElectricitySmartMeterGUID"
|
|
2871
|
+
]);
|
|
2872
|
+
function globalSettingsFieldSection(key) {
|
|
2873
|
+
if (key === "DefaultsPath" || key.startsWith("DefaultAssembly") || key.startsWith("FabricRow_") || key === "HEMIE_age_band" || key.startsWith("HEMIE_construction_")) return "fabric";
|
|
2874
|
+
if (key === "TargetBundleId" || key === "IsExistingBuilding" || key.startsWith("HEMIE_")) return "target";
|
|
2875
|
+
if (key.startsWith("AirPermeability_test_")) return "airTightness";
|
|
2876
|
+
if (key.startsWith("Ventilation_") || key === "AirPermeability_ventilation_zone_height") return "ventilation";
|
|
2877
|
+
if (key === "JunctionPsiDefaultsPath" || key.startsWith("DetailedBridgePsiProfile")) return "thermalBridging";
|
|
2878
|
+
if (key.startsWith("General_") || key.startsWith("NumberOf") || key.startsWith("Appliances_") || DWELLING_FIELD_KEYS.has(key)) return "dwelling";
|
|
2879
|
+
return null;
|
|
2880
|
+
}
|
|
2881
|
+
var METADATA_INPUT_LABELS = {
|
|
2882
|
+
NumberOfBedrooms: "Number of bedrooms",
|
|
2883
|
+
NumberOfWetRooms: "Number of wet rooms",
|
|
2884
|
+
GroundFloorArea: "Ground floor area (m\xB2)",
|
|
2885
|
+
HeatingControlType: "Heating control type",
|
|
2886
|
+
PartGcompliance: "Part G compliance",
|
|
2887
|
+
PartO_active_cooling_required: "Part O active cooling required",
|
|
2888
|
+
AirPermeability_test_pressure: "Test pressure",
|
|
2889
|
+
AirPermeability_test_result: "Test result",
|
|
2890
|
+
AirPermeability_ventilation_zone_height: "Ventilation zone height (m)",
|
|
2891
|
+
Ventilation_shield_class: "Shield class",
|
|
2892
|
+
Ventilation_terrain_class: "Terrain class",
|
|
2893
|
+
Ventilation_altitude: "Altitude (m)",
|
|
2894
|
+
Ventilation_ventilation_zone_base_height: "Ventilation zone base height (m)",
|
|
2895
|
+
Ventilation_noise_nuisance: "Noise nuisance",
|
|
2896
|
+
BuildingLength: "Building length (m)",
|
|
2897
|
+
BuildingWidth: "Building width (m)",
|
|
2898
|
+
NumberOfHotTappedRooms: "Number of hot-tapped rooms",
|
|
2899
|
+
NumberOfUtilityRooms: "Number of utility rooms",
|
|
2900
|
+
NumberOfBathrooms: "Number of bathrooms",
|
|
2901
|
+
NumberOfSanitaryAccommodations: "Number of sanitary accommodations",
|
|
2902
|
+
NumberOfHabitableRooms: "Number of habitable rooms",
|
|
2903
|
+
KitchenExtractorHoodExternal: "Kitchen cooker hood extracts to outside",
|
|
2904
|
+
General_build_type: "Build type",
|
|
2905
|
+
General_built_form: "SAP built form",
|
|
2906
|
+
General_storeys_in_dwelling: "Storeys in dwelling",
|
|
2907
|
+
General_storey_of_dwelling: "Storey of dwelling",
|
|
2908
|
+
General_storeys_in_building: "Storeys in building",
|
|
2909
|
+
HasElectricitySmartMeter: "Electricity smart meter",
|
|
2910
|
+
ElectricitySmartMeterGUID: "Smart meter GUID",
|
|
2911
|
+
IsExistingBuilding: "Existing building",
|
|
2912
|
+
Ventilation_cross_vent_possible: "Cross ventilation possible",
|
|
2913
|
+
Appliances_has_dryer: "Has a clothes dryer",
|
|
2914
|
+
Appliances_has_dishwasher: "Has a dishwasher",
|
|
2915
|
+
Appliances_has_separate_fridge_or_freezer: "Has a separate fridge or freezer"
|
|
2916
|
+
};
|
|
2779
2917
|
var TARGET_INPUT_ROWS = [
|
|
2780
2918
|
"HasElectricitySmartMeter",
|
|
2781
2919
|
"IsExistingBuilding",
|
|
@@ -2786,16 +2924,314 @@ var TARGET_INPUT_ROWS = [
|
|
|
2786
2924
|
];
|
|
2787
2925
|
var TARGET_INPUT_ROW_SET = new Set(TARGET_INPUT_ROWS);
|
|
2788
2926
|
|
|
2927
|
+
// ../community/packages/geometry-editor/src/lib/buildErrorDisplay.ts
|
|
2928
|
+
var SECTION_LOCATIONS = {
|
|
2929
|
+
fabric: "Global Settings > Fabric",
|
|
2930
|
+
target: "Global Settings",
|
|
2931
|
+
dwelling: "Global Settings > Dwelling details",
|
|
2932
|
+
airTightness: "Global Settings > Air tightness",
|
|
2933
|
+
ventilation: "Global Settings > Ventilation environment",
|
|
2934
|
+
thermalBridging: "Global Settings > Thermal bridging"
|
|
2935
|
+
};
|
|
2936
|
+
var VENTILATION_SETTINGS = /* @__PURE__ */ new Set(["cross_vent_possible", "terrain_class", "altitude", "shield_class", "noise_nuisance", "ventilation_zone_base_height"]);
|
|
2937
|
+
var settingsRow = (segments) => {
|
|
2938
|
+
if (segments[0] === "Metadata") return segments[1];
|
|
2939
|
+
if (segments[0] !== "InfiltrationVentilation") return void 0;
|
|
2940
|
+
if (segments[1] === "Leaks") {
|
|
2941
|
+
return segments[2] === "ventilation_zone_height" ? "AirPermeability_ventilation_zone_height" : "AirPermeability_test_result";
|
|
2942
|
+
}
|
|
2943
|
+
return segments[1] && VENTILATION_SETTINGS.has(segments[1]) ? `Ventilation_${segments[1]}` : void 0;
|
|
2944
|
+
};
|
|
2945
|
+
var titleCaseToken = (token) => token.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\s+/g, " ").trim().replace(/\b\w/g, (c) => c.toUpperCase());
|
|
2946
|
+
var pointerSegments = issuePathSegments;
|
|
2947
|
+
var buildErrorLocation = (path) => {
|
|
2948
|
+
const segments = pointerSegments(path);
|
|
2949
|
+
const zoneIdx = segments.indexOf("Zone");
|
|
2950
|
+
const elementIdx = segments.indexOf("BuildingElement");
|
|
2951
|
+
if (zoneIdx >= 0 && segments[zoneIdx + 1]) {
|
|
2952
|
+
const zone = segments[zoneIdx + 1];
|
|
2953
|
+
if (elementIdx >= 0 && segments[elementIdx + 1]) {
|
|
2954
|
+
return {
|
|
2955
|
+
location: `${zone} > ${segments[elementIdx + 1]}`,
|
|
2956
|
+
field: segments[elementIdx + 2]
|
|
2957
|
+
};
|
|
2958
|
+
}
|
|
2959
|
+
return {
|
|
2960
|
+
location: zone,
|
|
2961
|
+
field: segments[zoneIdx + 2]
|
|
2962
|
+
};
|
|
2963
|
+
}
|
|
2964
|
+
if (segments[0] === "Metadata" && segments[1]?.startsWith("HEMIE_")) {
|
|
2965
|
+
const constructionType = segments[1].match(/^HEMIE_construction_(.+)$/)?.[1];
|
|
2966
|
+
return {
|
|
2967
|
+
location: segments[1] === HEMIE_NATION ? "Global Settings > Dwelling details" : `Global Settings > Fabric${constructionType ? ` > ${hemieConstructionTypeLabel(constructionType)}` : ""}`
|
|
2968
|
+
};
|
|
2969
|
+
}
|
|
2970
|
+
const row = settingsRow(segments);
|
|
2971
|
+
const section = row ? globalSettingsFieldSection(row) : null;
|
|
2972
|
+
if (section) return { location: SECTION_LOCATIONS[section] };
|
|
2973
|
+
if (segments.length >= 2) {
|
|
2974
|
+
return {
|
|
2975
|
+
location: `${titleCaseToken(segments[0])} > ${titleCaseToken(segments[1])}`,
|
|
2976
|
+
field: segments[2]
|
|
2977
|
+
};
|
|
2978
|
+
}
|
|
2979
|
+
if (segments.length === 1) {
|
|
2980
|
+
return { location: titleCaseToken(segments[0]) };
|
|
2981
|
+
}
|
|
2982
|
+
return { location: "Model" };
|
|
2983
|
+
};
|
|
2984
|
+
var compactPathLabel = (segments) => {
|
|
2985
|
+
if (segments.length === 0) return "model";
|
|
2986
|
+
return segments.map(titleCaseToken).join(" > ");
|
|
2987
|
+
};
|
|
2988
|
+
var requiredFieldFromMessage = (message) => {
|
|
2989
|
+
const match = message.match(/^"([^"]+)" is a required property$/);
|
|
2990
|
+
return match?.[1] ? titleCaseToken(match[1]) : null;
|
|
2991
|
+
};
|
|
2992
|
+
var minimumFromMessage = (message) => {
|
|
2993
|
+
const match = message.match(/^(.+?) is less than the minimum of (.+)$/);
|
|
2994
|
+
return match?.[2]?.trim() || null;
|
|
2995
|
+
};
|
|
2996
|
+
var maximumFromMessage = (message) => {
|
|
2997
|
+
const match = message.match(/^(.+?) is greater than the maximum of (.+)$/);
|
|
2998
|
+
return match?.[2]?.trim() || null;
|
|
2999
|
+
};
|
|
3000
|
+
var unexpectedFieldsFromMessage = (message) => {
|
|
3001
|
+
const match = message.match(/were unexpected\)$/);
|
|
3002
|
+
if (!match) return null;
|
|
3003
|
+
const fields = [...message.matchAll(/'([^']+)'/g)].flatMap((m) => m[1] ? [m[1]] : []);
|
|
3004
|
+
if (fields.length === 0) return null;
|
|
3005
|
+
const shown = fields.slice(0, 5).map(titleCaseToken).join(", ");
|
|
3006
|
+
return fields.length > 5 ? `${shown}, and ${fields.length - 5} more` : shown;
|
|
3007
|
+
};
|
|
3008
|
+
var isSchemaKeywordError = (item) => Boolean(item.keyword || item.schemaPath);
|
|
3009
|
+
var formatBuildErrorForDisplay = (item) => {
|
|
3010
|
+
const pathSegments = pointerSegments(item.path);
|
|
3011
|
+
const { location, field } = buildErrorLocation(item.path);
|
|
3012
|
+
const fieldLabel = field ? titleCaseToken(field) : void 0;
|
|
3013
|
+
const keyword = item.keyword || "";
|
|
3014
|
+
const requiredField = requiredFieldFromMessage(item.message);
|
|
3015
|
+
const minimum = minimumFromMessage(item.message);
|
|
3016
|
+
const maximum = maximumFromMessage(item.message);
|
|
3017
|
+
const unexpectedFields = unexpectedFieldsFromMessage(item.message);
|
|
3018
|
+
const explicitUserMessage = item.userMessage?.trim();
|
|
3019
|
+
const unstatedInput = item.code === "E_EPC_REQUIRED_INPUT" && pathSegments[0] === "Metadata" && pathSegments[1] ? METADATA_INPUT_LABELS[pathSegments[1]] : void 0;
|
|
3020
|
+
let userMessage;
|
|
3021
|
+
if (explicitUserMessage) {
|
|
3022
|
+
userMessage = explicitUserMessage;
|
|
3023
|
+
} else if (unstatedInput) {
|
|
3024
|
+
const label = /^[A-Z][a-z]/.test(unstatedInput) && !/^Part\b/.test(unstatedInput) ? unstatedInput[0].toLowerCase() + unstatedInput.slice(1) : unstatedInput;
|
|
3025
|
+
userMessage = TARGET_INPUT_ROW_SET.has(pathSegments[1]) ? `Choose yes or no for ${label}.` : `Enter ${label}.`;
|
|
3026
|
+
} else if (location === "Appliances" && (item.message.includes("is not allowed for {}") || item.message.includes("has less than"))) {
|
|
3027
|
+
userMessage = "Add at least one appliance entry.";
|
|
3028
|
+
} else if (pathSegments[0] === "HotWaterDemand" && (item.message.includes("has less than") || keyword === "minProperties")) {
|
|
3029
|
+
userMessage = "Add at least one hot water outlet.";
|
|
3030
|
+
} else if (pathSegments[0] === "Zone" && pathSegments[2] === "Lighting" && pathSegments.length === 3 && item.message.startsWith("null ")) {
|
|
3031
|
+
userMessage = "Add at least one light to this zone.";
|
|
3032
|
+
} else if (pathSegments[0] === "InfiltrationVentilation" && pathSegments[1] === "MechanicalVentilation" && (item.message.includes("schemas listed in the 'oneOf' keyword") || keyword === "oneOf" || keyword === "anyOf")) {
|
|
3033
|
+
userMessage = "Add ventilation position details: height, orientation, and pitch.";
|
|
3034
|
+
} else if (requiredField || keyword === "required") {
|
|
3035
|
+
userMessage = requiredField ? `Add ${requiredField}.` : "Add the missing required field.";
|
|
3036
|
+
} else if (minimum || keyword === "minimum" || keyword === "exclusiveMinimum") {
|
|
3037
|
+
userMessage = `${fieldLabel || "Value"} must be at least ${minimum || "the allowed minimum"}.`;
|
|
3038
|
+
} else if (maximum || keyword === "maximum" || keyword === "exclusiveMaximum") {
|
|
3039
|
+
userMessage = `${fieldLabel || "Value"} must be no more than ${maximum || "the allowed maximum"}.`;
|
|
3040
|
+
} else if (item.message.includes("has less than") || keyword === "minProperties") {
|
|
3041
|
+
userMessage = `Add at least one entry for ${compactPathLabel(pathSegments)}.`;
|
|
3042
|
+
} else if (item.message.includes("schemas listed in the 'oneOf' keyword") || keyword === "oneOf" || keyword === "anyOf") {
|
|
3043
|
+
userMessage = fieldLabel ? `${fieldLabel} does not match an allowed option.` : `${compactPathLabel(pathSegments)} matches none of the forms this HEM version takes. Check its type and the inputs it states.`;
|
|
3044
|
+
} else if (unexpectedFields || keyword === "unevaluatedProperties" || keyword === "additionalProperties") {
|
|
3045
|
+
userMessage = unexpectedFields ? `Remove fields not allowed here: ${unexpectedFields}.` : "Remove fields that are not allowed here.";
|
|
3046
|
+
} else if (keyword === "const" || keyword === "allOf" || item.message.includes("is not allowed for")) {
|
|
3047
|
+
userMessage = location === "Appliances" ? "Check the appliance entries against the selected schema." : "These settings conflict with the selected schema.";
|
|
3048
|
+
} else if (!isSchemaKeywordError(item)) {
|
|
3049
|
+
userMessage = item.message.split("\n")[0];
|
|
3050
|
+
} else {
|
|
3051
|
+
userMessage = fieldLabel ? `Check ${fieldLabel}.` : "Check this section.";
|
|
3052
|
+
}
|
|
3053
|
+
return { item, location, field, userMessage, pathSegments };
|
|
3054
|
+
};
|
|
3055
|
+
var isNoisyUnexpectedPropertiesError = (error) => error.item.keyword === "unevaluatedProperties" || error.item.keyword === "additionalProperties" || error.item.message.includes("Unevaluated properties are not allowed") || error.item.message.includes("Additional properties are not allowed");
|
|
3056
|
+
var filterDisplayBuildErrors = (errors) => {
|
|
3057
|
+
const concreteErrorParents = /* @__PURE__ */ new Set();
|
|
3058
|
+
for (const error of errors) {
|
|
3059
|
+
if (isNoisyUnexpectedPropertiesError(error)) continue;
|
|
3060
|
+
if (error.pathSegments.length > 1) {
|
|
3061
|
+
concreteErrorParents.add(error.pathSegments.slice(0, -1).join("/"));
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
3064
|
+
const converterFailed = errors.some((error) => !isSchemaKeywordError(error.item) && !error.item.severity);
|
|
3065
|
+
return errors.filter((error) => {
|
|
3066
|
+
if (converterFailed && isSchemaKeywordError(error.item) && error.pathSegments.length <= 1 && (error.item.keyword === "anyOf" || error.item.keyword === "oneOf")) return false;
|
|
3067
|
+
if (!isNoisyUnexpectedPropertiesError(error)) return true;
|
|
3068
|
+
return !concreteErrorParents.has(error.pathSegments.join("/"));
|
|
3069
|
+
});
|
|
3070
|
+
};
|
|
3071
|
+
var collapseDerivedBuildErrors = (errors, resolve) => {
|
|
3072
|
+
const rows = errors.map((error) => ({ ...error, target: resolve(error.item.path), derived: [] }));
|
|
3073
|
+
const sourceRowByOwner = /* @__PURE__ */ new Map();
|
|
3074
|
+
for (const row of rows) {
|
|
3075
|
+
if (!isSchemaKeywordError(row.item) && !row.item.severity && row.target.section === "Zone" && !sourceRowByOwner.has(row.target.ownerKey)) {
|
|
3076
|
+
sourceRowByOwner.set(row.target.ownerKey, row);
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
return rows.filter((row) => {
|
|
3080
|
+
const sourceRow = isSchemaKeywordError(row.item) ? sourceRowByOwner.get(row.target.ownerKey) : void 0;
|
|
3081
|
+
if (!sourceRow) return true;
|
|
3082
|
+
sourceRow.derived.push(row);
|
|
3083
|
+
return false;
|
|
3084
|
+
});
|
|
3085
|
+
};
|
|
3086
|
+
var displayBuildErrorRows = (items, resolve) => collapseDerivedBuildErrors(filterDisplayBuildErrors(items.map(formatBuildErrorForDisplay)), resolve);
|
|
3087
|
+
|
|
2789
3088
|
// ../hem-target-runtime/src/hem/pythonFailureMessage.ts
|
|
3089
|
+
var MAX_DETAIL_LINE = 200;
|
|
2790
3090
|
var TargetRunError = class extends Error {
|
|
2791
|
-
constructor(message, failure, traceback) {
|
|
3091
|
+
constructor(message, failure, traceback, report) {
|
|
2792
3092
|
super(message);
|
|
2793
3093
|
this.failure = failure;
|
|
2794
3094
|
this.traceback = traceback;
|
|
3095
|
+
this.report = report;
|
|
2795
3096
|
}
|
|
2796
3097
|
};
|
|
3098
|
+
var pointer = (segments) => segments.map((segment) => `/${segment.replace(/~/g, "~0").replace(/\//g, "~1")}`).join("");
|
|
3099
|
+
var segmentsOf = (path) => path.split("/").slice(1).map((segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
3100
|
+
function authored(segments, provenance) {
|
|
3101
|
+
for (let length = segments.length; length >= Math.max(segments.length - 1, 1); length -= 1) {
|
|
3102
|
+
const source = provenance[pointer(segments.slice(0, length))];
|
|
3103
|
+
if (source !== void 0) return [...segmentsOf(source), ...segments.slice(length)];
|
|
3104
|
+
}
|
|
3105
|
+
return void 0;
|
|
3106
|
+
}
|
|
3107
|
+
function wallNamed(model, message) {
|
|
3108
|
+
const [, storey, edge] = message.match(/for wall 'storey(\d+)_wall(\d+)'/) ?? [];
|
|
3109
|
+
if (storey === void 0) return void 0;
|
|
3110
|
+
const parts = model.Zone?.building_parts ?? {};
|
|
3111
|
+
const found = Object.entries(parts).flatMap(([part, { walls = [] }]) => walls.flatMap((wall, index) => wall.storey_index === Number(storey) && wall.floorplan_index === Number(edge) ? [pointer(["Zone", "building_parts", part, "walls", String(index)])] : []));
|
|
3112
|
+
return found.length === 1 ? found[0] : void 0;
|
|
3113
|
+
}
|
|
3114
|
+
var SYSTEM_SECTIONS = /* @__PURE__ */ new Set(["HotWaterSource", "HeatSourceWet", "SpaceHeatSystem", "SpaceCoolSystem"]);
|
|
3115
|
+
function walk(input, loc, type) {
|
|
3116
|
+
const segments = [];
|
|
3117
|
+
let node = input;
|
|
3118
|
+
let building = false;
|
|
3119
|
+
let arm;
|
|
3120
|
+
for (const [index, raw] of loc.entries()) {
|
|
3121
|
+
const key = String(raw);
|
|
3122
|
+
const present = node !== null && typeof node === "object" && Object.prototype.hasOwnProperty.call(node, key);
|
|
3123
|
+
if (present) {
|
|
3124
|
+
segments.push(key);
|
|
3125
|
+
node = node[key];
|
|
3126
|
+
if (node?.model_type === "hemie" && !SYSTEM_SECTIONS.has(segments[0])) building = true;
|
|
3127
|
+
} else if (index === loc.length - 1) {
|
|
3128
|
+
segments.push(key);
|
|
3129
|
+
return { segments, building, arm, missing: type === "missing" };
|
|
3130
|
+
} else arm ?? (arm = { place: pointer(segments), tag: key, hemieInput: node?.model_type !== void 0 });
|
|
3131
|
+
}
|
|
3132
|
+
return { segments, building, arm, missing: false };
|
|
3133
|
+
}
|
|
3134
|
+
function chosenArms(all) {
|
|
3135
|
+
const key = (error) => `${pointer(error.segments)}
|
|
3136
|
+
${error.msg}`;
|
|
3137
|
+
const dropped = /* @__PURE__ */ new Set();
|
|
3138
|
+
for (const [index, error] of all.entries()) {
|
|
3139
|
+
if (error.type !== "extra_forbidden" || error.segments[error.segments.length - 1] !== "model_type") continue;
|
|
3140
|
+
dropped.add(index);
|
|
3141
|
+
const parent = pointer(error.segments.slice(0, -1));
|
|
3142
|
+
for (let previous = index - 1; previous >= 0; previous -= 1) {
|
|
3143
|
+
const candidate = all[previous];
|
|
3144
|
+
if (!pointer(candidate.segments).startsWith(parent) || candidate.arm?.tag !== error.arm?.tag) break;
|
|
3145
|
+
const copyElsewhere = all.some((other, at) => at !== previous && !dropped.has(at) && key(other) === key(candidate));
|
|
3146
|
+
if (!candidate.missing && !copyElsewhere) break;
|
|
3147
|
+
dropped.add(previous);
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3151
|
+
const kept = all.filter((_, index) => !dropped.has(index));
|
|
3152
|
+
const walked = (kept.length ? kept : all).filter((error) => !seen.has(key(error)) && seen.add(key(error)));
|
|
3153
|
+
const arms = /* @__PURE__ */ new Map();
|
|
3154
|
+
for (const { arm } of walked) {
|
|
3155
|
+
if (!arm) continue;
|
|
3156
|
+
const place = arms.get(arm.place) ?? /* @__PURE__ */ new Map();
|
|
3157
|
+
const container = /^(dict|list)\[/.test(arm.tag);
|
|
3158
|
+
const entry = place.get(arm.tag) ?? { count: 0, stated: arm.hemieInput !== container };
|
|
3159
|
+
entry.count += 1;
|
|
3160
|
+
place.set(arm.tag, entry);
|
|
3161
|
+
arms.set(arm.place, place);
|
|
3162
|
+
}
|
|
3163
|
+
const best = new Map([...arms].map(([place, tags]) => [place, [...tags].sort(([, a], [, b]) => Number(b.stated) - Number(a.stated) || a.count - b.count)[0][0]]));
|
|
3164
|
+
return walked.filter(({ arm }) => !arm || best.get(arm.place) === arm.tag);
|
|
3165
|
+
}
|
|
3166
|
+
var STAGE_TEXT = {
|
|
3167
|
+
input_check: "the input check",
|
|
3168
|
+
product_lookup: "the product lookup",
|
|
3169
|
+
existing_building_conversion: "the existing building conversion",
|
|
3170
|
+
preprocessing: "preparation",
|
|
3171
|
+
core: "the simulation",
|
|
3172
|
+
metrics: "the rating calculation",
|
|
3173
|
+
unclassified: "the calculation"
|
|
3174
|
+
};
|
|
3175
|
+
var firstLine = (text) => (text.trim().split("\n")[0] ?? "").replace(/^Value error, /, "").slice(0, MAX_DETAIL_LINE);
|
|
3176
|
+
var SYNTHESISED_FIELDS = /* @__PURE__ */ new Set(["model_type", "reference_building_part", "storey_index", "floorplan_index"]);
|
|
3177
|
+
var CODE_FAULTS = /* @__PURE__ */ new Set(["TypeError", "KeyError", "AttributeError", "IndexError", "NameError", "AssertionError", "UnboundLocalError"]);
|
|
3178
|
+
var VULCAN_FAULT = "Vulcan could not convert this existing building for the EPC calculation. This is a fault in Vulcan, not in your model. Report it to Vulcan support with this model.";
|
|
3179
|
+
var BUILDING_SECTIONS = { Zone: "the building", InfiltrationVentilation: "ventilation and air tightness", ExternalConditions: "shading" };
|
|
3180
|
+
function buildingPlace(segments) {
|
|
3181
|
+
const parts = [];
|
|
3182
|
+
for (let i = 1; i < segments.length - 1; i += 1) {
|
|
3183
|
+
const [key, next] = [segments[i], segments[i + 1]];
|
|
3184
|
+
if (key === "building_parts") {
|
|
3185
|
+
parts.push(`building part ${next}`);
|
|
3186
|
+
i += 1;
|
|
3187
|
+
} else if (/^\d+$/.test(next)) {
|
|
3188
|
+
parts.push(`${key.replace(/_/g, " ").replace(/s$/, "")} ${Number(next) + 1}`);
|
|
3189
|
+
i += 1;
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
return parts.length ? parts.join(", ") : BUILDING_SECTIONS[segments[0]] ?? segments[0];
|
|
3193
|
+
}
|
|
3194
|
+
var readable = (field, text) => text.replace(
|
|
3195
|
+
/^Input should be (.*?)\.?$/,
|
|
3196
|
+
(_, rule) => `${field.replace(/_/g, " ").replace(/^\w/, (c) => c.toUpperCase())} must be ${rule}.`
|
|
3197
|
+
);
|
|
3198
|
+
function targetRunError(report, input, provenance = {}) {
|
|
3199
|
+
const model = JSON.parse(input);
|
|
3200
|
+
const walked = chosenArms((report.errors ?? []).map((error) => ({ ...walk(model, error.loc, error.type), type: error.type, msg: error.msg })));
|
|
3201
|
+
const notes = /* @__PURE__ */ new Set();
|
|
3202
|
+
const issues = [];
|
|
3203
|
+
for (const { segments: converted, building, missing, msg } of walked) {
|
|
3204
|
+
const field = converted[converted.length - 1] ?? "";
|
|
3205
|
+
const segments = building && !SYNTHESISED_FIELDS.has(field) ? authored(converted, provenance) ?? converted : converted;
|
|
3206
|
+
const located = segments !== converted;
|
|
3207
|
+
if (building && SYNTHESISED_FIELDS.has(field)) notes.add(VULCAN_FAULT);
|
|
3208
|
+
else if (building && !located) {
|
|
3209
|
+
const reason = missing ? `${field.replace(/_/g, " ")} is missing` : readable(field, firstLine(msg ?? "")).replace(/\.$/, "");
|
|
3210
|
+
notes.add(`The EPC calculation could not use this existing building: ${reason} (${buildingPlace(segments)}). Check the elements it is built from; if they are correct, report it to Vulcan support.`);
|
|
3211
|
+
} else issues.push(missing ? { path: pointer(segments.slice(0, -1)), keyword: "required", message: `"${field}" is a required property` } : { path: pointer(segments), message: readable(field, firstLine(msg ?? "")) });
|
|
3212
|
+
}
|
|
3213
|
+
const conversionStage = report.stage === "existing_building_conversion";
|
|
3214
|
+
const wall = !walked.length && conversionStage ? wallNamed(model, report.message) : void 0;
|
|
3215
|
+
const wallSource = wall && provenance[wall];
|
|
3216
|
+
if (wallSource && /wall area is less than zero/.test(report.message)) {
|
|
3217
|
+
issues.push({ path: wallSource, message: "The windows, doors and bay in this wall take more than its area. Make them smaller, or check the wall length and height." });
|
|
3218
|
+
} else if (!walked.length && conversionStage) {
|
|
3219
|
+
notes.add(CODE_FAULTS.has(report.kind) ? VULCAN_FAULT : `The EPC calculation could not use this existing building: ${firstLine(report.message)}. Check the elements it is built from; if they are correct, report it to Vulcan support.`);
|
|
3220
|
+
}
|
|
3221
|
+
const cause = notes.size ? "conversion" : issues.length || ["input_check", "product_lookup"].includes(report.stage) ? "input" : "simulation";
|
|
3222
|
+
if (!notes.size && !issues.length) {
|
|
3223
|
+
notes.add(cause === "input" ? `The EPC calculation stopped at ${STAGE_TEXT[report.stage]}: ${firstLine(report.message)}` : `The EPC calculation stopped during ${STAGE_TEXT[report.stage]}: ${firstLine(report.message)}. Report it to Vulcan support with this model if it happens again.`);
|
|
3224
|
+
}
|
|
3225
|
+
const rows = displayBuildErrorRows(issues.map((issue) => ({ source: "schema", ...issue })), () => ({ ownerKey: "" }));
|
|
3226
|
+
const message = [...notes, ...rows.length ? [`The EPC calculation found ${rows.length === 1 ? "an error" : `${rows.length} errors`} in the model. ${rows.map((row) => `${row.location}: ${row.userMessage}`).join(" ")}`] : []].join(" ");
|
|
3227
|
+
return new TargetRunError(message, { stage: report.stage, kind: report.kind, cause, issues, notes: [...notes] }, report.traceback, report);
|
|
3228
|
+
}
|
|
2797
3229
|
|
|
2798
3230
|
// ../hem-target-runtime/src/hem/preparedRun.ts
|
|
3231
|
+
function rustTargetRun(module) {
|
|
3232
|
+
const detailed = typeof module.run_target_input_detailed === "function" ? module.run_target_input_detailed : void 0;
|
|
3233
|
+
return (detailedHeating) => detailedHeating && detailed || module.run_target_input;
|
|
3234
|
+
}
|
|
2799
3235
|
async function executePreparedJobs(manifest2, bundleId, jobId, jobs, execute, write2, progress, check) {
|
|
2800
3236
|
if (manifest2.bundleId !== bundleId) throw new Error("Worker target identity mismatch");
|
|
2801
3237
|
if (!jobs.length) throw new Error("Batch has no prepared jobs");
|
|
@@ -2803,9 +3239,9 @@ async function executePreparedJobs(manifest2, bundleId, jobId, jobs, execute, wr
|
|
|
2803
3239
|
const { resultsKind } = targetWrapper(resolveHemTarget(manifest2.bundleId));
|
|
2804
3240
|
const reservedNames = /* @__PURE__ */ new Set(["model.json", "source.csv", "weather.epw", "target-run.json"]);
|
|
2805
3241
|
for (const job of jobs) {
|
|
2806
|
-
if (
|
|
3242
|
+
if (!isRunOutputPath(job.outputDirectory)) throw new Error(`Invalid run output path: ${JSON.stringify(job.outputDirectory)}`);
|
|
2807
3243
|
if (!job.modes.length || job.modes.some((mode) => !allowedModes.has(mode))) throw new Error("Unsupported calculation mode for selected target");
|
|
2808
|
-
if (job.archiveDirectory && (!job.archiveDirectory.startsWith(`${job.outputDirectory}/`) || job.archiveDirectory
|
|
3244
|
+
if (job.archiveDirectory && (!job.archiveDirectory.startsWith(`${job.outputDirectory}/`) || !isRunOutputPath(job.archiveDirectory))) throw new Error(`Invalid archive path: ${JSON.stringify(job.archiveDirectory)}`);
|
|
2809
3245
|
if (job.heatingProfile) {
|
|
2810
3246
|
parseHeatingProfile(job.heatingProfile);
|
|
2811
3247
|
if (job.modes.length !== 1 || job.modes[0] !== "actual") throw new Error("Heating profiles require actual alone; they are not FHS compliance calculations");
|
|
@@ -2813,13 +3249,15 @@ async function executePreparedJobs(manifest2, bundleId, jobId, jobs, execute, wr
|
|
|
2813
3249
|
}
|
|
2814
3250
|
const scenario = (job) => `Scenario ${job.name}${job.parameterFiles?.length ? ` (${job.parameterFiles.join(", ")})` : ""}`;
|
|
2815
3251
|
const traceback = (error) => error instanceof TargetRunError ? { traceback: error.traceback } : {};
|
|
3252
|
+
const located = (error, job) => error instanceof TargetRunError && error.report && job.provenance ? targetRunError(error.report, job.input, job.provenance) : error;
|
|
2816
3253
|
if (check) {
|
|
2817
3254
|
const failures = [];
|
|
2818
3255
|
for (const [index, job] of jobs.entries()) {
|
|
2819
3256
|
progress(index, jobs.length, "Checking");
|
|
2820
3257
|
try {
|
|
2821
3258
|
await check(job.input);
|
|
2822
|
-
} catch (
|
|
3259
|
+
} catch (caught) {
|
|
3260
|
+
const error = located(caught, job);
|
|
2823
3261
|
failures.push({ job, error, message: error instanceof Error ? error.message : String(error) });
|
|
2824
3262
|
}
|
|
2825
3263
|
}
|
|
@@ -2841,12 +3279,11 @@ async function executePreparedJobs(manifest2, bundleId, jobId, jobs, execute, wr
|
|
|
2841
3279
|
const provenance = { ...job.weather ? { weather: { path: job.weather.path, sha256: job.weather.sha256 } } : {}, ...job.heatingProfile ? { calculationKind: "operating-sensitivity", heatingProfile: job.heatingProfile } : {}, target: manifest2, resultsKind, inputSha256, ...job.preparedBy ? { preparedBy: job.preparedBy } : {}, modes: job.modes, jobId, ...job.startedAt ? { startedAt: job.startedAt } : {}, name: job.name, ...job.warnings?.length ? { warnings: job.warnings } : {} };
|
|
2842
3280
|
try {
|
|
2843
3281
|
await write2(`${archive}/target-run.json`, JSON.stringify({ ...provenance, status: "running" }));
|
|
2844
|
-
if (archive !== job.outputDirectory) await write2(`${job.outputDirectory}/target-run.json`, JSON.stringify({ ...provenance, status: "running", archive }));
|
|
2845
3282
|
await write2(`${archive}/model.json`, job.input);
|
|
2846
3283
|
if (job.sourceCsv) await write2(`${archive}/source.csv`, job.sourceCsv);
|
|
2847
3284
|
if (job.weather) await write2(`${archive}/weather.epw`, job.weather.epw);
|
|
2848
3285
|
progress(index, jobs.length);
|
|
2849
|
-
const files = await execute(job.input, job.modes, job.weather, job.heatingProfile);
|
|
3286
|
+
const files = await execute(job.input, job.modes, job.weather, job.heatingProfile, job.detailedHeating);
|
|
2850
3287
|
const names = Object.keys(files);
|
|
2851
3288
|
if (!names.length) throw new Error("Calculation produced no result files");
|
|
2852
3289
|
for (const [name, content] of Object.entries(files)) {
|
|
@@ -2854,11 +3291,13 @@ async function executePreparedJobs(manifest2, bundleId, jobId, jobs, execute, wr
|
|
|
2854
3291
|
await write2(`${archive}/${name}`, content);
|
|
2855
3292
|
}
|
|
2856
3293
|
if (archive !== job.outputDirectory) {
|
|
3294
|
+
await write2(`${job.outputDirectory}/target-run.json`, JSON.stringify({ ...provenance, status: "running", archive }));
|
|
2857
3295
|
for (const [name, content] of Object.entries(files)) await write2(`${job.outputDirectory}/${name}`, content);
|
|
2858
|
-
await write2(`${job.outputDirectory}/target-run.json`, JSON.stringify({ ...provenance, status: "complete", files: names, archive }));
|
|
2859
3296
|
}
|
|
2860
3297
|
await write2(`${archive}/target-run.json`, JSON.stringify({ ...provenance, status: "complete", files: names }));
|
|
2861
|
-
|
|
3298
|
+
if (archive !== job.outputDirectory) await write2(`${job.outputDirectory}/target-run.json`, JSON.stringify({ ...provenance, status: "complete", files: names, archive }));
|
|
3299
|
+
} catch (caught) {
|
|
3300
|
+
const error = located(caught, job);
|
|
2862
3301
|
const message = error instanceof Error ? error.message : String(error);
|
|
2863
3302
|
await write2(`${archive}/target-run.json`, JSON.stringify({ ...provenance, status: "failed", error: message, ...traceback(error) }));
|
|
2864
3303
|
if (archive !== job.outputDirectory) await write2(`${job.outputDirectory}/target-run.json`, JSON.stringify({ ...provenance, status: "failed", error: message, archive }));
|
|
@@ -2867,12 +3306,29 @@ async function executePreparedJobs(manifest2, bundleId, jobId, jobs, execute, wr
|
|
|
2867
3306
|
}
|
|
2868
3307
|
}
|
|
2869
3308
|
|
|
3309
|
+
// ../hem-target-runtime/src/hem/designHeatLoss.ts
|
|
3310
|
+
var PINNED_WEATHER_NAME = "Bedford";
|
|
3311
|
+
var NO_DESIGN_HEAT_LOSS_EXPORT = "This HEM target build cannot compute the design heat loss. Released targets do not have it yet.";
|
|
3312
|
+
function computeDesignHeatLoss(module, fhsModelJson, weather) {
|
|
3313
|
+
if (typeof module.design_heat_loss !== "function" || typeof module.run_target_stage !== "function") {
|
|
3314
|
+
return { status: "unavailable", reason: NO_DESIGN_HEAT_LOSS_EXPORT };
|
|
3315
|
+
}
|
|
3316
|
+
const stage = JSON.parse(module.run_target_stage(fhsModelJson, "preprocess", weather?.epw));
|
|
3317
|
+
if (stage.status !== "calculated") throw new Error(stage.error ?? "FHS preprocessing failed");
|
|
3318
|
+
const names = Object.keys(stage.files ?? {}).filter((name) => name.endsWith("__preproc.json"));
|
|
3319
|
+
if (names.length !== 1) throw new Error("FHS preprocessing did not return exactly one core input");
|
|
3320
|
+
const coreInput = stage.files[names[0]];
|
|
3321
|
+
const loss = JSON.parse(module.design_heat_loss(coreInput));
|
|
3322
|
+
if (loss.status === "failed") throw new Error(loss.error ?? "Design heat loss failed");
|
|
3323
|
+
return { status: "ready", model: JSON.parse(coreInput), designHeatLoss: { ...loss, weatherName: weather?.name ?? PINNED_WEATHER_NAME } };
|
|
3324
|
+
}
|
|
3325
|
+
|
|
2870
3326
|
// ../hem-target-runtime/src/workers/workerProtocol.ts
|
|
2871
3327
|
var FS_REQUEST_TYPE = "file_system";
|
|
2872
3328
|
var FS_RESPONSE_TYPE = "file_system_response";
|
|
2873
3329
|
|
|
2874
3330
|
// ../hem-target-runtime/src/workers/batchWorkerFileSystemBridge.ts
|
|
2875
|
-
var DEFAULT_ACKNOWLEDGEMENT_TIMEOUT_MS =
|
|
3331
|
+
var DEFAULT_ACKNOWLEDGEMENT_TIMEOUT_MS = 5 * 6e4;
|
|
2876
3332
|
var BatchWorkerFileSystemAcknowledgements = class {
|
|
2877
3333
|
constructor(timeoutMs = DEFAULT_ACKNOWLEDGEMENT_TIMEOUT_MS) {
|
|
2878
3334
|
this.timeoutMs = timeoutMs;
|
|
@@ -2907,9 +3363,10 @@ var BatchWorkerFileSystemAcknowledgements = class {
|
|
|
2907
3363
|
settled: false
|
|
2908
3364
|
};
|
|
2909
3365
|
entry.timer = setTimeout(() => {
|
|
3366
|
+
const limit = this.timeoutMs >= 6e4 ? `${Math.round(this.timeoutMs / 6e4)} minutes` : `${Math.round(this.timeoutMs / 1e3)} seconds`;
|
|
2910
3367
|
this.settleFailure(
|
|
2911
3368
|
request.messageId,
|
|
2912
|
-
|
|
3369
|
+
`${request.operation === "write_file" ? "Saving" : "Deleting"} '${request.path}' did not finish within ${limit}. Check that the workspace folder is still available, then run again.`
|
|
2913
3370
|
);
|
|
2914
3371
|
}, this.timeoutMs);
|
|
2915
3372
|
this.pending.set(request.messageId, entry);
|
|
@@ -2974,6 +3431,7 @@ var runInput;
|
|
|
2974
3431
|
var supportsWeather = false;
|
|
2975
3432
|
var runStage;
|
|
2976
3433
|
var busy = false;
|
|
3434
|
+
var hem;
|
|
2977
3435
|
var acknowledgements = new BatchWorkerFileSystemAcknowledgements();
|
|
2978
3436
|
var send = (message) => self.postMessage(message);
|
|
2979
3437
|
async function write(path, content) {
|
|
@@ -3004,7 +3462,8 @@ async function initialize(bundle) {
|
|
|
3004
3462
|
await module.initialize_rayon_thread_pool(1);
|
|
3005
3463
|
supportsWeather = module.target_weather_protocol_version?.() === 1;
|
|
3006
3464
|
if (typeof module.run_target_input !== "function") throw new Error("Pinned runtime does not support prepared target jobs");
|
|
3007
|
-
runInput = module
|
|
3465
|
+
runInput = rustTargetRun(module);
|
|
3466
|
+
hem = module;
|
|
3008
3467
|
runStage = module.target_heating_profile_protocol_version?.() === 1 && typeof module.run_target_stage === "function" ? module.run_target_stage : void 0;
|
|
3009
3468
|
} finally {
|
|
3010
3469
|
URL.revokeObjectURL(url);
|
|
@@ -3027,7 +3486,7 @@ else self.onmessage = async ({ data }) => {
|
|
|
3027
3486
|
if (data.type === "initialize") await initialize(data.manifest);
|
|
3028
3487
|
else if (data.type === "run_prepared_batch") {
|
|
3029
3488
|
if (!manifest || !runInput) throw new Error("Rust target is not initialized");
|
|
3030
|
-
await executePreparedJobs(manifest, data.targetBundleId, data.jobId, data.jobs, async (input, modes, weather, heatingProfile) => {
|
|
3489
|
+
await executePreparedJobs(manifest, data.targetBundleId, data.jobId, data.jobs, async (input, modes, weather, heatingProfile, detailedHeating) => {
|
|
3031
3490
|
if (heatingProfile) {
|
|
3032
3491
|
if (!runStage) throw new Error("Pinned Rust bundle lacks heating profile protocol 1; rebuild and qualify its adapter");
|
|
3033
3492
|
const stage = async (data2, step) => {
|
|
@@ -3038,11 +3497,15 @@ else self.onmessage = async ({ data }) => {
|
|
|
3038
3497
|
return runHeatingProfile(input, heatingProfile, stage);
|
|
3039
3498
|
}
|
|
3040
3499
|
if (weather && !supportsWeather) throw new Error("Pinned Rust runtime does not implement custom EPW protocol 1; rebuild and qualify its bundle");
|
|
3041
|
-
const
|
|
3500
|
+
const run = runInput(detailedHeating);
|
|
3501
|
+
const result = JSON.parse(weather ? run(input, "model", JSON.stringify(modes), weather.epw) : run(input, "model", JSON.stringify(modes)));
|
|
3042
3502
|
if (result.status !== "calculated") throw new Error(result.error ?? "Rust calculation failed");
|
|
3043
3503
|
return result.files;
|
|
3044
3504
|
}, write, (completed, total) => send({ type: "progress", jobId: data.jobId, progress: { completed, total } }));
|
|
3045
3505
|
send({ type: "complete", jobId: data.jobId, targetBundleId: manifest.bundleId, result: { status: "success", targetBundleId: manifest.bundleId } });
|
|
3506
|
+
} else if (data.type === "design_heat_loss") {
|
|
3507
|
+
if (!manifest || !hem) throw new Error("Rust target is not initialized");
|
|
3508
|
+
send({ type: "design_heat_loss_result", jobId: data.jobId, result: computeDesignHeatLoss(hem, data.input) });
|
|
3046
3509
|
} else throw new Error("Unknown Rust target message");
|
|
3047
3510
|
} catch (error) {
|
|
3048
3511
|
send({ type: data.type === "initialize" ? "init_error" : "error", jobId: data.jobId, error: error instanceof Error ? error.message : String(error) });
|