mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 18:34:02 +00:00
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
export const HUD_SUMMARY_UNCONFIGURED_CODE = 'OPENAI_NOT_CONFIGURED';
|
|
|
|
/**
|
|
* Describe the optional HUD summary capability without turning a deliberately
|
|
* keyless boot into an HTTP failure.
|
|
*
|
|
* @param {unknown} apiKey - Candidate server-side OpenAI credential.
|
|
* @returns {{ statusCode: 200, payload: { configured: false, code: string, error: null, summary: null } }|null}
|
|
* A graceful unconfigured response, or null when the provider is configured.
|
|
*/
|
|
export function keylessHudSummaryResponse(apiKey) {
|
|
if (String(apiKey ?? '').trim()) return null;
|
|
return {
|
|
statusCode: 200,
|
|
payload: {
|
|
configured: false,
|
|
code: HUD_SUMMARY_UNCONFIGURED_CODE,
|
|
error: null,
|
|
summary: null,
|
|
},
|
|
};
|
|
}
|
|
|
|
/** Return true only for the deliberate, successful no-key capability response. */
|
|
export function isHudSummaryUnconfigured(status, data) {
|
|
const keys =
|
|
data !== null && typeof data === 'object' && !Array.isArray(data)
|
|
? Object.keys(data)
|
|
: [];
|
|
return (
|
|
keys.length === 4 &&
|
|
status === 200 &&
|
|
data?.configured === false &&
|
|
data?.code === HUD_SUMMARY_UNCONFIGURED_CODE &&
|
|
data?.error === null &&
|
|
data?.summary === null
|
|
);
|
|
}
|