@salsita-ai/sdk 0.50.0-develop.f6390cb584 → 0.50.0-develop.f87b940e67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (547) hide show
  1. package/dist/application/index.d.ts +1 -0
  2. package/dist/application/index.js +1 -1
  3. package/dist/application/mount-application.d.ts +1 -1
  4. package/dist/application/mount-application.js +1 -1
  5. package/dist/application/mount-configurator.d.ts +19 -0
  6. package/dist/application/mount-configurator.js +1 -0
  7. package/dist/application/mounted-application-runtime.d.ts +4 -0
  8. package/dist/application/mounted-application-runtime.js +1 -0
  9. package/dist/application/register-web-component.d.ts +2 -0
  10. package/dist/application/register-web-component.js +1 -0
  11. package/dist/application-spec/errors/diagnostic-codes.d.ts +9 -0
  12. package/dist/application-spec/errors/diagnostic-codes.js +1 -1
  13. package/dist/application-spec/errors/diagnostic-messages.d.ts +10 -1
  14. package/dist/application-spec/errors/diagnostic-messages.js +1 -1
  15. package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
  16. package/dist/application-spec/generate-application/code/templates/application-types.js +6 -6
  17. package/dist/application-spec/generate-application/code/templates/common/doc-comment.d.ts +2 -0
  18. package/dist/application-spec/generate-application/code/templates/common/doc-comment.js +1 -0
  19. package/dist/application-spec/generate-application/code/templates/configurator-globals.d.ts +2 -1
  20. package/dist/application-spec/generate-application/code/templates/configurator-globals.js +19 -6
  21. package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.js +7 -7
  22. package/dist/application-spec/generate-application/code/templates/global-definition/generate-assistant-form-element-types.d.ts +12 -0
  23. package/dist/application-spec/generate-application/code/templates/global-definition/generate-assistant-form-element-types.js +7 -0
  24. package/dist/application-spec/generate-application/code/templates/global-definition/generate-phx-types.js +24 -22
  25. package/dist/application-spec/generate-application/code/templates/global-definition/index.d.ts +1 -0
  26. package/dist/application-spec/generate-application/code/templates/global-definition/index.js +1 -1
  27. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +13 -6
  28. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +2 -2
  29. package/dist/application-spec/generate-application/implementations/phx-application-types.d.ts +25 -0
  30. package/dist/application-spec/generate-application/implementations/phx-application-types.js +1 -0
  31. package/dist/application-spec/generate-application/implementations/phx-domain.d.ts +36 -0
  32. package/dist/application-spec/generate-application/implementations/phx-domain.js +1 -0
  33. package/dist/application-spec/generate-application/implementations/phx-model.d.ts +24 -0
  34. package/dist/application-spec/generate-application/implementations/phx-model.js +1 -0
  35. package/dist/application-spec/generate-application/implementations/phx.d.ts +22 -0
  36. package/dist/application-spec/generate-application/implementations/phx.js +1 -0
  37. package/dist/application-spec/generate-application/index.d.ts +2 -0
  38. package/dist/application-spec/generate-application/index.js +1 -1
  39. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-model-runtime.d.ts +3 -3
  40. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-runtime.d.ts +7 -4
  41. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-runtime.js +1 -1
  42. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-spec-runtime.d.ts +16 -0
  43. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-spec-runtime.js +1 -0
  44. package/dist/application-spec/generate-application/runtime/application-runtime.d.ts +17 -4
  45. package/dist/application-spec/generate-application/runtime/application-runtime.js +1 -1
  46. package/dist/application-spec/generate-application/runtime/application-spec-slice.d.ts +71 -0
  47. package/dist/application-spec/generate-application/runtime/application-spec-slice.js +1 -0
  48. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-model-runtime.d.ts +3 -3
  49. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.d.ts +7 -5
  50. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.js +1 -1
  51. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-spec-runtime.d.ts +16 -0
  52. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-spec-runtime.js +1 -0
  53. package/dist/application-spec/generate-application/runtime/create-application.d.ts +57 -0
  54. package/dist/application-spec/generate-application/runtime/create-application.js +1 -0
  55. package/dist/application-spec/generate-application/runtime/index.d.ts +8 -0
  56. package/dist/application-spec/generate-application/runtime/index.js +1 -0
  57. package/dist/application-spec/generate-application/runtime/sections/expression-runtime.d.ts +9 -3
  58. package/dist/application-spec/generate-application/runtime/sections/expression-runtime.js +1 -1
  59. package/dist/application-spec/generate-application/runtime/spec-runtime.d.ts +21 -0
  60. package/dist/application-spec/generate-application/runtime/spec-runtime.js +1 -0
  61. package/dist/application-spec/generate-application/runtime-spec/encoded-runtime-spec.d.ts +3 -2
  62. package/dist/application-spec/generate-application/runtime-spec/runtime-spec.d.ts +44 -9
  63. package/dist/application-spec/generate-application/runtime-spec/runtime-spec.js +1 -1
  64. package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.d.ts +33 -3
  65. package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.js +1 -1
  66. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-form-elements.d.ts +9 -0
  67. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-form-elements.js +1 -0
  68. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +4 -1
  69. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
  70. package/dist/configurator/ConfiguratorApp.js +1 -1
  71. package/dist/configurator/app-loader-content/index.d.ts +0 -1
  72. package/dist/configurator/app-loader-content/index.js +1 -1
  73. package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
  74. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +4 -3
  75. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
  76. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +33 -7
  77. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -1
  78. package/dist/configurator/application-runtime/extensions/systems/canvas-system.d.ts +8 -0
  79. package/dist/configurator/application-runtime/extensions/systems/canvas-system.js +1 -1
  80. package/dist/configurator/application-runtime/extensions/systems/export-system/export-busy-error.d.ts +8 -0
  81. package/dist/configurator/application-runtime/extensions/systems/export-system/export-busy-error.js +1 -0
  82. package/dist/configurator/application-runtime/extensions/systems/export-system/export-system.d.ts +23 -1
  83. package/dist/configurator/application-runtime/extensions/systems/export-system/export-system.js +1 -1
  84. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.d.ts +14 -1
  85. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.js +1 -1
  86. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +45 -4
  87. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
  88. package/dist/configurator/application-runtime/extensions/systems/image-rendering-system/image-rendering-system.d.ts +14 -5
  89. package/dist/configurator/application-runtime/extensions/systems/image-rendering-system/image-rendering-system.js +1 -1
  90. package/dist/configurator/application-runtime/extensions/systems/index.d.ts +1 -1
  91. package/dist/configurator/common/configurator-interface.d.ts +40 -6
  92. package/dist/configurator/common/configurator-interface.js +1 -1
  93. package/dist/configurator/configuration-not-found-page/BuiltInConfigurationNotFoundPage.d.ts +5 -0
  94. package/dist/configurator/configuration-not-found-page/BuiltInConfigurationNotFoundPage.js +1 -0
  95. package/dist/configurator/configuration-not-found-page/ConfigurationNotFoundPageElement.d.ts +0 -6
  96. package/dist/configurator/configuration-not-found-page/ConfigurationNotFoundPageElement.js +1 -1
  97. package/dist/configurator/configuration-not-found-page/index.d.ts +2 -2
  98. package/dist/configurator/configuration-not-found-page/index.js +1 -1
  99. package/dist/configurator/configurator-context/ConfiguratorResponsiveProvider.d.ts +3 -3
  100. package/dist/configurator/configurator-context/ConfiguratorResponsiveProvider.js +1 -1
  101. package/dist/configurator/configurator-context/PreviewContextProvider.js +1 -1
  102. package/dist/configurator/configurator-context/configurator-hooks/layout-hooks.d.ts +4 -0
  103. package/dist/configurator/configurator-context/configurator-routing/ConfiguratorRoutingProvider.js +1 -1
  104. package/dist/configurator/configurator-error-page/BuiltInConfiguratorErrorPage.d.ts +3 -3
  105. package/dist/configurator/configurator-error-page/BuiltInConfiguratorErrorPage.js +1 -1
  106. package/dist/configurator/configurator-error-page/ConfiguratorErrorPageElement.d.ts +0 -5
  107. package/dist/configurator/configurator-error-page/ConfiguratorErrorPageElement.js +1 -1
  108. package/dist/configurator/configurator-error-page/index.d.ts +1 -2
  109. package/dist/configurator/configurator-error-page/index.js +1 -1
  110. package/dist/configurator/index.d.ts +9 -2
  111. package/dist/configurator/index.js +1 -1
  112. package/dist/configurator/pages/default-configurator-elements.d.ts +3 -2
  113. package/dist/configurator/pages/default-configurator-elements.js +1 -1
  114. package/dist/configurator/pages/default-elements/index.d.ts +1 -0
  115. package/dist/configurator/pages/default-elements/index.js +1 -1
  116. package/dist/configurator/pages/default-elements/scene-controls/BuiltInAddEntityFab.d.ts +3 -0
  117. package/dist/configurator/pages/default-elements/scene-controls/BuiltInAddEntityFab.js +1 -0
  118. package/dist/configurator/pages/default-elements/scene-controls/BuiltInDeleteEntityFab.d.ts +3 -0
  119. package/dist/configurator/pages/default-elements/scene-controls/BuiltInDeleteEntityFab.js +1 -0
  120. package/dist/configurator/pages/default-elements/scene-controls/BuiltInNavigationHotspot.d.ts +3 -0
  121. package/dist/configurator/pages/default-elements/scene-controls/BuiltInNavigationHotspot.js +1 -0
  122. package/dist/configurator/pages/default-elements/scene-controls/BuiltInSelectionHotspot.d.ts +3 -0
  123. package/dist/configurator/pages/default-elements/scene-controls/BuiltInSelectionHotspot.js +1 -0
  124. package/dist/configurator/pages/default-elements/scene-controls/BuiltInToolMenuFab.d.ts +3 -0
  125. package/dist/configurator/pages/default-elements/scene-controls/BuiltInToolMenuFab.js +1 -0
  126. package/dist/configurator/pages/default-elements/scene-controls/index.d.ts +6 -0
  127. package/dist/configurator/pages/default-elements/scene-controls/index.js +1 -0
  128. package/dist/configurator/pages/default-elements/scene-controls/scene-control-elements.d.ts +6 -0
  129. package/dist/configurator/pages/default-elements/scene-controls/scene-control-elements.js +1 -0
  130. package/dist/configurator/pages/error-boundaries/LoadingErrorBoundary.js +1 -1
  131. package/dist/configurator/scene/index.d.ts +1 -0
  132. package/dist/configurator/scene/index.js +1 -1
  133. package/dist/configurator/scene/scene-controls/ToolFab.d.ts +4 -0
  134. package/dist/configurator/scene/scene-controls/ToolFab.js +1 -1
  135. package/dist/configurator/scene/scene-controls/use-scene-control-tooltip.d.ts +2 -1
  136. package/dist/configurator/scene/scene-entity/scene-controls/SceneEntityHtmlHotspots.js +1 -1
  137. package/dist/configurator/toolbar-actions/index.d.ts +1 -0
  138. package/dist/configurator/toolbar-actions/index.js +1 -1
  139. package/dist/configurator/toolbar-actions/use-toolbar-actions.d.ts +100 -0
  140. package/dist/configurator/toolbar-actions/use-toolbar-actions.js +1 -0
  141. package/dist/configurator/toolbar-actions/use-toolbar-help.d.ts +7 -0
  142. package/dist/configurator/toolbar-actions/use-toolbar-help.js +1 -0
  143. package/dist/configurator/ui/assistant/AssistantChips.d.ts +3 -2
  144. package/dist/configurator/ui/assistant/AssistantChips.js +1 -1
  145. package/dist/configurator/ui/assistant/AssistantMarkdown.d.ts +1 -1
  146. package/dist/configurator/ui/assistant/AssistantMarkdown.js +1 -1
  147. package/dist/configurator/ui/assistant/alert/AssistantAlert.d.ts +8 -0
  148. package/dist/configurator/ui/assistant/alert/AssistantAlert.js +1 -0
  149. package/dist/configurator/ui/assistant/alert/index.d.ts +2 -0
  150. package/dist/configurator/ui/assistant/alert/index.js +1 -0
  151. package/dist/configurator/ui/assistant/alert/remark-alerts.d.ts +10 -0
  152. package/dist/configurator/ui/assistant/alert/remark-alerts.js +1 -0
  153. package/dist/configurator/ui/assistant/form/AssistantForm.js +1 -1
  154. package/dist/configurator/ui/assistant/form/compose-answer.d.ts +1 -1
  155. package/dist/configurator/ui/assistant/form/compose-answer.js +1 -1
  156. package/dist/configurator/ui/assistant/form/form-model.d.ts +3 -4
  157. package/dist/configurator/ui/assistant/form/form-state.d.ts +1 -1
  158. package/dist/configurator/ui/assistant/form/index.d.ts +2 -0
  159. package/dist/configurator/ui/assistant/form/index.js +1 -1
  160. package/dist/configurator/ui/assistant/form/parse-form-block.d.ts +3 -2
  161. package/dist/configurator/ui/assistant/form/parse-form-block.js +1 -1
  162. package/dist/configurator/ui/assistant/form/read-form-attributes.d.ts +1 -1
  163. package/dist/configurator/ui/assistant/form/read-form-attributes.js +1 -1
  164. package/dist/configurator/ui/assistant/form/registry/built-in-form-elements.d.ts +3 -0
  165. package/dist/configurator/ui/assistant/form/registry/built-in-form-elements.js +1 -0
  166. package/dist/configurator/ui/assistant/form/registry/create-assistant-form-element.d.ts +31 -0
  167. package/dist/configurator/ui/assistant/form/registry/create-assistant-form-element.js +1 -0
  168. package/dist/configurator/ui/assistant/form/{form-element-definition.d.ts → registry/form-element-definition.d.ts} +3 -1
  169. package/dist/configurator/ui/assistant/form/registry/form-element-definition.js +1 -0
  170. package/dist/configurator/ui/assistant/form/{form-registry.d.ts → registry/form-registry.d.ts} +2 -2
  171. package/dist/configurator/ui/assistant/form/registry/form-registry.js +1 -0
  172. package/dist/configurator/ui/assistant/form/registry/index.d.ts +6 -0
  173. package/dist/configurator/ui/assistant/form/registry/index.js +1 -0
  174. package/dist/configurator/ui/assistant/form/registry/use-form-registry.d.ts +8 -0
  175. package/dist/configurator/ui/assistant/form/registry/use-form-registry.js +1 -0
  176. package/dist/configurator/ui/assistant/form-elements/FormCard.d.ts +9 -0
  177. package/dist/configurator/ui/assistant/form-elements/FormCard.js +1 -0
  178. package/dist/configurator/ui/assistant/form-elements/FormConfirm.d.ts +9 -0
  179. package/dist/configurator/ui/assistant/form-elements/FormConfirm.js +1 -0
  180. package/dist/configurator/ui/assistant/form-elements/FormGroup.d.ts +4 -1
  181. package/dist/configurator/ui/assistant/form-elements/FormNumber.d.ts +9 -0
  182. package/dist/configurator/ui/assistant/form-elements/FormNumber.js +1 -0
  183. package/dist/configurator/ui/assistant/form-elements/FormOptions.d.ts +4 -1
  184. package/dist/configurator/ui/assistant/form-elements/FormReply.d.ts +4 -1
  185. package/dist/configurator/ui/assistant/form-elements/FormReply.js +1 -1
  186. package/dist/configurator/ui/assistant/form-elements/FormSwatch.d.ts +10 -0
  187. package/dist/configurator/ui/assistant/form-elements/FormSwatch.js +1 -0
  188. package/dist/configurator/ui/assistant/form-elements/FormText.d.ts +4 -1
  189. package/dist/configurator/ui/assistant/form-elements/FormText.js +1 -1
  190. package/dist/configurator/ui/assistant/form-elements/clamp-form-number.d.ts +10 -0
  191. package/dist/configurator/ui/assistant/form-elements/clamp-form-number.js +1 -0
  192. package/dist/configurator/ui/assistant/form-elements/form-element-props.d.ts +20 -16
  193. package/dist/configurator/ui/assistant/form-elements/index.d.ts +4 -0
  194. package/dist/configurator/ui/assistant/form-elements/index.js +1 -1
  195. package/dist/configurator/ui/assistant/index.d.ts +3 -0
  196. package/dist/configurator/ui/assistant/index.js +1 -1
  197. package/dist/configurator/ui/assistant/resource-image/index.d.ts +1 -1
  198. package/dist/configurator/ui/assistant/resource-image/index.js +1 -1
  199. package/dist/configurator/ui/assistant/resource-image/resource-path.d.ts +0 -9
  200. package/dist/configurator/ui/assistant/resource-image/resource-path.js +1 -1
  201. package/dist/configurator/ui/assistant/screenshots/ScreenshotThumbnails.d.ts +9 -0
  202. package/dist/configurator/ui/assistant/screenshots/ScreenshotThumbnails.js +1 -0
  203. package/dist/configurator/ui/assistant/screenshots/index.d.ts +2 -0
  204. package/dist/configurator/ui/assistant/screenshots/index.js +1 -0
  205. package/dist/configurator/ui/assistant/screenshots/tool-screenshots.d.ts +14 -0
  206. package/dist/configurator/ui/assistant/screenshots/tool-screenshots.js +1 -0
  207. package/dist/configurator/ui/assistant/streamed-markdown.d.ts +2 -2
  208. package/dist/configurator/ui/assistant/streamed-markdown.js +2 -2
  209. package/dist/configurator/ui/assistant/tool-chip.js +1 -1
  210. package/dist/configurator/ui/configurator-layout/slots/canvas/LayoutCanvas.js +1 -1
  211. package/dist/configurator/ui/configurator-layout/slots/canvas/SharedCanvas.js +1 -1
  212. package/dist/configurator/ui/configurator-layout/universal/ExportingOverlay.d.ts +5 -0
  213. package/dist/configurator/ui/configurator-layout/universal/ExportingOverlay.js +1 -0
  214. package/dist/configurator/ui/configurator-layout/universal/Layout.js +1 -1
  215. package/dist/configurator/ui/configurator-layout/universal/use-layout-scene-safe-area.js +1 -1
  216. package/dist/configurator/ui/index.d.ts +1 -0
  217. package/dist/configurator/ui/index.js +1 -1
  218. package/dist/configurator/ui/legacy/layout/common/ReactiveInterfaceLayout.js +1 -1
  219. package/dist/configurator/ui/phoenix-layout-elements/AppLoader.d.ts +0 -7
  220. package/dist/configurator/ui/phoenix-layout-elements/AppLoader.js +2 -2
  221. package/dist/configurator/ui/phoenix-layout-elements/index.d.ts +8 -1
  222. package/dist/configurator/ui/phoenix-layout-elements/index.js +1 -1
  223. package/dist/configurator/ui/preset-layout/PresetUi.d.ts +0 -2
  224. package/dist/configurator/ui/preset-layout/PresetUi.js +1 -1
  225. package/dist/configurator/ui/preset-layout/index.d.ts +6 -1
  226. package/dist/configurator/ui/preset-layout/index.js +1 -1
  227. package/dist/configurator/ui/save-message-snackbars/SaveMessageSnackbars.js +1 -1
  228. package/dist/docs/complex-use-cases/focus-mode.mdx +2 -0
  229. package/dist/docs/fabs/basic.mdx +4 -0
  230. package/dist/docs/index.json +95 -1
  231. package/dist/docs/integrations/webcomponent-api/basics.mdx +2 -0
  232. package/dist/docs/layouts/custom-layout.mdx +320 -158
  233. package/dist/docs/layouts/gallery/ardent-compressor.mdx +3516 -0
  234. package/dist/docs/layouts/gallery/corvid-drone.mdx +3428 -0
  235. package/dist/docs/layouts/gallery/fenwick-window.mdx +2803 -0
  236. package/dist/docs/layouts/gallery/ferrule-bar-station.mdx +6567 -0
  237. package/dist/docs/layouts/gallery/kestrel-kettle.mdx +1858 -0
  238. package/dist/docs/layouts/gallery/nightjar-guitar.mdx +3698 -0
  239. package/dist/docs/layouts/gallery/sunfold-solar.mdx +2683 -0
  240. package/dist/docs/layouts/gallery/tidepool-aquascape.mdx +5203 -0
  241. package/dist/docs/other-features/client-side-rendering/declarative.mdx +1 -1
  242. package/dist/docs/other-features/navigation-hotspot.mdx +2 -0
  243. package/dist/docs/phoenix/configurator-interface.mdx +72 -14
  244. package/dist/docs/phoenix/sdk-builder-workflow.mdx +1 -1
  245. package/dist/docs/phoenix/sessions-and-access.mdx +2 -0
  246. package/dist/docs/selection-and-highlight/hotspots.mdx +2 -0
  247. package/dist/domain/application/assistant/assistant-manifest.d.ts +16 -1
  248. package/dist/domain/application/assistant/assistant-resolved-manifest.d.ts +8 -1
  249. package/dist/domain/application/assistant/build-assistant-manifest.js +1 -1
  250. package/dist/domain/application/assistant/form/assistant-form-element-name.d.ts +11 -0
  251. package/dist/domain/application/assistant/form/assistant-form-element-name.js +8 -0
  252. package/dist/domain/application/assistant/form/assistant-form-elements.d.ts +174 -0
  253. package/dist/domain/application/assistant/form/assistant-form-elements.js +1 -0
  254. package/dist/domain/application/assistant/form/assistant-resource-path.d.ts +10 -0
  255. package/dist/domain/application/assistant/form/assistant-resource-path.js +1 -0
  256. package/dist/domain/application/assistant/form/index.d.ts +4 -0
  257. package/dist/domain/application/assistant/form/index.js +1 -0
  258. package/dist/domain/application/assistant/generate-assistant-prompt.d.ts +3 -0
  259. package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -1
  260. package/dist/domain/application/assistant/index.d.ts +2 -3
  261. package/dist/domain/application/assistant/index.js +1 -1
  262. package/dist/domain/application/assistant/session-setup/apply-assistant-setup.js +1 -1
  263. package/dist/domain/application/assistant/session-setup/assistant-setup-manifest.d.ts +2 -0
  264. package/dist/domain/application/assistant/session-setup/assistant-setup-manifest.js +1 -1
  265. package/dist/domain/application/configurator-builder.d.ts +7 -1
  266. package/dist/domain/application/configurator-builder.js +1 -1
  267. package/dist/domain/application/index.d.ts +1 -1
  268. package/dist/domain/application/index.js +1 -1
  269. package/dist/domain/application/standard-properties.js +1 -1
  270. package/dist/domain/application/web-component-property.d.ts +3 -1
  271. package/dist/domain/application/web-component-property.js +1 -1
  272. package/dist/domain/available-system-components.d.ts +1 -1
  273. package/dist/domain/available-system-components.js +1 -1
  274. package/dist/domain/domain-builder.d.ts +9 -3
  275. package/dist/domain/domain-builder.js +1 -1
  276. package/dist/domain/domain-context/store-system/store-system.d.ts +5 -0
  277. package/dist/domain/domain-context/store-system/store-system.js +1 -1
  278. package/dist/domain/domain-runtime/application.d.ts +39 -0
  279. package/dist/domain/domain-runtime/application.js +1 -0
  280. package/dist/domain/domain-runtime/domain-context/selectors.d.ts +1 -0
  281. package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
  282. package/dist/domain/domain-runtime/domain-runtime.d.ts +44 -4
  283. package/dist/domain/domain-runtime/domain-runtime.js +1 -1
  284. package/dist/domain/domain-runtime/environment/initialize.d.ts +1 -1
  285. package/dist/domain/domain-runtime/environment/types.d.ts +1 -1
  286. package/dist/domain/domain-runtime/errors/implementation-error-collector.d.ts +2 -0
  287. package/dist/domain/domain-runtime/errors/implementation-error-collector.js +1 -1
  288. package/dist/domain/domain-runtime/index.d.ts +2 -1
  289. package/dist/domain/domain-runtime/index.js +1 -1
  290. package/dist/domain/domain-runtime/spec/index.d.ts +1 -1
  291. package/dist/domain/domain-runtime/spec/index.js +1 -1
  292. package/dist/domain/domain-runtime/spec/initialize.js +1 -1
  293. package/dist/domain/domain-runtime/spec/module-checks/element-registration.d.ts +15 -1
  294. package/dist/domain/domain-runtime/spec/module-checks/element-registration.js +1 -1
  295. package/dist/domain/domain-runtime/spec/module-checks/find-assistant-form-element-errors.d.ts +12 -0
  296. package/dist/domain/domain-runtime/spec/module-checks/find-assistant-form-element-errors.js +1 -0
  297. package/dist/domain/domain-runtime/spec/module-checks/index.d.ts +3 -1
  298. package/dist/domain/domain-runtime/spec/module-checks/index.js +1 -1
  299. package/dist/domain/domain-runtime/spec/module-checks/merge-expression-modules.d.ts +23 -0
  300. package/dist/domain/domain-runtime/spec/module-checks/merge-expression-modules.js +1 -0
  301. package/dist/domain/domain-runtime/spec/module-checks/resolve-expression-modules.d.ts +3 -4
  302. package/dist/domain/domain-runtime/spec/module-checks/resolve-expression-modules.js +1 -1
  303. package/dist/domain/domain-runtime/spec/selectors.d.ts +3 -1
  304. package/dist/domain/domain-runtime/spec/selectors.js +1 -1
  305. package/dist/domain/domain-runtime/web-component/actions.d.ts +3 -0
  306. package/dist/domain/domain-runtime/web-component/actions.js +1 -1
  307. package/dist/domain/domain-runtime/web-component/initialize.d.ts +1 -0
  308. package/dist/domain/domain-runtime/web-component/initialize.js +1 -1
  309. package/dist/domain/domain-runtime/web-component/selectors.d.ts +2 -0
  310. package/dist/domain/domain-runtime/web-component/selectors.js +1 -1
  311. package/dist/domain/domain-runtime/web-component/types.d.ts +6 -3
  312. package/dist/domain/extensions/export-images/agent-screenshot.d.ts +24 -0
  313. package/dist/domain/extensions/export-images/agent-screenshot.js +1 -0
  314. package/dist/domain/extensions/{client-side-image.d.ts → export-images/client-side-image.d.ts} +2 -2
  315. package/dist/domain/extensions/export-images/client-side-image.js +1 -0
  316. package/dist/domain/extensions/export-images/index.d.ts +3 -0
  317. package/dist/domain/extensions/export-images/index.js +1 -0
  318. package/dist/domain/extensions/{save-template-thumbnail.d.ts → export-images/save-template-thumbnail.d.ts} +2 -2
  319. package/dist/domain/extensions/export-images/save-template-thumbnail.js +1 -0
  320. package/dist/domain/extensions/index.d.ts +1 -2
  321. package/dist/domain/extensions/index.js +1 -1
  322. package/dist/domain/mocks/create-mock-domain-runtime.d.ts +9 -0
  323. package/dist/editor/domain-editors/DomainSpecContext.js +1 -1
  324. package/dist/editor/domain-editors/apply-spec-update.d.ts +10 -2
  325. package/dist/editor/domain-editors/apply-spec-update.js +1 -1
  326. package/dist/editor/domain-editors/use-implementation-files.d.ts +6 -14
  327. package/dist/editor/domain-editors/use-implementation-files.js +1 -1
  328. package/dist/editor/screenshot/ScreenshotHandler.js +1 -1
  329. package/dist/i18n/locales/cs/messages.js +1 -1
  330. package/dist/i18n/locales/da/messages.js +1 -1
  331. package/dist/i18n/locales/de/messages.js +1 -1
  332. package/dist/i18n/locales/de-AT/messages.js +1 -1
  333. package/dist/i18n/locales/en/messages.js +1 -1
  334. package/dist/i18n/locales/en-AU/messages.js +1 -1
  335. package/dist/i18n/locales/en-GB/messages.js +1 -1
  336. package/dist/i18n/locales/es/messages.js +1 -1
  337. package/dist/i18n/locales/fr/messages.js +1 -1
  338. package/dist/i18n/locales/hu/messages.js +1 -1
  339. package/dist/i18n/locales/it/messages.js +1 -1
  340. package/dist/i18n/locales/nl/messages.js +1 -1
  341. package/dist/i18n/locales/pl/messages.js +1 -1
  342. package/dist/i18n/locales/pt/messages.js +1 -1
  343. package/dist/i18n/locales/ro/messages.js +1 -1
  344. package/dist/i18n/locales/sk/messages.js +1 -1
  345. package/dist/i18n/locales/tr/messages.js +1 -1
  346. package/dist/legacy/domain-cli/utils/cache.d.ts +1 -1
  347. package/dist/legacy/domain-cli/utils/cache.js +1 -1
  348. package/dist/legacy/domain-spec/__generated/domain-schema.d.ts +16 -0
  349. package/dist/legacy/domain-spec/spec/domain-spec.js +1 -1
  350. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/claude-md.d.ts +1 -1
  351. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/cursor-rules.d.ts +1 -1
  352. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.d.ts +1 -1
  353. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.js +11 -5
  354. package/dist/react-sdk/application-runtime/common-services/analytics/analytics-service.d.ts +1 -1
  355. package/dist/react-sdk/application-runtime/common-services/initialize.d.ts +2 -2
  356. package/dist/react-sdk/application-runtime/hooks/index.d.ts +2 -0
  357. package/dist/react-sdk/application-runtime/hooks/index.js +1 -1
  358. package/dist/react-sdk/application-runtime/hooks/loading/index.d.ts +5 -0
  359. package/dist/react-sdk/application-runtime/hooks/loading/index.js +1 -0
  360. package/dist/react-sdk/application-runtime/hooks/loading/loader-host-context.d.ts +11 -0
  361. package/dist/react-sdk/application-runtime/hooks/loading/loader-host-context.js +1 -0
  362. package/dist/react-sdk/application-runtime/hooks/loading/use-is-awaiting-loading-phase.d.ts +8 -0
  363. package/dist/react-sdk/application-runtime/hooks/loading/use-is-awaiting-loading-phase.js +1 -0
  364. package/dist/react-sdk/application-runtime/hooks/loading/use-is-loader-hosted.d.ts +7 -0
  365. package/dist/react-sdk/application-runtime/hooks/loading/use-is-loader-hosted.js +1 -0
  366. package/dist/react-sdk/application-runtime/hooks/loading/use-loading-actions.d.ts +9 -0
  367. package/dist/react-sdk/application-runtime/hooks/loading/use-loading-actions.js +1 -0
  368. package/dist/react-sdk/application-runtime/hooks/loading/use-loading-application.d.ts +24 -0
  369. package/dist/react-sdk/application-runtime/hooks/loading/use-loading-application.js +1 -0
  370. package/dist/react-sdk/application-runtime/hooks/responsive/index.d.ts +3 -0
  371. package/dist/react-sdk/application-runtime/hooks/responsive/index.js +1 -0
  372. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-actions.d.ts +9 -0
  373. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-actions.js +1 -0
  374. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-application.d.ts +26 -0
  375. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-application.js +1 -0
  376. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-state.d.ts +10 -0
  377. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-state.js +1 -0
  378. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-store.d.ts +24 -0
  379. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-store.js +1 -0
  380. package/dist/react-sdk/application-runtime/hooks/use-access-service.d.ts +5 -0
  381. package/dist/react-sdk/application-runtime/hooks/use-access-service.js +1 -1
  382. package/dist/react-sdk/application-runtime/hooks/use-phoenix-element-slots.d.ts +2 -1
  383. package/dist/react-sdk/application-runtime/hooks/use-web-component-readonly-sync.d.ts +4 -11
  384. package/dist/react-sdk/application-runtime/hooks/use-web-component-readonly-sync.js +1 -1
  385. package/dist/react-sdk/application-runtime/hooks/use-web-component.d.ts +5 -0
  386. package/dist/react-sdk/application-runtime/hooks/use-web-component.js +1 -1
  387. package/dist/react-sdk/application-runtime/host-properties/actions.d.ts +15 -0
  388. package/dist/react-sdk/application-runtime/host-properties/actions.js +1 -0
  389. package/dist/react-sdk/application-runtime/host-properties/connect-host-properties.d.ts +30 -0
  390. package/dist/react-sdk/application-runtime/host-properties/connect-host-properties.js +1 -0
  391. package/dist/react-sdk/application-runtime/host-properties/domain-host-properties.d.ts +7 -0
  392. package/dist/react-sdk/application-runtime/host-properties/domain-host-properties.js +1 -0
  393. package/dist/react-sdk/application-runtime/host-properties/host-property-descriptors.d.ts +21 -0
  394. package/dist/react-sdk/application-runtime/host-properties/host-property-descriptors.js +1 -0
  395. package/dist/react-sdk/application-runtime/host-properties/host-property-scopes.d.ts +42 -0
  396. package/dist/react-sdk/application-runtime/host-properties/host-property-scopes.js +1 -0
  397. package/dist/react-sdk/application-runtime/host-properties/index.d.ts +8 -0
  398. package/dist/react-sdk/application-runtime/host-properties/index.js +1 -0
  399. package/dist/react-sdk/application-runtime/host-properties/initialize.d.ts +7 -0
  400. package/dist/react-sdk/application-runtime/host-properties/initialize.js +1 -0
  401. package/dist/react-sdk/application-runtime/host-properties/selectors.d.ts +54 -0
  402. package/dist/react-sdk/application-runtime/host-properties/selectors.js +1 -0
  403. package/dist/react-sdk/application-runtime/host-properties/types.d.ts +18 -0
  404. package/dist/react-sdk/application-runtime/index.d.ts +3 -0
  405. package/dist/react-sdk/application-runtime/integration/initialize.d.ts +7 -6
  406. package/dist/react-sdk/application-runtime/integration/initialize.js +1 -1
  407. package/dist/react-sdk/application-runtime/integration/selectors.d.ts +11 -2
  408. package/dist/react-sdk/application-runtime/integration/selectors.js +1 -1
  409. package/dist/react-sdk/application-runtime/integration/types.d.ts +5 -2
  410. package/dist/react-sdk/application-runtime/loading/actions.d.ts +45 -0
  411. package/dist/react-sdk/application-runtime/loading/actions.js +1 -0
  412. package/dist/react-sdk/application-runtime/loading/index.d.ts +4 -0
  413. package/dist/react-sdk/application-runtime/loading/index.js +1 -0
  414. package/dist/react-sdk/application-runtime/loading/initialize.d.ts +3 -0
  415. package/dist/react-sdk/application-runtime/loading/initialize.js +1 -0
  416. package/dist/react-sdk/application-runtime/loading/selectors.d.ts +18 -0
  417. package/dist/react-sdk/application-runtime/loading/selectors.js +1 -0
  418. package/dist/react-sdk/application-runtime/loading/types.d.ts +59 -0
  419. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.js +1 -1
  420. package/dist/react-sdk/application-runtime/provider/ApplicationRuntime.d.ts +6 -0
  421. package/dist/react-sdk/application-runtime/provider/ApplicationRuntime.js +1 -1
  422. package/dist/react-sdk/application-runtime/provider/ApplicationType.d.ts +7 -0
  423. package/dist/react-sdk/application-runtime/provider/ApplicationType.js +1 -1
  424. package/dist/react-sdk/application-runtime/responsive/actions.d.ts +47 -0
  425. package/dist/react-sdk/application-runtime/responsive/actions.js +1 -0
  426. package/dist/react-sdk/application-runtime/responsive/index.d.ts +4 -0
  427. package/dist/react-sdk/application-runtime/responsive/index.js +1 -0
  428. package/dist/react-sdk/application-runtime/responsive/initialize.d.ts +3 -0
  429. package/dist/react-sdk/application-runtime/responsive/initialize.js +1 -0
  430. package/dist/react-sdk/application-runtime/responsive/selectors.d.ts +20 -0
  431. package/dist/react-sdk/application-runtime/responsive/selectors.js +1 -0
  432. package/dist/react-sdk/application-runtime/responsive/types.d.ts +104 -0
  433. package/dist/react-sdk/application-runtime/routing/routing-service.d.ts +34 -2
  434. package/dist/react-sdk/application-runtime/routing/routing-service.js +1 -1
  435. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +313 -10
  436. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.js +1 -1
  437. package/dist/react-sdk/domain-application-context/BackendDataProvider.js +1 -1
  438. package/dist/react-sdk/domain-application-context/FrontendDataProvider.js +1 -1
  439. package/dist/react-sdk/domain-application-context/PublishedDataProvider.js +1 -1
  440. package/dist/react-sdk/domain-context/common-hooks/index.d.ts +1 -0
  441. package/dist/react-sdk/domain-context/common-hooks/index.js +1 -1
  442. package/dist/react-sdk/domain-context/common-hooks/use-configuration-save-state.d.ts +23 -0
  443. package/dist/react-sdk/domain-context/common-hooks/use-configuration-save-state.js +1 -0
  444. package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +1 -0
  445. package/dist/react-sdk/domain-context/index.d.ts +1 -0
  446. package/dist/react-sdk/domain-context/index.js +1 -1
  447. package/dist/react-sdk/domain-context/system-hooks/undo-redo-hooks.js +1 -1
  448. package/dist/react-sdk/elements/index.d.ts +0 -1
  449. package/dist/react-sdk/index.d.ts +2 -1
  450. package/dist/react-sdk/index.js +1 -1
  451. package/dist/react-sdk/loading-state/LoaderHost.d.ts +20 -0
  452. package/dist/react-sdk/loading-state/LoaderHost.js +1 -0
  453. package/dist/react-sdk/loading-state/built-in-loading-phase.d.ts +9 -0
  454. package/dist/react-sdk/loading-state/built-in-loading-phase.js +1 -0
  455. package/dist/react-sdk/loading-state/create-app-loader.d.ts +18 -0
  456. package/dist/react-sdk/loading-state/create-app-loader.js +1 -0
  457. package/dist/react-sdk/loading-state/index.d.ts +4 -2
  458. package/dist/react-sdk/loading-state/index.js +1 -1
  459. package/dist/react-sdk/loading-state/{LoadingStateProvider.d.ts → loading-state-hooks.d.ts} +3 -12
  460. package/dist/react-sdk/loading-state/loading-state-hooks.js +1 -0
  461. package/dist/react-sdk/page-elements/ConfigurationNotFoundPagePropsProvider.d.ts +17 -0
  462. package/dist/react-sdk/page-elements/ConfigurationNotFoundPagePropsProvider.js +1 -0
  463. package/dist/react-sdk/page-elements/ConfiguratorErrorPagePropsProvider.d.ts +17 -0
  464. package/dist/react-sdk/page-elements/ConfiguratorErrorPagePropsProvider.js +1 -0
  465. package/dist/react-sdk/page-elements/configurator-error-page-props.js +1 -0
  466. package/dist/{configurator/configuration-not-found-page → react-sdk/page-elements}/create-configuration-not-found-page.d.ts +7 -1
  467. package/dist/react-sdk/page-elements/create-configuration-not-found-page.js +1 -0
  468. package/dist/{configurator/configurator-error-page → react-sdk/page-elements}/create-configurator-error-page.d.ts +6 -1
  469. package/dist/react-sdk/page-elements/create-configurator-error-page.js +1 -0
  470. package/dist/react-sdk/page-elements/create-preset-ui.d.ts +9 -0
  471. package/dist/react-sdk/page-elements/create-preset-ui.js +1 -0
  472. package/dist/react-sdk/page-elements/index.d.ts +6 -0
  473. package/dist/react-sdk/page-elements/index.js +1 -0
  474. package/dist/react-sdk/scene-control-elements/AddEntityFabElement.d.ts +36 -0
  475. package/dist/react-sdk/scene-control-elements/AddEntityFabElement.js +1 -0
  476. package/dist/react-sdk/scene-control-elements/DeleteEntityFabElement.d.ts +44 -0
  477. package/dist/react-sdk/scene-control-elements/DeleteEntityFabElement.js +1 -0
  478. package/dist/react-sdk/scene-control-elements/NavigationHotspotElement.d.ts +38 -0
  479. package/dist/react-sdk/scene-control-elements/NavigationHotspotElement.js +1 -0
  480. package/dist/react-sdk/scene-control-elements/SelectionHotspotElement.d.ts +30 -0
  481. package/dist/react-sdk/scene-control-elements/SelectionHotspotElement.js +1 -0
  482. package/dist/react-sdk/scene-control-elements/ToolMenuFabElement.d.ts +30 -0
  483. package/dist/react-sdk/scene-control-elements/ToolMenuFabElement.js +1 -0
  484. package/dist/react-sdk/scene-control-elements/create-add-entity-fab.d.ts +9 -0
  485. package/dist/react-sdk/scene-control-elements/create-add-entity-fab.js +1 -0
  486. package/dist/react-sdk/scene-control-elements/create-delete-entity-fab.d.ts +9 -0
  487. package/dist/react-sdk/scene-control-elements/create-delete-entity-fab.js +1 -0
  488. package/dist/react-sdk/scene-control-elements/create-navigation-hotspot.d.ts +10 -0
  489. package/dist/react-sdk/scene-control-elements/create-navigation-hotspot.js +1 -0
  490. package/dist/react-sdk/scene-control-elements/create-selection-hotspot.d.ts +9 -0
  491. package/dist/react-sdk/scene-control-elements/create-selection-hotspot.js +1 -0
  492. package/dist/react-sdk/scene-control-elements/create-tool-menu-fab.d.ts +9 -0
  493. package/dist/react-sdk/scene-control-elements/create-tool-menu-fab.js +1 -0
  494. package/dist/react-sdk/scene-control-elements/index.d.ts +11 -0
  495. package/dist/react-sdk/scene-control-elements/index.js +1 -0
  496. package/dist/react-sdk/scene-control-elements/scene-control-tooltip-visibility.d.ts +5 -0
  497. package/dist/react-sdk/scene-control-elements/scene-control-tooltip-visibility.js +1 -0
  498. package/dist/react-sdk/session/SessionServiceProvider.js +1 -1
  499. package/dist/react-sdk/web-component/create-web-component.js +1 -1
  500. package/dist/react-sdk/web-component/god-mode/god-mode-registry.d.ts +30 -0
  501. package/dist/react-sdk/web-component/god-mode/god-mode-registry.js +1 -0
  502. package/dist/react-sdk/web-component/god-mode/index.d.ts +1 -0
  503. package/dist/react-sdk/web-component/god-mode/index.js +1 -0
  504. package/dist/ui-sdk/icons/__generated/Lightbulb.d.ts +3 -0
  505. package/dist/ui-sdk/icons/__generated/Lightbulb.js +1 -0
  506. package/dist/ui-sdk/icons/__generated/XCircle.d.ts +3 -0
  507. package/dist/ui-sdk/icons/__generated/XCircle.js +1 -0
  508. package/dist/ui-sdk/icons/__generated/index.d.ts +4 -0
  509. package/dist/ui-sdk/icons/__generated/index.js +1 -1
  510. package/dist/ui-sdk/icons/icons-registry.js +1 -1
  511. package/dist/ui-sdk/responsive-application/ResponsiveApplicationProvider.d.ts +2 -2
  512. package/dist/ui-sdk/responsive-application/responsive-state-store.d.ts +11 -9
  513. package/dist/ui-sdk/responsive-application/use-store-responsive-info.js +1 -1
  514. package/dist/ui-sdk/theme/types.d.ts +5 -1
  515. package/package.json +13 -3
  516. package/schema/domain-spec.json +140 -0
  517. package/dist/configurator/app-loader-content/app-loader-content-name.d.ts +0 -5
  518. package/dist/configurator/app-loader-content/app-loader-content-name.js +0 -1
  519. package/dist/configurator/configuration-not-found-page/create-configuration-not-found-page.js +0 -1
  520. package/dist/configurator/configurator-error-page/create-configurator-error-page.js +0 -1
  521. package/dist/configurator/ui/assistant/form/built-in-form-registry.d.ts +0 -10
  522. package/dist/configurator/ui/assistant/form/built-in-form-registry.js +0 -1
  523. package/dist/configurator/ui/assistant/form/form-registry.js +0 -8
  524. package/dist/domain/application/assistant/assistant-form-elements.d.ts +0 -28
  525. package/dist/domain/application/assistant/assistant-form-elements.js +0 -1
  526. package/dist/domain/extensions/client-side-image.js +0 -1
  527. package/dist/domain/extensions/save-template-thumbnail.js +0 -1
  528. package/dist/react-sdk/application-runtime/runtime/god-mode.d.ts +0 -19
  529. package/dist/react-sdk/application-runtime/runtime/god-mode.js +0 -1
  530. package/dist/react-sdk/loading-state/LoadingStateProvider.js +0 -1
  531. package/dist/react-sdk/loading-state/loading-state-manager.d.ts +0 -37
  532. package/dist/react-sdk/loading-state/loading-state-manager.js +0 -1
  533. package/dist/react-sdk/responsive-state/ResponsiveStateProvider.d.ts +0 -25
  534. package/dist/react-sdk/responsive-state/ResponsiveStateProvider.js +0 -1
  535. package/dist/react-sdk/responsive-state/canvas-padding.d.ts +0 -14
  536. package/dist/react-sdk/responsive-state/index.d.ts +0 -5
  537. package/dist/react-sdk/responsive-state/index.js +0 -1
  538. package/dist/react-sdk/responsive-state/responsive-state-manager.d.ts +0 -111
  539. package/dist/react-sdk/responsive-state/responsive-state-manager.js +0 -1
  540. package/dist/react-sdk/responsive-state/use-responsive-state-manager.d.ts +0 -10
  541. package/dist/react-sdk/responsive-state/use-responsive-state-manager.js +0 -1
  542. package/dist/react-sdk/responsive-state/use-responsive-state.d.ts +0 -11
  543. package/dist/react-sdk/responsive-state/use-responsive-state.js +0 -1
  544. /package/dist/{configurator/ui/assistant/form/form-element-definition.js → react-sdk/application-runtime/host-properties/types.js} +0 -0
  545. /package/dist/react-sdk/{elements/configurator-error-page-props.js → application-runtime/loading/types.js} +0 -0
  546. /package/dist/react-sdk/{responsive-state/canvas-padding.js → application-runtime/responsive/types.js} +0 -0
  547. /package/dist/react-sdk/{elements → page-elements}/configurator-error-page-props.d.ts +0 -0
