vectorbench 0.0.0-stage → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +10 -0
- package/LICENSE +201 -0
- package/NOTICE +49 -0
- package/README.md +164 -2
- package/bench.config.mjs +255 -0
- package/bin/vectorbench.mjs +68 -0
- package/harness/Dockerfile +104 -0
- package/harness/adapters/chat.mjs +192 -0
- package/harness/adapters/index.mjs +77 -0
- package/harness/adapters/interactions.mjs +212 -0
- package/harness/adapters/messages.mjs +190 -0
- package/harness/adapters/responses.mjs +179 -0
- package/harness/box/README.md +46 -0
- package/harness/box/check.mjs +18 -0
- package/harness/box/tools.py +638 -0
- package/harness/box/vb3d.py +556 -0
- package/harness/claude-code.mjs +629 -0
- package/harness/codex-account.mjs +122 -0
- package/harness/codex.mjs +933 -0
- package/harness/grok-build.mjs +233 -0
- package/harness/loop.mjs +114 -0
- package/harness/prices.mjs +30 -0
- package/harness/request.mjs +155 -0
- package/harness/sandbox.mjs +77 -0
- package/package.json +76 -4
- package/scripts/doctor.mjs +113 -0
- package/scripts/harness.mjs +547 -0
- package/scripts/partner.mjs +140 -0
- package/scripts/zip.mjs +77 -0
- package/src/model-apis.js +516 -0
- package/worker/svg.js +350 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// A partner's one command: draws every VectorBench prompt with one model,
|
|
2
|
+
// through the same harness, sandbox and budget as our own drawings, and
|
|
3
|
+
// leaves a zip to send at https://vectorbench.ai/partners.
|
|
4
|
+
//
|
|
5
|
+
// npx vectorbench@latest draw --model gpt-6.2-astra no clone needed
|
|
6
|
+
// npm run partner -- --model gpt-6.2-astra the same, in a clone; a model in bench.config.mjs
|
|
7
|
+
// npm run partner -- --model gpt-6.2-astra --prompt chessboard one prompt first, to see the cost
|
|
8
|
+
// npm run partner -- --model grok-5 --via xai --api-model grok-5 --effort high --name "Grok 5"
|
|
9
|
+
// a model we don't list yet
|
|
10
|
+
// --via <provider> anthropic | openai | gemini | xai | openrouter: whose API answers
|
|
11
|
+
// --api-model <id> the model's id at that API (default: the --model id)
|
|
12
|
+
// --effort <level> its highest reasoning setting, up to max
|
|
13
|
+
// --codex an OpenAI model through the Codex CLI on your ChatGPT plan; the default
|
|
14
|
+
// when OPENAI_API_KEY isn't set and Codex is installed
|
|
15
|
+
// --grok-build an xAI model through Grok Build on your Grok plan; the default
|
|
16
|
+
// when XAI_API_KEY isn't set and Grok Build is installed
|
|
17
|
+
// --api a Claude model on API credits; without it, through Claude Code on your Claude plan
|
|
18
|
+
// --dry-run show what would be asked and what is missing, and ask nothing
|
|
19
|
+
// --out <dir> where to write (default harness/trial-partner/<model> in a clone,
|
|
20
|
+
// ./vectorbench-drawings/<model> when run with npx)
|
|
21
|
+
// --concurrency <n> drawings at once (default 3)
|
|
22
|
+
//
|
|
23
|
+
// It checks Node, Docker and Chrome, builds the sandbox image the first time
|
|
24
|
+
// (a few minutes), then runs scripts/harness.mjs. The API key comes from the
|
|
25
|
+
// environment or a .env file where the command is typed (.env.example has the
|
|
26
|
+
// names), and the run is billed to it. A drawing that has an answer is not asked again, so the same command
|
|
27
|
+
// picks up where a stopped run left off: the first answer stands.
|
|
28
|
+
|
|
29
|
+
import { spawnSync } from 'node:child_process';
|
|
30
|
+
import { copyFileSync, existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
31
|
+
import { join, relative, resolve } from 'node:path';
|
|
32
|
+
import { models as lineup, prompts, upcomingModels } from '../bench.config.mjs';
|
|
33
|
+
import { KEYS } from '../harness/adapters/index.mjs';
|
|
34
|
+
import { HARNESS } from '../harness/request.mjs';
|
|
35
|
+
import { IMAGE } from '../harness/sandbox.mjs';
|
|
36
|
+
import { INSTALLED, PROVIDERS, ROOT, check, findChrome, loadEnv, works } from './doctor.mjs';
|
|
37
|
+
import { zipFolder } from './zip.mjs';
|
|
38
|
+
|
|
39
|
+
const SITE = 'https://vectorbench.ai';
|
|
40
|
+
// How this was called, for the examples it prints: bin/vectorbench.mjs says `vectorbench draw`.
|
|
41
|
+
const COMMAND = process.env.VB_COMMAND || 'npm run partner --';
|
|
42
|
+
|
|
43
|
+
loadEnv();
|
|
44
|
+
|
|
45
|
+
const args = process.argv.slice(2);
|
|
46
|
+
const flag = (name) => args.includes(`--${name}`);
|
|
47
|
+
const option = (name) => (args.includes(`--${name}`) ? args[args.indexOf(`--${name}`) + 1] : undefined);
|
|
48
|
+
const dryRun = flag('dry-run');
|
|
49
|
+
const stop = (message) => {
|
|
50
|
+
console.error(message);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/* The model ---------------------------------------------------------------- */
|
|
55
|
+
|
|
56
|
+
const id = option('model');
|
|
57
|
+
if (!id || id.startsWith('--') || id.includes(',')) stop(`Name one model: ${COMMAND} --model <id>\nThe ones we list: ${[...lineup, ...upcomingModels].map((m) => m.id).join(', ')}.\nAny other: add --via <${PROVIDERS.join('|')}> --effort <its highest reasoning setting>.`);
|
|
58
|
+
|
|
59
|
+
let model = [...lineup, ...upcomingModels].find((m) => m.id === id);
|
|
60
|
+
let extra = null;
|
|
61
|
+
if (!model) {
|
|
62
|
+
const via = option('via');
|
|
63
|
+
const effort = option('effort');
|
|
64
|
+
if (!/^[a-z0-9][a-z0-9.-]*$/.test(id)) stop(`"${id}" can't be a model id here: use lower-case letters, digits, dots and hyphens, like gpt-6.2-astra. --api-model takes the id the API knows it by.`);
|
|
65
|
+
if (!PROVIDERS.includes(via)) stop(`"${id}" isn't in bench.config.mjs. To draw with it anyway, say whose API answers: --via <${PROVIDERS.join('|')}>, with --api-model <its id there> if that differs.`);
|
|
66
|
+
if (!effort) stop('Say the reasoning setting to ask at: --effort <level>. The rule is the highest the model has, up to max.');
|
|
67
|
+
model = extra = { id, name: option('name') ?? id, provider: via, via, model: option('api-model') ?? id, effort };
|
|
68
|
+
} else if (option('via') || option('effort') || option('api-model')) {
|
|
69
|
+
stop(`${model.name} is in bench.config.mjs, which already says how it is asked (${model.via}, effort ${model.effort}): leave out --via, --effort and --api-model.`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const wantedPrompts = option('prompt')?.split(',').filter(Boolean) ?? prompts.map((p) => p.id);
|
|
73
|
+
for (const p of wantedPrompts) if (!prompts.some((x) => x.id === p)) stop(`There is no prompt "${p}". The prompts: ${prompts.map((x) => x.id).join(', ')}.`);
|
|
74
|
+
|
|
75
|
+
/* What it runs on ---------------------------------------------------------- */
|
|
76
|
+
|
|
77
|
+
const keyName = KEYS[model.via];
|
|
78
|
+
// An OpenAI model with no API key goes to the ChatGPT plan when the Codex CLI is here, without being told to.
|
|
79
|
+
const codexBin = process.env.CODEX_BIN || 'codex';
|
|
80
|
+
const codex = model.via === 'openai' && (flag('codex') || (!process.env[keyName] && works(codexBin, ['--version'])));
|
|
81
|
+
// The same for an xAI model and the Grok plan, with Grok Build.
|
|
82
|
+
const grokBin = process.env.GROK_BIN || 'grok';
|
|
83
|
+
const grokBuild = model.via === 'xai' && (flag('grok-build') || (!process.env[keyName] && works(grokBin, ['--version'])));
|
|
84
|
+
const route = model.via === 'anthropic' && !flag('api') ? 'Claude Code' : codex ? 'Codex' : grokBuild ? 'Grok Build' : 'API';
|
|
85
|
+
const chrome = findChrome();
|
|
86
|
+
const missing = check({ model, route });
|
|
87
|
+
|
|
88
|
+
if (missing.length) {
|
|
89
|
+
console.error(`Missing:\n${missing.map((line) => ` - ${line}`).join('\n')}`);
|
|
90
|
+
if (!dryRun) process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// From a clone the drawings stay in it; run with npx, they land where the command was typed.
|
|
94
|
+
const OUT = resolve(option('out') ?? (INSTALLED ? join('vectorbench-drawings', model.id) : join(ROOT, 'harness', 'trial-partner', model.id)));
|
|
95
|
+
const shown = (path) => relative(process.cwd(), path) || '.';
|
|
96
|
+
console.log(`${model.name} (${model.model}, effort ${model.effort}) on ${route === 'API' ? `${model.via}'s API, billed to your ${keyName}` : `${route}, on your plan`}: ${wantedPrompts.length} prompt${wantedPrompts.length === 1 ? '' : 's'}, into ${shown(OUT)}/.`);
|
|
97
|
+
|
|
98
|
+
if (!dryRun && !works('docker', ['image', 'inspect', IMAGE])) {
|
|
99
|
+
console.log(`\nBuilding the sandbox image ${IMAGE}. This happens once and takes a few minutes.`);
|
|
100
|
+
const built = spawnSync('docker', ['build', '--network', 'host', '--build-context', 'site=worker', '-t', IMAGE, 'harness/'], { cwd: ROOT, stdio: 'inherit', env: { ...process.env, DOCKER_BUILDKIT: '1' } });
|
|
101
|
+
if (built.status !== 0) stop('The sandbox image did not build; the lines above say why.');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* Draw --------------------------------------------------------------------- */
|
|
105
|
+
|
|
106
|
+
// --paid: the partner's own key pays, which is what a partner run is.
|
|
107
|
+
const harnessArgs = ['scripts/harness.mjs', '--model', model.id, '--prompt', wantedPrompts.join(','), '--out', OUT, '--paid'];
|
|
108
|
+
for (const name of ['api', 'dry-run']) if (flag(name)) harnessArgs.push(`--${name}`);
|
|
109
|
+
if (codex) harnessArgs.push('--codex');
|
|
110
|
+
if (grokBuild) harnessArgs.push('--grok-build');
|
|
111
|
+
if (option('concurrency')) harnessArgs.push('--concurrency', option('concurrency'));
|
|
112
|
+
const ran = spawnSync(process.execPath, harnessArgs, {
|
|
113
|
+
cwd: ROOT,
|
|
114
|
+
stdio: 'inherit',
|
|
115
|
+
env: { ...process.env, ...(chrome && { CHROME_PATH: chrome }), ...(extra && { VB_EXTRA_MODELS: JSON.stringify([extra]) }) },
|
|
116
|
+
});
|
|
117
|
+
if (dryRun) process.exit(ran.status ?? 1);
|
|
118
|
+
|
|
119
|
+
/* Hand over ---------------------------------------------------------------- */
|
|
120
|
+
|
|
121
|
+
// The site takes drawings named after their prompt: drawings/<prompt id>.svg.
|
|
122
|
+
const DRAWINGS = join(OUT, 'drawings');
|
|
123
|
+
rmSync(DRAWINGS, { recursive: true, force: true });
|
|
124
|
+
mkdirSync(DRAWINGS, { recursive: true });
|
|
125
|
+
const drawn = wantedPrompts.filter((p) => existsSync(join(OUT, p, `${model.id}.svg`)));
|
|
126
|
+
for (const p of drawn) copyFileSync(join(OUT, p, `${model.id}.svg`), join(DRAWINGS, `${p}.svg`));
|
|
127
|
+
const notDrawn = wantedPrompts.filter((p) => !drawn.includes(p));
|
|
128
|
+
|
|
129
|
+
console.log(`\n${drawn.length} of ${wantedPrompts.length} drawn.`);
|
|
130
|
+
if (notDrawn.length) console.log(`Not drawn: ${notDrawn.join(', ')}. ${shown(join(OUT, 'summary.txt'))} says how each run ended. One the API failed on is asked again by the same command; one the model answered badly is its answer, and stays out.`);
|
|
131
|
+
if (!drawn.length) process.exit(1);
|
|
132
|
+
|
|
133
|
+
const ZIP = join(OUT, 'vectorbench-drawings.zip');
|
|
134
|
+
rmSync(ZIP, { force: true });
|
|
135
|
+
writeFileSync(ZIP, zipFolder(OUT, 'drawings'));
|
|
136
|
+
|
|
137
|
+
console.log(`
|
|
138
|
+
Look them over: ${shown(join(OUT, 'index.html'))}
|
|
139
|
+
Send them: ${SITE}/partners, sign in, choose the model, and drop in ${shown(ZIP)}
|
|
140
|
+
Made with: VectorBench harness ${HARNESS.version} (sandbox ${IMAGE}), ${route === 'API' ? `${model.via} API` : route}, effort ${model.effort}`);
|
package/scripts/zip.mjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Writes a .zip with nothing but node:zlib, so neither the site build nor a
|
|
2
|
+
// partner's hand-over needs the `zip` tool installed. Deflated members, UTF-8
|
|
3
|
+
// names, no zip64: plenty for a folder of drawings or requests.
|
|
4
|
+
//
|
|
5
|
+
// zip([{ name: 'drawings/fox.svg', data: '<svg…' }]) -> Buffer
|
|
6
|
+
// zipFolder('/path/to/out', 'drawings') -> Buffer of out/drawings/**
|
|
7
|
+
|
|
8
|
+
import { readFileSync, readdirSync } from 'node:fs';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { crc32, deflateRawSync } from 'node:zlib';
|
|
11
|
+
|
|
12
|
+
// A fixed date (1 January 2026, 00:00), so the same files always make the same zip.
|
|
13
|
+
const DOS_TIME = 0;
|
|
14
|
+
const DOS_DATE = ((2026 - 1980) << 9) | (1 << 5) | 1;
|
|
15
|
+
|
|
16
|
+
/** A zip of `entries`: [{ name, data }], name being the path inside it, data a string or bytes. */
|
|
17
|
+
export function zip(entries) {
|
|
18
|
+
const parts = [];
|
|
19
|
+
const central = [];
|
|
20
|
+
let offset = 0;
|
|
21
|
+
for (const { name, data } of entries) {
|
|
22
|
+
const path = Buffer.from(name.replaceAll('\\', '/'), 'utf8');
|
|
23
|
+
const raw = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
24
|
+
const deflated = deflateRawSync(raw, { level: 9 });
|
|
25
|
+
const stored = deflated.length >= raw.length;
|
|
26
|
+
const body = stored ? raw : deflated;
|
|
27
|
+
|
|
28
|
+
// What the local header and the central directory both say about the member.
|
|
29
|
+
const about = Buffer.alloc(26);
|
|
30
|
+
about.writeUInt16LE(20, 0); // version needed
|
|
31
|
+
about.writeUInt16LE(0x0800, 2); // names are UTF-8
|
|
32
|
+
about.writeUInt16LE(stored ? 0 : 8, 4);
|
|
33
|
+
about.writeUInt16LE(DOS_TIME, 6);
|
|
34
|
+
about.writeUInt16LE(DOS_DATE, 8);
|
|
35
|
+
about.writeUInt32LE(crc32(raw), 10);
|
|
36
|
+
about.writeUInt32LE(body.length, 14);
|
|
37
|
+
about.writeUInt32LE(raw.length, 18);
|
|
38
|
+
about.writeUInt16LE(path.length, 22);
|
|
39
|
+
about.writeUInt16LE(0, 24); // no extra field
|
|
40
|
+
|
|
41
|
+
const local = Buffer.alloc(4);
|
|
42
|
+
local.writeUInt32LE(0x04034b50, 0);
|
|
43
|
+
parts.push(local, about, path, body);
|
|
44
|
+
|
|
45
|
+
const entry = Buffer.alloc(46);
|
|
46
|
+
entry.writeUInt32LE(0x02014b50, 0);
|
|
47
|
+
entry.writeUInt16LE(20, 4); // version made by
|
|
48
|
+
about.copy(entry, 6);
|
|
49
|
+
entry.writeUInt32LE(offset, 42);
|
|
50
|
+
central.push(entry, path);
|
|
51
|
+
|
|
52
|
+
offset += 30 + path.length + body.length;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const directory = Buffer.concat(central);
|
|
56
|
+
const end = Buffer.alloc(22);
|
|
57
|
+
end.writeUInt32LE(0x06054b50, 0);
|
|
58
|
+
end.writeUInt16LE(entries.length, 8);
|
|
59
|
+
end.writeUInt16LE(entries.length, 10);
|
|
60
|
+
end.writeUInt32LE(directory.length, 12);
|
|
61
|
+
end.writeUInt32LE(offset, 16);
|
|
62
|
+
return Buffer.concat([...parts, directory, end]);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** A zip of the folder `name` inside `parent`, every file under it, paths starting at `name/`. */
|
|
66
|
+
export function zipFolder(parent, name) {
|
|
67
|
+
const entries = [];
|
|
68
|
+
const walk = (relative) => {
|
|
69
|
+
for (const item of readdirSync(join(parent, relative), { withFileTypes: true }).sort((a, b) => (a.name < b.name ? -1 : 1))) {
|
|
70
|
+
const path = `${relative}/${item.name}`;
|
|
71
|
+
if (item.isDirectory()) walk(path);
|
|
72
|
+
else if (item.isFile()) entries.push({ name: path, data: readFileSync(join(parent, path)) });
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
walk(name);
|
|
76
|
+
return zip(entries);
|
|
77
|
+
}
|