@roomle/web-sdk 7.0.0-alpha.4 → 7.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/THIRD-PARTY-NOTICES.txt +1 -1
  2. package/lib/ConfiguratorKernel.wasm +0 -0
  3. package/lib/RoomleCore.wasm +0 -0
  4. package/lib/RoomleToolsCore.wasm +0 -0
  5. package/lib/{api-0LgvKoxe.mjs → api-oqNjLSNZ.mjs} +2 -2
  6. package/lib/{api-0LgvKoxe.mjs.map → api-oqNjLSNZ.mjs.map} +1 -1
  7. package/lib/budgeteer.sw-ByZxiRBr.mjs.map +1 -1
  8. package/lib/{configuration-operations-B7uJDX_4.mjs → configuration-operations-Cx7WgZIb.mjs} +3 -3
  9. package/lib/{configuration-operations-B7uJDX_4.mjs.map → configuration-operations-Cx7WgZIb.mjs.map} +1 -1
  10. package/lib/configurator-C0zOzynv.mjs +3 -0
  11. package/lib/configurator-capabilities-DIAH0S8t.mjs +3 -0
  12. package/lib/{configurator-capabilities-o8fQ6Ang.mjs → configurator-capabilities-FnInde4-.mjs} +2 -2
  13. package/lib/{configurator-capabilities-o8fQ6Ang.mjs.map → configurator-capabilities-FnInde4-.mjs.map} +1 -1
  14. package/lib/{configurator-CU7jNdgC.mjs → configurator-tOyOfDMx.mjs} +3 -3
  15. package/lib/{configurator-CU7jNdgC.mjs.map → configurator-tOyOfDMx.mjs.map} +1 -1
  16. package/lib/glb-viewer-B_A_6G4z.mjs +3 -0
  17. package/lib/{glb-viewer-BByRaJ8F.mjs → glb-viewer-Bzphu_lz.mjs} +3 -3
  18. package/lib/{glb-viewer-BByRaJ8F.mjs.map → glb-viewer-Bzphu_lz.mjs.map} +1 -1
  19. package/lib/{homag-intelligence-wHSuuAC4.mjs → homag-intelligence-Bw-mJJwG.mjs} +3 -3
  20. package/lib/{homag-intelligence-wHSuuAC4.mjs.map → homag-intelligence-Bw-mJJwG.mjs.map} +1 -1
  21. package/lib/{material-viewer-beYa7Vpa.mjs → material-viewer-CY49RhiC.mjs} +3 -3
  22. package/lib/{material-viewer-beYa7Vpa.mjs.map → material-viewer-CY49RhiC.mjs.map} +1 -1
  23. package/lib/{packages-BrZdc9Gx.mjs → packages-D8YV3OnS.mjs} +5 -5
  24. package/lib/{packages-BrZdc9Gx.mjs.map → packages-D8YV3OnS.mjs.map} +1 -1
  25. package/lib/planner-ApAenIGG.mjs +3 -0
  26. package/lib/{planner-CSOl3bpc.mjs → planner-B-EAP7Cc.mjs} +3 -3
  27. package/lib/{planner-CSOl3bpc.mjs.map → planner-B-EAP7Cc.mjs.map} +1 -1
  28. package/lib/roomle-headless.d.ts +1 -9
  29. package/lib/roomle-headless.js +7 -7
  30. package/lib/{roomle-sdk-ByoTm5M6.mjs → roomle-sdk-8VVPfbDD.mjs} +19 -16
  31. package/lib/{roomle-sdk-ByoTm5M6.mjs.map → roomle-sdk-8VVPfbDD.mjs.map} +1 -1
  32. package/lib/roomle-sdk.d.ts +1 -9
  33. package/lib/roomle-sdk.js +6 -6
  34. package/lib/{script-loader-DGVS2Wqe.mjs → script-loader-BbtPLVDR.mjs} +2 -2
  35. package/lib/{script-loader-DGVS2Wqe.mjs.map → script-loader-BbtPLVDR.mjs.map} +1 -1
  36. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/package.json +1 -1
  37. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/plannerCoreInterface.d.ts +0 -7
  38. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/plannerCoreInterface.js.map +1 -1
  39. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
  40. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
  41. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
  42. package/lib/{tools-core-eVa8OooA.mjs → tools-core-BdbHH_Vh.mjs} +3 -3
  43. package/lib/{tools-core-eVa8OooA.mjs.map → tools-core-BdbHH_Vh.mjs.map} +1 -1
  44. package/package.json +2 -2
  45. package/sbom.cdx.json +5 -5
  46. package/lib/configurator-c5g9sbhL.mjs +0 -3
  47. package/lib/configurator-capabilities-Cr6BAnms.mjs +0 -3
  48. package/lib/glb-viewer-q6BU-GNu.mjs +0 -3
  49. package/lib/planner-C0ylcrU1.mjs +0 -3
@@ -1,4 +1,4 @@
1
- Third-party software notices for @roomle/web-sdk bef2bd699c2a0af76ae1c05135a4895d108bbd33
1
+ Third-party software notices for @roomle/web-sdk d73f32121cfc78309472db7f88a41a9c099211b4
2
2
  Generated 2026-11-12
3
3
 
4
4
  This product includes the following third-party components.
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
 
2
- import { h as e, m as t } from "./roomle-sdk-ByoTm5M6.mjs";
2
+ import { h as e, m as t } from "./roomle-sdk-8VVPfbDD.mjs";
3
3
  //#region packages/homag-intelligence/src/api.ts