@@ -1 +1 @@
1
- import{isArray as e}from"@salsita-ai/common/utils";import{ASSISTANT_HINTS as t,AssistantFieldClashError as i,buildAssistantManifest as r,describeAssistantValues as n,mergeAssistantFields as s,resolveAssistantField as o}from"#package/domain";import{DiagnosticCode as a,diagnosticMessages as l}from"../../../../errors/index.js";import{createSchemaRefResolver as S,isNullableSchema as p,phxDefinitionRefName as N}from"../../common/index.js";import{resolveAssistantFieldType as T}from"./assistant-field-type.js";let c="AnyDomainEntity",d="RecipeGroup",f="Recipe",A="DryRun",E="FieldOption",m={section:"childRecipes",component:"childEntityRecipes",mutation:"addChild"},_={section:"replaceRecipes",component:"replaceEntityRecipes",mutation:"replaceEntity"},u=new Set(["id","type","meta"]),O=new Set(["Query","Mutation","Navigation",d,f,A,"DryRunError",E,"JSON","String","Int","Float","Boolean","ID"]),I=new Set([d,f,E,A]),y=new Set(["id","type"]),b="A string, a message descriptor or a multilingual object; passed without translation.",h=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],g=(e,{property:t,writableKey:i},r,{resolveRef:s,exposed:o,sources:S},p)=>{let N=Object.entries(h(S,e)??{}),c=o.get(e)?.find(({source:e})=>e===t)?.name??N.find(([,{source:e}])=>e===t)?.[0],d=void 0===c?N.find(([e])=>e===t)?.[1]:void 0;if(d)return void p.at(i,t).error(a.ASSISTANT_FIELD_NAME_CONFLICT,l.ASSISTANT_FIELD_NAME_CONFLICT(e,t,[d.source,t],`${i}.${t}`));let{type:f,enumValues:A,localized:E,description:m}=T(r,s),_={...f,nonNull:!1},u=c??t,O=void 0===c?n(m,A):void 0;return E?{name:u,property:t,type:{kind:"scalar",name:"JSON",nonNull:!1},description:O?`${O} ${b}`:b}:{name:u,property:t,type:_,...void 0===O?{}:{description:O}}},v=(e,t,{model:i,components:r})=>{let n=new Set([e,...[...i.aliases].filter(([,t])=>t.includes(e)).map(([e])=>e)]);return r.filter(({componentName:e,typeOrAlias:i})=>e===t&&n.has(i)).map(({instanceName:e})=>String(e))},R=(...e)=>t.filter(t=>e.some(e=>e?.includes(t))),j=(e,t,i,r)=>{let{model:n}=i,s=new Map,o=new Map;for(let[S,{groups:p,hints:N}]of Object.entries(e)){let e=n.entityTypes.find(e=>e===S),T=e?[e]:[...n.aliases].find(([e])=>e===S)?.[1];if(!T){r.at(S).error(a.ASSISTANT_UNKNOWN_TYPE,l.ASSISTANT_UNKNOWN_TYPE(t.section,S));continue}for(let[e,n]of(T.forEach(e=>o.set(e,R(o.get(e),N))),Object.entries(p))){let o=r.at(S,"groups",e),p=`${S}.groups.${e}`,N={groupId:n?.as??e,instanceName:e,...n?.description===void 0?{}:{description:n.description},dryRuns:n?.allowDryRuns??!0};for(let r of T){let n=v(r,t.component,i),T=s.get(r)??[],c=T.find(e=>e.group.groupId===N.groupId);n.includes(e)?c?o.error(a.ASSISTANT_DUPLICATE_RECIPE_GROUP,l.ASSISTANT_DUPLICATE_RECIPE_GROUP(t,r,N.groupId,[c.entry,p])):s.set(r,[...T,{group:N,entry:p,entryCtx:o}]):o.error(a.ASSISTANT_UNKNOWN_RECIPE_GROUP,l.ASSISTANT_UNKNOWN_RECIPE_GROUP(t,S,e,r,n))}}}let S=n.entityTypes.flatMap(e=>{let t=s.get(e);return t?[{entityType:e,groups:t}]:[]});return{groups:Object.fromEntries(S.map(({entityType:e,groups:t})=>[e,t.map(({group:e})=>e)])),hints:o,metaEntries:new Map(S.flatMap(({entityType:e,groups:[t]})=>t?[[e,t.entryCtx]]:[]))}},M=e=>`${e}Meta`,D=e=>`${e.charAt(0).toUpperCase()+e.slice(1)}Result`,C=e=>{let t=(({anyOf:e,oneOf:t})=>[...e??[],...t??[]].filter(e=>"null"!==e.type))(e);return e.$ref||1!==t.length?e:t[0]},P=(e,t)=>{let{type:i,enumValues:r,localized:s,description:o}=T(e,t),a={...i,nonNull:!1},l=s?`${n(o,r)??""} ${b}`.trim():n(o,r);return{type:{...s?{kind:"scalar",name:"JSON",nonNull:!1}:a,nonNull:i.nonNull},...void 0===l?{}:{description:l}}},L=(t,i)=>{let r=(t=>{let i=C(t),r=i?.type==="array"&&i.items&&!e(i.items)?C(i.items):void 0,n=r??i;if(n?.$ref!==void 0&&"$DomainEntity"===N(n.$ref))return{target:n.references??c,list:void 0!==r}})(t);if(r)return{kind:"edge",...r,nullable:p(t,i),...void 0===t.description?{}:{description:t.description}};let{type:s,enumValues:o,localized:a,description:l}=T(t,i),S=n(l,o);return a?{kind:"value",type:{kind:"scalar",name:"JSON",nonNull:s.nonNull},description:`${l??""} ${b}`.trim()}:{kind:"value",type:s,...void 0===S?{}:{description:S}}},U=(e,t)=>{let{type:i,enumValues:r,localized:n,description:s}=T(e,t);return{type:{kind:"value",type:i},localized:!0===n,description:s,enumValues:r}},w=(e,t,i,r,s)=>{let o=t.startsWith("$")?((e,t,i,r)=>{let n=((e,t,{expressions:i,entityTypes:r})=>{let n=r.find(t=>t===e);for(let r of void 0===n?[e]:i.entityExpressions.get(n)?.shapeGroups??[]){let e=[...i.expressions.get(r)?.values()??[]].find(e=>e.name===t);if(e?.declaredSchema)return{implementation:e.implementation,declaredSchema:e.declaredSchema}}})(e.name,t,i);if(!n)return void r.error(a.ASSISTANT_UNKNOWN_FIELD,l.ASSISTANT_UNKNOWN_FIELD("entities",e.name,t));let{implementation:s}=n;if("violations"===s.kind)return void r.error(a.ASSISTANT_UNSUPPORTED_EXPRESSION,l.ASSISTANT_UNSUPPORTED_EXPRESSION(e.name,t));if("relation"===s.kind){let[{target:e,cardinality:t}]=s.params;return{type:{kind:"edge",target:e,cardinality:t},localized:!1,description:void 0}}return U(n.declaredSchema,i.resolveRef)})(e,t,r,s):((e,t,{resolveRef:i},r)=>{let n=Object.entries(e.shape.properties).find(([e])=>e===t)?.[1];return n?U(n,i):void r.error(a.ASSISTANT_UNKNOWN_FIELD,l.ASSISTANT_UNKNOWN_FIELD("entities",e.name,t))})(e,t,r,s);if(!o)return;let S=i?.as??(t.startsWith("$")?`_${t.slice(1)}`:t);return u.has(S)?void s.error(a.ASSISTANT_RESERVED_FIELD_NAME,l.ASSISTANT_RESERVED_FIELD_NAME(e.name,t,S)):{name:S,source:t,type:o.type,localized:o.localized,description:n(i?.description??o.description,o.enumValues),describedByManifest:i?.description!==void 0,enumValues:o.enumValues,valueDescription:i?.description??o.description,...i?.lenses?.length?{lenses:[...new Set(i.lenses)]}:{}}},$=(e,t,i,r,n)=>s(t,i,r,(t,i,r)=>{n.error(a.ASSISTANT_FIELD_NAME_CONFLICT,l.ASSISTANT_FIELD_NAME_CONFLICT(e,t,[i,r]))});export const resolveAssistantManifest=(e,{model:t,states:i,phxDefinitions:r,expressions:n,components:s,actions:p},N)=>{let d=N.errors.length,f=N.at("entities"),A=S(t.commonTypes,r);for(let e of t.resolvedShapes.keys())O.has(e)&&N.error(a.ASSISTANT_RESERVED_TYPE_NAME,l.ASSISTANT_RESERVED_TYPE_NAME(e,[...O]));let E=((e,t,i)=>{let r=new Map;for(let n of e){let e=[];for(let[r,s]of Object.entries(n.entries)){let o=w(n,r,s,t,i.at(n.name,r));o&&e.push(o)}r.set(n.name,e)}return r})(((e,t,i)=>{let r=[];for(let[i,n]of t.resolvedShapes){let t=e[i];t&&r.push({name:i,shape:n,entries:t})}let n=new Set(t.resolvedShapes.keys());for(let t of Object.keys(e))n.has(t)||i.at(t).error(a.ASSISTANT_UNKNOWN_TYPE,l.ASSISTANT_UNKNOWN_TYPE("entities",t));return r})(e.entities??{},t,f),{resolveRef:A,expressions:n,entityTypes:t.entityTypes},f),u=$(c,[],E.get(c)??[],()=>void 0,N),C=new Map([[c,u]]);for(let e of t.aliases.keys())e!==c&&C.set(e,$(e,[u],E.get(e)??[],()=>void 0,N));for(let e of t.entityTypes){let i=[c,...[...t.aliases].filter(([t,i])=>t!==c&&i.includes(e)).map(([e])=>e)],r=[...t.resolvedShapes].find(([t])=>t===e)?.[1];C.set(e,$(e,i.map(e=>C.get(e)??[]),E.get(e)??[],e=>{let t=Object.entries(r?.properties??{}).find(([t])=>t===e)?.[1];return t&&T(t,A).enumValues},N))}let U=Object.fromEntries(t.entityTypes.map(e=>[e,Object.fromEntries((C.get(e)??[]).map(({name:e,source:t,localized:i})=>[e,i?{source:t,localized:!0}:{source:t}]))])),F=j(e.childRecipes??{},m,{model:t,components:s},N.at("childRecipes")),W=j(e.replaceRecipes??{},_,{model:t,components:s},N.at("replaceRecipes")),k=((e,t,i)=>{let r=new Set;for(let n of Object.keys(e)){let e=t.entityTypes.find(e=>e===n),s=e?[e]:[...t.aliases].find(([e])=>e===n)?.[1];s?s.forEach(e=>r.add(e)):i.at(n).error(a.ASSISTANT_UNKNOWN_TYPE,l.ASSISTANT_UNKNOWN_TYPE("deletable",n))}return t.entityTypes.filter(e=>r.has(e))})(e.deletable??{},t,N.at("deletable")),K=((e,t,i)=>{let{model:r}=t,n=((e,t,i)=>{let r=new Map;for(let[n,s]of Object.entries(e)){let e=t.entityTypes.find(e=>e===n),o=e?[e]:[...t.aliases].find(([e])=>e===n)?.[1],S=[...t.resolvedShapes].find(([e])=>e===n)?.[1];if(!o||!S){i.at(n).error(a.ASSISTANT_UNKNOWN_TYPE,l.ASSISTANT_UNKNOWN_TYPE("writable",n));continue}for(let e of Object.keys(s)){let t=i.at(n,e);e.startsWith("$")||y.has(e)?t.error(a.ASSISTANT_NOT_WRITABLE,l.ASSISTANT_NOT_WRITABLE(n,e)):h(S.properties,e)?o.forEach(t=>{let i=r.get(t)??new Map;r.set(t,i.has(e)?i:i.set(e,n))}):t.error(a.ASSISTANT_UNKNOWN_FIELD,l.ASSISTANT_UNKNOWN_FIELD("writable",n,e))}}return r})(e,r,i);return r.entityTypes.flatMap(e=>{let s=[...r.resolvedShapes].find(([t])=>t===e)?.[1],o=[...n.get(e)??[]].flatMap(([r,n])=>{let o=s&&h(s.properties,r);return(o&&g(e,{property:r,writableKey:n},o,t,i))??[]});return o.length>0?[{entityType:e,fields:o}]:[]})})(e.writable??{},{model:t,resolveRef:A,exposed:E,sources:U},N.at("writable")),V=((e,t,i,r)=>{let{model:n}=i,s=new Map;for(let[o,S]of Object.entries(e)){let e=n.entityTypes.find(e=>e===o),p=e?[e]:[...n.aliases].find(([e])=>e===o)?.[1]??[];for(let[e,n]of Object.entries(S)){let S=n?.options;if(!S)continue;let N=r.at(o,e,"options"),T=`${o}.${e}`;for(let r of p){let n=t.find(e=>e.entityType===r)?.fields.find(t=>t.property===e);if(!n)continue;let o=S.as??`${n.name}Options`,p=v(r,S.componentType,i),c=s.get(r)??[],d=c.find(e=>e.options.edgeName===o||e.options.field===n.name);if(p.includes(S.instanceName))if(o===m.section||o===_.section)N.error(a.ASSISTANT_RESERVED_OPTIONS_EDGE_NAME,l.ASSISTANT_RESERVED_OPTIONS_EDGE_NAME(T,o,n.name));else if(d)N.error(a.ASSISTANT_DUPLICATE_OPTIONS_EDGE,l.ASSISTANT_DUPLICATE_OPTIONS_EDGE(r,d.options.edgeName===o?{edgeName:o}:{field:n.name},[d.entry,T]));else{let e={field:n.name,edgeName:o,componentType:S.componentType,instanceName:S.instanceName,validate:S.validate??!0,dryRuns:S.allowDryRuns??!0};s.set(r,[...c,{options:e,hints:R(S.hints),entry:T,entryCtx:N}])}else N.error(a.ASSISTANT_UNKNOWN_OPTIONS_COMPONENT,l.ASSISTANT_UNKNOWN_OPTIONS_COMPONENT(T,S,r,p))}}}return s})(e.writable??{},K,{model:t,components:s},N.at("writable"));var Y=[F.metaEntries,W.metaEntries,new Map([...V].flatMap(([e,[t]])=>t?[[e,t.entryCtx]]:[]))];for(let e of t.entityTypes){let i=Y.flatMap(t=>t.get(e)??[])[0],r=M(e);i&&[...t.resolvedShapes.keys()].some(e=>e===r)&&i.error(a.ASSISTANT_META_TYPE_NAME_CONFLICT,l.ASSISTANT_META_TYPE_NAME_CONFLICT(e,r))}let x=t.entityTypes.filter(e=>(F.groups[e]?.length??0)>0||(W.groups[e]?.length??0)>0||(V.get(e)?.length??0)>0).map(M),G=((e,{actions:t,resolveRef:i,builtInMutations:r,typeNames:n},s)=>{let o=[],S=[...t.values()].map(e=>String(e.name));for(let[p,N]of Object.entries(e)){let e=s.at(p),T=[...t.values()].find(e=>e.name===p);if(!T){e.error(a.ASSISTANT_UNKNOWN_ACTION,l.ASSISTANT_UNKNOWN_ACTION(p,S));continue}let c=N?.as??p,d=o.find(e=>e.fieldName===c),f=D(c);if(r.has(c)||d){e.error(a.ASSISTANT_MUTATION_NAME_CONFLICT,l.ASSISTANT_MUTATION_NAME_CONFLICT(p,c,d?`"assistant.actions.${d.actionName}" already exposes`:"the built-in mutation of that name already takes"));continue}if(n.has(f)||o.some(e=>D(e.fieldName)===f)){e.error(a.ASSISTANT_ACTION_RESULT_TYPE_CONFLICT,l.ASSISTANT_ACTION_RESULT_TYPE_CONFLICT(p,c,f));continue}let A=N?.description??T.description;o.push({fieldName:c,actionName:p,...void 0===A?{}:{description:A},args:Object.fromEntries(Object.entries(T.params).map(([e,{schema:t}])=>[e,P(t,i)])),result:Object.fromEntries(Object.entries(T.result).map(([e,t])=>[e,L(t,i)]))})}return o})(e.actions??{},{actions:p,resolveRef:A,builtInMutations:new Set(["deleteEntity",m.mutation,_.mutation,...K.map(({entityType:e})=>`modify${e}`)]),typeNames:new Set([...O,...t.resolvedShapes.keys(),...x])},N.at("actions")),z=((e,t)=>{let i=e.lenses??{},r=new Set;for(let[n,s]of Object.entries(e.entities??{}))for(let[e,o]of Object.entries(s))for(let s of o?.lenses??[])Object.hasOwn(i,s)?r.add(s):t.at("entities",n,e,"lenses").error(a.ASSISTANT_UNKNOWN_LENS,l.ASSISTANT_UNKNOWN_LENS(`${n}.${e}`,s,Object.keys(i)));for(let e of Object.keys(i))I.has(e)?t.at("lenses",e).error(a.ASSISTANT_RESERVED_LENS_NAME,l.ASSISTANT_RESERVED_LENS_NAME(e,[...I])):r.has(e)||t.at("lenses",e).error(a.ASSISTANT_EMPTY_LENS,l.ASSISTANT_EMPTY_LENS(e));return Object.fromEntries(Object.entries(i).map(([e,{description:t,maxDepth:i}])=>[e,{description:t,maxDepth:i??1}]))})(e,N);if(N.errors.length>d)return;let B=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{hints:R(t.hints),groups:Object.entries(t.groups).map(([e,t])=>({instanceName:e,groupId:t?.as??e,...t?.description===void 0?{}:{description:t.description},dryRuns:t?.allowDryRuns??!0}))}]));return{declarations:{entities:Object.fromEntries(Object.keys(e.entities??{}).map(e=>[e,(E.get(e)??[]).map(e=>({name:e.name,source:e.source,type:e.type,localized:e.localized,describedByManifest:e.describedByManifest,...void 0===e.description?{}:{description:e.description},...void 0===e.valueDescription?{}:{valueDescription:e.valueDescription},...void 0===e.enumValues?{}:{enumValues:e.enumValues},...void 0===e.lenses?{}:{lenses:e.lenses}}))])),enumValues:Object.fromEntries(t.entityTypes.map(e=>[e,Object.fromEntries(Object.entries(t.resolvedShapes.get(e)?.properties??{}).flatMap(([e,t])=>{let i=T(t,A).enumValues;return i?[[e,i]]:[]}))])),deletable:Object.keys(e.deletable??{}),writable:Object.fromEntries(Object.entries(e.writable??{}).map(([e,i])=>[e,Object.fromEntries(Object.entries(i).map(([i,r])=>[i,{defaultOptionsName:r?.options?.as===void 0,members:Object.fromEntries(t.entityTypes.filter(i=>i===e||[...t.aliases].find(([t])=>t===e)?.[1].includes(i)).flatMap(r=>{let n=h(t.resolvedShapes.get(r)?.properties??{},i),s=n&&g(r,{property:i,writableKey:e},n,{model:t,resolveRef:A,exposed:new Map,sources:{}},N.at("writable")),o=V.get(r)?.find(t=>t.entry===`${e}.${i}`);return s?[[r,{field:s,...T(n,A).localized?{exposedDescription:b}:{},...o?{options:{options:o.options,hints:o.hints}}:{}}]]:[]}))}]))])),childRecipes:B(e.childRecipes??{}),replaceRecipes:B(e.replaceRecipes??{})},entityTypes:t.entityTypes,aliases:Object.fromEntries(t.aliases),exampleType:t.rootEntityTypes[0]??t.entityTypes[0],states:{navigationStates:i.navigationStates,viewStates:i.viewStates,toolStates:i.toolStates},deletableTypes:k,writableTypes:K,actionFields:G,childRecipes:Object.fromEntries(Object.entries(F.groups).map(([e,t])=>[e,{groups:t,hints:F.hints.get(e)??[]}])),replaceRecipes:Object.fromEntries(Object.entries(W.groups).map(([e,t])=>[e,{groups:t,hints:W.hints.get(e)??[]}])),optionsEdges:Object.fromEntries([...V].map(([e,t])=>[e,t.map(({options:e,hints:t})=>({options:e,hints:t}))])),fields:Object.fromEntries([...C].map(([e,t])=>[e,t.map(t=>o(t,E.get(e)??[]))])),lenses:z}};export const createAssistantSchema=(e,t,n)=>{let s=resolveAssistantManifest(e,t,n);if(s)try{return{...r(s),resolved:s}}catch(e){if(e instanceof i)return void n.at("entities").error(a.ASSISTANT_FIELD_SHAPE_CONFLICT,l.ASSISTANT_FIELD_SHAPE_CONFLICT(e.fieldName,e.exposures));n.error(a.ASSISTANT_INVALID_SCHEMA,l.ASSISTANT_INVALID_SCHEMA([e instanceof Error?e.message:String(e)]));return}};
1
+ import{isArray as e}from"@salsita-ai/common/utils";import{ASSISTANT_HINTS as t,AssistantFieldClashError as r,buildAssistantManifest as i,describeAssistantValues as n,mergeAssistantFields as s,resolveAssistantField as o}from"#package/domain";import{DiagnosticCode as a,diagnosticMessages as l}from"../../../../errors/index.js";import{createSchemaRefResolver as S,isNullableSchema as p,phxDefinitionRefName as N}from"../../common/index.js";import{resolveAssistantFieldType as T}from"./assistant-field-type.js";import{resolveFormElements as c}from"./assistant-form-elements.js";let d="AnyDomainEntity",E="RecipeGroup",f="Recipe",A="DryRun",_="FieldOption",m="agentScreenshot",u=/^(?!(true|false|null)$)[_A-Za-z][_0-9A-Za-z]*$/,O={section:"childRecipes",component:"childEntityRecipes",mutation:"addChild"},I={section:"replaceRecipes",component:"replaceEntityRecipes",mutation:"replaceEntity"},y=new Set(["id","type","meta"]),h=new Set(["Query","Mutation","Navigation",E,f,A,"DryRunError",_,"Screenshot","JSON","String","Int","Float","Boolean","ID"]),v=new Set([E,f,_,A]),b=new Set(["id","type"]),g="A string, a message descriptor or a multilingual object; passed without translation.",R=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],M=(e,{property:t,writableKey:r},i,{resolveRef:s,exposed:o,sources:S},p)=>{let N=Object.entries(R(S,e)??{}),c=o.get(e)?.find(({source:e})=>e===t)?.name??N.find(([,{source:e}])=>e===t)?.[0],d=void 0===c?N.find(([e])=>e===t)?.[1]:void 0;if(d)return void p.at(r,t).error(a.ASSISTANT_FIELD_NAME_CONFLICT,l.ASSISTANT_FIELD_NAME_CONFLICT(e,t,[d.source,t],`${r}.${t}`));let{type:E,enumValues:f,localized:A,description:_}=T(i,s),m={...E,nonNull:!1},u=c??t,O=void 0===c?n(_,f):void 0;return A?{name:u,property:t,type:{kind:"scalar",name:"JSON",nonNull:!1},description:O?`${O} ${g}`:g}:{name:u,property:t,type:m,...void 0===O?{}:{description:O}}},C=(e,t,{model:r,components:i})=>{let n=new Set([e,...[...r.aliases].filter(([,t])=>t.includes(e)).map(([e])=>e)]);return i.filter(({componentName:e,typeOrAlias:r})=>e===t&&n.has(r)).map(({instanceName:e})=>String(e))},j=(...e)=>t.filter(t=>e.some(e=>e?.includes(t))),w=(e,t,r,i)=>{let{model:n}=r,s=new Map,o=new Map;for(let[S,{groups:p,hints:N}]of Object.entries(e)){let e=n.entityTypes.find(e=>e===S),T=e?[e]:[...n.aliases].find(([e])=>e===S)?.[1];if(!T){i.at(S).error(a.ASSISTANT_UNKNOWN_TYPE,l.ASSISTANT_UNKNOWN_TYPE(t.section,S));continue}for(let[e,n]of(T.forEach(e=>o.set(e,j(o.get(e),N))),Object.entries(p))){let o=i.at(S,"groups",e),p=`${S}.groups.${e}`,N={groupId:n?.as??e,instanceName:e,...n?.description===void 0?{}:{description:n.description},dryRuns:n?.allowDryRuns??!0};for(let i of T){let n=C(i,t.component,r),T=s.get(i)??[],c=T.find(e=>e.group.groupId===N.groupId);n.includes(e)?c?o.error(a.ASSISTANT_DUPLICATE_RECIPE_GROUP,l.ASSISTANT_DUPLICATE_RECIPE_GROUP(t,i,N.groupId,[c.entry,p])):s.set(i,[...T,{group:N,entry:p,entryCtx:o}]):o.error(a.ASSISTANT_UNKNOWN_RECIPE_GROUP,l.ASSISTANT_UNKNOWN_RECIPE_GROUP(t,S,e,i,n))}}}let S=n.entityTypes.flatMap(e=>{let t=s.get(e);return t?[{entityType:e,groups:t}]:[]});return{groups:Object.fromEntries(S.map(({entityType:e,groups:t})=>[e,t.map(({group:e})=>e)])),hints:o,metaEntries:new Map(S.flatMap(({entityType:e,groups:[t]})=>t?[[e,t.entryCtx]]:[]))}},P=(e,t,{model:r,components:i})=>{let n=new Set([e,...[...r.aliases].filter(([,t])=>t.includes(e)).map(([e])=>e)]),s=i.find(e=>e.componentName===m&&String(e.instanceName)===t&&n.has(e.typeOrAlias));if(s?.implementation.kind!=="userBound"||"composite"!==s.implementation.implementation.kind)return;let o=s.implementation.implementation.resolvedProps.exportState;return"string"==typeof o?o:void 0},D=e=>`${e}Meta`,L=e=>`${e}ScreenshotView`,U=e=>`${e.charAt(0).toUpperCase()+e.slice(1)}Result`,W=e=>{let t=(({anyOf:e,oneOf:t})=>[...e??[],...t??[]].filter(e=>"null"!==e.type))(e);return e.$ref||1!==t.length?e:t[0]},$=(e,t)=>{let{type:r,enumValues:i,localized:s,description:o}=T(e,t),a={...r,nonNull:!1},l=s?`${n(o,i)??""} ${g}`.trim():n(o,i);return{type:{...s?{kind:"scalar",name:"JSON",nonNull:!1}:a,nonNull:r.nonNull},...void 0===l?{}:{description:l}}},F=(t,r)=>{let i=(t=>{let r=W(t),i=r?.type==="array"&&r.items&&!e(r.items)?W(r.items):void 0,n=i??r;if(n?.$ref!==void 0&&"$DomainEntity"===N(n.$ref))return{target:n.references??d,list:void 0!==i}})(t);if(i)return{kind:"edge",...i,nullable:p(t,r),...void 0===t.description?{}:{description:t.description}};let{type:s,enumValues:o,localized:a,description:l}=T(t,r),S=n(l,o);return a?{kind:"value",type:{kind:"scalar",name:"JSON",nonNull:s.nonNull},description:`${l??""} ${g}`.trim()}:{kind:"value",type:s,...void 0===S?{}:{description:S}}},V=(e,t)=>{let{type:r,enumValues:i,localized:n,description:s}=T(e,t);return{type:{kind:"value",type:r},localized:!0===n,description:s,enumValues:i}},K=(e,t,r,i,s)=>{let o=t.startsWith("$")?((e,t,r,i)=>{let n=((e,t,{expressions:r,entityTypes:i})=>{let n=i.find(t=>t===e);for(let i of void 0===n?[e]:r.entityExpressions.get(n)?.shapeGroups??[]){let e=[...r.expressions.get(i)?.values()??[]].find(e=>e.name===t);if(e?.declaredSchema)return{implementation:e.implementation,declaredSchema:e.declaredSchema}}})(e.name,t,r);if(!n)return void i.error(a.ASSISTANT_UNKNOWN_FIELD,l.ASSISTANT_UNKNOWN_FIELD("entities",e.name,t));let{implementation:s}=n;if("violations"===s.kind)return void i.error(a.ASSISTANT_UNSUPPORTED_EXPRESSION,l.ASSISTANT_UNSUPPORTED_EXPRESSION(e.name,t));if("relation"===s.kind){let[{target:e,cardinality:t}]=s.params;return{type:{kind:"edge",target:e,cardinality:t},localized:!1,description:void 0}}return V(n.declaredSchema,r.resolveRef)})(e,t,i,s):((e,t,{resolveRef:r},i)=>{let n=Object.entries(e.shape.properties).find(([e])=>e===t)?.[1];return n?V(n,r):void i.error(a.ASSISTANT_UNKNOWN_FIELD,l.ASSISTANT_UNKNOWN_FIELD("entities",e.name,t))})(e,t,i,s);if(!o)return;let S=r?.as??(t.startsWith("$")?`_${t.slice(1)}`:t);return y.has(S)?void s.error(a.ASSISTANT_RESERVED_FIELD_NAME,l.ASSISTANT_RESERVED_FIELD_NAME(e.name,t,S)):{name:S,source:t,type:o.type,localized:o.localized,description:n(r?.description??o.description,o.enumValues),describedByManifest:r?.description!==void 0,enumValues:o.enumValues,valueDescription:r?.description??o.description,...r?.lenses?.length?{lenses:[...new Set(r.lenses)]}:{}}},k=(e,t,r,i,n)=>s(t,r,i,(t,r,i)=>{n.error(a.ASSISTANT_FIELD_NAME_CONFLICT,l.ASSISTANT_FIELD_NAME_CONFLICT(e,t,[r,i]))});export const resolveAssistantManifest=(e,{model:t,states:r,phxDefinitions:i,expressions:n,components:s,actions:p},N)=>{let E=N.errors.length,f=N.at("entities"),A=S(t.commonTypes,i);for(let e of t.resolvedShapes.keys())h.has(e)&&N.error(a.ASSISTANT_RESERVED_TYPE_NAME,l.ASSISTANT_RESERVED_TYPE_NAME(e,[...h]));let _=((e,t,r)=>{let i=new Map;for(let n of e){let e=[];for(let[i,s]of Object.entries(n.entries)){let o=K(n,i,s,t,r.at(n.name,i));o&&e.push(o)}i.set(n.name,e)}return i})(((e,t,r)=>{let i=[];for(let[r,n]of t.resolvedShapes){let t=e[r];t&&i.push({name:r,shape:n,entries:t})}let n=new Set(t.resolvedShapes.keys());for(let t of Object.keys(e))n.has(t)||r.at(t).error(a.ASSISTANT_UNKNOWN_TYPE,l.ASSISTANT_UNKNOWN_TYPE("entities",t));return i})(e.entities??{},t,f),{resolveRef:A,expressions:n,entityTypes:t.entityTypes},f),y=k(d,[],_.get(d)??[],()=>void 0,N),W=new Map([[d,y]]);for(let e of t.aliases.keys())e!==d&&W.set(e,k(e,[y],_.get(e)??[],()=>void 0,N));for(let e of t.entityTypes){let r=[d,...[...t.aliases].filter(([t,r])=>t!==d&&r.includes(e)).map(([e])=>e)],i=[...t.resolvedShapes].find(([t])=>t===e)?.[1];W.set(e,k(e,r.map(e=>W.get(e)??[]),_.get(e)??[],e=>{let t=Object.entries(i?.properties??{}).find(([t])=>t===e)?.[1];return t&&T(t,A).enumValues},N))}let V=Object.fromEntries(t.entityTypes.map(e=>[e,Object.fromEntries((W.get(e)??[]).map(({name:e,source:t,localized:r})=>[e,r?{source:t,localized:!0}:{source:t}]))])),Y=w(e.childRecipes??{},O,{model:t,components:s},N.at("childRecipes")),x=w(e.replaceRecipes??{},I,{model:t,components:s},N.at("replaceRecipes")),H=((e,t,r)=>{let i=new Set;for(let n of Object.keys(e)){let e=t.entityTypes.find(e=>e===n),s=e?[e]:[...t.aliases].find(([e])=>e===n)?.[1];s?s.forEach(e=>i.add(e)):r.at(n).error(a.ASSISTANT_UNKNOWN_TYPE,l.ASSISTANT_UNKNOWN_TYPE("deletable",n))}return t.entityTypes.filter(e=>i.has(e))})(e.deletable??{},t,N.at("deletable")),z=((e,t,r)=>{let{model:i}=t,n=((e,t,r)=>{let i=new Map;for(let[n,s]of Object.entries(e)){let e=t.entityTypes.find(e=>e===n),o=e?[e]:[...t.aliases].find(([e])=>e===n)?.[1],S=[...t.resolvedShapes].find(([e])=>e===n)?.[1];if(!o||!S){r.at(n).error(a.ASSISTANT_UNKNOWN_TYPE,l.ASSISTANT_UNKNOWN_TYPE("writable",n));continue}for(let e of Object.keys(s)){let t=r.at(n,e);e.startsWith("$")||b.has(e)?t.error(a.ASSISTANT_NOT_WRITABLE,l.ASSISTANT_NOT_WRITABLE(n,e)):R(S.properties,e)?o.forEach(t=>{let r=i.get(t)??new Map;i.set(t,r.has(e)?r:r.set(e,n))}):t.error(a.ASSISTANT_UNKNOWN_FIELD,l.ASSISTANT_UNKNOWN_FIELD("writable",n,e))}}return i})(e,i,r);return i.entityTypes.flatMap(e=>{let s=[...i.resolvedShapes].find(([t])=>t===e)?.[1],o=[...n.get(e)??[]].flatMap(([i,n])=>{let o=s&&R(s.properties,i);return(o&&M(e,{property:i,writableKey:n},o,t,r))??[]});return o.length>0?[{entityType:e,fields:o}]:[]})})(e.writable??{},{model:t,resolveRef:A,exposed:_,sources:V},N.at("writable")),G=((e,t,r,i)=>{let{model:n}=r,s=new Map;for(let[o,S]of Object.entries(e)){let e=n.entityTypes.find(e=>e===o),p=e?[e]:[...n.aliases].find(([e])=>e===o)?.[1]??[];for(let[e,n]of Object.entries(S)){let S=n?.options;if(!S)continue;let N=i.at(o,e,"options"),T=`${o}.${e}`;for(let i of p){let n=t.find(e=>e.entityType===i)?.fields.find(t=>t.property===e);if(!n)continue;let o=S.as??`${n.name}Options`,p=C(i,S.componentType,r),c=s.get(i)??[],d=c.find(e=>e.options.edgeName===o||e.options.field===n.name);if(p.includes(S.instanceName))if(o===O.section||o===I.section||"screenshot"===o)N.error(a.ASSISTANT_RESERVED_OPTIONS_EDGE_NAME,l.ASSISTANT_RESERVED_OPTIONS_EDGE_NAME(T,o,n.name));else if(d)N.error(a.ASSISTANT_DUPLICATE_OPTIONS_EDGE,l.ASSISTANT_DUPLICATE_OPTIONS_EDGE(i,d.options.edgeName===o?{edgeName:o}:{field:n.name},[d.entry,T]));else{let e={field:n.name,edgeName:o,componentType:S.componentType,instanceName:S.instanceName,validate:S.validate??!0,dryRuns:S.allowDryRuns??!0};s.set(i,[...c,{options:e,hints:j(S.hints),entry:T,entryCtx:N}])}else N.error(a.ASSISTANT_UNKNOWN_OPTIONS_COMPONENT,l.ASSISTANT_UNKNOWN_OPTIONS_COMPONENT(T,S,i,p))}}}return s})(e.writable??{},z,{model:t,components:s},N.at("writable")),B=((e,t,r)=>{let{model:i,states:n}=t,s=new Map;for(let[o,S]of Object.entries(e)){let e=i.entityTypes.find(e=>e===o),p=e?[e]:[...i.aliases].find(([e])=>e===o)?.[1];if(!p){r.at(o).error(a.ASSISTANT_UNKNOWN_TYPE,l.ASSISTANT_UNKNOWN_TYPE("screenshots",o));continue}for(let[e,{description:i,as:N}]of Object.entries(S)){let S=r.at(o,e),T=`${o}.${e}`,c={view:N??e,instanceName:e,description:i};if(!u.test(c.view)){S.error(a.ASSISTANT_INVALID_SCREENSHOT_VIEW_NAME,l.ASSISTANT_INVALID_SCREENSHOT_VIEW_NAME(o,e,c.view));continue}for(let r of p){let i=C(r,m,t),p=P(r,e,t),N=s.get(r)??[],d=N.find(e=>e.view.view===c.view);i.includes(e)?void 0===p||n.exportStates.includes(p)?d?S.error(a.ASSISTANT_DUPLICATE_SCREENSHOT_VIEW,l.ASSISTANT_DUPLICATE_SCREENSHOT_VIEW(r,c.view,[d.entry,T])):s.set(r,[...N,{view:c,entry:T,entryCtx:S}]):S.error(a.ASSISTANT_UNKNOWN_SCREENSHOT_EXPORT_STATE,l.ASSISTANT_UNKNOWN_SCREENSHOT_EXPORT_STATE(o,e,p,n.exportStates)):S.error(a.ASSISTANT_UNKNOWN_SCREENSHOT_VIEW,l.ASSISTANT_UNKNOWN_SCREENSHOT_VIEW(o,e,r,i))}}}let o=i.entityTypes.flatMap(e=>{let t=s.get(e);return t?[{entityType:e,views:t}]:[]});return{views:new Map(o.map(({entityType:e,views:t})=>[e,t.map(({view:e})=>e)])),metaEntries:new Map(o.flatMap(({entityType:e,views:[t]})=>t?[[e,t.entryCtx]]:[]))}})(e.screenshots??{},{model:t,components:s,states:r},N.at("screenshots"));var J=[Y.metaEntries,x.metaEntries,new Map([...G].flatMap(([e,[t]])=>t?[[e,t.entryCtx]]:[])),B.metaEntries];for(let e of t.entityTypes){let r=J.flatMap(t=>t.get(e)??[])[0],i=D(e);r&&[...t.resolvedShapes.keys()].some(e=>e===i)&&r.error(a.ASSISTANT_META_TYPE_NAME_CONFLICT,l.ASSISTANT_META_TYPE_NAME_CONFLICT(e,i))}for(let[e,r]of B.metaEntries){let i=L(e);[...t.resolvedShapes.keys()].some(e=>e===i)&&r.error(a.ASSISTANT_SCREENSHOT_VIEW_TYPE_NAME_CONFLICT,l.ASSISTANT_SCREENSHOT_VIEW_TYPE_NAME_CONFLICT(e,i))}let X=t.entityTypes.filter(e=>(Y.groups[e]?.length??0)>0||(x.groups[e]?.length??0)>0||(G.get(e)?.length??0)>0||B.views.has(e)).flatMap(e=>[D(e),...B.views.has(e)?[L(e)]:[]]),Z=((e,{actions:t,resolveRef:r,builtInMutations:i,typeNames:n},s)=>{let o=[],S=[...t.values()].map(e=>String(e.name));for(let[p,N]of Object.entries(e)){let e=s.at(p),T=[...t.values()].find(e=>e.name===p);if(!T){e.error(a.ASSISTANT_UNKNOWN_ACTION,l.ASSISTANT_UNKNOWN_ACTION(p,S));continue}let c=N?.as??p,d=o.find(e=>e.fieldName===c),E=U(c);if(i.has(c)||d){e.error(a.ASSISTANT_MUTATION_NAME_CONFLICT,l.ASSISTANT_MUTATION_NAME_CONFLICT(p,c,d?`"assistant.actions.${d.actionName}" already exposes`:"the built-in mutation of that name already takes"));continue}if(n.has(E)||o.some(e=>U(e.fieldName)===E)){e.error(a.ASSISTANT_ACTION_RESULT_TYPE_CONFLICT,l.ASSISTANT_ACTION_RESULT_TYPE_CONFLICT(p,c,E));continue}let f=N?.description??T.description;o.push({fieldName:c,actionName:p,...void 0===f?{}:{description:f},args:Object.fromEntries(Object.entries(T.params).map(([e,{schema:t}])=>[e,$(t,r)])),result:Object.fromEntries(Object.entries(T.result).map(([e,t])=>[e,F(t,r)]))})}return o})(e.actions??{},{actions:p,resolveRef:A,builtInMutations:new Set(["deleteEntity",O.mutation,I.mutation,...z.map(({entityType:e})=>`modify${e}`)]),typeNames:new Set([...h,...t.resolvedShapes.keys(),...X])},N.at("actions")),Q=((e,t)=>{let r=e.lenses??{},i=new Set;for(let[n,s]of Object.entries(e.entities??{}))for(let[e,o]of Object.entries(s))for(let s of o?.lenses??[])Object.hasOwn(r,s)?i.add(s):t.at("entities",n,e,"lenses").error(a.ASSISTANT_UNKNOWN_LENS,l.ASSISTANT_UNKNOWN_LENS(`${n}.${e}`,s,Object.keys(r)));for(let e of Object.keys(r))v.has(e)?t.at("lenses",e).error(a.ASSISTANT_RESERVED_LENS_NAME,l.ASSISTANT_RESERVED_LENS_NAME(e,[...v])):i.has(e)||t.at("lenses",e).error(a.ASSISTANT_EMPTY_LENS,l.ASSISTANT_EMPTY_LENS(e));return Object.fromEntries(Object.entries(r).map(([e,{description:t,maxDepth:r}])=>[e,{description:t,maxDepth:r??1}]))})(e,N),q=c(e.formElements??{},N.at("formElements"));if(N.errors.length>E)return;let ee=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{hints:j(t.hints),groups:Object.entries(t.groups).map(([e,t])=>({instanceName:e,groupId:t?.as??e,...t?.description===void 0?{}:{description:t.description},dryRuns:t?.allowDryRuns??!0}))}]));return{declarations:{entities:Object.fromEntries(Object.keys(e.entities??{}).map(e=>[e,(_.get(e)??[]).map(e=>({name:e.name,source:e.source,type:e.type,localized:e.localized,describedByManifest:e.describedByManifest,...void 0===e.description?{}:{description:e.description},...void 0===e.valueDescription?{}:{valueDescription:e.valueDescription},...void 0===e.enumValues?{}:{enumValues:e.enumValues},...void 0===e.lenses?{}:{lenses:e.lenses}}))])),enumValues:Object.fromEntries(t.entityTypes.map(e=>[e,Object.fromEntries(Object.entries(t.resolvedShapes.get(e)?.properties??{}).flatMap(([e,t])=>{let r=T(t,A).enumValues;return r?[[e,r]]:[]}))])),deletable:Object.keys(e.deletable??{}),writable:Object.fromEntries(Object.entries(e.writable??{}).map(([e,r])=>[e,Object.fromEntries(Object.entries(r).map(([r,i])=>[r,{defaultOptionsName:i?.options?.as===void 0,members:Object.fromEntries(t.entityTypes.filter(r=>r===e||[...t.aliases].find(([t])=>t===e)?.[1].includes(r)).flatMap(i=>{let n=R(t.resolvedShapes.get(i)?.properties??{},r),s=n&&M(i,{property:r,writableKey:e},n,{model:t,resolveRef:A,exposed:new Map,sources:{}},N.at("writable")),o=G.get(i)?.find(t=>t.entry===`${e}.${r}`);return s?[[i,{field:s,...T(n,A).localized?{exposedDescription:g}:{},...o?{options:{options:o.options,hints:o.hints}}:{}}]]:[]}))}]))])),childRecipes:ee(e.childRecipes??{}),replaceRecipes:ee(e.replaceRecipes??{}),screenshots:Object.fromEntries(Object.entries(e.screenshots??{}).map(([e,t])=>[e,Object.entries(t).map(([e,{description:t,as:r}])=>({view:r??e,instanceName:e,description:t}))]))},entityTypes:t.entityTypes,aliases:Object.fromEntries(t.aliases),exampleType:t.rootEntityTypes[0]??t.entityTypes[0],states:{navigationStates:r.navigationStates,viewStates:r.viewStates,toolStates:r.toolStates},deletableTypes:H,writableTypes:z,actionFields:Z,childRecipes:Object.fromEntries(Object.entries(Y.groups).map(([e,t])=>[e,{groups:t,hints:Y.hints.get(e)??[]}])),replaceRecipes:Object.fromEntries(Object.entries(x.groups).map(([e,t])=>[e,{groups:t,hints:x.hints.get(e)??[]}])),optionsEdges:Object.fromEntries([...G].map(([e,t])=>[e,t.map(({options:e,hints:t})=>({options:e,hints:t}))])),screenshots:Object.fromEntries(B.views),fields:Object.fromEntries([...W].map(([e,t])=>[e,t.map(t=>o(t,_.get(e)??[]))])),lenses:Q,formElements:q}};export const createAssistantSchema=(e,t,n)=>{let s=resolveAssistantManifest(e,t,n);if(s)try{return{...i(s),resolved:s}}catch(e){if(e instanceof r)return void n.at("entities").error(a.ASSISTANT_FIELD_SHAPE_CONFLICT,l.ASSISTANT_FIELD_SHAPE_CONFLICT(e.fieldName,e.exposures));n.error(a.ASSISTANT_INVALID_SCHEMA,l.ASSISTANT_INVALID_SCHEMA([e instanceof Error?e.message:String(e)]));return}};
@@ -1 +1 @@
1
- import{jsx as r,jsxs as e}from"react/jsx-runtime";import{I18nProvider as o}from"@lingui/react";import{QueryClientProvider as i}from"@tanstack/react-query";import n from"mui-modal-provider";import{useEffect as t}from"react";import{standardWebComponentProperties as c}from"#package/domain";import{getAvailableLocales as a,resolveLocale as m}from"#package/i18n";import{ApplicationType as l,ApplicationTypeProvider as d,InvalidDeploymentReload as p,LoadingStateProvider as s,SessionServiceProvider as f,useApplicationQueryClient as u,useI18n as h,useSpecAlwaysExpand as g,useSpecAppLoader as x,useSpecPrefetchTextureUrls as j,useSpecPreview as k,useWebComponentProperty$ as v,useWebComponentPropertySetter as b,useWebComponentPropertyValue as y,useWebComponentReadonlySync as C}from"#package/react-sdk";import{SnackbarProvider as w}from"#package/ui-sdk";import{ConfiguratorDataProvider as E}from"./configurator-context/ConfiguratorDataProvider.js";import{ConfiguratorResponsiveProvider as I}from"./configurator-context/ConfiguratorResponsiveProvider.js";import{usePowerRoutingLifecycle as L}from"./configurator-context/configurator-routing/use-power-routing-lifecycle.js";import{ConfiguratorRoutingProvider as P,OnApplicationStartProvider as Z,OnRoutingReadyProvider as q,OnSessionReadyProvider as A,PresetSelectionProvider as B,PreviewApplicationProvider as D}from"./configurator-context/index.js";import{LoadingErrorBoundary as F}from"./pages/error-boundaries/LoadingErrorBoundary.js";import{GeneralErrorFallback as R,RootPage as S}from"./pages/index.js";import{SceneResourcesProvider as T}from"./scene/index.js";import{EncapsulatedConfiguratorTheme as U}from"./ui/index.js";import{AppLoader as z}from"./ui/phoenix-layout-elements/index.js";export const ConfiguratorApp=()=>{let G=u(),H=h(),J=x(),K=k(),M=g(),N=j(),O=b(c.locale),Q=v(c.locale);C(),t(()=>{let r=Q.subscribe(r=>{let e=m(r,a(H));H.activate(e)}),e=()=>{O(H.locale)};return H.on("change",e),()=>{r.unsubscribe(),H.removeListener("change",e)}},[Q,H,O]);let V=y(c.containerZIndex),W=y(c.power);return(L(),"off"===W)?null:r(d,{type:l.Configurator,children:r(i,{client:G,children:r(U,{children:r(s,{children:r(I,{containerZIndex:V,children:r(z,{mode:J,children:r(D,{alwaysExpand:M,preview:K,children:r(o,{i18n:H,children:r(w,{maxSnack:5,children:r(F,{FallbackComponent:R,children:r(T,{prefetchTextureUrls:N,children:r(Z,{children:r(f,{children:r(A,{children:"on"===W&&r(P,{children:r(E,{children:r(B,{children:r(q,{children:e(n,{children:[r(p,{}),r(S,{})]})})})})})})})})})})})})})})})})})})})};
1
+ import{jsx as r,jsxs as e}from"react/jsx-runtime";import{I18nProvider as o}from"@lingui/react";import{QueryClientProvider as i}from"@tanstack/react-query";import n from"mui-modal-provider";import{useEffect as t}from"react";import{standardWebComponentProperties as c}from"#package/domain";import{getAvailableLocales as a,resolveLocale as m}from"#package/i18n";import{ApplicationType as l,ApplicationTypeProvider as d,InvalidDeploymentReload as p,LoaderHost as s,SessionServiceProvider as f,useApplicationQueryClient as u,useI18n as h,useSpecAlwaysExpand as g,useSpecAppLoader as x,useSpecPrefetchTextureUrls as j,useSpecPreview as k,useWebComponentProperty$ as v,useWebComponentPropertySetter as b,useWebComponentPropertyValue as y}from"#package/react-sdk";import{SnackbarProvider as C}from"#package/ui-sdk";import{ConfiguratorDataProvider as w}from"./configurator-context/ConfiguratorDataProvider.js";import{ConfiguratorResponsiveProvider as E}from"./configurator-context/ConfiguratorResponsiveProvider.js";import{usePowerRoutingLifecycle as I}from"./configurator-context/configurator-routing/use-power-routing-lifecycle.js";import{ConfiguratorRoutingProvider as L,OnApplicationStartProvider as P,OnRoutingReadyProvider as Z,OnSessionReadyProvider as q,PresetSelectionProvider as A,PreviewApplicationProvider as B}from"./configurator-context/index.js";import{LoadingErrorBoundary as D}from"./pages/error-boundaries/LoadingErrorBoundary.js";import{GeneralErrorFallback as F,RootPage as R}from"./pages/index.js";import{SceneResourcesProvider as S}from"./scene/index.js";import{EncapsulatedConfiguratorTheme as T}from"./ui/index.js";import{AppLoader as U}from"./ui/phoenix-layout-elements/index.js";export const ConfiguratorApp=()=>{let z=u(),G=h(),H=x(),J=k(),K=g(),M=j(),N=b(c.locale),O=v(c.locale);t(()=>{let r=O.subscribe(r=>{let e=m(r,a(G));G.activate(e)}),e=()=>{N(G.locale)};return G.on("change",e),()=>{r.unsubscribe(),G.removeListener("change",e)}},[O,G,N]);let Q=y(c.containerZIndex),V=y(c.power);return(I(),"off"===V)?null:r(d,{type:l.Configurator,children:r(i,{client:z,children:r(T,{children:r(s,{children:r(E,{containerZIndex:Q,children:r(U,{mode:H,children:r(B,{alwaysExpand:K,preview:J,children:r(o,{i18n:G,children:r(C,{maxSnack:5,children:r(D,{FallbackComponent:F,children:r(S,{prefetchTextureUrls:M,children:r(P,{children:r(f,{children:r(q,{children:"on"===V&&r(L,{children:r(w,{children:r(A,{children:r(Z,{children:e(n,{children:[r(p,{}),r(R,{})]})})})})})})})})})})})})})})})})})})})};
@@ -1,2 +1 @@
1
- export { AppLoaderContentName } from './app-loader-content-name.js';
2
1
  export { DefaultAppLoaderContent } from './DefaultAppLoaderContent.js';
