@darqlabs/curator-sdk-react 0.3.4 → 0.4.1

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.
@@ -17,6 +17,7 @@
17
17
  * mounted CuratorChat / launcher panel) so multi-turn context stays
18
18
  * intact across runs.
19
19
  */
20
+ import type { CuratorAttachmentAdapter } from "./CuratorAttachmentAdapter.js";
20
21
  import type { ChatModelAdapter } from "@assistant-ui/react";
21
22
  import type { AssistantMessage, Chat, CuratorError, StreamState, StreamPlanProgress } from "@darqlabs/curator-sdk";
22
23
  export interface CuratorAdapterCallbacks {
@@ -39,5 +40,11 @@ export interface CuratorAdapterCallbacks {
39
40
  /** Fired on any send-time error surfaced through the stream. */
40
41
  onError?: (error: CuratorError | Error) => void;
41
42
  }
42
- export declare function createCuratorAdapter(chat: Chat, callbacks?: CuratorAdapterCallbacks): ChatModelAdapter;
43
+ export declare function createCuratorAdapter(chat: Chat, callbacks?: CuratorAdapterCallbacks,
44
+ /**
45
+ * Supplies the storage references for this turn's attachments. Absent when
46
+ * the widget was mounted without attachment support, in which case the send
47
+ * behaves exactly as before.
48
+ */
49
+ attachments?: Pick<CuratorAttachmentAdapter, "takeReferences">): ChatModelAdapter;
43
50
  //# sourceMappingURL=CuratorAdapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CuratorAdapter.d.ts","sourceRoot":"","sources":["../../src/CuratorAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAsB,MAAM,qBAAqB,CAAA;AAC/E,OAAO,KAAK,EACV,gBAAgB,EAChB,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,kBAAkB,EACnB,MAAM,uBAAuB,CAAA;AAE9B,MAAM,WAAW,uBAAuB;IACtC,8DAA8D;IAC9D,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAA;IAC/C;;;;;OA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BAAgB,CA6JlB"}
@@ -20,11 +20,24 @@
20
20
  */
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.createCuratorAdapter = createCuratorAdapter;
23
- function createCuratorAdapter(chat, callbacks = {}) {
23
+ function createCuratorAdapter(chat, callbacks = {},
24
+ /**
25
+ * Supplies the storage references for this turn's attachments. Absent when
26
+ * the widget was mounted without attachment support, in which case the send
27
+ * behaves exactly as before.
28
+ */
29
+ attachments) {
24
30
  return {
25
31
  async *run({ messages, abortSignal }) {
26
32
  const userText = extractLatestUserText(messages);
27
- if (!userText)
33
+ const files = attachments
34
+ ? attachments.takeReferences(latestUserAttachmentIds(messages))
35
+ : [];
36
+ // A file with no caption is a complete message — the SDK accepts content
37
+ // OR files, and a bill of lading dropped in with nothing typed is the
38
+ // single most common way this widget is used. Returning early on empty
39
+ // text would silently discard it.
40
+ if (!userText && files.length === 0)
28
41
  return;
29
42
  // Assistant text arrives in SEGMENTS, not as one growing string. A model
30
43
  // may narrate ("Let me look those up…") in the same LLM turn that it
@@ -48,7 +61,11 @@ function createCuratorAdapter(chat, callbacks = {}) {
48
61
  }));
49
62
  };
50
63
  try {
51
- for await (const event of chat.stream(userText)) {
64
+ // Called with one argument when there are no files: the options object
65
+ // is meaningless then, and passing an empty one changes the observable
66
+ // call shape for anything wrapping or asserting on `stream`.
67
+ const stream = files.length ? chat.stream(userText, { files }) : chat.stream(userText);
68
+ for await (const event of stream) {
52
69
  if (abortSignal.aborted)
53
70
  return;
54
71
  if (event.type === "delta") {
@@ -158,11 +175,27 @@ function createCuratorAdapter(chat, callbacks = {}) {
158
175
  },
159
176
  };
160
177
  }
178
+ /**
179
+ * Attachment ids on the latest user turn, in composer order.
180
+ *
181
+ * The ids are the join key back to `CuratorAttachmentAdapter`'s upload map —
182
+ * assistant-ui's attachment payload has nowhere to carry a storage key, so the
183
+ * reference is looked up rather than read off the message.
184
+ */
185
+ function latestUserAttachmentIds(messages) {
186
+ for (let i = messages.length - 1; i >= 0; i--) {
187
+ const m = messages[i];
188
+ if (m.role !== "user")
189
+ continue;
190
+ return (m.attachments ?? []).map((a) => a.id);
191
+ }
192
+ return [];
193
+ }
161
194
  /**
162
195
  * Pull the latest user-turn text out of assistant-ui's structured
163
196
  * message array. Text parts are concatenated with newlines; other
164
- * part types (image, file, etc.) are ignored for now — the SDK's
165
- * `chat.stream` accepts plain text content only.
197
+ * part types are not text and are handled separately: attachments travel as
198
+ * storage references via `latestUserAttachmentIds`, not as message content.
166
199
  */
167
200
  function extractLatestUserText(messages) {
168
201
  for (let i = messages.length - 1; i >= 0; i--) {
@@ -1 +1 @@
1
- {"version":3,"file":"CuratorAdapter.js","sourceRoot":"","sources":["../../src/CuratorAdapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;AAgCH,oDAqJC;AArJD,SAAgB,oBAAoB,CAClC,IAAU,EACV,YAAqC,EAAE;IAEvC,OAAO;QACL,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE;YAClC,MAAM,QAAQ,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAA;YAChD,IAAI,CAAC,QAAQ;gBAAE,OAAM;YAErB,yEAAyE;YACzE,qEAAqE;YACrE,0EAA0E;YAC1E,mDAAmD;YACnD,EAAE;YACF,qEAAqE;YACrE,wEAAwE;YACxE,uEAAuE;YACvE,oEAAoE;YACpE,yEAAyE;YACzE,MAAM,QAAQ,GAAa,EAAE,CAAA;YAC7B,IAAI,GAAG,GAAG,EAAE,CAAA;YACZ,wEAAwE;YACxE,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAE,EAAE;gBACrC,MAAM,KAAK,GAAG,CAAC,GAAG,QAAQ,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;gBACjE,0EAA0E;gBAC1E,OAAO,CAAC,KAAK,CAAC,MAAM,GAA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CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;QACrB,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM;YAAE,SAAQ;QAC/B,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO;aACnB,MAAM,CAAC,CAAC,CAAC,EAAuC,EAAE,CACjD,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAK,CAAuB,CAAC,IAAI,KAAK,MAAM,CAChF;aACA,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aAClB,IAAI,CAAC,IAAI,CAAC,CAAA;QACb,OAAO,IAAI,CAAC,IAAI,EAAE,CAAA;IACpB,CAAC;IACD,OAAO,EAAE,CAAA;AACX,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Bridges assistant-ui's composer attachments to Curator's file storage.
3
+ *
4
+ * assistant-ui owns the attachment lifecycle in the composer — a chip appears
5
+ * when a file is picked, shows progress, and can be removed before send. What
6
+ * it has no opinion about is where the bytes go. This adapter uploads them
7
+ * through `curator.files`, which returns the `FileAttachment` reference that
8
+ * `chat.send(content, { files })` needs.
9
+ *
10
+ * The reference cannot ride inside the attachment itself: assistant-ui models
11
+ * an attachment's payload as `ThreadUserMessagePart[]`, whose shapes (text,
12
+ * image, file-with-data) have nowhere to carry a storage key, and anything
13
+ * smuggled into a text part would land in the prompt. So the adapter keeps its
14
+ * own id → reference map and `CuratorAdapter` reads it back when assembling the
15
+ * send. Both are constructed together in `CuratorChat`, so they share an
16
+ * instance and the map's lifetime is the widget's.
17
+ */
18
+ import type { Curator, FileAttachment } from "@darqlabs/curator-sdk";
19
+ /** Mirrors assistant-ui's attachment shapes without importing its internals. */
20
+ interface PendingAttachmentLike {
21
+ id: string;
22
+ type: "image" | "document" | "file" | (string & {});
23
+ name: string;
24
+ contentType?: string;
25
+ file: File;
26
+ status: {
27
+ type: "running";
28
+ reason: "uploading";
29
+ progress: number;
30
+ } | {
31
+ type: "requires-action";
32
+ reason: "composer-send";
33
+ } | {
34
+ type: "incomplete";
35
+ reason: "error" | "upload-paused";
36
+ message?: string;
37
+ };
38
+ }
39
+ interface CompleteAttachmentLike {
40
+ id: string;
41
+ type: "image" | "document" | "file" | (string & {});
42
+ name: string;
43
+ contentType?: string;
44
+ file?: File;
45
+ status: {
46
+ type: "complete";
47
+ };
48
+ content: Array<{
49
+ type: "text";
50
+ text: string;
51
+ }>;
52
+ }
53
+ export interface CuratorAttachmentAdapterOptions {
54
+ /** `accept` string for the picker, e.g. `.pdf,image/*`. Defaults to everything. */
55
+ accept?: string;
56
+ /** Reject client-side before uploading. Bytes. The server enforces its own limit. */
57
+ maxFileSize?: number;
58
+ }
59
+ export declare class CuratorAttachmentAdapter {
60
+ private readonly curator;
61
+ private readonly options;
62
+ accept: string;
63
+ /**
64
+ * Uploaded references by attachment id.
65
+ *
66
+ * Populated on `send` (assistant-ui's term for "the composer is submitting
67
+ * this one"), read by `CuratorAdapter` when it builds the request. Entries
68
+ * are dropped when the attachment is removed or once consumed, so a long
69
+ * conversation does not accumulate references to files it already sent.
70
+ */
71
+ private readonly uploaded;
72
+ constructor(curator: Curator, options?: CuratorAttachmentAdapterOptions);
73
+ add({ file }: {
74
+ file: File;
75
+ }): Promise<PendingAttachmentLike>;
76
+ send(attachment: PendingAttachmentLike): Promise<CompleteAttachmentLike>;
77
+ remove(attachment: {
78
+ id: string;
79
+ }): Promise<void>;
80
+ /**
81
+ * References for the given attachment ids, in the order given, dropping ids
82
+ * with no upload recorded. Consumed entries are released.
83
+ */
84
+ takeReferences(ids: readonly string[]): FileAttachment[];
85
+ }
86
+ export {};
87
+ //# sourceMappingURL=CuratorAttachmentAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CuratorAttachmentAdapter.d.ts","sourceRoot":"","sources":["../../src/CuratorAttachmentAdapter.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AA;CACrB;AAuBD,qBAAa,wBAAwB;IAcjC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAdnB,MAAM,EAAE,MAAM,CAAA;IAErB;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoC;gBAG1C,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,+BAAoC;IAK1D,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgC7D,IAAI,CAAC,UAAU,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAuBxE,MAAM,CAAC,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMvD;;;OAGG;IACH,cAAc,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,EAAE;CAWzD"}
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ /**
3
+ * Bridges assistant-ui's composer attachments to Curator's file storage.
4
+ *
5
+ * assistant-ui owns the attachment lifecycle in the composer — a chip appears
6
+ * when a file is picked, shows progress, and can be removed before send. What
7
+ * it has no opinion about is where the bytes go. This adapter uploads them
8
+ * through `curator.files`, which returns the `FileAttachment` reference that
9
+ * `chat.send(content, { files })` needs.
10
+ *
11
+ * The reference cannot ride inside the attachment itself: assistant-ui models
12
+ * an attachment's payload as `ThreadUserMessagePart[]`, whose shapes (text,
13
+ * image, file-with-data) have nowhere to carry a storage key, and anything
14
+ * smuggled into a text part would land in the prompt. So the adapter keeps its
15
+ * own id → reference map and `CuratorAdapter` reads it back when assembling the
16
+ * send. Both are constructed together in `CuratorChat`, so they share an
17
+ * instance and the map's lifetime is the widget's.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.CuratorAttachmentAdapter = void 0;
21
+ /** Human-readable size for the rejection message; matches the chip's formatting. */
22
+ function formatBytes(bytes) {
23
+ if (bytes < 1024)
24
+ return `${bytes} B`;
25
+ if (bytes < 1024 * 1024)
26
+ return `${Math.round(bytes / 1024)} KB`;
27
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
28
+ }
29
+ /**
30
+ * `image` gets a distinct type so a future thumbnail renderer can pick images
31
+ * out without re-sniffing the MIME type. Everything else is a document.
32
+ */
33
+ function attachmentKind(file) {
34
+ return file.type.startsWith("image/") ? "image" : "document";
35
+ }
36
+ let counter = 0;
37
+ function attachmentId() {
38
+ counter += 1;
39
+ return `curator_att_${Date.now().toString(36)}_${counter}`;
40
+ }
41
+ class CuratorAttachmentAdapter {
42
+ curator;
43
+ options;
44
+ accept;
45
+ /**
46
+ * Uploaded references by attachment id.
47
+ *
48
+ * Populated on `send` (assistant-ui's term for "the composer is submitting
49
+ * this one"), read by `CuratorAdapter` when it builds the request. Entries
50
+ * are dropped when the attachment is removed or once consumed, so a long
51
+ * conversation does not accumulate references to files it already sent.
52
+ */
53
+ uploaded = new Map();
54
+ constructor(curator, options = {}) {
55
+ this.curator = curator;
56
+ this.options = options;
57
+ this.accept = options.accept ?? "*/*";
58
+ }
59
+ async add({ file }) {
60
+ const max = this.options.maxFileSize;
61
+ if (max && file.size > max) {
62
+ // Surfaced on the chip rather than thrown: one oversized file should not
63
+ // discard the other attachments or the typed message.
64
+ return {
65
+ id: attachmentId(),
66
+ type: attachmentKind(file),
67
+ name: file.name,
68
+ contentType: file.type || undefined,
69
+ file,
70
+ status: {
71
+ type: "incomplete",
72
+ reason: "error",
73
+ message: `${file.name} is ${formatBytes(file.size)}; the limit is ${formatBytes(max)}.`,
74
+ },
75
+ };
76
+ }
77
+ // Upload happens in `send`, not here. Uploading on pick would spend the
78
+ // customer's storage on files the person then removes before sending, and
79
+ // an abandoned composer would leave orphans nothing ever references.
80
+ return {
81
+ id: attachmentId(),
82
+ type: attachmentKind(file),
83
+ name: file.name,
84
+ contentType: file.type || undefined,
85
+ file,
86
+ status: { type: "requires-action", reason: "composer-send" },
87
+ };
88
+ }
89
+ async send(attachment) {
90
+ const reference = await this.curator.files.upload({
91
+ filename: attachment.name,
92
+ mimeType: attachment.contentType || attachment.file.type || "application/octet-stream",
93
+ data: attachment.file,
94
+ });
95
+ this.uploaded.set(attachment.id, reference);
96
+ return {
97
+ id: attachment.id,
98
+ type: attachment.type,
99
+ name: attachment.name,
100
+ contentType: attachment.contentType,
101
+ file: attachment.file,
102
+ status: { type: "complete" },
103
+ // Deliberately empty. `content` becomes message parts, and the file's
104
+ // meaning reaches the model through the server-rendered attachment
105
+ // envelope — a duplicate here would put the filename in the prompt twice
106
+ // and, worse, make the widget's own text extraction pick it up.
107
+ content: [],
108
+ };
109
+ }
110
+ async remove(attachment) {
111
+ // Nothing to delete remotely: `send` is the only thing that uploads, so a
112
+ // removal before send never created an object.
113
+ this.uploaded.delete(attachment.id);
114
+ }
115
+ /**
116
+ * References for the given attachment ids, in the order given, dropping ids
117
+ * with no upload recorded. Consumed entries are released.
118
+ */
119
+ takeReferences(ids) {
120
+ const out = [];
121
+ for (const id of ids) {
122
+ const reference = this.uploaded.get(id);
123
+ if (reference) {
124
+ out.push(reference);
125
+ this.uploaded.delete(id);
126
+ }
127
+ }
128
+ return out;
129
+ }
130
+ }
131
+ exports.CuratorAttachmentAdapter = CuratorAttachmentAdapter;
132
+ //# sourceMappingURL=CuratorAttachmentAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CuratorAttachmentAdapter.js","sourceRoot":"","sources":["../../src/CuratorAttachmentAdapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAkCH,oFAAoF;AACpF,SAAS,WAAW,CAAC,KAAa;IAChC,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,IAAI,CAAA;IACrC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC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AA;IACH,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,UAA0B;QACrC,0EAA0E;QAC1E,+CAA+C;QAC/C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;IACrC,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,GAAsB;QACnC,MAAM,GAAG,GAAqB,EAAE,CAAA;QAChC,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;YACrB,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YACvC,IAAI,SAAS,EAAE,CAAC;gBACd,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;gBACnB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YAC1B,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;CACF;AAhGD,4DAgGC"}
@@ -11,6 +11,21 @@
11
11
  */
12
12
  import { type CSSProperties, type ReactNode } from "react";
13
13
  import type { AssistantMessage, Curator, CuratorError, Environment, StreamState, StreamPlanProgress } from "@darqlabs/curator-sdk";
14
+ /**
15
+ * A starter prompt offered in the empty thread.
16
+ *
17
+ * A bare string is both the button text and the message sent. The object form
18
+ * separates them, because the two want different lengths: a button reads best
19
+ * at three or four words, while the message that actually starts the
20
+ * conversation is usually a full sentence carrying the context the agent needs.
21
+ * Collapsing them forces a choice between a cramped button and a thin prompt.
22
+ */
23
+ export type CuratorPrompt = string | {
24
+ /** Button text. */
25
+ label: string;
26
+ /** Message sent on click. Defaults to `label`. */
27
+ prompt?: string;
28
+ };
14
29
  export interface CuratorChatProps {
15
30
  /** SDK instance. Optional when a `<CuratorProvider>` is mounted. */
16
31
  curator?: Curator;
@@ -26,6 +41,18 @@ export interface CuratorChatProps {
26
41
  conversationId?: string;
27
42
  /** Header title. Default: "Chat". */
28
43
  title?: string;
44
+ /**
45
+ * Render without the header.
46
+ *
47
+ * An embedded widget usually sits under a page that has already said what
48
+ * this is; the header then repeats it. CSS can hide it, but hiding a
49
+ * component's own chrome from outside is not a contract — a markup change
50
+ * here would silently un-hide it on someone's page. This is the contract.
51
+ *
52
+ * The close affordance goes with it, so a consumer passing `onClose` while
53
+ * hiding the header owns dismissal themselves.
54
+ */
55
+ hideHeader?: boolean;
29
56
  /** Input placeholder. Default: "Type a message…". */
30
57
  placeholder?: string;
31
58
  /** Shown above the empty message list as a system prompt. */
@@ -98,8 +125,61 @@ export interface CuratorChatProps {
98
125
  * immediately after a reply completes.
99
126
  */
100
127
  queueWhileRunning?: boolean;
128
+ /**
129
+ * Allow files to be attached to a message.
130
+ *
131
+ * Off by default. Turning an upload affordance on for every existing embed
132
+ * without the operator choosing it changes what their end users can push
133
+ * into their storage, so this is opt-in even though the capability now
134
+ * exists.
135
+ */
136
+ enableAttachments?: boolean;
137
+ /**
138
+ * Starter prompts shown in the empty thread. Clicking one sends it.
139
+ *
140
+ * The blank-thread problem is that a capable agent looks identical to an
141
+ * unconfigured one — nothing on screen says what it can do. These are the
142
+ * cheapest answer: they demonstrate scope and remove the cost of composing a
143
+ * first message.
144
+ *
145
+ * prompts={["Book a shipment", { label: "Track a load", prompt: "Where is my shipment LOG-4173?" }]}
146
+ *
147
+ * Shown only while the thread is empty; they are an entry point, not a menu.
148
+ */
149
+ prompts?: CuratorPrompt[];
150
+ /**
151
+ * Design tokens — colours, typography, spacing, radii — merged over the
152
+ * palette `theme` selects.
153
+ *
154
+ * The escape hatch below it is plain CSS: every token is a custom property
155
+ * on `[data-curator-chat]`, so anything not named here is still reachable
156
+ * from a stylesheet.
157
+ *
158
+ * <CuratorChat theme="light" tokens={{ fontFamily: "Inter, sans-serif", accent: "#6b46ff", radius: 8 }} />
159
+ */
160
+ tokens?: CuratorTokens;
161
+ /** `accept` for the file picker, e.g. `.pdf,image/*`. Default: everything. */
162
+ acceptedFileTypes?: string;
163
+ /**
164
+ * Reject files larger than this (bytes) before uploading. A convenience for
165
+ * the person picking, not a control — the server enforces its own limit.
166
+ */
167
+ maxFileSize?: number;
101
168
  }
102
169
  export declare function CuratorChat(props: CuratorChatProps): import("react").JSX.Element;
103
170
  declare function AssistantMessage(): import("react").JSX.Element;
171
+ /**
172
+ * Consumer-facing token names, mapped to the variables they set.
173
+ *
174
+ * Complete for the axes a consumer can be expected to want: the whole type
175
+ * scale, the whole spacing scale, every colour surface, and the radii. An
176
+ * earlier version exposed only `fontSize` and `radius`, which split each scale
177
+ * down the middle — half reachable by prop, half only by stylesheet. A partial
178
+ * scale is worse than none, because it lets someone change a base size and then
179
+ * discover the secondary sizes did not follow.
180
+ */
181
+ declare const TOKEN_VARS: Record<string, string>;
182
+ /** Token values a consumer may set. Numbers are treated as pixels. */
183
+ export type CuratorTokens = Partial<Record<keyof typeof TOKEN_VARS, string | number>>;
104
184
  export {};
105
185
  //# sourceMappingURL=CuratorChat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CuratorChat.d.ts","sourceRoot":"","sources":["../../src/CuratorChat.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAQL,KAAK,aAAa,EAElB,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAWd,OAAO,KAAK,EACV,gBAAgB,EAEhB,OAAO,EACP,YAAY,EACZ,WAAW,EACX,WAAW,EACX,kBAAkB,EACnB,MAAM,uBAAuB,CAAA;AAO9B,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,yEAAyE;IACzE,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB,qCAAqC;IACrC,KAAK,CAA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