@workbench-ai/workbench 0.0.67 → 0.0.69
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/dist/dev-open/client.css +387 -287
- package/dist/dev-open/client.js +202 -202
- package/dist/dev-open/fonts/ibm-plex-mono-cyrillic-400-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-cyrillic-400-normal.woff2 +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-cyrillic-500-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-cyrillic-500-normal.woff2 +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-cyrillic-600-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-cyrillic-600-normal.woff2 +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-cyrillic-ext-400-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-cyrillic-ext-400-normal.woff2 +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-cyrillic-ext-500-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-cyrillic-ext-500-normal.woff2 +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-cyrillic-ext-600-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-cyrillic-ext-600-normal.woff2 +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-latin-400-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-latin-500-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-latin-600-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-latin-ext-400-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-latin-ext-400-normal.woff2 +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-latin-ext-500-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-latin-ext-500-normal.woff2 +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-latin-ext-600-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-latin-ext-600-normal.woff2 +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-vietnamese-400-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-vietnamese-400-normal.woff2 +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-vietnamese-500-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-vietnamese-500-normal.woff2 +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-vietnamese-600-normal.woff +0 -0
- package/dist/dev-open/fonts/ibm-plex-mono-vietnamese-600-normal.woff2 +0 -0
- package/dist/dev-open/fonts/libre-caslon-display-latin-400-normal.woff +0 -0
- package/dist/dev-open/fonts/libre-caslon-display-latin-400-normal.woff2 +0 -0
- package/dist/dev-open/fonts/libre-caslon-display-latin-ext-400-normal.woff +0 -0
- package/dist/dev-open/fonts/libre-caslon-display-latin-ext-400-normal.woff2 +0 -0
- package/dist/index.d.ts +2 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2035 -5100
- package/dist/install-targets.d.ts +35 -0
- package/dist/install-targets.d.ts.map +1 -0
- package/dist/install-targets.js +188 -0
- package/dist/open-server.d.ts +12 -0
- package/dist/open-server.d.ts.map +1 -0
- package/dist/open-server.js +248 -0
- package/dist/output.d.ts +22 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +38 -0
- package/package.json +5 -5
- package/dist/adapter-command-env.d.ts +0 -8
- package/dist/adapter-command-env.d.ts.map +0 -1
- package/dist/adapter-command-env.js +0 -80
- package/dist/adapter-project.d.ts +0 -29
- package/dist/adapter-project.d.ts.map +0 -1
- package/dist/adapter-project.js +0 -332
- package/dist/benchmark-fingerprint.d.ts +0 -6
- package/dist/benchmark-fingerprint.d.ts.map +0 -1
- package/dist/benchmark-fingerprint.js +0 -42
- package/dist/command-model.d.ts +0 -5
- package/dist/command-model.d.ts.map +0 -1
- package/dist/command-model.js +0 -537
- package/dist/dev-open-server.d.ts +0 -18
- package/dist/dev-open-server.d.ts.map +0 -1
- package/dist/dev-open-server.js +0 -297
- package/dist/init-scaffold.d.ts +0 -22
- package/dist/init-scaffold.d.ts.map +0 -1
- package/dist/init-scaffold.js +0 -30
- package/dist/init-template-pack.d.ts +0 -19
- package/dist/init-template-pack.d.ts.map +0 -1
- package/dist/init-template-pack.js +0 -262
- package/dist/local-archive.d.ts +0 -48
- package/dist/local-archive.d.ts.map +0 -1
- package/dist/local-archive.js +0 -838
- package/dist/local-inspection.d.ts +0 -9
- package/dist/local-inspection.d.ts.map +0 -1
- package/dist/local-inspection.js +0 -354
- package/dist/project-source.d.ts +0 -63
- package/dist/project-source.d.ts.map +0 -1
- package/dist/project-source.js +0 -682
- package/dist/workspace-snapshot.d.ts +0 -10
- package/dist/workspace-snapshot.d.ts.map +0 -1
- package/dist/workspace-snapshot.js +0 -81
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
const SYSTEM_PATH_ENTRIES = [
|
|
4
|
-
"/usr/local/sbin",
|
|
5
|
-
"/usr/local/bin",
|
|
6
|
-
"/usr/sbin",
|
|
7
|
-
"/usr/bin",
|
|
8
|
-
"/sbin",
|
|
9
|
-
"/bin",
|
|
10
|
-
];
|
|
11
|
-
export function createAdapterCommandEnv(options = {}) {
|
|
12
|
-
const baseEnv = options.env ?? process.env;
|
|
13
|
-
const env = {};
|
|
14
|
-
for (const [key, value] of Object.entries(baseEnv)) {
|
|
15
|
-
if (typeof value === "string" && !key.startsWith("WORKBENCH_")) {
|
|
16
|
-
env[key] = value;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
env.PATH = adapterCommandPath({
|
|
20
|
-
workspaceRoot: options.workspaceRoot,
|
|
21
|
-
adapterRoot: options.adapterRoot,
|
|
22
|
-
basePath: baseEnv.PATH,
|
|
23
|
-
});
|
|
24
|
-
for (const [key, value] of Object.entries(options.extraEnv ?? {})) {
|
|
25
|
-
if (value !== undefined) {
|
|
26
|
-
env[key] = value;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return env;
|
|
30
|
-
}
|
|
31
|
-
function adapterCommandPath(options) {
|
|
32
|
-
return uniquePathEntries([
|
|
33
|
-
path.dirname(process.execPath),
|
|
34
|
-
...optionalProjectBinDirs(options.workspaceRoot),
|
|
35
|
-
...optionalProjectBinDirs(options.adapterRoot),
|
|
36
|
-
...nodeModuleBinDirsForAncestors(process.cwd()),
|
|
37
|
-
...nodeModuleBinDirsForAncestors(path.dirname(fileURLToPath(import.meta.url))),
|
|
38
|
-
...optionalAncestorBinDirs(options.workspaceRoot),
|
|
39
|
-
...optionalAncestorBinDirs(options.adapterRoot),
|
|
40
|
-
...SYSTEM_PATH_ENTRIES,
|
|
41
|
-
...(options.basePath ? options.basePath.split(path.delimiter) : []),
|
|
42
|
-
]).join(path.delimiter);
|
|
43
|
-
}
|
|
44
|
-
function optionalProjectBinDirs(root) {
|
|
45
|
-
return root
|
|
46
|
-
? [
|
|
47
|
-
path.join(root, "node_modules", ".bin"),
|
|
48
|
-
path.join(root, "products", "workbench", "node_modules", ".bin"),
|
|
49
|
-
]
|
|
50
|
-
: [];
|
|
51
|
-
}
|
|
52
|
-
function optionalAncestorBinDirs(root) {
|
|
53
|
-
return root ? nodeModuleBinDirsForAncestors(root) : [];
|
|
54
|
-
}
|
|
55
|
-
function nodeModuleBinDirsForAncestors(start) {
|
|
56
|
-
const dirs = [];
|
|
57
|
-
let current = path.resolve(start);
|
|
58
|
-
for (let depth = 0; depth < 12; depth += 1) {
|
|
59
|
-
dirs.push(path.join(current, "node_modules", ".bin"));
|
|
60
|
-
const parent = path.dirname(current);
|
|
61
|
-
if (parent === current) {
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
current = parent;
|
|
65
|
-
}
|
|
66
|
-
return dirs;
|
|
67
|
-
}
|
|
68
|
-
function uniquePathEntries(entries) {
|
|
69
|
-
const seen = new Set();
|
|
70
|
-
const output = [];
|
|
71
|
-
for (const entry of entries) {
|
|
72
|
-
const trimmed = entry.trim();
|
|
73
|
-
if (!trimmed || seen.has(trimmed)) {
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
seen.add(trimmed);
|
|
77
|
-
output.push(trimmed);
|
|
78
|
-
}
|
|
79
|
-
return output;
|
|
80
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type WorkbenchAdapterManifest } from "@workbench-ai/workbench-protocol";
|
|
2
|
-
import { type resolveWorkbenchResolvedSourceYaml } from "@workbench-ai/workbench-core";
|
|
3
|
-
export declare const WORKBENCH_ADAPTER_MANIFEST_FILE = "workbench.adapter.yaml";
|
|
4
|
-
export interface ResolvedWorkbenchAdapter {
|
|
5
|
-
source: string;
|
|
6
|
-
declaredSource: string;
|
|
7
|
-
kind: "default" | "path" | "npm" | "git";
|
|
8
|
-
stability: "default" | "local" | "pinned" | "floating";
|
|
9
|
-
overridesDefault?: boolean;
|
|
10
|
-
manifest: WorkbenchAdapterManifest;
|
|
11
|
-
root?: string;
|
|
12
|
-
files?: WorkbenchAdapterSourceFile[];
|
|
13
|
-
integrity?: string;
|
|
14
|
-
contentHash: string;
|
|
15
|
-
manifestHash: string;
|
|
16
|
-
}
|
|
17
|
-
export interface WorkbenchAdapterSourceFile {
|
|
18
|
-
path: string;
|
|
19
|
-
content: string;
|
|
20
|
-
executable: boolean;
|
|
21
|
-
}
|
|
22
|
-
type GenericSpec = ReturnType<typeof resolveWorkbenchResolvedSourceYaml>;
|
|
23
|
-
export declare function defaultAdapterManifests(): WorkbenchAdapterManifest[];
|
|
24
|
-
export declare function resolveDefaultWorkbenchAdapter(id: string): ResolvedWorkbenchAdapter | null;
|
|
25
|
-
export declare function resolveWorkbenchAdaptersForProject(dir: string, spec: GenericSpec): Promise<ResolvedWorkbenchAdapter[]>;
|
|
26
|
-
export declare function resolveProjectAdapterSource(dir: string, source: string): Promise<ResolvedWorkbenchAdapter>;
|
|
27
|
-
export declare function composeRuntimeDockerfileWithAdapters(dockerfile: string, adapters: readonly ResolvedWorkbenchAdapter[]): Promise<string>;
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=adapter-project.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-project.d.ts","sourceRoot":"","sources":["../src/adapter-project.ts"],"names":[],"mappings":"AAWA,OAAO,EAKL,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAGL,KAAK,kCAAkC,EACxC,MAAM,8BAA8B,CAAC;AAEtC,eAAO,MAAM,+BAA+B,2BAA2B,CAAC;AAIxE,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;IACzC,SAAS,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;IACvD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,wBAAwB,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,0BAA0B,EAAE,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAEzE,wBAAgB,uBAAuB,IAAI,wBAAwB,EAAE,CAEpE;AAED,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,MAAM,GAAG,wBAAwB,GAAG,IAAI,CAG1F;AAED,wBAAsB,kCAAkC,CACtD,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAmDrC;AAED,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,wBAAwB,CAAC,CAwBnC;AAED,wBAAsB,oCAAoC,CACxD,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,SAAS,wBAAwB,EAAE,GAC5C,OAAO,CAAC,MAAM,CAAC,CAUjB"}
|
package/dist/adapter-project.js
DELETED
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { execFile } from "node:child_process";
|
|
3
|
-
import { promises as fs } from "node:fs";
|
|
4
|
-
import os from "node:os";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import { promisify } from "node:util";
|
|
7
|
-
import { builtinWorkbenchAdapterManifest, builtinWorkbenchAdapterManifests, } from "@workbench-ai/workbench-built-in-adapters";
|
|
8
|
-
import { assertWorkbenchAdapterOperationSupport, collectWorkbenchAdapterOperationRequirements, parseWorkbenchAdapterManifest, } from "@workbench-ai/workbench-protocol";
|
|
9
|
-
import { composeRuntimeDockerfileWithAdapterInstallers, engineResolveInvocationForSpec, } from "@workbench-ai/workbench-core";
|
|
10
|
-
export const WORKBENCH_ADAPTER_MANIFEST_FILE = "workbench.adapter.yaml";
|
|
11
|
-
const execFileAsync = promisify(execFile);
|
|
12
|
-
export function defaultAdapterManifests() {
|
|
13
|
-
return builtinWorkbenchAdapterManifests();
|
|
14
|
-
}
|
|
15
|
-
export function resolveDefaultWorkbenchAdapter(id) {
|
|
16
|
-
const manifest = builtinWorkbenchAdapterManifest(id);
|
|
17
|
-
return manifest ? resolvedDefaultAdapter(manifest) : null;
|
|
18
|
-
}
|
|
19
|
-
export async function resolveWorkbenchAdaptersForProject(dir, spec) {
|
|
20
|
-
const adapters = new Map();
|
|
21
|
-
for (const id of topLevelAdapterIds(spec)) {
|
|
22
|
-
const defaultAdapter = resolveDefaultWorkbenchAdapter(id);
|
|
23
|
-
if (defaultAdapter) {
|
|
24
|
-
adapters.set(id, defaultAdapter);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
for (const source of spec.adapters) {
|
|
28
|
-
const adapter = await resolveProjectAdapterSource(dir, source);
|
|
29
|
-
const existing = adapters.get(adapter.manifest.id);
|
|
30
|
-
const override = adapterOverridesDefault(adapter);
|
|
31
|
-
const resolvedAdapter = {
|
|
32
|
-
...adapter,
|
|
33
|
-
...(override ? { overridesDefault: true } : {}),
|
|
34
|
-
};
|
|
35
|
-
if (existing?.kind === "default") {
|
|
36
|
-
adapters.set(adapter.manifest.id, resolvedAdapter);
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
if (existing && existing.source !== adapter.source) {
|
|
40
|
-
throw new Error(`Adapter id ${adapter.manifest.id} is provided by both ${existing.source} and ${adapter.source}. Remove one adapter source.`);
|
|
41
|
-
}
|
|
42
|
-
adapters.set(adapter.manifest.id, resolvedAdapter);
|
|
43
|
-
}
|
|
44
|
-
let discovered = true;
|
|
45
|
-
while (discovered) {
|
|
46
|
-
discovered = false;
|
|
47
|
-
const manifestById = new Map([...adapters.values()].map((adapter) => [adapter.manifest.id, adapter.manifest]));
|
|
48
|
-
for (const id of requiredAdapterIds(spec, [...manifestById.values()])) {
|
|
49
|
-
if (adapters.has(id)) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
const defaultAdapter = resolveDefaultWorkbenchAdapter(id);
|
|
53
|
-
if (defaultAdapter) {
|
|
54
|
-
adapters.set(id, defaultAdapter);
|
|
55
|
-
discovered = true;
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
throw new Error(`Adapter ${id} is referenced by benchmark/candidate YAML but is not installed. List its source under adapters in the YAML file that uses it.`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
assertWorkbenchAdapterOperationSupport(rootAdapterOperationRequirements(spec), [...adapters.values()].map((adapter) => adapter.manifest));
|
|
62
|
-
return [...adapters.values()].sort((left, right) => left.manifest.id.localeCompare(right.manifest.id));
|
|
63
|
-
}
|
|
64
|
-
export async function resolveProjectAdapterSource(dir, source) {
|
|
65
|
-
if (source.startsWith("npm:")) {
|
|
66
|
-
return await resolveNpmAdapterSource(source);
|
|
67
|
-
}
|
|
68
|
-
if (source.startsWith("git:")) {
|
|
69
|
-
return await resolveGitAdapterSource(source);
|
|
70
|
-
}
|
|
71
|
-
const isPathSource = source.startsWith(".") || source.startsWith("/") || source.includes("/");
|
|
72
|
-
if (!isPathSource) {
|
|
73
|
-
throw new Error(`Adapter source ${source} is not installed locally. Use a benchmark-contained path source, npm: package, or git: URL.`);
|
|
74
|
-
}
|
|
75
|
-
const root = path.resolve(dir, source);
|
|
76
|
-
const relative = path.relative(dir, root);
|
|
77
|
-
if (relative.startsWith("..") || path.isAbsolute(relative)) {
|
|
78
|
-
throw new Error(`Adapter source ${source} is outside the benchmark source root. Copy it into the benchmark source tree and list that benchmark-contained path.`);
|
|
79
|
-
}
|
|
80
|
-
return await resolveAdapterFromRoot({
|
|
81
|
-
declaredSource: source,
|
|
82
|
-
source: normalizeSourcePath(relative || "."),
|
|
83
|
-
kind: "path",
|
|
84
|
-
root,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
export async function composeRuntimeDockerfileWithAdapters(dockerfile, adapters) {
|
|
88
|
-
return composeRuntimeDockerfileWithAdapterInstallers(dockerfile, adapters.map((adapter) => ({
|
|
89
|
-
id: adapter.manifest.id,
|
|
90
|
-
source: adapter.source,
|
|
91
|
-
setup: adapter.manifest.setup,
|
|
92
|
-
files: adapter.files,
|
|
93
|
-
})));
|
|
94
|
-
}
|
|
95
|
-
function resolvedDefaultAdapter(manifest) {
|
|
96
|
-
const manifestHash = sha256(JSON.stringify(manifest));
|
|
97
|
-
return {
|
|
98
|
-
source: `default:${manifest.id}`,
|
|
99
|
-
declaredSource: `default:${manifest.id}`,
|
|
100
|
-
kind: "default",
|
|
101
|
-
stability: "default",
|
|
102
|
-
manifest: {
|
|
103
|
-
...manifest,
|
|
104
|
-
operations: JSON.parse(JSON.stringify(manifest.operations)),
|
|
105
|
-
setup: [...manifest.setup],
|
|
106
|
-
...(manifest.slots ? { slots: JSON.parse(JSON.stringify(manifest.slots)) } : {}),
|
|
107
|
-
},
|
|
108
|
-
manifestHash,
|
|
109
|
-
contentHash: manifestHash,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function adapterOverridesDefault(adapter) {
|
|
113
|
-
return adapter.kind !== "default" && builtinWorkbenchAdapterManifest(adapter.manifest.id) !== null;
|
|
114
|
-
}
|
|
115
|
-
async function resolveNpmAdapterSource(source) {
|
|
116
|
-
const specifier = source.slice("npm:".length).trim();
|
|
117
|
-
if (!specifier) {
|
|
118
|
-
throw new Error("npm adapter source must include a package specifier.");
|
|
119
|
-
}
|
|
120
|
-
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "workbench-adapter-npm-"));
|
|
121
|
-
try {
|
|
122
|
-
const npmCache = path.join(tempRoot, "npm-cache");
|
|
123
|
-
const npmLogs = path.join(tempRoot, "npm-logs");
|
|
124
|
-
await fs.mkdir(npmCache, { recursive: true });
|
|
125
|
-
await fs.mkdir(npmLogs, { recursive: true });
|
|
126
|
-
const pack = await execFileUtf8("npm", [
|
|
127
|
-
"pack",
|
|
128
|
-
specifier,
|
|
129
|
-
"--json",
|
|
130
|
-
"--pack-destination",
|
|
131
|
-
tempRoot,
|
|
132
|
-
], {
|
|
133
|
-
env: {
|
|
134
|
-
...process.env,
|
|
135
|
-
NPM_CONFIG_CACHE: npmCache,
|
|
136
|
-
NPM_CONFIG_LOGS_DIR: npmLogs,
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
const [entry] = JSON.parse(pack.stdout);
|
|
140
|
-
if (!entry?.name || !entry.version || !entry.filename) {
|
|
141
|
-
throw new Error(`npm pack ${specifier} did not return package metadata.`);
|
|
142
|
-
}
|
|
143
|
-
const tarballPath = path.join(tempRoot, entry.filename);
|
|
144
|
-
const extractRoot = path.join(tempRoot, "extract");
|
|
145
|
-
await fs.mkdir(extractRoot, { recursive: true });
|
|
146
|
-
await execFileUtf8("tar", ["-xzf", tarballPath, "-C", extractRoot]);
|
|
147
|
-
return await resolveAdapterFromRoot({
|
|
148
|
-
declaredSource: source,
|
|
149
|
-
source: `npm:${entry.name}@${entry.version}`,
|
|
150
|
-
kind: "npm",
|
|
151
|
-
stability: npmSourceStability(specifier),
|
|
152
|
-
root: path.join(extractRoot, "package"),
|
|
153
|
-
integrity: entry.integrity,
|
|
154
|
-
includeBuildArtifacts: true,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
finally {
|
|
158
|
-
await fs.rm(tempRoot, { recursive: true, force: true }).catch(() => undefined);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
async function resolveGitAdapterSource(source) {
|
|
162
|
-
const specifier = source.slice("git:".length).trim();
|
|
163
|
-
if (!specifier) {
|
|
164
|
-
throw new Error("git adapter source must include a repository URL.");
|
|
165
|
-
}
|
|
166
|
-
const { url, ref } = parseGitSource(specifier);
|
|
167
|
-
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "workbench-adapter-git-"));
|
|
168
|
-
const checkoutRoot = path.join(tempRoot, "checkout");
|
|
169
|
-
try {
|
|
170
|
-
await cloneGitAdapter(url, ref, checkoutRoot);
|
|
171
|
-
const commit = (await execFileUtf8("git", ["-C", checkoutRoot, "rev-parse", "HEAD"])).stdout.trim();
|
|
172
|
-
return await resolveAdapterFromRoot({
|
|
173
|
-
declaredSource: source,
|
|
174
|
-
source: `git:${url}#${commit}`,
|
|
175
|
-
kind: "git",
|
|
176
|
-
stability: gitSourceStability(ref),
|
|
177
|
-
root: checkoutRoot,
|
|
178
|
-
integrity: commit,
|
|
179
|
-
includeBuildArtifacts: true,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
finally {
|
|
183
|
-
await fs.rm(tempRoot, { recursive: true, force: true }).catch(() => undefined);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
async function resolveAdapterFromRoot(args) {
|
|
187
|
-
const manifestPath = path.join(args.root, WORKBENCH_ADAPTER_MANIFEST_FILE);
|
|
188
|
-
const manifestSource = await fs.readFile(manifestPath, "utf8");
|
|
189
|
-
const manifest = parseWorkbenchAdapterManifest(manifestSource, manifestPath);
|
|
190
|
-
const files = await readAdapterSourceFiles(args.root, {
|
|
191
|
-
includeBuildArtifacts: args.includeBuildArtifacts === true,
|
|
192
|
-
});
|
|
193
|
-
const manifestHash = sha256(manifestSource);
|
|
194
|
-
const contentHash = sha256(JSON.stringify(files.map((file) => ({
|
|
195
|
-
path: file.path,
|
|
196
|
-
executable: file.executable,
|
|
197
|
-
contentHash: sha256(file.content),
|
|
198
|
-
}))));
|
|
199
|
-
return {
|
|
200
|
-
source: args.source,
|
|
201
|
-
declaredSource: args.declaredSource ?? args.source,
|
|
202
|
-
kind: args.kind,
|
|
203
|
-
stability: args.stability ?? "local",
|
|
204
|
-
manifest,
|
|
205
|
-
root: args.root,
|
|
206
|
-
files,
|
|
207
|
-
...(args.integrity ? { integrity: args.integrity } : {}),
|
|
208
|
-
manifestHash,
|
|
209
|
-
contentHash,
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
async function cloneGitAdapter(url, ref, checkoutRoot) {
|
|
213
|
-
if (ref) {
|
|
214
|
-
try {
|
|
215
|
-
await execFileUtf8("git", ["clone", "--depth", "1", "--branch", ref, url, checkoutRoot]);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
catch {
|
|
219
|
-
await fs.rm(checkoutRoot, { recursive: true, force: true }).catch(() => undefined);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
await execFileUtf8("git", ["clone", "--depth", "1", url, checkoutRoot]);
|
|
223
|
-
if (ref) {
|
|
224
|
-
await execFileUtf8("git", ["-C", checkoutRoot, "fetch", "--depth", "1", "origin", ref]);
|
|
225
|
-
await execFileUtf8("git", ["-C", checkoutRoot, "checkout", "FETCH_HEAD"]);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
function parseGitSource(specifier) {
|
|
229
|
-
const hashIndex = specifier.lastIndexOf("#");
|
|
230
|
-
if (hashIndex < 0) {
|
|
231
|
-
return { url: specifier, ref: null };
|
|
232
|
-
}
|
|
233
|
-
const url = specifier.slice(0, hashIndex);
|
|
234
|
-
const ref = specifier.slice(hashIndex + 1);
|
|
235
|
-
if (!url || !ref) {
|
|
236
|
-
throw new Error(`Invalid git adapter source: git:${specifier}`);
|
|
237
|
-
}
|
|
238
|
-
return { url, ref };
|
|
239
|
-
}
|
|
240
|
-
function npmSourceStability(specifier) {
|
|
241
|
-
return npmSpecifierHasExactVersion(specifier) ? "pinned" : "floating";
|
|
242
|
-
}
|
|
243
|
-
function npmSpecifierHasExactVersion(specifier) {
|
|
244
|
-
const atIndex = specifier.lastIndexOf("@");
|
|
245
|
-
if (atIndex <= 0) {
|
|
246
|
-
return false;
|
|
247
|
-
}
|
|
248
|
-
const version = specifier.slice(atIndex + 1);
|
|
249
|
-
return /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/u.test(version);
|
|
250
|
-
}
|
|
251
|
-
function gitSourceStability(ref) {
|
|
252
|
-
return ref && /^[0-9a-f]{7,40}$/iu.test(ref) ? "pinned" : "floating";
|
|
253
|
-
}
|
|
254
|
-
function topLevelAdapterIds(spec) {
|
|
255
|
-
return [...new Set(rootAdapterInvocations(spec).map((invocation) => invocation.use))];
|
|
256
|
-
}
|
|
257
|
-
function rootAdapterOperationRequirements(spec) {
|
|
258
|
-
return [
|
|
259
|
-
{ invocation: engineResolveInvocationForSpec(spec), operation: "engine.resolve" },
|
|
260
|
-
{ invocation: spec.engineRun, operation: "engine.run" },
|
|
261
|
-
...(spec.improve ? [{ invocation: spec.improve, operation: "candidate.improve" }] : []),
|
|
262
|
-
{ invocation: spec.run, operation: "candidate.run" },
|
|
263
|
-
];
|
|
264
|
-
}
|
|
265
|
-
function rootAdapterInvocations(spec) {
|
|
266
|
-
return rootAdapterOperationRequirements(spec).map((requirement) => requirement.invocation);
|
|
267
|
-
}
|
|
268
|
-
function requiredAdapterIds(spec, manifests) {
|
|
269
|
-
const ids = new Set();
|
|
270
|
-
for (const requirement of collectWorkbenchAdapterOperationRequirements(rootAdapterOperationRequirements(spec), manifests)) {
|
|
271
|
-
ids.add(requirement.invocation.use);
|
|
272
|
-
}
|
|
273
|
-
return [...ids];
|
|
274
|
-
}
|
|
275
|
-
async function readAdapterSourceFiles(root, options = {}) {
|
|
276
|
-
const files = [];
|
|
277
|
-
async function visit(relativeDir) {
|
|
278
|
-
const absoluteDir = path.join(root, relativeDir);
|
|
279
|
-
const entries = await fs.readdir(absoluteDir, { withFileTypes: true });
|
|
280
|
-
for (const entry of entries) {
|
|
281
|
-
if (entry.name === "node_modules" ||
|
|
282
|
-
entry.name === ".git" ||
|
|
283
|
-
(!options.includeBuildArtifacts && entry.name === "dist")) {
|
|
284
|
-
continue;
|
|
285
|
-
}
|
|
286
|
-
const relativePath = normalizeSourcePath(path.join(relativeDir, entry.name));
|
|
287
|
-
const absolutePath = path.join(root, relativePath);
|
|
288
|
-
if (entry.isDirectory()) {
|
|
289
|
-
await visit(relativePath);
|
|
290
|
-
continue;
|
|
291
|
-
}
|
|
292
|
-
if (!entry.isFile()) {
|
|
293
|
-
continue;
|
|
294
|
-
}
|
|
295
|
-
const content = await fs.readFile(absolutePath, "utf8");
|
|
296
|
-
const stat = await fs.stat(absolutePath);
|
|
297
|
-
files.push({
|
|
298
|
-
path: relativePath,
|
|
299
|
-
content,
|
|
300
|
-
executable: Boolean(stat.mode & 0o111),
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
await visit("");
|
|
305
|
-
return files.sort((left, right) => left.path.localeCompare(right.path));
|
|
306
|
-
}
|
|
307
|
-
function normalizeSourcePath(value) {
|
|
308
|
-
return value.replace(/\\/gu, "/").replace(/^\.?\//u, "");
|
|
309
|
-
}
|
|
310
|
-
async function execFileUtf8(command, args, options = {}) {
|
|
311
|
-
try {
|
|
312
|
-
return await execFileAsync(command, [...args], {
|
|
313
|
-
encoding: "utf8",
|
|
314
|
-
...(options.env ? { env: options.env } : {}),
|
|
315
|
-
maxBuffer: 20 * 1024 * 1024,
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
catch (error) {
|
|
319
|
-
const record = error;
|
|
320
|
-
const stderr = typeof record.stderr === "string" ? record.stderr.trim() : "";
|
|
321
|
-
const stdout = typeof record.stdout === "string" ? record.stdout.trim() : "";
|
|
322
|
-
throw new Error([
|
|
323
|
-
`${command} ${args.join(" ")} failed.`,
|
|
324
|
-
stderr,
|
|
325
|
-
stdout,
|
|
326
|
-
record.message,
|
|
327
|
-
].filter(Boolean).join("\n"));
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
function sha256(value) {
|
|
331
|
-
return createHash("sha256").update(value).digest("hex");
|
|
332
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type WorkbenchProjectStateSource } from "@workbench-ai/workbench-core";
|
|
2
|
-
import { type LocalProjectSource } from "./project-source.js";
|
|
3
|
-
export declare function localBenchmarkFingerprint(project: LocalProjectSource): string;
|
|
4
|
-
export declare function projectStateBenchmarkFingerprint(source: WorkbenchProjectStateSource): string;
|
|
5
|
-
export declare function localCandidateFingerprint(project: LocalProjectSource): string;
|
|
6
|
-
//# sourceMappingURL=benchmark-fingerprint.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"benchmark-fingerprint.d.ts","sourceRoot":"","sources":["../src/benchmark-fingerprint.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,2BAA2B,EACjC,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,qBAAqB,CAAC;AAE7B,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAW7E;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,2BAA2B,GAAG,MAAM,CAU5F;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAO7E"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { engineResolveBindingForSpec, workbenchBenchmarkContentFingerprint, workbenchCandidateContentFingerprint, } from "@workbench-ai/workbench-core";
|
|
2
|
-
import { remoteEngineResolveFiles, } from "./project-source.js";
|
|
3
|
-
export function localBenchmarkFingerprint(project) {
|
|
4
|
-
return workbenchBenchmarkContentFingerprint({
|
|
5
|
-
sourceYaml: project.specSource,
|
|
6
|
-
engineResolveFiles: remoteEngineResolveFiles(project).map(toSurfaceFile),
|
|
7
|
-
engineResolveBinding: engineResolveBindingForSpec(project.spec),
|
|
8
|
-
adapterFiles: project.adapterFiles.map(toSurfaceFile),
|
|
9
|
-
adapterManifests: project.adapters.map((adapter) => adapter.manifest),
|
|
10
|
-
runtimeFiles: project.dockerfileFiles.map(toSurfaceFile),
|
|
11
|
-
resources: project.spec.environment.resources ?? {},
|
|
12
|
-
network: project.spec.environment.network?.egress === "open" ? "on" : "off",
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
export function projectStateBenchmarkFingerprint(source) {
|
|
16
|
-
return workbenchBenchmarkContentFingerprint({
|
|
17
|
-
sourceYaml: source.source,
|
|
18
|
-
engineResolveFiles: source.engineResolveFiles,
|
|
19
|
-
engineResolveBinding: source.engineResolveBinding,
|
|
20
|
-
adapterFiles: source.adapterFiles,
|
|
21
|
-
runtimeFiles: source.runtimeFiles,
|
|
22
|
-
resources: source.resources,
|
|
23
|
-
network: source.network,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
export function localCandidateFingerprint(project) {
|
|
27
|
-
return workbenchCandidateContentFingerprint({
|
|
28
|
-
sourceYaml: project.specSource,
|
|
29
|
-
candidateFiles: project.candidateFiles.map(toSurfaceFile),
|
|
30
|
-
adapterFiles: project.adapterFiles.map(toSurfaceFile),
|
|
31
|
-
adapterManifests: project.adapters.map((adapter) => adapter.manifest),
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function toSurfaceFile(file) {
|
|
35
|
-
return {
|
|
36
|
-
path: file.path,
|
|
37
|
-
kind: "kind" in file ? file.kind : file.encoding === "base64" ? "binary" : "text",
|
|
38
|
-
encoding: file.encoding ?? "utf8",
|
|
39
|
-
content: file.content,
|
|
40
|
-
executable: file.executable === true,
|
|
41
|
-
};
|
|
42
|
-
}
|
package/dist/command-model.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const LOCAL_DEV_OPEN_LIFECYCLE_NOTE = "Keep this command running while using the local web view; Ctrl-C stops the server and the page will stop working.";
|
|
2
|
-
export declare const REMOTE_WATCH_LIFECYCLE_NOTE: string;
|
|
3
|
-
export declare const rootUsage: string;
|
|
4
|
-
export declare function commandUsage(commandPath: string): string | null;
|
|
5
|
-
//# sourceMappingURL=command-model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command-model.d.ts","sourceRoot":"","sources":["../src/command-model.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,6BAA6B,sHAC2E,CAAC;AAOtH,eAAO,MAAM,2BAA2B,QAA0C,CAAC;AAiFnF,eAAO,MAAM,SAAS,QAAuB,CAAC;AAsc9C,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE/D"}
|