@mcpjam/inspector 3.12.5 → 3.12.6

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.
Files changed (27) hide show
  1. package/dist/client/assets/{OAuthDesktopReturnNotice-LlC451lX.js → OAuthDesktopReturnNotice-Hqfjrb1H.js} +2 -2
  2. package/dist/client/assets/{app-bootstrap-2jatN7gw.js → app-bootstrap-BJCjI-vd.js} +312 -312
  3. package/dist/client/assets/{button-B2OH2ei2.js → button-BIwDmB_t.js} +2 -2
  4. package/dist/client/assets/{chunk-YOKDWASO-uJ3KOQV7.js → chunk-YOKDWASO-BR3Wei6p.js} +5 -5
  5. package/dist/client/assets/{dead-clicks-autocapture-D055GjVp.js → dead-clicks-autocapture-By9oPZNO.js} +2 -2
  6. package/dist/client/assets/{error-reporting-FWZKbZxG.js → error-reporting-CcPrCWMZ.js} +1 -1
  7. package/dist/client/assets/{error-reporting-DGP36KLx.js → error-reporting-DETvm7SY.js} +21 -21
  8. package/dist/client/assets/{exception-autocapture-103gdJjL.js → exception-autocapture-DwbGcAD3.js} +2 -2
  9. package/dist/client/assets/{failed-request-tracker-Cp9_VFMm.js → failed-request-tracker-C_rHGGiC.js} +2 -2
  10. package/dist/client/assets/{highlighted-body-KPVGNVTW-Dx70h1nm.js → highlighted-body-KPVGNVTW-BtWesXMy.js} +2 -2
  11. package/dist/client/assets/{index-rskHnM3O.js → index-DVxvFt1b.js} +3 -3
  12. package/dist/client/assets/{jszip.min-CwJyI5tb.js → jszip.min-jjKI-S8C.js} +2 -2
  13. package/dist/client/assets/{mermaid-HWGCJPDP-Ck3prJKl.js → mermaid-HWGCJPDP-Sm76m65k.js} +1 -1
  14. package/dist/client/assets/{posthog-recorder-tKuMFijV.js → posthog-recorder-e8IS69Uh.js} +2 -2
  15. package/dist/client/assets/{preload-helper-DrcoTQ49.js → preload-helper-CWYHVRyR.js} +2 -2
  16. package/dist/client/assets/{rolldown-runtime-7FnpGOz6.js → rolldown-runtime-CQzr1Zku.js} +1 -1
  17. package/dist/client/assets/{surveys-BsZYxM6N.js → surveys-o2N6B1zC.js} +2 -2
  18. package/dist/client/assets/{trace-timeline-BOZvHcOG.js → trace-timeline-Beb_Djgr.js} +1 -1
  19. package/dist/client/assets/{trace-timeline-Bf9Oai70.js → trace-timeline-D_iD3a0v.js} +27 -27
  20. package/dist/client/assets/{web-vitals-DdzaVN3H.js → web-vitals-DCOcPgvo.js} +2 -2
  21. package/dist/client/index.html +6 -6
  22. package/dist/server/{chunk-QA6VJT6A.js → chunk-SUMJU6PX.js} +2 -2
  23. package/dist/server/{chunk-3EDQFXTF.js → chunk-T4H5HSBJ.js} +2 -2
  24. package/dist/server/harness-install-cli.js +1 -1
  25. package/dist/server/index.js +911 -368
  26. package/dist/server/{local-turn-XXOSZHMT.js → local-turn-ZKWOMPM4.js} +3 -3
  27. package/package.json +2 -2
@@ -28,7 +28,7 @@ import {
28
28
  stopLocalHarnessProject,
29
29
  stopLocalHarnessWorkspace,
30
30
  validateWorkspaceCandidate
31
- } from "./chunk-3EDQFXTF.js";
31
+ } from "./chunk-T4H5HSBJ.js";
32
32
  import {
33
33
  LOCAL_HARNESS_MANIFEST,
34
34
  LOCAL_HARNESS_POLICY_VERSION,
@@ -57,7 +57,7 @@ import {
57
57
  runtimeInstallRoot,
58
58
  startRuntimeInstall,
59
59
  supportsOwnershipProof
60
- } from "./chunk-QA6VJT6A.js";
60
+ } from "./chunk-SUMJU6PX.js";
61
61
  import {
62
62
  BROWSER_CONSENT_HEADER,
63
63
  createBrowserConsentLifetime,
@@ -8201,6 +8201,34 @@ var init_sdk_evals_normalizer = __esm({
8201
8201
  init_types();
8202
8202
  }
8203
8203
  });
