@salsita-ai/sdk 0.50.0-develop.10b1931917 → 0.50.0-develop.1ddc7020fd

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 (684) hide show
  1. package/README.md +11 -11
  2. package/dist/admin/create-admin-pages-from-spec.d.ts +1 -1
  3. package/dist/application-spec/generate-application/code/common/index.d.ts +1 -0
  4. package/dist/application-spec/generate-application/code/common/index.js +1 -1
  5. package/dist/application-spec/generate-application/code/common/project-module-list.d.ts +8 -0
  6. package/dist/application-spec/generate-application/code/common/project-module-list.js +3 -0
  7. package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
  8. package/dist/application-spec/generate-application/code/project-scaffolding.js +2 -2
  9. package/dist/application-spec/generate-application/code/templates/admin-domain-code.d.ts +1 -2
  10. package/dist/application-spec/generate-application/code/templates/admin-domain-code.js +6 -14
  11. package/dist/application-spec/generate-application/code/templates/admin-frontend-code.d.ts +1 -2
  12. package/dist/application-spec/generate-application/code/templates/admin-frontend-code.js +4 -4
  13. package/dist/application-spec/generate-application/code/templates/configurator-domain-code.d.ts +1 -2
  14. package/dist/application-spec/generate-application/code/templates/configurator-domain-code.js +7 -16
  15. package/dist/application-spec/generate-application/code/templates/configurator-frontend-code.d.ts +1 -2
  16. package/dist/application-spec/generate-application/code/templates/configurator-frontend-code.js +7 -9
  17. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-assistant.d.ts +2 -2
  18. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-assistant.js +1 -1
  19. package/dist/application-spec/generate-application/code/templates/domain-spec.js +4 -4
  20. package/dist/application-spec/generate-application/code/templates/domain.js +3 -3
  21. package/dist/application-spec/generate-application/code/templates/index.d.ts +1 -0
  22. package/dist/application-spec/generate-application/code/templates/index.js +1 -1
  23. package/dist/application-spec/generate-application/code/templates/skills/agents-md.js +1 -1
  24. package/dist/application-spec/generate-application/code/templates/skills/phoenix-cli-skill.js +1 -1
  25. package/dist/application-spec/generate-application/code/templates/skills/phoenix-create-configurator-skill.js +43 -13
  26. package/dist/application-spec/generate-application/code/templates/skills/phoenix-feedback-skill.js +39 -16
  27. package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js +2 -2
  28. package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill.js +1 -1
  29. package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.d.ts +1 -0
  30. package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.js +6 -0
  31. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +30 -3
  32. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +19 -5
  33. package/dist/application-spec/generate-application/code/templates/webhook-builders.js +8 -4
  34. package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.d.ts +4 -3
  35. package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.js +1 -1
  36. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.d.ts +3 -8
  37. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.js +1 -1
  38. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +9 -43
  39. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
  40. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-server-settings.d.ts +2 -2
  41. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant.d.ts +5 -21
  42. package/dist/client/phoenix-api.d.ts +58 -30
  43. package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
  44. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +158 -13
  45. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
  46. package/dist/configurator/application-runtime/extensions/systems/assistant-system/change-recorder.d.ts +85 -0
  47. package/dist/configurator/application-runtime/extensions/systems/assistant-system/change-recorder.js +1 -0
  48. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +8 -3
  49. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -1
  50. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.d.ts +4 -0
  51. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.js +1 -1
  52. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +16 -1
  53. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
  54. package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.d.ts +9 -0
  55. package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.js +1 -0
  56. package/dist/configurator/application-runtime/extensions/systems/index.d.ts +1 -1
  57. package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.d.ts +2 -0
  58. package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.js +1 -1
  59. package/dist/configurator/common/frontend-analytics.d.ts +21 -21
  60. package/dist/configurator/index.d.ts +0 -1
  61. package/dist/configurator/index.js +1 -1
  62. package/dist/configurator/pages/LoadedConfiguratorDetailPage.js +1 -1
  63. package/dist/configurator/scene/scene-analytics/scene-analytics.d.ts +2 -2
  64. package/dist/configurator/ui/assistant/AssistantChips.d.ts +11 -0
  65. package/dist/configurator/ui/assistant/AssistantChips.js +1 -0
  66. package/dist/configurator/ui/assistant/AssistantComposer.d.ts +6 -0
  67. package/dist/configurator/ui/assistant/AssistantComposer.js +1 -0
  68. package/dist/configurator/ui/assistant/AssistantMarkdown.d.ts +7 -0
  69. package/dist/configurator/ui/assistant/AssistantMarkdown.js +1 -0
  70. package/dist/configurator/ui/assistant/AssistantPanel.d.ts +11 -0
  71. package/dist/configurator/ui/assistant/AssistantPanel.js +1 -0
  72. package/dist/configurator/ui/assistant/AssistantThread.d.ts +6 -0
  73. package/dist/configurator/ui/assistant/AssistantThread.js +1 -0
  74. package/dist/configurator/ui/assistant/assistant-failure.d.ts +18 -0
  75. package/dist/configurator/ui/assistant/assistant-failure.js +1 -0
  76. package/dist/configurator/ui/assistant/index.d.ts +2 -0
  77. package/dist/configurator/ui/assistant/index.js +1 -0
  78. package/dist/configurator/ui/assistant/streamed-markdown.d.ts +6 -0
  79. package/dist/configurator/ui/assistant/streamed-markdown.js +2 -0
  80. package/dist/configurator/ui/assistant/theme.d.ts +2 -0
  81. package/dist/configurator/ui/assistant/theme.js +1 -0
  82. package/dist/configurator/ui/assistant/thread-items.d.ts +37 -0
  83. package/dist/configurator/ui/assistant/thread-items.js +1 -0
  84. package/dist/configurator/ui/assistant/tool-chip.d.ts +44 -0
  85. package/dist/configurator/ui/assistant/tool-chip.js +1 -0
  86. package/dist/configurator/ui/assistant/use-follow-stream.d.ts +17 -0
  87. package/dist/configurator/ui/assistant/use-follow-stream.js +1 -0
  88. package/dist/configurator/ui/assistant/use-is-assistant-panel-open.d.ts +5 -0
  89. package/dist/configurator/ui/assistant/use-is-assistant-panel-open.js +1 -0
  90. package/dist/configurator/ui/configurator-layout/universal/DesktopLayout.js +5 -5
  91. package/dist/configurator/ui/configurator-layout/universal/MobileLayout.d.ts +2 -0
  92. package/dist/configurator/ui/configurator-layout/universal/MobileLayout.js +4 -4
  93. package/dist/configurator/ui/legacy/mobile-controls/MobileControls.d.ts +1 -1
  94. package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.d.ts +10 -0
  95. package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.js +1 -0
  96. package/dist/configurator/ui/phoenix-layout-elements/index.d.ts +1 -0
  97. package/dist/configurator/ui/phoenix-layout-elements/index.js +1 -1
  98. package/dist/docs/complex-use-cases/filtered-controls-with-fix-dialog.mdx +84 -98
  99. package/dist/docs/complex-use-cases/navigation-reset-selection.mdx +18 -12
  100. package/dist/docs/index.json +1 -1
  101. package/dist/docs/layouts/custom-price.mdx +14 -16
  102. package/dist/docs/layouts/sidebar/tabs.mdx +24 -21
  103. package/dist/docs/layouts/toolbar.mdx +6 -0
  104. package/dist/docs/other-features/domain-actions.mdx +1 -1
  105. package/dist/docs/other-features/side-effects.mdx +68 -34
  106. package/dist/docs/other-features/transformers.mdx +1 -1
  107. package/dist/docs/phoenix/admin.mdx +11 -26
  108. package/dist/docs/phoenix/finalization.mdx +1 -1
  109. package/dist/docs/phoenix/integration/headless-mode-external.mdx +5 -5
  110. package/dist/docs/phoenix/integration/widget-mode-external.mdx +5 -5
  111. package/dist/docs/phoenix/localization.mdx +3 -22
  112. package/dist/docs/phoenix/phoenix-cli.mdx +96 -13
  113. package/dist/docs/phoenix/project-structure.mdx +9 -2
  114. package/dist/docs/phoenix/sdk-builder-workflow.mdx +7 -5
  115. package/dist/docs/recipes-and-delete/recipe-hierarchy-selection.mdx +15 -13
  116. package/dist/docs/relations/hierarchy.mdx +13 -2
  117. package/dist/domain/actions/action-factory.d.ts +4 -4
  118. package/dist/domain/admin-domain/__generated/enhanced-model.d.ts +1 -1
  119. package/dist/domain/admin-domain/__generated/model/versions/v1.d.ts +1 -1
  120. package/dist/domain/admin-domain/__generated/model/versions/v2.d.ts +1 -1
  121. package/dist/domain/admin-domain/__generated/model/versions/v3.d.ts +1 -1
  122. package/dist/domain/admin-domain/__generated/model/versions/v4.d.ts +1 -1
  123. package/dist/domain/admin-domain/__generated/model/versions/v5.d.ts +1 -1
  124. package/dist/domain/admin-domain/__generated/model/versions/v6.d.ts +2 -2
  125. package/dist/domain/admin-domain/__generated/model/versions/v6.js +1 -1
  126. package/dist/domain/admin-domain/implementation/common-admin-expressions.d.ts +1 -3
  127. package/dist/domain/admin-domain/implementation/common-admin-migrations.d.ts +1 -1
  128. package/dist/domain/admin-domain/index.d.ts +2 -3
  129. package/dist/domain/admin-domain/index.js +1 -1
  130. package/dist/domain/application/admin-page-factories.d.ts +1 -1
  131. package/dist/domain/application/application-config.d.ts +25 -75
  132. package/dist/domain/application/assistant/assistant-manifest.d.ts +61 -0
  133. package/dist/domain/application/assistant/assistant-resolved-manifest.d.ts +95 -0
  134. package/dist/domain/application/assistant/assistant-value-type.d.ts +9 -0
  135. package/dist/domain/application/assistant/assistant-value-type.js +1 -0
  136. package/dist/domain/application/assistant/build-assistant-manifest.d.ts +4 -0
  137. package/dist/domain/application/assistant/build-assistant-manifest.js +1 -0
  138. package/dist/{phoenix/application-spec → domain/application/assistant}/generate-assistant-prompt.d.ts +6 -5
  139. package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -0
  140. package/dist/domain/application/assistant/index.d.ts +4 -0
  141. package/dist/domain/application/assistant/index.js +1 -0
  142. package/dist/domain/application/assistant-field-options.d.ts +2 -3
  143. package/dist/domain/application/assistant-mutations.d.ts +2 -5
  144. package/dist/domain/application/assistant-mutations.js +1 -1
  145. package/dist/domain/application/assistant-recipe-groups.d.ts +2 -6
  146. package/dist/domain/application/configurator-builder.d.ts +33 -18
  147. package/dist/domain/application/configurator-builder.js +1 -1
  148. package/dist/domain/application/element-registration.d.ts +5 -0
  149. package/dist/domain/application/element-registration.js +1 -1
  150. package/dist/domain/application/handler-registration.d.ts +5 -0
  151. package/dist/domain/application/handler-registration.js +1 -1
  152. package/dist/domain/application/index.d.ts +5 -4
  153. package/dist/domain/application/index.js +1 -1
  154. package/dist/domain/application/published-data/create-finalize-admin-domain.d.ts +1 -2
  155. package/dist/domain/application/published-data/map-published-chunked-data.d.ts +1 -1
  156. package/dist/domain/application/published-data/map-published-data.d.ts +1 -2
  157. package/dist/domain/application/resolve-imported-transformers.d.ts +12 -2
  158. package/dist/domain/application/resolve-imported-transformers.js +1 -1
  159. package/dist/domain/core/action.d.ts +5 -6
  160. package/dist/domain/{components → core/component}/component-reader-types.d.ts +1 -2
  161. package/dist/domain/{components → core/component}/debug-state-component.d.ts +1 -1
  162. package/dist/domain/core/component/debug-state-component.js +1 -0
  163. package/dist/domain/{components → core/component}/domain-component-optic.d.ts +6 -6
  164. package/dist/domain/core/component/domain-component-optic.js +16 -0
  165. package/dist/domain/{components → core/component}/drag-state-component.d.ts +1 -1
  166. package/dist/domain/core/component/drag-state-component.js +1 -0
  167. package/dist/domain/{components → core/component}/export-state-component.d.ts +1 -1
  168. package/dist/domain/core/component/export-state-component.js +1 -0
  169. package/dist/domain/{components → core/component}/fullscreen-state-component.d.ts +1 -1
  170. package/dist/domain/core/component/fullscreen-state-component.js +1 -0
  171. package/dist/domain/{components → core/component}/group-components-by-entity-id-and-name.d.ts +1 -2
  172. package/dist/domain/core/component/group-components-by-entity-id-and-name.js +1 -0
  173. package/dist/domain/{components → core/component}/hover-state-component.d.ts +1 -1
  174. package/dist/domain/core/component/hover-state-component.js +1 -0
  175. package/dist/domain/core/component/index.d.ts +18 -0
  176. package/dist/domain/core/component/index.js +1 -0
  177. package/dist/domain/{components → core/component}/legacy-filter.d.ts +2 -2
  178. package/dist/domain/{components → core/component}/navigation-state-component.d.ts +1 -1
  179. package/dist/domain/core/component/navigation-state-component.js +1 -0
  180. package/dist/domain/{components → core/component}/selection-state-component.d.ts +1 -1
  181. package/dist/domain/core/component/selection-state-component.js +1 -0
  182. package/dist/domain/{components → core/component}/system-component-builder.d.ts +1 -2
  183. package/dist/domain/core/component/system-component-builder.js +1 -0
  184. package/dist/domain/{components → core/component}/system-component-filter.d.ts +3 -3
  185. package/dist/domain/core/component/system-virtual-entity.js +1 -0
  186. package/dist/domain/{components → core/component}/tool-state-component.d.ts +1 -1
  187. package/dist/domain/core/component/tool-state-component.js +1 -0
  188. package/dist/domain/{components → core/component}/updates.d.ts +17 -2
  189. package/dist/domain/{components → core/component}/view-state-component.d.ts +1 -1
  190. package/dist/domain/core/component/view-state-component.js +1 -0
  191. package/dist/domain/{components → core/component}/viewport-state-component.d.ts +1 -1
  192. package/dist/domain/core/component/viewport-state-component.js +1 -0
  193. package/dist/domain/core/decoder/create-decoder.d.ts +6 -0
  194. package/dist/domain/core/decoder/create-decoder.js +1 -0
  195. package/dist/domain/core/decoder/decoder.d.ts +6 -0
  196. package/dist/domain/core/decoder/index.d.ts +2 -0
  197. package/dist/domain/core/decoder/index.js +1 -0
  198. package/dist/domain/core/domain-factory.d.ts +3 -4
  199. package/dist/domain/core/domain-factory.js +1 -1
  200. package/dist/domain/core/domain.d.ts +3 -4
  201. package/dist/domain/core/domain.js +1 -1
  202. package/dist/domain/{expressions → core/expression}/constant-expressions.d.ts +2 -3
  203. package/dist/domain/core/expression/constant-expressions.js +1 -0
  204. package/dist/domain/{expressions → core/expression}/custom-expression.d.ts +4 -5
  205. package/dist/domain/core/expression/custom-expression.js +1 -0
  206. package/dist/domain/core/{expression.d.ts → expression/expression.d.ts} +6 -8
  207. package/dist/domain/core/expression/expression.js +1 -0
  208. package/dist/domain/core/expression/index.d.ts +5 -0
  209. package/dist/domain/core/expression/index.js +1 -0
  210. package/dist/domain/{expressions → core/expression}/memoize-expression.d.ts +2 -2
  211. package/dist/domain/{expressions → core/expression}/prepare-domain-expressions.d.ts +1 -1
  212. package/dist/domain/core/index.d.ts +8 -17
  213. package/dist/domain/core/index.js +1 -1
  214. package/dist/domain/core/{component.d.ts → model/component.d.ts} +1 -1
  215. package/dist/domain/core/model/index.d.ts +6 -0
  216. package/dist/domain/core/model/index.js +1 -0
  217. package/dist/domain/core/{reflection.d.ts → model/reflection.d.ts} +1 -1
  218. package/dist/domain/core/model/reflection.js +1 -0
  219. package/dist/domain/core/schema/enhanced-json-schema.js +1 -0
  220. package/dist/domain/core/schema/extended-schema-validator.js +1 -0
  221. package/dist/domain/core/schema/index.d.ts +3 -0
  222. package/dist/domain/core/schema/index.js +1 -0
  223. package/dist/domain/core/schema/schema-validator.js +1 -0
  224. package/dist/domain/core/state/id-sequence.d.ts +15 -0
  225. package/dist/domain/core/state/id-sequence.js +1 -0
  226. package/dist/domain/core/state/index.d.ts +3 -0
  227. package/dist/domain/core/state/index.js +1 -0
  228. package/dist/domain/core/{migrations.d.ts → state/migrations.d.ts} +1 -2
  229. package/dist/domain/core/{state.d.ts → state/state.d.ts} +1 -2
  230. package/dist/domain/domain-builder.d.ts +11 -8
  231. package/dist/domain/domain-builder.js +1 -1
  232. package/dist/domain/domain-context/action-system/action-system.d.ts +1 -3
  233. package/dist/domain/domain-context/action-system/action-system.js +1 -1
  234. package/dist/domain/domain-context/create-transformer.d.ts +1 -1
  235. package/dist/domain/domain-context/dimension-system/dimension-state.js +1 -1
  236. package/dist/domain/domain-context/domain-context-systems.d.ts +1 -3
  237. package/dist/domain/domain-context/index.d.ts +2 -2
  238. package/dist/domain/domain-context/navigation-system/navigation-system.d.ts +3 -5
  239. package/dist/domain/domain-context/navigation-system/navigation-system.js +1 -1
  240. package/dist/domain/domain-context/navigation-system/navigation-updates.d.ts +1 -12
  241. package/dist/domain/domain-context/navigation-system/navigation-updates.js +1 -1
  242. package/dist/domain/domain-context/navigation-system/selection-transformers.d.ts +1 -1
  243. package/dist/domain/domain-context/navigation-system/selection-transformers.js +1 -1
  244. package/dist/domain/domain-context/recipe-system/recipe-cooker-system.d.ts +1 -2
  245. package/dist/domain/domain-context/recipe-system/recipe-cooker-system.js +1 -1
  246. package/dist/domain/domain-context/recipe-system/recipes.d.ts +1 -3
  247. package/dist/domain/domain-context/recipe-system/recipes.js +1 -1
  248. package/dist/domain/domain-context/relation-transformers/cascade-deletes.d.ts +1 -1
  249. package/dist/domain/domain-context/relation-transformers/cascade-deletes.js +1 -1
  250. package/dist/domain/domain-context/relation-transformers/cascade-ref-pruning.d.ts +1 -1
  251. package/dist/domain/domain-context/relation-transformers/cascade-ref-pruning.js +1 -1
  252. package/dist/domain/domain-context/relation-transformers/create-entity-refs.d.ts +1 -1
  253. package/dist/domain/domain-context/relation-transformers/create-entity-refs.js +2 -2
  254. package/dist/domain/domain-context/relation-transformers/replace-refs.d.ts +1 -1
  255. package/dist/domain/domain-context/relation-transformers/replace-refs.js +1 -1
  256. package/dist/domain/domain-context/store-system/apply-updates.d.ts +1 -3
  257. package/dist/domain/domain-context/store-system/apply-updates.js +1 -1
  258. package/dist/domain/domain-context/store-system/next-domain-entity-id.d.ts +1 -13
  259. package/dist/domain/domain-context/store-system/next-domain-entity-id.js +1 -1
  260. package/dist/domain/domain-context/store-system/reconcile-projected-entities.d.ts +1 -2
  261. package/dist/domain/domain-context/store-system/reconcile-projected-entities.js +1 -1
  262. package/dist/domain/domain-context/store-system/store-system.d.ts +1 -4
  263. package/dist/domain/domain-context/store-system/store-system.js +2 -2
  264. package/dist/domain/domain-context/store-system/system-state.d.ts +1 -3
  265. package/dist/domain/domain-context/store-system/system-state.js +1 -1
  266. package/dist/domain/domain-context/transformers/actions-builder.d.ts +1 -2
  267. package/dist/domain/domain-context/transformers/actions-builder.js +1 -1
  268. package/dist/domain/domain-context/transformers/auto-snap-transformer.d.ts +1 -3
  269. package/dist/domain/domain-context/transformers/chain-builder.d.ts +2 -2
  270. package/dist/domain/domain-context/transformers/context.d.ts +1 -4
  271. package/dist/domain/domain-context/transformers/entity-builder.d.ts +1 -4
  272. package/dist/domain/domain-context/transformers/entity-builder.js +1 -1
  273. package/dist/domain/domain-context/transformers/then-builder.d.ts +1 -1
  274. package/dist/domain/domain-context/transformers/then-builder.js +1 -1
  275. package/dist/domain/domain-context/transformers/when-builder.d.ts +1 -6
  276. package/dist/domain/domain-context/transformers/when-builder.js +1 -1
  277. package/dist/domain/domain-context/undo-system.d.ts +1 -1
  278. package/dist/domain/domain-runtime/domain-context/component-reader.d.ts +1 -4
  279. package/dist/domain/domain-runtime/domain-context/component-reader.js +1 -1
  280. package/dist/domain/domain-runtime/domain-context/selectors.d.ts +1 -3
  281. package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
  282. package/dist/domain/domain-runtime/domain-runtime.d.ts +4 -4
  283. package/dist/domain/domain-runtime/spec/initialize.js +1 -1
  284. package/dist/domain/domain-runtime/spec/selectors.d.ts +2 -2
  285. package/dist/domain/domain-runtime/spec/selectors.js +1 -1
  286. package/dist/domain/domain-runtime/spec/types.d.ts +4 -5
  287. package/dist/domain/index.d.ts +2 -20
  288. package/dist/domain/index.js +1 -1
  289. package/dist/domain/invariants/builtin-invariant.d.ts +1 -2
  290. package/dist/domain/invariants/custom-invariants.d.ts +1 -3
  291. package/dist/domain/invariants/invariants.d.ts +10 -4
  292. package/dist/domain/invariants/invariants.js +1 -1
  293. package/dist/domain/invariants/violation-component.js +1 -1
  294. package/dist/domain/invariants/violation.d.ts +1 -1
  295. package/dist/domain/mocks/create-mock-domain-runtime.d.ts +3 -3
  296. package/dist/domain/mocks/create-mock-domain-runtime.js +1 -1
  297. package/dist/domain/project-modules/index.d.ts +1 -0
  298. package/dist/domain/project-modules/index.js +1 -0
  299. package/dist/domain/project-modules/project-modules.d.ts +41 -0
  300. package/dist/domain/project-modules/project-modules.js +1 -0
  301. package/dist/domain/projections/blender-projections/blender-projections.d.ts +1 -1
  302. package/dist/domain/projections/blender-projections/blender-projections.js +1 -1
  303. package/dist/domain/projections/composition-projections.js +1 -1
  304. package/dist/domain/projections/projected-entities-projections.d.ts +1 -2
  305. package/dist/domain/projections/snap-matching.d.ts +1 -2
  306. package/dist/domain/projections/snap-utils.d.ts +1 -2
  307. package/dist/domain/relations/all-of-type-relation.d.ts +1 -4
  308. package/dist/domain/relations/all-of-type-relation.js +1 -1
  309. package/dist/domain/relations/component-factories.d.ts +1 -2
  310. package/dist/domain/relations/composed-of.d.ts +1 -1
  311. package/dist/domain/relations/composed-of.js +1 -1
  312. package/dist/domain/relations/direct-relation.d.ts +1 -3
  313. package/dist/domain/relations/indirect-relation.d.ts +1 -4
  314. package/dist/domain/relations/indirect-relation.js +1 -1
  315. package/dist/domain/relations/reference-component.d.ts +3 -5
  316. package/dist/domain/relations/reference-component.js +1 -1
  317. package/dist/domain/relations/reference-field.d.ts +1 -1
  318. package/dist/domain/relations/relation-factory.d.ts +1 -3
  319. package/dist/domain/relations/relation-implementation.d.ts +1 -4
  320. package/dist/domain/system-components/admin-sidebar.d.ts +1 -1
  321. package/dist/domain/system-components/admin-sidebar.js +1 -1
  322. package/dist/domain/system-components/angle-dimension.js +1 -1
  323. package/dist/domain/system-components/angle-indicator.d.ts +1 -1
  324. package/dist/domain/system-components/angle-indicator.js +1 -1
  325. package/dist/domain/system-components/application-config.d.ts +1 -1
  326. package/dist/domain/system-components/application-config.js +1 -1
  327. package/dist/domain/system-components/attribute-selection.js +1 -1
  328. package/dist/domain/system-components/attribute-switch.js +1 -1
  329. package/dist/domain/system-components/autorotate-camera-component.d.ts +1 -1
  330. package/dist/domain/system-components/autorotate-camera-component.js +1 -1
  331. package/dist/domain/system-components/basic-sidebar-footer.d.ts +1 -1
  332. package/dist/domain/system-components/basic-sidebar-footer.js +1 -1
  333. package/dist/domain/system-components/bounding-box-component.d.ts +1 -1
  334. package/dist/domain/system-components/bounding-box-component.js +1 -1
  335. package/dist/domain/system-components/bounding-sphere-component.d.ts +1 -1
  336. package/dist/domain/system-components/bounding-sphere-component.js +1 -1
  337. package/dist/domain/system-components/camera-based-hidden-entity-object.js +1 -1
  338. package/dist/domain/system-components/camera-based-hidden-entity.js +1 -1
  339. package/dist/domain/system-components/canvas-config.d.ts +1 -1
  340. package/dist/domain/system-components/canvas-config.js +1 -1
  341. package/dist/domain/system-components/canvas-custom-environment.js +1 -1
  342. package/dist/domain/system-components/canvas-padding.d.ts +1 -1
  343. package/dist/domain/system-components/canvas-padding.js +1 -1
  344. package/dist/domain/system-components/canvas-preset-environment.d.ts +1 -1
  345. package/dist/domain/system-components/canvas-preset-environment.js +1 -1
  346. package/dist/domain/system-components/child-entity-recipe-hierarchy.d.ts +1 -1
  347. package/dist/domain/system-components/child-entity-recipe-hierarchy.js +1 -1
  348. package/dist/domain/system-components/child-entity-recipes.d.ts +1 -1
  349. package/dist/domain/system-components/child-entity-recipes.js +1 -1
  350. package/dist/domain/system-components/child-entity-selection.d.ts +1 -1
  351. package/dist/domain/system-components/child-entity-selection.js +1 -1
  352. package/dist/domain/system-components/client-side-image.js +1 -1
  353. package/dist/domain/system-components/collision-box-geometry.d.ts +1 -1
  354. package/dist/domain/system-components/collision-box-geometry.js +1 -1
  355. package/dist/domain/system-components/collision-geometries.d.ts +1 -1
  356. package/dist/domain/system-components/collision-geometry.d.ts +1 -1
  357. package/dist/domain/system-components/collision-geometry.js +1 -1
  358. package/dist/domain/system-components/collision-point-geometry.d.ts +1 -1
  359. package/dist/domain/system-components/collision-point-geometry.js +1 -1
  360. package/dist/domain/system-components/color-value.js +1 -1
  361. package/dist/domain/system-components/common/dimension-indicator-schema.d.ts +1 -1
  362. package/dist/domain/system-components/common/dimension-indicator-schema.js +1 -1
  363. package/dist/domain/system-components/constraint.d.ts +1 -1
  364. package/dist/domain/system-components/constraint.js +1 -1
  365. package/dist/domain/system-components/create-blueprint.d.ts +1 -1
  366. package/dist/domain/system-components/custom-header.d.ts +1 -1
  367. package/dist/domain/system-components/custom-header.js +1 -1
  368. package/dist/domain/system-components/custom-price-footer.js +1 -1
  369. package/dist/domain/system-components/custom-scene-entity.d.ts +1 -1
  370. package/dist/domain/system-components/custom-scene-entity.js +1 -1
  371. package/dist/domain/system-components/custom-sidebar-footer.d.ts +1 -1
  372. package/dist/domain/system-components/custom-sidebar-footer.js +1 -1
  373. package/dist/domain/system-components/detail.js +1 -1
  374. package/dist/domain/system-components/dimension-indicator.d.ts +1 -1
  375. package/dist/domain/system-components/dimension-indicator.js +1 -1
  376. package/dist/domain/system-components/distance-dimension-select.d.ts +1 -1
  377. package/dist/domain/system-components/distance-dimension-select.js +1 -1
  378. package/dist/domain/system-components/distance-dimension.d.ts +1 -1
  379. package/dist/domain/system-components/distance-dimension.js +1 -1
  380. package/dist/domain/system-components/drag-handle.d.ts +1 -1
  381. package/dist/domain/system-components/drag-handle.js +1 -1
  382. package/dist/domain/system-components/editable-angle-indicator.d.ts +1 -1
  383. package/dist/domain/system-components/editable-angle-indicator.js +1 -1
  384. package/dist/domain/system-components/editable-distance-dimension-indicator.d.ts +1 -1
  385. package/dist/domain/system-components/editable-distance-dimension-indicator.js +1 -1
  386. package/dist/domain/system-components/editable-offset-indicator.d.ts +1 -1
  387. package/dist/domain/system-components/editable-offset-indicator.js +1 -1
  388. package/dist/domain/system-components/editable-size-indicator.d.ts +1 -1
  389. package/dist/domain/system-components/editable-size-indicator.js +1 -1
  390. package/dist/domain/system-components/entity-header.js +1 -1
  391. package/dist/domain/system-components/exit-tool-mode-fab.d.ts +1 -1
  392. package/dist/domain/system-components/exit-tool-mode-fab.js +1 -1
  393. package/dist/domain/system-components/finalize-action.d.ts +1 -1
  394. package/dist/domain/system-components/finalize-action.js +1 -1
  395. package/dist/domain/system-components/finalize-component.js +1 -1
  396. package/dist/domain/system-components/fit-entity-orthographic-camera-component.js +1 -1
  397. package/dist/domain/system-components/fit-entity-perspective-camera-component.js +1 -1
  398. package/dist/domain/system-components/fit-root-orthographic-camera-component.js +1 -1
  399. package/dist/domain/system-components/fit-root-perspective-camera-component.js +1 -1
  400. package/dist/domain/system-components/fit-selection-orthographic-camera-component.js +1 -1
  401. package/dist/domain/system-components/fit-selection-perspective-camera-component.js +1 -1
  402. package/dist/domain/system-components/fixed-header.d.ts +1 -1
  403. package/dist/domain/system-components/fixed-header.js +1 -1
  404. package/dist/domain/system-components/floating-header.d.ts +1 -1
  405. package/dist/domain/system-components/floating-header.js +1 -1
  406. package/dist/domain/system-components/generic-dimension.d.ts +1 -1
  407. package/dist/domain/system-components/generic-dimension.js +1 -1
  408. package/dist/domain/system-components/hidden-entity.js +1 -1
  409. package/dist/domain/system-components/hidden-header.d.ts +1 -1
  410. package/dist/domain/system-components/hidden-header.js +1 -1
  411. package/dist/domain/system-components/hidden-sidebar-footer.d.ts +1 -1
  412. package/dist/domain/system-components/hidden-sidebar-footer.js +1 -1
  413. package/dist/domain/system-components/horizontal-tabs.d.ts +1 -1
  414. package/dist/domain/system-components/horizontal-tabs.js +1 -1
  415. package/dist/domain/system-components/hotspot-drag-handle.d.ts +1 -2
  416. package/dist/domain/system-components/hotspot-drag-handle.js +1 -1
  417. package/dist/domain/system-components/list-selector-dimension-indicator.d.ts +1 -1
  418. package/dist/domain/system-components/list-selector-dimension-indicator.js +1 -1
  419. package/dist/domain/system-components/material-override-property-transition.js +1 -1
  420. package/dist/domain/system-components/material-override-transformer.js +1 -1
  421. package/dist/domain/system-components/material-swatch.js +1 -1
  422. package/dist/domain/system-components/multilingual-text-value.js +1 -1
  423. package/dist/domain/system-components/navigation-page.js +1 -1
  424. package/dist/domain/system-components/navigation-panel-list.js +1 -1
  425. package/dist/domain/system-components/navigation-steps.js +1 -1
  426. package/dist/domain/system-components/offset-anchors.d.ts +1 -1
  427. package/dist/domain/system-components/offset-anchors.js +1 -1
  428. package/dist/domain/system-components/offset-indicator.d.ts +1 -2
  429. package/dist/domain/system-components/offset-indicator.js +1 -1
  430. package/dist/domain/system-components/offset.d.ts +1 -1
  431. package/dist/domain/system-components/offset.js +1 -1
  432. package/dist/domain/system-components/other-action.d.ts +1 -1
  433. package/dist/domain/system-components/other-action.js +1 -1
  434. package/dist/domain/system-components/phoenix-layout-elements/assistant-toolbar-button.d.ts +44 -0
  435. package/dist/domain/system-components/phoenix-layout-elements/assistant-toolbar-button.js +1 -0
  436. package/dist/domain/system-components/phoenix-layout-elements/index.d.ts +1 -0
  437. package/dist/domain/system-components/phoenix-layout-elements/index.js +1 -1
  438. package/dist/domain/system-components/phoenix-layout-elements/phoenix-layout-element.d.ts +2 -1
  439. package/dist/domain/system-components/phoenix-layout-elements/phoenix-layout-element.js +1 -1
  440. package/dist/domain/system-components/pivot-point.d.ts +1 -1
  441. package/dist/domain/system-components/pivot-point.js +1 -1
  442. package/dist/domain/system-components/price.js +1 -1
  443. package/dist/domain/system-components/projected-entities.d.ts +1 -1
  444. package/dist/domain/system-components/projected-entities.js +1 -1
  445. package/dist/domain/system-components/property-page.d.ts +1 -1
  446. package/dist/domain/system-components/property-page.js +1 -1
  447. package/dist/domain/system-components/read-sidebar-footer.d.ts +1 -1
  448. package/dist/domain/system-components/read-sidebar-footer.js +1 -1
  449. package/dist/domain/system-components/replace-entity-recipe-hierarchy.d.ts +1 -1
  450. package/dist/domain/system-components/replace-entity-recipe-hierarchy.js +1 -1
  451. package/dist/domain/system-components/replace-entity-recipes.d.ts +1 -1
  452. package/dist/domain/system-components/replace-entity-recipes.js +1 -1
  453. package/dist/domain/system-components/rotatable.js +1 -1
  454. package/dist/domain/system-components/rotation-handle.js +1 -1
  455. package/dist/domain/system-components/save-template-thumbnail.js +1 -1
  456. package/dist/domain/system-components/scene-entity-add-fab.js +1 -1
  457. package/dist/domain/system-components/scene-entity-ambient-light.js +1 -1
  458. package/dist/domain/system-components/scene-entity-animation.js +1 -1
  459. package/dist/domain/system-components/scene-entity-box-object.js +1 -1
  460. package/dist/domain/system-components/scene-entity-control.js +1 -1
  461. package/dist/domain/system-components/scene-entity-delete-fab.js +1 -1
  462. package/dist/domain/system-components/scene-entity-directional-light.js +1 -1
  463. package/dist/domain/system-components/scene-entity-floor-object.js +1 -1
  464. package/dist/domain/system-components/scene-entity-html-hotspot.js +1 -1
  465. package/dist/domain/system-components/scene-entity-local-material-override.js +1 -1
  466. package/dist/domain/system-components/scene-entity-material-override.js +1 -1
  467. package/dist/domain/system-components/scene-entity-navigation-hotspot.js +1 -1
  468. package/dist/domain/system-components/scene-entity-object-clip.js +1 -1
  469. package/dist/domain/system-components/scene-entity-object-decal.js +1 -1
  470. package/dist/domain/system-components/scene-entity-object-group.js +1 -1
  471. package/dist/domain/system-components/scene-entity-object-html-hotspot.js +1 -1
  472. package/dist/domain/system-components/scene-entity-object-local-material-override.js +1 -1
  473. package/dist/domain/system-components/scene-entity-object-material-override.js +1 -1
  474. package/dist/domain/system-components/scene-entity-object-properties.js +1 -1
  475. package/dist/domain/system-components/scene-entity-object-remote-material-override.js +1 -1
  476. package/dist/domain/system-components/scene-entity-object-text-decal.js +1 -1
  477. package/dist/domain/system-components/scene-entity-object-transformer.js +1 -1
  478. package/dist/domain/system-components/scene-entity-object-transimissive-material-override.js +1 -1
  479. package/dist/domain/system-components/scene-entity-object.js +1 -1
  480. package/dist/domain/system-components/scene-entity-point-light.js +1 -1
  481. package/dist/domain/system-components/scene-entity-properties.js +1 -1
  482. package/dist/domain/system-components/scene-entity-rect-area-light.js +1 -1
  483. package/dist/domain/system-components/scene-entity-remote-material-override.js +1 -1
  484. package/dist/domain/system-components/scene-entity-remote-object.js +1 -1
  485. package/dist/domain/system-components/scene-entity-select-hotspot.js +1 -1
  486. package/dist/domain/system-components/scene-entity-spot-light.js +1 -1
  487. package/dist/domain/system-components/scene-entity-transimissive-material-override.js +1 -1
  488. package/dist/domain/system-components/scene-entity-wall-object.js +1 -1
  489. package/dist/domain/system-components/selectable-component.js +1 -1
  490. package/dist/domain/system-components/sidebar-tabs.d.ts +1 -1
  491. package/dist/domain/system-components/sidebar-tabs.js +1 -1
  492. package/dist/domain/system-components/simple-summary.js +1 -1
  493. package/dist/domain/system-components/size.d.ts +1 -1
  494. package/dist/domain/system-components/size.js +1 -1
  495. package/dist/domain/system-components/sketching-draw.d.ts +1 -1
  496. package/dist/domain/system-components/sketching-draw.js +1 -1
  497. package/dist/domain/system-components/sketching-edit.d.ts +1 -1
  498. package/dist/domain/system-components/sketching-edit.js +1 -1
  499. package/dist/domain/system-components/sketching-line.d.ts +1 -1
  500. package/dist/domain/system-components/sketching-line.js +1 -1
  501. package/dist/domain/system-components/sketching-rectangle.d.ts +1 -1
  502. package/dist/domain/system-components/sketching-rectangle.js +1 -1
  503. package/dist/domain/system-components/sketching.d.ts +1 -1
  504. package/dist/domain/system-components/sketching.js +1 -1
  505. package/dist/domain/system-components/snap-axis.d.ts +1 -1
  506. package/dist/domain/system-components/snap-axis.js +1 -1
  507. package/dist/domain/system-components/snap-edge.d.ts +1 -1
  508. package/dist/domain/system-components/snap-edge.js +1 -1
  509. package/dist/domain/system-components/snap-plane.d.ts +1 -1
  510. package/dist/domain/system-components/snap-plane.js +1 -1
  511. package/dist/domain/system-components/snap-point.d.ts +1 -1
  512. package/dist/domain/system-components/snap-point.js +1 -1
  513. package/dist/domain/system-components/static-orthographic-camera-component.d.ts +1 -1
  514. package/dist/domain/system-components/static-orthographic-camera-component.js +1 -1
  515. package/dist/domain/system-components/static-perspective-camera-component.d.ts +1 -1
  516. package/dist/domain/system-components/static-perspective-camera-component.js +1 -1
  517. package/dist/domain/system-components/summary-component.js +1 -1
  518. package/dist/domain/system-components/text-value.js +1 -1
  519. package/dist/domain/system-components/tool-controls.js +1 -1
  520. package/dist/domain/system-components/tool-menu-fab.d.ts +1 -1
  521. package/dist/domain/system-components/tool-menu-fab.js +1 -1
  522. package/dist/domain/system-components/toolbar.d.ts +1 -1
  523. package/dist/domain/system-components/toolbar.js +1 -1
  524. package/dist/domain/system-components/universal-sidebar-footer.d.ts +1 -1
  525. package/dist/domain/system-components/universal-sidebar-footer.js +1 -1
  526. package/dist/domain/system-components/view-controls.js +1 -1
  527. package/dist/domain/utils/eval-cache.d.ts +1 -2
  528. package/dist/domain/utils/memo-eval.d.ts +1 -3
  529. package/dist/editor/Editor.js +1 -1
  530. package/dist/editor/domain-editors/use-implementation-files.d.ts +7 -6
  531. package/dist/editor/domain-editors/use-implementation-files.js +1 -1
  532. package/dist/editor/graphql/GraphQLPanel.js +1 -1
  533. package/dist/editor/variants/VariantAnswerFooter.d.ts +17 -0
  534. package/dist/editor/variants/VariantAnswerFooter.js +1 -0
  535. package/dist/editor/variants/VariantPreviewHandler.d.ts +6 -0
  536. package/dist/editor/variants/VariantPreviewHandler.js +1 -0
  537. package/dist/editor/variants/variant-preview-styles.d.ts +49 -0
  538. package/dist/editor/variants/variant-preview-styles.js +1 -0
  539. package/dist/i18n/locales/cs/messages.js +1 -1
  540. package/dist/i18n/locales/da/messages.js +1 -1
  541. package/dist/i18n/locales/de/messages.js +1 -1
  542. package/dist/i18n/locales/de-AT/messages.js +1 -1
  543. package/dist/i18n/locales/en/messages.js +1 -1
  544. package/dist/i18n/locales/en-AU/messages.js +1 -1
  545. package/dist/i18n/locales/en-GB/messages.js +1 -1
  546. package/dist/i18n/locales/es/messages.js +1 -1
  547. package/dist/i18n/locales/fr/messages.js +1 -1
  548. package/dist/i18n/locales/hu/messages.js +1 -1
  549. package/dist/i18n/locales/it/messages.js +1 -1
  550. package/dist/i18n/locales/nl/messages.js +1 -1
  551. package/dist/i18n/locales/pl/messages.js +1 -1
  552. package/dist/i18n/locales/pt/messages.js +1 -1
  553. package/dist/i18n/locales/ro/messages.js +1 -1
  554. package/dist/i18n/locales/sk/messages.js +1 -1
  555. package/dist/i18n/locales/tr/messages.js +1 -1
  556. package/dist/legacy/domain-cli/gen/configurator-builder.js +21 -8
  557. package/dist/legacy/domain-cli/utils/cache.d.ts +1 -1
  558. package/dist/legacy/domain-cli/utils/cache.js +1 -1
  559. package/dist/legacy/domain-spec/__generated/domain-schema.d.ts +6 -0
  560. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-admin.js +18 -19
  561. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-configurator.js +15 -16
  562. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-admin.js +22 -23
  563. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-configurator.js +15 -16
  564. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/generator-shared.d.ts +7 -2
  565. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/generator-shared.js +8 -12
  566. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/index.d.ts +1 -1
  567. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/index.js +1 -1
  568. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/webhook-builders.js +7 -7
  569. package/dist/phoenix/application-spec/application-spec-builder.js +1 -1
  570. package/dist/phoenix/application-spec/resolve-deployment-data.d.ts +4 -3
  571. package/dist/phoenix/application-spec/resolve-deployment-data.js +2 -2
  572. package/dist/phoenix/cli.js +1 -1
  573. package/dist/phoenix/commands/deploy.js +2 -2
  574. package/dist/phoenix/commands/dev.js +5 -5
  575. package/dist/phoenix/commands/feedback.d.ts +2 -1
  576. package/dist/phoenix/commands/feedback.js +1 -1
  577. package/dist/phoenix/commands/index.d.ts +1 -0
  578. package/dist/phoenix/commands/index.js +1 -1
  579. package/dist/phoenix/commands/prepare-deployment-command.js +2 -2
  580. package/dist/phoenix/commands/prepare-local-environment-command.js +1 -1
  581. package/dist/phoenix/commands/story-dev.js +2 -2
  582. package/dist/phoenix/commands/variants.d.ts +35 -0
  583. package/dist/phoenix/commands/variants.js +1 -0
  584. package/dist/phoenix/editor-server/commands-router.d.ts +68 -1
  585. package/dist/phoenix/editor-server/commands-router.js +1 -1
  586. package/dist/phoenix/editor-server/editor-router.d.ts +65 -0
  587. package/dist/phoenix/editor-server/editor-server.d.ts +3 -3
  588. package/dist/phoenix/editor-server/editor-server.js +1 -1
  589. package/dist/phoenix/editor-server/protocol.d.ts +1 -0
  590. package/dist/phoenix/editor-server/spec-router.js +1 -1
  591. package/dist/phoenix/editor-server/trpc.d.ts +3 -0
  592. package/dist/phoenix/scripts/build-admin.js +1 -1
  593. package/dist/phoenix/services/application-spec-project-watcher.d.ts +13 -2
  594. package/dist/phoenix/services/application-spec-project-watcher.js +3 -3
  595. package/dist/phoenix/services/index.d.ts +4 -0
  596. package/dist/phoenix/services/index.js +1 -1
  597. package/dist/phoenix/services/phoenix-application.d.ts +21 -0
  598. package/dist/phoenix/services/phoenix-application.js +1 -0
  599. package/dist/phoenix/services/phoenix-store.d.ts +48 -0
  600. package/dist/phoenix/services/phoenix-store.js +1 -0
  601. package/dist/phoenix/services/phx-variant-previews-plugin.d.ts +9 -0
  602. package/dist/phoenix/services/phx-variant-previews-plugin.js +1 -0
  603. package/dist/phoenix/services/prepare-development-environment.js +1 -1
  604. package/dist/phoenix/services/variant-file-session.d.ts +36 -0
  605. package/dist/phoenix/services/variant-file-session.js +1 -0
  606. package/dist/phoenix/services/variant-preview-service.d.ts +80 -0
  607. package/dist/phoenix/services/variant-preview-service.js +1 -0
  608. package/dist/phoenix/services/vite-config.js +1 -1
  609. package/dist/react-sdk/application-runtime/common-services/analytics/analytics-service.d.ts +2 -2
  610. package/dist/react-sdk/application-runtime/common-services/analytics/domain-controls-analytics.d.ts +21 -21
  611. package/dist/react-sdk/application-runtime/hooks/data/use-published-data.d.ts +1 -1
  612. package/dist/react-sdk/application-runtime/hooks/use-domain-application-props.d.ts +5 -2
  613. package/dist/react-sdk/application-runtime/hooks/use-spec.d.ts +1 -1
  614. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.d.ts +1 -1
  615. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.js +1 -1
  616. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +4 -4
  617. package/dist/ui-sdk/common/use-viewport-size.d.ts +4 -1
  618. package/dist/ui-sdk/common/use-viewport-size.js +1 -1
  619. package/dist/ui-sdk/components/mobile-controls/index.d.ts +1 -1
  620. package/dist/ui-sdk/theme/types.d.ts +4 -0
  621. package/dist/webhook/builders/common.d.ts +3 -0
  622. package/dist/webhook/builders/webhook-builder.d.ts +1 -1
  623. package/dist/webhook/builders/webhook-builder.js +1 -1
  624. package/package.json +5 -8
  625. package/schema/domain-spec.json +24 -0
  626. package/dist/configurator/assistant/index.d.ts +0 -1
  627. package/dist/configurator/assistant/index.js +0 -1
  628. package/dist/configurator/assistant/use-assistant-chat.d.ts +0 -20
  629. package/dist/configurator/assistant/use-assistant-chat.js +0 -1
  630. package/dist/domain/components/debug-state-component.js +0 -1
  631. package/dist/domain/components/domain-component-optic.js +0 -16
  632. package/dist/domain/components/drag-state-component.js +0 -1
  633. package/dist/domain/components/export-state-component.js +0 -1
  634. package/dist/domain/components/fullscreen-state-component.js +0 -1
  635. package/dist/domain/components/group-components-by-entity-id-and-name.js +0 -1
  636. package/dist/domain/components/hover-state-component.js +0 -1
  637. package/dist/domain/components/index.d.ts +0 -2
  638. package/dist/domain/components/index.js +0 -1
  639. package/dist/domain/components/navigation-state-component.js +0 -1
  640. package/dist/domain/components/selection-state-component.js +0 -1
  641. package/dist/domain/components/system-component-builder.js +0 -1
  642. package/dist/domain/components/system-virtual-entity.js +0 -1
  643. package/dist/domain/components/tool-state-component.js +0 -1
  644. package/dist/domain/components/view-state-component.js +0 -1
  645. package/dist/domain/components/viewport-state-component.js +0 -1
  646. package/dist/domain/core/json-schema.js +0 -1
  647. package/dist/domain/core/reflection.js +0 -1
  648. package/dist/domain/expressions/constant-expressions.js +0 -1
  649. package/dist/domain/expressions/custom-expression.js +0 -1
  650. package/dist/domain/expressions/index.d.ts +0 -1
  651. package/dist/domain/expressions/index.js +0 -1
  652. package/dist/extras/assistant/AssistantChat.d.ts +0 -6
  653. package/dist/extras/assistant/AssistantChat.js +0 -1
  654. package/dist/extras/assistant/index.d.ts +0 -1
  655. package/dist/extras/assistant/index.js +0 -1
  656. package/dist/phoenix/application-spec/generate-assistant-prompt.js +0 -1
  657. /package/dist/domain/{components/component-reader-types.js → application/assistant/assistant-manifest.js} +0 -0
  658. /package/dist/domain/{core/enhanced-json-schema.js → application/assistant/assistant-resolved-manifest.js} +0 -0
  659. /package/dist/domain/core/{expression.js → component/component-reader-types.js} +0 -0
  660. /package/dist/domain/{components → core/component}/legacy-filter.js +0 -0
  661. /package/dist/domain/{components → core/component}/system-component-filter.js +0 -0
  662. /package/dist/domain/{components → core/component}/system-virtual-entity.d.ts +0 -0
  663. /package/dist/domain/{components → core/component}/updates.js +0 -0
  664. /package/dist/domain/core/{schema-validator.js → decoder/decoder.js} +0 -0
  665. /package/dist/domain/{expressions → core/expression}/memoize-expression.js +0 -0
  666. /package/dist/domain/{expressions → core/expression}/prepare-domain-expressions.js +0 -0
  667. /package/dist/domain/core/{alias.d.ts → model/alias.d.ts} +0 -0
  668. /package/dist/domain/core/{alias.js → model/alias.js} +0 -0
  669. /package/dist/domain/core/{common-definitions.d.ts → model/common-definitions.d.ts} +0 -0
  670. /package/dist/domain/core/{common-definitions.js → model/common-definitions.js} +0 -0
  671. /package/dist/domain/core/{component.js → model/component.js} +0 -0
  672. /package/dist/domain/core/{model.d.ts → model/model.d.ts} +0 -0
  673. /package/dist/domain/core/{model.js → model/model.js} +0 -0
  674. /package/dist/domain/core/{preset.d.ts → model/preset.d.ts} +0 -0
  675. /package/dist/domain/core/{preset.js → model/preset.js} +0 -0
  676. /package/dist/domain/core/{schema-validator-ajv.d.ts → schema/create-ajv-schema-validator.d.ts} +0 -0
  677. /package/dist/domain/core/{schema-validator-ajv.js → schema/create-ajv-schema-validator.js} +0 -0
  678. /package/dist/domain/core/{schema-validator-csp.d.ts → schema/create-csp-schema-validator.d.ts} +0 -0
  679. /package/dist/domain/core/{schema-validator-csp.js → schema/create-csp-schema-validator.js} +0 -0
  680. /package/dist/domain/core/{enhanced-json-schema.d.ts → schema/enhanced-json-schema.d.ts} +0 -0
  681. /package/dist/domain/core/{json-schema.d.ts → schema/extended-schema-validator.d.ts} +0 -0
  682. /package/dist/domain/core/{schema-validator.d.ts → schema/schema-validator.d.ts} +0 -0
  683. /package/dist/domain/core/{migrations.js → state/migrations.js} +0 -0
  684. /package/dist/domain/core/{state.js → state/state.js} +0 -0
