@salsita-ai/sdk 0.50.0-develop.dfac20c66b → 0.50.0-develop.ea0d8e208d

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 (294) hide show
  1. package/dist/application-spec/generate-application/code/common/index.d.ts +1 -0
  2. package/dist/application-spec/generate-application/code/common/index.js +1 -1
  3. package/dist/application-spec/generate-application/code/common/project-module-list.d.ts +8 -0
  4. package/dist/application-spec/generate-application/code/common/project-module-list.js +3 -0
  5. package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
  6. package/dist/application-spec/generate-application/code/project-scaffolding.js +2 -2
  7. package/dist/application-spec/generate-application/code/templates/admin-domain-code.d.ts +1 -2
  8. package/dist/application-spec/generate-application/code/templates/admin-domain-code.js +6 -14
  9. package/dist/application-spec/generate-application/code/templates/admin-frontend-code.d.ts +1 -2
  10. package/dist/application-spec/generate-application/code/templates/admin-frontend-code.js +4 -4
  11. package/dist/application-spec/generate-application/code/templates/configurator-domain-code.d.ts +1 -2
  12. package/dist/application-spec/generate-application/code/templates/configurator-domain-code.js +7 -16
  13. package/dist/application-spec/generate-application/code/templates/configurator-frontend-code.d.ts +1 -2
  14. package/dist/application-spec/generate-application/code/templates/configurator-frontend-code.js +7 -9
  15. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-assistant.d.ts +2 -2
  16. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-assistant.js +1 -1
  17. package/dist/application-spec/generate-application/code/templates/domain-spec.js +4 -4
  18. package/dist/application-spec/generate-application/code/templates/domain.js +3 -3
  19. package/dist/application-spec/generate-application/code/templates/index.d.ts +1 -0
  20. package/dist/application-spec/generate-application/code/templates/index.js +1 -1
  21. package/dist/application-spec/generate-application/code/templates/skills/agents-md.js +1 -1
  22. package/dist/application-spec/generate-application/code/templates/skills/phoenix-cli-skill.js +1 -1
  23. package/dist/application-spec/generate-application/code/templates/skills/phoenix-create-configurator-skill.js +41 -13
  24. package/dist/application-spec/generate-application/code/templates/skills/phoenix-feedback-skill.js +1 -1
  25. package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js +2 -2
  26. package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill.js +1 -1
  27. package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.d.ts +1 -0
  28. package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.js +6 -0
  29. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +30 -3
  30. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +19 -5
  31. package/dist/application-spec/generate-application/code/templates/webhook-builders.js +8 -4
  32. package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.d.ts +4 -3
  33. package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.js +1 -1
  34. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.d.ts +3 -8
  35. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.js +1 -1
  36. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +9 -43
  37. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
  38. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-server-settings.d.ts +2 -2
  39. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant.d.ts +5 -21
  40. package/dist/client/phoenix-api.d.ts +58 -30
  41. package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
  42. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +158 -13
  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 +8 -3
  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.d.ts +4 -0
  49. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.js +1 -1
  50. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +16 -1
  51. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
  52. package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.d.ts +9 -0
  53. package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.js +1 -0
  54. package/dist/configurator/application-runtime/extensions/systems/index.d.ts +1 -1
  55. package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.d.ts +2 -0
  56. package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.js +1 -1
  57. package/dist/configurator/common/frontend-analytics.d.ts +21 -21
  58. package/dist/configurator/index.d.ts +0 -1
  59. package/dist/configurator/index.js +1 -1
  60. package/dist/configurator/pages/LoadedConfiguratorDetailPage.js +1 -1
  61. package/dist/configurator/scene/scene-analytics/scene-analytics.d.ts +2 -2
  62. package/dist/configurator/ui/assistant/AssistantChips.d.ts +11 -0
  63. package/dist/configurator/ui/assistant/AssistantChips.js +1 -0
  64. package/dist/configurator/ui/assistant/AssistantComposer.d.ts +6 -0
  65. package/dist/configurator/ui/assistant/AssistantComposer.js +1 -0
  66. package/dist/configurator/ui/assistant/AssistantMarkdown.d.ts +7 -0
  67. package/dist/configurator/ui/assistant/AssistantMarkdown.js +1 -0
  68. package/dist/configurator/ui/assistant/AssistantPanel.d.ts +11 -0
  69. package/dist/configurator/ui/assistant/AssistantPanel.js +1 -0
  70. package/dist/configurator/ui/assistant/AssistantThread.d.ts +6 -0
  71. package/dist/configurator/ui/assistant/AssistantThread.js +1 -0
  72. package/dist/configurator/ui/assistant/assistant-failure.d.ts +18 -0
  73. package/dist/configurator/ui/assistant/assistant-failure.js +1 -0
  74. package/dist/configurator/ui/assistant/index.d.ts +2 -0
  75. package/dist/configurator/ui/assistant/index.js +1 -0
  76. package/dist/configurator/ui/assistant/streamed-markdown.d.ts +6 -0
  77. package/dist/configurator/ui/assistant/streamed-markdown.js +2 -0
  78. package/dist/configurator/ui/assistant/theme.d.ts +2 -0
  79. package/dist/configurator/ui/assistant/theme.js +1 -0
  80. package/dist/configurator/ui/assistant/thread-items.d.ts +37 -0
  81. package/dist/configurator/ui/assistant/thread-items.js +1 -0
  82. package/dist/configurator/ui/assistant/tool-chip.d.ts +44 -0
  83. package/dist/configurator/ui/assistant/tool-chip.js +1 -0
  84. package/dist/configurator/ui/assistant/use-follow-stream.d.ts +17 -0
  85. package/dist/configurator/ui/assistant/use-follow-stream.js +1 -0
  86. package/dist/configurator/ui/assistant/use-is-assistant-panel-open.d.ts +5 -0
  87. package/dist/configurator/ui/assistant/use-is-assistant-panel-open.js +1 -0
  88. package/dist/configurator/ui/configurator-layout/universal/DesktopLayout.js +5 -5
  89. package/dist/configurator/ui/configurator-layout/universal/MobileLayout.d.ts +2 -0
  90. package/dist/configurator/ui/configurator-layout/universal/MobileLayout.js +4 -4
  91. package/dist/configurator/ui/legacy/mobile-controls/MobileControls.d.ts +1 -1
  92. package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.d.ts +10 -0
  93. package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.js +1 -0
  94. package/dist/configurator/ui/phoenix-layout-elements/index.d.ts +1 -0
  95. package/dist/configurator/ui/phoenix-layout-elements/index.js +1 -1
  96. package/dist/docs/complex-use-cases/filtered-controls-with-fix-dialog.mdx +84 -98
  97. package/dist/docs/complex-use-cases/navigation-reset-selection.mdx +18 -12
  98. package/dist/docs/index.json +1 -1
  99. package/dist/docs/layouts/custom-price.mdx +14 -16
  100. package/dist/docs/layouts/sidebar/tabs.mdx +24 -21
  101. package/dist/docs/layouts/toolbar.mdx +6 -0
  102. package/dist/docs/other-features/domain-actions.mdx +1 -1
  103. package/dist/docs/other-features/side-effects.mdx +68 -34
  104. package/dist/docs/other-features/transformers.mdx +1 -1
  105. package/dist/docs/phoenix/admin.mdx +9 -24
  106. package/dist/docs/phoenix/localization.mdx +3 -22
  107. package/dist/docs/phoenix/phoenix-cli.mdx +81 -2
  108. package/dist/docs/phoenix/project-structure.mdx +9 -2
  109. package/dist/docs/phoenix/sdk-builder-workflow.mdx +4 -3
  110. package/dist/docs/recipes-and-delete/recipe-hierarchy-selection.mdx +15 -13
  111. package/dist/docs/relations/hierarchy.mdx +13 -2
  112. package/dist/domain/actions/action-factory.d.ts +3 -2
  113. package/dist/domain/application/application-config.d.ts +25 -75
  114. package/dist/domain/application/assistant/assistant-manifest.d.ts +61 -0
  115. package/dist/domain/application/assistant/assistant-resolved-manifest.d.ts +95 -0
  116. package/dist/domain/application/assistant/assistant-value-type.d.ts +9 -0
  117. package/dist/domain/application/assistant/assistant-value-type.js +1 -0
  118. package/dist/domain/application/assistant/build-assistant-manifest.d.ts +4 -0
  119. package/dist/domain/application/assistant/build-assistant-manifest.js +1 -0
  120. package/dist/{phoenix/application-spec → domain/application/assistant}/generate-assistant-prompt.d.ts +6 -5
  121. package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -0
  122. package/dist/domain/application/assistant/index.d.ts +4 -0
  123. package/dist/domain/application/assistant/index.js +1 -0
  124. package/dist/domain/application/assistant-field-options.d.ts +1 -1
  125. package/dist/domain/application/assistant-mutations.d.ts +1 -1
  126. package/dist/domain/application/assistant-recipe-groups.d.ts +1 -1
  127. package/dist/domain/application/configurator-builder.d.ts +33 -18
  128. package/dist/domain/application/configurator-builder.js +1 -1
  129. package/dist/domain/application/element-registration.d.ts +5 -0
  130. package/dist/domain/application/element-registration.js +1 -1
  131. package/dist/domain/application/handler-registration.d.ts +5 -0
  132. package/dist/domain/application/handler-registration.js +1 -1
  133. package/dist/domain/application/index.d.ts +5 -4
  134. package/dist/domain/application/index.js +1 -1
  135. package/dist/domain/application/resolve-imported-transformers.d.ts +11 -1
  136. package/dist/domain/application/resolve-imported-transformers.js +1 -1
  137. package/dist/domain/components/domain-component-optic.d.ts +3 -0
  138. package/dist/domain/components/domain-component-optic.js +2 -2
  139. package/dist/domain/components/system-component-builder.js +1 -1
  140. package/dist/domain/components/updates.d.ts +16 -0
  141. package/dist/domain/core/action.d.ts +1 -1
  142. package/dist/domain/core/component.d.ts +1 -1
  143. package/dist/domain/core/domain-factory.js +1 -1
  144. package/dist/domain/core/index.d.ts +1 -3
  145. package/dist/domain/core/index.js +1 -1
  146. package/dist/domain/core/reflection.d.ts +1 -1
  147. package/dist/domain/core/reflection.js +1 -1
  148. package/dist/domain/core/schema/enhanced-json-schema.js +1 -0
  149. package/dist/domain/core/schema/extended-schema-validator.js +1 -0
  150. package/dist/domain/core/schema/index.d.ts +3 -0
  151. package/dist/domain/core/schema/index.js +1 -0
  152. package/dist/domain/core/schema/schema-validator.js +1 -0
  153. package/dist/domain/domain-builder.d.ts +10 -1
  154. package/dist/domain/domain-builder.js +1 -1
  155. package/dist/domain/domain-context/action-system/action-system.js +1 -1
  156. package/dist/domain/domain-context/index.d.ts +1 -1
  157. package/dist/domain/domain-context/store-system/store-system.js +1 -1
  158. package/dist/domain/domain-context/transformers/chain-builder.d.ts +1 -1
  159. package/dist/domain/domain-runtime/domain-runtime.d.ts +4 -4
  160. package/dist/domain/domain-runtime/spec/initialize.js +1 -1
  161. package/dist/domain/domain-runtime/spec/selectors.d.ts +2 -2
  162. package/dist/domain/domain-runtime/spec/selectors.js +1 -1
  163. package/dist/domain/domain-runtime/spec/types.d.ts +3 -3
  164. package/dist/domain/index.d.ts +3 -2
  165. package/dist/domain/index.js +1 -1
  166. package/dist/domain/invariants/invariants.d.ts +9 -0
  167. package/dist/domain/invariants/invariants.js +1 -1
  168. package/dist/domain/mocks/create-mock-domain-runtime.d.ts +3 -3
  169. package/dist/domain/mocks/create-mock-domain-runtime.js +1 -1
  170. package/dist/domain/project-modules/index.d.ts +1 -0
  171. package/dist/domain/project-modules/index.js +1 -0
  172. package/dist/domain/project-modules/project-modules.d.ts +41 -0
  173. package/dist/domain/project-modules/project-modules.js +1 -0
  174. package/dist/domain/system-components/common/dimension-indicator-schema.d.ts +1 -1
  175. package/dist/domain/system-components/common/dimension-indicator-schema.js +1 -1
  176. package/dist/domain/system-components/phoenix-layout-elements/assistant-toolbar-button.d.ts +44 -0
  177. package/dist/domain/system-components/phoenix-layout-elements/assistant-toolbar-button.js +1 -0
  178. package/dist/domain/system-components/phoenix-layout-elements/index.d.ts +1 -0
  179. package/dist/domain/system-components/phoenix-layout-elements/index.js +1 -1
  180. package/dist/domain/system-components/phoenix-layout-elements/phoenix-layout-element.d.ts +2 -1
  181. package/dist/domain/system-components/phoenix-layout-elements/phoenix-layout-element.js +1 -1
  182. package/dist/editor/Editor.js +1 -1
  183. package/dist/editor/domain-editors/use-implementation-files.d.ts +7 -6
  184. package/dist/editor/domain-editors/use-implementation-files.js +1 -1
  185. package/dist/editor/graphql/GraphQLPanel.js +1 -1
  186. package/dist/editor/variants/VariantAnswerFooter.d.ts +17 -0
  187. package/dist/editor/variants/VariantAnswerFooter.js +1 -0
  188. package/dist/editor/variants/VariantPreviewHandler.d.ts +6 -0
  189. package/dist/editor/variants/VariantPreviewHandler.js +1 -0
  190. package/dist/editor/variants/variant-preview-styles.d.ts +49 -0
  191. package/dist/editor/variants/variant-preview-styles.js +1 -0
  192. package/dist/i18n/locales/cs/messages.js +1 -1
  193. package/dist/i18n/locales/da/messages.js +1 -1
  194. package/dist/i18n/locales/de/messages.js +1 -1
  195. package/dist/i18n/locales/de-AT/messages.js +1 -1
  196. package/dist/i18n/locales/en/messages.js +1 -1
  197. package/dist/i18n/locales/en-AU/messages.js +1 -1
  198. package/dist/i18n/locales/en-GB/messages.js +1 -1
  199. package/dist/i18n/locales/es/messages.js +1 -1
  200. package/dist/i18n/locales/fr/messages.js +1 -1
  201. package/dist/i18n/locales/hu/messages.js +1 -1
  202. package/dist/i18n/locales/it/messages.js +1 -1
  203. package/dist/i18n/locales/nl/messages.js +1 -1
  204. package/dist/i18n/locales/pl/messages.js +1 -1
  205. package/dist/i18n/locales/pt/messages.js +1 -1
  206. package/dist/i18n/locales/ro/messages.js +1 -1
  207. package/dist/i18n/locales/sk/messages.js +1 -1
  208. package/dist/i18n/locales/tr/messages.js +1 -1
  209. package/dist/legacy/domain-cli/gen/configurator-builder.js +21 -8
  210. package/dist/legacy/domain-cli/utils/cache.d.ts +1 -1
  211. package/dist/legacy/domain-cli/utils/cache.js +1 -1
  212. package/dist/legacy/domain-spec/__generated/domain-schema.d.ts +6 -0
  213. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-admin.js +18 -19
  214. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-configurator.js +15 -16
  215. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-admin.js +22 -23
  216. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-configurator.js +15 -16
  217. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/generator-shared.d.ts +7 -2
  218. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/generator-shared.js +8 -12
  219. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/index.d.ts +1 -1
  220. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/index.js +1 -1
  221. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/webhook-builders.js +7 -7
  222. package/dist/phoenix/application-spec/application-spec-builder.js +1 -1
  223. package/dist/phoenix/application-spec/resolve-deployment-data.d.ts +4 -3
  224. package/dist/phoenix/application-spec/resolve-deployment-data.js +2 -2
  225. package/dist/phoenix/cli.js +1 -1
  226. package/dist/phoenix/commands/deploy.js +2 -2
  227. package/dist/phoenix/commands/dev.js +5 -5
  228. package/dist/phoenix/commands/index.d.ts +1 -0
  229. package/dist/phoenix/commands/index.js +1 -1
  230. package/dist/phoenix/commands/prepare-deployment-command.js +2 -2
  231. package/dist/phoenix/commands/prepare-local-environment-command.js +1 -1
  232. package/dist/phoenix/commands/story-dev.js +2 -2
  233. package/dist/phoenix/commands/variants.d.ts +35 -0
  234. package/dist/phoenix/commands/variants.js +1 -0
  235. package/dist/phoenix/editor-server/commands-router.d.ts +68 -1
  236. package/dist/phoenix/editor-server/commands-router.js +1 -1
  237. package/dist/phoenix/editor-server/editor-router.d.ts +65 -0
  238. package/dist/phoenix/editor-server/editor-server.d.ts +3 -3
  239. package/dist/phoenix/editor-server/editor-server.js +1 -1
  240. package/dist/phoenix/editor-server/protocol.d.ts +1 -0
  241. package/dist/phoenix/editor-server/spec-router.js +1 -1
  242. package/dist/phoenix/editor-server/trpc.d.ts +3 -0
  243. package/dist/phoenix/services/application-spec-project-watcher.d.ts +13 -2
  244. package/dist/phoenix/services/application-spec-project-watcher.js +3 -3
  245. package/dist/phoenix/services/index.d.ts +4 -0
  246. package/dist/phoenix/services/index.js +1 -1
  247. package/dist/phoenix/services/phoenix-application.d.ts +21 -0
  248. package/dist/phoenix/services/phoenix-application.js +1 -0
  249. package/dist/phoenix/services/phoenix-store.d.ts +48 -0
  250. package/dist/phoenix/services/phoenix-store.js +1 -0
  251. package/dist/phoenix/services/phx-variant-previews-plugin.d.ts +9 -0
  252. package/dist/phoenix/services/phx-variant-previews-plugin.js +1 -0
  253. package/dist/phoenix/services/prepare-development-environment.js +1 -1
  254. package/dist/phoenix/services/variant-file-session.d.ts +36 -0
  255. package/dist/phoenix/services/variant-file-session.js +1 -0
  256. package/dist/phoenix/services/variant-preview-service.d.ts +80 -0
  257. package/dist/phoenix/services/variant-preview-service.js +1 -0
  258. package/dist/phoenix/services/vite-config.js +1 -1
  259. package/dist/react-sdk/application-runtime/common-services/analytics/analytics-service.d.ts +2 -2
  260. package/dist/react-sdk/application-runtime/common-services/analytics/domain-controls-analytics.d.ts +21 -21
  261. package/dist/react-sdk/application-runtime/hooks/data/use-published-data.d.ts +1 -1
  262. package/dist/react-sdk/application-runtime/hooks/use-domain-application-props.d.ts +5 -2
  263. package/dist/react-sdk/application-runtime/hooks/use-spec.d.ts +1 -1
  264. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.d.ts +1 -1
  265. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.js +1 -1
  266. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +4 -4
  267. package/dist/ui-sdk/common/use-viewport-size.d.ts +4 -1
  268. package/dist/ui-sdk/common/use-viewport-size.js +1 -1
  269. package/dist/ui-sdk/components/mobile-controls/index.d.ts +1 -1
  270. package/dist/ui-sdk/theme/types.d.ts +4 -0
  271. package/dist/webhook/builders/common.d.ts +3 -0
  272. package/dist/webhook/builders/webhook-builder.d.ts +1 -1
  273. package/dist/webhook/builders/webhook-builder.js +1 -1
  274. package/package.json +5 -8
  275. package/schema/domain-spec.json +24 -0
  276. package/dist/configurator/assistant/index.d.ts +0 -1
  277. package/dist/configurator/assistant/index.js +0 -1
  278. package/dist/configurator/assistant/use-assistant-chat.d.ts +0 -20
  279. package/dist/configurator/assistant/use-assistant-chat.js +0 -1
  280. package/dist/domain/core/json-schema.js +0 -1
  281. package/dist/extras/assistant/AssistantChat.d.ts +0 -6
  282. package/dist/extras/assistant/AssistantChat.js +0 -1
  283. package/dist/extras/assistant/index.d.ts +0 -1
  284. package/dist/extras/assistant/index.js +0 -1
  285. package/dist/phoenix/application-spec/generate-assistant-prompt.js +0 -1
  286. /package/dist/domain/{core/enhanced-json-schema.js → application/assistant/assistant-manifest.js} +0 -0
  287. /package/dist/domain/{core/schema-validator.js → application/assistant/assistant-resolved-manifest.js} +0 -0
  288. /package/dist/domain/core/{schema-validator-ajv.d.ts → schema/create-ajv-schema-validator.d.ts} +0 -0
  289. /package/dist/domain/core/{schema-validator-ajv.js → schema/create-ajv-schema-validator.js} +0 -0
  290. /package/dist/domain/core/{schema-validator-csp.d.ts → schema/create-csp-schema-validator.d.ts} +0 -0
  291. /package/dist/domain/core/{schema-validator-csp.js → schema/create-csp-schema-validator.js} +0 -0
  292. /package/dist/domain/core/{enhanced-json-schema.d.ts → schema/enhanced-json-schema.d.ts} +0 -0
  293. /package/dist/domain/core/{json-schema.d.ts → schema/extended-schema-validator.d.ts} +0 -0
  294. /package/dist/domain/core/{schema-validator.d.ts → schema/schema-validator.d.ts} +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']
