@salsita-ai/sdk 0.50.0-develop.9eab66c5a9 → 0.50.0-develop.9fe72d003e

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 (379) hide show
  1. package/README.md +1 -1
  2. package/dist/application-spec/core/enhanced-json-value.d.ts +2 -31
  3. package/dist/application-spec/core/enhanced-json-value.js +1 -1
  4. package/dist/application-spec/core/index.d.ts +1 -3
  5. package/dist/application-spec/core/index.js +1 -1
  6. package/dist/application-spec/core/json-schema.d.ts +2 -52
  7. package/dist/application-spec/core/markers/index.d.ts +1 -1
  8. package/dist/application-spec/core/markers/index.js +1 -1
  9. package/dist/application-spec/core/markers/msg-marker.d.ts +2 -28
  10. package/dist/application-spec/core/markers/msg-marker.js +1 -1
  11. package/dist/application-spec/core/markers/raw-eval-write-marker.d.ts +1 -1
  12. package/dist/application-spec/core/markers/raw-eval-write-marker.js +1 -1
  13. package/dist/application-spec/core/markers/raw-read-write-marker.js +1 -1
  14. package/dist/application-spec/errors/diagnostic-codes.d.ts +8 -1
  15. package/dist/application-spec/errors/diagnostic-codes.js +1 -1
  16. package/dist/application-spec/errors/diagnostic-messages.d.ts +15 -1
  17. package/dist/application-spec/errors/diagnostic-messages.js +1 -1
  18. package/dist/application-spec/generate-application/code/project-scaffolding.js +2 -2
  19. package/dist/application-spec/generate-application/code/templates/index.d.ts +2 -6
  20. package/dist/application-spec/generate-application/code/templates/index.js +1 -1
  21. package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill-bundle.d.ts +10 -0
  22. package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill-bundle.js +7 -0
  23. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +1 -1
  24. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +1 -1
  25. package/dist/application-spec/generate-application/implementations/phx-model.d.ts +1 -1
  26. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-model-runtime.d.ts +1 -2
  27. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-model-runtime.d.ts +1 -2
  28. package/dist/application-spec/generate-application/runtime/factory-data/factory-data-runtime.d.ts +1 -2
  29. package/dist/application-spec/generate-application/runtime/factory-data/recipe-defaults.d.ts +1 -1
  30. package/dist/application-spec/generate-application/runtime/factory-data/recipe-defaults.js +1 -1
  31. package/dist/application-spec/generate-application/runtime/factory-data/static-violations.d.ts +1 -2
  32. package/dist/application-spec/generate-application/runtime/factory-data/static-violations.js +1 -1
  33. package/dist/application-spec/generate-application/runtime/generate-runtime-instance.d.ts +1 -1
  34. package/dist/application-spec/generate-application/runtime/generate-runtime-instance.js +1 -1
  35. package/dist/application-spec/generate-application/runtime/sections/actions-runtime.d.ts +1 -2
  36. package/dist/application-spec/generate-application/runtime/sections/build-sdk-optic.d.ts +1 -1
  37. package/dist/application-spec/generate-application/runtime/sections/build-sdk-optic.js +1 -1
  38. package/dist/application-spec/generate-application/runtime/sections/build-user-bound-optic.d.ts +1 -1
  39. package/dist/application-spec/generate-application/runtime/sections/component-optic.d.ts +1 -2
  40. package/dist/application-spec/generate-application/runtime/sections/expression-runtime.d.ts +1 -2
  41. package/dist/application-spec/generate-application/runtime/sections/expression-runtime.js +1 -1
  42. package/dist/application-spec/generate-application/runtime/sections/generate-memo-eval-plan-runtime.d.ts +1 -2
  43. package/dist/application-spec/generate-application/runtime/sections/generate-memo-eval-plan-runtime.js +1 -1
  44. package/dist/application-spec/generate-application/runtime/sections/preset-runtime.d.ts +2 -3
  45. package/dist/application-spec/generate-application/runtime/sections/reflection-constants-runtime.d.ts +1 -1
  46. package/dist/application-spec/generate-application/runtime/spec-code/resolve-spec-code.d.ts +1 -1
  47. package/dist/application-spec/generate-application/runtime-spec/runtime-spec.d.ts +96 -31
  48. package/dist/application-spec/generate-application/runtime-spec/spec-code-id.d.ts +1 -1
  49. package/dist/application-spec/parse-application-files/merge/merged-assistant.d.ts +13 -4
  50. package/dist/application-spec/parse-application-files/merge/merged-assistant.js +1 -1
  51. package/dist/application-spec/parse-application-files/merge/merged-infra.d.ts +4 -11
  52. package/dist/application-spec/parse-application-files/merge/merged-transformers.d.ts +2 -4
  53. package/dist/application-spec/parse-application-files/parse-application-files.js +1 -1
  54. package/dist/application-spec/parse-application-files/raw-spec/raw-acl.d.ts +2 -2
  55. package/dist/application-spec/parse-application-files/raw-spec/raw-acl.js +1 -1
  56. package/dist/application-spec/parse-application-files/raw-spec/raw-admin-pages.d.ts +3 -24
  57. package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.d.ts +25 -20
  58. package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.js +1 -1
  59. package/dist/application-spec/parse-application-files/raw-spec/raw-expressions.d.ts +1 -1
  60. package/dist/application-spec/parse-application-files/raw-spec/raw-expressions.js +1 -1
  61. package/dist/application-spec/parse-application-files/raw-spec/raw-resources.d.ts +19 -64
  62. package/dist/application-spec/parse-application-files/spec/application/admin-spec/admin-pages.d.ts +3 -20
  63. package/dist/application-spec/parse-application-files/spec/application/admin-spec/states.d.ts +3 -5
  64. package/dist/application-spec/parse-application-files/spec/application/configurator-spec/states.d.ts +3 -8
  65. package/dist/application-spec/parse-application-files/spec/components/bindings/read-binding.d.ts +3 -13
  66. package/dist/application-spec/parse-application-files/spec/components/bindings/write-binding.d.ts +4 -32
  67. package/dist/application-spec/parse-application-files/spec/components/component-filter.d.ts +4 -10
  68. package/dist/application-spec/parse-application-files/spec/components/components.d.ts +3 -4
  69. package/dist/application-spec/parse-application-files/spec/components/index.d.ts +1 -2
  70. package/dist/application-spec/parse-application-files/spec/components/index.js +1 -1
  71. package/dist/application-spec/parse-application-files/spec/components/sdk-component-entry.d.ts +1 -1
  72. package/dist/application-spec/parse-application-files/spec/components/user-component-entry.d.ts +2 -3
  73. package/dist/application-spec/parse-application-files/spec/components/user-component-entry.js +1 -1
  74. package/dist/application-spec/parse-application-files/spec/components/user-components.d.ts +2 -3
  75. package/dist/application-spec/parse-application-files/spec/expressions/expression-read-types.d.ts +2 -2
  76. package/dist/application-spec/parse-application-files/spec/expressions/expressions.d.ts +7 -29
  77. package/dist/application-spec/parse-application-files/spec/expressions/index.d.ts +0 -1
  78. package/dist/application-spec/parse-application-files/spec/expressions/memo-eval-plan.d.ts +4 -71
  79. package/dist/application-spec/parse-application-files/spec/expressions/memo-eval-plan.js +1 -1
  80. package/dist/application-spec/parse-application-files/spec/expressions/user-expressions.d.ts +2 -2
  81. package/dist/application-spec/parse-application-files/spec/invariants/invariant.d.ts +5 -21
  82. package/dist/application-spec/parse-application-files/spec/invariants/invariants.d.ts +4 -14
  83. package/dist/application-spec/parse-application-files/spec/model/aliases.d.ts +3 -9
  84. package/dist/application-spec/parse-application-files/spec/model/common-types.d.ts +6 -14
  85. package/dist/application-spec/parse-application-files/spec/model/defaults.d.ts +6 -31
  86. package/dist/application-spec/parse-application-files/spec/model/entity-types.d.ts +3 -8
  87. package/dist/application-spec/parse-application-files/spec/model/model-version-key.d.ts +3 -3
  88. package/dist/application-spec/parse-application-files/spec/model/names/action-name.d.ts +3 -7
  89. package/dist/application-spec/parse-application-files/spec/model/names/alias-name.d.ts +3 -7
  90. package/dist/application-spec/parse-application-files/spec/model/names/entity-or-alias-name.d.ts +3 -8
  91. package/dist/application-spec/parse-application-files/spec/model/names/entity-type-name.d.ts +3 -8
  92. package/dist/application-spec/parse-application-files/spec/model/names/expression-name.d.ts +3 -6
  93. package/dist/application-spec/parse-application-files/spec/model/names/instance-name.d.ts +3 -7
  94. package/dist/application-spec/parse-application-files/spec/model/names/invariant-name.d.ts +3 -3
  95. package/dist/application-spec/parse-application-files/spec/model/names/shape-property-name.d.ts +3 -11
  96. package/dist/application-spec/parse-application-files/spec/model/names/violation-type-name.d.ts +3 -3
  97. package/dist/application-spec/parse-application-files/spec/model/presets.d.ts +6 -29
  98. package/dist/application-spec/parse-application-files/spec/sections/actions.d.ts +6 -23
  99. package/dist/application-spec/parse-application-files/spec/sections/app-metadata.d.ts +3 -18
  100. package/dist/application-spec/parse-application-files/spec/sections/application-version.d.ts +3 -7
  101. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
  102. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant.js +1 -1
  103. package/dist/application-spec/parse-application-files/spec/sections/data-spec/chunks.d.ts +6 -23
  104. package/dist/application-spec/parse-application-files/spec/sections/data-spec/custom-data-spec.d.ts +1 -16
  105. package/dist/application-spec/parse-application-files/spec/sections/data-spec/data-entry-key.d.ts +3 -9
  106. package/dist/application-spec/parse-application-files/spec/sections/data-spec/data-spec.d.ts +1 -10
  107. package/dist/application-spec/parse-application-files/spec/sections/data-spec/swatch-data-spec.d.ts +1 -14
  108. package/dist/application-spec/parse-application-files/spec/sections/state-value.d.ts +3 -7
  109. package/dist/application-spec/parse-application-files/spec/sections/theme.d.ts +3 -10
  110. package/dist/application-spec/parse-application-files/spec/sections/transformers.d.ts +4 -11
  111. package/dist/application-spec/parse-application-files/spec/sections/ui.d.ts +3 -12
  112. package/dist/configurator/ConfiguratorApp.js +1 -1
  113. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
  114. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +19 -3
  115. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -1
  116. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.d.ts +70 -56
  117. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.js +1 -1
  118. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +15 -0
  119. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
  120. package/dist/configurator/application-runtime/extensions/systems/graphql-system/violations.d.ts +40 -0
  121. package/dist/configurator/application-runtime/extensions/systems/graphql-system/violations.js +1 -0
  122. package/dist/configurator/common/configurator-interface.d.ts +2 -2
  123. package/dist/configurator/common/configurator-interface.js +1 -1
  124. package/dist/configurator/configurator-context/PresetSelectionProvider.js +1 -1
  125. package/dist/configurator/configurator-context/configurator-hooks/index.d.ts +0 -1
  126. package/dist/configurator/configurator-context/configurator-hooks/index.js +1 -1
  127. package/dist/configurator/configurator-context/index.d.ts +0 -4
  128. package/dist/configurator/configurator-context/index.js +1 -1
  129. package/dist/configurator/pages/ConfiguratorNotFoundPage.js +1 -1
  130. package/dist/configurator/pages/LoadedConfiguratorDetailPage.js +1 -1
  131. package/dist/configurator/pages/error-boundaries/DevContextFallback.js +1 -1
  132. package/dist/configurator/pages/error-boundaries/DevLoadingFallback.js +1 -1
  133. package/dist/configurator/ui/assistant/AssistantChips.js +1 -1
  134. package/dist/configurator/ui/assistant/tool-chip.d.ts +19 -9
  135. package/dist/configurator/ui/assistant/tool-chip.js +1 -1
  136. package/dist/configurator/ui/configurator-layout/slots/canvas/GPUAccelerationDisabled.js +1 -1
  137. package/dist/configurator/ui/configurator-layout/slots/canvas/WebGLNotSupported.js +1 -1
  138. package/dist/configurator/ui/configurator-layout/slots/readonly-banner/CloneToEditDialog.js +1 -1
  139. package/dist/configurator/ui/legacy/chat/MobileChat.js +1 -1
  140. package/dist/configurator/ui/legacy/layout/common/CommonTopNavigation.js +1 -1
  141. package/dist/configurator/ui/legacy/layout/simple/SimpleSidebar.js +1 -1
  142. package/dist/configurator/ui/legacy/layout/simple/SimpleTopNavigation.js +1 -1
  143. package/dist/configurator/ui/legacy/layout/steps/StepsNavigation.js +1 -1
  144. package/dist/configurator/ui/legacy/layout/steps/StepsOwnerLayout.js +1 -1
  145. package/dist/configurator/ui/legacy/layout/steps/StepsSideBar.js +1 -1
  146. package/dist/configurator/ui/legacy/layout/tabs/TabsSidebar.js +1 -1
  147. package/dist/configurator/ui/phoenix-layout-elements/header/common/back-button/use-go-back-action.js +1 -1
  148. package/dist/configurator/ui/phoenix-layout-elements/header/common/step-navigation/StepsNavigation.js +1 -1
  149. package/dist/configurator/ui/phoenix-layout-elements/sidebar-footer/common/PreviousStepButton.js +1 -1
  150. package/dist/configurator/ui/save-message-snackbars/SaveMessageSnackbars.js +1 -1
  151. package/dist/docs/3d-scene/cameras/custom.mdx +4 -2
  152. package/dist/docs/drag-and-drop/room-planner.mdx +1 -1
  153. package/dist/docs/index.json +1 -1
  154. package/dist/docs/phoenix/configurator-interface.mdx +1 -1
  155. package/dist/docs/phoenix/layout-slots.mdx +21 -0
  156. package/dist/docs/phoenix/phoenix-cli.mdx +4 -3
  157. package/dist/docs/phoenix/project-structure.mdx +21 -17
  158. package/dist/docs/phoenix/sdk-builder-workflow.mdx +2 -2
  159. package/dist/docs/phoenix/webhooks.mdx +5 -1
  160. package/dist/domain/application/application-config.d.ts +6 -24
  161. package/dist/domain/application/assistant/assistant-manifest.d.ts +13 -3
  162. package/dist/domain/application/assistant/assistant-manifest.js +1 -1
  163. package/dist/domain/application/assistant/assistant-resolved-manifest.d.ts +5 -9
  164. package/dist/domain/application/assistant/assistant-resolved-manifest.js +1 -1
  165. package/dist/domain/application/assistant/build-assistant-lenses.js +1 -1
  166. package/dist/domain/application/assistant/build-assistant-manifest.js +1 -1
  167. package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -1
  168. package/dist/domain/application/assistant/index.d.ts +3 -3
  169. package/dist/domain/application/assistant/index.js +1 -1
  170. package/dist/domain/application/assistant/session-setup/apply-assistant-setup.js +1 -1
  171. package/dist/domain/application/assistant/session-setup/assistant-setup-manifest.d.ts +2 -4
  172. package/dist/domain/application/assistant/session-setup/assistant-setup-manifest.js +1 -1
  173. package/dist/domain/application/assistant-mutations.js +1 -1
  174. package/dist/domain/index.d.ts +1 -0
  175. package/dist/domain/index.js +1 -1
  176. package/dist/domain/spec/application/admin-pages-section.d.ts +29 -0
  177. package/dist/domain/spec/application/admin-pages.d.ts +26 -0
  178. package/dist/domain/spec/application/admin-states.d.ts +5 -0
  179. package/dist/domain/spec/application/configurator-states.d.ts +8 -0
  180. package/dist/domain/spec/application/configurator-states.js +1 -0
  181. package/dist/domain/spec/application/index.d.ts +5 -0
  182. package/dist/domain/spec/application/index.js +1 -0
  183. package/dist/domain/spec/components/bindings/index.d.ts +2 -0
  184. package/dist/domain/spec/components/bindings/index.js +1 -0
  185. package/dist/domain/spec/components/bindings/read-binding.d.ts +13 -0
  186. package/dist/domain/spec/components/bindings/read-binding.js +1 -0
  187. package/dist/domain/spec/components/bindings/write-binding.d.ts +32 -0
  188. package/dist/domain/spec/components/bindings/write-binding.js +1 -0
  189. package/dist/{application-spec/parse-application-files → domain}/spec/components/component-entry.d.ts +3 -3
  190. package/dist/domain/spec/components/component-entry.js +1 -0
  191. package/dist/{application-spec/core → domain/spec}/components/component-filter.d.ts +3 -2
  192. package/dist/domain/spec/components/component-filters.d.ts +10 -0
  193. package/dist/domain/spec/components/component-filters.js +1 -0
  194. package/dist/domain/spec/components/components.d.ts +4 -0
  195. package/dist/domain/spec/components/components.js +1 -0
  196. package/dist/domain/spec/components/index.d.ts +6 -0
  197. package/dist/domain/spec/enhanced-json-value.d.ts +30 -0
  198. package/dist/domain/spec/enhanced-json-value.js +1 -0
  199. package/dist/{application-spec/parse-application-files → domain}/spec/expressions/expression.d.ts +9 -3
  200. package/dist/domain/spec/expressions/expression.js +1 -0
  201. package/dist/domain/spec/expressions/expressions.d.ts +27 -0
  202. package/dist/domain/spec/expressions/expressions.js +1 -0
  203. package/dist/domain/spec/expressions/index.d.ts +5 -0
  204. package/dist/domain/spec/expressions/memo-eval-plan.d.ts +70 -0
  205. package/dist/domain/spec/expressions/memo-eval-plan.js +1 -0
  206. package/dist/domain/spec/expressions/relation-expression-params.js +1 -0
  207. package/dist/domain/spec/index.d.ts +9 -0
  208. package/dist/domain/spec/index.js +1 -0
  209. package/dist/domain/spec/invariants/index.d.ts +2 -0
  210. package/dist/domain/spec/invariants/index.js +1 -0
  211. package/dist/domain/spec/invariants/invariant.d.ts +24 -0
  212. package/dist/domain/spec/invariants/invariant.js +1 -0
  213. package/dist/domain/spec/invariants/invariants.d.ts +14 -0
  214. package/dist/domain/spec/invariants/invariants.js +1 -0
  215. package/dist/domain/spec/json-schema.d.ts +52 -0
  216. package/dist/domain/spec/json-schema.js +1 -0
  217. package/dist/domain/spec/markers/index.d.ts +3 -0
  218. package/dist/domain/spec/markers/index.js +1 -0
  219. package/dist/domain/spec/markers/msg-marker.d.ts +28 -0
  220. package/dist/domain/spec/markers/msg-marker.js +1 -0
  221. package/dist/domain/spec/model/aliases.d.ts +9 -0
  222. package/dist/domain/spec/model/aliases.js +1 -0
  223. package/dist/domain/spec/model/common-types.d.ts +15 -0
  224. package/dist/domain/spec/model/common-types.js +1 -0
  225. package/dist/domain/spec/model/defaults.d.ts +33 -0
  226. package/dist/domain/spec/model/defaults.js +1 -0
  227. package/dist/domain/spec/model/entity-types.d.ts +8 -0
  228. package/dist/domain/spec/model/entity-types.js +1 -0
  229. package/dist/domain/spec/model/index.d.ts +7 -0
  230. package/dist/domain/spec/model/index.js +1 -0
  231. package/dist/domain/spec/model/model-version-key.d.ts +3 -0
  232. package/dist/domain/spec/model/model-version-key.js +1 -0
  233. package/dist/domain/spec/model/names/action-name.d.ts +7 -0
  234. package/dist/domain/spec/model/names/action-name.js +1 -0
  235. package/dist/domain/spec/model/names/alias-name.d.ts +7 -0
  236. package/dist/domain/spec/model/names/alias-name.js +1 -0
  237. package/dist/domain/spec/model/names/entity-or-alias-name.d.ts +8 -0
  238. package/dist/domain/spec/model/names/entity-or-alias-name.js +1 -0
  239. package/dist/domain/spec/model/names/entity-type-name.d.ts +8 -0
  240. package/dist/domain/spec/model/names/entity-type-name.js +1 -0
  241. package/dist/domain/spec/model/names/expression-name.d.ts +6 -0
  242. package/dist/domain/spec/model/names/expression-name.js +1 -0
  243. package/dist/domain/spec/model/names/index.d.ts +9 -0
  244. package/dist/domain/spec/model/names/index.js +1 -0
  245. package/dist/domain/spec/model/names/instance-name.d.ts +7 -0
  246. package/dist/domain/spec/model/names/instance-name.js +1 -0
  247. package/dist/domain/spec/model/names/invariant-name.d.ts +3 -0
  248. package/dist/domain/spec/model/names/invariant-name.js +1 -0
  249. package/dist/domain/spec/model/names/shape-property-name.d.ts +11 -0
  250. package/dist/domain/spec/model/names/shape-property-name.js +1 -0
  251. package/dist/domain/spec/model/names/violation-type-name.d.ts +3 -0
  252. package/dist/domain/spec/model/names/violation-type-name.js +1 -0
  253. package/dist/domain/spec/model/presets.d.ts +30 -0
  254. package/dist/domain/spec/model/presets.js +1 -0
  255. package/dist/domain/spec/sections/actions.d.ts +23 -0
  256. package/dist/domain/spec/sections/actions.js +1 -0
  257. package/dist/domain/spec/sections/app-metadata.d.ts +18 -0
  258. package/dist/domain/spec/sections/app-metadata.js +1 -0
  259. package/dist/domain/spec/sections/application-version.d.ts +7 -0
  260. package/dist/domain/spec/sections/application-version.js +1 -0
  261. package/dist/domain/spec/sections/data-spec/chunks.d.ts +23 -0
  262. package/dist/domain/spec/sections/data-spec/chunks.js +1 -0
  263. package/dist/domain/spec/sections/data-spec/custom-data-spec-entry.d.ts +16 -0
  264. package/dist/domain/spec/sections/data-spec/custom-data-spec-entry.js +1 -0
  265. package/dist/domain/spec/sections/data-spec/data-entry-key.d.ts +9 -0
  266. package/dist/domain/spec/sections/data-spec/data-entry-key.js +1 -0
  267. package/dist/domain/spec/sections/data-spec/index.d.ts +5 -0
  268. package/dist/domain/spec/sections/data-spec/index.js +1 -0
  269. package/dist/domain/spec/sections/data-spec/parsed-data-spec-entries.d.ts +10 -0
  270. package/dist/domain/spec/sections/data-spec/parsed-data-spec-entries.js +1 -0
  271. package/dist/domain/spec/sections/data-spec/swatch-data-spec-entry.d.ts +14 -0
  272. package/dist/domain/spec/sections/data-spec/swatch-data-spec-entry.js +1 -0
  273. package/dist/domain/spec/sections/index.d.ts +9 -0
  274. package/dist/domain/spec/sections/index.js +1 -0
  275. package/dist/domain/spec/sections/infra/acl.d.ts +12 -0
  276. package/dist/domain/spec/sections/infra/acl.js +1 -0
  277. package/dist/domain/spec/sections/infra/index.d.ts +3 -0
  278. package/dist/domain/spec/sections/infra/index.js +1 -0
  279. package/dist/domain/spec/sections/infra/resource-entry.d.ts +46 -0
  280. package/dist/domain/spec/sections/infra/resource-entry.js +1 -0
  281. package/dist/domain/spec/sections/infra/resources-config.d.ts +10 -0
  282. package/dist/domain/spec/sections/infra/resources-config.js +1 -0
  283. package/dist/domain/spec/sections/state-value.d.ts +7 -0
  284. package/dist/domain/spec/sections/state-value.js +1 -0
  285. package/dist/domain/spec/sections/theme.d.ts +10 -0
  286. package/dist/domain/spec/sections/theme.js +1 -0
  287. package/dist/domain/spec/sections/transformers.d.ts +15 -0
  288. package/dist/domain/spec/sections/transformers.js +1 -0
  289. package/dist/domain/spec/sections/ui.d.ts +12 -0
  290. package/dist/domain/spec/sections/ui.js +1 -0
  291. package/dist/editor/graphql/GraphQLPanel.js +1 -1
  292. package/dist/phoenix/application-spec/generate-application-spec-project.d.ts +1 -0
  293. package/dist/phoenix/application-spec/generate-application-spec-project.js +2 -2
  294. package/dist/phoenix/application-spec/generate-project-files.d.ts +1 -0
  295. package/dist/phoenix/application-spec/index.d.ts +1 -0
  296. package/dist/phoenix/application-spec/index.js +1 -1
  297. package/dist/phoenix/bin.js +1 -1
  298. package/dist/phoenix/commands/build.js +1 -1
  299. package/dist/phoenix/commands/clean.js +1 -1
  300. package/dist/phoenix/commands/deploy.js +1 -1
  301. package/dist/phoenix/commands/sync.js +1 -1
  302. package/dist/phoenix/lingui/index.d.ts +1 -0
  303. package/dist/phoenix/lingui/index.js +1 -0
  304. package/dist/phoenix/services/application-spec-project-watcher.js +1 -1
  305. package/dist/phoenix/services/index.d.ts +1 -1
  306. package/dist/phoenix/services/index.js +1 -1
  307. package/dist/phoenix/services/lingui-watcher.js +1 -1
  308. package/dist/phoenix/services/vite-config.js +1 -1
  309. package/dist/react-sdk/application-runtime/domain-application-context/chat-system.d.ts +1 -1
  310. package/dist/{configurator/configurator-context → react-sdk}/configurator-routing/ConfiguratorRoutingProvider.d.ts +1 -1
  311. package/dist/react-sdk/configurator-routing/ConfiguratorRoutingProvider.js +1 -0
  312. package/dist/{configurator/configurator-context → react-sdk}/configurator-routing/OnGoToIndexHandler.d.ts +1 -2
  313. package/dist/react-sdk/configurator-routing/OnGoToIndexHandler.js +1 -0
  314. package/dist/react-sdk/configurator-routing/index.d.ts +3 -0
  315. package/dist/{configurator/configurator-context → react-sdk}/configurator-routing/index.js +1 -1
  316. package/dist/{configurator/configurator-context → react-sdk}/configurator-routing/use-power-routing-lifecycle.d.ts +2 -0
  317. package/dist/react-sdk/configurator-routing/use-power-routing-lifecycle.js +1 -0
  318. package/dist/react-sdk/domain-application-context/ConfigurationPersistSystemFailureHandler.js +1 -1
  319. package/dist/react-sdk/domain-application-context/OnPresetLoadedHandler.js +1 -0
  320. package/dist/react-sdk/domain-application-context/chat-hooks.d.ts +4 -0
  321. package/dist/react-sdk/domain-application-context/chat-hooks.js +1 -0
  322. package/dist/react-sdk/domain-application-context/index.d.ts +2 -0
  323. package/dist/react-sdk/domain-application-context/index.js +1 -1
  324. package/dist/react-sdk/index.d.ts +4 -0
  325. package/dist/react-sdk/index.js +1 -1
  326. package/dist/react-sdk/integration/IntegrationSubscription.js +1 -0
  327. package/dist/react-sdk/integration/index.d.ts +1 -0
  328. package/dist/react-sdk/integration/index.js +1 -0
  329. package/dist/react-sdk/lifecycle-providers/ConfiguratorDataProvider.d.ts +8 -0
  330. package/dist/react-sdk/lifecycle-providers/ConfiguratorDataProvider.js +1 -0
  331. package/dist/react-sdk/lifecycle-providers/LifecycleProviders.js +1 -0
  332. package/dist/react-sdk/lifecycle-providers/index.d.ts +2 -0
  333. package/dist/react-sdk/lifecycle-providers/index.js +1 -0
  334. package/dist/react-sdk/notifications/index.d.ts +1 -0
  335. package/dist/react-sdk/notifications/index.js +1 -0
  336. package/dist/react-sdk/notifications/snackbar-action-button.d.ts +30 -0
  337. package/dist/react-sdk/notifications/snackbar-action-button.js +1 -0
  338. package/dist/ui-sdk/components/snackbar/Snackbar.d.ts +24 -3
  339. package/dist/ui-sdk/components/snackbar/Snackbar.js +1 -1
  340. package/dist/watch/glob-matcher.d.ts +4 -4
  341. package/dist/watch/glob-matcher.js +1 -1
  342. package/dist/watch/watch.d.ts +4 -4
  343. package/dist/watch/watch.js +1 -1
  344. package/package.json +3 -3
  345. package/dist/application-spec/core/components/index.d.ts +0 -2
  346. package/dist/application-spec/core/expressions/index.d.ts +0 -2
  347. package/dist/configurator/configurator-context/ConfiguratorDataProvider.d.ts +0 -2
  348. package/dist/configurator/configurator-context/ConfiguratorDataProvider.js +0 -1
  349. package/dist/configurator/configurator-context/IntegrationSubscription.js +0 -1
  350. package/dist/configurator/configurator-context/LifecycleProviders.js +0 -1
  351. package/dist/configurator/configurator-context/OnPresetLoadedHandler.js +0 -1
  352. package/dist/configurator/configurator-context/configurator-hooks/chat-hooks.d.ts +0 -1
  353. package/dist/configurator/configurator-context/configurator-hooks/chat-hooks.js +0 -1
  354. package/dist/configurator/configurator-context/configurator-routing/ConfiguratorRoutingProvider.js +0 -1
  355. package/dist/configurator/configurator-context/configurator-routing/OnGoToIndexHandler.js +0 -1
  356. package/dist/configurator/configurator-context/configurator-routing/index.d.ts +0 -2
  357. package/dist/configurator/configurator-context/configurator-routing/use-power-routing-lifecycle.js +0 -1
  358. /package/dist/{application-spec/core/expressions/relation-expression-params.js → domain/spec/application/admin-pages-section.js} +0 -0
  359. /package/dist/{application-spec/parse-application-files/spec/components/component-entry.js → domain/spec/application/admin-pages.js} +0 -0
  360. /package/dist/{application-spec/parse-application-files/spec/expressions/expression.js → domain/spec/application/admin-states.js} +0 -0
  361. /package/dist/{application-spec/core → domain/spec/application}/application-instance.d.ts +0 -0
  362. /package/dist/{application-spec/core → domain/spec/application}/application-instance.js +0 -0
  363. /package/dist/{application-spec/core → domain/spec}/components/component-filter.js +0 -0
  364. /package/dist/{application-spec/core → domain/spec}/components/index.js +0 -0
  365. /package/dist/{application-spec/core → domain/spec}/components/sdk-code-ref.d.ts +0 -0
  366. /package/dist/{application-spec/core → domain/spec}/components/sdk-code-ref.js +0 -0
  367. /package/dist/{application-spec/core → domain/spec}/expressions/index.js +0 -0
  368. /package/dist/{application-spec/core → domain/spec}/expressions/relation-expression-params.d.ts +0 -0
  369. /package/dist/{application-spec/core → domain/spec}/expressions/sdk-expression-implementation.d.ts +0 -0
  370. /package/dist/{application-spec/core → domain/spec}/expressions/sdk-expression-implementation.js +0 -0
  371. /package/dist/{application-spec/parse-application-files/spec/components → domain/spec/markers}/component-prop-target.d.ts +0 -0
  372. /package/dist/{application-spec/parse-application-files/spec/components → domain/spec/markers}/component-prop-target.js +0 -0
  373. /package/dist/{application-spec/core → domain/spec}/markers/eval-marker.d.ts +0 -0
  374. /package/dist/{application-spec/core → domain/spec}/markers/eval-marker.js +0 -0
  375. /package/dist/phoenix/{services → lingui}/lingui.d.ts +0 -0
  376. /package/dist/phoenix/{services → lingui}/lingui.js +0 -0
  377. /package/dist/{configurator/configurator-context → react-sdk/domain-application-context}/OnPresetLoadedHandler.d.ts +0 -0
  378. /package/dist/{configurator/configurator-context → react-sdk/integration}/IntegrationSubscription.d.ts +0 -0
  379. /package/dist/{configurator/configurator-context → react-sdk/lifecycle-providers}/LifecycleProviders.d.ts +0 -0
