@salsita-ai/sdk 0.50.0-develop.da8d27f5d7 → 0.50.0-develop.dbf0122072
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.
- package/README.md +19 -11
- package/dist/{phoenix/application-spec → application-spec/assistant}/generate-assistant-prompt.d.ts +6 -5
- package/dist/application-spec/assistant/generate-assistant-prompt.js +1 -0
- package/dist/application-spec/assistant/index.d.ts +1 -0
- package/dist/application-spec/assistant/index.js +1 -0
- package/dist/application-spec/errors/diagnostic-codes.d.ts +6 -0
- package/dist/application-spec/errors/diagnostic-codes.js +1 -1
- package/dist/application-spec/errors/diagnostic-messages.d.ts +6 -0
- package/dist/application-spec/errors/diagnostic-messages.js +1 -1
- package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
- package/dist/application-spec/generate-application/code/project-scaffolding.js +2 -2
- package/dist/application-spec/generate-application/code/templates/application-types.js +6 -6
- package/dist/application-spec/generate-application/code/templates/configurator-domain-code.d.ts +1 -0
- package/dist/application-spec/generate-application/code/templates/configurator-domain-code.js +11 -8
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-assistant.d.ts +2 -2
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-assistant.js +1 -1
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.d.ts +3 -1
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.js +70 -66
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-phx-globals.js +3 -0
- package/dist/application-spec/generate-application/code/templates/domain-spec.js +7 -7
- package/dist/application-spec/generate-application/code/templates/domain.js +2 -2
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.d.ts +11 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.js +8 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/index.d.ts +1 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/globals.js +1 -0
- package/dist/application-spec/generate-application/code/templates/index.d.ts +7 -6
- package/dist/application-spec/generate-application/code/templates/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/agents-md.js +2 -0
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-cli-skill.js +1 -0
- package/dist/application-spec/generate-application/code/templates/{phoenix-create-configurator-skill.d.ts → skills/phoenix-create-configurator-skill.d.ts} +1 -1
- package/dist/application-spec/generate-application/code/templates/{phoenix-create-configurator-skill.js → skills/phoenix-create-configurator-skill.js} +43 -13
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-feedback-skill.js +54 -0
- package/dist/application-spec/generate-application/code/templates/{phoenix-review-skill.js → skills/phoenix-review-skill.js} +7 -5
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill.js +1 -0
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.d.ts +1 -0
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.js +6 -0
- package/dist/application-spec/generate-application/code/templates/{common → skills}/sdk-content.d.ts +52 -3
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +82 -0
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.d.ts +2 -0
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/sections/actions-runtime.d.ts +14 -0
- package/dist/application-spec/generate-application/runtime/sections/actions-runtime.js +1 -0
- package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.d.ts +4 -3
- package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/sections/index.d.ts +1 -0
- package/dist/application-spec/generate-application/runtime/sections/index.js +1 -1
- package/dist/application-spec/index.d.ts +1 -0
- package/dist/application-spec/index.js +1 -1
- package/dist/application-spec/parse-application-files/categorize/categorize-files.d.ts +3 -1
- package/dist/application-spec/parse-application-files/categorize/categorize-files.js +1 -1
- package/dist/application-spec/parse-application-files/merge/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/merge/index.js +1 -1
- package/dist/application-spec/parse-application-files/merge/merged-actions.d.ts +11 -0
- package/dist/application-spec/parse-application-files/merge/merged-actions.js +1 -0
- package/dist/application-spec/parse-application-files/merge/merged-spec.d.ts +2 -0
- package/dist/application-spec/parse-application-files/merge/merged-spec.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/raw-spec/index.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-actions.d.ts +18 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-actions.js +1 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.d.ts +14 -2
- package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.d.ts +2 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.js +1 -1
- package/dist/application-spec/parse-application-files/resolve/resolve-import-modules.js +1 -1
- package/dist/application-spec/parse-application-files/spec/application/application-spec.js +1 -1
- package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.d.ts +4 -2
- package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.js +1 -1
- package/dist/application-spec/parse-application-files/spec/common/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/spec/common/index.js +1 -1
- package/dist/application-spec/parse-application-files/spec/common/schema-ref-resolver.d.ts +23 -0
- package/dist/application-spec/parse-application-files/spec/common/schema-ref-resolver.js +1 -0
- package/dist/application-spec/parse-application-files/spec/model/names/action-name.d.ts +10 -0
- package/dist/application-spec/parse-application-files/spec/model/names/action-name.js +1 -0
- package/dist/application-spec/parse-application-files/spec/model/names/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/spec/model/names/index.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/actions.d.ts +35 -0
- package/dist/application-spec/parse-application-files/spec/sections/actions.js +1 -0
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.d.ts +5 -21
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +14 -39
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-server-settings.d.ts +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant.d.ts +5 -19
- package/dist/application-spec/parse-application-files/spec/sections/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/spec/sections/index.js +1 -1
- package/dist/client/phoenix-api.d.ts +5 -1
- package/dist/configurator/application-runtime/extensions/configurator-extension-systems.d.ts +2 -1
- package/dist/configurator/application-runtime/extensions/configurator-extension-systems.js +1 -1
- package/dist/configurator/application-runtime/extensions/selectors.d.ts +2 -1
- package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +180 -0
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -0
- package/dist/configurator/{assistant → application-runtime/extensions/systems/assistant-system}/browser-details.d.ts +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/browser-details.js +1 -0
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/change-recorder.d.ts +85 -0
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/change-recorder.js +1 -0
- package/dist/configurator/{assistant → application-runtime/extensions/systems/assistant-system}/graphql-tools.d.ts +20 -16
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -0
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.d.ts +4 -0
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +16 -1
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.d.ts +9 -0
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.js +1 -0
- package/dist/configurator/application-runtime/extensions/systems/index.d.ts +1 -0
- package/dist/configurator/application-runtime/extensions/systems/index.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.d.ts +2 -0
- package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.js +1 -1
- package/dist/configurator/common/frontend-analytics.d.ts +21 -21
- package/dist/configurator/index.d.ts +0 -1
- package/dist/configurator/index.js +1 -1
- package/dist/configurator/pages/LoadedConfiguratorDetailPage.js +1 -1
- package/dist/configurator/scene/scene-analytics/scene-analytics.d.ts +2 -2
- package/dist/configurator/ui/assistant/AssistantChips.d.ts +11 -0
- package/dist/configurator/ui/assistant/AssistantChips.js +1 -0
- package/dist/configurator/ui/assistant/AssistantComposer.d.ts +6 -0
- package/dist/configurator/ui/assistant/AssistantComposer.js +1 -0
- package/dist/configurator/ui/assistant/AssistantMarkdown.d.ts +7 -0
- package/dist/configurator/ui/assistant/AssistantMarkdown.js +1 -0
- package/dist/configurator/ui/assistant/AssistantPanel.d.ts +11 -0
- package/dist/configurator/ui/assistant/AssistantPanel.js +1 -0
- package/dist/configurator/ui/assistant/AssistantThread.d.ts +6 -0
- package/dist/configurator/ui/assistant/AssistantThread.js +1 -0
- package/dist/configurator/ui/assistant/assistant-failure.d.ts +18 -0
- package/dist/configurator/ui/assistant/assistant-failure.js +1 -0
- package/dist/configurator/ui/assistant/index.d.ts +2 -0
- package/dist/configurator/ui/assistant/index.js +1 -0
- package/dist/configurator/ui/assistant/streamed-markdown.d.ts +6 -0
- package/dist/configurator/ui/assistant/streamed-markdown.js +2 -0
- package/dist/configurator/ui/assistant/theme.d.ts +2 -0
- package/dist/configurator/ui/assistant/theme.js +1 -0
- package/dist/configurator/ui/assistant/thread-items.d.ts +37 -0
- package/dist/configurator/ui/assistant/thread-items.js +1 -0
- package/dist/configurator/ui/assistant/tool-chip.d.ts +44 -0
- package/dist/configurator/ui/assistant/tool-chip.js +1 -0
- package/dist/configurator/ui/assistant/use-follow-stream.d.ts +17 -0
- package/dist/configurator/ui/assistant/use-follow-stream.js +1 -0
- package/dist/configurator/ui/assistant/use-is-assistant-panel-open.d.ts +5 -0
- package/dist/configurator/ui/assistant/use-is-assistant-panel-open.js +1 -0
- package/dist/configurator/ui/configurator-layout/universal/DesktopLayout.js +5 -5
- package/dist/configurator/ui/configurator-layout/universal/MobileLayout.d.ts +2 -0
- package/dist/configurator/ui/configurator-layout/universal/MobileLayout.js +4 -4
- package/dist/configurator/ui/legacy/mobile-controls/MobileControls.d.ts +1 -1
- package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.d.ts +10 -0
- package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.js +1 -0
- package/dist/configurator/ui/phoenix-layout-elements/index.d.ts +1 -0
- package/dist/configurator/ui/phoenix-layout-elements/index.js +1 -1
- package/dist/docs/index.json +12 -2
- package/dist/docs/layouts/toolbar.mdx +6 -0
- package/dist/docs/other-features/domain-actions.mdx +418 -0
- package/dist/docs/other-features/side-effects.mdx +26 -0
- package/dist/docs/phoenix/admin.mdx +2 -2
- package/dist/docs/phoenix/best-practices.mdx +1 -0
- package/dist/docs/phoenix/finalization.mdx +1 -1
- package/dist/docs/phoenix/integration/headless-mode-external.mdx +5 -5
- package/dist/docs/phoenix/integration/widget-mode-external.mdx +5 -5
- package/dist/docs/phoenix/migrations.mdx +45 -5
- package/dist/docs/phoenix/phoenix-cli.mdx +139 -20
- package/dist/docs/phoenix/project-structure.mdx +7 -3
- package/dist/docs/phoenix/sdk-builder-workflow.mdx +12 -8
- package/dist/domain/actions/action-factory.d.ts +10 -0
- package/dist/domain/actions/action-factory.js +1 -0
- package/dist/domain/actions/prepare-action-implementations.d.ts +15 -0
- package/dist/domain/actions/prepare-action-implementations.js +5 -0
- package/dist/domain/application/application-config.d.ts +2 -60
- package/dist/domain/application/assistant/assistant-manifest.d.ts +61 -0
- package/dist/domain/application/assistant/assistant-manifest.js +1 -0
- package/dist/domain/application/assistant/assistant-resolved-manifest.d.ts +95 -0
- package/dist/domain/application/assistant/assistant-resolved-manifest.js +1 -0
- package/dist/domain/application/assistant/assistant-value-type.d.ts +9 -0
- package/dist/domain/application/assistant/assistant-value-type.js +1 -0
- package/dist/domain/application/assistant/build-assistant-manifest.d.ts +4 -0
- package/dist/domain/application/assistant/build-assistant-manifest.js +1 -0
- package/dist/domain/application/assistant/index.d.ts +3 -0
- package/dist/domain/application/assistant/index.js +1 -0
- package/dist/domain/application/assistant-field-options.d.ts +1 -1
- package/dist/domain/application/assistant-mutations.d.ts +16 -15
- package/dist/domain/application/assistant-mutations.js +1 -1
- package/dist/domain/application/assistant-recipe-groups.d.ts +1 -1
- package/dist/domain/application/configurator-builder.d.ts +4 -3
- package/dist/domain/application/index.d.ts +2 -1
- package/dist/domain/application/index.js +1 -1
- package/dist/domain/components/updates.d.ts +16 -0
- package/dist/domain/core/action.d.ts +67 -0
- package/dist/domain/core/action.js +1 -0
- package/dist/domain/core/domain-factory.d.ts +4 -0
- package/dist/domain/core/index.d.ts +1 -0
- package/dist/domain/domain-builder.d.ts +7 -0
- package/dist/domain/domain-builder.js +1 -1
- package/dist/domain/domain-context/action-system/action-system.d.ts +40 -0
- package/dist/domain/domain-context/action-system/action-system.js +1 -0
- package/dist/domain/domain-context/domain-context-systems.d.ts +5 -2
- package/dist/domain/domain-context/index.d.ts +2 -1
- package/dist/domain/domain-context/index.js +1 -1
- package/dist/domain/domain-context/store-system/store-system.js +1 -1
- package/dist/domain/domain-runtime/domain-context/domain-context.js +1 -1
- package/dist/domain/domain-runtime/domain-context/selectors.d.ts +4 -0
- package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
- package/dist/domain/domain-runtime/domain-runtime.d.ts +16 -4
- package/dist/domain/domain-runtime/spec/initialize.js +1 -1
- package/dist/domain/domain-runtime/spec/selectors.d.ts +2 -2
- package/dist/domain/domain-runtime/spec/selectors.js +1 -1
- package/dist/domain/domain-runtime/spec/types.d.ts +18 -4
- package/dist/domain/index.d.ts +2 -0
- package/dist/domain/index.js +1 -1
- package/dist/domain/mocks/create-mock-domain-runtime.d.ts +8 -2
- package/dist/domain/system-components/phoenix-layout-elements/assistant-toolbar-button.d.ts +44 -0
- package/dist/domain/system-components/phoenix-layout-elements/assistant-toolbar-button.js +1 -0
- package/dist/domain/system-components/phoenix-layout-elements/index.d.ts +1 -0
- package/dist/domain/system-components/phoenix-layout-elements/index.js +1 -1
- package/dist/domain/system-components/phoenix-layout-elements/phoenix-layout-element.d.ts +2 -1
- package/dist/domain/system-components/phoenix-layout-elements/phoenix-layout-element.js +1 -1
- package/dist/editor/Editor.js +1 -1
- package/dist/editor/domain-editors/DomainSpecContext.js +1 -1
- package/dist/editor/domain-editors/apply-spec-update.js +1 -1
- package/dist/editor/domain-editors/use-implementation-files.d.ts +7 -3
- package/dist/editor/domain-editors/use-implementation-files.js +1 -1
- package/dist/editor/graphql/GraphQLPanel.js +1 -1
- package/dist/editor/variants/VariantAnswerFooter.d.ts +17 -0
- package/dist/editor/variants/VariantAnswerFooter.js +1 -0
- package/dist/editor/variants/VariantPreviewHandler.d.ts +6 -0
- package/dist/editor/variants/VariantPreviewHandler.js +1 -0
- package/dist/editor/variants/variant-preview-styles.d.ts +49 -0
- package/dist/editor/variants/variant-preview-styles.js +1 -0
- package/dist/i18n/locales/cs/messages.js +1 -1
- package/dist/i18n/locales/da/messages.js +1 -1
- package/dist/i18n/locales/de/messages.js +1 -1
- package/dist/i18n/locales/de-AT/messages.js +1 -1
- package/dist/i18n/locales/en/messages.js +1 -1
- package/dist/i18n/locales/en-AU/messages.js +1 -1
- package/dist/i18n/locales/en-GB/messages.js +1 -1
- package/dist/i18n/locales/es/messages.js +1 -1
- package/dist/i18n/locales/fr/messages.js +1 -1
- package/dist/i18n/locales/hu/messages.js +1 -1
- package/dist/i18n/locales/it/messages.js +1 -1
- package/dist/i18n/locales/nl/messages.js +1 -1
- package/dist/i18n/locales/pl/messages.js +1 -1
- package/dist/i18n/locales/pt/messages.js +1 -1
- package/dist/i18n/locales/ro/messages.js +1 -1
- package/dist/i18n/locales/sk/messages.js +1 -1
- package/dist/i18n/locales/tr/messages.js +1 -1
- package/dist/legacy/domain-spec/__generated/domain-schema.d.ts +6 -0
- package/dist/phoenix/application-spec/application-spec-builder.js +1 -1
- package/dist/phoenix/application-spec/resolve-deployment-data.js +2 -2
- package/dist/phoenix/cli.js +1 -1
- package/dist/phoenix/commands/build.d.ts +5 -0
- package/dist/phoenix/commands/build.js +1 -1
- package/dist/phoenix/commands/deploy.js +2 -2
- package/dist/phoenix/commands/dev.js +5 -5
- package/dist/phoenix/commands/feedback.d.ts +2 -1
- package/dist/phoenix/commands/feedback.js +1 -1
- package/dist/phoenix/commands/index.d.ts +1 -0
- package/dist/phoenix/commands/index.js +1 -1
- package/dist/phoenix/commands/login.d.ts +24 -6
- package/dist/phoenix/commands/login.js +2 -2
- package/dist/phoenix/commands/story-dev.js +2 -2
- package/dist/phoenix/commands/variants.d.ts +35 -0
- package/dist/phoenix/commands/variants.js +1 -0
- package/dist/phoenix/editor-server/commands-router.d.ts +68 -1
- package/dist/phoenix/editor-server/commands-router.js +1 -1
- package/dist/phoenix/editor-server/editor-router.d.ts +65 -0
- package/dist/phoenix/editor-server/editor-server.d.ts +3 -3
- package/dist/phoenix/editor-server/editor-server.js +1 -1
- package/dist/phoenix/editor-server/protocol.d.ts +1 -0
- package/dist/phoenix/editor-server/spec-router.js +1 -1
- package/dist/phoenix/editor-server/trpc.d.ts +3 -0
- package/dist/phoenix/services/application-spec-project-watcher.d.ts +13 -2
- package/dist/phoenix/services/application-spec-project-watcher.js +3 -3
- package/dist/phoenix/services/index.d.ts +5 -0
- package/dist/phoenix/services/index.js +1 -1
- package/dist/phoenix/services/phoenix-application.d.ts +21 -0
- package/dist/phoenix/services/phoenix-application.js +1 -0
- package/dist/phoenix/services/phoenix-store.d.ts +48 -0
- package/dist/phoenix/services/phoenix-store.js +1 -0
- package/dist/phoenix/services/phx-banner-plugin.d.ts +32 -0
- package/dist/phoenix/services/phx-banner-plugin.js +1 -0
- package/dist/phoenix/services/phx-licenses-plugin.d.ts +55 -0
- package/dist/phoenix/services/phx-licenses-plugin.js +8 -0
- package/dist/phoenix/services/phx-variant-previews-plugin.d.ts +9 -0
- package/dist/phoenix/services/phx-variant-previews-plugin.js +1 -0
- package/dist/phoenix/services/variant-file-session.d.ts +36 -0
- package/dist/phoenix/services/variant-file-session.js +1 -0
- package/dist/phoenix/services/variant-preview-service.d.ts +80 -0
- package/dist/phoenix/services/variant-preview-service.js +1 -0
- package/dist/phoenix/services/vite-config.d.ts +2 -0
- package/dist/phoenix/services/vite-config.js +1 -1
- package/dist/phoenix/utils/index.d.ts +1 -0
- package/dist/phoenix/utils/index.js +1 -1
- package/dist/phoenix/utils/read-git-commit.d.ts +14 -0
- package/dist/phoenix/utils/read-git-commit.js +1 -0
- package/dist/react-sdk/application-runtime/common-services/analytics/analytics-service.d.ts +2 -2
- package/dist/react-sdk/application-runtime/common-services/analytics/domain-controls-analytics.d.ts +21 -21
- package/dist/react-sdk/application-runtime/hooks/data/use-published-data.d.ts +1 -1
- package/dist/react-sdk/application-runtime/hooks/use-spec.d.ts +1 -1
- package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +16 -4
- package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +3 -0
- package/dist/ui-sdk/common/use-viewport-size.d.ts +4 -1
- package/dist/ui-sdk/common/use-viewport-size.js +1 -1
- package/dist/ui-sdk/components/mobile-controls/index.d.ts +1 -1
- package/dist/ui-sdk/theme/types.d.ts +4 -0
- package/package.json +5 -8
- package/schema/domain-spec.json +24 -0
- package/dist/application-spec/generate-application/code/templates/agents-md.js +0 -2
- package/dist/application-spec/generate-application/code/templates/common/sdk-content.js +0 -67
- package/dist/application-spec/generate-application/code/templates/phoenix-cli-skill.js +0 -1
- package/dist/application-spec/generate-application/code/templates/phoenix-feedback-skill.js +0 -31
- package/dist/application-spec/generate-application/code/templates/phoenix-skill.js +0 -1
- package/dist/configurator/assistant/browser-details.js +0 -1
- package/dist/configurator/assistant/graphql-tools.js +0 -1
- package/dist/configurator/assistant/index.d.ts +0 -1
- package/dist/configurator/assistant/index.js +0 -1
- package/dist/configurator/assistant/use-assistant-chat.d.ts +0 -20
- package/dist/configurator/assistant/use-assistant-chat.js +0 -1
- package/dist/extras/assistant/AssistantChat.d.ts +0 -6
- package/dist/extras/assistant/AssistantChat.js +0 -1
- package/dist/extras/assistant/index.d.ts +0 -1
- package/dist/extras/assistant/index.js +0 -1
- package/dist/phoenix/application-spec/generate-assistant-prompt.js +0 -1
- /package/dist/application-spec/generate-application/code/templates/{common → skills}/agent-skill.d.ts +0 -0
- /package/dist/application-spec/generate-application/code/templates/{common → skills}/agent-skill.js +0 -0
- /package/dist/application-spec/generate-application/code/templates/{agents-md.d.ts → skills/agents-md.d.ts} +0 -0
- /package/dist/application-spec/generate-application/code/templates/{phoenix-cli-skill.d.ts → skills/phoenix-cli-skill.d.ts} +0 -0
- /package/dist/application-spec/generate-application/code/templates/{phoenix-feedback-skill.d.ts → skills/phoenix-feedback-skill.d.ts} +0 -0
- /package/dist/application-spec/generate-application/code/templates/{phoenix-review-skill.d.ts → skills/phoenix-review-skill.d.ts} +0 -0
- /package/dist/application-spec/generate-application/code/templates/{phoenix-skill.d.ts → skills/phoenix-skill.d.ts} +0 -0
package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{GraphQLError as e,buildSchema as t,defaultFieldResolver as i,getNamedType as o,graphql as a,validateSchema as n}from"graphql";import{assertExistence as r,createSelector as s,isMessageDescriptor as l,isMultilingualString as c}from"@salsita-ai/common/utils";import{DomainEntityIdSchema as h,findAssistantMutation as d}from"#package/domain";import{createEntityMeta as m}from"./entity-meta.js";let
|
|
1
|
+
import{GraphQLError as e,buildSchema as t,defaultFieldResolver as i,getNamedType as o,graphql as a,validateSchema as n}from"graphql";import{assertExistence as r,createSelector as s,isMessageDescriptor as l,isMultilingualString as c}from"@salsita-ai/common/utils";import{DomainEntityIdSchema as h,findAssistantMutation as d}from"#package/domain";import{createEntityMeta as m}from"./entity-meta.js";import{readSideEffects as p}from"./side-effects.js";let f={errors:[new e('No assistant manifest in the application spec. The GraphQL schema is generated from the "assistant" section. Add an "assistant" section to a spec file to expose a schema.')]},u={errors:[new e("The configuration is not loaded yet, so there is no state to query. Run the query again once the configurator has finished loading.")]},y=new RegExp(h.pattern),g=e=>"object"==typeof e&&null!==e&&"type"in e&&"string"==typeof e.type&&"id"in e&&"string"==typeof e.id,v=(e,t)=>"object"==typeof e&&null!==e?Reflect.get(e,t):void 0,S=e=>e instanceof Error?e.message:String(e),x=e=>/[.!?]$/.test(e)?e:`${e}.`,_=e=>"object"==typeof e&&null!==e&&Object.getPrototypeOf(e)===Object.prototype,w=(e,t)=>{let i=_(e)?e._raw:void 0;if(g(i))return i;if(!Array.isArray(e)&&!_(e))return e;if(t.has(e))throw Error("The value contains itself. Return ids or copies of the values instead of objects that reference each other.");let o=new Set([...t,e]);return Array.isArray(e)?e.map(e=>w(e,o)):Object.fromEntries(Object.entries(e).map(([e,t])=>[e,w(t,o)]))};export const localize=(e,t)=>Array.isArray(e)?e.map(e=>localize(e,t)):"string"==typeof e||l(e)||c(e)?t(e):e;let E=t=>new e(`The GraphQL schema generated from the "assistant" manifest is invalid: ${x(t)} Regenerate the application so the schema is rebuilt from the current spec.`),$=e=>(e.errors?.length??0)>0,b=t=>({errors:[new e(`Not run: operation ${t+1} failed, so the operations after it were skipped and no change of the list takes effect. Fix the failing operation and send the whole list again.`)]});export class GraphQLSystem{_context;_selectSchema=s([s.leaf(e=>e)],e=>{try{let i=t(e),o=n(i);return o.length>0?E(o.map(e=>e.message).join(" ")):i}catch(e){return E(S(e))}});_selectFieldResolver=s([s.leaf(e=>e)],t=>(a,n,r,s)=>{if(s.parentType===s.schema.getQueryType())return i(a,n,r,s);if(s.parentType===s.schema.getMutationType())return this._resolveMutation(s.fieldName,String(s.path.key),n,r);if(!g(a))return i(a,n,r,s);if("meta"===s.fieldName){let e;return m({entity:a,state:("object"==typeof(e=v(a,"_state"))&&null!==e&&"entities"in e&&"rootEntityId"in e?e:void 0)??r.state},{manifest:r.manifest,recipes:this._recipeContext(),prepareStateEmission:(e,t,i)=>this._context.domainContextSelectors.getStoreSystem().prepareStateEmission(e,t,i),find$Entity:(e,t)=>this._find$Entity(e,t),validateEntity:e=>this._context.domainContextSelectors.getDomain().validateEntity(e)})}let{source:l,localized:c}=t[s.parentType.name]?.[s.fieldName]??{source:s.fieldName},h=((t,i)=>{try{return v(t,i)}catch(o){throw new e(`Expression "${i}" failed on ${g(t)?t.id:"an entity"}: ${x(S(o))} The expression threw while the query read it; fix the expression or the configuration state it reads.`,{originalError:o instanceof Error?o:void 0})}})(a,l);return c?localize(h,this._context.domainServicesSelectors.getResolveLocalizable()):l.startsWith("$")&&"JSON"===o(s.returnType).name?((t,i,o)=>{try{return w(o,new Set)}catch(o){throw new e(`Expression "${i}" returned a value that is not plain serializable data on ${g(t)?t.id:"an entity"}: ${x(S(o))} A JSON field can only return data that serializes to JSON.`,{originalError:o instanceof Error?o:void 0})}})(a,l,h):h});constructor(e){this._context=e}_get$Entity=(e,t)=>this._context.domainContextSelectors.getDomain().get$Entity(e,t);_find$Entity=(e,t)=>this._context.domainContextSelectors.getDomain().getEntity(e,t)?this._get$Entity(e,t):null;_recipeContext=()=>({componentReader:this._context.domainContextSelectors.getComponentReader(),recipeCooker:this._context.domainContextSelectors.getRecipeCookerSystem(),resolveLocalizable:this._context.domainServicesSelectors.getResolveLocalizable()});_rootValue={root:(e,{state:t})=>this._get$Entity(t.rootEntityId,t),entities:({ids:t},{state:i})=>{if(null==t)return i.entities.map(e=>this._get$Entity(e.id,i));var o=i.rootEntityId;let a=t.filter(e=>!y.test(e));if(a.length>0)throw new e(`${a.map(e=>`"${e}"`).join(", ")} ${1===a.length?"is not an entity id":"are not entity ids"}. Entity ids have the form "<Type>-<number>", e.g. "${o}". Use ids as returned by the "id" field.`);return t.map(e=>y.test(e)?this._find$Entity(e,i):null)},selectedEntity:(e,{state:t})=>this._find$Entity(this._context.domainContextSelectors.getNavigationSystem().getActiveSelectionState(t),t),navigation:(e,{state:t})=>{let i=this._context.domainContextSelectors.getNavigationSystem();return{navigationState:i.getActiveNavigationState(t),viewState:i.getActiveViewState(t),toolState:i.getActiveToolState(t)}}};_resolveType=e=>g(e)?e.type:void 0;initialize=()=>{};_resolveMutation=(t,i,o,a)=>{if(void 0!==a.failedMutationField)throw new e(`Not run: the earlier field "${a.failedMutationField}" of this operation failed, so "${i}" was skipped and no change of the operation takes effect. Fix the failing field and send the operation again.`);try{return this._runMutation(t,o,a)}catch(e){throw a.failedMutationField=i,e}};_runMutation=(t,i,o)=>{let a=d(t,o.manifest);if(!a)throw new e(`The schema declares the mutation "${t}", but the configurator has no implementation for it. Regenerate the application so the schema matches the configurator.`);let n=o.state,r=a.implementation(i,n,{manifest:o.manifest,action:this._context.domainContextSelectors.getActionSystem().createContext(n),resolveLocalizable:this._context.domainServicesSelectors.getResolveLocalizable()});if(r.updates.length>0){let i=this._context.domainContextSelectors.getStoreSystem().prepareStateEmission(r.updates,n,"committed");if(!i.validity.valid)throw new e(`The changes of "${t}" were not applied, because the resulting configuration is invalid: ${(e=>{if("uncaught"===e.severity)return`validating it threw: ${x(S(e.error))}`;let t=[...new Set(e.entityViolations.filter(({violation:t})=>t.severity===e.severity).map(({entityId:e})=>e))];return`it has ${e.severity} violations on ${t.join(", ")}.`})(i.validity)} Change the request so the configuration stays valid.`);o.emissions.push(i),o.state=i.state}return r.readResult({previousState:n,state:o.state})};_setup=()=>{let t=this._context.specSelectors.getAssistant();if(!t)return{ready:!1,result:f};let i=this._selectSchema(t.sdl);return i instanceof e?{ready:!1,result:{errors:[i]}}:{ready:!0,assistant:t,schema:i,fieldResolver:this._selectFieldResolver(t.fields)}};prepare=async(e,t)=>{let i,o=this._setup();if(!o.ready)return t.map(()=>({result:o.result,emissions:[]}));let n={manifest:o.assistant,state:e,emissions:[],failedMutationField:void 0},r=[];for(let[e,s]of t.entries())if(void 0===i){let t=n.emissions.length;n.failedMutationField=void 0;let l=await a({schema:o.schema,source:s.document,rootValue:this._rootValue,contextValue:n,variableValues:s.variables,operationName:s.operationName,fieldResolver:o.fieldResolver,typeResolver:this._resolveType});r.push({result:l,emissions:n.emissions.slice(t)}),$(l)&&(i=e)}else r.push({result:b(i),emissions:[]});return r};readSideEffects=e=>{let t=this._context.domainServicesSelectors.getResolveLocalizable();return e.flatMap(({emissions:e})=>e.flatMap(e=>p(e.updates,t)))};_prepareAndCommit=async e=>{let t,i,o,a=this._context.domainContextSelectors.getStoreSystem(),n=await this.prepare(a.stateSlices.committed.value.state,e),s=n.map(({result:e})=>e),l=this.readSideEffects(n),c=n.flatMap(e=>e.emissions);return s.some($)||0===c.length?{results:s,sideEffects:l,outcome:"none"}:{results:s,sideEffects:l,outcome:a.commitPrepared((t=r(c[0]),i=r(c[c.length-1]),o=c.some(e=>void 0!==e.transformationLog),{kind:"committed",previousState:t.previousState,state:i.state,updates:c.flatMap(e=>e.updates),validity:i.validity,transformationLog:o?c.flatMap(e=>e.transformationLog??[]):void 0}))}};execute=async e=>{if(!this._context.domainContextSelectors.getStoreSystem().isInitialized)return{results:e.map(()=>u),committed:!1,sideEffects:[]};let t=await this._prepareAndCommit(e),{results:i,sideEffects:o,outcome:a}="conflict"===t.outcome?await this._prepareAndCommit(e):t;return"committed"===a?{results:i,committed:!0,sideEffects:o}:"held"===a?{results:i,committed:!1,message:"The changes were not committed yet: the application held them, usually to ask the user for approval. They may still be applied once the user approves, and the next turn shows whether they were. Do not send the operations again.",sideEffects:o}:"conflict"===a?{results:i,committed:!1,message:"The changes were not committed, because the configuration changed while they were being applied. The results describe a state that was discarded. Query the current configuration and send the operations again if they still make sense.",sideEffects:o}:{results:i,committed:!1,sideEffects:o}}}
|
package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Localizable } from '@salsita-ai/common/utils';
|
|
2
|
+
import type { DataUpdate, DomainEntity } from '#package/domain';
|
|
3
|
+
/**
|
|
4
|
+
* What the updates of an emission tell the assistant agent the configurator did beyond what was
|
|
5
|
+
* asked, in applied order with duplicates kept, the way the user gets them as snackbars. An update's
|
|
6
|
+
* `agentHint` replaces its user-facing `hint` for the agent, `null` keeps the update from the agent,
|
|
7
|
+
* and an update with neither says nothing. Empty text counts as none, as it does for the snackbar.
|
|
8
|
+
*/
|
|
9
|
+
export declare const readSideEffects: (updates: ReadonlyArray<DataUpdate<DomainEntity<string>, DomainEntity<string>>>, resolveLocalizable: (message: Localizable) => string) => readonly string[];
|
package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const readSideEffects=(e,t)=>e.flatMap(({hint:e,agentHint:a})=>null===a?[]:void 0!==a?a?[a]:[]:e?[t(e)]:[]);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AnimationSystem, type AnimationSystemContext } from './animation-system.js';
|
|
2
|
+
export { type AssistantChatSnapshot, type AssistantClientTool, type AssistantPanelSnapshot, AssistantSystem, type AssistantSystemContext, } from './assistant-system/assistant-system.js';
|
|
2
3
|
export { CameraControlSystem, CameraControlType } from './camera-control-system/camera-control-system.js';
|
|
3
4
|
export { type AnyCameraSystem, CameraSystem, type CameraSystemContext } from './camera-control-system/camera-system.js';
|
|
4
5
|
export { createCameraControls } from './camera-control-system/create-camera-controls.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{AnimationSystem}from"./animation-system.js";export{CameraControlSystem,CameraControlType}from"./camera-control-system/camera-control-system.js";export{CameraSystem}from"./camera-control-system/camera-system.js";export{createCameraControls}from"./camera-control-system/create-camera-controls.js";export{CanvasSystem}from"./canvas-system.js";export{DragAndDropSystem}from"./drag-and-drop-system/drag-and-drop-system.js";export{ExportSystem}from"./export-system/export-system.js";export{GraphQLSystem}from"./graphql-system/graphql-system.js";export{ImageRenderingSystem}from"./image-rendering-system/image-rendering-system.js";export{LayoutSystem}from"./layout-system/layout-system.js";export{toolbarHelpElementName}from"./layout-system/toolbar-help-element.js";export{SketchingSystem}from"./sketching-system/sketching-system.js";export{LineEndPointUpdateTag,LineLengthUpdateTag,LineLineConnectionUpdateTag,LineRectangleBottomLeftConnectionUpdateTag,LineRectangleBottomRightConnectionUpdateTag,LineRectangleTopLeftConnectionUpdateTag,LineRectangleTopRightConnectionUpdateTag,LineSketchingPointUpdateTag,LineStartPointUpdateTag,RectangleBottomLeftCornerUpdateTag,RectangleBottomRightCornerUpdateTag,RectangleDepthUpdateTag,RectangleSketchingPointUpdateTag,RectangleTopLeftCornerUpdateTag,RectangleTopRightCornerUpdateTag,RectangleWidthUpdateTag,SetInitialSketchingPointPositionTag,SketchingFixTransformationTag,isAnySketchingPointUpdate,isLineEndPointUpdate,isLineLengthUpdate,isLineLineConnectionUpdate,isLineRectangleBottomLeftConnectionUpdate,isLineRectangleBottomRightConnectionUpdate,isLineRectangleTopLeftConnectionUpdate,isLineRectangleTopRightConnectionUpdate,isLineSketchingPointUpdate,isLineStartPointUpdate,isRectangleBottomLeftCornerUpdate,isRectangleBottomRightCornerUpdate,isRectangleDepthUpdate,isRectangleSketchingPointUpdate,isRectangleTopLeftCornerUpdate,isRectangleTopRightCornerUpdate,isRectangleWidthUpdate,isSetInitialLinePositionUpdate,isSetInitialRectanglePositionUpdate,isSketchingFixTransformationUpdate}from"./sketching-system/sketching-updates.js";
|
|
1
|
+
export{AnimationSystem}from"./animation-system.js";export{AssistantSystem}from"./assistant-system/assistant-system.js";export{CameraControlSystem,CameraControlType}from"./camera-control-system/camera-control-system.js";export{CameraSystem}from"./camera-control-system/camera-system.js";export{createCameraControls}from"./camera-control-system/create-camera-controls.js";export{CanvasSystem}from"./canvas-system.js";export{DragAndDropSystem}from"./drag-and-drop-system/drag-and-drop-system.js";export{ExportSystem}from"./export-system/export-system.js";export{GraphQLSystem}from"./graphql-system/graphql-system.js";export{ImageRenderingSystem}from"./image-rendering-system/image-rendering-system.js";export{LayoutSystem}from"./layout-system/layout-system.js";export{toolbarHelpElementName}from"./layout-system/toolbar-help-element.js";export{SketchingSystem}from"./sketching-system/sketching-system.js";export{LineEndPointUpdateTag,LineLengthUpdateTag,LineLineConnectionUpdateTag,LineRectangleBottomLeftConnectionUpdateTag,LineRectangleBottomRightConnectionUpdateTag,LineRectangleTopLeftConnectionUpdateTag,LineRectangleTopRightConnectionUpdateTag,LineSketchingPointUpdateTag,LineStartPointUpdateTag,RectangleBottomLeftCornerUpdateTag,RectangleBottomRightCornerUpdateTag,RectangleDepthUpdateTag,RectangleSketchingPointUpdateTag,RectangleTopLeftCornerUpdateTag,RectangleTopRightCornerUpdateTag,RectangleWidthUpdateTag,SetInitialSketchingPointPositionTag,SketchingFixTransformationTag,isAnySketchingPointUpdate,isLineEndPointUpdate,isLineLengthUpdate,isLineLineConnectionUpdate,isLineRectangleBottomLeftConnectionUpdate,isLineRectangleBottomRightConnectionUpdate,isLineRectangleTopLeftConnectionUpdate,isLineRectangleTopRightConnectionUpdate,isLineSketchingPointUpdate,isLineStartPointUpdate,isRectangleBottomLeftCornerUpdate,isRectangleBottomRightCornerUpdate,isRectangleDepthUpdate,isRectangleSketchingPointUpdate,isRectangleTopLeftCornerUpdate,isRectangleTopRightCornerUpdate,isRectangleWidthUpdate,isSetInitialLinePositionUpdate,isSetInitialRectanglePositionUpdate,isSketchingFixTransformationUpdate}from"./sketching-system/sketching-updates.js";
|
package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export declare class LayoutSystem<ENTITIES extends DomainEntity<string>> {
|
|
|
25
25
|
* whatever was true when it was created.
|
|
26
26
|
*/
|
|
27
27
|
private get _toolbarHelpExists();
|
|
28
|
+
/** Whether the application spec has an `assistant` section; read on demand for the same reason. */
|
|
29
|
+
private get _hasAssistant();
|
|
28
30
|
initialize: () => void;
|
|
29
31
|
getCleanUpPropertyPageStateUpdates: (entityId: DomainEntityId<string>, state: DomainState<ENTITIES>) => import("#package/domain").ComponentModification<import("#package/domain").SystemComponentType<"layoutStateComponent", import("./layout-state.js").LayoutStateComponentState, "propertyPageStates">>[];
|
|
30
32
|
getLayoutConfig: (state: DomainState<ENTITIES>) => {
|
package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as t,match as e}from"ts-pattern";import{SystemState as o,applicationConfigComponent as n,customSummaryPageComponent as a,entityHeaderComponent as i,navigationStepsComponent as r,propertyPageComponent as s,sidebarTabsComponent as l,simpleSummaryComponent as d,toolbarComponent as c}from"#package/domain";import{layoutStateComponent as g}from"./layout-state.js";import{toolbarHelpElementName as u}from"./toolbar-help-element.js";export class LayoutSystem{_context;_toolbarCache=new WeakMap;state;constructor(t){this._context=t,this.state=new o({...this._context,selectors:this._context.domainContextSelectors,componentType:g,getInitialState:()=>({propertyPageStates:{}})})}get _toolbarHelpExists(){return void 0!==this._context.specSelectors.getElementSlots().layoutElements[u]}initialize=()=>{this.state.initialize()};getCleanUpPropertyPageStateUpdates=(t,e)=>this.state.getUpdates(e=>{if(!e.propertyPageStates[t])return null;let o={...e.propertyPageStates};return delete o[t],{...e,propertyPageStates:o}},e);getLayoutConfig=t=>{let e=this._context.domainContextSelectors.getComponentReader().readFirstRootComponent({componentTypes:[n]},t),o=e?.state.shareDisabled??!1,a=o||(e?.state.shareOwnerLinkDisabled??!1),i=o||(e?.state.shareReadRevisionLinkDisabled??!1);return{layout:e?.state.layout??"universal",ignoreSelectionInSidebar:e?.state.ignoreSelectionInSidebar??!1,miniSidebar:e?.state.miniSidebar??!1,splitSidebar:e?.state.splitSidebar??!1,showSelectionBackButton:e?.state.showSelectionBackButton??!0,shareDisabled:a&&i,availableLocales:e?.state.availableLocales??["en"],indicatorSwitch:e?.state.indicatorSwitch??!0}};getSidebarSummaryPage=t=>{let e=this._context.domainContextSelectors.getNavigationSystem().getActiveNavigationState(t),o=this._context.domainContextSelectors.getComponentReader().readFirstRootComponent({componentTypes:[a,d]},t),n=e===o?.state.summaryNavigationState,i=o?.state.summaryNavigationState;return{page:o,isSummaryActive:n,summaryNavigationState:i}};getEnterSidebarSummaryUpdates=t=>{let{summaryNavigationState:e}=this.getSidebarSummaryPage(t);return e?[this._context.domainContextSelectors.getNavigationSystem().getPushNavigationUpdate(e,t)]:[]};getLeaveSidebarSummaryUpdates=t=>{let e=this._context.domainContextSelectors.getNavigationSystem().getPopNavigationUpdate(t);if(e)return[e];let o=this._context.domainContextSelectors.getNavigationStates().at(0);return o?(this._context.domainServicesSelectors.getLogger().error("There is no navigation state to pop, falling back to the initial navigation state. Check whether the history stack is not broken by some custom navigation logic."),[this._context.domainContextSelectors.getNavigationSystem().getNavigationUpdate(o)]):(this._context.domainServicesSelectors.getLogger().error("There is no navigation state to pop and no initial navigation state to fallback to, this should not happen"),[])};getPushSidebarStackPageUpdates=(t,e,o,n)=>this.state.getUpdates(n=>{let a=n.propertyPageStates[t]??{customState:{},stackPages:[]};return{...n,propertyPageStates:{...n.propertyPageStates,[t]:{...a,stackPages:[...a.stackPages,{props:o,component:e}]}}}},n);getPopSidebarStackPageUpdates=(t,e)=>this.state.getUpdates(e=>{let o=e.propertyPageStates[t]??{customState:{},stackPages:[]};return{...e,propertyPageStates:{...e.propertyPageStates,[t]:{...o,stackPages:o.stackPages.slice(0,-1)}}}},e);getSidebarBackUpdates=t=>{let e=this._context.domainContextSelectors.getNavigationSystem().getHasStackToPop(t),o=this._context.domainContextSelectors.getNavigationSystem().getIsRootSelected(t),{renderedStackedPage:n,summaryPage:a,activePropertyPageId:i}=this.getSidebarContent(t);if(a)return this.getLeaveSidebarSummaryUpdates(t);if(n&&i)return this.getPopSidebarStackPageUpdates(i,t);if(e){let e=this._context.domainContextSelectors.getNavigationSystem().getPopNavigationUpdate(t);return e?[e]:[]}return o?[]:[this._context.domainContextSelectors.getNavigationSystem().getDeselectUpdate()]};getSidebarContent=t=>{let e=this._context.domainContextSelectors.getNavigationSystem().getActiveSelectionState(t),o=this.state.get(t),n=this.getLayoutConfig(t),a=this._context.domainContextSelectors.getComponentReader().readManyComponents({componentTypes:[l],entityIds:[e]},t).some(t=>t.state.tabs.length>0),r=n.miniSidebar&&!a;r&&a&&this._context.domainServicesSelectors.getLogger().warn("Mini sidebar is not active because the layout contains tabs. Only layouts without tabs can have mini sidebar.");let d=this._context.domainContextSelectors.getComponentReader().readManyComponents({componentTypes:[s]},t),{isSummaryActive:c,page:g}=this.getSidebarSummaryPage(t),u=this._context.domainContextSelectors.getComponentReader().readManyComponents({componentTypes:[i]},t),p=this._context.domainContextSelectors.getCompositionProjections().getTree(t).map.get(e);if(!p)throw Error(`Selected entity ${e} not found in composition tree`);let m=this._context.domainContextSelectors.getCompositionProjections().getTree(t).map.get(t.rootEntityId);if(!m)throw Error(`Root entity ${t.rootEntityId} not found in composition tree`);let
|
|
1
|
+
import{P as t,match as e}from"ts-pattern";import{SystemState as o,applicationConfigComponent as n,customSummaryPageComponent as a,entityHeaderComponent as i,navigationStepsComponent as r,propertyPageComponent as s,sidebarTabsComponent as l,simpleSummaryComponent as d,toolbarComponent as c}from"#package/domain";import{layoutStateComponent as g}from"./layout-state.js";import{toolbarHelpElementName as u}from"./toolbar-help-element.js";export class LayoutSystem{_context;_toolbarCache=new WeakMap;state;constructor(t){this._context=t,this.state=new o({...this._context,selectors:this._context.domainContextSelectors,componentType:g,getInitialState:()=>({propertyPageStates:{}})})}get _toolbarHelpExists(){return void 0!==this._context.specSelectors.getElementSlots().layoutElements[u]}get _hasAssistant(){return void 0!==this._context.specSelectors.getAssistant()}initialize=()=>{this.state.initialize()};getCleanUpPropertyPageStateUpdates=(t,e)=>this.state.getUpdates(e=>{if(!e.propertyPageStates[t])return null;let o={...e.propertyPageStates};return delete o[t],{...e,propertyPageStates:o}},e);getLayoutConfig=t=>{let e=this._context.domainContextSelectors.getComponentReader().readFirstRootComponent({componentTypes:[n]},t),o=e?.state.shareDisabled??!1,a=o||(e?.state.shareOwnerLinkDisabled??!1),i=o||(e?.state.shareReadRevisionLinkDisabled??!1);return{layout:e?.state.layout??"universal",ignoreSelectionInSidebar:e?.state.ignoreSelectionInSidebar??!1,miniSidebar:e?.state.miniSidebar??!1,splitSidebar:e?.state.splitSidebar??!1,showSelectionBackButton:e?.state.showSelectionBackButton??!0,shareDisabled:a&&i,availableLocales:e?.state.availableLocales??["en"],indicatorSwitch:e?.state.indicatorSwitch??!0}};getSidebarSummaryPage=t=>{let e=this._context.domainContextSelectors.getNavigationSystem().getActiveNavigationState(t),o=this._context.domainContextSelectors.getComponentReader().readFirstRootComponent({componentTypes:[a,d]},t),n=e===o?.state.summaryNavigationState,i=o?.state.summaryNavigationState;return{page:o,isSummaryActive:n,summaryNavigationState:i}};getEnterSidebarSummaryUpdates=t=>{let{summaryNavigationState:e}=this.getSidebarSummaryPage(t);return e?[this._context.domainContextSelectors.getNavigationSystem().getPushNavigationUpdate(e,t)]:[]};getLeaveSidebarSummaryUpdates=t=>{let e=this._context.domainContextSelectors.getNavigationSystem().getPopNavigationUpdate(t);if(e)return[e];let o=this._context.domainContextSelectors.getNavigationStates().at(0);return o?(this._context.domainServicesSelectors.getLogger().error("There is no navigation state to pop, falling back to the initial navigation state. Check whether the history stack is not broken by some custom navigation logic."),[this._context.domainContextSelectors.getNavigationSystem().getNavigationUpdate(o)]):(this._context.domainServicesSelectors.getLogger().error("There is no navigation state to pop and no initial navigation state to fallback to, this should not happen"),[])};getPushSidebarStackPageUpdates=(t,e,o,n)=>this.state.getUpdates(n=>{let a=n.propertyPageStates[t]??{customState:{},stackPages:[]};return{...n,propertyPageStates:{...n.propertyPageStates,[t]:{...a,stackPages:[...a.stackPages,{props:o,component:e}]}}}},n);getPopSidebarStackPageUpdates=(t,e)=>this.state.getUpdates(e=>{let o=e.propertyPageStates[t]??{customState:{},stackPages:[]};return{...e,propertyPageStates:{...e.propertyPageStates,[t]:{...o,stackPages:o.stackPages.slice(0,-1)}}}},e);getSidebarBackUpdates=t=>{let e=this._context.domainContextSelectors.getNavigationSystem().getHasStackToPop(t),o=this._context.domainContextSelectors.getNavigationSystem().getIsRootSelected(t),{renderedStackedPage:n,summaryPage:a,activePropertyPageId:i}=this.getSidebarContent(t);if(a)return this.getLeaveSidebarSummaryUpdates(t);if(n&&i)return this.getPopSidebarStackPageUpdates(i,t);if(e){let e=this._context.domainContextSelectors.getNavigationSystem().getPopNavigationUpdate(t);return e?[e]:[]}return o?[]:[this._context.domainContextSelectors.getNavigationSystem().getDeselectUpdate()]};getSidebarContent=t=>{let e=this._context.domainContextSelectors.getNavigationSystem().getActiveSelectionState(t),o=this.state.get(t),n=this.getLayoutConfig(t),a=this._context.domainContextSelectors.getComponentReader().readManyComponents({componentTypes:[l],entityIds:[e]},t).some(t=>t.state.tabs.length>0),r=n.miniSidebar&&!a;r&&a&&this._context.domainServicesSelectors.getLogger().warn("Mini sidebar is not active because the layout contains tabs. Only layouts without tabs can have mini sidebar.");let d=this._context.domainContextSelectors.getComponentReader().readManyComponents({componentTypes:[s]},t),{isSummaryActive:c,page:g}=this.getSidebarSummaryPage(t),u=this._context.domainContextSelectors.getComponentReader().readManyComponents({componentTypes:[i]},t),p=this._context.domainContextSelectors.getCompositionProjections().getTree(t).map.get(e);if(!p)throw Error(`Selected entity ${e} not found in composition tree`);let m=this._context.domainContextSelectors.getCompositionProjections().getTree(t).map.get(t.rootEntityId);if(!m)throw Error(`Root entity ${t.rootEntityId} not found in composition tree`);let h=(n.ignoreSelectionInSidebar?[m]:[p,...p.ancestors()]).map(t=>{let e=n.ignoreSelectionInSidebar?d:d.filter(e=>e.componentInstance.entityId===t.id),o=u.filter(e=>e.componentInstance.entityId===t.id);return{id:t.id,propertyPages:e,header:o[0]??null}}),S=h[0]?.id,b=(S?o.propertyPageStates[S]?.stackPages??[]:[]).at(-1)??null,k=this._context.domainContextSelectors.getNavigationSystem().getHasStackToPop(t),x=this._context.domainContextSelectors.getNavigationSystem().getIsRootSelected(t),y=c&&k||k||!!b||!x&&n.showSelectionBackButton&&!n.ignoreSelectionInSidebar;return c?{summaryPage:g,propertyPages:[],isBackAvailable:y,hasMiniSidebar:r,hasSplitSidebar:n.splitSidebar}:{summaryPage:null,propertyPages:h,renderedStackedPage:b,activePropertyPageId:S,isBackAvailable:y,hasMiniSidebar:r,hasSplitSidebar:n.splitSidebar}};getToolbarState=o=>{let n=this._toolbarHelpExists,a=this._hasAssistant,i=this._toolbarCache.get(o);if(i&&i.toolbarHelpExists===n&&i.hasAssistant===a)return i.result;let r=this._context.domainContextSelectors.getExpressionContext(),s=this._context.domainContextSelectors.getNavigationSystem().getActiveFullscreenState(o),l="read"===r.mode,d=this._context.domainContextSelectors.getComponentReader().readFirstRootComponent({componentTypes:[c]},o),g=this._context.domainContextSelectors.getDimensionSystem().getDimensionConfig(o),u=this.getLayoutConfig(o),p="read"===this._context.domainContextSelectors.getExpressionContext().mode,m=u.availableLocales.length>1,h=!p&&!u.shareDisabled,S=u.indicatorSwitch,b=g.availableDimensions.length>1||S,k=a?[{kind:"toolbarButtonGroup",children:[{kind:"assistantToolbarButton"}]}]:[],x=e(d).returnType().with(t.nonNullable,t=>t.state).with(t.nullish,()=>e([s,l]).returnType().with([!1,!1],()=>({desktop:[{kind:"toolbarButtonGroup",children:[{kind:"enterFullscreenToolbarButton"}]},{kind:"toolbarButtonGroup",children:[{kind:"resetCameraToolbarButton"}]},...m?[{kind:"toolbarButtonGroup",children:[{kind:"languageToolbarButton"}]}]:[],...h||b?[{kind:"toolbarButtonGroup",children:[...h?[{kind:"shareToolbarButton"}]:[],...b?[{kind:"measurementsToolbarButton"}]:[],...n?[{kind:"helpToolbarButton"}]:[]]}]:[],{kind:"toolbarButtonGroup",children:[{kind:"undoToolbarButton"},{kind:"redoToolbarButton"}]},...k],mobile:[{kind:"toolbarButtonGroup",children:[{kind:"undoToolbarButton"},{kind:"redoToolbarButton"}]},{kind:"toolbarButtonGroup",children:[{kind:"resetCameraToolbarButton"}]},{kind:"toolbarButtonGroup",children:[{kind:"enterFullscreenToolbarButton"}]},...k],mobileMenu:[...h?[{kind:"shareMenuAction"}]:[],...b?[{kind:"measurementsMenuAction"}]:[],...m?[{kind:"languageMenuAction"}]:[],...n?[{kind:"helpMenuAction"}]:[]]})).with([!0,!1],()=>({desktop:[{kind:"toolbarButtonGroup",children:[{kind:"exitFullscreenToolbarButton"}]}],mobile:[{kind:"toolbarButtonGroup",children:[{kind:"exitFullscreenToolbarButton"}]}],mobileMenu:[]})).with([!1,!0],()=>({desktop:[{kind:"toolbarButtonGroup",children:[{kind:"enterFullscreenToolbarButton"}]},{kind:"toolbarButtonGroup",children:[{kind:"resetCameraToolbarButton"}]},...m?[{kind:"toolbarButtonGroup",children:[{kind:"languageToolbarButton"}]}]:[],...b?[{kind:"toolbarButtonGroup",children:[...b?[{kind:"measurementsToolbarButton"}]:[]]}]:[],...n?[{kind:"helpToolbarButton"}]:[],...k],mobile:[{kind:"toolbarButtonGroup",children:[{kind:"resetCameraToolbarButton"}]},{kind:"toolbarButtonGroup",children:[{kind:"enterFullscreenToolbarButton"}]},...k],mobileMenu:[...b?[{kind:"measurementsMenuAction"}]:[],...m?[{kind:"languageMenuAction"}]:[],...n?[{kind:"helpMenuAction"}]:[]]})).with([!0,!0],()=>({desktop:[{kind:"toolbarButtonGroup",children:[{kind:"exitFullscreenToolbarButton"}]}],mobile:[{kind:"toolbarButtonGroup",children:[{kind:"exitFullscreenToolbarButton"}]}],mobileMenu:[]})).exhaustive()).exhaustive();return this._toolbarCache.set(o,{toolbarHelpExists:n,hasAssistant:a,result:x}),x};getNavigationSteps=t=>{let e=this._context.domainContextSelectors.getComponentReader().readFirstRootComponent({componentTypes:[r]},t);return e?.state.steps??[]}}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { type EntityId } from '#package/domain';
|
|
2
|
-
declare const CloseConfiguratorClicked: () => import("
|
|
3
|
-
declare const PreviousStepButtonClicked: () => import("
|
|
4
|
-
declare const NextStepButtonClicked: () => import("
|
|
5
|
-
declare const FinalizeButtonClicked: () => import("
|
|
6
|
-
declare const SummaryButtonClicked: () => import("
|
|
7
|
-
declare const TopNavigationStepClicked: (step: string) => import("
|
|
8
|
-
declare const HorizontalTabClicked: (tab: string) => import("
|
|
9
|
-
declare const GoToProductsClicked: () => import("
|
|
10
|
-
declare const ExpandedViewClosed: () => import("
|
|
11
|
-
declare const ProductSelected: (productType: string, productName: string) => import("
|
|
12
|
-
declare const SelectionHotspotClicked: (id: string) => import("
|
|
13
|
-
declare const RedoButtonClicked: () => import("
|
|
14
|
-
declare const UndoButtonClicked: () => import("
|
|
15
|
-
declare const GlobalDimensionsButtonClicked: (dimensionUnit: string) => import("
|
|
16
|
-
declare const MeasurementsMenuToggled: () => import("
|
|
17
|
-
declare const MeasurementsMenuClosed: () => import("
|
|
18
|
-
declare const DimensionIndicatorsToggled: () => import("
|
|
19
|
-
declare const FullScreenModeToggled: () => import("
|
|
20
|
-
declare const HelpDialogOpened: () => import("
|
|
21
|
-
declare const HelpDialogClosed: () => import("
|
|
22
|
-
declare const EntityDeleteHotspotClicked: (id: EntityId) => import("
|
|
2
|
+
declare const CloseConfiguratorClicked: () => import("#package/domain").UserActionEvent;
|
|
3
|
+
declare const PreviousStepButtonClicked: () => import("#package/domain").UserActionEvent;
|
|
4
|
+
declare const NextStepButtonClicked: () => import("#package/domain").UserActionEvent;
|
|
5
|
+
declare const FinalizeButtonClicked: () => import("#package/domain").UserActionEvent;
|
|
6
|
+
declare const SummaryButtonClicked: () => import("#package/domain").UserActionEvent;
|
|
7
|
+
declare const TopNavigationStepClicked: (step: string) => import("#package/domain").UserActionEvent;
|
|
8
|
+
declare const HorizontalTabClicked: (tab: string) => import("#package/domain").UserActionEvent;
|
|
9
|
+
declare const GoToProductsClicked: () => import("#package/domain").UserActionEvent;
|
|
10
|
+
declare const ExpandedViewClosed: () => import("#package/domain").UserActionEvent;
|
|
11
|
+
declare const ProductSelected: (productType: string, productName: string) => import("#package/domain").UserActionEvent;
|
|
12
|
+
declare const SelectionHotspotClicked: (id: string) => import("#package/domain").UserActionEvent;
|
|
13
|
+
declare const RedoButtonClicked: () => import("#package/domain").UserActionEvent;
|
|
14
|
+
declare const UndoButtonClicked: () => import("#package/domain").UserActionEvent;
|
|
15
|
+
declare const GlobalDimensionsButtonClicked: (dimensionUnit: string) => import("#package/domain").UserActionEvent;
|
|
16
|
+
declare const MeasurementsMenuToggled: () => import("#package/domain").UserActionEvent;
|
|
17
|
+
declare const MeasurementsMenuClosed: () => import("#package/domain").UserActionEvent;
|
|
18
|
+
declare const DimensionIndicatorsToggled: () => import("#package/domain").UserActionEvent;
|
|
19
|
+
declare const FullScreenModeToggled: () => import("#package/domain").UserActionEvent;
|
|
20
|
+
declare const HelpDialogOpened: () => import("#package/domain").UserActionEvent;
|
|
21
|
+
declare const HelpDialogClosed: () => import("#package/domain").UserActionEvent;
|
|
22
|
+
declare const EntityDeleteHotspotClicked: (id: EntityId) => import("#package/domain").UserActionEvent;
|
|
23
23
|
export declare const FrontendAnalyticsFactory: {
|
|
24
24
|
CloseConfiguratorClicked: typeof CloseConfiguratorClicked;
|
|
25
25
|
PreviousStepButtonClicked: typeof PreviousStepButtonClicked;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{ConfiguratorApp}from"./ConfiguratorApp.js";export*from"./application-runtime/index.js";export*from"./
|
|
1
|
+
export{ConfiguratorApp}from"./ConfiguratorApp.js";export*from"./application-runtime/index.js";export*from"./common/index.js";export*from"./configurator-context/index.js";export*from"./pages/index.js";export*from"./scene/index.js";export*from"./ui/index.js";export*from"./integration/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e,jsxs as o,Fragment as i}from"react/jsx-runtime";import r from"mui-modal-provider";import{memo as n,useCallback as t,useEffect as a,useMemo as d}from"react";import{match as s}from"ts-pattern";import{InvalidAccessKeyError as l}from"#package/client";import{BuiltInLoadingPhase as u,CommonAnalyticsFactory as m,DomainLifecycleBoundary as c,LoadedDataProvider as f,useAccessService as p,useAnalyticsService as g,useAuthorizedClient as v,useConfiguratorDomainFactory as w,useConfiguratorLoadStatus as y,useConfiguratorRawLoadedData as h,useExpectPhase as I,useLoadedDataActions as j,useLoadingError as x,useLoadingPhase as C,useLogger as b,useRoutingService as k,useSpecAssistant as L}from"#package/react-sdk";import{useConfigurator as U}from"../application-runtime/index.js";import{IntegrationSubscription as M,OnConfiguratorReadyProvider as S,ViewportStateSync as E,useLayoutSystemConfig as F}from"../configurator-context/index.js";import{Layout as R,Legacy as D}from"../ui/index.js";import{LayoutCustomOwnerUi as T,LayoutCustomReadUi as P,LayoutDialog as A}from"../ui/phoenix-layout-elements/index.js";import{ConfiguratorNotFoundPage as O}from"./ConfiguratorNotFoundPage.js";import{DevContextFallback as V}from"./error-boundaries/DevContextFallback.js";import{DevLoadingFallback as q}from"./error-boundaries/DevLoadingFallback.js";import{LoadingErrorBoundary as z}from"./error-boundaries/LoadingErrorBoundary.js";import{useLoad as B}from"./use-load.js";let G=n(n=>{let{viewMode:t}=n,l=F();(()=>{let{assistantSystem:e}=U(),o=null!=L();a(()=>{if(o)return e.activate()},[e,o])})();let{ownerUi:u,readUi:m}=d(()=>s(l.layout).with("simple",()=>({ownerUi:e(D.SimpleOwnerLayout,{}),readUi:e(D.SummaryReadLayout,{})})).with("tabs",()=>({ownerUi:e(D.TabsOwnerLayout,{}),readUi:e(D.SummaryReadLayout,{})})).with("steps",()=>({ownerUi:e(D.StepsOwnerLayout,{}),readUi:e(D.SummaryReadLayout,{})})).with("universal",()=>({ownerUi:e(R,{}),readUi:e(R,{})})).with("custom",()=>({ownerUi:e(T,{}),readUi:e(P,{})})).exhaustive(),[l.layout]);return e(r,{children:o(S,{children:[t?m:u,"universal"===l.layout&&o(i,{children:[e(D.CommonFinalizePage,{}),e(A,{})]})]})})});export const LoadedConfiguratorDetailPage=()=>{I(u.SceneAssets);let{configurationId:i,accessInfo:r}=p(),n=v(),a=k(),d=b(),s=g(),{startConfiguratorLoad:L,completeConfiguratorLoad:U,failConfiguratorLoad:S,resetConfiguratorLoad:F}=j(),{isLoading:R,isError:D}=y(),T=h(),P=w(),A=t(()=>r.viewMode&&void 0!==r.revisionId?n.getConfigurationRevision(i,r.revisionId):n.getConfiguration(i),[r.revisionId,r.viewMode,n,i]),N=t(()=>{L()},[L]),H=t(e=>{U({initialRevisionId:e.revisionId,initialEntities:e.data,modelVersion:e.modelVersion,rootEntityType:e.rootEntityType,schemaIdentity:P}),s.push(m.ConfigurationLoaded(e.configurationId,e.revisionId,r.viewMode?"read":"owner")),d.appendToGlobalContext({configurationId:e.configurationId,revisionId:e.revisionId,mode:r.viewMode}),d.info("Configuration loaded.")},[r.viewMode,s,U,P,d]),J=t(e=>{if(S(e),e instanceof l)return void a.rejectAccessToken(i,r.raw);let o=e instanceof Error?e:Error("Configuration loading failed with an unknown error.",{cause:e});d.error("Configuration loading failed because the API request did not succeed. Verify the configuration ID and access token.",{configurationId:i},o)},[r.raw,i,S,d,a]),K=t(()=>{F()},[F]);return(B({key:[n,i,r.revisionId,r.viewMode],load:A,onStart:N,onSuccess:H,onError:J,onCleanup:K}),C({id:u.DataFetch,label:"Loading configuration…"},R),x(D),D)?e(O,{}):null===T?null:e(f,{value:T,children:e(z,{fallbackRender:o=>e(q,{...o}),children:e(c,{type:"configurator",children:e(z,{FallbackComponent:V,children:o(M,{children:[e(E,{}),e(G,{viewMode:r.viewMode})]})})})})})};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare const PerspectiveCameraDragEvent: () => import("
|
|
2
|
-
declare const OrthographicCameraDragEvent: () => import("
|
|
1
|
+
declare const PerspectiveCameraDragEvent: () => import("#package/domain").UserActionEvent;
|
|
2
|
+
declare const OrthographicCameraDragEvent: () => import("#package/domain").UserActionEvent;
|
|
3
3
|
export declare const SceneAnalyticsFactory: {
|
|
4
4
|
PerspectiveCameraDragEvent: typeof PerspectiveCameraDragEvent;
|
|
5
5
|
OrthographicCameraDragEvent: typeof OrthographicCameraDragEvent;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AssistantToolItem } from './thread-items.js';
|
|
2
|
+
export interface AssistantToolChipsProps {
|
|
3
|
+
readonly tools: readonly AssistantToolItem[];
|
|
4
|
+
/** True while the reply runs and this row is its newest block: the assistant is at work on it. */
|
|
5
|
+
readonly isActive: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A row of notes on what the assistant did in a reply, one per tool call. A click on a note logs
|
|
9
|
+
* the input and the result of its call to the console.
|
|
10
|
+
*/
|
|
11
|
+
export declare const AssistantToolChips: import("react").MemoExoticComponent<({ tools, isActive }: AssistantToolChipsProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as t,jsxs as e}from"react/jsx-runtime";import{Tooltip as a,styled as i}from"@mui/material";import{memo as s,useCallback as o}from"react";import{match as n}from"ts-pattern";import{useLocalizable as r}from"#package/react-sdk";import{PhxIcon as l}from"#package/ui-sdk";import{AssistantPanelName as d}from"./theme.js";let m={id:"sdk.assistant.tool.updateDesign.label",message:"Update design"},c={id:"sdk.assistant.tool.readDesign.label",message:"Read design"},p={id:"sdk.assistant.tool.mistake.hint",message:"The assistant made a mistake."},h={id:"sdk.assistant.tool.cancelled.hint",message:"Stopped before it finished."},g={id:"sdk.assistant.tool.noResult.hint",message:"The result of this step was lost. It may or may not have been done."},f={id:"sdk.assistant.tool.toolBudget.hint",message:"Not done: the assistant reached its limit of steps for one message."},u=i("div",{name:d,slot:"chips"})(({theme:{palette:t,spacing:e,typography:a}})=>({...a.caption,alignItems:"start",color:t.text.secondary,display:"grid",gap:e(.75),gridTemplateColumns:"min-content minmax(0, 1fr)"})),k=i("span",{name:d,slot:"activity"})(({theme:{typography:t}})=>({blockSize:`calc(${t.caption.lineHeight} * 1em)`,display:"grid",placeItems:"center"})),x=i(l,{name:d,slot:"activityIcon"})({fontSize:14,'[data-chips="active"] &':{animation:"phx-assistant-turn 2.4s linear infinite","@media (prefers-reduced-motion: reduce)":{animation:"none"}},"@keyframes phx-assistant-turn":{to:{rotate:"360deg"}}}),w=i("span",{name:d,slot:"chip"})(({theme:{palette:t,spacing:e}})=>({cursor:"default",display:"inline-block",whiteSpace:"nowrap","&:not(:last-child)::after":{color:t.text.secondary,content:'"\xb7"',display:"inline-block",marginInline:e(.75),textDecoration:"none"},'&[data-chip="failed"]':{color:t.error.main},'&[data-chip="flawed"]':{textDecoration:"line-through",textDecorationColor:t.error.main}})),y=s(({tool:e})=>{let{chip:i,input:s,result:l}=e,d=r(m),u=r(c),k=r(p),x=r(h),y=r(g),b=r(f),v=n(i.label).with({kind:"text"},({text:t})=>t).with({kind:"updateDesign"},()=>d).with({kind:"readDesign"},()=>u).exhaustive(),C=o(()=>{console.info(`Assistant tool call "${v}"`,{input:s,result:l})},[s,v,l]);return t(a,{title:n(i).with({errorCode:"cancelled"},()=>x).with({errorCode:"no_result"},()=>y).with({errorCode:"tool_budget"},()=>b).with({state:"failed"},{state:"flawed"},()=>k).otherwise(()=>""),placement:"top-start",children:t(w,{onClick:C,"data-chip":i.state,children:v})})});export const AssistantToolChips=s(({tools:a,isActive:i})=>e(u,{"data-chips":i?"active":"done","aria-busy":i,children:[t(k,{children:t(x,{name:"Gear"})}),t("div",{children:a.map(e=>t(y,{tool:e},e.id))})]}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The message input of the panel. Enter sends and Shift+Enter adds a line. While a reply runs the
|
|
3
|
+
* send control is a Stop control and the input stays editable, so the next message can be written.
|
|
4
|
+
* A thread this session may not continue disables the input and says why.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AssistantComposer: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import{Trans as i}from"@lingui/react";import{IconButton as o,InputBase as r,Tooltip as t,styled as n}from"@mui/material";import{useCallback as s,useRef as d,useState as l}from"react";import{useEagerObservableSelector as m,useLocalizable as c}from"#package/react-sdk";import{PhxIcon as p,useResponsive as u}from"#package/ui-sdk";import{useConfigurator as b}from"../../application-runtime/index.js";import{AssistantPanelName as g}from"./theme.js";let h={id:"sdk.assistant.composer.placeholder",message:"Ask or tell me what to change…"},k={id:"sdk.assistant.composer.send.label",message:"Send"},f={id:"sdk.assistant.composer.stop.label",message:"Stop"},x=n("form",{name:g,slot:"composer"})(({theme:{palette:e,spacing:a}})=>({borderBlockStart:`1px solid ${e.divider}`,display:"grid",gap:a(.75),paddingBlock:a(1.25),paddingInline:`var(--phx-sidebar-padding, ${a(2)})`})),y=n("div",{name:g,slot:"inputFrame"})(({theme:{palette:e,spacing:a}})=>({alignItems:"flex-end",border:`1px solid ${e.divider}`,borderRadius:12,display:"flex",gap:a(1),paddingBlock:a(.5),paddingInline:`${a(1.5)} ${a(.5)}`,"&:focus-within":{borderColor:e.primary.main},"&:has(textarea:disabled)":{background:e.action.disabledBackground}})),v=n(r,{name:g,slot:"input"})(({theme:{spacing:e,typography:a}})=>({...a.body2,flex:1,paddingBlock:e(.75)})),B=n(o,{name:g,slot:"sendButton"})(({theme:{palette:e}})=>({background:e.primary.main,borderRadius:8,color:e.primary.contrastText,"&:hover":{background:e.primary.dark},"&.Mui-disabled":{background:e.action.disabledBackground,color:e.action.disabled}})),C=n(o,{name:g,slot:"stopButton"})(({theme:{palette:e}})=>({background:e.text.primary,borderRadius:8,color:e.background.paper,"&:hover":{background:e.text.secondary}})),R=n("span")({background:"currentColor",blockSize:10,borderRadius:2,inlineSize:10,margin:5}),S=n("div",{name:g,slot:"hint"})(({theme:{palette:e,typography:a}})=>({...a.caption,color:e.text.secondary}));export const AssistantComposer=()=>{let{assistantSystem:o}=b(),[r,n]=l(""),g=d(null),{isDesktop:I}=u(),$=c(h),j=c(k),w=c(f),{isReplying:z,isContinuable:F}=m(o.chat$,e=>({isReplying:e.isLoading,isContinuable:e.isContinuable}),[]),A=r.trim(),D=F&&!z&&A.length>0,P=s(()=>{D&&(n(""),o.send(A),I||g.current?.blur())},[o,D,A,I]),T=s(e=>{e.preventDefault(),P()},[P]),E=s(e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),P())},[P]),K=s(()=>{o.stop()},[o]);return a(x,{onSubmit:T,children:[!F&&e(S,{role:"status",children:e(i,{id:"sdk.assistant.composer.notContinuable",message:"This conversation can be read here, but it can no longer be continued."})}),a(y,{children:[e(v,{multiline:!0,maxRows:6,placeholder:$,value:r,disabled:!F,inputRef:g,onChange:e=>n(e.target.value),onKeyDown:E,onFocus:()=>o.setInputFocused(!0),onBlur:()=>o.setInputFocused(!1),inputProps:{"aria-label":$}}),z?e(t,{title:w,placement:"top",children:e(C,{size:"small","aria-label":w,onClick:K,children:e(R,{})})}):e(t,{title:j,placement:"top",children:e("span",{children:e(B,{type:"submit",size:"small","aria-label":j,disabled:!D,children:e(p,{name:"PaperPlaneRightBold",fontSize:"small"})})})})]}),e(S,{children:e(i,{id:"sdk.assistant.composer.disclaimer",message:"AI can be wrong. Check the result."})})]})};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface AssistantMarkdownProps {
|
|
2
|
+
readonly markdown: string;
|
|
3
|
+
/** True while the text is still arriving, so markup the model has not finished is completed. */
|
|
4
|
+
readonly isStreaming: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** Assistant text of the thread: Markdown with lists, tables, links and code, without a bubble. */
|
|
7
|
+
export declare const AssistantMarkdown: import("react").MemoExoticComponent<({ markdown, isStreaming }: AssistantMarkdownProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{styled as e}from"@mui/material";import{memo as o}from"react";import a from"react-markdown";import i from"remark-gfm";import{completeStreamedMarkdown as n}from"./streamed-markdown.js";import{AssistantPanelName as t}from"./theme.js";let l=e("div",{name:t,slot:"assistantMessage"})(({theme:{palette:r,shape:e,spacing:o,typography:a}})=>({overflowWrap:"anywhere","& > :first-child":{marginBlockStart:0},"& > :last-child":{marginBlockEnd:0},"p, ul, ol, pre, blockquote":{marginBlock:o(1)},"h1, h2, h3, h4, h5, h6":{...a.subtitle2,marginBlock:o(1.5,.5)},"ul, ol":{paddingInlineStart:o(2.5)},a:{color:r.primary.main},code:{background:r.action.hover,borderRadius:e.borderRadius/2,fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.9em",paddingInline:o(.5)},pre:{background:r.action.hover,borderRadius:e.borderRadius,overflowX:"auto",padding:o(1),code:{background:"none",padding:0}},blockquote:{borderInlineStart:`2px solid ${r.divider}`,color:r.text.secondary,marginInline:0,paddingInlineStart:o(1.5)},"th, td":{borderBlockEnd:`1px solid ${r.divider}`,padding:o(.5,1),textAlign:"start",verticalAlign:"top"}})),d=e("div")({overflowX:"auto",table:{borderCollapse:"collapse",inlineSize:"100%"}}),m={a:({node:e,children:o,...a})=>r("a",{...a,target:"_blank",rel:"noopener noreferrer",children:o}),table:({node:e,children:o,...a})=>r(d,{children:r("table",{...a,children:o})})},s=[i],c=["img"];export const AssistantMarkdown=o(({markdown:e,isStreaming:o})=>r(l,{children:r(a,{components:m,remarkPlugins:s,disallowedElements:c,children:o?n(e):e})}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The attribute the panel carries on its root. The layouts key their styles on it: what the panel
|
|
3
|
+
* covers is hidden, and a sidebar shorter than its slot is stretched to the height the panel needs.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ASSISTANT_PANEL_SLOT = "slot[assistant]";
|
|
6
|
+
/**
|
|
7
|
+
* The built-in assistant panel: a header with the title and a close control, the thread and the
|
|
8
|
+
* composer. It covers the sidebar it is rendered in, and renders nothing while it is closed or when
|
|
9
|
+
* the application spec has no `assistant` section.
|
|
10
|
+
*/
|
|
11
|
+
export declare const AssistantPanel: () => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{IconButton as s,Tooltip as a,Typography as i,styled as n}from"@mui/material";import{useCallback as r}from"react";import{useLocalizable as o}from"#package/react-sdk";import{PhxIcon as l}from"#package/ui-sdk";import{useConfigurator as m}from"../../application-runtime/index.js";import{AssistantComposer as d}from"./AssistantComposer.js";import{AssistantThread as p}from"./AssistantThread.js";import{AssistantPanelName as c}from"./theme.js";import{useIsAssistantPanelOpen as u}from"./use-is-assistant-panel-open.js";let b={id:"sdk.assistant.panel.title",message:"Assistant"},f={id:"sdk.assistant.panel.close.label",message:"Close assistant"};export const ASSISTANT_PANEL_SLOT="slot[assistant]";let g=n("section",{name:c,slot:"root"})(({theme:{palette:e}})=>({background:`var(--phx-sidebar-background, ${e.background.paper})`,border:"var(--phx-sidebar-border, 0)",borderRadius:"inherit",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gridTemplateRows:"min-content minmax(0, 1fr) min-content",inset:0,overflow:"hidden",position:"absolute",zIndex:1})),h=n("header",{name:c,slot:"header"})(({theme:{palette:e,spacing:t}})=>({alignItems:"center",borderBlockEnd:`1px solid ${e.divider}`,display:"flex",gap:t(1),justifyContent:"space-between",paddingBlock:t(1),paddingInline:`var(--phx-sidebar-padding, ${t(2)}) ${t(1)}`})),x=n(i,{name:c,slot:"title"})({fontWeight:600}),k=n(s,{name:c,slot:"closeButton"})({}),j=e=>{e.target instanceof Element&&e.target.closest("button")&&e.preventDefault()};export const AssistantPanel=()=>{let{assistantSystem:s}=m(),i=u(),n=o(b),c=o(f),v=r(()=>{s.setOpen(!1)},[s]);return i?t(g,{"data-sidebar":"slot[assistant]","aria-label":n,onMouseDown:j,children:[t(h,{children:[e(x,{variant:"subtitle1",component:"h2",children:n}),e(a,{title:c,placement:"top",children:e(k,{size:"small","aria-label":c,onClick:v,children:e(l,{name:"X"})})})]}),e(p,{}),e(d,{})]}):null};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The conversation: user bubbles, assistant Markdown, tool chips, and what the panel
|
|
3
|
+
* has to say itself, which is a greeting for an empty thread, a "Thinking…" line and a failure with
|
|
4
|
+
* its way out. It follows a streaming reply until the user scrolls up.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AssistantThread: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as i}from"react/jsx-runtime";import{Trans as a}from"@lingui/react";import{Button as t,styled as s}from"@mui/material";import{useMemo as r}from"react";import{match as n}from"ts-pattern";import{useEagerObservableValue as o}from"#package/react-sdk";import{PhxIcon as l}from"#package/ui-sdk";import{useConfigurator as d}from"../../application-runtime/index.js";import{AssistantToolChips as m}from"./AssistantChips.js";import{AssistantMarkdown as p}from"./AssistantMarkdown.js";import{describeAssistantFailure as c}from"./assistant-failure.js";import{AssistantPanelName as h}from"./theme.js";import{buildThreadView as g}from"./thread-items.js";import{useFollowStream as u}from"./use-follow-stream.js";let f=s("div",{name:h,slot:"thread"})({display:"grid",position:"relative"}),k=s("div",{name:h,slot:"messages"})(({theme:{spacing:e,typography:i}})=>({...i.body2,display:"flex",flexDirection:"column",gap:e(1.5),overflowY:"auto",overscrollBehavior:"contain",paddingBlock:e(2),paddingInline:`var(--phx-sidebar-padding, ${e(2)})`,"& > :first-child":{marginBlockStart:"auto"}})),v=s("div",{name:h,slot:"userMessage"})(({theme:{palette:e,spacing:i}})=>({alignSelf:"flex-end",background:`hsl(from ${e.primary.main} h s l / 12%)`,borderRadius:"14px 14px 4px 14px",maxInlineSize:"85%",overflowWrap:"anywhere",paddingBlock:i(1),paddingInline:i(1.5),whiteSpace:"pre-wrap"})),w=s("div",{name:h,slot:"greeting"})({}),b=s("div",{name:h,slot:"status"})(({theme:{palette:e,typography:i}})=>({...i.caption,color:e.text.secondary})),x=s("div",{name:h,slot:"notice"})(({theme:{palette:e,shape:i,spacing:a}})=>({alignItems:"center",background:e.action.hover,borderRadius:i.borderRadius,display:"flex",flexWrap:"wrap",gap:a(1),justifyContent:"space-between",paddingBlock:a(1),paddingInline:a(1.5)})),y=s(t,{name:h,slot:"newReplyButton"})(({theme:{palette:e,spacing:i}})=>({background:e.text.primary,borderRadius:"calc(infinity * 1px)",color:e.background.paper,insetBlockEnd:i(1),insetInlineStart:"50%",position:"absolute",translate:"-50% 0","&:hover":{background:e.text.secondary}})),j=({item:i,isActive:a})=>n(i).with({kind:"user"},({text:i})=>e(v,{children:i})).with({kind:"text"},({markdown:i,isStreaming:a})=>e(p,{markdown:i,isStreaming:a})).with({kind:"tools"},({tools:i})=>e(m,{tools:i,isActive:a})).exhaustive();export const AssistantThread=()=>{let{assistantSystem:s}=d(),m=o(s.chat$),{messages:p,isLoading:h}=m,{items:v,isThinking:T}=r(()=>g(p,h),[p,h]),I=r(()=>v.filter(({kind:e})=>"user"===e).length,[v]),S=m.error?c(m.failedStatus):void 0,{scrollerRef:A,hasUnseenContent:B,handleScroll:R,scrollToEnd:C}=u(r(()=>({messages:p,isThinking:T,failure:S?.kind}),[p,T,S?.kind]),I);return i(f,{children:[i(k,{ref:A,onScroll:R,role:"log","aria-live":"polite",children:[m.isLoaded&&0===v.length&&!h&&!S&&e(w,{children:e(a,{id:"sdk.assistant.thread.greeting",message:"Hi. I can answer questions about this design and change it with you. Tell me what you need."})}),v.map(i=>e(j,{item:i,isActive:h&&i===v.at(-1)},i.id)),T&&e(b,{children:e(a,{id:"sdk.assistant.thread.thinking",message:"Thinking…"})}),S&&i(x,{role:"alert",children:[e("span",{children:n(S.kind).with("notAvailable",()=>e(a,{id:"sdk.assistant.failure.notAvailable",message:"The assistant is not available here."})).with("busy",()=>e(a,{id:"sdk.assistant.failure.busy",message:"The assistant is still working on an earlier message."})).with("unavailable",()=>e(a,{id:"sdk.assistant.failure.unavailable",message:"The assistant is unavailable right now."})).exhaustive()}),S.canRetry&&e(t,{size:"small",variant:"outlined",color:"inherit",onClick:s.reloadThread,children:e(a,{id:"sdk.assistant.failure.retry.label",message:"Try again"})})]})]}),B&&e(y,{size:"small",onClick:C,endIcon:e(l,{name:"CaretDown"}),children:e(a,{id:"sdk.assistant.thread.newReply.label",message:"New reply"})})]})};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the panel tells the user when the assistant failed:
|
|
3
|
+
* - `notAvailable`: the server refuses this configuration or customer, and asking again will not help
|
|
4
|
+
* - `busy`: the server is still answering an earlier message of this thread
|
|
5
|
+
* - `unavailable`: anything else, including a dropped connection and a reply that broke off
|
|
6
|
+
*/
|
|
7
|
+
export type AssistantFailureKind = 'notAvailable' | 'busy' | 'unavailable';
|
|
8
|
+
export interface AssistantFailure {
|
|
9
|
+
readonly kind: AssistantFailureKind;
|
|
10
|
+
/** True when loading the thread again may help, so the panel offers "Try again". */
|
|
11
|
+
readonly canRetry: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Maps a failed assistant request to what the panel shows, by the HTTP status the server answered
|
|
15
|
+
* with. A failure without a status never reached the server or broke off mid-reply; it gets the same
|
|
16
|
+
* generic message as an unknown status, because the chat client does not tell those apart.
|
|
17
|
+
*/
|
|
18
|
+
export declare const describeAssistantFailure: (failedStatus: number | undefined) => AssistantFailure;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const describeAssistantFailure=a=>403===a?{kind:"notAvailable",canRetry:!1}:409===a?{kind:"busy",canRetry:!0}:{kind:"unavailable",canRetry:!0};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{AssistantPanel,ASSISTANT_PANEL_SLOT}from"./AssistantPanel.js";export{useIsAssistantPanelOpen}from"./use-is-assistant-panel-open.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes the Markdown of a reply that is still streaming renderable as it stands, so half-written
|
|
3
|
+
* markup does not flash as raw characters: an open code fence is closed, an inline code span, a link
|
|
4
|
+
* or a table header the model has not finished is held back, and open bold text is closed.
|
|
5
|
+
*/
|
|
6
|
+
export declare const completeStreamedMarkdown: (text: string) => string;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let e=(e,t)=>e.split(t).length-1,t=/^\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;export const completeStreamedMarkdown=l=>{if(e(l,"```")%2==1)return`${l}
|
|
2
|
+
\`\`\``;let n=l.lastIndexOf("```"),s=-1===n?"":l.slice(0,n+3),r=l.slice(s.length),i=(e=>{let l=e.split("\n"),n=l.length;for(;n>0&&l[n-1]?.trimStart().startsWith("|");)n-=1;let s=l.slice(n),r=s[1],i=null!=r&&s.length>2&&t.test(r);return 0===s.length||i?e:l.slice(0,n).join("\n")})((e(r,"`")%2==1?r.slice(0,r.lastIndexOf("`")):r).replace(/!?\[([^\]\n]*)\]\([^)\n]*$/,"$1").replace(/!?\[[^\]\n]*$/,"")),c=e(i,"**")%2==1?`${i}**`:i;return`${s}${c}`};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const AssistantPanelName="PhxAssistantPanel";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { UIMessage } from '@tanstack/ai-client';
|
|
2
|
+
import { type AssistantToolChip } from './tool-chip.js';
|
|
3
|
+
/** A tool call of the thread, with what its chip shows and what a click on the chip logs. */
|
|
4
|
+
export interface AssistantToolItem {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly chip: AssistantToolChip;
|
|
7
|
+
readonly input: unknown;
|
|
8
|
+
readonly result: unknown;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* One block of the thread, in reading order: a user bubble, a stretch of assistant Markdown, or a
|
|
12
|
+
* row of chips for the tool calls that follow each other without text in between.
|
|
13
|
+
*/
|
|
14
|
+
export type AssistantThreadItem = {
|
|
15
|
+
readonly kind: 'user';
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly text: string;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: 'text';
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly markdown: string;
|
|
22
|
+
readonly isStreaming: boolean;
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: 'tools';
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly tools: readonly AssistantToolItem[];
|
|
27
|
+
};
|
|
28
|
+
export interface AssistantThreadView {
|
|
29
|
+
readonly items: readonly AssistantThreadItem[];
|
|
30
|
+
/** True while a reply runs and neither streaming text nor a row of tool chips shows that it does. */
|
|
31
|
+
readonly isThinking: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Lays the messages of the chat out as the blocks the thread renders. Reasoning is left out; tool
|
|
35
|
+
* results are not shown on their own but decide the state of the chip of their call.
|
|
36
|
+
*/
|
|
37
|
+
export declare const buildThreadView: (messages: ReadonlyArray<UIMessage>, isReplying: boolean) => AssistantThreadView;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{describeToolCall as t}from"./tool-chip.js";let e=t=>{try{return JSON.parse(t)}catch{return t}},r=t=>t.map(t=>"text"===t.type?t.content:"").join("").trim();export const buildThreadView=(o,n)=>{let l=(t=>{let r=new Map;for(let o of t)for(let t of o.parts)"tool-result"===t.type&&r.set(t.toolCallId,{result:"string"==typeof t.content?e(t.content):t.content,error:"error"===t.state?t.error??"The tool call failed.":void 0});return r})(o),i=[],s=o.at(-1),a=t=>{let e=i.at(-1);e?.kind==="tools"?i[i.length-1]={...e,tools:[...e.tools,t]}:i.push({kind:"tools",id:t.id,tools:[t]})};for(let e of o){if("user"===e.role){let t=r(e.parts);t&&i.push({kind:"user",id:e.id,text:t});continue}let o=n&&e===s;e.parts.forEach((r,n)=>{let s=`${e.id}:${n}`;if("text"===r.type){if(r.content.trim()){let t=o&&n===e.parts.length-1;i.push({kind:"text",id:s,markdown:r.content,isStreaming:t})}return}if("tool-call"!==r.type)return;let p=l.get(r.id),d=r.input,u=r.output??p?.result;a({id:r.id,input:d,result:u,chip:t({name:r.name,input:d,result:u,error:p?.error,isReplyRunning:o})})})}let p=i.at(-1),d=s?.role==="assistant"&&(p?.kind==="text"&&p.isStreaming||p?.kind==="tools");return{items:i,isThinking:n&&!d}};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type AssistantToolErrorCode } from '@salsita-ai/contracts/assistant';
|
|
2
|
+
/**
|
|
3
|
+
* How a tool call of the assistant looks in the thread: still running, finished, a change that was
|
|
4
|
+
* not kept (`failed`), or a read that answered with errors (`flawed`), which matters less because
|
|
5
|
+
* the assistant usually just asks again.
|
|
6
|
+
*/
|
|
7
|
+
export type AssistantToolChipState = 'running' | 'done' | 'failed' | 'flawed';
|
|
8
|
+
/** What a tool chip is called: the operation names the model gave, a fixed text, or the tool's name. */
|
|
9
|
+
export type AssistantToolChipLabel = {
|
|
10
|
+
readonly kind: 'text';
|
|
11
|
+
readonly text: string;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'updateDesign';
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: 'readDesign';
|
|
16
|
+
};
|
|
17
|
+
export interface AssistantToolChip {
|
|
18
|
+
readonly label: AssistantToolChipLabel;
|
|
19
|
+
readonly state: AssistantToolChipState;
|
|
20
|
+
/**
|
|
21
|
+
* Why the server recorded an error in place of the call's result, when it said so with a code this
|
|
22
|
+
* panel knows. Nothing for a call that went wrong for any other reason.
|
|
23
|
+
*/
|
|
24
|
+
readonly errorCode: AssistantToolErrorCode | undefined;
|
|
25
|
+
}
|
|
26
|
+
/** A tool call of a message as the chip reads it. */
|
|
27
|
+
export interface AssistantToolCall {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
/** The parsed input of the call; nothing while the model is still writing it. */
|
|
30
|
+
readonly input: unknown;
|
|
31
|
+
/** The result of the call, parsed from JSON; nothing while there is none. */
|
|
32
|
+
readonly result: unknown;
|
|
33
|
+
/** The error text of a call the chat client could not run. */
|
|
34
|
+
readonly error: string | undefined;
|
|
35
|
+
/** True while the reply this call belongs to is still running. */
|
|
36
|
+
readonly isReplyRunning: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Describes one tool call for its chip: the label in the order operation names, fixed text for the
|
|
40
|
+
* `apply` and `query` tools, tool name; and whether the call runs, finished, or went wrong. Why it
|
|
41
|
+
* went wrong is part of it only as the code of an error the server recorded: the text of a tool
|
|
42
|
+
* result is worded for the model, not for the user.
|
|
43
|
+
*/
|
|
44
|
+
export declare const describeToolCall: (call: AssistantToolCall) => AssistantToolChip;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Kind as e,parse as t}from"graphql";import{z as n}from"zod";import{ASSISTANT_TOOL_ERROR_CODES as r,AssistantToolError as a,applyTool as i,queryTool as o}from"@salsita-ai/contracts/assistant";let l=n.object({operations:n.array(n.object({query:n.string(),operationName:n.string().nullish()}))}),s=n.object({results:n.array(n.object({errors:n.array(n.unknown()).optional()})),committed:n.boolean()});export const describeToolCall=n=>{let d=(({name:n,input:r})=>{let a,s=(a=l.safeParse(r)).success?a.data.operations.flatMap(({query:n,operationName:r})=>r??(n=>{try{let r=t(n).definitions.find(t=>t.kind===e.OPERATION_DEFINITION);return r?.kind===e.OPERATION_DEFINITION?r.name?.value:void 0}catch{return}})(n)??[]):[];return s.length>0?{kind:"text",text:s.join(", ")}:n===i.name?{kind:"updateDesign"}:n===o.name?{kind:"readDesign"}:{kind:"text",text:n}})(n);if(null==n.result&&null==n.error)return{label:d,state:n.isReplyRunning?"running":"done",errorCode:void 0};let u=(e=>{let t=a.safeParse(e);if(t.success)return r.find(e=>e===t.data.code)})(n.result);return{label:d,state:(({name:e,result:t,error:n},r)=>{if(null!=n||null!=r)return e===o.name?"flawed":"failed";if(e!==i.name&&e!==o.name)return"done";let a=s.safeParse(t);if(!a.success)return e===o.name?"flawed":"failed";let{results:l,committed:d}=a.data;return e===i.name?d?"done":"failed":l.some(({errors:e})=>(e?.length??0)>0)||0===l.length?"flawed":"done"})(n,u),errorCode:u}};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
export interface FollowStream<ELEMENT extends HTMLElement> {
|
|
3
|
+
readonly scrollerRef: RefObject<ELEMENT>;
|
|
4
|
+
/** True when content arrived while the user was reading further up. */
|
|
5
|
+
readonly hasUnseenContent: boolean;
|
|
6
|
+
readonly handleScroll: () => void;
|
|
7
|
+
readonly scrollToEnd: () => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Keeps a scrolling thread at its end while content arrives, until the user scrolls up; from then on
|
|
11
|
+
* it only reports that there is unseen content, and follows again once the user is back at the end.
|
|
12
|
+
*
|
|
13
|
+
* @param content changes whenever the thread's content does
|
|
14
|
+
* @param followKey changes when the thread must return to its end whatever the user did, such as
|
|
15
|
+
* when the user sends a message
|
|
16
|
+
*/
|
|
17
|
+
export declare const useFollowStream: <ELEMENT extends HTMLElement>(content: unknown, followKey: unknown) => FollowStream<ELEMENT>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as r,useEffect as e,useLayoutEffect as t,useRef as l,useState as c}from"react";export const useFollowStream=(o,n)=>{let s=l(null),u=l(!0),[i,g]=c(!1),h=r(()=>{let r=s.current;u.current=!0,g(!1),r&&(r.scrollTop=r.scrollHeight)},[]),H=r(()=>{let r=s.current;r&&(u.current=r.scrollHeight-r.scrollTop-r.clientHeight<=24,u.current&&g(!1))},[]);return t(()=>{h()},[n,h]),t(()=>{let r=s.current;r&&(u.current?r.scrollTop=r.scrollHeight:r.scrollHeight>r.clientHeight&&g(!0))},[o]),e(()=>{let r=s.current;if(!r)return;let e=new ResizeObserver(()=>{u.current&&(r.scrollTop=r.scrollHeight)});return e.observe(r),()=>{e.disconnect()}},[]),{scrollerRef:s,hasUnseenContent:i,handleScroll:H,scrollToEnd:h}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useEagerObservableSelector as e,useSpecAssistant as n}from"#package/react-sdk";import{useConfigurator as t}from"../../application-runtime/index.js";export const useIsAssistantPanelOpen=()=>{let{assistantSystem:p}=t(),r=n();return e(p.panel$,e=>e.open,[])&&null!=r};
|