@@ -1 +1 @@
1
- export{AppLoaderContentName}from"./app-loader-content-name.js";export{DefaultAppLoaderContent}from"./DefaultAppLoaderContent.js";
1
+ export{DefaultAppLoaderContent}from"./DefaultAppLoaderContent.js";
@@ -1 +1 @@
1
- import{createSelector as e}from"@salsita-ai/common/utils";import{createSessionAssistant as t,isAssistantSetupHandler as n}from"#package/domain";import{AnimationSystem as s,AssistantSystem as o,CameraControlSystem as r,CameraSystem as a,CanvasSystem as i,DragAndDropSystem as g,ExportSystem as m,GraphQLSystem as c,ImageRenderingSystem as l,LayoutSystem as S,SketchingSystem as u}from"./systems/index.js";export const createConfiguratorExtensionSelectors=y=>{let{getState:C,domainContextSelectors:d,specSelectors:f,domainServicesSelectors:p,accessSelectors:w,commonServicesSelectors:h}=y,x=e.withTypes()([f.selectConfiguratorSpec,d.selectInitializationContext],(e,s)=>t({resolved:e.assistant,handler:e.handlers.find(n),inputs:s&&s.access?{role:s.role,sessionData:s.sessionData,access:s.access}:null})),A={getConfigurationId:()=>w.getConfiguratorConfigurationId(),getAuthorizedClient:()=>h.getConfiguratorAuthorizedClient(),getAssistantSetup:()=>x(C()),domainContextSelectors:d,domainServicesSelectors:p,specSelectors:f},D={getSystems:()=>q,getCanvasSystem:()=>I,getCameraControlSystem:()=>z,getAnimationSystem:()=>v,getDragAndDropSystem:()=>k,getImageRenderingSystem:()=>b,getLayoutSystem:()=>Q,getSketchingSystem:()=>R,getExportSystem:()=>L,getCameraSystem:()=>T,getGraphQLSystem:()=>j,getAssistantSystem:()=>G},E={...A,configuratorExtensionSelectors:D},I=new i(A),z=new r({configuratorExtensionSelectors:D}),k=new g(E),v=new s(A),L=new m(E),j=new c(A),G=new o(E),Q=new S(A),R=new u(E),T=new a(E),b=new l(E),q={cameraControlSystem:z,layoutSystem:Q,sketchingSystem:R,dragAndDropSystem:k,canvasSystem:I,cameraSystem:T,exportSystem:L,imageRenderingSystem:b,animationSystem:v,graphQLSystem:j,assistantSystem:G};return D};
1
+ import{createSelector as e}from"@salsita-ai/common/utils";import{createSessionAssistant as t,isAssistantSetupHandler as n}from"#package/domain";import{AnimationSystem as s,AssistantSystem as o,CameraControlSystem as r,CameraSystem as a,CanvasSystem as i,DragAndDropSystem as g,ExportSystem as m,GraphQLSystem as c,ImageRenderingSystem as l,LayoutSystem as S,SketchingSystem as d}from"./systems/index.js";export const createConfiguratorExtensionSelectors=u=>{let{getState:y,domainContextSelectors:w,specSelectors:C,domainServicesSelectors:f,accessSelectors:p,commonServicesSelectors:h}=u,x=e.withTypes()([C.selectConfiguratorSpec,w.selectInitializationContext],(e,s)=>t({resolved:e.assistant,handler:e.handlers.find(n),inputs:s&&s.access?{role:s.role,sessionData:s.sessionData,access:s.access}:null})),A={getConfigurationId:()=>p.getConfiguratorConfigurationId(),getAuthorizedClient:()=>h.getConfiguratorAuthorizedClient(),getAssistantSetup:()=>x(y()),domainContextSelectors:w,domainServicesSelectors:f,specSelectors:C},I={getSystems:()=>Q,getCanvasSystem:()=>D,getCameraControlSystem:()=>v,getAnimationSystem:()=>b,getDragAndDropSystem:()=>z,getImageRenderingSystem:()=>G,getLayoutSystem:()=>T,getSketchingSystem:()=>j,getExportSystem:()=>k,getCameraSystem:()=>F,getGraphQLSystem:()=>L,getAssistantSystem:()=>R},E={...A,configuratorExtensionSelectors:I},D=new i(A),v=new r({configuratorExtensionSelectors:I}),z=new g(E),b=new s(A),k=new m(E),L=new c({...A,renderScreenshot:async(e,t)=>{let[n]=await I.getImageRenderingSystem().generateImagesFromComponents([e],t,{},{awaitSettledState:!0});if(!n)throw Error("The canvas rendered no image.");return n.blob}}),R=new o(E),T=new S(A),j=new d(E),F=new a(E),G=new l(E),Q={cameraControlSystem:v,layoutSystem:T,sketchingSystem:j,dragAndDropSystem:z,canvasSystem:D,cameraSystem:F,exportSystem:k,imageRenderingSystem:G,animationSystem:b,graphQLSystem:L,assistantSystem:R};return I};
@@ -8,8 +8,8 @@ import type { ConfiguratorExtensionSelectors } from '../../selectors.js';
8
8
  export type AssistantClientTool = AnyClientTool;
