@mcpjam/inspector 3.12.5 → 3.12.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{OAuthDesktopReturnNotice-LlC451lX.js → OAuthDesktopReturnNotice-DUuacpVO.js} +2 -2
- package/dist/client/assets/{app-bootstrap-2jatN7gw.js → app-bootstrap-DiOYsEwh.js} +314 -314
- package/dist/client/assets/{button-B2OH2ei2.js → button-F4pHUjYC.js} +2 -2
- package/dist/client/assets/{chunk-YOKDWASO-uJ3KOQV7.js → chunk-YOKDWASO-B2XCf4h4.js} +5 -5
- package/dist/client/assets/{dead-clicks-autocapture-D055GjVp.js → dead-clicks-autocapture-BAMovRYs.js} +2 -2
- package/dist/client/assets/{error-reporting-DGP36KLx.js → error-reporting-BrfSwhO1.js} +21 -21
- package/dist/client/assets/{error-reporting-FWZKbZxG.js → error-reporting-CWlEVH2b.js} +1 -1
- package/dist/client/assets/{exception-autocapture-103gdJjL.js → exception-autocapture-D5Eikj0K.js} +2 -2
- package/dist/client/assets/{failed-request-tracker-Cp9_VFMm.js → failed-request-tracker-CYWaDq0H.js} +2 -2
- package/dist/client/assets/{highlighted-body-KPVGNVTW-Dx70h1nm.js → highlighted-body-KPVGNVTW-BjkaxPPc.js} +2 -2
- package/dist/client/assets/{index-rskHnM3O.js → index-B-8CVYYi.js} +3 -3
- package/dist/client/assets/{jszip.min-CwJyI5tb.js → jszip.min-BtiG5GuL.js} +2 -2
- package/dist/client/assets/{mermaid-HWGCJPDP-Ck3prJKl.js → mermaid-HWGCJPDP-CYPKMbVd.js} +1 -1
- package/dist/client/assets/{posthog-recorder-tKuMFijV.js → posthog-recorder-D-Nq98cg.js} +2 -2
- package/dist/client/assets/{preload-helper-DrcoTQ49.js → preload-helper-CC679xXH.js} +2 -2
- package/dist/client/assets/{rolldown-runtime-7FnpGOz6.js → rolldown-runtime-1PqeXL0B.js} +1 -1
- package/dist/client/assets/{surveys-BsZYxM6N.js → surveys-olC_pHGU.js} +2 -2
- package/dist/client/assets/{trace-timeline-BOZvHcOG.js → trace-timeline-D2FsrVpF.js} +1 -1
- package/dist/client/assets/{trace-timeline-Bf9Oai70.js → trace-timeline-fl51h9sN.js} +27 -27
- package/dist/client/assets/{web-vitals-DdzaVN3H.js → web-vitals-CIP57d68.js} +2 -2
- package/dist/client/index.html +6 -6
- package/dist/server/{chunk-QA6VJT6A.js → chunk-76PAQUEP.js} +2 -2
- package/dist/server/{chunk-3EDQFXTF.js → chunk-FQTRKEDA.js} +2 -2
- package/dist/server/harness-install-cli.js +1 -1
- package/dist/server/index.js +927 -368
- package/dist/server/{local-turn-XXOSZHMT.js → local-turn-3DH4OF7C.js} +3 -3
- package/package.json +2 -2
package/dist/server/index.js
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
stopLocalHarnessProject,
|
|
29
29
|
stopLocalHarnessWorkspace,
|
|
30
30
|
validateWorkspaceCandidate
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-FQTRKEDA.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-
|
|
60
|
+
} from "./chunk-76PAQUEP.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.
|
|
28837
|
+
var SDK_VERSION = "8.20.1";
|
|
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.
|
|
28849
|
+
return "8.20.1";
|
|
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" &&
|
|
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
|
|
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
|
-
|
|
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.
|
|
87732
|
+
return "8.20.1";
|
|
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
|
|
91328
|
-
|
|
91329
|
-
|
|
91330
|
-
headers.
|
|
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 (
|
|
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
|
-
|
|
91502
|
+
setResponsePolicies(res.headers, isDocument, reportOnlyPolicy);
|
|
91349
91503
|
} catch {
|
|
91350
91504
|
const copy = new Response(res.body, res);
|
|
91351
|
-
|
|
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-
|
|
92550
|
+
const { localHarnessSupervisor } = await import("./local-turn-3DH4OF7C.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
|
|
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({
|
|
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
|
-
...
|
|
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 {
|
|
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
|
-
|
|
156250
|
+
turnEndedByLength ? "length" : "stop"
|
|
156011
156251
|
)
|
|
156012
156252
|
);
|
|
156013
156253
|
finishEmitted = true;
|
|
156014
156254
|
}
|
|
156015
156255
|
driver.usage = traceTurn.turnUsage;
|
|
156016
|
-
driver.finishReason =
|
|
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.
|
|
161597
|
+
return "8.20.1";
|
|
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
|
-
{
|
|
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"
|
|
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
|
|
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 =
|
|
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
|
-
|
|
208410
|
-
|
|
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 === "
|
|
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(
|
|
219859
|
-
|
|
219860
|
-
|
|
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(
|
|
220029
|
-
|
|
220030
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
222331
|
-
|
|
222332
|
-
|
|
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(
|
|
222390
|
-
|
|
222391
|
-
|
|
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(
|
|
222462
|
-
|
|
222463
|
-
|
|
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(
|
|
222503
|
-
|
|
222504
|
-
|
|
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(
|
|
222550
|
-
|
|
222551
|
-
|
|
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(
|
|
222642
|
-
|
|
222643
|
-
|
|
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(
|
|
222671
|
-
|
|
222672
|
-
|
|
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(
|
|
222707
|
-
|
|
222708
|
-
|
|
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
|
-
|
|
222756
|
-
|
|
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
|
-
|
|
222806
|
-
|
|
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
|
-
|
|
222846
|
-
|
|
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(
|
|
222892
|
-
|
|
222893
|
-
|
|
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
|
-
|
|
222958
|
-
|
|
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
|
-
|
|
223017
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
224013
|
-
|
|
224014
|
-
|
|
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(
|
|
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(
|
|
224169
|
-
|
|
224170
|
-
|
|
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(
|
|
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(
|
|
224457
|
-
|
|
224458
|
-
|
|
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(
|
|
224494
|
-
|
|
224495
|
-
|
|
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(
|
|
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
|
-
|
|
224553
|
-
|
|
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(
|
|
224574
|
-
|
|
224575
|
-
|
|
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(
|
|
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(
|
|
224609
|
-
|
|
224610
|
-
|
|
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(
|
|
224676
|
-
|
|
224677
|
-
|
|
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(
|
|
224868
|
-
|
|
224869
|
-
|
|
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(
|
|
224956
|
-
|
|
224957
|
-
|
|
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
|
-
|
|
225037
|
-
|
|
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
|
-
|
|
225055
|
-
|
|
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)
|
|
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,
|
|
@@ -225368,6 +225757,19 @@ async function handleEvalAuthoring(c, local) {
|
|
|
225368
225757
|
requestedEnvironmentId: input.environmentId,
|
|
225369
225758
|
hasServerOverride: false,
|
|
225370
225759
|
serverField: "servers"
|
|
225760
|
+
}).catch((error) => {
|
|
225761
|
+
if (!local && input.source === "markdown" && error instanceof WebRouteError && error.details?.reason === "ENVIRONMENT_REQUIRED") {
|
|
225762
|
+
getRequestLogger(c, "routes.shared.eval-authoring").event(
|
|
225763
|
+
"eval.import.environment_selection.failed",
|
|
225764
|
+
{
|
|
225765
|
+
projectId: input.projectId,
|
|
225766
|
+
suiteId: input.suiteId,
|
|
225767
|
+
reason: "ENVIRONMENT_REQUIRED"
|
|
225768
|
+
},
|
|
225769
|
+
{ sentry: true }
|
|
225770
|
+
);
|
|
225771
|
+
}
|
|
225772
|
+
throw error;
|
|
225371
225773
|
});
|
|
225372
225774
|
const environment = environmentId ? await resolveEnvironmentForLaunch(convex, {
|
|
225373
225775
|
serverSource: EVAL_LAUNCH_SERVER_SOURCE,
|
|
@@ -225379,7 +225781,12 @@ async function handleEvalAuthoring(c, local) {
|
|
|
225379
225781
|
const selection = environment ? {
|
|
225380
225782
|
serverIds: environmentServerIds(environment),
|
|
225381
225783
|
serverNames: environmentServerNames(environment)
|
|
225382
|
-
} : await fetchSuiteRunServerSelection(
|
|
225784
|
+
} : await fetchSuiteRunServerSelection(
|
|
225785
|
+
token,
|
|
225786
|
+
input.suiteId,
|
|
225787
|
+
void 0,
|
|
225788
|
+
"authorized"
|
|
225789
|
+
);
|
|
225383
225790
|
const { manager } = await createAuthorizedManager(
|
|
225384
225791
|
callerContextFromHono(c),
|
|
225385
225792
|
token,
|
|
@@ -236910,6 +237317,7 @@ document.addEventListener('securitypolicyviolation', function(e) {
|
|
|
236910
237317
|
sandboxAttrs,
|
|
236911
237318
|
cspDirectives,
|
|
236912
237319
|
cspSubtypePolicy,
|
|
237320
|
+
clientContext,
|
|
236913
237321
|
browserStorage,
|
|
236914
237322
|
permissive,
|
|
236915
237323
|
colorScheme,
|
|
@@ -237052,6 +237460,8 @@ document.addEventListener('securitypolicyviolation', function(e) {
|
|
|
237052
237460
|
{
|
|
237053
237461
|
csp,
|
|
237054
237462
|
cspDirectives,
|
|
237463
|
+
cspSubtypePolicy,
|
|
237464
|
+
clientContext,
|
|
237055
237465
|
permissive: Boolean(permissive),
|
|
237056
237466
|
},
|
|
237057
237467
|
);
|
|
@@ -244261,7 +244671,7 @@ function spendRefusalOf(error) {
|
|
|
244261
244671
|
return void 0;
|
|
244262
244672
|
if (!(error instanceof Error)) return void 0;
|
|
244263
244673
|
const info = humanizeSwarmAttemptError(error.message);
|
|
244264
|
-
return info.refusalReason ? info : void 0;
|
|
244674
|
+
return info.refusalReason || isTransientSpendRefusal(info.code) ? info : void 0;
|
|
244265
244675
|
}
|
|
244266
244676
|
var AdmissionWaitBudget = class {
|
|
244267
244677
|
constructor(totalMs = 5 * 6e4, maxAttemptsPerCall = 8) {
|
|
@@ -244458,7 +244868,7 @@ async function resolveTurnRuntime(args) {
|
|
|
244458
244868
|
assertOrgModelAllowed(orgRuntime.provider, modelId);
|
|
244459
244869
|
const llmModel = buildOrgModelFromResolvedConfig(orgRuntime.provider, modelId);
|
|
244460
244870
|
const effort = args.settings?.reasoningEffort;
|
|
244461
|
-
const providerOptions = effort ?
|
|
244871
|
+
const providerOptions = effort ? reasoningEffortProviderOptions2({
|
|
244462
244872
|
providerKey: orgRuntime.provider.providerKey,
|
|
244463
244873
|
modelId: args.modelSelection?.modelId ?? modelId,
|
|
244464
244874
|
effort
|
|
@@ -246956,6 +247366,13 @@ function swarmTargetModelDefinition(target) {
|
|
|
246956
247366
|
}
|
|
246957
247367
|
return definition;
|
|
246958
247368
|
}
|
|
247369
|
+
function swarmTargetReasoningEffort(target) {
|
|
247370
|
+
const selection = readStoredModelSelection(target.resolvedSelection);
|
|
247371
|
+
if (!selection || selection.modelId !== target.modelId.trim()) {
|
|
247372
|
+
return void 0;
|
|
247373
|
+
}
|
|
247374
|
+
return selection.settings?.reasoningEffort;
|
|
247375
|
+
}
|
|
246959
247376
|
function swarmTargetBackendSelection(target) {
|
|
246960
247377
|
const selection = readStoredModelSelection(target.resolvedSelection);
|
|
246961
247378
|
if (!selection || selection.modelId !== target.modelId.trim()) {
|
|
@@ -247208,6 +247625,9 @@ async function runJourneyFanOut(opts) {
|
|
|
247208
247625
|
// request body to override it — and passed explicitly so it
|
|
247209
247626
|
// STAYS identical if that ever stops being true.
|
|
247210
247627
|
hostModelId: modelId,
|
|
247628
|
+
// The saved selection's effort: a harness that cannot apply it
|
|
247629
|
+
// refuses the target here, before a box is booted.
|
|
247630
|
+
...swarmTargetReasoningEffort(target) !== void 0 ? { reasoningEffort: swarmTargetReasoningEffort(target) } : {},
|
|
247211
247631
|
// TRI-STATE, read without throwing, and INVALID counts as ON —
|
|
247212
247632
|
// the same call `mcp/chat-v2.ts` makes. `xaaPolicyFromMcpProfile`
|
|
247213
247633
|
// (the web route's variant) THROWS a 409 on a malformed profile,
|
|
@@ -259423,14 +259843,22 @@ servers3.post("/projects/:projectId/servers", async (c) => {
|
|
|
259423
259843
|
});
|
|
259424
259844
|
servers3.get("/projects/:projectId/servers/:serverId", async (c) => {
|
|
259425
259845
|
const token = await getConvexBearerForRequest(c);
|
|
259426
|
-
|
|
259427
|
-
|
|
259428
|
-
|
|
259429
|
-
|
|
259430
|
-
|
|
259431
|
-
|
|
259432
|
-
|
|
259433
|
-
|
|
259846
|
+
try {
|
|
259847
|
+
return v1Resource(
|
|
259848
|
+
c,
|
|
259849
|
+
await findProjectServer(
|
|
259850
|
+
token,
|
|
259851
|
+
c.req.param("projectId"),
|
|
259852
|
+
c.req.param("serverId")
|
|
259853
|
+
)
|
|
259854
|
+
);
|
|
259855
|
+
} catch (error) {
|
|
259856
|
+
throw translateStructuredConvexRefusal(error) ?? translateConvexReadError(error, {
|
|
259857
|
+
scope: "v1.servers",
|
|
259858
|
+
notFoundMessage: "Server not found",
|
|
259859
|
+
redactedIsRefusal: true
|
|
259860
|
+
});
|
|
259861
|
+
}
|
|
259434
259862
|
});
|
|
259435
259863
|
servers3.patch("/projects/:projectId/servers/:serverId", async (c) => {
|
|
259436
259864
|
const projectId = c.req.param("projectId");
|
|
@@ -259573,7 +260001,7 @@ serverGroups.get("/projects/:projectId/server-groups", async (c) => {
|
|
|
259573
260001
|
{ projectId }
|
|
259574
260002
|
);
|
|
259575
260003
|
} catch (error) {
|
|
259576
|
-
throw translateServerGroupError(error);
|
|
260004
|
+
throw redactedReadRefusalError(error, "Server group not found") ?? translateServerGroupError(error);
|
|
259577
260005
|
}
|
|
259578
260006
|
return v1PageJson(c, (rows ?? []).map(toServerGroupDto));
|
|
259579
260007
|
});
|
|
@@ -264953,7 +265381,10 @@ async function listHostRows(convexAuthToken, projectId) {
|
|
|
264953
265381
|
{ projectId }
|
|
264954
265382
|
) ?? [];
|
|
264955
265383
|
} catch (error) {
|
|
264956
|
-
throw
|
|
265384
|
+
throw redactedReadRefusalError(
|
|
265385
|
+
error,
|
|
265386
|
+
"Project or client not found, or you do not have access to it."
|
|
265387
|
+
) ?? translateConvexWriteError3(error);
|
|
264957
265388
|
}
|
|
264958
265389
|
}
|
|
264959
265390
|
async function readHostDetail(convexAuthToken, projectId, hostId) {
|
|
@@ -265635,7 +266066,10 @@ async function readEnvironment(convexAuthToken, projectId, environmentId) {
|
|
|
265635
266066
|
{ projectId, environmentId }
|
|
265636
266067
|
);
|
|
265637
266068
|
} catch (error) {
|
|
265638
|
-
throw
|
|
266069
|
+
throw redactedReadRefusalError(
|
|
266070
|
+
error,
|
|
266071
|
+
"Environment or project not found, or you do not have access to it."
|
|
266072
|
+
) ?? translateConvexError(error);
|
|
265639
266073
|
}
|
|
265640
266074
|
if (!row2) {
|
|
265641
266075
|
throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Environment not found");
|
|
@@ -265754,7 +266188,10 @@ environments2.get("/projects/:projectId/environments", async (c) => {
|
|
|
265754
266188
|
{ projectId, includeArchived }
|
|
265755
266189
|
);
|
|
265756
266190
|
} catch (error) {
|
|
265757
|
-
throw
|
|
266191
|
+
throw redactedReadRefusalError(
|
|
266192
|
+
error,
|
|
266193
|
+
"Environment or project not found, or you do not have access to it."
|
|
266194
|
+
) ?? translateConvexError(error);
|
|
265758
266195
|
}
|
|
265759
266196
|
return v1PageJson(
|
|
265760
266197
|
c,
|
|
@@ -266046,7 +266483,8 @@ function translatePluginReadError(error) {
|
|
|
266046
266483
|
}
|
|
266047
266484
|
return translateConvexReadError(error, {
|
|
266048
266485
|
scope: "v1/plugins",
|
|
266049
|
-
notFoundMessage: "Plugin or project not found, or you do not have access."
|
|
266486
|
+
notFoundMessage: "Plugin or project not found, or you do not have access.",
|
|
266487
|
+
redactedIsRefusal: true
|
|
266050
266488
|
});
|
|
266051
266489
|
}
|
|
266052
266490
|
plugins2.get("/projects/:projectId/plugins", async (c) => {
|
|
@@ -266129,7 +266567,10 @@ function translateSkillReadError(error) {
|
|
|
266129
266567
|
}
|
|
266130
266568
|
return translateConvexReadError(error, {
|
|
266131
266569
|
scope: "v1/skills",
|
|
266132
|
-
notFoundMessage: "Skill or project not found, or you do not have access."
|
|
266570
|
+
notFoundMessage: "Skill or project not found, or you do not have access.",
|
|
266571
|
+
// Every read here scopes a caller-supplied id; production masks the plain
|
|
266572
|
+
// refusal to "Server Error", which answered 502 without this (MJ-021).
|
|
266573
|
+
redactedIsRefusal: true
|
|
266133
266574
|
});
|
|
266134
266575
|
}
|
|
266135
266576
|
skills4.get("/projects/:projectId/skills", async (c) => {
|
|
@@ -266192,7 +266633,10 @@ import { Hono as Hono98 } from "hono";
|
|
|
266192
266633
|
import { z as z70 } from "zod";
|
|
266193
266634
|
var personas = new Hono98();
|
|
266194
266635
|
function translateReadError(error) {
|
|
266195
|
-
return translateConvexReadError(error, {
|
|
266636
|
+
return translateConvexReadError(error, {
|
|
266637
|
+
scope: "v1.personas",
|
|
266638
|
+
redactedIsRefusal: true
|
|
266639
|
+
});
|
|
266196
266640
|
}
|
|
266197
266641
|
function toPersonaDto(row2, projectId) {
|
|
266198
266642
|
return {
|
|
@@ -266385,7 +266829,10 @@ import { Hono as Hono99 } from "hono";
|
|
|
266385
266829
|
import { z as z71 } from "zod";
|
|
266386
266830
|
var swarms = new Hono99();
|
|
266387
266831
|
function translateReadError2(error) {
|
|
266388
|
-
return translateConvexReadError(error, {
|
|
266832
|
+
return translateConvexReadError(error, {
|
|
266833
|
+
scope: "v1.swarms",
|
|
266834
|
+
redactedIsRefusal: true
|
|
266835
|
+
});
|
|
266389
266836
|
}
|
|
266390
266837
|
function toSwarmDto(row2) {
|
|
266391
266838
|
return {
|
|
@@ -266608,6 +267055,12 @@ var MAX_PAGE_SIZE = 200;
|
|
|
266608
267055
|
function translateReadError3(error) {
|
|
266609
267056
|
return translateConvexReadError(error, { scope: "v1.journeys" });
|
|
266610
267057
|
}
|
|
267058
|
+
function translatePreflightReadError(error) {
|
|
267059
|
+
return translateConvexReadError(error, {
|
|
267060
|
+
scope: "v1.journeys",
|
|
267061
|
+
redactedIsRefusal: true
|
|
267062
|
+
});
|
|
267063
|
+
}
|
|
266611
267064
|
function paginationOptsFrom(c) {
|
|
266612
267065
|
const cursor = c.req.query("cursor");
|
|
266613
267066
|
const rawLimit = Number(c.req.query("limit"));
|
|
@@ -266863,7 +267316,7 @@ async function requireGoalInProject(client3, projectId, goalId, surface) {
|
|
|
266863
267316
|
}
|
|
266864
267317
|
);
|
|
266865
267318
|
} catch (error) {
|
|
266866
|
-
throw
|
|
267319
|
+
throw translatePreflightReadError(error);
|
|
266867
267320
|
}
|
|
266868
267321
|
if (!row2) {
|
|
266869
267322
|
throw new WebRouteError(
|
|
@@ -266884,7 +267337,7 @@ async function requireRunInProject(client3, projectId, runId, surface) {
|
|
|
266884
267337
|
}
|
|
266885
267338
|
);
|
|
266886
267339
|
} catch (error) {
|
|
266887
|
-
throw
|
|
267340
|
+
throw translatePreflightReadError(error);
|
|
266888
267341
|
}
|
|
266889
267342
|
if (!run3 || String(run3.projectId) !== projectId) {
|
|
266890
267343
|
throw new WebRouteError(
|
|
@@ -266911,7 +267364,7 @@ both(
|
|
|
266911
267364
|
}
|
|
266912
267365
|
);
|
|
266913
267366
|
} catch (error) {
|
|
266914
|
-
throw
|
|
267367
|
+
throw translatePreflightReadError(error);
|
|
266915
267368
|
}
|
|
266916
267369
|
return v1PageJson(
|
|
266917
267370
|
c,
|
|
@@ -267255,7 +267708,10 @@ import { Hono as Hono101 } from "hono";
|
|
|
267255
267708
|
import { z as z73 } from "zod";
|
|
267256
267709
|
var secrets = new Hono101();
|
|
267257
267710
|
function translateReadError4(error) {
|
|
267258
|
-
return translateConvexReadError(error, {
|
|
267711
|
+
return translateConvexReadError(error, {
|
|
267712
|
+
scope: "v1.secrets",
|
|
267713
|
+
redactedIsRefusal: true
|
|
267714
|
+
});
|
|
267259
267715
|
}
|
|
267260
267716
|
function toSecretDto(row2) {
|
|
267261
267717
|
return {
|
|
@@ -268034,6 +268490,12 @@ var swarmInsights = new Hono104();
|
|
|
268034
268490
|
function translateReadError6(error) {
|
|
268035
268491
|
return translateConvexReadError(error, { scope: "v1.swarm-insights" });
|
|
268036
268492
|
}
|
|
268493
|
+
function translatePreflightReadError2(error) {
|
|
268494
|
+
return translateConvexReadError(error, {
|
|
268495
|
+
scope: "v1.swarm-insights",
|
|
268496
|
+
redactedIsRefusal: true
|
|
268497
|
+
});
|
|
268498
|
+
}
|
|
268037
268499
|
function toScorecardDto(row2, runId) {
|
|
268038
268500
|
return {
|
|
268039
268501
|
runId,
|
|
@@ -268189,7 +268651,7 @@ async function requireRunInProject2(client3, projectId, runId) {
|
|
|
268189
268651
|
{ runId }
|
|
268190
268652
|
);
|
|
268191
268653
|
} catch (error) {
|
|
268192
|
-
throw
|
|
268654
|
+
throw translatePreflightReadError2(error);
|
|
268193
268655
|
}
|
|
268194
268656
|
if (!run3 || String(run3.projectId) !== projectId) {
|
|
268195
268657
|
throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Journey run not found");
|
|
@@ -268202,7 +268664,7 @@ async function listFindingRows(client3, projectId) {
|
|
|
268202
268664
|
{ projectId }
|
|
268203
268665
|
) ?? [];
|
|
268204
268666
|
} catch (error) {
|
|
268205
|
-
throw
|
|
268667
|
+
throw translatePreflightReadError2(error);
|
|
268206
268668
|
}
|
|
268207
268669
|
}
|
|
268208
268670
|
async function requireFindingInProject(client3, projectId, findingId) {
|
|
@@ -268235,7 +268697,7 @@ both2(
|
|
|
268235
268697
|
{ projectId }
|
|
268236
268698
|
);
|
|
268237
268699
|
} catch (error) {
|
|
268238
|
-
throw
|
|
268700
|
+
throw translatePreflightReadError2(error);
|
|
268239
268701
|
}
|
|
268240
268702
|
return v1Resource(c, toOverviewDto(row2));
|
|
268241
268703
|
}
|
|
@@ -268304,7 +268766,7 @@ bothInsights("get", "/insights", async (c, surface) => {
|
|
|
268304
268766
|
{ projectId, swarmRunGroupId: swarmRunId }
|
|
268305
268767
|
);
|
|
268306
268768
|
} catch (error) {
|
|
268307
|
-
throw
|
|
268769
|
+
throw translatePreflightReadError2(error);
|
|
268308
268770
|
}
|
|
268309
268771
|
if (!row2) {
|
|
268310
268772
|
throw new WebRouteError(
|
|
@@ -268590,7 +269052,11 @@ async function requireEnvironmentInProject(client3, projectId, environmentId) {
|
|
|
268590
269052
|
} catch (error) {
|
|
268591
269053
|
const failure = classifyConvexReadError(error);
|
|
268592
269054
|
if (failure.kind !== "membership") {
|
|
268593
|
-
throw translateConvexReadError(error, {
|
|
269055
|
+
throw translateConvexReadError(error, {
|
|
269056
|
+
scope: "v1.scenarios",
|
|
269057
|
+
notFoundMessage: "Environment not found",
|
|
269058
|
+
redactedIsRefusal: true
|
|
269059
|
+
});
|
|
268594
269060
|
}
|
|
268595
269061
|
row2 = null;
|
|
268596
269062
|
}
|
|
@@ -268702,8 +269168,14 @@ var unpublishHandler = async (c) => {
|
|
|
268702
269168
|
});
|
|
268703
269169
|
};
|
|
268704
269170
|
var STUDY_SUCCESSOR = "/api/v1/projects/{projectId}/environments/{environmentId}/study";
|
|
268705
|
-
scenarios2.put(
|
|
268706
|
-
|
|
269171
|
+
scenarios2.put(
|
|
269172
|
+
"/projects/:projectId/environments/:environmentId/study",
|
|
269173
|
+
publishHandler
|
|
269174
|
+
);
|
|
269175
|
+
scenarios2.delete(
|
|
269176
|
+
"/projects/:projectId/environments/:environmentId/study",
|
|
269177
|
+
unpublishHandler
|
|
269178
|
+
);
|
|
268707
269179
|
scenarios2.put(
|
|
268708
269180
|
"/projects/:projectId/environments/:environmentId/scenario",
|
|
268709
269181
|
(c) => {
|
|
@@ -268765,6 +269237,37 @@ async function fetchJsonBlob(url, options) {
|
|
|
268765
269237
|
|
|
268766
269238
|
// server/routes/v1/convex-v1-proxy.ts
|
|
268767
269239
|
var PROXY_TIMEOUT_MS = 15e3;
|
|
269240
|
+
var CONVEX_INTERNAL_DETAIL = /\bArgumentValidationError\b|\bValidator:\s|\[Request ID:/;
|
|
269241
|
+
function sanitizeProxiedFailure(c, convexPath, status, body) {
|
|
269242
|
+
if (status < 400) return body;
|
|
269243
|
+
const serialized = JSON.stringify(body) ?? "";
|
|
269244
|
+
if (!CONVEX_INTERNAL_DETAIL.test(serialized)) return body;
|
|
269245
|
+
if (!HOSTED_MODE) return body;
|
|
269246
|
+
const { requestId } = responseRequestId(c);
|
|
269247
|
+
logger.warn("[v1.read-proxy] upstream error text withheld from response", {
|
|
269248
|
+
convexPath,
|
|
269249
|
+
status,
|
|
269250
|
+
requestId,
|
|
269251
|
+
detail: redactForLog(
|
|
269252
|
+
JSON.stringify(body, (key, value) => {
|
|
269253
|
+
if (typeof value !== "string") return value;
|
|
269254
|
+
if (/^(api[-_]?key|secret|token|password|passwd|authorization)$/i.test(
|
|
269255
|
+
key
|
|
269256
|
+
)) {
|
|
269257
|
+
return "[redacted]";
|
|
269258
|
+
}
|
|
269259
|
+
return redactForLog(value);
|
|
269260
|
+
})
|
|
269261
|
+
)
|
|
269262
|
+
});
|
|
269263
|
+
const upstreamCode = body?.code;
|
|
269264
|
+
const code = typeof upstreamCode === "string" && !CONVEX_INTERNAL_DETAIL.test(upstreamCode) ? upstreamCode : status >= 500 ? ErrorCode.INTERNAL_ERROR : ErrorCode.VALIDATION_ERROR;
|
|
269265
|
+
return {
|
|
269266
|
+
code,
|
|
269267
|
+
message: status >= 500 ? hostedInternalErrorMessage(requestId) : `One or more request parameters were invalid. If it keeps happening, contact support with reference ${requestId}.`,
|
|
269268
|
+
details: { requestId }
|
|
269269
|
+
};
|
|
269270
|
+
}
|
|
268768
269271
|
function forwardQueryParams(c, target, names) {
|
|
268769
269272
|
for (const name15 of names) {
|
|
268770
269273
|
const value = c.req.query(name15);
|
|
@@ -268846,7 +269349,11 @@ async function fetchConvexV1Read(c, convexPath, configure, options = {}) {
|
|
|
268846
269349
|
const value = response.headers.get(name15);
|
|
268847
269350
|
if (value) headers[name15] = value;
|
|
268848
269351
|
}
|
|
268849
|
-
return {
|
|
269352
|
+
return {
|
|
269353
|
+
status: response.status,
|
|
269354
|
+
body: sanitizeProxiedFailure(c, convexPath, response.status, body),
|
|
269355
|
+
headers
|
|
269356
|
+
};
|
|
268850
269357
|
}
|
|
268851
269358
|
async function proxyConvexV1Read(c, convexPath, configure, options) {
|
|
268852
269359
|
const { status, body, headers } = await fetchConvexV1Read(
|
|
@@ -268882,7 +269389,7 @@ function both3(method, suffix, handler) {
|
|
|
268882
269389
|
function translateReadError7(error) {
|
|
268883
269390
|
return translateConvexReadError(error, { scope: "v1.user-testing" });
|
|
268884
269391
|
}
|
|
268885
|
-
function
|
|
269392
|
+
function translatePreflightReadError3(error, notFoundMessage) {
|
|
268886
269393
|
return translateConvexReadError(error, {
|
|
268887
269394
|
scope: "v1.user-testing",
|
|
268888
269395
|
notFoundMessage,
|
|
@@ -268946,7 +269453,7 @@ async function requireScenarioInProject(client3, projectId, scenarioId) {
|
|
|
268946
269453
|
{ scenarioId }
|
|
268947
269454
|
);
|
|
268948
269455
|
} catch (error) {
|
|
268949
|
-
throw
|
|
269456
|
+
throw translatePreflightReadError3(error, "Scenario not found");
|
|
268950
269457
|
}
|
|
268951
269458
|
if (!row2 || String(row2.projectId ?? "") !== projectId) {
|
|
268952
269459
|
throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Scenario not found");
|
|
@@ -269178,7 +269685,7 @@ both3("get", "/sessions/:sessionId", async (c, surface) => {
|
|
|
269178
269685
|
{ sessionId }
|
|
269179
269686
|
);
|
|
269180
269687
|
} catch (error) {
|
|
269181
|
-
throw
|
|
269688
|
+
throw translatePreflightReadError3(error, "Session not found");
|
|
269182
269689
|
}
|
|
269183
269690
|
if (!session || String(session.scenarioId ?? "") !== scenarioId) {
|
|
269184
269691
|
throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Session not found");
|
|
@@ -269592,7 +270099,7 @@ var RESOURCE_TYPES = /* @__PURE__ */ new Set(["scenario", "conformanceRun", "eva
|
|
|
269592
270099
|
function translateReadError8(error) {
|
|
269593
270100
|
return translateConvexReadError(error, { scope: "v1.shares" });
|
|
269594
270101
|
}
|
|
269595
|
-
function
|
|
270102
|
+
function translatePreflightReadError4(error) {
|
|
269596
270103
|
return translateConvexReadError(error, {
|
|
269597
270104
|
scope: "v1.shares",
|
|
269598
270105
|
notFoundMessage: "Share not found",
|
|
@@ -269653,7 +270160,7 @@ async function requireShareInProject(client3, projectId, resourceType, resourceI
|
|
|
269653
270160
|
{ resourceType, resourceId }
|
|
269654
270161
|
);
|
|
269655
270162
|
} catch (error) {
|
|
269656
|
-
throw
|
|
270163
|
+
throw translatePreflightReadError4(error);
|
|
269657
270164
|
}
|
|
269658
270165
|
if (!row2 || String(row2.projectId ?? "") !== projectId) {
|
|
269659
270166
|
throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Share not found");
|
|
@@ -269863,7 +270370,10 @@ async function readEnvironmentInProject(convexAuthToken, projectId, environmentI
|
|
|
269863
270370
|
}
|
|
269864
270371
|
);
|
|
269865
270372
|
} catch (error) {
|
|
269866
|
-
throw
|
|
270373
|
+
throw redactedReadRefusalError(
|
|
270374
|
+
error,
|
|
270375
|
+
"Environment or project not found, or you do not have access to it."
|
|
270376
|
+
) ?? translateConvexWriteError4(error);
|
|
269867
270377
|
}
|
|
269868
270378
|
if (!env || env.projectId !== projectId) {
|
|
269869
270379
|
throw new WebRouteError(
|
|
@@ -269949,7 +270459,10 @@ images.get("/projects/:projectId/images", async (c) => {
|
|
|
269949
270459
|
{ projectId }
|
|
269950
270460
|
);
|
|
269951
270461
|
} catch (error) {
|
|
269952
|
-
throw
|
|
270462
|
+
throw redactedReadRefusalError(
|
|
270463
|
+
error,
|
|
270464
|
+
"Environment or project not found, or you do not have access to it."
|
|
270465
|
+
) ?? translateConvexWriteError4(error);
|
|
269953
270466
|
}
|
|
269954
270467
|
return v1PageJson(c, (rows ?? []).map(toEnvironmentDto2));
|
|
269955
270468
|
});
|
|
@@ -270591,6 +271104,7 @@ router2.post("/projects/:projectId/eval-runs/:runId/backtest", async (c) => {
|
|
|
270591
271104
|
return v1Error(c, "INTERNAL_ERROR", "Backtest service is unavailable");
|
|
270592
271105
|
const client3 = new ConvexHttpClient26(process.env.CONVEX_URL);
|
|
270593
271106
|
client3.setAuth(token);
|
|
271107
|
+
let scopeVerified = false;
|
|
270594
271108
|
try {
|
|
270595
271109
|
const run3 = await client3.query(
|
|
270596
271110
|
"testSuites:getTestSuiteRun",
|
|
@@ -270598,6 +271112,7 @@ router2.post("/projects/:projectId/eval-runs/:runId/backtest", async (c) => {
|
|
|
270598
271112
|
);
|
|
270599
271113
|
if (!run3 || run3.projectId !== c.req.param("projectId") || !run3.suiteId)
|
|
270600
271114
|
return v1Error(c, "NOT_FOUND", "Eval run not found");
|
|
271115
|
+
scopeVerified = true;
|
|
270601
271116
|
const report = await runAssertionBacktest({
|
|
270602
271117
|
runId: c.req.param("runId"),
|
|
270603
271118
|
suiteId: run3.suiteId,
|
|
@@ -270657,7 +271172,9 @@ router2.post("/projects/:projectId/eval-runs/:runId/backtest", async (c) => {
|
|
|
270657
271172
|
);
|
|
270658
271173
|
throw translateConvexReadError(error, {
|
|
270659
271174
|
scope: "v1.eval-backtest",
|
|
270660
|
-
notFoundMessage: "Eval run not found or backtest is not authorized"
|
|
271175
|
+
notFoundMessage: "Eval run not found or backtest is not authorized",
|
|
271176
|
+
// Only the initial run lookup can be a masked scope refusal.
|
|
271177
|
+
redactedIsRefusal: !scopeVerified
|
|
270661
271178
|
});
|
|
270662
271179
|
}
|
|
270663
271180
|
});
|
|
@@ -270684,6 +271201,7 @@ router2.post(
|
|
|
270684
271201
|
return v1Error(c, "INTERNAL_ERROR", "Backtest service is unavailable");
|
|
270685
271202
|
const client3 = new ConvexHttpClient26(process.env.CONVEX_URL);
|
|
270686
271203
|
client3.setAuth(await getConvexBearerForRequest(c));
|
|
271204
|
+
let scopeVerified = false;
|
|
270687
271205
|
try {
|
|
270688
271206
|
const run3 = await client3.query(
|
|
270689
271207
|
"testSuites:getTestSuiteRun",
|
|
@@ -270691,6 +271209,7 @@ router2.post(
|
|
|
270691
271209
|
);
|
|
270692
271210
|
if (!run3 || run3.projectId !== c.req.param("projectId") || !run3.suiteId)
|
|
270693
271211
|
return v1Error(c, "NOT_FOUND", "Eval run not found");
|
|
271212
|
+
scopeVerified = true;
|
|
270694
271213
|
const report = await client3.action(
|
|
270695
271214
|
"goalCompletionAction:requestJudgeBacktest",
|
|
270696
271215
|
{
|
|
@@ -270713,7 +271232,9 @@ router2.post(
|
|
|
270713
271232
|
);
|
|
270714
271233
|
throw translateConvexReadError(error, {
|
|
270715
271234
|
scope: "v1.eval-judge-backtest",
|
|
270716
|
-
notFoundMessage: "Eval run not found or judge backtest is not authorized"
|
|
271235
|
+
notFoundMessage: "Eval run not found or judge backtest is not authorized",
|
|
271236
|
+
// Only the initial run lookup can be a masked scope refusal.
|
|
271237
|
+
redactedIsRefusal: !scopeVerified
|
|
270717
271238
|
});
|
|
270718
271239
|
}
|
|
270719
271240
|
}
|
|
@@ -273201,6 +273722,7 @@ function buildAgentApiToolSet(opts) {
|
|
|
273201
273722
|
const tools5 = {};
|
|
273202
273723
|
for (const operation of AGENT_API_OPERATIONS) {
|
|
273203
273724
|
if (opts.disabledOperations?.has(operation.name)) continue;
|
|
273725
|
+
if (operation.readOnly !== true && opts.hasHumanSurface !== true) continue;
|
|
273204
273726
|
tools5[operation.name] = tool18({
|
|
273205
273727
|
description: `${operation.description} (Scoped to the current project automatically.)`,
|
|
273206
273728
|
inputSchema: relaxProjectRequirement(
|
|
@@ -273388,6 +273910,17 @@ agent.use("/agent-ops", requireVerifiedAuth());
|
|
|
273388
273910
|
agent.get("/agent-ops", async (c) => {
|
|
273389
273911
|
return v1Resource(c, { operations: listAgentOpCatalog() });
|
|
273390
273912
|
});
|
|
273913
|
+
async function readAgentJobStatus(convex, jobId) {
|
|
273914
|
+
try {
|
|
273915
|
+
return await convex.query("agentTurnState:status", { jobId });
|
|
273916
|
+
} catch (error) {
|
|
273917
|
+
throw translateStructuredConvexRefusal(error) ?? translateConvexReadError(error, {
|
|
273918
|
+
scope: "v1.agent",
|
|
273919
|
+
notFoundMessage: "Agent job not found.",
|
|
273920
|
+
redactedIsRefusal: true
|
|
273921
|
+
});
|
|
273922
|
+
}
|
|
273923
|
+
}
|
|
273391
273924
|
agent.get("/projects/:projectId/agent/jobs/:jobId", async (c) => {
|
|
273392
273925
|
if (!process.env.CONVEX_URL)
|
|
273393
273926
|
return v1Error(
|
|
@@ -273396,9 +273929,7 @@ agent.get("/projects/:projectId/agent/jobs/:jobId", async (c) => {
|
|
|
273396
273929
|
"The agent endpoint requires a hosted MCPJam deployment."
|
|
273397
273930
|
);
|
|
273398
273931
|
const convex = createConvexClient(await getConvexBearerForRequest(c));
|
|
273399
|
-
const result = await convex.
|
|
273400
|
-
jobId: c.req.param("jobId")
|
|
273401
|
-
});
|
|
273932
|
+
const result = await readAgentJobStatus(convex, c.req.param("jobId"));
|
|
273402
273933
|
if (!result || result.projectId !== c.req.param("projectId"))
|
|
273403
273934
|
return v1Error(c, "NOT_FOUND", "Agent job not found.");
|
|
273404
273935
|
return v1Resource(c, result);
|
|
@@ -273411,9 +273942,7 @@ agent.post("/projects/:projectId/agent/jobs/:jobId/cancel", async (c) => {
|
|
|
273411
273942
|
"The agent endpoint requires a hosted MCPJam deployment."
|
|
273412
273943
|
);
|
|
273413
273944
|
const convex = createConvexClient(await getConvexBearerForRequest(c));
|
|
273414
|
-
const status = await convex.
|
|
273415
|
-
jobId: c.req.param("jobId")
|
|
273416
|
-
});
|
|
273945
|
+
const status = await readAgentJobStatus(convex, c.req.param("jobId"));
|
|
273417
273946
|
if (!status || status.projectId !== c.req.param("projectId"))
|
|
273418
273947
|
return v1Error(c, "NOT_FOUND", "Agent job not found.");
|
|
273419
273948
|
await convex.mutation("agentTurnState:cancel", {
|
|
@@ -273563,7 +274092,10 @@ agent.post("/projects/:projectId/agent", async (c) => {
|
|
|
273563
274092
|
created,
|
|
273564
274093
|
...body.idempotencyKey ? { turnIdempotencyKey: body.idempotencyKey } : {},
|
|
273565
274094
|
clientWithHeaders: makeClient4,
|
|
273566
|
-
disabledOperations
|
|
274095
|
+
disabledOperations,
|
|
274096
|
+
// The same presence test that decides whether the gated tools exist
|
|
274097
|
+
// at all: without it the direct tier's writes are omitted too.
|
|
274098
|
+
hasHumanSurface: proposalSurface !== void 0
|
|
273567
274099
|
}),
|
|
273568
274100
|
...proposalSurface ? buildGatedProposalTools({
|
|
273569
274101
|
projectId,
|
|
@@ -275424,6 +275956,8 @@ function resolveChatSessionEngine(args) {
|
|
|
275424
275956
|
const hostConfig = args.hostTarget.runtimeConfig;
|
|
275425
275957
|
const name15 = getHarnessAdapter(harness2).displayName;
|
|
275426
275958
|
const requireToolApproval = hostConfig.requireToolApproval === true;
|
|
275959
|
+
const hostSelection = hostConfig.modelSelection;
|
|
275960
|
+
const hostEffort = hostSelection?.modelId === args.model.id ? selectionReasoningEffort(hostSelection) : void 0;
|
|
275427
275961
|
const availability = checkHarnessRuntimeAvailable({
|
|
275428
275962
|
harnessId: harness2,
|
|
275429
275963
|
requireToolApproval,
|
|
@@ -275435,7 +275969,11 @@ function resolveChatSessionEngine(args) {
|
|
|
275435
275969
|
xaaEnterprisePolicyOn: readXaaEnterprisePolicy(hostConfig.mcpProfile).kind !== "off",
|
|
275436
275970
|
// An API chat turn is chat: an unverified harness × model pair runs, and
|
|
275437
275971
|
// the verdict's reason comes back as `warning`.
|
|
275438
|
-
purpose: "chat"
|
|
275972
|
+
purpose: "chat",
|
|
275973
|
+
// The host's saved effort, when its selection names the model this turn
|
|
275974
|
+
// runs. A harness that cannot apply it refuses the turn instead of running
|
|
275975
|
+
// without it.
|
|
275976
|
+
...hostEffort !== void 0 ? { reasoningEffort: hostEffort } : {}
|
|
275439
275977
|
});
|
|
275440
275978
|
if (!availability.ok) {
|
|
275441
275979
|
return {
|
|
@@ -276836,7 +277374,7 @@ var DEFAULT_MESSAGE_PAGE = 50;
|
|
|
276836
277374
|
var MAX_MESSAGE_PAGE = 200;
|
|
276837
277375
|
var DEFAULT_TRACE_TURNS = 1;
|
|
276838
277376
|
var MAX_TRACE_TURNS = 20;
|
|
276839
|
-
function
|
|
277377
|
+
function translatePreflightReadError5(error) {
|
|
276840
277378
|
return translateConvexReadError(error, {
|
|
276841
277379
|
scope: "v1.chat-sessions",
|
|
276842
277380
|
notFoundMessage: "Chat session not found",
|
|
@@ -276856,7 +277394,7 @@ async function resolveScopedSession(client3, sessionId, projectId) {
|
|
|
276856
277394
|
}
|
|
276857
277395
|
);
|
|
276858
277396
|
} catch (error) {
|
|
276859
|
-
throw
|
|
277397
|
+
throw translatePreflightReadError5(error);
|
|
276860
277398
|
}
|
|
276861
277399
|
if (!session) {
|
|
276862
277400
|
throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Chat session not found");
|
|
@@ -277553,66 +278091,69 @@ var connectCheckRepoSchema = z93.object({
|
|
|
277553
278091
|
*/
|
|
277554
278092
|
outagePolicy: z93.enum(["fail_open", "fail_closed"])
|
|
277555
278093
|
}).strict();
|
|
277556
|
-
evalChecks.get(
|
|
277557
|
-
"
|
|
277558
|
-
|
|
277559
|
-
|
|
277560
|
-
|
|
277561
|
-
|
|
277562
|
-
|
|
277563
|
-
|
|
277564
|
-
|
|
277565
|
-
|
|
277566
|
-
|
|
277567
|
-
|
|
277568
|
-
|
|
277569
|
-
}
|
|
277570
|
-
|
|
277571
|
-
|
|
277572
|
-
|
|
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
|
-
}
|
|
278094
|
+
evalChecks.get("/organizations/:organizationId/eval-check-repos", async (c) => {
|
|
278095
|
+
const organizationId = c.req.param("organizationId");
|
|
278096
|
+
const client3 = convexClient4(await getConvexBearerForRequest(c));
|
|
278097
|
+
let availability = null;
|
|
278098
|
+
try {
|
|
278099
|
+
availability = await client3.query(
|
|
278100
|
+
"github/checkRepoConfigs:getGithubChecksSettingsAvailability",
|
|
278101
|
+
{ organizationId }
|
|
278102
|
+
);
|
|
278103
|
+
} catch (error) {
|
|
278104
|
+
throw translateConvexReadError(error, {
|
|
278105
|
+
scope: "v1.evalChecks",
|
|
278106
|
+
redactedIsRefusal: true
|
|
278107
|
+
});
|
|
278108
|
+
}
|
|
278109
|
+
const enabled = availability?.state === "enabled";
|
|
278110
|
+
if (!enabled) {
|
|
277608
278111
|
return v1Resource(c, {
|
|
277609
278112
|
organizationId,
|
|
277610
|
-
available:
|
|
277611
|
-
items:
|
|
277612
|
-
connectable
|
|
278113
|
+
available: false,
|
|
278114
|
+
items: [],
|
|
278115
|
+
connectable: null
|
|
277613
278116
|
});
|
|
277614
278117
|
}
|
|
277615
|
-
|
|
278118
|
+
let rows;
|
|
278119
|
+
try {
|
|
278120
|
+
rows = await client3.query(
|
|
278121
|
+
"github/checkRepoConfigs:listForOrganization",
|
|
278122
|
+
{ organizationId }
|
|
278123
|
+
) ?? [];
|
|
278124
|
+
} catch (error) {
|
|
278125
|
+
throw translateConvexReadError(error, {
|
|
278126
|
+
scope: "v1.evalChecks",
|
|
278127
|
+
redactedIsRefusal: true
|
|
278128
|
+
});
|
|
278129
|
+
}
|
|
278130
|
+
let connectable = null;
|
|
278131
|
+
try {
|
|
278132
|
+
const repos = await client3.action(
|
|
278133
|
+
"github/checkRepoConfigsNode:listInstallationRepos",
|
|
278134
|
+
{ organizationId }
|
|
278135
|
+
) ?? [];
|
|
278136
|
+
connectable = repos.map((repo) => ({
|
|
278137
|
+
repo: String(repo.fullName ?? repo.repoFullName ?? "")
|
|
278138
|
+
}));
|
|
278139
|
+
} catch (error) {
|
|
278140
|
+
reportRouteFailure(
|
|
278141
|
+
"[v1.evalChecks] installation repositories unavailable",
|
|
278142
|
+
error,
|
|
278143
|
+
{
|
|
278144
|
+
source: "v1.evalChecks.listInstallationRepos",
|
|
278145
|
+
hop: "mcpjam_internal"
|
|
278146
|
+
}
|
|
278147
|
+
);
|
|
278148
|
+
connectable = null;
|
|
278149
|
+
}
|
|
278150
|
+
return v1Resource(c, {
|
|
278151
|
+
organizationId,
|
|
278152
|
+
available: true,
|
|
278153
|
+
items: rows.map(toCheckRepoDto),
|
|
278154
|
+
connectable
|
|
278155
|
+
});
|
|
278156
|
+
});
|
|
277616
278157
|
evalChecks.post(
|
|
277617
278158
|
"/organizations/:organizationId/eval-check-repos",
|
|
277618
278159
|
async (c) => {
|
|
@@ -277783,7 +278324,10 @@ spendBudget.get("/organizations/:organizationId/spend-budget", async (c) => {
|
|
|
277783
278324
|
{ organizationId }
|
|
277784
278325
|
);
|
|
277785
278326
|
} catch (error) {
|
|
277786
|
-
throw translateConvexReadError(error, {
|
|
278327
|
+
throw translateConvexReadError(error, {
|
|
278328
|
+
scope: "v1.spendBudget",
|
|
278329
|
+
redactedIsRefusal: true
|
|
278330
|
+
});
|
|
277787
278331
|
}
|
|
277788
278332
|
return v1Resource(c, toBudgetDto(view));
|
|
277789
278333
|
});
|
|
@@ -278138,7 +278682,11 @@ capabilities.get("/projects/:projectId/capabilities", async (c) => {
|
|
|
278138
278682
|
{ projectId }
|
|
278139
278683
|
);
|
|
278140
278684
|
} catch (error) {
|
|
278141
|
-
throw translateConvexReadError(error, {
|
|
278685
|
+
throw translateConvexReadError(error, {
|
|
278686
|
+
scope: "v1.capabilities",
|
|
278687
|
+
notFoundMessage: "Project not found",
|
|
278688
|
+
redactedIsRefusal: true
|
|
278689
|
+
});
|
|
278142
278690
|
}
|
|
278143
278691
|
if (!row2) {
|
|
278144
278692
|
throw new WebRouteError(404, ErrorCode.NOT_FOUND, "Project not found");
|
|
@@ -279479,10 +280027,14 @@ readiness.get("/projects/:projectId/readiness-runs/:runId", async (c) => {
|
|
|
279479
280027
|
runId
|
|
279480
280028
|
});
|
|
279481
280029
|
} catch (error) {
|
|
279482
|
-
throw translateConvexWriteError(error, { resource: "Readiness run" });
|
|
280030
|
+
throw redactedReadRefusalError(error, "Readiness run not found") ?? translateConvexWriteError(error, { resource: "Readiness run" });
|
|
279483
280031
|
}
|
|
279484
280032
|
if (!run3) {
|
|
279485
|
-
throw new WebRouteError(
|
|
280033
|
+
throw new WebRouteError(
|
|
280034
|
+
404,
|
|
280035
|
+
ErrorCode.NOT_FOUND,
|
|
280036
|
+
"Readiness run not found"
|
|
280037
|
+
);
|
|
279486
280038
|
}
|
|
279487
280039
|
return v1Resource(c, toRunDto2(run3, projectId));
|
|
279488
280040
|
});
|
|
@@ -279516,7 +280068,7 @@ readiness.get("/projects/:projectId/readiness-runs", async (c) => {
|
|
|
279516
280068
|
...limit !== void 0 ? { limit } : {}
|
|
279517
280069
|
});
|
|
279518
280070
|
} catch (error) {
|
|
279519
|
-
throw translateConvexWriteError(error, { resource: "Readiness runs" });
|
|
280071
|
+
throw redactedReadRefusalError(error, "Readiness runs not found") ?? translateConvexWriteError(error, { resource: "Readiness runs" });
|
|
279520
280072
|
}
|
|
279521
280073
|
return v1PageJson(
|
|
279522
280074
|
c,
|
|
@@ -279530,10 +280082,9 @@ readiness.post(
|
|
|
279530
280082
|
const runId = c.req.param("runId");
|
|
279531
280083
|
const convex = createConvexClient9(await getConvexBearerForRequest(c));
|
|
279532
280084
|
try {
|
|
279533
|
-
await convex.mutation(
|
|
279534
|
-
|
|
279535
|
-
|
|
279536
|
-
);
|
|
280085
|
+
await convex.mutation("claudeReadinessRuns:cancelReadinessRun", {
|
|
280086
|
+
runId
|
|
280087
|
+
});
|
|
279537
280088
|
} catch (error) {
|
|
279538
280089
|
throw translateConvexWriteError(error, { resource: "Readiness run" });
|
|
279539
280090
|
}
|
|
@@ -279552,7 +280103,7 @@ readiness.get(
|
|
|
279552
280103
|
{ runId }
|
|
279553
280104
|
);
|
|
279554
280105
|
} catch (error) {
|
|
279555
|
-
throw translateConvexWriteError(error, { resource: "Readiness report" });
|
|
280106
|
+
throw redactedReadRefusalError(error, "Readiness report not found") ?? translateConvexWriteError(error, { resource: "Readiness report" });
|
|
279556
280107
|
}
|
|
279557
280108
|
if (!blobId) {
|
|
279558
280109
|
throw new WebRouteError(
|
|
@@ -280387,7 +280938,7 @@ async function loadRun(convex, runId, projectId) {
|
|
|
280387
280938
|
try {
|
|
280388
280939
|
run3 = await convex.query("conformanceRuns:getRun", { runId });
|
|
280389
280940
|
} catch (error) {
|
|
280390
|
-
throw translateConvexWriteError(error, { resource: "Conformance run" });
|
|
280941
|
+
throw redactedReadRefusalError(error, "Conformance run not found") ?? translateConvexWriteError(error, { resource: "Conformance run" });
|
|
280391
280942
|
}
|
|
280392
280943
|
if (!run3) {
|
|
280393
280944
|
throw new WebRouteError(
|
|
@@ -280470,7 +281021,7 @@ conformanceRuns.get("/projects/:projectId/conformance-runs", async (c) => {
|
|
|
280470
281021
|
paginationOpts: paginationOptsFrom2(c)
|
|
280471
281022
|
});
|
|
280472
281023
|
} catch (error) {
|
|
280473
|
-
throw translateConvexWriteError(error, { resource: "Conformance runs" });
|
|
281024
|
+
throw redactedReadRefusalError(error, "Conformance runs not found") ?? translateConvexWriteError(error, { resource: "Conformance runs" });
|
|
280474
281025
|
}
|
|
280475
281026
|
return v1PageJson(
|
|
280476
281027
|
c,
|
|
@@ -281997,7 +282548,7 @@ function percentile(sorted2, p) {
|
|
|
281997
282548
|
return Math.round(sorted2[Math.max(0, idx)]);
|
|
281998
282549
|
}
|
|
281999
282550
|
function flushRelayStats() {
|
|
282000
|
-
if (stats2.requests === 0) return;
|
|
282551
|
+
if (stats2.requests === 0 && stats2.rateLimitRejects === 0) return;
|
|
282001
282552
|
const sorted2 = [...stats2.latenciesMs].sort((a, b) => a - b);
|
|
282002
282553
|
relayLogger.event("relay.stats", {
|
|
282003
282554
|
requests: stats2.requests,
|
|
@@ -282033,38 +282584,38 @@ function flushRelayStats() {
|
|
|
282033
282584
|
}
|
|
282034
282585
|
setInterval(flushRelayStats, STATS_FLUSH_INTERVAL_MS).unref();
|
|
282035
282586
|
var RATE_LIMIT_PER_MIN = 600;
|
|
282587
|
+
var RELAY_INGEST_LIMIT_PER_MIN = 60;
|
|
282036
282588
|
var RATE_WINDOW_MS2 = 6e4;
|
|
282037
282589
|
var UNATTESTED_CLIENT_KEY3 = "unattested";
|
|
282038
|
-
var
|
|
282039
|
-
|
|
282040
|
-
|
|
282041
|
-
|
|
282042
|
-
|
|
282043
|
-
|
|
282044
|
-
|
|
282045
|
-
|
|
282046
|
-
|
|
282047
|
-
|
|
282048
|
-
|
|
282049
|
-
|
|
282590
|
+
var relayWindows = createFixedWindowMap(RATE_LIMIT_PER_MIN, RATE_WINDOW_MS2);
|
|
282591
|
+
var ingestWindows = createFixedWindowMap(
|
|
282592
|
+
RELAY_INGEST_LIMIT_PER_MIN,
|
|
282593
|
+
RATE_WINDOW_MS2
|
|
282594
|
+
);
|
|
282595
|
+
var unattestedIngestWindows = createFixedWindowMap(
|
|
282596
|
+
4 * RELAY_INGEST_LIMIT_PER_MIN,
|
|
282597
|
+
RATE_WINDOW_MS2
|
|
282598
|
+
);
|
|
282599
|
+
function isIngestSubpath(subpath) {
|
|
282600
|
+
return /^\/(?:e|i\/v0\/e|s|i\/v1\/(?:logs|metrics))\/?$/.test(subpath);
|
|
282601
|
+
}
|
|
282602
|
+
function relayClientIp(c) {
|
|
282603
|
+
return edgeAttestationConfigured() ? getAttestedClientIp(c) : null;
|
|
282604
|
+
}
|
|
282050
282605
|
function relayClientKey(c) {
|
|
282051
|
-
return
|
|
282606
|
+
return relayClientIp(c) ?? UNATTESTED_CLIENT_KEY3;
|
|
282052
282607
|
}
|
|
282053
|
-
function relayRateLimit(c) {
|
|
282608
|
+
function relayRateLimit(c, subpath) {
|
|
282054
282609
|
if (!HOSTED_MODE) return null;
|
|
282055
|
-
const
|
|
282056
|
-
|
|
282057
|
-
|
|
282058
|
-
|
|
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 });
|
|
282610
|
+
const attestedIp = relayClientIp(c);
|
|
282611
|
+
let refusedMs = relayWindows.charge(attestedIp ?? UNATTESTED_CLIENT_KEY3);
|
|
282612
|
+
if (refusedMs === null && isIngestSubpath(subpath)) {
|
|
282613
|
+
refusedMs = attestedIp ? ingestWindows.charge(attestedIp) : unattestedIngestWindows.charge(UNATTESTED_CLIENT_KEY3);
|
|
282066
282614
|
}
|
|
282067
|
-
return null;
|
|
282615
|
+
if (refusedMs === null) return null;
|
|
282616
|
+
stats2.rateLimitRejects++;
|
|
282617
|
+
c.header("Retry-After", String(Math.max(1, Math.ceil(refusedMs / 1e3))));
|
|
282618
|
+
return c.json({ error: "rate_limited" }, 429);
|
|
282068
282619
|
}
|
|
282069
282620
|
function makeBodyLimit(maxSize) {
|
|
282070
282621
|
return bodyLimit3({
|
|
@@ -282664,7 +283215,7 @@ async function checkProjectTokens(subpath, url, method, body) {
|
|
|
282664
283215
|
}
|
|
282665
283216
|
var relayRoutes = new Hono137();
|
|
282666
283217
|
relayRoutes.post("/launch-engagement", makeBodyLimit(2048), async (c) => {
|
|
282667
|
-
const limited = relayRateLimit(c);
|
|
283218
|
+
const limited = relayRateLimit(c, "/launch-engagement");
|
|
282668
283219
|
if (limited) return limited;
|
|
282669
283220
|
const parsed = launchEngagementSchema.safeParse(
|
|
282670
283221
|
await c.req.json().catch(() => null)
|
|
@@ -282674,14 +283225,14 @@ relayRoutes.post("/launch-engagement", makeBodyLimit(2048), async (c) => {
|
|
|
282674
283225
|
return c.body(null, 204);
|
|
282675
283226
|
});
|
|
282676
283227
|
relayRoutes.all("*", async (c) => {
|
|
282677
|
-
const
|
|
283228
|
+
const url = new URL(c.req.url);
|
|
283229
|
+
const subpath = stripRelayPrefix(url.pathname);
|
|
283230
|
+
const limited = relayRateLimit(c, subpath);
|
|
282678
283231
|
if (limited) {
|
|
282679
283232
|
return limited;
|
|
282680
283233
|
}
|
|
282681
283234
|
stats2.requests++;
|
|
282682
283235
|
const startedAt = Date.now();
|
|
282683
|
-
const url = new URL(c.req.url);
|
|
282684
|
-
const subpath = stripRelayPrefix(url.pathname);
|
|
282685
283236
|
if (!supportsRelayRequest(subpath, c.req.method)) {
|
|
282686
283237
|
recordResponseStatus(404);
|
|
282687
283238
|
return c.json({ error: "not_found" }, 404);
|
|
@@ -282799,25 +283350,25 @@ var MAX_KEY_SEGMENT = 2048;
|
|
|
282799
283350
|
var RATE_LIMIT = 600;
|
|
282800
283351
|
var RATE_WINDOW_MS3 = 6e4;
|
|
282801
283352
|
var MAX_TRACKED_IPS = 1e4;
|
|
282802
|
-
var
|
|
283353
|
+
var ipWindows7 = /* @__PURE__ */ new Map();
|
|
282803
283354
|
var rateCleanup = setInterval(() => {
|
|
282804
283355
|
const now = Date.now();
|
|
282805
|
-
for (const [ip, entry3] of
|
|
282806
|
-
if (now - entry3.windowStart > RATE_WINDOW_MS3 * 2)
|
|
283356
|
+
for (const [ip, entry3] of ipWindows7) {
|
|
283357
|
+
if (now - entry3.windowStart > RATE_WINDOW_MS3 * 2) ipWindows7.delete(ip);
|
|
282807
283358
|
}
|
|
282808
283359
|
}, 5 * 6e4);
|
|
282809
283360
|
rateCleanup.unref?.();
|
|
282810
283361
|
function isRateLimited(c) {
|
|
282811
283362
|
const ip = getClientIp(c) ?? "unknown";
|
|
282812
283363
|
const now = Date.now();
|
|
282813
|
-
const entry3 =
|
|
283364
|
+
const entry3 = ipWindows7.get(ip);
|
|
282814
283365
|
if (entry3 && now - entry3.windowStart < RATE_WINDOW_MS3) {
|
|
282815
283366
|
if (entry3.count >= RATE_LIMIT) return true;
|
|
282816
283367
|
entry3.count++;
|
|
282817
283368
|
return false;
|
|
282818
283369
|
}
|
|
282819
|
-
if (!entry3 &&
|
|
282820
|
-
|
|
283370
|
+
if (!entry3 && ipWindows7.size >= MAX_TRACKED_IPS) return true;
|
|
283371
|
+
ipWindows7.set(ip, { count: 1, windowStart: now });
|
|
282821
283372
|
return false;
|
|
282822
283373
|
}
|
|
282823
283374
|
function confidentialCimdPublicOrigin(c) {
|
|
@@ -283254,7 +283805,10 @@ async function postServiceRoute2(path8, body) {
|
|
|
283254
283805
|
);
|
|
283255
283806
|
}
|
|
283256
283807
|
const controller = new AbortController();
|
|
283257
|
-
const timeout = setTimeout(
|
|
283808
|
+
const timeout = setTimeout(
|
|
283809
|
+
() => controller.abort(),
|
|
283810
|
+
SERVICE_ROUTE_TIMEOUT_MS2
|
|
283811
|
+
);
|
|
283258
283812
|
let response;
|
|
283259
283813
|
try {
|
|
283260
283814
|
response = await fetch(`${env.convexUrl}${path8}`, {
|
|
@@ -283342,7 +283896,12 @@ async function executeClaimedRun(claimed) {
|
|
|
283342
283896
|
serverNames: environmentServerNames(resolved),
|
|
283343
283897
|
resolvedEnvironment: resolved
|
|
283344
283898
|
};
|
|
283345
|
-
})() : await fetchSuiteRunServerSelection(
|
|
283899
|
+
})() : await fetchSuiteRunServerSelection(
|
|
283900
|
+
bearer,
|
|
283901
|
+
claimed.suiteId,
|
|
283902
|
+
void 0,
|
|
283903
|
+
"authorized"
|
|
283904
|
+
);
|
|
283346
283905
|
const authorized = await createAuthorizedManager(
|
|
283347
283906
|
{},
|
|
283348
283907
|
bearer,
|