@@ -1 +1 @@
1
- import{GraphQLBoolean as e,GraphQLID as t,GraphQLInputObjectType as n,GraphQLInterfaceType as i,GraphQLList as r,GraphQLNonNull as o,GraphQLObjectType as s,GraphQLSchema as a,GraphQLString as p,getNullableType as l,isInputType as d,isNonNullType as c,printSchema as h,validateSchema as f}from"graphql";import{isArray as u}from"@salsita-ai/common/utils";import{DiagnosticCode as y,diagnosticMessages as m}from"../../../../errors/index.js";import{ASSISTANT_HINTS as g}from"../../../raw-spec/index.js";import{createSchemaRefResolver as S,isNullableSchema as T,phxDefinitionRefName as N}from"../../common/index.js";import{GraphQLJSON as w,assistantFieldType as A}from"./assistant-field-type.js";let E="AnyDomainEntity",I="RootEntity",_="RecipeGroup",O="Recipe",v="DryRun",b="DryRunError",$="FieldOption",R={section:"childRecipes",component:"childEntityRecipes",mutation:"addChild"},j={section:"replaceRecipes",component:"replaceEntityRecipes",mutation:"replaceEntity"},M=new Set(["id","type","meta"]),D=new Set(["Query","Mutation","Navigation",_,O,v,b,$,"JSON","String","Int","Float","Boolean","ID"]),C=(e,t)=>{if(!t||0===t.length)return e;let n=`One of: ${t.map(e=>`"${e}"`).join(", ")}.`;return e?/[.!?]$/.test(e)?`${e} ${n}`:`${e}. ${n}`:n},U=new Set(["id","type"]),P="The raw stored value: a string, a message descriptor or a multilingual object.",k=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],L=(e,t,{model:n,components:i})=>{let r=new Set([e,...[...n.aliases].filter(([,t])=>t.includes(e)).map(([e])=>e)]);return i.filter(({componentName:e,typeOrAlias:n})=>e===t&&r.has(n)).map(({instanceName:e})=>String(e))},W=(...e)=>g.filter(t=>e.some(e=>e?.includes(t))),F=(e,t,n,i)=>{let{model:r}=n,o=new Map,s=new Map;for(let[a,{groups:p,hints:l}]of Object.entries(e)){let e=r.entityTypes.find(e=>e===a),d=e?[e]:[...r.aliases].find(([e])=>e===a)?.[1];if(!d){i.at(a).error(y.ASSISTANT_UNKNOWN_TYPE,m.ASSISTANT_UNKNOWN_TYPE(t.section,a));continue}for(let[e,r]of(d.forEach(e=>s.set(e,W(s.get(e),l))),Object.entries(p))){let s=i.at(a,"groups",e),p=`${a}.groups.${e}`,l={groupId:r?.as??e,instanceName:e,...r?.description===void 0?{}:{description:r.description},dryRuns:r?.allowDryRuns??!0};for(let i of d){let r=L(i,t.component,n),d=o.get(i)??[],c=d.find(e=>e.group.groupId===l.groupId);r.includes(e)?c?s.error(y.ASSISTANT_DUPLICATE_RECIPE_GROUP,m.ASSISTANT_DUPLICATE_RECIPE_GROUP(t,i,l.groupId,[c.entry,p])):o.set(i,[...d,{group:l,entry:p,entryCtx:s}]):s.error(y.ASSISTANT_UNKNOWN_RECIPE_GROUP,m.ASSISTANT_UNKNOWN_RECIPE_GROUP(t,a,e,i,r))}}}let a=r.entityTypes.flatMap(e=>{let t=o.get(e);return t?[{entityType:e,groups:t}]:[]});return{groups:Object.fromEntries(a.map(({entityType:e,groups:t})=>[e,t.map(({group:e})=>e)])),hints:s,metaEntries:new Map(a.flatMap(({entityType:e,groups:[t]})=>t?[[e,t.entryCtx]]:[]))}},K=e=>`${e}Meta`,G={sameForAllInstances:e=>`All ${e} instances have the same recipe groups and recipes.`,constantDuringSession:()=>"They do not change during the session."},Y={sameForAllInstances:e=>`All ${e} instances have the same options.`,constantDuringSession:()=>"The options do not change during the session."},V=(e,t,n)=>e.map(e=>` ${t[e](n)}`).join(""),x=({section:e},{groups:t,hints:n},{entityType:i,purpose:s,recipeGroup:a})=>{let p=t.filter(({dryRuns:e})=>!e).map(({groupId:e})=>e);return 0===t.length?{}:{[e]:{type:new o(new r(new o(a))),description:`The recipe groups for ${s} this ${i}: ${t.map(({groupId:e})=>e).join(", ")}. A group is listed only while the configurator offers it on the entity.${p.length>0?` Recipes of these groups cannot be dry-run: ${p.join(", ")}.`:""}${V(n,G,i)}`}}},q=({entityType:e,childRecipes:t,replaceRecipes:n,optionsEdges:i},{recipeGroup:a,fieldOption:p})=>new s({name:K(e),fields:Object.assign(x(R,t,{entityType:e,purpose:"adding children to",recipeGroup:a}),x(j,n,{entityType:e,purpose:"replacing",recipeGroup:a}),...i.map(({options:{edgeName:t,field:n,validate:i,dryRuns:s},hints:a})=>({[t]:{type:new r(new o(p)),description:`The values "${n}" of this ${e} can take, as the configurator offers them in the current state of the entity. Null when the configurator does not offer a choice on this entity. ${i?`modify${e} rejects a "${n}" value that is not in the list.`:`modify${e} does not check "${n}" against the list.`}${s?"":" Its options cannot be dry-run."}${V(a,Y,e)}`}})))}),B=e=>Object.entries(e).map(([e,t])=>`${e} (${t.map(({groupId:e})=>e).join(", ")})`),z=e=>`${e.charAt(0).toUpperCase()+e.slice(1)}Result`,H=e=>{let t=(({anyOf:e,oneOf:t})=>[...e??[],...t??[]].filter(e=>"null"!==e.type))(e);return e.$ref||1!==t.length?e:t[0]},Q=(e,t)=>{let{type:n,enumValues:i,localized:r,description:s}=A(e,t),a=l(n),p=r||!d(a)?w:a;return{type:c(n)?new o(p):p,description:r?`${C(s,i)??""} ${P}`.trim():C(s,i)}},X=(e,t)=>{let n=(e=>{let t=H(e),n=t?.type==="array"&&t.items&&!u(t.items)?H(t.items):void 0,i=n??t;if(i?.$ref!==void 0&&"$DomainEntity"===N(i.$ref))return{target:i.references??E,list:void 0!==n}})(e);if(n)return{kind:"edge",...n,nullable:T(e,t),description:e.description};let{type:i,enumValues:r,localized:s,description:a}=A(e,t);return s?{kind:"value",type:c(i)?new o(w):w,description:`${a??""} ${P}`.trim()}:{kind:"value",type:i,description:C(a,r)}},J=(e,t)=>{let{type:n,enumValues:i,localized:r,description:o}=A(e,t);return{type:{kind:"value",type:n},localized:!0===r,description:o,enumValues:i}},Z=(e,t,n,i,r)=>{let o=t.startsWith("$")?((e,t,n,i)=>{let r=((e,t,{expressions:n,entityTypes:i})=>{let r=i.find(t=>t===e);for(let i of void 0===r?[e]:n.entityExpressions.get(r)?.shapeGroups??[]){let e=[...n.expressions.get(i)?.values()??[]].find(e=>e.name===t);if(e?.declaredSchema)return{implementation:e.implementation,declaredSchema:e.declaredSchema}}})(e.name,t,n);if(!r)return void i.error(y.ASSISTANT_UNKNOWN_FIELD,m.ASSISTANT_UNKNOWN_FIELD("entities",e.name,t));let{implementation:o}=r;if("violations"===o.kind)return void i.error(y.ASSISTANT_UNSUPPORTED_EXPRESSION,m.ASSISTANT_UNSUPPORTED_EXPRESSION(e.name,t));if("relation"===o.kind){let[{target:e,cardinality:t}]=o.params;return{type:{kind:"edge",target:e,cardinality:t},localized:!1,description:void 0}}return J(r.declaredSchema,n.resolveRef)})(e,t,i,r):((e,t,{resolveRef:n},i)=>{let r=Object.entries(e.shape.properties).find(([e])=>e===t)?.[1];return r?J(r,n):void i.error(y.ASSISTANT_UNKNOWN_FIELD,m.ASSISTANT_UNKNOWN_FIELD("entities",e.name,t))})(e,t,i,r);if(!o)return;let s=n?.as??(t.startsWith("$")?`_${t.slice(1)}`:t);return M.has(s)?void r.error(y.ASSISTANT_RESERVED_FIELD_NAME,m.ASSISTANT_RESERVED_FIELD_NAME(e.name,t,s)):{name:s,source:t,type:o.type,localized:o.localized,description:C(n?.description??o.description,o.enumValues),describedByManifest:n?.description!==void 0,enumValues:o.enumValues,valueDescription:n?.description??o.description}},ee=(e,t,n,i,r)=>{let o=new Map,s=new Set(n);for(let i of[...t.flat(),...n]){let t=o.get(i.name);t?t.source!==i.source?r.error(y.ASSISTANT_FIELD_NAME_CONFLICT,m.ASSISTANT_FIELD_NAME_CONFLICT(e,i.name,[t.source,i.source])):s.has(i)&&i.describedByManifest&&o.set(i.name,{...t,description:i.description,describedByManifest:!0,valueDescription:i.valueDescription}):o.set(i.name,i)}return[...o.values()].map(e=>{let t=e.enumValues&&i(e.source);return t?{...e,enumValues:t,description:C(e.valueDescription,t)}:e})},et=({target:e,cardinality:t},n)=>{let i=n(e);switch(t){case"1-1":return new o(i);case"0-1":return i;case"0-N":case"1-N":return new o(new r(new o(i)))}},en=(e,n,i)=>{let r={id:{type:new o(t),description:i?`Unique id of the entity, e.g. "${i}-1".`:void 0},type:{type:new o(p),description:i?`Entity type name, e.g. "${i}".`:void 0}};for(let t of e)r[t.name]={type:"edge"===t.type.kind?et(t.type,n):t.type.type,description:t.description};return r},ei=e=>Object.fromEntries(e.map(({name:e,source:t,localized:n})=>[e,n?{source:t,localized:!0}:{source:t}]));export const createAssistantSchema=(c,{model:u,states:g,phxDefinitions:T,expressions:N,components:M,actions:G},Y)=>{let V,x,H,J=Y.errors.length,et=Y.at("entities"),er=S(u.commonTypes,T),eo=u.rootEntityTypes[0]??u.entityTypes[0];for(let e of u.resolvedShapes.keys())D.has(e)&&Y.error(y.ASSISTANT_RESERVED_TYPE_NAME,m.ASSISTANT_RESERVED_TYPE_NAME(e,[...D]));let es=((e,t,n)=>{let i=new Map;for(let r of e){let e=[];for(let[i,o]of Object.entries(r.entries)){let s=Z(r,i,o,t,n.at(r.name,i));s&&e.push(s)}i.set(r.name,e)}return i})(((e,t,n)=>{let i=[];for(let[n,r]of t.resolvedShapes){let t=e[n];t&&i.push({name:n,shape:r,entries:t})}let r=new Set(t.resolvedShapes.keys());for(let t of Object.keys(e))r.has(t)||n.at(t).error(y.ASSISTANT_UNKNOWN_TYPE,m.ASSISTANT_UNKNOWN_TYPE("entities",t));return i})(c.entities??{},u,et),{resolveRef:er,expressions:N,entityTypes:u.entityTypes},et),ea=ee(E,[],es.get(E)??[],()=>void 0,Y),ep=new Map,el=F(c.childRecipes??{},R,{model:u,components:M},Y.at(R.section)),ed=F(c.replaceRecipes??{},j,{model:u,components:M},Y.at(j.section)),ec=el.groups,eh=ed.groups,ef=new Map,eu=e=>{let[t,...n]=[...u.aliases].find(([t])=>t===e)?.[1]??[];return(t&&0===n.length?ep.get(t):void 0)??eg.get(e)??em},ey=e=>ep.get(e)??eu(e),em=new i({name:E,description:"Every domain entity.",fields:()=>en(ea,ey,eo)}),eg=new Map([[E,em]]),eS=new Map([[E,ea]]);for(let e of u.aliases.keys()){if(e===E)continue;let t=ee(e,[ea],es.get(e)??[],()=>void 0,Y);eS.set(e,t),eg.set(e,new i({name:e,interfaces:[em],fields:()=>en(t,ey)}))}let eT={};for(let e of u.entityTypes){let t=[E,...[...u.aliases].filter(([t,n])=>t!==E&&n.includes(e)).map(([e])=>e)],n=[...u.resolvedShapes].find(([t])=>t===e)?.[1],i=ee(e,t.map(e=>eS.get(e)??[]),es.get(e)??[],e=>{let t=Object.entries(n?.properties??{}).find(([t])=>t===e)?.[1];return t&&A(t,er).enumValues},Y);eT[e]=ei(i),ep.set(e,new s({name:e,interfaces:t.flatMap(e=>eg.get(e)??[]),fields:()=>{let t=ef.get(e);return{...en(i,ey),...t?{meta:{type:new o(t),description:"What the configurator offers on this entity besides its fields."}}:{}}}}))}let eN=((e,t,n)=>{let i=new Set;for(let r of Object.keys(e)){let e=t.entityTypes.find(e=>e===r),o=e?[e]:[...t.aliases].find(([e])=>e===r)?.[1];o?o.forEach(e=>i.add(e)):n.at(r).error(y.ASSISTANT_UNKNOWN_TYPE,m.ASSISTANT_UNKNOWN_TYPE("deletable",r))}return t.entityTypes.filter(e=>i.has(e))})(c.deletable??{},u,Y.at("deletable")),ew=((e,t,n)=>{let{model:i}=t,r=((e,t,n)=>{let i=new Map;for(let[r,o]of Object.entries(e)){let e=t.entityTypes.find(e=>e===r),s=e?[e]:[...t.aliases].find(([e])=>e===r)?.[1],a=[...t.resolvedShapes].find(([e])=>e===r)?.[1];if(!s||!a){n.at(r).error(y.ASSISTANT_UNKNOWN_TYPE,m.ASSISTANT_UNKNOWN_TYPE("writable",r));continue}for(let e of Object.keys(o)){let t=n.at(r,e);e.startsWith("$")||U.has(e)?t.error(y.ASSISTANT_NOT_WRITABLE,m.ASSISTANT_NOT_WRITABLE(r,e)):k(a.properties,e)?s.forEach(t=>{let n=i.get(t)??new Map;i.set(t,n.has(e)?n:n.set(e,r))}):t.error(y.ASSISTANT_UNKNOWN_FIELD,m.ASSISTANT_UNKNOWN_FIELD("writable",r,e))}}return i})(e,i,n);return i.entityTypes.flatMap(e=>{let o=[...i.resolvedShapes].find(([t])=>t===e)?.[1],s=[...r.get(e)??[]].flatMap(([i,r])=>{let s=o&&k(o.properties,i);return(s&&((e,{property:t,writableKey:n},i,{resolveRef:r,exposed:o,sources:s},a)=>{let p=Object.entries(k(s,e)??{}),c=o.get(e)?.find(({source:e})=>e===t)?.name??p.find(([,{source:e}])=>e===t)?.[0],h=void 0===c?p.find(([e])=>e===t)?.[1]:void 0;if(h)return void a.at(n,t).error(y.ASSISTANT_FIELD_NAME_CONFLICT,m.ASSISTANT_FIELD_NAME_CONFLICT(e,t,[h.source,t],`${n}.${t}`));let{type:f,enumValues:u,localized:g,description:S}=A(i,r),T=l(f),N=c??t,E=void 0===c?C(S,u):void 0;return g?{name:N,property:t,type:w,description:E?`${E} ${P}`:P}:{name:N,property:t,type:d(T)?T:w,description:E}})(e,{property:i,writableKey:r},s,t,n))??[]});return s.length>0?[{entityType:e,fields:s}]:[]})})(c.writable??{},{model:u,resolveRef:er,exposed:es,sources:eT},Y.at("writable")),eA=((e,t,n,i)=>{let{model:r}=n,o=new Map;for(let[s,a]of Object.entries(e)){let e=r.entityTypes.find(e=>e===s),p=e?[e]:[...r.aliases].find(([e])=>e===s)?.[1]??[];for(let[e,r]of Object.entries(a)){let a=r?.options;if(!a)continue;let l=i.at(s,e,"options"),d=`${s}.${e}`;for(let i of p){let r=t.find(e=>e.entityType===i)?.fields.find(t=>t.property===e);if(!r)continue;let s=a.as??`${r.name}Options`,p=L(i,a.componentType,n),c=o.get(i)??[],h=c.find(e=>e.options.edgeName===s||e.options.field===r.name);if(p.includes(a.instanceName))if(s===R.section||s===j.section)l.error(y.ASSISTANT_RESERVED_OPTIONS_EDGE_NAME,m.ASSISTANT_RESERVED_OPTIONS_EDGE_NAME(d,s,r.name));else if(h)l.error(y.ASSISTANT_DUPLICATE_OPTIONS_EDGE,m.ASSISTANT_DUPLICATE_OPTIONS_EDGE(i,h.options.edgeName===s?{edgeName:s}:{field:r.name},[h.entry,d]));else{let e={field:r.name,edgeName:s,componentType:a.componentType,instanceName:a.instanceName,validate:a.validate??!0,dryRuns:a.allowDryRuns??!0};o.set(i,[...c,{options:e,hints:W(a.hints),entry:d,entryCtx:l}])}else l.error(y.ASSISTANT_UNKNOWN_OPTIONS_COMPONENT,m.ASSISTANT_UNKNOWN_OPTIONS_COMPONENT(d,a,i,p))}}}return o})(c.writable??{},ew,{model:u,components:M},Y.at("writable"));var eE,eI,e_,eO=[el.metaEntries,ed.metaEntries,new Map([...eA].flatMap(([e,[t]])=>t?[[e,t.entryCtx]]:[]))];for(let e of u.entityTypes){let t=eO.flatMap(t=>t.get(e)??[])[0],n=K(e);t&&[...u.resolvedShapes.keys()].some(e=>e===n)&&t.error(y.ASSISTANT_META_TYPE_NAME_CONFLICT,m.ASSISTANT_META_TYPE_NAME_CONFLICT(e,n))}let ev=(eE=()=>eu(eg.has(I)?I:E),eI=()=>eu(E),V=new s({name:b,description:"One reason a change cannot be made right now.",fields:{type:{type:new o(p),description:'Kind of the problem, or "uncaught".'},entityId:{type:t,description:"The entity the problem is on, when it is on one."},message:{type:p,description:"The problem as the configurator words it for the user."}}}),new s({name:v,description:"What using a recipe or writing an option would do, tried out on the configuration the query reads. Nothing is changed.",fields:()=>({ok:{type:new o(e),description:"Whether the change would succeed on the configuration the query reads."},root:{type:eE(),description:"The root entity of the configuration as it would be after the change; null when ok is false. Everything selected under it reads that configuration."},changedEntities:{type:new o(new r(new o(eI()))),description:"Every entity the change would add or modify, read from that configuration; empty when ok is false. An entity whose id the configuration does not have yet would be added, and its id may differ in the real mutation. An entity that is written to is listed even when it gets the values it already has."},deletedEntityIds:{type:new o(new r(new o(t))),description:"The ids of the entities the change would remove; empty when ok is false."},errors:{type:new o(new r(new o(V))),description:"Why the change cannot be made; empty when ok is true."}})})),eb={recipeGroup:(e_=[...Object.keys(ec).length>0?[R.mutation]:[],...Object.keys(eh).length>0?[j.mutation]:[]],x=e_.join(" or "),H=new s({name:O,description:"One recipe of a recipe group: something that can be added to the entity, or something the entity can be replaced with, depending on the edge the group is listed under.",fields:{key:{type:new o(p),description:`Identifies the recipe within its group; pass it to ${x} as recipeKey. Keys can change with the configuration and with the language, so read them from the listing rather than remembering them.`},name:{type:new o(p),description:"Name shown to the user."},description:{type:p},imageUrl:{type:p,description:"Thumbnail shown to the user."},dryRun:{type:ev,description:"Tries the recipe out. Each selected dry-run costs a full recalculation, so select it only on the recipes you are deciding between. Null for a group whose recipes cannot be dry-run."}}}),new s({name:_,description:"A group of recipes of an entity, as the configurator offers them to the user.",fields:{groupId:{type:new o(p),description:`Identifies the group on its entity; pass it to ${x} as recipeGroupId.`},name:{type:new o(p),description:"Name shown to the user."},description:{type:p},recipes:{type:new o(new r(new o(H)))}}})),fieldOption:new s({name:$,description:"One choice of a field, as the configurator offers it to the user.",fields:{value:{type:new o(w),description:"The value to write to the field."},name:{type:p,description:"Name shown to the user."},description:{type:p},imageUrl:{type:p,description:"Image shown to the user."},color:{type:p,description:'Color shown to the user, as "#rrggbb".'},dryRun:{type:ev,description:"Tries writing the value to the field. Each selected dry-run costs a full recalculation, so select it only on the options you are deciding between. Null for a field whose options cannot be dry-run."}}})};for(let e of u.entityTypes){let t=k(ec,e)??[],n=k(eh,e)??[],i=eA.get(e)??[];(t.length>0||n.length>0||i.length>0)&&ef.set(e,q({entityType:e,childRecipes:{groups:t,hints:el.hints.get(e)??[]},replaceRecipes:{groups:n,hints:ed.hints.get(e)??[]},optionsEdges:i},eb))}let e$=Object.fromEntries(u.entityTypes.flatMap(e=>{let t=eA.get(e);return t?[[e,t.map(({options:e})=>e)]]:[]})),eR=((e,{actions:t,resolveRef:n,builtInMutations:i,typeNames:r},o)=>{let s=[],a=[...t.values()].map(e=>String(e.name));for(let[p,l]of Object.entries(e)){let e=o.at(p),d=[...t.values()].find(e=>e.name===p);if(!d){e.error(y.ASSISTANT_UNKNOWN_ACTION,m.ASSISTANT_UNKNOWN_ACTION(p,a));continue}let c=l?.as??p,h=s.find(e=>e.fieldName===c),f=z(c);if(i.has(c)||h){e.error(y.ASSISTANT_MUTATION_NAME_CONFLICT,m.ASSISTANT_MUTATION_NAME_CONFLICT(p,c,h?`"assistant.actions.${h.actionName}" already exposes`:"the built-in mutation of that name already takes"));continue}if(r.has(f)||s.some(e=>z(e.fieldName)===f)){e.error(y.ASSISTANT_ACTION_RESULT_TYPE_CONFLICT,m.ASSISTANT_ACTION_RESULT_TYPE_CONFLICT(p,c,f));continue}s.push({fieldName:c,actionName:p,description:l?.description??d.description,args:Object.fromEntries(Object.entries(d.params).map(([e,{schema:t}])=>[e,Q(t,n)])),result:Object.fromEntries(Object.entries(d.result).map(([e,t])=>[e,X(t,n)]))})}return s})(c.actions??{},{actions:G,resolveRef:er,builtInMutations:new Set(["deleteEntity",R.mutation,j.mutation,...ew.map(({entityType:e})=>`modify${e}`)]),typeNames:new Set([...D,...u.resolvedShapes.keys(),...ef.keys()])},Y.at("actions"));if(Y.errors.length>J)return;let ej=((e,t)=>{let n;try{let t=e();if(n=f(t).map(e=>e.message),0===n.length)return h(t)}catch(e){n=[e instanceof Error?e.message:String(e)]}t.error(y.ASSISTANT_INVALID_SCHEMA,m.ASSISTANT_INVALID_SCHEMA(n))})(()=>{var e,i;let l;return new a({query:(e=eu(eg.has(I)?I:E),i=eu(E),l=(e=>{let t={};for(let[n,i,r]of[["navigationState","Active navigation state.",e.navigationStates],["viewState","Active view state.",e.viewStates],["toolState","Active tool state.",e.toolStates]])r.length>1&&(t[n]={type:new o(p),description:C(i,r)});if(0!==Object.keys(t).length)return new s({name:"Navigation",description:"The active UI states of the configurator.",fields:t})})(g),new s({name:"Query",fields:{root:{type:new o(e),description:"The root entity of the configuration."},entities:{type:new o(new r(i)),args:{ids:{type:new r(new o(t))}},description:`Every entity of the configuration, or, when ids are given, those entities in the same order with null for an unknown id. Ids have the form "<Type>-<number>"${eo?`, e.g. "${eo}-1"`:""}; any other id is an error.`},selectedEntity:{type:new o(i),description:"The selected entity, or the root entity when nothing is selected."},...l?{navigation:{type:new o(l)}}:{}}})),mutation:(({deletableTypes:e,writableTypes:i,childRecipes:a,replaceRecipes:l,actionFields:d,objectTypes:c,anyDomainEntity:h,targetOutputType:f})=>{let u,y;if(0!==e.length||0!==i.length||0!==Object.keys(a).length||0!==Object.keys(l).length||0!==d.length)return new s({name:"Mutation",fields:Object.assign(0===e.length?{}:{deleteEntity:{type:new o(new r(new o(t))),args:{id:{type:new o(t)}},description:`Deletes the entity with the given id, together with the entities composed into it, and returns the ids of every entity the deletion removed, the given one first. Deletable entity types: ${e.join(", ")}. Nothing can be read from removed entities afterwards, so query what you need from them before deleting.`}},0===(u=B(a)).length?{}:{addChild:{type:new o(new r(new o(h))),args:{parentId:{type:new o(t)},recipeGroupId:{type:new o(p)},recipeKey:{type:new o(p)}},description:`Adds a child to the entity with the id parentId by one recipe of one of its recipe groups. Entity types with recipe groups: ${u.join("; ")}. Read the groupId and the recipe key from "meta { childRecipes }" of the parent. Returns every entity the change added, the recipe's own first and then whatever the configurator added in response, such as a part the new child needs; the list is empty when the configurator removed them again.`}},0===(y=B(l)).length?{}:{replaceEntity:{type:new o(new r(new o(h))),args:{entityId:{type:new o(t)},recipeGroupId:{type:new o(p)},recipeKey:{type:new o(p)}},description:`Replaces the entity with the id entityId by one recipe of one of its replace recipe groups. Entity types with replace recipe groups: ${y.join("; ")}. Read the groupId and the recipe key from "meta { replaceRecipes }" of the entity. The replacement is a new entity with a new id: the id passed in no longer exists afterwards, and the replacement has the field values of its recipe, not those of the entity it replaces. Returns every entity the change added, the replacement first and then whatever the configurator added in response, such as a part the replacement needs; the list is empty when the configurator removed them again.`}},...i.flatMap(e=>{let i=c.get(e.entityType);return i?[(({entityType:e,fields:i},r)=>{let s=Object.fromEntries(i.map(({name:e,type:t,description:n})=>[e,{type:t,description:n}]));return{[`modify${e}`]:{type:r,args:{id:{type:new o(t)},delta:{type:new o(new n({name:`${e}Delta`,fields:s}))}},description:`Changes writable fields of the one ${e} with the given id: ${i.map(({name:e})=>e).join(", ")}. The delta sets only the fields it names and needs at least one; values are in stored units, as the field descriptions say. Returns the entity as it is after the change, including what the configurator adjusted in response, or null when the change caused the entity to be removed.`}}})(e,i)]:[]}),Object.fromEntries(d.map(e=>[e.fieldName,{type:new o(new s({name:z(e.fieldName),description:`What ${e.fieldName} returns, read from the configuration after the change.`,fields:()=>Object.fromEntries(Object.entries(e.result).map(([e,t])=>[e,{type:"edge"===t.kind?(({target:e,list:t,nullable:n},i)=>{let s=t?new r(new o(i(e))):i(e);return n?s:new o(s)})(t,f):t.type,description:t.description}]))})),args:e.args,description:e.description}])))})})({deletableTypes:eN,writableTypes:ew,childRecipes:ec,replaceRecipes:eh,actionFields:eR,objectTypes:ep,anyDomainEntity:eu(E),targetOutputType:ey}),types:[...eg.values(),...ep.values()]})},Y);return void 0===ej?void 0:{sdl:ej,fields:eT,deletableTypes:eN,writableFields:Object.fromEntries(ew.map(({entityType:e,fields:t})=>[e,Object.fromEntries(t.map(({name:e,property:t})=>[e,t]))])),childRecipes:ec,replaceRecipes:eh,fieldOptions:e$,actions:Object.fromEntries(eR.map(({fieldName:e,actionName:t})=>[e,t]))}};
1
+ import{isArray as e}from"@salsita-ai/common/utils";import{buildAssistantManifest as t}from"#package/domain";import{DiagnosticCode as r,diagnosticMessages as i}from"../../../../errors/index.js";import{ASSISTANT_HINTS as n}from"../../../raw-spec/index.js";import{createSchemaRefResolver as s,isNullableSchema as o,phxDefinitionRefName as a}from"../../common/index.js";import{resolveAssistantFieldType as l}from"./assistant-field-type.js";let p="AnyDomainEntity",S={section:"childRecipes",component:"childEntityRecipes",mutation:"addChild"},N={section:"replaceRecipes",component:"replaceEntityRecipes",mutation:"replaceEntity"},T=new Set(["id","type","meta"]),d=new Set(["Query","Mutation","Navigation","RecipeGroup","Recipe","DryRun","DryRunError","FieldOption","JSON","String","Int","Float","Boolean","ID"]),c=(e,t)=>{if(!t||0===t.length)return e;let r=`One of: ${t.map(e=>`"${e}"`).join(", ")}.`;return e?/[.!?]$/.test(e)?`${e} ${r}`:`${e}. ${r}`:r},f=new Set(["id","type"]),m="The raw stored value: a string, a message descriptor or a multilingual object.",A=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],u=(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))},_=(...e)=>n.filter(t=>e.some(e=>e?.includes(t))),E=(e,t,n,s)=>{let{model:o}=n,a=new Map,l=new Map;for(let[p,{groups:S,hints:N}]of Object.entries(e)){let e=o.entityTypes.find(e=>e===p),T=e?[e]:[...o.aliases].find(([e])=>e===p)?.[1];if(!T){s.at(p).error(r.ASSISTANT_UNKNOWN_TYPE,i.ASSISTANT_UNKNOWN_TYPE(t.section,p));continue}for(let[e,o]of(T.forEach(e=>l.set(e,_(l.get(e),N))),Object.entries(S))){let l=s.at(p,"groups",e),S=`${p}.groups.${e}`,N={groupId:o?.as??e,instanceName:e,...o?.description===void 0?{}:{description:o.description},dryRuns:o?.allowDryRuns??!0};for(let s of T){let o=u(s,t.component,n),T=a.get(s)??[],d=T.find(e=>e.group.groupId===N.groupId);o.includes(e)?d?l.error(r.ASSISTANT_DUPLICATE_RECIPE_GROUP,i.ASSISTANT_DUPLICATE_RECIPE_GROUP(t,s,N.groupId,[d.entry,S])):a.set(s,[...T,{group:N,entry:S,entryCtx:l}]):l.error(r.ASSISTANT_UNKNOWN_RECIPE_GROUP,i.ASSISTANT_UNKNOWN_RECIPE_GROUP(t,p,e,s,o))}}}let p=o.entityTypes.flatMap(e=>{let t=a.get(e);return t?[{entityType:e,groups:t}]:[]});return{groups:Object.fromEntries(p.map(({entityType:e,groups:t})=>[e,t.map(({group:e})=>e)])),hints:l,metaEntries:new Map(p.flatMap(({entityType:e,groups:[t]})=>t?[[e,t.entryCtx]]:[]))}},I=e=>`${e}Meta`,O=e=>`${e.charAt(0).toUpperCase()+e.slice(1)}Result`,y=e=>{let t=(({anyOf:e,oneOf:t})=>[...e??[],...t??[]].filter(e=>"null"!==e.type))(e);return e.$ref||1!==t.length?e:t[0]},h=(e,t)=>{let{type:r,enumValues:i,localized:n,description:s}=l(e,t),o={...r,nonNull:!1},a=n?`${c(s,i)??""} ${m}`.trim():c(s,i);return{type:{...n?{kind:"scalar",name:"JSON",nonNull:!1}:o,nonNull:r.nonNull},...void 0===a?{}:{description:a}}},g=(t,r)=>{let i=(t=>{let r=y(t),i=r?.type==="array"&&r.items&&!e(r.items)?y(r.items):void 0,n=i??r;if(n?.$ref!==void 0&&"$DomainEntity"===a(n.$ref))return{target:n.references??p,list:void 0!==i}})(t);if(i)return{kind:"edge",...i,nullable:o(t,r),...void 0===t.description?{}:{description:t.description}};let{type:n,enumValues:s,localized:S,description:N}=l(t,r),T=c(N,s);return S?{kind:"value",type:{kind:"scalar",name:"JSON",nonNull:n.nonNull},description:`${N??""} ${m}`.trim()}:{kind:"value",type:n,...void 0===T?{}:{description:T}}},v=(e,t)=>{let{type:r,enumValues:i,localized:n,description:s}=l(e,t);return{type:{kind:"value",type:r},localized:!0===n,description:s,enumValues:i}},R=(e,t,n,s,o)=>{let a=t.startsWith("$")?((e,t,n,s)=>{let o=((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,n);if(!o)return void s.error(r.ASSISTANT_UNKNOWN_FIELD,i.ASSISTANT_UNKNOWN_FIELD("entities",e.name,t));let{implementation:a}=o;if("violations"===a.kind)return void s.error(r.ASSISTANT_UNSUPPORTED_EXPRESSION,i.ASSISTANT_UNSUPPORTED_EXPRESSION(e.name,t));if("relation"===a.kind){let[{target:e,cardinality:t}]=a.params;return{type:{kind:"edge",target:e,cardinality:t},localized:!1,description:void 0}}return v(o.declaredSchema,n.resolveRef)})(e,t,s,o):((e,t,{resolveRef:n},s)=>{let o=Object.entries(e.shape.properties).find(([e])=>e===t)?.[1];return o?v(o,n):void s.error(r.ASSISTANT_UNKNOWN_FIELD,i.ASSISTANT_UNKNOWN_FIELD("entities",e.name,t))})(e,t,s,o);if(!a)return;let l=n?.as??(t.startsWith("$")?`_${t.slice(1)}`:t);return T.has(l)?void o.error(r.ASSISTANT_RESERVED_FIELD_NAME,i.ASSISTANT_RESERVED_FIELD_NAME(e.name,t,l)):{name:l,source:t,type:a.type,localized:a.localized,description:c(n?.description??a.description,a.enumValues),describedByManifest:n?.description!==void 0,enumValues:a.enumValues,valueDescription:n?.description??a.description}},M=(e,t,n,s,o)=>{let a=new Map,l=new Set(n);for(let s of[...t.flat(),...n]){let t=a.get(s.name);t?t.source!==s.source?o.error(r.ASSISTANT_FIELD_NAME_CONFLICT,i.ASSISTANT_FIELD_NAME_CONFLICT(e,s.name,[t.source,s.source])):l.has(s)&&s.describedByManifest&&a.set(s.name,{...t,description:s.description,describedByManifest:!0,valueDescription:s.valueDescription}):a.set(s.name,s)}return[...a.values()].map(e=>{let t=e.enumValues&&s(e.source);return t?{...e,enumValues:t,description:c(e.valueDescription,t)}:e})};export const resolveAssistantManifest=(e,{model:t,states:n,phxDefinitions:o,expressions:a,components:T,actions:y},v)=>{let b=v.errors.length,D=v.at("entities"),C=s(t.commonTypes,o);for(let e of t.resolvedShapes.keys())d.has(e)&&v.error(r.ASSISTANT_RESERVED_TYPE_NAME,i.ASSISTANT_RESERVED_TYPE_NAME(e,[...d]));let P=((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=R(n,i,s,t,r.at(n.name,i));o&&e.push(o)}i.set(n.name,e)}return i})(((e,t,n)=>{let s=[];for(let[r,i]of t.resolvedShapes){let t=e[r];t&&s.push({name:r,shape:i,entries:t})}let o=new Set(t.resolvedShapes.keys());for(let t of Object.keys(e))o.has(t)||n.at(t).error(r.ASSISTANT_UNKNOWN_TYPE,i.ASSISTANT_UNKNOWN_TYPE("entities",t));return s})(e.entities??{},t,D),{resolveRef:C,expressions:a,entityTypes:t.entityTypes},D),U=M(p,[],P.get(p)??[],()=>void 0,v),j=new Map([[p,U]]);for(let e of t.aliases.keys())e!==p&&j.set(e,M(e,[U],P.get(e)??[],()=>void 0,v));for(let e of t.entityTypes){let r=[p,...[...t.aliases].filter(([t,r])=>t!==p&&r.includes(e)).map(([e])=>e)],i=[...t.resolvedShapes].find(([t])=>t===e)?.[1];j.set(e,M(e,r.map(e=>j.get(e)??[]),P.get(e)??[],e=>{let t=Object.entries(i?.properties??{}).find(([t])=>t===e)?.[1];return t&&l(t,C).enumValues},v))}let L=Object.fromEntries(t.entityTypes.map(e=>[e,Object.fromEntries((j.get(e)??[]).map(({name:e,source:t,localized:r})=>[e,r?{source:t,localized:!0}:{source:t}]))])),$=E(e.childRecipes??{},S,{model:t,components:T},v.at("childRecipes")),w=E(e.replaceRecipes??{},N,{model:t,components:T},v.at("replaceRecipes")),W=((e,t,n)=>{let s=new Set;for(let o of Object.keys(e)){let e=t.entityTypes.find(e=>e===o),a=e?[e]:[...t.aliases].find(([e])=>e===o)?.[1];a?a.forEach(e=>s.add(e)):n.at(o).error(r.ASSISTANT_UNKNOWN_TYPE,i.ASSISTANT_UNKNOWN_TYPE("deletable",o))}return t.entityTypes.filter(e=>s.has(e))})(e.deletable??{},t,v.at("deletable")),F=((e,t,n)=>{let{model:s}=t,o=((e,t,n)=>{let s=new Map;for(let[o,a]of Object.entries(e)){let e=t.entityTypes.find(e=>e===o),l=e?[e]:[...t.aliases].find(([e])=>e===o)?.[1],p=[...t.resolvedShapes].find(([e])=>e===o)?.[1];if(!l||!p){n.at(o).error(r.ASSISTANT_UNKNOWN_TYPE,i.ASSISTANT_UNKNOWN_TYPE("writable",o));continue}for(let e of Object.keys(a)){let t=n.at(o,e);e.startsWith("$")||f.has(e)?t.error(r.ASSISTANT_NOT_WRITABLE,i.ASSISTANT_NOT_WRITABLE(o,e)):A(p.properties,e)?l.forEach(t=>{let r=s.get(t)??new Map;s.set(t,r.has(e)?r:r.set(e,o))}):t.error(r.ASSISTANT_UNKNOWN_FIELD,i.ASSISTANT_UNKNOWN_FIELD("writable",o,e))}}return s})(e,s,n);return s.entityTypes.flatMap(e=>{let a=[...s.resolvedShapes].find(([t])=>t===e)?.[1],p=[...o.get(e)??[]].flatMap(([s,o])=>{let p=a&&A(a.properties,s);return(p&&((e,{property:t,writableKey:n},s,{resolveRef:o,exposed:a,sources:p},S)=>{let N=Object.entries(A(p,e)??{}),T=a.get(e)?.find(({source:e})=>e===t)?.name??N.find(([,{source:e}])=>e===t)?.[0],d=void 0===T?N.find(([e])=>e===t)?.[1]:void 0;if(d)return void S.at(n,t).error(r.ASSISTANT_FIELD_NAME_CONFLICT,i.ASSISTANT_FIELD_NAME_CONFLICT(e,t,[d.source,t],`${n}.${t}`));let{type:f,enumValues:u,localized:_,description:E}=l(s,o),I={...f,nonNull:!1},O=T??t,y=void 0===T?c(E,u):void 0;return _?{name:O,property:t,type:{kind:"scalar",name:"JSON",nonNull:!1},description:y?`${y} ${m}`:m}:{name:O,property:t,type:I,...void 0===y?{}:{description:y}}})(e,{property:s,writableKey:o},p,t,n))??[]});return p.length>0?[{entityType:e,fields:p}]:[]})})(e.writable??{},{model:t,resolveRef:C,exposed:P,sources:L},v.at("writable")),k=((e,t,n,s)=>{let{model:o}=n,a=new Map;for(let[l,p]of Object.entries(e)){let e=o.entityTypes.find(e=>e===l),T=e?[e]:[...o.aliases].find(([e])=>e===l)?.[1]??[];for(let[e,o]of Object.entries(p)){let p=o?.options;if(!p)continue;let d=s.at(l,e,"options"),c=`${l}.${e}`;for(let s of T){let o=t.find(e=>e.entityType===s)?.fields.find(t=>t.property===e);if(!o)continue;let l=p.as??`${o.name}Options`,T=u(s,p.componentType,n),f=a.get(s)??[],m=f.find(e=>e.options.edgeName===l||e.options.field===o.name);if(T.includes(p.instanceName))if(l===S.section||l===N.section)d.error(r.ASSISTANT_RESERVED_OPTIONS_EDGE_NAME,i.ASSISTANT_RESERVED_OPTIONS_EDGE_NAME(c,l,o.name));else if(m)d.error(r.ASSISTANT_DUPLICATE_OPTIONS_EDGE,i.ASSISTANT_DUPLICATE_OPTIONS_EDGE(s,m.options.edgeName===l?{edgeName:l}:{field:o.name},[m.entry,c]));else{let e={field:o.name,edgeName:l,componentType:p.componentType,instanceName:p.instanceName,validate:p.validate??!0,dryRuns:p.allowDryRuns??!0};a.set(s,[...f,{options:e,hints:_(p.hints),entry:c,entryCtx:d}])}else d.error(r.ASSISTANT_UNKNOWN_OPTIONS_COMPONENT,i.ASSISTANT_UNKNOWN_OPTIONS_COMPONENT(c,p,s,T))}}}return a})(e.writable??{},F,{model:t,components:T},v.at("writable"));var K=[$.metaEntries,w.metaEntries,new Map([...k].flatMap(([e,[t]])=>t?[[e,t.entryCtx]]:[]))];for(let e of t.entityTypes){let n=K.flatMap(t=>t.get(e)??[])[0],s=I(e);n&&[...t.resolvedShapes.keys()].some(e=>e===s)&&n.error(r.ASSISTANT_META_TYPE_NAME_CONFLICT,i.ASSISTANT_META_TYPE_NAME_CONFLICT(e,s))}let Y=t.entityTypes.filter(e=>($.groups[e]?.length??0)>0||(w.groups[e]?.length??0)>0||(k.get(e)?.length??0)>0).map(I),V=((e,{actions:t,resolveRef:n,builtInMutations:s,typeNames:o},a)=>{let l=[],p=[...t.values()].map(e=>String(e.name));for(let[S,N]of Object.entries(e)){let e=a.at(S),T=[...t.values()].find(e=>e.name===S);if(!T){e.error(r.ASSISTANT_UNKNOWN_ACTION,i.ASSISTANT_UNKNOWN_ACTION(S,p));continue}let d=N?.as??S,c=l.find(e=>e.fieldName===d),f=O(d);if(s.has(d)||c){e.error(r.ASSISTANT_MUTATION_NAME_CONFLICT,i.ASSISTANT_MUTATION_NAME_CONFLICT(S,d,c?`"assistant.actions.${c.actionName}" already exposes`:"the built-in mutation of that name already takes"));continue}if(o.has(f)||l.some(e=>O(e.fieldName)===f)){e.error(r.ASSISTANT_ACTION_RESULT_TYPE_CONFLICT,i.ASSISTANT_ACTION_RESULT_TYPE_CONFLICT(S,d,f));continue}let m=N?.description??T.description;l.push({fieldName:d,actionName:S,...void 0===m?{}:{description:m},args:Object.fromEntries(Object.entries(T.params).map(([e,{schema:t}])=>[e,h(t,n)])),result:Object.fromEntries(Object.entries(T.result).map(([e,t])=>[e,g(t,n)]))})}return l})(e.actions??{},{actions:y,resolveRef:C,builtInMutations:new Set(["deleteEntity",S.mutation,N.mutation,...F.map(({entityType:e})=>`modify${e}`)]),typeNames:new Set([...d,...t.resolvedShapes.keys(),...Y])},v.at("actions"));if(!(v.errors.length>b))return{entityTypes:t.entityTypes,aliases:Object.fromEntries(t.aliases),exampleType:t.rootEntityTypes[0]??t.entityTypes[0],states:{navigationStates:n.navigationStates,viewStates:n.viewStates,toolStates:n.toolStates},deletableTypes:W,writableTypes:F,actionFields:V,childRecipes:Object.fromEntries(Object.entries($.groups).map(([e,t])=>[e,{groups:t,hints:$.hints.get(e)??[]}])),replaceRecipes:Object.fromEntries(Object.entries(w.groups).map(([e,t])=>[e,{groups:t,hints:w.hints.get(e)??[]}])),optionsEdges:Object.fromEntries([...k].map(([e,t])=>[e,t.map(({options:e,hints:t})=>({options:e,hints:t}))])),fields:Object.fromEntries([...j].map(([e,t])=>[e,t.map(e=>({name:e.name,source:e.source,localized:e.localized,type:e.type,...void 0===e.description?{}:{description:e.description}}))]))}};export const createAssistantSchema=(e,n,s)=>{let o=resolveAssistantManifest(e,n,s);if(o)try{return{...t(o),resolved:o}}catch(e){s.error(r.ASSISTANT_INVALID_SCHEMA,i.ASSISTANT_INVALID_SCHEMA([e instanceof Error?e.message:String(e)]));return}};
@@ -4,8 +4,8 @@ import type { MergedAssistant } from '../../../merge/index.js';
4
4
  /**
5
5
  * The part of the assistant manifest only the server reads: the integrator's instructions for the
6
6
  * assistant and the AI settings it runs with. It is kept beside `AssistantSpec`, never inside it,
7
- * because `AssistantSpec` is serialized into the application bundle and into hot reload, and these
8
- * must not reach the browser of a customer. Deployment registration uploads them. `null` when the
7
+ * because its resolved manifest is serialized into the application bundle and into hot reload, and these
8
+ * must not reach the browser of a customer. The generated webhook bundle carries them for server-side setup resolution. `null` when the
9
9
  * application declares no `assistant` section.
10
10
  */
