semiotic 3.7.3 → 3.7.5

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 (138) hide show
  1. package/CLAUDE.md +13 -7
  2. package/README.md +36 -20
  3. package/ai/schema.json +221 -1
  4. package/ai/system-prompt.md +2 -1
  5. package/dist/components/Annotation.d.ts +4 -0
  6. package/dist/components/DataSummaryContext.d.ts +1 -0
  7. package/dist/components/LinkedCharts.d.ts +2 -2
  8. package/dist/components/ai/chartCapabilityTypes.d.ts +16 -0
  9. package/dist/components/ai/dataPitfallsBridge.d.ts +101 -0
  10. package/dist/components/ai/dataQualityBridge.d.ts +201 -0
  11. package/dist/components/ai/describeChart.d.ts +2 -0
  12. package/dist/components/ai/generativeChart.d.ts +145 -0
  13. package/dist/components/charts/custom/NetworkCustomChart.d.ts +15 -2
  14. package/dist/components/charts/ordinal/SwarmPlot.d.ts +7 -0
  15. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +21 -0
  16. package/dist/components/charts/realtime/aggregate.d.ts +51 -0
  17. package/dist/components/charts/realtime/eventTime.d.ts +26 -0
  18. package/dist/components/charts/shared/colorPalettes.d.ts +2 -0
  19. package/dist/components/charts/shared/colorUtils.d.ts +1 -12
  20. package/dist/components/charts/shared/minMax.d.ts +3 -0
  21. package/dist/components/charts/shared/radialGeometry.d.ts +0 -18
  22. package/dist/components/charts/shared/smartTooltip.d.ts +27 -0
  23. package/dist/components/charts/shared/statisticalOverlays.d.ts +35 -0
  24. package/dist/components/charts/shared/tooltipUtils.d.ts +2 -0
  25. package/dist/components/charts/shared/useChartSetup.d.ts +1 -1
  26. package/dist/components/charts/shared/useCustomChartSetup.d.ts +1 -1
  27. package/dist/components/charts/shared/validateChartData.d.ts +1 -1
  28. package/dist/components/charts/xy/Scatterplot.d.ts +9 -0
  29. package/dist/components/data/fromArrow.d.ts +54 -0
  30. package/dist/components/data/fromMermaid.d.ts +47 -0
  31. package/dist/components/data/fromObservablePlot.d.ts +69 -0
  32. package/dist/components/data/portability/index.d.ts +14 -0
  33. package/dist/components/data/portability/spec.d.ts +129 -0
  34. package/dist/components/data/portability/vegaLite.d.ts +62 -0
  35. package/dist/components/realtime/ReorderBuffer.d.ts +54 -0
  36. package/dist/components/realtime/RunningStats.d.ts +66 -0
  37. package/dist/components/realtime/WindowAccumulator.d.ts +105 -0
  38. package/dist/components/realtime/parseWindowDuration.d.ts +12 -0
  39. package/dist/components/recipes/customTooltip.d.ts +31 -0
  40. package/dist/components/recipes/gofish.d.ts +207 -0
  41. package/dist/components/recipes/gofishBoba.d.ts +23 -0
  42. package/dist/components/recipes/gofishIR.d.ts +169 -0
  43. package/dist/components/recipes/gofishIRExamples.d.ts +89 -0
  44. package/dist/components/recipes/gofishInterpreter.d.ts +52 -0
  45. package/dist/components/recipes/gofishLambdas.d.ts +145 -0
  46. package/dist/components/recipes/lineageDag.d.ts +129 -0
  47. package/dist/components/recipes/mermaidDag.d.ts +44 -0
  48. package/dist/components/recipes/packedClusterMatrix.d.ts +166 -0
  49. package/dist/components/recipes/recipeChrome.d.ts +100 -0
  50. package/dist/components/recipes/recipeLegend.d.ts +57 -0
  51. package/dist/components/recipes/recipeUtils.d.ts +105 -0
  52. package/dist/components/semiotic-ai.d.ts +6 -0
  53. package/dist/components/semiotic-data.d.ts +2 -0
  54. package/dist/components/semiotic-experimental.d.ts +20 -0
  55. package/dist/components/semiotic-network.d.ts +3 -1
  56. package/dist/components/semiotic-ordinal.d.ts +2 -0
  57. package/dist/components/semiotic-realtime.d.ts +9 -1
  58. package/dist/components/semiotic-recipes.d.ts +20 -1
  59. package/dist/components/semiotic-themes.d.ts +2 -0
  60. package/dist/components/semiotic-xy.d.ts +2 -0
  61. package/dist/components/semiotic.d.ts +6 -2
  62. package/dist/components/store/ObservationStore.d.ts +21 -2
  63. package/dist/components/store/SelectionStore.d.ts +1 -1
  64. package/dist/components/store/ThemeStore.d.ts +1 -1
  65. package/dist/components/store/TooltipStore.d.ts +1 -1
  66. package/dist/components/store/createStore.d.ts +1 -1
  67. package/dist/components/store/designTokens.d.ts +15 -0
  68. package/dist/components/store/useSelection.d.ts +22 -0
  69. package/dist/components/stream/NetworkHtmlMarksLayer.d.ts +44 -0
  70. package/dist/components/stream/NetworkPipelineStore.d.ts +32 -0
  71. package/dist/components/stream/NetworkSVGOverlay.d.ts +12 -0
  72. package/dist/components/stream/OrdinalPipelineStore.d.ts +18 -0
  73. package/dist/components/stream/PipelineStore.d.ts +27 -0
  74. package/dist/components/stream/SceneGraph.d.ts +5 -1
  75. package/dist/components/stream/customLayout.d.ts +20 -0
  76. package/dist/components/stream/customLayoutDiagnostics.d.ts +11 -0
  77. package/dist/components/stream/customLayoutSelection.d.ts +52 -0
  78. package/dist/components/stream/networkCustomLayout.d.ts +101 -1
  79. package/dist/components/stream/networkTypes.d.ts +38 -1
  80. package/dist/components/stream/ordinalCustomLayout.d.ts +17 -1
  81. package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -0
  82. package/dist/components/stream/ordinalTypes.d.ts +19 -3
  83. package/dist/components/stream/renderers/networkSymbolRenderer.d.ts +2 -0
  84. package/dist/components/stream/renderers/symbolCanvasRenderer.d.ts +2 -0
  85. package/dist/components/stream/stalenessBands.d.ts +28 -0
  86. package/dist/components/stream/symbolPath.d.ts +24 -0
  87. package/dist/components/stream/types.d.ts +72 -3
  88. package/dist/components/stream/useStalenessCheck.d.ts +6 -1
  89. package/dist/components/stream/xySceneBuilders/pointScene.d.ts +2 -2
  90. package/dist/components/stream/xySceneBuilders/types.d.ts +5 -0
  91. package/dist/geo.min.js +1 -1
  92. package/dist/geo.module.min.js +1 -1
  93. package/dist/network.min.js +1 -1
  94. package/dist/network.module.min.js +1 -1
  95. package/dist/ordinal.min.js +1 -1
  96. package/dist/ordinal.module.min.js +1 -1
  97. package/dist/realtime.min.js +1 -1
  98. package/dist/realtime.module.min.js +1 -1
  99. package/dist/semiotic-ai-semiotic-ai-u954ylUn.js +2 -0
  100. package/dist/semiotic-ai-statisticalOverlays-CU7jW05Q.js +1 -0
  101. package/dist/semiotic-ai.d.ts +6 -0
  102. package/dist/semiotic-ai.min.js +1 -1
  103. package/dist/semiotic-ai.module.min.js +1 -1
  104. package/dist/semiotic-data.d.ts +2 -0
  105. package/dist/semiotic-data.min.js +1 -1
  106. package/dist/semiotic-data.module.min.js +1 -1
  107. package/dist/semiotic-experimental.d.ts +20 -0
  108. package/dist/semiotic-experimental.min.js +1 -0
  109. package/dist/semiotic-experimental.module.min.js +1 -0
  110. package/dist/semiotic-network.d.ts +3 -1
  111. package/dist/semiotic-ordinal.d.ts +2 -0
  112. package/dist/semiotic-realtime.d.ts +9 -1
  113. package/dist/semiotic-recipes.d.ts +20 -1
  114. package/dist/semiotic-recipes.min.js +1 -1
  115. package/dist/semiotic-recipes.module.min.js +1 -1
  116. package/dist/semiotic-semiotic-BmrYbi99.js +2 -0
  117. package/dist/semiotic-statisticalOverlays-IjZw8Lsu.js +1 -0
  118. package/dist/semiotic-themes.d.ts +2 -0
  119. package/dist/semiotic-themes.min.js +1 -1
  120. package/dist/semiotic-themes.module.min.js +1 -1
  121. package/dist/semiotic-utils.min.js +1 -1
  122. package/dist/semiotic-utils.module.min.js +1 -1
  123. package/dist/semiotic-value.min.js +1 -1
  124. package/dist/semiotic-value.module.min.js +1 -1
  125. package/dist/semiotic-xy.d.ts +2 -0
  126. package/dist/semiotic.d.ts +6 -2
  127. package/dist/semiotic.min.js +1 -1
  128. package/dist/semiotic.module.min.js +1 -1
  129. package/dist/server.min.js +1 -1
  130. package/dist/server.module.min.js +1 -1
  131. package/dist/xy-semiotic-xy-Dufu3D0-.js +2 -0
  132. package/dist/xy-statisticalOverlays-3Ni9bRph.js +1 -0
  133. package/dist/xy.min.js +1 -1
  134. package/dist/xy.module.min.js +1 -1
  135. package/package.json +11 -3
  136. package/dist/semiotic-ai-statisticalOverlays-C2PPlmXv.js +0 -1
  137. package/dist/semiotic-statisticalOverlays-C3DsOgr_.js +0 -1
  138. package/dist/xy-statisticalOverlays-C2PPlmXv.js +0 -1
