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.
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { expect, test } from 'bun:test';
|
|
import { Gateway } from '../src/gateway';
|
|
|
|
test('catalog reads cached local and remote subscription accounts without leaking quota data', async () => {
|
|
const paths: string[] = [];
|
|
const server = Bun.serve({
|
|
hostname: '127.0.0.1',
|
|
port: 0,
|
|
fetch(req) {
|
|
const url = new URL(req.url);
|
|
paths.push(url.pathname + url.search);
|
|
return Response.json(
|
|
url.pathname === '/v1/models'
|
|
? { data: [{ id: 'vendor/model' }] }
|
|
: {
|
|
data: [
|
|
{
|
|
provider: 'vendor',
|
|
user: 'local-account',
|
|
name: 'Local',
|
|
balance: '$42',
|
|
secret: 'excluded',
|
|
},
|
|
{
|
|
provider: 'vendor',
|
|
user: 'remote-account',
|
|
name: 'Remote',
|
|
kind: 'subscription',
|
|
},
|
|
{ provider: 'vendor', user: 'key-card', name: 'Key', kind: 'balance' },
|
|
{ provider: 'vendor', kind: 'subscription' },
|
|
],
|
|
},
|
|
);
|
|
},
|
|
});
|
|
try {
|
|
const { accounts } = await new Gateway(`http://127.0.0.1:${server.port}`).catalog();
|
|
expect(paths).toContain('/v1/magpie/quotas?kept=1');
|
|
expect(accounts).toEqual([
|
|
{ provider: 'vendor', id: 'local-account', name: 'Local' },
|
|
{ provider: 'vendor', id: 'remote-account', name: 'Remote' },
|
|
]);
|
|
} finally {
|
|
server.stop(true);
|
|
}
|
|
});
|