@copilotkitnext/angular 0.0.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.
Files changed (169) hide show
  1. package/.turbo/turbo-build.log +39 -0
  2. package/.turbo/turbo-check-types.log +0 -0
  3. package/.turbo/turbo-test.log +71 -0
  4. package/LICENSE +10 -0
  5. package/README-agent-context.md +310 -0
  6. package/dist/LICENSE +10 -0
  7. package/dist/components/chat/copilot-chat-assistant-message-buttons.component.d.ts +75 -0
  8. package/dist/components/chat/copilot-chat-assistant-message-renderer.component.d.ts +31 -0
  9. package/dist/components/chat/copilot-chat-assistant-message-toolbar.component.d.ts +8 -0
  10. package/dist/components/chat/copilot-chat-assistant-message.component.d.ts +131 -0
  11. package/dist/components/chat/copilot-chat-assistant-message.types.d.ts +31 -0
  12. package/dist/components/chat/copilot-chat-audio-recorder.component.d.ts +40 -0
  13. package/dist/components/chat/copilot-chat-buttons.component.d.ts +66 -0
  14. package/dist/components/chat/copilot-chat-input-defaults.d.ts +37 -0
  15. package/dist/components/chat/copilot-chat-input.component.d.ts +133 -0
  16. package/dist/components/chat/copilot-chat-input.types.d.ts +129 -0
  17. package/dist/components/chat/copilot-chat-message-view-cursor.component.d.ts +15 -0
  18. package/dist/components/chat/copilot-chat-message-view.component.d.ts +293 -0
  19. package/dist/components/chat/copilot-chat-message-view.types.d.ts +24 -0
  20. package/dist/components/chat/copilot-chat-textarea.component.d.ts +45 -0
  21. package/dist/components/chat/copilot-chat-tool-calls-view.component.d.ts +35 -0
  22. package/dist/components/chat/copilot-chat-toolbar.component.d.ts +8 -0
  23. package/dist/components/chat/copilot-chat-tools-menu.component.d.ts +20 -0
  24. package/dist/components/chat/copilot-chat-user-message-branch-navigation.component.d.ts +23 -0
  25. package/dist/components/chat/copilot-chat-user-message-buttons.component.d.ts +39 -0
  26. package/dist/components/chat/copilot-chat-user-message-renderer.component.d.ts +9 -0
  27. package/dist/components/chat/copilot-chat-user-message-toolbar.component.d.ts +8 -0
  28. package/dist/components/chat/copilot-chat-user-message.component.d.ts +55 -0
  29. package/dist/components/chat/copilot-chat-user-message.types.d.ts +33 -0
  30. package/dist/components/chat/copilot-chat-view-disclaimer.component.d.ts +15 -0
  31. package/dist/components/chat/copilot-chat-view-feather.component.d.ts +15 -0
  32. package/dist/components/chat/copilot-chat-view-handlers.service.d.ts +11 -0
  33. package/dist/components/chat/copilot-chat-view-input-container.component.d.ts +23 -0
  34. package/dist/components/chat/copilot-chat-view-scroll-to-bottom-button.component.d.ts +17 -0
  35. package/dist/components/chat/copilot-chat-view-scroll-view.component.d.ts +84 -0
  36. package/dist/components/chat/copilot-chat-view.component.d.ts +205 -0
  37. package/dist/components/chat/copilot-chat-view.types.d.ts +42 -0
  38. package/dist/components/chat/copilot-chat.component.d.ts +37 -0
  39. package/dist/components/copilotkit-tool-render.component.d.ts +25 -0
  40. package/dist/core/chat-configuration/chat-configuration.providers.d.ts +54 -0
  41. package/dist/core/chat-configuration/chat-configuration.service.d.ts +75 -0
  42. package/dist/core/chat-configuration/chat-configuration.types.d.ts +27 -0
  43. package/dist/core/copilotkit.providers.d.ts +13 -0
  44. package/dist/core/copilotkit.service.d.ts +119 -0
  45. package/dist/core/copilotkit.types.d.ts +83 -0
  46. package/dist/directives/copilotkit-agent-context.directive.d.ts +68 -0
  47. package/dist/directives/copilotkit-agent.directive.d.ts +106 -0
  48. package/dist/directives/copilotkit-chat-config.directive.d.ts +84 -0
  49. package/dist/directives/copilotkit-config.directive.d.ts +44 -0
  50. package/dist/directives/copilotkit-frontend-tool.directive.d.ts +25 -0
  51. package/dist/directives/copilotkit-human-in-the-loop.directive.d.ts +124 -0
  52. package/dist/directives/stick-to-bottom.directive.d.ts +62 -0
  53. package/dist/fesm2022/copilotkitnext-angular.mjs +9314 -0
  54. package/dist/fesm2022/copilotkitnext-angular.mjs.map +1 -0
  55. package/dist/index.d.ts +55 -0
  56. package/dist/lib/directives/tooltip.directive.d.ts +33 -0
  57. package/dist/lib/slots/copilot-slot.component.d.ts +34 -0
  58. package/dist/lib/slots/slot.types.d.ts +55 -0
  59. package/dist/lib/slots/slot.utils.d.ts +108 -0
  60. package/dist/lib/utils.d.ts +6 -0
  61. package/dist/services/resize-observer.service.d.ts +44 -0
  62. package/dist/services/scroll-position.service.d.ts +50 -0
  63. package/dist/styles.css +1963 -0
  64. package/dist/types/frontend-tool.d.ts +37 -0
  65. package/dist/types/human-in-the-loop.d.ts +44 -0
  66. package/dist/utils/agent-context.utils.d.ts +75 -0
  67. package/dist/utils/agent.utils.d.ts +99 -0
  68. package/dist/utils/chat-config.utils.d.ts +166 -0
  69. package/dist/utils/copilotkit.utils.d.ts +16 -0
  70. package/dist/utils/frontend-tool.utils.d.ts +119 -0
  71. package/dist/utils/human-in-the-loop.utils.d.ts +92 -0
  72. package/eslint.config.mjs +20 -0
  73. package/ng-package.json +19 -0
  74. package/package.json +96 -0
  75. package/slots.md +331 -0
  76. package/src/components/chat/__tests__/copilot-chat-assistant-message.component.spec.ts +282 -0
  77. package/src/components/chat/__tests__/copilot-chat-input.component.spec.ts +419 -0
  78. package/src/components/chat/__tests__/copilot-chat-message-view.component.spec.ts +372 -0
  79. package/src/components/chat/__tests__/copilot-chat-user-message.component.spec.ts +249 -0
  80. package/src/components/chat/copilot-chat-assistant-message-buttons.component.ts +292 -0
  81. package/src/components/chat/copilot-chat-assistant-message-renderer.component.ts +472 -0
  82. package/src/components/chat/copilot-chat-assistant-message-toolbar.component.ts +29 -0
  83. package/src/components/chat/copilot-chat-assistant-message.component.ts +463 -0
  84. package/src/components/chat/copilot-chat-assistant-message.types.ts +50 -0
  85. package/src/components/chat/copilot-chat-audio-recorder.component.ts +241 -0
  86. package/src/components/chat/copilot-chat-buttons.component.ts +308 -0
  87. package/src/components/chat/copilot-chat-buttons.component.ts.bak +471 -0
  88. package/src/components/chat/copilot-chat-input-defaults.ts +47 -0
  89. package/src/components/chat/copilot-chat-input.component.ts +512 -0
  90. package/src/components/chat/copilot-chat-input.types.ts +148 -0
  91. package/src/components/chat/copilot-chat-message-view-cursor.component.ts +51 -0
  92. package/src/components/chat/copilot-chat-message-view.component.ts +233 -0
  93. package/src/components/chat/copilot-chat-message-view.types.ts +39 -0
  94. package/src/components/chat/copilot-chat-textarea.component.ts +220 -0
  95. package/src/components/chat/copilot-chat-tool-calls-view.component.ts +261 -0
  96. package/src/components/chat/copilot-chat-toolbar.component.ts +35 -0
  97. package/src/components/chat/copilot-chat-tools-menu.component.ts +185 -0
  98. package/src/components/chat/copilot-chat-user-message-branch-navigation.component.ts +121 -0
  99. package/src/components/chat/copilot-chat-user-message-buttons.component.ts +170 -0
  100. package/src/components/chat/copilot-chat-user-message-renderer.component.ts +37 -0
  101. package/src/components/chat/copilot-chat-user-message-toolbar.component.ts +37 -0
  102. package/src/components/chat/copilot-chat-user-message.component.ts +247 -0
  103. package/src/components/chat/copilot-chat-user-message.types.ts +42 -0
  104. package/src/components/chat/copilot-chat-view-disclaimer.component.ts +51 -0
  105. package/src/components/chat/copilot-chat-view-feather.component.ts +47 -0
  106. package/src/components/chat/copilot-chat-view-handlers.service.ts +14 -0
  107. package/src/components/chat/copilot-chat-view-input-container.component.ts +87 -0
  108. package/src/components/chat/copilot-chat-view-scroll-to-bottom-button.component.ts +79 -0
  109. package/src/components/chat/copilot-chat-view-scroll-view.component.ts +322 -0
  110. package/src/components/chat/copilot-chat-view.component.ts +420 -0
  111. package/src/components/chat/copilot-chat-view.types.ts +52 -0
  112. package/src/components/chat/copilot-chat.component.ts +232 -0
  113. package/src/components/copilotkit-tool-render.component.ts +169 -0
  114. package/src/core/__tests__/copilotkit.service.spec.ts +1051 -0
  115. package/src/core/__tests__/copilotkit.service.wildcard.spec.ts +316 -0
  116. package/src/core/chat-configuration/__tests__/chat-configuration.service.spec.ts +287 -0
  117. package/src/core/chat-configuration/chat-configuration.providers.ts +71 -0
  118. package/src/core/chat-configuration/chat-configuration.service.ts +162 -0
  119. package/src/core/chat-configuration/chat-configuration.types.ts +57 -0
  120. package/src/core/copilotkit.providers.ts +59 -0
  121. package/src/core/copilotkit.service.ts +542 -0
  122. package/src/core/copilotkit.types.ts +132 -0
  123. package/src/directives/__tests__/copilotkit-agent-context.directive.spec.ts +384 -0
  124. package/src/directives/__tests__/copilotkit-agent.directive.spec.ts +253 -0
  125. package/src/directives/__tests__/copilotkit-chat-config.directive.spec.ts +385 -0
  126. package/src/directives/__tests__/copilotkit-config.directive.spec.ts +69 -0
  127. package/src/directives/__tests__/copilotkit-frontend-tool-simple.directive.spec.ts +60 -0
  128. package/src/directives/__tests__/copilotkit-frontend-tool.directive.spec.ts +108 -0
  129. package/src/directives/__tests__/copilotkit-human-in-the-loop.directive.spec.ts +452 -0
  130. package/src/directives/copilotkit-agent-context.directive.ts +138 -0
  131. package/src/directives/copilotkit-agent.directive.ts +225 -0
  132. package/src/directives/copilotkit-chat-config.directive.ts +241 -0
  133. package/src/directives/copilotkit-config.directive.ts +81 -0
  134. package/src/directives/copilotkit-frontend-tool.directive.ts +145 -0
  135. package/src/directives/copilotkit-human-in-the-loop.directive.ts +281 -0
  136. package/src/directives/stick-to-bottom.directive.ts +204 -0
  137. package/src/index.ts +105 -0
  138. package/src/lib/directives/tooltip.directive.ts +292 -0
  139. package/src/lib/slots/__tests__/slot.utils.spec.ts +377 -0
  140. package/src/lib/slots/copilot-slot.component.ts +135 -0
  141. package/src/lib/slots/index.ts +3 -0
  142. package/src/lib/slots/slot.types.ts +64 -0
  143. package/src/lib/slots/slot.utils.ts +289 -0
  144. package/src/lib/utils.ts +10 -0
  145. package/src/public-api.ts +1 -0
  146. package/src/services/resize-observer.service.ts +181 -0
  147. package/src/services/scroll-position.service.ts +169 -0
  148. package/src/styles/globals.css +266 -0
  149. package/src/styles/index.css +3 -0
  150. package/src/test-setup.ts +15 -0
  151. package/src/testing/index.ts +3 -0
  152. package/src/testing/testing.utils.ts +248 -0
  153. package/src/types/frontend-tool.ts +44 -0
  154. package/src/types/human-in-the-loop.ts +52 -0
  155. package/src/utils/__tests__/agent.utils.spec.ts +234 -0
  156. package/src/utils/__tests__/chat-config.utils.spec.ts +306 -0
  157. package/src/utils/__tests__/frontend-tool-inject.spec.ts +350 -0
  158. package/src/utils/__tests__/frontend-tool-integration.spec.ts +199 -0
  159. package/src/utils/__tests__/frontend-tool.utils.spec.ts +272 -0
  160. package/src/utils/__tests__/human-in-the-loop.utils.spec.ts +365 -0
  161. package/src/utils/agent-context.utils.ts +133 -0
  162. package/src/utils/agent.utils.ts +239 -0
  163. package/src/utils/chat-config.utils.ts +221 -0
  164. package/src/utils/copilotkit.utils.ts +20 -0
  165. package/src/utils/frontend-tool.utils.ts +266 -0
  166. package/src/utils/human-in-the-loop.utils.ts +359 -0
  167. package/tsconfig.json +33 -0
  168. package/tsconfig.spec.json +12 -0
  169. package/vitest.config.mts +34 -0
