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
package/package.json
CHANGED
|
@@ -1,6 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vectorbench",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "3.0.2",
|
|
4
|
+
"description": "Draw VectorBench's SVG prompts with your own model, in the same sandbox as the benchmark at vectorbench.ai",
|
|
5
|
+
"homepage": "https://vectorbench.ai",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/vectorbench/vectorbench.git"
|
|
9
|
+
},
|
|
10
|
+
"bugs": "https://github.com/vectorbench/vectorbench/issues",
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"svg",
|
|
14
|
+
"benchmark",
|
|
15
|
+
"llm",
|
|
16
|
+
"vectorbench"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"bin": {
|
|
20
|
+
"vectorbench": "bin/vectorbench.mjs"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22.13"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"bin/",
|
|
27
|
+
"bench.config.mjs",
|
|
28
|
+
"scripts/partner.mjs",
|
|
29
|
+
"scripts/harness.mjs",
|
|
30
|
+
"scripts/doctor.mjs",
|
|
31
|
+
"scripts/zip.mjs",
|
|
32
|
+
"harness/*.mjs",
|
|
33
|
+
"harness/adapters/",
|
|
34
|
+
"harness/box/",
|
|
35
|
+
"harness/Dockerfile",
|
|
36
|
+
"worker/svg.js",
|
|
37
|
+
"src/model-apis.js",
|
|
38
|
+
".env.example",
|
|
39
|
+
"NOTICE"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "node scripts/build.mjs",
|
|
43
|
+
"assets": "node scripts/assets.mjs && node scripts/build.mjs",
|
|
44
|
+
"migrate": "wrangler d1 migrations apply DB --local",
|
|
45
|
+
"dev": "node scripts/dev.mjs",
|
|
46
|
+
"test": "node --disable-warning=ExperimentalWarning --test \"test/*.test.mjs\"",
|
|
47
|
+
"arena": "node scripts/arena.mjs",
|
|
48
|
+
"generate": "node scripts/generate.mjs",
|
|
49
|
+
"partner": "node scripts/partner.mjs",
|
|
50
|
+
"deploy": "node --disable-warning=ExperimentalWarning scripts/deploy.mjs",
|
|
51
|
+
"deploy:staging": "node --disable-warning=ExperimentalWarning scripts/deploy.mjs --env staging",
|
|
52
|
+
"backup": "node --disable-warning=ExperimentalWarning scripts/backup.mjs",
|
|
53
|
+
"export:votes": "node --disable-warning=ExperimentalWarning scripts/export-votes.mjs",
|
|
54
|
+
"restore:staging": "node --disable-warning=ExperimentalWarning scripts/restore.mjs",
|
|
55
|
+
"turnstile:setup": "node --disable-warning=ExperimentalWarning scripts/turnstile-setup.mjs",
|
|
56
|
+
"mail": "node scripts/mail.mjs",
|
|
57
|
+
"mail:setup": "node scripts/mail-setup.mjs",
|
|
58
|
+
"mail:deploy": "cd workers/mail && wrangler d1 migrations apply vectorbench-mail --remote && wrangler deploy",
|
|
59
|
+
"www:deploy": "cd workers/www && wrangler deploy",
|
|
60
|
+
"share:videos": "node scripts/share-videos.mjs --missing",
|
|
61
|
+
"edge:deploy": "cd workers/edge && wrangler deploy",
|
|
62
|
+
"warm:deploy": "cd workers/warm && wrangler deploy",
|
|
63
|
+
"todo": "node scripts/todo.mjs",
|
|
64
|
+
"doctor": "node scripts/doctor.mjs"
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"playwright-core": "^1.65.1"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@anthropic-ai/sdk": "^1.8.0",
|
|
71
|
+
"@cloudflare/puppeteer": "2.0.1",
|
|
72
|
+
"@fontsource-variable/archivo": "^5.3.0",
|
|
73
|
+
"@resvg/resvg-wasm": "^2.6.2",
|
|
74
|
+
"esbuild": "^0.28.2",
|
|
75
|
+
"postal-mime": "^4.2.1",
|
|
76
|
+
"wrangler": "4.161.0"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// What a drawing run needs on this machine, and what to do about each thing
|
|
2
|
+
// that is missing. scripts/partner.mjs checks before it draws; on its own:
|
|
3
|
+
//
|
|
4
|
+
// vectorbench doctor (or: node scripts/doctor.mjs)
|
|
5
|
+
//
|
|
6
|
+
// Nothing here asks a model anything or costs anything.
|
|
7
|
+
|
|
8
|
+
import { spawnSync } from 'node:child_process';
|
|
9
|
+
import { existsSync } from 'node:fs';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
12
|
+
import { KEYS } from '../harness/adapters/index.mjs';
|
|
13
|
+
import { IMAGE } from '../harness/sandbox.mjs';
|
|
14
|
+
|
|
15
|
+
export const ROOT = fileURLToPath(new URL('../', import.meta.url));
|
|
16
|
+
/** Run from an installed package (npx vectorbench) rather than a clone of the repository. */
|
|
17
|
+
export const INSTALLED = !existsSync(join(ROOT, '.git'));
|
|
18
|
+
/** The oldest Node.js that runs everything here without a flag (node:sqlite, zlib.crc32). */
|
|
19
|
+
export const NODE = [22, 13];
|
|
20
|
+
|
|
21
|
+
/** Whose API can answer: what --via takes. */
|
|
22
|
+
export const PROVIDERS = ['anthropic', 'openai', 'gemini', 'xai', 'openrouter'];
|
|
23
|
+
|
|
24
|
+
export const CHROMES = [
|
|
25
|
+
'/usr/bin/google-chrome',
|
|
26
|
+
'/usr/bin/google-chrome-stable',
|
|
27
|
+
'/usr/bin/chromium',
|
|
28
|
+
'/usr/bin/chromium-browser',
|
|
29
|
+
'/snap/bin/chromium',
|
|
30
|
+
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
31
|
+
'/Applications/Chromium.app/Contents/MacOS/Chromium',
|
|
32
|
+
'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
|
|
33
|
+
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
export const works = (command, args) => spawnSync(command, args, { stdio: 'ignore' }).status === 0;
|
|
37
|
+
|
|
38
|
+
/** Where Chrome or Chromium is, or undefined. CHROME_PATH wins. */
|
|
39
|
+
export const findChrome = () => {
|
|
40
|
+
const chrome = process.env.CHROME_PATH || CHROMES.find((path) => existsSync(path));
|
|
41
|
+
return chrome && existsSync(chrome) ? chrome : undefined;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** .env beside where the command was typed, then the repository's own; neither replaces what is already set. */
|
|
45
|
+
export function loadEnv() {
|
|
46
|
+
for (const dir of new Set([process.cwd(), ROOT])) {
|
|
47
|
+
try {
|
|
48
|
+
process.loadEnvFile(join(dir, '.env'));
|
|
49
|
+
} catch {}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const nodeOk = () => {
|
|
54
|
+
const [major, minor] = process.versions.node.split('.').map(Number);
|
|
55
|
+
return major > NODE[0] || (major === NODE[0] && minor >= NODE[1]);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const hasDependencies = () => {
|
|
59
|
+
try {
|
|
60
|
+
import.meta.resolve('playwright-core');
|
|
61
|
+
return true;
|
|
62
|
+
} catch {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/** What every run needs, whichever model: [{ name, ok, fix }]. */
|
|
68
|
+
export function machine() {
|
|
69
|
+
return [
|
|
70
|
+
{ name: `Node.js ${NODE.join('.')} or later`, ok: nodeOk(), fix: `This is ${process.versions.node}: install a newer one from https://nodejs.org.` },
|
|
71
|
+
{ name: 'Docker, installed and running', ok: works('docker', ['info']), fix: 'Each drawing is made in a container with no network. Install Docker (https://docs.docker.com/get-docker/) and start it; on Linux, your user needs to run it without sudo.' },
|
|
72
|
+
{ name: 'Chrome or Chromium', ok: Boolean(findChrome()), fix: 'It checks each drawing renders. Install one, or set CHROME_PATH if it is somewhere unusual.' },
|
|
73
|
+
{ name: 'The dependencies', ok: hasDependencies(), fix: 'Run `npm ci` in the repository first.' },
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** How a model can be asked here: [{ name, ok, fix }]. One of them is enough. */
|
|
78
|
+
export function routes() {
|
|
79
|
+
return [
|
|
80
|
+
{ name: 'Claude Code (Claude models, on your Claude plan)', ok: works('claude', ['--version']), fix: 'Install it and sign in, or use ANTHROPIC_API_KEY with --api.' },
|
|
81
|
+
{ name: 'The Codex CLI (OpenAI models, on your ChatGPT plan: used when OPENAI_API_KEY is not set, or with --codex)', ok: works(process.env.CODEX_BIN || 'codex', ['--version']), fix: 'Install it and sign in, or use OPENAI_API_KEY.' },
|
|
82
|
+
{ name: 'Grok Build (xAI models, on your Grok plan: used when XAI_API_KEY is not set, or with --grok-build)', ok: works(process.env.GROK_BIN || 'grok', ['--version']), fix: 'Install it and sign in, or use XAI_API_KEY.' },
|
|
83
|
+
...PROVIDERS.map((provider) => [provider, KEYS[provider]]).map(([provider, key]) => ({ name: `${key} (${provider}'s API)`, ok: Boolean(process.env[key]), fix: `Set it in the environment or in a .env file here, to draw through ${provider}'s API.` })),
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** What is missing to draw with `model` over `route` ('Claude Code' | 'Codex' | 'Grok Build' | 'API'): lines to print. */
|
|
88
|
+
export function check({ model, route }) {
|
|
89
|
+
const missing = machine()
|
|
90
|
+
.filter((item) => !item.ok)
|
|
91
|
+
.map((item) => `${item.name}. ${item.fix}`);
|
|
92
|
+
if (route === 'Claude Code' && !works('claude', ['--version'])) missing.push('Claude Code, installed and signed in (or pass --api to use ANTHROPIC_API_KEY).');
|
|
93
|
+
if (route === 'Codex' && !works(process.env.CODEX_BIN || 'codex', ['--version'])) missing.push('The Codex CLI, installed and signed in.');
|
|
94
|
+
if (route === 'Grok Build' && !works(process.env.GROK_BIN || 'grok', ['--version'])) missing.push('Grok Build, installed and signed in.');
|
|
95
|
+
if (route === 'API' && !process.env[KEYS[model.via]]) missing.push(`${KEYS[model.via]}, in the environment or in a .env file here${model.via === 'openai' ? ' (or install the Codex CLI and sign in, to use your ChatGPT plan)' : model.via === 'xai' ? ' (or install Grok Build and sign in, to use your Grok plan)' : ''}.`);
|
|
96
|
+
return missing;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
100
|
+
loadEnv();
|
|
101
|
+
const mark = (ok) => (ok ? 'ok ' : 'missing');
|
|
102
|
+
const needs = machine();
|
|
103
|
+
console.log('To draw at all:');
|
|
104
|
+
for (const item of needs) console.log(` ${mark(item.ok)} ${item.name}${item.ok ? '' : `\n ${item.fix}`}`);
|
|
105
|
+
const ways = routes();
|
|
106
|
+
console.log('\nTo ask a model (one of these is enough):');
|
|
107
|
+
for (const item of ways) console.log(` ${mark(item.ok)} ${item.name}`);
|
|
108
|
+
const built = works('docker', ['image', 'inspect', IMAGE]);
|
|
109
|
+
console.log(`\nThe sandbox image ${IMAGE} is ${built ? 'built' : 'not built yet: the first drawing run builds it, which takes a few minutes'}.`);
|
|
110
|
+
const ready = needs.every((item) => item.ok) && ways.some((item) => item.ok);
|
|
111
|
+
console.log(ready ? '\nReady to draw.' : `\nNot ready yet: ${[...needs.filter((item) => !item.ok).map((item) => item.name), ...(ways.some((item) => item.ok) ? [] : ['a way to ask a model'])].join('; ')}.`);
|
|
112
|
+
process.exit(ready ? 0 : 1);
|
|
113
|
+
}
|