diff --git a/docs/eve-migration-roadmap.md b/docs/eve-migration-roadmap.md index 039fad5..d49579f 100644 --- a/docs/eve-migration-roadmap.md +++ b/docs/eve-migration-roadmap.md @@ -285,11 +285,11 @@ Exit criteria: ## Active Work Queue -1. Move the browser/Electron Aetheria product frontends onto the same - advertisement, command, receipt, and interactive-world authority used by - the generic Unity client. -2. Turn the Unity live witness into a conformance-pack attachment with cold and +1. Turn the Unity live witness into a conformance-pack attachment with cold and warm asset-transfer timings, command receipts, and screenshot metrics. +2. Replace Aetheria's specialized browser embedded-document methods with a + generic CultMesh document handle once the field/plugin document contract is + explicit; do not move Aetheria gravity or object schemas into Eve. Recently cut: @@ -311,6 +311,16 @@ Recently cut: intent instead of relying on legacy loadout groups. Runtime camera framing uses aggregate authored-renderer bounds; the resulting frame is attached at `E:\Projects\EveUnity\artifacts\aetheria-daemon\aetheria-daemon-world.png`. +- Eve's browser lowerer now owns `EveBrowserProviderHost`: provider + advertisement selection, surface polling, lowering, command submission, and + command-triggered refresh. Aetheria Electron publishes its provider + advertisement over preload IPC and supplies a narrow CultMesh adapter. Its + renderer no longer selects `eve:surface:aetheria.daemon.game` or owns the + refresh loop; the product launcher configures the desired advertised surface. + Eve parity and generated-binding checks pass. The existing Stage 7C Electron + live smoke currently times out in its initial CultMesh frame probe before the + renderer loads, despite the daemon log showing published frames, so that + launch witness remains open rather than being counted as lowering proof. - The clean EveUnity PlayMode client now consumes Aetheria's independently running daemon without importing Aetheria code. Aetheria builds its authored @@ -321,9 +331,9 @@ Recently cut: entity pose on a wrapper root, submits movement, observes the authoritative receipt and later surface version, and captures `E:\Projects\EveUnity\artifacts\aetheria-daemon\aetheria-daemon-world.png`. - The warm-cache witness passes; first-load transfer still needs a persistent - CDN session, and the current capture framing is diagnostic rather than a - presentation-quality gameplay camera. + Cold- and warm-cache witnesses pass through the retained CDN session. The + current capture framing is diagnostic rather than a presentation-quality + gameplay camera. - Eve core now publishes typed CultCache wire documents for provider advertisement, command invocation, and provider receipt. Command descriptors @@ -1359,11 +1369,7 @@ Evidence on 2026-07-10: Remaining before this gate is complete: -- publish and consume Aetheria's asset manifest through a generic core boundary - so the clean client uses provider-authored assets rather than fallback - geometry; -- add one action/combat invocation witness alongside movement; -- attach both PNGs and receipt/version evidence to the exported conformance +- attach both PNGs, cold/warm transfer timings, and receipt/version evidence to the exported conformance pack rather than leaving them only in EveUnity's local artifacts. ## Stop Conditions diff --git a/packages/eve-browser-lowering/dist/index.d.ts b/packages/eve-browser-lowering/dist/index.d.ts index 20df7f8..1063728 100644 --- a/packages/eve-browser-lowering/dist/index.d.ts +++ b/packages/eve-browser-lowering/dist/index.d.ts @@ -51,6 +51,9 @@ export interface EveSurfaceWorldInteraction { } export interface EveProviderSurfaceAdvertisement { surfaceId?: string; + key?: string; + status?: string; + transport?: string; worldInteraction?: EveSurfaceWorldInteraction; } export interface EveProviderAdvertisement { @@ -72,6 +75,37 @@ export interface EveBrowserLoweringOptions { source?: string; statusElement?: HTMLElement; } +export interface EveBrowserProviderTransport { + providerAdvertisement(): Promise; + surface(surface: EveProviderSurfaceAdvertisement): Promise; + submitCommand(intent: EveCommandIntent): Promise; + resolveDocument?: EveBrowserLoweringOptions["documentResolver"]; + resolveAssetUrl?: EveBrowserLoweringOptions["assetUrlResolver"]; +} +export interface EveBrowserProviderHostOptions { + body?: HTMLElement; + clientId?: string; + pollMs?: number; + requestedSurfaceId?: string; + source?: string; + statusElement?: HTMLElement; +} +export declare function selectAdvertisedSurface(provider: EveProviderAdvertisement, requestedSurfaceId?: string): EveProviderSurfaceAdvertisement; +export declare class EveBrowserProviderHost { + private readonly host; + private readonly transport; + private readonly options; + private active; + private lastSurfaceVersion; + private pollHandle; + private provider; + private selected; + constructor(host: HTMLElement, transport: EveBrowserProviderTransport, options?: EveBrowserProviderHostOptions); + start(): Promise; + stop(): void; + refresh(): Promise; + private submit; +} export interface EveEmbeddedDocumentRequest { documentId: string; presentationKind?: string; diff --git a/packages/eve-browser-lowering/dist/index.js b/packages/eve-browser-lowering/dist/index.js index 821f65e..d2cab97 100644 --- a/packages/eve-browser-lowering/dist/index.js +++ b/packages/eve-browser-lowering/dist/index.js @@ -1,3 +1,76 @@ +export function selectAdvertisedSurface(provider, requestedSurfaceId = "") { + const surfaces = provider.surfaces || provider.localAdvertisement?.surfaces || []; + const selected = requestedSurfaceId + ? surfaces.find(surface => surface.surfaceId === requestedSurfaceId) + : surfaces.find(surface => surface.status !== "unavailable") ?? surfaces[0]; + if (!selected?.surfaceId) { + throw new Error(`Provider ${provider.providerId || "(unknown)"} does not advertise surface ${requestedSurfaceId || "(first available)"}.`); + } + return selected; +} +export class EveBrowserProviderHost { + host; + transport; + options; + active = false; + lastSurfaceVersion = ""; + pollHandle; + provider; + selected; + constructor(host, transport, options = {}) { + this.host = host; + this.transport = transport; + this.options = options; + } + async start() { + this.provider = await this.transport.providerAdvertisement(); + this.selected = selectAdvertisedSurface(this.provider, this.options.requestedSurfaceId); + this.active = true; + await this.refresh(); + const pollMs = Math.max(0, this.options.pollMs ?? 250); + if (pollMs > 0) { + this.pollHandle = window.setInterval(() => void this.refresh(), pollMs); + } + } + stop() { + this.active = false; + if (this.pollHandle !== undefined) + window.clearInterval(this.pollHandle); + this.pollHandle = undefined; + } + async refresh() { + if (!this.active || !this.provider || !this.selected) + return; + try { + const surface = await this.transport.surface(this.selected); + const version = `${surface.providerId || ""}:${surface.surface?.id || ""}:${surface.version ?? ""}`; + if (version === this.lastSurfaceVersion) + return; + this.lastSurfaceVersion = version; + renderEveSurface(surface, this.host, { + activeSurfaceId: this.selected.surfaceId, + assetUrlResolver: this.transport.resolveAssetUrl, + body: this.options.body, + clientId: this.options.clientId || "eve-browser", + commandSink: intent => this.submit(intent), + documentResolver: this.transport.resolveDocument, + provider: this.provider, + source: this.options.source, + statusElement: this.options.statusElement, + }); + } + catch (error) { + if (this.options.statusElement) { + this.options.statusElement.textContent = error instanceof Error ? error.message : "Eve surface unavailable."; + } + } + } + async submit(intent) { + await this.transport.submitCommand(intent); + this.lastSurfaceVersion = ""; + window.setTimeout(() => void this.refresh(), 100); + } +} const defaultStyleTokens = { "--bg": "#020909", "--bg-top": "#020909", diff --git a/packages/eve-browser-lowering/src/index.ts b/packages/eve-browser-lowering/src/index.ts index 760ca0a..a23e0e6 100644 --- a/packages/eve-browser-lowering/src/index.ts +++ b/packages/eve-browser-lowering/src/index.ts @@ -51,6 +51,9 @@ export interface EveSurfaceWorldInteraction { export interface EveProviderSurfaceAdvertisement { surfaceId?: string; + key?: string; + status?: string; + transport?: string; worldInteraction?: EveSurfaceWorldInteraction; } @@ -75,6 +78,99 @@ export interface EveBrowserLoweringOptions { statusElement?: HTMLElement; } +export interface EveBrowserProviderTransport { + providerAdvertisement(): Promise; + surface(surface: EveProviderSurfaceAdvertisement): Promise; + submitCommand(intent: EveCommandIntent): Promise; + resolveDocument?: EveBrowserLoweringOptions["documentResolver"]; + resolveAssetUrl?: EveBrowserLoweringOptions["assetUrlResolver"]; +} + +export interface EveBrowserProviderHostOptions { + body?: HTMLElement; + clientId?: string; + pollMs?: number; + requestedSurfaceId?: string; + source?: string; + statusElement?: HTMLElement; +} + +export function selectAdvertisedSurface( + provider: EveProviderAdvertisement, + requestedSurfaceId = "", +): EveProviderSurfaceAdvertisement { + const surfaces = provider.surfaces || provider.localAdvertisement?.surfaces || []; + const selected = requestedSurfaceId + ? surfaces.find(surface => surface.surfaceId === requestedSurfaceId) + : surfaces.find(surface => surface.status !== "unavailable") ?? surfaces[0]; + if (!selected?.surfaceId) { + throw new Error(`Provider ${provider.providerId || "(unknown)"} does not advertise surface ${requestedSurfaceId || "(first available)"}.`); + } + return selected; +} + +export class EveBrowserProviderHost { + private active = false; + private lastSurfaceVersion = ""; + private pollHandle: number | undefined; + private provider: EveProviderAdvertisement | undefined; + private selected: EveProviderSurfaceAdvertisement | undefined; + + constructor( + private readonly host: HTMLElement, + private readonly transport: EveBrowserProviderTransport, + private readonly options: EveBrowserProviderHostOptions = {}, + ) {} + + async start(): Promise { + this.provider = await this.transport.providerAdvertisement(); + this.selected = selectAdvertisedSurface(this.provider, this.options.requestedSurfaceId); + this.active = true; + await this.refresh(); + const pollMs = Math.max(0, this.options.pollMs ?? 250); + if (pollMs > 0) { + this.pollHandle = window.setInterval(() => void this.refresh(), pollMs); + } + } + + stop(): void { + this.active = false; + if (this.pollHandle !== undefined) window.clearInterval(this.pollHandle); + this.pollHandle = undefined; + } + + async refresh(): Promise { + if (!this.active || !this.provider || !this.selected) return; + try { + const surface = await this.transport.surface(this.selected); + const version = `${surface.providerId || ""}:${surface.surface?.id || ""}:${surface.version ?? ""}`; + if (version === this.lastSurfaceVersion) return; + this.lastSurfaceVersion = version; + renderEveSurface(surface, this.host, { + activeSurfaceId: this.selected.surfaceId, + assetUrlResolver: this.transport.resolveAssetUrl, + body: this.options.body, + clientId: this.options.clientId || "eve-browser", + commandSink: intent => this.submit(intent), + documentResolver: this.transport.resolveDocument, + provider: this.provider, + source: this.options.source, + statusElement: this.options.statusElement, + }); + } catch (error) { + if (this.options.statusElement) { + this.options.statusElement.textContent = error instanceof Error ? error.message : "Eve surface unavailable."; + } + } + } + + private async submit(intent: EveCommandIntent): Promise { + await this.transport.submitCommand(intent); + this.lastSurfaceVersion = ""; + window.setTimeout(() => void this.refresh(), 100); + } +} + export interface EveEmbeddedDocumentRequest { documentId: string; presentationKind?: string; diff --git a/packages/eve-browser-lowering/test/browser-lowering.test.mjs b/packages/eve-browser-lowering/test/browser-lowering.test.mjs index 668787f..1f83715 100644 --- a/packages/eve-browser-lowering/test/browser-lowering.test.mjs +++ b/packages/eve-browser-lowering/test/browser-lowering.test.mjs @@ -1,6 +1,19 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { createEveCommandIntent } from "../dist/index.js"; +import { createEveCommandIntent, selectAdvertisedSurface } from "../dist/index.js"; + +test("selects the requested surface from provider authority", () => { + const provider = { + providerId: "example", + surfaces: [ + { surfaceId: "example.menu", status: "available" }, + { surfaceId: "example.world", status: "available" }, + ], + }; + + assert.equal(selectAdvertisedSurface(provider, "example.world").surfaceId, "example.world"); + assert.throws(() => selectAdvertisedSurface(provider, "example.missing"), /does not advertise surface/); +}); test("command intents use the active surface advertisement boundary", () => { const intent = createEveCommandIntent("aetheria.daemon.editor.inspect", {