@copilotkitnext/angular 0.0.2 → 0.0.4

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 (168) hide show
  1. package/README.md +3 -3
  2. package/dist/README.md +3 -3
  3. package/dist/components/chat/copilot-chat-assistant-message.component.d.ts +10 -10
  4. package/dist/components/chat/copilot-chat-message-view.component.d.ts +42 -42
  5. package/dist/components/chat/copilot-chat-view.component.d.ts +14 -14
  6. package/dist/esm2022/components/chat/copilot-chat-assistant-message-buttons.component.mjs +384 -0
  7. package/dist/esm2022/components/chat/copilot-chat-assistant-message-renderer.component.mjs +286 -0
  8. package/dist/esm2022/components/chat/copilot-chat-assistant-message-toolbar.component.mjs +27 -0
  9. package/dist/esm2022/components/chat/copilot-chat-assistant-message.component.mjs +433 -0
  10. package/dist/esm2022/components/chat/copilot-chat-assistant-message.types.mjs +2 -0
  11. package/dist/esm2022/components/chat/copilot-chat-audio-recorder.component.mjs +202 -0
  12. package/dist/esm2022/components/chat/copilot-chat-buttons.component.mjs +321 -0
  13. package/dist/esm2022/components/chat/copilot-chat-input-defaults.mjs +38 -0
  14. package/dist/esm2022/components/chat/copilot-chat-input.component.mjs +666 -0
  15. package/dist/esm2022/components/chat/copilot-chat-input.types.mjs +10 -0
  16. package/dist/esm2022/components/chat/copilot-chat-message-view-cursor.component.mjs +45 -0
  17. package/dist/esm2022/components/chat/copilot-chat-message-view.component.mjs +296 -0
  18. package/dist/esm2022/components/chat/copilot-chat-message-view.types.mjs +2 -0
  19. package/dist/esm2022/components/chat/copilot-chat-textarea.component.mjs +188 -0
  20. package/dist/esm2022/components/chat/copilot-chat-tool-calls-view.component.mjs +216 -0
  21. package/dist/esm2022/components/chat/copilot-chat-toolbar.component.mjs +25 -0
  22. package/dist/esm2022/components/chat/copilot-chat-tools-menu.component.mjs +199 -0
  23. package/dist/esm2022/components/chat/copilot-chat-user-message-branch-navigation.component.mjs +137 -0
  24. package/dist/esm2022/components/chat/copilot-chat-user-message-buttons.component.mjs +207 -0
  25. package/dist/esm2022/components/chat/copilot-chat-user-message-renderer.component.mjs +35 -0
  26. package/dist/esm2022/components/chat/copilot-chat-user-message-toolbar.component.mjs +34 -0
  27. package/dist/esm2022/components/chat/copilot-chat-user-message.component.mjs +341 -0
  28. package/dist/esm2022/components/chat/copilot-chat-user-message.types.mjs +2 -0
  29. package/dist/esm2022/components/chat/copilot-chat-view-disclaimer.component.mjs +52 -0
  30. package/dist/esm2022/components/chat/copilot-chat-view-feather.component.mjs +55 -0
  31. package/dist/esm2022/components/chat/copilot-chat-view-handlers.service.mjs +19 -0
  32. package/dist/esm2022/components/chat/copilot-chat-view-input-container.component.mjs +110 -0
  33. package/dist/esm2022/components/chat/copilot-chat-view-scroll-to-bottom-button.component.mjs +93 -0
  34. package/dist/esm2022/components/chat/copilot-chat-view-scroll-view.component.mjs +443 -0
  35. package/dist/esm2022/components/chat/copilot-chat-view.component.mjs +479 -0
  36. package/dist/esm2022/components/chat/copilot-chat-view.types.mjs +2 -0
  37. package/dist/esm2022/components/chat/copilot-chat.component.mjs +214 -0
  38. package/dist/esm2022/components/copilotkit-tool-render.component.mjs +153 -0
  39. package/dist/esm2022/copilotkitnext-angular.mjs +5 -0
  40. package/dist/esm2022/core/chat-configuration/chat-configuration.providers.mjs +65 -0
  41. package/dist/esm2022/core/chat-configuration/chat-configuration.service.mjs +145 -0
  42. package/dist/esm2022/core/chat-configuration/chat-configuration.types.mjs +26 -0
  43. package/dist/esm2022/core/copilotkit.providers.mjs +34 -0
  44. package/dist/esm2022/core/copilotkit.service.mjs +430 -0
  45. package/dist/esm2022/core/copilotkit.types.mjs +12 -0
  46. package/dist/esm2022/directives/copilotkit-agent-context.directive.mjs +130 -0
  47. package/dist/esm2022/directives/copilotkit-agent.directive.mjs +217 -0
  48. package/dist/esm2022/directives/copilotkit-chat-config.directive.mjs +218 -0
  49. package/dist/esm2022/directives/copilotkit-config.directive.mjs +94 -0
  50. package/dist/esm2022/directives/copilotkit-frontend-tool.directive.mjs +130 -0
  51. package/dist/esm2022/directives/copilotkit-human-in-the-loop.directive.mjs +266 -0
  52. package/dist/esm2022/directives/stick-to-bottom.directive.mjs +181 -0
  53. package/dist/esm2022/index.mjs +70 -0
  54. package/dist/esm2022/lib/directives/tooltip.directive.mjs +211 -0
  55. package/dist/esm2022/lib/slots/copilot-slot.component.mjs +144 -0
  56. package/dist/esm2022/lib/slots/slot.types.mjs +6 -0
  57. package/dist/esm2022/lib/slots/slot.utils.mjs +222 -0
  58. package/dist/esm2022/lib/utils.mjs +10 -0
  59. package/dist/esm2022/services/resize-observer.service.mjs +152 -0
  60. package/dist/esm2022/services/scroll-position.service.mjs +124 -0
  61. package/dist/esm2022/types/frontend-tool.mjs +2 -0
  62. package/dist/esm2022/types/human-in-the-loop.mjs +2 -0
  63. package/dist/esm2022/utils/agent-context.utils.mjs +114 -0
  64. package/dist/esm2022/utils/agent.utils.mjs +204 -0
  65. package/dist/esm2022/utils/chat-config.utils.mjs +186 -0
  66. package/dist/esm2022/utils/copilotkit.utils.mjs +20 -0
  67. package/dist/esm2022/utils/frontend-tool.utils.mjs +228 -0
  68. package/dist/esm2022/utils/human-in-the-loop.utils.mjs +296 -0
  69. package/dist/fesm2022/copilotkitnext-angular.mjs +163 -164
  70. package/dist/fesm2022/copilotkitnext-angular.mjs.map +1 -1
  71. package/package.json +21 -18
  72. package/vitest.config.mts +32 -21
  73. package/.turbo/turbo-build.log +0 -38
  74. package/.turbo/turbo-check-types.log +0 -0
  75. package/.turbo/turbo-test.log +0 -71
  76. package/ng-package.json +0 -19
  77. package/src/components/chat/__tests__/copilot-chat-assistant-message.component.spec.ts +0 -282
  78. package/src/components/chat/__tests__/copilot-chat-input.component.spec.ts +0 -419
  79. package/src/components/chat/__tests__/copilot-chat-message-view.component.spec.ts +0 -372
  80. package/src/components/chat/__tests__/copilot-chat-user-message.component.spec.ts +0 -249
  81. package/src/components/chat/copilot-chat-assistant-message-buttons.component.ts +0 -292
  82. package/src/components/chat/copilot-chat-assistant-message-renderer.component.ts +0 -472
  83. package/src/components/chat/copilot-chat-assistant-message-toolbar.component.ts +0 -29
  84. package/src/components/chat/copilot-chat-assistant-message.component.ts +0 -463
  85. package/src/components/chat/copilot-chat-assistant-message.types.ts +0 -50
  86. package/src/components/chat/copilot-chat-audio-recorder.component.ts +0 -241
  87. package/src/components/chat/copilot-chat-buttons.component.ts +0 -308
  88. package/src/components/chat/copilot-chat-buttons.component.ts.bak +0 -471
  89. package/src/components/chat/copilot-chat-input-defaults.ts +0 -47
  90. package/src/components/chat/copilot-chat-input.component.ts +0 -512
  91. package/src/components/chat/copilot-chat-input.types.ts +0 -148
  92. package/src/components/chat/copilot-chat-message-view-cursor.component.ts +0 -51
  93. package/src/components/chat/copilot-chat-message-view.component.ts +0 -233
  94. package/src/components/chat/copilot-chat-message-view.types.ts +0 -39
  95. package/src/components/chat/copilot-chat-textarea.component.ts +0 -220
  96. package/src/components/chat/copilot-chat-tool-calls-view.component.ts +0 -261
  97. package/src/components/chat/copilot-chat-toolbar.component.ts +0 -35
  98. package/src/components/chat/copilot-chat-tools-menu.component.ts +0 -185
  99. package/src/components/chat/copilot-chat-user-message-branch-navigation.component.ts +0 -121
  100. package/src/components/chat/copilot-chat-user-message-buttons.component.ts +0 -170
  101. package/src/components/chat/copilot-chat-user-message-renderer.component.ts +0 -37
  102. package/src/components/chat/copilot-chat-user-message-toolbar.component.ts +0 -37
  103. package/src/components/chat/copilot-chat-user-message.component.ts +0 -247
  104. package/src/components/chat/copilot-chat-user-message.types.ts +0 -42
  105. package/src/components/chat/copilot-chat-view-disclaimer.component.ts +0 -51
  106. package/src/components/chat/copilot-chat-view-feather.component.ts +0 -47
  107. package/src/components/chat/copilot-chat-view-handlers.service.ts +0 -14
  108. package/src/components/chat/copilot-chat-view-input-container.component.ts +0 -87
  109. package/src/components/chat/copilot-chat-view-scroll-to-bottom-button.component.ts +0 -79
  110. package/src/components/chat/copilot-chat-view-scroll-view.component.ts +0 -322
  111. package/src/components/chat/copilot-chat-view.component.ts +0 -420
  112. package/src/components/chat/copilot-chat-view.types.ts +0 -52
  113. package/src/components/chat/copilot-chat.component.ts +0 -232
  114. package/src/components/copilotkit-tool-render.component.ts +0 -169
  115. package/src/core/__tests__/copilotkit.service.spec.ts +0 -1051
  116. package/src/core/__tests__/copilotkit.service.wildcard.spec.ts +0 -316
  117. package/src/core/chat-configuration/__tests__/chat-configuration.service.spec.ts +0 -287
  118. package/src/core/chat-configuration/chat-configuration.providers.ts +0 -71
  119. package/src/core/chat-configuration/chat-configuration.service.ts +0 -162
  120. package/src/core/chat-configuration/chat-configuration.types.ts +0 -57
  121. package/src/core/copilotkit.providers.ts +0 -59
  122. package/src/core/copilotkit.service.ts +0 -542
  123. package/src/core/copilotkit.types.ts +0 -132
  124. package/src/directives/__tests__/copilotkit-agent-context.directive.spec.ts +0 -384
  125. package/src/directives/__tests__/copilotkit-agent.directive.spec.ts +0 -253
  126. package/src/directives/__tests__/copilotkit-chat-config.directive.spec.ts +0 -385
  127. package/src/directives/__tests__/copilotkit-config.directive.spec.ts +0 -69
  128. package/src/directives/__tests__/copilotkit-frontend-tool-simple.directive.spec.ts +0 -60
  129. package/src/directives/__tests__/copilotkit-frontend-tool.directive.spec.ts +0 -108
  130. package/src/directives/__tests__/copilotkit-human-in-the-loop.directive.spec.ts +0 -452
  131. package/src/directives/copilotkit-agent-context.directive.ts +0 -138
  132. package/src/directives/copilotkit-agent.directive.ts +0 -225
  133. package/src/directives/copilotkit-chat-config.directive.ts +0 -241
  134. package/src/directives/copilotkit-config.directive.ts +0 -81
  135. package/src/directives/copilotkit-frontend-tool.directive.ts +0 -145
  136. package/src/directives/copilotkit-human-in-the-loop.directive.ts +0 -281
  137. package/src/directives/stick-to-bottom.directive.ts +0 -204
  138. package/src/index.ts +0 -105
  139. package/src/lib/directives/tooltip.directive.ts +0 -292
  140. package/src/lib/slots/__tests__/slot.utils.spec.ts +0 -377
  141. package/src/lib/slots/copilot-slot.component.ts +0 -135
  142. package/src/lib/slots/index.ts +0 -3
  143. package/src/lib/slots/slot.types.ts +0 -64
  144. package/src/lib/slots/slot.utils.ts +0 -289
  145. package/src/lib/utils.ts +0 -10
  146. package/src/public-api.ts +0 -1
  147. package/src/services/resize-observer.service.ts +0 -181
  148. package/src/services/scroll-position.service.ts +0 -169
  149. package/src/styles/globals.css +0 -266
  150. package/src/styles/index.css +0 -3
  151. package/src/test-setup.ts +0 -15
  152. package/src/testing/index.ts +0 -3
  153. package/src/testing/testing.utils.ts +0 -248
  154. package/src/types/frontend-tool.ts +0 -44
  155. package/src/types/human-in-the-loop.ts +0 -52
  156. package/src/utils/__tests__/agent.utils.spec.ts +0 -234
  157. package/src/utils/__tests__/chat-config.utils.spec.ts +0 -306
  158. package/src/utils/__tests__/frontend-tool-inject.spec.ts +0 -350
  159. package/src/utils/__tests__/frontend-tool-integration.spec.ts +0 -199
  160. package/src/utils/__tests__/frontend-tool.utils.spec.ts +0 -272
  161. package/src/utils/__tests__/human-in-the-loop.utils.spec.ts +0 -365
  162. package/src/utils/agent-context.utils.ts +0 -133
  163. package/src/utils/agent.utils.ts +0 -239
  164. package/src/utils/chat-config.utils.ts +0 -221
  165. package/src/utils/copilotkit.utils.ts +0 -20
  166. package/src/utils/frontend-tool.utils.ts +0 -266
  167. package/src/utils/human-in-the-loop.utils.ts +0 -359
  168. package/tsconfig.spec.json +0 -12
