A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.
JavaScript 3d-globecesiumflight-trackinggeospatialgeospatial-intelligencegisosintphotogrammetrysatellite-trackingspatial-intelligencewebglworldview
Merge main into feat/voice-core and reconcile layer capabilities
Sameh Khamis1594db94979b
diff --cc CHANGELOG.mdindex 1086e5ed3,1b3876f79..424d9f79a--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -1,55 -1,34 +1,85 @@@# Changelog++- Street Level is included in the voice layer manifest for visibility toggles;++ imagery is not exposed as countable analyst records.+++- Voice debug logs omit complete tool-result bodies and serialized function+ outputs by default, including location queries and generated spoken replies.+ `GEV_VOICE_LOG_CONTENT=1` retains them for explicit content debugging.++- Unqualified Alps searches use the bundled European range for navigation+ and annotations instead of a same-named peak returned by a geocoder.+ Coordinates, supplied presets and geographically qualified place names+ keep their precedence; annotation proximity and containment guards remain.+- Contacts analyst follow-ups retain the snapshot's distance ranking rather+ than switching to the camera. Requested radii and explicit scopes remain+ authoritative, and a request for a list still requires an analyst query.+ Analyst speech names stale or degraded feeds and withholds authoritative+ counts when unavailable. The existing NOTES disclosure preserves complete,+ deduplicated coverage and source caveats, including crowded results.+- The voice card shows analyst counts ("At least 250,000 aircraft …") with+ their scope, feed window and caveats, and marks partial answers. Analyst+ speech uses the same deterministic headline, preserves lower bounds and says+ when an answer is partial. Follow-ups retain unanswered-layer coverage, and+ keep the original scope label when they narrow a remembered result.+ Contacts-window answers read one immutable panel snapshot, mark a 20,000-row+ layer cap as a lower bound, and commit that displayed cohort only after+ cancellation checks pass. Concurrent analyst calls from one model response+ remain independent; a stopped or replaced user turn still cancels them.+- Voice answers are shorter and fill slow work instead of going silent. Slow+ or multi-step requests may open with one short spoken plan; instant ones+ just happen. Tool results carry a code-built `say` line and a `display`+ card: sources and notes stay on screen, a caveat is spoken only when it+ changes the answer, and "at least" and partial answers are always said. A card above the mic shows captions, the plan's steps and the+ result. When a tool that reports steps (layers, place lookups, outlines,+ nearest-aircraft) is still running after 1.5 s its current step is spoken+ once; others say "still working" once after 8 s. A soft+ tick plays in push-to-talk. Holding Space while the assistant talks cuts it+ off. Each turn writes latency and speech figures to the debug log+ (`node scripts/voice-turn-spans.mjs`). Captions of what you say are+ counted in the voice cost meter; the debug log leaves out what was said+ unless `GEV_VOICE_LOG_CONTENT=1`.+- Point and ask: hold Space with the cursor on an aircraft, ship or spot on+ the map and say "what's that", "track that one" or "how many flights+ around here". A reticle marks the point and the voice card shows what+ "this" meant. In open mic it works when you have just moved the cursor+ there. "The second one" picks from the last numbered list. Asking about+ "the last one" resolves to the last of the five rows actually shown, and+ referent-only tracking calls are accepted while empty targets are rejected.+ Asking about+ bare ground up close gives the assistant a small crop of the map around the+ point. A slow render gets one bounded second frame request, while hidden,+ stale, moved-camera, invalid and oversized captures still fail closed.+## [Unreleased]+ - Street Level: a street-level imagery layer modelled on the iD editor's photo+ overlay, with Mapillary as its first provider (free client token, CC BY-SA 4.0+ imagery). One right-rail panel holds a chip per provider, shared 360°/flat and+ captured-since filters, and an embedded viewer with EXPAND, FIT/FILL and+ FOLLOW (Google 3D only). Coverage lines and image cones are drawn from orbit+ down to a single street; on Google 3D they sit on the bare earth, refined+ against the rendered mesh near the camera, so trees and buildings hide them.+ Share links carry the provider switches, the filters and the panel's collapsed+ state. A server proxy caches Mapillary coverage tiles (24 h, 1 GiB on disk),+ refuses cross-site requests, rate-limits per IP and backs off when Mapillary+ rejects the token or rate-limits.++ - The CCTV and Street Level panels are portable: drag the header to float the+ panel, resize it from any edge or corner, and double-click the header to dock+ it again. The position persists across reloads.++ - Add Norway's road cameras from Statens vegvesen as a CCTV pack. The camera+ list is one keyless GeoJSON request to the agency's OGC API view of its+ DATEX 3.1 CCTV table, so no DATEX account is needed. Every working camera+ loads (~850; faulty ones are dropped) under one "Norway" category, and the+ ~135 working cameras that publish HLS play as live video through the existing in-memory+ relay with the still as fallback. Frames and manifests are pinned to each+ camera's own path on the agency hosts. `CCTV_VEGVESEN_ENABLED=0` disables+ the pack, `CCTV_VEGVESEN_MAX_SOURCES` caps it (keeping cameras nearest the+ largest cities) and `CCTV_VEGVESEN_VIDEO=0` keeps stills only. Attributed+ under NLOD 2.0.+## [0.2.1] — 2026-10-02 — God's Eye View through Your Agent (with security fixes and other features)- Ship each bundled data pack once. The region, marine, admin-boundary,diff --cc docs/CURRENT-STATE.mdindex 920d508e7,d51be986b..10616ca74--- a/docs/CURRENT-STATE.md+++ b/docs/CURRENT-STATE.md@@@ -353,62 -353,6 +353,64 @@@ replacement session; audio meters releaframes. Delayed action results and post-capture continuations cannot resume astopped conversation or send output into a replacement. See [voice ownership](VOICE-OWNERSHIP.md).+Contacts nearest-aircraft follow-ups retain the snapshot's distance basis even+after the camera moves. An explicit new scope replaces that basis. Provider+instructions require an analyst query for requested lists and use the requested+radius rather than substituting the panel's fixed window. Analyst speech carries+stale/degraded feed status and does not speak an authoritative unavailable count.+The existing NOTES disclosure deduplicates coverage/source caveats and retains+their full text in at most six rows, grouping analyst overflow in the final row;+ordinary tool-card limits are unchanged.++Voice speech: `src/voice/speech.js` adds `{ say, display, referents?, schedule? }`+to layer toggles, fly_to_location, frame_overhead, select_nearest_aircraft,+get_entity_context, annotate_map and analyst_query. Analyst speech and the card+share one deterministic count/scope headline; lower bounds use "At least" and+partial answers name the unanswered layers. `get_current_view_state` lists enabled layers only.+The voice card nested in the mic control (`voiceCard.js`) shows captions, plan+steps and the result. `resultDisplay.js` is the one adapter from a result to+the card: builder results show as built, and analyst results show a title+with their scope, window and caveats. Caveats are on the card; the model speaks+one only when it changes the answer, and always says lower bounds and partial+answers. `narration.js` speaks one+code-authored line for the current step of a tool still running at 1.5 s+(out of band, never after the result). Tools that report steps: layer+toggles, place lookups, select_nearest_aircraft and annotate_map (finding,+outlining). Other tools get one "still working" line at 8 s. The+earcon plays in push-to-talk only. A claimed Space hold while the assistant+speaks is a barge-in (WebRTC cancel + audio clear), refused while Radio holds+the speaker (`mayVoiceClaimSpeaker()`). Progress lines stay outside the reply+lifecycle and Radio handoff. `turn.span` debug records carry generation and+playback latency, silence, preamble and word-count figures. Caption+transcription (`OPENAI_REALTIME_TRANSCRIBE_MODEL`, default on) is metered into+the session cost and cap. The debug log omits transcripts, text, tool arguments+and complete tool-result bodies (including serialized function outputs) unless+`GEV_VOICE_LOG_CONTENT=1`.+Tool names, call IDs, protocol event metadata and usage remain available.++The voice manifest includes Street Level visibility toggles; its imagery has no++analyst query or entity-context records.++Point and ask: `pointerContext.js` reads what the cursor is on. A Space hold+is the pointing gesture: its keydown snapshot (released with the key) is sent+as an inert `pointer_context` item with the target, with reticle and chip.+Open-mic speech and typed turns count only a pointer that moved on the map in+the last 5 s and send only the kind (`pointing:"aircraft"`/`"ground"`); the chip appears when a tool+resolves it. Losing the pointer sends one `target:"none"` item. `deixis.js` resolves `'pointer'` in+track_entity/fly_to_location queries, get_entity_context scope, analyst_query+`scope.kind` and annotate_map targets, plus `referent:n` from the latest+numbered result (`referents.js`, cleared at session end). A new result set (an analyst count) replaces+the numbered list even when it is empty. Only the five rows numbered on the+card are resolvable; `-1` means the fifth/last visible row. `track_entity`+accepts either a named query or a referent, while an empty target is rejected. A reticle marks the+point during the turn and the voice card shows "THIS"/"HERE"; both hide in+Clean-UI and recording. A ground-only pointer lookup at local/city scale sends a ringed 512 px crop in+the one retained image slot, dropped if the camera moved or a newer capture or+turn started. The pointer path makes at most two bounded fresh-frame requests so+a slow render loop can recover without accepting a stale frame; a missing camera+identity, expired snapshot, invalid geometry, black frame or oversized payload+still fails closed. screenX/screenY against the crop are mapped back to the canvas. Harness: `qa-voice-routing.mjs --layer deixis`,+`--layer deixis-live`, `--layer behavior --deixis-only`.+The application shell composes focused state owners for navigation, destinationlookup/orbit, Cockpit, visual settings, panel layout, aircraft display and layerbindings. Keyboard/display subscriptions have a separate lifetime; existingdiff --cc scripts/package-boundaries.jsonindex 4670dbd82,ce778ee95..2a188b4b0--- a/scripts/package-boundaries.json+++ b/scripts/package-boundaries.json@@@ -2072,12 -2101,35 +2131,41 @@@"src/maps/imageryHost.js","src/ui/recentImagery.js","src/ui/imageryBoxTool.js",+ "src/voice/pointerContext.js",+ "src/voice/pointerReticle.js",+ "src/voice/deixis.js",+ "src/voice/referents.js",+ "src/voice/pointerPick.js",+ "src/data/pickedContext.js",+ "src/ui/streetLevelControls.js",+ "src/ui/streetLevelPresentation.js",+ "src/layers/streetLevel/index.js",+ "src/layers/streetLevel/providers/mapillary/index.js",+ "src/layers/streetLevel/viewerHost.js",+ "src/layers/streetLevel/credits.js",+ "src/layers/streetLevel/cameraFollow.js",+ "src/layers/streetLevel/marker.js",+ "src/layers/streetLevel/view.js",+ "src/layers/streetLevel/uiState.js",+ "src/layers/streetLevel/groundCast.js",+ "src/layers/streetLevel/meshSampler.js",+ "src/layers/streetLevel/pickRouter.js",+ "src/layers/streetLevel/params.js",+ "src/layers/streetLevel/registry.js",+ "src/layers/streetLevel/filter.js",+ "src/layers/streetLevel/policy.js",+ "src/layers/streetLevel/state.js",+ "src/layers/streetLevel/providers/mapillary/policy.js",+ "src/layers/streetLevel/providers/mapillary/coverage.js",+ "src/layers/streetLevel/providers/mapillary/sequences.js",+ "src/layers/streetLevel/glyphs.js",+ "src/layers/streetLevel/providers/mapillary/decode.js",+ "src/layers/streetLevel/providers/mapillary/coverageFixture.mjs",+ "src/layers/streetLevel/tileMath.js",+ "src/layers/streetLevel/selection.js",+ "src/layers/streetLevel/providers/mapillary/viewer.js",+ "src/layers/streetLevel/providers/mapillary/source.js",+ "src/app/layers/streetLevel.js","src/layers/alpr/tileRecords.js","src/sources/capability.js","src/sources/openFreeMap.js",diff --cc src/firstRunExperience.test.mjsindex c4a98e702,347b8c9ef..49711163f--- a/src/firstRunExperience.test.mjs+++ b/src/firstRunExperience.test.mjs@@@ -667,16 -667,12 +667,17 @@@ test('the voice TOOL SCHEMA matches th// Cyber deliberately adds one layout; first-run missions still change no tools.hudLayout.enum = hudLayout.enum.filter((layout) => layout !== 'cyber');const block = JSON.stringify(legacyTools);- // Re-derived for the additive `local-adsb` set_layer_visibility value and- // its common-name mapping; the missions still ride existing tools.- assert.equal(block.length, 27432, 'serialized tool schema length drifted');+ // Re-derived for the voice layer manifest (generated layer enums, alias and+ // field hints), point-and-ask's pointer/referent arguments and the prompt+ // consolidation (shorter analyst, annotate_map and ISS wording), plus the+ // referent-only track_entity alternative (kept out of the model-facing+ // schema, which may not carry top-level anyOf), and Contacts requested-radius+ // list descriptions; the missions still ride existing tools.- assert.equal(block.length, 29724, 'serialized tool schema length drifted');++ // Street Level adds toggle enum values and the generated alias hint.++ assert.equal(block.length, 29802, 'serialized tool schema length drifted');assert.equal(crypto.createHash('sha256').update(block).digest('hex'),- '5dd41cfbd4f52acce3071dcfbc80acd758e390ad251ca07b5db67094383c6a93',- 'a2a4a787f4528f75b01f3f42caec636f29c37452c0d45b11f4f986171d6be57d',++ 'b316ca2e67848eb565b6847ac044a19d1465d8ef8252a5dfbd7d947a2a36d5ed','the first-run missions must ride EXISTING tools: no schema edit, no cache bust',);const instructions = fs.readFileSync(new URL('../server/providers/openai/instructions.js', import.meta.url), 'utf8');diff --cc src/voice/actionSchemas.test.mjsindex 8c3d09b55,8b944924b..d3b8e8a90--- a/src/voice/actionSchemas.test.mjs+++ b/src/voice/actionSchemas.test.mjs@@@ -31,12 -27,9 +31,13 @@@ test('the complete Realtime tool payloa.digest('hex');assert.equal(digest,- // Re-derived for the additive `local-adsb` set_layer_visibility value and- // the Cyber HUD layout; the separate sonar tool is excluded above.- '590d537d93e132ac64ac5e211ad5bb9d7d1b1f22e2dd963dda5465fab4510a3b',+ // Re-derived for the voice layer manifest (generated layer enums and+ // aliases), point-and-ask (pointer sentinels, referent args) and the+ // consolidated tool wording (each policy stated once); model-facing tools+ // omit top-level anyOf (OpenAI rejects it). Contacts list routing preserves+ // requested radius and center authority in descriptions only.- '71c66bb725e6987e56780db1e1a05e17359df6f2fcc4884b7ad46f326eae5f5d',++ // Street Level adds its toggle enum values and generated alias hint.++ '9eb113454c5af5e32e27ffcdc7919d0e4600ba1d204f8f175e071152be41ad0f',);});diff --cc src/voice/layerManifest.jsindex 3fe090785,000000000..1e348ee41mode 100644,000000..100644--- a/src/voice/layerManifest.js+++ b/src/voice/layerManifest.js@@@ -1,518 -1,0 +1,524 @@@+/**+ * Voice manifest for every data layer the application catalog constructs.+ *+ * One plain-data entry per layer declares each voice capability separately:+ * the spoken aliases the action runner accepts, `toggle` (set_layer_visibility),+ * `context` (registers in-view entity context), `track` (track_entity), and+ * `query` — the analyst_query fields with type and unit — or `noQuery`, the+ * reason it has none. No layer has a voice timeline yet.+ *+ * Both the server tool builder (`actionSchemas.js` → the Realtime tool JSON)+ * and the browser runner (`gevActions.js`) derive their layer enums and alias+ * tables from here, so a new layer is reachable by voice as soon as it has an+ * entry. `layerManifest.test.mjs` fails when a catalog layer is neither listed+ * nor named in `VOICE_OFF_LAYERS`.+ *+ * Pure data: no Cesium, DOM or Node imports (the server imports this module).+ * @module voice/layerManifest+ */++/**+ * Field type shorthands: n = number, t = text, f = flag (boolean),+ * ms = epoch-milliseconds time (filters also accept ISO strings).+ * A second array element is the unit.+ */+const AIRCRAFT_FIELDS = {+ altitudeM: ['n', 'm'],+ speedMps: ['n', 'm/s'],+ verticalRateMps: ['n', 'm/s'],+ heading: ['n', 'deg'],+ callsign: ['t'],+ icao24: ['t'],+ originCountry: ['t'],+ operator: ['t'],+ aircraftClass: ['t'],+ military: ['f'],+ onGround: ['f'],+};++const layers = [+ {+ id: 'flights',+ track: true,+ aliases: ['planes', 'aircraft', 'air traffic'],+ context: false,+ query: {+ fields: {+ ...AIRCRAFT_FIELDS,+ routeOrigin: ['t'],+ routeDestination: ['t'],+ },+ viewportLoaded: true,+ },+ },+ {+ id: 'military',+ track: true,+ aliases: ['military flights', 'military aircraft', 'military planes'],+ context: false,+ query: { fields: AIRCRAFT_FIELDS },+ },+ {+ id: 'local-adsb',+ aliases: [+ 'my receiver',+ 'local adsb',+ 'local ads-b',+ 'my antenna',+ 'my sdr',+ ],+ context: true,+ query: {+ fields: {+ altitudeM: ['n', 'm'],+ speedKts: ['n', 'kn'],+ heading: ['n', 'deg'],+ callsign: ['t'],+ icao24: ['t'],+ onGround: ['f'],+ },+ },+ },+ {+ id: 'ais-live-vessels',+ track: true,+ aliases: ['ships', 'vessels', 'boats', 'ais', 'live vessels'],+ context: true,+ query: {+ fields: {+ speedKts: ['n', 'kn'],+ courseDeg: ['n', 'deg'],+ name: ['t'],+ mmsi: ['t'],+ shipType: ['t'],+ destination: ['t'],+ },+ },+ },+ {+ id: 'satellites',+ track: true,+ aliases: ['satellite', 'sats'],+ context: false,+ query: {+ fields: {+ altitudeM: ['n', 'm'],+ speedMps: ['n', 'm/s'],+ name: ['t'],+ noradId: ['t'],+ satelliteClass: ['t'],+ group: ['t'],+ },+ caveat: 'distance is ground distance, not overhead',+ },+ },+ {+ id: 'rocket-launches',+ aliases: [+ 'rocket launches',+ 'launches',+ 'space missions',+ 'space mission',+ 'missions',+ ],+ context: false,+ query: {+ fields: {+ name: ['t'],+ provider: ['t'],+ status: ['t'],+ launchSite: ['t'],+ missionName: ['t'],+ launchTimeMs: ['ms'],+ hoursUntil: ['n', 'h'],+ },+ window: 'past 30 d and upcoming',+ },+ },+ {+ id: 'earthquakes',+ aliases: ['quakes', 'seismic'],+ context: false,+ query: {+ fields: {+ magnitude: ['n'],+ depthKm: ['n', 'km'],+ place: ['t'],+ timeMs: ['ms'],+ },+ timeField: 'timeMs',+ window: 'last 24 h',+ },+ },+ {+ id: 'local-firms',+ aliases: ['fires', 'wildfires', 'active fires', 'firms'],+ context: true,+ query: {+ fields: {+ frp: ['n', 'MW'],+ confidence: ['n', '0-1'],+ satellite: ['t'],+ sensor: ['t'],+ acqTime: ['ms'],+ },+ timeField: 'acqTime',+ window: 'last 24 h',+ },+ },+ {+ id: 'fire-perimeters',+ aliases: [+ 'fire perimeters',+ 'wildfire perimeters',+ 'burn areas',+ 'perimeters',+ ],+ context: false,+ query: {+ fields: {+ acres: ['n', 'acres'],+ containedPct: ['n', '%'],+ personnel: ['n'],+ costToDate: ['n', 'USD'],+ name: ['t'],+ state: ['t'],+ county: ['t'],+ cause: ['t'],+ behavior: ['t'],+ complexity: ['t'],+ discoveredTime: ['ms'],+ },+ timeField: 'discoveredTime',+ },+ },+ {+ id: 'weather-cyclones',+ aliases: ['cyclones', 'hurricanes', 'typhoons', 'tropical storms'],+ context: false,+ query: {+ fields: {+ name: ['t'],+ classification: ['t'],+ basin: ['t'],+ windKt: ['n', 'kn'],+ pressureHpa: ['n', 'hPa'],+ },+ },+ },+ {+ id: 'weather-radar',+ aliases: ['weather radar', 'radar', 'rain', 'weather'],+ context: false,+ noQuery: 'map overlay; no countable records',+ },+ {+ id: 'weather-satellite',+ aliases: ['weather satellite', 'clouds', 'cloud imagery'],+ context: false,+ noQuery: 'map overlay; no countable records',+ },+ {+ id: 'weather-lightning',+ aliases: ['lightning', 'lightning strikes'],+ context: false,+ noQuery: 'map overlay; no countable records',+ },+ {+ id: 'wind',+ aliases: ['winds', 'wind map'],+ context: false,+ noQuery: 'map overlay; no countable records',+ },+ {+ id: 'traffic',+ aliases: ['street traffic', 'road traffic', 'congestion'],+ context: false,+ noQuery: 'road-speed overlay; no countable records',+ },+ {+ id: 'transit',+ aliases: ['buses', 'trains', 'public transit', 'trams', 'subway'],+ context: false,+ query: {+ fields: {+ mode: ['t'],+ routeId: ['t'],+ speedMps: ['n', 'm/s'],+ courseDeg: ['n', 'deg'],+ status: ['t'],+ occupancy: ['t'],+ },+ },+ },+ {+ id: 'bikeshare',+ aliases: ['bike share', 'bikes', 'bike stations'],+ context: false,+ query: {+ fields: {+ bikesAvailable: ['n'],+ docksAvailable: ['n'],+ capacity: ['n'],+ name: ['t'],+ city: ['t'],+ renting: ['f'],+ },+ },+ },+ {+ id: 'cctv',+ aliases: ['traffic cameras', 'cameras', 'webcams'],+ context: false,+ noQuery: 'use control_cctv',+ },+ {+ id: 'alpr-cameras',+ aliases: [+ 'flock cameras',+ 'license plate readers',+ 'alpr',+ 'alpr cameras',+ 'license plate cameras',+ 'plate readers',+ ],+ context: true,+ query: {+ fields: {+ operator: ['t'],+ manufacturer: ['t'],+ cameraType: ['t'],+ directionDeg: ['n', 'deg'],+ },+ },+ },+ {+ id: 'radio',+ aliases: ['internet radio', 'radio stations'],+ context: false,+ noQuery: 'use control_radio',+ },++ {++ id: 'street-level',++ aliases: ['street level', 'street-level imagery', 'mapillary'],++ context: false,++ noQuery: 'street-level imagery; no countable records',++ },+ {+ id: 'recent-imagery',+ aliases: [+ 'recent satellite imagery',+ 'recent imagery',+ 'latest imagery',+ 'new imagery',+ ],+ context: false,+ noQuery: 'imagery tiles; no countable records',+ },+ {+ id: 'directions',+ aliases: ['driving directions', 'directions panel'],+ context: false,+ noQuery: 'use annotate_map type=route',+ },+ {+ id: 'military-installations',+ aliases: ['military bases', 'bases', 'installations'],+ context: true,+ query: { fields: { name: ['t'], class: ['t'], kind: ['t'] } },+ },+ {+ id: 'local-datacenters',+ aliases: ['datacenters', 'data centers', 'data centres'],+ context: true,+ query: {+ fields: { name: ['t'], operator: ['t'], capacity: ['t'] },+ },+ },+ {+ id: 'local-dams',+ aliases: ['dams'],+ context: true,+ query: {+ fields: {+ name: ['t'],+ operator: ['t'],+ river: ['t'],+ output: ['t'],+ },+ },+ },+ {+ id: 'telegeography-submarine-cables',+ aliases: ['submarine cables', 'undersea cables', 'cables', 'telegeography'],+ context: false,+ noQuery: 'cable records are not loaded for queries',+ },+ {+ // Global Context owns this layer; voice reaches it through+ // set_context_mode, never a bare toggle.+ id: 'military-awareness',+ aliases: [],+ toggle: false,+ context: false,+ noQuery: 'use set_context_mode contacts',+ },+];++/**+ * Catalog layers deliberately outside voice, with the reason. The Bhote Koshi+ * pair belong to a scripted scene and are driven by `control_scene`.+ */+export const VOICE_OFF_LAYERS = Object.freeze({+ 'bhote-koshi-2026': 'scene-driven event layer (control_scene)',+ 'bhote-koshi-locator': 'scene-driven event layer (control_scene)',+});++const TYPE_NAMES = Object.freeze({+ n: 'number',+ t: 'text',+ f: 'flag',+ ms: 'time',+});++function normalizeEntry(entry) {+ const fields = entry.query+ ? Object.fromEntries(+ Object.entries(entry.query.fields).map(([name, [type, unit]]) => [+ name,+ Object.freeze({+ type: TYPE_NAMES[type],+ ...(unit ? { unit } : {}),+ }),+ ]),+ )+ : null;+ return Object.freeze({+ id: entry.id,+ aliases: Object.freeze([...entry.aliases]),+ toggle: entry.toggle !== false,+ context: entry.context === true,+ track: entry.track === true,+ noQuery: entry.noQuery || null,+ query: fields+ ? Object.freeze({+ fields: Object.freeze(fields),+ timeField: entry.query.timeField || null,+ window: entry.query.window || null,+ caveat: entry.query.caveat || null,+ viewportLoaded: entry.query.viewportLoaded === true,+ })+ : null,+ });+}++/** Every voice-reachable layer, in the order the tool enums list them. */+export const VOICE_LAYER_MANIFEST = Object.freeze(layers.map(normalizeEntry));++const byId = new Map(VOICE_LAYER_MANIFEST.map((entry) => [entry.id, entry]));++/**+ * The manifest entry for one layer id.+ * @param {string} id Layer id.+ * @returns {object|null} Entry, or null for an unknown or voice-off layer.+ */+export function voiceLayer(id) {+ return byId.get(id) || null;+}++/** Layer ids `set_layer_visibility` and `show_data_layers_menu` accept. */+export const VOICE_TOGGLE_LAYER_IDS = Object.freeze(+ VOICE_LAYER_MANIFEST.filter((entry) => entry.toggle).map((entry) => entry.id),+);++/** Layers that register in-view entity context (`get_entity_context.layerId`). */+export const VOICE_CONTEXT_LAYER_IDS = Object.freeze(+ VOICE_LAYER_MANIFEST.filter((entry) => entry.context).map(+ (entry) => entry.id,+ ),+);++/** Layers `analyst_query` can count, filter and rank. */+export const VOICE_QUERY_LAYER_IDS = Object.freeze(+ VOICE_LAYER_MANIFEST.filter((entry) => entry.query).map((entry) => entry.id),+);++/**+ * Spoken name → layer id, for the browser runner. Ids map to themselves and+ * each alias to its layer; the first layer to claim an alias keeps it.+ * @returns {Map<string, string>} Lower-case phrase → layer id.+ */+export function voiceLayerAliasMap() {+ const map = new Map();+ for (const entry of VOICE_LAYER_MANIFEST) {+ map.set(entry.id, entry.id);+ map.set(entry.id.replace(/-/g, ' '), entry.id);+ }+ for (const entry of VOICE_LAYER_MANIFEST) {+ for (const alias of entry.aliases) {+ const key = alias.toLowerCase();+ if (!map.has(key)) map.set(key, entry.id);+ }+ }+ return map;+}++/** Plain-word ids the model already maps from speech without a hint. */+const SELF_EVIDENT_IDS = new Set([+ 'flights',+ 'military',+ 'satellites',+ 'earthquakes',+ 'traffic',+ 'radio',+ 'wind',+ 'directions',+]);++/**+ * Compact model-facing alias hint: "alias/alias→id; …" for toggleable layers+ * whose id is not already the spoken word. At most two aliases per layer keep+ * the tool JSON small; the runner accepts the full alias list.+ * @returns {string} One line for the layerId description.+ */+export function voiceLayerAliasHint() {+ return VOICE_LAYER_MANIFEST.filter(+ (entry) =>+ entry.toggle && entry.aliases.length && !SELF_EVIDENT_IDS.has(entry.id),+ )+ .map((entry) => `${entry.aliases.slice(0, 2).join('/')}→${entry.id}`)+ .join('; ');+}++/** Field names that already carry their unit (altitudeM, speedKts, …). */+const UNIT_SUFFIX = /(M|Mps|Kts|Kt|Km|Deg|Hpa)$/;++/**+ * Compact field list for the analyst_query description:+ * "flights: altitudeM,speedMps,…,confidence(0-1)". Units appear only where+ * the field name does not already say them.+ * @returns {string} One clause per queryable layer.+ */+export function voiceQueryFieldHint() {+ const printed = [];+ return VOICE_LAYER_MANIFEST.filter((entry) => entry.query)+ .map((entry) => {+ const names = Object.keys(entry.query.fields);+ // A layer whose fields are a subset of an earlier one's points at it.+ const parent = printed.find((prior) =>+ names.every((name) => prior.names.includes(name)),+ );+ printed.push({ id: entry.id, names });+ if (parent) {+ const minus = parent.names.filter((name) => !names.includes(name));+ return `${entry.id}: as ${parent.id}${minus.length ? ` minus ${minus.join(',')}` : ''}`;+ }+ const fields = Object.entries(entry.query.fields)+ .map(([name, spec]) =>+ spec.unit && !UNIT_SUFFIX.test(name) ? `${name}(${spec.unit})` : name,+ )+ .join(',');+ return `${entry.id}: ${fields}`;+ })+ .join('; ');+}diff --cc src/voice/layerManifest.test.mjsindex 6607e078d,000000000..d0222b934mode 100644,000000..100644--- a/src/voice/layerManifest.test.mjs+++ b/src/voice/layerManifest.test.mjs@@@ -1,112 -1,0 +1,114 @@@+import test from 'node:test';+import assert from 'node:assert/strict';+import { APPLICATION_LAYER_METADATA } from '../app/constructCatalog.js';+import { GEV_REALTIME_TOOLS } from '../../server/providers/openai/tools.js';+import { ANALYST_LAYERS } from '../data/analystEngine.js';+import {+ VOICE_LAYER_MANIFEST,+ VOICE_OFF_LAYERS,+ VOICE_TOGGLE_LAYER_IDS,+ VOICE_CONTEXT_LAYER_IDS,+ VOICE_QUERY_LAYER_IDS,+ voiceLayerAliasMap,+} from './layerManifest.js';++const catalogIds = APPLICATION_LAYER_METADATA.map((layer) => layer.id);+const manifestIds = VOICE_LAYER_MANIFEST.map((entry) => entry.id);+const tool = (name) => GEV_REALTIME_TOOLS.find((entry) => entry.name === name);++test('every catalog layer is in the voice manifest or explicitly voice-off', () => {+ const missing = catalogIds.filter(+ (id) => !manifestIds.includes(id) && !Object.hasOwn(VOICE_OFF_LAYERS, id),+ );+ assert.deepEqual(missing, [], `add a voice manifest entry for: ${missing.join(', ')}`);+ for (const id of Object.keys(VOICE_OFF_LAYERS)) {+ assert.ok(catalogIds.includes(id), `${id} is voice-off but not in the catalog`);+ assert.ok(!manifestIds.includes(id), `${id} is both voice-off and in the manifest`);+ }+ const unknown = manifestIds.filter((id) => !catalogIds.includes(id));+ assert.deepEqual(unknown, [], 'the manifest names only catalog layers');+ assert.equal(new Set(manifestIds).size, manifestIds.length, 'one entry per layer');+});++test('each layer declares a query or the reason it has none', () => {+ for (const entry of VOICE_LAYER_MANIFEST) {+ assert.ok(+ Boolean(entry.query) !== Boolean(entry.noQuery),+ `${entry.id} needs exactly one of query / noQuery`,+ );+ if (entry.query) assert.ok(Object.keys(entry.query.fields).length > 0);+ }+});++test('tool enums are generated from the manifest', () => {+ const toggle = tool('set_layer_visibility').parameters.properties.layerId.enum;+ assert.deepEqual(toggle, [...VOICE_TOGGLE_LAYER_IDS]);+ for (const id of [+ 'transit',+ 'recent-imagery',++ 'street-level',+ 'wind',+ 'weather-radar',+ 'weather-satellite',+ 'weather-lightning',+ 'weather-cyclones',+ 'military-installations',+ 'directions',+ 'rocket-launches',+ 'bikeshare',+ 'local-adsb',+ ])+ assert.ok(toggle.includes(id), `${id} is voice-toggleable`);+ assert.ok(!toggle.includes('military-awareness'), 'Global Context is reached through set_context_mode');+ assert.deepEqual(+ tool('show_data_layers_menu').parameters.properties.layerId.enum,+ [...VOICE_TOGGLE_LAYER_IDS],+ );+ assert.deepEqual(+ tool('get_entity_context').parameters.properties.layerId.enum,+ [...VOICE_CONTEXT_LAYER_IDS],+ );+ assert.ok(!VOICE_CONTEXT_LAYER_IDS.includes('telegeography-submarine-cables'), 'cables register no context records');+ assert.deepEqual(+ tool('analyst_query').parameters.properties.layers.items.enum,+ [...VOICE_QUERY_LAYER_IDS],+ );+ assert.deepEqual(Object.keys(ANALYST_LAYERS), [...VOICE_QUERY_LAYER_IDS]);+ const panels = tool('set_panel_open').parameters.properties.panelId.enum;+ assert.ok(panels.includes('weather-panel') && panels.includes('recent-imagery-panel'));+});++test('spoken aliases resolve to real layers, keep every legacy phrase and never collide', () => {+ const aliases = voiceLayerAliasMap();+ for (const id of aliases.values()) assert.ok(manifestIds.includes(id), id);+ const legacy = {+ planes: 'flights', aircraft: 'flights', 'military flights': 'military', quakes: 'earthquakes',+ 'space mission': 'rocket-launches', 'space missions': 'rocket-launches', missions: 'rocket-launches',+ 'street traffic': 'traffic', cameras: 'cctv', 'internet radio': 'radio', 'radio stations': 'radio',+ bikes: 'bikeshare', ais: 'ais-live-vessels', ships: 'ais-live-vessels', vessels: 'ais-live-vessels',+ 'live vessels': 'ais-live-vessels', datacenters: 'local-datacenters', 'data centers': 'local-datacenters',+ 'data centres': 'local-datacenters', dams: 'local-dams', 'submarine cables': 'telegeography-submarine-cables',+ cables: 'telegeography-submarine-cables', telegeography: 'telegeography-submarine-cables',+ firms: 'local-firms', fires: 'local-firms', 'active fires': 'local-firms', alpr: 'alpr-cameras',+ 'alpr cameras': 'alpr-cameras', 'flock cameras': 'alpr-cameras', 'license plate readers': 'alpr-cameras',+ 'license plate cameras': 'alpr-cameras', 'plate readers': 'alpr-cameras', 'local-adsb': 'local-adsb',+ 'local adsb': 'local-adsb', 'local ads-b': 'local-adsb', 'my receiver': 'local-adsb',+ 'my antenna': 'local-adsb', 'my sdr': 'local-adsb',+ };+ for (const [phrase, id] of Object.entries(legacy)) assert.equal(aliases.get(phrase), id, phrase);+ const added = {+ buses: 'transit', trains: 'transit', hurricanes: 'weather-cyclones', cyclones: 'weather-cyclones',+ 'weather radar': 'weather-radar', lightning: 'weather-lightning', 'military bases': 'military-installations',+ 'recent imagery': 'recent-imagery', 'bike share': 'bikeshare', 'rocket launches': 'rocket-launches',++ 'street level': 'street-level', mapillary: 'street-level',+ wind: 'wind', directions: 'directions', 'fire perimeters': 'fire-perimeters',+ 'wildfire perimeters': 'fire-perimeters', 'burn areas': 'fire-perimeters',+ };+ for (const [phrase, id] of Object.entries(added)) assert.equal(aliases.get(phrase), id, phrase);+ const claimed = new Map();+ for (const entry of VOICE_LAYER_MANIFEST)+ for (const alias of entry.aliases) {+ assert.ok(!claimed.has(alias), `"${alias}" claimed by ${claimed.get(alias)} and ${entry.id}`);+ claimed.set(alias, entry.id);+ }+});