Files
plugins/packages/fingerprint/src/demo.ts
T
KaranocaVe 00f4d84b8f fingerprint 0.1.0: a page that checks whether a model answers like the one it claims to be (#516)
Adds the Fingerprint page plugin (packages/fingerprint): it checks whether a model behind the local magpie gateway answers like the model it claims to be.

Reviewed at 531ca11f4 (KaranocaVe). Run at that head merged with main 848497c, through mote-run on the Mac mini with Bun 1.4.2:
- bun run rebuild from the committed bun.lock (frozen, --ignore-scripts): typecheck, 30/30 tests, build; diff -r against the committed dist/ is empty.
- HOME=$(mktemp -d) bun test: 3838 pass, 0 fail. bun scripts/check.mjs: exit 0.
- Offline preload refusing every non-loopback fetch/socket: 30/30, nothing refused.
- Broken by hand, each red: ensureDetector() in bootstrap, dropping ttl: Infinity, validating the job after the download.

Maintainer decision: the reference data comes from two third-party hosts (lm.ikale.io, cdn.jsdmirror.com), only on an explicit Download or a valid job, and both are named on the page, in registry.json and the READMEs. It is data used locally to rank candidates and is sent nowhere; the @latest fallback has no pinned hash, so a bad snapshot would rank wrongly, which the page states.

Not on npm yet (E404): magpie installs it from the dist branch until an owner publishes the first version.
2026-10-31 02:00:33 +08:00

125 lines
3.5 KiB
TypeScript

import type { Analysis, Job, Model, RunConfig } from './types';
import { generateChallenges } from '../vendor/lmfpd-sdk/index.js';
export const demoModels: Model[] = [
{
id: 'anthropic/claude-sonnet-4.6',
name: 'Claude Sonnet 4.6',
provider: 'anthropic',
efforts: ['low', 'medium', 'high'],
nativeEndpoints: ['/v1/messages'],
},
{
id: 'openai/gpt-5.5',
name: 'GPT-5.5',
provider: 'openai',
efforts: ['low', 'medium', 'high'],
nativeEndpoints: ['/v1/responses'],
},
{
id: 'relay/claude-opus-4.7',
name: 'Claude Opus 4.7',
provider: 'relay',
efforts: ['low', 'medium', 'high'],
nativeEndpoints: ['/v1/messages'],
},
{
id: 'google/gemini-3.1-pro',
name: 'Gemini 3.1 Pro',
provider: 'google',
efforts: [],
nativeEndpoints: [],
},
];
export function demoAnalysis(model: string): Analysis {
const id = model.split('/').slice(1).join('/');
const candidates = [id, 'claude-sonnet-4.6', 'gpt-5.4', 'gemini-3.1-pro', 'deepseek-v3.2'].filter(
(v, i, a) => a.indexOf(v) === i,
);
return {
decision: 'scored',
prediction: id,
prediction_name: id,
family_prediction: id.split('-')[0],
family_prediction_name: id.split('-')[0],
results: candidates.map((v, i) => ({
model: v,
display_name: v,
family: v.split('-')[0],
family_name: v.split('-')[0],
score: 1 - i * 0.17,
probability: i === 0 ? 0.87 : 0.13 / (candidates.length - 1),
})),
ranking_score: 1,
probability: 0.87,
probability_status: 'reference_calibrated',
probability_scope: 'Reference bank candidates only (illustrative demo)',
calibration: null,
used_outputs: 3,
diagnostics: [0, 1, 2].map((index) => ({
index,
parsed_numbers: 300,
minimum_numbers: 165,
accepted: true,
raw_out_of_range_count: 0,
})),
sequence: null,
method: 'Illustrative demo; no measurement',
model_version: { base_sha256: 'demo-not-measured' },
evidence: {
insufficient: false,
label: 'Demo',
reason: 'Illustrative data only',
threshold: null,
method: 'demo',
},
};
}
export function demoHistory(): Job {
const createdAt = new Date(Date.now() - 3600_000).toISOString();
const config: RunConfig = {
targets: demoModels.slice(0, 2).map((m) => ({ model: m.id })),
api: 'auto',
effort: '',
serviceTier: 'default',
strict: false,
targetParallel: 1,
sampleParallel: 3,
deadlineSeconds: 300,
};
return {
id: 'demo-example',
createdAt,
finishedAt: createdAt,
state: 'completed',
config,
challenges: generateChallenges(),
bank: { builtAt: 'Demo reference data', sdk: '0.2.0' },
demo: true,
results: config.targets.map((target, i) => ({
id: `demo-${i}`,
target,
api: i ? 'responses' : 'messages',
state: 'completed',
samples: [0, 1, 2].map(() => ({
state: 'complete',
text: '137, 42, 291, 65, 188',
raw_text: '137, 42, 291, 65, 188 (illustrative excerpt)',
count: 300,
expected_count: 300,
first_byte_ms: 650,
response_model: target.model.split('/')[1],
response_id: 'demo',
error: null,
})),
provenance: [0, 1, 2].map((n) => ({
session: `demo-${n}`,
requestedModel: target.model,
provider: target.model.split('/')[0],
model: target.model,
})),
analysis: demoAnalysis(target.model),
error: null,
})),
};
}