@aleph-alpha/chat-kit 1.3.0 → 1.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.
Files changed (60) hide show
  1. package/dist/{CkInput.vue_vue_type_script_setup_true_lang-BoUxOQbH.js → CkInput.vue_vue_type_script_setup_true_lang-C5C09u0z.js} +13 -12
  2. package/dist/adapters/index.d.ts +18 -0
  3. package/dist/adapters/index.d.ts.map +1 -0
  4. package/dist/adapters/index.js +4 -0
  5. package/dist/adapters/responses-api.d.ts +180 -0
  6. package/dist/adapters/responses-api.d.ts.map +1 -0
  7. package/dist/adapters/responses-api.js +153 -0
  8. package/dist/chat-kit.css +2 -11
  9. package/dist/components/base/CkFeedbackButton/CkFeedbackButton.vue.d.ts.map +1 -1
  10. package/dist/components/base/CkPromptActionButton/CkPromptActionButton.vue.d.ts +1 -1
  11. package/dist/components/composed/CkConversation/CkConversation.stories.d.ts +11 -3
  12. package/dist/components/composed/CkConversation/CkConversation.stories.d.ts.map +1 -1
  13. package/dist/components/composed/CkConversation/CkConversation.vue.d.ts +5 -1
  14. package/dist/components/composed/CkConversation/CkConversation.vue.d.ts.map +1 -1
  15. package/dist/components/index.js +1 -1
  16. package/dist/composables/index.js +1 -1
  17. package/dist/composables/useConversations.d.ts +12 -0
  18. package/dist/composables/useConversations.d.ts.map +1 -1
  19. package/dist/favicon.ico +0 -0
  20. package/dist/generateId-BHf0W4Rq.js +6 -0
  21. package/dist/handlers/index.js +1 -1
  22. package/dist/handlers/useMessageHandler.d.ts +2 -2
  23. package/dist/handlers/useMessageHandler.d.ts.map +1 -1
  24. package/dist/index.d.ts +2 -2
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +6 -8
  27. package/dist/services/index.d.ts +0 -2
  28. package/dist/services/index.d.ts.map +1 -1
  29. package/dist/services/index.js +1 -37
  30. package/dist/services/types.d.ts +2 -2
  31. package/dist/services/types.d.ts.map +1 -1
  32. package/dist/types.d.ts +47 -2
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/{useConversationSessions-ulFhtpQr.js → useConversationSessions-GLZV_Ctr.js} +18 -2
  35. package/dist/{useMessageHandler-BmBdu2EW.js → useMessageHandler-ZRC-gIOJ.js} +5 -5
  36. package/package.json +11 -2
  37. package/src/adapters/index.ts +17 -0
  38. package/src/adapters/responses-api.spec.ts +365 -0
  39. package/src/adapters/responses-api.ts +444 -0
  40. package/src/components/base/CkFeedbackButton/CkFeedbackButton.vue +8 -24
  41. package/src/components/composed/CkConversation/CkConversation.spec.ts +171 -25
  42. package/src/components/composed/CkConversation/CkConversation.stories.ts +266 -46
  43. package/src/components/composed/CkConversation/CkConversation.vue +19 -7
  44. package/src/composables/useConversations.spec.ts +118 -0
  45. package/src/composables/useConversations.ts +32 -0
  46. package/src/handlers/useChatKitLabels.spec.ts +16 -2
  47. package/src/handlers/useMessageHandler.spec.ts +112 -44
  48. package/src/handlers/useMessageHandler.ts +16 -2
  49. package/src/helpers/conversationTree.spec.ts +46 -19
  50. package/src/index.ts +11 -2
  51. package/src/services/index.ts +0 -2
  52. package/src/services/types.ts +2 -2
  53. package/src/types.ts +55 -2
  54. package/dist/ChatService-LogwJNxh.js +0 -9
  55. package/dist/services/ChatService.d.ts +0 -42
  56. package/dist/services/ChatService.d.ts.map +0 -1
  57. package/dist/services/MockChatService.d.ts +0 -10
  58. package/dist/services/MockChatService.d.ts.map +0 -1
  59. package/src/services/ChatService.ts +0 -60
  60. package/src/services/MockChatService.ts +0 -47
