ag-ui-validate 0.2.0 → 0.3.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 (144) hide show
  1. package/README.md +70 -10
  2. package/dist/{catalog-Ci9dqc1a.cjs → catalog-AB5vuZ8j.cjs} +3 -3
  3. package/dist/catalog-AB5vuZ8j.cjs.map +1 -0
  4. package/dist/{catalog-BglXBNbL.js → catalog-DqTI4VLt.js} +3 -3
  5. package/dist/catalog-DqTI4VLt.js.map +1 -0
  6. package/dist/cli.js +2 -2
  7. package/dist/cli.js.map +1 -1
  8. package/dist/index.cjs +2 -2
  9. package/dist/index.js +2 -2
  10. package/dist/report.cjs +1 -1
  11. package/dist/report.cjs.map +1 -1
  12. package/dist/report.js +1 -1
  13. package/dist/report.js.map +1 -1
  14. package/dist/{src-HmI-kxef.cjs → src-D04i3Vso.cjs} +2 -2
  15. package/dist/src-D04i3Vso.cjs.map +1 -0
  16. package/dist/{src-rGZ2G4qA.js → src-Dcuqz2QC.js} +2 -2
  17. package/dist/src-Dcuqz2QC.js.map +1 -0
  18. package/dist/transport.cjs +1 -1
  19. package/dist/transport.cjs.map +1 -1
  20. package/dist/transport.js +1 -1
  21. package/dist/transport.js.map +1 -1
  22. package/dist/vitest.js +2 -2
  23. package/dist/vitest.js.map +1 -1
  24. package/{src → js/src}/rules/catalog.ts +1 -1
  25. package/{src → js/src}/transport/index.ts +1 -1
  26. package/package.json +14 -13
  27. package/{src/rules → spec}/catalog.json +1 -1
  28. package/spec/event-categories.json +56 -0
  29. package/spec/fixtures/README.md +91 -0
  30. package/spec/fixtures/invalid/AGUI001-first-event-not-run-started/expected.json +10 -0
  31. package/spec/fixtures/invalid/AGUI001-first-event-not-run-started/stream.jsonl +4 -0
  32. package/spec/fixtures/invalid/AGUI002-duplicate-run-started/expected.json +11 -0
  33. package/spec/fixtures/invalid/AGUI002-duplicate-run-started/stream.jsonl +3 -0
  34. package/spec/fixtures/invalid/AGUI003-run-never-terminated/expected.json +10 -0
  35. package/spec/fixtures/invalid/AGUI003-run-never-terminated/stream.jsonl +4 -0
  36. package/spec/fixtures/invalid/AGUI004-event-after-terminal/expected.json +11 -0
  37. package/spec/fixtures/invalid/AGUI004-event-after-terminal/stream.jsonl +3 -0
  38. package/spec/fixtures/invalid/AGUI005-finished-and-error/expected.json +11 -0
  39. package/spec/fixtures/invalid/AGUI005-finished-and-error/stream.jsonl +3 -0
  40. package/spec/fixtures/invalid/AGUI006-step-finished-unmatched/expected.json +11 -0
  41. package/spec/fixtures/invalid/AGUI006-step-finished-unmatched/stream.jsonl +3 -0
  42. package/spec/fixtures/invalid/AGUI007-step-unterminated/expected.json +10 -0
  43. package/spec/fixtures/invalid/AGUI007-step-unterminated/stream.jsonl +3 -0
  44. package/spec/fixtures/invalid/AGUI008-unstable-run-ids/expected.json +12 -0
  45. package/spec/fixtures/invalid/AGUI008-unstable-run-ids/stream.jsonl +2 -0
  46. package/spec/fixtures/invalid/AGUI101-content-without-start/expected.json +11 -0
  47. package/spec/fixtures/invalid/AGUI101-content-without-start/stream.jsonl +3 -0
  48. package/spec/fixtures/invalid/AGUI102-end-without-start/expected.json +11 -0
  49. package/spec/fixtures/invalid/AGUI102-end-without-start/stream.jsonl +3 -0
  50. package/spec/fixtures/invalid/AGUI103-message-unterminated/expected.json +10 -0
  51. package/spec/fixtures/invalid/AGUI103-message-unterminated/stream.jsonl +4 -0
  52. package/spec/fixtures/invalid/AGUI104-duplicate-message-id/expected.json +12 -0
  53. package/spec/fixtures/invalid/AGUI104-duplicate-message-id/stream.jsonl +6 -0
  54. package/spec/fixtures/invalid/AGUI105-empty-content-delta/expected.json +12 -0
  55. package/spec/fixtures/invalid/AGUI105-empty-content-delta/stream.jsonl +5 -0
  56. package/spec/fixtures/invalid/AGUI106-interleaved-same-message-id/expected.json +12 -0
  57. package/spec/fixtures/invalid/AGUI106-interleaved-same-message-id/stream.jsonl +5 -0
  58. package/spec/fixtures/invalid/AGUI201-args-without-start/expected.json +11 -0
  59. package/spec/fixtures/invalid/AGUI201-args-without-start/stream.jsonl +3 -0
  60. package/spec/fixtures/invalid/AGUI202-end-without-start/expected.json +11 -0
  61. package/spec/fixtures/invalid/AGUI202-end-without-start/stream.jsonl +3 -0
  62. package/spec/fixtures/invalid/AGUI203-unterminated-tool-call/expected.json +10 -0
  63. package/spec/fixtures/invalid/AGUI203-unterminated-tool-call/stream.jsonl +4 -0
  64. package/spec/fixtures/invalid/AGUI204-args-not-json/expected.json +10 -0
  65. package/spec/fixtures/invalid/AGUI204-args-not-json/stream.jsonl +6 -0
  66. package/spec/fixtures/invalid/AGUI205-duplicate-tool-call-id/expected.json +12 -0
  67. package/spec/fixtures/invalid/AGUI205-duplicate-tool-call-id/stream.jsonl +5 -0
  68. package/spec/fixtures/invalid/AGUI206-result-before-end/expected.json +12 -0
  69. package/spec/fixtures/invalid/AGUI206-result-before-end/stream.jsonl +5 -0
  70. package/spec/fixtures/invalid/AGUI207-result-unknown-id/expected.json +11 -0
  71. package/spec/fixtures/invalid/AGUI207-result-unknown-id/stream.jsonl +3 -0
  72. package/spec/fixtures/invalid/AGUI208-unknown-parent-message-id/expected.json +11 -0
  73. package/spec/fixtures/invalid/AGUI208-unknown-parent-message-id/stream.jsonl +4 -0
  74. package/spec/fixtures/invalid/AGUI301-delta-before-snapshot/expected.json +10 -0
  75. package/spec/fixtures/invalid/AGUI301-delta-before-snapshot/stream.jsonl +3 -0
  76. package/spec/fixtures/invalid/AGUI302-delta-failed-to-apply/expected.json +11 -0
  77. package/spec/fixtures/invalid/AGUI302-delta-failed-to-apply/stream.jsonl +4 -0
  78. package/spec/fixtures/invalid/AGUI303-invalid-patch-document/expected.json +11 -0
  79. package/spec/fixtures/invalid/AGUI303-invalid-patch-document/stream.jsonl +4 -0
  80. package/spec/fixtures/invalid/AGUI304-midrun-snapshot-discards-deltas/expected.json +10 -0
  81. package/spec/fixtures/invalid/AGUI304-midrun-snapshot-discards-deltas/stream.jsonl +5 -0
  82. package/spec/fixtures/invalid/AGUI305-shared-state-never-established/expected.json +9 -0
  83. package/spec/fixtures/invalid/AGUI305-shared-state-never-established/options.json +5 -0
  84. package/spec/fixtures/invalid/AGUI305-shared-state-never-established/stream.jsonl +5 -0
  85. package/spec/fixtures/invalid/AGUI401-reasoning-content-without-start/expected.json +11 -0
  86. package/spec/fixtures/invalid/AGUI401-reasoning-content-without-start/stream.jsonl +3 -0
  87. package/spec/fixtures/invalid/AGUI402-reasoning-unterminated/expected.json +10 -0
  88. package/spec/fixtures/invalid/AGUI402-reasoning-unterminated/stream.jsonl +3 -0
  89. package/spec/fixtures/invalid/AGUI501-missing-data-prefix/expected.json +9 -0
  90. package/spec/fixtures/invalid/AGUI501-missing-data-prefix/scenario.json +17 -0
  91. package/spec/fixtures/invalid/AGUI502-payload-not-json/expected.json +10 -0
  92. package/spec/fixtures/invalid/AGUI502-payload-not-json/stream.jsonl +3 -0
  93. package/spec/fixtures/invalid/AGUI503-unknown-event-type/expected.json +10 -0
  94. package/spec/fixtures/invalid/AGUI503-unknown-event-type/stream.jsonl +3 -0
  95. package/spec/fixtures/invalid/AGUI504-schema-violation/expected.json +11 -0
  96. package/spec/fixtures/invalid/AGUI504-schema-violation/stream.jsonl +4 -0
  97. package/spec/fixtures/invalid/AGUI505-unexpected-content-type/expected.json +9 -0
  98. package/spec/fixtures/invalid/AGUI505-unexpected-content-type/scenario.json +25 -0
  99. package/spec/fixtures/invalid/AGUI506-keepalive-gap/expected.json +9 -0
  100. package/spec/fixtures/invalid/AGUI506-keepalive-gap/scenario.json +25 -0
  101. package/spec/fixtures/invalid/AGUI507-buffered-response/expected.json +9 -0
  102. package/spec/fixtures/invalid/AGUI507-buffered-response/scenario.json +9 -0
  103. package/spec/fixtures/invalid/AGUI508-connection-dropped/expected.json +17 -0
  104. package/spec/fixtures/invalid/AGUI508-connection-dropped/scenario.json +10 -0
  105. package/spec/fixtures/invalid/AGUI901-raw-wraps-typed-event/expected.json +11 -0
  106. package/spec/fixtures/invalid/AGUI901-raw-wraps-typed-event/stream.jsonl +3 -0
  107. package/spec/fixtures/invalid/AGUI902-no-timestamps/expected.json +9 -0
  108. package/spec/fixtures/invalid/AGUI902-no-timestamps/stream.jsonl +2 -0
  109. package/spec/fixtures/invalid/AGUI903-custom-name-not-namespaced/expected.json +11 -0
  110. package/spec/fixtures/invalid/AGUI903-custom-name-not-namespaced/stream.jsonl +3 -0
  111. package/spec/fixtures/valid/agentic-chat.jsonl +14 -0
  112. package/spec/fixtures/valid/agentic-generative-ui.jsonl +13 -0
  113. package/spec/fixtures/valid/backend-tool-rendering.jsonl +14 -0
  114. package/spec/fixtures/valid/human-in-the-loop.jsonl +13 -0
  115. package/spec/fixtures/valid/predictive-state-updates.expected.json +11 -0
  116. package/spec/fixtures/valid/predictive-state-updates.jsonl +11 -0
  117. package/spec/fixtures/valid/shared-state.jsonl +8 -0
  118. package/spec/fixtures/valid/tool-based-generative-ui.jsonl +5 -0
  119. package/dist/catalog-BglXBNbL.js.map +0 -1
  120. package/dist/catalog-Ci9dqc1a.cjs.map +0 -1
  121. package/dist/src-HmI-kxef.cjs.map +0 -1
  122. package/dist/src-rGZ2G4qA.js.map +0 -1
  123. /package/{src → js/src}/cli-args.ts +0 -0
  124. /package/{src → js/src}/cli.ts +0 -0
  125. /package/{src → js/src}/index.ts +0 -0
  126. /package/{src → js/src}/protocol/event-table.ts +0 -0
  127. /package/{src → js/src}/protocol/jsonpatch.ts +0 -0
  128. /package/{src → js/src}/report/index.ts +0 -0
  129. /package/{src → js/src}/report/json.ts +0 -0
  130. /package/{src → js/src}/report/junit.ts +0 -0
  131. /package/{src → js/src}/report/pretty.ts +0 -0
  132. /package/{src → js/src}/report/sarif.ts +0 -0
  133. /package/{src → js/src}/rules/checks/context.ts +0 -0
  134. /package/{src → js/src}/rules/checks/lifecycle.ts +0 -0
  135. /package/{src → js/src}/rules/checks/reasoning.ts +0 -0
  136. /package/{src → js/src}/rules/checks/state.ts +0 -0
  137. /package/{src → js/src}/rules/checks/text.ts +0 -0
  138. /package/{src → js/src}/rules/checks/toolcalls.ts +0 -0
  139. /package/{src → js/src}/rules/checks/transport.ts +0 -0
  140. /package/{src → js/src}/transport/ndjson.ts +0 -0
  141. /package/{src → js/src}/transport/sse.ts +0 -0
  142. /package/{src → js/src}/types.ts +0 -0
  143. /package/{src → js/src}/vitest/index.ts +0 -0
  144. /package/{src → js/src}/vitest/matcher.ts +0 -0
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":["SEVERITIES","catalogJson"],"sources":["../src/cli-args.ts","../src/rules/catalog.json","../src/rules/catalog.ts","../src/report/pretty.ts","../src/report/json.ts","../src/report/sarif.ts","../src/report/junit.ts","../src/protocol/event-table.ts","../src/rules/checks/context.ts","../src/rules/checks/lifecycle.ts","../src/rules/checks/reasoning.ts","../src/protocol/jsonpatch.ts","../src/rules/checks/state.ts","../src/rules/checks/text.ts","../src/rules/checks/toolcalls.ts","../src/rules/checks/transport.ts","../src/types.ts","../src/index.ts","../src/transport/ndjson.ts","../src/transport/sse.ts","../src/transport/index.ts","../src/cli.ts"],"sourcesContent":["// Pure CLI argument parsing — no Node APIs, so it obeys the core purity rules\n// and tests without spawning processes. The Node-only entry lives in cli.ts.\nimport type { Severity } from \"./types.js\"\n\nexport type CliFormat = \"pretty\" | \"json\" | \"sarif\" | \"junit\"\n\nexport interface CliConfig {\n /** URL, file path, or \"-\" for stdin. Empty only with --help/--version. */\n target: string\n format: CliFormat\n /** true/false forced; null = auto-detect from TTY. */\n color: boolean | null\n maxWarnings?: number\n timeoutMs?: number\n /** Header names lowercased. */\n headers: Record<string, string>\n features?: string[]\n severityOverrides: Record<string, Severity | \"off\">\n /** Write these formats to files in the same run, whatever stdout shows. */\n sarifFile?: string\n junitFile?: string\n jsonFile?: string\n /** Pretty output only: one line per rule with a count, not one per finding. */\n group: boolean\n help: boolean\n version: boolean\n}\n\nexport type ParseResult = { ok: true; config: CliConfig } | { ok: false; error: string }\n\nexport const USAGE = `ag-ui-validate — conformance validator for the AG-UI protocol\n\nUsage:\n ag-ui-validate <url> connect to a live endpoint and validate the stream\n ag-ui-validate <file> validate a recorded stream (SSE capture or NDJSON/JSONL)\n ag-ui-validate - read a recorded stream from stdin\n\nOutput (default: human-readable):\n --json machine-readable report on stdout\n --sarif SARIF 2.1.0 log on stdout (code scanning)\n --junit JUnit XML on stdout (CI test reports)\n --json-file <path> additionally write the JSON report to a file\n --sarif-file <path> additionally write a SARIF log to a file\n --junit-file <path> additionally write JUnit XML to a file\n --group one line per rule with a count (large streams)\n --no-color disable ANSI colors\n\nRules:\n --rule AGUI###=<severity> override a rule's severity (error|warning|info|off)\n --off AGUI### shorthand for --rule AGUI###=off\n --features <a,b,...> declare exercised features (enables e.g. AGUI305)\n --max-warnings <n> exit 1 when warnings exceed n\n\nEndpoint options:\n --header \"Name: value\" extra request header (repeatable)\n --timeout <seconds> abort the request after this long\n\nExit codes: 0 clean, 1 findings at error level (or warnings over --max-warnings), 2 tool failure.\n`\n\nconst SEVERITIES = new Set([\"error\", \"warning\", \"info\", \"off\"])\nconst RULE_ID = /^AGUI\\d{3}$/\n\ninterface Flag {\n takesValue: boolean\n apply(config: CliConfig, value: string): string | null\n}\n\nconst FLAGS: Record<string, Flag> = {\n \"--help\": { takesValue: false, apply: (c) => ((c.help = true), null) },\n \"--version\": { takesValue: false, apply: (c) => ((c.version = true), null) },\n \"--no-color\": { takesValue: false, apply: (c) => ((c.color = false), null) },\n \"--group\": { takesValue: false, apply: (c) => ((c.group = true), null) },\n \"--json\": { takesValue: false, apply: (c) => setFormat(c, \"json\") },\n \"--sarif\": { takesValue: false, apply: (c) => setFormat(c, \"sarif\") },\n \"--junit\": { takesValue: false, apply: (c) => setFormat(c, \"junit\") },\n \"--off\": {\n takesValue: true,\n apply: (c, v) => {\n if (!RULE_ID.test(v)) return `--off expects a rule ID like AGUI203, got '${v}'`\n c.severityOverrides[v] = \"off\"\n return null\n },\n },\n \"--rule\": {\n takesValue: true,\n apply: (c, v) => {\n const eq = v.indexOf(\"=\")\n if (eq === -1) return `--rule expects ID=severity (e.g. AGUI105=warning), got '${v}'`\n const id = v.slice(0, eq)\n const severity = v.slice(eq + 1)\n if (!RULE_ID.test(id)) return `--rule expects a rule ID like AGUI105, got '${id}'`\n if (!SEVERITIES.has(severity)) {\n return `'${severity}' is not a severity; use error, warning, info, or off`\n }\n c.severityOverrides[id] = severity as Severity | \"off\"\n return null\n },\n },\n \"--max-warnings\": {\n takesValue: true,\n apply: (c, v) => {\n const n = Number(v)\n if (!Number.isInteger(n) || n < 0) return `--max-warnings expects a non-negative integer, got '${v}'`\n c.maxWarnings = n\n return null\n },\n },\n \"--timeout\": {\n takesValue: true,\n apply: (c, v) => {\n const n = Number(v)\n if (!Number.isFinite(n) || n <= 0) return `--timeout expects a positive number of seconds, got '${v}'`\n c.timeoutMs = Math.round(n * 1000)\n return null\n },\n },\n \"--header\": {\n takesValue: true,\n apply: (c, v) => {\n const colon = v.indexOf(\":\")\n if (colon <= 0) return `--header expects \"Name: value\", got '${v}'`\n c.headers[v.slice(0, colon).trim().toLowerCase()] = v.slice(colon + 1).trim()\n return null\n },\n },\n \"--sarif-file\": { takesValue: true, apply: (c, v) => ((c.sarifFile = v), null) },\n \"--junit-file\": { takesValue: true, apply: (c, v) => ((c.junitFile = v), null) },\n \"--json-file\": { takesValue: true, apply: (c, v) => ((c.jsonFile = v), null) },\n \"--features\": {\n takesValue: true,\n apply: (c, v) => {\n c.features = v\n .split(\",\")\n .map((f) => f.trim())\n .filter((f) => f !== \"\")\n return null\n },\n },\n}\n\nfunction setFormat(c: CliConfig, format: CliFormat): string | null {\n if (c.format !== \"pretty\" && c.format !== format) {\n return `pick at most one of --json, --sarif, --junit`\n }\n c.format = format\n return null\n}\n\nexport function parseCliArgs(argv: string[]): ParseResult {\n const config: CliConfig = {\n target: \"\",\n format: \"pretty\",\n color: null,\n headers: {},\n severityOverrides: {},\n group: false,\n help: false,\n version: false,\n }\n\n const targets: string[] = []\n for (let i = 0; i < argv.length; i += 1) {\n const arg = argv[i]!\n if (arg === \"-\" || !arg.startsWith(\"-\")) {\n targets.push(arg)\n continue\n }\n let name = arg\n let inlineValue: string | null = null\n const eq = arg.indexOf(\"=\")\n if (eq !== -1) {\n name = arg.slice(0, eq)\n inlineValue = arg.slice(eq + 1)\n }\n const flag = FLAGS[name]\n if (flag === undefined) return { ok: false, error: `unknown flag '${name}'` }\n let value = \"\"\n if (flag.takesValue) {\n if (inlineValue !== null) value = inlineValue\n else if (i + 1 < argv.length) value = argv[(i += 1)]!\n else return { ok: false, error: `${name} requires a value` }\n } else if (inlineValue !== null) {\n return { ok: false, error: `${name} does not take a value` }\n }\n const error = flag.apply(config, value)\n if (error !== null) return { ok: false, error }\n }\n\n if (config.group && config.format !== \"pretty\") {\n return {\n ok: false,\n error: \"--group only applies to the default pretty output, not --json/--sarif/--junit\",\n }\n }\n if (targets.length > 1) {\n return { ok: false, error: `expected exactly one target, got ${targets.length}` }\n }\n if (targets.length === 1) config.target = targets[0]!\n else if (!config.help && !config.version) {\n return { ok: false, error: \"missing target: a URL, a file path, or - for stdin\" }\n }\n return { ok: true, config }\n}\n\nexport function decideExitCode(\n summary: { errors: number; warnings: number; info: number },\n maxWarnings?: number,\n): 0 | 1 {\n if (summary.errors > 0) return 1\n if (maxWarnings !== undefined && summary.warnings > maxWarnings) return 1\n return 0\n}\n","","// Typed loader for the rule catalog. The catalog itself is data\n// (catalog.json) so other implementations can share it; this module gives it\n// types and validates its invariants once at load time.\n//\n// Note the asymmetry: the validator never throws on stream input, but a\n// malformed catalog is a programming error in this package, so the loader\n// throws loudly at import time.\n\nimport catalogJson from \"./catalog.json\"\n\nexport type Severity = \"error\" | \"warning\" | \"info\"\nexport type SeverityOrOff = Severity | \"off\"\n\nconst SEVERITIES: readonly string[] = [\"error\", \"warning\", \"info\"]\nconst LAYERS: readonly string[] = [\"core\", \"transport\"]\n\nexport interface RuleDefinition {\n /** e.g. \"AGUI203\" */\n id: string\n severity: Severity\n title: string\n /** Human template with {placeholder} slots filled per diagnostic. */\n messageTemplate: string\n /** Governing spec section. Mandatory: rules that cannot cite one don't ship. */\n specUrl: string\n /** Exact sentence from the spec section, where one exists. */\n specQuote?: string\n since: string\n /** Canonical AG-UI feature this rule relates to, if any. */\n feature?: string\n /** True when the rule only fires if opts.features declares `feature`. */\n requiresFeature?: boolean\n /** Cross-reference into docs/spec-questions.md for downgraded/ambiguous rules. */\n specQuestion?: string\n /** Where the rule is evaluated. Transport rules are skipped (and the skip\n * reported) when validating recorded input with no transport in play. */\n checkedIn: \"core\" | \"transport\"\n}\n\nexport interface Catalog {\n catalogVersion: string\n spec: string\n rules: readonly RuleDefinition[]\n}\n\n/** Validates catalog data and returns it typed. Throws on structural problems. */\nexport function validateCatalog(data: unknown): Catalog {\n const problems: string[] = []\n const cat = data as Catalog\n if (typeof cat !== \"object\" || cat === null || !Array.isArray(cat.rules)) {\n throw new Error(\"rule catalog: expected an object with a rules array\")\n }\n const seen = new Set<string>()\n for (const rule of cat.rules) {\n const where = rule?.id ?? \"<missing id>\"\n if (!/^AGUI\\d{3}$/.test(rule.id ?? \"\")) problems.push(`${where}: id must match AGUI###`)\n if (seen.has(rule.id)) problems.push(`${where}: duplicate id`)\n seen.add(rule.id)\n if (!SEVERITIES.includes(rule.severity)) problems.push(`${where}: bad severity '${rule.severity}'`)\n if (!rule.title) problems.push(`${where}: missing title`)\n if (!rule.messageTemplate) problems.push(`${where}: missing messageTemplate`)\n if (!rule.specUrl?.startsWith(\"https://\")) problems.push(`${where}: specUrl must be an https URL`)\n if (!rule.since) problems.push(`${where}: missing since`)\n if (!LAYERS.includes(rule.checkedIn)) problems.push(`${where}: bad checkedIn '${rule.checkedIn}'`)\n if (rule.requiresFeature && !rule.feature) problems.push(`${where}: requiresFeature without feature`)\n }\n if (problems.length > 0) {\n throw new Error(`rule catalog is invalid:\\n ${problems.join(\"\\n \")}`)\n }\n return cat\n}\n\nexport const CATALOG: Catalog = validateCatalog(catalogJson)\n\nexport const RULES: ReadonlyMap<string, RuleDefinition> = new Map(\n CATALOG.rules.map((r) => [r.id, r]),\n)\n\n/** Fills a rule's messageTemplate. Unknown placeholders are left intact. */\nexport function formatMessage(rule: RuleDefinition, params: Record<string, unknown>): string {\n return rule.messageTemplate.replace(/\\{(\\w+)\\}/g, (whole, key: string) =>\n key in params ? String(params[key]) : whole,\n )\n}\n","// Human-readable output. Pure string formatting — the CLI decides where it\n// goes and whether a TTY wants color.\nimport { RULES } from \"../rules/catalog.js\"\nimport type { Diagnostic, Report, Severity } from \"../types.js\"\n\nexport interface PrettyOptions {\n color: boolean\n}\n\nconst SYMBOL: Record<Severity, string> = { error: \"✖\", warning: \"⚠\", info: \"ℹ\" }\nconst SGR: Record<Severity, string> = { error: \"31\", warning: \"33\", info: \"36\" }\n\nfunction paint(code: string, s: string, on: boolean): string {\n return on ? `\\x1b[${code}m${s}\\x1b[0m` : s\n}\n\nexport function formatDiagnosticLine(d: Diagnostic, opts: PrettyOptions): string {\n const where = d.eventIndex >= 0 ? `event ${d.eventIndex}` : \"—\"\n const head = paint(SGR[d.severity], `${SYMBOL[d.severity]} ${d.rule}`, opts.color)\n const meta = paint(\"2\", `${d.severity.padEnd(7)} ${where.padEnd(10)}`, opts.color)\n const cite = paint(\"2\", ` ↳ ${d.specUrl}`, opts.color)\n return `${head} ${meta} ${d.message}\\n${cite}`\n}\n\nfunction count(n: number, noun: string): string {\n return `${n} ${noun}${n === 1 ? \"\" : \"s\"}`\n}\n\nconst SEVERITY_RANK: Record<Severity, number> = { error: 0, warning: 1, info: 2 }\nconst SAMPLE_INDEXES = 3\n\n/**\n * One line per rule instead of one per occurrence — for large streams where\n * the same violation repeats. Totals stay honest in the summary; this only\n * changes what is listed.\n */\nexport function formatGroupedDiagnostics(diagnostics: Diagnostic[], opts: PrettyOptions): string {\n const groups = new Map<string, Diagnostic[]>()\n for (const d of diagnostics) {\n const list = groups.get(d.rule)\n if (list === undefined) groups.set(d.rule, [d])\n else list.push(d)\n }\n\n const sorted = [...groups.values()].sort((a, b) => {\n const bySeverity = SEVERITY_RANK[a[0]!.severity] - SEVERITY_RANK[b[0]!.severity]\n return bySeverity !== 0 ? bySeverity : a[0]!.rule.localeCompare(b[0]!.rule)\n })\n\n const lines: string[] = []\n for (const group of sorted) {\n const first = group[0]!\n const title = RULES.get(first.rule)?.title ?? first.message\n const indexes = group.map((d) => d.eventIndex).filter((i) => i >= 0)\n let where: string\n if (indexes.length === 0) {\n where = \"stream-level\"\n } else {\n const sample = indexes.slice(0, SAMPLE_INDEXES).join(\", \")\n const rest = indexes.length - SAMPLE_INDEXES\n where = `events ${sample}${rest > 0 ? ` (+${rest} more)` : \"\"}`\n }\n const head = paint(SGR[first.severity], `${SYMBOL[first.severity]} ${first.rule}`, opts.color)\n const meta = paint(\"2\", `${first.severity.padEnd(7)} ×${group.length}`, opts.color)\n const cite = paint(\"2\", ` ↳ ${first.specUrl}`, opts.color)\n lines.push(`${head} ${meta} ${title} — ${where}`, cite)\n }\n return lines.join(\"\\n\")\n}\n\nexport function formatReportSummary(report: Report, opts: PrettyOptions): string {\n const { errors, warnings, info } = report.summary\n const lines: string[] = []\n\n if (errors + warnings + info === 0) {\n lines.push(\n paint(\"32\", `✔ no conformance violations across ${count(report.eventCount, \"event\")}`, opts.color),\n )\n } else {\n lines.push(\n `${count(errors, \"error\")}, ${count(warnings, \"warning\")}, ${info} info across ${count(report.eventCount, \"event\")}`,\n )\n }\n\n const features = Object.entries(report.features)\n const exercised = features.filter(([, s]) => s === \"exercised\").map(([f]) => f)\n const suffix = exercised.length > 0 ? `: ${exercised.join(\", \")}` : \"\"\n lines.push(`${exercised.length} of ${features.length} AG-UI features exercised${suffix}`)\n\n if (report.skipped.length > 0) {\n lines.push(`${count(report.skipped.length, \"rule\")} not evaluated:`)\n for (const s of report.skipped) {\n lines.push(paint(\"2\", ` – ${s.rule}: ${s.reason}`, opts.color))\n }\n }\n\n for (const e of report.internalErrors) {\n lines.push(paint(\"31\", `! internal validator error: ${e}`, opts.color))\n }\n\n return lines.join(\"\\n\")\n}\n","// Machine-readable report: the core Report plus tool identification, so a\n// stored document is self-describing.\nimport type { Report } from \"../types.js\"\n\nexport interface JsonReportOptions {\n tool: { name: string; version: string }\n /** What was validated: URL, file path, or \"stdin\". */\n target?: string\n}\n\nexport interface JsonReportDocument extends Report {\n tool: { name: string; version: string }\n target?: string\n}\n\nexport function toJsonReport(report: Report, opts: JsonReportOptions): JsonReportDocument {\n const doc: JsonReportDocument = { tool: opts.tool, ...report }\n if (opts.target !== undefined) doc.target = opts.target\n return doc\n}\n","// SARIF 2.1.0 output for code-scanning integrations (e.g. GitHub).\n// Level mapping: error→error, warning→warning, info→note. When the input was a\n// line-oriented file (JSONL/captured SSE fed line-per-event is not guaranteed,\n// so only the caller knows), event N is reported at line N+1 via artifactUri.\nimport { RULES } from \"../rules/catalog.js\"\nimport type { Diagnostic, Report } from \"../types.js\"\n\nexport interface SarifOptions {\n toolVersion: string\n /** URI of the validated artifact; enables line-based locations. */\n artifactUri?: string\n}\n\nexport type SarifLevel = \"error\" | \"warning\" | \"note\"\n\nexport interface SarifResult {\n ruleId: string\n level: SarifLevel\n message: { text: string }\n locations: Array<{\n physicalLocation: {\n artifactLocation: { uri: string }\n region: { startLine: number }\n }\n }>\n}\n\nexport interface SarifLog {\n $schema: string\n version: \"2.1.0\"\n runs: Array<{\n tool: {\n driver: {\n name: string\n version: string\n informationUri: string\n rules: Array<{\n id: string\n helpUri: string\n shortDescription?: { text: string }\n defaultConfiguration?: { level: SarifLevel }\n }>\n }\n }\n results: SarifResult[]\n }>\n}\n\nconst LEVEL: Record<Diagnostic[\"severity\"], SarifLevel> = {\n error: \"error\",\n warning: \"warning\",\n info: \"note\",\n}\n\ntype SarifRule = {\n id: string\n helpUri: string\n shortDescription?: { text: string }\n defaultConfiguration?: { level: SarifLevel }\n}\n\nexport function toSarif(report: Report, opts: SarifOptions): SarifLog {\n const rules = new Map<string, SarifRule>()\n for (const d of report.diagnostics) {\n if (rules.has(d.rule)) continue\n const entry: SarifRule = { id: d.rule, helpUri: d.specUrl }\n const catalog = RULES.get(d.rule)\n if (catalog !== undefined) {\n entry.shortDescription = { text: catalog.title }\n entry.defaultConfiguration = { level: LEVEL[catalog.severity] }\n }\n rules.set(d.rule, entry)\n }\n\n const results: SarifResult[] = report.diagnostics.map((d) => ({\n ruleId: d.rule,\n level: LEVEL[d.severity],\n message: { text: d.message },\n locations:\n opts.artifactUri !== undefined && d.eventIndex >= 0\n ? [\n {\n physicalLocation: {\n artifactLocation: { uri: opts.artifactUri },\n region: { startLine: d.eventIndex + 1 },\n },\n },\n ]\n : [],\n }))\n\n return {\n $schema: \"https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/schemas/sarif-schema-2.1.0.json\",\n version: \"2.1.0\",\n runs: [\n {\n tool: {\n driver: {\n name: \"ag-ui-validate\",\n version: opts.toolVersion,\n informationUri: \"https://github.com/langport-dev/ag-ui-validate\",\n rules: [...rules.values()],\n },\n },\n results,\n },\n ],\n }\n}\n","// JUnit XML output for CI systems. One testcase per finding: errors are\n// <failure>, warnings and info are <skipped> (visible but not build-breaking —\n// the exit code, not the XML, decides pass/fail). A clean report is a single\n// passing testcase so the suite is never empty.\nimport type { Report } from \"../types.js\"\n\nexport interface JUnitOptions {\n /** Suite name — typically the validated target. */\n name: string\n}\n\nfunction esc(s: string): string {\n return s\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&apos;\")\n}\n\nexport function toJUnit(report: Report, opts: JUnitOptions): string {\n const lines: string[] = ['<?xml version=\"1.0\" encoding=\"UTF-8\"?>']\n const suite = esc(opts.name)\n\n if (report.diagnostics.length === 0) {\n lines.push('<testsuites name=\"ag-ui-validate\" tests=\"1\" failures=\"0\" errors=\"0\" skipped=\"0\">')\n lines.push(` <testsuite name=\"${suite}\" tests=\"1\" failures=\"0\" errors=\"0\" skipped=\"0\">`)\n lines.push(\n ` <testcase name=\"AG-UI conformance: no violations across ${report.eventCount} events\" classname=\"${suite}\"/>`,\n )\n lines.push(\" </testsuite>\")\n lines.push(\"</testsuites>\")\n return `${lines.join(\"\\n\")}\\n`\n }\n\n const failures = report.diagnostics.filter((d) => d.severity === \"error\").length\n const skipped = report.diagnostics.length - failures\n const counts = `tests=\"${report.diagnostics.length}\" failures=\"${failures}\" errors=\"0\" skipped=\"${skipped}\"`\n lines.push(`<testsuites name=\"ag-ui-validate\" ${counts}>`)\n lines.push(` <testsuite name=\"${suite}\" ${counts}>`)\n for (const d of report.diagnostics) {\n const where = d.eventIndex >= 0 ? `event ${d.eventIndex}` : \"stream\"\n const name = esc(`${d.rule} (${where})`)\n lines.push(` <testcase name=\"${name}\" classname=\"${suite}\">`)\n const body = `${esc(d.message)}\\n${esc(d.specUrl)}`\n if (d.severity === \"error\") {\n lines.push(` <failure message=\"${esc(d.message)}\">${body}</failure>`)\n } else {\n lines.push(` <skipped message=\"${esc(`${d.severity}: ${d.message}`)}\">${body}</skipped>`)\n }\n lines.push(\" </testcase>\")\n }\n lines.push(\" </testsuite>\")\n lines.push(\"</testsuites>\")\n return `${lines.join(\"\\n\")}\\n`\n}\n","// AUTO-GENERATED from @ag-ui/core v0.0.58 — do not edit by hand.\n// Regenerate with: node scripts/generate-event-table.mjs\n// test/protocol-drift.test.ts fails if this file drifts from the installed SDK.\n\nexport type FieldKind = \"string\" | \"number\" | \"boolean\" | \"object\" | \"array\" | \"any\"\n\nexport type EventCategory =\n | \"lifecycle\"\n | \"text\"\n | \"toolcall\"\n | \"state\"\n | \"activity\"\n | \"reasoning\"\n | \"thinking\"\n | \"special\"\n\nexport interface FieldSpec {\n kind: FieldKind\n required: boolean\n enum?: readonly string[]\n}\n\nexport interface EventSpec {\n category: EventCategory\n /** Present when the SDK marks the event @deprecated; names the replacement. */\n deprecated?: string\n /** Docs section governing this event. */\n specUrl: string\n /** Wire fields beyond the base-event fields (type, timestamp, rawEvent). */\n fields: Readonly<Record<string, FieldSpec>>\n}\n\n/** Version of @ag-ui/core this table was derived from. */\nexport const SDK_VERSION = \"0.0.58\"\n\n/** Canonical wire event types and their schemas, derived from @ag-ui/core. */\nexport const EVENT_TABLE: Readonly<Record<string, EventSpec>> = {\n \"TEXT_MESSAGE_START\": {\n category: \"text\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#textmessagestart\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n \"role\": { kind: \"string\", required: false, enum: [\"developer\",\"system\",\"assistant\",\"user\"] },\n \"name\": { kind: \"string\", required: false },\n },\n },\n \"TEXT_MESSAGE_CONTENT\": {\n category: \"text\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#textmessagecontent\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n \"delta\": { kind: \"string\", required: true },\n },\n },\n \"TEXT_MESSAGE_END\": {\n category: \"text\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#textmessageend\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n },\n },\n \"TEXT_MESSAGE_CHUNK\": {\n category: \"text\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#textmessagechunk\",\n fields: {\n \"messageId\": { kind: \"string\", required: false },\n \"role\": { kind: \"string\", required: false, enum: [\"developer\",\"system\",\"assistant\",\"user\"] },\n \"delta\": { kind: \"string\", required: false },\n \"name\": { kind: \"string\", required: false },\n },\n },\n \"TOOL_CALL_START\": {\n category: \"toolcall\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#toolcallstart\",\n fields: {\n \"toolCallId\": { kind: \"string\", required: true },\n \"toolCallName\": { kind: \"string\", required: true },\n \"parentMessageId\": { kind: \"string\", required: false },\n },\n },\n \"TOOL_CALL_ARGS\": {\n category: \"toolcall\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#toolcallargs\",\n fields: {\n \"toolCallId\": { kind: \"string\", required: true },\n \"delta\": { kind: \"string\", required: true },\n },\n },\n \"TOOL_CALL_END\": {\n category: \"toolcall\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#toolcallend\",\n fields: {\n \"toolCallId\": { kind: \"string\", required: true },\n },\n },\n \"TOOL_CALL_CHUNK\": {\n category: \"toolcall\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#toolcallchunk\",\n fields: {\n \"toolCallId\": { kind: \"string\", required: false },\n \"toolCallName\": { kind: \"string\", required: false },\n \"parentMessageId\": { kind: \"string\", required: false },\n \"delta\": { kind: \"string\", required: false },\n },\n },\n \"TOOL_CALL_RESULT\": {\n category: \"toolcall\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#toolcallresult\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n \"toolCallId\": { kind: \"string\", required: true },\n \"content\": { kind: \"string\", required: true },\n \"role\": { kind: \"string\", required: false, enum: [\"tool\"] },\n },\n },\n \"THINKING_START\": {\n category: \"thinking\",\n deprecated: \"REASONING_START\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#thinking-events-deprecated\",\n fields: {\n \"title\": { kind: \"string\", required: false },\n },\n },\n \"THINKING_END\": {\n category: \"thinking\",\n deprecated: \"REASONING_END\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#thinking-events-deprecated\",\n fields: {\n },\n },\n \"THINKING_TEXT_MESSAGE_START\": {\n category: \"thinking\",\n deprecated: \"REASONING_MESSAGE_START\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#thinking-events-deprecated\",\n fields: {\n },\n },\n \"THINKING_TEXT_MESSAGE_CONTENT\": {\n category: \"thinking\",\n deprecated: \"REASONING_MESSAGE_CONTENT\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#thinking-events-deprecated\",\n fields: {\n \"delta\": { kind: \"string\", required: true },\n },\n },\n \"THINKING_TEXT_MESSAGE_END\": {\n category: \"thinking\",\n deprecated: \"REASONING_MESSAGE_END\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#thinking-events-deprecated\",\n fields: {\n },\n },\n \"STATE_SNAPSHOT\": {\n category: \"state\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#statesnapshot\",\n fields: {\n \"snapshot\": { kind: \"any\", required: true },\n },\n },\n \"STATE_DELTA\": {\n category: \"state\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#statedelta\",\n fields: {\n \"delta\": { kind: \"array\", required: true },\n },\n },\n \"MESSAGES_SNAPSHOT\": {\n category: \"state\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#messagessnapshot\",\n fields: {\n \"messages\": { kind: \"array\", required: true },\n },\n },\n \"ACTIVITY_SNAPSHOT\": {\n category: \"activity\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#activitysnapshot\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n \"activityType\": { kind: \"string\", required: true },\n \"content\": { kind: \"object\", required: true },\n \"replace\": { kind: \"boolean\", required: false },\n },\n },\n \"ACTIVITY_DELTA\": {\n category: \"activity\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#activitydelta\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n \"activityType\": { kind: \"string\", required: true },\n \"patch\": { kind: \"array\", required: true },\n },\n },\n \"RAW\": {\n category: \"special\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#raw\",\n fields: {\n \"event\": { kind: \"any\", required: true },\n \"source\": { kind: \"string\", required: false },\n },\n },\n \"CUSTOM\": {\n category: \"special\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#custom\",\n fields: {\n \"name\": { kind: \"string\", required: true },\n \"value\": { kind: \"any\", required: true },\n },\n },\n \"RUN_STARTED\": {\n category: \"lifecycle\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#runstarted\",\n fields: {\n \"threadId\": { kind: \"string\", required: true },\n \"runId\": { kind: \"string\", required: true },\n \"parentRunId\": { kind: \"string\", required: false },\n \"input\": { kind: \"object\", required: false },\n },\n },\n \"RUN_FINISHED\": {\n category: \"lifecycle\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#runfinished\",\n fields: {\n \"threadId\": { kind: \"string\", required: true },\n \"runId\": { kind: \"string\", required: true },\n \"result\": { kind: \"any\", required: false },\n \"outcome\": { kind: \"object\", required: false },\n \"usage\": { kind: \"array\", required: false },\n },\n },\n \"RUN_ERROR\": {\n category: \"lifecycle\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#runerror\",\n fields: {\n \"message\": { kind: \"string\", required: true },\n \"code\": { kind: \"string\", required: false },\n \"usage\": { kind: \"array\", required: false },\n },\n },\n \"STEP_STARTED\": {\n category: \"lifecycle\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#stepstarted\",\n fields: {\n \"stepName\": { kind: \"string\", required: true },\n },\n },\n \"STEP_FINISHED\": {\n category: \"lifecycle\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#stepfinished\",\n fields: {\n \"stepName\": { kind: \"string\", required: true },\n },\n },\n \"REASONING_START\": {\n category: \"reasoning\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#reasoningstart\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n },\n },\n \"REASONING_MESSAGE_START\": {\n category: \"reasoning\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#reasoningmessagestart\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n \"role\": { kind: \"string\", required: true, enum: [\"reasoning\"] },\n },\n },\n \"REASONING_MESSAGE_CONTENT\": {\n category: \"reasoning\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#reasoningmessagecontent\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n \"delta\": { kind: \"string\", required: true },\n },\n },\n \"REASONING_MESSAGE_END\": {\n category: \"reasoning\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#reasoningmessageend\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n },\n },\n \"REASONING_MESSAGE_CHUNK\": {\n category: \"reasoning\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#reasoningmessagechunk\",\n fields: {\n \"messageId\": { kind: \"string\", required: false },\n \"delta\": { kind: \"string\", required: false },\n },\n },\n \"REASONING_END\": {\n category: \"reasoning\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#reasoningend\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n },\n },\n \"REASONING_ENCRYPTED_VALUE\": {\n category: \"reasoning\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#reasoningencryptedvalue\",\n fields: {\n \"subtype\": { kind: \"string\", required: true, enum: [\"tool-call\",\"message\"] },\n \"entityId\": { kind: \"string\", required: true },\n \"encryptedValue\": { kind: \"string\", required: true },\n },\n },\n}\n\n/** All canonical wire `type` values, in @ag-ui/core enum order. */\nexport const EVENT_TYPES: readonly string[] = Object.keys(EVENT_TABLE)\n\n/**\n * Wire types documented as drafts (https://docs.ag-ui.com/drafts/overview) but\n * not yet in @ag-ui/core. Not errors: reported at info severity.\n */\nexport const DRAFT_EVENT_TYPES: readonly string[] = [\"META\"]\n","// Internal validator state and the API each check module sees.\n// Everything here is engine-internal; the public surface lives in src/types.ts.\n\nimport type { CanonicalFeature } from \"../../types.js\"\n\n/** Emit a diagnostic for rule `id`; params fill the catalog messageTemplate. */\nexport type EmitFn = (\n ruleId: string,\n params: Record<string, unknown>,\n extra?: {\n eventIndex?: number\n pointer?: string\n relatedEventIndex?: number\n /** Instance-level severity floor (e.g. draft META downgrades AGUI503). */\n severity?: \"error\" | \"warning\" | \"info\"\n /** Instance-level spec link override (e.g. draft docs page). */\n specUrl?: string\n /** Appended to the formatted message (e.g. casing hints). */\n messageSuffix?: string\n },\n) => void\n\nexport interface OpenToolCall {\n startIndex: number\n args: string\n sawArgs: boolean\n}\n\nexport interface RunState {\n /** null while the run is implicit (stream opened without RUN_STARTED). */\n runId: string | null\n threadId: string | null\n startIndex: number\n implicit: boolean\n terminal: { type: string; index: number } | null\n\n openMessages: Map<string, { startIndex: number }>\n /** messageId -> index of the event that closed it. */\n closedMessages: Map<string, number>\n /** Every message id observed (starts, chunks, snapshots, tool results). */\n knownMessageIds: Set<string>\n\n openToolCalls: Map<string, OpenToolCall>\n closedToolCalls: Map<string, number>\n /** Ids also known from MESSAGES_SNAPSHOT history. */\n knownToolCallIds: Set<string>\n\n /** stepName -> re-entrant open count (SQ-10) and first-open index. */\n openSteps: Map<string, { count: number; firstIndex: number }>\n\n openReasoningBlocks: Map<string, number>\n openReasoningMessages: Map<string, number>\n\n state: {\n /** True once a STATE_SNAPSHOT established an observable base (SQ-1). */\n known: boolean\n value: unknown\n deltasSinceSnapshot: number\n snapshotSeen: boolean\n agui301Fired: boolean\n }\n\n /** Implicit streams opened by *_CHUNK events; closed by any other event. */\n textChunk: { messageId: string; startIndex: number } | null\n toolChunk: { toolCallId: string; startIndex: number; args: string; sawArgs: boolean } | null\n reasoningChunk: { messageId: string; startIndex: number } | null\n}\n\nexport function newRunState(init: {\n runId: string | null\n threadId: string | null\n startIndex: number\n implicit: boolean\n}): RunState {\n return {\n ...init,\n terminal: null,\n openMessages: new Map(),\n closedMessages: new Map(),\n knownMessageIds: new Set(),\n openToolCalls: new Map(),\n closedToolCalls: new Map(),\n knownToolCallIds: new Set(),\n openSteps: new Map(),\n openReasoningBlocks: new Map(),\n openReasoningMessages: new Map(),\n state: { known: false, value: undefined, deltasSinceSnapshot: 0, snapshotSeen: false, agui301Fired: false },\n textChunk: null,\n toolChunk: null,\n reasoningChunk: null,\n }\n}\n\nexport interface StreamState {\n eventCount: number\n sawTimestamp: boolean\n anySnapshot: boolean\n agui001Fired: boolean\n features: Set<CanonicalFeature>\n}\n\n/** What a per-event check handler receives. */\nexport interface CheckApi {\n index: number\n type: string\n event: Record<string, unknown>\n run: RunState\n stream: StreamState\n emit: EmitFn\n feature: (f: CanonicalFeature) => void\n}\n\n/** Reads a field only if it is a string (schema problems already reported). */\nexport function str(event: Record<string, unknown>, field: string): string | undefined {\n const v = event[field]\n return typeof v === \"string\" ? v : undefined\n}\n","// Lifecycle rules: AGUI001–AGUI008. Run open/terminate logic lives in the\n// engine (src/index.ts) because it owns run-scope resets; this module holds\n// the step pairing and the RUN_FINISHED id-stability check.\n\nimport type { CheckApi, RunState, EmitFn } from \"./context.js\"\nimport { str } from \"./context.js\"\n\nexport function handleStepEvent(api: CheckApi): void {\n const { type, event, run, emit, index } = api\n const stepName = str(event, \"stepName\")\n if (stepName === undefined) return\n\n if (type === \"STEP_STARTED\") {\n const open = run.openSteps.get(stepName)\n if (open !== undefined) {\n open.count += 1 // re-entrant same-name steps are tolerated (SQ-10)\n } else {\n run.openSteps.set(stepName, { count: 1, firstIndex: index })\n }\n return\n }\n\n if (type === \"STEP_FINISHED\") {\n const open = run.openSteps.get(stepName)\n if (open === undefined) {\n emit(\"AGUI006\", { stepName }, { pointer: \"/stepName\" })\n return\n }\n open.count -= 1\n if (open.count === 0) run.openSteps.delete(stepName)\n }\n}\n\n/** AGUI008 — RUN_FINISHED must carry the ids RUN_STARTED established. */\nexport function checkRunIdStability(api: CheckApi): void {\n const { event, run, emit } = api\n if (run.implicit) return // no RUN_STARTED to compare against\n for (const field of [\"threadId\", \"runId\"] as const) {\n const actual = str(api.event, field)\n const expected = field === \"threadId\" ? run.threadId : run.runId\n if (actual !== undefined && expected !== null && actual !== expected) {\n emit(\"AGUI008\", { field, actual, expected }, {\n pointer: `/${field}`,\n relatedEventIndex: run.startIndex,\n })\n }\n }\n void event\n}\n\n/** AGUI007 — open steps when the run reaches a clean end. */\nexport function endOfRunSteps(run: RunState, emit: EmitFn, atIndex: number): void {\n for (const [stepName, open] of run.openSteps) {\n emit(\"AGUI007\", { stepName }, {\n eventIndex: atIndex,\n relatedEventIndex: open.firstIndex,\n })\n }\n}\n","// Reasoning rules: AGUI401–AGUI402, plus REASONING_MESSAGE_CHUNK handling.\n//\n// Per SQ-4: block-level nesting (REASONING_MESSAGE_* inside\n// REASONING_START/END) is only described as \"a typical flow\" by the docs, so\n// it is NOT enforced. AGUI401 enforces the message-level pairing, mirroring\n// the text message rules; AGUI402 reports unterminated starts at warning.\n\nimport type { CheckApi, RunState, EmitFn } from \"./context.js\"\nimport { str } from \"./context.js\"\n\nexport function handleReasoningEvent(api: CheckApi): void {\n const { type, event, run, emit, index } = api\n\n switch (type) {\n case \"REASONING_START\": {\n const id = str(event, \"messageId\")\n if (id !== undefined) run.openReasoningBlocks.set(id, index)\n return\n }\n\n case \"REASONING_END\": {\n const id = str(event, \"messageId\")\n if (id !== undefined) run.openReasoningBlocks.delete(id)\n return\n }\n\n case \"REASONING_MESSAGE_START\": {\n const id = str(event, \"messageId\")\n if (id !== undefined) run.openReasoningMessages.set(id, index)\n return\n }\n\n case \"REASONING_MESSAGE_CONTENT\": {\n const id = str(event, \"messageId\")\n if (id === undefined) return\n const openChunk = run.reasoningChunk !== null && run.reasoningChunk.messageId === id\n if (!run.openReasoningMessages.has(id) && !openChunk) {\n emit(\"AGUI401\", { messageId: id }, { pointer: \"/messageId\" })\n }\n return\n }\n\n case \"REASONING_MESSAGE_END\": {\n const id = str(event, \"messageId\")\n if (id !== undefined) run.openReasoningMessages.delete(id)\n return\n }\n\n case \"REASONING_MESSAGE_CHUNK\": {\n const id = str(event, \"messageId\")\n if (id === undefined) {\n if (run.reasoningChunk === null) {\n emit(\"AGUI504\", { type, detail: \"first REASONING_MESSAGE_CHUNK must include messageId\" }, {\n pointer: \"/messageId\",\n })\n return\n }\n if (event.delta === \"\") run.reasoningChunk = null // documented implicit close\n return\n }\n if (run.reasoningChunk !== null && run.reasoningChunk.messageId !== id) {\n run.reasoningChunk = null\n }\n if (event.delta === \"\") {\n run.reasoningChunk = null // empty delta implicitly closes the message\n return\n }\n if (run.reasoningChunk === null) {\n run.reasoningChunk = { messageId: id, startIndex: index }\n }\n return\n }\n\n // REASONING_ENCRYPTED_VALUE: schema-checked only; no ordering rules cited.\n }\n}\n\n/** Chunked reasoning also closes on any non-reasoning event (documented). */\nexport function closeReasoningChunk(run: RunState): void {\n run.reasoningChunk = null\n}\n\n/** AGUI402 — unterminated reasoning at a clean run end. */\nexport function endOfRunReasoning(run: RunState, emit: EmitFn, atIndex: number): void {\n for (const [id, startIndex] of run.openReasoningBlocks) {\n emit(\"AGUI402\", { startType: \"REASONING_START\", messageId: id }, {\n eventIndex: atIndex,\n relatedEventIndex: startIndex,\n })\n }\n for (const [id, startIndex] of run.openReasoningMessages) {\n emit(\"AGUI402\", { startType: \"REASONING_MESSAGE_START\", messageId: id }, {\n eventIndex: atIndex,\n relatedEventIndex: startIndex,\n })\n }\n}\n","// Minimal RFC 6902 (JSON Patch) + RFC 6901 (JSON Pointer) implementation.\n// Hand-rolled so the core keeps zero runtime dependencies. Immutable: the\n// input document is never mutated; ops apply atomically (all or none).\n\nexport type PatchResult =\n | { ok: true; result: unknown }\n | { ok: false; error: string; opIndex: number }\n\nexport interface PatchShapeProblem {\n /** Human-readable problem. */\n error: string\n /** Index of the offending op, or -1 when the document itself is not an array. */\n opIndex: number\n /** RFC 6901 pointer into the patch document, e.g. \"/0/op\". */\n pointer: string\n}\n\nconst OPS = [\"add\", \"remove\", \"replace\", \"move\", \"copy\", \"test\"] as const\ntype OpName = (typeof OPS)[number]\n\n/** RFC 6901: \"\" → whole document; \"/a/b\" → [\"a\", \"b\"]. Returns null when invalid. */\nexport function parsePointer(pointer: unknown): string[] | null {\n if (typeof pointer !== \"string\") return null\n if (pointer === \"\") return []\n if (!pointer.startsWith(\"/\")) return null\n return pointer\n .slice(1)\n .split(\"/\")\n .map((t) => t.replace(/~1/g, \"/\").replace(/~0/g, \"~\"))\n}\n\n/** Structural validation of a patch document, without applying it. */\nexport function validatePatchShape(patch: unknown): PatchShapeProblem | null {\n if (!Array.isArray(patch)) {\n return { error: \"patch document must be an array of operations\", opIndex: -1, pointer: \"\" }\n }\n for (let i = 0; i < patch.length; i++) {\n const op = patch[i]\n if (typeof op !== \"object\" || op === null || Array.isArray(op)) {\n return { error: `operation ${i} is not an object`, opIndex: i, pointer: `/${i}` }\n }\n const o = op as Record<string, unknown>\n if (!OPS.includes(o.op as OpName)) {\n return { error: `operation ${i} has invalid op '${String(o.op)}'`, opIndex: i, pointer: `/${i}/op` }\n }\n if (parsePointer(o.path) === null) {\n return { error: `operation ${i} (${String(o.op)}) has invalid path`, opIndex: i, pointer: `/${i}/path` }\n }\n if ((o.op === \"add\" || o.op === \"replace\" || o.op === \"test\") && !(\"value\" in o)) {\n return { error: `operation ${i} (${String(o.op)}) is missing value`, opIndex: i, pointer: `/${i}` }\n }\n if ((o.op === \"move\" || o.op === \"copy\") && parsePointer(o.from) === null) {\n return { error: `operation ${i} (${String(o.op)}) is missing or has invalid from`, opIndex: i, pointer: `/${i}` }\n }\n }\n return null\n}\n\nfunction clone(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(clone)\n if (typeof value === \"object\" && value !== null) {\n const out: Record<string, unknown> = {}\n for (const [k, v] of Object.entries(value)) out[k] = clone(v)\n return out\n }\n return value\n}\n\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true\n if (Array.isArray(a) && Array.isArray(b)) {\n return a.length === b.length && a.every((v, i) => deepEqual(v, b[i]))\n }\n if (typeof a === \"object\" && a !== null && typeof b === \"object\" && b !== null && !Array.isArray(a) && !Array.isArray(b)) {\n const ka = Object.keys(a)\n const kb = Object.keys(b as object)\n return ka.length === kb.length && ka.every((k) => deepEqual((a as Record<string, unknown>)[k], (b as Record<string, unknown>)[k]))\n }\n return false\n}\n\nfunction arrayIndex(token: string, length: number, allowAppend: boolean): number | null {\n if (allowAppend && token === \"-\") return length\n if (!/^(0|[1-9]\\d*)$/.test(token)) return null\n const i = Number(token)\n return i > length ? null : i\n}\n\ninterface Located {\n parent: Record<string, unknown> | unknown[] | null // null → the document root itself\n key: string | number\n exists: boolean\n value: unknown\n}\n\nfunction locate(doc: unknown, tokens: string[], forAdd: boolean): Located | string {\n if (tokens.length === 0) return { parent: null, key: \"\", exists: true, value: doc }\n let current = doc\n for (let i = 0; i < tokens.length - 1; i++) {\n const token = tokens[i]!\n if (Array.isArray(current)) {\n const idx = arrayIndex(token, current.length, false)\n if (idx === null || idx >= current.length) return `path segment '/${token}' does not exist`\n current = current[idx]\n } else if (typeof current === \"object\" && current !== null) {\n const obj = current as Record<string, unknown>\n if (!(token in obj)) return `path segment '/${token}' does not exist`\n current = obj[token]\n } else {\n return `path segment '/${token}' is not an object or array`\n }\n }\n const last = tokens[tokens.length - 1]!\n if (Array.isArray(current)) {\n const idx = arrayIndex(last, current.length, forAdd)\n if (idx === null) return `'${last}' is not a valid index for an array of length ${current.length}`\n return { parent: current, key: idx, exists: idx < current.length, value: current[idx] }\n }\n if (typeof current === \"object\" && current !== null) {\n const obj = current as Record<string, unknown>\n return { parent: obj, key: last, exists: last in obj, value: obj[last] }\n }\n return `target of '/${last}' is not an object or array`\n}\n\n/** Applies an RFC 6902 patch. Validates shape first; never throws. */\nexport function applyPatch(doc: unknown, patch: unknown): PatchResult {\n const shape = validatePatchShape(patch)\n if (shape !== null) return { ok: false, error: shape.error, opIndex: shape.opIndex }\n\n let result = clone(doc)\n const ops = patch as Record<string, unknown>[]\n\n const getAt = (pointer: string): { ok: true; value: unknown } | { ok: false; error: string } => {\n const loc = locate(result, parsePointer(pointer)!, false)\n if (typeof loc === \"string\") return { ok: false, error: `${pointer}: ${loc}` }\n if (!loc.exists) return { ok: false, error: `${pointer} does not exist` }\n return { ok: true, value: loc.value }\n }\n\n const setAt = (pointer: string, value: unknown, mustExist: boolean): string | null => {\n const tokens = parsePointer(pointer)!\n if (tokens.length === 0) {\n result = value\n return null\n }\n const loc = locate(result, tokens, !mustExist)\n if (typeof loc === \"string\") return `${pointer}: ${loc}`\n if (mustExist && !loc.exists) return `${pointer} does not exist`\n if (Array.isArray(loc.parent)) {\n if (mustExist) loc.parent[loc.key as number] = value\n else loc.parent.splice(loc.key as number, 0, value)\n } else {\n loc.parent![loc.key as string] = value\n }\n return null\n }\n\n const removeAt = (pointer: string): { ok: true; removed: unknown } | { ok: false; error: string } => {\n const tokens = parsePointer(pointer)!\n if (tokens.length === 0) return { ok: false, error: \"cannot remove the whole document\" }\n const loc = locate(result, tokens, false)\n if (typeof loc === \"string\") return { ok: false, error: `${pointer}: ${loc}` }\n if (!loc.exists) return { ok: false, error: `${pointer} does not exist` }\n if (Array.isArray(loc.parent)) loc.parent.splice(loc.key as number, 1)\n else delete loc.parent![loc.key as string]\n return { ok: true, removed: loc.value }\n }\n\n for (let i = 0; i < ops.length; i++) {\n const op = ops[i]!\n const path = op.path as string\n let error: string | null = null\n\n switch (op.op as OpName) {\n case \"add\":\n error = setAt(path, clone(op.value), false)\n break\n case \"replace\":\n error = setAt(path, clone(op.value), true)\n break\n case \"remove\": {\n const r = removeAt(path)\n if (!r.ok) error = r.error\n break\n }\n case \"move\": {\n const from = op.from as string\n if (path.startsWith(`${from}/`)) {\n error = `cannot move ${from} into its own child ${path}`\n break\n }\n const r = removeAt(from)\n if (!r.ok) { error = r.error; break }\n error = setAt(path, r.removed, false)\n break\n }\n case \"copy\": {\n const r = getAt(op.from as string)\n if (!r.ok) { error = r.error; break }\n error = setAt(path, clone(r.value), false)\n break\n }\n case \"test\": {\n const r = getAt(path)\n if (!r.ok) error = r.error\n else if (!deepEqual(r.value, op.value)) error = `test failed at ${path}`\n break\n }\n }\n\n if (error !== null) return { ok: false, error, opIndex: i }\n }\n return { ok: true, result }\n}\n\n/** RFC 6901 token escaping, for building diagnostic pointers. */\nexport function escapePointerToken(token: string): string {\n return token.replace(/~/g, \"~0\").replace(/\\//g, \"~1\")\n}\n","// State rules: AGUI301–AGUI305, plus MESSAGES_SNAPSHOT history harvesting.\n\nimport { applyPatch, validatePatchShape } from \"../../protocol/jsonpatch.js\"\nimport type { CheckApi } from \"./context.js\"\n\nexport function handleStateEvent(api: CheckApi): void {\n const { type, event, run, stream, emit } = api\n\n switch (type) {\n case \"STATE_SNAPSHOT\": {\n api.feature(\"shared-state\")\n if (run.state.deltasSinceSnapshot > 0) {\n emit(\"AGUI304\", { deltaCount: run.state.deltasSinceSnapshot }, {})\n }\n run.state.known = true\n run.state.value = event.snapshot\n run.state.snapshotSeen = true\n run.state.deltasSinceSnapshot = 0\n stream.anySnapshot = true\n return\n }\n\n case \"STATE_DELTA\": {\n api.feature(\"shared-state\")\n const delta = event.delta\n if (!Array.isArray(delta)) return // AGUI504 already reported the kind mismatch\n const shape = validatePatchShape(delta)\n if (shape !== null) {\n emit(\"AGUI303\", { error: shape.error }, { pointer: `/delta${shape.pointer}` })\n return\n }\n if (!run.state.snapshotSeen && !run.state.agui301Fired) {\n // The base may be seeded out-of-band via RunAgentInput.state (SQ-1),\n // so this is informational, and patch application is not judged until\n // a snapshot establishes an observable base.\n emit(\"AGUI301\", {}, {})\n run.state.agui301Fired = true\n }\n if (run.state.known) {\n const applied = applyPatch(run.state.value, delta)\n if (applied.ok) {\n run.state.value = applied.result\n } else {\n emit(\"AGUI302\", { error: applied.error }, { pointer: `/delta/${applied.opIndex}` })\n }\n }\n run.state.deltasSinceSnapshot += 1\n return\n }\n\n case \"MESSAGES_SNAPSHOT\": {\n // Snapshots can carry history from before this capture: harvest ids so\n // reference checks (AGUI207/AGUI208) don't false-positive on them.\n const messages = event.messages\n if (!Array.isArray(messages)) return\n for (const message of messages) {\n if (typeof message !== \"object\" || message === null) continue\n const m = message as Record<string, unknown>\n if (typeof m.id === \"string\") run.knownMessageIds.add(m.id)\n if (Array.isArray(m.toolCalls)) {\n for (const call of m.toolCalls) {\n if (typeof call === \"object\" && call !== null) {\n const id = (call as Record<string, unknown>).id\n if (typeof id === \"string\") run.knownToolCallIds.add(id)\n }\n }\n }\n }\n return\n }\n }\n}\n","// Text message rules: AGUI101–AGUI106, plus TEXT_MESSAGE_CHUNK stream handling.\n\nimport type { CheckApi, RunState, EmitFn } from \"./context.js\"\nimport { str } from \"./context.js\"\n\nexport function handleTextEvent(api: CheckApi): void {\n const { type, event, run, emit, index } = api\n api.feature(\"agentic-chat\")\n\n switch (type) {\n case \"TEXT_MESSAGE_START\": {\n const id = str(event, \"messageId\")\n if (id === undefined) return\n if (run.openMessages.has(id)) {\n emit(\"AGUI106\", { messageId: id }, {\n pointer: \"/messageId\",\n relatedEventIndex: run.openMessages.get(id)!.startIndex,\n })\n return\n }\n if (run.closedMessages.has(id)) {\n emit(\"AGUI104\", { messageId: id }, {\n pointer: \"/messageId\",\n relatedEventIndex: run.closedMessages.get(id)!,\n })\n return\n }\n run.openMessages.set(id, { startIndex: index })\n run.knownMessageIds.add(id)\n return\n }\n\n case \"TEXT_MESSAGE_CONTENT\": {\n const id = str(event, \"messageId\")\n if (id === undefined) return\n const open = run.openMessages.get(id)\n if (open === undefined) {\n const closedAt = run.closedMessages.get(id)\n emit(\"AGUI101\", { messageId: id }, {\n pointer: \"/messageId\",\n ...(closedAt !== undefined ? { relatedEventIndex: closedAt } : {}),\n })\n return\n }\n if (event.delta === \"\") {\n emit(\"AGUI105\", { messageId: id }, { pointer: \"/delta\", relatedEventIndex: open.startIndex })\n }\n return\n }\n\n case \"TEXT_MESSAGE_END\": {\n const id = str(event, \"messageId\")\n if (id === undefined) return\n if (!run.openMessages.has(id)) {\n emit(\"AGUI102\", { messageId: id }, { pointer: \"/messageId\" })\n return\n }\n run.openMessages.delete(id)\n run.closedMessages.set(id, index)\n return\n }\n\n case \"TEXT_MESSAGE_CHUNK\": {\n const id = str(event, \"messageId\")\n if (id === undefined) {\n // Continuation chunks may omit messageId; the first chunk must not\n // (docs: \"First chunk for a message must include messageId\").\n if (run.textChunk === null) {\n emit(\"AGUI504\", { type, detail: \"first TEXT_MESSAGE_CHUNK for a message must include messageId\" }, {\n pointer: \"/messageId\",\n })\n }\n return\n }\n // Mixing chunk and explicit forms on one id is undefined behaviour\n // (SQ-9): tolerated, treated as content for the open message.\n if (run.openMessages.has(id)) return\n if (run.textChunk !== null && run.textChunk.messageId === id) return\n closeTextChunk(run, index)\n if (run.closedMessages.has(id)) {\n emit(\"AGUI104\", { messageId: id }, {\n pointer: \"/messageId\",\n relatedEventIndex: run.closedMessages.get(id)!,\n })\n return\n }\n run.textChunk = { messageId: id, startIndex: index }\n run.knownMessageIds.add(id)\n return\n }\n }\n}\n\n/** Chunk streams close implicitly on the next non-chunk event. */\nexport function closeTextChunk(run: RunState, atIndex: number): void {\n if (run.textChunk === null) return\n run.closedMessages.set(run.textChunk.messageId, atIndex)\n run.textChunk = null\n}\n\n/** AGUI103 — open messages when the run reaches a clean end. */\nexport function endOfRunText(run: RunState, emit: EmitFn, atIndex: number): void {\n for (const [id, open] of run.openMessages) {\n emit(\"AGUI103\", { messageId: id }, {\n eventIndex: atIndex,\n relatedEventIndex: open.startIndex,\n })\n }\n}\n","// Tool call rules: AGUI201–AGUI208, plus TOOL_CALL_CHUNK stream handling.\n\nimport type { CheckApi, RunState, EmitFn } from \"./context.js\"\nimport { str } from \"./context.js\"\n\nexport function handleToolCallEvent(api: CheckApi): void {\n const { type, event, run, emit, index } = api\n api.feature(\"backend-tool-rendering\")\n\n switch (type) {\n case \"TOOL_CALL_START\": {\n const id = str(event, \"toolCallId\")\n if (id === undefined) return\n if (run.openToolCalls.has(id) || run.closedToolCalls.has(id)) {\n const related = run.openToolCalls.get(id)?.startIndex ?? run.closedToolCalls.get(id)!\n emit(\"AGUI205\", { toolCallId: id }, { pointer: \"/toolCallId\", relatedEventIndex: related })\n return\n }\n run.openToolCalls.set(id, { startIndex: index, args: \"\", sawArgs: false })\n const parent = str(event, \"parentMessageId\")\n if (parent !== undefined && !run.knownMessageIds.has(parent)) {\n emit(\"AGUI208\", { parentMessageId: parent }, { pointer: \"/parentMessageId\" })\n }\n return\n }\n\n case \"TOOL_CALL_ARGS\": {\n const id = str(event, \"toolCallId\")\n if (id === undefined) return\n const open = run.openToolCalls.get(id)\n if (open === undefined) {\n emit(\"AGUI201\", { toolCallId: id }, { pointer: \"/toolCallId\" })\n return\n }\n const delta = str(event, \"delta\")\n if (delta !== undefined) {\n open.args += delta\n open.sawArgs = true\n }\n return\n }\n\n case \"TOOL_CALL_END\": {\n const id = str(event, \"toolCallId\")\n if (id === undefined) return\n const open = run.openToolCalls.get(id)\n if (open === undefined) {\n emit(\"AGUI202\", { toolCallId: id }, { pointer: \"/toolCallId\" })\n return\n }\n run.openToolCalls.delete(id)\n run.closedToolCalls.set(id, index)\n checkArgsJson(id, open, emit, index)\n return\n }\n\n case \"TOOL_CALL_RESULT\": {\n const id = str(event, \"toolCallId\")\n if (id !== undefined) {\n const open = run.openToolCalls.get(id)\n if (open !== undefined) {\n emit(\"AGUI206\", { toolCallId: id }, {\n pointer: \"/toolCallId\",\n relatedEventIndex: open.startIndex,\n })\n } else if (!run.closedToolCalls.has(id) && !run.knownToolCallIds.has(id)) {\n emit(\"AGUI207\", { toolCallId: id }, { pointer: \"/toolCallId\" })\n }\n }\n // The result is itself a tool message in the conversation.\n const messageId = str(event, \"messageId\")\n if (messageId !== undefined) run.knownMessageIds.add(messageId)\n return\n }\n\n case \"TOOL_CALL_CHUNK\": {\n const id = str(event, \"toolCallId\")\n const delta = str(event, \"delta\")\n if (id === undefined) {\n if (run.toolChunk === null) {\n emit(\"AGUI504\", { type, detail: \"first TOOL_CALL_CHUNK for a tool call must include toolCallId and toolCallName\" }, {\n pointer: \"/toolCallId\",\n })\n return\n }\n if (delta !== undefined) {\n run.toolChunk.args += delta\n run.toolChunk.sawArgs = true\n }\n return\n }\n // SQ-9: chunk continuing an explicitly-opened call — treat as args.\n const openExplicit = run.openToolCalls.get(id)\n if (openExplicit !== undefined) {\n if (delta !== undefined) {\n openExplicit.args += delta\n openExplicit.sawArgs = true\n }\n return\n }\n if (run.toolChunk !== null && run.toolChunk.toolCallId === id) {\n if (delta !== undefined) {\n run.toolChunk.args += delta\n run.toolChunk.sawArgs = true\n }\n return\n }\n closeToolChunk(run, emit, index)\n if (run.closedToolCalls.has(id)) {\n emit(\"AGUI205\", { toolCallId: id }, {\n pointer: \"/toolCallId\",\n relatedEventIndex: run.closedToolCalls.get(id)!,\n })\n return\n }\n if (str(event, \"toolCallName\") === undefined) {\n emit(\"AGUI504\", { type, detail: \"first TOOL_CALL_CHUNK for a tool call must include toolCallName\" }, {\n pointer: \"/toolCallName\",\n })\n }\n run.toolChunk = {\n toolCallId: id,\n startIndex: index,\n args: delta ?? \"\",\n sawArgs: delta !== undefined && delta.length > 0,\n }\n return\n }\n }\n}\n\nfunction checkArgsJson(\n id: string,\n call: { startIndex: number; args: string; sawArgs: boolean },\n emit: EmitFn,\n atIndex: number,\n): void {\n // A call that streamed no args at all is fine (a no-argument tool).\n if (!call.sawArgs || call.args.length === 0) return\n try {\n JSON.parse(call.args)\n } catch (e) {\n emit(\"AGUI204\", { toolCallId: id, error: e instanceof Error ? e.message : String(e) }, {\n eventIndex: atIndex,\n relatedEventIndex: call.startIndex,\n })\n }\n}\n\n/** Chunk streams close implicitly on the next non-chunk event. */\nexport function closeToolChunk(run: RunState, emit: EmitFn, atIndex: number): void {\n if (run.toolChunk === null) return\n const { toolCallId, startIndex, args, sawArgs } = run.toolChunk\n run.toolChunk = null\n run.closedToolCalls.set(toolCallId, atIndex)\n checkArgsJson(toolCallId, { startIndex, args, sawArgs }, emit, atIndex)\n}\n\n/** AGUI203 — open tool calls when the run reaches a clean end. */\nexport function endOfRunToolCalls(run: RunState, emit: EmitFn, atIndex: number): void {\n for (const [id, open] of run.openToolCalls) {\n emit(\"AGUI203\", { toolCallId: id }, {\n eventIndex: atIndex,\n relatedEventIndex: open.startIndex,\n })\n }\n}\n","// Transport rules (AGUI501, AGUI505–AGUI508) are only checkable against a\n// live connection: SSE framing, Content-Type, keepalive timing, flush\n// behaviour, abnormal EOF. The core cannot observe any of that from a parsed\n// event sequence, so it reports these rules as skipped — never silently —\n// and the transport layer (ag-ui-validate/transport, M5) evaluates them.\n//\n// AGUI502/503/504 are transport-adjacent but *are* checkable here (the core\n// accepts raw JSON strings), so they live in the engine, not this list.\n\nimport { CATALOG } from \"../catalog.js\"\n\nexport const TRANSPORT_SKIP_REASON =\n \"transport-layer rule; only checkable against a live connection (validated by ag-ui-validate/transport)\"\n\nexport const TRANSPORT_RULE_IDS: readonly string[] = CATALOG.rules\n .filter((r) => r.checkedIn === \"transport\")\n .map((r) => r.id)\n","import type { Severity, SeverityOrOff } from \"./rules/catalog.js\"\n\nexport type { Severity, SeverityOrOff }\n\n/** A single conformance finding. */\nexport interface Diagnostic {\n /** Rule ID, e.g. \"AGUI203\". */\n rule: string\n severity: Severity\n /** Human-readable, includes the offending id/value. */\n message: string\n /**\n * 0-based position in the stream of the event this diagnostic is about.\n * Stream-level diagnostics (e.g. AGUI902) use -1.\n */\n eventIndex: number\n /** The event's declared type, if parseable. */\n eventType?: string\n /** RFC 6901 JSON pointer into the event, e.g. \"/toolCallId\". */\n pointer?: string\n /** e.g. the unterminated TOOL_CALL_START this refers back to. */\n relatedEventIndex?: number\n /** Link to the governing spec section. Always populated. */\n specUrl: string\n}\n\n/** The seven canonical AG-UI features (from the AG-UI Dojo). */\nexport type CanonicalFeature =\n | \"agentic-chat\"\n | \"backend-tool-rendering\"\n | \"human-in-the-loop\"\n | \"agentic-generative-ui\"\n | \"tool-based-generative-ui\"\n | \"shared-state\"\n | \"predictive-state-updates\"\n\nexport const CANONICAL_FEATURES: readonly CanonicalFeature[] = [\n \"agentic-chat\",\n \"backend-tool-rendering\",\n \"human-in-the-loop\",\n \"agentic-generative-ui\",\n \"tool-based-generative-ui\",\n \"shared-state\",\n \"predictive-state-updates\",\n]\n\n/**\n * Feature-matrix status. Capability discovery (getCapabilities()) is\n * out-of-band and invisible to a passive stream observer, so this matrix is\n * inferred from observed events; features whose exercise cannot be\n * distinguished passively are \"not-inferable\". See docs/spec-questions.md SQ-13.\n */\nexport type FeatureStatus = \"exercised\" | \"not-exercised\" | \"not-inferable\"\n\nexport type FeatureMatrix = Record<CanonicalFeature, FeatureStatus>\n\nexport interface Summary {\n errors: number\n warnings: number\n info: number\n}\n\nexport interface SkippedRule {\n rule: string\n reason: string\n}\n\nexport interface Report {\n diagnostics: Diagnostic[]\n summary: Summary\n features: FeatureMatrix\n /**\n * Rules that were not evaluated in this mode and why — e.g. transport rules\n * when validating recorded input. Skips are reported, never silent.\n */\n skipped: SkippedRule[]\n eventCount: number\n /**\n * Unexpected internal validator errors. The validator never throws on any\n * input; if a check itself crashes, the message lands here instead.\n */\n internalErrors: string[]\n}\n\nexport type ValidationLayer = \"core\" | \"transport\"\n\nexport interface ValidatorOptions {\n /** Pins the rule set to a spec version. Only \"0.x\" exists today. */\n spec?: \"0.x\"\n /**\n * Declared features. Enables feature-conditional rules (e.g. AGUI305 fires\n * only when \"shared-state\" is declared).\n */\n features?: string[]\n /** Per-rule severity overrides; \"off\" disables a rule. */\n severityOverrides?: Record<string, SeverityOrOff>\n /**\n * Which rule layers are being evaluated. \"core\" is always on. Wrapping\n * layers that check transport rules (via emitExternal) declare \"transport\"\n * so those rules stop being reported as skipped. Default: [\"core\"].\n */\n layers?: ValidationLayer[]\n}\n\nexport interface Validator {\n /**\n * Feed one event — a parsed object, or a raw JSON string (malformed JSON is\n * a diagnostic, not an exception). Returns diagnostics detectable at this\n * event, in stream order. Never throws.\n */\n feed(event: unknown): Diagnostic[]\n /**\n * End-of-stream checks (unterminated tool calls, missing RUN_FINISHED, …).\n * Idempotent: second and later calls return []. Never throws.\n */\n finalize(): Diagnostic[]\n /** Cumulative report over everything fed so far. Never throws. */\n report(): Report\n /**\n * For wrapping layers (transport, CLI): report a layer-checked rule through\n * the same catalog formatting, severity overrides, and summary as core\n * diagnostics. Returns the diagnostic, or null when the rule is unknown\n * (recorded in internalErrors) or overridden off. Never throws.\n */\n emitExternal(\n rule: string,\n params?: Record<string, unknown>,\n extra?: { eventIndex?: number; pointer?: string; relatedEventIndex?: number },\n ): Diagnostic | null\n /**\n * For wrapping layers: declare that a rule was NOT evaluated and why (e.g.\n * timing rules on recorded input). The entry appears in report().skipped,\n * replacing any layer-computed entry for the same rule. Never throws.\n */\n markSkipped(rule: string, reason: string): void\n}\n","// ag-ui-validate core: a pure function over an AG-UI event sequence.\n// Zero I/O, zero runtime dependencies, isomorphic. Transports, the CLI, and\n// the Vitest matcher are thin wrappers over this module.\n//\n// Two invariants hold everywhere here:\n// - the validator NEVER throws on input: broken input is its input;\n// - every diagnostic cites the spec section that governs it (specUrl).\n\nimport { DRAFT_EVENT_TYPES, EVENT_TABLE, EVENT_TYPES, SDK_VERSION } from \"./protocol/event-table.js\"\nimport type { EventSpec } from \"./protocol/event-table.js\"\nimport { RULES, formatMessage } from \"./rules/catalog.js\"\nimport type { CheckApi, EmitFn, RunState, StreamState } from \"./rules/checks/context.js\"\nimport { newRunState, str } from \"./rules/checks/context.js\"\nimport { checkRunIdStability, endOfRunSteps, handleStepEvent } from \"./rules/checks/lifecycle.js\"\nimport { closeReasoningChunk, endOfRunReasoning, handleReasoningEvent } from \"./rules/checks/reasoning.js\"\nimport { handleStateEvent } from \"./rules/checks/state.js\"\nimport { closeTextChunk, endOfRunText, handleTextEvent } from \"./rules/checks/text.js\"\nimport { closeToolChunk, endOfRunToolCalls, handleToolCallEvent } from \"./rules/checks/toolcalls.js\"\nimport { TRANSPORT_RULE_IDS, TRANSPORT_SKIP_REASON } from \"./rules/checks/transport.js\"\nimport type {\n CanonicalFeature,\n Diagnostic,\n FeatureMatrix,\n Report,\n Severity,\n Validator,\n ValidatorOptions,\n} from \"./types.js\"\nimport { CANONICAL_FEATURES } from \"./types.js\"\n\nexport * from \"./types.js\"\nexport { CATALOG, RULES, formatMessage, validateCatalog } from \"./rules/catalog.js\"\nexport type { Catalog, RuleDefinition, Severity as RuleSeverity, SeverityOrOff } from \"./rules/catalog.js\"\nexport { EVENT_TABLE, EVENT_TYPES, SDK_VERSION } from \"./protocol/event-table.js\"\nexport type { EventCategory, EventSpec, FieldKind, FieldSpec } from \"./protocol/event-table.js\"\nexport { applyPatch, validatePatchShape } from \"./protocol/jsonpatch.js\"\n\nconst DRAFTS_META_URL = \"https://docs.ag-ui.com/drafts/meta-events\"\n\n// Features whose exercise cannot be distinguished on a passive stream: both\n// generative-UI features need knowledge of the frontend's tool/component\n// registry, which is out-of-band (see SQ-13).\nconst NOT_INFERABLE: readonly CanonicalFeature[] = [\n \"agentic-generative-ui\",\n \"tool-based-generative-ui\",\n]\n\n/** \"runStarted\" → \"RUN_STARTED\": case-insensitive match against wire types. */\nconst CANONICAL_BY_SQUASHED: ReadonlyMap<string, string> = new Map(\n EVENT_TYPES.map((t) => [t.replace(/_/g, \"\").toLowerCase(), t]),\n)\n\nfunction describeValue(v: unknown): string {\n if (v === null) return \"null\"\n if (Array.isArray(v)) return \"array\"\n return typeof v\n}\n\nexport function createValidator(opts: ValidatorOptions = {}): Validator {\n const overrides = opts.severityOverrides ?? {}\n const declaredFeatures = new Set(opts.features ?? [])\n const layers = new Set([\"core\", ...(opts.layers ?? [])])\n\n const diagnostics: Diagnostic[] = []\n const internalErrors: string[] = []\n const explicitSkips = new Map<string, string>()\n const stream: StreamState = {\n eventCount: 0,\n sawTimestamp: false,\n anySnapshot: false,\n agui001Fired: false,\n features: new Set(),\n }\n let run: RunState | null = null\n let finalized = false\n\n function mkEmit(batch: Diagnostic[], current: { index: number; type: string } | null): EmitFn {\n return (ruleId, params, extra = {}) => {\n const rule = RULES.get(ruleId)\n if (rule === undefined) {\n internalErrors.push(`emit() for unknown rule ${ruleId}`)\n return\n }\n const override = overrides[ruleId]\n if (override === \"off\") return\n const severity: Severity = override ?? extra.severity ?? rule.severity\n const aboutCurrentEvent = extra.eventIndex === undefined && current !== null\n const diag: Diagnostic = {\n rule: ruleId,\n severity,\n message: formatMessage(rule, params) + (extra.messageSuffix ?? \"\"),\n eventIndex: extra.eventIndex ?? current?.index ?? -1,\n specUrl: extra.specUrl ?? rule.specUrl,\n }\n if (aboutCurrentEvent) diag.eventType = current.type\n if (extra.pointer !== undefined) diag.pointer = extra.pointer\n if (extra.relatedEventIndex !== undefined) diag.relatedEventIndex = extra.relatedEventIndex\n diagnostics.push(diag)\n batch.push(diag)\n }\n }\n\n function validateSchema(type: string, spec: EventSpec, ev: Record<string, unknown>, emit: EmitFn): void {\n for (const [field, fs] of Object.entries(spec.fields)) {\n const v = ev[field]\n if (v === undefined) {\n if (fs.required) {\n emit(\"AGUI504\", { type, detail: `missing required field '${field}' (${fs.kind})` }, {\n pointer: `/${field}`,\n })\n }\n continue\n }\n let kindOk = true\n switch (fs.kind) {\n case \"string\":\n case \"number\":\n case \"boolean\":\n kindOk = typeof v === fs.kind\n break\n case \"array\":\n kindOk = Array.isArray(v)\n break\n case \"object\":\n kindOk = typeof v === \"object\" && v !== null && !Array.isArray(v)\n break\n case \"any\":\n break\n }\n if (!kindOk) {\n emit(\"AGUI504\", { type, detail: `field '${field}' must be ${fs.kind === \"array\" ? \"an\" : \"a\"} ${fs.kind}, got ${describeValue(v)}` }, {\n pointer: `/${field}`,\n })\n continue\n }\n if (fs.enum !== undefined && typeof v === \"string\" && !fs.enum.includes(v)) {\n emit(\"AGUI504\", { type, detail: `field '${field}' must be one of ${fs.enum.join(\"|\")}, got '${v}'` }, {\n pointer: `/${field}`,\n })\n }\n }\n }\n\n /** Chunk streams close implicitly on any event of a different type. */\n function closeChunks(r: RunState, emit: EmitFn, atIndex: number, except?: string): void {\n if (except !== \"TEXT_MESSAGE_CHUNK\") closeTextChunk(r, atIndex)\n if (except !== \"TOOL_CALL_CHUNK\") closeToolChunk(r, emit, atIndex)\n if (except !== \"REASONING_MESSAGE_CHUNK\") closeReasoningChunk(r)\n }\n\n /** Unterminated-at-run-end rules. Only on a *clean* end (RUN_FINISHED or a\n * stream that just stops): after RUN_ERROR, open streams are expected\n * debris of the failure, and flagging them would manufacture noise. */\n function endOfRunChecks(r: RunState, emit: EmitFn, atIndex: number): void {\n endOfRunText(r, emit, atIndex)\n endOfRunToolCalls(r, emit, atIndex)\n endOfRunSteps(r, emit, atIndex)\n endOfRunReasoning(r, emit, atIndex)\n }\n\n /** Opens the implicit run scope for streams that never announced one. */\n function ensureRun(index: number, type: string, emit: EmitFn): RunState {\n if (run === null) {\n if (!stream.agui001Fired) {\n emit(\"AGUI001\", { type }, {})\n stream.agui001Fired = true\n }\n run = newRunState({ runId: null, threadId: null, startIndex: index, implicit: true })\n }\n return run\n }\n\n function processEvent(input: unknown, batch: Diagnostic[]): void {\n const index = stream.eventCount\n stream.eventCount += 1\n\n // 1. Parse. Malformed input is a diagnostic, never an exception.\n let parsed: unknown = input\n if (typeof input === \"string\") {\n try {\n parsed = JSON.parse(input)\n } catch (e) {\n mkEmit(batch, { index, type: \"\" })(\"AGUI502\", {\n error: e instanceof Error ? e.message : String(e),\n })\n return\n }\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n mkEmit(batch, { index, type: \"\" })(\"AGUI502\", {\n error: `payload is ${describeValue(parsed)}, expected a JSON object`,\n })\n return\n }\n const ev = parsed as Record<string, unknown>\n\n // 2. The declared type is the key to everything else.\n if (typeof ev.type !== \"string\") {\n mkEmit(batch, { index, type: \"\" })(\"AGUI504\", {\n type: \"(untyped)\",\n detail: \"event has no string 'type' property\",\n }, { pointer: \"/type\" })\n return\n }\n const type = ev.type\n const emit = mkEmit(batch, { index, type })\n\n // 3. Base-event fields.\n if (\"timestamp\" in ev && ev.timestamp !== undefined) {\n if (typeof ev.timestamp === \"number\") stream.sawTimestamp = true\n else emit(\"AGUI504\", { type, detail: `field 'timestamp' must be a number, got ${describeValue(ev.timestamp)}` }, { pointer: \"/timestamp\" })\n }\n\n // 4. Unknown types: AGUI503 (documented drafts at info; casing hints for\n // near-misses — SQ-7).\n const spec = EVENT_TABLE[type]\n if (spec === undefined) {\n if (DRAFT_EVENT_TYPES.includes(type)) {\n emit(\"AGUI503\", { type, sdkVersion: SDK_VERSION }, {\n severity: \"info\",\n specUrl: DRAFTS_META_URL,\n messageSuffix: \" — documented draft event type, not yet in @ag-ui/core\",\n })\n } else {\n const canonical = CANONICAL_BY_SQUASHED.get(type.replace(/[_\\-\\s]/g, \"\").toLowerCase())\n emit(\"AGUI503\", { type, sdkVersion: SDK_VERSION }, {\n ...(canonical !== undefined\n ? { messageSuffix: ` — did you mean '${canonical}'? AG-UI wire types use SCREAMING_SNAKE_CASE` }\n : {}),\n })\n }\n return\n }\n\n // 5. Schema validation for the declared type (AGUI504).\n validateSchema(type, spec, ev, emit)\n\n // 6. Lifecycle position.\n if (type === \"RUN_STARTED\") {\n if (run === null) {\n run = newRunState({\n runId: str(ev, \"runId\") ?? null,\n threadId: str(ev, \"threadId\") ?? null,\n startIndex: index,\n implicit: false,\n })\n } else if (run.terminal !== null) {\n // A new run after a clean terminal: multi-run streams are legal\n // (serialized logs branch via parentRunId — SQ-6). Fresh scope.\n run = newRunState({\n runId: str(ev, \"runId\") ?? null,\n threadId: str(ev, \"threadId\") ?? null,\n startIndex: index,\n implicit: false,\n })\n } else if (run.implicit) {\n // The stream opened without RUN_STARTED (AGUI001 already fired); the\n // late start legitimizes the implicit scope rather than double-firing.\n closeChunks(run, emit, index)\n run.implicit = false\n run.runId = str(ev, \"runId\") ?? null\n run.threadId = str(ev, \"threadId\") ?? null\n } else {\n closeChunks(run, emit, index)\n emit(\"AGUI002\", { runId: str(ev, \"runId\") ?? \"(missing)\" }, {\n relatedEventIndex: run.startIndex,\n })\n }\n return\n }\n\n const r = ensureRun(index, type, emit)\n\n // 7. Nothing may follow a terminal event (AGUI004/AGUI005).\n if (r.terminal !== null) {\n const terminalType = r.terminal.type\n if ((type === \"RUN_FINISHED\" || type === \"RUN_ERROR\") && type !== terminalType) {\n emit(\"AGUI005\", { type, terminalType }, { relatedEventIndex: r.terminal.index })\n } else {\n emit(\"AGUI004\", { type, terminalType }, { relatedEventIndex: r.terminal.index })\n }\n return\n }\n\n closeChunks(r, emit, index, type)\n\n // 8. Terminal events.\n if (type === \"RUN_FINISHED\" || type === \"RUN_ERROR\") {\n if (type === \"RUN_FINISHED\") {\n checkRunIdStability(api(index, type, ev, r, emit))\n endOfRunChecks(r, emit, index)\n const outcome = ev.outcome\n if (typeof outcome === \"object\" && outcome !== null &&\n (outcome as Record<string, unknown>).type === \"interrupt\") {\n stream.features.add(\"human-in-the-loop\")\n }\n }\n r.terminal = { type, index }\n return\n }\n\n // 9. Per-category checks.\n const a = api(index, type, ev, r, emit)\n switch (spec.category) {\n case \"lifecycle\":\n handleStepEvent(a) // STEP_STARTED / STEP_FINISHED\n break\n case \"text\":\n handleTextEvent(a)\n break\n case \"toolcall\":\n handleToolCallEvent(a)\n break\n case \"state\":\n handleStateEvent(a)\n break\n case \"reasoning\":\n handleReasoningEvent(a)\n break\n case \"thinking\":\n // Deprecated but valid (SQ-8): schema-checked above, no ordering rules\n // in the catalog yet — a \"deprecated event used\" rule is proposed\n // upstream rather than invented here.\n break\n case \"activity\":\n // No activity rules in the catalog yet.\n break\n case \"special\":\n if (type === \"RAW\") {\n const wrapped = ev.event\n if (typeof wrapped === \"object\" && wrapped !== null) {\n const wrappedType = (wrapped as Record<string, unknown>).type\n if (typeof wrappedType === \"string\" && EVENT_TABLE[wrappedType] !== undefined) {\n emit(\"AGUI901\", { wrappedType }, { pointer: \"/event/type\" })\n }\n }\n } else if (type === \"CUSTOM\") {\n const name = str(ev, \"name\")\n if (name !== undefined) {\n if (name === \"PredictState\") stream.features.add(\"predictive-state-updates\")\n if (!/[.:/]/.test(name)) emit(\"AGUI903\", { name }, { pointer: \"/name\" })\n }\n }\n break\n }\n }\n\n function api(\n index: number,\n type: string,\n event: Record<string, unknown>,\n r: RunState,\n emit: EmitFn,\n ): CheckApi {\n return {\n index,\n type,\n event,\n run: r,\n stream,\n emit,\n feature: (f) => stream.features.add(f),\n }\n }\n\n return {\n feed(event: unknown): Diagnostic[] {\n const batch: Diagnostic[] = []\n try {\n processEvent(event, batch)\n } catch (e) {\n internalErrors.push(`feed(event ${stream.eventCount - 1}): ${e instanceof Error ? (e.stack ?? e.message) : String(e)}`)\n }\n return batch\n },\n\n finalize(): Diagnostic[] {\n if (finalized) return []\n finalized = true\n const batch: Diagnostic[] = []\n const emit = mkEmit(batch, null)\n try {\n if (run !== null && run.terminal === null) {\n closeChunks(run, emit, -1)\n emit(\"AGUI003\", { runId: run.runId ?? \"(unknown)\" }, {\n eventIndex: -1,\n relatedEventIndex: run.startIndex,\n })\n endOfRunChecks(run, emit, -1)\n }\n if (stream.eventCount > 0 && !stream.sawTimestamp) {\n emit(\"AGUI902\", { eventCount: stream.eventCount }, { eventIndex: -1 })\n }\n if (declaredFeatures.has(\"shared-state\") && !stream.anySnapshot) {\n emit(\"AGUI305\", {}, { eventIndex: -1 })\n }\n } catch (e) {\n internalErrors.push(`finalize(): ${e instanceof Error ? (e.stack ?? e.message) : String(e)}`)\n }\n return batch\n },\n\n emitExternal(rule, params = {}, extra = {}): Diagnostic | null {\n const batch: Diagnostic[] = []\n try {\n mkEmit(batch, null)(rule, params, extra)\n } catch (e) {\n internalErrors.push(`emitExternal(${rule}): ${e instanceof Error ? e.message : String(e)}`)\n }\n return batch[0] ?? null\n },\n\n markSkipped(rule, reason): void {\n explicitSkips.set(String(rule), String(reason))\n },\n\n report(): Report {\n const summary = { errors: 0, warnings: 0, info: 0 }\n for (const d of diagnostics) {\n if (d.severity === \"error\") summary.errors += 1\n else if (d.severity === \"warning\") summary.warnings += 1\n else summary.info += 1\n }\n\n const features = {} as FeatureMatrix\n for (const f of CANONICAL_FEATURES) {\n features[f] = NOT_INFERABLE.includes(f)\n ? \"not-inferable\"\n : stream.features.has(f)\n ? \"exercised\"\n : \"not-exercised\"\n }\n\n let skipped = layers.has(\"transport\")\n ? []\n : TRANSPORT_RULE_IDS\n .filter((id) => overrides[id] !== \"off\")\n .map((rule) => ({ rule, reason: TRANSPORT_SKIP_REASON }))\n if (!declaredFeatures.has(\"shared-state\") && overrides.AGUI305 !== \"off\") {\n skipped.push({\n rule: \"AGUI305\",\n reason: \"only evaluated when the 'shared-state' feature is declared via options.features\",\n })\n }\n for (const [rule, severity] of Object.entries(overrides)) {\n if (severity === \"off\" && RULES.has(rule)) {\n skipped.push({ rule, reason: \"disabled by severityOverrides\" })\n }\n }\n if (explicitSkips.size > 0) {\n skipped = skipped.filter((s) => !explicitSkips.has(s.rule))\n for (const [rule, reason] of explicitSkips) skipped.push({ rule, reason })\n }\n\n return {\n diagnostics: [...diagnostics],\n summary,\n features,\n skipped,\n eventCount: stream.eventCount,\n internalErrors: [...internalErrors],\n }\n },\n }\n}\n","// Incremental NDJSON (application/x-ndjson) line splitter. Yields non-empty\n// lines with trailing CR stripped; the core decides whether they parse.\n\nexport async function* ndjsonLines(source: AsyncIterable<Uint8Array>): AsyncGenerator<string> {\n const decoder = new TextDecoder(\"utf-8\")\n let buffer = \"\"\n\n function clean(line: string): string | null {\n const trimmed = line.endsWith(\"\\r\") ? line.slice(0, -1) : line\n return trimmed.trim() === \"\" ? null : trimmed\n }\n\n for await (const chunk of source) {\n buffer += decoder.decode(chunk, { stream: true })\n let i: number\n while ((i = buffer.indexOf(\"\\n\")) !== -1) {\n const line = clean(buffer.slice(0, i))\n buffer = buffer.slice(i + 1)\n if (line !== null) yield line\n }\n }\n buffer += decoder.decode()\n const last = clean(buffer)\n if (last !== null) yield last\n}\n","// WHATWG-compliant incremental SSE (text/event-stream) parser.\n// https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation\n//\n// Beyond plain parsing it surfaces framing anomalies relevant to AGUI501:\n// - json-line-without-data-prefix: a line that looks like a JSON payload but\n// has no \"data:\" field prefix. Spec-wise it is an unknown field and gets\n// silently dropped by every SSE client — the classic broken-server bug.\n// - truncated-frame: the stream ended mid-frame (pending data never\n// dispatched, or a partial final line).\n\nexport type SseProblemCode = \"json-line-without-data-prefix\" | \"truncated-frame\"\n\nexport type SseItem =\n | { kind: \"event\"; data: string; event?: string; id?: string }\n | { kind: \"comment\"; text: string }\n | { kind: \"problem\"; code: SseProblemCode; detail: string }\n\nconst truncate = (s: string, n: number): string => (s.length > n ? `${s.slice(0, n)}…` : s)\n\nexport async function* sseItems(source: AsyncIterable<Uint8Array>): AsyncGenerator<SseItem> {\n const decoder = new TextDecoder(\"utf-8\")\n let buffer = \"\"\n let sawFirstChars = false\n let dataLines: string[] = []\n let eventName = \"\"\n let lastId: string | undefined\n\n function handleLine(line: string): SseItem | null {\n if (line === \"\") {\n // Dispatch. Per spec, an empty data buffer dispatches nothing.\n const data = dataLines.join(\"\\n\")\n const hadData = dataLines.length > 0\n dataLines = []\n const name = eventName\n eventName = \"\"\n if (!hadData || data === \"\") return null\n const item: SseItem = { kind: \"event\", data }\n if (name !== \"\") item.event = name\n if (lastId !== undefined) item.id = lastId\n return item\n }\n if (line.startsWith(\":\")) return { kind: \"comment\", text: line.slice(1) }\n\n const colon = line.indexOf(\":\")\n const field = colon === -1 ? line : line.slice(0, colon)\n let value = colon === -1 ? \"\" : line.slice(colon + 1)\n if (value.startsWith(\" \")) value = value.slice(1)\n\n switch (field) {\n case \"data\":\n dataLines.push(value)\n return null\n case \"event\":\n eventName = value\n return null\n case \"id\":\n if (!value.includes(\"\\0\")) lastId = value\n return null\n case \"retry\":\n return null\n default: {\n // Unknown field: ignored per spec — but a JSON-looking line is almost\n // certainly a payload missing its \"data:\" prefix, silently lost.\n const trimmed = line.trimStart()\n if (trimmed.startsWith(\"{\") || trimmed.startsWith(\"[\")) {\n return {\n kind: \"problem\",\n code: \"json-line-without-data-prefix\",\n detail: `line '${truncate(trimmed, 60)}' looks like a JSON payload but lacks the 'data:' field prefix, so SSE clients silently drop it`,\n }\n }\n return null\n }\n }\n }\n\n function* drainLines(eof: boolean): Generator<SseItem> {\n for (;;) {\n const nl = buffer.indexOf(\"\\n\")\n const cr = buffer.indexOf(\"\\r\")\n let end: number\n let next: number\n if (cr !== -1 && (nl === -1 || cr < nl)) {\n // Hold back a trailing CR mid-stream: it may be a CRLF split across\n // chunk boundaries.\n if (cr === buffer.length - 1 && !eof) return\n end = cr\n next = buffer[cr + 1] === \"\\n\" ? cr + 2 : cr + 1\n } else if (nl !== -1) {\n end = nl\n next = nl + 1\n } else {\n return\n }\n const line = buffer.slice(0, end)\n buffer = buffer.slice(next)\n const item = handleLine(line)\n if (item !== null) yield item\n }\n }\n\n for await (const chunk of source) {\n buffer += decoder.decode(chunk, { stream: true })\n if (!sawFirstChars && buffer.length > 0) {\n if (buffer.startsWith(\"\")) buffer = buffer.slice(1)\n sawFirstChars = true\n }\n yield* drainLines(false)\n }\n buffer += decoder.decode()\n yield* drainLines(true)\n\n if (buffer !== \"\") {\n yield {\n kind: \"problem\",\n code: \"truncated-frame\",\n detail: `stream ended mid-line: '${truncate(buffer, 60)}' (no trailing newline; the frame was never dispatched)`,\n }\n } else if (dataLines.length > 0) {\n yield {\n kind: \"problem\",\n code: \"truncated-frame\",\n detail: \"stream ended with a pending frame that was never terminated by a blank line\",\n }\n }\n}\n","// ag-ui-validate/transport: SSE + NDJSON clients over the pure core.\n// This is the I/O layer — fetch, streams, and clocks live here, never in the\n// core. Uses only web-platform APIs (fetch, TextDecoder, AbortController) so\n// it stays isomorphic: Node 20+, browsers, Deno, Workers.\n\nimport { createValidator } from \"../index.js\"\nimport type { Diagnostic, Report, ValidationLayer, ValidatorOptions } from \"../index.js\"\nimport { ndjsonLines } from \"./ndjson.js\"\nimport { sseItems } from \"./sse.js\"\n\nexport { ndjsonLines } from \"./ndjson.js\"\nexport { sseItems } from \"./sse.js\"\nexport type { SseItem, SseProblemCode } from \"./sse.js\"\n\nconst DEFAULT_KEEPALIVE_MS = 30_000\n\nexport interface TransportRequestInit {\n method: string\n headers: Record<string, string>\n body?: string\n signal?: AbortSignal\n}\n\nexport interface TransportResponseLike {\n status: number\n headers: { get(name: string): string | null }\n body: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array> | null\n}\n\nexport type FetchLike = (url: string, init: TransportRequestInit) => Promise<TransportResponseLike>\n\n/** Operational failure (unreachable endpoint, non-2xx, no body) — distinct\n * from conformance findings, which are diagnostics. */\nexport class TransportError extends Error {\n status?: number\n constructor(message: string, status?: number) {\n super(message)\n this.name = \"TransportError\"\n if (status !== undefined) this.status = status\n }\n}\n\nexport interface TransportOptions {\n /** Options passed through to createValidator (\"transport\" layer is added). */\n validator?: ValidatorOptions\n /** Extra request headers (validateEndpoint only). */\n headers?: Record<string, string>\n /** RunAgentInput to POST; defaults to a minimal valid input with one user message. */\n input?: unknown\n method?: \"POST\" | \"GET\"\n /** AGUI506 window; default 30 000 ms. */\n keepaliveWindowMs?: number\n /** Abort the request after this long (validateEndpoint only). */\n timeoutMs?: number\n /** Injectable fetch (tests, custom stacks). Default: globalThis.fetch. */\n fetchImpl?: FetchLike\n /** Injectable clock for keepalive/buffering measurement. Default: Date.now. */\n now?: () => number\n /**\n * The body is a recording (file, stdin) rather than a live connection.\n * Timing-based rules (AGUI506, AGUI507) and mid-stream disconnect detection\n * (AGUI508) are meaningless for recordings; they are reported as skipped\n * with a reason instead of risking false positives, and read failures become\n * TransportErrors (tool failure) rather than AGUI508 findings.\n */\n recorded?: boolean\n signal?: AbortSignal\n /** Called after each fed event with the diagnostics it produced. */\n onEvent?: (raw: string, diagnostics: Diagnostic[]) => void\n /** Called for every diagnostic as soon as it is detected. */\n onDiagnostic?: (diagnostic: Diagnostic) => void\n}\n\nexport interface TransportResult {\n report: Report\n /** HTTP status; null when validating a bare body/recording. */\n status: number | null\n contentType: string | null\n /** Events fed to the validator (SSE frames / NDJSON lines). */\n eventCount: number\n /** Present when the connection failed mid-stream (see AGUI508). */\n transportError?: string\n}\n\nfunction randomId(prefix: string): string {\n const c = globalThis.crypto\n const suffix =\n c !== undefined && \"randomUUID\" in c\n ? c.randomUUID().slice(0, 8)\n : Math.random().toString(36).slice(2, 10)\n return `${prefix}_${suffix}`\n}\n\n/** The minimal valid RunAgentInput POSTed when none is supplied. */\nexport function defaultRunAgentInput(): Record<string, unknown> {\n return {\n threadId: randomId(\"thread\"),\n runId: randomId(\"run\"),\n state: {},\n messages: [{ id: randomId(\"msg\"), role: \"user\", content: \"Hello! Please respond briefly.\" }],\n tools: [],\n context: [],\n forwardedProps: {},\n }\n}\n\nasync function* iterateBody(\n body: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>,\n): AsyncGenerator<Uint8Array> {\n if (Symbol.asyncIterator in body) {\n yield* body as AsyncIterable<Uint8Array>\n return\n }\n const reader = (body as ReadableStream<Uint8Array>).getReader()\n try {\n for (;;) {\n const { done, value } = await reader.read()\n if (done) return\n if (value !== undefined) yield value\n }\n } finally {\n reader.releaseLock()\n }\n}\n\n/** Buffers up to the first line to guess SSE vs NDJSON, then replays. */\nasync function sniffFormat(\n source: AsyncGenerator<Uint8Array>,\n): Promise<{ format: \"sse\" | \"ndjson\"; replay: AsyncGenerator<Uint8Array> }> {\n const held: Uint8Array[] = []\n const decoder = new TextDecoder()\n let text = \"\"\n while (!text.includes(\"\\n\") && text.length < 4096) {\n const { done, value } = await source.next()\n if (done) break\n held.push(value)\n text += decoder.decode(value, { stream: true })\n }\n const firstLine = (text.split(\"\\n\")[0] ?? \"\").trim()\n const format = firstLine.startsWith(\"{\") || firstLine.startsWith(\"[\") ? \"ndjson\" : \"sse\"\n async function* replay(): AsyncGenerator<Uint8Array> {\n yield* held\n for (;;) {\n const { done, value } = await source.next()\n if (done) return\n yield value\n }\n }\n return { format, replay: replay() }\n}\n\nexport async function validateBody(\n body: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>,\n contentType: string | null,\n opts: TransportOptions = {},\n): Promise<TransportResult> {\n const userLayers = opts.validator?.layers ?? []\n const layers: ValidationLayer[] = [...new Set<ValidationLayer>([...userLayers, \"core\", \"transport\"])]\n const v = createValidator({ ...(opts.validator ?? {}), layers })\n const now = opts.now ?? Date.now\n const keepaliveWindow = opts.keepaliveWindowMs ?? DEFAULT_KEEPALIVE_MS\n const recorded = opts.recorded === true\n\n const emitTransport: typeof v.emitExternal = (rule, params, extra) => {\n const d = v.emitExternal(rule, params, extra)\n if (d !== null) opts.onDiagnostic?.(d)\n return d\n }\n\n // Byte-level tap: chunk arrival times drive AGUI506 (silent gaps) and\n // AGUI507 (everything in one chunk = buffered, not flushed).\n let chunkCount = 0\n let maxGapMs = 0\n let lastArrival: number | null = null\n async function* tapped(): AsyncGenerator<Uint8Array> {\n for await (const chunk of iterateBody(body)) {\n const t = now()\n if (lastArrival !== null) maxGapMs = Math.max(maxGapMs, t - lastArrival)\n lastArrival = t\n chunkCount += 1\n yield chunk\n }\n }\n\n const mime = contentType === null ? null : (contentType.split(\";\")[0] ?? \"\").trim().toLowerCase()\n if (contentType === null) {\n v.markSkipped(\"AGUI505\", \"no Content-Type header is available for this input\")\n } else if (mime !== \"text/event-stream\" && mime !== \"application/x-ndjson\") {\n emitTransport(\"AGUI505\", { contentType: mime === \"\" ? \"(none)\" : mime })\n }\n if (recorded) {\n v.markSkipped(\"AGUI506\", \"keepalive timing is not meaningful for recorded input\")\n v.markSkipped(\"AGUI507\", \"chunk arrival timing is not meaningful for recorded input\")\n v.markSkipped(\n \"AGUI508\",\n \"abnormal disconnects cannot be distinguished from end-of-capture in recorded input\",\n )\n }\n\n let format: \"sse\" | \"ndjson\"\n let stream: AsyncGenerator<Uint8Array> = tapped()\n if (mime === \"text/event-stream\") format = \"sse\"\n else if (mime === \"application/x-ndjson\") format = \"ndjson\"\n else ({ format, replay: stream } = await sniffFormat(stream))\n if (format === \"ndjson\") {\n v.markSkipped(\"AGUI501\", \"the stream is NDJSON; there is no SSE framing to check\")\n }\n\n let eventCount = 0\n let runOpen = false\n let openRunId: string | null = null\n const feedRaw = (raw: string): void => {\n eventCount += 1\n const diags = v.feed(raw)\n try {\n const parsed = JSON.parse(raw) as { type?: unknown; runId?: unknown }\n if (parsed?.type === \"RUN_STARTED\") {\n runOpen = true\n openRunId = typeof parsed.runId === \"string\" ? parsed.runId : null\n } else if (parsed?.type === \"RUN_FINISHED\" || parsed?.type === \"RUN_ERROR\") {\n runOpen = false\n }\n } catch {\n // unparseable payloads are already AGUI502 diagnostics from the core\n }\n opts.onEvent?.(raw, diags)\n if (opts.onDiagnostic !== undefined) for (const d of diags) opts.onDiagnostic(d)\n }\n\n let transportError: string | undefined\n try {\n if (format === \"sse\") {\n for await (const item of sseItems(stream)) {\n if (item.kind === \"event\") feedRaw(item.data)\n else if (item.kind === \"problem\") emitTransport(\"AGUI501\", { detail: item.detail })\n }\n } else {\n for await (const line of ndjsonLines(stream)) feedRaw(line)\n }\n } catch (e) {\n if (recorded) {\n // A read failure on a recording is a broken input, not an observation\n // about the agent's transport behavior.\n throw e instanceof TransportError\n ? e\n : new TransportError(\n `failed to read recorded input: ${e instanceof Error ? e.message : String(e)}`,\n )\n }\n transportError = e instanceof Error ? e.message : String(e)\n if (runOpen) {\n // The connection died mid-run. The core's finalize will additionally\n // report the run (and any open streams) as unterminated — both are true\n // statements about the observed stream.\n emitTransport(\"AGUI508\", { runId: openRunId ?? \"(unknown)\" })\n }\n }\n\n if (!recorded) {\n if (lastArrival !== null) maxGapMs = Math.max(maxGapMs, now() - lastArrival)\n if (maxGapMs > keepaliveWindow) {\n emitTransport(\"AGUI506\", { seconds: Math.round(maxGapMs / 1000) })\n }\n if (chunkCount === 1 && eventCount >= 3) {\n emitTransport(\"AGUI507\", { detail: `entire body (${eventCount} events) arrived in a single chunk` })\n }\n }\n\n const finalDiags = v.finalize()\n if (opts.onDiagnostic !== undefined) for (const d of finalDiags) opts.onDiagnostic(d)\n\n const result: TransportResult = {\n report: v.report(),\n status: null,\n contentType,\n eventCount,\n }\n if (transportError !== undefined) result.transportError = transportError\n return result\n}\n\nexport async function validateEndpoint(\n url: string,\n opts: TransportOptions = {},\n): Promise<TransportResult> {\n const fetchImpl = opts.fetchImpl ?? (globalThis.fetch as FetchLike | undefined)\n if (fetchImpl === undefined) {\n throw new TransportError(\"no fetch implementation available; pass fetchImpl\")\n }\n\n const method = opts.method ?? \"POST\"\n const headers: Record<string, string> = {\n accept: \"text/event-stream, application/x-ndjson\",\n ...(method === \"POST\" ? { \"content-type\": \"application/json\" } : {}),\n ...(opts.headers ?? {}),\n }\n\n const controller = new AbortController()\n const timers: ReturnType<typeof setTimeout>[] = []\n if (opts.timeoutMs !== undefined) {\n timers.push(\n setTimeout(\n () => controller.abort(new TransportError(`timed out after ${opts.timeoutMs}ms`)),\n opts.timeoutMs,\n ),\n )\n }\n opts.signal?.addEventListener(\"abort\", () => controller.abort(opts.signal?.reason), { once: true })\n\n try {\n let res: TransportResponseLike\n try {\n const init: TransportRequestInit = { method, headers, signal: controller.signal }\n if (method === \"POST\") init.body = JSON.stringify(opts.input ?? defaultRunAgentInput())\n res = await fetchImpl(url, init)\n } catch (e) {\n throw e instanceof TransportError\n ? e\n : new TransportError(`request failed: ${e instanceof Error ? e.message : String(e)}`)\n }\n if (res.status < 200 || res.status >= 300) {\n throw new TransportError(`endpoint responded with HTTP ${res.status}`, res.status)\n }\n if (res.body === null) throw new TransportError(\"response has no body\", res.status)\n const contentType = res.headers.get(\"content-type\") ?? \"\"\n const result = await validateBody(res.body, contentType, opts)\n return { ...result, status: res.status }\n } finally {\n for (const timer of timers) clearTimeout(timer)\n }\n}\n","#!/usr/bin/env node\n// The ag-ui-validate executable — the one deliberately Node-only file in src/.\n// Everything it does is delegated: parsing to cli-args.ts, validation to the\n// core + transport layers, output to the pure reporters. This file only wires\n// process.argv/stdin/stdout/exit codes to those pieces.\nimport { createReadStream, readFileSync, writeFileSync } from \"node:fs\"\nimport process from \"node:process\"\nimport { decideExitCode, parseCliArgs, USAGE } from \"./cli-args.js\"\nimport type { CliConfig } from \"./cli-args.js\"\nimport { formatDiagnosticLine, formatGroupedDiagnostics, formatReportSummary, toJsonReport, toJUnit, toSarif } from \"./report/index.js\"\nimport { TransportError, validateBody, validateEndpoint } from \"./transport/index.js\"\nimport type { TransportOptions, TransportResult } from \"./transport/index.js\"\nimport type { Diagnostic, ValidatorOptions } from \"./types.js\"\n\nconst TOOL_NAME = \"ag-ui-validate\"\n\nfunction toolVersion(): string {\n try {\n const pkg = JSON.parse(readFileSync(new URL(\"../package.json\", import.meta.url), \"utf8\")) as {\n version?: string\n }\n return pkg.version ?? \"0.0.0\"\n } catch {\n return \"0.0.0\"\n }\n}\n\nfunction transportOptions(\n config: CliConfig,\n onDiagnostic: ((d: Diagnostic) => void) | undefined,\n): TransportOptions {\n const validator: ValidatorOptions = {}\n if (config.features !== undefined) validator.features = config.features\n if (Object.keys(config.severityOverrides).length > 0) {\n validator.severityOverrides = config.severityOverrides\n }\n const opts: TransportOptions = { validator }\n if (onDiagnostic !== undefined) opts.onDiagnostic = onDiagnostic\n return opts\n}\n\nasync function main(): Promise<number> {\n const parsed = parseCliArgs(process.argv.slice(2))\n if (!parsed.ok) {\n process.stderr.write(`error: ${parsed.error}\\n\\n${USAGE}`)\n return 2\n }\n const config = parsed.config\n if (config.help) {\n process.stdout.write(USAGE)\n return 0\n }\n const version = toolVersion()\n if (config.version) {\n process.stdout.write(`${TOOL_NAME} ${version}\\n`)\n return 0\n }\n\n const color =\n config.color ?? (process.stdout.isTTY === true && process.env.NO_COLOR === undefined)\n const pretty = config.format === \"pretty\"\n\n // Pretty mode streams findings as they are detected; machine formats emit\n // one document at the end, so nothing else may touch stdout before it.\n // --group defers everything to one collapsed block after the run.\n let printed = 0\n const onDiagnostic = pretty && !config.group\n ? (d: Diagnostic): void => {\n printed += 1\n process.stdout.write(`${formatDiagnosticLine(d, { color })}\\n`)\n }\n : undefined\n\n const isUrl = /^https?:\\/\\//i.test(config.target)\n let result: TransportResult\n let targetLabel: string\n if (isUrl) {\n targetLabel = config.target\n const opts = transportOptions(config, onDiagnostic)\n if (Object.keys(config.headers).length > 0) opts.headers = config.headers\n if (config.timeoutMs !== undefined) opts.timeoutMs = config.timeoutMs\n result = await validateEndpoint(config.target, opts)\n } else if (config.target === \"-\") {\n targetLabel = \"stdin\"\n if (process.stdin.isTTY === true) {\n process.stderr.write(\"error: stdin is a terminal — pipe a recording in, or pass a file path\\n\")\n return 2\n }\n result = await validateBody(process.stdin, null, {\n ...transportOptions(config, onDiagnostic),\n recorded: true,\n })\n } else {\n targetLabel = config.target\n result = await validateBody(createReadStream(config.target), null, {\n ...transportOptions(config, onDiagnostic),\n recorded: true,\n })\n }\n\n const report = result.report\n // Line-based SARIF locations only make sense when events map 1:1 to lines.\n const lineOriented = !isUrl && config.target !== \"-\" && /\\.(jsonl|ndjson)$/i.test(config.target)\n const sarifOptions = lineOriented\n ? { toolVersion: version, artifactUri: config.target }\n : { toolVersion: version }\n\n if (config.jsonFile !== undefined) {\n const doc = toJsonReport(report, { tool: { name: TOOL_NAME, version }, target: targetLabel })\n writeFileSync(config.jsonFile, `${JSON.stringify(doc, null, 2)}\\n`)\n }\n if (config.sarifFile !== undefined) {\n writeFileSync(config.sarifFile, `${JSON.stringify(toSarif(report, sarifOptions), null, 2)}\\n`)\n }\n if (config.junitFile !== undefined) {\n writeFileSync(config.junitFile, toJUnit(report, { name: targetLabel }))\n }\n\n if (pretty) {\n if (config.group && report.diagnostics.length > 0) {\n process.stdout.write(`${formatGroupedDiagnostics(report.diagnostics, { color })}\\n\\n`)\n } else if (printed > 0) {\n process.stdout.write(\"\\n\")\n }\n process.stdout.write(`${formatReportSummary(report, { color })}\\n`)\n } else if (config.format === \"json\") {\n const doc = toJsonReport(report, { tool: { name: TOOL_NAME, version }, target: targetLabel })\n process.stdout.write(`${JSON.stringify(doc, null, 2)}\\n`)\n } else if (config.format === \"sarif\") {\n process.stdout.write(`${JSON.stringify(toSarif(report, sarifOptions), null, 2)}\\n`)\n } else {\n process.stdout.write(toJUnit(report, { name: targetLabel }))\n }\n\n return decideExitCode(report.summary, config.maxWarnings)\n}\n\nmain().then(\n (code) => {\n process.exitCode = code\n },\n (e: unknown) => {\n const message =\n e instanceof TransportError\n ? e.message\n : e instanceof Error\n ? (e.stack ?? e.message)\n : String(e)\n process.stderr.write(`error: ${message}\\n`)\n process.exitCode = 2\n },\n)\n"],"mappings":";;;;AA8BA,MAAa,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BrB,MAAMA,+BAAa,IAAI,IAAI;CAAC;CAAS;CAAW;CAAQ;AAAK,CAAC;AAC9D,MAAM,UAAU;AAOhB,MAAM,QAA8B;CAClC,UAAU;EAAE,YAAY;EAAO,QAAQ,OAAQ,EAAE,OAAO,MAAO;CAAM;CACrE,aAAa;EAAE,YAAY;EAAO,QAAQ,OAAQ,EAAE,UAAU,MAAO;CAAM;CAC3E,cAA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,OAAO,IAAI,OAAO,WAAW,QAAQ;EACnC,MAAM,MAAM,aAAa,QAAQ;GAAE,MAAM;IAAE,MAAM;IAAW;GAAQ;GAAG,QAAQ;EAAY,CAAC;EAC5F,QAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE,GAAG;CAC1D,OAAO,IAAI,OAAO,WAAW,SAC3B,QAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,QAAQ,QAAQ,YAAY,GAAG,MAAM,CAAC,EAAE,GAAG;MAElF,QAAQ,OAAO,MAAM,QAAQ,QAAQ,EAAE,MAAM,YAAY,CAAC,CAAC;CAG7D,OAAO,eAAe,OAAO,SAAS,OAAO,WAAW;AAC1D;AAEA,KAAK,CAAC,CAAC,MACJ,SAAS;CACR,QAAQ,WAAW;AACrB,IACC,MAAe;CACd,MAAM,UACJ,aAAa,iBACT,EAAE,UACF,aAAa,QACV,EAAE,SAAS,EAAE,UACd,OAAO,CAAC;CAChB,QAAQ,OAAO,MAAM,UAAU,QAAQ,GAAG;CAC1C,QAAQ,WAAW;AACrB,CACF"}
1
+ {"version":3,"file":"cli.js","names":["SEVERITIES","catalogJson"],"sources":["../js/src/cli-args.ts","../spec/catalog.json","../js/src/rules/catalog.ts","../js/src/report/pretty.ts","../js/src/report/json.ts","../js/src/report/sarif.ts","../js/src/report/junit.ts","../js/src/protocol/event-table.ts","../js/src/rules/checks/context.ts","../js/src/rules/checks/lifecycle.ts","../js/src/rules/checks/reasoning.ts","../js/src/protocol/jsonpatch.ts","../js/src/rules/checks/state.ts","../js/src/rules/checks/text.ts","../js/src/rules/checks/toolcalls.ts","../js/src/rules/checks/transport.ts","../js/src/types.ts","../js/src/index.ts","../js/src/transport/ndjson.ts","../js/src/transport/sse.ts","../js/src/transport/index.ts","../js/src/cli.ts"],"sourcesContent":["// Pure CLI argument parsing — no Node APIs, so it obeys the core purity rules\n// and tests without spawning processes. The Node-only entry lives in cli.ts.\nimport type { Severity } from \"./types.js\"\n\nexport type CliFormat = \"pretty\" | \"json\" | \"sarif\" | \"junit\"\n\nexport interface CliConfig {\n /** URL, file path, or \"-\" for stdin. Empty only with --help/--version. */\n target: string\n format: CliFormat\n /** true/false forced; null = auto-detect from TTY. */\n color: boolean | null\n maxWarnings?: number\n timeoutMs?: number\n /** Header names lowercased. */\n headers: Record<string, string>\n features?: string[]\n severityOverrides: Record<string, Severity | \"off\">\n /** Write these formats to files in the same run, whatever stdout shows. */\n sarifFile?: string\n junitFile?: string\n jsonFile?: string\n /** Pretty output only: one line per rule with a count, not one per finding. */\n group: boolean\n help: boolean\n version: boolean\n}\n\nexport type ParseResult = { ok: true; config: CliConfig } | { ok: false; error: string }\n\nexport const USAGE = `ag-ui-validate — conformance validator for the AG-UI protocol\n\nUsage:\n ag-ui-validate <url> connect to a live endpoint and validate the stream\n ag-ui-validate <file> validate a recorded stream (SSE capture or NDJSON/JSONL)\n ag-ui-validate - read a recorded stream from stdin\n\nOutput (default: human-readable):\n --json machine-readable report on stdout\n --sarif SARIF 2.1.0 log on stdout (code scanning)\n --junit JUnit XML on stdout (CI test reports)\n --json-file <path> additionally write the JSON report to a file\n --sarif-file <path> additionally write a SARIF log to a file\n --junit-file <path> additionally write JUnit XML to a file\n --group one line per rule with a count (large streams)\n --no-color disable ANSI colors\n\nRules:\n --rule AGUI###=<severity> override a rule's severity (error|warning|info|off)\n --off AGUI### shorthand for --rule AGUI###=off\n --features <a,b,...> declare exercised features (enables e.g. AGUI305)\n --max-warnings <n> exit 1 when warnings exceed n\n\nEndpoint options:\n --header \"Name: value\" extra request header (repeatable)\n --timeout <seconds> abort the request after this long\n\nExit codes: 0 clean, 1 findings at error level (or warnings over --max-warnings), 2 tool failure.\n`\n\nconst SEVERITIES = new Set([\"error\", \"warning\", \"info\", \"off\"])\nconst RULE_ID = /^AGUI\\d{3}$/\n\ninterface Flag {\n takesValue: boolean\n apply(config: CliConfig, value: string): string | null\n}\n\nconst FLAGS: Record<string, Flag> = {\n \"--help\": { takesValue: false, apply: (c) => ((c.help = true), null) },\n \"--version\": { takesValue: false, apply: (c) => ((c.version = true), null) },\n \"--no-color\": { takesValue: false, apply: (c) => ((c.color = false), null) },\n \"--group\": { takesValue: false, apply: (c) => ((c.group = true), null) },\n \"--json\": { takesValue: false, apply: (c) => setFormat(c, \"json\") },\n \"--sarif\": { takesValue: false, apply: (c) => setFormat(c, \"sarif\") },\n \"--junit\": { takesValue: false, apply: (c) => setFormat(c, \"junit\") },\n \"--off\": {\n takesValue: true,\n apply: (c, v) => {\n if (!RULE_ID.test(v)) return `--off expects a rule ID like AGUI203, got '${v}'`\n c.severityOverrides[v] = \"off\"\n return null\n },\n },\n \"--rule\": {\n takesValue: true,\n apply: (c, v) => {\n const eq = v.indexOf(\"=\")\n if (eq === -1) return `--rule expects ID=severity (e.g. AGUI105=warning), got '${v}'`\n const id = v.slice(0, eq)\n const severity = v.slice(eq + 1)\n if (!RULE_ID.test(id)) return `--rule expects a rule ID like AGUI105, got '${id}'`\n if (!SEVERITIES.has(severity)) {\n return `'${severity}' is not a severity; use error, warning, info, or off`\n }\n c.severityOverrides[id] = severity as Severity | \"off\"\n return null\n },\n },\n \"--max-warnings\": {\n takesValue: true,\n apply: (c, v) => {\n const n = Number(v)\n if (!Number.isInteger(n) || n < 0) return `--max-warnings expects a non-negative integer, got '${v}'`\n c.maxWarnings = n\n return null\n },\n },\n \"--timeout\": {\n takesValue: true,\n apply: (c, v) => {\n const n = Number(v)\n if (!Number.isFinite(n) || n <= 0) return `--timeout expects a positive number of seconds, got '${v}'`\n c.timeoutMs = Math.round(n * 1000)\n return null\n },\n },\n \"--header\": {\n takesValue: true,\n apply: (c, v) => {\n const colon = v.indexOf(\":\")\n if (colon <= 0) return `--header expects \"Name: value\", got '${v}'`\n c.headers[v.slice(0, colon).trim().toLowerCase()] = v.slice(colon + 1).trim()\n return null\n },\n },\n \"--sarif-file\": { takesValue: true, apply: (c, v) => ((c.sarifFile = v), null) },\n \"--junit-file\": { takesValue: true, apply: (c, v) => ((c.junitFile = v), null) },\n \"--json-file\": { takesValue: true, apply: (c, v) => ((c.jsonFile = v), null) },\n \"--features\": {\n takesValue: true,\n apply: (c, v) => {\n c.features = v\n .split(\",\")\n .map((f) => f.trim())\n .filter((f) => f !== \"\")\n return null\n },\n },\n}\n\nfunction setFormat(c: CliConfig, format: CliFormat): string | null {\n if (c.format !== \"pretty\" && c.format !== format) {\n return `pick at most one of --json, --sarif, --junit`\n }\n c.format = format\n return null\n}\n\nexport function parseCliArgs(argv: string[]): ParseResult {\n const config: CliConfig = {\n target: \"\",\n format: \"pretty\",\n color: null,\n headers: {},\n severityOverrides: {},\n group: false,\n help: false,\n version: false,\n }\n\n const targets: string[] = []\n for (let i = 0; i < argv.length; i += 1) {\n const arg = argv[i]!\n if (arg === \"-\" || !arg.startsWith(\"-\")) {\n targets.push(arg)\n continue\n }\n let name = arg\n let inlineValue: string | null = null\n const eq = arg.indexOf(\"=\")\n if (eq !== -1) {\n name = arg.slice(0, eq)\n inlineValue = arg.slice(eq + 1)\n }\n const flag = FLAGS[name]\n if (flag === undefined) return { ok: false, error: `unknown flag '${name}'` }\n let value = \"\"\n if (flag.takesValue) {\n if (inlineValue !== null) value = inlineValue\n else if (i + 1 < argv.length) value = argv[(i += 1)]!\n else return { ok: false, error: `${name} requires a value` }\n } else if (inlineValue !== null) {\n return { ok: false, error: `${name} does not take a value` }\n }\n const error = flag.apply(config, value)\n if (error !== null) return { ok: false, error }\n }\n\n if (config.group && config.format !== \"pretty\") {\n return {\n ok: false,\n error: \"--group only applies to the default pretty output, not --json/--sarif/--junit\",\n }\n }\n if (targets.length > 1) {\n return { ok: false, error: `expected exactly one target, got ${targets.length}` }\n }\n if (targets.length === 1) config.target = targets[0]!\n else if (!config.help && !config.version) {\n return { ok: false, error: \"missing target: a URL, a file path, or - for stdin\" }\n }\n return { ok: true, config }\n}\n\nexport function decideExitCode(\n summary: { errors: number; warnings: number; info: number },\n maxWarnings?: number,\n): 0 | 1 {\n if (summary.errors > 0) return 1\n if (maxWarnings !== undefined && summary.warnings > maxWarnings) return 1\n return 0\n}\n","","// Typed loader for the rule catalog. The catalog itself is data\n// (catalog.json) so other implementations can share it; this module gives it\n// types and validates its invariants once at load time.\n//\n// Note the asymmetry: the validator never throws on stream input, but a\n// malformed catalog is a programming error in this package, so the loader\n// throws loudly at import time.\n\nimport catalogJson from \"../../../spec/catalog.json\"\n\nexport type Severity = \"error\" | \"warning\" | \"info\"\nexport type SeverityOrOff = Severity | \"off\"\n\nconst SEVERITIES: readonly string[] = [\"error\", \"warning\", \"info\"]\nconst LAYERS: readonly string[] = [\"core\", \"transport\"]\n\nexport interface RuleDefinition {\n /** e.g. \"AGUI203\" */\n id: string\n severity: Severity\n title: string\n /** Human template with {placeholder} slots filled per diagnostic. */\n messageTemplate: string\n /** Governing spec section. Mandatory: rules that cannot cite one don't ship. */\n specUrl: string\n /** Exact sentence from the spec section, where one exists. */\n specQuote?: string\n since: string\n /** Canonical AG-UI feature this rule relates to, if any. */\n feature?: string\n /** True when the rule only fires if opts.features declares `feature`. */\n requiresFeature?: boolean\n /** Cross-reference into docs/spec-questions.md for downgraded/ambiguous rules. */\n specQuestion?: string\n /** Where the rule is evaluated. Transport rules are skipped (and the skip\n * reported) when validating recorded input with no transport in play. */\n checkedIn: \"core\" | \"transport\"\n}\n\nexport interface Catalog {\n catalogVersion: string\n spec: string\n rules: readonly RuleDefinition[]\n}\n\n/** Validates catalog data and returns it typed. Throws on structural problems. */\nexport function validateCatalog(data: unknown): Catalog {\n const problems: string[] = []\n const cat = data as Catalog\n if (typeof cat !== \"object\" || cat === null || !Array.isArray(cat.rules)) {\n throw new Error(\"rule catalog: expected an object with a rules array\")\n }\n const seen = new Set<string>()\n for (const rule of cat.rules) {\n const where = rule?.id ?? \"<missing id>\"\n if (!/^AGUI\\d{3}$/.test(rule.id ?? \"\")) problems.push(`${where}: id must match AGUI###`)\n if (seen.has(rule.id)) problems.push(`${where}: duplicate id`)\n seen.add(rule.id)\n if (!SEVERITIES.includes(rule.severity)) problems.push(`${where}: bad severity '${rule.severity}'`)\n if (!rule.title) problems.push(`${where}: missing title`)\n if (!rule.messageTemplate) problems.push(`${where}: missing messageTemplate`)\n if (!rule.specUrl?.startsWith(\"https://\")) problems.push(`${where}: specUrl must be an https URL`)\n if (!rule.since) problems.push(`${where}: missing since`)\n if (!LAYERS.includes(rule.checkedIn)) problems.push(`${where}: bad checkedIn '${rule.checkedIn}'`)\n if (rule.requiresFeature && !rule.feature) problems.push(`${where}: requiresFeature without feature`)\n }\n if (problems.length > 0) {\n throw new Error(`rule catalog is invalid:\\n ${problems.join(\"\\n \")}`)\n }\n return cat\n}\n\nexport const CATALOG: Catalog = validateCatalog(catalogJson)\n\nexport const RULES: ReadonlyMap<string, RuleDefinition> = new Map(\n CATALOG.rules.map((r) => [r.id, r]),\n)\n\n/** Fills a rule's messageTemplate. Unknown placeholders are left intact. */\nexport function formatMessage(rule: RuleDefinition, params: Record<string, unknown>): string {\n return rule.messageTemplate.replace(/\\{(\\w+)\\}/g, (whole, key: string) =>\n key in params ? String(params[key]) : whole,\n )\n}\n","// Human-readable output. Pure string formatting — the CLI decides where it\n// goes and whether a TTY wants color.\nimport { RULES } from \"../rules/catalog.js\"\nimport type { Diagnostic, Report, Severity } from \"../types.js\"\n\nexport interface PrettyOptions {\n color: boolean\n}\n\nconst SYMBOL: Record<Severity, string> = { error: \"✖\", warning: \"⚠\", info: \"ℹ\" }\nconst SGR: Record<Severity, string> = { error: \"31\", warning: \"33\", info: \"36\" }\n\nfunction paint(code: string, s: string, on: boolean): string {\n return on ? `\\x1b[${code}m${s}\\x1b[0m` : s\n}\n\nexport function formatDiagnosticLine(d: Diagnostic, opts: PrettyOptions): string {\n const where = d.eventIndex >= 0 ? `event ${d.eventIndex}` : \"—\"\n const head = paint(SGR[d.severity], `${SYMBOL[d.severity]} ${d.rule}`, opts.color)\n const meta = paint(\"2\", `${d.severity.padEnd(7)} ${where.padEnd(10)}`, opts.color)\n const cite = paint(\"2\", ` ↳ ${d.specUrl}`, opts.color)\n return `${head} ${meta} ${d.message}\\n${cite}`\n}\n\nfunction count(n: number, noun: string): string {\n return `${n} ${noun}${n === 1 ? \"\" : \"s\"}`\n}\n\nconst SEVERITY_RANK: Record<Severity, number> = { error: 0, warning: 1, info: 2 }\nconst SAMPLE_INDEXES = 3\n\n/**\n * One line per rule instead of one per occurrence — for large streams where\n * the same violation repeats. Totals stay honest in the summary; this only\n * changes what is listed.\n */\nexport function formatGroupedDiagnostics(diagnostics: Diagnostic[], opts: PrettyOptions): string {\n const groups = new Map<string, Diagnostic[]>()\n for (const d of diagnostics) {\n const list = groups.get(d.rule)\n if (list === undefined) groups.set(d.rule, [d])\n else list.push(d)\n }\n\n const sorted = [...groups.values()].sort((a, b) => {\n const bySeverity = SEVERITY_RANK[a[0]!.severity] - SEVERITY_RANK[b[0]!.severity]\n return bySeverity !== 0 ? bySeverity : a[0]!.rule.localeCompare(b[0]!.rule)\n })\n\n const lines: string[] = []\n for (const group of sorted) {\n const first = group[0]!\n const title = RULES.get(first.rule)?.title ?? first.message\n const indexes = group.map((d) => d.eventIndex).filter((i) => i >= 0)\n let where: string\n if (indexes.length === 0) {\n where = \"stream-level\"\n } else {\n const sample = indexes.slice(0, SAMPLE_INDEXES).join(\", \")\n const rest = indexes.length - SAMPLE_INDEXES\n where = `events ${sample}${rest > 0 ? ` (+${rest} more)` : \"\"}`\n }\n const head = paint(SGR[first.severity], `${SYMBOL[first.severity]} ${first.rule}`, opts.color)\n const meta = paint(\"2\", `${first.severity.padEnd(7)} ×${group.length}`, opts.color)\n const cite = paint(\"2\", ` ↳ ${first.specUrl}`, opts.color)\n lines.push(`${head} ${meta} ${title} — ${where}`, cite)\n }\n return lines.join(\"\\n\")\n}\n\nexport function formatReportSummary(report: Report, opts: PrettyOptions): string {\n const { errors, warnings, info } = report.summary\n const lines: string[] = []\n\n if (errors + warnings + info === 0) {\n lines.push(\n paint(\"32\", `✔ no conformance violations across ${count(report.eventCount, \"event\")}`, opts.color),\n )\n } else {\n lines.push(\n `${count(errors, \"error\")}, ${count(warnings, \"warning\")}, ${info} info across ${count(report.eventCount, \"event\")}`,\n )\n }\n\n const features = Object.entries(report.features)\n const exercised = features.filter(([, s]) => s === \"exercised\").map(([f]) => f)\n const suffix = exercised.length > 0 ? `: ${exercised.join(\", \")}` : \"\"\n lines.push(`${exercised.length} of ${features.length} AG-UI features exercised${suffix}`)\n\n if (report.skipped.length > 0) {\n lines.push(`${count(report.skipped.length, \"rule\")} not evaluated:`)\n for (const s of report.skipped) {\n lines.push(paint(\"2\", ` – ${s.rule}: ${s.reason}`, opts.color))\n }\n }\n\n for (const e of report.internalErrors) {\n lines.push(paint(\"31\", `! internal validator error: ${e}`, opts.color))\n }\n\n return lines.join(\"\\n\")\n}\n","// Machine-readable report: the core Report plus tool identification, so a\n// stored document is self-describing.\nimport type { Report } from \"../types.js\"\n\nexport interface JsonReportOptions {\n tool: { name: string; version: string }\n /** What was validated: URL, file path, or \"stdin\". */\n target?: string\n}\n\nexport interface JsonReportDocument extends Report {\n tool: { name: string; version: string }\n target?: string\n}\n\nexport function toJsonReport(report: Report, opts: JsonReportOptions): JsonReportDocument {\n const doc: JsonReportDocument = { tool: opts.tool, ...report }\n if (opts.target !== undefined) doc.target = opts.target\n return doc\n}\n","// SARIF 2.1.0 output for code-scanning integrations (e.g. GitHub).\n// Level mapping: error→error, warning→warning, info→note. When the input was a\n// line-oriented file (JSONL/captured SSE fed line-per-event is not guaranteed,\n// so only the caller knows), event N is reported at line N+1 via artifactUri.\nimport { RULES } from \"../rules/catalog.js\"\nimport type { Diagnostic, Report } from \"../types.js\"\n\nexport interface SarifOptions {\n toolVersion: string\n /** URI of the validated artifact; enables line-based locations. */\n artifactUri?: string\n}\n\nexport type SarifLevel = \"error\" | \"warning\" | \"note\"\n\nexport interface SarifResult {\n ruleId: string\n level: SarifLevel\n message: { text: string }\n locations: Array<{\n physicalLocation: {\n artifactLocation: { uri: string }\n region: { startLine: number }\n }\n }>\n}\n\nexport interface SarifLog {\n $schema: string\n version: \"2.1.0\"\n runs: Array<{\n tool: {\n driver: {\n name: string\n version: string\n informationUri: string\n rules: Array<{\n id: string\n helpUri: string\n shortDescription?: { text: string }\n defaultConfiguration?: { level: SarifLevel }\n }>\n }\n }\n results: SarifResult[]\n }>\n}\n\nconst LEVEL: Record<Diagnostic[\"severity\"], SarifLevel> = {\n error: \"error\",\n warning: \"warning\",\n info: \"note\",\n}\n\ntype SarifRule = {\n id: string\n helpUri: string\n shortDescription?: { text: string }\n defaultConfiguration?: { level: SarifLevel }\n}\n\nexport function toSarif(report: Report, opts: SarifOptions): SarifLog {\n const rules = new Map<string, SarifRule>()\n for (const d of report.diagnostics) {\n if (rules.has(d.rule)) continue\n const entry: SarifRule = { id: d.rule, helpUri: d.specUrl }\n const catalog = RULES.get(d.rule)\n if (catalog !== undefined) {\n entry.shortDescription = { text: catalog.title }\n entry.defaultConfiguration = { level: LEVEL[catalog.severity] }\n }\n rules.set(d.rule, entry)\n }\n\n const results: SarifResult[] = report.diagnostics.map((d) => ({\n ruleId: d.rule,\n level: LEVEL[d.severity],\n message: { text: d.message },\n locations:\n opts.artifactUri !== undefined && d.eventIndex >= 0\n ? [\n {\n physicalLocation: {\n artifactLocation: { uri: opts.artifactUri },\n region: { startLine: d.eventIndex + 1 },\n },\n },\n ]\n : [],\n }))\n\n return {\n $schema: \"https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/schemas/sarif-schema-2.1.0.json\",\n version: \"2.1.0\",\n runs: [\n {\n tool: {\n driver: {\n name: \"ag-ui-validate\",\n version: opts.toolVersion,\n informationUri: \"https://github.com/langport-dev/ag-ui-validate\",\n rules: [...rules.values()],\n },\n },\n results,\n },\n ],\n }\n}\n","// JUnit XML output for CI systems. One testcase per finding: errors are\n// <failure>, warnings and info are <skipped> (visible but not build-breaking —\n// the exit code, not the XML, decides pass/fail). A clean report is a single\n// passing testcase so the suite is never empty.\nimport type { Report } from \"../types.js\"\n\nexport interface JUnitOptions {\n /** Suite name — typically the validated target. */\n name: string\n}\n\nfunction esc(s: string): string {\n return s\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&apos;\")\n}\n\nexport function toJUnit(report: Report, opts: JUnitOptions): string {\n const lines: string[] = ['<?xml version=\"1.0\" encoding=\"UTF-8\"?>']\n const suite = esc(opts.name)\n\n if (report.diagnostics.length === 0) {\n lines.push('<testsuites name=\"ag-ui-validate\" tests=\"1\" failures=\"0\" errors=\"0\" skipped=\"0\">')\n lines.push(` <testsuite name=\"${suite}\" tests=\"1\" failures=\"0\" errors=\"0\" skipped=\"0\">`)\n lines.push(\n ` <testcase name=\"AG-UI conformance: no violations across ${report.eventCount} events\" classname=\"${suite}\"/>`,\n )\n lines.push(\" </testsuite>\")\n lines.push(\"</testsuites>\")\n return `${lines.join(\"\\n\")}\\n`\n }\n\n const failures = report.diagnostics.filter((d) => d.severity === \"error\").length\n const skipped = report.diagnostics.length - failures\n const counts = `tests=\"${report.diagnostics.length}\" failures=\"${failures}\" errors=\"0\" skipped=\"${skipped}\"`\n lines.push(`<testsuites name=\"ag-ui-validate\" ${counts}>`)\n lines.push(` <testsuite name=\"${suite}\" ${counts}>`)\n for (const d of report.diagnostics) {\n const where = d.eventIndex >= 0 ? `event ${d.eventIndex}` : \"stream\"\n const name = esc(`${d.rule} (${where})`)\n lines.push(` <testcase name=\"${name}\" classname=\"${suite}\">`)\n const body = `${esc(d.message)}\\n${esc(d.specUrl)}`\n if (d.severity === \"error\") {\n lines.push(` <failure message=\"${esc(d.message)}\">${body}</failure>`)\n } else {\n lines.push(` <skipped message=\"${esc(`${d.severity}: ${d.message}`)}\">${body}</skipped>`)\n }\n lines.push(\" </testcase>\")\n }\n lines.push(\" </testsuite>\")\n lines.push(\"</testsuites>\")\n return `${lines.join(\"\\n\")}\\n`\n}\n","// AUTO-GENERATED from @ag-ui/core v0.0.58 — do not edit by hand.\n// Regenerate with: node scripts/generate-event-table.mjs\n// test/protocol-drift.test.ts fails if this file drifts from the installed SDK.\n\nexport type FieldKind = \"string\" | \"number\" | \"boolean\" | \"object\" | \"array\" | \"any\"\n\nexport type EventCategory =\n | \"lifecycle\"\n | \"text\"\n | \"toolcall\"\n | \"state\"\n | \"activity\"\n | \"reasoning\"\n | \"thinking\"\n | \"special\"\n\nexport interface FieldSpec {\n kind: FieldKind\n required: boolean\n enum?: readonly string[]\n}\n\nexport interface EventSpec {\n category: EventCategory\n /** Present when the SDK marks the event @deprecated; names the replacement. */\n deprecated?: string\n /** Docs section governing this event. */\n specUrl: string\n /** Wire fields beyond the base-event fields (type, timestamp, rawEvent). */\n fields: Readonly<Record<string, FieldSpec>>\n}\n\n/** Version of @ag-ui/core this table was derived from. */\nexport const SDK_VERSION = \"0.0.58\"\n\n/** Canonical wire event types and their schemas, derived from @ag-ui/core. */\nexport const EVENT_TABLE: Readonly<Record<string, EventSpec>> = {\n \"TEXT_MESSAGE_START\": {\n category: \"text\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#textmessagestart\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n \"role\": { kind: \"string\", required: false, enum: [\"developer\",\"system\",\"assistant\",\"user\"] },\n \"name\": { kind: \"string\", required: false },\n },\n },\n \"TEXT_MESSAGE_CONTENT\": {\n category: \"text\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#textmessagecontent\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n \"delta\": { kind: \"string\", required: true },\n },\n },\n \"TEXT_MESSAGE_END\": {\n category: \"text\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#textmessageend\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n },\n },\n \"TEXT_MESSAGE_CHUNK\": {\n category: \"text\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#textmessagechunk\",\n fields: {\n \"messageId\": { kind: \"string\", required: false },\n \"role\": { kind: \"string\", required: false, enum: [\"developer\",\"system\",\"assistant\",\"user\"] },\n \"delta\": { kind: \"string\", required: false },\n \"name\": { kind: \"string\", required: false },\n },\n },\n \"TOOL_CALL_START\": {\n category: \"toolcall\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#toolcallstart\",\n fields: {\n \"toolCallId\": { kind: \"string\", required: true },\n \"toolCallName\": { kind: \"string\", required: true },\n \"parentMessageId\": { kind: \"string\", required: false },\n },\n },\n \"TOOL_CALL_ARGS\": {\n category: \"toolcall\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#toolcallargs\",\n fields: {\n \"toolCallId\": { kind: \"string\", required: true },\n \"delta\": { kind: \"string\", required: true },\n },\n },\n \"TOOL_CALL_END\": {\n category: \"toolcall\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#toolcallend\",\n fields: {\n \"toolCallId\": { kind: \"string\", required: true },\n },\n },\n \"TOOL_CALL_CHUNK\": {\n category: \"toolcall\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#toolcallchunk\",\n fields: {\n \"toolCallId\": { kind: \"string\", required: false },\n \"toolCallName\": { kind: \"string\", required: false },\n \"parentMessageId\": { kind: \"string\", required: false },\n \"delta\": { kind: \"string\", required: false },\n },\n },\n \"TOOL_CALL_RESULT\": {\n category: \"toolcall\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#toolcallresult\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n \"toolCallId\": { kind: \"string\", required: true },\n \"content\": { kind: \"string\", required: true },\n \"role\": { kind: \"string\", required: false, enum: [\"tool\"] },\n },\n },\n \"THINKING_START\": {\n category: \"thinking\",\n deprecated: \"REASONING_START\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#thinking-events-deprecated\",\n fields: {\n \"title\": { kind: \"string\", required: false },\n },\n },\n \"THINKING_END\": {\n category: \"thinking\",\n deprecated: \"REASONING_END\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#thinking-events-deprecated\",\n fields: {\n },\n },\n \"THINKING_TEXT_MESSAGE_START\": {\n category: \"thinking\",\n deprecated: \"REASONING_MESSAGE_START\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#thinking-events-deprecated\",\n fields: {\n },\n },\n \"THINKING_TEXT_MESSAGE_CONTENT\": {\n category: \"thinking\",\n deprecated: \"REASONING_MESSAGE_CONTENT\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#thinking-events-deprecated\",\n fields: {\n \"delta\": { kind: \"string\", required: true },\n },\n },\n \"THINKING_TEXT_MESSAGE_END\": {\n category: \"thinking\",\n deprecated: \"REASONING_MESSAGE_END\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#thinking-events-deprecated\",\n fields: {\n },\n },\n \"STATE_SNAPSHOT\": {\n category: \"state\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#statesnapshot\",\n fields: {\n \"snapshot\": { kind: \"any\", required: true },\n },\n },\n \"STATE_DELTA\": {\n category: \"state\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#statedelta\",\n fields: {\n \"delta\": { kind: \"array\", required: true },\n },\n },\n \"MESSAGES_SNAPSHOT\": {\n category: \"state\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#messagessnapshot\",\n fields: {\n \"messages\": { kind: \"array\", required: true },\n },\n },\n \"ACTIVITY_SNAPSHOT\": {\n category: \"activity\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#activitysnapshot\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n \"activityType\": { kind: \"string\", required: true },\n \"content\": { kind: \"object\", required: true },\n \"replace\": { kind: \"boolean\", required: false },\n },\n },\n \"ACTIVITY_DELTA\": {\n category: \"activity\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#activitydelta\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n \"activityType\": { kind: \"string\", required: true },\n \"patch\": { kind: \"array\", required: true },\n },\n },\n \"RAW\": {\n category: \"special\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#raw\",\n fields: {\n \"event\": { kind: \"any\", required: true },\n \"source\": { kind: \"string\", required: false },\n },\n },\n \"CUSTOM\": {\n category: \"special\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#custom\",\n fields: {\n \"name\": { kind: \"string\", required: true },\n \"value\": { kind: \"any\", required: true },\n },\n },\n \"RUN_STARTED\": {\n category: \"lifecycle\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#runstarted\",\n fields: {\n \"threadId\": { kind: \"string\", required: true },\n \"runId\": { kind: \"string\", required: true },\n \"parentRunId\": { kind: \"string\", required: false },\n \"input\": { kind: \"object\", required: false },\n },\n },\n \"RUN_FINISHED\": {\n category: \"lifecycle\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#runfinished\",\n fields: {\n \"threadId\": { kind: \"string\", required: true },\n \"runId\": { kind: \"string\", required: true },\n \"result\": { kind: \"any\", required: false },\n \"outcome\": { kind: \"object\", required: false },\n \"usage\": { kind: \"array\", required: false },\n },\n },\n \"RUN_ERROR\": {\n category: \"lifecycle\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#runerror\",\n fields: {\n \"message\": { kind: \"string\", required: true },\n \"code\": { kind: \"string\", required: false },\n \"usage\": { kind: \"array\", required: false },\n },\n },\n \"STEP_STARTED\": {\n category: \"lifecycle\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#stepstarted\",\n fields: {\n \"stepName\": { kind: \"string\", required: true },\n },\n },\n \"STEP_FINISHED\": {\n category: \"lifecycle\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#stepfinished\",\n fields: {\n \"stepName\": { kind: \"string\", required: true },\n },\n },\n \"REASONING_START\": {\n category: \"reasoning\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#reasoningstart\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n },\n },\n \"REASONING_MESSAGE_START\": {\n category: \"reasoning\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#reasoningmessagestart\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n \"role\": { kind: \"string\", required: true, enum: [\"reasoning\"] },\n },\n },\n \"REASONING_MESSAGE_CONTENT\": {\n category: \"reasoning\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#reasoningmessagecontent\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n \"delta\": { kind: \"string\", required: true },\n },\n },\n \"REASONING_MESSAGE_END\": {\n category: \"reasoning\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#reasoningmessageend\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n },\n },\n \"REASONING_MESSAGE_CHUNK\": {\n category: \"reasoning\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#reasoningmessagechunk\",\n fields: {\n \"messageId\": { kind: \"string\", required: false },\n \"delta\": { kind: \"string\", required: false },\n },\n },\n \"REASONING_END\": {\n category: \"reasoning\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#reasoningend\",\n fields: {\n \"messageId\": { kind: \"string\", required: true },\n },\n },\n \"REASONING_ENCRYPTED_VALUE\": {\n category: \"reasoning\",\n specUrl: \"https://docs.ag-ui.com/concepts/events#reasoningencryptedvalue\",\n fields: {\n \"subtype\": { kind: \"string\", required: true, enum: [\"tool-call\",\"message\"] },\n \"entityId\": { kind: \"string\", required: true },\n \"encryptedValue\": { kind: \"string\", required: true },\n },\n },\n}\n\n/** All canonical wire `type` values, in @ag-ui/core enum order. */\nexport const EVENT_TYPES: readonly string[] = Object.keys(EVENT_TABLE)\n\n/**\n * Wire types documented as drafts (https://docs.ag-ui.com/drafts/overview) but\n * not yet in @ag-ui/core. Not errors: reported at info severity.\n */\nexport const DRAFT_EVENT_TYPES: readonly string[] = [\"META\"]\n","// Internal validator state and the API each check module sees.\n// Everything here is engine-internal; the public surface lives in src/types.ts.\n\nimport type { CanonicalFeature } from \"../../types.js\"\n\n/** Emit a diagnostic for rule `id`; params fill the catalog messageTemplate. */\nexport type EmitFn = (\n ruleId: string,\n params: Record<string, unknown>,\n extra?: {\n eventIndex?: number\n pointer?: string\n relatedEventIndex?: number\n /** Instance-level severity floor (e.g. draft META downgrades AGUI503). */\n severity?: \"error\" | \"warning\" | \"info\"\n /** Instance-level spec link override (e.g. draft docs page). */\n specUrl?: string\n /** Appended to the formatted message (e.g. casing hints). */\n messageSuffix?: string\n },\n) => void\n\nexport interface OpenToolCall {\n startIndex: number\n args: string\n sawArgs: boolean\n}\n\nexport interface RunState {\n /** null while the run is implicit (stream opened without RUN_STARTED). */\n runId: string | null\n threadId: string | null\n startIndex: number\n implicit: boolean\n terminal: { type: string; index: number } | null\n\n openMessages: Map<string, { startIndex: number }>\n /** messageId -> index of the event that closed it. */\n closedMessages: Map<string, number>\n /** Every message id observed (starts, chunks, snapshots, tool results). */\n knownMessageIds: Set<string>\n\n openToolCalls: Map<string, OpenToolCall>\n closedToolCalls: Map<string, number>\n /** Ids also known from MESSAGES_SNAPSHOT history. */\n knownToolCallIds: Set<string>\n\n /** stepName -> re-entrant open count (SQ-10) and first-open index. */\n openSteps: Map<string, { count: number; firstIndex: number }>\n\n openReasoningBlocks: Map<string, number>\n openReasoningMessages: Map<string, number>\n\n state: {\n /** True once a STATE_SNAPSHOT established an observable base (SQ-1). */\n known: boolean\n value: unknown\n deltasSinceSnapshot: number\n snapshotSeen: boolean\n agui301Fired: boolean\n }\n\n /** Implicit streams opened by *_CHUNK events; closed by any other event. */\n textChunk: { messageId: string; startIndex: number } | null\n toolChunk: { toolCallId: string; startIndex: number; args: string; sawArgs: boolean } | null\n reasoningChunk: { messageId: string; startIndex: number } | null\n}\n\nexport function newRunState(init: {\n runId: string | null\n threadId: string | null\n startIndex: number\n implicit: boolean\n}): RunState {\n return {\n ...init,\n terminal: null,\n openMessages: new Map(),\n closedMessages: new Map(),\n knownMessageIds: new Set(),\n openToolCalls: new Map(),\n closedToolCalls: new Map(),\n knownToolCallIds: new Set(),\n openSteps: new Map(),\n openReasoningBlocks: new Map(),\n openReasoningMessages: new Map(),\n state: { known: false, value: undefined, deltasSinceSnapshot: 0, snapshotSeen: false, agui301Fired: false },\n textChunk: null,\n toolChunk: null,\n reasoningChunk: null,\n }\n}\n\nexport interface StreamState {\n eventCount: number\n sawTimestamp: boolean\n anySnapshot: boolean\n agui001Fired: boolean\n features: Set<CanonicalFeature>\n}\n\n/** What a per-event check handler receives. */\nexport interface CheckApi {\n index: number\n type: string\n event: Record<string, unknown>\n run: RunState\n stream: StreamState\n emit: EmitFn\n feature: (f: CanonicalFeature) => void\n}\n\n/** Reads a field only if it is a string (schema problems already reported). */\nexport function str(event: Record<string, unknown>, field: string): string | undefined {\n const v = event[field]\n return typeof v === \"string\" ? v : undefined\n}\n","// Lifecycle rules: AGUI001–AGUI008. Run open/terminate logic lives in the\n// engine (src/index.ts) because it owns run-scope resets; this module holds\n// the step pairing and the RUN_FINISHED id-stability check.\n\nimport type { CheckApi, RunState, EmitFn } from \"./context.js\"\nimport { str } from \"./context.js\"\n\nexport function handleStepEvent(api: CheckApi): void {\n const { type, event, run, emit, index } = api\n const stepName = str(event, \"stepName\")\n if (stepName === undefined) return\n\n if (type === \"STEP_STARTED\") {\n const open = run.openSteps.get(stepName)\n if (open !== undefined) {\n open.count += 1 // re-entrant same-name steps are tolerated (SQ-10)\n } else {\n run.openSteps.set(stepName, { count: 1, firstIndex: index })\n }\n return\n }\n\n if (type === \"STEP_FINISHED\") {\n const open = run.openSteps.get(stepName)\n if (open === undefined) {\n emit(\"AGUI006\", { stepName }, { pointer: \"/stepName\" })\n return\n }\n open.count -= 1\n if (open.count === 0) run.openSteps.delete(stepName)\n }\n}\n\n/** AGUI008 — RUN_FINISHED must carry the ids RUN_STARTED established. */\nexport function checkRunIdStability(api: CheckApi): void {\n const { event, run, emit } = api\n if (run.implicit) return // no RUN_STARTED to compare against\n for (const field of [\"threadId\", \"runId\"] as const) {\n const actual = str(api.event, field)\n const expected = field === \"threadId\" ? run.threadId : run.runId\n if (actual !== undefined && expected !== null && actual !== expected) {\n emit(\"AGUI008\", { field, actual, expected }, {\n pointer: `/${field}`,\n relatedEventIndex: run.startIndex,\n })\n }\n }\n void event\n}\n\n/** AGUI007 — open steps when the run reaches a clean end. */\nexport function endOfRunSteps(run: RunState, emit: EmitFn, atIndex: number): void {\n for (const [stepName, open] of run.openSteps) {\n emit(\"AGUI007\", { stepName }, {\n eventIndex: atIndex,\n relatedEventIndex: open.firstIndex,\n })\n }\n}\n","// Reasoning rules: AGUI401–AGUI402, plus REASONING_MESSAGE_CHUNK handling.\n//\n// Per SQ-4: block-level nesting (REASONING_MESSAGE_* inside\n// REASONING_START/END) is only described as \"a typical flow\" by the docs, so\n// it is NOT enforced. AGUI401 enforces the message-level pairing, mirroring\n// the text message rules; AGUI402 reports unterminated starts at warning.\n\nimport type { CheckApi, RunState, EmitFn } from \"./context.js\"\nimport { str } from \"./context.js\"\n\nexport function handleReasoningEvent(api: CheckApi): void {\n const { type, event, run, emit, index } = api\n\n switch (type) {\n case \"REASONING_START\": {\n const id = str(event, \"messageId\")\n if (id !== undefined) run.openReasoningBlocks.set(id, index)\n return\n }\n\n case \"REASONING_END\": {\n const id = str(event, \"messageId\")\n if (id !== undefined) run.openReasoningBlocks.delete(id)\n return\n }\n\n case \"REASONING_MESSAGE_START\": {\n const id = str(event, \"messageId\")\n if (id !== undefined) run.openReasoningMessages.set(id, index)\n return\n }\n\n case \"REASONING_MESSAGE_CONTENT\": {\n const id = str(event, \"messageId\")\n if (id === undefined) return\n const openChunk = run.reasoningChunk !== null && run.reasoningChunk.messageId === id\n if (!run.openReasoningMessages.has(id) && !openChunk) {\n emit(\"AGUI401\", { messageId: id }, { pointer: \"/messageId\" })\n }\n return\n }\n\n case \"REASONING_MESSAGE_END\": {\n const id = str(event, \"messageId\")\n if (id !== undefined) run.openReasoningMessages.delete(id)\n return\n }\n\n case \"REASONING_MESSAGE_CHUNK\": {\n const id = str(event, \"messageId\")\n if (id === undefined) {\n if (run.reasoningChunk === null) {\n emit(\"AGUI504\", { type, detail: \"first REASONING_MESSAGE_CHUNK must include messageId\" }, {\n pointer: \"/messageId\",\n })\n return\n }\n if (event.delta === \"\") run.reasoningChunk = null // documented implicit close\n return\n }\n if (run.reasoningChunk !== null && run.reasoningChunk.messageId !== id) {\n run.reasoningChunk = null\n }\n if (event.delta === \"\") {\n run.reasoningChunk = null // empty delta implicitly closes the message\n return\n }\n if (run.reasoningChunk === null) {\n run.reasoningChunk = { messageId: id, startIndex: index }\n }\n return\n }\n\n // REASONING_ENCRYPTED_VALUE: schema-checked only; no ordering rules cited.\n }\n}\n\n/** Chunked reasoning also closes on any non-reasoning event (documented). */\nexport function closeReasoningChunk(run: RunState): void {\n run.reasoningChunk = null\n}\n\n/** AGUI402 — unterminated reasoning at a clean run end. */\nexport function endOfRunReasoning(run: RunState, emit: EmitFn, atIndex: number): void {\n for (const [id, startIndex] of run.openReasoningBlocks) {\n emit(\"AGUI402\", { startType: \"REASONING_START\", messageId: id }, {\n eventIndex: atIndex,\n relatedEventIndex: startIndex,\n })\n }\n for (const [id, startIndex] of run.openReasoningMessages) {\n emit(\"AGUI402\", { startType: \"REASONING_MESSAGE_START\", messageId: id }, {\n eventIndex: atIndex,\n relatedEventIndex: startIndex,\n })\n }\n}\n","// Minimal RFC 6902 (JSON Patch) + RFC 6901 (JSON Pointer) implementation.\n// Hand-rolled so the core keeps zero runtime dependencies. Immutable: the\n// input document is never mutated; ops apply atomically (all or none).\n\nexport type PatchResult =\n | { ok: true; result: unknown }\n | { ok: false; error: string; opIndex: number }\n\nexport interface PatchShapeProblem {\n /** Human-readable problem. */\n error: string\n /** Index of the offending op, or -1 when the document itself is not an array. */\n opIndex: number\n /** RFC 6901 pointer into the patch document, e.g. \"/0/op\". */\n pointer: string\n}\n\nconst OPS = [\"add\", \"remove\", \"replace\", \"move\", \"copy\", \"test\"] as const\ntype OpName = (typeof OPS)[number]\n\n/** RFC 6901: \"\" → whole document; \"/a/b\" → [\"a\", \"b\"]. Returns null when invalid. */\nexport function parsePointer(pointer: unknown): string[] | null {\n if (typeof pointer !== \"string\") return null\n if (pointer === \"\") return []\n if (!pointer.startsWith(\"/\")) return null\n return pointer\n .slice(1)\n .split(\"/\")\n .map((t) => t.replace(/~1/g, \"/\").replace(/~0/g, \"~\"))\n}\n\n/** Structural validation of a patch document, without applying it. */\nexport function validatePatchShape(patch: unknown): PatchShapeProblem | null {\n if (!Array.isArray(patch)) {\n return { error: \"patch document must be an array of operations\", opIndex: -1, pointer: \"\" }\n }\n for (let i = 0; i < patch.length; i++) {\n const op = patch[i]\n if (typeof op !== \"object\" || op === null || Array.isArray(op)) {\n return { error: `operation ${i} is not an object`, opIndex: i, pointer: `/${i}` }\n }\n const o = op as Record<string, unknown>\n if (!OPS.includes(o.op as OpName)) {\n return { error: `operation ${i} has invalid op '${String(o.op)}'`, opIndex: i, pointer: `/${i}/op` }\n }\n if (parsePointer(o.path) === null) {\n return { error: `operation ${i} (${String(o.op)}) has invalid path`, opIndex: i, pointer: `/${i}/path` }\n }\n if ((o.op === \"add\" || o.op === \"replace\" || o.op === \"test\") && !(\"value\" in o)) {\n return { error: `operation ${i} (${String(o.op)}) is missing value`, opIndex: i, pointer: `/${i}` }\n }\n if ((o.op === \"move\" || o.op === \"copy\") && parsePointer(o.from) === null) {\n return { error: `operation ${i} (${String(o.op)}) is missing or has invalid from`, opIndex: i, pointer: `/${i}` }\n }\n }\n return null\n}\n\nfunction clone(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(clone)\n if (typeof value === \"object\" && value !== null) {\n const out: Record<string, unknown> = {}\n for (const [k, v] of Object.entries(value)) out[k] = clone(v)\n return out\n }\n return value\n}\n\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true\n if (Array.isArray(a) && Array.isArray(b)) {\n return a.length === b.length && a.every((v, i) => deepEqual(v, b[i]))\n }\n if (typeof a === \"object\" && a !== null && typeof b === \"object\" && b !== null && !Array.isArray(a) && !Array.isArray(b)) {\n const ka = Object.keys(a)\n const kb = Object.keys(b as object)\n return ka.length === kb.length && ka.every((k) => deepEqual((a as Record<string, unknown>)[k], (b as Record<string, unknown>)[k]))\n }\n return false\n}\n\nfunction arrayIndex(token: string, length: number, allowAppend: boolean): number | null {\n if (allowAppend && token === \"-\") return length\n if (!/^(0|[1-9]\\d*)$/.test(token)) return null\n const i = Number(token)\n return i > length ? null : i\n}\n\ninterface Located {\n parent: Record<string, unknown> | unknown[] | null // null → the document root itself\n key: string | number\n exists: boolean\n value: unknown\n}\n\nfunction locate(doc: unknown, tokens: string[], forAdd: boolean): Located | string {\n if (tokens.length === 0) return { parent: null, key: \"\", exists: true, value: doc }\n let current = doc\n for (let i = 0; i < tokens.length - 1; i++) {\n const token = tokens[i]!\n if (Array.isArray(current)) {\n const idx = arrayIndex(token, current.length, false)\n if (idx === null || idx >= current.length) return `path segment '/${token}' does not exist`\n current = current[idx]\n } else if (typeof current === \"object\" && current !== null) {\n const obj = current as Record<string, unknown>\n if (!(token in obj)) return `path segment '/${token}' does not exist`\n current = obj[token]\n } else {\n return `path segment '/${token}' is not an object or array`\n }\n }\n const last = tokens[tokens.length - 1]!\n if (Array.isArray(current)) {\n const idx = arrayIndex(last, current.length, forAdd)\n if (idx === null) return `'${last}' is not a valid index for an array of length ${current.length}`\n return { parent: current, key: idx, exists: idx < current.length, value: current[idx] }\n }\n if (typeof current === \"object\" && current !== null) {\n const obj = current as Record<string, unknown>\n return { parent: obj, key: last, exists: last in obj, value: obj[last] }\n }\n return `target of '/${last}' is not an object or array`\n}\n\n/** Applies an RFC 6902 patch. Validates shape first; never throws. */\nexport function applyPatch(doc: unknown, patch: unknown): PatchResult {\n const shape = validatePatchShape(patch)\n if (shape !== null) return { ok: false, error: shape.error, opIndex: shape.opIndex }\n\n let result = clone(doc)\n const ops = patch as Record<string, unknown>[]\n\n const getAt = (pointer: string): { ok: true; value: unknown } | { ok: false; error: string } => {\n const loc = locate(result, parsePointer(pointer)!, false)\n if (typeof loc === \"string\") return { ok: false, error: `${pointer}: ${loc}` }\n if (!loc.exists) return { ok: false, error: `${pointer} does not exist` }\n return { ok: true, value: loc.value }\n }\n\n const setAt = (pointer: string, value: unknown, mustExist: boolean): string | null => {\n const tokens = parsePointer(pointer)!\n if (tokens.length === 0) {\n result = value\n return null\n }\n const loc = locate(result, tokens, !mustExist)\n if (typeof loc === \"string\") return `${pointer}: ${loc}`\n if (mustExist && !loc.exists) return `${pointer} does not exist`\n if (Array.isArray(loc.parent)) {\n if (mustExist) loc.parent[loc.key as number] = value\n else loc.parent.splice(loc.key as number, 0, value)\n } else {\n loc.parent![loc.key as string] = value\n }\n return null\n }\n\n const removeAt = (pointer: string): { ok: true; removed: unknown } | { ok: false; error: string } => {\n const tokens = parsePointer(pointer)!\n if (tokens.length === 0) return { ok: false, error: \"cannot remove the whole document\" }\n const loc = locate(result, tokens, false)\n if (typeof loc === \"string\") return { ok: false, error: `${pointer}: ${loc}` }\n if (!loc.exists) return { ok: false, error: `${pointer} does not exist` }\n if (Array.isArray(loc.parent)) loc.parent.splice(loc.key as number, 1)\n else delete loc.parent![loc.key as string]\n return { ok: true, removed: loc.value }\n }\n\n for (let i = 0; i < ops.length; i++) {\n const op = ops[i]!\n const path = op.path as string\n let error: string | null = null\n\n switch (op.op as OpName) {\n case \"add\":\n error = setAt(path, clone(op.value), false)\n break\n case \"replace\":\n error = setAt(path, clone(op.value), true)\n break\n case \"remove\": {\n const r = removeAt(path)\n if (!r.ok) error = r.error\n break\n }\n case \"move\": {\n const from = op.from as string\n if (path.startsWith(`${from}/`)) {\n error = `cannot move ${from} into its own child ${path}`\n break\n }\n const r = removeAt(from)\n if (!r.ok) { error = r.error; break }\n error = setAt(path, r.removed, false)\n break\n }\n case \"copy\": {\n const r = getAt(op.from as string)\n if (!r.ok) { error = r.error; break }\n error = setAt(path, clone(r.value), false)\n break\n }\n case \"test\": {\n const r = getAt(path)\n if (!r.ok) error = r.error\n else if (!deepEqual(r.value, op.value)) error = `test failed at ${path}`\n break\n }\n }\n\n if (error !== null) return { ok: false, error, opIndex: i }\n }\n return { ok: true, result }\n}\n\n/** RFC 6901 token escaping, for building diagnostic pointers. */\nexport function escapePointerToken(token: string): string {\n return token.replace(/~/g, \"~0\").replace(/\\//g, \"~1\")\n}\n","// State rules: AGUI301–AGUI305, plus MESSAGES_SNAPSHOT history harvesting.\n\nimport { applyPatch, validatePatchShape } from \"../../protocol/jsonpatch.js\"\nimport type { CheckApi } from \"./context.js\"\n\nexport function handleStateEvent(api: CheckApi): void {\n const { type, event, run, stream, emit } = api\n\n switch (type) {\n case \"STATE_SNAPSHOT\": {\n api.feature(\"shared-state\")\n if (run.state.deltasSinceSnapshot > 0) {\n emit(\"AGUI304\", { deltaCount: run.state.deltasSinceSnapshot }, {})\n }\n run.state.known = true\n run.state.value = event.snapshot\n run.state.snapshotSeen = true\n run.state.deltasSinceSnapshot = 0\n stream.anySnapshot = true\n return\n }\n\n case \"STATE_DELTA\": {\n api.feature(\"shared-state\")\n const delta = event.delta\n if (!Array.isArray(delta)) return // AGUI504 already reported the kind mismatch\n const shape = validatePatchShape(delta)\n if (shape !== null) {\n emit(\"AGUI303\", { error: shape.error }, { pointer: `/delta${shape.pointer}` })\n return\n }\n if (!run.state.snapshotSeen && !run.state.agui301Fired) {\n // The base may be seeded out-of-band via RunAgentInput.state (SQ-1),\n // so this is informational, and patch application is not judged until\n // a snapshot establishes an observable base.\n emit(\"AGUI301\", {}, {})\n run.state.agui301Fired = true\n }\n if (run.state.known) {\n const applied = applyPatch(run.state.value, delta)\n if (applied.ok) {\n run.state.value = applied.result\n } else {\n emit(\"AGUI302\", { error: applied.error }, { pointer: `/delta/${applied.opIndex}` })\n }\n }\n run.state.deltasSinceSnapshot += 1\n return\n }\n\n case \"MESSAGES_SNAPSHOT\": {\n // Snapshots can carry history from before this capture: harvest ids so\n // reference checks (AGUI207/AGUI208) don't false-positive on them.\n const messages = event.messages\n if (!Array.isArray(messages)) return\n for (const message of messages) {\n if (typeof message !== \"object\" || message === null) continue\n const m = message as Record<string, unknown>\n if (typeof m.id === \"string\") run.knownMessageIds.add(m.id)\n if (Array.isArray(m.toolCalls)) {\n for (const call of m.toolCalls) {\n if (typeof call === \"object\" && call !== null) {\n const id = (call as Record<string, unknown>).id\n if (typeof id === \"string\") run.knownToolCallIds.add(id)\n }\n }\n }\n }\n return\n }\n }\n}\n","// Text message rules: AGUI101–AGUI106, plus TEXT_MESSAGE_CHUNK stream handling.\n\nimport type { CheckApi, RunState, EmitFn } from \"./context.js\"\nimport { str } from \"./context.js\"\n\nexport function handleTextEvent(api: CheckApi): void {\n const { type, event, run, emit, index } = api\n api.feature(\"agentic-chat\")\n\n switch (type) {\n case \"TEXT_MESSAGE_START\": {\n const id = str(event, \"messageId\")\n if (id === undefined) return\n if (run.openMessages.has(id)) {\n emit(\"AGUI106\", { messageId: id }, {\n pointer: \"/messageId\",\n relatedEventIndex: run.openMessages.get(id)!.startIndex,\n })\n return\n }\n if (run.closedMessages.has(id)) {\n emit(\"AGUI104\", { messageId: id }, {\n pointer: \"/messageId\",\n relatedEventIndex: run.closedMessages.get(id)!,\n })\n return\n }\n run.openMessages.set(id, { startIndex: index })\n run.knownMessageIds.add(id)\n return\n }\n\n case \"TEXT_MESSAGE_CONTENT\": {\n const id = str(event, \"messageId\")\n if (id === undefined) return\n const open = run.openMessages.get(id)\n if (open === undefined) {\n const closedAt = run.closedMessages.get(id)\n emit(\"AGUI101\", { messageId: id }, {\n pointer: \"/messageId\",\n ...(closedAt !== undefined ? { relatedEventIndex: closedAt } : {}),\n })\n return\n }\n if (event.delta === \"\") {\n emit(\"AGUI105\", { messageId: id }, { pointer: \"/delta\", relatedEventIndex: open.startIndex })\n }\n return\n }\n\n case \"TEXT_MESSAGE_END\": {\n const id = str(event, \"messageId\")\n if (id === undefined) return\n if (!run.openMessages.has(id)) {\n emit(\"AGUI102\", { messageId: id }, { pointer: \"/messageId\" })\n return\n }\n run.openMessages.delete(id)\n run.closedMessages.set(id, index)\n return\n }\n\n case \"TEXT_MESSAGE_CHUNK\": {\n const id = str(event, \"messageId\")\n if (id === undefined) {\n // Continuation chunks may omit messageId; the first chunk must not\n // (docs: \"First chunk for a message must include messageId\").\n if (run.textChunk === null) {\n emit(\"AGUI504\", { type, detail: \"first TEXT_MESSAGE_CHUNK for a message must include messageId\" }, {\n pointer: \"/messageId\",\n })\n }\n return\n }\n // Mixing chunk and explicit forms on one id is undefined behaviour\n // (SQ-9): tolerated, treated as content for the open message.\n if (run.openMessages.has(id)) return\n if (run.textChunk !== null && run.textChunk.messageId === id) return\n closeTextChunk(run, index)\n if (run.closedMessages.has(id)) {\n emit(\"AGUI104\", { messageId: id }, {\n pointer: \"/messageId\",\n relatedEventIndex: run.closedMessages.get(id)!,\n })\n return\n }\n run.textChunk = { messageId: id, startIndex: index }\n run.knownMessageIds.add(id)\n return\n }\n }\n}\n\n/** Chunk streams close implicitly on the next non-chunk event. */\nexport function closeTextChunk(run: RunState, atIndex: number): void {\n if (run.textChunk === null) return\n run.closedMessages.set(run.textChunk.messageId, atIndex)\n run.textChunk = null\n}\n\n/** AGUI103 — open messages when the run reaches a clean end. */\nexport function endOfRunText(run: RunState, emit: EmitFn, atIndex: number): void {\n for (const [id, open] of run.openMessages) {\n emit(\"AGUI103\", { messageId: id }, {\n eventIndex: atIndex,\n relatedEventIndex: open.startIndex,\n })\n }\n}\n","// Tool call rules: AGUI201–AGUI208, plus TOOL_CALL_CHUNK stream handling.\n\nimport type { CheckApi, RunState, EmitFn } from \"./context.js\"\nimport { str } from \"./context.js\"\n\nexport function handleToolCallEvent(api: CheckApi): void {\n const { type, event, run, emit, index } = api\n api.feature(\"backend-tool-rendering\")\n\n switch (type) {\n case \"TOOL_CALL_START\": {\n const id = str(event, \"toolCallId\")\n if (id === undefined) return\n if (run.openToolCalls.has(id) || run.closedToolCalls.has(id)) {\n const related = run.openToolCalls.get(id)?.startIndex ?? run.closedToolCalls.get(id)!\n emit(\"AGUI205\", { toolCallId: id }, { pointer: \"/toolCallId\", relatedEventIndex: related })\n return\n }\n run.openToolCalls.set(id, { startIndex: index, args: \"\", sawArgs: false })\n const parent = str(event, \"parentMessageId\")\n if (parent !== undefined && !run.knownMessageIds.has(parent)) {\n emit(\"AGUI208\", { parentMessageId: parent }, { pointer: \"/parentMessageId\" })\n }\n return\n }\n\n case \"TOOL_CALL_ARGS\": {\n const id = str(event, \"toolCallId\")\n if (id === undefined) return\n const open = run.openToolCalls.get(id)\n if (open === undefined) {\n emit(\"AGUI201\", { toolCallId: id }, { pointer: \"/toolCallId\" })\n return\n }\n const delta = str(event, \"delta\")\n if (delta !== undefined) {\n open.args += delta\n open.sawArgs = true\n }\n return\n }\n\n case \"TOOL_CALL_END\": {\n const id = str(event, \"toolCallId\")\n if (id === undefined) return\n const open = run.openToolCalls.get(id)\n if (open === undefined) {\n emit(\"AGUI202\", { toolCallId: id }, { pointer: \"/toolCallId\" })\n return\n }\n run.openToolCalls.delete(id)\n run.closedToolCalls.set(id, index)\n checkArgsJson(id, open, emit, index)\n return\n }\n\n case \"TOOL_CALL_RESULT\": {\n const id = str(event, \"toolCallId\")\n if (id !== undefined) {\n const open = run.openToolCalls.get(id)\n if (open !== undefined) {\n emit(\"AGUI206\", { toolCallId: id }, {\n pointer: \"/toolCallId\",\n relatedEventIndex: open.startIndex,\n })\n } else if (!run.closedToolCalls.has(id) && !run.knownToolCallIds.has(id)) {\n emit(\"AGUI207\", { toolCallId: id }, { pointer: \"/toolCallId\" })\n }\n }\n // The result is itself a tool message in the conversation.\n const messageId = str(event, \"messageId\")\n if (messageId !== undefined) run.knownMessageIds.add(messageId)\n return\n }\n\n case \"TOOL_CALL_CHUNK\": {\n const id = str(event, \"toolCallId\")\n const delta = str(event, \"delta\")\n if (id === undefined) {\n if (run.toolChunk === null) {\n emit(\"AGUI504\", { type, detail: \"first TOOL_CALL_CHUNK for a tool call must include toolCallId and toolCallName\" }, {\n pointer: \"/toolCallId\",\n })\n return\n }\n if (delta !== undefined) {\n run.toolChunk.args += delta\n run.toolChunk.sawArgs = true\n }\n return\n }\n // SQ-9: chunk continuing an explicitly-opened call — treat as args.\n const openExplicit = run.openToolCalls.get(id)\n if (openExplicit !== undefined) {\n if (delta !== undefined) {\n openExplicit.args += delta\n openExplicit.sawArgs = true\n }\n return\n }\n if (run.toolChunk !== null && run.toolChunk.toolCallId === id) {\n if (delta !== undefined) {\n run.toolChunk.args += delta\n run.toolChunk.sawArgs = true\n }\n return\n }\n closeToolChunk(run, emit, index)\n if (run.closedToolCalls.has(id)) {\n emit(\"AGUI205\", { toolCallId: id }, {\n pointer: \"/toolCallId\",\n relatedEventIndex: run.closedToolCalls.get(id)!,\n })\n return\n }\n if (str(event, \"toolCallName\") === undefined) {\n emit(\"AGUI504\", { type, detail: \"first TOOL_CALL_CHUNK for a tool call must include toolCallName\" }, {\n pointer: \"/toolCallName\",\n })\n }\n run.toolChunk = {\n toolCallId: id,\n startIndex: index,\n args: delta ?? \"\",\n sawArgs: delta !== undefined && delta.length > 0,\n }\n return\n }\n }\n}\n\nfunction checkArgsJson(\n id: string,\n call: { startIndex: number; args: string; sawArgs: boolean },\n emit: EmitFn,\n atIndex: number,\n): void {\n // A call that streamed no args at all is fine (a no-argument tool).\n if (!call.sawArgs || call.args.length === 0) return\n try {\n JSON.parse(call.args)\n } catch (e) {\n emit(\"AGUI204\", { toolCallId: id, error: e instanceof Error ? e.message : String(e) }, {\n eventIndex: atIndex,\n relatedEventIndex: call.startIndex,\n })\n }\n}\n\n/** Chunk streams close implicitly on the next non-chunk event. */\nexport function closeToolChunk(run: RunState, emit: EmitFn, atIndex: number): void {\n if (run.toolChunk === null) return\n const { toolCallId, startIndex, args, sawArgs } = run.toolChunk\n run.toolChunk = null\n run.closedToolCalls.set(toolCallId, atIndex)\n checkArgsJson(toolCallId, { startIndex, args, sawArgs }, emit, atIndex)\n}\n\n/** AGUI203 — open tool calls when the run reaches a clean end. */\nexport function endOfRunToolCalls(run: RunState, emit: EmitFn, atIndex: number): void {\n for (const [id, open] of run.openToolCalls) {\n emit(\"AGUI203\", { toolCallId: id }, {\n eventIndex: atIndex,\n relatedEventIndex: open.startIndex,\n })\n }\n}\n","// Transport rules (AGUI501, AGUI505–AGUI508) are only checkable against a\n// live connection: SSE framing, Content-Type, keepalive timing, flush\n// behaviour, abnormal EOF. The core cannot observe any of that from a parsed\n// event sequence, so it reports these rules as skipped — never silently —\n// and the transport layer (ag-ui-validate/transport, M5) evaluates them.\n//\n// AGUI502/503/504 are transport-adjacent but *are* checkable here (the core\n// accepts raw JSON strings), so they live in the engine, not this list.\n\nimport { CATALOG } from \"../catalog.js\"\n\nexport const TRANSPORT_SKIP_REASON =\n \"transport-layer rule; only checkable against a live connection (validated by ag-ui-validate/transport)\"\n\nexport const TRANSPORT_RULE_IDS: readonly string[] = CATALOG.rules\n .filter((r) => r.checkedIn === \"transport\")\n .map((r) => r.id)\n","import type { Severity, SeverityOrOff } from \"./rules/catalog.js\"\n\nexport type { Severity, SeverityOrOff }\n\n/** A single conformance finding. */\nexport interface Diagnostic {\n /** Rule ID, e.g. \"AGUI203\". */\n rule: string\n severity: Severity\n /** Human-readable, includes the offending id/value. */\n message: string\n /**\n * 0-based position in the stream of the event this diagnostic is about.\n * Stream-level diagnostics (e.g. AGUI902) use -1.\n */\n eventIndex: number\n /** The event's declared type, if parseable. */\n eventType?: string\n /** RFC 6901 JSON pointer into the event, e.g. \"/toolCallId\". */\n pointer?: string\n /** e.g. the unterminated TOOL_CALL_START this refers back to. */\n relatedEventIndex?: number\n /** Link to the governing spec section. Always populated. */\n specUrl: string\n}\n\n/** The seven canonical AG-UI features (from the AG-UI Dojo). */\nexport type CanonicalFeature =\n | \"agentic-chat\"\n | \"backend-tool-rendering\"\n | \"human-in-the-loop\"\n | \"agentic-generative-ui\"\n | \"tool-based-generative-ui\"\n | \"shared-state\"\n | \"predictive-state-updates\"\n\nexport const CANONICAL_FEATURES: readonly CanonicalFeature[] = [\n \"agentic-chat\",\n \"backend-tool-rendering\",\n \"human-in-the-loop\",\n \"agentic-generative-ui\",\n \"tool-based-generative-ui\",\n \"shared-state\",\n \"predictive-state-updates\",\n]\n\n/**\n * Feature-matrix status. Capability discovery (getCapabilities()) is\n * out-of-band and invisible to a passive stream observer, so this matrix is\n * inferred from observed events; features whose exercise cannot be\n * distinguished passively are \"not-inferable\". See docs/spec-questions.md SQ-13.\n */\nexport type FeatureStatus = \"exercised\" | \"not-exercised\" | \"not-inferable\"\n\nexport type FeatureMatrix = Record<CanonicalFeature, FeatureStatus>\n\nexport interface Summary {\n errors: number\n warnings: number\n info: number\n}\n\nexport interface SkippedRule {\n rule: string\n reason: string\n}\n\nexport interface Report {\n diagnostics: Diagnostic[]\n summary: Summary\n features: FeatureMatrix\n /**\n * Rules that were not evaluated in this mode and why — e.g. transport rules\n * when validating recorded input. Skips are reported, never silent.\n */\n skipped: SkippedRule[]\n eventCount: number\n /**\n * Unexpected internal validator errors. The validator never throws on any\n * input; if a check itself crashes, the message lands here instead.\n */\n internalErrors: string[]\n}\n\nexport type ValidationLayer = \"core\" | \"transport\"\n\nexport interface ValidatorOptions {\n /** Pins the rule set to a spec version. Only \"0.x\" exists today. */\n spec?: \"0.x\"\n /**\n * Declared features. Enables feature-conditional rules (e.g. AGUI305 fires\n * only when \"shared-state\" is declared).\n */\n features?: string[]\n /** Per-rule severity overrides; \"off\" disables a rule. */\n severityOverrides?: Record<string, SeverityOrOff>\n /**\n * Which rule layers are being evaluated. \"core\" is always on. Wrapping\n * layers that check transport rules (via emitExternal) declare \"transport\"\n * so those rules stop being reported as skipped. Default: [\"core\"].\n */\n layers?: ValidationLayer[]\n}\n\nexport interface Validator {\n /**\n * Feed one event — a parsed object, or a raw JSON string (malformed JSON is\n * a diagnostic, not an exception). Returns diagnostics detectable at this\n * event, in stream order. Never throws.\n */\n feed(event: unknown): Diagnostic[]\n /**\n * End-of-stream checks (unterminated tool calls, missing RUN_FINISHED, …).\n * Idempotent: second and later calls return []. Never throws.\n */\n finalize(): Diagnostic[]\n /** Cumulative report over everything fed so far. Never throws. */\n report(): Report\n /**\n * For wrapping layers (transport, CLI): report a layer-checked rule through\n * the same catalog formatting, severity overrides, and summary as core\n * diagnostics. Returns the diagnostic, or null when the rule is unknown\n * (recorded in internalErrors) or overridden off. Never throws.\n */\n emitExternal(\n rule: string,\n params?: Record<string, unknown>,\n extra?: { eventIndex?: number; pointer?: string; relatedEventIndex?: number },\n ): Diagnostic | null\n /**\n * For wrapping layers: declare that a rule was NOT evaluated and why (e.g.\n * timing rules on recorded input). The entry appears in report().skipped,\n * replacing any layer-computed entry for the same rule. Never throws.\n */\n markSkipped(rule: string, reason: string): void\n}\n","// ag-ui-validate core: a pure function over an AG-UI event sequence.\n// Zero I/O, zero runtime dependencies, isomorphic. Transports, the CLI, and\n// the Vitest matcher are thin wrappers over this module.\n//\n// Two invariants hold everywhere here:\n// - the validator NEVER throws on input: broken input is its input;\n// - every diagnostic cites the spec section that governs it (specUrl).\n\nimport { DRAFT_EVENT_TYPES, EVENT_TABLE, EVENT_TYPES, SDK_VERSION } from \"./protocol/event-table.js\"\nimport type { EventSpec } from \"./protocol/event-table.js\"\nimport { RULES, formatMessage } from \"./rules/catalog.js\"\nimport type { CheckApi, EmitFn, RunState, StreamState } from \"./rules/checks/context.js\"\nimport { newRunState, str } from \"./rules/checks/context.js\"\nimport { checkRunIdStability, endOfRunSteps, handleStepEvent } from \"./rules/checks/lifecycle.js\"\nimport { closeReasoningChunk, endOfRunReasoning, handleReasoningEvent } from \"./rules/checks/reasoning.js\"\nimport { handleStateEvent } from \"./rules/checks/state.js\"\nimport { closeTextChunk, endOfRunText, handleTextEvent } from \"./rules/checks/text.js\"\nimport { closeToolChunk, endOfRunToolCalls, handleToolCallEvent } from \"./rules/checks/toolcalls.js\"\nimport { TRANSPORT_RULE_IDS, TRANSPORT_SKIP_REASON } from \"./rules/checks/transport.js\"\nimport type {\n CanonicalFeature,\n Diagnostic,\n FeatureMatrix,\n Report,\n Severity,\n Validator,\n ValidatorOptions,\n} from \"./types.js\"\nimport { CANONICAL_FEATURES } from \"./types.js\"\n\nexport * from \"./types.js\"\nexport { CATALOG, RULES, formatMessage, validateCatalog } from \"./rules/catalog.js\"\nexport type { Catalog, RuleDefinition, Severity as RuleSeverity, SeverityOrOff } from \"./rules/catalog.js\"\nexport { EVENT_TABLE, EVENT_TYPES, SDK_VERSION } from \"./protocol/event-table.js\"\nexport type { EventCategory, EventSpec, FieldKind, FieldSpec } from \"./protocol/event-table.js\"\nexport { applyPatch, validatePatchShape } from \"./protocol/jsonpatch.js\"\n\nconst DRAFTS_META_URL = \"https://docs.ag-ui.com/drafts/meta-events\"\n\n// Features whose exercise cannot be distinguished on a passive stream: both\n// generative-UI features need knowledge of the frontend's tool/component\n// registry, which is out-of-band (see SQ-13).\nconst NOT_INFERABLE: readonly CanonicalFeature[] = [\n \"agentic-generative-ui\",\n \"tool-based-generative-ui\",\n]\n\n/** \"runStarted\" → \"RUN_STARTED\": case-insensitive match against wire types. */\nconst CANONICAL_BY_SQUASHED: ReadonlyMap<string, string> = new Map(\n EVENT_TYPES.map((t) => [t.replace(/_/g, \"\").toLowerCase(), t]),\n)\n\nfunction describeValue(v: unknown): string {\n if (v === null) return \"null\"\n if (Array.isArray(v)) return \"array\"\n return typeof v\n}\n\nexport function createValidator(opts: ValidatorOptions = {}): Validator {\n const overrides = opts.severityOverrides ?? {}\n const declaredFeatures = new Set(opts.features ?? [])\n const layers = new Set([\"core\", ...(opts.layers ?? [])])\n\n const diagnostics: Diagnostic[] = []\n const internalErrors: string[] = []\n const explicitSkips = new Map<string, string>()\n const stream: StreamState = {\n eventCount: 0,\n sawTimestamp: false,\n anySnapshot: false,\n agui001Fired: false,\n features: new Set(),\n }\n let run: RunState | null = null\n let finalized = false\n\n function mkEmit(batch: Diagnostic[], current: { index: number; type: string } | null): EmitFn {\n return (ruleId, params, extra = {}) => {\n const rule = RULES.get(ruleId)\n if (rule === undefined) {\n internalErrors.push(`emit() for unknown rule ${ruleId}`)\n return\n }\n const override = overrides[ruleId]\n if (override === \"off\") return\n const severity: Severity = override ?? extra.severity ?? rule.severity\n const aboutCurrentEvent = extra.eventIndex === undefined && current !== null\n const diag: Diagnostic = {\n rule: ruleId,\n severity,\n message: formatMessage(rule, params) + (extra.messageSuffix ?? \"\"),\n eventIndex: extra.eventIndex ?? current?.index ?? -1,\n specUrl: extra.specUrl ?? rule.specUrl,\n }\n if (aboutCurrentEvent) diag.eventType = current.type\n if (extra.pointer !== undefined) diag.pointer = extra.pointer\n if (extra.relatedEventIndex !== undefined) diag.relatedEventIndex = extra.relatedEventIndex\n diagnostics.push(diag)\n batch.push(diag)\n }\n }\n\n function validateSchema(type: string, spec: EventSpec, ev: Record<string, unknown>, emit: EmitFn): void {\n for (const [field, fs] of Object.entries(spec.fields)) {\n const v = ev[field]\n if (v === undefined) {\n if (fs.required) {\n emit(\"AGUI504\", { type, detail: `missing required field '${field}' (${fs.kind})` }, {\n pointer: `/${field}`,\n })\n }\n continue\n }\n let kindOk = true\n switch (fs.kind) {\n case \"string\":\n case \"number\":\n case \"boolean\":\n kindOk = typeof v === fs.kind\n break\n case \"array\":\n kindOk = Array.isArray(v)\n break\n case \"object\":\n kindOk = typeof v === \"object\" && v !== null && !Array.isArray(v)\n break\n case \"any\":\n break\n }\n if (!kindOk) {\n emit(\"AGUI504\", { type, detail: `field '${field}' must be ${fs.kind === \"array\" ? \"an\" : \"a\"} ${fs.kind}, got ${describeValue(v)}` }, {\n pointer: `/${field}`,\n })\n continue\n }\n if (fs.enum !== undefined && typeof v === \"string\" && !fs.enum.includes(v)) {\n emit(\"AGUI504\", { type, detail: `field '${field}' must be one of ${fs.enum.join(\"|\")}, got '${v}'` }, {\n pointer: `/${field}`,\n })\n }\n }\n }\n\n /** Chunk streams close implicitly on any event of a different type. */\n function closeChunks(r: RunState, emit: EmitFn, atIndex: number, except?: string): void {\n if (except !== \"TEXT_MESSAGE_CHUNK\") closeTextChunk(r, atIndex)\n if (except !== \"TOOL_CALL_CHUNK\") closeToolChunk(r, emit, atIndex)\n if (except !== \"REASONING_MESSAGE_CHUNK\") closeReasoningChunk(r)\n }\n\n /** Unterminated-at-run-end rules. Only on a *clean* end (RUN_FINISHED or a\n * stream that just stops): after RUN_ERROR, open streams are expected\n * debris of the failure, and flagging them would manufacture noise. */\n function endOfRunChecks(r: RunState, emit: EmitFn, atIndex: number): void {\n endOfRunText(r, emit, atIndex)\n endOfRunToolCalls(r, emit, atIndex)\n endOfRunSteps(r, emit, atIndex)\n endOfRunReasoning(r, emit, atIndex)\n }\n\n /** Opens the implicit run scope for streams that never announced one. */\n function ensureRun(index: number, type: string, emit: EmitFn): RunState {\n if (run === null) {\n if (!stream.agui001Fired) {\n emit(\"AGUI001\", { type }, {})\n stream.agui001Fired = true\n }\n run = newRunState({ runId: null, threadId: null, startIndex: index, implicit: true })\n }\n return run\n }\n\n function processEvent(input: unknown, batch: Diagnostic[]): void {\n const index = stream.eventCount\n stream.eventCount += 1\n\n // 1. Parse. Malformed input is a diagnostic, never an exception.\n let parsed: unknown = input\n if (typeof input === \"string\") {\n try {\n parsed = JSON.parse(input)\n } catch (e) {\n mkEmit(batch, { index, type: \"\" })(\"AGUI502\", {\n error: e instanceof Error ? e.message : String(e),\n })\n return\n }\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n mkEmit(batch, { index, type: \"\" })(\"AGUI502\", {\n error: `payload is ${describeValue(parsed)}, expected a JSON object`,\n })\n return\n }\n const ev = parsed as Record<string, unknown>\n\n // 2. The declared type is the key to everything else.\n if (typeof ev.type !== \"string\") {\n mkEmit(batch, { index, type: \"\" })(\"AGUI504\", {\n type: \"(untyped)\",\n detail: \"event has no string 'type' property\",\n }, { pointer: \"/type\" })\n return\n }\n const type = ev.type\n const emit = mkEmit(batch, { index, type })\n\n // 3. Base-event fields.\n if (\"timestamp\" in ev && ev.timestamp !== undefined) {\n if (typeof ev.timestamp === \"number\") stream.sawTimestamp = true\n else emit(\"AGUI504\", { type, detail: `field 'timestamp' must be a number, got ${describeValue(ev.timestamp)}` }, { pointer: \"/timestamp\" })\n }\n\n // 4. Unknown types: AGUI503 (documented drafts at info; casing hints for\n // near-misses — SQ-7).\n const spec = EVENT_TABLE[type]\n if (spec === undefined) {\n if (DRAFT_EVENT_TYPES.includes(type)) {\n emit(\"AGUI503\", { type, sdkVersion: SDK_VERSION }, {\n severity: \"info\",\n specUrl: DRAFTS_META_URL,\n messageSuffix: \" — documented draft event type, not yet in @ag-ui/core\",\n })\n } else {\n const canonical = CANONICAL_BY_SQUASHED.get(type.replace(/[_\\-\\s]/g, \"\").toLowerCase())\n emit(\"AGUI503\", { type, sdkVersion: SDK_VERSION }, {\n ...(canonical !== undefined\n ? { messageSuffix: ` — did you mean '${canonical}'? AG-UI wire types use SCREAMING_SNAKE_CASE` }\n : {}),\n })\n }\n return\n }\n\n // 5. Schema validation for the declared type (AGUI504).\n validateSchema(type, spec, ev, emit)\n\n // 6. Lifecycle position.\n if (type === \"RUN_STARTED\") {\n if (run === null) {\n run = newRunState({\n runId: str(ev, \"runId\") ?? null,\n threadId: str(ev, \"threadId\") ?? null,\n startIndex: index,\n implicit: false,\n })\n } else if (run.terminal !== null) {\n // A new run after a clean terminal: multi-run streams are legal\n // (serialized logs branch via parentRunId — SQ-6). Fresh scope.\n run = newRunState({\n runId: str(ev, \"runId\") ?? null,\n threadId: str(ev, \"threadId\") ?? null,\n startIndex: index,\n implicit: false,\n })\n } else if (run.implicit) {\n // The stream opened without RUN_STARTED (AGUI001 already fired); the\n // late start legitimizes the implicit scope rather than double-firing.\n closeChunks(run, emit, index)\n run.implicit = false\n run.runId = str(ev, \"runId\") ?? null\n run.threadId = str(ev, \"threadId\") ?? null\n } else {\n closeChunks(run, emit, index)\n emit(\"AGUI002\", { runId: str(ev, \"runId\") ?? \"(missing)\" }, {\n relatedEventIndex: run.startIndex,\n })\n }\n return\n }\n\n const r = ensureRun(index, type, emit)\n\n // 7. Nothing may follow a terminal event (AGUI004/AGUI005).\n if (r.terminal !== null) {\n const terminalType = r.terminal.type\n if ((type === \"RUN_FINISHED\" || type === \"RUN_ERROR\") && type !== terminalType) {\n emit(\"AGUI005\", { type, terminalType }, { relatedEventIndex: r.terminal.index })\n } else {\n emit(\"AGUI004\", { type, terminalType }, { relatedEventIndex: r.terminal.index })\n }\n return\n }\n\n closeChunks(r, emit, index, type)\n\n // 8. Terminal events.\n if (type === \"RUN_FINISHED\" || type === \"RUN_ERROR\") {\n if (type === \"RUN_FINISHED\") {\n checkRunIdStability(api(index, type, ev, r, emit))\n endOfRunChecks(r, emit, index)\n const outcome = ev.outcome\n if (typeof outcome === \"object\" && outcome !== null &&\n (outcome as Record<string, unknown>).type === \"interrupt\") {\n stream.features.add(\"human-in-the-loop\")\n }\n }\n r.terminal = { type, index }\n return\n }\n\n // 9. Per-category checks.\n const a = api(index, type, ev, r, emit)\n switch (spec.category) {\n case \"lifecycle\":\n handleStepEvent(a) // STEP_STARTED / STEP_FINISHED\n break\n case \"text\":\n handleTextEvent(a)\n break\n case \"toolcall\":\n handleToolCallEvent(a)\n break\n case \"state\":\n handleStateEvent(a)\n break\n case \"reasoning\":\n handleReasoningEvent(a)\n break\n case \"thinking\":\n // Deprecated but valid (SQ-8): schema-checked above, no ordering rules\n // in the catalog yet — a \"deprecated event used\" rule is proposed\n // upstream rather than invented here.\n break\n case \"activity\":\n // No activity rules in the catalog yet.\n break\n case \"special\":\n if (type === \"RAW\") {\n const wrapped = ev.event\n if (typeof wrapped === \"object\" && wrapped !== null) {\n const wrappedType = (wrapped as Record<string, unknown>).type\n if (typeof wrappedType === \"string\" && EVENT_TABLE[wrappedType] !== undefined) {\n emit(\"AGUI901\", { wrappedType }, { pointer: \"/event/type\" })\n }\n }\n } else if (type === \"CUSTOM\") {\n const name = str(ev, \"name\")\n if (name !== undefined) {\n if (name === \"PredictState\") stream.features.add(\"predictive-state-updates\")\n if (!/[.:/]/.test(name)) emit(\"AGUI903\", { name }, { pointer: \"/name\" })\n }\n }\n break\n }\n }\n\n function api(\n index: number,\n type: string,\n event: Record<string, unknown>,\n r: RunState,\n emit: EmitFn,\n ): CheckApi {\n return {\n index,\n type,\n event,\n run: r,\n stream,\n emit,\n feature: (f) => stream.features.add(f),\n }\n }\n\n return {\n feed(event: unknown): Diagnostic[] {\n const batch: Diagnostic[] = []\n try {\n processEvent(event, batch)\n } catch (e) {\n internalErrors.push(`feed(event ${stream.eventCount - 1}): ${e instanceof Error ? (e.stack ?? e.message) : String(e)}`)\n }\n return batch\n },\n\n finalize(): Diagnostic[] {\n if (finalized) return []\n finalized = true\n const batch: Diagnostic[] = []\n const emit = mkEmit(batch, null)\n try {\n if (run !== null && run.terminal === null) {\n closeChunks(run, emit, -1)\n emit(\"AGUI003\", { runId: run.runId ?? \"(unknown)\" }, {\n eventIndex: -1,\n relatedEventIndex: run.startIndex,\n })\n endOfRunChecks(run, emit, -1)\n }\n if (stream.eventCount > 0 && !stream.sawTimestamp) {\n emit(\"AGUI902\", { eventCount: stream.eventCount }, { eventIndex: -1 })\n }\n if (declaredFeatures.has(\"shared-state\") && !stream.anySnapshot) {\n emit(\"AGUI305\", {}, { eventIndex: -1 })\n }\n } catch (e) {\n internalErrors.push(`finalize(): ${e instanceof Error ? (e.stack ?? e.message) : String(e)}`)\n }\n return batch\n },\n\n emitExternal(rule, params = {}, extra = {}): Diagnostic | null {\n const batch: Diagnostic[] = []\n try {\n mkEmit(batch, null)(rule, params, extra)\n } catch (e) {\n internalErrors.push(`emitExternal(${rule}): ${e instanceof Error ? e.message : String(e)}`)\n }\n return batch[0] ?? null\n },\n\n markSkipped(rule, reason): void {\n explicitSkips.set(String(rule), String(reason))\n },\n\n report(): Report {\n const summary = { errors: 0, warnings: 0, info: 0 }\n for (const d of diagnostics) {\n if (d.severity === \"error\") summary.errors += 1\n else if (d.severity === \"warning\") summary.warnings += 1\n else summary.info += 1\n }\n\n const features = {} as FeatureMatrix\n for (const f of CANONICAL_FEATURES) {\n features[f] = NOT_INFERABLE.includes(f)\n ? \"not-inferable\"\n : stream.features.has(f)\n ? \"exercised\"\n : \"not-exercised\"\n }\n\n let skipped = layers.has(\"transport\")\n ? []\n : TRANSPORT_RULE_IDS\n .filter((id) => overrides[id] !== \"off\")\n .map((rule) => ({ rule, reason: TRANSPORT_SKIP_REASON }))\n if (!declaredFeatures.has(\"shared-state\") && overrides.AGUI305 !== \"off\") {\n skipped.push({\n rule: \"AGUI305\",\n reason: \"only evaluated when the 'shared-state' feature is declared via options.features\",\n })\n }\n for (const [rule, severity] of Object.entries(overrides)) {\n if (severity === \"off\" && RULES.has(rule)) {\n skipped.push({ rule, reason: \"disabled by severityOverrides\" })\n }\n }\n if (explicitSkips.size > 0) {\n skipped = skipped.filter((s) => !explicitSkips.has(s.rule))\n for (const [rule, reason] of explicitSkips) skipped.push({ rule, reason })\n }\n\n return {\n diagnostics: [...diagnostics],\n summary,\n features,\n skipped,\n eventCount: stream.eventCount,\n internalErrors: [...internalErrors],\n }\n },\n }\n}\n","// Incremental NDJSON (application/x-ndjson) line splitter. Yields non-empty\n// lines with trailing CR stripped; the core decides whether they parse.\n\nexport async function* ndjsonLines(source: AsyncIterable<Uint8Array>): AsyncGenerator<string> {\n const decoder = new TextDecoder(\"utf-8\")\n let buffer = \"\"\n\n function clean(line: string): string | null {\n const trimmed = line.endsWith(\"\\r\") ? line.slice(0, -1) : line\n return trimmed.trim() === \"\" ? null : trimmed\n }\n\n for await (const chunk of source) {\n buffer += decoder.decode(chunk, { stream: true })\n let i: number\n while ((i = buffer.indexOf(\"\\n\")) !== -1) {\n const line = clean(buffer.slice(0, i))\n buffer = buffer.slice(i + 1)\n if (line !== null) yield line\n }\n }\n buffer += decoder.decode()\n const last = clean(buffer)\n if (last !== null) yield last\n}\n","// WHATWG-compliant incremental SSE (text/event-stream) parser.\n// https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation\n//\n// Beyond plain parsing it surfaces framing anomalies relevant to AGUI501:\n// - json-line-without-data-prefix: a line that looks like a JSON payload but\n// has no \"data:\" field prefix. Spec-wise it is an unknown field and gets\n// silently dropped by every SSE client — the classic broken-server bug.\n// - truncated-frame: the stream ended mid-frame (pending data never\n// dispatched, or a partial final line).\n\nexport type SseProblemCode = \"json-line-without-data-prefix\" | \"truncated-frame\"\n\nexport type SseItem =\n | { kind: \"event\"; data: string; event?: string; id?: string }\n | { kind: \"comment\"; text: string }\n | { kind: \"problem\"; code: SseProblemCode; detail: string }\n\nconst truncate = (s: string, n: number): string => (s.length > n ? `${s.slice(0, n)}…` : s)\n\nexport async function* sseItems(source: AsyncIterable<Uint8Array>): AsyncGenerator<SseItem> {\n const decoder = new TextDecoder(\"utf-8\")\n let buffer = \"\"\n let sawFirstChars = false\n let dataLines: string[] = []\n let eventName = \"\"\n let lastId: string | undefined\n\n function handleLine(line: string): SseItem | null {\n if (line === \"\") {\n // Dispatch. Per spec, an empty data buffer dispatches nothing.\n const data = dataLines.join(\"\\n\")\n const hadData = dataLines.length > 0\n dataLines = []\n const name = eventName\n eventName = \"\"\n if (!hadData || data === \"\") return null\n const item: SseItem = { kind: \"event\", data }\n if (name !== \"\") item.event = name\n if (lastId !== undefined) item.id = lastId\n return item\n }\n if (line.startsWith(\":\")) return { kind: \"comment\", text: line.slice(1) }\n\n const colon = line.indexOf(\":\")\n const field = colon === -1 ? line : line.slice(0, colon)\n let value = colon === -1 ? \"\" : line.slice(colon + 1)\n if (value.startsWith(\" \")) value = value.slice(1)\n\n switch (field) {\n case \"data\":\n dataLines.push(value)\n return null\n case \"event\":\n eventName = value\n return null\n case \"id\":\n if (!value.includes(\"\\0\")) lastId = value\n return null\n case \"retry\":\n return null\n default: {\n // Unknown field: ignored per spec — but a JSON-looking line is almost\n // certainly a payload missing its \"data:\" prefix, silently lost.\n const trimmed = line.trimStart()\n if (trimmed.startsWith(\"{\") || trimmed.startsWith(\"[\")) {\n return {\n kind: \"problem\",\n code: \"json-line-without-data-prefix\",\n detail: `line '${truncate(trimmed, 60)}' looks like a JSON payload but lacks the 'data:' field prefix, so SSE clients silently drop it`,\n }\n }\n return null\n }\n }\n }\n\n function* drainLines(eof: boolean): Generator<SseItem> {\n for (;;) {\n const nl = buffer.indexOf(\"\\n\")\n const cr = buffer.indexOf(\"\\r\")\n let end: number\n let next: number\n if (cr !== -1 && (nl === -1 || cr < nl)) {\n // Hold back a trailing CR mid-stream: it may be a CRLF split across\n // chunk boundaries.\n if (cr === buffer.length - 1 && !eof) return\n end = cr\n next = buffer[cr + 1] === \"\\n\" ? cr + 2 : cr + 1\n } else if (nl !== -1) {\n end = nl\n next = nl + 1\n } else {\n return\n }\n const line = buffer.slice(0, end)\n buffer = buffer.slice(next)\n const item = handleLine(line)\n if (item !== null) yield item\n }\n }\n\n for await (const chunk of source) {\n buffer += decoder.decode(chunk, { stream: true })\n if (!sawFirstChars && buffer.length > 0) {\n if (buffer.startsWith(\"\")) buffer = buffer.slice(1)\n sawFirstChars = true\n }\n yield* drainLines(false)\n }\n buffer += decoder.decode()\n yield* drainLines(true)\n\n if (buffer !== \"\") {\n yield {\n kind: \"problem\",\n code: \"truncated-frame\",\n detail: `stream ended mid-line: '${truncate(buffer, 60)}' (no trailing newline; the frame was never dispatched)`,\n }\n } else if (dataLines.length > 0) {\n yield {\n kind: \"problem\",\n code: \"truncated-frame\",\n detail: \"stream ended with a pending frame that was never terminated by a blank line\",\n }\n }\n}\n","// ag-ui-validate/transport: SSE + NDJSON clients over the pure core.\n// This is the I/O layer — fetch, streams, and clocks live here, never in the\n// core. Uses only web-platform APIs (fetch, TextDecoder, AbortController) so\n// it stays isomorphic: Node 22+, browsers, Deno, Workers.\n\nimport { createValidator } from \"../index.js\"\nimport type { Diagnostic, Report, ValidationLayer, ValidatorOptions } from \"../index.js\"\nimport { ndjsonLines } from \"./ndjson.js\"\nimport { sseItems } from \"./sse.js\"\n\nexport { ndjsonLines } from \"./ndjson.js\"\nexport { sseItems } from \"./sse.js\"\nexport type { SseItem, SseProblemCode } from \"./sse.js\"\n\nconst DEFAULT_KEEPALIVE_MS = 30_000\n\nexport interface TransportRequestInit {\n method: string\n headers: Record<string, string>\n body?: string\n signal?: AbortSignal\n}\n\nexport interface TransportResponseLike {\n status: number\n headers: { get(name: string): string | null }\n body: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array> | null\n}\n\nexport type FetchLike = (url: string, init: TransportRequestInit) => Promise<TransportResponseLike>\n\n/** Operational failure (unreachable endpoint, non-2xx, no body) — distinct\n * from conformance findings, which are diagnostics. */\nexport class TransportError extends Error {\n status?: number\n constructor(message: string, status?: number) {\n super(message)\n this.name = \"TransportError\"\n if (status !== undefined) this.status = status\n }\n}\n\nexport interface TransportOptions {\n /** Options passed through to createValidator (\"transport\" layer is added). */\n validator?: ValidatorOptions\n /** Extra request headers (validateEndpoint only). */\n headers?: Record<string, string>\n /** RunAgentInput to POST; defaults to a minimal valid input with one user message. */\n input?: unknown\n method?: \"POST\" | \"GET\"\n /** AGUI506 window; default 30 000 ms. */\n keepaliveWindowMs?: number\n /** Abort the request after this long (validateEndpoint only). */\n timeoutMs?: number\n /** Injectable fetch (tests, custom stacks). Default: globalThis.fetch. */\n fetchImpl?: FetchLike\n /** Injectable clock for keepalive/buffering measurement. Default: Date.now. */\n now?: () => number\n /**\n * The body is a recording (file, stdin) rather than a live connection.\n * Timing-based rules (AGUI506, AGUI507) and mid-stream disconnect detection\n * (AGUI508) are meaningless for recordings; they are reported as skipped\n * with a reason instead of risking false positives, and read failures become\n * TransportErrors (tool failure) rather than AGUI508 findings.\n */\n recorded?: boolean\n signal?: AbortSignal\n /** Called after each fed event with the diagnostics it produced. */\n onEvent?: (raw: string, diagnostics: Diagnostic[]) => void\n /** Called for every diagnostic as soon as it is detected. */\n onDiagnostic?: (diagnostic: Diagnostic) => void\n}\n\nexport interface TransportResult {\n report: Report\n /** HTTP status; null when validating a bare body/recording. */\n status: number | null\n contentType: string | null\n /** Events fed to the validator (SSE frames / NDJSON lines). */\n eventCount: number\n /** Present when the connection failed mid-stream (see AGUI508). */\n transportError?: string\n}\n\nfunction randomId(prefix: string): string {\n const c = globalThis.crypto\n const suffix =\n c !== undefined && \"randomUUID\" in c\n ? c.randomUUID().slice(0, 8)\n : Math.random().toString(36).slice(2, 10)\n return `${prefix}_${suffix}`\n}\n\n/** The minimal valid RunAgentInput POSTed when none is supplied. */\nexport function defaultRunAgentInput(): Record<string, unknown> {\n return {\n threadId: randomId(\"thread\"),\n runId: randomId(\"run\"),\n state: {},\n messages: [{ id: randomId(\"msg\"), role: \"user\", content: \"Hello! Please respond briefly.\" }],\n tools: [],\n context: [],\n forwardedProps: {},\n }\n}\n\nasync function* iterateBody(\n body: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>,\n): AsyncGenerator<Uint8Array> {\n if (Symbol.asyncIterator in body) {\n yield* body as AsyncIterable<Uint8Array>\n return\n }\n const reader = (body as ReadableStream<Uint8Array>).getReader()\n try {\n for (;;) {\n const { done, value } = await reader.read()\n if (done) return\n if (value !== undefined) yield value\n }\n } finally {\n reader.releaseLock()\n }\n}\n\n/** Buffers up to the first line to guess SSE vs NDJSON, then replays. */\nasync function sniffFormat(\n source: AsyncGenerator<Uint8Array>,\n): Promise<{ format: \"sse\" | \"ndjson\"; replay: AsyncGenerator<Uint8Array> }> {\n const held: Uint8Array[] = []\n const decoder = new TextDecoder()\n let text = \"\"\n while (!text.includes(\"\\n\") && text.length < 4096) {\n const { done, value } = await source.next()\n if (done) break\n held.push(value)\n text += decoder.decode(value, { stream: true })\n }\n const firstLine = (text.split(\"\\n\")[0] ?? \"\").trim()\n const format = firstLine.startsWith(\"{\") || firstLine.startsWith(\"[\") ? \"ndjson\" : \"sse\"\n async function* replay(): AsyncGenerator<Uint8Array> {\n yield* held\n for (;;) {\n const { done, value } = await source.next()\n if (done) return\n yield value\n }\n }\n return { format, replay: replay() }\n}\n\nexport async function validateBody(\n body: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>,\n contentType: string | null,\n opts: TransportOptions = {},\n): Promise<TransportResult> {\n const userLayers = opts.validator?.layers ?? []\n const layers: ValidationLayer[] = [...new Set<ValidationLayer>([...userLayers, \"core\", \"transport\"])]\n const v = createValidator({ ...(opts.validator ?? {}), layers })\n const now = opts.now ?? Date.now\n const keepaliveWindow = opts.keepaliveWindowMs ?? DEFAULT_KEEPALIVE_MS\n const recorded = opts.recorded === true\n\n const emitTransport: typeof v.emitExternal = (rule, params, extra) => {\n const d = v.emitExternal(rule, params, extra)\n if (d !== null) opts.onDiagnostic?.(d)\n return d\n }\n\n // Byte-level tap: chunk arrival times drive AGUI506 (silent gaps) and\n // AGUI507 (everything in one chunk = buffered, not flushed).\n let chunkCount = 0\n let maxGapMs = 0\n let lastArrival: number | null = null\n async function* tapped(): AsyncGenerator<Uint8Array> {\n for await (const chunk of iterateBody(body)) {\n const t = now()\n if (lastArrival !== null) maxGapMs = Math.max(maxGapMs, t - lastArrival)\n lastArrival = t\n chunkCount += 1\n yield chunk\n }\n }\n\n const mime = contentType === null ? null : (contentType.split(\";\")[0] ?? \"\").trim().toLowerCase()\n if (contentType === null) {\n v.markSkipped(\"AGUI505\", \"no Content-Type header is available for this input\")\n } else if (mime !== \"text/event-stream\" && mime !== \"application/x-ndjson\") {\n emitTransport(\"AGUI505\", { contentType: mime === \"\" ? \"(none)\" : mime })\n }\n if (recorded) {\n v.markSkipped(\"AGUI506\", \"keepalive timing is not meaningful for recorded input\")\n v.markSkipped(\"AGUI507\", \"chunk arrival timing is not meaningful for recorded input\")\n v.markSkipped(\n \"AGUI508\",\n \"abnormal disconnects cannot be distinguished from end-of-capture in recorded input\",\n )\n }\n\n let format: \"sse\" | \"ndjson\"\n let stream: AsyncGenerator<Uint8Array> = tapped()\n if (mime === \"text/event-stream\") format = \"sse\"\n else if (mime === \"application/x-ndjson\") format = \"ndjson\"\n else ({ format, replay: stream } = await sniffFormat(stream))\n if (format === \"ndjson\") {\n v.markSkipped(\"AGUI501\", \"the stream is NDJSON; there is no SSE framing to check\")\n }\n\n let eventCount = 0\n let runOpen = false\n let openRunId: string | null = null\n const feedRaw = (raw: string): void => {\n eventCount += 1\n const diags = v.feed(raw)\n try {\n const parsed = JSON.parse(raw) as { type?: unknown; runId?: unknown }\n if (parsed?.type === \"RUN_STARTED\") {\n runOpen = true\n openRunId = typeof parsed.runId === \"string\" ? parsed.runId : null\n } else if (parsed?.type === \"RUN_FINISHED\" || parsed?.type === \"RUN_ERROR\") {\n runOpen = false\n }\n } catch {\n // unparseable payloads are already AGUI502 diagnostics from the core\n }\n opts.onEvent?.(raw, diags)\n if (opts.onDiagnostic !== undefined) for (const d of diags) opts.onDiagnostic(d)\n }\n\n let transportError: string | undefined\n try {\n if (format === \"sse\") {\n for await (const item of sseItems(stream)) {\n if (item.kind === \"event\") feedRaw(item.data)\n else if (item.kind === \"problem\") emitTransport(\"AGUI501\", { detail: item.detail })\n }\n } else {\n for await (const line of ndjsonLines(stream)) feedRaw(line)\n }\n } catch (e) {\n if (recorded) {\n // A read failure on a recording is a broken input, not an observation\n // about the agent's transport behavior.\n throw e instanceof TransportError\n ? e\n : new TransportError(\n `failed to read recorded input: ${e instanceof Error ? e.message : String(e)}`,\n )\n }\n transportError = e instanceof Error ? e.message : String(e)\n if (runOpen) {\n // The connection died mid-run. The core's finalize will additionally\n // report the run (and any open streams) as unterminated — both are true\n // statements about the observed stream.\n emitTransport(\"AGUI508\", { runId: openRunId ?? \"(unknown)\" })\n }\n }\n\n if (!recorded) {\n if (lastArrival !== null) maxGapMs = Math.max(maxGapMs, now() - lastArrival)\n if (maxGapMs > keepaliveWindow) {\n emitTransport(\"AGUI506\", { seconds: Math.round(maxGapMs / 1000) })\n }\n if (chunkCount === 1 && eventCount >= 3) {\n emitTransport(\"AGUI507\", { detail: `entire body (${eventCount} events) arrived in a single chunk` })\n }\n }\n\n const finalDiags = v.finalize()\n if (opts.onDiagnostic !== undefined) for (const d of finalDiags) opts.onDiagnostic(d)\n\n const result: TransportResult = {\n report: v.report(),\n status: null,\n contentType,\n eventCount,\n }\n if (transportError !== undefined) result.transportError = transportError\n return result\n}\n\nexport async function validateEndpoint(\n url: string,\n opts: TransportOptions = {},\n): Promise<TransportResult> {\n const fetchImpl = opts.fetchImpl ?? (globalThis.fetch as FetchLike | undefined)\n if (fetchImpl === undefined) {\n throw new TransportError(\"no fetch implementation available; pass fetchImpl\")\n }\n\n const method = opts.method ?? \"POST\"\n const headers: Record<string, string> = {\n accept: \"text/event-stream, application/x-ndjson\",\n ...(method === \"POST\" ? { \"content-type\": \"application/json\" } : {}),\n ...(opts.headers ?? {}),\n }\n\n const controller = new AbortController()\n const timers: ReturnType<typeof setTimeout>[] = []\n if (opts.timeoutMs !== undefined) {\n timers.push(\n setTimeout(\n () => controller.abort(new TransportError(`timed out after ${opts.timeoutMs}ms`)),\n opts.timeoutMs,\n ),\n )\n }\n opts.signal?.addEventListener(\"abort\", () => controller.abort(opts.signal?.reason), { once: true })\n\n try {\n let res: TransportResponseLike\n try {\n const init: TransportRequestInit = { method, headers, signal: controller.signal }\n if (method === \"POST\") init.body = JSON.stringify(opts.input ?? defaultRunAgentInput())\n res = await fetchImpl(url, init)\n } catch (e) {\n throw e instanceof TransportError\n ? e\n : new TransportError(`request failed: ${e instanceof Error ? e.message : String(e)}`)\n }\n if (res.status < 200 || res.status >= 300) {\n throw new TransportError(`endpoint responded with HTTP ${res.status}`, res.status)\n }\n if (res.body === null) throw new TransportError(\"response has no body\", res.status)\n const contentType = res.headers.get(\"content-type\") ?? \"\"\n const result = await validateBody(res.body, contentType, opts)\n return { ...result, status: res.status }\n } finally {\n for (const timer of timers) clearTimeout(timer)\n }\n}\n","#!/usr/bin/env node\n// The ag-ui-validate executable — the one deliberately Node-only file in src/.\n// Everything it does is delegated: parsing to cli-args.ts, validation to the\n// core + transport layers, output to the pure reporters. This file only wires\n// process.argv/stdin/stdout/exit codes to those pieces.\nimport { createReadStream, readFileSync, writeFileSync } from \"node:fs\"\nimport process from \"node:process\"\nimport { decideExitCode, parseCliArgs, USAGE } from \"./cli-args.js\"\nimport type { CliConfig } from \"./cli-args.js\"\nimport { formatDiagnosticLine, formatGroupedDiagnostics, formatReportSummary, toJsonReport, toJUnit, toSarif } from \"./report/index.js\"\nimport { TransportError, validateBody, validateEndpoint } from \"./transport/index.js\"\nimport type { TransportOptions, TransportResult } from \"./transport/index.js\"\nimport type { Diagnostic, ValidatorOptions } from \"./types.js\"\n\nconst TOOL_NAME = \"ag-ui-validate\"\n\nfunction toolVersion(): string {\n try {\n const pkg = JSON.parse(readFileSync(new URL(\"../package.json\", import.meta.url), \"utf8\")) as {\n version?: string\n }\n return pkg.version ?? \"0.0.0\"\n } catch {\n return \"0.0.0\"\n }\n}\n\nfunction transportOptions(\n config: CliConfig,\n onDiagnostic: ((d: Diagnostic) => void) | undefined,\n): TransportOptions {\n const validator: ValidatorOptions = {}\n if (config.features !== undefined) validator.features = config.features\n if (Object.keys(config.severityOverrides).length > 0) {\n validator.severityOverrides = config.severityOverrides\n }\n const opts: TransportOptions = { validator }\n if (onDiagnostic !== undefined) opts.onDiagnostic = onDiagnostic\n return opts\n}\n\nasync function main(): Promise<number> {\n const parsed = parseCliArgs(process.argv.slice(2))\n if (!parsed.ok) {\n process.stderr.write(`error: ${parsed.error}\\n\\n${USAGE}`)\n return 2\n }\n const config = parsed.config\n if (config.help) {\n process.stdout.write(USAGE)\n return 0\n }\n const version = toolVersion()\n if (config.version) {\n process.stdout.write(`${TOOL_NAME} ${version}\\n`)\n return 0\n }\n\n const color =\n config.color ?? (process.stdout.isTTY === true && process.env.NO_COLOR === undefined)\n const pretty = config.format === \"pretty\"\n\n // Pretty mode streams findings as they are detected; machine formats emit\n // one document at the end, so nothing else may touch stdout before it.\n // --group defers everything to one collapsed block after the run.\n let printed = 0\n const onDiagnostic = pretty && !config.group\n ? (d: Diagnostic): void => {\n printed += 1\n process.stdout.write(`${formatDiagnosticLine(d, { color })}\\n`)\n }\n : undefined\n\n const isUrl = /^https?:\\/\\//i.test(config.target)\n let result: TransportResult\n let targetLabel: string\n if (isUrl) {\n targetLabel = config.target\n const opts = transportOptions(config, onDiagnostic)\n if (Object.keys(config.headers).length > 0) opts.headers = config.headers\n if (config.timeoutMs !== undefined) opts.timeoutMs = config.timeoutMs\n result = await validateEndpoint(config.target, opts)\n } else if (config.target === \"-\") {\n targetLabel = \"stdin\"\n if (process.stdin.isTTY === true) {\n process.stderr.write(\"error: stdin is a terminal — pipe a recording in, or pass a file path\\n\")\n return 2\n }\n result = await validateBody(process.stdin, null, {\n ...transportOptions(config, onDiagnostic),\n recorded: true,\n })\n } else {\n targetLabel = config.target\n result = await validateBody(createReadStream(config.target), null, {\n ...transportOptions(config, onDiagnostic),\n recorded: true,\n })\n }\n\n const report = result.report\n // Line-based SARIF locations only make sense when events map 1:1 to lines.\n const lineOriented = !isUrl && config.target !== \"-\" && /\\.(jsonl|ndjson)$/i.test(config.target)\n const sarifOptions = lineOriented\n ? { toolVersion: version, artifactUri: config.target }\n : { toolVersion: version }\n\n if (config.jsonFile !== undefined) {\n const doc = toJsonReport(report, { tool: { name: TOOL_NAME, version }, target: targetLabel })\n writeFileSync(config.jsonFile, `${JSON.stringify(doc, null, 2)}\\n`)\n }\n if (config.sarifFile !== undefined) {\n writeFileSync(config.sarifFile, `${JSON.stringify(toSarif(report, sarifOptions), null, 2)}\\n`)\n }\n if (config.junitFile !== undefined) {\n writeFileSync(config.junitFile, toJUnit(report, { name: targetLabel }))\n }\n\n if (pretty) {\n if (config.group && report.diagnostics.length > 0) {\n process.stdout.write(`${formatGroupedDiagnostics(report.diagnostics, { color })}\\n\\n`)\n } else if (printed > 0) {\n process.stdout.write(\"\\n\")\n }\n process.stdout.write(`${formatReportSummary(report, { color })}\\n`)\n } else if (config.format === \"json\") {\n const doc = toJsonReport(report, { tool: { name: TOOL_NAME, version }, target: targetLabel })\n process.stdout.write(`${JSON.stringify(doc, null, 2)}\\n`)\n } else if (config.format === \"sarif\") {\n process.stdout.write(`${JSON.stringify(toSarif(report, sarifOptions), null, 2)}\\n`)\n } else {\n process.stdout.write(toJUnit(report, { name: targetLabel }))\n }\n\n return decideExitCode(report.summary, config.maxWarnings)\n}\n\nmain().then(\n (code) => {\n process.exitCode = code\n },\n (e: unknown) => {\n const message =\n e inst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