4
4
  var n = {
5
5
  27: "ElectricPlug",
@@ -89,4 +89,4 @@ var n = {
89
89
  //#endregion
90
90
  export { i as t };
91
91
 
92
- //# sourceMappingURL=api-0LgvKoxe.mjs.map
92
+ //# sourceMappingURL=api-oqNjLSNZ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-0LgvKoxe.mjs","names":[],"sources":["../../packages/homag-intelligence/src/api.ts"],"sourcesContent":["import type { RoomDesignerRequests } from './glue-logic';\nimport type { MasterData, PosGroup } from './model/oc-scripts-domain.model';\nimport type {\n ExternalPlanInstallationElement,\n ExternalPlanInstallationElementType,\n ExternalPlanObstacles,\n PlanRoomGeometryMode,\n} from './external-object-api';\nimport { PLAN_ROOM_GEOMETRY_MODE } from './external-object-api';\nimport type { RoomlePlannerType } from '../../typings/external-objects';\nimport {\n HI_CONTEXT_ACTION,\n type LoadExternalObjectOptions,\n} from './external-object-api';\n\n// The kernel levels that classify a plan object as an installation element.\n// Exact levels only: 43, 47, 52 and 55 do not classify.\nconst PLAN_INSTALLATION_ELEMENT_LEVELS: Record<\n number,\n ExternalPlanInstallationElementType\n> = {\n 27: 'ElectricPlug',\n 28: 'WaterConnection',\n};\n\n// + 0 turns IEEE -0 into +0 so serialized values never show -0\nconst round2 = (value: number): number => Math.round(value * 100) / 100 + 0;\n\n// The parts of a kernel plan object the installation-element gathering\n// reads; getPlanObjects is typed any, so the shape is named here.\ninterface PlanObjectInfo {\n level: number;\n hidden: boolean;\n getId(): number;\n getCenter(): { x: number; y: number; z: number };\n}\n\nexport interface ExternalObjectModuleIdMap {\n originalModuleId: string;\n newModuleId: string;\n}\n\nexport class RoomDesignerApi implements RoomDesignerRequests {\n private _roomlePlanner: RoomlePlannerType;\n\n constructor(roomlePlanner: RoomlePlannerType) {\n this._roomlePlanner = roomlePlanner;\n }\n\n public loadMasterData(masterData: MasterData) {\n this._roomlePlanner.loadExternalObjectMasterData(masterData);\n }\n\n public async loadPosGroups(\n posDataJson: PosGroup | PosGroup[],\n options: LoadExternalObjectOptions,\n ): Promise<void> {\n const posDataArray = Array.isArray(posDataJson)\n ? posDataJson\n : [posDataJson];\n await this._roomlePlanner.loadExternalObjectGroups(posDataArray, options);\n }\n\n completelyLoaded(): void {\n this._roomlePlanner.externalObjectsCompletelyLoaded();\n }\n\n public async selectGroup(groupId: string): Promise<void> {\n await this._roomlePlanner.selectExternalObject(\n groupId,\n null,\n HI_CONTEXT_ACTION.ROOM,\n );\n }\n\n public async selectRoot(rootModuleId: string): Promise<void> {\n await this._roomlePlanner.selectExternalObject(\n rootModuleId,\n null,\n HI_CONTEXT_ACTION.ISOLATION,\n );\n }\n\n public async selectModule(\n rootModuleId: string,\n subModuleId: string,\n ): Promise<void> {\n await this._roomlePlanner.selectExternalObject(\n rootModuleId,\n subModuleId,\n HI_CONTEXT_ACTION.ISOLATION,\n );\n }\n\n public openCloseGroup(\n groupOrRootModuleId: string,\n subModuleId: string | null,\n open: boolean,\n animate: boolean,\n ) {\n return Promise.resolve(\n this._roomlePlanner.openOrCloseGeometryOfExternalObject(\n groupOrRootModuleId,\n subModuleId ?? null,\n open,\n animate,\n ),\n );\n }\n\n public deleteGroup(groupId: string): Promise<void> {\n return this._roomlePlanner.removeExternalObject(groupId);\n }\n\n public deleteRootModule(rootModuleId: string): Promise<void> {\n return this._roomlePlanner.removeExternalObject(rootModuleId);\n }\n\n public mergeGroups(groupIds: string[]): Promise<void> {\n return this._roomlePlanner._mergeExternalObjects(groupIds);\n }\n\n public async getPosDataOfAllGroups() {\n const groups =\n (await this._roomlePlanner.getExternalObjectGroups()) as PosGroup[];\n return groups;\n }\n\n public async getRoomInformation(mode?: PlanRoomGeometryMode) {\n const rooms = await this._roomlePlanner.getExternalRoomInformation(\n mode ?? PLAN_ROOM_GEOMETRY_MODE.FLOOR,\n );\n return rooms;\n }\n\n public async getPlanObstacles(): Promise<ExternalPlanObstacles> {\n const obstacles = await this._roomlePlanner._getExternalPlanObstacles();\n const installationElements = await this._gatherInstallationElements();\n return { ...obstacles, installationElements };\n }\n\n // Installation elements are gathered from the live plan objects,\n // independently of the obstacle segments: an element is not lost merely\n // because no usable outline was exported. One entry per placed supply\n // assembly (children included); hidden owners are omitted.\n private async _gatherInstallationElements(): Promise<\n ExternalPlanInstallationElement[]\n > {\n const planInteractionManager =\n await this._roomlePlanner.getPlanInteractionManager();\n const planModelViewHelper =\n await this._roomlePlanner.getPlanModelViewHelper();\n const plan = planInteractionManager.getPlan();\n const planObjects = plan.getPlanObjects() as PlanObjectInfo[];\n const planObjectsById = new Map(\n planObjects.map((planObject) => [planObject.getId(), planObject]),\n );\n const installationElements: ExternalPlanInstallationElement[] = [];\n const typesByOwner = new Map<number, ExternalPlanInstallationElementType>();\n for (const planObject of planObjects) {\n const type = PLAN_INSTALLATION_ELEMENT_LEVELS[planObject.level];\n if (!type) {\n continue;\n }\n const ownerId = planModelViewHelper.getRootPlanObjectId(\n plan,\n planObject.getId(),\n );\n if (typesByOwner.has(ownerId)) {\n // one entry per placed supply assembly, children included\n continue;\n }\n // the owner is the assembly root, itself a plan object; getPlanObject\n // would return its data DTO, which has no getCenter method\n const owner = planObjectsById.get(ownerId) ?? planObject;\n if (owner.hidden) {\n continue;\n }\n typesByOwner.set(ownerId, type);\n const center = owner.getCenter();\n installationElements.push({\n runtimeId: ownerId,\n type,\n position: [round2(center.x), round2(center.z), round2(-center.y)],\n });\n }\n return installationElements;\n }\n\n public async saveExternalObjectSnapshot() {\n return this._roomlePlanner.saveExternalObjectSnapshot();\n }\n\n public async saveCurrentPlanSnapshot() {\n return this._roomlePlanner.saveCurrentPlanSnapshot();\n }\n\n public async renderPosDataImage(posDataJson: object) {\n const posDataArray = Array.isArray(posDataJson)\n ? posDataJson\n : [posDataJson];\n await this._roomlePlanner.renderImagesOfExternalObjectGroup(posDataArray);\n }\n}\n"],"mappings":";;;AAiBA,IAAM,IAGF;CACF,IAAI;CACJ,IAAI;CACL,EAGK,KAAU,MAA0B,KAAK,MAAM,IAAQ,IAAI,GAAG,MAAM,GAgB7D,IAAb,MAA6D;CAG3D,YAAY,GAAkC;AAC5C,OAAK,iBAAiB;;CAGxB,eAAsB,GAAwB;AAC5C,OAAK,eAAe,6BAA6B,EAAW;;CAG9D,MAAa,cACX,GACA,GACe;EACf,IAAM,IAAe,MAAM,QAAQ,EAAY,GAC3C,IACA,CAAC,EAAY;AACjB,QAAM,KAAK,eAAe,yBAAyB,GAAc,EAAQ;;CAG3E,mBAAyB;AACvB,OAAK,eAAe,iCAAiC;;CAGvD,MAAa,YAAY,GAAgC;AACvD,QAAM,KAAK,eAAe,qBACxB,GACA,MACA,EAAkB,KACnB;;CAGH,MAAa,WAAW,GAAqC;AAC3D,QAAM,KAAK,eAAe,qBACxB,GACA,MACA,EAAkB,UACnB;;CAGH,MAAa,aACX,GACA,GACe;AACf,QAAM,KAAK,eAAe,qBACxB,GACA,GACA,EAAkB,UACnB;;CAGH,eACE,GACA,GACA,GACA,GACA;AACA,SA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E;KAAE,EAAO,CAAC,EAAO,EAAE;KAAC;IAClE,CAAC;;AAEJ,SAAO;;CAGT,MAAa,6BAA6B;AACxC,SAAO,KAAK,eAAe,4BAA4B;;CAGzD,MAAa,0BAA0B;AACrC,SAAO,KAAK,eAAe,yBAAyB;;CAGtD,MAAa,mBAAmB,GAAqB;EACnD,IAAM,IAAe,MAAM,QAAQ,EAAY,GAC3C,IACA,CAAC,EAAY;AACjB,QAAM,KAAK,eAAe,kCAAkC,EAAa"}
1
+ {"version":3,"file":"api-oqNjLSNZ.mjs","names":[],"sources":["../../packages/homag-intelligence/src/api.ts"],"sourcesContent":["import type { RoomDesignerRequests } from './glue-logic';\nimport type { MasterData, PosGroup } from './model/oc-scripts-domain.model';\nimport type {\n ExternalPlanInstallationElement,\n ExternalPlanInstallationElementType,\n ExternalPlanObstacles,\n PlanRoomGeometryMode,\n} from './external-object-api';\nimport { PLAN_ROOM_GEOMETRY_MODE } from './external-object-api';\nimport type { RoomlePlannerType } from '../../typings/external-objects';\nimport {\n HI_CONTEXT_ACTION,\n type LoadExternalObjectOptions,\n} from './external-object-api';\n\n// The kernel levels that classify a plan object as an installation element.\n// Exact levels only: 43, 47, 52 and 55 do not classify.\nconst PLAN_INSTALLATION_ELEMENT_LEVELS: Record<\n number,\n ExternalPlanInstallationElementType\n> = {\n 27: 'ElectricPlug',\n 28: 'WaterConnection',\n};\n\n// + 0 turns IEEE -0 into +0 so serialized values never show -0\nconst round2 = (value: number): number => Math.round(value * 100) / 100 + 0;\n\n// The parts of a kernel plan object the installation-element gathering\n// reads; getPlanObjects is typed any, so the shape is named here.\ninterface PlanObjectInfo {\n level: number;\n hidden: boolean;\n getId(): number;\n getCenter(): { x: number; y: number; z: number };\n}\n\nexport interface ExternalObjectModuleIdMap {\n originalModuleId: string;\n newModuleId: string;\n}\n\nexport class RoomDesignerApi implements RoomDesignerRequests {\n private _roomlePlanner: RoomlePlannerType;\n\n constructor(roomlePlanner: RoomlePlannerType) {\n this._roomlePlanner = roomlePlanner;\n }\n\n public loadMasterData(masterData: MasterData) {\n this._roomlePlanner.loadExternalObjectMasterData(masterData);\n }\n\n public async loadPosGroups(\n posDataJson: PosGroup | PosGroup[],\n options: LoadExternalObjectOptions,\n ): Promise<void> {\n const posDataArray = Array.isArray(posDataJson)\n ? posDataJson\n : [posDataJson];\n await this._roomlePlanner.loadExternalObjectGroups(posDataArray, options);\n }\n\n completelyLoaded(): void {\n this._roomlePlanner.externalObjectsCompletelyLoaded();\n }\n\n public async selectGroup(groupId: string): Promise<void> {\n await this._roomlePlanner.selectExternalObject(\n groupId,\n null,\n HI_CONTEXT_ACTION.ROOM,\n );\n }\n\n public async selectRoot(rootModuleId: string): Promise<void> {\n await this._roomlePlanner.selectExternalObject(\n rootModuleId,\n null,\n HI_CONTEXT_ACTION.ISOLATION,\n );\n }\n\n public async selectModule(\n rootModuleId: string,\n subModuleId: string,\n ): Promise<void> {\n await this._roomlePlanner.selectExternalObject(\n rootModuleId,\n subModuleId,\n HI_CONTEXT_ACTION.ISOLATION,\n );\n }\n\n public openCloseGroup(\n groupOrRootModuleId: string,\n subModuleId: string | null,\n open: boolean,\n animate: boolean,\n ) {\n return Promise.resolve(\n this._roomlePlanner.openOrCloseGeometryOfExternalObject(\n groupOrRootModuleId,\n subModuleId ?? null,\n open,\n animate,\n ),\n );\n }\n\n public deleteGroup(groupId: string): Promise<void> {\n return this._roomlePlanner.removeExternalObject(groupId);\n }\n\n public deleteRootModule(rootModuleId: string): Promise<void> {\n return this._roomlePlanner.removeExternalObject(rootModuleId);\n }\n\n public mergeGroups(groupIds: string[]): Promise<void> {\n return this._roomlePlanner._mergeExternalObjects(groupIds);\n }\n\n public async getPosDataOfAllGroups() {\n const groups =\n (await this._roomlePlanner.getExternalObjectGroups()) as PosGroup[];\n return groups;\n }\n\n public async getRoomInformation(mode?: PlanRoomGeometryMode) {\n const rooms = await this._roomlePlanner.getExternalRoomInformation(\n mode ?? PLAN_ROOM_GEOMETRY_MODE.FLOOR,\n );\n return rooms;\n }\n\n public async getPlanObstacles(): Promise<ExternalPlanObstacles> {\n const obstacles = await this._roomlePlanner._getExternalPlanObstacles();\n const installationElements = await this._gatherInstallationElements();\n return { ...obstacles, installationElements };\n }\n\n // Installation elements are gathered from the live plan objects,\n // independently of the obstacle segments: an element is not lost merely\n // because no usable outline was exported. One entry per placed supply\n // assembly (children included); hidden owners are omitted.\n private async _gatherInstallationElements(): Promise<\n ExternalPlanInstallationElement[]\n > {\n const planInteractionManager =\n await this._roomlePlanner.getPlanInteractionManager();\n const planModelViewHelper =\n await this._roomlePlanner.getPlanModelViewHelper();\n const plan = planInteractionManager.getPlan();\n const planObjects = plan.getPlanObjects() as PlanObjectInfo[];\n const planObjectsById = new Map(\n planObjects.map((planObject) => [planObject.getId(), planObject]),\n );\n const installationElements: ExternalPlanInstallationElement[] = [];\n const typesByOwner = new Map<number, ExternalPlanInstallationElementType>();\n for (const planObject of planObjects) {\n const type = PLAN_INSTALLATION_ELEMENT_LEVELS[planObject.level];\n if (!type) {\n continue;\n }\n const ownerId = planModelViewHelper.getRootPlanObjectId(\n plan,\n planObject.getId(),\n );\n if (typesByOwner.has(ownerId)) {\n // one entry per placed supply assembly, children included\n continue;\n }\n // the owner is the assembly root, itself a plan object; getPlanObject\n // would return its data DTO, which has no getCenter method\n const owner = planObjectsById.get(ownerId) ?? planObject;\n if (owner.hidden) {\n continue;\n }\n typesByOwner.set(ownerId, type);\n const center = owner.getCenter();\n installationElements.push({\n runtimeId: ownerId,\n type,\n position: [round2(center.x), round2(center.z), round2(-center.y)],\n });\n }\n return installationElements;\n }\n\n public async saveExternalObjectSnapshot() {\n return this._roomlePlanner.saveExternalObjectSnapshot();\n }\n\n public async saveCurrentPlanSnapshot() {\n return this._roomlePlanner.saveCurrentPlanSnapshot();\n }\n\n public async renderPosDataImage(posDataJson: object) {\n const posDataArray = Array.isArray(posDataJson)\n ? posDataJson\n : [posDataJson];\n await this._roomlePlanner.renderImagesOfExternalObjectGroup(posDataAr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AG;GAAW;GAAsB;;CAO/C,MAAc,8BAEZ;EACA,IAAM,IACJ,MAAM,KAAK,eAAe,2BAA2B,EACjD,IACJ,MAAM,KAAK,eAAe,wBAAwB,EAC9C,IAAO,EAAuB,SAAS,EACvC,IAAc,EAAK,gBAAgB,EACnC,IAAkB,IAAI,IAC1B,EAAY,KAAK,MAAe,CAAC,EAAW,OAAO,EAAE,EAAW,CAAC,CAClE,EACK,IAA0D,EAAE,EAC5D,oBAAe,IAAI,KAAkD;AAC3E,OAAK,IAAM,KAAc,GAAa;GACpC,IAAM,IAAO,EAAiC,EAAW;AACzD,OAAI,CAAC,EACH;GAEF,IAAM,IAAU,EAAoB,oBAClC,GACA,EAAW,OAAO,CACnB;AACD,OAAI,EAAa,IAAI,EAAQ,CAE3B;GAIF,IAAM,IAAQ,EAAgB,IAAI,EAAQ,IAAI;AAC9C,OAAI,EAAM,OACR;AAEF,KAAa,IAAI,GAAS,EAAK;GAC/B,IAAM,IAAS,EAAM,WAAW;AAChC,KAAqB,KAAK;IACxB,WAAW;IACX;IACA,UAAU;KAAC,EAAO,EAAO,EAAE;KAAE,EAAO,EAAO,EAAE;KAAE,EAAO,CAAC,EAAO,EAAE;KAAC;IAClE,CAAC;;AAEJ,SAAO;;CAGT,MAAa,6BAA6B;AACxC,SAAO,KAAK,eAAe,4BAA4B;;CAGzD,MAAa,0BAA0B;AACrC,SAAO,KAAK,eAAe,yBAAyB;;CAGtD,MAAa,mBAAmB,GAAqB;EACnD,IAAM,IAAe,MAAM,QAAQ,EAAY,GAC3C,IACA,CAAC,EAAY;AACjB,QAAM,KAAK,eAAe,kCAAkC,EAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"budgeteer.sw-ByZxiRBr.mjs","names":[],"sources":["../../packages/workers/generated/budgeteer.sw.js?no-inline?url"],"sourcesContent":["export default \"__VITE_ASSET__ykb1zIozoJBMq4UvQnlhcQ__\""],"mappings":";;AAAA,IAAA,IAAe,KAAA,IAAA,IAAA,mBAAA,OAAA,KAAA,IAAA,CAAA"}
1
+ {"version":3,"file":"budgeteer.sw-ByZxiRBr.mjs","names":[],"sources":["../../packages/workers/generated/budgeteer.sw.js?no-inline?url"],"sourcesContent":["export default \"__VITE_ASSET__dJ$ULFcuzX43djbIEsCZPw__\""],"mappings":";;AAAA,IAAA,IAAe,KAAA,IAAA,IAAA,mBAAA,OAAA,KAAA,IAAA,CAAA"}
@@ -1,7 +1,7 @@
1
1
 
2
- import { B as e, j as t } from "./roomle-sdk-ByoTm5M6.mjs";
2
+ import { B as e, j as t } from "./roomle-sdk-8VVPfbDD.mjs";
3
3
  import { i as n, r } from "./configuration-operation-schemas-Q4gAd-KO.mjs";
4
- import { a as i, c as a, i as o, n as s, o as c, r as l, s as u, t as d } from "./configurator-capabilities-o8fQ6Ang.mjs";
4
+ import { a as i, c as a, i as o, n as s, o as c, r as l, s as u, t as d } from "./configurator-capabilities-FnInde4-.mjs";
5
5
  //#region packages/common-core/src/mcp-api/configuration-operations.ts
6
6
  var f = Object.keys(n), p = Object.keys(r), m = (e) => JSON.parse(JSON.stringify(e)), h = (e) => e.map((e) => m({
7
7
  ...e,
@@ -382,4 +382,4 @@ var f = Object.keys(n), p = Object.keys(r), m = (e) => JSON.parse(JSON.stringify
382
382
  //#endregion
383
383
  export { P as executeConfigurationOperation, N as queryConfigurationOperation };
384
384
 
385
- //# sourceMappingURL=configuration-operations-B7uJDX_4.mjs.map
385
+ //# sourceMappingURL=configuration-operations-Cx7WgZIb.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"configuration-operations-B7uJDX_4.mjs","names":[],"sources":["../../packages/common-core/src/mcp-api/configuration-operations.ts"],"sourcesContent":["import type { z } from 'zod';\nimport {\n configurationOperationSchemas,\n configurationQuerySchemas,\n type ValidatedOperation,\n type ValidatedQuery,\n} from './configuration-operation-schemas';\nimport type ConfiguratorKernelAccess from '../configurator-kernel-access';\nimport type ConfiguratorContext from '../webgl/configurator-context';\nimport type { RapiAccess } from '../rapi-access';\nimport { BASE_CONTEXT } from '../main';\nimport type {\n ConfiguratorKernelClass,\n KernelComponent,\n KernelDockPairQuerySource,\n KernelParameter,\n KernelParameterGroup,\n PossibleChildPreviewElement,\n} from '../../../typings/kernel';\nimport { ANIMATION_PARAMETER_PREFIX } from '../../../configurator-core/src/utils/animation/animation-value-map';\nimport { collectConfiguratorCapabilities } from './configurator-capabilities';\nimport {\n configurationComponentIds,\n fetchComponentLlmData,\n readComponentLlmData,\n withParameterLlmData,\n} from './component-llm-data';\nimport {\n collectProductFamily,\n productContextOf,\n readComponentDefinition,\n} from './component-models';\nimport type {\n CapabilityJsonObject,\n ConfiguratorCapabilityContext,\n} from './configurator-capabilities-types';\nimport type {\n ConfigurationOperationHistoryState,\n ConfigurationOperationDockingChild,\n ConfigurationOperationExecutePayload,\n ConfigurationOperationHost,\n ConfigurationOperationName,\n ConfigurationOperationQueryPayload,\n ConfigurationOperationQueryResult,\n ConfigurationOperationQueryType,\n ConfigurationOperationResult,\n} from './configuration-operations-types';\n\nconst QUERY_TYPES = Object.keys(configurationQuerySchemas);\nconst EXECUTE_TYPES = Object.keys(configurationOperationSchemas);\n\ntype OperationKind = 'query' | 'operation';\ntype OperationKindLabel = 'Query' | 'Operation';\n\nconst detach = <T>(value: T): T => JSON.parse(JSON.stringify(value));\nconst detachParameters = (parameters: KernelParameter[]): KernelParameter[] =>\n parameters.map((parameter) =>\n detach({\n ...parameter,\n ...(parameter.viewType\n ? { viewType: { value: parameter.viewType.value } }\n : {}),\n }),\n );\n\nconst invalidPayload = (\n kind: OperationKind,\n name: string,\n reason: string,\n): Error => new Error(`Invalid payload for ${kind} '${name}': ${reason}`);\n\nconst parsePayload = <Schema extends z.ZodType>(\n schema: Schema,\n kind: OperationKind,\n name: string,\n payload: unknown,\n): z.output<Schema> => {\n const parsed = schema.safeParse(payload ?? {});\n if (!parsed.success) {\n throw invalidPayload(kind, name, parsed.error.issues[0].message);\n }\n return parsed.data;\n};\n\ninterface OperationSession {\n context: ConfiguratorContext;\n access: ConfiguratorKernelAccess;\n rapi: RapiAccess;\n host: ConfigurationOperationHost;\n kernel: ConfiguratorKernelClass;\n captured: ConfiguratorCapabilityContext;\n assertFresh: () => void;\n}\n\nconst parseConfigurationJson = (value: string): CapabilityJsonObject => {\n try {\n const parsed: unknown = JSON.parse(value);\n if (\n parsed !== null &&\n typeof parsed === 'object' &&\n !Array.isArray(parsed)\n ) {\n return parsed as CapabilityJsonObject;\n }\n } catch {\n /* falls through to the actionable error below */\n }\n throw new Error('Missing or invalid configuration JSON');\n};\n\nconst rootComponentIdOf = (configuration: string): string | undefined => {\n const parsed = parseConfigurationJson(configuration);\n return typeof parsed['componentId'] === 'string' && parsed['componentId']\n ? (parsed['componentId'] as string)\n : undefined;\n};\n\nconst preloadAssemblyRootDefinition = async (\n session: OperationSession,\n kind: OperationKind,\n name: string,\n configuration: string,\n): Promise<void> => {\n const rootComponentId = rootComponentIdOf(configuration);\n if (!rootComponentId) {\n return;\n }\n const record = await session.rapi.getComponent(rootComponentId);\n if (!record.configuration) {\n throw invalidPayload(\n kind,\n name,\n `the definition of root component '${rootComponentId}' has no configuration`,\n );\n }\n session.access.loadComponentIntoKernel(record.configuration, rootComponentId);\n};\n\nconst requireActiveComponent = (\n session: OperationSession,\n kind: OperationKindLabel,\n name: string,\n runtimeId: number,\n): KernelComponent => {\n let component: KernelComponent | undefined;\n try {\n component = session.kernel.getComponent(runtimeId);\n } catch {\n component = undefined;\n }\n if (!component) {\n throw new Error(\n `${kind} '${name}': no component with runtime id ${runtimeId} in the active configuration`,\n );\n }\n if (component.objectId !== session.captured.configurationRuntimeId) {\n throw new Error(\n `${kind} '${name}': component with runtime id ${runtimeId} is not part of the active configuration`,\n );\n }\n return component;\n};\n\nconst resolveDockingChildSource = async (\n session: OperationSession,\n kind: OperationKind,\n name: string,\n child: ConfigurationOperationDockingChild,\n): Promise<Exclude<KernelDockPairQuerySource, { runtimeId: number }>> => {\n if ('componentId' in child) {\n const record = await session.rapi.getComponent(child.componentId);\n if (!record.configuration) {\n throw invalidPayload(\n kind,\n name,\n `component '${child.componentId}' has no configuration`,\n );\n }\n return {\n componentId: child.componentId,\n configuration: record.configuration,\n };\n }\n if ('itemId' in child) {\n const item = await session.rapi.getItem(child.itemId);\n if (!item.configuration) {\n throw invalidPayload(\n kind,\n name,\n `item '${child.itemId}' has no configuration`,\n );\n }\n await preloadAssemblyRootDefinition(\n session,\n kind,\n name,\n item.configuration,\n );\n return { configuration: item.configuration };\n }\n await preloadAssemblyRootDefinition(session, kind, name, child.configuration);\n return { configuration: child.configuration };\n};\n\nconst previewElementOf = (\n child: ConfigurationOperationDockingChild,\n configuration: string,\n): PossibleChildPreviewElement => {\n if ('componentId' in child) {\n return {\n id: child.componentId,\n configuration,\n isComponent: true,\n isItem: false,\n };\n }\n return {\n id:\n 'itemId' in child ? child.itemId : rootComponentIdOf(configuration) ?? '',\n configuration,\n isComponent: false,\n isItem: true,\n };\n};\n\nconst runQuery = async (\n session: OperationSession,\n query: ValidatedQuery,\n): Promise<ConfigurationOperationQueryResult> => {\n const { captured, assertFresh } = session;\n switch (query.type) {\n case 'capabilities': {\n const capabilities = await collectConfiguratorCapabilities(\n session.context,\n session.access,\n session.rapi,\n query.include,\n );\n return {\n type: query.type,\n context: capabilities.context,\n capabilities,\n };\n }\n case 'configuration': {\n const configuration = parseConfigurationJson(\n session.access.getSerializedConfiguration(\n captured.configurationRuntimeId,\n ),\n );\n assertFresh();\n return {\n type: query.type,\n context: captured,\n configuration: detach(configuration),\n configurationHash: captured.configurationHash,\n };\n }\n case 'componentParameters': {\n const component = requireActiveComponent(\n session,\n 'Query',\n query.type,\n query.runtimeId,\n );\n const componentId = session.kernel.getComponentId(query.runtimeId);\n const groups = detach(component.parameterGroups);\n const [kernelParameters, llmData] = await Promise.all([\n session.access.getComponentParameters(query.runtimeId),\n readComponentLlmData(session.rapi, componentId),\n ]);\n const parameters = withParameterLlmData(\n detachParameters(kernelParameters),\n [llmData],\n );\n assertFresh();\n return {\n type: query.type,\n context: captured,\n runtimeId: query.runtimeId,\n componentId,\n groups,\n parameters,\n };\n }\n case 'globalParameters': {\n const rootAsGlobal = session.context.rootComponentParametersAsGlobal;\n const globalDefinition = rootAsGlobal\n ? session.kernel.getComponent(captured.rootRuntimeId)\n : session.kernel.getPlanObject(captured.configurationRuntimeId);\n const groups = detach(\n (globalDefinition.parameterGroups ?? []) as KernelParameterGroup[],\n );\n const componentIds = configurationComponentIds(\n parseConfigurationJson(\n session.access.getSerializedConfiguration(\n captured.configurationRuntimeId,\n ),\n ),\n );\n const [kernelParameters, llmData] = await Promise.all([\n session.access.getGlobalParameters(\n captured.configurationRuntimeId,\n rootAsGlobal,\n ),\n Promise.all(\n componentIds.map((id) => readComponentLlmData(session.rapi, id)),\n ),\n ]);\n const parameters = withParameterLlmData(\n detachParameters(kernelParameters),\n llmData,\n );\n assertFresh();\n return {\n type: query.type,\n context: captured,\n scope: rootAsGlobal ? 'rootComponent' : 'planObject',\n groups,\n parameters,\n };\n }\n case 'possibleChildren': {\n const runtimeId = query.runtimeId ?? captured.configurationRuntimeId;\n if (query.runtimeId !== undefined) {\n requireActiveComponent(session, 'Query', query.type, query.runtimeId);\n }\n const children =\n query.runtimeId !== undefined\n ? await session.host.getChildrenOfPlanComponent(\n query.runtimeId,\n true,\n true,\n )\n : await session.host.getChildrenOfPlanObject(true, true);\n if (!children) {\n throw new Error(\n 'Configuration or selection changed while reading capabilities; read again',\n );\n }\n assertFresh();\n return {\n type: query.type,\n context: captured,\n runtimeId,\n tags: detach(children.tags),\n defaultChild: children.defaultChild\n ? detach(children.defaultChild)\n : undefined,\n };\n }\n case 'dockingPositions': {\n const source = await resolveDockingChildSource(\n session,\n 'query',\n query.type,\n query.child,\n );\n const dockPairs = session.access.getDockPairs(\n captured.configurationRuntimeId,\n source,\n query.allowInsertInBetween,\n );\n assertFresh();\n return {\n type: query.type,\n context: captured,\n allowInsertInBetween: query.allowInsertInBetween,\n dockPairs: detach(dockPairs),\n };\n }\n case 'componentDockingPositions': {\n requireActiveComponent(session, 'Query', query.type, query.runtimeId);\n const dockPairs = session.access.getDockPairs(\n captured.configurationRuntimeId,\n { runtimeId: query.runtimeId },\n query.allowInsertInBetween,\n );\n assertFresh();\n return {\n type: query.type,\n context: captured,\n runtimeId: query.runtimeId,\n allowInsertInBetween: query.allowInsertInBetween,\n dockPairs: detach(dockPairs),\n };\n }\n case 'deleteImpact': {\n const deletable = session.access.isComponentDeletable(\n query.runtimeId,\n query.redockChildrenToParent,\n );\n const componentsDeleted =\n session.access.determineComponentsThatWillBeDeleted(\n query.runtimeId,\n query.redockChildrenToParent,\n );\n assertFresh();\n return {\n type: query.type,\n context: captured,\n runtimeId: query.runtimeId,\n redockChildrenToParent: query.redockChildrenToParent,\n deletable,\n componentsDeleted: detach(componentsDeleted),\n };\n }\n case 'componentSkill': {\n const { skills } = await fetchComponentLlmData(\n session.rapi,\n query.componentId,\n );\n const skill = skills.find(({ name }) => name === query.name);\n if (!skill) {\n const available = skills.length\n ? `its skills are ${skills.map(({ name }) => name).join(', ')}`\n : 'it has no skills';\n throw new Error(\n `Query 'componentSkill': component '${query.componentId}' has no skill '${query.name}'; ${available}`,\n );\n }\n assertFresh();\n return {\n type: query.type,\n context: captured,\n componentId: query.componentId,\n ...skill,\n };\n }\n case 'productContext': {\n const configuration = parseConfigurationJson(\n session.access.getSerializedConfiguration(\n captured.configurationRuntimeId,\n ),\n );\n const unresolved: Array<{\n resourceType: 'component' | 'item';\n id: string;\n reason: string;\n }> = [];\n const family = await collectProductFamily(\n session.rapi,\n configuration,\n (resourceType, id, error) =>\n unresolved.push({\n resourceType,\n id,\n reason: error instanceof Error ? error.message : String(error),\n }),\n [],\n );\n assertFresh();\n return {\n type: query.type,\n context: captured,\n product: productContextOf(family, captured.rootComponentId),\n unresolved,\n };\n }\n case 'componentDefinition': {\n let component;\n try {\n component = await readComponentDefinition(\n session.rapi,\n query.componentId,\n );\n } catch (error) {\n throw new Error(\n `Query 'componentDefinition': component '${query.componentId}' could not be read: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n assertFresh();\n return { type: query.type, context: captured, component };\n }\n }\n};\n\nconst runOperation = async (\n session: OperationSession,\n operation: ValidatedOperation,\n) => {\n const { captured, assertFresh } = session;\n const resultHash = (): string =>\n session.access.getCurrentConfigurationHash(\n session.context.configurationRuntimeId,\n );\n switch (operation.type) {\n case 'changeComponentParameter': {\n requireActiveComponent(\n session,\n 'Operation',\n operation.type,\n operation.runtimeId,\n );\n if (operation.key.startsWith(ANIMATION_PARAMETER_PREFIX)) {\n throw new Error(\n `Operation 'changeComponentParameter': parameter keys starting with '${ANIMATION_PARAMETER_PREFIX}' are reserved for the animation system`,\n );\n }\n const parameters = await session.access.getComponentParameters(\n operation.runtimeId,\n );\n const parameter = parameters.find((entry) => entry.key === operation.key);\n if (!parameter) {\n throw new Error(\n `Operation 'changeComponentParameter': the component with runtime id ${operation.runtimeId} has no parameter '${operation.key}'`,\n );\n }\n if (!parameter.enabled) {\n throw new Error(\n `Operation 'changeComponentParameter': the parameter '${operation.key}' of the component with runtime id ${operation.runtimeId} is disabled`,\n );\n }\n assertFresh();\n session.access.setComponentParameter(\n operation.runtimeId,\n operation.key,\n operation.value,\n );\n session.access.updateSelectedComponentDependencies(\n captured.configurationRuntimeId,\n );\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n runtimeId: operation.runtimeId,\n key: operation.key,\n value: operation.value,\n };\n }\n case 'changeGlobalParameter': {\n const rootAsGlobal = session.context.rootComponentParametersAsGlobal;\n const parameters = await session.access.getGlobalParameters(\n captured.configurationRuntimeId,\n rootAsGlobal,\n );\n const parameter = parameters.find((entry) => entry.key === operation.key);\n if (!parameter) {\n throw new Error(\n `Operation 'changeGlobalParameter': the active configuration has no global parameter '${operation.key}'`,\n );\n }\n if (!parameter.enabled) {\n throw new Error(\n `Operation 'changeGlobalParameter': the global parameter '${operation.key}' is disabled`,\n );\n }\n assertFresh();\n if (rootAsGlobal) {\n session.access.setComponentParameter(\n captured.rootRuntimeId,\n operation.key,\n operation.value,\n );\n } else {\n session.access.setPlanObjectParameter(\n captured.configurationRuntimeId,\n operation.key,\n operation.value,\n );\n }\n session.access.updateSelectedComponentDependencies(\n captured.configurationRuntimeId,\n );\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n scope: rootAsGlobal ? 'rootComponent' : 'planObject',\n key: operation.key,\n value: operation.value,\n };\n }\n case 'previewDockings': {\n const source = await resolveDockingChildSource(\n session,\n 'operation',\n operation.type,\n operation.child,\n );\n assertFresh();\n const dockPairs = session.access.getDockPairs(\n captured.configurationRuntimeId,\n source,\n session.access.allowInsertingBetweenWhenDocking,\n );\n session.host\n .getSceneManager()\n .requestDockingsPreview(\n true,\n previewElementOf(operation.child, source.configuration),\n );\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n dockPairCount: dockPairs.length,\n };\n }\n case 'dockComponent': {\n const source = await resolveDockingChildSource(\n session,\n 'operation',\n operation.type,\n operation.child,\n );\n assertFresh();\n const runtimeId = session.access.dockNewComponent(\n captured.configurationRuntimeId,\n source,\n {\n parentId: operation.parentId,\n parentDockId: operation.parentDockId,\n position: operation.position,\n insertInBetween: operation.insertInBetween,\n },\n );\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n runtimeId,\n };\n }\n case 'dragComponent': {\n requireActiveComponent(\n session,\n 'Operation',\n operation.type,\n operation.runtimeId,\n );\n requireActiveComponent(\n session,\n 'Operation',\n operation.type,\n operation.parentId,\n );\n assertFresh();\n session.access.moveComponent(\n captured.configurationRuntimeId,\n operation.runtimeId,\n {\n parentId: operation.parentId,\n parentDockId: operation.parentDockId,\n childDockId: operation.childDockId,\n position: operation.position,\n insertInBetween: operation.insertInBetween,\n },\n );\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n runtimeId: operation.runtimeId,\n };\n }\n case 'deleteComponent': {\n requireActiveComponent(\n session,\n 'Operation',\n operation.type,\n operation.runtimeId,\n );\n if (\n !session.access.isComponentDeletable(\n operation.runtimeId,\n operation.redockChildrenToParent,\n )\n ) {\n throw new Error(\n `Operation 'deleteComponent': the component with runtime id ${operation.runtimeId} is not deletable with redockChildrenToParent ${operation.redockChildrenToParent}`,\n );\n }\n const componentsDeleted =\n session.access.determineComponentsThatWillBeDeleted(\n operation.runtimeId,\n operation.redockChildrenToParent,\n );\n assertFresh();\n session.access.deleteComponent(\n operation.runtimeId,\n operation.redockChildrenToParent,\n );\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n runtimeId: operation.runtimeId,\n redockChildrenToParent: operation.redockChildrenToParent,\n componentsDeleted: detach(componentsDeleted),\n };\n }\n case 'replaceComponent': {\n requireActiveComponent(\n session,\n 'Operation',\n operation.type,\n operation.runtimeId,\n );\n const source = await resolveDockingChildSource(\n session,\n 'operation',\n operation.type,\n operation.child,\n );\n assertFresh();\n const replaced = session.access.replaceComponent(\n captured.configurationRuntimeId,\n operation.runtimeId,\n source,\n );\n if (!replaced) {\n throw new Error(\n `Operation 'replaceComponent': the configurator did not put the child in the place of the component with runtime id ${operation.runtimeId}; the configuration is unchanged. Read the configuration again before the next operation: its runtime ids can have changed`,\n );\n }\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n runtimeId: replaced.runtimeId,\n componentsDeleted: detach(replaced.componentsDeleted),\n };\n }\n case 'swapComponents': {\n const [firstRuntimeId, secondRuntimeId] = operation.runtimeIds;\n for (const runtimeId of [firstRuntimeId, secondRuntimeId]) {\n requireActiveComponent(session, 'Operation', operation.type, runtimeId);\n }\n assertFresh();\n session.access.swapComponents(\n captured.configurationRuntimeId,\n firstRuntimeId,\n secondRuntimeId,\n );\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n runtimeIds: [firstRuntimeId, secondRuntimeId],\n };\n }\n case 'loadConfiguration': {\n await session.host\n .getSceneManager()\n .reloadConfiguration(operation.configuration);\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n };\n }\n case 'undo': {\n await session.host.undo();\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n };\n }\n case 'redo': {\n await session.host.redo();\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n };\n }\n }\n};\n\nconst STALE_QUERY_MESSAGE =\n 'Configuration or selection changed while reading capabilities; read again';\nconst STALE_OPERATION_MESSAGE =\n 'Configuration or selection changed while executing the operation; the operation was not applied';\n\ninterface QueuedConfiguration {\n pending: number;\n configurationRuntimeId: number;\n}\n\nlet operationChain: Promise<unknown> = Promise.resolve();\nconst queuedConfigurations = new WeakMap<\n ConfiguratorContext,\n QueuedConfiguration\n>();\n\nconst enqueue = <T>(\n context: ConfiguratorContext,\n staleMessage: string,\n work: (queued: QueuedConfiguration) => Promise<T>,\n): Promise<T> => {\n const current = queuedConfigurations.get(context);\n const queued = current?.pending\n ? current\n : { pending: 0, configurationRuntimeId: context.configurationRuntimeId };\n queuedConfigurations.set(context, queued);\n queued.pending += 1;\n const run = operationChain.then(() => {\n if (context.configurationRuntimeId !== queued.configurationRuntimeId) {\n throw new Error(staleMessage);\n }\n return work(queued);\n });\n operationChain = run\n .finally(() => {\n queued.pending -= 1;\n })\n .catch(() => undefined);\n return run;\n};\n\nconst captureContext = (\n context: ConfiguratorContext,\n kernel: ConfiguratorKernelClass,\n access: ConfiguratorKernelAccess,\n): ConfiguratorCapabilityContext => {\n if (\n context.baseContext !== BASE_CONTEXT.CONFIGURATOR ||\n !context.configurationRuntimeId\n ) {\n throw new Error(\n 'Load a configuration or enter planner isolation before reading configurator capabilities',\n );\n }\n if (kernel.isExternalPlanObject(context.configurationRuntimeId)) {\n throw new Error(\n 'Use the HI external-object API to read capabilities of an external configuration',\n );\n }\n const rootRuntimeId = kernel.getRootPlanComponentIdFromObjectId(\n context.configurationRuntimeId,\n );\n if (!rootRuntimeId) {\n throw new Error(\n 'No active root component; load a configuration before reading capabilities',\n );\n }\n return {\n configurationRuntimeId: context.configurationRuntimeId,\n rootRuntimeId,\n rootComponentId: kernel.getComponentId(rootRuntimeId),\n selectedRuntimeIds: [...context.selectedRuntimeComponentIds],\n configurationHash: access.getCurrentConfigurationHash(\n context.configurationRuntimeId,\n ),\n };\n};\n\nconst createAssertFresh = (\n context: ConfiguratorContext,\n kernel: ConfiguratorKernelClass,\n access: ConfiguratorKernelAccess,\n captured: ConfiguratorCapabilityContext,\n staleMessage: string,\n): (() => void) => {\n const rootAsGlobal = context.rootComponentParametersAsGlobal;\n const contextRootId = context.rootComponentId;\n return () => {\n try {\n if (\n JSON.stringify(captureContext(context, kernel, access)) ===\n JSON.stringify(captured) &&\n rootAsGlobal === context.rootComponentParametersAsGlobal &&\n contextRootId === context.rootComponentId\n ) {\n return;\n }\n } catch {\n /* A target that disappeared also invalidates the captured read. */\n }\n throw new Error(staleMessage);\n };\n};\n\nexport const queryConfigurationOperation = (\n context: ConfiguratorContext,\n access: ConfiguratorKernelAccess,\n rapi: RapiAccess,\n host: ConfigurationOperationHost,\n type: ConfigurationOperationQueryType,\n payload?: ConfigurationOperationQueryPayload,\n): Promise<ConfigurationOperationQueryResult> =>\n enqueue(context, STALE_QUERY_MESSAGE, async () => {\n if (!QUERY_TYPES.includes(type)) {\n throw new Error(\n `Unknown configuration operation query type '${String(type)}'; expected one of: ${QUERY_TYPES.join(', ')}`,\n );\n }\n const query = {\n ...parsePayload(configurationQuerySchemas[type], 'query', type, payload),\n type,\n } as ValidatedQuery;\n const kernel = access.kernelInstance;\n const captured = captureContext(context, kernel, access);\n const assertFresh = createAssertFresh(\n context,\n kernel,\n access,\n captured,\n STALE_QUERY_MESSAGE,\n );\n return runQuery(\n {\n context,\n access,\n rapi,\n host,\n kernel,\n captured,\n assertFresh,\n },\n query,\n );\n });\n\nexport const executeConfigurationOperation = (\n context: ConfiguratorContext,\n access: ConfiguratorKernelAccess,\n rapi: RapiAccess,\n host: ConfigurationOperationHost,\n readHistory: () => ConfigurationOperationHistoryState,\n name: ConfigurationOperationName,\n payload?: ConfigurationOperationExecutePayload,\n): Promise<ConfigurationOperationResult> =>\n enqueue(context, STALE_OPERATION_MESSAGE, async (queued) => {\n if (!EXECUTE_TYPES.includes(name)) {\n throw new Error(\n `Unknown configuration operation '${String(name)}'; expected one of: ${EXECUTE_TYPES.join(', ')}`,\n );\n }\n const operation = {\n ...parsePayload(\n configurationOperationSchemas[name],\n 'operation',\n name,\n payload,\n ),\n type: name,\n } as ValidatedOperation;\n const kernel = access.kernelInstance;\n const captured = captureContext(context, kernel, access);\n const assertFresh = createAssertFresh(\n context,\n kernel,\n access,\n captured,\n STALE_OPERATION_MESSAGE,\n );\n const before = readHistory();\n const result = await runOperation(\n {\n context,\n access,\n rapi,\n host,\n kernel,\n captured,\n assertFresh,\n },\n operation,\n );\n queued.configurationRuntimeId = context.configurationRuntimeId;\n const after = readHistory();\n return {\n ...result,\n history: {\n changed:\n before.configurationHash !== after.configurationHash &&\n after.configurationHash === result.configurationHash,\n canUndo: after.canUndo,\n canRedo: after.canRedo,\n },\n } as ConfigurationOperationResult;\n });\n"],"mappings":";;;;;AAgDA,IAAM,IAAc,OAAO,KAAK,EAA0B,EACpD,IAAgB,OAAO,KAAK,EAA8B,EAK1D,KAAa,MAAgB,KAAK,MAAM,KAAK,UAAU,EAAM,CAAC,EAC9D,KAAoB,MACxB,EAAW,KAAK,MACd,EAAO;CACL,GAAG;CACH,GAAI,EAAU,WACV,EAAE,UAAU,EAAE,OAAO,EAAU,SAAS,OAAO,EAAE,GACjD,EAAE;CACP,CAAC,CACH,EAEG,KACJ,GACA,GACA,MACU,gBAAI,MAAM,uBAAuB,EAAK,IAAI,EAAK,KAAK,IAAS,EAEnE,KACJ,GACA,GACA,GACA,MACqB;CACrB,IAAM,IAAS,EAAO,UAAU,KAAW,EAAE,CAAC;AAC9C,KAAI,CAAC,EAAO,QACV,OAAM,EAAe,GAAM,GAAM,EAAO,MAAM,OAAO,GAAG,QAAQ;AAElE,QAAO,EAAO;GAaV,KAA0B,MAAwC;AACtE,KAAI;EACF,IAA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EACA;EACA;EACD,EACD,EACD;AACD,GAAO,yBAAyB,EAAQ;CACxC,IAAM,IAAQ,GAAa;AAC3B,QAAO;EACL,GAAG;EACH,SAAS;GACP,SACE,EAAO,sBAAsB,EAAM,qBACnC,EAAM,sBAAsB,EAAO;GACrC,SAAS,EAAM;GACf,SAAS,EAAM;GAChB;EACF;EACD"}
1
+ {"version":3,"file":"configuration-operations-Cx7WgZIb.mjs","names":[],"sources":["../../packages/common-core/src/mcp-api/configuration-operations.ts"],"sourcesContent":["import type { z } from 'zod';\nimport {\n configurationOperationSchemas,\n configurationQuerySchemas,\n type ValidatedOperation,\n type ValidatedQuery,\n} from './configuration-operation-schemas';\nimport type ConfiguratorKernelAccess from '../configurator-kernel-access';\nimport type ConfiguratorContext from '../webgl/configurator-context';\nimport type { RapiAccess } from '../rapi-access';\nimport { BASE_CONTEXT } from '../main';\nimport type {\n ConfiguratorKernelClass,\n KernelComponent,\n KernelDockPairQuerySource,\n KernelParameter,\n KernelParameterGroup,\n PossibleChildPreviewElement,\n} from '../../../typings/kernel';\nimport { ANIMATION_PARAMETER_PREFIX } from '../../../configurator-core/src/utils/animation/animation-value-map';\nimport { collectConfiguratorCapabilities } from './configurator-capabilities';\nimport {\n configurationComponentIds,\n fetchComponentLlmData,\n readComponentLlmData,\n withParameterLlmData,\n} from './component-llm-data';\nimport {\n collectProductFamily,\n productContextOf,\n readComponentDefinition,\n} from './component-models';\nimport type {\n CapabilityJsonObject,\n ConfiguratorCapabilityContext,\n} from './configurator-capabilities-types';\nimport type {\n ConfigurationOperationHistoryState,\n ConfigurationOperationDockingChild,\n ConfigurationOperationExecutePayload,\n ConfigurationOperationHost,\n ConfigurationOperationName,\n ConfigurationOperationQueryPayload,\n ConfigurationOperationQueryResult,\n ConfigurationOperationQueryType,\n ConfigurationOperationResult,\n} from './configuration-operations-types';\n\nconst QUERY_TYPES = Object.keys(configurationQuerySchemas);\nconst EXECUTE_TYPES = Object.keys(configurationOperationSchemas);\n\ntype OperationKind = 'query' | 'operation';\ntype OperationKindLabel = 'Query' | 'Operation';\n\nconst detach = <T>(value: T): T => JSON.parse(JSON.stringify(value));\nconst detachParameters = (parameters: KernelParameter[]): KernelParameter[] =>\n parameters.map((parameter) =>\n detach({\n ...parameter,\n ...(parameter.viewType\n ? { viewType: { value: parameter.viewType.value } }\n : {}),\n }),\n );\n\nconst invalidPayload = (\n kind: OperationKind,\n name: string,\n reason: string,\n): Error => new Error(`Invalid payload for ${kind} '${name}': ${reason}`);\n\nconst parsePayload = <Schema extends z.ZodType>(\n schema: Schema,\n kind: OperationKind,\n name: string,\n payload: unknown,\n): z.output<Schema> => {\n const parsed = schema.safeParse(payload ?? {});\n if (!parsed.success) {\n throw invalidPayload(kind, name, parsed.error.issues[0].message);\n }\n return parsed.data;\n};\n\ninterface OperationSession {\n context: ConfiguratorContext;\n access: ConfiguratorKernelAccess;\n rapi: RapiAccess;\n host: ConfigurationOperationHost;\n kernel: ConfiguratorKernelClass;\n captured: ConfiguratorCapabilityContext;\n assertFresh: () => void;\n}\n\nconst parseConfigurationJson = (value: string): CapabilityJsonObject => {\n try {\n const parsed: unknown = JSON.parse(value);\n if (\n parsed !== null &&\n typeof parsed === 'object' &&\n !Array.isArray(parsed)\n ) {\n return parsed as CapabilityJsonObject;\n }\n } catch {\n /* falls through to the actionable error below */\n }\n throw new Error('Missing or invalid configuration JSON');\n};\n\nconst rootComponentIdOf = (configuration: string): string | undefined => {\n const parsed = parseConfigurationJson(configuration);\n return typeof parsed['componentId'] === 'string' && parsed['componentId']\n ? (parsed['componentId'] as string)\n : undefined;\n};\n\nconst preloadAssemblyRootDefinition = async (\n session: OperationSession,\n kind: OperationKind,\n name: string,\n configuration: string,\n): Promise<void> => {\n const rootComponentId = rootComponentIdOf(configuration);\n if (!rootComponentId) {\n return;\n }\n const record = await session.rapi.getComponent(rootComponentId);\n if (!record.configuration) {\n throw invalidPayload(\n kind,\n name,\n `the definition of root component '${rootComponentId}' has no configuration`,\n );\n }\n session.access.loadComponentIntoKernel(record.configuration, rootComponentId);\n};\n\nconst requireActiveComponent = (\n session: OperationSession,\n kind: OperationKindLabel,\n name: string,\n runtimeId: number,\n): KernelComponent => {\n let component: KernelComponent | undefined;\n try {\n component = session.kernel.getComponent(runtimeId);\n } catch {\n component = undefined;\n }\n if (!component) {\n throw new Error(\n `${kind} '${name}': no component with runtime id ${runtimeId} in the active configuration`,\n );\n }\n if (component.objectId !== session.captured.configurationRuntimeId) {\n throw new Error(\n `${kind} '${name}': component with runtime id ${runtimeId} is not part of the active configuration`,\n );\n }\n return component;\n};\n\nconst resolveDockingChildSource = async (\n session: OperationSession,\n kind: OperationKind,\n name: string,\n child: ConfigurationOperationDockingChild,\n): Promise<Exclude<KernelDockPairQuerySource, { runtimeId: number }>> => {\n if ('componentId' in child) {\n const record = await session.rapi.getComponent(child.componentId);\n if (!record.configuration) {\n throw invalidPayload(\n kind,\n name,\n `component '${child.componentId}' has no configuration`,\n );\n }\n return {\n componentId: child.componentId,\n configuration: record.configuration,\n };\n }\n if ('itemId' in child) {\n const item = await session.rapi.getItem(child.itemId);\n if (!item.configuration) {\n throw invalidPayload(\n kind,\n name,\n `item '${child.itemId}' has no configuration`,\n );\n }\n await preloadAssemblyRootDefinition(\n session,\n kind,\n name,\n item.configuration,\n );\n return { configuration: item.configuration };\n }\n await preloadAssemblyRootDefinition(session, kind, name, child.configuration);\n return { configuration: child.configuration };\n};\n\nconst previewElementOf = (\n child: ConfigurationOperationDockingChild,\n configuration: string,\n): PossibleChildPreviewElement => {\n if ('componentId' in child) {\n return {\n id: child.componentId,\n configuration,\n isComponent: true,\n isItem: false,\n };\n }\n return {\n id:\n 'itemId' in child ? child.itemId : rootComponentIdOf(configuration) ?? '',\n configuration,\n isComponent: false,\n isItem: true,\n };\n};\n\nconst runQuery = async (\n session: OperationSession,\n query: ValidatedQuery,\n): Promise<ConfigurationOperationQueryResult> => {\n const { captured, assertFresh } = session;\n switch (query.type) {\n case 'capabilities': {\n const capabilities = await collectConfiguratorCapabilities(\n session.context,\n session.access,\n session.rapi,\n query.include,\n );\n return {\n type: query.type,\n context: capabilities.context,\n capabilities,\n };\n }\n case 'configuration': {\n const configuration = parseConfigurationJson(\n session.access.getSerializedConfiguration(\n captured.configurationRuntimeId,\n ),\n );\n assertFresh();\n return {\n type: query.type,\n context: captured,\n configuration: detach(configuration),\n configurationHash: captured.configurationHash,\n };\n }\n case 'componentParameters': {\n const component = requireActiveComponent(\n session,\n 'Query',\n query.type,\n query.runtimeId,\n );\n const componentId = session.kernel.getComponentId(query.runtimeId);\n const groups = detach(component.parameterGroups);\n const [kernelParameters, llmData] = await Promise.all([\n session.access.getComponentParameters(query.runtimeId),\n readComponentLlmData(session.rapi, componentId),\n ]);\n const parameters = withParameterLlmData(\n detachParameters(kernelParameters),\n [llmData],\n );\n assertFresh();\n return {\n type: query.type,\n context: captured,\n runtimeId: query.runtimeId,\n componentId,\n groups,\n parameters,\n };\n }\n case 'globalParameters': {\n const rootAsGlobal = session.context.rootComponentParametersAsGlobal;\n const globalDefinition = rootAsGlobal\n ? session.kernel.getComponent(captured.rootRuntimeId)\n : session.kernel.getPlanObject(captured.configurationRuntimeId);\n const groups = detach(\n (globalDefinition.parameterGroups ?? []) as KernelParameterGroup[],\n );\n const componentIds = configurationComponentIds(\n parseConfigurationJson(\n session.access.getSerializedConfiguration(\n captured.configurationRuntimeId,\n ),\n ),\n );\n const [kernelParameters, llmData] = await Promise.all([\n session.access.getGlobalParameters(\n captured.configurationRuntimeId,\n rootAsGlobal,\n ),\n Promise.all(\n componentIds.map((id) => readComponentLlmData(session.rapi, id)),\n ),\n ]);\n const parameters = withParameterLlmData(\n detachParameters(kernelParameters),\n llmData,\n );\n assertFresh();\n return {\n type: query.type,\n context: captured,\n scope: rootAsGlobal ? 'rootComponent' : 'planObject',\n groups,\n parameters,\n };\n }\n case 'possibleChildren': {\n const runtimeId = query.runtimeId ?? captured.configurationRuntimeId;\n if (query.runtimeId !== undefined) {\n requireActiveComponent(session, 'Query', query.type, query.runtimeId);\n }\n const children =\n query.runtimeId !== undefined\n ? await session.host.getChildrenOfPlanComponent(\n query.runtimeId,\n true,\n true,\n )\n : await session.host.getChildrenOfPlanObject(true, true);\n if (!children) {\n throw new Error(\n 'Configuration or selection changed while reading capabilities; read again',\n );\n }\n assertFresh();\n return {\n type: query.type,\n context: captured,\n runtimeId,\n tags: detach(children.tags),\n defaultChild: children.defaultChild\n ? detach(children.defaultChild)\n : undefined,\n };\n }\n case 'dockingPositions': {\n const source = await resolveDockingChildSource(\n session,\n 'query',\n query.type,\n query.child,\n );\n const dockPairs = session.access.getDockPairs(\n captured.configurationRuntimeId,\n source,\n query.allowInsertInBetween,\n );\n assertFresh();\n return {\n type: query.type,\n context: captured,\n allowInsertInBetween: query.allowInsertInBetween,\n dockPairs: detach(dockPairs),\n };\n }\n case 'componentDockingPositions': {\n requireActiveComponent(session, 'Query', query.type, query.runtimeId);\n const dockPairs = session.access.getDockPairs(\n captured.configurationRuntimeId,\n { runtimeId: query.runtimeId },\n query.allowInsertInBetween,\n );\n assertFresh();\n return {\n type: query.type,\n context: captured,\n runtimeId: query.runtimeId,\n allowInsertInBetween: query.allowInsertInBetween,\n dockPairs: detach(dockPairs),\n };\n }\n case 'deleteImpact': {\n const deletable = session.access.isComponentDeletable(\n query.runtimeId,\n query.redockChildrenToParent,\n );\n const componentsDeleted =\n session.access.determineComponentsThatWillBeDeleted(\n query.runtimeId,\n query.redockChildrenToParent,\n );\n assertFresh();\n return {\n type: query.type,\n context: captured,\n runtimeId: query.runtimeId,\n redockChildrenToParent: query.redockChildrenToParent,\n deletable,\n componentsDeleted: detach(componentsDeleted),\n };\n }\n case 'componentSkill': {\n const { skills } = await fetchComponentLlmData(\n session.rapi,\n query.componentId,\n );\n const skill = skills.find(({ name }) => name === query.name);\n if (!skill) {\n const available = skills.length\n ? `its skills are ${skills.map(({ name }) => name).join(', ')}`\n : 'it has no skills';\n throw new Error(\n `Query 'componentSkill': component '${query.componentId}' has no skill '${query.name}'; ${available}`,\n );\n }\n assertFresh();\n return {\n type: query.type,\n context: captured,\n componentId: query.componentId,\n ...skill,\n };\n }\n case 'productContext': {\n const configuration = parseConfigurationJson(\n session.access.getSerializedConfiguration(\n captured.configurationRuntimeId,\n ),\n );\n const unresolved: Array<{\n resourceType: 'component' | 'item';\n id: string;\n reason: string;\n }> = [];\n const family = await collectProductFamily(\n session.rapi,\n configuration,\n (resourceType, id, error) =>\n unresolved.push({\n resourceType,\n id,\n reason: error instanceof Error ? error.message : String(error),\n }),\n [],\n );\n assertFresh();\n return {\n type: query.type,\n context: captured,\n product: productContextOf(family, captured.rootComponentId),\n unresolved,\n };\n }\n case 'componentDefinition': {\n let component;\n try {\n component = await readComponentDefinition(\n session.rapi,\n query.componentId,\n );\n } catch (error) {\n throw new Error(\n `Query 'componentDefinition': component '${query.componentId}' could not be read: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n assertFresh();\n return { type: query.type, context: captured, component };\n }\n }\n};\n\nconst runOperation = async (\n session: OperationSession,\n operation: ValidatedOperation,\n) => {\n const { captured, assertFresh } = session;\n const resultHash = (): string =>\n session.access.getCurrentConfigurationHash(\n session.context.configurationRuntimeId,\n );\n switch (operation.type) {\n case 'changeComponentParameter': {\n requireActiveComponent(\n session,\n 'Operation',\n operation.type,\n operation.runtimeId,\n );\n if (operation.key.startsWith(ANIMATION_PARAMETER_PREFIX)) {\n throw new Error(\n `Operation 'changeComponentParameter': parameter keys starting with '${ANIMATION_PARAMETER_PREFIX}' are reserved for the animation system`,\n );\n }\n const parameters = await session.access.getComponentParameters(\n operation.runtimeId,\n );\n const parameter = parameters.find((entry) => entry.key === operation.key);\n if (!parameter) {\n throw new Error(\n `Operation 'changeComponentParameter': the component with runtime id ${operation.runtimeId} has no parameter '${operation.key}'`,\n );\n }\n if (!parameter.enabled) {\n throw new Error(\n `Operation 'changeComponentParameter': the parameter '${operation.key}' of the component with runtime id ${operation.runtimeId} is disabled`,\n );\n }\n assertFresh();\n session.access.setComponentParameter(\n operation.runtimeId,\n operation.key,\n operation.value,\n );\n session.access.updateSelectedComponentDependencies(\n captured.configurationRuntimeId,\n );\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n runtimeId: operation.runtimeId,\n key: operation.key,\n value: operation.value,\n };\n }\n case 'changeGlobalParameter': {\n const rootAsGlobal = session.context.rootComponentParametersAsGlobal;\n const parameters = await session.access.getGlobalParameters(\n captured.configurationRuntimeId,\n rootAsGlobal,\n );\n const parameter = parameters.find((entry) => entry.key === operation.key);\n if (!parameter) {\n throw new Error(\n `Operation 'changeGlobalParameter': the active configuration has no global parameter '${operation.key}'`,\n );\n }\n if (!parameter.enabled) {\n throw new Error(\n `Operation 'changeGlobalParameter': the global parameter '${operation.key}' is disabled`,\n );\n }\n assertFresh();\n if (rootAsGlobal) {\n session.access.setComponentParameter(\n captured.rootRuntimeId,\n operation.key,\n operation.value,\n );\n } else {\n session.access.setPlanObjectParameter(\n captured.configurationRuntimeId,\n operation.key,\n operation.value,\n );\n }\n session.access.updateSelectedComponentDependencies(\n captured.configurationRuntimeId,\n );\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n scope: rootAsGlobal ? 'rootComponent' : 'planObject',\n key: operation.key,\n value: operation.value,\n };\n }\n case 'previewDockings': {\n const source = await resolveDockingChildSource(\n session,\n 'operation',\n operation.type,\n operation.child,\n );\n assertFresh();\n const dockPairs = session.access.getDockPairs(\n captured.configurationRuntimeId,\n source,\n session.access.allowInsertingBetweenWhenDocking,\n );\n session.host\n .getSceneManager()\n .requestDockingsPreview(\n true,\n previewElementOf(operation.child, source.configuration),\n );\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n dockPairCount: dockPairs.length,\n };\n }\n case 'dockComponent': {\n const source = await resolveDockingChildSource(\n session,\n 'operation',\n operation.type,\n operation.child,\n );\n assertFresh();\n const runtimeId = session.access.dockNewComponent(\n captured.configurationRuntimeId,\n source,\n {\n parentId: operation.parentId,\n parentDockId: operation.parentDockId,\n position: operation.position,\n insertInBetween: operation.insertInBetween,\n },\n );\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n runtimeId,\n };\n }\n case 'dragComponent': {\n requireActiveComponent(\n session,\n 'Operation',\n operation.type,\n operation.runtimeId,\n );\n requireActiveComponent(\n session,\n 'Operation',\n operation.type,\n operation.parentId,\n );\n assertFresh();\n session.access.moveComponent(\n captured.configurationRuntimeId,\n operation.runtimeId,\n {\n parentId: operation.parentId,\n parentDockId: operation.parentDockId,\n childDockId: operation.childDockId,\n position: operation.position,\n insertInBetween: operation.insertInBetween,\n },\n );\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n runtimeId: operation.runtimeId,\n };\n }\n case 'deleteComponent': {\n requireActiveComponent(\n session,\n 'Operation',\n operation.type,\n operation.runtimeId,\n );\n if (\n !session.access.isComponentDeletable(\n operation.runtimeId,\n operation.redockChildrenToParent,\n )\n ) {\n throw new Error(\n `Operation 'deleteComponent': the component with runtime id ${operation.runtimeId} is not deletable with redockChildrenToParent ${operation.redockChildrenToParent}`,\n );\n }\n const componentsDeleted =\n session.access.determineComponentsThatWillBeDeleted(\n operation.runtimeId,\n operation.redockChildrenToParent,\n );\n assertFresh();\n session.access.deleteComponent(\n operation.runtimeId,\n operation.redockChildrenToParent,\n );\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n runtimeId: operation.runtimeId,\n redockChildrenToParent: operation.redockChildrenToParent,\n componentsDeleted: detach(componentsDeleted),\n };\n }\n case 'replaceComponent': {\n requireActiveComponent(\n session,\n 'Operation',\n operation.type,\n operation.runtimeId,\n );\n const source = await resolveDockingChildSource(\n session,\n 'operation',\n operation.type,\n operation.child,\n );\n assertFresh();\n const replaced = session.access.replaceComponent(\n captured.configurationRuntimeId,\n operation.runtimeId,\n source,\n );\n if (!replaced) {\n throw new Error(\n `Operation 'replaceComponent': the configurator did not put the child in the place of the component with runtime id ${operation.runtimeId}; the configuration is unchanged. Read the configuration again before the next operation: its runtime ids can have changed`,\n );\n }\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n runtimeId: replaced.runtimeId,\n componentsDeleted: detach(replaced.componentsDeleted),\n };\n }\n case 'swapComponents': {\n const [firstRuntimeId, secondRuntimeId] = operation.runtimeIds;\n for (const runtimeId of [firstRuntimeId, secondRuntimeId]) {\n requireActiveComponent(session, 'Operation', operation.type, runtimeId);\n }\n assertFresh();\n session.access.swapComponents(\n captured.configurationRuntimeId,\n firstRuntimeId,\n secondRuntimeId,\n );\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n runtimeIds: [firstRuntimeId, secondRuntimeId],\n };\n }\n case 'loadConfiguration': {\n await session.host\n .getSceneManager()\n .reloadConfiguration(operation.configuration);\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n };\n }\n case 'undo': {\n await session.host.undo();\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n };\n }\n case 'redo': {\n await session.host.redo();\n return {\n type: operation.type,\n context: captured,\n configurationHash: resultHash(),\n };\n }\n }\n};\n\nconst STALE_QUERY_MESSAGE =\n 'Configuration or selection changed while reading capabilities; read again';\nconst STALE_OPERATION_MESSAGE =\n 'Configuration or selection changed while executing the operation; the operation was not applied';\n\ninterface QueuedConfiguration {\n pending: number;\n configurationRuntimeId: number;\n}\n\nlet operationChain: Promise<unknown> = Promise.resolve();\nconst queuedConfigurations = new WeakMap<\n ConfiguratorContext,\n QueuedConfiguration\n>();\n\nconst enqueue = <T>(\n context: ConfiguratorContext,\n staleMessage: string,\n work: (queued: QueuedConfiguration) => Promise<T>,\n): Promise<T> => {\n const current = queuedConfigurations.get(context);\n const queued = current?.pending\n ? current\n : { pending: 0, configurationRuntimeId: context.configurationRuntimeId };\n queuedConfigurations.set(context, queued);\n queued.pending += 1;\n const run = operationChain.then(() => {\n if (context.configurationRuntimeId !== queued.configurationRuntimeId) {\n throw new Error(staleMessage);\n }\n return work(queued);\n });\n operationChain = run\n .finally(() => {\n queued.pending -= 1;\n })\n .catch(() => undefined);\n return run;\n};\n\nconst captureContext = (\n context: ConfiguratorContext,\n kernel: ConfiguratorKernelClass,\n access: ConfiguratorKernelAccess,\n): ConfiguratorCapabilityContext => {\n if (\n context.baseContext !== BASE_CONTEXT.CONFIGURATOR ||\n !context.configurationRuntimeId\n ) {\n throw new Error(\n 'Load a configuration or enter planner isolation before reading configurator capabilities',\n );\n }\n if (kernel.isExternalPlanObject(context.configurationRuntimeId)) {\n throw new Error(\n 'Use the HI external-object API to read capabilities of an external configuration',\n );\n }\n const rootRuntimeId = kernel.getRootPlanComponentIdFromObjectId(\n context.configurationRuntimeId,\n );\n if (!rootRuntimeId) {\n throw new Error(\n 'No active root component; load a configuration before reading capabilities',\n );\n }\n return {\n configurationRuntimeId: context.configurationRuntimeId,\n rootRuntimeId,\n rootComponentId: kernel.getComponentId(rootRuntimeId),\n selectedRuntimeIds: [...context.selectedRuntimeComponentIds],\n configurationHash: access.getCurrentConfigurationHash(\n context.configurationRuntimeId,\n ),\n };\n};\n\nconst createAssertFresh = (\n context: ConfiguratorContext,\n kernel: ConfiguratorKernelClass,\n access: ConfiguratorKernelAccess,\n captured: ConfiguratorCapabilityContext,\n staleMessage: string,\n): (() => void) => {\n const rootAsGlobal = context.rootComponentParametersAsGlobal;\n const contextRootId = context.rootComponentId;\n return () => {\n try {\n if (\n JSON.stringify(captureContext(context, kernel, access)) ===\n JSON.stringify(captured) &&\n rootAsGlobal === context.rootComponentParametersAsGlobal &&\n contextRootId === context.rootComponentId\n ) {\n return;\n }\n } catch {\n /* A target that disappeared also invalidates the captured read. */\n }\n throw new Error(staleMessage);\n };\n};\n\nexport const queryConfigurationOperation = (\n context: ConfiguratorContext,\n access: ConfiguratorKernelAccess,\n rapi: RapiAccess,\n host: ConfigurationOperationHost,\n type: ConfigurationOperationQueryType,\n payload?: ConfigurationOperationQueryPayload,\n): Promise<ConfigurationOperationQueryResult> =>\n enqueue(context, STALE_QUERY_MESSAGE, async () => {\n if (!QUERY_TYPES.includes(type)) {\n throw new Error(\n `Unknown configuration operation query type '${String(type)}'; expected one of: ${QUERY_TYPES.join(', ')}`,\n );\n }\n const query = {\n ...parsePayload(configurationQuerySchemas[type], 'query', type, payload),\n type,\n } as ValidatedQuery;\n const kernel = access.kernelInstance;\n const captured = captureContext(context, kernel, access);\n const assertFresh = createAssertFresh(\n context,\n kernel,\n access,\n captured,\n STALE_QUERY_MESSAGE,\n );\n return runQuery(\n {\n context,\n access,\n rapi,\n host,\n kernel,\n captured,\n assertFresh,\n },\n query,\n );\n });\n\nexport const executeConfigurationOperation = (\n context: ConfiguratorContext,\n access: ConfiguratorKernelAccess,\n rapi: RapiAccess,\n host: ConfigurationOperationHost,\n readHistory: () => ConfigurationOperationHistoryState,\n name: ConfigurationOperationName,\n payload?: ConfigurationOperationExecutePayload,\n): Promise<ConfigurationOperationResult> =>\n enqueue(context, STALE_OPERATION_MESSAGE, async (queued) => {\n if (!EXECUTE_TYPES.includes(name)) {\n throw new Error(\n `Unknown configuration operation '${String(name)}'; expected one of: ${EXECUTE_TYPES.join(', ')}`,\n );\n }\n const operation = {\n ...parsePayload(\n configurationOperationSchemas[name],\n 'operation',\n name,\n payload,\n ),\n type: name,\n } as ValidatedOperation;\n const kernel = access.kernelInstance;\n const captured = captureContext(context, kernel, access);\n const assertFresh = createAssertFresh(\n context,\n kernel,\n access,\n captured,\n STALE_OPERATION_MESSAGE,\n );\n const before = readHistory();\n const result = await runOperation(\n {\n context,\n access,\n rapi,\n host,\n kernel,\n captured,\n assertFresh,\n },\n operation,\n );\n queued.configurationRuntimeId = context.configurationRuntimeId;\n const after = readHistory();\n return {\n ...result,\n history: {\n changed:\n before.configurationHash !== after.configurationHash &&\n after.configurationHash === result.configurationHash,\n canUndo: after.canUndo,\n canRedo: after.canRedo,\n },\n } as ConfigurationOperationResult;\n });\n"],"mappings":";;;;;AAgDA,IAAM,IAAc,OAAO,KAAK,EAA0B,EACpD,IAAgB,OAAO,KAAK,E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ACA;EACA;EACA;EACA;EACA;EACA,aAfgB,EAClB,GACA,GACA,GACA,GACA,EACD;EAUE,EACD,EACD;EACD,EAES,KACX,GACA,GACA,GACA,GACA,GACA,GACA,MAEA,EAAQ,GAAS,GAAyB,OAAO,MAAW;AAC1D,KAAI,CAAC,EAAc,SAAS,EAAK,CAC/B,OAAU,MACR,oCAAoC,OAAO,EAAK,CAAC,sBAAsB,EAAc,KAAK,KAAK,GAChG;CAEH,IAAM,IAAY;EAChB,GAAG,EACD,EAA8B,IAC9B,aACA,GACA,EACD;EACD,MAAM;EACP,EACK,IAAS,EAAO,gBAChB,IAAW,EAAe,GAAS,GAAQ,EAAO,EAClD,IAAc,EAClB,GACA,GACA,GACA,GACA,EACD,EACK,IAAS,GAAa,EACtB,IAAS,MAAM,EACnB;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACD,EACD,EACD;AACD,GAAO,yBAAyB,EAAQ;CACxC,IAAM,IAAQ,GAAa;AAC3B,QAAO;EACL,GAAG;EACH,SAAS;GACP,SACE,EAAO,sBAAsB,EAAM,qBACnC,EAAM,sBAAsB,EAAO;GACrC,SAAS,EAAM;GACf,SAAS,EAAM;GAChB;EACF;EACD"}
@@ -0,0 +1,3 @@
1
+
2
+ import { t as e } from "./configurator-tOyOfDMx.mjs";
3
+ export { e as Configurator };
@@ -0,0 +1,3 @@
1
+
2
+ import { t as e } from "./configurator-capabilities-FnInde4-.mjs";
3
+ export { e as collectConfiguratorCapabilities };
@@ -1,5 +1,5 @@
1
1
 
2
- import { U as e, j as t } from "./roomle-sdk-ByoTm5M6.mjs";
2
+ import { U as e, j as t } from "./roomle-sdk-8VVPfbDD.mjs";
3
3
  import { n, t as r } from "./configuration-operation-schemas-Q4gAd-KO.mjs";
4
4
  //#region packages/common-core/src/mcp-api/component-llm-data.ts
5
5
  var i = new Set([e.DECIMAL, e.INTEGER]), a = (e) => typeof e == "string" && e.trim() ? e : void 0, o = (e) => typeof e == "object" && e && !Array.isArray(e) ? e : void 0, s = (e) => Array.isArray(e) ? e.map(o).filter((e) => !!e) : [], c = (e) => {
@@ -437,4 +437,4 @@ var i = new Set([e.DECIMAL, e.INTEGER]), a = (e) => typeof e == "string" && e.tr
437
437
  //#endregion
438
438
  export { h as a, m as c, A as i, O as n, u as o, k as r, d as s, V as t };
439
439
 
440
- //# sourceMappingURL=configurator-capabilities-o8fQ6Ang.mjs.map
440
+ //# sourceMappingURL=configurator-capabilities-FnInde4-.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"configurator-capabilities-o8fQ6Ang.mjs","names":[],"sources":["../../packages/common-core/src/mcp-api/component-llm-data.ts","../../packages/common-core/src/mcp-api/component-models.ts","../../packages/common-core/src/mcp-api/configurator-capabilities.ts"],"sourcesContent":["import type { RapiAccess } from '../rapi-access';\nimport { PARAMETER_KERNEL_TYPE } from '../utils/parameter-types';\nimport type { KernelParameter, KernelValue } from '../../../typings/kernel';\nimport type {\n CapabilityJson,\n CapabilityJsonObject,\n} from './configurator-capabilities-types';\n\n/** A skill a component definition offers the configuration assistant. */\nexport interface ComponentSkill {\n name: string;\n description: string;\n skillData: string;\n}\n\n/** The LLM data a component definition gives one parameter key. */\nexport interface ParameterLlmData {\n llmData?: string;\n values: Array<{ value: CapabilityJson; llmData: string }>;\n}\n\n/** The LLM data of a component definition: its `llm` object and the `llmData` of its parameters. */\nexport interface ComponentLlmData {\n label?: string;\n llmData?: string;\n skills: ComponentSkill[];\n parameters: Record<string, ParameterLlmData>;\n}\n\n/** The component description and skill index, without the skill texts. */\nexport interface ComponentLlmIndex {\n llmData?: string;\n skills: Array<{ name: string; description: string }>;\n}\n\nexport type LlmKernelValue = KernelValue & { llmData?: string };\nexport type LlmKernelParameter = Omit<KernelParameter, 'validValues'> & {\n llmData?: string;\n validValues: LlmKernelValue[];\n};\n\nconst NUMERIC_TYPES: ReadonlySet<string> = new Set([\n PARAMETER_KERNEL_TYPE.DECIMAL,\n PARAMETER_KERNEL_TYPE.INTEGER,\n]);\n\nexport const text = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim() ? value : undefined;\nexport const objectOf = (value: unknown): CapabilityJsonObject | undefined =>\n value !== null && typeof value === 'object' && !Array.isArray(value)\n ? (value as CapabilityJsonObject)\n : undefined;\nexport const objectsOf = (value: unknown): CapabilityJsonObject[] =>\n Array.isArray(value)\n ? value\n .map(objectOf)\n .filter((entry): entry is CapabilityJsonObject => !!entry)\n : [];\n\nconst parameterLlmData = (\n parameter: CapabilityJsonObject,\n): ParameterLlmData | undefined => {\n const llmData = text(parameter.llmData);\n const values = objectsOf(parameter.valueObjects).flatMap((valueObject) => {\n const valueLlmData = text(valueObject.llmData);\n return valueLlmData && valueObject.value !== undefined\n ? [{ value: valueObject.value, llmData: valueLlmData }]\n : [];\n });\n if (!llmData && !values.length) {\n return undefined;\n }\n return { ...(llmData ? { llmData } : {}), values };\n};\n\n/** Reads the LLM data of a parsed component definition; non-string and empty values are left out. */\nexport const componentLlmData = (\n definition: CapabilityJsonObject,\n): ComponentLlmData => {\n const llm = objectOf(definition.llm);\n const llmData = text(llm?.llmData);\n const skills = objectsOf(llm?.skills).flatMap((skill) => {\n const name = text(skill.name);\n return name\n ? [\n {\n name,\n description: text(skill.description) ?? '',\n skillData: text(skill.skillData) ?? '',\n },\n ]\n : [];\n });\n const parameters: Record<string, ParameterLlmData> = {};\n for (const parameter of objectsOf(definition.parameters)) {\n const key = text(parameter.key);\n const data = key ? parameterLlmData(parameter) : undefined;\n if (key && data) {\n parameters[key] = data;\n }\n }\n return { ...(llmData ? { llmData } : {}), skills, parameters };\n};\n\n/** The description and skill index of LLM data, or undefined when it has neither. */\nexport const componentLlmIndex = (\n data: ComponentLlmData,\n): ComponentLlmIndex | undefined =>\n data.llmData || data.skills.length\n ? {\n ...(data.llmData ? { llmData: data.llmData } : {}),\n skills: data.skills.map(({ name, description }) => ({\n name,\n description,\n })),\n }\n : undefined;\n\n/** Fetches a component definition from RAPI and reads its LLM data; rejects when the read fails. */\nexport const fetchComponentLlmData = async (\n rapi: Pick<RapiAccess, 'getComponent'>,\n componentId: string,\n): Promise<ComponentLlmData> => {\n const record = await rapi.getComponent(componentId);\n const definition = record.configuration\n ? objectOf(JSON.parse(record.configuration))\n : undefined;\n if (!definition) {\n throw new Error(\n `the definition of component '${componentId}' has no configuration`,\n );\n }\n const label = text(record.label);\n return { ...componentLlmData(definition), ...(label ? { label } : {}) };\n};\n\n/** Like fetchComponentLlmData, but a failed read gives empty LLM data. */\nexport const readComponentLlmData = async (\n rapi: Pick<RapiAccess, 'getComponent'>,\n componentId: string,\n): Promise<ComponentLlmData> => {\n try {\n return await fetchComponentLlmData(rapi, componentId);\n } catch (error) {\n console.warn(\n `[configurator-mcp] no LLM data for component '${componentId}'`,\n error,\n );\n return { skills: [], parameters: {} };\n }\n};\n\nconst numberOf = (value: CapabilityJson): number =>\n typeof value === 'number' || (typeof value === 'string' && value.trim())\n ? Number(value)\n : Number.NaN;\n\n// The kernel formats a decimal with at least two decimals (\"3000.00\"), so a\n// numeric value is compared after rounding to the decimals the kernel wrote.\nconst matchesValue = (\n type: string,\n definitionValue: CapabilityJson,\n kernelValue: string,\n): boolean => {\n if (!NUMERIC_TYPES.has(type)) {\n return String(definitionValue) === kernelValue;\n }\n const expected = numberOf(definitionValue);\n const actual = numberOf(kernelValue);\n const decimals = kernelValue.split('.')[1]?.length ?? 0;\n return (\n Number.isFinite(expected) &&\n Number.isFinite(actual) &&\n Number(expected.toFixed(decimals)) === actual\n );\n};\n\n/**\n * Adds the `llmData` of the definitions to the kernel parameters: per key and per value, the first\n * definition in the given order that has one. Parameters and values without `llmData` stay as they are.\n */\nexport const withParameterLlmData = (\n parameters: KernelParameter[],\n definitions: ComponentLlmData[],\n): LlmKernelParameter[] =>\n parameters.map((parameter) => {\n const declared = definitions.flatMap(({ parameters: byKey }) =>\n byKey[parameter.key] ? [byKey[parameter.key]] : [],\n );\n if (!declared.length) {\n return parameter;\n }\n const llmData = declared.find((entry) => entry.llmData)?.llmData;\n const values = declared.flatMap((entry) => entry.values);\n return {\n ...parameter,\n ...(llmData ? { llmData } : {}),\n validValues: parameter.validValues.map((value) => {\n const valueLlmData = values.find((entry) =>\n matchesValue(parameter.type, entry.value, value.value),\n )?.llmData;\n return valueLlmData ? { ...value, llmData: valueLlmData } : value;\n }),\n };\n });\n\n/** The distinct component ids of a parsed configuration tree, root first, depth first. */\nexport const configurationComponentIds = (\n configuration: CapabilityJsonObject,\n): string[] => {\n const ids: string[] = [];\n const visit = (node: CapabilityJsonObject) => {\n const id = text(node.componentId);\n if (id && !ids.includes(id)) {\n ids.push(id);\n }\n objectsOf(node.children).forEach(visit);\n };\n visit(configuration);\n return ids;\n};\n","import type { RapiAccess } from '../rapi-access';\nimport {\n componentLlmData,\n objectOf,\n objectsOf,\n text,\n type ComponentLlmData,\n} from './component-llm-data';\nimport type {\n CapabilityJson,\n CapabilityJsonObject,\n} from './configurator-capabilities-types';\n\n/** A component or item that a component definition names as a possible child. */\nexport interface ComponentModelChild {\n id: string;\n kind: 'component' | 'item';\n label?: string;\n /** The root component of an item child. */\n rootComponentId?: string;\n}\n\n/** What the agent gets of every component of the product: the static context of the system prompt. */\nexport interface ComponentShortModel {\n id: string;\n label?: string;\n llmData?: string;\n skills?: Array<{ name: string; description: string }>;\n children?: ComponentModelChild[];\n}\n\nexport interface ComponentModelValue {\n value: CapabilityJson;\n label?: string;\n llmData?: string;\n}\n\nexport interface ComponentModelParameter {\n key: string;\n label?: string;\n type?: string;\n unitType?: string;\n group?: string;\n defaultValue?: CapabilityJson;\n global?: boolean;\n llmData?: string;\n validValues?: ComponentModelValue[];\n validRange?: CapabilityJsonObject;\n}\n\n/** What the agent gets of one component on request: the short model and the parameters of the definition. */\nexport interface ComponentDetailedModel extends ComponentShortModel {\n parameterGroups?: Array<{ key: string; label?: string }>;\n parameters: ComponentModelParameter[];\n}\n\n/** The static context of a product: the short model of every component of its family, in walk order. */\nexport interface ProductContext {\n rootComponentId: string;\n components: ComponentShortModel[];\n}\n\nexport interface ProductFamilyComponent {\n id: string;\n label?: string;\n thumbnail?: string;\n definition: CapabilityJsonObject;\n llm: ComponentLlmData;\n}\n\nexport interface ProductFamilyItem {\n id: string;\n label?: string;\n thumbnail?: string;\n rootComponentId: string;\n assembly: CapabilityJsonObject;\n}\n\n/** The product family in walk order: the components breadth first from the root, and the items they reference. */\nexport interface ProductFamily {\n components: Map<string, ProductFamilyComponent>;\n items: Map<string, ProductFamilyItem>;\n}\n\nexport type ProductFamilyUnresolved = (\n resourceType: 'component' | 'item',\n id: string,\n error: unknown,\n) => void;\n\ntype FamilyRapi = Pick<RapiAccess, 'getComponent' | 'getItem'>;\ntype ChildLookup = (\n kind: ComponentModelChild['kind'],\n id: string,\n) => Pick<ComponentModelChild, 'label' | 'rootComponentId'> | undefined;\n\nconst RANGE_FIELDS = ['valueFrom', 'valueTo', 'step'];\n\nconst strings = (value: unknown): string[] =>\n Array.isArray(value)\n ? value.filter((entry): entry is string => !!text(entry))\n : [];\nconst detach = <T>(value: T): T => JSON.parse(JSON.stringify(value));\n\nconst parseDefinition = (configuration: unknown): CapabilityJsonObject => {\n const parsed =\n typeof configuration === 'string' && configuration\n ? objectOf(JSON.parse(configuration))\n : undefined;\n if (!parsed) {\n throw new Error('Missing or invalid configuration JSON');\n }\n return parsed;\n};\n\nconst familyComponent = (\n id: string,\n record: { label?: string; thumbnail?: string },\n definition: CapabilityJsonObject,\n): ProductFamilyComponent => {\n if (definition.id && definition.id !== id) {\n throw new Error('Component definition ID does not match requested ID');\n }\n const label = text(record.label);\n const thumbnail = text(record.thumbnail);\n return {\n id,\n ...(label ? { label } : {}),\n ...(thumbnail ? { thumbnail } : {}),\n definition,\n llm: componentLlmData(definition),\n };\n};\n\nconst childrenOf = (\n definition: CapabilityJsonObject,\n lookup: ChildLookup,\n): ComponentModelChild[] => {\n const children: ComponentModelChild[] = [];\n const seen = new Set<string>();\n const add = (kind: ComponentModelChild['kind'], value: unknown) => {\n const id = text(value);\n if (!id || seen.has(kind + ':' + id)) {\n return;\n }\n seen.add(kind + ':' + id);\n const known = lookup(kind, id);\n children.push({\n id,\n kind,\n ...(known?.label ? { label: known.label } : {}),\n ...(kind === 'item' && known?.rootComponentId\n ? { rootComponentId: known.rootComponentId }\n : {}),\n });\n };\n for (const child of objectsOf(definition.possibleChildren)) {\n add('component', child.componentId);\n add('item', child.itemId);\n }\n strings(definition.validChildren).forEach((id) => add('component', id));\n return children;\n};\n\nconst valueObjectCandidates = (value: unknown): ComponentModelValue[] =>\n objectsOf(value).flatMap((valueObject) => {\n if (valueObject.value === undefined) {\n return [];\n }\n const label = text(valueObject.label);\n const llmData = text(valueObject.llmData);\n return [\n {\n value: valueObject.value,\n ...(label ? { label } : {}),\n ...(llmData ? { llmData } : {}),\n },\n ];\n });\n\n// The candidates in the kernel's order: valueObjects, validValues,\n// localizedValues, conditionalValues. A value listed twice keeps its first\n// place and takes a label or llmData it lacks from the later entry.\nconst candidateValues = (\n parameter: CapabilityJsonObject,\n): ComponentModelValue[] => {\n const plainValues: ComponentModelValue[] = Array.isArray(\n parameter.validValues,\n )\n ? parameter.validValues\n .filter(\n (value): value is string | number | boolean =>\n value !== null && typeof value !== 'object',\n )\n .map((value) => ({ value }))\n : [];\n const candidates = new Map<CapabilityJson, ComponentModelValue>();\n for (const candidate of [\n ...valueObjectCandidates(parameter.valueObjects),\n ...plainValues,\n ...valueObjectCandidates(parameter.localizedValues),\n ...valueObjectCandidates(parameter.conditionalValues),\n ]) {\n const listed = candidates.get(candidate.value);\n candidates.set(\n candidate.value,\n listed ? { ...candidate, ...listed } : candidate,\n );\n }\n return [...candidates.values()];\n};\n\nconst parameterModel = (\n parameter: CapabilityJsonObject,\n): ComponentModelParameter | undefined => {\n const key = text(parameter.key);\n if (!key) {\n return undefined;\n }\n const validValues = candidateValues(parameter);\n const range = objectOf(parameter.validRange);\n const validRange = range\n ? Object.fromEntries(\n RANGE_FIELDS.filter((field) => range[field] !== undefined).map(\n (field) => [field, range[field]],\n ),\n )\n : undefined;\n const label = text(parameter.label);\n const type = text(parameter.type);\n const unitType = text(parameter.unitType);\n const group = text(parameter.group);\n const llmData = text(parameter.llmData);\n return {\n key,\n ...(label ? { label } : {}),\n ...(type ? { type } : {}),\n ...(unitType ? { unitType } : {}),\n ...(group ? { group } : {}),\n ...(parameter.defaultValue !== undefined\n ? { defaultValue: parameter.defaultValue }\n : {}),\n ...(parameter.global === true ? { global: true } : {}),\n ...(llmData ? { llmData } : {}),\n ...(validValues.length ? { validValues } : {}),\n ...(validRange && Object.keys(validRange).length ? { validRange } : {}),\n };\n};\n\n/** The short model of a component: id, label, LLM description, skill names and the children it can take. */\nexport const shortComponentModel = (\n { id, label, llm, definition }: ProductFamilyComponent,\n lookup: ChildLookup,\n): ComponentShortModel => {\n const children = childrenOf(definition, lookup);\n return detach({\n id,\n ...(label ? { label } : {}),\n ...(llm.llmData ? { llmData: llm.llmData } : {}),\n ...(llm.skills.length\n ? {\n skills: llm.skills.map(({ name, description }) => ({\n name,\n description,\n })),\n }\n : {}),\n ...(children.length ? { children } : {}),\n });\n};\n\n/** The detailed model of a component: the short model plus its parameter groups and parameters. */\nexport const detailedComponentModel = (\n component: ProductFamilyComponent,\n lookup: ChildLookup,\n): ComponentDetailedModel => {\n const { definition } = component;\n const parameterGroups = objectsOf(definition.parameterGroups).flatMap(\n (group) => {\n const key = text(group.key);\n const label = text(group.label);\n return key ? [{ key, ...(label ? { label } : {}) }] : [];\n },\n );\n return detach({\n ...shortComponentModel(component, lookup),\n ...(parameterGroups.length ? { parameterGroups } : {}),\n parameters: objectsOf(definition.parameters).flatMap((parameter) => {\n const model = parameterModel(parameter);\n return model ? [model] : [];\n }),\n });\n};\n\n/** The labels and item roots of the family, for the children of its models. */\nexport const familyLookup =\n (family: ProductFamily): ChildLookup =>\n (kind, id) => {\n if (kind === 'component') {\n const component = family.components.get(id);\n return component && { label: component.label };\n }\n const item = family.items.get(id);\n return item && { label: item.label, rootComponentId: item.rootComponentId };\n };\n\n/**\n * Walks the product family of a configuration as the agent needs it: the components of the\n * configuration and the seeds, then breadth first their possible children, sub-components, valid\n * children and the root components of the items they name, each definition read once. A read that\n * fails is reported and left out.\n */\nexport const collectProductFamily = async (\n rapi: FamilyRapi,\n configuration: CapabilityJsonObject,\n unresolved: ProductFamilyUnresolved,\n seeds: string[],\n): Promise<ProductFamily> => {\n const components = new Map<string, ProductFamilyComponent>();\n const items = new Map<string, ProductFamilyItem>();\n const seenComponents = new Set<string>();\n const seenItems = new Set<string>();\n const pendingComponents: string[] = [];\n const pendingItems: string[] = [];\n const queueComponent = (value: unknown) => {\n const id = text(value);\n if (id && !seenComponents.has(id)) {\n seenComponents.add(id);\n pendingComponents.push(id);\n }\n };\n const queueItem = (value: unknown) => {\n const id = text(value);\n if (id && !seenItems.has(id)) {\n seenItems.add(id);\n pendingItems.push(id);\n }\n };\n const seedAssembly = (assembly: CapabilityJsonObject) => {\n const nodes = [assembly];\n while (nodes.length) {\n const node = nodes.pop()!;\n queueComponent(node.componentId);\n nodes.push(...objectsOf(node.children));\n }\n };\n seeds.forEach(queueComponent);\n seedAssembly(configuration);\n while (pendingComponents.length || pendingItems.length) {\n const batch = pendingComponents.splice(0);\n const itemBatch = pendingItems.splice(0);\n const [definitions, assemblies] = await Promise.all([\n Promise.all(\n batch.map(async (id) => {\n try {\n const record = await rapi.getComponent(id);\n return familyComponent(\n id,\n record,\n parseDefinition(record.configuration),\n );\n } catch (error) {\n unresolved('component', id, error);\n return undefined;\n }\n }),\n ),\n Promise.all(\n itemBatch.map(async (id): Promise<ProductFamilyItem | undefined> => {\n try {\n const record = await rapi.getItem(id);\n const assembly = parseDefinition(record.configuration);\n const rootComponentId = text(assembly.componentId);\n if (!rootComponentId) {\n throw new Error('Item configuration has no root component ID');\n }\n const label = text(record.label);\n const thumbnail = text(record.thumbnail);\n return {\n id,\n ...(label ? { label } : {}),\n ...(thumbnail ? { thumbnail } : {}),\n rootComponentId,\n assembly,\n };\n } catch (error) {\n unresolved('item', id, error);\n return undefined;\n }\n }),\n ),\n ]);\n for (const component of definitions) {\n if (!component) {\n continue;\n }\n components.set(component.id, component);\n const { definition } = component;\n for (const child of [\n ...objectsOf(definition.possibleChildren),\n ...objectsOf(definition.subComponents),\n ]) {\n queueComponent(child.componentId);\n queueItem(child.itemId);\n }\n strings(definition.validChildren).forEach(queueComponent);\n }\n for (const item of assemblies) {\n if (!item) {\n continue;\n }\n items.set(item.id, item);\n seedAssembly(item.assembly);\n }\n }\n return { components, items };\n};\n\n/** The product context of a family: the short model of every component, in walk order. */\nexport const productContextOf = (\n family: ProductFamily,\n rootComponentId: string,\n): ProductContext => {\n const lookup = familyLookup(family);\n return {\n rootComponentId,\n components: [...family.components.values()].map((component) =>\n shortComponentModel(component, lookup),\n ),\n };\n};\n\n/**\n * Reads the detailed model of one component by its id, also of a component that is not in the\n * configuration. The direct children are read for their labels; a child RAPI cannot deliver keeps\n * its id only.\n */\nexport const readComponentDefinition = async (\n rapi: FamilyRapi,\n componentId: string,\n): Promise<ComponentDetailedModel> => {\n const record = await rapi.getComponent(componentId);\n const component = familyComponent(\n componentId,\n record,\n parseDefinition(record.configuration),\n );\n const known = new Map<\n string,\n Pick<ComponentModelChild, 'label' | 'rootComponentId'>\n >();\n await Promise.all(\n childrenOf(component.definition, () => undefined).map(\n async ({ id, kind }) => {\n try {\n if (kind === 'component') {\n const child = await rapi.getComponent(id);\n known.set(kind + ':' + id, { label: text(child.label) });\n } else {\n const item = await rapi.getItem(id);\n const assembly = parseDefinition(item.configuration);\n known.set(kind + ':' + id, {\n label: text(item.label),\n rootComponentId: text(assembly.componentId),\n });\n }\n } catch {\n /* The child keeps its id. */\n }\n },\n ),\n );\n return detailedComponentModel(component, (kind, id) =>\n known.get(kind + ':' + id),\n );\n};\n","import {\n CAPABILITY_SECTIONS,\n capabilitiesIncludeSchema,\n} from './configuration-operation-schemas';\nimport type ConfiguratorKernelAccess from '../configurator-kernel-access';\nimport type ConfiguratorContext from '../webgl/configurator-context';\nimport type { RapiAccess } from '../rapi-access';\nimport { BASE_CONTEXT } from '../main';\nimport type {\n KernelParameter,\n KernelParameterGroup,\n} from '../../../typings/kernel';\nimport type { RapiMaterial } from '../../../typings/rapi-types';\nimport {\n configurationComponentIds,\n withParameterLlmData,\n type ComponentLlmData,\n} from './component-llm-data';\nimport {\n collectProductFamily,\n detailedComponentModel,\n familyLookup,\n type ComponentModelParameter,\n} from './component-models';\nimport type {\n CapabilityJson,\n CapabilityJsonObject,\n ConfiguratorCapabilities,\n ConfiguratorCapabilityContext,\n ConfiguratorCapabilityInstance,\n ConfiguratorCapabilitySection,\n} from './configurator-capabilities-types';\n\nconst detach = <T>(value: T): T => JSON.parse(JSON.stringify(value));\nconst detachParameters = (parameters: KernelParameter[]): KernelParameter[] =>\n parameters.map((parameter) =>\n detach({\n ...parameter,\n ...(parameter.viewType\n ? { viewType: { value: parameter.viewType.value } }\n : {}),\n }),\n );\nconst object = (value: unknown): CapabilityJsonObject | undefined =>\n value !== null && typeof value === 'object' && !Array.isArray(value)\n ? (value as CapabilityJsonObject)\n : undefined;\nconst objects = (value: CapabilityJson | undefined): CapabilityJsonObject[] =>\n Array.isArray(value)\n ? value\n .map(object)\n .filter((entry): entry is CapabilityJsonObject => !!entry)\n : [];\nconst strings = (value: CapabilityJson | undefined): string[] =>\n Array.isArray(value)\n ? value.filter(\n (entry): entry is string => typeof entry === 'string' && !!entry,\n )\n : [];\nconst project = (source: object, keys: string[]): CapabilityJsonObject => {\n const entries = Object.entries(source).filter(\n ([key, value]) => keys.includes(key) && value !== undefined,\n );\n return detach(Object.fromEntries(entries));\n};\nconst parseConfiguration = (\n value: string | undefined,\n): CapabilityJsonObject => {\n const parsed = value && object(JSON.parse(value));\n if (!parsed) {\n throw new Error('Missing or invalid configuration JSON');\n }\n return parsed;\n};\nconst childIds = (value: unknown): number[] => {\n if (Array.isArray(value)) {\n return [...value];\n }\n const list = value as { size(): number; get(index: number): number };\n return Array.from({ length: list.size() }, (_, i) => list.get(i));\n};\n\ntype Unresolved = (\n resourceType: ConfiguratorCapabilities['unresolved'][number]['resourceType'],\n id: string,\n error: unknown,\n) => void;\n\nconst discoverProductFamily = async (\n rapi: RapiAccess,\n configuration: CapabilityJsonObject,\n instances: ConfiguratorCapabilityInstance[],\n unresolved: Unresolved,\n) => {\n const family = await collectProductFamily(\n rapi,\n configuration,\n unresolved,\n instances.map((instance) => instance.componentId),\n );\n const lookup = familyLookup(family);\n const components: NonNullable<ConfiguratorCapabilities['components']> = {};\n const items: NonNullable<ConfiguratorCapabilities['items']> = {};\n const declaredByComponent: Record<string, ComponentModelParameter[]> = {};\n const declaredRawParameters: Record<string, CapabilityJsonObject[]> = {};\n const llmDataByComponent: Record<string, ComponentLlmData> = {};\n for (const [id, component] of family.components) {\n const model = detailedComponentModel(component, lookup);\n components[id] = model;\n declaredByComponent[id] = model.parameters;\n declaredRawParameters[id] = objects(component.definition.parameters);\n llmDataByComponent[id] = component.llm;\n }\n for (const [id, item] of family.items) {\n items[id] = {\n ...(item.label ? { label: item.label } : {}),\n ...(item.thumbnail ? { thumbnail: item.thumbnail } : {}),\n rootComponentId: item.rootComponentId,\n };\n }\n return {\n components,\n items,\n declaredByComponent,\n declaredRawParameters,\n llmDataByComponent,\n };\n};\n\nconst collectMaterials = async (\n rapi: RapiAccess,\n declaredByComponent: Record<string, CapabilityJsonObject[]>,\n current: NonNullable<ConfiguratorCapabilities['parameters']>['current'],\n unresolved: Unresolved,\n): Promise<NonNullable<ConfiguratorCapabilities['materials']>> => {\n const materials: NonNullable<ConfiguratorCapabilities['materials']> = {\n byId: {},\n groups: {},\n };\n const materialIds = new Set<string>();\n const groupIds = new Set<string>();\n const addId = (set: Set<string>, id: unknown) => {\n if (typeof id === 'string' && id) {\n set.add(id);\n }\n };\n const collectParameter = (parameter: CapabilityJsonObject) => {\n if (parameter.type !== 'Material') {\n return;\n }\n addId(materialIds, parameter.value);\n addId(materialIds, parameter.defaultValue);\n if (Array.isArray(parameter.validValues)) {\n for (const value of parameter.validValues) {\n addId(materialIds, object(value)?.value ?? value);\n }\n }\n for (const key of [\n 'valueObjects',\n 'localizedValues',\n 'conditionalValues',\n ]) {\n objects(parameter[key]).forEach((value) =>\n addId(materialIds, value.value),\n );\n }\n strings(parameter.validGroups).forEach((id) => groupIds.add(id));\n objects(parameter.conditionalGroups).forEach((group) =>\n addId(groupIds, group.value),\n );\n };\n Object.values(declaredByComponent).flat().forEach(collectParameter);\n const currentParameters: KernelParameter[] = [\n ...current.global.parameters,\n ...Object.values(current.byComponent).flatMap((value) => value.parameters),\n ];\n currentParameters.forEach((parameter) =>\n collectParameter(\n project(parameter, ['type', 'value', 'validValues', 'validGroups']),\n ),\n );\n const addMaterial = (material: RapiMaterial) => {\n materials.byId[material.id] = project(material, [\n 'id',\n 'name',\n 'label',\n 'thumbnail',\n 'color',\n 'active',\n 'group',\n 'groupLabel',\n 'tags',\n ]);\n if (material.shading?.basecolor !== undefined) {\n materials.byId[material.id].shading = project(material.shading, [\n 'basecolor',\n ]);\n }\n };\n await Promise.all(\n [...groupIds].map(async (id) => {\n try {\n const online = navigator.onLine;\n const groups = await rapi.getMaterialsByGroup([id]);\n const matched = groups.find(\n (group) => group.id === id || group.legacyId === id,\n );\n const members = groups.flatMap((group) =>\n group.materials.filter(\n (material) =>\n group === matched ||\n material.group === id ||\n material.tags?.includes(id),\n ),\n );\n members.forEach(addMaterial);\n const legacyMaterial = members.find(\n (material) => material.group === id,\n );\n const label = matched?.label ?? legacyMaterial?.groupLabel;\n const legacyId = matched?.legacyId ?? (legacyMaterial ? id : undefined);\n materials.groups[id] = {\n id,\n ...(label ? { label } : {}),\n ...(legacyId ? { legacyId } : {}),\n materialIds: [...new Set(members.map((material) => material.id))],\n };\n if (!online || !navigator.onLine) {\n unresolved(\n 'materialGroup',\n id,\n 'Offline material group coverage cannot be established',\n );\n }\n } catch (error) {\n unresolved('materialGroup', id, error);\n }\n }),\n );\n const missingIds = [...materialIds].filter((id) => !materials.byId[id]);\n if (missingIds.length) {\n try {\n (await rapi.getMaterials(missingIds)).forEach(addMaterial);\n missingIds\n .filter((id) => !materials.byId[id])\n .forEach((id) =>\n unresolved('material', id, 'Material metadata unavailable'),\n );\n } catch (error) {\n missingIds.forEach((id) => unresolved('material', id, error));\n }\n }\n return materials;\n};\n\nexport const collectConfiguratorCapabilities = async (\n context: ConfiguratorContext,\n access: ConfiguratorKernelAccess,\n rapi: RapiAccess,\n include?: ConfiguratorCapabilitySection[],\n): Promise<ConfiguratorCapabilities> => {\n const parsed = capabilitiesIncludeSchema.safeParse(include ?? undefined);\n if (!parsed.success) {\n throw new Error('Unknown configurator capability section');\n }\n const sections = new Set(\n parsed.data?.length ? parsed.data : CAPABILITY_SECTIONS,\n );\n const kernel = access.kernelInstance;\n const captureContext = (): ConfiguratorCapabilityContext => {\n if (\n context.baseContext !== BASE_CONTEXT.CONFIGURATOR ||\n !context.configurationRuntimeId\n ) {\n throw new Error(\n 'Load a configuration or enter planner isolation before reading configurator capabilities',\n );\n }\n if (kernel.isExternalPlanObject(context.configurationRuntimeId)) {\n throw new Error(\n 'Use the HI external-object API to read capabilities of an external configuration',\n );\n }\n const rootRuntimeId = kernel.getRootPlanComponentIdFromObjectId(\n context.configurationRuntimeId,\n );\n if (!rootRuntimeId) {\n throw new Error(\n 'No active root component; load a configuration before reading capabilities',\n );\n }\n return {\n configurationRuntimeId: context.configurationRuntimeId,\n rootRuntimeId,\n rootComponentId: kernel.getComponentId(rootRuntimeId),\n selectedRuntimeIds: [...context.selectedRuntimeComponentIds],\n configurationHash: access.getCurrentConfigurationHash(\n context.configurationRuntimeId,\n ),\n };\n };\n const captured = captureContext();\n const rootAsGlobal = context.rootComponentParametersAsGlobal;\n const contextRootId = context.rootComponentId;\n const assertFresh = () => {\n try {\n if (\n JSON.stringify(captureContext()) === JSON.stringify(captured) &&\n rootAsGlobal === context.rootComponentParametersAsGlobal &&\n contextRootId === context.rootComponentId\n ) {\n return;\n }\n } catch {\n /* A target that disappeared also invalidates the captured read. */\n }\n throw new Error(\n 'Configuration or selection changed while reading capabilities; read again',\n );\n };\n const result: ConfiguratorCapabilities = {\n context: captured,\n complete: true,\n unresolved: [],\n };\n const unresolved = (\n resourceType: ConfiguratorCapabilities['unresolved'][number]['resourceType'],\n id: string,\n error: unknown,\n ) => {\n result.complete = false;\n result.unresolved.push({\n resourceType,\n id,\n sections: [...sections].filter(\n (section) =>\n section !== 'configuration' &&\n (!resourceType.startsWith('material') || section === 'materials'),\n ),\n reason: error instanceof Error ? error.message : String(error),\n });\n };\n const configuration = parseConfiguration(\n access.getSerializedConfiguration(captured.configurationRuntimeId),\n );\n const instances: ConfiguratorCapabilityInstance[] = [];\n const current: NonNullable<\n ConfiguratorCapabilities['parameters']\n >['current'] = {\n global: {\n scope: rootAsGlobal ? 'rootComponent' : 'planObject',\n parameters: [],\n groups: [],\n },\n byComponent: {},\n };\n const docking: NonNullable<ConfiguratorCapabilities['docking']> = {\n current: { globalPossibleChildren: [], byComponent: {} },\n };\n const needsParameters =\n sections.has('parameters') || sections.has('materials');\n const reads: Array<Promise<void>> = [];\n const pendingRuntimeIds = [captured.rootRuntimeId];\n const visitedRuntimeIds = new Set<number>();\n while (pendingRuntimeIds.length) {\n const runtimeId = pendingRuntimeIds.shift()!;\n if (visitedRuntimeIds.has(runtimeId)) {\n continue;\n }\n visitedRuntimeIds.add(runtimeId);\n const component = kernel.getComponent(runtimeId);\n const componentId = kernel.getComponentId(runtimeId);\n const childRuntimeIds = childIds(component.childIds);\n instances.push({\n runtimeId,\n componentId,\n parentRuntimeId: component.parentId || null,\n childRuntimeIds,\n });\n pendingRuntimeIds.push(...childRuntimeIds);\n if (needsParameters) {\n const groups = detach(component.parameterGroups);\n reads.push(\n access.getComponentParameters(runtimeId).then((parameters) => {\n current.byComponent[runtimeId] = {\n componentId,\n groups,\n parameters: detachParameters(parameters),\n };\n }),\n );\n }\n if (sections.has('docking')) {\n docking.current.byComponent[runtimeId] = detach(\n kernel.getPlanComponentPossibleChildren(runtimeId),\n );\n }\n }\n if (needsParameters) {\n const globalDefinition = rootAsGlobal\n ? kernel.getComponent(captured.rootRuntimeId)\n : kernel.getPlanObject(captured.configurationRuntimeId);\n current.global.groups = detach(\n (globalDefinition.parameterGroups ?? []) as KernelParameterGroup[],\n );\n reads.push(\n access\n .getGlobalParameters(captured.configurationRuntimeId, rootAsGlobal)\n .then((parameters) => {\n current.global.parameters = detachParameters(parameters);\n }),\n );\n }\n if (sections.has('docking')) {\n docking.current.globalPossibleChildren = detach(\n kernel.getPlanObjectPossibleChildren(captured.configurationRuntimeId),\n );\n }\n await Promise.all(reads);\n assertFresh();\n if (sections.has('configuration')) {\n result.configuration = { data: configuration, instances };\n }\n if (sections.size === 1 && sections.has('configuration')) {\n return result;\n }\n\n const {\n components,\n items,\n declaredByComponent,\n declaredRawParameters,\n llmDataByComponent,\n } = await discoverProductFamily(rapi, configuration, instances, unresolved);\n if (sections.has('components')) {\n result.components = components;\n }\n if (sections.has('items')) {\n result.items = items;\n }\n if (sections.has('parameters')) {\n const llmDataOf = (componentId: string) =>\n llmDataByComponent[componentId] ? [llmDataByComponent[componentId]] : [];\n for (const entry of Object.values(current.byComponent)) {\n entry.parameters = withParameterLlmData(\n entry.parameters,\n llmDataOf(entry.componentId),\n );\n }\n current.global.parameters = withParameterLlmData(\n current.global.parameters,\n configurationComponentIds(configuration).flatMap(llmDataOf),\n );\n result.parameters = { declaredByComponent, current };\n }\n if (sections.has('docking')) {\n result.docking = docking;\n }\n\n if (sections.has('materials')) {\n result.materials = await collectMaterials(\n rapi,\n declaredRawParameters,\n current,\n unresolved,\n );\n }\n assertFresh();\n return result;\n};\n"],"mappings":";;;;AAyCA,IAAM,IAAqC,IAAI,IAAI,CACjD,EAAsB,SACtB,EAAsB,QACvB,CAAC,EAEW,KAAQ,MACnB,OAAO,KAAU,YAAY,EAAM,MAAM,GAAG,IAAQ,KAAA,GACzC,KAAY,MACL,OAAO,KAAU,YAAnC,KAA+C,CAAC,MAAM,QAAQ,EAAM,GAC/D,IACD,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["../../packages/common-core/src/mcp-api/component-llm-data.ts","../../packages/common-core/src/mcp-api/component-models.ts","../../packages/common-core/src/mcp-api/configurator-capabilities.ts"],"sourcesContent":["import type { RapiAccess } from '../rapi-access';\nimport { PARAMETER_KERNEL_TYPE } from '../utils/parameter-types';\nimport type { KernelParameter, KernelValue } from '../../../typings/kernel';\nimport type {\n CapabilityJson,\n CapabilityJsonObject,\n} from './configurator-capabilities-types';\n\n/** A skill a component definition offers the configuration assistant. */\nexport interface ComponentSkill {\n name: string;\n description: string;\n skillData: string;\n}\n\n/** The LLM data a component definition gives one parameter key. */\nexport interface ParameterLlmData {\n llmData?: string;\n values: Array<{ value: CapabilityJson; llmData: string }>;\n}\n\n/** The LLM data of a component definition: its `llm` object and the `llmData` of its parameters. */\nexport interface ComponentLlmData {\n label?: string;\n llmData?: string;\n skills: ComponentSkill[];\n parameters: Record<string, ParameterLlmData>;\n}\n\n/** The component description and skill index, without the skill texts. */\nexport interface ComponentLlmIndex {\n llmData?: string;\n skills: Array<{ name: string; description: string }>;\n}\n\nexport type LlmKernelValue = KernelValue & { llmData?: string };\nexport type LlmKernelParameter = Omit<KernelParameter, 'validValues'> & {\n llmData?: string;\n validValues: LlmKernelValue[];\n};\n\nconst NUMERIC_TYPES: ReadonlySet<string> = new Set([\n PARAMETER_KERNEL_TYPE.DECIMAL,\n PARAMETER_KERNEL_TYPE.INTEGER,\n]);\n\nexport const text = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim() ? value : undefined;\nexport const objectOf = (value: unknown): CapabilityJsonObject | undefined =>\n value !== null && typeof value === 'object' && !Array.isArray(value)\n ? (value as CapabilityJsonObject)\n : undefined;\nexport const objectsOf = (value: unknown): CapabilityJsonObject[] =>\n Array.isArray(value)\n ? value\n .map(objectOf)\n .filter((entry): entry is CapabilityJsonObject => !!entry)\n : [];\n\nconst parameterLlmData = (\n parameter: CapabilityJsonObject,\n): ParameterLlmData | undefined => {\n const llmData = text(parameter.llmData);\n const values = objectsOf(parameter.valueObjects).flatMap((valueObject) => {\n const valueLlmData = text(valueObject.llmData);\n return valueLlmData && valueObject.value !== undefined\n ? [{ value: valueObject.value, llmData: valueLlmData }]\n : [];\n });\n if (!llmData && !values.length) {\n return undefined;\n }\n return { ...(llmData ? { llmData } : {}), values };\n};\n\n/** Reads the LLM data of a parsed component definition; non-string and empty values are left out. */\nexport const componentLlmData = (\n definition: CapabilityJsonObject,\n): ComponentLlmData => {\n const llm = objectOf(definition.llm);\n const llmData = text(llm?.llmData);\n const skills = objectsOf(llm?.skills).flatMap((skill) => {\n const name = text(skill.name);\n return name\n ? [\n {\n name,\n description: text(skill.description) ?? '',\n skillData: text(skill.skillData) ?? '',\n },\n ]\n : [];\n });\n const parameters: Record<string, ParameterLlmData> = {};\n for (const parameter of objectsOf(definition.parameters)) {\n const key = text(parameter.key);\n const data = key ? parameterLlmData(parameter) : undefined;\n if (key && data) {\n parameters[key] = data;\n }\n }\n return { ...(llmData ? { llmData } : {}), skills, parameters };\n};\n\n/** The description and skill index of LLM data, or undefined when it has neither. */\nexport const componentLlmIndex = (\n data: ComponentLlmData,\n): ComponentLlmIndex | undefined =>\n data.llmData || data.skills.length\n ? {\n ...(data.llmData ? { llmData: data.llmData } : {}),\n skills: data.skills.map(({ name, description }) => ({\n name,\n description,\n })),\n }\n : undefined;\n\n/** Fetches a component definition from RAPI and reads its LLM data; rejects when the read fails. */\nexport const fetchComponentLlmData = async (\n rapi: Pick<RapiAccess, 'getComponent'>,\n componentId: string,\n): Promise<ComponentLlmData> => {\n const record = await rapi.getComponent(componentId);\n const definition = record.configuration\n ? objectOf(JSON.parse(record.configuration))\n : undefined;\n if (!definition) {\n throw new Error(\n `the definition of component '${componentId}' has no configuration`,\n );\n }\n const label = text(record.label);\n return { ...componentLlmData(definition), ...(label ? { label } : {}) };\n};\n\n/** Like fetchComponentLlmData, but a failed read gives empty LLM data. */\nexport const readComponentLlmData = async (\n rapi: Pick<RapiAccess, 'getComponent'>,\n componentId: string,\n): Promise<ComponentLlmData> => {\n try {\n return await fetchComponentLlmData(rapi, componentId);\n } catch (error) {\n console.warn(\n `[configurator-mcp] no LLM data for component '${componentId}'`,\n error,\n );\n return { skills: [], parameters: {} };\n }\n};\n\nconst numberOf = (value: CapabilityJson): number =>\n typeof value === 'number' || (typeof value === 'string' && value.trim())\n ? Number(value)\n : Number.NaN;\n\n// The kernel formats a decimal with at least two decimals (\"3000.00\"), so a\n// numeric value is compared after rounding to the decimals the kernel wrote.\nconst matchesValue = (\n type: string,\n definitionValue: CapabilityJson,\n kernelValue: string,\n): boolean => {\n if (!NUMERIC_TYPES.has(type)) {\n return String(definitionValue) === kernelValue;\n }\n const expected = numberOf(definitionValue);\n const actual = numberOf(kernelValue);\n const decimals = kernelValue.split('.')[1]?.length ?? 0;\n return (\n Number.isFinite(expected) &&\n Number.isFinite(actual) &&\n Number(expected.toFixed(decimals)) === actual\n );\n};\n\n/**\n * Adds the `llmData` of the definitions to the kernel parameters: per key and per value, the first\n * definition in the given order that has one. Parameters and values without `llmData` stay as they are.\n */\nexport const withParameterLlmData = (\n parameters: KernelParameter[],\n definitions: ComponentLlmData[],\n): LlmKernelParameter[] =>\n parameters.map((parameter) => {\n const declared = definitions.flatMap(({ parameters: byKey }) =>\n byKey[parameter.key] ? [byKey[parameter.key]] : [],\n );\n if (!declared.length) {\n return parameter;\n }\n const llmData = declared.find((entry) => entry.llmData)?.llmData;\n const values = declared.flatMap((entry) => entry.values);\n return {\n ...parameter,\n ...(llmData ? { llmData } : {}),\n validValues: parameter.validValues.map((value) => {\n const valueLlmData = values.find((entry) =>\n matchesValue(parameter.type, entry.value, value.value),\n )?.llmData;\n return valueLlmData ? { ...value, llmData: valueLlmData } : value;\n }),\n };\n });\n\n/** The distinct component ids of a parsed configuration tree, root first, depth first. */\nexport const configurationComponentIds = (\n configuration: CapabilityJsonObject,\n): string[] => {\n const ids: string[] = [];\n const visit = (node: CapabilityJsonObject) => {\n const id = text(node.componentId);\n if (id && !ids.includes(id)) {\n ids.push(id);\n }\n objectsOf(node.children).forEach(visit);\n };\n visit(configuration);\n return ids;\n};\n","import type { RapiAccess } from '../rapi-access';\nimport {\n componentLlmData,\n objectOf,\n objectsOf,\n text,\n type ComponentLlmData,\n} from './component-llm-data';\nimport type {\n CapabilityJson,\n CapabilityJsonObject,\n} from './configurator-capabilities-types';\n\n/** A component or item that a component definition names as a possible child. */\nexport interface ComponentModelChild {\n id: string;\n kind: 'component' | 'item';\n label?: string;\n /** The root component of an item child. */\n rootComponentId?: string;\n}\n\n/** What the agent gets of every component of the product: the static context of the system prompt. */\nexport interface ComponentShortModel {\n id: string;\n label?: string;\n llmData?: string;\n skills?: Array<{ name: string; description: string }>;\n children?: ComponentModelChild[];\n}\n\nexport interface ComponentModelValue {\n value: CapabilityJson;\n label?: string;\n llmData?: string;\n}\n\nexport interface ComponentModelParameter {\n key: string;\n label?: string;\n type?: string;\n unitType?: string;\n group?: string;\n defaultValue?: CapabilityJson;\n global?: boolean;\n llmData?: string;\n validValues?: ComponentModelValue[];\n validRange?: CapabilityJsonObject;\n}\n\n/** What the agent gets of one component on request: the short model and the parameters of the definition. */\nexport interface ComponentDetailedModel extends ComponentShortModel {\n parameterGroups?: Array<{ key: string; label?: string }>;\n parameters: ComponentModelParameter[];\n}\n\n/** The static context of a product: the short model of every component of its family, in walk order. */\nexport interface ProductContext {\n rootComponentId: string;\n components: ComponentShortModel[];\n}\n\nexport interface ProductFamilyComponent {\n id: string;\n label?: string;\n thumbnail?: string;\n definition: CapabilityJsonObject;\n llm: ComponentLlmData;\n}\n\nexport interface ProductFamilyItem {\n id: string;\n label?: string;\n thumbnail?: string;\n rootComponentId: string;\n assembly: CapabilityJsonObject;\n}\n\n/** The product family in walk order: the components breadth first from the root, and the items they reference. */\nexport interface ProductFamily {\n components: Map<string, ProductFamilyComponent>;\n items: Map<string, ProductFamilyItem>;\n}\n\nexport type ProductFamilyUnresolved = (\n resourceType: 'component' | 'item',\n id: string,\n error: unknown,\n) => void;\n\ntype FamilyRapi = Pick<RapiAccess, 'getComponent' | 'getItem'>;\ntype ChildLookup = (\n kind: ComponentModelChild['kind'],\n id: string,\n) => Pick<ComponentModelChild, 'label' | 'rootComponentId'> | undefined;\n\nconst RANGE_FIELDS = ['valueFrom', 'valueTo', 'step'];\n\nconst strings = (value: unknown): string[] =>\n Array.isArray(value)\n ? value.filter((entry): entry is string => !!text(entry))\n : [];\nconst detach = <T>(value: T): T => JSON.parse(JSON.stringify(value));\n\nconst parseDefinition = (configuration: unknown): CapabilityJsonObject => {\n const parsed =\n typeof configuration === 'string' && configuration\n ? objectOf(JSON.parse(configuration))\n : undefined;\n if (!parsed) {\n throw new Error('Missing or invalid configuration JSON');\n }\n return parsed;\n};\n\nconst familyComponent = (\n id: string,\n record: { label?: string; thumbnail?: string },\n definition: CapabilityJsonObject,\n): ProductFamilyComponent => {\n if (definition.id && definition.id !== id) {\n throw new Error('Component definition ID does not match requested ID');\n }\n const label = text(record.label);\n const thumbnail = text(record.thumbnail);\n return {\n id,\n ...(label ? { label } : {}),\n ...(thumbnail ? { thumbnail } : {}),\n definition,\n llm: componentLlmData(definition),\n };\n};\n\nconst childrenOf = (\n definition: CapabilityJsonObject,\n lookup: ChildLookup,\n): ComponentModelChild[] => {\n const children: ComponentModelChild[] = [];\n const seen = new Set<string>();\n const add = (kind: ComponentModelChild['kind'], value: unknown) => {\n const id = text(value);\n if (!id || seen.has(kind + ':' + id)) {\n return;\n }\n seen.add(kind + ':' + id);\n const known = lookup(kind, id);\n children.push({\n id,\n kind,\n ...(known?.label ? { label: known.label } : {}),\n ...(kind === 'item' && known?.rootComponentId\n ? { rootComponentId: known.rootComponentId }\n : {}),\n });\n };\n for (const child of objectsOf(definition.possibleChildren)) {\n add('component', child.componentId);\n add('item', child.itemId);\n }\n strings(definition.validChildren).forEach((id) => add('component', id));\n return children;\n};\n\nconst valueObjectCandidates = (value: unknown): ComponentModelValue[] =>\n objectsOf(value).flatMap((valueObject) => {\n if (valueObject.value === undefined) {\n return [];\n }\n const label = text(valueObject.label);\n const llmData = text(valueObject.llmData);\n return [\n {\n value: valueObject.value,\n ...(label ? { label } : {}),\n ...(llmData ? { llmData } : {}),\n },\n ];\n });\n\n// The candidates in the kernel's order: valueObjects, validValues,\n// localizedValues, conditionalValues. A value listed twice keeps its first\n// place and takes a label or llmData it lacks from the later entry.\nconst candidateValues = (\n parameter: CapabilityJsonObject,\n): ComponentModelValue[] => {\n const plainValues: ComponentModelValue[] = Array.isArray(\n parameter.validValues,\n )\n ? parameter.validValues\n .filter(\n (value): value is string | number | boolean =>\n value !== null && typeof value !== 'object',\n )\n .map((value) => ({ value }))\n : [];\n const candidates = new Map<CapabilityJson, ComponentModelValue>();\n for (const candidate of [\n ...valueObjectCandidates(parameter.valueObjects),\n ...plainValues,\n ...valueObjectCandidates(parameter.localizedValues),\n ...valueObjectCandidates(parameter.conditionalValues),\n ]) {\n const listed = candidates.get(candidate.value);\n candidates.set(\n candidate.value,\n listed ? { ...candidate, ...listed } : candidate,\n );\n }\n return [...candidates.values()];\n};\n\nconst parameterModel = (\n parameter: CapabilityJsonObject,\n): ComponentModelParameter | undefined => {\n const key = text(parameter.key);\n if (!key) {\n return undefined;\n }\n const validValues = candidateValues(parameter);\n const range = objectOf(parameter.validRange);\n const validRange = range\n ? Object.fromEntries(\n RANGE_FIELDS.filter((field) => range[field] !== undefined).map(\n (field) => [field, range[field]],\n ),\n )\n : undefined;\n const label = text(parameter.label);\n const type = text(parameter.type);\n const unitType = text(parameter.unitType);\n const group = text(parameter.group);\n const llmData = text(parameter.llmData);\n return {\n key,\n ...(label ? { label } : {}),\n ...(type ? { type } : {}),\n ...(unitType ? { unitType } : {}),\n ...(group ? { group } : {}),\n ...(parameter.defaultValue !== undefined\n ? { defaultValue: parameter.defaultValue }\n : {}),\n ...(parameter.global === true ? { global: true } : {}),\n ...(llmData ? { llmData } : {}),\n ...(validValues.length ? { validValues } : {}),\n ...(validRange && Object.keys(validRange).length ? { validRange } : {}),\n };\n};\n\n/** The short model of a component: id, label, LLM description, skill names and the children it can take. */\nexport const shortComponentModel = (\n { id, label, llm, definition }: ProductFamilyComponent,\n lookup: ChildLookup,\n): ComponentShortModel => {\n const children = childrenOf(definition, lookup);\n return detach({\n id,\n ...(label ? { label } : {}),\n ...(llm.llmData ? { llmData: llm.llmData } : {}),\n ...(llm.skills.length\n ? {\n skills: llm.skills.map(({ name, description }) => ({\n name,\n description,\n })),\n }\n : {}),\n ...(children.length ? { children } : {}),\n });\n};\n\n/** The detailed model of a component: the short model plus its parameter groups and parameters. */\nexport const detailedComponentModel = (\n component: ProductFamilyComponent,\n lookup: ChildLookup,\n): ComponentDetailedModel => {\n const { definition } = component;\n const parameterGroups = objectsOf(definition.parameterGroups).flatMap(\n (group) => {\n const key = text(group.key);\n const label = text(group.label);\n return key ? [{ key, ...(label ? { label } : {}) }] : [];\n },\n );\n return detach({\n ...shortComponentModel(component, lookup),\n ...(parameterGroups.length ? { parameterGroups } : {}),\n parameters: objectsOf(definition.parameters).flatMap((parameter) => {\n const model = parameterModel(parameter);\n return model ? [model] : [];\n }),\n });\n};\n\n/** The labels and item roots of the family, for the children of its models. */\nexport const familyLookup =\n (family: ProductFamily): ChildLookup =>\n (kind, id) => {\n if (kind === 'component') {\n const component = family.components.get(id);\n return component && { label: component.label };\n }\n const item = family.items.get(id);\n return item && { label: item.label, rootComponentId: item.rootComponentId };\n };\n\n/**\n * Walks the product family of a configuration as the agent needs it: the components of the\n * configuration and the seeds, then breadth first their possible children, sub-components, valid\n * children and the root components of the items they name, each definition read once. A read that\n * fails is reported and left out.\n */\nexport const collectProductFamily = async (\n rapi: FamilyRapi,\n configuration: CapabilityJsonObject,\n unresolved: ProductFamilyUnresolved,\n seeds: string[],\n): Promise<ProductFamily> => {\n const components = new Map<string, ProductFamilyComponent>();\n const items = new Map<string, ProductFamilyItem>();\n const seenComponents = new Set<string>();\n const seenItems = new Set<string>();\n const pendingComponents: string[] = [];\n const pendingItems: string[] = [];\n const queueComponent = (value: unknown) => {\n const id = text(value);\n if (id && !seenComponents.has(id)) {\n seenComponents.add(id);\n pendingComponents.push(id);\n }\n };\n const queueItem = (value: unknown) => {\n const id = text(value);\n if (id && !seenItems.has(id)) {\n seenItems.add(id);\n pendingItems.push(id);\n }\n };\n const seedAssembly = (assembly: CapabilityJsonObject) => {\n const nodes = [assembly];\n while (nodes.length) {\n const node = nodes.pop()!;\n queueComponent(node.componentId);\n nodes.push(...objectsOf(node.children));\n }\n };\n seeds.forEach(queueComponent);\n seedAssembly(configuration);\n while (pendingComponents.length || pendingItems.length) {\n const batch = pendingComponents.splice(0);\n const itemBatch = pendingItems.splice(0);\n const [definitions, assemblies] = await Promise.all([\n Promise.all(\n batch.map(async (id) => {\n try {\n const record = await rapi.getComponent(id);\n return familyComponent(\n id,\n record,\n parseDefinition(record.configuration),\n );\n } catch (error) {\n unresolved('component', id, error);\n return undefined;\n }\n }),\n ),\n Promise.all(\n itemBatch.map(async (id): Promise<ProductFamilyItem | undefined> => {\n try {\n const record = await rapi.getItem(id);\n const assembly = parseDefinition(record.configuration);\n const rootComponentId = text(assembly.componentId);\n if (!rootComponentId) {\n throw new Error('Item configuration has no root component ID');\n }\n const label = text(record.label);\n const thumbnail = text(record.thumbnail);\n return {\n id,\n ...(label ? { label } : {}),\n ...(thumbnail ? { thumbnail } : {}),\n rootComponentId,\n assembly,\n };\n } catch (error) {\n unresolved('item', id, error);\n return undefined;\n }\n }),\n ),\n ]);\n for (const component of definitions) {\n if (!component) {\n continue;\n }\n components.set(component.id, component);\n const { definition } = component;\n for (const child of [\n ...objectsOf(definition.possibleChildren),\n ...objectsOf(definition.subComponents),\n ]) {\n queueComponent(child.componentId);\n queueItem(child.itemId);\n }\n strings(definition.validChildren).forEach(queueComponent);\n }\n for (const item of assemblies) {\n if (!item) {\n continue;\n }\n items.set(item.id, item);\n seedAssembly(item.assembly);\n }\n }\n return { components, items };\n};\n\n/** The product context of a family: the short model of every component, in walk order. */\nexport const productContextOf = (\n family: ProductFamily,\n rootComponentId: string,\n): ProductContext => {\n const lookup = familyLookup(family);\n return {\n rootComponentId,\n components: [...family.components.values()].map((component) =>\n shortComponentModel(component, lookup),\n ),\n };\n};\n\n/**\n * Reads the detailed model of one component by its id, also of a component that is not in the\n * configuration. The direct children are read for their labels; a child RAPI cannot deliver keeps\n * its id only.\n */\nexport const readComponentDefinition = async (\n rapi: FamilyRapi,\n componentId: string,\n): Promise<ComponentDetailedModel> => {\n const record = await rapi.getComponent(componentId);\n const component = familyComponent(\n componentId,\n record,\n parseDefinition(record.configuration),\n );\n const known = new Map<\n string,\n Pick<ComponentModelChild, 'label' | 'rootComponentId'>\n >();\n await Promise.all(\n childrenOf(component.definition, () => undefined).map(\n async ({ id, kind }) => {\n try {\n if (kind === 'component') {\n const child = await rapi.getComponent(id);\n known.set(kind + ':' + id, { label: text(child.label) });\n } else {\n const item = await rapi.getItem(id);\n const assembly = parseDefinition(item.configuration);\n known.set(kind + ':' + id, {\n label: text(item.label),\n rootComponentId: text(assembly.componentId),\n });\n }\n } catch {\n /* The child keeps its id. */\n }\n },\n ),\n );\n return detailedComponentModel(component, (kind, id) =>\n known.get(kind + ':' + id),\n );\n};\n","import {\n CAPABILITY_SECTIONS,\n capabilitiesIncludeSchema,\n} from './configuration-operation-schemas';\nimport type ConfiguratorKernelAccess from '../configurator-kernel-access';\nimport type ConfiguratorContext from '../webgl/configurator-context';\nimport type { RapiAccess } from '../rapi-access';\nimport { BASE_CONTEXT } from '../main';\nimport type {\n KernelParameter,\n KernelParameterGroup,\n} from '../../../typings/kernel';\nimport type { RapiMaterial } from '../../../typings/rapi-types';\nimport {\n configurationComponentIds,\n withParameterLlmData,\n type ComponentLlmData,\n} from './component-llm-data';\nimport {\n collectProductFamily,\n detailedComponentModel,\n familyLookup,\n type ComponentModelParameter,\n} from './component-models';\nimport type {\n CapabilityJson,\n CapabilityJsonObject,\n ConfiguratorCapabilities,\n ConfiguratorCapabilityContext,\n ConfiguratorCapabilityInstance,\n ConfiguratorCapabilitySection,\n} from './configurator-capabilities-types';\n\nconst detach = <T>(value: T): T => JSON.parse(JSON.stringify(value));\nconst detachParameters = (parameters: KernelParameter[]): KernelParameter[] =>\n parameters.map((parameter) =>\n detach({\n ...parameter,\n ...(parameter.viewType\n ? { viewType: { value: parameter.viewType.value } }\n : {}),\n }),\n );\nconst object = (value: unknown): CapabilityJsonObject | undefined =>\n value !== null && typeof value === 'object' && !Array.isArray(value)\n ? (value as CapabilityJsonObject)\n : undefined;\nconst objects = (value: CapabilityJson | undefined): CapabilityJsonObject[] =>\n Array.isArray(value)\n ? value\n .map(object)\n .filter((entry): entry is CapabilityJsonObject => !!entry)\n : [];\nconst strings = (value: CapabilityJson | undefined): string[] =>\n Array.isArray(value)\n ? value.filter(\n (entry): entry is string => typeof entry === 'string' && !!entry,\n )\n : [];\nconst project = (source: object, keys: string[]): CapabilityJsonObject => {\n const entries = Object.entries(source).filter(\n ([key, value]) => keys.includes(key) && value !== undefined,\n );\n return detach(Object.fromEntries(entries));\n};\nconst parseConfiguration = (\n value: string | undefined,\n): CapabilityJsonObject => {\n const parsed = value && object(JSON.parse(value));\n if (!parsed) {\n throw new Error('Missing or invalid configuration JSON');\n }\n return parsed;\n};\nconst childIds = (value: unknown): number[] => {\n if (Array.isArray(value)) {\n return [...value];\n }\n const list = value as { size(): number; get(index: number): number };\n return Array.from({ length: list.size() }, (_, i) => list.get(i));\n};\n\ntype Unresolved = (\n resourceType: ConfiguratorCapabilities['unresolved'][number]['resourceType'],\n id: string,\n error: unknown,\n) => void;\n\nconst discoverProductFamily = async (\n rapi: RapiAccess,\n configuration: CapabilityJsonObject,\n instances: ConfiguratorCapabilityInstance[],\n unresolved: Unresolved,\n) => {\n const family = await collectProductFamily(\n rapi,\n configuration,\n unresolved,\n instances.map((instance) => instance.componentId),\n );\n const lookup = familyLookup(family);\n const components: NonNullable<ConfiguratorCapabilities['components']> = {};\n const items: NonNullable<ConfiguratorCapabilities['items']> = {};\n const declaredByComponent: Record<string, ComponentModelParameter[]> = {};\n const declaredRawParameters: Record<string, CapabilityJsonObject[]> = {};\n const llmDataByComponent: Record<string, ComponentLlmData> = {};\n for (const [id, component] of family.components) {\n const model = detailedComponentModel(component, lookup);\n components[id] = model;\n declaredByComponent[id] = model.parameters;\n declaredRawParameters[id] = objects(component.definition.parameters);\n llmDataByComponent[id] = component.llm;\n }\n for (const [id, item] of family.items) {\n items[id] = {\n ...(item.label ? { label: item.label } : {}),\n ...(item.thumbnail ? { thumbnail: item.thumbnail } : {}),\n rootComponentId: item.rootComponentId,\n };\n }\n return {\n components,\n items,\n declaredByComponent,\n declaredRawParameters,\n llmDataByComponent,\n };\n};\n\nconst collectMaterials = async (\n rapi: RapiAccess,\n declaredByComponent: Record<string, CapabilityJsonObject[]>,\n current: NonNullable<ConfiguratorCapabilities['parameters']>['current'],\n unresolved: Unresolved,\n): Promise<NonNullable<ConfiguratorCapabilities['materials']>> => {\n const materials: NonNullable<ConfiguratorCapabilities['materials']> = {\n byId: {},\n groups: {},\n };\n const materialIds = new Set<string>();\n const groupIds = new Set<string>();\n const addId = (set: Set<string>, id: unknown) => {\n if (typeof id === 'string' && id) {\n set.add(id);\n }\n };\n const collectParameter = (parameter: CapabilityJsonObject) => {\n if (parameter.type !== 'Material') {\n return;\n }\n addId(materialIds, parameter.value);\n addId(materialIds, parameter.defaultValue);\n if (Array.isArray(parameter.validValues)) {\n for (const value of parameter.validValues) {\n addId(materialIds, object(value)?.value ?? value);\n }\n }\n for (const key of [\n 'valueObjects',\n 'localizedValues',\n 'conditionalValues',\n ]) {\n objects(parameter[key]).forEach((value) =>\n addId(materialIds, value.value),\n );\n }\n strings(parameter.validGroups).forEach((id) => groupIds.add(id));\n objects(parameter.conditionalGroups).forEach((group) =>\n addId(groupIds, group.value),\n );\n };\n Object.values(declaredByComponent).flat().forEach(collectParameter);\n const currentParameters: KernelParameter[] = [\n ...current.global.parameters,\n ...Object.values(current.byComponent).flatMap((value) => value.parameters),\n ];\n currentParameters.forEach((parameter) =>\n collectParameter(\n project(parameter, ['type', 'value', 'validValues', 'validGroups']),\n ),\n );\n const addMaterial = (material: RapiMaterial) => {\n materials.byId[material.id] = project(material, [\n 'id',\n 'name',\n 'label',\n 'thumbnail',\n 'color',\n 'active',\n 'group',\n 'groupLabel',\n 'tags',\n ]);\n if (material.shading?.basecolor !== undefined) {\n materials.byId[material.id].shading = project(material.shading, [\n 'basecolor',\n ]);\n }\n };\n await Promise.all(\n [...groupIds].map(async (id) => {\n try {\n const online = navigator.onLine;\n const groups = await rapi.getMaterialsByGroup([id]);\n const matched = groups.find(\n (group) => group.id === id || group.legacyId === id,\n );\n const members = groups.flatMap((group) =>\n group.materials.filter(\n (material) =>\n group === matched ||\n material.group === id ||\n material.tags?.includes(id),\n ),\n );\n members.forEach(addMaterial);\n const legacyMaterial = members.find(\n (material) => material.group === id,\n );\n const label = matched?.label ?? legacyMaterial?.groupLabel;\n const legacyId = matched?.legacyId ?? (legacyMaterial ? id : undefined);\n materials.groups[id] = {\n id,\n ...(label ? { label } : {}),\n ...(legacyId ? { legacyId } : {}),\n materialIds: [...new Set(members.map((material) => material.id))],\n };\n if (!online || !navigator.onLine) {\n unresolved(\n 'materialGroup',\n id,\n 'Offline material group coverage cannot be established',\n );\n }\n } catch (error) {\n unresolved('materialGroup', id, error);\n }\n }),\n );\n const missingIds = [...materialIds].filter((id) => !materials.byId[id]);\n if (missingIds.length) {\n try {\n (await rapi.getMaterials(missingIds)).forEach(addMaterial);\n missingIds\n .filter((id) => !materials.byId[id])\n .forEach((id) =>\n unresolved('material', id, 'Material metadata unavailable'),\n );\n } catch (error) {\n missingIds.forEach((id) => unresolved('material', id, error));\n }\n }\n return materials;\n};\n\nexport const collectConfiguratorCapabilities = async (\n context: ConfiguratorContext,\n access: ConfiguratorKernelAccess,\n rapi: RapiAccess,\n include?: ConfiguratorCapabilitySection[],\n): Promise<ConfiguratorCapabilities> => {\n const parsed = capabilitiesIncludeSchema.safeParse(include ?? undefined);\n if (!parsed.success) {\n throw new Error('Unknown configurator capability section');\n }\n const sections = new Set(\n parsed.data?.length ? parsed.data : CAPABILITY_SECTIONS,\n );\n const kernel = access.kernelInstance;\n const captureContext = (): ConfiguratorCapabilityContext => {\n if (\n context.baseContext !== BASE_CONTEXT.CONFIGURATOR ||\n !context.configurationRuntimeId\n ) {\n throw new Error(\n 'Load a configuration or enter planner isolation before reading configurator capabilities',\n );\n }\n if (kernel.isExternalPlanObject(context.configurationRuntimeId)) {\n throw new Error(\n 'Use the HI external-object API to read capabilities of an external configuration',\n );\n }\n const rootRuntimeId = kernel.getRootPlanComponentIdFromObjectId(\n context.configurationRuntimeId,\n );\n if (!rootRuntimeId) {\n throw new Error(\n 'No active root component; load a configuration before reading capabilities',\n );\n }\n return {\n configurationRuntimeId: context.configurationRuntimeId,\n rootRuntimeId,\n rootComponentId: kernel.getComponentId(rootRuntimeId),\n selectedRuntimeIds: [...context.selectedRuntimeComponentIds],\n configurationHash: access.getCurrentConfigurationHash(\n context.configurationRuntimeId,\n ),\n };\n };\n const captured = captureContext();\n const rootAsGlobal = context.rootComponentParametersAsGlobal;\n const contextRootId = context.rootComponentId;\n const assertFresh = () => {\n try {\n if (\n JSON.stringify(captureContext()) === JSON.stringify(captured) &&\n rootAsGlobal === context.rootComponentParametersAsGlobal &&\n contextRootId === context.rootComponentId\n ) {\n return;\n }\n } catch {\n /* A target that disappeared also invalidates the captured read. */\n }\n throw new Error(\n 'Configuration or selection changed while reading capabilities; read again',\n );\n };\n const result: ConfiguratorCapabilities = {\n context: captured,\n complete: true,\n unresolved: [],\n };\n const unresolved = (\n resourceType: ConfiguratorCapabilities['unresolved'][number]['resourceType'],\n id: string,\n error: unknown,\n ) => {\n result.complete = false;\n result.unresolved.push({\n resourceType,\n id,\n sections: [...sections].filter(\n (section) =>\n section !== 'configuration' &&\n (!resourceType.startsWith('material') || section === 'materials'),\n ),\n reason: error instanceof Error ? error.message : String(error),\n });\n };\n const configuration = parseConfiguration(\n access.getSerializedConfiguration(captured.configurationRuntimeId),\n );\n const instances: ConfiguratorCapabilityInstance[] = [];\n const current: NonNullable<\n ConfiguratorCapabilities['parameters']\n >['current'] = {\n global: {\n scope: rootAsGlobal ? 'rootComponent' : 'planObject',\n parameters: [],\n groups: [],\n },\n byComponent: {},\n };\n const docking: NonNullable<ConfiguratorCapabilities['docking']> = {\n current: { globalPossibleChildren: [], byComponent: {} },\n };\n const needsParameters =\n sections.has('parameters') || sections.has('materials');\n const reads: Array<Promise<void>> = [];\n const pendingRuntimeIds = [captured.rootRuntimeId];\n const visitedRuntimeIds = new Set<number>();\n while (pendingRuntimeIds.length) {\n const runtimeId = pendingRuntimeIds.shift()!;\n if (visitedRuntimeIds.has(runtimeId)) {\n continue;\n }\n visitedRuntimeIds.add(runtimeId);\n const component = kernel.getComponent(runtimeId);\n const componentId = kernel.getComponentId(runtimeId);\n const childRuntimeIds = childIds(component.childIds);\n instances.push({\n runtimeId,\n componentId,\n parentRuntimeId: component.parentId || null,\n childRuntimeIds,\n });\n pendingRuntimeIds.push(...childRuntimeIds);\n if (needsParameters) {\n const groups = detach(component.parameterGroups);\n reads.push(\n access.getComponentParameters(runtimeId).then((parameters) => {\n current.byComponent[runtimeId] = {\n componentId,\n groups,\n parameters: detachParameters(parameters),\n };\n }),\n );\n }\n if (sections.has('docking')) {\n docking.current.byComponent[runtimeId] = detach(\n kernel.getPlanComponentPossibleChildren(runtimeId),\n );\n }\n }\n if (needsParameters) {\n const globalDefinition = rootAsGlobal\n ? kernel.getComponent(captured.rootRuntimeId)\n : kernel.getPlanObject(captured.configurationRuntimeId);\n current.global.groups = detach(\n (globalDefinition.parameterGroups ?? []) as KernelParameterGroup[],\n );\n reads.push(\n access\n .getGlobalParameters(captured.configurationRuntimeId, rootAsGlobal)\n .then((parameters) => {\n current.global.parameters = detachParameters(parameters);\n }),\n );\n }\n if (sections.has('docking')) {\n docking.current.globalPossibleChildren = detach(\n kernel.getPlanObjectPossibleChildren(captured.configurationRuntimeId),\n );\n }\n await Promise.all(reads);\n assertFresh();\n if (sections.has('configuration')) {\n result.configuration = { data: configuration, instances };\n }\n if (sections.size === 1 && sections.has('configuration')) {\n return result;\n }\n\n const {\n components,\n items,\n declaredByComponent,\n declaredRawParameters,\n llmDataByComponent,\n } = await discoverProductFamily(rapi, configuration, instances, unresolved);\n if (sections.has('components')) {\n result.components = components;\n }\n if (sections.has('items')) {\n result.items = items;\n }\n if (sections.has('parameters')) {\n const llmDataOf = (componentId: string) =>\n llmDataByComponent[componentId] ? [llmDataByComponent[componentId]] : [];\n for (const entry of Object.values(current.byComponent)) {\n entry.parameters = withParameterLlmData(\n entry.parameters,\n llmDataOf(entry.componentId),\n );\n }\n current.global.parameters = withParameterLlmData(\n current.global.parameters,\n configurationComponentIds(configuration).flatMap(llmDataOf),\n );\n result.parameters = { declaredByComponent, current };\n }\n if (sections.has('docking')) {\n result.docking = docking;\n }\n\n if (sections.has('materials')) {\n result.materials = await collectMaterials(\n rapi,\n declaredRawParameters,\n current,\n unresolved,\n );\n }\n assertFresh();\n return result;\n};\n"],"mappings":";;;;AAyCA,IAAM,IAAqC,IAAI,IAAI,CACjD,EAAsB,SACtB,EAAsB,QACvB,CAAC,EAEW,KAAQ,MACnB,OAAO,KAAU,YAAY,EAAM,MAAM,GAAG,IAAQ,KAAA,GACzC,KAAY,MACL,OAAO,KAAU,YAAnC,KAA+C,CAAC,MAAM,QAAQ,EAAM,GAC/D,IACD,KAAA,GACO,KAAa,MACxB,MAAM,QAAQ,EAAM,GAChB,EACG,IAAI,EAAS,CACb,QAAQ,MAAyC,CAAC,CAAC,EAAM,GAC5D,EAAE,EAEF,KACJ,MACiC;CACjC,IAAM,IAAU,EAAK,EAAU,QAAQ,EACjC,IAAS,EAAU,EAAU,aAAa,CAAC,SAAS,MAAgB;EACxE,IAAM,IAAe,EAAK,EAAY,QAAQ;AAC9C,SAAO,KAAgB,EAAY,UAAU,KAAA,IACzC,CAAC;GAAE,OAAO,EAAY;GAAO,SAAS;GAAc,CAAC,GACr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AAM,QAAQ,IAAI,EAAM,EACxB,GAAa,EACT,EAAS,IAAI,gBAAgB,KAC/B,EAAO,gBAAgB;EAAE,MAAM;EAAe;EAAW,GAEvD,EAAS,SAAS,KAAK,EAAS,IAAI,gBAAgB,CACtD,QAAO;CAGT,IAAM,EACJ,eACA,UACA,wBACA,0BACA,0BACE,MAAM,EAAsB,GAAM,GAAe,GAAW,EAAW;AAO3E,KANI,EAAS,IAAI,aAAa,KAC5B,EAAO,aAAa,IAElB,EAAS,IAAI,QAAQ,KACvB,EAAO,QAAQ,IAEb,EAAS,IAAI,aAAa,EAAE;EAC9B,IAAM,KAAa,MACjB,EAAmB,KAAe,CAAC,EAAmB,GAAa,GAAG,EAAE;AAC1E,OAAK,IAAM,KAAS,OAAO,OAAO,EAAQ,YAAY,CACpD,GAAM,aAAa,EACjB,EAAM,YACN,EAAU,EAAM,YAAY,CAC7B;AAMH,EAJA,EAAQ,OAAO,aAAa,EAC1B,EAAQ,OAAO,YACf,EAA0B,EAAc,CAAC,QAAQ,EAAU,CAC5D,EACD,EAAO,aAAa;GAAE;GAAqB;GAAS;;AAetD,QAbI,EAAS,IAAI,UAAU,KACzB,EAAO,UAAU,IAGf,EAAS,IAAI,YAAY,KAC3B,EAAO,YAAY,MAAM,EACvB,GACA,GACA,GACA,EACD,GAEH,GAAa,EACN"}
@@ -1,6 +1,6 @@
1
1
 
2
- import { F as e, H as t, L as n, M as r, N as i, at as a, dt as o, ft as s, j as c, mt as l, n as u, nt as d, ot as f, x as p, yt as m, z as h } from "./roomle-sdk-ByoTm5M6.mjs";
3
- import { t as g } from "./script-loader-DGVS2Wqe.mjs";
2
+ import { F as e, H as t, L as n, M as r, N as i, at as a, dt as o, ft as s, j as c, mt as l, n as u, nt as d, ot as f, x as p, yt as m, z as h } from "./roomle-sdk-8VVPfbDD.mjs";
3
+ import { t as g } from "./script-loader-BbtPLVDR.mjs";
4
4
  import { t as _ } from "./component-raycast-helper-CMFpSJXC.mjs";
5
5
  //#region packages/configurator-core/src/utils/injectables.ts
6
6
  var v = [
@@ -43,4 +43,4 @@ var v = [
43
43
  //#endregion
44
44
  export { y as t };
45
45
 
46
- //# sourceMappingURL=configurator-CU7jNdgC.mjs.map
46
+ //# sourceMappingURL=configurator-tOyOfDMx.mjs.map