milieu-cli 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (330) hide show
  1. package/README.md +177 -76
  2. package/dist/bridges/context/agents-json.d.ts +0 -1
  3. package/dist/bridges/context/agents-json.js +21 -12
  4. package/dist/bridges/context/auth-clarity.d.ts +0 -1
  5. package/dist/bridges/context/auth-clarity.js +11 -9
  6. package/dist/bridges/context/auth-legibility.d.ts +2 -2
  7. package/dist/bridges/context/auth-legibility.js +67 -60
  8. package/dist/bridges/context/index.d.ts +1 -2
  9. package/dist/bridges/context/index.js +19 -40
  10. package/dist/bridges/context/oauth-metadata.d.ts +14 -0
  11. package/dist/bridges/context/oauth-metadata.js +127 -0
  12. package/dist/bridges/context/probe.d.ts +33 -0
  13. package/dist/bridges/context/probe.js +157 -0
  14. package/dist/bridges/context/rate-limits.d.ts +5 -2
  15. package/dist/bridges/context/rate-limits.js +27 -51
  16. package/dist/bridges/context/tos-contact.d.ts +13 -4
  17. package/dist/bridges/context/tos-contact.js +108 -46
  18. package/dist/bridges/context/versioning.d.ts +1 -2
  19. package/dist/bridges/context/versioning.js +42 -7
  20. package/dist/bridges/index.d.ts +0 -1
  21. package/dist/bridges/index.js +0 -1
  22. package/dist/bridges/reachability/crawler-policy.d.ts +30 -10
  23. package/dist/bridges/reachability/crawler-policy.js +41 -56
  24. package/dist/bridges/reachability/http-status.d.ts +3 -2
  25. package/dist/bridges/reachability/http-status.js +18 -3
  26. package/dist/bridges/reachability/https-check.d.ts +2 -2
  27. package/dist/bridges/reachability/https-check.js +6 -3
  28. package/dist/bridges/reachability/index.d.ts +1 -2
  29. package/dist/bridges/reachability/index.js +34 -43
  30. package/dist/bridges/reachability/meta-robots.d.ts +0 -13
  31. package/dist/bridges/reachability/meta-robots.js +89 -101
  32. package/dist/bridges/reachability/robots-parser.d.ts +7 -7
  33. package/dist/bridges/reachability/robots-parser.js +65 -15
  34. package/dist/bridges/reachability/robots-txt.d.ts +4 -2
  35. package/dist/bridges/reachability/robots-txt.js +33 -60
  36. package/dist/bridges/schema/descriptions.d.ts +2 -2
  37. package/dist/bridges/schema/descriptions.js +79 -44
  38. package/dist/bridges/schema/error-schemas.d.ts +2 -2
  39. package/dist/bridges/schema/error-schemas.js +31 -18
  40. package/dist/bridges/schema/index.d.ts +2 -2
  41. package/dist/bridges/schema/index.js +48 -30
  42. package/dist/bridges/schema/oas-types.d.ts +65 -26
  43. package/dist/bridges/schema/oas-types.js +37 -7
  44. package/dist/bridges/schema/operation-ids.d.ts +2 -2
  45. package/dist/bridges/schema/operation-ids.js +2 -3
  46. package/dist/bridges/schema/required-fields.d.ts +2 -2
  47. package/dist/bridges/schema/required-fields.js +12 -10
  48. package/dist/bridges/schema/schema-sources.d.ts +19 -0
  49. package/dist/bridges/schema/schema-sources.js +182 -0
  50. package/dist/bridges/schema/schema-types.d.ts +2 -2
  51. package/dist/bridges/schema/schema-types.js +20 -21
  52. package/dist/bridges/separation/api-presence.d.ts +3 -15
  53. package/dist/bridges/separation/api-presence.js +34 -85
  54. package/dist/bridges/separation/developer-docs.d.ts +6 -18
  55. package/dist/bridges/separation/developer-docs.js +100 -99
  56. package/dist/bridges/separation/docs-discovery.d.ts +28 -0
  57. package/dist/bridges/separation/docs-discovery.js +95 -0
  58. package/dist/bridges/separation/evidence-summary.d.ts +2 -0
  59. package/dist/bridges/separation/evidence-summary.js +67 -0
  60. package/dist/bridges/separation/index.d.ts +2 -19
  61. package/dist/bridges/separation/index.js +35 -39
  62. package/dist/bridges/separation/published-routes.d.ts +69 -0
  63. package/dist/bridges/separation/published-routes.js +271 -0
  64. package/dist/bridges/separation/sdk-references.d.ts +8 -3
  65. package/dist/bridges/separation/sdk-references.js +86 -61
  66. package/dist/bridges/separation/webhook-support.d.ts +3 -23
  67. package/dist/bridges/separation/webhook-support.js +61 -162
  68. package/dist/bridges/standards/a2a-agent-card.d.ts +0 -1
  69. package/dist/bridges/standards/a2a-agent-card.js +24 -9
  70. package/dist/bridges/standards/graphql.d.ts +3 -4
  71. package/dist/bridges/standards/graphql.js +70 -66
  72. package/dist/bridges/standards/index.d.ts +1 -2
  73. package/dist/bridges/standards/index.js +57 -47
  74. package/dist/bridges/standards/json-ld.d.ts +25 -11
  75. package/dist/bridges/standards/json-ld.js +114 -56
  76. package/dist/bridges/standards/llms-txt.d.ts +4 -2
  77. package/dist/bridges/standards/llms-txt.js +46 -32
  78. package/dist/bridges/standards/markdown-negotiation.d.ts +4 -1
  79. package/dist/bridges/standards/markdown-negotiation.js +16 -11
  80. package/dist/bridges/standards/mcp.d.ts +3 -12
  81. package/dist/bridges/standards/mcp.js +89 -132
  82. package/dist/bridges/standards/openapi.d.ts +7 -15
  83. package/dist/bridges/standards/openapi.js +657 -207
  84. package/dist/bridges/standards/probe-evidence.d.ts +30 -0
  85. package/dist/bridges/standards/probe-evidence.js +90 -0
  86. package/dist/bridges/standards/schema-org.d.ts +15 -9
  87. package/dist/bridges/standards/schema-org.js +38 -64
  88. package/dist/bridges/standards/sitemap.d.ts +2 -3
  89. package/dist/bridges/standards/sitemap.js +161 -169
  90. package/dist/bridges/standards/well-known.d.ts +3 -7
  91. package/dist/bridges/standards/well-known.js +28 -12
  92. package/dist/cli/index.d.ts +1 -1
  93. package/dist/cli/index.js +107 -22
  94. package/dist/cli/journey-commands.d.ts +3 -0
  95. package/dist/cli/journey-commands.js +35 -0
  96. package/dist/cli/read-report.d.ts +2 -0
  97. package/dist/cli/read-report.js +11 -0
  98. package/dist/core/bridge-output.d.ts +11 -0
  99. package/dist/core/bridge-output.js +86 -0
  100. package/dist/core/bridge-session.d.ts +28 -0
  101. package/dist/core/bridge-session.js +58 -0
  102. package/dist/core/bridge-worker.d.ts +1 -0
  103. package/dist/core/bridge-worker.js +66 -0
  104. package/dist/core/diff.d.ts +79 -0
  105. package/dist/core/diff.js +499 -0
  106. package/dist/core/explanations.d.ts +1 -3
  107. package/dist/core/explanations.js +36 -59
  108. package/dist/core/index.d.ts +4 -2
  109. package/dist/core/index.js +2 -3
  110. package/dist/core/scan-options.d.ts +0 -1
  111. package/dist/core/scan-options.js +14 -6
  112. package/dist/core/scan.d.ts +0 -1
  113. package/dist/core/scan.js +91 -41
  114. package/dist/core/scoring.d.ts +6 -0
  115. package/dist/core/scoring.js +27 -0
  116. package/dist/core/types.d.ts +97 -61
  117. package/dist/core/types.js +9 -3
  118. package/dist/core/validate-report.d.ts +5 -0
  119. package/dist/core/validate-report.js +95 -0
  120. package/dist/core/version.d.ts +0 -1
  121. package/dist/core/version.js +0 -1
  122. package/dist/index.d.ts +0 -1
  123. package/dist/index.js +0 -1
  124. package/dist/journey/body-worker.d.ts +27 -0
  125. package/dist/journey/body-worker.js +140 -0
  126. package/dist/journey/case.d.ts +74 -0
  127. package/dist/journey/case.js +187 -0
  128. package/dist/journey/cli.d.ts +14 -0
  129. package/dist/journey/cli.js +226 -0
  130. package/dist/journey/compare.d.ts +43 -0
  131. package/dist/journey/compare.js +83 -0
  132. package/dist/journey/contracts.d.ts +143 -0
  133. package/dist/journey/contracts.js +37 -0
  134. package/dist/journey/decision.d.ts +72 -0
  135. package/dist/journey/decision.js +121 -0
  136. package/dist/journey/demo.d.ts +36 -0
  137. package/dist/journey/demo.js +137 -0
  138. package/dist/journey/document.d.ts +8 -0
  139. package/dist/journey/document.js +113 -0
  140. package/dist/journey/excerpt.d.ts +6 -0
  141. package/dist/journey/excerpt.js +54 -0
  142. package/dist/journey/name-guidance.d.ts +2 -0
  143. package/dist/journey/name-guidance.js +41 -0
  144. package/dist/journey/providers.d.ts +34 -0
  145. package/dist/journey/providers.js +197 -0
  146. package/dist/journey/report-validation.d.ts +3 -0
  147. package/dist/journey/report-validation.js +457 -0
  148. package/dist/journey/runner.d.ts +12 -0
  149. package/dist/journey/runner.js +321 -0
  150. package/dist/journey/scope.d.ts +8 -0
  151. package/dist/journey/scope.js +50 -0
  152. package/dist/journey/transport.d.ts +3 -0
  153. package/dist/journey/transport.js +45 -0
  154. package/dist/journey/verify.d.ts +21 -0
  155. package/dist/journey/verify.js +213 -0
  156. package/dist/render/colors.d.ts +6 -7
  157. package/dist/render/colors.js +16 -25
  158. package/dist/render/discovery-guidance.d.ts +3 -0
  159. package/dist/render/discovery-guidance.js +66 -0
  160. package/dist/render/format-bridge.d.ts +1 -2
  161. package/dist/render/format-bridge.js +22 -17
  162. package/dist/render/format-diff.d.ts +2 -0
  163. package/dist/render/format-diff.js +169 -0
  164. package/dist/render/format-scan.d.ts +0 -1
  165. package/dist/render/format-scan.js +6 -4
  166. package/dist/render/format-verbose.d.ts +0 -1
  167. package/dist/render/format-verbose.js +7 -4
  168. package/dist/render/index.d.ts +0 -1
  169. package/dist/render/index.js +1 -2
  170. package/dist/render/oauth-observations.d.ts +4 -0
  171. package/dist/render/oauth-observations.js +27 -0
  172. package/dist/render/progress-bar.d.ts +1 -2
  173. package/dist/render/progress-bar.js +8 -6
  174. package/dist/render/robots-inventory.d.ts +3 -0
  175. package/dist/render/robots-inventory.js +38 -0
  176. package/dist/render/symbols.d.ts +4 -10
  177. package/dist/render/symbols.js +15 -17
  178. package/dist/render/terminal-text.d.ts +1 -3
  179. package/dist/render/terminal-text.js +1 -5
  180. package/dist/utils/analysis-worker-entry.d.ts +3 -0
  181. package/dist/utils/analysis-worker-entry.js +12 -0
  182. package/dist/utils/analysis-worker.d.ts +12 -0
  183. package/dist/utils/analysis-worker.js +54 -0
  184. package/dist/utils/html.d.ts +39 -0
  185. package/dist/utils/html.js +261 -0
  186. package/dist/utils/http-client.d.ts +24 -17
  187. package/dist/utils/http-client.js +166 -200
  188. package/dist/utils/http-types.d.ts +43 -0
  189. package/dist/utils/http-types.js +11 -0
  190. package/dist/utils/index.d.ts +0 -1
  191. package/dist/utils/index.js +0 -1
  192. package/dist/utils/package-registry.d.ts +11 -0
  193. package/dist/utils/package-registry.js +69 -0
  194. package/dist/utils/read-json-file.d.ts +3 -0
  195. package/dist/utils/read-json-file.js +41 -0
  196. package/dist/utils/record.d.ts +1 -0
  197. package/dist/utils/record.js +3 -0
  198. package/dist/utils/response-body.d.ts +7 -0
  199. package/dist/utils/response-body.js +71 -0
  200. package/dist/utils/ssrf.d.ts +11 -15
  201. package/dist/utils/ssrf.js +80 -44
  202. package/dist/utils/terminal-text.d.ts +2 -0
  203. package/dist/utils/terminal-text.js +4 -0
  204. package/dist/utils/url.d.ts +29 -1
  205. package/dist/utils/url.js +147 -17
  206. package/docs/examples/onboarding/account-claim.json +25 -0
  207. package/docs/examples/onboarding/pages/account-claim.html +3 -0
  208. package/docs/examples/onboarding/pages/production-activation.html +3 -0
  209. package/docs/examples/onboarding/pages/test-credential.html +3 -0
  210. package/docs/examples/onboarding/production-activation.json +25 -0
  211. package/docs/examples/onboarding/test-credential.json +25 -0
  212. package/docs/journey-qualification.md +46 -0
  213. package/docs/journeys.md +83 -0
  214. package/package.json +28 -8
  215. package/dist/bridges/context/agents-json.d.ts.map +0 -1
  216. package/dist/bridges/context/agents-json.js.map +0 -1
  217. package/dist/bridges/context/auth-clarity.d.ts.map +0 -1
  218. package/dist/bridges/context/auth-clarity.js.map +0 -1
  219. package/dist/bridges/context/auth-legibility.d.ts.map +0 -1
  220. package/dist/bridges/context/auth-legibility.js.map +0 -1
  221. package/dist/bridges/context/index.d.ts.map +0 -1
  222. package/dist/bridges/context/index.js.map +0 -1
  223. package/dist/bridges/context/rate-limits.d.ts.map +0 -1
  224. package/dist/bridges/context/rate-limits.js.map +0 -1
  225. package/dist/bridges/context/tos-contact.d.ts.map +0 -1
  226. package/dist/bridges/context/tos-contact.js.map +0 -1
  227. package/dist/bridges/context/versioning.d.ts.map +0 -1
  228. package/dist/bridges/context/versioning.js.map +0 -1
  229. package/dist/bridges/index.d.ts.map +0 -1
  230. package/dist/bridges/index.js.map +0 -1
  231. package/dist/bridges/reachability/crawler-policy.d.ts.map +0 -1
  232. package/dist/bridges/reachability/crawler-policy.js.map +0 -1
  233. package/dist/bridges/reachability/http-status.d.ts.map +0 -1
  234. package/dist/bridges/reachability/http-status.js.map +0 -1
  235. package/dist/bridges/reachability/https-check.d.ts.map +0 -1
  236. package/dist/bridges/reachability/https-check.js.map +0 -1
  237. package/dist/bridges/reachability/index.d.ts.map +0 -1
  238. package/dist/bridges/reachability/index.js.map +0 -1
  239. package/dist/bridges/reachability/meta-robots.d.ts.map +0 -1
  240. package/dist/bridges/reachability/meta-robots.js.map +0 -1
  241. package/dist/bridges/reachability/robots-parser.d.ts.map +0 -1
  242. package/dist/bridges/reachability/robots-parser.js.map +0 -1
  243. package/dist/bridges/reachability/robots-txt.d.ts.map +0 -1
  244. package/dist/bridges/reachability/robots-txt.js.map +0 -1
  245. package/dist/bridges/schema/descriptions.d.ts.map +0 -1
  246. package/dist/bridges/schema/descriptions.js.map +0 -1
  247. package/dist/bridges/schema/error-schemas.d.ts.map +0 -1
  248. package/dist/bridges/schema/error-schemas.js.map +0 -1
  249. package/dist/bridges/schema/index.d.ts.map +0 -1
  250. package/dist/bridges/schema/index.js.map +0 -1
  251. package/dist/bridges/schema/oas-types.d.ts.map +0 -1
  252. package/dist/bridges/schema/oas-types.js.map +0 -1
  253. package/dist/bridges/schema/operation-ids.d.ts.map +0 -1
  254. package/dist/bridges/schema/operation-ids.js.map +0 -1
  255. package/dist/bridges/schema/required-fields.d.ts.map +0 -1
  256. package/dist/bridges/schema/required-fields.js.map +0 -1
  257. package/dist/bridges/schema/schema-types.d.ts.map +0 -1
  258. package/dist/bridges/schema/schema-types.js.map +0 -1
  259. package/dist/bridges/separation/api-presence.d.ts.map +0 -1
  260. package/dist/bridges/separation/api-presence.js.map +0 -1
  261. package/dist/bridges/separation/developer-docs.d.ts.map +0 -1
  262. package/dist/bridges/separation/developer-docs.js.map +0 -1
  263. package/dist/bridges/separation/index.d.ts.map +0 -1
  264. package/dist/bridges/separation/index.js.map +0 -1
  265. package/dist/bridges/separation/sdk-references.d.ts.map +0 -1
  266. package/dist/bridges/separation/sdk-references.js.map +0 -1
  267. package/dist/bridges/separation/webhook-support.d.ts.map +0 -1
  268. package/dist/bridges/separation/webhook-support.js.map +0 -1
  269. package/dist/bridges/standards/a2a-agent-card.d.ts.map +0 -1
  270. package/dist/bridges/standards/a2a-agent-card.js.map +0 -1
  271. package/dist/bridges/standards/graphql.d.ts.map +0 -1
  272. package/dist/bridges/standards/graphql.js.map +0 -1
  273. package/dist/bridges/standards/index.d.ts.map +0 -1
  274. package/dist/bridges/standards/index.js.map +0 -1
  275. package/dist/bridges/standards/json-ld.d.ts.map +0 -1
  276. package/dist/bridges/standards/json-ld.js.map +0 -1
  277. package/dist/bridges/standards/llms-txt.d.ts.map +0 -1
  278. package/dist/bridges/standards/llms-txt.js.map +0 -1
  279. package/dist/bridges/standards/markdown-negotiation.d.ts.map +0 -1
  280. package/dist/bridges/standards/markdown-negotiation.js.map +0 -1
  281. package/dist/bridges/standards/mcp.d.ts.map +0 -1
  282. package/dist/bridges/standards/mcp.js.map +0 -1
  283. package/dist/bridges/standards/openapi.d.ts.map +0 -1
  284. package/dist/bridges/standards/openapi.js.map +0 -1
  285. package/dist/bridges/standards/schema-org.d.ts.map +0 -1
  286. package/dist/bridges/standards/schema-org.js.map +0 -1
  287. package/dist/bridges/standards/sitemap.d.ts.map +0 -1
  288. package/dist/bridges/standards/sitemap.js.map +0 -1
  289. package/dist/bridges/standards/well-known.d.ts.map +0 -1
  290. package/dist/bridges/standards/well-known.js.map +0 -1
  291. package/dist/cli/index.d.ts.map +0 -1
  292. package/dist/cli/index.js.map +0 -1
  293. package/dist/core/explanations.d.ts.map +0 -1
  294. package/dist/core/explanations.js.map +0 -1
  295. package/dist/core/index.d.ts.map +0 -1
  296. package/dist/core/index.js.map +0 -1
  297. package/dist/core/scan-options.d.ts.map +0 -1
  298. package/dist/core/scan-options.js.map +0 -1
  299. package/dist/core/scan.d.ts.map +0 -1
  300. package/dist/core/scan.js.map +0 -1
  301. package/dist/core/types.d.ts.map +0 -1
  302. package/dist/core/types.js.map +0 -1
  303. package/dist/core/version.d.ts.map +0 -1
  304. package/dist/core/version.js.map +0 -1
  305. package/dist/index.d.ts.map +0 -1
  306. package/dist/index.js.map +0 -1
  307. package/dist/render/colors.d.ts.map +0 -1
  308. package/dist/render/colors.js.map +0 -1
  309. package/dist/render/format-bridge.d.ts.map +0 -1
  310. package/dist/render/format-bridge.js.map +0 -1
  311. package/dist/render/format-scan.d.ts.map +0 -1
  312. package/dist/render/format-scan.js.map +0 -1
  313. package/dist/render/format-verbose.d.ts.map +0 -1
  314. package/dist/render/format-verbose.js.map +0 -1
  315. package/dist/render/index.d.ts.map +0 -1
  316. package/dist/render/index.js.map +0 -1
  317. package/dist/render/progress-bar.d.ts.map +0 -1
  318. package/dist/render/progress-bar.js.map +0 -1
  319. package/dist/render/symbols.d.ts.map +0 -1
  320. package/dist/render/symbols.js.map +0 -1
  321. package/dist/render/terminal-text.d.ts.map +0 -1
  322. package/dist/render/terminal-text.js.map +0 -1
  323. package/dist/utils/http-client.d.ts.map +0 -1
  324. package/dist/utils/http-client.js.map +0 -1
  325. package/dist/utils/index.d.ts.map +0 -1
  326. package/dist/utils/index.js.map +0 -1
  327. package/dist/utils/ssrf.d.ts.map +0 -1
  328. package/dist/utils/ssrf.js.map +0 -1
  329. package/dist/utils/url.d.ts.map +0 -1
  330. package/dist/utils/url.js.map +0 -1
