Merge origin/main into german/navara

Main's new layers (drone airspace, OSM places, sea marks, ski pistes) are
Cesium-only for now: they join the layer directory and the Cesium catalog,
are built afresh for each Cesium catalog, and show as unavailable on Navara.

The zoom-out guard is a scene part that attaches to Cesium globes only. The
awareness range pulses and their echoes draw on Cesium through the awareness
display's viewer; Navara keeps the plain range ring. Camera-input wakes go
through the display, and the analyst keeps the session-owned memory with
main's area presentation. A disposed voice runner aborts work in flight, and
an engine switch still keeps the last answer.

Modules main added that read Cesium while they load (zoomOutGuard,
awarenessEcho, the ground-sampling scratch in localGeojsonCore) now build
those values on first use or use src/geo, so a Navara page still starts
without the SDK. The OSM view box reads the engine's view rectangle.

Main grew its own main chunk by 93,873 bytes gzip-9 since the merge base, so
the baseline is raised to the merged size.
This commit is contained in:
German Khokhlov committed 2026-11-04 23:11:31 +04:00
commit db9bf64821
264 files changed
+33864 -1424

No files matched your search

+234 -52
View File
@@ -63,6 +63,14 @@ import {
activeContactsWindow,
TRACKABLE_FAMILIES,
} from '../agent/worldPacket.js';
import { createVoiceAreas } from './areaActions.js';
import { findImagery } from './imageryActions.js';
import { osmQuery } from './osmActions.js';
import { createOsmFeatureSource } from '../sources/osmFeatures.js';
import {
OSM_PLACES_CREDIT,
registerDynamicCredit,
} from '../data/dataCredits.js';
const ALLOWED_STYLES = new Set([
'normal',
@@ -328,6 +336,8 @@ export function createGevActionRunner({
readVoicePanelOperation = null,
analystMemory = null,
layerEnabledAt = null,
osmSearch = null,
areaOptions = null,
}) {
// Voice enable times and analyst follow-up memory belong to this runner.
// Speech builders turn results into say/display envelopes; callers extend
@@ -341,13 +351,25 @@ export function createGevActionRunner({
// runner keeps them.
const _layerEnabledAt = layerEnabledAt ?? new Map();
let analystEngine;
const resolveRegionRing = (name, signal) =>
annotationResolver.resolveRegionRingForQuery(name, signal, placeSearch);
// Area handles live for this runner (the page): resolve_area, the
// analyst's region/area/drawn scopes, find_imagery and osm_query all read
// the same store.
const voiceAreas = createVoiceAreas({
viewer,
annotations,
placeSearch,
annotationResolver,
...(areaOptions || {}),
});
const searchOsmFeatures = osmSearch || createOsmFeatureSource();
const resolveRegionRing = (name, options) =>
voiceAreas.resolveRegion(name, options);
const ensureAnalystEngine = () =>
(analystEngine ||= createAnalystEngine(
analystProviders(engine, dataManager, {
placeSearch,
resolveRegionRing,
resolveAreaScope: voiceAreas.resolveAreaScope,
isWarming: (layerKey) => layerIsWarming(_layerEnabledAt, layerKey),
}),
{ memory: analystMemory },
@@ -1283,6 +1305,65 @@ export function createGevActionRunner({
return nextIssPass(engine, dataManager, args);
}
if (name === 'resolve_area') {
return voiceAreas.resolveAreaAction(args, {
signal: runOptions.signal,
isCurrent: current,
progress: reportProgress,
});
}
if (name === 'find_imagery') {
return findImagery(
{
dataManager,
viewer,
getArea: (areaId) => voiceAreas.store.get(areaId),
enableLayer: (enabled) =>
runGevAction(
'set_layer_visibility',
{ layerId: 'recent-imagery', enabled },
runOptions,
),
progress: reportProgress,
},
args,
{ isCurrent: current, signal: runOptions.signal },
);
}
if (name === 'osm_query') {
return osmQuery(
{
dataManager,
getArea: (areaId) => voiceAreas.store.get(areaId),
viewBox: () => cameraViewBox(engine),
enableLayer: (enabled) =>
runGevAction(
'set_layer_visibility',
{ layerId: 'osm-places', enabled },
runOptions,
),
search: searchOsmFeatures,
onCredit: () => registerDynamicCredit(viewer, OSM_PLACES_CREDIT),
// The listed places become the analyst's "last answer", so
// "which of those…" filters them and never an older set.
rememberResults: (rows, presentation, { truncated = false } = {}) => {
if (!current()) return;
if (rows)
ensureAnalystEngine().remember('osm-places', rows, {
presentation,
truncated,
});
else analystEngine?.reset();
},
progress: reportProgress,
},
args,
{ isCurrent: current, signal: runOptions.signal },
);
}
if (name === 'analyst_query') {
// Layers this engine's catalog left out cannot be asked: say so rather
// than answer zero.
@@ -1495,10 +1576,31 @@ export function createGevActionRunner({
throw new Error(`Unknown GEV tool: ${name}`);
};
// Lifetimes: the runner lives for the page; conversation state — the
// Lifetimes: the runner lives for the page (area handles included, so an
// outline stays countable across mic sessions); conversation state — the
// analyst's follow-up memory and any write still in flight — lives for one
// voice session and is dropped by resetConversation().
let conversation = 0;
// Calls emitted by one assistant response are siblings rather than newer
// user intent. The new spatial actions share mutable surfaces (area board,
// imagery panel, OSM layer/follow-up memory), so serialize those siblings in
// event order just as analyst_query already was. A genuinely newer group or
// direct call still invalidates the older attempt.
const serializedSiblingActions = new Set([
'analyst_query',
'resolve_area',
'find_imagery',
'osm_query',
]);
let serializedAttempt = 0;
let serializedSiblingGroup = null;
let serializedSiblingTail = Promise.resolve();
// Direct/programmatic callers do not necessarily arrive through
// createVoiceSession, so the runner must own the conversation lifetime of
// its serialized spatial workflows as well. Reset/dispose abort the real
// provider/catalog work, not just the eventual commit, while area handles
// remain owned by voiceAreas for the page lifetime.
let conversationAbort = new AbortController();
let disposed = false;
async function runVoiceAction(name, rawArgs = {}, callerOptions = {}) {
if (disposed)
@@ -1509,70 +1611,128 @@ export function createGevActionRunner({
error: 'Voice ended.',
};
const epoch = conversation;
let attempt = null;
let releaseSerializedSibling = null;
if (serializedSiblingActions.has(name)) {
const siblingGroup = callerOptions.authorityGroup || null;
if (siblingGroup) {
if (siblingGroup !== serializedSiblingGroup) {
serializedSiblingGroup = siblingGroup;
serializedSiblingTail = Promise.resolve();
serializedAttempt++;
}
attempt = serializedAttempt;
const predecessor = serializedSiblingTail;
const completion = new Promise((resolve) => {
releaseSerializedSibling = resolve;
});
serializedSiblingTail = predecessor.then(() => completion);
await predecessor;
} else {
serializedSiblingGroup = null;
serializedSiblingTail = Promise.resolve();
attempt = ++serializedAttempt;
}
}
const runnerSignal = serializedSiblingActions.has(name)
? conversationAbort.signal
: null;
const signal = runnerSignal
? callerOptions.signal
? AbortSignal.any([runnerSignal, callerOptions.signal])
: runnerSignal
: callerOptions.signal;
const runOptions = {
...callerOptions,
...(signal ? { signal } : {}),
isCurrent: () =>
!signal?.aborted &&
epoch === conversation &&
(attempt === null || attempt === serializedAttempt) &&
!disposed &&
(typeof callerOptions.isCurrent !== 'function' ||
callerOptions.isCurrent()),
};
const input = rawArgs && typeof rawArgs === 'object' ? rawArgs : {};
// Point-and-ask: 'pointer' and referent:n become real targets here, from
// the turn's pointer snapshot and the latest numbered result.
const deictic = resolveDeicticArgs(name, input, {
pointer: deixis?.pointer?.activeSnapshot?.() || null,
referents: deixis?.referents || null,
imageFrame: deixis?.imageFrame?.() || null,
cameraKey: deixis?.cameraKey?.() || null,
});
if (deictic.error) {
return attachVoiceResult(
name,
{ ok: false, action: name, error: deictic.error },
input,
builders,
);
}
const referentGeneration = deixis?.referents?.generation?.();
let result = await runGevAction(name, deictic.args, runOptions);
if (deictic.used && result && typeof result === 'object')
result = { ...result, resolvedFrom: deictic.used };
if (Object.hasOwn(UNAVAILABLE_FEATURES, name))
result = { engine: engine?.kind ?? null, ...result };
const out = attachVoiceResult(name, result, deictic.args, builders);
// Only an accepted, still-current result may become "the last list": a
// cancelled turn or one finishing after the session ended must not
// repopulate a cleared registry.
const stillCurrent =
!runOptions.signal?.aborted &&
(typeof runOptions.isCurrent !== 'function' || runOptions.isCurrent());
if (stillCurrent)
deixis?.referents?.recordResult?.(name, out, {
since: referentGeneration,
try {
const input = rawArgs && typeof rawArgs === 'object' ? rawArgs : {};
if (attempt !== null && !runOptions.isCurrent()) {
return attachVoiceResult(
name,
{
ok: false,
action: name,
code: 'CANCELLED',
cancelled: true,
error: 'This request was superseded.',
},
input,
builders,
);
}
// Point-and-ask: 'pointer' and referent:n become real targets here, from
// the turn's pointer snapshot and the latest numbered result.
const deictic = resolveDeicticArgs(name, input, {
pointer: deixis?.pointer?.activeSnapshot?.() || null,
referents: deixis?.referents || null,
imageFrame: deixis?.imageFrame?.() || null,
cameraKey: deixis?.cameraKey?.() || null,
});
if (stillCurrent && deictic.used?.source === 'pointer')
deixis?.onPointerUsed?.();
return out;
if (deictic.error) {
return attachVoiceResult(
name,
{ ok: false, action: name, error: deictic.error },
input,
builders,
);
}
const referentGeneration = deixis?.referents?.generation?.();
let result = await runGevAction(name, deictic.args, runOptions);
if (deictic.used && result && typeof result === 'object')
result = { ...result, resolvedFrom: deictic.used };
if (Object.hasOwn(UNAVAILABLE_FEATURES, name))
result = { engine: engine?.kind ?? null, ...result };
const out = attachVoiceResult(name, result, deictic.args, builders);
// Only an accepted, still-current result may become "the last list": a
// cancelled turn or one finishing after the session ended must not
// repopulate a cleared registry.
const stillCurrent =
!runOptions.signal?.aborted &&
(typeof runOptions.isCurrent !== 'function' || runOptions.isCurrent());
if (stillCurrent)
deixis?.referents?.recordResult?.(name, out, {
since: referentGeneration,
});
if (stillCurrent && deictic.used?.source === 'pointer')
deixis?.onPointerUsed?.();
return out;
} finally {
releaseSerializedSibling?.();
}
}
/**
* A voice session ended: invalidate every write still in flight, then
* forget the analyst's "last answer".
* forget the analyst's "last answer". Area handles stay (page lifetime).
*/
runVoiceAction.resetConversation = () => {
function endConversation({ keepMemory = false } = {}) {
conversationAbort.abort();
conversationAbort = new AbortController();
conversation++;
analystEngine?.reset();
};
serializedAttempt++;
serializedSiblingGroup = null;
serializedSiblingTail = Promise.resolve();
if (!keepMemory) analystEngine?.reset();
}
runVoiceAction.resetConversation = () => endConversation();
/**
* Voice was removed, or this runner's globe left (`keepMemory`: a host
* that shares the analyst's memory with the next runner keeps the last
* answer): nothing may run or write again.
* answer): work in flight is aborted and nothing may run or write again.
*/
runVoiceAction.dispose = ({ keepMemory = false } = {}) => {
if (disposed) return;
conversation++;
if (!keepMemory) analystEngine?.reset();
endConversation({ keepMemory });
disposed = true;
voiceAreas.dispose();
};
return runVoiceAction;
}
@@ -4026,8 +4186,14 @@ async function aircraftProximityWindowForQuery(
layerKeys: wanted,
coverage,
unanswered: [...(result?.unanswered || [])],
scopeLabel: answer.scopeLabel,
scopeDetail: answer.display.scope,
presentation: {
scopeLabel: answer.scopeLabel,
display: answer.display,
coverageScope: coverage.scope,
coverageNote: coverage.note,
centeredOn: answer.window.centeredOn,
window: answer.window,
},
},
};
}
@@ -4895,6 +5061,7 @@ function analystProviders(
placeSearch,
),
isWarming = () => false,
resolveAreaScope = null,
} = {},
) {
// Per-layer truncation seen by the last getRecords call.
@@ -4949,6 +5116,7 @@ function analystProviders(
return note ? note.trim() : null;
},
resolveRegionRing,
...(resolveAreaScope ? { resolveAreaScope } : {}),
/**
* The active Contacts subject, when there is one — the centre the operator
* is reasoning about while Contacts is up. Null whenever Contacts is off,
@@ -4984,6 +5152,15 @@ function analystProviders(
};
}
/** The camera's view rectangle as [west, south, east, north] degrees, or null. */
function cameraViewBox(engine) {
const rect = engine?.camera?.viewRectangle?.();
if (!rect) return null;
return [rect.west, rect.south, rect.east, rect.north].map((radians) =>
geo.math.toDegrees(radians),
);
}
/** Identity fields every compact analyst item keeps when present. */
const ANALYST_IDENTITY_FIELDS = Object.freeze([
'icao24',
@@ -5043,6 +5220,9 @@ const ANALYST_REFUSAL_FIELDS = Object.freeze([
'layers',
'layerStatus',
'cancelled',
'needsClarification',
'candidates',
'query',
]);
const VIEWPORT_COVERAGE_NOTE = 'the flights layer loads by viewport';
@@ -5091,7 +5271,7 @@ async function runAnalystQuery(
args = {},
_layerEnabledAt,
isCurrent = () => true,
signal = undefined,
signal = null,
) {
let entityWindow = null;
const result = await analystEngine.query(
@@ -5105,8 +5285,8 @@ async function runAnalystQuery(
followUp: Boolean(args.followUp),
},
{
isCurrent,
signal,
isCurrent,
beforeCommit: async (candidate) => {
const projected = await aircraftProximityWindowForQuery(
dataManager,
@@ -5135,8 +5315,8 @@ async function runAnalystQuery(
code: result.code || null,
error: result.error,
};
// The engine's semantic fields pass through unchanged: a cancellation
// stays a cancellation.
// The engine's semantic fields pass through unchanged: a clarification
// keeps its candidates, a cancellation stays a cancellation.
for (const key of ANALYST_REFUSAL_FIELDS)
if (result[key] !== undefined) refusal[key] = result[key];
if (result.coverage) refusal.coverage = result.coverage;
@@ -5209,7 +5389,9 @@ async function runAnalystQuery(
...(result.partial
? { partial: true, unanswered: result.unanswered || [] }
: {}),
...(result.areaId ? { areaId: result.areaId } : {}),
...(result.centeredOn ? { centeredOn: result.centeredOn } : {}),
...(result.window ? { window: result.window } : {}),
// Every count names its scope in words; a bare number is what made two
// honest answers look like a contradiction.
scopeLabel: result.scopeLabel,