@@ -1,4 +1,9 @@
1
- import type { ConversationTree, TreeMessage } from '../types';
1
+ import type {
2
+ ConversationTree,
3
+ MessageContent,
4
+ MessageTextContent,
5
+ TreeMessage,
6
+ } from '../types';
2
7
  import {
3
8
  addNode,
4
9
  createEmptyTree,
@@ -8,6 +13,17 @@ import {
8
13
  updateNodeId,
9
14
  } from './conversationTree';
10
15
 
16
+ let textIdCounter = 0;
17
+ function text(value: string): MessageTextContent {
18
+ textIdCounter += 1;
19
+ return {
20
+ type: 'text',
21
+ id: `txt-${textIdCounter}`,
22
+ text: value,
23
+ status: 'completed',
24
+ };
25
+ }
26
+
11
27
  function makeTreeMessage(
12
28
  overrides: Partial<TreeMessage> & { id: string },
13
29
  ): TreeMessage {
@@ -16,7 +32,7 @@ function makeTreeMessage(
16
32
  childrenIds: [],
17
33
  activeChildIndex: 0,
18
34
  role: 'user',
19
- content: '',
35
+ content: [],
20
36
  status: 'completed',
21
37
  createdAt: new Date('2025-01-01'),
22
38
  ...overrides,
@@ -42,6 +58,13 @@ function makeTree(
42
58
  return { nodes, rootId };
43
59
  }
44
60
 
61
+ function getText(content: MessageContent[]): string {
62
+ return content
63
+ .filter((c): c is MessageTextContent => c.type === 'text')
64
+ .map((c) => c.text)
65
+ .join('');
66
+ }
67
+
45
68
  /**
46
69
  * Builds a simple branching tree for tests:
47
70
  *
@@ -58,42 +81,42 @@ function makeTree(
58
81
  function makeBranchingTree(): ConversationTree {
59
82
  return makeTree(
60
83
  {
61
- u1: makeTreeMessage({ id: 'u1', role: 'user', content: 'Hello' }),
84
+ u1: makeTreeMessage({ id: 'u1', role: 'user', content: [text('Hello')] }),
62
85
  a1: makeTreeMessage({
63
86
  id: 'a1',
64
87
  parentId: 'u1',
65
88
  role: 'assistant',
66
- content: 'Hi',
89
+ content: [text('Hi')],
67
90
  }),
68
91
  u2: makeTreeMessage({
69
92
  id: 'u2',
70
93
  parentId: 'a1',
71
94
  role: 'user',
72
- content: 'Question',
95
+ content: [text('Question')],
73
96
  }),
74
97
  a2: makeTreeMessage({
75
98
  id: 'a2',
76
99
  parentId: 'u2',
77
100
  role: 'assistant',
78
- content: 'Answer 1',
101
+ content: [text('Answer 1')],
79
102
  }),
80
103
  a3: makeTreeMessage({
81
104
  id: 'a3',
82
105
  parentId: 'u2',
83
106
  role: 'assistant',
84
- content: 'Answer 2',
107
+ content: [text('Answer 2')],
85
108
  }),
86
109
  a1b: makeTreeMessage({
87
110
  id: 'a1b',
88
111
  parentId: 'u1',
89
112
  role: 'assistant',
90
- content: 'Alt hi',
113
+ content: [text('Alt hi')],
91
114
  }),
92
115
  u3: makeTreeMessage({
93
116
  id: 'u3',
94
117
  parentId: 'a1b',
95
118
  role: 'user',
96
- content: 'Follow-up',
119
+ content: [text('Follow-up')],
97
120
  }),
98
121
  },
99
122
  'u1',
@@ -166,7 +189,7 @@ describe('getLinearPath', () => {
166
189
 
167
190
  const u1Msg = path[0];
168
191
  expect(u1Msg.role).toBe('user');
169
- expect(u1Msg.content).toBe('Hello');
192
+ expect(getText(u1Msg.content)).toBe('Hello');
170
193
  expect(u1Msg.status).toBe('completed');
171
194
  expect(u1Msg.createdAt).toEqual(new Date('2025-01-01'));
172
195
  });
@@ -175,7 +198,7 @@ describe('getLinearPath', () => {
175
198
  describe('addNode', () => {
176
199
  it('adds the first node as root', () => {
177
200
  const tree = createEmptyTree();
178
- const node = makeTreeMessage({ id: 'u1', content: 'Hello' });
201
+ const node = makeTreeMessage({ id: 'u1', content: [text('Hello')] });
179
202
 
180
203
  addNode(tree, node);
181
204
 
@@ -248,8 +271,8 @@ describe('addNode', () => {
248
271
  describe('updateNode', () => {
249
272
  it('updates content of an existing node', () => {
250
273
  const tree = makeBranchingTree();
251
- updateNode(tree, 'a1', { content: 'Updated hi' });
252
- expect(tree.nodes.a1.content).toBe('Updated hi');
274
+ updateNode(tree, 'a1', { content: [text('Updated hi')] });
275
+ expect(getText(tree.nodes.a1.content)).toBe('Updated hi');
253
276
  });
254
277
 
255
278
  it('updates status of an existing node', () => {
@@ -261,7 +284,7 @@ describe('updateNode', () => {
261
284
  it('is a no-op for nonexistent id', () => {
262
285
  const tree = makeBranchingTree();
263
286
  const nodeCount = Object.keys(tree.nodes).length;
264
- updateNode(tree, 'nonexistent', { content: 'x' });
287
+ updateNode(tree, 'nonexistent', { content: [text('x')] });
265
288
  expect(Object.keys(tree.nodes).length).toBe(nodeCount);
266
289
  });
267
290
  });
@@ -366,19 +389,23 @@ describe('integration: full branching scenario', () => {
366
389
  it('simulates send → regenerate → navigate workflow', () => {
367
390
  const tree = createEmptyTree();
368
391
 
369
- addNode(tree, makeTreeMessage({ id: 'u1', content: 'Hello' }));
392
+ addNode(tree, makeTreeMessage({ id: 'u1', content: [text('Hello')] }));
370
393
  addNode(
371
394
  tree,
372
395
  makeTreeMessage({
373
396
  id: 'a1',
374
397
  parentId: 'u1',
375
398
  role: 'assistant',
376
- content: 'Hi there',
399
+ content: [text('Hi there')],
377
400
  }),
378
401
  );
379
402
  addNode(
380
403
  tree,
381
- makeTreeMessage({ id: 'u2', parentId: 'a1', content: 'Tell me more' }),
404
+ makeTreeMessage({
405
+ id: 'u2',
406
+ parentId: 'a1',
407
+ content: [text('Tell me more')],
408
+ }),
382
409
  );
383
410
  addNode(
384
411
  tree,
@@ -386,7 +413,7 @@ describe('integration: full branching scenario', () => {
386
413
  id: 'a2',
387
414
  parentId: 'u2',
388
415
  role: 'assistant',
389
- content: 'Sure thing',
416
+ content: [text('Sure thing')],
390
417
  }),
391
418
  );
392
419
 
@@ -399,7 +426,7 @@ describe('integration: full branching scenario', () => {
399
426
  id: 'a3',
400
427
  parentId: 'u2',
401
428
  role: 'assistant',
402
- content: 'Certainly!',
429
+ content: [text('Certainly!')],
403
430
  }),
404
431
  );
405
432
 
package/src/index.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  // Services
2
2
  export {
3
- ChatService,
4
- type IChatService,
5
3
  type ChatConfig,
6
4
  type ChatMessage,
7
5
  type ChatResponse,
@@ -12,6 +10,12 @@ export {
12
10
  type StreamEvent,
13
11
  } from './services';
14
12
 
13
+ // Adapters' wire-level types (e.g. Responses-API) are intentionally NOT
14
+ // re-exported at the top level — import them from
15
+ // `@aleph-alpha/chat-kit/adapters/responses-api` (or the aggregate
16
+ // `@aleph-alpha/chat-kit/adapters`) to keep the format you depend on
17
+ // explicit.
18
+
15
19
  // Handlers
16
20
  export {
17
21
  useMessageHandler,
@@ -83,7 +87,12 @@ export type {
83
87
  BaseMessage,
84
88
  Conversation,
85
89
  ConversationTree,
90
+ MessageContent,
91
+ MessageContentStatus,
92
+ MessageReasoningContent,
86
93
  MessageRole,
87
94
  MessageStatus,
95
+ MessageTextContent,
96
+ MessageToolContent,
88
97
  TreeMessage,
89
98
  } from './types';
@@ -1,5 +1,3 @@
1
- export { ChatService, type IChatService } from './ChatService';
2
- export { MockChatService } from './MockChatService';
3
1
  export type {
4
2
  ChatConfig,
5
3
  ChatMessage,
@@ -1,4 +1,4 @@
1
- import type { BaseMessage, MessageRole } from '../types';
1
+ import type { BaseMessage, MessageContent, MessageRole } from '../types';
2
2
 
3
3
  /**
4
4
  * Minimal HTTP transport contract that chat-kit composables depend on.
@@ -61,7 +61,7 @@ export interface RawConversationList {
61
61
  export interface ChatMessage {
62
62
  id: string;
63
63
  role: MessageRole;
64
- content: string;
64
+ content: MessageContent[];
65
65
  }
66
66
 
67
67
  /**
package/src/types.ts CHANGED
@@ -6,10 +6,63 @@ export type MessageRole = 'user' | 'assistant' | 'system';
6
6
 
7
7
  export type MessageStatus = 'started' | 'sending' | 'completed' | 'error';
8
8
 
9
+ /**
10
+ * Lifecycle of a single content item inside a message — used to indicate
11
+ * whether a streamed text part is still being produced, has finished, or was
12
+ * cut short. Tool content does not carry a status (it represents a single
13
+ * fired tool call) so it always omits this field.
14
+ */
15
+ export type MessageContentStatus = 'in_progress' | 'completed' | 'incomplete';
16
+
17
+ /**
18
+ * Plain text part of a message. Multiple text parts can appear in a single
19
+ * assistant turn, interleaved with reasoning and tool calls.
20
+ */
21
+ export interface MessageTextContent {
22
+ type: 'text';
23
+ id: string;
24
+ text: string;
25
+ status: MessageContentStatus;
26
+ }
27
+
28
+ /**
29
+ * Tool invocation triggered by the assistant during its turn. Only the tool
30
+ * name is rendered; arguments and results are intentionally outside the
31
+ * UI-facing model and should be tracked by the host application.
32
+ */
33
+ export interface MessageToolContent {
34
+ type: 'tool';
35
+ id: string;
36
+ name: string;
37
+ }
38
+
39
+ /**
40
+ * Chain-of-thought / reasoning segment produced by the assistant. `text` is
41
+ * the (optional) human-readable trail — populated when the underlying
42
+ * transport exposes reasoning content (`REASONING_MESSAGE_CONTENT` deltas
43
+ * during a live run, `reasoning_text` parts when re-hydrating from the
44
+ * Responses API). Surfaces that only need a "Thinking…" / "Thought"
45
+ * indicator can ignore it and rely on `status` alone.
46
+ */
47
+ export interface MessageReasoningContent {
48
+ type: 'reasoning';
49
+ id: string;
50
+ text?: string;
51
+ status: MessageContentStatus;
52
+ }
53
+
54
+ /**
55
+ * Discriminated union of all content parts that can appear inside a message.
56
+ */
57
+ export type MessageContent =
58
+ | MessageTextContent
59
+ | MessageToolContent
60
+ | MessageReasoningContent;
61
+
9
62
  export interface BaseMessage {
10
63
  id: string;
11
64
  role: MessageRole;
12
- content: string;
65
+ content: MessageContent[];
13
66
  createdAt: Date;
14
67
  status: MessageStatus;
15
68
  siblingIds?: string[];
@@ -22,7 +75,7 @@ export interface TreeMessage {
22
75
  childrenIds: string[];
23
76
  activeChildIndex: number;
24
77
  role: MessageRole;
25
- content: string;
78
+ content: MessageContent[];
26
79
  status: MessageStatus;
27
80
  createdAt: Date;
28
81
  }
@@ -1,9 +0,0 @@
1
- class ChatService {
2
- config;
3
- constructor(config) {
4
- this.config = config || {};
5
- }
6
- }
7
- export {
8
- ChatService as C
9
- };
@@ -1,42 +0,0 @@
1
- import type { ChatConfig, ChatMessage, ChatResponse, StreamEvent } from './types';
2
- /**
3
- * Interface for chat service implementations
4
- *
5
- * This is a skeleton interface that defines the contract for chat services.
6
- * Implementations should provide concrete implementations of these methods.
7
- */
8
- export interface IChatService {
9
- /**
10
- * Send a message and receive a response
11
- * @param message - The message to send
12
- * @returns Promise resolving to the chat response
13
- */
14
- sendMessage(message: ChatMessage): Promise<ChatResponse>;
15
- /**
16
- * Get chat history
17
- * @param limit - Maximum number of messages to retrieve
18
- * @returns Promise resolving to an array of messages
19
- */
20
- getHistory(limit?: number): Promise<ChatMessage[]>;
21
- /**
22
- * Stream a message response
23
- * @param message - The message to send
24
- * @param onEvent - Callback for stream events
25
- * @returns Promise that resolves when streaming is complete
26
- */
27
- streamMessage(message: ChatMessage, onEvent: (event: StreamEvent) => void): Promise<void>;
28
- }
29
- /**
30
- * Abstract base class for chat service implementations
31
- *
32
- * This is a skeleton abstract class that can be extended to create
33
- * concrete chat service implementations.
34
- */
35
- export declare abstract class ChatService implements IChatService {
36
- protected config: ChatConfig;
37
- constructor(config?: ChatConfig);
38
- abstract sendMessage(message: ChatMessage): Promise<ChatResponse>;
39
- abstract getHistory(limit?: number): Promise<ChatMessage[]>;
40
- abstract streamMessage(message: ChatMessage, onEvent: (event: StreamEvent) => void): Promise<void>;
41
- }
42
- //# sourceMappingURL=ChatService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChatService.d.ts","sourceRoot":"","sources":["../../src/services/ChatService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,YAAY,EACZ,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAEzD;;;;OAIG;IACH,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAEnD;;;;;OAKG;IACH,aAAa,CACX,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACpC,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB;AAED;;;;;GAKG;AACH,8BAAsB,WAAY,YAAW,YAAY;IACvD,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;gBAEjB,MAAM,CAAC,EAAE,UAAU;IAI/B,QAAQ,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IACjE,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAC3D,QAAQ,CAAC,aAAa,CACpB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACpC,OAAO,CAAC,IAAI,CAAC;CACjB"}
@@ -1,10 +0,0 @@
1
- import { ChatService, type IChatService } from './ChatService';
2
- import type { ChatMessage, ChatResponse, StreamEvent } from './types';
3
- export declare class MockChatService extends ChatService implements IChatService {
4
- constructor();
5
- sendMessage(message: ChatMessage): Promise<ChatResponse>;
6
- getHistory(): Promise<ChatMessage[]>;
7
- streamMessage(message: ChatMessage, onEvent: (event: StreamEvent) => void): Promise<void>;
8
- private createBaseMessage;
9
- }
10
- //# sourceMappingURL=MockChatService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MockChatService.d.ts","sourceRoot":"","sources":["../../src/services/MockChatService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtE,qBAAa,eAAgB,SAAQ,WAAY,YAAW,YAAY;;IAKhE,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAYxD,UAAU,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAIpC,aAAa,CACjB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACpC,OAAO,CAAC,IAAI,CAAC;IAMhB,OAAO,CAAC,iBAAiB;CAY1B"}
@@ -1,60 +0,0 @@
1
- import type {
2
- ChatConfig,
3
- ChatMessage,
4
- ChatResponse,
5
- StreamEvent,
6
- } from './types';
7
-
8
- /**
9
- * Interface for chat service implementations
10
- *
11
- * This is a skeleton interface that defines the contract for chat services.
12
- * Implementations should provide concrete implementations of these methods.
13
- */
14
- export interface IChatService {
15
- /**
16
- * Send a message and receive a response
17
- * @param message - The message to send
18
- * @returns Promise resolving to the chat response
19
- */
20
- sendMessage(message: ChatMessage): Promise<ChatResponse>;
21
-
22
- /**
23
- * Get chat history
24
- * @param limit - Maximum number of messages to retrieve
25
- * @returns Promise resolving to an array of messages
26
- */
27
- getHistory(limit?: number): Promise<ChatMessage[]>;
28
-
29
- /**
30
- * Stream a message response
31
- * @param message - The message to send
32
- * @param onEvent - Callback for stream events
33
- * @returns Promise that resolves when streaming is complete
34
- */
35
- streamMessage(
36
- message: ChatMessage,
37
- onEvent: (event: StreamEvent) => void,
38
- ): Promise<void>;
39
- }
40
-
41
- /**
42
- * Abstract base class for chat service implementations
43
- *
44
- * This is a skeleton abstract class that can be extended to create
45
- * concrete chat service implementations.
46
- */
47
- export abstract class ChatService implements IChatService {
48
- protected config: ChatConfig;
49
-
50
- constructor(config?: ChatConfig) {
51
- this.config = config || {};
52
- }
53
-
54
- abstract sendMessage(message: ChatMessage): Promise<ChatResponse>;
55
- abstract getHistory(limit?: number): Promise<ChatMessage[]>;
56
- abstract streamMessage(
57
- message: ChatMessage,
58
- onEvent: (event: StreamEvent) => void,
59
- ): Promise<void>;
60
- }
@@ -1,47 +0,0 @@
1
- import type { BaseMessage } from '../types';
2
- import { ChatService, type IChatService } from './ChatService';
3
- import type { ChatMessage, ChatResponse, StreamEvent } from './types';
4
-
5
- export class MockChatService extends ChatService implements IChatService {
6
- constructor() {
7
- super({});
8
- }
9
-
10
- async sendMessage(message: ChatMessage): Promise<ChatResponse> {
11
- const replyText = `Mock reply: ${message.content}`;
12
-
13
- return {
14
- message: this.createBaseMessage({
15
- role: 'assistant',
16
- content: replyText,
17
- }),
18
- metadata: { mock: true },
19
- };
20
- }
21
-
22
- async getHistory(): Promise<ChatMessage[]> {
23
- return [];
24
- }
25
-
26
- async streamMessage(
27
- message: ChatMessage,
28
- onEvent: (event: StreamEvent) => void,
29
- ): Promise<void> {
30
- const response = await this.sendMessage(message);
31
- onEvent({ type: 'chunk', data: response.message.content });
32
- onEvent({ type: 'done' });
33
- }
34
-
35
- private createBaseMessage(input: {
36
- role: BaseMessage['role'];
37
- content: string;
38
- }): BaseMessage {
39
- return {
40
- id: crypto.randomUUID(),
41
- role: input.role,
42
- content: input.content,
43
- createdAt: new Date(),
44
- status: 'completed',
45
- };
46
- }
47
- }