mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(voice): add reusable geometry actions
- turn named places and mapped landmarks into reusable bounded areas - count loaded records inside resolved, drawn and annotated geometry - find recent imagery for an area, the view or the pointer snapshot - keep osm place search behind an operator-configured overpass endpoint - preserve cancellation, ownership and follow-up memory across every action - cover geometry, provider lifecycle, cache isolation and voice routing
This commit is contained in:
1 parent
01979bba1e
commit
b234d7b427
84 files changed
+14262
-1681
No files matched your search
@@ -3,6 +3,9 @@ import assert from 'node:assert/strict';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { GEV_ACTION_SCHEMAS, createActionTools } from './actionSchemas.js';
|
||||
import { GEV_REALTIME_TOOLS } from '../../server/providers/openai/tools.js';
|
||||
import { createAreaStore } from '../data/areaStore.js';
|
||||
import { createAreaResolver } from '../data/areaResolver.js';
|
||||
import { findAdminCandidates } from '../data/adminBoundaries.js';
|
||||
import { validateArgs } from '../../scripts/voice-bench/grade.mjs';
|
||||
|
||||
const stable = (value) =>
|
||||
@@ -29,9 +32,11 @@ test('the complete Realtime tool payload pins the manifest-generated layer relea
|
||||
assert.equal(
|
||||
digest,
|
||||
// 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).
|
||||
'a824c2ed0ceb553eb3041350856db05dbfc5abad8a3fa17d29dc378bf7a732d2',
|
||||
// aliases), point-and-ask (pointer sentinels, referent args), the
|
||||
// consolidated tool wording (each policy stated once), then voice
|
||||
// geometry (resolve_area, find_imagery, osm_query, analyst area scopes
|
||||
// and the osm-places layer).
|
||||
'8051e024669a055601d7b8020aa185bb67101bfd1b5a7fc73cc4ab09046ec20d',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -61,6 +66,37 @@ test('descriptions customize wording without changing immutable shared arguments
|
||||
);
|
||||
});
|
||||
|
||||
test('every emitted area candidate round-trips through the production schema', async () => {
|
||||
const candidateSchema = GEV_ACTION_SCHEMAS.find(
|
||||
(tool) => tool.name === 'resolve_area',
|
||||
).parameters.properties.candidateId;
|
||||
const resolver = createAreaResolver({
|
||||
store: createAreaStore(),
|
||||
findAdminCandidates,
|
||||
});
|
||||
const ambiguous = await resolver.resolve({ query: 'Georgia' });
|
||||
assert.equal(ambiguous.needsClarification, true);
|
||||
for (const choice of ambiguous.candidates) {
|
||||
assert.ok(choice.candidateId.length >= candidateSchema.minLength);
|
||||
assert.ok(choice.candidateId.length <= candidateSchema.maxLength);
|
||||
assert.match(choice.candidateId, new RegExp(candidateSchema.pattern, 'u'));
|
||||
assert.equal(
|
||||
(await resolver.resolve({ candidateId: choice.candidateId })).ok,
|
||||
true,
|
||||
);
|
||||
}
|
||||
assert.equal(ambiguous.candidates[0].candidateId.length, 41);
|
||||
const grammar = new RegExp(candidateSchema.pattern, 'u');
|
||||
for (const malformed of [
|
||||
'ne:state:bad slug',
|
||||
'ne:state:../../etc',
|
||||
'ne:state:!!!',
|
||||
'ne:state:a_b',
|
||||
])
|
||||
assert.doesNotMatch(malformed, grammar);
|
||||
assert.ok(`ne:state:${'x'.repeat(80)}`.length > candidateSchema.maxLength);
|
||||
});
|
||||
|
||||
test('metadata cannot add tools, fields, types or enum values', () => {
|
||||
for (const descriptions of [
|
||||
{ execute_shell: { description: 'not an action' } },
|
||||
@@ -89,7 +125,14 @@ test('metadata cannot add tools, fields, types or enum values', () => {
|
||||
|
||||
test('all legacy action arguments are byte-identical after removing the deliberate additions', () => {
|
||||
const legacy = structuredClone(GEV_ACTION_SCHEMAS).filter(
|
||||
(tool) => !['next_satellite_pass', 'set_cyber_sonar'].includes(tool.name),
|
||||
(tool) =>
|
||||
![
|
||||
'next_satellite_pass',
|
||||
'set_cyber_sonar',
|
||||
'resolve_area',
|
||||
'find_imagery',
|
||||
'osm_query',
|
||||
].includes(tool.name),
|
||||
);
|
||||
// Layer enums are generated from the voice layer manifest and pinned by
|
||||
// layerManifest.test.mjs; the two shipped right-rail panels are additive.
|
||||
@@ -121,6 +164,13 @@ test('all legacy action arguments are byte-identical after removing the delibera
|
||||
analystScopeKind.enum = analystScopeKind.enum.filter(
|
||||
(key) => key !== 'pointer',
|
||||
);
|
||||
// Area handles add three scope kinds and their two identifiers.
|
||||
const scope = property('analyst_query').scope;
|
||||
scope.properties.kind.enum = scope.properties.kind.enum.filter(
|
||||
(kind) => !['area', 'drawn', 'annotation'].includes(kind),
|
||||
);
|
||||
delete scope.properties.areaId;
|
||||
delete scope.properties.id;
|
||||
// The analyst centre now requires a real coordinate.
|
||||
const center = property('analyst_query').scope.properties.center;
|
||||
delete center.required;
|
||||
|
||||
Reference in new issue
Block a user