@shapesos/clay 0.11.0 → 0.12.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 (56) hide show
  1. package/README.md +60 -0
  2. package/dist/artifacts.cjs +858 -132
  3. package/dist/artifacts.cjs.map +1 -1
  4. package/dist/artifacts.d.cts +38 -5
  5. package/dist/artifacts.d.ts +38 -5
  6. package/dist/artifacts.js +13 -3
  7. package/dist/blocks.cjs +1185 -467
  8. package/dist/blocks.cjs.map +1 -1
  9. package/dist/blocks.css +1 -1
  10. package/dist/blocks.d.cts +23 -10
  11. package/dist/blocks.d.ts +23 -10
  12. package/dist/blocks.js +6 -3
  13. package/dist/chart.cjs +594 -0
  14. package/dist/chart.cjs.map +1 -0
  15. package/dist/chart.d.cts +439 -0
  16. package/dist/chart.d.ts +439 -0
  17. package/dist/chart.js +32 -0
  18. package/dist/chat.cjs +1207 -489
  19. package/dist/chat.cjs.map +1 -1
  20. package/dist/chat.d.cts +3 -2
  21. package/dist/chat.d.ts +3 -2
  22. package/dist/chat.js +7 -4
  23. package/dist/{chunk-MXOPG747.js → chunk-36CB624W.js} +7 -7
  24. package/dist/chunk-36CB624W.js.map +1 -0
  25. package/dist/{chunk-L35M3OD5.js → chunk-4MZZH3WX.js} +5 -11
  26. package/dist/chunk-4MZZH3WX.js.map +1 -0
  27. package/dist/chunk-AQEJRMRN.js +1 -0
  28. package/dist/chunk-AQEJRMRN.js.map +1 -0
  29. package/dist/{chunk-OUW6PUEB.js → chunk-FFX3CAOX.js} +7 -7
  30. package/dist/chunk-P6GUNIAE.js +11 -0
  31. package/dist/chunk-P6GUNIAE.js.map +1 -0
  32. package/dist/chunk-QXGYMDIA.js +477 -0
  33. package/dist/chunk-QXGYMDIA.js.map +1 -0
  34. package/dist/{chunk-BX5TCEPR.js → chunk-Z5JWF24N.js} +388 -105
  35. package/dist/chunk-Z5JWF24N.js.map +1 -0
  36. package/dist/index.cjs +924 -198
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +4 -3
  39. package/dist/index.d.ts +4 -3
  40. package/dist/index.js +23 -15
  41. package/dist/table.js +2 -1
  42. package/dist/types-B2aYk82c.d.cts +29 -0
  43. package/dist/types-B2aYk82c.d.ts +29 -0
  44. package/dist/types-C0BvwliI.d.cts +332 -0
  45. package/dist/types-C5bFH4v3.d.ts +332 -0
  46. package/dist/{types-DuuRI4ll.d.cts → types-DCutaXjZ.d.cts} +16 -1
  47. package/dist/{types-C9XX-Uhk.d.ts → types-uPfn67Dc.d.ts} +16 -1
  48. package/package.json +13 -1
  49. package/dist/chunk-BX5TCEPR.js.map +0 -1
  50. package/dist/chunk-L35M3OD5.js.map +0 -1
  51. package/dist/chunk-MEJESPTZ.js +0 -1
  52. package/dist/chunk-MXOPG747.js.map +0 -1
  53. package/dist/types-3Gzk7cRt.d.cts +0 -121
  54. package/dist/types-3Gzk7cRt.d.ts +0 -121
  55. /package/dist/{chunk-MEJESPTZ.js.map → chart.js.map} +0 -0
  56. /package/dist/{chunk-OUW6PUEB.js.map → chunk-FFX3CAOX.js.map} +0 -0
