@salsita-ai/sdk 0.50.0-develop.801a817d3f → 0.50.0-develop.97a772d197

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 (652) hide show
  1. package/README.md +1 -1
  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 +41 -13
  26. package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js +2 -2
  27. package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill.js +1 -1
  28. package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.d.ts +1 -0
  29. package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.js +6 -0
  30. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +30 -3
  31. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +19 -5
  32. package/dist/application-spec/generate-application/code/templates/webhook-builders.js +8 -4
  33. package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.d.ts +4 -3
  34. package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.js +1 -1
  35. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.d.ts +3 -8
  36. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.js +1 -1
  37. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +9 -43
  38. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
  39. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-server-settings.d.ts +2 -2
  40. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant.d.ts +5 -21
  41. package/dist/client/phoenix-api.d.ts +58 -30
  42. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +33 -7
  43. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
  44. package/dist/configurator/application-runtime/extensions/systems/assistant-system/change-recorder.d.ts +85 -0
  45. package/dist/configurator/application-runtime/extensions/systems/assistant-system/change-recorder.js +1 -0
  46. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +5 -1
  47. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -1
  48. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.js +1 -1
  49. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +6 -0
  50. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
  51. package/dist/configurator/ui/assistant/AssistantChips.js +1 -1
  52. package/dist/configurator/ui/assistant/tool-chip.d.ts +8 -1
  53. package/dist/configurator/ui/assistant/tool-chip.js +1 -1
  54. package/dist/docs/complex-use-cases/filtered-controls-with-fix-dialog.mdx +84 -98
  55. package/dist/docs/complex-use-cases/navigation-reset-selection.mdx +18 -12
  56. package/dist/docs/index.json +1 -1
  57. package/dist/docs/layouts/custom-price.mdx +14 -16
  58. package/dist/docs/layouts/sidebar/tabs.mdx +24 -21
  59. package/dist/docs/other-features/domain-actions.mdx +1 -1
  60. package/dist/docs/other-features/side-effects.mdx +50 -37
  61. package/dist/docs/other-features/transformers.mdx +1 -1
  62. package/dist/docs/phoenix/admin.mdx +9 -24
  63. package/dist/docs/phoenix/deployments.mdx +1 -1
  64. package/dist/docs/phoenix/localization.mdx +3 -22
  65. package/dist/docs/phoenix/phoenix-cli.mdx +101 -22
  66. package/dist/docs/phoenix/project-structure.mdx +9 -2
  67. package/dist/docs/phoenix/sdk-builder-workflow.mdx +10 -9
  68. package/dist/docs/recipes-and-delete/recipe-hierarchy-selection.mdx +15 -13
  69. package/dist/docs/relations/hierarchy.mdx +13 -2
  70. package/dist/domain/admin-domain/__generated/enhanced-model.d.ts +1 -2
  71. package/dist/domain/admin-domain/__generated/model/versions/v1.d.ts +1 -1
  72. package/dist/domain/admin-domain/__generated/model/versions/v2.d.ts +1 -1
  73. package/dist/domain/admin-domain/__generated/model/versions/v3.d.ts +1 -1
  74. package/dist/domain/admin-domain/__generated/model/versions/v4.d.ts +1 -1
  75. package/dist/domain/admin-domain/__generated/model/versions/v5.d.ts +1 -1
  76. package/dist/domain/admin-domain/__generated/model/versions/v6.d.ts +2 -2
  77. package/dist/domain/admin-domain/__generated/model/versions/v6.js +1 -1
  78. package/dist/domain/admin-domain/implementation/common-admin-expressions.d.ts +1 -4
  79. package/dist/domain/admin-domain/implementation/common-admin-migrations.d.ts +1 -1
  80. package/dist/domain/admin-domain/index.d.ts +3 -4
  81. package/dist/domain/admin-domain/index.js +1 -1
  82. package/dist/domain/application/admin-page-factories.d.ts +1 -1
  83. package/dist/domain/application/application-config.d.ts +25 -75
  84. package/dist/domain/application/assistant/assistant-manifest.d.ts +63 -0
  85. package/dist/domain/application/assistant/assistant-resolved-manifest.d.ts +95 -0
  86. package/dist/domain/application/assistant/assistant-value-type.d.ts +9 -0
  87. package/dist/domain/application/assistant/assistant-value-type.js +1 -0
  88. package/dist/domain/application/assistant/build-assistant-manifest.d.ts +4 -0
  89. package/dist/domain/application/assistant/build-assistant-manifest.js +1 -0
  90. package/dist/domain/application/assistant/generate-assistant-prompt.d.ts +3 -0
  91. package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -0
  92. package/dist/domain/application/assistant/index.d.ts +4 -0
  93. package/dist/domain/application/assistant/index.js +1 -0
  94. package/dist/domain/application/assistant-field-options.d.ts +2 -3
  95. package/dist/domain/application/assistant-mutations.d.ts +2 -5
  96. package/dist/domain/application/assistant-mutations.js +1 -1
  97. package/dist/domain/application/assistant-recipe-groups.d.ts +2 -6
  98. package/dist/domain/application/configurator-builder.d.ts +33 -18
  99. package/dist/domain/application/configurator-builder.js +1 -1
  100. package/dist/domain/application/element-registration.d.ts +5 -0
  101. package/dist/domain/application/element-registration.js +1 -1
  102. package/dist/domain/application/handler-registration.d.ts +5 -0
  103. package/dist/domain/application/handler-registration.js +1 -1
  104. package/dist/domain/application/index.d.ts +6 -5
  105. package/dist/domain/application/index.js +1 -1
  106. package/dist/domain/application/published-data/create-finalize-admin-domain.d.ts +1 -2
  107. package/dist/domain/application/published-data/map-published-chunked-data.d.ts +1 -1
  108. package/dist/domain/application/published-data/map-published-data.d.ts +1 -2
  109. package/dist/domain/application/resolve-imported-transformers.d.ts +12 -2
  110. package/dist/domain/application/resolve-imported-transformers.js +1 -1
  111. package/dist/domain/available-system-components.js +1 -1
  112. package/dist/domain/{actions → core/action}/action-factory.d.ts +5 -4
  113. package/dist/domain/core/{action.d.ts → action/action.d.ts} +6 -7
  114. package/dist/domain/core/action/index.d.ts +2 -0
  115. package/dist/domain/core/action/index.js +1 -0
  116. package/dist/domain/{components → core/component}/component-reader-types.d.ts +1 -2
  117. package/dist/domain/{components → core/component}/debug-state-component.d.ts +1 -1
  118. package/dist/domain/core/component/debug-state-component.js +1 -0
  119. package/dist/domain/{components → core/component}/domain-component-optic.d.ts +6 -6
  120. package/dist/domain/core/component/domain-component-optic.js +16 -0
  121. package/dist/domain/{components → core/component}/drag-state-component.d.ts +1 -1
  122. package/dist/domain/core/component/drag-state-component.js +1 -0
  123. package/dist/domain/{components → core/component}/export-state-component.d.ts +1 -1
  124. package/dist/domain/core/component/export-state-component.js +1 -0
  125. package/dist/domain/{components → core/component}/fullscreen-state-component.d.ts +1 -1
  126. package/dist/domain/core/component/fullscreen-state-component.js +1 -0
  127. package/dist/domain/{components → core/component}/group-components-by-entity-id-and-name.d.ts +1 -2
  128. package/dist/domain/core/component/group-components-by-entity-id-and-name.js +1 -0
  129. package/dist/domain/{components → core/component}/hover-state-component.d.ts +1 -1
  130. package/dist/domain/core/component/hover-state-component.js +1 -0
  131. package/dist/domain/core/component/index.d.ts +18 -0
  132. package/dist/domain/core/component/index.js +1 -0
  133. package/dist/domain/{components → core/component}/legacy-filter.d.ts +2 -2
  134. package/dist/domain/{components → core/component}/navigation-state-component.d.ts +1 -1
  135. package/dist/domain/core/component/navigation-state-component.js +1 -0
  136. package/dist/domain/{components → core/component}/selection-state-component.d.ts +1 -1
  137. package/dist/domain/core/component/selection-state-component.js +1 -0
  138. package/dist/domain/{components → core/component}/system-component-builder.d.ts +1 -2
  139. package/dist/domain/core/component/system-component-builder.js +1 -0
  140. package/dist/domain/{components → core/component}/system-component-filter.d.ts +3 -3
  141. package/dist/domain/core/component/system-virtual-entity.js +1 -0
  142. package/dist/domain/{components → core/component}/tool-state-component.d.ts +1 -1
  143. package/dist/domain/core/component/tool-state-component.js +1 -0
  144. package/dist/domain/{components → core/component}/updates.d.ts +9 -10
  145. package/dist/domain/{components → core/component}/view-state-component.d.ts +1 -1
  146. package/dist/domain/core/component/view-state-component.js +1 -0
  147. package/dist/domain/{components → core/component}/viewport-state-component.d.ts +1 -1
  148. package/dist/domain/core/component/viewport-state-component.js +1 -0
  149. package/dist/domain/core/decoder/create-decoder.d.ts +6 -0
  150. package/dist/domain/core/decoder/create-decoder.js +1 -0
  151. package/dist/domain/core/decoder/decoder.d.ts +6 -0
  152. package/dist/domain/core/decoder/index.d.ts +2 -0
  153. package/dist/domain/core/decoder/index.js +1 -0
  154. package/dist/domain/core/domain-factory.d.ts +4 -5
  155. package/dist/domain/core/domain-factory.js +1 -1
  156. package/dist/domain/core/domain.d.ts +3 -4
  157. package/dist/domain/core/domain.js +1 -1
  158. package/dist/domain/core/expression/aliased-expressions.d.ts +10 -0
  159. package/dist/domain/{expressions → core/expression}/constant-expressions.d.ts +2 -3
  160. package/dist/domain/core/expression/constant-expressions.js +1 -0
  161. package/dist/domain/{expressions → core/expression}/custom-expression.d.ts +4 -5
  162. package/dist/domain/core/expression/custom-expression.js +1 -0
  163. package/dist/domain/core/{expression.d.ts → expression/expression.d.ts} +6 -8
  164. package/dist/domain/core/expression/index.d.ts +4 -0
  165. package/dist/domain/core/expression/index.js +1 -0
  166. package/dist/domain/core/index.d.ts +11 -17
  167. package/dist/domain/core/index.js +1 -1
  168. package/dist/domain/{invariants → core/invariant}/builtin-invariant.d.ts +2 -2
  169. package/dist/domain/{invariants → core/invariant}/custom-invariants.d.ts +2 -3
  170. package/dist/domain/core/invariant/custom-invariants.js +1 -0
  171. package/dist/domain/core/invariant/index.d.ts +5 -0
  172. package/dist/domain/core/invariant/index.js +1 -0
  173. package/dist/domain/{invariants → core/invariant}/invariants.d.ts +12 -4
  174. package/dist/domain/core/invariant/invariants.js +1 -0
  175. package/dist/domain/core/invariant/violation-component.js +1 -0
  176. package/dist/domain/{invariants → core/invariant}/violation.d.ts +2 -2
  177. package/dist/domain/core/{component.d.ts → model/component.d.ts} +1 -1
  178. package/dist/domain/core/model/index.d.ts +6 -0
  179. package/dist/domain/core/model/index.js +1 -0
  180. package/dist/domain/core/{reflection.d.ts → model/reflection.d.ts} +1 -1
  181. package/dist/domain/core/model/reflection.js +1 -0
  182. package/dist/domain/core/recipe/index.d.ts +1 -0
  183. package/dist/domain/core/recipe/index.js +1 -0
  184. package/dist/domain/{domain-context/recipe-system → core/recipe}/recipes.d.ts +1 -3
  185. package/dist/domain/core/recipe/recipes.js +1 -0
  186. package/dist/domain/{relations → core/relation}/all-of-type-relation.d.ts +3 -4
  187. package/dist/domain/core/relation/all-of-type-relation.js +1 -0
  188. package/dist/domain/{relations → core/relation}/component-factories.d.ts +1 -2
  189. package/dist/domain/core/relation/component-factories.js +1 -0
  190. package/dist/domain/{relations → core/relation}/composed-of.d.ts +1 -1
  191. package/dist/domain/core/relation/composed-of.js +1 -0
  192. package/dist/domain/{relations → core/relation}/direct-relation.d.ts +2 -3
  193. package/dist/domain/core/relation/index.d.ts +9 -0
  194. package/dist/domain/core/relation/index.js +1 -0
  195. package/dist/domain/{relations → core/relation}/indirect-relation.d.ts +3 -4
  196. package/dist/domain/core/relation/indirect-relation.js +1 -0
  197. package/dist/domain/{relations → core/relation}/reference-component.d.ts +4 -5
  198. package/dist/domain/core/relation/reference-component.js +1 -0
  199. package/dist/domain/{relations → core/relation}/reference-field.d.ts +1 -1
  200. package/dist/domain/core/relation/reference-field.js +1 -0
  201. package/dist/domain/{relations → core/relation}/relation-factory.d.ts +2 -3
  202. package/dist/domain/{relations → core/relation}/relation-implementation.d.ts +3 -4
  203. package/dist/domain/core/relation/relation-implementation.js +1 -0
  204. package/dist/domain/core/schema/enhanced-json-schema.js +1 -0
  205. package/dist/domain/core/schema/extended-schema-validator.js +1 -0
  206. package/dist/domain/core/schema/index.d.ts +3 -0
  207. package/dist/domain/core/schema/index.js +1 -0
  208. package/dist/domain/core/schema/schema-validator.js +1 -0
  209. package/dist/domain/core/state/id-sequence.d.ts +15 -0
  210. package/dist/domain/core/state/id-sequence.js +1 -0
  211. package/dist/domain/core/state/index.d.ts +3 -0
  212. package/dist/domain/core/state/index.js +1 -0
  213. package/dist/domain/core/{migrations.d.ts → state/migrations.d.ts} +1 -2
  214. package/dist/domain/core/{state.d.ts → state/state.d.ts} +1 -2
  215. package/dist/domain/domain-builder.d.ts +11 -11
  216. package/dist/domain/domain-builder.js +1 -1
  217. package/dist/domain/domain-context/action-system/action-system.d.ts +1 -3
  218. package/dist/domain/domain-context/action-system/action-system.js +1 -1
  219. package/dist/domain/domain-context/create-transformer.d.ts +1 -1
  220. package/dist/domain/domain-context/dimension-system/dimension-state.js +1 -1
  221. package/dist/domain/domain-context/dimension-system/dimension-system.d.ts +1 -2
  222. package/dist/domain/domain-context/domain-context-systems.d.ts +1 -3
  223. package/dist/domain/domain-context/index.d.ts +1 -2
  224. package/dist/domain/domain-context/index.js +1 -1
  225. package/dist/domain/domain-context/navigation-system/navigation-system.d.ts +3 -5
  226. package/dist/domain/domain-context/navigation-system/navigation-system.js +1 -1
  227. package/dist/domain/domain-context/navigation-system/navigation-updates.d.ts +1 -12
  228. package/dist/domain/domain-context/navigation-system/navigation-updates.js +1 -1
  229. package/dist/domain/domain-context/navigation-system/selection-transformers.d.ts +1 -1
  230. package/dist/domain/domain-context/navigation-system/selection-transformers.js +1 -1
  231. package/dist/domain/domain-context/recipe-system/recipe-cooker-system.d.ts +1 -3
  232. package/dist/domain/domain-context/recipe-system/recipe-cooker-system.js +1 -1
  233. package/dist/domain/domain-context/relation-transformers/cascade-deletes.d.ts +1 -1
  234. package/dist/domain/domain-context/relation-transformers/cascade-deletes.js +1 -1
  235. package/dist/domain/domain-context/relation-transformers/cascade-ref-pruning.d.ts +1 -1
  236. package/dist/domain/domain-context/relation-transformers/cascade-ref-pruning.js +1 -1
  237. package/dist/domain/domain-context/relation-transformers/create-entity-refs.d.ts +1 -1
  238. package/dist/domain/domain-context/relation-transformers/create-entity-refs.js +2 -2
  239. package/dist/domain/domain-context/relation-transformers/replace-refs.d.ts +1 -1
  240. package/dist/domain/domain-context/relation-transformers/replace-refs.js +1 -1
  241. package/dist/domain/domain-context/store-system/apply-updates.d.ts +1 -3
  242. package/dist/domain/domain-context/store-system/apply-updates.js +1 -1
  243. package/dist/domain/domain-context/store-system/next-domain-entity-id.d.ts +1 -13
  244. package/dist/domain/domain-context/store-system/next-domain-entity-id.js +1 -1
  245. package/dist/domain/domain-context/store-system/reconcile-projected-entities.d.ts +1 -2
  246. package/dist/domain/domain-context/store-system/reconcile-projected-entities.js +1 -1
  247. package/dist/domain/domain-context/store-system/store-system.d.ts +1 -5
  248. package/dist/domain/domain-context/store-system/store-system.js +2 -2
  249. package/dist/domain/domain-context/store-system/system-state.d.ts +1 -3
  250. package/dist/domain/domain-context/store-system/system-state.js +1 -1
  251. package/dist/domain/domain-context/transformers/actions-builder.d.ts +1 -2
  252. package/dist/domain/domain-context/transformers/actions-builder.js +1 -1
  253. package/dist/domain/domain-context/transformers/auto-snap-transformer.d.ts +1 -3
  254. package/dist/domain/domain-context/transformers/chain-builder.d.ts +2 -2
  255. package/dist/domain/domain-context/transformers/context.d.ts +1 -5
  256. package/dist/domain/domain-context/transformers/entity-builder.d.ts +1 -5
  257. package/dist/domain/domain-context/transformers/entity-builder.js +1 -1
  258. package/dist/domain/domain-context/transformers/then-builder.d.ts +1 -2
  259. package/dist/domain/domain-context/transformers/then-builder.js +1 -1
  260. package/dist/domain/domain-context/transformers/when-builder.d.ts +1 -6
  261. package/dist/domain/domain-context/transformers/when-builder.js +1 -1
  262. package/dist/domain/domain-context/undo-system.d.ts +1 -1
  263. package/dist/domain/domain-runtime/domain-context/component-reader.d.ts +1 -4
  264. package/dist/domain/domain-runtime/domain-context/component-reader.js +1 -1
  265. package/dist/domain/domain-runtime/domain-context/selectors.d.ts +2 -4
  266. package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
  267. package/dist/domain/domain-runtime/domain-runtime.d.ts +4 -4
  268. package/dist/domain/domain-runtime/spec/index.d.ts +3 -0
  269. package/dist/domain/domain-runtime/spec/index.js +1 -1
  270. package/dist/domain/domain-runtime/spec/initialize.js +1 -1
  271. package/dist/domain/{expressions → domain-runtime/spec}/memoize-expression.d.ts +1 -2
  272. package/dist/domain/{actions → domain-runtime/spec}/prepare-action-implementations.d.ts +1 -1
  273. package/dist/domain/domain-runtime/spec/prepare-action-implementations.js +5 -0
  274. package/dist/domain/{expressions → domain-runtime/spec}/prepare-domain-expressions.d.ts +1 -1
  275. package/dist/domain/domain-runtime/spec/selectors.d.ts +2 -2
  276. package/dist/domain/domain-runtime/spec/selectors.js +1 -1
  277. package/dist/domain/domain-runtime/spec/types.d.ts +4 -5
  278. package/dist/domain/index.d.ts +2 -32
  279. package/dist/domain/index.js +1 -1
  280. package/dist/domain/mocks/create-mock-domain-runtime.d.ts +3 -3
  281. package/dist/domain/mocks/create-mock-domain-runtime.js +1 -1
  282. package/dist/domain/project-modules/index.d.ts +1 -0
  283. package/dist/domain/project-modules/index.js +1 -0
  284. package/dist/domain/project-modules/project-modules.d.ts +41 -0
  285. package/dist/domain/project-modules/project-modules.js +1 -0
  286. package/dist/domain/projections/blender-projections/blender-projections.d.ts +1 -1
  287. package/dist/domain/projections/blender-projections/blender-projections.js +1 -1
  288. package/dist/domain/projections/composition-projections.js +1 -1
  289. package/dist/domain/projections/projected-entities-projections.d.ts +1 -2
  290. package/dist/domain/projections/snap-matching.d.ts +1 -2
  291. package/dist/domain/projections/snap-utils.d.ts +1 -2
  292. package/dist/domain/projections/validation-projections.d.ts +1 -2
  293. package/dist/domain/projections/validation-projections.js +1 -1
  294. package/dist/domain/system-components/admin-sidebar.d.ts +1 -1
  295. package/dist/domain/system-components/admin-sidebar.js +1 -1
  296. package/dist/domain/system-components/angle-dimension.js +1 -1
  297. package/dist/domain/system-components/angle-indicator.d.ts +1 -1
  298. package/dist/domain/system-components/angle-indicator.js +1 -1
  299. package/dist/domain/system-components/application-config.d.ts +1 -1
  300. package/dist/domain/system-components/application-config.js +1 -1
  301. package/dist/domain/system-components/attribute-selection.js +1 -1
  302. package/dist/domain/system-components/attribute-switch.js +1 -1
  303. package/dist/domain/system-components/autorotate-camera-component.d.ts +1 -1
  304. package/dist/domain/system-components/autorotate-camera-component.js +1 -1
  305. package/dist/domain/system-components/basic-sidebar-footer.d.ts +1 -1
  306. package/dist/domain/system-components/basic-sidebar-footer.js +1 -1
  307. package/dist/domain/system-components/bounding-box-component.d.ts +1 -1
  308. package/dist/domain/system-components/bounding-box-component.js +1 -1
  309. package/dist/domain/system-components/bounding-sphere-component.d.ts +1 -1
  310. package/dist/domain/system-components/bounding-sphere-component.js +1 -1
  311. package/dist/domain/system-components/camera-based-hidden-entity-object.js +1 -1
  312. package/dist/domain/system-components/camera-based-hidden-entity.js +1 -1
  313. package/dist/domain/system-components/canvas-config.d.ts +1 -1
  314. package/dist/domain/system-components/canvas-config.js +1 -1
  315. package/dist/domain/system-components/canvas-custom-environment.js +1 -1
  316. package/dist/domain/system-components/canvas-padding.d.ts +1 -1
  317. package/dist/domain/system-components/canvas-padding.js +1 -1
  318. package/dist/domain/system-components/canvas-preset-environment.d.ts +1 -1
  319. package/dist/domain/system-components/canvas-preset-environment.js +1 -1
  320. package/dist/domain/system-components/child-entity-recipe-hierarchy.d.ts +1 -1
  321. package/dist/domain/system-components/child-entity-recipe-hierarchy.js +1 -1
  322. package/dist/domain/system-components/child-entity-recipes.d.ts +1 -1
  323. package/dist/domain/system-components/child-entity-recipes.js +1 -1
  324. package/dist/domain/system-components/child-entity-selection.d.ts +1 -2
  325. package/dist/domain/system-components/child-entity-selection.js +1 -1
  326. package/dist/domain/system-components/client-side-image.js +1 -1
  327. package/dist/domain/system-components/collision-box-geometry.d.ts +1 -1
  328. package/dist/domain/system-components/collision-box-geometry.js +1 -1
  329. package/dist/domain/system-components/collision-geometries.d.ts +1 -1
  330. package/dist/domain/system-components/collision-geometry.d.ts +1 -1
  331. package/dist/domain/system-components/collision-geometry.js +1 -1
  332. package/dist/domain/system-components/collision-point-geometry.d.ts +1 -1
  333. package/dist/domain/system-components/collision-point-geometry.js +1 -1
  334. package/dist/domain/system-components/color-value.js +1 -1
  335. package/dist/domain/system-components/common/dimension-indicator-schema.d.ts +1 -1
  336. package/dist/domain/system-components/common/dimension-indicator-schema.js +1 -1
  337. package/dist/domain/system-components/common/recipes.d.ts +1 -2
  338. package/dist/domain/system-components/constraint.d.ts +1 -1
  339. package/dist/domain/system-components/constraint.js +1 -1
  340. package/dist/domain/system-components/create-blueprint.d.ts +1 -1
  341. package/dist/domain/system-components/custom-header.d.ts +1 -1
  342. package/dist/domain/system-components/custom-header.js +1 -1
  343. package/dist/domain/system-components/custom-price-footer.js +1 -1
  344. package/dist/domain/system-components/custom-scene-entity.d.ts +1 -1
  345. package/dist/domain/system-components/custom-scene-entity.js +1 -1
  346. package/dist/domain/system-components/custom-sidebar-footer.d.ts +1 -1
  347. package/dist/domain/system-components/custom-sidebar-footer.js +1 -1
  348. package/dist/domain/system-components/detail.js +1 -1
  349. package/dist/domain/system-components/dimension-indicator.d.ts +1 -1
  350. package/dist/domain/system-components/dimension-indicator.js +1 -1
  351. package/dist/domain/system-components/distance-dimension-select.d.ts +1 -1
  352. package/dist/domain/system-components/distance-dimension-select.js +1 -1
  353. package/dist/domain/system-components/distance-dimension.d.ts +1 -1
  354. package/dist/domain/system-components/distance-dimension.js +1 -1
  355. package/dist/domain/system-components/drag-handle.d.ts +1 -1
  356. package/dist/domain/system-components/drag-handle.js +1 -1
  357. package/dist/domain/system-components/editable-angle-indicator.d.ts +1 -1
  358. package/dist/domain/system-components/editable-angle-indicator.js +1 -1
  359. package/dist/domain/system-components/editable-distance-dimension-indicator.d.ts +1 -1
  360. package/dist/domain/system-components/editable-distance-dimension-indicator.js +1 -1
  361. package/dist/domain/system-components/editable-offset-indicator.d.ts +1 -1
  362. package/dist/domain/system-components/editable-offset-indicator.js +1 -1
  363. package/dist/domain/system-components/editable-size-indicator.d.ts +1 -1
  364. package/dist/domain/system-components/editable-size-indicator.js +1 -1
  365. package/dist/domain/system-components/entity-header.js +1 -1
  366. package/dist/domain/system-components/exit-tool-mode-fab.d.ts +1 -1
  367. package/dist/domain/system-components/exit-tool-mode-fab.js +1 -1
  368. package/dist/domain/system-components/finalize-action.d.ts +1 -1
  369. package/dist/domain/system-components/finalize-action.js +1 -1
  370. package/dist/domain/system-components/finalize-component.js +1 -1
  371. package/dist/domain/system-components/fit-entity-orthographic-camera-component.js +1 -1
  372. package/dist/domain/system-components/fit-entity-perspective-camera-component.js +1 -1
  373. package/dist/domain/system-components/fit-root-orthographic-camera-component.js +1 -1
  374. package/dist/domain/system-components/fit-root-perspective-camera-component.js +1 -1
  375. package/dist/domain/system-components/fit-selection-orthographic-camera-component.js +1 -1
  376. package/dist/domain/system-components/fit-selection-perspective-camera-component.js +1 -1
  377. package/dist/domain/system-components/fixed-header.d.ts +1 -1
  378. package/dist/domain/system-components/fixed-header.js +1 -1
  379. package/dist/domain/system-components/floating-header.d.ts +1 -1
  380. package/dist/domain/system-components/floating-header.js +1 -1
  381. package/dist/domain/system-components/generic-dimension.d.ts +1 -1
  382. package/dist/domain/system-components/generic-dimension.js +1 -1
  383. package/dist/domain/system-components/hidden-entity.js +1 -1
  384. package/dist/domain/system-components/hidden-header.d.ts +1 -1
  385. package/dist/domain/system-components/hidden-header.js +1 -1
  386. package/dist/domain/system-components/hidden-sidebar-footer.d.ts +1 -1
  387. package/dist/domain/system-components/hidden-sidebar-footer.js +1 -1
  388. package/dist/domain/system-components/horizontal-tabs.d.ts +1 -1
  389. package/dist/domain/system-components/horizontal-tabs.js +1 -1
  390. package/dist/domain/system-components/hotspot-drag-handle.d.ts +1 -2
  391. package/dist/domain/system-components/hotspot-drag-handle.js +1 -1
  392. package/dist/domain/system-components/list-selector-dimension-indicator.d.ts +1 -1
  393. package/dist/domain/system-components/list-selector-dimension-indicator.js +1 -1
  394. package/dist/domain/system-components/material-override-property-transition.js +1 -1
  395. package/dist/domain/system-components/material-override-transformer.js +1 -1
  396. package/dist/domain/system-components/material-swatch.js +1 -1
  397. package/dist/domain/system-components/multilingual-text-value.js +1 -1
  398. package/dist/domain/system-components/navigation-page.js +1 -1
  399. package/dist/domain/system-components/navigation-panel-list.js +1 -1
  400. package/dist/domain/system-components/navigation-steps.js +1 -1
  401. package/dist/domain/system-components/offset-anchors.d.ts +1 -1
  402. package/dist/domain/system-components/offset-anchors.js +1 -1
  403. package/dist/domain/system-components/offset-indicator.d.ts +1 -2
  404. package/dist/domain/system-components/offset-indicator.js +1 -1
  405. package/dist/domain/system-components/offset.d.ts +1 -1
  406. package/dist/domain/system-components/offset.js +1 -1
  407. package/dist/domain/system-components/other-action.d.ts +1 -1
  408. package/dist/domain/system-components/other-action.js +1 -1
  409. package/dist/domain/system-components/pivot-point.d.ts +1 -1
  410. package/dist/domain/system-components/pivot-point.js +1 -1
  411. package/dist/domain/system-components/price.js +1 -1
  412. package/dist/domain/system-components/projected-entities.d.ts +1 -1
  413. package/dist/domain/system-components/projected-entities.js +1 -1
  414. package/dist/domain/system-components/property-page.d.ts +1 -1
  415. package/dist/domain/system-components/property-page.js +1 -1
  416. package/dist/domain/system-components/read-sidebar-footer.d.ts +1 -1
  417. package/dist/domain/system-components/read-sidebar-footer.js +1 -1
  418. package/dist/domain/system-components/replace-entity-recipe-hierarchy.d.ts +1 -1
  419. package/dist/domain/system-components/replace-entity-recipe-hierarchy.js +1 -1
  420. package/dist/domain/system-components/replace-entity-recipes.d.ts +1 -1
  421. package/dist/domain/system-components/replace-entity-recipes.js +1 -1
  422. package/dist/domain/system-components/rotatable.js +1 -1
  423. package/dist/domain/system-components/rotation-handle.js +1 -1
  424. package/dist/domain/system-components/save-template-thumbnail.js +1 -1
  425. package/dist/domain/system-components/scene-entity-add-fab.js +1 -1
  426. package/dist/domain/system-components/scene-entity-ambient-light.js +1 -1
  427. package/dist/domain/system-components/scene-entity-animation.js +1 -1
  428. package/dist/domain/system-components/scene-entity-box-object.js +1 -1
  429. package/dist/domain/system-components/scene-entity-control.js +1 -1
  430. package/dist/domain/system-components/scene-entity-delete-fab.js +1 -1
  431. package/dist/domain/system-components/scene-entity-directional-light.js +1 -1
  432. package/dist/domain/system-components/scene-entity-floor-object.js +1 -1
  433. package/dist/domain/system-components/scene-entity-html-hotspot.js +1 -1
  434. package/dist/domain/system-components/scene-entity-local-material-override.js +1 -1
  435. package/dist/domain/system-components/scene-entity-material-override.js +1 -1
  436. package/dist/domain/system-components/scene-entity-navigation-hotspot.js +1 -1
  437. package/dist/domain/system-components/scene-entity-object-clip.js +1 -1
  438. package/dist/domain/system-components/scene-entity-object-decal.js +1 -1
  439. package/dist/domain/system-components/scene-entity-object-group.js +1 -1
  440. package/dist/domain/system-components/scene-entity-object-html-hotspot.js +1 -1
  441. package/dist/domain/system-components/scene-entity-object-local-material-override.js +1 -1
  442. package/dist/domain/system-components/scene-entity-object-material-override.js +1 -1
  443. package/dist/domain/system-components/scene-entity-object-properties.js +1 -1
  444. package/dist/domain/system-components/scene-entity-object-remote-material-override.js +1 -1
  445. package/dist/domain/system-components/scene-entity-object-text-decal.js +1 -1
  446. package/dist/domain/system-components/scene-entity-object-transformer.js +1 -1
  447. package/dist/domain/system-components/scene-entity-object-transimissive-material-override.js +1 -1
  448. package/dist/domain/system-components/scene-entity-object.js +1 -1
  449. package/dist/domain/system-components/scene-entity-point-light.js +1 -1
  450. package/dist/domain/system-components/scene-entity-properties.js +1 -1
  451. package/dist/domain/system-components/scene-entity-rect-area-light.js +1 -1
  452. package/dist/domain/system-components/scene-entity-remote-material-override.js +1 -1
  453. package/dist/domain/system-components/scene-entity-remote-object.js +1 -1
  454. package/dist/domain/system-components/scene-entity-select-hotspot.js +1 -1
  455. package/dist/domain/system-components/scene-entity-spot-light.js +1 -1
  456. package/dist/domain/system-components/scene-entity-transimissive-material-override.js +1 -1
  457. package/dist/domain/system-components/scene-entity-wall-object.js +1 -1
  458. package/dist/domain/system-components/selectable-component.js +1 -1
  459. package/dist/domain/system-components/sidebar-tabs.d.ts +1 -1
  460. package/dist/domain/system-components/sidebar-tabs.js +1 -1
  461. package/dist/domain/system-components/simple-summary.js +1 -1
  462. package/dist/domain/system-components/size.d.ts +1 -1
  463. package/dist/domain/system-components/size.js +1 -1
  464. package/dist/domain/system-components/sketching-draw.d.ts +1 -1
  465. package/dist/domain/system-components/sketching-draw.js +1 -1
  466. package/dist/domain/system-components/sketching-edit.d.ts +1 -1
  467. package/dist/domain/system-components/sketching-edit.js +1 -1
  468. package/dist/domain/system-components/sketching-line.d.ts +1 -1
  469. package/dist/domain/system-components/sketching-line.js +1 -1
  470. package/dist/domain/system-components/sketching-rectangle.d.ts +1 -1
  471. package/dist/domain/system-components/sketching-rectangle.js +1 -1
  472. package/dist/domain/system-components/sketching.d.ts +1 -1
  473. package/dist/domain/system-components/sketching.js +1 -1
  474. package/dist/domain/system-components/snap-axis.d.ts +1 -1
  475. package/dist/domain/system-components/snap-axis.js +1 -1
  476. package/dist/domain/system-components/snap-edge.d.ts +1 -1
  477. package/dist/domain/system-components/snap-edge.js +1 -1
  478. package/dist/domain/system-components/snap-plane.d.ts +1 -1
  479. package/dist/domain/system-components/snap-plane.js +1 -1
  480. package/dist/domain/system-components/snap-point.d.ts +1 -1
  481. package/dist/domain/system-components/snap-point.js +1 -1
  482. package/dist/domain/system-components/static-orthographic-camera-component.d.ts +1 -1
  483. package/dist/domain/system-components/static-orthographic-camera-component.js +1 -1
  484. package/dist/domain/system-components/static-perspective-camera-component.d.ts +1 -1
  485. package/dist/domain/system-components/static-perspective-camera-component.js +1 -1
  486. package/dist/domain/system-components/summary-component.js +1 -1
  487. package/dist/domain/system-components/text-value.js +1 -1
  488. package/dist/domain/system-components/tool-controls.js +1 -1
  489. package/dist/domain/system-components/tool-menu-fab.d.ts +1 -1
  490. package/dist/domain/system-components/tool-menu-fab.js +1 -1
  491. package/dist/domain/system-components/toolbar.d.ts +1 -1
  492. package/dist/domain/system-components/toolbar.js +1 -1
  493. package/dist/domain/system-components/universal-sidebar-footer.d.ts +1 -1
  494. package/dist/domain/system-components/universal-sidebar-footer.js +1 -1
  495. package/dist/domain/system-components/view-controls.js +1 -1
  496. package/dist/domain/utils/eval-cache.d.ts +1 -2
  497. package/dist/domain/utils/memo-eval.d.ts +1 -3
  498. package/dist/editor/Editor.js +1 -1
  499. package/dist/editor/domain-editors/use-implementation-files.d.ts +7 -6
  500. package/dist/editor/domain-editors/use-implementation-files.js +1 -1
  501. package/dist/editor/variants/VariantAnswerFooter.d.ts +17 -0
  502. package/dist/editor/variants/VariantAnswerFooter.js +1 -0
  503. package/dist/editor/variants/VariantPreviewHandler.d.ts +6 -0
  504. package/dist/editor/variants/VariantPreviewHandler.js +1 -0
  505. package/dist/editor/variants/variant-preview-styles.d.ts +49 -0
  506. package/dist/editor/variants/variant-preview-styles.js +1 -0
  507. package/dist/i18n/locales/cs/messages.js +1 -1
  508. package/dist/i18n/locales/da/messages.js +1 -1
  509. package/dist/i18n/locales/de/messages.js +1 -1
  510. package/dist/i18n/locales/de-AT/messages.js +1 -1
  511. package/dist/i18n/locales/en/messages.js +1 -1
  512. package/dist/i18n/locales/en-AU/messages.js +1 -1
  513. package/dist/i18n/locales/en-GB/messages.js +1 -1
  514. package/dist/i18n/locales/es/messages.js +1 -1
  515. package/dist/i18n/locales/fr/messages.js +1 -1
  516. package/dist/i18n/locales/hu/messages.js +1 -1
  517. package/dist/i18n/locales/it/messages.js +1 -1
  518. package/dist/i18n/locales/nl/messages.js +1 -1
  519. package/dist/i18n/locales/pl/messages.js +1 -1
  520. package/dist/i18n/locales/pt/messages.js +1 -1
  521. package/dist/i18n/locales/ro/messages.js +1 -1
  522. package/dist/i18n/locales/sk/messages.js +1 -1
  523. package/dist/i18n/locales/tr/messages.js +1 -1
  524. package/dist/legacy/domain-cli/gen/configurator-builder.js +21 -8
  525. package/dist/legacy/domain-cli/utils/cache.d.ts +1 -1
  526. package/dist/legacy/domain-cli/utils/cache.js +1 -1
  527. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-admin.js +18 -19
  528. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-configurator.js +15 -16
  529. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-admin.js +22 -23
  530. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-configurator.js +15 -16
  531. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/generator-shared.d.ts +7 -2
  532. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/generator-shared.js +8 -12
  533. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/index.d.ts +1 -1
  534. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/index.js +1 -1
  535. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/webhook-builders.js +7 -7
  536. package/dist/phoenix/application-spec/application-spec-builder.js +1 -1
  537. package/dist/phoenix/application-spec/resolve-deployment-data.d.ts +4 -3
  538. package/dist/phoenix/application-spec/resolve-deployment-data.js +2 -2
  539. package/dist/phoenix/cli.js +1 -1
  540. package/dist/phoenix/commands/dev.js +5 -5
  541. package/dist/phoenix/commands/index.d.ts +1 -0
  542. package/dist/phoenix/commands/index.js +1 -1
  543. package/dist/phoenix/commands/prepare-deployment-command.js +2 -2
  544. package/dist/phoenix/commands/prepare-local-environment-command.js +1 -1
  545. package/dist/phoenix/commands/story-dev.js +2 -2
  546. package/dist/phoenix/commands/variants.d.ts +35 -0
  547. package/dist/phoenix/commands/variants.js +1 -0
  548. package/dist/phoenix/editor-server/commands-router.d.ts +68 -1
  549. package/dist/phoenix/editor-server/commands-router.js +1 -1
  550. package/dist/phoenix/editor-server/editor-router.d.ts +65 -0
  551. package/dist/phoenix/editor-server/editor-server.d.ts +3 -3
  552. package/dist/phoenix/editor-server/editor-server.js +1 -1
  553. package/dist/phoenix/editor-server/protocol.d.ts +1 -0
  554. package/dist/phoenix/editor-server/spec-router.js +1 -1
  555. package/dist/phoenix/editor-server/trpc.d.ts +3 -0
  556. package/dist/phoenix/scripts/build-admin.js +1 -1
  557. package/dist/phoenix/services/application-spec-project-watcher.d.ts +13 -2
  558. package/dist/phoenix/services/application-spec-project-watcher.js +3 -3
  559. package/dist/phoenix/services/index.d.ts +4 -0
  560. package/dist/phoenix/services/index.js +1 -1
  561. package/dist/phoenix/services/phoenix-application.d.ts +21 -0
  562. package/dist/phoenix/services/phoenix-application.js +1 -0
  563. package/dist/phoenix/services/phoenix-store.d.ts +48 -0
  564. package/dist/phoenix/services/phoenix-store.js +1 -0
  565. package/dist/phoenix/services/phx-variant-previews-plugin.d.ts +9 -0
  566. package/dist/phoenix/services/phx-variant-previews-plugin.js +1 -0
  567. package/dist/phoenix/services/prepare-development-environment.js +1 -1
  568. package/dist/phoenix/services/variant-file-session.d.ts +36 -0
  569. package/dist/phoenix/services/variant-file-session.js +1 -0
  570. package/dist/phoenix/services/variant-preview-service.d.ts +80 -0
  571. package/dist/phoenix/services/variant-preview-service.js +1 -0
  572. package/dist/phoenix/services/vite-config.js +1 -1
  573. package/dist/react-sdk/application-runtime/hooks/use-domain-application-props.d.ts +5 -2
  574. package/dist/react-sdk/application-runtime/hooks/use-spec.d.ts +1 -1
  575. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.d.ts +1 -1
  576. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.js +1 -1
  577. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +4 -4
  578. package/dist/webhook/builders/common.d.ts +3 -0
  579. package/dist/webhook/builders/webhook-builder.d.ts +1 -1
  580. package/dist/webhook/builders/webhook-builder.js +1 -1
  581. package/package.json +3 -3
  582. package/dist/domain/actions/prepare-action-implementations.js +0 -5
  583. package/dist/domain/components/debug-state-component.js +0 -1
  584. package/dist/domain/components/domain-component-optic.js +0 -16
  585. package/dist/domain/components/drag-state-component.js +0 -1
  586. package/dist/domain/components/export-state-component.js +0 -1
  587. package/dist/domain/components/fullscreen-state-component.js +0 -1
  588. package/dist/domain/components/group-components-by-entity-id-and-name.js +0 -1
  589. package/dist/domain/components/hover-state-component.js +0 -1
  590. package/dist/domain/components/index.d.ts +0 -2
  591. package/dist/domain/components/index.js +0 -1
  592. package/dist/domain/components/navigation-state-component.js +0 -1
  593. package/dist/domain/components/selection-state-component.js +0 -1
  594. package/dist/domain/components/system-component-builder.js +0 -1
  595. package/dist/domain/components/system-virtual-entity.js +0 -1
  596. package/dist/domain/components/tool-state-component.js +0 -1
  597. package/dist/domain/components/view-state-component.js +0 -1
  598. package/dist/domain/components/viewport-state-component.js +0 -1
  599. package/dist/domain/core/json-schema.js +0 -1
  600. package/dist/domain/core/reflection.js +0 -1
  601. package/dist/domain/domain-context/recipe-system/recipes.js +0 -1
  602. package/dist/domain/expressions/constant-expressions.js +0 -1
  603. package/dist/domain/expressions/custom-expression.js +0 -1
  604. package/dist/domain/expressions/index.d.ts +0 -1
  605. package/dist/domain/expressions/index.js +0 -1
  606. package/dist/domain/invariants/custom-invariants.js +0 -1
  607. package/dist/domain/invariants/invariants.js +0 -1
  608. package/dist/domain/invariants/violation-component.js +0 -1
  609. package/dist/domain/relations/all-of-type-relation.js +0 -1
  610. package/dist/domain/relations/component-factories.js +0 -1
  611. package/dist/domain/relations/composed-of.js +0 -1
  612. package/dist/domain/relations/indirect-relation.js +0 -1
  613. package/dist/domain/relations/reference-component.js +0 -1
  614. package/dist/phoenix/application-spec/generate-assistant-prompt.d.ts +0 -12
  615. package/dist/phoenix/application-spec/generate-assistant-prompt.js +0 -1
  616. /package/dist/domain/{components/component-reader-types.js → application/assistant/assistant-manifest.js} +0 -0
  617. /package/dist/domain/{core/action.js → application/assistant/assistant-resolved-manifest.js} +0 -0
  618. /package/dist/domain/{actions → core/action}/action-factory.js +0 -0
  619. /package/dist/domain/core/{enhanced-json-schema.js → action/action.js} +0 -0
  620. /package/dist/domain/core/{expression.js → component/component-reader-types.js} +0 -0
  621. /package/dist/domain/{components → core/component}/legacy-filter.js +0 -0
  622. /package/dist/domain/{components → core/component}/system-component-filter.js +0 -0
  623. /package/dist/domain/{components → core/component}/system-virtual-entity.d.ts +0 -0
  624. /package/dist/domain/{components → core/component}/updates.js +0 -0
  625. /package/dist/domain/core/{schema-validator.js → decoder/decoder.js} +0 -0
  626. /package/dist/domain/{relations/reference-field.js → core/expression/aliased-expressions.js} +0 -0
  627. /package/dist/domain/{relations/relation-implementation.js → core/expression/expression.js} +0 -0
  628. /package/dist/domain/{invariants → core/invariant}/builtin-invariant.js +0 -0
  629. /package/dist/domain/{invariants → core/invariant}/violation-component.d.ts +0 -0
  630. /package/dist/domain/{invariants → core/invariant}/violation.js +0 -0
  631. /package/dist/domain/core/{alias.d.ts → model/alias.d.ts} +0 -0
  632. /package/dist/domain/core/{alias.js → model/alias.js} +0 -0
  633. /package/dist/domain/core/{common-definitions.d.ts → model/common-definitions.d.ts} +0 -0
  634. /package/dist/domain/core/{common-definitions.js → model/common-definitions.js} +0 -0
  635. /package/dist/domain/core/{component.js → model/component.js} +0 -0
  636. /package/dist/domain/core/{model.d.ts → model/model.d.ts} +0 -0
  637. /package/dist/domain/core/{model.js → model/model.js} +0 -0
  638. /package/dist/domain/core/{preset.d.ts → model/preset.d.ts} +0 -0
  639. /package/dist/domain/core/{preset.js → model/preset.js} +0 -0
  640. /package/dist/domain/{relations → core/relation}/direct-relation.js +0 -0
  641. /package/dist/domain/{relations → core/relation}/relation-factory.js +0 -0
  642. /package/dist/domain/core/{schema-validator-ajv.d.ts → schema/create-ajv-schema-validator.d.ts} +0 -0
  643. /package/dist/domain/core/{schema-validator-ajv.js → schema/create-ajv-schema-validator.js} +0 -0
  644. /package/dist/domain/core/{schema-validator-csp.d.ts → schema/create-csp-schema-validator.d.ts} +0 -0
  645. /package/dist/domain/core/{schema-validator-csp.js → schema/create-csp-schema-validator.js} +0 -0
  646. /package/dist/domain/core/{enhanced-json-schema.d.ts → schema/enhanced-json-schema.d.ts} +0 -0
  647. /package/dist/domain/core/{json-schema.d.ts → schema/extended-schema-validator.d.ts} +0 -0
  648. /package/dist/domain/core/{schema-validator.d.ts → schema/schema-validator.d.ts} +0 -0
  649. /package/dist/domain/core/{migrations.js → state/migrations.js} +0 -0
  650. /package/dist/domain/core/{state.js → state/state.js} +0 -0
  651. /package/dist/domain/{expressions → domain-runtime/spec}/memoize-expression.js +0 -0
  652. /package/dist/domain/{expressions → domain-runtime/spec}/prepare-domain-expressions.js +0 -0
