@darqlabs/curator-sdk-react 0.3.3 → 0.4.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.
- package/dist/cjs/CuratorAdapter.d.ts +8 -1
- package/dist/cjs/CuratorAdapter.d.ts.map +1 -1
- package/dist/cjs/CuratorAdapter.js +38 -5
- package/dist/cjs/CuratorAdapter.js.map +1 -1
- package/dist/cjs/CuratorAttachmentAdapter.d.ts +87 -0
- package/dist/cjs/CuratorAttachmentAdapter.d.ts.map +1 -0
- package/dist/cjs/CuratorAttachmentAdapter.js +132 -0
- package/dist/cjs/CuratorAttachmentAdapter.js.map +1 -0
- package/dist/cjs/CuratorChat.d.ts +38 -0
- package/dist/cjs/CuratorChat.d.ts.map +1 -1
- package/dist/cjs/CuratorChat.js +239 -39
- package/dist/cjs/CuratorChat.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/useCuratorChat.d.ts +21 -2
- package/dist/cjs/useCuratorChat.d.ts.map +1 -1
- package/dist/cjs/useCuratorChat.js +19 -4
- package/dist/cjs/useCuratorChat.js.map +1 -1
- package/dist/esm/CuratorAdapter.d.ts +8 -1
- package/dist/esm/CuratorAdapter.d.ts.map +1 -1
- package/dist/esm/CuratorAdapter.js +38 -5
- package/dist/esm/CuratorAdapter.js.map +1 -1
- package/dist/esm/CuratorAttachmentAdapter.d.ts +87 -0
- package/dist/esm/CuratorAttachmentAdapter.d.ts.map +1 -0
- package/dist/esm/CuratorAttachmentAdapter.js +128 -0
- package/dist/esm/CuratorAttachmentAdapter.js.map +1 -0
- package/dist/esm/CuratorChat.d.ts +38 -0
- package/dist/esm/CuratorChat.d.ts.map +1 -1
- package/dist/esm/CuratorChat.js +239 -39
- package/dist/esm/CuratorChat.js.map +1 -1
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/useCuratorChat.d.ts +21 -2
- package/dist/esm/useCuratorChat.d.ts.map +1 -1
- package/dist/esm/useCuratorChat.js +19 -4
- package/dist/esm/useCuratorChat.js.map +1 -1
- package/package.json +3 -3
|
@@ -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
|
|
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,OA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,EAAE,YAAY,GAAG,KAAK,KAAK,IAAI,CAAA;CAChD;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,EACV,SAAS,GAAE,uBAA4B;AACvC;;;;GAIG;AACH,WAAW,CAAC,EAAE,IAAI,CAAC,wBAAwB,EAAE,gBAAgB,CAAC,GAC7D,gBAAgB,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
|
-
|
|
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
|
-
|
|
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
|
|
165
|
-
* `
|
|
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;;
|
|
1
|
+
{"version":3,"file":"CuratorAdapter.js","sourceRoot":"","sources":["../../src/CuratorAdapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;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AAC,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.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEpE,gFAAgF;AAChF,UAAU,qBAAqB;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EACF;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,MAAM,EAAE,WAAW,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAC1D;QAAE,IAAI,EAAE,iBAAiB,CAAC;QAAC,MAAM,EAAE,eAAe,CAAA;KAAE,GACpD;QAAE,IAAI,EAAE,YAAY,CAAC;QAAC,MAAM,EAAE,OAAO,GAAG,eAAe,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE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|
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":"Cu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AAU,CAAC,EAAE;YACjB,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,WAAW,EAAE,UAAU,CAAC,WAAW;YACnC,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;YAC5B,sEAAsE;YACtE,mEAAmE;YACnE,yEAAyE;YACzE,gEAAgE;YAChE,OAAO,EAAE,EAAE;SACZ,CAAA;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"}
|
|
@@ -98,8 +98,46 @@ export interface CuratorChatProps {
|
|
|
98
98
|
* immediately after a reply completes.
|
|
99
99
|
*/
|
|
100
100
|
queueWhileRunning?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Allow files to be attached to a message.
|
|
103
|
+
*
|
|
104
|
+
* Off by default. Turning an upload affordance on for every existing embed
|
|
105
|
+
* without the operator choosing it changes what their end users can push
|
|
106
|
+
* into their storage, so this is opt-in even though the capability now
|
|
107
|
+
* exists.
|
|
108
|
+
*/
|
|
109
|
+
enableAttachments?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Design tokens — colours, typography, spacing, radii — merged over the
|
|
112
|
+
* palette `theme` selects.
|
|
113
|
+
*
|
|
114
|
+
* The escape hatch below it is plain CSS: every token is a custom property
|
|
115
|
+
* on `[data-curator-chat]`, so anything not named here is still reachable
|
|
116
|
+
* from a stylesheet.
|
|
117
|
+
*
|
|
118
|
+
* <CuratorChat theme="light" tokens={{ fontFamily: "Inter, sans-serif", accent: "#6b46ff", radius: 8 }} />
|
|
119
|
+
*/
|
|
120
|
+
tokens?: CuratorTokens;
|
|
121
|
+
/** `accept` for the file picker, e.g. `.pdf,image/*`. Default: everything. */
|
|
122
|
+
acceptedFileTypes?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Reject files larger than this (bytes) before uploading. A convenience for
|
|
125
|
+
* the person picking, not a control — the server enforces its own limit.
|
|
126
|
+
*/
|
|
127
|
+
maxFileSize?: number;
|
|
101
128
|
}
|
|
102
129
|
export declare function CuratorChat(props: CuratorChatProps): import("react").JSX.Element;
|
|
103
130
|
declare function AssistantMessage(): import("react").JSX.Element;
|
|
131
|
+
/**
|
|
132
|
+
* Consumer-facing token names, mapped to the variables they set.
|
|
133
|
+
*
|
|
134
|
+
* A curated subset rather than every variable: this is the surface someone
|
|
135
|
+
* reaches for first, and a prop that mirrors forty internals is a worse
|
|
136
|
+
* document than one that names the dozen things people actually change.
|
|
137
|
+
* Anything outside it is still reachable as raw CSS.
|
|
138
|
+
*/
|
|
139
|
+
declare const TOKEN_VARS: Record<string, string>;
|
|
140
|
+
/** Token values a consumer may set. Numbers are treated as pixels. */
|
|
141
|
+
export type CuratorTokens = Partial<Record<keyof typeof TOKEN_VARS, string | number>>;
|
|
104
142
|
export {};
|
|
105
143
|
//# sourceMappingURL=CuratorChat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CuratorChat.d.ts","sourceRoot":"","sources":["../../src/CuratorChat.tsx"],"names":[],"mappings":"AAAA;;;;;;;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