@@ -9,6 +9,7 @@ import type { AdminIntegrationService } from '#package/react-sdk';
9
9
  import type { $DomainEntity, DataCellValue, DataSchema, DomainEntity, DomainFactory, ProductPreset } from '../core/index.js';
10
10
  import type { AnalyticsSystem, RegistrableTransformer, TransformerFactory } from '../domain-context/index.js';
11
11
  import type { ElementRegistration, ProjectModule } from '../domain-runtime/index.js';
12
+ import type { AdminPagesSection } from '../spec/index.js';
12
13
  import type { AssistantResolvedManifest } from './assistant/index.js';
13
14
  import type { WebComponentEventDescriptor } from './web-component-event.js';
14
15
  import type { WebComponentPropertyDescriptor } from './web-component-property.js';
@@ -55,30 +56,11 @@ export type DataSpec = {
55
56
  export type ChunksSpec = Readonly<Record<string, {
56
57
  readonly scope: string;
57
58
  }>>;
58
- export type AdminPagesSpec = {
59
- readonly presets?: boolean | {
60
- readonly categoryNavigationState?: string;
61
- readonly presetNavigationState?: string;
62
- };
63
- readonly recipes?: ReadonlyArray<{
64
- readonly name: string;
65
- readonly navigationState?: string;
66
- }>;
67
- readonly pages?: ReadonlyArray<{
68
- readonly key: string;
69
- readonly title: string;
70
- readonly icon?: string;
71
- readonly navigationState?: string;
72
- readonly entity?: string;
73
- readonly component?: string;
74
- readonly actionsComponent?: string;
75
- readonly connectedDataEntry?: string;
76
- readonly sidebar?: {
77
- readonly title: string;
78
- readonly component: string;
79
- };
80
- }>;
81
- };
59
+ /**
60
+ * The admin pages of an application config: the `$adminPages` section of the application spec as
61
+ * written, which `createAdminPagesFromSpec` turns into admin pages; see {@link AdminPagesSection}.
62
+ */
63
+ export type AdminPagesSpec = AdminPagesSection;
82
64
  type PersistenceConfig = {
83
65
  readonly type: 'server';
84
66
  /**
@@ -8,18 +8,28 @@ export interface AssistantFieldSource {
8
8
  readonly source: string;
9
9
  readonly localized?: true;
10
10
  }
11
+ /**
12
+ * What the integrator promises about a list of choices, so the agent can read it once and reuse it:
13
+ * `sameForAllInstances` when every entity of the type gets the same list, `constantDuringSession`
14
+ * when the list does not change during a session. A hint only adds a sentence to the description of
15
+ * the recipe group or options edge it is declared on; nothing verifies it.
16
+ */
17
+ export declare const ASSISTANT_HINTS: readonly ['sameForAllInstances', 'constantDuringSession'];
18
+ export type AssistantResolvedHint = (typeof ASSISTANT_HINTS)[number];
11
19
  /**
12
20
  * One recipe group the assistant manifest exposes on an entity type: a `childEntityRecipes` instance
13
21
  * under `childRecipes`, a `replaceEntityRecipes` instance under `replaceRecipes`. `groupId` is the
14
- * name the agent addresses the group by, `instanceName` the component instance it reads,
15
- * `description` the manifest's text replacing the component's group description, and `dryRuns`
16
- * whether the recipes of the group can be dry-run.
22
+ * name of its field on `<Type>ChildRecipes` or `<Type>ReplaceRecipes` and the id the agent passes to
23
+ * `addChild` or `replaceEntity`, `instanceName` the component instance it reads, `description` the
24
+ * manifest's text for that field, `dryRuns` whether the recipes of the group can be dry-run, and
25
+ * `hints` the sentences of the field's description saying when the agent can reuse what it read.
17
26
  */
18
27
  export interface AssistantRecipeGroup {
19
28
  readonly groupId: string;
20
29
  readonly instanceName: string;
21
30
  readonly description?: string;
22
31
  readonly dryRuns: boolean;
32
+ readonly hints: readonly AssistantResolvedHint[];
23
33
  }
24
34
  /**
25
35
  * The options edge of one writable field the assistant manifest links to its component. `field` is
@@ -1 +1 @@
1
- export{};
1
+ export const ASSISTANT_HINTS=["sameForAllInstances","constantDuringSession"];
@@ -1,4 +1,4 @@
1
- import type { AssistantFieldOptions, AssistantRecipeGroup, AssistantScreenshotView } from './assistant-manifest.js';
1
+ import type { AssistantFieldOptions, AssistantRecipeGroup, AssistantResolvedHint, AssistantScreenshotView } from './assistant-manifest.js';
2
2
  import type { AssistantFormElementDescriptor } from './form/index.js';
3
3
  /** JSON description of a scalar or recursively nested list, including nullability at each level. */
4
4
  export type AssistantValueType = {
@@ -54,6 +54,8 @@ export interface AssistantResolvedManifest {
54
54
  /** The screenshot views of each entity type with at least one, aliases expanded, in manifest order. */
55
55
  readonly screenshots: Readonly<Record<string, readonly AssistantScreenshotView[]>>;
56
56
  readonly actionFields: readonly AssistantResolvedAction[];
57
+ /** The entity types that declare invariants, whose `meta` lists the warnings and notices they hold. */
58
+ readonly invariantTypes: readonly string[];
57
59
  /** The declared lenses by name: when to use each, and how many levels its tagged relations nest. */
58
60
  readonly lenses: Readonly<Record<string, {
59
61
  readonly description: string;
@@ -74,14 +76,8 @@ export interface AssistantWritableType {
74
76
  readonly entityType: string;
75
77
  readonly fields: readonly AssistantWritableField[];
76
78
  }
77
- /** Description hints resolved from recipe/option entries; no parse context is retained. */
78
- export declare const ASSISTANT_HINTS: readonly ['sameForAllInstances', 'constantDuringSession'];
79
- export type AssistantResolvedHint = (typeof ASSISTANT_HINTS)[number];
80
- /** Recipe groups and their description hints for one entity type. */
81
- export interface AssistantResolvedRecipes {
82
- readonly groups: readonly AssistantRecipeGroup[];
83
- readonly hints: readonly AssistantResolvedHint[];
84
- }
79
+ /** The recipe groups of one kind on one entity type or alias key, in manifest order, each with its own hints. */
80
+ export type AssistantResolvedRecipes = readonly AssistantRecipeGroup[];
85
81
  /** One options edge, carrying the write-validation contract and schema description hints. */
86
82
  export interface AssistantResolvedOptionsEdge {
87
83
  readonly options: AssistantFieldOptions;
@@ -1 +1 @@
1
- export const ASSISTANT_HINTS=["sameForAllInstances","constantDuringSession"];
1
+ export{};
@@ -1,4 +1,4 @@
1
- import{NoUnusedFragmentsRule as e,parse as t,specifiedRules as i,validate as n}from"graphql";let s="AnyDomainEntity",r=[{name:"RecipeGroup",description:"A recipe group with its recipes, without their dry-runs.",selections:["groupId","name","description","recipes { ...Recipe }"]},{name:"Recipe",description:"A recipe without its dry-run.",selections:["key","name","description","imageUrl"]},{name:"FieldOption",description:"A value a field accepts, without its dry-run.",selections:["value","name","description","imageUrl","color"]},{name:"DryRun",description:"What a dry-run would do, with the ids of the entities it would change instead of the entities.",selections:["ok","deletedEntityIds","sideEffects","errors { type entityId message }","changedEntities { id }"]}],a=(e,t)=>0===t?e:`${e}__${t}`,l=e=>e.split("\n").map(e=>`# ${e}`.trimEnd()).join("\n"),o=(e,t,i)=>[`fragment ${e} on ${t} {`,...i.map(e=>` ${e}`),"}"].join("\n"),p=(e,t,i)=>{let n=e=>"edge"===e.type.kind?`${e.name} { ${i} }`:e.name;return o(e,s,["id",...t.flatMap(({typeName:e,fields:t})=>e===s?t.map(n):[`... on ${e} {`,...t.map(e=>` ${n(e)}`),"}"])])};export const buildAssistantLenses=(d,m)=>{let c=Object.entries(d.lenses).flatMap(([e,t])=>{let i=[s,...Object.keys(d.aliases).filter(e=>e!==s),...d.entityTypes].flatMap(t=>{let i=(d.fields[t]??[]).filter(t=>t.lenses?.includes(e));return i.length>0?[{typeName:t,fields:i}]:[]});return i.length>0?[{name:e,...t,conditions:i}]:[]}),$=r.filter(({name:e})=>void 0!==m.getType(e)),h=[...c.map(({name:e,description:t,maxDepth:i,conditions:n})=>{let s=n.some(({fields:e})=>e.some(e=>"edge"===e.type.kind));return`${l(s?`${t} ${`Nested relations carry the same selection up to ${i} ${1===i?"level":"levels"}, below that only \`id\`.`}`:t)}
1
+ import{NoUnusedFragmentsRule as e,parse as t,specifiedRules as i,validate as n}from"graphql";let s="AnyDomainEntity",r=[{name:"RecipeGroup",description:"A recipe group with its recipes, without their dry-runs.",selections:["groupId","name","description","recipes { ...Recipe }"]},{name:"Recipe",description:"A recipe without its dry-run.",selections:["key","name","description","imageUrl"]},{name:"FieldOption",description:"A value a field accepts, without its dry-run.",selections:["value","name","description","imageUrl","color"]},{name:"DryRun",description:"What a dry-run would do, with the ids of the entities it would change instead of the entities.",selections:["ok","deletedEntityIds","sideEffects","warnings","errors { type entityId message }","changedEntities { id }"]}],a=(e,t)=>0===t?e:`${e}__${t}`,l=e=>e.split("\n").map(e=>`# ${e}`.trimEnd()).join("\n"),o=(e,t,i)=>[`fragment ${e} on ${t} {`,...i.map(e=>` ${e}`),"}"].join("\n"),p=(e,t,i)=>{let n=e=>"edge"===e.type.kind?`${e.name} { ${i} }`:e.name;return o(e,s,["id",...t.flatMap(({typeName:e,fields:t})=>e===s?t.map(n):[`... on ${e} {`,...t.map(e=>` ${n(e)}`),"}"])])};export const buildAssistantLenses=(d,m)=>{let c=Object.entries(d.lenses).flatMap(([e,t])=>{let i=[s,...Object.keys(d.aliases).filter(e=>e!==s),...d.entityTypes].flatMap(t=>{let i=(d.fields[t]??[]).filter(t=>t.lenses?.includes(e));return i.length>0?[{typeName:t,fields:i}]:[]});return i.length>0?[{name:e,...t,conditions:i}]:[]}),$=r.filter(({name:e})=>void 0!==m.getType(e)),h=[...c.map(({name:e,description:t,maxDepth:i,conditions:n})=>{let s=n.some(({fields:e})=>e.some(e=>"edge"===e.type.kind));return`${l(s?`${t} ${`Nested relations carry the same selection up to ${i} ${1===i?"level":"levels"}, below that only \`id\`.`}`:t)}
2
2
  ${p(e,n,`...${e}`)}`}),...$.map(({name:e,description:t,selections:i})=>`${l(t)}
3
3
  ${o(e,e,i)}`)].join("\n\n"),u=[...c.flatMap(({name:e,maxDepth:t,conditions:i})=>Array.from({length:t+1},(n,s)=>p(a(e,s),i,s<t?`...${a(e,s+1)}`:"id"))),...$.map(({name:e,selections:t})=>o(e,e,t))].join("\n\n");if(""!==u){let s=c.length>0?`entities { ${c.map(({name:e})=>`...${e}`).join(" ")} }`:"__typename",r=n(m,t(`${u}
4
4
 
@@ -1 +1 @@
1
- import{GraphQLBoolean as e,GraphQLEnumType as t,GraphQLID as n,GraphQLInputObjectType as i,GraphQLInterfaceType as s,GraphQLList as r,GraphQLNonNull as o,GraphQLObjectType as a,GraphQLSchema as p,GraphQLString as d,printSchema as c,validateSchema as l}from"graphql";import{GraphQLJSON as h,createAssistantValueType as w}from"./assistant-value-type.js";import{buildAssistantLenses as y}from"./build-assistant-lenses.js";import{createAssistantExecutionSchema as u}from"./create-assistant-execution-schema.js";let m="AnyDomainEntity",f="RootEntity",g=[["navigationState","Active navigation state.","navigationStates"],["viewState","Active view state.","viewStates"],["toolState","Active tool state.","toolStates"]],b={section:"childRecipes",mutation:"addChild"},v={section:"replaceRecipes",mutation:"replaceEntity"},j=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],$=(e,t)=>{if(!t||0===t.length)return e;let n=`One of: ${t.map(e=>`"${e}"`).join(", ")}.`;return e?/[.!?]$/.test(e)?`${e} ${n}`:`${e}. ${n}`:n},O=({target:e,cardinality:t},n)=>{let i=n(e);switch(t){case"1-1":return new o(i);case"0-1":return i;case"0-N":case"1-N":return new o(new r(new o(i)))}},E=(e,t,i)=>{let s={id:{type:new o(n),description:i?`Unique id of the entity, assigned by the configurator, e.g. "${i}-1".`:void 0},type:{type:new o(d),description:i?`Entity type name, e.g. "${i}".`:void 0}};for(let n of e)s[n.name]={type:"edge"===n.type.kind?O(n.type,t):w(n.type.type),description:n.description};return s},R=e=>Object.fromEntries(e.map(({name:e,source:t,localized:n})=>[e,n?{source:t,localized:!0}:{source:t}])),k={sameForAllInstances:e=>`Same recipe groups and recipes for every ${e}.`,constantDuringSession:()=>"Fixed for the session."},T={sameForAllInstances:e=>`Same for every ${e}.`,constantDuringSession:()=>"Fixed for the session."},I=(e,t,n)=>e.map(e=>` ${t[e](n)}`).join(""),N=({section:e},{groups:t,hints:n},{entityType:i,purpose:s,recipeGroup:a})=>{let p=t.filter(({dryRuns:e})=>!e).map(({groupId:e})=>e);return 0===t.length?{}:{[e]:{type:new o(new r(new o(a))),description:`The recipe groups for ${s} this ${i}: ${t.map(({groupId:e})=>e).join(", ")}. A group is listed only while the configurator offers it on the entity.${p.length>0?` Recipes of these groups cannot be dry-run: ${p.join(", ")}.`:""}${I(n,k,i)}`}}},A=({entityType:e,childRecipes:n,replaceRecipes:i,optionsEdges:s,screenshots:p},{recipeGroup:d,fieldOption:c,screenshot:l})=>new a({name:`${e}Meta`,fields:Object.assign(N(b,n,{entityType:e,purpose:"adding children to",recipeGroup:d}),N(v,i,{entityType:e,purpose:"replacing",recipeGroup:d}),...s.map(({options:{edgeName:t,field:n,validate:i,dryRuns:s},hints:a})=>({[t]:{type:new r(new o(c)),description:`Values "${n}" accepts on this ${e}. Null when there is no choice to make.${i?"":" Not checked on write."}${s?"":" Cannot be dry-run."}${I(a,T,e)}`}})),0===p.length?{}:{screenshot:{type:l,args:{view:{type:new o(new t({name:`${e}ScreenshotView`,values:Object.fromEntries(p.map(({view:e,description:t})=>[e,{description:t}]))}))}},description:"Renders this entity from a predefined view. The picture follows the tool result as an image labelled with `image`. Null when the view does not apply to this entity right now."}})}),S=e=>Object.entries(e).map(([e,t])=>`${e} (${t.map(({groupId:e})=>e).join(", ")})`);export const buildAssistantManifest=t=>{var O,k,T,I,N;let M,D,F,W,{entityTypes:x,aliases:C,exampleType:q,fields:G,states:U,deletableTypes:K,writableTypes:V,actionFields:P,optionsEdges:z}=t,L=Object.fromEntries(Object.entries(t.childRecipes).map(([e,t])=>[e,t.groups])),Q=Object.fromEntries(Object.entries(t.replaceRecipes).map(([e,t])=>[e,t.groups])),B=new Map,H=new Map,J=new Map,X=e=>{let[t,...n]=Object.entries(C).find(([t])=>t===e)?.[1]??[];return(t&&0===n.length?H.get(t):void 0)??J.get(e)??Z},Y=e=>H.get(e)??X(e),Z=new s({name:m,description:"Every entity of the configuration.",fields:()=>E(G[m]??[],Y,q)});for(let e of(J.set(m,Z),Object.keys(C)))e!==m&&J.set(e,new s({name:e,interfaces:[Z],fields:()=>E(G[e]??[],Y)}));let _={};for(let e of x){let t=[m,...Object.entries(C).filter(([t,n])=>t!==m&&n.includes(e)).map(([e])=>e)],n=G[e]??[];_[e]=R(n),H.set(e,new a({name:e,interfaces:t.flatMap(e=>J.get(e)??[]),fields:()=>{let t=B.get(e);return{...E(n,Y),...t?{meta:{type:new o(t),description:"What can be done to this entity right now."}}:{}}}}))}let ee=(O=()=>X(J.has(f)?f:m),k=()=>X(m),M=new a({name:"DryRunError",description:"One reason a change cannot be made right now.",fields:{type:{type:new o(d),description:"Kind of the problem."},entityId:{type:n,description:"The entity the problem is on, when it is on one."},message:{type:d,description:"The problem as the user would be told it."}}}),new a({name:"DryRun",description:"What using a recipe or writing an option would do, tried out on the configuration the query reads. Nothing is changed.",fields:()=>({ok:{type:new o(e),description:"Whether the change would succeed on the configuration the query reads."},root:{type:O(),description:"The root entity of the configuration as it would be after the change; null when ok is false. Everything selected under it reads that configuration."},changedEntities:{type:new o(new r(new o(k()))),description:"Entities the change would add or modify; empty when ok is false. One whose id is not in the configuration would be added, and its real id may differ. An entity written to is listed even when its values stay the same."},deletedEntityIds:{type:new o(new r(new o(n))),description:"The ids of the entities the change would remove; empty when ok is false."},sideEffects:{type:new o(new r(new o(d))),description:"The major or unexpected things the configurator would change along with it; empty when ok is false."},errors:{type:new o(new r(new o(M))),description:"Why the change cannot be made; empty when ok is true."}})})),et={recipeGroup:(T=[...Object.keys(L).length>0?[b.mutation]:[],...Object.keys(Q).length>0?[v.mutation]:[]],D=T.join(" or "),F=new a({name:"Recipe",description:`${T.includes("addChild")?"One thing that can be added to the entity (under childRecipes)":"One thing the entity can be replaced with (under replaceRecipes)"}${T.length>1?" or that it can be replaced with (under replaceRecipes)":""}.`,fields:{key:{type:new o(d),description:`Pass to ${D} as recipeKey. Valid only for the listing it came from.`},name:{type:new o(d),description:"Name shown to the user."},description:{type:d},imageUrl:{type:d,description:"Thumbnail shown to the user."},dryRun:{type:ee,description:"What using this recipe would do. Null when it cannot be tried."}}}),new a({name:"RecipeGroup",description:"A group of recipes for this entity.",fields:{groupId:{type:new o(d),description:`Pass to ${D} as recipeGroupId.`},name:{type:new o(d),description:"Name shown to the user."},description:{type:d},recipes:{type:new o(new r(new o(F)))}}})),fieldOption:new a({name:"FieldOption",description:"One value a field accepts. Writing a value outside the list is rejected unless the field description says it is not checked.",fields:{value:{type:new o(h),description:"The value to write to the field."},name:{type:d,description:"Name shown to the user."},description:{type:d},imageUrl:{type:d,description:"Image shown to the user."},color:{type:d,description:'Color shown to the user, as "#rrggbb".'},dryRun:{type:ee,description:"What writing this value would do. Null when it cannot be tried."}}}),screenshot:new a({name:"Screenshot",description:"A screenshot of an entity. The picture itself follows the tool result.",fields:{image:{type:new o(n),description:"Label of the image that follows the tool result."}}})};for(let e of x){let n=j(t.childRecipes,e)??{groups:[],hints:[]},i=j(t.replaceRecipes,e)??{groups:[],hints:[]},s=j(z,e)??[],r=j(t.screenshots,e)??[];(n.groups.length>0||i.groups.length>0||s.length>0||r.length>0)&&B.set(e,A({entityType:e,childRecipes:n,replaceRecipes:i,optionsEdges:s.map(t=>({...t,hints:(C[f]??[]).includes(e)?t.hints.filter(e=>"sameForAllInstances"!==e):t.hints})),screenshots:r},et))}let en=new p({query:(I=X(J.has(f)?f:m),N=X(m),W=(e=>{let t={};for(let[n,i,s]of g){let r=e[s];r.length>1&&(t[n]={type:new o(d),description:$(i,r)})}if(0!==Object.keys(t).length)return new a({name:"Navigation",description:"The active UI states of the configurator.",fields:t})})(U),new a({name:"Query",fields:{root:{type:new o(I),description:"The root entity of the configuration."},entities:{type:new o(new r(N)),args:{ids:{type:new r(new o(n))}},description:"Every entity, or the given ids in order with null for an unknown id."},selectedEntity:{type:new o(N),description:"The selected entity, or the root entity when nothing is selected."},...W?{navigation:{type:new o(W)}}:{}}})),mutation:(({deletableTypes:e,writableTypes:t,childRecipes:s,replaceRecipes:p,actionFields:c,objectTypes:l,anyDomainEntity:h,targetOutputType:y})=>{let u,m;if(0!==e.length||0!==t.length||0!==Object.keys(s).length||0!==Object.keys(p).length||0!==c.length)return new a({name:"Mutation",fields:Object.assign(0===e.length?{}:{deleteEntity:{type:new o(new r(new o(n))),args:{id:{type:new o(n)}},description:`Deletes the entity and everything composed into it. Deletable types: ${e.join(", ")}. Returns the ids removed, the given one first.`}},0===(u=S(s)).length?{}:{addChild:{type:new o(new r(new o(h))),args:{parentId:{type:new o(n)},recipeGroupId:{type:new o(d)},recipeKey:{type:new o(d)}},description:`Adds a child to the entity parentId from a recipe listed under its meta { childRecipes }. Types with child recipes: ${u.join("; ")}. Returns the entities added, the recipe's own first; empty when they were removed again.`}},0===(m=S(p)).length?{}:{replaceEntity:{type:new o(new r(new o(h))),args:{entityId:{type:new o(n)},recipeGroupId:{type:new o(d)},recipeKey:{type:new o(d)}},description:`Replaces the entity entityId from a recipe listed under its meta { replaceRecipes }. Types with replace recipes: ${m.join("; ")}. The replacement is a new entity: it has a new id and the field values of its recipe, and entityId no longer exists. Returns the entities added, the replacement first; empty when they were removed again.`}},...t.flatMap(e=>{let t=l.get(e.entityType);return t?[(({entityType:e,fields:t},s)=>{let r=Object.fromEntries(t.map(({name:e,type:t,description:n})=>[e,{type:w(t),description:n}]));return{[`modify${e}`]:{type:s,args:{id:{type:new o(n)},delta:{type:new o(new i({name:`${e}Delta`,fields:r}))}},description:`Sets the fields named in delta on one ${e}. Returns the entity after the change, or null when the change removed it.`}}})(e,t)]:[]}),Object.fromEntries(c.map(e=>{var t;return[e.fieldName,{type:new o(new a({name:(t=e.fieldName,`${t.charAt(0).toUpperCase()+t.slice(1)}Result`),description:`What ${e.fieldName} returns, read from the configuration after the change.`,fields:()=>Object.fromEntries(Object.entries(e.result).map(([e,t])=>[e,{type:"edge"===t.kind?(({target:e,list:t,nullable:n},i)=>{let s=t?new r(new o(i(e))):i(e);return n?s:new o(s)})(t,y):w(t.type),description:t.description}]))})),args:Object.fromEntries(Object.entries(e.args).map(([e,t])=>[e,{type:w(t.type),description:t.description}])),description:e.description}]})))})})({deletableTypes:K,writableTypes:V,childRecipes:L,replaceRecipes:Q,actionFields:P,objectTypes:H,anyDomainEntity:X(m),targetOutputType:Y}),types:[...J.values(),...H.values()]}),ei=l(en);if(ei.length>0)throw Error(ei.map(e=>e.message).join(" "));let es=c(en);return{sdl:es,navigationFields:g.filter(([,,e])=>U[e].length>1).map(([e])=>e),fields:_,deletableTypes:K,writableFields:Object.fromEntries(V.map(({entityType:e,fields:t})=>[e,Object.fromEntries(t.map(({name:e,property:t})=>[e,t]))])),childRecipes:L,replaceRecipes:Q,fieldOptions:Object.fromEntries(x.flatMap(e=>{let t=j(z,e);return t?[[e,t.map(({options:e})=>e)]]:[]})),screenshots:Object.fromEntries(x.flatMap(e=>{let n=j(t.screenshots,e);return n?[[e,n]]:[]})),actions:Object.fromEntries(P.map(({fieldName:e,actionName:t})=>[e,t])),lenses:y(t,u(es)),formElements:t.formElements}};
1
+ import{GraphQLBoolean as e,GraphQLEnumType as t,GraphQLID as n,GraphQLInputObjectType as i,GraphQLInterfaceType as s,GraphQLList as r,GraphQLNonNull as o,GraphQLObjectType as a,GraphQLSchema as p,GraphQLString as d,printSchema as c,validateSchema as l}from"graphql";import{GraphQLJSON as h,createAssistantValueType as w}from"./assistant-value-type.js";import{buildAssistantLenses as y}from"./build-assistant-lenses.js";import{createAssistantExecutionSchema as u}from"./create-assistant-execution-schema.js";let g="AnyDomainEntity",f="RootEntity",m=[["navigationState","Active navigation state.","navigationStates"],["viewState","Active view state.","viewStates"],["toolState","Active tool state.","toolStates"]],b={section:"childRecipes",mutation:"addChild",typeSuffix:"ChildRecipes"},v={section:"replaceRecipes",mutation:"replaceEntity",typeSuffix:"ReplaceRecipes"},$=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],j=(e,t)=>{if(!t||0===t.length)return e;let n=`One of: ${t.map(e=>`"${e}"`).join(", ")}.`;return e?/[.!?]$/.test(e)?`${e} ${n}`:`${e}. ${n}`:n},O=({target:e,cardinality:t},n)=>{let i=n(e);switch(t){case"1-1":return new o(i);case"0-1":return i;case"0-N":case"1-N":return new o(new r(new o(i)))}},E=(e,t,i)=>{let s={id:{type:new o(n),description:i?`Unique id of the entity, assigned by the configurator, e.g. "${i}-1".`:void 0},type:{type:new o(d),description:i?`Entity type name, e.g. "${i}".`:void 0}};for(let n of e)s[n.name]={type:"edge"===n.type.kind?O(n.type,t):w(n.type.type),description:n.description};return s},R=e=>Object.fromEntries(e.map(({name:e,source:t,localized:n})=>[e,n?{source:t,localized:!0}:{source:t}])),k=new o(new r(new o(h))),T=' Each is { type, severity, entityId, message }: severity is "warning" or "notice", entityId the entity it is on or null, message the warning as the user would be told it or null.',I={sameForAllInstances:e=>`Same recipes for every ${e}.`,constantDuringSession:()=>"Fixed for the session."},N={sameForAllInstances:e=>`Same for every ${e}.`,constantDuringSession:()=>"Fixed for the session."},S=(e,t,n)=>e.map(e=>` ${t[e](n)}`).join(""),A=({section:e,typeSuffix:t},n,{entityType:i,purpose:s,recipeGroup:r})=>0===n.length?{}:{[e]:{type:new o(new a({name:`${i}${t}`,fields:Object.fromEntries(n.map(({groupId:e,description:t,dryRuns:n,hints:s})=>{let o;return[e,{type:r,description:`${!(o=t?.trim())?"":/[.!?]$/.test(o)?`${o} `:`${o}. `}Null while the configurator does not offer it on the entity.${n?"":" Cannot be dry-run."}${S(s,I,i)}`}]}))})),description:`The recipe groups for ${s} this ${i}, one field each.`}},M=({entityType:e,childRecipes:n,replaceRecipes:i,optionsEdges:s,screenshots:p,hasInvariants:d},{recipeGroup:c,fieldOption:l,screenshot:w})=>new a({name:`${e}Meta`,fields:Object.assign(A(b,n,{entityType:e,purpose:"adding children to",recipeGroup:c}),A(v,i,{entityType:e,purpose:"replacing",recipeGroup:c}),...s.map(({options:{edgeName:t,field:n,validate:i,dryRuns:s},hints:a})=>({[t]:{type:new r(new o(l)),args:{values:{type:new r(new o(h)),description:"Only the options with these values; values not listed are ignored."}},description:`Values "${n}" accepts on this ${e}. Null when there is no choice to make.${i?"":" Not checked on write."}${s?"":" Cannot be dry-run."}${S(a,N,e)}`}})),0===p.length?{}:{screenshot:{type:w,args:{view:{type:new o(new t({name:`${e}ScreenshotView`,values:Object.fromEntries(p.map(({view:e,description:t})=>[e,{description:t}]))}))}},description:"Renders this entity from a predefined view. The picture follows the tool result as an image labelled with `image`. Null when the view does not apply to this entity right now."}},d?{warnings:{type:k,description:`The warnings and notices this ${e} has right now.${T}`}}:{})}),D=(e,t)=>t?e?"What can be done to this entity right now, and its warnings.":"The warnings of this entity right now.":"What can be done to this entity right now.",W=e=>Object.entries(e).map(([e,t])=>`${e} (${t.map(({groupId:e})=>e).join(", ")})`);export const buildAssistantManifest=t=>{var O,I,N,S,A;let x,C,F,q,{entityTypes:G,aliases:U,exampleType:K,fields:P,states:V,deletableTypes:z,writableTypes:L,actionFields:Q,optionsEdges:B,invariantTypes:H}=t,{childRecipes:J,replaceRecipes:X}=t,Y=new Map,Z=new Map,_=new Map,ee=e=>{let[t,...n]=Object.entries(U).find(([t])=>t===e)?.[1]??[];return(t&&0===n.length?Z.get(t):void 0)??_.get(e)??en},et=e=>Z.get(e)??ee(e),en=new s({name:g,description:"Every entity of the configuration.",fields:()=>E(P[g]??[],et,K)});for(let e of(_.set(g,en),Object.keys(U)))e!==g&&_.set(e,new s({name:e,interfaces:[en],fields:()=>E(P[e]??[],et)}));let ei={};for(let e of G){let t=[g,...Object.entries(U).filter(([t,n])=>t!==g&&n.includes(e)).map(([e])=>e)],n=P[e]??[];ei[e]=R(n),Z.set(e,new a({name:e,interfaces:t.flatMap(e=>_.get(e)??[]),fields:()=>{let t=Y.get(e);return{...E(n,et),...t?{meta:{type:new o(t.type),description:t.description}}:{}}}}))}let es=(O=()=>ee(_.has(f)?f:g),I=()=>ee(g),x=new a({name:"DryRunError",description:"One reason a change cannot be made right now.",fields:{type:{type:new o(d),description:"Kind of the problem."},entityId:{type:n,description:"The entity the problem is on, when it is on one."},message:{type:d,description:"The problem as the user would be told it."}}}),new a({name:"DryRun",description:"What using a recipe or writing an option would do, tried out on the configuration the query reads. Nothing is changed.",fields:()=>({ok:{type:new o(e),description:"Whether the change would succeed on the configuration the query reads."},root:{type:O(),description:"The root entity of the configuration as it would be after the change; null when ok is false. Everything selected under it reads that configuration."},changedEntities:{type:new o(new r(new o(I()))),description:"Entities the change would add or modify; empty when ok is false. One whose id is not in the configuration would be added, and its real id may differ. An entity written to is listed even when its values stay the same."},deletedEntityIds:{type:new o(new r(new o(n))),description:"The ids of the entities the change would remove; empty when ok is false."},sideEffects:{type:new o(new r(new o(d))),description:"The major or unexpected things the configurator would change along with it; empty when ok is false."},warnings:{type:k,description:`The warnings and notices the change would newly cause, which do not stop it; empty when ok is false.${T}`},errors:{type:new o(new r(new o(x))),description:"Why the change cannot be made; empty when ok is true."}})})),er={recipeGroup:(N=[...Object.keys(J).length>0?[b.mutation]:[],...Object.keys(X).length>0?[v.mutation]:[]],C=N.join(" or "),F=new a({name:"Recipe",description:`${N.includes("addChild")?"One thing that can be added to the entity (under childRecipes)":"One thing the entity can be replaced with (under replaceRecipes)"}${N.length>1?" or that it can be replaced with (under replaceRecipes)":""}.`,fields:{key:{type:new o(d),description:`Pass to ${C} as recipeKey, or to recipes(keys:) to read this recipe again.`},name:{type:new o(d),description:"Name shown to the user."},description:{type:d},imageUrl:{type:d,description:"Thumbnail shown to the user."},dryRun:{type:es,description:"What using this recipe would do. Null when it cannot be tried."}}}),new a({name:"RecipeGroup",description:"A group of recipes for this entity.",fields:{groupId:{type:new o(d),description:`Pass to ${C} as recipeGroupId.`},name:{type:new o(d),description:"Name shown to the user."},description:{type:d},recipes:{type:new o(new r(new o(F))),args:{keys:{type:new r(new o(d)),description:"Only the recipes with these keys; keys not in the group are ignored."}}}}})),fieldOption:new a({name:"FieldOption",description:"One value a field accepts. Writing a value outside the list is rejected unless the field description says it is not checked.",fields:{value:{type:new o(h),description:"The value to write to the field."},name:{type:d,description:"Name shown to the user."},description:{type:d},imageUrl:{type:d,description:"Image shown to the user."},color:{type:d,description:'Color shown to the user, as "#rrggbb".'},dryRun:{type:es,description:"What writing this value would do. Null when it cannot be tried."}}}),screenshot:new a({name:"Screenshot",description:"A screenshot of an entity. The picture itself follows the tool result.",fields:{image:{type:new o(n),description:"Label of the image that follows the tool result."}}})};for(let e of G){let n=$(J,e)??[],i=$(X,e)??[],s=$(B,e)??[],r=$(t.screenshots,e)??[],o=H.includes(e),a=n.length>0||i.length>0||s.length>0||r.length>0;(a||o)&&Y.set(e,{description:D(a,o),type:M({entityType:e,childRecipes:n,replaceRecipes:i,optionsEdges:s,screenshots:r,hasInvariants:o},er)})}let eo=new p({query:(S=ee(_.has(f)?f:g),A=ee(g),q=(e=>{let t={};for(let[n,i,s]of m){let r=e[s];r.length>1&&(t[n]={type:new o(d),description:j(i,r)})}if(0!==Object.keys(t).length)return new a({name:"Navigation",description:"The active UI states of the configurator.",fields:t})})(V),new a({name:"Query",fields:{root:{type:new o(S),description:"The root entity of the configuration."},entities:{type:new o(new r(A)),args:{ids:{type:new r(new o(n))}},description:"Every entity, or the given ids in order with null for an unknown id."},selectedEntity:{type:new o(A),description:"The selected entity, or the root entity when nothing is selected."},...q?{navigation:{type:new o(q)}}:{},warnings:{type:k,description:`Every warning and notice of the configuration the query reads.${T}`}}})),mutation:(({deletableTypes:e,writableTypes:t,childRecipes:s,replaceRecipes:p,actionFields:c,objectTypes:l,anyDomainEntity:h,targetOutputType:y})=>{let u,g;if(0!==e.length||0!==t.length||0!==Object.keys(s).length||0!==Object.keys(p).length||0!==c.length)return new a({name:"Mutation",fields:Object.assign(0===e.length?{}:{deleteEntity:{type:new o(new r(new o(n))),args:{id:{type:new o(n)}},description:`Deletes the entity and everything composed into it. Deletable types: ${e.join(", ")}. Returns the ids removed, the given one first.`}},0===(u=W(s)).length?{}:{addChild:{type:new o(new r(new o(h))),args:{parentId:{type:new o(n)},recipeGroupId:{type:new o(d)},recipeKey:{type:new o(d)}},description:`Adds a child to the entity parentId from a recipe listed under its meta { childRecipes }. Types with child recipes: ${u.join("; ")}. Returns the entities added, the recipe's own first; empty when they were removed again.`}},0===(g=W(p)).length?{}:{replaceEntity:{type:new o(new r(new o(h))),args:{entityId:{type:new o(n)},recipeGroupId:{type:new o(d)},recipeKey:{type:new o(d)}},description:`Replaces the entity entityId from a recipe listed under its meta { replaceRecipes }. Types with replace recipes: ${g.join("; ")}. The replacement is a new entity: it has a new id and the field values of its recipe, and entityId no longer exists. Returns the entities added, the replacement first; empty when they were removed again.`}},...t.flatMap(e=>{let t=l.get(e.entityType);return t?[(({entityType:e,fields:t},s)=>{let r=Object.fromEntries(t.map(({name:e,type:t,description:n})=>[e,{type:w(t),description:n}]));return{[`modify${e}`]:{type:s,args:{id:{type:new o(n)},delta:{type:new o(new i({name:`${e}Delta`,fields:r}))}},description:`Sets the fields named in delta on one ${e}. Returns the entity after the change, or null when the change removed it.`}}})(e,t)]:[]}),Object.fromEntries(c.map(e=>{var t;return[e.fieldName,{type:new o(new a({name:(t=e.fieldName,`${t.charAt(0).toUpperCase()+t.slice(1)}Result`),description:`What ${e.fieldName} returns, read from the configuration after the change.`,fields:()=>Object.fromEntries(Object.entries(e.result).map(([e,t])=>[e,{type:"edge"===t.kind?(({target:e,list:t,nullable:n},i)=>{let s=t?new r(new o(i(e))):i(e);return n?s:new o(s)})(t,y):w(t.type),description:t.description}]))})),args:Object.fromEntries(Object.entries(e.args).map(([e,t])=>[e,{type:w(t.type),description:t.description}])),description:e.description}]})))})})({deletableTypes:z,writableTypes:L,childRecipes:J,replaceRecipes:X,actionFields:Q,objectTypes:Z,anyDomainEntity:ee(g),targetOutputType:et}),types:[..._.values(),...Z.values()]}),ea=l(eo);if(ea.length>0)throw Error(ea.map(e=>e.message).join(" "));let ep=c(eo);return{sdl:ep,navigationFields:m.filter(([,,e])=>V[e].length>1).map(([e])=>e),fields:ei,deletableTypes:z,writableFields:Object.fromEntries(L.map(({entityType:e,fields:t})=>[e,Object.fromEntries(t.map(({name:e,property:t})=>[e,t]))])),childRecipes:J,replaceRecipes:X,fieldOptions:Object.fromEntries(G.flatMap(e=>{let t=$(B,e);return t?[[e,t.map(({options:e})=>e)]]:[]})),screenshots:Object.fromEntries(G.flatMap(e=>{let n=$(t.screenshots,e);return n?[[e,n]]:[]})),actions:Object.fromEntries(Q.map(({fieldName:e,actionName:t})=>[e,t])),lenses:y(t,u(ep)),formElements:t.formElements}};
@@ -1 +1 @@
1
- import{ASSISTANT_BUILT_IN_FORM_ELEMENTS as e}from"./form/index.js";let t=[["Containers",["group","choice","choices"]],["Options",["option"]],["Inputs",["input"]]];export const formElementSignature=({name:e,role:t,attributes:a})=>{let n=["label",...Object.entries(a).map(([e,t])=>((e,{type:t,enum:a})=>a?`${e}="${a.join("|")}"`:"string"===t?e:`${e}="<${t}>"`)(e,t))];return"option"===t||"input"===t?`<${e} ${n.join(" ")} />`:`<${e} ${n.join(" ")}>…</${e}>`};export const generateAssistantPrompt=a=>{let n,s=Object.values(a.childRecipes??{}).some(e=>e.length>0),o=Object.values(a.replaceRecipes??{}).some(e=>e.length>0),i=Object.values(a.fieldOptions??{}).some(e=>e.length>0),r=Object.keys(a.actions??{}).length>0,h=Object.values(a.screenshots??{}).some(e=>e.length>0),l=(a.deletableTypes?.length??0)>0||Object.values(a.writableFields??{}).some(e=>Object.keys(e).length>0)||s||o||r,d=s||o||i,u=[...s?["`childRecipes` is what can be added to it"]:[],...o?["`replaceRecipes` what it can be replaced with"]:[],...i?["`<field>Options` the values a field accepts"]:[]],c=["`selected`",...(a.navigationFields??[]).map(e=>`\`${e}\``)].join(", ");return[["Tools","- Put related operations in one call and select only the fields you need.",...l?[`- Use a mutation inside \`query\` to answer a what-if about a change ${d?"the lists under `meta` do not show":"before making it"}.`,"- Use `apply` only for what the user asked for."]:["- Nothing in this configurator can be changed through you. Say so when the user asks for a change."],"- When an operation fails, its `errors` say why and what to send instead."],...l?[["After a change","- A change is made only when the `apply` result has `committed: true`. Otherwise `errors` or `message` says what happened; without either, nothing changed. Never say a change was made when it was not.","- `sideEffects` names the major or unexpected things the configurator changed along with your change. Tell the user about them when committed; otherwise they describe what would happen. Smaller adjustments are not listed.","- A mutation returns the state after the change: use the ids and values it returned, not the ones you sent.",...r?["- When one mutation does the whole of what the user asked, use it instead of building the same change from several others."]:[]]]:[],...d?[["What can be done to an entity",`- \`meta\` lists what is possible right now: ${u.join(", ")}. Read the list before such a change and before telling the user what is available.`,`- You can select \`dryRun\` on ${[...s||o?["recipes"]:[],...i?["options"]:[]].join(" or ")} to look ahead and pick one that meets what the user asked for. It is optional before a change.`,"- Read the lists again after a change, unless their descriptions say they stay the same."]]:[],...h?[["Seeing the design","- `meta { screenshot(view: …) { image } }` renders an entity from one of the views its `<Type>ScreenshotView` lists. The picture follows the tool result.","- Take one when the user asks how the design looks, or when you are not sure something is laid out right: what sits where, what overlaps or lines up. Otherwise rely on the data.","- Each one costs tokens and blocks the user's configurator while it renders."]]:[],["The `[changes]` block","- Every user message starts with it: a glimpse of what the user did in the configurator since your last turn.",`- \`[changes: none]\`, or only ${c} lines: what you know still holds. Do not query it again.`,"- Other lines are a hint at what to read again: `A` added, `D` deleted, `M` modified with the fields. Text after `#` says what caused the line; `reset: undo/redo` says the user undid or redid changes.","- Read computed fields again when a listed change may affect them.","- `[changes: unavailable]` and `[changes: too many (n)]`: read again before relying on anything you read earlier.",...l?["- Your applied changes are not listed, except those waiting for user approval: they appear once approved."]:[]],["Reading the schema","- Take ids from results.",...(a.deletableTypes?.length??0)>0||o?["- The id of a deleted or replaced entity is gone and may later be given to another entity."]:[],`- A field whose name starts with \`_\` is computed: read it${l?", never write it":""}.`,"- Numbers are in the unit the field description names. Convert when the user uses another unit."],["Links","- You may link an entity of the current configuration when you speak about that very entity: `[the left burner](entity:CookingTop-1)`. It helps the user find it in the configurator.",...d?["- Whenever you name recipes or options you read from `meta`, in a list, a table or a sentence, link each one: `[Single gas burner](recipe:KitchenRange-1/top/gas_single)` or `[Oak](option:Cabinet-2/finishOptions/oak)`. The link shows the user its picture or color and its description, so never draw previews yourself. The target is the entity id, the recipe group id or the options field you read, and the key or value, each encoded as in a URL."]:[]],["Replies","- Write Markdown only, never HTML: the panel does not render it.","- An image, `![alt](path)`, is shown only when its path is relative.","- To make a warning or a key note stand out, write a GitHub alert: a blockquote whose first line is only `[!WARNING]` or `[!NOTE]`. Use it sparingly."],["Forms","- To ask the user something they answer by picking or typing, end your reply with a form: a fenced code block with the language `form`. It holds only elements, written as lowercase tags with string attributes, without Markdown or text.","- Every element takes `label`, the text the user sees; on a container or an input it also names the answer. An option or an input whose signature lists `value` takes it: an option sends it instead of its label, and an input starts with it.",'- A bare attribute in a signature takes any text, `name="<type>"` takes a value of that type written as text, such as `min="<number>"`, and `name="a|b"` takes one of the words listed.',"- Options can also stand on their own, outside a `choice` or `choices`.","- An element or attribute not listed here, or an element other than an option inside a `choice` or `choices`, makes the whole form fail.","- The answer is the user's next message. Each container or input gives a line `Label: value`, or the bare value without a label; the lines of a labelled container are indented by two spaces under it, a `choices` lists each picked option on its own line, and `—` marks what was left unanswered.",'- Example: `<choice label="Plinth"><reply label="Black" /><reply label="Oak" /></choice>` is answered with `Plinth: Oak`.',"- The chat shows the answer as the user's own message, so a `value` reads as natural words, never as an id, key or code. Give `value` only when the label alone would be unclear as an answer, and map the answer's labels back to ids yourself.",...(n=[...e,...a.formElements??[]],t.flatMap(([e,t])=>{let a=n.filter(({role:e})=>t.includes(e));return 0===a.length?[]:[`- ${e}:`,...a.map(e=>` - \`${formElementSignature(e)}\`: ${(({description:e,required:t=[]})=>0===t.length?e:`${e} Requires ${t.map(e=>`\`${e}\``).join(", ")}.`)(e)}`)]}))],...a.lenses?.declarations?[["Built-in fragments","- These fragments are already defined for every operation. Spread one by name on a field of its type, as in `field { ...FragmentName }`, instead of listing its fields.","- A fragment is a starting selection: add the other fields you need next to the spread, by name from the schema.","- Never define a fragment with one of these names.","",a.lenses.declarations]]:[]].map(e=>e.join("\n")).join("\n\n")};
1
+ import{ASSISTANT_BUILT_IN_FORM_ELEMENTS as e}from"./form/index.js";let t=[["Containers",["group","choice","choices"]],["Options",["option"]],["Inputs",["input"]]];export const formElementSignature=({name:e,role:t,attributes:a})=>{let n=["label",...Object.entries(a).map(([e,t])=>((e,{type:t,enum:a})=>a?`${e}="${a.join("|")}"`:"string"===t?e:`${e}="<${t}>"`)(e,t))];return"option"===t||"input"===t?`<${e} ${n.join(" ")} />`:`<${e} ${n.join(" ")}>…</${e}>`};export const generateAssistantPrompt=a=>{let n,s=Object.values(a.childRecipes??{}).some(e=>e.length>0),o=Object.values(a.replaceRecipes??{}).some(e=>e.length>0),i=Object.values(a.fieldOptions??{}).some(e=>e.length>0),r=Object.keys(a.actions??{}).length>0,h=Object.values(a.screenshots??{}).some(e=>e.length>0),l=(a.deletableTypes?.length??0)>0||Object.values(a.writableFields??{}).some(e=>Object.keys(e).length>0)||s||o||r,d=s||o||i,u=[...s?["`childRecipes` is what can be added to it"]:[],...o?["`replaceRecipes` what it can be replaced with"]:[],...i?["`<field>Options` the values a field accepts"]:[]],c=["`selected`",...(a.navigationFields??[]).map(e=>`\`${e}\``)].join(", ");return[["Tools","- Put related operations in one call and select only the fields you need.",`- Give every ${l?"`query` and `apply` call":"`query` call"} a \`title\` of two to five words in the user's language that says what it does for them, e.g. ${l?'"Add two drawers"':'"Compare drawer prices"'}.`,...l?[`- Use a mutation inside \`query\` to answer a what-if about a change ${d?"the lists under `meta` do not show":"before making it"}.`,"- Use `apply` only for what the user asked for."]:["- Nothing in this configurator can be changed through you. Say so when the user asks for a change."],"- When an operation fails, its `errors` say why and what to send instead. A change the configuration does not allow fails with one error per reason, as the user would be told it.","- Warnings and notices never make anything fail. The root `warnings` field lists every current one, and `meta { warnings }` those of one entity, where its type has them."],...l?[["After a change","- A change is made only when the `apply` result has `committed: true`. Otherwise `errors` or `message` says what happened; without either, nothing changed. Never say a change was made when it was not.","- `sideEffects` names the major or unexpected things the configurator changed along with your change. Tell the user about them when committed; otherwise they describe what would happen. Smaller adjustments are not listed.","- `warnings` lists the warnings and notices your change newly causes. They do not block it: tell the user about them, and offer a fix when one is clear.","- A mutation returns the state after the change: use the ids and values it returned, not the ones you sent.",...r?["- When one mutation does the whole of what the user asked, use it instead of building the same change from several others."]:[]]]:[],...d?[["What can be done to an entity",`- \`meta\` lists what is possible right now: ${u.join(", ")}. Read the list before such a change and before telling the user what is available.`,`- You can select \`dryRun\` on ${[...s||o?["recipes"]:[],...i?["options"]:[]].join(" or ")} to look ahead and pick one that meets what the user asked for. It is optional before a change.`,`- Select only the ${[...s||o?["recipe groups"]:[],...i?["options edges"]:[]].join(" and ")} you need. To read again only the ones you are deciding between, pass ${[...s||o?["their `key` to `recipes(keys:)`"]:[],...i?["their `value` to `<field>Options(values:)`"]:[]].join(" or ")}.`,"- Read the lists again after a change, unless their descriptions say they stay the same."]]:[],...h?[["Seeing the design","- `meta { screenshot(view: …) { image } }` renders an entity from one of the views its `<Type>ScreenshotView` lists. The picture follows the tool result.","- Take one when the user asks how the design looks, or when you are not sure something is laid out right: what sits where, what overlaps or lines up. Otherwise rely on the data.","- Each one costs tokens and blocks the user's configurator while it renders."]]:[],["The `[changes]` block","- Every user message starts with it: a glimpse of what the user did in the configurator since your last turn.",`- \`[changes: none]\`, or only ${c} lines: what you know still holds. Do not query it again.`,"- Other lines are a hint at what to read again: `A` added, `D` deleted, `M` modified with the fields. Text after `#` says what caused the line; `reset: undo/redo` says the user undid or redid changes.","- Read computed fields again when a listed change may affect them.","- `[changes: unavailable]` and `[changes: too many (n)]`: read again before relying on anything you read earlier.",...l?["- Your applied changes are not listed, except those waiting for user approval: they appear once approved."]:[]],["Reading the schema","- Take ids from results.",...(a.deletableTypes?.length??0)>0||o?["- The id of a deleted or replaced entity is gone and may later be given to another entity."]:[],`- A field whose name starts with \`_\` is computed: read it${l?", never write it":""}.`,"- Numbers are in the unit the field description names. Convert when the user uses another unit."],["Links","- You may link an entity of the current configuration when you speak about that very entity: `[the left burner](entity:CookingTop-1)`. It helps the user find it in the configurator.",...d?["- Whenever you name recipes or options you read from `meta`, in a list, a table or a sentence, link each one: `[Single gas burner](recipe:KitchenRange-1/top/gas_single)` or `[Oak](option:Cabinet-2/finishOptions/oak)`. The link shows the user its picture or color and its description, so never draw previews yourself. The target is the entity id, the recipe group id or the options field you read, and the key or value, each encoded as in a URL."]:[]],["Replies","- Write Markdown only, never HTML: the panel does not render it.","- An image, `![alt](path)`, is shown only when its path is relative.","- To make a warning or a key note stand out, write a GitHub alert: a blockquote whose first line is only `[!WARNING]` or `[!NOTE]`. Use it sparingly."],["Forms","- To ask the user something they answer by picking or typing, end your reply with a form: a fenced code block with the language `form`. It holds only elements, written as lowercase tags with string attributes, without Markdown or text.","- Every element takes `label`, the text the user sees; on a container or an input it also names the answer. An option or an input whose signature lists `value` takes it: an option sends it instead of its label, and an input starts with it.",'- A bare attribute in a signature takes any text, `name="<type>"` takes a value of that type written as text, such as `min="<number>"`, and `name="a|b"` takes one of the words listed.',"- Options can also stand on their own, outside a `choice` or `choices`.","- An element or attribute not listed here, or an element other than an option inside a `choice` or `choices`, makes the whole form fail.","- The answer is the user's next message. Each container or input gives a line `Label: value`, or the bare value without a label; the lines of a labelled container are indented by two spaces under it, a `choices` lists each picked option on its own line, and `—` marks what was left unanswered.",'- Example: `<choice label="Plinth"><reply label="Black" /><reply label="Oak" /></choice>` is answered with `Plinth: Oak`.',"- The chat shows the answer as the user's own message, so a `value` reads as natural words, never as an id, key or code. Give `value` only when the label alone would be unclear as an answer, and map the answer's labels back to ids yourself.",...(n=[...e,...a.formElements??[]],t.flatMap(([e,t])=>{let a=n.filter(({role:e})=>t.includes(e));return 0===a.length?[]:[`- ${e}:`,...a.map(e=>` - \`${formElementSignature(e)}\`: ${(({description:e,required:t=[]})=>0===t.length?e:`${e} Requires ${t.map(e=>`\`${e}\``).join(", ")}.`)(e)}`)]}))],...a.lenses?.declarations?[["Built-in fragments","- These fragments are already defined for every operation. Spread one by name on a field of its type, as in `field { ...FragmentName }`, instead of listing its fields.","- A fragment is a starting selection: add the other fields you need next to the spread, by name from the schema.","- Never define a fragment with one of these names.","",a.lenses.declarations]]:[]].map(e=>e.join("\n")).join("\n\n")};
@@ -1,9 +1,9 @@
1
- export { ASSISTANT_HINTS } from './assistant-resolved-manifest.js';
2
- export type { AssistantResolvedManifest, AssistantDeclaredField, AssistantDeclarations, AssistantDeclaredWrite, AssistantResolvedField, AssistantValueType, AssistantRelationType, AssistantStates, AssistantWritableType, AssistantWritableField, AssistantResolvedHint, AssistantResolvedRecipes, AssistantResolvedOptionsEdge, AssistantResolvedAction, AssistantResolvedActionResult, } from './assistant-resolved-manifest.js';
1
+ export { ASSISTANT_HINTS } from './assistant-manifest.js';
2
+ export type { AssistantResolvedManifest, AssistantDeclaredField, AssistantDeclarations, AssistantDeclaredWrite, AssistantResolvedField, AssistantValueType, AssistantRelationType, AssistantStates, AssistantWritableType, AssistantWritableField, AssistantResolvedRecipes, AssistantResolvedOptionsEdge, AssistantResolvedAction, AssistantResolvedActionResult, } from './assistant-resolved-manifest.js';
3
3
  export { buildAssistantManifest } from './build-assistant-manifest.js';
4
4
  export type { AssistantFieldExposure } from './create-assistant-execution-schema.js';
5
5
  export { AssistantFieldClashError, createAssistantExecutionSchema } from './create-assistant-execution-schema.js';
6
- export type { AssistantFieldSource, AssistantRecipeGroup, AssistantFieldOptions, AssistantScreenshotView, AssistantManifest, } from './assistant-manifest.js';
6
+ export type { AssistantFieldSource, AssistantResolvedHint, AssistantRecipeGroup, AssistantFieldOptions, AssistantScreenshotView, AssistantManifest, } from './assistant-manifest.js';
7
7
  export { generateAssistantPrompt } from './generate-assistant-prompt.js';
8
8
  export * from './session-setup/index.js';
9
9
  export { describeAssistantValues, mergeAssistantFields, resolveAssistantField } from './assistant-fields.js';
@@ -1 +1 @@
1
- export{ASSISTANT_HINTS}from"./assistant-resolved-manifest.js";export{buildAssistantManifest}from"./build-assistant-manifest.js";export{AssistantFieldClashError,createAssistantExecutionSchema}from"./create-assistant-execution-schema.js";export{generateAssistantPrompt}from"./generate-assistant-prompt.js";export*from"./session-setup/index.js";export{describeAssistantValues,mergeAssistantFields,resolveAssistantField}from"./assistant-fields.js";export*from"./form/index.js";
1
+ export{ASSISTANT_HINTS}from"./assistant-manifest.js";export{buildAssistantManifest}from"./build-assistant-manifest.js";export{AssistantFieldClashError,createAssistantExecutionSchema}from"./create-assistant-execution-schema.js";export{generateAssistantPrompt}from"./generate-assistant-prompt.js";export*from"./session-setup/index.js";export{describeAssistantValues,mergeAssistantFields,resolveAssistantField}from"./assistant-fields.js";export*from"./form/index.js";
@@ -1 +1 @@
1
- import{ASSISTANT_AI_PROVIDERS as e,ASSISTANT_MODEL_TIERS as t,ASSISTANT_REASONING_LEVELS as s}from"@salsita-ai/contracts/assistant";import{describeAssistantValues as i,mergeAssistantFields as n,resolveAssistantField as o}from"../assistant-fields.js";import{ASSISTANT_HINTS as r}from"../assistant-resolved-manifest.js";import{projectAssistantSetupManifest as a}from"./assistant-setup-manifest.js";export class AssistantSetupError extends Error{constructor(e,t){super(`${e}: ${t}`),this.name="AssistantSetupError"}}let l=(e,t)=>{throw new AssistantSetupError(e,t)},p=(e,t,s)=>{for(let i of((null===t||"object"!=typeof t||Array.isArray(t))&&l(s,"expected an object; omit an entry to remove it"),Object.keys(t)))Object.hasOwn(e,i)||l(`${s}.${i}`,"not declared in the spec; remove this key")},c=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0,d=(e,t,s)=>(void 0!==e&&"string"!=typeof e&&l(`${s}.description`,"expected a string"),e??t),u=(e,t,s)=>(void 0!==e&&!1!==e&&l(`${s}.allowDryRuns`,"can only disable dry-runs; omit this flag or set false"),!1!==e&&t);export const applyAssistantSetup=(f,m,b)=>{if(null===b)return null;let y=a(f,m),g=f.declarations;p({entities:{},deletable:{},writable:{},childRecipes:{},replaceRecipes:{},screenshots:{},actions:{},instructions:"",ai:{}},b,"assistant"),p(y.entities,b.entities,"assistant.entities"),p(y.deletable,b.deletable,"assistant.deletable"),p(y.writable,b.writable,"assistant.writable"),p(y.actions,b.actions,"assistant.actions"),p(y.screenshots,b.screenshots,"assistant.screenshots");let h=Object.fromEntries(Object.entries(b.entities).map(([e,t])=>{let s=`assistant.entities.${e}`;p(y.entities[e],t,s);let n=g.entities[e];return[e,Object.entries(t).map(([e,t])=>{p({description:""},t,`${s}.${e}`);let o=n.find(t=>t.source===e),r=d(t.description,o.valueDescription,`${s}.${e}`);return{...o,valueDescription:r,description:i(r,o.enumValues),describedByManifest:void 0!==t.description||o.describedByManifest}})]})),v=(e,t,s)=>l(`assistant.entities.${e}`,`conflicting sources ${t} and ${s}`),$=n([],c(h,"AnyDomainEntity")??[],()=>void 0,v),w=new Map([["AnyDomainEntity",$]]);for(let e of Object.keys(f.aliases))"AnyDomainEntity"!==e&&w.set(e,n([$],c(h,e)??[],()=>void 0,v));for(let e of f.entityTypes){let t=Object.entries(f.aliases).filter(([t,s])=>"AnyDomainEntity"!==t&&s.includes(e));w.set(e,n([$,...t.map(([e])=>w.get(e)??[])],c(h,e)??[],t=>g.enumValues[e]?.[t],v))}let j=Object.fromEntries([...w].map(([e,t])=>[e,t.map(t=>o(t,c(h,e)??[]))])),O=new Map,T=new Map;for(let[e,t]of Object.entries(b.writable)){let s=`assistant.writable.${e}`;for(let[i,n]of(p(y.writable[e],t,s),Object.entries(t))){let t=`${s}.${i}`,o=g.writable[e][i];for(let[e,{field:s,options:r,exposedDescription:a}]of(p(Object.values(o.members).some(e=>e.options)?{options:{}}:{},n,t),void 0!==n.options&&(p({validate:!0,allowDryRuns:!1},n.options,`${t}.options`),void 0!==n.options.validate&&!0!==n.options.validate&&l(`${t}.options.validate`,"can only enable validation; omit this flag or set true"),u(n.options.allowDryRuns,!0,`${t}.options`)),Object.entries(o.members))){let p=c(h,e)?.find(e=>e.source===i)?.name??w.get(e)?.find(e=>e.source===i)?.name,d=p??i;void 0===p&&w.get(e)?.some(e=>e.name===i&&e.source!==i)&&l(t,`narrowing leaves ${e}.${i} bound to another read field; retain its original exposure or remove this writable property`);let f=O.get(e)??new Map;if([...f.values()].some(e=>e.name===d&&e.property!==i)&&l(t,`narrowing maps multiple writable properties to ${e}.${d}; retain their original exposures or remove the conflicting property`),f.has(i)||f.set(i,{...s,name:d,...void 0===p?{}:{description:a}}),O.set(e,f),r){let s=o.defaultOptionsName?`${d}Options`:r.options.edgeName;T.get(e)?.some(e=>e.options.edgeName===s||e.options.field===d)&&l(`${t}.options`,`narrowing duplicates options edge ${e}.${s}; retain the original field exposures or remove the conflicting writable declaration`),T.set(e,[...T.get(e)??[],{hints:r.hints,options:{...r.options,field:d,edgeName:s,validate:n.options?.validate??r.options.validate,dryRuns:u(n.options?.allowDryRuns,r.options.dryRuns,`${t}.options`)}}])}}}}for(let[e,t]of Object.entries(f.optionsEdges))for(let s of t){let t=f.writableTypes.find(t=>t.entityType===e)?.fields.find(e=>e.name===s.options.field)?.property;if(s.options.validate&&t&&O.get(e)?.has(t)&&!T.get(e)?.some(s=>s.options.field===O.get(e)?.get(t)?.name&&s.options.validate)){let s=Object.keys(b.writable).find(s=>Object.hasOwn(b.writable[s],t)&&g.writable[s]?.[t]?.members[e]);l(`assistant.writable.${s}.${t}`,`cannot remove declared validation while another declaration keeps ${e}.${t} writable; remove all writable declarations for it`)}}let x=e=>{p(y[e],b[e],`assistant.${e}`);let t=new Map;for(let[s,i]of Object.entries(b[e])){let n=`assistant.${e}.${s}`;p({groups:{}},i,n),p(y[e][s].groups,i.groups,`${n}.groups`);let o=g[e][s],a=Object.entries(i.groups).map(([e,t])=>{let s=`${n}.groups.${e}`;p({description:"",allowDryRuns:!1},t,s);let i=o.groups.find(t=>t.instanceName===e);return{...i,description:d(t.description,i.description,s),dryRuns:u(t.allowDryRuns,i.dryRuns,s)}});for(let e of f.entityTypes.includes(s)?[s]:f.aliases[s]??[]){let s=t.get(e);t.set(e,{groups:[...s?.groups??[],...a],hints:r.filter(e=>o.hints.includes(e)||s?.hints.includes(e))})}}return Object.fromEntries(f.entityTypes.flatMap(e=>{let s=t.get(e);return s?.groups.length?[[e,s]]:[]}))},E=new Map;for(let[e,t]of Object.entries(b.screenshots)){let s=`assistant.screenshots.${e}`;p(y.screenshots[e],t,s);let i=f.entityTypes.includes(e)?[e]:f.aliases[e]??[];for(let[n,o]of Object.entries(t)){let t=`${s}.${n}`;p({description:""},o,t);let r=g.screenshots[e].find(e=>e.instanceName===n),a={...r,description:d(o.description,r.description,t)??r.description};for(let e of i)E.set(e,[...E.get(e)??[],a])}}for(let[e,t]of Object.entries(b.deletable))p({},t,`assistant.deletable.${e}`);let R=new Set(Object.keys(b.deletable).flatMap(e=>f.entityTypes.includes(e)?[e]:f.aliases[e]??[])),M=f.actionFields.flatMap(e=>{let t=c(b.actions,e.actionName);if(void 0===t)return[];let s=`assistant.actions.${e.actionName}`;return p({description:""},t,s),[{...e,description:d(t.description,e.description,s)}]}),D=m;if(m){void 0!==b.ai&&p({...m.ai,maxThreadSize:void 0},b.ai,"assistant.ai");let i={...m.ai,...Object.fromEntries(Object.entries(b.ai??{}).filter(([,e])=>void 0!==e))};e.includes(i.provider)&&t.includes(i.model)&&s.includes(i.reasoning)||l("assistant.ai","expected a supported provider, model and reasoning level"),void 0!==i.maxThreadSize&&(!Number.isInteger(i.maxThreadSize)||i.maxThreadSize<=0)&&l("assistant.ai.maxThreadSize","expected a positive whole number of input tokens"),void 0!==b.instructions&&"string"!=typeof b.instructions&&l("assistant.instructions","expected a string"),D={instructions:""===b.instructions?null:b.instructions??m.instructions,ai:i}}return{resolved:{...f,fields:j,deletableTypes:f.entityTypes.filter(e=>R.has(e)),writableTypes:f.entityTypes.flatMap(e=>{let t=[...O.get(e)?.values()??[]];return t.length?[{entityType:e,fields:t}]:[]}),optionsEdges:Object.fromEntries(T),childRecipes:x("childRecipes"),replaceRecipes:x("replaceRecipes"),screenshots:Object.fromEntries(f.entityTypes.flatMap(e=>{let t=E.get(e);return t?[[e,t]]:[]})),actionFields:M},settings:D}};
1
+ import{ASSISTANT_AI_PROVIDERS as e,ASSISTANT_MODEL_TIERS as t,ASSISTANT_REASONING_LEVELS as i}from"@salsita-ai/contracts/assistant";import{describeAssistantValues as s,mergeAssistantFields as n,resolveAssistantField as o}from"../assistant-fields.js";import{projectAssistantSetupManifest as a}from"./assistant-setup-manifest.js";export class AssistantSetupError extends Error{constructor(e,t){super(`${e}: ${t}`),this.name="AssistantSetupError"}}let r=(e,t)=>{throw new AssistantSetupError(e,t)},l=(e,t,i)=>{for(let s of((null===t||"object"!=typeof t||Array.isArray(t))&&r(i,"expected an object; omit an entry to remove it"),Object.keys(t)))Object.hasOwn(e,s)||r(`${i}.${s}`,"not declared in the spec; remove this key")},p=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0,c=(e,t,i)=>(void 0!==e&&"string"!=typeof e&&r(`${i}.description`,"expected a string"),e??t),d=(e,t,i)=>(void 0!==e&&!1!==e&&r(`${i}.allowDryRuns`,"can only disable dry-runs; omit this flag or set false"),!1!==e&&t);export const applyAssistantSetup=(f,u,m)=>{if(null===m)return null;let b=a(f,u),y=f.declarations;l({entities:{},deletable:{},writable:{},childRecipes:{},replaceRecipes:{},screenshots:{},actions:{},instructions:"",ai:{}},m,"assistant"),l(b.entities,m.entities,"assistant.entities"),l(b.deletable,m.deletable,"assistant.deletable"),l(b.writable,m.writable,"assistant.writable"),l(b.actions,m.actions,"assistant.actions"),l(b.screenshots,m.screenshots,"assistant.screenshots");let v=Object.fromEntries(Object.entries(m.entities).map(([e,t])=>{let i=`assistant.entities.${e}`;l(b.entities[e],t,i);let n=y.entities[e];return[e,Object.entries(t).map(([e,t])=>{l({description:""},t,`${i}.${e}`);let o=n.find(t=>t.source===e),a=c(t.description,o.valueDescription,`${i}.${e}`);return{...o,valueDescription:a,description:s(a,o.enumValues),describedByManifest:void 0!==t.description||o.describedByManifest}})]})),$=(e,t,i)=>r(`assistant.entities.${e}`,`conflicting sources ${t} and ${i}`),h=n([],p(v,"AnyDomainEntity")??[],()=>void 0,$),w=new Map([["AnyDomainEntity",h]]);for(let e of Object.keys(f.aliases))"AnyDomainEntity"!==e&&w.set(e,n([h],p(v,e)??[],()=>void 0,$));for(let e of f.entityTypes){let t=Object.entries(f.aliases).filter(([t,i])=>"AnyDomainEntity"!==t&&i.includes(e));w.set(e,n([h,...t.map(([e])=>w.get(e)??[])],p(v,e)??[],t=>y.enumValues[e]?.[t],$))}let g=Object.fromEntries([...w].map(([e,t])=>[e,t.map(t=>o(t,p(v,e)??[]))])),O=new Map,j=new Map;for(let[e,t]of Object.entries(m.writable)){let i=`assistant.writable.${e}`;for(let[s,n]of(l(b.writable[e],t,i),Object.entries(t))){let t=`${i}.${s}`,o=y.writable[e][s];for(let[e,{field:i,options:a,exposedDescription:c}]of(l(Object.values(o.members).some(e=>e.options)?{options:{}}:{},n,t),void 0!==n.options&&(l({validate:!0,allowDryRuns:!1},n.options,`${t}.options`),void 0!==n.options.validate&&!0!==n.options.validate&&r(`${t}.options.validate`,"can only enable validation; omit this flag or set true"),d(n.options.allowDryRuns,!0,`${t}.options`)),Object.entries(o.members))){let l=p(v,e)?.find(e=>e.source===s)?.name??w.get(e)?.find(e=>e.source===s)?.name,f=l??s;void 0===l&&w.get(e)?.some(e=>e.name===s&&e.source!==s)&&r(t,`narrowing leaves ${e}.${s} bound to another read field; retain its original exposure or remove this writable property`);let u=O.get(e)??new Map;if([...u.values()].some(e=>e.name===f&&e.property!==s)&&r(t,`narrowing maps multiple writable properties to ${e}.${f}; retain their original exposures or remove the conflicting property`),u.has(s)||u.set(s,{...i,name:f,...void 0===l?{}:{description:c}}),O.set(e,u),a){let i=o.defaultOptionsName?`${f}Options`:a.options.edgeName;j.get(e)?.some(e=>e.options.edgeName===i||e.options.field===f)&&r(`${t}.options`,`narrowing duplicates options edge ${e}.${i}; retain the original field exposures or remove the conflicting writable declaration`),j.set(e,[...j.get(e)??[],{hints:a.hints,options:{...a.options,field:f,edgeName:i,validate:n.options?.validate??a.options.validate,dryRuns:d(n.options?.allowDryRuns,a.options.dryRuns,`${t}.options`)}}])}}}}for(let[e,t]of Object.entries(f.optionsEdges))for(let i of t){let t=f.writableTypes.find(t=>t.entityType===e)?.fields.find(e=>e.name===i.options.field)?.property;if(i.options.validate&&t&&O.get(e)?.has(t)&&!j.get(e)?.some(i=>i.options.field===O.get(e)?.get(t)?.name&&i.options.validate)){let i=Object.keys(m.writable).find(i=>Object.hasOwn(m.writable[i],t)&&y.writable[i]?.[t]?.members[e]);r(`assistant.writable.${i}.${t}`,`cannot remove declared validation while another declaration keeps ${e}.${t} writable; remove all writable declarations for it`)}}let T=e=>{l(b[e],m[e],`assistant.${e}`);let t=new Map;for(let[i,s]of Object.entries(m[e])){let n=`assistant.${e}.${i}`;l(b[e][i],s,n);let o=y[e][i],a=Object.entries(s).map(([e,t])=>{let i=`${n}.${e}`;l({description:"",allowDryRuns:!1},t,i);let s=o.find(t=>t.instanceName===e);return{...s,description:c(t.description,s.description,i),dryRuns:d(t.allowDryRuns,s.dryRuns,i)}});for(let e of f.entityTypes.includes(i)?[i]:f.aliases[i]??[])t.set(e,[...t.get(e)??[],...a])}return Object.fromEntries(f.entityTypes.flatMap(e=>{let i=t.get(e);return i?.length?[[e,i]]:[]}))},x=new Map;for(let[e,t]of Object.entries(m.screenshots)){let i=`assistant.screenshots.${e}`;l(b.screenshots[e],t,i);let s=f.entityTypes.includes(e)?[e]:f.aliases[e]??[];for(let[n,o]of Object.entries(t)){let t=`${i}.${n}`;l({description:""},o,t);let a=y.screenshots[e].find(e=>e.instanceName===n),r={...a,description:c(o.description,a.description,t)??a.description};for(let e of s)x.set(e,[...x.get(e)??[],r])}}for(let[e,t]of Object.entries(m.deletable))l({},t,`assistant.deletable.${e}`);let E=new Set(Object.keys(m.deletable).flatMap(e=>f.entityTypes.includes(e)?[e]:f.aliases[e]??[])),R=f.actionFields.flatMap(e=>{let t=p(m.actions,e.actionName);if(void 0===t)return[];let i=`assistant.actions.${e.actionName}`;return l({description:""},t,i),[{...e,description:c(t.description,e.description,i)}]}),M=u;if(u){void 0!==m.ai&&l({...u.ai,maxThreadSize:void 0},m.ai,"assistant.ai");let s={...u.ai,...Object.fromEntries(Object.entries(m.ai??{}).filter(([,e])=>void 0!==e))};e.includes(s.provider)&&t.includes(s.model)&&i.includes(s.reasoning)||r("assistant.ai","expected a supported provider, model and reasoning level"),void 0!==s.maxThreadSize&&(!Number.isInteger(s.maxThreadSize)||s.maxThreadSize<=0)&&r("assistant.ai.maxThreadSize","expected a positive whole number of input tokens"),void 0!==m.instructions&&"string"!=typeof m.instructions&&r("assistant.instructions","expected a string"),M={instructions:""===m.instructions?null:m.instructions??u.instructions,ai:s}}return{resolved:{...f,fields:g,deletableTypes:f.entityTypes.filter(e=>E.has(e)),writableTypes:f.entityTypes.flatMap(e=>{let t=[...O.get(e)?.values()??[]];return t.length?[{entityType:e,fields:t}]:[]}),optionsEdges:Object.fromEntries(j),childRecipes:T("childRecipes"),replaceRecipes:T("replaceRecipes"),screenshots:Object.fromEntries(f.entityTypes.flatMap(e=>{let t=x.get(e);return t?[[e,t]]:[]})),actionFields:R},settings:M}};
@@ -38,10 +38,8 @@ export interface AssistantSetupRecipeGroup {
38
38
  readonly description?: string;
39
39
  readonly allowDryRuns?: false;
40
40
  }
41
- /** Only explicitly declared groups appear, under their original entity or alias key. */
42
- export interface AssistantSetupRecipes {
43
- readonly groups: Readonly<Record<string, AssistantSetupRecipeGroup>>;
44
- }
41
+ /** Only explicitly declared groups appear, under their original entity or alias key, keyed by instance name. */
42
+ export type AssistantSetupRecipes = Readonly<Record<string, AssistantSetupRecipeGroup>>;
45
43
  /** Server settings baseline, kept out of the browser spec. */
46
44
  export interface AssistantSetupSettings {
47
45
  readonly instructions?: string | null;
@@ -1 +1 @@
1
- export const projectAssistantSetupManifest=(e,t)=>{let i=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{groups:Object.fromEntries(t.groups.map(e=>[e.instanceName,{...void 0===e.description?{}:{description:e.description},...!e.dryRuns?{allowDryRuns:!1}:{}}]))}])),s=e.declarations;return{entities:Object.fromEntries(Object.entries(s.entities).map(([e,t])=>[e,Object.fromEntries(t.map(e=>[e.source,{...!e.describedByManifest||void 0===e.valueDescription?{}:{description:e.valueDescription}}]))])),deletable:Object.fromEntries(s.deletable.map(e=>[e,{}])),writable:Object.fromEntries(Object.entries(s.writable).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([e,t])=>{let i=Object.values(t.members).find(e=>e.options)?.options?.options;return[e,i?{options:{...i.validate?{validate:!0}:{},...!i.dryRuns?{allowDryRuns:!1}:{}}}:{}]}))])),childRecipes:i(s.childRecipes),replaceRecipes:i(s.replaceRecipes),screenshots:Object.fromEntries(Object.entries(s.screenshots).map(([e,t])=>[e,Object.fromEntries(t.map(({instanceName:e,description:t})=>[e,{description:t}]))])),actions:Object.fromEntries(e.actionFields.map(e=>[e.actionName,void 0===e.description?{}:{description:e.description}])),...t?{instructions:t.instructions??void 0,ai:{...t.ai}}:{}}};
1
+ export const projectAssistantSetupManifest=(e,t)=>{let i=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Object.fromEntries(t.map(e=>[e.instanceName,{...void 0===e.description?{}:{description:e.description},...!e.dryRuns?{allowDryRuns:!1}:{}}]))])),s=e.declarations;return{entities:Object.fromEntries(Object.entries(s.entities).map(([e,t])=>[e,Object.fromEntries(t.map(e=>[e.source,{...!e.describedByManifest||void 0===e.valueDescription?{}:{description:e.valueDescription}}]))])),deletable:Object.fromEntries(s.deletable.map(e=>[e,{}])),writable:Object.fromEntries(Object.entries(s.writable).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([e,t])=>{let i=Object.values(t.members).find(e=>e.options)?.options?.options;return[e,i?{options:{...i.validate?{validate:!0}:{},...!i.dryRuns?{allowDryRuns:!1}:{}}}:{}]}))])),childRecipes:i(s.childRecipes),replaceRecipes:i(s.replaceRecipes),screenshots:Object.fromEntries(Object.entries(s.screenshots).map(([e,t])=>[e,Object.fromEntries(t.map(({instanceName:e,description:t})=>[e,{description:t}]))])),actions:Object.fromEntries(e.actionFields.map(e=>[e.actionName,void 0===e.description?{}:{description:e.description}])),...t?{instructions:t.instructions??void 0,ai:{...t.ai}}:{}}};
@@ -1 +1 @@
1
- import{z as e}from"zod";import{DomainEntityIdSchema as t,systemUpdateFactory as i}from"../core/index.js";import{findAssistantFieldOptions as n,readAssistantFieldOptions as r}from"./assistant-field-options.js";import{assistantAddedEntityIds as o,findAssistantRecipeGroups as a,prepareAssistantRecipeUpdates as s,readAssistantRecipeGroup as d}from"./assistant-recipe-groups.js";export const deleteEntityUpdateTag="deleteEntity";export const modifyEntityUpdateTag="modifyEntity";let l=({action:e,resolveLocalizable:t})=>({componentReader:e.systems.componentReader,recipeCooker:e.systems.recipeCooker,resolveLocalizable:t}),p=e.string().regex(new RegExp(t.pattern),'An entity id is the type name, a dash and a number, e.g. "Root-1". Query the current entities and use an id they return.'),h=e.object({id:p}),y=e.object({id:p,delta:e.record(e.unknown())}),c="modify",f=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],u=e=>Array.isArray(e)?e.map(u):"object"!=typeof e||null===e||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,u(t)])),m=e.object({parentId:p,recipeGroupId:e.string(),recipeKey:e.string()}),g=e.object({entityId:p,recipeGroupId:e.string(),recipeKey:e.string()}),$=e=>e.map(e=>`"${e}"`).join(", "),w=[{name:"deleteEntity",implementation:(e,t,{manifest:n})=>{let{id:r}=h.parse(e),o=t.entities.find(e=>e.id===r);if(!o)throw Error(`Entity "${r}" does not exist, so it cannot be deleted. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);let a=n.deletableTypes??[];if(!a.includes(o.type))throw Error(`Entity "${r}" is a ${o.type}, which is not deletable. ${a.length>0?`Only entities of these types can be deleted: ${a.join(", ")}.`:"No entity type is deletable."} Delete an entity of a deletable type instead.`);return{updates:[i.EntityDeletion({entityId:o.id,updateTag:"deleteEntity"})],readResult:({previousState:e,state:t})=>{var i;let n;return[o.id,...(i=o.id,n=new Set(t.entities.map(e=>e.id)),e.entities.map(e=>e.id).filter(e=>e!==i&&!n.has(e)))]}}}},{name:"addChild",implementation:(e,t,i)=>{let{parentId:n,recipeGroupId:r,recipeKey:p}=m.parse(e),h=t.entities.find(e=>e.id===n);if(!h)throw Error(`Entity "${n}" does not exist, so nothing can be added to it. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);let y=a(i.manifest,"child",h.type),c=y.find(e=>e.groupId===r);if(!c)throw Error(`Entity "${n}" is a ${h.type}, which has no recipe group "${r}". ${y.length>0?`Its recipe groups are: ${$(y.map(({groupId:e})=>e))}.`:`Nothing can be added to a ${h.type}.`} Query "meta { childRecipes { groupId } }" on the entity you want to add to and use a groupId it returns.`);let f=l(i),u=d("child",c,h.id,t,f);if(!u)throw Error(`The recipe group "${r}" is not available on "${n}" right now, so nothing can be added from it. The configurator offers a group only in some states of the configuration. Query "meta { childRecipes { groupId } }" on "${n}" to see the groups it offers now.`);let g=u.recipes.find(e=>e.key===p);if(!g)throw Error(`The recipe group "${r}" on "${n}" has no recipe with the key "${p}". Recipes and their keys change with the configuration and with the language. List the recipes of the group again and use a key it returns.`);let w=s(g,u,h.id,t,f);return{updates:w,readResult:e=>o(w,h.id,e).map(t=>i.action.systems.domain.get$Entity(t,e.state))}}},{name:"replaceEntity",implementation:(e,t,i)=>{let{entityId:n,recipeGroupId:r,recipeKey:p}=g.parse(e),h=t.entities.find(e=>e.id===n);if(!h)throw Error(`Entity "${n}" does not exist, so it cannot be replaced. It may have been deleted or replaced by an earlier operation or field; a replaced entity gets a new id. Query the current entities and use an id they return.`);let y=a(i.manifest,"replace",h.type),c=y.find(e=>e.groupId===r);if(!c)throw Error(`Entity "${n}" is a ${h.type}, which has no replace recipe group "${r}". ${y.length>0?`Its replace recipe groups are: ${$(y.map(({groupId:e})=>e))}.`:`A ${h.type} cannot be replaced.`} Query "meta { replaceRecipes { groupId } }" on the entity you want to replace and use a groupId it returns.`);let f=l(i),u=d("replace",c,h.id,t,f);if(!u)throw Error(`The recipe group "${r}" is not available on "${n}" right now, so it cannot be replaced from it. The configurator offers a group only in some states of the configuration. Query "meta { replaceRecipes { groupId } }" on "${n}" to see the groups it offers now.`);let m=u.recipes.find(e=>e.key===p);if(!m)throw Error(`The recipe group "${r}" on "${n}" has no recipe with the key "${p}". Recipes and their keys change with the configuration and with the language. List the recipes of the group again and use a key it returns.`);let w=s(m,u,h.id,t,f);return{updates:w,readResult:e=>o(w,h.id,e).map(t=>i.action.systems.domain.get$Entity(t,e.state))}}}];export const findAssistantMutation=(e,t)=>{let o,a,s=w.find(t=>t.name===e),d=f(t.actions??{},e);if(s)return s;if(void 0!==d)return{name:e,implementation:(e,t,{action:i})=>i.systems.actionSystem.prepareAction(d,u(e),t)};if(!e.startsWith(c))return;let p=e.slice(c.length),h=f(t.writableFields??{},p);return h&&(o=`${c}${p}`,a=Object.keys(h).join(", "),{name:o,implementation:(e,t,s)=>{let{manifest:d}=s,{domain:m}=s.action.systems,{id:g,delta:$}=y.parse(e),w=t.entities.find(e=>e.id===g);if(!w)throw Error(`Entity "${g}" does not exist, so it cannot be modified. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);if(w.type!==p)throw Error(`Entity "${g}" is a ${w.type}, but ${o} modifies only ${p} entities. ${f(d.writableFields??{},w.type)?`Use ${c}${w.type} for it instead.`:`${w.type} has no writable fields, so it cannot be modified; pass the id of a ${p}.`}`);let b=Object.entries($).flatMap(([e,t])=>{let i=f(h,e);return void 0===i?[]:[{field:e,property:i,value:u(t)}]}),E=Object.fromEntries(b.map(({property:e,value:t})=>[e,t]));if(0===Object.keys(E).length)throw Error(`The delta of ${o} is empty, so there is nothing to change on "${g}". Set at least one of its fields: ${a}.`);let v=m.validateEntity({...w,...E});if(!v.success){let e=b.filter(({field:e,property:t})=>e!==t).map(({field:e,property:t})=>`${e} refers to ${t}`);throw Error(`The delta would make "${g}" an invalid ${p}: ${v.errors.join("; ")}. ${e.length>0?`The messages use these field names: ${e.join(", ")}. `:""}Nothing was changed. Send values that fit the types and the allowed values the schema describes for these fields.`)}let j=n(d,p);for(let{field:e,value:i}of b){let n=j.find(t=>t.field===e);if(!n?.validate||null===i)continue;let o=r(n,w.id,t,l(s));if(o&&!o.some(e=>e.value===i))throw Error(`${JSON.stringify(i)} is not a value "${e}" of "${g}" can take right now. ${o.length>0?`The configurator offers these values: ${o.map(e=>JSON.stringify(e.value)).join(", ")}.`:"The configurator offers no value for it in this state."} Nothing was changed. Send one of the offered values; "meta { ${n.edgeName} }" on the entity lists them with their names. When the values depend on another field of this delta, change that field in an earlier mutation field of the same operation.`)}return{updates:[i.DomainEntityModification({entityId:w.id,stateDelta:E,updateTag:"modifyEntity"})],readResult:({state:e})=>m.getEntity(w.id,e)?m.get$Entity(w.id,e):null}}})};
1
+ import{z as e}from"zod";import{DomainEntityIdSchema as t,systemUpdateFactory as i}from"../core/index.js";import{findAssistantFieldOptions as n,readAssistantFieldOptions as r}from"./assistant-field-options.js";import{assistantAddedEntityIds as o,findAssistantRecipeGroups as a,prepareAssistantRecipeUpdates as s,readAssistantRecipeGroup as d}from"./assistant-recipe-groups.js";export const deleteEntityUpdateTag="deleteEntity";export const modifyEntityUpdateTag="modifyEntity";let l=({action:e,resolveLocalizable:t})=>({componentReader:e.systems.componentReader,recipeCooker:e.systems.recipeCooker,resolveLocalizable:t}),p=e.string().regex(new RegExp(t.pattern),'An entity id is the type name, a dash and a number, e.g. "Root-1". Query the current entities and use an id they return.'),h=e.object({id:p}),u=e.object({id:p,delta:e.record(e.unknown())}),f="modify",y=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],c=e=>Array.isArray(e)?e.map(c):"object"!=typeof e||null===e||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,c(t)])),m=e.object({parentId:p,recipeGroupId:e.string(),recipeKey:e.string()}),g=e.object({entityId:p,recipeGroupId:e.string(),recipeKey:e.string()}),$=e=>e.map(e=>`"${e}"`).join(", "),w=[{name:"deleteEntity",implementation:(e,t,{manifest:n})=>{let{id:r}=h.parse(e),o=t.entities.find(e=>e.id===r);if(!o)throw Error(`Entity "${r}" does not exist, so it cannot be deleted. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);let a=n.deletableTypes??[];if(!a.includes(o.type))throw Error(`Entity "${r}" is a ${o.type}, which is not deletable. ${a.length>0?`Only entities of these types can be deleted: ${a.join(", ")}.`:"No entity type is deletable."} Delete an entity of a deletable type instead.`);return{updates:[i.EntityDeletion({entityId:o.id,updateTag:"deleteEntity"})],readResult:({previousState:e,state:t})=>{var i;let n;return[o.id,...(i=o.id,n=new Set(t.entities.map(e=>e.id)),e.entities.map(e=>e.id).filter(e=>e!==i&&!n.has(e)))]}}}},{name:"addChild",implementation:(e,t,i)=>{let{parentId:n,recipeGroupId:r,recipeKey:p}=m.parse(e),h=t.entities.find(e=>e.id===n);if(!h)throw Error(`Entity "${n}" does not exist, so nothing can be added to it. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);let u=a(i.manifest,"child",h.type),f=u.find(e=>e.groupId===r);if(!f)throw Error(`Entity "${n}" is a ${h.type}, which has no recipe group "${r}". ${u.length>0?`Its recipe groups are: ${$(u.map(({groupId:e})=>e))}.`:`Nothing can be added to a ${h.type}.`} Query the groups under "meta { childRecipes }" on the entity you want to add to and use a groupId they return.`);let y=l(i),c=d("child",f,h.id,t,y);if(!c)throw Error(`The recipe group "${r}" is not available on "${n}" right now, so nothing can be added from it. The configurator offers a group only in some states of the configuration. Query the groups under "meta { childRecipes }" on "${n}" to see the ones it offers now; a group it does not offer is null.`);let g=c.recipes.find(e=>e.key===p);if(!g)throw Error(`The recipe group "${r}" on "${n}" has no recipe with the key "${p}". Recipes and their keys change with the configuration and with the language. List the recipes of the group again and use a key it returns.`);let w=s(g,c,h.id,t,y);return{updates:w,readResult:e=>o(w,h.id,e).map(t=>i.action.systems.domain.get$Entity(t,e.state))}}},{name:"replaceEntity",implementation:(e,t,i)=>{let{entityId:n,recipeGroupId:r,recipeKey:p}=g.parse(e),h=t.entities.find(e=>e.id===n);if(!h)throw Error(`Entity "${n}" does not exist, so it cannot be replaced. It may have been deleted or replaced by an earlier operation or field; a replaced entity gets a new id. Query the current entities and use an id they return.`);let u=a(i.manifest,"replace",h.type),f=u.find(e=>e.groupId===r);if(!f)throw Error(`Entity "${n}" is a ${h.type}, which has no replace recipe group "${r}". ${u.length>0?`Its replace recipe groups are: ${$(u.map(({groupId:e})=>e))}.`:`A ${h.type} cannot be replaced.`} Query the groups under "meta { replaceRecipes }" on the entity you want to replace and use a groupId they return.`);let y=l(i),c=d("replace",f,h.id,t,y);if(!c)throw Error(`The recipe group "${r}" is not available on "${n}" right now, so it cannot be replaced from it. The configurator offers a group only in some states of the configuration. Query the groups under "meta { replaceRecipes }" on "${n}" to see the ones it offers now; a group it does not offer is null.`);let m=c.recipes.find(e=>e.key===p);if(!m)throw Error(`The recipe group "${r}" on "${n}" has no recipe with the key "${p}". Recipes and their keys change with the configuration and with the language. List the recipes of the group again and use a key it returns.`);let w=s(m,c,h.id,t,y);return{updates:w,readResult:e=>o(w,h.id,e).map(t=>i.action.systems.domain.get$Entity(t,e.state))}}}];export const findAssistantMutation=(e,t)=>{let o,a,s=w.find(t=>t.name===e),d=y(t.actions??{},e);if(s)return s;if(void 0!==d)return{name:e,implementation:(e,t,{action:i})=>i.systems.actionSystem.prepareAction(d,c(e),t)};if(!e.startsWith(f))return;let p=e.slice(f.length),h=y(t.writableFields??{},p);return h&&(o=`${f}${p}`,a=Object.keys(h).join(", "),{name:o,implementation:(e,t,s)=>{let{manifest:d}=s,{domain:m}=s.action.systems,{id:g,delta:$}=u.parse(e),w=t.entities.find(e=>e.id===g);if(!w)throw Error(`Entity "${g}" does not exist, so it cannot be modified. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);if(w.type!==p)throw Error(`Entity "${g}" is a ${w.type}, but ${o} modifies only ${p} entities. ${y(d.writableFields??{},w.type)?`Use ${f}${w.type} for it instead.`:`${w.type} has no writable fields, so it cannot be modified; pass the id of a ${p}.`}`);let b=Object.entries($).flatMap(([e,t])=>{let i=y(h,e);return void 0===i?[]:[{field:e,property:i,value:c(t)}]}),E=Object.fromEntries(b.map(({property:e,value:t})=>[e,t]));if(0===Object.keys(E).length)throw Error(`The delta of ${o} is empty, so there is nothing to change on "${g}". Set at least one of its fields: ${a}.`);let v=m.validateEntity({...w,...E});if(!v.success){let e=b.filter(({field:e,property:t})=>e!==t).map(({field:e,property:t})=>`${e} refers to ${t}`);throw Error(`The delta would make "${g}" an invalid ${p}: ${v.errors.join("; ")}. ${e.length>0?`The messages use these field names: ${e.join(", ")}. `:""}Nothing was changed. Send values that fit the types and the allowed values the schema describes for these fields.`)}let j=n(d,p);for(let{field:e,value:i}of b){let n=j.find(t=>t.field===e);if(!n?.validate||null===i)continue;let o=r(n,w.id,t,l(s));if(o&&!o.some(e=>e.value===i))throw Error(`${JSON.stringify(i)} is not a value "${e}" of "${g}" can take right now. ${o.length>0?`The configurator offers these values: ${o.map(e=>JSON.stringify(e.value)).join(", ")}.`:"The configurator offers no value for it in this state."} Nothing was changed. Send one of the offered values; "meta { ${n.edgeName} }" on the entity lists them with their names. When the values depend on another field of this delta, change that field in an earlier mutation field of the same operation.`)}return{updates:[i.DomainEntityModification({entityId:w.id,stateDelta:E,updateTag:"modifyEntity"})],readResult:({state:e})=>m.getEntity(w.id,e)?m.get$Entity(w.id,e):null}}})};
@@ -16,3 +16,4 @@ export { getAllPhxDefinitions } from './system-definitions.js';
16
16
  export { availableSystemComponents, componentsByName } from './available-system-components.js';