@@ -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']
@@ -2,7 +2,7 @@ import type { AnyClientTool } from '@tanstack/ai';
2
2
  import { type UIMessage } from '@tanstack/ai-client';
3
3
  import { type ObservableWithLastValue } from '@salsita-ai/common/utils';
4
4
  import type { AuthorizedPhoenixApiClient } from '#package/client';
5
- import type { DomainContextSelectors, DomainServicesSelectors, InitializableSystem } from '#package/domain';
5
+ import type { DomainContextSelectors, DomainServicesSelectors, InitializableSystem, SpecSelectors } from '#package/domain';
6
6
  import type { ConfiguratorExtensionSelectors } from '../../selectors.js';
7
7
  /** A tool of the assistant that the model calls and the browser runs, as the chat client accepts it. */
8
8
  export type AssistantClientTool = AnyClientTool;
@@ -15,6 +15,7 @@ export interface AssistantSystemContext {
15
15
  readonly configuratorExtensionSelectors: ConfiguratorExtensionSelectors;
16
16
  readonly domainContextSelectors: DomainContextSelectors;
17
17
  readonly domainServicesSelectors: DomainServicesSelectors;
18
+ readonly specSelectors: SpecSelectors;
18
19
  readonly getConfigurationId: () => string;
19
20
  readonly getAuthorizedClient: () => AuthorizedPhoenixApiClient<any, any, any>;
20
21
  }
