@shapesos/clay 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +60 -0
  2. package/dist/artifacts.cjs +1420 -245
  3. package/dist/artifacts.cjs.map +1 -1
  4. package/dist/artifacts.d.cts +167 -6
  5. package/dist/artifacts.d.ts +167 -6
  6. package/dist/artifacts.js +18 -3
  7. package/dist/blocks.cjs +1696 -532
  8. package/dist/blocks.cjs.map +1 -1
  9. package/dist/blocks.css +1 -1
  10. package/dist/blocks.d.cts +21 -10
  11. package/dist/blocks.d.ts +21 -10
  12. package/dist/blocks.js +7 -3
  13. package/dist/capture.cjs +220 -0
  14. package/dist/capture.cjs.map +1 -0
  15. package/dist/capture.d.cts +113 -0
  16. package/dist/capture.d.ts +113 -0
  17. package/dist/capture.js +17 -0
  18. package/dist/chart.cjs +594 -0
  19. package/dist/chart.cjs.map +1 -0
  20. package/dist/chart.d.cts +439 -0
  21. package/dist/chart.d.ts +439 -0
  22. package/dist/chart.js +32 -0
  23. package/dist/chart.js.map +1 -0
  24. package/dist/chat.cjs +1687 -532
  25. package/dist/chat.cjs.map +1 -1
  26. package/dist/chat.d.cts +3 -2
  27. package/dist/chat.d.ts +3 -2
  28. package/dist/chat.js +8 -4
  29. package/dist/{chunk-MXOPG747.js → chunk-26XVDY6Z.js} +8 -8
  30. package/dist/chunk-26XVDY6Z.js.map +1 -0
  31. package/dist/{chunk-L35M3OD5.js → chunk-4MZZH3WX.js} +5 -11
  32. package/dist/chunk-4MZZH3WX.js.map +1 -0
  33. package/dist/chunk-DT44KNCV.js +1004 -0
  34. package/dist/chunk-DT44KNCV.js.map +1 -0
  35. package/dist/chunk-JAGNXEWK.js +116 -0
  36. package/dist/chunk-JAGNXEWK.js.map +1 -0
  37. package/dist/chunk-LXYCT4YO.js +7 -0
  38. package/dist/chunk-LXYCT4YO.js.map +1 -0
  39. package/dist/chunk-P6GUNIAE.js +11 -0
  40. package/dist/chunk-P6GUNIAE.js.map +1 -0
  41. package/dist/{chunk-OUW6PUEB.js → chunk-QH2WW2MW.js} +7 -7
  42. package/dist/chunk-QXGYMDIA.js +477 -0
  43. package/dist/chunk-QXGYMDIA.js.map +1 -0
  44. package/dist/chunk-RSRNSWJN.js +1 -0
  45. package/dist/chunk-RSRNSWJN.js.map +1 -0
  46. package/dist/dom-to-image-NATF3446.js +21 -0
  47. package/dist/dom-to-image-NATF3446.js.map +1 -0
  48. package/dist/index.cjs +1489 -317
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +4 -3
  51. package/dist/index.d.ts +4 -3
  52. package/dist/index.js +28 -15
  53. package/dist/table.js +2 -1
  54. package/dist/types-B2aYk82c.d.cts +29 -0
  55. package/dist/types-B2aYk82c.d.ts +29 -0
  56. package/dist/types-BzXPBy6s.d.cts +330 -0
  57. package/dist/{types-DuuRI4ll.d.cts → types-CW45GBXl.d.cts} +31 -4
  58. package/dist/{types-C9XX-Uhk.d.ts → types-D1b8v7EY.d.ts} +31 -4
  59. package/dist/types-GCkXbyFm.d.ts +330 -0
  60. package/package.json +24 -2
  61. package/dist/chunk-BX5TCEPR.js +0 -436
  62. package/dist/chunk-BX5TCEPR.js.map +0 -1
  63. package/dist/chunk-L35M3OD5.js.map +0 -1
  64. package/dist/chunk-MEJESPTZ.js +0 -1
  65. package/dist/chunk-MXOPG747.js.map +0 -1
  66. package/dist/types-3Gzk7cRt.d.cts +0 -121
  67. package/dist/types-3Gzk7cRt.d.ts +0 -121
  68. /package/dist/{chunk-MEJESPTZ.js.map → capture.js.map} +0 -0
  69. /package/dist/{chunk-OUW6PUEB.js.map → chunk-QH2WW2MW.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { ColorToken, TypographyStyle, TypographyType, colors, fontFamilies, typographyMixin, typographyStyles, typographyTypes } from './tokens.cjs';
2
2
  export { ArtifactRefBlock, ArtifactRefBlockService, Block, BlockContext, BlockContextValue, BlockServices, TextBlockService, useBlockContext } from './blocks.cjs';
3
- export { A as ArtifactRefBlockRecord, B as BlockComponentProps, a as BlockRecord, b as BlockService, c as BlockType, T as TextBlockRecord, d as blockTypes } from './types-DuuRI4ll.cjs';
4
- export { A as ArtifactRecord, a as ArtifactService, b as ArtifactServiceProps, c as ArtifactType, T as TableArtifactRecord, d as TableColumn, e as TableConfig, f as TableRow, g as TableStats, h as artifactTypes } from './types-3Gzk7cRt.cjs';
5
- export { ArtifactDownloadButton, ArtifactDownloadButtonProps, ArtifactServices, TableArtifact, artifactToClipboardText, isSafeDownloadUrl } from './artifacts.cjs';
3
+ export { A as ArtifactRefBlockRecord, B as BlockComponentProps, a as BlockRecord, b as BlockService, c as BlockType, T as TextBlockRecord, d as blockTypes } from './types-CW45GBXl.cjs';
4
+ export { A as ArtifactCallbacksOf, a as ArtifactDataRow, b as ArtifactLabelsOf, c as ArtifactRecord, d as ArtifactService, e as ArtifactServiceProps, f as ArtifactType, B as BarChartConfig, C as ChartArtifactLabels, g as ChartArtifactRecord, h as ChartConfig, i as ChartStats, D as DEFAULT_CHART_ARTIFACT_LABELS, j as DEFAULT_TABLE_ARTIFACT_LABELS, L as LineChartConfig, P as PieChartConfig, T as TableArtifactLabels, k as TableArtifactRecord, l as TableColumn, m as TableConfig, n as TableRow, o as TableStats, p as artifactTypes } from './types-BzXPBy6s.cjs';
5
+ export { ArtifactCopyAsImageButton, ArtifactCopyAsImageButtonProps, ArtifactDownloadButton, ArtifactDownloadButtonProps, ArtifactDownloadMenu, ArtifactDownloadMenuCsvAction, ArtifactDownloadMenuPngAction, ArtifactDownloadMenuProps, ArtifactServices, ChartArtifact, TableArtifact, artifactToClipboardText, isSafeDownloadUrl } from './artifacts.cjs';
6
6
  export { ChatContext, ChatContextValue, ChatMessage, ChatMessageType, MESSAGE_ROLE, MessageRole, copyMessageText, useChatContext, useCopyToClipboard } from './chat.cjs';
7
7
  export { Icon, IconButton, IconButtonProps, IconButtonSize, IconButtonVariant, IconProps } from './icon.cjs';
8
8
  export { IconCtrl, KEYBOARD_SHORTCUT_VARIANTS, KeyIcon, KeyboardShortcut, KeyboardShortcutProps, KeyboardShortcutVariant } from './keyboard-shortcut.cjs';
@@ -10,6 +10,7 @@ export { Lottie, LottieAnimationData, LottieProps, LottieRef } from './lottie.cj
10
10
  export { TextArea, TextAreaProps } from './text-area.cjs';
11
11
  export { MarkdownTable, convertTableToCSV, escapeCsvField, markdownToPlainText, mergeRefs, parseMarkdownTable } from './utils.cjs';
12
12
  export { BUTTON_INTENT, BUTTON_SIZE, BUTTON_VARIANT, Button, ButtonIntent, ButtonProps, ButtonSize, ButtonVariant, ICON_POSITION, IconPosition } from './button.cjs';
13
+ export { C as ChartSeries, a as ChartVariant } from './types-B2aYk82c.cjs';
13
14
  import 'react';
14
15
  import 'react/jsx-runtime';
15
16
  import 'lottie-web';
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { ColorToken, TypographyStyle, TypographyType, colors, fontFamilies, typographyMixin, typographyStyles, typographyTypes } from './tokens.js';
2
2
  export { ArtifactRefBlock, ArtifactRefBlockService, Block, BlockContext, BlockContextValue, BlockServices, TextBlockService, useBlockContext } from './blocks.js';
3
- export { A as ArtifactRefBlockRecord, B as BlockComponentProps, a as BlockRecord, b as BlockService, c as BlockType, T as TextBlockRecord, d as blockTypes } from './types-C9XX-Uhk.js';
4
- export { A as ArtifactRecord, a as ArtifactService, b as ArtifactServiceProps, c as ArtifactType, T as TableArtifactRecord, d as TableColumn, e as TableConfig, f as TableRow, g as TableStats, h as artifactTypes } from './types-3Gzk7cRt.js';
5
- export { ArtifactDownloadButton, ArtifactDownloadButtonProps, ArtifactServices, TableArtifact, artifactToClipboardText, isSafeDownloadUrl } from './artifacts.js';
3
+ export { A as ArtifactRefBlockRecord, B as BlockComponentProps, a as BlockRecord, b as BlockService, c as BlockType, T as TextBlockRecord, d as blockTypes } from './types-D1b8v7EY.js';
4
+ export { A as ArtifactCallbacksOf, a as ArtifactDataRow, b as ArtifactLabelsOf, c as ArtifactRecord, d as ArtifactService, e as ArtifactServiceProps, f as ArtifactType, B as BarChartConfig, C as ChartArtifactLabels, g as ChartArtifactRecord, h as ChartConfig, i as ChartStats, D as DEFAULT_CHART_ARTIFACT_LABELS, j as DEFAULT_TABLE_ARTIFACT_LABELS, L as LineChartConfig, P as PieChartConfig, T as TableArtifactLabels, k as TableArtifactRecord, l as TableColumn, m as TableConfig, n as TableRow, o as TableStats, p as artifactTypes } from './types-GCkXbyFm.js';
5
+ export { ArtifactCopyAsImageButton, ArtifactCopyAsImageButtonProps, ArtifactDownloadButton, ArtifactDownloadButtonProps, ArtifactDownloadMenu, ArtifactDownloadMenuCsvAction, ArtifactDownloadMenuPngAction, ArtifactDownloadMenuProps, ArtifactServices, ChartArtifact, TableArtifact, artifactToClipboardText, isSafeDownloadUrl } from './artifacts.js';
6
6
  export { ChatContext, ChatContextValue, ChatMessage, ChatMessageType, MESSAGE_ROLE, MessageRole, copyMessageText, useChatContext, useCopyToClipboard } from './chat.js';
7
7
  export { Icon, IconButton, IconButtonProps, IconButtonSize, IconButtonVariant, IconProps } from './icon.js';
8
8
  export { IconCtrl, KEYBOARD_SHORTCUT_VARIANTS, KeyIcon, KeyboardShortcut, KeyboardShortcutProps, KeyboardShortcutVariant } from './keyboard-shortcut.js';
@@ -10,6 +10,7 @@ export { Lottie, LottieAnimationData, LottieProps, LottieRef } from './lottie.js
10
10
  export { TextArea, TextAreaProps } from './text-area.js';
11
11
  export { MarkdownTable, convertTableToCSV, escapeCsvField, markdownToPlainText, mergeRefs, parseMarkdownTable } from './utils.js';
12
12
  export { BUTTON_INTENT, BUTTON_SIZE, BUTTON_VARIANT, Button, ButtonIntent, ButtonProps, ButtonSize, ButtonVariant, ICON_POSITION, IconPosition } from './button.js';
13
+ export { C as ChartSeries, a as ChartVariant } from './types-B2aYk82c.js';
13
14
  import 'react';
14
15
  import 'react/jsx-runtime';
15
16
  import 'lottie-web';
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ import {
2
+ Lottie
3
+ } from "./chunk-BIATJTD4.js";
1
4
  import {
2
5
  TextArea
3
6
  } from "./chunk-WPQQVKWY.js";
@@ -21,7 +24,6 @@ import {
21
24
  Button,
22
25
  ICON_POSITION
23
26
  } from "./chunk-EDICS62G.js";
24
- import "./chunk-C77QMQNT.js";
25
27
  import {
26
28
  ChatContext,
27
29
  ChatMessage,
@@ -29,7 +31,7 @@ import {
29
31
  copyMessageText,
30
32
  useChatContext,
31
33
  useCopyToClipboard
32
- } from "./chunk-OUW6PUEB.js";
34
+ } from "./chunk-QH2WW2MW.js";
33
35
  import {
34
36
  BlockContext,
35
37
  useBlockContext
@@ -41,26 +43,35 @@ import {
41
43
  BlockServices,
42
44
  TextBlockService,
43
45
  blockTypes
44
- } from "./chunk-MXOPG747.js";
46
+ } from "./chunk-26XVDY6Z.js";
45
47
  import {
46
48
  markdownToPlainText
47
49
  } from "./chunk-NMKKU2UG.js";
50
+ import "./chunk-RSRNSWJN.js";
48
51
  import {
49
- fontFamilies,
50
- typographyMixin,
51
- typographyStyles,
52
- typographyTypes
53
- } from "./chunk-SV24ONND.js";
54
- import "./chunk-MEJESPTZ.js";
55
- import {
52
+ ArtifactCopyAsImageButton,
56
53
  ArtifactDownloadButton,
54
+ ArtifactDownloadMenu,
57
55
  ArtifactServices,
56
+ ChartArtifact,
57
+ DEFAULT_CHART_ARTIFACT_LABELS,
58
+ DEFAULT_TABLE_ARTIFACT_LABELS,
58
59
  TableArtifact,
59
60
  artifactToClipboardText,
60
61
  artifactTypes,
61
62
  isSafeDownloadUrl
62
- } from "./chunk-BX5TCEPR.js";
63
- import "./chunk-L35M3OD5.js";
63
+ } from "./chunk-DT44KNCV.js";
64
+ import "./chunk-LXYCT4YO.js";
65
+ import "./chunk-QXGYMDIA.js";
66
+ import "./chunk-C77QMQNT.js";
67
+ import {
68
+ fontFamilies,
69
+ typographyMixin,
70
+ typographyStyles,
71
+ typographyTypes
72
+ } from "./chunk-SV24ONND.js";
73
+ import "./chunk-4MZZH3WX.js";
74
+ import "./chunk-P6GUNIAE.js";
64
75
  import "./chunk-72TJUKMV.js";
