@salsita-ai/sdk 0.50.0-develop.334b422a4f → 0.50.0-develop.3986957af6

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 (112) hide show
  1. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +11 -5
  2. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +1 -1
  3. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-runtime.d.ts +3 -2
  4. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-runtime.js +1 -1
  5. package/dist/application-spec/generate-application/runtime/application-runtime.d.ts +12 -4
  6. package/dist/application-spec/generate-application/runtime/application-runtime.js +1 -1
  7. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.d.ts +3 -3
  8. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.js +1 -1
  9. package/dist/application-spec/generate-application/runtime/sections/expression-runtime.d.ts +9 -3
  10. package/dist/application-spec/generate-application/runtime/sections/expression-runtime.js +1 -1
  11. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +4 -3
  12. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
  13. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +21 -5
  14. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -1
  15. package/dist/configurator/common/configurator-interface.d.ts +6 -1
  16. package/dist/configurator/common/configurator-interface.js +1 -1
  17. package/dist/configurator/configurator-context/ConfiguratorResponsiveProvider.d.ts +3 -3
  18. package/dist/configurator/configurator-context/ConfiguratorResponsiveProvider.js +1 -1
  19. package/dist/configurator/configurator-context/PreviewContextProvider.js +1 -1
  20. package/dist/configurator/ui/configurator-layout/universal/use-layout-scene-safe-area.js +1 -1
  21. package/dist/configurator/ui/save-message-snackbars/SaveMessageSnackbars.js +1 -1
  22. package/dist/docs/index.json +12 -1
  23. package/dist/docs/integrations/webcomponent-api/basics.mdx +2 -0
  24. package/dist/docs/layouts/custom-layout.mdx +318 -158
  25. package/dist/docs/layouts/gallery/ardent-compressor.mdx +1 -0
  26. package/dist/docs/layouts/gallery/fenwick-window.mdx +198 -127
  27. package/dist/docs/layouts/gallery/ferrule-bar-station.mdx +6567 -0
  28. package/dist/docs/layouts/gallery/sunfold-solar.mdx +16 -4
  29. package/dist/docs/phoenix/configurator-interface.mdx +4 -3
  30. package/dist/docs/phoenix/sessions-and-access.mdx +2 -0
  31. package/dist/domain/application/web-component-property.d.ts +3 -1
  32. package/dist/domain/application/web-component-property.js +1 -1
  33. package/dist/domain/domain-builder.d.ts +9 -3
  34. package/dist/domain/domain-builder.js +1 -1
  35. package/dist/domain/domain-runtime/domain-context/selectors.d.ts +1 -0
  36. package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
  37. package/dist/domain/domain-runtime/domain-runtime.d.ts +4 -0
  38. package/dist/domain/domain-runtime/errors/implementation-error-collector.d.ts +2 -0
  39. package/dist/domain/domain-runtime/errors/implementation-error-collector.js +1 -1
  40. package/dist/domain/domain-runtime/index.d.ts +1 -1
  41. package/dist/domain/domain-runtime/index.js +1 -1
  42. package/dist/domain/domain-runtime/spec/index.d.ts +1 -1
  43. package/dist/domain/domain-runtime/spec/index.js +1 -1
  44. package/dist/domain/domain-runtime/spec/module-checks/index.d.ts +1 -0
  45. package/dist/domain/domain-runtime/spec/module-checks/index.js +1 -1
  46. package/dist/domain/domain-runtime/spec/module-checks/merge-expression-modules.d.ts +23 -0
  47. package/dist/domain/domain-runtime/spec/module-checks/merge-expression-modules.js +1 -0
  48. package/dist/domain/domain-runtime/spec/module-checks/resolve-expression-modules.d.ts +3 -4
  49. package/dist/domain/domain-runtime/spec/module-checks/resolve-expression-modules.js +1 -1
  50. package/dist/domain/mocks/create-mock-domain-runtime.d.ts +2 -0
  51. package/dist/editor/domain-editors/DomainSpecContext.js +1 -1
  52. package/dist/editor/domain-editors/use-implementation-files.d.ts +6 -11
  53. package/dist/editor/domain-editors/use-implementation-files.js +1 -1
  54. package/dist/legacy/domain-cli/utils/cache.d.ts +1 -1
  55. package/dist/legacy/domain-cli/utils/cache.js +1 -1
  56. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/claude-md.d.ts +1 -1
  57. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/cursor-rules.d.ts +1 -1
  58. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.d.ts +1 -1
  59. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.js +11 -5
  60. package/dist/react-sdk/application-runtime/hooks/index.d.ts +1 -0
  61. package/dist/react-sdk/application-runtime/hooks/index.js +1 -1
  62. package/dist/react-sdk/application-runtime/hooks/responsive/index.d.ts +3 -0
  63. package/dist/react-sdk/application-runtime/hooks/responsive/index.js +1 -0
  64. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-actions.d.ts +9 -0
  65. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-actions.js +1 -0
  66. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-application.d.ts +26 -0
  67. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-application.js +1 -0
  68. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-state.d.ts +10 -0
  69. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-state.js +1 -0
  70. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-store.d.ts +24 -0
  71. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-store.js +1 -0
  72. package/dist/react-sdk/application-runtime/hooks/use-access-service.d.ts +5 -0
  73. package/dist/react-sdk/application-runtime/hooks/use-access-service.js +1 -1
  74. package/dist/react-sdk/application-runtime/index.d.ts +1 -0
  75. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.js +1 -1
  76. package/dist/react-sdk/application-runtime/responsive/actions.d.ts +47 -0
  77. package/dist/react-sdk/application-runtime/responsive/actions.js +1 -0
  78. package/dist/react-sdk/application-runtime/responsive/index.d.ts +4 -0
  79. package/dist/react-sdk/application-runtime/responsive/index.js +1 -0
  80. package/dist/react-sdk/application-runtime/responsive/initialize.d.ts +3 -0
  81. package/dist/react-sdk/application-runtime/responsive/initialize.js +1 -0
  82. package/dist/react-sdk/application-runtime/responsive/selectors.d.ts +20 -0
  83. package/dist/react-sdk/application-runtime/responsive/selectors.js +1 -0
  84. package/dist/react-sdk/application-runtime/responsive/types.d.ts +104 -0
  85. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +91 -0
  86. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.js +1 -1
  87. package/dist/react-sdk/domain-context/common-hooks/index.d.ts +1 -0
  88. package/dist/react-sdk/domain-context/common-hooks/index.js +1 -1
  89. package/dist/react-sdk/domain-context/common-hooks/use-configuration-save-state.d.ts +23 -0
  90. package/dist/react-sdk/domain-context/common-hooks/use-configuration-save-state.js +1 -0
  91. package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +1 -0
  92. package/dist/react-sdk/domain-context/index.d.ts +1 -0
  93. package/dist/react-sdk/domain-context/index.js +1 -1
  94. package/dist/react-sdk/index.d.ts +0 -1
  95. package/dist/react-sdk/index.js +1 -1
  96. package/dist/react-sdk/web-component/create-web-component.js +1 -1
  97. package/dist/ui-sdk/responsive-application/ResponsiveApplicationProvider.d.ts +2 -2
  98. package/dist/ui-sdk/responsive-application/responsive-state-store.d.ts +11 -9
  99. package/dist/ui-sdk/responsive-application/use-store-responsive-info.js +1 -1
  100. package/package.json +3 -3
  101. package/dist/react-sdk/responsive-state/ResponsiveStateProvider.d.ts +0 -25
  102. package/dist/react-sdk/responsive-state/ResponsiveStateProvider.js +0 -1
  103. package/dist/react-sdk/responsive-state/canvas-padding.d.ts +0 -14
  104. package/dist/react-sdk/responsive-state/index.d.ts +0 -5
  105. package/dist/react-sdk/responsive-state/index.js +0 -1
  106. package/dist/react-sdk/responsive-state/responsive-state-manager.d.ts +0 -111
  107. package/dist/react-sdk/responsive-state/responsive-state-manager.js +0 -1
  108. package/dist/react-sdk/responsive-state/use-responsive-state-manager.d.ts +0 -10
  109. package/dist/react-sdk/responsive-state/use-responsive-state-manager.js +0 -1
  110. package/dist/react-sdk/responsive-state/use-responsive-state.d.ts +0 -11
  111. package/dist/react-sdk/responsive-state/use-responsive-state.js +0 -1
  112. /package/dist/react-sdk/{responsive-state/canvas-padding.js → application-runtime/responsive/types.js} +0 -0
