style: apply current runtime formatter to voice integration

This commit is contained in:
Bilawal Sidhu committed 2026-09-15 10:54:32 -05:00
1 parent 3385e6b713
commit d1a72a35af
4 files changed
+201 -36

No files matched your search

+68 -11
View File
@@ -29,14 +29,54 @@ import { pointInRing } from './naturalEarthRegions.js';
/** Layers the engine understands, with the fields queries may reference. */ /** Layers the engine understands, with the fields queries may reference. */
export const ANALYST_LAYERS = { export const ANALYST_LAYERS = {
flights: { numeric: ['altitudeM', 'speedMps', 'verticalRateMps'], text: ['callsign', 'icao24', 'originCountry', 'operator', 'routeOrigin', 'routeDestination', 'aircraftClass'], flags: ['military', 'onGround'] }, flights: {
military: { numeric: ['altitudeM', 'speedMps', 'verticalRateMps'], text: ['callsign', 'icao24', 'originCountry', 'operator', 'aircraftClass'], flags: ['military', 'onGround'] }, numeric: ['altitudeM', 'speedMps', 'verticalRateMps'],
'ais-live-vessels': { numeric: ['speedKts', 'courseDeg'], text: ['name', 'mmsi', 'shipType', 'destination', 'navStatus'], flags: [] }, text: [
'local-firms': { numeric: ['frp'], text: ['confidence', 'satellite'], flags: [] }, 'callsign',
earthquakes: { numeric: ['magnitude', 'depthKm'], text: ['place'], flags: [] }, 'icao24',
satellites: { numeric: ['altitudeM', 'speedMps'], text: ['name', 'noradId', 'satelliteClass', 'group'], flags: [] }, 'originCountry',
'local-datacenters': { numeric: [], text: ['name', 'operator', 'capacity'], flags: [] }, 'operator',
'local-dams': { numeric: [], text: ['name', 'operator', 'river', 'output'], flags: [] }, 'routeOrigin',
'routeDestination',
'aircraftClass',
],
flags: ['military', 'onGround'],
},
military: {
numeric: ['altitudeM', 'speedMps', 'verticalRateMps'],
text: ['callsign', 'icao24', 'originCountry', 'operator', 'aircraftClass'],
flags: ['military', 'onGround'],
},
'ais-live-vessels': {
numeric: ['speedKts', 'courseDeg'],
text: ['name', 'mmsi', 'shipType', 'destination', 'navStatus'],
flags: [],
},
'local-firms': {
numeric: ['frp'],
text: ['confidence', 'satellite'],
flags: [],
},
earthquakes: {
numeric: ['magnitude', 'depthKm'],
text: ['place'],
flags: [],
},
satellites: {
numeric: ['altitudeM', 'speedMps'],
text: ['name', 'noradId', 'satelliteClass', 'group'],
flags: [],
},
'local-datacenters': {
numeric: [],
text: ['name', 'operator', 'capacity'],
flags: [],
},
'local-dams': {
numeric: [],
text: ['name', 'operator', 'river', 'output'],
flags: [],
},
}; };
const EARTH_R_KM = 6371; const EARTH_R_KM = 6371;
@@ -161,7 +201,20 @@ export function createAnalystEngine(providers) {
const rows = providers.getRecords(key) || []; const rows = providers.getRecords(key) || [];
const snapshot = providers.getLayerSnapshot?.(key); const snapshot = providers.getLayerSnapshot?.(key);
if (snapshot) queriedSnapshots.push(snapshot); if (snapshot) queriedSnapshots.push(snapshot);
layersQueried.push({ layerKey: key, records: rows.length, ...(snapshot ? { feedState: snapshot.feedState, source: snapshot.source, lastUpdate: snapshot.lastUpdate, enabled: snapshot.enabled, error: snapshot.error } : {}), ...providers.getRecordCoverage?.(key, rows) }); layersQueried.push({
layerKey: key,
records: rows.length,
...(snapshot
? {
feedState: snapshot.feedState,
source: snapshot.source,
lastUpdate: snapshot.lastUpdate,
enabled: snapshot.enabled,
error: snapshot.error,
}
: {}),
...providers.getRecordCoverage?.(key, rows),
});
for (const row of rows) records.push({ layerKey: key, ...row }); for (const row of rows) records.push({ layerKey: key, ...row });
} }
} }
@@ -273,9 +326,13 @@ export function createAnalystEngine(providers) {
coverage: { coverage: {
layersQueried, layersQueried,
scope: scopeNote, scope: scopeNote,
...(queriedSnapshots.length ? { feedProvenance: feedProvenanceEnvelope(queriedSnapshots) } : {}), ...(queriedSnapshots.length
? { feedProvenance: feedProvenanceEnvelope(queriedSnapshots) }
: {}),
followUp: Boolean(spec.followUp && lastResult), followUp: Boolean(spec.followUp && lastResult),
note: layersQueried.some((layer) => layer.basis === 'bounded-loaded-records') note: layersQueried.some(
(layer) => layer.basis === 'bounded-loaded-records',
)
? 'Counts and ranks cover the bounded examined loaded records only; omitted records may change the nearest item or count. Satellite distance is ground distance, not slant range.' ? 'Counts and ranks cover the bounded examined loaded records only; omitted records may change the nearest item or count. Satellite distance is ground distance, not slant range.'
: 'client-side data only — answers cover what the enabled layers currently hold', : 'client-side data only — answers cover what the enabled layers currently hold',
}, },
+21 -4
View File
@@ -24,7 +24,12 @@ import {
geoidHeight, geoidHeight,
} from './data/geoid.js'; } from './data/geoid.js';
import { getBasemapLabelContext } from './voice/gevActions.js'; import { getBasemapLabelContext } from './voice/gevActions.js';
import { hudSummaryMatchesProvenance, hudSummaryLayerContext, hudTelemetryProvenanceTag, isHudSummaryUnconfigured } from './hudSummaryResponse.js'; import {
hudSummaryMatchesProvenance,
hudSummaryLayerContext,
hudTelemetryProvenanceTag,
isHudSummaryUnconfigured,
} from './hudSummaryResponse.js';
/** Color palettes keyed by shader mode; applied as CSS custom properties. */ /** Color palettes keyed by shader mode; applied as CSS custom properties. */
const HUD_COLORS = { const HUD_COLORS = {
@@ -649,7 +654,9 @@ export class IntelHUD {
// NEAR the nearest catalogued POI at metro range; otherwise the lat/lon sector. // NEAR the nearest catalogued POI at metro range; otherwise the lat/lon sector.
const localityTag = composeLocalityTag(nearest, m.latDeg, m.lonDeg); const localityTag = composeLocalityTag(nearest, m.latDeg, m.lonDeg);
const provenance = hudTelemetryProvenanceTag(this._dataManager?.getAll?.() || []); const provenance = hudTelemetryProvenanceTag(
this._dataManager?.getAll?.() || [],
);
const line = `${modeLabel} ${band} ${localityTag} | ${region} | ALT ${altTag} | WINDOW ${winTag} | SUN ${m.sunEl.toFixed(0)}° | ONA ${m.ona.toFixed(0)}° | ${localTag}`; const line = `${modeLabel} ${band} ${localityTag} | ${region} | ALT ${altTag} | WINDOW ${winTag} | SUN ${m.sunEl.toFixed(0)}° | ONA ${m.ona.toFixed(0)}° | ${localTag}`;
return provenance ? `${line} | ${provenance}` : line; return provenance ? `${line} | ${provenance}` : line;
} }
@@ -736,7 +743,12 @@ export class IntelHUD {
if (!response.ok || !data?.summary) { if (!response.ok || !data?.summary) {
throw new Error(data?.error || `HTTP ${response.status}`); throw new Error(data?.error || `HTTP ${response.status}`);
} }
this._setSummaryText(hudSummaryMatchesProvenance(data.summary, context.feedProvenance) ? data.summary : fallbackText, animate); this._setSummaryText(
hudSummaryMatchesProvenance(data.summary, context.feedProvenance)
? data.summary
: fallbackText,
animate,
);
} catch (error) { } catch (error) {
if (error?.name !== 'AbortError') { if (error?.name !== 'AbortError') {
console.warn('[HUD] AI summary unavailable:', error); console.warn('[HUD] AI summary unavailable:', error);
@@ -907,7 +919,12 @@ export class IntelHUD {
this._dataManager = dataManager || null; this._dataManager = dataManager || null;
if (typeof this._dataManager?.subscribe === 'function') { if (typeof this._dataManager?.subscribe === 'function') {
this._dataManagerUnsubscribe = this._dataManager.subscribe((change) => { this._dataManagerUnsubscribe = this._dataManager.subscribe((change) => {
if (['visibility', 'refresh-transition', 'refresh-cancelled'].includes(change?.type)) this._markSummaryDirty(); if (
['visibility', 'refresh-transition', 'refresh-cancelled'].includes(
change?.type,
)
)
this._markSummaryDirty();
}); });
} }
this._markSummaryDirty(); this._markSummaryDirty();
+7 -2
View File
@@ -93,7 +93,9 @@ export function hudTelemetryProvenanceTag(layers = [], options) {
const envelope = feedProvenanceEnvelope(snapshots, options); const envelope = feedProvenanceEnvelope(snapshots, options);
if (!envelope.overall || envelope.overall === 'nominal') return null; if (!envelope.overall || envelope.overall === 'nominal') return null;
const names = envelope.layers const names = envelope.layers
.filter((s) => s.feedState && s.feedState !== 'nominal' && s.feedState !== 'off') .filter(
(s) => s.feedState && s.feedState !== 'nominal' && s.feedState !== 'off',
)
.map((s) => String(s.name || s.id || 'LAYER').toUpperCase()) .map((s) => String(s.name || s.id || 'LAYER').toUpperCase())
.slice(0, 2); .slice(0, 2);
return `${envelope.overall.toUpperCase()}${names.length ? ` ${names.join('/')}` : ''}`; return `${envelope.overall.toUpperCase()}${names.length ? ` ${names.join('/')}` : ''}`;
@@ -103,5 +105,8 @@ export function hudTelemetryProvenanceTag(layers = [], options) {
export function hudSummaryMatchesProvenance(summary, provenance) { export function hudSummaryMatchesProvenance(summary, provenance) {
const state = provenance?.overall; const state = provenance?.overall;
if (!state || state === 'nominal' || state === 'off') return true; if (!state || state === 'nominal' || state === 'off') return true;
return String(summary || '').toUpperCase().split(/\W+/).includes(String(state).toUpperCase()); return String(summary || '')
.toUpperCase()
.split(/\W+/)
.includes(String(state).toUpperCase());
} }
+105 -19
View File
@@ -1,4 +1,8 @@
import { layerSnapshot, layerSnapshots, feedProvenanceEnvelope } from '../data/layerSnapshot.js'; import {
layerSnapshot,
layerSnapshots,
feedProvenanceEnvelope,
} from '../data/layerSnapshot.js';
import { readLayerLifecycleSummary } from './layerSummary.js'; import { readLayerLifecycleSummary } from './layerSummary.js';
export { readLayerLifecycleSummary } from './layerSummary.js'; export { readLayerLifecycleSummary } from './layerSummary.js';
import { defaultGeospatial } from '../search/defaults.js'; import { defaultGeospatial } from '../search/defaults.js';
@@ -2661,7 +2665,8 @@ function nextIssPass(viewer, dataManager, args) {
peakElevationDeg: Math.round(pass.maxElevDeg), peakElevationDeg: Math.round(pass.maxElevDeg),
riseDirection: compassDir(pass.riseAzDeg), riseDirection: compassDir(pass.riseAzDeg),
visible: typeof pass.visible === 'boolean' ? pass.visible : null, visible: typeof pass.visible === 'boolean' ? pass.visible : null,
visibilityNote: 'Geometric illumination estimate only; weather, brightness and orbital-element age affect actual visibility.', visibilityNote:
'Geometric illumination estimate only; weather, brightness and orbital-element age affect actual visibility.',
setIso: new Date(pass.setMs).toISOString(), setIso: new Date(pass.setMs).toISOString(),
peakIso: new Date(pass.maxElevMs).toISOString(), peakIso: new Date(pass.maxElevMs).toISOString(),
}; };
@@ -2669,22 +2674,55 @@ function nextIssPass(viewer, dataManager, args) {
function nextSatellitePass(viewer, dataManager, args) { function nextSatellitePass(viewer, dataManager, args) {
const layer = dataManager?.layers?.get('satellites')?.module; const layer = dataManager?.layers?.get('satellites')?.module;
const identity = layer?.resolveSatelliteForPass?.(args.target) || { status: 'not-found' }; const identity = layer?.resolveSatelliteForPass?.(args.target) || {
if (identity.status !== 'ok') return { status: 'not-found',
ok: false, action: 'next_satellite_pass', ...identity, };
error: identity.status === 'ambiguous' ? 'Several loaded satellites match. Choose a NORAD ID from candidates.' : 'No loaded satellite matches. Enable satellites and use an exact name or NORAD ID.', if (identity.status !== 'ok')
return {
ok: false,
action: 'next_satellite_pass',
...identity,
error:
identity.status === 'ambiguous'
? 'Several loaded satellites match. Choose a NORAD ID from candidates.'
: 'No loaded satellite matches. Enable satellites and use an exact name or NORAD ID.',
}; };
// Reuse the legacy location fallback and result formatting, substituting only // Reuse the legacy location fallback and result formatting, substituting only
// this explicitly resolved catalog identity and the optional visibility filter. // this explicitly resolved catalog identity and the optional visibility filter.
const adapter = { layers: new Map([['satellites', { module: { const adapter = {
getNextIssPass: (options) => layer.getNextSatellitePass(identity.noradId, { ...options, requireVisible: args.visibleOnly === true }), layers: new Map([
} }]]) }; [
'satellites',
{
module: {
getNextIssPass: (options) =>
layer.getNextSatellitePass(identity.noradId, {
...options,
requireVisible: args.visibleOnly === true,
}),
},
},
],
]),
};
const result = nextIssPass(viewer, adapter, args); const result = nextIssPass(viewer, adapter, args);
if (result.error) { if (result.error) {
result.error = result.error.replace(/ISS/g, identity.name || String(identity.noradId)); result.error = result.error.replace(
if (args.visibleOnly === true) result.error += ' Search required estimated illumination under a dark sky.'; /ISS/g,
identity.name || String(identity.noradId),
);
if (args.visibleOnly === true)
result.error +=
' Search required estimated illumination under a dark sky.';
} }
return { ...result, action: 'next_satellite_pass', noradId: identity.noradId, name: identity.name, visibleOnly: args.visibleOnly === true, horizonHours: 24 }; return {
...result,
action: 'next_satellite_pass',
noradId: identity.noradId,
name: identity.name,
visibleOnly: args.visibleOnly === true,
horizonHours: 24,
};
} }
function normalizePanelId(value) { function normalizePanelId(value) {
@@ -3058,7 +3096,9 @@ function getCurrentViewState(
source: layerSnapshot(layer).source, source: layerSnapshot(layer).source,
lastUpdate: layerSnapshot(layer).lastUpdate, lastUpdate: layerSnapshot(layer).lastUpdate,
})), })),
feedProvenance: feedProvenanceEnvelope(layerSnapshots(dataManager.getAll()).filter((layer) => layer.enabled)), feedProvenance: feedProvenanceEnvelope(
layerSnapshots(dataManager.getAll()).filter((layer) => layer.enabled),
),
}; };
} }
@@ -4189,10 +4229,15 @@ function analystProviders(
const row = dataManager.getAll?.().find((layer) => layer.id === layerKey); const row = dataManager.getAll?.().find((layer) => layer.id === layerKey);
if (row) return layerSnapshot(row); if (row) return layerSnapshot(row);
const module = dataManager.layers?.get(layerKey)?.module; const module = dataManager.layers?.get(layerKey)?.module;
return layerSnapshot({ id: layerKey, enabled: dataManager.isEnabled?.(layerKey), stats: module?.getStats?.() || {} }); return layerSnapshot({
id: layerKey,
enabled: dataManager.isEnabled?.(layerKey),
stats: module?.getStats?.() || {},
});
}, },
getRecordCoverage(layerKey, rows) { getRecordCoverage(layerKey, rows) {
if (!['satellites', 'local-datacenters', 'local-dams'].includes(layerKey)) return null; if (!['satellites', 'local-datacenters', 'local-dams'].includes(layerKey))
return null;
const module = dataManager.layers.get(layerKey)?.module; const module = dataManager.layers.get(layerKey)?.module;
const loaded = module?.getStats?.().count; const loaded = module?.getStats?.().count;
return { return {
@@ -4271,7 +4316,36 @@ async function runAnalystQuery(
// model burned the turn on retries (owner field session 2026-08-21, 23:48). // model burned the turn on retries (owner field session 2026-08-21, 23:48).
const items = result.items.map((r) => { const items = result.items.map((r) => {
const compact = { layerKey: r.layerKey, id: r.id }; const compact = { layerKey: r.layerKey, id: r.id };
for (const k of ['icao24', 'mmsi', 'registration', 'label', 'callsign', 'name', 'altitudeM', 'speedMps', 'speedKts', 'frp', 'magnitude', 'shipType', 'destination', 'operator', 'routeOrigin', 'routeDestination', 'aircraftClass', 'military', 'onGround', 'distanceKm', 'confidence', 'place', 'noradId', 'satelliteClass', 'group', 'river', 'output', 'capacity']) { for (const k of [
'icao24',
'mmsi',
'registration',
'label',
'callsign',
'name',
'altitudeM',
'speedMps',
'speedKts',
'frp',
'magnitude',
'shipType',
'destination',
'operator',
'routeOrigin',
'routeDestination',
'aircraftClass',
'military',
'onGround',
'distanceKm',
'confidence',
'place',
'noradId',
'satelliteClass',
'group',
'river',
'output',
'capacity',
]) {
if (r[k] !== null && r[k] !== undefined) compact[k] = r[k]; if (r[k] !== null && r[k] !== undefined) compact[k] = r[k];
} }
return compact; return compact;
@@ -4305,10 +4379,22 @@ async function runAnalystQuery(
// differ. The generic record/scope engine still owns explicit regions and // differ. The generic record/scope engine still owns explicit regions and
// arbitrary points — only "how many aircraft around <this contact>" is // arbitrary points — only "how many aircraft around <this contact>" is
// unified, because that is the question the panel is already answering. // unified, because that is the question the panel is already answering.
const entityWindow = aircraftProximityWindowForQuery(dataManager, args, result); const entityWindow = aircraftProximityWindowForQuery(
dataManager,
args,
result,
);
if (entityWindow) { if (entityWindow) {
const provenance = feedProvenanceEnvelope(layerSnapshots(dataManager.getAll?.() || []).filter((layer) => layer.enabled && ['flights', 'military'].includes(layer.id))); const provenance = feedProvenanceEnvelope(
return { ...entityWindow, feedProvenance: provenance, feedState: provenance.overall }; layerSnapshots(dataManager.getAll?.() || []).filter(
(layer) => layer.enabled && ['flights', 'military'].includes(layer.id),
),
);
return {
...entityWindow,
feedProvenance: provenance,
feedState: provenance.overall,
};
} }
const contactsWindow = activeContactsWindow(dataManager); const contactsWindow = activeContactsWindow(dataManager);