11
11
  export type AssistantServerSettings = Branded<'AssistantServerSettings', {
@@ -1,27 +1,11 @@
1
1
  import { Branded } from '@salsita-ai/common/utils';
2
2
  import type { ParseContext } from '../../../../core/index.js';
3
3
  import type { MergedAssistant } from '../../../merge/index.js';
4
- import type { EntityTypeName } from '../../model/index.js';
5
- import { type AssistantActions, type AssistantFieldOptionsByType, type AssistantFieldSources, type AssistantRecipeGroups, type AssistantSchemaInput, type AssistantWritableFields } from './assistant-schema.js';
4
+ import { type AssistantSchema, type AssistantSchemaInput } from './assistant-schema.js';
6
5
  /**
7
- * The experimental assistant manifest with its GraphQL SDL, prepared once at parse time so the
8
- * `.phoenix` codegen, the in-browser hot-reload runtime and deployment registration all carry the
9
- * exact same schema text. `fields` maps exposed GraphQL fields back to the stored fields and
10
- * expressions the runtime resolvers read; `deletableTypes` lists the entity types `deleteEntity`
11
- * may delete; `writableFields` maps the delta fields of each `modify<Type>` mutation to the stored
12
- * properties they write; `childRecipes` and `replaceRecipes` list the recipe groups each entity type exposes; `fieldOptions` lists
13
- * the options edges of each entity type's writable fields; `actions` maps each custom `Mutation`
14
- * field to the declared action it runs. `null` when the application declares no `assistant`
15
- * section or it is invalid.
6
+ * The validated built assistant schema and its JSON-only resolved input. Parsing constructs the
7
+ * schema to retain diagnostics; code generation and hot reload carry `resolved`, while deployment
8
+ * registration consumes the built SDL and resolver metadata. Null without a valid assistant section.
16
9
  */
17
- export type AssistantSpec = Branded<'AssistantSpec', {
18
- readonly sdl: string;
19
- readonly fields: AssistantFieldSources;
20
- readonly deletableTypes: readonly EntityTypeName[];
21
- readonly writableFields: AssistantWritableFields;
22
- readonly childRecipes: AssistantRecipeGroups;
23
- readonly replaceRecipes: AssistantRecipeGroups;
24
- readonly fieldOptions: AssistantFieldOptionsByType;
25
- readonly actions: AssistantActions;
26
- }> | null;
10
+ export type AssistantSpec = Branded<'AssistantSpec', AssistantSchema> | null;
27
11
  export declare const AssistantSpec: (merged: MergedAssistant, input: AssistantSchemaInput, ctx: ParseContext) => AssistantSpec;
@@ -201,10 +201,10 @@ export interface paths {
201
201
  readonly path?: never
202
202
  readonly cookie?: never
203
203
  }
204
- /** @description Load the caller's latest assistant thread on the configuration with its active run, newest window first. The `x-assistant-thread-continuable` response header is `false` when the thread belongs to another deployment or is closed; a chat request then answers 409. */
204
+ /** @description Load the caller's latest assistant thread on the configuration with its active run, newest window first. The `x-assistant-thread-continuable` response header is `false` when the thread has a different setup or is closed; a chat request then answers 409. */
205
205
  readonly get: operations['getAssistantThread']
206
206
  readonly put?: never
207
- /** @description Run the experimental assistant on the caller's thread of the configuration, or replay the run when the request carries `Last-Event-ID`. Answers 409 when the thread cannot be continued from this deployment or another run is still answering, and 503 while the server shuts down; sent again, the message reaches another instance. Answers 403 unless the customer has the AI Assistant feature flag on. */
207
+ /** @description Run the experimental assistant on the caller's thread of the configuration, or replay the run when the request carries `Last-Event-ID`. Answers 409 when the thread cannot be continued with this setup or another run is still answering, and 503 while the server shuts down; sent again, the message reaches another instance. Answers 403 unless the customer has the AI Assistant feature flag on. */
208
208
  readonly post: operations['assistantChat']
209
209
  readonly delete?: never
210
210
  readonly options?: never
@@ -993,6 +993,12 @@ export interface paths {
993
993
  export type webhooks = Record<string, never>
994
994
  export interface components {
995
995
  schemas: {
996
+ /** @description The deployment webhook failed or returned invalid assistant setup. */
997
+ readonly BadGatewayError: {
998
+ readonly message: string
999
+ /** @enum {number} */
1000
+ readonly statusCode: 502
1001
+ }
996
1002
  /** @description Bad Request: The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
997
1003
  readonly BadRequestError: {
998
1004
  /** @example Expected integer, received string! */
@@ -2443,6 +2449,15 @@ export interface operations {
2443
2449
  readonly 'application/json': components['schemas']['NotFoundError']
2444
2450
  }
2445
2451
  }
2452
+ /** @description Bad Gateway! */
2453
+ readonly 502: {
2454
+ headers: {
2455
+ readonly [name: string]: unknown
2456
+ }
2457
+ content: {
2458
+ readonly 'application/json': components['schemas']['BadGatewayError']
2459
+ }
2460
+ }
2446
2461
  /** @description An unexpected error occurred! */
2447
2462
  readonly default: {
2448
2463
  headers: {
@@ -2527,6 +2542,15 @@ export interface operations {
2527
2542
  readonly 'application/json': components['schemas']['ConflictError']
2528
2543
  }
2529
2544
  }
2545
+ /** @description Bad Gateway! */
2546
+ readonly 502: {
2547
+ headers: {
2548
+ readonly [name: string]: unknown
2549
+ }
2550
+ content: {
2551
+ readonly 'application/json': components['schemas']['BadGatewayError']
2552
+ }
2553
+ }
2530
2554
  /** @description Service Unavailable! */
2531
2555
  readonly 503: {
2532
2556
  headers: {
@@ -5370,20 +5394,22 @@ export interface operations {
5370
5394
  readonly adminConfigurationSchema?: components['schemas']['ConfigurationSchema']
5371
5395
  /** @description Semantic version (x.y.z) of the deployed application. */
5372
5396
  readonly applicationVersion?: string
5373
- /** @description What the deployment registers for its experimental assistant: the GraphQL SDL of the application spec, the prompt the SDK generates for its version, the instructions of the integrator and the AI settings. A deployment prepared without it has no assistant. */
5374
- readonly assistant?: {
5375
- readonly ai: {
5376
- /** @enum {string} */
5377
- readonly model: 'frontier' | 'advanced' | 'balanced' | 'fast'
5378
- /** @enum {string} */
5379
- readonly provider: 'openai'
5380
- /** @enum {string} */
5381
- readonly reasoning: 'low' | 'medium' | 'high'
5382
- }
5383
- readonly instructions?: string
5384
- readonly prompt: string
5385
- readonly sdl: string
5386
- }
5397
+ /** @description Whether the deployment webhook provides assistant setup. Omitted or legacy object registrations disable the assistant; prepare with a current SDK to enable it. */
5398
+ readonly assistant?:
5399
+ | boolean
5400
+ | {
5401
+ readonly ai: {
5402
+ /** @enum {string} */
5403
+ readonly model: 'frontier' | 'advanced' | 'balanced' | 'fast'
5404
+ /** @enum {string} */
5405
+ readonly provider: 'openai'
5406
+ /** @enum {string} */
5407
+ readonly reasoning: 'low' | 'medium' | 'high'
5408
+ }
5409
+ readonly instructions?: string
5410
+ readonly prompt: string
5411
+ readonly sdl: string
5412
+ }
5387
5413
  /** @description Configuration of the chat functionality. */
5388
5414
  readonly chat?: components['schemas']['ChatConfiguration']
5389
5415
  readonly configurationSchema: components['schemas']['ConfigurationSchema']
@@ -5590,20 +5616,22 @@ export interface operations {
5590
5616
  readonly adminConfigurationSchema?: components['schemas']['ConfigurationSchema']
5591
5617
  /** @description Semantic version (x.y.z) of the deployed application. */
5592
5618
  readonly applicationVersion?: string
5593
- /** @description What the deployment registers for its experimental assistant: the GraphQL SDL of the application spec, the prompt the SDK generates for its version, the instructions of the integrator and the AI settings. A deployment prepared without it has no assistant. */
5594
- readonly assistant?: {
5595
- readonly ai: {
5596
- /** @enum {string} */
5597
- readonly model: 'frontier' | 'advanced' | 'balanced' | 'fast'
5598
- /** @enum {string} */
5599
- readonly provider: 'openai'
5600
- /** @enum {string} */
5601
- readonly reasoning: 'low' | 'medium' | 'high'
5602
- }
5603
- readonly instructions?: string
5604
- readonly prompt: string
5605
- readonly sdl: string
5606
- }
5619
+ /** @description Whether the deployment webhook provides assistant setup. Omitted or legacy object registrations disable the assistant; prepare with a current SDK to enable it. */
5620
+ readonly assistant?:
5621
+ | boolean
5622
+ | {
5623
+ readonly ai: {
5624
+ /** @enum {string} */
5625
+ readonly model: 'frontier' | 'advanced' | 'balanced' | 'fast'
5626
+ /** @enum {string} */
5627
+ readonly provider: 'openai'
5628
+ /** @enum {string} */
5629
+ readonly reasoning: 'low' | 'medium' | 'high'
5630
+ }
5631
+ readonly instructions?: string
5632
+ readonly prompt: string
5633
+ readonly sdl: string
5634
+ }
5607
5635
  /** @description Configuration of the chat functionality. */
5608
5636
  readonly chat?: components['schemas']['ChatConfiguration']
5609
5637
  readonly configurationSchema: components['schemas']['ConfigurationSchema']
@@ -1 +1 @@
1
- import{AnimationSystem as e,AssistantSystem as t,CameraControlSystem as n,CameraSystem as o,CanvasSystem as r,DragAndDropSystem as s,ExportSystem as g,GraphQLSystem as i,ImageRenderingSystem as a,LayoutSystem as m,SketchingSystem as S}from"./systems/index.js";export const createConfiguratorExtensionSelectors=y=>{let{domainContextSelectors:u,specSelectors:w,domainServicesSelectors:C,accessSelectors:c,commonServicesSelectors:f}=y,l={getConfigurationId:()=>c.getConfiguratorConfigurationId(),getAuthorizedClient:()=>f.getConfiguratorAuthorizedClient(),domainContextSelectors:u,domainServicesSelectors:C,specSelectors:w},d={getSystems:()=>G,getCanvasSystem:()=>p,getCameraControlSystem:()=>A,getAnimationSystem:()=>h,getDragAndDropSystem:()=>E,getImageRenderingSystem:()=>v,getLayoutSystem:()=>L,getSketchingSystem:()=>j,getExportSystem:()=>I,getCameraSystem:()=>k,getGraphQLSystem:()=>z,getAssistantSystem:()=>D},x={...l,configuratorExtensionSelectors:d},p=new r(l),A=new n({configuratorExtensionSelectors:d}),E=new s(x),h=new e(l),I=new g(x),z=new i(l),D=new t({configuratorExtensionSelectors:d,domainContextSelectors:u,specSelectors:w}),L=new m(l),j=new S(x),k=new o(x),v=new a(x),G={cameraControlSystem:A,layoutSystem:L,sketchingSystem:j,dragAndDropSystem:E,canvasSystem:p,cameraSystem:k,exportSystem:I,imageRenderingSystem:v,animationSystem:h,graphQLSystem:z,assistantSystem:D};return d};
1
+ import{AnimationSystem as e,AssistantSystem as t,CameraControlSystem as n,CameraSystem as o,CanvasSystem as r,DragAndDropSystem as s,ExportSystem as g,GraphQLSystem as i,ImageRenderingSystem as a,LayoutSystem as m,SketchingSystem as S}from"./systems/index.js";export const createConfiguratorExtensionSelectors=y=>{let{domainContextSelectors:u,specSelectors:w,domainServicesSelectors:C,accessSelectors:c,commonServicesSelectors:f}=y,d={getConfigurationId:()=>c.getConfiguratorConfigurationId(),getAuthorizedClient:()=>f.getConfiguratorAuthorizedClient(),domainContextSelectors:u,domainServicesSelectors:C,specSelectors:w},l={getSystems:()=>G,getCanvasSystem:()=>p,getCameraControlSystem:()=>A,getAnimationSystem:()=>E,getDragAndDropSystem:()=>h,getImageRenderingSystem:()=>v,getLayoutSystem:()=>L,getSketchingSystem:()=>j,getExportSystem:()=>I,getCameraSystem:()=>k,getGraphQLSystem:()=>z,getAssistantSystem:()=>D},x={...d,configuratorExtensionSelectors:l},p=new r(d),A=new n({configuratorExtensionSelectors:l}),h=new s(x),E=new e(d),I=new g(x),z=new i(d),D=new t(x),L=new m(d),j=new S(x),k=new o(x),v=new a(x),G={cameraControlSystem:A,layoutSystem:L,sketchingSystem:j,dragAndDropSystem:h,canvasSystem:p,cameraSystem:k,exportSystem:I,imageRenderingSystem:v,animationSystem:E,graphQLSystem:z,assistantSystem:D};return l};
@@ -1,35 +1,180 @@
1
1
  import type { AnyClientTool } from '@tanstack/ai';
2
- import type { DomainContextSelectors, InitializableSystem, SpecSelectors } from '#package/domain';
2
+ import { type UIMessage } from '@tanstack/ai-client';
3
+ import { type ObservableWithLastValue } from '@salsita-ai/common/utils';
4
+ import type { AuthorizedPhoenixApiClient } from '#package/client';
5
+ import type { DomainContextSelectors, DomainServicesSelectors, InitializableSystem, SpecSelectors } from '#package/domain';
3
6
  import type { ConfiguratorExtensionSelectors } from '../../selectors.js';
4
7
  /** A tool of the assistant that the model calls and the browser runs, as the chat client accepts it. */
5
8
  export type AssistantClientTool = AnyClientTool;
6
9
  /**
7
10
  * Constructor context of an `AssistantSystem`: whole selector objects, like its peers take them, so
8
- * the tools reach the store, the session mode and the `GraphQLSystem` when they are called.
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.
9
13
  */
10
14
  export interface AssistantSystemContext {
11
15
  readonly configuratorExtensionSelectors: ConfiguratorExtensionSelectors;
12
16
  readonly domainContextSelectors: DomainContextSelectors;
17
+ readonly domainServicesSelectors: DomainServicesSelectors;
13
18
  readonly specSelectors: SpecSelectors;
19
+ readonly getConfigurationId: () => string;
20
+ readonly getAuthorizedClient: () => AuthorizedPhoenixApiClient<any, any, any>;
14
21
  }
15
22
  /**
16
- * Owns the client tools of the conversational assistant: `getBrowserDetails`, `query` and `apply`.
17
- * They are built once, over the runtime's selectors, and offered only by a configurator whose
18
- * application spec has an `assistant` section, so a configurator without one has no tools to
19
- * register with a chat.
23
+ * The conversation with the assistant as the panel paints it. One value is published per change, so
24
+ * it changes with every chunk of a streaming reply.
25
+ */
26
+ export interface AssistantChatSnapshot {
27
+ /** The thread as painted: hydrated from the server, then streamed. */
28
+ readonly messages: ReadonlyArray<UIMessage>;
29
+ /** True while a round of a reply streams or its browser tools run; false in the pause before the next round. */
30
+ readonly isLoading: boolean;
31
+ readonly error: Error | undefined;
32
+ /**
33
+ * HTTP status of the latest request the server answered with a failure, for telling a refusal from
34
+ * a dropped connection when `error` is set. Nothing when the latest answered request succeeded or
35
+ * the server was never reached.
36
+ */
37
+ readonly failedStatus: number | undefined;
38
+ /** False when the server said this session may read the thread but not add to it. */
39
+ readonly isContinuable: boolean;
40
+ /** False until the first request of the chat, the thread read, was answered or failed. */
41
+ readonly isLoaded: boolean;
42
+ }
43
+ /**
44
+ * The built-in assistant panel as a layout and the toolbar button see it: whether it is open, and
45
+ * the few facts about it they render. It changes only when one of those does.
46
+ */
47
+ export interface AssistantPanelSnapshot {
48
+ readonly open: boolean;
49
+ /** True when a reply finished while the panel was closed and the panel was not opened since. */
50
+ readonly hasUnreadReply: boolean;
51
+ /** True while the message input has focus; a phone layout gives the panel the whole screen then. */
52
+ readonly isInputFocused: boolean;
53
+ }
54
+ /**
55
+ * Owns the conversational assistant of a configurator: its client tools (`getBrowserDetails`,
56
+ * `query` and `apply`), the chat with the server, the state of the built-in panel, and the record
57
+ * of what changed in the configuration since the agent last acted, which every user message carries.
58
+ *
59
+ * The server owns the thread, so the chat keeps nothing in browser storage: its client hydrates
60
+ * from the server and rejoins a reply that is still streaming.
61
+ *
62
+ * WORKAROUND: the runtime cannot tell a system that its configuration was left, and a system cannot
63
+ * observe the application spec. Until it can do both, the chat is started and ended from outside,
64
+ * through {@link AssistantSystem.activate}; see there for what that costs.
20
65
  */
21
66
  export declare class AssistantSystem implements InitializableSystem {
22
67
  private readonly _context;
23
68
  private readonly _tools;
24
- private _isInitialized;
69
+ private readonly _chat;
70
+ private readonly _panel;
71
+ /** Identity of the current `activate()` call; nothing while the chat is not active. */
72
+ private _activation;
73
+ /** The chat of the current activation; nothing while no chat is active. */
74
+ private _current;
75
+ /**
76
+ * Chats that have ended while their reply was still running and are finishing it in the
77
+ * background. Each leaves the set when its reply ends or when a new chat takes its thread over.
78
+ */
79
+ private readonly _finishing;
80
+ private readonly _recorder;
81
+ /** The recorder's subscription to the committed emissions of the store; made by the first `initialize()`. */
82
+ private _recording;
25
83
  constructor(_context: AssistantSystemContext);
84
+ /** The conversation. It never completes, and holds the empty chat whenever no chat is active. */
85
+ readonly chat$: ObservableWithLastValue<AssistantChatSnapshot>;
86
+ /** The state of the built-in panel. It never completes. */
87
+ readonly panel$: ObservableWithLastValue<AssistantPanelSnapshot>;
88
+ /**
89
+ * A new configuration load: the chat of the previous one is deactivated and both observables go
90
+ * back to their empty values. An activation that is still held outlives it and gets the chat of
91
+ * the new load, because the page that holds it can be mounted before this runs: a configuration
92
+ * that is entered again renders its page at once and initializes from an effect after the page's.
93
+ *
94
+ * Accepted cost: on such a re-entry the thread is read twice. The page's `activate()` has already
95
+ * created a client and started its read when this runs, and that client is replaced here, because
96
+ * the system cannot tell that it was created for the load that is only now being initialized.
97
+ *
98
+ * The change recorder starts over from the loaded state, so the first message after a load says
99
+ * that the changes are unavailable. The store is retained across loads and has already emitted the
100
+ * loaded state when this runs, so one subscription serves every load.
101
+ */
26
102
  initialize: () => void;
27
103
  /**
28
- * The tools to register with the chat: all of them when the application spec has an `assistant`
29
- * section, none otherwise or before the first initialization. The section is read on every call
30
- * and not in `initialize()`, because editor hot reload adds or removes it by reconciliation alone.
31
- * Each answer is always the same array instance, so the getter is a valid snapshot for a hook
32
- * subscribed to the runtime.
104
+ * Starts the chat of the loaded configuration: creates the client, which reads the thread from the
105
+ * server and rejoins a reply that is still running. The returned function ends it.
106
+ *
107
+ * WORKAROUND, to be replaced once the runtime has teardown and spec observation for systems. Two
108
+ * things a system cannot learn by itself are decided by the caller, the loaded configurator page:
109
+ *
110
+ * - Whether the application spec has an `assistant` section, also after editor hot reload added or
111
+ * removed it. The page calls this only while the section is there; the system does not check.
112
+ * - That the user left the configuration. No `initialize()` follows a route change, so without the
113
+ * returned function the chat would go on working on a configuration nobody looks at.
114
+ *
115
+ * Ending the chat does not cut a running reply off: it finishes in the background, where every
116
+ * tool call it still makes is answered with a refusal that tells the model to stop, and it no
117
+ * longer reaches `chat$` or `panel$`. A tool call that is already running when the chat ends is
118
+ * not interrupted, so an `apply` that has started may still commit. The background reply keeps
119
+ * the configuration and the authorized client it started with.
120
+ *
121
+ * The background reply ends early when a new chat starts for the same configuration, which is
122
+ * what opening the configuration again does: see `_takeOverThread`.
123
+ */
124
+ activate: () => (() => void);
125
+ /**
126
+ * Sends a user message with the record of what changed in the configuration since the agent last
127
+ * acted, which the server puts in front of the message for the model. The record is taken only
128
+ * when there is a chat to send it on, because taking it moves its baseline.
129
+ *
130
+ * A thread can end in a tool call that nothing will answer: its reply parked while no page was
131
+ * open, or the page that ran the tool was left before the result was sent. The client refuses to
132
+ * send while it waits on such a call, so the wait is given up first, and the server records for
133
+ * the model that the call got no result.
134
+ *
135
+ * It never rejects: a message the client could not send is reported as the error of the chat.
136
+ */
137
+ send: (content: string) => Promise<void>;
138
+ /**
139
+ * Stops the reply on both sides. Closing the stream alone keeps the server run going, because a
140
+ * closed connection is also how a reload looks and a reload must be able to rejoin the run.
141
+ */
142
+ stop: () => Promise<void>;
143
+ /**
144
+ * Loads the thread from the server again, rejoining a reply that is still running there. It never
145
+ * sends a message again, because the server may already hold it; a message that did not reach the
146
+ * server is therefore gone from the thread and has to be written again.
147
+ */
148
+ reloadThread: () => void;
149
+ setOpen: (open: boolean) => void;
150
+ setInputFocused: (isInputFocused: boolean) => void;
151
+ private _committedState;
152
+ private _patchPanel;
153
+ /**
154
+ * Disconnects every chat that is still finishing a reply on the thread of the given configuration,
155
+ * so the chat that is about to start is the only one on it.
156
+ *
157
+ * Two clients on one thread would both follow the same server run: the new one rejoins it when it
158
+ * reads the thread. Both would then handle the run's next tool call, the old one with a refusal
159
+ * and the new one for real, and both would send the result back, of which the server accepts one.
160
+ * The model could be told that nothing was run about a change that was made.
161
+ *
162
+ * Stopping a client closes its stream in the browser and cancels nothing on the server: a run that
163
+ * is still producing goes on there and the new chat rejoins it. The stopped client also drops the
164
+ * result of a tool call that is still running in it, and any continuation it has not sent yet. Such
165
+ * a call still finishes, so an `apply` may commit, but the server never gets its result: the run is
166
+ * parked on the call with nothing running for the new chat to rejoin, and the thread waits on it
167
+ * until the user's next message gives the wait up; see `send`.
168
+ *
169
+ * A chat that finishes a reply for another configuration is on another thread and is left alone.
170
+ */
171
+ private _takeOverThread;
172
+ private _startClient;
173
+ /**
174
+ * Lets go of the current chat and puts the empty chat in its place. The client itself is left as
175
+ * it is: whether it finishes its reply or is cut off is the caller's decision.
33
176
  */
34
- getTools: () => readonly AssistantClientTool[];
177
+ private _retireChat;
178
+ /** Ends the current chat without cutting its reply off. */
179
+ private _endChat;
35
180
  }
@@ -1 +1 @@
1
- import{createBrowserDetailsClientTool as t}from"./browser-details.js";import{createApplyClientTool as e,createQueryClientTool as s}from"./graphql-tools.js";let i=[];export class AssistantSystem{_context;_tools;_isInitialized=!1;constructor(i){this._context=i;let{configuratorExtensionSelectors:o,domainContextSelectors:l}=i,r={getGraphQLSystem:()=>o.getGraphQLSystem(),getStoreSystem:()=>l.getStoreSystem(),getActiveMode:()=>l.getActiveMode()};this._tools=[t(),s(r),e(r)]}initialize=()=>{this._isInitialized=!0};getTools=()=>this._isInitialized&&this._context.specSelectors.getAssistant()?this._tools:i}
1
+ import{ChatClient as t,fetchServerSentEvents as e}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{createBrowserDetailsClientTool as r}from"./browser-details.js";import{ChangeRecorder as n}from"./change-recorder.js";import{createApplyClientTool as o,createQueryClientTool as c}from"./graphql-tools.js";let l=Object.freeze({messages:Object.freeze([]),isLoading:!1,error:void 0,failedStatus:void 0,isContinuable:!0,isLoaded:!1}),h=Object.freeze({open:!1,hasUnreadReply:!1,isInputFocused:!1}),d=Object.freeze({}),g=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."}),u=t=>{if(t.getError())return!0;let e=t.getMessages().at(-1)?.parts.at(-1);return e?.type!=="tool-call"&&e?.type!=="tool-result"};export class AssistantSystem{_context;_tools;_chat=new i(l);_panel=new i(h);_activation=null;_current=null;_finishing=new Set;_recorder;_recording=null;constructor(t){this._context=t;let{configuratorExtensionSelectors:e,domainContextSelectors:i,domainServicesSelectors:s,specSelectors:a}=t;this._recorder=new n({maxEntities:30},{readers:{selectedEntityId:t=>i.getNavigationSystem().getActiveSelectionState(t),navigationState:t=>i.getNavigationSystem().getActiveNavigationState(t),viewState:t=>i.getNavigationSystem().getActiveViewState(t),toolState:t=>i.getNavigationSystem().getActiveToolState(t)},getExposedFields:()=>a.getAssistant()?.fields??d,resolveLocalizable:t=>s.getResolveLocalizable()(t)});let l={getGraphQLSystem:()=>e.getGraphQLSystem(),getStoreSystem:()=>i.getStoreSystem(),getActiveMode:()=>i.getActiveMode(),clearChanges:()=>this._recorder.clear(this._committedState())};this._tools=[r(),c(l),o(l)]}chat$=this._chat;panel$=this._panel;initialize=()=>{let{committed:t}=this._context.domainContextSelectors.getStoreSystem().stateSlices;this._recording??=t.pipe(s(1)).subscribe(this._recorder.record),this._recorder.reset(t.value.state),this._endChat(),this._patchPanel(h),this._activation&&this._startClient()};activate=()=>{this._endChat();let t={};return this._activation=t,this._startClient(),()=>{this._activation===t&&(this._activation=null,this._endChat())}};send=async t=>{let e=this._current;if(!e)return;let{client:i}=e;i.getIsLoading()||null===i.getResumeState()||i.stop();let s={changes:this._recorder.take(this._committedState())};try{await i.sendMessage({content:t,metadata:s})}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)}};stop=async()=>{let t=this._current;if(!t)return;let e=t.client.getCurrentRunId();if(t.client.stop(),null!=e)try{let i=t.getConnection();await fetch(`${i.url}/runs/${encodeURIComponent(e)}/cancel`,{method:"POST",headers:await i.headers()})}catch(t){this._context.domainServicesSelectors.getLogger().warn("Could not cancel the assistant run on the server",{error:t})}};reloadThread=()=>{if(!this._activation)return;let t=this._retireChat();t?.client.stop(),t?.dispose(),this._recorder.reset(this._committedState()),this._startClient()};setOpen=t=>{this._patchPanel(t?{open:t,hasUnreadReply:!1}:{open:t,isInputFocused:!1})};setInputFocused=t=>{this._patchPanel({isInputFocused:t})};_committedState=()=>this._context.domainContextSelectors.getStoreSystem().stateSlices.committed.value.state;_patchPanel=t=>{let e={...this._panel.value,...t};a(e,this._panel.value)||this._panel.next(e)};_takeOverThread=t=>{for(let e of this._finishing)e.configurationId===t&&(e.client.stop(),e.dispose())};_startClient=()=>{let i={active:!0},s=this._context.getConfigurationId();this._takeOverThread(s);let r=this._context.getAuthorizedClient(),n=()=>r.getAssistantChatConnection(s),o=t=>{if(!i.active)return;let e={...this._chat.value,...t};a(e,this._chat.value)||this._chat.next(e)},c=async(t,e)=>{let i=await fetch(t,e).finally(()=>o({isLoaded:!0})),s=i.headers.get("x-assistant-thread-continuable");return o({failedStatus:i.ok?void 0:i.status,...null!=s&&{isContinuable:"false"!==s}}),i},l=async()=>({headers:await n().headers(),fetchClient:c}),h=e(()=>n().url,l),d=e(()=>`${n().url}/runs`,l),_=this._tools.map(t=>({...t,execute:(e,s)=>i.active?t.execute?.(e,s):g})),m=new t({threadId:`assistant:${s}`,connection:{...h,joinRun:d.joinRun},persistence:!0,history:{pageSize:50},tools:_,onMessagesChange:t=>o({messages:t}),onLoadingChange:t=>{let e=i.active&&this._chat.value.isLoading;o({isLoading:t}),!t&&u(m)&&(i.active?e&&!this._panel.value.open&&this._patchPanel({hasUnreadReply:!0}):v())},onErrorChange:t=>{i.active&&t!==this._chat.value.error&&(o({error:t}),t&&this._context.domainServicesSelectors.getLogger().error("The assistant request failed",{status:this._chat.value.failedStatus},t))}}),p=!1,v=()=>{p||(p=!0,this._finishing.delete(S),m.dispose())},S={client:m,configurationId:s,generation:i,getConnection:n,dispose:v};this._current=S,m.attach()};_retireChat=()=>{let t=this._current;return this._current=null,t&&(t.generation.active=!1),this._chat.value!==l&&this._chat.next(l),t};_endChat=()=>{let t=this._retireChat();if(t){if(!t.client.getIsLoading()&&u(t.client))return void t.dispose();this._finishing.add(t)}}}
@@ -0,0 +1,85 @@
1
+ import type { Localizable } from '@salsita-ai/common/utils';
2
+ import { type $DomainEntity, type AssistantManifest, type DomainEntity, type DomainState, type StateEmission } from '#package/domain';
3
+ type AnyDomainEntity = DomainEntity<string>;
4
+ type AnyDomainState = DomainState<AnyDomainEntity>;
5
+ type AnyStateEmission = StateEmission<AnyDomainEntity, Record<string, $DomainEntity<AnyDomainEntity>>>;
6
+ /**
7
+ * What the change record compares besides the entities: the values the `Query` root of the
8
+ * assistant's schema exposes as `selectedEntity` and `navigation`, read off a state.
9
+ */
10
+ export interface ChangeRecorderStateReaders {
11
+ readonly selectedEntityId: (state: AnyDomainState) => string | undefined;
12
+ readonly navigationState: (state: AnyDomainState) => string | undefined;
13
+ readonly viewState: (state: AnyDomainState) => string | undefined;
14
+ readonly toolState: (state: AnyDomainState) => string | undefined;
15
+ }
16
+ /** What a {@link ChangeRecorder} reads from the running configurator. */
17
+ export interface ChangeRecorderContext {
18
+ readonly readers: ChangeRecorderStateReaders;
19
+ /**
20
+ * The field table of the assistant manifest: per entity type of the schema, each exposed field
21
+ * name with the stored field or expression it reads. The record lists nothing the table does not
22
+ * hold, so the agent is shown only what it could also query. Read at every take, because editor
23
+ * hot reload replaces the manifest.
24
+ */
25
+ readonly getExposedFields: () => AssistantManifest['fields'];
26
+ readonly resolveLocalizable: (message: Localizable) => string;
27
+ }
28
+ export interface ChangeRecorderProps {
29
+ /** More differing entities than this are counted and not listed. */
30
+ readonly maxEntities: number;
31
+ }
32
+ /**
33
+ * Records what changed in the committed configuration since the assistant agent last acted, and
34
+ * prints it as the change record a user message carries to the agent.
35
+ *
36
+ * The record is a net diff: the committed state at the last take or clear is kept as the baseline
37
+ * and compared with the current one, so a value that was changed and changed back is not listed.
38
+ * Of the emissions in between, only the last update that touched each entity and each entity field
39
+ * is kept, to say why a line is there. Selection and navigation are read off the two states and
40
+ * never from their updates.
41
+ *
42
+ * Only what the assistant manifest exposes is listed: entities of the types its schema has, and of
43
+ * their stored fields the exposed ones, under their exposed names and localized like the schema
44
+ * returns them. A change of anything else is not in the record.
45
+ */
46
+ export declare class ChangeRecorder {
47
+ private readonly _props;
48
+ private readonly _context;
49
+ private _baseline;
50
+ /** True from a reset until the first take: what happened before the baseline is not known. */
51
+ private _isUnavailable;
52
+ private readonly _touches;
53
+ private _lastReset;
54
+ private _wasUndoneOrRedone;
55
+ constructor(_props: ChangeRecorderProps, _context: ChangeRecorderContext);
56
+ /** Starts over from this committed state; the next take reports `unavailable`. */
57
+ reset: (state: AnyDomainState) => void;
58
+ /** Records one committed emission: the last update that touched each entity and field, or the reset. */
59
+ record: (emission: AnyStateEmission) => void;
60
+ /** The change record since the last take or clear, as the prompt describes it; moves the baseline. */
61
+ take: (state: AnyDomainState) => string;
62
+ /** Forgets what was recorded and makes this committed state the baseline. */
63
+ clear: (state: AnyDomainState) => void;
64
+ private _touchesOf;
65
+ private _touchFields;
66
+ private _print;
67
+ private _diffStates;
68
+ /** Added and modified entities in the order of the current state, then the deleted ones in the order they had. */
69
+ private _diffEntities;
70
+ /**
71
+ * The lines of the exposed stored fields that differ, in manifest order. A field no update
72
+ * touched since its entity was created or replaced under an id that existed before is explained
73
+ * by that creation.
74
+ */
75
+ private _diffFields;
76
+ /** Why a line is in the record; a line no recorded update explains was left by a reset. */
77
+ private _comment;
78
+ /**
79
+ * What the agent is told about an update, else what the user was told, else the update tag. As
80
+ * for `sideEffects`, an `agentHint` replaces the `hint` whatever it holds: `null` or empty text
81
+ * hides the wording from the agent, not the change, so the tag stands in.
82
+ */
83
+ private _explain;
84
+ }
85
+ export {};
@@ -0,0 +1 @@
1
+ import{match as e}from"ts-pattern";import{isUndoRedoReset as t}from"#package/domain";import{localize as i}from"../graphql-system/graphql-system.js";let s=[["selected","selectedEntityId"],["navigationState","navigationState"],["viewState","viewState"],["toolState","toolState"]],n=e=>e.length>80?`${e.slice(0,80)}…`:e,a=e=>void 0===e||""===e?"none":e,r=e=>new Map(Object.entries(e)),l=["id","type"];export class ChangeRecorder{_props;_context;_baseline;_isUnavailable=!0;_touches=new Map;_lastReset;_wasUndoneOrRedone=!1;constructor(e,t){this._props=e,this._context=t}reset=e=>{this.clear(e),this._isUnavailable=!0};record=i=>{if("reset"===i.kind){this._touches.clear(),this._lastReset=t(i)?"undo/redo":"reset",this._wasUndoneOrRedone||="undo/redo"===this._lastReset;return}for(let t of i.updates)e(t).with({kind:"createDomainEntity"},e=>{this._touchesOf(e.entityId).created=e}).with({kind:"deleteEntity"},e=>{let t=this._touchesOf(e.entityId);t.fields.clear(),t.deleted=e}).with({kind:"modifyDomainEntity"},e=>{this._touchFields(e.entityId,Object.keys(e.stateDelta),e)}).with({kind:"replaceDomainEntity"},e=>{let{replacementEntity:t}=e;this._touchesOf(e.entityId).fields.clear(),this._touchesOf(e.entityId).deleted=e,this._touchesOf(t.id).created=e}).with({kind:"createEphemeralRecord"},{kind:"modifyEphemeralRecord"},{kind:"deleteEphemeralRecord"},()=>{}).exhaustive()};take=e=>{let t=this._print(e);return this.clear(e),this._isUnavailable=!1,t};clear=e=>{this._baseline=e,this._touches.clear(),this._lastReset=void 0,this._wasUndoneOrRedone=!1};_touchesOf=e=>{let t=this._touches.get(e);if(t)return t;let i={created:void 0,deleted:void 0,fields:new Map};return this._touches.set(e,i),i};_touchFields=(e,t,i)=>{let s=this._touchesOf(e);for(let e of t)s.fields.set(e,i)};_print=e=>{let t=this._baseline;if(this._isUnavailable||!t)return"[changes: unavailable]";let{lines:i,count:s}=this._diffEntities(t,e);if(s>this._props.maxEntities)return`[changes: too many (${s})]`;let n=[...this._diffStates(t,e),...i];return 0===n.length?"[changes: none]":["[changes]",...this._wasUndoneOrRedone?["reset: undo/redo"]:[],...n].join("\n")};_diffStates=(e,t)=>s.flatMap(([i,s])=>{let n=a(this._context.readers[s](e)),r=a(this._context.readers[s](t));return n===r?[]:[`${i}: ${n} -> ${r}`]});_diffEntities=(e,t)=>{let i=this._context.getExposedFields(),s=new Map(e.entities.map(e=>[e.id,e])),n=new Set(t.entities.map(e=>e.id)),a=t.entities.flatMap(e=>{let t=i[e.type],n=s.get(e.id);if(!t)return[];if(!n)return[[`A ${e.id}${this._comment(this._touches.get(e.id)?.created)}`]];let a=n===e?[]:this._diffFields(n,e,t);return a.length>0?[[`M ${e.id}`,...a]]:[]}),r=e.entities.filter(e=>i[e.type]&&!n.has(e.id)).map(e=>[`D ${e.id}${this._comment(this._touches.get(e.id)?.deleted)}`]);return{lines:[...a,...r].flat(),count:a.length+r.length}};_diffFields=(e,t,s)=>{let a=r(e),d=r(t),o=this._touches.get(t.id);return Object.entries(s).flatMap(([e,{source:t,localized:s}])=>{if(!(!t.startsWith("$")&&!l.includes(t)))return[];let r=e=>{let t;return void 0===(t=s?i(e,this._context.resolveLocalizable):e)?"undefined":JSON.stringify(t)},h=r(a.get(t)),c=r(d.get(t));return h===c?[]:[` ${e}: ${n(h)} -> ${n(c)}${this._comment(o?.fields.get(t)??o?.created)}`]})};_comment=e=>e?` # ${this._explain(e).replace(/\s*\n\s*/g," ")}`:this._lastReset?` # ${this._lastReset}`:"";_explain=({agentHint:e,hint:t,updateTag:i})=>void 0!==e?null===e||""===e?i:e:t?this._context.resolveLocalizable(t):i}