@@ -1 +1 @@
1
- import{AnimationSystem as e,AssistantSystem as t,CameraControlSystem as n,CameraSystem as o,CanvasSystem as r,DragAndDropSystem as s,ExportSystem as g,GraphQLSystem as i,ImageRenderingSystem as a,LayoutSystem as m,SketchingSystem as S}from"./systems/index.js";export const createConfiguratorExtensionSelectors=y=>{let{domainContextSelectors:u,specSelectors:w,domainServicesSelectors:C,accessSelectors:c,commonServicesSelectors:f}=y,l={getConfigurationId:()=>c.getConfiguratorConfigurationId(),getAuthorizedClient:()=>f.getConfiguratorAuthorizedClient(),domainContextSelectors:u,domainServicesSelectors:C,specSelectors:w},d={getSystems:()=>G,getCanvasSystem:()=>p,getCameraControlSystem:()=>A,getAnimationSystem:()=>h,getDragAndDropSystem:()=>E,getImageRenderingSystem:()=>v,getLayoutSystem:()=>L,getSketchingSystem:()=>j,getExportSystem:()=>I,getCameraSystem:()=>k,getGraphQLSystem:()=>z,getAssistantSystem:()=>D},x={...l,configuratorExtensionSelectors:d},p=new r(l),A=new n({configuratorExtensionSelectors:d}),E=new s(x),h=new e(l),I=new g(x),z=new i(l),D=new t({configuratorExtensionSelectors:d,domainContextSelectors:u,specSelectors:w}),L=new m(l),j=new S(x),k=new o(x),v=new a(x),G={cameraControlSystem:A,layoutSystem:L,sketchingSystem:j,dragAndDropSystem:E,canvasSystem:p,cameraSystem:k,exportSystem:I,imageRenderingSystem:v,animationSystem:h,graphQLSystem:z,assistantSystem:D};return d};
1
+ import{AnimationSystem as e,AssistantSystem as t,CameraControlSystem as n,CameraSystem as o,CanvasSystem as r,DragAndDropSystem as s,ExportSystem as g,GraphQLSystem as i,ImageRenderingSystem as a,LayoutSystem as m,SketchingSystem as S}from"./systems/index.js";export const createConfiguratorExtensionSelectors=y=>{let{domainContextSelectors:u,specSelectors:w,domainServicesSelectors:C,accessSelectors:c,commonServicesSelectors:f}=y,d={getConfigurationId:()=>c.getConfiguratorConfigurationId(),getAuthorizedClient:()=>f.getConfiguratorAuthorizedClient(),domainContextSelectors:u,domainServicesSelectors:C,specSelectors:w},l={getSystems:()=>G,getCanvasSystem:()=>p,getCameraControlSystem:()=>A,getAnimationSystem:()=>E,getDragAndDropSystem:()=>h,getImageRenderingSystem:()=>v,getLayoutSystem:()=>L,getSketchingSystem:()=>j,getExportSystem:()=>I,getCameraSystem:()=>k,getGraphQLSystem:()=>z,getAssistantSystem:()=>D},x={...d,configuratorExtensionSelectors:l},p=new r(d),A=new n({configuratorExtensionSelectors:l}),h=new s(x),E=new e(d),I=new g(x),z=new i(d),D=new t(x),L=new m(d),j=new S(x),k=new o(x),v=new a(x),G={cameraControlSystem:A,layoutSystem:L,sketchingSystem:j,dragAndDropSystem:h,canvasSystem:p,cameraSystem:k,exportSystem:I,imageRenderingSystem:v,animationSystem:E,graphQLSystem:z,assistantSystem:D};return l};
@@ -1,35 +1,180 @@
1
1
  import type { AnyClientTool } from '@tanstack/ai';
