mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(voice): voice core — honest layer reach, spoken summary with on-screen card, narration, point-and-ask
- Voice layer manifest (src/voice/layerManifest.js) generates the layer enums, aliases and analyst field hints; a test fails when a catalog layer has no entry. - analyst_query validates fields, operators, units, values and scopes, counts up to 250,000 loaded records per layer, reports complete/partial/unanswered, tells LAYER_OFF / NOT_READY / FEED_UNAVAILABLE apart from zero, refuses mismatched follow-ups and never lets a superseded query replace follow-up memory. Seven more layers expose analyst records. - Tool results carry a code-built say line and a display card; the voice card in the mic control shows captions, plan steps and the result (src/voice/resultDisplay.js is the one adapter). Slow tools narrate their current step out of band; holding Space while the assistant talks cuts it off. Turn spans go to the debug log; caption transcription is metered; the log omits what was said unless GEV_VOICE_LOG_CONTENT=1. - Point and ask: the Space-down pointer snapshot resolves "this", "that one" and "around here" through 'pointer' targets, and "the second one" through referent:n from the last numbered list. - Prompt states each policy once (instructions + tools 48.5k -> 46.7k chars). - Voice benchmark harness (scripts/qa-voice-bench.mjs, scripts/voice-bench/) shares its phrase table and grading with scripts/qa-voice-routing.mjs.
This commit is contained in:
1 parent
e7707d9a0f
commit
a19897ad15
97 files changed
+14343
-755
No files matched your search
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* Referents: the numbered things the latest voice result listed, so "the
|
||||
* second one" or "that one" can resolve without the model copying ids.
|
||||
*
|
||||
* The registry mirrors what the voice card shows: a result replaces the list
|
||||
* when the card displays it with numbered rows (see resultDisplay.js, which
|
||||
* both the card and this registry read — analyst items included, in the
|
||||
* order the model reads them in the tool output).
|
||||
*
|
||||
* Session-scoped: the voice commands clear it when a session ends.
|
||||
*/
|
||||
|
||||
import { presentResult } from './resultDisplay.js';
|
||||
|
||||
const MAX_REFERENTS = 12;
|
||||
|
||||
function finite(value) {
|
||||
if (value === null || value === undefined || value === '') return null;
|
||||
const number = Number(value);
|
||||
return Number.isFinite(number) ? number : null;
|
||||
}
|
||||
|
||||
function normalize(entry, index) {
|
||||
if (!entry || typeof entry !== 'object') return null;
|
||||
// Identity is the canonical key (transponder hex, MMSI, NORAD id); a
|
||||
// display `id` such as a callsign is only a label, and two contacts can
|
||||
// share one.
|
||||
const id = entry.icao24 ?? entry.mmsi ?? entry.noradId ?? entry.id ?? null;
|
||||
const label = String(
|
||||
entry.label ?? entry.callsign ?? entry.name ?? entry.id ?? id ?? '',
|
||||
).trim();
|
||||
if (!label && id === null) return null;
|
||||
return {
|
||||
n: index + 1,
|
||||
id: id === null ? null : String(id),
|
||||
label: label || String(id),
|
||||
layerId: entry.layerId ?? entry.layerKey ?? null,
|
||||
lat: finite(entry.lat ?? entry.latitude),
|
||||
lon: finite(entry.lon ?? entry.longitude),
|
||||
};
|
||||
}
|
||||
|
||||
/** Referents a tool result offers, in card order; [] when it offers none. */
|
||||
export function referentsFromResult(name, result) {
|
||||
if (!result || typeof result !== 'object' || result.ok === false) return [];
|
||||
return presentResult(name, result)?.referents || [];
|
||||
}
|
||||
|
||||
/** Numbered referent records ({n, id, label, layerId, lat, lon}). */
|
||||
export function normalizeReferents(entries, max = MAX_REFERENTS) {
|
||||
return (Array.isArray(entries) ? entries : [])
|
||||
.slice(0, max)
|
||||
.map(normalize)
|
||||
.filter(Boolean)
|
||||
.map((entry, index) => ({ ...entry, n: index + 1 }));
|
||||
}
|
||||
|
||||
export function createReferentRegistry({ max = MAX_REFERENTS } = {}) {
|
||||
let list = [];
|
||||
let generation = 0;
|
||||
return {
|
||||
/** Bumped by every clear; read before an action, checked after it. */
|
||||
generation() {
|
||||
return generation;
|
||||
},
|
||||
/**
|
||||
* Replace the list with a result's referents; empty results keep it
|
||||
* unless they are a result set of their own. A
|
||||
* result whose action started before the last clear (a new session or a
|
||||
* cancelled turn) is refused.
|
||||
*/
|
||||
recordResult(name, result, { since = generation } = {}) {
|
||||
if (since !== generation) return false;
|
||||
if (!result || typeof result !== 'object' || result.ok === false)
|
||||
return false;
|
||||
const shown = presentResult(name, result);
|
||||
const entries = shown?.referents || [];
|
||||
// A new result set (a count) replaces the list even
|
||||
// when it is empty: "the second one" never reaches an older answer.
|
||||
if (!entries.length && !shown?.resultSet) return false;
|
||||
list = normalizeReferents(entries, max);
|
||||
return list.length > 0;
|
||||
},
|
||||
/** 1-based lookup; negative counts from the end ("the last one" = -1). */
|
||||
get(n) {
|
||||
const index = Number(n);
|
||||
if (!Number.isInteger(index) || index === 0) return null;
|
||||
return (index > 0 ? list[index - 1] : list[list.length + index]) || null;
|
||||
},
|
||||
list() {
|
||||
return list.slice();
|
||||
},
|
||||
clear() {
|
||||
list = [];
|
||||
generation++;
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user