@copilotkitnext/angular 0.0.17 → 0.0.19-alpha.0

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.
@@ -199,24 +199,17 @@ class RenderToolCalls {
199
199
  messages = input.required();
200
200
  isLoading = input(false);
201
201
  pickRenderer(name) {
202
- const messageAgentId = this.message()
203
- .agentId;
202
+ const messageAgentId = this.message().agentId;
204
203
  const renderers = this.#copilotKit.toolCallRenderConfigs();
205
204
  const clientTools = this.#copilotKit.clientToolCallRenderConfigs();
206
205
  const humanInTheLoopTools = this.#copilotKit.humanInTheLoopToolRenderConfigs();
207
- const renderer = renderers.find((candidate) => candidate.name === name &&
208
- (candidate.agentId === undefined ||
209
- candidate.agentId === messageAgentId));
206
+ const renderer = renderers.find((candidate) => candidate.name === name && (candidate.agentId === undefined || candidate.agentId === messageAgentId));
210
207
  if (renderer)
211
208
  return { type: "renderer", config: renderer };
212
- const clientTool = clientTools.find((candidate) => candidate.name === name &&
213
- (candidate.agentId === undefined ||
214
- candidate.agentId === messageAgentId));
209
+ const clientTool = clientTools.find((candidate) => candidate.name === name && (candidate.agentId === undefined || candidate.agentId === messageAgentId));
215
210
  if (clientTool)
216
211
  return { type: "clientTool", config: clientTool };
217
- const humanInTheLoopTool = humanInTheLoopTools.find((candidate) => candidate.name === name &&
218
- (candidate.agentId === undefined ||
219
- candidate.agentId === messageAgentId));
212
+ const humanInTheLoopTool = humanInTheLoopTools.find((candidate) => candidate.name === name && (candidate.agentId === undefined || candidate.agentId === messageAgentId));
220
213
  if (humanInTheLoopTool)
221
214
  return { type: "humanInTheLoopTool", config: humanInTheLoopTool };
222
215
  const starRenderer = renderers.find((candidate) => candidate.name === "*");
@@ -278,18 +271,16 @@ class RenderToolCalls {
278
271
  }
279
272
  }
280
273
  #getToolMessage(toolCallId) {
281
- return this.messages().find((m) => m.role === "tool" && m.toolCallId === toolCallId);
274
+ const message = this.messages().find((m) => m.role === "tool" && m.toolCallId === toolCallId);
275
+ return message;
282
276
  }