@@ -1,169 +0,0 @@
1
- import { Injectable, ElementRef, NgZone, OnDestroy } from '@angular/core';
2
- import { ScrollDispatcher, ViewportRuler } from '@angular/cdk/scrolling';
3
- import { Observable, Subject, BehaviorSubject, fromEvent, merge, animationFrameScheduler } from 'rxjs';
4
- import {
5
- takeUntil,
6
- debounceTime,
7
- throttleTime,
8
- distinctUntilChanged,
9
- map,
10
- observeOn,
11
- startWith
12
- } from 'rxjs/operators';
13
-
14
- export interface ScrollState {
15
- isAtBottom: boolean;
16
- scrollTop: number;
17
- scrollHeight: number;
18
- clientHeight: number;
19
- }
20
-
21
- @Injectable({
22
- providedIn: 'root'
23
- })
24
- export class ScrollPositionService implements OnDestroy {
25
- private destroy$ = new Subject<void>();
26
- private scrollStateSubject = new BehaviorSubject<ScrollState>({
27
- isAtBottom: true,
28
- scrollTop: 0,
29
- scrollHeight: 0,
30
- clientHeight: 0
31
- });
32
-
33
- public scrollState$ = this.scrollStateSubject.asObservable();
34
-
35
- constructor(
36
- private scrollDispatcher: ScrollDispatcher,
37
- private viewportRuler: ViewportRuler,
38
- private ngZone: NgZone
39
- ) {}
40
-
41
- /**
42
- * Monitor scroll position of an element
43
- * @param element The element to monitor
44
- * @param threshold Pixels from bottom to consider "at bottom" (default 10)
45
- */
46
- monitorScrollPosition(
47
- element: ElementRef<HTMLElement> | HTMLElement,
48
- threshold: number = 10
49
- ): Observable<ScrollState> {
50
- const el = element instanceof ElementRef ? element.nativeElement : element;
51
-
52
- // Create scroll observable
53
- const scroll$ = merge(
54
- fromEvent(el, 'scroll'),
55
- this.viewportRuler.change(150) // Monitor viewport changes
56
- ).pipe(
57
- startWith(null), // Emit initial state
58
- throttleTime(16, animationFrameScheduler, { trailing: true }), // ~60fps
59
- map(() => this.getScrollState(el, threshold)),
60
- distinctUntilChanged((a, b) =>
61
- a.isAtBottom === b.isAtBottom &&
62
- a.scrollTop === b.scrollTop &&
63
- a.scrollHeight === b.scrollHeight
64
- ),
65
- takeUntil(this.destroy$)
66
- );
67
-
68
- // Subscribe and update subject
69
- scroll$.subscribe(state => {
70
- this.scrollStateSubject.next(state);
71
- });
72
-
73
- return scroll$;
74
- }
75
-
76
- /**
77
- * Scroll element to bottom with smooth animation
78
- * @param element The element to scroll
79
- * @param smooth Whether to use smooth scrolling
80
- */
81
- scrollToBottom(
82
- element: ElementRef<HTMLElement> | HTMLElement,
83
- smooth: boolean = true
84
- ): void {
85
- const el = element instanceof ElementRef ? element.nativeElement : element;
86
-
87
- this.ngZone.runOutsideAngular(() => {
88
- if (smooth && 'scrollBehavior' in document.documentElement.style) {
89
- el.scrollTo({
90
- top: el.scrollHeight,
91
- behavior: 'smooth'
92
- });
93
- } else {
94
- el.scrollTop = el.scrollHeight;
95
- }
96
- });
97
- }
98
-
99
- /**
100
- * Check if element is at bottom
101
- * @param element The element to check
102
- * @param threshold Pixels from bottom to consider "at bottom"
103
- */
104
- isAtBottom(
105
- element: ElementRef<HTMLElement> | HTMLElement,
106
- threshold: number = 10
107
- ): boolean {
108
- const el = element instanceof ElementRef ? element.nativeElement : element;
109
- return this.getScrollState(el, threshold).isAtBottom;
110
- }
111
-
112
- /**
113
- * Get current scroll state of element
114
- */
115
- public getScrollState(element: HTMLElement, threshold: number): ScrollState {
116
- const scrollTop = element.scrollTop;
117
- const scrollHeight = element.scrollHeight;
118
- const clientHeight = element.clientHeight;
119
- const distanceFromBottom = scrollHeight - scrollTop - clientHeight;
120
- const isAtBottom = distanceFromBottom <= threshold;
121
-
122
- return {
123
- isAtBottom,
124
- scrollTop,
125
- scrollHeight,
126
- clientHeight
127
- };
128
- }
129
-
130
- /**
131
- * Create a ResizeObserver for element size changes
132
- * @param element The element to observe
133
- * @param debounceMs Debounce time in milliseconds
134
- */
135
- observeResize(
136
- element: ElementRef<HTMLElement> | HTMLElement,
137
- debounceMs: number = 250
138
- ): Observable<ResizeObserverEntry> {
139
- const el = element instanceof ElementRef ? element.nativeElement : element;
140
- const resize$ = new Subject<ResizeObserverEntry>();
141
-
142
- const resizeObserver = new ResizeObserver((entries) => {
143
- const entry = entries[0];
144
- if (entry) {
145
- this.ngZone.run(() => {
146
- resize$.next(entry);
147
- });
148
- }
149
- });
150
-
151
- resizeObserver.observe(el);
152
-
153
- // Cleanup on destroy
154
- this.destroy$.subscribe(() => {
155
- resizeObserver.disconnect();
156
- });
157
-
158
- return resize$.pipe(
159
- debounceTime(debounceMs),
160
- takeUntil(this.destroy$)
161
- );
162
- }
163
-
164
- ngOnDestroy(): void {
165
- this.destroy$.next();
166
- this.destroy$.complete();
167
- this.scrollStateSubject.complete();
168
- }
169
- }
@@ -1,266 +0,0 @@
1
- @import "tailwindcss";
2
- @plugin "@tailwindcss/typography";
3
- @source "../**/*.{ts,html}";
4
- @source "../../apps/angular/storybook/stories/**/*.{ts,html}";
5
-
6
- @import "tw-animate-css";
7
-
8
- @custom-variant dark (&:is(.dark *));
9
-
10
- :root {
11
- --background: oklch(1 0 0);
12
- --foreground: oklch(0.145 0 0);
13
- --card: oklch(1 0 0);
14
- --card-foreground: oklch(0.145 0 0);
15
- --popover: oklch(1 0 0);
16
- --popover-foreground: oklch(0.145 0 0);
17
- --primary: oklch(0.205 0 0);
18
- --primary-foreground: oklch(0.985 0 0);
19
- --secondary: oklch(0.97 0 0);
20
- --secondary-foreground: oklch(0.205 0 0);
21
- --muted: oklch(0.97 0 0);
22
- --muted-foreground: oklch(0.556 0 0);
23
- --accent: oklch(0.97 0 0);
24
- --accent-foreground: oklch(0.205 0 0);
25
- --destructive: oklch(0.577 0.245 27.325);
26
- --destructive-foreground: oklch(0.577 0.245 27.325);
27
- --border: oklch(0.922 0 0);
28
- --input: oklch(0.922 0 0);
29
- --ring: oklch(0.708 0 0);
30
- --chart-1: oklch(0.646 0.222 41.116);
31
- --chart-2: oklch(0.6 0.118 184.704);
32
- --chart-3: oklch(0.398 0.07 227.392);
33
- --chart-4: oklch(0.828 0.189 84.429);
34
- --chart-5: oklch(0.769 0.188 70.08);
35
- --radius: 0.625rem;
36
- --sidebar: oklch(0.985 0 0);
37
- --sidebar-foreground: oklch(0.145 0 0);
38
- --sidebar-primary: oklch(0.205 0 0);
39
- --sidebar-primary-foreground: oklch(0.985 0 0);
40
- --sidebar-accent: oklch(0.97 0 0);
41
- --sidebar-accent-foreground: oklch(0.205 0 0);
42
- --sidebar-border: oklch(0.922 0 0);
43
- --sidebar-ring: oklch(0.708 0 0);
44
- }
45
-
46
- .dark {
47
- --background: oklch(0.145 0 0);
48
- --foreground: oklch(0.985 0 0);
49
- --card: oklch(0.145 0 0);
50
- --card-foreground: oklch(0.985 0 0);
51
- --popover: oklch(0.145 0 0);
52
- --popover-foreground: oklch(0.985 0 0);
53
- --primary: oklch(0.985 0 0);
54
- --primary-foreground: oklch(0.205 0 0);
55
- --secondary: oklch(0.269 0 0);
56
- --secondary-foreground: oklch(0.985 0 0);
57
- --muted: oklch(0.269 0 0);
58
- --muted-foreground: oklch(0.708 0 0);
59
- --accent: oklch(0.269 0 0);
60
- --accent-foreground: oklch(0.985 0 0);
61
- --destructive: oklch(0.396 0.141 25.723);
62
- --destructive-foreground: oklch(0.637 0.237 25.331);
63
- --border: oklch(0.269 0 0);
64
- --input: oklch(0.269 0 0);
65
- --ring: oklch(0.556 0 0);
66
- --chart-1: oklch(0.488 0.243 264.376);
67
- --chart-2: oklch(0.696 0.17 162.48);
68
- --chart-3: oklch(0.769 0.188 70.08);
69
- --chart-4: oklch(0.627 0.265 303.9);
70
- --chart-5: oklch(0.645 0.246 16.439);
71
- --sidebar: oklch(0.205 0 0);
72
- --sidebar-foreground: oklch(0.985 0 0);
73
- --sidebar-primary: oklch(0.488 0.243 264.376);
74
- --sidebar-primary-foreground: oklch(0.985 0 0);
75
- --sidebar-accent: oklch(0.269 0 0);
76
- --sidebar-accent-foreground: oklch(0.985 0 0);
77
- --sidebar-border: oklch(0.269 0 0);
78
- --sidebar-ring: oklch(0.439 0 0);
79
- }
80
-
81
- @theme inline {
82
- --color-background: var(--background);
83
- --color-foreground: var(--foreground);
84
- --color-card: var(--card);
85
- --color-card-foreground: var(--card-foreground);
86
- --color-popover: var(--popover);
87
- --color-popover-foreground: var(--popover-foreground);
88
- --color-primary: var(--primary);
89
- --color-primary-foreground: var(--primary-foreground);
90
- --color-secondary: var(--secondary);
91
- --color-secondary-foreground: var(--secondary-foreground);
92
- --color-muted: var(--muted);
93
- --color-muted-foreground: var(--muted-foreground);
94
- --color-accent: var(--accent);
95
- --color-accent-foreground: var(--accent-foreground);
96
- --color-destructive: var(--destructive);
97
- --color-destructive-foreground: var(--destructive-foreground);
98
- --color-border: var(--border);
99
- --color-input: var(--input);
100
- --color-ring: var(--ring);
101
- --color-chart-1: var(--chart-1);
102
- --color-chart-2: var(--chart-2);
103
- --color-chart-3: var(--chart-3);
104
- --color-chart-4: var(--chart-4);
105
- --color-chart-5: var(--chart-5);
106
- --radius-sm: calc(var(--radius) - 4px);
107
- --radius-md: calc(var(--radius) - 2px);
108
- --radius-lg: var(--radius);
109
- --radius-xl: calc(var(--radius) + 4px);
110
- --color-sidebar: var(--sidebar);
111
- --color-sidebar-foreground: var(--sidebar-foreground);
112
- --color-sidebar-primary: var(--sidebar-primary);
113
- --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
114
- --color-sidebar-accent: var(--sidebar-accent);
115
- --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
116
- --color-sidebar-border: var(--sidebar-border);
117
- --color-sidebar-ring: var(--sidebar-ring);
118
- }
119
-
120
- @theme {
121
- --animate-pulse-cursor: pulse-cursor 0.9s cubic-bezier(0.4, 0, 0.2, 1)
122
- infinite;
123
- @keyframes pulse-cursor {
124
- 0%,
125
- 100% {
126
- transform: scale(1);
127
- opacity: 1;
128
- }
129
- 50% {
130
- transform: scale(1.5);
131
- opacity: 0.8;
132
- }
133
- }
134
- }
135
-
136
- @layer base {
137
- * {
138
- @apply border-border outline-ring/50;
139
- }
140
- body {
141
- @apply bg-background text-foreground;
142
- }
143
- }
144
-
145
- /* Shiki styles removed - Angular uses highlight.js instead */
146
-
147
- .prose {
148
- -webkit-font-smoothing: antialiased;
149
- -moz-osx-font-smoothing: grayscale;
150
- }
151
-
152
- .prose
153
- :where(code):not(
154
- :where([class~="not-prose"], [class~="not-prose"] *)
155
- )::before {
156
- content: none;
157
- }
158
-
159
- .prose
160
- :where(code):not(
161
- :where([class~="not-prose"], [class~="not-prose"] *)
162
- )::after {
163
- content: none;
164
- }
165
-
166
- .prose :where(code):not(:where([class~="not-prose"], [class~="not-prose"] *)) {
167
- font-weight: 400;
168
- }
169
-
170
- .prose h1 {
171
- margin-block-end: 8px;
172
- margin-bottom: 8px;
173
- font-size: 24px;
174
- font-weight: 600;
175
- }
176
-
177
- .prose h2 {
178
- margin-block-end: 4px;
179
- margin-block-start: 16px;
180
- margin-top: 16px;
181
- margin-bottom: 4px;
182
- font-size: 20px;
183
- font-weight: 600;
184
- }
185
-
186
- .prose h3 {
187
- margin-block-end: 4px;
188
- margin-block-start: 16px;
189
- margin-top: 16px;
190
- margin-bottom: 4px;
191
- font-size: 18px;
192
- font-weight: 600;
193
- }
194
-
195
- .prose p {
196
- margin-block-start: 8px;
197
- margin-block-end: 4px;
198
- margin-top: 4px;
199
- margin-bottom: 8px;
200
- }
201
-
202
- .prose a {
203
- color: #2964aa;
204
- text-decoration: none;
205
- }
206
-
207
- .prose a:hover {
208
- color: #749ac8;
209
- }
210
-
211
- .prose
212
- :where(blockquote p:first-of-type):not(
213
- :where([class~="not-prose"], [class~="not-prose"] *)
214
- )::before {
215
- content: none;
216
- }
217
-
218
- .prose blockquote {
219
- font-style: normal;
220
- font-weight: 400;
221
- }
222
-
223
- .prose input[type="checkbox"] {
224
- appearance: none;
225
- background-color: #fff;
226
- background-origin: border-box;
227
- border-color: #9b9b9b;
228
- border-width: 1px;
229
- color: #004f99;
230
- display: inline-block;
231
- flex-shrink: 0;
232
- height: 1rem;
233
- padding: 0;
234
- -webkit-print-color-adjust: exact;
235
- print-color-adjust: exact;
236
- -webkit-user-select: none;
237
- user-select: none;
238
- vertical-align: middle;
239
- width: 1rem;
240
- border-radius: 2px;
241
- }
242
-
243
- .prose input[type="checkbox"]:checked {
244
- background-color: #004f99;
245
- border-color: #004f99;
246
- background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 16 16' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0z'/%3E%3C/svg%3E");
247
- background-position: center;
248
- background-repeat: no-repeat;
249
- background-size: 100% 100%;
250
- }
251
-
252
- .prose em {
253
- @apply text-foreground;
254
- }
255
-
256
- .prose hr {
257
- margin-block-start: 0px;
258
- margin-block-end: 0px;
259
- margin-top: 28px;
260
- margin-bottom: 28px;
261
- color: rgb(13, 13, 13);
262
- }
263
-
264
- .prose td {
265
- @apply text-foreground;
266
- }
@@ -1,3 +0,0 @@
1
- @tailwind base;
2
- @tailwind components;
3
- @tailwind utilities;
package/src/test-setup.ts DELETED
@@ -1,15 +0,0 @@
1
- import 'reflect-metadata';
2
- import 'zone.js';
3
- import 'zone.js/testing';
4
- import { getTestBed } from '@angular/core/testing';
5
- import {
6
- BrowserDynamicTestingModule,
7
- platformBrowserDynamicTesting
8
- } from '@angular/platform-browser-dynamic/testing';
9
-
10
- // Initialize Angular testing environment
11
- getTestBed().initTestEnvironment(
12
- BrowserDynamicTestingModule,
13
- platformBrowserDynamicTesting(),
14
- { teardown: { destroyAfterEach: true } }
15
- );
@@ -1,3 +0,0 @@
1
- // Testing utilities for @copilotkitnext/angular
2
- // These should only be imported in test files, not in production code
3
- export * from "./testing.utils";
@@ -1,248 +0,0 @@
1
- import { TestBed, TestModuleMetadata } from "@angular/core/testing";
2
- import { DestroyRef } from "@angular/core";
3
- import { provideCopilotKit } from "../core/copilotkit.providers";
4
- import { provideCopilotChatConfiguration } from "../core/chat-configuration/chat-configuration.providers";
5
- import { CopilotKitCoreConfig } from "@copilotkitnext/core";
6
- import { CopilotChatConfiguration } from "../core/chat-configuration/chat-configuration.types";
7
- import { vi } from "vitest";
8
-
9
- /**
10
- * Creates a CopilotKit testing module with mock providers.
11
- * Simplifies test setup and provides consistent mocking across tests.
12
- *
13
- * @param config - Optional CopilotKit configuration
14
- * @param chatConfig - Optional chat configuration
15
- * @param additionalProviders - Additional providers to include
16
- * @returns Configured TestBed instance
17
- *
18
- * @example
19
- * ```typescript
20
- * describe('MyComponent', () => {
21
- * beforeEach(() => {
22
- * createCopilotKitTestingModule({
23
- * runtimeUrl: 'test-url'
24
- * });
25
- * });
26
- *
27
- * it('should work', () => {
28
- * const fixture = TestBed.createComponent(MyComponent);
29
- * // ...
30
- * });
31
- * });
32
- * ```
33
- */
34
- /**
35
- * Mock DestroyRef implementation for testing
36
- */
37
- export class MockDestroyRef implements DestroyRef {
38
- private callbacks: Array<() => void> = [];
39
-
40
- onDestroy(callback: () => void): () => void {
41
- this.callbacks.push(callback);
42
- return () => {
43
- const index = this.callbacks.indexOf(callback);
44
- if (index > -1) {
45
- this.callbacks.splice(index, 1);
46
- }
47
- };
48
- }
49
-
50
- // Method to trigger destroy for testing
51
- destroy(): void {
52
- this.callbacks.forEach((cb) => cb());
53
- this.callbacks = [];
54
- }
55
- }
56
-
57
- export function createCopilotKitTestingModule(
58
- config?: Partial<CopilotKitCoreConfig>,
59
- chatConfig?: Partial<CopilotChatConfiguration>,
60
- additionalProviders?: any[]
61
- ): any {
62
- const mockDestroyRef = new MockDestroyRef();
63
-
64
- const metadata: TestModuleMetadata = {
65
- providers: [
66
- { provide: DestroyRef, useValue: mockDestroyRef },
67
- ...provideCopilotKit(
68
- config
69
- ? {
70
- runtimeUrl: config.runtimeUrl,
71
- headers: config.headers as Record<string, string> | undefined,
72
- properties: config.properties,
73
- agents: config.agents,
74
- }
75
- : {}
76
- ),
77
- ...(chatConfig ? provideCopilotChatConfiguration(chatConfig) : []),
78
- ...(additionalProviders ?? []),
79
- ],
80
- };
81
-
82
- const testBed = TestBed.configureTestingModule(metadata);
83
- // Attach the mock to TestBed for testing access
84
- (testBed as any).mockDestroyRef = mockDestroyRef;
85
- return testBed;
86
- }
87
-
88
- /**
89
- * Creates a mock CopilotKitCore instance for testing.
90
- * Provides all necessary methods with vi.fn() mocks.
91
- *
92
- * @returns Mock CopilotKitCore instance
93
- *
94
- * @example
95
- * ```typescript
96
- * const mockCore = createMockCopilotKitCore();
97
- * vi.spyOn(mockCore, 'addContext').mockReturnValue('context-id');
98
- * ```
99
- */
100
- export function createMockCopilotKitCore() {
101
- return {
102
- addContext: vi.fn().mockImplementation(() => "context-id-" + Math.random()),
103
- removeContext: vi.fn(),
104
- addTool: vi.fn().mockImplementation(() => "tool-id-" + Math.random()),
105
- removeTool: vi.fn(),
106
- setRuntimeUrl: vi.fn(),
107
- setHeaders: vi.fn(),
108
- setProperties: vi.fn(),
109
- setAgents: vi.fn(),
110
- getAgent: vi.fn(),
111
- subscribe: vi.fn(() => vi.fn()), // Returns unsubscribe function
112
- getMessages: vi.fn(() => []),
113
- getState: vi.fn(() => ({})),
114
- send: vi.fn(),
115
- render: vi.fn(),
116
- };
117
- }
118
-
119
- /**
120
- * Creates a mock Agent instance for testing.
121
- * Provides all necessary methods with vi.fn() mocks.
122
- *
123
- * @param id - Agent ID
124
- * @returns Mock Agent instance
125
- *
126
- * @example
127
- * ```typescript
128
- * const mockAgent = createMockAgent('test-agent');
129
- * vi.spyOn(mockAgent, 'subscribe').mockReturnValue({ unsubscribe: vi.fn() });
130
- * ```
131
- */
132
- export function createMockAgent(id: string = "test-agent") {
133
- return {
134
- id,
135
- getMessages: vi.fn(() => []),
136
- getState: vi.fn(() => ({})),
137
- subscribe: vi.fn(() => ({ unsubscribe: vi.fn() })),
138
- send: vi.fn(),
139
- render: vi.fn(),
140
- isRunning: vi.fn(() => false),
141
- };
142
- }
143
-
144
- /**
145
- * Helper to create a test host component for directive testing.
146
- * Reduces boilerplate in directive test files.
147
- *
148
- * @param template - Component template
149
- * @param componentClass - Optional component class definition
150
- * @returns Component class
151
- *
152
- * @example
153
- * ```typescript
154
- * const TestComponent = createTestHostComponent(`
155
- * <div copilotkitAgent [agentId]="agentId"></div>
156
- * `, {
157
- * agentId: 'test-agent'
158
- * });
159
- * ```
160
- */
161
- export function createTestHostComponent(
162
- template: string,
163
- componentClass: Record<string, any> = {}
164
- ): any {
165
- return class TestHostComponent {
166
- constructor() {
167
- Object.assign(this, componentClass);
168
- }
169
- };
170
- }
171
-
172
- /**
173
- * Waits for Angular change detection to complete.
174
- * Useful for testing async operations.
175
- *
176
- * @param fixture - Component fixture
177
- * @param timeout - Maximum wait time in ms
178
- * @returns Promise that resolves when stable
179
- *
180
- * @example
181
- * ```typescript
182
- * await waitForStable(fixture);
183
- * expect(component.isReady).toBe(true);
184
- * ```
185
- */
186
- export async function waitForStable(
187
- fixture: any,
188
- timeout: number = 1000
189
- ): Promise<void> {
190
- return new Promise((resolve, reject) => {
191
- const startTime = Date.now();
192
-
193
- const check = () => {
194
- fixture.detectChanges();
195
-
196
- if (fixture.isStable()) {
197
- resolve();
198
- } else if (Date.now() - startTime > timeout) {
199
- reject(new Error("Fixture did not stabilize within timeout"));
200
- } else {
201
- setTimeout(check, 10);
202
- }
203
- };
204
-
205
- check();
206
- });
207
- }
208
-
209
- /**
210
- * Creates a mock render function for tool testing.
211
- *
212
- * @returns Mock render function
213
- */
214
- export function createMockToolRender() {
215
- return vi.fn().mockImplementation((props: any) => {
216
- return { type: "mock-render", props };
217
- });
218
- }
219
-
220
- /**
221
- * Creates a mock tool handler for testing.
222
- *
223
- * @param returnValue - Value to return from handler
224
- * @returns Mock handler function
225
- */
226
- export function createMockToolHandler(returnValue: any = "mock-result") {
227
- return vi.fn().mockResolvedValue(returnValue);
228
- }
229
-
230
- /**
231
- * Helper to test directive lifecycle methods.
232
- *
233
- * @param directive - Directive instance
234
- * @param changes - SimpleChanges to apply
235
- */
236
- export function triggerLifecycle(directive: any, changes?: any): void {
237
- if (directive.ngOnInit) {
238
- directive.ngOnInit();
239
- }
240
-
241
- if (changes && directive.ngOnChanges) {
242
- directive.ngOnChanges(changes);
243
- }
244
-
245
- if (directive.ngOnDestroy) {
246
- directive.ngOnDestroy();
247
- }
248
- }