@riddledc/riddle-proof 0.7.10 → 0.7.11

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.
@@ -193,16 +193,16 @@ function normalizeRiddleProofProfile(input, options = {}) {
193
193
  function resolveRiddleProofProfileTargetUrl(profile) {
194
194
  const route = profile.target.route || "";
195
195
  const targetUrl = profile.target.url || "";
196
+ if (targetUrl && route) return resolveRiddleProofProfileRouteUrl(targetUrl, route);
196
197
  if (/^https?:\/\//i.test(route)) return route;
197
- if (targetUrl && route) return new URL(route, targetUrl).href;
198
198
  if (targetUrl) return targetUrl;
199
199
  throw new Error("profile target URL could not be resolved.");
200
200
  }
201
- function routeForViewport(viewport) {
201
+ function routeForViewport(viewport, targetUrl) {
202
202
  if (viewport?.route) {
203
203
  return {
204
204
  ...viewport.route,
205
- matched: viewport.route.matched || routePathMatches(viewport.route.observed, viewport.route.expected_path)
205
+ matched: viewport.route.matched || routePathMatches(viewport.route.observed, viewport.route.expected_path, targetUrl)
206
206
  };
207
207
  }
208
208
  return {
@@ -236,11 +236,48 @@ function normalizeRoutePath(path) {
236
236
  if (value === "/") return "/";
237
237
  return value.replace(/\/+$/, "") || "/";
238
238
  }
239
- function routePathMatches(observed, expected) {
240
- return normalizeRoutePath(observed) === normalizeRoutePath(expected);
239
+ function previewMountPrefix(pathname) {
240
+ const value = pathname || "/";
241
+ const apiPreview = value.match(/^(\/s\/[^/]+)(?:\/|$)/);
242
+ if (apiPreview) return apiPreview[1];
243
+ const internalPreview = value.match(/^(\/preview\/[^/]+\/[^/]+)(?:\/|$)/);
244
+ return internalPreview ? internalPreview[1] : "";
241
245
  }
242
- function successfulRoute(route) {
243
- const matched = route.matched || routePathMatches(route.observed, route.expected_path);
246
+ function joinMountedRoutePath(mountPrefix, routePath) {
247
+ const route = routePath.startsWith("/") ? routePath : `/${routePath}`;
248
+ if (!mountPrefix) return route;
249
+ if (route === mountPrefix || route.startsWith(`${mountPrefix}/`)) return route;
250
+ return `${mountPrefix}${route}`;
251
+ }
252
+ function resolveRiddleProofProfileRouteUrl(targetUrl, route) {
253
+ if (/^https?:\/\//i.test(route)) return route;
254
+ if (!targetUrl) return route;
255
+ if (route.startsWith("/")) {
256
+ const base = new URL(targetUrl);
257
+ const mountPrefix = previewMountPrefix(base.pathname);
258
+ if (mountPrefix) {
259
+ const routeParts = new URL(route, base.origin);
260
+ base.pathname = joinMountedRoutePath(mountPrefix, routeParts.pathname);
261
+ base.search = routeParts.search;
262
+ base.hash = routeParts.hash;
263
+ return base.href;
264
+ }
265
+ }
266
+ return new URL(route, targetUrl).href;
267
+ }
268
+ function mountedExpectedRoutePath(targetUrl, expected) {
269
+ if (!targetUrl || !expected || !expected.startsWith("/")) return expected;
270
+ const mountPrefix = previewMountPrefix(new URL(targetUrl).pathname);
271
+ return mountPrefix ? joinMountedRoutePath(mountPrefix, expected) : expected;
272
+ }
273
+ function routePathMatches(observed, expected, targetUrl) {
274
+ const normalizedObserved = normalizeRoutePath(observed);
275
+ const normalizedExpected = normalizeRoutePath(expected);
276
+ if (normalizedObserved === normalizedExpected) return true;
277
+ return normalizedObserved === normalizeRoutePath(mountedExpectedRoutePath(targetUrl, expected));
278
+ }
279
+ function successfulRoute(route, targetUrl) {
280
+ const matched = route.matched || routePathMatches(route.observed, route.expected_path, targetUrl);
244
281
  return matched && !route.error && (route.http_status === null || route.http_status === void 0 || route.http_status < 400);
245
282
  }
246
283
  function assessCheckFromEvidence(check, evidence) {
@@ -259,8 +296,8 @@ function assessCheckFromEvidence(check, evidence) {
259
296
  const failed = viewports.filter((viewport) => !successfulRoute({
260
297
  ...viewport.route,
261
298
  expected_path: expectedPath,
262
- matched: routePathMatches(viewport.route.observed, expectedPath) || viewport.route.matched
263
- }));
299
+ matched: routePathMatches(viewport.route.observed, expectedPath, evidence.target_url) || viewport.route.matched
300
+ }, evidence.target_url));
264
301
  return {
265
302
  type: check.type,
266
303
  label: checkLabel(check),
@@ -435,7 +472,7 @@ function assessRiddleProofProfileEvidence(profile, evidence, options = {}) {
435
472
  runner: options.runner || "riddle",
436
473
  status,
437
474
  baseline_policy: profile.baseline_policy,
438
- route: routeForViewport(firstViewport),
475
+ route: routeForViewport(firstViewport, evidence?.target_url),
439
476
  artifacts: {
440
477
  screenshots,
441
478
  console: "console.json",
@@ -532,11 +569,32 @@ function normalizeRoutePath(path) {
532
569
  if (value === "/") return "/";
533
570
  return value.replace(/\/+$/, "") || "/";
534
571
  }
535
- function routePathMatches(observed, expected) {
536
- return normalizeRoutePath(observed) === normalizeRoutePath(expected);
572
+ function previewMountPrefix(pathname) {
573
+ const value = pathname || "/";
574
+ const apiPreview = value.match(/^(\/s\/[^/]+)(?:\/|$)/);
575
+ if (apiPreview) return apiPreview[1];
576
+ const internalPreview = value.match(/^(\/preview\/[^/]+\/[^/]+)(?:\/|$)/);
577
+ return internalPreview ? internalPreview[1] : "";
578
+ }
579
+ function joinMountedRoutePath(mountPrefix, routePath) {
580
+ const route = routePath.startsWith("/") ? routePath : "/" + routePath;
581
+ if (!mountPrefix) return route;
582
+ if (route === mountPrefix || route.startsWith(mountPrefix + "/")) return route;
583
+ return mountPrefix + route;
584
+ }
585
+ function mountedExpectedRoutePath(targetUrl, expected) {
586
+ if (!targetUrl || !expected || !expected.startsWith("/")) return expected;
587
+ const mountPrefix = previewMountPrefix(new URL(targetUrl).pathname);
588
+ return mountPrefix ? joinMountedRoutePath(mountPrefix, expected) : expected;
589
+ }
590
+ function routePathMatches(observed, expected, targetUrl) {
591
+ const normalizedObserved = normalizeRoutePath(observed);
592
+ const normalizedExpected = normalizeRoutePath(expected);
593
+ if (normalizedObserved === normalizedExpected) return true;
594
+ return normalizedObserved === normalizeRoutePath(mountedExpectedRoutePath(targetUrl, expected));
537
595
  }
538
- function routeOk(route) {
539
- return Boolean(route && (route.matched || routePathMatches(route.observed, route.expected_path)) && !route.error && (route.http_status == null || route.http_status < 400));
596
+ function routeOk(route, targetUrl) {
597
+ return Boolean(route && (route.matched || routePathMatches(route.observed, route.expected_path, targetUrl)) && !route.error && (route.http_status == null || route.http_status < 400));
540
598
  }
541
599
  function textMatches(sample, check) {
542
600
  if (check.pattern) {
@@ -593,8 +651,8 @@ function assessProfile(profile, evidence) {
593
651
  const expectedPath = check.expected_path || new URL(evidence.target_url).pathname || "/";
594
652
  const failed = viewports.filter((viewport) => {
595
653
  const route = { ...(viewport.route || {}), expected_path: expectedPath };
596
- route.matched = routePathMatches(route.observed, expectedPath) || route.matched;
597
- return !routeOk(route);
654
+ route.matched = routePathMatches(route.observed, expectedPath, evidence.target_url) || route.matched;
655
+ return !routeOk(route, evidence.target_url);
598
656
  });
599
657
  checks.push({
600
658
  type: check.type,
@@ -935,7 +993,7 @@ async function captureViewport(viewport) {
935
993
  requested: targetUrl,
936
994
  observed: dom.pathname,
937
995
  expected_path: expectedPath,
938
- matched: routePathMatches(dom.pathname, expectedPath),
996
+ matched: routePathMatches(dom.pathname, expectedPath, targetUrl),
939
997
  http_status: httpStatus,
940
998
  error: navigationError || waitError || undefined,
941
999
  },
@@ -1051,6 +1109,7 @@ export {
1051
1109
  slugifyRiddleProofProfileName,
1052
1110
  normalizeRiddleProofProfile,
1053
1111
  resolveRiddleProofProfileTargetUrl,
1112
+ resolveRiddleProofProfileRouteUrl,
1054
1113
  assessRiddleProofProfileEvidence,
1055
1114
  summarizeRiddleProofProfileResult,
1056
1115
  profileStatusExitCode,
package/dist/cli.cjs CHANGED
@@ -6972,16 +6972,16 @@ function normalizeRiddleProofProfile(input, options = {}) {
6972
6972
  function resolveRiddleProofProfileTargetUrl(profile) {
6973
6973
  const route = profile.target.route || "";
6974
6974
  const targetUrl = profile.target.url || "";
6975
+ if (targetUrl && route) return resolveRiddleProofProfileRouteUrl(targetUrl, route);
6975
6976
  if (/^https?:\/\//i.test(route)) return route;
6976
- if (targetUrl && route) return new URL(route, targetUrl).href;
6977
6977
  if (targetUrl) return targetUrl;
6978
6978
  throw new Error("profile target URL could not be resolved.");
6979
6979
  }
6980
- function routeForViewport(viewport) {
6980
+ function routeForViewport(viewport, targetUrl) {
6981
6981
  if (viewport?.route) {
6982
6982
  return {
6983
6983
  ...viewport.route,
6984
- matched: viewport.route.matched || routePathMatches(viewport.route.observed, viewport.route.expected_path)
6984
+ matched: viewport.route.matched || routePathMatches(viewport.route.observed, viewport.route.expected_path, targetUrl)
6985
6985
  };
6986
6986
  }
6987
6987
  return {
@@ -7015,11 +7015,48 @@ function normalizeRoutePath(path7) {
7015
7015
  if (value === "/") return "/";
7016
7016
  return value.replace(/\/+$/, "") || "/";
7017
7017
  }
7018
- function routePathMatches(observed, expected) {
7019
- return normalizeRoutePath(observed) === normalizeRoutePath(expected);
7018
+ function previewMountPrefix(pathname) {
7019
+ const value = pathname || "/";
7020
+ const apiPreview = value.match(/^(\/s\/[^/]+)(?:\/|$)/);
7021
+ if (apiPreview) return apiPreview[1];
7022
+ const internalPreview = value.match(/^(\/preview\/[^/]+\/[^/]+)(?:\/|$)/);
7023
+ return internalPreview ? internalPreview[1] : "";
7020
7024
  }
7021
- function successfulRoute(route) {
7022
- const matched = route.matched || routePathMatches(route.observed, route.expected_path);
7025
+ function joinMountedRoutePath(mountPrefix, routePath) {
7026
+ const route = routePath.startsWith("/") ? routePath : `/${routePath}`;
7027
+ if (!mountPrefix) return route;
7028
+ if (route === mountPrefix || route.startsWith(`${mountPrefix}/`)) return route;
7029
+ return `${mountPrefix}${route}`;
7030
+ }
7031
+ function resolveRiddleProofProfileRouteUrl(targetUrl, route) {
7032
+ if (/^https?:\/\//i.test(route)) return route;
7033
+ if (!targetUrl) return route;
7034
+ if (route.startsWith("/")) {
7035
+ const base = new URL(targetUrl);
7036
+ const mountPrefix = previewMountPrefix(base.pathname);
7037
+ if (mountPrefix) {
7038
+ const routeParts = new URL(route, base.origin);
7039
+ base.pathname = joinMountedRoutePath(mountPrefix, routeParts.pathname);
7040
+ base.search = routeParts.search;
7041
+ base.hash = routeParts.hash;
7042
+ return base.href;
7043
+ }
7044
+ }
7045
+ return new URL(route, targetUrl).href;
7046
+ }
7047
+ function mountedExpectedRoutePath(targetUrl, expected) {
7048
+ if (!targetUrl || !expected || !expected.startsWith("/")) return expected;
7049
+ const mountPrefix = previewMountPrefix(new URL(targetUrl).pathname);
7050
+ return mountPrefix ? joinMountedRoutePath(mountPrefix, expected) : expected;
7051
+ }
7052
+ function routePathMatches(observed, expected, targetUrl) {
7053
+ const normalizedObserved = normalizeRoutePath(observed);
7054
+ const normalizedExpected = normalizeRoutePath(expected);
7055
+ if (normalizedObserved === normalizedExpected) return true;
7056
+ return normalizedObserved === normalizeRoutePath(mountedExpectedRoutePath(targetUrl, expected));
7057
+ }
7058
+ function successfulRoute(route, targetUrl) {
7059
+ const matched = route.matched || routePathMatches(route.observed, route.expected_path, targetUrl);
7023
7060
  return matched && !route.error && (route.http_status === null || route.http_status === void 0 || route.http_status < 400);
7024
7061
  }
7025
7062
  function assessCheckFromEvidence(check, evidence) {
@@ -7038,8 +7075,8 @@ function assessCheckFromEvidence(check, evidence) {
7038
7075
  const failed = viewports.filter((viewport) => !successfulRoute({
7039
7076
  ...viewport.route,
7040
7077
  expected_path: expectedPath,
7041
- matched: routePathMatches(viewport.route.observed, expectedPath) || viewport.route.matched
7042
- }));
7078
+ matched: routePathMatches(viewport.route.observed, expectedPath, evidence.target_url) || viewport.route.matched
7079
+ }, evidence.target_url));
7043
7080
  return {
7044
7081
  type: check.type,
7045
7082
  label: checkLabel(check),
@@ -7214,7 +7251,7 @@ function assessRiddleProofProfileEvidence(profile, evidence, options = {}) {
7214
7251
  runner: options.runner || "riddle",
7215
7252
  status,
7216
7253
  baseline_policy: profile.baseline_policy,
7217
- route: routeForViewport(firstViewport),
7254
+ route: routeForViewport(firstViewport, evidence?.target_url),
7218
7255
  artifacts: {
7219
7256
  screenshots,
7220
7257
  console: "console.json",
@@ -7295,11 +7332,32 @@ function normalizeRoutePath(path) {
7295
7332
  if (value === "/") return "/";
7296
7333
  return value.replace(/\/+$/, "") || "/";
7297
7334
  }
7298
- function routePathMatches(observed, expected) {
7299
- return normalizeRoutePath(observed) === normalizeRoutePath(expected);
7300
- }
7301
- function routeOk(route) {
7302
- return Boolean(route && (route.matched || routePathMatches(route.observed, route.expected_path)) && !route.error && (route.http_status == null || route.http_status < 400));
7335
+ function previewMountPrefix(pathname) {
7336
+ const value = pathname || "/";
7337
+ const apiPreview = value.match(/^(\/s\/[^/]+)(?:\/|$)/);
7338
+ if (apiPreview) return apiPreview[1];
7339
+ const internalPreview = value.match(/^(\/preview\/[^/]+\/[^/]+)(?:\/|$)/);
7340
+ return internalPreview ? internalPreview[1] : "";
7341
+ }
7342
+ function joinMountedRoutePath(mountPrefix, routePath) {
7343
+ const route = routePath.startsWith("/") ? routePath : "/" + routePath;
7344
+ if (!mountPrefix) return route;
7345
+ if (route === mountPrefix || route.startsWith(mountPrefix + "/")) return route;
7346
+ return mountPrefix + route;
7347
+ }
7348
+ function mountedExpectedRoutePath(targetUrl, expected) {
7349
+ if (!targetUrl || !expected || !expected.startsWith("/")) return expected;
7350
+ const mountPrefix = previewMountPrefix(new URL(targetUrl).pathname);
7351
+ return mountPrefix ? joinMountedRoutePath(mountPrefix, expected) : expected;
7352
+ }
7353
+ function routePathMatches(observed, expected, targetUrl) {
7354
+ const normalizedObserved = normalizeRoutePath(observed);
7355
+ const normalizedExpected = normalizeRoutePath(expected);
7356
+ if (normalizedObserved === normalizedExpected) return true;
7357
+ return normalizedObserved === normalizeRoutePath(mountedExpectedRoutePath(targetUrl, expected));
7358
+ }
7359
+ function routeOk(route, targetUrl) {
7360
+ return Boolean(route && (route.matched || routePathMatches(route.observed, route.expected_path, targetUrl)) && !route.error && (route.http_status == null || route.http_status < 400));
7303
7361
  }
7304
7362
  function textMatches(sample, check) {
7305
7363
  if (check.pattern) {
@@ -7356,8 +7414,8 @@ function assessProfile(profile, evidence) {
7356
7414
  const expectedPath = check.expected_path || new URL(evidence.target_url).pathname || "/";
7357
7415
  const failed = viewports.filter((viewport) => {
7358
7416
  const route = { ...(viewport.route || {}), expected_path: expectedPath };
7359
- route.matched = routePathMatches(route.observed, expectedPath) || route.matched;
7360
- return !routeOk(route);
7417
+ route.matched = routePathMatches(route.observed, expectedPath, evidence.target_url) || route.matched;
7418
+ return !routeOk(route, evidence.target_url);
7361
7419
  });
7362
7420
  checks.push({
7363
7421
  type: check.type,
@@ -7698,7 +7756,7 @@ async function captureViewport(viewport) {
7698
7756
  requested: targetUrl,
7699
7757
  observed: dom.pathname,
7700
7758
  expected_path: expectedPath,
7701
- matched: routePathMatches(dom.pathname, expectedPath),
7759
+ matched: routePathMatches(dom.pathname, expectedPath, targetUrl),
7702
7760
  http_status: httpStatus,
7703
7761
  error: navigationError || waitError || undefined,
7704
7762
  },
package/dist/cli.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  normalizeRiddleProofProfile,
10
10
  profileStatusExitCode,
11
11
  resolveRiddleProofProfileTargetUrl
12
- } from "./chunk-A7RJZD4I.js";
12
+ } from "./chunk-PZYQGRQ5.js";
13
13
  import {
14
14
  createRiddleApiClient,
15
15
  parseRiddleViewport
package/dist/index.cjs CHANGED
@@ -2994,6 +2994,7 @@ __export(index_exports, {
2994
2994
  redactForProofDiagnostics: () => redactForProofDiagnostics,
2995
2995
  resolveBasicGameplayProgressionCheckWithArtifactScreenshots: () => resolveBasicGameplayProgressionCheckWithArtifactScreenshots,
2996
2996
  resolveRiddleApiKey: () => resolveRiddleApiKey,
2997
+ resolveRiddleProofProfileRouteUrl: () => resolveRiddleProofProfileRouteUrl,
2997
2998
  resolveRiddleProofProfileTargetUrl: () => resolveRiddleProofProfileTargetUrl,
2998
2999
  riddleRequestJson: () => riddleRequestJson,
2999
3000
  runCodexExecAgentDoctor: () => runCodexExecAgentDoctor,
@@ -8699,16 +8700,16 @@ function normalizeRiddleProofProfile(input, options = {}) {
8699
8700
  function resolveRiddleProofProfileTargetUrl(profile) {
8700
8701
  const route = profile.target.route || "";
8701
8702
  const targetUrl = profile.target.url || "";
8703
+ if (targetUrl && route) return resolveRiddleProofProfileRouteUrl(targetUrl, route);
8702
8704
  if (/^https?:\/\//i.test(route)) return route;
8703
- if (targetUrl && route) return new URL(route, targetUrl).href;
8704
8705
  if (targetUrl) return targetUrl;
8705
8706
  throw new Error("profile target URL could not be resolved.");
8706
8707
  }
8707
- function routeForViewport(viewport) {
8708
+ function routeForViewport(viewport, targetUrl) {
8708
8709
  if (viewport?.route) {
8709
8710
  return {
8710
8711
  ...viewport.route,
8711
- matched: viewport.route.matched || routePathMatches(viewport.route.observed, viewport.route.expected_path)
8712
+ matched: viewport.route.matched || routePathMatches(viewport.route.observed, viewport.route.expected_path, targetUrl)
8712
8713
  };
8713
8714
  }
8714
8715
  return {
@@ -8742,11 +8743,48 @@ function normalizeRoutePath(path6) {
8742
8743
  if (value === "/") return "/";
8743
8744
  return value.replace(/\/+$/, "") || "/";
8744
8745
  }
8745
- function routePathMatches(observed, expected) {
8746
- return normalizeRoutePath(observed) === normalizeRoutePath(expected);
8746
+ function previewMountPrefix(pathname) {
8747
+ const value = pathname || "/";
8748
+ const apiPreview = value.match(/^(\/s\/[^/]+)(?:\/|$)/);
8749
+ if (apiPreview) return apiPreview[1];
8750
+ const internalPreview = value.match(/^(\/preview\/[^/]+\/[^/]+)(?:\/|$)/);
8751
+ return internalPreview ? internalPreview[1] : "";
8747
8752
  }
8748
- function successfulRoute(route) {
8749
- const matched = route.matched || routePathMatches(route.observed, route.expected_path);
8753
+ function joinMountedRoutePath(mountPrefix, routePath) {
8754
+ const route = routePath.startsWith("/") ? routePath : `/${routePath}`;
8755
+ if (!mountPrefix) return route;
8756
+ if (route === mountPrefix || route.startsWith(`${mountPrefix}/`)) return route;
8757
+ return `${mountPrefix}${route}`;
8758
+ }
8759
+ function resolveRiddleProofProfileRouteUrl(targetUrl, route) {
8760
+ if (/^https?:\/\//i.test(route)) return route;
8761
+ if (!targetUrl) return route;
8762
+ if (route.startsWith("/")) {
8763
+ const base = new URL(targetUrl);
8764
+ const mountPrefix = previewMountPrefix(base.pathname);
8765
+ if (mountPrefix) {
8766
+ const routeParts = new URL(route, base.origin);
8767
+ base.pathname = joinMountedRoutePath(mountPrefix, routeParts.pathname);
8768
+ base.search = routeParts.search;
8769
+ base.hash = routeParts.hash;
8770
+ return base.href;
8771
+ }
8772
+ }
8773
+ return new URL(route, targetUrl).href;
8774
+ }
8775
+ function mountedExpectedRoutePath(targetUrl, expected) {
8776
+ if (!targetUrl || !expected || !expected.startsWith("/")) return expected;
8777
+ const mountPrefix = previewMountPrefix(new URL(targetUrl).pathname);
8778
+ return mountPrefix ? joinMountedRoutePath(mountPrefix, expected) : expected;
8779
+ }
8780
+ function routePathMatches(observed, expected, targetUrl) {
8781
+ const normalizedObserved = normalizeRoutePath(observed);
8782
+ const normalizedExpected = normalizeRoutePath(expected);
8783
+ if (normalizedObserved === normalizedExpected) return true;
8784
+ return normalizedObserved === normalizeRoutePath(mountedExpectedRoutePath(targetUrl, expected));
8785
+ }
8786
+ function successfulRoute(route, targetUrl) {
8787
+ const matched = route.matched || routePathMatches(route.observed, route.expected_path, targetUrl);
8750
8788
  return matched && !route.error && (route.http_status === null || route.http_status === void 0 || route.http_status < 400);
8751
8789
  }
8752
8790
  function assessCheckFromEvidence(check, evidence) {
@@ -8765,8 +8803,8 @@ function assessCheckFromEvidence(check, evidence) {
8765
8803
  const failed = viewports.filter((viewport) => !successfulRoute({
8766
8804
  ...viewport.route,
8767
8805
  expected_path: expectedPath,
8768
- matched: routePathMatches(viewport.route.observed, expectedPath) || viewport.route.matched
8769
- }));
8806
+ matched: routePathMatches(viewport.route.observed, expectedPath, evidence.target_url) || viewport.route.matched
8807
+ }, evidence.target_url));
8770
8808
  return {
8771
8809
  type: check.type,
8772
8810
  label: checkLabel(check),
@@ -8941,7 +8979,7 @@ function assessRiddleProofProfileEvidence(profile, evidence, options = {}) {
8941
8979
  runner: options.runner || "riddle",
8942
8980
  status,
8943
8981
  baseline_policy: profile.baseline_policy,
8944
- route: routeForViewport(firstViewport),
8982
+ route: routeForViewport(firstViewport, evidence?.target_url),
8945
8983
  artifacts: {
8946
8984
  screenshots,
8947
8985
  console: "console.json",
@@ -9038,11 +9076,32 @@ function normalizeRoutePath(path) {
9038
9076
  if (value === "/") return "/";
9039
9077
  return value.replace(/\/+$/, "") || "/";
9040
9078
  }
9041
- function routePathMatches(observed, expected) {
9042
- return normalizeRoutePath(observed) === normalizeRoutePath(expected);
9043
- }
9044
- function routeOk(route) {
9045
- return Boolean(route && (route.matched || routePathMatches(route.observed, route.expected_path)) && !route.error && (route.http_status == null || route.http_status < 400));
9079
+ function previewMountPrefix(pathname) {
9080
+ const value = pathname || "/";
9081
+ const apiPreview = value.match(/^(\/s\/[^/]+)(?:\/|$)/);
9082
+ if (apiPreview) return apiPreview[1];
9083
+ const internalPreview = value.match(/^(\/preview\/[^/]+\/[^/]+)(?:\/|$)/);
9084
+ return internalPreview ? internalPreview[1] : "";
9085
+ }
9086
+ function joinMountedRoutePath(mountPrefix, routePath) {
9087
+ const route = routePath.startsWith("/") ? routePath : "/" + routePath;
9088
+ if (!mountPrefix) return route;
9089
+ if (route === mountPrefix || route.startsWith(mountPrefix + "/")) return route;
9090
+ return mountPrefix + route;
9091
+ }
9092
+ function mountedExpectedRoutePath(targetUrl, expected) {
9093
+ if (!targetUrl || !expected || !expected.startsWith("/")) return expected;
9094
+ const mountPrefix = previewMountPrefix(new URL(targetUrl).pathname);
9095
+ return mountPrefix ? joinMountedRoutePath(mountPrefix, expected) : expected;
9096
+ }
9097
+ function routePathMatches(observed, expected, targetUrl) {
9098
+ const normalizedObserved = normalizeRoutePath(observed);
9099
+ const normalizedExpected = normalizeRoutePath(expected);
9100
+ if (normalizedObserved === normalizedExpected) return true;
9101
+ return normalizedObserved === normalizeRoutePath(mountedExpectedRoutePath(targetUrl, expected));
9102
+ }
9103
+ function routeOk(route, targetUrl) {
9104
+ return Boolean(route && (route.matched || routePathMatches(route.observed, route.expected_path, targetUrl)) && !route.error && (route.http_status == null || route.http_status < 400));
9046
9105
  }
9047
9106
  function textMatches(sample, check) {
9048
9107
  if (check.pattern) {
@@ -9099,8 +9158,8 @@ function assessProfile(profile, evidence) {
9099
9158
  const expectedPath = check.expected_path || new URL(evidence.target_url).pathname || "/";
9100
9159
  const failed = viewports.filter((viewport) => {
9101
9160
  const route = { ...(viewport.route || {}), expected_path: expectedPath };
9102
- route.matched = routePathMatches(route.observed, expectedPath) || route.matched;
9103
- return !routeOk(route);
9161
+ route.matched = routePathMatches(route.observed, expectedPath, evidence.target_url) || route.matched;
9162
+ return !routeOk(route, evidence.target_url);
9104
9163
  });
9105
9164
  checks.push({
9106
9165
  type: check.type,
@@ -9441,7 +9500,7 @@ async function captureViewport(viewport) {
9441
9500
  requested: targetUrl,
9442
9501
  observed: dom.pathname,
9443
9502
  expected_path: expectedPath,
9444
- matched: routePathMatches(dom.pathname, expectedPath),
9503
+ matched: routePathMatches(dom.pathname, expectedPath, targetUrl),
9445
9504
  http_status: httpStatus,
9446
9505
  error: navigationError || waitError || undefined,
9447
9506
  },
@@ -9876,6 +9935,7 @@ function createRiddleApiClient(config = {}) {
9876
9935
  redactForProofDiagnostics,
9877
9936
  resolveBasicGameplayProgressionCheckWithArtifactScreenshots,
9878
9937
  resolveRiddleApiKey,
9938
+ resolveRiddleProofProfileRouteUrl,
9879
9939
  resolveRiddleProofProfileTargetUrl,
9880
9940
  riddleRequestJson,
9881
9941
  runCodexExecAgentDoctor,
package/dist/index.d.cts CHANGED
@@ -10,5 +10,5 @@ export { CreateCaptureDiagnosticInput, DEFAULT_DIAGNOSTIC_ARRAY_LIMIT, DEFAULT_D
10
10
  export { BuildVisualProofSessionInput, RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION, RIDDLE_PROOF_VISUAL_SESSION_VERSION, VisualProofSessionMismatch, buildVisualProofSession, compareVisualProofSessionFingerprint, parseVisualProofSession, visualSessionFingerprint, visualSessionFingerprintBasis } from './proof-session.cjs';
11
11
  export { AssessPlayabilityOptions, RIDDLE_PROOF_PLAYABILITY_ASSESSMENT_VERSION, RIDDLE_PROOF_PLAYABILITY_VERSION, RiddleProofPlayabilityAssessment, RiddleProofPlayabilityEvidence, assessPlayabilityEvidence, extractPlayabilityEvidence, isRiddleProofPlayabilityMode } from './playability.cjs';
12
12
  export { AssessBasicGameplayOptions, AttachBasicGameplayArtifactOptions, BASIC_GAMEPLAY_ACTION_TYPES, BASIC_GAMEPLAY_PROGRESS_CHECK_TYPES, BasicGameplayActionResult, BasicGameplayActionType, BasicGameplayArtifactResolution, BasicGameplayAssessmentSummary, BasicGameplayCanvasState, BasicGameplayCatchRecord, BasicGameplayChangeSummary, BasicGameplayFailureCode, BasicGameplayFixReference, BasicGameplayMetric, BasicGameplayMobileEvidence, BasicGameplayProgressCheckType, BasicGameplayProgressionCheck, BasicGameplayProofArtifact, BasicGameplayRouteReference, BasicGameplaySnapshot, BasicGameplaySuiteFailure, BasicGameplayWarningCode, CreateBasicGameplayCatchSummaryInput, RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION, RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION, RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION, RiddleProofBasicGameplayAssessment, RiddleProofBasicGameplayCatchSummary, RiddleProofBasicGameplayEvidence, RiddleProofBasicGameplayRouteAssessment, RiddleProofBasicGameplayRouteEvidence, assessBasicGameplayEvidence, assessBasicGameplayProgressionCheck, assessBasicGameplayProgressionChecks, assessBasicGameplayRoute, attachBasicGameplayArtifactScreenshotHashes, augmentBasicGameplayAssessmentWithProgressionChecks, compactBasicGameplayText, createBasicGameplayCatchRecords, createBasicGameplayCatchSummary, extractBasicGameplayEvidence, resolveBasicGameplayProgressionCheckWithArtifactScreenshots, sanitizeBasicGameplayJsonString } from './basic-gameplay.cjs';
13
- export { NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, RiddleProofProfile, RiddleProofProfileArtifactRef, RiddleProofProfileBaselinePolicy, RiddleProofProfileCheck, RiddleProofProfileCheckResult, RiddleProofProfileCheckType, RiddleProofProfileEvidence, RiddleProofProfileFailureAction, RiddleProofProfileResult, RiddleProofProfileRouteEvidence, RiddleProofProfileRunner, RiddleProofProfileSetupAction, RiddleProofProfileSetupActionType, RiddleProofProfileStatus, RiddleProofProfileTarget, RiddleProofProfileViewport, RiddleProofProfileViewportEvidence, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, extractRiddleProofProfileResult, normalizeRiddleProofProfile, profileStatusExitCode, resolveRiddleProofProfileTargetUrl, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult } from './profile.cjs';
13
+ export { NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, RiddleProofProfile, RiddleProofProfileArtifactRef, RiddleProofProfileBaselinePolicy, RiddleProofProfileCheck, RiddleProofProfileCheckResult, RiddleProofProfileCheckType, RiddleProofProfileEvidence, RiddleProofProfileFailureAction, RiddleProofProfileResult, RiddleProofProfileRouteEvidence, RiddleProofProfileRunner, RiddleProofProfileSetupAction, RiddleProofProfileSetupActionType, RiddleProofProfileStatus, RiddleProofProfileTarget, RiddleProofProfileViewport, RiddleProofProfileViewportEvidence, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, extractRiddleProofProfileResult, normalizeRiddleProofProfile, profileStatusExitCode, resolveRiddleProofProfileRouteUrl, resolveRiddleProofProfileTargetUrl, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult } from './profile.cjs';
14
14
  export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, RiddleClientConfig, RiddleFetch, RiddlePollJobResult, RiddlePreviewDeployResult, RiddleRunScriptInput, RiddleServerPreviewInput, RiddleServerPreviewResult, createRiddleApiClient, deployRiddleStaticPreview, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, riddleRequestJson, runRiddleScript, runRiddleServerPreview } from './riddle-client.cjs';
package/dist/index.d.ts CHANGED
@@ -10,5 +10,5 @@ export { CreateCaptureDiagnosticInput, DEFAULT_DIAGNOSTIC_ARRAY_LIMIT, DEFAULT_D
10
10
  export { BuildVisualProofSessionInput, RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION, RIDDLE_PROOF_VISUAL_SESSION_VERSION, VisualProofSessionMismatch, buildVisualProofSession, compareVisualProofSessionFingerprint, parseVisualProofSession, visualSessionFingerprint, visualSessionFingerprintBasis } from './proof-session.js';
11
11
  export { AssessPlayabilityOptions, RIDDLE_PROOF_PLAYABILITY_ASSESSMENT_VERSION, RIDDLE_PROOF_PLAYABILITY_VERSION, RiddleProofPlayabilityAssessment, RiddleProofPlayabilityEvidence, assessPlayabilityEvidence, extractPlayabilityEvidence, isRiddleProofPlayabilityMode } from './playability.js';
12
12
  export { AssessBasicGameplayOptions, AttachBasicGameplayArtifactOptions, BASIC_GAMEPLAY_ACTION_TYPES, BASIC_GAMEPLAY_PROGRESS_CHECK_TYPES, BasicGameplayActionResult, BasicGameplayActionType, BasicGameplayArtifactResolution, BasicGameplayAssessmentSummary, BasicGameplayCanvasState, BasicGameplayCatchRecord, BasicGameplayChangeSummary, BasicGameplayFailureCode, BasicGameplayFixReference, BasicGameplayMetric, BasicGameplayMobileEvidence, BasicGameplayProgressCheckType, BasicGameplayProgressionCheck, BasicGameplayProofArtifact, BasicGameplayRouteReference, BasicGameplaySnapshot, BasicGameplaySuiteFailure, BasicGameplayWarningCode, CreateBasicGameplayCatchSummaryInput, RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION, RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION, RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION, RiddleProofBasicGameplayAssessment, RiddleProofBasicGameplayCatchSummary, RiddleProofBasicGameplayEvidence, RiddleProofBasicGameplayRouteAssessment, RiddleProofBasicGameplayRouteEvidence, assessBasicGameplayEvidence, assessBasicGameplayProgressionCheck, assessBasicGameplayProgressionChecks, assessBasicGameplayRoute, attachBasicGameplayArtifactScreenshotHashes, augmentBasicGameplayAssessmentWithProgressionChecks, compactBasicGameplayText, createBasicGameplayCatchRecords, createBasicGameplayCatchSummary, extractBasicGameplayEvidence, resolveBasicGameplayProgressionCheckWithArtifactScreenshots, sanitizeBasicGameplayJsonString } from './basic-gameplay.js';
13
- export { NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, RiddleProofProfile, RiddleProofProfileArtifactRef, RiddleProofProfileBaselinePolicy, RiddleProofProfileCheck, RiddleProofProfileCheckResult, RiddleProofProfileCheckType, RiddleProofProfileEvidence, RiddleProofProfileFailureAction, RiddleProofProfileResult, RiddleProofProfileRouteEvidence, RiddleProofProfileRunner, RiddleProofProfileSetupAction, RiddleProofProfileSetupActionType, RiddleProofProfileStatus, RiddleProofProfileTarget, RiddleProofProfileViewport, RiddleProofProfileViewportEvidence, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, extractRiddleProofProfileResult, normalizeRiddleProofProfile, profileStatusExitCode, resolveRiddleProofProfileTargetUrl, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult } from './profile.js';
13
+ export { NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, RiddleProofProfile, RiddleProofProfileArtifactRef, RiddleProofProfileBaselinePolicy, RiddleProofProfileCheck, RiddleProofProfileCheckResult, RiddleProofProfileCheckType, RiddleProofProfileEvidence, RiddleProofProfileFailureAction, RiddleProofProfileResult, RiddleProofProfileRouteEvidence, RiddleProofProfileRunner, RiddleProofProfileSetupAction, RiddleProofProfileSetupActionType, RiddleProofProfileStatus, RiddleProofProfileTarget, RiddleProofProfileViewport, RiddleProofProfileViewportEvidence, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, extractRiddleProofProfileResult, normalizeRiddleProofProfile, profileStatusExitCode, resolveRiddleProofProfileRouteUrl, resolveRiddleProofProfileTargetUrl, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult } from './profile.js';
14
14
  export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, RiddleClientConfig, RiddleFetch, RiddlePollJobResult, RiddlePreviewDeployResult, RiddleRunScriptInput, RiddleServerPreviewInput, RiddleServerPreviewResult, createRiddleApiClient, deployRiddleStaticPreview, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, riddleRequestJson, runRiddleScript, runRiddleServerPreview } from './riddle-client.js';
package/dist/index.js CHANGED
@@ -53,10 +53,11 @@ import {
53
53
  extractRiddleProofProfileResult,
54
54
  normalizeRiddleProofProfile,
55
55
  profileStatusExitCode,
56
+ resolveRiddleProofProfileRouteUrl,
56
57
  resolveRiddleProofProfileTargetUrl,
57
58
  slugifyRiddleProofProfileName,
58
59
  summarizeRiddleProofProfileResult
59
- } from "./chunk-A7RJZD4I.js";
60
+ } from "./chunk-PZYQGRQ5.js";
60
61
  import {
61
62
  DEFAULT_RIDDLE_API_BASE_URL,
62
63
  DEFAULT_RIDDLE_API_KEY_FILE,
@@ -231,6 +232,7 @@ export {
231
232
  redactForProofDiagnostics,
232
233
  resolveBasicGameplayProgressionCheckWithArtifactScreenshots,
233
234
  resolveRiddleApiKey,
235
+ resolveRiddleProofProfileRouteUrl,
234
236
  resolveRiddleProofProfileTargetUrl,
235
237
  riddleRequestJson,
236
238
  runCodexExecAgentDoctor,
package/dist/profile.cjs CHANGED
@@ -35,6 +35,7 @@ __export(profile_exports, {
35
35
  extractRiddleProofProfileResult: () => extractRiddleProofProfileResult,
36
36
  normalizeRiddleProofProfile: () => normalizeRiddleProofProfile,
37
37
  profileStatusExitCode: () => profileStatusExitCode,
38
+ resolveRiddleProofProfileRouteUrl: () => resolveRiddleProofProfileRouteUrl,
38
39
  resolveRiddleProofProfileTargetUrl: () => resolveRiddleProofProfileTargetUrl,
39
40
  slugifyRiddleProofProfileName: () => slugifyRiddleProofProfileName,
40
41
  summarizeRiddleProofProfileResult: () => summarizeRiddleProofProfileResult
@@ -234,16 +235,16 @@ function normalizeRiddleProofProfile(input, options = {}) {
234
235
  function resolveRiddleProofProfileTargetUrl(profile) {
235
236
  const route = profile.target.route || "";
236
237
  const targetUrl = profile.target.url || "";
238
+ if (targetUrl && route) return resolveRiddleProofProfileRouteUrl(targetUrl, route);
237
239
  if (/^https?:\/\//i.test(route)) return route;
238
- if (targetUrl && route) return new URL(route, targetUrl).href;
239
240
  if (targetUrl) return targetUrl;
240
241
  throw new Error("profile target URL could not be resolved.");
241
242
  }
242
- function routeForViewport(viewport) {
243
+ function routeForViewport(viewport, targetUrl) {
243
244
  if (viewport?.route) {
244
245
  return {
245
246
  ...viewport.route,
246
- matched: viewport.route.matched || routePathMatches(viewport.route.observed, viewport.route.expected_path)
247
+ matched: viewport.route.matched || routePathMatches(viewport.route.observed, viewport.route.expected_path, targetUrl)
247
248
  };
248
249
  }
249
250
  return {
@@ -277,11 +278,48 @@ function normalizeRoutePath(path) {
277
278
  if (value === "/") return "/";
278
279
  return value.replace(/\/+$/, "") || "/";
279
280
  }
280
- function routePathMatches(observed, expected) {
281
- return normalizeRoutePath(observed) === normalizeRoutePath(expected);
281
+ function previewMountPrefix(pathname) {
282
+ const value = pathname || "/";
283
+ const apiPreview = value.match(/^(\/s\/[^/]+)(?:\/|$)/);
284
+ if (apiPreview) return apiPreview[1];
285
+ const internalPreview = value.match(/^(\/preview\/[^/]+\/[^/]+)(?:\/|$)/);
286
+ return internalPreview ? internalPreview[1] : "";
282
287
  }
283
- function successfulRoute(route) {
284
- const matched = route.matched || routePathMatches(route.observed, route.expected_path);
288
+ function joinMountedRoutePath(mountPrefix, routePath) {
289
+ const route = routePath.startsWith("/") ? routePath : `/${routePath}`;
290
+ if (!mountPrefix) return route;
291
+ if (route === mountPrefix || route.startsWith(`${mountPrefix}/`)) return route;
292
+ return `${mountPrefix}${route}`;
293
+ }
294
+ function resolveRiddleProofProfileRouteUrl(targetUrl, route) {
295
+ if (/^https?:\/\//i.test(route)) return route;
296
+ if (!targetUrl) return route;
297
+ if (route.startsWith("/")) {
298
+ const base = new URL(targetUrl);
299
+ const mountPrefix = previewMountPrefix(base.pathname);
300
+ if (mountPrefix) {
301
+ const routeParts = new URL(route, base.origin);
302
+ base.pathname = joinMountedRoutePath(mountPrefix, routeParts.pathname);
303
+ base.search = routeParts.search;
304
+ base.hash = routeParts.hash;
305
+ return base.href;
306
+ }
307
+ }
308
+ return new URL(route, targetUrl).href;
309
+ }
310
+ function mountedExpectedRoutePath(targetUrl, expected) {
311
+ if (!targetUrl || !expected || !expected.startsWith("/")) return expected;
312
+ const mountPrefix = previewMountPrefix(new URL(targetUrl).pathname);
313
+ return mountPrefix ? joinMountedRoutePath(mountPrefix, expected) : expected;
314
+ }
315
+ function routePathMatches(observed, expected, targetUrl) {
316
+ const normalizedObserved = normalizeRoutePath(observed);
317
+ const normalizedExpected = normalizeRoutePath(expected);
318
+ if (normalizedObserved === normalizedExpected) return true;
319
+ return normalizedObserved === normalizeRoutePath(mountedExpectedRoutePath(targetUrl, expected));
320
+ }
321
+ function successfulRoute(route, targetUrl) {
322
+ const matched = route.matched || routePathMatches(route.observed, route.expected_path, targetUrl);
285
323
  return matched && !route.error && (route.http_status === null || route.http_status === void 0 || route.http_status < 400);
286
324
  }
287
325
  function assessCheckFromEvidence(check, evidence) {
@@ -300,8 +338,8 @@ function assessCheckFromEvidence(check, evidence) {
300
338
  const failed = viewports.filter((viewport) => !successfulRoute({
301
339
  ...viewport.route,
302
340
  expected_path: expectedPath,
303
- matched: routePathMatches(viewport.route.observed, expectedPath) || viewport.route.matched
304
- }));
341
+ matched: routePathMatches(viewport.route.observed, expectedPath, evidence.target_url) || viewport.route.matched
342
+ }, evidence.target_url));
305
343
  return {
306
344
  type: check.type,
307
345
  label: checkLabel(check),
@@ -476,7 +514,7 @@ function assessRiddleProofProfileEvidence(profile, evidence, options = {}) {
476
514
  runner: options.runner || "riddle",
477
515
  status,
478
516
  baseline_policy: profile.baseline_policy,
479
- route: routeForViewport(firstViewport),
517
+ route: routeForViewport(firstViewport, evidence?.target_url),
480
518
  artifacts: {
481
519
  screenshots,
482
520
  console: "console.json",
@@ -573,11 +611,32 @@ function normalizeRoutePath(path) {
573
611
  if (value === "/") return "/";
574
612
  return value.replace(/\/+$/, "") || "/";
575
613
  }
576
- function routePathMatches(observed, expected) {
577
- return normalizeRoutePath(observed) === normalizeRoutePath(expected);
614
+ function previewMountPrefix(pathname) {
615
+ const value = pathname || "/";
616
+ const apiPreview = value.match(/^(\/s\/[^/]+)(?:\/|$)/);
617
+ if (apiPreview) return apiPreview[1];
618
+ const internalPreview = value.match(/^(\/preview\/[^/]+\/[^/]+)(?:\/|$)/);
619
+ return internalPreview ? internalPreview[1] : "";
620
+ }
621
+ function joinMountedRoutePath(mountPrefix, routePath) {
622
+ const route = routePath.startsWith("/") ? routePath : "/" + routePath;
623
+ if (!mountPrefix) return route;
624
+ if (route === mountPrefix || route.startsWith(mountPrefix + "/")) return route;
625
+ return mountPrefix + route;
626
+ }
627
+ function mountedExpectedRoutePath(targetUrl, expected) {
628
+ if (!targetUrl || !expected || !expected.startsWith("/")) return expected;
629
+ const mountPrefix = previewMountPrefix(new URL(targetUrl).pathname);
630
+ return mountPrefix ? joinMountedRoutePath(mountPrefix, expected) : expected;
631
+ }
632
+ function routePathMatches(observed, expected, targetUrl) {
633
+ const normalizedObserved = normalizeRoutePath(observed);
634
+ const normalizedExpected = normalizeRoutePath(expected);
635
+ if (normalizedObserved === normalizedExpected) return true;
636
+ return normalizedObserved === normalizeRoutePath(mountedExpectedRoutePath(targetUrl, expected));
578
637
  }
579
- function routeOk(route) {
580
- return Boolean(route && (route.matched || routePathMatches(route.observed, route.expected_path)) && !route.error && (route.http_status == null || route.http_status < 400));
638
+ function routeOk(route, targetUrl) {
639
+ return Boolean(route && (route.matched || routePathMatches(route.observed, route.expected_path, targetUrl)) && !route.error && (route.http_status == null || route.http_status < 400));
581
640
  }
582
641
  function textMatches(sample, check) {
583
642
  if (check.pattern) {
@@ -634,8 +693,8 @@ function assessProfile(profile, evidence) {
634
693
  const expectedPath = check.expected_path || new URL(evidence.target_url).pathname || "/";
635
694
  const failed = viewports.filter((viewport) => {
636
695
  const route = { ...(viewport.route || {}), expected_path: expectedPath };
637
- route.matched = routePathMatches(route.observed, expectedPath) || route.matched;
638
- return !routeOk(route);
696
+ route.matched = routePathMatches(route.observed, expectedPath, evidence.target_url) || route.matched;
697
+ return !routeOk(route, evidence.target_url);
639
698
  });
640
699
  checks.push({
641
700
  type: check.type,
@@ -976,7 +1035,7 @@ async function captureViewport(viewport) {
976
1035
  requested: targetUrl,
977
1036
  observed: dom.pathname,
978
1037
  expected_path: expectedPath,
979
- matched: routePathMatches(dom.pathname, expectedPath),
1038
+ matched: routePathMatches(dom.pathname, expectedPath, targetUrl),
980
1039
  http_status: httpStatus,
981
1040
  error: navigationError || waitError || undefined,
982
1041
  },
@@ -1098,6 +1157,7 @@ function extractRiddleProofProfileResult(input) {
1098
1157
  extractRiddleProofProfileResult,
1099
1158
  normalizeRiddleProofProfile,
1100
1159
  profileStatusExitCode,
1160
+ resolveRiddleProofProfileRouteUrl,
1101
1161
  resolveRiddleProofProfileTargetUrl,
1102
1162
  slugifyRiddleProofProfileName,
1103
1163
  summarizeRiddleProofProfileResult
@@ -157,6 +157,7 @@ interface NormalizeRiddleProofProfileOptions {
157
157
  declare function slugifyRiddleProofProfileName(value: string): string;
158
158
  declare function normalizeRiddleProofProfile(input: unknown, options?: NormalizeRiddleProofProfileOptions): RiddleProofProfile;
159
159
  declare function resolveRiddleProofProfileTargetUrl(profile: RiddleProofProfile): string;
160
+ declare function resolveRiddleProofProfileRouteUrl(targetUrl: string, route: string): string;
160
161
  declare function assessRiddleProofProfileEvidence(profile: RiddleProofProfile, evidence: RiddleProofProfileEvidence | undefined, options?: {
161
162
  runner?: RiddleProofProfileRunner;
162
163
  riddle?: RiddleProofProfileResult["riddle"];
@@ -188,4 +189,4 @@ declare function buildRiddleProofProfileScript(profile: RiddleProofProfile): str
188
189
  declare function collectRiddleProfileArtifactRefs(input: unknown): RiddleProofProfileArtifactRef[];
189
190
  declare function extractRiddleProofProfileResult(input: unknown): RiddleProofProfileResult | undefined;
190
191
 
191
- export { type NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, type RiddleProofProfile, type RiddleProofProfileArtifactRef, type RiddleProofProfileBaselinePolicy, type RiddleProofProfileCheck, type RiddleProofProfileCheckResult, type RiddleProofProfileCheckType, type RiddleProofProfileEvidence, type RiddleProofProfileFailureAction, type RiddleProofProfileResult, type RiddleProofProfileRouteEvidence, type RiddleProofProfileRunner, type RiddleProofProfileSetupAction, type RiddleProofProfileSetupActionType, type RiddleProofProfileStatus, type RiddleProofProfileTarget, type RiddleProofProfileViewport, type RiddleProofProfileViewportEvidence, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, extractRiddleProofProfileResult, normalizeRiddleProofProfile, profileStatusExitCode, resolveRiddleProofProfileTargetUrl, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult };
192
+ export { type NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, type RiddleProofProfile, type RiddleProofProfileArtifactRef, type RiddleProofProfileBaselinePolicy, type RiddleProofProfileCheck, type RiddleProofProfileCheckResult, type RiddleProofProfileCheckType, type RiddleProofProfileEvidence, type RiddleProofProfileFailureAction, type RiddleProofProfileResult, type RiddleProofProfileRouteEvidence, type RiddleProofProfileRunner, type RiddleProofProfileSetupAction, type RiddleProofProfileSetupActionType, type RiddleProofProfileStatus, type RiddleProofProfileTarget, type RiddleProofProfileViewport, type RiddleProofProfileViewportEvidence, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, extractRiddleProofProfileResult, normalizeRiddleProofProfile, profileStatusExitCode, resolveRiddleProofProfileRouteUrl, resolveRiddleProofProfileTargetUrl, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult };
package/dist/profile.d.ts CHANGED
@@ -157,6 +157,7 @@ interface NormalizeRiddleProofProfileOptions {
157
157
  declare function slugifyRiddleProofProfileName(value: string): string;
158
158
  declare function normalizeRiddleProofProfile(input: unknown, options?: NormalizeRiddleProofProfileOptions): RiddleProofProfile;
159
159
  declare function resolveRiddleProofProfileTargetUrl(profile: RiddleProofProfile): string;
160
+ declare function resolveRiddleProofProfileRouteUrl(targetUrl: string, route: string): string;
160
161
  declare function assessRiddleProofProfileEvidence(profile: RiddleProofProfile, evidence: RiddleProofProfileEvidence | undefined, options?: {
161
162
  runner?: RiddleProofProfileRunner;
162
163
  riddle?: RiddleProofProfileResult["riddle"];
@@ -188,4 +189,4 @@ declare function buildRiddleProofProfileScript(profile: RiddleProofProfile): str
188
189
  declare function collectRiddleProfileArtifactRefs(input: unknown): RiddleProofProfileArtifactRef[];
189
190
  declare function extractRiddleProofProfileResult(input: unknown): RiddleProofProfileResult | undefined;
190
191
 
191
- export { type NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, type RiddleProofProfile, type RiddleProofProfileArtifactRef, type RiddleProofProfileBaselinePolicy, type RiddleProofProfileCheck, type RiddleProofProfileCheckResult, type RiddleProofProfileCheckType, type RiddleProofProfileEvidence, type RiddleProofProfileFailureAction, type RiddleProofProfileResult, type RiddleProofProfileRouteEvidence, type RiddleProofProfileRunner, type RiddleProofProfileSetupAction, type RiddleProofProfileSetupActionType, type RiddleProofProfileStatus, type RiddleProofProfileTarget, type RiddleProofProfileViewport, type RiddleProofProfileViewportEvidence, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, extractRiddleProofProfileResult, normalizeRiddleProofProfile, profileStatusExitCode, resolveRiddleProofProfileTargetUrl, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult };
192
+ export { type NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, type RiddleProofProfile, type RiddleProofProfileArtifactRef, type RiddleProofProfileBaselinePolicy, type RiddleProofProfileCheck, type RiddleProofProfileCheckResult, type RiddleProofProfileCheckType, type RiddleProofProfileEvidence, type RiddleProofProfileFailureAction, type RiddleProofProfileResult, type RiddleProofProfileRouteEvidence, type RiddleProofProfileRunner, type RiddleProofProfileSetupAction, type RiddleProofProfileSetupActionType, type RiddleProofProfileStatus, type RiddleProofProfileTarget, type RiddleProofProfileViewport, type RiddleProofProfileViewportEvidence, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, extractRiddleProofProfileResult, normalizeRiddleProofProfile, profileStatusExitCode, resolveRiddleProofProfileRouteUrl, resolveRiddleProofProfileTargetUrl, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult };
package/dist/profile.js CHANGED
@@ -14,10 +14,11 @@ import {
14
14
  extractRiddleProofProfileResult,
15
15
  normalizeRiddleProofProfile,
16
16
  profileStatusExitCode,
17
+ resolveRiddleProofProfileRouteUrl,
17
18
  resolveRiddleProofProfileTargetUrl,
18
19
  slugifyRiddleProofProfileName,
19
20
  summarizeRiddleProofProfileResult
20
- } from "./chunk-A7RJZD4I.js";
21
+ } from "./chunk-PZYQGRQ5.js";
21
22
  export {
22
23
  RIDDLE_PROOF_PROFILE_CHECK_TYPES,
23
24
  RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
@@ -34,6 +35,7 @@ export {
34
35
  extractRiddleProofProfileResult,
35
36
  normalizeRiddleProofProfile,
36
37
  profileStatusExitCode,
38
+ resolveRiddleProofProfileRouteUrl,
37
39
  resolveRiddleProofProfileTargetUrl,
38
40
  slugifyRiddleProofProfileName,
39
41
  summarizeRiddleProofProfileResult
@@ -292,7 +292,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
292
292
  blocking?: boolean;
293
293
  details?: Record<string, unknown>;
294
294
  ok: boolean;
295
- action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
295
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
296
296
  state_path: string;
297
297
  stage: any;
298
298
  summary: string;
@@ -382,7 +382,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
382
382
  continueWithStage?: WorkflowStage | null;
383
383
  blocking?: boolean;
384
384
  details?: Record<string, unknown>;
385
- action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
385
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
386
386
  state_path: string;
387
387
  stage: any;
388
388
  checkpoint: string;
@@ -659,7 +659,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
659
659
  error?: undefined;
660
660
  } | {
661
661
  ok: boolean;
662
- action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
662
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
663
663
  state_path: string;
664
664
  stage: any;
665
665
  summary: string;
@@ -292,7 +292,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
292
292
  blocking?: boolean;
293
293
  details?: Record<string, unknown>;
294
294
  ok: boolean;
295
- action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
295
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
296
296
  state_path: string;
297
297
  stage: any;
298
298
  summary: string;
@@ -382,7 +382,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
382
382
  continueWithStage?: WorkflowStage | null;
383
383
  blocking?: boolean;
384
384
  details?: Record<string, unknown>;
385
- action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
385
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
386
386
  state_path: string;
387
387
  stage: any;
388
388
  checkpoint: string;
@@ -659,7 +659,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
659
659
  error?: undefined;
660
660
  } | {
661
661
  ok: boolean;
662
- action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
662
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
663
663
  state_path: string;
664
664
  stage: any;
665
665
  summary: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.7.10",
3
+ "version": "0.7.11",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",