@@ -40,12 +40,18 @@ Without a lockfile, use the package manager the \`packageManager\` field of \`pa
40
40
  - \`src/components/\` — ECS system components (\`phx.domain.attachComponent.withEntity()\`)
41
41
  - \`src/elements/\` — Page-level React components (\`phx.frontend.createCustomPhoenixLayoutElement()\`)
42
42
  - \`ConfiguratorLayout\`: a layout element with this name replaces everything the built-in layout renders for a loaded configuration, in owner and read mode, finalization included. Prefer arranging the spec's layout components; write one for shell-level changes, such as moving the sidebar or adding an area the built-in layout has no place for
43
- - Mount \`LayoutSlots.SharedCanvas\` (from \`@salsita-ai/sdk/configurator\`) in a positioned root covering the page, or the app loader stays on screen; put the UI above it, positioned and after it in the markup. Call \`useSceneSafeArea()\` (same import) and put \`containerRef\` on the element covering the whole canvas and \`safeAreaRef\` on the region the UI leaves free, with \`pointerEvents: 'none'\`, so the camera frames the scene there
43
+ - Mount \`LayoutSlots.SharedCanvas\` (from \`@salsita-ai/sdk/configurator\`) in a positioned root covering the page; put the UI above it, positioned and after it in the markup. With the canvas mounted the app loader waits until the scene has loaded; a layout without a canvas is not held by the loader. Call \`phx.frontend.useSceneSafeArea()\` and put \`containerRef\` on the element covering the whole canvas and \`safeAreaRef\` on the region the UI leaves free, with \`pointerEvents: 'none'\`, so the camera frames the scene there
44
44
  - Sidebar moved, contents as the spec configures them: mount \`LayoutSlots.DesktopSidebar\` in a positioned container that sets its size, with \`side="start"\` on the left; \`docs/layouts/sidebar/in-a-custom-layout.mdx\` is the whole layout
45
- - Your own UI: "Hooks for a Project Layout" in \`docs/phoenix/configurator-interface.mdx\` lists the hooks with what each returns (\`pnpm phoenix docs -r docs/phoenix/configurator-interface.mdx\`), \`docs/phoenix/layout-slots.mdx\` the built-in pieces you can still mount, and \`docs/layouts/custom-layout.mdx\` is a worked example
46
- - Messages: mount \`LayoutSlots.Services\` for the built-in snackbars, or show violations, side-effect hints and errors yourself with \`phx.frontend.useConfiguratorMessages(onMessage)\`, not both. Either way mount a snackbar root (\`LayoutSlots.DesktopSnackbarsRoot\` or \`LayoutSlots.MobileSnackbarsRoot\`): save and built-in action errors are always snackbars
47
- - Finalize over the spec's \`finalizeAction\` components, each naming a handler registered with \`phx.frontend.createPhoenixHandler\`: run each with \`phx.frontend.useFinalizeAction(handler)\` in a component of its own wrapped in \`PhoenixHandlerBoundary\` (from \`@salsita-ai/sdk/react\`), or mount \`FinalizeActions\` (from \`@salsita-ai/sdk/configurator\`) for the built-in buttons. \`finalizePage\` and \`finalizeButton\` are legacy
48
- - Read mode and fullscreen are the layout's job, no hook enforces them: hide what a viewer must not change while \`phx.frontend.useAccessService().accessInfo.viewMode\` is \`true\`, and remove panels while \`phx.frontend.useIsFullscreenActive()\` is set; \`phx.frontend.useSetFullscreen()\` returns its setter
45
+ - Your own UI: "Hooks for a Project Layout" in \`docs/phoenix/configurator-interface.mdx\` lists the hooks with what each returns (\`pnpm phoenix docs -r docs/phoenix/configurator-interface.mdx\`), \`docs/phoenix/layout-slots.mdx\` the built-in pieces you can still mount, and \`docs/layouts/custom-layout.mdx\` is a worked example. Call the hooks as \`phx.frontend.useX()\`; besides those below, these are often needed: \`usePreview()\` (\`isPreview\` while the preview start screen shows), \`useCloseAction()\` (the host's close action or \`null\`), \`useActiveViewports()\` (the container's breakpoints, \`null\` until measured, \`desktop\` above 768 px: the desktop/phone switch), \`useResolveLocalizable()\` and \`useLocalizable(text)\` (spec texts to strings), \`useIsCloningAllowed()\` (a read-mode "edit a copy" action with \`LayoutSlots.CloneToEditDialog\`)
46
+ - Undo and redo: \`phx.frontend.useUndoRedo()\` returns \`{ canUndo, canRedo, undo, redo }\`; disable each button from \`canUndo\`/\`canRedo\`
47
+ - Tabs: \`phx.frontend.useTabNavigation()\` returns \`{ source, tabs, activeTab, select }\` for the spec's \`sidebarTabs\` (of the selected entity) or \`horizontalTabs\`; render \`tabs\` (each \`{ index, label, icon, state, isActive }\`, \`icon\` a PhxIcon name) and call \`select(tab.index)\` on click. Pass \`{ source: 'sidebarTabs' }\` or \`{ source: 'horizontalTabs' }\` when the layout shows one kind only. Not \`LayoutSlots.useSidebarTabs()\`: it serves the built-in sidebar and returns no tabs while its summary shows
48
+ - Steps: \`phx.frontend.useStepNavigation()\` returns \`{ steps, activeStep, activeIndex, isFirst, isLast, canGoNext, canGoPrevious, next, previous, goTo }\` for the spec's \`navigationSteps\`; render \`steps\` (each \`{ index, label, state, status }\`, \`status\` \`'complete' | 'active' | 'upcoming'\`), call \`next()\`/\`previous()\` for Back and Next and \`goTo(step.index)\` from a stepper. It enforces no order and no validity: enable only \`'complete'\` steps for an "earlier steps only" stepper, and to block moving on while the configuration has a problem, require \`phx.frontend.useStateValidity().severity !== 'warning'\` besides \`canGoNext\`: a change with a \`fixable\` or \`fatal\` violation is rejected, so the configuration is never invalid, and a \`warning\` is the problem that stays (it blocks finalizing too). \`useSteps\` and \`useHasSteps\` from \`@salsita-ai/sdk/configurator\` are deprecated
49
+ - Messages: mount \`LayoutSlots.Services\` for the built-in snackbars, or show violations, side-effect hints, errors and failed saves yourself with \`phx.frontend.useConfiguratorMessages(onMessage)\`, not both. A failed save arrives as \`saveError\`, the next successful save as \`saveRecovery\`; a layout that mounts neither shows no sign of a failed save. Either way mount a snackbar root (\`LayoutSlots.DesktopSnackbarsRoot\` or \`LayoutSlots.MobileSnackbarsRoot\`): errors of the built-in actions are always snackbars
50
+ - Finalize over the spec's \`finalizeAction\` components, each naming a handler registered with \`phx.frontend.createPhoenixHandler\`: \`phx.frontend.useFinalizeActions()\` returns \`{ actions, primary, secondary, disabled, hints }\`; render \`primary\` (and \`secondary\` in a menu or list) in a loop, each action \`{ key, label, title, icon, run, isPending, error, disabled }\`, and call \`action.run()\` on click (its promise never rejects; show \`action.error\` on failure). The configurator runs the handlers itself, outside the layout, so a handler must not rely on a provider the layout adds. For one known handler, \`phx.frontend.useFinalizeAction(handler)\` in a component wrapped in \`PhoenixHandlerBoundary\` (from \`@salsita-ai/sdk/react\`) works too; \`FinalizeActions\` (from \`@salsita-ai/sdk/configurator\`) mounts the built-in buttons. \`finalizePage\` and \`finalizeButton\` are legacy
51
+ - Read mode and fullscreen are the layout's job, no hook enforces them (\`useUndoRedo\`, \`useFinalizeActions\` and \`useStepNavigation\` included): hide undo, redo, finalization and whatever else a viewer must not change while \`phx.frontend.useAccessService().accessInfo.viewMode\` is \`true\` (tabs are navigation, so a viewer may switch them), and remove panels while \`phx.frontend.useIsFullscreenActive()\` is set; \`phx.frontend.useSetFullscreen()\` returns its setter
52
+ - \`ConfigurationNotFoundPage\`: \`phx.frontend.createConfigurationNotFoundPage(({ onBack }) => …)\` replaces the "configuration not accessible" page; show a way back only when the optional \`onBack\` is set. The not-authenticated page's default renders it too; only the admin's not-authorized page keeps the built-in page
53
+ - \`ConfiguratorErrorPage\`: \`phx.frontend.createConfiguratorErrorPage(({ reason, onRetry }) => …)\` replaces the production error page; \`reason\` is \`uncaughtError\` or \`presetCreationFailed\`. A page that throws falls back to the built-in one, and development keeps the detailed error pages, so the project page shows only in a production build. Register both pages with these helpers: \`createCustomPhoenixLayoutElement\` with the name works too, but types the component as taking only \`children\`, so the typed props do not compile there in a strict project
54
+ - \`AppLoaderContent\`: \`phx.frontend.createAppLoader(({ phases }) => …)\` replaces what the loading overlay shows (each phase \`{ id, label?, progress? }\`, the list possibly empty); Phoenix keeps the overlay itself
49
55
  - Assistant form elements: an element declared under \`assistant.formElements\` (\`description\`, \`role\`, scalar \`attributes\` beside the built-in \`label\`, a \`value\` included, \`required\`) is the default export \`phx.frontend.createAssistantFormElement('name', Component)\` of one file; the name types the component's props by its role (\`AssistantFormElementProps<'name'>\`): an option reports its answer with \`onSelect(answer)\`, an input with \`onChange(state, answer)\`; and the application does not start while a declared element has no registration or a registration no declaration
50
56
  - \`src/handlers/\` — Event & lifecycle handlers
51
57
  - \`src/webhooks/\` — Server-side webhook handlers (\`phx.webhooks.*Builder\`); the webhook is the default export of \`src/webhooks/index.ts\`, which you create when the project needs its own handlers — without it the build uses a built-in inert webhook that answers only anonymous auth, so create the file before setting \`useAuthHook\` or \`useClerk\`
@@ -1,4 +1,4 @@
1
- export const sdkGuidanceSections={packageManager:"## Package Manager\nThe project installs with its own package manager, and the commands in this skill are written for pnpm. Run them through the package manager the project uses, which the lockfile in the project root names:\n- `pnpm-lock.yaml`: `pnpm phoenix <command>`, `pnpm install`, `pnpm add <package>`\n- `package-lock.json`: `npx phoenix <command>`, `npm install`, `npm install <package>`\n- `yarn.lock`: `yarn phoenix <command>`, `yarn install`, `yarn add <package>`\n- `bun.lock` or `bun.lockb`: `bunx phoenix <command>`, `bun install`, `bun add <package>`\n\nWithout a lockfile, use the package manager the `packageManager` field of `package.json` names, or ask the user.",buildCommands:"## Build Commands\n- `pnpm phoenix build` — Full production build\n- `pnpm phoenix dev` — Development mode with hot reload\n- `pnpm phoenix sync` — Sync generated files without full build\n- `pnpm phoenix deps` — Add the SDK's missing peer dependencies to `package.json` and move out-of-range ones into the SDK's range; it installs nothing, so install after it",devLogs:"## Dev Logs\n- `pnpm phoenix dev` writes all logs to `.phoenix/phoenix-dev.log`\n- Contains: spec parse errors, build errors, browser runtime errors, file watcher events\n- After making changes, always check the log for errors: `tail -50 .phoenix/phoenix-dev.log` or `grep ERROR .phoenix/phoenix-dev.log`\n- Rotated automatically at 10MB (`.log.1`, `.log.2` are older rotations)",projectStructure:"## Project Structure\n- `spec/` — Domain YAML specs (entities, relations, expressions, invariants, components, application config)\n- `src/expressions/` — Computed/derived entity properties (`phx.domain.implementCustomExpressions()`)\n- `src/actions/` — Domain operations declared under `actions:` in the spec (`phx.domain.implementActions()`), run by controls and exposed to the assistant\n- `src/invariants/` — Business rule constraints (`phx.domain.implementCustomInvariants()`)\n- `src/transformers/` — Automatic state fixers (`phx.frontend.transformerBuilder`)\n- `src/components/` — ECS system components (`phx.domain.attachComponent.withEntity()`)\n- `src/elements/` — Page-level React components (`phx.frontend.createCustomPhoenixLayoutElement()`)\n - `ConfiguratorLayout`: a layout element with this name replaces everything the built-in layout renders for a loaded configuration, in owner and read mode, finalization included. Prefer arranging the spec's layout components; write one for shell-level changes, such as moving the sidebar or adding an area the built-in layout has no place for\n - Mount `LayoutSlots.SharedCanvas` (from `@salsita-ai/sdk/configurator`) in a positioned root covering the page, or the app loader stays on screen; put the UI above it, positioned and after it in the markup. Call `useSceneSafeArea()` (same import) and put `containerRef` on the element covering the whole canvas and `safeAreaRef` on the region the UI leaves free, with `pointerEvents: 'none'`, so the camera frames the scene there\n - Sidebar moved, contents as the spec configures them: mount `LayoutSlots.DesktopSidebar` in a positioned container that sets its size, with `side=\"start\"` on the left; `docs/layouts/sidebar/in-a-custom-layout.mdx` is the whole layout\n - Your own UI: \"Hooks for a Project Layout\" in `docs/phoenix/configurator-interface.mdx` lists the hooks with what each returns (`pnpm phoenix docs -r docs/phoenix/configurator-interface.mdx`), `docs/phoenix/layout-slots.mdx` the built-in pieces you can still mount, and `docs/layouts/custom-layout.mdx` is a worked example\n - Messages: mount `LayoutSlots.Services` for the built-in snackbars, or show violations, side-effect hints and errors yourself with `phx.frontend.useConfiguratorMessages(onMessage)`, not both. Either way mount a snackbar root (`LayoutSlots.DesktopSnackbarsRoot` or `LayoutSlots.MobileSnackbarsRoot`): save and built-in action errors are always snackbars\n - Finalize over the spec's `finalizeAction` components, each naming a handler registered with `phx.frontend.createPhoenixHandler`: run each with `phx.frontend.useFinalizeAction(handler)` in a component of its own wrapped in `PhoenixHandlerBoundary` (from `@salsita-ai/sdk/react`), or mount `FinalizeActions` (from `@salsita-ai/sdk/configurator`) for the built-in buttons. `finalizePage` and `finalizeButton` are legacy\n - Read mode and fullscreen are the layout's job, no hook enforces them: hide what a viewer must not change while `phx.frontend.useAccessService().accessInfo.viewMode` is `true`, and remove panels while `phx.frontend.useIsFullscreenActive()` is set; `phx.frontend.useSetFullscreen()` returns its setter\n - Assistant form elements: an element declared under `assistant.formElements` (`description`, `role`, scalar `attributes` beside the built-in `label`, a `value` included, `required`) is the default export `phx.frontend.createAssistantFormElement('name', Component)` of one file; the name types the component's props by its role (`AssistantFormElementProps<'name'>`): an option reports its answer with `onSelect(answer)`, an input with `onChange(state, answer)`; and the application does not start while a declared element has no registration or a registration no declaration\n- `src/handlers/` — Event & lifecycle handlers\n- `src/webhooks/` — Server-side webhook handlers (`phx.webhooks.*Builder`); the webhook is the default export of `src/webhooks/index.ts`, which you create when the project needs its own handlers — without it the build uses a built-in inert webhook that answers only anonymous auth, so create the file before setting `useAuthHook` or `useClerk`\n- `src/migrations/` — Schema version migrations (v*.ts)\n- `src/locales/` — Locale catalogs (authored .po sources; compiled .ts, do not edit)\n- `src/admin/` — Admin interface (mirrors main src/ structure)\n- `src/_shared/` — Shared utilities (NOT auto-imported, requires explicit imports)\n- `.phoenix/` — Auto-generated files (DO NOT EDIT, except the option files in `.phoenix/variants/`)\n- `public/` — Static assets (3D models, textures, images, HDRI maps, fonts)\n- `assets/` — Uploadable resources (PDF templates, email assets)",architecturePrinciples:"## Architecture Principles\n- YAML-first: 99% of configuration in spec/*.yaml, custom code is last resort\n- ECS pattern: entities (domain objects) + components (behavior/UI) + systems (SDK runtime)\n- Reactive state: immutable domain state flows through RxJS pipelines\n- Data binding: `$read` (read-only), `$write` (write-only), `$bind` (bidirectional) connect components to domain\n- memoEval: all component implementations must use memoEval for stable object references",keyPatterns:"## Key Patterns\n- Expressions = computed properties on entities (prefix: `$`), implemented per-entity in src/expressions/\n- Actions = named domain operations (`actions:` in YAML with `params` and `result` schemas), implemented in src/actions/, prepared through `actionSystem.prepareAction()` and exposed as assistant mutations through `assistant.actions`\n- Invariants = validation rules returning violations, static or dynamic\n- Transformers = auto-fixers maintaining consistency after state changes\n- Components defined in YAML with `$read`/`$bind` bindings, or custom in src/components/ using attachComponent builder\n- Webhooks = server-side finalization tasks (PDF, email, CSV, image rendering)\n- Filters = contextual component activation via navigationStates, viewStates, modes, selectedEntityIds",fileConventions:`## File Conventions
1
+ export const sdkGuidanceSections={packageManager:"## Package Manager\nThe project installs with its own package manager, and the commands in this skill are written for pnpm. Run them through the package manager the project uses, which the lockfile in the project root names:\n- `pnpm-lock.yaml`: `pnpm phoenix <command>`, `pnpm install`, `pnpm add <package>`\n- `package-lock.json`: `npx phoenix <command>`, `npm install`, `npm install <package>`\n- `yarn.lock`: `yarn phoenix <command>`, `yarn install`, `yarn add <package>`\n- `bun.lock` or `bun.lockb`: `bunx phoenix <command>`, `bun install`, `bun add <package>`\n\nWithout a lockfile, use the package manager the `packageManager` field of `package.json` names, or ask the user.",buildCommands:"## Build Commands\n- `pnpm phoenix build` — Full production build\n- `pnpm phoenix dev` — Development mode with hot reload\n- `pnpm phoenix sync` — Sync generated files without full build\n- `pnpm phoenix deps` — Add the SDK's missing peer dependencies to `package.json` and move out-of-range ones into the SDK's range; it installs nothing, so install after it",devLogs:"## Dev Logs\n- `pnpm phoenix dev` writes all logs to `.phoenix/phoenix-dev.log`\n- Contains: spec parse errors, build errors, browser runtime errors, file watcher events\n- After making changes, always check the log for errors: `tail -50 .phoenix/phoenix-dev.log` or `grep ERROR .phoenix/phoenix-dev.log`\n- Rotated automatically at 10MB (`.log.1`, `.log.2` are older rotations)",projectStructure:"## Project Structure\n- `spec/` — Domain YAML specs (entities, relations, expressions, invariants, components, application config)\n- `src/expressions/` — Computed/derived entity properties (`phx.domain.implementCustomExpressions()`)\n- `src/actions/` — Domain operations declared under `actions:` in the spec (`phx.domain.implementActions()`), run by controls and exposed to the assistant\n- `src/invariants/` — Business rule constraints (`phx.domain.implementCustomInvariants()`)\n- `src/transformers/` — Automatic state fixers (`phx.frontend.transformerBuilder`)\n- `src/components/` — ECS system components (`phx.domain.attachComponent.withEntity()`)\n- `src/elements/` — Page-level React components (`phx.frontend.createCustomPhoenixLayoutElement()`)\n - `ConfiguratorLayout`: a layout element with this name replaces everything the built-in layout renders for a loaded configuration, in owner and read mode, finalization included. Prefer arranging the spec's layout components; write one for shell-level changes, such as moving the sidebar or adding an area the built-in layout has no place for\n - Mount `LayoutSlots.SharedCanvas` (from `@salsita-ai/sdk/configurator`) in a positioned root covering the page; put the UI above it, positioned and after it in the markup. With the canvas mounted the app loader waits until the scene has loaded; a layout without a canvas is not held by the loader. Call `phx.frontend.useSceneSafeArea()` and put `containerRef` on the element covering the whole canvas and `safeAreaRef` on the region the UI leaves free, with `pointerEvents: 'none'`, so the camera frames the scene there\n - Sidebar moved, contents as the spec configures them: mount `LayoutSlots.DesktopSidebar` in a positioned container that sets its size, with `side=\"start\"` on the left; `docs/layouts/sidebar/in-a-custom-layout.mdx` is the whole layout\n - Your own UI: \"Hooks for a Project Layout\" in `docs/phoenix/configurator-interface.mdx` lists the hooks with what each returns (`pnpm phoenix docs -r docs/phoenix/configurator-interface.mdx`), `docs/phoenix/layout-slots.mdx` the built-in pieces you can still mount, and `docs/layouts/custom-layout.mdx` is a worked example. Call the hooks as `phx.frontend.useX()`; besides those below, these are often needed: `usePreview()` (`isPreview` while the preview start screen shows), `useCloseAction()` (the host's close action or `null`), `useActiveViewports()` (the container's breakpoints, `null` until measured, `desktop` above 768 px: the desktop/phone switch), `useResolveLocalizable()` and `useLocalizable(text)` (spec texts to strings), `useIsCloningAllowed()` (a read-mode \"edit a copy\" action with `LayoutSlots.CloneToEditDialog`)\n - Undo and redo: `phx.frontend.useUndoRedo()` returns `{ canUndo, canRedo, undo, redo }`; disable each button from `canUndo`/`canRedo`\n - Tabs: `phx.frontend.useTabNavigation()` returns `{ source, tabs, activeTab, select }` for the spec's `sidebarTabs` (of the selected entity) or `horizontalTabs`; render `tabs` (each `{ index, label, icon, state, isActive }`, `icon` a PhxIcon name) and call `select(tab.index)` on click. Pass `{ source: 'sidebarTabs' }` or `{ source: 'horizontalTabs' }` when the layout shows one kind only. Not `LayoutSlots.useSidebarTabs()`: it serves the built-in sidebar and returns no tabs while its summary shows\n - Steps: `phx.frontend.useStepNavigation()` returns `{ steps, activeStep, activeIndex, isFirst, isLast, canGoNext, canGoPrevious, next, previous, goTo }` for the spec's `navigationSteps`; render `steps` (each `{ index, label, state, status }`, `status` `'complete' | 'active' | 'upcoming'`), call `next()`/`previous()` for Back and Next and `goTo(step.index)` from a stepper. It enforces no order and no validity: enable only `'complete'` steps for an \"earlier steps only\" stepper, and to block moving on while the configuration has a problem, require `phx.frontend.useStateValidity().severity !== 'warning'` besides `canGoNext`: a change with a `fixable` or `fatal` violation is rejected, so the configuration is never invalid, and a `warning` is the problem that stays (it blocks finalizing too). `useSteps` and `useHasSteps` from `@salsita-ai/sdk/configurator` are deprecated\n - Messages: mount `LayoutSlots.Services` for the built-in snackbars, or show violations, side-effect hints, errors and failed saves yourself with `phx.frontend.useConfiguratorMessages(onMessage)`, not both. A failed save arrives as `saveError`, the next successful save as `saveRecovery`; a layout that mounts neither shows no sign of a failed save. Either way mount a snackbar root (`LayoutSlots.DesktopSnackbarsRoot` or `LayoutSlots.MobileSnackbarsRoot`): errors of the built-in actions are always snackbars\n - Finalize over the spec's `finalizeAction` components, each naming a handler registered with `phx.frontend.createPhoenixHandler`: `phx.frontend.useFinalizeActions()` returns `{ actions, primary, secondary, disabled, hints }`; render `primary` (and `secondary` in a menu or list) in a loop, each action `{ key, label, title, icon, run, isPending, error, disabled }`, and call `action.run()` on click (its promise never rejects; show `action.error` on failure). The configurator runs the handlers itself, outside the layout, so a handler must not rely on a provider the layout adds. For one known handler, `phx.frontend.useFinalizeAction(handler)` in a component wrapped in `PhoenixHandlerBoundary` (from `@salsita-ai/sdk/react`) works too; `FinalizeActions` (from `@salsita-ai/sdk/configurator`) mounts the built-in buttons. `finalizePage` and `finalizeButton` are legacy\n - Read mode and fullscreen are the layout's job, no hook enforces them (`useUndoRedo`, `useFinalizeActions` and `useStepNavigation` included): hide undo, redo, finalization and whatever else a viewer must not change while `phx.frontend.useAccessService().accessInfo.viewMode` is `true` (tabs are navigation, so a viewer may switch them), and remove panels while `phx.frontend.useIsFullscreenActive()` is set; `phx.frontend.useSetFullscreen()` returns its setter\n - `ConfigurationNotFoundPage`: `phx.frontend.createConfigurationNotFoundPage(({ onBack }) => …)` replaces the \"configuration not accessible\" page; show a way back only when the optional `onBack` is set. The not-authenticated page's default renders it too; only the admin's not-authorized page keeps the built-in page\n - `ConfiguratorErrorPage`: `phx.frontend.createConfiguratorErrorPage(({ reason, onRetry }) => …)` replaces the production error page; `reason` is `uncaughtError` or `presetCreationFailed`. A page that throws falls back to the built-in one, and development keeps the detailed error pages, so the project page shows only in a production build. Register both pages with these helpers: `createCustomPhoenixLayoutElement` with the name works too, but types the component as taking only `children`, so the typed props do not compile there in a strict project\n - `AppLoaderContent`: `phx.frontend.createAppLoader(({ phases }) => …)` replaces what the loading overlay shows (each phase `{ id, label?, progress? }`, the list possibly empty); Phoenix keeps the overlay itself\n - Assistant form elements: an element declared under `assistant.formElements` (`description`, `role`, scalar `attributes` beside the built-in `label`, a `value` included, `required`) is the default export `phx.frontend.createAssistantFormElement('name', Component)` of one file; the name types the component's props by its role (`AssistantFormElementProps<'name'>`): an option reports its answer with `onSelect(answer)`, an input with `onChange(state, answer)`; and the application does not start while a declared element has no registration or a registration no declaration\n- `src/handlers/` — Event & lifecycle handlers\n- `src/webhooks/` — Server-side webhook handlers (`phx.webhooks.*Builder`); the webhook is the default export of `src/webhooks/index.ts`, which you create when the project needs its own handlers — without it the build uses a built-in inert webhook that answers only anonymous auth, so create the file before setting `useAuthHook` or `useClerk`\n- `src/migrations/` — Schema version migrations (v*.ts)\n- `src/locales/` — Locale catalogs (authored .po sources; compiled .ts, do not edit)\n- `src/admin/` — Admin interface (mirrors main src/ structure)\n- `src/_shared/` — Shared utilities (NOT auto-imported, requires explicit imports)\n- `.phoenix/` — Auto-generated files (DO NOT EDIT, except the option files in `.phoenix/variants/`)\n- `public/` — Static assets (3D models, textures, images, HDRI maps, fonts)\n- `assets/` — Uploadable resources (PDF templates, email assets)",architecturePrinciples:"## Architecture Principles\n- YAML-first: 99% of configuration in spec/*.yaml, custom code is last resort\n- ECS pattern: entities (domain objects) + components (behavior/UI) + systems (SDK runtime)\n- Reactive state: immutable domain state flows through RxJS pipelines\n- Data binding: `$read` (read-only), `$write` (write-only), `$bind` (bidirectional) connect components to domain\n- memoEval: all component implementations must use memoEval for stable object references",keyPatterns:"## Key Patterns\n- Expressions = computed properties on entities (prefix: `$`), implemented per-entity in src/expressions/\n- Actions = named domain operations (`actions:` in YAML with `params` and `result` schemas), implemented in src/actions/, prepared through `actionSystem.prepareAction()` and exposed as assistant mutations through `assistant.actions`\n- Invariants = validation rules returning violations, static or dynamic\n- Transformers = auto-fixers maintaining consistency after state changes\n- Components defined in YAML with `$read`/`$bind` bindings, or custom in src/components/ using attachComponent builder\n- Webhooks = server-side finalization tasks (PDF, email, CSV, image rendering)\n- Filters = contextual component activation via navigationStates, viewStates, modes, selectedEntityIds",fileConventions:`## File Conventions
2
2
  - Components: PascalCase (.tsx)
3
3
  - Utilities: kebab-case (.ts)
4
4
  - Expressions: entity-name.ts
@@ -1,10 +1,11 @@
1
1
  import { Branded } from '@salsita-ai/common/utils';
2
+ import { type ImplementationErrorCollector, type ProjectModule } from '#package/domain';
2
3
  import type { RuntimeReferenceStore } from '../../../caching/index.js';
3
4
  import type { RuntimeSpec } from '../../runtime-spec/index.js';
4
5
  import { FactoryDataRuntime } from '../factory-data/index.js';
5
6
  import { type MigrationModules, MigrationRuntime } from '../migrations/index.js';
6
7
  import { ComponentOptics } from '../sections/component-optic.js';
7
- import { type ExpressionImplementations, ExpressionRuntime, type InvariantImplementations, type MissingExpression } from '../sections/expression-runtime.js';
8
+ import { ExpressionRuntime, type InvariantImplementations, type MissingExpression } from '../sections/expression-runtime.js';
8
9
  import { PresetRuntime } from '../sections/preset-runtime.js';
9
10
  import type { SpecCodeMap } from '../spec-code/index.js';
10
11
  import { AdminModelRuntime } from './admin-model-runtime.js';
@@ -25,4 +26,4 @@ export type AdminRuntimeResult = {
25
26
  readonly ok: false;
26
27
  readonly missingExpressions: readonly MissingExpression[];
27
28
  };
28
- export declare const AdminRuntime: (spec: RuntimeSpec, referenceStore: RuntimeReferenceStore, implementations: ExpressionImplementations, invariantImplementations: InvariantImplementations, migrationModules: MigrationModules, code: SpecCodeMap | undefined) => AdminRuntimeResult;
29
+ export declare const AdminRuntime: (spec: RuntimeSpec, referenceStore: RuntimeReferenceStore, expressionModules: readonly ProjectModule[], invariantImplementations: InvariantImplementations, migrationModules: MigrationModules, code: SpecCodeMap | undefined, errors: ImplementationErrorCollector) => AdminRuntimeResult;
@@ -1 +1 @@
1
- import{Branded as e}from"@salsita-ai/common/utils";import{Preset as t,PresetCategory as i,commonAdminCustomExpressions as n,commonAdminViolationExpressions as r}from"#package/domain";import{FactoryDataRuntime as s}from"../factory-data/index.js";import{MigrationRuntime as o}from"../migrations/index.js";import{ComponentOptics as m}from"../sections/component-optic.js";import{ExpressionRuntime as a}from"../sections/expression-runtime.js";import{PresetRuntime as p}from"../sections/preset-runtime.js";import{AdminModelRuntime as f}from"./admin-model-runtime.js";import{AdminStatesRuntime as u}from"./states-runtime.js";let c={Preset:[{evaluate:(e,i,n)=>{let s=n.domain.get$Entity(e,i);return t.assert(s),r.Preset.nameNotEmpty(s)}}]},l={PresetCategory:{$isDraft:{origin:{name:"$isDraft",typeOrAlias:"PresetCategory"},evaluate:(e,t,r)=>{let s=r.domain.get$Entity(e,t);return i.assert(s),n.PresetCategory.$isDraft(s)},meta:{}}}},d=new WeakMap;export const AdminRuntime=(t,i,n,r,g,R)=>{let y={...l};for(let[e,t]of Object.entries(n))y[e]={...y[e],...t};let j=f(t.admin,t.configurator.dataSchemas,i,R),k=a(t.admin,i,y,"adminExpressionRuntime",((e,t)=>{if(0===Object.keys(e).length)return c;let i=d.get(t)??new WeakMap;d.set(t,i);let n=i.get(e);if(n)return n;let r={};for(let i of[c,e])for(let[e,n]of Object.entries(i))for(let i of t[e]??[e])r[i]=[...r[i]??[],...n];return i.set(e,r),r})(r,j.aliases),R);return k.ok?{ok:!0,runtime:e({modelRuntime:j,componentOptics:m(i,{components:t.admin.components,referenceScope:"adminRuntime/componentOptics",modelRuntime:j,code:R}),expressionRuntime:k.runtime,presetRuntime:p(i,{referenceScope:"adminRuntime/presetRuntime",presets:t.admin.presets.presets}),statesRuntime:u(t,i),migrationRuntime:o(i,{referenceScope:"adminRuntime/migrationRuntime",resolvedVersions:t.admin.resolvedVersions,latestEntities:j.entities,migrationModules:g}),factoryDataRuntime:s(i,{referenceScope:"adminRuntime/factoryDataRuntime",invariants:t.admin.invariants,defaults:t.admin.defaults,aliases:j.aliases,entities:j.entities})})}:{ok:!1,missingExpressions:k.missing}};
1
+ import{Branded as e}from"@salsita-ai/common/utils";import{Preset as t,PresetCategory as i,commonAdminCustomExpressions as n,commonAdminViolationExpressions as r}from"#package/domain";import{FactoryDataRuntime as s}from"../factory-data/index.js";import{MigrationRuntime as o}from"../migrations/index.js";import{ComponentOptics as m}from"../sections/component-optic.js";import{ExpressionRuntime as a}from"../sections/expression-runtime.js";import{PresetRuntime as p}from"../sections/preset-runtime.js";import{AdminModelRuntime as u}from"./admin-model-runtime.js";import{AdminStatesRuntime as f}from"./states-runtime.js";let c={Preset:[{evaluate:(e,i,n)=>{let s=n.domain.get$Entity(e,i);return t.assert(s),r.Preset.nameNotEmpty(s)}}]},d={PresetCategory:{$isDraft:{origin:{name:"$isDraft",typeOrAlias:"PresetCategory"},evaluate:(e,t,r)=>{let s=r.domain.get$Entity(e,t);return i.assert(s),n.PresetCategory.$isDraft(s)},meta:{}}}},l=new WeakMap;export const AdminRuntime=(t,i,n,r,g,R,y)=>{let j=u(t.admin,t.configurator.dataSchemas,i,R),k=a(t.admin,i,n,"adminExpressionRuntime",((e,t)=>{if(0===Object.keys(e).length)return c;let i=l.get(t)??new WeakMap;l.set(t,i);let n=i.get(e);if(n)return n;let r={};for(let i of[c,e])for(let[e,n]of Object.entries(i))for(let i of t[e]??[e])r[i]=[...r[i]??[],...n];return i.set(e,r),r})(r,j.aliases),R,y,d);return k.ok?{ok:!0,runtime:e({modelRuntime:j,componentOptics:m(i,{components:t.admin.components,referenceScope:"adminRuntime/componentOptics",modelRuntime:j,code:R}),expressionRuntime:k.runtime,presetRuntime:p(i,{referenceScope:"adminRuntime/presetRuntime",presets:t.admin.presets.presets}),statesRuntime:f(t,i),migrationRuntime:o(i,{referenceScope:"adminRuntime/migrationRuntime",resolvedVersions:t.admin.resolvedVersions,latestEntities:j.entities,migrationModules:g}),factoryDataRuntime:s(i,{referenceScope:"adminRuntime/factoryDataRuntime",invariants:t.admin.invariants,defaults:t.admin.defaults,aliases:j.aliases,entities:j.entities})})}:{ok:!1,missingExpressions:k.missing}};
@@ -1,12 +1,12 @@
1
1
  import { Branded } from '@salsita-ai/common/utils';
2
- import type { ImportedTransformer } from '#package/domain';
2
+ import { type ImplementationErrorCollector, type ImportedTransformer, type ProjectModule } from '#package/domain';
3
3
  import type { RuntimeReferenceStore } from '../../caching/index.js';
4
4
  import type { RuntimeSpec } from '../runtime-spec/index.js';
5
5
  import { AdminRuntime } from './admin-runtime/admin-runtime.js';
6
6
  import { ConfiguratorRuntime } from './configurator-runtime/configurator-runtime.js';
7
7
  import type { MigrationModules } from './migrations/index.js';
8
8
  import { DataRuntime } from './sections/data-runtime.js';
9
- import type { ExpressionImplementations, InvariantImplementations, MissingExpression } from './sections/expression-runtime.js';
9
+ import type { InvariantImplementations, MissingExpression } from './sections/expression-runtime.js';
10
10
  import type { SpecCodeModule } from './spec-code/index.js';
11
11
  /**
12
12
  * Runtime objects built from a RuntimeSpec.
@@ -42,6 +42,14 @@ export type ApplicationRuntimeResult = {
42
42
  * same generation as `spec`; an id carries a hash of its code, so a module from another generation
43
43
  * misses the ids of changed code instead of running an old closure.
44
44
  *
45
- * Returns an error result when declared expressions are missing implementations.
45
+ * `expressionModules` and `adminExpressionModules` are the project's expression files
46
+ * (`src/expressions/`, `src/admin/expressions/`), as the generated barrels or the editor's reload
47
+ * hand them over; each domain merges them with the aliases of its spec (`mergeExpressionModules`).
48
+ *
49
+ * The mistakes of the project files are recorded in `errors` as `ImplementationError`s: a file with
50
+ * the wrong export, an expression two files define, or that a file defines although the spec or the
51
+ * SDK gives it a value (`DUPLICATE_DEFINITION`), and a declared expression no file implements
52
+ * (`MISSING_IMPLEMENTATION`), which also makes the result an error. Without `errors`, everything
53
+ * recorded is thrown together as one `ImplementationErrors` before the result is returned.
46
54
  */
47
- export declare const ApplicationRuntime: (spec: RuntimeSpec, referenceStore: RuntimeReferenceStore, implementations: ExpressionImplementations, importedTransformers: readonly ImportedTransformer[], invariantImplementations?: InvariantImplementations, adminImplementations?: ExpressionImplementations, adminInvariantImplementations?: InvariantImplementations, migrationModules?: MigrationModules, specCode?: SpecCodeModule) => ApplicationRuntimeResult;
55
+ export declare const ApplicationRuntime: (spec: RuntimeSpec, referenceStore: RuntimeReferenceStore, expressionModules: readonly ProjectModule[], importedTransformers: readonly ImportedTransformer[], invariantImplementations?: InvariantImplementations, adminExpressionModules?: readonly ProjectModule[], adminInvariantImplementations?: InvariantImplementations, migrationModules?: MigrationModules, specCode?: SpecCodeModule, errors?: ImplementationErrorCollector) => ApplicationRuntimeResult;
@@ -1 +1 @@
1
- import{Branded as i}from"@salsita-ai/common/utils";import{AdminRuntime as r}from"./admin-runtime/admin-runtime.js";import{ConfiguratorRuntime as n}from"./configurator-runtime/configurator-runtime.js";import{DataRuntime as o}from"./sections/data-runtime.js";export const ApplicationRuntime=(s,t,m,e,a,u={},p={},f={},c)=>{let g=n(s,t,m,e,a,f,c?.configurator);if(!g.ok)return{ok:!1,missingExpressions:g.missingExpressions};let d=r(s,t,u,p,f,c?.admin);return d.ok?{ok:!0,runtime:i({configurator:g.runtime,admin:d.runtime,data:o(s,t)})}:{ok:!1,missingExpressions:d.missingExpressions}};
1
+ import{Branded as i}from"@salsita-ai/common/utils";import{createImplementationErrorCollector as o}from"#package/domain";import{AdminRuntime as r}from"./admin-runtime/admin-runtime.js";import{ConfiguratorRuntime as n}from"./configurator-runtime/configurator-runtime.js";import{DataRuntime as m}from"./sections/data-runtime.js";export const ApplicationRuntime=(t,s,a,e,u,p=[],f={},c={},d,g)=>{let k=g??o(),l=n(t,s,a,e,u,c,d?.configurator,k),x=r(t,s,p,f,c,d?.admin,k);return(void 0===g&&k.throwIfAny(),l.ok&&x.ok)?{ok:!0,runtime:i({configurator:l.runtime,admin:x.runtime,data:m(t,s)})}:{ok:!1,missingExpressions:[...l.ok?[]:l.missingExpressions,...x.ok?[]:x.missingExpressions]}};
@@ -1,5 +1,5 @@
1
1
  import { Branded } from '@salsita-ai/common/utils';
2
- import type { ImportedTransformer } from '#package/domain';
2
+ import type { ImplementationErrorCollector, ImportedTransformer, ProjectModule } from '#package/domain';
3
3
  import type { RuntimeReferenceStore } from '../../../caching/index.js';
4
4
  import type { RuntimeSpec } from '../../runtime-spec/index.js';
5
5
  import { FactoryDataRuntime } from '../factory-data/index.js';
@@ -7,7 +7,7 @@ import { type MigrationModules, MigrationRuntime } from '../migrations/index.js'
7
7
  import { ActionsRuntime } from '../sections/actions-runtime.js';
8
8
  import { AssistantRuntime } from '../sections/assistant-runtime.js';
9
9
  import { ComponentOptics } from '../sections/component-optic.js';
10
- import { type ExpressionImplementations, ExpressionRuntime, type InvariantImplementations, type MissingExpression } from '../sections/expression-runtime.js';
10
+ import { ExpressionRuntime, type InvariantImplementations, type MissingExpression } from '../sections/expression-runtime.js';
11
11
  import { PresetRuntime } from '../sections/preset-runtime.js';
12
12
  import { ThemeRuntime } from '../sections/theme-runtime.js';
13
13
  import { TransformersRuntime } from '../sections/transformers-runtime.js';
@@ -34,4 +34,4 @@ export type ConfiguratorRuntimeResult = {
34
34
  readonly ok: false;
35
35
  readonly missingExpressions: readonly MissingExpression[];
36
36
  };
37
- export declare const ConfiguratorRuntime: (spec: RuntimeSpec, referenceStore: RuntimeReferenceStore, implementations: ExpressionImplementations, importedTransformers: readonly ImportedTransformer[], invariantImplementations: InvariantImplementations | undefined, migrationModules: MigrationModules, code: SpecCodeMap | undefined) => ConfiguratorRuntimeResult;
37
+ export declare const ConfiguratorRuntime: (spec: RuntimeSpec, referenceStore: RuntimeReferenceStore, expressionModules: readonly ProjectModule[], importedTransformers: readonly ImportedTransformer[], invariantImplementations: InvariantImplementations | undefined, migrationModules: MigrationModules, code: SpecCodeMap | undefined, errors: ImplementationErrorCollector) => ConfiguratorRuntimeResult;
@@ -1 +1 @@
1
- import{Branded as t}from"@salsita-ai/common/utils";import{FactoryDataRuntime as e}from"../factory-data/index.js";import{MigrationRuntime as i}from"../migrations/index.js";import{ActionsRuntime as o}from"../sections/actions-runtime.js";import{AssistantRuntime as r}from"../sections/assistant-runtime.js";import{ComponentOptics as n}from"../sections/component-optic.js";import{ExpressionRuntime as s}from"../sections/expression-runtime.js";import{PresetRuntime as m}from"../sections/preset-runtime.js";import{ThemeRuntime as a}from"../sections/theme-runtime.js";import{TransformersRuntime as u}from"../sections/transformers-runtime.js";import{ConfiguratorModelRuntime as c}from"./configurator-model-runtime.js";import{ConfiguratorStatesRuntime as f}from"./states-runtime.js";export const ConfiguratorRuntime=(p,g,R,j,l,d,x)=>{let v=c(p.configurator,g,x),S=s(p.configurator,g,R,"configuratorExpressionRuntime",l,x);return S.ok?{ok:!0,runtime:t({modelRuntime:v,componentOptics:n(g,{components:p.configurator.components,referenceScope:"configuratorRuntime/componentOptics",modelRuntime:v,code:x}),presetRuntime:m(g,{referenceScope:"configuratorRuntime/presetRuntime",presets:p.configurator.presets.presets}),statesRuntime:f(p,g),expressionRuntime:S.runtime,themeRuntime:a(p,g),transformersRuntime:u(p,g,j),assistantRuntime:r(p,g),actionsRuntime:o(p.configurator.actions,g),migrationRuntime:i(g,{referenceScope:"configuratorRuntime/migrationRuntime",resolvedVersions:p.configurator.resolvedVersions,latestEntities:v.entities,migrationModules:d}),factoryDataRuntime:e(g,{referenceScope:"configuratorRuntime/factoryDataRuntime",invariants:p.configurator.invariants,defaults:p.configurator.defaults,aliases:v.aliases,entities:v.entities})})}:{ok:!1,missingExpressions:S.missing}};
1
+ import{Branded as t}from"@salsita-ai/common/utils";import{FactoryDataRuntime as e}from"../factory-data/index.js";import{MigrationRuntime as i}from"../migrations/index.js";import{ActionsRuntime as o}from"../sections/actions-runtime.js";import{AssistantRuntime as r}from"../sections/assistant-runtime.js";import{ComponentOptics as n}from"../sections/component-optic.js";import{ExpressionRuntime as s}from"../sections/expression-runtime.js";import{PresetRuntime as m}from"../sections/preset-runtime.js";import{ThemeRuntime as a}from"../sections/theme-runtime.js";import{TransformersRuntime as u}from"../sections/transformers-runtime.js";import{ConfiguratorModelRuntime as c}from"./configurator-model-runtime.js";import{ConfiguratorStatesRuntime as f}from"./states-runtime.js";export const ConfiguratorRuntime=(p,g,R,j,l,d,x,v)=>{let S=c(p.configurator,g,x),k=s(p.configurator,g,R,"configuratorExpressionRuntime",l,x,v);return k.ok?{ok:!0,runtime:t({modelRuntime:S,componentOptics:n(g,{components:p.configurator.components,referenceScope:"configuratorRuntime/componentOptics",modelRuntime:S,code:x}),presetRuntime:m(g,{referenceScope:"configuratorRuntime/presetRuntime",presets:p.configurator.presets.presets}),statesRuntime:f(p,g),expressionRuntime:k.runtime,themeRuntime:a(p,g),transformersRuntime:u(p,g,j),assistantRuntime:r(p,g),actionsRuntime:o(p.configurator.actions,g),migrationRuntime:i(g,{referenceScope:"configuratorRuntime/migrationRuntime",resolvedVersions:p.configurator.resolvedVersions,latestEntities:S.entities,migrationModules:d}),factoryDataRuntime:e(g,{referenceScope:"configuratorRuntime/factoryDataRuntime",invariants:p.configurator.invariants,defaults:p.configurator.defaults,aliases:S.aliases,entities:S.entities})})}:{ok:!1,missingExpressions:k.missing}};
@@ -1,5 +1,5 @@
1
1
  import { Branded } from '@salsita-ai/common/utils';
2
- import type { DomainEntity, Expression as DomainExpression, Invariant as DomainInvariant } from '#package/domain';
2
+ import type { DomainEntity, Expression as DomainExpression, Invariant as DomainInvariant, ImplementationErrorCollector, ProjectModule } from '#package/domain';
3
3
  import type { RuntimeReferenceStore } from '../../../caching/index.js';
4
4
  import type { Expressions } from '../../../parse-application-files/index.js';
5
5
  import { type RuntimeModelVersion } from '../../runtime-spec/index.js';
@@ -39,11 +39,17 @@ interface ExpressionRuntimeSpec {
39
39
  *
40
40
  * Dispatches on `expression.implementation.kind`:
41
41
  * - `relation` / `violations` — calls the matching SDK factory with params + runtime context
42
- * - `user` — uses the dynamically imported impl from `src/expressions/*.ts`
42
+ * - `user` — uses the implementation of the project files `expressionModules` (`src/expressions/`,
43
+ * or `src/admin/expressions/`), merged with the spec's aliases by `mergeExpressionModules`, or the
44
+ * one `builtIn` holds
43
45
  * - `value` — evaluates the parsed {@link MemoEvalPlan}; stabilized per
44
46
  * {@link canonicalEnhancedJsonValueKey} so identical values reuse the same
45
47
  * evaluator across rebuilds. Its `$eval` code comes from `code`, the domain's map of the generated
46
48
  * code module, when that holds it.
49
+ *
50
+ * A file that is wrong, or that defines an expression another file, the spec or `builtIn` already
51
+ * defines, is recorded in `errors` as an `ImplementationError` and left out. So is every declared
52
+ * expression without an implementation, which also makes the result an error.
47
53
  */