8204
+ var ANTHROPIC_REASONING_EFFORTS;
8205
+ var GOOGLE_REASONING_EFFORTS;
8206
+ var HARNESS_REASONING_EFFORTS;
8207
+ var EFFORT_SET2;
8208
+ var init_reasoning_effort = __esm({
8209
+ "src/host-config/reasoning-effort.ts"() {
8210
+ init_model_selection();
8211
+ ANTHROPIC_REASONING_EFFORTS = [
8212
+ "low",
8213
+ "medium",
8214
+ "high",
8215
+ "xhigh",
8216
+ "max"
8217
+ ];
8218
+ GOOGLE_REASONING_EFFORTS = [
8219
+ "minimal",
8220
+ "low",
8221
+ "medium",
8222
+ "high"
8223
+ ];
8224
+ HARNESS_REASONING_EFFORTS = {
8225
+ "claude-code": [],
8226
+ codex: [],
8227
+ cursor: []
8228
+ };
8229
+ EFFORT_SET2 = new Set(MODEL_REASONING_EFFORTS);
8230
+ }
8231
+ });
8204
8232
  var init_internal = __esm({
8205
8233
  "src/host-config/internal.ts"() {
8206
8234
  init_canonicalize();
@@ -8214,6 +8242,7 @@ var init_internal = __esm({
8214
8242
  init_compat_runtime();
8215
8243
  init_sdk_evals_normalizer();
8216
8244
  init_model_selection();
8245
+ init_reasoning_effort();
8217
8246
  }
8218
8247
  });
8219
8248
  function isMalformedUriError(error) {
@@ -21799,6 +21828,7 @@ function taskModeForSurface(policy, surface) {
21799
21828
  return surface === "eval" ? "await" : "expose";
21800
21829
  }
21801
21830
  init_model_selection();
21831
+ init_reasoning_effort();
21802
21832
  init_model_selection();
21803
21833
  var PROVIDER_DEFAULT_MAX_OUTPUT_TOKENS = 0;
21804
21834
  function isRecord11(value) {
@@ -28804,7 +28834,7 @@ var noopPosthog = {
28804
28834
  var posthog = isTelemetryDisabled ? noopPosthog : new PostHog("phc_dTOPniyUNU2kD8Jx8yHMXSqiZHM8I91uWopTMX6EBE9", {
28805
28835
  host: "https://us.i.posthog.com"
28806
28836
  });
28807
- var SDK_VERSION = "8.19.0";
28837
+ var SDK_VERSION = "8.20.0";
28808
28838
  var SDK_RELEASE = `@mcpjam/sdk@${SDK_VERSION}`;
28809
28839
  var CAPTURED_ERROR_SYMBOL = Symbol.for("@mcpjam/sdk/captured-eval-error");
28810
28840
  init_internal();
@@ -28816,7 +28846,7 @@ init_eval_tool_execution();
28816
28846
  init_internal();
28817
28847
  init_internal();
28818
28848
  function readSdkVersion() {
28819
- return "8.19.0";
28849
+ return "8.20.0";
28820
28850
  }
28821
28851
  var DEFAULT_PLATFORM_USER_AGENT = `mcpjam-sdk/${readSdkVersion()}`;
28822
28852
  init_HostRunner();
@@ -78869,7 +78899,7 @@ function readSettings2(raw, issues) {
78869
78899
  rejectUnknownKeys2(raw, SETTINGS_KEYS2, path8, issues);
78870
78900
  const out = {};
78871
78901
  if (raw.reasoningEffort !== void 0) {
78872
- if (typeof raw.reasoningEffort === "string" && EFFORT_SET2.has(raw.reasoningEffort)) {
78902
+ if (typeof raw.reasoningEffort === "string" && EFFORT_SET3.has(raw.reasoningEffort)) {
78873
78903
  out.reasoningEffort = raw.reasoningEffort;
78874
78904
  } else {
78875
78905
  issues.push({
@@ -79035,7 +79065,7 @@ var LOCAL_REF_KEYS2;
79035
79065
  var SETTINGS_KEYS2;
79036
79066
  var FALLBACK_KEYS2;
79037
79067
  var SOURCE_SET2;
79038
- var EFFORT_SET2;
79068
+ var EFFORT_SET3;
79039
79069
  var FALLBACK_PROVIDER_SET2;
79040
79070
  var CANONICAL_MODEL_ID2;
79041
79071
  var MODEL_SELECTION_TEMPERATURE_MIN2;
@@ -79096,7 +79126,7 @@ var init_model_selection2 = __esm2({
79096
79126
  ]);
79097
79127
  FALLBACK_KEYS2 = /* @__PURE__ */ new Set(["provider", "model"]);
79098
79128
  SOURCE_SET2 = new Set(MODEL_SELECTION_SOURCES2);
79099
- EFFORT_SET2 = new Set(MODEL_REASONING_EFFORTS2);
79129
+ EFFORT_SET3 = new Set(MODEL_REASONING_EFFORTS2);
79100
79130
  FALLBACK_PROVIDER_SET2 = new Set(
79101
79131
  MODEL_SELECTION_FALLBACK_PROVIDERS2
79102
79132
  );
@@ -81277,6 +81307,116 @@ var init_sdk_evals_normalizer2 = __esm2({
81277
81307
  init_types2();
81278
81308
  }
81279
81309
  });
81310
+ function bareModelName(modelId) {
81311
+ const slash = modelId.indexOf("/");
81312
+ return slash >= 0 ? modelId.slice(slash + 1) : modelId;
81313
+ }
81314
+ function openaiEfforts(name15) {
81315
+ if (/-(?:pro|chat)(?:[.-]|$)/.test(name15)) return [];
81316
+ if (/^(?:o1|o3|o3-mini|o4-mini)(?:-\d{4}-\d{2}-\d{2})?$/.test(name15)) {
81317
+ return ["low", "medium", "high"];
81318
+ }
81319
+ if (/-codex(?:[.-]|$)/.test(name15)) {
81320
+ return /^gpt-5\.1-codex-max$|^gpt-5\.2-codex$/.test(name15) ? ["low", "medium", "high", "xhigh"] : [];
81321
+ }
81322
+ const minor = /^gpt-5\.(\d+)(?:[.-]|$)/.exec(name15);
81323
+ if (minor) {
81324
+ return Number(minor[1]) >= 2 ? ["none", "low", "medium", "high", "xhigh"] : ["none", "low", "medium", "high"];
81325
+ }
81326
+ if (/^gpt-5(?:-|$)/.test(name15)) return ["minimal", "low", "medium", "high"];
81327
+ return [];
81328
+ }
81329
+ function anthropicEfforts(name15) {
81330
+ const m = /^claude-(opus|sonnet|haiku|fable)-(\d+)(?:[.-](\d{1,2})(?!\d))?(?:[.-]|$)/.exec(
81331
+ name15
81332
+ );
81333
+ if (!m) return [];
81334
+ const major = Number(m[2]);
81335
+ const minor = m[3] === void 0 ? 0 : Number(m[3]);
81336
+ const ALL8 = ANTHROPIC_REASONING_EFFORTS2;
81337
+ if (m[1] === "haiku") return [];
81338
+ if (major >= 5) return ALL8;
81339
+ if (major !== 4 || minor >= 10) return [];
81340
+ if (m[1] === "opus") {
81341
+ if (minor >= 7) return ALL8;
81342
+ if (minor === 6) return ["low", "medium", "high", "max"];
81343
+ if (minor === 5) return ["low", "medium", "high"];
81344
+ return [];
81345
+ }
81346
+ return m[1] === "sonnet" && minor >= 6 ? ["low", "medium", "high", "max"] : [];
81347
+ }
81348
+ function googleEfforts(name15) {
81349
+ if (/^gemini-3\.\d+-pro(?:-preview)?(?:-\d+)?$/.test(name15)) {
81350
+ return ["low", "medium", "high"];
81351
+ }
81352
+ if (/^gemini-3-pro(?:-preview)?(?:-\d+)?$/.test(name15)) return ["low", "high"];
81353
+ if (/^gemini-3(?:\.\d+)?-flash(?:-preview)?(?:-\d+)?$/.test(name15)) {
81354
+ return GOOGLE_REASONING_EFFORTS2;
81355
+ }
81356
+ return [];
81357
+ }
81358
+ function directEfforts(providerKey, modelId) {
81359
+ const name15 = bareModelName(modelId);
81360
+ switch (providerKey) {
81361
+ case "openai":
81362
+ return openaiEfforts(name15);
81363
+ case "anthropic":
81364
+ return anthropicEfforts(name15);
81365
+ case "google":
81366
+ return googleEfforts(name15);
81367
+ default:
81368
+ return [];
81369
+ }
81370
+ }
81371
+ function reasoningEffortProviderOptions(args) {
81372
+ if (!directEfforts(args.providerKey, args.modelId).includes(args.effort)) {
81373
+ return void 0;
81374
+ }
81375
+ const name15 = bareModelName(args.modelId);
81376
+ switch (args.providerKey) {
81377
+ case "openai":
81378
+ return { openai: { reasoningEffort: args.effort } };
81379
+ case "anthropic":
81380
+ return {
81381
+ anthropic: {
81382
+ effort: args.effort,
81383
+ .../^claude-opus-4[.-]5(?:-|$)/.test(name15) ? {} : { thinking: { type: "adaptive" } }
81384
+ }
81385
+ };
81386
+ case "google":
81387
+ return { google: { thinkingConfig: { thinkingLevel: args.effort } } };
81388
+ default:
81389
+ return void 0;
81390
+ }
81391
+ }
81392
+ var ANTHROPIC_REASONING_EFFORTS2;
81393
+ var GOOGLE_REASONING_EFFORTS2;
81394
+ var HARNESS_REASONING_EFFORTS2;
81395
+ var EFFORT_SET22;
81396
+ var init_reasoning_effort2 = __esm2({
81397
+ "src/host-config/reasoning-effort.ts"() {
81398
+ init_model_selection2();
81399
+ ANTHROPIC_REASONING_EFFORTS2 = [
81400
+ "low",
81401
+ "medium",
81402
+ "high",
81403
+ "xhigh",
81404
+ "max"
81405
+ ];
81406
+ GOOGLE_REASONING_EFFORTS2 = [
81407
+ "minimal",
81408
+ "low",
81409
+ "medium",
81410
+ "high"
81411
+ ];
81412
+ HARNESS_REASONING_EFFORTS2 = {
81413
+ "claude-code": [],
81414
+ codex: [],
81415
+ cursor: []
81416
+ };
81417
+ EFFORT_SET22 = new Set(MODEL_REASONING_EFFORTS2);
81418
+ }
81419
+ });
81280
81420
  var init_internal2 = __esm2({
81281
81421
  "src/host-config/internal.ts"() {
81282
81422
  init_canonicalize2();
@@ -81290,6 +81430,7 @@ var init_internal2 = __esm2({
81290
81430
  init_compat_runtime2();
81291
81431
  init_sdk_evals_normalizer2();
81292
81432
  init_model_selection2();
81433
+ init_reasoning_effort2();
81293
81434
  }
81294
81435
  });
81295
81436
  function isMalformedUriError2(error) {
@@ -87588,7 +87729,7 @@ var NEGATIVE_TEST_MODE_DETAILS = {
87588
87729
  };
87589
87730
  init_client_id_metadata2();
87590
87731
  function readSdkVersion2() {
87591
- return "8.19.0";
87732
+ return "8.20.0";
87592
87733
  }
87593
87734
  var CONFORMANCE_CHECKER_VERSION2 = readSdkVersion2();
87594
87735
  var MUST_POINTS2 = 95;
@@ -87598,6 +87739,7 @@ init_types2();
87598
87739
  init_host2();
87599
87740
  init_host_runtime2();
87600
87741
  init_model_selection2();
87742
+ init_reasoning_effort2();
87601
87743
  init_model_selection2();
87602
87744
  init_mcp_protocol_version2();
87603
87745
  init_mcp_protocol_version2();
@@ -91287,6 +91429,9 @@ function reportOnlyDirectives(runtimeConfig, sandboxHosts, sentryDsn) {
91287
91429
  frameSources.add(source);
91288
91430
  }
91289
91431
  return [
91432
+ // The fallback for fetch directives not listed below (media-src, …);
91433
+ // report-only, so an unlisted source only produces a report.
91434
+ ["default-src", ["'self'"]],
91290
91435
  // 'unsafe-eval': JSON Schema validators (ajv) compile schemas at runtime
91291
91436
  // with `new Function`.
91292
91437
  ["script-src", ["'self'", "'unsafe-eval'", ...STRIPE_SCRIPT_SOURCES]],
@@ -91303,8 +91448,8 @@ function reportOnlyDirectives(runtimeConfig, sandboxHosts, sentryDsn) {
91303
91448
  ...sentry ? [["report-uri", [sentry.reportUri]]] : []
91304
91449
  ];
91305
91450
  }
91306
- function renderPolicy(directives, scriptNonce) {
91307
- return directives.map(([name15, iterable]) => {
91451
+ function renderPolicy(directives, scriptNonce, includeReportUri = true) {
91452
+ return directives.filter(([name15]) => includeReportUri || name15 !== "report-uri").map(([name15, iterable]) => {
91308
91453
  const sources = Array.from(iterable);
91309
91454
  if (name15 === "script-src" && scriptNonce) {
91310
91455
  sources.splice(1, 0, `'nonce-${scriptNonce}'`);
@@ -91313,21 +91458,23 @@ function renderPolicy(directives, scriptNonce) {
91313
91458
  }).join("; ");
91314
91459
  }
91315
91460
  var reportOnlyBase = null;
91316
- function reportOnlyContentSecurityPolicy(scriptNonce) {
91461
+ function reportOnlyContentSecurityPolicy(scriptNonce, includeReportUri) {
91317
91462
  reportOnlyBase ??= reportOnlyDirectives(
91318
91463
  getInspectorClientRuntimeConfig(),
91319
91464
  SANDBOX_HOSTS,
91320
91465
  SENTRY_DSN.client
91321
91466
  );
91322
- return renderPolicy(reportOnlyBase, scriptNonce);
91467
+ return renderPolicy(reportOnlyBase, scriptNonce, includeReportUri);
91323
91468
  }
91324
91469
  function isHtmlDocument(res) {
91325
91470
  return (res.headers.get("Content-Type") ?? "").toLowerCase().startsWith("text/html");
91326
91471
  }
91327
- function setDocumentPolicies(headers, reportOnlyPolicy) {
91328
- headers.set("Content-Security-Policy", DOCUMENT_CONTENT_SECURITY_POLICY);
91329
- if (!headers.has("Permissions-Policy")) {
91330
- headers.set("Permissions-Policy", DOCUMENT_PERMISSIONS_POLICY);
91472
+ function setResponsePolicies(headers, isDocument, reportOnlyPolicy) {
91473
+ if (isDocument) {
91474
+ headers.set("Content-Security-Policy", DOCUMENT_CONTENT_SECURITY_POLICY);
91475
+ if (!headers.has("Permissions-Policy")) {
91476
+ headers.set("Permissions-Policy", DOCUMENT_PERMISSIONS_POLICY);
91477
+ }
91331
91478
  }
91332
91479
  if (reportOnlyPolicy) {
91333
91480
  headers.set("Content-Security-Policy-Report-Only", reportOnlyPolicy);
@@ -91340,15 +91487,22 @@ async function securityHeadersMiddleware(c, next) {
91340
91487
  c.header("Referrer-Policy", "strict-origin-when-cross-origin");
91341
91488
  await next();
91342
91489
  const res = c.res;
91343
- if (!isHtmlDocument(res) || res.headers.has("Content-Security-Policy")) {
91490
+ if (res.headers.has("Content-Security-Policy")) {
91491
+ return;
91492
+ }
91493
+ const isDocument = isHtmlDocument(res);
91494
+ const reportOnlyPolicy = HOSTED_MODE ? reportOnlyContentSecurityPolicy(
91495
+ isDocument ? scriptNonces.get(c) : void 0,
91496
+ Math.random() < CSP_REPORT_SAMPLE_RATE
91497
+ ) : null;
91498
+ if (!isDocument && !reportOnlyPolicy) {
91344
91499
  return;
91345
91500
  }
91346
- const reportOnlyPolicy = HOSTED_MODE && Math.random() < CSP_REPORT_SAMPLE_RATE ? reportOnlyContentSecurityPolicy(scriptNonces.get(c)) : null;
91347
91501
  try {
91348
- setDocumentPolicies(res.headers, reportOnlyPolicy);
91502
+ setResponsePolicies(res.headers, isDocument, reportOnlyPolicy);
91349
91503
  } catch {
91350
91504
  const copy = new Response(res.body, res);
91351
- setDocumentPolicies(copy.headers, reportOnlyPolicy);
91505
+ setResponsePolicies(copy.headers, isDocument, reportOnlyPolicy);
91352
91506
  c.res = copy;
91353
91507
  }
91354
91508
  }
@@ -92393,7 +92547,7 @@ async function sweepLocalHarnessScratch() {
92393
92547
  var startup;
92394
92548
  function startLocalHarnessJanitor() {
92395
92549
  startup ??= (async () => {
92396
- const { localHarnessSupervisor } = await import("./local-turn-XXOSZHMT.js");
92550
+ const { localHarnessSupervisor } = await import("./local-turn-ZKWOMPM4.js");
92397
92551
  await localHarnessSupervisor().reclaimOrphans();
92398
92552
  await sweepLocalHarnessScratch();
92399
92553
  })().catch((error) => {
@@ -130308,10 +130462,12 @@ async function fetchHostRuntimeConfig(args) {
130308
130462
  response = await fetch(url, requestInit);
130309
130463
  } catch (retryError) {
130310
130464
  logger.error("[host-runtime-config] network error after retry", retryError);
130465
+ const networkCode = getFetchErrorCause(retryError);
130311
130466
  return {
130312
130467
  ok: false,
130313
130468
  status: 502,
130314
- error: "Failed to reach host runtime-config endpoint"
130469
+ error: "Failed to reach host runtime-config endpoint",
130470
+ ...networkCode ? { networkCode } : {}
130315
130471
  };
130316
130472
  }
130317
130473
  }
@@ -133288,7 +133444,7 @@ var MODEL_SELECTION_FALLBACK_PROVIDERS4 = [
133288
133444
  "openrouter"
133289
133445
  ];
133290
133446
  var SOURCE_SET3 = new Set(MODEL_SELECTION_SOURCES4);
133291
- var EFFORT_SET3 = new Set(MODEL_REASONING_EFFORTS4);
133447
+ var EFFORT_SET4 = new Set(MODEL_REASONING_EFFORTS4);
133292
133448
  var FALLBACK_PROVIDER_SET3 = new Set(
133293
133449
  MODEL_SELECTION_FALLBACK_PROVIDERS4
133294
133450
  );
@@ -133677,6 +133833,12 @@ function resolveOpenAiCompatForHostConfig3(hostConfig, hostConfigOverride) {
133677
133833
  if (explicitBase !== void 0) return explicitBase;
133678
133834
  return compatPresetForHostStyle3(readHostStyle23(hostConfig)) ?? false;
133679
133835
  }
133836
+ var HARNESS_REASONING_EFFORTS3 = {
133837
+ "claude-code": [],
133838
+ codex: [],
133839
+ cursor: []
133840
+ };
133841
+ var EFFORT_SET23 = new Set(MODEL_REASONING_EFFORTS4);
133680
133842
 
133681
133843
  // shared/harness-mcp-delivery.ts
133682
133844
  var HARNESS_MCP_DELIVERY = {
@@ -133989,6 +134151,8 @@ function memoizedBuiltinTools(build2) {
133989
134151
  var claudeCodeAdapter = {
133990
134152
  id: "claude-code",
133991
134153
  displayName: "Claude Code",
134154
+ // Nothing verified yet: an effort on this harness is refused, not dropped.
134155
+ supportedReasoningEfforts: HARNESS_REASONING_EFFORTS3["claude-code"],
133992
134156
  requiresComputer: true,
133993
134157
  // MCPJam brokers the model credential: Convex mints a lease, E2B injects it
133994
134158
  // outside the VM, and the model proxy meters the spend.
@@ -134089,6 +134253,8 @@ var codexExecAdapter = {
134089
134253
  // second one exists, so a reader of either arm can tell which is which.
134090
134254
  transport: "exec",
134091
134255
  displayName: "Codex",
134256
+ // Nothing verified yet: an effort on this harness is refused, not dropped.
134257
+ supportedReasoningEfforts: HARNESS_REASONING_EFFORTS3["codex"],
134092
134258
  requiresComputer: true,
134093
134259
  // Brokered, same as Claude Code — an OpenAI-protocol lease instead of an
134094
134260
  // Anthropic one.
@@ -134216,6 +134382,8 @@ var cursorAdapter = {
134216
134382
  // different surfaces. Every preflight/refusal message a user reads comes from
134217
134383
  // here, so the distinction has to be in the name itself.
134218
134384
  displayName: "Cursor CLI",
134385
+ // Nothing verified yet: an effort on this harness is refused, not dropped.
134386
+ supportedReasoningEfforts: HARNESS_REASONING_EFFORTS3["cursor"],
134219
134387
  requiresComputer: true,
134220
134388
  // NO BROKER. cursor-agent has no provider or gateway routing at all: it
134221
134389
  // authenticates with a `CURSOR_API_KEY` (the adapter's own `credentialEnv`
@@ -134437,6 +134605,26 @@ function externalAccountHostModelRefusalReason(args) {
134437
134605
  if (isRuntimeChosenModelSentinel(args.modelId)) return void 0;
134438
134606
  return `the ${adapter.displayName} harness chooses its own model on your own account, so this host cannot pin one \u2014 it carries "${args.modelId}", which the runtime would ignore while the session recorded it as the model that ran. Reset this host's model, or pick a harness that runs the model you chose`;
134439
134607
  }
134608
+ function readReasoningEffort(value) {
134609
+ return typeof value === "string" && MODEL_REASONING_EFFORTS2.includes(value) ? value : void 0;
134610
+ }
134611
+ function selectionReasoningEffort(selection) {
134612
+ if (!selection || typeof selection !== "object") return void 0;
134613
+ const settings = selection.settings;
134614
+ if (!settings || typeof settings !== "object") return void 0;
134615
+ return readReasoningEffort(
134616
+ settings.reasoningEffort
134617
+ );
134618
+ }
134619
+ function harnessReasoningEffortRefusalReason(args) {
134620
+ const { adapter, reasoningEffort } = args;
134621
+ if (reasoningEffort === void 0) return void 0;
134622
+ if (adapter.supportedReasoningEfforts.includes(reasoningEffort)) {
134623
+ return void 0;
134624
+ }
134625
+ const name15 = adapter.displayName;
134626
+ return adapter.supportedReasoningEfforts.length === 0 ? `the ${name15} harness can't apply a reasoning effort yet ("${reasoningEffort}") \u2014 remove the effort from this model, or use the emulated engine` : `the ${name15} harness can't apply the "${reasoningEffort}" reasoning effort \u2014 it supports ${adapter.supportedReasoningEfforts.map((level) => `"${level}"`).join(", ")}`;
134627
+ }
134440
134628
  function harnessToolApprovalRefusalReason(args) {
134441
134629
  if (!args.requireToolApproval) return void 0;
134442
134630
  const name15 = args.adapter.displayName;
@@ -134482,6 +134670,13 @@ function checkHarnessRuntimeAvailable(args) {
134482
134670
  if (approvalRefusal) {
134483
134671
  return { ok: false, kind: "tool-approval", reason: approvalRefusal };
134484
134672
  }
134673
+ const effortRefusal = harnessReasoningEffortRefusalReason({
134674
+ adapter,
134675
+ ...args.reasoningEffort !== void 0 ? { reasoningEffort: args.reasoningEffort } : {}
134676
+ });
134677
+ if (effortRefusal) {
134678
+ return { ok: false, kind: "setting-unsupported", reason: effortRefusal };
134679
+ }
134485
134680
  const modelVerdict = harnessModelRefusal({
134486
134681
  adapter,
134487
134682
  model: args.model,
@@ -148721,6 +148916,7 @@ async function runHarnessTurn(options, streamSink) {
148721
148916
  );
148722
148917
  }
148723
148918
  const harnessAdapter = getHarnessAdapter(harness2);
148919
+ const turnReasoningEffort = options.reasoningEffort ?? selectionReasoningEffort(options.extraBodyFields?.modelSelection);
148724
148920
  const messageHistory = [...messages];
148725
148921
  const provenanceContext = historyProvenanceContextFor(
148726
148922
  projectId,
@@ -148935,6 +149131,13 @@ async function runHarnessTurn(options, streamSink) {
148935
149131
  if (approvalRefusal) {
148936
149132
  throw new Error(`Can't run this turn: ${approvalRefusal}.`);
148937
149133
  }
149134
+ const effortRefusal = harnessReasoningEffortRefusalReason({
149135
+ adapter: harnessAdapter,
149136
+ ...turnReasoningEffort !== void 0 ? { reasoningEffort: turnReasoningEffort } : {}
149137
+ });
149138
+ if (effortRefusal) {
149139
+ throw new Error(`Can't run this turn: ${effortRefusal}.`);
149140
+ }
148938
149141
  if (harnessAdapter.modelAccess !== "external-account" && !harnessBrokerDeliveryEnabled()) {
148939
149142
  throw new Error(
148940
149143
  "Harness runs require broker credential delivery, but it is disabled on this server (MCPJAM_HARNESS_BROKER_DELIVERY=false). There is no fallback credential path \u2014 re-enable the broker to run harness turns."
@@ -149413,7 +149616,16 @@ async function runHarnessTurn(options, streamSink) {
149413
149616
  auth = buildBrokerDummyAuth(harnessAdapter.id, broker.proxyBaseUrl);
149414
149617
  }
149415
149618
  tBroker = Date.now();
149416
- let harnessRuntime = harnessAdapter.mcpDelivery === "native" && harnessAdapter.mcpNativeDelivery === "session-config" ? harnessAdapter.createHarness({ modelId, auth, mcpJson }) : harnessAdapter.createHarness({ modelId, auth });
149619
+ let harnessRuntime = harnessAdapter.mcpDelivery === "native" && harnessAdapter.mcpNativeDelivery === "session-config" ? harnessAdapter.createHarness({
149620
+ modelId,
149621
+ auth,
149622
+ mcpJson,
149623
+ ...turnReasoningEffort !== void 0 ? { reasoningEffort: turnReasoningEffort } : {}
149624
+ }) : harnessAdapter.createHarness({
149625
+ modelId,
149626
+ auth,
149627
+ ...turnReasoningEffort !== void 0 ? { reasoningEffort: turnReasoningEffort } : {}
149628
+ });
149417
149629
  if (localPrepared) harnessRuntime = await withLocalPackBootstrap(harnessRuntime, localPrepared.plan.runtime.rootPath);
149418
149630
  const offeredBuiltInTools = Object.fromEntries(
149419
149631
  Object.entries(builtInTools2 ?? {}).filter(
@@ -153834,6 +154046,19 @@ function readFinishReasonFromChunk(finishChunk) {
153834
154046
  const source = finishChunk;
153835
154047
  return normalizeFinishReason(source?.finishReason);
153836
154048
  }
154049
+ var STEP_LIMIT_NOTE = "I reached my step limit for this message. Send a message to continue.";
154050
+ function writeStepLimitNote(writer, messageHistory, traceTurn) {
154051
+ const id3 = `step-limit-${traceTurn.turnId}`;
154052
+ writer.write({ type: "start-step" });
154053
+ writer.write({ type: "text-start", id: id3 });
154054
+ writer.write({ type: "text-delta", id: id3, delta: STEP_LIMIT_NOTE });
154055
+ writer.write({ type: "text-end", id: id3 });
154056
+ writer.write({ type: "finish-step" });
154057
+ messageHistory.push({
154058
+ role: "assistant",
154059
+ content: [{ type: "text", text: STEP_LIMIT_NOTE }]
154060
+ });
154061
+ }
153837
154062
  function createClientFinishChunk(finishChunk, traceTurn, fallbackReason) {
153838
154063
  const source = finishChunk;
153839
154064
  const aggregateUsage = traceTurn?.turnUsage;
@@ -154834,6 +155059,7 @@ async function processOneStep(ctx) {
154834
155059
  modelVisibleMcpToolResults,
154835
155060
  approvalMode,
154836
155061
  stepIndex,
155062
+ isFinalStep,
154837
155063
  usedToolCallIds,
154838
155064
  traceTurn,
154839
155065
  progressivePlan,
@@ -154877,6 +155103,7 @@ async function processOneStep(ctx) {
154877
155103
  activeToolDefs = activeToolDefs.filter((def) => advertised.has(def.name));
154878
155104
  }
154879
155105
  const forcedToolChoice = shouldForceInitialToolSearch(progressivePlan, discoveryState, stepIndex) && activeToolDefs.some((def) => def.name === META_TOOL_SEARCH) ? { type: "tool", toolName: META_TOOL_SEARCH } : void 0;
155106
+ const toolChoice = isFinalStep ? "none" : forcedToolChoice;
154880
155107
  const { abortSignal } = ctx;
154881
155108
  if (abortSignal?.aborted) {
154882
155109
  throw abortSignal.reason instanceof Error ? abortSignal.reason : Object.assign(new Error("Aborted"), { name: "AbortError" });
@@ -154975,7 +155202,7 @@ async function processOneStep(ctx) {
154975
155202
  turnId: traceTurn.turnId,
154976
155203
  promptIndex: traceTurn.promptIndex,
154977
155204
  stepIndex,
154978
- ...forcedToolChoice ? { toolChoice: forcedToolChoice } : {},
155205
+ ...toolChoice ? { toolChoice } : {},
154979
155206
  ...extraBodyFields ?? {}
154980
155207
  }),
154981
155208
  ...abortSignal ? { signal: abortSignal } : {}
@@ -155616,7 +155843,11 @@ async function processOneStep(ctx) {
155616
155843
  if (finishChunk) {
155617
155844
  writer.write(createClientFinishChunk(finishChunk, traceTurn, "stop"));
155618
155845
  }
155619
- return { shouldContinue: false, didEmitFinish };
155846
+ return {
155847
+ shouldContinue: false,
155848
+ didEmitFinish,
155849
+ modelFinishReason: harnessSpanMeta.finishReason
155850
+ };
155620
155851
  }
155621
155852
  async function runChatEngineLoop(options, streamSink) {
155622
155853
  const {
@@ -155888,6 +156119,8 @@ async function runChatEngineLoop(options, streamSink) {
155888
156119
  mrtrPaused = true;
155889
156120
  }
155890
156121
  }
156122
+ let stepEndedTurn = false;
156123
+ let endingModelFinishReason;
155891
156124
  while (!mrtrPaused && effectiveSteps() < resolvedMaxSteps) {
155892
156125
  if (aborted) break;
155893
156126
  await options.durableCheckpoint?.({
@@ -155895,7 +156128,7 @@ async function runChatEngineLoop(options, streamSink) {
155895
156128
  messages: messageHistory,
155896
156129
  step: effectiveSteps()
155897
156130
  });
155898
- const { shouldContinue, didEmitFinish } = await processOneStep({
156131
+ const { shouldContinue, didEmitFinish, modelFinishReason } = await processOneStep({
155899
156132
  durableCheckpoint: options.durableCheckpoint,
155900
156133
  writer: safeWriter,
155901
156134
  messageHistory,
@@ -155922,6 +156155,7 @@ async function runChatEngineLoop(options, streamSink) {
155922
156155
  modelVisibleMcpToolResults,
155923
156156
  approvalMode,
155924
156157
  stepIndex: effectiveSteps(),
156158
+ isFinalStep: effectiveSteps() === resolvedMaxSteps - 1,
155925
156159
  usedToolCallIds,
155926
156160
  traceTurn,
155927
156161
  endpointPath: resolvedEndpointPath,
@@ -155961,6 +156195,8 @@ async function runChatEngineLoop(options, streamSink) {
155961
156195
  !didEmitFinish && !shouldContinue
155962
156196
  );
155963
156197
  if (!shouldContinue) {
156198
+ stepEndedTurn = true;
156199
+ endingModelFinishReason = modelFinishReason;
155964
156200
  break;
155965
156201
  }
155966
156202
  if (options.yieldAfterStep) break;
@@ -156002,18 +156238,22 @@ async function runChatEngineLoop(options, streamSink) {
156002
156238
  turnId: traceTurn.turnId
156003
156239
  });
156004
156240
  }
156241
+ if (!mrtrPaused && steps === 0 && hitStepCap()) {
156242
+ writeStepLimitNote(safeWriter, messageHistory, traceTurn);
156243
+ }
156244
+ const turnEndedByLength = hitStepCap() && !stepEndedTurn || endingModelFinishReason === "length";
156005
156245
  if (!finishEmitted) {
156006
156246
  safeWriter.write(
156007
156247
  createClientFinishChunk(
156008
156248
  null,
156009
156249
  traceTurn,
156010
- hitStepCap() ? "length" : "stop"
156250
+ turnEndedByLength ? "length" : "stop"
156011
156251
  )
156012
156252
  );
156013
156253
  finishEmitted = true;
156014
156254
  }
156015
156255
  driver.usage = traceTurn.turnUsage;
156016
- driver.finishReason = hitStepCap() ? "length" : "stop";
156256
+ driver.finishReason = turnEndedByLength ? "length" : "stop";
156017
156257
  driver.finishTurn(safeWriter, { alreadyEmittedFinish: true });
156018
156258
  runSucceeded = true;
156019
156259
  } catch (error) {
@@ -161354,7 +161594,7 @@ function platformRefusalHint(refusal) {
161354
161594
  return refusal.canTopUp === false ? `${when} This is a usage limit: topping up credits does not lift it.` : when;
161355
161595
  }
161356
161596
  function readSdkVersion3() {
161357
- return "8.19.0";
161597
+ return "8.20.0";
161358
161598
  }
161359
161599
  var DEFAULT_PLATFORM_API_BASE_URL = "https://app.mcpjam.com/api/v1";
161360
161600
  function resolvePlatformRequestUrl(spec) {
@@ -189088,11 +189328,19 @@ chatV2.post("/", async (c) => {
189088
189328
  } else {
189089
189329
  logger.warn(
189090
189330
  "[mcp/chat-v2] host runtime-config fetch failed; failing closed",
189091
- { hostId: bodyHostId, status: runtime.status, error: runtime.error }
189331
+ {
189332
+ hostId: bodyHostId,
189333
+ status: runtime.status,
189334
+ error: runtime.error,
189335
+ networkCode: runtime.networkCode
189336
+ }
189092
189337
  );
189093
189338
  return c.json(
189094
189339
  {
189095
- error: `Couldn't load this host's settings, so the turn was stopped to avoid running with the wrong engine. ${runtime.error}`
189340
+ error: `Couldn't load this host's settings, so the turn was stopped to avoid running with the wrong engine. ${runtime.error}`,
189341
+ // Not shown to the user. Rides the body into the client's
189342
+ // `chat_request_failed` report (`extra.rawMessage`).
189343
+ ...runtime.networkCode ? { networkCode: runtime.networkCode } : {}
189096
189344
  },
189097
189345
  runtime.status >= 500 ? 502 : runtime.status
189098
189346
  );
@@ -194201,7 +194449,7 @@ var AGENT_ERROR_ENVELOPE = /^(?:swarm-agent\s+\S+\s+failed\s+\((\d{3})\):|Backen
194201
194449
  var URL_PATTERN2 = /https?:\/\/\S+/g;
194202
194450
  var ENGINE_DETAIL_SUFFIX = /\((?:([a-z][a-z0-9]*(?:_[a-z0-9]+)+)(?:, HTTP (\d{3}))?|HTTP (\d{3}))\)$/;
194203
194451
  function isTransientSpendRefusal(code, refusalReason) {
194204
- return code === "user_rate_limit" && refusalReason === "holds_committed";
194452
+ return code === "spending_reservation_busy" || code === "user_rate_limit" && refusalReason === "holds_committed";
194205
194453
  }
194206
194454
  var MAX_ATTEMPT_ERROR_CHARS = 500;
194207
194455
  function parseJsonObject(text2) {
@@ -194254,7 +194502,13 @@ function humanizeSwarmAttemptError(raw, errorCode2) {
194254
194502
  return { message: sandboxMessage, code: errorCode2 };
194255
194503
  }
194256
194504
  const input = (raw ?? "").trim();
194257
- if (errorCode2 === "spending_reservation_busy" || input.includes("streamSpendingReservations") && input.includes("changed while this mutation was being run")) {
194505
+ if (errorCode2 === "spending_reservation_busy") {
194506
+ return {
194507
+ code: errorCode2,
194508
+ message: "MCPJam is temporarily busy reserving spending capacity. Retry this attempt."
194509
+ };
194510
+ }
194511
+ if (input.includes("streamSpendingReservations") && input.includes("changed while this mutation was being run")) {
194258
194512
  return {
194259
194513
  code: "spending_reservation_busy",
194260
194514
  message: "MCPJam could not reserve spending capacity because concurrent requests kept changing it. This is an internal execution failure. Retry this attempt."
@@ -200764,6 +201018,12 @@ function stableStringify4(value, depth = 0) {
200764
201018
  }
200765
201019
 
200766
201020
  // server/services/evals/harness-admission.ts
201021
+ function caseReasoningEffort(test) {
201022
+ return test.reasoningEffort ?? selectionReasoningEffort(test.selection);
201023
+ }
201024
+ function hostSavedReasoningEffort(hostConfig) {
201025
+ return selectionReasoningEffort(hostConfig.modelSelection);
201026
+ }
200767
201027
  var MODEL_FREE_SENTINEL_PROVIDER = "none";
200768
201028
  function isModelFreeCase(test) {
200769
201029
  return !test.model || test.provider === MODEL_FREE_SENTINEL_PROVIDER || test.model === "widget-probe";
@@ -200831,7 +201091,9 @@ function checkEvalHarnessStaticAdmission(args) {
200831
201091
  xaaEnterprisePolicyOn: readXaaEnterprisePolicy(hostConfig.mcpProfile).kind !== "off",
200832
201092
  // Evals refuse an unverified harness × model pair ("not verified for
200833
201093
  // <harness> <version>") rather than run it.
200834
- purpose: "eval"
201094
+ purpose: "eval",
201095
+ // The host's saved effort is known here; refusing it now costs nothing.
201096
+ ...hostSavedReasoningEffort(hostConfig) !== void 0 ? { reasoningEffort: hostSavedReasoningEffort(hostConfig) } : {}
200835
201097
  });
200836
201098
  if (!availability.ok) {
200837
201099
  if (!hostModelId && isModelKind(availability.kind)) {
@@ -200853,7 +201115,8 @@ function checkEvalHarnessAdmission(args) {
200853
201115
  const ineligible = [];
200854
201116
  const verdictByModel = /* @__PURE__ */ new Map();
200855
201117
  for (const test of modelCases) {
200856
- const key = `${test.provider ?? ""}::${test.model}`;
201118
+ const effort = caseReasoningEffort(test) ?? hostSavedReasoningEffort(hostConfig);
201119
+ const key = `${test.provider ?? ""}::${test.model}::${effort ?? ""}`;
200857
201120
  let verdict = verdictByModel.get(key);
200858
201121
  if (!verdictByModel.has(key)) {
200859
201122
  const availability = checkHarnessRuntimeAvailable({
@@ -200870,7 +201133,8 @@ function checkEvalHarnessAdmission(args) {
200870
201133
  // more answer that than a request body can.
200871
201134
  ...fullCheckHostModelId ? { hostModelId: fullCheckHostModelId } : {},
200872
201135
  xaaEnterprisePolicyOn,
200873
- purpose: "eval"
201136
+ purpose: "eval",
201137
+ ...effort !== void 0 ? { reasoningEffort: effort } : {}
200874
201138
  });
200875
201139
  verdict = availability.ok ? void 0 : { reason: availability.reason, kind: availability.kind };
200876
201140
  verdictByModel.set(key, verdict);
@@ -206309,6 +206573,7 @@ function buildHandlerOptions(opts, captureTranscript) {
206309
206573
  mcpClientManager: opts.mcpClientManager,
206310
206574
  authHeader: opts.authContext.token,
206311
206575
  ...opts.temperature !== void 0 ? { temperature: opts.temperature } : {},
206576
+ ...opts.reasoningEffort !== void 0 ? { reasoningEffort: opts.reasoningEffort } : {},
206312
206577
  ...opts.scenarioId ? { scenarioId: opts.scenarioId } : {},
206313
206578
  ...opts.accessVersion !== void 0 ? { accessVersion: opts.accessVersion } : {},
206314
206579
  ...opts.projectId ? { projectId: opts.projectId } : {},
@@ -206408,6 +206673,7 @@ async function runAssistantTurn(opts) {
206408
206673
  const harnessModelId = String(opts.modelDefinition.id);
206409
206674
  if (harnessRequested) {
206410
206675
  const harnessAdapter = getHarnessAdapter(opts.harness);
206676
+ const harnessEffort = opts.reasoningEffort ?? selectionReasoningEffort(opts.extraBodyFields?.modelSelection);
206411
206677
  const purpose = harnessModelPurposeForSourceType(opts.sourceType);
206412
206678
  const { refusal, warning: warning2 } = harnessModelRefusal({
206413
206679
  adapter: harnessAdapter,
@@ -206418,6 +206684,15 @@ async function runAssistantTurn(opts) {
206418
206684
  },
206419
206685
  purpose
206420
206686
  });
206687
+ const effortRefusal = harnessReasoningEffortRefusalReason({
206688
+ adapter: harnessAdapter,
206689
+ ...harnessEffort !== void 0 ? { reasoningEffort: harnessEffort } : {}
206690
+ });
206691
+ if (effortRefusal) {
206692
+ throw new Error(
206693
+ `This host runs the ${opts.harness} harness, which isn't available: ${effortRefusal}.`
206694
+ );
206695
+ }
206421
206696
  if (refusal) {
206422
206697
  throw new Error(
206423
206698
  `This host runs the ${opts.harness} harness, which isn't available: ${refusal.reason}.`
@@ -208353,7 +208628,7 @@ function resolveEffectiveModelSettings(input) {
208353
208628
  );
208354
208629
  }
208355
208630
  if (route === "direct") {
208356
- const options = reasoningEffortProviderOptions({
208631
+ const options = reasoningEffortProviderOptions2({
208357
208632
  providerKey: String(modelDefinition.provider),
208358
208633
  modelId,
208359
208634
  effort: effort.value
@@ -208406,48 +208681,8 @@ function resolveEffectiveModelSettings(input) {
208406
208681
  ...providerOptions ? { providerOptions } : {}
208407
208682
  };
208408
208683
  }
208409
- var OPENAI_EFFORTS = [
208410
- "none",
208411
- "minimal",
208412
- "low",
208413
- "medium",
208414
- "high",
208415
- "xhigh"
208416
- ];
208417
- var ANTHROPIC_EFFORTS = [
208418
- "low",
208419
- "medium",
208420
- "high",
208421
- "xhigh",
208422
- "max"
208423
- ];
208424
- var GOOGLE_EFFORTS = [
208425
- "minimal",
208426
- "low",
208427
- "medium",
208428
- "high"
208429
- ];
208430
- function bareModelName(modelId) {
208431
- const slash = modelId.indexOf("/");
208432
- return slash >= 0 ? modelId.slice(slash + 1) : modelId;
208433
- }
208434
- function reasoningEffortProviderOptions(args) {
208435
- const name15 = bareModelName(args.modelId);
208436
- switch (args.providerKey) {
208437
- case "openai":
208438
- return /^(gpt-5|o[1-9])(?:[.-]|$)/.test(name15) && OPENAI_EFFORTS.includes(args.effort) ? { openai: { reasoningEffort: args.effort } } : void 0;
208439
- case "anthropic":
208440
- return /^claude-/.test(name15) && ANTHROPIC_EFFORTS.includes(args.effort) ? {
208441
- anthropic: {
208442
- effort: args.effort,
208443
- .../^claude-opus-4[.-]5(?:-|$)/.test(name15) ? {} : { thinking: { type: "adaptive" } }
208444
- }
208445
- } : void 0;
208446
- case "google":
208447
- return /^gemini-([3-9]|[1-9][0-9])(?:[.-]|$)/.test(name15) && GOOGLE_EFFORTS.includes(args.effort) ? { google: { thinkingConfig: { thinkingLevel: args.effort } } } : void 0;
208448
- default:
208449
- return void 0;
208450
- }
208684
+ function reasoningEffortProviderOptions2(args) {
208685
+ return reasoningEffortProviderOptions(args);
208451
208686
  }
208452
208687
 
208453
208688
  // server/utils/local-execution-record.ts
@@ -219086,6 +219321,28 @@ var MEMBERSHIP_REFUSAL = /not a member of this (?:project|workspace|organization
219086
219321
  var ARGUMENT_VALIDATION_FAILURE = /\bArgumentValidationError\b/i;
219087
219322
  var REDACTED_SERVER_ERROR = /\bserver error\b/i;
219088
219323
  var AUTHENTICATION_FAILURE = /\b(unauthenticated|invalid token|token (has )?expired|expired token|jwt)\b/i;
219324
+ function redactedReadRefusalError(error, notFoundMessage) {
219325
+ if (error instanceof WebRouteError) return void 0;
219326
+ if (hasConvexErrorData(error)) return void 0;
219327
+ if (classifyConvexReadError(error).kind !== "redacted") return void 0;
219328
+ logRedactedReadAsNotFound("v1.read-refusal", error);
219329
+ return new WebRouteError(404, ErrorCode.NOT_FOUND, notFoundMessage);
219330
+ }
219331
+ function logRedactedReadAsNotFound(scope, error) {
219332
+ logger.warn(`[${scope}] redacted read failure answered as not found`, {
219333
+ scope,
219334
+ detail: redactForLog(error)
219335
+ });
219336
+ }
219337
+ function hasConvexErrorData(error) {
219338
+ let current = error;
219339
+ for (let depth = 0; depth < 4 && current; depth += 1) {
219340
+ const data = current.data;
219341
+ if (data !== void 0 && data !== null) return true;
219342
+ current = current.cause;
219343
+ }
219344
+ return false;
219345
+ }
219089
219346
  function classifyConvexReadError(error) {
219090
219347
  const message = error instanceof Error ? error.message : String(error);
219091
219348
  if (MEMBERSHIP_REFUSAL.test(message)) return { kind: "membership" };
@@ -219097,6 +219354,8 @@ function classifyConvexReadError(error) {
219097
219354
  }
219098
219355
  function translateConvexReadError(error, options) {
219099
219356
  if (error instanceof WebRouteError) return error;
219357
+ const structured = translateStructuredConvexRefusal(error);
219358
+ if (structured) return structured;
219100
219359
  const failure = classifyConvexReadError(error);
219101
219360
  if (failure.kind === "invalid-argument") {
219102
219361
  logger.warn(`[${options.scope}] convex rejected read arguments`, {
@@ -219109,7 +219368,15 @@ function translateConvexReadError(error, options) {
219109
219368
  options.notFoundMessage ?? "Not found"
219110
219369
  );
219111
219370
  }
219112
- if (failure.kind === "membership" || failure.kind === "redacted" && options.redactedIsRefusal === true) {
219371
+ if (failure.kind === "redacted" && options.redactedIsRefusal === true) {
219372
+ logRedactedReadAsNotFound(options.scope, error);
219373
+ return new WebRouteError(
219374
+ 404,
219375
+ ErrorCode.NOT_FOUND,
219376
+ options.notFoundMessage ?? "Not found"
219377
+ );
219378
+ }
219379
+ if (failure.kind === "membership") {
219113
219380
  return new WebRouteError(
219114
219381
  404,
219115
219382
  ErrorCode.NOT_FOUND,
@@ -219819,6 +220086,13 @@ function isConvexNotVisibleError(error) {
219819
220086
  const message = error instanceof Error ? error.message : String(error);
219820
220087
  return /not found|unauthorized|not a member/i.test(message);
219821
220088
  }
220089
+ function scopedEvalReadOptions(notFoundMessage, phase = "preflight") {
220090
+ return {
220091
+ scope: "v1.evals",
220092
+ notFoundMessage,
220093
+ redactedIsRefusal: phase === "preflight"
220094
+ };
220095
+ }
219822
220096
  function evalIdParam(c, param, resource) {
219823
220097
  return requireConvexIdParam(c, param, {
219824
220098
  scope: "v1.evals",
@@ -219843,7 +220117,7 @@ function requireProjectMatch(resource, projectId, what) {
219843
220117
  throw new WebRouteError(404, ErrorCode.NOT_FOUND, `${what} not found`);
219844
220118
  }
219845
220119
  }
219846
- async function readSuiteInProject(convexAuthToken, projectId, suiteId) {
220120
+ async function readSuiteInProject(convexAuthToken, projectId, suiteId, phase) {
219847
220121
  requireConvexIdShape(suiteId, "suiteId", {
219848
220122
  scope: "v1.evals",
219849
220123
  notFoundMessage: "Eval suite not found"
@@ -219855,10 +220129,10 @@ async function readSuiteInProject(convexAuthToken, projectId, suiteId) {
219855
220129
  { suiteId }
219856
220130
  );
219857
220131
  } catch (error) {
219858
- throw translateConvexReadError(error, {
219859
- scope: "v1.evals",
219860
- notFoundMessage: "Eval suite not found"
219861
- });
220132
+ throw translateConvexReadError(
220133
+ error,
220134
+ scopedEvalReadOptions("Eval suite not found", phase)
220135
+ );
219862
220136
  }
219863
220137
  requireProjectMatch(suite, projectId, "Eval suite");
219864
220138
  return suite;
@@ -219998,7 +220272,7 @@ function assertScheduleSurvivesEnvironmentChange(suite, nextEnvironmentIds) {
219998
220272
  );
219999
220273
  }
220000
220274
  }
220001
- async function fetchSuiteRunServerSelection(convexAuthToken, suiteId, namedHostId) {
220275
+ async function fetchSuiteRunServerSelection(convexAuthToken, suiteId, namedHostId, phase) {
220002
220276
  requireConvexIdShape(suiteId, "suiteId", {
220003
220277
  scope: "v1.evals",
220004
220278
  notFoundMessage: "Eval suite not found"
@@ -220025,10 +220299,10 @@ async function fetchSuiteRunServerSelection(convexAuthToken, suiteId, namedHostI
220025
220299
  "This deployment cannot derive the suite's saved servers yet. Pass serverIds explicitly."
220026
220300
  );
220027
220301
  }
220028
- throw translateConvexReadError(error, {
220029
- scope: "v1.evals",
220030
- notFoundMessage: "Eval suite not found"
220031
- });
220302
+ throw translateConvexReadError(
220303
+ error,
220304
+ scopedEvalReadOptions("Eval suite not found", phase)
220305
+ );
220032
220306
  }
220033
220307
  if (selection == null) {
220034
220308
  throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Eval suite not found");
@@ -221657,7 +221931,12 @@ async function resolveLaunchServers(params) {
221657
221931
  const environmentId = suiteId ? await selectSuiteEnvironmentId({
221658
221932
  convexAuthToken,
221659
221933
  projectId,
221660
- suite: await readSuiteInProject(convexAuthToken, projectId, suiteId),
221934
+ suite: await readSuiteInProject(
221935
+ convexAuthToken,
221936
+ projectId,
221937
+ suiteId,
221938
+ params.suiteReadPhase
221939
+ ),
221661
221940
  requestedEnvironmentId: params.requestedEnvironmentId,
221662
221941
  hasServerOverride: params.requestedServerIds.length > 0,
221663
221942
  serverField: "serverIds",
@@ -221683,7 +221962,8 @@ async function resolveLaunchServers(params) {
221683
221962
  const selection = await fetchSuiteRunServerSelection(
221684
221963
  convexAuthToken,
221685
221964
  suiteId,
221686
- namedHostId
221965
+ namedHostId,
221966
+ namedHostId ? "preflight" : "authorized"
221687
221967
  );
221688
221968
  serverIds = selection.serverIds;
221689
221969
  serverNames = selection.serverNames;
@@ -221731,6 +222011,7 @@ evals.post("/projects/:projectId/eval-runs", async (c) => {
221731
222011
  convexAuthToken,
221732
222012
  projectId,
221733
222013
  suiteId: body.suiteId,
222014
+ suiteReadPhase: "preflight",
221734
222015
  requestedEnvironmentId: body.environmentId,
221735
222016
  namedHostId: body.namedHostId,
221736
222017
  requestedServerIds: body.serverIds ?? [],
@@ -221908,7 +222189,8 @@ evals.post("/projects/:projectId/eval-run-groups", async (c) => {
221908
222189
  const suite = await readSuiteInProject(
221909
222190
  convexAuthToken,
221910
222191
  projectId,
221911
- body.suiteId
222192
+ body.suiteId,
222193
+ "preflight"
221912
222194
  );
221913
222195
  const attachedEnvironmentIds = suiteEnvironmentIds(suite);
221914
222196
  const attachedHosts = Array.isArray(
@@ -221980,6 +222262,7 @@ evals.post("/projects/:projectId/eval-run-groups", async (c) => {
221980
222262
  convexAuthToken,
221981
222263
  projectId,
221982
222264
  suiteId: body.suiteId,
222265
+ suiteReadPhase: "authorized",
221983
222266
  requestedEnvironmentId: target.environmentId,
221984
222267
  namedHostId: target.namedHostId,
221985
222268
  requestedServerIds: [],
@@ -222225,7 +222508,12 @@ evals.post("/projects/:projectId/eval-suites", async (c) => {
222225
222508
  ...idempotencyKey ? { idempotencyKey } : {}
222226
222509
  });
222227
222510
  let attachedHostIds = [];
222228
- const authoredSuite = body.hosts?.length ? await readSuiteInProject(convexAuthToken, projectId, suiteId) : null;
222511
+ const authoredSuite = body.hosts?.length ? await readSuiteInProject(
222512
+ convexAuthToken,
222513
+ projectId,
222514
+ suiteId,
222515
+ "authorized"
222516
+ ) : null;
222229
222517
  if ((authoredSuite?.environmentIds?.length ?? 0) > 0) {
222230
222518
  attachedHostIds = (preResolvedHosts ?? []).map(
222231
222519
  (attachment) => String(attachment.namedHostId)
@@ -222311,7 +222599,8 @@ evals.post("/projects/:projectId/eval-suites/from-file", async (c) => {
222311
222599
  token,
222312
222600
  projectId,
222313
222601
  String(result.suite._id),
222314
- vocabularyOf(c)
222602
+ vocabularyOf(c),
222603
+ "authorized"
222315
222604
  );
222316
222605
  return v1Resource(
222317
222606
  c,
@@ -222327,10 +222616,10 @@ evals.get("/projects/:projectId/eval-runs/:runId", async (c) => {
222327
222616
  try {
222328
222617
  run3 = await convex.query("testSuites:getTestSuiteRun", { runId });
222329
222618
  } catch (error) {
222330
- throw translateConvexReadError(error, {
222331
- scope: "v1.evals",
222332
- notFoundMessage: "Eval run not found"
222333
- });
222619
+ throw translateConvexReadError(
222620
+ error,
222621
+ scopedEvalReadOptions("Eval run not found")
222622
+ );
222334
222623
  }
222335
222624
  requireProjectMatch(run3, projectId, "Eval run");
222336
222625
  const insights = await loadInsightsEnvelope(
@@ -222386,10 +222675,10 @@ evals.get("/projects/:projectId/eval-runs/:runId/compare", async (c) => {
222386
222675
  try {
222387
222676
  run3 = await convex.query("testSuites:getTestSuiteRun", { runId });
222388
222677
  } catch (error) {
222389
- throw translateConvexReadError(error, {
222390
- scope: "v1.evals",
222391
- notFoundMessage: "Eval run not found"
222392
- });
222678
+ throw translateConvexReadError(
222679
+ error,
222680
+ scopedEvalReadOptions("Eval run not found")
222681
+ );
222393
222682
  }
222394
222683
  requireProjectMatch(run3, projectId, "Eval run");
222395
222684
  let result;
@@ -222458,10 +222747,10 @@ evals.post("/projects/:projectId/eval-runs/:runId/insights", async (c) => {
222458
222747
  try {
222459
222748
  run3 = await convex.query("testSuites:getTestSuiteRun", { runId });
222460
222749
  } catch (error) {
222461
- throw translateConvexReadError(error, {
222462
- scope: "v1.evals",
222463
- notFoundMessage: "Eval run not found"
222464
- });
222750
+ throw translateConvexReadError(
222751
+ error,
222752
+ scopedEvalReadOptions("Eval run not found")
222753
+ );
222465
222754
  }
222466
222755
  requireProjectMatch(run3, projectId, "Eval run");
222467
222756
  const raw = await c.req.text();
@@ -222499,10 +222788,10 @@ evals.post("/projects/:projectId/eval-runs/:runId/judge", async (c) => {
222499
222788
  try {
222500
222789
  run3 = await convex.query("testSuites:getTestSuiteRun", { runId });
222501
222790
  } catch (error) {
222502
- throw translateConvexReadError(error, {
222503
- scope: "v1.evals",
222504
- notFoundMessage: "Eval run not found"
222505
- });
222791
+ throw translateConvexReadError(
222792
+ error,
222793
+ scopedEvalReadOptions("Eval run not found")
222794
+ );
222506
222795
  }
222507
222796
  requireProjectMatch(run3, projectId, "Eval run");
222508
222797
  const raw = await c.req.text();
@@ -222546,10 +222835,10 @@ evals.post("/projects/:projectId/eval-runs/:runId/cancel", async (c) => {
222546
222835
  runId
222547
222836
  });
222548
222837
  } catch (error) {
222549
- throw translateConvexReadError(error, {
222550
- scope: "v1.evals",
222551
- notFoundMessage: "Eval run not found"
222552
- });
222838
+ throw translateConvexReadError(
222839
+ error,
222840
+ scopedEvalReadOptions("Eval run not found")
222841
+ );
222553
222842
  }
222554
222843
  requireProjectMatch(run3, projectId, "Eval run");
222555
222844
  const status = String(run3.status);
@@ -222638,10 +222927,10 @@ evals.post("/projects/:projectId/eval-runs/:runId/gate-waivers", async (c) => {
222638
222927
  runId
222639
222928
  });
222640
222929
  } catch (error) {
222641
- throw translateConvexReadError(error, {
222642
- scope: "v1.evals",
222643
- notFoundMessage: "Eval run not found"
222644
- });
222930
+ throw translateConvexReadError(
222931
+ error,
222932
+ scopedEvalReadOptions("Eval run not found")
222933
+ );
222645
222934
  }
222646
222935
  requireProjectMatch(run3, projectId, "Eval run");
222647
222936
  let result;
@@ -222667,10 +222956,10 @@ evals.get("/projects/:projectId/eval-runs/:runId/gate-waivers", async (c) => {
222667
222956
  try {
222668
222957
  run3 = await convex.query("testSuites:getTestSuiteRun", { runId });
222669
222958
  } catch (error) {
222670
- throw translateConvexReadError(error, {
222671
- scope: "v1.evals",
222672
- notFoundMessage: "Eval run not found"
222673
- });
222959
+ throw translateConvexReadError(
222960
+ error,
222961
+ scopedEvalReadOptions("Eval run not found")
222962
+ );
222674
222963
  }
222675
222964
  requireProjectMatch(run3, projectId, "Eval run");
222676
222965
  let waiver;
@@ -222703,10 +222992,10 @@ evals.delete(
222703
222992
  runId
222704
222993
  });
222705
222994
  } catch (error) {
222706
- throw translateConvexReadError(error, {
222707
- scope: "v1.evals",
222708
- notFoundMessage: "Eval run not found"
222709
- });
222995
+ throw translateConvexReadError(
222996
+ error,
222997
+ scopedEvalReadOptions("Eval run not found")
222998
+ );
222710
222999
  }
222711
223000
  requireProjectMatch(run3, projectId, "Eval run");
222712
223001
  const activeWaiverId = run3?.gateWaiver?.id ? String(run3.gateWaiver.id) : null;
@@ -222740,9 +223029,11 @@ evals.get(
222740
223029
  const convex = createConvexReadClient(await getConvexBearerForRequest(c));
222741
223030
  let run3;
222742
223031
  let page3;
223032
+ let scopeVerified = false;
222743
223033
  try {
222744
223034
  run3 = await convex.query("testSuites:getTestSuiteRun", { runId });
222745
223035
  requireProjectMatch(run3, projectId, "Eval run");
223036
+ scopeVerified = true;
222746
223037
  page3 = await convex.query(
222747
223038
  "testSuites:listTestSuiteRunIterations",
222748
223039
  {
@@ -222752,8 +223043,8 @@ evals.get(
222752
223043
  );
222753
223044
  } catch (error) {
222754
223045
  throw translateConvexReadError(error, {
222755
- scope: "v1.evals",
222756
- notFoundMessage: "Eval run not found"
223046
+ ...scopedEvalReadOptions("Eval run not found"),
223047
+ redactedIsRefusal: !scopeVerified
222757
223048
  });
222758
223049
  }
222759
223050
  const complete = decisionSummaryPageIsComplete({
@@ -222793,17 +223084,19 @@ evals.get("/projects/:projectId/eval-runs/:runId/iterations", async (c) => {
222793
223084
  const convex = createConvexReadClient(await getConvexBearerForRequest(c));
222794
223085
  let run3;
222795
223086
  let page3;
223087
+ let scopeVerified = false;
222796
223088
  try {
222797
223089
  run3 = await convex.query("testSuites:getTestSuiteRun", { runId });
222798
223090
  requireProjectMatch(run3, projectId, "Eval run");
223091
+ scopeVerified = true;
222799
223092
  page3 = await convex.query("testSuites:listTestSuiteRunIterations", {
222800
223093
  runId,
222801
223094
  paginationOpts: { numItems: limit, cursor }
222802
223095
  });
222803
223096
  } catch (error) {
222804
223097
  throw translateConvexReadError(error, {
222805
- scope: "v1.evals",
222806
- notFoundMessage: "Eval run not found"
223098
+ ...scopedEvalReadOptions("Eval run not found"),
223099
+ redactedIsRefusal: !scopeVerified
222807
223100
  });
222808
223101
  }
222809
223102
  const listVocabulary = vocabularyOf(c);
@@ -222824,6 +223117,7 @@ evals.get(
222824
223117
  const convexAuthToken = await getConvexBearerForRequest(c);
222825
223118
  const convex = createConvexReadClient(convexAuthToken);
222826
223119
  let trace;
223120
+ let scopeVerified = false;
222827
223121
  try {
222828
223122
  const [run3, iteration] = await Promise.all([
222829
223123
  convex.query("testSuites:getTestSuiteRun", { runId }),
@@ -222837,13 +223131,14 @@ evals.get(
222837
223131
  "Eval iteration not found"
222838
223132
  );
222839
223133
  }
223134
+ scopeVerified = true;
222840
223135
  trace = await convex.action("testSuites:getTestIterationBlob", {
222841
223136
  iterationId
222842
223137
  });
222843
223138
  } catch (error) {
222844
223139
  throw translateConvexReadError(error, {
222845
- scope: "v1.evals",
222846
- notFoundMessage: "Eval iteration not found"
223140
+ ...scopedEvalReadOptions("Eval iteration not found"),
223141
+ redactedIsRefusal: !scopeVerified
222847
223142
  });
222848
223143
  }
222849
223144
  if (trace === null || trace === void 0) {
@@ -222888,10 +223183,10 @@ evals.get(
222888
223183
  );
222889
223184
  }
222890
223185
  } catch (error) {
222891
- throw translateConvexReadError(error, {
222892
- scope: "v1.evals",
222893
- notFoundMessage: "Eval iteration not found"
222894
- });
223186
+ throw translateConvexReadError(
223187
+ error,
223188
+ scopedEvalReadOptions("Eval iteration not found")
223189
+ );
222895
223190
  }
222896
223191
  const snapshot2 = iteration.testCaseSnapshot ?? {};
222897
223192
  const steps = internalCaseToSteps(snapshot2);
@@ -222945,17 +223240,19 @@ evals.get("/projects/:projectId/eval-suites/:suiteId/runs", async (c) => {
222945
223240
  const convex = createConvexReadClient(await getConvexBearerForRequest(c));
222946
223241
  let runs;
222947
223242
  let suite;
223243
+ let scopeVerified = false;
222948
223244
  try {
222949
223245
  suite = await convex.query("testSuites:getTestSuite", { suiteId });
222950
223246
  requireProjectMatch(suite, projectId, "Eval suite");
223247
+ scopeVerified = true;
222951
223248
  runs = await convex.query("testSuites:listTestSuiteRuns", {
222952
223249
  suiteId,
222953
223250
  limit
222954
223251
  });
222955
223252
  } catch (error) {
222956
223253
  throw translateConvexReadError(error, {
222957
- scope: "v1.evals",
222958
- notFoundMessage: "Eval suite not found"
223254
+ ...scopedEvalReadOptions("Eval suite not found"),
223255
+ redactedIsRefusal: !scopeVerified
222959
223256
  });
222960
223257
  }
222961
223258
  return v1PageJson(c, (runs ?? []).map(toRunDto));
@@ -223001,20 +223298,22 @@ evals.get("/projects/:projectId/eval-suites/:suiteId/revisions", async (c) => {
223001
223298
  const cursor = query.cursor ?? null;
223002
223299
  const convex = createConvexReadClient(await getConvexBearerForRequest(c));
223003
223300
  let page3;
223301
+ let scopeVerified = false;
223004
223302
  try {
223005
223303
  const suite = await convex.query(
223006
223304
  "testSuites:getTestSuite",
223007
223305
  { suiteId }
223008
223306
  );
223009
223307
  requireProjectMatch(suite, projectId, "Eval suite");
223308
+ scopeVerified = true;
223010
223309
  page3 = await convex.query("testSuites:listSuiteRevisions", {
223011
223310
  suiteId,
223012
223311
  paginationOpts: { numItems: limit, cursor }
223013
223312
  });
223014
223313
  } catch (error) {
223015
223314
  throw translateConvexReadError(error, {
223016
- scope: "v1.evals",
223017
- notFoundMessage: "Eval suite not found"
223315
+ ...scopedEvalReadOptions("Eval suite not found"),
223316
+ redactedIsRefusal: !scopeVerified
223018
223317
  });
223019
223318
  }
223020
223319
  return v1PageJson(
@@ -223062,11 +223361,13 @@ evals.get(
223062
223361
  const cursor = query.cursor ?? null;
223063
223362
  const convex = createConvexReadClient(await getConvexBearerForRequest(c));
223064
223363
  let page3;
223364
+ let scopeVerified = false;
223065
223365
  try {
223066
223366
  const suite = await convex.query("testSuites:getTestSuite", {
223067
223367
  suiteId
223068
223368
  });
223069
223369
  requireProjectMatch(suite, projectId, "Eval suite");
223370
+ scopeVerified = true;
223070
223371
  page3 = await convex.query("testSuites:listEvalStageAnalytics", {
223071
223372
  projectId,
223072
223373
  suiteId,
@@ -223094,7 +223395,10 @@ evals.get(
223094
223395
  typeof message === "string" ? message : "Invalid stage analytics window"
223095
223396
  );
223096
223397
  }
223097
- throw error;
223398
+ throw translateConvexReadError(error, {
223399
+ ...scopedEvalReadOptions("Eval suite not found"),
223400
+ redactedIsRefusal: !scopeVerified
223401
+ });
223098
223402
  }
223099
223403
  const rows = [];
223100
223404
  for (const row2 of page3.page ?? []) {
@@ -223134,11 +223438,13 @@ evals.get(
223134
223438
  const convex = createConvexReadClient(await getConvexBearerForRequest(c));
223135
223439
  let document2;
223136
223440
  let runSuiteId;
223441
+ let scopeVerified = false;
223137
223442
  try {
223138
223443
  const run3 = await convex.query("testSuites:getTestSuiteRun", {
223139
223444
  runId
223140
223445
  });
223141
223446
  requireProjectMatch(run3, projectId, "Eval run");
223447
+ scopeVerified = true;
223142
223448
  const suiteId = run3?.suiteId;
223143
223449
  runSuiteId = typeof suiteId === "string" ? suiteId : void 0;
223144
223450
  document2 = await convex.query(
@@ -223153,7 +223459,10 @@ evals.get(
223153
223459
  RUN_ANALYTICS_NOT_FOUND
223154
223460
  );
223155
223461
  }
223156
- throw error;
223462
+ throw translateConvexReadError(error, {
223463
+ ...scopedEvalReadOptions(RUN_ANALYTICS_NOT_FOUND),
223464
+ redactedIsRefusal: !scopeVerified
223465
+ });
223157
223466
  }
223158
223467
  if (document2 === null || document2 === void 0) {
223159
223468
  throw new WebRouteError(
@@ -223202,11 +223511,13 @@ evals.get("/projects/:projectId/eval-runs/:runId/gate", async (c) => {
223202
223511
  });
223203
223512
  const convex = createConvexReadClient(await getConvexBearerForRequest(c));
223204
223513
  let document2;
223514
+ let scopeVerified = false;
223205
223515
  try {
223206
223516
  const run3 = await convex.query("testSuites:getTestSuiteRun", {
223207
223517
  runId
223208
223518
  });
223209
223519
  requireProjectMatch(run3, projectId, "Eval run");
223520
+ scopeVerified = true;
223210
223521
  document2 = await convex.query("testSuites:evaluateSuiteGate", {
223211
223522
  runId
223212
223523
  });
@@ -223219,7 +223530,10 @@ evals.get("/projects/:projectId/eval-runs/:runId/gate", async (c) => {
223219
223530
  if (isConvexNotVisibleError(error)) {
223220
223531
  throw new WebRouteError(404, ErrorCode.NOT_FOUND, RUN_GATE_NOT_FOUND);
223221
223532
  }
223222
- throw error;
223533
+ throw translateConvexReadError(error, {
223534
+ ...scopedEvalReadOptions(RUN_GATE_NOT_FOUND),
223535
+ redactedIsRefusal: !scopeVerified
223536
+ });
223223
223537
  }
223224
223538
  if (document2 === null || document2 === void 0) {
223225
223539
  throw new WebRouteError(
@@ -223258,11 +223572,13 @@ evals.get("/projects/:projectId/eval-runs/:runId/route-facts", async (c) => {
223258
223572
  const convex = createConvexReadClient(await getConvexBearerForRequest(c));
223259
223573
  let document2;
223260
223574
  let runSuiteId;
223575
+ let scopeVerified = false;
223261
223576
  try {
223262
223577
  const run3 = await convex.query("testSuites:getTestSuiteRun", {
223263
223578
  runId
223264
223579
  });
223265
223580
  requireProjectMatch(run3, projectId, "Eval run");
223581
+ scopeVerified = true;
223266
223582
  const suiteId = run3?.suiteId;
223267
223583
  runSuiteId = typeof suiteId === "string" ? suiteId : void 0;
223268
223584
  document2 = await convex.query("testSuites:getEvalRunRouteFacts", {
@@ -223276,7 +223592,10 @@ evals.get("/projects/:projectId/eval-runs/:runId/route-facts", async (c) => {
223276
223592
  RUN_ROUTE_FACTS_NOT_FOUND
223277
223593
  );
223278
223594
  }
223279
- throw error;
223595
+ throw translateConvexReadError(error, {
223596
+ ...scopedEvalReadOptions(RUN_ROUTE_FACTS_NOT_FOUND),
223597
+ redactedIsRefusal: !scopeVerified
223598
+ });
223280
223599
  }
223281
223600
  if (document2 === null || document2 === void 0) {
223282
223601
  throw new WebRouteError(
@@ -223323,11 +223642,13 @@ evals.get("/projects/:projectId/eval-runs/:runId/server-facts", async (c) => {
223323
223642
  const convex = createConvexReadClient(await getConvexBearerForRequest(c));
223324
223643
  let document2;
223325
223644
  let runSuiteId;
223645
+ let scopeVerified = false;
223326
223646
  try {
223327
223647
  const run3 = await convex.query("testSuites:getTestSuiteRun", {
223328
223648
  runId
223329
223649
  });
223330
223650
  requireProjectMatch(run3, projectId, "Eval run");
223651
+ scopeVerified = true;
223331
223652
  const suiteId = run3?.suiteId;
223332
223653
  runSuiteId = typeof suiteId === "string" ? suiteId : void 0;
223333
223654
  document2 = await convex.query("testSuites:getEvalRunServerFacts", {
@@ -223346,7 +223667,10 @@ evals.get("/projects/:projectId/eval-runs/:runId/server-facts", async (c) => {
223346
223667
  RUN_SERVER_FACTS_NOT_FOUND
223347
223668
  );
223348
223669
  }
223349
- throw error;
223670
+ throw translateConvexReadError(error, {
223671
+ ...scopedEvalReadOptions(RUN_SERVER_FACTS_NOT_FOUND),
223672
+ redactedIsRefusal: !scopeVerified
223673
+ });
223350
223674
  }
223351
223675
  if (document2 === null || document2 === void 0) {
223352
223676
  throw new WebRouteError(
@@ -223537,7 +223861,10 @@ evals.get(
223537
223861
  if (isConvexNotVisibleError(error)) {
223538
223862
  throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Eval run not found");
223539
223863
  }
223540
- throw error;
223864
+ throw translateConvexReadError(
223865
+ error,
223866
+ scopedEvalReadOptions("Eval run not found")
223867
+ );
223541
223868
  }
223542
223869
  requireProjectMatch(run3, projectId, "Eval run");
223543
223870
  let rows;
@@ -223600,7 +223927,10 @@ evals.post(
223600
223927
  if (isConvexNotVisibleError(error)) {
223601
223928
  throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Eval run not found");
223602
223929
  }
223603
- throw error;
223930
+ throw translateConvexReadError(
223931
+ error,
223932
+ scopedEvalReadOptions("Eval run not found")
223933
+ );
223604
223934
  }
223605
223935
  requireProjectMatch(run3, projectId, "Eval run");
223606
223936
  throwIfDescriptionOverrideUnattributable(run3, body.toolName);
@@ -223656,7 +223986,10 @@ evals.post(
223656
223986
  DESCRIPTION_EXPERIMENT_NOT_FOUND
223657
223987
  );
223658
223988
  }
223659
- throw error;
223989
+ throw translateConvexReadError(
223990
+ error,
223991
+ scopedEvalReadOptions(DESCRIPTION_EXPERIMENT_NOT_FOUND)
223992
+ );
223660
223993
  }
223661
223994
  if (!experiment) {
223662
223995
  throw new WebRouteError(
@@ -223688,7 +224021,10 @@ evals.post(
223688
224021
  if (isConvexNotVisibleError(error)) {
223689
224022
  throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Eval run not found");
223690
224023
  }
223691
- throw error;
224024
+ throw translateConvexReadError(
224025
+ error,
224026
+ scopedEvalReadOptions("Eval run not found")
224027
+ );
223692
224028
  }
223693
224029
  requireProjectMatch(sourceRun, projectId, "Eval run");
223694
224030
  throwIfDescriptionOverrideUnattributable(
@@ -223749,6 +224085,7 @@ evals.post(
223749
224085
  convexAuthToken: token,
223750
224086
  projectId,
223751
224087
  suiteId,
224088
+ suiteReadPhase: "authorized",
223752
224089
  requestedEnvironmentId: envRef?.environmentId,
223753
224090
  namedHostId,
223754
224091
  requestedServerIds: [],
@@ -223948,7 +224285,10 @@ evals.get(
223948
224285
  DESCRIPTION_EXPERIMENT_NOT_FOUND
223949
224286
  );
223950
224287
  }
223951
- throw error;
224288
+ throw translateConvexReadError(
224289
+ error,
224290
+ scopedEvalReadOptions(DESCRIPTION_EXPERIMENT_NOT_FOUND)
224291
+ );
223952
224292
  }
223953
224293
  if (document2 === null || document2 === void 0) {
223954
224294
  throw new WebRouteError(
@@ -224003,16 +224343,16 @@ evals.get(
224003
224343
  return v1Resource(c, toDescriptionExperimentDto(raw));
224004
224344
  }
224005
224345
  );
224006
- async function readSuiteDetail(convexAuthToken, projectId, suiteId, vocabulary4) {
224346
+ async function readSuiteDetail(convexAuthToken, projectId, suiteId, vocabulary4, phase) {
224007
224347
  const convex = createConvexReadClient(convexAuthToken);
224008
224348
  let suite;
224009
224349
  try {
224010
224350
  suite = await convex.query("testSuites:getTestSuite", { suiteId });
224011
224351
  } catch (error) {
224012
- throw translateConvexReadError(error, {
224013
- scope: "v1.evals",
224014
- notFoundMessage: "Eval suite not found"
224015
- });
224352
+ throw translateConvexReadError(
224353
+ error,
224354
+ scopedEvalReadOptions("Eval suite not found", phase)
224355
+ );
224016
224356
  }
224017
224357
  requireProjectMatch(suite, projectId, "Eval suite");
224018
224358
  let execConfig = null;
@@ -224109,7 +224449,13 @@ evals.get("/projects/:projectId/eval-suites/:suiteId", async (c) => {
224109
224449
  const token = await getConvexBearerForRequest(c);
224110
224450
  return suiteResource(
224111
224451
  c,
224112
- await readSuiteDetail(token, projectId, suiteId, vocabularyOf(c))
224452
+ await readSuiteDetail(
224453
+ token,
224454
+ projectId,
224455
+ suiteId,
224456
+ vocabularyOf(c),
224457
+ "preflight"
224458
+ )
224113
224459
  );
224114
224460
  });
224115
224461
  function applyVerdictPolicySettings(suite, settings, updateArgs, names = countFieldNames(1)) {
@@ -224165,10 +224511,10 @@ evals.patch("/projects/:projectId/eval-suites/:suiteId", async (c) => {
224165
224511
  suiteId
224166
224512
  });
224167
224513
  } catch (error) {
224168
- throw translateConvexReadError(error, {
224169
- scope: "v1.evals",
224170
- notFoundMessage: "Eval suite not found"
224171
- });
224514
+ throw translateConvexReadError(
224515
+ error,
224516
+ scopedEvalReadOptions("Eval suite not found")
224517
+ );
224172
224518
  }
224173
224519
  requireProjectMatch(suite, projectId, "Eval suite");
224174
224520
  if (body.environmentIds !== void 0) {
@@ -224397,7 +224743,13 @@ evals.patch("/projects/:projectId/eval-suites/:suiteId", async (c) => {
224397
224743
  }
224398
224744
  return suiteResource(
224399
224745
  c,
224400
- await readSuiteDetail(token, projectId, suiteId, vocabularyOf(c))
224746
+ await readSuiteDetail(
224747
+ token,
224748
+ projectId,
224749
+ suiteId,
224750
+ vocabularyOf(c),
224751
+ "authorized"
224752
+ )
224401
224753
  );
224402
224754
  });
224403
224755
  evals.post(
@@ -224415,7 +224767,7 @@ evals.post(
224415
224767
  { scope: "v1.evals", notFoundMessage: "Environment not found" }
224416
224768
  );
224417
224769
  const token = await getConvexBearerForRequest(c);
224418
- await readSuiteInProject(token, projectId, suiteId);
224770
+ await readSuiteInProject(token, projectId, suiteId, "preflight");
224419
224771
  const { convexClient: convexClient6 } = createConvexClients(token);
224420
224772
  let result;
224421
224773
  try {
@@ -224453,10 +224805,10 @@ evals.delete("/projects/:projectId/eval-suites/:suiteId", async (c) => {
224453
224805
  suiteId
224454
224806
  });
224455
224807
  } catch (error) {
224456
- throw translateConvexReadError(error, {
224457
- scope: "v1.evals",
224458
- notFoundMessage: "Eval suite not found"
224459
- });
224808
+ throw translateConvexReadError(
224809
+ error,
224810
+ scopedEvalReadOptions("Eval suite not found")
224811
+ );
224460
224812
  }
224461
224813
  requireProjectMatch(suite, projectId, "Eval suite");
224462
224814
  const { convexClient: convexClient6 } = createConvexClients(token);
@@ -224490,10 +224842,10 @@ evals.patch("/projects/:projectId/eval-suites/:suiteId/schedule", async (c) => {
224490
224842
  suiteId
224491
224843
  });
224492
224844
  } catch (error) {
224493
- throw translateConvexReadError(error, {
224494
- scope: "v1.evals",
224495
- notFoundMessage: "Eval suite not found"
224496
- });
224845
+ throw translateConvexReadError(
224846
+ error,
224847
+ scopedEvalReadOptions("Eval suite not found")
224848
+ );
224497
224849
  }
224498
224850
  requireProjectMatch(suite, projectId, "Eval suite");
224499
224851
  if (body.enabled && body.intervalMinutes === void 0 && suite?.schedule?.intervalMinutes === void 0) {
@@ -224534,7 +224886,13 @@ evals.patch("/projects/:projectId/eval-suites/:suiteId/schedule", async (c) => {
224534
224886
  }
224535
224887
  return suiteResource(
224536
224888
  c,
224537
- await readSuiteDetail(token, projectId, suiteId, vocabularyOf(c))
224889
+ await readSuiteDetail(
224890
+ token,
224891
+ projectId,
224892
+ suiteId,
224893
+ vocabularyOf(c),
224894
+ "authorized"
224895
+ )
224538
224896
  );
224539
224897
  });
224540
224898
  evals.get("/projects/:projectId/eval-suites/:suiteId/cases", async (c) => {
@@ -224543,14 +224901,16 @@ evals.get("/projects/:projectId/eval-suites/:suiteId/cases", async (c) => {
224543
224901
  const convex = createConvexReadClient(await getConvexBearerForRequest(c));
224544
224902
  let suite;
224545
224903
  let cases;
224904
+ let scopeVerified = false;
224546
224905
  try {
224547
224906
  suite = await convex.query("testSuites:getTestSuite", { suiteId });
224548
224907
  requireProjectMatch(suite, projectId, "Eval suite");
224908
+ scopeVerified = true;
224549
224909
  cases = await convex.query("testSuites:listTestCases", { suiteId });
224550
224910
  } catch (error) {
224551
224911
  throw translateConvexReadError(error, {
224552
- scope: "v1.evals",
224553
- notFoundMessage: "Eval suite not found"
224912
+ ...scopedEvalReadOptions("Eval suite not found"),
224913
+ redactedIsRefusal: !scopeVerified
224554
224914
  });
224555
224915
  }
224556
224916
  const listVocabulary = vocabularyOf(c);
@@ -224563,17 +224923,17 @@ evals.get("/projects/:projectId/eval-suites/:suiteId/cases", async (c) => {
224563
224923
  )
224564
224924
  );
224565
224925
  });
224566
- async function loadCaseInScope(convex, projectId, suiteId, caseId) {
224926
+ async function loadCaseInScope(convex, projectId, suiteId, caseId, phase) {
224567
224927
  let testCase;
224568
224928
  try {
224569
224929
  testCase = await convex.query("testSuites:getTestCase", {
224570
224930
  testCaseId: caseId
224571
224931
  });
224572
224932
  } catch (error) {
224573
- throw translateConvexReadError(error, {
224574
- scope: "v1.evals",
224575
- notFoundMessage: "Eval case not found"
224576
- });
224933
+ throw translateConvexReadError(
224934
+ error,
224935
+ scopedEvalReadOptions("Eval case not found", phase)
224936
+ );
224577
224937
  }
224578
224938
  if (!testCase || String(testCase.testSuiteId ?? "") !== suiteId) {
224579
224939
  throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Eval case not found");
@@ -224588,7 +224948,13 @@ evals.get(
224588
224948
  const suiteId = evalIdParam(c, "suiteId", "Eval suite");
224589
224949
  const caseId = evalIdParam(c, "caseId", "Eval case");
224590
224950
  const convex = createConvexReadClient(await getConvexBearerForRequest(c));
224591
- const testCase = await loadCaseInScope(convex, projectId, suiteId, caseId);
224951
+ const testCase = await loadCaseInScope(
224952
+ convex,
224953
+ projectId,
224954
+ suiteId,
224955
+ caseId,
224956
+ "preflight"
224957
+ );
224592
224958
  return caseResource(c, testCase);
224593
224959
  }
224594
224960
  );
@@ -224605,10 +224971,10 @@ evals.post("/projects/:projectId/eval-suites/:suiteId/cases", async (c) => {
224605
224971
  suiteId
224606
224972
  });
224607
224973
  } catch (error) {
224608
- throw translateConvexReadError(error, {
224609
- scope: "v1.evals",
224610
- notFoundMessage: "Eval suite not found"
224611
- });
224974
+ throw translateConvexReadError(
224975
+ error,
224976
+ scopedEvalReadOptions("Eval suite not found")
224977
+ );
224612
224978
  }
224613
224979
  requireProjectMatch(suite, projectId, "Eval suite");
224614
224980
  assertCasePolicyFieldsSupported(
@@ -224651,7 +225017,8 @@ evals.post("/projects/:projectId/eval-suites/:suiteId/cases", async (c) => {
224651
225017
  createConvexReadClient(token),
224652
225018
  projectId,
224653
225019
  suiteId,
224654
- String(committed.testCaseId)
225020
+ String(committed.testCaseId),
225021
+ "authorized"
224655
225022
  );
224656
225023
  return caseResource(c, created, 201);
224657
225024
  });
@@ -224672,10 +225039,10 @@ evals.post(
224672
225039
  suiteId
224673
225040
  });
224674
225041
  } catch (error) {
224675
- throw translateConvexReadError(error, {
224676
- scope: "v1.evals",
224677
- notFoundMessage: "Eval suite not found"
224678
- });
225042
+ throw translateConvexReadError(
225043
+ error,
225044
+ scopedEvalReadOptions("Eval suite not found")
225045
+ );
224679
225046
  }
224680
225047
  requireProjectMatch(suite, projectId, "Eval suite");
224681
225048
  const names = countFieldNames(vocabularyOf(c));
@@ -224771,11 +225138,12 @@ evals.patch(
224771
225138
  createConvexReadClient(token),
224772
225139
  projectId,
224773
225140
  suiteId,
224774
- caseId
225141
+ caseId,
225142
+ "preflight"
224775
225143
  );
224776
225144
  if (body.repetitions !== void 0 || body.passThreshold !== void 0) {
224777
225145
  assertCasePolicyFieldsSupported(
224778
- await readSuiteInProject(token, projectId, suiteId),
225146
+ await readSuiteInProject(token, projectId, suiteId, "authorized"),
224779
225147
  body,
224780
225148
  "",
224781
225149
  countFieldNames(vocabularyOf(c))
@@ -224811,7 +225179,8 @@ evals.patch(
224811
225179
  createConvexReadClient(token),
224812
225180
  projectId,
224813
225181
  suiteId,
224814
- caseId
225182
+ caseId,
225183
+ "authorized"
224815
225184
  );
224816
225185
  }
224817
225186
  return caseResource(c, updated);
@@ -224828,7 +225197,8 @@ evals.delete(
224828
225197
  createConvexReadClient(token),
224829
225198
  projectId,
224830
225199
  suiteId,
224831
- caseId
225200
+ caseId,
225201
+ "preflight"
224832
225202
  );
224833
225203
  const { convexClient: convexClient6 } = createConvexClients(token);
224834
225204
  try {
@@ -224864,10 +225234,10 @@ evals.post(
224864
225234
  suiteId
224865
225235
  });
224866
225236
  } catch (error) {
224867
- throw translateConvexReadError(error, {
224868
- scope: "v1.evals",
224869
- notFoundMessage: "Eval suite not found"
224870
- });
225237
+ throw translateConvexReadError(
225238
+ error,
225239
+ scopedEvalReadOptions("Eval suite not found")
225240
+ );
224871
225241
  }
224872
225242
  requireProjectMatch(suite, projectId, "Eval suite");
224873
225243
  const environmentId = await selectSuiteEnvironmentId({
@@ -224897,7 +225267,8 @@ evals.post(
224897
225267
  const selection = await fetchSuiteRunServerSelection(
224898
225268
  token,
224899
225269
  suiteId,
224900
- void 0
225270
+ void 0,
225271
+ "authorized"
224901
225272
  );
224902
225273
  serverIds = selection.serverIds;
224903
225274
  serverNames = selection.serverNames;
@@ -224952,10 +225323,10 @@ evals.post(
224952
225323
  suiteId
224953
225324
  });
224954
225325
  } catch (error) {
224955
- throw translateConvexReadError(error, {
224956
- scope: "v1.evals",
224957
- notFoundMessage: "Eval suite not found"
224958
- });
225326
+ throw translateConvexReadError(
225327
+ error,
225328
+ scopedEvalReadOptions("Eval suite not found")
225329
+ );
224959
225330
  }
224960
225331
  requireProjectMatch(suite, projectId, "Eval suite");
224961
225332
  const environmentId = await selectSuiteEnvironmentId({
@@ -224989,7 +225360,8 @@ evals.post(
224989
225360
  const selection = await fetchSuiteRunServerSelection(
224990
225361
  token,
224991
225362
  suiteId,
224992
- void 0
225363
+ void 0,
225364
+ "authorized"
224993
225365
  );
224994
225366
  serverIds = selection.serverIds;
224995
225367
  serverNames = selection.serverNames;
@@ -225033,9 +225405,17 @@ evals.get(
225033
225405
  "/projects/:projectId/eval-suites/:suiteId/authoring/:jobId",
225034
225406
  async (c) => {
225035
225407
  const convex = createConvexReadClient(await getConvexBearerForRequest(c));
225036
- const job = await convex.query("evalAuthoringState:status", {
225037
- jobId: evalIdParam(c, "jobId", "Authoring job")
225038
- });
225408
+ let job;
225409
+ try {
225410
+ job = await convex.query("evalAuthoringState:status", {
225411
+ jobId: evalIdParam(c, "jobId", "Authoring job")
225412
+ });
225413
+ } catch (error) {
225414
+ throw translateConvexReadError(
225415
+ error,
225416
+ scopedEvalReadOptions("Authoring job not found.")
225417
+ );
225418
+ }
225039
225419
  if (!job || job.projectId !== c.req.param("projectId") || job.suiteId !== c.req.param("suiteId"))
225040
225420
  throw new WebRouteError(
225041
225421
  404,
@@ -225051,9 +225431,17 @@ evals.post(
225051
225431
  const { convexClient: convex } = createConvexClients(
225052
225432
  await getConvexBearerForRequest(c)
225053
225433
  );
225054
- const job = await convex.query("evalAuthoringState:status", {
225055
- jobId: evalIdParam(c, "jobId", "Authoring job")
225056
- });
225434
+ let job;
225435
+ try {
225436
+ job = await convex.query("evalAuthoringState:status", {
225437
+ jobId: evalIdParam(c, "jobId", "Authoring job")
225438
+ });
225439
+ } catch (error) {
225440
+ throw translateConvexReadError(
225441
+ error,
225442
+ scopedEvalReadOptions("Generated authoring job not found.")
225443
+ );
225444
+ }
225057
225445
  const suiteId = c.req.param("suiteId");
225058
225446
  if (!job || job.projectId !== c.req.param("projectId") || job.suiteId !== suiteId || job.source === "markdown")
225059
225447
  throw new WebRouteError(
@@ -225130,7 +225518,8 @@ async function startAuthoringJobAndAwait(c, args) {
225130
225518
  try {
225131
225519
  job = JSON.parse(bodyText);
225132
225520
  } catch {
225133
- if (!response.ok) throw authoringRefusal(response, bodyText, args, void 0);
225521
+ if (!response.ok)
225522
+ throw authoringRefusal(response, bodyText, args, void 0);
225134
225523
  throw new WebRouteError(
225135
225524
  502,
225136
225525
  ErrorCode.SERVER_UNREACHABLE,
@@ -225379,7 +225768,12 @@ async function handleEvalAuthoring(c, local) {
225379
225768
  const selection = environment ? {
225380
225769
  serverIds: environmentServerIds(environment),
225381
225770
  serverNames: environmentServerNames(environment)
225382
- } : await fetchSuiteRunServerSelection(token, input.suiteId, void 0);
225771
+ } : await fetchSuiteRunServerSelection(
225772
+ token,
225773
+ input.suiteId,
225774
+ void 0,
225775
+ "authorized"
225776
+ );
225383
225777
  const { manager } = await createAuthorizedManager(
225384
225778
  callerContextFromHono(c),
225385
225779
  token,
@@ -244261,7 +244655,7 @@ function spendRefusalOf(error) {
244261
244655
  return void 0;
244262
244656
  if (!(error instanceof Error)) return void 0;
244263
244657
  const info = humanizeSwarmAttemptError(error.message);
244264
- return info.refusalReason ? info : void 0;
244658
+ return info.refusalReason || isTransientSpendRefusal(info.code) ? info : void 0;
244265
244659
  }
244266
244660
  var AdmissionWaitBudget = class {
244267
244661
  constructor(totalMs = 5 * 6e4, maxAttemptsPerCall = 8) {
@@ -244458,7 +244852,7 @@ async function resolveTurnRuntime(args) {
244458
244852
  assertOrgModelAllowed(orgRuntime.provider, modelId);
244459
244853
  const llmModel = buildOrgModelFromResolvedConfig(orgRuntime.provider, modelId);
244460
244854
  const effort = args.settings?.reasoningEffort;
244461
- const providerOptions = effort ? reasoningEffortProviderOptions({
244855
+ const providerOptions = effort ? reasoningEffortProviderOptions2({
244462
244856
  providerKey: orgRuntime.provider.providerKey,
244463
244857
  modelId: args.modelSelection?.modelId ?? modelId,
244464
244858
  effort
@@ -246956,6 +247350,13 @@ function swarmTargetModelDefinition(target) {
246956
247350
  }
246957
247351
  return definition;
246958
247352
  }
247353
+ function swarmTargetReasoningEffort(target) {
247354
+ const selection = readStoredModelSelection(target.resolvedSelection);
247355
+ if (!selection || selection.modelId !== target.modelId.trim()) {
247356
+ return void 0;
247357
+ }
247358
+ return selection.settings?.reasoningEffort;
247359
+ }
246959
247360
  function swarmTargetBackendSelection(target) {
246960
247361
  const selection = readStoredModelSelection(target.resolvedSelection);
246961
247362
  if (!selection || selection.modelId !== target.modelId.trim()) {
@@ -247208,6 +247609,9 @@ async function runJourneyFanOut(opts) {
247208
247609
  // request body to override it — and passed explicitly so it
247209
247610
  // STAYS identical if that ever stops being true.
247210
247611
  hostModelId: modelId,
247612
+ // The saved selection's effort: a harness that cannot apply it
247613
+ // refuses the target here, before a box is booted.
247614
+ ...swarmTargetReasoningEffort(target) !== void 0 ? { reasoningEffort: swarmTargetReasoningEffort(target) } : {},
247211
247615
  // TRI-STATE, read without throwing, and INVALID counts as ON —
247212
247616
  // the same call `mcp/chat-v2.ts` makes. `xaaPolicyFromMcpProfile`
247213
247617
  // (the web route's variant) THROWS a 409 on a malformed profile,
@@ -259423,14 +259827,22 @@ servers3.post("/projects/:projectId/servers", async (c) => {
259423
259827
  });
259424
259828
  servers3.get("/projects/:projectId/servers/:serverId", async (c) => {
259425
259829
  const token = await getConvexBearerForRequest(c);
259426
- return v1Resource(
259427
- c,
259428
- await findProjectServer(
259429
- token,
259430
- c.req.param("projectId"),
259431
- c.req.param("serverId")
259432
- )
259433
- );
259830
+ try {
259831
+ return v1Resource(
259832
+ c,
259833
+ await findProjectServer(
259834
+ token,
259835
+ c.req.param("projectId"),
259836
+ c.req.param("serverId")
259837
+ )
259838
+ );
259839
+ } catch (error) {
259840
+ throw translateStructuredConvexRefusal(error) ?? translateConvexReadError(error, {
259841
+ scope: "v1.servers",
259842
+ notFoundMessage: "Server not found",
259843
+ redactedIsRefusal: true
259844
+ });
259845
+ }
259434
259846
  });
259435
259847
  servers3.patch("/projects/:projectId/servers/:serverId", async (c) => {
259436
259848
  const projectId = c.req.param("projectId");
@@ -259573,7 +259985,7 @@ serverGroups.get("/projects/:projectId/server-groups", async (c) => {
259573
259985
  { projectId }
259574
259986
  );
259575
259987
  } catch (error) {
259576
- throw translateServerGroupError(error);
259988
+ throw redactedReadRefusalError(error, "Server group not found") ?? translateServerGroupError(error);
259577
259989
  }
259578
259990
  return v1PageJson(c, (rows ?? []).map(toServerGroupDto));
259579
259991
  });
@@ -264953,7 +265365,10 @@ async function listHostRows(convexAuthToken, projectId) {
264953
265365
  { projectId }
264954
265366
  ) ?? [];
264955
265367
  } catch (error) {
264956
- throw translateConvexWriteError3(error);
265368
+ throw redactedReadRefusalError(
265369
+ error,
265370
+ "Project or client not found, or you do not have access to it."
265371
+ ) ?? translateConvexWriteError3(error);
264957
265372
  }
264958
265373
  }
264959
265374
  async function readHostDetail(convexAuthToken, projectId, hostId) {
@@ -265635,7 +266050,10 @@ async function readEnvironment(convexAuthToken, projectId, environmentId) {
265635
266050
  { projectId, environmentId }
265636
266051
  );
265637
266052
  } catch (error) {
265638
- throw translateConvexError(error);
266053
+ throw redactedReadRefusalError(
266054
+ error,
266055
+ "Environment or project not found, or you do not have access to it."
266056
+ ) ?? translateConvexError(error);
265639
266057
  }
265640
266058
  if (!row2) {
265641
266059
  throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Environment not found");
@@ -265754,7 +266172,10 @@ environments2.get("/projects/:projectId/environments", async (c) => {
265754
266172
  { projectId, includeArchived }
265755
266173
  );
265756
266174
  } catch (error) {
265757
- throw translateConvexError(error);
266175
+ throw redactedReadRefusalError(
266176
+ error,
266177
+ "Environment or project not found, or you do not have access to it."
266178
+ ) ?? translateConvexError(error);
265758
266179
  }
265759
266180
  return v1PageJson(
265760
266181
  c,
@@ -266046,7 +266467,8 @@ function translatePluginReadError(error) {
266046
266467
  }
266047
266468
  return translateConvexReadError(error, {
266048
266469
  scope: "v1/plugins",
266049
- notFoundMessage: "Plugin or project not found, or you do not have access."
266470
+ notFoundMessage: "Plugin or project not found, or you do not have access.",
266471
+ redactedIsRefusal: true
266050
266472
  });
266051
266473
  }
266052
266474
  plugins2.get("/projects/:projectId/plugins", async (c) => {
@@ -266129,7 +266551,10 @@ function translateSkillReadError(error) {
266129
266551
  }
266130
266552
  return translateConvexReadError(error, {
266131
266553
  scope: "v1/skills",
266132
- notFoundMessage: "Skill or project not found, or you do not have access."
266554
+ notFoundMessage: "Skill or project not found, or you do not have access.",
266555
+ // Every read here scopes a caller-supplied id; production masks the plain
266556
+ // refusal to "Server Error", which answered 502 without this (MJ-021).
266557
+ redactedIsRefusal: true
266133
266558
  });
266134
266559
  }
266135
266560
  skills4.get("/projects/:projectId/skills", async (c) => {
@@ -266192,7 +266617,10 @@ import { Hono as Hono98 } from "hono";
266192
266617
  import { z as z70 } from "zod";
266193
266618
  var personas = new Hono98();
266194
266619
  function translateReadError(error) {
266195
- return translateConvexReadError(error, { scope: "v1.personas" });
266620
+ return translateConvexReadError(error, {
266621
+ scope: "v1.personas",
266622
+ redactedIsRefusal: true
266623
+ });
266196
266624
  }
266197
266625
  function toPersonaDto(row2, projectId) {
266198
266626
  return {
@@ -266385,7 +266813,10 @@ import { Hono as Hono99 } from "hono";
266385
266813
  import { z as z71 } from "zod";
266386
266814
  var swarms = new Hono99();
266387
266815
  function translateReadError2(error) {
266388
- return translateConvexReadError(error, { scope: "v1.swarms" });
266816
+ return translateConvexReadError(error, {
266817
+ scope: "v1.swarms",
266818
+ redactedIsRefusal: true
266819
+ });
266389
266820
  }
266390
266821
  function toSwarmDto(row2) {
266391
266822
  return {
@@ -266608,6 +267039,12 @@ var MAX_PAGE_SIZE = 200;
266608
267039
  function translateReadError3(error) {
266609
267040
  return translateConvexReadError(error, { scope: "v1.journeys" });
266610
267041
  }
267042
+ function translatePreflightReadError(error) {
267043
+ return translateConvexReadError(error, {
267044
+ scope: "v1.journeys",
267045
+ redactedIsRefusal: true
267046
+ });
267047
+ }
266611
267048
  function paginationOptsFrom(c) {
266612
267049
  const cursor = c.req.query("cursor");
266613
267050
  const rawLimit = Number(c.req.query("limit"));
@@ -266863,7 +267300,7 @@ async function requireGoalInProject(client3, projectId, goalId, surface) {
266863
267300
  }
266864
267301
  );
266865
267302
  } catch (error) {
266866
- throw translateReadError3(error);
267303
+ throw translatePreflightReadError(error);
266867
267304
  }
266868
267305
  if (!row2) {
266869
267306
  throw new WebRouteError(
@@ -266884,7 +267321,7 @@ async function requireRunInProject(client3, projectId, runId, surface) {
266884
267321
  }
266885
267322
  );
266886
267323
  } catch (error) {
266887
- throw translateReadError3(error);
267324
+ throw translatePreflightReadError(error);
266888
267325
  }
266889
267326
  if (!run3 || String(run3.projectId) !== projectId) {
266890
267327
  throw new WebRouteError(
@@ -266911,7 +267348,7 @@ both(
266911
267348
  }
266912
267349
  );
266913
267350
  } catch (error) {
266914
- throw translateReadError3(error);
267351
+ throw translatePreflightReadError(error);
266915
267352
  }
266916
267353
  return v1PageJson(
266917
267354
  c,
@@ -267255,7 +267692,10 @@ import { Hono as Hono101 } from "hono";
267255
267692
  import { z as z73 } from "zod";
267256
267693
  var secrets = new Hono101();
267257
267694
  function translateReadError4(error) {
267258
- return translateConvexReadError(error, { scope: "v1.secrets" });
267695
+ return translateConvexReadError(error, {
267696
+ scope: "v1.secrets",
267697
+ redactedIsRefusal: true
267698
+ });
267259
267699
  }
267260
267700
  function toSecretDto(row2) {
267261
267701
  return {
@@ -268034,6 +268474,12 @@ var swarmInsights = new Hono104();
268034
268474
  function translateReadError6(error) {
268035
268475
  return translateConvexReadError(error, { scope: "v1.swarm-insights" });
268036
268476
  }
268477
+ function translatePreflightReadError2(error) {
268478
+ return translateConvexReadError(error, {
268479
+ scope: "v1.swarm-insights",
268480
+ redactedIsRefusal: true
268481
+ });
268482
+ }
268037
268483
  function toScorecardDto(row2, runId) {
268038
268484
  return {
268039
268485
  runId,
@@ -268189,7 +268635,7 @@ async function requireRunInProject2(client3, projectId, runId) {
268189
268635
  { runId }
268190
268636
  );
268191
268637
  } catch (error) {
268192
- throw translateReadError6(error);
268638
+ throw translatePreflightReadError2(error);
268193
268639
  }
268194
268640
  if (!run3 || String(run3.projectId) !== projectId) {
268195
268641
  throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Journey run not found");
@@ -268202,7 +268648,7 @@ async function listFindingRows(client3, projectId) {
268202
268648
  { projectId }
268203
268649
  ) ?? [];
268204
268650
  } catch (error) {
268205
- throw translateReadError6(error);
268651
+ throw translatePreflightReadError2(error);
268206
268652
  }
268207
268653
  }
268208
268654
  async function requireFindingInProject(client3, projectId, findingId) {
@@ -268235,7 +268681,7 @@ both2(
268235
268681
  { projectId }
268236
268682
  );
268237
268683
  } catch (error) {
268238
- throw translateReadError6(error);
268684
+ throw translatePreflightReadError2(error);
268239
268685
  }
268240
268686
  return v1Resource(c, toOverviewDto(row2));
268241
268687
  }
@@ -268304,7 +268750,7 @@ bothInsights("get", "/insights", async (c, surface) => {
268304
268750
  { projectId, swarmRunGroupId: swarmRunId }
268305
268751
  );
268306
268752
  } catch (error) {
268307
- throw translateReadError6(error);
268753
+ throw translatePreflightReadError2(error);
268308
268754
  }
268309
268755
  if (!row2) {
268310
268756
  throw new WebRouteError(
@@ -268590,7 +269036,11 @@ async function requireEnvironmentInProject(client3, projectId, environmentId) {
268590
269036
  } catch (error) {
268591
269037
  const failure = classifyConvexReadError(error);
268592
269038
  if (failure.kind !== "membership") {
268593
- throw translateConvexReadError(error, { scope: "v1.scenarios" });
269039
+ throw translateConvexReadError(error, {
269040
+ scope: "v1.scenarios",
269041
+ notFoundMessage: "Environment not found",
269042
+ redactedIsRefusal: true
269043
+ });
268594
269044
  }
268595
269045
  row2 = null;
268596
269046
  }
@@ -268702,8 +269152,14 @@ var unpublishHandler = async (c) => {
268702
269152
  });
268703
269153
  };
268704
269154
  var STUDY_SUCCESSOR = "/api/v1/projects/{projectId}/environments/{environmentId}/study";
268705
- scenarios2.put("/projects/:projectId/environments/:environmentId/study", publishHandler);
268706
- scenarios2.delete("/projects/:projectId/environments/:environmentId/study", unpublishHandler);
269155
+ scenarios2.put(
269156
+ "/projects/:projectId/environments/:environmentId/study",
269157
+ publishHandler
269158
+ );
269159
+ scenarios2.delete(
269160
+ "/projects/:projectId/environments/:environmentId/study",
269161
+ unpublishHandler
269162
+ );
268707
269163
  scenarios2.put(
268708
269164
  "/projects/:projectId/environments/:environmentId/scenario",
268709
269165
  (c) => {
@@ -268765,6 +269221,37 @@ async function fetchJsonBlob(url, options) {
268765
269221
 
268766
269222
  // server/routes/v1/convex-v1-proxy.ts
268767
269223
  var PROXY_TIMEOUT_MS = 15e3;
269224
+ var CONVEX_INTERNAL_DETAIL = /\bArgumentValidationError\b|\bValidator:\s|\[Request ID:/;
269225
+ function sanitizeProxiedFailure(c, convexPath, status, body) {
269226
+ if (status < 400) return body;
269227
+ const serialized = JSON.stringify(body) ?? "";
269228
+ if (!CONVEX_INTERNAL_DETAIL.test(serialized)) return body;
269229
+ if (!HOSTED_MODE) return body;
269230
+ const { requestId } = responseRequestId(c);
269231
+ logger.warn("[v1.read-proxy] upstream error text withheld from response", {
269232
+ convexPath,
269233
+ status,
269234
+ requestId,
269235
+ detail: redactForLog(
269236
+ JSON.stringify(body, (key, value) => {
269237
+ if (typeof value !== "string") return value;
269238
+ if (/^(api[-_]?key|secret|token|password|passwd|authorization)$/i.test(
269239
+ key
269240
+ )) {
269241
+ return "[redacted]";
269242
+ }
269243
+ return redactForLog(value);
269244
+ })
269245
+ )
269246
+ });
269247
+ const upstreamCode = body?.code;
269248
+ const code = typeof upstreamCode === "string" && !CONVEX_INTERNAL_DETAIL.test(upstreamCode) ? upstreamCode : status >= 500 ? ErrorCode.INTERNAL_ERROR : ErrorCode.VALIDATION_ERROR;
269249
+ return {
269250
+ code,
269251
+ message: status >= 500 ? hostedInternalErrorMessage(requestId) : `One or more request parameters were invalid. If it keeps happening, contact support with reference ${requestId}.`,
269252
+ details: { requestId }
269253
+ };
269254
+ }
268768
269255
  function forwardQueryParams(c, target, names) {
268769
269256
  for (const name15 of names) {
268770
269257
  const value = c.req.query(name15);
@@ -268846,7 +269333,11 @@ async function fetchConvexV1Read(c, convexPath, configure, options = {}) {
268846
269333
  const value = response.headers.get(name15);
268847
269334
  if (value) headers[name15] = value;
268848
269335
  }
268849
- return { status: response.status, body, headers };
269336
+ return {
269337
+ status: response.status,
269338
+ body: sanitizeProxiedFailure(c, convexPath, response.status, body),
269339
+ headers
269340
+ };
268850
269341
  }
268851
269342
  async function proxyConvexV1Read(c, convexPath, configure, options) {
268852
269343
  const { status, body, headers } = await fetchConvexV1Read(
@@ -268882,7 +269373,7 @@ function both3(method, suffix, handler) {
268882
269373
  function translateReadError7(error) {
268883
269374
  return translateConvexReadError(error, { scope: "v1.user-testing" });
268884
269375
  }
268885
- function translatePreflightReadError(error, notFoundMessage) {
269376
+ function translatePreflightReadError3(error, notFoundMessage) {
268886
269377
  return translateConvexReadError(error, {
268887
269378
  scope: "v1.user-testing",
268888
269379
  notFoundMessage,
@@ -268946,7 +269437,7 @@ async function requireScenarioInProject(client3, projectId, scenarioId) {
268946
269437
  { scenarioId }
268947
269438
  );
268948
269439
  } catch (error) {
268949
- throw translatePreflightReadError(error, "Scenario not found");
269440
+ throw translatePreflightReadError3(error, "Scenario not found");
268950
269441
  }
268951
269442
  if (!row2 || String(row2.projectId ?? "") !== projectId) {
268952
269443
  throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Scenario not found");
@@ -269178,7 +269669,7 @@ both3("get", "/sessions/:sessionId", async (c, surface) => {
269178
269669
  { sessionId }
269179
269670
  );
269180
269671
  } catch (error) {
269181
- throw translatePreflightReadError(error, "Session not found");
269672
+ throw translatePreflightReadError3(error, "Session not found");
269182
269673
  }
269183
269674
  if (!session || String(session.scenarioId ?? "") !== scenarioId) {
269184
269675
  throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Session not found");
@@ -269592,7 +270083,7 @@ var RESOURCE_TYPES = /* @__PURE__ */ new Set(["scenario", "conformanceRun", "eva
269592
270083
  function translateReadError8(error) {
269593
270084
  return translateConvexReadError(error, { scope: "v1.shares" });
269594
270085
  }
269595
- function translatePreflightReadError2(error) {
270086
+ function translatePreflightReadError4(error) {
269596
270087
  return translateConvexReadError(error, {
269597
270088
  scope: "v1.shares",
269598
270089
  notFoundMessage: "Share not found",
@@ -269653,7 +270144,7 @@ async function requireShareInProject(client3, projectId, resourceType, resourceI
269653
270144
  { resourceType, resourceId }
269654
270145
  );
269655
270146
  } catch (error) {
269656
- throw translatePreflightReadError2(error);
270147
+ throw translatePreflightReadError4(error);
269657
270148
  }
269658
270149
  if (!row2 || String(row2.projectId ?? "") !== projectId) {
269659
270150
  throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Share not found");
@@ -269863,7 +270354,10 @@ async function readEnvironmentInProject(convexAuthToken, projectId, environmentI
269863
270354
  }
269864
270355
  );
269865
270356
  } catch (error) {
269866
- throw translateConvexWriteError4(error);
270357
+ throw redactedReadRefusalError(
270358
+ error,
270359
+ "Environment or project not found, or you do not have access to it."
270360
+ ) ?? translateConvexWriteError4(error);
269867
270361
  }
269868
270362
  if (!env || env.projectId !== projectId) {
269869
270363
  throw new WebRouteError(
@@ -269949,7 +270443,10 @@ images.get("/projects/:projectId/images", async (c) => {
269949
270443
  { projectId }
269950
270444
  );
269951
270445
  } catch (error) {
269952
- throw translateConvexWriteError4(error);
270446
+ throw redactedReadRefusalError(
270447
+ error,
270448
+ "Environment or project not found, or you do not have access to it."
270449
+ ) ?? translateConvexWriteError4(error);
269953
270450
  }
269954
270451
  return v1PageJson(c, (rows ?? []).map(toEnvironmentDto2));
269955
270452
  });
@@ -270591,6 +271088,7 @@ router2.post("/projects/:projectId/eval-runs/:runId/backtest", async (c) => {
270591
271088
  return v1Error(c, "INTERNAL_ERROR", "Backtest service is unavailable");
270592
271089
  const client3 = new ConvexHttpClient26(process.env.CONVEX_URL);
270593
271090
  client3.setAuth(token);
271091
+ let scopeVerified = false;
270594
271092
  try {
270595
271093
  const run3 = await client3.query(
270596
271094
  "testSuites:getTestSuiteRun",
@@ -270598,6 +271096,7 @@ router2.post("/projects/:projectId/eval-runs/:runId/backtest", async (c) => {
270598
271096
  );
270599
271097
  if (!run3 || run3.projectId !== c.req.param("projectId") || !run3.suiteId)
270600
271098
  return v1Error(c, "NOT_FOUND", "Eval run not found");
271099
+ scopeVerified = true;
270601
271100
  const report = await runAssertionBacktest({
270602
271101
  runId: c.req.param("runId"),
270603
271102
  suiteId: run3.suiteId,
@@ -270657,7 +271156,9 @@ router2.post("/projects/:projectId/eval-runs/:runId/backtest", async (c) => {
270657
271156
  );
270658
271157
  throw translateConvexReadError(error, {
270659
271158
  scope: "v1.eval-backtest",
270660
- notFoundMessage: "Eval run not found or backtest is not authorized"
271159
+ notFoundMessage: "Eval run not found or backtest is not authorized",
271160
+ // Only the initial run lookup can be a masked scope refusal.
271161
+ redactedIsRefusal: !scopeVerified
270661
271162
  });
270662
271163
  }
270663
271164
  });
@@ -270684,6 +271185,7 @@ router2.post(
270684
271185
  return v1Error(c, "INTERNAL_ERROR", "Backtest service is unavailable");
270685
271186
  const client3 = new ConvexHttpClient26(process.env.CONVEX_URL);
270686
271187
  client3.setAuth(await getConvexBearerForRequest(c));
271188
+ let scopeVerified = false;
270687
271189
  try {
270688
271190
  const run3 = await client3.query(
270689
271191
  "testSuites:getTestSuiteRun",
@@ -270691,6 +271193,7 @@ router2.post(
270691
271193
  );
270692
271194
  if (!run3 || run3.projectId !== c.req.param("projectId") || !run3.suiteId)
270693
271195
  return v1Error(c, "NOT_FOUND", "Eval run not found");
271196
+ scopeVerified = true;
270694
271197
  const report = await client3.action(
270695
271198
  "goalCompletionAction:requestJudgeBacktest",
270696
271199
  {
@@ -270713,7 +271216,9 @@ router2.post(
270713
271216
  );
270714
271217
  throw translateConvexReadError(error, {
270715
271218
  scope: "v1.eval-judge-backtest",
270716
- notFoundMessage: "Eval run not found or judge backtest is not authorized"
271219
+ notFoundMessage: "Eval run not found or judge backtest is not authorized",
271220
+ // Only the initial run lookup can be a masked scope refusal.
271221
+ redactedIsRefusal: !scopeVerified
270717
271222
  });
270718
271223
  }
270719
271224
  }
@@ -273201,6 +273706,7 @@ function buildAgentApiToolSet(opts) {
273201
273706
  const tools5 = {};
273202
273707
  for (const operation of AGENT_API_OPERATIONS) {
273203
273708
  if (opts.disabledOperations?.has(operation.name)) continue;
273709
+ if (operation.readOnly !== true && opts.hasHumanSurface !== true) continue;
273204
273710
  tools5[operation.name] = tool18({
273205
273711
  description: `${operation.description} (Scoped to the current project automatically.)`,
273206
273712
  inputSchema: relaxProjectRequirement(
@@ -273388,6 +273894,17 @@ agent.use("/agent-ops", requireVerifiedAuth());
273388
273894
  agent.get("/agent-ops", async (c) => {
273389
273895
  return v1Resource(c, { operations: listAgentOpCatalog() });
273390
273896
  });
273897
+ async function readAgentJobStatus(convex, jobId) {
273898
+ try {
273899
+ return await convex.query("agentTurnState:status", { jobId });
273900
+ } catch (error) {
273901
+ throw translateStructuredConvexRefusal(error) ?? translateConvexReadError(error, {
273902
+ scope: "v1.agent",
273903
+ notFoundMessage: "Agent job not found.",
273904
+ redactedIsRefusal: true
273905
+ });
273906
+ }
273907
+ }
273391
273908
  agent.get("/projects/:projectId/agent/jobs/:jobId", async (c) => {
273392
273909
  if (!process.env.CONVEX_URL)
273393
273910
  return v1Error(
@@ -273396,9 +273913,7 @@ agent.get("/projects/:projectId/agent/jobs/:jobId", async (c) => {
273396
273913
  "The agent endpoint requires a hosted MCPJam deployment."
273397
273914
  );
273398
273915
  const convex = createConvexClient(await getConvexBearerForRequest(c));
273399
- const result = await convex.query("agentTurnState:status", {
273400
- jobId: c.req.param("jobId")
273401
- });
273916
+ const result = await readAgentJobStatus(convex, c.req.param("jobId"));
273402
273917
  if (!result || result.projectId !== c.req.param("projectId"))
273403
273918
  return v1Error(c, "NOT_FOUND", "Agent job not found.");
273404
273919
  return v1Resource(c, result);
@@ -273411,9 +273926,7 @@ agent.post("/projects/:projectId/agent/jobs/:jobId/cancel", async (c) => {
273411
273926
  "The agent endpoint requires a hosted MCPJam deployment."
273412
273927
  );
273413
273928
  const convex = createConvexClient(await getConvexBearerForRequest(c));
273414
- const status = await convex.query("agentTurnState:status", {
273415
- jobId: c.req.param("jobId")
273416
- });
273929
+ const status = await readAgentJobStatus(convex, c.req.param("jobId"));
273417
273930
  if (!status || status.projectId !== c.req.param("projectId"))
273418
273931
  return v1Error(c, "NOT_FOUND", "Agent job not found.");
273419
273932
  await convex.mutation("agentTurnState:cancel", {
@@ -273563,7 +274076,10 @@ agent.post("/projects/:projectId/agent", async (c) => {
273563
274076
  created,
273564
274077
  ...body.idempotencyKey ? { turnIdempotencyKey: body.idempotencyKey } : {},
273565
274078
  clientWithHeaders: makeClient4,
273566
- disabledOperations
274079
+ disabledOperations,
274080
+ // The same presence test that decides whether the gated tools exist
274081
+ // at all: without it the direct tier's writes are omitted too.
274082
+ hasHumanSurface: proposalSurface !== void 0
273567
274083
  }),
273568
274084
  ...proposalSurface ? buildGatedProposalTools({
273569
274085
  projectId,
@@ -275424,6 +275940,8 @@ function resolveChatSessionEngine(args) {
275424
275940
  const hostConfig = args.hostTarget.runtimeConfig;
275425
275941
  const name15 = getHarnessAdapter(harness2).displayName;
275426
275942
  const requireToolApproval = hostConfig.requireToolApproval === true;
275943
+ const hostSelection = hostConfig.modelSelection;
275944
+ const hostEffort = hostSelection?.modelId === args.model.id ? selectionReasoningEffort(hostSelection) : void 0;
275427
275945
  const availability = checkHarnessRuntimeAvailable({
275428
275946
  harnessId: harness2,
275429
275947
  requireToolApproval,
@@ -275435,7 +275953,11 @@ function resolveChatSessionEngine(args) {
275435
275953
  xaaEnterprisePolicyOn: readXaaEnterprisePolicy(hostConfig.mcpProfile).kind !== "off",
275436
275954
  // An API chat turn is chat: an unverified harness × model pair runs, and
275437
275955
  // the verdict's reason comes back as `warning`.
275438
- purpose: "chat"
275956
+ purpose: "chat",
275957
+ // The host's saved effort, when its selection names the model this turn
275958
+ // runs. A harness that cannot apply it refuses the turn instead of running
275959
+ // without it.
275960
+ ...hostEffort !== void 0 ? { reasoningEffort: hostEffort } : {}
275439
275961
  });
275440
275962
  if (!availability.ok) {
275441
275963
  return {
@@ -276836,7 +277358,7 @@ var DEFAULT_MESSAGE_PAGE = 50;
276836
277358
  var MAX_MESSAGE_PAGE = 200;
276837
277359
  var DEFAULT_TRACE_TURNS = 1;
276838
277360
  var MAX_TRACE_TURNS = 20;
276839
- function translatePreflightReadError3(error) {
277361
+ function translatePreflightReadError5(error) {
276840
277362
  return translateConvexReadError(error, {
276841
277363
  scope: "v1.chat-sessions",
276842
277364
  notFoundMessage: "Chat session not found",
@@ -276856,7 +277378,7 @@ async function resolveScopedSession(client3, sessionId, projectId) {
276856
277378
  }
276857
277379
  );
276858
277380
  } catch (error) {
276859
- throw translatePreflightReadError3(error);
277381
+ throw translatePreflightReadError5(error);
276860
277382
  }
276861
277383
  if (!session) {
276862
277384
  throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Chat session not found");
@@ -277553,66 +278075,69 @@ var connectCheckRepoSchema = z93.object({
277553
278075
  */
277554
278076
  outagePolicy: z93.enum(["fail_open", "fail_closed"])
277555
278077
  }).strict();
277556
- evalChecks.get(
277557
- "/organizations/:organizationId/eval-check-repos",
277558
- async (c) => {
277559
- const organizationId = c.req.param("organizationId");
277560
- const client3 = convexClient4(await getConvexBearerForRequest(c));
277561
- let availability = null;
277562
- try {
277563
- availability = await client3.query(
277564
- "github/checkRepoConfigs:getGithubChecksSettingsAvailability",
277565
- { organizationId }
277566
- );
277567
- } catch (error) {
277568
- throw translateConvexReadError(error, { scope: "v1.evalChecks" });
277569
- }
277570
- const enabled = availability?.state === "enabled";
277571
- if (!enabled) {
277572
- return v1Resource(c, {
277573
- organizationId,
277574
- available: false,
277575
- items: [],
277576
- connectable: null
277577
- });
277578
- }
277579
- let rows;
277580
- try {
277581
- rows = await client3.query(
277582
- "github/checkRepoConfigs:listForOrganization",
277583
- { organizationId }
277584
- ) ?? [];
277585
- } catch (error) {
277586
- throw translateConvexReadError(error, { scope: "v1.evalChecks" });
277587
- }
277588
- let connectable = null;
277589
- try {
277590
- const repos = await client3.action(
277591
- "github/checkRepoConfigsNode:listInstallationRepos",
277592
- { organizationId }
277593
- ) ?? [];
277594
- connectable = repos.map((repo) => ({
277595
- repo: String(repo.fullName ?? repo.repoFullName ?? "")
277596
- }));
277597
- } catch (error) {
277598
- reportRouteFailure(
277599
- "[v1.evalChecks] installation repositories unavailable",
277600
- error,
277601
- {
277602
- source: "v1.evalChecks.listInstallationRepos",
277603
- hop: "mcpjam_internal"
277604
- }
277605
- );
277606
- connectable = null;
277607
- }
278078
+ evalChecks.get("/organizations/:organizationId/eval-check-repos", async (c) => {
278079
+ const organizationId = c.req.param("organizationId");
278080
+ const client3 = convexClient4(await getConvexBearerForRequest(c));
278081
+ let availability = null;
278082
+ try {
278083
+ availability = await client3.query(
278084
+ "github/checkRepoConfigs:getGithubChecksSettingsAvailability",
278085
+ { organizationId }
278086
+ );
278087
+ } catch (error) {
278088
+ throw translateConvexReadError(error, {
278089
+ scope: "v1.evalChecks",
278090
+ redactedIsRefusal: true
278091
+ });
278092
+ }
278093
+ const enabled = availability?.state === "enabled";
278094
+ if (!enabled) {
277608
278095
  return v1Resource(c, {
277609
278096
  organizationId,
277610
- available: true,
277611
- items: rows.map(toCheckRepoDto),
277612
- connectable
278097
+ available: false,
278098
+ items: [],
278099
+ connectable: null
277613
278100
  });
277614
278101
  }
277615
- );
278102
+ let rows;
278103
+ try {
278104
+ rows = await client3.query(
278105
+ "github/checkRepoConfigs:listForOrganization",
278106
+ { organizationId }
278107
+ ) ?? [];
278108
+ } catch (error) {
278109
+ throw translateConvexReadError(error, {
278110
+ scope: "v1.evalChecks",
278111
+ redactedIsRefusal: true
278112
+ });
278113
+ }
278114
+ let connectable = null;
278115
+ try {
278116
+ const repos = await client3.action(
278117
+ "github/checkRepoConfigsNode:listInstallationRepos",
278118
+ { organizationId }
278119
+ ) ?? [];
278120
+ connectable = repos.map((repo) => ({
278121
+ repo: String(repo.fullName ?? repo.repoFullName ?? "")
278122
+ }));
278123
+ } catch (error) {
278124
+ reportRouteFailure(
278125
+ "[v1.evalChecks] installation repositories unavailable",
278126
+ error,
278127
+ {
278128
+ source: "v1.evalChecks.listInstallationRepos",
278129
+ hop: "mcpjam_internal"
278130
+ }
278131
+ );
278132
+ connectable = null;
278133
+ }
278134
+ return v1Resource(c, {
278135
+ organizationId,
278136
+ available: true,
278137
+ items: rows.map(toCheckRepoDto),
278138
+ connectable
278139
+ });
278140
+ });
277616
278141
  evalChecks.post(
277617
278142
  "/organizations/:organizationId/eval-check-repos",
277618
278143
  async (c) => {
@@ -277783,7 +278308,10 @@ spendBudget.get("/organizations/:organizationId/spend-budget", async (c) => {
277783
278308
  { organizationId }
277784
278309
  );
277785
278310
  } catch (error) {
277786
- throw translateConvexReadError(error, { scope: "v1.spendBudget" });
278311
+ throw translateConvexReadError(error, {
278312
+ scope: "v1.spendBudget",
278313
+ redactedIsRefusal: true
278314
+ });
277787
278315
  }
277788
278316
  return v1Resource(c, toBudgetDto(view));
277789
278317
  });
@@ -278138,7 +278666,11 @@ capabilities.get("/projects/:projectId/capabilities", async (c) => {
278138
278666
  { projectId }
278139
278667
  );
278140
278668
  } catch (error) {
278141
- throw translateConvexReadError(error, { scope: "v1.capabilities" });
278669
+ throw translateConvexReadError(error, {
278670
+ scope: "v1.capabilities",
278671
+ notFoundMessage: "Project not found",
278672
+ redactedIsRefusal: true
278673
+ });
278142
278674
  }
278143
278675
  if (!row2) {
278144
278676
  throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Project not found");
@@ -279479,10 +280011,14 @@ readiness.get("/projects/:projectId/readiness-runs/:runId", async (c) => {
279479
280011
  runId
279480
280012
  });
279481
280013
  } catch (error) {
279482
- throw translateConvexWriteError(error, { resource: "Readiness run" });
280014
+ throw redactedReadRefusalError(error, "Readiness run not found") ?? translateConvexWriteError(error, { resource: "Readiness run" });
279483
280015
  }
279484
280016
  if (!run3) {
279485
- throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Readiness run not found");
280017
+ throw new WebRouteError(
280018
+ 404,
280019
+ ErrorCode.NOT_FOUND,
280020
+ "Readiness run not found"
280021
+ );
279486
280022
  }
279487
280023
  return v1Resource(c, toRunDto2(run3, projectId));
279488
280024
  });
@@ -279516,7 +280052,7 @@ readiness.get("/projects/:projectId/readiness-runs", async (c) => {
279516
280052
  ...limit !== void 0 ? { limit } : {}
279517
280053
  });
279518
280054
  } catch (error) {
279519
- throw translateConvexWriteError(error, { resource: "Readiness runs" });
280055
+ throw redactedReadRefusalError(error, "Readiness runs not found") ?? translateConvexWriteError(error, { resource: "Readiness runs" });
279520
280056
  }
279521
280057
  return v1PageJson(
279522
280058
  c,
@@ -279530,10 +280066,9 @@ readiness.post(
279530
280066
  const runId = c.req.param("runId");
279531
280067
  const convex = createConvexClient9(await getConvexBearerForRequest(c));
279532
280068
  try {
279533
- await convex.mutation(
279534
- "claudeReadinessRuns:cancelReadinessRun",
279535
- { runId }
279536
- );
280069
+ await convex.mutation("claudeReadinessRuns:cancelReadinessRun", {
280070
+ runId
280071
+ });
279537
280072
  } catch (error) {
279538
280073
  throw translateConvexWriteError(error, { resource: "Readiness run" });
279539
280074
  }
@@ -279552,7 +280087,7 @@ readiness.get(
279552
280087
  { runId }
279553
280088
  );
279554
280089
  } catch (error) {
279555
- throw translateConvexWriteError(error, { resource: "Readiness report" });
280090
+ throw redactedReadRefusalError(error, "Readiness report not found") ?? translateConvexWriteError(error, { resource: "Readiness report" });
279556
280091
  }
279557
280092
  if (!blobId) {
279558
280093
  throw new WebRouteError(
@@ -280387,7 +280922,7 @@ async function loadRun(convex, runId, projectId) {
280387
280922
  try {
280388
280923
  run3 = await convex.query("conformanceRuns:getRun", { runId });
280389
280924
  } catch (error) {
280390
- throw translateConvexWriteError(error, { resource: "Conformance run" });
280925
+ throw redactedReadRefusalError(error, "Conformance run not found") ?? translateConvexWriteError(error, { resource: "Conformance run" });
280391
280926
  }
280392
280927
  if (!run3) {
280393
280928
  throw new WebRouteError(
@@ -280470,7 +281005,7 @@ conformanceRuns.get("/projects/:projectId/conformance-runs", async (c) => {
280470
281005
  paginationOpts: paginationOptsFrom2(c)
280471
281006
  });
280472
281007
  } catch (error) {
280473
- throw translateConvexWriteError(error, { resource: "Conformance runs" });
281008
+ throw redactedReadRefusalError(error, "Conformance runs not found") ?? translateConvexWriteError(error, { resource: "Conformance runs" });
280474
281009
  }
280475
281010
  return v1PageJson(
280476
281011
  c,
@@ -281997,7 +282532,7 @@ function percentile(sorted2, p) {
281997
282532
  return Math.round(sorted2[Math.max(0, idx)]);
281998
282533
  }
281999
282534
  function flushRelayStats() {
282000
- if (stats2.requests === 0) return;
282535
+ if (stats2.requests === 0 && stats2.rateLimitRejects === 0) return;
282001
282536
  const sorted2 = [...stats2.latenciesMs].sort((a, b) => a - b);
282002
282537
  relayLogger.event("relay.stats", {
282003
282538
  requests: stats2.requests,
@@ -282033,38 +282568,38 @@ function flushRelayStats() {
282033
282568
  }
282034
282569
  setInterval(flushRelayStats, STATS_FLUSH_INTERVAL_MS).unref();
282035
282570
  var RATE_LIMIT_PER_MIN = 600;
282571
+ var RELAY_INGEST_LIMIT_PER_MIN = 60;
282036
282572
  var RATE_WINDOW_MS2 = 6e4;
282037
282573
  var UNATTESTED_CLIENT_KEY3 = "unattested";
282038
- var ipWindows7 = /* @__PURE__ */ new Map();
282039
- setInterval(
282040
- () => {
282041
- const now = Date.now();
282042
- for (const [ip, entry3] of ipWindows7) {
282043
- if (now - entry3.windowStart > RATE_WINDOW_MS2 * 2) {
282044
- ipWindows7.delete(ip);
282045
- }
282046
- }
282047
- },
282048
- 5 * 6e4
282049
- ).unref();
282574
+ var relayWindows = createFixedWindowMap(RATE_LIMIT_PER_MIN, RATE_WINDOW_MS2);
282575
+ var ingestWindows = createFixedWindowMap(
282576
+ RELAY_INGEST_LIMIT_PER_MIN,
282577
+ RATE_WINDOW_MS2
282578
+ );
282579
+ var unattestedIngestWindows = createFixedWindowMap(
282580
+ 4 * RELAY_INGEST_LIMIT_PER_MIN,
282581
+ RATE_WINDOW_MS2
282582
+ );
282583
+ function isIngestSubpath(subpath) {
282584
+ return /^\/(?:e|i\/v0\/e|s|i\/v1\/(?:logs|metrics))\/?$/.test(subpath);
282585
+ }
282586
+ function relayClientIp(c) {
282587
+ return edgeAttestationConfigured() ? getAttestedClientIp(c) : null;
282588
+ }
282050
282589
  function relayClientKey(c) {
282051
- return getAttestedClientIp(c) ?? UNATTESTED_CLIENT_KEY3;
282590
+ return relayClientIp(c) ?? UNATTESTED_CLIENT_KEY3;
282052
282591
  }
282053
- function relayRateLimit(c) {
282592
+ function relayRateLimit(c, subpath) {
282054
282593
  if (!HOSTED_MODE) return null;
282055
- const ip = relayClientKey(c);
282056
- const now = Date.now();
282057
- const entry3 = ipWindows7.get(ip);
282058
- if (entry3 && now - entry3.windowStart < RATE_WINDOW_MS2) {
282059
- if (entry3.count >= RATE_LIMIT_PER_MIN) {
282060
- stats2.rateLimitRejects++;
282061
- return c.json({ error: "rate_limited" }, 429);
282062
- }
282063
- entry3.count++;
282064
- } else {
282065
- ipWindows7.set(ip, { count: 1, windowStart: now });
282594
+ const attestedIp = relayClientIp(c);
282595
+ let refusedMs = relayWindows.charge(attestedIp ?? UNATTESTED_CLIENT_KEY3);
282596
+ if (refusedMs === null && isIngestSubpath(subpath)) {
282597
+ refusedMs = attestedIp ? ingestWindows.charge(attestedIp) : unattestedIngestWindows.charge(UNATTESTED_CLIENT_KEY3);
282066
282598
  }
282067
- return null;
282599
+ if (refusedMs === null) return null;
282600
+ stats2.rateLimitRejects++;
282601
+ c.header("Retry-After", String(Math.max(1, Math.ceil(refusedMs / 1e3))));
282602
+ return c.json({ error: "rate_limited" }, 429);
282068
282603
  }
282069
282604
  function makeBodyLimit(maxSize) {
282070
282605
  return bodyLimit3({
@@ -282664,7 +283199,7 @@ async function checkProjectTokens(subpath, url, method, body) {
282664
283199
  }
282665
283200
  var relayRoutes = new Hono137();
282666
283201
  relayRoutes.post("/launch-engagement", makeBodyLimit(2048), async (c) => {
282667
- const limited = relayRateLimit(c);
283202
+ const limited = relayRateLimit(c, "/launch-engagement");
282668
283203
  if (limited) return limited;
282669
283204
  const parsed = launchEngagementSchema.safeParse(
282670
283205
  await c.req.json().catch(() => null)
@@ -282674,14 +283209,14 @@ relayRoutes.post("/launch-engagement", makeBodyLimit(2048), async (c) => {
282674
283209
  return c.body(null, 204);
282675
283210
  });
282676
283211
  relayRoutes.all("*", async (c) => {
282677
- const limited = relayRateLimit(c);
283212
+ const url = new URL(c.req.url);
283213
+ const subpath = stripRelayPrefix(url.pathname);
283214
+ const limited = relayRateLimit(c, subpath);
282678
283215
  if (limited) {
282679
283216
  return limited;
282680
283217
  }
282681
283218
  stats2.requests++;
282682
283219
  const startedAt = Date.now();
282683
- const url = new URL(c.req.url);
282684
- const subpath = stripRelayPrefix(url.pathname);
282685
283220
  if (!supportsRelayRequest(subpath, c.req.method)) {
282686
283221
  recordResponseStatus(404);
282687
283222
  return c.json({ error: "not_found" }, 404);
@@ -282799,25 +283334,25 @@ var MAX_KEY_SEGMENT = 2048;
282799
283334
  var RATE_LIMIT = 600;
282800
283335
  var RATE_WINDOW_MS3 = 6e4;
282801
283336
  var MAX_TRACKED_IPS = 1e4;
282802
- var ipWindows8 = /* @__PURE__ */ new Map();
283337
+ var ipWindows7 = /* @__PURE__ */ new Map();
282803
283338
  var rateCleanup = setInterval(() => {
282804
283339
  const now = Date.now();
282805
- for (const [ip, entry3] of ipWindows8) {
282806
- if (now - entry3.windowStart > RATE_WINDOW_MS3 * 2) ipWindows8.delete(ip);
283340
+ for (const [ip, entry3] of ipWindows7) {
283341
+ if (now - entry3.windowStart > RATE_WINDOW_MS3 * 2) ipWindows7.delete(ip);
282807
283342
  }
282808
283343
  }, 5 * 6e4);
282809
283344
  rateCleanup.unref?.();
282810
283345
  function isRateLimited(c) {
282811
283346
  const ip = getClientIp(c) ?? "unknown";
282812
283347
  const now = Date.now();
282813
- const entry3 = ipWindows8.get(ip);
283348
+ const entry3 = ipWindows7.get(ip);
282814
283349
  if (entry3 && now - entry3.windowStart < RATE_WINDOW_MS3) {
282815
283350
  if (entry3.count >= RATE_LIMIT) return true;
282816
283351
  entry3.count++;
282817
283352
  return false;
282818
283353
  }
282819
- if (!entry3 && ipWindows8.size >= MAX_TRACKED_IPS) return true;
282820
- ipWindows8.set(ip, { count: 1, windowStart: now });
283354
+ if (!entry3 && ipWindows7.size >= MAX_TRACKED_IPS) return true;
283355
+ ipWindows7.set(ip, { count: 1, windowStart: now });
282821
283356
  return false;
282822
283357
  }
282823
283358
  function confidentialCimdPublicOrigin(c) {
@@ -283254,7 +283789,10 @@ async function postServiceRoute2(path8, body) {
283254
283789
  );
283255
283790
  }
283256
283791
  const controller = new AbortController();
283257
- const timeout = setTimeout(() => controller.abort(), SERVICE_ROUTE_TIMEOUT_MS2);
283792
+ const timeout = setTimeout(
283793
+ () => controller.abort(),
283794
+ SERVICE_ROUTE_TIMEOUT_MS2
283795
+ );
283258
283796
  let response;
283259
283797
  try {
283260
283798
  response = await fetch(`${env.convexUrl}${path8}`, {
@@ -283342,7 +283880,12 @@ async function executeClaimedRun(claimed) {
283342
283880
  serverNames: environmentServerNames(resolved),
283343
283881
  resolvedEnvironment: resolved
283344
283882
  };
283345
- })() : await fetchSuiteRunServerSelection(bearer, claimed.suiteId, void 0);
283883
+ })() : await fetchSuiteRunServerSelection(
283884
+ bearer,
283885
+ claimed.suiteId,
283886
+ void 0,
283887
+ "authorized"
283888
+ );
283346
283889
  const authorized = await createAuthorizedManager(
283347
283890
  {},
283348
283891
  bearer,