feat(health): complete P0 health channel — baseline engine, page-data, MindSpace UI

Deliver encrypted health zone, observation API, baseline maturity pipeline,
page-data bindings, and H5/WeChat channel integration for health P0.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-09-09 18:04:22 +08:00
parent 7bf16500a1
commit 2baf29b3ae
94 changed files with 7283 additions and 194 deletions
+100
View File
@@ -25,3 +25,103 @@ export async function saveConfirmedBloodPressure(input: {
}),
});
}
export async function extractHealthImage(input: {
imageUrl: string;
metricSet?: string | null;
}) {
return apiFetch('/health/extract-image', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
imageUrl: input.imageUrl,
metricSet: input.metricSet ?? null,
}),
});
}
export async function archiveHealthDocument(input: {
imageUrl: string;
notes?: string | null;
}) {
return apiFetch('/health/documents', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
confirmed: true,
imageUrl: input.imageUrl,
source: 'manual',
notes: input.notes ?? null,
}),
});
}
export async function saveHealthObservation(body: Record<string, unknown>) {
return apiFetch('/health/observations', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ confirmed: true, source: 'manual', ...body }),
});
}
export async function fetchHealthAssessSummary() {
const data = await apiFetch('/health/assess-summary');
return typeof data?.summary === 'string' ? data.summary : '';
}
export async function fetchHealthTimeline(days = 30) {
const data = await apiFetch(`/health/timeline?days=${days}`);
return Array.isArray(data?.timeline) ? data.timeline : [];
}
export async function fetchHealthDocuments(limit = 50) {
const data = await apiFetch(`/health/documents?limit=${limit}`);
return Array.isArray(data?.documents) ? data.documents : [];
}
export async function fetchHealthAgentContext() {
const data = await apiFetch('/health/agent-context');
return typeof data?.context === 'string' ? data.context : '';
}
export async function createHealthReportPage() {
const data = await apiFetch('/health/report-page', { method: 'POST' });
return {
relativePath: typeof data?.relativePath === 'string' ? data.relativePath : '',
url: typeof data?.url === 'string' ? data.url : '',
summary: typeof data?.summary === 'string' ? data.summary : '',
size: typeof data?.size === 'number' ? data.size : 0,
};
}
export async function bootstrapHealthWorkspace() {
return apiFetch('/health/workspace/bootstrap', { method: 'POST' });
}
export async function commitHealthDraft(draftKey: string, source = 'photo') {
return apiFetch(`/health/drafts/${encodeURIComponent(draftKey)}/commit`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ source }),
});
}
export type HealthUnreadAlert = {
id: number;
severity: 'info' | 'watch' | 'alert' | string;
message?: string;
agentSummary?: string;
eventType?: string;
ruleId?: string | null;
metricType?: string | null;
detectedAt?: number;
};
export async function fetchHealthUnreadAlerts(limit = 20): Promise<HealthUnreadAlert[]> {
const data = await apiFetch(`/health/alerts/unread?limit=${limit}`);
return Array.isArray(data?.alerts) ? data.alerts : [];
}
export async function acknowledgeAllHealthAlerts() {
return apiFetch('/health/alerts/acknowledge-all', { method: 'POST' });
}