agentic-mermaid 0.1.1 → 0.1.2

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 (336) hide show
  1. package/CHANGELOG.md +144 -4
  2. package/LICENSES/Apache-2.0.txt +202 -0
  3. package/README.md +25 -32
  4. package/THIRD_PARTY_NOTICES.md +29 -0
  5. package/dist/agent-core.d.ts +463 -0
  6. package/dist/agent-core.js +397 -0
  7. package/dist/agent.d.ts +73 -1868
  8. package/dist/agent.js +336 -37325
  9. package/dist/agentic-mermaid-mcp.js +7 -38399
  10. package/dist/am.js +33632 -40445
  11. package/dist/chunk-4QECACIA.js +4702 -0
  12. package/dist/chunk-CDPKJ2BQ.js +37 -0
  13. package/dist/chunk-QKDLMOJJ.js +3487 -0
  14. package/dist/chunk-WI35L7IR.js +615 -0
  15. package/dist/chunk-WN3YDOBG.js +149 -0
  16. package/dist/chunk-ZYMMKQ3I.js +62637 -0
  17. package/dist/index-D54dqSdC.d.ts +6777 -0
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +310 -33014
  20. package/dist/mcp-cli-SBQSTJFC.js +17 -0
  21. package/docs/README.md +14 -6
  22. package/docs/schemas/style-spec.schema.json +1221 -30
  23. package/examples/styles/catalog.json +54 -0
  24. package/examples/styles/cloudflare-workers-inspired-prototype.mmd +9 -0
  25. package/examples/styles/cloudflare-workers-inspired-prototype.style.json +110 -0
  26. package/examples/styles/cupertino-prototype.mmd +10 -0
  27. package/examples/styles/cupertino-prototype.style.json +63 -0
  28. package/examples/styles/mid-century-report.style.json +2 -2
  29. package/examples/styles/star-chart-atlas.style.json +2 -1
  30. package/examples/styles/transit-route-map.style.json +2 -2
  31. package/examples/styles/vercel-inspired-prototype.mmd +6 -0
  32. package/examples/styles/vercel-inspired-prototype.style.json +87 -0
  33. package/package.json +68 -43
  34. package/server.json +2 -2
  35. package/skills/agentic-mermaid-diagram-workflow/SKILL.md +17 -36
  36. package/skills/agentic-mermaid-diagram-workflow/references/cli.md +4 -5
  37. package/skills/agentic-mermaid-diagram-workflow/references/code-mode.md +15 -31
  38. package/skills/agentic-mermaid-diagram-workflow/references/sequence.md +10 -14
  39. package/skills/agentic-mermaid-live-editor/SKILL.md +100 -206
  40. package/AGENT_NATIVE.md +0 -607
  41. package/Instructions_for_agents.md +0 -89
  42. package/TODO.md +0 -684
  43. package/assets/hero.png +0 -0
  44. package/dist/index-wjRjbsP-.d.ts +0 -1102
  45. package/docs/agent-api-cookbook.md +0 -308
  46. package/docs/agent-mutation-policy.md +0 -104
  47. package/docs/agent-workflow-examples.md +0 -46
  48. package/docs/api.md +0 -211
  49. package/docs/ascii.md +0 -103
  50. package/docs/assets/improvements/box-start-connector.png +0 -0
  51. package/docs/assets/improvements/comment-dropped-lint.png +0 -0
  52. package/docs/assets/improvements/er-content-loss.png +0 -0
  53. package/docs/assets/improvements/fan-in-trunks.png +0 -0
  54. package/docs/assets/improvements/gantt-family.png +0 -0
  55. package/docs/assets/improvements/gantt-milestone-clamp.png +0 -0
  56. package/docs/assets/improvements/gantt-verify-seam.png +0 -0
  57. package/docs/assets/improvements/subgraph-container-edges.png +0 -0
  58. package/docs/assets/improvements/wrapper-frontmatter.png +0 -0
  59. package/docs/assets/improvements/wrapper-init-directive.png +0 -0
  60. package/docs/assets/improvements/wrapper-leading-comment.png +0 -0
  61. package/docs/assets/style-cookbook/mid-century-report.png +0 -0
  62. package/docs/assets/style-cookbook/star-chart-atlas.png +0 -0
  63. package/docs/assets/style-cookbook/transit-route-map.png +0 -0
  64. package/docs/comparison.md +0 -94
  65. package/docs/config.md +0 -105
  66. package/docs/contributing/adding-diagram-types.md +0 -144
  67. package/docs/contributing/diagram-family-citizenship.matrix.json +0 -2127
  68. package/docs/contributing/diagram-family-citizenship.md +0 -82
  69. package/docs/contributing/harvesting-upstream-tests.md +0 -126
  70. package/docs/contributing/lessons-learned.md +0 -276
  71. package/docs/contributing/releasing.md +0 -82
  72. package/docs/contributing/visual-review-evidence.md +0 -53
  73. package/docs/custom-style-cookbook.md +0 -154
  74. package/docs/design/families/README.md +0 -26
  75. package/docs/design/families/architecture-beta.md +0 -48
  76. package/docs/design/families/flowchart-parser-conformance.md +0 -22
  77. package/docs/design/families/gantt-research.md +0 -137
  78. package/docs/design/families/gantt.md +0 -329
  79. package/docs/design/families/journey-agentic-cards-before.png +0 -0
  80. package/docs/design/families/journey-experience-curve-implementation.png +0 -0
  81. package/docs/design/families/journey-mermaid-classic-implementation.png +0 -0
  82. package/docs/design/families/journey-mermaid-classic-prototype.png +0 -0
  83. package/docs/design/families/journey-mermaid-classic-prototype.svg +0 -163
  84. package/docs/design/families/journey-mermaid-classic-prototype.svg.png +0 -0
  85. package/docs/design/families/journey-migration-parity.md +0 -439
  86. package/docs/design/families/journey-section-overlap-after.png +0 -0
  87. package/docs/design/families/journey-section-overlap-before.png +0 -0
  88. package/docs/design/families/journey-usage-research.md +0 -423
  89. package/docs/design/families/journey.md +0 -153
  90. package/docs/design/families/xychart.md +0 -85
  91. package/docs/design/system/README.md +0 -45
  92. package/docs/design/system/abstraction-audit.md +0 -224
  93. package/docs/design/system/abstraction-recommendations.md +0 -655
  94. package/docs/design/system/architecture.mmd +0 -29
  95. package/docs/design/system/architecture.svg +0 -137
  96. package/docs/design/system/layout-guarantees-and-robustness.md +0 -351
  97. package/docs/design/system/layout-rubric.md +0 -138
  98. package/docs/design/system/route-contracts.md +0 -848
  99. package/docs/design/system/source-preservation-ladder.md +0 -52
  100. package/docs/design/system/styles-rollout.md +0 -216
  101. package/docs/design/system/ugly-layouts.md +0 -119
  102. package/docs/diagram-families.md +0 -193
  103. package/docs/features.md +0 -147
  104. package/docs/fork-differences.md +0 -130
  105. package/docs/getting-started.md +0 -175
  106. package/docs/issue-derived-test-cases.md +0 -156
  107. package/docs/layout-characterization/README.md +0 -245
  108. package/docs/layout-characterization/contact-sheet-families.md +0 -498
  109. package/docs/layout-characterization/contact-sheet.md +0 -638
  110. package/docs/layout-characterization/properties.md +0 -281
  111. package/docs/layout-characterization/visual-quality.md +0 -160
  112. package/docs/layout-characterization/visual-snapshots/architecture.svg +0 -79
  113. package/docs/layout-characterization/visual-snapshots/class.svg +0 -60
  114. package/docs/layout-characterization/visual-snapshots/er.svg +0 -61
  115. package/docs/layout-characterization/visual-snapshots/flowchart.svg +0 -58
  116. package/docs/layout-characterization/visual-snapshots/gantt.svg +0 -52
  117. package/docs/layout-characterization/visual-snapshots/journey.svg +0 -98
  118. package/docs/layout-characterization/visual-snapshots/pie.svg +0 -36
  119. package/docs/layout-characterization/visual-snapshots/quadrant.svg +0 -47
  120. package/docs/layout-characterization/visual-snapshots/sequence.svg +0 -59
  121. package/docs/layout-characterization/visual-snapshots/state.svg +0 -52
  122. package/docs/layout-characterization/visual-snapshots/timeline.svg +0 -64
  123. package/docs/layout-characterization/visual-snapshots/xychart.svg +0 -97
  124. package/docs/mcp-code-mode-rationale.md +0 -101
  125. package/docs/mcp-http-transport.md +0 -223
  126. package/docs/mermaid-layout-complaints.md +0 -837
  127. package/docs/mutation-testing.md +0 -206
  128. package/docs/project/divergences.md +0 -98
  129. package/docs/project/dogfooding-docs-strategy.md +0 -66
  130. package/docs/project/hosted-mcp-cloudflare-plan.md +0 -338
  131. package/docs/project/lessons-learned.md +0 -1019
  132. package/docs/project/remove-role-styling-plan.md +0 -176
  133. package/docs/quality.md +0 -215
  134. package/docs/react.md +0 -97
  135. package/docs/style-authoring.md +0 -133
  136. package/docs/testing-strategy.md +0 -335
  137. package/docs/theming.md +0 -162
  138. package/examples/agent-improve-auth-flow.ts +0 -206
  139. package/examples/agent-loop.ts +0 -53
  140. package/examples/mcp-vs-cli-complex-diagrams.ts +0 -133
  141. package/llms.txt +0 -104
  142. package/skill-evals/README.md +0 -77
  143. package/skill-evals/fixtures/architecture-cache/input.mmd +0 -5
  144. package/skill-evals/fixtures/class-payment/input.mmd +0 -4
  145. package/skill-evals/fixtures/er-orders/input.mmd +0 -10
  146. package/skill-evals/fixtures/flowchart-cache/input.mmd +0 -3
  147. package/skill-evals/fixtures/gantt-release/input.mmd +0 -7
  148. package/skill-evals/fixtures/journey-checkout/input.mmd +0 -6
  149. package/skill-evals/fixtures/pie-exports/input.mmd +0 -5
  150. package/skill-evals/fixtures/quadrant-priorities/input.mmd +0 -11
  151. package/skill-evals/fixtures/sequence-retry/input.mmd +0 -8
  152. package/skill-evals/fixtures/state-lifecycle/input.mmd +0 -5
  153. package/skill-evals/fixtures/timeline-release/input.mmd +0 -6
  154. package/skill-evals/fixtures/xychart-growth/input.mmd +0 -5
  155. package/skill-evals/shared-benchmark.json +0 -510
  156. package/src/agent/analyze.ts +0 -157
  157. package/src/agent/apply.ts +0 -146
  158. package/src/agent/architecture-body.ts +0 -458
  159. package/src/agent/certificates.ts +0 -110
  160. package/src/agent/class-body.ts +0 -319
  161. package/src/agent/core.ts +0 -207
  162. package/src/agent/create.ts +0 -106
  163. package/src/agent/describe.ts +0 -368
  164. package/src/agent/er-body.ts +0 -224
  165. package/src/agent/facts.ts +0 -360
  166. package/src/agent/families-builtin.ts +0 -920
  167. package/src/agent/families.ts +0 -232
  168. package/src/agent/family-layouts.ts +0 -832
  169. package/src/agent/flowchart-body.ts +0 -372
  170. package/src/agent/flowchart-unsupported.ts +0 -243
  171. package/src/agent/font-coverage.ts +0 -288
  172. package/src/agent/gantt-body.ts +0 -495
  173. package/src/agent/index.ts +0 -10
  174. package/src/agent/journey-body.ts +0 -374
  175. package/src/agent/label-metrics.ts +0 -28
  176. package/src/agent/layout-to-rendered.ts +0 -63
  177. package/src/agent/mutate.ts +0 -97
  178. package/src/agent/mutation-ops.ts +0 -51
  179. package/src/agent/op-schema.ts +0 -443
  180. package/src/agent/parse.ts +0 -223
  181. package/src/agent/pie-body.ts +0 -270
  182. package/src/agent/png.ts +0 -171
  183. package/src/agent/quadrant-body.ts +0 -336
  184. package/src/agent/quality.ts +0 -363
  185. package/src/agent/readability-audit.ts +0 -92
  186. package/src/agent/rendered-route-audit.ts +0 -61
  187. package/src/agent/sequence-body.ts +0 -345
  188. package/src/agent/serialize.ts +0 -214
  189. package/src/agent/state-body.ts +0 -589
  190. package/src/agent/structural-count.ts +0 -150
  191. package/src/agent/timeline-body.ts +0 -280
  192. package/src/agent/trace-log.ts +0 -43
  193. package/src/agent/types.ts +0 -995
  194. package/src/agent/verify.ts +0 -603
  195. package/src/agent/xychart-body.ts +0 -472
  196. package/src/architecture/config.ts +0 -282
  197. package/src/architecture/layout.ts +0 -496
  198. package/src/architecture/parser.ts +0 -375
  199. package/src/architecture/renderer.ts +0 -611
  200. package/src/architecture/types.ts +0 -113
  201. package/src/ascii/ansi.ts +0 -423
  202. package/src/ascii/architecture.ts +0 -210
  203. package/src/ascii/canvas.ts +0 -443
  204. package/src/ascii/class-diagram.ts +0 -697
  205. package/src/ascii/converter.ts +0 -475
  206. package/src/ascii/draw.ts +0 -1693
  207. package/src/ascii/edge-bundling.ts +0 -328
  208. package/src/ascii/edge-routing.ts +0 -330
  209. package/src/ascii/er-diagram.ts +0 -439
  210. package/src/ascii/gantt.ts +0 -276
  211. package/src/ascii/grid.ts +0 -747
  212. package/src/ascii/index.ts +0 -196
  213. package/src/ascii/journey.ts +0 -169
  214. package/src/ascii/meta.ts +0 -244
  215. package/src/ascii/multiline-utils.ts +0 -80
  216. package/src/ascii/pathfinder.ts +0 -301
  217. package/src/ascii/pie.ts +0 -67
  218. package/src/ascii/quadrant.ts +0 -158
  219. package/src/ascii/reverse.ts +0 -216
  220. package/src/ascii/sequence.ts +0 -499
  221. package/src/ascii/shapes/circle.ts +0 -27
  222. package/src/ascii/shapes/corners.ts +0 -143
  223. package/src/ascii/shapes/diamond.ts +0 -27
  224. package/src/ascii/shapes/hexagon.ts +0 -27
  225. package/src/ascii/shapes/index.ts +0 -106
  226. package/src/ascii/shapes/rectangle.ts +0 -168
  227. package/src/ascii/shapes/rounded.ts +0 -27
  228. package/src/ascii/shapes/special.ts +0 -332
  229. package/src/ascii/shapes/stadium.ts +0 -110
  230. package/src/ascii/shapes/state.ts +0 -192
  231. package/src/ascii/shapes/types.ts +0 -73
  232. package/src/ascii/timeline.ts +0 -141
  233. package/src/ascii/types.ts +0 -312
  234. package/src/ascii/validate.ts +0 -120
  235. package/src/ascii/width.ts +0 -81
  236. package/src/ascii/wrap.ts +0 -131
  237. package/src/ascii/xychart.ts +0 -919
  238. package/src/browser.ts +0 -29
  239. package/src/class/layout.ts +0 -240
  240. package/src/class/parser.ts +0 -332
  241. package/src/class/renderer.ts +0 -638
  242. package/src/class/types.ts +0 -129
  243. package/src/cli/agent-instructions.ts +0 -1
  244. package/src/cli/am-bin.ts +0 -6
  245. package/src/cli/exit-codes.ts +0 -18
  246. package/src/cli/index.ts +0 -1132
  247. package/src/cli/init-agent.ts +0 -147
  248. package/src/cli/run-entrypoint.ts +0 -10
  249. package/src/color-resolver.ts +0 -152
  250. package/src/elk-instance.ts +0 -114
  251. package/src/er/layout.ts +0 -187
  252. package/src/er/parser.ts +0 -226
  253. package/src/er/renderer.ts +0 -792
  254. package/src/er/types.ts +0 -99
  255. package/src/family-rubric.ts +0 -425
  256. package/src/font-manifest.ts +0 -31
  257. package/src/gantt/layout.ts +0 -365
  258. package/src/gantt/parser.ts +0 -282
  259. package/src/gantt/pipeline.ts +0 -27
  260. package/src/gantt/renderer.ts +0 -414
  261. package/src/gantt/schedule.ts +0 -513
  262. package/src/gantt/types.ts +0 -255
  263. package/src/index.ts +0 -368
  264. package/src/journey/layout.ts +0 -554
  265. package/src/journey/parse-core.ts +0 -251
  266. package/src/journey/parser.ts +0 -101
  267. package/src/journey/renderer.ts +0 -917
  268. package/src/journey/types.ts +0 -144
  269. package/src/layout/geometry.ts +0 -182
  270. package/src/layout/pass.ts +0 -142
  271. package/src/layout/passes/index.ts +0 -3916
  272. package/src/layout-engine.ts +0 -1565
  273. package/src/layout-rubric.ts +0 -659
  274. package/src/mcp/artifacts.ts +0 -137
  275. package/src/mcp/dynamic-harness.ts +0 -31
  276. package/src/mcp/dynamic-modules.d.ts +0 -7
  277. package/src/mcp/facade.ts +0 -608
  278. package/src/mcp/harness-runtime.ts +0 -203
  279. package/src/mcp/hosted-server.ts +0 -468
  280. package/src/mcp/mcp-bin.ts +0 -3
  281. package/src/mcp/mcp-cli.ts +0 -82
  282. package/src/mcp/protocol.ts +0 -13
  283. package/src/mcp/sandbox.ts +0 -195
  284. package/src/mcp/sdk-decl.ts +0 -391
  285. package/src/mcp/server.ts +0 -362
  286. package/src/mcp/tool-surface.ts +0 -146
  287. package/src/mermaid-source.ts +0 -655
  288. package/src/multiline-utils.ts +0 -228
  289. package/src/parser.ts +0 -1031
  290. package/src/pie/layout.ts +0 -168
  291. package/src/pie/parser.ts +0 -136
  292. package/src/pie/renderer.ts +0 -234
  293. package/src/pie/types.ts +0 -82
  294. package/src/quadrant/layout.ts +0 -191
  295. package/src/quadrant/parser.ts +0 -183
  296. package/src/quadrant/renderer.ts +0 -322
  297. package/src/quadrant/types.ts +0 -113
  298. package/src/render-family-hooks.ts +0 -244
  299. package/src/renderer.ts +0 -1099
  300. package/src/route-contracts.ts +0 -2723
  301. package/src/scene/backend.ts +0 -76
  302. package/src/scene/fidelity.ts +0 -183
  303. package/src/scene/hybrid-backend.ts +0 -174
  304. package/src/scene/ir.ts +0 -181
  305. package/src/scene/marks.ts +0 -127
  306. package/src/scene/rough-backend.ts +0 -378
  307. package/src/scene/seed.ts +0 -46
  308. package/src/scene/style-registry.ts +0 -556
  309. package/src/sequence/layout.ts +0 -456
  310. package/src/sequence/parser.ts +0 -255
  311. package/src/sequence/renderer.ts +0 -604
  312. package/src/sequence/types.ts +0 -154
  313. package/src/shape-clipping.ts +0 -351
  314. package/src/shared/accessibility-directives.ts +0 -22
  315. package/src/shared/batched.ts +0 -61
  316. package/src/shared/color-math.ts +0 -93
  317. package/src/shared/svg-a11y.ts +0 -29
  318. package/src/shared/syntax-error.ts +0 -17
  319. package/src/shared/unicode-ranges.ts +0 -135
  320. package/src/styles.ts +0 -318
  321. package/src/svg-paths.ts +0 -28
  322. package/src/text-metrics.ts +0 -248
  323. package/src/theme.ts +0 -710
  324. package/src/timeline/layout.ts +0 -381
  325. package/src/timeline/parser.ts +0 -215
  326. package/src/timeline/renderer.ts +0 -538
  327. package/src/timeline/types.ts +0 -105
  328. package/src/types.ts +0 -462
  329. package/src/website-worker-modules.d.ts +0 -18
  330. package/src/xychart/axis-utils.ts +0 -109
  331. package/src/xychart/colors.ts +0 -124
  332. package/src/xychart/config.ts +0 -88
  333. package/src/xychart/layout.ts +0 -656
  334. package/src/xychart/parser.ts +0 -504
  335. package/src/xychart/renderer.ts +0 -640
  336. package/src/xychart/types.ts +0 -282