2
- import type { DomainContextSelectors, InitializableSystem, SpecSelectors } from '#package/domain';
2
+ import { type UIMessage } from '@tanstack/ai-client';
3
+ import { type ObservableWithLastValue } from '@salsita-ai/common/utils';
4
+ import type { AuthorizedPhoenixApiClient } from '#package/client';
5
+ import type { DomainContextSelectors, DomainServicesSelectors, InitializableSystem, SpecSelectors } from '#package/domain';
3
6
  import type { ConfiguratorExtensionSelectors } from '../../selectors.js';
4
7
  /** A tool of the assistant that the model calls and the browser runs, as the chat client accepts it. */
5
8
  export type AssistantClientTool = AnyClientTool;
6
9
  /**
7
10
  * Constructor context of an `AssistantSystem`: whole selector objects, like its peers take them, so
8
- * the tools reach the store, the session mode and the `GraphQLSystem` when they are called.
11
+ * the tools reach the store, the session mode and the `GraphQLSystem` when they are called, and the
12
+ * chat reaches the server of the current session when it sends a request.
9
13
  */
10
14
  export interface AssistantSystemContext {
11
15
  readonly configuratorExtensionSelectors: ConfiguratorExtensionSelectors;
12
16
  readonly domainContextSelectors: DomainContextSelectors;
17
+ readonly domainServicesSelectors: DomainServicesSelectors;
13
18
  readonly specSelectors: SpecSelectors;
19
+ readonly getConfigurationId: () => string;
20
+ readonly getAuthorizedClient: () => AuthorizedPhoenixApiClient<any, any, any>;
14
21
  }