@@ -1,121 +0,0 @@
1
- import { ComponentType } from 'react';
2
-
3
- /**
4
- * Artifact-domain types — wire-protocol shapes shared between artifact components, block-services, and
5
- * consumers. The block layer (`@/components/blocks`) imports these to define
6
- * `ArtifactRefBlockRecord`; the artifact components consume them directly.
7
- *
8
- * Mirrored from the agent / io-server contract — see the `chat-typed-content-blocks-and-artifacts`
9
- * plan, §6.4 (table contract).
10
- */
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
- };
19
- /** Discriminator for artifact types. Additive — new types extend this union. */
20
- type ArtifactType = (typeof artifactTypes)[keyof typeof artifactTypes];
21
- /**
22
- * A single column descriptor for a `TableArtifact`. Carries the ORDER and LABEL for the
23
- * rendered table — `key` selects a column from the CSV header; `label` overrides the rendered
24
- * header text. The CSV is always the source of truth for the data shape; clay never coerces,
25
- * reformats, or interprets cell values.
26
- */
27
- interface TableColumn {
28
- /** Matches a header in the CSV. Required. Used to project + order the CSV's columns. */
29
- key: string;
30
- /** Human-readable header text. Required. */
31
- label: string;
32
- /**
33
- * Accepted in the wire payload but not consulted by the renderer — every cell is rendered as
34
- * the raw CSV string (or empty for null). Format conversion is a server concern; if a column
35
- * needs to be "Yes/No" instead of "true/false", the server should emit it that way in the CSV.
36
- * Kept in the interface so callers that pass `type` (e.g. io-client) don't get a type error.
37
- */
38
- type?: "string" | "number" | "date" | "boolean";
39
- /**
40
- * Accepted in the wire payload but not consulted by the renderer — every column is left-aligned
41
- * by design. Kept in the interface for forward-compat; restore per-column alignment by editing
42
- * `table-artifact-content.tsx` if a future use case justifies it.
43
- */
44
- align?: "left" | "center" | "right";
45
- }
46
- /**
47
- * Optional stats embedded in `TableConfig` so clients can pre-render UI before fetching the
48
- * actual data payload (e.g. N loading shimmers sized to the eventual row count).
49
- *
50
- * Backward-compat: optional everywhere — older artifacts persisted before this field shipped
51
- * still validate. The renderer falls back to a single status-message line when `stats` is absent.
52
- */
53
- interface TableStats {
54
- /** Total number of rows in the materialised CSV. Lets the loading branch render shimmers. */
55
- rowCount: number;
56
- }
57
- /** Rendering config for a table artifact, stored at `artifact.config` (JSONB on the server). */
58
- interface TableConfig {
59
- /** Column descriptors in render order. */
60
- columns: TableColumn[];
61
- /** Optional metadata describing the underlying data — used for loading-state UI. */
62
- stats?: TableStats;
63
- }
64
- /**
65
- * A row inside a table artifact's parsed CSV. Every cell is the raw string from the CSV (or
66
- * `null` for the empty string). The renderer never coerces or interprets — type-aware formatting
67
- * is a server concern (the CSV's contents are what the user sees).
68
- */
69
- type TableRow = Record<string, string | null>;
70
- /** Common shape every artifact record carries. Discriminated by `type`. */
71
- interface ArtifactBase<TType extends ArtifactType, TConfig> {
72
- /** Artifact-type discriminator. */
73
- type: TType;
74
- /** Human-readable label. Nullable when the artifact has no title. */
75
- title: string | null;
76
- /** Rendering config — shape varies per artifact type. */
77
- config: TConfig;
78
- /** Protected-asset metadata pointing to the underlying data payload. Null while the asset is unavailable. */
79
- protectedAsset: {
80
- /** Time-limited URL the renderer fetches the artifact's data from. */
81
- presignedUrl: string;
82
- } | null;
83
- }
84
- /** Concrete table artifact record. Future artifact types extend `ArtifactRecord` here. */
85
- type TableArtifactRecord = ArtifactBase<typeof artifactTypes.TABLE, TableConfig>;
86
- /**
87
- * Discriminated union of all supported artifacts. Single-member today; extension pattern:
88
- *
89
- * export type ArtifactRecord = TableArtifactRecord | ChartArtifactRecord;
90
- *
91
- * Every consumer that narrows on `artifact.type` must add the new branch here AND in the
92
- * `ArtifactServices` map (single source of truth for the type→component mapping). Older clay
93
- * versions that don't know about a new type silently render nothing — see `ArtifactRefBlock` guard.
94
- */
95
- type ArtifactRecord = TableArtifactRecord;
96
- /** Props every concrete artifact component receives from the dispatcher. */
97
- interface ArtifactServiceProps<TArtifact extends ArtifactRecord = ArtifactRecord> {
98
- /** The artifact metadata (config + presigned URL). */
99
- artifact: TArtifact;
100
- }
101
- /** Per-artifact-type service — registry entry that pairs a discriminator with its concrete component. */
102
- interface ArtifactService<TArtifact extends ArtifactRecord = ArtifactRecord> {
103
- /** Discriminator value this service handles. */
104
- type: ArtifactType;
105
- /** React component that renders an artifact of this type — composes ai-elements primitives
106
- * (`Artifact`, `ArtifactHeader`, `ArtifactTitle`, `ArtifactActions`, `ArtifactContent`) directly. */
107
- Component: ComponentType<ArtifactServiceProps<TArtifact>>;
108
- /**
109
- * Returns a plain-text / markdown string suitable for clipboard copy.
110
- *
111
- * Called by `ArtifactRefBlockService.toClipboardText` when the user copies a message that
112
- * contains this artifact. Must be pure and synchronous.
113
- *
114
- * Implementation notes per type:
115
- * - `table`: returns the artifact title as plain text (see `TableArtifactService`).
116
- * - Future types implement their own representation in a co-located `*-service.ts` file.
117
- */
118
- toClipboardText: (artifact: TArtifact) => string;
119
- }
120
-
121
- export { type ArtifactRecord as A, type TableArtifactRecord as T, type ArtifactService as a, type ArtifactServiceProps as b, type ArtifactType as c, type TableColumn as d, type TableConfig as e, type TableRow as f, type TableStats as g, artifactTypes as h };
@@ -1,121 +0,0 @@
1
- import { ComponentType } from 'react';
2
-
3
- /**
4
- * Artifact-domain types — wire-protocol shapes shared between artifact components, block-services, and
5
- * consumers. The block layer (`@/components/blocks`) imports these to define
6
- * `ArtifactRefBlockRecord`; the artifact components consume them directly.
7
- *
8
- * Mirrored from the agent / io-server contract — see the `chat-typed-content-blocks-and-artifacts`
9
- * plan, §6.4 (table contract).
10
- */
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
- };
19
- /** Discriminator for artifact types. Additive — new types extend this union. */
20
- type ArtifactType = (typeof artifactTypes)[keyof typeof artifactTypes];
21
- /**
22
- * A single column descriptor for a `TableArtifact`. Carries the ORDER and LABEL for the
23
- * rendered table — `key` selects a column from the CSV header; `label` overrides the rendered
24
- * header text. The CSV is always the source of truth for the data shape; clay never coerces,
25
- * reformats, or interprets cell values.
26
- */
27
- interface TableColumn {
28
- /** Matches a header in the CSV. Required. Used to project + order the CSV's columns. */
29
- key: string;
30
- /** Human-readable header text. Required. */
31
- label: string;
32
- /**
33
- * Accepted in the wire payload but not consulted by the renderer — every cell is rendered as
34
- * the raw CSV string (or empty for null). Format conversion is a server concern; if a column
35
- * needs to be "Yes/No" instead of "true/false", the server should emit it that way in the CSV.
36
- * Kept in the interface so callers that pass `type` (e.g. io-client) don't get a type error.
37
- */
38
- type?: "string" | "number" | "date" | "boolean";
39
- /**
40
- * Accepted in the wire payload but not consulted by the renderer — every column is left-aligned
41
- * by design. Kept in the interface for forward-compat; restore per-column alignment by editing
42
- * `table-artifact-content.tsx` if a future use case justifies it.
43
- */
44
- align?: "left" | "center" | "right";
45
- }
46
- /**
47
- * Optional stats embedded in `TableConfig` so clients can pre-render UI before fetching the
48
- * actual data payload (e.g. N loading shimmers sized to the eventual row count).
49
- *
50
- * Backward-compat: optional everywhere — older artifacts persisted before this field shipped
51
- * still validate. The renderer falls back to a single status-message line when `stats` is absent.
52
- */
53
- interface TableStats {
54
- /** Total number of rows in the materialised CSV. Lets the loading branch render shimmers. */
55
- rowCount: number;
56
- }
57
- /** Rendering config for a table artifact, stored at `artifact.config` (JSONB on the server). */
58
- interface TableConfig {
59
- /** Column descriptors in render order. */
60
- columns: TableColumn[];
61
- /** Optional metadata describing the underlying data — used for loading-state UI. */
62
- stats?: TableStats;
63
- }
64
- /**
65
- * A row inside a table artifact's parsed CSV. Every cell is the raw string from the CSV (or
66
- * `null` for the empty string). The renderer never coerces or interprets — type-aware formatting
67
- * is a server concern (the CSV's contents are what the user sees).
68
- */
69
- type TableRow = Record<string, string | null>;
70
- /** Common shape every artifact record carries. Discriminated by `type`. */
71
- interface ArtifactBase<TType extends ArtifactType, TConfig> {
72
- /** Artifact-type discriminator. */
73
- type: TType;
74
- /** Human-readable label. Nullable when the artifact has no title. */
75
- title: string | null;
76
- /** Rendering config — shape varies per artifact type. */
77
- config: TConfig;
78
- /** Protected-asset metadata pointing to the underlying data payload. Null while the asset is unavailable. */
79
- protectedAsset: {
80
- /** Time-limited URL the renderer fetches the artifact's data from. */
81
- presignedUrl: string;
82
- } | null;
83
- }
84
- /** Concrete table artifact record. Future artifact types extend `ArtifactRecord` here. */
85
- type TableArtifactRecord = ArtifactBase<typeof artifactTypes.TABLE, TableConfig>;
86
- /**
87
- * Discriminated union of all supported artifacts. Single-member today; extension pattern:
88
- *
89
- * export type ArtifactRecord = TableArtifactRecord | ChartArtifactRecord;
90
- *
91
- * Every consumer that narrows on `artifact.type` must add the new branch here AND in the
92
- * `ArtifactServices` map (single source of truth for the type→component mapping). Older clay
93
- * versions that don't know about a new type silently render nothing — see `ArtifactRefBlock` guard.
94
- */
95
- type ArtifactRecord = TableArtifactRecord;
96
- /** Props every concrete artifact component receives from the dispatcher. */
97
- interface ArtifactServiceProps<TArtifact extends ArtifactRecord = ArtifactRecord> {
98
- /** The artifact metadata (config + presigned URL). */
99
- artifact: TArtifact;
100
- }
101
- /** Per-artifact-type service — registry entry that pairs a discriminator with its concrete component. */
102
- interface ArtifactService<TArtifact extends ArtifactRecord = ArtifactRecord> {
103
- /** Discriminator value this service handles. */
104
- type: ArtifactType;
105
- /** React component that renders an artifact of this type — composes ai-elements primitives
106
- * (`Artifact`, `ArtifactHeader`, `ArtifactTitle`, `ArtifactActions`, `ArtifactContent`) directly. */
107
- Component: ComponentType<ArtifactServiceProps<TArtifact>>;
108
- /**
109
- * Returns a plain-text / markdown string suitable for clipboard copy.
110
- *
111
- * Called by `ArtifactRefBlockService.toClipboardText` when the user copies a message that
112
- * contains this artifact. Must be pure and synchronous.
113
- *
114
- * Implementation notes per type:
115
- * - `table`: returns the artifact title as plain text (see `TableArtifactService`).
116
- * - Future types implement their own representation in a co-located `*-service.ts` file.
117
- */
118
- toClipboardText: (artifact: TArtifact) => string;
119
- }
120
-
121
- export { type ArtifactRecord as A, type TableArtifactRecord as T, type ArtifactService as a, type ArtifactServiceProps as b, type ArtifactType as c, type TableColumn as d, type TableConfig as e, type TableRow as f, type TableStats as g, artifactTypes as h };
File without changes