mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-22 19:22:18 +00:00
Add the opt-in Cyber HUD layout with coordinated map and cockpit panel styling, GPU-only contact sonar (rings, range, power, opacity, sector) with native-rendering fallback, and set_cyber_sonar voice controls. Sonar visual style inspired by kk376's tactical naval sonar (#214). Co-authored-by: Sameh Khamis <[email protected]> Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
124 lines
4.3 KiB
JavaScript
124 lines
4.3 KiB
JavaScript
import test from 'node:test';
|
|
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';
|
|
|
|
const stable = (value) =>
|
|
Array.isArray(value)
|
|
? value.map(stable)
|
|
: value && typeof value === 'object'
|
|
? Object.fromEntries(
|
|
Object.entries(value)
|
|
.sort(([a], [b]) => a.localeCompare(b))
|
|
.map(([key, child]) => [key, stable(child)]),
|
|
)
|
|
: value;
|
|
|
|
test('the complete Realtime tool payload pins the additive analyst, satellite, Local ADS-B and Cyber release', () => {
|
|
const digest = createHash('sha256')
|
|
.update(
|
|
JSON.stringify(
|
|
stable(
|
|
GEV_REALTIME_TOOLS.filter((tool) => tool.name !== 'set_cyber_sonar'),
|
|
),
|
|
),
|
|
)
|
|
.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',
|
|
);
|
|
});
|
|
|
|
test('descriptions customize wording without changing immutable shared arguments', () => {
|
|
const descriptions = {
|
|
fly_to_location: {
|
|
description: 'Navigate',
|
|
parameters: { properties: { query: { description: 'A place' } } },
|
|
},
|
|
};
|
|
const tools = createActionTools(descriptions);
|
|
const tool = tools.find((tool) => tool.name === 'fly_to_location');
|
|
assert.equal(tool.description, 'Navigate');
|
|
assert.equal(tool.parameters.properties.query.description, 'A place');
|
|
assert.equal(tool.parameters.properties.query.type, 'string');
|
|
tool.parameters.properties.query.type = 'number';
|
|
assert.equal(
|
|
createActionTools()[0].parameters.properties.query.type,
|
|
'string',
|
|
);
|
|
assert.throws(() => {
|
|
GEV_ACTION_SCHEMAS[0].parameters.properties.query.type = 'number';
|
|
}, TypeError);
|
|
assert.equal(
|
|
JSON.stringify(GEV_ACTION_SCHEMAS).includes('"description"'),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test('metadata cannot add tools, fields, types or enum values', () => {
|
|
for (const descriptions of [
|
|
{ execute_shell: { description: 'not an action' } },
|
|
{
|
|
fly_to_location: {
|
|
parameters: { properties: { description: 'new field' } },
|
|
},
|
|
},
|
|
{ fly_to_location: { $position: -1, description: 'invalid position' } },
|
|
{ fly_to_location: { name: 'other' } },
|
|
{
|
|
fly_to_location: {
|
|
parameters: { properties: { arbitrary: { description: 'new field' } } },
|
|
},
|
|
},
|
|
{
|
|
fly_to_location: {
|
|
parameters: { properties: { query: { type: 'number' } } },
|
|
},
|
|
},
|
|
{ fly_to_location: { parameters: { required: { 0: 'another' } } } },
|
|
{ fly_to_location: { description: { nested: 'invalid' } } },
|
|
])
|
|
assert.throws(() => createActionTools(descriptions), TypeError);
|
|
});
|
|
|
|
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),
|
|
);
|
|
const layers = legacy.find((tool) => tool.name === 'analyst_query').parameters
|
|
.properties.layers.items;
|
|
layers.enum = layers.enum.filter(
|
|
(key) =>
|
|
![
|
|
'satellites',
|
|
'local-datacenters',
|
|
'local-dams',
|
|
'fire-perimeters',
|
|
].includes(key),
|
|
);
|
|
// Local ADS-B is an additive set_layer_visibility enum value.
|
|
const visibility = legacy.find((tool) => tool.name === 'set_layer_visibility')
|
|
.parameters.properties.layerId;
|
|
visibility.enum = visibility.enum.filter(
|
|
(key) => !['local-adsb', 'fire-perimeters'].includes(key),
|
|
);
|
|
for (const tool of legacy) {
|
|
for (const value of Object.values(tool.parameters.properties)) {
|
|
if (value.enum)
|
|
value.enum = value.enum.filter((key) => key !== 'fire-perimeters');
|
|
}
|
|
}
|
|
// Independently derived by executing trusted c9f9896 actionSchemas in the restricted container.
|
|
const hud = legacy.find((tool) => tool.name === 'set_hud').parameters
|
|
.properties.layout;
|
|
hud.enum = hud.enum.filter((layout) => layout !== 'cyber');
|
|
assert.equal(
|
|
createHash('sha256').update(JSON.stringify(legacy)).digest('hex'),
|
|
'820fff21658f6907e1010b2b79c5431a77f4e34afd2277d62d8de46c368b6f8c',
|
|
);
|
|
});
|