@@ -0,0 +1,101 @@
1
+ import type { Datum } from "../charts/shared/datumTypes";
2
+ import { type AccessibilityAuditResult, type AuditAccessibilityOptions } from "../charts/shared/auditAccessibility";
3
+ import { type DiagnosisResult } from "../charts/shared/diagnoseConfig";
4
+ import { type ChartConfig, type ToConfigOptions } from "../export/chartConfig";
5
+ import { type ChartReaderGrounding, type ChartReaderGroundingOptions } from "./readerGrounding";
6
+ export type DataPitfallsImageMediaType = "image/png" | "image/jpeg" | "image/gif" | "image/webp";
7
+ export interface DataPitfallsImageSource {
8
+ content: string;
9
+ mediaType: DataPitfallsImageMediaType;
10
+ filename?: string;
11
+ }
12
+ export interface DataPitfallsTextInput {
13
+ kind: "code" | "text";
14
+ content: string;
15
+ language?: string;
16
+ filename?: string;
17
+ }
18
+ export interface DataPitfallsImageInput {
19
+ kind: "image";
20
+ images: DataPitfallsImageSource[];
21
+ }
22
+ export interface DataPitfallsDocumentInput {
23
+ kind: "document";
24
+ content: string;
25
+ mediaType: "application/pdf";
26
+ filename?: string;
27
+ }
28
+ export interface DataPitfallsSlideContent {
29
+ text: string;
30
+ images: DataPitfallsImageSource[];
31
+ }
32
+ export interface DataPitfallsSlidesInput {
33
+ kind: "slides";
34
+ slides: DataPitfallsSlideContent[];
35
+ filename?: string;
36
+ }
37
+ export type DataPitfallsSingleArtifactInput = DataPitfallsTextInput | DataPitfallsImageInput | DataPitfallsDocumentInput | DataPitfallsSlidesInput;
38
+ export interface DataPitfallsChainStage {
39
+ role: string;
40
+ artifact: DataPitfallsSingleArtifactInput;
41
+ }
42
+ export interface DataPitfallsChainInput {
43
+ kind: "chain";
44
+ stages: DataPitfallsChainStage[];
45
+ }
46
+ export interface DataPitfallsRenderedChart {
47
+ /** SVG markup from `semiotic/server` renderChart/renderChartWithEvidence or MCP renderChart. */
48
+ svg?: string;
49
+ /** Render evidence from `renderChartWithEvidence` or MCP renderChart. */
50
+ evidence?: unknown;
51
+ /** Optional rendered chart image for Data Pitfalls' Vision path. */
52
+ image?: DataPitfallsImageSource | DataPitfallsImageSource[];
53
+ }
54
+ export interface DataPitfallsBridgeOptions {
55
+ /** Default true. Include the serializable Semiotic chart config as JSON. */
56
+ includeConfig?: boolean;
57
+ /** Default true. Include JSX reconstructed from the serializable chart config. */
58
+ includeJSX?: boolean;
59
+ /** Default true. Include describeChart/buildReaderGrounding text and structure. */
60
+ includeGrounding?: boolean;
61
+ /** Default true. Include diagnoseConfig output. */
62
+ includeDiagnostics?: boolean;
63
+ /** Default true. Include auditAccessibility output. */
64
+ includeAccessibility?: boolean;
65
+ /** Optional author or app context, such as the analytical question or intended claim. */
66
+ context?: string;
67
+ /** Optional narrative/caption/claim that will be reviewed alongside the chart. */
68
+ narrative?: string;
69
+ /** Optional output from a render path. */
70
+ rendered?: DataPitfallsRenderedChart;
71
+ /** Forwarded to toConfig. Use includeData: false to omit raw rows from config/JSX stages; other stages may still summarize data. */
72
+ config?: ToConfigOptions;
73
+ /** Forwarded to buildReaderGrounding. */
74
+ grounding?: ChartReaderGroundingOptions;
75
+ /** Forwarded to auditAccessibility. */
76
+ accessibility?: AuditAccessibilityOptions;
77
+ /** Prefix used for generated filenames. Default: component name. */
78
+ filenamePrefix?: string;
79
+ /** Extra caller-supplied chain stages, appended last. */
80
+ additionalStages?: DataPitfallsChainStage[];
81
+ }
82
+ export interface DataPitfallsBridgeResult {
83
+ input: DataPitfallsChainInput;
84
+ config: ChartConfig;
85
+ grounding?: ChartReaderGrounding;
86
+ diagnosis?: DiagnosisResult;
87
+ accessibility?: AccessibilityAuditResult;
88
+ }
89
+ /**
90
+ * Build a Data Pitfalls-compatible chain input from a Semiotic chart config.
91
+ *
92
+ * The returned `input` is intentionally dependency-free: pass it to
93
+ * `detectPitfalls(input, options)` from the `datapitfalls` package in your app,
94
+ * CI job, or research harness. Semiotic contributes the chart config,
95
+ * reader-grounding payload, config diagnostics, accessibility audit, and
96
+ * optional rendered output; Data Pitfalls remains responsible for model-backed
97
+ * pitfall detection.
98
+ */
99
+ export declare function buildDataPitfallsBridge(component: string, props: Datum, options?: DataPitfallsBridgeOptions): DataPitfallsBridgeResult;
100
+ /** Convenience wrapper when you only need the Data Pitfalls input object. */
101
+ export declare function toDataPitfallsChain(component: string, props: Datum, options?: DataPitfallsBridgeOptions): DataPitfallsChainInput;
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Data-quality → provenanced-annotation bridge.
3
+ *
4
+ * Ingests data-quality results — dbt source-freshness + test artifacts, Great
5
+ * Expectations validation results, or a normalized form anyone can hand-build —
6
+ * and maps them to **provenanced, lifecycled chart annotations**. A failed dbt
7
+ * freshness check becomes a danger threshold on the chart that says *who* found
8
+ * it (a system rule), *how* (a freshness rule), *when*, and against *which data
9
+ * snapshot* — so the chart's communicative act flips from report to alert,
10
+ * driven entirely by external metadata.
11
+ *
12
+ * Doctrine this module honors:
13
+ * - Pure, no React, no new dependencies — it shapes plain JSON into the
14
+ * `Annotated[]` surface that already ships (`withProvenance` + the lifecycle
15
+ * helpers do the rest).
16
+ * - **Read-only overlay.** It consumes a data-quality system's output and never
17
+ * writes back into it. Clicking the chart does not trigger a dbt run.
18
+ * - **Refuse rather than mistranslate.** A check with no faithful chart
19
+ * coordinate (a `not_null` test, a uniqueness expectation) is NOT given a
20
+ * fabricated position — it is returned in `unplaced[]` with a reason, so the
21
+ * 30% an adapter can't place is announced rather than hidden.
22
+ *
23
+ * The data-quality system owns query execution, governance, and the test
24
+ * definitions; this bridge owns only the visual overlay and its provenance.
25
+ */
26
+ import type { Datum } from "../charts/shared/datumTypes";
27
+ import type { AnnotationAnchor, AnnotationBasis, AnnotationStatus, Annotated } from "./annotationProvenance";
28
+ export type DataQualityStatus = "pass" | "fail" | "warn" | "error";
29
+ /**
30
+ * How a check relates to a chart. Only the kinds with a clear visual analog
31
+ * produce an annotation; the rest are reported as `unplaced`.
32
+ */
33
+ export type DataQualityCheckKind = "range" | "min" | "max" | "threshold" | "freshness" | "not-null" | "unique" | "accepted-values" | "row-condition" | "custom";
34
+ /**
35
+ * A single data-quality result, normalized across source systems. The dbt and
36
+ * Great-Expectations parsers produce these; consumers can also hand-build them
37
+ * (e.g. to bridge Monte Carlo or a bespoke checker).
38
+ */
39
+ export interface DataQualityResult {
40
+ /** Stable id of the check (test/expectation id). Becomes provenance.stableId. */
41
+ id: string;
42
+ /** Human-readable check name; falls back to id. Doubles as the provenance author. */
43
+ name?: string;
44
+ /** Concise phrase drawn on the chart. Falls back to `name`. Keep it short. */
45
+ label?: string;
46
+ status: DataQualityStatus;
47
+ kind: DataQualityCheckKind;
48
+ /** Column/field the check applies to (mapped through `fieldMap`). */
49
+ column?: string;
50
+ /** Lower bound (range/min). */
51
+ min?: number;
52
+ /** Upper bound (range/max). */
53
+ max?: number;
54
+ /** Single reference value (threshold/min/max). */
55
+ value?: number;
56
+ /** Freshness deadline or observed event time (ISO string or epoch ms). */
57
+ at?: string | number;
58
+ /** Free-form detail surfaced in the label. */
59
+ message?: string;
60
+ /** Source system. */
61
+ source?: "dbt" | "great-expectations" | (string & {});
62
+ /** Evidence type. Defaults to "rule" (deterministic constraint). */
63
+ basis?: AnnotationBasis;
64
+ /** 0–1; surfaced in the label only when < 1 (a hard rule needs no percent). */
65
+ confidence?: number;
66
+ /** ISO timestamp the check ran. */
67
+ createdAt?: string;
68
+ /** Data snapshot id (dbt invocation_id, GE run id). */
69
+ dataVersion?: string;
70
+ /** Failing-row count etc., surfaced in the label. */
71
+ observedCount?: number;
72
+ }
73
+ export interface DataQualityAnnotationOptions {
74
+ /** Map normalized column names → chart accessor field names. */
75
+ fieldMap?: Record<string, string>;
76
+ /** Which axis numeric thresholds map onto. Default "y". (Ranges always band on y.) */
77
+ valueAxis?: "x" | "y";
78
+ /** TTL applied to every generated annotation's lifecycle — drives freshness decay. */
79
+ ttlHint?: string | number;
80
+ /** Surface passing checks too (default false — only failures/warnings overlay). */
81
+ includePassed?: boolean;
82
+ /** Editorial status stamped on generated notes. Default "proposed". */
83
+ status?: AnnotationStatus;
84
+ /** Anchor mode. Default "semantic" so notes re-resolve through stableId on refresh. */
85
+ anchor?: AnnotationAnchor;
86
+ /** Color for failing/erroring checks. Default CSS var --semiotic-danger. */
87
+ failColor?: string;
88
+ /** Color for warnings. Default CSS var --semiotic-warning. */
89
+ warnColor?: string;
90
+ /** Color for passing checks (only used when includePassed). Default --semiotic-success. */
91
+ passColor?: string;
92
+ }
93
+ /** A result the bridge declined to place, with the reason (the D7 honesty surface). */
94
+ export interface UnplacedDataQualityResult {
95
+ result: DataQualityResult;
96
+ reason: string;
97
+ }
98
+ export interface DataQualityAnnotationsResult {
99
+ /** Annotations ready to pass to a chart's `annotations` prop. */
100
+ annotations: Annotated<Datum>[];
101
+ /** Results with no faithful chart coordinate, each with a reason. */
102
+ unplaced: UnplacedDataQualityResult[];
103
+ }
104
+ /**
105
+ * Map normalized data-quality results to provenanced annotations. The pure core
106
+ * both the dbt and Great-Expectations parsers funnel through; call it directly
107
+ * to bridge any other checker.
108
+ */
109
+ export declare function dataQualityToAnnotations(results: ReadonlyArray<DataQualityResult>, options?: DataQualityAnnotationOptions): DataQualityAnnotationsResult;
110
+ /** Subset of a dbt artifact's `metadata` block we read. */
111
+ interface DbtMetadata {
112
+ generated_at?: string;
113
+ invocation_id?: string;
114
+ }
115
+ /** A `sources.json` (source-freshness) result entry. */
116
+ interface DbtFreshnessResult {
117
+ unique_id?: string;
118
+ status?: string;
119
+ max_loaded_at?: string;
120
+ snapshotted_at?: string;
121
+ criteria?: {
122
+ warn_after?: {
123
+ count?: number;
124
+ period?: string;
125
+ };
126
+ error_after?: {
127
+ count?: number;
128
+ period?: string;
129
+ };
130
+ };
131
+ }
132
+ /** A `run_results.json` result entry (we read the test-relevant fields). */
133
+ interface DbtRunResult {
134
+ unique_id?: string;
135
+ status?: string;
136
+ failures?: number | null;
137
+ message?: string | null;
138
+ }
139
+ export interface DbtArtifacts {
140
+ /** Parsed `sources.json` (dbt source freshness). */
141
+ sources?: {
142
+ metadata?: DbtMetadata;
143
+ results?: ReadonlyArray<DbtFreshnessResult>;
144
+ };
145
+ /** Parsed `run_results.json`. */
146
+ runResults?: {
147
+ metadata?: DbtMetadata;
148
+ results?: ReadonlyArray<DbtRunResult>;
149
+ };
150
+ }
151
+ /**
152
+ * Map dbt artifacts to provenanced annotations. The strongest mapping is source
153
+ * freshness (`sources.json`) — a real timestamp + status becomes a time
154
+ * threshold. Test results (`run_results.json`) carry pass/fail but not, without
155
+ * `manifest.json`, the column/range semantics needed to place them; those land
156
+ * in `unplaced[]` with a reason (D7).
157
+ */
158
+ export declare function fromDbtArtifacts(artifacts: DbtArtifacts, options?: DataQualityAnnotationOptions): DataQualityAnnotationsResult;
159
+ interface GEExpectationConfig {
160
+ expectation_type?: string;
161
+ kwargs?: {
162
+ column?: string;
163
+ min_value?: number | null;
164
+ max_value?: number | null;
165
+ value?: number | null;
166
+ [key: string]: unknown;
167
+ };
168
+ }
169
+ interface GEResultEntry {
170
+ success?: boolean;
171
+ expectation_config?: GEExpectationConfig;
172
+ result?: {
173
+ observed_value?: number | string;
174
+ element_count?: number;
175
+ unexpected_count?: number;
176
+ };
177
+ }
178
+ export interface GEValidationResult {
179
+ success?: boolean;
180
+ results?: ReadonlyArray<GEResultEntry>;
181
+ meta?: {
182
+ run_id?: {
183
+ run_name?: string;
184
+ run_time?: string;
185
+ } | string;
186
+ [key: string]: unknown;
187
+ };
188
+ statistics?: {
189
+ evaluated_expectations?: number;
190
+ successful_expectations?: number;
191
+ };
192
+ }
193
+ /**
194
+ * Map a Great Expectations validation result to provenanced annotations.
195
+ * Range expectations (`expect_*_to_be_between`) become bands; single-bound
196
+ * expectations become thresholds. Set/uniqueness/null expectations have no
197
+ * single chart coordinate and are returned in `unplaced[]`. GE expectations are
198
+ * statistical assertions, so `basis` defaults to "statistical-test".
199
+ */
200
+ export declare function fromGreatExpectations(validation: GEValidationResult, options?: DataQualityAnnotationOptions): DataQualityAnnotationsResult;
201
+ export {};
@@ -99,6 +99,8 @@ export declare function communicativeActForIntent(intent: IntentId): Communicati
99
99
  * family classification. Returns undefined only when nothing identifies it.