17
17
  export * from './mocks/index.js';
18
18
  export * from './domain-runtime/index.js';
19
+ export * from './spec/index.js';
@@ -1 +1 @@
1
- export*from"./core/index.js";export{DomainBuilder}from"./domain-builder.js";export{memoEval,isMemoizedArray,isMemoizedObject}from"./utils/memo-eval.js";export{cloneEvalCache,getEvalCache,setEvalCache,createEvalCacheToken}from"./utils/eval-cache.js";export{areProfilerLabelsEnabled,setProfilerLabelsEnabled}from"./utils/profiler-label.js";export*from"./dimensions/index.js";export*from"./domain-context/index.js";export*from"./system-components/index.js";export*from"./extensions/index.js";export*from"./sketching/index.js";export*from"./projections/index.js";export*from"./admin-domain/index.js";export*from"./application/index.js";export*from"./scene/index.js";export{getAllPhxDefinitions}from"./system-definitions.js";export{availableSystemComponents,componentsByName}from"./available-system-components.js";export*from"./mocks/index.js";export*from"./domain-runtime/index.js";
1
+ export*from"./core/index.js";export{DomainBuilder}from"./domain-builder.js";export{memoEval,isMemoizedArray,isMemoizedObject}from"./utils/memo-eval.js";export{cloneEvalCache,getEvalCache,setEvalCache,createEvalCacheToken}from"./utils/eval-cache.js";export{areProfilerLabelsEnabled,setProfilerLabelsEnabled}from"./utils/profiler-label.js";export*from"./dimensions/index.js";export*from"./domain-context/index.js";export*from"./system-components/index.js";export*from"./extensions/index.js";export*from"./sketching/index.js";export*from"./projections/index.js";export*from"./admin-domain/index.js";export*from"./application/index.js";export*from"./scene/index.js";export{getAllPhxDefinitions}from"./system-definitions.js";export{availableSystemComponents,componentsByName}from"./available-system-components.js";export*from"./mocks/index.js";export*from"./domain-runtime/index.js";export*from"./spec/index.js";
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The `$adminPages` section of an admin spec file as it is written, which the parsed admin pages
3
+ * keep as their `spec`. `application-spec` exports it as `RawAdminPages`, and the application
4
+ * config takes it as `AdminPagesSpec`.
5
+ */
6
+ export interface AdminPagesSection {
7
+ readonly presets?: boolean | {
8
+ readonly categoryNavigationState?: string;
9
+ readonly presetNavigationState?: string;
10
+ };
11
+ readonly recipes?: ReadonlyArray<{
12
+ readonly name: string;
13
+ readonly navigationState?: string;
14
+ }>;
15
+ readonly pages?: ReadonlyArray<{
16
+ readonly key: string;
17
+ readonly title: string;
18
+ readonly icon?: string;
19
+ readonly navigationState?: string;
20
+ readonly entity?: string;
21
+ readonly component?: string;
22
+ readonly actionsComponent?: string;
23
+ readonly connectedDataEntry?: string;
24
+ readonly sidebar?: {
25
+ readonly title: string;
26
+ readonly component: string;
27
+ };
28
+ }>;
29
+ }
@@ -0,0 +1,26 @@
1
+ import type { Branded } from '@salsita-ai/common/utils';
2
+ import type { ComponentEntry } from '../components/index.js';
3
+ import type { AdminPagesSection } from './admin-pages-section.js';
4
+ /**
5
+ * The parsed admin pages of an admin spec: the `$adminPages` section as written, the components
6
+ * the pages attach, the items of the admin navigation and the navigation states the pages add.
7
+ */
8
+ export type AdminPages = Branded<'AdminPages', {
9
+ readonly spec: AdminPagesSection;
10
+ readonly components: readonly ComponentEntry[];
11
+ readonly navigationItems: readonly AdminNavigationItem[];
12
+ readonly navigationStates: readonly string[];
13
+ }>;
14
+ interface AdminNavigationListItem {
15
+ readonly label: string;
16
+ readonly icon?: string;
17
+ readonly navigationStates: readonly string[];
18
+ }
19
+ interface AdminNestedNavigationListItem {
20
+ readonly label: string;
21
+ readonly icon?: string;
22
+ readonly items: ReadonlyArray<Omit<AdminNavigationListItem, 'icon'>>;
23
+ }
24
+ /** One item of the admin navigation: a list item, or a nested list of them. */
25
+ export type AdminNavigationItem = AdminNavigationListItem | AdminNestedNavigationListItem;
26
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { Branded } from '@salsita-ai/common/utils';
2
+ import type { StateValue } from '../sections/index.js';
3
+ export type AdminStates = Branded<'AdminStates', {
4
+ readonly navigationStates: readonly StateValue[];
5
+ }>;
@@ -0,0 +1,8 @@
1
+ import type { Branded } from '@salsita-ai/common/utils';
2
+ import type { StateValue } from '../sections/index.js';
3
+ export type ConfiguratorStates = Branded<'ConfiguratorStates', {
4
+ readonly navigationStates: readonly StateValue[];
5
+ readonly viewStates: readonly StateValue[];
6
+ readonly toolStates: readonly StateValue[];
7
+ readonly exportStates: readonly StateValue[];
8
+ }>;
@@ -0,0 +1,5 @@
1
+ export type * from './admin-pages.js';
2
+ export type * from './admin-pages-section.js';
3
+ export type * from './admin-states.js';
4
+ export * from './application-instance.js';
5
+ export type * from './configurator-states.js';
@@ -0,0 +1 @@
1
+ export*from"./application-instance.js";
@@ -0,0 +1,2 @@
1
+ export type * from './read-binding.js';
2
+ export type * from './write-binding.js';
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1,13 @@
1
+ import type { Branded } from '@salsita-ai/common/utils';
2
+ /**
3
+ * A validated `$read` dependency found anywhere in the component props tree.
4
+ * Used for memoEval dependency tracking — the target becomes `self.target` in generated code.
5
+ * Field targets are validated against the entity shape; expression targets ($-prefixed)
6
+ * are accepted without validation (they may be inferred during Phase C).
7
+ */
8
+ export type ComponentReadBinding = Branded<'ComponentReadBinding', {
9
+ /** The raw target string from `$read` (e.g. "height" or "$price"). */
10
+ readonly target: string;
11
+ /** Whether the target is an expression (starts with `$`) or a shape field. */
12
+ readonly isExpression: boolean;
13
+ }>;
@@ -0,0 +1,32 @@
1
+ import type { Branded } from '@salsita-ai/common/utils';
2
+ /**
3
+ * Runtime type assertion to emit in the write callback.
4
+ * Resolved from the target entity field's schema during parsing.
5
+ */
6
+ export type AssertionKind = {
7
+ readonly kind: 'declaredType';
8
+ readonly typeName: string;
9
+ } | {
10
+ readonly kind: 'declaredTypeId';
11
+ readonly referencedType: string;
12
+ } | {
13
+ readonly kind: 'primitive';
14
+ readonly assertFn: 'assertString' | 'assertNumber' | 'assertBoolean';
15
+ } | {
16
+ readonly kind: 'literal';
17
+ readonly value: null;
18
+ } | {
19
+ readonly kind: 'anyOf';
20
+ readonly assertions: readonly AssertionKind[];
21
+ } | {
22
+ readonly kind: 'none';
23
+ };
24
+ /**
25
+ * A validated `$write` or `$bind` mapping from a component state key to an entity field.
26
+ * Includes the resolved assertion kind for runtime type checking in the write callback.
27
+ */
28
+ export type ComponentWriteBinding = Branded<'ComponentWriteBinding', {
29
+ readonly propKey: string;
30
+ readonly entityField: string;
31
+ readonly assertion: AssertionKind;
32
+ }>;
@@ -1,9 +1,9 @@
1
1
  import type { Branded } from '@salsita-ai/common/utils';