package/dist/agent.d.ts CHANGED
@@ -1,1882 +1,23 @@
1
- import { N as NodeShape, E as EdgeStyle, M as MermaidFrontmatterMap, a as MermaidConfigMap, b as MermaidGraph, D as Direction, R as RouteClass, c as EdgeRouteCertificate, d as RegionContainmentCertificate, e as MermaidNode, f as MermaidEdge, g as NormalizedMermaidSource, h as RenderOptions, i as DiagramColors, P as PositionedDiagram, j as RenderContext, S as SceneDoc, A as AsciiConfig, C as ColorMode, k as AsciiTheme, L as LayoutRouteCertificate, l as AsciiRenderOptions, r as renderMermaidASCII$1, m as renderMermaidSVG$1, n as StyleInput } from './index-wjRjbsP-.js';
2
- export { o as AnyPort, p as DiamondFacet, F as FamilyEdgeRouteCertificate, q as FamilyRouteCertificate, s as LayoutRouteClass, t as PortSemanticRole, u as PortSide, v as RouteBlocker, w as RouteCertificate, x as RoutePortAssignment, y as StyleSpec, T as TEXT_MEASUREMENT_CONTRACT, z as TextMeasurementContract, B as TextMeasurementInput, G as TextMeasurementResult, H as getStyle, I as inferBackend, J as knownStyles, K as measureText, O as measureTextWidth, Q as registerStyle, U as resolveStyleStack, V as validateStyleSpec, W as verifyNoExternalRefs } from './index-wjRjbsP-.js';
1
+ import { AsciiWarning } from './agent-core.js';
2
+ export { ASCII_ROUTE_PARITY_CONTRACT, ApplyOpsInput, AsciiRegion, AsciiWarningCode, AsciiWithMeta, BOUND_PROVENANCE, BoundBasis, BoundProvenance, BuildError, CheckMermaidObjectSpec, CheckMermaidResult, CheckMermaidSpec, CheckedBuildError, CreateMermaidOptions, DEFAULT_BOUNDS, DescribeOptions, DescribeTree, FamilyConformanceError, LayoutCertificateProof, LayoutMermaidOptions, LayoutRenderOptions, MermaidFact, OpEnvelope, OpFamily, OpFieldDoc, OpValidationError, QualityBounds, QualityMeasurementOptions, QualityMetrics, QualityVerdict, RankedViolation, RegionKind, RenderedLayoutArtifact, VerifySummary, ViolationSeverity, analyzeMermaid, analyzeMermaidSource, applyOps, asciiToMermaid, buildChecked, buildMermaid, checkMermaid, checkMermaidSource, checkQuality, collectActionRecords, createMermaid, describeMermaid, describeMermaidFacts, describeMermaidFactsSource, describeMermaidSource, describeMermaidTree, describeOps, edgeIdOf, hasOpSchema, layoutCertificateProof, layoutMermaid, layoutMermaidWithReceipt, measureQuality, mutate, mutateChecked, opMenu, opSignatures, projectPositionedView, registerFamily, renderMermaidASCII, renderMermaidASCIIWithMeta, renderMermaidASCIIWithReceipt, renderMermaidSVG, renderMermaidSVGWithReceipt, serializeMermaid, synthesizeFromGraph, validateOp, verifyMermaid, verifySummary } from './agent-core.js';
3
+ import { P as ParsedDiagram, R as RenderOptions, a as PngOutputPolicyInput, b as RenderRequestReceipt, c as PngRuntimeProvenance, H as HostBackendPolicy, A as AsciiRenderOptions, d as RenderedRegion, D as DiagramActionRecord } from './index-D54dqSdC.js';
4
+ export { e as Accessibility, f as AnyMutationOp, g as AnyPort, h as ArchitectureBody, i as ArchitectureEdge, j as ArchitectureEndpoint, k as ArchitectureEndpointBoundary, l as ArchitectureGroup, m as ArchitectureJunction, n as ArchitectureMutationOp, o as ArchitectureService, p as ArchitectureSide, q as ArchitectureValidDiagram, r as ArchitectureVisualOverrides, s as AsciiRenderColorMode, t as AsciiWidthError, u as AsciiWidthErrorReason, B as BACKEND_CONFORMANCE_CHECK_IDS, v as BACKEND_CONFORMANCE_FIXTURE_ID, w as BACKEND_CONFORMANCE_VERSION, x as BINDABLE_ROLE_STYLE_PROPERTIES, y as BINDABLE_SCENE_ROLES, z as BRAND_CONSTRAINT_DESCRIPTORS, C as BRAND_CONSTRAINT_KINDS, E as BUILTIN_FAMILY_METADATA, F as BUILTIN_FAMILY_METADATA_COVERS_DIAGRAM_KIND, G as BUILTIN_SCENE_ROLE_TRAITS, I as BackendCapabilityConformanceResult, J as BackendCapabilityConformanceStatus, K as BackendConformanceCheck, L as BackendConformanceCheckId, M as BackendConformanceReport, N as BackendDescriptor, O as BackendRegistrationOptions, Q as BindableSceneRole, S as BrandConstraint, T as BrandConstraintAction, U as BrandConstraintKind, V as BuiltinFamilyId, W as BuiltinFamilyMetadata, X as CAPABILITY_NEGOTIATION_VERSION, Y as CORE_CAPABILITY_OFFERS, Z as CORE_SCENE_FEATURES, _ as CORE_SCENE_OPERATIONS, $ as CORE_SCENE_PRIMITIVES, a0 as CapabilityDecision, a1 as CapabilityId, a2 as CapabilityOffer, a3 as CapabilityRequirement, a4 as CapabilityRequirementLevel, a5 as CapabilityResolution, a6 as ClassBody, a7 as ClassMutationOp, a8 as ClassNode, a9 as ClassNote, aa as ClassRelation, ab as ClassRelationKind, ac as ClassValidDiagram, ad as CliRenderTransport, ae as CodeModeRenderTransport, af as ConnectorContourSemantics, ag as ConnectorEndpoints, ah as ConnectorGeometry, ai as ConnectorHitGeometry, aj as ConnectorLabelDescriptor, ak as ConnectorMark, al as ConnectorRelationship, am as ConnectorRoute, an as ConnectorStroke, ao as ConnectorSubpath, ap as ConnectorTerminalLabelProjection, aq as ConnectorTerminalMarkerPlacement, ar as ConnectorTerminalMarkerProjection, as as ConnectorTerminalProjection, at as ConnectorTerminalStrokeLoss, au as DEFAULT_LABEL_CHAR_CAP, av as DefaultBackend, aw as DiagramActionKind, ax as DiagramActionSecurity, ay as DiagramAnalysis, az as DiagramBody, aA as DiagramKind, aB as DiamondFacet, aC as EXACT_ROLE_STYLE_CONTRACT, aD as EXACT_STYLE_SCENE_ROLES, aE as EXTERNAL_SCENE_API_VERSION, aF as EdgeId, aG as EdgeRouteCertificate, aH as ErAttribute, aI as ErBody, aJ as ErCardinality, aK as ErEntity, aL as ErMutationOp, aM as ErRelation, aN as ErValidDiagram, aO as ExactStyleSceneRole, aP as ExtensionDiagramBody, aQ as ExtensionIdentity, aR as ExtensionValidDiagram, aS as ExternalFamilyId, aT as ExternalSceneConnector, aU as ExternalSceneConnectorGeometry, aV as ExternalSceneConnectorLabel, aW as ExternalSceneContainer, aX as ExternalSceneDataMark, aY as ExternalSceneDocument, aZ as ExternalSceneGeometry, a_ as ExternalSceneInput, a$ as ExternalSceneMarker, b0 as ExternalSceneNode, b1 as ExternalSceneNodeBase, b2 as ExternalSceneShape, b3 as ExternalSceneText, b4 as ExtractedLabel, b5 as FAMILY_CAPABILITY_COLUMNS, b6 as FAMILY_CONFORMANCE_MAX_EXAMPLE_BYTES, b7 as FAMILY_CONFORMANCE_VERSION, b8 as FAMILY_DESCRIPTOR_CONTRACT_VERSION, b9 as FamilyCapability, ba as FamilyCapabilityConformanceResult, bb as FamilyCapabilityEvidence, bc as FamilyCapabilityState, bd as FamilyConformanceReport, be as FamilyConformanceStatus, bf as FamilyDescriptor, bg as FamilyDetectionDiagnostic, bh as FamilyEdgeRouteCertificate, bi as FamilyId, bj as FamilyOperations, bk as FamilyParsedBody, bl as FamilyPositionedProjectionContext, bm as FamilyPositionedProjectionOptions, bn as FamilyPositionedView, bo as FamilyRouteCertificate, bp as FamilyScenePositivePrimitive, bq as FamilyScenePrimitiveApplicability, br as FamilyScenePrimitiveEvidence, bs as FamilySceneRolePrimitiveDeclaration, bt as FeedbackEdgeAnalysis, bu as Finite, bv as FlowchartMutationOp, bw as FlowchartValidDiagram, bx as GanttBody, by as GanttBodySection, bz as GanttBodyTask, bA as GanttBodyTaskTag, bB as GanttMutationOp, bC as GanttScheduleAnalysisSummary, bD as GanttStatement, bE as GanttValidDiagram, bF as GitGraphBody, bG as GitGraphMutationOp, bH as GitGraphValidDiagram, bI as GroupId, bJ as HOSTED_FONT_RESOURCES, bK as InitDirective, bL as JourneyBody, bM as JourneyMutationOp, bN as JourneySection, bO as JourneyTask, bP as JourneyValidDiagram, bQ as LayoutRouteCertificate, bR as LayoutRouteClass, bS as LayoutWarning, bT as LibraryRenderTransport, bU as MAX_HOSTED_PNG_BYTES, bV as MAX_HOSTED_PNG_PIXELS, bW as MAX_PNG_FONT_DIRECTORIES, bX as MAX_PNG_FONT_DIRECTORY_LENGTH, bY as MAX_PNG_PIXELS, bZ as MAX_PNG_RASTER_DIMENSION, b_ as MarkerDescriptor, b$ as MermaidFamilyClassification, c0 as MermaidFamilyDetectionError, c1 as MindmapBody, c2 as MindmapMutationOp, c3 as MindmapValidDiagram, c4 as MutableValidDiagram, c5 as MutationError, c6 as NATIVE_PNG_HOST_ONLY_OPTION_FIELDS, c7 as NATIVE_PNG_OUTPUT_POLICY_FIELDS, c8 as NativePngHostOnlyOptionField, c9 as NativePngOutputPolicyField, ca as NodeId, cb as PNG_DEFAULT_FONT_FAMILY, cc as PNG_DEFAULT_SCALE, cd as PNG_FONT_SOURCES, ce as PNG_NAPI_RUNTIME, cf as PNG_OUTPUT_OPTION_FIELDS, cg as PNG_OUTPUT_OPTION_FIELD_DESCRIPTORS, ch as PNG_OUTPUT_POLICY_VERSION, ci as PNG_WASM_RUNTIME, cj as PORTABLE_PNG_OUTPUT_OPTION_FIELDS, ck as PRIMITIVE_REALIZATIONS, cl as ParseError, cm as ParticipantId, cn as PieBody, co as PieMutationOp, cp as PieSlice, cq as PieValidDiagram, cr as PngFitTo, cs as PngFontSource, ct as PngOutputOptionField, cu as PngOutputOptionFieldDescriptor, cv as PngOutputOptionInputKind, cw as PngOutputOptionPolicyState, cx as PngOutputOptionReceiptState, cy as PngOutputOptionScope, cz as PngRasterDimensions, cA as PortSemanticRole, cB as PortSide, cC as PortablePngOutputOptionField, cD as PortablePngOutputOptions, cE as PreservedDiagramBody, cF as PreservedSourceSpans, cG as PreservedValidDiagram, cH as QuadrantAxis, cI as QuadrantBody, cJ as QuadrantMutationOp, cK as QuadrantPoint, cL as QuadrantValidDiagram, cM as RENDER_CONTRACT_VERSION, cN as RENDER_OUTPUTS, cO as RENDER_OUTPUT_DESCRIPTORS, cP as RESOURCE_MANIFEST, cQ as RESOURCE_MANIFEST_VERSION, cR as ROLE_STYLE_PROPERTY_DESCRIPTORS, cS as RadarBody, cT as RadarBodyAxis, cU as RadarBodyCurve, cV as RadarMutationOp, cW as RadarValidDiagram, cX as RegionContainmentCertificate, cY as RenderCapabilityError, cZ as RenderOutputDescriptor, c_ as RenderOutputTransports, c$ as RenderedAscii, d0 as RenderedLayout, d1 as RenderedLayoutEdge, d2 as RenderedLayoutGroup, d3 as RenderedLayoutNode, d4 as RenderedRegionKind, d5 as ResolvedPngOutputPolicy, d6 as ResolvedTerminalOutputPolicy, d7 as Result, d8 as RoleStyleFor, d9 as RoleStyleSpec, da as RoleStyles, db as RouteBlocker, dc as RouteCertificate, dd as RouteClass, de as RoutePortAssignment, df as SCENE_CONTRACT_VERSION, dg as SCENE_ROLE_DESCRIPTORS, dh as SCENE_VALIDATION_LIMITS, di as SCENE_VALIDATION_VERSION, dj as SEMANTIC_BINDING_CHANNELS, dk as SHARED_RENDER_OPTION_FIELDS, dl as STYLE_COLOR_TOKEN_DESCRIPTORS, dm as STYLE_SPEC_FIELD_DESCRIPTORS, dn as STYLE_SPEC_FORMAT_VERSION, dp as SceneDoc, dq as SceneNode, dr as SceneRole, ds as SceneValidationDiagnostic, dt as SceneValidationDiagnosticCode, du as SceneValidationError, dv as SceneValidationOptions, dw as SceneValidationResult, dx as SemanticBinding, dy as SemanticBindingChannel, dz as SemanticChannels, dA as SemanticSlots, dB as SequenceBody, dC as SequenceMessage, dD as SequenceMessageStyle, dE as SequenceMutationOp, dF as SequenceParticipant, dG as SequenceValidDiagram, dH as SerializedFlowchartGraph, dI as SourceComment, dJ as SourceMap, dK as SourceMapSpans, dL as SourcePreservationReceipt, dM as SourceSpan, dN as SourceSpanPoint, dO as StateBody, dP as StateMutationOp, dQ as StateNode, dR as StateTransition, dS as StateValidDiagram, dT as StyleBackend, dU as StyleBackendContext, dV as StyleColors, dW as StyleDescriptor, dX as StyleInput, dY as StyleReferenceResolution, dZ as StyleRegistrationOptions, d_ as StyleSpec, d$ as TERMINAL_BOUNDED_PADDING_X, e0 as TERMINAL_DEFAULT_BOX_BORDER_PADDING, e1 as TERMINAL_DEFAULT_PADDING_X, e2 as TERMINAL_DEFAULT_PADDING_Y, e3 as TERMINAL_OUTPUT_POLICY_VERSION, e4 as TEXT_MEASUREMENT_CONTRACT, e5 as TerminalOutputPolicyError, e6 as TerminalOutputPolicyInput, e7 as TextMeasurementContract, e8 as TextMeasurementInput, e9 as TextMeasurementResult, ea as Tier1WarningCode, eb as Tier2WarningCode, ec as TimelineBody, ed as TimelineEvent, ee as TimelineMutationOp, ef as TimelinePeriod, eg as TimelineSection, eh as TimelineValidDiagram, ei as UNREGISTERED_FAMILY_CAPABILITY_STATES, ej as UPSTREAM_MERMAID_FAMILY_INDEX, ek as UpstreamFamilyDescriptor, el as UpstreamHeaderDescriptor, em as UpstreamHeaderMatch, en as UpstreamManifestDiff, eo as UpstreamMermaidFamilyIndex, ep as UpstreamMermaidManifest, eq as ValidDiagram, er as ValidDiagramMeta, es as ValidDiagramPayload, et as VerifyOptions, eu as VerifyResult, ev as WARNING_SEVERITY, ew as WARNING_TIER, ex as WarningCode, ey as WarningSeverity, ez as WarningTier, eA as XyChartAxis, eB as XyChartAxisSpec, eC as XyChartBody, eD as XyChartMutationOp, eE as XyChartSeries, eF as XyChartValidDiagram, eG as asArchitecture, eH as asClass, eI as asEr, eJ as asFlowchart, eK as asGantt, eL as asGitGraph, eM as asJourney, eN as asMindmap, eO as asPie, eP as asQuadrant, eQ as asRadar, eR as asSequence, eS as asState, eT as asTimeline, eU as asXyChart, eV as assertHostedPngRasterBudget, eW as assertPngRasterBudget, eX as assertValidSceneDoc, eY as buildExternalScene, eZ as builtinFamilyMetadata, e_ as classifyMermaidFamilyFromFirstLine, e$ as createExtensionIdentity, f0 as declareFamilyScenePrimitiveEvidence, f1 as detectRegisteredFamilyFromFirstLine, f2 as effectiveFamilyCapabilityState, f3 as err, f4 as findUpstreamFamilyByHeader, f5 as getBackend, f6 as getFamily, f7 as getFamilyConformanceReport, f8 as getStyle, f9 as hostedFontResource, fa as inferBackend, fb as isBuiltinFamilyId, fc as isExternalFamilyId, fd as knownBackendDescriptors, fe as knownBuiltinFamilies, ff as knownFamilies, fg as knownStyleDescriptors, fh as knownStyles, fi as measureText, fj as measureTextWidth, fk as negotiateCapabilities, fl as negotiateRenderCapabilities, fm as normalizePortablePngBackground, fn as ok, fo as omitPngOutputOptions, fp as parseRegisteredMermaid, fq as parseSemVer, fr as pngNapiRuntimeProvenance, fs as pngOutputOptionsJsonSchema, ft as pngRasterDimensions, fu as prepareSvgForPngRasterization, fv as projectNativePngOutputPolicyInput, fw as projectPortablePngOutputOptions, fx as registerBackend, fy as registerStyle, fz as resolvePngOutputPolicy, fA as resolvePortablePngOutputPolicy, fB as resolveSceneRoleTraits, fC as resolveStyleReference, fD as resolveStyleStack, fE as resolveTerminalOutputPolicy, fF as runBackendConformance, fG as sceneRoleTraits, fH as semVerSatisfies, fI as sharedRenderOptionsJsonSchema, fJ as styleInputJsonSchema, fK as styleSpecJsonSchema, fL as svgIntrinsicDimensions, fM as terminalConnectorCapabilityClaims, fN as toFinite, fO as validatePrimitiveCapabilities, fP as validateResourceManifest, fQ as validateSceneDoc, fR as validateSerializableRenderOptions, fS as validateStyleSpec, fT as verifyNoExternalRefs, fU as verifyResourceBytes } from './index-D54dqSdC.js';
3
5
 