15
22
  /**
16
- * Owns the client tools of the conversational assistant: `getBrowserDetails`, `query` and `apply`.
17
- * They are built once, over the runtime's selectors, and offered only by a configurator whose
18
- * application spec has an `assistant` section, so a configurator without one has no tools to
19
- * register with a chat.
23
+ * The conversation with the assistant as the panel paints it. One value is published per change, so
24
+ * it changes with every chunk of a streaming reply.
25
+ */
26
+ export interface AssistantChatSnapshot {
27
+ /** The thread as painted: hydrated from the server, then streamed. */
28
+ readonly messages: ReadonlyArray<UIMessage>;
29
+ /** True while a round of a reply streams or its browser tools run; false in the pause before the next round. */
30
+ readonly isLoading: boolean;
31
+ readonly error: Error | undefined;
32
+ /**
33
+ * HTTP status of the latest request the server answered with a failure, for telling a refusal from
34
+ * a dropped connection when `error` is set. Nothing when the latest answered request succeeded or
35
+ * the server was never reached.
36
+ */
37
+ readonly failedStatus: number | undefined;
38
+ /** False when the server said this session may read the thread but not add to it. */
39
+ readonly isContinuable: boolean;
40
+ /** False until the first request of the chat, the thread read, was answered or failed. */
41
+ readonly isLoaded: boolean;
42
+ }
43
+ /**
44
+ * The built-in assistant panel as a layout and the toolbar button see it: whether it is open, and
45
+ * the few facts about it they render. It changes only when one of those does.
46
+ */
47
+ export interface AssistantPanelSnapshot {
48
+ readonly open: boolean;
49
+ /** True when a reply finished while the panel was closed and the panel was not opened since. */
50
+ readonly hasUnreadReply: boolean;
51
+ /** True while the message input has focus; a phone layout gives the panel the whole screen then. */
52
+ readonly isInputFocused: boolean;
53
+ }
54
+ /**
55
+ * Owns the conversational assistant of a configurator: its client tools (`getBrowserDetails`,
56
+ * `query` and `apply`), the chat with the server, the state of the built-in panel, and the record
57
+ * of what changed in the configuration since the agent last acted, which every user message carries.
58
+ *
59
+ * The server owns the thread, so the chat keeps nothing in browser storage: its client hydrates
60
+ * from the server and rejoins a reply that is still streaming.
61
+ *
62
+ * WORKAROUND: the runtime cannot tell a system that its configuration was left, and a system cannot
63
+ * observe the application spec. Until it can do both, the chat is started and ended from outside,
64
+ * through {@link AssistantSystem.activate}; see there for what that costs.
20
65
  */