100
100
  */
101
101
  export declare function resolveCommunicativeAct(component: string, context: ChartCapability | DescribeCapabilityContext | undefined): CommunicativeAct | undefined;
102
+ /** True when props carry a provenanced, system/agent-generated alert annotation. */
103
+ export declare function hasGeneratedAlertAnnotation(props: Datum): boolean;
102
104
  /** Build a number formatter — compact (6.5M) for large magnitudes, plain
103
105
  * otherwise. Exported so the navigation tree formats values identically. */
104
106
  export declare function chartValueFormatter(locale?: string): (n: number) => string;
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Generative-UI trust layer.
3
+ *
4
+ * "Generation is cheap; trust is scarce." An LLM can emit chart code in a
5
+ * sentence — but hand-written JSX breaks on first paint, and a plausible-looking
6
+ * chart for the wrong data misleads exactly the reader who can't tell. This
7
+ * module is the trust layer an AI framework wraps around chart generation: it
8
+ * turns an LLM's *proposal* (a component name + props) into a result that is
9
+ * either guaranteed-renderable or accompanied by structured reasons and ranked
10
+ * alternatives to retry with — never a broken chart.
11
+ *
12
+ * It composes the already-shipped surface into the documented loop —
13
+ * **generate → validate → diagnose → repair → render+prove** — and rides
14
+ * `ChartConfig`, the gate-defended public artifact. It is framework-agnostic by
15
+ * construction: no Vercel/LangChain/OpenAI/Anthropic SDK enters the library
16
+ * (the tool-definition shapers below are pure object transforms over JSON
17
+ * Schema). The one heavy step — rendering to SVG with render evidence — is
18
+ * *dependency-injected* (`RenderFn`), so this module stays free of server deps
19
+ * and usable in a browser, an edge runtime, or a notebook.
20
+ */
21
+ import type { Datum } from "../charts/shared/datumTypes";
22
+ import type { ChartConfig } from "../export/chartConfig";
23
+ import type { ValidationResult } from "../charts/shared/validateProps";
24
+ import type { Diagnosis } from "../charts/shared/diagnoseConfig";
25
+ import type { RepairResult } from "./repairChartConfig";
26
+ import type { IntentId } from "./intents";
27
+ import type { RenderEvidence } from "../server/renderEvidence";
28
+ /**
29
+ * A renderer that turns a validated config into SVG + render evidence. Inject
30
+ * `renderChartWithEvidence` from `semiotic/server` in Node/SSR; omit it in the
31
+ * browser (the helper still validates, diagnoses, repairs, and emits JSX).
32
+ */
33
+ export type RenderFn = (component: string, props: Datum) => {
34
+ svg: string;
35
+ evidence: RenderEvidence;
36
+ };
37
+ export interface PrepareChartInput {
38
+ /** Chart component name the model proposed (e.g. "LineChart"). */
39
+ component: string;
40
+ /** Props the model proposed. */
41
+ props?: Datum;
42
+ }
43
+ export interface PrepareChartOptions {
44
+ /**
45
+ * The dataset, used to route a repair when the proposed chart is unknown or a
46
+ * poor fit. When present, `repair` runs by default.
47
+ */
48
+ data?: ReadonlyArray<Datum>;
49
+ /** Ranking intent passed to repair's alternative search. */
50
+ intent?: IntentId | IntentId[];
51
+ /** Run `diagnoseConfig` anti-pattern checks (default true). */
52
+ diagnose?: boolean;
53
+ /**
54
+ * Run repair routing (fit check + ranked alternatives). Default: true when
55
+ * `data` is provided, false otherwise (repair needs the data to profile).
56
+ */
57
+ repair?: boolean;
58
+ /**
59
+ * Inject a renderer to prove the config paints (and to read render evidence —
60
+ * the first-try oracle). When omitted, the result has no `svg`/`evidence`,
61
+ * and `ok` is decided on validation + diagnostics alone.
62
+ */
63
+ render?: RenderFn;
64
+ /**
65
+ * Treat error-severity diagnostics as blocking `ok` (default true). Set false
66
+ * to let a caller surface warnings without failing the gate.
67
+ */
68
+ treatErrorsAsBlocking?: boolean;
69
+ }
70
+ export interface PrepareChartResult {
71
+ /**
72
+ * True only when the proposal is trustworthy: it validates, carries no
73
+ * error-severity diagnostics, and — if a renderer was injected — produced a
74
+ * non-empty scene. A `false` result is the signal to retry with `reasons` and
75
+ * `repair.alternatives`, never to paint.
76
+ */
77
+ ok: boolean;
78
+ component: string;
79
+ props: Datum;
80
+ /** The serializable, validated config — present whenever the component is known. */
81
+ config?: ChartConfig;
82
+ /** JSX string for the validated config (only when a config could be built). */
83
+ jsx?: string;
84
+ /** Structural validation: required props, types, enums, accessor/data shape. */
85
+ validation: ValidationResult;
86
+ /** Anti-pattern diagnostics (empty data, misleading design, contrast, …). */
87
+ diagnostics: Diagnosis[];
88
+ /** Fit verdict + ranked alternatives, when repair ran. */
89
+ repair?: RepairResult;
90
+ /** Render evidence (mark count, domains, ariaLabel, …) when a renderer ran. */
91
+ evidence?: RenderEvidence;
92
+ /** Rendered SVG when a renderer ran. */
93
+ svg?: string;
94
+ /** Human-readable reasons the proposal is not `ok` (empty when `ok`). */
95
+ reasons: string[];
96
+ }
97
+ /**
98
+ * Run an LLM chart proposal through the trust loop. Pure except for any side
99
+ * effects of an injected `render` function.
100
+ */
101
+ export declare function prepareChart(input: PrepareChartInput, options?: PrepareChartOptions): PrepareChartResult;
102
+ /**
103
+ * A tool definition expressed as JSON Schema — the common denominator every
104
+ * agent framework accepts. Mirrors the MCP `renderChart` contract so an
105
+ * in-process tool and the MCP server speak the same shape.
106
+ */
107
+ export interface ChartToolDefinition {
108
+ name: string;
109
+ description: string;
110
+ /** JSON Schema for the tool input. */
111
+ inputSchema: Record<string, unknown>;
112
+ }
113
+ export interface ChartToolOptions {
114
+ /** Override the tool name (default "render_semiotic_chart"). */
115
+ name?: string;
116
+ /** Restrict the component enum to this allow-list (default: the whole registry). */
117
+ components?: ReadonlyArray<string>;
118
+ }
119
+ /**
120
+ * Build a framework-agnostic tool definition for generating a Semiotic chart.
121
+ * Pass it (or a shaper's output) to your agent framework, and pair it with
122
+ * {@link createChartToolHandler} for the execute step.
123
+ */
124
+ export declare function chartGenerationTool(options?: ChartToolOptions): ChartToolDefinition;
125
+ /** Shape a tool definition for the Anthropic Messages API `tools` array. */
126
+ export declare function toAnthropicTool(def: ChartToolDefinition): {
127
+ name: string;
128
+ description: string;
129
+ input_schema: Record<string, unknown>;
130
+ };
131
+ /** Shape a tool definition for the OpenAI / function-calling `tools` array. */
132
+ export declare function toOpenAITool(def: ChartToolDefinition): {
133
+ type: "function";
134
+ function: {
135
+ name: string;
136
+ description: string;
137
+ parameters: Record<string, unknown>;
138
+ };
139
+ };
140
+ /**
141
+ * Build the execute handler for the chart tool: it runs {@link prepareChart} on
142
+ * the tool input and returns the trust-loop result. Inject a `render` fn (from
143
+ * `semiotic/server`) and/or the `data` for fit checking via `optionsFor`.
144
+ */
145
+ export declare function createChartToolHandler(optionsFor?: (input: PrepareChartInput) => PrepareChartOptions): (input: PrepareChartInput) => PrepareChartResult;
@@ -22,14 +22,27 @@ export interface NetworkCustomChartProps<TNode extends Datum = Datum, TEdge exte
22
22
  /** Color scheme threaded into the layout's `resolveColor` helper. */