4
- type Result<T, E> = {
5
- ok: true;
6
- value: T;
7
- } | {
8
- ok: false;
9
- error: E;
10
- };
11
- declare function ok<T, E = never>(value: T): Result<T, E>;
12
- declare function err<E, T = never>(error: E): Result<T, E>;
13
- type DiagramKind = 'flowchart' | 'state' | 'sequence' | 'class' | 'er' | 'timeline' | 'journey' | 'xychart' | 'architecture' | 'pie' | 'quadrant' | 'gantt';
14
- interface SequenceParticipant {
15
- id: string;
16
- label: string;
17
- kind: 'participant' | 'actor';
18
- }
19
- type SequenceMessageStyle = 'sync' | 'reply' | 'async' | 'async-dashed' | 'lost' | 'lost-dashed';
20
- interface SequenceMessage {
21
- from: string;
22
- to: string;
23
- text: string;
24
- style: SequenceMessageStyle;
25
- }
26
- type SequenceStatement = {
27
- kind: 'participant';
28
- ref: number;
29
- } | {
30
- kind: 'message';
31
- ref: number;
32
- } | {
33
- kind: 'opaque-block';
34
- lines: string[];
35
- };
36
- interface SequenceBody {
37
- kind: 'sequence';
38
- participants: SequenceParticipant[];
39
- messages: SequenceMessage[];
40
- statements?: SequenceStatement[];
41
- }
42
- interface TimelineEvent {
43
- /** Stable within one parse; recomputed each parse. Not a durable identifier. */
44
- id: string;
45
- text: string;
46
- }
47
- interface TimelinePeriod {
48
- id: string;
49
- /** The temporal label (e.g., "2020", "Q1 2024"). */
50
- label: string;
51
- events: TimelineEvent[];
52
- }
53
- interface TimelineSection {
54
- id: string;
55
- /** Undefined = implicit/ungrouped section. */
56
- label?: string;
57
- periods: TimelinePeriod[];
58
- }
59
- interface TimelineBody {
60
- kind: 'timeline';
61
- title?: string;
62
- sections: TimelineSection[];
63
- }
64
- interface JourneyTask {
65
- /** Stable within one parse; recomputed each parse. Not a durable identifier. */
66
- id: string;
67
- text: string;
68
- /** Satisfaction score, integer 1..5 (Mermaid journey convention). */
69
- score: number;
70
- actors: string[];
71
- }
72
- interface JourneySection {
73
- id: string;
74
- /** Undefined = implicit/ungrouped section. */
75
- label?: string;
76
- tasks: JourneyTask[];
77
- }
78
- interface JourneyBody {
79
- kind: 'journey';
80
- title?: string;
81
- /** Optional accessibility title from Mermaid accTitle. */
82
- accessibilityTitle?: string;
83
- /** Optional accessibility description from Mermaid accDescr. */
84
- accessibilityDescription?: string;
85
- sections: JourneySection[];
86
- }
87
- type ClassRelationKind = 'inheritance' | 'composition' | 'aggregation' | 'association' | 'dependency' | 'realization' | 'link-solid' | 'link-dashed';
88
- interface ClassNode {
89
- /** The bare class name (e.g., 'Animal'). */
90
- id: string;
91
- /** Optional display label (e.g., from `class X["My Label"]` or `class X as "..."`). */
92
- label?: string;
93
- /** Members, each as the raw source string ('+String name', '+eat()', '<<interface>>'). */
94
- members: string[];
95
- }
96
- interface ClassRelation {
97
- from: string;
98
- to: string;
99
- kind: ClassRelationKind;
100
- /** Optional relationship label, e.g., from `A --> B : uses`. */
101
- label?: string;
102
- /** Optional cardinality on the `from` side (e.g., '"1"'). */
103
- fromCardinality?: string;
104
- /** Optional cardinality on the `to` side. */
105
- toCardinality?: string;
106
- }
107
- interface ClassNote {
108
- text: string;
109
- /** Class id the note is attached to (undefined = freestanding). */
110
- for?: string;
111
- }
112
- interface ClassBody {
113
- kind: 'class';
114
- title?: string;
115
- classes: ClassNode[];
116
- relations: ClassRelation[];
117
- notes: ClassNote[];
118
- }
119
- type ErCardinality = 'one-only' | 'zero-or-one' | 'zero-or-many' | 'one-or-many';
120
- interface ErAttribute {
121
- /** The full source line (e.g., 'string name PK "comment"'). */
122
- text: string;
123
- }
124
- interface ErEntity {
125
- id: string;
126
- attributes: ErAttribute[];
127
- }
128
- interface ErRelation {
129
- from: string;
130
- to: string;
131
- leftCard: ErCardinality;
132
- rightCard: ErCardinality;
133
- /** Solid (--) or dashed (..) line. */
134
- dashed: boolean;
135
- label?: string;
136
- }
137
- interface ErBody {
138
- kind: 'er';
139
- entities: ErEntity[];
140
- relations: ErRelation[];
141
- }
142
- type ArchitectureSide = 'L' | 'R' | 'T' | 'B';
143
- interface ArchitectureGroup {
144
- id: string;
145
- label: string;
146
- icon?: string;
147
- /** Undefined = root (not nested in another group). */
148
- parentId?: string;
149
- }
150
- interface ArchitectureService {
151
- id: string;
152
- label: string;
153
- icon?: string;
154
- /** Undefined = ungrouped (not inside a group). */
155
- parentId?: string;
156
- }
157
- interface ArchitectureJunction {
158
- id: string;
159
- parentId?: string;
160
- }
161
- interface ArchitectureEndpoint {
162
- id: string;
163
- side: ArchitectureSide;
164
- }
165
- interface ArchitectureEdge {
166
- source: ArchitectureEndpoint;
167
- target: ArchitectureEndpoint;
168
- label?: string;
169
- hasArrowStart: boolean;
170
- hasArrowEnd: boolean;
171
- }
172
- interface ArchitectureBody {
173
- kind: 'architecture';
174
- groups: ArchitectureGroup[];
175
- services: ArchitectureService[];
176
- junctions: ArchitectureJunction[];
177
- edges: ArchitectureEdge[];
178
- }
179
- /** A single chart axis: an optional bare-text name plus EITHER categorical
180
- * labels (x-axis only) OR a numeric range. All three fields are optional;
181
- * a structured axis carries at least one of them. */
182
- interface XyChartAxis {
183
- /** Optional bare-text axis name/title. */
184
- name?: string;
185
- /** Categorical labels (x-axis only) — mutually exclusive with range. */
186
- categories?: string[];
187
- /** Numeric range — mutually exclusive with categories. */
188
- range?: {
189
- min: number;
190
- max: number;
191
- };
192
- }
193
- interface XyChartSeries {
194
- /** Stable within one parse; recomputed each parse. Not a durable identifier. */
195
- id: string;
196
- kind: 'bar' | 'line';
197
- /** Optional bare-text series name. */
198
- name?: string;
199
- /** Data values; all finite. */
200
- values: number[];
201
- }
202
- interface XyChartBody {
203
- kind: 'xychart';
204
- title?: string;
205
- /** Header orientation suffix: `xychart-beta horizontal`. Default vertical. */
206
- horizontal?: boolean;
207
- xAxis?: XyChartAxis;
208
- yAxis?: XyChartAxis;
209
- series: XyChartSeries[];
210
- }
211
- interface PieSlice {
212
- /** Stable within one parse; recomputed each parse. Not a durable identifier. */
213
- id: string;
214
- /** The slice label (contents of the `"..."` quotes). */
215
- label: string;
216
- /** The slice value — a positive finite number. */
217
- value: number;
218
- }
219
- interface PieBody {
220
- kind: 'pie';
221
- title?: string;
222
- /** When true (`pie showData`), the legend shows each slice's numeric value. */
223
- showData: boolean;
224
- /** Slices in source order (drawn clockwise). */
225
- slices: PieSlice[];
226
- }
227
- /** Axis label pair. The "far" side is optional in the grammar. */
228
- interface QuadrantAxis {
229
- /** x-axis: left label / y-axis: bottom label. */
230
- near: string;
231
- /** x-axis: right label / y-axis: top label. Optional. */
232
- far?: string;
233
- }
234
- interface QuadrantPoint {
235
- label: string;
236
- /** Normalized x in [0, 1] (0 = left, 1 = right). */
237
- x: number;
238
- /** Normalized y in [0, 1] (0 = bottom, 1 = top). */
239
- y: number;
240
- }
241
- interface QuadrantBody {
242
- kind: 'quadrant';
243
- title?: string;
244
- xAxis?: QuadrantAxis;
245
- yAxis?: QuadrantAxis;
246
- /**
247
- * Quadrant region labels indexed 1..4 by Mermaid's numbering:
248
- * 1 = top-right, 2 = top-left, 3 = bottom-left, 4 = bottom-right.
249
- * Stored 0-based where index `n-1` holds quadrant-`n`.
250
- */
251
- quadrants: [string?, string?, string?, string?];
252
- /** Plotted points in source order. */
253
- points: QuadrantPoint[];
254
- }
255
- type GanttBodyTaskTag = 'active' | 'done' | 'crit' | 'milestone' | 'vert';
256
- interface GanttBodyTask {
257
- /** Stable within one parse; recomputed each parse. Not a durable identifier. */
258
- id: string;
259
- /** Mermaid task id from `:id, start, end` — referenced by after/until/click. */
260
- taskId?: string;
261
- label: string;
262
- /** Status/shape tags in canonical order (active/done/crit/milestone/vert). */
263
- tags: GanttBodyTaskTag[];
264
- /** Raw start expression: a date in the diagram's dateFormat or `after id…`.
265
- * Undefined = starts when the previous task ends (Mermaid default). */
266
- start?: string;
267
- /** Raw end expression: a date, a duration token (`3d`), or `until id…`. */
268
- end: string;
269
- }
270
- interface GanttBodySection {
271
- id: string;
272
- /** Undefined = implicit/ungrouped section. */
273
- label?: string;
274
- tasks: GanttBodyTask[];
275
- }
276
- /**
277
- * Segment-preserving statement list (the sequence-body pattern): typed ops see
278
- * sections/tasks/title; calendar directives (dateFormat, excludes, weekend…),
279
- * click lines, comments, and markers ride along VERBATIM as opaque-block
280
- * segments — never dropped, edited at the source level only.
281
- */
282
- type GanttStatement = {
283
- kind: 'title';
284
- } | {
285
- kind: 'section';
286
- ref: number;
287
- } | {
288
- kind: 'task';
289
- section: number;
290
- ref: number;
291
- } | {
292
- kind: 'opaque-block';
293
- lines: string[];
294
- };
295
- interface GanttBody {
296
- kind: 'gantt';
297
- title?: string;
298
- sections: GanttBodySection[];
299
- /** Optional for synthesized payloads; parsed bodies always populate it. */
300
- statements?: GanttStatement[];
301
- }
302
- /**
303
- * A state node. Simple states carry an optional display label; composite states
304
- * additionally carry their own nested `states` + `transitions` (and an optional
305
- * per-composite `direction`). The reserved pseudostate `[*]` is NOT a StateNode
306
- * — it is modeled contextually as the endpoint id '[*]' on transitions (source
307
- * = start pseudostate, target = end pseudostate), scoped per composite level.
308
- */
309
- interface StateNode {
310
- id: string;
311
- /** Optional display label (`state "Label" as id` / `id : Label`). */
312
- label?: string;
313
- /** Composite children — present iff this is a composite state. */
314
- states?: StateNode[];
315
- /** Composite-internal transitions — present iff this is a composite state. */
316
- transitions?: StateTransition[];
317
- /** Optional per-composite layout direction. */
318
- direction?: Direction;
319
- }
320
- interface StateTransition {
321
- /** Source state id, or '[*]' for a start pseudostate. */
322
- from: string;
323
- /** Target state id, or '[*]' for an end pseudostate. */
324
- to: string;
325
- label?: string;
326
- }
327
- interface StateBody {
328
- kind: 'state';
329
- states: StateNode[];
330
- transitions: StateTransition[];
331
- /** Optional top-level layout direction. */
332
- direction?: Direction;
333
- }
334
- interface SourceComment {
335
- text: string;
336
- line: number;
337
- }
338
- interface InitDirective {
339
- raw: string;
340
- parsed: MermaidConfigMap;
341
- }
342
- interface Accessibility {
343
- title?: string;
344
- descr?: string;
345
- }
346
- interface ValidDiagramMeta {
347
- frontmatter?: MermaidFrontmatterMap;
348
- initDirectives: InitDirective[];
349
- comments: SourceComment[];
350
- accessibility: Accessibility;
351
- /**
352
- * The leading source wrapper (frontmatter block, `%%{init}%%` directives,
353
- * `%%` comments, and blank lines before the diagram header), preserved
354
- * byte-verbatim. serializeMermaid re-emits it untouched by default;
355
- * canonical wrapper synthesis is opt-in via `{ wrapper: 'canonical' }`.
356
- * Absent on diagrams synthesized from JSON payloads, which fall back to
357
- * canonical synthesis.
358
- */
359
- wrapperSource?: string;
360
- /**
361
- * In-body `%%` comments that structured serialization does not preserve,
362
- * computed at parse time by diffing against the canonical serialization.
363
- * Surfaced by verify as the Tier 3 `COMMENT_DROPPED` lint. Opaque bodies
364
- * preserve comments verbatim and never set this.
365
- */
366
- droppedComments?: SourceComment[];
367
- }
368
- interface SourceLocation {
369
- line: number;
370
- col: number;
371
- }
372
- interface SourceMap {
373
- nodes: Map<string, SourceLocation>;
374
- edges: Map<string, SourceLocation>;
375
- groups: Map<string, SourceLocation>;
376
- /** Stable label spans where known: `node:<id>`, `edge#<i>:<from>-><to>`, `group:<id>`. */
377
- labels: Map<string, SourceLocation>;
378
- }
379
- type DiagramActionKind = 'href' | 'call' | 'callback';
380
- type DiagramActionSecurity = 'safe' | 'unsafe' | 'source-only' | 'unsupported';
381
- interface DiagramActionRecord {
382
- /** Stable source-side action id (`action:<family>:<target>:<n>`). */
383
- id?: string;
384
- /** Region id this action attaches to when a rendered layout exposes regions. */
385
- regionId?: string;
386
- family: DiagramKind;
387
- target: string;
388
- action: DiagramActionKind;
389
- /** Original action payload after the target id; never executed by analysis. */
390
- raw: string;
391
- line?: number;
392
- href?: string;
393
- security: DiagramActionSecurity;
394
- executable: false;
395
- message?: string;
396
- }
397
- interface FeedbackEdgeAnalysis {
398
- edgeIndex: number;
399
- from: NodeId;
400
- to: NodeId;
401
- label?: string;
402
- routeClass: RouteClass;
403
- }
404
- interface GanttScheduleAnalysisSummary {
405
- criticalPathTaskIds: string[];
406
- slackByTaskId: Record<string, number>;
407
- projectStart: number;
408
- projectEnd: number;
409
- entryTaskIds: string[];
410
- sinkTaskIds: string[];
411
- }
412
- interface DiagramAnalysis {
413
- kind: DiagramKind;
414
- feedbackEdges: FeedbackEdgeAnalysis[];
415
- actions: DiagramActionRecord[];
416
- gantt?: GanttScheduleAnalysisSummary;
417
- }
418
- type DiagramBody = {
419
- kind: 'flowchart';
420
- graph: MermaidGraph;
421
- } | StateBody | SequenceBody | TimelineBody | ClassBody | ErBody | JourneyBody | ArchitectureBody | XyChartBody | PieBody | QuadrantBody | GanttBody
422
- /**
423
- * Opaque body — the parser understood the family header but encountered
424
- * unmodeled syntax. `source` is the ORIGINAL body with indentation, blank
425
- * lines, and comments PRESERVED (per the Loop 5 Phase A fix), so the
426
- * serializer can re-emit byte-for-byte. Distinct from `ValidDiagram.canonicalSource`,
427
- * which for structured bodies is the rebuilt canonical form.
428
- */
429
- | {
430
- kind: 'opaque';
431
- family: DiagramKind;
432
- source: string;
433
- };
434
- interface ValidDiagram {
435
- readonly kind: DiagramKind;
436
- readonly meta: ValidDiagramMeta;
437
- readonly body: DiagramBody;
438
- readonly source: SourceMap;
439
- /**
440
- * Load-bearing round-trip pillar. See AGENT_NATIVE.md § (3).
441
- *
442
- * For STRUCTURED bodies, `canonicalSource` is the normalized text
443
- * (`normalized.text` from `mermaid-source.ts`) — used by `renderMermaidSVG`
444
- * + the legacy parser for the flowchart pathway. After `serializeMermaid`,
445
- * the re-emitted source is rebuilt from the structured body.
446
- *
447
- * For OPAQUE bodies, the serializer emits `body.source` directly (NOT
448
- * `canonicalSource`) so original indentation and blank lines round-trip
449
- * byte-for-byte. `canonicalSource` is still set, but it's the normalized
450
- * (line-trimmed) form — useful for layout / rendering, not for fidelity.
451
- *
452
- * This split exists because the legacy flowchart parser needs trimmed
453
- * lines, but opaque-fallback round-trip needs the original. Treat
454
- * `body.source` as the source of truth for opaque-body fidelity.
455
- */
456
- readonly canonicalSource: string;
457
- }
458
- type FlowchartValidDiagram = ValidDiagram & {
459
- body: {
460
- kind: 'flowchart';
461
- graph: MermaidGraph;
462
- };
463
- };
464
- type StateValidDiagram = ValidDiagram & {
465
- body: StateBody;
466
- };
467
- type SequenceValidDiagram = ValidDiagram & {
468
- body: SequenceBody;
469
- };
470
- type TimelineValidDiagram = ValidDiagram & {
471
- body: TimelineBody;
472
- };
473
- type ClassValidDiagram = ValidDiagram & {
474
- body: ClassBody;
475
- };
476
- type ErValidDiagram = ValidDiagram & {
477
- body: ErBody;
478
- };
479
- type JourneyValidDiagram = ValidDiagram & {
480
- body: JourneyBody;
481
- };
482
- type ArchitectureValidDiagram = ValidDiagram & {
483
- body: ArchitectureBody;
484
- };
485
- type XyChartValidDiagram = ValidDiagram & {
486
- body: XyChartBody;
487
- };
488
- type PieValidDiagram = ValidDiagram & {
489
- body: PieBody;
490
- };
491
- type QuadrantValidDiagram = ValidDiagram & {
492
- body: QuadrantBody;
493
- };
494
- type GanttValidDiagram = ValidDiagram & {
495
- body: GanttBody;
496
- };
497
- type MutableValidDiagram = FlowchartValidDiagram | StateValidDiagram | SequenceValidDiagram | TimelineValidDiagram | ClassValidDiagram | ErValidDiagram | JourneyValidDiagram | ArchitectureValidDiagram | XyChartValidDiagram | PieValidDiagram | QuadrantValidDiagram | GanttValidDiagram;
498
- declare function asFlowchart(d: ValidDiagram): FlowchartValidDiagram | null;
499
- declare function asState(d: ValidDiagram): StateValidDiagram | null;
500
- declare function asSequence(d: ValidDiagram): SequenceValidDiagram | null;
501
- declare function asTimeline(d: ValidDiagram): TimelineValidDiagram | null;
502
- declare function asClass(d: ValidDiagram): ClassValidDiagram | null;
503
- declare function asEr(d: ValidDiagram): ErValidDiagram | null;
504
- declare function asJourney(d: ValidDiagram): JourneyValidDiagram | null;
505
- declare function asArchitecture(d: ValidDiagram): ArchitectureValidDiagram | null;
506
- declare function asXyChart(d: ValidDiagram): XyChartValidDiagram | null;
507
- declare function asPie(d: ValidDiagram): PieValidDiagram | null;
508
- declare function asQuadrant(d: ValidDiagram): QuadrantValidDiagram | null;
509
- declare function asGantt(d: ValidDiagram): GanttValidDiagram | null;
510
- interface ParseError {
511
- code: string;
512
- message: string;
513
- line?: number;
514
- col?: number;
515
- }
516
- interface MutationError {
517
- code: 'NODE_NOT_FOUND' | 'EDGE_NOT_FOUND' | 'PARTICIPANT_NOT_FOUND' | 'MESSAGE_NOT_FOUND' | 'SECTION_NOT_FOUND' | 'PERIOD_NOT_FOUND' | 'EVENT_NOT_FOUND' | 'TASK_NOT_FOUND' | 'ACTOR_NOT_FOUND' | 'CLASS_NOT_FOUND' | 'MEMBER_NOT_FOUND' | 'RELATION_NOT_FOUND' | 'NOTE_NOT_FOUND' | 'ENTITY_NOT_FOUND' | 'ATTRIBUTE_NOT_FOUND' | 'SERVICE_NOT_FOUND' | 'GROUP_NOT_FOUND' | 'SERIES_NOT_FOUND' | 'SLICE_NOT_FOUND' | 'POINT_NOT_FOUND' | 'STATE_NOT_FOUND' | 'TRANSITION_NOT_FOUND' | 'DUPLICATE_NODE' | 'DUPLICATE_PARTICIPANT' | 'DUPLICATE_CLASS' | 'DUPLICATE_ENTITY' | 'DUPLICATE_STATE' | 'DUPLICATE_TASK' | 'INVALID_OP';
518
- message: string;
519
- }
520
- type NodeId = string;
521
- type EdgeId = string;
522
- type GroupId = string;
523
- type ParticipantId = string;
524
- type FlowchartMutationOp = {
525
- kind: 'add_node';
526
- id: NodeId;
527
- label: string;
528
- shape?: NodeShape;
529
- parent?: GroupId;
530
- } | {
531
- kind: 'remove_node';
532
- id: NodeId;
533
- } | {
534
- kind: 'rename_node';
535
- from: NodeId;
536
- to: NodeId;
537
- } | {
538
- kind: 'set_label';
539
- target: NodeId | EdgeId;
540
- label: string;
541
- } | {
542
- kind: 'add_edge';
543
- from: NodeId;
544
- to: NodeId;
545
- label?: string;
546
- style?: EdgeStyle;
547
- } | {
548
- kind: 'remove_edge';
549
- id: EdgeId;
550
- };
551
- type SequenceMutationOp = {
552
- kind: 'add_participant';
553
- id: ParticipantId;
554
- label?: string;
555
- participantKind?: 'participant' | 'actor';
556
- } | {
557
- kind: 'remove_participant';
558
- id: ParticipantId;
559
- } | {
560
- kind: 'add_message';
561
- from: ParticipantId;
562
- to: ParticipantId;
563
- text: string;
564
- style?: SequenceMessageStyle;
565
- } | {
566
- kind: 'remove_message';
567
- index: number;
568
- } | {
569
- kind: 'set_message_text';
570
- index: number;
571
- text: string;
572
- };
573
- type TimelineMutationOp = {
574
- kind: 'set_title';
575
- title: string | null;
576
- } | {
577
- kind: 'add_section';
578
- label: string;
579
- } | {
580
- kind: 'remove_section';
581
- index: number;
582
- } | {
583
- kind: 'set_section_label';
584
- index: number;
585
- label: string;
586
- } | {
587
- kind: 'add_period';
588
- sectionIndex: number;
589
- label: string;
590
- events?: string[];
591
- } | {
592
- kind: 'remove_period';
593
- sectionIndex: number;
594
- periodIndex: number;
595
- } | {
596
- kind: 'set_period_label';
597
- sectionIndex: number;
598
- periodIndex: number;
599
- label: string;
600
- } | {
601
- kind: 'add_event';
602
- sectionIndex: number;
603
- periodIndex: number;
604
- text: string;
605
- } | {
606
- kind: 'remove_event';
607
- sectionIndex: number;
608
- periodIndex: number;
609
- eventIndex: number;
610
- } | {
611
- kind: 'set_event_text';
612
- sectionIndex: number;
613
- periodIndex: number;
614
- eventIndex: number;
615
- text: string;
616
- };
617
- type ClassMutationOp = {
618
- kind: 'set_title';
619
- title: string | null;
620
- } | {
621
- kind: 'add_class';
622
- id: string;
623
- label?: string;
624
- members?: string[];
625
- } | {
626
- kind: 'remove_class';
627
- id: string;
628
- } | {
629
- kind: 'rename_class';
630
- from: string;
631
- to: string;
632
- } | {
633
- kind: 'add_member';
634
- class: string;
635
- text: string;
636
- } | {
637
- kind: 'remove_member';
638
- class: string;
639
- index: number;
640
- } | {
641
- kind: 'add_relation';
642
- from: string;
643
- to: string;
644
- relKind: ClassRelationKind;
645
- label?: string;
646
- } | {
647
- kind: 'remove_relation';
648
- index: number;
649
- } | {
650
- kind: 'add_note';
651
- text: string;
652
- for?: string;
653
- } | {
654
- kind: 'remove_note';
655
- index: number;
656
- };
657
- type ErMutationOp = {
658
- kind: 'add_entity';
659
- id: string;
660
- attributes?: string[];
661
- } | {
662
- kind: 'remove_entity';
663
- id: string;
664
- } | {
665
- kind: 'rename_entity';
666
- from: string;
667
- to: string;
668
- } | {
669
- kind: 'add_attribute';
670
- entity: string;
671
- text: string;
672
- } | {
673
- kind: 'remove_attribute';
674
- entity: string;
675
- index: number;
676
- } | {
677
- kind: 'add_relation';
678
- from: string;
679
- to: string;
680
- leftCard: ErCardinality;
681
- rightCard: ErCardinality;
682
- dashed?: boolean;
683
- label?: string;
684
- } | {
685
- kind: 'remove_relation';
686
- index: number;
687
- };
688
- type JourneyMutationOp = {
689
- kind: 'set_title';
690
- title: string | null;
691
- } | {
692
- kind: 'add_section';
693
- label: string;
694
- index?: number;
695
- } | {
696
- kind: 'remove_section';
697
- index: number;
698
- } | {
699
- kind: 'set_section_label';
700
- index: number;
701
- label: string;
702
- } | {
703
- kind: 'add_task';
704
- sectionIndex: number;
705
- text: string;
706
- score: number;
707
- actors?: string[];
708
- index?: number;
709
- } | {
710
- kind: 'remove_task';
711
- sectionIndex: number;
712
- taskIndex: number;
713
- } | {
714
- kind: 'set_task_text';
715
- sectionIndex: number;
716
- taskIndex: number;
717
- text: string;
718
- } | {
719
- kind: 'set_task_score';
720
- sectionIndex: number;
721
- taskIndex: number;
722
- score: number;
723
- } | {
724
- kind: 'set_task_actors';
725
- sectionIndex: number;
726
- taskIndex: number;
727
- actors: string[];
728
- } | {
729
- kind: 'rename_actor';
730
- from: string;
731
- to: string;
732
- } | {
733
- kind: 'move_task';
734
- fromSection: number;
735
- fromIndex: number;
736
- toSection: number;
737
- toIndex: number;
738
- } | {
739
- kind: 'move_section';
740
- from: number;
741
- to: number;
742
- } | {
743
- kind: 'set_accessibility_title';
744
- title: string | null;
745
- } | {
746
- kind: 'set_accessibility_description';
747
- description: string | null;
748
- };
749
- type ArchitectureMutationOp = {
750
- kind: 'add_service';
751
- id: string;
752
- label?: string;
753
- icon?: string | null;
754
- group?: string | null;
755
- } | {
756
- kind: 'remove_service';
757
- id: string;
758
- } | {
759
- kind: 'rename_service';
760
- from: string;
761
- to: string;
762
- } | {
763
- kind: 'set_service_label';
764
- id: string;
765
- label: string;
766
- } | {
767
- kind: 'set_service_icon';
768
- id: string;
769
- icon: string | null;
770
- } | {
771
- kind: 'move_service';
772
- id: string;
773
- group: string | null;
774
- } | {
775
- kind: 'add_group';
776
- id: string;
777
- label?: string;
778
- icon?: string | null;
779
- parent?: string | null;
780
- } | {
781
- kind: 'remove_group';
782
- id: string;
783
- } | {
784
- kind: 'add_edge';
785
- from: string;
786
- to: string;
787
- fromSide: ArchitectureSide;
788
- toSide: ArchitectureSide;
789
- label?: string | null;
790
- hasArrowStart?: boolean;
791
- hasArrowEnd?: boolean;
792
- } | {
793
- kind: 'remove_edge';
794
- index?: number;
795
- id?: string;
796
- };
797
- type StateMutationOp = {
798
- kind: 'add_state';
799
- id: string;
800
- label?: string | null;
801
- parent?: string | null;
802
- } | {
803
- kind: 'remove_state';
804
- id: string;
805
- } | {
806
- kind: 'rename_state';
807
- from: string;
808
- to: string;
809
- } | {
810
- kind: 'set_state_label';
811
- id: string;
812
- label: string | null;
813
- } | {
814
- kind: 'add_transition';
815
- from: string;
816
- to: string;
817
- label?: string | null;
818
- parent?: string | null;
819
- } | {
820
- kind: 'remove_transition';
821
- index?: number;
822
- from?: string;
823
- to?: string;
824
- parent?: string | null;
825
- } | {
826
- kind: 'set_transition_label';
827
- index?: number;
828
- from?: string;
829
- to?: string;
830
- label: string | null;
831
- parent?: string | null;
832
- } | {
833
- kind: 'make_composite';
834
- id: string;
835
- members: string[];
836
- label?: string | null;
837
- };
838
- type XyChartAxisSpec = {
839
- name?: string | null;
840
- categories?: string[];
841
- range?: {
842
- min: number;
843
- max: number;
844
- };
845
- };
846
- type XyChartMutationOp = {
847
- kind: 'set_title';
848
- title: string | null;
849
- } | {
850
- kind: 'set_x_axis';
851
- axis: XyChartAxisSpec | null;
852
- } | {
853
- kind: 'set_y_axis';
854
- axis: XyChartAxisSpec | null;
855
- } | {
856
- kind: 'add_series';
857
- kind2: 'bar' | 'line';
858
- name?: string | null;
859
- values: number[];
860
- } | {
861
- kind: 'remove_series';
862
- index: number;
863
- } | {
864
- kind: 'set_series_values';
865
- index: number;
866
- values: number[];
867
- } | {
868
- kind: 'set_series_name';
869
- index: number;
870
- name: string | null;
871
- } | {
872
- kind: 'reorder_series';
873
- from: number;
874
- to: number;
875
- };
876
- type PieMutationOp = {
877
- kind: 'set_title';
878
- title: string | null;
879
- } | {
880
- kind: 'set_show_data';
881
- showData: boolean;
882
- } | {
883
- kind: 'add_slice';
884
- label: string;
885
- value: number;
886
- } | {
887
- kind: 'remove_slice';
888
- label: string;
889
- } | {
890
- kind: 'rename_slice';
891
- from: string;
892
- to: string;
893
- } | {
894
- kind: 'set_slice_value';
895
- label: string;
896
- value: number;
897
- } | {
898
- kind: 'reorder_slice';
899
- from: number;
900
- to: number;
901
- };
902
- type QuadrantMutationOp = {
903
- kind: 'set_title';
904
- title: string | null;
905
- } | {
906
- kind: 'set_axis_labels';
907
- axis: 'x' | 'y';
908
- near: string | null;
909
- far?: string | null;
910
- } | {
911
- kind: 'set_quadrant_label';
912
- quadrant: number;
913
- label: string | null;
914
- } | {
915
- kind: 'add_point';
916
- label: string;
917
- x: number;
918
- y: number;
919
- } | {
920
- kind: 'remove_point';
921
- label: string;
922
- } | {
923
- kind: 'move_point';
924
- label: string;
925
- x: number;
926
- y: number;
927
- } | {
928
- kind: 'rename_point';
929
- from: string;
930
- to: string;
931
- };
932
- type GanttMutationOp = {
933
- kind: 'set_title';
934
- title: string | null;
935
- } | {
936
- kind: 'add_section';
937
- label: string;
938
- } | {
939
- kind: 'rename_section';
940
- index: number;
941
- label: string;
942
- } | {
943
- kind: 'remove_section';
944
- index: number;
945
- } | {
946
- kind: 'add_task';
947
- sectionIndex: number;
948
- label: string;
949
- taskId?: string;
950
- tags?: GanttBodyTaskTag[];
951
- start?: string;
952
- end: string;
953
- } | {
954
- kind: 'remove_task';
955
- sectionIndex: number;
956
- taskIndex: number;
957
- } | {
958
- kind: 'rename_task';
959
- sectionIndex: number;
960
- taskIndex: number;
961
- label: string;
962
- } | {
963
- kind: 'set_task_status';
964
- sectionIndex: number;
965
- taskIndex: number;
966
- status: 'active' | 'done' | 'crit' | null;
967
- } | {
968
- kind: 'set_task_dates';
969
- sectionIndex: number;
970
- taskIndex: number;
971
- start?: string | null;
972
- end?: string;
973
- };
974
- type AnyMutationOp = FlowchartMutationOp | StateMutationOp | SequenceMutationOp | TimelineMutationOp | ClassMutationOp | ErMutationOp | JourneyMutationOp | ArchitectureMutationOp | XyChartMutationOp | PieMutationOp | QuadrantMutationOp | GanttMutationOp;
975
- type MutationOp = FlowchartMutationOp;
976
- declare const FINITE_BRAND: unique symbol;
977
- type Finite = number & {
978
- readonly [FINITE_BRAND]: true;
979
- };
980
- declare function toFinite(n: number): Finite;
981
- type WarningSeverity = 'error' | 'warning';
982
- type WarningTier = 'structural' | 'geometric' | 'lint';
983
- type Tier1WarningCode = 'EMPTY_DIAGRAM' | 'EDGE_MISANCHORED' | 'OFF_CANVAS' | 'GROUP_BREACH' | 'UNKNOWN_SHAPE' | 'LABEL_OVERFLOW' | 'UNRESOLVABLE_SCHEDULE' | 'RENDER_FAILED';
984
- type Tier2WarningCode = 'NODE_OVERLAP' | 'ROUTE_SELF_CROSS' | 'ROUTE_HITCH' | 'ROUTE_UNEXPLAINED_BEND' | 'ROUTE_LABEL_ON_SHARED_TRUNK' | 'ROUTE_CONTAINER_MISANCHOR' | 'ROUTE_SHAPE_MISANCHOR' | 'ROUTE_STALE_AFTER_NODE_MOVE';
985
- /**
986
- * Tier 3 (advisory lint). Family-specific quality hints for common agent
987
- * mistakes that still parse and render. Lint warnings never flip verify.ok.
988
- */
989
- type Tier3WarningCode = 'DUPLICATE_EDGE' | 'UNREACHABLE_NODE' | 'DECISION_BRANCH_UNLABELED' | 'COMMENT_DROPPED' | 'UNSUPPORTED_SYNTAX' | 'CONTENT_DROPPED_ON_ROUNDTRIP' | 'INEFFECTIVE_CONFIG';
990
- type WarningCode = Tier1WarningCode | Tier2WarningCode | Tier3WarningCode;
991
- type LayoutWarning = {
992
- code: 'EMPTY_DIAGRAM';
993
- } | {
994
- code: 'EDGE_MISANCHORED';
995
- edge: EdgeId;
996
- from?: NodeId;
997
- to?: NodeId;
998
- } | {
999
- code: 'OFF_CANVAS';
1000
- target: NodeId | EdgeId;
1001
- axis: 'x' | 'y';
1002
- } | {
1003
- code: 'GROUP_BREACH';
1004
- group: GroupId;
1005
- member: NodeId;
1006
- } | {
1007
- code: 'UNKNOWN_SHAPE';
1008
- node: NodeId;
1009
- shape: string;
1010
- } | {
1011
- code: 'LABEL_OVERFLOW';
1012
- target: NodeId | EdgeId;
1013
- charCount: number;
1014
- limit: number;
1015
- }
1016
- /**
1017
- * The diagram parses (and round-trips) but its semantics cannot resolve, so
1018
- * rendering will fail loudly — e.g. a Gantt whose schedule hits a bad
1019
- * calendar date, a dependency cycle, or an everything-excluded calendar.
1020
- * `reason` carries the named renderer error (GANTT_*…). Closes the
1021
- * "verify ok but render throws" seam for structured gantt bodies.
1022
- */
1023
- | {
1024
- code: 'UNRESOLVABLE_SCHEDULE';
1025
- reason: string;
1026
- }
1027
- /**
1028
- * The diagram parses on the agent side (possibly with unmodeled syntax
1029
- * preserved verbatim) but the STRICT render parser throws on its canonical
1030
- * source — `am render` would exit 4. Generalizes UNRESOLVABLE_SCHEDULE's
1031
- * "verify ok but render throws" seam-closing to every family: found live
1032
- * when onboarding agents followed verify-before-commit and still shipped
1033
- * unrenderable quadrant/architecture diagrams. `reason` carries the
1034
- * renderer's error message.
1035
- */
1036
- | {
1037
- code: 'RENDER_FAILED';
1038
- reason: string;
1039
- } | {
1040
- code: 'NODE_OVERLAP';
1041
- a: NodeId;
1042
- b: NodeId;
1043
- areaPx: number;
1044
- } | {
1045
- code: 'ROUTE_SELF_CROSS';
1046
- edge: EdgeId;
1047
- count: number;
1048
- } | {
1049
- code: 'ROUTE_HITCH';
1050
- edge: EdgeId;
1051
- deviationPx: number;
1052
- } | {
1053
- code: 'ROUTE_UNEXPLAINED_BEND';
1054
- edge: EdgeId;
1055
- } | {
1056
- code: 'ROUTE_LABEL_ON_SHARED_TRUNK';
1057
- edge: EdgeId;
1058
- sharedWith: EdgeId;
1059
- } | {
1060
- code: 'ROUTE_CONTAINER_MISANCHOR';
1061
- edge: EdgeId;
1062
- container: GroupId;
1063
- } | {
1064
- code: 'ROUTE_SHAPE_MISANCHOR';
1065
- edge: EdgeId;
1066
- node: NodeId;
1067
- } | {
1068
- code: 'ROUTE_STALE_AFTER_NODE_MOVE';
1069
- edge: EdgeId;
1070
- node: NodeId;
1071
- } | {
1072
- code: 'DUPLICATE_EDGE';
1073
- edge: EdgeId;
1074
- duplicateOf: EdgeId;
1075
- from: NodeId;
1076
- to: NodeId;
1077
- label?: string;
1078
- } | {
1079
- code: 'UNREACHABLE_NODE';
1080
- node: NodeId;
1081
- } | {
1082
- code: 'DECISION_BRANCH_UNLABELED';
1083
- node: NodeId;
1084
- edge: EdgeId;
1085
- } | {
1086
- code: 'COMMENT_DROPPED';
1087
- count: number;
1088
- lines: number[];
1089
- } | {
1090
- code: 'UNSUPPORTED_SYNTAX';
1091
- line?: number;
1092
- syntax: string;
1093
- message: string;
1094
- }
1095
- /**
1096
- * Structured content was lost across a parse → serialize → re-parse cycle:
1097
- * the {nodes, edges, groups} tally changed, so canonical serialization is
1098
- * silently dropping (or duplicating) a node/edge/group even though the bytes
1099
- * may re-parse. The faithfulness analogue of COMMENT_DROPPED — "100% parse
1100
- * success is not faithfulness" (Loop 17). Lint, never flips verify.ok.
1101
- */
1102
- | {
1103
- code: 'CONTENT_DROPPED_ON_ROUNDTRIP';
1104
- before: {
1105
- nodes: number;
1106
- edges: number;
1107
- groups: number;
1108
- };
1109
- after: {
1110
- nodes: number;
1111
- edges: number;
1112
- groups: number;
1113
- };
1114
- }
1115
- /**
1116
- * A Mermaid config field was accepted (for config-shape compatibility) but
1117
- * has no effect on this family's geometry or paint — e.g. Journey's
1118
- * sequence-era fields. Accepting-and-ignoring silently misleads migrating
1119
- * users; this lint says so. Never flips verify.ok.
1120
- */
1121
- | {
1122
- code: 'INEFFECTIVE_CONFIG';
1123
- field: string;
1124
- message: string;
1125
- };
1126
- declare const WARNING_SEVERITY: Record<WarningCode, WarningSeverity>;
1127
- declare const WARNING_TIER: Record<WarningCode, WarningTier>;
1128
- declare const DEFAULT_LABEL_CHAR_CAP = 40;
1129
- interface VerifyOptions {
1130
- suppress?: WarningCode[];
1131
- labelCharCap?: number;
1132
- }
1133
- type RenderedRegionKind = 'node' | 'edge' | 'label' | 'group' | 'canvas';
1134
- interface RenderedRegion {
1135
- id: string;
1136
- kind: RenderedRegionKind;
1137
- elementId?: string;
1138
- parentId?: string;
1139
- bounds: {
1140
- x: Finite;
1141
- y: Finite;
1142
- w: Finite;
1143
- h: Finite;
1144
- };
1145
- sourceLine?: number;
1146
- }
1147
- interface RenderedLayoutNode {
1148
- id: NodeId;
1149
- x: Finite;
1150
- y: Finite;
1151
- w: Finite;
1152
- h: Finite;
1153
- shape: string;
1154
- label?: string;
1155
- }
1156
- interface RenderedLayoutEdge {
1157
- id: EdgeId;
1158
- from: NodeId;
1159
- to: NodeId;
1160
- path: [Finite, Finite][];
1161
- label?: {
1162
- x: Finite;
1163
- y: Finite;
1164
- text: string;
1165
- };
1166
- /** Edge route certificate; present only under layoutMermaid(d, { debug: true }) for families with an edge certificate model. */
1167
- route?: EdgeRouteCertificate;
1168
- }
1169
- interface RenderedLayoutGroup {
1170
- id: GroupId;
1171
- x: Finite;
1172
- y: Finite;
1173
- w: Finite;
1174
- h: Finite;
1175
- members: NodeId[];
1176
- label?: string;
1177
- /** Parent group id for flattened region-tree consumers; undefined means root-level group. */
1178
- parentId?: GroupId;
1179
- }
1180
- interface RenderedLayout {
1181
- version: 1;
1182
- kind: DiagramKind;
1183
- nodes: RenderedLayoutNode[];
1184
- edges: RenderedLayoutEdge[];
1185
- groups: RenderedLayoutGroup[];
1186
- /** Region-containment certificates for non-edge invariants; present only under layoutMermaid(d, { debug: true }). */
1187
- certificates?: RegionContainmentCertificate[];
1188
- /** Optional region sidecar for renderer/action alignment; debug-only in layoutMermaid V1. */
1189
- regions?: RenderedRegion[];
1190
- /** Optional source-only actions aligned to region ids; debug-only in layoutMermaid V1. */
1191
- actions?: DiagramActionRecord[];
1192
- bounds: {
1193
- w: Finite;
1194
- h: Finite;
1195
- };
1196
- }
1197
- interface VerifyResult {
1198
- ok: boolean;
1199
- warnings: LayoutWarning[];
1200
- layout: RenderedLayout;
1201
- }
1202
- interface SerializedFlowchartGraph {
1203
- direction: Direction;
1204
- nodes: Record<string, MermaidNode> | Array<[string, MermaidNode]>;
1205
- edges?: MermaidEdge[];
1206
- subgraphs?: unknown;
1207
- classDefs?: unknown;
1208
- classAssignments?: unknown;
1209
- nodeStyles?: unknown;
1210
- linkStyles?: unknown;
1211
- }
1212
- interface ValidDiagramPayload {
1213
- kind: DiagramKind;
1214
- meta?: Partial<ValidDiagramMeta>;
1215
- body: {
1216
- kind: 'flowchart';
1217
- graph: SerializedFlowchartGraph;
1218
- } | StateBody | SequenceBody | TimelineBody | ClassBody | ErBody | JourneyBody | ArchitectureBody | XyChartBody | PieBody | QuadrantBody | GanttBody | {
1219
- kind: 'opaque';
1220
- family: DiagramKind;
1221
- source: string;
1222
- };
1223
- }
1224
-
1225
- type MermaidFact = string;
1226
- interface CheckMermaidObjectSpec {
1227
- /** Required facts. Aliases: expected / require / required. */
1228
- include?: readonly string[];
1229
- expected?: readonly string[];
1230
- require?: readonly string[];
1231
- required?: readonly string[];
1232
- /** Forbidden facts. Aliases: absent / forbid / forbidden / unexpected. */
1233
- exclude?: readonly string[];
1234
- absent?: readonly string[];
1235
- forbid?: readonly string[];
1236
- forbidden?: readonly string[];
1237
- unexpected?: readonly string[];
1238
- /** When true, every emitted fact must be listed in the required set. */
1239
- exact?: boolean;
1240
- }
1241
- type CheckMermaidSpec = readonly string[] | CheckMermaidObjectSpec;
1242
- interface CheckMermaidResult {
1243
- ok: boolean;
1244
- /** Required facts not present in the diagram. */
1245
- missing: string[];
1246
- /** Forbidden facts that were present, or extra facts under exact:true. */
1247
- unexpected: string[];
1248
- /** Full deterministic fact set used for the comparison. */
1249
- facts: string[];
1250
- }
1251
- /** Facts for a parsed diagram. Output is sorted, de-duplicated, and single-line. */
1252
- declare function describeMermaidFacts(d: ValidDiagram): string[];
1253
- /** Parse then emit facts. Parse failures are explicit Result errors. */
1254
- declare function describeMermaidFactsSource(source: string): Result<string[], ParseError[]>;
1255
- /** Check required/forbidden semantic facts against a parsed diagram. */
1256
- declare function checkMermaid(d: ValidDiagram, spec: CheckMermaidSpec): CheckMermaidResult;
1257
- declare function checkMermaidSource(source: string, spec: CheckMermaidSpec): Result<CheckMermaidResult, ParseError[]>;
1258
-
1259
- interface ExtractedLabel {
1260
- /** The label text, with quotes stripped. */
1261
- text: string;
1262
- /** Best-effort target identifier (node id, participant, period, etc.). */
1263
- target: string;
1264
- }
1265
- interface FamilyLayoutContext {
1266
- source: NormalizedMermaidSource;
1267
- options: RenderOptions;
1268
- /** Render options after public-entrypoint normalization, e.g. security/font/config threading. */
1269
- renderOptions: RenderOptions;
1270
- colors: DiagramColors;
1271
- }
1272
- interface FamilyLayoutResult<TPositioned extends PositionedDiagram = PositionedDiagram> {
1273
- positioned: TPositioned;
1274
- /** Optional family-specific palette override for rendering/finalization. */
1275
- colors?: DiagramColors;
1276
- /** Optional family-specific render options override for RenderContext. */
1277
- options?: RenderOptions;
1278
- /** False when the family renderer already owns SVG accessibility metadata. */
1279
- injectAccessibility?: boolean;
1280
- }
1281
- interface AsciiContext {
1282
- source: NormalizedMermaidSource;
1283
- config: AsciiConfig;
1284
- colorMode: ColorMode;
1285
- theme: AsciiTheme;
1286
- options: {
1287
- maxWidth?: number;
1288
- ganttToday?: string;
1289
- };
1290
- }
1291
- interface FamilyPlugin {
1292
- /** The DiagramKind this plugin owns. */
1293
- id: DiagramKind;
1294
- /** First-non-blank-line predicate. Lowercase, leading whitespace stripped. */
1295
- detect: (firstLineLower: string) => boolean;
1296
- /**
1297
- * Source-based label extractor for universal Tier 1 LABEL_OVERFLOW on opaque
1298
- * bodies. Each plugin should extract everything an agent would consider a
1299
- * label — node text, edge text, message text, axis names, section titles.
1300
- * The generic fallback (extractLabelsGeneric) is used when a family doesn't
1301
- * provide its own.
1302
- */
1303
- extractLabels?: (source: string) => ExtractedLabel[];
1304
- /**
1305
- * Family-specific structured parser. `lines` are the normalized source
1306
- * lines including the header; `opaqueSource` is the original body for
1307
- * lossless fallback; `canonicalSource` is the full normalized text (the
1308
- * legacy flowchart parser consumes it whole). Structured-or-opaque
1309
- * families return ok(structured ?? opaque); error-semantics families
1310
- * (flowchart/state) return err(ParseError[]).
1311
- */
1312
- parse?: (lines: string[], opaqueSource: string, meta: ValidDiagramMeta, canonicalSource: string) => Result<DiagramBody, ParseError[]>;
1313
- /**
1314
- * Optional source-map builder, run after a successful parse. Today only
1315
- * flowchart/state index node positions; other families return no map.
1316
- */
1317
- buildSourceMap?: (body: DiagramBody, canonicalSource: string) => SourceMap;
1318
- /** Optional: family-specific serializer for a structured body. */
1319
- serialize?: (body: DiagramBody) => string;
1320
- /** Optional: family-specific structured mutation. */
1321
- mutate?: (body: DiagramBody, op: AnyMutationOp) => Result<DiagramBody, MutationError>;
1322
- /** Optional: family-specific verify (Tier 1 + Tier 2). Returns warnings only. */
1323
- verify?: (body: DiagramBody, opts: VerifyOptions) => LayoutWarning[];
1324
- /** Optional: family-specific source-to-positioned layout for public SVG rendering. */
1325
- layout?: (ctx: FamilyLayoutContext) => FamilyLayoutResult | PositionedDiagram;
1326
- /** Optional: family-specific SVG renderer fed by a positioned layout result. */
1327
- renderSvg?: (ctx: RenderContext<PositionedDiagram>) => string;
1328
- /**
1329
- * Optional: family-specific SceneGraph lowering (SPEC §3.1). Produces the
1330
- * semantic render-mark tree that style backends consume; renderSvg for a
1331
- * lowered family is DefaultBackend serialization of this scene.
1332
- */
1333
- lowerScene?: (ctx: RenderContext<PositionedDiagram>) => SceneDoc;
1334
- /** Optional: family-specific ASCII renderer. */
1335
- renderAscii?: (ctx: AsciiContext) => string;
1336
- }
1337
- interface BuiltinFamilyMetadata {
1338
- /** Built-in DiagramKind exposed by Agentic Mermaid. */
1339
- id: DiagramKind;
1340
- /** Human-facing family name used in docs and editor examples. */
1341
- label: string;
1342
- /** Mermaid headers routed to this family. */
1343
- headers: readonly string[];
1344
- /** SDK narrower advertised for structured mutation. */
1345
- narrower: `as${string}`;
1346
- /** Editor example category label. */
1347
- editorDiagramType: string;
1348
- /** Basic editor example that must exist for this family. */
1349
- editorExampleId: string;
1350
- /** Short glyph used by the editor example picker. */
1351
- editorGlyph: string;
1352
- /** Minimal canonical source: correct header + core syntax. Exposed via
1353
- * `am capabilities` so agents learn each family's dialect from the
1354
- * discovery envelope instead of error-message trial-and-error (the
1355
- * onboarding probes burned most of their iterations on exactly this —
1356
- * architecture-beta headers, quadrant [x, y] brackets). A test pins
1357
- * every example to parse, verify, and render clean. */
1358
- example: string;
1359
- }
1360
- declare const BUILTIN_FAMILY_METADATA: readonly [{
1361
- readonly id: "flowchart";
1362
- readonly label: "Flowchart";
1363
- readonly headers: readonly ["flowchart", "graph"];
1364
- readonly narrower: "asFlowchart";
1365
- readonly editorDiagramType: "Flowchart";
1366
- readonly editorExampleId: "flowchart-basic";
1367
- readonly editorGlyph: "F";
1368
- readonly example: "flowchart TD\n A[Start] --> B{Ship?}\n B -->|yes| C[Deploy]\n B -->|no| D[Fix]";
1369
- }, {
1370
- readonly id: "state";
1371
- readonly label: "State";
1372
- readonly headers: readonly ["stateDiagram", "stateDiagram-v2"];
1373
- readonly narrower: "asState";
1374
- readonly editorDiagramType: "State";
1375
- readonly editorExampleId: "state-basic";
1376
- readonly editorGlyph: "S";
1377
- readonly example: "stateDiagram-v2\n [*] --> Draft\n Draft --> Review : submit\n Review --> [*] : approve";
1378
- }, {
1379
- readonly id: "sequence";
1380
- readonly label: "Sequence";
1381
- readonly headers: readonly ["sequenceDiagram"];
1382
- readonly narrower: "asSequence";
1383
- readonly editorDiagramType: "Sequence";
1384
- readonly editorExampleId: "sequence-basic";
1385
- readonly editorGlyph: "Q";
1386
- readonly example: "sequenceDiagram\n participant U as User\n participant S as Server\n U->>S: request\n S-->>U: response";
1387
- }, {
1388
- readonly id: "timeline";
1389
- readonly label: "Timeline";
1390
- readonly headers: readonly ["timeline"];
1391
- readonly narrower: "asTimeline";
1392
- readonly editorDiagramType: "Timeline";
1393
- readonly editorExampleId: "timeline-basic";
1394
- readonly editorGlyph: "T";
1395
- readonly example: "timeline\n title Roadmap\n 2025 : Alpha : Beta\n 2026 : GA";
1396
- }, {
1397
- readonly id: "class";
1398
- readonly label: "Class";
1399
- readonly headers: readonly ["classDiagram"];
1400
- readonly narrower: "asClass";
1401
- readonly editorDiagramType: "Class";
1402
- readonly editorExampleId: "class-basic";
1403
- readonly editorGlyph: "C";
1404
- readonly example: "classDiagram\n class Account {\n +id: string\n +close() void\n }\n Account <|-- Savings\n Account \"1\" o-- \"*\" Transaction : logs";
1405
- }, {
1406
- readonly id: "er";
1407
- readonly label: "ER";
1408
- readonly headers: readonly ["erDiagram"];
1409
- readonly narrower: "asEr";
1410
- readonly editorDiagramType: "ER";
1411
- readonly editorExampleId: "er-basic";
1412
- readonly editorGlyph: "ER";
1413
- readonly example: "erDiagram\n CUSTOMER ||--o{ ORDER : places\n ORDER {\n string id\n }";
1414
- }, {
1415
- readonly id: "journey";
1416
- readonly label: "Journey";
1417
- readonly headers: readonly ["journey"];
1418
- readonly narrower: "asJourney";
1419
- readonly editorDiagramType: "Journey";
1420
- readonly editorExampleId: "journey-basic";
1421
- readonly editorGlyph: "J";
1422
- readonly example: "journey\n title Checkout\n section Browse\n Find product: 4: Shopper\n section Buy\n Pay: 3: Shopper";
1423
- }, {
1424
- readonly id: "architecture";
1425
- readonly label: "Architecture";
1426
- readonly headers: readonly ["architecture-beta"];
1427
- readonly narrower: "asArchitecture";
1428
- readonly editorDiagramType: "Architecture";
1429
- readonly editorExampleId: "architecture-basic";
1430
- readonly editorGlyph: "A";
1431
- readonly example: "architecture-beta\n group backend(cloud)[Backend]\n service api(server)[API] in backend\n service db(database)[Database] in backend\n service cache(disk)[Cache] in backend\n api:R --> L:db\n api:B -[reads]-> T:cache";
1432
- }, {
1433
- readonly id: "xychart";
1434
- readonly label: "XY chart";
1435
- readonly headers: readonly ["xychart", "xychart-beta"];
1436
- readonly narrower: "asXyChart";
1437
- readonly editorDiagramType: "XY Chart";
1438
- readonly editorExampleId: "xychart-basic";
1439
- readonly editorGlyph: "XY";
1440
- readonly example: "xychart-beta\n title \"Revenue\"\n x-axis [Q1, Q2, Q3]\n y-axis \"USD\" 0 --> 100\n bar [45, 62, 80]";
1441
- }, {
1442
- readonly id: "pie";
1443
- readonly label: "Pie";
1444
- readonly headers: readonly ["pie"];
1445
- readonly narrower: "asPie";
1446
- readonly editorDiagramType: "Pie";
1447
- readonly editorExampleId: "pie-basic";
1448
- readonly editorGlyph: "P";
1449
- readonly example: "pie title Plans\n \"Free\" : 60\n \"Pro\" : 30\n \"Enterprise\" : 10";
1450
- }, {
1451
- readonly id: "quadrant";
1452
- readonly label: "Quadrant";
1453
- readonly headers: readonly ["quadrantChart"];
1454
- readonly narrower: "asQuadrant";
1455
- readonly editorDiagramType: "Quadrant";
1456
- readonly editorExampleId: "quadrant-basic";
1457
- readonly editorGlyph: "4Q";
1458
- readonly example: "quadrantChart\n title Prioritize\n x-axis Low Effort --> High Effort\n y-axis Low Value --> High Value\n Quick win: [0.2, 0.8]\n Money pit: [0.8, 0.2]";
1459
- }, {
1460
- readonly id: "gantt";
1461
- readonly label: "Gantt";
1462
- readonly headers: readonly ["gantt"];
1463
- readonly narrower: "asGantt";
1464
- readonly editorDiagramType: "Gantt";
1465
- readonly editorExampleId: "gantt-basic";
1466
- readonly editorGlyph: "G";
1467
- readonly example: "gantt\n title Plan\n dateFormat YYYY-MM-DD\n section Build\n Implement :a1, 2026-01-05, 5d\n Review :after a1, 2d";
1468
- }];
1469
- type BuiltinFamilyId = typeof BUILTIN_FAMILY_METADATA[number]['id'];
1470
- type BuiltinFamilyMetadataCoversDiagramKind = [
1471
- Exclude<DiagramKind, BuiltinFamilyId>,
1472
- Exclude<BuiltinFamilyId, DiagramKind>
1473
- ] extends [never, never] ? true : never;
1474
- declare const BUILTIN_FAMILY_METADATA_COVERS_DIAGRAM_KIND: BuiltinFamilyMetadataCoversDiagramKind;
1475
- declare function builtinFamilyMetadata(kind: DiagramKind): BuiltinFamilyMetadata | undefined;
1476
- declare function registerFamily(plugin: FamilyPlugin): void;
1477
- declare function getFamily(kind: DiagramKind): FamilyPlugin | undefined;
1478
- declare function knownFamilies(): DiagramKind[];
1479
-
1480
- declare function parseMermaid(source: string): Result<ValidDiagram, ParseError[]>;
1481
-
1482
- interface SerializeOptions {
1483
- /**
1484
- * Wrapper emission policy. 'verbatim' (default) re-emits the leading source
1485
- * wrapper (frontmatter, init directives, comments) byte-identically from
1486
- * `meta.wrapperSource`. 'canonical' synthesizes Mermaid's documented shape
1487
- * instead: one frontmatter block with `title`/`displayMode` at the top
1488
- * level and everything else nested under `config:`, init directives folded
1489
- * in (re-emitted raw only when their payload could not be folded), and
1490
- * wrapper comments dropped. Diagrams without a captured wrapper (e.g.
1491
- * synthesized from JSON payloads) always use canonical synthesis.
1492
- */
1493
- wrapper?: 'verbatim' | 'canonical';
1494
- }
1495
- declare function serializeMermaid(d: ValidDiagram, opts?: SerializeOptions): string;
1496
- declare function synthesizeFromGraph(payload: ValidDiagramPayload): Result<ValidDiagram, ParseError[]>;
1497
-
1498
- interface CreateMermaidOptions {
1499
- /** Layout direction for flowchart/state diagrams (default TD). Ignored elsewhere. */
1500
- direction?: Direction;
1501
- }
1502
- /** A mutation failure annotated with which op in the build list failed. */
1503
- type BuildError = MutationError & {
1504
- opIndex: number;
1505
- };
1506
- declare function createMermaid(kind: 'flowchart', opts?: CreateMermaidOptions): FlowchartValidDiagram;
1507
- declare function createMermaid(kind: 'state', opts?: CreateMermaidOptions): StateValidDiagram;
1508
- declare function createMermaid(kind: 'sequence', opts?: CreateMermaidOptions): SequenceValidDiagram;
1509
- declare function createMermaid(kind: 'timeline', opts?: CreateMermaidOptions): TimelineValidDiagram;
1510
- declare function createMermaid(kind: 'class', opts?: CreateMermaidOptions): ClassValidDiagram;
1511
- declare function createMermaid(kind: 'er', opts?: CreateMermaidOptions): ErValidDiagram;
1512
- declare function createMermaid(kind: 'journey', opts?: CreateMermaidOptions): JourneyValidDiagram;
1513
- declare function createMermaid(kind: 'architecture', opts?: CreateMermaidOptions): ArchitectureValidDiagram;
1514
- declare function createMermaid(kind: 'xychart', opts?: CreateMermaidOptions): XyChartValidDiagram;
1515
- declare function createMermaid(kind: 'pie', opts?: CreateMermaidOptions): PieValidDiagram;
1516
- declare function createMermaid(kind: 'quadrant', opts?: CreateMermaidOptions): QuadrantValidDiagram;
1517
- declare function createMermaid(kind: 'gantt', opts?: CreateMermaidOptions): GanttValidDiagram;
1518
- declare function createMermaid(kind: DiagramKind, opts?: CreateMermaidOptions): MutableValidDiagram;
1519
- declare function buildMermaid(kind: 'flowchart', ops: FlowchartMutationOp[], opts?: CreateMermaidOptions): Result<FlowchartValidDiagram, BuildError>;
1520
- declare function buildMermaid(kind: 'state', ops: StateMutationOp[], opts?: CreateMermaidOptions): Result<StateValidDiagram, BuildError>;
1521
- declare function buildMermaid(kind: 'sequence', ops: SequenceMutationOp[], opts?: CreateMermaidOptions): Result<SequenceValidDiagram, BuildError>;
1522
- declare function buildMermaid(kind: 'timeline', ops: TimelineMutationOp[], opts?: CreateMermaidOptions): Result<TimelineValidDiagram, BuildError>;
1523
- declare function buildMermaid(kind: 'class', ops: ClassMutationOp[], opts?: CreateMermaidOptions): Result<ClassValidDiagram, BuildError>;
1524
- declare function buildMermaid(kind: 'er', ops: ErMutationOp[], opts?: CreateMermaidOptions): Result<ErValidDiagram, BuildError>;
1525
- declare function buildMermaid(kind: 'journey', ops: JourneyMutationOp[], opts?: CreateMermaidOptions): Result<JourneyValidDiagram, BuildError>;
1526
- declare function buildMermaid(kind: 'architecture', ops: ArchitectureMutationOp[], opts?: CreateMermaidOptions): Result<ArchitectureValidDiagram, BuildError>;
1527
- declare function buildMermaid(kind: 'xychart', ops: XyChartMutationOp[], opts?: CreateMermaidOptions): Result<XyChartValidDiagram, BuildError>;
1528
- declare function buildMermaid(kind: 'pie', ops: PieMutationOp[], opts?: CreateMermaidOptions): Result<PieValidDiagram, BuildError>;
1529
- declare function buildMermaid(kind: 'quadrant', ops: QuadrantMutationOp[], opts?: CreateMermaidOptions): Result<QuadrantValidDiagram, BuildError>;
1530
- declare function buildMermaid(kind: 'gantt', ops: GanttMutationOp[], opts?: CreateMermaidOptions): Result<GanttValidDiagram, BuildError>;
1531
- declare function buildMermaid(kind: DiagramKind, ops: AnyMutationOp[], opts?: CreateMermaidOptions): Result<MutableValidDiagram, BuildError>;
1532
-
1533
- declare function edgeIdOf(edge: MermaidEdge, idx?: number): string;
1534
-
1535
- declare function mutate(d: FlowchartValidDiagram, op: FlowchartMutationOp): Result<FlowchartValidDiagram, MutationError>;
1536
- declare function mutate(d: StateValidDiagram, op: StateMutationOp): Result<StateValidDiagram, MutationError>;
1537
- declare function mutate(d: SequenceValidDiagram, op: SequenceMutationOp): Result<SequenceValidDiagram, MutationError>;
1538
- declare function mutate(d: TimelineValidDiagram, op: TimelineMutationOp): Result<TimelineValidDiagram, MutationError>;
1539
- declare function mutate(d: ClassValidDiagram, op: ClassMutationOp): Result<ClassValidDiagram, MutationError>;
1540
- declare function mutate(d: ErValidDiagram, op: ErMutationOp): Result<ErValidDiagram, MutationError>;
1541
- declare function mutate(d: JourneyValidDiagram, op: JourneyMutationOp): Result<JourneyValidDiagram, MutationError>;
1542
- declare function mutate(d: ArchitectureValidDiagram, op: ArchitectureMutationOp): Result<ArchitectureValidDiagram, MutationError>;
1543
- declare function mutate(d: XyChartValidDiagram, op: XyChartMutationOp): Result<XyChartValidDiagram, MutationError>;
1544
- declare function mutate(d: PieValidDiagram, op: PieMutationOp): Result<PieValidDiagram, MutationError>;
1545
- declare function mutate(d: QuadrantValidDiagram, op: QuadrantMutationOp): Result<QuadrantValidDiagram, MutationError>;
1546
- declare function mutate(d: GanttValidDiagram, op: GanttMutationOp): Result<GanttValidDiagram, MutationError>;
1547
- declare function mutate(d: MutableValidDiagram, op: AnyMutationOp): Result<MutableValidDiagram, MutationError>;
1548
- /**
1549
- * mutate with a shape check in front — the one choke point every UNTYPED edit
1550
- * path funnels through: the declarative applyOps/buildChecked entrypoints, the
1551
- * Code Mode facade, and the CLI `--op`/`--ops` path. Typed callers keep using
1552
- * `mutate` directly, where the compiler already guarantees op shape;
1553
- * `mutateChecked` restores that guarantee at the boundaries where ops arrive as
1554
- * raw JSON.
1555
- *
1556
- * `validateOp` proves the op's SHAPE (field names, primitive types, enums)
1557
- * BEFORE the mutator runs, so a malformed op is rejected with a prescriptive
1558
- * INVALID_OP error instead of silently mangling the diagram. Semantics — does
1559
- * the referenced node exist, is the id a duplicate — stay in the mutator, which
1560
- * runs second on a shape-proven op. Result shape is identical to `mutate`, so
1561
- * this is a drop-in wherever the raw mutator was called with untyped ops.
1562
- */
1563
- declare function mutateChecked(d: MutableValidDiagram, op: unknown): Result<MutableValidDiagram, MutationError>;
1564
-
1565
- declare const MUTATION_OPS_BY_FAMILY: {
1566
- readonly flowchart: readonly ["add_node", "remove_node", "rename_node", "set_label", "add_edge", "remove_edge"];
1567
- readonly state: readonly ["add_state", "remove_state", "rename_state", "set_state_label", "add_transition", "remove_transition", "set_transition_label", "make_composite"];
1568
- readonly sequence: readonly ["add_participant", "remove_participant", "add_message", "remove_message", "set_message_text"];
1569
- readonly timeline: readonly ["set_title", "add_section", "remove_section", "set_section_label", "add_period", "remove_period", "set_period_label", "add_event", "remove_event", "set_event_text"];
1570
- readonly class: readonly ["set_title", "add_class", "remove_class", "rename_class", "add_member", "remove_member", "add_relation", "remove_relation", "add_note", "remove_note"];
1571
- readonly er: readonly ["add_entity", "remove_entity", "rename_entity", "add_attribute", "remove_attribute", "add_relation", "remove_relation"];
1572
- readonly journey: readonly ["set_title", "add_section", "remove_section", "set_section_label", "add_task", "remove_task", "set_task_text", "set_task_score", "set_task_actors", "rename_actor", "move_task", "move_section", "set_accessibility_title", "set_accessibility_description"];
1573
- readonly architecture: readonly ["add_service", "remove_service", "rename_service", "set_service_label", "set_service_icon", "move_service", "add_group", "remove_group", "add_edge", "remove_edge"];
1574
- readonly xychart: readonly ["set_title", "set_x_axis", "set_y_axis", "add_series", "remove_series", "set_series_values", "set_series_name", "reorder_series"];
1575
- readonly pie: readonly ["set_title", "set_show_data", "add_slice", "remove_slice", "rename_slice", "set_slice_value", "reorder_slice"];
1576
- readonly quadrant: readonly ["set_title", "set_axis_labels", "set_quadrant_label", "add_point", "remove_point", "move_point", "rename_point"];
1577
- readonly gantt: readonly ["set_title", "add_section", "rename_section", "remove_section", "add_task", "remove_task", "rename_task", "set_task_status", "set_task_dates"];
1578
- };
1579
- type MutableFamilyId = keyof typeof MUTATION_OPS_BY_FAMILY;
1580
-
1581
- type OpFamily = MutableFamilyId;
1582
- /** True when `family` has a shape schema (i.e. is a mutable structured family). */
1583
- declare function hasOpSchema(family: string): family is OpFamily;
1584
- /**
1585
- * Structured, model-actionable validation error. `code` is always INVALID_OP
1586
- * (so it flows through the existing MutationError channel unchanged), but the
1587
- * payload names the exact problem and enumerates the legal fields so a weak
1588
- * model can self-correct in one turn.
1589
- */
1590
- interface OpValidationError {
1591
- code: 'INVALID_OP';
1592
- /** 'expected_single_op' | 'unknown_kind' | 'unknown_field' | 'missing_field' | 'wrong_type' | 'require_one_of' */
1593
- reason: string;
1594
- message: string;
1595
- family: OpFamily;
1596
- opKind?: string;
1597
- /** the offending field, when applicable */
1598
- field?: string;
1599
- /** valid field names for this op (or valid op kinds, for unknown_kind) */
1600
- validFields?: string[];
1601
- /** nearest valid name to a typo'd field/kind, when an obvious match exists */
1602
- didYouMean?: string;
1603
- }
1604
- /**
1605
- * Validate one op's SHAPE against its family schema. Returns null when valid.
1606
- * The one and only shape choke point: every untyped edit path (declarative
1607
- * applyOps / buildChecked and the Code Mode facade) calls this — through
1608
- * mutateChecked — before touching a mutator.
1609
- */
1610
- declare function validateOp(family: OpFamily, op: unknown): OpValidationError | null;
1611
- /** Machine-readable op menu for a family — { opKind: [fieldName, …] } — the
1612
- * basis for tool-discovery output. Optional fields are marked with a trailing
1613
- * `?`; the op's `kind` is implicit and omitted. */
1614
- declare function opMenu(family: OpFamily): Record<string, string[]>;
1615
- /** One field of an op, as a model needs it to fill the op correctly: the name,
1616
- * whether it is required, and a human type that spells out enum values inline
1617
- * (e.g. `one of "inheritance", "composition", …`). */
1618
- interface OpFieldDoc {
1619
- name: string;
1620
- required: boolean;
1621
- type: string;
1622
- note?: string;
1623
- }
1624
- /** Full field shapes for every op of a family — the thing a model must know to
1625
- * author a correct op without guessing (which the prescriptive INVALID_OP error
1626
- * only teaches AFTER a wrong guess). Surfaced in `am capabilities --json` and
1627
- * the declarative MCP tool descriptions so field names, required-ness, and enum
1628
- * vocabularies are discoverable up front. */
1629
- declare function describeOps(family: OpFamily): Record<string, OpFieldDoc[]>;
1630
- /** Compact one-line signatures for a family's ops — `add_relation(from, to,
1631
- * relKind, label?)` — for embedding in a tool description. Optional fields carry
1632
- * a trailing `?`; enum values are left to `describeOps`/the error to keep the
1633
- * menu short. */
1634
- declare function opSignatures(family: OpFamily): string[];
1635
-
1636
- /** A verify summary reduced to plain JSON (no RenderedLayout proxy graph). */
1637
- interface VerifySummary {
1638
- ok: boolean;
1639
- warnings: VerifyResult['warnings'];
1640
- }
1641
- /** A mutation failure annotated with which op in the list failed. */
1642
- type CheckedBuildError = MutationError & {
1643
- opIndex: number;
1644
- };
1645
- /**
1646
- * THE single output DTO for the declarative surface. Success and failure share
1647
- * one shape: `ok` discriminates. Every field is plain JSON — safe to return
1648
- * straight out as an MCP tool result and safe to JSON round-trip: no
1649
- * `{ok,value}`-vs-plain split, no provenance proxy, no Map.
1650
- */
1651
- type OpEnvelope = {
1652
- ok: true;
1653
- family: DiagramKind;
1654
- /** canonical Mermaid source of the mutated diagram */
1655
- source: string;
1656
- verify: VerifySummary;
1657
- } | {
1658
- ok: false;
1659
- family: OpFamily | DiagramKind | null;
1660
- /** index of the failing op within the batch, when the failure is op-scoped */
1661
- opIndex?: number;
1662
- error: OpValidationError | {
1663
- code: string;
1664
- message: string;
1665
- };
1666
- };
1667
- /** Drop the layout proxy graph; keep the model-actionable verdict. The JSON
1668
- * round-trip guarantees no residual Map / prototype leaks through. */
1669
- declare function verifySummary(v: VerifyResult): VerifySummary;
1670
- /**
1671
- * buildMermaid's contract (createMermaid → fold ops) with the shape check in
1672
- * front of every op. Same Result shape as buildMermaid, so it is a drop-in for
1673
- * the untyped build path (Code Mode facade `buildMermaid`, declarative `build`).
1674
- */
1675
- declare function buildChecked(kind: DiagramKind, ops: unknown[], opts?: CreateMermaidOptions): Result<MutableValidDiagram, CheckedBuildError>;
1676
- interface ApplyOpsInput {
1677
- /** Existing Mermaid `source` to edit, OR `family` to author from blank. */
1678
- source?: string;
1679
- family?: string;
1680
- ops: unknown;
1681
- }
1682
- /**
1683
- * Plain-JSON-in / plain-JSON-out batch edit. Fail-fast, all-or-nothing: ops
1684
- * apply in order over a working copy; the first invalid or semantically-rejected
1685
- * op stops the batch and reports its index — nothing is committed (the input
1686
- * `source` is untouched, mirroring buildMermaid). Returns the canonical envelope.
1687
- */
1688
- declare function applyOps(input: ApplyOpsInput): OpEnvelope;
1689
-
1690
- declare function verifyMermaid(input: ValidDiagram | string, opts?: VerifyOptions): VerifyResult;
1691
-
1692
- interface QualityMetrics {
1693
- edgeCrossings: number;
1694
- labelLegibility: number;
1695
- whitespaceBalance: number;
1696
- labelEdgeProximity: number;
1697
- aspectRatio: number;
1698
- nodeCount: number;
1699
- edgeCount: number;
1700
- }
1701
- interface QualityBounds {
1702
- /** Max edge crossings per (edge × edge) pair. Default 0.05 = 5%. */
1703
- maxCrossingsRatio?: number;
1704
- /** Min label legibility. Default 0.85 = 85% of labels fit. */
1705
- minLabelLegibility?: number;
1706
- /** Whitespace fill band [min, max]. Default [0.05, 0.55]. */
1707
- whitespaceBand?: [number, number];
1708
- /** Min pixels between any edge-label bbox and a non-attached node, another edge-label, or another edge path. Default 4. */
1709
- minLabelEdgeProximity?: number;
1710
- /** Aspect ratio band [min, max]. Default [0.2, 5.0]. */
1711
- aspectBand?: [number, number];
1712
- }
1713
- declare const DEFAULT_BOUNDS: Required<QualityBounds>;
1714
- type BoundBasis = 'evidence' | 'derived' | 'chosen' | 'sanity';
1715
- type ViolationSeverity = 'primary' | 'secondary' | 'sanity';
1716
- interface BoundProvenance {
1717
- basis: BoundBasis;
1718
- severity: ViolationSeverity;
1719
- note: string;
1720
- }
1721
- /** Per-metric provenance. Keyed by the QualityMetrics field each bound gates. */
1722
- declare const BOUND_PROVENANCE: Record<'edgeCrossings' | 'labelLegibility' | 'whitespaceBalance' | 'labelEdgeProximity' | 'aspectRatio', BoundProvenance>;
1723
- declare function measureQuality(layout: RenderedLayout): QualityMetrics;
1724
- interface RankedViolation {
1725
- metric: keyof typeof BOUND_PROVENANCE;
1726
- severity: ViolationSeverity;
1727
- message: string;
1728
- }
1729
- interface QualityVerdict {
1730
- ok: boolean;
1731
- metrics: QualityMetrics;
1732
- /** Human-readable violation strings. Backward-compatible. */
1733
- violations: string[];
1734
- /**
1735
- * The same violations, each tagged with its evidence-based severity so a
1736
- * consumer can weight a crossings violation above a whitespace one
1737
- * (Purchase 1997/2002). Ordered primary → secondary → sanity.
1738
- */
1739
- ranked: RankedViolation[];
1740
- }
1741
- declare function checkQuality(layout: RenderedLayout, bounds?: QualityBounds): QualityVerdict;
1742
-
1743
- type LayoutCertificateProof = 'edge-route' | 'region-containment';
1744
- declare function layoutCertificateProof(cert: LayoutRouteCertificate): LayoutCertificateProof;
1745
-
1746
- type RegionKind = 'node' | 'edge' | 'label' | 'subgraph';
1747
- type AsciiWarningCode = 'ASCII_RENDER_FAILED' | 'ASCII_EDGE_REGION_UNMAPPED';
1748
- interface AsciiWarning {
1749
- code: AsciiWarningCode;
1750
- message: string;
1751
- severity: 'degraded';
1752
- }
1753
- declare const ASCII_ROUTE_PARITY_CONTRACT: {
1754
- readonly version: 1;
1755
- readonly routeIntent: "shared-route-classes";
1756
- readonly svgSource: "route-contract classifyRoutes() + certificates";
1757
- readonly asciiSource: "grid router seeded with classifyRoutes() routeClass metadata, longest-path layering, and direct-lane-first routing";
1758
- readonly degradationWarnings: readonly ["ASCII_RENDER_FAILED", "ASCII_EDGE_REGION_UNMAPPED"];
1759
- };
1760
- interface AsciiRegion {
1761
- kind: RegionKind;
1762
- /** Stable identifier for the diagram element (e.g. node id, participant id). */
1763
- id: string;
1764
- /** Optional 1-based source line where the element was declared, when known. */
1765
- sourceLine?: number;
1766
- /** 0-based row in the rendered canvas where the region starts. */
1767
- canvasRow: number;
1768
- /** 0-based column where the region starts (inclusive). */
1769
- canvasColStart: number;
1770
- /** 0-based column where the region ends (exclusive). */
1771
- canvasColEnd: number;
1772
- /** Optional row count when the region spans multiple lines (boxed node). */
1773
- rowSpan?: number;
1774
- }
1775
- interface AsciiWithMeta {
1776
- ascii: string;
1777
- regions: AsciiRegion[];
1778
- warnings: AsciiWarning[];
1779
- routeParity: typeof ASCII_ROUTE_PARITY_CONTRACT;
1780
- }
1781
- declare function renderMermaidASCIIWithMeta(input: string, opts?: AsciiRenderOptions): AsciiWithMeta;
1782
-
1783
- interface DescribeOptions {
1784
- /** 'text' (default): prose summary. 'json': structured AX tree (#7349). 'facts': deterministic semantic facts. */
1785
- format?: 'text' | 'json' | 'facts';
1786
- }
1787
- /** Structured accessibility tree (#7349): the graph as a list of nodes + edges. */
1788
- interface DescribeTree {
1789
- kind: string;
1790
- nodes: Array<{
1791
- id: string;
1792
- label: string;
1793
- }>;
1794
- edges: Array<{
1795
- from: string;
1796
- to: string;
1797
- label?: string;
1798
- }>;
1799
- entryPoints: string[];
1800
- sinks: string[];
1801
- }
1802
- declare function describeMermaidSource(source: string, opts?: DescribeOptions): string;
1803
- declare function describeMermaid(d: ValidDiagram, opts?: DescribeOptions): string;
1804
- /**
1805
- * #7349: machine-readable accessibility tree — the graph as a flat node/edge
1806
- * list with entry points and sinks. More useful to agents and screen-reader
1807
- * tooling than prose. Covers the structured families; source-level/opaque
1808
- * families expose extracted labels as nodes and no edges.
1809
- */
1810
- declare function describeMermaidTree(d: ValidDiagram): DescribeTree;
1811
-
1812
- declare function analyzeMermaid(d: ValidDiagram): DiagramAnalysis;
1813
- declare function analyzeMermaidSource(source: string): Result<DiagramAnalysis, ParseError[]>;
1814
- declare function collectActionRecords(d: ValidDiagram): DiagramActionRecord[];
1815
-
1816
- /**
1817
- * Reverse an ASCII flowchart render back to (best-effort) Mermaid source.
1818
- * Returns synthesized ids (N0, N1, …) with recovered labels and edges.
1819
- */
1820
- declare function asciiToMermaid(ascii: string, opts?: {
1821
- direction?: 'TD' | 'LR';
1822
- }): Result<string, ParseError[]>;
1823
-
1824
- declare function renderMermaidSVG(input: ValidDiagram | string, opts?: Parameters<typeof renderMermaidSVG$1>[1]): string;
1825
- declare function renderMermaidASCII(input: ValidDiagram | string, opts?: Parameters<typeof renderMermaidASCII$1>[1]): string;
1826
- interface LayoutMermaidOptions {
1827
- debug?: boolean;
1828
- regions?: boolean;
1829
- actions?: boolean;
1830
- }
1831
- declare function layoutMermaid(d: ValidDiagram, opts?: LayoutMermaidOptions): RenderedLayout;
1832
-
1833
- /**
1834
- * Loud-tofu guard: emitted when rendered text contains characters no loaded
1835
- * font covers (they would silently rasterize as empty boxes). Delivered to
1836
- * `PngOptions.onWarning` when provided, otherwise written to stderr — never
1837
- * silent either way.
1838
- */
1839
6
  interface PngFontWarning {
1840
7
  code: 'PNG_FONT_COVERAGE';
1841
- /** Coarse script bucket of the uncovered characters ('CJK', 'emoji', …). */
1842
8
  script: string;
1843
- /** The uncovered characters, unique, ascending codepoint order. */
1844
9
  chars: string[];
1845
- /** Human-readable summary naming the script and the escape hatches. */
1846
10
  message: string;
1847
11
  }