@@ -52,7 +53,8 @@ export interface AssistantPanelSnapshot {
52
53
  }
53
54
  /**
54
55
  * Owns the conversational assistant of a configurator: its client tools (`getBrowserDetails`,
55
- * `query` and `apply`), the chat with the server, and the state of the built-in panel.
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.
56
58
  *
57
59
  * The server owns the thread, so the chat keeps nothing in browser storage: its client hydrates
58
60
  * from the server and rejoins a reply that is still streaming.
@@ -75,6 +77,9 @@ export declare class AssistantSystem implements InitializableSystem {
75
77
  * background. Each leaves the set when its reply ends or when a new chat takes its thread over.
76
78
  */
77
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;
78
83
  constructor(_context: AssistantSystemContext);
79
84
  /** The conversation. It never completes, and holds the empty chat whenever no chat is active. */
80
85
  readonly chat$: ObservableWithLastValue<AssistantChatSnapshot>;
@@ -89,6 +94,10 @@ export declare class AssistantSystem implements InitializableSystem {
89
94
  * Accepted cost: on such a re-entry the thread is read twice. The page's `activate()` has already
90
95
  * created a client and started its read when this runs, and that client is replaced here, because
91
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.
92
101
  */
93
102
  initialize: () => void;
94
103
  /**
@@ -109,11 +118,22 @@ export declare class AssistantSystem implements InitializableSystem {
109
118
  * not interrupted, so an `apply` that has started may still commit. The background reply keeps
110
119
  * the configuration and the authorized client it started with.
111
120
  *
112
- * The background reply ends early when a new chat starts for the same configuration, which is
121
+ * The background reply is disconnected when a new chat starts for the same configuration, which is
113
122
  * what opening the configuration again does: see `_takeOverThread`.
114
123
  */
115
124
  activate: () => (() => void);
116
- /** Sends a user message stamped with its send time, which the model is told. */
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
+ */
117
137
  send: (content: string) => Promise<void>;
118
138
  /**
119
139
  * Stops the reply on both sides. Closing the stream alone keeps the server run going, because a
@@ -128,6 +148,7 @@ export declare class AssistantSystem implements InitializableSystem {
128
148
  reloadThread: () => void;
129
149
  setOpen: (open: boolean) => void;
130
150
  setInputFocused: (isInputFocused: boolean) => void;
151
+ private _committedState;
131
152
  private _patchPanel;
132
153
  /**
133
154
  * Disconnects every chat that is still finishing a reply on the thread of the given configuration,
@@ -138,9 +159,14 @@ export declare class AssistantSystem implements InitializableSystem {
138
159
  * and the new one for real, and both would send the result back, of which the server accepts one.
139
160
  * The model could be told that nothing was run about a change that was made.
140
161
  *
141
- * Stopping a client only closes its stream in the browser. Nothing is cancelled on the server, so
142
- * the run goes on there and the new chat rejoins it. A chat that finishes a reply for another
143
- * configuration is on another thread and is left alone.
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.
144
170
  */
145
171
  private _takeOverThread;
146
172
  private _startClient;
@@ -1 +1 @@
1
- import{ChatClient as t,fetchServerSentEvents as e}from"@tanstack/ai-client";import{BehaviorSubject as i}from"rxjs";import{isShallowEqual as s}from"@salsita-ai/common/utils";import{createBrowserDetailsClientTool as a}from"./browser-details.js";import{createApplyClientTool as n,createQueryClientTool as r}from"./graphql-tools.js";let o=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}),l=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."}),c=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(o);_panel=new i(h);_activation=null;_current=null;_finishing=new Set;constructor(t){this._context=t;let{configuratorExtensionSelectors:e,domainContextSelectors:i}=t,s={getGraphQLSystem:()=>e.getGraphQLSystem(),getStoreSystem:()=>i.getStoreSystem(),getActiveMode:()=>i.getActiveMode()};this._tools=[a(),r(s),n(s)]}chat$=this._chat;panel$=this._panel;initialize=()=>{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={sentAt:new Date().toISOString()};await this._current?.client.sendMessage({content:t,metadata:e})};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._startClient()};setOpen=t=>{this._patchPanel(t?{open:t,hasUnreadReply:!1}:{open:t,isInputFocused:!1})};setInputFocused=t=>{this._patchPanel({isInputFocused:t})};_patchPanel=t=>{let e={...this._panel.value,...t};s(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},a=this._context.getConfigurationId();this._takeOverThread(a);let n=this._context.getAuthorizedClient(),r=()=>n.getAssistantChatConnection(a),o=t=>{if(!i.active)return;let e={...this._chat.value,...t};s(e,this._chat.value)||this._chat.next(e)},h=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},u=async()=>({headers:await r().headers(),fetchClient:h}),d=e(()=>r().url,u),_=e(()=>`${r().url}/runs`,u),g=this._tools.map(t=>({...t,execute:(e,s)=>i.active?t.execute?.(e,s):l})),p=new t({threadId:`assistant:${a}`,connection:{...d,joinRun:_.joinRun},persistence:!0,history:{pageSize:50},tools:g,onMessagesChange:t=>o({messages:t}),onLoadingChange:t=>{let e=i.active&&this._chat.value.isLoading;o({isLoading:t}),!t&&c(p)&&(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))}}),f=!1,v=()=>{f||(f=!0,this._finishing.delete(m),p.dispose())},m={client:p,configurationId:a,generation:i,getConnection:r,dispose:v};this._current=m,p.attach()};_retireChat=()=>{let t=this._current;return this._current=null,t&&(t.generation.active=!1),this._chat.value!==o&&this._chat.next(o),t};_endChat=()=>{let t=this._retireChat();if(t){if(!t.client.getIsLoading()&&c(t.client))return void t.dispose();this._finishing.add(t)}}}
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}
@@ -18,6 +18,8 @@ export interface AssistantToolDependencies {
18
18
  };