48
- export declare const ExpressionRuntime: (spec: ExpressionRuntimeSpec, referenceStore: RuntimeReferenceStore, implementations: ExpressionImplementations, referenceScopePrefix: string, invariantImplementations: InvariantImplementations | undefined, code: SpecCodeMap | undefined) => ExpressionRuntimeResult;
54
+ export declare const ExpressionRuntime: (spec: ExpressionRuntimeSpec, referenceStore: RuntimeReferenceStore, expressionModules: readonly ProjectModule[], referenceScopePrefix: string, invariantImplementations: InvariantImplementations | undefined, code: SpecCodeMap | undefined, errors: ImplementationErrorCollector, builtIn?: ExpressionImplementations) => ExpressionRuntimeResult;
49
55
  export {};
@@ -1 +1 @@
1
- import e from"lodash-es/isEqual.js";import{Branded as t}from"@salsita-ai/common/utils";import{createRelationFactory as i}from"#package/domain";import{canonicalEnhancedJsonValueKey as n,isSdkExpressionImplementation as a}from"../../../core/index.js";import{specCodeExpressionKey as r}from"../../runtime-spec/index.js";import{generateMemoEvalPlanRuntime as l}from"./generate-memo-eval-plan-runtime.js";let o={},s=["0-1","1-1","0-N","1-N"],p={relation:(e,t)=>{let n=t[0];if(!("object"==typeof n&&null!==n&&"kind"in n&&"target"in n&&"string"==typeof n.target&&"cardinality"in n&&s.includes(n.cardinality)&&("allOfType"===n.kind||("direct"===n.kind||"indirect"===n.kind)&&"field"in n&&"string"==typeof n.field)))throw Error("Cannot create the relation expression because its parameter is not a relation declaration. The application spec is inconsistent; rebuild it from a valid relations declaration.");return i(e.aliasMap)(n)},violations:(e,t)=>{let i=t[0];if("object"!=typeof i||null===i||!("entityType"in i)||"string"!=typeof i.entityType)throw Error("Cannot create the violations expression because its entityType parameter is missing. The application spec is inconsistent; rebuild it from a valid invariants declaration.");let n=i.entityType,a=Object.entries(e.invariantImplementations).flatMap(([t,i])=>{let a=e.aliasMap[t];return t===n||a?.includes(n)?i:[]});return{origin:{name:"$violations",typeOrAlias:n},evaluate:(e,t,i)=>a.flatMap(n=>n.evaluate(e,t,i)),meta:{}}}},m=e=>{let t=l(e.plan,r(e.entityOrAlias,e.name),e.code);return{origin:{name:e.name,typeOrAlias:e.entityOrAlias},evaluate:(e,i,n)=>t(n.domain.get$Entity(e,i),i,n),meta:{}}},d=e=>({...(0,p[e.kind])({aliasMap:e.aliasMap,invariantImplementations:e.invariantImplementations},e.params),origin:{name:e.name,typeOrAlias:e.entityOrAlias}});export const ExpressionRuntime=(i,r,l,s,p=o,u)=>{let c={};for(let[e,t]of i.latestModel.aliases)c[String(e)]=t.map(String);let f=r.createBuilder(`${s}/sdk`,{build:d,getKey:e=>`sdk::${e.entityOrAlias}::${e.name}`,compare:(t,i)=>t.kind===i.kind&&e(t.params,i.params)&&e(t.aliasMap,i.aliasMap)&&("violations"!==i.kind||t.invariantImplementations===i.invariantImplementations)}),y=r.createBuilder(`${s}/user`,{build:e=>e.impl,getKey:e=>`user::${e.entityType}::${e.name}`,compare:(e,t)=>e.impl===t.impl}),g=r.createBuilder(`${s}/value`,{build:m,getKey:e=>`value::${e.entityOrAlias}::${e.name}`,compare:(e,t)=>e.valueKey===t.valueKey&&e.code===t.code}),v={},S=!1,k=new Set,b=new Set,O=new Set;for(let[e,t]of i.expressions.expressions)for(let[,i]of t){let t=c[String(e)]??[String(e)];if(a(i.implementation)){let n={entityOrAlias:String(e),name:String(i.name),kind:i.implementation.kind,params:i.implementation.params,aliasMap:c,invariantImplementations:p},a=f.build(n);for(let e of(a.changed&&(S=!0),k.add(f.getKey(n)),t))v[e]||(v[e]={}),v[e][String(i.name)]=a.output;continue}if("value"===i.implementation.kind){let a=i.implementation.value,r={entityOrAlias:String(e),name:String(i.name),valueKey:n(a),plan:i.implementation.plan,code:u},l=g.build(r);for(let e of(l.changed&&(S=!0),O.add(g.getKey(r)),t))v[e]||(v[e]={}),v[e][String(i.name)]=l.output;continue}}for(let[e,t]of Object.entries(l))for(let[i,n]of Object.entries(t)){let t={entityType:e,name:i,impl:n},a=y.build(t);a.changed&&(S=!0),b.add(y.getKey(t)),v[e]||(v[e]={}),v[e][i]=a.output}f.cleanup(k)&&(S=!0),y.cleanup(b)&&(S=!0),g.cleanup(O)&&(S=!0);let h=[];for(let[e,t]of i.expressions.entityExpressions)for(let n of t.shapeGroups){let t=i.expressions.expressions.get(n);if(t)for(let[i]of t)v[String(e)]?.[String(i)]||h.push({entityType:String(e),exprName:String(i)})}return h.length>0?{ok:!1,missing:h}:{ok:!0,runtime:t({merged:v,changed:S})}};
1
+ import e from"lodash-es/isEqual.js";import{Branded as t}from"@salsita-ai/common/utils";import{ImplementationError as i,createRelationFactory as n,mergeExpressionModules as a}from"#package/domain";import{canonicalEnhancedJsonValueKey as r,isSdkExpressionImplementation as o}from"../../../core/index.js";import{specCodeExpressionKey as l}from"../../runtime-spec/index.js";import{generateMemoEvalPlanRuntime as s}from"./generate-memo-eval-plan-runtime.js";let p={},m=["0-1","1-1","0-N","1-N"],d={relation:(e,t)=>{let i=t[0];if(!("object"==typeof i&&null!==i&&"kind"in i&&"target"in i&&"string"==typeof i.target&&"cardinality"in i&&m.includes(i.cardinality)&&("allOfType"===i.kind||("direct"===i.kind||"indirect"===i.kind)&&"field"in i&&"string"==typeof i.field)))throw Error("Cannot create the relation expression because its parameter is not a relation declaration. The application spec is inconsistent; rebuild it from a valid relations declaration.");return n(e.aliasMap)(i)},violations:(e,t)=>{let i=t[0];if("object"!=typeof i||null===i||!("entityType"in i)||"string"!=typeof i.entityType)throw Error("Cannot create the violations expression because its entityType parameter is missing. The application spec is inconsistent; rebuild it from a valid invariants declaration.");let n=i.entityType,a=Object.entries(e.invariantImplementations).flatMap(([t,i])=>{let a=e.aliasMap[t];return t===n||a?.includes(n)?i:[]});return{origin:{name:"$violations",typeOrAlias:n},evaluate:(e,t,i)=>a.flatMap(n=>n.evaluate(e,t,i)),meta:{}}}},f=e=>{let t=s(e.plan,l(e.entityOrAlias,e.name),e.code);return{origin:{name:e.name,typeOrAlias:e.entityOrAlias},evaluate:(e,i,n)=>t(n.domain.get$Entity(e,i),i,n),meta:{}}},u=e=>({...(0,d[e.kind])({aliasMap:e.aliasMap,invariantImplementations:e.invariantImplementations},e.params),origin:{name:e.name,typeOrAlias:e.entityOrAlias}});export const ExpressionRuntime=(n,l,s,m,d=p,c,g,y={})=>{let v={};for(let[e,t]of n.latestModel.aliases)v[String(e)]=t.map(String);let x={...y};for(let[e,t]of Object.entries(a(s,v,g,((e,t,i)=>{let n=new Map,a=(e,t)=>{n.set(e,(n.get(e)??new Set).add(t))};for(let[i,n]of e.expressions.expressions)for(let[e,r]of n)if("user"!==r.implementation.kind)for(let n of t[String(i)]??[String(i)])a(n,String(e));for(let[e,t]of Object.entries(i))for(let i of Object.keys(t))a(e,i);return n})(n,v,y))))x[e]={...x[e],...t};let S=l.createBuilder(`${m}/sdk`,{build:u,getKey:e=>`sdk::${e.entityOrAlias}::${e.name}`,compare:(t,i)=>t.kind===i.kind&&e(t.params,i.params)&&e(t.aliasMap,i.aliasMap)&&("violations"!==i.kind||t.invariantImplementations===i.invariantImplementations)}),h=l.createBuilder(`${m}/user`,{build:e=>e.impl,getKey:e=>`user::${e.entityType}::${e.name}`,compare:(e,t)=>{let i,n;return(i=e.impl)===(n=t.impl)||i.evaluate===n.evaluate&&i.meta===n.meta&&i.origin.name===n.origin.name&&i.origin.typeOrAlias===n.origin.typeOrAlias}}),O=l.createBuilder(`${m}/value`,{build:f,getKey:e=>`value::${e.entityOrAlias}::${e.name}`,compare:(e,t)=>e.valueKey===t.valueKey&&e.code===t.code}),b={},k=!1,$=new Set,M=new Set,j=new Set;for(let[e,t]of n.expressions.expressions)for(let[,i]of t){let t=v[String(e)]??[String(e)];if(o(i.implementation)){let n={entityOrAlias:String(e),name:String(i.name),kind:i.implementation.kind,params:i.implementation.params,aliasMap:v,invariantImplementations:d},a=S.build(n);for(let e of(a.changed&&(k=!0),$.add(S.getKey(n)),t))b[e]||(b[e]={}),b[e][String(i.name)]=a.output;continue}if("value"===i.implementation.kind){let n=i.implementation.value,a={entityOrAlias:String(e),name:String(i.name),valueKey:r(n),plan:i.implementation.plan,code:c},o=O.build(a);for(let e of(o.changed&&(k=!0),j.add(O.getKey(a)),t))b[e]||(b[e]={}),b[e][String(i.name)]=o.output;continue}}for(let[e,t]of Object.entries(x))for(let[i,n]of Object.entries(t)){let t={entityType:e,name:i,impl:n},a=h.build(t);a.changed&&(k=!0),M.add(h.getKey(t)),b[e]||(b[e]={}),b[e][i]=a.output}S.cleanup($)&&(k=!0),h.cleanup(M)&&(k=!0),O.cleanup(j)&&(k=!0);let A=[];for(let[e,t]of n.expressions.entityExpressions)for(let i of t.shapeGroups){let t=n.expressions.expressions.get(i);if(t)for(let[i]of t)b[String(e)]?.[String(i)]||A.push({entityType:String(e),exprName:String(i)})}return A.length>0?(A.forEach(e=>g.add(new i({code:"MISSING_IMPLEMENTATION",origin:null,problem:`Missing implementation of expression ${e.entityType}.${e.exprName}`,fix:"The spec declares it without a value of its own ($eval, $msg or a read), so a project file implements it: a default export of phx.domain.implementCustomExpressions({ ... }) in src/expressions/, or of phx.domain.admin.implementCustomExpressions({ ... }) in src/admin/expressions/ for an admin entity type. Implement it, or remove the declaration from the spec."}))),{ok:!1,missing:A}):{ok:!0,runtime:t({merged:b,changed:k})}};
@@ -8,8 +8,8 @@ import type { ConfiguratorExtensionSelectors } from '../../selectors.js';
8
8
  export type AssistantClientTool = AnyClientTool;