23
23
  colorScheme?: string | string[];
24
24
  enableHover?: boolean;
25
+ /**
26
+ * Annotations rendered over the chart. A custom network layout's marks are
27
+ * anchorable by id: emit a scene node with `id: <foo>` and an annotation with
28
+ * `pointId: "<foo>"` resolves to that mark's center (the editorial-callout
29
+ * story, now unified with the built-in network charts). Data-coordinate
30
+ * anchoring doesn't apply — custom layouts own their own geometry — so anchor
31
+ * by `pointId`, or draw bespoke callouts with the recipe chrome kit's
32
+ * `markCallout`.
33
+ */
34
+ annotations?: StreamNetworkFrameProps["annotations"];
35
+ /** Collision-avoiding auto-placement for the annotations above. */
36
+ autoPlaceAnnotations?: StreamNetworkFrameProps["autoPlaceAnnotations"];
25
37
  /**
26
38
  * Custom layouts own their own color resolution (the layout function
27
39
  * decides what each node looks like), so the auto-legend infrastructure
28
40
  * the built-in network HOCs use can't run. To render a legend, build a
29
- * `legendGroups` array yourself and pass it through `frameProps.legend`.
41
+ * `legendGroups` array yourself (see `legendGroupsFrom`) and pass it through
42
+ * `frameProps.legend`.
30
43
  */
