mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 07:42:23 +00:00
Merge branch 'main' into upstream/route-outage-unavailable
This commit is contained in:
424 files changed
+25336
-981
No files matched your search
@@ -1,7 +1,12 @@
|
||||
/** Composite queries that combine other tools' answers for one area. */
|
||||
|
||||
import { suggestView } from '../views.js';
|
||||
import { feedProvenanceEnvelope } from '../../data/layerSnapshot.js';
|
||||
import {
|
||||
feedProvenanceEnvelope,
|
||||
hudSummaryMatchesProvenance,
|
||||
provenanceLine,
|
||||
provenanceTag,
|
||||
} from '../../data/layerSnapshot.js';
|
||||
import { defineTool, ToolError } from '../catalog.js';
|
||||
import {
|
||||
AREA_SCHEMA,
|
||||
@@ -232,6 +237,7 @@ export const getHudCaption = defineTool({
|
||||
feedState: sectionFeedState(brief[key]),
|
||||
}),
|
||||
);
|
||||
const feedProvenance = feedProvenanceEnvelope(layers);
|
||||
const response = await context.services.summary.summarize(
|
||||
{
|
||||
placeLabels: [area.label],
|
||||
@@ -244,16 +250,28 @@ export const getHudCaption = defineTool({
|
||||
name,
|
||||
feedState,
|
||||
})),
|
||||
feedProvenance: feedProvenanceEnvelope(layers),
|
||||
feedProvenance,
|
||||
},
|
||||
{ signal: context.signal },
|
||||
);
|
||||
const caption = response?.data?.summary;
|
||||
if (!response?.ok || typeof caption !== 'string' || !caption)
|
||||
const words = response?.data?.summary;
|
||||
if (!response?.ok || typeof words !== 'string' || !words)
|
||||
throw new ToolError('unavailable', 'The caption service did not answer');
|
||||
// As on the HUD: the app's own state leads and its layers trail, and a
|
||||
// reply that names another state than the app's keeps only the place.
|
||||
const caption = provenanceLine(
|
||||
hudSummaryMatchesProvenance(response.data, feedProvenance)
|
||||
? words
|
||||
: area.label,
|
||||
provenanceTag(feedProvenance),
|
||||
);
|
||||
return {
|
||||
summary: caption,
|
||||
data: { area: area.label, caption },
|
||||
data: {
|
||||
area: area.label,
|
||||
caption,
|
||||
feedState: feedProvenance.overall,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { composeCatalog, coreTools } from '../index.js';
|
||||
|
||||
// get_hud_caption shows the app's own feed state, not the model's words.
|
||||
async function staleCaption(reply) {
|
||||
const conditions = {
|
||||
observedAt: '2026-10-01T19:15:00.000Z',
|
||||
temperatureC: 26.3,
|
||||
apparentTemperatureC: 32,
|
||||
precipitationMm: 0,
|
||||
cloudCoverPct: 100,
|
||||
windKph: 5.4,
|
||||
windDirectionDeg: 318,
|
||||
visibilityM: 15400,
|
||||
weatherCode: 3,
|
||||
};
|
||||
const places = {
|
||||
resolve: async (name) =>
|
||||
name === 'Austin'
|
||||
? {
|
||||
name: 'Austin, Texas',
|
||||
bounds: { west: -97.94, south: 30.1, east: -97.56, north: 30.52 },
|
||||
}
|
||||
: null,
|
||||
};
|
||||
const staleWeather = {
|
||||
getConditions: async () => ({ status: 'stale', weather: conditions }),
|
||||
};
|
||||
let sent = null;
|
||||
const summary = {
|
||||
async summarize(context) {
|
||||
sent = context;
|
||||
return { ok: true, status: 200, data: { error: null, ...reply } };
|
||||
},
|
||||
};
|
||||
const catalog = composeCatalog({
|
||||
tools: coreTools,
|
||||
services: { weather: staleWeather, summary, places },
|
||||
});
|
||||
const result = await catalog.call('get_hud_caption', {
|
||||
area: { place: 'Austin' },
|
||||
});
|
||||
assert.equal(sent.feedProvenance.overall, 'stale');
|
||||
return result.data;
|
||||
}
|
||||
|
||||
test('get_hud_caption keeps the canonical feed state of a stale view', async () => {
|
||||
const data = await staleCaption({
|
||||
summary: 'Austin weather across the area',
|
||||
feedState: 'stale',
|
||||
});
|
||||
assert.equal(data.feedState, 'stale');
|
||||
assert.equal(
|
||||
data.caption,
|
||||
'STALE | Austin weather across the area | WEATHER',
|
||||
);
|
||||
});
|
||||
|
||||
test('get_hud_caption drops words whose feed state is not the app one', async () => {
|
||||
const data = await staleCaption({
|
||||
summary: 'Austin live weather looks fine',
|
||||
feedState: 'nominal',
|
||||
});
|
||||
assert.equal(data.feedState, 'stale');
|
||||
assert.equal(data.caption, 'STALE | Austin, Texas | WEATHER');
|
||||
});
|
||||
Reference in new issue
Block a user