9
9
  /**
10
10
  * Constructor context of an `AssistantSystem`: whole selector objects, like its peers take them, so
11
- * the tools reach the store, the session mode and the `GraphQLSystem` when they are called, and the
12
- * chat reaches the server of the current session when it sends a request.
11
+ * the tools reach the store, the session mode, the view mode and the `GraphQLSystem` when they are
12
+ * called, and the chat reaches the server of the current session when it sends a request.
13
13
  */
14
14
  export interface AssistantSystemContext {
15
15
  readonly configuratorExtensionSelectors: ConfiguratorExtensionSelectors;
@@ -253,7 +253,8 @@ export declare class AssistantSystem implements InitializableSystem {
253
253
  * taken back; the non-undoable commits made on top of an undone change go with it, as with the
254
254
  * toolbar's undo.
255
255
  *
256
- * Accepted: like the toolbar's undo, it does not check the session mode; only `apply` requires `owner`.
256
+ * Accepted: like the toolbar's undo, it checks neither the session mode nor the view mode; only
257
+ * `apply` follows the view mode and refuses a finalize run.
257
258
  */
258
259
  undoToolCalls: (toolCallIds: ReadonlySet<string>) => void;
259
260
  setOpen: (open: boolean) => void;
@@ -1 +1 @@
1
- import{ChatClient as t,fetchServerSentEvents as e}from"@tanstack/ai-client";import{BehaviorSubject as i}from"rxjs";import{skip as s}from"rxjs/operators";import{isShallowEqual as a}from"@salsita-ai/common/utils";import{AssistantRequestError as r}from"#package/client";import{createBrowserDetailsClientTool as n}from"./browser-details.js";import{ChangeRecorder as o}from"./change-recorder.js";import{createApplyClientTool as l,createQueryClientTool as h,toToolResult as d}from"./graphql-tools.js";let c=Object.freeze({messages:Object.freeze([]),isLoading:!1,error:void 0,failedStatus:void 0,isContinuable:!0,isLoaded:!1,isResuming:!1,earlierThreads:Object.freeze([]),hasEarlierThread:!1,isLoadingEarlierThread:!1}),u=Object.freeze({open:!1,hasUnreadReply:!1,isInputFocused:!1}),_=Object.freeze({}),g=d({results:[],committed:!1,sideEffects:[],screenshots:new Map,message:"Nothing was run, because the user closed the configurator while this reply was being written. Do not call any more tools in this reply and end it now. The tools work again as soon as the user writes the next message."}),m=t=>{if(t.getError())return!0;let e=t.getMessages().at(-1)?.parts.at(-1);return e?.type!=="tool-call"&&e?.type!=="tool-result"};export class AssistantSystem{_context;_tools;_chat=new i(c);_panel=new i(u);_activation=null;_current=null;_finishing=new Set;_olderThreadId=null;_resuming=null;_refused=null;_firstAttempt=null;_chain={};_loadingThreadId=null;_recorder;_recording=null;_applyToolCallIds=new WeakMap;_undoTipToolCallId=new i(void 0);constructor(t){this._context=t;let{configuratorExtensionSelectors:e,domainContextSelectors:i,domainServicesSelectors:s,getAssistantSetup:a}=t;this._recorder=new o({maxEntities:30},{readers:{selectedEntityId:t=>i.getNavigationSystem().getActiveSelectionState(t),navigationState:t=>i.getNavigationSystem().getActiveNavigationState(t),viewState:t=>i.getNavigationSystem().getActiveViewState(t),toolState:t=>i.getNavigationSystem().getActiveToolState(t)},getExposedFields:()=>a().manifest?.fields??_,resolveLocalizable:t=>s.getResolveLocalizable()(t)});let r={getGraphQLSystem:()=>e.getGraphQLSystem(),getStoreSystem:()=>i.getStoreSystem(),getActiveMode:()=>i.getActiveMode(),clearChanges:()=>this._recorder.clear(this._committedState()),rememberCommit:(t,e)=>{this._applyToolCallIds.set(e,t),this._refreshUndoTip()}};this._tools=[n(),h(r),l(r)],i.getUndoSystem().tip$.subscribe(this._refreshUndoTip)}chat$=this._chat;panel$=this._panel;undoTipToolCallId$=this._undoTipToolCallId;getSessionManifest=()=>this._context.getAssistantSetup().manifest;initialize=()=>{let{committed:t}=this._context.domainContextSelectors.getStoreSystem().stateSlices;this._recording??=t.pipe(s(1)).subscribe(this._recorder.record),this._recorder.reset(t.value.state),this._endChat(),this._patchPanel(u),this._activation&&this._startClient()};activate=()=>{this._endChat();let t={};return this._activation=t,this._startClient(),()=>{this._activation===t&&(this._activation=null,this._endChat())}};send=async t=>{if(!this._chat.value.isContinuable&&!await this.resume())return;let e=this._current;if(!e)return;let i={changes:this._recorder.take(this._committedState())};this._firstAttempt=e;try{await this._sendOn(e,t,i);let s=this._findRefusedMessageIndex(e);if(-1===s)return;this._refused={chat:e,index:s}}finally{this._firstAttempt===e&&(this._firstAttempt=null)}if(!await this.resume())return;let s=this._current;s&&await this._sendOn(s,t,i)};resume=async()=>{let t=this._current;if(!t)return!1;if(this._chat.value.isContinuable)return!0;if(this._resuming)return this._resuming;let e=this._resume(t).finally(()=>{this._resuming===e&&(this._resuming=null)});return this._resuming=e,e};loadEarlierThread=async()=>{let t=this._current,e=this._olderThreadId;if(!t||null===e||this._loadingThreadId===e)return;let i=this._chain;this._loadingThreadId=e,this._chat.next({...this._chat.value,isLoadingEarlierThread:!0});try{let s=await t.authorizedClient.getAssistantEarlierThread(t.configurationId,e,50);if(this._chain!==i||this._olderThreadId!==e)return;this._olderThreadId=s.previousThreadId,this._chat.next({...this._chat.value,earlierThreads:[{threadId:e,messages:s.messages},...this._chat.value.earlierThreads],hasEarlierThread:null!==s.previousThreadId})}catch(t){this._context.domainServicesSelectors.getLogger().warn("Could not load the earlier assistant conversation",{error:t})}finally{this._chain===i&&this._loadingThreadId===e&&(this._loadingThreadId=null,this._chat.next({...this._chat.value,isLoadingEarlierThread:!1}))}};stop=async()=>{let t=this._current;if(!t)return;let e=t.client.getCurrentRunId();if(t.client.stop(),null!=e)try{let i=t.getConnection();await fetch(`${i.url}/runs/${encodeURIComponent(e)}/cancel`,{method:"POST",headers:await i.headers()})}catch(t){this._context.domainServicesSelectors.getLogger().warn("Could not cancel the assistant run on the server",{error:t})}};reloadThread=()=>{if(!this._activation)return;let t=this._retireChat();t?.client.stop(),t?.dispose(),this._recorder.reset(this._committedState()),this._startClient()};undoToolCalls=t=>{let e=this._context.domainContextSelectors.getUndoSystem(),i=()=>{let e=this._findTipToolCallId();return void 0!==e&&t.has(e)};for(;i();)e.undo()};setOpen=t=>{this._patchPanel(t?{open:t,hasUnreadReply:!1}:{open:t,isInputFocused:!1})};setInputFocused=t=>{this._patchPanel({isInputFocused:t})};_findRefusedMessageIndex=t=>{var e;let i,{failedStatus:s,isContinuable:a}=this._chat.value;return this._firstAttempt===t&&t.generation.active&&409===s&&!a?(i=(e=t.client.getMessages()).map(t=>t.role).lastIndexOf("user"),e.slice(i+1).every(t=>0===t.parts.length)?i:-1):-1};_sendOn=async(t,e,i)=>{let{client:s}=t;s.getIsLoading()||null===s.getResumeState()||s.stop();try{await s.sendMessage({content:e,metadata:i})}catch(i){let e=i instanceof Error?i:Error(String(i));t.generation.active&&this._chat.next({...this._chat.value,error:e}),this._context.domainServicesSelectors.getLogger().error("The assistant message could not be sent",{},e)}};_resume=async t=>{this._chat.next({...this._chat.value,isResuming:!0,error:void 0,failedStatus:void 0});try{let{previousThreadId:e}=await t.authorizedClient.compactAssistantThread(t.configurationId);if(!t.generation.active)return!1;let{messages:i,earlierThreads:s,hasEarlierThread:a}=this._chat.value,r=this._refused?.chat===t?i.slice(0,this._refused.index):i;return t.generation.active=!1,this._current=null,t.client.stop(),t.dispose(),this._chat.next({...c,earlierThreads:[...s,{threadId:e,messages:r}],hasEarlierThread:a,isLoadingEarlierThread:null!==this._loadingThreadId}),this._startClient(),!0}catch(i){let e=i instanceof Error?i:Error(String(i));if(e instanceof r&&409===e.status)return t.generation.active&&this.reloadThread(),!1;return t.generation.active&&this._chat.next({...this._chat.value,isResuming:!1,error:e,failedStatus:e instanceof r?e.status:void 0}),this._context.domainServicesSelectors.getLogger().error("The assistant thread could not be resumed",{},e),!1}};_findTipToolCallId=()=>{let t=this._context.domainContextSelectors.getUndoSystem(),e=t.tip$.value?.committedState;return void 0!==e&&t.canUndo()?this._applyToolCallIds.get(e):void 0};_refreshUndoTip=()=>{let t=this._findTipToolCallId();t!==this._undoTipToolCallId.value&&this._undoTipToolCallId.next(t)};_committedState=()=>this._context.domainContextSelectors.getStoreSystem().stateSlices.committed.value.state;_patchPanel=t=>{let e={...this._panel.value,...t};a(e,this._panel.value)||this._panel.next(e)};_takeOverThread=t=>{for(let e of this._finishing)e.configurationId===t&&(e.client.stop(),e.dispose())};_startClient=()=>{let i={active:!0},s=this._context.getConfigurationId();this._takeOverThread(s);let r=this._context.getAuthorizedClient(),n=()=>{if(i.active){let{manifest:t,error:e}=this._context.getAssistantSetup();if(e)throw e;if(!t)throw Error("The assistant is disabled for this session.")}return r.getAssistantChatConnection(s)},o=t=>{if(!i.active)return;let e={...this._chat.value,...t};a(e,this._chat.value)||this._chat.next(e)},l=async(t,e)=>{let s=await fetch(t,e).finally(()=>o({isLoaded:!0})),a=s.headers.get("x-assistant-thread-continuable");return null!=a&&s.ok&&i.active&&0===this._chat.value.earlierThreads.length&&(this._olderThreadId=s.headers.get("x-assistant-previous-thread")),o({failedStatus:s.ok?void 0:s.status,...null!=a&&{isContinuable:"false"!==a,hasEarlierThread:null!==this._olderThreadId}}),s},h=async()=>({headers:await n().headers(),fetchClient:l}),d=e(()=>n().url,h),c=e(()=>`${n().url}/runs`,h),u=this._tools.map(t=>({...t,execute:(e,s)=>{if(!i.active)return g;let{manifest:a,error:r}=this._context.getAssistantSetup();return r||!a?{error:r?.message??"The assistant is disabled for this session."}:t.execute?.(e,s)}})),_=new t({threadId:`assistant:${s}`,connection:{...d,joinRun:c.joinRun},persistence:!0,history:{pageSize:50},tools:u,onMessagesChange:t=>o({messages:t}),onLoadingChange:t=>{let e=i.active&&this._chat.value.isLoading;o({isLoading:t}),!t&&m(_)&&(i.active?e&&!this._panel.value.open&&this._patchPanel({hasUnreadReply:!0}):p())},onErrorChange:t=>{i.active&&t!==this._chat.value.error&&(!t||-1===this._findRefusedMessageIndex(v))&&(o({error:t}),t&&this._context.domainServicesSelectors.getLogger().error("The assistant request failed",{status:this._chat.value.failedStatus},t))}}),f=!1,p=()=>{f||(f=!0,this._finishing.delete(v),_.dispose())},v={client:_,configurationId:s,generation:i,authorizedClient:r,getConnection:n,dispose:p};this._current=v,_.attach()};_retireChat=()=>{let t=this._current;return this._current=null,t&&(t.generation.active=!1),this._chain={},this._olderThreadId=null,this._resuming=null,this._refused=null,this._loadingThreadId=null,this._chat.value!==c&&this._chat.next(c),t};_endChat=()=>{let t=this._retireChat();if(t){if(!t.client.getIsLoading()&&m(t.client))return void t.dispose();this._finishing.add(t)}}}
1
+ import{ChatClient as e,fetchServerSentEvents as t}from"@tanstack/ai-client";import{BehaviorSubject as i}from"rxjs";import{skip as s}from"rxjs/operators";import{isShallowEqual as a}from"@salsita-ai/common/utils";import{AssistantRequestError as r}from"#package/client";import{createBrowserDetailsClientTool as n}from"./browser-details.js";import{ChangeRecorder as o}from"./change-recorder.js";import{createApplyClientTool as l,createQueryClientTool as h,toToolResult as d}from"./graphql-tools.js";let c=Object.freeze({messages:Object.freeze([]),isLoading:!1,error:void 0,failedStatus:void 0,isContinuable:!0,isLoaded:!1,isResuming:!1,earlierThreads:Object.freeze([]),hasEarlierThread:!1,isLoadingEarlierThread:!1}),u=Object.freeze({open:!1,hasUnreadReply:!1,isInputFocused:!1}),_=Object.freeze({}),g=d({results:[],committed:!1,sideEffects:[],screenshots:new Map,message:"Nothing was run, because the user closed the configurator while this reply was being written. Do not call any more tools in this reply and end it now. The tools work again as soon as the user writes the next message."}),m=e=>{if(e.getError())return!0;let t=e.getMessages().at(-1)?.parts.at(-1);return t?.type!=="tool-call"&&t?.type!=="tool-result"};export class AssistantSystem{_context;_tools;_chat=new i(c);_panel=new i(u);_activation=null;_current=null;_finishing=new Set;_olderThreadId=null;_resuming=null;_refused=null;_firstAttempt=null;_chain={};_loadingThreadId=null;_recorder;_recording=null;_applyToolCallIds=new WeakMap;_undoTipToolCallId=new i(void 0);constructor(e){this._context=e;let{configuratorExtensionSelectors:t,domainContextSelectors:i,domainServicesSelectors:s,getAssistantSetup:a}=e;this._recorder=new o({maxEntities:30},{readers:{selectedEntityId:e=>i.getNavigationSystem().getActiveSelectionState(e),navigationState:e=>i.getNavigationSystem().getActiveNavigationState(e),viewState:e=>i.getNavigationSystem().getActiveViewState(e),toolState:e=>i.getNavigationSystem().getActiveToolState(e)},getExposedFields:()=>a().manifest?.fields??_,resolveLocalizable:e=>s.getResolveLocalizable()(e)});let r={getGraphQLSystem:()=>t.getGraphQLSystem(),getStoreSystem:()=>i.getStoreSystem(),getActiveMode:()=>i.getActiveMode(),getIsViewMode:()=>i.getIsViewMode(),clearChanges:()=>this._recorder.clear(this._committedState()),rememberCommit:(e,t)=>{this._applyToolCallIds.set(t,e),this._refreshUndoTip()}};this._tools=[n(),h(r),l(r)],i.getUndoSystem().tip$.subscribe(this._refreshUndoTip)}chat$=this._chat;panel$=this._panel;undoTipToolCallId$=this._undoTipToolCallId;getSessionManifest=()=>this._context.getAssistantSetup().manifest;initialize=()=>{let{committed:e}=this._context.domainContextSelectors.getStoreSystem().stateSlices;this._recording??=e.pipe(s(1)).subscribe(this._recorder.record),this._recorder.reset(e.value.state),this._endChat(),this._patchPanel(u),this._activation&&this._startClient()};activate=()=>{this._endChat();let e={};return this._activation=e,this._startClient(),()=>{this._activation===e&&(this._activation=null,this._endChat())}};send=async e=>{if(!this._chat.value.isContinuable&&!await this.resume())return;let t=this._current;if(!t)return;let i={changes:this._recorder.take(this._committedState())};this._firstAttempt=t;try{await this._sendOn(t,e,i);let s=this._findRefusedMessageIndex(t);if(-1===s)return;this._refused={chat:t,index:s}}finally{this._firstAttempt===t&&(this._firstAttempt=null)}if(!await this.resume())return;let s=this._current;s&&await this._sendOn(s,e,i)};resume=async()=>{let e=this._current;if(!e)return!1;if(this._chat.value.isContinuable)return!0;if(this._resuming)return this._resuming;let t=this._resume(e).finally(()=>{this._resuming===t&&(this._resuming=null)});return this._resuming=t,t};loadEarlierThread=async()=>{let e=this._current,t=this._olderThreadId;if(!e||null===t||this._loadingThreadId===t)return;let i=this._chain;this._loadingThreadId=t,this._chat.next({...this._chat.value,isLoadingEarlierThread:!0});try{let s=await e.authorizedClient.getAssistantEarlierThread(e.configurationId,t,50);if(this._chain!==i||this._olderThreadId!==t)return;this._olderThreadId=s.previousThreadId,this._chat.next({...this._chat.value,earlierThreads:[{threadId:t,messages:s.messages},...this._chat.value.earlierThreads],hasEarlierThread:null!==s.previousThreadId})}catch(e){this._context.domainServicesSelectors.getLogger().warn("Could not load the earlier assistant conversation",{error:e})}finally{this._chain===i&&this._loadingThreadId===t&&(this._loadingThreadId=null,this._chat.next({...this._chat.value,isLoadingEarlierThread:!1}))}};stop=async()=>{let e=this._current;if(!e)return;let t=e.client.getCurrentRunId();if(e.client.stop(),null!=t)try{let i=e.getConnection();await fetch(`${i.url}/runs/${encodeURIComponent(t)}/cancel`,{method:"POST",headers:await i.headers()})}catch(e){this._context.domainServicesSelectors.getLogger().warn("Could not cancel the assistant run on the server",{error:e})}};reloadThread=()=>{if(!this._activation)return;let e=this._retireChat();e?.client.stop(),e?.dispose(),this._recorder.reset(this._committedState()),this._startClient()};undoToolCalls=e=>{let t=this._context.domainContextSelectors.getUndoSystem(),i=()=>{let t=this._findTipToolCallId();return void 0!==t&&e.has(t)};for(;i();)t.undo()};setOpen=e=>{this._patchPanel(e?{open:e,hasUnreadReply:!1}:{open:e,isInputFocused:!1})};setInputFocused=e=>{this._patchPanel({isInputFocused:e})};_findRefusedMessageIndex=e=>{var t;let i,{failedStatus:s,isContinuable:a}=this._chat.value;return this._firstAttempt===e&&e.generation.active&&409===s&&!a?(i=(t=e.client.getMessages()).map(e=>e.role).lastIndexOf("user"),t.slice(i+1).every(e=>0===e.parts.length)?i:-1):-1};_sendOn=async(e,t,i)=>{let{client:s}=e;s.getIsLoading()||null===s.getResumeState()||s.stop();try{await s.sendMessage({content:t,metadata:i})}catch(i){let t=i instanceof Error?i:Error(String(i));e.generation.active&&this._chat.next({...this._chat.value,error:t}),this._context.domainServicesSelectors.getLogger().error("The assistant message could not be sent",{},t)}};_resume=async e=>{this._chat.next({...this._chat.value,isResuming:!0,error:void 0,failedStatus:void 0});try{let{previousThreadId:t}=await e.authorizedClient.compactAssistantThread(e.configurationId);if(!e.generation.active)return!1;let{messages:i,earlierThreads:s,hasEarlierThread:a}=this._chat.value,r=this._refused?.chat===e?i.slice(0,this._refused.index):i;return e.generation.active=!1,this._current=null,e.client.stop(),e.dispose(),this._chat.next({...c,earlierThreads:[...s,{threadId:t,messages:r}],hasEarlierThread:a,isLoadingEarlierThread:null!==this._loadingThreadId}),this._startClient(),!0}catch(i){let t=i instanceof Error?i:Error(String(i));if(t instanceof r&&409===t.status)return e.generation.active&&this.reloadThread(),!1;return e.generation.active&&this._chat.next({...this._chat.value,isResuming:!1,error:t,failedStatus:t instanceof r?t.status:void 0}),this._context.domainServicesSelectors.getLogger().error("The assistant thread could not be resumed",{},t),!1}};_findTipToolCallId=()=>{let e=this._context.domainContextSelectors.getUndoSystem(),t=e.tip$.value?.committedState;return void 0!==t&&e.canUndo()?this._applyToolCallIds.get(t):void 0};_refreshUndoTip=()=>{let e=this._findTipToolCallId();e!==this._undoTipToolCallId.value&&this._undoTipToolCallId.next(e)};_committedState=()=>this._context.domainContextSelectors.getStoreSystem().stateSlices.committed.value.state;_patchPanel=e=>{let t={...this._panel.value,...e};a(t,this._panel.value)||this._panel.next(t)};_takeOverThread=e=>{for(let t of this._finishing)t.configurationId===e&&(t.client.stop(),t.dispose())};_startClient=()=>{let i={active:!0},s=this._context.getConfigurationId();this._takeOverThread(s);let r=this._context.getAuthorizedClient(),n=()=>{if(i.active){let{manifest:e,error:t}=this._context.getAssistantSetup();if(t)throw t;if(!e)throw Error("The assistant is disabled for this session.")}return r.getAssistantChatConnection(s)},o=e=>{if(!i.active)return;let t={...this._chat.value,...e};a(t,this._chat.value)||this._chat.next(t)},l=async(e,t)=>{let s=await fetch(e,t).finally(()=>o({isLoaded:!0})),a=s.headers.get("x-assistant-thread-continuable");return null!=a&&s.ok&&i.active&&0===this._chat.value.earlierThreads.length&&(this._olderThreadId=s.headers.get("x-assistant-previous-thread")),o({failedStatus:s.ok?void 0:s.status,...null!=a&&{isContinuable:"false"!==a,hasEarlierThread:null!==this._olderThreadId}}),s},h=async()=>({headers:await n().headers(),fetchClient:l}),d=t(()=>n().url,h),c=t(()=>`${n().url}/runs`,h),u=this._tools.map(e=>({...e,execute:(t,s)=>{if(!i.active)return g;let{manifest:a,error:r}=this._context.getAssistantSetup();return r||!a?{error:r?.message??"The assistant is disabled for this session."}:e.execute?.(t,s)}})),_=new e({threadId:`assistant:${s}`,connection:{...d,joinRun:c.joinRun},persistence:!0,history:{pageSize:50},tools:u,onMessagesChange:e=>o({messages:e}),onLoadingChange:e=>{let t=i.active&&this._chat.value.isLoading;o({isLoading:e}),!e&&m(_)&&(i.active?t&&!this._panel.value.open&&this._patchPanel({hasUnreadReply:!0}):p())},onErrorChange:e=>{i.active&&e!==this._chat.value.error&&(!e||-1===this._findRefusedMessageIndex(v))&&(o({error:e}),e&&this._context.domainServicesSelectors.getLogger().error("The assistant request failed",{status:this._chat.value.failedStatus},e))}}),f=!1,p=()=>{f||(f=!0,this._finishing.delete(v),_.dispose())},v={client:_,configurationId:s,generation:i,authorizedClient:r,getConnection:n,dispose:p};this._current=v,_.attach()};_retireChat=()=>{let e=this._current;return this._current=null,e&&(e.generation.active=!1),this._chain={},this._olderThreadId=null,this._resuming=null,this._refused=null,this._loadingThreadId=null,this._chat.value!==c&&this._chat.next(c),e};_endChat=()=>{let e=this._retireChat();if(e){if(!e.client.getIsLoading()&&m(e.client))return void e.dispose();this._finishing.add(e)}}}
@@ -3,8 +3,8 @@ import type { DomainEntity, DomainMode, DomainState } from '#package/domain';
3
3
  import type { GraphQLExecution, GraphQLSystem } from '../graphql-system/graphql-system.js';
4
4
  /**
5
5
  * What the assistant's client tools need from the running configurator, as accessors they call when
6
- * the model calls them: a tool call always runs against the systems and the session mode current at
7
- * that moment, never against ones captured when its reply began streaming.
6
+ * the model calls them: a tool call always runs against the systems, the session mode and the view
7
+ * mode current at that moment, never against ones captured when its reply began streaming.
8
8
  */
9
9
  export interface AssistantToolDependencies {
10
10
  readonly getGraphQLSystem: () => Pick<GraphQLSystem, 'prepare' | 'execute' | 'readSideEffects' | 'readScreenshots'>;
@@ -19,6 +19,11 @@ export interface AssistantToolDependencies {
19
19
  };
20
20
  };
21
21
  readonly getActiveMode: () => DomainMode;
22
+ /**
23
+ * Whether the configuration is read-only for the user now, by the rule the UI follows: the
24
+ * domain-context selector `getIsViewMode`, which `useAccessService().accessInfo.viewMode` returns.
25
+ */
26
+ readonly getIsViewMode: () => boolean;
22
27
  /** Forgets the changes recorded for the next change record, so it never lists what the agent itself changed. */
23
28
  readonly clearChanges: () => void;
24
29
  /**
@@ -109,9 +114,20 @@ export declare const createQueryClientTool: (dependencies: AssistantToolDependen
109
114
  * including why nothing was committed when a commit was held or lost to a conflict. A commit clears
110
115
  * the recorded changes; a held one does not, so it shows in the next change record once the user
111
116
  * approves it. The state it committed or held is remembered under the id of the call, so the chip
112
- * row of the call can undo it. Only an owner
113
- * session may change the configuration; the check lives here and not in the `GraphQLSystem`, whose
114
- * other caller, the editor panel, has its own rules.
117
+ * row of the call can undo it.
118
+ *
119
+ * The assistant changes the configuration exactly when the UI lets the user change it: while the
120
+ * view mode is off, which the host can switch both ways while the configurator runs. A finalize run
121
+ * never changes it. The checks live here and not in the `GraphQLSystem`, whose other caller, the
122
+ * editor panel, has its own rules.
123
+ *
124
+ * Accepted: the view mode is read live, while saving follows the mode captured at initialization
125
+ * (the named exception in `docs/architecture/application-runtime.md`). When the configuration turns
126
+ * editable, because the host cleared `readonly` or the access changed, for example from a
127
+ * read-revision to an owner token, a change applied before the configuration is initialized again
128
+ * is committed and reported to the model as committed, but it is not saved, and that initialization
129
+ * replaces it. The configurator page loads the configuration again on either switch, so the window
130
+ * lasts one load.
115
131
  */
116
132
  export declare const createApplyClientTool: (dependencies: AssistantToolDependencies) => import("@tanstack/ai").ClientTool<{
117
133
  type: string;
@@ -1 +1 @@
1
- import{AssistantGraphQLToolInput as e,applyTool as t,queryTool as o}from"@salsita-ai/contracts/assistant";let s=e=>({results:[],committed:!1,message:e,sideEffects:[],screenshots:new Map});export const toToolResult=({preparedState:e,screenshots:t,...o})=>[{type:"text",content:JSON.stringify(o)},...[...t].flatMap(([e,{data:t,mimeType:o}])=>[{type:"text",content:e},{type:"image",source:{type:"data",value:t,mimeType:o}}])];let a=t=>{let o=e.safeParse(t);if(!o.success){let e=o.error.issues.map(e=>`${e.path.join(".")}: ${e.message}`).join("; ");return{ok:!1,refusal:s(`Nothing was run, because the tool input is not a list of operations (${e}). Send { "operations": [{ "query": "<one GraphQL operation>" }] } with at least one item.`)}}return{ok:!0,operations:o.data.operations.map(({query:e,variables:t,operationName:o})=>({document:e,variables:t??void 0,operationName:o??void 0}))}};export const createQueryClientTool=e=>o.client(async t=>{let o=a(t);if(!o.ok)return toToolResult(o.refusal);let i=e.getStoreSystem();if(!i.isInitialized)return toToolResult(s("Nothing was run, because the configuration is not loaded yet, so there is no state to query. Call the tool again once the configurator has finished loading."));let r=e.getGraphQLSystem(),n=await r.prepare(i.stateSlices.committed.value.state,o.operations);return toToolResult({results:n.map(({result:e})=>e),committed:!1,sideEffects:r.readSideEffects(n),screenshots:r.readScreenshots(n)})});export const createApplyClientTool=e=>t.client(async(t,o)=>{if("owner"!==e.getActiveMode())return toToolResult(s("Nothing was run, because changes cannot be applied in this session: the user may view this configuration but not change it. The query tool still works here, including mutations, to show what a change would do without keeping it."));let i=a(t);if(!i.ok)return toToolResult(i.refusal);let r=await e.getGraphQLSystem().execute(i.operations),n=o?.toolCallId;return void 0!==n&&void 0!==r.preparedState&&e.rememberCommit(n,r.preparedState),r.committed&&e.clearChanges(),toToolResult(r)});
1
+ import{AssistantGraphQLToolInput as e,applyTool as t,queryTool as o}from"@salsita-ai/contracts/assistant";let a=e=>({results:[],committed:!1,message:e,sideEffects:[],screenshots:new Map});export const toToolResult=({preparedState:e,screenshots:t,...o})=>[{type:"text",content:JSON.stringify(o)},...[...t].flatMap(([e,{data:t,mimeType:o}])=>[{type:"text",content:e},{type:"image",source:{type:"data",value:t,mimeType:o}}])];let i=t=>{let o=e.safeParse(t);if(!o.success){let e=o.error.issues.map(e=>`${e.path.join(".")}: ${e.message}`).join("; ");return{ok:!1,refusal:a(`Nothing was run, because the tool input is not a list of operations (${e}). Send { "operations": [{ "query": "<one GraphQL operation>" }] } with at least one item.`)}}return{ok:!0,operations:o.data.operations.map(({query:e,variables:t,operationName:o})=>({document:e,variables:t??void 0,operationName:o??void 0}))}};export const createQueryClientTool=e=>o.client(async t=>{let o=i(t);if(!o.ok)return toToolResult(o.refusal);let s=e.getStoreSystem();if(!s.isInitialized)return toToolResult(a("Nothing was run, because the configuration is not loaded yet, so there is no state to query. Call the tool again once the configurator has finished loading."));let n=e.getGraphQLSystem(),r=await n.prepare(s.stateSlices.committed.value.state,o.operations);return toToolResult({results:r.map(({result:e})=>e),committed:!1,sideEffects:n.readSideEffects(r),screenshots:n.readScreenshots(r)})});export const createApplyClientTool=e=>t.client(async(t,o)=>{if("finalize"===e.getActiveMode())return toToolResult(a("Nothing was run, because changes cannot be applied in this session: the user may view this configuration but not change it. The query tool still works here, including mutations, to show what a change would do without keeping it."));if(e.getIsViewMode())return toToolResult(a("Nothing was run, because the configuration is read-only right now: the user may view it but not change it. The query tool still works here, including mutations, to show what a change would do without keeping it. Call apply again only once the configuration is editable."));let s=i(t);if(!s.ok)return toToolResult(s.refusal);let n=await e.getGraphQLSystem().execute(s.operations),r=o?.toolCallId;return void 0!==r&&void 0!==n.preparedState&&e.rememberCommit(r,n.preparedState),n.committed&&e.clearChanges(),toToolResult(n)});
@@ -1,5 +1,5 @@
1
1
  import { type $DomainEntity, type ConfiguratorBuilder, type CreateCustomPhoenixEntityElement, type CreateCustomPhoenixLayoutElement, type CreateGetThemeHandler, type CreateGetWebComponentOptionsHandler, type CreatePhoenixHandler, type DomainEntity, type IsCreateRecipeUpdate, type IsReplaceRecipeUpdate, type TransformerBuilder, type TransformerFactory, type UpdateFactory, getIdSequence } from '#package/domain';
2
- import { type CreateAddEntityFab, type CreateCollectFrontendDataHandler, type CreateDeleteEntityFab, type CreateFilterPublishedChunksHandler, type CreateNavigationHotspot, type CreateNotAuthenticatedPage, type CreateSelectionHotspot, type CreateToolMenuFab, type IsAngleDimensionUpdate, type IsAttributeSelectionUpdate, type IsAttributeSwitchUpdate, type IsDeleteEntityUpdate, type IsDistanceDimensionUpdate, type IsGenericDimensionUpdate, type IsSwatchSelectionUpdate, type IsTextValueUpdate, type UseAccessService, type UseActiveNavigationState, type UseActiveToolState, type UseActiveViewState, type UseActiveViewports, type UseAnalyticsService, type UseAngleDimension, type UseAttributeSelection, type UseAttributeSwitch, type UseAuthenticatedClient, type UseAuthorizedClient, type UseBackendData, type UseChildEntitySelection, type UseComponent, type UseComponents, type UseComposition, type UseConfigurationId, type UseConfiguratorMessages, type UseControlViolations, type UseCookRecipes, type UseCookReplaceRecipes, type UseCookedRecipes, type UseCookedReplaceRecipes, type UseCreateAuthorizedClient, type UseDeleteEntity, type UseDeletedEntity, type UseDeselect, type UseDistanceDimension, type UseDistanceDimensionSelection, type UseDomainApplicationContext, type UseDomainApplicationProps, type UseDomainContext, type UseDomainEntityState, type UseEntityPrice, type UseEntitySelector, type UseFinalizeAction, type UseFinalizeActions, type UseFinalizeViolations, type UseFirstComponent, type UseFirstRootComponent, type UseFrontendData, type UseGenericDimension, type UseGroupedRecipeOptions, type UseHoveredDomainEntityId, type UseHoveredEntity, type UseHoveredEntityId, type UseIntegrationService, type UseIntegrationState, type UseIsFullscreenActive, type UseLoadedData, type UseLoadingState, type UseLocaleSwitch, type UseMapViolationHints, type UseNavigate, type UsePopNavigate, type UsePresetEmbeddedState, type UsePublishedData, type UsePushNavigate, type UseRecipeEmbeddedState, type UseReplaceEntityRecipeOptions, type UseRootComponents, type UseRootEntityId, type UseRootEntityPrice, type UseRootEntitySelector, type UseRootEntityState, type UseSelectEntity, type UseSelectParent, type UseSelectedDomainEntityId, type UseSelectedEntity, type UseSelectedEntityId, type UseSession, type UseSessionRole, type UseSessionService, type UseSetFullscreen, type UseSetViewState, type UseShareLinks, type UseSlice, type UseState, type UseStateValidity, type UseStepNavigation, type UseSwatchSelection, type UseSynchronizedSelector, type UseSynchronizedSelector$, type UseTabNavigation, type UseTextValue, type UseUndoRedo, type UseUpdateControl, type UseUpdatedControl, useGenerateShareLink, useLoadingStateValue, useLocalizable, useResolveLocalizable } from '#package/react-sdk';
2
+ import { type CreateAddEntityFab, type CreateCollectFrontendDataHandler, type CreateDeleteEntityFab, type CreateFilterPublishedChunksHandler, type CreateNavigationHotspot, type CreateNotAuthenticatedPage, type CreateSelectionHotspot, type CreateToolMenuFab, type IsAngleDimensionUpdate, type IsAttributeSelectionUpdate, type IsAttributeSwitchUpdate, type IsDeleteEntityUpdate, type IsDistanceDimensionUpdate, type IsGenericDimensionUpdate, type IsSwatchSelectionUpdate, type IsTextValueUpdate, type UseAccessService, type UseActiveNavigationState, type UseActiveToolState, type UseActiveViewState, type UseActiveViewports, type UseAnalyticsService, type UseAngleDimension, type UseAttributeSelection, type UseAttributeSwitch, type UseAuthenticatedClient, type UseAuthorizedClient, type UseBackendData, type UseChildEntitySelection, type UseComponent, type UseComponents, type UseComposition, type UseConfigurationId, type UseConfigurationSaveState, type UseConfiguratorMessages, type UseControlViolations, type UseCookRecipes, type UseCookReplaceRecipes, type UseCookedRecipes, type UseCookedReplaceRecipes, type UseCreateAuthorizedClient, type UseDeleteEntity, type UseDeletedEntity, type UseDeselect, type UseDistanceDimension, type UseDistanceDimensionSelection, type UseDomainApplicationContext, type UseDomainApplicationProps, type UseDomainContext, type UseDomainEntityState, type UseEntityPrice, type UseEntitySelector, type UseFinalizeAction, type UseFinalizeActions, type UseFinalizeViolations, type UseFirstComponent, type UseFirstRootComponent, type UseFrontendData, type UseGenericDimension, type UseGroupedRecipeOptions, type UseHoveredDomainEntityId, type UseHoveredEntity, type UseHoveredEntityId, type UseIntegrationService, type UseIntegrationState, type UseIsFullscreenActive, type UseLoadedData, type UseLoadingState, type UseLocaleSwitch, type UseMapViolationHints, type UseNavigate, type UsePopNavigate, type UsePresetEmbeddedState, type UsePublishedData, type UsePushNavigate, type UseRecipeEmbeddedState, type UseReplaceEntityRecipeOptions, type UseRootComponents, type UseRootEntityId, type UseRootEntityPrice, type UseRootEntitySelector, type UseRootEntityState, type UseSelectEntity, type UseSelectParent, type UseSelectedDomainEntityId, type UseSelectedEntity, type UseSelectedEntityId, type UseSession, type UseSessionRole, type UseSessionService, type UseSetFullscreen, type UseSetViewState, type UseShareLinks, type UseSlice, type UseState, type UseStateValidity, type UseStepNavigation, type UseSwatchSelection, type UseSynchronizedSelector, type UseSynchronizedSelector$, type UseTabNavigation, type UseTextValue, type UseUndoRedo, type UseUpdateControl, type UseUpdatedControl, useGenerateShareLink, useLoadingStateValue, useLocalizable, useResolveLocalizable } from '#package/react-sdk';
3
3
  import { type CreatePhoenixIconSet } from '#package/ui-sdk';
4
4
  import { type UseConfiguratorExtensions } from '../application-runtime/index.js';
5
5
  import { type CreateConfigurationNotFoundPage } from '../configuration-not-found-page/index.js';
@@ -387,6 +387,11 @@ export interface ConfiguratorInterface<ENTITIES extends DomainEntity<string>, AL
387
387
  * text resolved
388
388
  */
389
389
  useConfiguratorMessages: UseConfiguratorMessages<ENTITIES, $MAP>;
390
+ /**
391
+ * The save status of the configuration: `{ revisionId, isSaving, failure }`, where `failure` is the latest save's
392
+ * `{ error, timestamp }` until a later save succeeds
393
+ */
394
+ useConfigurationSaveState: UseConfigurationSaveState;
390
395
  /**
391
396
  * Runs the project handler a `finalizeAction` component names, with its pending state, its error and the
392
397
  * finalize violations; call it once per component, wrapped in `PhoenixHandlerBoundary`
@@ -1 +1 @@
1
- import{createCustomPhoenixEntityElement as e,createCustomPhoenixLayoutElement as o,createGetThemeHandler as r,createGetWebComponentOptionsHandler as t,createPhoenixHandler as i,createTransformer as n,createTransformerBuilder as s,createUpdateFactory as a,getIdSequence as m,isCreateEntityUpdate as p,isReplaceEntityUpdate as d}from"#package/domain";import{createAddEntityFab as f,createCollectFrontendDataHandler as u,createDeleteEntityFab as c,createFilterPublishedChunksHandler as g,createNavigationHotspot as l,createNotAuthenticatedPage as j,createSelectionHotspot as x,createToolMenuFab as k,isAngleDimensionUpdate as y,isAttributeSelectionUpdate as I,isAttributeSwitchUpdate as A,isDeleteEntityUpdate as C,isDistanceDimensionUpdate as S,isGenericDimensionUpdate as w,isSwatchSelectionUpdate as E,isTextValueUpdate as b,useAccessService as q,useActiveNavigationState as B,useActiveToolState as P,useActiveViewState as R,useActiveViewports as U,useAnalyticsService as h,useAngleDimension as v,useAttributeSelection as z,useAttributeSwitch as D,useAuthenticatedClient as F,useAuthorizedClient as G,useBackendData as H,useChildEntitySelection as J,useCommittedSlice as K,useCommittedState as L,useComponent as M,useComponents as N,useComposition as O,useConfigurationId as Q,useConfiguratorMessages as T,useControlViolations as V,useCookRecipes as W,useCookReplaceRecipes as X,useCookedRecipes as Y,useCookedReplaceRecipes as Z,useCreateAuthorizedClient as $,useDeleteEntity as _,useDeletedEntity as ee,useDeselect as eo,useDistanceDimension as er,useDistanceDimensionSelection as et,useDomain as ei,useDomainApplication as en,useDomainApplicationProps as es,useDomainEntityRenderedState as ea,useDomainEntityState as em,useEntityPrice as ep,useEntitySelector as ed,useFinalizeAction as ef,useFinalizeActions as eu,useFinalizeViolations as ec,useFirstComponent as eg,useFirstRenderedComponent as el,useFirstRootComponent as ej,useFirstRootRenderedComponent as ex,useFrontendData as ek,useGenerateShareLink as ey,useGenericDimension as eI,useGroupedRecipeOptions as eA,useHoveredDomainEntityId as eC,useHoveredEntity as eS,useHoveredEntityId as ew,useIntegrationService as eE,useIntegrationState as eb,useIsFullscreenActive as eq,useLoadedData as eB,useLoadingState as eP,useLoadingStateValue as eR,useLocaleSwitch as eU,useLocalizable as eh,useMapViolationHints as ev,useNavigate as ez,usePopNavigate as eD,usePresetEmbeddedState as eF,usePublishedData as eG,usePushNavigate as eH,useRecipeEmbeddedState as eJ,useRenderedComponent as eK,useRenderedComponents as eL,useRenderedEntitySelector as eM,useRenderedRootEntitySelector as eN,useRenderedSelector as eO,useRenderedSelector$ as eQ,useRenderedSlice as eT,useRenderedState as eV,useReplaceEntityRecipeOptions as eW,useResolveLocalizable as eX,useRootComponents as eY,useRootEntityId as eZ,useRootEntityPrice as e$,useRootEntityRenderedId as e_,useRootEntityRenderedState as e0,useRootEntitySelector as e1,useRootEntityState as e2,useRootRenderedComponents as e3,useSelectEntity as e4,useSelectParent as e5,useSelectedDomainEntityId as e6,useSelectedEntity as e7,useSelectedEntityId as e8,useSession as e9,useSessionRole as oe,useSessionService as oo,useSetFullscreen as or,useSetViewState as ot,useShareLinks as oi,useStateValidity as on,useStepNavigation as os,useStoreSelector as oa,useStoreSelector$ as om,useSwatchSelection as op,useTabNavigation as od,useTextValue as of,useUndoRedo as ou,useUpdateControl as oc,useUpdatedControl as og}from"#package/react-sdk";import{createPhoenixIconSet as ol}from"#package/ui-sdk";import{useConfigurator as oj}from"../application-runtime/index.js";import{createConfigurationNotFoundPage as ox}from"../configuration-not-found-page/index.js";import{createOnApplicationStartProvider as ok,createOnBackendDataReadyProvider as oy,createOnConfiguratorReadyProvider as oI,createOnFrontendDataReadyProvider as oA,createOnGoToIndexHandler as oC,createOnPresetLoadedHandler as oS,createOnPublishedDataReadyProvider as ow,createOnRoutingReadyProvider as oE,createOnSessionReadyProvider as ob,useConfiguratorRouting as oq,usePresetSelection as oB,usePreview as oP,usePropertyPageStack as oR,usePropertyPageState as oU}from"../configurator-context/index.js";import{createConfiguratorErrorPage as oh}from"../configurator-error-page/index.js";import{useCloseAction as ov}from"../integration/index.js";import{createGetTextureProcessingMapHandler as oz}from"../scene/index.js";import{useUpdateEntityObjectSelection as oD}from"../scene/scene-entity/drag-and-drop/use-updated-selection.js";import{useAssistantPanel as oF,useMeasurements as oG,useToolbarActions as oH}from"../toolbar-actions/index.js";import{LayoutSlots as oJ,createAppLoader as oK,createCanvasLoader as oL,createLayoutAdminUi as oM,createLayoutCustomOwnerUi as oN,createLayoutCustomReadUi as oO,createLayoutDialog as oQ,createLayoutFooter as oT,createLayoutToolbarDesktop as oV,createLayoutToolbarDesktopFullScreen as oW,createLayoutToolbarReadDesktop as oX,createLayoutToolbarReadDesktopFullScreen as oY,createLayoutUserUi as oZ,createToolbarHelp as o$,useSceneSafeArea as o_}from"../ui/index.js";import{createPresetDeviceNotSupported as o0,createPresetPageAction as o1,createPresetUi as o2}from"../ui/preset-layout/PresetUi.js";import{useResetCamera as o3}from"./use-reset-camera.js";export const createConfiguratorInterface=o4=>({updates:a(),getIdSequence:m,createGetWebComponentOptionsHandler:t,createGetThemeHandler:r,createPhoenixHandler:i,createCustomPhoenixEntityElement:e,createCustomPhoenixLayoutElement:o,createPhoenixIconSet:ol,createGetTextureProcessingMapHandler:oz,createCollectFrontendDataHandler:u,createFilterPublishedChunksHandler:g,createOnGoToIndexHandler:oC,createOnApplicationStartProvider:ok,createOnSessionReadyProvider:ob,createOnPublishedDataReadyProvider:ow,createOnFrontendDataReadyProvider:oA,createOnBackendDataReadyProvider:oy,createOnRoutingReadyProvider:oE,createOnConfiguratorReadyProvider:oI,createOnPresetLoadedHandler:oS,createPresetUi:o2,createPresetPageAction:o1,createPresetDeviceNotSupported:o0,createLayoutFooter:oT,createAppLoader:oK,createCanvasLoader:oL,createLayoutDialog:oQ,createLayoutToolbarDesktop:oV,createLayoutToolbarDesktopFullScreen:oW,createLayoutToolbarReadDesktop:oX,createLayoutToolbarReadDesktopFullScreen:oY,createLayoutCustomOwnerUi:oN,createLayoutCustomReadUi:oO,createLayoutAdminUi:oM,createLayoutUserUi:oZ,createToolbarHelp:o$,createNotAuthenticatedPage:j,createConfigurationNotFoundPage:ox,createConfiguratorErrorPage:oh,createAddEntityFab:f,createDeleteEntityFab:c,createSelectionHotspot:x,createNavigationHotspot:l,createToolMenuFab:k,createTransformer:n,transformerBuilder:s(),useAnalytics:h,useAuthenticatedClient:F,useAuthorizedClient:G,useCreateAuthorizedClient:$,useAccessService:q,useConfigurationId:Q,useSession:e9,useSessionRole:oe,useSessionService:oo,useDomain:ei,useDomainApplication:en,useConfigurator:oj,useConfiguratorRouting:oq,usePresetSelection:oB,usePublishedData:eG,useFrontendData:ek,useBackendData:H,useDomainApplicationProps:es,useLoadedData:eB,useIntegrationService:eE,useIntegrationState:eb,usePresetEmbeddedState:eF,useRecipeEmbeddedState:eJ,useCommittedSlice:K,useRenderedSlice:eT,useCommittedState:L,useRenderedState:eV,useStoreSelector:oa,useRenderedSelector:eO,useStoreSelector$:om,useRenderedSelector$:eQ,useEntitySelector:ed,useRenderedEntitySelector:eM,useRootEntitySelector:e1,useRenderedRootEntitySelector:eN,useStateValidity:on,useMapViolationHints:ev,useNavigate:ez,usePopNavigate:eD,usePushNavigate:eH,useControlViolations:V,useFinalizeViolations:ec,useConfiguratorMessages:T,useFinalizeAction:ef,useFinalizeActions:eu,useComponent:M,useRenderedComponent:eK,useComponents:N,useRenderedComponents:eL,useFirstComponent:eg,useFirstRenderedComponent:el,useRootComponents:eY,useRootRenderedComponents:e3,useFirstRootComponent:ej,useFirstRootRenderedComponent:ex,useEntityState:em,useEntityRenderedState:ea,useRootEntityState:e2,useRootEntityRenderedState:e0,useRootEntityId:eZ,useRootEntityRenderedId:e_,useEntityPrice:ep,useRootEntityPrice:e$,useSelectedEntity:e7,useSelectedEntityId:e8,useSelectedDomainEntityId:e6,useSelectEntity:e4,useDeselect:eo,useSelectParent:e5,useHoveredEntity:eS,useHoveredEntityId:ew,useHoveredDomainEntityId:eC,useActiveNavigationState:B,useActiveViewState:R,useSetViewState:ot,useActiveToolState:P,useIsFullscreenActive:eq,useSetFullscreen:or,useResetCamera:o3,useUndoRedo:ou,useTabNavigation:od,useStepNavigation:os,useSceneSafeArea:o_,useActiveViewports:U,usePreview:oP,useCloseAction:ov,useIsCloningAllowed:oJ.useIsCloningAllowed,useResolveLocalizable:eX,useLocalizable:eh,useToolbarActions:oH,useMeasurements:oG,useLocaleSwitch:eU,useShareLinks:oi,useAssistantPanel:oF,useComposition:O,useUpdateControl:oc,useUpdatedControl:og,useCookRecipes:W,useCookedRecipes:Y,useCookReplaceRecipes:X,useCookedReplaceRecipes:Z,useDeleteEntity:_,useDeletedEntity:ee,useSwatchSelection:op,useTextValue:of,useAttributeSelection:z,useAttributeSwitch:D,useDistanceDimension:er,useDistanceDimensionSelection:et,useGenericDimension:eI,useAngleDimension:v,useChildEntitySelection:J,useGroupedRecipeOptions:eA,useReplaceEntityRecipeOptions:eW,useUpdateEntityObjectSelection:oD,useGenerateShareLink:ey,useLoadingState:eP,useLoadingStateValue:eR,usePropertyPageStack:oR,usePropertyPageState:oU,isCreateEntityUpdate:p,isReplaceEntityUpdate:d,isDeleteEntityUpdate:C,isAngleDimensionUpdate:y,isDistanceDimensionUpdate:S,isGenericDimensionUpdate:w,isAttributeSelectionUpdate:I,isAttributeSwitchUpdate:A,isTextValueUpdate:b,isSwatchSelectionUpdate:E});
1
+ import{createCustomPhoenixEntityElement as e,createCustomPhoenixLayoutElement as o,createGetThemeHandler as r,createGetWebComponentOptionsHandler as t,createPhoenixHandler as i,createTransformer as n,createTransformerBuilder as s,createUpdateFactory as a,getIdSequence as m,isCreateEntityUpdate as p,isReplaceEntityUpdate as d}from"#package/domain";import{createAddEntityFab as f,createCollectFrontendDataHandler as u,createDeleteEntityFab as c,createFilterPublishedChunksHandler as g,createNavigationHotspot as l,createNotAuthenticatedPage as j,createSelectionHotspot as x,createToolMenuFab as k,isAngleDimensionUpdate as y,isAttributeSelectionUpdate as I,isAttributeSwitchUpdate as A,isDeleteEntityUpdate as C,isDistanceDimensionUpdate as S,isGenericDimensionUpdate as w,isSwatchSelectionUpdate as E,isTextValueUpdate as b,useAccessService as q,useActiveNavigationState as B,useActiveToolState as P,useActiveViewState as R,useActiveViewports as U,useAnalyticsService as h,useAngleDimension as v,useAttributeSelection as z,useAttributeSwitch as D,useAuthenticatedClient as F,useAuthorizedClient as G,useBackendData as H,useChildEntitySelection as J,useCommittedSlice as K,useCommittedState as L,useComponent as M,useComponents as N,useComposition as O,useConfigurationId as Q,useConfigurationSaveState as T,useConfiguratorMessages as V,useControlViolations as W,useCookRecipes as X,useCookReplaceRecipes as Y,useCookedRecipes as Z,useCookedReplaceRecipes as $,useCreateAuthorizedClient as _,useDeleteEntity as ee,useDeletedEntity as eo,useDeselect as er,useDistanceDimension as et,useDistanceDimensionSelection as ei,useDomain as en,useDomainApplication as es,useDomainApplicationProps as ea,useDomainEntityRenderedState as em,useDomainEntityState as ep,useEntityPrice as ed,useEntitySelector as ef,useFinalizeAction as eu,useFinalizeActions as ec,useFinalizeViolations as eg,useFirstComponent as el,useFirstRenderedComponent as ej,useFirstRootComponent as ex,useFirstRootRenderedComponent as ek,useFrontendData as ey,useGenerateShareLink as eI,useGenericDimension as eA,useGroupedRecipeOptions as eC,useHoveredDomainEntityId as eS,useHoveredEntity as ew,useHoveredEntityId as eE,useIntegrationService as eb,useIntegrationState as eq,useIsFullscreenActive as eB,useLoadedData as eP,useLoadingState as eR,useLoadingStateValue as eU,useLocaleSwitch as eh,useLocalizable as ev,useMapViolationHints as ez,useNavigate as eD,usePopNavigate as eF,usePresetEmbeddedState as eG,usePublishedData as eH,usePushNavigate as eJ,useRecipeEmbeddedState as eK,useRenderedComponent as eL,useRenderedComponents as eM,useRenderedEntitySelector as eN,useRenderedRootEntitySelector as eO,useRenderedSelector as eQ,useRenderedSelector$ as eT,useRenderedSlice as eV,useRenderedState as eW,useReplaceEntityRecipeOptions as eX,useResolveLocalizable as eY,useRootComponents as eZ,useRootEntityId as e$,useRootEntityPrice as e_,useRootEntityRenderedId as e0,useRootEntityRenderedState as e1,useRootEntitySelector as e2,useRootEntityState as e3,useRootRenderedComponents as e4,useSelectEntity as e5,useSelectParent as e6,useSelectedDomainEntityId as e7,useSelectedEntity as e8,useSelectedEntityId as e9,useSession as oe,useSessionRole as oo,useSessionService as or,useSetFullscreen as ot,useSetViewState as oi,useShareLinks as on,useStateValidity as os,useStepNavigation as oa,useStoreSelector as om,useStoreSelector$ as op,useSwatchSelection as od,useTabNavigation as of,useTextValue as ou,useUndoRedo as oc,useUpdateControl as og,useUpdatedControl as ol}from"#package/react-sdk";import{createPhoenixIconSet as oj}from"#package/ui-sdk";import{useConfigurator as ox}from"../application-runtime/index.js";import{createConfigurationNotFoundPage as ok}from"../configuration-not-found-page/index.js";import{createOnApplicationStartProvider as oy,createOnBackendDataReadyProvider as oI,createOnConfiguratorReadyProvider as oA,createOnFrontendDataReadyProvider as oC,createOnGoToIndexHandler as oS,createOnPresetLoadedHandler as ow,createOnPublishedDataReadyProvider as oE,createOnRoutingReadyProvider as ob,createOnSessionReadyProvider as oq,useConfiguratorRouting as oB,usePresetSelection as oP,usePreview as oR,usePropertyPageStack as oU,usePropertyPageState as oh}from"../configurator-context/index.js";import{createConfiguratorErrorPage as ov}from"../configurator-error-page/index.js";import{useCloseAction as oz}from"../integration/index.js";import{createGetTextureProcessingMapHandler as oD}from"../scene/index.js";import{useUpdateEntityObjectSelection as oF}from"../scene/scene-entity/drag-and-drop/use-updated-selection.js";import{useAssistantPanel as oG,useMeasurements as oH,useToolbarActions as oJ}from"../toolbar-actions/index.js";import{LayoutSlots as oK,createAppLoader as oL,createCanvasLoader as oM,createLayoutAdminUi as oN,createLayoutCustomOwnerUi as oO,createLayoutCustomReadUi as oQ,createLayoutDialog as oT,createLayoutFooter as oV,createLayoutToolbarDesktop as oW,createLayoutToolbarDesktopFullScreen as oX,createLayoutToolbarReadDesktop as oY,createLayoutToolbarReadDesktopFullScreen as oZ,createLayoutUserUi as o$,createToolbarHelp as o_,useSceneSafeArea as o0}from"../ui/index.js";import{createPresetDeviceNotSupported as o1,createPresetPageAction as o2,createPresetUi as o3}from"../ui/preset-layout/PresetUi.js";import{useResetCamera as o4}from"./use-reset-camera.js";export const createConfiguratorInterface=o5=>({updates:a(),getIdSequence:m,createGetWebComponentOptionsHandler:t,createGetThemeHandler:r,createPhoenixHandler:i,createCustomPhoenixEntityElement:e,createCustomPhoenixLayoutElement:o,createPhoenixIconSet:oj,createGetTextureProcessingMapHandler:oD,createCollectFrontendDataHandler:u,createFilterPublishedChunksHandler:g,createOnGoToIndexHandler:oS,createOnApplicationStartProvider:oy,createOnSessionReadyProvider:oq,createOnPublishedDataReadyProvider:oE,createOnFrontendDataReadyProvider:oC,createOnBackendDataReadyProvider:oI,createOnRoutingReadyProvider:ob,createOnConfiguratorReadyProvider:oA,createOnPresetLoadedHandler:ow,createPresetUi:o3,createPresetPageAction:o2,createPresetDeviceNotSupported:o1,createLayoutFooter:oV,createAppLoader:oL,createCanvasLoader:oM,createLayoutDialog:oT,createLayoutToolbarDesktop:oW,createLayoutToolbarDesktopFullScreen:oX,createLayoutToolbarReadDesktop:oY,createLayoutToolbarReadDesktopFullScreen:oZ,createLayoutCustomOwnerUi:oO,createLayoutCustomReadUi:oQ,createLayoutAdminUi:oN,createLayoutUserUi:o$,createToolbarHelp:o_,createNotAuthenticatedPage:j,createConfigurationNotFoundPage:ok,createConfiguratorErrorPage:ov,createAddEntityFab:f,createDeleteEntityFab:c,createSelectionHotspot:x,createNavigationHotspot:l,createToolMenuFab:k,createTransformer:n,transformerBuilder:s(),useAnalytics:h,useAuthenticatedClient:F,useAuthorizedClient:G,useCreateAuthorizedClient:_,useAccessService:q,useConfigurationId:Q,useSession:oe,useSessionRole:oo,useSessionService:or,useDomain:en,useDomainApplication:es,useConfigurator:ox,useConfiguratorRouting:oB,usePresetSelection:oP,usePublishedData:eH,useFrontendData:ey,useBackendData:H,useDomainApplicationProps:ea,useLoadedData:eP,useIntegrationService:eb,useIntegrationState:eq,usePresetEmbeddedState:eG,useRecipeEmbeddedState:eK,useCommittedSlice:K,useRenderedSlice:eV,useCommittedState:L,useRenderedState:eW,useStoreSelector:om,useRenderedSelector:eQ,useStoreSelector$:op,useRenderedSelector$:eT,useEntitySelector:ef,useRenderedEntitySelector:eN,useRootEntitySelector:e2,useRenderedRootEntitySelector:eO,useStateValidity:os,useMapViolationHints:ez,useNavigate:eD,usePopNavigate:eF,usePushNavigate:eJ,useControlViolations:W,useFinalizeViolations:eg,useConfiguratorMessages:V,useConfigurationSaveState:T,useFinalizeAction:eu,useFinalizeActions:ec,useComponent:M,useRenderedComponent:eL,useComponents:N,useRenderedComponents:eM,useFirstComponent:el,useFirstRenderedComponent:ej,useRootComponents:eZ,useRootRenderedComponents:e4,useFirstRootComponent:ex,useFirstRootRenderedComponent:ek,useEntityState:ep,useEntityRenderedState:em,useRootEntityState:e3,useRootEntityRenderedState:e1,useRootEntityId:e$,useRootEntityRenderedId:e0,useEntityPrice:ed,useRootEntityPrice:e_,useSelectedEntity:e8,useSelectedEntityId:e9,useSelectedDomainEntityId:e7,useSelectEntity:e5,useDeselect:er,useSelectParent:e6,useHoveredEntity:ew,useHoveredEntityId:eE,useHoveredDomainEntityId:eS,useActiveNavigationState:B,useActiveViewState:R,useSetViewState:oi,useActiveToolState:P,useIsFullscreenActive:eB,useSetFullscreen:ot,useResetCamera:o4,useUndoRedo:oc,useTabNavigation:of,useStepNavigation:oa,useSceneSafeArea:o0,useActiveViewports:U,usePreview:oR,useCloseAction:oz,useIsCloningAllowed:oK.useIsCloningAllowed,useResolveLocalizable:eY,useLocalizable:ev,useToolbarActions:oJ,useMeasurements:oH,useLocaleSwitch:eh,useShareLinks:on,useAssistantPanel:oG,useComposition:O,useUpdateControl:og,useUpdatedControl:ol,useCookRecipes:X,useCookedRecipes:Z,useCookReplaceRecipes:Y,useCookedReplaceRecipes:$,useDeleteEntity:ee,useDeletedEntity:eo,useSwatchSelection:od,useTextValue:ou,useAttributeSelection:z,useAttributeSwitch:D,useDistanceDimension:et,useDistanceDimensionSelection:ei,useGenericDimension:eA,useAngleDimension:v,useChildEntitySelection:J,useGroupedRecipeOptions:eC,useReplaceEntityRecipeOptions:eX,useUpdateEntityObjectSelection:oF,useGenerateShareLink:eI,useLoadingState:eR,useLoadingStateValue:eU,usePropertyPageStack:oU,usePropertyPageState:oh,isCreateEntityUpdate:p,isReplaceEntityUpdate:d,isDeleteEntityUpdate:C,isAngleDimensionUpdate:y,isDistanceDimensionUpdate:S,isGenericDimensionUpdate:w,isAttributeSelectionUpdate:I,isAttributeSwitchUpdate:A,isTextValueUpdate:b,isSwatchSelectionUpdate:E});
@@ -4,9 +4,9 @@ interface ConfiguratorResponsiveProviderProps {
4
4
  readonly containerZIndex: number;
5
5
  }
6
6
  /**
7
- * Gives the configurator its responsive state for as long as it is mounted, and renders the root
8
- * container that measures itself into that state. The lifecycle reads the state from the runtime
9
- * provider, the UI through `useResponsive()`.
7
+ * Renders the configurator's root container, which measures itself into the application runtime's
8
+ * responsive state. The lifecycle reads that state from the runtime, the UI through
9
+ * `useResponsive()`. The state belongs to this mount: it is reset when the container unmounts.
10
10
  */
11
11
  export declare const ConfiguratorResponsiveProvider: (props: ConfiguratorResponsiveProviderProps) => import("react/jsx-runtime").JSX.Element;
12
12
  export {};
@@ -1 +1 @@
1
- import{jsx as r}from"react/jsx-runtime";import{useState as e}from"react";import{ResponsiveStateManager as o,ResponsiveStateProvider as t}from"#package/react-sdk";import{ResponsiveApplicationProvider as a}from"#package/ui-sdk";export const ConfiguratorResponsiveProvider=i=>{let{children:n,containerZIndex:m}=i,[c]=e(()=>new o);return r(t,{manager:c,children:r(a,{containerZIndex:m,store:c,children:n})})};
1
+ import{jsx as r}from"react/jsx-runtime";import{useLayoutEffect as e}from"react";import{useResponsiveActions as o,useResponsiveStore as t}from"#package/react-sdk";import{ResponsiveApplicationProvider as i}from"#package/ui-sdk";export const ConfiguratorResponsiveProvider=a=>{let{children:m,containerZIndex:n}=a,s=t(),{reset:c}=o();return e(()=>()=>{c()},[c]),r(i,{containerZIndex:n,store:s,children:m})};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{createContext as r,useCallback as t,useContext as o,useEffect as i,useMemo as a,useState as n}from"react";import{match as s}from"ts-pattern";import{standardWebComponentProperties as d}from"#package/domain";import{useResponsiveState as m,useResponsiveStateManager as p,useWebComponentPropertyState as u,useWebComponentPropertyValue as w}from"#package/react-sdk";let h=r(null);export const PreviewContextProvider=r=>{let{children:o,preview:v,alwaysExpand:c}=r,[f,x]=n(!0),[l,P]=u(d.expanded),g=w(d.mode),k=w(d.power),{isMobile:C}=m(),{expand:b,collapse:j,show:y,hide:E}=p(),q=t(()=>{x(!1),(c||C)&&P(!0)},[C,c,P]),z=t(()=>{x(!0),P(!1)},[P]),A=a(()=>!!l||"configurator"===g&&s(v).with("hide",()=>!1).with("never",()=>!1).with("always",()=>!0).with("auto",()=>C).exhaustive(),[v,l,C,g]),B=!l&&A&&f,D="hide"===v&&!l&&"configurator"===g,F=a(()=>({isPreview:B,isExpanded:l,enter:q,leave:z,isPreviewEnabled:A,isHidden:D}),[B,l,q,z,A,D]),G=s(k).with("on",()=>!0).with("standby","off",()=>!1).exhaustive();return i(()=>{l&&G?b():j()},[l,b,j,G]),i(()=>{D?E():y()},[D,E,y]),e(h.Provider,{value:F,children:o})};export const usePreview=()=>{let e=o(h);if(!e)throw Error("Context was not provided - usePreview must be used inside PreviewContext provider");return e};
1
+ import{jsx as e}from"react/jsx-runtime";import{createContext as r,useCallback as t,useContext as o,useEffect as i,useMemo as a,useState as n}from"react";import{match as s}from"ts-pattern";import{standardWebComponentProperties as d}from"#package/domain";import{useResponsiveActions as m,useResponsiveState as p,useWebComponentPropertyState as u,useWebComponentPropertyValue as w}from"#package/react-sdk";let h=r(null);export const PreviewContextProvider=r=>{let{children:o,preview:v,alwaysExpand:c}=r,[f,x]=n(!0),[l,P]=u(d.expanded),g=w(d.mode),k=w(d.power),{isMobile:C}=p(),{expand:b,collapse:j,show:y,hide:E}=m(),q=t(()=>{x(!1),(c||C)&&P(!0)},[C,c,P]),z=t(()=>{x(!0),P(!1)},[P]),A=a(()=>!!l||"configurator"===g&&s(v).with("hide",()=>!1).with("never",()=>!1).with("always",()=>!0).with("auto",()=>C).exhaustive(),[v,l,C,g]),B=!l&&A&&f,D="hide"===v&&!l&&"configurator"===g,F=a(()=>({isPreview:B,isExpanded:l,enter:q,leave:z,isPreviewEnabled:A,isHidden:D}),[B,l,q,z,A,D]),G=s(k).with("on",()=>!0).with("standby","off",()=>!1).exhaustive();return i(()=>{l&&G?b():j()},[l,b,j,G]),i(()=>{D?E():y()},[D,E,y]),e(h.Provider,{value:F,children:o})};export const usePreview=()=>{let e=o(h);if(!e)throw Error("Context was not provided - usePreview must be used inside PreviewContext provider");return e};
@@ -1 +1 @@
1
- import{useCallback as t,useEffect as e,useRef as r}from"react";import{canvasPaddingComponent as n}from"#package/domain";import{useFirstComponent as o,useResponsiveStateManager as a}from"#package/react-sdk";export const useLayoutSceneSafeArea=c=>{let{enabled:u,hasMiniSidebar:i}=c,{setCanvasPadding:l}=a(),m=r(null),s=r(null),f=r(null),h=r(null),g=r(0),p=r(()=>{}),b=o({componentTypes:[n]}),d=t(()=>{let t=s.current,e=f.current;if(!u||!t||!e)return;let r=t.getBoundingClientRect(),n=e.getBoundingClientRect();if(Math.abs(r.width-t.offsetWidth)>1||Math.abs(r.height-t.offsetHeight)>1){if(g.current+=1,g.current>60){g.current=0;return}m.current&&cancelAnimationFrame(m.current),m.current=requestAnimationFrame(()=>p.current());return}g.current=0;let o={bottom:Math.max(0,r.bottom-n.bottom),left:Math.max(0,n.left-r.left),right:Math.max(0,r.right-n.right),top:Math.max(0,n.top-r.top)},a=i?.3:1,c=b?.state.bottom??1,h=b?.state.left??1,d=b?.state.right??a,A=b?.state.top??1;l({bottom:o.bottom*c,left:o.left*h,right:o.right*d,top:o.top*A})},[u,i,b?.state.bottom,b?.state.left,b?.state.right,b?.state.top,l]);p.current=d;let A=t(()=>{m.current&&cancelAnimationFrame(m.current),m.current=requestAnimationFrame(d)},[d]),M=t(()=>{h.current?.disconnect(),h.current=null},[]),x=t(()=>{let t=s.current,e=f.current;if(!u||!t||!e)return void M();M();let r=new ResizeObserver(A);r.observe(t),r.observe(e),h.current=r},[M,u,A]),F=t(t=>{s.current=t,x()},[x]),v=t(t=>{f.current=t,x()},[x]);return e(()=>(x(),()=>{M(),m.current&&cancelAnimationFrame(m.current)}),[x,M]),{containerRef:F,safeAreaRef:v,update:A}};
1
+ import{useCallback as t,useEffect as e,useRef as r}from"react";import{canvasPaddingComponent as n}from"#package/domain";import{useFirstComponent as o,useResponsiveActions as a}from"#package/react-sdk";export const useLayoutSceneSafeArea=c=>{let{enabled:u,hasMiniSidebar:i}=c,{setCanvasPadding:l}=a(),m=r(null),s=r(null),f=r(null),h=r(null),g=r(0),p=r(()=>{}),b=o({componentTypes:[n]}),d=t(()=>{let t=s.current,e=f.current;if(!u||!t||!e)return;let r=t.getBoundingClientRect(),n=e.getBoundingClientRect();if(Math.abs(r.width-t.offsetWidth)>1||Math.abs(r.height-t.offsetHeight)>1){if(g.current+=1,g.current>60){g.current=0;return}m.current&&cancelAnimationFrame(m.current),m.current=requestAnimationFrame(()=>p.current());return}g.current=0;let o={bottom:Math.max(0,r.bottom-n.bottom),left:Math.max(0,n.left-r.left),right:Math.max(0,r.right-n.right),top:Math.max(0,n.top-r.top)},a=i?.3:1,c=b?.state.bottom??1,h=b?.state.left??1,d=b?.state.right??a,A=b?.state.top??1;l({bottom:o.bottom*c,left:o.left*h,right:o.right*d,top:o.top*A})},[u,i,b?.state.bottom,b?.state.left,b?.state.right,b?.state.top,l]);p.current=d;let A=t(()=>{m.current&&cancelAnimationFrame(m.current),m.current=requestAnimationFrame(d)},[d]),M=t(()=>{h.current?.disconnect(),h.current=null},[]),x=t(()=>{let t=s.current,e=f.current;if(!u||!t||!e)return void M();M();let r=new ResizeObserver(A);r.observe(t),r.observe(e),h.current=r},[M,u,A]),F=t(t=>{s.current=t,x()},[x]),v=t(t=>{f.current=t,x()},[x]);return e(()=>(x(),()=>{M(),m.current&&cancelAnimationFrame(m.current)}),[x,M]),{containerRef:F,safeAreaRef:v,update:A}};
@@ -1 +1 @@
1
- import{jsx as r}from"react/jsx-runtime";import{Trans as e}from"@lingui/react";import{Button as s}from"@mui/material";import{useSnackbar as i}from"notistack";import{useEffect as t}from"react";import{useApplicationRuntime as o,useApplicationRuntimeSelector as a,useConfiguratorMessages as n}from"#package/react-sdk";let m="phx-configuration-persist-system-failure";export const SaveMessageSnackbars=()=>{let c=a(o().selectors.domainContext.configurator.getInitializationState).isViewMode,{enqueueSnackbar:d,closeSnackbar:p}=i();return t(()=>{c&&p(m)},[c,p]),n(i=>{c||("saveError"===i.kind&&d(r(e,{id:"sdk.persist.system.error.message",message:"An error occured when trying to update a configuration"}),{variant:"error",key:m,persist:!0,preventDuplicate:!0,action:i=>r(s,{color:"inherit",size:"small",onClick:()=>{p(i)},children:r(e,{id:"sdk.persist.system.error.dismiss",message:"Dismiss"})})}),"saveRecovery"===i.kind&&(p(m),d(r(e,{id:"sdk.persist.system.error.recovered",message:"Configuration updated"}),{variant:"info"})))}),null};
1
+ import{jsx as r}from"react/jsx-runtime";import{Trans as e}from"@lingui/react";import{Button as s}from"@mui/material";import{useSnackbar as i}from"notistack";import{useEffect as t}from"react";import{useApplicationRuntime as o,useApplicationRuntimeSelector as a,useConfiguratorMessages as n}from"#package/react-sdk";let m="phx-configuration-persist-system-failure";export const SaveMessageSnackbars=()=>{let c=a(o().selectors.domainContext.configurator.getIsViewMode),{enqueueSnackbar:d,closeSnackbar:p}=i();return t(()=>{c&&p(m)},[c,p]),n(i=>{c||("saveError"===i.kind&&d(r(e,{id:"sdk.persist.system.error.message",message:"An error occured when trying to update a configuration"}),{variant:"error",key:m,persist:!0,preventDuplicate:!0,action:i=>r(s,{color:"inherit",size:"small",onClick:()=>{p(i)},children:r(e,{id:"sdk.persist.system.error.dismiss",message:"Dismiss"})})}),"saveRecovery"===i.kind&&(p(m),d(r(e,{id:"sdk.persist.system.error.recovered",message:"Configuration updated"}),{variant:"info"})))}),null};