@adea-ai/spatial 0.69.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # @adea-ai/spatial
2
+
3
+ Scene and asset manifest contracts plus the shell-to-engine spatial protocol
4
+ for Adea workspaces. Pure types, mount manifests, URL helpers, and telemetry
5
+ schema — no rendering, no binaries, no secrets.
6
+
7
+ Consolidates the former `@adea-ai/asset-manifests` and `@adea-ai/spatial-protocol`
8
+ packages, which always released together; both are deprecated in favor of this
9
+ package.
10
+
11
+ - `asset-manifests.ts` — typed scene data shapes: `SceneManifest`, `SceneZone`,
12
+ `SceneStartPosition`, assigned-props manifests, static-field asset URLs.
13
+ - `manifests.ts` — `hqHomeManifest` / `hqWorkManifest` mount constants (mirrors
14
+ the engine's room layout; the engine is source of truth).
15
+ - `engine.ts` — agent-sim engine manifest discovery and validation
16
+ (`parseAgentSimEngineManifest`, official web hosts).
17
+ - `scene-spawn.ts` — cross-app spawn encode/parse and portal URL helpers.
18
+ - `telemetry.ts` — `ScenePerformanceReport` schema, validation, envelope, and
19
+ navigation instrumentation.
20
+ - `data/` — tracked scene manifests (`home/`, `work/`), mirrored from the
21
+ engine's `scenes/sim/assets/`; staged into the web public dir by
22
+ `scripts/sync-assets.mjs`.
@@ -0,0 +1,88 @@
1
+ export type SceneAvailability = 'ready' | 'planned';
2
+ export type SceneZone = {
3
+ id: string;
4
+ assetUrl: string;
5
+ /** Optional collision layer that follows this visual zone. */
6
+ collisionAssetUrl?: string;
7
+ /** Additional visual layers that load and unload with this zone. */
8
+ assetUrls?: readonly string[];
9
+ /** Exact-triangle field colliders that load and unload with this zone. */
10
+ collisionAssetUrls?: readonly string[];
11
+ preload?: boolean;
12
+ /** Load the zone automatically when the player enters this radius. */
13
+ preloadDistance?: number;
14
+ /** Optional transform for a model authored in local building space. */
15
+ transform?: {
16
+ position?: readonly [number, number, number];
17
+ quaternion?: readonly [number, number, number, number];
18
+ scale?: readonly [number, number, number];
19
+ };
20
+ };
21
+ export type SceneStartPosition = {
22
+ x: number;
23
+ y: number;
24
+ z: number;
25
+ yaw?: number;
26
+ pitch?: number;
27
+ /** Keep an authored start height instead of snapping to the first ray hit. */
28
+ snapToGround?: boolean;
29
+ };
30
+ export type StaticFieldAssetUrls = {
31
+ foliage?: string;
32
+ props?: string;
33
+ };
34
+ export type AssignedPropManifestPlacement = {
35
+ id?: string;
36
+ p?: readonly [number, number, number];
37
+ q?: readonly [number, number, number, number];
38
+ s?: readonly [number, number, number];
39
+ footprint?: readonly [number, number];
40
+ };
41
+ export type AssignedPropManifestAsset = {
42
+ assetUrl: string;
43
+ defaultScale: number;
44
+ footprint?: readonly [number, number];
45
+ placementSurface?: 'floor' | 'wall';
46
+ wallMountHeight?: number;
47
+ floorLift?: number;
48
+ placeableOnTop?: boolean;
49
+ };
50
+ /** Runtime-only room content for props already assigned to a scene. */
51
+ export type AssignedPropsManifest = {
52
+ version?: number;
53
+ scene?: string;
54
+ assets: Record<string, AssignedPropManifestAsset>;
55
+ placements: Record<string, AssignedPropManifestPlacement[]>;
56
+ };
57
+ export type SceneManifest = {
58
+ id: string;
59
+ label: string;
60
+ availability?: SceneAvailability;
61
+ entryAssetUrl: string;
62
+ /** Optional id for making the initially loaded asset unloadable as a zone. */
63
+ entryZoneId?: string;
64
+ /** Keep the entry collision layer active while visual zones transition. */
65
+ preserveEntryCollision?: boolean;
66
+ collisionAssetUrl?: string;
67
+ /** Additional collision layers kept active for multi-level scenes. */
68
+ additionalCollisionAssetUrls?: readonly string[];
69
+ additionalAssetUrls?: readonly string[];
70
+ zones?: SceneZone[];
71
+ startPosition?: SceneStartPosition;
72
+ /** Build-generated instanced fields for static scenes (preferred over runtime manifests). */
73
+ staticFieldAssetUrls?: StaticFieldAssetUrls;
74
+ /** Render-free exact-triangle companions for the generated static fields. */
75
+ staticFieldCollisionAssetUrls?: StaticFieldAssetUrls;
76
+ /** Optional foliage placement manifest (instanced from the foliage catalog at runtime). */
77
+ foliageManifestUrl?: string;
78
+ /** Optional props placement manifest (instanced from the props catalog at runtime). */
79
+ propsManifestUrl?: string;
80
+ /** Runtime-only manifest for props explicitly assigned to this workspace. */
81
+ assignedPropsManifestUrl?: string;
82
+ /** Public URL for persisted authored-object editor overrides. */
83
+ editorOverridesUrl?: string;
84
+ /** Optional repository-relative source path for persisted overrides. */
85
+ editorOverridesSourcePath?: string;
86
+ /** Optional repository-relative public copy path for persisted overrides. */
87
+ editorOverridesPublicPath?: string;
88
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Entitlement gate and loading contract for the Agent Sim engine.
3
+ *
4
+ * The engine (models, textures, audio, runtime code) lives in the private
5
+ * agent-sim repo and never ships in this public one. The shell may only
6
+ * resolve the engine remote when the deployment is entitled to it:
7
+ *
8
+ * - Web: the site is served from an official Adea domain (adea.dev /
9
+ * adea.io, including subdomains). Forked deployments on other origins
10
+ * are refused before any engine fetch happens.
11
+ * - Desktop / any build: an official build packs the engine into its own
12
+ * assets at build time (see scripts/pack-agent-sim.mjs, wired into the
13
+ * release lanes). The pack writes a manifest at a well-known same-origin
14
+ * URL; plain checkouts and fork builds simply do not have it.
15
+ *
16
+ * Both signals are checked; the engine is fetched only when both pass, so
17
+ * copying engine assets into a forked website still fails the host gate.
18
+ */
19
+ export declare const OFFICIAL_AGENT_SIM_WEB_HOSTS: readonly ["adea.dev", "adea.io"];
20
+ export type AgentSimWebPlatform = 'web' | 'desktop';
21
+ export type AgentSimEngineManifest = {
22
+ /**
23
+ * Same-origin ES module URL of the engine entry. The entry must register
24
+ * the `window.__adeaAgentSim` mount API documented in the package README
25
+ * before its load event resolves.
26
+ */
27
+ entryUrl: string;
28
+ /** Engine pack version (agent-sim repo release). Diagnostics only. */
29
+ version: string;
30
+ };
31
+ /** Well-known same-origin URL the official pack lane writes the manifest to. */
32
+ export declare function agentSimEngineManifestUrl(origin: string): string;
33
+ /**
34
+ * Parse and validate an engine manifest fetched from a trusted origin.
35
+ * Rejects payloads that would point the loader off the deployment's own
36
+ * origin — the engine ships with the site, never from third parties.
37
+ */
38
+ export declare function parseAgentSimEngineManifest(value: unknown, origin: string): {
39
+ ok: true;
40
+ manifest: AgentSimEngineManifest;
41
+ } | {
42
+ ok: false;
43
+ };
44
+ /**
45
+ * Whether a web origin is an official Adea deployment allowed to resolve the
46
+ * Agent Sim engine remote. Desktop builds skip this check: they are gated by
47
+ * the packed engine manifest instead.
48
+ */
49
+ export declare function isOfficialAgentSimWebOrigin(origin: string): boolean;
50
+ /**
51
+ * Hosts where a developer runs the shell locally. Local development is
52
+ * entitled only when the engine was explicitly packed into the local build
53
+ * (engine manifest present); the host check alone never entitles it.
54
+ */
55
+ export declare function isLocalDevHost(hostname: string): boolean;
package/dist/engine.js ADDED
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Entitlement gate and loading contract for the Agent Sim engine.
3
+ *
4
+ * The engine (models, textures, audio, runtime code) lives in the private
5
+ * agent-sim repo and never ships in this public one. The shell may only
6
+ * resolve the engine remote when the deployment is entitled to it:
7
+ *
8
+ * - Web: the site is served from an official Adea domain (adea.dev /
9
+ * adea.io, including subdomains). Forked deployments on other origins
10
+ * are refused before any engine fetch happens.
11
+ * - Desktop / any build: an official build packs the engine into its own
12
+ * assets at build time (see scripts/pack-agent-sim.mjs, wired into the
13
+ * release lanes). The pack writes a manifest at a well-known same-origin
14
+ * URL; plain checkouts and fork builds simply do not have it.
15
+ *
16
+ * Both signals are checked; the engine is fetched only when both pass, so
17
+ * copying engine assets into a forked website still fails the host gate.
18
+ */
19
+ export const OFFICIAL_AGENT_SIM_WEB_HOSTS = ['adea.dev', 'adea.io'];
20
+ /** Known-public hostname suffixes never treated as official even if they embed an official host. */
21
+ const NON_OFFICIAL_SUFFIXES = ['.local', '.localhost', '.internal'];
22
+ const OFFICIAL_LOCAL_HOSTS = ['localhost', '127.0.0.1', '[::1]'];
23
+ /** Well-known same-origin URL the official pack lane writes the manifest to. */
24
+ export function agentSimEngineManifestUrl(origin) {
25
+ return new URL('/assets/agent-sim/engine.json', origin).toString();
26
+ }
27
+ /**
28
+ * Parse and validate an engine manifest fetched from a trusted origin.
29
+ * Rejects payloads that would point the loader off the deployment's own
30
+ * origin — the engine ships with the site, never from third parties.
31
+ */
32
+ export function parseAgentSimEngineManifest(value, origin) {
33
+ if (typeof value !== 'object' || value === null)
34
+ return { ok: false };
35
+ const entryUrl = value.engine?.entryUrl;
36
+ const version = value.engine?.version;
37
+ if (typeof entryUrl !== 'string' || entryUrl.length === 0)
38
+ return { ok: false };
39
+ if (typeof version !== 'string' || version.length === 0)
40
+ return { ok: false };
41
+ let resolved;
42
+ try {
43
+ resolved = new URL(entryUrl, origin);
44
+ }
45
+ catch {
46
+ return { ok: false };
47
+ }
48
+ if (resolved.origin !== new URL(origin).origin)
49
+ return { ok: false };
50
+ if (!resolved.pathname.endsWith('.js'))
51
+ return { ok: false };
52
+ return { ok: true, manifest: { entryUrl: resolved.toString(), version } };
53
+ }
54
+ /**
55
+ * Whether a web origin is an official Adea deployment allowed to resolve the
56
+ * Agent Sim engine remote. Desktop builds skip this check: they are gated by
57
+ * the packed engine manifest instead.
58
+ */
59
+ export function isOfficialAgentSimWebOrigin(origin) {
60
+ let url;
61
+ try {
62
+ url = new URL(origin);
63
+ }
64
+ catch {
65
+ return false;
66
+ }
67
+ if (url.protocol !== 'https:')
68
+ return false;
69
+ const host = url.hostname.toLowerCase();
70
+ if (NON_OFFICIAL_SUFFIXES.some((suffix) => host.endsWith(suffix)))
71
+ return false;
72
+ return OFFICIAL_AGENT_SIM_WEB_HOSTS.some((official) => host === official || host.endsWith(`.${official}`));
73
+ }
74
+ /**
75
+ * Hosts where a developer runs the shell locally. Local development is
76
+ * entitled only when the engine was explicitly packed into the local build
77
+ * (engine manifest present); the host check alone never entitles it.
78
+ */
79
+ export function isLocalDevHost(hostname) {
80
+ const host = hostname.toLowerCase();
81
+ return OFFICIAL_LOCAL_HOSTS.includes(host) || host.endsWith('.localhost');
82
+ }
@@ -0,0 +1,13 @@
1
+ export * from './asset-manifests';
2
+ export { agentSimEngineManifestUrl, isLocalDevHost, isOfficialAgentSimWebOrigin, parseAgentSimEngineManifest, OFFICIAL_AGENT_SIM_WEB_HOSTS, type AgentSimEngineManifest, } from './engine';
3
+ export { hqHomeManifest, hqWorkManifest } from './manifests';
4
+ export { appRouteHref, encodeSceneStartPosition, portalNavigationHref, readSceneStartPosition, type PortalNavigation, type SceneApp, } from './scene-spawn';
5
+ export { createSceneTelemetryEnvelope, MAX_SCENE_TELEMETRY_BYTES, onRouterTransitionStart, parseScenePerformanceReport, recordNavigation, SCENE_TELEMETRY_LOG_PREFIX, type SceneNavigationType, type ScenePerformanceReport, type SceneRuntimeStats, type SceneTelemetryEnvelope, } from './telemetry';
6
+ export declare const configurableCharacterId = "configurable";
7
+ export declare const DEFAULT_CHARACTER_ID = "configurable";
8
+ /**
9
+ * Shell-side character param check. The engine validates against its
10
+ * reference/preset catalogs on mount; the shell only needs a plausible
11
+ * non-empty value to thread through.
12
+ */
13
+ export declare function isPlausibleCharacterId(value: string | undefined): value is string;
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ export * from './asset-manifests';
2
+ export { agentSimEngineManifestUrl, isLocalDevHost, isOfficialAgentSimWebOrigin, parseAgentSimEngineManifest, OFFICIAL_AGENT_SIM_WEB_HOSTS, } from './engine';
3
+ export { hqHomeManifest, hqWorkManifest } from './manifests';
4
+ export { appRouteHref, encodeSceneStartPosition, portalNavigationHref, readSceneStartPosition, } from './scene-spawn';
5
+ export { createSceneTelemetryEnvelope, MAX_SCENE_TELEMETRY_BYTES, onRouterTransitionStart, parseScenePerformanceReport, recordNavigation, SCENE_TELEMETRY_LOG_PREFIX, } from './telemetry';
6
+ export const configurableCharacterId = 'configurable';
7
+ export const DEFAULT_CHARACTER_ID = configurableCharacterId;
8
+ /**
9
+ * Shell-side character param check. The engine validates against its
10
+ * reference/preset catalogs on mount; the shell only needs a plausible
11
+ * non-empty value to thread through.
12
+ */
13
+ export function isPlausibleCharacterId(value) {
14
+ return typeof value === 'string' && value.length > 0 && value.length <= 128;
15
+ }
@@ -0,0 +1,3 @@
1
+ import type { SceneManifest } from './asset-manifests';
2
+ export declare const hqHomeManifest: SceneManifest;
3
+ export declare const hqWorkManifest: SceneManifest;
@@ -0,0 +1,26 @@
1
+ const sceneConfig = {
2
+ home: { label: 'Home', floorVersion: 20, foliageVersion: 10 },
3
+ work: { label: 'Work', floorVersion: 21, foliageVersion: 11 },
4
+ };
5
+ // Start height mirrors the engine's ROOM_GALLERY_FOUNDATION_TOP_Y (slab base 0
6
+ // + height 6) plus the authored 135-unit lift. The engine's room-config is
7
+ // the simulation source of truth; this package carries the mount constants
8
+ // the shell needs without depending on engine code.
9
+ const START_Y = 6 + 135;
10
+ function createHqManifest(scene) {
11
+ const { label, floorVersion, foliageVersion } = sceneConfig[scene];
12
+ const sceneId = `hq-${scene}`;
13
+ return {
14
+ id: sceneId,
15
+ label,
16
+ availability: 'ready',
17
+ entryAssetUrl: `/assets/worlds/${sceneId}/floor.glb?v=${floorVersion}`,
18
+ collisionAssetUrl: `/assets/worlds/${sceneId}/floor-collision.glb?v=${floorVersion}`,
19
+ foliageManifestUrl: `/assets/worlds/${sceneId}/foliage.json?v=${foliageVersion}`,
20
+ assignedPropsManifestUrl: `/assets/worlds/${sceneId}/props-runtime.json?v=room-layout`,
21
+ zones: [],
22
+ startPosition: { x: 0, y: START_Y, z: 0, yaw: 0, pitch: -0.2 },
23
+ };
24
+ }
25
+ export const hqHomeManifest = createHqManifest('home');
26
+ export const hqWorkManifest = createHqManifest('work');
@@ -0,0 +1,15 @@
1
+ import type { SceneStartPosition } from './asset-manifests';
2
+ export type SceneApp = 'world' | 'hq';
3
+ /** Encode a scene start position for a cross-app navigation URL. */
4
+ export declare function encodeSceneStartPosition(position: SceneStartPosition): string;
5
+ /** Parse a validated scene start position from a route's `spawn` query. */
6
+ export declare function readSceneStartPosition(value: string | string[] | undefined): SceneStartPosition | undefined;
7
+ /** Resolve a route for the sibling World or HQ app in dev and production. */
8
+ export declare function appRouteHref(app: SceneApp, path: string, currentHref?: string): string;
9
+ export type PortalNavigation = {
10
+ app: SceneApp;
11
+ path: string;
12
+ spawn?: SceneStartPosition;
13
+ };
14
+ /** Build a portal URL while carrying the selected character and target spawn. */
15
+ export declare function portalNavigationHref(navigation: PortalNavigation, currentHref?: string): string;
@@ -0,0 +1,88 @@
1
+ const SPAWN_QUERY_KEY = 'spawn';
2
+ const APP_DEV_PORTS = { world: '3000', hq: '3004' };
3
+ const APP_PORTLESS_URLS = {
4
+ world: 'https://world.localhost',
5
+ hq: 'https://adea.localhost',
6
+ };
7
+ function firstValue(value) {
8
+ return Array.isArray(value) ? value[0] : value;
9
+ }
10
+ function finiteNumber(value) {
11
+ if (!value)
12
+ return undefined;
13
+ const parsed = Number(value);
14
+ return Number.isFinite(parsed) ? parsed : undefined;
15
+ }
16
+ /** Encode a scene start position for a cross-app navigation URL. */
17
+ export function encodeSceneStartPosition(position) {
18
+ return [
19
+ position.x,
20
+ position.y,
21
+ position.z,
22
+ position.yaw ?? '',
23
+ position.pitch ?? '',
24
+ position.snapToGround == null ? '' : position.snapToGround ? '1' : '0',
25
+ ].join(',');
26
+ }
27
+ /** Parse a validated scene start position from a route's `spawn` query. */
28
+ export function readSceneStartPosition(value) {
29
+ const parts = firstValue(value)?.split(',');
30
+ if (!parts || parts.length < 3 || parts.length > 6)
31
+ return undefined;
32
+ const x = finiteNumber(parts[0]);
33
+ const y = finiteNumber(parts[1]);
34
+ const z = finiteNumber(parts[2]);
35
+ if (x == null || y == null || z == null)
36
+ return undefined;
37
+ const yaw = finiteNumber(parts[3]);
38
+ const pitch = finiteNumber(parts[4]);
39
+ const snap = parts[5];
40
+ if (parts[3] && yaw == null)
41
+ return undefined;
42
+ if (parts[4] && pitch == null)
43
+ return undefined;
44
+ if (snap && snap !== '0' && snap !== '1')
45
+ return undefined;
46
+ return {
47
+ x,
48
+ y,
49
+ z,
50
+ ...(yaw == null ? {} : { yaw }),
51
+ ...(pitch == null ? {} : { pitch }),
52
+ ...(snap === '0' ? { snapToGround: false } : snap === '1' ? { snapToGround: true } : {}),
53
+ };
54
+ }
55
+ function configuredAppBase(app) {
56
+ const configured = app === 'world' ? process.env.ADEA_PUBLIC_WORLD_URL : process.env.ADEA_PUBLIC_HQ_URL;
57
+ return configured?.trim() || undefined;
58
+ }
59
+ function isDevelopmentHost(hostname) {
60
+ return (hostname === 'localhost' ||
61
+ hostname === '127.0.0.1' ||
62
+ hostname === '0.0.0.0' ||
63
+ hostname === 'amf-mb-pro' ||
64
+ hostname.endsWith('.localhost') ||
65
+ hostname.endsWith('.ts.net'));
66
+ }
67
+ /** Resolve a route for the sibling World or HQ app in dev and production. */
68
+ export function appRouteHref(app, path, currentHref) {
69
+ const current = new URL(currentHref ?? window.location.href);
70
+ const configuredBase = configuredAppBase(app);
71
+ const isPortlessHost = current.hostname.endsWith('.localhost');
72
+ const target = new URL(path, configuredBase ?? (isPortlessHost ? APP_PORTLESS_URLS[app] : current.origin));
73
+ if (!configuredBase && !isPortlessHost && isDevelopmentHost(current.hostname)) {
74
+ target.port = APP_DEV_PORTS[app];
75
+ }
76
+ return target.toString();
77
+ }
78
+ /** Build a portal URL while carrying the selected character and target spawn. */
79
+ export function portalNavigationHref(navigation, currentHref) {
80
+ const current = new URL(currentHref ?? window.location.href);
81
+ const target = new URL(appRouteHref(navigation.app, navigation.path, current.toString()));
82
+ const character = current.searchParams.get('character');
83
+ if (character)
84
+ target.searchParams.set('character', character);
85
+ if (navigation.spawn)
86
+ target.searchParams.set(SPAWN_QUERY_KEY, encodeSceneStartPosition(navigation.spawn));
87
+ return target.toString();
88
+ }