65
76
  import {
66
77
  IconButton
@@ -71,12 +82,11 @@ import {
71
82
  import {
72
83
  colors
73
84
  } from "./chunk-JF3P66JF.js";
74
- import {
75
- Lottie
76
- } from "./chunk-BIATJTD4.js";
77
85
  import "./chunk-5WRI5ZAA.js";
78
86
  export {
87
+ ArtifactCopyAsImageButton,
79
88
  ArtifactDownloadButton,
89
+ ArtifactDownloadMenu,
80
90
  ArtifactRefBlock,
81
91
  ArtifactRefBlockService,
82
92
  ArtifactServices,
@@ -87,8 +97,11 @@ export {
87
97
  BlockContext,
88
98
  BlockServices,
89
99
  Button,
100
+ ChartArtifact,
90
101
  ChatContext,
91
102
  ChatMessage,
103
+ DEFAULT_CHART_ARTIFACT_LABELS,
104
+ DEFAULT_TABLE_ARTIFACT_LABELS,
92
105
  ICON_POSITION,
93
106
  Icon,
94
107
  IconButton,
package/dist/table.js CHANGED
@@ -8,7 +8,8 @@ import {
8
8
  TableHeader,
9
9
  TableRow,
10
10
  useScrollShadow
11
- } from "./chunk-L35M3OD5.js";
11
+ } from "./chunk-4MZZH3WX.js";
12
+ import "./chunk-P6GUNIAE.js";
12
13
  import "./chunk-5WRI5ZAA.js";
13
14
  export {
14
15
  Table,
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Core types for clay's chart library.
3
+ *
4
+ * Two layers consume these:
5
+ *
6
+ * 1. The high-level chart components (`<BarChart>`, `<LineChart>`, `<PieChart>`) — single-call
7
+ * convenience renderers with sensible defaults.
8
+ * 2. The artifact-side `ChartConfig` (in `@/components/artifacts/types`) — wire-protocol shape
9
+ * that drives the artifact renderer. `artifacts/types` re-exports `ChartSeries` and
10
+ * `ChartVariant` from here so both layers share one canonical type.
11
+ */
12
+ /**
13
+ * A single series in a multi-series chart. Used by `<LineChart>` and `<BarChart>`.
14
+ */
15
+ interface ChartSeries {
16
+ /** Must match a property name on every row in the chart's `data`. The value at this property
17
+ * is plotted (coerced to number if necessary). */
18
+ key: string;
19
+ /** Human-readable name shown in legend + tooltip. Defaults to `key` if missing, but always
20
+ * pass a label for clarity. */
21
+ label: string;
22
+ }
23
+ /**
24
+ * Variant discriminator — used by code that selects a chart type at runtime (the artifact
25
+ * renderer, for example). Each variant maps to a dedicated high-level component.
26
+ */
27
+ type ChartVariant = "LINE" | "BAR" | "PIE";
28
+
29
+ export type { ChartSeries as C, ChartVariant as a };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Core types for clay's chart library.
3
+ *
4
+ * Two layers consume these:
5
+ *
6
+ * 1. The high-level chart components (`<BarChart>`, `<LineChart>`, `<PieChart>`) — single-call
7
+ * convenience renderers with sensible defaults.
8
+ * 2. The artifact-side `ChartConfig` (in `@/components/artifacts/types`) — wire-protocol shape
9
+ * that drives the artifact renderer. `artifacts/types` re-exports `ChartSeries` and
10
+ * `ChartVariant` from here so both layers share one canonical type.
11
+ */
12
+ /**
13
+ * A single series in a multi-series chart. Used by `<LineChart>` and `<BarChart>`.
14
+ */
15
+ interface ChartSeries {
16
+ /** Must match a property name on every row in the chart's `data`. The value at this property
17
+ * is plotted (coerced to number if necessary). */
18
+ key: string;
19
+ /** Human-readable name shown in legend + tooltip. Defaults to `key` if missing, but always
20
+ * pass a label for clarity. */
21
+ label: string;
22
+ }
23
+ /**
24
+ * Variant discriminator — used by code that selects a chart type at runtime (the artifact
25
+ * renderer, for example). Each variant maps to a dedicated high-level component.
26
+ */
27
+ type ChartVariant = "LINE" | "BAR" | "PIE";
28
+
29
+ export type { ChartSeries as C, ChartVariant as a };
@@ -0,0 +1,330 @@
1
+ import { ComponentType } from 'react';
2
+ import { C as ChartSeries } from './types-B2aYk82c.cjs';
3
+
4
+ /**
5
+ * Shared artifact primitives — the discriminator constant and the cross-variant `ArtifactBase`
6
+ * shape that every concrete artifact record extends.
7
+ *
8
+ * Pulled into its own file so the per-type `types.ts` files (`table-artifact/types.ts`,
9
+ * `chart-artifact/types.ts`) and the union assembler (`artifacts/types.ts`) can all depend on
10
+ * one canonical source without creating a circular module graph between them.
11
+ */
12
+ /**
13
+ * Artifact-type discriminator constants. Uppercase to match the server-side `artifactTypes`
14
+ * constant — io-server stores `artifact.type === "TABLE"` (aligned with the GraphQL enum).
15
+ */
16
+ declare const artifactTypes: {
17
+ readonly TABLE: "TABLE";
18
+ readonly CHART: "CHART";
19
+ };
20
+ /** Discriminator for artifact types. Additive — new types extend this union. */
21
+ type ArtifactType = (typeof artifactTypes)[keyof typeof artifactTypes];
22
+ /** Common shape every artifact record carries. Discriminated by `type`. */
23
+ interface ArtifactBase<TType extends ArtifactType, TConfig> {
24
+ /** Artifact-type discriminator. */
25
+ type: TType;
26
+ /** Human-readable label. Nullable when the artifact has no title. */
27
+ title: string | null;
28
+ /** Rendering config — shape varies per artifact type. */
29
+ config: TConfig;
30
+ /** Protected-asset metadata pointing to the underlying data payload. Null while the asset is unavailable. */
31
+ protectedAsset: {
32
+ /** Time-limited URL the renderer fetches the artifact's data from. */
33
+ presignedUrl: string;
34
+ } | null;
35
+ }
36
+ /**
37
+ * A row inside an artifact's parsed CSV. Every cell is the raw string from the CSV (or `null`
38
+ * for the empty string). Used by every artifact kind whose data wire is a CSV (`TABLE`, `CHART`).
39
+ * The renderer never coerces — type-aware formatting is a server concern (the CSV's contents
40
+ * are what the user sees).
41
+ */
42
+ type ArtifactDataRow = Record<string, string | null>;
43
+
44
+ /**
45
+ * Rendering config for a `BAR` chart. `xKey` selects the categorical axis; each series
46
+ * contributes one `<Bar>`. `stacked` collapses all series onto a single stack-id (so they sum
47
+ * vertically); when false / omitted bars are grouped side-by-side per x-tick.
48
+ */
49
+ interface BarChartConfig extends ChartConfigBase {
50
+ variant: "BAR";
51
+ /** CSV column key used as the x-axis. */
52
+ xKey: string;
53
+ /** When true, stack all series on one stack-id. When false / omitted, group bars side-by-side. */
54
+ stacked?: boolean;
55
+ }
56
+
57
+ /**
58
+ * Rendering config for a `LINE` chart. `xKey` selects the categorical/temporal axis from the
59
+ * CSV; each series contributes one `<Line>` overlaid against that axis.
60
+ */
61
+ interface LineChartConfig extends ChartConfigBase {
62
+ variant: "LINE";
63
+ /** CSV column key used as the x-axis. */
64
+ xKey: string;
65
+ }
66
+
67
+ /**
68
+ * Rendering config for a `PIE` chart. `categoryKey` names the slice; `valueKey` carries the
69
+ * slice's numeric magnitude. One row of CSV becomes one slice. The base's `series` array is
70
+ * always empty for pie — colors are resolved by row index from the palette.
71
+ */
72
+ interface PieChartConfig extends ChartConfigBase {
73
+ variant: "PIE";
74
+ /** CSV column key used as the slice label. */
75
+ categoryKey: string;
76
+ /** CSV column key used as the slice numeric value. */
77
+ valueKey: string;
78
+ }
79
+
80
+ /**
81
+ * Discriminated union of all supported chart variant configs. Assembled here (not in the parent
82
+ * `types.ts`) because the union depends on each variant service file as its single source of
83
+ * truth for that variant's config type.
84
+ *
85
+ * Extension pattern: add a new variant by creating one `*-chart-variant-service.ts` file and
86
+ * extending this union + the `ChartVariantServices` map below. No edits to the dispatcher.
87
+ */
88
+ type ChartConfig = LineChartConfig | BarChartConfig | PieChartConfig;
89
+
90
+ /**
91
+ * Optional stats embedded in `ChartConfig` so clients can pre-render UI before fetching the
92
+ * actual CSV (e.g. a skeleton sized to the eventual row count). Mirrors `TableStats`.
93
+ */
94
+ interface ChartStats {
95
+ /** Total number of rows in the materialised CSV. */
96
+ rowCount: number;
97
+ }
98
+ /**
99
+ * Cross-variant base for `ChartConfig`. Carries the fields every variant shares — series
100
+ * descriptors and optional stats. Per-variant config interfaces (in `chart-variant-services/`)
101
+ * extend this with their own required fields.
102
+ *
103
+ * Note: `series` is always present on the wire (matching the GraphQL `[ChartSeries!]!` shape)
104
+ * even for PIE — PIE just receives an empty array. Keeping it on the base mirrors the wire shape
105
+ * exactly and avoids TS object-literal freshness errors for callers that explicitly set
106
+ * `series: []` on a pie config.
107
+ */
108
+ interface ChartConfigBase {
109
+ /** Series descriptors in render order. LINE/BAR consume these; PIE ignores in favour of `categoryKey`+`valueKey`. */
110
+ series: ChartSeries[];
111
+ /** Optional metadata describing the underlying data — used for loading-state UI. */
112
+ stats?: ChartStats;
113
+ }
114
+ /** Concrete chart artifact record. */
115
+ type ChartArtifactRecord = ArtifactBase<typeof artifactTypes.CHART, ChartConfig>;
116
+ /**
117
+ * Localized labels for the `CHART` artifact's user-facing strings. Covers action buttons AND
118
+ * status messages — see `TableArtifactLabels` for the same shape philosophy. Extends as the
119
+ * chart artifact grows its action set (e.g. future `copyAsPng`); optional keys document
120
+ * anticipated additions without forcing every consumer to provide them today.
121
+ */
122
+ interface ChartArtifactLabels {
123
+ /** Tooltip + aria-label on the Download menu's trigger button (icon-only, opens the format
124
+ * picker). The trigger is action-shaped (just "Download"); the menu items spell out the
125
+ * format. */
126
+ download: string;
127
+ /** Label for the "Download CSV" item inside the Download menu. */
128
+ downloadCsv: string;
129
+ /** Label for the "Download PNG" item inside the Download menu. */
130
+ downloadPng: string;
131
+ /** Tooltip + aria-label on the "Copy Image" button in the chart artifact header (idle state).
132
+ * Transient working / success / error tooltips remain in English — they flash for ~1.5s and the
133
+ * cost of translating them is rarely worth it. */
134
+ copyAsImage: string;
135
+ /** Status message shown when no presigned URL is available or the chart config is malformed. */
136
+ unavailable: string;
137
+ /** Status message shown when the fetch / parse fails at runtime. */
138
+ loadError: string;
139
+ /** Status message shown while the CSV is being fetched. */
140
+ loading: string;
141
+ /** Status message shown when the fetched CSV has zero data rows. */
142
+ empty: string;
143
+ /**
144
+ * Category labels treated as the "Others" bucket in pie charts (case-insensitive). Matching
145
+ * slices are pinned to the end of the sweep and rendered in neutral grey. The agent writes a
146
+ * translated bucket name in non-English UIs (e.g. "אחרים", "Otros") — consumer passes the
147
+ * localized list here so clay can detect the bucket regardless of language. English fallback
148
+ * is `["Others", "Other"]`. Pass `[]` to disable Others detection (every slice from the palette).
149
+ */
150
+ othersCategoryLabels: readonly string[];
151
+ }
152
+ /** English fallback for `ChartArtifactLabels`. Used when the consumer hasn't passed `labels`. */
153
+ declare const DEFAULT_CHART_ARTIFACT_LABELS: ChartArtifactLabels;
154
+ /**
155
+ * Consumer-supplied side-effect callbacks for actions on the chart artifact. Mirrors
156
+ * `ChartArtifactLabels`'s shape philosophy: one entry per action this artifact exposes
157
+ * (download today; future "Copy as PNG" etc.). Every callback is optional — consumers wire
158
+ * only the actions they care about. The artifact passes its own `ChartArtifactRecord` as the
159
+ * only argument so consumers can derive analytics context (title, config.variant, etc.) without
160
+ * a per-block closure at every render site.
161
+ *
162
+ * The callback fires alongside the default browser behaviour (e.g. `onDownload` does not
163
+ * prevent the anchor's download navigation) — it's purely for analytics / observability hooks.
164
+ */
165
+ interface ChartArtifactCallbacks {
166
+ /** Fires when the "Download CSV" menu item is selected. Browser-native download still happens. */
167
+ onDownload?: (artifact: ChartArtifactRecord) => void;
168
+ /** Fires when the "Download PNG" menu item is selected. Runs alongside the rasterise — fires
169
+ * regardless of whether the rasterise ultimately succeeds (failures surface via console.warn). */
170
+ onDownloadPng?: (artifact: ChartArtifactRecord) => void;
171
+ /** Fires when the Copy Image button is clicked. Fires regardless of whether the copy ultimately
172
+ * succeeds (the result is reported via the button's own state flash) — use this only for
173
+ * analytics / observability, not for retrying failed copies. */
174
+ onCopyAsImage?: (artifact: ChartArtifactRecord) => void;
175
+ }
176
+
177
+ /**
178
+ * A single column descriptor for a `TableArtifact`. Carries the ORDER and LABEL for the
179
+ * rendered table — `key` selects a column from the CSV header; `label` overrides the rendered
180
+ * header text. The CSV is always the source of truth for the data shape; clay never coerces,
181
+ * reformats, or interprets cell values.
182
+ */
183
+ interface TableColumn {
184
+ /** Matches a header in the CSV. Required. Used to project + order the CSV's columns. */
185
+ key: string;
186
+ /** Human-readable header text. Required. */
187
+ label: string;
188
+ /**
189
+ * Accepted in the wire payload but not consulted by the renderer — every cell is rendered as
190
+ * the raw CSV string (or empty for null). Format conversion is a server concern; if a column
191
+ * needs to be "Yes/No" instead of "true/false", the server should emit it that way in the CSV.
192
+ * Kept in the interface so callers that pass `type` (e.g. io-client) don't get a type error.
193
+ */
194
+ type?: "string" | "number" | "date" | "boolean";
195
+ /**
196
+ * Accepted in the wire payload but not consulted by the renderer — every column is left-aligned
197
+ * by design. Kept in the interface for forward-compat; restore per-column alignment by editing
198
+ * `table-artifact-content.tsx` if a future use case justifies it.
199
+ */
200
+ align?: "left" | "center" | "right";
201
+ }
202
+ /**
203
+ * Optional stats embedded in `TableConfig` so clients can pre-render UI before fetching the
204
+ * actual data payload (e.g. N loading shimmers sized to the eventual row count).
205
+ *
206
+ * Backward-compat: optional everywhere — older artifacts persisted before this field shipped
207
+ * still validate. The renderer falls back to a single status-message line when `stats` is absent.
208
+ */
209
+ interface TableStats {
210
+ /** Total number of rows in the materialised CSV. Lets the loading branch render shimmers. */
211
+ rowCount: number;
212
+ }
213
+ /** Rendering config for a table artifact, stored at `artifact.config` (JSONB on the server). */
214
+ interface TableConfig {
215
+ /** Column descriptors in render order. */
216
+ columns: TableColumn[];
217
+ /** Optional metadata describing the underlying data — used for loading-state UI. */
218
+ stats?: TableStats;
219
+ }
220
+ /** Alias retained for callers typed against the table-specific name. */
221
+ type TableRow = ArtifactDataRow;
222
+ /** Concrete table artifact record. */
223
+ type TableArtifactRecord = ArtifactBase<typeof artifactTypes.TABLE, TableConfig>;
224
+ /**
225
+ * Localized labels for the `TABLE` artifact's user-facing strings. Covers both action buttons
226
+ * (download today; future "Copy as CSV", etc.) AND status messages (loading / error / empty /
227
+ * unavailable). Consumer passes the bag from their i18n layer; clay falls back to English
228
+ * defaults when omitted (per-key Partial merge).
229
+ */
230
+ interface TableArtifactLabels {
231
+ /** Tooltip + aria-label on the Download CSV button in the table artifact header. */
232
+ download: string;
233
+ /**
234
+ * Status message shown when no presigned URL is available (permanent server-side absence) or
235
+ * the artifact config is malformed. Both states reduce to "the underlying file isn't usable".
236
+ */
237
+ unavailable: string;
238
+ /** Status message shown when the fetch / parse fails at runtime (transient). */
239
+ loadError: string;
240
+ /** Status message shown while the CSV is being fetched and `stats.rowCount` is not known. */
241
+ loading: string;
242
+ /** Empty-state row inside the table body when the fetched CSV has zero data rows. */
243
+ empty: string;
244
+ }
245
+ /** English fallback for `TableArtifactLabels`. Used when the consumer hasn't passed `labels`. */
246
+ declare const DEFAULT_TABLE_ARTIFACT_LABELS: TableArtifactLabels;
247
+ /**
248
+ * Consumer-supplied side-effect callbacks for actions on the table artifact. Mirrors
249
+ * `ChartArtifactCallbacks` — see that interface for the shape philosophy. Every callback is
250
+ * optional; the artifact passes its own `TableArtifactRecord` as the only argument so consumers
251
+ * can derive analytics context without a per-block closure at every render site.
252
+ */
253
+ interface TableArtifactCallbacks {
254
+ /** Fires when the Download CSV button is clicked. Browser-native download still happens. */
255
+ onDownload?: (artifact: TableArtifactRecord) => void;
256
+ }
257
+
258
+ /**
259
+ * Artifact-domain types — wire-protocol shapes shared between artifact components, block-services,
260
+ * and consumers. Splits responsibilities across three layers so each artifact kind owns its own
261
+ * `types.ts` and this file assembles the cross-type union + service contract:
262
+ *
263
+ * 1. **`artifact-base.ts`** — discriminator (`artifactTypes`), `ArtifactBase<TType, TConfig>`, and
264
+ * `ArtifactDataRow`. Pulled out so each per-type `types.ts` and this assembler can depend on
265
+ * one canonical base without a circular module graph.
266
+ * 2. **`<type>-artifact/types.ts`** — per-artifact-type records, configs, labels, and defaults.
267
+ * Variant-specific types (e.g. `LineChartConfig`) live in even deeper per-variant service files.
268
+ * 3. **This file** — the cross-type `ArtifactRecord` union, the labels map keyed by artifact type,
269
+ * and the `ArtifactService<TArtifact, TLabels>` registry contract used by the dispatcher.
270
+ *
271
+ * Mirrored from the agent / io-server contract — see the `chat-typed-content-blocks-and-artifacts`
272
+ * plan, §6.4 (table contract).
273
+ */
274
+
275
+ /**
276
+ * Discriminated union of all supported artifacts. Extension pattern: add the new branch here AND
277
+ * in the `ArtifactServices` map (single source of truth for the type→component mapping). Older
278
+ * clay versions that don't know about a new type silently render nothing — see `ArtifactRefBlock`
279
+ * guard.
280
+ */
281
+ type ArtifactRecord = TableArtifactRecord | ChartArtifactRecord;
282
+ /**
283
+ * Type-level lookup from an `ArtifactRecord` branch to its labels / callbacks slice. The block
284
+ * layer already carries the discriminator on `artifact.type`, so the renderer-side `labels` and
285
+ * `callbacks` props expose exactly one type's slice — never a union-bag keyed by type. Consumers
286
+ * emit a flat object; the dispatcher narrows it implicitly via `TArtifact`.
287
+ */
288
+ type ArtifactLabelsOf<TArtifact extends ArtifactRecord> = TArtifact extends ChartArtifactRecord ? ChartArtifactLabels : TArtifact extends TableArtifactRecord ? TableArtifactLabels : never;
289
+ /** Sibling to `ArtifactLabelsOf` — callbacks slice matching the artifact branch. */
290
+ type ArtifactCallbacksOf<TArtifact extends ArtifactRecord> = TArtifact extends ChartArtifactRecord ? ChartArtifactCallbacks : TArtifact extends TableArtifactRecord ? TableArtifactCallbacks : never;
291
+ /**
292
+ * Props every concrete artifact component receives from the dispatcher.
293
+ *
294
+ * `labels` and `callbacks` are the renderer's OWN flat slice — narrowed by `TArtifact` so a
295
+ * `ChartArtifact` reads `ChartArtifactLabels` directly. The block layer (`ArtifactRefBlockRecord`)
296
+ * is a *distributed* union over `ArtifactRecord` branches, so wrong-shape labels for a given
297
+ * artifact.type are caught at the consumer's construction site — not silently forwarded here.
298
+ */
299
+ interface ArtifactServiceProps<TArtifact extends ArtifactRecord = ArtifactRecord> {
300
+ /** The artifact metadata (config + presigned URL). */
301
+ artifact: TArtifact;
302
+ /**
303
+ * Optional localized labels for this artifact's action buttons + status messages. Per-key
304
+ * `Partial` merge against `DEFAULT_*_ARTIFACT_LABELS` — anything omitted falls back to English.
305
+ */
306
+ labels?: Partial<ArtifactLabelsOf<TArtifact>>;
307
+ /**
308
+ * Optional side-effect callbacks for actions on this artifact — for analytics / observability
309
+ * hooks (e.g. tracking a download event). Callbacks fire alongside the default browser
310
+ * behaviour and do not replace it.
311
+ */
312
+ callbacks?: Partial<ArtifactCallbacksOf<TArtifact>>;
313
+ }
314
+ /** Per-artifact-type service — registry entry that pairs a discriminator with its concrete component. */
315
+ interface ArtifactService<TArtifact extends ArtifactRecord = ArtifactRecord> {
316
+ /** Discriminator value this service handles. */
317
+ type: (typeof artifactTypes)[keyof typeof artifactTypes];
318
+ /** React component that renders an artifact of this type — composes ai-elements primitives
319
+ * (`Artifact`, `ArtifactHeader`, `ArtifactTitle`, `ArtifactActions`, `ArtifactContent`) directly. */
320
+ Component: ComponentType<ArtifactServiceProps<TArtifact>>;
321
+ /**
322
+ * Returns a plain-text / markdown string suitable for clipboard copy.
323
+ *
324
+ * Called by `ArtifactRefBlockService.toClipboardText` when the user copies a message that
325
+ * contains this artifact. Must be pure and synchronous.
326
+ */
327
+ toClipboardText: (artifact: TArtifact) => string;
328
+ }
329
+
330
+ export { type ArtifactCallbacksOf as A, type BarChartConfig as B, type ChartArtifactLabels as C, DEFAULT_CHART_ARTIFACT_LABELS as D, type LineChartConfig as L, type PieChartConfig as P, type TableArtifactLabels as T, type ArtifactDataRow as a, type ArtifactLabelsOf as b, type ArtifactRecord as c, type ArtifactService as d, type ArtifactServiceProps as e, type ArtifactType as f, type ChartArtifactRecord as g, type ChartConfig as h, type ChartStats as i, DEFAULT_TABLE_ARTIFACT_LABELS as j, type TableArtifactRecord as k, type TableColumn as l, type TableConfig as m, type TableRow as n, type TableStats as o, artifactTypes as p };
@@ -1,5 +1,5 @@
1
1
  import { ComponentType } from 'react';
2
- import { A as ArtifactRecord } from './types-3Gzk7cRt.cjs';
2
+ import { c as ArtifactRecord, b as ArtifactLabelsOf, A as ArtifactCallbacksOf } from './types-BzXPBy6s.cjs';
3
3
 
4
4
  /** Block-type discriminator constants. Mirrors the wire shape from io-server / shapes-agent. */
5
5
  declare const blockTypes: {
@@ -25,8 +25,15 @@ interface TextBlockRecord {
25
25
  * `@/components/artifacts/types` so the artifact layer can be consumed independently of the
26
26
  * block layer (e.g. by a future surface that renders an artifact outside chat). The block layer
27
27
  * imports them here to wrap an artifact in an `ARTIFACT_REF` block.
28
+ *
29
+ * `ArtifactRefBlockRecord` is a *distributed* union over `ArtifactRecord` branches — TS narrows
30
+ * `labels` and `callbacks` to the slice matching `artifact.type` via `ArtifactLabelsOf<T>` /
31
+ * `ArtifactCallbacksOf<T>`. Without this distribution, `Partial<ChartLabels | TableLabels>`
32
+ * collapses to `Partial<ChartLabels> | Partial<TableLabels>` and TS accepts chart-only keys on
33
+ * a TABLE block's payload (the discriminator becomes load-bearing only at runtime, not in the
34
+ * type system).
28
35
  */
29
- interface ArtifactRefBlockRecord {
36
+ type ArtifactRefBlockRecord = ArtifactRecord extends infer TArtifact ? TArtifact extends ArtifactRecord ? {
30
37
  /** Block-type discriminator. */
31
38
  type: typeof blockTypes.ARTIFACT_REF;
32
39
  /** Type-specific data; kept as `payload` to match the wire shape 1:1. */
@@ -34,9 +41,29 @@ interface ArtifactRefBlockRecord {
34
41
  /** The artifact's stable identifier, used for keying / future cross-message reuse. */
35
42
  artifactId: string;
36
43
  /** Inlined artifact metadata — clients fetch the underlying data via `artifact.protectedAsset.presignedUrl`. */
37
- artifact: ArtifactRecord;
44
+ artifact: TArtifact;
45
+ /**
46
+ * Optional consumer-supplied labels for the rendered artifact's action buttons + status
47
+ * messages — a flat slice narrowed by `artifact.type`. NOT a wire field; the consumer
48
+ * constructs this from their i18n layer when materialising the block-record from the
49
+ * server payload, then passes the augmented block to `<Block>`. The dispatcher forwards
50
+ * the slice directly to the matching renderer — no per-type key wrapping (the block
51
+ * already carries the discriminator).
52
+ *
53
+ * TS catches cross-type assignments here: `block.payload.labels = { downloadCsv: 'X' }`
54
+ * on a `TableArtifactRecord`-typed block is a type error because `downloadCsv` isn't a
55
+ * `TableArtifactLabels` key.
56
+ */
57
+ labels?: Partial<ArtifactLabelsOf<TArtifact>>;
58
+ /**
59
+ * Optional side-effect callbacks for actions on the rendered artifact (e.g. `onDownload`).
60
+ * Flat slice narrowed by `artifact.type` via `ArtifactCallbacksOf<T>`. NOT a wire field
61
+ * — the consumer wires this once to bridge artifact actions to their analytics /
62
+ * observability layer.
63
+ */
64
+ callbacks?: Partial<ArtifactCallbacksOf<TArtifact>>;
38
65
  };
39
- }
66
+ } : never : never;
40
67
  /** Discriminated union of all supported content blocks. Additive — new types extend this union. */
41
68
  type BlockRecord = TextBlockRecord | ArtifactRefBlockRecord;
42
69
  /** Props every concrete block component receives from the dispatcher. */
@@ -1,5 +1,5 @@
1
1
  import { ComponentType } from 'react';
2
- import { A as ArtifactRecord } from './types-3Gzk7cRt.js';
2
+ import { c as ArtifactRecord, b as ArtifactLabelsOf, A as ArtifactCallbacksOf } from './types-GCkXbyFm.js';
3
3
 
4
4
  /** Block-type discriminator constants. Mirrors the wire shape from io-server / shapes-agent. */
5
5
  declare const blockTypes: {
@@ -25,8 +25,15 @@ interface TextBlockRecord {
25
25
  * `@/components/artifacts/types` so the artifact layer can be consumed independently of the
26
26
  * block layer (e.g. by a future surface that renders an artifact outside chat). The block layer
27
27
  * imports them here to wrap an artifact in an `ARTIFACT_REF` block.
28
+ *
29
+ * `ArtifactRefBlockRecord` is a *distributed* union over `ArtifactRecord` branches — TS narrows
30
+ * `labels` and `callbacks` to the slice matching `artifact.type` via `ArtifactLabelsOf<T>` /
31
+ * `ArtifactCallbacksOf<T>`. Without this distribution, `Partial<ChartLabels | TableLabels>`
32
+ * collapses to `Partial<ChartLabels> | Partial<TableLabels>` and TS accepts chart-only keys on
33
+ * a TABLE block's payload (the discriminator becomes load-bearing only at runtime, not in the
34
+ * type system).
28
35
  */
29
- interface ArtifactRefBlockRecord {
36
+ type ArtifactRefBlockRecord = ArtifactRecord extends infer TArtifact ? TArtifact extends ArtifactRecord ? {
30
37
  /** Block-type discriminator. */
31
38
  type: typeof blockTypes.ARTIFACT_REF;
32
39
  /** Type-specific data; kept as `payload` to match the wire shape 1:1. */
@@ -34,9 +41,29 @@ interface ArtifactRefBlockRecord {
34
41
  /** The artifact's stable identifier, used for keying / future cross-message reuse. */
35
42
  artifactId: string;
36
43
  /** Inlined artifact metadata — clients fetch the underlying data via `artifact.protectedAsset.presignedUrl`. */
37
- artifact: ArtifactRecord;
44
+ artifact: TArtifact;
45
+ /**
46
+ * Optional consumer-supplied labels for the rendered artifact's action buttons + status
47
+ * messages — a flat slice narrowed by `artifact.type`. NOT a wire field; the consumer
48
+ * constructs this from their i18n layer when materialising the block-record from the
49
+ * server payload, then passes the augmented block to `<Block>`. The dispatcher forwards
50
+ * the slice directly to the matching renderer — no per-type key wrapping (the block
51
+ * already carries the discriminator).
52
+ *
53
+ * TS catches cross-type assignments here: `block.payload.labels = { downloadCsv: 'X' }`
54
+ * on a `TableArtifactRecord`-typed block is a type error because `downloadCsv` isn't a
55
+ * `TableArtifactLabels` key.
56
+ */
57
+ labels?: Partial<ArtifactLabelsOf<TArtifact>>;
58
+ /**
59
+ * Optional side-effect callbacks for actions on the rendered artifact (e.g. `onDownload`).
60
+ * Flat slice narrowed by `artifact.type` via `ArtifactCallbacksOf<T>`. NOT a wire field
61
+ * — the consumer wires this once to bridge artifact actions to their analytics /
62
+ * observability layer.
63
+ */
64
+ callbacks?: Partial<ArtifactCallbacksOf<TArtifact>>;
38
65
  };
39
- }
66
+ } : never : never;
40
67
  /** Discriminated union of all supported content blocks. Additive — new types extend this union. */
41
68
  type BlockRecord = TextBlockRecord | ArtifactRefBlockRecord;
42
69
  /** Props every concrete block component receives from the dispatcher. */