@nimiplatform/sdk 0.22.2 → 0.24.0-rc.10
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/CHANGELOG.md +211 -0
- package/README.md +30 -1
- package/dist/core/ai/capability-configuration.d.ts +35 -1
- package/dist/core/ai/capability-configuration.d.ts.map +1 -1
- package/dist/core/ai/capability-configuration.js +58 -3
- package/dist/core/ai/capability-configuration.js.map +1 -1
- package/dist/core/ai/index.d.ts +1 -0
- package/dist/core/ai/index.d.ts.map +1 -1
- package/dist/core/ai/index.js +1 -0
- package/dist/core/ai/index.js.map +1 -1
- package/dist/core/ai/local-app-model.d.ts +3 -0
- package/dist/core/ai/local-app-model.d.ts.map +1 -1
- package/dist/core/ai/local-app-model.js +7 -7
- package/dist/core/ai/local-app-model.js.map +1 -1
- package/dist/core/ai/reasoning.d.ts +3 -1
- package/dist/core/ai/reasoning.d.ts.map +1 -1
- package/dist/core/ai/reasoning.js +2 -1
- package/dist/core/ai/reasoning.js.map +1 -1
- package/dist/core/app/desktop-open.d.ts +17 -4
- package/dist/core/app/desktop-open.d.ts.map +1 -1
- package/dist/core/app/desktop-open.js +46 -6
- package/dist/core/app/desktop-open.js.map +1 -1
- package/dist/core/app/index.d.ts +8 -2
- package/dist/core/app/index.d.ts.map +1 -1
- package/dist/core/app/index.js +3 -0
- package/dist/core/app/index.js.map +1 -1
- package/dist/core/app/local-app-agent-work-input.d.ts +1 -1
- package/dist/core/app/local-app-agent-work-input.d.ts.map +1 -1
- package/dist/core/app/local-app-agent-work-input.js +5 -2
- package/dist/core/app/local-app-agent-work-input.js.map +1 -1
- package/dist/core/app/local-app-character-discovery.d.ts +44 -0
- package/dist/core/app/local-app-character-discovery.d.ts.map +1 -0
- package/dist/core/app/local-app-character-discovery.js +82 -0
- package/dist/core/app/local-app-character-discovery.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-activity-view.d.ts +2 -0
- package/dist/core/app/local-app-runtime-platform-activity-view.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-activity-view.js +4 -1
- package/dist/core/app/local-app-runtime-platform-activity-view.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-activity.d.ts +2 -2
- package/dist/core/app/local-app-runtime-platform-activity.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-activity.js +2 -0
- package/dist/core/app/local-app-runtime-platform-activity.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-agent-work.js +1 -1
- package/dist/core/app/local-app-runtime-platform-agent-work.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-ai-config.d.ts +3 -3
- package/dist/core/app/local-app-runtime-platform-ai-config.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-ai-config.js +19 -7
- package/dist/core/app/local-app-runtime-platform-ai-config.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-ai.d.ts +28 -2
- package/dist/core/app/local-app-runtime-platform-ai.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-ai.js +112 -25
- package/dist/core/app/local-app-runtime-platform-ai.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-assets.d.ts +2 -0
- package/dist/core/app/local-app-runtime-platform-assets.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-assets.js +5 -2
- package/dist/core/app/local-app-runtime-platform-assets.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-direct-ai-realtime.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-direct-ai-realtime.js +33 -4
- package/dist/core/app/local-app-runtime-platform-direct-ai-realtime.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-direct-realtime-shared.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-direct-realtime-shared.js +1 -0
- package/dist/core/app/local-app-runtime-platform-direct-realtime-shared.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-integration.d.ts +13 -0
- package/dist/core/app/local-app-runtime-platform-integration.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-integration.js +89 -15
- package/dist/core/app/local-app-runtime-platform-integration.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-realm-realtime.js +1 -1
- package/dist/core/app/local-app-runtime-platform-realm-realtime.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-realtime.d.ts +55 -10
- package/dist/core/app/local-app-runtime-platform-realtime.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-realtime.js +66 -23
- package/dist/core/app/local-app-runtime-platform-realtime.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-utopia.d.ts +208 -0
- package/dist/core/app/local-app-runtime-platform-utopia.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-utopia.js +629 -0
- package/dist/core/app/local-app-runtime-platform-utopia.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-world-creator.d.ts +2 -0
- package/dist/core/app/local-app-runtime-platform-world-creator.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-world-creator.js +8 -6
- package/dist/core/app/local-app-runtime-platform-world-creator.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform.d.ts +7 -3
- package/dist/core/app/local-app-runtime-platform.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform.js +22 -112
- package/dist/core/app/local-app-runtime-platform.js.map +1 -1
- package/dist/core/app/local-app-text-candidate.d.ts +3 -0
- package/dist/core/app/local-app-text-candidate.d.ts.map +1 -0
- package/dist/core/app/local-app-text-candidate.js +100 -0
- package/dist/core/app/local-app-text-candidate.js.map +1 -0
- package/dist/core/app/local-app-text.d.ts +6 -0
- package/dist/core/app/local-app-text.d.ts.map +1 -1
- package/dist/core/app/local-app-text.js +19 -4
- package/dist/core/app/local-app-text.js.map +1 -1
- package/dist/core/app/portable-client.d.ts +17 -0
- package/dist/core/app/portable-client.d.ts.map +1 -0
- package/dist/core/app/portable-client.js +2 -0
- package/dist/core/app/portable-client.js.map +1 -0
- package/dist/core/app/runtime-account-realm-source-readiness.generated.d.ts +2 -2
- package/dist/core/app/runtime-account-realm-source-readiness.generated.d.ts.map +1 -1
- package/dist/core/app/runtime-account-realm-source-readiness.generated.js +11 -1
- package/dist/core/app/runtime-account-realm-source-readiness.generated.js.map +1 -1
- package/dist/core/contracts/primitives.d.ts +8 -0
- package/dist/core/contracts/primitives.d.ts.map +1 -1
- package/dist/core/contracts/primitives.js.map +1 -1
- package/dist/core-client/index.d.ts +3 -1
- package/dist/core-client/index.d.ts.map +1 -1
- package/dist/core-client/index.js +13 -2
- package/dist/core-client/index.js.map +1 -1
- package/dist/core-generated/realm-client.d.ts.map +1 -1
- package/dist/core-generated/realm-client.js +166 -4
- package/dist/core-generated/realm-client.js.map +1 -1
- package/dist/core-generated/realm-typed-client.d.ts +712 -28
- package/dist/core-generated/realm-typed-client.d.ts.map +1 -1
- package/dist/core-generated/realm-typed-client.js +333 -6
- package/dist/core-generated/realm-typed-client.js.map +1 -1
- package/dist/core-generated/runtime-client.d.ts.map +1 -1
- package/dist/core-generated/runtime-client.js +112 -0
- package/dist/core-generated/runtime-client.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/account.d.ts +137 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/account.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/account.js +314 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/account.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.d.ts +154 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.js +343 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_utopia.d.ts +985 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_utopia.d.ts.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_utopia.js +2132 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_utopia.js.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.d.ts +315 -3
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.js +569 -7
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai_realtime.d.ts +229 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai_realtime.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai_realtime.js +432 -7
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai_realtime.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.d.ts +33 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.js +74 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/audit.d.ts +31 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/audit.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/audit.js +62 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/audit.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/auth.d.ts +33 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/auth.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/auth.js +76 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/auth.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/capability_configuration.d.ts +151 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/capability_configuration.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/capability_configuration.js +281 -5
- package/dist/core-generated/runtime-protobuf/runtime/v1/capability_configuration.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/common.d.ts +31 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/common.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/common.js +30 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/common.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/connector.d.ts +298 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/connector.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/connector.js +611 -4
- package/dist/core-generated/runtime-protobuf/runtime/v1/connector.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/integration.d.ts +146 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/integration.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/integration.js +296 -4
- package/dist/core-generated/runtime-protobuf/runtime/v1/integration.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime.d.ts +12 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime.js +25 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/realtime_control.d.ts +5 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/realtime_control.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/realtime_control.js +4 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/realtime_control.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/remote_access.d.ts +552 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/remote_access.d.ts.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/remote_access.js +1097 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/remote_access.js.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/runtime_service_control.d.ts +4 -3
- package/dist/core-generated/runtime-protobuf/runtime/v1/runtime_service_control.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/runtime_service_control.js.map +1 -1
- package/dist/core-generated/runtime-public-client.d.ts.map +1 -1
- package/dist/core-generated/runtime-public-client.js +104 -0
- package/dist/core-generated/runtime-public-client.js.map +1 -1
- package/dist/core-generated/runtime-public-rpc-auth-posture.d.ts.map +1 -1
- package/dist/core-generated/runtime-public-rpc-auth-posture.js +13 -0
- package/dist/core-generated/runtime-public-rpc-auth-posture.js.map +1 -1
- package/dist/core-generated/runtime-public-wire-codecs.d.ts +18 -3
- package/dist/core-generated/runtime-public-wire-codecs.d.ts.map +1 -1
- package/dist/core-generated/runtime-public-wire-codecs.js +18 -3
- package/dist/core-generated/runtime-public-wire-codecs.js.map +1 -1
- package/dist/core-generated/runtime-rpc-auth-posture.d.ts.map +1 -1
- package/dist/core-generated/runtime-rpc-auth-posture.js +14 -0
- package/dist/core-generated/runtime-rpc-auth-posture.js.map +1 -1
- package/dist/core-generated/runtime-typed-client.d.ts +37 -18
- package/dist/core-generated/runtime-typed-client.d.ts.map +1 -1
- package/dist/core-generated/runtime-typed-client.js +159 -8
- package/dist/core-generated/runtime-typed-client.js.map +1 -1
- package/dist/core-generated/runtime-wire-codecs.d.ts +20 -4
- package/dist/core-generated/runtime-wire-codecs.d.ts.map +1 -1
- package/dist/core-generated/runtime-wire-codecs.js +20 -4
- package/dist/core-generated/runtime-wire-codecs.js.map +1 -1
- package/dist/features/generation/runtime-image-generation.d.ts +8 -1
- package/dist/features/generation/runtime-image-generation.d.ts.map +1 -1
- package/dist/features/generation/runtime-image-generation.js +7 -0
- package/dist/features/generation/runtime-image-generation.js.map +1 -1
- package/dist/features/generation/runtime-scenarios.d.ts +8 -1
- package/dist/features/generation/runtime-scenarios.d.ts.map +1 -1
- package/dist/features/generation/runtime-scenarios.js +17 -1
- package/dist/features/generation/runtime-scenarios.js.map +1 -1
- package/dist/realm/account-settings.d.ts +2 -2
- package/dist/realm/account-settings.d.ts.map +1 -1
- package/dist/realm/auth.d.ts.map +1 -1
- package/dist/realm/auth.js +1 -0
- package/dist/realm/auth.js.map +1 -1
- package/dist/realm/index.d.ts +5 -4
- package/dist/realm/index.d.ts.map +1 -1
- package/dist/realm/index.js +7 -1
- package/dist/realm/index.js.map +1 -1
- package/dist/realm/media-delivery.d.ts.map +1 -1
- package/dist/realm/media-delivery.js +15 -7
- package/dist/realm/media-delivery.js.map +1 -1
- package/dist/realm/notifications.d.ts +2 -0
- package/dist/realm/notifications.d.ts.map +1 -1
- package/dist/realm/notifications.js +8 -3
- package/dist/realm/notifications.js.map +1 -1
- package/dist/realm/resource-upload.d.ts +13 -0
- package/dist/realm/resource-upload.d.ts.map +1 -1
- package/dist/realm/resource-upload.js +35 -21
- package/dist/realm/resource-upload.js.map +1 -1
- package/dist/realm/runtime-client.d.ts +57 -0
- package/dist/realm/runtime-client.d.ts.map +1 -0
- package/dist/realm/runtime-client.js +241 -0
- package/dist/realm/runtime-client.js.map +1 -0
- package/dist/realm/social-types.d.ts +1 -1
- package/dist/realm/social-types.d.ts.map +1 -1
- package/dist/realm/social.d.ts +17 -3
- package/dist/realm/social.d.ts.map +1 -1
- package/dist/realm/social.js +66 -114
- package/dist/realm/social.js.map +1 -1
- package/dist/runtime/config-projections.d.ts +25 -0
- package/dist/runtime/config-projections.d.ts.map +1 -1
- package/dist/runtime/config-projections.js +4 -0
- package/dist/runtime/config-projections.js.map +1 -1
- package/dist/runtime/connector-inventory.d.ts +14 -3
- package/dist/runtime/connector-inventory.d.ts.map +1 -1
- package/dist/runtime/connector-inventory.js +13 -0
- package/dist/runtime/connector-inventory.js.map +1 -1
- package/dist/runtime/desktop-first-party-runtime.d.ts +2 -0
- package/dist/runtime/desktop-first-party-runtime.d.ts.map +1 -1
- package/dist/runtime/desktop-first-party-runtime.js +12 -0
- package/dist/runtime/desktop-first-party-runtime.js.map +1 -1
- package/dist/runtime/electron-ipc.d.ts.map +1 -1
- package/dist/runtime/electron-ipc.js +61 -26
- package/dist/runtime/electron-ipc.js.map +1 -1
- package/dist/runtime/first-party-protected-runtime-profiles.generated.d.ts +275 -1
- package/dist/runtime/first-party-protected-runtime-profiles.generated.d.ts.map +1 -1
- package/dist/runtime/first-party-protected-runtime-profiles.generated.js +74 -1
- package/dist/runtime/first-party-protected-runtime-profiles.generated.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/reason-messages.d.ts +5 -0
- package/dist/runtime/reason-messages.d.ts.map +1 -1
- package/dist/runtime/reason-messages.js +10 -0
- package/dist/runtime/reason-messages.js.map +1 -1
- package/dist/runtime/remote-app.d.ts +63 -0
- package/dist/runtime/remote-app.d.ts.map +1 -0
- package/dist/runtime/remote-app.js +184 -0
- package/dist/runtime/remote-app.js.map +1 -0
- package/dist/runtime/remote-data-channel.d.ts +25 -0
- package/dist/runtime/remote-data-channel.d.ts.map +1 -0
- package/dist/runtime/remote-data-channel.js +406 -0
- package/dist/runtime/remote-data-channel.js.map +1 -0
- package/dist/runtime/remote-realm.d.ts +9 -0
- package/dist/runtime/remote-realm.d.ts.map +1 -0
- package/dist/runtime/remote-realm.js +82 -0
- package/dist/runtime/remote-realm.js.map +1 -0
- package/dist/runtime/remote.d.ts +114 -0
- package/dist/runtime/remote.d.ts.map +1 -0
- package/dist/runtime/remote.js +177 -0
- package/dist/runtime/remote.js.map +1 -0
- package/dist/runtime/runtime-agent-consume-streams.d.ts.map +1 -1
- package/dist/runtime/runtime-agent-consume-streams.js +37 -15
- package/dist/runtime/runtime-agent-consume-streams.js.map +1 -1
- package/dist/runtime/runtime-agent-context-projections.d.ts +1 -1
- package/dist/runtime/runtime-agent-context-projections.d.ts.map +1 -1
- package/dist/runtime/runtime-agent-context-projections.js +5 -1
- package/dist/runtime/runtime-agent-context-projections.js.map +1 -1
- package/dist/runtime/wire-types/agent-participation-types.d.ts +4 -2
- package/dist/runtime/wire-types/agent-participation-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-enums.d.ts +58 -4
- package/dist/runtime/wire-types/ai-scenario-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-enums.js +60 -0
- package/dist/runtime/wire-types/ai-scenario-enums.js.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-types.d.ts +10 -8
- package/dist/runtime/wire-types/ai-scenario-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/identity-app-types.d.ts +8 -8
- package/dist/runtime/wire-types/identity-app-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/reason-code-enums.d.ts +8 -1
- package/dist/runtime/wire-types/reason-code-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/reason-code-enums.js +7 -0
- package/dist/runtime/wire-types/reason-code-enums.js.map +1 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +1 -0
- package/dist/types/errors.js.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/reason-code.d.ts +5 -0
- package/dist/types/reason-code.d.ts.map +1 -1
- package/dist/types/reason-code.js +5 -0
- package/dist/types/reason-code.js.map +1 -1
- package/package.json +12 -2
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
import { asRecord, assertExactKeys, assertExactProjectionKeys, canonicalString, decimalCursor, localAppError, localAppProjectionError, projectTimestamp, } from './local-app-runtime-platform-validation.js';
|
|
2
|
+
const utf8Encoder = new TextEncoder();
|
|
3
|
+
const HABITAT_DAYPARTS = new Set(['morning', 'day', 'dusk', 'night']);
|
|
4
|
+
const HABITAT_THEME_TAGS = new Set([
|
|
5
|
+
'seaside', 'polar', 'xianxia', 'farming', 'woodland',
|
|
6
|
+
'mountain', 'harbor', 'observatory', 'courtyard', 'shelter',
|
|
7
|
+
]);
|
|
8
|
+
const HABITAT_ARCHETYPES = new Set([
|
|
9
|
+
'lookout', 'workshop', 'garden', 'waterside',
|
|
10
|
+
'hearth', 'library', 'courtyard', 'shelter',
|
|
11
|
+
]);
|
|
12
|
+
const HABITAT_SOCIAL_MODES = new Set(['solo', 'co_present', 'shared_invite']);
|
|
13
|
+
const HABITAT_SCENERY_KINDS = new Set([
|
|
14
|
+
'clear-sky', 'rain', 'snowfall', 'mist',
|
|
15
|
+
'aurora', 'meteor-shower', 'blossom', 'wildlife-visit',
|
|
16
|
+
'tide-pooling', 'harvest', 'hearth-lit', 'radio-signal',
|
|
17
|
+
]);
|
|
18
|
+
const UTOPIA_SHARED_STATES = new Set([
|
|
19
|
+
'invited', 'accepted', 'active', 'completed',
|
|
20
|
+
'declined', 'expired', 'invalidated',
|
|
21
|
+
'relocated', 'relocated_partial',
|
|
22
|
+
'missed', 'interrupted', 'unanswered', 'unavailable',
|
|
23
|
+
]);
|
|
24
|
+
const NAMESPACED_ID_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/u;
|
|
25
|
+
const LOCAL_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
|
|
26
|
+
const SHORT_NOUN_FORBIDDEN_RE = /[\u0000-\u001f\u007f.!?。!?;;::\r\n\t<>[\]{}]/u;
|
|
27
|
+
const DISPLAY_SUMMARY_FORBIDDEN_RE = /[\u0000-\u001f\u007f]/u;
|
|
28
|
+
const BACKDROP_FORBIDDEN_RE = /[\u0000-\u0009\u000b-\u001f\u007f]/u;
|
|
29
|
+
const AGENT_HANDLE_RE = /^agent_ref_[\w-]{43}$/u;
|
|
30
|
+
function failMode(isInput, field) {
|
|
31
|
+
if (isInput) {
|
|
32
|
+
localAppError(`Invalid Utopia input field: ${field}.`, 'SDK_LOCAL_APP_INPUT_INVALID', 'fix_utopia_input');
|
|
33
|
+
}
|
|
34
|
+
return localAppProjectionError(field);
|
|
35
|
+
}
|
|
36
|
+
function codePoints(value) {
|
|
37
|
+
return [...value].length;
|
|
38
|
+
}
|
|
39
|
+
function utf8Bytes(value) {
|
|
40
|
+
return utf8Encoder.encode(value).byteLength;
|
|
41
|
+
}
|
|
42
|
+
function checkRevision(value, isInput) {
|
|
43
|
+
if (typeof value !== 'string' || !/^[1-9]\d*$/u.test(value) || value.length > 20
|
|
44
|
+
|| (value.length === 20 && value > '18446744073709551615')) {
|
|
45
|
+
failMode(isInput, 'Utopia revision');
|
|
46
|
+
}
|
|
47
|
+
return decimalCursor(value, 'Utopia revision');
|
|
48
|
+
}
|
|
49
|
+
function checkBoolean(value, field, isInput) {
|
|
50
|
+
if (typeof value !== 'boolean')
|
|
51
|
+
failMode(isInput, field);
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
function checkIntRange(value, min, max, field, isInput) {
|
|
55
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < min || value > max) {
|
|
56
|
+
failMode(isInput, field);
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
function checkNamespacedId(value, field, isInput) {
|
|
61
|
+
if (typeof value !== 'string' || value.length < 3 || value.length > 64 || !NAMESPACED_ID_RE.test(value)) {
|
|
62
|
+
failMode(isInput, field);
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
function checkLocalSlug(value, field, isInput) {
|
|
67
|
+
if (typeof value !== 'string' || value.length < 1 || value.length > 32 || !LOCAL_SLUG_RE.test(value)) {
|
|
68
|
+
failMode(isInput, field);
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
function checkShortNounLabel(value, field, isInput) {
|
|
73
|
+
if (typeof value !== 'string' || value.trim() !== value || !value
|
|
74
|
+
|| SHORT_NOUN_FORBIDDEN_RE.test(value) || codePoints(value) > 16 || utf8Bytes(value) > 48) {
|
|
75
|
+
failMode(isInput, field);
|
|
76
|
+
}
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
function checkDisplaySummary(value, field, isInput, allowEmpty = true) {
|
|
80
|
+
if (typeof value !== 'string')
|
|
81
|
+
failMode(isInput, field);
|
|
82
|
+
if (value === '') {
|
|
83
|
+
if (!allowEmpty)
|
|
84
|
+
failMode(isInput, field);
|
|
85
|
+
return '';
|
|
86
|
+
}
|
|
87
|
+
if (value.trim() !== value || DISPLAY_SUMMARY_FORBIDDEN_RE.test(value)
|
|
88
|
+
|| codePoints(value) > 120 || utf8Bytes(value) > 480) {
|
|
89
|
+
failMode(isInput, field);
|
|
90
|
+
}
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
function checkBackdropProse(value, field, isInput) {
|
|
94
|
+
if (typeof value !== 'string' || value.trim() !== value || !value
|
|
95
|
+
|| BACKDROP_FORBIDDEN_RE.test(value) || codePoints(value) > 240 || utf8Bytes(value) > 960) {
|
|
96
|
+
failMode(isInput, field);
|
|
97
|
+
}
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
100
|
+
function checkTimezone(value, field, isInput) {
|
|
101
|
+
if (typeof value !== 'string' || value.trim() !== value || value.length < 1 || value.length > 64
|
|
102
|
+
|| /[\u0000-\u0020\u007f-\uffff]/u.test(value)) {
|
|
103
|
+
failMode(isInput, field);
|
|
104
|
+
}
|
|
105
|
+
return value;
|
|
106
|
+
}
|
|
107
|
+
function checkEnum(value, allowed, field, isInput) {
|
|
108
|
+
if (typeof value !== 'string' || !allowed.has(value))
|
|
109
|
+
failMode(isInput, field);
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
function checkExactObject(value, keys, field, isInput) {
|
|
113
|
+
if (isInput) {
|
|
114
|
+
const record = asRecord(value);
|
|
115
|
+
if (!record)
|
|
116
|
+
failMode(true, field);
|
|
117
|
+
assertExactKeys(record, keys, field);
|
|
118
|
+
for (const key of keys) {
|
|
119
|
+
if (!(key in record))
|
|
120
|
+
failMode(true, `${field}.${key}`);
|
|
121
|
+
}
|
|
122
|
+
return record;
|
|
123
|
+
}
|
|
124
|
+
assertExactProjectionKeys(value, keys, field);
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
function checkArray(value, min, max, field, isInput, item) {
|
|
128
|
+
if (!Array.isArray(value) || value.length < min || value.length > max)
|
|
129
|
+
failMode(isInput, field);
|
|
130
|
+
return Object.freeze(value.map((entry, index) => item(entry, index)));
|
|
131
|
+
}
|
|
132
|
+
function checkConditions(value, paramOptions, field, isInput) {
|
|
133
|
+
const seenKeys = new Set();
|
|
134
|
+
return checkArray(value, 0, 4, field, isInput, (entry) => {
|
|
135
|
+
const record = checkExactObject(entry, ['parameterKey', 'allowedValues'], field, isInput);
|
|
136
|
+
const parameterKey = checkLocalSlug(record.parameterKey, `${field}.parameterKey`, isInput);
|
|
137
|
+
const allowedSet = paramOptions.get(parameterKey);
|
|
138
|
+
if (!allowedSet || seenKeys.has(parameterKey))
|
|
139
|
+
failMode(isInput, `${field}.parameterKey`);
|
|
140
|
+
seenKeys.add(parameterKey);
|
|
141
|
+
const seenVals = new Set();
|
|
142
|
+
const allowedValues = checkArray(record.allowedValues, 1, 5, `${field}.allowedValues`, isInput, (rawVal) => {
|
|
143
|
+
const val = checkLocalSlug(rawVal, `${field}.allowedValues`, isInput);
|
|
144
|
+
if (!allowedSet.has(val) || seenVals.has(val))
|
|
145
|
+
failMode(isInput, `${field}.allowedValues`);
|
|
146
|
+
seenVals.add(val);
|
|
147
|
+
return val;
|
|
148
|
+
});
|
|
149
|
+
return Object.freeze({ parameterKey, allowedValues });
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
// @nimi-authority: rule.nimi.runtime.agent-life.utopia-settings
|
|
153
|
+
// @nimi-authority: rule.nimi.sdks.feature-clients.utopia
|
|
154
|
+
export function validateHabitatSpecV1(value, isInput = true) {
|
|
155
|
+
const root = checkExactObject(value, [
|
|
156
|
+
'schemaVersion', 'habitatId', 'title', 'themeTag', 'backdropSummary',
|
|
157
|
+
'personalQuarter', 'places', 'activities', 'parameters', 'eventPresets',
|
|
158
|
+
], 'HabitatSpecV1', isInput);
|
|
159
|
+
if (root.schemaVersion !== '1.0')
|
|
160
|
+
failMode(isInput, 'HabitatSpecV1.schemaVersion');
|
|
161
|
+
if (isInput) {
|
|
162
|
+
const encoded = JSON.stringify(root);
|
|
163
|
+
if (typeof encoded !== 'string' || utf8Bytes(encoded) > 16_384) {
|
|
164
|
+
failMode(true, 'HabitatSpecV1 byte size');
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const habitatId = checkNamespacedId(root.habitatId, 'HabitatSpecV1.habitatId', isInput);
|
|
168
|
+
const title = checkShortNounLabel(root.title, 'HabitatSpecV1.title', isInput);
|
|
169
|
+
const themeTag = checkEnum(root.themeTag, HABITAT_THEME_TAGS, 'HabitatSpecV1.themeTag', isInput);
|
|
170
|
+
const backdropSummary = checkBackdropProse(root.backdropSummary, 'HabitatSpecV1.backdropSummary', isInput);
|
|
171
|
+
const pqRec = checkExactObject(root.personalQuarter, ['id', 'name', 'sensoryTraits'], 'HabitatSpecV1.personalQuarter', isInput);
|
|
172
|
+
if (pqRec.id !== 'personal-quarter')
|
|
173
|
+
failMode(isInput, 'HabitatSpecV1.personalQuarter.id');
|
|
174
|
+
const personalQuarter = Object.freeze({
|
|
175
|
+
id: 'personal-quarter',
|
|
176
|
+
name: checkShortNounLabel(pqRec.name, 'HabitatSpecV1.personalQuarter.name', isInput),
|
|
177
|
+
sensoryTraits: checkDisplaySummary(pqRec.sensoryTraits, 'HabitatSpecV1.personalQuarter.sensoryTraits', isInput),
|
|
178
|
+
});
|
|
179
|
+
const paramOptions = new Map();
|
|
180
|
+
const parameters = checkArray(root.parameters, 0, 4, 'HabitatSpecV1.parameters', isInput, (entry) => {
|
|
181
|
+
const rec = checkExactObject(entry, ['key', 'label', 'defaultValue', 'options'], 'HabitatParameterSpec', isInput);
|
|
182
|
+
const key = checkLocalSlug(rec.key, 'HabitatParameterSpec.key', isInput);
|
|
183
|
+
if (paramOptions.has(key))
|
|
184
|
+
failMode(isInput, 'HabitatParameterSpec.key');
|
|
185
|
+
const label = checkShortNounLabel(rec.label, 'HabitatParameterSpec.label', isInput);
|
|
186
|
+
const optionValues = new Set();
|
|
187
|
+
const options = checkArray(rec.options, 2, 5, 'HabitatParameterSpec.options', isInput, (optEntry) => {
|
|
188
|
+
const optRec = checkExactObject(optEntry, ['value', 'label', 'summary'], 'HabitatParameterOption', isInput);
|
|
189
|
+
const optValue = checkLocalSlug(optRec.value, 'HabitatParameterOption.value', isInput);
|
|
190
|
+
if (optionValues.has(optValue))
|
|
191
|
+
failMode(isInput, 'HabitatParameterOption.value');
|
|
192
|
+
optionValues.add(optValue);
|
|
193
|
+
return Object.freeze({
|
|
194
|
+
value: optValue,
|
|
195
|
+
label: checkShortNounLabel(optRec.label, 'HabitatParameterOption.label', isInput),
|
|
196
|
+
summary: checkDisplaySummary(optRec.summary, 'HabitatParameterOption.summary', isInput),
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
const defaultValue = checkLocalSlug(rec.defaultValue, 'HabitatParameterSpec.defaultValue', isInput);
|
|
200
|
+
if (!optionValues.has(defaultValue))
|
|
201
|
+
failMode(isInput, 'HabitatParameterSpec.defaultValue');
|
|
202
|
+
paramOptions.set(key, optionValues);
|
|
203
|
+
return Object.freeze({ key, label, defaultValue, options });
|
|
204
|
+
});
|
|
205
|
+
const placeIdsSet = new Set();
|
|
206
|
+
const places = checkArray(root.places, 1, 8, 'HabitatSpecV1.places', isInput, (entry) => {
|
|
207
|
+
const rec = checkExactObject(entry, ['id', 'name', 'archetype', 'indoor', 'sensoryTraits', 'openWhen'], 'HabitatPlaceSpec', isInput);
|
|
208
|
+
const id = checkLocalSlug(rec.id, 'HabitatPlaceSpec.id', isInput);
|
|
209
|
+
if (id === 'personal-quarter' || placeIdsSet.has(id))
|
|
210
|
+
failMode(isInput, 'HabitatPlaceSpec.id');
|
|
211
|
+
placeIdsSet.add(id);
|
|
212
|
+
return Object.freeze({
|
|
213
|
+
id,
|
|
214
|
+
name: checkShortNounLabel(rec.name, 'HabitatPlaceSpec.name', isInput),
|
|
215
|
+
archetype: checkEnum(rec.archetype, HABITAT_ARCHETYPES, 'HabitatPlaceSpec.archetype', isInput),
|
|
216
|
+
indoor: checkBoolean(rec.indoor, 'HabitatPlaceSpec.indoor', isInput),
|
|
217
|
+
sensoryTraits: checkDisplaySummary(rec.sensoryTraits, 'HabitatPlaceSpec.sensoryTraits', isInput),
|
|
218
|
+
openWhen: checkConditions(rec.openWhen, paramOptions, 'HabitatPlaceSpec.openWhen', isInput),
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
const activityIdsSet = new Set();
|
|
222
|
+
let hasAllDayPersonalFallback = false;
|
|
223
|
+
const activities = checkArray(root.activities, 2, 24, 'HabitatSpecV1.activities', isInput, (entry) => {
|
|
224
|
+
const rec = checkExactObject(entry, ['id', 'name', 'placeIds', 'socialMode', 'allowedDayparts', 'when', 'minDurationMinutes', 'maxDurationMinutes', 'sceneHint'], 'HabitatActivitySpec', isInput);
|
|
225
|
+
const id = checkLocalSlug(rec.id, 'HabitatActivitySpec.id', isInput);
|
|
226
|
+
if (activityIdsSet.has(id))
|
|
227
|
+
failMode(isInput, 'HabitatActivitySpec.id');
|
|
228
|
+
activityIdsSet.add(id);
|
|
229
|
+
const seenPlaces = new Set();
|
|
230
|
+
const placeIds = checkArray(rec.placeIds, 1, 4, 'HabitatActivitySpec.placeIds', isInput, (rawPlace) => {
|
|
231
|
+
const pid = checkLocalSlug(rawPlace, 'HabitatActivitySpec.placeIds', isInput);
|
|
232
|
+
if ((pid !== 'personal-quarter' && !placeIdsSet.has(pid)) || seenPlaces.has(pid)) {
|
|
233
|
+
failMode(isInput, 'HabitatActivitySpec.placeIds');
|
|
234
|
+
}
|
|
235
|
+
seenPlaces.add(pid);
|
|
236
|
+
return pid;
|
|
237
|
+
});
|
|
238
|
+
const socialMode = checkEnum(rec.socialMode, HABITAT_SOCIAL_MODES, 'HabitatActivitySpec.socialMode', isInput);
|
|
239
|
+
if (seenPlaces.has('personal-quarter') && (placeIds.length !== 1 || socialMode !== 'solo')) {
|
|
240
|
+
failMode(isInput, 'HabitatActivitySpec.personalQuarterIsolation');
|
|
241
|
+
}
|
|
242
|
+
const seenDayparts = new Set();
|
|
243
|
+
const allowedDayparts = checkArray(rec.allowedDayparts, 1, 4, 'HabitatActivitySpec.allowedDayparts', isInput, (rawDp) => {
|
|
244
|
+
const dp = checkEnum(rawDp, HABITAT_DAYPARTS, 'HabitatActivitySpec.allowedDayparts', isInput);
|
|
245
|
+
if (seenDayparts.has(dp))
|
|
246
|
+
failMode(isInput, 'HabitatActivitySpec.allowedDayparts');
|
|
247
|
+
seenDayparts.add(dp);
|
|
248
|
+
return dp;
|
|
249
|
+
});
|
|
250
|
+
const when = checkConditions(rec.when, paramOptions, 'HabitatActivitySpec.when', isInput);
|
|
251
|
+
const minDurationMinutes = checkIntRange(rec.minDurationMinutes, 15, 240, 'HabitatActivitySpec.minDurationMinutes', isInput);
|
|
252
|
+
const maxDurationMinutes = checkIntRange(rec.maxDurationMinutes, minDurationMinutes, 240, 'HabitatActivitySpec.maxDurationMinutes', isInput);
|
|
253
|
+
const sceneHint = checkDisplaySummary(rec.sceneHint, 'HabitatActivitySpec.sceneHint', isInput);
|
|
254
|
+
if (placeIds.length === 1 && placeIds[0] === 'personal-quarter'
|
|
255
|
+
&& socialMode === 'solo' && when.length === 0 && allowedDayparts.length === 4) {
|
|
256
|
+
hasAllDayPersonalFallback = true;
|
|
257
|
+
}
|
|
258
|
+
return Object.freeze({
|
|
259
|
+
id,
|
|
260
|
+
name: checkShortNounLabel(rec.name, 'HabitatActivitySpec.name', isInput),
|
|
261
|
+
placeIds,
|
|
262
|
+
socialMode,
|
|
263
|
+
allowedDayparts,
|
|
264
|
+
when,
|
|
265
|
+
minDurationMinutes,
|
|
266
|
+
maxDurationMinutes,
|
|
267
|
+
sceneHint,
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
if (!hasAllDayPersonalFallback) {
|
|
271
|
+
failMode(isInput, 'HabitatSpecV1.personalQuarterAllDayFallback');
|
|
272
|
+
}
|
|
273
|
+
const presetIdsSet = new Set();
|
|
274
|
+
const eventPresets = checkArray(root.eventPresets, 0, 8, 'HabitatSpecV1.eventPresets', isInput, (entry) => {
|
|
275
|
+
const rec = checkExactObject(entry, ['id', 'sceneryKind', 'label', 'description', 'placeId', 'defaultDurationMinutes'], 'HabitatEventPresetSpec', isInput);
|
|
276
|
+
const id = checkLocalSlug(rec.id, 'HabitatEventPresetSpec.id', isInput);
|
|
277
|
+
if (presetIdsSet.has(id))
|
|
278
|
+
failMode(isInput, 'HabitatEventPresetSpec.id');
|
|
279
|
+
presetIdsSet.add(id);
|
|
280
|
+
let placeId = null;
|
|
281
|
+
if (rec.placeId !== null) {
|
|
282
|
+
const pid = checkLocalSlug(rec.placeId, 'HabitatEventPresetSpec.placeId', isInput);
|
|
283
|
+
if (!placeIdsSet.has(pid))
|
|
284
|
+
failMode(isInput, 'HabitatEventPresetSpec.placeId');
|
|
285
|
+
placeId = pid;
|
|
286
|
+
}
|
|
287
|
+
return Object.freeze({
|
|
288
|
+
id,
|
|
289
|
+
sceneryKind: checkEnum(rec.sceneryKind, HABITAT_SCENERY_KINDS, 'HabitatEventPresetSpec.sceneryKind', isInput),
|
|
290
|
+
label: checkShortNounLabel(rec.label, 'HabitatEventPresetSpec.label', isInput),
|
|
291
|
+
description: checkDisplaySummary(rec.description, 'HabitatEventPresetSpec.description', isInput),
|
|
292
|
+
placeId,
|
|
293
|
+
defaultDurationMinutes: checkIntRange(rec.defaultDurationMinutes, 30, 720, 'HabitatEventPresetSpec.defaultDurationMinutes', isInput),
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
return Object.freeze({
|
|
297
|
+
schemaVersion: '1.0',
|
|
298
|
+
habitatId,
|
|
299
|
+
title,
|
|
300
|
+
themeTag,
|
|
301
|
+
backdropSummary,
|
|
302
|
+
personalQuarter,
|
|
303
|
+
places,
|
|
304
|
+
activities,
|
|
305
|
+
parameters,
|
|
306
|
+
eventPresets,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
function projectTimestampRequired(value, field) {
|
|
310
|
+
const result = projectTimestamp(value, field);
|
|
311
|
+
if (!result)
|
|
312
|
+
localAppProjectionError(field);
|
|
313
|
+
return Object.freeze(result);
|
|
314
|
+
}
|
|
315
|
+
function projectBoundedText(value, field, optional = false, maxBytes = 256) {
|
|
316
|
+
const result = canonicalString(value, field);
|
|
317
|
+
if ((!optional && !result) || utf8Bytes(result) > maxBytes || result.includes('\0')) {
|
|
318
|
+
localAppProjectionError(field);
|
|
319
|
+
}
|
|
320
|
+
return result;
|
|
321
|
+
}
|
|
322
|
+
function checkParameterRecord(value, field, isInput, maxEntries = 4) {
|
|
323
|
+
const record = asRecord(value);
|
|
324
|
+
if (!record)
|
|
325
|
+
failMode(isInput, field);
|
|
326
|
+
const entries = Object.entries(record);
|
|
327
|
+
if (entries.length > maxEntries)
|
|
328
|
+
failMode(isInput, field);
|
|
329
|
+
const out = {};
|
|
330
|
+
for (const [key, rawVal] of entries) {
|
|
331
|
+
out[checkLocalSlug(key, `${field}.key`, isInput)] = checkLocalSlug(rawVal, `${field}.${key}`, isInput);
|
|
332
|
+
}
|
|
333
|
+
return Object.freeze(out);
|
|
334
|
+
}
|
|
335
|
+
function projectActiveEvent(value) {
|
|
336
|
+
assertExactProjectionKeys(value, ['eventId', 'slot', 'sceneryKind', 'label', 'description', 'placeId', 'startsAt', 'expiresAt'], 'Utopia active event');
|
|
337
|
+
if (value.slot !== 'preset' && value.slot !== 'custom')
|
|
338
|
+
localAppProjectionError('Utopia active event slot');
|
|
339
|
+
return Object.freeze({
|
|
340
|
+
eventId: projectBoundedText(value.eventId, 'Utopia eventId', false, 64),
|
|
341
|
+
slot: value.slot,
|
|
342
|
+
sceneryKind: checkEnum(value.sceneryKind, HABITAT_SCENERY_KINDS, 'Utopia sceneryKind', false),
|
|
343
|
+
label: checkShortNounLabel(value.label, 'Utopia event label', false),
|
|
344
|
+
description: checkDisplaySummary(value.description, 'Utopia event description', false),
|
|
345
|
+
placeId: value.placeId === null ? null : checkLocalSlug(value.placeId, 'Utopia event placeId', false),
|
|
346
|
+
startsAt: projectTimestampRequired(value.startsAt, 'Utopia event startsAt'),
|
|
347
|
+
expiresAt: projectTimestampRequired(value.expiresAt, 'Utopia event expiresAt'),
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
function projectFrame(value) {
|
|
351
|
+
if (value === null)
|
|
352
|
+
return null;
|
|
353
|
+
assertExactProjectionKeys(value, [
|
|
354
|
+
'activityId', 'title', 'habitatActivationId', 'habitatId', 'habitatTitle',
|
|
355
|
+
'placeId', 'placeLabel', 'startsAt', 'endsAt', 'interaction',
|
|
356
|
+
], 'Utopia frame');
|
|
357
|
+
return Object.freeze({
|
|
358
|
+
activityId: projectBoundedText(value.activityId, 'Utopia frame activityId', true, 64),
|
|
359
|
+
title: projectBoundedText(value.title, 'Utopia frame title', false, 64),
|
|
360
|
+
habitatActivationId: projectBoundedText(value.habitatActivationId, 'Utopia frame habitatActivationId', true, 64),
|
|
361
|
+
habitatId: projectBoundedText(value.habitatId, 'Utopia frame habitatId', true, 64),
|
|
362
|
+
habitatTitle: projectBoundedText(value.habitatTitle, 'Utopia frame habitatTitle', true, 64),
|
|
363
|
+
placeId: projectBoundedText(value.placeId, 'Utopia frame placeId', true, 64),
|
|
364
|
+
placeLabel: projectBoundedText(value.placeLabel, 'Utopia frame placeLabel', true, 64),
|
|
365
|
+
startsAt: projectTimestampRequired(value.startsAt, 'Utopia frame startsAt'),
|
|
366
|
+
endsAt: value.endsAt === null ? null : projectTimestampRequired(value.endsAt, 'Utopia frame endsAt'),
|
|
367
|
+
interaction: checkBoolean(value.interaction, 'Utopia frame interaction', false),
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
function projectRelocation(value) {
|
|
371
|
+
if (value === null)
|
|
372
|
+
return null;
|
|
373
|
+
assertExactProjectionKeys(value, ['fromHabitatId', 'fromHabitatTitle', 'toHabitatId', 'toHabitatTitle', 'relocatedAt'], 'Utopia relocation summary');
|
|
374
|
+
return Object.freeze({
|
|
375
|
+
fromHabitatId: projectBoundedText(value.fromHabitatId, 'Utopia fromHabitatId', false, 64),
|
|
376
|
+
fromHabitatTitle: projectBoundedText(value.fromHabitatTitle, 'Utopia fromHabitatTitle', false, 64),
|
|
377
|
+
toHabitatId: projectBoundedText(value.toHabitatId, 'Utopia toHabitatId', false, 64),
|
|
378
|
+
toHabitatTitle: projectBoundedText(value.toHabitatTitle, 'Utopia toHabitatTitle', false, 64),
|
|
379
|
+
relocatedAt: projectTimestampRequired(value.relocatedAt, 'Utopia relocatedAt'),
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
function projectOpenPlaceIds(raw) {
|
|
383
|
+
return checkArray(raw, 0, 8, 'Utopia openPlaceIds', false, (id) => {
|
|
384
|
+
const slug = checkLocalSlug(id, 'Utopia openPlaceId', false);
|
|
385
|
+
if (slug === 'personal-quarter')
|
|
386
|
+
localAppProjectionError('Utopia openPlaceId personal-quarter');
|
|
387
|
+
return slug;
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
function projectSnapshot(value) {
|
|
391
|
+
assertExactProjectionKeys(value, [
|
|
392
|
+
'revision', 'observedAt', 'habitatActivationId', 'contentDigest', 'timezone',
|
|
393
|
+
'publicParticipation', 'habitat', 'parameterValues', 'openPlaceIds',
|
|
394
|
+
'activeEvents', 'lastRelocation', 'residents', 'occupancy', 'sharedActivities',
|
|
395
|
+
], 'Utopia snapshot');
|
|
396
|
+
const contentDigest = projectBoundedText(value.contentDigest, 'Utopia contentDigest', false, 72);
|
|
397
|
+
if (!/^sha256:[0-9a-f]{64}$/u.test(contentDigest))
|
|
398
|
+
localAppProjectionError('Utopia contentDigest');
|
|
399
|
+
const seenResidentHandles = new Set();
|
|
400
|
+
const seenOccupancyPlaces = new Set();
|
|
401
|
+
const seenSharedRefs = new Set();
|
|
402
|
+
return Object.freeze({
|
|
403
|
+
revision: checkRevision(value.revision, false),
|
|
404
|
+
observedAt: projectTimestampRequired(value.observedAt, 'Utopia observedAt'),
|
|
405
|
+
habitatActivationId: projectBoundedText(value.habitatActivationId, 'Utopia habitatActivationId', false, 64),
|
|
406
|
+
contentDigest,
|
|
407
|
+
timezone: checkTimezone(value.timezone, 'Utopia timezone', false),
|
|
408
|
+
publicParticipation: checkBoolean(value.publicParticipation, 'Utopia publicParticipation', false),
|
|
409
|
+
habitat: validateHabitatSpecV1(value.habitat, false),
|
|
410
|
+
parameterValues: checkParameterRecord(value.parameterValues, 'Utopia parameterValues', false, 4),
|
|
411
|
+
openPlaceIds: projectOpenPlaceIds(value.openPlaceIds),
|
|
412
|
+
activeEvents: checkArray(value.activeEvents, 0, 2, 'Utopia activeEvents', false, projectActiveEvent),
|
|
413
|
+
lastRelocation: projectRelocation(value.lastRelocation),
|
|
414
|
+
residents: checkArray(value.residents, 0, Number.MAX_SAFE_INTEGER, 'Utopia residents', false, (row) => {
|
|
415
|
+
assertExactProjectionKeys(row, ['agentHandle', 'displayName', 'solitary', 'current', 'recent', 'next'], 'Utopia resident');
|
|
416
|
+
const handle = projectBoundedText(row.agentHandle, 'Utopia Agent handle', false, 64);
|
|
417
|
+
if (!AGENT_HANDLE_RE.test(handle) || seenResidentHandles.has(handle)) {
|
|
418
|
+
localAppProjectionError('Utopia Agent handle');
|
|
419
|
+
}
|
|
420
|
+
seenResidentHandles.add(handle);
|
|
421
|
+
return Object.freeze({
|
|
422
|
+
agentHandle: handle,
|
|
423
|
+
displayName: projectBoundedText(row.displayName, 'Utopia display name', false, 256),
|
|
424
|
+
solitary: checkBoolean(row.solitary, 'Utopia solitude', false),
|
|
425
|
+
current: projectFrame(row.current),
|
|
426
|
+
recent: projectFrame(row.recent),
|
|
427
|
+
next: projectFrame(row.next),
|
|
428
|
+
});
|
|
429
|
+
}),
|
|
430
|
+
occupancy: checkArray(value.occupancy, 0, 8, 'Utopia occupancy', false, (row) => {
|
|
431
|
+
assertExactProjectionKeys(row, ['placeId', 'agentHandles'], 'Utopia occupancy');
|
|
432
|
+
const placeId = checkLocalSlug(row.placeId, 'Utopia occupancy placeId', false);
|
|
433
|
+
if (placeId === 'personal-quarter' || seenOccupancyPlaces.has(placeId)) {
|
|
434
|
+
localAppProjectionError('Utopia occupancy placeId');
|
|
435
|
+
}
|
|
436
|
+
seenOccupancyPlaces.add(placeId);
|
|
437
|
+
const seenOccupantHandles = new Set();
|
|
438
|
+
return Object.freeze({
|
|
439
|
+
placeId,
|
|
440
|
+
agentHandles: checkArray(row.agentHandles, 1, Number.MAX_SAFE_INTEGER, 'Utopia occupants', false, (rawHandle) => {
|
|
441
|
+
const handle = projectBoundedText(rawHandle, 'Utopia occupant handle', false, 64);
|
|
442
|
+
if (!AGENT_HANDLE_RE.test(handle) || seenOccupantHandles.has(handle)) {
|
|
443
|
+
localAppProjectionError('Utopia occupant handle');
|
|
444
|
+
}
|
|
445
|
+
seenOccupantHandles.add(handle);
|
|
446
|
+
return handle;
|
|
447
|
+
}),
|
|
448
|
+
});
|
|
449
|
+
}),
|
|
450
|
+
sharedActivities: checkArray(value.sharedActivities, 0, Number.MAX_SAFE_INTEGER, 'Utopia sharedActivities', false, (row) => {
|
|
451
|
+
assertExactProjectionKeys(row, [
|
|
452
|
+
'activityRef', 'habitatActivationId', 'habitatId', 'habitatTitle',
|
|
453
|
+
'initiatorHandle', 'recipientHandle', 'placeId', 'placeLabel',
|
|
454
|
+
'activityId', 'activityLabel', 'state', 'startsAt', 'endsAt', 'acceptedAt',
|
|
455
|
+
], 'Utopia shared activity');
|
|
456
|
+
const activityRef = projectBoundedText(row.activityRef, 'Utopia activityRef', false, 64);
|
|
457
|
+
if (seenSharedRefs.has(activityRef))
|
|
458
|
+
localAppProjectionError('Utopia activityRef');
|
|
459
|
+
seenSharedRefs.add(activityRef);
|
|
460
|
+
const initiatorHandle = projectBoundedText(row.initiatorHandle, 'Utopia initiatorHandle', true, 64);
|
|
461
|
+
const recipientHandle = projectBoundedText(row.recipientHandle, 'Utopia recipientHandle', true, 64);
|
|
462
|
+
if ((initiatorHandle && !AGENT_HANDLE_RE.test(initiatorHandle))
|
|
463
|
+
|| (recipientHandle && !AGENT_HANDLE_RE.test(recipientHandle))) {
|
|
464
|
+
localAppProjectionError('Utopia shared handle');
|
|
465
|
+
}
|
|
466
|
+
return Object.freeze({
|
|
467
|
+
activityRef,
|
|
468
|
+
habitatActivationId: projectBoundedText(row.habitatActivationId, 'Utopia shared habitatActivationId', true, 64),
|
|
469
|
+
habitatId: projectBoundedText(row.habitatId, 'Utopia shared habitatId', true, 64),
|
|
470
|
+
habitatTitle: projectBoundedText(row.habitatTitle, 'Utopia shared habitatTitle', true, 64),
|
|
471
|
+
initiatorHandle,
|
|
472
|
+
recipientHandle,
|
|
473
|
+
placeId: projectBoundedText(row.placeId, 'Utopia shared placeId', false, 64),
|
|
474
|
+
placeLabel: projectBoundedText(row.placeLabel, 'Utopia shared placeLabel', false, 64),
|
|
475
|
+
activityId: projectBoundedText(row.activityId, 'Utopia shared activityId', false, 64),
|
|
476
|
+
activityLabel: projectBoundedText(row.activityLabel, 'Utopia shared activityLabel', false, 64),
|
|
477
|
+
state: checkEnum(row.state, UTOPIA_SHARED_STATES, 'Utopia shared state', false),
|
|
478
|
+
startsAt: row.startsAt === null ? null : projectTimestampRequired(row.startsAt, 'Utopia shared startsAt'),
|
|
479
|
+
endsAt: row.endsAt === null ? null : projectTimestampRequired(row.endsAt, 'Utopia shared endsAt'),
|
|
480
|
+
acceptedAt: row.acceptedAt === null ? null : projectTimestampRequired(row.acceptedAt, 'Utopia shared acceptedAt'),
|
|
481
|
+
});
|
|
482
|
+
}),
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
function projectMutationAck(value) {
|
|
486
|
+
assertExactProjectionKeys(value, [
|
|
487
|
+
'revision', 'habitatActivationId', 'habitatId', 'habitatTitle', 'contentDigest',
|
|
488
|
+
'timezone', 'publicParticipation', 'parameterValues', 'openPlaceIds', 'activeEvents',
|
|
489
|
+
], 'Utopia mutation ack');
|
|
490
|
+
const contentDigest = projectBoundedText(value.contentDigest, 'Utopia contentDigest', false, 72);
|
|
491
|
+
if (!/^sha256:[0-9a-f]{64}$/u.test(contentDigest))
|
|
492
|
+
localAppProjectionError('Utopia contentDigest');
|
|
493
|
+
return Object.freeze({
|
|
494
|
+
revision: checkRevision(value.revision, false),
|
|
495
|
+
habitatActivationId: projectBoundedText(value.habitatActivationId, 'Utopia habitatActivationId', false, 64),
|
|
496
|
+
habitatId: checkNamespacedId(value.habitatId, 'Utopia habitatId', false),
|
|
497
|
+
habitatTitle: checkShortNounLabel(value.habitatTitle, 'Utopia habitatTitle', false),
|
|
498
|
+
contentDigest,
|
|
499
|
+
timezone: checkTimezone(value.timezone, 'Utopia timezone', false),
|
|
500
|
+
publicParticipation: checkBoolean(value.publicParticipation, 'Utopia publicParticipation', false),
|
|
501
|
+
parameterValues: checkParameterRecord(value.parameterValues, 'Utopia parameterValues', false, 4),
|
|
502
|
+
openPlaceIds: projectOpenPlaceIds(value.openPlaceIds),
|
|
503
|
+
activeEvents: checkArray(value.activeEvents, 0, 2, 'Utopia activeEvents', false, projectActiveEvent),
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
function normalizeEventMutationInput(value) {
|
|
507
|
+
const rec = asRecord(value);
|
|
508
|
+
if (!rec || typeof rec.kind !== 'string')
|
|
509
|
+
failMode(true, 'Utopia event mutation');
|
|
510
|
+
switch (rec.kind) {
|
|
511
|
+
case 'trigger-preset': {
|
|
512
|
+
assertExactKeys(rec, ['kind', 'presetId', 'durationMinutes'], 'Utopia trigger-preset event');
|
|
513
|
+
const presetId = checkLocalSlug(rec.presetId, 'Utopia event.presetId', true);
|
|
514
|
+
if (rec.durationMinutes === undefined) {
|
|
515
|
+
return { kind: 'trigger-preset', presetId };
|
|
516
|
+
}
|
|
517
|
+
return {
|
|
518
|
+
kind: 'trigger-preset',
|
|
519
|
+
presetId,
|
|
520
|
+
durationMinutes: checkIntRange(rec.durationMinutes, 30, 720, 'Utopia event.durationMinutes', true),
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
case 'put-custom': {
|
|
524
|
+
assertExactKeys(rec, ['kind', 'sceneryKind', 'label', 'description', 'placeId', 'durationMinutes'], 'Utopia put-custom event');
|
|
525
|
+
const sceneryKind = checkEnum(rec.sceneryKind, HABITAT_SCENERY_KINDS, 'Utopia event.sceneryKind', true);
|
|
526
|
+
const label = checkShortNounLabel(rec.label, 'Utopia event.label', true);
|
|
527
|
+
const description = checkDisplaySummary(rec.description, 'Utopia event.description', true);
|
|
528
|
+
const durationMinutes = checkIntRange(rec.durationMinutes, 30, 720, 'Utopia event.durationMinutes', true);
|
|
529
|
+
if (rec.placeId === undefined || rec.placeId === null) {
|
|
530
|
+
return { kind: 'put-custom', sceneryKind, label, description, durationMinutes };
|
|
531
|
+
}
|
|
532
|
+
const placeId = checkLocalSlug(rec.placeId, 'Utopia event.placeId', true);
|
|
533
|
+
if (placeId === 'personal-quarter')
|
|
534
|
+
failMode(true, 'Utopia event.placeId');
|
|
535
|
+
return { kind: 'put-custom', sceneryKind, label, description, placeId, durationMinutes };
|
|
536
|
+
}
|
|
537
|
+
case 'clear-event': {
|
|
538
|
+
assertExactKeys(rec, ['kind', 'eventId'], 'Utopia clear-event');
|
|
539
|
+
const eventId = typeof rec.eventId === 'string' && rec.eventId.trim() === rec.eventId
|
|
540
|
+
&& rec.eventId.length >= 1 && rec.eventId.length <= 64 && !rec.eventId.includes('\0')
|
|
541
|
+
? rec.eventId
|
|
542
|
+
: failMode(true, 'Utopia event.eventId');
|
|
543
|
+
return { kind: 'clear-event', eventId };
|
|
544
|
+
}
|
|
545
|
+
default:
|
|
546
|
+
return failMode(true, 'Utopia event mutation kind');
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
function normalizeUpdateIntentInput(value) {
|
|
550
|
+
const rec = asRecord(value);
|
|
551
|
+
if (!rec || typeof rec.kind !== 'string')
|
|
552
|
+
failMode(true, 'Utopia update intent');
|
|
553
|
+
switch (rec.kind) {
|
|
554
|
+
case 'activate-habitat': {
|
|
555
|
+
assertExactKeys(rec, ['kind', 'habitat', 'initialParameters', 'timezone'], 'Utopia activate-habitat');
|
|
556
|
+
const habitat = validateHabitatSpecV1(rec.habitat, true);
|
|
557
|
+
const out = { kind: 'activate-habitat', habitat };
|
|
558
|
+
if (rec.initialParameters !== undefined) {
|
|
559
|
+
out.initialParameters = checkParameterRecord(rec.initialParameters, 'Utopia initialParameters', true, 4);
|
|
560
|
+
}
|
|
561
|
+
if (rec.timezone !== undefined) {
|
|
562
|
+
out.timezone = checkTimezone(rec.timezone, 'Utopia timezone', true);
|
|
563
|
+
}
|
|
564
|
+
return out;
|
|
565
|
+
}
|
|
566
|
+
case 'restore-default': {
|
|
567
|
+
assertExactKeys(rec, ['kind', 'timezone'], 'Utopia restore-default');
|
|
568
|
+
if (rec.timezone === undefined) {
|
|
569
|
+
return { kind: 'restore-default' };
|
|
570
|
+
}
|
|
571
|
+
return { kind: 'restore-default', timezone: checkTimezone(rec.timezone, 'Utopia timezone', true) };
|
|
572
|
+
}
|
|
573
|
+
case 'apply-tuning': {
|
|
574
|
+
assertExactKeys(rec, ['kind', 'parameters', 'event'], 'Utopia apply-tuning');
|
|
575
|
+
const parameters = rec.parameters === undefined
|
|
576
|
+
? undefined
|
|
577
|
+
: checkParameterRecord(rec.parameters, 'Utopia tuning parameters', true, 4);
|
|
578
|
+
const event = rec.event === undefined ? undefined : normalizeEventMutationInput(rec.event);
|
|
579
|
+
const hasParams = parameters !== undefined && Object.keys(parameters).length > 0;
|
|
580
|
+
if (!hasParams && !event)
|
|
581
|
+
failMode(true, 'Utopia empty apply-tuning');
|
|
582
|
+
return {
|
|
583
|
+
kind: 'apply-tuning',
|
|
584
|
+
...(parameters !== undefined ? { parameters } : {}),
|
|
585
|
+
...(event !== undefined ? { event } : {}),
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
case 'set-public-participation': {
|
|
589
|
+
assertExactKeys(rec, ['kind', 'enabled'], 'Utopia set-public-participation');
|
|
590
|
+
return {
|
|
591
|
+
kind: 'set-public-participation',
|
|
592
|
+
enabled: checkBoolean(rec.enabled, 'Utopia enabled', true),
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
case 'set-solitude': {
|
|
596
|
+
assertExactKeys(rec, ['kind', 'agentHandle', 'solitary'], 'Utopia set-solitude');
|
|
597
|
+
const agentHandle = typeof rec.agentHandle === 'string' && AGENT_HANDLE_RE.test(rec.agentHandle)
|
|
598
|
+
? rec.agentHandle
|
|
599
|
+
: failMode(true, 'Utopia agentHandle');
|
|
600
|
+
return {
|
|
601
|
+
kind: 'set-solitude',
|
|
602
|
+
agentHandle,
|
|
603
|
+
solitary: checkBoolean(rec.solitary, 'Utopia solitary', true),
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
case 'set-timezone': {
|
|
607
|
+
assertExactKeys(rec, ['kind', 'timezone'], 'Utopia set-timezone');
|
|
608
|
+
return {
|
|
609
|
+
kind: 'set-timezone',
|
|
610
|
+
timezone: checkTimezone(rec.timezone, 'Utopia timezone', true),
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
default:
|
|
614
|
+
return failMode(true, 'Utopia update intent kind');
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
// @nimi-authority: rule.nimi.sdks.feature-clients.utopia
|
|
618
|
+
export function createNimiLocalAppUtopiaClient(shell) {
|
|
619
|
+
return Object.freeze({
|
|
620
|
+
snapshot: async () => projectSnapshot(await shell.snapshot()),
|
|
621
|
+
async update(input) {
|
|
622
|
+
assertExactKeys(input, ['expectedRevision', 'intent'], 'Utopia settings update');
|
|
623
|
+
const expectedRevision = checkRevision(input.expectedRevision, true);
|
|
624
|
+
const intent = normalizeUpdateIntentInput(input.intent);
|
|
625
|
+
return projectMutationAck(await shell.update({ expectedRevision, intent }));
|
|
626
|
+
},
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
//# sourceMappingURL=local-app-runtime-platform-utopia.js.map
|