283
277
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RenderToolCalls, deps: [], target: i0.ɵɵFactoryTarget.Component });
284
278
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: RenderToolCalls, isStandalone: true, selector: "copilot-render-tool-calls", inputs: { message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: true, transformFunction: null }, messages: { classPropertyName: "messages", publicName: "messages", isSignal: true, isRequired: true, transformFunction: null }, isLoading: { classPropertyName: "isLoading", publicName: "isLoading", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
285
279
  @for (toolCall of message().toolCalls ?? []; track toolCall.id) {
286
280
  @let renderConfig = pickRenderer(toolCall.function.name);
287
- @if (renderConfig && renderConfig.type !== "humanInTheLoopTool") {
281
+ @if (renderConfig && renderConfig.type !== "humanInTheLoopTool" && renderConfig.config.component) {
288
282
  <ng-container
289
- *ngComponentOutlet="
290
- renderConfig.config.component;
291
- inputs: { toolCall: buildToolCall(toolCall) }
292
- "
283
+ *ngComponentOutlet="renderConfig.config.component; inputs: { toolCall: buildToolCall(toolCall) }"
293
284
  />
294
285
  }
295
286
  }
@@ -304,12 +295,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
304
295
  template: `
305
296
  @for (toolCall of message().toolCalls ?? []; track toolCall.id) {
306
297
  @let renderConfig = pickRenderer(toolCall.function.name);
307
- @if (renderConfig && renderConfig.type !== "humanInTheLoopTool") {
298
+ @if (renderConfig && renderConfig.type !== "humanInTheLoopTool" && renderConfig.config.component) {
308
299
  <ng-container
309
- *ngComponentOutlet="
310
- renderConfig.config.component;
311
- inputs: { toolCall: buildToolCall(toolCall) }
312
- "
300
+ *ngComponentOutlet="renderConfig.config.component; inputs: { toolCall: buildToolCall(toolCall) }"
313
301
  />
314
302
  }
315
303
  }
@@ -2930,23 +2918,13 @@ class CopilotChatUserMessageBranchNavigation {
2930
2918
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: CopilotChatUserMessageBranchNavigation, isStandalone: true, selector: "copilot-chat-user-message-branch-navigation", inputs: { currentBranch: { classPropertyName: "currentBranch", publicName: "currentBranch", isSignal: true, isRequired: false, transformFunction: null }, numberOfBranches: { classPropertyName: "numberOfBranches", publicName: "numberOfBranches", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, inputClass: { classPropertyName: "inputClass", publicName: "inputClass", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { switchToBranch: "switchToBranch" }, ngImport: i0, template: `
2931
2919
  @if (showNavigation()) {
2932
2920
  <div [class]="computedClass()">
2933
- <button
2934
- type="button"
2935
- [class]="buttonClass"
2936
- [disabled]="!canGoPrev()"
2937
- (click)="handlePrevious()"
2938
- >
2921
+ <button type="button" [class]="buttonClass" [disabled]="!canGoPrev()" (click)="handlePrevious()">
2939
2922
  <lucide-angular [img]="ChevronLeftIcon" [size]="20"></lucide-angular>
2940
2923
  </button>
2941
2924
  <span class="text-sm text-muted-foreground px-0 font-medium">
2942
2925
  {{ currentBranch() + 1 }}/{{ numberOfBranches() }}
2943
2926
  </span>
2944
- <button
2945
- type="button"
2946
- [class]="buttonClass"
2947
- [disabled]="!canGoNext()"
2948
- (click)="handleNext()"
2949
- >
2927
+ <button type="button" [class]="buttonClass" [disabled]="!canGoNext()" (click)="handleNext()">
2950
2928
  <lucide-angular [img]="ChevronRightIcon" [size]="20"></lucide-angular>
2951
2929
  </button>
2952
2930
  </div>
@@ -2964,23 +2942,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
2964
2942
  template: `
2965
2943
  @if (showNavigation()) {
2966
2944
  <div [class]="computedClass()">
2967
- <button
2968
- type="button"
2969
- [class]="buttonClass"
2970
- [disabled]="!canGoPrev()"
2971
- (click)="handlePrevious()"
2972
- >
2945
+ <button type="button" [class]="buttonClass" [disabled]="!canGoPrev()" (click)="handlePrevious()">
2973
2946
  <lucide-angular [img]="ChevronLeftIcon" [size]="20"></lucide-angular>
2974
2947
  </button>
2975
2948
  <span class="text-sm text-muted-foreground px-0 font-medium">
2976
2949
  {{ currentBranch() + 1 }}/{{ numberOfBranches() }}
2977
2950
  </span>
2978
- <button
2979
- type="button"
2980
- [class]="buttonClass"
2981
- [disabled]="!canGoNext()"
2982
- (click)="handleNext()"
2983
- >
2951
+ <button type="button" [class]="buttonClass" [disabled]="!canGoNext()" (click)="handleNext()">
2984
2952
  <lucide-angular [img]="ChevronRightIcon" [size]="20"></lucide-angular>
2985
2953
  </button>
2986
2954
  </div>
@@ -2989,6 +2957,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
2989
2957
  }]
2990
2958
  }] });
2991
2959
 
2960
+ function flattenUserMessageContent(content) {
2961
+ if (!content) {
2962
+ return "";
2963
+ }
2964
+ if (typeof content === "string") {
2965
+ return content;
2966
+ }
2967
+ return content
2968
+ .map((part) => {
2969
+ if (part &&
2970
+ typeof part === "object" &&
2971
+ "type" in part &&
2972
+ part.type === "text" &&
2973
+ typeof part.text === "string") {
2974
+ return part.text;
2975
+ }
2976
+ return "";
2977
+ })
2978
+ .filter((text) => text.length > 0)
2979
+ .join("\n");
2980
+ }
2992
2981
  class CopilotChatUserMessage {
2993
2982
  // Capture templates from content projection
2994
2983
  messageRendererTemplate;
@@ -3030,8 +3019,9 @@ class CopilotChatUserMessage {
3030
3019
  showBranchNavigation = computed(() => (this.numberOfBranches() ?? 1) > 1);
3031
3020
  computedClass = computed(() => cn("flex flex-col items-end group pt-10", this.inputClass()));
3032
3021
  // Context for slots (reactive via signals)
3022
+ flattenedContent = computed(() => flattenUserMessageContent(this.message()?.content));
3033
3023
  messageRendererContext = computed(() => ({
3034
- content: this.message()?.content || "",
3024
+ content: this.flattenedContent(),
3035
3025
  }));
3036
3026
  // Output maps for slots
3037
3027
  copyButtonOutputs = { clicked: () => this.handleCopy() };
@@ -3068,10 +3058,7 @@ class CopilotChatUserMessage {
3068
3058
  >
3069
3059
  </copilot-slot>
3070
3060
  } @else {
3071
- <copilot-chat-user-message-renderer
3072
- [content]="message()?.content || ''"
3073
- [inputClass]="messageRendererClass()"
3074
- >
3061
+ <copilot-chat-user-message-renderer [content]="flattenedContent()" [inputClass]="messageRendererClass()">
3075
3062
  </copilot-chat-user-message-renderer>
3076
3063
  }
3077
3064
 
@@ -3088,23 +3075,21 @@ class CopilotChatUserMessage {
3088
3075
  <div class="flex items-center gap-1 justify-end">
3089
3076
  <!-- Additional toolbar items -->
3090
3077
  @if (additionalToolbarItems()) {
3091
- <ng-container
3092
- [ngTemplateOutlet]="additionalToolbarItems() || null"
3093
- ></ng-container>
3078
+ <ng-container [ngTemplateOutlet]="additionalToolbarItems() || null"></ng-container>
3094
3079
  }
3095
3080
 
3096
3081
  <!-- Copy button -->
3097
3082
  @if (copyButtonTemplate || copyButtonComponent()) {
3098
3083
  <copilot-slot
3099
3084
  [slot]="copyButtonTemplate || copyButtonComponent()"
3100
- [context]="{ content: message()?.content || '' }"
3085
+ [context]="{ content: flattenedContent() }"
3101
3086
  [outputs]="copyButtonOutputs"
3102
3087
  [defaultComponent]="CopilotChatUserMessageCopyButton"
3103
3088
  >
3104
3089
  </copilot-slot>
3105
3090
  } @else {
3106
3091
  <copilot-chat-user-message-copy-button
3107
- [content]="message()?.content"
3092
+ [content]="flattenedContent()"
3108
3093
  [inputClass]="copyButtonClass()"
3109
3094
  (clicked)="handleCopy()"
3110
3095
  >
@@ -3122,10 +3107,7 @@ class CopilotChatUserMessage {
3122
3107
  >
3123
3108
  </copilot-slot>
3124
3109
  } @else {
3125
- <copilot-chat-user-message-edit-button
3126
- [inputClass]="editButtonClass()"
3127
- (clicked)="handleEdit()"
3128
- >
3110
+ <copilot-chat-user-message-edit-button [inputClass]="editButtonClass()" (clicked)="handleEdit()">
3129
3111
  </copilot-chat-user-message-edit-button>
3130
3112
  }
3131
3113
  }
@@ -3134,9 +3116,7 @@ class CopilotChatUserMessage {
3134
3116
  @if (showBranchNavigation()) {
3135
3117
  @if (branchNavigationTemplate || branchNavigationComponent()) {
3136
3118
  <copilot-slot
3137
- [slot]="
3138
- branchNavigationTemplate || branchNavigationComponent()
3139
- "
3119
+ [slot]="branchNavigationTemplate || branchNavigationComponent()"
3140
3120
  [context]="branchNavigationContext()"
3141
3121
  [defaultComponent]="CopilotChatUserMessageBranchNavigation"
3142
3122
  >
@@ -3179,10 +3159,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
3179
3159
  >
3180
3160
  </copilot-slot>
3181
3161
  } @else {
3182
- <copilot-chat-user-message-renderer
3183
- [content]="message()?.content || ''"
3184
- [inputClass]="messageRendererClass()"
3185
- >
3162
+ <copilot-chat-user-message-renderer [content]="flattenedContent()" [inputClass]="messageRendererClass()">
3186
3163
  </copilot-chat-user-message-renderer>
3187
3164
  }
3188
3165
 
@@ -3199,23 +3176,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
3199
3176
  <div class="flex items-center gap-1 justify-end">
3200
3177
  <!-- Additional toolbar items -->
3201
3178
  @if (additionalToolbarItems()) {
3202
- <ng-container
3203
- [ngTemplateOutlet]="additionalToolbarItems() || null"
3204
- ></ng-container>
3179
+ <ng-container [ngTemplateOutlet]="additionalToolbarItems() || null"></ng-container>
3205
3180
  }
3206
3181
 
3207
3182
  <!-- Copy button -->
3208
3183
  @if (copyButtonTemplate || copyButtonComponent()) {
3209
3184
  <copilot-slot
3210
3185
  [slot]="copyButtonTemplate || copyButtonComponent()"
3211
- [context]="{ content: message()?.content || '' }"
3186
+ [context]="{ content: flattenedContent() }"
3212
3187
  [outputs]="copyButtonOutputs"
3213
3188
  [defaultComponent]="CopilotChatUserMessageCopyButton"
3214
3189
  >
3215
3190
  </copilot-slot>
3216
3191
  } @else {
3217
3192
  <copilot-chat-user-message-copy-button
3218
- [content]="message()?.content"
3193
+ [content]="flattenedContent()"
3219
3194
  [inputClass]="copyButtonClass()"
3220
3195
  (clicked)="handleCopy()"
3221
3196
  >
@@ -3233,10 +3208,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
3233
3208
  >
3234
3209
  </copilot-slot>
3235
3210
  } @else {
3236
- <copilot-chat-user-message-edit-button
3237
- [inputClass]="editButtonClass()"
3238
- (clicked)="handleEdit()"
3239
- >
3211
+ <copilot-chat-user-message-edit-button [inputClass]="editButtonClass()" (clicked)="handleEdit()">
3240
3212
  </copilot-chat-user-message-edit-button>
3241
3213
  }
3242
3214
  }
@@ -3245,9 +3217,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
3245
3217
  @if (showBranchNavigation()) {
3246
3218
  @if (branchNavigationTemplate || branchNavigationComponent()) {
3247
3219
  <copilot-slot
3248
- [slot]="
3249
- branchNavigationTemplate || branchNavigationComponent()
3250
- "
3220
+ [slot]="branchNavigationTemplate || branchNavigationComponent()"
3251
3221
  [context]="branchNavigationContext()"
3252
3222
  [defaultComponent]="CopilotChatUserMessageBranchNavigation"
3253
3223
  >