@workbench-ai/workbench 0.0.50 → 0.0.51

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.
@@ -38,6 +38,9 @@ export declare function localBenchmarkSnapshot(context: LocalWorkbenchRequestCon
38
38
  completedSampleCount: number;
39
39
  errorSampleCount: number;
40
40
  metrics?: Record<string, import("@workbench-ai/workbench-contract").MetricStats>;
41
+ selectionMetric?: string;
42
+ selectionLabel?: string;
43
+ selectionScore?: import("@workbench-ai/workbench-contract").MetricStats;
41
44
  durationMs?: import("@workbench-ai/workbench-contract").MetricStats;
42
45
  usage?: import("@workbench-ai/workbench-contract").EvaluationUsageStats;
43
46
  error?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"dev-open-server.d.ts","sourceRoot":"","sources":["../src/dev-open-server.ts"],"names":[],"mappings":"AAKA,OAAO,EAYL,KAAK,UAAU,EACf,KAAK,mBAAmB,EAIzB,MAAM,8BAA8B,CAAC;AAatC,OAAO,EAGL,KAAK,kBAAkB,EAExB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,8BAA8B;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAkBD,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACtD;AAKD,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,uBAAuB,CAAC,CAwClC;AAoOD,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,4BAA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C,OAAO,EAAE,4BAA4B,EACrC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,uFAiCrC;AAwBD,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAExF;AAED,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,4BAA4B,EACrC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,GACnC,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAchC"}
@@ -108,7 +108,34 @@ async function handleLocalWorkbenchRequest(args) {
108
108
  await sendFontFile(args.response, args.context.assetsRoot, url, args.request.method);
109
109
  return;
110
110
  }
111
- await sendHtml(args.response, args.request.method);
111
+ if (url.pathname.startsWith("/assets/")) {
112
+ throw new LocalApiError("Workbench local asset not found.", 404);
113
+ }
114
+ await sendHtml(args.response, args.request.method, isKnownWorkbenchDocumentPath(url.pathname) ? 200 : 404);
115
+ }
116
+ function isKnownWorkbenchDocumentPath(pathname) {
117
+ const segments = pathname.split("/").filter(Boolean).map(decodeDocumentPathSegment);
118
+ if (segments.length === 0) {
119
+ return true;
120
+ }
121
+ if (segments[0] === "evaluations") {
122
+ return segments.length === 1;
123
+ }
124
+ if (segments[0] !== "candidates") {
125
+ return false;
126
+ }
127
+ if (segments.length === 1 || segments.length === 2) {
128
+ return true;
129
+ }
130
+ return segments.length === 3 && (segments[2] === "files" || segments[2] === "manifest");
131
+ }
132
+ function decodeDocumentPathSegment(segment) {
133
+ try {
134
+ return decodeURIComponent(segment);
135
+ }
136
+ catch {
137
+ return segment;
138
+ }
112
139
  }
113
140
  async function handleApiRequest(request, response, context, url) {
114
141
  const { workspace } = context;
@@ -487,7 +514,16 @@ function readPreviewMode(params) {
487
514
  throw new LocalApiError("view must be diff, raw, or rendered.");
488
515
  }
489
516
  async function sendFile(response, filePath, contentType, method = "GET") {
490
- const body = await fs.readFile(filePath);
517
+ let body;
518
+ try {
519
+ body = await fs.readFile(filePath);
520
+ }
521
+ catch (error) {
522
+ if (error.code === "ENOENT") {
523
+ throw new LocalApiError("Workbench local asset not found.", 404);
524
+ }
525
+ throw error;
526
+ }
491
527
  response.writeHead(200, {
492
528
  "content-type": contentType,
493
529
  "content-length": body.byteLength,
@@ -508,7 +544,7 @@ async function sendFontFile(response, assetsRoot, url, method = "GET") {
508
544
  }
509
545
  await sendFile(response, path.join(assetsRoot, "fonts", fileName), "font/woff2", method);
510
546
  }
511
- async function sendHtml(response, method = "GET") {
547
+ async function sendHtml(response, method = "GET", status = 200) {
512
548
  const body = `<!doctype html>
513
549
  <html lang="en">
514
550
  <head>
@@ -522,7 +558,7 @@ async function sendHtml(response, method = "GET") {
522
558
  <script type="module" src="/assets/client.js"></script>
523
559
  </body>
524
560
  </html>`;
525
- response.writeHead(200, {
561
+ response.writeHead(status, {
526
562
  "content-type": "text/html; charset=utf-8",
527
563
  "content-length": Buffer.byteLength(body),
528
564
  "cache-control": "no-store",
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAyHA,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;CAC/B;AA6BD,UAAU,iBAAiB;CAAG;AA4K9B,wBAAsB,MAAM,CAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,EAAE,GAAE,KAIH,EACD,cAAc,GAAE,iBAAsB,GACrC,OAAO,CAAC,MAAM,CAAC,CAiHjB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA2IA,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;CAC/B;AA4BD,UAAU,iBAAiB;CAAG;AAuK9B,wBAAsB,MAAM,CAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,EAAE,GAAE,KAIH,EACD,cAAc,GAAE,iBAAsB,GACrC,OAAO,CAAC,MAAM,CAAC,CAmHjB"}