-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathverify-tinymodel-integration.ts
More file actions
53 lines (45 loc) · 1.48 KB
/
Copy pathverify-tinymodel-integration.ts
File metadata and controls
53 lines (45 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Phase 0/1 smoke: corpus chunks + optional TinyModel sidecar health.
* Run: npm run verify:tinymodel
*/
import { HSP_PROGRAM_CORPUS_CHUNKS } from "../ai/hspProgramCorpus.js";
import {
getTinyModelStatus,
inferHspRouteHint,
isTinyModelConfigured,
} from "../ai/tinymodel.js";
const MIN_CHUNKS = 8;
function fail(message: string): never {
console.error(`[verify:tinymodel] FAIL: ${message}`);
process.exit(1);
}
async function main(): Promise<void> {
const chunks = HSP_PROGRAM_CORPUS_CHUNKS.length;
console.log(`[verify:tinymodel] corpus chunks: ${chunks}`);
if (chunks < MIN_CHUNKS) {
fail(`expected at least ${MIN_CHUNKS} corpus chunks, got ${chunks}`);
}
const route = inferHspRouteHint("open swap page");
if (route !== "navigate:/swap") {
fail(`route hint expected navigate:/swap, got ${route ?? "undefined"}`);
}
if (!isTinyModelConfigured()) {
console.log(
"[verify:tinymodel] TINYMODEL_API_URL not set — corpus-only OK (start sidecar for full check)",
);
console.log("[verify:tinymodel] OK");
return;
}
const status = await getTinyModelStatus();
console.log("[verify:tinymodel] sidecar:", JSON.stringify(status));
if (!status.health_ok) {
fail(
`TinyModel health failed: ${String(status.error ?? "unknown")} (is phase3_reference_server running?)`,
);
}
console.log("[verify:tinymodel] OK");
}
main().catch((e: unknown) => {
const message = e instanceof Error ? e.message : String(e);
fail(message);
});