1848
- interface PngOptions {
1849
- /** Output scale multiplier (default 2 — retina). */
1850
- scale?: number;
1851
- /** Background color, any CSS color string (default 'white'). */
1852
- background?: string;
1853
- /** Constrain output dimensions; otherwise honors scale on the SVG bounds. */
1854
- fitTo?: {
1855
- width?: number;
1856
- height?: number;
1857
- };
1858
- /** Style name | spec | stack, same as RenderOptions.style. Faces referenced
1859
- * by the built-in looks are bundled in assets/fonts/; other families fall
1860
- * back to DejaVu Sans unless supplied via fontDirs. */
1861
- style?: StyleInput | StyleInput[];
1862
- /** Ink-wobble seed for styled looks, same as RenderOptions.seed. */
1863
- seed?: number;
1864
- /** Extra font directories searched in addition to the bundled ones —
1865
- * the escape hatch for custom styles that reference unbundled families
1866
- * and for scripts the bundled fonts don't cover (CJK, emoji). */
1867
- fontDirs?: string[];
1868
- /** Also load the OS's installed fonts (default false). Opting in trades
1869
- * cross-machine determinism for coverage — useful when the diagram needs
1870
- * CJK/emoji glyphs and a system font provides them. Coverage warnings are
1871
- * skipped in this mode: the system font set is unknown to the checker. */
1872
- loadSystemFonts?: boolean;
12
+
13
+ interface PngOptions extends RenderOptions, PngOutputPolicyInput {
1873
14
  /** Receives glyph-coverage warnings instead of the default stderr write.
1874
15
  * Warnings never change the PNG bytes; identical inputs render
1875
16
  * identically whether or not a handler is installed. */
1876
17
  onWarning?: (warning: PngFontWarning) => void;
1877
18
  }
1878
19
  /**
1879
- * Render a Mermaid diagram (source string or ValidDiagram) to a PNG byte array.
20
+ * Render a Mermaid diagram (source string or ParsedDiagram) to a PNG byte array.
1880
21
  * Deterministic within one runtime; cross-runtime parity is guarded for
1881
22
  * same-machine Bun ≡ Node on x86_64/ARM64 when Node + built dist are present.
1882
23
  *
@@ -1884,6 +25,70 @@ interface PngOptions {
1884
25
  * the CLI/MCP integration straightforward. Library consumers can wrap in
1885
26
  * `Promise.resolve()` if they want async semantics.
1886
27
  */
1887
- declare function renderMermaidPNG(input: ValidDiagram | string, opts?: PngOptions): Uint8Array;
28
+ declare function renderMermaidPNG(input: ParsedDiagram | string, opts?: PngOptions): Uint8Array;
29
+ interface RenderedPng {
30
+ png: Uint8Array;
31
+ receipt: RenderRequestReceipt;
32
+ /** Artifact/runtime provenance; deliberately excluded from request digests. */
33
+ runtime: PngRuntimeProvenance;
34
+ }
35
+ declare function renderMermaidPNGWithReceipt(input: ParsedDiagram | string, opts?: PngOptions): RenderedPng;
36
+ /** Trusted Node/Bun host policy; never copied into RenderOptions or receipts. */
37
+ interface MermaidPNGRendererHostOptions {
38
+ readonly backendPolicy?: HostBackendPolicy;
39
+ }
40
+ interface MermaidPNGRenderer {
41
+ renderMermaidPNG(input: ParsedDiagram | string, opts?: PngOptions): Uint8Array;
42
+ renderMermaidPNGWithReceipt(input: ParsedDiagram | string, opts?: PngOptions): RenderedPng;
43
+ }
44
+ /** Bind the native PNG adapter to a trusted in-process graphical backend. */
45
+ declare function createMermaidPNGRenderer(hostOptions?: MermaidPNGRendererHostOptions): MermaidPNGRenderer;
46
+
47
+ type RendererActionFormat = 'svg' | 'png' | 'ascii' | 'unicode';
48
+ type RendererActionDisposition = 'embedded-inert' | 'sidecar-only';
49
+ interface RendererAction extends DiagramActionRecord {
50
+ surface: RendererActionFormat;
51
+ disposition: RendererActionDisposition;
52
+ /** Surface-coordinate hit region, absent when the target was not rendered. */
53
+ region?: RenderedRegion;
54
+ }
55
+ interface RendererActionSurface {
56
+ version: 1;
57
+ format: RendererActionFormat;
58
+ coordinateSpace: 'pixel' | 'cell';
59
+ /** Only regions referenced by at least one action. */
60
+ regions: RenderedRegion[];
61
+ /** Callbacks remain metadata-only and `executable` is always false. */
62
+ actions: RendererAction[];
63
+ }
64
+ type RenderMermaidActionRequest = {
65
+ format: 'svg';
66
+ options?: RenderOptions;
67
+ } | {
68
+ format: 'png';
69
+ options?: PngOptions;
70
+ } | {
71
+ format: 'ascii' | 'unicode';
72
+ options?: AsciiRenderOptions;
73
+ };
74
+ type RenderedActionArtifact = {
75
+ format: 'svg';
76
+ output: string;
77
+ actionSurface: RendererActionSurface;
78
+ } | {
79
+ format: 'png';
80
+ output: Uint8Array;
81
+ actionSurface: RendererActionSurface;
82
+ } | {
83
+ format: 'ascii' | 'unicode';
84
+ output: string;
85
+ actionSurface: RendererActionSurface;
86
+ warnings: AsciiWarning[];
87
+ };
88
+ /**
89
+ * Render SVG, PNG, ASCII, or Unicode and return one renderer-neutral inert
90
+ * action/hit-region sidecar. The ordinary byte/string render APIs are unchanged.
91
+ */
92
+ declare function renderMermaidWithActions(input: ParsedDiagram | string, request: RenderMermaidActionRequest): RenderedActionArtifact;
1888
93
 
1889
- export { ASCII_ROUTE_PARITY_CONTRACT, type Accessibility, type AnyMutationOp, type ApplyOpsInput, type ArchitectureBody, type ArchitectureEdge, type ArchitectureEndpoint, type ArchitectureGroup, type ArchitectureJunction, type ArchitectureMutationOp, type ArchitectureService, type ArchitectureSide, type ArchitectureValidDiagram, type AsciiRegion, type AsciiWarning, type AsciiWarningCode, type AsciiWithMeta, BOUND_PROVENANCE, BUILTIN_FAMILY_METADATA, BUILTIN_FAMILY_METADATA_COVERS_DIAGRAM_KIND, type BoundBasis, type BoundProvenance, type BuildError, type BuiltinFamilyId, type BuiltinFamilyMetadata, type CheckMermaidObjectSpec, type CheckMermaidResult, type CheckMermaidSpec, type CheckedBuildError, type ClassBody, type ClassMutationOp, type ClassNode, type ClassNote, type ClassRelation, type ClassRelationKind, type ClassValidDiagram, type CreateMermaidOptions, DEFAULT_BOUNDS, DEFAULT_LABEL_CHAR_CAP, type DescribeOptions, type DescribeTree, type DiagramActionKind, type DiagramActionRecord, type DiagramActionSecurity, type DiagramAnalysis, type DiagramBody, type DiagramKind, type EdgeId, EdgeRouteCertificate, type ErAttribute, type ErBody, type ErCardinality, type ErEntity, type ErMutationOp, type ErRelation, type ErValidDiagram, type ExtractedLabel, type FamilyPlugin, type FeedbackEdgeAnalysis, type Finite, type FlowchartMutationOp, type FlowchartValidDiagram, type GanttBody, type GanttBodySection, type GanttBodyTask, type GanttBodyTaskTag, type GanttMutationOp, type GanttScheduleAnalysisSummary, type GanttStatement, type GanttValidDiagram, type GroupId, type InitDirective, type JourneyBody, type JourneyMutationOp, type JourneySection, type JourneyTask, type JourneyValidDiagram, type LayoutCertificateProof, type LayoutMermaidOptions, LayoutRouteCertificate, type LayoutWarning, type MermaidFact, type MutableValidDiagram, type MutationError, type MutationOp, type NodeId, type OpEnvelope, type OpFamily, type OpFieldDoc, type OpValidationError, type ParseError, type ParticipantId, type PieBody, type PieMutationOp, type PieSlice, type PieValidDiagram, type PngOptions, type QuadrantAxis, type QuadrantBody, type QuadrantMutationOp, type QuadrantPoint, type QuadrantValidDiagram, type QualityBounds, type QualityMetrics, type QualityVerdict, type RankedViolation, RegionContainmentCertificate, type RegionKind, type RenderedLayout, type RenderedLayoutEdge, type RenderedLayoutGroup, type RenderedLayoutNode, type RenderedRegion, type RenderedRegionKind, type Result, RouteClass, type SequenceBody, type SequenceMessage, type SequenceMessageStyle, type SequenceMutationOp, type SequenceParticipant, type SequenceValidDiagram, type SerializedFlowchartGraph, type SourceComment, type SourceMap, type StateBody, type StateMutationOp, type StateNode, type StateTransition, type StateValidDiagram, StyleInput, type Tier1WarningCode, type Tier2WarningCode, type TimelineBody, type TimelineEvent, type TimelineMutationOp, type TimelinePeriod, type TimelineSection, type TimelineValidDiagram, type ValidDiagram, type ValidDiagramMeta, type ValidDiagramPayload, type VerifyOptions, type VerifyResult, type VerifySummary, type ViolationSeverity, WARNING_SEVERITY, WARNING_TIER, type WarningCode, type WarningSeverity, type WarningTier, type XyChartAxis, type XyChartAxisSpec, type XyChartBody, type XyChartMutationOp, type XyChartSeries, type XyChartValidDiagram, analyzeMermaid, analyzeMermaidSource, applyOps, asArchitecture, asClass, asEr, asFlowchart, asGantt, asJourney, asPie, asQuadrant, asSequence, asState, asTimeline, asXyChart, asciiToMermaid, buildChecked, buildMermaid, builtinFamilyMetadata, checkMermaid, checkMermaidSource, checkQuality, collectActionRecords, createMermaid, describeMermaid, describeMermaidFacts, describeMermaidFactsSource, describeMermaidSource, describeMermaidTree, describeOps, edgeIdOf, err, getFamily, hasOpSchema, knownFamilies, layoutCertificateProof, layoutMermaid, measureQuality, mutate, mutateChecked, ok, opMenu, opSignatures, parseMermaid, registerFamily, renderMermaidASCII, renderMermaidASCIIWithMeta, renderMermaidPNG, renderMermaidSVG, serializeMermaid, synthesizeFromGraph, toFinite, validateOp, verifyMermaid, verifySummary };
94
+ export { AsciiRenderOptions, AsciiWarning, DiagramActionRecord, HostBackendPolicy, type MermaidPNGRenderer, type MermaidPNGRendererHostOptions, ParsedDiagram, type PngOptions, PngOutputPolicyInput, PngRuntimeProvenance, type RenderMermaidActionRequest, RenderRequestReceipt, type RenderedActionArtifact, type RenderedPng, RenderedRegion, type RendererAction, type RendererActionDisposition, type RendererActionFormat, type RendererActionSurface, createMermaidPNGRenderer, renderMermaidPNG, renderMermaidPNGWithReceipt, renderMermaidWithActions };