@lostgradient/cinder 0.14.0 → 0.15.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/CHANGELOG.md +10 -0
- package/README.md +6 -6
- package/components.json +1 -1
- package/dist/components/chat/conversation-model.d.ts +1 -1
- package/dist/components/chat/index.d.ts +5 -3
- package/dist/components/chat/index.js +18 -4
- package/dist/index.js +13 -4
- package/dist/server/components/chat/index.js +13 -3
- package/dist/server/index.js +1 -1
- package/dist/server/{index.server-f2me5abn.js → index.server-czf35aba.js} +14 -3
- package/package.json +5 -6
- package/src/components/chat/chat.examples.json +6 -0
- package/src/components/chat/container/chat.svelte +1 -1
- package/src/components/chat/conversation-model.ts +11 -0
- package/src/components/chat/index.ts +25 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @lostgradient/cinder
|
|
2
2
|
|
|
3
|
+
## 0.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#757](https://github.com/stevekinney/cinder/pull/757) [`792a36d`](https://github.com/stevekinney/cinder/commit/792a36dcf267dcc3f5362f2716b5ab8060b34b5b) Thanks [@stevekinney](https://github.com/stevekinney)! - Improve Chat dependency ownership, streaming exports, and automatic component CSS imports.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#759](https://github.com/stevekinney/cinder/pull/759) [`278ed74`](https://github.com/stevekinney/cinder/commit/278ed74bc6125daa4be3fdfaaa41c78114c6d009) Thanks [@stevekinney](https://github.com/stevekinney)! - Fix Chat SSR hydration stability for empty conversations.
|
|
12
|
+
|
|
3
13
|
## 0.14.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -32,27 +32,25 @@ import '@lostgradient/cinder/styles';
|
|
|
32
32
|
import '@lostgradient/cinder/styles/guard';
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
`@lostgradient/cinder/styles` is the base stylesheet. Import it once at your app entry before any component
|
|
35
|
+
`@lostgradient/cinder/styles` is the base stylesheet. Import it once at your app entry before importing any cinder component. It declares cinder's cascade-layer order, design tokens, foundation rules, utilities, and shared internal chrome.
|
|
36
36
|
|
|
37
37
|
`@lostgradient/cinder/styles/guard` is development-only. It warns if the base stylesheet is missing or loaded too late.
|
|
38
38
|
|
|
39
|
-
Then import components
|
|
39
|
+
Then import the components you use. In browser/Svelte-aware builds, component entry points automatically include their co-located CSS; no matching `/styles` import is required:
|
|
40
40
|
|
|
41
41
|
```svelte
|
|
42
42
|
<script lang="ts">
|
|
43
43
|
import Button from '@lostgradient/cinder/button';
|
|
44
|
-
import '@lostgradient/cinder/button/styles';
|
|
45
44
|
</script>
|
|
46
45
|
|
|
47
46
|
<Button variant="primary" label="Save changes" />
|
|
48
47
|
```
|
|
49
48
|
|
|
50
|
-
|
|
49
|
+
The same applies to other components:
|
|
51
50
|
|
|
52
51
|
```svelte
|
|
53
52
|
<script lang="ts">
|
|
54
53
|
import Modal from '@lostgradient/cinder/modal';
|
|
55
|
-
import '@lostgradient/cinder/modal/styles';
|
|
56
54
|
</script>
|
|
57
55
|
|
|
58
56
|
<Modal open title="Edit project" />
|
|
@@ -64,7 +62,9 @@ You can also import the component module from TypeScript:
|
|
|
64
62
|
import Modal from '@lostgradient/cinder/modal';
|
|
65
63
|
```
|
|
66
64
|
|
|
67
|
-
Compound components include their leaf styles from the parent
|
|
65
|
+
Compound components include their leaf styles from the parent entry. For example, importing `@lostgradient/cinder/tabs` covers `Tabs`, `Tabs.List`, `Tabs.Trigger`, and `Tabs.Panel`.
|
|
66
|
+
|
|
67
|
+
The `/styles` subpaths remain published for explicit CSS composition and advanced bundler setups. Use `@lostgradient/cinder/styles/all` when you want one stylesheet with every component, or the base stylesheet plus specific `/styles` sidecars when you intentionally manage CSS imports yourself.
|
|
68
68
|
|
|
69
69
|
If you want one stylesheet with everything, use:
|
|
70
70
|
|
package/components.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
10
|
import type { ToMarkdownOptions as ConversationalistToMarkdownOptions } from 'conversationalist/markdown';
|
|
11
|
-
export type { AssistantMessage, ContainerUploadContent, ConversationEnvironment, ConversationHistory, ConversationStatus, ImageContent, JSONValue, Message, MessageInput, MessageRole, MultiModalContent, RedactedThinkingContent, ServerToolResultContent, ServerToolResultType, ServerToolUseContent, TextContent, ThinkingContent, TokenUsage, ToolAction, ToolCall, ToolError, ToolErrorCategory, ToolResult, WebSearchToolResultContent, } from 'conversationalist';
|
|
11
|
+
export type { AssistantMessage, ContainerUploadContent, Conversation, ConversationActionType, ConversationEnvironment, ConversationEvent, ConversationEventMap, ConversationEventType, ConversationHistory, ConversationHistoryDraft, ConversationNodeSnapshot, ConversationSnapshot, ConversationStatus, ImageContent, JSONValue, Message, MessageInput, MessageRole, MultiModalContent, RedactedThinkingContent, ServerToolResultContent, ServerToolResultType, ServerToolUseContent, TextContent, ThinkingContent, TokenUsage, ToolAction, ToolCall, ToolCallInput, ToolError, ToolErrorCategory, ToolInteraction, ToolResult, ToolResultInput, WebSearchToolResultContent, } from 'conversationalist';
|
|
12
12
|
export type { ToolCallPair } from 'conversationalist/utilities';
|
|
13
13
|
/** Base options shared by all transcript export operations. */
|
|
14
14
|
export type ExportOptions = Omit<ConversationalistToMarkdownOptions, 'includeMetadata'>;
|
|
@@ -5,19 +5,21 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @module
|
|
7
7
|
*/
|
|
8
|
+
import { CURRENT_SCHEMA_VERSION } from 'conversationalist/versioning';
|
|
8
9
|
import './chat.css';
|
|
9
10
|
import Chat from './chat.svelte';
|
|
10
11
|
export default Chat;
|
|
11
12
|
export type { ChatAnnounceLevel, ChatCapabilities, ChatProps, ReadReceipt, TypingParticipant, } from './chat.types.ts';
|
|
12
|
-
export { Chat };
|
|
13
|
+
export { Chat, CURRENT_SCHEMA_VERSION };
|
|
13
14
|
export type { ChatAdapter, ChatAdapterErrorEvent, ChatCommand, ChatPushHandlers, ChatReadReceiptEvent, } from './adapter';
|
|
14
15
|
export { appendAssistantMessage, appendMessages, appendUserMessage, createConversation, } from './builders.ts';
|
|
15
|
-
export
|
|
16
|
+
export { appendStreamingMessage, cancelStreamingMessage, finalizeStreamingMessage, updateStreamingMessage, } from 'conversationalist/streaming';
|
|
17
|
+
export type { AssistantMessage, ContainerUploadContent, Conversation, ConversationActionType, ConversationEnvironment, ConversationEvent, ConversationEventMap, ConversationEventType, ConversationHistory, ConversationHistoryDraft, ConversationNodeSnapshot, ConversationSnapshot, ConversationStatus, ExportOptions, ImageContent, JSONValue, Message, MessageInput, MessageRole, MultiModalContent, RedactedThinkingContent, ServerToolResultContent, ServerToolResultType, ServerToolUseContent, TextContent, ThinkingContent, TokenUsage, ToMarkdownOptions, ToolAction, ToolCall, ToolCallInput, ToolCallPair, ToolError, ToolErrorCategory, ToolInteraction, ToolResult, ToolResultInput, WebSearchToolResultContent, } from './conversation-model.ts';
|
|
16
18
|
export { formatMessageAsMarkdown, getMessageRoleLabel, getMessageText, messagesToMarkdown, type ChatExportOptions, type DeliveryStatus, } from './utilities';
|
|
17
19
|
export { ChatAttachmentPreview, ChatInput, deriveAttachmentKind, serializeChatAttachment, serializeChatAttachments, } from './input';
|
|
18
20
|
export type { AttachmentKind, ChatAttachment, SerializedChatAttachment } from './input';
|
|
19
21
|
export { ChatDateSeparator, ChatMessage, MessageAttachments, MessageContent, ToolCallGroup, } from './message';
|
|
20
|
-
export {
|
|
22
|
+
export { calculateScrollToBottom, calculateUnreadCount, DEFAULT_SCROLL_CONFIGURATION, extractTimestamp, findUnreadBoundaryIndex, isAtBottom, shouldShowJumpToLatest, } from './container';
|
|
21
23
|
export type { ChatScrollStateChangeEvent, ChatStopGeneratingEvent, ChatSubmitEvent, ChatUnreadIndicatorChangeEvent, ScrollConfiguration, ScrollState, } from './container';
|
|
22
24
|
export { ConversationExportActions } from './export';
|
|
23
25
|
export { ArtifactPanel, ArtifactViewer, ChatArtifactLayout } from './artifact';
|
|
@@ -2478,6 +2478,7 @@ function Portal($$anchor, $$props) {
|
|
|
2478
2478
|
var portal_default = Portal;
|
|
2479
2479
|
// src/components/chat/index.ts
|
|
2480
2480
|
import"@lostgradient/cinder/chat/styles";
|
|
2481
|
+
import { CURRENT_SCHEMA_VERSION } from "conversationalist/versioning";
|
|
2481
2482
|
|
|
2482
2483
|
// src/components/chat/chat.svelte
|
|
2483
2484
|
import"svelte/internal/disclose-version";
|
|
@@ -8124,7 +8125,7 @@ function Chat($$anchor, $$props) {
|
|
|
8124
8125
|
});
|
|
8125
8126
|
const messages = $65.derived(() => getMessages($$props.conversation));
|
|
8126
8127
|
const lastMessageId = $65.derived(() => $65.get(messages).at(-1)?.id);
|
|
8127
|
-
let previousAutoScrollMessageCount =
|
|
8128
|
+
let previousAutoScrollMessageCount = $65.state($65.proxy($65.get(messages).length));
|
|
8128
8129
|
const conversationId = $65.derived(() => $$props.conversation.id);
|
|
8129
8130
|
const showTypingIndicator = $65.derived(() => streaming() && !$65.get(streamingMessageId));
|
|
8130
8131
|
const allowAttachments = $65.derived(() => $$props.capabilities?.attachments ?? true);
|
|
@@ -8281,8 +8282,8 @@ function Chat($$anchor, $$props) {
|
|
|
8281
8282
|
if (!$65.get(viewport))
|
|
8282
8283
|
return;
|
|
8283
8284
|
const currentCount = $65.get(messages).length;
|
|
8284
|
-
const isTranscriptAppend = currentCount > previousAutoScrollMessageCount;
|
|
8285
|
-
previousAutoScrollMessageCount
|
|
8285
|
+
const isTranscriptAppend = currentCount > $65.get(previousAutoScrollMessageCount);
|
|
8286
|
+
$65.set(previousAutoScrollMessageCount, currentCount, true);
|
|
8286
8287
|
const currentScrollExtent = $65.get(isVirtualized) ? chatVirtualizer.scrollSize : $65.get(viewport).scrollHeight;
|
|
8287
8288
|
const atBottom2 = untrack3(() => scrollState.atBottom);
|
|
8288
8289
|
if (scrollState.isUserScrolling)
|
|
@@ -9818,6 +9819,14 @@ function resolveRoleHelperMetadata(metadataOrEnvironment, environment) {
|
|
|
9818
9819
|
return metadataOrEnvironment;
|
|
9819
9820
|
throw new Error("metadata must be a JSON-compatible object");
|
|
9820
9821
|
}
|
|
9822
|
+
|
|
9823
|
+
// src/components/chat/index.ts
|
|
9824
|
+
import {
|
|
9825
|
+
appendStreamingMessage,
|
|
9826
|
+
cancelStreamingMessage,
|
|
9827
|
+
finalizeStreamingMessage,
|
|
9828
|
+
updateStreamingMessage
|
|
9829
|
+
} from "conversationalist/streaming";
|
|
9821
9830
|
// src/components/chat/export/conversation-export-actions.svelte
|
|
9822
9831
|
import"svelte/internal/disclose-version";
|
|
9823
9832
|
import * as $73 from "svelte/internal/client";
|
|
@@ -11269,6 +11278,7 @@ function Chat_artifact_layout($$anchor, $$props) {
|
|
|
11269
11278
|
// src/components/chat/index.ts
|
|
11270
11279
|
var chat_default = Chat2;
|
|
11271
11280
|
export {
|
|
11281
|
+
updateStreamingMessage,
|
|
11272
11282
|
shouldShowJumpToLatest,
|
|
11273
11283
|
serializeChatAttachments,
|
|
11274
11284
|
serializeChatAttachment,
|
|
@@ -11278,13 +11288,16 @@ export {
|
|
|
11278
11288
|
getMessageRoleLabel,
|
|
11279
11289
|
formatMessageAsMarkdown,
|
|
11280
11290
|
findUnreadBoundaryIndex,
|
|
11291
|
+
finalizeStreamingMessage,
|
|
11281
11292
|
extractTimestamp,
|
|
11282
11293
|
deriveAttachmentKind,
|
|
11283
11294
|
chat_default as default,
|
|
11284
11295
|
createConversation,
|
|
11296
|
+
cancelStreamingMessage,
|
|
11285
11297
|
calculateUnreadCount,
|
|
11286
11298
|
calculateScrollToBottom,
|
|
11287
11299
|
appendUserMessage,
|
|
11300
|
+
appendStreamingMessage,
|
|
11288
11301
|
appendMessages,
|
|
11289
11302
|
appendAssistantMessage,
|
|
11290
11303
|
Tool_call_group as ToolCallGroup,
|
|
@@ -11298,8 +11311,9 @@ export {
|
|
|
11298
11311
|
Chat_attachment_preview as ChatAttachmentPreview,
|
|
11299
11312
|
Chat_artifact_layout as ChatArtifactLayout,
|
|
11300
11313
|
Chat2 as Chat,
|
|
11314
|
+
CURRENT_SCHEMA_VERSION,
|
|
11301
11315
|
Artifact_viewer as ArtifactViewer,
|
|
11302
11316
|
Artifact_panel as ArtifactPanel
|
|
11303
11317
|
};
|
|
11304
11318
|
|
|
11305
|
-
//# debugId=
|
|
11319
|
+
//# debugId=7AD7E565972D544664756E2164756E21
|
package/dist/index.js
CHANGED
|
@@ -15099,6 +15099,7 @@ $100.delegate(["click"]);
|
|
|
15099
15099
|
var carousel_default = Carousel;
|
|
15100
15100
|
// src/components/chat/index.ts
|
|
15101
15101
|
import"@lostgradient/cinder/chat/styles";
|
|
15102
|
+
import { CURRENT_SCHEMA_VERSION } from "conversationalist/versioning";
|
|
15102
15103
|
|
|
15103
15104
|
// src/components/chat/chat.svelte
|
|
15104
15105
|
import"svelte/internal/disclose-version";
|
|
@@ -19471,7 +19472,7 @@ function Chat($$anchor, $$props) {
|
|
|
19471
19472
|
});
|
|
19472
19473
|
const messages = $137.derived(() => getMessages($$props.conversation));
|
|
19473
19474
|
const lastMessageId = $137.derived(() => $137.get(messages).at(-1)?.id);
|
|
19474
|
-
let previousAutoScrollMessageCount =
|
|
19475
|
+
let previousAutoScrollMessageCount = $137.state($137.proxy($137.get(messages).length));
|
|
19475
19476
|
const conversationId = $137.derived(() => $$props.conversation.id);
|
|
19476
19477
|
const showTypingIndicator = $137.derived(() => streaming() && !$137.get(streamingMessageId));
|
|
19477
19478
|
const allowAttachments = $137.derived(() => $$props.capabilities?.attachments ?? true);
|
|
@@ -19628,8 +19629,8 @@ function Chat($$anchor, $$props) {
|
|
|
19628
19629
|
if (!$137.get(viewport))
|
|
19629
19630
|
return;
|
|
19630
19631
|
const currentCount = $137.get(messages).length;
|
|
19631
|
-
const isTranscriptAppend = currentCount > previousAutoScrollMessageCount;
|
|
19632
|
-
previousAutoScrollMessageCount
|
|
19632
|
+
const isTranscriptAppend = currentCount > $137.get(previousAutoScrollMessageCount);
|
|
19633
|
+
$137.set(previousAutoScrollMessageCount, currentCount, true);
|
|
19633
19634
|
const currentScrollExtent = $137.get(isVirtualized) ? chatVirtualizer.scrollSize : $137.get(viewport).scrollHeight;
|
|
19634
19635
|
const atBottom2 = untrack6(() => scrollState.atBottom);
|
|
19635
19636
|
if (scrollState.isUserScrolling)
|
|
@@ -21165,6 +21166,14 @@ function resolveRoleHelperMetadata(metadataOrEnvironment, environment) {
|
|
|
21165
21166
|
return metadataOrEnvironment;
|
|
21166
21167
|
throw new Error("metadata must be a JSON-compatible object");
|
|
21167
21168
|
}
|
|
21169
|
+
|
|
21170
|
+
// src/components/chat/index.ts
|
|
21171
|
+
import {
|
|
21172
|
+
appendStreamingMessage,
|
|
21173
|
+
cancelStreamingMessage,
|
|
21174
|
+
finalizeStreamingMessage,
|
|
21175
|
+
updateStreamingMessage
|
|
21176
|
+
} from "conversationalist/streaming";
|
|
21168
21177
|
// src/components/chat/export/conversation-export-actions.svelte
|
|
21169
21178
|
import"svelte/internal/disclose-version";
|
|
21170
21179
|
import * as $144 from "svelte/internal/client";
|
|
@@ -73366,4 +73375,4 @@ export {
|
|
|
73366
73375
|
AccessGateExport as AccessGate
|
|
73367
73376
|
};
|
|
73368
73377
|
|
|
73369
|
-
//# debugId=
|
|
73378
|
+
//# debugId=F140FF8A09D82E1E64756E2164756E21
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Artifact_panel,
|
|
3
3
|
Artifact_viewer,
|
|
4
|
+
CURRENT_SCHEMA_VERSION,
|
|
4
5
|
Chat,
|
|
5
6
|
Chat_artifact_layout,
|
|
6
7
|
Chat_attachment_preview,
|
|
@@ -13,19 +14,23 @@ import {
|
|
|
13
14
|
Tool_call_group,
|
|
14
15
|
appendAssistantMessage,
|
|
15
16
|
appendMessages,
|
|
17
|
+
appendStreamingMessage,
|
|
16
18
|
appendUserMessage,
|
|
17
19
|
calculateScrollToBottom,
|
|
18
20
|
calculateUnreadCount,
|
|
21
|
+
cancelStreamingMessage,
|
|
19
22
|
chat_default,
|
|
20
23
|
createConversation,
|
|
21
24
|
deriveAttachmentKind,
|
|
22
25
|
extractTimestamp,
|
|
26
|
+
finalizeStreamingMessage,
|
|
23
27
|
findUnreadBoundaryIndex,
|
|
24
28
|
isAtBottom,
|
|
25
29
|
serializeChatAttachment,
|
|
26
30
|
serializeChatAttachments,
|
|
27
|
-
shouldShowJumpToLatest
|
|
28
|
-
|
|
31
|
+
shouldShowJumpToLatest,
|
|
32
|
+
updateStreamingMessage
|
|
33
|
+
} from "../../index.server-czf35aba.js";
|
|
29
34
|
import"../../index.server-qkfd0qa7.js";
|
|
30
35
|
import"../../index.server-kb6w1a7c.js";
|
|
31
36
|
import"../../index.server-317enkqq.js";
|
|
@@ -85,6 +90,7 @@ import"../../index.server-mc6vc1pm.js";
|
|
|
85
90
|
import"../../index.server-z7nvkz8v.js";
|
|
86
91
|
import"../../index.server-0v6na3yp.js";
|
|
87
92
|
export {
|
|
93
|
+
updateStreamingMessage,
|
|
88
94
|
shouldShowJumpToLatest,
|
|
89
95
|
serializeChatAttachments,
|
|
90
96
|
serializeChatAttachment,
|
|
@@ -94,13 +100,16 @@ export {
|
|
|
94
100
|
getMessageRoleLabel,
|
|
95
101
|
formatMessageAsMarkdown,
|
|
96
102
|
findUnreadBoundaryIndex,
|
|
103
|
+
finalizeStreamingMessage,
|
|
97
104
|
extractTimestamp,
|
|
98
105
|
deriveAttachmentKind,
|
|
99
106
|
chat_default as default,
|
|
100
107
|
createConversation,
|
|
108
|
+
cancelStreamingMessage,
|
|
101
109
|
calculateUnreadCount,
|
|
102
110
|
calculateScrollToBottom,
|
|
103
111
|
appendUserMessage,
|
|
112
|
+
appendStreamingMessage,
|
|
104
113
|
appendMessages,
|
|
105
114
|
appendAssistantMessage,
|
|
106
115
|
Tool_call_group as ToolCallGroup,
|
|
@@ -114,8 +123,9 @@ export {
|
|
|
114
123
|
Chat_attachment_preview as ChatAttachmentPreview,
|
|
115
124
|
Chat_artifact_layout as ChatArtifactLayout,
|
|
116
125
|
Chat,
|
|
126
|
+
CURRENT_SCHEMA_VERSION,
|
|
117
127
|
Artifact_viewer as ArtifactViewer,
|
|
118
128
|
Artifact_panel as ArtifactPanel
|
|
119
129
|
};
|
|
120
130
|
|
|
121
|
-
//# debugId=
|
|
131
|
+
//# debugId=DA9264A3674823E364756E2164756E21
|
package/dist/server/index.js
CHANGED
|
@@ -70,6 +70,9 @@ import {
|
|
|
70
70
|
classNames
|
|
71
71
|
} from "./index.server-z7nvkz8v.js";
|
|
72
72
|
|
|
73
|
+
// src/components/chat/index.ts
|
|
74
|
+
import { CURRENT_SCHEMA_VERSION } from "conversationalist/versioning";
|
|
75
|
+
|
|
73
76
|
// src/components/chat/chat.svelte
|
|
74
77
|
import * as $36 from "svelte/internal/server";
|
|
75
78
|
|
|
@@ -2872,7 +2875,7 @@ function Chat($$renderer, $$props) {
|
|
|
2872
2875
|
});
|
|
2873
2876
|
const messages = $35.derived(() => getMessages(conversation));
|
|
2874
2877
|
const lastMessageId = $35.derived(() => messages().at(-1)?.id);
|
|
2875
|
-
let previousAutoScrollMessageCount =
|
|
2878
|
+
let previousAutoScrollMessageCount = messages().length;
|
|
2876
2879
|
const conversationId = $35.derived(() => conversation.id);
|
|
2877
2880
|
const showTypingIndicator = $35.derived(() => streaming && !streamingMessageId);
|
|
2878
2881
|
const allowAttachments = $35.derived(() => capabilities?.attachments ?? true);
|
|
@@ -4150,6 +4153,14 @@ function resolveRoleHelperMetadata(metadataOrEnvironment, environment) {
|
|
|
4150
4153
|
return metadataOrEnvironment;
|
|
4151
4154
|
throw new Error("metadata must be a JSON-compatible object");
|
|
4152
4155
|
}
|
|
4156
|
+
|
|
4157
|
+
// src/components/chat/index.ts
|
|
4158
|
+
import {
|
|
4159
|
+
appendStreamingMessage,
|
|
4160
|
+
cancelStreamingMessage,
|
|
4161
|
+
finalizeStreamingMessage,
|
|
4162
|
+
updateStreamingMessage
|
|
4163
|
+
} from "conversationalist/streaming";
|
|
4153
4164
|
// src/components/chat/artifact/artifact-panel.svelte
|
|
4154
4165
|
import * as $37 from "svelte/internal/server";
|
|
4155
4166
|
function Artifact_panel($$renderer, $$props) {
|
|
@@ -4225,6 +4236,6 @@ function Chat_artifact_layout($$renderer, $$props) {
|
|
|
4225
4236
|
}
|
|
4226
4237
|
// src/components/chat/index.ts
|
|
4227
4238
|
var chat_default = Chat2;
|
|
4228
|
-
export { Chat_date_separator, Message_content, Tool_call_group, Message_attachments, Chat_message, deriveAttachmentKind, Chat_attachment_preview, serializeChatAttachment, serializeChatAttachments, Chat_input, DEFAULT_SCROLL_CONFIGURATION, isAtBottom, shouldShowJumpToLatest, calculateUnreadCount, findUnreadBoundaryIndex, calculateScrollToBottom, extractTimestamp, Chat2 as Chat, createConversation, appendMessages, appendUserMessage, appendAssistantMessage, Artifact_panel, Artifact_viewer, Chat_artifact_layout, chat_default };
|
|
4239
|
+
export { Chat_date_separator, Message_content, Tool_call_group, Message_attachments, Chat_message, deriveAttachmentKind, Chat_attachment_preview, serializeChatAttachment, serializeChatAttachments, Chat_input, DEFAULT_SCROLL_CONFIGURATION, isAtBottom, shouldShowJumpToLatest, calculateUnreadCount, findUnreadBoundaryIndex, calculateScrollToBottom, extractTimestamp, Chat2 as Chat, createConversation, appendMessages, appendUserMessage, appendAssistantMessage, Artifact_panel, Artifact_viewer, Chat_artifact_layout, CURRENT_SCHEMA_VERSION, chat_default, appendStreamingMessage, cancelStreamingMessage, finalizeStreamingMessage, updateStreamingMessage };
|
|
4229
4240
|
|
|
4230
|
-
//# debugId=
|
|
4241
|
+
//# debugId=718230D5CCC8725F64756E2164756E21
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lostgradient/cinder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "A Svelte 5 component library and design system focused on accessibility, theming, and per-component tree-shaking.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svelte",
|
|
@@ -6566,7 +6566,8 @@
|
|
|
6566
6566
|
"remark-stringify": "^11.0.0",
|
|
6567
6567
|
"shiki": "^3.21.0",
|
|
6568
6568
|
"unified": "^11.0.5",
|
|
6569
|
-
"unist-util-visit": "^5.0.0"
|
|
6569
|
+
"unist-util-visit": "^5.0.0",
|
|
6570
|
+
"zod": "4.4.1"
|
|
6570
6571
|
},
|
|
6571
6572
|
"devDependencies": {
|
|
6572
6573
|
"@changesets/parse": "0.4.3",
|
|
@@ -6592,8 +6593,7 @@
|
|
|
6592
6593
|
"svelte-check": "^4.0.0",
|
|
6593
6594
|
"svelte2tsx": "^0.7.33",
|
|
6594
6595
|
"ts-morph": "^28.0.0",
|
|
6595
|
-
"typescript": "^5.9.0"
|
|
6596
|
-
"zod": "4.4.1"
|
|
6596
|
+
"typescript": "^5.9.0"
|
|
6597
6597
|
},
|
|
6598
6598
|
"peerDependencies": {
|
|
6599
6599
|
"@milkdown/ctx": "^7.17.3",
|
|
@@ -6604,8 +6604,7 @@
|
|
|
6604
6604
|
"prosemirror-model": "^1.25.4",
|
|
6605
6605
|
"prosemirror-state": "^1.4.4",
|
|
6606
6606
|
"prosemirror-view": "^1.41.3",
|
|
6607
|
-
"svelte": ">=5.56.0 <6"
|
|
6608
|
-
"zod": "4.4.1"
|
|
6607
|
+
"svelte": ">=5.56.0 <6"
|
|
6609
6608
|
},
|
|
6610
6609
|
"peerDependenciesMeta": {
|
|
6611
6610
|
"@milkdown/ctx": {
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
"component": "chat",
|
|
4
4
|
"import": "@lostgradient/cinder/chat",
|
|
5
5
|
"examples": [
|
|
6
|
+
{
|
|
7
|
+
"id": "adapter-streaming",
|
|
8
|
+
"title": "Adapter-driven streaming",
|
|
9
|
+
"description": "Use ChatAdapter.sendMessage with the public streaming builders while keeping the conversation snapshot synchronized with Chat's imperative stream.",
|
|
10
|
+
"code": "<script lang=\"ts\">\n import {\n Chat,\n appendStreamingMessage,\n appendUserMessage,\n cancelStreamingMessage,\n createConversation,\n finalizeStreamingMessage,\n updateStreamingMessage,\n type ChatAdapter,\n type ConversationHistory,\n } from '@lostgradient/cinder/chat';\n\n let chat: ReturnType<typeof Chat> | undefined;\n let conversation = $state<ConversationHistory>(createConversation({ id: 'adapter-streaming' }));\n let streaming = $state(false);\n\n const responseChunks = ['This reply ', 'arrives ', 'through ', 'an adapter.'];\n\n function wait(milliseconds: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, milliseconds));\n }\n\n const adapter: ChatAdapter = {\n async sendMessage(message, _attachments) {\n conversation = appendUserMessage(conversation, message.content);\n const started = appendStreamingMessage(conversation, 'assistant');\n conversation = started.conversation;\n streaming = true;\n chat?.beginStreaming(started.messageId);\n\n let content = '';\n try {\n for (const chunk of responseChunks) {\n content += chunk;\n conversation = updateStreamingMessage(conversation, started.messageId, content);\n chat?.pushToken(chunk);\n await wait(240);\n }\n conversation = finalizeStreamingMessage(conversation, started.messageId);\n } catch (error) {\n conversation = cancelStreamingMessage(conversation, started.messageId);\n throw error;\n } finally {\n chat?.endStreaming();\n streaming = false;\n }\n },\n };\n</script>\n\n<div style=\"height: 34rem;\">\n <Chat\n bind:this={chat}\n id=\"adapter-streaming\"\n {conversation}\n {adapter}\n {streaming}\n capabilities={{ attachments: false }}\n />\n</div>\n"
|
|
11
|
+
},
|
|
6
12
|
{
|
|
7
13
|
"id": "basic",
|
|
8
14
|
"title": "Basic chat",
|
|
@@ -141,7 +141,7 @@ const messages = $derived(getMessages(conversation));
|
|
|
141
141
|
// C5 — suggested replies are a per-TURN affordance shown only beneath the last
|
|
142
142
|
// message, not on every historical message that still carries the metadata.
|
|
143
143
|
const lastMessageId = $derived(messages.at(-1)?.id);
|
|
144
|
-
let previousAutoScrollMessageCount =
|
|
144
|
+
let previousAutoScrollMessageCount = $state(messages.length);
|
|
145
145
|
// The conversation id as a stable VALUE dependency. The subscribe effect keys
|
|
146
146
|
// on this (not on `conversation.id` read inline) so a consumer passing a fresh
|
|
147
147
|
// `conversation` snapshot on every transcript update — but with the same id —
|
|
@@ -13,8 +13,16 @@ import type { ToMarkdownOptions as ConversationalistToMarkdownOptions } from 'co
|
|
|
13
13
|
export type {
|
|
14
14
|
AssistantMessage,
|
|
15
15
|
ContainerUploadContent,
|
|
16
|
+
Conversation,
|
|
17
|
+
ConversationActionType,
|
|
16
18
|
ConversationEnvironment,
|
|
19
|
+
ConversationEvent,
|
|
20
|
+
ConversationEventMap,
|
|
21
|
+
ConversationEventType,
|
|
17
22
|
ConversationHistory,
|
|
23
|
+
ConversationHistoryDraft,
|
|
24
|
+
ConversationNodeSnapshot,
|
|
25
|
+
ConversationSnapshot,
|
|
18
26
|
ConversationStatus,
|
|
19
27
|
ImageContent,
|
|
20
28
|
JSONValue,
|
|
@@ -31,9 +39,12 @@ export type {
|
|
|
31
39
|
TokenUsage,
|
|
32
40
|
ToolAction,
|
|
33
41
|
ToolCall,
|
|
42
|
+
ToolCallInput,
|
|
34
43
|
ToolError,
|
|
35
44
|
ToolErrorCategory,
|
|
45
|
+
ToolInteraction,
|
|
36
46
|
ToolResult,
|
|
47
|
+
ToolResultInput,
|
|
37
48
|
WebSearchToolResultContent,
|
|
38
49
|
} from 'conversationalist';
|
|
39
50
|
export type { ToolCallPair } from 'conversationalist/utilities';
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// Top-level Chat wrapper — the public component consumers import as
|
|
10
10
|
// `@lostgradient/cinder/chat`. It composes the inner implementation in container/ with a
|
|
11
11
|
// custom class-merge layer.
|
|
12
|
+
import { CURRENT_SCHEMA_VERSION } from 'conversationalist/versioning';
|
|
12
13
|
import './chat.css';
|
|
13
14
|
import Chat from './chat.svelte';
|
|
14
15
|
|
|
@@ -20,7 +21,7 @@ export type {
|
|
|
20
21
|
ReadReceipt,
|
|
21
22
|
TypingParticipant,
|
|
22
23
|
} from './chat.types.ts';
|
|
23
|
-
export { Chat };
|
|
24
|
+
export { Chat, CURRENT_SCHEMA_VERSION };
|
|
24
25
|
|
|
25
26
|
// Adapter seam — the optional event/transport boundary around <Chat>. Type-only.
|
|
26
27
|
export type {
|
|
@@ -40,14 +41,32 @@ export {
|
|
|
40
41
|
createConversation,
|
|
41
42
|
} from './builders.ts';
|
|
42
43
|
|
|
44
|
+
// Streaming conversation builders — keep the immutable snapshot and Chat's
|
|
45
|
+
// imperative streaming surface in sync without requiring a direct
|
|
46
|
+
// conversationalist dependency in the consuming application.
|
|
47
|
+
export {
|
|
48
|
+
appendStreamingMessage,
|
|
49
|
+
cancelStreamingMessage,
|
|
50
|
+
finalizeStreamingMessage,
|
|
51
|
+
updateStreamingMessage,
|
|
52
|
+
} from 'conversationalist/streaming';
|
|
53
|
+
|
|
43
54
|
// Conversation data model — published Conversationalist shapes Chat renders.
|
|
44
55
|
// Public so consumers can type the `conversation` prop and construct messages
|
|
45
56
|
// without Cinder maintaining a stale local mirror.
|
|
46
57
|
export type {
|
|
47
58
|
AssistantMessage,
|
|
48
59
|
ContainerUploadContent,
|
|
60
|
+
Conversation,
|
|
61
|
+
ConversationActionType,
|
|
49
62
|
ConversationEnvironment,
|
|
63
|
+
ConversationEvent,
|
|
64
|
+
ConversationEventMap,
|
|
65
|
+
ConversationEventType,
|
|
50
66
|
ConversationHistory,
|
|
67
|
+
ConversationHistoryDraft,
|
|
68
|
+
ConversationNodeSnapshot,
|
|
69
|
+
ConversationSnapshot,
|
|
51
70
|
ConversationStatus,
|
|
52
71
|
ExportOptions,
|
|
53
72
|
ImageContent,
|
|
@@ -65,14 +84,17 @@ export type {
|
|
|
65
84
|
ServerToolUseContent,
|
|
66
85
|
TextContent,
|
|
67
86
|
ThinkingContent,
|
|
68
|
-
ToMarkdownOptions,
|
|
69
87
|
TokenUsage,
|
|
88
|
+
ToMarkdownOptions,
|
|
70
89
|
ToolAction,
|
|
71
90
|
ToolCall,
|
|
91
|
+
ToolCallInput,
|
|
72
92
|
ToolCallPair,
|
|
73
93
|
ToolError,
|
|
74
94
|
ToolErrorCategory,
|
|
95
|
+
ToolInteraction,
|
|
75
96
|
ToolResult,
|
|
97
|
+
ToolResultInput,
|
|
76
98
|
WebSearchToolResultContent,
|
|
77
99
|
} from './conversation-model.ts';
|
|
78
100
|
|
|
@@ -114,9 +136,9 @@ export {
|
|
|
114
136
|
// "99+"), not reusable behavior a consumer building a custom chat container
|
|
115
137
|
// would depend on. They remain available internally from ./container.
|
|
116
138
|
export {
|
|
117
|
-
DEFAULT_SCROLL_CONFIGURATION,
|
|
118
139
|
calculateScrollToBottom,
|
|
119
140
|
calculateUnreadCount,
|
|
141
|
+
DEFAULT_SCROLL_CONFIGURATION,
|
|
120
142
|
extractTimestamp,
|
|
121
143
|
findUnreadBoundaryIndex,
|
|
122
144
|
isAtBottom,
|