@roomle/web-sdk 7.0.0-alpha.1 → 7.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.txt +2 -2
- package/lib/{BufferGeometry-CzBRCIk3.mjs → BufferGeometry-YaAhwXNX.mjs} +2 -2
- package/lib/{BufferGeometry-CzBRCIk3.mjs.map → BufferGeometry-YaAhwXNX.mjs.map} +1 -1
- package/lib/ConfiguratorKernel.wasm +0 -0
- package/lib/{Object3D-Bkmul_of.mjs → Object3D-Dx0HN7Wz.mjs} +1 -1
- package/lib/{Object3D-Bkmul_of.mjs.map → Object3D-Dx0HN7Wz.mjs.map} +1 -1
- package/lib/{PointLightHelper-DOW-3Hvn.mjs → PointLightHelper-B8k3nJVr.mjs} +4 -4
- package/lib/{PointLightHelper-DOW-3Hvn.mjs.map → PointLightHelper-B8k3nJVr.mjs.map} +1 -1
- package/lib/RoomleCore.wasm +0 -0
- package/lib/RoomleToolsCore.wasm +0 -0
- package/lib/{SpotLightHelper-sE9yZPeq.mjs → SpotLightHelper-jqI3QyNE.mjs} +3 -3
- package/lib/{SpotLightHelper-sE9yZPeq.mjs.map → SpotLightHelper-jqI3QyNE.mjs.map} +1 -1
- package/lib/{USDZExporter-zhEk6F4K.mjs → USDZExporter-BS1qa3HO.mjs} +2 -2
- package/lib/{USDZExporter-zhEk6F4K.mjs.map → USDZExporter-BS1qa3HO.mjs.map} +1 -1
- package/lib/{Vector4-CmUR_DSp.mjs → Vector4-BmWb-htx.mjs} +2 -2
- package/lib/{Vector4-CmUR_DSp.mjs.map → Vector4-BmWb-htx.mjs.map} +1 -1
- package/lib/{api-1YHSF8TD.mjs → api-DOHbOr7K.mjs} +2 -2
- package/lib/{api-1YHSF8TD.mjs.map → api-DOHbOr7K.mjs.map} +1 -1
- package/lib/asset-loader.worker-Bdvb-pt7.mjs.map +1 -1
- package/lib/budgeteer.sw-ByZxiRBr.mjs.map +1 -1
- package/lib/{common-utils-DZiN8bjs.mjs → common-utils-zPOllvAT.mjs} +3 -2
- package/lib/common-utils-zPOllvAT.mjs.map +1 -0
- package/lib/{component-raycast-helper-BSFG09WY.mjs → component-raycast-helper-CMFpSJXC.mjs} +3 -3
- package/lib/{component-raycast-helper-BSFG09WY.mjs.map → component-raycast-helper-CMFpSJXC.mjs.map} +1 -1
- package/lib/{configuration-operations-DI677LMN.mjs → configuration-operations-DJD9A1xP.mjs} +38 -38
- package/lib/{configuration-operations-DI677LMN.mjs.map → configuration-operations-DJD9A1xP.mjs.map} +1 -1
- package/lib/configurator-D5Ehj649.mjs +3 -0
- package/lib/configurator-DCynrn7X.mjs +46 -0
- package/lib/{configurator-CgFJ2voV.mjs.map → configurator-DCynrn7X.mjs.map} +1 -1
- package/lib/{configurator-capabilities-CLqul800.mjs → configurator-capabilities-BfSMwdWh.mjs} +12 -12
- package/lib/{configurator-capabilities-CLqul800.mjs.map → configurator-capabilities-BfSMwdWh.mjs.map} +1 -1
- package/lib/configurator-capabilities-DAJuxSTw.mjs +3 -0
- package/lib/{fflate.module-CpWr9KGw.mjs → fflate.module-BfCRKtjc.mjs} +1 -1
- package/lib/{fflate.module-CpWr9KGw.mjs.map → fflate.module-BfCRKtjc.mjs.map} +1 -1
- package/lib/{glb-viewer-B2WH46su.mjs → glb-viewer-BhiCqjpE.mjs} +24 -24
- package/lib/{glb-viewer-B2WH46su.mjs.map → glb-viewer-BhiCqjpE.mjs.map} +1 -1
- package/lib/glb-viewer-BrggGLte.mjs +3 -0
- package/lib/{hi-mcp-server-tVF1bn28.mjs → hi-mcp-server-rSu1HL4m.mjs} +2 -2
- package/lib/{hi-mcp-server-tVF1bn28.mjs.map → hi-mcp-server-rSu1HL4m.mjs.map} +1 -1
- package/lib/{highlight-coordinator-CiBzWsMf.mjs → highlight-coordinator-DbqhP7Hy.mjs} +3 -3
- package/lib/{highlight-coordinator-CiBzWsMf.mjs.map → highlight-coordinator-DbqhP7Hy.mjs.map} +1 -1
- package/lib/{homag-intelligence-CdYda0Mb.mjs → homag-intelligence-DuFtYgdG.mjs} +3 -3
- package/lib/{homag-intelligence-CdYda0Mb.mjs.map → homag-intelligence-DuFtYgdG.mjs.map} +1 -1
- package/lib/{material-viewer-BrARE0p0.mjs → material-viewer-uEDqIbCx.mjs} +25 -21
- package/lib/material-viewer-uEDqIbCx.mjs.map +1 -0
- package/lib/{packages-DhBz4dX3.mjs → packages-DOCmEOxI.mjs} +6 -6
- package/lib/{packages-DhBz4dX3.mjs.map → packages-DOCmEOxI.mjs.map} +1 -1
- package/lib/planner-B9GbQLSB.mjs +3 -0
- package/lib/{planner-SRvOM5ZQ.mjs → planner-D8UVNfkJ.mjs} +16 -16
- package/lib/{planner-SRvOM5ZQ.mjs.map → planner-D8UVNfkJ.mjs.map} +1 -1
- package/lib/roomle-headless.d.ts +14 -18
- package/lib/roomle-headless.js +35 -32
- package/lib/roomle-headless.js.map +1 -1
- package/lib/{roomle-sdk-Sdrd7K0F.mjs → roomle-sdk-C0YpFZdj.mjs} +24740 -24770
- package/lib/roomle-sdk-C0YpFZdj.mjs.map +1 -0
- package/lib/roomle-sdk.d.ts +14 -18
- package/lib/roomle-sdk.js +9 -9
- package/lib/{roomle-webgpu-renderer-CWoN5YzU.mjs → roomle-webgpu-renderer-DZ9LaZfc.mjs} +3 -3
- package/lib/{roomle-webgpu-renderer-CWoN5YzU.mjs.map → roomle-webgpu-renderer-DZ9LaZfc.mjs.map} +1 -1
- package/lib/{scene-renderer-CsbP23gu.mjs → scene-renderer-BmtXHWEw.mjs} +3 -3
- package/lib/{scene-renderer-CsbP23gu.mjs.map → scene-renderer-BmtXHWEw.mjs.map} +1 -1
- package/lib/{script-loader-D9Tr-8LN.mjs → script-loader-jRBMP-ca.mjs} +2 -2
- package/lib/{script-loader-D9Tr-8LN.mjs.map → script-loader-jRBMP-ca.mjs.map} +1 -1
- package/lib/{shading-settings-mnQRn2LO.mjs → shading-settings-CpXZmOnx.mjs} +2 -2
- package/lib/{shading-settings-mnQRn2LO.mjs.map → shading-settings-CpXZmOnx.mjs.map} +1 -1
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/package.json +1 -1
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
- package/lib/{stats-helper-Q25NjvCQ.mjs → stats-helper-jzrLyoHV.mjs} +2 -2
- package/lib/{stats-helper-Q25NjvCQ.mjs.map → stats-helper-jzrLyoHV.mjs.map} +1 -1
- package/lib/{threejs-utils-C3CWKZXa.mjs → threejs-utils-D1gtvxiA.mjs} +7 -15
- package/lib/{threejs-utils-C3CWKZXa.mjs.map → threejs-utils-D1gtvxiA.mjs.map} +1 -1
- package/lib/{tools-core-BBYYzygJ.mjs → tools-core-k93qrqfB.mjs} +6 -6
- package/lib/{tools-core-BBYYzygJ.mjs.map → tools-core-k93qrqfB.mjs.map} +1 -1
- package/lib/{util-BdWrqTeC.mjs → util-LmkV26fg.mjs} +1 -1
- package/lib/{util-BdWrqTeC.mjs.map → util-LmkV26fg.mjs.map} +1 -1
- package/package.json +2 -2
- package/sbom.cdx.json +5 -5
- package/lib/common-utils-DZiN8bjs.mjs.map +0 -1
- package/lib/configurator-AwPowYQR.mjs +0 -3
- package/lib/configurator-CgFJ2voV.mjs +0 -46
- package/lib/configurator-capabilities-Dg8oD49T.mjs +0 -3
- package/lib/glb-viewer-sxVA5IgD.mjs +0 -3
- package/lib/material-viewer-BrARE0p0.mjs.map +0 -1
- package/lib/planner-D6uV0kCw.mjs +0 -3
- package/lib/roomle-sdk-Sdrd7K0F.mjs.map +0 -1
package/lib/{configuration-operations-DI677LMN.mjs.map → configuration-operations-DJD9A1xP.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration-operations-DI677LMN.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.dockComponent(\n operation.parentId,\n operation.parentDockId,\n operation.runtimeId,\n operation.childDockId,\n operation.position,\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,I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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"}
|
|
1
|
+
{"version":3,"file":"configuration-operations-DJD9A1xP.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.dockComponent(\n operation.parentId,\n operation.parentDockId,\n operation.runtimeId,\n operation.childDockId,\n operation.position,\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 Config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QxD,QAAO,EACL;EACE;EACA;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,46 @@
|
|
|
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-C0YpFZdj.mjs";
|
|
3
|
+
import { t as g } from "./script-loader-jRBMP-ca.mjs";
|
|
4
|
+
import { t as _ } from "./component-raycast-helper-CMFpSJXC.mjs";
|
|
5
|
+
//#region packages/configurator-core/src/utils/injectables.ts
|
|
6
|
+
var v = [
|
|
7
|
+
new s("logger", f),
|
|
8
|
+
new s("rapi-access", l),
|
|
9
|
+
new s("script-loader", g),
|
|
10
|
+
new s("camera-control-3d", e),
|
|
11
|
+
new s("camera-control", n),
|
|
12
|
+
new s("global-init-data", d),
|
|
13
|
+
new s("data-syncer", a),
|
|
14
|
+
new s("configurator-scene-manager", p, o.CONTEXT),
|
|
15
|
+
new s("configurator-view-model", i, o.CONTEXT),
|
|
16
|
+
new s("component-raycast-helper", _, o.GLOBAL)
|
|
17
|
+
], y = class extends r {
|
|
18
|
+
setupDependencies() {
|
|
19
|
+
u.setup(v), this.lookup("planner-kernel-access", this._context).init(t.CONFIGURATOR), this.lookup("rapi-access", this._context), this.lookup("script-loader", this._context), this.lookup("logger", this._context);
|
|
20
|
+
}
|
|
21
|
+
cleanUpGlobals() {
|
|
22
|
+
delete window.RoomleConfigurator;
|
|
23
|
+
}
|
|
24
|
+
cleanUpDependencies() {
|
|
25
|
+
let e = this.lookup("script-loader"), t = this.lookup("rapi-access");
|
|
26
|
+
this.lookup("dom-helper");
|
|
27
|
+
let n = this.lookup("configurator-scene-manager");
|
|
28
|
+
e && e.cleanUp(), t && t.cleanUp(), n && n.cleanUp();
|
|
29
|
+
}
|
|
30
|
+
setupGlobals(e) {
|
|
31
|
+
m.init(e ?? {});
|
|
32
|
+
}
|
|
33
|
+
getApi() {
|
|
34
|
+
return this._configurator;
|
|
35
|
+
}
|
|
36
|
+
async bootFinished() {
|
|
37
|
+
this._configurator = new h(this._context), this._configurator.getMain = () => this, window.RoomleConfigurator || (window.RoomleConfigurator = this._configurator);
|
|
38
|
+
}
|
|
39
|
+
getContextName() {
|
|
40
|
+
return c.CONFIGURATOR;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { y as t };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=configurator-DCynrn7X.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurator-
|
|
1
|
+
{"version":3,"file":"configurator-DCynrn7X.mjs","names":[],"sources":["../../packages/configurator-core/src/utils/injectables.ts","../../packages/configurator-core/src/configurator.ts"],"sourcesContent":["import CameraControl from '../../../common-core/src/cameracontrol/camera-control';\nimport CameraControl3D from '../../../common-core/src/cameracontrol/camera-control-3d';\nimport ScriptLoader from '../../../common-core/src/script-loader';\nimport { RapiAccess } from '../../../common-core/src/rapi-access';\nimport Logger from '../../../common-core/src/logger';\nimport DataSyncer from '../../../common-core/src/services/data-syncer';\nimport {\n DependencyInjectionAssignment,\n DI_TYPE,\n} from '../../../common-core/src/di/container';\nimport ComponentRaycastHelper from './component-raycast-helper';\nimport ConfiguratorSceneManager from '../webgl/configurator-scene-manager';\nimport ConfiguratorViewModel from '../../../common-core/src/view-model/configurator-view-model';\nimport GlobalInitData from '../../../common-core/src/utils/global-init-data';\n\nexport const INJECTABLES: DependencyInjectionAssignment[] = [\n new DependencyInjectionAssignment('logger', Logger),\n new DependencyInjectionAssignment('rapi-access', RapiAccess),\n new DependencyInjectionAssignment('script-loader', ScriptLoader),\n new DependencyInjectionAssignment('camera-control-3d', CameraControl3D),\n new DependencyInjectionAssignment('camera-control', CameraControl),\n new DependencyInjectionAssignment('global-init-data', GlobalInitData),\n new DependencyInjectionAssignment('data-syncer', DataSyncer),\n new DependencyInjectionAssignment(\n 'configurator-scene-manager',\n ConfiguratorSceneManager,\n DI_TYPE.CONTEXT,\n ),\n new DependencyInjectionAssignment(\n 'configurator-view-model',\n ConfiguratorViewModel,\n DI_TYPE.CONTEXT,\n ),\n new DependencyInjectionAssignment(\n 'component-raycast-helper',\n ComponentRaycastHelper,\n DI_TYPE.GLOBAL,\n ),\n];\n","import './utils/global-definitions';\nimport { Main, BASE_CONTEXT } from '../../common-core/src/main';\nimport type { AppState } from '../../common-core/src/utils/app-context';\nimport ConfiguratorAppContext from '../../common-core/src/utils/app-context';\nimport { INJECTABLES } from './utils/injectables';\nimport RoomleDependencyInjection from '../../common-core/src/di/roomle-dependency-injection';\nimport type ScriptLoader from '../../common-core/src/script-loader';\nimport { type RapiAccess } from '../../common-core/src/rapi-access';\nimport type Logger from '../../common-core/src/logger';\nimport type DomHelper from '../../common-core/src/utils/dom-helper';\nimport type ConfiguratorSceneManager from './webgl/configurator-scene-manager';\nimport { RoomleConfigurator } from './roomle-configurator';\nimport type PlannerKernelAccess from '../../planner-core/src/services/planner-kernel-access';\nimport { KERNEL_TYPE } from '../../common-core/src/services/common-kernel-access';\n\nexport class Configurator extends Main {\n private _configurator: RoomleConfigurator;\n\n protected setupDependencies(): void {\n RoomleDependencyInjection.setup(INJECTABLES);\n // This needs to be done so that subscribe to events is done\n const plannerKernelAccess = this.lookup<PlannerKernelAccess>(\n 'planner-kernel-access',\n this._context,\n );\n plannerKernelAccess.init(KERNEL_TYPE.CONFIGURATOR);\n this.lookup<RapiAccess>('rapi-access', this._context);\n this.lookup<ScriptLoader>('script-loader', this._context);\n this.lookup<Logger>('logger', this._context);\n }\n\n protected cleanUpGlobals(): void {\n delete window.RoomleConfigurator;\n }\n\n protected cleanUpDependencies(): void {\n const scriptLoader = this.lookup<ScriptLoader>('script-loader');\n const rapiAccess = this.lookup<RapiAccess>('rapi-access');\n const domHelper = this.lookup<DomHelper>('dom-helper');\n const sceneManager = this.lookup<ConfiguratorSceneManager>(\n 'configurator-scene-manager',\n );\n\n if (scriptLoader) {\n scriptLoader.cleanUp();\n }\n\n if (rapiAccess) {\n rapiAccess.cleanUp();\n }\n\n if (domHelper) {\n //domHelper.cleanUp();\n }\n\n if (sceneManager) {\n sceneManager.cleanUp();\n }\n }\n\n /** Currently the only module that uses AppState — all others ignore the parameter. */\n protected setupGlobals(appState?: AppState): void {\n ConfiguratorAppContext.init(appState ?? {});\n }\n\n public getApi(): RoomleConfigurator {\n return this._configurator;\n }\n\n protected async bootFinished(): Promise<void> {\n this._configurator = new RoomleConfigurator(this._context);\n this._configurator.getMain = () => {\n return this;\n };\n\n if (!window.RoomleConfigurator) {\n window.RoomleConfigurator = this._configurator;\n }\n }\n\n protected getContextName(): string {\n return BASE_CONTEXT.CONFIGURATOR;\n }\n}\n"],"mappings":";;;;;AAeA,IAAa,IAA+C;CAC1D,IAAI,EAA8B,UAAU,EAAO;CACnD,IAA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j as t } from "./roomle-sdk-C0YpFZdj.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
|
-
var i = new Set([
|
|
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) => {
|
|
6
6
|
let t = a(e.llmData), n = s(e.valueObjects).flatMap((e) => {
|
|
7
7
|
let t = a(e.llmData);
|
|
8
8
|
return t && e.value !== void 0 ? [{
|
|
@@ -349,24 +349,24 @@ var i = new Set([t.DECIMAL, t.INTEGER]), a = (e) => typeof e == "string" && e.tr
|
|
|
349
349
|
u.forEach((t) => r("material", t, e));
|
|
350
350
|
}
|
|
351
351
|
return i;
|
|
352
|
-
}, V = async (
|
|
352
|
+
}, V = async (e, i, a, o) => {
|
|
353
353
|
let s = n.safeParse(o ?? void 0);
|
|
354
354
|
if (!s.success) throw Error("Unknown configurator capability section");
|
|
355
355
|
let c = new Set(s.data?.length ? s.data : r), l = i.kernelInstance, u = () => {
|
|
356
|
-
if (
|
|
357
|
-
if (l.isExternalPlanObject(
|
|
358
|
-
let n = l.getRootPlanComponentIdFromObjectId(
|
|
356
|
+
if (e.baseContext !== t.CONFIGURATOR || !e.configurationRuntimeId) throw Error("Load a configuration or enter planner isolation before reading configurator capabilities");
|
|
357
|
+
if (l.isExternalPlanObject(e.configurationRuntimeId)) throw Error("Use the HI external-object API to read capabilities of an external configuration");
|
|
358
|
+
let n = l.getRootPlanComponentIdFromObjectId(e.configurationRuntimeId);
|
|
359
359
|
if (!n) throw Error("No active root component; load a configuration before reading capabilities");
|
|
360
360
|
return {
|
|
361
|
-
configurationRuntimeId:
|
|
361
|
+
configurationRuntimeId: e.configurationRuntimeId,
|
|
362
362
|
rootRuntimeId: n,
|
|
363
363
|
rootComponentId: l.getComponentId(n),
|
|
364
|
-
selectedRuntimeIds: [...
|
|
365
|
-
configurationHash: i.getCurrentConfigurationHash(
|
|
364
|
+
selectedRuntimeIds: [...e.selectedRuntimeComponentIds],
|
|
365
|
+
configurationHash: i.getCurrentConfigurationHash(e.configurationRuntimeId)
|
|
366
366
|
};
|
|
367
|
-
}, d = u(), f =
|
|
367
|
+
}, d = u(), f = e.rootComponentParametersAsGlobal, p = e.rootComponentId, g = () => {
|
|
368
368
|
try {
|
|
369
|
-
if (JSON.stringify(u()) === JSON.stringify(d) && f ===
|
|
369
|
+
if (JSON.stringify(u()) === JSON.stringify(d) && f === e.rootComponentParametersAsGlobal && p === e.rootComponentId) return;
|
|
370
370
|
} catch {}
|
|
371
371
|
throw Error("Configuration or selection changed while reading capabilities; read again");
|
|
372
372
|
}, _ = {
|
|
@@ -437,4 +437,4 @@ var i = new Set([t.DECIMAL, t.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-
|
|
440
|
+
//# sourceMappingURL=configurator-capabilities-BfSMwdWh.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurator-capabilities-CLqul800.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,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,GACrD,EAAE;GACN;AACE,QAAC,KAAW,CAAC,EAAO,QAGxB,QAAO;EAAE,GAAI,IAAU,EAAE,YAAS,GAAG,EAAE;EAAG;EAAQ;GAIvC,KACX,MACqB;CACrB,IAAM,IAAM,EAAS,EAAW,IAAI,EAC9B,IAAU,EAAK,GAAK,QAAQ,EAC5B,IAAS,EAAU,GAAK,OAAO,CAAC,SAAS,MAAU;EACvD,IAAM,IAAO,EAAK,EAAM,KAAK;AAC7B,SAAO,IACH,CACE;GACE;GACA,aAAa,EAAK,EAAM,YAAY,IAAI;GACxC,WAAW,E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,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
|
+
{"version":3,"file":"configurator-capabilities-BfSMwdWh.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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