31
44
  /** Additional StreamNetworkFrame props for advanced customization. */
32
- frameProps?: Partial<Omit<StreamNetworkFrameProps, "nodes" | "edges" | "chartType" | "size" | "customNetworkLayout" | "layoutConfig">>;
45
+ frameProps?: Partial<Omit<StreamNetworkFrameProps, "nodes" | "edges" | "chartType" | "size" | "customNetworkLayout" | "layoutConfig" | "layoutSelection">>;
33
46
  }
34
47
  /**
35
48
  * NetworkCustomChart — escape hatch for bespoke network geometry.
@@ -1,6 +1,7 @@
1
1
  import type { Datum } from "../shared/datumTypes";
2
2
  import * as React from "react";
3
3
  import type { StreamOrdinalFrameProps } from "../../stream/ordinalTypes";
4
+ import type { SymbolName } from "../../stream/symbolPath";
4
5
  import type { LegendInteractionMode, LegendPosition } from "../shared/hooks";
5
6
  import type { BaseChartProps, ChartAccessor, CategoryFormatFn } from "../shared/types";
6
7
  import { type TooltipProp } from "../../Tooltip/Tooltip";
@@ -17,6 +18,12 @@ export interface SwarmPlotProps<TDatum extends Datum = Datum> extends BaseChartP
17
18
  colorScheme?: string | string[];
18
19
  sizeBy?: ChartAccessor<TDatum, number>;
19
20
  sizeRange?: [number, number];
21
+ /** Field name or function → glyph **shape**: each point renders as a d3-shape
22
+ * glyph instead of a circle. Pair with `symbolMap` for stable, legend-matchable
23
+ * shapes; unmapped categories auto-assign. Size still tracks `sizeBy`/`pointRadius`. */
24
+ symbolBy?: ChartAccessor<TDatum, string>;
25
+ /** Explicit `{category → shape}` map for `symbolBy`; unmapped auto-assign. */
26
+ symbolMap?: Record<string, SymbolName>;
20
27
  pointRadius?: number;
