@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.
- package/README.md +3 -3
- package/dist/README.md +3 -3
- package/dist/components/chat/copilot-chat-assistant-message.component.d.ts +10 -10
- package/dist/components/chat/copilot-chat-message-view.component.d.ts +42 -42
- package/dist/components/chat/copilot-chat-view.component.d.ts +14 -14
- package/dist/esm2022/components/chat/copilot-chat-assistant-message-buttons.component.mjs +384 -0
- package/dist/esm2022/components/chat/copilot-chat-assistant-message-renderer.component.mjs +286 -0
- package/dist/esm2022/components/chat/copilot-chat-assistant-message-toolbar.component.mjs +27 -0
- package/dist/esm2022/components/chat/copilot-chat-assistant-message.component.mjs +433 -0
- package/dist/esm2022/components/chat/copilot-chat-assistant-message.types.mjs +2 -0
- package/dist/esm2022/components/chat/copilot-chat-audio-recorder.component.mjs +202 -0
- package/dist/esm2022/components/chat/copilot-chat-buttons.component.mjs +321 -0
- package/dist/esm2022/components/chat/copilot-chat-input-defaults.mjs +38 -0
- package/dist/esm2022/components/chat/copilot-chat-input.component.mjs +666 -0
- package/dist/esm2022/components/chat/copilot-chat-input.types.mjs +10 -0
- package/dist/esm2022/components/chat/copilot-chat-message-view-cursor.component.mjs +45 -0
- package/dist/esm2022/components/chat/copilot-chat-message-view.component.mjs +296 -0
- package/dist/esm2022/components/chat/copilot-chat-message-view.types.mjs +2 -0
- package/dist/esm2022/components/chat/copilot-chat-textarea.component.mjs +188 -0
- package/dist/esm2022/components/chat/copilot-chat-tool-calls-view.component.mjs +216 -0
- package/dist/esm2022/components/chat/copilot-chat-toolbar.component.mjs +25 -0
- package/dist/esm2022/components/chat/copilot-chat-tools-menu.component.mjs +199 -0
- package/dist/esm2022/components/chat/copilot-chat-user-message-branch-navigation.component.mjs +137 -0
- package/dist/esm2022/components/chat/copilot-chat-user-message-buttons.component.mjs +207 -0
- package/dist/esm2022/components/chat/copilot-chat-user-message-renderer.component.mjs +35 -0
- package/dist/esm2022/components/chat/copilot-chat-user-message-toolbar.component.mjs +34 -0
- package/dist/esm2022/components/chat/copilot-chat-user-message.component.mjs +341 -0
- package/dist/esm2022/components/chat/copilot-chat-user-message.types.mjs +2 -0
- package/dist/esm2022/components/chat/copilot-chat-view-disclaimer.component.mjs +52 -0
- package/dist/esm2022/components/chat/copilot-chat-view-feather.component.mjs +55 -0
- package/dist/esm2022/components/chat/copilot-chat-view-handlers.service.mjs +19 -0
- package/dist/esm2022/components/chat/copilot-chat-view-input-container.component.mjs +110 -0
- package/dist/esm2022/components/chat/copilot-chat-view-scroll-to-bottom-button.component.mjs +93 -0
- package/dist/esm2022/components/chat/copilot-chat-view-scroll-view.component.mjs +443 -0
- package/dist/esm2022/components/chat/copilot-chat-view.component.mjs +479 -0
- package/dist/esm2022/components/chat/copilot-chat-view.types.mjs +2 -0
- package/dist/esm2022/components/chat/copilot-chat.component.mjs +214 -0
- package/dist/esm2022/components/copilotkit-tool-render.component.mjs +153 -0
- package/dist/esm2022/copilotkitnext-angular.mjs +5 -0
- package/dist/esm2022/core/chat-configuration/chat-configuration.providers.mjs +65 -0
- package/dist/esm2022/core/chat-configuration/chat-configuration.service.mjs +145 -0
- package/dist/esm2022/core/chat-configuration/chat-configuration.types.mjs +26 -0
- package/dist/esm2022/core/copilotkit.providers.mjs +34 -0
- package/dist/esm2022/core/copilotkit.service.mjs +430 -0
- package/dist/esm2022/core/copilotkit.types.mjs +12 -0
- package/dist/esm2022/directives/copilotkit-agent-context.directive.mjs +130 -0
- package/dist/esm2022/directives/copilotkit-agent.directive.mjs +217 -0
- package/dist/esm2022/directives/copilotkit-chat-config.directive.mjs +218 -0
- package/dist/esm2022/directives/copilotkit-config.directive.mjs +94 -0
- package/dist/esm2022/directives/copilotkit-frontend-tool.directive.mjs +130 -0
- package/dist/esm2022/directives/copilotkit-human-in-the-loop.directive.mjs +266 -0
- package/dist/esm2022/directives/stick-to-bottom.directive.mjs +181 -0
- package/dist/esm2022/index.mjs +70 -0
- package/dist/esm2022/lib/directives/tooltip.directive.mjs +211 -0
- package/dist/esm2022/lib/slots/copilot-slot.component.mjs +144 -0
- package/dist/esm2022/lib/slots/slot.types.mjs +6 -0
- package/dist/esm2022/lib/slots/slot.utils.mjs +222 -0
- package/dist/esm2022/lib/utils.mjs +10 -0
- package/dist/esm2022/services/resize-observer.service.mjs +152 -0
- package/dist/esm2022/services/scroll-position.service.mjs +124 -0
- package/dist/esm2022/types/frontend-tool.mjs +2 -0
- package/dist/esm2022/types/human-in-the-loop.mjs +2 -0
- package/dist/esm2022/utils/agent-context.utils.mjs +114 -0
- package/dist/esm2022/utils/agent.utils.mjs +204 -0
- package/dist/esm2022/utils/chat-config.utils.mjs +186 -0
- package/dist/esm2022/utils/copilotkit.utils.mjs +20 -0
- package/dist/esm2022/utils/frontend-tool.utils.mjs +228 -0
- package/dist/esm2022/utils/human-in-the-loop.utils.mjs +296 -0
- package/dist/fesm2022/copilotkitnext-angular.mjs +163 -164
- package/dist/fesm2022/copilotkitnext-angular.mjs.map +1 -1
- package/package.json +21 -18
- package/vitest.config.mts +32 -21
- package/.turbo/turbo-build.log +0 -38
- package/.turbo/turbo-check-types.log +0 -0
- package/.turbo/turbo-test.log +0 -71
- package/ng-package.json +0 -19
- package/src/components/chat/__tests__/copilot-chat-assistant-message.component.spec.ts +0 -282
- package/src/components/chat/__tests__/copilot-chat-input.component.spec.ts +0 -419
- package/src/components/chat/__tests__/copilot-chat-message-view.component.spec.ts +0 -372
- package/src/components/chat/__tests__/copilot-chat-user-message.component.spec.ts +0 -249
- package/src/components/chat/copilot-chat-assistant-message-buttons.component.ts +0 -292
- package/src/components/chat/copilot-chat-assistant-message-renderer.component.ts +0 -472
- package/src/components/chat/copilot-chat-assistant-message-toolbar.component.ts +0 -29
- package/src/components/chat/copilot-chat-assistant-message.component.ts +0 -463
- package/src/components/chat/copilot-chat-assistant-message.types.ts +0 -50
- package/src/components/chat/copilot-chat-audio-recorder.component.ts +0 -241
- package/src/components/chat/copilot-chat-buttons.component.ts +0 -308
- package/src/components/chat/copilot-chat-buttons.component.ts.bak +0 -471
- package/src/components/chat/copilot-chat-input-defaults.ts +0 -47
- package/src/components/chat/copilot-chat-input.component.ts +0 -512
- package/src/components/chat/copilot-chat-input.types.ts +0 -148
- package/src/components/chat/copilot-chat-message-view-cursor.component.ts +0 -51
- package/src/components/chat/copilot-chat-message-view.component.ts +0 -233
- package/src/components/chat/copilot-chat-message-view.types.ts +0 -39
- package/src/components/chat/copilot-chat-textarea.component.ts +0 -220
- package/src/components/chat/copilot-chat-tool-calls-view.component.ts +0 -261
- package/src/components/chat/copilot-chat-toolbar.component.ts +0 -35
- package/src/components/chat/copilot-chat-tools-menu.component.ts +0 -185
- package/src/components/chat/copilot-chat-user-message-branch-navigation.component.ts +0 -121
- package/src/components/chat/copilot-chat-user-message-buttons.component.ts +0 -170
- package/src/components/chat/copilot-chat-user-message-renderer.component.ts +0 -37
- package/src/components/chat/copilot-chat-user-message-toolbar.component.ts +0 -37
- package/src/components/chat/copilot-chat-user-message.component.ts +0 -247
- package/src/components/chat/copilot-chat-user-message.types.ts +0 -42
- package/src/components/chat/copilot-chat-view-disclaimer.component.ts +0 -51
- package/src/components/chat/copilot-chat-view-feather.component.ts +0 -47
- package/src/components/chat/copilot-chat-view-handlers.service.ts +0 -14
- package/src/components/chat/copilot-chat-view-input-container.component.ts +0 -87
- package/src/components/chat/copilot-chat-view-scroll-to-bottom-button.component.ts +0 -79
- package/src/components/chat/copilot-chat-view-scroll-view.component.ts +0 -322
- package/src/components/chat/copilot-chat-view.component.ts +0 -420
- package/src/components/chat/copilot-chat-view.types.ts +0 -52
- package/src/components/chat/copilot-chat.component.ts +0 -232
- package/src/components/copilotkit-tool-render.component.ts +0 -169
- package/src/core/__tests__/copilotkit.service.spec.ts +0 -1051
- package/src/core/__tests__/copilotkit.service.wildcard.spec.ts +0 -316
- package/src/core/chat-configuration/__tests__/chat-configuration.service.spec.ts +0 -287
- package/src/core/chat-configuration/chat-configuration.providers.ts +0 -71
- package/src/core/chat-configuration/chat-configuration.service.ts +0 -162
- package/src/core/chat-configuration/chat-configuration.types.ts +0 -57
- package/src/core/copilotkit.providers.ts +0 -59
- package/src/core/copilotkit.service.ts +0 -542
- package/src/core/copilotkit.types.ts +0 -132
- package/src/directives/__tests__/copilotkit-agent-context.directive.spec.ts +0 -384
- package/src/directives/__tests__/copilotkit-agent.directive.spec.ts +0 -253
- package/src/directives/__tests__/copilotkit-chat-config.directive.spec.ts +0 -385
- package/src/directives/__tests__/copilotkit-config.directive.spec.ts +0 -69
- package/src/directives/__tests__/copilotkit-frontend-tool-simple.directive.spec.ts +0 -60
- package/src/directives/__tests__/copilotkit-frontend-tool.directive.spec.ts +0 -108
- package/src/directives/__tests__/copilotkit-human-in-the-loop.directive.spec.ts +0 -452
- package/src/directives/copilotkit-agent-context.directive.ts +0 -138
- package/src/directives/copilotkit-agent.directive.ts +0 -225
- package/src/directives/copilotkit-chat-config.directive.ts +0 -241
- package/src/directives/copilotkit-config.directive.ts +0 -81
- package/src/directives/copilotkit-frontend-tool.directive.ts +0 -145
- package/src/directives/copilotkit-human-in-the-loop.directive.ts +0 -281
- package/src/directives/stick-to-bottom.directive.ts +0 -204
- package/src/index.ts +0 -105
- package/src/lib/directives/tooltip.directive.ts +0 -292
- package/src/lib/slots/__tests__/slot.utils.spec.ts +0 -377
- package/src/lib/slots/copilot-slot.component.ts +0 -135
- package/src/lib/slots/index.ts +0 -3
- package/src/lib/slots/slot.types.ts +0 -64
- package/src/lib/slots/slot.utils.ts +0 -289
- package/src/lib/utils.ts +0 -10
- package/src/public-api.ts +0 -1
- package/src/services/resize-observer.service.ts +0 -181
- package/src/services/scroll-position.service.ts +0 -169
- package/src/styles/globals.css +0 -266
- package/src/styles/index.css +0 -3
- package/src/test-setup.ts +0 -15
- package/src/testing/index.ts +0 -3
- package/src/testing/testing.utils.ts +0 -248
- package/src/types/frontend-tool.ts +0 -44
- package/src/types/human-in-the-loop.ts +0 -52
- package/src/utils/__tests__/agent.utils.spec.ts +0 -234
- package/src/utils/__tests__/chat-config.utils.spec.ts +0 -306
- package/src/utils/__tests__/frontend-tool-inject.spec.ts +0 -350
- package/src/utils/__tests__/frontend-tool-integration.spec.ts +0 -199
- package/src/utils/__tests__/frontend-tool.utils.spec.ts +0 -272
- package/src/utils/__tests__/human-in-the-loop.utils.spec.ts +0 -365
- package/src/utils/agent-context.utils.ts +0 -133
- package/src/utils/agent.utils.ts +0 -239
- package/src/utils/chat-config.utils.ts +0 -221
- package/src/utils/copilotkit.utils.ts +0 -20
- package/src/utils/frontend-tool.utils.ts +0 -266
- package/src/utils/human-in-the-loop.utils.ts +0 -359
- package/tsconfig.spec.json +0 -12
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Component,
|
|
3
|
-
Input,
|
|
4
|
-
ViewContainerRef,
|
|
5
|
-
TemplateRef,
|
|
6
|
-
Type,
|
|
7
|
-
OnChanges,
|
|
8
|
-
SimpleChanges,
|
|
9
|
-
ComponentRef,
|
|
10
|
-
inject,
|
|
11
|
-
ViewChild,
|
|
12
|
-
AfterViewInit,
|
|
13
|
-
} from "@angular/core";
|
|
14
|
-
import { CommonModule } from "@angular/common";
|
|
15
|
-
import { CopilotKitService } from "../core/copilotkit.service";
|
|
16
|
-
import type {
|
|
17
|
-
ToolCallProps,
|
|
18
|
-
AngularToolCallRender,
|
|
19
|
-
} from "../core/copilotkit.types";
|
|
20
|
-
import { ToolCallStatus } from "../core/copilotkit.types";
|
|
21
|
-
|
|
22
|
-
@Component({
|
|
23
|
-
selector: "copilotkit-tool-render",
|
|
24
|
-
standalone: true,
|
|
25
|
-
imports: [CommonModule],
|
|
26
|
-
template: `
|
|
27
|
-
<ng-container #dynamicContainer></ng-container>
|
|
28
|
-
<ng-container *ngIf="templateRef && templateContext">
|
|
29
|
-
<ng-container
|
|
30
|
-
*ngTemplateOutlet="templateRef; context: templateContext"
|
|
31
|
-
></ng-container>
|
|
32
|
-
</ng-container>
|
|
33
|
-
`,
|
|
34
|
-
})
|
|
35
|
-
export class CopilotKitToolRenderComponent implements OnChanges, AfterViewInit {
|
|
36
|
-
@Input() toolName!: string;
|
|
37
|
-
@Input() args: any;
|
|
38
|
-
@Input() status: ToolCallStatus = ToolCallStatus.InProgress;
|
|
39
|
-
@Input() result?: any;
|
|
40
|
-
@Input() description?: string;
|
|
41
|
-
|
|
42
|
-
@ViewChild("dynamicContainer", { read: ViewContainerRef, static: true })
|
|
43
|
-
private container!: ViewContainerRef;
|
|
44
|
-
|
|
45
|
-
private copilotkit = inject(CopilotKitService);
|
|
46
|
-
private componentRef?: ComponentRef<any>;
|
|
47
|
-
|
|
48
|
-
templateRef?: TemplateRef<any>;
|
|
49
|
-
templateContext?: any;
|
|
50
|
-
|
|
51
|
-
ngAfterViewInit(): void {
|
|
52
|
-
this.renderTool();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
ngOnChanges(changes: SimpleChanges): void {
|
|
56
|
-
if (
|
|
57
|
-
changes["toolName"] ||
|
|
58
|
-
changes["args"] ||
|
|
59
|
-
changes["status"] ||
|
|
60
|
-
changes["result"]
|
|
61
|
-
) {
|
|
62
|
-
this.renderTool();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private renderTool(): void {
|
|
67
|
-
// Clear existing component
|
|
68
|
-
if (this.componentRef) {
|
|
69
|
-
this.componentRef.destroy();
|
|
70
|
-
this.componentRef = undefined;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Clear template
|
|
74
|
-
this.templateRef = undefined;
|
|
75
|
-
this.templateContext = undefined;
|
|
76
|
-
|
|
77
|
-
if (!this.toolName) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Get the tool render configuration
|
|
82
|
-
const toolRender = this.copilotkit.getToolRender(this.toolName) as
|
|
83
|
-
| AngularToolCallRender
|
|
84
|
-
| undefined;
|
|
85
|
-
|
|
86
|
-
if (!toolRender) {
|
|
87
|
-
console.warn(`No render found for tool: ${this.toolName}`);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Prepare props to pass to the component
|
|
92
|
-
const props: ToolCallProps<any> = {
|
|
93
|
-
name: this.toolName,
|
|
94
|
-
description: this.description || "",
|
|
95
|
-
args: this.args,
|
|
96
|
-
status: this.status,
|
|
97
|
-
result: this.result,
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
// Check if render is a Component class or TemplateRef
|
|
101
|
-
if (this.isComponentClass(toolRender.render)) {
|
|
102
|
-
// Create component dynamically
|
|
103
|
-
this.renderComponent(toolRender.render, props);
|
|
104
|
-
} else if (this.isTemplateRef(toolRender.render)) {
|
|
105
|
-
// Use template
|
|
106
|
-
this.renderTemplate(toolRender.render, props);
|
|
107
|
-
} else {
|
|
108
|
-
console.error(`Invalid render type for tool: ${this.toolName}`);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
private renderComponent(
|
|
113
|
-
componentClass: Type<any>,
|
|
114
|
-
props: ToolCallProps
|
|
115
|
-
): void {
|
|
116
|
-
// Clear the container
|
|
117
|
-
this.container.clear();
|
|
118
|
-
|
|
119
|
-
// Create the component
|
|
120
|
-
this.componentRef = this.container.createComponent(componentClass);
|
|
121
|
-
|
|
122
|
-
// Set inputs on the component using setInput
|
|
123
|
-
// Try setting a single 'props' input first
|
|
124
|
-
try {
|
|
125
|
-
this.componentRef.setInput('props', props);
|
|
126
|
-
} catch (e) {
|
|
127
|
-
// If props input doesn't exist, try setting individual inputs
|
|
128
|
-
for (const [key, value] of Object.entries(props)) {
|
|
129
|
-
try {
|
|
130
|
-
this.componentRef.setInput(key, value);
|
|
131
|
-
} catch (inputError) {
|
|
132
|
-
// Input might not exist on the component, skip it
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Trigger change detection
|
|
138
|
-
this.componentRef.changeDetectorRef.detectChanges();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
private renderTemplate(
|
|
142
|
-
template: TemplateRef<any>,
|
|
143
|
-
props: ToolCallProps
|
|
144
|
-
): void {
|
|
145
|
-
this.templateRef = template;
|
|
146
|
-
this.templateContext = {
|
|
147
|
-
$implicit: props,
|
|
148
|
-
name: props.name,
|
|
149
|
-
description: props.description,
|
|
150
|
-
args: props.args,
|
|
151
|
-
status: props.status,
|
|
152
|
-
result: props.result,
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
private isComponentClass(value: any): value is Type<any> {
|
|
157
|
-
return typeof value === "function" && value.prototype;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
private isTemplateRef(value: any): value is TemplateRef<any> {
|
|
161
|
-
return value instanceof TemplateRef;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
ngOnDestroy(): void {
|
|
165
|
-
if (this.componentRef) {
|
|
166
|
-
this.componentRef.destroy();
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|