@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,9 +0,0 @@
|
|
|
1
|
-
import { type WorkbenchInspection } from "@workbench-ai/workbench-core";
|
|
2
|
-
import { type LocalProjectSource } from "./project-source.js";
|
|
3
|
-
export interface LocalWorkbenchInspectionOptions {
|
|
4
|
-
workspace: string;
|
|
5
|
-
readProjectSource?: () => Promise<LocalProjectSource>;
|
|
6
|
-
}
|
|
7
|
-
export declare function createLocalWorkbenchInspection(options: LocalWorkbenchInspectionOptions): WorkbenchInspection;
|
|
8
|
-
export declare function createLocalProjectSourceReader(workspace: string): () => Promise<LocalProjectSource>;
|
|
9
|
-
//# sourceMappingURL=local-inspection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local-inspection.d.ts","sourceRoot":"","sources":["../src/local-inspection.ts"],"names":[],"mappings":"AAEA,OAAO,EAgBL,KAAK,mBAAmB,EAIzB,MAAM,8BAA8B,CAAC;AAetC,OAAO,EAGL,KAAK,kBAAkB,EAExB,MAAM,qBAAqB,CAAC;AAgB7B,MAAM,WAAW,+BAA+B;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACvD;AAED,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,+BAA+B,GACvC,mBAAmB,CA2DrB;AAkBD,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,GAChB,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAiBnC"}
|
package/dist/local-inspection.js
DELETED
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { WorkbenchInspectionError, candidateRecordWithoutDerivedFields, candidateSummaryFromRecord, createCandidateFilePreview, createWorkbenchInspection, loadAuthoredWorkbenchSourceDocument, selectedFilePath, summarizeCandidateFiles, traceSessionLabel, } from "@workbench-ai/workbench-core";
|
|
3
|
-
import { localBenchmarkFingerprint } from "./benchmark-fingerprint.js";
|
|
4
|
-
import { loadLocalArchiveIndex, readLocalCandidateFilesForId, readLocalCandidateRecord, readLocalEvaluationRecord, readLocalExecutionFiles, readLocalJobInRun, readLocalRunJobs, readLocalRunRecord, } from "./local-archive.js";
|
|
5
|
-
import { readLocalAuthoredProjectSource, readLocalProjectSource, WORKBENCH_BENCHMARK_FILE, } from "./project-source.js";
|
|
6
|
-
const PROJECT_SOURCE_CACHE_TTL_MS = 1000;
|
|
7
|
-
export function createLocalWorkbenchInspection(options) {
|
|
8
|
-
const context = {
|
|
9
|
-
workspace: path.resolve(options.workspace),
|
|
10
|
-
readProjectSource: options.readProjectSource ??
|
|
11
|
-
createLocalProjectSourceReader(options.workspace),
|
|
12
|
-
};
|
|
13
|
-
const backend = {
|
|
14
|
-
projectId: "local",
|
|
15
|
-
snapshot: () => localBenchmarkSnapshot(context),
|
|
16
|
-
spec: (input) => localSpecDocument(context, input.fingerprint),
|
|
17
|
-
sourceFiles: async (input) => {
|
|
18
|
-
const files = await localBenchmarkMountedFiles(context, input.fingerprint);
|
|
19
|
-
return summarizeCandidateFiles(files, files.map((file) => file.path));
|
|
20
|
-
},
|
|
21
|
-
sourceFileSurface: async (input) => {
|
|
22
|
-
const files = await localBenchmarkMountedFiles(context, input.fingerprint);
|
|
23
|
-
return localFileSurface(files, files.map((file) => file.path), input.path, input.view);
|
|
24
|
-
},
|
|
25
|
-
candidate: (input) => readCandidateForInspection(context.workspace, input.id),
|
|
26
|
-
candidateFiles: async (input) => {
|
|
27
|
-
const candidate = await readCandidateForInspection(context.workspace, input.id);
|
|
28
|
-
return summarizeCandidateFiles(await readCandidateFilesForInspection(context.workspace, input.id), candidate.fileChanges);
|
|
29
|
-
},
|
|
30
|
-
candidateFileSurface: async (input) => {
|
|
31
|
-
const candidate = await readCandidateForInspection(context.workspace, input.id);
|
|
32
|
-
return localFileSurface(await readCandidateFilesForInspection(context.workspace, input.id), candidate.fileChanges, input.path, input.view);
|
|
33
|
-
},
|
|
34
|
-
evaluation: (input) => readEvaluationForInspection(context.workspace, input.id),
|
|
35
|
-
run: async (input) => {
|
|
36
|
-
const run = await readRunForInspection(context.workspace, input.id);
|
|
37
|
-
return {
|
|
38
|
-
run,
|
|
39
|
-
...(input.includeJobs
|
|
40
|
-
? { jobs: await readLocalRunJobs(context.workspace, input.id) }
|
|
41
|
-
: {}),
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
jobInRun: (input) => readExecutionJobForRun(context.workspace, input.runId, input.jobId),
|
|
45
|
-
executionFiles: async (input) => {
|
|
46
|
-
const files = await readExecutionFilesForRun(context.workspace, input.runId, input.jobId);
|
|
47
|
-
return summarizeCandidateFiles(files, files.map((file) => file.path));
|
|
48
|
-
},
|
|
49
|
-
executionFileSurface: async (input) => {
|
|
50
|
-
const files = await readExecutionFilesForRun(context.workspace, input.runId, input.jobId);
|
|
51
|
-
return localFileSurface(files, files.map((file) => file.path), input.path, input.view);
|
|
52
|
-
},
|
|
53
|
-
traceForJob: readLocalAggregateTrace,
|
|
54
|
-
traceSessionsForJob: readLocalTraceSessions,
|
|
55
|
-
};
|
|
56
|
-
return createWorkbenchInspection(backend);
|
|
57
|
-
}
|
|
58
|
-
function localFileSurface(files, changedPaths, path, view = "rendered") {
|
|
59
|
-
const summaries = summarizeCandidateFiles(files, changedPaths);
|
|
60
|
-
const previewPath = selectedFilePath(path, summaries);
|
|
61
|
-
return {
|
|
62
|
-
files: summaries,
|
|
63
|
-
preview: previewPath
|
|
64
|
-
? createCandidateFilePreview({ files, path: previewPath, view })
|
|
65
|
-
: null,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
export function createLocalProjectSourceReader(workspace) {
|
|
69
|
-
const resolvedWorkspace = path.resolve(workspace);
|
|
70
|
-
let cached = null;
|
|
71
|
-
return () => {
|
|
72
|
-
const now = Date.now();
|
|
73
|
-
if (cached && now - cached.loadedAt < PROJECT_SOURCE_CACHE_TTL_MS) {
|
|
74
|
-
return cached.promise;
|
|
75
|
-
}
|
|
76
|
-
const promise = readLocalProjectSource(resolvedWorkspace);
|
|
77
|
-
cached = { loadedAt: now, promise };
|
|
78
|
-
promise.catch(() => {
|
|
79
|
-
if (cached?.promise === promise) {
|
|
80
|
-
cached = null;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
return promise;
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
async function localBenchmarkSnapshot(context) {
|
|
87
|
-
const { workspace } = context;
|
|
88
|
-
const snapshot = await loadLocalArchiveIndex(workspace);
|
|
89
|
-
const candidates = snapshot.candidates.filter(isInspectableCandidateRecord);
|
|
90
|
-
const summaries = candidates.map(candidateSummaryFromRecord);
|
|
91
|
-
const activeId = snapshot.activeId && candidates.some((candidate) => candidate.id === snapshot.activeId)
|
|
92
|
-
? snapshot.activeId
|
|
93
|
-
: null;
|
|
94
|
-
const currentBenchmarkFingerprint = await readCurrentBenchmarkFingerprint(context);
|
|
95
|
-
return {
|
|
96
|
-
workspaceRoot: path.resolve(workspace),
|
|
97
|
-
activeId,
|
|
98
|
-
currentBenchmarkFingerprint,
|
|
99
|
-
summaries,
|
|
100
|
-
evaluations: snapshot.evaluations.map(evaluationSummary),
|
|
101
|
-
runs: snapshot.runs.map(publicLocalRunSummary),
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
async function localSpecDocument(context, benchmarkFingerprint) {
|
|
105
|
-
const { workspace } = context;
|
|
106
|
-
const projectSource = await context.readProjectSource().catch(() => null);
|
|
107
|
-
const authoredSource = projectSource
|
|
108
|
-
? null
|
|
109
|
-
: await readLocalAuthoredProjectSource(workspace).catch(() => null);
|
|
110
|
-
const requestedFingerprint = normalizeOptionalFingerprint(benchmarkFingerprint);
|
|
111
|
-
const currentFingerprint = projectSource
|
|
112
|
-
? localBenchmarkFingerprint(projectSource)
|
|
113
|
-
: null;
|
|
114
|
-
if (requestedFingerprint &&
|
|
115
|
-
currentFingerprint &&
|
|
116
|
-
requestedFingerprint !== currentFingerprint) {
|
|
117
|
-
const snapshot = await loadLocalArchiveIndex(workspace);
|
|
118
|
-
const source = localHistoricalBenchmarkSource(snapshot, requestedFingerprint);
|
|
119
|
-
if (source) {
|
|
120
|
-
return loadAuthoredWorkbenchSourceDocument({
|
|
121
|
-
sourceYaml: source.sourceYaml,
|
|
122
|
-
path: WORKBENCH_BENCHMARK_FILE,
|
|
123
|
-
sourceFiles: [{
|
|
124
|
-
path: WORKBENCH_BENCHMARK_FILE,
|
|
125
|
-
kind: "text",
|
|
126
|
-
encoding: "utf8",
|
|
127
|
-
content: source.sourceYaml,
|
|
128
|
-
executable: false,
|
|
129
|
-
}],
|
|
130
|
-
cases: source.engineResolveFiles,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
throw new WorkbenchInspectionError(`Benchmark version not found: ${requestedFingerprint}`, { status: 404 });
|
|
134
|
-
}
|
|
135
|
-
const sourceYaml = projectSource?.specSource ?? authoredSource?.specSource ?? "";
|
|
136
|
-
const cases = projectSource
|
|
137
|
-
? caseSummaryFilesFromEngineCases(projectSource.engineCases, projectSource.engineResolveFiles)
|
|
138
|
-
: [];
|
|
139
|
-
return loadAuthoredWorkbenchSourceDocument({
|
|
140
|
-
sourceYaml,
|
|
141
|
-
path: WORKBENCH_BENCHMARK_FILE,
|
|
142
|
-
sourceFiles: projectSource?.sourceFiles ?? authoredSource?.sourceFiles,
|
|
143
|
-
cases,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
async function localBenchmarkMountedFiles(context, benchmarkFingerprint) {
|
|
147
|
-
const requestedFingerprint = normalizeOptionalFingerprint(benchmarkFingerprint);
|
|
148
|
-
const { workspace } = context;
|
|
149
|
-
const projectSource = await context.readProjectSource();
|
|
150
|
-
const currentFingerprint = localBenchmarkFingerprint(projectSource);
|
|
151
|
-
if (requestedFingerprint &&
|
|
152
|
-
currentFingerprint &&
|
|
153
|
-
requestedFingerprint !== currentFingerprint) {
|
|
154
|
-
const snapshot = await loadLocalArchiveIndex(workspace);
|
|
155
|
-
const source = localHistoricalBenchmarkSource(snapshot, requestedFingerprint);
|
|
156
|
-
if (source) {
|
|
157
|
-
return source.engineResolveFiles.map((file) => ({ ...file }));
|
|
158
|
-
}
|
|
159
|
-
throw new WorkbenchInspectionError(`Benchmark version not found: ${requestedFingerprint}`, { status: 404 });
|
|
160
|
-
}
|
|
161
|
-
return inspectableEngineCaseFiles(projectSource.engineCases);
|
|
162
|
-
}
|
|
163
|
-
function publicLocalRunSummary(run) {
|
|
164
|
-
const { executionFingerprint: _executionFingerprint, input: _input, ...summary } = run;
|
|
165
|
-
return summary;
|
|
166
|
-
}
|
|
167
|
-
async function readCurrentBenchmarkFingerprint(context) {
|
|
168
|
-
return await context.readProjectSource()
|
|
169
|
-
.then(localBenchmarkFingerprint)
|
|
170
|
-
.catch(() => null);
|
|
171
|
-
}
|
|
172
|
-
function caseSummaryFilesFromEngineCases(engineCases, files) {
|
|
173
|
-
const existingCaseIds = new Set(files.flatMap((file) => {
|
|
174
|
-
const normalized = file.path.replace(/\\/gu, "/").replace(/^\/+/u, "");
|
|
175
|
-
const slash = normalized.indexOf("/");
|
|
176
|
-
return slash > 0 ? [normalized.slice(0, slash)] : [];
|
|
177
|
-
}));
|
|
178
|
-
return [
|
|
179
|
-
...files.map((file) => ({ ...file })),
|
|
180
|
-
...engineCases
|
|
181
|
-
.filter((engineCase) => !existingCaseIds.has(engineCase.id))
|
|
182
|
-
.map((engineCase) => ({
|
|
183
|
-
path: `${engineCase.id}/.workbench-case.json`,
|
|
184
|
-
encoding: "utf8",
|
|
185
|
-
content: `${JSON.stringify({ id: engineCase.id })}\n`,
|
|
186
|
-
executable: false,
|
|
187
|
-
})),
|
|
188
|
-
];
|
|
189
|
-
}
|
|
190
|
-
function localHistoricalBenchmarkSource(snapshot, benchmarkFingerprint) {
|
|
191
|
-
for (const run of snapshot.runs) {
|
|
192
|
-
if (run.benchmarkFingerprint !== benchmarkFingerprint) {
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
const source = readRunSourceInput(run);
|
|
196
|
-
if (source) {
|
|
197
|
-
return source;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
function inspectableEngineCaseFiles(engineCases) {
|
|
203
|
-
return engineCases.flatMap((bundle) => engineCaseFiles(bundle).map((file) => ({
|
|
204
|
-
...file,
|
|
205
|
-
path: `${bundle.id}/${file.path}`,
|
|
206
|
-
}))).sort((left, right) => left.path.localeCompare(right.path));
|
|
207
|
-
}
|
|
208
|
-
function engineCaseFiles(bundle) {
|
|
209
|
-
const buckets = bundle.files;
|
|
210
|
-
return buckets.source?.length
|
|
211
|
-
? buckets.source
|
|
212
|
-
: [...(buckets.public ?? []), ...(buckets.private ?? [])];
|
|
213
|
-
}
|
|
214
|
-
function isInspectableCandidateRecord(candidate) {
|
|
215
|
-
return Boolean(candidate.eval || asRecord(asRecord(candidate.meta)?.source));
|
|
216
|
-
}
|
|
217
|
-
function evaluationSummary(evaluation) {
|
|
218
|
-
const { evaluation: _evaluation, ...summary } = evaluation;
|
|
219
|
-
return summary;
|
|
220
|
-
}
|
|
221
|
-
async function readCandidateForInspection(workspace, candidateId) {
|
|
222
|
-
const candidate = await readArchiveRecord("Candidate", candidateId, () => readLocalCandidateRecord(workspace, candidateId));
|
|
223
|
-
return candidateRecordWithoutDerivedFields(candidate);
|
|
224
|
-
}
|
|
225
|
-
async function readEvaluationForInspection(workspace, evaluationId) {
|
|
226
|
-
return await readArchiveRecord("Evaluation", evaluationId, () => readLocalEvaluationRecord(workspace, evaluationId));
|
|
227
|
-
}
|
|
228
|
-
async function readRunForInspection(workspace, runId) {
|
|
229
|
-
return await readArchiveRecord("Run", runId, () => readLocalRunRecord(workspace, runId));
|
|
230
|
-
}
|
|
231
|
-
async function readCandidateFilesForInspection(workspace, candidateId) {
|
|
232
|
-
return await readArchiveRecord("Candidate", candidateId, () => readLocalCandidateFilesForId(workspace, candidateId));
|
|
233
|
-
}
|
|
234
|
-
function readRunSourceInput(run) {
|
|
235
|
-
const input = asRecord(run.input);
|
|
236
|
-
const sourceYaml = typeof input?.sourceYaml === "string" ? input.sourceYaml : null;
|
|
237
|
-
if (!input || !sourceYaml) {
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
240
|
-
const engineResolveFiles = Array.isArray(input.engineResolveFiles)
|
|
241
|
-
? input.engineResolveFiles
|
|
242
|
-
.map(readSurfaceSnapshotFile)
|
|
243
|
-
.filter((file) => file !== null)
|
|
244
|
-
.sort((left, right) => left.path.localeCompare(right.path))
|
|
245
|
-
: [];
|
|
246
|
-
return { sourceYaml, engineResolveFiles };
|
|
247
|
-
}
|
|
248
|
-
function readSurfaceSnapshotFile(value) {
|
|
249
|
-
const record = asRecord(value);
|
|
250
|
-
if (!record) {
|
|
251
|
-
return null;
|
|
252
|
-
}
|
|
253
|
-
const filePath = typeof record?.path === "string" ? record.path : "";
|
|
254
|
-
const content = typeof record?.content === "string" ? record.content : null;
|
|
255
|
-
if (!filePath || content === null) {
|
|
256
|
-
return null;
|
|
257
|
-
}
|
|
258
|
-
return {
|
|
259
|
-
path: filePath,
|
|
260
|
-
kind: record.kind === "binary" ? "binary" : "text",
|
|
261
|
-
encoding: record.encoding === "base64" ? "base64" : "utf8",
|
|
262
|
-
content,
|
|
263
|
-
executable: record.executable === true,
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
async function readArchiveRecord(kind, id, read) {
|
|
267
|
-
try {
|
|
268
|
-
return await read();
|
|
269
|
-
}
|
|
270
|
-
catch (error) {
|
|
271
|
-
if (error instanceof Error && error.message === `${kind} not found: ${id}`) {
|
|
272
|
-
throw new WorkbenchInspectionError(error.message, { status: 404 });
|
|
273
|
-
}
|
|
274
|
-
throw error;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
async function readExecutionFilesForRun(workspace, runId, jobId) {
|
|
278
|
-
await readExecutionJobForRun(workspace, runId, jobId);
|
|
279
|
-
return await readLocalExecutionFiles(workspace, jobId);
|
|
280
|
-
}
|
|
281
|
-
async function readExecutionJobForRun(workspace, runId, jobId) {
|
|
282
|
-
const job = await readLocalJobInRun(workspace, runId, jobId);
|
|
283
|
-
if (!job) {
|
|
284
|
-
throw new WorkbenchInspectionError(`Execution job not found: ${jobId}`, { status: 404 });
|
|
285
|
-
}
|
|
286
|
-
return job;
|
|
287
|
-
}
|
|
288
|
-
function readLocalAggregateTrace(job) {
|
|
289
|
-
const trace = job.trace;
|
|
290
|
-
if (!trace || typeof trace !== "object" || Array.isArray(trace)) {
|
|
291
|
-
return { trace_id: job.id, spans: [], events: [], summaries: [] };
|
|
292
|
-
}
|
|
293
|
-
const record = trace;
|
|
294
|
-
return {
|
|
295
|
-
trace_id: typeof record.trace_id === "string" ? record.trace_id : job.id,
|
|
296
|
-
spans: Array.isArray(record.spans) ? record.spans : [],
|
|
297
|
-
events: Array.isArray(record.events) ? record.events : [],
|
|
298
|
-
summaries: Array.isArray(record.summaries) ? record.summaries : [],
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
function readLocalTraceSessions(job, role) {
|
|
302
|
-
if (!Array.isArray(job.traceSessions)) {
|
|
303
|
-
return [];
|
|
304
|
-
}
|
|
305
|
-
return job.traceSessions.map((session) => ({
|
|
306
|
-
id: typeof session.id === "string" && session.id.length > 0
|
|
307
|
-
? session.id
|
|
308
|
-
: `${job.id}:trace`,
|
|
309
|
-
jobId: typeof session.jobId === "string" && session.jobId.length > 0
|
|
310
|
-
? session.jobId
|
|
311
|
-
: job.id,
|
|
312
|
-
role: session.role === "improver" || session.role === "runner" || session.role === "engine"
|
|
313
|
-
? session.role
|
|
314
|
-
: role,
|
|
315
|
-
kind: typeof session.kind === "string" && session.kind.length > 0 ? session.kind : "trace",
|
|
316
|
-
label: traceSessionDisplayLabel(session, role),
|
|
317
|
-
sourcePath: typeof session.sourcePath === "string" ? session.sourcePath : null,
|
|
318
|
-
trace: sanitizeLocalTrace(session.trace, session.id),
|
|
319
|
-
...(session.metadata && typeof session.metadata === "object" && !Array.isArray(session.metadata)
|
|
320
|
-
? { metadata: session.metadata }
|
|
321
|
-
: {}),
|
|
322
|
-
}));
|
|
323
|
-
}
|
|
324
|
-
function traceSessionDisplayLabel(session, fallbackRole) {
|
|
325
|
-
const role = session.role === "improver" || session.role === "runner" || session.role === "engine"
|
|
326
|
-
? session.role
|
|
327
|
-
: fallbackRole;
|
|
328
|
-
return typeof session.label === "string" && session.label.length > 0
|
|
329
|
-
? session.label
|
|
330
|
-
: typeof session.sourcePath === "string" && session.sourcePath.length > 0
|
|
331
|
-
? traceSessionLabel(session.sourcePath, role)
|
|
332
|
-
: "Trace";
|
|
333
|
-
}
|
|
334
|
-
function sanitizeLocalTrace(trace, fallbackId) {
|
|
335
|
-
if (!trace || typeof trace !== "object" || Array.isArray(trace)) {
|
|
336
|
-
return { trace_id: fallbackId, spans: [], events: [], summaries: [] };
|
|
337
|
-
}
|
|
338
|
-
const record = trace;
|
|
339
|
-
return {
|
|
340
|
-
trace_id: typeof record.trace_id === "string" ? record.trace_id : fallbackId,
|
|
341
|
-
spans: Array.isArray(record.spans) ? record.spans : [],
|
|
342
|
-
events: Array.isArray(record.events) ? record.events : [],
|
|
343
|
-
summaries: Array.isArray(record.summaries) ? record.summaries : [],
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
function asRecord(value) {
|
|
347
|
-
return value && typeof value === "object" && !Array.isArray(value)
|
|
348
|
-
? value
|
|
349
|
-
: null;
|
|
350
|
-
}
|
|
351
|
-
function normalizeOptionalFingerprint(value) {
|
|
352
|
-
const normalized = value?.trim();
|
|
353
|
-
return normalized ? normalized : null;
|
|
354
|
-
}
|
package/dist/project-source.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { resolveWorkbenchResolvedSourceYaml, type Json, type SurfaceSnapshotFile } from "@workbench-ai/workbench-core";
|
|
2
|
-
import { type WorkbenchEngineCase, type WorkbenchEngineResolveResult } from "@workbench-ai/workbench-protocol";
|
|
3
|
-
import { type WorkspaceSnapshotFile } from "./workspace-snapshot.js";
|
|
4
|
-
import { type ResolvedWorkbenchAdapter } from "./adapter-project.js";
|
|
5
|
-
export declare const WORKBENCH_BENCHMARK_FILE = "benchmark.yaml";
|
|
6
|
-
export declare const WORKBENCH_CANDIDATES_DIR = "candidates";
|
|
7
|
-
export declare const WORKBENCH_CANDIDATE_FILE = "candidate.yaml";
|
|
8
|
-
export type RemoteFile = WorkspaceSnapshotFile;
|
|
9
|
-
export interface LocalProjectSource {
|
|
10
|
-
dir: string;
|
|
11
|
-
specPath: string;
|
|
12
|
-
specSource: string;
|
|
13
|
-
spec: ReturnType<typeof resolveWorkbenchResolvedSourceYaml>;
|
|
14
|
-
benchmarkPath: string;
|
|
15
|
-
benchmarkSource: string;
|
|
16
|
-
candidateName: string;
|
|
17
|
-
candidateDir: string;
|
|
18
|
-
candidateFilesPath: string;
|
|
19
|
-
candidateSpecPath: string;
|
|
20
|
-
candidateSource: string;
|
|
21
|
-
candidateRunId: string;
|
|
22
|
-
candidateRunIds: string[];
|
|
23
|
-
benchmarkAdapterSources: string[];
|
|
24
|
-
benchmarkAdapterIds: string[];
|
|
25
|
-
dockerfilePath: string;
|
|
26
|
-
dockerfile: string;
|
|
27
|
-
runtimeDockerfile: string;
|
|
28
|
-
dockerfileFiles: RemoteFile[];
|
|
29
|
-
candidateFiles: RemoteFile[];
|
|
30
|
-
engineResolveFiles: RemoteFile[];
|
|
31
|
-
adapters: ResolvedWorkbenchAdapter[];
|
|
32
|
-
adapterFiles: RemoteFile[];
|
|
33
|
-
caseIds: string[];
|
|
34
|
-
engineCases: WorkbenchEngineCase[];
|
|
35
|
-
engineResolve: LocalEngineResolveInvocation;
|
|
36
|
-
engineResolveFingerprintPath: string;
|
|
37
|
-
engineResolveEnvironment?: WorkbenchEngineResolveResult["environment"];
|
|
38
|
-
sourceFiles: SurfaceSnapshotFile[];
|
|
39
|
-
}
|
|
40
|
-
export interface LocalAuthoredProjectSource {
|
|
41
|
-
dir: string;
|
|
42
|
-
specPath: string;
|
|
43
|
-
specSource: string;
|
|
44
|
-
benchmarkPath: string;
|
|
45
|
-
benchmarkSource: string;
|
|
46
|
-
candidateDir: string;
|
|
47
|
-
candidateSpecPath: string;
|
|
48
|
-
candidateSource: string;
|
|
49
|
-
sourceFiles: SurfaceSnapshotFile[];
|
|
50
|
-
}
|
|
51
|
-
export interface LocalEngineResolveInvocation {
|
|
52
|
-
use: string;
|
|
53
|
-
with: Json;
|
|
54
|
-
auth?: Json;
|
|
55
|
-
}
|
|
56
|
-
interface LocalProjectSourceOptions {
|
|
57
|
-
runId?: string;
|
|
58
|
-
}
|
|
59
|
-
export declare function readLocalProjectSource(source: string, options?: LocalProjectSourceOptions): Promise<LocalProjectSource>;
|
|
60
|
-
export declare function readLocalAuthoredProjectSource(source: string, options?: LocalProjectSourceOptions): Promise<LocalAuthoredProjectSource>;
|
|
61
|
-
export declare function remoteEngineResolveFiles(source: LocalProjectSource): RemoteFile[];
|
|
62
|
-
export {};
|
|
63
|
-
//# sourceMappingURL=project-source.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-source.d.ts","sourceRoot":"","sources":["../src/project-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAOL,kCAAkC,EAGlC,KAAK,IAAI,EACT,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAUL,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EAClC,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAML,KAAK,wBAAwB,EAC9B,MAAM,sBAAsB,CAAC;AAI9B,eAAO,MAAM,wBAAwB,mBAAsB,CAAC;AAC5D,eAAO,MAAM,wBAAwB,eAAe,CAAC;AACrD,eAAO,MAAM,wBAAwB,mBAAsB,CAAC;AAE5D,MAAM,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAE/C,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,UAAU,CAAC,OAAO,kCAAkC,CAAC,CAAC;IAC5D,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,uBAAuB,EAAE,MAAM,EAAE,CAAC;IAClC,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,UAAU,EAAE,CAAC;IAC9B,cAAc,EAAE,UAAU,EAAE,CAAC;IAC7B,kBAAkB,EAAE,UAAU,EAAE,CAAC;IACjC,QAAQ,EAAE,wBAAwB,EAAE,CAAC;IACrC,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACnC,aAAa,EAAE,4BAA4B,CAAC;IAC5C,4BAA4B,EAAE,MAAM,CAAC;IACrC,wBAAwB,CAAC,EAAE,4BAA4B,CAAC,aAAa,CAAC,CAAC;IACvE,WAAW,EAAE,mBAAmB,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,0BAA0B;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,mBAAmB,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,4BAA4B;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED,UAAU,yBAAyB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAaD,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,kBAAkB,CAAC,CA8G7B;AAED,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,0BAA0B,CAAC,CA6BrC;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,GAAG,UAAU,EAAE,CAqBjF"}
|