mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 08:02:12 +00:00
GET /api/insights/chat/{id}/messages/{messageId}/results returns the
tables one assistant message read, narrowed to the conversation's owner
like the conversation read, with a table withheld as module_disabled when
its domain's module is off and as unavailable when it cannot be read. A
data read: no AI capability.
The published document now describes every stream frame as the
CoachStreamEvent union, including the suggestedAction frame it never
named, the new step, result, followUps and clarification frames, their
components, the provenance fields, the followUp and clarification request
fields, and the reuse provider type.
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
/**
|
|
* Which module owns the domain a stored Coach table is about, so a table
|
|
* read after the module was switched off is withheld rather than served.
|
|
*
|
|
* The same ownership the Coach applies when it reads: the measurement-level
|
|
* table in `MODULE_SCOPED_SOURCES`, plus the cycle and illness domains,
|
|
* which the Coach gates on their own modules. Labs, medication compliance,
|
|
* correlations and the full snapshot answer to no module there, so none
|
|
* here either — gating them on this read would make a stored answer
|
|
* stricter than the Coach that wrote it.
|
|
*/
|
|
import { MODULE_SCOPED_SOURCES } from "@/lib/modules/measurement-scope";
|
|
import type { ModuleKey } from "@/lib/modules/registry";
|
|
import type { CoachStepDomain } from "@/lib/ai/coach/types";
|
|
|
|
const OWNER_BY_DOMAIN: ReadonlyMap<string, ModuleKey> = (() => {
|
|
const out = new Map<string, ModuleKey>([
|
|
["cycle", "cycle"],
|
|
["illness", "illness"],
|
|
]);
|
|
for (const [key, sources] of Object.entries(MODULE_SCOPED_SOURCES)) {
|
|
for (const source of sources ?? []) out.set(source, key as ModuleKey);
|
|
}
|
|
return out;
|
|
})();
|
|
|
|
export function moduleForCoachDomain(
|
|
domain: CoachStepDomain,
|
|
): ModuleKey | null {
|
|
return OWNER_BY_DOMAIN.get(domain) ?? null;
|
|
}
|
|
|
|
/** True when the domain's module is switched off in `modules`. */
|
|
export function isCoachDomainWithheld(
|
|
domain: CoachStepDomain,
|
|
modules: Readonly<Record<ModuleKey, boolean>>,
|
|
): boolean {
|
|
const owner = moduleForCoachDomain(domain);
|
|
return owner !== null && modules[owner] === false;
|
|
}
|