21
28
  pointOpacity?: number;
22
29
  categoryPadding?: number;
@@ -7,6 +7,8 @@ import type { ChartMode, ChartAccessor, SelectionConfig } from "../shared/types"
7
7
  import type { OnObservationCallback } from "../../store/ObservationStore";
8
8
  import type { Datum } from "../shared/datumTypes";
9
9
  import type { AutoPlaceAnnotations } from "../../recipes/annotationLayout";
10
+ import { type AggregateConfig } from "./aggregate";
11
+ import { type EventTimeConfig } from "./eventTime";
10
12
  export interface RealtimeLineChartProps<TDatum extends Datum = Datum> {
11
13
  /** Display mode: "primary" (full chrome), "context" (compact), "sparkline" (inline) */
12
14
  mode?: ChartMode;
@@ -106,6 +108,25 @@ export interface RealtimeLineChartProps<TDatum extends Datum = Datum> {
106
108
  legendInteraction?: LegendInteractionMode;
107
109
  /** ID accessor for remove()/update() on the push API */
108
110
  pointIdAccessor?: string | ((d: Datum) => string);
111
+ /**
112
+ * Opt-in windowed aggregation over event-time. When set, pushed
113
+ * events are reduced into tumbling/hopping/session windows and the
114
+ * chart draws one mark per window (mean/sum/min/max/count) plus an
115
+ * optional ±σ or min–max band — render cost scales with the number of
116
+ * visible windows, not the arrival rate. This is the **aggregation
117
+ * window**, distinct from `windowMode`'s RingBuffer eviction.
118
+ */
119
+ aggregate?: AggregateConfig;
120
+ /**
121
+ * Opt-in event-time ingestion. Buffers pushed events for a bounded
122
+ * lateness/grace window and releases them to the chart in event-time
123
+ * order, so out-of-order or merged multi-source streams render
124
+ * monotonically instead of zigzagging. Late events (older than
125
+ * `watermark − lateness`) are dropped or kept per policy and surfaced
126
+ * via `onObservation` as `"late-data"`. Default-off; when unset the
127
+ * push path is byte-for-byte unchanged.
128
+ */
129
+ eventTime?: EventTimeConfig;
109
130
  }
110
131
  /**
111
132
  * RealtimeLineChart - Simplified wrapper for streaming line charts.
@@ -0,0 +1,51 @@
1
+ import { WindowAccumulator, type WindowType, type AggregateStat, type AggregateBand } from "../../realtime/WindowAccumulator";
2
+ import type { Datum } from "../shared/datumTypes";
3
+ /**
4
+ * Opt-in windowed-aggregation transform for realtime XY charts. With it
5
+ * set, pushed events are reduced into event-time windows and the chart
6
+ * draws one mark per window (mean / sum / min / max / count) plus an
7
+ * optional ±σ or min–max envelope — bounded render cost regardless of
8
+ * arrival rate.
9
+ */
10
+ export interface AggregateConfig {
11
+ /** Window kind. @default "tumbling" */
12
+ window?: WindowType;
13
+ /** Window width — ms or a duration string (`"1m"`, `"10s"`, `"500ms"`). */
14
+ size: number | string;
15
+ /** Hop between hopping windows — ms or duration string. @default = size */
16
+ hop?: number | string;
17
+ /** Session inactivity gap — ms or duration string (session windows only). */
18
+ gap?: number | string;
19
+ /** Statistic rendered as the primary series. @default "mean" */
20
+ stat?: AggregateStat;
21
+ /** Envelope drawn around the series. @default "none" */
22
+ band?: AggregateBand;
23
+ /** Multiplier for the `stddev` band (drawn as value ± sigma·σ). @default 1 */
24
+ sigma?: number;
25
+ /** Keep at most this many most-recent windows. @default unbounded */
26
+ retain?: number;
27
+ }
28
+ export declare const AGG_TIME = "time";
29
+ export declare const AGG_VALUE = "value";
30
+ export declare const AGG_LOWER = "__aggLower";
31
+ export declare const AGG_UPPER = "__aggUpper";
32
+ export declare const AGG_PARTIAL = "__aggPartial";
33
+ export declare const AGG_COUNT = "count";
34
+ export declare const AGG_START = "__aggStart";
35
+ export declare const AGG_END = "__aggEnd";
36
+ /**
37
+ * Build a `WindowAccumulator` from a config, parsing duration strings.
38
+ * Returns `null` when the window width is unparseable, so the caller can
39
+ * skip aggregation rather than bucket on a zero-width window.
40
+ */
41
+ export declare function createAccumulator(config: AggregateConfig): WindowAccumulator | null;
42
+ /**
43
+ * Snapshot the accumulator into frame-ready rows. Each row carries the
44
+ * primary stat at `value`, the window midpoint at `time`, the band
45
+ * bounds (when a band is configured), and provenance fields (`count`,
46
+ * partial flag, raw start/end) for tooltips and partial-window styling.
47
+ */
48
+ export declare function aggregatedRows(acc: WindowAccumulator, config: AggregateConfig): Datum[];
49
+ /** Whether a config requests a band envelope. */
50
+ export declare function hasBand(config: AggregateConfig): boolean;
51
+ export type { AggregateStat, AggregateBand, WindowType };
@@ -0,0 +1,26 @@
1
+ import { ReorderBuffer, type LatePolicy } from "../../realtime/ReorderBuffer";
2
+ import type { Datum } from "../shared/datumTypes";
3
+ /**
4
+ * Opt-in event-time ingestion for realtime XY charts. Reorders pushed
5
+ * events within a bounded grace window so out-of-order arrivals render
6
+ * in event-time order, at the cost of delaying display by `lateness`.
7
+ */
8
+ export interface EventTimeConfig {
9
+ /**
10
+ * Grace window — ms or a duration string (`"2s"`, `"500ms"`). Events
11
+ * whose time is older than `watermark − lateness` are late.
12
+ */
13
+ lateness: number | string;
14
+ /**
15
+ * What to do with a late event:
16
+ * - `"drop"` (default): discard it (still counted + surfaced).
17
+ * - `"keep"`: release it immediately, out of order (still counted).
18
+ */
19
+ latePolicy?: LatePolicy;
20
+ }
21
+ /**
22
+ * Build a `ReorderBuffer` from a config and a time accessor, parsing the
23
+ * lateness duration. Returns `null` when the lateness is unparseable so
24
+ * the caller can fall back to plain (in-order) ingestion.
25
+ */
26
+ export declare function createReorderBuffer(config: EventTimeConfig, getTime: (d: Datum) => number): ReorderBuffer<Datum> | null;
@@ -53,6 +53,8 @@ export declare const interpolateInferno: (t: number) => string;
53
53
  export declare const interpolateMagma: (t: number) => string;
54
54
  export declare const interpolateCividis: (t: number) => string;
55
55
  export declare const interpolateTurbo: (t: number) => string;
56
+ export declare const SEQUENTIAL_INTERPOLATORS: Record<string, (t: number) => string>;
57
+ export declare function getSequentialInterpolator(scheme: string | undefined): (t: number) => string;
56
58
  export declare const interpolateRdBu: (t: number) => string;
57
59
  export declare const interpolatePiYG: (t: number) => string;
58
60
  export declare const interpolatePRGn: (t: number) => string;
@@ -2,18 +2,7 @@ import type { Datum } from "./datumTypes";
2
2
  /**
3
3
  * Predefined color schemes
4
4
  */
5
- export declare const COLOR_SCHEMES: {
6
- category10: readonly string[];
7
- tableau10: readonly string[];
8
- set3: readonly string[];
9
- blues: (t: number) => string;
10
- reds: (t: number) => string;
11
- greens: (t: number) => string;
12
- oranges: (t: number) => string;
13
- purples: (t: number) => string;
14
- viridis: (t: number) => string;
15
- plasma: (t: number) => string;
16
- };
5
+ export declare const COLOR_SCHEMES: Record<string, readonly string[] | ((t: number) => string)>;
17
6
  /**
18
7
  * Default colors for charts
19
8
  */
@@ -0,0 +1,3 @@
1
+ export declare function getMinMax(values: ReadonlyArray<number>): [number, number];
2
+ export declare function getMin(values: ReadonlyArray<number>, fallback?: number): number;
3
+ export declare function getMax(values: ReadonlyArray<number>, fallback?: number): number;