21
66
  export declare class AssistantSystem implements InitializableSystem {
22
67
  private readonly _context;
23
68
  private readonly _tools;
24
- private _isInitialized;
69
+ private readonly _chat;
70
+ private readonly _panel;
71
+ /** Identity of the current `activate()` call; nothing while the chat is not active. */
72
+ private _activation;
73
+ /** The chat of the current activation; nothing while no chat is active. */
74
+ private _current;
75
+ /**
76
+ * Chats that have ended while their reply was still running and are finishing it in the
77
+ * background. Each leaves the set when its reply ends or when a new chat takes its thread over.
78
+ */
79
+ private readonly _finishing;
80
+ private readonly _recorder;
81
+ /** The recorder's subscription to the committed emissions of the store; made by the first `initialize()`. */
82
+ private _recording;
25
83
  constructor(_context: AssistantSystemContext);
84
+ /** The conversation. It never completes, and holds the empty chat whenever no chat is active. */
85
+ readonly chat$: ObservableWithLastValue<AssistantChatSnapshot>;
86
+ /** The state of the built-in panel. It never completes. */
87
+ readonly panel$: ObservableWithLastValue<AssistantPanelSnapshot>;
88
+ /**
89
+ * A new configuration load: the chat of the previous one is deactivated and both observables go
90
+ * back to their empty values. An activation that is still held outlives it and gets the chat of
91
+ * the new load, because the page that holds it can be mounted before this runs: a configuration
92
+ * that is entered again renders its page at once and initializes from an effect after the page's.
93
+ *
94
+ * Accepted cost: on such a re-entry the thread is read twice. The page's `activate()` has already
95
+ * created a client and started its read when this runs, and that client is replaced here, because
96
+ * the system cannot tell that it was created for the load that is only now being initialized.
97
+ *
98
+ * The change recorder starts over from the loaded state, so the first message after a load says
99
+ * that the changes are unavailable. The store is retained across loads and has already emitted the
100
+ * loaded state when this runs, so one subscription serves every load.
101
+ */
26
102
  initialize: () => void;
27
103
  /**
28
- * The tools to register with the chat: all of them when the application spec has an `assistant`
29
- * section, none otherwise or before the first initialization. The section is read on every call
30
- * and not in `initialize()`, because editor hot reload adds or removes it by reconciliation alone.
31
- * Each answer is always the same array instance, so the getter is a valid snapshot for a hook
32
- * subscribed to the runtime.
104
+ * Starts the chat of the loaded configuration: creates the client, which reads the thread from the
105
+ * server and rejoins a reply that is still running. The returned function ends it.
106
+ *
107
+ * WORKAROUND, to be replaced once the runtime has teardown and spec observation for systems. Two
108
+ * things a system cannot learn by itself are decided by the caller, the loaded configurator page:
109
+ *
110
+ * - Whether the application spec has an `assistant` section, also after editor hot reload added or
111
+ * removed it. The page calls this only while the section is there; the system does not check.
112
+ * - That the user left the configuration. No `initialize()` follows a route change, so without the
113
+ * returned function the chat would go on working on a configuration nobody looks at.
114
+ *
115
+ * Ending the chat does not cut a running reply off: it finishes in the background, where every
116
+ * tool call it still makes is answered with a refusal that tells the model to stop, and it no
117
+ * longer reaches `chat$` or `panel$`. A tool call that is already running when the chat ends is
118
+ * not interrupted, so an `apply` that has started may still commit. The background reply keeps
119
+ * the configuration and the authorized client it started with.
120
+ *
121
+ * The background reply ends early when a new chat starts for the same configuration, which is
122
+ * what opening the configuration again does: see `_takeOverThread`.
123
+ */
124
+ activate: () => (() => void);
125
+ /**
126
+ * Sends a user message with the record of what changed in the configuration since the agent last
127
+ * acted, which the server puts in front of the message for the model. The record is taken only
128
+ * when there is a chat to send it on, because taking it moves its baseline.
129
+ *
130
+ * A thread can end in a tool call that nothing will answer: its reply parked while no page was
131
+ * open, or the page that ran the tool was left before the result was sent. The client refuses to
132
+ * send while it waits on such a call, so the wait is given up first, and the server records for
133
+ * the model that the call got no result.
134
+ *
135
+ * It never rejects: a message the client could not send is reported as the error of the chat.
136
+ */
137
+ send: (content: string) => Promise<void>;
138
+ /**
139
+ * Stops the reply on both sides. Closing the stream alone keeps the server run going, because a
140
+ * closed connection is also how a reload looks and a reload must be able to rejoin the run.
141
+ */
142
+ stop: () => Promise<void>;
143
+ /**
144
+ * Loads the thread from the server again, rejoining a reply that is still running there. It never
145
+ * sends a message again, because the server may already hold it; a message that did not reach the
146
+ * server is therefore gone from the thread and has to be written again.
147
+ */
148
+ reloadThread: () => void;
149
+ setOpen: (open: boolean) => void;
150
+ setInputFocused: (isInputFocused: boolean) => void;
151
+ private _committedState;
152
+ private _patchPanel;
153
+ /**
154
+ * Disconnects every chat that is still finishing a reply on the thread of the given configuration,
155
+ * so the chat that is about to start is the only one on it.
156
+ *
157
+ * Two clients on one thread would both follow the same server run: the new one rejoins it when it
158
+ * reads the thread. Both would then handle the run's next tool call, the old one with a refusal
159
+ * and the new one for real, and both would send the result back, of which the server accepts one.
160
+ * The model could be told that nothing was run about a change that was made.
161
+ *
162
+ * Stopping a client closes its stream in the browser and cancels nothing on the server: a run that
163
+ * is still producing goes on there and the new chat rejoins it. The stopped client also drops the
164
+ * result of a tool call that is still running in it, and any continuation it has not sent yet. Such
165
+ * a call still finishes, so an `apply` may commit, but the server never gets its result: the run is
166
+ * parked on the call with nothing running for the new chat to rejoin, and the thread waits on it
167
+ * until the user's next message gives the wait up; see `send`.
168
+ *
169
+ * A chat that finishes a reply for another configuration is on another thread and is left alone.
170
+ */
171
+ private _takeOverThread;
172
+ private _startClient;
173
+ /**
174
+ * Lets go of the current chat and puts the empty chat in its place. The client itself is left as
175
+ * it is: whether it finishes its reply or is cut off is the caller's decision.
33
176
  */
34
- getTools: () => readonly AssistantClientTool[];
177
+ private _retireChat;
178
+ /** Ends the current chat without cutting its reply off. */
179
+ private _endChat;
35
180
  }
