mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 07:38:43 +01:00
* chore: add a formatter, matching the style this repo already writes singleQuote=false was chosen by counting this repo's own imports, not by fleet decree. The fleet is genuinely split and the two repos that already had a .prettierrc disagreed with each other, so there was no standard to restore. Quote style does not cross repo boundaries; having a gate does. Markdown is ignored for now — prettier rewraps prose, which would bury the real diff. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * style: format with prettier (1062 files) Mechanical. No behaviour change. This SHA is listed in .git-blame-ignore-revs so `git blame` skips it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore: teach git blame to skip the reformat Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(lint): reattach two guards the reformat detached Both effects were one-liners, so a trailing eslint-disable-line covered the setState call: useEffect(() => { setSelected(new Set()); }, [q.length]); // eslint-disable-line ... prettier expanded the block. The comment stayed on the closing line while the call moved above it, so the guard protected nothing and the rule its author had deliberately silenced failed the build. This is the second shape of the same defect — hirnli had the eslint-disable-NEXT-line variant. Both come from the same fact: an eslint directive binds to a line number, so reformatting can silently unbind it, which makes 'mechanical, no behaviour change' false for any bulk reformat. * chore(desktop): bump the runner version the reformat requires desktop-release-drift enforces that anything built into Fleet Runner which differs from the last released tag must carry a version ahead of that tag — main read 0.8.15 and fleet-runner-v0.8.15 already shipped. A whole-repo reformat changes bytes under desktop/, so the gate fires. The alternative was adding desktop/ to .prettierignore, which would buy a quiet PR by carving a permanent hole in the formatter's coverage — the precise shape of silent drift this test was written to catch. Bumping is what the rule asks for and costs one patch release whose only content is whitespace. * chore: merge main and re-format A whole-repo reformat conflicts with any concurrent commit, and a conflicting PR runs no checks at all while reporting nothing. Conflicts resolved to main, which is correct because this branch changes formatting and nothing else. * chore: leave desktop/ out of this reformat desktop-release-drift is right to refuse this. Everything under desktop/ is built into Fleet Runner, so changing it means shipping: bump the version AND add a FLEET_RUNNER_RELEASES entry, whose stated audience is 'person who installed Fleet Runner and wants to know what changed'. For a whitespace-only build the honest answer is 'nothing', so that release should not exist — and I should not write release notes claiming otherwise. I had bumped to 0.8.16 to get the gate green. That was the wrong direction: publishing a build to three OS runners to keep a formatting PR quiet. Reverted. desktop/ is excluded in .prettierignore with the reasoning recorded there, to be formatted alongside the next real runner change, where the bump and the notes are true anyway. --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
166 lines
6.6 KiB
TypeScript
166 lines
6.6 KiB
TypeScript
/**
|
|
* Live model probe — is every model this app depends on actually alive?
|
|
*
|
|
* Run: npx tsx scripts/probe-models.ts [chat-model ...] (npm run probe:models)
|
|
* (defaults to a spread from frontier-ish down to tiny)
|
|
*
|
|
* Why this exists as a committed script rather than a one-off: Loki is meant to
|
|
* keep working as the model underneath it changes, and the thing that actually
|
|
* breaks when you swap models is not reasoning quality — it is whether the model
|
|
* emits a tool call the loop can parse. That is cheap to measure and impossible
|
|
* to guess, so measure it before switching, not after.
|
|
*
|
|
* Covers BOTH halves, because both have bitten:
|
|
* CHAT — can the model emit a tool call the loop can parse?
|
|
* VISION — does any model in the chain actually read an image?
|
|
*
|
|
* The vision half exists because a pinned free model (Groq's llama-4-scout) was
|
|
* decommissioned and every attached screenshot 404'd, silently, until someone
|
|
* tried one. That was the fourth pinned-free-model rot in this fleet, so the
|
|
* class gets a command instead of another one-off fix: run this before swapping
|
|
* a model, and on any "images stopped working" report.
|
|
*
|
|
* NOT part of `npm run verify`: it costs real tokens and needs live keys.
|
|
* The env-independent coverage of the same parser lives in
|
|
* scripts/test/agent-tool-loop.ts.
|
|
*
|
|
* Reads: does the model produce a call at all, via which protocol, with correct
|
|
* arguments. A model that scores `calls=0` cannot drive the loop; one that
|
|
* answers via `text` proves the fallback protocol is earning its place.
|
|
*/
|
|
import { config } from "dotenv";
|
|
config({ path: ".env.local" });
|
|
|
|
import { callModelLinkOnce } from "../src/lib/agent/llm";
|
|
import { analyzeImages } from "../src/lib/vision";
|
|
import { usableVisionChain } from "../src/config/vision-models";
|
|
import { usableChatChain, CHAT_CHAIN, type ChatLink } from "../src/config/chat-models";
|
|
|
|
const TOOLS = [
|
|
{
|
|
type: "function",
|
|
function: {
|
|
name: "search_people",
|
|
description: "Look up the operator's contacts by name.",
|
|
parameters: {
|
|
type: "object",
|
|
properties: { query: { type: "string" } },
|
|
required: ["query"],
|
|
},
|
|
},
|
|
},
|
|
];
|
|
|
|
// Mirrors the real system prompt's tool section — including the copyable example,
|
|
// which is the part that carries small models.
|
|
const SYSTEM = [
|
|
"You are Loki. You answer ONLY from tools; you know nothing about the operator otherwise.",
|
|
"",
|
|
"Call a tool by writing these two lines in your reply, exactly like this:",
|
|
"",
|
|
"TOOL: search_people",
|
|
'ARGS: {"query": "Elena"}',
|
|
"",
|
|
"Write nothing else in a reply that calls a tool.",
|
|
].join("\n");
|
|
|
|
/**
|
|
* Resolve what to probe. No args → the whole configured chain, which is the
|
|
* question that actually matters ("is every fallback I ship real?"). Explicit
|
|
* model ids → those, matched against the chain so they carry their provider,
|
|
* falling back to the first keyed provider for an id nobody advertises yet.
|
|
*/
|
|
function linksToProbe(): ChatLink[] {
|
|
const chain = usableChatChain();
|
|
const wanted = process.argv.slice(2);
|
|
if (wanted.length === 0) return chain;
|
|
const host = chain[0]?.provider ?? CHAT_CHAIN[0];
|
|
return wanted.map((model) => chain.find((l) => l.model === model) ?? { provider: host, model });
|
|
}
|
|
|
|
async function main() {
|
|
const links = linksToProbe();
|
|
if (links.length === 0) {
|
|
console.error(
|
|
"No chat provider configured — set GROQ_API_KEY or OPENROUTER_API_KEY in .env.local.",
|
|
);
|
|
process.exit(2);
|
|
}
|
|
let usable = 0;
|
|
|
|
console.log(`Chat chain (${links.length} link(s)) — can each one actually drive the loop?\n`);
|
|
for (const link of links) {
|
|
const label = `${link.provider.id}/${link.model}`;
|
|
try {
|
|
// callModelLinkOnce, NOT the chain walker: a walk reports whoever
|
|
// answered, which would credit this model with another link's success.
|
|
const turn = await callModelLinkOnce(link, {
|
|
messages: [
|
|
{ role: "system", content: SYSTEM },
|
|
{ role: "user", content: "Who is Ilya in my contacts?" },
|
|
],
|
|
tools: TOOLS,
|
|
validToolNames: ["search_people"],
|
|
maxTokens: 300,
|
|
});
|
|
const call = turn.toolCalls[0];
|
|
const protocol = call ? (call.id.startsWith("text_") ? "text" : "native") : "-";
|
|
const ok = call?.name === "search_people" && typeof call.args.query === "string";
|
|
if (ok) usable++;
|
|
console.log(
|
|
`${ok ? "✓" : "✗"} ${label.padEnd(48)} calls=${turn.toolCalls.length} via=${protocol.padEnd(6)} args=${JSON.stringify(call?.args ?? {})}`,
|
|
);
|
|
} catch (e) {
|
|
console.log(
|
|
`✗ ${label.padEnd(48)} ERROR ${e instanceof Error ? e.message.slice(0, 90) : String(e)}`,
|
|
);
|
|
}
|
|
}
|
|
|
|
console.log(`\n${usable}/${links.length} chat link(s) can drive the loop.`);
|
|
if (usable === 0)
|
|
console.log(" ✗ NO chat model answered — Loki's tool loop is DOWN, not degraded.");
|
|
|
|
// ── Vision chain ───────────────────────────────────────────────────────────
|
|
// A 2x2 solid-red PNG. Tiny, but it proves the model actually READ the image
|
|
// rather than merely accepting the request — a provider that returns 200 with
|
|
// empty content passes a "did it error" check and fails this one.
|
|
const RED_2X2 =
|
|
"iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFElEQVR4nGP8z8Dwn4GKgImahgEAG1kDCf0X4o8AAAAASUVORK5CYII=";
|
|
|
|
const chain = usableVisionChain();
|
|
console.log(`\nVision chain (${chain.length} usable link(s)):`);
|
|
if (chain.length === 0) {
|
|
console.log(
|
|
" ✗ none — no OPENROUTER_API_KEY and no GROQ_VISION_MODEL. Image attachments WILL fail.",
|
|
);
|
|
}
|
|
let visionOk = 0;
|
|
for (const { provider, model } of chain) {
|
|
try {
|
|
const r = await analyzeImages({
|
|
prompt: "What colour fills this image? Answer with one word.",
|
|
images: [{ mimeType: "image/png", dataBase64: RED_2X2 }],
|
|
maxTokens: 30,
|
|
timeoutMs: 90_000,
|
|
});
|
|
// analyzeImages walks the whole chain itself, so this reports the link
|
|
// that actually answered rather than the one we asked about.
|
|
console.log(` ✓ ${provider.id}/${model} → answered via ${r.model}: ${r.text.slice(0, 40)}`);
|
|
visionOk++;
|
|
break;
|
|
} catch (e) {
|
|
console.log(
|
|
` ✗ ${provider.id}/${model} — ${e instanceof Error ? e.message.slice(0, 90) : e}`,
|
|
);
|
|
}
|
|
}
|
|
if (visionOk === 0 && chain.length > 0)
|
|
console.log(" ✗ NO vision model answered — image attachments are broken.");
|
|
}
|
|
|
|
main().catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
});
|