@salsita-ai/sdk 0.50.0-develop.8c8c362f86 → 0.50.0-develop.8e3768cb11
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/dist/application-spec/core/components/component-filter.d.ts +53 -0
- package/dist/application-spec/core/components/component-filter.js +1 -0
- package/dist/application-spec/core/components/index.d.ts +2 -0
- package/dist/application-spec/core/components/index.js +1 -0
- package/dist/application-spec/core/components/sdk-code-ref.d.ts +9 -0
- package/dist/application-spec/core/components/sdk-code-ref.js +1 -0
- package/dist/application-spec/core/enhanced-json-value.d.ts +0 -68
- package/dist/application-spec/core/enhanced-json-value.js +1 -1
- package/dist/application-spec/core/expressions/index.d.ts +2 -0
- package/dist/application-spec/core/expressions/index.js +1 -0
- package/dist/application-spec/core/expressions/relation-expression-params.d.ts +11 -0
- package/dist/application-spec/core/expressions/relation-expression-params.js +1 -0
- package/dist/application-spec/core/expressions/sdk-expression-implementation.d.ts +24 -0
- package/dist/application-spec/core/expressions/sdk-expression-implementation.js +1 -0
- package/dist/application-spec/core/index.d.ts +2 -0
- package/dist/application-spec/core/index.js +1 -1
- package/dist/application-spec/core/json-value.d.ts +1 -1
- package/dist/application-spec/{core → enhanced-json}/eval-to-constant.d.ts +1 -1
- package/dist/application-spec/enhanced-json/index.d.ts +4 -0
- package/dist/application-spec/enhanced-json/index.js +1 -0
- package/dist/application-spec/enhanced-json/is-enhanced-json-array.d.ts +2 -0
- package/dist/application-spec/enhanced-json/is-enhanced-json-array.js +1 -0
- package/dist/application-spec/enhanced-json/resolve-enhanced-json-value.d.ts +18 -0
- package/dist/application-spec/enhanced-json/resolve-enhanced-json-value.js +1 -0
- package/dist/application-spec/enhanced-json/schema-from-value.d.ts +24 -0
- package/dist/application-spec/enhanced-json/schema-from-value.js +1 -0
- package/dist/application-spec/enhanced-json/stringify-enhanced-json-value.d.ts +14 -0
- package/dist/application-spec/enhanced-json/stringify-enhanced-json-value.js +1 -0
- package/dist/application-spec/enhanced-json/validate-enhanced-json-value-caps.d.ts +12 -0
- package/dist/application-spec/enhanced-json/validate-enhanced-json-value-caps.js +1 -0
- package/dist/application-spec/enhanced-json/validate-no-legacy-code-ref.d.ts +13 -0
- package/dist/application-spec/enhanced-json/validate-no-legacy-code-ref.js +1 -0
- package/dist/application-spec/generate-application/code/generate-application-code.d.ts +3 -2
- package/dist/application-spec/generate-application/code/generate-application-code.js +1 -1
- package/dist/application-spec/generate-application/code/project-scaffolding.d.ts +9 -4
- package/dist/application-spec/generate-application/code/project-scaffolding.js +2 -2
- package/dist/application-spec/generate-application/code/standalone-app-files.d.ts +2 -2
- package/dist/application-spec/generate-application/code/standalone-app-files.js +1 -1
- package/dist/application-spec/generate-application/code/templates/configurator-config.js +6 -4
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-component-optics.js +4 -4
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-defaults.js +1 -1
- package/dist/application-spec/generate-application/code/templates/gitignore.js +1 -2
- package/dist/application-spec/generate-application/code/templates/index.d.ts +1 -1
- package/dist/application-spec/generate-application/code/templates/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/package-json.js +1 -1
- package/dist/application-spec/generate-application/code/templates/root-tsconfig.d.ts +6 -0
- package/dist/application-spec/generate-application/code/templates/root-tsconfig.js +2 -0
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +10 -4
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +2 -2
- package/dist/application-spec/generate-application/code/templates/tsconfig.d.ts +5 -0
- package/dist/application-spec/generate-application/code/templates/tsconfig.js +1 -1
- package/dist/application-spec/generate-application/code/templates/webhook-index.d.ts +6 -1
- package/dist/application-spec/generate-application/code/templates/webhook-index.js +10 -1
- package/dist/application-spec/generate-application/index.d.ts +2 -0
- package/dist/application-spec/generate-application/index.js +1 -1
- package/dist/application-spec/generate-application/runtime/admin-runtime/admin-runtime.d.ts +6 -2
- package/dist/application-spec/generate-application/runtime/admin-runtime/admin-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/application-runtime.d.ts +8 -1
- package/dist/application-spec/generate-application/runtime/application-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.d.ts +5 -1
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/factory-data/factory-data-runtime.d.ts +43 -0
- package/dist/application-spec/generate-application/runtime/factory-data/factory-data-runtime.js +1 -0
- package/dist/application-spec/generate-application/runtime/factory-data/index.d.ts +3 -0
- package/dist/application-spec/generate-application/runtime/factory-data/index.js +1 -0
- package/dist/application-spec/generate-application/runtime/factory-data/recipe-defaults.d.ts +13 -0
- package/dist/application-spec/generate-application/runtime/factory-data/recipe-defaults.js +1 -0
- package/dist/application-spec/generate-application/runtime/factory-data/static-violations.d.ts +16 -0
- package/dist/application-spec/generate-application/runtime/factory-data/static-violations.js +1 -0
- package/dist/application-spec/generate-application/runtime/migrations/index.d.ts +1 -0
- package/dist/application-spec/generate-application/runtime/migrations/index.js +1 -0
- package/dist/application-spec/generate-application/runtime/migrations/migration-runtime.d.ts +53 -0
- package/dist/application-spec/generate-application/runtime/migrations/migration-runtime.js +1 -0
- package/dist/application-spec/generate-application/runtime/sections/build-sdk-optic.d.ts +1 -1
- package/dist/application-spec/generate-application/runtime/sections/build-sdk-optic.js +1 -1
- package/dist/application-spec/generate-application/runtime/sections/expression-runtime.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 +16 -0
- package/dist/application-spec/parse-application-files/categorize/categorize-files.js +1 -1
- package/dist/application-spec/parse-application-files/categorize/earlier-generated-tsconfig.d.ts +9 -0
- package/dist/application-spec/parse-application-files/categorize/earlier-generated-tsconfig.js +1 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.js +1 -1
- package/dist/application-spec/parse-application-files/spec/components/component-entry.d.ts +1 -9
- package/dist/application-spec/parse-application-files/spec/components/component-entry.js +1 -1
- package/dist/application-spec/parse-application-files/spec/components/component-filter.d.ts +1 -54
- package/dist/application-spec/parse-application-files/spec/components/component-filter.js +1 -1
- package/dist/application-spec/parse-application-files/spec/components/index.d.ts +1 -1
- package/dist/application-spec/parse-application-files/spec/components/index.js +1 -1
- package/dist/application-spec/parse-application-files/spec/expressions/expression.d.ts +1 -28
- package/dist/application-spec/parse-application-files/spec/expressions/expression.js +1 -1
- package/dist/application-spec/parse-application-files/spec/expressions/expressions.d.ts +1 -1
- package/dist/application-spec/parse-application-files/spec/expressions/expressions.js +1 -1
- package/dist/application-spec/parse-application-files/spec/expressions/index.d.ts +0 -1
- package/dist/application-spec/parse-application-files/spec/expressions/index.js +1 -1
- package/dist/application-spec/parse-application-files/spec/expressions/memo-eval-plan.js +1 -1
- package/dist/application-spec/parse-application-files/spec/expressions/user-expressions.js +1 -1
- package/dist/application-spec/parse-application-files/spec/model/defaults.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +29 -0
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +7 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/drag-and-drop-system/drag-and-drop-system.d.ts +3 -3
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +6 -0
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.d.ts +2 -2
- package/dist/configurator/common/configurator-interface.d.ts +22 -1
- package/dist/configurator/common/configurator-interface.js +1 -1
- package/dist/configurator/common/frontend-analytics.d.ts +2 -0
- package/dist/configurator/common/frontend-analytics.js +1 -1
- package/dist/configurator/common/index.d.ts +2 -0
- package/dist/configurator/common/index.js +1 -1
- package/dist/configurator/common/use-finalize-action.d.ts +31 -0
- package/dist/configurator/common/use-finalize-action.js +1 -0
- package/dist/configurator/common/use-reset-camera.d.ts +6 -0
- package/dist/configurator/common/use-reset-camera.js +1 -0
- package/dist/configurator/configurator-context/configurator-hooks/layout-hooks.d.ts +1 -1
- package/dist/configurator/pages/DefaultConfiguratorLayout.d.ts +2 -2
- package/dist/configurator/pages/LoadedConfiguratorDetailPage.js +1 -1
- package/dist/configurator/pages/configurator-layout-name.d.ts +2 -0
- package/dist/configurator/pages/configurator-layout-name.js +1 -0
- package/dist/configurator/pages/default-configurator-elements.d.ts +7 -0
- package/dist/configurator/pages/default-configurator-elements.js +1 -0
- package/dist/configurator/pages/index.d.ts +1 -0
- package/dist/configurator/pages/index.js +1 -1
- package/dist/configurator/scene/scene-controls/hotspot-drag-handle/HotspotDragHandle.d.ts +1 -1
- package/dist/configurator/scene/scene-controls/hotspot-drag-handle/HotspotDragSceneHandle.d.ts +1 -1
- package/dist/configurator/scene/scene-entity/dimension-indicators/DimensionIndicator.d.ts +1 -1
- package/dist/configurator/scene/scene-entity/dimension-indicators/DimensionIndicatorInternal.d.ts +1 -1
- package/dist/configurator/scene/scene-entity/drag-and-drop/shared.d.ts +2 -2
- package/dist/configurator/scene/scene-entity/drag-and-drop/use-drag-object.d.ts +1 -1
- package/dist/configurator/scene/scene-entity/materials/RemoteReplacedMaterial.js +1 -1
- package/dist/configurator/scene/scene-entity/objects/SceneEntityObjectTextDecal.d.ts +1 -1
- package/dist/configurator/ui/assistant/AssistantChips.d.ts +8 -2
- package/dist/configurator/ui/assistant/AssistantChips.js +1 -1
- package/dist/configurator/ui/assistant/AssistantMarkdown.d.ts +1 -1
- package/dist/configurator/ui/assistant/AssistantMarkdown.js +1 -1
- package/dist/configurator/ui/assistant/AssistantThread.js +1 -1
- package/dist/configurator/ui/assistant/entity-link/AssistantEntityLink.d.ts +13 -0
- package/dist/configurator/ui/assistant/entity-link/AssistantEntityLink.js +1 -0
- package/dist/configurator/ui/assistant/entity-link/entity-link-selection.d.ts +22 -0
- package/dist/configurator/ui/assistant/entity-link/entity-link-selection.js +1 -0
- package/dist/configurator/ui/assistant/entity-link/entity-link-state.d.ts +27 -0
- package/dist/configurator/ui/assistant/entity-link/entity-link-state.js +1 -0
- package/dist/configurator/ui/assistant/entity-link/entity-link-target.d.ts +5 -0
- package/dist/configurator/ui/assistant/entity-link/entity-link-target.js +1 -0
- package/dist/configurator/ui/assistant/entity-link/index.d.ts +3 -0
- package/dist/configurator/ui/assistant/entity-link/index.js +1 -0
- package/dist/configurator/ui/configurator-layout/slots/services/InvariantViolations.d.ts +4 -4
- package/dist/configurator/ui/configurator-layout/slots/services/InvariantViolations.js +1 -1
- package/dist/configurator/ui/configurator-layout/slots/services/SideEffects.d.ts +3 -6
- package/dist/configurator/ui/configurator-layout/slots/services/SideEffects.js +1 -1
- package/dist/configurator/ui/legacy/layout/steps/StepsNavigation.d.ts +2 -2
- package/dist/configurator/ui/phoenix-layout-elements/header/common/step-navigation/StepsNavigation.d.ts +2 -2
- package/dist/docs/dimensions/3d-scene-integration/dimension-indicators.mdx +2 -2
- package/dist/docs/dimensions/3d-scene-integration/editable-angle-indicator.mdx +1 -1
- package/dist/docs/dimensions/3d-scene-integration/editable-distance-dimension-indicator.mdx +1 -1
- package/dist/docs/dimensions/3d-scene-integration/list-selector-dimension-indicator.mdx +1 -1
- package/dist/docs/drag-and-drop/drag-handle.mdx +1 -1
- package/dist/docs/drag-and-drop/hotspot-handle.mdx +1 -1
- package/dist/docs/drag-and-drop/planes.mdx +1 -1
- package/dist/docs/drag-and-drop/rotatable.mdx +2 -2
- package/dist/docs/index.json +11 -1
- package/dist/docs/layouts/custom-layout.mdx +1323 -179
- package/dist/docs/layouts/header/fixed.mdx +2 -2
- package/dist/docs/layouts/header/floating.mdx +2 -2
- package/dist/docs/layouts/sidebar/in-a-custom-layout.mdx +2 -2
- package/dist/docs/layouts/sidebar-footer/basic.mdx +32 -77
- package/dist/docs/other-features/client-side-rendering/declarative.mdx +1 -1
- package/dist/docs/phoenix/application-states.mdx +9 -7
- package/dist/docs/phoenix/configurator-interface.mdx +134 -18
- package/dist/docs/phoenix/finalization.mdx +1 -1
- package/dist/docs/phoenix/layout-slots.mdx +116 -0
- package/dist/docs/phoenix/migration-guide.mdx +19 -8
- package/dist/docs/phoenix/phoenix-cli.mdx +26 -8
- package/dist/docs/phoenix/project-structure.mdx +20 -5
- package/dist/docs/phoenix/sdk-builder-workflow.mdx +2 -2
- package/dist/docs/phoenix/webhooks.mdx +17 -0
- package/dist/domain/application/application-config.d.ts +3 -1
- package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -1
- package/dist/domain/application/configurator-builder.d.ts +4 -1
- package/dist/domain/application/configurator-builder.js +1 -1
- package/dist/domain/core/invariant/violation.d.ts +50 -2
- package/dist/domain/core/invariant/violation.js +1 -1
- package/dist/domain/core/model/model.d.ts +1 -1
- package/dist/domain/domain-context/index.d.ts +1 -1
- package/dist/domain/domain-context/undo-system.d.ts +28 -1
- package/dist/domain/domain-context/undo-system.js +1 -1
- package/dist/domain/domain-runtime/spec/initialize.js +1 -1
- package/dist/domain/domain-runtime/spec/selectors.js +1 -1
- package/dist/domain/domain-runtime/spec/types.d.ts +2 -0
- package/dist/domain/extensions/attribute-switch.d.ts +1 -1
- package/dist/domain/extensions/attribute-switch.js +1 -1
- package/dist/domain/extensions/canvas-config.d.ts +1 -1
- package/dist/domain/extensions/client-side-image.d.ts +2 -2
- package/dist/domain/extensions/client-side-image.js +1 -1
- package/dist/domain/extensions/common/angle-indicator-schema.d.ts +2 -2
- package/dist/domain/extensions/common/dimension-indicator-schema.d.ts +2 -2
- package/dist/domain/extensions/editable-angle-indicator.d.ts +1 -1
- package/dist/domain/extensions/editable-distance-dimension-indicator.d.ts +1 -1
- package/dist/domain/extensions/editable-offset-indicator.d.ts +1 -1
- package/dist/domain/extensions/editable-offset-indicator.js +1 -1
- package/dist/domain/extensions/fit-selection-orthographic-camera-component.js +1 -1
- package/dist/domain/extensions/fit-selection-perspective-camera-component.js +1 -1
- package/dist/domain/extensions/horizontal-tabs.d.ts +2 -2
- package/dist/domain/extensions/list-selector-dimension-indicator.d.ts +1 -1
- package/dist/domain/extensions/navigation-steps.d.ts +2 -2
- package/dist/domain/extensions/offset-indicator.js +1 -1
- package/dist/domain/extensions/rotation-handle.d.ts +2 -2
- package/dist/domain/extensions/save-template-thumbnail.d.ts +2 -2
- package/dist/domain/extensions/save-template-thumbnail.js +1 -1
- package/dist/domain/extensions/scene-entity-animation.js +1 -1
- package/dist/domain/system-components/application-config.d.ts +2 -2
- package/dist/domain/system-components/child-entity-selection.js +1 -1
- package/dist/domain/system-components/collision-box-geometry.d.ts +4 -2
- package/dist/domain/system-components/collision-geometry.d.ts +4 -2
- package/dist/domain/system-components/collision-point-geometry.d.ts +4 -2
- package/dist/domain/system-components/common/material-override-schema.d.ts +2 -2
- package/dist/domain/system-components/common/recipes.d.ts +21 -3
- package/dist/domain/system-components/common/recipes.js +1 -1
- package/dist/domain/system-components/constraint.d.ts +10 -23
- package/dist/domain/system-components/drag-handle.d.ts +1 -1
- package/dist/domain/system-components/drag-handle.js +1 -1
- package/dist/domain/system-components/fit-entity-orthographic-camera-component.js +1 -1
- package/dist/domain/system-components/fit-entity-perspective-camera-component.js +1 -1
- package/dist/domain/system-components/fit-root-orthographic-camera-component.js +1 -1
- package/dist/domain/system-components/fit-root-perspective-camera-component.js +1 -1
- package/dist/domain/system-components/hotspot-drag-handle.d.ts +1 -1
- package/dist/domain/system-components/hotspot-drag-handle.js +1 -1
- package/dist/domain/system-components/material-swatch.js +1 -1
- package/dist/domain/system-components/scene-entity-material-override.d.ts +1 -1
- package/dist/domain/system-components/scene-entity-object-material-override.d.ts +1 -1
- package/dist/domain/system-components/scene-entity-object-text-decal.d.ts +1 -1
- package/dist/domain/system-components/scene-entity-object-transimissive-material-override.d.ts +1 -1
- package/dist/domain/system-components/scene-entity-transimissive-material-override.d.ts +1 -1
- package/dist/domain/system-components/static-orthographic-camera-component.js +1 -1
- package/dist/domain/system-components/static-perspective-camera-component.js +1 -1
- 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-cli/utils/cache.d.ts +1 -1
- package/dist/legacy/domain-cli/utils/cache.js +1 -1
- package/dist/legacy/domain-spec/__generated/domain-schema.d.ts +81 -68
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/claude-md.d.ts +1 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/cursor-rules.d.ts +1 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.d.ts +1 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.js +7 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-admin.js +18 -16
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-configurator.js +14 -12
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-admin.js +13 -11
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-configurator.js +13 -11
- package/dist/phoenix/application-spec/application-spec-builder.js +1 -1
- package/dist/phoenix/application-spec/project-files.js +1 -1
- package/dist/phoenix/commands/check.js +1 -1
- package/dist/phoenix/commands/deploy.js +1 -1
- package/dist/phoenix/commands/dev.js +5 -5
- package/dist/phoenix/commands/fix.js +1 -1
- package/dist/phoenix/services/application-spec-project-watcher.d.ts +2 -0
- package/dist/phoenix/services/application-spec-project-watcher.js +3 -3
- package/dist/phoenix/services/source-archive.d.ts +1 -0
- package/dist/phoenix/services/source-archive.js +1 -1
- package/dist/phoenix/services/swc.js +1 -1
- package/dist/react-sdk/domain-context/common-hooks/use-configurator-messages.d.ts +30 -0
- package/dist/react-sdk/domain-context/common-hooks/use-configurator-messages.js +1 -0
- package/dist/react-sdk/domain-context/index.d.ts +2 -1
- package/dist/react-sdk/domain-context/index.js +1 -1
- package/dist/react-sdk/domain-context/system-hooks/navigation-hooks.d.ts +5 -0
- package/dist/react-sdk/domain-context/system-hooks/navigation-hooks.js +1 -1
- package/dist/react-sdk/domain-controls/hooks/use-angle-dimension.d.ts +1 -1
- package/dist/ui-sdk/theme/types.d.ts +1 -1
- package/package.json +33 -29
- package/schema/domain-spec.json +1115 -209
- package/dist/application-spec/generate-application/code/templates/webhook-implementation.d.ts +0 -1
- package/dist/application-spec/generate-application/code/templates/webhook-implementation.js +0 -7
- /package/dist/application-spec/{core → enhanced-json}/eval-code-uses-self.d.ts +0 -0
- /package/dist/application-spec/{core → enhanced-json}/eval-code-uses-self.js +0 -0
- /package/dist/application-spec/{core → enhanced-json}/eval-to-constant.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"lodash-es/isEqual.js";import{Branded as t}from"@salsita-ai/common/utils";import{createRelationFactory as i}from"#package/domain";import{canonicalEnhancedJsonValueKey as n
|
|
1
|
+
import e from"lodash-es/isEqual.js";import{Branded as t}from"@salsita-ai/common/utils";import{createRelationFactory as i}from"#package/domain";import{canonicalEnhancedJsonValueKey as n,isSdkExpressionImplementation as a}from"../../../core/index.js";import{generateMemoEvalPlanRuntime as r}from"./generate-memo-eval-plan-runtime.js";let l={},o=["0-1","1-1","0-N","1-N"],s={relation:(e,t)=>{let n=t[0];if(!("object"==typeof n&&null!==n&&"kind"in n&&"target"in n&&"string"==typeof n.target&&"cardinality"in n&&o.includes(n.cardinality)&&("allOfType"===n.kind||("direct"===n.kind||"indirect"===n.kind)&&"field"in n&&"string"==typeof n.field)))throw Error("Cannot create the relation expression because its parameter is not a relation declaration. The application spec is inconsistent; rebuild it from a valid relations declaration.");return i(e.aliasMap)(n)},violations:(e,t)=>{let i=t[0];if("object"!=typeof i||null===i||!("entityType"in i)||"string"!=typeof i.entityType)throw Error("Cannot create the violations expression because its entityType parameter is missing. The application spec is inconsistent; rebuild it from a valid invariants declaration.");let n=i.entityType,a=Object.entries(e.invariantImplementations).flatMap(([t,i])=>{let a=e.aliasMap[t];return t===n||a?.includes(n)?i:[]});return{origin:{name:"$violations",typeOrAlias:n},evaluate:(e,t,i)=>a.flatMap(n=>n.evaluate(e,t,i)),meta:{}}}},p=e=>{let t=r(e.plan);return{origin:{name:e.name,typeOrAlias:e.entityOrAlias},evaluate:(e,i,n)=>t(n.domain.get$Entity(e,i),i,n),meta:{}}},m=e=>({...(0,s[e.kind])({aliasMap:e.aliasMap,invariantImplementations:e.invariantImplementations},e.params),origin:{name:e.name,typeOrAlias:e.entityOrAlias}});export const ExpressionRuntime=(i,r,o,s,u=l)=>{let d={};for(let[e,t]of i.latestModel.aliases)d[String(e)]=t.map(String);let c=r.createBuilder(`${s}/sdk`,{build:m,getKey:e=>`sdk::${e.entityOrAlias}::${e.name}`,compare:(t,i)=>t.kind===i.kind&&e(t.params,i.params)&&e(t.aliasMap,i.aliasMap)&&("violations"!==i.kind||t.invariantImplementations===i.invariantImplementations)}),f=r.createBuilder(`${s}/user`,{build:e=>e.impl,getKey:e=>`user::${e.entityType}::${e.name}`,compare:(e,t)=>e.impl===t.impl}),y=r.createBuilder(`${s}/value`,{build:p,getKey:e=>`value::${e.entityOrAlias}::${e.name}`,compare:(e,t)=>e.valueKey===t.valueKey}),g={},v=!1,S=new Set,k=new Set,b=new Set;for(let[e,t]of i.expressions.expressions)for(let[,i]of t){let t=d[String(e)]??[String(e)];if(a(i.implementation)){let n={entityOrAlias:String(e),name:String(i.name),kind:i.implementation.kind,params:i.implementation.params,aliasMap:d,invariantImplementations:u},a=c.build(n);for(let e of(a.changed&&(v=!0),S.add(c.getKey(n)),t))g[e]||(g[e]={}),g[e][String(i.name)]=a.output;continue}if("value"===i.implementation.kind){let a=i.implementation.value,r={entityOrAlias:String(e),name:String(i.name),valueKey:n(a),plan:i.implementation.plan},l=y.build(r);for(let e of(l.changed&&(v=!0),b.add(y.getKey(r)),t))g[e]||(g[e]={}),g[e][String(i.name)]=l.output;continue}}for(let[e,t]of Object.entries(o))for(let[i,n]of Object.entries(t)){let t={entityType:e,name:i,impl:n},a=f.build(t);a.changed&&(v=!0),k.add(f.getKey(t)),g[e]||(g[e]={}),g[e][i]=a.output}c.cleanup(S)&&(v=!0),f.cleanup(k)&&(v=!0),y.cleanup(b)&&(v=!0);let h=[];for(let[e,t]of i.expressions.entityExpressions)for(let n of t.shapeGroups){let t=i.expressions.expressions.get(n);if(t)for(let[i]of t)g[String(e)]?.[String(i)]||h.push({entityType:String(e),exprName:String(i)})}return h.length>0?{ok:!1,missing:h}:{ok:!0,runtime:t({merged:g,changed:v})}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./core/index.js";export*from"./caching/index.js";export*from"./errors/index.js";export*from"./generate-application/index.js";export*from"./parse-application-files/index.js";export*from"./webhook-boundary.js";
|
|
1
|
+
export*from"./core/index.js";export*from"./enhanced-json/index.js";export*from"./caching/index.js";export*from"./errors/index.js";export*from"./generate-application/index.js";export*from"./parse-application-files/index.js";export*from"./webhook-boundary.js";
|
|
@@ -58,12 +58,28 @@ export type CategorizedFiles = Branded<'CategorizedFiles', {
|
|
|
58
58
|
readonly adminElementsChanged: boolean;
|
|
59
59
|
readonly webhooks: readonly CategorizedFile[];
|
|
60
60
|
readonly webhooksChanged: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Whether the project has its webhook entry, `src/webhooks/index.ts`, whose default export is the
|
|
63
|
+
* project's webhook. Generation reads it to decide the generated webhook entry: without it the
|
|
64
|
+
* entry holds the built-in inert webhook.
|
|
65
|
+
*/
|
|
66
|
+
readonly hasWebhookEntry: boolean;
|
|
61
67
|
readonly locales: readonly CategorizedFile[];
|
|
62
68
|
readonly localesChanged: boolean;
|
|
63
69
|
readonly mockTemplates: readonly CategorizedFile[];
|
|
64
70
|
readonly mockTemplatesChanged: boolean;
|
|
65
71
|
readonly projectFiles: readonly CategorizedFile[];
|
|
66
72
|
readonly projectFilesChanged: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* One-time migration: true only on a checkout's first sync with an SDK that contains this field;
|
|
75
|
+
* delete it once projects have synced with such an SDK.
|
|
76
|
+
*
|
|
77
|
+
* Whether the project's root `tsconfig.json` is the full file earlier SDK versions generated on
|
|
78
|
+
* every sync, before the TypeScript settings moved to `.phoenix/tsconfig.json`. Generation reads
|
|
79
|
+
* it to replace that file with the one-line `tsconfig.json` that extends `.phoenix/tsconfig.json`;
|
|
80
|
+
* any other root `tsconfig.json` is the project's own and is left as it is.
|
|
81
|
+
*/
|
|
82
|
+
readonly hasEarlierGeneratedTsconfig: boolean;
|
|
67
83
|
readonly customCode: readonly CategorizedFile[];
|
|
68
84
|
readonly customCodeChanged: boolean;
|
|
69
85
|
readonly envs: Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"lodash-es/isEqual.js";import{Branded as n}from"@salsita-ai/common/utils";import{computeFileDepHashes as s}from"../../caching/index.js";import{DiagnosticCode as o,diagnosticMessages as
|
|
1
|
+
import e from"lodash-es/isEqual.js";import{Branded as n}from"@salsita-ai/common/utils";import{computeFileDepHashes as s}from"../../caching/index.js";import{DiagnosticCode as o,diagnosticMessages as i}from"../../errors/index.js";import{isEarlierGeneratedTsconfig as a}from"./earlier-generated-tsconfig.js";import{findWebhookHandlerRegistration as t}from"./module-analysis.js";import{findWebhookSafetyViolation as r}from"./webhook-safety.js";export const buildProjectFileIndex=e=>new Map([...e.spec,...e.expressions,...e.actions,...e.handlers,...e.elements,...e.transformers,...e.components,...e.invariants,...e.migrations,...e.adminMigrations,...e.adminExpressions,...e.adminInvariants,...e.adminComponents,...e.adminElements,...e.webhooks,...e.locales,...e.mockTemplates,...e.projectFiles,...e.customCode].map(e=>[e.file.name,e]));let m=e=>/\/_[^/]+\//.test(e),l=[{path:"spec/",key:"spec"},{path:"src/admin/expressions/",key:"adminExpressions"},{path:"src/admin/invariants/",key:"adminInvariants"},{path:"src/admin/components/",key:"adminComponents"},{path:"src/admin/elements/",key:"adminElements"},{path:"src/admin/migrations/",key:"adminMigrations"},{path:"src/expressions/",key:"expressions"},{path:"src/actions/",key:"actions"},{path:"src/handlers/",key:"handlers"},{path:"src/elements/",key:"elements"},{path:"src/transformers/",key:"transformers"},{path:"src/components/",key:"components"},{path:"src/invariants/",key:"invariants"},{path:"src/migrations/",key:"migrations"},{path:"src/webhooks/",key:"webhooks"},{path:"src/locales/",key:"locales"},{path:"mocks/",key:"mockTemplates"}],d="tsconfig.json",c=new Set(["package.json",".gitignore",d,"CLAUDE.md",".cursor/rules/phoenix.mdc"]),p=new Set(["migrations","adminMigrations"]),h=l.filter(({path:e,key:n})=>e.startsWith("src/")&&p.has(n)),f=(e,n)=>{let s=e.slice(n.length).split("/");return!(s.length<=1)&&s.slice(0,-1).some(e=>!e.startsWith("_"))},g=/\.(ts|tsx|js|jsx)$/,u=(e,n)=>{if("components"===e||"adminComponents"===e)return n.hasUseWebhookDirective?{membership:"pinned",logSuffix:"webhook ('use webhook' directive)"}:{membership:"frontend",logSuffix:"frontend only (no 'use webhook' directive)"};if("handlers"===e){let e=t(n);return void 0!==e?{membership:"named-handler",logSuffix:`webhook (the ${e} registration)`}:n.hasUseWebhookDirective?{membership:"pinned",logSuffix:"webhook ('use webhook' directive)"}:{membership:"frontend",logSuffix:"frontend only (not a named handler or pin)"}}};export const CategorizedFiles=(t,p,k,b)=>{let C={spec:[],expressions:[],actions:[],handlers:[],elements:[],transformers:[],components:[],invariants:[],migrations:[],adminMigrations:[],adminExpressions:[],adminInvariants:[],adminComponents:[],adminElements:[],webhooks:[],locales:[],mockTemplates:[],projectFiles:[],customCode:[]},v=[];for(let e of t.files){if("text"!==e.kind)continue;if(m(e.name)){C.customCode.push({file:e,category:"customCode"});continue}if(c.has(e.name)){C.projectFiles.push({file:e,category:"projectFiles"});continue}let n=!1;for(let{path:s,key:o}of l)if(e.name.startsWith(s)){C[o].push({file:e,category:o}),n=!0;break}n||v.push(e.name)}for(let e of v)e.startsWith("src/")&&k.error(o.UNKNOWN_SRC_PATH,i.UNKNOWN_SRC_PATH(e));for(let{path:e,key:n}of h)for(let s of C[n])f(s.file.name,e)&&k.error(o.INVALID_SUBDIRECTORY,i.INVALID_SUBDIRECTORY(s.file.name,e));let x=C.webhooks.some(e=>"src/webhooks/index.ts"===e.file.name);if(C.webhooks.length>0&&!x&&k.error(o.MISSING_WEBHOOK_INDEX,i.MISSING_WEBHOOK_INDEX()),k.hasErrors)return;let y=C.projectFiles.find(e=>e.file.name===d),E=void 0!==y&&a(y.file.content),I=[];for(let e of Object.values(C))for(let n of e)I.push(n.file.name);let w=s(t,I),{analyzer:S,logger:j}=b,F=p.createBuilder("categorizedFiles/moduleAnalysis",{build:e=>{try{return{analysis:S(e.name,e.content)}}catch(e){return{error:e instanceof Error?e.message:String(e)}}},getKey:e=>e.name,compare:(e,n)=>e.content===n.content}),_=new Set,M=e=>{if(!g.test(e.name))return;_.add(e.name);let n=F.build({name:e.name,content:e.content}).output;return void 0!==n.error?void k.error(o.MODULE_ANALYSIS_FAILED,i[o.MODULE_ANALYSIS_FAILED](e.name,n.error)):n.analysis},O={},N={};for(let[e,s]of Object.entries(C)){let o=p.createBuilder(`categorizedFiles/${e}`,{build:e=>e,getKey:e=>e.name,compare:(e,n)=>e.depHash===n.depHash}),i=new Set;O[e]=s.map(e=>{let s=w[e.file.name]??{deps:[],hash:""},{changed:a}=o.build({name:e.file.name,depHash:s.hash});i.add(e.file.name);let t=M(e.file),r=void 0===t?void 0:u(e.category,t);return void 0!==r&&j.debug(`Webhook membership: ${e.file.name} -> ${r.logSuffix}`),n({file:e.file,category:e.category,deps:s.deps,depHash:s.hash,changed:a,analysis:t,webhookMembership:r?.membership})}),N[e]=o.cleanup(i)}F.cleanup(_);let A=(e,n)=>n.some(e=>e.changed)||!0===N[e],T=p.createBuilder("categorizedFiles/envs",{build:e=>e.envs,getKey:()=>"singleton",compare:(n,s)=>e(n.envs,s.envs)}).build({envs:t.envs}),D=n({spec:O.spec,specChanged:A("spec",O.spec),expressions:O.expressions,expressionsChanged:A("expressions",O.expressions),actions:O.actions,actionsChanged:A("actions",O.actions),handlers:O.handlers,handlersChanged:A("handlers",O.handlers),elements:O.elements,elementsChanged:A("elements",O.elements),transformers:O.transformers,transformersChanged:A("transformers",O.transformers),components:O.components,componentsChanged:A("components",O.components),invariants:O.invariants,invariantsChanged:A("invariants",O.invariants),migrations:O.migrations,migrationsChanged:A("migrations",O.migrations),adminMigrations:O.adminMigrations,adminMigrationsChanged:A("adminMigrations",O.adminMigrations),adminExpressions:O.adminExpressions,adminExpressionsChanged:A("adminExpressions",O.adminExpressions),adminInvariants:O.adminInvariants,adminInvariantsChanged:A("adminInvariants",O.adminInvariants),adminComponents:O.adminComponents,adminComponentsChanged:A("adminComponents",O.adminComponents),adminElements:O.adminElements,adminElementsChanged:A("adminElements",O.adminElements),webhooks:O.webhooks,webhooksChanged:A("webhooks",O.webhooks),hasWebhookEntry:x,locales:O.locales,localesChanged:A("locales",O.locales),mockTemplates:O.mockTemplates,mockTemplatesChanged:A("mockTemplates",O.mockTemplates),projectFiles:O.projectFiles,projectFilesChanged:A("projectFiles",O.projectFiles),hasEarlierGeneratedTsconfig:E,customCode:O.customCode,customCodeChanged:A("customCode",O.customCode),envs:T.output,envsChanged:T.changed}),W=buildProjectFileIndex(D);for(let e of W.values()){if("pinned"!==e.webhookMembership&&"named-handler"!==e.webhookMembership)continue;let n=r(e,W);void 0!==n&&k.error(o.WEBHOOK_UNSAFE_IMPORT,i[o.WEBHOOK_UNSAFE_IMPORT](n.fileName,n.inclusionReason,n.importer,n.specifier))}return D};
|
package/dist/application-spec/parse-application-files/categorize/earlier-generated-tsconfig.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-time migration, see the top of this module: true only before a checkout's first sync with this SDK.
|
|
3
|
+
*
|
|
4
|
+
* Whether the content of a project's root `tsconfig.json` is the file earlier SDK versions generated.
|
|
5
|
+
* The comparison is by meaning: comments, formatting and key order do not count, so a generated
|
|
6
|
+
* file that an editor or formatter rewrote is still recognised. Content that does not parse, or that
|
|
7
|
+
* differs in any setting, is the project's own.
|
|
8
|
+
*/
|
|
9
|
+
export declare const isEarlierGeneratedTsconfig: (content: string) => boolean;
|
package/dist/application-spec/parse-application-files/categorize/earlier-generated-tsconfig.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"lodash-es/isEqual.js";let l={compilerOptions:{noEmit:!0,module:"ESNext",moduleResolution:"Bundler",lib:["ES2022","DOM"],esModuleInterop:!0,isolatedModules:!0,resolveJsonModule:!0,allowJs:!1,skipLibCheck:!0,strict:!0,noImplicitOverride:!0,noImplicitReturns:!0,noPropertyAccessFromIndexSignature:!0,noUncheckedIndexedAccess:!0,allowUnreachableCode:!1,allowUnusedLabels:!1,noFallthroughCasesInSwitch:!0,noUnusedLocals:!0,noUnusedParameters:!0,useDefineForClassFields:!0,jsx:"react-jsx",paths:{}},include:["src",".phoenix","prettier.config.js","eslint.config.js","./.phoenix/globals.d.ts"]},s=(e,l)=>{let s=l+1;for(;s<e.length&&'"'!==e[s];)s+="\\"===e[s]?2:1;return s+1};export const isEarlierGeneratedTsconfig=t=>e((e=>{try{return JSON.parse((e=>{let l="",t=0;for(;t<e.length;){let n=e[t];if('"'===n){let n=s(e,t);l+=e.slice(t,n),t=n;continue}","===n&&/^\s*[}\]]/.test(e.slice(t+1))||(l+=n),t++}return l})((e=>{let l="",t=0;for(;t<e.length;){let n=e[t],o=e[t+1];if('"'===n){let n=s(e,t);l+=e.slice(t,n),t=n}else if("/"===n&&"/"===o){let l=e.indexOf("\n",t);t=-1===l?e.length:l}else if("/"===n&&"*"===o){let l=e.indexOf("*/",t+2);t=-1===l?e.length:l+2}else l+=n,t++}return l})(e)))}catch{return}})(t),l);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as o}from"zod";import{Branded as a}from"@salsita-ai/common/utils";import{enhancedJsonObjectSchema as t
|
|
1
|
+
import{z as o}from"zod";import{Branded as a}from"@salsita-ai/common/utils";import{enhancedJsonObjectSchema as t}from"../../core/index.js";import{validateNoLegacyCodeRef as e}from"../../enhanced-json/index.js";import{DiagnosticCode as n,diagnosticMessages as i}from"../../errors/index.js";import{rawAclSchema as r}from"./raw-acl.js";import{rawActionsSchema as s}from"./raw-actions.js";import{rawAdminPagesSchema as l}from"./raw-admin-pages.js";import{rawAssistantSchema as p}from"./raw-assistant.js";import{rawBudgetsSchema as m}from"./raw-budgets.js";import{rawChunksSchema as c}from"./raw-chunks.js";import{rawComponentsSchema as f}from"./raw-components.js";import{rawConstantsSchema as d}from"./raw-constants.js";import{rawDataSpecSchema as j}from"./raw-data.js";import{rawDefaultsSchema as u}from"./raw-defaults.js";import{rawEnvSchema as w}from"./raw-env.js";import{rawExpressionsSchema as b}from"./raw-expressions.js";import{rawInvariantsSchema as g}from"./raw-invariants.js";import{rawModelSchema as S}from"./raw-model.js";import{rawPresetsSchema as h}from"./raw-presets.js";import{rawRelationsSchema as D}from"./raw-relations.js";import{rawResourcesConfigSchema as v,rawResourcesSchema as O}from"./raw-resources.js";import{rawStateValuesSchema as E}from"./raw-states.js";import{rawTransformersSchema as R}from"./raw-transformers.js";export const DATA_SCHEMA_KEYS=["publishedData","sessionData","frontendData","backendData","finalizeData","prefetchedFinalizeData","finalizeResult","callbackData"];let k=o.object({$admin:o.boolean().optional(),model:S.optional(),components:f.optional(),presets:h.optional(),$data:j.optional(),expressions:b.optional(),actions:s.optional(),invariants:g.optional(),constants:d.optional(),relations:D.optional(),defaults:u.optional(),publishedData:t.optional(),sessionData:t.optional(),frontendData:t.optional(),backendData:t.optional(),finalizeData:t.optional(),prefetchedFinalizeData:t.optional(),finalizeResult:t.optional(),callbackData:t.optional(),navigationStates:E.optional(),viewStates:E.optional(),toolStates:E.optional(),exportStates:E.optional(),themePreset:o.string().optional(),themeOptions:o.record(o.unknown()).optional(),preview:o.enum(["always","never","auto","hide"]).optional(),alwaysExpand:o.boolean().optional(),availableLocales:o.array(o.string()).optional(),textLanguages:o.array(o.string()).optional(),transformers:R.optional(),project:o.string().regex(/^[a-z0-9-]{3,}$/,"must be a project slug (lowercase letters, digits and dashes, at least 3) or `default`").optional(),applicationVersion:o.string().optional(),workspace:o.boolean().optional(),webComponentTag:o.string().optional(),pageTitle:o.string().optional(),useAuthHook:o.boolean().optional(),useClerk:o.boolean().optional(),enableAdminRelease:o.boolean().optional(),jsonSchemaValidator:o.enum(["ajv","csp-compatible"]).optional(),gltfDecoder:o.enum(["js","wasm"]).optional(),appLoader:o.enum(["legacy","universal"]).optional(),collectFinalizeData:o.boolean().optional(),env:w.optional(),acl:r.optional(),resources:O.optional(),resourcesConfig:v.optional(),budgets:m.optional(),chunks:c.optional(),assistant:p.optional(),$adminPages:l.optional()}).strict();export const parseRawSpecFile=(o,t)=>{e(o.content,t);let r=k.safeParse(o.content);if(!r.success){for(let o of r.error.issues)t.error(n.SCHEMA_PARSE_ERROR,i.SCHEMA_PARSE_ERROR(o.path.join("."),o.message));return}let{constants:s,...l}=r.data,p=((o,a)=>{let t=Object.fromEntries(Object.entries(o.expressions??{}).map(([o,a])=>[o,{...a}]));if(void 0===o.constants)return Object.keys(t).length>0?t:void 0;for(let[e,r]of Object.entries(o.constants))for(let[o,s]of(t[e]||(t[e]={}),Object.entries(r))){if(void 0!==t[e][o]){a.at("constants",e,o).error(n.CONSTANTS_EXPRESSION_CONFLICT,i[n.CONSTANTS_EXPRESSION_CONFLICT](e,o));continue}t[e][o]={kind:"value",constant:!0,value:s,schema:{}}}return Object.keys(t).length>0?t:void 0})(r.data,t);return a({name:o.name,content:{...l,expressions:p}})};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Branded } from '@salsita-ai/common/utils';
|
|
2
|
+
import type { SdkCodeRef } from '../../../core/index.js';
|
|
2
3
|
import type { MemoEvalPlan, MemoEvalPlanInput } from '../expressions/memo-eval-plan.js';
|
|
3
4
|
import type { EntityOrAliasName, InstanceName } from '../model/index.js';
|
|
4
5
|
import type { ComponentReadBinding, ComponentWriteBinding } from './bindings/index.js';
|
|
@@ -46,15 +47,6 @@ interface UserBoundImplementation {
|
|
|
46
47
|
readonly plan: MemoEvalPlan;
|
|
47
48
|
readonly implementation: RootReadImplementation | CompositeImplementation;
|
|
48
49
|
}
|
|
49
|
-
/**
|
|
50
|
-
* A parameter that should be emitted as an unquoted code reference in codegen
|
|
51
|
-
* (e.g. an entity reflection variable like `Top`).
|
|
52
|
-
* At runtime, the string value is resolved to the actual object (e.g. entity reflection).
|
|
53
|
-
*/
|
|
54
|
-
export interface SdkCodeRef {
|
|
55
|
-
readonly $codeRef: string;
|
|
56
|
-
}
|
|
57
|
-
export declare const isSdkCodeRef: (value: unknown) => value is SdkCodeRef;
|
|
58
50
|
export type SdkFactoryParam = SdkCodeRef | string | number | boolean | null | readonly SdkFactoryParam[] | {
|
|
59
51
|
readonly [key: string]: SdkFactoryParam;
|
|
60
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
|
@@ -1,58 +1,5 @@
|
|
|
1
1
|
import { Branded } from '@salsita-ai/common/utils';
|
|
2
|
-
import { type EnhancedJsonSchemaType, type EnhancedJsonValue } from '../../../core/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* A single filter criterion — static value, dynamic `$read` reference, or
|
|
5
|
-
* inline `$eval` expression evaluated against `self` at runtime.
|
|
6
|
-
*
|
|
7
|
-
* The `target` field on the `'dynamic'` variant is a bare name (matches the
|
|
8
|
-
* same pattern as prop-level reads); codegen emits `self.target`, runtime
|
|
9
|
-
* reads `self[target]`.
|
|
10
|
-
*/
|
|
11
|
-
export type FilterCriterion<T> = {
|
|
12
|
-
readonly kind: 'static';
|
|
13
|
-
readonly value: T;
|
|
14
|
-
} | {
|
|
15
|
-
readonly kind: 'dynamic';
|
|
16
|
-
readonly target: string;
|
|
17
|
-
} | {
|
|
18
|
-
readonly kind: 'eval';
|
|
19
|
-
readonly code: string;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Parsed component filter controlling when the component is active. Two
|
|
23
|
-
* mutually-exclusive shapes:
|
|
24
|
-
*
|
|
25
|
-
* - `'gradual'` — zero or more per-criterion fields; compiles to one entry per
|
|
26
|
-
* set key inside `.withGradualFilter({…})`. The preferred form.
|
|
27
|
-
* - `'root'` — the entire filter is a single `$read` at the root (legacy
|
|
28
|
-
* form `$filter: { $read: '$x' }`); compiles to `.withFilter(self => (self.target))`.
|
|
29
|
-
* Distinct codegen because the SDK's `withFilter` and `withGradualFilter`
|
|
30
|
-
* methods have different evaluation semantics (whole-closure vs per-key).
|
|
31
|
-
*
|
|
32
|
-
* See `components.md §"Simple expression filter"` / `§"Declarative filter"`.
|
|
33
|
-
*/
|
|
34
|
-
export type ComponentFilter = {
|
|
35
|
-
readonly kind: 'gradual';
|
|
36
|
-
readonly navigationStates?: FilterCriterion<readonly string[]>;
|
|
37
|
-
readonly viewStates?: FilterCriterion<readonly string[]>;
|
|
38
|
-
readonly toolStates?: FilterCriterion<readonly string[]>;
|
|
39
|
-
readonly exportStates?: FilterCriterion<readonly string[]>;
|
|
40
|
-
readonly modes?: FilterCriterion<readonly string[]>;
|
|
41
|
-
readonly roles?: FilterCriterion<readonly string[]>;
|
|
42
|
-
readonly selectedEntityIds?: FilterCriterion<unknown>;
|
|
43
|
-
readonly hoveredEntityIds?: FilterCriterion<unknown>;
|
|
44
|
-
readonly draggedEntityIds?: FilterCriterion<unknown>;
|
|
45
|
-
readonly exportedEntityIds?: FilterCriterion<unknown>;
|
|
46
|
-
readonly active?: FilterCriterion<boolean>;
|
|
47
|
-
readonly fullscreen?: FilterCriterion<boolean>;
|
|
48
|
-
readonly debug?: FilterCriterion<boolean>;
|
|
49
|
-
readonly viewports?: FilterCriterion<unknown>;
|
|
50
|
-
} | {
|
|
51
|
-
readonly kind: 'root';
|
|
52
|
-
readonly target: string;
|
|
53
|
-
};
|
|
54
|
-
/** Criterion field names on the gradual variant — used for parse and iteration. */
|
|
55
|
-
export declare const FILTER_CRITERION_KEYS: readonly ["navigationStates", "viewStates", "toolStates", "exportStates", "modes", "roles", "selectedEntityIds", "hoveredEntityIds", "draggedEntityIds", "exportedEntityIds", "active", "fullscreen", "debug", "viewports"];
|
|
2
|
+
import { type ComponentFilter, type EnhancedJsonSchemaType, type EnhancedJsonValue } from '../../../core/index.js';
|
|
56
3
|
/**
|
|
57
4
|
* Schema types for each filter criterion, used for expression inference.
|
|
58
5
|
* When `$read: '$expr'` appears in a filter criterion, the expression is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Branded as t}from"@salsita-ai/common/utils";import{
|
|
1
|
+
import{Branded as t}from"@salsita-ai/common/utils";import{FILTER_CRITERION_KEYS as e,FILTER_OR_KEY as r,READ_MARKER_KEY as i,isEnhancedJsonObject as s,isEvalMarker as a,isRawReadMarker as o}from"../../../core/index.js";let n={tsType:"IdOrWithId | readonly IdOrWithId[]",import:[{module:"@salsita-ai/sdk/domain",member:"IdOrWithId"}]};export const FILTER_CRITERION_SCHEMAS={navigationStates:{type:"array",items:{type:"string"}},viewStates:{type:"array",items:{type:"string"}},toolStates:{type:"array",items:{type:"string"}},exportStates:{type:"array",items:{type:"string"}},modes:{type:"array",items:{type:"string"}},roles:{type:"array",items:{type:"string"}},selectedEntityIds:n,hoveredEntityIds:n,draggedEntityIds:n,exportedEntityIds:n,active:{type:"boolean"},fullscreen:{type:"boolean"},debug:{type:"boolean"},viewports:{type:"array",items:{type:"string"},tsType:"readonly Viewport[]",import:[{module:"@salsita-ai/sdk/domain",member:"Viewport"}]}};let y=new Set(e),d=t=>o(t)?{kind:"dynamic",target:t[i]}:a(t)?{kind:"eval",code:t.$eval}:{kind:"static",value:t},p=t=>{let e=t[i];if("string"==typeof e&&!Object.keys(t).some(t=>y.has(t)))return{kind:"root",target:e};let r={};for(let[e,i]of Object.entries(t))y.has(e)&&void 0!==i&&(r[e]=d(i));return{kind:"gradual",...r}};export const ComponentFilters=e=>{if(void 0===e||!s(e))return t({items:[]});let i=e[r];return Array.isArray(i)?t({items:i.filter(s).map(p)}):t({items:[p(e)]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./bindings/index.js";export*from"./component-
|
|
1
|
+
export*from"./bindings/index.js";export*from"./component-filter.js";export*from"./component-prop-target.js";export*from"./components.js";export*from"./sdk-component-entry.js";export*from"./user-component-entry.js";export*from"./user-components.js";
|
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
import type { Branded } from '@salsita-ai/common/utils';
|
|
2
|
-
import type { EnhancedJsonSchemaType, EnhancedJsonValue } from '../../../core/index.js';
|
|
2
|
+
import type { EnhancedJsonSchemaType, EnhancedJsonValue, SdkExpressionImplementation } from '../../../core/index.js';
|
|
3
3
|
import type { EntityOrAliasName, ExpressionName } from '../model/index.js';
|
|
4
4
|
import type { MemoEvalPlan } from './memo-eval-plan.js';
|
|
5
|
-
/**
|
|
6
|
-
* The relation factory's single positional param: the relation's kind, the entity type or alias it
|
|
7
|
-
* points to and its cardinality, plus the id field for `direct` and `indirect` relations. The
|
|
8
|
-
* assistant schema reads `target` and `cardinality` to type a relation edge.
|
|
9
|
-
*/
|
|
10
|
-
export interface RelationExpressionParams {
|
|
11
|
-
readonly kind: 'direct' | 'indirect' | 'allOfType';
|
|
12
|
-
readonly target: string;
|
|
13
|
-
readonly cardinality: '0-1' | '1-1' | '0-N' | '1-N';
|
|
14
|
-
readonly field?: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* An expression implementation built by an SDK factory at runtime. The kind is the
|
|
18
|
-
* semantic source of the expression, declared by the section that generated it —
|
|
19
|
-
* codegen and runtime dispatch on it instead of inspecting factory-function names.
|
|
20
|
-
* - `relation`: generated from a `relations:` declaration
|
|
21
|
-
* - `violations`: generated from `invariants:` declarations (the `$violations` expression)
|
|
22
|
-
*/
|
|
23
|
-
export type SdkExpressionImplementation = {
|
|
24
|
-
readonly kind: 'relation';
|
|
25
|
-
readonly params: readonly [RelationExpressionParams];
|
|
26
|
-
} | {
|
|
27
|
-
readonly kind: 'violations';
|
|
28
|
-
readonly params: readonly unknown[];
|
|
29
|
-
};
|
|
30
5
|
/**
|
|
31
6
|
* How an expression's runtime implementation is provided.
|
|
32
7
|
* - `user`: implementation from `src/expressions/*.ts` (dynamic import)
|
|
@@ -47,8 +22,6 @@ export type ExpressionImplementation = {
|
|
|
47
22
|
readonly value: EnhancedJsonValue;
|
|
48
23
|
readonly plan: MemoEvalPlan;
|
|
49
24
|
};
|
|
50
|
-
/** Narrows to implementations that are built by an SDK expression factory at runtime. */
|
|
51
|
-
export declare const isSdkExpressionImplementation: (implementation: ExpressionImplementation) => implementation is SdkExpressionImplementation;
|
|
52
25
|
/** A single parsed expression declaration. */
|
|
53
26
|
export type Expression = Branded<'Expression', {
|
|
54
27
|
readonly entityKey: EntityOrAliasName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
|
@@ -2,7 +2,7 @@ import { Branded } from '@salsita-ai/common/utils';
|
|
|
2
2
|
import { type EvalExpressionParser, type ParseContext } from '../../../core/index.js';
|
|
3
3
|
import type { MergedExpressions } from '../../merge/index.js';
|
|
4
4
|
import type { Aliases, EntityOrAliasName, EntityTypeName, ExpressionName, ModelVersion } from '../model/index.js';
|
|
5
|
-
import {
|
|
5
|
+
import type { Expression } from './expression.js';
|
|
6
6
|
import type { MemoEvalPlan } from './memo-eval-plan.js';
|
|
7
7
|
export type { Expression, ExpressionImplementation } from './expression.js';
|
|
8
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Branded as e}from"@salsita-ai/common/utils";import{intersectSchemas as t}from"../../../core/index.js";import{DiagnosticCode as
|
|
1
|
+
import{Branded as e}from"@salsita-ai/common/utils";import{intersectSchemas as t,isSdkExpressionImplementation as n}from"../../../core/index.js";import{DiagnosticCode as i,diagnosticMessages as o}from"../../../errors/index.js";import{UserExpressions as r}from"./user-expressions.js";let s=(e,t)=>{let n=e.get(t.entityKey);n||(n=new Map,e.set(t.entityKey,n)),n.set(t.name,t)},a=(n,i)=>{let o=n.get(i.entityKey);o||(o=new Map,n.set(i.entityKey,o));let r=o.get(i.name);r?o.set(i.name,e({...r,schema:t(r.schema,i.schema),...r.declaredSchema||!i.declaredSchema?{}:{declaredSchema:i.declaredSchema}})):o.set(i.name,i)},l=e=>"relation"===e.implementation.kind?"relations":"violations"===e.implementation.kind?"invariants":"expressions";export const Expressions=(t,m)=>{let{rawExpressions:f,inferredExpressions:p}=t,{latestModel:c,aliases:d,entityTypes:y,evalExpressionParser:u,parsingContext:g}=m,S=r(f,{latestModel:c,evalExpressionParser:u,parsingContext:g});if(void 0===S)return;let h=new Map;for(let e of S)s(h,e);for(let e of p)a(h,e);let w=((e,t)=>{let i=new Map,o=e=>{let t=i.get(e.entityKey);t||(t=new Set,i.set(e.entityKey,t)),t.add(e.name)};for(let t of e)o(t);for(let e of t)n(e.implementation)&&o(e);return i})(S,p),x=new Map;for(let e of S){let{implementation:t}=e;if("value"!==t.kind||!t.constant||t.plan.usesSelf)continue;let n=x.get(e.entityKey);n||(n=new Map,x.set(e.entityKey,n)),n.set(e.name,t.plan)}let K=new Map;for(let t of y){let n=[],r=new Map,s=e=>{let s=h.get(e);if(!s||0===s.size)return;n.push(e);let a=w.get(e);for(let[n,m]of s){if(!a?.has(n))continue;let s=r.get(n);if(s){g.at(l(m),e,n).error(i.DUPLICATE_EXPRESSION,o.DUPLICATE_EXPRESSION(t,n,s,e));continue}r.set(n,e)}};for(let[e,n]of d)n.includes(t)&&s(e);s(t),K.set(t,e({shapeGroups:n}))}return e({expressions:h,entityExpressions:K,constants:x})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export*from"./expressions.js";export*from"./memo-eval-plan.js";export*from"./user-expressions.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Branded as e}from"@salsita-ai/common/utils";import{
|
|
1
|
+
import{Branded as e}from"@salsita-ai/common/utils";import{isEvalMarker as r,isMsgMarker as t}from"../../../core/index.js";import{evalCodeUsesSelf as n}from"../../../enhanced-json/eval-code-uses-self.js";import{isComponentPropTarget as o}from"../components/component-prop-target.js";let l=(e,r)=>0===r.length?e:`${e}.${r.join(".")}`,i=(n,a,d,u)=>{if(void 0===n)throw Error(`MemoEvalPlan: found undefined at ${l(d,u)}, undefined cannot be generated, remove the property or use null.`);if(r(n)){let r=((r,t,n)=>{let o=t.trim();for(let e=0;e<r.length;e++){let t=r[e];if("eval"===t.kind&&t.code===o)return e}return r.push(e({kind:"eval",code:o,label:n})),r.length-1})(a,n.$eval,d);return e({kind:"slot",depIndex:r})}if(o(n)){let r=((r,t)=>{for(let e=0;e<r.length;e++){let n=r[e];if("read"===n.kind&&n.target===t)return e}return r.push(e({kind:"read",target:t})),r.length-1})(a,n.$target);return e({kind:"slot",depIndex:r})}if(t(n))return e({kind:"msg",marker:n});if(null===n||"object"!=typeof n)return e({kind:"literal",value:n});if(Array.isArray(n))return e({kind:"array",items:n.map((e,r)=>i(e,a,d,[...u,String(r)]))});if("object"!=typeof n||null===n)throw Error(`MemoEvalPlan: found unsupported value at ${l(d,u)}, remove it or use null.`);let s=[];for(let e in n){let r=n[e];s.push([e,i(r,a,d,[...u,e])])}return e({kind:"object",entries:s})};export const MemoEvalPlan=(r,t)=>{let o=[],l=i(r,o,t,[]),a=o.some(e=>"read"===e.kind||n(e.code));return e({deps:o,template:l,usesSelf:a})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Branded as e}from"@salsita-ai/common/utils";import{schemaFromValue as t}from"../../../
|
|
1
|
+
import{Branded as e}from"@salsita-ai/common/utils";import{schemaFromValue as t}from"../../../enhanced-json/index.js";import{DiagnosticCode as r,diagnosticMessages as n}from"../../../errors/index.js";import{ExpressionName as s}from"../model/index.js";import{MemoEvalPlan as a}from"./memo-eval-plan.js";let o=(e,r,n,s)=>{if("user"===e.kind)return{schema:e.schema,implementation:{kind:"user"}};let o=a(e.value,r),i={kind:"value",constant:e.constant,value:e.value,plan:o};if(Object.keys(e.schema).length>0)return{schema:e.schema,implementation:i};let m=t(e.value,n,s);if(void 0!==m)return{schema:m,implementation:i}};export const UserExpressions=(t,a)=>{let{latestModel:i,evalExpressionParser:m,parsingContext:l}=a,{allNames:c}=i,h=[...c].map(String),f=[];for(let[a,i]of Object.entries(t)){c.has(a)||l.error(r.EXPRESSION_UNKNOWN_ENTITY_KEY,n.EXPRESSION_UNKNOWN_ENTITY_KEY(a,h));let t=e(a);for(let[r,n]of Object.entries(i)){let i=l.at(a),c=s(r,i);if(!c)continue;let h=o(n,`${a}.${r}`,i.at(r),m);h&&f.push(e({entityKey:t,name:c,schema:h.schema,declaredSchema:h.schema,implementation:h.implementation}))}}if(!l.hasErrors)return f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Branded as e}from"@salsita-ai/common/utils";import{CONSTANT_CAPS as t
|
|
1
|
+
import{Branded as e}from"@salsita-ai/common/utils";import{CONSTANT_CAPS as t}from"../../../core/index.js";import{resolveEnhancedJsonValue as r}from"../../../enhanced-json/index.js";import{DiagnosticCode as i,diagnosticMessages as n}from"../../../errors/index.js";import{ShapePropertyName as o}from"./names/shape-property-name.js";let s=(e,t,r,o,s)=>{for(let l of r.validatePartialShape(t).errors){let t=l.instancePath?l.instancePath:"(root)",r=l.instancePath.split("/").filter(Boolean)[0]??"";o.error(i.DEFAULTS_SCHEMA_VIOLATION,n[i.DEFAULTS_SCHEMA_VIOLATION](e,r,t,l.message,s))}};export const Defaults=(l,a,f)=>{let E=a.allNames,T=[...E].map(String),S=new Map,N=new Map;for(let e of a.entitySchemas)S.set(e.entityType,new Set(Object.keys(e.shapeProperties))),N.set(e.entityType,e);let g={},O=new Map;for(let[e,_]of Object.entries(l)){let l=f.at(e);if(!E.has(e)){f.error(i.DEFAULTS_UNKNOWN_ENTITY_KEY,n[i.DEFAULTS_UNKNOWN_ENTITY_KEY](e,T));continue}let c=a.aliases.get(e),p=void 0!==c,h={};for(let[t,r]of Object.entries(_)){let s=o(t,l);if(s){if(p){let t=[];for(let e of c){let r=S.get(e);r&&r.has(s)||t.push(String(e))}if(t.length>0){let r=c[0],o=r?[...S.get(r)??[]]:[];f.error(i.DEFAULTS_UNKNOWN_PROPERTY,n[i.DEFAULTS_UNKNOWN_PROPERTY](e,s,o,t));continue}}else{let t=S.get(e);if(!t||!t.has(s)){let r=t?[...t]:[];f.error(i.DEFAULTS_UNKNOWN_PROPERTY,n[i.DEFAULTS_UNKNOWN_PROPERTY](e,s,r));continue}}h[s]=r}}if(0===Object.keys(h).length)continue;let m=r(h,void 0,t,l);if(void 0!==m){if(p)for(let t of c){let r=N.get(t);r&&s(e,m,r,l,String(t))}else{let t=N.get(e);t&&s(e,m,t,l)}for(let t of c??[e])g[String(t)]={...g[String(t)],...h},O.set(t,[...O.get(t)??[],e])}}for(let[e,t]of O){let r=g[String(e)]??{},o=(N.get(e)?.shapeSchema.required??[]).filter(e=>!Object.hasOwn(r,e));if(0===o.length)continue;let s=t.includes(String(e))?String(e):t.at(-1);f.at(s).error(i.DEFAULTS_INCOMPLETE,n[i.DEFAULTS_INCOMPLETE](String(e),o,t))}if(Object.keys(l).length>0&&f.warning(i.DEFAULTS_DEPRECATED,n[i.DEFAULTS_DEPRECATED]()),!f.hasErrors)return e({entries:g})};
|
|
@@ -127,11 +127,25 @@ export declare class AssistantSystem implements InitializableSystem {
|
|
|
127
127
|
private readonly _recorder;
|
|
128
128
|
/** The recorder's subscription to the committed emissions of the store; made by the first `initialize()`. */
|
|
129
129
|
private _recording;
|
|
130
|
+
/**
|
|
131
|
+
* The tool call of every `apply` by the state it committed or held, for as long as the state
|
|
132
|
+
* lives: an undone state that the undo history dropped is forgotten with it.
|
|
133
|
+
*
|
|
134
|
+
* Accepted: a commit the project's `registerIsUndoable` keeps out of the history never becomes a
|
|
135
|
+
* step, so the row of its `apply` never offers Undo.
|
|
136
|
+
*/
|
|
137
|
+
private readonly _applyToolCallIds;
|
|
138
|
+
private readonly _undoTipToolCallId;
|
|
130
139
|
constructor(_context: AssistantSystemContext);
|
|
131
140
|
/** The conversation. It never completes, and holds the empty chat whenever no chat is active. */
|
|
132
141
|
readonly chat$: ObservableWithLastValue<AssistantChatSnapshot>;
|
|
133
142
|
/** The state of the built-in panel. It never completes. */
|
|
134
143
|
readonly panel$: ObservableWithLastValue<AssistantPanelSnapshot>;
|
|
144
|
+
/**
|
|
145
|
+
* The `apply` tool call whose committed state is the step of the undo history the configuration is
|
|
146
|
+
* at; nothing when that step is not a change of the assistant. It never completes.
|
|
147
|
+
*/
|
|
148
|
+
readonly undoTipToolCallId$: ObservableWithLastValue<string | undefined>;
|
|
135
149
|
/**
|
|
136
150
|
* A new configuration load: the chat of the previous one is deactivated and both observables go
|
|
137
151
|
* back to their empty values. An activation that is still held outlives it and gets the chat of
|
|
@@ -227,6 +241,15 @@ export declare class AssistantSystem implements InitializableSystem {
|
|
|
227
241
|
* server is therefore gone from the thread and has to be written again.
|
|
228
242
|
*/
|
|
229
243
|
reloadThread: () => void;
|
|
244
|
+
/**
|
|
245
|
+
* Undoes the changes of the given `apply` tool calls, one undo step at a time, while the step the
|
|
246
|
+
* configuration is at is one of them. A change the user made in between stops it, so it is never
|
|
247
|
+
* taken back; the non-undoable commits made on top of an undone change go with it, as with the
|
|
248
|
+
* toolbar's undo.
|
|
249
|
+
*
|
|
250
|
+
* Accepted: like the toolbar's undo, it does not check the session mode; only `apply` requires `owner`.
|
|
251
|
+
*/
|
|
252
|
+
undoToolCalls: (toolCallIds: ReadonlySet<string>) => void;
|
|
230
253
|
setOpen: (open: boolean) => void;
|
|
231
254
|
setInputFocused: (isInputFocused: boolean) => void;
|
|
232
255
|
/**
|
|
@@ -237,6 +260,12 @@ export declare class AssistantSystem implements InitializableSystem {
|
|
|
237
260
|
private _findRefusedMessageIndex;
|
|
238
261
|
private _sendOn;
|
|
239
262
|
private _resume;
|
|
263
|
+
/**
|
|
264
|
+
* The `apply` call whose committed state is the step the configuration is at. Nothing at the bottom
|
|
265
|
+
* of the history, where nothing can be undone: that step was not made by a change it could take back.
|
|
266
|
+
*/
|
|
267
|
+
private _findTipToolCallId;
|
|
268
|
+
private _refreshUndoTip;
|
|
240
269
|
private _committedState;
|
|
241
270
|
private _patchPanel;
|
|
242
271
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ChatClient as e,fetchServerSentEvents as t}from"@tanstack/ai-client";import{BehaviorSubject as i}from"rxjs";import{skip as s}from"rxjs/operators";import{isShallowEqual as a}from"@salsita-ai/common/utils";import{AssistantRequestError as r}from"#package/client";import{createBrowserDetailsClientTool as n}from"./browser-details.js";import{ChangeRecorder as
|
|
1
|
+
import{ChatClient as e,fetchServerSentEvents as t}from"@tanstack/ai-client";import{BehaviorSubject as i}from"rxjs";import{skip as s}from"rxjs/operators";import{isShallowEqual as a}from"@salsita-ai/common/utils";import{AssistantRequestError as r}from"#package/client";import{createBrowserDetailsClientTool as n}from"./browser-details.js";import{ChangeRecorder as o}from"./change-recorder.js";import{createApplyClientTool as l,createQueryClientTool as h}from"./graphql-tools.js";let d=Object.freeze({messages:Object.freeze([]),isLoading:!1,error:void 0,failedStatus:void 0,isContinuable:!0,isLoaded:!1,isResuming:!1,earlierThreads:Object.freeze([]),hasEarlierThread:!1,isLoadingEarlierThread:!1}),c=Object.freeze({open:!1,hasUnreadReply:!1,isInputFocused:!1}),u=Object.freeze({}),_=Object.freeze({results:Object.freeze([]),committed:!1,sideEffects:Object.freeze([]),message:"Nothing was run, because the user closed the configurator while this reply was being written. Do not call any more tools in this reply and end it now. The tools work again as soon as the user writes the next message."}),g=e=>{if(e.getError())return!0;let t=e.getMessages().at(-1)?.parts.at(-1);return t?.type!=="tool-call"&&t?.type!=="tool-result"};export class AssistantSystem{_context;_tools;_chat=new i(d);_panel=new i(c);_activation=null;_current=null;_finishing=new Set;_olderThreadId=null;_resuming=null;_refused=null;_firstAttempt=null;_chain={};_loadingThreadId=null;_recorder;_recording=null;_applyToolCallIds=new WeakMap;_undoTipToolCallId=new i(void 0);constructor(e){this._context=e;let{configuratorExtensionSelectors:t,domainContextSelectors:i,domainServicesSelectors:s,getAssistantSetup:a}=e;this._recorder=new o({maxEntities:30},{readers:{selectedEntityId:e=>i.getNavigationSystem().getActiveSelectionState(e),navigationState:e=>i.getNavigationSystem().getActiveNavigationState(e),viewState:e=>i.getNavigationSystem().getActiveViewState(e),toolState:e=>i.getNavigationSystem().getActiveToolState(e)},getExposedFields:()=>a().manifest?.fields??u,resolveLocalizable:e=>s.getResolveLocalizable()(e)});let r={getGraphQLSystem:()=>t.getGraphQLSystem(),getStoreSystem:()=>i.getStoreSystem(),getActiveMode:()=>i.getActiveMode(),clearChanges:()=>this._recorder.clear(this._committedState()),rememberCommit:(e,t)=>{this._applyToolCallIds.set(t,e),this._refreshUndoTip()}};this._tools=[n(),h(r),l(r)],i.getUndoSystem().tip$.subscribe(this._refreshUndoTip)}chat$=this._chat;panel$=this._panel;undoTipToolCallId$=this._undoTipToolCallId;initialize=()=>{let{committed:e}=this._context.domainContextSelectors.getStoreSystem().stateSlices;this._recording??=e.pipe(s(1)).subscribe(this._recorder.record),this._recorder.reset(e.value.state),this._endChat(),this._patchPanel(c),this._activation&&this._startClient()};activate=()=>{this._endChat();let e={};return this._activation=e,this._startClient(),()=>{this._activation===e&&(this._activation=null,this._endChat())}};send=async e=>{if(!this._chat.value.isContinuable&&!await this.resume())return;let t=this._current;if(!t)return;let i={changes:this._recorder.take(this._committedState())};this._firstAttempt=t;try{await this._sendOn(t,e,i);let s=this._findRefusedMessageIndex(t);if(-1===s)return;this._refused={chat:t,index:s}}finally{this._firstAttempt===t&&(this._firstAttempt=null)}if(!await this.resume())return;let s=this._current;s&&await this._sendOn(s,e,i)};resume=async()=>{let e=this._current;if(!e)return!1;if(this._chat.value.isContinuable)return!0;if(this._resuming)return this._resuming;let t=this._resume(e).finally(()=>{this._resuming===t&&(this._resuming=null)});return this._resuming=t,t};loadEarlierThread=async()=>{let e=this._current,t=this._olderThreadId;if(!e||null===t||this._loadingThreadId===t)return;let i=this._chain;this._loadingThreadId=t,this._chat.next({...this._chat.value,isLoadingEarlierThread:!0});try{let s=await e.authorizedClient.getAssistantEarlierThread(e.configurationId,t,50);if(this._chain!==i||this._olderThreadId!==t)return;this._olderThreadId=s.previousThreadId,this._chat.next({...this._chat.value,earlierThreads:[{threadId:t,messages:s.messages},...this._chat.value.earlierThreads],hasEarlierThread:null!==s.previousThreadId})}catch(e){this._context.domainServicesSelectors.getLogger().warn("Could not load the earlier assistant conversation",{error:e})}finally{this._chain===i&&this._loadingThreadId===t&&(this._loadingThreadId=null,this._chat.next({...this._chat.value,isLoadingEarlierThread:!1}))}};stop=async()=>{let e=this._current;if(!e)return;let t=e.client.getCurrentRunId();if(e.client.stop(),null!=t)try{let i=e.getConnection();await fetch(`${i.url}/runs/${encodeURIComponent(t)}/cancel`,{method:"POST",headers:await i.headers()})}catch(e){this._context.domainServicesSelectors.getLogger().warn("Could not cancel the assistant run on the server",{error:e})}};reloadThread=()=>{if(!this._activation)return;let e=this._retireChat();e?.client.stop(),e?.dispose(),this._recorder.reset(this._committedState()),this._startClient()};undoToolCalls=e=>{let t=this._context.domainContextSelectors.getUndoSystem(),i=()=>{let t=this._findTipToolCallId();return void 0!==t&&e.has(t)};for(;i();)t.undo()};setOpen=e=>{this._patchPanel(e?{open:e,hasUnreadReply:!1}:{open:e,isInputFocused:!1})};setInputFocused=e=>{this._patchPanel({isInputFocused:e})};_findRefusedMessageIndex=e=>{var t;let i,{failedStatus:s,isContinuable:a}=this._chat.value;return this._firstAttempt===e&&e.generation.active&&409===s&&!a?(i=(t=e.client.getMessages()).map(e=>e.role).lastIndexOf("user"),t.slice(i+1).every(e=>0===e.parts.length)?i:-1):-1};_sendOn=async(e,t,i)=>{let{client:s}=e;s.getIsLoading()||null===s.getResumeState()||s.stop();try{await s.sendMessage({content:t,metadata:i})}catch(i){let t=i instanceof Error?i:Error(String(i));e.generation.active&&this._chat.next({...this._chat.value,error:t}),this._context.domainServicesSelectors.getLogger().error("The assistant message could not be sent",{},t)}};_resume=async e=>{this._chat.next({...this._chat.value,isResuming:!0,error:void 0,failedStatus:void 0});try{let{previousThreadId:t}=await e.authorizedClient.compactAssistantThread(e.configurationId);if(!e.generation.active)return!1;let{messages:i,earlierThreads:s,hasEarlierThread:a}=this._chat.value,r=this._refused?.chat===e?i.slice(0,this._refused.index):i;return e.generation.active=!1,this._current=null,e.client.stop(),e.dispose(),this._chat.next({...d,earlierThreads:[...s,{threadId:t,messages:r}],hasEarlierThread:a,isLoadingEarlierThread:null!==this._loadingThreadId}),this._startClient(),!0}catch(i){let t=i instanceof Error?i:Error(String(i));if(t instanceof r&&409===t.status)return e.generation.active&&this.reloadThread(),!1;return e.generation.active&&this._chat.next({...this._chat.value,isResuming:!1,error:t,failedStatus:t instanceof r?t.status:void 0}),this._context.domainServicesSelectors.getLogger().error("The assistant thread could not be resumed",{},t),!1}};_findTipToolCallId=()=>{let e=this._context.domainContextSelectors.getUndoSystem(),t=e.tip$.value?.committedState;return void 0!==t&&e.canUndo()?this._applyToolCallIds.get(t):void 0};_refreshUndoTip=()=>{let e=this._findTipToolCallId();e!==this._undoTipToolCallId.value&&this._undoTipToolCallId.next(e)};_committedState=()=>this._context.domainContextSelectors.getStoreSystem().stateSlices.committed.value.state;_patchPanel=e=>{let t={...this._panel.value,...e};a(t,this._panel.value)||this._panel.next(t)};_takeOverThread=e=>{for(let t of this._finishing)t.configurationId===e&&(t.client.stop(),t.dispose())};_startClient=()=>{let i={active:!0},s=this._context.getConfigurationId();this._takeOverThread(s);let r=this._context.getAuthorizedClient(),n=()=>{if(i.active){let{manifest:e,error:t}=this._context.getAssistantSetup();if(t)throw t;if(!e)throw Error("The assistant is disabled for this session.")}return r.getAssistantChatConnection(s)},o=e=>{if(!i.active)return;let t={...this._chat.value,...e};a(t,this._chat.value)||this._chat.next(t)},l=async(e,t)=>{let s=await fetch(e,t).finally(()=>o({isLoaded:!0})),a=s.headers.get("x-assistant-thread-continuable");return null!=a&&s.ok&&i.active&&0===this._chat.value.earlierThreads.length&&(this._olderThreadId=s.headers.get("x-assistant-previous-thread")),o({failedStatus:s.ok?void 0:s.status,...null!=a&&{isContinuable:"false"!==a,hasEarlierThread:null!==this._olderThreadId}}),s},h=async()=>({headers:await n().headers(),fetchClient:l}),d=t(()=>n().url,h),c=t(()=>`${n().url}/runs`,h),u=this._tools.map(e=>({...e,execute:(t,s)=>{if(!i.active)return _;let{manifest:a,error:r}=this._context.getAssistantSetup();return r||!a?{error:r?.message??"The assistant is disabled for this session."}:e.execute?.(t,s)}})),m=new e({threadId:`assistant:${s}`,connection:{...d,joinRun:c.joinRun},persistence:!0,history:{pageSize:50},tools:u,onMessagesChange:e=>o({messages:e}),onLoadingChange:e=>{let t=i.active&&this._chat.value.isLoading;o({isLoading:e}),!e&&g(m)&&(i.active?t&&!this._panel.value.open&&this._patchPanel({hasUnreadReply:!0}):p())},onErrorChange:e=>{i.active&&e!==this._chat.value.error&&(!e||-1===this._findRefusedMessageIndex(v))&&(o({error:e}),e&&this._context.domainServicesSelectors.getLogger().error("The assistant request failed",{status:this._chat.value.failedStatus},e))}}),f=!1,p=()=>{f||(f=!0,this._finishing.delete(v),m.dispose())},v={client:m,configurationId:s,generation:i,authorizedClient:r,getConnection:n,dispose:p};this._current=v,m.attach()};_retireChat=()=>{let e=this._current;return this._current=null,e&&(e.generation.active=!1),this._chain={},this._olderThreadId=null,this._resuming=null,this._refused=null,this._loadingThreadId=null,this._chat.value!==d&&this._chat.next(d),e};_endChat=()=>{let e=this._retireChat();if(e){if(!e.client.getIsLoading()&&g(e.client))return void e.dispose();this._finishing.add(e)}}}
|
package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts
CHANGED
|
@@ -20,6 +20,11 @@ export interface AssistantToolDependencies {
|
|
|
20
20
|
readonly getActiveMode: () => DomainMode;
|
|
21
21
|
/** Forgets the changes recorded for the next change record, so it never lists what the agent itself changed. */
|
|
22
22
|
readonly clearChanges: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Remembers the state an `apply` call committed or held for the user's approval, so the panel can
|
|
25
|
+
* tell while that state is the step of the undo history the configuration is at.
|
|
26
|
+
*/
|
|
27
|
+
readonly rememberCommit: (toolCallId: string, state: DomainState<DomainEntity<string>>) => void;
|
|
23
28
|
}
|
|
24
29
|
/**
|
|
25
30
|
* Browser implementation of the assistant's `query` tool: prepares the operations from the
|
|
@@ -93,7 +98,8 @@ export declare const createQueryClientTool: (dependencies: AssistantToolDependen
|
|
|
93
98
|
* `GraphQLSystem.execute`, which commits their changes as one undo step, and returns its result,
|
|
94
99
|
* including why nothing was committed when a commit was held or lost to a conflict. A commit clears
|
|
95
100
|
* the recorded changes; a held one does not, so it shows in the next change record once the user
|
|
96
|
-
* approves it.
|
|
101
|
+
* approves it. The state it committed or held is remembered under the id of the call, so the chip
|
|
102
|
+
* row of the call can undo it. Only an owner
|
|
97
103
|
* session may change the configuration; the check lives here and not in the `GraphQLSystem`, whose
|
|
98
104
|
* other caller, the editor panel, has its own rules.
|
|
99
105
|
*/
|
package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AssistantGraphQLToolInput as e,applyTool as t,queryTool as o}from"@salsita-ai/contracts/assistant";let a=e=>({results:[],committed:!1,message:e,sideEffects:[]}),i=e=>JSON.parse(JSON.stringify(
|
|
1
|
+
import{AssistantGraphQLToolInput as e,applyTool as t,queryTool as o}from"@salsita-ai/contracts/assistant";let a=e=>({results:[],committed:!1,message:e,sideEffects:[]}),i=({preparedState:e,...t})=>JSON.parse(JSON.stringify(t)),s=t=>{let o=e.safeParse(t);if(!o.success){let e=o.error.issues.map(e=>`${e.path.join(".")}: ${e.message}`).join("; ");return{ok:!1,refusal:a(`Nothing was run, because the tool input is not a list of operations (${e}). Send { "operations": [{ "query": "<one GraphQL operation>" }] } with at least one item.`)}}return{ok:!0,operations:o.data.operations.map(({query:e,variables:t,operationName:o})=>({document:e,variables:t??void 0,operationName:o??void 0}))}};export const createQueryClientTool=e=>o.client(async t=>{let o=s(t);if(!o.ok)return o.refusal;let r=e.getStoreSystem();if(!r.isInitialized)return a("Nothing was run, because the configuration is not loaded yet, so there is no state to query. Call the tool again once the configurator has finished loading.");let n=e.getGraphQLSystem(),l=await n.prepare(r.stateSlices.committed.value.state,o.operations);return i({results:l.map(({result:e})=>e),committed:!1,sideEffects:n.readSideEffects(l)})});export const createApplyClientTool=e=>t.client(async(t,o)=>{if("owner"!==e.getActiveMode())return a("Nothing was run, because changes cannot be applied in this session: the user may view this configuration but not change it. The query tool still works here, including mutations, to show what a change would do without keeping it.");let r=s(t);if(!r.ok)return r.refusal;let n=await e.getGraphQLSystem().execute(r.operations),l=o?.toolCallId;return void 0!==l&&void 0!==n.preparedState&&e.rememberCommit(l,n.preparedState),n.committed&&e.clearChanges(),i(n)});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Object3D, Vector2, Vector3 } from 'three';
|
|
2
2
|
import type { ObservableWithLastValue } from '@salsita-ai/common/utils';
|
|
3
|
-
import type { DomainContextSelectors, DomainEntity, DomainEntityId, DomainServicesSelectors, DomainState, DraggableSurface } from '#package/domain';
|
|
3
|
+
import type { DomainContextSelectors, DomainEntity, DomainEntityId, DomainServicesSelectors, DomainState, DraggableSurface, RotatableSurface } from '#package/domain';
|
|
4
4
|
import type { ConfiguratorExtensionSelectors } from '../../selectors.js';
|
|
5
5
|
/**
|
|
6
6
|
* Constructor context of a `DragAndDropSystem`. Same-layer configurator peers are reached through
|
|
@@ -17,7 +17,7 @@ export interface DraggableState {
|
|
|
17
17
|
readonly type: 'draggable';
|
|
18
18
|
readonly entityId: DomainEntityId<string>;
|
|
19
19
|
readonly originalMouseDiff: Vector3;
|
|
20
|
-
readonly draggingPlanes: DraggableSurface[];
|
|
20
|
+
readonly draggingPlanes: readonly DraggableSurface[];
|
|
21
21
|
readonly dragHandleInstance: string;
|
|
22
22
|
readonly newWorldPosition: Vector3;
|
|
23
23
|
readonly originalWorldPosition: Vector3;
|
|
@@ -28,7 +28,7 @@ export interface RotationDraggingState {
|
|
|
28
28
|
readonly type: 'rotation';
|
|
29
29
|
readonly entityId: DomainEntityId<string>;
|
|
30
30
|
readonly originalMouseVector: Vector2;
|
|
31
|
-
readonly draggingPlane:
|
|
31
|
+
readonly draggingPlane: RotatableSurface;
|
|
32
32
|
readonly originalEntityVector: Vector3;
|
|
33
33
|
readonly initialAngle: number;
|
|
34
34
|
readonly dragHandleTarget: string;
|
package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts
CHANGED
|
@@ -39,6 +39,12 @@ export interface GraphQLExecution {
|
|
|
39
39
|
readonly message?: string;
|
|
40
40
|
/** What the configurator did, or would do, beyond what the operations asked for, in applied order. */
|
|
41
41
|
readonly sideEffects: readonly string[];
|
|
42
|
+
/**
|
|
43
|
+
* The state the operations prepared, when it was committed or held for the user's approval; a
|
|
44
|
+
* held state is the one committed if the user approves. A caller can recognize its own change in
|
|
45
|
+
* the undo history by it. It stays in the browser: nothing that leaves it may carry the state.
|
|
46
|
+
*/
|
|
47
|
+
readonly preparedState?: AnyDomainState;
|
|
42
48
|
}
|
|
43
49
|
/**
|
|
44
50
|
* Resolves a localizable value, or each item of a list of them, to a string in the current locale.
|