@@ -1 +1 @@
1
- import{createBrowserDetailsClientTool as t}from"./browser-details.js";import{createApplyClientTool as e,createQueryClientTool as s}from"./graphql-tools.js";let i=[];export class AssistantSystem{_context;_tools;_isInitialized=!1;constructor(i){this._context=i;let{configuratorExtensionSelectors:o,domainContextSelectors:l}=i,r={getGraphQLSystem:()=>o.getGraphQLSystem(),getStoreSystem:()=>l.getStoreSystem(),getActiveMode:()=>l.getActiveMode()};this._tools=[t(),s(r),e(r)]}initialize=()=>{this._isInitialized=!0};getTools=()=>this._isInitialized&&this._context.specSelectors.getAssistant()?this._tools:i}
1
+ import{ChatClient as t,fetchServerSentEvents as e}from"@tanstack/ai-client";import{BehaviorSubject as i}from"rxjs";import{skip as s}from"rxjs/operators";import{isShallowEqual as a}from"@salsita-ai/common/utils";import{createBrowserDetailsClientTool as r}from"./browser-details.js";import{ChangeRecorder as n}from"./change-recorder.js";import{createApplyClientTool as o,createQueryClientTool as c}from"./graphql-tools.js";let l=Object.freeze({messages:Object.freeze([]),isLoading:!1,error:void 0,failedStatus:void 0,isContinuable:!0,isLoaded:!1}),h=Object.freeze({open:!1,hasUnreadReply:!1,isInputFocused:!1}),d=Object.freeze({}),g=Object.freeze({results:Object.freeze([]),committed:!1,sideEffects:Object.freeze([]),message:"Nothing was run, because the user closed the configurator while this reply was being written. Do not call any more tools in this reply and end it now. The tools work again as soon as the user writes the next message."}),u=t=>{if(t.getError())return!0;let e=t.getMessages().at(-1)?.parts.at(-1);return e?.type!=="tool-call"&&e?.type!=="tool-result"};export class AssistantSystem{_context;_tools;_chat=new i(l);_panel=new i(h);_activation=null;_current=null;_finishing=new Set;_recorder;_recording=null;constructor(t){this._context=t;let{configuratorExtensionSelectors:e,domainContextSelectors:i,domainServicesSelectors:s,specSelectors:a}=t;this._recorder=new n({maxEntities:30},{readers:{selectedEntityId:t=>i.getNavigationSystem().getActiveSelectionState(t),navigationState:t=>i.getNavigationSystem().getActiveNavigationState(t),viewState:t=>i.getNavigationSystem().getActiveViewState(t),toolState:t=>i.getNavigationSystem().getActiveToolState(t)},getExposedFields:()=>a.getAssistant()?.fields??d,resolveLocalizable:t=>s.getResolveLocalizable()(t)});let l={getGraphQLSystem:()=>e.getGraphQLSystem(),getStoreSystem:()=>i.getStoreSystem(),getActiveMode:()=>i.getActiveMode(),clearChanges:()=>this._recorder.clear(this._committedState())};this._tools=[r(),c(l),o(l)]}chat$=this._chat;panel$=this._panel;initialize=()=>{let{committed:t}=this._context.domainContextSelectors.getStoreSystem().stateSlices;this._recording??=t.pipe(s(1)).subscribe(this._recorder.record),this._recorder.reset(t.value.state),this._endChat(),this._patchPanel(h),this._activation&&this._startClient()};activate=()=>{this._endChat();let t={};return this._activation=t,this._startClient(),()=>{this._activation===t&&(this._activation=null,this._endChat())}};send=async t=>{let e=this._current;if(!e)return;let{client:i}=e;i.getIsLoading()||null===i.getResumeState()||i.stop();let s={changes:this._recorder.take(this._committedState())};try{await i.sendMessage({content:t,metadata:s})}catch(i){let t=i instanceof Error?i:Error(String(i));e.generation.active&&this._chat.next({...this._chat.value,error:t}),this._context.domainServicesSelectors.getLogger().error("The assistant message could not be sent",{},t)}};stop=async()=>{let t=this._current;if(!t)return;let e=t.client.getCurrentRunId();if(t.client.stop(),null!=e)try{let i=t.getConnection();await fetch(`${i.url}/runs/${encodeURIComponent(e)}/cancel`,{method:"POST",headers:await i.headers()})}catch(t){this._context.domainServicesSelectors.getLogger().warn("Could not cancel the assistant run on the server",{error:t})}};reloadThread=()=>{if(!this._activation)return;let t=this._retireChat();t?.client.stop(),t?.dispose(),this._recorder.reset(this._committedState()),this._startClient()};setOpen=t=>{this._patchPanel(t?{open:t,hasUnreadReply:!1}:{open:t,isInputFocused:!1})};setInputFocused=t=>{this._patchPanel({isInputFocused:t})};_committedState=()=>this._context.domainContextSelectors.getStoreSystem().stateSlices.committed.value.state;_patchPanel=t=>{let e={...this._panel.value,...t};a(e,this._panel.value)||this._panel.next(e)};_takeOverThread=t=>{for(let e of this._finishing)e.configurationId===t&&(e.client.stop(),e.dispose())};_startClient=()=>{let i={active:!0},s=this._context.getConfigurationId();this._takeOverThread(s);let r=this._context.getAuthorizedClient(),n=()=>r.getAssistantChatConnection(s),o=t=>{if(!i.active)return;let e={...this._chat.value,...t};a(e,this._chat.value)||this._chat.next(e)},c=async(t,e)=>{let i=await fetch(t,e).finally(()=>o({isLoaded:!0})),s=i.headers.get("x-assistant-thread-continuable");return o({failedStatus:i.ok?void 0:i.status,...null!=s&&{isContinuable:"false"!==s}}),i},l=async()=>({headers:await n().headers(),fetchClient:c}),h=e(()=>n().url,l),d=e(()=>`${n().url}/runs`,l),_=this._tools.map(t=>({...t,execute:(e,s)=>i.active?t.execute?.(e,s):g})),m=new t({threadId:`assistant:${s}`,connection:{...h,joinRun:d.joinRun},persistence:!0,history:{pageSize:50},tools:_,onMessagesChange:t=>o({messages:t}),onLoadingChange:t=>{let e=i.active&&this._chat.value.isLoading;o({isLoading:t}),!t&&u(m)&&(i.active?e&&!this._panel.value.open&&this._patchPanel({hasUnreadReply:!0}):v())},onErrorChange:t=>{i.active&&t!==this._chat.value.error&&(o({error:t}),t&&this._context.domainServicesSelectors.getLogger().error("The assistant request failed",{status:this._chat.value.failedStatus},t))}}),p=!1,v=()=>{p||(p=!0,this._finishing.delete(S),m.dispose())},S={client:m,configurationId:s,generation:i,getConnection:n,dispose:v};this._current=S,m.attach()};_retireChat=()=>{let t=this._current;return this._current=null,t&&(t.generation.active=!1),this._chat.value!==l&&this._chat.next(l),t};_endChat=()=>{let t=this._retireChat();if(t){if(!t.client.getIsLoading()&&u(t.client))return void t.dispose();this._finishing.add(t)}}}
@@ -0,0 +1,85 @@
1
+ import type { Localizable } from '@salsita-ai/common/utils';
2
+ import { type $DomainEntity, type AssistantManifest, type DomainEntity, type DomainState, type StateEmission } from '#package/domain';
3
+ type AnyDomainEntity = DomainEntity<string>;
4
+ type AnyDomainState = DomainState<AnyDomainEntity>;
5
+ type AnyStateEmission = StateEmission<AnyDomainEntity, Record<string, $DomainEntity<AnyDomainEntity>>>;
6
+ /**
7
+ * What the change record compares besides the entities: the values the `Query` root of the
8
+ * assistant's schema exposes as `selectedEntity` and `navigation`, read off a state.
9
+ */
10
+ export interface ChangeRecorderStateReaders {
11
+ readonly selectedEntityId: (state: AnyDomainState) => string | undefined;
12
+ readonly navigationState: (state: AnyDomainState) => string | undefined;
13
+ readonly viewState: (state: AnyDomainState) => string | undefined;
14
+ readonly toolState: (state: AnyDomainState) => string | undefined;
15
+ }
16
+ /** What a {@link ChangeRecorder} reads from the running configurator. */
17
+ export interface ChangeRecorderContext {
18
+ readonly readers: ChangeRecorderStateReaders;
19
+ /**
20
+ * The field table of the assistant manifest: per entity type of the schema, each exposed field
21
+ * name with the stored field or expression it reads. The record lists nothing the table does not
22
+ * hold, so the agent is shown only what it could also query. Read at every take, because editor
23
+ * hot reload replaces the manifest.
24
+ */
25
+ readonly getExposedFields: () => AssistantManifest['fields'];
26
+ readonly resolveLocalizable: (message: Localizable) => string;
27
+ }
28
+ export interface ChangeRecorderProps {
29
+ /** More differing entities than this are counted and not listed. */
30
+ readonly maxEntities: number;
31
+ }
32
+ /**
33
+ * Records what changed in the committed configuration since the assistant agent last acted, and
34
+ * prints it as the change record a user message carries to the agent.
35
+ *
36
+ * The record is a net diff: the committed state at the last take or clear is kept as the baseline
37
+ * and compared with the current one, so a value that was changed and changed back is not listed.
38
+ * Of the emissions in between, only the last update that touched each entity and each entity field
39
+ * is kept, to say why a line is there. Selection and navigation are read off the two states and
40
+ * never from their updates.
41
+ *
42
+ * Only what the assistant manifest exposes is listed: entities of the types its schema has, and of
43
+ * their stored fields the exposed ones, under their exposed names and localized like the schema
44
+ * returns them. A change of anything else is not in the record.
45
+ */
46
+ export declare class ChangeRecorder {
47
+ private readonly _props;
48
+ private readonly _context;
49
+ private _baseline;
50
+ /** True from a reset until the first take: what happened before the baseline is not known. */
51
+ private _isUnavailable;
52
+ private readonly _touches;
53
+ private _lastReset;
54
+ private _wasUndoneOrRedone;
55
+ constructor(_props: ChangeRecorderProps, _context: ChangeRecorderContext);
56
+ /** Starts over from this committed state; the next take reports `unavailable`. */
57
+ reset: (state: AnyDomainState) => void;
58
+ /** Records one committed emission: the last update that touched each entity and field, or the reset. */
59
+ record: (emission: AnyStateEmission) => void;
60
+ /** The change record since the last take or clear, as the prompt describes it; moves the baseline. */
61
+ take: (state: AnyDomainState) => string;
62
+ /** Forgets what was recorded and makes this committed state the baseline. */
63
+ clear: (state: AnyDomainState) => void;
64
+ private _touchesOf;
65
+ private _touchFields;
66
+ private _print;
67
+ private _diffStates;
68
+ /** Added and modified entities in the order of the current state, then the deleted ones in the order they had. */
69
+ private _diffEntities;
70
+ /**
71
+ * The lines of the exposed stored fields that differ, in manifest order. A field no update
72
+ * touched since its entity was created or replaced under an id that existed before is explained
73
+ * by that creation.
74
+ */
75
+ private _diffFields;
76
+ /** Why a line is in the record; a line no recorded update explains was left by a reset. */
77
+ private _comment;
78
+ /**
79
+ * What the agent is told about an update, else what the user was told, else the update tag. As
80
+ * for `sideEffects`, an `agentHint` replaces the `hint` whatever it holds: `null` or empty text
81
+ * hides the wording from the agent, not the change, so the tag stands in.
82
+ */
83
+ private _explain;
84
+ }
85
+ export {};
@@ -0,0 +1 @@
1
+ import{match as e}from"ts-pattern";import{isUndoRedoReset as t}from"#package/domain";import{localize as i}from"../graphql-system/graphql-system.js";let s=[["selected","selectedEntityId"],["navigationState","navigationState"],["viewState","viewState"],["toolState","toolState"]],n=e=>e.length>80?`${e.slice(0,80)}…`:e,a=e=>void 0===e||""===e?"none":e,r=e=>new Map(Object.entries(e)),l=["id","type"];export class ChangeRecorder{_props;_context;_baseline;_isUnavailable=!0;_touches=new Map;_lastReset;_wasUndoneOrRedone=!1;constructor(e,t){this._props=e,this._context=t}reset=e=>{this.clear(e),this._isUnavailable=!0};record=i=>{if("reset"===i.kind){this._touches.clear(),this._lastReset=t(i)?"undo/redo":"reset",this._wasUndoneOrRedone||="undo/redo"===this._lastReset;return}for(let t of i.updates)e(t).with({kind:"createDomainEntity"},e=>{this._touchesOf(e.entityId).created=e}).with({kind:"deleteEntity"},e=>{let t=this._touchesOf(e.entityId);t.fields.clear(),t.deleted=e}).with({kind:"modifyDomainEntity"},e=>{this._touchFields(e.entityId,Object.keys(e.stateDelta),e)}).with({kind:"replaceDomainEntity"},e=>{let{replacementEntity:t}=e;this._touchesOf(e.entityId).fields.clear(),this._touchesOf(e.entityId).deleted=e,this._touchesOf(t.id).created=e}).with({kind:"createEphemeralRecord"},{kind:"modifyEphemeralRecord"},{kind:"deleteEphemeralRecord"},()=>{}).exhaustive()};take=e=>{let t=this._print(e);return this.clear(e),this._isUnavailable=!1,t};clear=e=>{this._baseline=e,this._touches.clear(),this._lastReset=void 0,this._wasUndoneOrRedone=!1};_touchesOf=e=>{let t=this._touches.get(e);if(t)return t;let i={created:void 0,deleted:void 0,fields:new Map};return this._touches.set(e,i),i};_touchFields=(e,t,i)=>{let s=this._touchesOf(e);for(let e of t)s.fields.set(e,i)};_print=e=>{let t=this._baseline;if(this._isUnavailable||!t)return"[changes: unavailable]";let{lines:i,count:s}=this._diffEntities(t,e);if(s>this._props.maxEntities)return`[changes: too many (${s})]`;let n=[...this._diffStates(t,e),...i];return 0===n.length?"[changes: none]":["[changes]",...this._wasUndoneOrRedone?["reset: undo/redo"]:[],...n].join("\n")};_diffStates=(e,t)=>s.flatMap(([i,s])=>{let n=a(this._context.readers[s](e)),r=a(this._context.readers[s](t));return n===r?[]:[`${i}: ${n} -> ${r}`]});_diffEntities=(e,t)=>{let i=this._context.getExposedFields(),s=new Map(e.entities.map(e=>[e.id,e])),n=new Set(t.entities.map(e=>e.id)),a=t.entities.flatMap(e=>{let t=i[e.type],n=s.get(e.id);if(!t)return[];if(!n)return[[`A ${e.id}${this._comment(this._touches.get(e.id)?.created)}`]];let a=n===e?[]:this._diffFields(n,e,t);return a.length>0?[[`M ${e.id}`,...a]]:[]}),r=e.entities.filter(e=>i[e.type]&&!n.has(e.id)).map(e=>[`D ${e.id}${this._comment(this._touches.get(e.id)?.deleted)}`]);return{lines:[...a,...r].flat(),count:a.length+r.length}};_diffFields=(e,t,s)=>{let a=r(e),d=r(t),o=this._touches.get(t.id);return Object.entries(s).flatMap(([e,{source:t,localized:s}])=>{if(!(!t.startsWith("$")&&!l.includes(t)))return[];let r=e=>{let t;return void 0===(t=s?i(e,this._context.resolveLocalizable):e)?"undefined":JSON.stringify(t)},h=r(a.get(t)),c=r(d.get(t));return h===c?[]:[` ${e}: ${n(h)} -> ${n(c)}${this._comment(o?.fields.get(t)??o?.created)}`]})};_comment=e=>e?` # ${this._explain(e).replace(/\s*\n\s*/g," ")}`:this._lastReset?` # ${this._lastReset}`:"";_explain=({agentHint:e,hint:t,updateTag:i})=>void 0!==e?null===e||""===e?i:e:t?this._context.resolveLocalizable(t):i}
@@ -6,7 +6,7 @@ import type { GraphQLSystem } from '../graphql-system/graphql-system.js';
6
6
  * that moment, never against ones captured when its reply began streaming.
