@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,119 @@
1
+ import { ToolCallRender, AngularFrontendTool, AngularHumanInTheLoop } from "./copilotkit.types";
2
+ import { CopilotKitCore } from "@copilotkitnext/core";
3
+ import { AbstractAgent } from "@ag-ui/client";
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Angular service for managing CopilotKit state and interactions.
7
+ * Provides reactive state management using Angular signals and observables.
8
+ */
9
+ export declare class CopilotKitService {
10
+ private readonly initialFrontendTools;
11
+ private readonly initialHumanInTheLoop;
12
+ private readonly initialRenderToolCalls;
13
+ readonly copilotkit: CopilotKitCore;
14
+ private readonly _renderToolCalls;
15
+ private readonly _currentRenderToolCalls;
16
+ private readonly _runtimeUrl;
17
+ private readonly _headers;
18
+ private readonly _properties;
19
+ private readonly _agents;
20
+ private readonly _frontendTools;
21
+ private readonly _humanInTheLoop;
22
+ private readonly _runtimeStateVersion;
23
+ private readonly _allTools;
24
+ private readonly _allRenderToolCalls;
25
+ readonly renderToolCalls: any;
26
+ readonly currentRenderToolCalls: any;
27
+ readonly runtimeUrl: any;
28
+ readonly headers: any;
29
+ readonly properties: any;
30
+ readonly agents: any;
31
+ readonly frontendTools: any;
32
+ readonly humanInTheLoop: any;
33
+ readonly runtimeStateVersion: any;
34
+ readonly renderToolCalls$: any;
35
+ readonly currentRenderToolCalls$: any;
36
+ readonly runtimeUrl$: any;
37
+ readonly headers$: any;
38
+ readonly properties$: any;
39
+ readonly agents$: any;
40
+ readonly frontendTools$: any;
41
+ readonly humanInTheLoop$: any;
42
+ readonly context: any;
43
+ readonly context$: any;
44
+ constructor(runtimeUrl: string | undefined, headers: Record<string, string>, properties: Record<string, unknown>, agents: Record<string, AbstractAgent>, renderToolCalls: ToolCallRender<unknown>[], frontendTools: AngularFrontendTool<any>[], humanInTheLoop: AngularHumanInTheLoop<any>[]);
45
+ /**
46
+ * Process frontend tools and human-in-the-loop tools
47
+ */
48
+ private processTools;
49
+ /**
50
+ * Setup stability warning effects
51
+ */
52
+ private setupStabilityWarnings;
53
+ /**
54
+ * Setup effects to sync runtime configuration with CopilotKitCore
55
+ */
56
+ private setupRuntimeSyncEffects;
57
+ /**
58
+ * Subscribe to CopilotKit runtime events
59
+ */
60
+ private setupEventSubscription;
61
+ /**
62
+ * Notify consumers that the runtime state has changed.
63
+ * This is similar to React's forceUpdate - it triggers change detection
64
+ * for any computed signals or effects that depend on runtime state.
65
+ */
66
+ private notifyRuntimeStateChange;
67
+ /**
68
+ * Update the runtime URL
69
+ */
70
+ setRuntimeUrl(url?: string): void;
71
+ /**
72
+ * Update request headers
73
+ */
74
+ setHeaders(headers: Record<string, string>): void;
75
+ /**
76
+ * Update runtime properties
77
+ */
78
+ setProperties(properties: Record<string, unknown>): void;
79
+ /**
80
+ * Update agents configuration
81
+ */
82
+ setAgents(agents: Record<string, AbstractAgent>): void;
83
+ /**
84
+ * Get an agent by ID
85
+ * @param agentId - The agent ID to retrieve
86
+ * @returns The agent or undefined if not found
87
+ */
88
+ getAgent(agentId: string): AbstractAgent | undefined;
89
+ /**
90
+ * Update render tool calls (warns if object reference changes)
91
+ */
92
+ setRenderToolCalls(renderToolCalls: ToolCallRender<unknown>[]): void;
93
+ /**
94
+ * Update frontend tools array
95
+ */
96
+ setFrontendTools(frontendTools: AngularFrontendTool<any>[]): void;
97
+ /**
98
+ * Update human-in-the-loop array
99
+ */
100
+ setHumanInTheLoop(humanInTheLoop: AngularHumanInTheLoop<any>[]): void;
101
+ /**
102
+ * Update current render tool calls
103
+ */
104
+ setCurrentRenderToolCalls(renderToolCalls: ToolCallRender<unknown>[]): void;
105
+ /**
106
+ * Register a tool render
107
+ */
108
+ registerToolRender(name: string, render: ToolCallRender<unknown>): void;
109
+ /**
110
+ * Unregister a tool render
111
+ */
112
+ unregisterToolRender(name: string): void;
113
+ /**
114
+ * Get a specific tool render
115
+ */
116
+ getToolRender(name: string): ToolCallRender<unknown> | undefined;
117
+ static ɵfac: i0.ɵɵFactoryDeclaration<CopilotKitService, never>;
118
+ static ɵprov: i0.ɵɵInjectableDeclaration<CopilotKitService>;
119
+ }
@@ -0,0 +1,83 @@
1
+ import { InjectionToken, TemplateRef, Type, Signal } from "@angular/core";
2
+ import { Observable } from "rxjs";
3
+ import { CopilotKitCore, ToolCallStatus } from "@copilotkitnext/core";
4
+ import { AbstractAgent } from "@ag-ui/client";
5
+ import type { z } from "zod";
6
+ import type { AngularFrontendTool } from "../types/frontend-tool";
7
+ import type { AngularHumanInTheLoop } from "../types/human-in-the-loop";
8
+ export type { Context } from "@ag-ui/client";
9
+ export type { AngularFrontendTool } from "../types/frontend-tool";
10
+ export type { AngularHumanInTheLoop, HumanInTheLoopProps, } from "../types/human-in-the-loop";
11
+ export { ToolCallStatus } from "@copilotkitnext/core";
12
+ export type ToolCallProps<T = unknown> = {
13
+ name: string;
14
+ description: string;
15
+ args: Partial<T>;
16
+ status: ToolCallStatus.InProgress;
17
+ result: undefined;
18
+ } | {
19
+ name: string;
20
+ description: string;
21
+ args: T;
22
+ status: ToolCallStatus.Executing;
23
+ result: undefined;
24
+ } | {
25
+ name: string;
26
+ description: string;
27
+ args: T;
28
+ status: ToolCallStatus.Complete;
29
+ result: string;
30
+ };
31
+ export interface AngularToolCallRender<T = unknown> {
32
+ name: string;
33
+ args: z.ZodSchema<T>;
34
+ /**
35
+ * Optional agent ID to constrain this tool render to a specific agent.
36
+ * If specified, this render will only be used for the specified agent.
37
+ */
38
+ agentId?: string;
39
+ render: Type<any> | TemplateRef<ToolCallProps<T>>;
40
+ }
41
+ export type ToolCallRender<T = unknown> = AngularToolCallRender<T>;
42
+ export interface CopilotKitContextValue {
43
+ copilotkit: CopilotKitCore;
44
+ renderToolCalls: ToolCallRender<unknown>[];
45
+ currentRenderToolCalls: ToolCallRender<unknown>[];
46
+ setCurrentRenderToolCalls: (v: ToolCallRender<unknown>[]) => void;
47
+ }
48
+ export interface CopilotKitRuntimeInputs {
49
+ runtimeUrl?: string;
50
+ headers?: Record<string, string>;
51
+ properties?: Record<string, unknown>;
52
+ agents?: Record<string, AbstractAgent>;
53
+ renderToolCalls?: ToolCallRender<unknown>[];
54
+ }
55
+ export declare const COPILOTKIT_RUNTIME_URL: InjectionToken<string>;
56
+ export declare const COPILOTKIT_HEADERS: InjectionToken<Record<string, string>>;
57
+ export declare const COPILOTKIT_PROPERTIES: InjectionToken<Record<string, unknown>>;
58
+ export declare const COPILOTKIT_AGENTS: InjectionToken<Record<string, AbstractAgent>>;
59
+ export declare const COPILOTKIT_RENDER_TOOL_CALLS: InjectionToken<ToolCallRender<unknown>[]>;
60
+ export declare const COPILOTKIT_FRONTEND_TOOLS: InjectionToken<AngularFrontendTool<any>[]>;
61
+ export declare const COPILOTKIT_HUMAN_IN_THE_LOOP: InjectionToken<AngularHumanInTheLoop<any>[]>;
62
+ import type { Message } from "@ag-ui/client";
63
+ export interface AgentWatchResult {
64
+ agent: Signal<AbstractAgent | undefined>;
65
+ messages: Signal<Message[]>;
66
+ isRunning: Signal<boolean>;
67
+ agent$: Observable<AbstractAgent | undefined>;
68
+ messages$: Observable<Message[]>;
69
+ isRunning$: Observable<boolean>;
70
+ unsubscribe: () => void;
71
+ }
72
+ export interface AgentSubscriptionCallbacks {
73
+ onMessagesChanged?: (params: any) => void;
74
+ onStateChanged?: (params: any) => void;
75
+ onRunInitialized?: (params: any) => void;
76
+ onRunFinalized?: (params: any) => void;
77
+ onRunFailed?: (params: any) => void;
78
+ }
79
+ export interface HumanInTheLoopState {
80
+ status: Signal<ToolCallStatus>;
81
+ toolId: string;
82
+ destroy: () => void;
83
+ }
@@ -0,0 +1,68 @@
1
+ import { OnInit, OnChanges, OnDestroy, SimpleChanges } from "@angular/core";
2
+ import { CopilotKitService } from "../core/copilotkit.service";
3
+ import type { Context } from "@ag-ui/client";
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Directive to manage agent context in CopilotKit.
7
+ * Automatically adds context on init, updates on changes, and removes on destroy.
8
+ *
9
+ * @example
10
+ * ```html
11
+ * <!-- With separate inputs -->
12
+ * <div copilotkitAgentContext
13
+ * [description]="'User preferences'"
14
+ * [value]="userSettings">
15
+ * </div>
16
+ *
17
+ * <!-- With context object -->
18
+ * <div [copilotkitAgentContext]="contextObject">
19
+ * </div>
20
+ *
21
+ * <!-- With dynamic values -->
22
+ * <div copilotkitAgentContext
23
+ * description="Form state"
24
+ * [value]="formData$ | async">
25
+ * </div>
26
+ * ```
27
+ */
28
+ export declare class CopilotKitAgentContextDirective implements OnInit, OnChanges, OnDestroy {
29
+ private readonly copilotkit;
30
+ private contextId?;
31
+ constructor(copilotkit: CopilotKitService);
32
+ /**
33
+ * Context object containing both description and value.
34
+ * If provided, this takes precedence over individual inputs.
35
+ */
36
+ context?: Context;
37
+ /**
38
+ * Description of the context.
39
+ * Used when context object is not provided.
40
+ */
41
+ description?: string;
42
+ /**
43
+ * Value of the context.
44
+ * Used when context object is not provided.
45
+ */
46
+ value?: any;
47
+ ngOnInit(): void;
48
+ ngOnChanges(changes: SimpleChanges): void;
49
+ ngOnDestroy(): void;
50
+ /**
51
+ * Adds the context to CopilotKit
52
+ */
53
+ private addContext;
54
+ /**
55
+ * Updates the context by removing the old one and adding a new one
56
+ */
57
+ private updateContext;
58
+ /**
59
+ * Removes the current context from CopilotKit
60
+ */
61
+ private removeContext;
62
+ /**
63
+ * Gets the context object from inputs
64
+ */
65
+ private getContext;
66
+ static ɵfac: i0.ɵɵFactoryDeclaration<CopilotKitAgentContextDirective, never>;
67
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CopilotKitAgentContextDirective, "[copilotkitAgentContext]", never, { "context": { "alias": "copilotkitAgentContext"; "required": false; }; "description": { "alias": "description"; "required": false; }; "value": { "alias": "value"; "required": false; }; }, {}, never, never, true, never>;
68
+ }
@@ -0,0 +1,106 @@
1
+ import { EventEmitter, OnInit, OnChanges, OnDestroy, SimpleChanges } from "@angular/core";
2
+ import { Observable } from "rxjs";
3
+ import { CopilotKitService } from "../core/copilotkit.service";
4
+ import { AbstractAgent } from "@ag-ui/client";
5
+ import * as i0 from "@angular/core";
6
+ /**
7
+ * Directive to watch and interact with CopilotKit agents.
8
+ * Provides reactive outputs for agent state changes.
9
+ *
10
+ * @example
11
+ * ```html
12
+ * <!-- Basic usage with default agent -->
13
+ * <div copilotkitAgent
14
+ * (agentChange)="onAgentChange($event)"
15
+ * (runningChange)="isProcessing = $event">
16
+ * Content here
17
+ * </div>
18
+ *
19
+ * <!-- With specific agent ID -->
20
+ * <div copilotkitAgent
21
+ * [agentId]="'my-agent-id'"
22
+ * (agentChange)="currentAgent = $event"
23
+ * (runningChange)="onRunningStateChange($event)"
24
+ * (messagesChange)="onMessagesUpdate($event)"
25
+ * (stateChange)="onStateUpdate($event)">
26
+ * Content here
27
+ * </div>
28
+ *
29
+ * <!-- Two-way binding for running state -->
30
+ * <div copilotkitAgent
31
+ * [(running)]="isAgentRunning">
32
+ * <span *ngIf="isAgentRunning">Processing...</span>
33
+ * </div>
34
+ * ```
35
+ */
36
+ export declare class CopilotKitAgentDirective implements OnInit, OnChanges, OnDestroy {
37
+ private readonly copilotkit;
38
+ private agent?;
39
+ private agentSubscription?;
40
+ private coreUnsubscribe?;
41
+ private _isRunning;
42
+ private runningSignal;
43
+ private agentSignal;
44
+ constructor(copilotkit: CopilotKitService);
45
+ /**
46
+ * The ID of the agent to watch.
47
+ * If not provided, uses the default agent ID.
48
+ */
49
+ agentId?: string;
50
+ /**
51
+ * Alternative input using the directive selector.
52
+ * Allows: [copilotkitAgent]="'agent-id'"
53
+ */
54
+ set directiveAgentId(value: string | undefined);
55
+ /**
56
+ * Emits when the agent instance changes.
57
+ */
58
+ agentChange: EventEmitter<AbstractAgent>;
59
+ /**
60
+ * Emits when the running state changes.
61
+ */
62
+ runningChange: EventEmitter<boolean>;
63
+ /**
64
+ * Observable of the running state.
65
+ */
66
+ get running$(): Observable<boolean>;
67
+ /**
68
+ * Observable of the agent instance.
69
+ */
70
+ get agent$(): Observable<AbstractAgent | undefined>;
71
+ /**
72
+ * Two-way binding for running state.
73
+ */
74
+ get running(): boolean;
75
+ set running(value: boolean);
76
+ /**
77
+ * Emits when agent messages change.
78
+ */
79
+ messagesChange: EventEmitter<any>;
80
+ /**
81
+ * Emits when agent state changes.
82
+ */
83
+ stateChange: EventEmitter<any>;
84
+ /**
85
+ * Emits when a run is initialized.
86
+ */
87
+ runInitialized: EventEmitter<any>;
88
+ /**
89
+ * Emits when a run is finalized.
90
+ */
91
+ runFinalized: EventEmitter<any>;
92
+ /**
93
+ * Emits when a run fails.
94
+ */
95
+ runFailed: EventEmitter<any>;
96
+ ngOnInit(): void;
97
+ ngOnChanges(changes: SimpleChanges): void;
98
+ ngOnDestroy(): void;
99
+ private setupAgent;
100
+ private subscribeToAgent;
101
+ private subscribeToCore;
102
+ private cleanupAgentSubscription;
103
+ private cleanupCoreSubscription;
104
+ static ɵfac: i0.ɵɵFactoryDeclaration<CopilotKitAgentDirective, never>;
105
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CopilotKitAgentDirective, "[copilotkitAgent]", never, { "agentId": { "alias": "agentId"; "required": false; }; "directiveAgentId": { "alias": "copilotkitAgent"; "required": false; }; "running": { "alias": "running"; "required": false; }; }, { "agentChange": "agentChange"; "runningChange": "runningChange"; "messagesChange": "messagesChange"; "stateChange": "stateChange"; "runInitialized": "runInitialized"; "runFinalized": "runFinalized"; "runFailed": "runFailed"; }, never, never, true, never>;
106
+ }
@@ -0,0 +1,84 @@
1
+ import { EventEmitter, OnInit, OnChanges, OnDestroy, SimpleChanges } from "@angular/core";
2
+ import { CopilotChatConfigurationService } from "../core/chat-configuration/chat-configuration.service";
3
+ import { CopilotChatConfiguration, CopilotChatLabels } from "../core/chat-configuration/chat-configuration.types";
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Directive for configuring CopilotKit chat settings declaratively in templates.
7
+ * Works with the CopilotChatConfigurationService to provide reactive chat configuration.
8
+ *
9
+ * @example
10
+ * ```html
11
+ * <!-- Basic usage with individual inputs -->
12
+ * <div copilotkitChatConfig
13
+ * [labels]="customLabels"
14
+ * [inputValue]="currentInput"
15
+ * (submitInput)="onSubmit($event)"
16
+ * (changeInput)="onChange($event)">
17
+ * <!-- Chat UI components -->
18
+ * </div>
19
+ *
20
+ * <!-- Using configuration object -->
21
+ * <div [copilotkitChatConfig]="chatConfig">
22
+ * <!-- Chat UI components -->
23
+ * </div>
24
+ *
25
+ * <!-- Two-way binding for input value -->
26
+ * <div copilotkitChatConfig
27
+ * [(value)]="chatInput"
28
+ * (submitInput)="handleSubmit($event)">
29
+ * <!-- Chat UI components -->
30
+ * </div>
31
+ * ```
32
+ */
33
+ export declare class CopilotKitChatConfigDirective implements OnInit, OnChanges, OnDestroy {
34
+ private readonly chatConfig;
35
+ private _value?;
36
+ private submitHandler?;
37
+ private changeHandler?;
38
+ constructor(chatConfig: CopilotChatConfigurationService | null);
39
+ /**
40
+ * Partial labels to override defaults
41
+ */
42
+ labels?: Partial<CopilotChatLabels>;
43
+ /**
44
+ * The current input value
45
+ */
46
+ inputValue?: string;
47
+ /**
48
+ * Event emitted when input is submitted
49
+ */
50
+ submitInput: EventEmitter<string>;
51
+ /**
52
+ * Event emitted when input value changes
53
+ */
54
+ changeInput: EventEmitter<string>;
55
+ /**
56
+ * Alternative: accept full configuration object
57
+ */
58
+ set config(value: CopilotChatConfiguration | undefined);
59
+ /**
60
+ * Two-way binding for input value
61
+ */
62
+ get value(): string | undefined;
63
+ set value(v: string | undefined);
64
+ /**
65
+ * Two-way binding output for value
66
+ */
67
+ valueChange: EventEmitter<string>;
68
+ ngOnInit(): void;
69
+ ngOnChanges(changes: SimpleChanges): void;
70
+ ngOnDestroy(): void;
71
+ /**
72
+ * Submit the current input value
73
+ */
74
+ submit(value: string): void;
75
+ /**
76
+ * Handle input value change
77
+ */
78
+ change(value: string): void;
79
+ private updateConfiguration;
80
+ private updateInputValue;
81
+ private setupHandlers;
82
+ static ɵfac: i0.ɵɵFactoryDeclaration<CopilotKitChatConfigDirective, [{ optional: true; }]>;
83
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CopilotKitChatConfigDirective, "[copilotkitChatConfig]", never, { "labels": { "alias": "labels"; "required": false; }; "inputValue": { "alias": "inputValue"; "required": false; }; "config": { "alias": "copilotkitChatConfig"; "required": false; }; "value": { "alias": "value"; "required": false; }; }, { "submitInput": "submitInput"; "changeInput": "changeInput"; "valueChange": "valueChange"; }, never, never, true, never>;
84
+ }
@@ -0,0 +1,44 @@
1
+ import { OnChanges, SimpleChanges } from "@angular/core";
2
+ import { CopilotKitService } from "../core/copilotkit.service";
3
+ import { AbstractAgent } from "@ag-ui/client";
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Directive to configure CopilotKit runtime settings declaratively in templates.
7
+ *
8
+ * @example
9
+ * ```html
10
+ * <div [copilotkitConfig]="{
11
+ * runtimeUrl: 'https://api.example.com',
12
+ * headers: { 'Authorization': 'Bearer token' }
13
+ * }">
14
+ * <!-- Your app content -->
15
+ * </div>
16
+ * ```
17
+ *
18
+ * Or with individual inputs:
19
+ * ```html
20
+ * <div copilotkitConfig
21
+ * [runtimeUrl]="apiUrl"
22
+ * [headers]="authHeaders"
23
+ * [agents]="myAgents">
24
+ * <!-- Your app content -->
25
+ * </div>
26
+ * ```
27
+ */
28
+ export declare class CopilotKitConfigDirective implements OnChanges {
29
+ private readonly copilotkit;
30
+ constructor(copilotkit: CopilotKitService);
31
+ copilotkitConfig?: {
32
+ runtimeUrl?: string;
33
+ headers?: Record<string, string>;
34
+ properties?: Record<string, unknown>;
35
+ agents?: Record<string, AbstractAgent>;
36
+ };
37
+ runtimeUrl?: string;
38
+ headers?: Record<string, string>;
39
+ properties?: Record<string, unknown>;
40
+ agents?: Record<string, AbstractAgent>;
41
+ ngOnChanges(changes: SimpleChanges): void;
42
+ static ɵfac: i0.ɵɵFactoryDeclaration<CopilotKitConfigDirective, never>;
43
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CopilotKitConfigDirective, "[copilotkitConfig]", never, { "copilotkitConfig": { "alias": "copilotkitConfig"; "required": false; }; "runtimeUrl": { "alias": "runtimeUrl"; "required": false; }; "headers": { "alias": "headers"; "required": false; }; "properties": { "alias": "properties"; "required": false; }; "agents": { "alias": "agents"; "required": false; }; }, {}, never, never, true, never>;
44
+ }
@@ -0,0 +1,25 @@
1
+ import { OnInit, OnChanges, OnDestroy, SimpleChanges, TemplateRef, Type } from "@angular/core";
2
+ import { CopilotKitService } from "../core/copilotkit.service";
3
+ import type { AngularFrontendTool } from "../core/copilotkit.types";
4
+ import { z } from "zod";
5
+ import * as i0 from "@angular/core";
6
+ export declare class CopilotKitFrontendToolDirective<T extends Record<string, any> = Record<string, any>> implements OnInit, OnChanges, OnDestroy {
7
+ private readonly copilotkit;
8
+ private isRegistered;
9
+ constructor(copilotkit: CopilotKitService);
10
+ name: string;
11
+ description?: string;
12
+ parameters?: z.ZodSchema<T>;
13
+ handler?: (args: T) => Promise<any>;
14
+ render?: Type<any> | TemplateRef<any>;
15
+ followUp?: boolean;
16
+ tool?: AngularFrontendTool<T>;
17
+ ngOnInit(): void;
18
+ ngOnChanges(_changes: SimpleChanges): void;
19
+ ngOnDestroy(): void;
20
+ private registerTool;
21
+ private unregisterTool;
22
+ private getTool;
23
+ static ɵfac: i0.ɵɵFactoryDeclaration<CopilotKitFrontendToolDirective<any>, never>;
24
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CopilotKitFrontendToolDirective<any>, "[copilotkitFrontendTool]", never, { "name": { "alias": "name"; "required": false; }; "description": { "alias": "description"; "required": false; }; "parameters": { "alias": "parameters"; "required": false; }; "handler": { "alias": "handler"; "required": false; }; "render": { "alias": "render"; "required": false; }; "followUp": { "alias": "followUp"; "required": false; }; "tool": { "alias": "copilotkitFrontendTool"; "required": false; }; }, {}, never, never, true, never>;
25
+ }
@@ -0,0 +1,124 @@
1
+ import { EventEmitter, OnInit, OnChanges, OnDestroy, SimpleChanges, TemplateRef, Type } from "@angular/core";
2
+ import { CopilotKitService } from "../core/copilotkit.service";
3
+ import type { AngularHumanInTheLoop, HumanInTheLoopProps } from "../core/copilotkit.types";
4
+ import { ToolCallStatus } from "../core/copilotkit.types";
5
+ import * as z from "zod";
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * Directive for declaratively creating human-in-the-loop tools.
9
+ * Provides reactive outputs for status changes and response events.
10
+ *
11
+ * @example
12
+ * ```html
13
+ * <!-- Basic usage -->
14
+ * <div copilotkitHumanInTheLoop
15
+ * [name]="'requireApproval'"
16
+ * [description]="'Requires user approval'"
17
+ * [args]="argsSchema"
18
+ * [render]="approvalComponent"
19
+ * (statusChange)="onStatusChange($event)"
20
+ * (responseProvided)="onResponse($event)">
21
+ * </div>
22
+ *
23
+ * <!-- With template -->
24
+ * <div copilotkitHumanInTheLoop
25
+ * [name]="'requireApproval'"
26
+ * [description]="'Requires user approval'"
27
+ * [args]="argsSchema"
28
+ * [render]="approvalTemplate"
29
+ * [(status)]="approvalStatus">
30
+ * </div>
31
+ *
32
+ * <ng-template #approvalTemplate let-props>
33
+ * <div *ngIf="props.status === 'executing'">
34
+ * <p>{{ props.args.action }}</p>
35
+ * <button (click)="props.respond('approved')">Approve</button>
36
+ * <button (click)="props.respond('rejected')">Reject</button>
37
+ * </div>
38
+ * </ng-template>
39
+ * ```
40
+ */
41
+ export declare class CopilotKitHumanInTheLoopDirective<T extends Record<string, any> = Record<string, any>> implements OnInit, OnChanges, OnDestroy {
42
+ private readonly copilotkit;
43
+ private toolId?;
44
+ private statusSignal;
45
+ private resolvePromise;
46
+ private _status;
47
+ constructor(copilotkit: CopilotKitService);
48
+ /**
49
+ * The name of the human-in-the-loop tool.
50
+ */
51
+ name: string;
52
+ /**
53
+ * Description of what the tool does.
54
+ */
55
+ description: string;
56
+ /**
57
+ * Zod schema for the tool parameters.
58
+ */
59
+ parameters: z.ZodSchema<T>;
60
+ /**
61
+ * Component class or template to render for user interaction.
62
+ */
63
+ render: Type<any> | TemplateRef<HumanInTheLoopProps<T>>;
64
+ /**
65
+ * Whether the tool should be registered (default: true).
66
+ */
67
+ enabled: boolean;
68
+ /**
69
+ * Alternative input using the directive selector.
70
+ * Allows: [copilotkitHumanInTheLoop]="config"
71
+ */
72
+ set config(value: Partial<AngularHumanInTheLoop<T>> | undefined);
73
+ /**
74
+ * Emits when the status changes.
75
+ */
76
+ statusChange: EventEmitter<ToolCallStatus>;
77
+ /**
78
+ * Two-way binding for status.
79
+ */
80
+ get status(): ToolCallStatus;
81
+ set status(value: ToolCallStatus);
82
+ /**
83
+ * Emits when a response is provided by the user.
84
+ */
85
+ responseProvided: EventEmitter<unknown>;
86
+ /**
87
+ * Emits when the tool execution starts.
88
+ */
89
+ executionStarted: EventEmitter<any>;
90
+ /**
91
+ * Emits when the tool execution completes.
92
+ */
93
+ executionCompleted: EventEmitter<unknown>;
94
+ ngOnInit(): void;
95
+ ngOnChanges(changes: SimpleChanges): void;
96
+ ngOnDestroy(): void;
97
+ /**
98
+ * Programmatically trigger a response.
99
+ * Useful when the directive is used as a controller.
100
+ */
101
+ respond(result: unknown): void;
102
+ private registerTool;
103
+ private unregisterTool;
104
+ private createEnhancedRender;
105
+ private handleResponse;
106
+ private updateStatus;
107
+ static ɵfac: i0.ɵɵFactoryDeclaration<CopilotKitHumanInTheLoopDirective<any>, never>;
108
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CopilotKitHumanInTheLoopDirective<any>, "[copilotkitHumanInTheLoop]", never, { "name": { "alias": "name"; "required": false; }; "description": { "alias": "description"; "required": false; }; "parameters": { "alias": "parameters"; "required": false; }; "render": { "alias": "render"; "required": false; }; "enabled": { "alias": "enabled"; "required": false; }; "config": { "alias": "copilotkitHumanInTheLoop"; "required": false; }; "status": { "alias": "status"; "required": false; }; }, { "statusChange": "statusChange"; "responseProvided": "responseProvided"; "executionStarted": "executionStarted"; "executionCompleted": "executionCompleted"; }, never, never, true, never>;
109
+ }
110
+ /**
111
+ * Helper directive to provide respond function in templates.
112
+ * This would be used internally by the tool render component.
113
+ *
114
+ * @internal
115
+ */
116
+ export declare class CopilotKitHumanInTheLoopRespondDirective {
117
+ copilotkitHumanInTheLoopRespond?: (result: unknown) => Promise<void>;
118
+ /**
119
+ * Convenience method for templates to call respond.
120
+ */
121
+ respond(result: unknown): void;
122
+ static ɵfac: i0.ɵɵFactoryDeclaration<CopilotKitHumanInTheLoopRespondDirective, never>;
123
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CopilotKitHumanInTheLoopRespondDirective, "[copilotkitHumanInTheLoopRespond]", never, { "copilotkitHumanInTheLoopRespond": { "alias": "copilotkitHumanInTheLoopRespond"; "required": false; }; }, {}, never, never, true, never>;
124
+ }