@@ -1,3 +1,6 @@
1
+ import type { HttpSuccess, HttpResponse } from "../utils/http-types.js";
2
+ export type { HttpErrorKind, HttpError, HttpSuccess, HttpFailure, HttpResponse } from "../utils/http-types.js";
3
+ import type { ParsedOpenApiSpec } from "../bridges/schema/oas-types.js";
1
4
  /** Status of an individual check within a bridge */
2
5
  export type CheckStatus = "pass" | "partial" | "fail" | "error";
3
6
  /** A single check result */
@@ -22,21 +25,38 @@ export interface ContentSource {
22
25
  /** Human-readable source label (e.g., "homepage", "llms.txt", "/docs") */
23
26
  source: string;
24
27
  }
25
- /** Bridge identifiers (1-5) */
26
- export type BridgeId = 1 | 2 | 3 | 4 | 5;
27
- /** Human-readable bridge names */
28
- export type BridgeName = "Reachability" | "Standards" | "Separation" | "Schema" | "Context";
28
+ export declare const BRIDGES: {
29
+ readonly 1: {
30
+ readonly id: 1;
31
+ readonly name: "Reachability";
32
+ };
33
+ readonly 2: {
34
+ readonly id: 2;
35
+ readonly name: "Standards";
36
+ };
37
+ readonly 3: {
38
+ readonly id: 3;
39
+ readonly name: "Separation";
40
+ };
41
+ readonly 4: {
42
+ readonly id: 4;
43
+ readonly name: "Schema";
44
+ };
45
+ readonly 5: {
46
+ readonly id: 5;
47
+ readonly name: "Context";
48
+ };
49
+ };
50
+ export type BridgeId = keyof typeof BRIDGES;
51
+ export type BridgeName = typeof BRIDGES[BridgeId]["name"];
52
+ export declare const BRIDGE_NAMES: ("Reachability" | "Standards" | "Separation" | "Schema" | "Context")[];
29
53
  /** Bridge evaluation status */