@@ -0,0 +1,463 @@
1
+ import {
2
+ Component,
3
+ Input,
4
+ Output,
5
+ EventEmitter,
6
+ TemplateRef,
7
+ ContentChild,
8
+ signal,
9
+ computed,
10
+ Type,
11
+ ChangeDetectionStrategy,
12
+ ViewEncapsulation,
13
+ Optional,
14
+ Inject
15
+ } from '@angular/core';
16
+ import { CommonModule } from '@angular/common';
17
+ import { CopilotSlotComponent } from '../../lib/slots/copilot-slot.component';
18
+ import { CopilotChatToolCallsViewComponent } from './copilot-chat-tool-calls-view.component';
19
+ import type { Message } from '@ag-ui/core';
20
+ import {
21
+ type AssistantMessage,
22
+ type CopilotChatAssistantMessageOnThumbsUpProps,
23
+ type CopilotChatAssistantMessageOnThumbsDownProps,
24
+ type CopilotChatAssistantMessageOnReadAloudProps,
25
+ type CopilotChatAssistantMessageOnRegenerateProps,
26
+ type AssistantMessageMarkdownRendererContext,
27
+ type AssistantMessageCopyButtonContext,
28
+ type ThumbsUpButtonContext,
29
+ type ThumbsDownButtonContext,
30
+ type ReadAloudButtonContext,
31
+ type RegenerateButtonContext,
32
+ type AssistantMessageToolbarContext
33
+ } from './copilot-chat-assistant-message.types';
34
+ import { CopilotChatAssistantMessageRendererComponent } from './copilot-chat-assistant-message-renderer.component';
35
+ import {
36
+ CopilotChatAssistantMessageCopyButtonComponent,
37
+ CopilotChatAssistantMessageThumbsUpButtonComponent,
38
+ CopilotChatAssistantMessageThumbsDownButtonComponent,
39
+ CopilotChatAssistantMessageReadAloudButtonComponent,
40
+ CopilotChatAssistantMessageRegenerateButtonComponent
41
+ } from './copilot-chat-assistant-message-buttons.component';
42
+ import { CopilotChatAssistantMessageToolbarComponent } from './copilot-chat-assistant-message-toolbar.component';
43
+ import { cn } from '../../lib/utils';
44
+ import { CopilotChatViewHandlersService } from './copilot-chat-view-handlers.service';
45
+
46
+ @Component({
47
+ selector: 'copilot-chat-assistant-message',
48
+ standalone: true,
49
+ imports: [
50
+ CommonModule,
51
+ CopilotSlotComponent,
52
+ CopilotChatAssistantMessageRendererComponent,
53
+ CopilotChatAssistantMessageCopyButtonComponent,
54
+ CopilotChatAssistantMessageThumbsUpButtonComponent,
55
+ CopilotChatAssistantMessageThumbsDownButtonComponent,
56
+ CopilotChatAssistantMessageReadAloudButtonComponent,
57
+ CopilotChatAssistantMessageRegenerateButtonComponent,
58
+ CopilotChatAssistantMessageToolbarComponent,
59
+ CopilotChatToolCallsViewComponent
60
+ ],
61
+ changeDetection: ChangeDetectionStrategy.OnPush,
62
+ encapsulation: ViewEncapsulation.None,
63
+ template: `
64
+ <div
65
+ [class]="computedClass()"
66
+ [attr.data-message-id]="message?.id">
67
+
68
+ <!-- Markdown Renderer -->
69
+ @if (markdownRendererTemplate || markdownRendererComponent) {
70
+ <copilot-slot
71
+ [slot]="markdownRendererTemplate || markdownRendererComponent"
72
+ [context]="markdownRendererContext()"
73
+ [defaultComponent]="CopilotChatAssistantMessageRendererComponent"
74
+ >
75
+ </copilot-slot>
76
+ } @else {
77
+ <copilot-chat-assistant-message-renderer
78
+ [content]="message?.content || ''"
79
+ [inputClass]="markdownRendererClass">
80
+ </copilot-chat-assistant-message-renderer>
81
+ }
82
+
83
+ <!-- Tool Calls View -->
84
+ @if (toolCallsViewTemplate || toolCallsViewComponent) {
85
+ <copilot-slot
86
+ [slot]="toolCallsViewTemplate || toolCallsViewComponent"
87
+ [context]="toolCallsViewContext()"
88
+ [defaultComponent]="CopilotChatToolCallsViewComponent">
89
+ </copilot-slot>
90
+ } @else if (message?.toolCalls && message.toolCalls.length > 0) {
91
+ <copilot-chat-tool-calls-view
92
+ [message]="message"
93
+ [messages]="messages"
94
+ [isLoading]="isLoading">
95
+ </copilot-chat-tool-calls-view>
96
+ }
97
+
98
+ <!-- Toolbar -->
99
+ <ng-container *ngIf="toolbarVisible">
100
+ @if (toolbarTemplate || toolbarComponent) {
101
+ <copilot-slot
102
+ [slot]="toolbarTemplate || toolbarComponent"
103
+ [context]="toolbarContext()"
104
+ [defaultComponent]="CopilotChatAssistantMessageToolbarComponent"
105
+ >
106
+ </copilot-slot>
107
+ } @else {
108
+ <div copilotChatAssistantMessageToolbar [inputClass]="toolbarClass">
109
+ <div class="flex items-center gap-1">
110
+ <!-- Copy button -->
111
+ @if (copyButtonTemplate || copyButtonComponent) {
112
+ <copilot-slot
113
+ [slot]="copyButtonTemplate || copyButtonComponent"
114
+ [context]="{ content: message?.content || '' }"
115
+ [defaultComponent]="CopilotChatAssistantMessageCopyButtonComponent"
116
+ [outputs]="copyButtonOutputs"
117
+ >
118
+ </copilot-slot>
119
+ } @else {
120
+ <copilot-chat-assistant-message-copy-button
121
+ [content]="message?.content"
122
+ [inputClass]="copyButtonClass"
123
+ (clicked)="handleCopy()">
124
+ </copilot-chat-assistant-message-copy-button>
125
+ }
126
+
127
+ <!-- Thumbs up button - show if custom slot provided OR if handler available at top level -->
128
+ @if (thumbsUpButtonComponent || thumbsUpButtonTemplate || handlers.hasAssistantThumbsUpHandler()) {
129
+ <copilot-slot
130
+ [slot]="thumbsUpButtonTemplate || thumbsUpButtonComponent"
131
+ [context]="{}"
132
+ [defaultComponent]="defaultThumbsUpButtonComponent"
133
+ [outputs]="thumbsUpButtonOutputs">
134
+ </copilot-slot>
135
+ }
136
+
137
+ <!-- Thumbs down button - show if custom slot provided OR if handler available at top level -->
138
+ @if (thumbsDownButtonComponent || thumbsDownButtonTemplate || handlers.hasAssistantThumbsDownHandler()) {
139
+ <copilot-slot
140
+ [slot]="thumbsDownButtonTemplate || thumbsDownButtonComponent"
141
+ [context]="{}"
142
+ [defaultComponent]="defaultThumbsDownButtonComponent"
143
+ [outputs]="thumbsDownButtonOutputs">
144
+ </copilot-slot>
145
+ }
146
+
147
+ <!-- Read aloud button - only show if custom slot provided -->
148
+ @if (readAloudButtonComponent || readAloudButtonTemplate) {
149
+ <copilot-slot
150
+ [slot]="readAloudButtonTemplate || readAloudButtonComponent"
151
+ [context]="{}"
152
+ [outputs]="readAloudButtonOutputs"
153
+ >
154
+ </copilot-slot>
155
+ }
156
+
157
+ <!-- Regenerate button - only show if custom slot provided -->
158
+ @if (regenerateButtonComponent || regenerateButtonTemplate) {
159
+ <copilot-slot
160
+ [slot]="regenerateButtonTemplate || regenerateButtonComponent"
161
+ [context]="{}"
162
+ [outputs]="regenerateButtonOutputs"
163
+ >
164
+ </copilot-slot>
165
+ }
166
+
167
+ <!-- Additional toolbar items -->
168
+ @if (additionalToolbarItems) {
169
+ <ng-container *ngTemplateOutlet="additionalToolbarItems"></ng-container>
170
+ }
171
+ </div>
172
+ </div>
173
+ }
174
+ </ng-container>
175
+ </div>
176
+ `,
177
+ styles: [`
178
+ /* Import KaTeX styles */
179
+ @import 'katex/dist/katex.min.css';
180
+
181
+ :host {
182
+ display: block;
183
+ width: 100%;
184
+ }
185
+
186
+ /* Atom One Light theme for highlight.js */
187
+ .hljs {
188
+ color: rgb(56, 58, 66);
189
+ background: transparent;
190
+ }
191
+
192
+ .hljs-comment,
193
+ .hljs-quote {
194
+ color: #a0a1a7;
195
+ font-style: italic;
196
+ }
197
+
198
+ .hljs-doctag,
199
+ .hljs-formula,
200
+ .hljs-keyword {
201
+ color: #a626a4;
202
+ }
203
+
204
+ .hljs-deletion,
205
+ .hljs-name,
206
+ .hljs-section,
207
+ .hljs-selector-tag,
208
+ .hljs-subst {
209
+ color: #e45649;
210
+ }
211
+
212
+ .hljs-literal {
213
+ color: #0184bb;
214
+ }
215
+
216
+ .hljs-addition,
217
+ .hljs-attribute,
218
+ .hljs-meta .hljs-string,
219
+ .hljs-regexp,
220
+ .hljs-string {
221
+ color: #50a14f;
222
+ }
223
+
224
+ .hljs-attr,
225
+ .hljs-number,
226
+ .hljs-selector-attr,
227
+ .hljs-selector-class,
228
+ .hljs-selector-pseudo,
229
+ .hljs-template-variable,
230
+ .hljs-type,
231
+ .hljs-variable {
232
+ color: #986801;
233
+ }
234
+
235
+ .hljs-params {
236
+ color: rgb(56, 58, 66);
237
+ }
238
+
239
+ .hljs-bullet,
240
+ .hljs-link,
241
+ .hljs-meta,
242
+ .hljs-selector-id,
243
+ .hljs-symbol,
244
+ .hljs-title {
245
+ color: #4078f2;
246
+ }
247
+
248
+ .hljs-built_in,
249
+ .hljs-class .hljs-title,
250
+ .hljs-title.class_ {
251
+ color: #c18401;
252
+ }
253
+
254
+ .hljs-emphasis {
255
+ font-style: italic;
256
+ }
257
+
258
+ .hljs-strong {
259
+ font-weight: 700;
260
+ }
261
+
262
+ .hljs-link {
263
+ text-decoration: underline;
264
+ }
265
+
266
+ /* Atom One Dark theme for highlight.js */
267
+ .dark .hljs {
268
+ color: #abb2bf;
269
+ background: transparent;
270
+ }
271
+
272
+ .dark .hljs-comment,
273
+ .dark .hljs-quote {
274
+ color: #5c6370;
275
+ font-style: italic;
276
+ }
277
+
278
+ .dark .hljs-doctag,
279
+ .dark .hljs-formula,
280
+ .dark .hljs-keyword {
281
+ color: #c678dd;
282
+ }
283
+
284
+ .dark .hljs-deletion,
285
+ .dark .hljs-name,
286
+ .dark .hljs-section,
287
+ .dark .hljs-selector-tag,
288
+ .dark .hljs-subst {
289
+ color: #e06c75;
290
+ }
291
+
292
+ .dark .hljs-literal {
293
+ color: #56b6c2;
294
+ }
295
+
296
+ .dark .hljs-addition,
297
+ .dark .hljs-attribute,
298
+ .dark .hljs-meta .hljs-string,
299
+ .dark .hljs-regexp,
300
+ .dark .hljs-string {
301
+ color: #98c379;
302
+ }
303
+
304
+ .dark .hljs-attr,
305
+ .dark .hljs-number,
306
+ .dark .hljs-selector-attr,
307
+ .dark .hljs-selector-class,
308
+ .dark .hljs-selector-pseudo,
309
+ .dark .hljs-template-variable,
310
+ .dark .hljs-type,
311
+ .dark .hljs-variable {
312
+ color: #d19a66;
313
+ }
314
+
315
+ .dark .hljs-bullet,
316
+ .dark .hljs-link,
317
+ .dark .hljs-meta,
318
+ .dark .hljs-selector-id,
319
+ .dark .hljs-symbol,
320
+ .dark .hljs-title {
321
+ color: #61aeee;
322
+ }
323
+
324
+ .dark .hljs-built_in,
325
+ .dark .hljs-class .hljs-title,
326
+ .dark .hljs-title.class_ {
327
+ color: #e6c07b;
328
+ }
329
+
330
+ .dark .hljs-params {
331
+ color: #abb2bf; /* same as regular text */
332
+ }
333
+
334
+ .dark .hljs-emphasis {
335
+ font-style: italic;
336
+ }
337
+
338
+ .dark .hljs-strong {
339
+ font-weight: 700;
340
+ }
341
+
342
+ .dark .hljs-link {
343
+ text-decoration: underline;
344
+ }
345
+ `]
346
+ })
347
+ export class CopilotChatAssistantMessageComponent {
348
+ // Capture templates from content projection
349
+ @ContentChild('markdownRenderer', { read: TemplateRef }) markdownRendererTemplate?: TemplateRef<AssistantMessageMarkdownRendererContext>;
350
+ @ContentChild('toolbar', { read: TemplateRef }) toolbarTemplate?: TemplateRef<AssistantMessageToolbarContext>;
351
+ @ContentChild('copyButton', { read: TemplateRef }) copyButtonTemplate?: TemplateRef<AssistantMessageCopyButtonContext>;
352
+ @ContentChild('thumbsUpButton', { read: TemplateRef }) thumbsUpButtonTemplate?: TemplateRef<ThumbsUpButtonContext>;
353
+ @ContentChild('thumbsDownButton', { read: TemplateRef }) thumbsDownButtonTemplate?: TemplateRef<ThumbsDownButtonContext>;
354
+ @ContentChild('readAloudButton', { read: TemplateRef }) readAloudButtonTemplate?: TemplateRef<ReadAloudButtonContext>;
355
+ @ContentChild('regenerateButton', { read: TemplateRef }) regenerateButtonTemplate?: TemplateRef<RegenerateButtonContext>;
356
+ @ContentChild('toolCallsView', { read: TemplateRef }) toolCallsViewTemplate?: TemplateRef<any>;
357
+
358
+ // Class inputs for styling default components
359
+ @Input() markdownRendererClass?: string;
360
+ @Input() toolbarClass?: string;
361
+ @Input() copyButtonClass?: string;
362
+ @Input() thumbsUpButtonClass?: string;
363
+ @Input() thumbsDownButtonClass?: string;
364
+ @Input() readAloudButtonClass?: string;
365
+ @Input() regenerateButtonClass?: string;
366
+ @Input() toolCallsViewClass?: string;
367
+
368
+ // Component inputs for overrides
369
+ @Input() markdownRendererComponent?: Type<any>;
370
+ @Input() toolbarComponent?: Type<any>;
371
+ @Input() copyButtonComponent?: Type<any>;
372
+ @Input() thumbsUpButtonComponent?: Type<any>;
373
+ @Input() thumbsDownButtonComponent?: Type<any>;
374
+ @Input() readAloudButtonComponent?: Type<any>;
375
+ @Input() regenerateButtonComponent?: Type<any>;
376
+ @Input() toolCallsViewComponent?: Type<any>;
377
+
378
+ // Regular inputs
379
+ @Input() message!: AssistantMessage;
380
+ @Input() messages: Message[] = [];
381
+ @Input() isLoading = false;
382
+ @Input() additionalToolbarItems?: TemplateRef<any>;
383
+ @Input() toolbarVisible = true;
384
+ @Input() set inputClass(val: string | undefined) {
385
+ this.customClass.set(val);
386
+ }
387
+
388
+ // DI service exposes handler availability scoped to CopilotChatView
389
+ // Make it optional with a default fallback for testing
390
+ handlers: CopilotChatViewHandlersService;
391
+
392
+ constructor(@Optional() @Inject(CopilotChatViewHandlersService) handlers?: CopilotChatViewHandlersService | null) {
393
+ this.handlers = handlers || new CopilotChatViewHandlersService();
394
+ }
395
+
396
+ // Output events
397
+ @Output() thumbsUp = new EventEmitter<CopilotChatAssistantMessageOnThumbsUpProps>();
398
+ @Output() thumbsDown = new EventEmitter<CopilotChatAssistantMessageOnThumbsDownProps>();
399
+ @Output() readAloud = new EventEmitter<CopilotChatAssistantMessageOnReadAloudProps>();
400
+ @Output() regenerate = new EventEmitter<CopilotChatAssistantMessageOnRegenerateProps>();
401
+
402
+ // Signals
403
+ customClass = signal<string | undefined>(undefined);
404
+
405
+ // Computed values
406
+ computedClass = computed(() => {
407
+ return cn(
408
+ "prose max-w-full break-words dark:prose-invert",
409
+ this.customClass()
410
+ );
411
+ });
412
+
413
+ // Default components
414
+ protected readonly defaultThumbsUpButtonComponent = CopilotChatAssistantMessageThumbsUpButtonComponent;
415
+ protected readonly defaultThumbsDownButtonComponent = CopilotChatAssistantMessageThumbsDownButtonComponent;
416
+ protected readonly CopilotChatAssistantMessageRendererComponent = CopilotChatAssistantMessageRendererComponent;
417
+ protected readonly CopilotChatAssistantMessageToolbarComponent = CopilotChatAssistantMessageToolbarComponent;
418
+ protected readonly CopilotChatAssistantMessageCopyButtonComponent = CopilotChatAssistantMessageCopyButtonComponent;
419
+ protected readonly CopilotChatToolCallsViewComponent = CopilotChatToolCallsViewComponent;
420
+
421
+ // Context for slots (reactive via signals)
422
+ markdownRendererContext = computed<AssistantMessageMarkdownRendererContext>(() => ({
423
+ content: this.message?.content || ''
424
+ }));
425
+
426
+ // Output maps for slots
427
+ copyButtonOutputs = { clicked: () => this.handleCopy() };
428
+ thumbsUpButtonOutputs = { clicked: () => this.handleThumbsUp() };
429
+ thumbsDownButtonOutputs = { clicked: () => this.handleThumbsDown() };
430
+ readAloudButtonOutputs = { clicked: () => this.handleReadAloud() };
431
+ regenerateButtonOutputs = { clicked: () => this.handleRegenerate() };
432
+
433
+ toolbarContext = computed<AssistantMessageToolbarContext>(() => ({
434
+ children: null // Will be populated by the toolbar content
435
+ }));
436
+
437
+ toolCallsViewContext = computed(() => ({
438
+ message: this.message,
439
+ messages: this.messages,
440
+ isLoading: this.isLoading
441
+ }));
442
+
443
+ handleCopy(): void {
444
+ // Copy is handled by the button component itself
445
+ // This is just for any additional logic if needed
446
+ }
447
+
448
+ handleThumbsUp(): void {
449
+ this.thumbsUp.emit({ message: this.message });
450
+ }
451
+
452
+ handleThumbsDown(): void {
453
+ this.thumbsDown.emit({ message: this.message });
454
+ }
455
+
456
+ handleReadAloud(): void {
457
+ this.readAloud.emit({ message: this.message });
458
+ }
459
+
460
+ handleRegenerate(): void {
461
+ this.regenerate.emit({ message: this.message });
462
+ }
463
+ }
@@ -0,0 +1,50 @@
1
+ import { AssistantMessage } from '@ag-ui/client';
2
+
3
+ // Context interfaces for slots
4
+ export interface AssistantMessageMarkdownRendererContext {
5
+ content: string;
6
+ }
7
+
8
+ export interface AssistantMessageToolbarContext {
9
+ children?: any;
10
+ }
11
+
12
+ export interface AssistantMessageCopyButtonContext {
13
+ content?: string;
14
+ }
15
+
16
+ export interface ThumbsUpButtonContext {
17
+ // Empty context - click handled via outputs map
18
+ }
19
+
20
+ export interface ThumbsDownButtonContext {
21
+ // Empty context - click handled via outputs map
22
+ }
23
+
24
+ export interface ReadAloudButtonContext {
25
+ // Empty context - click handled via outputs map
26
+ }
27
+
28
+ export interface RegenerateButtonContext {
29
+ // Empty context - click handled via outputs map
30
+ }
31
+
32
+ // Event handler props
33
+ export interface CopilotChatAssistantMessageOnThumbsUpProps {
34
+ message: AssistantMessage;
35
+ }
36
+
37
+ export interface CopilotChatAssistantMessageOnThumbsDownProps {
38
+ message: AssistantMessage;
39
+ }
40
+
41
+ export interface CopilotChatAssistantMessageOnReadAloudProps {
42
+ message: AssistantMessage;
43
+ }
44
+
45
+ export interface CopilotChatAssistantMessageOnRegenerateProps {
46
+ message: AssistantMessage;
47
+ }
48
+
49
+ // Re-export for convenience
50
+ export type { AssistantMessage };