7
7
  */
8
8
  export interface AssistantToolDependencies {
9
- readonly getGraphQLSystem: () => Pick<GraphQLSystem, 'prepare' | 'execute'>;
9
+ readonly getGraphQLSystem: () => Pick<GraphQLSystem, 'prepare' | 'execute' | 'readSideEffects'>;
10
10
  readonly getStoreSystem: () => {
11
11
  readonly isInitialized: boolean;
12
12
  readonly stateSlices: {
@@ -18,11 +18,14 @@ 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
24
26
  * committed state and drops their emissions, so mutations in the list show a hypothetical state and
25
- * the configuration, the undo stack and the saved revision stay as they were.
27
+ * the configuration, the undo stack and the saved revision stay as they were. The side effects of
28
+ * the dropped emissions are still reported, as what the changes would do.
26
29
  */
27
30
  export declare const createQueryClientTool: (dependencies: AssistantToolDependencies) => import("@tanstack/ai").ClientTool<{
28
31
  type: string;
@@ -88,7 +91,9 @@ export declare const createQueryClientTool: (dependencies: AssistantToolDependen
88
91
  /**
89
92
  * Browser implementation of the assistant's `apply` tool: hands the operations to
90
93
  * `GraphQLSystem.execute`, which commits their changes as one undo step, and returns its result,
91
- * 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
92
97
  * session may change the configuration; the check lives here and not in the `GraphQLSystem`, whose
93
98
  * other caller, the editor panel, has its own rules.
94
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}),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();return n.isInitialized?i({results:(await e.getGraphQLSystem().prepare(n.stateSlices.committed.value.state,o.operations)).map(({result:e})=>e),committed:!1}):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.")});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)});
@@ -47,12 +47,14 @@ export declare const createEntityMeta: (source: EntityMetaSource, context: Entit
47
47
  root: null;
48
48
  changedEntities: never[];
49
49
  deletedEntityIds: never[];
50
+ sideEffects: never[];
50
51
  errors: readonly DryRunError[];
51
52
  } | {
52
53
  ok: boolean;
53
54
  root: unknown;
54
55
  changedEntities: {}[];
55
56
  deletedEntityIds: DomainEntityId<string>[];
57
+ sideEffects: readonly string[];
56
58
  errors: never[];
57
59
  } | null;
58
60
  }[];
@@ -71,12 +73,14 @@ export declare const createEntityMeta: (source: EntityMetaSource, context: Entit
71
73
  root: null;
72
74
  changedEntities: never[];
73
75
  deletedEntityIds: never[];
76
+ sideEffects: never[];
74
77
  errors: readonly DryRunError[];
75
78
  } | {
76
79
  ok: boolean;
77
80
  root: unknown;
78
81
  changedEntities: {}[];
79
82
  deletedEntityIds: DomainEntityId<string>[];
83
+ sideEffects: readonly string[];
80
84
  errors: never[];
81
85
  } | null;
82
86
  }[];
@@ -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";let o=e=>({ok:!1,root:null,changedEntities:[],deletedEntityIds:[],errors:e}),d=(e,{state:t},{recipes:i,prepareStateEmission:r,find$Entity:n})=>{let{validity:s,state:a}=r(e,t,"committed");if(s.valid){let e=new Map(t.entities.map(e=>[e.id,e])),i=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=>!i.has(e)),errors:[]}}return o("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=(l,c)=>{let p=e=>()=>t(c.manifest,e,l.entity.type).flatMap(t=>{let i=s(e,t,l.entity.id,l.state,c.recipes);return i?[((e,t,i)=>{let{group:n,label:s,description:a,recipes:l}=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:l.map(n=>((e,t,i,n)=>{let{key:s,item:a}=e,{resolveLocalizable:l}=n.recipes;return{key:s,name:l(a.title),description:void 0===a.description?null:l(a.description),imageUrl:void 0===a.thumbnailUrl?null:l(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?o([{type:"uncaught",entityId:null,message:a}]):d(s,i,n)})(e,t,i,n):null}})(n,e,t,i))}})(i,l,c)]:[]});return{...Object.fromEntries(e(c.manifest,l.entity.type).map(e=>[e.edgeName,()=>n(e,l.entity.id,l.state,c.recipes)?.map(t=>({...t,dryRun:()=>e.dryRuns?(({field:e},{value:t},r,n)=>{let{entity:s}=r,l=Object.entries(Object.entries(n.manifest.writableFields??{}).find(([e])=>e===s.type)?.[1]??{}).find(([t])=>t===e)?.[1];if(void 0===l)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={[l]:t},u=c?n.validateEntity({...c,...p}):{success:!0};return u.success?d([a.DomainEntityModification({entityId:s.id,stateDelta:p,updateTag:i})],r,n):o([{type:"uncaught",entityId:s.id,message:`Writing ${JSON.stringify(t)} to "${e}" would make "${s.id}" an invalid ${s.type}: ${u.errors.join("; ")}.${e===l?"":` The message names the stored property: ${e} is stored as ${l}.`} The option comes from the configurator and cannot be corrected from here, so do not write it.`}])})(e,t,l,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 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,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 {
@@ -26,13 +27,22 @@ export interface PreparedOperation {
26
27
  /**
27
28
  * What {@link GraphQLSystem.execute} returns: the results of the operations as prepared from the
28
29
  * committed state, whether their changes were committed as one undo step, and, when the operations
29
- * succeeded but their changes were not committed, the reason addressed to the caller.
30
+ * succeeded but their changes were not committed, the reason addressed to the caller. `sideEffects`
31
+ * describes the prepared changes whether or not they were committed, so a caller can weigh a held
32
+ * commit before the user approves it.
30
33
  */
31
34
  export interface GraphQLExecution {
32
35
  readonly results: readonly ExecutionResult[];
33
36
  readonly committed: boolean;
34
37
  readonly message?: string;
38
+ /** What the configurator did, or would do, beyond what the operations asked for, in applied order. */
39
+ readonly sideEffects: readonly string[];
35
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;
36
46
  /**
37
47
  * Executes GraphQL operations against the schema generated from the application spec `assistant`
38
48
  * manifest, resolving it against the committed domain state. Agent-independent: the assistant's
@@ -75,6 +85,11 @@ export declare class GraphQLSystem {
75
85
  * "not run" error instead.
76
86
  */
77
87
  prepare: (originalState: AnyDomainState, operations: readonly GraphQLOperation[]) => Promise<readonly PreparedOperation[]>;
88
+ /**
89
+ * The side effects of prepared operations: the hints of every update of their emissions, as the
90
+ * agent is told them, in applied order.
91
+ */
92
+ readSideEffects: (prepared: readonly PreparedOperation[]) => readonly string[];
78
93
  private readonly _prepareAndCommit;
79
94
  /**
80
95
  * Prepares the operations from the committed state and commits their changes as one emission,