@copilotkitnext/angular 0.0.1 → 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 (171) hide show
  1. package/README.md +248 -0
  2. package/dist/README.md +248 -0
  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/dist/styles.css +0 -27
  72. package/package.json +23 -20
  73. package/vitest.config.mts +32 -21
  74. package/.turbo/turbo-build.log +0 -39
  75. package/.turbo/turbo-check-types.log +0 -0
  76. package/.turbo/turbo-test.log +0 -71
  77. package/README-agent-context.md +0 -310
  78. package/ng-package.json +0 -19
  79. package/slots.md +0 -331
  80. package/src/components/chat/__tests__/copilot-chat-assistant-message.component.spec.ts +0 -282
  81. package/src/components/chat/__tests__/copilot-chat-input.component.spec.ts +0 -419
  82. package/src/components/chat/__tests__/copilot-chat-message-view.component.spec.ts +0 -372
  83. package/src/components/chat/__tests__/copilot-chat-user-message.component.spec.ts +0 -249
  84. package/src/components/chat/copilot-chat-assistant-message-buttons.component.ts +0 -292
  85. package/src/components/chat/copilot-chat-assistant-message-renderer.component.ts +0 -472
  86. package/src/components/chat/copilot-chat-assistant-message-toolbar.component.ts +0 -29
  87. package/src/components/chat/copilot-chat-assistant-message.component.ts +0 -463
  88. package/src/components/chat/copilot-chat-assistant-message.types.ts +0 -50
  89. package/src/components/chat/copilot-chat-audio-recorder.component.ts +0 -241
  90. package/src/components/chat/copilot-chat-buttons.component.ts +0 -308
  91. package/src/components/chat/copilot-chat-buttons.component.ts.bak +0 -471
  92. package/src/components/chat/copilot-chat-input-defaults.ts +0 -47
  93. package/src/components/chat/copilot-chat-input.component.ts +0 -512
  94. package/src/components/chat/copilot-chat-input.types.ts +0 -148
  95. package/src/components/chat/copilot-chat-message-view-cursor.component.ts +0 -51
  96. package/src/components/chat/copilot-chat-message-view.component.ts +0 -233
  97. package/src/components/chat/copilot-chat-message-view.types.ts +0 -39
  98. package/src/components/chat/copilot-chat-textarea.component.ts +0 -220
  99. package/src/components/chat/copilot-chat-tool-calls-view.component.ts +0 -261
  100. package/src/components/chat/copilot-chat-toolbar.component.ts +0 -35
  101. package/src/components/chat/copilot-chat-tools-menu.component.ts +0 -185
  102. package/src/components/chat/copilot-chat-user-message-branch-navigation.component.ts +0 -121
  103. package/src/components/chat/copilot-chat-user-message-buttons.component.ts +0 -170
  104. package/src/components/chat/copilot-chat-user-message-renderer.component.ts +0 -37
  105. package/src/components/chat/copilot-chat-user-message-toolbar.component.ts +0 -37
  106. package/src/components/chat/copilot-chat-user-message.component.ts +0 -247
  107. package/src/components/chat/copilot-chat-user-message.types.ts +0 -42
  108. package/src/components/chat/copilot-chat-view-disclaimer.component.ts +0 -51
  109. package/src/components/chat/copilot-chat-view-feather.component.ts +0 -47
  110. package/src/components/chat/copilot-chat-view-handlers.service.ts +0 -14
  111. package/src/components/chat/copilot-chat-view-input-container.component.ts +0 -87
  112. package/src/components/chat/copilot-chat-view-scroll-to-bottom-button.component.ts +0 -79
  113. package/src/components/chat/copilot-chat-view-scroll-view.component.ts +0 -322
  114. package/src/components/chat/copilot-chat-view.component.ts +0 -420
  115. package/src/components/chat/copilot-chat-view.types.ts +0 -52
  116. package/src/components/chat/copilot-chat.component.ts +0 -232
  117. package/src/components/copilotkit-tool-render.component.ts +0 -169
  118. package/src/core/__tests__/copilotkit.service.spec.ts +0 -1051
  119. package/src/core/__tests__/copilotkit.service.wildcard.spec.ts +0 -316
  120. package/src/core/chat-configuration/__tests__/chat-configuration.service.spec.ts +0 -287
  121. package/src/core/chat-configuration/chat-configuration.providers.ts +0 -71
  122. package/src/core/chat-configuration/chat-configuration.service.ts +0 -162
  123. package/src/core/chat-configuration/chat-configuration.types.ts +0 -57
  124. package/src/core/copilotkit.providers.ts +0 -59
  125. package/src/core/copilotkit.service.ts +0 -542
  126. package/src/core/copilotkit.types.ts +0 -132
  127. package/src/directives/__tests__/copilotkit-agent-context.directive.spec.ts +0 -384
  128. package/src/directives/__tests__/copilotkit-agent.directive.spec.ts +0 -253
  129. package/src/directives/__tests__/copilotkit-chat-config.directive.spec.ts +0 -385
  130. package/src/directives/__tests__/copilotkit-config.directive.spec.ts +0 -69
  131. package/src/directives/__tests__/copilotkit-frontend-tool-simple.directive.spec.ts +0 -60
  132. package/src/directives/__tests__/copilotkit-frontend-tool.directive.spec.ts +0 -108
  133. package/src/directives/__tests__/copilotkit-human-in-the-loop.directive.spec.ts +0 -452
  134. package/src/directives/copilotkit-agent-context.directive.ts +0 -138
  135. package/src/directives/copilotkit-agent.directive.ts +0 -225
  136. package/src/directives/copilotkit-chat-config.directive.ts +0 -241
  137. package/src/directives/copilotkit-config.directive.ts +0 -81
  138. package/src/directives/copilotkit-frontend-tool.directive.ts +0 -145
  139. package/src/directives/copilotkit-human-in-the-loop.directive.ts +0 -281
  140. package/src/directives/stick-to-bottom.directive.ts +0 -204
  141. package/src/index.ts +0 -105
  142. package/src/lib/directives/tooltip.directive.ts +0 -292
  143. package/src/lib/slots/__tests__/slot.utils.spec.ts +0 -377
  144. package/src/lib/slots/copilot-slot.component.ts +0 -135
  145. package/src/lib/slots/index.ts +0 -3
  146. package/src/lib/slots/slot.types.ts +0 -64
  147. package/src/lib/slots/slot.utils.ts +0 -289
  148. package/src/lib/utils.ts +0 -10
  149. package/src/public-api.ts +0 -1
  150. package/src/services/resize-observer.service.ts +0 -181
  151. package/src/services/scroll-position.service.ts +0 -169
  152. package/src/styles/globals.css +0 -266
  153. package/src/styles/index.css +0 -3
  154. package/src/test-setup.ts +0 -15
  155. package/src/testing/index.ts +0 -3
  156. package/src/testing/testing.utils.ts +0 -248
  157. package/src/types/frontend-tool.ts +0 -44
  158. package/src/types/human-in-the-loop.ts +0 -52
  159. package/src/utils/__tests__/agent.utils.spec.ts +0 -234
  160. package/src/utils/__tests__/chat-config.utils.spec.ts +0 -306
  161. package/src/utils/__tests__/frontend-tool-inject.spec.ts +0 -350
  162. package/src/utils/__tests__/frontend-tool-integration.spec.ts +0 -199
  163. package/src/utils/__tests__/frontend-tool.utils.spec.ts +0 -272
  164. package/src/utils/__tests__/human-in-the-loop.utils.spec.ts +0 -365
  165. package/src/utils/agent-context.utils.ts +0 -133
  166. package/src/utils/agent.utils.ts +0 -239
  167. package/src/utils/chat-config.utils.ts +0 -221
  168. package/src/utils/copilotkit.utils.ts +0 -20
  169. package/src/utils/frontend-tool.utils.ts +0 -266
  170. package/src/utils/human-in-the-loop.utils.ts +0 -359
  171. package/tsconfig.spec.json +0 -12