30
54
  export type BridgeStatus = "evaluated" | "not_evaluated";
31
55
  /** Result of a single bridge assessment */
32
- export interface BridgeResult {
33
- /** Bridge number (1-5) */
34
- id: BridgeId;
35
- /** Bridge name */
36
- name: BridgeName;
37
- /** Whether this bridge ran or was skipped after a fatal reachability error */
56
+ export type BridgeResult<Id extends BridgeId = BridgeId> = typeof BRIDGES[Id] & {
57
+ /** Whether this bridge ran or a prerequisite prevented evaluation */
38
58
  status: BridgeStatus;
39
- /** Score 0-100 for scored bridges (1, 2, 4, 5), null for detection-only (3) */
59
+ /** Score 0-100, or null for an unmeasured bridge or the Separation inventory */
40
60
  score: number | null;
41
61
  /** Score category for scored bridges, null for unscored */
42
62
  scoreLabel: "pass" | "partial" | "fail" | null;
@@ -46,24 +66,67 @@ export interface BridgeResult {
46
66
  durationMs: number;
47
67
  /** Optional message about the bridge's evaluation */
48
68
  message?: string;
69
+ /** Eligible checks (not skipped by policy) and how many returned a measured status. Set on evaluated bridges of a scan. */
70
+ measurement?: {
71
+ measured: number;
72
+ eligible: number;
73
+ };
49
74
  /** If true, scan should abort -- no further bridges attempted */
50
75
  abort?: boolean;
51
76
  /** Network error that stopped the scan */
52
77
  abortReason?: string;
53
- }
78
+ };
54
79
  /** Options passed to the scan function */
55
80
  export interface ScanOptions {
56
81
  /** Per-request HTTP timeout in milliseconds (default: 10000) */
57
82
  timeout?: number;
58
- /** Show verbose output with individual check details */
83
+ /** @deprecated Verbosity is controlled by the renderer. */
59
84
  verbose?: boolean;
60
- /** Suppress spinner and terminal output (for JSON/quiet modes) */
85
+ /** @deprecated The library is silent. Use onProgress to receive updates. */
61
86
  silent?: boolean;
87
+ /** Called when the scan enters a new stage. Errors thrown by the callback, and rejections of a returned promise, are ignored. */
88
+ onProgress?: (stage: string) => void;
89
+ /** Cancel an in-progress scan. */
90
+ signal?: AbortSignal;
91
+ /** Overall scan deadline in milliseconds, including DNS, redirects, retries and queuing. */
92
+ deadlineMs?: number;
93
+ /** Allow fallback discovery through the public APIs.guru registry (default true). */
94
+ registryLookup?: boolean;
62
95
  /** Maximum simultaneous outbound HTTP requests (default: 8) */
63
96
  maxConcurrency?: number;
64
97
  /** Maximum outbound HTTP request attempts for the whole scan, counting every redirect hop and retry (default: 150) */
65
98
  maxRequests?: number;
66
99
  }
100
+ export interface SharedState {
101
+ pageBody?: string;
102
+ pageUrl?: string;
103
+ pageHeaders?: Record<string, string>;
104
+ pageResponse?: HttpSuccess;
105
+ /** The homepage body was withheld from parsing because its markup exceeds the node or formatting-nesting limit. */
106
+ pageOverHtmlLimit?: boolean;
107
+ robotsSitemaps?: string[];
108
+ /** robotsSitemaps may stop short of the Sitemap lines robots.txt declares: the list was cut, or the file was cut or not read. */
109
+ robotsSitemapsCut?: boolean;
110
+ openApiCheck?: Check;
111
+ graphqlCheck?: Check;
112
+ openApiDocumentUrls?: string[];
113
+ /** The detected spec as JSON text, the form in which it crosses between bridges. */
114
+ openApiSpecText?: string | null;
115
+ /** That text parsed, in the bridges that read it. */
116
+ openApiSpec?: ParsedOpenApiSpec | null;
117
+ openApiDetected?: boolean;
118
+ openApiDiscoveryIncomplete?: boolean;
119
+ openApiHasWebhooks?: boolean;
120
+ openApiHasCallbacks?: boolean;
121
+ graphqlDetected?: boolean;
122
+ llmsTxtBody?: string | null;
123
+ rootLlmsResponse?: HttpResponse;
124
+ /** What the contact check reports of security.txt, or null. Standards reads it, so that no later bridge holds the file. */
125
+ securityTxtContact?: Pick<Check, "detail" | "data"> | null;
126
+ securityTxtIncomplete?: boolean;
127
+ /** The Terms link Standards found in the homepage it parsed, or null: Context holds the parsed spec and does not parse the page too. */
128
+ pageTermsUrl?: string | null;
129
+ }
67
130
  /** Context shared across bridge checks during a single scan */
68
131
  export interface ScanContext {
69
132
  /** The original URL provided by the user */
@@ -75,13 +138,25 @@ export interface ScanContext {
75
138
  /** Scan options */
76
139
  options: ScanOptions;
77
140
  /** Shared data between bridges (e.g., Bridge 2 OpenAPI result reused by Bridge 3) */
78
- shared: Record<string, unknown>;
141
+ shared: SharedState;
142
+ }
143
+ /** Effective scan-wide baseline for HTTP probes and the coordinator's physical attempt counts.
144
+ * Individual probes can have shorter deadlines.
145
+ */
146
+ export interface ScanRequestSummary {
147
+ timeoutMs: number;
148
+ deadlineMs?: number;
149
+ registryLookup?: boolean;
150
+ maxConcurrency: number;
151
+ maxRequests: number;
152
+ started: number;
153
+ denied: number;
79
154
  }
80
155
  /** A completed scan -- this is the JSON output public API contract */
81
156
  export interface ScanResult {
82
157
  /** Discriminant: a completed scan. Mirrors HttpResponse's `ok` field. */
83
158
  ok: true;
84
- /** Schema version for JSON output stability (semver) */
159
+ /** Scanner package version. Comparing saved reports requires identical versions. */
85
160
  version: string;
86
161
  /** The URL that was scanned */
87
162
  url: string;
@@ -89,19 +164,22 @@ export interface ScanResult {
89
164
  scannedOrigin: string;
90
165
  /** True when the scan request budget ran out and at least one probe was skipped — treat affected checks as unmeasured, not failing */
91
166
  incomplete: boolean;
167
+ /** Absent from reports produced before request context was recorded. */
168
+ requestContext?: ScanRequestSummary;
92
169
  /** ISO 8601 timestamp when scan started */
93
170
  timestamp: string;
94
171
  /** Total scan duration in milliseconds */
95
172
  durationMs: number;
96
- /** Overall score (0-100) averaged from scored bridges (1, 2, 4, 5) */
173
+ /** Rounded average of available numeric scores for Bridges 1, 2, 4 and 5 */
97
174
  overallScore: number;
98
175
  /** Overall score category */
99
176
  overallScoreLabel: "pass" | "partial" | "fail";
100
177
  /** Results for each bridge (always 5 entries, in order) */
101
- bridges: [BridgeResult, BridgeResult, BridgeResult, BridgeResult, BridgeResult];
178
+ bridges: [BridgeResult<1>, BridgeResult<2>, BridgeResult<3>, BridgeResult<4>, BridgeResult<5>];
102
179
  }
103
180
  /** Why a scan could not produce a result. */
104
- export type ScanErrorKind = "invalid_url" | "scan_failed";
181
+ export type ScanErrorKind = "invalid_url" | "invalid_options" | "scan_cancelled" | "scan_failed";
182
+ export type CliErrorKind = ScanErrorKind | "diff_failed" | "usage_error";
105
183
  /** A scan that never produced a result. Mirrors HttpFailure. */
106
184
  export interface ScanFailure {
107
185
  ok: false;
@@ -116,45 +194,3 @@ export interface ScanFailure {
116
194
  * narrow on `.ok` before using the result.
117
195
  */
118
196
  export type ScanOutcome = ScanResult | ScanFailure;
119
- /** Discriminated union for HTTP client errors (FOUND-03) */
120
- export type HttpErrorKind = "dns" | "timeout" | "ssrf_blocked" | "http_error" | "bot_protected" | "connection_refused" | "ssl_error" | "body_too_large" | "request_budget_exhausted" | "unknown";
121
- /** HTTP error with discriminated kind field */
122
- export interface HttpError {
123
- kind: HttpErrorKind;
124
- message: string;
125
- statusCode?: number;
126
- url: string;
127
- }
128
- /** HTTP success response */
129
- export interface HttpSuccess {
130
- ok: true;
131
- url: string;
132
- status: number;
133
- headers: Record<string, string>;
134
- body: string;
135
- redirects: string[];
136
- durationMs: number;
137
- }
138
- /** HTTP failure response */
139
- export interface HttpFailure {
140
- ok: false;
141
- error: HttpError;
142
- /**
143
- * The HTTP response, present only when the failure IS one — a 4xx/5xx
144
- * (`http_error`) or bot-protection (`bot_protected`). Absent for
145
- * network-level failures (dns, timeout, ssrf_blocked, connection_refused,
146
- * ssl_error, body_too_large, request_budget_exhausted).
147
- *
148
- * Checks that grade a *rejection* rather than an absence — auth legibility
149
- * (401/403 quality) and rate limits (headers on any response) — read this
150
- * instead of treating every non-2xx as "unreachable".
151
- */
152
- response?: {
153
- status: number;
154
- headers: Record<string, string>;
155
- body: string;
156
- };
157
- }
158
- /** Discriminated union for HTTP responses */
159
- export type HttpResponse = HttpSuccess | HttpFailure;
160
- //# sourceMappingURL=types.d.ts.map
@@ -1,3 +1,9 @@
1
- // === Check Status ===
2
- export {};
3
- //# sourceMappingURL=types.js.map
1
+ // === Bridge Types ===
2
+ export const BRIDGES = {
3
+ 1: { id: 1, name: "Reachability" },
4
+ 2: { id: 2, name: "Standards" },
5
+ 3: { id: 3, name: "Separation" },
6
+ 4: { id: 4, name: "Schema" },
7
+ 5: { id: 5, name: "Context" },
8
+ };
9
+ export const BRIDGE_NAMES = Object.values(BRIDGES).map(bridge => bridge.name);
@@ -0,0 +1,5 @@
1
+ import type { ScanResult } from "./types.js";
2
+ export declare function reportOrigin(raw: string): string;
3
+ /** Normalize historical saved reports into the ordered tuple used by current consumers. */
4
+ export declare function parseScanReport(input: unknown): ScanResult;
5
+ export declare function validateReport(value: unknown): asserts value is ScanResult;
@@ -0,0 +1,95 @@
1
+ import { isRecord } from "../utils/record.js";
2
+ import { checkCoverage } from "./scoring.js";
3
+ import { BRIDGE_NAMES } from "./types.js";
4
+ const CHECK_STATUSES = new Set(["pass", "partial", "fail", "error"]);
5
+ const SCORE_LABELS = new Set(["pass", "partial", "fail"]);
6
+ export function reportOrigin(raw) {
7
+ const url = URL.parse(raw);
8
+ if (!url || url.username || url.password || !/^https?:\/\/[^/?#\\\s]+\/?$/i.test(raw) || url.href !== url.origin + "/") {
9
+ throw new Error("Expected an absolute HTTP(S) origin without a path, credentials, query or fragment.");
10
+ }
11
+ return url.origin;
12
+ }
13
+ function isScore(value) {
14
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 100;
15
+ }
16
+ function isDuration(value) {
17
+ return typeof value === "number" && Number.isFinite(value) && value >= 0;
18
+ }
19
+ /** Normalize historical saved reports into the ordered tuple used by current consumers. */
20
+ export function parseScanReport(input) {
21
+ let value = input;
22
+ if (isRecord(input) && Array.isArray(input.bridges) && input.bridges.length === BRIDGE_NAMES.length &&
23
+ input.bridges.every(bridge => isRecord(bridge) && typeof bridge.id === "number")) {
24
+ const reordered = input.bridges.some((bridge, index) => bridge.id !== index + 1);
25
+ let bridges = reordered ? [...input.bridges].sort((a, b) => a.id - b.id) : input.bridges;
26
+ // 0.3.2 wrote 0/fail for skipped scored bridges after a reachability abort.
27
+ if (input.version === "0.3.2" && bridges[0].abort === true) {
28
+ bridges = bridges.map(bridge => [2, 4, 5].includes(bridge.id) && bridge.status === "not_evaluated" &&
29
+ bridge.score === 0 && bridge.scoreLabel === "fail" ? { ...bridge, score: null, scoreLabel: null } : bridge);
30
+ }
31
+ if (bridges !== input.bridges)
32
+ value = { ...input, bridges };
33
+ }
34
+ validateReport(value);
35
+ return value;
36
+ }
37
+ export function validateReport(value) {
38
+ if (isRecord(value) && value.ok === false)
39
+ throw new Error("the file contains a failed scan");
40
+ if (!isRecord(value) || value.ok !== true || typeof value.version !== "string" || !value.version ||
41
+ typeof value.scannedOrigin !== "string" || typeof value.incomplete !== "boolean" ||
42
+ typeof value.url !== "string" || typeof value.timestamp !== "string" || !isDuration(value.durationMs) ||
43
+ !isScore(value.overallScore) || typeof value.overallScoreLabel !== "string" || !SCORE_LABELS.has(value.overallScoreLabel) ||
44
+ !Array.isArray(value.bridges) || value.bridges.length !== BRIDGE_NAMES.length) {
45
+ throw new Error("expected a five-bridge scan report with version, scannedOrigin and incomplete");
46
+ }
47
+ reportOrigin(value.scannedOrigin);
48
+ if (value.requestContext !== undefined) {
49
+ const ctx = value.requestContext;
50
+ const integer = (n, min) => typeof n === "number" && Number.isSafeInteger(n) && n >= min;
51
+ if (!isRecord(ctx) || !integer(ctx.timeoutMs, 1) || ctx.timeoutMs > 2_147_483_647 ||
52
+ (ctx.deadlineMs !== undefined && (!integer(ctx.deadlineMs, 1) || ctx.deadlineMs > 2_147_483_647)) ||
53
+ (ctx.registryLookup !== undefined && typeof ctx.registryLookup !== "boolean") ||
54
+ !integer(ctx.maxConcurrency, 1) || !integer(ctx.maxRequests, 1) || !integer(ctx.started, 0) ||
55
+ !integer(ctx.denied, 0) || ctx.started > ctx.maxRequests || (ctx.denied > 0) !== value.incomplete ||
56
+ (ctx.denied > 0 && ctx.started !== ctx.maxRequests))
57
+ throw new Error("invalid scan request context");
58
+ }
59
+ for (const [index, bridge] of value.bridges.entries()) {
60
+ if (!isRecord(bridge) || typeof bridge.id !== "number" || !Number.isInteger(bridge.id) ||
61
+ bridge.id < 1 || bridge.id > BRIDGE_NAMES.length || bridge.name !== BRIDGE_NAMES[bridge.id - 1] ||
62
+ bridge.id !== index + 1 || (bridge.status !== "evaluated" && bridge.status !== "not_evaluated") ||
63
+ !isDuration(bridge.durationMs) || !Array.isArray(bridge.checks) ||
64
+ ((bridge.score === null) !== (bridge.scoreLabel === null)) ||
65
+ (bridge.id === 3 && bridge.score !== null) ||
66
+ (bridge.status === "not_evaluated" && (bridge.score !== null || bridge.checks.length > 0)) ||
67
+ (bridge.score !== null && !isScore(bridge.score)) ||
68
+ (bridge.scoreLabel !== null && (typeof bridge.scoreLabel !== "string" || !SCORE_LABELS.has(bridge.scoreLabel))) ||
69
+ (bridge.abort !== undefined && typeof bridge.abort !== "boolean") ||
70
+ (bridge.abortReason !== undefined && typeof bridge.abortReason !== "string") ||
71
+ (bridge.message !== undefined && typeof bridge.message !== "string")) {
72
+ throw new Error("invalid or duplicate bridge in scan report");
73
+ }
74
+ const checkIds = new Set();
75
+ for (const check of bridge.checks) {
76
+ if (!isRecord(check) || typeof check.id !== "string" || !check.id || checkIds.has(check.id) ||
77
+ typeof check.label !== "string" || typeof check.status !== "string" || !CHECK_STATUSES.has(check.status) ||
78
+ (check.detail !== undefined && typeof check.detail !== "string") ||
79
+ (check.why !== undefined && typeof check.why !== "string") ||
80
+ (check.data !== undefined && !isRecord(check.data))) {
81
+ throw new Error("invalid or duplicate check in " + bridge.name);
82
+ }
83
+ checkIds.add(check.id);
84
+ }
85
+ // Earlier reports have no measurement counts. When present it must agree with the checks it summarizes.
86
+ if (bridge.measurement !== undefined) {
87
+ const expected = checkCoverage(bridge.checks);
88
+ if (bridge.status !== "evaluated" || !isRecord(bridge.measurement) ||
89
+ Object.keys(bridge.measurement).some(key => key !== "measured" && key !== "eligible") ||
90
+ bridge.measurement.measured !== expected.measured || bridge.measurement.eligible !== expected.eligible) {
91
+ throw new Error("invalid measurement in " + bridge.name);
92
+ }
93
+ }
94
+ }
95
+ }
@@ -1,2 +1 @@
1
1
  export declare function getVersion(): string;
2
- //# sourceMappingURL=version.d.ts.map
@@ -4,4 +4,3 @@ const pkg = require("../../package.json");
4
4
  export function getVersion() {
5
5
  return pkg.version;
6
6
  }
7
- //# sourceMappingURL=version.js.map
package/dist/index.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export * from "./core/index.js";
2
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
1
  // milieu-cli - Measure how legible your product is to AI agents
2
2
  // Package entry point: re-exports public API
3
3
  export * from "./core/index.js";
4
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,27 @@
1
+ import type { JourneyCase } from "./case.js";
2
+ import { type EvidenceEvent, type FaultCode } from "./contracts.js";
3
+ import { type Observation } from "./verify.js";
4
+ export interface JourneyBodyInput {
5
+ body: Uint8Array;
6
+ mediaType: string;
7
+ event: EvidenceEvent;
8
+ url: string;
9
+ c: JourneyCase;
10
+ role: "actor" | "control";
11
+ prefix: string;
12
+ linkCount: number;
13
+ credential?: string;
14
+ }
15
+ type Link = {
16
+ linkId: string;
17
+ path: string;
18
+ };
19
+ export type JourneyBodyResult = {
20
+ fault: FaultCode;
21
+ } | {
22
+ event: EvidenceEvent;
23
+ observation: Partial<Omit<Observation, "event" | "originalJson" | "json">>;
24
+ links?: Link[];
25
+ feedback?: object;
26
+ };
27
+ export {};
@@ -0,0 +1,140 @@
1
+ import { workerData } from "node:worker_threads";
2
+ import { finishAnalysis } from "../utils/analysis-worker-entry.js";
3
+ import { HtmlLimitError } from "../utils/html.js";
4
+ import { terminalText } from "../utils/terminal-text.js";
5
+ import { budgets, documentPreview, JourneyFault, jsonPreview, redactLiteral } from "./contracts.js";
6
+ import { readDocument, clip } from "./document.js";
7
+ import { examineExcerpt } from "./excerpt.js";
8
+ import { boundAssertion, verifyApi } from "./verify.js";
9
+ /** A clipped API observation presents only complete top-level entries that fit.
10
+ * Its verifier can use those entries, but cannot infer that omitted keys are missing. */
11
+ function visibleJson(value, limit) {
12
+ if (Buffer.byteLength(JSON.stringify(value)) <= limit)
13
+ return { json: value, clipped: false };
14
+ if (!value || typeof value !== "object")
15
+ return { clipped: true };
16
+ let left = limit - 2;
17
+ if (Array.isArray(value)) {
18
+ const prefix = [];
19
+ for (const el of value) {
20
+ const cost = Buffer.byteLength(JSON.stringify(el)) + Number(prefix.length > 0);
21
+ if (cost > left)
22
+ break;
23
+ left -= cost;
24
+ prefix.push(el);
25
+ }
26
+ return { json: prefix, clipped: true };
27
+ }
28
+ const fields = Object.create(null);
29
+ for (const [key, el] of Object.entries(value)) {
30
+ const cost = Buffer.byteLength(JSON.stringify(key)) + Buffer.byteLength(JSON.stringify(el)) + 2;
31
+ if (cost > left)
32
+ break;
33
+ fields[key] = el;
34
+ left -= cost;
35
+ }
36
+ return { json: fields, clipped: true };
37
+ }
38
+ const jsonMedia = (media) => /^application\/(?:json|[a-z0-9!#$&^_.+-]+\+json)$/.test(media);
39
+ function readApi(c, obs, source, media, role, clean) {
40
+ if (!jsonMedia(media))
41
+ obs.jsonCode = "MEDIA_TYPE";
42
+ else {
43
+ try {
44
+ obs.originalJson = JSON.parse(source);
45
+ }
46
+ catch {
47
+ obs.jsonCode = "JSON_INVALID";
48
+ }
49
+ }
50
+ if (obs.jsonCode)
51
+ return { event: obs.event, observation: { jsonCode: obs.jsonCode }, feedback: { format: obs.jsonCode } };
52
+ const parsed = obs.originalJson;
53
+ const pending = [{ value: parsed, depth: 0 }];
54
+ while (pending.length) {
55
+ const { value, depth } = pending.pop();
56
+ if (depth > 128 || (typeof value === "number" && !Number.isFinite(value)))
57
+ throw new JourneyFault("JSON_LIMIT");
58
+ if (value !== null && typeof value === "object") {
59
+ for (const child of Object.values(value))
60
+ pending.push({ value: child, depth: depth + 1 });
61
+ }
62
+ }
63
+ let feedback;
64
+ if (role === "control") {
65
+ obs.json = parsed;
66
+ }
67
+ else {
68
+ // Sanitize strings and keys before exposing or verifying them.
69
+ const safe = clean(JSON.stringify(parsed, (_key, value) => typeof value === "string" ? clean(value) : value));
70
+ const projected = visibleJson(JSON.parse(safe), budgets.observationBytes);
71
+ Object.assign(obs, projected);
72
+ obs.event.preview = jsonPreview(projected.clipped);
73
+ feedback = projected;
74
+ }
75
+ // Compare both the original and the actor-visible values inside this worker.
76
+ // Only bounded assertions and the actor's projection cross back to the runner.
77
+ const apiAssessment = verifyApi(c, obs);
78
+ for (const assertion of apiAssessment.assertions)
79
+ boundAssertion(assertion, clean);
80
+ return { event: obs.event, observation: { apiAssessment }, feedback };
81
+ }
82
+ function readPage(input, source, media, clean) {
83
+ if (!["text/html", "text/plain", "text/markdown"].includes(media))
84
+ throw new JourneyFault("DOCUMENT_MEDIA_TYPE");
85
+ const { c, event } = input;
86
+ const doc = readDocument(source, media, new URL(input.url), c.scope.docsPathPrefixes, clean);
87
+ const links = [];
88
+ const observation = {};
89
+ let bytes = budgets.observationBytes;
90
+ const requiredPath = c.kind === "api_read" ? c.expect.requiredDocsPath : c.expect.sourcePath;
91
+ for (const path of doc.paths) {
92
+ const linkId = input.prefix + "-l" + (input.linkCount + links.length + 1);
93
+ const cost = Buffer.byteLength(JSON.stringify({ linkId, path })) + 1;
94
+ if (links.length >= budgets.links || cost > Math.min(bytes, 2048)) {
95
+ event.linksTruncated = true;
96
+ if (path === requiredPath)
97
+ observation.hiddenPath = path;
98
+ continue;
99
+ }
100
+ if (path === requiredPath)
101
+ observation.offeredPath = path;
102
+ bytes -= cost;
103
+ links.push({ linkId, path });
104
+ }
105
+ const text = clip(doc.text, bytes);
106
+ const clipped = text !== doc.text;
107
+ if (c.kind === "api_read" && c.expect.requiredDocsExcerpt && event.path === c.expect.requiredDocsPath) {
108
+ observation.excerpt = examineExcerpt(doc.original, doc.text, text, bytes, c.expect.requiredDocsExcerpt, c.expect.apiPath);
109
+ }
110
+ event.preview = documentPreview(clipped);
111
+ return { event, observation: { ...observation, text, clipped }, links, feedback: { text, clipped, links } };
112
+ }
113
+ function analyze(input) {
114
+ const { c, body, event } = input;
115
+ const clean = (s) => terminalText(redactLiteral(s, input.credential));
116
+ const media = input.mediaType.split(";")[0].trim().toLowerCase();
117
+ let source;
118
+ try {
119
+ source = new TextDecoder("utf-8", { fatal: true }).decode(body);
120
+ }
121
+ catch {
122
+ if (event.kind === "api")
123
+ return { event, observation: { jsonCode: "JSON_INVALID" }, feedback: { format: "JSON_INVALID" } };
124
+ return { fault: "DOCUMENT_ENCODING" };
125
+ }
126
+ try {
127
+ if (event.kind === "api" && c.kind === "api_read")
128
+ return readApi(c, { event }, source, media, input.role, clean);
129
+ return readPage(input, source, media, clean);
130
+ }
131
+ catch (error) {
132
+ if (error instanceof JourneyFault)
133
+ return { fault: error.code };
134
+ if (error instanceof HtmlLimitError)
135
+ return { fault: "DOCUMENT_LIMIT" };
136
+ // Parser exceptions can quote the response or a credential-bearing value.
137
+ return { fault: "INTERNAL_ERROR" };
138
+ }
139
+ }
140
+ finishAnalysis(analyze(workerData));
@@ -0,0 +1,74 @@
1
+ export { readJsonFile } from '../utils/read-json-file.js';
2
+ export type JsonScalar = null | string | boolean | number;
3
+ export type Disposition = 'answer' | 'clarify' | 'stop';
4
+ export type JsonType = 'null' | 'string' | 'boolean' | 'number' | 'object' | 'array';
5
+ export type ApiAssertion = {
6
+ id: string;
7
+ pointer: string;
8
+ } & ({
9
+ op: 'exists';
10
+ } | {
11
+ op: 'type';
12
+ type: JsonType;
13
+ } | {
14
+ op: 'equals';
15
+ value: JsonScalar;
16
+ });
17
+ export interface JourneyTarget {
18
+ docsOrigin: string;
19
+ apiOrigin?: string;
20
+ releaseId: string;
21
+ fixtureId: string;
22
+ }
23
+ interface CommonCase {
24
+ schemaVersion: 1;
25
+ id: string;
26
+ prompt: string;
27
+ startPath: string;
28
+ targets: Record<string, JourneyTarget>;
29
+ }
30
+ export interface GroundedCase extends CommonCase {
31
+ kind: 'grounded_answer';
32
+ scope: {
33
+ docsPathPrefixes: string[];
34
+ };
35
+ expect: {
36
+ sourcePath: string;
37
+ excerpt: string;
38
+ } & ({
39
+ disposition: 'answer';
40
+ value: string;
41
+ } | {
42
+ disposition: 'clarify' | 'stop';
43
+ value?: never;
44
+ });
45
+ }
46
+ export interface ApiCase extends CommonCase {
47
+ kind: 'api_read';
48
+ scope: {
49
+ docsPathPrefixes: string[];
50
+ apiPaths: string[];
51
+ };
52
+ expect: {
53
+ apiPath: string;
54
+ requiredDocsPath?: string;
55
+ requiredDocsExcerpt?: string;
56
+ status: number;
57
+ assertions: ApiAssertion[];
58
+ };
59
+ }
60
+ export type JourneyCase = GroundedCase | ApiCase;
61
+ export declare function record(value: unknown, field: string): Record<string, unknown>;
62
+ export declare function fields(obj: Record<string, unknown>, field: string, required: string[], optional?: string[]): void;
63
+ export declare function isIdentifier(value: unknown): value is string;
64
+ export declare function nonempty(value: unknown, field: string): string;
65
+ export declare function isScalar(value: unknown): value is JsonScalar;
66
+ export declare function parseCase(value: unknown): JourneyCase;
67
+ export declare function selectTarget(c: JourneyCase, name: string): JourneyTarget;
68
+ /** Emit sorted object keys directly, including integer-like keys that JSON.stringify
69
+ * would otherwise enumerate in numeric order. Array order stays significant. */
70
+ export declare function canonicalJson(value: unknown): string;
71
+ /** SHA-256 over the UTF-8 bytes of JSON.stringify(s), including its quotes and escapes. */
72
+ export declare function stringDigest(s: string): string;
73
+ export declare function caseFingerprint(c: JourneyCase): string;
74
+ export declare function readCase(path: string): Promise<JourneyCase>;