19
19
  };
20
20
  readonly getActiveMode: () => DomainMode;
21
+ /** Forgets the changes recorded for the next change record, so it never lists what the agent itself changed. */
22
+ readonly clearChanges: () => void;
21
23
  }
22
24
  /**
23
25
  * Browser implementation of the assistant's `query` tool: prepares the operations from the
@@ -89,7 +91,9 @@ export declare const createQueryClientTool: (dependencies: AssistantToolDependen
89
91
  /**
90
92
  * Browser implementation of the assistant's `apply` tool: hands the operations to
91
93
  * `GraphQLSystem.execute`, which commits their changes as one undo step, and returns its result,
92
- * including why nothing was committed when a commit was held or lost to a conflict. Only an owner
94
+ * including why nothing was committed when a commit was held or lost to a conflict. A commit clears
95
+ * the recorded changes; a held one does not, so it shows in the next change record once the user
96
+ * approves it. Only an owner
93
97
  * session may change the configuration; the check lives here and not in the `GraphQLSystem`, whose
94
98
  * other caller, the editor panel, has its own rules.
95
99
  */
@@ -1 +1 @@
1
- import{AssistantGraphQLToolInput as e,applyTool as t,queryTool as o}from"@salsita-ai/contracts/assistant";let a=e=>({results:[],committed:!1,message:e,sideEffects:[]}),i=e=>JSON.parse(JSON.stringify(e)),s=t=>{let o=e.safeParse(t);if(!o.success){let e=o.error.issues.map(e=>`${e.path.join(".")}: ${e.message}`).join("; ");return{ok:!1,refusal:a(`Nothing was run, because the tool input is not a list of operations (${e}). Send { "operations": [{ "query": "<one GraphQL operation>" }] } with at least one item.`)}}return{ok:!0,operations:o.data.operations.map(({query:e,variables:t,operationName:o})=>({document:e,variables:t??void 0,operationName:o??void 0}))}};export const createQueryClientTool=e=>o.client(async t=>{let o=s(t);if(!o.ok)return o.refusal;let n=e.getStoreSystem();if(!n.isInitialized)return a("Nothing was run, because the configuration is not loaded yet, so there is no state to query. Call the tool again once the configurator has finished loading.");let r=e.getGraphQLSystem(),l=await r.prepare(n.stateSlices.committed.value.state,o.operations);return i({results:l.map(({result:e})=>e),committed:!1,sideEffects:r.readSideEffects(l)})});export const createApplyClientTool=e=>t.client(async t=>{if("owner"!==e.getActiveMode())return a("Nothing was run, because changes cannot be applied in this session: the user may view this configuration but not change it. The query tool still works here, including mutations, to show what a change would do without keeping it.");let o=s(t);return o.ok?i(await e.getGraphQLSystem().execute(o.operations)):o.refusal});
1
+ import{AssistantGraphQLToolInput as e,applyTool as t,queryTool as o}from"@salsita-ai/contracts/assistant";let a=e=>({results:[],committed:!1,message:e,sideEffects:[]}),i=e=>JSON.parse(JSON.stringify(e)),s=t=>{let o=e.safeParse(t);if(!o.success){let e=o.error.issues.map(e=>`${e.path.join(".")}: ${e.message}`).join("; ");return{ok:!1,refusal:a(`Nothing was run, because the tool input is not a list of operations (${e}). Send { "operations": [{ "query": "<one GraphQL operation>" }] } with at least one item.`)}}return{ok:!0,operations:o.data.operations.map(({query:e,variables:t,operationName:o})=>({document:e,variables:t??void 0,operationName:o??void 0}))}};export const createQueryClientTool=e=>o.client(async t=>{let o=s(t);if(!o.ok)return o.refusal;let n=e.getStoreSystem();if(!n.isInitialized)return a("Nothing was run, because the configuration is not loaded yet, so there is no state to query. Call the tool again once the configurator has finished loading.");let r=e.getGraphQLSystem(),l=await r.prepare(n.stateSlices.committed.value.state,o.operations);return i({results:l.map(({result:e})=>e),committed:!1,sideEffects:r.readSideEffects(l)})});export const createApplyClientTool=e=>t.client(async t=>{if("owner"!==e.getActiveMode())return a("Nothing was run, because changes cannot be applied in this session: the user may view this configuration but not change it. The query tool still works here, including mutations, to show what a change would do without keeping it.");let o=s(t);if(!o.ok)return o.refusal;let n=await e.getGraphQLSystem().execute(o.operations);return n.committed&&e.clearChanges(),i(n)});
@@ -1 +1 @@
1
- import{findAssistantFieldOptions as e,findAssistantRecipeGroups as t,modifyEntityUpdateTag as i,prepareAssistantRecipeUpdates as r,readAssistantFieldOptions as n,readAssistantRecipeGroup as s,systemUpdateFactory as a}from"#package/domain";import{readSideEffects as o}from"./side-effects.js";let d=e=>({ok:!1,root:null,changedEntities:[],deletedEntityIds:[],sideEffects:[],errors:e}),l=(e,{state:t},{recipes:i,prepareStateEmission:r,find$Entity:n})=>{let{validity:s,state:a,updates:l}=r(e,t,"committed");if(s.valid){let e=new Map(t.entities.map(e=>[e.id,e])),r=new Set(a.entities.map(e=>e.id));return{ok:!0,root:n(a.rootEntityId,a),changedEntities:a.entities.filter(t=>e.get(t.id)!==t).flatMap(e=>n(e.id,a)??[]),deletedEntityIds:t.entities.map(e=>e.id).filter(e=>!r.has(e)),sideEffects:o(l,i.resolveLocalizable),errors:[]}}return d("uncaught"===s.severity?[{type:"uncaught",entityId:null,message:s.error.message}]:s.entityViolations.filter(({violation:e})=>e.severity===s.severity).map(({entityId:e,violation:t})=>({type:t.type,entityId:e,message:void 0===t.message?null:i.resolveLocalizable(t.message)})))};export const createEntityMeta=(o,c)=>{let p=e=>()=>t(c.manifest,e,o.entity.type).flatMap(t=>{let i=s(e,t,o.entity.id,o.state,c.recipes);return i?[((e,t,i)=>{let{group:n,label:s,description:a,recipes:o}=e,{resolveLocalizable:c}=i.recipes;return{groupId:n.groupId,name:void 0===s?n.instanceName:c(s),description:n.description??(void 0===a?null:c(a)),recipes:o.map(n=>((e,t,i,n)=>{let{key:s,item:a}=e,{resolveLocalizable:o}=n.recipes;return{key:s,name:o(a.title),description:void 0===a.description?null:o(a.description),imageUrl:void 0===a.thumbnailUrl?null:o(a.thumbnailUrl),dryRun:()=>t.group.dryRuns?((e,t,i,n)=>{let{updates:s,error:a}=((e,t,{entity:i,state:n},{recipes:s})=>{try{return{updates:r(e,t,i.id,n,s),error:void 0}}catch(e){if("child"===t.target.kind)throw e;return{updates:void 0,error:e instanceof Error?e.message:String(e)}}})(e,t,i,n);return void 0===s?d([{type:"uncaught",entityId:null,message:a}]):l(s,i,n)})(e,t,i,n):null}})(n,e,t,i))}})(i,o,c)]:[]});return{...Object.fromEntries(e(c.manifest,o.entity.type).map(e=>[e.edgeName,()=>n(e,o.entity.id,o.state,c.recipes)?.map(t=>({...t,dryRun:()=>e.dryRuns?(({field:e},{value:t},r,n)=>{let{entity:s}=r,o=Object.entries(Object.entries(n.manifest.writableFields??{}).find(([e])=>e===s.type)?.[1]??{}).find(([t])=>t===e)?.[1];if(void 0===o)throw Error(`The options of "${e}" on "${s.id}" cannot be dry-run: the schema lists them, but the configurator has no writable field "${e}" on ${s.type}. Regenerate the application so the schema matches the configurator.`);let c=r.state.entities.find(e=>e.id===s.id),p={[o]:t},u=c?n.validateEntity({...c,...p}):{success:!0};return u.success?l([a.DomainEntityModification({entityId:s.id,stateDelta:p,updateTag:i})],r,n):d([{type:"uncaught",entityId:s.id,message:`Writing ${JSON.stringify(t)} to "${e}" would make "${s.id}" an invalid ${s.type}: ${u.errors.join("; ")}.${e===o?"":` The message names the stored property: ${e} is stored as ${o}.`} The option comes from the configurator and cannot be corrected from here, so do not write it.`}])})(e,t,o,c):null}))??null])),childRecipes:p("child"),replaceRecipes:p("replace")}};
1
+ import{findAssistantFieldOptions as e,findAssistantRecipeGroups as t,modifyEntityUpdateTag as i,prepareAssistantRecipeUpdates as r,readAssistantFieldOptions as n,readAssistantRecipeGroup as o,systemUpdateFactory as s}from"#package/domain";import{readSideEffects as a}from"./side-effects.js";let d=e=>({ok:!1,root:null,changedEntities:[],deletedEntityIds:[],sideEffects:[],errors:e}),l=(e,{state:t},{recipes:i,prepareStateEmission:r,find$Entity:n})=>{let{validity:o,state:s,updates:l}=r(e,t,"committed");if(o.valid){let e=new Map(t.entities.map(e=>[e.id,e])),r=new Set(s.entities.map(e=>e.id));return{ok:!0,root:n(s.rootEntityId,s),changedEntities:s.entities.filter(t=>e.get(t.id)!==t).flatMap(e=>n(e.id,s)??[]),deletedEntityIds:t.entities.map(e=>e.id).filter(e=>!r.has(e)),sideEffects:a(l,i.resolveLocalizable),errors:[]}}return d("uncaught"===o.severity?[{type:"uncaught",entityId:null,message:o.error.message}]:o.entityViolations.filter(({violation:e})=>e.severity===o.severity).map(({entityId:e,violation:t})=>({type:t.type,entityId:e,message:void 0===t.message?null:i.resolveLocalizable(t.message)})))};export const createEntityMeta=(a,u)=>{let c=e=>()=>t(u.manifest,e,a.entity.type).flatMap(t=>{let i=o(e,t,a.entity.id,a.state,u.recipes);return i?[((e,t,i)=>{let{group:n,label:o,description:s,recipes:a}=e,{resolveLocalizable:u}=i.recipes;return{groupId:n.groupId,name:void 0===o?n.instanceName:u(o),description:n.description??(void 0===s?null:u(s)),recipes:a.map(n=>((e,t,i,n)=>{let{key:o,item:s}=e,{resolveLocalizable:a}=n.recipes;return{key:o,name:a(s.title),description:void 0===s.description?null:a(s.description),imageUrl:void 0===s.thumbnailUrl?null:a(s.thumbnailUrl),dryRun:()=>t.group.dryRuns?((e,t,i,n)=>{let{updates:o,error:s}=((e,t,{entity:i,state:n},{recipes:o})=>{try{return{updates:r(e,t,i.id,n,o),error:void 0}}catch(e){if("child"===t.target.kind)throw e;return{updates:void 0,error:e instanceof Error?e.message:String(e)}}})(e,t,i,n);return void 0===o?d([{type:"uncaught",entityId:null,message:s}]):l(o,i,n)})(e,t,i,n):null}})(n,e,t,i))}})(i,a,u)]:[]});return{...Object.fromEntries(e(u.manifest,a.entity.type).map(e=>[e.edgeName,()=>n(e,a.entity.id,a.state,u.recipes)?.map(t=>({...t,dryRun:()=>e.dryRuns?(({field:e},{value:t},r,n)=>{let{entity:o}=r,a=Object.entries(Object.entries(n.manifest.writableFields??{}).find(([e])=>e===o.type)?.[1]??{}).find(([t])=>t===e)?.[1];if(void 0===a)throw Error(`The options of "${e}" on "${o.id}" cannot be dry-run: the schema lists them, but the configurator has no writable field "${e}" on ${o.type}. This is a fault in the configurator, not in your request. Tell the user this is not available.`);let u=r.state.entities.find(e=>e.id===o.id);if(!u)throw Error(`The options of "${e}" on "${o.id}" cannot be dry-run: entity "${o.id}" does not exist. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);let c={[a]:t},p=n.validateEntity({...u,...c});return p.success?l([s.DomainEntityModification({entityId:o.id,stateDelta:c,updateTag:i})],r,n):d([{type:"uncaught",entityId:o.id,message:`Writing ${JSON.stringify(t)} to "${e}" would make "${o.id}" an invalid ${o.type}: ${p.errors.join("; ")}. The option comes from the configurator and cannot be corrected from here, so do not write it.`}])})(e,t,a,u):null}))??null])),childRecipes:c("child"),replaceRecipes:c("replace")}};
@@ -1,4 +1,5 @@
1
1
  import { type ExecutionResult } from 'graphql';
2
+ import { type Localizable } from '@salsita-ai/common/utils';
2
3
  import { type $DomainEntity, type DomainContextSelectors, type DomainEntity, type DomainServicesSelectors, type DomainState, type SpecSelectors, type StateUpdateEmission } from '#package/domain';
3
4
  /** One single-operation GraphQL document with its own variables, as executed by {@link GraphQLSystem}. */
4
5
  export interface GraphQLOperation {
@@ -37,6 +38,11 @@ export interface GraphQLExecution {
37
38
  /** What the configurator did, or would do, beyond what the operations asked for, in applied order. */
38
39
  readonly sideEffects: readonly string[];
39
40
  }
41
+ /**
42
+ * Resolves a localizable value, or each item of a list of them, to a string in the current locale.
43
+ * `null` and values that are not localizable pass through, so the schema's nullability decides.
44
+ */
45
+ export declare const localize: (value: unknown, resolveLocalizable: (message: Localizable) => string) => unknown;
40
46
  /**
41
47
  * Executes GraphQL operations against the schema generated from the application spec `assistant`
42
48
  * manifest, resolving it against the committed domain state. Agent-independent: the assistant's
@@ -1 +1 @@
1
- import{GraphQLError as e,buildSchema as t,defaultFieldResolver as i,getNamedType as o,graphql as a,validateSchema as n}from"graphql";import{assertExistence as r,createSelector as s,isMessageDescriptor as l,isMultilingualString as c}from"@salsita-ai/common/utils";import{DomainEntityIdSchema as h,findAssistantMutation as d}from"#package/domain";import{createEntityMeta as m}from"./entity-meta.js";import{readSideEffects as p}from"./side-effects.js";let f={errors:[new e('No assistant manifest in the application spec. The GraphQL schema is generated from the "assistant" section. Add an "assistant" section to a spec file to expose a schema.')]},u={errors:[new e("The configuration is not loaded yet, so there is no state to query. Run the query again once the configurator has finished loading.")]},y=new RegExp(h.pattern),g=e=>"object"==typeof e&&null!==e&&"type"in e&&"string"==typeof e.type&&"id"in e&&"string"==typeof e.id,v=(e,t)=>"object"==typeof e&&null!==e?Reflect.get(e,t):void 0,S=e=>e instanceof Error?e.message:String(e),_=e=>/[.!?]$/.test(e)?e:`${e}.`,x=e=>"object"==typeof e&&null!==e&&Object.getPrototypeOf(e)===Object.prototype,w=(e,t)=>{let i=x(e)?e._raw:void 0;if(g(i))return i;if(!Array.isArray(e)&&!x(e))return e;if(t.has(e))throw Error("The value contains itself. Return ids or copies of the values instead of objects that reference each other.");let o=new Set([...t,e]);return Array.isArray(e)?e.map(e=>w(e,o)):Object.fromEntries(Object.entries(e).map(([e,t])=>[e,w(t,o)]))},E=(e,t)=>Array.isArray(e)?e.map(e=>E(e,t)):"string"==typeof e||l(e)||c(e)?t(e):e,$=t=>new e(`The GraphQL schema generated from the "assistant" manifest is invalid: ${_(t)} Regenerate the application so the schema is rebuilt from the current spec.`),b=e=>(e.errors?.length??0)>0,C=t=>({errors:[new e(`Not run: operation ${t+1} failed, so the operations after it were skipped and no change of the list takes effect. Fix the failing operation and send the whole list again.`)]});export class GraphQLSystem{_context;_selectSchema=s([s.leaf(e=>e)],e=>{try{let i=t(e),o=n(i);return o.length>0?$(o.map(e=>e.message).join(" ")):i}catch(e){return $(S(e))}});_selectFieldResolver=s([s.leaf(e=>e)],t=>(a,n,r,s)=>{if(s.parentType===s.schema.getQueryType())return i(a,n,r,s);if(s.parentType===s.schema.getMutationType())return this._resolveMutation(s.fieldName,String(s.path.key),n,r);if(!g(a))return i(a,n,r,s);if("meta"===s.fieldName){let e;return m({entity:a,state:("object"==typeof(e=v(a,"_state"))&&null!==e&&"entities"in e&&"rootEntityId"in e?e:void 0)??r.state},{manifest:r.manifest,recipes:this._recipeContext(),prepareStateEmission:(e,t,i)=>this._context.domainContextSelectors.getStoreSystem().prepareStateEmission(e,t,i),find$Entity:(e,t)=>this._find$Entity(e,t),validateEntity:e=>this._context.domainContextSelectors.getDomain().validateEntity(e)})}let{source:l,localized:c}=t[s.parentType.name]?.[s.fieldName]??{source:s.fieldName},h=((t,i)=>{try{return v(t,i)}catch(o){throw new e(`Expression "${i}" failed on ${g(t)?t.id:"an entity"}: ${_(S(o))} The expression threw while the query read it; fix the expression or the configuration state it reads.`,{originalError:o instanceof Error?o:void 0})}})(a,l);return c?E(h,this._context.domainServicesSelectors.getResolveLocalizable()):l.startsWith("$")&&"JSON"===o(s.returnType).name?((t,i,o)=>{try{return w(o,new Set)}catch(o){throw new e(`Expression "${i}" returned a value that is not plain serializable data on ${g(t)?t.id:"an entity"}: ${_(S(o))} A JSON field can only return data that serializes to JSON.`,{originalError:o instanceof Error?o:void 0})}})(a,l,h):h});constructor(e){this._context=e}_get$Entity=(e,t)=>this._context.domainContextSelectors.getDomain().get$Entity(e,t);_find$Entity=(e,t)=>this._context.domainContextSelectors.getDomain().getEntity(e,t)?this._get$Entity(e,t):null;_recipeContext=()=>({componentReader:this._context.domainContextSelectors.getComponentReader(),recipeCooker:this._context.domainContextSelectors.getRecipeCookerSystem(),resolveLocalizable:this._context.domainServicesSelectors.getResolveLocalizable()});_rootValue={root:(e,{state:t})=>this._get$Entity(t.rootEntityId,t),entities:({ids:t},{state:i})=>{if(null==t)return i.entities.map(e=>this._get$Entity(e.id,i));var o=i.rootEntityId;let a=t.filter(e=>!y.test(e));if(a.length>0)throw new e(`${a.map(e=>`"${e}"`).join(", ")} ${1===a.length?"is not an entity id":"are not entity ids"}. Entity ids have the form "<Type>-<number>", e.g. "${o}". Use ids as returned by the "id" field.`);return t.map(e=>y.test(e)?this._find$Entity(e,i):null)},selectedEntity:(e,{state:t})=>this._find$Entity(this._context.domainContextSelectors.getNavigationSystem().getActiveSelectionState(t),t),navigation:(e,{state:t})=>{let i=this._context.domainContextSelectors.getNavigationSystem();return{navigationState:i.getActiveNavigationState(t),viewState:i.getActiveViewState(t),toolState:i.getActiveToolState(t)}}};_resolveType=e=>g(e)?e.type:void 0;initialize=()=>{};_resolveMutation=(t,i,o,a)=>{if(void 0!==a.failedMutationField)throw new e(`Not run: the earlier field "${a.failedMutationField}" of this operation failed, so "${i}" was skipped and no change of the operation takes effect. Fix the failing field and send the operation again.`);try{return this._runMutation(t,o,a)}catch(e){throw a.failedMutationField=i,e}};_runMutation=(t,i,o)=>{let a=d(t,o.manifest);if(!a)throw new e(`The schema declares the mutation "${t}", but the configurator has no implementation for it. Regenerate the application so the schema matches the configurator.`);let n=o.state,r=a.implementation(i,n,{manifest:o.manifest,action:this._context.domainContextSelectors.getActionSystem().createContext(n),resolveLocalizable:this._context.domainServicesSelectors.getResolveLocalizable()});if(r.updates.length>0){let i=this._context.domainContextSelectors.getStoreSystem().prepareStateEmission(r.updates,n,"committed");if(!i.validity.valid)throw new e(`The changes of "${t}" were not applied, because the resulting configuration is invalid: ${(e=>{if("uncaught"===e.severity)return`validating it threw: ${_(S(e.error))}`;let t=[...new Set(e.entityViolations.filter(({violation:t})=>t.severity===e.severity).map(({entityId:e})=>e))];return`it has ${e.severity} violations on ${t.join(", ")}.`})(i.validity)} Change the request so the configuration stays valid.`);o.emissions.push(i),o.state=i.state}return r.readResult({previousState:n,state:o.state})};_setup=()=>{let t=this._context.specSelectors.getAssistant();if(!t)return{ready:!1,result:f};let i=this._selectSchema(t.sdl);return i instanceof e?{ready:!1,result:{errors:[i]}}:{ready:!0,assistant:t,schema:i,fieldResolver:this._selectFieldResolver(t.fields)}};prepare=async(e,t)=>{let i,o=this._setup();if(!o.ready)return t.map(()=>({result:o.result,emissions:[]}));let n={manifest:o.assistant,state:e,emissions:[],failedMutationField:void 0},r=[];for(let[e,s]of t.entries())if(void 0===i){let t=n.emissions.length;n.failedMutationField=void 0;let l=await a({schema:o.schema,source:s.document,rootValue:this._rootValue,contextValue:n,variableValues:s.variables,operationName:s.operationName,fieldResolver:o.fieldResolver,typeResolver:this._resolveType});r.push({result:l,emissions:n.emissions.slice(t)}),b(l)&&(i=e)}else r.push({result:C(i),emissions:[]});return r};readSideEffects=e=>{let t=this._context.domainServicesSelectors.getResolveLocalizable();return e.flatMap(({emissions:e})=>e.flatMap(e=>p(e.updates,t)))};_prepareAndCommit=async e=>{let t,i,o,a=this._context.domainContextSelectors.getStoreSystem(),n=await this.prepare(a.stateSlices.committed.value.state,e),s=n.map(({result:e})=>e),l=this.readSideEffects(n),c=n.flatMap(e=>e.emissions);return s.some(b)||0===c.length?{results:s,sideEffects:l,outcome:"none"}:{results:s,sideEffects:l,outcome:a.commitPrepared((t=r(c[0]),i=r(c[c.length-1]),o=c.some(e=>void 0!==e.transformationLog),{kind:"committed",previousState:t.previousState,state:i.state,updates:c.flatMap(e=>e.updates),validity:i.validity,transformationLog:o?c.flatMap(e=>e.transformationLog??[]):void 0}))}};execute=async e=>{if(!this._context.domainContextSelectors.getStoreSystem().isInitialized)return{results:e.map(()=>u),committed:!1,sideEffects:[]};let t=await this._prepareAndCommit(e),{results:i,sideEffects:o,outcome:a}="conflict"===t.outcome?await this._prepareAndCommit(e):t;return"committed"===a?{results:i,committed:!0,sideEffects:o}:"held"===a?{results:i,committed:!1,message:"The changes were not committed yet: the application held them, usually to ask the user for approval. They may still be applied once the user approves, and the next turn shows whether they were. Do not send the operations again.",sideEffects:o}:"conflict"===a?{results:i,committed:!1,message:"The changes were not committed, because the configuration changed while they were being applied. The results describe a state that was discarded. Query the current configuration and send the operations again if they still make sense.",sideEffects:o}:{results:i,committed:!1,sideEffects:o}}}
1
+ import{GraphQLError as e,buildSchema as t,defaultFieldResolver as i,getNamedType as o,graphql as n,validateSchema as a}from"graphql";import{assertExistence as r,createSelector as s,isMessageDescriptor as l,isMultilingualString as c}from"@salsita-ai/common/utils";import{DomainEntityIdSchema as d,findAssistantMutation as h}from"#package/domain";import{createEntityMeta as u}from"./entity-meta.js";import{readSideEffects as m}from"./side-effects.js";let f={errors:[new e("The configurator does not provide this request. This is a fault in the configurator, not in your request. Tell the user this is not available.")]},p={errors:[new e("The configuration is not loaded yet, so there is no state to query. Run the query again once the configurator has finished loading.")]},y=new RegExp(d.pattern),g=e=>"object"==typeof e&&null!==e&&"type"in e&&"string"==typeof e.type&&"id"in e&&"string"==typeof e.id,v=(e,t)=>"object"==typeof e&&null!==e?Reflect.get(e,t):void 0,S=e=>e instanceof Error?e.message:String(e),_=e=>/[.!?]$/.test(e)?e:`${e}.`,x=e=>"object"==typeof e&&null!==e&&Object.getPrototypeOf(e)===Object.prototype,w=(e,t)=>{let i=x(e)?e._raw:void 0;if(g(i))return i;if(!Array.isArray(e)&&!x(e))return e;if(t.has(e))throw Error("The value contains itself.");let o=new Set([...t,e]);return Array.isArray(e)?e.map(e=>w(e,o)):Object.fromEntries(Object.entries(e).map(([e,t])=>[e,w(t,o)]))};export const localize=(e,t)=>Array.isArray(e)?e.map(e=>localize(e,t)):"string"==typeof e||l(e)||c(e)?t(e):e;let E=t=>new e(`The configurator cannot handle this request: ${_(t)} This is a fault in the configurator, not in your request. Tell the user this is not available.`),$=e=>(e.errors?.length??0)>0,b=t=>({errors:[new e(`Not run: operation ${t+1} failed, so the operations after it were skipped and no change of the list takes effect. Fix the failing operation and send the whole list again.`)]});export class GraphQLSystem{_context;_selectSchema=s([s.leaf(e=>e)],e=>{try{let i=t(e),o=a(i);return o.length>0?E(o.map(e=>e.message).join(" ")):i}catch(e){return E(S(e))}});_selectFieldResolver=s([s.leaf(e=>e)],t=>(n,a,r,s)=>{if(s.parentType===s.schema.getQueryType())return i(n,a,r,s);if(s.parentType===s.schema.getMutationType())return this._resolveMutation(s.fieldName,String(s.path.key),a,r);if(!g(n))return i(n,a,r,s);if("meta"===s.fieldName){let e;return u({entity:n,state:("object"==typeof(e=v(n,"_state"))&&null!==e&&"entities"in e&&"rootEntityId"in e?e:void 0)??r.state},{manifest:r.manifest,recipes:this._recipeContext(),prepareStateEmission:(e,t,i)=>this._context.domainContextSelectors.getStoreSystem().prepareStateEmission(e,t,i),find$Entity:(e,t)=>this._find$Entity(e,t),validateEntity:e=>this._context.domainContextSelectors.getDomain().validateEntity(e)})}let{source:l,localized:c}=t[s.parentType.name]?.[s.fieldName]??{source:s.fieldName},d=((t,i)=>{try{return v(t,i)}catch(o){throw new e(`Expression "${i}" failed on ${g(t)?t.id:"an entity"}: ${_(S(o))} This is a fault in the configurator, not in your request. Tell the user this is not available.`,{originalError:o instanceof Error?o:void 0})}})(n,l);return c?localize(d,this._context.domainServicesSelectors.getResolveLocalizable()):l.startsWith("$")&&"JSON"===o(s.returnType).name?((t,i,o)=>{try{return w(o,new Set)}catch(o){throw new e(`Expression "${i}" returned a value that is not plain serializable data on ${g(t)?t.id:"an entity"}: ${_(S(o))} This is a fault in the configurator, not in your request. Tell the user this is not available.`,{originalError:o instanceof Error?o:void 0})}})(n,l,d):d});constructor(e){this._context=e}_get$Entity=(e,t)=>this._context.domainContextSelectors.getDomain().get$Entity(e,t);_find$Entity=(e,t)=>this._context.domainContextSelectors.getDomain().getEntity(e,t)?this._get$Entity(e,t):null;_recipeContext=()=>({componentReader:this._context.domainContextSelectors.getComponentReader(),recipeCooker:this._context.domainContextSelectors.getRecipeCookerSystem(),resolveLocalizable:this._context.domainServicesSelectors.getResolveLocalizable()});_rootValue={root:(e,{state:t})=>this._get$Entity(t.rootEntityId,t),entities:({ids:t},{state:i})=>{if(null==t)return i.entities.map(e=>this._get$Entity(e.id,i));var o=i.rootEntityId;let n=t.filter(e=>!y.test(e));if(n.length>0)throw new e(`${n.map(e=>`"${e}"`).join(", ")} ${1===n.length?"is not an entity id":"are not entity ids"}. Entity ids have the form "<Type>-<number>", e.g. "${o}". Use ids as returned by the "id" field.`);return t.map(e=>y.test(e)?this._find$Entity(e,i):null)},selectedEntity:(e,{state:t})=>this._find$Entity(this._context.domainContextSelectors.getNavigationSystem().getActiveSelectionState(t),t),navigation:(e,{state:t})=>{let i=this._context.domainContextSelectors.getNavigationSystem();return{navigationState:i.getActiveNavigationState(t),viewState:i.getActiveViewState(t),toolState:i.getActiveToolState(t)}}};_resolveType=e=>g(e)?e.type:void 0;initialize=()=>{};_resolveMutation=(t,i,o,n)=>{if(void 0!==n.failedMutationField)throw new e(`Not run: the earlier field "${n.failedMutationField}" of this operation failed, so "${i}" was skipped and no change of the operation takes effect. Fix the failing field and send the operation again.`);try{return this._runMutation(t,o,n)}catch(e){throw n.failedMutationField=i,e}};_runMutation=(t,i,o)=>{let n=h(t,o.manifest);if(!n)throw new e(`The schema declares the mutation "${t}", but the configurator has no implementation for it. This is a fault in the configurator, not in your request. Tell the user this is not available.`);let a=o.state,r=n.implementation(i,a,{manifest:o.manifest,action:this._context.domainContextSelectors.getActionSystem().createContext(a),resolveLocalizable:this._context.domainServicesSelectors.getResolveLocalizable()});if(r.updates.length>0){let i=this._context.domainContextSelectors.getStoreSystem().prepareStateEmission(r.updates,a,"committed");if(!i.validity.valid)throw new e(`The changes of "${t}" were not applied, because the resulting configuration is invalid: ${(e=>{if("uncaught"===e.severity)return`validating it threw: ${_(S(e.error))}`;let t=[...new Set(e.entityViolations.filter(({violation:t})=>t.severity===e.severity).map(({entityId:e})=>e))];return`it has ${e.severity} violations on ${t.join(", ")}.`})(i.validity)} Change the request so the configuration stays valid.`);o.emissions.push(i),o.state=i.state}return r.readResult({previousState:a,state:o.state})};_setup=()=>{let t=this._context.specSelectors.getAssistant();if(!t)return{ready:!1,result:f};let i=this._selectSchema(t.sdl);return i instanceof e?{ready:!1,result:{errors:[i]}}:{ready:!0,assistant:t,schema:i,fieldResolver:this._selectFieldResolver(t.fields)}};prepare=async(e,t)=>{let i,o=this._setup();if(!o.ready)return t.map(()=>({result:o.result,emissions:[]}));let a={manifest:o.assistant,state:e,emissions:[],failedMutationField:void 0},r=[];for(let[e,s]of t.entries())if(void 0===i){let t=a.emissions.length;a.failedMutationField=void 0;let l=await n({schema:o.schema,source:s.document,rootValue:this._rootValue,contextValue:a,variableValues:s.variables,operationName:s.operationName,fieldResolver:o.fieldResolver,typeResolver:this._resolveType});r.push({result:l,emissions:a.emissions.slice(t)}),$(l)&&(i=e)}else r.push({result:b(i),emissions:[]});return r};readSideEffects=e=>{let t=this._context.domainServicesSelectors.getResolveLocalizable();return e.flatMap(({emissions:e})=>e.flatMap(e=>m(e.updates,t)))};_prepareAndCommit=async e=>{let t,i,o,n=this._context.domainContextSelectors.getStoreSystem(),a=await this.prepare(n.stateSlices.committed.value.state,e),s=a.map(({result:e})=>e),l=this.readSideEffects(a),c=a.flatMap(e=>e.emissions);return s.some($)||0===c.length?{results:s,sideEffects:l,outcome:"none"}:{results:s,sideEffects:l,outcome:n.commitPrepared((t=r(c[0]),i=r(c[c.length-1]),o=c.some(e=>void 0!==e.transformationLog),{kind:"committed",previousState:t.previousState,state:i.state,updates:c.flatMap(e=>e.updates),validity:i.validity,transformationLog:o?c.flatMap(e=>e.transformationLog??[]):void 0}))}};execute=async e=>{if(!this._context.domainContextSelectors.getStoreSystem().isInitialized)return{results:e.map(()=>p),committed:!1,sideEffects:[]};let t=await this._prepareAndCommit(e),{results:i,sideEffects:o,outcome:n}="conflict"===t.outcome?await this._prepareAndCommit(e):t;return"committed"===n?{results:i,committed:!0,sideEffects:o}:"held"===n?{results:i,committed:!1,message:"The changes wait for the user's approval and are not applied yet. Do not send them again; the next `[changes]` block lists them once approved.",sideEffects:o}:"conflict"===n?{results:i,committed:!1,message:"The changes were not committed, because the configuration changed while they were being applied. The results describe a state that was discarded. Query the current configuration and send the operations again if they still make sense.",sideEffects:o}:{results:i,committed:!1,sideEffects:o}}}
@@ -1 +1 @@
1
- import{jsx as t,jsxs as e}from"react/jsx-runtime";import{Tooltip as a,styled as i}from"@mui/material";import{memo as n,useCallback as s}from"react";import{match as o}from"ts-pattern";import{useLocalizable as r}from"#package/react-sdk";import{PhxIcon as l}from"#package/ui-sdk";import{AssistantPanelName as d}from"./theme.js";let c={id:"sdk.assistant.tool.updateDesign.label",message:"Update design"},m={id:"sdk.assistant.tool.readDesign.label",message:"Read design"},p={id:"sdk.assistant.tool.mistake.hint",message:"The assistant made a mistake."},h=i("div",{name:d,slot:"chips"})(({theme:{palette:t,spacing:e,typography:a}})=>({...a.caption,alignItems:"start",color:t.text.secondary,display:"grid",gap:e(.75),gridTemplateColumns:"min-content minmax(0, 1fr)"})),g=i("span",{name:d,slot:"activity"})(({theme:{typography:t}})=>({blockSize:`calc(${t.caption.lineHeight} * 1em)`,display:"grid",placeItems:"center"})),f=i(l,{name:d,slot:"activityIcon"})({fontSize:14,'[data-chips="active"] &':{animation:"phx-assistant-turn 2.4s linear infinite","@media (prefers-reduced-motion: reduce)":{animation:"none"}},"@keyframes phx-assistant-turn":{to:{rotate:"360deg"}}}),k=i("span",{name:d,slot:"chip"})(({theme:{palette:t,spacing:e}})=>({cursor:"default",display:"inline-block",whiteSpace:"nowrap","&:not(:last-child)::after":{color:t.text.secondary,content:'"\xb7"',display:"inline-block",marginInline:e(.75),textDecoration:"none"},'&[data-chip="failed"]':{color:t.error.main},'&[data-chip="flawed"]':{textDecoration:"line-through",textDecorationColor:t.error.main}})),u=n(({tool:e})=>{let{chip:i,input:n,result:l}=e,d=r(c),h=r(m),g=r(p),f=o(i.label).with({kind:"text"},({text:t})=>t).with({kind:"updateDesign"},()=>d).with({kind:"readDesign"},()=>h).exhaustive(),u=s(()=>{console.info(`Assistant tool call "${f}"`,{input:n,result:l})},[n,f,l]);return t(a,{title:"failed"===i.state||"flawed"===i.state?g:"",placement:"top-start",children:t(k,{onClick:u,"data-chip":i.state,children:f})})});export const AssistantToolChips=n(({tools:a,isActive:i})=>e(h,{"data-chips":i?"active":"done","aria-busy":i,children:[t(g,{children:t(f,{name:"Gear"})}),t("div",{children:a.map(e=>t(u,{tool:e},e.id))})]}));
1
+ import{jsx as t,jsxs as e}from"react/jsx-runtime";import{Tooltip as a,styled as i}from"@mui/material";import{memo as s,useCallback as o}from"react";import{match as n}from"ts-pattern";import{useLocalizable as r}from"#package/react-sdk";import{PhxIcon as l}from"#package/ui-sdk";import{AssistantPanelName as d}from"./theme.js";let m={id:"sdk.assistant.tool.updateDesign.label",message:"Update design"},c={id:"sdk.assistant.tool.readDesign.label",message:"Read design"},p={id:"sdk.assistant.tool.mistake.hint",message:"The assistant made a mistake."},h={id:"sdk.assistant.tool.cancelled.hint",message:"Stopped before it finished."},g={id:"sdk.assistant.tool.noResult.hint",message:"The result of this step was lost. It may or may not have been done."},f={id:"sdk.assistant.tool.toolBudget.hint",message:"Not done: the assistant reached its limit of steps for one message."},u=i("div",{name:d,slot:"chips"})(({theme:{palette:t,spacing:e,typography:a}})=>({...a.caption,alignItems:"start",color:t.text.secondary,display:"grid",gap:e(.75),gridTemplateColumns:"min-content minmax(0, 1fr)"})),k=i("span",{name:d,slot:"activity"})(({theme:{typography:t}})=>({blockSize:`calc(${t.caption.lineHeight} * 1em)`,display:"grid",placeItems:"center"})),x=i(l,{name:d,slot:"activityIcon"})({fontSize:14,'[data-chips="active"] &':{animation:"phx-assistant-turn 2.4s linear infinite","@media (prefers-reduced-motion: reduce)":{animation:"none"}},"@keyframes phx-assistant-turn":{to:{rotate:"360deg"}}}),w=i("span",{name:d,slot:"chip"})(({theme:{palette:t,spacing:e}})=>({cursor:"default",display:"inline-block",whiteSpace:"nowrap","&:not(:last-child)::after":{color:t.text.secondary,content:'"\xb7"',display:"inline-block",marginInline:e(.75),textDecoration:"none"},'&[data-chip="failed"]':{color:t.error.main},'&[data-chip="flawed"]':{textDecoration:"line-through",textDecorationColor:t.error.main}})),y=s(({tool:e})=>{let{chip:i,input:s,result:l}=e,d=r(m),u=r(c),k=r(p),x=r(h),y=r(g),b=r(f),v=n(i.label).with({kind:"text"},({text:t})=>t).with({kind:"updateDesign"},()=>d).with({kind:"readDesign"},()=>u).exhaustive(),C=o(()=>{console.info(`Assistant tool call "${v}"`,{input:s,result:l})},[s,v,l]);return t(a,{title:n(i).with({errorCode:"cancelled"},()=>x).with({errorCode:"no_result"},()=>y).with({errorCode:"tool_budget"},()=>b).with({state:"failed"},{state:"flawed"},()=>k).otherwise(()=>""),placement:"top-start",children:t(w,{onClick:C,"data-chip":i.state,children:v})})});export const AssistantToolChips=s(({tools:a,isActive:i})=>e(u,{"data-chips":i?"active":"done","aria-busy":i,children:[t(k,{children:t(x,{name:"Gear"})}),t("div",{children:a.map(e=>t(y,{tool:e},e.id))})]}));
@@ -1,3 +1,4 @@
1
+ import { type AssistantToolErrorCode } from '@salsita-ai/contracts/assistant';
1
2
  /**
2
3
  * How a tool call of the assistant looks in the thread: still running, finished, a change that was
3
4
  * not kept (`failed`), or a read that answered with errors (`flawed`), which matters less because
@@ -16,6 +17,11 @@ export type AssistantToolChipLabel = {
16
17
  export interface AssistantToolChip {
17
18
  readonly label: AssistantToolChipLabel;
18
19
  readonly state: AssistantToolChipState;
20
+ /**
21
+ * Why the server recorded an error in place of the call's result, when it said so with a code this
22
+ * panel knows. Nothing for a call that went wrong for any other reason.
23
+ */
24
+ readonly errorCode: AssistantToolErrorCode | undefined;
19
25
  }
20
26
  /** A tool call of a message as the chip reads it. */
21
27
  export interface AssistantToolCall {
@@ -32,6 +38,7 @@ export interface AssistantToolCall {
32
38
  /**
33
39
  * Describes one tool call for its chip: the label in the order operation names, fixed text for the
34
40
  * `apply` and `query` tools, tool name; and whether the call runs, finished, or went wrong. Why it
35
- * went wrong is not part of it: the tool result words that for the model, not for the user.
41
+ * went wrong is part of it only as the code of an error the server recorded: the text of a tool
42
+ * result is worded for the model, not for the user.
36
43
  */
37
44
  export declare const describeToolCall: (call: AssistantToolCall) => AssistantToolChip;
@@ -1 +1 @@
1
- import{Kind as e,parse as t}from"graphql";import{z as n}from"zod";import{applyTool as r,queryTool as a}from"@salsita-ai/contracts/assistant";let o=n.object({operations:n.array(n.object({query:n.string(),operationName:n.string().nullish()}))}),i=n.object({results:n.array(n.object({errors:n.array(n.unknown()).optional()})),committed:n.boolean()});export const describeToolCall=n=>{let s=(({name:n,input:i})=>{let s,l=(s=o.safeParse(i)).success?s.data.operations.flatMap(({query:n,operationName:r})=>r??(n=>{try{let r=t(n).definitions.find(t=>t.kind===e.OPERATION_DEFINITION);return r?.kind===e.OPERATION_DEFINITION?r.name?.value:void 0}catch{return}})(n)??[]):[];return l.length>0?{kind:"text",text:l.join(", ")}:n===r.name?{kind:"updateDesign"}:n===a.name?{kind:"readDesign"}:{kind:"text",text:n}})(n);return null==n.result&&null==n.error?{label:s,state:n.isReplyRunning?"running":"done"}:{label:s,state:(({name:e,result:t,error:n})=>{if(null!=n)return e===a.name?"flawed":"failed";let o=i.safeParse(t);if(!o.success)return"done";let{results:s,committed:l}=o.data;return e===r.name?l?"done":"failed":s.some(({errors:e})=>(e?.length??0)>0)||0===s.length?"flawed":"done"})(n)}};
1
+ import{Kind as e,parse as t}from"graphql";import{z as n}from"zod";import{ASSISTANT_TOOL_ERROR_CODES as r,AssistantToolError as a,applyTool as i,queryTool as o}from"@salsita-ai/contracts/assistant";let l=n.object({operations:n.array(n.object({query:n.string(),operationName:n.string().nullish()}))}),s=n.object({results:n.array(n.object({errors:n.array(n.unknown()).optional()})),committed:n.boolean()});export const describeToolCall=n=>{let d=(({name:n,input:r})=>{let a,s=(a=l.safeParse(r)).success?a.data.operations.flatMap(({query:n,operationName:r})=>r??(n=>{try{let r=t(n).definitions.find(t=>t.kind===e.OPERATION_DEFINITION);return r?.kind===e.OPERATION_DEFINITION?r.name?.value:void 0}catch{return}})(n)??[]):[];return s.length>0?{kind:"text",text:s.join(", ")}:n===i.name?{kind:"updateDesign"}:n===o.name?{kind:"readDesign"}:{kind:"text",text:n}})(n);if(null==n.result&&null==n.error)return{label:d,state:n.isReplyRunning?"running":"done",errorCode:void 0};let u=(e=>{let t=a.safeParse(e);if(t.success)return r.find(e=>e===t.data.code)})(n.result);return{label:d,state:(({name:e,result:t,error:n},r)=>{if(null!=n||null!=r)return e===o.name?"flawed":"failed";if(e!==i.name&&e!==o.name)return"done";let a=s.safeParse(t);if(!a.success)return e===o.name?"flawed":"failed";let{results:l,committed:d}=a.data;return e===i.name?d?"done":"failed":l.some(({errors:e})=>(e?.length??0)>0)||0===l.length?"flawed":"done"})(n,u),errorCode:u}};