9
9
  /**
10
10
  * Constructor context of an `AssistantSystem`: whole selector objects, like its peers take them, so
11
- * the tools reach the store, the session mode and the `GraphQLSystem` when they are called, and the
12
- * chat reaches the server of the current session when it sends a request.
11
+ * the tools reach the store, the session mode, the view mode and the `GraphQLSystem` when they are
12
+ * called, and the chat reaches the server of the current session when it sends a request.
13
13
  */
14
14
  export interface AssistantSystemContext {
15
15
  readonly configuratorExtensionSelectors: ConfiguratorExtensionSelectors;
@@ -253,7 +253,8 @@ export declare class AssistantSystem implements InitializableSystem {
253
253
  * taken back; the non-undoable commits made on top of an undone change go with it, as with the
254
254
  * toolbar's undo.
255
255
  *
256
- * Accepted: like the toolbar's undo, it does not check the session mode; only `apply` requires `owner`.
256
+ * Accepted: like the toolbar's undo, it checks neither the session mode nor the view mode; only
257
+ * `apply` follows the view mode and refuses a finalize run.
257
258
  */
258
259
  undoToolCalls: (toolCallIds: ReadonlySet<string>) => void;
259
260
  setOpen: (open: boolean) => void;
@@ -1 +1 @@
1
- import{ChatClient as e,fetchServerSentEvents as t}from"@tanstack/ai-client";import{BehaviorSubject as i}from"rxjs";import{skip as s}from"rxjs/operators";import{isShallowEqual as a}from"@salsita-ai/common/utils";import{AssistantRequestError as r}from"#package/client";import{createBrowserDetailsClientTool as n}from"./browser-details.js";import{ChangeRecorder as o}from"./change-recorder.js";import{createApplyClientTool as l,createQueryClientTool as h}from"./graphql-tools.js";let d=Object.freeze({messages:Object.freeze([]),isLoading:!1,error:void 0,failedStatus:void 0,isContinuable:!0,isLoaded:!1,isResuming:!1,earlierThreads:Object.freeze([]),hasEarlierThread:!1,isLoadingEarlierThread:!1}),c=Object.freeze({open:!1,hasUnreadReply:!1,isInputFocused:!1}),u=Object.freeze({}),_=Object.freeze({results:Object.freeze([]),committed:!1,sideEffects:Object.freeze([]),message:"Nothing was run, because the user closed the configurator while this reply was being written. Do not call any more tools in this reply and end it now. The tools work again as soon as the user writes the next message."}),g=e=>{if(e.getError())return!0;let t=e.getMessages().at(-1)?.parts.at(-1);return t?.type!=="tool-call"&&t?.type!=="tool-result"};export class AssistantSystem{_context;_tools;_chat=new i(d);_panel=new i(c);_activation=null;_current=null;_finishing=new Set;_olderThreadId=null;_resuming=null;_refused=null;_firstAttempt=null;_chain={};_loadingThreadId=null;_recorder;_recording=null;_applyToolCallIds=new WeakMap;_undoTipToolCallId=new i(void 0);constructor(e){this._context=e;let{configuratorExtensionSelectors:t,domainContextSelectors:i,domainServicesSelectors:s,getAssistantSetup:a}=e;this._recorder=new o({maxEntities:30},{readers:{selectedEntityId:e=>i.getNavigationSystem().getActiveSelectionState(e),navigationState:e=>i.getNavigationSystem().getActiveNavigationState(e),viewState:e=>i.getNavigationSystem().getActiveViewState(e),toolState:e=>i.getNavigationSystem().getActiveToolState(e)},getExposedFields:()=>a().manifest?.fields??u,resolveLocalizable:e=>s.getResolveLocalizable()(e)});let r={getGraphQLSystem:()=>t.getGraphQLSystem(),getStoreSystem:()=>i.getStoreSystem(),getActiveMode:()=>i.getActiveMode(),clearChanges:()=>this._recorder.clear(this._committedState()),rememberCommit:(e,t)=>{this._applyToolCallIds.set(t,e),this._refreshUndoTip()}};this._tools=[n(),h(r),l(r)],i.getUndoSystem().tip$.subscribe(this._refreshUndoTip)}chat$=this._chat;panel$=this._panel;undoTipToolCallId$=this._undoTipToolCallId;getSessionManifest=()=>this._context.getAssistantSetup().manifest;initialize=()=>{let{committed:e}=this._context.domainContextSelectors.getStoreSystem().stateSlices;this._recording??=e.pipe(s(1)).subscribe(this._recorder.record),this._recorder.reset(e.value.state),this._endChat(),this._patchPanel(c),this._activation&&this._startClient()};activate=()=>{this._endChat();let e={};return this._activation=e,this._startClient(),()=>{this._activation===e&&(this._activation=null,this._endChat())}};send=async e=>{if(!this._chat.value.isContinuable&&!await this.resume())return;let t=this._current;if(!t)return;let i={changes:this._recorder.take(this._committedState())};this._firstAttempt=t;try{await this._sendOn(t,e,i);let s=this._findRefusedMessageIndex(t);if(-1===s)return;this._refused={chat:t,index:s}}finally{this._firstAttempt===t&&(this._firstAttempt=null)}if(!await this.resume())return;let s=this._current;s&&await this._sendOn(s,e,i)};resume=async()=>{let e=this._current;if(!e)return!1;if(this._chat.value.isContinuable)return!0;if(this._resuming)return this._resuming;let t=this._resume(e).finally(()=>{this._resuming===t&&(this._resuming=null)});return this._resuming=t,t};loadEarlierThread=async()=>{let e=this._current,t=this._olderThreadId;if(!e||null===t||this._loadingThreadId===t)return;let i=this._chain;this._loadingThreadId=t,this._chat.next({...this._chat.value,isLoadingEarlierThread:!0});try{let s=await e.authorizedClient.getAssistantEarlierThread(e.configurationId,t,50);if(this._chain!==i||this._olderThreadId!==t)return;this._olderThreadId=s.previousThreadId,this._chat.next({...this._chat.value,earlierThreads:[{threadId:t,messages:s.messages},...this._chat.value.earlierThreads],hasEarlierThread:null!==s.previousThreadId})}catch(e){this._context.domainServicesSelectors.getLogger().warn("Could not load the earlier assistant conversation",{error:e})}finally{this._chain===i&&this._loadingThreadId===t&&(this._loadingThreadId=null,this._chat.next({...this._chat.value,isLoadingEarlierThread:!1}))}};stop=async()=>{let e=this._current;if(!e)return;let t=e.client.getCurrentRunId();if(e.client.stop(),null!=t)try{let i=e.getConnection();await fetch(`${i.url}/runs/${encodeURIComponent(t)}/cancel`,{method:"POST",headers:await i.headers()})}catch(e){this._context.domainServicesSelectors.getLogger().warn("Could not cancel the assistant run on the server",{error:e})}};reloadThread=()=>{if(!this._activation)return;let e=this._retireChat();e?.client.stop(),e?.dispose(),this._recorder.reset(this._committedState()),this._startClient()};undoToolCalls=e=>{let t=this._context.domainContextSelectors.getUndoSystem(),i=()=>{let t=this._findTipToolCallId();return void 0!==t&&e.has(t)};for(;i();)t.undo()};setOpen=e=>{this._patchPanel(e?{open:e,hasUnreadReply:!1}:{open:e,isInputFocused:!1})};setInputFocused=e=>{this._patchPanel({isInputFocused:e})};_findRefusedMessageIndex=e=>{var t;let i,{failedStatus:s,isContinuable:a}=this._chat.value;return this._firstAttempt===e&&e.generation.active&&409===s&&!a?(i=(t=e.client.getMessages()).map(e=>e.role).lastIndexOf("user"),t.slice(i+1).every(e=>0===e.parts.length)?i:-1):-1};_sendOn=async(e,t,i)=>{let{client:s}=e;s.getIsLoading()||null===s.getResumeState()||s.stop();try{await s.sendMessage({content:t,metadata:i})}catch(i){let t=i instanceof Error?i:Error(String(i));e.generation.active&&this._chat.next({...this._chat.value,error:t}),this._context.domainServicesSelectors.getLogger().error("The assistant message could not be sent",{},t)}};_resume=async e=>{this._chat.next({...this._chat.value,isResuming:!0,error:void 0,failedStatus:void 0});try{let{previousThreadId:t}=await e.authorizedClient.compactAssistantThread(e.configurationId);if(!e.generation.active)return!1;let{messages:i,earlierThreads:s,hasEarlierThread:a}=this._chat.value,r=this._refused?.chat===e?i.slice(0,this._refused.index):i;return e.generation.active=!1,this._current=null,e.client.stop(),e.dispose(),this._chat.next({...d,earlierThreads:[...s,{threadId:t,messages:r}],hasEarlierThread:a,isLoadingEarlierThread:null!==this._loadingThreadId}),this._startClient(),!0}catch(i){let t=i instanceof Error?i:Error(String(i));if(t instanceof r&&409===t.status)return e.generation.active&&this.reloadThread(),!1;return e.generation.active&&this._chat.next({...this._chat.value,isResuming:!1,error:t,failedStatus:t instanceof r?t.status:void 0}),this._context.domainServicesSelectors.getLogger().error("The assistant thread could not be resumed",{},t),!1}};_findTipToolCallId=()=>{let e=this._context.domainContextSelectors.getUndoSystem(),t=e.tip$.value?.committedState;return void 0!==t&&e.canUndo()?this._applyToolCallIds.get(t):void 0};_refreshUndoTip=()=>{let e=this._findTipToolCallId();e!==this._undoTipToolCallId.value&&this._undoTipToolCallId.next(e)};_committedState=()=>this._context.domainContextSelectors.getStoreSystem().stateSlices.committed.value.state;_patchPanel=e=>{let t={...this._panel.value,...e};a(t,this._panel.value)||this._panel.next(t)};_takeOverThread=e=>{for(let t of this._finishing)t.configurationId===e&&(t.client.stop(),t.dispose())};_startClient=()=>{let i={active:!0},s=this._context.getConfigurationId();this._takeOverThread(s);let r=this._context.getAuthorizedClient(),n=()=>{if(i.active){let{manifest:e,error:t}=this._context.getAssistantSetup();if(t)throw t;if(!e)throw Error("The assistant is disabled for this session.")}return r.getAssistantChatConnection(s)},o=e=>{if(!i.active)return;let t={...this._chat.value,...e};a(t,this._chat.value)||this._chat.next(t)},l=async(e,t)=>{let s=await fetch(e,t).finally(()=>o({isLoaded:!0})),a=s.headers.get("x-assistant-thread-continuable");return null!=a&&s.ok&&i.active&&0===this._chat.value.earlierThreads.length&&(this._olderThreadId=s.headers.get("x-assistant-previous-thread")),o({failedStatus:s.ok?void 0:s.status,...null!=a&&{isContinuable:"false"!==a,hasEarlierThread:null!==this._olderThreadId}}),s},h=async()=>({headers:await n().headers(),fetchClient:l}),d=t(()=>n().url,h),c=t(()=>`${n().url}/runs`,h),u=this._tools.map(e=>({...e,execute:(t,s)=>{if(!i.active)return _;let{manifest:a,error:r}=this._context.getAssistantSetup();return r||!a?{error:r?.message??"The assistant is disabled for this session."}:e.execute?.(t,s)}})),f=new e({threadId:`assistant:${s}`,connection:{...d,joinRun:c.joinRun},persistence:!0,history:{pageSize:50},tools:u,onMessagesChange:e=>o({messages:e}),onLoadingChange:e=>{let t=i.active&&this._chat.value.isLoading;o({isLoading:e}),!e&&g(f)&&(i.active?t&&!this._panel.value.open&&this._patchPanel({hasUnreadReply:!0}):p())},onErrorChange:e=>{i.active&&e!==this._chat.value.error&&(!e||-1===this._findRefusedMessageIndex(v))&&(o({error:e}),e&&this._context.domainServicesSelectors.getLogger().error("The assistant request failed",{status:this._chat.value.failedStatus},e))}}),m=!1,p=()=>{m||(m=!0,this._finishing.delete(v),f.dispose())},v={client:f,configurationId:s,generation:i,authorizedClient:r,getConnection:n,dispose:p};this._current=v,f.attach()};_retireChat=()=>{let e=this._current;return this._current=null,e&&(e.generation.active=!1),this._chain={},this._olderThreadId=null,this._resuming=null,this._refused=null,this._loadingThreadId=null,this._chat.value!==d&&this._chat.next(d),e};_endChat=()=>{let e=this._retireChat();if(e){if(!e.client.getIsLoading()&&g(e.client))return void e.dispose();this._finishing.add(e)}}}
1
+ import{ChatClient as e,fetchServerSentEvents as t}from"@tanstack/ai-client";import{BehaviorSubject as i}from"rxjs";import{skip as s}from"rxjs/operators";import{isShallowEqual as a}from"@salsita-ai/common/utils";import{AssistantRequestError as r}from"#package/client";import{createBrowserDetailsClientTool as n}from"./browser-details.js";import{ChangeRecorder as o}from"./change-recorder.js";import{createApplyClientTool as l,createQueryClientTool as h,toToolResult as d}from"./graphql-tools.js";let c=Object.freeze({messages:Object.freeze([]),isLoading:!1,error:void 0,failedStatus:void 0,isContinuable:!0,isLoaded:!1,isResuming:!1,earlierThreads:Object.freeze([]),hasEarlierThread:!1,isLoadingEarlierThread:!1}),u=Object.freeze({open:!1,hasUnreadReply:!1,isInputFocused:!1}),_=Object.freeze({}),g=d({results:[],committed:!1,sideEffects:[],screenshots:new Map,message:"Nothing was run, because the user closed the configurator while this reply was being written. Do not call any more tools in this reply and end it now. The tools work again as soon as the user writes the next message."}),m=e=>{if(e.getError())return!0;let t=e.getMessages().at(-1)?.parts.at(-1);return t?.type!=="tool-call"&&t?.type!=="tool-result"};export class AssistantSystem{_context;_tools;_chat=new i(c);_panel=new i(u);_activation=null;_current=null;_finishing=new Set;_olderThreadId=null;_resuming=null;_refused=null;_firstAttempt=null;_chain={};_loadingThreadId=null;_recorder;_recording=null;_applyToolCallIds=new WeakMap;_undoTipToolCallId=new i(void 0);constructor(e){this._context=e;let{configuratorExtensionSelectors:t,domainContextSelectors:i,domainServicesSelectors:s,getAssistantSetup:a}=e;this._recorder=new o({maxEntities:30},{readers:{selectedEntityId:e=>i.getNavigationSystem().getActiveSelectionState(e),navigationState:e=>i.getNavigationSystem().getActiveNavigationState(e),viewState:e=>i.getNavigationSystem().getActiveViewState(e),toolState:e=>i.getNavigationSystem().getActiveToolState(e)},getExposedFields:()=>a().manifest?.fields??_,resolveLocalizable:e=>s.getResolveLocalizable()(e)});let r={getGraphQLSystem:()=>t.getGraphQLSystem(),getStoreSystem:()=>i.getStoreSystem(),getActiveMode:()=>i.getActiveMode(),getIsViewMode:()=>i.getIsViewMode(),clearChanges:()=>this._recorder.clear(this._committedState()),rememberCommit:(e,t)=>{this._applyToolCallIds.set(t,e),this._refreshUndoTip()}};this._tools=[n(),h(r),l(r)],i.getUndoSystem().tip$.subscribe(this._refreshUndoTip)}chat$=this._chat;panel$=this._panel;undoTipToolCallId$=this._undoTipToolCallId;getSessionManifest=()=>this._context.getAssistantSetup().manifest;initialize=()=>{let{committed:e}=this._context.domainContextSelectors.getStoreSystem().stateSlices;this._recording??=e.pipe(s(1)).subscribe(this._recorder.record),this._recorder.reset(e.value.state),this._endChat(),this._patchPanel(u),this._activation&&this._startClient()};activate=()=>{this._endChat();let e={};return this._activation=e,this._startClient(),()=>{this._activation===e&&(this._activation=null,this._endChat())}};send=async e=>{if(!this._chat.value.isContinuable&&!await this.resume())return;let t=this._current;if(!t)return;let i={changes:this._recorder.take(this._committedState())};this._firstAttempt=t;try{await this._sendOn(t,e,i);let s=this._findRefusedMessageIndex(t);if(-1===s)return;this._refused={chat:t,index:s}}finally{this._firstAttempt===t&&(this._firstAttempt=null)}if(!await this.resume())return;let s=this._current;s&&await this._sendOn(s,e,i)};resume=async()=>{let e=this._current;if(!e)return!1;if(this._chat.value.isContinuable)return!0;if(this._resuming)return this._resuming;let t=this._resume(e).finally(()=>{this._resuming===t&&(this._resuming=null)});return this._resuming=t,t};loadEarlierThread=async()=>{let e=this._current,t=this._olderThreadId;if(!e||null===t||this._loadingThreadId===t)return;let i=this._chain;this._loadingThreadId=t,this._chat.next({...this._chat.value,isLoadingEarlierThread:!0});try{let s=await e.authorizedClient.getAssistantEarlierThread(e.configurationId,t,50);if(this._chain!==i||this._olderThreadId!==t)return;this._olderThreadId=s.previousThreadId,this._chat.next({...this._chat.value,earlierThreads:[{threadId:t,messages:s.messages},...this._chat.value.earlierThreads],hasEarlierThread:null!==s.previousThreadId})}catch(e){this._context.domainServicesSelectors.getLogger().warn("Could not load the earlier assistant conversation",{error:e})}finally{this._chain===i&&this._loadingThreadId===t&&(this._loadingThreadId=null,this._chat.next({...this._chat.value,isLoadingEarlierThread:!1}))}};stop=async()=>{let e=this._current;if(!e)return;let t=e.client.getCurrentRunId();if(e.client.stop(),null!=t)try{let i=e.getConnection();await fetch(`${i.url}/runs/${encodeURIComponent(t)}/cancel`,{method:"POST",headers:await i.headers()})}catch(e){this._context.domainServicesSelectors.getLogger().warn("Could not cancel the assistant run on the server",{error:e})}};reloadThread=()=>{if(!this._activation)return;let e=this._retireChat();e?.client.stop(),e?.dispose(),this._recorder.reset(this._committedState()),this._startClient()};undoToolCalls=e=>{let t=this._context.domainContextSelectors.getUndoSystem(),i=()=>{let t=this._findTipToolCallId();return void 0!==t&&e.has(t)};for(;i();)t.undo()};setOpen=e=>{this._patchPanel(e?{open:e,hasUnreadReply:!1}:{open:e,isInputFocused:!1})};setInputFocused=e=>{this._patchPanel({isInputFocused:e})};_findRefusedMessageIndex=e=>{var t;let i,{failedStatus:s,isContinuable:a}=this._chat.value;return this._firstAttempt===e&&e.generation.active&&409===s&&!a?(i=(t=e.client.getMessages()).map(e=>e.role).lastIndexOf("user"),t.slice(i+1).every(e=>0===e.parts.length)?i:-1):-1};_sendOn=async(e,t,i)=>{let{client:s}=e;s.getIsLoading()||null===s.getResumeState()||s.stop();try{await s.sendMessage({content:t,metadata:i})}catch(i){let t=i instanceof Error?i:Error(String(i));e.generation.active&&this._chat.next({...this._chat.value,error:t}),this._context.domainServicesSelectors.getLogger().error("The assistant message could not be sent",{},t)}};_resume=async e=>{this._chat.next({...this._chat.value,isResuming:!0,error:void 0,failedStatus:void 0});try{let{previousThreadId:t}=await e.authorizedClient.compactAssistantThread(e.configurationId);if(!e.generation.active)return!1;let{messages:i,earlierThreads:s,hasEarlierThread:a}=this._chat.value,r=this._refused?.chat===e?i.slice(0,this._refused.index):i;return e.generation.active=!1,this._current=null,e.client.stop(),e.dispose(),this._chat.next({...c,earlierThreads:[...s,{threadId:t,messages:r}],hasEarlierThread:a,isLoadingEarlierThread:null!==this._loadingThreadId}),this._startClient(),!0}catch(i){let t=i instanceof Error?i:Error(String(i));if(t instanceof r&&409===t.status)return e.generation.active&&this.reloadThread(),!1;return e.generation.active&&this._chat.next({...this._chat.value,isResuming:!1,error:t,failedStatus:t instanceof r?t.status:void 0}),this._context.domainServicesSelectors.getLogger().error("The assistant thread could not be resumed",{},t),!1}};_findTipToolCallId=()=>{let e=this._context.domainContextSelectors.getUndoSystem(),t=e.tip$.value?.committedState;return void 0!==t&&e.canUndo()?this._applyToolCallIds.get(t):void 0};_refreshUndoTip=()=>{let e=this._findTipToolCallId();e!==this._undoTipToolCallId.value&&this._undoTipToolCallId.next(e)};_committedState=()=>this._context.domainContextSelectors.getStoreSystem().stateSlices.committed.value.state;_patchPanel=e=>{let t={...this._panel.value,...e};a(t,this._panel.value)||this._panel.next(t)};_takeOverThread=e=>{for(let t of this._finishing)t.configurationId===e&&(t.client.stop(),t.dispose())};_startClient=()=>{let i={active:!0},s=this._context.getConfigurationId();this._takeOverThread(s);let r=this._context.getAuthorizedClient(),n=()=>{if(i.active){let{manifest:e,error:t}=this._context.getAssistantSetup();if(t)throw t;if(!e)throw Error("The assistant is disabled for this session.")}return r.getAssistantChatConnection(s)},o=e=>{if(!i.active)return;let t={...this._chat.value,...e};a(t,this._chat.value)||this._chat.next(t)},l=async(e,t)=>{let s=await fetch(e,t).finally(()=>o({isLoaded:!0})),a=s.headers.get("x-assistant-thread-continuable");return null!=a&&s.ok&&i.active&&0===this._chat.value.earlierThreads.length&&(this._olderThreadId=s.headers.get("x-assistant-previous-thread")),o({failedStatus:s.ok?void 0:s.status,...null!=a&&{isContinuable:"false"!==a,hasEarlierThread:null!==this._olderThreadId}}),s},h=async()=>({headers:await n().headers(),fetchClient:l}),d=t(()=>n().url,h),c=t(()=>`${n().url}/runs`,h),u=this._tools.map(e=>({...e,execute:(t,s)=>{if(!i.active)return g;let{manifest:a,error:r}=this._context.getAssistantSetup();return r||!a?{error:r?.message??"The assistant is disabled for this session."}:e.execute?.(t,s)}})),_=new e({threadId:`assistant:${s}`,connection:{...d,joinRun:c.joinRun},persistence:!0,history:{pageSize:50},tools:u,onMessagesChange:e=>o({messages:e}),onLoadingChange:e=>{let t=i.active&&this._chat.value.isLoading;o({isLoading:e}),!e&&m(_)&&(i.active?t&&!this._panel.value.open&&this._patchPanel({hasUnreadReply:!0}):p())},onErrorChange:e=>{i.active&&e!==this._chat.value.error&&(!e||-1===this._findRefusedMessageIndex(v))&&(o({error:e}),e&&this._context.domainServicesSelectors.getLogger().error("The assistant request failed",{status:this._chat.value.failedStatus},e))}}),f=!1,p=()=>{f||(f=!0,this._finishing.delete(v),_.dispose())},v={client:_,configurationId:s,generation:i,authorizedClient:r,getConnection:n,dispose:p};this._current=v,_.attach()};_retireChat=()=>{let e=this._current;return this._current=null,e&&(e.generation.active=!1),this._chain={},this._olderThreadId=null,this._resuming=null,this._refused=null,this._loadingThreadId=null,this._chat.value!==c&&this._chat.next(c),e};_endChat=()=>{let e=this._retireChat();if(e){if(!e.client.getIsLoading()&&m(e.client))return void e.dispose();this._finishing.add(e)}}}
@@ -1,12 +1,13 @@
1
+ import type { ContentPart } from '@tanstack/ai';
1
2
  import type { DomainEntity, DomainMode, DomainState } from '#package/domain';
2
- import type { GraphQLSystem } from '../graphql-system/graphql-system.js';
3
+ import type { GraphQLExecution, GraphQLSystem } from '../graphql-system/graphql-system.js';
3
4
  /**
4
5
  * What the assistant's client tools need from the running configurator, as accessors they call when
5
- * the model calls them: a tool call always runs against the systems and the session mode current at
6
- * that moment, never against ones captured when its reply began streaming.
6
+ * the model calls them: a tool call always runs against the systems, the session mode and the view
7
+ * mode current at that moment, never against ones captured when its reply began streaming.
7
8
  */
8
9
  export interface AssistantToolDependencies {
9
- readonly getGraphQLSystem: () => Pick<GraphQLSystem, 'prepare' | 'execute' | 'readSideEffects'>;
10
+ readonly getGraphQLSystem: () => Pick<GraphQLSystem, 'prepare' | 'execute' | 'readSideEffects' | 'readScreenshots'>;
10
11
  readonly getStoreSystem: () => {
11
12
  readonly isInitialized: boolean;
12
13
  readonly stateSlices: {
@@ -18,6 +19,11 @@ export interface AssistantToolDependencies {
18
19
  };
19
20
  };
20
21
  readonly getActiveMode: () => DomainMode;
22
+ /**
23
+ * Whether the configuration is read-only for the user now, by the rule the UI follows: the
24
+ * domain-context selector `getIsViewMode`, which `useAccessService().accessInfo.viewMode` returns.
25
+ */
26
+ readonly getIsViewMode: () => boolean;
21
27
  /** Forgets the changes recorded for the next change record, so it never lists what the agent itself changed. */
22
28
  readonly clearChanges: () => void;
23
29
  /**
@@ -26,6 +32,15 @@ export interface AssistantToolDependencies {
26
32
  */
27
33
  readonly rememberCommit: (toolCallId: string, state: DomainState<DomainEntity<string>>) => void;
28
34
  }
35
+ /**
36
+ * A tool result as the chat client accepts it: content parts, the execution's JSON as a text part
37
+ * followed, per screenshot, by its label as a text part and its picture as an image part, so the
38
+ * model reads each picture under the label its `image` field returned. The client deep-clones a
39
+ * result and rejects anything that is not plain JSON, so the `GraphQLError` instances of a result
40
+ * are formatted through their `toJSON` and `undefined` members are dropped. The prepared state stays
41
+ * in the browser.
42
+ */
43
+ export declare const toToolResult: ({ preparedState, screenshots, ...execution }: GraphQLExecution) => ContentPart[];
29
44
  /**
30
45
  * Browser implementation of the assistant's `query` tool: prepares the operations from the
31
46
  * committed state and drops their emissions, so mutations in the list show a hypothetical state and
@@ -99,9 +114,20 @@ export declare const createQueryClientTool: (dependencies: AssistantToolDependen
99
114
  * including why nothing was committed when a commit was held or lost to a conflict. A commit clears
100
115
  * the recorded changes; a held one does not, so it shows in the next change record once the user
101
116
  * approves it. The state it committed or held is remembered under the id of the call, so the chip
102
- * row of the call can undo it. Only an owner
103
- * session may change the configuration; the check lives here and not in the `GraphQLSystem`, whose
104
- * other caller, the editor panel, has its own rules.
117
+ * row of the call can undo it.
118
+ *
119
+ * The assistant changes the configuration exactly when the UI lets the user change it: while the
120
+ * view mode is off, which the host can switch both ways while the configurator runs. A finalize run
121
+ * never changes it. The checks live here and not in the `GraphQLSystem`, whose other caller, the
122
+ * editor panel, has its own rules.
123
+ *
124
+ * Accepted: the view mode is read live, while saving follows the mode captured at initialization
125
+ * (the named exception in `docs/architecture/application-runtime.md`). When the configuration turns
126
+ * editable, because the host cleared `readonly` or the access changed, for example from a
127
+ * read-revision to an owner token, a change applied before the configuration is initialized again
128
+ * is committed and reported to the model as committed, but it is not saved, and that initialization
129
+ * replaces it. The configurator page loads the configuration again on either switch, so the window
130
+ * lasts one load.
105
131
  */
106
132
  export declare const createApplyClientTool: (dependencies: AssistantToolDependencies) => import("@tanstack/ai").ClientTool<{
107
133
  type: string;
@@ -1 +1 @@
1
- import{AssistantGraphQLToolInput as e,applyTool as t,queryTool as o}from"@salsita-ai/contracts/assistant";let a=e=>({results:[],committed:!1,message:e,sideEffects:[]}),i=({preparedState:e,...t})=>JSON.parse(JSON.stringify(t)),s=t=>{let o=e.safeParse(t);if(!o.success){let e=o.error.issues.map(e=>`${e.path.join(".")}: ${e.message}`).join("; ");return{ok:!1,refusal:a(`Nothing was run, because the tool input is not a list of operations (${e}). Send { "operations": [{ "query": "<one GraphQL operation>" }] } with at least one item.`)}}return{ok:!0,operations:o.data.operations.map(({query:e,variables:t,operationName:o})=>({document:e,variables:t??void 0,operationName:o??void 0}))}};export const createQueryClientTool=e=>o.client(async t=>{let o=s(t);if(!o.ok)return o.refusal;let r=e.getStoreSystem();if(!r.isInitialized)return a("Nothing was run, because the configuration is not loaded yet, so there is no state to query. Call the tool again once the configurator has finished loading.");let n=e.getGraphQLSystem(),l=await n.prepare(r.stateSlices.committed.value.state,o.operations);return i({results:l.map(({result:e})=>e),committed:!1,sideEffects:n.readSideEffects(l)})});export const createApplyClientTool=e=>t.client(async(t,o)=>{if("owner"!==e.getActiveMode())return a("Nothing was run, because changes cannot be applied in this session: the user may view this configuration but not change it. The query tool still works here, including mutations, to show what a change would do without keeping it.");let r=s(t);if(!r.ok)return r.refusal;let n=await e.getGraphQLSystem().execute(r.operations),l=o?.toolCallId;return void 0!==l&&void 0!==n.preparedState&&e.rememberCommit(l,n.preparedState),n.committed&&e.clearChanges(),i(n)});
1
+ import{AssistantGraphQLToolInput as e,applyTool as t,queryTool as o}from"@salsita-ai/contracts/assistant";let a=e=>({results:[],committed:!1,message:e,sideEffects:[],screenshots:new Map});export const toToolResult=({preparedState:e,screenshots:t,...o})=>[{type:"text",content:JSON.stringify(o)},...[...t].flatMap(([e,{data:t,mimeType:o}])=>[{type:"text",content:e},{type:"image",source:{type:"data",value:t,mimeType:o}}])];let i=t=>{let o=e.safeParse(t);if(!o.success){let e=o.error.issues.map(e=>`${e.path.join(".")}: ${e.message}`).join("; ");return{ok:!1,refusal:a(`Nothing was run, because the tool input is not a list of operations (${e}). Send { "operations": [{ "query": "<one GraphQL operation>" }] } with at least one item.`)}}return{ok:!0,operations:o.data.operations.map(({query:e,variables:t,operationName:o})=>({document:e,variables:t??void 0,operationName:o??void 0}))}};export const createQueryClientTool=e=>o.client(async t=>{let o=i(t);if(!o.ok)return toToolResult(o.refusal);let s=e.getStoreSystem();if(!s.isInitialized)return toToolResult(a("Nothing was run, because the configuration is not loaded yet, so there is no state to query. Call the tool again once the configurator has finished loading."));let n=e.getGraphQLSystem(),r=await n.prepare(s.stateSlices.committed.value.state,o.operations);return toToolResult({results:r.map(({result:e})=>e),committed:!1,sideEffects:n.readSideEffects(r),screenshots:n.readScreenshots(r)})});export const createApplyClientTool=e=>t.client(async(t,o)=>{if("finalize"===e.getActiveMode())return toToolResult(a("Nothing was run, because changes cannot be applied in this session: the user may view this configuration but not change it. The query tool still works here, including mutations, to show what a change would do without keeping it."));if(e.getIsViewMode())return toToolResult(a("Nothing was run, because the configuration is read-only right now: the user may view it but not change it. The query tool still works here, including mutations, to show what a change would do without keeping it. Call apply again only once the configuration is editable."));let s=i(t);if(!s.ok)return toToolResult(s.refusal);let n=await e.getGraphQLSystem().execute(s.operations),r=o?.toolCallId;return void 0!==r&&void 0!==n.preparedState&&e.rememberCommit(r,n.preparedState),n.committed&&e.clearChanges(),toToolResult(n)});
@@ -94,6 +94,14 @@ export declare class CanvasSystem<ENTITIES extends DomainEntity<string>> {
94
94
  readonly getCanvasEnvironment: (state: DomainState<ENTITIES>) => import("#package/domain").ComponentSnapshot<import("#package/domain").SystemComponentType<"canvasCustomEnvironment", import("#package/domain").CanvasCustomEnvironmentComponentState, never> | import("#package/domain").SystemComponentType<"canvasPresetEnvironment", import("#package/domain").CanvasPresetEnvironmentComponentState, never>> | undefined;
95
95
  readonly getCanvasConfig: (state: DomainState<ENTITIES>) => import("#package/domain").CanvasConfigComponentState | undefined;
96
96
  readonly register: (scene: Scene, gl: WebGLRenderer, r3fHandle: R3FHandle, loadingProgress$: Observable<LoadingProgress>) => () => void;
97
+ /**
98
+ * Resolves with the handle of the mounted canvas, waiting for a canvas to register when none is
99
+ * mounted yet. Work that needs the canvas and can be started by the user before the first mount
100
+ * (an image capture started from the summary) awaits this instead of failing on an empty handle.
101
+ *
102
+ * @internal
103
+ */
104
+ readonly waitForCanvas: (timeoutMs?: number) => Promise<R3FHandle>;
97
105
  readonly reportFlush: (token: FlushToken) => void;
98
106
  readonly registerForceFlush: (trigger: (token: FlushToken) => void) => () => void;
99
107
  private _forceFlush;
@@ -1 +1 @@
1
- import{BehaviorSubject as e,Subject as t,debounceTime as i,delay as n,filter as s,firstValueFrom as r,map as o,merge as a,of as h,switchMap as l,tap as c}from"rxjs";import{applicationConfigComponent as d,canvasConfigComponent as u,canvasCustomEnvironmentComponent as g,canvasPresetEnvironmentComponent as _}from"#package/domain";export const resolveInteractiveViewport=(e,t)=>!Number.isFinite(t.width)||!Number.isFinite(t.height)||t.width<=0||t.height<=0||e?.width===t.width&&e.height===t.height?e:t;export class CanvasInitializationCancellationError extends Error{constructor(){super("Canvas generation ended while waiting for a flush!"),this.name="CanvasInitializationCancellationError"}}export class CanvasSystem{_context;_dimensionIndicatorShown;_meshChanged$=new e(!0);_firstLoadFinished=new e(!1);dimensionIndicatorShown$;meshChanged$=this._meshChanged$;firstLoadFinished$=this._firstLoadFinished;onCanvasClick$=new t;onCanvasPointerMove$=new t;_ready$=new e(null);ready$=this._ready$;_r3fHandle$=new e(null);r3fHandle$=this._r3fHandle$;_interactiveViewport$=new e(null);interactiveViewport$=this._interactiveViewport$;_flushed$=new t;_flushSequence=0;_lastReportedFlushSequence=0;_triggerForceFlush=null;_registration=null;_progress$=new e({type:"finished"});_generation=null;constructor(t){this._context=t,this._dimensionIndicatorShown=new e(!1),this.dimensionIndicatorShown$=this._dimensionIndicatorShown}getCanvasEnvironment=e=>{let t=this._context.domainContextSelectors.getComponentReader().readManyComponents({componentTypes:[g,_]},e);return t.length>1&&this._context.domainServicesSelectors.getLogger().warn("Multiple canvas environments found, using the first one!",{environments:t}),t.at(0)};getCanvasConfig=e=>{let t=this._context.domainContextSelectors.getComponentReader().readManyComponents({componentTypes:[u]},e);return t.length>1&&this._context.domainServicesSelectors.getLogger().warn("Multiple canvas configs found, using the first one!",{configs:t}),t.at(0)?.state};register=(e,t,i,n)=>{let s={scene:e,gl:t,r3fHandle:i};this._registration=s,this._ready$.next({scene:e,gl:t}),this._r3fHandle$.next(i),this._interactiveViewport$.next(null);let r=n.subscribe(e=>{this._progress$.next(e)}),o=e=>{if(this._registration!==s)return;let t=resolveInteractiveViewport(this._interactiveViewport$.value,e);t!==this._interactiveViewport$.value&&(this._interactiveViewport$.next(t),i.get().invalidate())},a=t.domElement,h=a.getBoundingClientRect();o({width:h.width,height:h.height});let l=new ResizeObserver(([e])=>{e&&o({width:e.contentRect.width,height:e.contentRect.height})});return l.observe(a),()=>{r.unsubscribe(),l.disconnect(),this._registration===s&&(this._registration=null,this._ready$.next(null),this._r3fHandle$.next(null),this._interactiveViewport$.next(null),this._progress$.next({type:"finished"}),this._firstLoadFinished.next(!1))}};reportFlush=e=>{this._lastReportedFlushSequence=Math.max(this._lastReportedFlushSequence,e.sequence),this._flushed$.next(e)};registerForceFlush=e=>(this._triggerForceFlush=e,()=>{this._triggerForceFlush===e&&(this._triggerForceFlush=null)});_forceFlush(){if(!this._triggerForceFlush)throw this._context.domainServicesSelectors.getLogger().debug("Force flush skipped: canvas not ready"),new CanvasInitializationCancellationError;let e={sequence:++this._flushSequence},t=r(a(this._flushed$.pipe(s(t=>t.sequence>=e.sequence),o(()=>void 0)),h(void 0).pipe(n(1e4),c(()=>{this._context.domainServicesSelectors.getLogger().error("Force flush timeout",{requestedSequence:e.sequence,lastReportedSequence:this._lastReportedFlushSequence,timeoutMs:1e4,detectorRegistered:null!==this._triggerForceFlush})}))));return this._triggerForceFlush(e),t}toggleDimensionIndicator=()=>{this._dimensionIndicatorShown.next(!this._dimensionIndicatorShown.value)};setDimensionIndicatorShown=e=>{this._dimensionIndicatorShown.value!==e&&this._dimensionIndicatorShown.next(e)};reportMeshChanged=()=>{this._meshChanged$.next(!0)};reportFirstLoadFinished=()=>{this._firstLoadFinished.next(!0)};_findEntity3d(e,t){let i=[];if(e.entityIds?.length===0)return i;if(t.traverse(t=>{let n=t.userData;"entityRoot"===n.type&&(void 0===e.entityIds||e.entityIds.includes(n.entityId))&&i.push(t)}),e.descendantEntities){let e=[...i];for(;e.length>0;){let t=e.shift();t&&t.children.forEach(t=>{"entityRoot"===t.userData.type&&(i.push(t),e.push(t))})}}let n=e.entityRoots?[...i]:[];if(e.entityObjects){let t=i=>{i.children.forEach(i=>{let s=i.userData;"entityObjectGroup"===s.type?t(i):"entityObject"!==s.type||(void 0===e.objectInstanceNames||e.objectInstanceNames.includes(s.objectInstanceName))&&(e.recursiveObjects?i.traverse(e=>{n.push(e)}):n.push(i))})};i.forEach(e=>t(e))}return n}findEntity3d=e=>this.ready$.value?.scene?this._findEntity3d(e,this.ready$.value.scene):[];findEntity3d$=e=>this.ready$.pipe(s(e=>null!=e),l(({scene:t})=>this.meshChanged$.pipe(i(0),o(()=>this._findEntity3d(e,t)))));initialize=()=>{let e=this._context.domainContextSelectors.getComponentReader().readFirstRootComponent({componentTypes:[d]},this._context.domainContextSelectors.getStoreSystem().stateSlices.committed.value.state);null!==this._generation&&(this._generation.active=!1);let t=e?.state.initialIndicatorShown??!1;this._generation={active:!0},this._dimensionIndicatorShown.next(t),this._meshChanged$.next(!0)};waitForFlush=async()=>{let e=this._generation,t=()=>{if(!e?.active)throw new CanvasInitializationCancellationError};for(t(),await this._forceFlush(),t(),await this._forceFlush(),t();"finished"!==this._progress$.value.type;)await r(this._progress$.pipe(s(e=>"finished"===e.type))),t(),await this._forceFlush(),t(),await this._forceFlush(),t()}}
1
+ import{BehaviorSubject as e,Subject as t,debounceTime as i,delay as n,filter as s,firstValueFrom as r,map as o,merge as a,of as h,switchMap as l,tap as c,throwError as d,timeout as u}from"rxjs";import{isNonNullish as g}from"@salsita-ai/common/utils";import{applicationConfigComponent as _,canvasConfigComponent as p,canvasCustomEnvironmentComponent as m,canvasPresetEnvironmentComponent as w}from"#package/domain";export const resolveInteractiveViewport=(e,t)=>!Number.isFinite(t.width)||!Number.isFinite(t.height)||t.width<=0||t.height<=0||e?.width===t.width&&e.height===t.height?e:t;export class CanvasInitializationCancellationError extends Error{constructor(){super("Canvas generation ended while waiting for a flush!"),this.name="CanvasInitializationCancellationError"}}let v=1e4;export class CanvasSystem{_context;_dimensionIndicatorShown;_meshChanged$=new e(!0);_firstLoadFinished=new e(!1);dimensionIndicatorShown$;meshChanged$=this._meshChanged$;firstLoadFinished$=this._firstLoadFinished;onCanvasClick$=new t;onCanvasPointerMove$=new t;_ready$=new e(null);ready$=this._ready$;_r3fHandle$=new e(null);r3fHandle$=this._r3fHandle$;_interactiveViewport$=new e(null);interactiveViewport$=this._interactiveViewport$;_flushed$=new t;_flushSequence=0;_lastReportedFlushSequence=0;_triggerForceFlush=null;_registration=null;_progress$=new e({type:"finished"});_generation=null;constructor(t){this._context=t,this._dimensionIndicatorShown=new e(!1),this.dimensionIndicatorShown$=this._dimensionIndicatorShown}getCanvasEnvironment=e=>{let t=this._context.domainContextSelectors.getComponentReader().readManyComponents({componentTypes:[m,w]},e);return t.length>1&&this._context.domainServicesSelectors.getLogger().warn("Multiple canvas environments found, using the first one!",{environments:t}),t.at(0)};getCanvasConfig=e=>{let t=this._context.domainContextSelectors.getComponentReader().readManyComponents({componentTypes:[p]},e);return t.length>1&&this._context.domainServicesSelectors.getLogger().warn("Multiple canvas configs found, using the first one!",{configs:t}),t.at(0)?.state};register=(e,t,i,n)=>{let s={scene:e,gl:t,r3fHandle:i};this._registration=s,this._ready$.next({scene:e,gl:t}),this._r3fHandle$.next(i),this._interactiveViewport$.next(null);let r=n.subscribe(e=>{this._progress$.next(e)}),o=e=>{if(this._registration!==s)return;let t=resolveInteractiveViewport(this._interactiveViewport$.value,e);t!==this._interactiveViewport$.value&&(this._interactiveViewport$.next(t),i.get().invalidate())},a=t.domElement,h=a.getBoundingClientRect();o({width:h.width,height:h.height});let l=new ResizeObserver(([e])=>{e&&o({width:e.contentRect.width,height:e.contentRect.height})});return l.observe(a),()=>{r.unsubscribe(),l.disconnect(),this._registration===s&&(this._registration=null,this._ready$.next(null),this._r3fHandle$.next(null),this._interactiveViewport$.next(null),this._progress$.next({type:"finished"}),this._firstLoadFinished.next(!1))}};waitForCanvas=(e=v)=>r(this._r3fHandle$.pipe(s(g),u({first:e,with:()=>d(()=>Error(`The 3D canvas did not mount within ${e} ms, so the canvas work that waited for it (an image capture or an export) cannot run. The canvas mounts when the configurator layout renders it; make sure the current layout shows the canvas, then retry once the scene is visible.`))})));reportFlush=e=>{this._lastReportedFlushSequence=Math.max(this._lastReportedFlushSequence,e.sequence),this._flushed$.next(e)};registerForceFlush=e=>(this._triggerForceFlush=e,()=>{this._triggerForceFlush===e&&(this._triggerForceFlush=null)});_forceFlush(){if(!this._triggerForceFlush)throw this._context.domainServicesSelectors.getLogger().debug("Force flush skipped: canvas not ready"),new CanvasInitializationCancellationError;let e={sequence:++this._flushSequence},t=r(a(this._flushed$.pipe(s(t=>t.sequence>=e.sequence),o(()=>void 0)),h(void 0).pipe(n(1e4),c(()=>{this._context.domainServicesSelectors.getLogger().error("Force flush timeout",{requestedSequence:e.sequence,lastReportedSequence:this._lastReportedFlushSequence,timeoutMs:1e4,detectorRegistered:null!==this._triggerForceFlush})}))));return this._triggerForceFlush(e),t}toggleDimensionIndicator=()=>{this._dimensionIndicatorShown.next(!this._dimensionIndicatorShown.value)};setDimensionIndicatorShown=e=>{this._dimensionIndicatorShown.value!==e&&this._dimensionIndicatorShown.next(e)};reportMeshChanged=()=>{this._meshChanged$.next(!0)};reportFirstLoadFinished=()=>{this._firstLoadFinished.next(!0)};_findEntity3d(e,t){let i=[];if(e.entityIds?.length===0)return i;if(t.traverse(t=>{let n=t.userData;"entityRoot"===n.type&&(void 0===e.entityIds||e.entityIds.includes(n.entityId))&&i.push(t)}),e.descendantEntities){let e=[...i];for(;e.length>0;){let t=e.shift();t&&t.children.forEach(t=>{"entityRoot"===t.userData.type&&(i.push(t),e.push(t))})}}let n=e.entityRoots?[...i]:[];if(e.entityObjects){let t=i=>{i.children.forEach(i=>{let s=i.userData;"entityObjectGroup"===s.type?t(i):"entityObject"!==s.type||(void 0===e.objectInstanceNames||e.objectInstanceNames.includes(s.objectInstanceName))&&(e.recursiveObjects?i.traverse(e=>{n.push(e)}):n.push(i))})};i.forEach(e=>t(e))}return n}findEntity3d=e=>this.ready$.value?.scene?this._findEntity3d(e,this.ready$.value.scene):[];findEntity3d$=e=>this.ready$.pipe(s(e=>null!=e),l(({scene:t})=>this.meshChanged$.pipe(i(0),o(()=>this._findEntity3d(e,t)))));initialize=()=>{let e=this._context.domainContextSelectors.getComponentReader().readFirstRootComponent({componentTypes:[_]},this._context.domainContextSelectors.getStoreSystem().stateSlices.committed.value.state);null!==this._generation&&(this._generation.active=!1);let t=e?.state.initialIndicatorShown??!1;this._generation={active:!0},this._dimensionIndicatorShown.next(t),this._meshChanged$.next(!0)};waitForFlush=async()=>{let e=this._generation,t=()=>{if(!e?.active)throw new CanvasInitializationCancellationError};for(t(),await this._forceFlush(),t(),await this._forceFlush(),t();"finished"!==this._progress$.value.type;)await r(this._progress$.pipe(s(e=>"finished"===e.type))),t(),await this._forceFlush(),t(),await this._forceFlush(),t()}}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * An export run that waited for the configuration to settle gave up: the user kept changing what
3
+ * the configurator shows (a drag in progress, for instance), and exporting over it would have thrown
4
+ * the change away.
5
+ */
6
+ export declare class ExportBusyError extends Error {
7
+ constructor();
8
+ }
@@ -0,0 +1 @@
1
+ export class ExportBusyError extends Error{constructor(){super("The export did not start, because the user kept changing the configuration while it waited, and exporting would have discarded the change. Run the export again once the user has finished."),this.name="ExportBusyError"}}
@@ -1,4 +1,5 @@
1
1
  import type { Scene } from 'three';
2
+ import { type ObservableWithLastValue } from '@salsita-ai/common/utils';
2
3
  import type { $DomainEntity, DomainContextSelectors, DomainEntity, DomainEntityId, DomainServicesSelectors, DomainState } from '#package/domain';
3
4
  import type { ConfiguratorExtensionSelectors } from '../../selectors.js';
4
5
  import type { R3FHandle } from '../canvas-system.js';
@@ -29,12 +30,26 @@ export interface ExportJob<EXPORT_STATES extends string, ENTITIES extends Domain
29
30
  selectedEntityId?: ENTITIES['id'];
30
31
  execute: (props: ExportJobArguments<ENTITIES, any, any>) => Promise<R>;
31
32
  }
33
+ /** How one export run starts. */
34
+ export interface ExportRunOptions {
35
+ /**
36
+ * Waits for the user to finish a change they are making, such as a drag, before the first job, for
37
+ * up to {@link SETTLE_TIMEOUT_MS}, and rejects with an {@link ExportBusyError} when they do not. A run
38
+ * the user did not start themselves, such as the assistant's screenshot, must not export over it. A
39
+ * hover is no such change: the run's restore drops it, as it always did.
40
+ */
41
+ readonly awaitSettledState?: boolean;
42
+ }
32
43
  /** ExportSystem with its entity types erased — how the runtime selectors expose the instance. */
33
44
  export type AnyExportSystem = ExportSystem<any, any, any, any, any, any, any>;
34
45
  export declare class ExportSystem<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string> {
35
46
  private readonly _context;
36
47
  private _generation;
37
48
  private _frameloopPause;
49
+ private _queue;
50
+ private readonly _exporting;
51
+ /** True while an export run is queued or running; the configurator UI is inert meanwhile. */
52
+ readonly exporting$: ObservableWithLastValue<boolean>;
38
53
  constructor(_context: ExportSystemContext);
39
54
  /**
40
55
  * Pauses the frameloop of the given canvas mount until the returned release has been called as
@@ -55,6 +70,13 @@ export declare class ExportSystem<ENTITIES extends DomainEntity<string>, ALLOWED
55
70
  navigationState?: NAVIGATION_STATES;
56
71
  selectedEntityId?: DomainEntityId<ENTITY_TYPE>;
57
72
  }, job: (props: ExportJobArguments<ENTITIES, $MAP[ENTITY_TYPE], $MAP[ALLOWED_ROOT_ENTITIES['type']]>) => Promise<R>) => ExportJob<EXPORT_STATES, ENTITIES, TOOL_STATES, VIEW_STATES, NAVIGATION_STATES, R>;
58
- runExportJobs: <R>(jobs: ReadonlyArray<ExportJob<EXPORT_STATES, ENTITIES, TOOL_STATES, VIEW_STATES, NAVIGATION_STATES, R>>) => Promise<R[]>;
73
+ /**
74
+ * Queues the jobs as one export run behind every run already queued and resolves with their
75
+ * results in order. While the run is queued or running, `exporting$` is true. Afterwards the store
76
+ * shows the committed state current at that moment, not the one the run started from.
77
+ */
78
+ runExportJobs: <R>(jobs: ReadonlyArray<ExportJob<EXPORT_STATES, ENTITIES, TOOL_STATES, VIEW_STATES, NAVIGATION_STATES, R>>, options?: ExportRunOptions) => Promise<R[]>;
79
+ private readonly _awaitSettledState;
80
+ private readonly _runExportJobs;
59
81
  initialize: () => void;
60
82
  }
@@ -1 +1 @@
1
- import{isNonNullish as t}from"@salsita-ai/common/utils";export class ExportSystem{_context;_generation=null;_frameloopPause=null;constructor(t){this._context=t}pauseFrameloop=t=>{if(this._frameloopPause?.handle===t)this._frameloopPause.holders+=1;else{let{frameloop:e,internal:o}=t.get();this._frameloopPause={handle:t,frameloop:e,priority:o.priority,holders:1},t.set(t=>({...t,frameloop:"never",internal:{...t.internal,priority:1/0}}))}let e=this._frameloopPause,o=!1;return()=>{o||(o=!0,e.holders-=1,e.holders>0||this._frameloopPause!==e||(this._frameloopPause=null,this._context.configuratorExtensionSelectors.getCanvasSystem().r3fHandle$.value===t&&t.set(t=>({...t,frameloop:e.frameloop,internal:{...t.internal,priority:e.priority}}))))}};createExportJob=(t,e,o)=>({sourceState:t,exportState:e.exportState,exportedEntityId:e.exportedEntityId,execute:o,toolState:e.toolState,viewState:e.viewState,navigationState:e.navigationState,selectedEntityId:e.selectedEntityId});runExportJobs=async e=>{let o=this._generation,i=()=>{if(!o?.active)throw Error("Export generation ended while jobs were running! The configurator context was reinitialized mid-export, so the remaining jobs would drive a state that is no longer theirs. Await the export before leaving the configuration, or discard the rejection.")};i();let a=this._context.configuratorExtensionSelectors.getCanvasSystem().r3fHandle$.value;if(!a)throw Error("Canvas is not ready");let n=this._context.domainContextSelectors.getStoreSystem().stateSlices.committed.value,r=this.pauseFrameloop(a);try{let o=[];for(let n of e){i();let e=this._context.domainContextSelectors.getStoreSystem().prepareStateEmission([this._context.domainContextSelectors.getNavigationSystem().getExportUpdate(n.exportState,n.exportedEntityId),null!=n.toolState?this._context.domainContextSelectors.getNavigationSystem().getToolUpdate(n.toolState):void 0,null!=n.viewState?this._context.domainContextSelectors.getNavigationSystem().getViewUpdate(n.viewState):void 0,null!=n.navigationState?this._context.domainContextSelectors.getNavigationSystem().getNavigationUpdate(n.navigationState):void 0,null!=n.selectedEntityId?this._context.domainContextSelectors.getNavigationSystem().getSelectUpdate(n.selectedEntityId):void 0,this._context.domainContextSelectors.getNavigationSystem().getHoverOutUpdate()].filter(t),n.sourceState,"staged");if(this._context.domainContextSelectors.getStoreSystem().emit(e),await this._context.configuratorExtensionSelectors.getCanvasSystem().waitForFlush(),i(),!e.validity.valid)throw this._context.domainServicesSelectors.getLogger().error(`Setting an export state to ${n.exportState} for entity ${n.exportedEntityId} resulted in an invalid state! Check if there isn't a transformer corrupting the state as a reaction to setting the export state.`,e),Error("Exported state is invalid!");let r=e.state,s=this._context.domainContextSelectors.getDomain().get$Entity(n.exportedEntityId,r),l=this._context.domainContextSelectors.getDomain().getRoot$Entity(r),c=await n.execute({$entity:s,$root:l,state:r,scene:a.get().scene});i(),o.push(c)}return o}finally{o?.active&&this._context.domainContextSelectors.getStoreSystem().emit(n),r()}};initialize=()=>{null!==this._generation&&(this._generation.active=!1),this._generation={active:!0}}}
1
+ import{BehaviorSubject as t}from"rxjs";import{isNonNullish as e}from"@salsita-ai/common/utils";import{ExportBusyError as o}from"./export-busy-error.js";export class ExportSystem{_context;_generation=null;_frameloopPause=null;_queue=null;_exporting=new t(!1);exporting$=this._exporting;constructor(t){this._context=t}pauseFrameloop=t=>{if(this._frameloopPause?.handle===t)this._frameloopPause.holders+=1;else{let{frameloop:e,internal:o}=t.get();this._frameloopPause={handle:t,frameloop:e,priority:o.priority,holders:1},t.set(t=>({...t,frameloop:"never",internal:{...t.internal,priority:1/0}}))}let e=this._frameloopPause,o=!1;return()=>{o||(o=!0,e.holders-=1,e.holders>0||this._frameloopPause!==e||(this._frameloopPause=null,this._context.configuratorExtensionSelectors.getCanvasSystem().r3fHandle$.value===t&&t.set(t=>({...t,frameloop:e.frameloop,internal:{...t.internal,priority:e.priority}}))))}};createExportJob=(t,e,o)=>({sourceState:t,exportState:e.exportState,exportedEntityId:e.exportedEntityId,execute:o,toolState:e.toolState,viewState:e.viewState,navigationState:e.navigationState,selectedEntityId:e.selectedEntityId});runExportJobs=(t,e={})=>{let o=this._generation,i=(this._queue??Promise.resolve()).then(()=>this._runExportJobs(t,e,o)),a=i.catch(()=>void 0);return this._queue=a,this._exporting.value||this._exporting.next(!0),a.then(()=>{this._queue===a&&(this._queue=null,this._exporting.next(!1))}),i};_awaitSettledState=async t=>{let e=this._context.domainContextSelectors.getStoreSystem(),i=Date.now()+2e3;for(;e.hasStagedUpdates;){if(Date.now()>=i)throw new o;await new Promise(t=>setTimeout(t,200)),t()}};_runExportJobs=async(t,{awaitSettledState:o=!1},i)=>{let a=()=>{if(!i?.active)throw Error("Export generation ended while jobs were running! The configurator context was reinitialized mid-export, so the remaining jobs would drive a state that is no longer theirs. Await the export before leaving the configuration, or discard the rejection.")};a(),o&&await this._awaitSettledState(a);let n=this._context.configuratorExtensionSelectors.getCanvasSystem(),r=n.r3fHandle$.value??await n.waitForCanvas().catch(t=>{throw a(),t});a();let s=this.pauseFrameloop(r);try{let o=[];for(let i of t){a();let t=this._context.domainContextSelectors.getStoreSystem().prepareStateEmission([this._context.domainContextSelectors.getNavigationSystem().getExportUpdate(i.exportState,i.exportedEntityId),null!=i.toolState?this._context.domainContextSelectors.getNavigationSystem().getToolUpdate(i.toolState):void 0,null!=i.viewState?this._context.domainContextSelectors.getNavigationSystem().getViewUpdate(i.viewState):void 0,null!=i.navigationState?this._context.domainContextSelectors.getNavigationSystem().getNavigationUpdate(i.navigationState):void 0,null!=i.selectedEntityId?this._context.domainContextSelectors.getNavigationSystem().getSelectUpdate(i.selectedEntityId):void 0,this._context.domainContextSelectors.getNavigationSystem().getHoverOutUpdate()].filter(e),i.sourceState,"staged");if(this._context.domainContextSelectors.getStoreSystem().emit(t),await this._context.configuratorExtensionSelectors.getCanvasSystem().waitForFlush(),a(),!t.validity.valid)throw this._context.domainServicesSelectors.getLogger().error(`Setting an export state to ${i.exportState} for entity ${i.exportedEntityId} resulted in an invalid state! Check if there isn't a transformer corrupting the state as a reaction to setting the export state.`,t),Error("Exported state is invalid!");let n=t.state,s=this._context.domainContextSelectors.getDomain().get$Entity(i.exportedEntityId,n),l=this._context.domainContextSelectors.getDomain().getRoot$Entity(n),c=await i.execute({$entity:s,$root:l,state:n,scene:r.get().scene});a(),o.push(c)}return o}finally{if(i?.active){let t=this._context.domainContextSelectors.getStoreSystem();t.emit(t.stateSlices.committed.value)}s()}};initialize=()=>{null!==this._generation&&(this._generation.active=!1),this._generation={active:!0},this._queue=null,this._exporting.value&&this._exporting.next(!1)}}
@@ -20,6 +20,13 @@ export interface EntityMetaContext {
20
20
  readonly success: false;
21
21
  readonly errors: readonly string[];
22
22
  };
23
+ /**
24
+ * Takes a screenshot of the entity from one of its views on the state it was read on and returns
25
+ * the label of the image; `null` when the view does not apply to the entity there.
26
+ */
27
+ readonly takeScreenshot: (source: EntityMetaSource, view: string) => Promise<{
28
+ readonly image: string;
29
+ } | null>;
23
30
  }
24
31
  /** One reason a dry-run reports for a change that cannot be made; a violation can sit on a virtual entity. */
25
32
  interface DryRunError {
@@ -30,7 +37,8 @@ interface DryRunError {
30
37
  /**
31
38
  * The value of an entity's `meta` field: its built-ins, resolved lazily against the state the entity
32
39
  * was read on. `childRecipes` and `replaceRecipes` list the manifest's recipe groups of their kind
33
- * that are active on the entity there; each options edge lists the choices of its field there, or `null` when its component is not active.
40
+ * that are active on the entity there; each options edge lists the choices of its field there, or `null` when its component is not active;
41
+ * `screenshot` renders the entity there.
34
42
  */
35
43
  export declare const createEntityMeta: (source: EntityMetaSource, context: EntityMetaContext) => {
36
44
  childRecipes: () => {
@@ -85,5 +93,10 @@ export declare const createEntityMeta: (source: EntityMetaSource, context: Entit
85
93
  } | null;
86
94
  }[];
87
95
  }[];
96
+ screenshot: ({ view }: {
97
+ readonly view: string;
98
+ }) => Promise<{
99
+ readonly image: string;
100
+ } | null>;
88
101
  };
89
102
  export {};
@@ -1 +1 @@
1
- import{findAssistantFieldOptions as e,findAssistantRecipeGroups as t,modifyEntityUpdateTag as i,prepareAssistantRecipeUpdates as r,readAssistantFieldOptions as n,readAssistantRecipeGroup as o,systemUpdateFactory as s}from"#package/domain";import{readSideEffects as a}from"./side-effects.js";let d=e=>({ok:!1,root:null,changedEntities:[],deletedEntityIds:[],sideEffects:[],errors:e}),l=(e,{state:t},{recipes:i,prepareStateEmission:r,find$Entity:n})=>{let{validity:o,state:s,updates:l}=r(e,t,"committed");if(o.valid){let e=new Map(t.entities.map(e=>[e.id,e])),r=new Set(s.entities.map(e=>e.id));return{ok:!0,root:n(s.rootEntityId,s),changedEntities:s.entities.filter(t=>e.get(t.id)!==t).flatMap(e=>n(e.id,s)??[]),deletedEntityIds:t.entities.map(e=>e.id).filter(e=>!r.has(e)),sideEffects:a(l,i.resolveLocalizable),errors:[]}}return d("uncaught"===o.severity?[{type:"uncaught",entityId:null,message:o.error.message}]:o.entityViolations.filter(({violation:e})=>e.severity===o.severity).map(({entityId:e,violation:t})=>({type:t.type,entityId:e,message:void 0===t.message?null:i.resolveLocalizable(t.message)})))};export const createEntityMeta=(a,u)=>{let c=e=>()=>t(u.manifest,e,a.entity.type).flatMap(t=>{let i=o(e,t,a.entity.id,a.state,u.recipes);return i?[((e,t,i)=>{let{group:n,label:o,description:s,recipes:a}=e,{resolveLocalizable:u}=i.recipes;return{groupId:n.groupId,name:void 0===o?n.instanceName:u(o),description:n.description??(void 0===s?null:u(s)),recipes:a.map(n=>((e,t,i,n)=>{let{key:o,item:s}=e,{resolveLocalizable:a}=n.recipes;return{key:o,name:a(s.title),description:void 0===s.description?null:a(s.description),imageUrl:void 0===s.thumbnailUrl?null:a(s.thumbnailUrl),dryRun:()=>t.group.dryRuns?((e,t,i,n)=>{let{updates:o,error:s}=((e,t,{entity:i,state:n},{recipes:o})=>{try{return{updates:r(e,t,i.id,n,o),error:void 0}}catch(e){if("child"===t.target.kind)throw e;return{updates:void 0,error:e instanceof Error?e.message:String(e)}}})(e,t,i,n);return void 0===o?d([{type:"uncaught",entityId:null,message:s}]):l(o,i,n)})(e,t,i,n):null}})(n,e,t,i))}})(i,a,u)]:[]});return{...Object.fromEntries(e(u.manifest,a.entity.type).map(e=>[e.edgeName,()=>n(e,a.entity.id,a.state,u.recipes)?.map(t=>({...t,dryRun:()=>e.dryRuns?(({field:e},{value:t},r,n)=>{let{entity:o}=r,a=Object.entries(Object.entries(n.manifest.writableFields??{}).find(([e])=>e===o.type)?.[1]??{}).find(([t])=>t===e)?.[1];if(void 0===a)throw Error(`The options of "${e}" on "${o.id}" cannot be dry-run: the schema lists them, but the configurator has no writable field "${e}" on ${o.type}. This is a fault in the configurator, not in your request. Tell the user this is not available.`);let u=r.state.entities.find(e=>e.id===o.id);if(!u)throw Error(`The options of "${e}" on "${o.id}" cannot be dry-run: entity "${o.id}" does not exist. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);let c={[a]:t},p=n.validateEntity({...u,...c});return p.success?l([s.DomainEntityModification({entityId:o.id,stateDelta:c,updateTag:i})],r,n):d([{type:"uncaught",entityId:o.id,message:`Writing ${JSON.stringify(t)} to "${e}" would make "${o.id}" an invalid ${o.type}: ${p.errors.join("; ")}. The option comes from the configurator and cannot be corrected from here, so do not write it.`}])})(e,t,a,u):null}))??null])),childRecipes:c("child"),replaceRecipes:c("replace")}};
1
+ import{findAssistantFieldOptions as e,findAssistantRecipeGroups as t,modifyEntityUpdateTag as i,prepareAssistantRecipeUpdates as r,readAssistantFieldOptions as n,readAssistantRecipeGroup as o,systemUpdateFactory as s}from"#package/domain";import{readSideEffects as a}from"./side-effects.js";let d=e=>({ok:!1,root:null,changedEntities:[],deletedEntityIds:[],sideEffects:[],errors:e}),l=(e,{state:t},{recipes:i,prepareStateEmission:r,find$Entity:n})=>{let{validity:o,state:s,updates:l}=r(e,t,"committed");if(o.valid){let e=new Map(t.entities.map(e=>[e.id,e])),r=new Set(s.entities.map(e=>e.id));return{ok:!0,root:n(s.rootEntityId,s),changedEntities:s.entities.filter(t=>e.get(t.id)!==t).flatMap(e=>n(e.id,s)??[]),deletedEntityIds:t.entities.map(e=>e.id).filter(e=>!r.has(e)),sideEffects:a(l,i.resolveLocalizable),errors:[]}}return d("uncaught"===o.severity?[{type:"uncaught",entityId:null,message:o.error.message}]:o.entityViolations.filter(({violation:e})=>e.severity===o.severity).map(({entityId:e,violation:t})=>({type:t.type,entityId:e,message:void 0===t.message?null:i.resolveLocalizable(t.message)})))};export const createEntityMeta=(a,u)=>{let c=e=>()=>t(u.manifest,e,a.entity.type).flatMap(t=>{let i=o(e,t,a.entity.id,a.state,u.recipes);return i?[((e,t,i)=>{let{group:n,label:o,description:s,recipes:a}=e,{resolveLocalizable:u}=i.recipes;return{groupId:n.groupId,name:void 0===o?n.instanceName:u(o),description:n.description??(void 0===s?null:u(s)),recipes:a.map(n=>((e,t,i,n)=>{let{key:o,item:s}=e,{resolveLocalizable:a}=n.recipes;return{key:o,name:a(s.title),description:void 0===s.description?null:a(s.description),imageUrl:void 0===s.thumbnailUrl?null:a(s.thumbnailUrl),dryRun:()=>t.group.dryRuns?((e,t,i,n)=>{let{updates:o,error:s}=((e,t,{entity:i,state:n},{recipes:o})=>{try{return{updates:r(e,t,i.id,n,o),error:void 0}}catch(e){if("child"===t.target.kind)throw e;return{updates:void 0,error:e instanceof Error?e.message:String(e)}}})(e,t,i,n);return void 0===o?d([{type:"uncaught",entityId:null,message:s}]):l(o,i,n)})(e,t,i,n):null}})(n,e,t,i))}})(i,a,u)]:[]});return{...Object.fromEntries(e(u.manifest,a.entity.type).map(e=>[e.edgeName,()=>n(e,a.entity.id,a.state,u.recipes)?.map(t=>({...t,dryRun:()=>e.dryRuns?(({field:e},{value:t},r,n)=>{let{entity:o}=r,a=Object.entries(Object.entries(n.manifest.writableFields??{}).find(([e])=>e===o.type)?.[1]??{}).find(([t])=>t===e)?.[1];if(void 0===a)throw Error(`The options of "${e}" on "${o.id}" cannot be dry-run: the schema lists them, but the configurator has no writable field "${e}" on ${o.type}. This is a fault in the configurator, not in your request. Tell the user this is not available.`);let u=r.state.entities.find(e=>e.id===o.id);if(!u)throw Error(`The options of "${e}" on "${o.id}" cannot be dry-run: entity "${o.id}" does not exist. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);let c={[a]:t},p=n.validateEntity({...u,...c});return p.success?l([s.DomainEntityModification({entityId:o.id,stateDelta:c,updateTag:i})],r,n):d([{type:"uncaught",entityId:o.id,message:`Writing ${JSON.stringify(t)} to "${e}" would make "${o.id}" an invalid ${o.type}: ${p.errors.join("; ")}. The option comes from the configurator and cannot be corrected from here, so do not write it.`}])})(e,t,a,u):null}))??null])),childRecipes:c("child"),replaceRecipes:c("replace"),screenshot:({view:e})=>u.takeScreenshot(a,e)}};
@@ -1,15 +1,29 @@
1
1
  import { type ExecutionResult } from 'graphql';
2
2
  import { type Localizable } from '@salsita-ai/common/utils';
3
- import { type $DomainEntity, type DomainContextSelectors, type DomainEntity, type DomainServicesSelectors, type DomainState, type SessionAssistantSetup, type SpecSelectors, type StateUpdateEmission } from '#package/domain';
3
+ import { type $DomainEntity, type AgentScreenshotComponent, type ComponentSnapshot, type DomainContextSelectors, type DomainEntity, type DomainServicesSelectors, type DomainState, type InitializationGeneration, type SessionAssistantSetup, type SpecSelectors, type StateUpdateEmission } from '#package/domain';
4
4
  /** One single-operation GraphQL document with its own variables, as executed by {@link GraphQLSystem}. */
5
5
  export interface GraphQLOperation {
6
6
  readonly document: string;
7
7
  readonly variables?: Readonly<Record<string, unknown>>;
8
8
  readonly operationName?: string;
9
9
  }
10
+ /** A screenshot an operation took, under the label its `image` field returned. */
11
+ export interface GraphQLScreenshot {
12
+ readonly entityId: string;
13
+ readonly view: string;
14
+ /** The picture as base64 data. */
15
+ readonly data: string;
16
+ readonly mimeType: 'image/jpeg' | 'image/png';
17
+ }
10
18
  export interface GraphQLSystemContext {
11
19
  /** The assistant the initialized session runs: the operations are validated and executed against its schema. */
12
20
  readonly getAssistantSetup: () => SessionAssistantSetup;
21
+ /**
22
+ * Renders the picture an `agentScreenshot` component of a state declares, behind every export
23
+ * already queued; `null` from an executor that renders no pictures. The only async step of an
24
+ * execution, and the only one that needs a canvas.
25
+ */
26
+ readonly renderScreenshot: (component: ComponentSnapshot<AgentScreenshotComponent>, state: AnyDomainState) => Promise<Blob | null>;
13
27
  readonly specSelectors: SpecSelectors;
14
28
  readonly domainContextSelectors: DomainContextSelectors;
15
29
  readonly domainServicesSelectors: DomainServicesSelectors;
@@ -25,6 +39,8 @@ type AnyStateUpdateEmission = StateUpdateEmission<DomainEntity<string>, Record<s
25
39
  export interface PreparedOperation {
26
40
  readonly result: ExecutionResult;
27
41
  readonly emissions: readonly AnyStateUpdateEmission[];
42
+ /** The screenshots the operation took, by label, in the order they were taken. */
43
+ readonly screenshots: ReadonlyMap<string, GraphQLScreenshot>;
28
44
  }
29
45
  /**
30
46
  * What {@link GraphQLSystem.execute} returns: the results of the operations as prepared from the
@@ -45,6 +61,8 @@ export interface GraphQLExecution {
45
61
  * the undo history by it. It stays in the browser: nothing that leaves it may carry the state.
46
62
  */
47
63
  readonly preparedState?: AnyDomainState;
64
+ /** The screenshots the operations took, by the label their `image` field returned, in the order they were taken. */
65
+ readonly screenshots: ReadonlyMap<string, GraphQLScreenshot>;
48
66
  }
49
67
  /**
50
68
  * Resolves a localizable value, or each item of a list of them, to a string in the current locale.
@@ -77,6 +95,17 @@ export declare class GraphQLSystem {
77
95
  /** Root field resolvers, called by the executor with the field arguments and the operation context. */
78
96
  private readonly _rootValue;
79
97
  private readonly _resolveType;
98
+ private _generation;
99
+ /**
100
+ * The picture of an entity of a state from one `agentScreenshot` view, as base64 of the view's
101
+ * file format; `null` when the view is not attached to the entity there or nothing renders it.
102
+ */
103
+ private readonly _renderScreenshot;
104
+ /**
105
+ * Starts a new generation for a new configuration load. Screenshots wait on renders that take
106
+ * seconds, so an execution can outlive its configuration: one started under the ended generation
107
+ * renders no more screenshots and commits nothing, not even on a conflict retry.
108
+ */
80
109
  initialize: () => void;
81
110
  /**
82
111
  * Runs one mutation field against the working state: its implementation computes updates from the
@@ -87,6 +116,13 @@ export declare class GraphQLSystem {
87
116
  */
88
117
  private readonly _resolveMutation;
89
118
  private readonly _runMutation;
119
+ /**
120
+ * Takes a screenshot once every one asked for before it in the execution has been taken, so they
121
+ * render and spend the budget in document order. A failure nulls only its own field and fails
122
+ * nothing else: the user kept changing the configuration, the image did not fit the budget, or
123
+ * rendering failed. Once the budget is spent, no later screenshot renders.
124
+ */
125
+ private readonly _takeScreenshot;
90
126
  private readonly _setup;
91
127
  /**
92
128
  * Parses, validates and executes one operation document. Validation adds the rule against
@@ -98,21 +134,26 @@ export declare class GraphQLSystem {
98
134
  * Runs the operations in order through one working state that starts at `originalState`: a query
99
135
  * reads the current working state, and each mutation field advances it with its own emission.
100
136
  * The closing braces an operation's document left off are added, then the lenses it spreads are injected into it. Nothing is committed. The first operation that fails stops the list; every later one gets a
101
- * "not run" error instead.
137
+ * "not run" error instead. Screenshots render only while `generation`, the current one by
138
+ * default, is active.
102
139
  */
103
- prepare: (originalState: AnyDomainState, operations: readonly GraphQLOperation[]) => Promise<readonly PreparedOperation[]>;
140
+ prepare: (originalState: AnyDomainState, operations: readonly GraphQLOperation[], generation?: InitializationGeneration) => Promise<readonly PreparedOperation[]>;
104
141
  /**
105
142
  * The side effects of prepared operations: the hints of every update of their emissions, as the
106
143
  * agent is told them, in applied order.
107
144
  */
108
145
  readSideEffects: (prepared: readonly PreparedOperation[]) => readonly string[];
146
+ /** The screenshots of prepared operations, by label, in the order they were taken. */
147
+ readScreenshots: (prepared: readonly PreparedOperation[]) => ReadonlyMap<string, GraphQLScreenshot>;
109
148
  private readonly _prepareAndCommit;
110
149
  /**
111
150
  * Prepares the operations from the committed state and commits their changes as one emission,
112
151
  * synthesized from every field emission of the list: one undo step, `onBeforeCommit` hooks run once. Nothing is committed when an operation fails or
113
152
  * none changes anything. When the committed state changed meanwhile, the operations are prepared
114
153
  * once more from the new committed state; their earlier updates are never replayed, since they
115
- * were computed from a state that is gone.
154
+ * were computed from a state that is gone. When another configuration was loaded meanwhile,
155
+ * nothing is committed or prepared again: the operations were written for the configuration
156
+ * that was left.
116
157
  */
117
158
  execute: (operations: readonly GraphQLOperation[]) => Promise<GraphQLExecution>;
118
159
  }