2
- import type { SdkCodeRef } from '../../../core/index.js';
3
- import type { MemoEvalPlan, MemoEvalPlanInput } from '../expressions/memo-eval-plan.js';
2
+ import type { MemoEvalPlan, MemoEvalPlanInput } from '../expressions/index.js';
4
3
  import type { EntityOrAliasName, InstanceName } from '../model/index.js';
5
4
  import type { ComponentReadBinding, ComponentWriteBinding } from './bindings/index.js';
6
- import type { ComponentFilters } from './component-filter.js';
5
+ import type { ComponentFilters } from './component-filters.js';
6
+ import type { SdkCodeRef } from './sdk-code-ref.js';
7
7
  /**
8
8
  * Root-level `$read` variant — the entire instance state is driven by a single
9
9
  * `$read` at the root (components.md §"Root-Level $read"). No `resolvedProps`
@@ -0,0 +1 @@
1
+ export{};
@@ -17,7 +17,8 @@ export type FilterCriterion<T> = {
17
17
  readonly code: string;
18
18
  };
19
19
  /**
20
- * Parsed component filter controlling when the component is active. Two
20
+ * Parsed component filter controlling when the component is active, as the application spec
21
+ * declares it under `$filter`; `application-spec` exports it as `ComponentFilter`. Two
21
22
  * mutually-exclusive shapes:
22
23
  *
23
24
  * - `'gradual'` — zero or more per-criterion fields; compiles to one entry per
@@ -29,7 +30,7 @@ export type FilterCriterion<T> = {
29
30
  *
30
31
  * See `components.md §"Simple expression filter"` / `§"Declarative filter"`.
31
32
  */
32
- export type ComponentFilter = {
33
+ export type SpecComponentFilter = {
33
34
  readonly kind: 'gradual';
34
35
  readonly navigationStates?: FilterCriterion<readonly string[]>;
35
36
  readonly viewStates?: FilterCriterion<readonly string[]>;
@@ -0,0 +1,10 @@
1
+ import type { Branded } from '@salsita-ai/common/utils';
2
+ import type { SpecComponentFilter } from './component-filter.js';
3
+ /**
4
+ * Validated set of `$filter` entries on a user-bound component instance. Each
5
+ * {@link SpecComponentFilter} represents one alternative filter condition; multiple
6
+ * entries arise from `$or`. Empty `items` means no filter is applied.
7
+ */
8
+ export type ComponentFilters = Branded<'ComponentFilters', {
9
+ readonly items: readonly SpecComponentFilter[];
10
+ }>;
@@ -0,0 +1 @@
1
+ export{};