package/README.md ADDED
@@ -0,0 +1,248 @@
1
+ # CopilotKit for Angular
2
+
3
+ This package provides native Angular components, directives, and providers to build Copilot chat UIs powered by the CopilotKit runtime and AG-UI agents. It mirrors the React experience with idiomatic Angular APIs.
4
+
5
+ ## Quick Start
6
+
7
+ 1. **Install**: `pnpm add @copilotkitnext/angular`
8
+ 2. **Add styles**: Add `@copilotkitnext/angular/styles.css` to your Angular app styles array or `@import "@copilotkitnext/angular/styles.css";` in a global stylesheet
9
+ 3. **Provide CopilotKit**: Set the runtime URL and optional labels via providers
10
+ 4. **Use the chat**: Drop `<copilot-chat />` into any template
11
+
12
+ ## Installation
13
+
14
+ ### Package Installation
15
+
16
+ Install `@copilotkitnext/angular` in your Angular app (supports Angular 18 and 19):
17
+
18
+ ```bash
19
+ # pnpm (recommended)
20
+ pnpm add @copilotkitnext/angular
21
+
22
+ # npm
23
+ npm install @copilotkitnext/angular
24
+
25
+ # yarn
26
+ yarn add @copilotkitnext/angular
27
+ ```
28
+
29
+ ### Peer Dependencies
30
+
31
+ Ensure these are present (matching your Angular major):
32
+
33
+ - `@angular/core`
34
+ - `@angular/common`
35
+ - `@angular/cdk` (use `^18` with Angular 18, `^19` with Angular 19)
36
+ - `rxjs`
37
+ - `tslib`
38
+
39
+ ### Styles
40
+
41
+ Reference the package CSS so the components render correctly:
42
+
43
+ **Option 1:** In `angular.json`:
44
+
45
+ ```json
46
+ "styles": [
47
+ "@copilotkitnext/angular/styles.css",
48
+ "src/styles.css"
49
+ ]
50
+ ```
51
+
52
+ **Option 2:** In your global stylesheet:
53
+
54
+ ```css
55
+ @import "@copilotkitnext/angular/styles.css";
56
+ ```
57
+
58
+ ## App Wiring (Providers)
59
+
60
+ Add CopilotKit providers in your application config to set labels and runtime URL.
61
+
62
+ ### Example (`app.config.ts`):
63
+
64
+ ```typescript
65
+ import {
66
+ provideCopilotKit,
67
+ provideCopilotChatConfiguration,
68
+ } from "@copilotkitnext/angular";
69
+
70
+ export const appConfig: ApplicationConfig = {
71
+ providers: [
72
+ importProvidersFrom(BrowserModule),
73
+ ...provideCopilotKit({
74
+ // runtimeUrl can also be set via template directive; see below
75
+ }),
76
+ provideCopilotChatConfiguration({
77
+ labels: {
78
+ chatInputPlaceholder: "Ask me anything...",
79
+ chatDisclaimerText: "AI responses may need verification.",
80
+ },
81
+ }),
82
+ ],
83
+ };
84
+ ```
85
+
86
+ ## Runtime URL (Template Directive)
87
+
88
+ You can declare the CopilotKit runtime endpoint directly in templates via the `CopilotKitConfigDirective`.
89
+
90
+ ### Component Template Example:
91
+
92
+ ```html
93
+ <div
94
+ [copilotkitConfig]="{ runtimeUrl: runtimeUrl }"
95
+ style="display:block;height:100vh"
96
+ >
97
+ <copilot-chat></copilot-chat>
98
+ </div>
99
+ ```
100
+
101
+ ### Component Class:
102
+
103
+ ```typescript
104
+ export class AppComponent {
105
+ runtimeUrl = "http://localhost:3001/api/copilotkit";
106
+ }
107
+ ```
108
+
109
+ ## Using the Chat Component
110
+
111
+ ### Minimal Usage:
112
+
113
+ ```html
114
+ <copilot-chat></copilot-chat>
115
+ ```
116
+
117
+ ### With a Specific Agent:
118
+
119
+ ```html
120
+ <copilot-chat [agentId]="'sales'"></copilot-chat>
121
+ ```
122
+
123
+ ### Behavior:
124
+
125
+ - If `agentId` is omitted, the component uses the default agent (ID: `default`)
126
+
127
+ ## Agents 101 (AG-UI)
128
+
129
+ - **Agent model**: CopilotKit uses AG-UI's `AbstractAgent` interface (package `@ag-ui/client`)
130
+ - **Frontend vs backend**:
131
+ - **Backend (runtime)**: Host your real agents. You can use any AG-UI agent on the server
132
+ - **Frontend (Angular app)**: Discovers remote agents from the runtime automatically, and can also host local in-browser agents if desired
133
+ - **Default agent**: The ID `default` is special; when present, it is used by `<copilot-chat>` if no `agentId` is provided
134
+ - **Compatibility**: Any agent that supports AG-UI works. See https://docs.ag-ui.com/
135
+
136
+ > **Note**: In most real apps, you define agents on the server (runtime). The frontend will auto-discover them when a `runtimeUrl` is configured.
137
+
138
+ ## Backend Runtime (Hono Server)
139
+
140
+ Example Angular server (from `apps/angular/demo-server`):
141
+
142
+ ### `index.ts`
143
+
144
+ ```typescript
145
+ import { serve } from "@hono/node-server";
146
+ import { Hono } from "hono";
147
+ import { cors } from "hono/cors";
148
+ import {
149
+ CopilotRuntime,
150
+ createCopilotEndpoint,
151
+ InMemoryAgentRunner,
152
+ } from "@copilotkitnext/runtime";
153
+ import { AnyAGUIAgent } from "@ag-ui/your-desired-agent-framework";
154
+
155
+ const runtime = new CopilotRuntime({
156
+ agents: { default: new AnyAGUIAgent() },
157
+ });
158
+
159
+ // Create a main app with CORS enabled
160
+ const app = new Hono();
161
+
162
+ // Enable CORS for local dev (Angular demo at http://localhost:4200)
163
+ app.use(
164
+ "*",
165
+ cors({
166
+ origin: "http://localhost:4200",
167
+ allowMethods: ["GET", "POST", "OPTIONS", "PUT", "DELETE"],
168
+ allowHeaders: ["Content-Type", "Authorization", "X-Requested-With"],
169
+ exposeHeaders: ["Content-Type"],
170
+ credentials: true,
171
+ maxAge: 86400,
172
+ })
173
+ );
174
+
175
+ // Create the CopilotKit endpoint
176
+ const copilotApp = createCopilotEndpoint({
177
+ runtime,
178
+ basePath: "/api/copilotkit",
179
+ });
180
+
181
+ // Mount the CopilotKit app
182
+ app.route("/", copilotApp);
183
+
184
+ const port = Number(process.env.PORT || 3001);
185
+ serve({ fetch: app.fetch, port });
186
+ console.log(
187
+ `CopilotKit runtime listening at http://localhost:${port}/api/copilotkit`
188
+ );
189
+ ```
190
+
191
+ ## CopilotKit Angular APIs (Most Used)
192
+
193
+ ### Components
194
+
195
+ - **`CopilotChatComponent`**: Full chat UI
196
+ - Inputs: `agentId?: string`
197
+
198
+ ### Directives
199
+
200
+ - **`CopilotKitConfigDirective`** (`[copilotkitConfig]`): Set `runtimeUrl`, `headers`, `properties`, and/or `agents` declaratively
201
+ - **`CopilotKitAgentDirective`** (`[copilotkitAgent]`): Observe agent state; defaults to the `default` agent if no `agentId` is provided
202
+
203
+ ### Providers
204
+
205
+ - **`provideCopilotKit(...)`**: Set runtime URL, headers, properties, agents, tools, human-in-the-loop handlers
206
+ - **`provideCopilotChatConfiguration(...)`**: Set UI labels and behavior for chat input/view
207
+
208
+ ## End-to-End: Running the Demo
209
+
210
+ From the repo root:
211
+
212
+ 1. **Install deps**: `pnpm install`
213
+ 2. **Start both demo server and Angular demo app**: pnpm build && pnpm demo:angular`
214
+ - Frontend: runs on http://localhost:4200
215
+ - Backend: runs on http://localhost:3001/api/copilotkit
216
+ 3. **Prerequisite**: Set `OPENAI_API_KEY` in `apps/angular/demo-server/.env` if using the OpenAI demo agent
217
+
218
+ ## Building This Monorepo
219
+
220
+ - **Full build**: `pnpm build` (compiles all packages including Angular)
221
+ - **Clean**: `pnpm clean`
222
+ - **Package-only dev (watch)**: `pnpm dev`
223
+
224
+ ## Angular Storybook
225
+
226
+ ### Dev Server
227
+
228
+ ```bash
229
+ pnpm storybook:angular
230
+ ```
231
+
232
+ - Serves Storybook for Angular components on http://localhost:6007
233
+ - For live chat stories, ensure the demo server is running so the chat can connect:
234
+ ```bash
235
+ pnpm --filter @copilotkitnext/angular-demo-server dev
236
+ ```
237
+
238
+ ### Production Build
239
+
240
+ ```bash
241
+ pnpm -C apps/angular/storybook build
242
+ ```
243
+
244
+ ## Notes
245
+
246
+ - Node 18+ and pnpm 9+ recommended
247
+ - If using custom CORS or non-default ports, update `runtimeUrl` and server CORS settings accordingly
248
+ - Styles must be included for proper rendering; if customizing CSS, prefer overriding classes instead of modifying the distributed CSS
package/dist/README.md ADDED
@@ -0,0 +1,248 @@
1
+ # CopilotKit for Angular
2
+
3
+ This package provides native Angular components, directives, and providers to build Copilot chat UIs powered by the CopilotKit runtime and AG-UI agents. It mirrors the React experience with idiomatic Angular APIs.
4
+
5
+ ## Quick Start
6
+
7
+ 1. **Install**: `pnpm add @copilotkitnext/angular`
8
+ 2. **Add styles**: Add `@copilotkitnext/angular/styles.css` to your Angular app styles array or `@import "@copilotkitnext/angular/styles.css";` in a global stylesheet
9
+ 3. **Provide CopilotKit**: Set the runtime URL and optional labels via providers
10
+ 4. **Use the chat**: Drop `<copilot-chat />` into any template
11
+
12
+ ## Installation
13
+
14
+ ### Package Installation
15
+
16
+ Install `@copilotkitnext/angular` in your Angular app (supports Angular 18 and 19):
17
+
18
+ ```bash
19
+ # pnpm (recommended)
20
+ pnpm add @copilotkitnext/angular
21
+
22
+ # npm
23
+ npm install @copilotkitnext/angular
24
+
25
+ # yarn
26
+ yarn add @copilotkitnext/angular
27
+ ```
28
+
29
+ ### Peer Dependencies
30
+
31
+ Ensure these are present (matching your Angular major):
32
+
33
+ - `@angular/core`
34
+ - `@angular/common`
35
+ - `@angular/cdk` (use `^18` with Angular 18, `^19` with Angular 19)
36
+ - `rxjs`
37
+ - `tslib`
38
+
39
+ ### Styles
40
+
41
+ Reference the package CSS so the components render correctly:
42
+
43
+ **Option 1:** In `angular.json`:
44
+
45
+ ```json
46
+ "styles": [
47
+ "@copilotkitnext/angular/styles.css",
48
+ "src/styles.css"
49
+ ]
50
+ ```
51
+
52
+ **Option 2:** In your global stylesheet:
53
+
54
+ ```css
55
+ @import "@copilotkitnext/angular/styles.css";
56
+ ```
57
+
58
+ ## App Wiring (Providers)
59
+
60
+ Add CopilotKit providers in your application config to set labels and runtime URL.
61
+
62
+ ### Example (`app.config.ts`):
63
+
64
+ ```typescript
65
+ import {
66
+ provideCopilotKit,
67
+ provideCopilotChatConfiguration,
68
+ } from "@copilotkitnext/angular";
69
+
70
+ export const appConfig: ApplicationConfig = {
71
+ providers: [
72
+ importProvidersFrom(BrowserModule),
73
+ ...provideCopilotKit({
74
+ // runtimeUrl can also be set via template directive; see below
75
+ }),
76
+ provideCopilotChatConfiguration({
77
+ labels: {
78
+ chatInputPlaceholder: "Ask me anything...",
79
+ chatDisclaimerText: "AI responses may need verification.",
80
+ },
81
+ }),
82
+ ],
83
+ };
84
+ ```
85
+
86
+ ## Runtime URL (Template Directive)
87
+
88
+ You can declare the CopilotKit runtime endpoint directly in templates via the `CopilotKitConfigDirective`.
89
+
90
+ ### Component Template Example:
91
+
92
+ ```html
93
+ <div
94
+ [copilotkitConfig]="{ runtimeUrl: runtimeUrl }"
95
+ style="display:block;height:100vh"
96
+ >
97
+ <copilot-chat></copilot-chat>
98
+ </div>
99
+ ```
100
+
101
+ ### Component Class:
102
+
103
+ ```typescript
104
+ export class AppComponent {
105
+ runtimeUrl = "http://localhost:3001/api/copilotkit";
106
+ }
107
+ ```
108
+
109
+ ## Using the Chat Component
110
+
111
+ ### Minimal Usage:
112
+
113
+ ```html
114
+ <copilot-chat></copilot-chat>
115
+ ```
116
+
117
+ ### With a Specific Agent:
118
+
119
+ ```html
120
+ <copilot-chat [agentId]="'sales'"></copilot-chat>
121
+ ```
122
+
123
+ ### Behavior:
124
+
125
+ - If `agentId` is omitted, the component uses the default agent (ID: `default`)
126
+
127
+ ## Agents 101 (AG-UI)
128
+
129
+ - **Agent model**: CopilotKit uses AG-UI's `AbstractAgent` interface (package `@ag-ui/client`)
130
+ - **Frontend vs backend**:
131
+ - **Backend (runtime)**: Host your real agents. You can use any AG-UI agent on the server
132
+ - **Frontend (Angular app)**: Discovers remote agents from the runtime automatically, and can also host local in-browser agents if desired
133
+ - **Default agent**: The ID `default` is special; when present, it is used by `<copilot-chat>` if no `agentId` is provided
134
+ - **Compatibility**: Any agent that supports AG-UI works. See https://docs.ag-ui.com/
135
+
136
+ > **Note**: In most real apps, you define agents on the server (runtime). The frontend will auto-discover them when a `runtimeUrl` is configured.
137
+
138
+ ## Backend Runtime (Hono Server)
139
+
140
+ Example Angular server (from `apps/angular/demo-server`):
141
+
142
+ ### `index.ts`
143
+
144
+ ```typescript
145
+ import { serve } from "@hono/node-server";
146
+ import { Hono } from "hono";
147
+ import { cors } from "hono/cors";
148
+ import {
149
+ CopilotRuntime,
150
+ createCopilotEndpoint,
151
+ InMemoryAgentRunner,
152
+ } from "@copilotkitnext/runtime";
153
+ import { AnyAGUIAgent } from "@ag-ui/your-desired-agent-framework";
154
+
155
+ const runtime = new CopilotRuntime({
156
+ agents: { default: new AnyAGUIAgent() },
157
+ });
158
+
159
+ // Create a main app with CORS enabled
160
+ const app = new Hono();
161
+
162
+ // Enable CORS for local dev (Angular demo at http://localhost:4200)
163
+ app.use(
164
+ "*",
165
+ cors({
166
+ origin: "http://localhost:4200",
167
+ allowMethods: ["GET", "POST", "OPTIONS", "PUT", "DELETE"],
168
+ allowHeaders: ["Content-Type", "Authorization", "X-Requested-With"],
169
+ exposeHeaders: ["Content-Type"],
170
+ credentials: true,
171
+ maxAge: 86400,
172
+ })
173
+ );
174
+
175
+ // Create the CopilotKit endpoint
176
+ const copilotApp = createCopilotEndpoint({
177
+ runtime,
178
+ basePath: "/api/copilotkit",
179
+ });
180
+
181
+ // Mount the CopilotKit app
182
+ app.route("/", copilotApp);
183
+
184
+ const port = Number(process.env.PORT || 3001);
185
+ serve({ fetch: app.fetch, port });
186
+ console.log(
187
+ `CopilotKit runtime listening at http://localhost:${port}/api/copilotkit`
188
+ );
189
+ ```
190
+
191
+ ## CopilotKit Angular APIs (Most Used)
192
+
193
+ ### Components
194
+
195
+ - **`CopilotChatComponent`**: Full chat UI
196
+ - Inputs: `agentId?: string`
197
+
198
+ ### Directives
199
+
200
+ - **`CopilotKitConfigDirective`** (`[copilotkitConfig]`): Set `runtimeUrl`, `headers`, `properties`, and/or `agents` declaratively
201
+ - **`CopilotKitAgentDirective`** (`[copilotkitAgent]`): Observe agent state; defaults to the `default` agent if no `agentId` is provided
202
+
203
+ ### Providers
204
+
205
+ - **`provideCopilotKit(...)`**: Set runtime URL, headers, properties, agents, tools, human-in-the-loop handlers
206
+ - **`provideCopilotChatConfiguration(...)`**: Set UI labels and behavior for chat input/view
207
+
208
+ ## End-to-End: Running the Demo
209
+
210
+ From the repo root:
211
+
212
+ 1. **Install deps**: `pnpm install`
213
+ 2. **Start both demo server and Angular demo app**: pnpm build && pnpm demo:angular`
214
+ - Frontend: runs on http://localhost:4200
215
+ - Backend: runs on http://localhost:3001/api/copilotkit
216
+ 3. **Prerequisite**: Set `OPENAI_API_KEY` in `apps/angular/demo-server/.env` if using the OpenAI demo agent
217
+
218
+ ## Building This Monorepo
219
+
220
+ - **Full build**: `pnpm build` (compiles all packages including Angular)
221
+ - **Clean**: `pnpm clean`
222
+ - **Package-only dev (watch)**: `pnpm dev`
223
+
224
+ ## Angular Storybook
225
+
226
+ ### Dev Server
227
+
228
+ ```bash
229
+ pnpm storybook:angular
230
+ ```
231
+
232
+ - Serves Storybook for Angular components on http://localhost:6007
233
+ - For live chat stories, ensure the demo server is running so the chat can connect:
234
+ ```bash
235
+ pnpm --filter @copilotkitnext/angular-demo-server dev
236
+ ```
237
+
238
+ ### Production Build
239
+
240
+ ```bash
241
+ pnpm -C apps/angular/storybook build
242
+ ```
243
+
244
+ ## Notes
245
+
246
+ - Node 18+ and pnpm 9+ recommended
247
+ - If using custom CORS or non-default ports, update `runtimeUrl` and server CORS settings accordingly
248
+ - Styles must be included for proper rendering; if customizing CSS, prefer overriding classes instead of modifying the distributed CSS
@@ -73,8 +73,8 @@ export declare class CopilotChatAssistantMessageComponent {
73
73
  message: {
74
74
  id: string;
75
75
  role: "assistant";
76
- name?: string | undefined;
77
- content?: string | undefined;
76
+ name?: string;
77
+ content?: string;
78
78
  toolCalls?: {
79
79
  function: {
80
80
  name: string;
@@ -82,23 +82,23 @@ export declare class CopilotChatAssistantMessageComponent {
82
82
  };
83
83
  type: "function";
84
84
  id: string;
85
- }[] | undefined;
85
+ }[];
86
86
  };
87
87
  messages: ({
88
88
  id: string;
89
89
  role: "developer";
90
90
  content: string;
91
- name?: string | undefined;
91
+ name?: string;
92
92
  } | {
93
93
  id: string;
94
94
  role: "system";
95
95
  content: string;
96
- name?: string | undefined;
96
+ name?: string;
97
97
  } | {
98
98
  id: string;
99
99
  role: "assistant";
100
- name?: string | undefined;
101
- content?: string | undefined;
100
+ name?: string;
101
+ content?: string;
102
102
  toolCalls?: {
103
103
  function: {
104
104
  name: string;
@@ -106,18 +106,18 @@ export declare class CopilotChatAssistantMessageComponent {
106
106
  };
107
107
  type: "function";
108
108
  id: string;
109
- }[] | undefined;
109
+ }[];
110
110
  } | {
111
111
  id: string;
112
112
  role: "user";
113
113
  content: string;
114
- name?: string | undefined;
114
+ name?: string;
115
115
  } | {
116
116
  id: string;
117
117
  role: "tool";
118
118
  content: string;
119
119
  toolCallId: string;
120
- error?: string | undefined;
120
+ error?: string;
121
121
  })[];
122
122
  isLoading: boolean;
123
123
  }>;